API Reference
Complete reference for the delta-agents public API
createDeltaEngine
The single factory that assembles the engine. Returns a Promise<DeltaEngine>.
import { createDeltaEngine } from "delta-agents";
const delta = await createDeltaEngine(config: DeltaEngineConfig);DeltaEngine
The unified facade for authoring and runtime operations.
Authoring methods
delta.action(def)
Define an executable operation. Validated and registered immediately.
const action = delta.action(def: Action): Actiondelta.workflow(def)
Define an ordered procedure composed of phases.
const workflow = delta.workflow(def: Workflow): Workflowdelta.agent(def)
Define a role with its allowed actions, workflows, and data sources.
const agent = delta.agent(def: Agent): Agentdelta.dataSource(def)
Define a named, owned store of governed CRUD operations. See Data sources for usage.
const ds = delta.dataSource(def: DataSource): DataSourceRuntime methods
delta.deploy(agent)
Mark a defined agent as active. The agent must already be registered via delta.agent().
delta.deploy(agent: Agent): voiddelta.send(input)
Hand a goal to a named agent and drive execution to completion or until blocked. Creates a new TaskID, runs the reasoner loop through governance checks, and returns the terminal result.
const result = await delta.send(input: SendInput): Promise<Result<SendResult, string>>SendResult.status is one of: "completed" | "failed" | "blocked" | "queued" | "pendingCommit".
When the agent is already busy, returns "queued": no new task is created, and the goal is queued as a message on the existing task.
delta.approve(approvalId)
Approve a pending human approval request. After approving, call delta.resume(taskId) to continue a blocked task.
const approval = await delta.approve(approvalId: string): Promise<Result<ApprovalRequest, string>>delta.reject(approvalId)
Reject a pending human approval request. The action stays permanently blocked: the engine never re-opens a rejected approval.
const approval = await delta.reject(approvalId: string): Promise<Result<ApprovalRequest, string>>delta.pause(taskId)
Suspend a running task and save its current state as a checkpoint.
await delta.pause(taskId: string): Promise<Result<void, string>>delta.resume(taskId)
Resume a paused or blocked task from its latest checkpoint.
const result = await delta.resume(taskId: string): Promise<Result<SendResult, string>>delta.inspect(taskId)
Read the full governance state for a task.
const state = await delta.inspect(taskId: string): Promise<Result<InspectResult, string>>Returns task record, execution history, latest checkpoint, escalations, and pending approvals.
delta.lastTask(agentName)
Return the most recent task for a named agent. No need to store TaskIDs.
const task = await delta.lastTask(agentName: string): Promise<Result<Task | null, string>>delta.roster(query?)
Team-awareness read-model: who is doing what and how loaded each agent is.
const roster = await delta.roster(query?: { team?: string }): Promise<Result<RosterEntry[], string>>delta.inbox(args)
An agent's inbox: messages addressed to it, unread first then oldest-first.
const messages = await delta.inbox(args: { agent: string }): Promise<Result<Message[], string>>delta.outbox(args)
An agent's outbox: messages it sent, newest first.
const messages = await delta.outbox(args: { agent: string }): Promise<Result<Message[], string>>delta.unsend(args)
Unsend a message, allowed only while unread.
const message = await delta.unsend(args: { messageId: string }): Promise<Result<Message, string>>delta.cleanup(options?)
Manually prune old tasks and messages past retention windows.
await delta.cleanup(options?: CleanupOptions): Promise<Result<void, string>>Events
delta.events
Subscribe to engine events with typed payloads. Each event name maps to a specific payload shape so subscribers receive correctly typed data without casting. Every event carries a timestamp (ms since epoch) and agentName in the envelope, so consumers no longer need to join against delta.inspect() for time and agent context.
// Subscribe. Returns an unsubscribe function
const unsub = delta.events.on("approval-requested", (data) => {
// data is typed as { taskId: string; action: string; approvalId: string; reason: string; timestamp: number; agentName: string }
console.log(`${data.agentName} at ${new Date(data.timestamp)}: ${data.action} needs approval`);
});
// Unsubscribe when no longer needed
unsub();
// Remove a specific handler
delta.events.off("approval-requested", handler);Available event types: approval-requested, approval-resolved, escalation-raised, task-completed, task-blocked, task-failed, step-start, step-end, action-start, action-end, commit-step-attempt, commit-step-done, commit-step-auto-commit.
delta.tools.invoke(args)
Direct developer-facing invocation for any registered tool (builtin or custom). Does not record tool history or apply loop or budget governance.
const result = await delta.tools.invoke(args: InvokeArgs): Promise<Result<unknown, string>>Adapter factories
createInMemoryStore()
Create an in-memory storage adapter. Default when no store is configured.
import { createInMemoryStore } from "delta-agents";
const store = createInMemoryStore();createDrizzleStore(config)
Create a persistent SQLite storage adapter using Drizzle ORM.
import { createDrizzleStore } from "delta-agents";
const store = createDrizzleStore({ client, schema });createMockReasoner(options?)
Create a mock reasoner for testing.
import { createMockReasoner } from "delta-agents";
const reasoner = createMockReasoner({ respondWith: ... });createChatSdkChannel(config)
Create a channel adapter using the Chat SDK for multi-platform messaging.
import { createChatSdkChannel } from "delta-agents";
const channel = createChatSdkChannel({ type: "slack", adapter: slackAdapter });Attachment loaders
loadAttachmentFromFile(path)
Read a local file and return an AttachmentInput with base64-encoded data.
const attachment = await loadAttachmentFromFile(path: string): Promise<Result<AttachmentInput, string>>loadAttachmentFromUrl(url)
Fetch a remote URL and return an AttachmentInput with base64-encoded data.
const attachment = await loadAttachmentFromUrl(url: string): Promise<Result<AttachmentInput, string>>Result utilities
Re-exported from slang-ts:
import { Ok, Err, option, match, safeTry, pipe } from "delta-agents";