StackMap
Subscribe
Explore / agentdock
agentdock-ai

agentdock

TypeScript library giving a backend one agent runtime: session-scoped runs with streaming, approvals and cancel, a tool registry, injectable stores and a factory over nine AI SDK providers.

6 2 TypeScript MITupdated 3 days ago
View on GitHubDispute this mapping →
Curator's take

A deliberately thin agent loop for Node backends. The one decision worth copying is that sessions own their message history through an injected store, so a multi-tenant app stops threading transcripts through every call site. Set expectations accordingly: v0.1.0, single-digit stars, in-memory defaults, and it is a wrapper over the Vercel AI SDK, so anything the SDK cannot do it cannot do either. Use it if you want a runtime small enough to read end to end; use a real harness if you want planning, sub-agents, sandboxes or memory.

Mapped by ShipWithAI editors · links verified
README.md
AgentDock Logo

Reusable TypeScript agent infrastructure for multi-tenant applications.

version TypeScript Node.js License


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 AgentDock instance.
  • 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:artifact creates agentdock.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

Continue your stack

What teams reach for next — and why each earns a place beside agentdock. Ranked by curator confidence.