Production-oriented TypeScript infrastructure for streamed, tool-using agents.
Agentdock gives a TypeScript application the runtime it needs to build a real agent: model calls, typed tools, approvals, sessions, persistence, streaming events, and lifecycle control.
The public API belongs to Agentdock. Applications configure providers through @agentdock-ai/models and use Agentdock’s runtime and contracts. LangChain and LangGraph run the model and workflow internally; application code does not need to import provider classes from LangChain.
Create the runtime with the AgentDock class. This is the only AgentDock agent
construction API. defineTool() is a typed tool-definition helper; it does not
create another agent runtime or execution path.
- Typed agent runtime: create an agent with the
AgentDockclass. - Provider configuration: configure OpenAI, Ollama, or OpenRouter with
AgentDockModel. - Typed tools: define tools with Zod using
defineTool(), validate input, report progress, and receive an abort signal. - Tool registry: register, inspect, and update tools at runtime.
- Approvals and authorization: pause side effects for approval and check whether a user may call a tool before and during execution.
- Streaming events: consume one normalized event contract for text, reasoning, media, tool calls, progress, usage, interrupts, and terminal states.
- Sessions: continue conversations by
sessionId, partition shared storage withsessionNamespace, read history, and delete sessions safely. - Durable checkpoints: use in-memory storage for development or SQLite, PostgreSQL, MongoDB, and Redis Stack for persistence.
- Context management: opt in to conversation summarization when long sessions approach the model’s input limit.
- Run control: set step and timeout limits, cancel active runs, resume approvals, and close resources cleanly.
- Framework-independent contracts: share JSON-compatible events and run data between servers, frontends, and transports.
- Frontend-ready output: normalized messages and content parts are designed for React and other clients.
| Package | Purpose |
|---|---|
@agentdock-ai/agentdock |
Core runtime for models, tools, runs, approvals, sessions, streaming, and lifecycle. |
@agentdock-ai/models |
Application-facing provider configuration for OpenAI, Ollama, and OpenRouter. Requires Node.js 22+. |
@agentdock-ai/contracts |
Framework-independent JSON data contracts, event types, content parts, and event reducer. |
@agentdock-ai/checkpoint |
Checkpoint adapter contract and the process-local memory adapter. |
@agentdock-ai/checkpoint-sqlite |
SQLite persistence for local applications and single-server deployments. |
@agentdock-ai/checkpoint-postgres |
PostgreSQL persistence for shared production deployments. |
@agentdock-ai/checkpoint-mongodb |
MongoDB persistence for applications using MongoDB. |
@agentdock-ai/checkpoint-redis |
Redis Stack persistence for fast shared storage and TTL-based retention. |
The core runtime is intentionally separate from the React package. For a ready-made chat surface, see agentdock-ui.
For the normal application path:
npm install @agentdock-ai/agentdock @agentdock-ai/models zodUse Node.js 20 or newer for the core runtime. The @agentdock-ai/models package requires Node.js 22 or newer.
Set your provider key on the server, then create a model, define a tool, and run the agent:
import { AgentDock, ToolRegistry, defineTool } from "@agentdock-ai/agentdock";
import { AgentDockModel } from "@agentdock-ai/models";
import { z } from "zod";
const weather = defineTool({
name: "get_weather",
description: "Get the weather for a city.",
input: z.object({ city: z.string() }),
run: async ({ city }) => ({ city, forecast: "Sunny" }),
});
const registry = new ToolRegistry();
registry.register(weather);
const agent = new AgentDock({
model: AgentDockModel.openAI({ model: "gpt-5.4-mini" }),
defaults: {
systemPrompt: "Answer clearly and use the weather tool when it helps.",
},
registry,
});
try {
const result = await agent.run(
"What is the weather in Lahore?",
{ userId: "user-123" },
{ sessionId: "session-123" },
);
const answer = result.content
.filter((part) => part.type === "text")
.map((part) => part.text)
.join("");
console.log(answer);
} finally {
await agent.close();
}get_weather is an application-defined example tool. Agentdock does not provide a weather service; replace its run function with your own API or business logic.
Every run has a sessionId and a JSON context object. Use agent.stream() when the application should show text and tool activity as it arrives:
const { stream, result } = await agent.stream(
"Summarize my latest order.",
{ userId: "user-123" },
{ sessionId: "session-123" },
);
for await (const event of stream) {
if (event.type === "message.part.delta" && event.part.type === "text") {
process.stdout.write(event.part.text);
}
}
console.log(await result);The default checkpoint is process-local memory. Use an adapter when conversations must survive restarts or be shared across application instances:
npm install @agentdock-ai/checkpoint-postgresimport { PostgresCheckpoint } from "@agentdock-ai/checkpoint-postgres";
const agent = new AgentDock({
model,
checkpoint: new PostgresCheckpoint({
connectionString: process.env.DATABASE_URL!,
}),
});Authorize every run, resume, read, history, and delete request in your application. Use a stable sessionNamespace when multiple applications or tenants share one checkpoint store.
Agentdock owns the application contract:
- tool definitions and validation;
- authorization and approval policy;
- normalized events and run results;
- session and checkpoint lifecycle;
- cancellation, timeouts, and resource cleanup.
Your application owns provider credentials, user authentication, session access rules, infrastructure, and external side effects. Keep model keys on the server and make every side-effecting tool idempotent in the host system.
This repository is a Yarn workspace. Use Node.js 20 or newer:
yarn install
yarn ciRun a single package while developing:
yarn workspace @agentdock-ai/agentdock test
yarn workspace @agentdock-ai/agentdock typecheck
yarn workspace @agentdock-ai/checkpoint buildThe full workspace commands are:
yarn format:check
yarn typecheck
yarn build
yarn testAll packages are MIT licensed and designed to be usable in open-source and commercial applications. Versions are managed with Changesets:
yarn changeset
yarn version-packages
yarn releaseThe repository is currently pre-1.0, so public APIs may continue to evolve before the first stable release.
agentdock-ui: React components and hooks for displaying Agentdock event streams.
MIT. Use Agentdock in open-source and commercial software. Your application remains responsible for its own providers, infrastructure, security, and dependency obligations.
