aricode now ships a real in-process Node SDK. Create sessions, stream structured events, register custom tools, and keep session state under your application's control.
The public SDK is intentionally narrow: Node-only, async-iterator-first, and built around host-managed session state.
Create a reusable client, then spawn isolated sessions for each conversation or workflow branch.
createAriadne(...)
client.createSession(...)
session.run(...)
Quick start
Consume `message.delta`, `tool.call`, `approval.required`, `usage`, and `turn.completed` over a single async iterator.
for await (const event of session.run(task)) {
...
}
Event model
Register application-specific tools with `defineTool(...)` and `createToolRegistry(...)` while keeping aricode's built-ins available.
defineTool(...)
createToolRegistry([...])
Custom tools
The package root now exports the SDK directly. New integrations should use the aricode package and the createAricode(...) factory. Legacy createAriadne(...) aliases remain available for compatibility.
Install aricode once. The same package ships the CLI binaries and the SDK runtime.
npm install aricode
Provide model and backend config once at client construction, then create one or more isolated sessions.
import { createAricode } from "aricode";
const client = createAricode({
model: "glm-5",
baseUrl: "http://localhost:11434/v1",
});
const session = client.createSession({
cwd: process.cwd(),
});
Runs stream structured events with `for await`, which works equally well in CLIs, servers, and desktop apps.
for await (const event of session.run("Read package.json and summarize the scripts.")) {
if (event.type === "message.delta") {
process.stdout.write(event.delta);
}
if (event.type === "tool.call") {
console.log("tool", event.name, event.args);
}
}
The async iterator is the primary runtime interface in v1. aricode emits structured events instead of requiring callback orchestration.
message.delta streams partial text, and message.completed marks the full assistant message for a turn.
tool.call, tool.result, and turn.completed show exactly how the engine progressed.
status, usage, warning, error, approval.required, and approval.resolved cover control flow and safety.
The public tool SDK is part of the first release. Define tools once, register them in a registry, and pass that registry into the client or session.
import { createAricode, createToolRegistry, defineTool } from "aricode";
const tools = createToolRegistry([
defineTool({
name: "lookup_ticket",
schema: {
name: "lookup_ticket",
description: "Look up a ticket by id.",
parameters: {
type: "object",
properties: {
id: { type: "string" },
},
required: ["id"],
},
},
async execute(args) {
return { result: `ticket:${args.id}` };
},
metadata: {
sideEffects: "none",
permissionTier: "readonly",
concurrentSafe: true,
category: "plugin",
kind: "tool",
idempotent: true,
cancellable: false,
streaming: false,
timeoutMs: 0,
requiresApproval: false,
},
}),
]);
const client = createAricode({
model: "glm-5",
baseUrl: "http://localhost:11434/v1",
toolRegistry: tools,
});
The SDK defaults to in-memory host-managed state. Persist snapshots yourself, or use the included workspace adapter if you want aricode-style on-disk sessions.
InMemorySessionStore ships by default and keeps the SDK free of filesystem assumptions.
session.snapshot() returns serializable state and session.restore(state) rehydrates it later.
WorkspaceSessionStore bridges the SDK into aricode's existing workspace session model for internal product use.