@agentdock-ai/agentdock
v0.1.1
Published
An easy-to-use TypeScript wrapper around LangGraph for building AI agents.
Readme
Agentdock gives TypeScript applications a focused runtime for model calls, typed tools, approvals, sessions, persistence, streaming, and lifecycle control. LangChain and LangGraph run internally; application code uses the Agentdock API.
✨ What you get
- Agent runtime: one
AgentDockclass for runs, streams, and resumes. - Typed tools: validation, authorization, progress, cancellation, and approvals.
- Durable sessions: memory, SQLite, PostgreSQL, MongoDB, and Redis adapters.
- Normalized events: one frontend-friendly contract for text, tools, usage, and interrupts.
- Safe lifecycle: timeouts, cancellation, cleanup, and owned resource management.
🚀 Install
yarn add @agentdock-ai/agentdock @agentdock-ai/models zod💻 Quick start
import { AgentDock, 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 agent = new AgentDock({
model: AgentDockModel.openAI({ model: "gpt-5.4-mini" }),
});
agent.registerTool(weather);
try {
const result = await agent.run(
"What is the weather in Lahore?",
{ userId: "user-123" },
{ sessionId: "session-123" },
);
console.log(result.content);
} finally {
await agent.close();
}Use agent.stream() when the UI should receive 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);🧠 Sessions and approvals
Pass a stable sessionId to continue a conversation. Use a durable checkpoint
adapter when sessions must survive restarts or be shared across instances:
yarn add @agentdock-ai/checkpoint-postgresimport { PostgresCheckpoint } from "@agentdock-ai/checkpoint-postgres";
const agent = new AgentDock({
model,
checkpoint: new PostgresCheckpoint({
connectionString: process.env.DATABASE_URL!,
}),
});Set requiresApproval: true on a side-effecting tool. Agentdock pauses the run,
persists the interrupt, and resumes it with agent.resume() after approval.
📚 Useful APIs
| API | Use it for |
| --------------------- | --------------------------------------------------- |
| run() | Execute a prompt and receive one result. |
| stream() | Consume normalized events while a run is executing. |
| resume() | Continue a paused approval run. |
| getSession() | Read the current normalized message state. |
| getSessionHistory() | Inspect checkpoint-by-checkpoint history. |
| deleteSession() | Remove a session’s checkpoint context. |
| close() | Stop active work and release owned resources. |
🔗 Related packages
@agentdock-ai/models— provider configuration.@agentdock-ai/contracts— framework-independent events and data types.@agentdock-ai/checkpoint— checkpoint contract and memory adapter.
📄 License
MIT. See the repository license.
