@mono-agent/agent-runtime 0.20.11 → 0.20.14

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.
Files changed (101) hide show
  1. package/MIGRATION.md +264 -25
  2. package/README.md +139 -448
  3. package/package.json +7 -43
  4. package/src/agent/tools/agent-tool.js +5 -5
  5. package/src/agent/tools/bash.js +1 -24
  6. package/src/agent/tools/codex-subscription-search.js +1 -1
  7. package/src/agent/tools/index.js +7 -0
  8. package/src/agent/tools/monitor.js +140 -0
  9. package/src/agent/tools/pi-bridge.js +92 -7
  10. package/src/agent/tools/shared/bash-environment.js +31 -0
  11. package/src/agent/tools/shared/monitors.js +274 -0
  12. package/src/agent/tools/shared/process-runner.js +23 -5
  13. package/src/ai/cost.js +13 -68
  14. package/src/ai/index.js +4 -17
  15. package/src/ai/pi-interop.js +65 -1
  16. package/src/ai/pi-oauth-compat.js +1 -1
  17. package/src/ai/providers/codex/app-server-client.js +592 -0
  18. package/src/ai/providers/pi-models.js +18 -10
  19. package/src/ai/providers/pi-native/compaction-driver.js +49 -21
  20. package/src/ai/providers/pi-native/harness-adapter.js +338 -0
  21. package/src/ai/providers/pi-native/result-builder.js +10 -10
  22. package/src/ai/providers/pi-native/session-lifecycle.js +95 -40
  23. package/src/ai/providers/pi-native/stream-subscriber.js +23 -5
  24. package/src/ai/providers/pi-native/turn-runner.js +34 -15
  25. package/src/ai/providers/pi-native.js +48 -22
  26. package/src/ai/runtime/capabilities.js +11 -56
  27. package/src/ai/runtime/model-refs.js +118 -153
  28. package/src/ai/runtime/registry.js +22 -56
  29. package/src/ai/runtime/router.js +48 -408
  30. package/src/ai/runtime/session-liveness.js +3 -4
  31. package/src/ai/runtime/sessions.js +4 -5
  32. package/src/ai/runtime/tool-policy.js +0 -2
  33. package/src/ai/types.js +12 -108
  34. package/src/index.js +0 -6
  35. package/src/runtime.js +8 -14
  36. package/types/agent/tools/agent-tool.d.ts +1 -2
  37. package/types/agent/tools/codex-subscription-search.d.ts +1 -1
  38. package/types/agent/tools/index.d.ts +1 -0
  39. package/types/agent/tools/monitor.d.ts +44 -0
  40. package/types/agent/tools/pi-bridge.d.ts +3 -2
  41. package/types/agent/tools/shared/bash-environment.d.ts +4 -0
  42. package/types/agent/tools/shared/monitors.d.ts +83 -0
  43. package/types/agent/tools/shared/process-runner.d.ts +11 -2
  44. package/types/ai/cost.d.ts +1 -2
  45. package/types/ai/index.d.ts +1 -4
  46. package/types/ai/pi-interop.d.ts +20 -0
  47. package/types/ai/providers/codex/app-server-client.d.ts +37 -0
  48. package/types/ai/providers/pi-native/harness-adapter.d.ts +56 -0
  49. package/types/ai/providers/pi-native/result-builder.d.ts +3 -3
  50. package/types/ai/providers/pi-native/session-lifecycle.d.ts +2 -1
  51. package/types/ai/providers/pi-native/stream-subscriber.d.ts +2 -2
  52. package/types/ai/providers/pi-native/turn-runner.d.ts +33 -6
  53. package/types/ai/providers/pi-native.d.ts +21 -4
  54. package/types/ai/runtime/capabilities.d.ts +21 -70
  55. package/types/ai/runtime/model-refs.d.ts +0 -24
  56. package/types/ai/runtime/router.d.ts +3 -10
  57. package/types/ai/runtime/tool-policy.d.ts +0 -2
  58. package/types/ai/types.d.ts +28 -250
  59. package/types/index.d.ts +0 -1
  60. package/src/ai/providers/acp-client.js +0 -1149
  61. package/src/ai/providers/acp-privacy.js +0 -124
  62. package/src/ai/providers/acp-public.js +0 -21
  63. package/src/ai/providers/acp-session-tokens.js +0 -282
  64. package/src/ai/providers/acp-transport.js +0 -356
  65. package/src/ai/providers/acp.js +0 -543
  66. package/src/ai/providers/claude-cli.js +0 -883
  67. package/src/ai/providers/claude-sandbox.js +0 -71
  68. package/src/ai/providers/claude-sdk-discovery-worker.js +0 -53
  69. package/src/ai/providers/claude-sdk-discovery.js +0 -352
  70. package/src/ai/providers/claude-sdk.js +0 -1127
  71. package/src/ai/providers/claude-subagent-activity.js +0 -719
  72. package/src/ai/providers/claude-subagents.js +0 -88
  73. package/src/ai/providers/codex-app.js +0 -2946
  74. package/src/ai/providers/opencode-app.js +0 -1109
  75. package/src/ai/providers/opencode-discovery.js +0 -39
  76. package/src/ai/providers/opencode-server.js +0 -508
  77. package/src/ai/runtime/context-windows.js +0 -46
  78. package/src/ai/runtime/fast-mode.js +0 -8
  79. package/src/ai/streaming/codex-events.js +0 -146
  80. package/src/ai/streaming/opencode-events.js +0 -59
  81. package/types/ai/providers/acp-client.d.ts +0 -227
  82. package/types/ai/providers/acp-privacy.d.ts +0 -25
  83. package/types/ai/providers/acp-public.d.ts +0 -7
  84. package/types/ai/providers/acp-session-tokens.d.ts +0 -41
  85. package/types/ai/providers/acp-transport.d.ts +0 -45
  86. package/types/ai/providers/acp.d.ts +0 -93
  87. package/types/ai/providers/claude-cli.d.ts +0 -305
  88. package/types/ai/providers/claude-sandbox.d.ts +0 -79
  89. package/types/ai/providers/claude-sdk-discovery-worker.d.ts +0 -1
  90. package/types/ai/providers/claude-sdk-discovery.d.ts +0 -97
  91. package/types/ai/providers/claude-sdk.d.ts +0 -138
  92. package/types/ai/providers/claude-subagent-activity.d.ts +0 -53
  93. package/types/ai/providers/claude-subagents.d.ts +0 -18
  94. package/types/ai/providers/codex-app.d.ts +0 -151
  95. package/types/ai/providers/opencode-app.d.ts +0 -96
  96. package/types/ai/providers/opencode-discovery.d.ts +0 -4
  97. package/types/ai/providers/opencode-server.d.ts +0 -20
  98. package/types/ai/runtime/context-windows.d.ts +0 -9
  99. package/types/ai/runtime/fast-mode.d.ts +0 -2
  100. package/types/ai/streaming/codex-events.d.ts +0 -40
  101. package/types/ai/streaming/opencode-events.d.ts +0 -42
@@ -1,48 +1,17 @@
1
1
  /**
2
- * @typedef {"claude" | "pi" | "codex" | "opencode" | "acp" | (string & {})} RuntimeSdkId
3
- * Canonical active runtime id. See ACTIVE_RUNTIME_KINDS (model-refs.js) for
4
- * the enforced-at-runtime vocabulary.
2
+ * @typedef {"pi"} RuntimeSdkId
3
+ * Runtime-result and telemetry label. Model references no longer carry this
4
+ * field because Pi is the sole runtime bridge.
5
5
  */
6
6
  /**
7
- * @typedef {"claude" | "claude-code" | "codex-app" | "opencode-app" | "pi" | "acp-stdio" | (string & {})} RuntimeBridgeId
8
- * Registry bridge id (distinct from RuntimeSdkId: a single sdk can be served
9
- * by more than one bridge, e.g. sdk "claude" is served by both the "claude"
10
- * SDK bridge and the "claude-code" CLI bridge). See
11
- * src/ai/runtime/registry.js's builtinBridgeSpecs.
7
+ * @typedef {"pi"} RuntimeBridgeId
8
+ * Registry bridge id. See src/ai/runtime/registry.js's builtinBridgeSpecs.
12
9
  */
13
10
  /**
14
11
  * @typedef {Object} RuntimeModelRef
15
- * @property {RuntimeSdkId} sdk Canonical active runtime id.
12
+ * @property {string} provider Pi provider id.
16
13
  * @property {string} model Provider model id.
17
- * @property {string} [reference] Original canonical model reference; always set by
18
- * parseRuntimeModelReference, but router.js's chain
19
- * shorthand accepts bare {sdk, model} refs without one.
20
- * @property {string} [provider] Pi/OpenCode provider id when sdk === "pi" | "opencode".
21
- */
22
- /**
23
- * @typedef {Object} RuntimeNativeSubagentDefinition
24
- * One caller-defined Claude native `Task` profile. Codex collaboration-agent
25
- * definitions are owned by Codex and are not represented by this type.
26
- * @property {string} name
27
- * @property {string} [displayName]
28
- * @property {string} [description]
29
- * @property {string} [helperSystemPrompt]
30
- * @property {string} [instructions]
31
- * @property {ReadonlyArray<string>} [allowedTools]
32
- * @property {ReadonlyArray<string>} [disallowedTools]
33
- * @property {string | RuntimeModelRef} [modelRef]
34
- * @property {RuntimeModelRef} [model]
35
- * @property {string} [effort]
36
- * @property {Object<string, Object>} [mcpServers]
37
- * @property {Object} [mcpApps] App-owned exact-connection MCP Apps registry (Pi-native only).
38
- */
39
- /**
40
- * @typedef {Object} RuntimeNativeSubagentsOptions
41
- * Caller-defined native profiles are supported only by the Claude bridges.
42
- * Codex owns its collaboration agents; use `codexLoadProjectDocs` when those
43
- * agents should receive repository instructions.
44
- * @property {"claude"} provider
45
- * @property {ReadonlyArray<RuntimeNativeSubagentDefinition>} teammates
14
+ * @property {string} reference Canonical `<provider>:<model>` reference.
46
15
  */
47
16
  /**
48
17
  * @typedef {Object} RuntimeSubagentIdentity
@@ -134,28 +103,6 @@
134
103
  * @param {RuntimeToolLifecycleEvent} event
135
104
  * @returns {Promise<RuntimeToolLifecyclePersistence|undefined>}
136
105
  */
137
- /** @typedef {"uniform"|"per-route-native"} RuntimeRouteSafetyMode */
138
- /**
139
- * @typedef {"mono-agent-monotonic"|"disabled"|"mono-agent-srt"|"mono-agent-srt-unsafe-host-fallback"|"provider-native"|"codex-native"|"unsupported"} RuntimeRouteSandboxContract
140
- * Fixed telemetry vocabulary for a route's sandbox posture. The
141
- * `mono-agent-srt-unsafe-host-fallback` describes a policy that prefers SRT but
142
- * explicitly permits host execution if unavailable; it does not claim which
143
- * branch ran for a particular command.
144
- */
145
- /**
146
- * @typedef {"mono-agent-monotonic"|"mono-agent-policy"|"provider-representable"|"exact-allow-all"|"unsupported"} RuntimeRouteToolsContract
147
- * `exact-allow-all` is a stable telemetry token. It describes an effective
148
- * unrestricted contract, including mixed allowlists that contain `"*"`;
149
- * it does not require the literal one-element array `["*"]`.
150
- */
151
- /**
152
- * @typedef {Object} RuntimeRouteSafetyContract
153
- * Bounded, credential-free description of the sandbox/tool contract applied
154
- * to one fallback route.
155
- * @property {RuntimeRouteSafetyMode} mode
156
- * @property {RuntimeRouteSandboxContract} sandbox
157
- * @property {RuntimeRouteToolsContract} tools
158
- */
159
106
  /**
160
107
  * @typedef {Object} RuntimeObserver
161
108
  * Per-call or host-level observer merged by createObserverHub (ai/observer.js).
@@ -214,10 +161,8 @@
214
161
  * @typedef {Object} RuntimeRunOptions
215
162
  * The options object a host passes to `createRuntime(host).run(systemPrompt, options)`.
216
163
  * @property {RuntimeModelRef} model Resolved model reference; see parseRuntimeModelReference.
217
- * @property {"sdk"|"cli"|"acp"} [executionMode] "sdk" (default), "cli", or "acp"; selects which bridge variant handles the model.
218
164
  * @property {string} [sessionId] Host conversation/session key for resumable bridges.
219
165
  * @property {string} [providerSessionId] Provider-owned resume id for resumable bridges.
220
- * @property {typeof import("@anthropic-ai/claude-agent-sdk").query} [claudeAgentQuery] Advanced programmatic/test seam for the Claude SDK route; omitted runs use the runtime's pinned SDK query implementation.
221
166
  * @property {boolean} [sessionKeepAlive] Keep resumable provider state alive after the turn.
222
167
  * @property {number} [sessionIdleTimeoutMs] Idle TTL for resumable provider state.
223
168
  * @property {AsyncIterable<{body: string, id?: string, receivedAt?: string, acknowledge?: () => void, reject?: (error?: unknown) => void}>} [liveInput] Stream of in-flight user messages for steering an active run. Providers acknowledge only after accepting a message into the active turn.
@@ -226,7 +171,6 @@
226
171
  * @property {RuntimeToolLifecycleSink} [toolLifecycleSink] Awaited host-owned incremental lifecycle persistence boundary.
227
172
  * @property {ReadonlyArray<Object>} [messages]
228
173
  * @property {string} [effort]
229
- * @property {boolean} [fastMode]
230
174
  * @property {string} [cwd]
231
175
  * @property {Object<string, Object>} [mcpServers]
232
176
  * @property {ReadonlyArray<{name: string, description?: string}>} [skills] Skills disclosed to this run, as `{name, description}`. Non-empty makes `supports_skills` a routing requirement (see router.js), so a chain entry that lacks it is skipped.
@@ -245,36 +189,14 @@
245
189
  * @property {RuntimeToolLimits} [toolLimits] Typed per-run tool-output limits (supported replacement for the deprecated `settings` tool keys).
246
190
  * @property {RuntimeCompactionPolicy} [compaction] Typed per-run compaction policy (supported replacement for the deprecated `settings` compaction keys).
247
191
  * @property {RuntimePromptOverrides} [prompts] Per-run prompt-fragment overrides (run wins over the host default).
248
- * @property {import('./providers/acp-client.js').AcpClientHostOptions["resolveAcpProfile"]} [resolveAcpProfile] Per-run ACP profile resolver; wins over the host default.
249
- * @property {import('./providers/acp-client.js').AcpClientHostOptions["onAcpInteractionRequest"]} [onAcpInteractionRequest] Per-run ACP permission/elicitation callback; wins over the host default.
250
- * @property {Uint8Array} [acpSessionTokenKey] Host-owned 32-byte key for confidential authenticated ACP session handles. Required for every ACP task run.
251
192
  * @property {{backend?: "auto"|"searxng"|"codex"|"keyless", endpoint?: string, codex?: {model?: string}}} [webSearchConfig] Run-scoped WebSearch backend configuration.
252
193
  * @property {{render?: "never"|"auto", browserCommand?: string}} [webFetchConfig] Run-scoped WebFetch extraction/render configuration.
253
194
  * @property {"sequential"|"safe-parallel"} [piToolExecutionMode] Pi built-in tool scheduling mode. Safe parallelism is the default.
254
195
  * @property {"one-at-a-time"|"all"} [piToolParallelismMode] DEPRECATED. Compatibility alias mapped to piToolExecutionMode.
255
196
  * @property {Object} [settings] DEPRECATED. Legacy flat settings bag; consumed only as a per-group FALLBACK when the corresponding typed object (`toolLimits` / `compaction`) is absent. Consuming any key emits one `deprecated_settings_option` runtime_warning per run. Migrate via resolveRuntimePolicies (@mono-agent/runtime-adapter).
256
- * @property {ReadonlyArray<"user" | "project" | "local">} [settingSources] Claude Agent SDK only. Filesystem
257
- * settings the SDK may load for this run. Omitted/empty disables user, project, and local sources, including their
258
- * CLAUDE.md, hooks, plugins, and on-disk agent profiles. Anthropic managed settings remain in force and may still
259
- * configure hooks or plugins; this option is not a managed-policy bypass. Each opted-in source may execute configured
260
- * hooks and plugins, so enable only trusted settings and avoid these sources in an untrusted checkout. Include
261
- * `"project"`/`"user"` to let the native `Task` tool discover `.claude/agents` definitions. Unrecognized entries are
262
- * dropped. The Claude Code CLI bridge does not take this option: that binary performs its own settings discovery and
263
- * mono-agent passes no `--setting-sources`, so a CLI run already reads the host config regardless of this value.
264
- * @property {boolean} [codexLoadProjectDocs] Codex app-server only. Omitted/false starts the managed app-server with
265
- * `project_doc_max_bytes=0`, preventing automatic repository-instruction discovery. True restores Codex's native
266
- * project-doc loading defaults. An explicit `codexAppServerArgs` array wins over this convenience option.
267
- * @property {boolean} [codexSandboxNetworkAccess] Codex app-server only, code-only. Strict `true` enables native
268
- * network access for plan/read-only and default/acceptEdits/workspace-write turns; omitted or any other runtime
269
- * value denies it. No-tool probes always deny network access, and bypass/danger-full-access remains unchanged. This
270
- * is unrelated to `RuntimeRunOptions.sandboxPolicy`, which controls mono-agent's own sandbox and is not consumed by
271
- * Codex's provider-owned tool loop. Default/acceptEdits workspace-write plus network true grants repository read and
272
- * network egress in the same turn; prefer plan when only read-only browsing is needed.
273
- * @property {RuntimeNativeSubagentsOptions} [nativeSubagents] Caller-defined Claude native `Task` profiles. Direct
274
- * Codex owns its collaboration agents and rejects configured teammate definitions; `codexLoadProjectDocs` controls
275
- * whether Codex loads repository instructions for its own agents.
276
197
  * @property {RuntimeSubagentsOptions} [subagents] In-process `Agent` built-in: profiles, caps, and the nested-run callback.
277
198
  * @property {import('../agent/tools/shared/process-jobs.js').ProcessJobsController} [processJobs] Pi-native-only structural process-job controller. When absent, Exec/Bash schemas and foreground behavior are unchanged.
199
+ * @property {import('../agent/tools/shared/monitors.js').MonitorsController} [monitors] Pi-native-only structural monitor controller. When absent, the Monitor and MonitorStop tools are not registered at all.
278
200
  * @property {Object} [diagnosticsSeed] Set by createRouterRuntime (ai/runtime/router.js) with a `resume_snapshot` when
279
201
  * failing over mid-chain; a host-level coordinator may relay it forward (see agent/transcript.js), not read by any
280
202
  * bridge in this package today.
@@ -284,7 +206,7 @@
284
206
  */
285
207
  /**
286
208
  * @typedef {RuntimeRunOptions
287
- * & Pick<AgentRuntimeHostOptions, "resolveCustomPricing" | "resolvePiApiKey" | "resolveAcpProfile" | "onAcpInteractionRequest" | "acpSessionTokenKey" | "persistArtifact" | "onCompactionRecorded" | "onToolApprovalRequest" | "toolRiskTiers" | "approvalDefaultRiskTier" | "approvalTimeoutMs" | "approvalAlwaysAllowTools">
209
+ * & Pick<AgentRuntimeHostOptions, "resolveCustomPricing" | "resolvePiApiKey" | "persistArtifact" | "onCompactionRecorded" | "onToolApprovalRequest" | "toolRiskTiers" | "approvalDefaultRiskTier" | "approvalTimeoutMs" | "approvalAlwaysAllowTools">
288
210
  * & {runtimeBrand: import('../runtime-brand.js').RuntimeBrand, toolContext?: import('../agent/tools/shared/tool-context.js').ToolContext, observerHub: {emit: (event: RuntimeEvent) => void, flush: () => Promise<void>}}
289
211
  * } RuntimeRequest
290
212
  * The request shape a bridge's `execute(systemPrompt, req)` receives as its
@@ -361,8 +283,7 @@
361
283
  * @property {Array<Object>} [runtimeWarnings]
362
284
  * @property {Object} [diagnostics]
363
285
  * @property {Object} [capabilitiesUsed]
364
- * @property {Array<{model: RuntimeModelRef, failureKind: (string|null), requestId?: (string|null), retryableSubkind?: (string|null), retryIndex?: number, requirements?: Object, routeSafety?: RuntimeRouteSafetyMode, safetyContract?: RuntimeRouteSafetyContract}>} [failoverHistory] Set by createRouterRuntime (ai/runtime/router.js) on every failed/skipped attempt.
365
- * @property {Array<{attemptIndex: number, model: RuntimeModelRef, routeSafety: RuntimeRouteSafetyMode, safetyContract: RuntimeRouteSafetyContract, status: string}>} [routeSafetyHistory] Bounded route-safety audit emitted by createRouterRuntime.
286
+ * @property {Array<{model: RuntimeModelRef, failureKind: (string|null), requestId?: (string|null), retryableSubkind?: (string|null), retryIndex?: number, requirements?: Object}>} [failoverHistory] Set by createRouterRuntime (ai/runtime/router.js) on every failed/skipped attempt.
366
287
  */
367
288
  /**
368
289
  * @typedef {Object} RuntimeCapabilities
@@ -381,8 +302,7 @@
381
302
  * @property {boolean} [supports_builtin_tools]
382
303
  * @property {boolean} [supports_live_input]
383
304
  * @property {boolean} [supports_native_subagents] Whether the bridge exposes provider-native subagent surfaces and
384
- * normalized activity. This does not imply it accepts caller-defined `nativeSubagents`: Codex owns its collaboration
385
- * agents, while only the Claude bridges project caller-defined profiles.
305
+ * normalized activity. In-process delegation is the `Agent` tool, configured by the host.
386
306
  * @property {boolean} [supports_request_tool_environment]
387
307
  * @property {boolean} [supports_fast_mode]
388
308
  * @property {"projected"|"allow_all_only"} [tool_policy] Whether the bridge can
@@ -455,11 +375,8 @@
455
375
  * @property {RuntimePromptOverrides} [prompts] Host-level prompt-fragment override defaults; a per-run `options.prompts` field wins over these (see resolvePrompts, runtime.js).
456
376
  * @property {ReadonlyArray<*>} [observers] Observer instances (see RuntimeObserver); loose because observer.js is not a kernel seam file.
457
377
  * @property {*} [runtimeBrand] See resolveRuntimeBrand (runtime-brand.js); accepts a partial RuntimeBrand.
458
- * @property {(parsed: {sdk: (string|null), provider?: string, model: string}) => (import('./cost.js').NormalizedPricing|null)} [resolveCustomPricing] See resolvePricing (ai/cost.js).
378
+ * @property {(parsed: {provider: string, model: string}) => (import('./cost.js').NormalizedPricing|null)} [resolveCustomPricing] See resolvePricing (ai/cost.js).
459
379
  * @property {import('../pi-auth.js').PiApiKeyResolver} [resolvePiApiKey] See createPiOAuthApiKeyResolver (pi-auth.js) for a ready-made implementation.
460
- * @property {import('./providers/acp-client.js').AcpClientHostOptions["resolveAcpProfile"]} [resolveAcpProfile] Default ACP profile resolver; a per-run callback wins.
461
- * @property {import('./providers/acp-client.js').AcpClientHostOptions["onAcpInteractionRequest"]} [onAcpInteractionRequest] Default ACP interaction callback; a per-run callback wins.
462
- * @property {Uint8Array} [acpSessionTokenKey] Default host-owned 32-byte key for confidential authenticated ACP session handles.
463
380
  * @property {(artifact: {filename: string, buffer: Buffer, toolName: string, toolUseId: (string|null)}) => (string|null)} [persistArtifact]
464
381
  * @property {(record: CompactionRecordedPayload) => void} [onCompactionRecorded]
465
382
  * @property {(payload: ApprovalRequestPayload) => Promise<ApprovalDecision>} [onToolApprovalRequest]
@@ -494,68 +411,27 @@
494
411
  */
495
412
  export const PROVIDER_KIND_VALUES: string[];
496
413
  /**
497
- * Canonical active runtime id. See ACTIVE_RUNTIME_KINDS (model-refs.js) for
498
- * the enforced-at-runtime vocabulary.
414
+ * Runtime-result and telemetry label. Model references no longer carry this
415
+ * field because Pi is the sole runtime bridge.
499
416
  */
500
- export type RuntimeSdkId = "claude" | "pi" | "codex" | "opencode" | "acp" | (string & {});
417
+ export type RuntimeSdkId = "pi";
501
418
  /**
502
- * Registry bridge id (distinct from RuntimeSdkId: a single sdk can be served
503
- * by more than one bridge, e.g. sdk "claude" is served by both the "claude"
504
- * SDK bridge and the "claude-code" CLI bridge). See
505
- * src/ai/runtime/registry.js's builtinBridgeSpecs.
419
+ * Registry bridge id. See src/ai/runtime/registry.js's builtinBridgeSpecs.
506
420
  */
507
- export type RuntimeBridgeId = "claude" | "claude-code" | "codex-app" | "opencode-app" | "pi" | "acp-stdio" | (string & {});
421
+ export type RuntimeBridgeId = "pi";
508
422
  export type RuntimeModelRef = {
509
423
  /**
510
- * Canonical active runtime id.
424
+ * Pi provider id.
511
425
  */
512
- sdk: RuntimeSdkId;
426
+ provider: string;
513
427
  /**
514
428
  * Provider model id.
515
429
  */
516
430
  model: string;
517
431
  /**
518
- * Original canonical model reference; always set by
519
- * parseRuntimeModelReference, but router.js's chain
520
- * shorthand accepts bare {sdk, model} refs without one.
432
+ * Canonical `<provider>:<model>` reference.
521
433
  */
522
- reference?: string;
523
- /**
524
- * Pi/OpenCode provider id when sdk === "pi" | "opencode".
525
- */
526
- provider?: string;
527
- };
528
- /**
529
- * One caller-defined Claude native `Task` profile. Codex collaboration-agent
530
- * definitions are owned by Codex and are not represented by this type.
531
- */
532
- export type RuntimeNativeSubagentDefinition = {
533
- name: string;
534
- displayName?: string;
535
- description?: string;
536
- helperSystemPrompt?: string;
537
- instructions?: string;
538
- allowedTools?: ReadonlyArray<string>;
539
- disallowedTools?: ReadonlyArray<string>;
540
- modelRef?: string | RuntimeModelRef;
541
- model?: RuntimeModelRef;
542
- effort?: string;
543
- mcpServers?: {
544
- [x: string]: any;
545
- };
546
- /**
547
- * App-owned exact-connection MCP Apps registry (Pi-native only).
548
- */
549
- mcpApps?: any;
550
- };
551
- /**
552
- * Caller-defined native profiles are supported only by the Claude bridges.
553
- * Codex owns its collaboration agents; use `codexLoadProjectDocs` when those
554
- * agents should receive repository instructions.
555
- */
556
- export type RuntimeNativeSubagentsOptions = {
557
- provider: "claude";
558
- teammates: ReadonlyArray<RuntimeNativeSubagentDefinition>;
434
+ reference: string;
559
435
  };
560
436
  /**
561
437
  * Provider-neutral identity attached to every `subagent_activity` event.
@@ -684,29 +560,6 @@ export type RuntimeToolLifecyclePersistence = Readonly<{
684
560
  errorCode?: string;
685
561
  }>;
686
562
  export type RuntimeToolLifecycleSink = (event: RuntimeToolLifecycleEvent) => Promise<RuntimeToolLifecyclePersistence | undefined>;
687
- export type RuntimeRouteSafetyMode = "uniform" | "per-route-native";
688
- /**
689
- * Fixed telemetry vocabulary for a route's sandbox posture. The
690
- * `mono-agent-srt-unsafe-host-fallback` describes a policy that prefers SRT but
691
- * explicitly permits host execution if unavailable; it does not claim which
692
- * branch ran for a particular command.
693
- */
694
- export type RuntimeRouteSandboxContract = "mono-agent-monotonic" | "disabled" | "mono-agent-srt" | "mono-agent-srt-unsafe-host-fallback" | "provider-native" | "codex-native" | "unsupported";
695
- /**
696
- * `exact-allow-all` is a stable telemetry token. It describes an effective
697
- * unrestricted contract, including mixed allowlists that contain `"*"`;
698
- * it does not require the literal one-element array `["*"]`.
699
- */
700
- export type RuntimeRouteToolsContract = "mono-agent-monotonic" | "mono-agent-policy" | "provider-representable" | "exact-allow-all" | "unsupported";
701
- /**
702
- * Bounded, credential-free description of the sandbox/tool contract applied
703
- * to one fallback route.
704
- */
705
- export type RuntimeRouteSafetyContract = {
706
- mode: RuntimeRouteSafetyMode;
707
- sandbox: RuntimeRouteSandboxContract;
708
- tools: RuntimeRouteToolsContract;
709
- };
710
563
  /**
711
564
  * Per-call or host-level observer merged by createObserverHub (ai/observer.js).
712
565
  * Loose on purpose: observer.js is not a kernel seam file.
@@ -827,10 +680,6 @@ export type RuntimeRunOptions = {
827
680
  * Resolved model reference; see parseRuntimeModelReference.
828
681
  */
829
682
  model: RuntimeModelRef;
830
- /**
831
- * "sdk" (default), "cli", or "acp"; selects which bridge variant handles the model.
832
- */
833
- executionMode?: "sdk" | "cli" | "acp";
834
683
  /**
835
684
  * Host conversation/session key for resumable bridges.
836
685
  */
@@ -839,10 +688,6 @@ export type RuntimeRunOptions = {
839
688
  * Provider-owned resume id for resumable bridges.
840
689
  */
841
690
  providerSessionId?: string;
842
- /**
843
- * Advanced programmatic/test seam for the Claude SDK route; omitted runs use the runtime's pinned SDK query implementation.
844
- */
845
- claudeAgentQuery?: typeof import("@anthropic-ai/claude-agent-sdk").query;
846
691
  /**
847
692
  * Keep resumable provider state alive after the turn.
848
693
  */
@@ -872,7 +717,6 @@ export type RuntimeRunOptions = {
872
717
  toolLifecycleSink?: RuntimeToolLifecycleSink;
873
718
  messages?: ReadonlyArray<any>;
874
719
  effort?: string;
875
- fastMode?: boolean;
876
720
  cwd?: string;
877
721
  mcpServers?: {
878
722
  [x: string]: any;
@@ -927,18 +771,6 @@ export type RuntimeRunOptions = {
927
771
  * Per-run prompt-fragment overrides (run wins over the host default).
928
772
  */
929
773
  prompts?: RuntimePromptOverrides;
930
- /**
931
- * Per-run ACP profile resolver; wins over the host default.
932
- */
933
- resolveAcpProfile?: import("./providers/acp-client.js").AcpClientHostOptions["resolveAcpProfile"];
934
- /**
935
- * Per-run ACP permission/elicitation callback; wins over the host default.
936
- */
937
- onAcpInteractionRequest?: import("./providers/acp-client.js").AcpClientHostOptions["onAcpInteractionRequest"];
938
- /**
939
- * Host-owned 32-byte key for confidential authenticated ACP session handles. Required for every ACP task run.
940
- */
941
- acpSessionTokenKey?: Uint8Array;
942
774
  /**
943
775
  * Run-scoped WebSearch backend configuration.
944
776
  */
@@ -968,38 +800,6 @@ export type RuntimeRunOptions = {
968
800
  * DEPRECATED. Legacy flat settings bag; consumed only as a per-group FALLBACK when the corresponding typed object (`toolLimits` / `compaction`) is absent. Consuming any key emits one `deprecated_settings_option` runtime_warning per run. Migrate via resolveRuntimePolicies (@mono-agent/runtime-adapter).
969
801
  */
970
802
  settings?: any;
971
- /**
972
- * Claude Agent SDK only. Filesystem
973
- * settings the SDK may load for this run. Omitted/empty disables user, project, and local sources, including their
974
- * CLAUDE.md, hooks, plugins, and on-disk agent profiles. Anthropic managed settings remain in force and may still
975
- * configure hooks or plugins; this option is not a managed-policy bypass. Each opted-in source may execute configured
976
- * hooks and plugins, so enable only trusted settings and avoid these sources in an untrusted checkout. Include
977
- * `"project"`/`"user"` to let the native `Task` tool discover `.claude/agents` definitions. Unrecognized entries are
978
- * dropped. The Claude Code CLI bridge does not take this option: that binary performs its own settings discovery and
979
- * mono-agent passes no `--setting-sources`, so a CLI run already reads the host config regardless of this value.
980
- */
981
- settingSources?: ReadonlyArray<"user" | "project" | "local">;
982
- /**
983
- * Codex app-server only. Omitted/false starts the managed app-server with
984
- * `project_doc_max_bytes=0`, preventing automatic repository-instruction discovery. True restores Codex's native
985
- * project-doc loading defaults. An explicit `codexAppServerArgs` array wins over this convenience option.
986
- */
987
- codexLoadProjectDocs?: boolean;
988
- /**
989
- * Codex app-server only, code-only. Strict `true` enables native
990
- * network access for plan/read-only and default/acceptEdits/workspace-write turns; omitted or any other runtime
991
- * value denies it. No-tool probes always deny network access, and bypass/danger-full-access remains unchanged. This
992
- * is unrelated to `RuntimeRunOptions.sandboxPolicy`, which controls mono-agent's own sandbox and is not consumed by
993
- * Codex's provider-owned tool loop. Default/acceptEdits workspace-write plus network true grants repository read and
994
- * network egress in the same turn; prefer plan when only read-only browsing is needed.
995
- */
996
- codexSandboxNetworkAccess?: boolean;
997
- /**
998
- * Caller-defined Claude native `Task` profiles. Direct
999
- * Codex owns its collaboration agents and rejects configured teammate definitions; `codexLoadProjectDocs` controls
1000
- * whether Codex loads repository instructions for its own agents.
1001
- */
1002
- nativeSubagents?: RuntimeNativeSubagentsOptions;
1003
803
  /**
1004
804
  * In-process `Agent` built-in: profiles, caps, and the nested-run callback.
1005
805
  */
@@ -1008,6 +808,10 @@ export type RuntimeRunOptions = {
1008
808
  * Pi-native-only structural process-job controller. When absent, Exec/Bash schemas and foreground behavior are unchanged.
1009
809
  */
1010
810
  processJobs?: import("../agent/tools/shared/process-jobs.js").ProcessJobsController;
811
+ /**
812
+ * Pi-native-only structural monitor controller. When absent, the Monitor and MonitorStop tools are not registered at all.
813
+ */
814
+ monitors?: import("../agent/tools/shared/monitors.js").MonitorsController;
1011
815
  /**
1012
816
  * Set by createRouterRuntime (ai/runtime/router.js) with a `resume_snapshot` when
1013
817
  * failing over mid-chain; a host-level coordinator may relay it forward (see agent/transcript.js), not read by any
@@ -1030,7 +834,7 @@ export type RuntimeRunOptions = {
1030
834
  * createRuntime), and the per-run observerHub (onEvent is overridden to the
1031
835
  * hub's emit). `systemPrompt` is passed positionally, not folded into this object.
1032
836
  */
1033
- export type RuntimeRequest = RuntimeRunOptions & Pick<AgentRuntimeHostOptions, "resolveCustomPricing" | "resolvePiApiKey" | "resolveAcpProfile" | "onAcpInteractionRequest" | "acpSessionTokenKey" | "persistArtifact" | "onCompactionRecorded" | "onToolApprovalRequest" | "toolRiskTiers" | "approvalDefaultRiskTier" | "approvalTimeoutMs" | "approvalAlwaysAllowTools"> & {
837
+ export type RuntimeRequest = RuntimeRunOptions & Pick<AgentRuntimeHostOptions, "resolveCustomPricing" | "resolvePiApiKey" | "persistArtifact" | "onCompactionRecorded" | "onToolApprovalRequest" | "toolRiskTiers" | "approvalDefaultRiskTier" | "approvalTimeoutMs" | "approvalAlwaysAllowTools"> & {
1034
838
  runtimeBrand: import("../runtime-brand.js").RuntimeBrand;
1035
839
  toolContext?: import("../agent/tools/shared/tool-context.js").ToolContext;
1036
840
  observerHub: {
@@ -1162,18 +966,6 @@ export type RuntimeResult = {
1162
966
  retryableSubkind?: (string | null);
1163
967
  retryIndex?: number;
1164
968
  requirements?: any;
1165
- routeSafety?: RuntimeRouteSafetyMode;
1166
- safetyContract?: RuntimeRouteSafetyContract;
1167
- }>;
1168
- /**
1169
- * Bounded route-safety audit emitted by createRouterRuntime.
1170
- */
1171
- routeSafetyHistory?: Array<{
1172
- attemptIndex: number;
1173
- model: RuntimeModelRef;
1174
- routeSafety: RuntimeRouteSafetyMode;
1175
- safetyContract: RuntimeRouteSafetyContract;
1176
- status: string;
1177
969
  }>;
1178
970
  };
1179
971
  /**
@@ -1195,8 +987,7 @@ export type RuntimeCapabilities = {
1195
987
  supports_live_input?: boolean;
1196
988
  /**
1197
989
  * Whether the bridge exposes provider-native subagent surfaces and
1198
- * normalized activity. This does not imply it accepts caller-defined `nativeSubagents`: Codex owns its collaboration
1199
- * agents, while only the Claude bridges project caller-defined profiles.
990
+ * normalized activity. In-process delegation is the `Agent` tool, configured by the host.
1200
991
  */
1201
992
  supports_native_subagents?: boolean;
1202
993
  supports_request_tool_environment?: boolean;
@@ -1299,26 +1090,13 @@ export type AgentRuntimeHostOptions = {
1299
1090
  * See resolvePricing (ai/cost.js).
1300
1091
  */
1301
1092
  resolveCustomPricing?: (parsed: {
1302
- sdk: (string | null);
1303
- provider?: string;
1093
+ provider: string;
1304
1094
  model: string;
1305
1095
  }) => (import("./cost.js").NormalizedPricing | null);
1306
1096
  /**
1307
1097
  * See createPiOAuthApiKeyResolver (pi-auth.js) for a ready-made implementation.
1308
1098
  */
1309
1099
  resolvePiApiKey?: import("../pi-auth.js").PiApiKeyResolver;
1310
- /**
1311
- * Default ACP profile resolver; a per-run callback wins.
1312
- */
1313
- resolveAcpProfile?: import("./providers/acp-client.js").AcpClientHostOptions["resolveAcpProfile"];
1314
- /**
1315
- * Default ACP interaction callback; a per-run callback wins.
1316
- */
1317
- onAcpInteractionRequest?: import("./providers/acp-client.js").AcpClientHostOptions["onAcpInteractionRequest"];
1318
- /**
1319
- * Default host-owned 32-byte key for confidential authenticated ACP session handles.
1320
- */
1321
- acpSessionTokenKey?: Uint8Array;
1322
1100
  persistArtifact?: (artifact: {
1323
1101
  filename: string;
1324
1102
  buffer: Buffer;
package/types/index.d.ts CHANGED
@@ -5,4 +5,3 @@ export * from "./ai/index.js";
5
5
  export * from "./agent/index.js";
6
6
  export { configureToolRuntime, readToolRuntime, readRuntimeBrand, resetToolRuntime } from "./agent/tools/shared/runtime-context.js";
7
7
  export { DEFAULT_RUNTIME_BRAND, resolveRuntimeBrand } from "./runtime-brand.js";
8
- export { CLAUDE_SDK_CATALOG_VERSION, discoverClaudeSdkModels, normalizeClaudeSdkCatalog, normalizeClaudeSdkModelId } from "./ai/providers/claude-sdk-discovery.js";