|
1 | 1 | # @agent-dispatch/core |
2 | 2 |
|
3 | | -Provider-neutral runtime contracts and dispatch orchestration for AgentDispatch. |
| 3 | +[](https://www.npmjs.com/package/@agent-dispatch/core) |
| 4 | +[](https://www.npmjs.com/package/@agent-dispatch/core) |
4 | 5 |
|
5 | | -This package is the compatibility anchor for all AgentDispatch repositories. Cloud adapters, stores, SDKs, CLIs, and MCP servers depend on these interfaces; `@agent-dispatch/core` does not depend on any adapter package. |
| 6 | +Provider-neutral runtime primitives for AgentDispatch: the MCP control plane that lets a lead agent spawn, monitor, and interact with cloud subagents without binding itself to one cloud API. |
6 | 7 |
|
7 | | -## Core concepts |
| 8 | +## Why this package exists |
8 | 9 |
|
9 | | -- Providers: `aws`, `gcp`, `azure`, `kubernetes`, `local`, or future provider strings. |
10 | | -- Capabilities: `agent-runtime` in V1, with reserved support for `service-deploy`, `job-runner`, `container-task`, and `workflow-runner`. |
11 | | -- Tasks: durable work units with provider-neutral lifecycle state. |
12 | | -- Adapters: provider-specific implementations behind a stable `BackendAdapter` contract. |
13 | | -- Policies: provider-neutral authorization rules for account profiles, capabilities, task types, and target modes. |
14 | | -- Testing: `assertBackendAdapterContract` gives adapter repos a reusable conformance check. |
15 | | - |
16 | | -## Publishing |
| 10 | +Agents should not need to know whether a long-running task runs on AWS AgentCore, Cloud Run, Azure Container Apps, Kubernetes, or a local worker. They should ask for a capability, account profile, task type, and target. `@agent-dispatch/core` defines that stable contract and keeps every adapter compatible with the rest of the system. |
17 | 11 |
|
18 | 12 | See the [release workflow](https://github.com/agent-dispatch/core/blob/main/docs/release.md) for the npm publishing workflow and the dependency-order checklist for the separate `agent-dispatch` repositories. |
| 13 | + |
| 14 | +```mermaid |
| 15 | +flowchart LR |
| 16 | + A["Lead agent\n(OpenClaw, Hermes, Codex, Claude Code)"] --> B["AgentDispatch core"] |
| 17 | + B --> C["Backend adapter"] |
| 18 | + C --> D["Cloud runtime"] |
| 19 | + D --> E["Cloud subagent"] |
| 20 | +``` |
| 21 | + |
| 22 | +## What core owns |
| 23 | + |
| 24 | +- Provider-neutral models for `Provider`, `Capability`, `AccountProfile`, `Target`, `Task`, `Runtime`, `Session`, `Event`, and `Artifact`. |
| 25 | +- Adapter registration and routing by `provider + capability + task_type + target.mode`. |
| 26 | +- Durable task lifecycle orchestration with pluggable stores. |
| 27 | +- Runtime protocol metadata for A2A, MCP, AG-UI, and HTTP interaction planes. |
| 28 | +- Clarification-safe request validation so MCP servers can ask for missing runtime inputs before dispatch. |
| 29 | + |
| 30 | +## Adapter contract |
| 31 | + |
| 32 | +Every provider adapter implements the same shape: |
| 33 | + |
| 34 | +```ts |
| 35 | +interface BackendAdapter { |
| 36 | + provider: string; |
| 37 | + capabilities(): AdapterCapability[]; |
| 38 | + resolveTarget(request: DispatchRequest): Promise<ResolvedTarget>; |
| 39 | + provision(request: ProvisionRequest): Promise<ProvisionResult>; |
| 40 | + prepareTask?(request: PrepareTaskRequest): Promise<PrepareTaskResult>; |
| 41 | + startTask(request: StartTaskRequest): Promise<StartTaskResult>; |
| 42 | + streamEvents(taskId: string): AsyncIterable<RuntimeEvent>; |
| 43 | + cancel(taskId: string): Promise<CancelResult>; |
| 44 | + cleanup(target: RuntimeTarget): Promise<CleanupResult>; |
| 45 | +} |
| 46 | +``` |
| 47 | + |
| 48 | +Adapters translate provider-neutral requests into provider APIs, then return provider-neutral task handles, events, artifacts, and optional `cloudAgent` metadata. Provider-specific values stay in adapter config or `target.details`; the MCP server and SDK do not import provider SDK types. |
| 49 | + |
| 50 | +## Install |
| 51 | + |
| 52 | +```bash |
| 53 | +npm install @agent-dispatch/core |
| 54 | +``` |
| 55 | + |
| 56 | +## Example |
| 57 | + |
| 58 | +```ts |
| 59 | +import { RuntimeService } from "@agent-dispatch/core"; |
| 60 | + |
| 61 | +const runtime = new RuntimeService({ |
| 62 | + adapters: [awsAgentCoreAdapter], |
| 63 | + store, |
| 64 | + config |
| 65 | +}); |
| 66 | + |
| 67 | +const task = await runtime.dispatchTask({ |
| 68 | + provider: "aws", |
| 69 | + accountProfile: "dev-aws", |
| 70 | + capability: "agent-runtime", |
| 71 | + taskType: "agent.run", |
| 72 | + target: { mode: "session", protocol: "a2a" }, |
| 73 | + input: { |
| 74 | + instruction: "Analyze this repository and produce a migration plan." |
| 75 | + } |
| 76 | +}); |
| 77 | +``` |
| 78 | + |
| 79 | +## Package role |
| 80 | + |
| 81 | +`@agent-dispatch/core` is the compatibility anchor. All adapters depend on it. It depends on no adapters. If a future provider needs a new feature, the design goal is to extend core once and keep the agent-facing MCP tools stable. |
| 82 | + |
| 83 | +## Development |
| 84 | + |
| 85 | +```bash |
| 86 | +npm install |
| 87 | +npm run typecheck |
| 88 | +npm test |
| 89 | +npm run build |
| 90 | +``` |
0 commit comments