Skip to content

Commit b034675

Browse files
Nick Ficanoclaude
andcommitted
docs: align reference docs with current source
Cross-checked every doc against packages/* and corrected ~50 concrete drifts surfaced by an audit: - Replaced `client.state.sessionId` / `welcome.session_id` with `client.state.id` (the actual getter; session_id lives on the envelope, not the welcome payload). - Replaced every "Zod" reference with Effect Schema (no Zod dep exists in the workspace). - Corrected `SessionPhase` values to `opening | accepted | closing | rejected` everywhere; removed the fictional `pre-handshake/awaiting-welcome/closed` machine. - Removed `leaseConstraints.budgets` — budgets ride on `lease["cost.budget"]` as `currency:decimal` patterns. Updated jobs, leases, and errors guides accordingly. - Fixed `validateLeaseOp` signature to the real single-object form `{ lease, capability, target, ctx? }`. - Rewrote docs/cli.md to match the actual CLI flags (packages/sdk/src/cli.ts). - Fixed `startWebSocketServer` doc (no `path`/`allowedHosts`; those belong to `attachArcpUpgrade`). - Corrected OTel middleware doc: span names are `arcp.send <type>`/`arcp.recv <type>`, attributes match source, removed the false "heartbeats are filtered" claim. - Corrected runtime doc: `accept()` is sync, versioned agents use `registerAgentVersion`/`setDefaultAgentVersion`, file-layout matches the post-refactor module split. - Corrected client doc: `listJobs` filter uses `status: string[]`, `client.send()` does NOT auto-fill `session_id`. - Fixed CONFORMANCE.md spec link and refreshed file:line citations after the runtime refactor. - Removed dead CODE_OF_CONDUCT link from CONTRIBUTING.md. - Expanded CHANGELOG.md to record the v1.1 surface and feature flags shipped in 0.1.0. Coverage added: - New docs/effect.md — comprehensive map of the previously undocumented Effect-native surface (ARCPRuntimeLayer, ARCPClientLayer, JobService, EventLogService, tagged errors, OtelTracerLayer). Linked from docs/README.md. - Effect-shaped twins surfaced in architecture and each package page. - docs/README.md index now links the credentials guide. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 5a8765e commit b034675

32 files changed

Lines changed: 994 additions & 507 deletions

CHANGELOG.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12-
- Initial reference SDK release aligned with ARCP protocol v1.1 (see README status).
12+
- Initial reference SDK release aligned with ARCP protocol v1.1.
13+
- Wire envelopes carry `arcp: "1.1"` (`PROTOCOL_VERSION`).
14+
- v1.0 surface: sessions, jobs, leases, delegation, resume, idempotency,
15+
WebSocket / stdio / in-memory transports, bearer auth.
16+
- v1.1 features negotiated via `capabilities.features`: `heartbeat`, `ack`,
17+
`list_jobs`, `subscribe`, `lease_expires_at`, `cost.budget`, `progress`,
18+
`result_chunk`, `agent_versions`, `model.use`, `provisioned_credentials`.
19+
- v1.1 error codes: `AGENT_VERSION_NOT_AVAILABLE`, `LEASE_EXPIRED`,
20+
`BUDGET_EXHAUSTED` (15 codes total).
21+
- Packages: `@agentruntimecontrolprotocol/core`, `/client`, `/runtime`,
22+
`/sdk`, plus host middleware `/node`, `/express`, `/fastify`, `/hono`,
23+
`/bun`, and `/middleware-otel`.
24+
- Effect-native surface alongside the legacy Promise/class API
25+
(`ARCPRuntimeLayer`, `ARCPClientLayer`, `JobService`, `LoggerLayer`,
26+
etc.).

CONFORMANCE.md

Lines changed: 69 additions & 63 deletions
Large diffs are not rendered by default.

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
Thanks for your interest in improving the TypeScript SDK for ARCP. This
44
document covers how to report issues, propose changes, and get a change merged.
55

6-
By participating you agree to the [Code of Conduct](CODE_OF_CONDUCT.md).
6+
Be respectful — assume good intent, keep critique focused on the work, and
7+
flag conduct issues to the maintainers.
78

89
## Where changes belong
910

docs/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ go deeper into each subsystem.
1515
- [Architecture](./architecture.md) — how `@agentruntimecontrolprotocol/core`, `@agentruntimecontrolprotocol/client`, and `@agentruntimecontrolprotocol/runtime` fit together.
1616
- [Transports](./transports.md) — WebSocket, stdio, in-memory; when to pick each.
1717
- [CLI](./cli.md) — the `arcp` binary shipped by `@agentruntimecontrolprotocol/sdk`.
18+
- [Effect-native surface](./effect.md) — Layers, Services, and ManagedRuntime for Effect-shaped callers.
1819

1920
## Guides (one per spec section)
2021

@@ -26,6 +27,7 @@ go deeper into each subsystem.
2627
| [Jobs](./guides/jobs.md) | §7 |
2728
| [Job events](./guides/job-events.md) | §8 |
2829
| [Leases](./guides/leases.md) | §9 |
30+
| [Credentials](./guides/credentials.md) | §9.7–§9.8 |
2931
| [Delegation](./guides/delegation.md) | §10 |
3032
| [Observability](./guides/observability.md) | §11 |
3133
| [Errors](./guides/errors.md) | §12 |

docs/architecture.md

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
## Layering
99

1010
The SDK is a pnpm monorepo. Every package is ESM-only and strictly
11-
typed against TypeScript 5.6 with `exactOptionalPropertyTypes`.
11+
typed with `exactOptionalPropertyTypes`. The workspace pins
12+
TypeScript `^6.0.3`.
1213

1314
```
1415
@agentruntimecontrolprotocol/sdk — meta, re-exports the three below; ships `arcp` CLI
@@ -34,29 +35,41 @@ Middleware packages are optional adapters around `@agentruntimecontrolprotocol/c
3435
The shared kernel: nothing in here knows about being a client or a
3536
runtime. It exports:
3637

37-
- **Envelope schema**Zod definitions for every message type, plus
38-
`Envelope` as a discriminated union and helpers like `buildEnvelope()`,
39-
`messageEnvelope()`, `isPreSessionType()`.
38+
- **Envelope schema**Effect `Schema` definitions for every message
39+
type, plus `Envelope` as a discriminated union and helpers like
40+
`buildEnvelope()`, `messageEnvelope()`, `isPreSessionType()`.
4041
- **Branded IDs**`JobId`, `SessionId`, `MessageId`, `TraceId`, and
4142
`EventSeq` are brand types; you cannot mix them up by accident, and
4243
schema validation enforces format constraints (e.g., `TraceId` must
4344
be 32 lowercase hex chars).
44-
- **Error taxonomy** — one class per code in `ERROR_CODES`; the base
45-
is `ARCPError`. All errors carry a structured `ErrorPayload` for
46-
wire emission.
45+
- **Error taxonomy** — one class per code in `ERROR_CODES` (15 codes
46+
in v1.1); the base is `ARCPError`. All errors carry a structured
47+
`ErrorPayload` for wire emission. An Effect-tagged twin
48+
(`TaggedAgentNotAvailable`, etc.) lives in `errors-tagged.ts` for
49+
typed-error pipelines.
4750
- **Transports**`Transport` interface plus three implementations:
4851
`MemoryTransport` (pair via `pairMemoryTransports()`),
4952
`StdioTransport`, `WebSocketTransport` + `startWebSocketServer()`.
53+
Each also exposes an Effect-shaped twin
54+
(`memoryTransportEffect`, `stdioTransportEffect`,
55+
`websocketTransportEffect`) producing `Stream`-based incoming.
5056
- **Session state**`SessionState` is the phase machine
51-
(`pre-handshake``awaiting-welcome``accepted``closed`), and
57+
(`opening``accepted``closing | rejected`), and
5258
`PendingRegistry` tracks awaiting request/response correlations.
53-
- **Event log**`EventLog` interface with a SQLite-backed default
54-
for replay during resume (§6.3).
59+
`SessionStateService` is the Effect-shaped twin backed by a
60+
`SynchronizedRef` for concurrent fibers.
61+
- **Event log**`EventLog` class (SQLite-backed via
62+
`better-sqlite3`, defaults to `:memory:`) for replay during resume
63+
(§6.3). Effect-aware callers use `EventLogService` + `eventLogLayer`.
5564
- **Auth verifier**`BearerVerifier` interface and
56-
`StaticBearerVerifier` for tests.
57-
- **Capability negotiation**`negotiateCapabilities()` computes the
58-
intersection of advertised features, with `V1_1_FEATURES` as the
59-
default opt-in set.
65+
`StaticBearerVerifier` for tests, with `BearerVerifierService` and
66+
`staticBearerVerifierLayer` for Effect consumers.
67+
- **Capability negotiation**`negotiateCapabilities()` and
68+
`intersectFeatures()` compute the effective feature set, with
69+
`V1_1_FEATURES` as the default opt-in.
70+
- **Logging**`rootLogger` / `sessionLogger(parent, sessionId)` /
71+
`silentLogger` (pino), plus `PinoLogger` and `LoggerLayer` for
72+
Effect's logger.
6073

6174
See [packages/core.md](./packages/core.md).
6275

@@ -82,9 +95,18 @@ See [packages/client.md](./packages/client.md).
8295

8396
Two main classes: `ARCPServer` and `SessionContext`. `ARCPServer`
8497
holds the agent registry and shared resources (event log, bearer
85-
verifier, idempotency cache); `SessionContext` is created per
86-
accepted transport and runs the per-session machinery (dispatch,
87-
heartbeat, ack tracking, subscription set).
98+
verifier, idempotency cache); `SessionContext` (in
99+
`session-context.ts`) is created per accepted transport and runs the
100+
per-session machinery (dispatch, heartbeat, ack tracking,
101+
subscription set). `JobRunner` (`job-runner.ts`) drives a single
102+
in-flight job through its state machine.
103+
104+
An Effect-native surface lives alongside the class API:
105+
`ARCPRuntimeLayer` / `ARCPServerService` (and `makeARCPServerRuntime`)
106+
wrap the server in a `ManagedRuntime`; `JobService` / `jobLayer` and
107+
`JobManagerService` / `jobManagerLayer` expose the per-job pipeline;
108+
`acceptSessionEffect` and `resumeSweepDaemon` are the Effect-shaped
109+
entry points for the same lifecycle the class drives via callbacks.
88110

89111
Agents are functions registered by name:
90112

@@ -141,7 +163,7 @@ Every message is one JSON object with a small fixed envelope:
141163
| ------------ | ---------------------------------------- | ---------------------------------------------------- |
142164
| `arcp` | always | `"1.1"` (the v1.1 wire-format version literal) |
143165
| `id` | always | ULID or UUIDv7, unique per message |
144-
| `type` | always | discriminator (`"session.hello"`, `"job.submit"`, ) |
166+
| `type` | always | discriminator (`"session.hello"`, `"job.submit"`, ...) |
145167
| `payload` | always | type-specific body |
146168
| `session_id` | after handshake | absent on pre-session frames |
147169
| `job_id` | job-scoped envelopes | set on `job.*` types |
@@ -156,7 +178,7 @@ round-tripped per §15 — see [vendor-extensions.md](./guides/vendor-extensions
156178

157179
- Envelope schemas: [`packages/core/src/envelope.ts`](../packages/core/src/envelope.ts) and [`packages/core/src/messages/`](../packages/core/src/messages/)
158180
- Transports: [`packages/core/src/transport/`](../packages/core/src/transport/)
159-
- Client: [`packages/client/src/client.ts`](../packages/client/src/client.ts)
160-
- Server + dispatch: [`packages/runtime/src/server.ts`](../packages/runtime/src/server.ts)
161-
- Job + JobContext: [`packages/runtime/src/job.ts`](../packages/runtime/src/job.ts)
162-
- Lease validation: [`packages/runtime/src/lease.ts`](../packages/runtime/src/lease.ts)
181+
- Client: [`packages/client/src/client.ts`](../packages/client/src/client.ts); Effect twin: [`packages/client/src/client-effect.ts`](../packages/client/src/client-effect.ts)
182+
- Server + dispatch: [`packages/runtime/src/server.ts`](../packages/runtime/src/server.ts) and [`packages/runtime/src/session-context.ts`](../packages/runtime/src/session-context.ts); Effect twin: [`packages/runtime/src/server-effect.ts`](../packages/runtime/src/server-effect.ts)
183+
- Job + JobContext + JobRunner: [`packages/runtime/src/job.ts`](../packages/runtime/src/job.ts), [`packages/runtime/src/job-context.ts`](../packages/runtime/src/job-context.ts), [`packages/runtime/src/job-runner.ts`](../packages/runtime/src/job-runner.ts); Effect twins: [`packages/runtime/src/job-effect.ts`](../packages/runtime/src/job-effect.ts)
184+
- Lease validation: [`packages/runtime/src/lease.ts`](../packages/runtime/src/lease.ts); Effect twin: [`packages/runtime/src/lease-effect.ts`](../packages/runtime/src/lease-effect.ts)

docs/cli.md

Lines changed: 64 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# CLI
22

33
The `@agentruntimecontrolprotocol/sdk` package ships an `arcp` binary. It's a thin
4-
operational tool for running runtimes, submitting jobs, and replaying
4+
operational tool for running runtimes, submitting jobs, and inspecting
55
event logs.
66

77
## Install
@@ -16,11 +16,15 @@ If you've cloned the monorepo, the binary is at
1616
[`packages/sdk/src/cli.ts`](../packages/sdk/src/cli.ts) and can be run
1717
with `pnpm tsx`.
1818

19+
Run `arcp --version` to print the implementation and protocol versions
20+
(e.g., `0.2.0 (protocol 1.1)`).
21+
1922
## `arcp serve`
2023

21-
Start a runtime that hosts a single named echo-style agent. Most
22-
real deployments embed `ARCPServer` programmatically; `serve` is for
23-
ad-hoc testing and reproductions.
24+
Start a runtime that accepts a configurable bearer token. Most real
25+
deployments embed `ARCPServer` programmatically; `serve` is for ad-hoc
26+
testing and reproductions, and registers no agents by default — submits
27+
return `AGENT_NOT_AVAILABLE` unless you wire your own server.
2428

2529
```sh
2630
arcp serve \
@@ -32,15 +36,18 @@ arcp serve \
3236

3337
Flags:
3438

35-
| Flag | Default | Notes |
36-
| ------------------------- | ----------- | ------------------------------------------------- |
37-
| `--transport <ws\|stdio>` | `ws` | `stdio` makes this a subprocess agent. |
38-
| `--host <host>` | `127.0.0.1` | Bind address for WebSocket. |
39-
| `--port <port>` | `7777` | Bind port for WebSocket. |
40-
| `--path <path>` | `/arcp` | URL path for the WS upgrade. |
41-
| `--token <token>` || Required. Static bearer accepted by the verifier. |
42-
| `--principal <id>` || Principal returned when the token verifies. |
43-
| `--db <path>` | none | If set, persist events to this SQLite file. |
39+
| Flag | Default | Notes |
40+
| ------------------------- | ---------------- | ----------------------------------------------------------------------- |
41+
| `--transport <ws\|stdio>` | `ws` | `stdio` makes this a subprocess agent. |
42+
| `--host <host>` | `127.0.0.1` | Bind address for WebSocket. |
43+
| `--port <port>` | `0` (ephemeral) | Bind port for WebSocket. The bound URL is printed to stdout. |
44+
| `--token <token>` | `tok` | Static bearer accepted by the verifier. |
45+
| `--principal <id>` | `anonymous` | Principal returned when the token verifies. |
46+
| `--db <path>` | `:memory:` | SQLite event log path. Defaults to an in-memory log (not persisted). |
47+
48+
`startWebSocketServer` accepts every connection on the root path; there
49+
is no `--path` flag. For path-routed mounts on an existing `http.Server`
50+
use [`attachArcpUpgrade`](./packages/node.md) instead.
4451

4552
## `arcp submit`
4653

@@ -49,7 +56,7 @@ and CI.
4956

5057
```sh
5158
arcp submit \
52-
--url ws://127.0.0.1:7777/arcp \
59+
--url ws://127.0.0.1:7777 \
5360
--token tok \
5461
--agent my-agent \
5562
--input '{"hi":1}' \
@@ -58,55 +65,70 @@ arcp submit \
5865

5966
Flags:
6067

61-
| Flag | Notes |
62-
| ------------------------- | --------------------------------- |
63-
| `--url <ws-url>` | Runtime URL. |
64-
| `--token <token>` | Bearer token. |
65-
| `--agent <name>` | Registered agent name. |
66-
| `--input <json>` | Inline JSON payload. |
67-
| `--input-file <path>` | Read payload from a file. |
68-
| `--idempotency-key <key>` | Optional dedupe key (§7.2). |
69-
| `--max-runtime-sec <n>` | Hard wall clock for the job. |
70-
| `--lease <json>` | Lease object (§9). |
71-
| `--trace-id <hex>` | 32-hex W3C trace id to propagate. |
72-
73-
Stdout receives the final `job.result` payload as JSON; the process
74-
exit code is `0` on `success`, non-zero otherwise. Events are streamed
75-
to stderr in a human-readable form (`[seq] kind message`).
68+
| Flag | Notes |
69+
| ------------------------- | ------------------------------------------------------- |
70+
| `--url <ws-url>` | Required. Runtime WebSocket URL. |
71+
| `--token <token>` | Required. Bearer token. |
72+
| `--agent <name>` | Required. Registered agent name (`name` or `name@ver`). |
73+
| `--input <json>` | Inline JSON payload. Default `{}`. |
74+
| `--idempotency-key <key>` | Optional dedupe key (§7.2). |
75+
| `--max-runtime <sec>` | Hard wall clock for the job, in seconds. |
76+
77+
Stdout receives the final `job.result` / `job.error` payload as JSON.
78+
The process exits non-zero on submission failure or a rejected promise.
79+
Per-event streaming is not built into the CLI; for that, use the SDK
80+
programmatically and register `client.on("job.event", ...)`.
81+
82+
For richer submit flags (lease, lease constraints, trace id, file
83+
input), drive `ARCPClient` directly — the CLI is intentionally minimal.
7684

7785
## `arcp replay`
7886

79-
Replay events from a SQLite event log. Useful for postmortems and for
87+
Dump events from a SQLite event log. Useful for postmortems and for
8088
testing resume behavior offline.
8189

8290
```sh
8391
arcp replay \
8492
--db arcp.db \
85-
--session sess_01J4XY \
93+
--session sess_01J4XY... \
8694
--after-seq 0
8795
```
8896

8997
Flags:
9098

91-
| Flag | Notes |
92-
| ----------------- | -------------------------------------- |
93-
| `--db <path>` | SQLite event log to read. |
94-
| `--session <id>` | Filter to a specific session. |
95-
| `--job <id>` | Filter to a specific job. |
96-
| `--after-seq <n>` | Start strictly after this `event_seq`. |
97-
| `--until-seq <n>` | Stop at this `event_seq`. |
99+
| Flag | Notes |
100+
| ----------------- | ----------------------------------------------------------------------- |
101+
| `--db <path>` | Required. SQLite event log to read (opened read-only). |
102+
| `--session <id>` | Required. Filter to a specific session. |
103+
| `--after-seq <n>` | Start strictly after this `event_seq`. Default `0`. |
98104

99-
Events are printed one per line, newest envelope at the bottom.
105+
Events are printed one envelope per line as JSON, oldest first.
106+
107+
## `arcp manifest`
108+
109+
Print the CLI's package manifest (name, implementation version, and
110+
protocol version) as JSON. Useful for tooling that needs to assert the
111+
on-disk binary matches an expected version.
112+
113+
```sh
114+
arcp manifest
115+
# → { "name": "arcp", "version": "0.2.0", "protocol_version": "1.1" }
116+
```
100117

101118
## stdio
102119

103120
`--transport stdio` makes `arcp serve` read envelopes from stdin and
104121
write them to stdout. The runtime is the child; the parent process is
105122
the ARCP client. Pipe agent logs to stderr or silence them — any
106-
non-envelope byte on stdout will crash the channel.
123+
non-envelope byte on stdout will crash the channel. On startup the
124+
child writes a single readiness line (`arcp serve: stdio transport
125+
ready`) to **stderr**, not stdout, so the wire stays clean.
126+
127+
```ts
128+
// In a parent process:
129+
import { spawn } from "node:child_process";
130+
import { StdioTransport } from "@agentruntimecontrolprotocol/sdk";
107131

108-
```sh
109-
# In a parent process:
110132
const child = spawn("arcp", [
111133
"serve", "--transport", "stdio",
112134
"--token", "tok", "--principal", "me",
@@ -118,12 +140,3 @@ const transport = new StdioTransport({
118140
```
119141

120142
See [transports.md#stdio](./transports.md#stdio) for the full pattern.
121-
122-
## Exit codes
123-
124-
| Code | Meaning |
125-
| ---- | --------------------------------------------------------- |
126-
| 0 | Job completed with `final_status: "success"`. |
127-
| 1 | Runtime/server error (auth, bind failure, unknown agent). |
128-
| 2 | Job terminated with `error`, `cancelled`, or `timed_out`. |
129-
| 64 | Bad CLI arguments. |

0 commit comments

Comments
 (0)