@mono-agent/agent-runtime 0.17.1 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MIGRATION.md +46 -3
- package/README.md +107 -13
- package/package.json +7 -2
- package/src/ai/failure.js +2 -1
- package/src/ai/index.js +2 -0
- package/src/ai/providers/acp-client.js +1149 -0
- package/src/ai/providers/acp-privacy.js +124 -0
- package/src/ai/providers/acp-public.js +21 -0
- package/src/ai/providers/acp-session-tokens.js +282 -0
- package/src/ai/providers/acp-transport.js +356 -0
- package/src/ai/providers/acp.js +539 -0
- package/src/ai/runtime/capabilities.js +16 -0
- package/src/ai/runtime/model-refs.js +20 -1
- package/src/ai/runtime/registry.js +6 -0
- package/src/ai/runtime/router.js +4 -1
- package/src/ai/types.js +11 -5
- package/src/runtime.js +5 -2
- package/types/ai/failure.d.ts +2 -2
- package/types/ai/index.d.ts +2 -0
- package/types/ai/providers/acp-client.d.ts +227 -0
- package/types/ai/providers/acp-privacy.d.ts +25 -0
- package/types/ai/providers/acp-public.d.ts +7 -0
- package/types/ai/providers/acp-session-tokens.d.ts +41 -0
- package/types/ai/providers/acp-transport.d.ts +45 -0
- package/types/ai/providers/acp.d.ts +93 -0
- package/types/ai/runtime/capabilities.d.ts +21 -0
- package/types/ai/types.d.ts +39 -9
package/MIGRATION.md
CHANGED
|
@@ -63,9 +63,51 @@ the configuration schema.
|
|
|
63
63
|
authoritative and the runtime emits a bounded
|
|
64
64
|
`live_input_callback_failed` warning.
|
|
65
65
|
|
|
66
|
+
## 0.18.1
|
|
67
|
+
|
|
68
|
+
- ACP provider-session ids and session-list cursors are now confidential,
|
|
69
|
+
authenticated v2 handles. Hosts must persist one exact 32-byte binary
|
|
70
|
+
`acpSessionTokenKey` and pass it to ACP task runs, list/delete helpers, and
|
|
71
|
+
`validateAcpProviderSessionId(value, expectedProfileId, key)`. A changed or
|
|
72
|
+
missing key fails before profile resolution or process spawn. Existing v1
|
|
73
|
+
handles are rejected; discard them and obtain fresh v2 handles. Preserve the
|
|
74
|
+
complete returned value for resume, pagination, validation, and delete, but
|
|
75
|
+
do not compare ciphertexts for equality or parse/substitute the remote
|
|
76
|
+
agent's raw session id or cursor.
|
|
77
|
+
- Payload-bearing diagnostics from the pinned ACP SDK are scoped to the owned
|
|
78
|
+
ACP receive loop and reduced to content-free labels. Malformed or hostile
|
|
79
|
+
agent notifications cannot copy elicitation values or URL secrets into
|
|
80
|
+
process-wide console diagnostics.
|
|
81
|
+
|
|
82
|
+
## 0.18.0
|
|
83
|
+
|
|
84
|
+
- `acp:<profile-id>` is now a canonical runtime model reference when paired
|
|
85
|
+
with `executionMode: "acp"`. Hosts must provide `resolveAcpProfile`; profiles
|
|
86
|
+
define direct argv/environment values, client-versus-agent ownership,
|
|
87
|
+
capability policy, session configuration, and bounded process policy.
|
|
88
|
+
- `onAcpInteractionRequest` is the host rendezvous for ACP permission and
|
|
89
|
+
elicitation requests. Hosts must echo only advertised permission option ids,
|
|
90
|
+
keep submitted form values out of durable logs, and fail closed on abort.
|
|
91
|
+
- ACP profile callbacks never receive raw protocol `sessionId`, `_meta`, or
|
|
92
|
+
copied raw-id strings. Use the optional opaque
|
|
93
|
+
`AcpCallbackContext.providerSessionId` for safe session correlation.
|
|
94
|
+
- ACP provider-session ids and session-list cursors are opaque, profile-bound
|
|
95
|
+
runtime handles. Preserve the complete value returned by the runtime for
|
|
96
|
+
resume, pagination, validation, and delete operations; do not parse or
|
|
97
|
+
substitute the remote agent's raw session id or cursor. Raw ACP transport
|
|
98
|
+
connections are internal; use the high-level management helpers.
|
|
99
|
+
- The stable ACP update stream is preserved as typed `acp_session_update`
|
|
100
|
+
events and normalized assistant, thought, tool, plan, and cumulative usage
|
|
101
|
+
events. Stable usage comes from `usage_update`, not experimental prompt
|
|
102
|
+
response fields.
|
|
103
|
+
- ACP management helpers (`probeAcpProfile`, `authenticateAcpProfile`,
|
|
104
|
+
`logoutAcpProfile`, `listAcpSessions`, and `deleteAcpSession`) use the same
|
|
105
|
+
resolver and callback boundary as turns. Authentication always requires an
|
|
106
|
+
explicitly selected advertised method id.
|
|
107
|
+
|
|
66
108
|
## 0.17.x baseline
|
|
67
109
|
|
|
68
|
-
This
|
|
110
|
+
This prior baseline carries the 0.16.x contract forward
|
|
69
111
|
and adds a host-only, request-scoped `toolEnvironment` boundary. Hosts may pass
|
|
70
112
|
validated values and PATH prefixes through the request, harness, and runtime;
|
|
71
113
|
the runtime applies them only when Bash, Exec, or a nested subagent process is
|
|
@@ -370,7 +412,7 @@ now a loud failure (guarded by `scripts/verify-deep-imports.mjs`).
|
|
|
370
412
|
<!-- public-api-js-subpaths:start -->
|
|
371
413
|
<!-- Generated by scripts/generate-public-api-docs.mjs. Do not edit by hand. -->
|
|
372
414
|
|
|
373
|
-
The package exposes **
|
|
415
|
+
The package exposes **22 named deep `.js` subpaths**:
|
|
374
416
|
|
|
375
417
|
```text
|
|
376
418
|
@mono-agent/agent-runtime/agent/allowlists.js
|
|
@@ -384,6 +426,7 @@ The package exposes **21 named deep `.js` subpaths**:
|
|
|
384
426
|
@mono-agent/agent-runtime/ai/failure.js
|
|
385
427
|
@mono-agent/agent-runtime/ai/file-change-stats.js
|
|
386
428
|
@mono-agent/agent-runtime/ai/live-input-prompt.js
|
|
429
|
+
@mono-agent/agent-runtime/ai/providers/acp.js
|
|
387
430
|
@mono-agent/agent-runtime/ai/providers/claude-cli.js
|
|
388
431
|
@mono-agent/agent-runtime/ai/providers/claude-sdk-discovery.js
|
|
389
432
|
@mono-agent/agent-runtime/ai/providers/claude-sdk.js
|
|
@@ -407,7 +450,7 @@ a compatibility subpath.
|
|
|
407
450
|
|
|
408
451
|
## Version
|
|
409
452
|
|
|
410
|
-
This guide describes the published `0.
|
|
453
|
+
This guide describes the published `0.18.x` package contract. Keep
|
|
411
454
|
`@mono-agent/agent-runtime`, `@mono-agent/runtime-adapter`, and other
|
|
412
455
|
`@mono-agent/*` packages on the same lockstep version when upgrading. The paired
|
|
413
456
|
runtime adapter no longer exposes `piReasoningSummary` in its run-options type.
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @mono-agent/agent-runtime
|
|
2
2
|
|
|
3
3
|
Use this package when you need direct, capability-aware access to mono-agent's
|
|
4
|
-
|
|
4
|
+
six built-in model runtime bridges, including product-neutral ACP v1 agents.
|
|
5
5
|
|
|
6
6
|
## Category
|
|
7
7
|
|
|
@@ -10,13 +10,13 @@ five built-in model runtime bridges.
|
|
|
10
10
|
|
|
11
11
|
Category: `runtime`
|
|
12
12
|
Tier: `core`
|
|
13
|
-
Catalog responsibility: Provides
|
|
13
|
+
Catalog responsibility: Provides six runtime bridges (ACP v1, Claude SDK, Claude Code CLI, Codex app-server, OpenCode app-server, Pi SDK); direct OpenCode requires stable CLI >=1.15.0 on PATH.
|
|
14
14
|
|
|
15
15
|
<!-- package-metadata:end -->
|
|
16
16
|
|
|
17
17
|
## Responsibility
|
|
18
18
|
|
|
19
|
-
Provides
|
|
19
|
+
Provides six runtime bridges (ACP v1, Claude SDK, Claude Code CLI, Codex app-server, OpenCode app-server, Pi SDK), with capabilities declared per bridge. This is the runtime layer that `@mono-agent/runtime-adapter` wraps behind runtime contracts. Pi and ACP-owned stdio children enforce optional mono-agent sandbox policy through an injectable `RuntimeSandbox` seam (a fail-closed passthrough by default; `@mono-agent/runtime-adapter` injects the real implementation). The router supports a compatibility-preserving uniform contract or explicit isolated per-route-native contracts; no provider route silently drops required capabilities.
|
|
20
20
|
|
|
21
21
|
## Install / Usage
|
|
22
22
|
|
|
@@ -61,7 +61,7 @@ only after a run selects a matching model reference and execution mode:
|
|
|
61
61
|
### Data flow
|
|
62
62
|
|
|
63
63
|
1. `createRuntime()` binds host callbacks and creates an isolated tool context.
|
|
64
|
-
2. `resolveRuntimeBridge()` checks the
|
|
64
|
+
2. `resolveRuntimeBridge()` checks the six static bridge descriptors in order.
|
|
65
65
|
3. The selected descriptor lazily imports its provider implementation.
|
|
66
66
|
4. The bridge prepares the runtime inputs it supports, including managed or MCP
|
|
67
67
|
tools only where that bridge can represent them, streams normalized events,
|
|
@@ -75,7 +75,7 @@ only after a run selects a matching model reference and execution mode:
|
|
|
75
75
|
| --- | --- |
|
|
76
76
|
| `src/runtime.js` | Host binding, per-instance tool context, bridge dispatch, and observer flushing |
|
|
77
77
|
| `src/ai/runtime/` | Model-reference parsing, the lazy bridge registry, capabilities, sessions, and fallback routing |
|
|
78
|
-
| `src/ai/providers/` | Claude SDK/CLI, Codex app-server, OpenCode app-server, and Pi SDK integrations |
|
|
78
|
+
| `src/ai/providers/` | ACP v1, Claude SDK/CLI, Codex app-server, OpenCode app-server, and Pi SDK integrations |
|
|
79
79
|
| `src/agent/tools/` | Managed tools, MCP adaptation, output limits, and the injectable sandbox seam |
|
|
80
80
|
| `src/agent/` | Approvals, allowlists, transcript snapshots, and compaction policy helpers |
|
|
81
81
|
|
|
@@ -89,9 +89,10 @@ the [architecture guide](https://github.com/robertsreberski/mono-agent/blob/main
|
|
|
89
89
|
| API | Use it for |
|
|
90
90
|
| --- | --- |
|
|
91
91
|
| `createRuntime()` | Run one model bridge with host-owned credentials, observers, tools, and lifecycle callbacks |
|
|
92
|
+
| `probeAcpProfile()` / ACP management helpers | Probe, authenticate, log out, list sessions, validate opaque handles, or delete an ACP provider session |
|
|
92
93
|
| `createRouterRuntime()` | Retry an ordered model chain while preserving explicit route-safety contracts |
|
|
93
|
-
| `parseRuntimeModelReference()` | Convert a canonical `claude:`, `codex:`, `opencode:`, or `pi:` string into the object required by `run()` |
|
|
94
|
-
| `listRuntimeBridges()` / `runtimeCapabilities()` | Inspect the
|
|
94
|
+
| `parseRuntimeModelReference()` | Convert a canonical `acp:`, `claude:`, `codex:`, `opencode:`, or `pi:` string into the object required by `run()` |
|
|
95
|
+
| `listRuntimeBridges()` / `runtimeCapabilities()` | Inspect the six built-in bridge descriptors without loading provider implementations |
|
|
95
96
|
| `createPiOAuthApiKeyResolver()` | Bind a host-owned Pi auth file with refresh-safe writes |
|
|
96
97
|
| `listPiBuiltinModels()` / `getPiBuiltinModel()` | Read cloned snapshots from the runtime-owned, exact-pinned Pi model catalog without importing Pi directly |
|
|
97
98
|
| `resolvePiOAuthApiKey()` / `loginPiOAuth()` | Use the runtime-owned Pi OAuth implementation without importing Pi's mutable provider registry |
|
|
@@ -109,10 +110,18 @@ Every symbol exported by each public code entrypoint is listed below.
|
|
|
109
110
|
**`@mono-agent/agent-runtime`**
|
|
110
111
|
|
|
111
112
|
```text
|
|
113
|
+
ACP_PROTOCOL_VERSION
|
|
112
114
|
ACTIVE_RUNTIME_KINDS
|
|
113
115
|
ALLOWLIST_MODE_ALL
|
|
114
116
|
ALLOWLIST_MODE_CUSTOM
|
|
115
117
|
APPROVAL_DECISIONS
|
|
118
|
+
AcpCallbackContext
|
|
119
|
+
AcpClientError
|
|
120
|
+
AcpClientHostOptions
|
|
121
|
+
AcpInteractionRequest
|
|
122
|
+
AcpListedSession
|
|
123
|
+
AcpProfileDescriptor
|
|
124
|
+
AcpSessionListResult
|
|
116
125
|
BINARY_BLOAT_TOOLS
|
|
117
126
|
BridgeSpec
|
|
118
127
|
CLAUDE_SDK_CATALOG_VERSION
|
|
@@ -127,6 +136,8 @@ RuntimeBridgeDescriptor
|
|
|
127
136
|
RuntimeBridgeId
|
|
128
137
|
RuntimeModelRef
|
|
129
138
|
UNKNOWN_CAPABILITY
|
|
139
|
+
acpRuntimeBridge
|
|
140
|
+
authenticateAcpProfile
|
|
130
141
|
buildCapabilitiesUsed
|
|
131
142
|
buildTranscriptTailSnapshot
|
|
132
143
|
canonicalizeLegacyModelReference
|
|
@@ -140,19 +151,23 @@ createRouterRuntime
|
|
|
140
151
|
createRuntime
|
|
141
152
|
createSessionRegistry
|
|
142
153
|
curatedClaudeSdkModels
|
|
154
|
+
deleteAcpSession
|
|
143
155
|
discoverClaudeSdkModels
|
|
144
156
|
disposeAllProviderSessions
|
|
145
157
|
disposeProviderSession
|
|
146
158
|
executionModeIncompatibilityReason
|
|
159
|
+
generateAcpResponse
|
|
147
160
|
generatePiNativeResponse
|
|
148
161
|
getPiBuiltinModel
|
|
149
162
|
inferAllowlistMode
|
|
150
163
|
invalidateProviderSession
|
|
151
164
|
isLikelyContextTermination
|
|
152
165
|
isModelCompatibleWithExecutionMode
|
|
166
|
+
listAcpSessions
|
|
153
167
|
listPiBuiltinModels
|
|
154
168
|
listRuntimeBridges
|
|
155
169
|
loginPiOAuth
|
|
170
|
+
logoutAcpProfile
|
|
156
171
|
normalizeAllowlistMode
|
|
157
172
|
normalizeClaudeSdkCatalog
|
|
158
173
|
normalizeClaudeSdkModelId
|
|
@@ -161,6 +176,7 @@ normalizeRuntimeModelReference
|
|
|
161
176
|
parseRuntimeModelReference
|
|
162
177
|
parseStoredAllowlist
|
|
163
178
|
piNativeRuntimeBridge
|
|
179
|
+
probeAcpProfile
|
|
164
180
|
readRuntimeBrand
|
|
165
181
|
readToolRuntime
|
|
166
182
|
reasoningLevelsForPiModel
|
|
@@ -178,6 +194,8 @@ sdkFromModelReference
|
|
|
178
194
|
storedAllowlistMode
|
|
179
195
|
syncProviderSession
|
|
180
196
|
toolCompactionAppliedFromWarnings
|
|
197
|
+
validateAcpProfileId
|
|
198
|
+
validateAcpProviderSessionId
|
|
181
199
|
wrapToolsWithApprovalGate
|
|
182
200
|
```
|
|
183
201
|
|
|
@@ -302,7 +320,15 @@ renderResumeSnapshot
|
|
|
302
320
|
**`@mono-agent/agent-runtime/ai`**
|
|
303
321
|
|
|
304
322
|
```text
|
|
323
|
+
ACP_PROTOCOL_VERSION
|
|
305
324
|
ACTIVE_RUNTIME_KINDS
|
|
325
|
+
AcpCallbackContext
|
|
326
|
+
AcpClientError
|
|
327
|
+
AcpClientHostOptions
|
|
328
|
+
AcpInteractionRequest
|
|
329
|
+
AcpListedSession
|
|
330
|
+
AcpProfileDescriptor
|
|
331
|
+
AcpSessionListResult
|
|
306
332
|
BridgeSpec
|
|
307
333
|
CLAUDE_SDK_CATALOG_VERSION
|
|
308
334
|
RESERVED_RUNTIME_KINDS
|
|
@@ -312,6 +338,8 @@ RuntimeBridgeDescriptor
|
|
|
312
338
|
RuntimeBridgeId
|
|
313
339
|
RuntimeModelRef
|
|
314
340
|
UNKNOWN_CAPABILITY
|
|
341
|
+
acpRuntimeBridge
|
|
342
|
+
authenticateAcpProfile
|
|
315
343
|
buildCapabilitiesUsed
|
|
316
344
|
canonicalizeLegacyModelReference
|
|
317
345
|
createClaudeSdkDiscoveryIsolation
|
|
@@ -319,22 +347,27 @@ createMetricsObserver
|
|
|
319
347
|
createObserverHub
|
|
320
348
|
createSessionRegistry
|
|
321
349
|
curatedClaudeSdkModels
|
|
350
|
+
deleteAcpSession
|
|
322
351
|
discoverClaudeSdkModels
|
|
323
352
|
disposeAllProviderSessions
|
|
324
353
|
disposeProviderSession
|
|
325
354
|
executionModeIncompatibilityReason
|
|
355
|
+
generateAcpResponse
|
|
326
356
|
generatePiNativeResponse
|
|
327
357
|
getPiBuiltinModel
|
|
328
358
|
invalidateProviderSession
|
|
329
359
|
isModelCompatibleWithExecutionMode
|
|
360
|
+
listAcpSessions
|
|
330
361
|
listPiBuiltinModels
|
|
331
362
|
listRuntimeBridges
|
|
332
363
|
loginPiOAuth
|
|
364
|
+
logoutAcpProfile
|
|
333
365
|
normalizeClaudeSdkCatalog
|
|
334
366
|
normalizeClaudeSdkModelId
|
|
335
367
|
normalizeRuntimeModelReference
|
|
336
368
|
parseRuntimeModelReference
|
|
337
369
|
piNativeRuntimeBridge
|
|
370
|
+
probeAcpProfile
|
|
338
371
|
reasoningLevelsForPiModel
|
|
339
372
|
refreshProviderSession
|
|
340
373
|
resolvePiOAuthApiKey
|
|
@@ -343,6 +376,8 @@ runtimeCapabilities
|
|
|
343
376
|
sdkFromModelReference
|
|
344
377
|
syncProviderSession
|
|
345
378
|
toolCompactionAppliedFromWarnings
|
|
379
|
+
validateAcpProfileId
|
|
380
|
+
validateAcpProviderSessionId
|
|
346
381
|
```
|
|
347
382
|
|
|
348
383
|
**`@mono-agent/agent-runtime/ai/cost.js`**
|
|
@@ -390,6 +425,13 @@ statsForCompletedChange
|
|
|
390
425
|
formatLiveInputGuidance
|
|
391
426
|
```
|
|
392
427
|
|
|
428
|
+
**`@mono-agent/agent-runtime/ai/providers/acp.js`**
|
|
429
|
+
|
|
430
|
+
```text
|
|
431
|
+
acpRuntimeBridge
|
|
432
|
+
generateAcpResponse
|
|
433
|
+
```
|
|
434
|
+
|
|
393
435
|
**`@mono-agent/agent-runtime/ai/providers/claude-cli.js`**
|
|
394
436
|
|
|
395
437
|
```text
|
|
@@ -499,7 +541,7 @@ normalizeCodexItemType
|
|
|
499
541
|
`@mono-agent/agent-runtime` is purpose-built for **autonomous, long-running agent work** with provider portability and operational resilience as first-class concerns. It is *not* a streaming-chat UI kit. Where each peer fits:
|
|
500
542
|
|
|
501
543
|
- **Vercel AI SDK** — best when you're building a chat / generative-UI experience inside a React or Next.js app. `useChat`, `useCompletion`, streaming server components, and edge-runtime compatibility are their strengths. Their provider list is curated (Anthropic, OpenAI, Google, etc., via `@ai-sdk/*` packages); there's no Pi gateway, no Claude Code CLI, no Codex CLI app-server, and no per-call provider fallback. If you're rendering a streaming chat into a browser, use them. If you're orchestrating multi-turn autonomous work that must survive a rate-limited primary provider, use us.
|
|
502
|
-
- **Claude Agent SDK** (`@anthropic-ai/claude-agent-sdk`) — first-party Anthropic SDK. Tight integration with Claude features (canUseTool, sub-agents, hooks, MCP). We *wrap* it as one of our
|
|
544
|
+
- **Claude Agent SDK** (`@anthropic-ai/claude-agent-sdk`) — first-party Anthropic SDK. Tight integration with Claude features (canUseTool, sub-agents, hooks, MCP). We *wrap* it as one of our six bridges and add transcript-resume across provider drops, a structured failure taxonomy, a tool-bloat guard with artifact persistence, and a provider fallback router. Context/window handling remains bridge-specific; the pi-native bridge drives its own compaction recovery. Reach for the bare Anthropic SDK when you only ever talk to Claude and don't need cross-provider portability or resume.
|
|
503
545
|
- **Mastra** — a workflow engine + memory + RAG stack. Different category: it's the layer *above* a runtime. You can layer Mastra workflows on top of `@mono-agent/agent-runtime` if you want both.
|
|
504
546
|
- **OpenAI Agents SDK** — first-party OpenAI SDK. Same trade-off as the Claude Agent SDK: tight integration with OpenAI, no other providers. Pi providers in our runtime cover OpenAI plus a dozen others through a single API.
|
|
505
547
|
- **LangChain.js** — kitchen sink with deep abstraction stacks. We're deliberately lean; if you want chains, agents, vector stores, and parsers under one umbrella, LangChain is built for that. If you want a focused runtime kernel, use us.
|
|
@@ -510,6 +552,7 @@ normalizeCodexItemType
|
|
|
510
552
|
- Anthropic Claude via the `claude` Code CLI binary.
|
|
511
553
|
- OpenAI's Codex via the `codex` app-server CLI.
|
|
512
554
|
- OpenCode providers via an isolated, password-authenticated `opencode` app-server.
|
|
555
|
+
- Any ACP v1 stdio agent resolved by the host from an `acp:<profile-id>` reference.
|
|
513
556
|
- OpenAI, Google Gemini, AWS Bedrock, OpenRouter, xAI, Groq, Mistral, Perplexity, DeepSeek, Ollama, LlamaCPP, GLM, Vercel AI Gateway, GitHub Copilot, Gemini CLI — all through the Pi (`@earendil-works/pi-ai`) provider gateway, which our SDK adapter speaks directly.
|
|
514
557
|
|
|
515
558
|
**At-a-glance:**
|
|
@@ -517,7 +560,7 @@ normalizeCodexItemType
|
|
|
517
560
|
| Need | Use this | Use Vercel AI SDK | Use Claude Agent SDK |
|
|
518
561
|
|---|---|---|---|
|
|
519
562
|
| Streaming chat UI in React/Next | ✗ | ✓ | ✗ |
|
|
520
|
-
| Multi-provider portability | ✓ (
|
|
563
|
+
| Multi-provider portability | ✓ (6 bridges, 15+ providers) | partial | ✗ |
|
|
521
564
|
| CLI providers (claude/codex/opencode binaries) | ✓ | ✗ | ✗ |
|
|
522
565
|
| Provider fallback on rate limit / overload | ✓ (`createRouterRuntime`) | ✗ | ✗ |
|
|
523
566
|
| Context handling delegated to the provider (no host auto-summarization) | ✓ | ✓ | ✓ |
|
|
@@ -541,20 +584,70 @@ The runtime picks a backend from `options.model` + `options.executionMode`:
|
|
|
541
584
|
| `"pi"` | `"sdk"` (or omitted) | Pi SDK |
|
|
542
585
|
| `"codex"` | `"cli"` | Codex app-server CLI |
|
|
543
586
|
| `"opencode"` | `"cli"` | Isolated OpenCode app-server CLI |
|
|
587
|
+
| `"acp"` | `"acp"` | ACP v1 stdio client |
|
|
544
588
|
|
|
545
589
|
A `model` is a parsed `{ sdk, model, provider? }` object. Convert canonical
|
|
546
590
|
strings such as `"pi:openai:gpt-5.5"` with
|
|
547
591
|
`parseRuntimeModelReference()` before calling `run()`.
|
|
548
592
|
|
|
593
|
+
#### ACP v1 host contract
|
|
594
|
+
|
|
595
|
+
ACP references are canonical `acp:<profile-id>` strings and always use the
|
|
596
|
+
dedicated `executionMode: "acp"`. The host supplies
|
|
597
|
+
`resolveAcpProfile(profileId, context)` either to `createRuntime()` or per run;
|
|
598
|
+
per-run callbacks win. A profile contains an absolute executable command,
|
|
599
|
+
literal arguments, an exact child environment, ownership declarations for
|
|
600
|
+
configuration/workspace/MCP, explicit capability policy, and bounded process
|
|
601
|
+
limits. The runtime never invokes a shell or inherits `process.env`.
|
|
602
|
+
|
|
603
|
+
Client-owned filesystem, terminal, permission, and elicitation behavior must be
|
|
604
|
+
provided as callbacks and is advertised only when enabled. The runtime-adapter
|
|
605
|
+
facade injects mono-agent's real sandbox implementation; direct kernel callers
|
|
606
|
+
must provide their own when policy requires it. Every owned stdio bridge is
|
|
607
|
+
closed after the operation with stdin close, TERM, then bounded KILL escalation.
|
|
608
|
+
Callback payloads retain their typed operation fields but omit raw protocol
|
|
609
|
+
session ids, extension metadata, and copied raw-id strings. Session-scoped
|
|
610
|
+
callbacks receive the corresponding opaque handle as
|
|
611
|
+
`AcpCallbackContext.providerSessionId`; request ids are opaque host correlation
|
|
612
|
+
tokens as well.
|
|
613
|
+
Session-update dispatch reads only validated own protocol fields. If a valid
|
|
614
|
+
transport frame is too structurally complex for the bounded host sanitizer,
|
|
615
|
+
the turn fails explicitly as `provider_protocol` instead of emitting a partial
|
|
616
|
+
tool, plan, or message event.
|
|
617
|
+
|
|
618
|
+
ACP provider-session ids and list cursors are confidential, authenticated v2
|
|
619
|
+
handles bound to their token kind and profile. The host must supply an exact
|
|
620
|
+
32-byte binary `acpSessionTokenKey` for every task run, list, validation, and
|
|
621
|
+
delete operation. Call
|
|
622
|
+
`validateAcpProviderSessionId(handle, expectedProfileId, key)` at untrusted
|
|
623
|
+
ingress. Keep the key stable and secret across host restarts; changing it
|
|
624
|
+
invalidates every outstanding handle. Legacy `acp:v1:` and `acp-cursor:v1:`
|
|
625
|
+
values are rejected.
|
|
626
|
+
|
|
627
|
+
Preserve each returned handle byte-for-byte and pass it back only to the
|
|
628
|
+
matching high-level resume, list, validation, or delete operation. Encryption
|
|
629
|
+
uses a fresh nonce, so two handles for the same remote id are not equality
|
|
630
|
+
keys. Raw protocol session ids, cursors, token keys, and transport connections
|
|
631
|
+
remain private runtime state and are omitted from profile resolver context,
|
|
632
|
+
callbacks, and diagnostics. Under the default `auto` recovery policy, the
|
|
633
|
+
client prefers `session/resume`, then `session/load`, and finally a fresh
|
|
634
|
+
session when neither capability is advertised. Explicit `resume` or `load`
|
|
635
|
+
policies fail closed if missing. Stable usage comes from the latest typed
|
|
636
|
+
`usage_update` notification; unstable `PromptResponse.usage` is ignored.
|
|
637
|
+
|
|
549
638
|
### `createRuntime(host)`
|
|
550
639
|
|
|
551
|
-
Pass host-level integration once at boot.
|
|
640
|
+
Pass host-level integration once at boot. Keys are optional unless the selected
|
|
641
|
+
backend contract requires them.
|
|
552
642
|
|
|
553
643
|
```js
|
|
554
644
|
createRuntime({
|
|
555
645
|
// -- host callbacks --
|
|
556
646
|
resolveCustomPricing, // (parsed) => NormalizedPricing | null
|
|
557
647
|
resolvePiApiKey, // async (provider) => string | undefined
|
|
648
|
+
resolveAcpProfile, // async (profileId, context) => AcpProfileDescriptor
|
|
649
|
+
onAcpInteractionRequest, // async permission/elicitation fallback callback
|
|
650
|
+
acpSessionTokenKey, // Uint8Array(32), required for ACP task/session-handle operations
|
|
558
651
|
persistArtifact, // ({ filename, buffer, toolName, toolUseId }) => path | null
|
|
559
652
|
onCompactionRecorded, // (compactionRow) => void — fired when the pi bridge
|
|
560
653
|
// runs an automatic compaction (proactive or reactive
|
|
@@ -652,7 +745,7 @@ Per-call options (a non-exhaustive selection):
|
|
|
652
745
|
| Option | Type | Notes |
|
|
653
746
|
|---|---|---|
|
|
654
747
|
| `model` | `RuntimeModelRef` | **Required.** Pass the object returned by `parseRuntimeModelReference()`; `run()` does not parse strings. |
|
|
655
|
-
| `executionMode` | `"sdk" \| "cli"` | Default `"sdk"`. |
|
|
748
|
+
| `executionMode` | `"sdk" \| "cli" \| "acp"` | Default `"sdk"`; ACP references require `"acp"`. |
|
|
656
749
|
| `messages` | `Message[]` | Conversation history. |
|
|
657
750
|
| `cwd` | `string` | Working directory for the agent's tools. |
|
|
658
751
|
| `allowedTools` | `string[]` | Built-in tool allowlist. Default: all. |
|
|
@@ -670,6 +763,7 @@ Per-call options (a non-exhaustive selection):
|
|
|
670
763
|
| `onEvent` | `(event) => void` | Fired for every runtime event (assistant text, tool calls/results, applied live input, runtime warnings, structured output). |
|
|
671
764
|
| `runId` | `string` | Tag this run for downstream callbacks (e.g. `onCompactionRecorded`). |
|
|
672
765
|
| `providerSessionId` | `string` | Resume a prior provider session. |
|
|
766
|
+
| `acpSessionTokenKey` | `Uint8Array(32)` | Required for ACP task runs when not bound at `createRuntime()`; keep it secret and stable across restarts. |
|
|
673
767
|
| `runArtifactDir` | `string` | Used by some providers as the Playwright MCP filename target. |
|
|
674
768
|
| `codexAppServerCommand` | `string` | Override the Codex CLI binary. |
|
|
675
769
|
| `codexAppServerArgs` | `string[]` | Override the Codex CLI arguments. |
|
|
@@ -1010,7 +1104,7 @@ These are stable but treated as advanced API. Most consumers should reach for `c
|
|
|
1010
1104
|
## Dependency Boundary
|
|
1011
1105
|
|
|
1012
1106
|
This package has zero `@mono-agent/*` workspace dependencies. Its runtime
|
|
1013
|
-
dependencies are `@anthropic-ai/claude-agent-sdk`, `@anthropic-ai/sdk`,
|
|
1107
|
+
dependencies are `@agentclientprotocol/sdk`, `@anthropic-ai/claude-agent-sdk`, `@anthropic-ai/sdk`,
|
|
1014
1108
|
`@earendil-works/pi-agent-core`, `@earendil-works/pi-ai`,
|
|
1015
1109
|
`@modelcontextprotocol/sdk`, `@opencode-ai/sdk`, `@vscode/ripgrep`,
|
|
1016
1110
|
`cross-spawn`, and `zod`.
|
|
@@ -1047,7 +1141,7 @@ runtime fails closed.
|
|
|
1047
1141
|
- [Runtime and providers](https://mono-agent-docs.vercel.app/runtime/) explains the
|
|
1048
1142
|
config-first model and backend choices.
|
|
1049
1143
|
- [Backends and model references](https://mono-agent-docs.vercel.app/runtime/backends/)
|
|
1050
|
-
documents
|
|
1144
|
+
documents the built-in bridges and their execution modes.
|
|
1051
1145
|
- [Programmatic approvals and structured output](https://mono-agent-docs.vercel.app/programmatic/approval-and-structured-output/)
|
|
1052
1146
|
shows the code-only host hooks.
|
|
1053
1147
|
- [Local-first web research](https://mono-agent-docs.vercel.app/tools/web-research/)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mono-agent/agent-runtime",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Agent runtime supporting Claude SDK/CLI, Codex, OpenCode,
|
|
3
|
+
"version": "0.18.1",
|
|
4
|
+
"description": "Agent runtime supporting Claude SDK/CLI, Codex, OpenCode, Pi SDK, and ACP v1 bridges out of the box",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "GPL-3.0-only",
|
|
7
7
|
"repository": {
|
|
@@ -87,6 +87,10 @@
|
|
|
87
87
|
"types": "./types/ai/providers/opencode-discovery.d.ts",
|
|
88
88
|
"default": "./src/ai/providers/opencode-discovery.js"
|
|
89
89
|
},
|
|
90
|
+
"./ai/providers/acp.js": {
|
|
91
|
+
"types": "./types/ai/providers/acp.d.ts",
|
|
92
|
+
"default": "./src/ai/providers/acp.js"
|
|
93
|
+
},
|
|
90
94
|
"./agent/tools/index.js": {
|
|
91
95
|
"types": "./types/agent/tools/index.d.ts",
|
|
92
96
|
"default": "./src/agent/tools/index.js"
|
|
@@ -131,6 +135,7 @@
|
|
|
131
135
|
"node": ">=22.19.0"
|
|
132
136
|
},
|
|
133
137
|
"dependencies": {
|
|
138
|
+
"@agentclientprotocol/sdk": "1.3.0",
|
|
134
139
|
"@anthropic-ai/claude-agent-sdk": "0.3.206",
|
|
135
140
|
"@anthropic-ai/sdk": "^0.110.0",
|
|
136
141
|
"@earendil-works/pi-agent-core": "0.83.0",
|
package/src/ai/failure.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
/**
|
|
11
11
|
* @typedef {"spawn" | "timeout" | "stall" | "context_limit" | "usage_limit" | "invalid_result"
|
|
12
12
|
* | "invalid_delegation" | "tool_failure" | "provider_unavailable"
|
|
13
|
-
* | "provider_unavailable_exhausted" | "provider_auth"
|
|
13
|
+
* | "provider_unavailable_exhausted" | "provider_auth" | "provider_protocol"
|
|
14
14
|
* | "skipped_capability_mismatch" | "cancelled" | "cancelled_user"
|
|
15
15
|
* | "cancelled_shutdown" | "cancelled_signal" | "abandoned"
|
|
16
16
|
* | "session_not_found" | "session_busy" | (string & {})} FailureKind
|
|
@@ -49,6 +49,7 @@ export const FAILURE_KINDS = [
|
|
|
49
49
|
"provider_unavailable",
|
|
50
50
|
"provider_unavailable_exhausted",
|
|
51
51
|
"provider_auth",
|
|
52
|
+
"provider_protocol",
|
|
52
53
|
"skipped_capability_mismatch",
|
|
53
54
|
"child_failed",
|
|
54
55
|
"budget_exceeded",
|
package/src/ai/index.js
CHANGED
|
@@ -12,6 +12,8 @@ export {
|
|
|
12
12
|
} from "./runtime/sessions.js";
|
|
13
13
|
export { createMetricsObserver, createObserverHub } from "./observer.js";
|
|
14
14
|
export { generatePiNativeResponse, piNativeRuntimeBridge } from "./providers/pi-native.js";
|
|
15
|
+
export { generateAcpResponse, acpRuntimeBridge } from "./providers/acp.js";
|
|
16
|
+
export * from "./providers/acp-public.js";
|
|
15
17
|
export {
|
|
16
18
|
getPiBuiltinModel,
|
|
17
19
|
listPiBuiltinModels,
|