@mono-agent/agent-runtime 0.20.11 → 0.21.0

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 (148) hide show
  1. package/ARCHITECTURE.md +50 -11
  2. package/MIGRATION.md +288 -26
  3. package/README.md +352 -477
  4. package/package.json +13 -44
  5. package/src/agent/tool-bloat.js +145 -9
  6. package/src/agent/tools/agent-tool.js +108 -9
  7. package/src/agent/tools/bash.js +11 -26
  8. package/src/agent/tools/codex-subscription-search.js +123 -29
  9. package/src/agent/tools/exec.js +10 -2
  10. package/src/agent/tools/index.js +7 -0
  11. package/src/agent/tools/monitor.js +149 -0
  12. package/src/agent/tools/pi-bridge.js +123 -19
  13. package/src/agent/tools/shared/bash-environment.js +31 -0
  14. package/src/agent/tools/shared/monitors.js +293 -0
  15. package/src/agent/tools/shared/path-resolver.js +25 -6
  16. package/src/agent/tools/shared/process-jobs.js +6 -1
  17. package/src/agent/tools/shared/process-runner.js +26 -6
  18. package/src/agent/tools/shared/tool-context.js +8 -0
  19. package/src/agent/tools/web-access-interstitial.js +70 -0
  20. package/src/agent/tools/web-browser-render.js +83 -58
  21. package/src/agent/tools/web-controller.js +112 -21
  22. package/src/agent/tools/web-document-extractor.js +379 -0
  23. package/src/agent/tools/web-fetch.js +271 -243
  24. package/src/agent/tools/web-request.js +65 -0
  25. package/src/agent/tools/web-search-output.js +165 -0
  26. package/src/agent/tools/web-search-state.js +75 -0
  27. package/src/agent/tools/web-search.js +532 -71
  28. package/src/ai/cost.js +13 -68
  29. package/src/ai/failure.js +3 -3
  30. package/src/ai/index.js +5 -17
  31. package/src/ai/observer.js +8 -0
  32. package/src/ai/pi-interop.js +221 -1
  33. package/src/ai/pi-oauth-compat.js +1 -1
  34. package/src/ai/provider-check.js +131 -0
  35. package/src/ai/providers/codex/app-server-client.js +592 -0
  36. package/src/ai/providers/pi-models.js +18 -10
  37. package/src/ai/providers/pi-native/compaction-driver.js +94 -42
  38. package/src/ai/providers/pi-native/compaction-summary.js +140 -0
  39. package/src/ai/providers/pi-native/harness-adapter.js +376 -0
  40. package/src/ai/providers/pi-native/prompt-cache-diagnostics.js +103 -0
  41. package/src/ai/providers/pi-native/provider-attribution.js +102 -0
  42. package/src/ai/providers/pi-native/result-builder.js +38 -14
  43. package/src/ai/providers/pi-native/session-lifecycle.js +253 -55
  44. package/src/ai/providers/pi-native/stream-subscriber.js +52 -6
  45. package/src/ai/providers/pi-native/terminal-recovery.js +40 -0
  46. package/src/ai/providers/pi-native/turn-runner.js +279 -28
  47. package/src/ai/providers/pi-native.js +206 -61
  48. package/src/ai/runtime/capabilities.js +11 -56
  49. package/src/ai/runtime/live-input-events.js +250 -54
  50. package/src/ai/runtime/model-refs.js +118 -153
  51. package/src/ai/runtime/registry.js +22 -56
  52. package/src/ai/runtime/router.js +76 -417
  53. package/src/ai/runtime/session-liveness.js +3 -4
  54. package/src/ai/runtime/sessions.js +4 -5
  55. package/src/ai/runtime/tool-policy.js +0 -2
  56. package/src/ai/tool-lifecycle.js +32 -18
  57. package/src/ai/types.js +37 -112
  58. package/src/index.js +0 -6
  59. package/src/runtime.js +29 -16
  60. package/types/agent/tool-bloat.d.ts +1 -1
  61. package/types/agent/tools/agent-tool.d.ts +4 -2
  62. package/types/agent/tools/bash.d.ts +5 -3
  63. package/types/agent/tools/codex-subscription-search.d.ts +7 -3
  64. package/types/agent/tools/exec.d.ts +5 -3
  65. package/types/agent/tools/index.d.ts +1 -0
  66. package/types/agent/tools/monitor.d.ts +47 -0
  67. package/types/agent/tools/pi-bridge.d.ts +7 -4
  68. package/types/agent/tools/shared/bash-environment.d.ts +4 -0
  69. package/types/agent/tools/shared/monitors.d.ts +98 -0
  70. package/types/agent/tools/shared/process-jobs.d.ts +5 -1
  71. package/types/agent/tools/shared/process-runner.d.ts +14 -4
  72. package/types/agent/tools/shared/tool-context.d.ts +2 -0
  73. package/types/agent/tools/web-access-interstitial.d.ts +23 -0
  74. package/types/agent/tools/web-browser-render.d.ts +4 -1
  75. package/types/agent/tools/web-controller.d.ts +4 -2
  76. package/types/agent/tools/web-document-extractor.d.ts +27 -0
  77. package/types/agent/tools/web-fetch.d.ts +19 -24
  78. package/types/agent/tools/web-request.d.ts +20 -0
  79. package/types/agent/tools/web-search-output.d.ts +31 -0
  80. package/types/agent/tools/web-search-state.d.ts +21 -0
  81. package/types/agent/tools/web-search.d.ts +10 -45
  82. package/types/ai/cost.d.ts +1 -2
  83. package/types/ai/index.d.ts +2 -4
  84. package/types/ai/observer.d.ts +6 -0
  85. package/types/ai/pi-interop.d.ts +81 -0
  86. package/types/ai/provider-check.d.ts +53 -0
  87. package/types/ai/providers/codex/app-server-client.d.ts +37 -0
  88. package/types/ai/providers/pi-native/compaction-driver.d.ts +2 -1
  89. package/types/ai/providers/pi-native/compaction-summary.d.ts +19 -0
  90. package/types/ai/providers/pi-native/harness-adapter.d.ts +58 -0
  91. package/types/ai/providers/pi-native/prompt-cache-diagnostics.d.ts +3 -0
  92. package/types/ai/providers/pi-native/provider-attribution.d.ts +26 -0
  93. package/types/ai/providers/pi-native/result-builder.d.ts +14 -4
  94. package/types/ai/providers/pi-native/session-lifecycle.d.ts +25 -6
  95. package/types/ai/providers/pi-native/stream-subscriber.d.ts +2 -2
  96. package/types/ai/providers/pi-native/terminal-recovery.d.ts +2 -0
  97. package/types/ai/providers/pi-native/turn-runner.d.ts +68 -10
  98. package/types/ai/providers/pi-native.d.ts +21 -4
  99. package/types/ai/runtime/capabilities.d.ts +21 -70
  100. package/types/ai/runtime/live-input-events.d.ts +32 -8
  101. package/types/ai/runtime/model-refs.d.ts +0 -24
  102. package/types/ai/runtime/router.d.ts +3 -10
  103. package/types/ai/runtime/tool-policy.d.ts +0 -2
  104. package/types/ai/tool-lifecycle.d.ts +4 -3
  105. package/types/ai/types.d.ts +162 -256
  106. package/types/index.d.ts +0 -1
  107. package/src/ai/providers/acp-client.js +0 -1149
  108. package/src/ai/providers/acp-privacy.js +0 -124
  109. package/src/ai/providers/acp-public.js +0 -21
  110. package/src/ai/providers/acp-session-tokens.js +0 -282
  111. package/src/ai/providers/acp-transport.js +0 -356
  112. package/src/ai/providers/acp.js +0 -543
  113. package/src/ai/providers/claude-cli.js +0 -883
  114. package/src/ai/providers/claude-sandbox.js +0 -71
  115. package/src/ai/providers/claude-sdk-discovery-worker.js +0 -53
  116. package/src/ai/providers/claude-sdk-discovery.js +0 -352
  117. package/src/ai/providers/claude-sdk.js +0 -1127
  118. package/src/ai/providers/claude-subagent-activity.js +0 -719
  119. package/src/ai/providers/claude-subagents.js +0 -88
  120. package/src/ai/providers/codex-app.js +0 -2946
  121. package/src/ai/providers/opencode-app.js +0 -1109
  122. package/src/ai/providers/opencode-discovery.js +0 -39
  123. package/src/ai/providers/opencode-server.js +0 -508
  124. package/src/ai/runtime/context-windows.js +0 -46
  125. package/src/ai/runtime/fast-mode.js +0 -8
  126. package/src/ai/streaming/codex-events.js +0 -146
  127. package/src/ai/streaming/opencode-events.js +0 -59
  128. package/types/ai/providers/acp-client.d.ts +0 -227
  129. package/types/ai/providers/acp-privacy.d.ts +0 -25
  130. package/types/ai/providers/acp-public.d.ts +0 -7
  131. package/types/ai/providers/acp-session-tokens.d.ts +0 -41
  132. package/types/ai/providers/acp-transport.d.ts +0 -45
  133. package/types/ai/providers/acp.d.ts +0 -93
  134. package/types/ai/providers/claude-cli.d.ts +0 -305
  135. package/types/ai/providers/claude-sandbox.d.ts +0 -79
  136. package/types/ai/providers/claude-sdk-discovery-worker.d.ts +0 -1
  137. package/types/ai/providers/claude-sdk-discovery.d.ts +0 -97
  138. package/types/ai/providers/claude-sdk.d.ts +0 -138
  139. package/types/ai/providers/claude-subagent-activity.d.ts +0 -53
  140. package/types/ai/providers/claude-subagents.d.ts +0 -18
  141. package/types/ai/providers/codex-app.d.ts +0 -151
  142. package/types/ai/providers/opencode-app.d.ts +0 -96
  143. package/types/ai/providers/opencode-discovery.d.ts +0 -4
  144. package/types/ai/providers/opencode-server.d.ts +0 -20
  145. package/types/ai/runtime/context-windows.d.ts +0 -9
  146. package/types/ai/runtime/fast-mode.d.ts +0 -2
  147. package/types/ai/streaming/codex-events.d.ts +0 -40
  148. 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
@@ -60,6 +29,8 @@
60
29
  * nested native agent. Informational only; `id` remains the attachment key.
61
30
  * @property {number} [costUsd] Priced delegation cost, when the runtime can
62
31
  * attribute it to this subagent.
32
+ * @property {*} [attribution] Bounded provider-route attribution for the
33
+ * completed child run. Consumers must treat it as operator telemetry.
63
34
  */
64
35
  /**
65
36
  * @typedef {"agent_started"|"started"|"completed"|"message"|"agent_completed"} RuntimeSubagentActivityPhase
@@ -120,7 +91,7 @@
120
91
  * @typedef {Readonly<{
121
92
  * recordId?: string,
122
93
  * sequence?: number,
123
- * persistence: "persisted"|"failed",
94
+ * persistence: "persisted"|"deferred"|"failed",
124
95
  * truncated?: boolean,
125
96
  * originalBytes?: number,
126
97
  * retainedBytes?: number,
@@ -134,32 +105,11 @@
134
105
  * @param {RuntimeToolLifecycleEvent} event
135
106
  * @returns {Promise<RuntimeToolLifecyclePersistence|undefined>}
136
107
  */
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
108
  /**
160
109
  * @typedef {Object} RuntimeObserver
161
110
  * Per-call or host-level observer merged by createObserverHub (ai/observer.js).
162
111
  * Loose on purpose: observer.js is not a kernel seam file.
112
+ * @property {(event: RuntimeToolLifecycleEvent) => void} [recordToolLifecycle] Synchronous admission before queued lifecycle persistence.
163
113
  * @property {(event: RuntimeEvent) => (void|Promise<void>)} [onEvent]
164
114
  * @property {() => (void|Promise<void>)} [flush]
165
115
  */
@@ -214,19 +164,19 @@
214
164
  * @typedef {Object} RuntimeRunOptions
215
165
  * The options object a host passes to `createRuntime(host).run(systemPrompt, options)`.
216
166
  * @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
167
  * @property {string} [sessionId] Host conversation/session key for resumable bridges.
219
168
  * @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.
169
+ * @property {string} [providerAttributionSessionId] Host-owned provider attribution continuity key; does not authorize transcript resume.
170
+ * @property {{runId: string, revision: number}} [sessionRecovery] Host-owned durable recovery opt-in.
221
171
  * @property {boolean} [sessionKeepAlive] Keep resumable provider state alive after the turn.
222
172
  * @property {number} [sessionIdleTimeoutMs] Idle TTL for resumable provider state.
223
- * @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.
173
+ * @property {AsyncIterable<{body: string, id?: string, receivedAt?: string, logicalOwner?: object, accepted?: (evidence?: {providerEntryId?: string, providerRunId?: string}) => unknown, acknowledge?: (evidence?: {providerEntryId?: string, providerRunId?: string}) => unknown, uncertain?: (details: {reason: "delivery_uncertain", providerEntryId?: string, providerRunId?: string}) => unknown, reject?: (error?: unknown) => unknown}>} [liveInput] Stream of in-flight user messages for steering an active run. Native acceptance, exact transcript consumption, and uncertain delivery are distinct synchronous callbacks; thenables are never awaited as settlement confirmation. An optional opaque logicalOwner object proves that a later same-id value is a fresh callback lease for the first logical owner, not an independent duplicate.
224
174
  * @property {ReadonlyArray<*>} [observers] Per-call observers (see RuntimeObserver) merged with host-level (createRuntime) observers.
225
175
  * @property {(event: RuntimeEvent) => void} [onEvent]
176
+ * @property {boolean} [promptCacheDiagnostics] Emit metadata-only prompt-cache request fingerprints.
226
177
  * @property {RuntimeToolLifecycleSink} [toolLifecycleSink] Awaited host-owned incremental lifecycle persistence boundary.
227
178
  * @property {ReadonlyArray<Object>} [messages]
228
179
  * @property {string} [effort]
229
- * @property {boolean} [fastMode]
230
180
  * @property {string} [cwd]
231
181
  * @property {Object<string, Object>} [mcpServers]
232
182
  * @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.
@@ -235,46 +185,32 @@
235
185
  * @property {ReadonlyArray<string>} [disallowedTools]
236
186
  * @property {string} [permissionMode]
237
187
  * @property {number} [maxTurns]
188
+ * @property {number} [providerCheckMaxTokens] Internal provider-check output cap; ordinary callers must omit it.
189
+ * @property {{env(name: string): Promise<string|undefined>, fileExists(path: string): Promise<boolean>}} [providerCheckAuthContext] Internal provider-check effective auth context; ordinary callers must omit it.
238
190
  * @property {Object} [outputSchema]
239
191
  * @property {string} [runArtifactDir]
240
192
  * @property {AbortSignal} [abortSignal]
193
+ * @property {(artifact: {filename: string, buffer: Buffer, toolName: string, toolUseId: (string|null)}) => (string|null)} [persistArtifact] Host-owned synchronous artifact writer bound to this run.
241
194
  * @property {{schema: 1, values: Readonly<Record<string, string>>, pathPrepend?: readonly string[]}} [toolEnvironment] Host-only environment for Bash, Exec, and nested subagents in this run.
242
195
  * @property {import('../agent/sandbox-seam.js').SandboxPolicy} [sandboxPolicy] Per-run sandbox policy; merged monotonically with the host policy (see resolveSandboxPolicy, agent/tools/shared/tool-context.js).
243
196
  * @property {import('../agent/sandbox-seam.js').RuntimeSandboxEngine} [sandboxEngine] Per-run concrete sandbox engine handed to the active sandbox implementation.
244
197
  * @property {import('../agent/sandbox-seam.js').RuntimeSandbox} [sandbox] Per-run sandbox IMPLEMENTATION override; when set it enforces this run's tools instead of the host/ToolContext impl (precedence run > host > passthrough). Policy DATA still merges monotonically (I13); this overrides only the enforcing code.
245
198
  * @property {RuntimeToolLimits} [toolLimits] Typed per-run tool-output limits (supported replacement for the deprecated `settings` tool keys).
199
+ * @property {readonly string[]} [mcpCallNoTotalTimeoutTools] Exact `server:tool`
200
+ * names whose host-owned lifecycle has no total deadline. Inactivity and abort still apply.
246
201
  * @property {RuntimeCompactionPolicy} [compaction] Typed per-run compaction policy (supported replacement for the deprecated `settings` compaction keys).
247
202
  * @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
- * @property {{backend?: "auto"|"searxng"|"codex"|"keyless", endpoint?: string, codex?: {model?: string}}} [webSearchConfig] Run-scoped WebSearch backend configuration.
203
+ * @property {any} [webRequestCoordinator] Host-owned shared web admission and quota state.
204
+ * @property {{backend?: "auto"|"searxng"|"ollama"|"codex"|"keyless", maxRequestsPerRun?: number, endpoint?: string, searxng?: {endpoint?: string}, ollama?: {baseUrl?: string, apiKey?: string, apiKeyEnv?: string, trustPublicUrl?: boolean}, codex?: {model?: string}}} [webSearchConfig] Run-scoped WebSearch backend configuration.
205
+ * @property {any} [webSearchState] Private request budget and provider deferral state for one logical run.
252
206
  * @property {{render?: "never"|"auto", browserCommand?: string}} [webFetchConfig] Run-scoped WebFetch extraction/render configuration.
253
207
  * @property {"sequential"|"safe-parallel"} [piToolExecutionMode] Pi built-in tool scheduling mode. Safe parallelism is the default.
254
208
  * @property {"one-at-a-time"|"all"} [piToolParallelismMode] DEPRECATED. Compatibility alias mapped to piToolExecutionMode.
255
209
  * @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
210
  * @property {RuntimeSubagentsOptions} [subagents] In-process `Agent` built-in: profiles, caps, and the nested-run callback.
277
211
  * @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.
212
+ * @property {{chainDepth: number, maxChainDepth: number, remainingStarts: number, unavailableReason?: string}} [processJobsAvailability] Host-owned request lineage diagnostics, including when the controller is unavailable.
213
+ * @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
214
  * @property {Object} [diagnosticsSeed] Set by createRouterRuntime (ai/runtime/router.js) with a `resume_snapshot` when
279
215
  * failing over mid-chain; a host-level coordinator may relay it forward (see agent/transcript.js), not read by any
280
216
  * bridge in this package today.
@@ -284,7 +220,7 @@
284
220
  */
285
221
  /**
286
222
  * @typedef {RuntimeRunOptions
287
- * & Pick<AgentRuntimeHostOptions, "resolveCustomPricing" | "resolvePiApiKey" | "resolveAcpProfile" | "onAcpInteractionRequest" | "acpSessionTokenKey" | "persistArtifact" | "onCompactionRecorded" | "onToolApprovalRequest" | "toolRiskTiers" | "approvalDefaultRiskTier" | "approvalTimeoutMs" | "approvalAlwaysAllowTools">
223
+ * & Pick<AgentRuntimeHostOptions, "resolveCustomPricing" | "resolvePiApiKey" | "onCompactionRecorded" | "onToolApprovalRequest" | "toolRiskTiers" | "approvalDefaultRiskTier" | "approvalTimeoutMs" | "approvalAlwaysAllowTools">
288
224
  * & {runtimeBrand: import('../runtime-brand.js').RuntimeBrand, toolContext?: import('../agent/tools/shared/tool-context.js').ToolContext, observerHub: {emit: (event: RuntimeEvent) => void, flush: () => Promise<void>}}
289
225
  * } RuntimeRequest
290
226
  * The request shape a bridge's `execute(systemPrompt, req)` receives as its
@@ -351,18 +287,19 @@
351
287
  * @property {number} [numTurns]
352
288
  * @property {string} [model]
353
289
  * @property {string} [effort]
290
+ * @property {string} [effectiveEffort] Provider-effective reasoning/thinking level when reported.
354
291
  * @property {RuntimeSdkId} [sdk]
355
292
  * @property {boolean} [cancelled]
356
293
  * @property {string|null} [error]
357
294
  * @property {Object|null} [errorDetails]
358
295
  * @property {string|null} [failureKind]
296
+ * @property {{runId: string, revision: number, providerSessionId: string, modelKey: string, tipId: string}} [providerSessionRecovery]
359
297
  * @property {string|null} [providerSessionId]
360
298
  * @property {string|null} [stderrTail] Bounded stderr tail from a CLI-backed bridge; see createStderrTail (ai/failure.js).
361
299
  * @property {Array<Object>} [runtimeWarnings]
362
300
  * @property {Object} [diagnostics]
363
301
  * @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.
302
+ * @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
303
  */
367
304
  /**
368
305
  * @typedef {Object} RuntimeCapabilities
@@ -381,8 +318,7 @@
381
318
  * @property {boolean} [supports_builtin_tools]
382
319
  * @property {boolean} [supports_live_input]
383
320
  * @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.
321
+ * normalized activity. In-process delegation is the `Agent` tool, configured by the host.
386
322
  * @property {boolean} [supports_request_tool_environment]
387
323
  * @property {boolean} [supports_fast_mode]
388
324
  * @property {"projected"|"allow_all_only"} [tool_policy] Whether the bridge can
@@ -447,6 +383,8 @@
447
383
  * host-integration callbacks (bound once, applied to every run via hostDefaults).
448
384
  * @property {string} [workspace]
449
385
  * @property {string} [repoRoot]
386
+ * @property {ReadonlyArray<string>} [additionalReadRoots]
387
+ * @property {ReadonlyArray<string>} [additionalWriteRoots]
450
388
  * @property {string} [ripgrepPath]
451
389
  * @property {string} [qaOutputDir]
452
390
  * @property {import('../agent/sandbox-seam.js').SandboxPolicy} [sandboxPolicy]
@@ -455,11 +393,8 @@
455
393
  * @property {RuntimePromptOverrides} [prompts] Host-level prompt-fragment override defaults; a per-run `options.prompts` field wins over these (see resolvePrompts, runtime.js).
456
394
  * @property {ReadonlyArray<*>} [observers] Observer instances (see RuntimeObserver); loose because observer.js is not a kernel seam file.
457
395
  * @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).
396
+ * @property {(parsed: {provider: string, model: string}) => (import('./cost.js').NormalizedPricing|null)} [resolveCustomPricing] See resolvePricing (ai/cost.js).
459
397
  * @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
398
  * @property {(artifact: {filename: string, buffer: Buffer, toolName: string, toolUseId: (string|null)}) => (string|null)} [persistArtifact]
464
399
  * @property {(record: CompactionRecordedPayload) => void} [onCompactionRecorded]
465
400
  * @property {(payload: ApprovalRequestPayload) => Promise<ApprovalDecision>} [onToolApprovalRequest]
@@ -474,6 +409,8 @@
474
409
  * (createRuntime's TOOL_RUNTIME_KEYS pick).
475
410
  * @property {string} [workspace]
476
411
  * @property {string} [repoRoot]
412
+ * @property {ReadonlyArray<string>} [additionalReadRoots]
413
+ * @property {ReadonlyArray<string>} [additionalWriteRoots]
477
414
  * @property {string} [ripgrepPath]
478
415
  * @property {string} [qaOutputDir]
479
416
  * @property {import('../agent/sandbox-seam.js').SandboxPolicy} [sandboxPolicy]
@@ -485,77 +422,37 @@
485
422
  * The object `createRuntime`/`createRouterRuntime` return.
486
423
  * @property {(systemPrompt: string, options: RuntimeRunOptions) => Promise<RuntimeResult>} run
487
424
  * @property {(next?: AgentRuntimeToolOptions) => void} configureTools
425
+ * @property {(receipt: NonNullable<RuntimeResult["providerSessionRecovery"]>, context: {appliedInputIds: readonly string[]}) => Promise<boolean>} recoverSession
488
426
  * @property {(providerSessionId: string) => Promise<boolean>} syncSession
489
427
  * @property {(providerSessionId: string) => Promise<void>} refreshSession Guarantees the id has no reusable process-local handle; rejects on failure.
490
- * @property {(providerSessionId: string, sessionsRoot: string) => Promise<void>} retireDurableSession Permanently deletes every durable transcript with the exact id; absence is success.
428
+ * @property {(providerSessionId: string, sessionsRoot: string) => Promise<void>} retireDurableSession Deletes every currently materialized durable transcript with the exact id; callers retry after an active retired run settles to reclaim any late same-name append. Absence is success.
491
429
  * @property {(providerSessionId: string) => Promise<boolean>} disposeSession
492
430
  * @property {(providerSessionId: string) => Promise<boolean>} invalidateSession
493
431
  * @property {() => Promise<void>} disposeAllSessions
494
432
  */
495
433
  export const PROVIDER_KIND_VALUES: string[];
496
434
  /**
497
- * Canonical active runtime id. See ACTIVE_RUNTIME_KINDS (model-refs.js) for
498
- * the enforced-at-runtime vocabulary.
435
+ * Runtime-result and telemetry label. Model references no longer carry this
436
+ * field because Pi is the sole runtime bridge.
499
437
  */
500
- export type RuntimeSdkId = "claude" | "pi" | "codex" | "opencode" | "acp" | (string & {});
438
+ export type RuntimeSdkId = "pi";
501
439
  /**
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.
440
+ * Registry bridge id. See src/ai/runtime/registry.js's builtinBridgeSpecs.
506
441
  */
507
- export type RuntimeBridgeId = "claude" | "claude-code" | "codex-app" | "opencode-app" | "pi" | "acp-stdio" | (string & {});
442
+ export type RuntimeBridgeId = "pi";
508
443
  export type RuntimeModelRef = {
509
444
  /**
510
- * Canonical active runtime id.
445
+ * Pi provider id.
511
446
  */
512
- sdk: RuntimeSdkId;
447
+ provider: string;
513
448
  /**
514
449
  * Provider model id.
515
450
  */
516
451
  model: string;
517
452
  /**
518
- * Original canonical model reference; always set by
519
- * parseRuntimeModelReference, but router.js's chain
520
- * shorthand accepts bare {sdk, model} refs without one.
521
- */
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).
453
+ * Canonical `<provider>:<model>` reference.
548
454
  */
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>;
455
+ reference: string;
559
456
  };
560
457
  /**
561
458
  * Provider-neutral identity attached to every `subagent_activity` event.
@@ -595,6 +492,11 @@ export type RuntimeSubagentIdentity = {
595
492
  * attribute it to this subagent.
596
493
  */
597
494
  costUsd?: number;
495
+ /**
496
+ * Bounded provider-route attribution for the
497
+ * completed child run. Consumers must treat it as operator telemetry.
498
+ */
499
+ attribution?: any;
598
500
  };
599
501
  /**
600
502
  * `agent_started`/`agent_completed` bracket the delegation; `started`/`completed`
@@ -673,7 +575,7 @@ export type RuntimeToolLifecycleEvent = RuntimeToolLifecycleInvocationEvent | Ru
673
575
  export type RuntimeToolLifecyclePersistence = Readonly<{
674
576
  recordId?: string;
675
577
  sequence?: number;
676
- persistence: "persisted" | "failed";
578
+ persistence: "persisted" | "deferred" | "failed";
677
579
  truncated?: boolean;
678
580
  originalBytes?: number;
679
581
  retainedBytes?: number;
@@ -684,34 +586,15 @@ export type RuntimeToolLifecyclePersistence = Readonly<{
684
586
  errorCode?: string;
685
587
  }>;
686
588
  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
589
  /**
711
590
  * Per-call or host-level observer merged by createObserverHub (ai/observer.js).
712
591
  * Loose on purpose: observer.js is not a kernel seam file.
713
592
  */
714
593
  export type RuntimeObserver = {
594
+ /**
595
+ * Synchronous admission before queued lifecycle persistence.
596
+ */
597
+ recordToolLifecycle?: (event: RuntimeToolLifecycleEvent) => void;
715
598
  onEvent?: (event: RuntimeEvent) => (void | Promise<void>);
716
599
  flush?: () => (void | Promise<void>);
717
600
  };
@@ -827,10 +710,6 @@ export type RuntimeRunOptions = {
827
710
  * Resolved model reference; see parseRuntimeModelReference.
828
711
  */
829
712
  model: RuntimeModelRef;
830
- /**
831
- * "sdk" (default), "cli", or "acp"; selects which bridge variant handles the model.
832
- */
833
- executionMode?: "sdk" | "cli" | "acp";
834
713
  /**
835
714
  * Host conversation/session key for resumable bridges.
836
715
  */
@@ -840,9 +719,16 @@ export type RuntimeRunOptions = {
840
719
  */
841
720
  providerSessionId?: string;
842
721
  /**
843
- * Advanced programmatic/test seam for the Claude SDK route; omitted runs use the runtime's pinned SDK query implementation.
722
+ * Host-owned provider attribution continuity key; does not authorize transcript resume.
723
+ */
724
+ providerAttributionSessionId?: string;
725
+ /**
726
+ * Host-owned durable recovery opt-in.
844
727
  */
845
- claudeAgentQuery?: typeof import("@anthropic-ai/claude-agent-sdk").query;
728
+ sessionRecovery?: {
729
+ runId: string;
730
+ revision: number;
731
+ };
846
732
  /**
847
733
  * Keep resumable provider state alive after the turn.
848
734
  */
@@ -852,27 +738,43 @@ export type RuntimeRunOptions = {
852
738
  */
853
739
  sessionIdleTimeoutMs?: number;
854
740
  /**
855
- * Stream of in-flight user messages for steering an active run. Providers acknowledge only after accepting a message into the active turn.
741
+ * Stream of in-flight user messages for steering an active run. Native acceptance, exact transcript consumption, and uncertain delivery are distinct synchronous callbacks; thenables are never awaited as settlement confirmation. An optional opaque logicalOwner object proves that a later same-id value is a fresh callback lease for the first logical owner, not an independent duplicate.
856
742
  */
857
743
  liveInput?: AsyncIterable<{
858
744
  body: string;
859
745
  id?: string;
860
746
  receivedAt?: string;
861
- acknowledge?: () => void;
862
- reject?: (error?: unknown) => void;
747
+ logicalOwner?: object;
748
+ accepted?: (evidence?: {
749
+ providerEntryId?: string;
750
+ providerRunId?: string;
751
+ }) => unknown;
752
+ acknowledge?: (evidence?: {
753
+ providerEntryId?: string;
754
+ providerRunId?: string;
755
+ }) => unknown;
756
+ uncertain?: (details: {
757
+ reason: "delivery_uncertain";
758
+ providerEntryId?: string;
759
+ providerRunId?: string;
760
+ }) => unknown;
761
+ reject?: (error?: unknown) => unknown;
863
762
  }>;
864
763
  /**
865
764
  * Per-call observers (see RuntimeObserver) merged with host-level (createRuntime) observers.
866
765
  */
867
766
  observers?: ReadonlyArray<any>;
868
767
  onEvent?: (event: RuntimeEvent) => void;
768
+ /**
769
+ * Emit metadata-only prompt-cache request fingerprints.
770
+ */
771
+ promptCacheDiagnostics?: boolean;
869
772
  /**
870
773
  * Awaited host-owned incremental lifecycle persistence boundary.
871
774
  */
872
775
  toolLifecycleSink?: RuntimeToolLifecycleSink;
873
776
  messages?: ReadonlyArray<any>;
874
777
  effort?: string;
875
- fastMode?: boolean;
876
778
  cwd?: string;
877
779
  mcpServers?: {
878
780
  [x: string]: any;
@@ -892,9 +794,29 @@ export type RuntimeRunOptions = {
892
794
  disallowedTools?: ReadonlyArray<string>;
893
795
  permissionMode?: string;
894
796
  maxTurns?: number;
797
+ /**
798
+ * Internal provider-check output cap; ordinary callers must omit it.
799
+ */
800
+ providerCheckMaxTokens?: number;
801
+ /**
802
+ * Internal provider-check effective auth context; ordinary callers must omit it.
803
+ */
804
+ providerCheckAuthContext?: {
805
+ env(name: string): Promise<string | undefined>;
806
+ fileExists(path: string): Promise<boolean>;
807
+ };
895
808
  outputSchema?: any;
896
809
  runArtifactDir?: string;
897
810
  abortSignal?: AbortSignal;
811
+ /**
812
+ * Host-owned synchronous artifact writer bound to this run.
813
+ */
814
+ persistArtifact?: (artifact: {
815
+ filename: string;
816
+ buffer: Buffer;
817
+ toolName: string;
818
+ toolUseId: (string | null);
819
+ }) => (string | null);
898
820
  /**
899
821
  * Host-only environment for Bash, Exec, and nested subagents in this run.
900
822
  */
@@ -919,6 +841,11 @@ export type RuntimeRunOptions = {
919
841
  * Typed per-run tool-output limits (supported replacement for the deprecated `settings` tool keys).
920
842
  */
921
843
  toolLimits?: RuntimeToolLimits;
844
+ /**
845
+ * Exact `server:tool`
846
+ * names whose host-owned lifecycle has no total deadline. Inactivity and abort still apply.
847
+ */
848
+ mcpCallNoTotalTimeoutTools?: readonly string[];
922
849
  /**
923
850
  * Typed per-run compaction policy (supported replacement for the deprecated `settings` compaction keys).
924
851
  */
@@ -928,27 +855,33 @@ export type RuntimeRunOptions = {
928
855
  */
929
856
  prompts?: RuntimePromptOverrides;
930
857
  /**
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.
858
+ * Host-owned shared web admission and quota state.
940
859
  */
941
- acpSessionTokenKey?: Uint8Array;
860
+ webRequestCoordinator?: any;
942
861
  /**
943
862
  * Run-scoped WebSearch backend configuration.
944
863
  */
945
864
  webSearchConfig?: {
946
- backend?: "auto" | "searxng" | "codex" | "keyless";
865
+ backend?: "auto" | "searxng" | "ollama" | "codex" | "keyless";
866
+ maxRequestsPerRun?: number;
947
867
  endpoint?: string;
868
+ searxng?: {
869
+ endpoint?: string;
870
+ };
871
+ ollama?: {
872
+ baseUrl?: string;
873
+ apiKey?: string;
874
+ apiKeyEnv?: string;
875
+ trustPublicUrl?: boolean;
876
+ };
948
877
  codex?: {
949
878
  model?: string;
950
879
  };
951
880
  };
881
+ /**
882
+ * Private request budget and provider deferral state for one logical run.
883
+ */
884
+ webSearchState?: any;
952
885
  /**
953
886
  * Run-scoped WebFetch extraction/render configuration.
954
887
  */
@@ -968,38 +901,6 @@ export type RuntimeRunOptions = {
968
901
  * 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
902
  */
970
903
  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
904
  /**
1004
905
  * In-process `Agent` built-in: profiles, caps, and the nested-run callback.
1005
906
  */
@@ -1008,6 +909,19 @@ export type RuntimeRunOptions = {
1008
909
  * Pi-native-only structural process-job controller. When absent, Exec/Bash schemas and foreground behavior are unchanged.
1009
910
  */
1010
911
  processJobs?: import("../agent/tools/shared/process-jobs.js").ProcessJobsController;
912
+ /**
913
+ * Host-owned request lineage diagnostics, including when the controller is unavailable.
914
+ */
915
+ processJobsAvailability?: {
916
+ chainDepth: number;
917
+ maxChainDepth: number;
918
+ remainingStarts: number;
919
+ unavailableReason?: string;
920
+ };
921
+ /**
922
+ * Pi-native-only structural monitor controller. When absent, the Monitor and MonitorStop tools are not registered at all.
923
+ */
924
+ monitors?: import("../agent/tools/shared/monitors.js").MonitorsController;
1011
925
  /**
1012
926
  * Set by createRouterRuntime (ai/runtime/router.js) with a `resume_snapshot` when
1013
927
  * failing over mid-chain; a host-level coordinator may relay it forward (see agent/transcript.js), not read by any
@@ -1030,7 +944,7 @@ export type RuntimeRunOptions = {
1030
944
  * createRuntime), and the per-run observerHub (onEvent is overridden to the
1031
945
  * hub's emit). `systemPrompt` is passed positionally, not folded into this object.
1032
946
  */
1033
- export type RuntimeRequest = RuntimeRunOptions & Pick<AgentRuntimeHostOptions, "resolveCustomPricing" | "resolvePiApiKey" | "resolveAcpProfile" | "onAcpInteractionRequest" | "acpSessionTokenKey" | "persistArtifact" | "onCompactionRecorded" | "onToolApprovalRequest" | "toolRiskTiers" | "approvalDefaultRiskTier" | "approvalTimeoutMs" | "approvalAlwaysAllowTools"> & {
947
+ export type RuntimeRequest = RuntimeRunOptions & Pick<AgentRuntimeHostOptions, "resolveCustomPricing" | "resolvePiApiKey" | "onCompactionRecorded" | "onToolApprovalRequest" | "toolRiskTiers" | "approvalDefaultRiskTier" | "approvalTimeoutMs" | "approvalAlwaysAllowTools"> & {
1034
948
  runtimeBrand: import("../runtime-brand.js").RuntimeBrand;
1035
949
  toolContext?: import("../agent/tools/shared/tool-context.js").ToolContext;
1036
950
  observerHub: {
@@ -1139,11 +1053,22 @@ export type RuntimeResult = {
1139
1053
  numTurns?: number;
1140
1054
  model?: string;
1141
1055
  effort?: string;
1056
+ /**
1057
+ * Provider-effective reasoning/thinking level when reported.
1058
+ */
1059
+ effectiveEffort?: string;
1142
1060
  sdk?: RuntimeSdkId;
1143
1061
  cancelled?: boolean;
1144
1062
  error?: string | null;
1145
1063
  errorDetails?: any | null;
1146
1064
  failureKind?: string | null;
1065
+ providerSessionRecovery?: {
1066
+ runId: string;
1067
+ revision: number;
1068
+ providerSessionId: string;
1069
+ modelKey: string;
1070
+ tipId: string;
1071
+ };
1147
1072
  providerSessionId?: string | null;
1148
1073
  /**
1149
1074
  * Bounded stderr tail from a CLI-backed bridge; see createStderrTail (ai/failure.js).
@@ -1162,18 +1087,6 @@ export type RuntimeResult = {
1162
1087
  retryableSubkind?: (string | null);
1163
1088
  retryIndex?: number;
1164
1089
  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
1090
  }>;
1178
1091
  };
1179
1092
  /**
@@ -1195,8 +1108,7 @@ export type RuntimeCapabilities = {
1195
1108
  supports_live_input?: boolean;
1196
1109
  /**
1197
1110
  * 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.
1111
+ * normalized activity. In-process delegation is the `Agent` tool, configured by the host.
1200
1112
  */
1201
1113
  supports_native_subagents?: boolean;
1202
1114
  supports_request_tool_environment?: boolean;
@@ -1275,6 +1187,8 @@ export type CompactionRecordedPayload = {
1275
1187
  export type AgentRuntimeHostOptions = {
1276
1188
  workspace?: string;
1277
1189
  repoRoot?: string;
1190
+ additionalReadRoots?: ReadonlyArray<string>;
1191
+ additionalWriteRoots?: ReadonlyArray<string>;
1278
1192
  ripgrepPath?: string;
1279
1193
  qaOutputDir?: string;
1280
1194
  sandboxPolicy?: import("../agent/sandbox-seam.js").SandboxPolicy;
@@ -1299,26 +1213,13 @@ export type AgentRuntimeHostOptions = {
1299
1213
  * See resolvePricing (ai/cost.js).
1300
1214
  */
1301
1215
  resolveCustomPricing?: (parsed: {
1302
- sdk: (string | null);
1303
- provider?: string;
1216
+ provider: string;
1304
1217
  model: string;
1305
1218
  }) => (import("./cost.js").NormalizedPricing | null);
1306
1219
  /**
1307
1220
  * See createPiOAuthApiKeyResolver (pi-auth.js) for a ready-made implementation.
1308
1221
  */
1309
1222
  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
1223
  persistArtifact?: (artifact: {
1323
1224
  filename: string;
1324
1225
  buffer: Buffer;
@@ -1341,6 +1242,8 @@ export type AgentRuntimeHostOptions = {
1341
1242
  export type AgentRuntimeToolOptions = {
1342
1243
  workspace?: string;
1343
1244
  repoRoot?: string;
1245
+ additionalReadRoots?: ReadonlyArray<string>;
1246
+ additionalWriteRoots?: ReadonlyArray<string>;
1344
1247
  ripgrepPath?: string;
1345
1248
  qaOutputDir?: string;
1346
1249
  sandboxPolicy?: import("../agent/sandbox-seam.js").SandboxPolicy;
@@ -1353,13 +1256,16 @@ export type AgentRuntimeToolOptions = {
1353
1256
  export type AgentRuntimeInstance = {
1354
1257
  run: (systemPrompt: string, options: RuntimeRunOptions) => Promise<RuntimeResult>;
1355
1258
  configureTools: (next?: AgentRuntimeToolOptions) => void;
1259
+ recoverSession: (receipt: NonNullable<RuntimeResult["providerSessionRecovery"]>, context: {
1260
+ appliedInputIds: readonly string[];
1261
+ }) => Promise<boolean>;
1356
1262
  syncSession: (providerSessionId: string) => Promise<boolean>;
1357
1263
  /**
1358
1264
  * Guarantees the id has no reusable process-local handle; rejects on failure.
1359
1265
  */
1360
1266
  refreshSession: (providerSessionId: string) => Promise<void>;
1361
1267
  /**
1362
- * Permanently deletes every durable transcript with the exact id; absence is success.
1268
+ * Deletes every currently materialized durable transcript with the exact id; callers retry after an active retired run settles to reclaim any late same-name append. Absence is success.
1363
1269
  */
1364
1270
  retireDurableSession: (providerSessionId: string, sessionsRoot: string) => Promise<void>;
1365
1271
  disposeSession: (providerSessionId: string) => Promise<boolean>;