This package provides a single AgentDock runtime for backend applications. Product-specific tools, prompts, authorization, and persistence stay in the consuming app.
Runs belong to a required sessionId. AgentDock loads and updates the session's
conversation messages through the injected store; callers do not need
to manually pass message history between runs. The default in-memory stores are
process-local and can be replaced with database-backed implementations.
✨ Features
- Agent Runtime: Run, stream, resume approvals, and cancel agent runs.
- Typed Events: Provider-independent events for live clients.
- Tool Registry: Register and manage tools per
AgentDockinstance. - Run State: Inject in-memory or durable run persistence.
- Provider Helpers: Built-in helpers for AI SDK providers such as OpenRouter.
- TypeScript First: Fully typed for safe, scalable, and rapid development.
🚀 Setup
Install the dependencies and build the package:
yarn install
yarn build
💻 Local Development
Run the TypeScript compiler in watch mode:
yarn dev
📦 Build And Package
To perform typechecking, create a clean build, and package the artifact:
yarn typecheck
yarn build
yarn pack:artifact
Note:
yarn pack:artifactcreatesagentdock.tgz. The package lifecycle runs a clean build before packing, so the artifact is always created from the current source.
🛠️ Usage
Create one configured AgentDock instance for your backend application:
import {
AgentDock,
AgentModelFactory,
ToolRegistry,
InMemoryAgentStore,
} from "agentdock";
const modelFactory = new AgentModelFactory();
const sessionId = "session-123";
const agent = new AgentDock({
model: modelFactory.create({
provider: "openrouter",
modelId: "your-model-id",
}),
registry: new ToolRegistry(),
store: new InMemoryAgentStore(),
defaults: {
systemPrompt: "You are a helpful assistant. Use registered tools when appropriate.",
},
});
agent.registerTool({
name: "get_weather",
description: "Get the current weather for a city.",
parameters: {
type: "object",
properties: { city: { type: "string" } },
required: ["city"],
additionalProperties: false,
},
execute: async ({ input }) => ({ city: input.city, temperature: 22 }),
});
const result = await agent.run(
"What is the weather in Lahore?",
{ userId: "user-123" },
{ sessionId },
);
systemPrompt belongs inside defaults when it should apply to every run
created by the AgentDock instance. It can also be overridden for one run:
const result = await agent.run(
"Answer concisely.",
{ userId: "user-123" },
{
sessionId,
systemPrompt: "Use one short sentence.",
},
);
systemPrompt is not a top-level AgentDock constructor option.
For live output, consume the normalized AgentDock event stream:
import { AgentEventType } from "agentdock";
const session = await agent.stream(
"What is the weather in Lahore?",
{ userId: "user-123" },
{ sessionId },
);
for await (const event of session.stream) {
if (event.type === AgentEventType.TextDelta) {
process.stdout.write(event.text);
}
}
const result = await session.result;
Provider selection
AgentModelFactory pr
