@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.
- package/MIGRATION.md +264 -25
- package/README.md +139 -448
- package/package.json +7 -43
- package/src/agent/tools/agent-tool.js +5 -5
- package/src/agent/tools/bash.js +1 -24
- package/src/agent/tools/codex-subscription-search.js +1 -1
- package/src/agent/tools/index.js +7 -0
- package/src/agent/tools/monitor.js +140 -0
- package/src/agent/tools/pi-bridge.js +92 -7
- package/src/agent/tools/shared/bash-environment.js +31 -0
- package/src/agent/tools/shared/monitors.js +274 -0
- package/src/agent/tools/shared/process-runner.js +23 -5
- package/src/ai/cost.js +13 -68
- package/src/ai/index.js +4 -17
- package/src/ai/pi-interop.js +65 -1
- package/src/ai/pi-oauth-compat.js +1 -1
- package/src/ai/providers/codex/app-server-client.js +592 -0
- package/src/ai/providers/pi-models.js +18 -10
- package/src/ai/providers/pi-native/compaction-driver.js +49 -21
- package/src/ai/providers/pi-native/harness-adapter.js +338 -0
- package/src/ai/providers/pi-native/result-builder.js +10 -10
- package/src/ai/providers/pi-native/session-lifecycle.js +95 -40
- package/src/ai/providers/pi-native/stream-subscriber.js +23 -5
- package/src/ai/providers/pi-native/turn-runner.js +34 -15
- package/src/ai/providers/pi-native.js +48 -22
- package/src/ai/runtime/capabilities.js +11 -56
- package/src/ai/runtime/model-refs.js +118 -153
- package/src/ai/runtime/registry.js +22 -56
- package/src/ai/runtime/router.js +48 -408
- package/src/ai/runtime/session-liveness.js +3 -4
- package/src/ai/runtime/sessions.js +4 -5
- package/src/ai/runtime/tool-policy.js +0 -2
- package/src/ai/types.js +12 -108
- package/src/index.js +0 -6
- package/src/runtime.js +8 -14
- package/types/agent/tools/agent-tool.d.ts +1 -2
- package/types/agent/tools/codex-subscription-search.d.ts +1 -1
- package/types/agent/tools/index.d.ts +1 -0
- package/types/agent/tools/monitor.d.ts +44 -0
- package/types/agent/tools/pi-bridge.d.ts +3 -2
- package/types/agent/tools/shared/bash-environment.d.ts +4 -0
- package/types/agent/tools/shared/monitors.d.ts +83 -0
- package/types/agent/tools/shared/process-runner.d.ts +11 -2
- package/types/ai/cost.d.ts +1 -2
- package/types/ai/index.d.ts +1 -4
- package/types/ai/pi-interop.d.ts +20 -0
- package/types/ai/providers/codex/app-server-client.d.ts +37 -0
- package/types/ai/providers/pi-native/harness-adapter.d.ts +56 -0
- package/types/ai/providers/pi-native/result-builder.d.ts +3 -3
- package/types/ai/providers/pi-native/session-lifecycle.d.ts +2 -1
- package/types/ai/providers/pi-native/stream-subscriber.d.ts +2 -2
- package/types/ai/providers/pi-native/turn-runner.d.ts +33 -6
- package/types/ai/providers/pi-native.d.ts +21 -4
- package/types/ai/runtime/capabilities.d.ts +21 -70
- package/types/ai/runtime/model-refs.d.ts +0 -24
- package/types/ai/runtime/router.d.ts +3 -10
- package/types/ai/runtime/tool-policy.d.ts +0 -2
- package/types/ai/types.d.ts +28 -250
- package/types/index.d.ts +0 -1
- package/src/ai/providers/acp-client.js +0 -1149
- package/src/ai/providers/acp-privacy.js +0 -124
- package/src/ai/providers/acp-public.js +0 -21
- package/src/ai/providers/acp-session-tokens.js +0 -282
- package/src/ai/providers/acp-transport.js +0 -356
- package/src/ai/providers/acp.js +0 -543
- package/src/ai/providers/claude-cli.js +0 -883
- package/src/ai/providers/claude-sandbox.js +0 -71
- package/src/ai/providers/claude-sdk-discovery-worker.js +0 -53
- package/src/ai/providers/claude-sdk-discovery.js +0 -352
- package/src/ai/providers/claude-sdk.js +0 -1127
- package/src/ai/providers/claude-subagent-activity.js +0 -719
- package/src/ai/providers/claude-subagents.js +0 -88
- package/src/ai/providers/codex-app.js +0 -2946
- package/src/ai/providers/opencode-app.js +0 -1109
- package/src/ai/providers/opencode-discovery.js +0 -39
- package/src/ai/providers/opencode-server.js +0 -508
- package/src/ai/runtime/context-windows.js +0 -46
- package/src/ai/runtime/fast-mode.js +0 -8
- package/src/ai/streaming/codex-events.js +0 -146
- package/src/ai/streaming/opencode-events.js +0 -59
- package/types/ai/providers/acp-client.d.ts +0 -227
- package/types/ai/providers/acp-privacy.d.ts +0 -25
- package/types/ai/providers/acp-public.d.ts +0 -7
- package/types/ai/providers/acp-session-tokens.d.ts +0 -41
- package/types/ai/providers/acp-transport.d.ts +0 -45
- package/types/ai/providers/acp.d.ts +0 -93
- package/types/ai/providers/claude-cli.d.ts +0 -305
- package/types/ai/providers/claude-sandbox.d.ts +0 -79
- package/types/ai/providers/claude-sdk-discovery-worker.d.ts +0 -1
- package/types/ai/providers/claude-sdk-discovery.d.ts +0 -97
- package/types/ai/providers/claude-sdk.d.ts +0 -138
- package/types/ai/providers/claude-subagent-activity.d.ts +0 -53
- package/types/ai/providers/claude-subagents.d.ts +0 -18
- package/types/ai/providers/codex-app.d.ts +0 -151
- package/types/ai/providers/opencode-app.d.ts +0 -96
- package/types/ai/providers/opencode-discovery.d.ts +0 -4
- package/types/ai/providers/opencode-server.d.ts +0 -20
- package/types/ai/runtime/context-windows.d.ts +0 -9
- package/types/ai/runtime/fast-mode.d.ts +0 -2
- package/types/ai/streaming/codex-events.d.ts +0 -40
- package/types/ai/streaming/opencode-events.d.ts +0 -42
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
// Synchronous session-liveness primitives over a createSessionRegistry.
|
|
3
3
|
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
4
|
+
// The Pi bridge owns session DURABILITY by keeping a Session transcript; this
|
|
5
|
+
// kernel layer owns session LIVENESS —
|
|
6
6
|
// the concurrency claim that keeps two turns from driving one session at once.
|
|
7
7
|
// The primitives here are deliberately SYNCHRONOUS: each does its registry
|
|
8
8
|
// get -> check -> set in a single await-free span, so the "busy claim must be
|
|
@@ -11,8 +11,7 @@
|
|
|
11
11
|
//
|
|
12
12
|
// The registry stays the storage + idle-TTL + dispose fan-out layer (its
|
|
13
13
|
// exports are unchanged, worklab-compatible); liveness only adds the claim /
|
|
14
|
-
// reserve / release / adoptIfPresent seam that
|
|
15
|
-
// codex-app both consume.
|
|
14
|
+
// reserve / release / adoptIfPresent seam that Pi's session lifecycle consumes.
|
|
16
15
|
|
|
17
16
|
/**
|
|
18
17
|
* @typedef {object} SessionRegistryLike
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// Provider session registries.
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
// transcript) register their live sessions here, keyed by provider session id.
|
|
3
|
+
// Pi keeps each continuous provider session as a live Session transcript and
|
|
4
|
+
// registers it here under the provider session id.
|
|
6
5
|
// The host
|
|
7
6
|
// owns session lifetime policy (which conversation maps to which session,
|
|
8
7
|
// when to resume, when to retire); these registries only make sure nothing
|
|
@@ -13,8 +12,8 @@
|
|
|
13
12
|
// `createSessionRegistry` instances self-register in a module-level set so
|
|
14
13
|
// the runtime surface can expose `syncSession(id)` / `refreshSession(id)` /
|
|
15
14
|
// `disposeSession(id)` / `disposeAllSessions()`
|
|
16
|
-
// without
|
|
17
|
-
//
|
|
15
|
+
// without coupling the host-facing lifecycle surface to Pi's transcript
|
|
16
|
+
// implementation. Pi session UUIDs are unique, so fan-out dispose is safe.
|
|
18
17
|
|
|
19
18
|
const DEFAULT_IDLE_TIMEOUT_MS = 30 * 60 * 1000;
|
|
20
19
|
|
package/src/ai/types.js
CHANGED
|
@@ -8,62 +8,22 @@
|
|
|
8
8
|
// via `import('./types.js').X` JSDoc syntax from the other seam files, or
|
|
9
9
|
// transitively through the package root's generated declarations.
|
|
10
10
|
//
|
|
11
|
-
// A few fields below use the `"literal" | (string & {})` shape (a "branded
|
|
12
|
-
// string union"). This keeps the known literal values available for
|
|
13
|
-
// IDE/editor autocomplete while still accepting any plain `string`, since
|
|
14
|
-
// hosts validate the real vocabulary at runtime (parseRuntimeModelReference,
|
|
15
|
-
// resolveRuntimeBridge) rather than at the type level — the type only
|
|
16
|
-
// documents the values active runtimes currently produce.
|
|
17
|
-
|
|
18
11
|
/**
|
|
19
|
-
* @typedef {"
|
|
20
|
-
*
|
|
21
|
-
* the
|
|
12
|
+
* @typedef {"pi"} RuntimeSdkId
|
|
13
|
+
* Runtime-result and telemetry label. Model references no longer carry this
|
|
14
|
+
* field because Pi is the sole runtime bridge.
|
|
22
15
|
*/
|
|
23
16
|
|
|
24
17
|
/**
|
|
25
|
-
* @typedef {"
|
|
26
|
-
* Registry bridge id
|
|
27
|
-
* by more than one bridge, e.g. sdk "claude" is served by both the "claude"
|
|
28
|
-
* SDK bridge and the "claude-code" CLI bridge). See
|
|
29
|
-
* src/ai/runtime/registry.js's builtinBridgeSpecs.
|
|
18
|
+
* @typedef {"pi"} RuntimeBridgeId
|
|
19
|
+
* Registry bridge id. See src/ai/runtime/registry.js's builtinBridgeSpecs.
|
|
30
20
|
*/
|
|
31
21
|
|
|
32
22
|
/**
|
|
33
23
|
* @typedef {Object} RuntimeModelRef
|
|
34
|
-
* @property {
|
|
24
|
+
* @property {string} provider Pi provider id.
|
|
35
25
|
* @property {string} model Provider model id.
|
|
36
|
-
* @property {string}
|
|
37
|
-
* parseRuntimeModelReference, but router.js's chain
|
|
38
|
-
* shorthand accepts bare {sdk, model} refs without one.
|
|
39
|
-
* @property {string} [provider] Pi/OpenCode provider id when sdk === "pi" | "opencode".
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* @typedef {Object} RuntimeNativeSubagentDefinition
|
|
44
|
-
* One caller-defined Claude native `Task` profile. Codex collaboration-agent
|
|
45
|
-
* definitions are owned by Codex and are not represented by this type.
|
|
46
|
-
* @property {string} name
|
|
47
|
-
* @property {string} [displayName]
|
|
48
|
-
* @property {string} [description]
|
|
49
|
-
* @property {string} [helperSystemPrompt]
|
|
50
|
-
* @property {string} [instructions]
|
|
51
|
-
* @property {ReadonlyArray<string>} [allowedTools]
|
|
52
|
-
* @property {ReadonlyArray<string>} [disallowedTools]
|
|
53
|
-
* @property {string | RuntimeModelRef} [modelRef]
|
|
54
|
-
* @property {RuntimeModelRef} [model]
|
|
55
|
-
* @property {string} [effort]
|
|
56
|
-
* @property {Object<string, Object>} [mcpServers]
|
|
57
|
-
* @property {Object} [mcpApps] App-owned exact-connection MCP Apps registry (Pi-native only).
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* @typedef {Object} RuntimeNativeSubagentsOptions
|
|
62
|
-
* Caller-defined native profiles are supported only by the Claude bridges.
|
|
63
|
-
* Codex owns its collaboration agents; use `codexLoadProjectDocs` when those
|
|
64
|
-
* agents should receive repository instructions.
|
|
65
|
-
* @property {"claude"} provider
|
|
66
|
-
* @property {ReadonlyArray<RuntimeNativeSubagentDefinition>} teammates
|
|
26
|
+
* @property {string} reference Canonical `<provider>:<model>` reference.
|
|
67
27
|
*/
|
|
68
28
|
|
|
69
29
|
/**
|
|
@@ -166,32 +126,6 @@
|
|
|
166
126
|
* @returns {Promise<RuntimeToolLifecyclePersistence|undefined>}
|
|
167
127
|
*/
|
|
168
128
|
|
|
169
|
-
/** @typedef {"uniform"|"per-route-native"} RuntimeRouteSafetyMode */
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* @typedef {"mono-agent-monotonic"|"disabled"|"mono-agent-srt"|"mono-agent-srt-unsafe-host-fallback"|"provider-native"|"codex-native"|"unsupported"} RuntimeRouteSandboxContract
|
|
173
|
-
* Fixed telemetry vocabulary for a route's sandbox posture. The
|
|
174
|
-
* `mono-agent-srt-unsafe-host-fallback` describes a policy that prefers SRT but
|
|
175
|
-
* explicitly permits host execution if unavailable; it does not claim which
|
|
176
|
-
* branch ran for a particular command.
|
|
177
|
-
*/
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* @typedef {"mono-agent-monotonic"|"mono-agent-policy"|"provider-representable"|"exact-allow-all"|"unsupported"} RuntimeRouteToolsContract
|
|
181
|
-
* `exact-allow-all` is a stable telemetry token. It describes an effective
|
|
182
|
-
* unrestricted contract, including mixed allowlists that contain `"*"`;
|
|
183
|
-
* it does not require the literal one-element array `["*"]`.
|
|
184
|
-
*/
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* @typedef {Object} RuntimeRouteSafetyContract
|
|
188
|
-
* Bounded, credential-free description of the sandbox/tool contract applied
|
|
189
|
-
* to one fallback route.
|
|
190
|
-
* @property {RuntimeRouteSafetyMode} mode
|
|
191
|
-
* @property {RuntimeRouteSandboxContract} sandbox
|
|
192
|
-
* @property {RuntimeRouteToolsContract} tools
|
|
193
|
-
*/
|
|
194
|
-
|
|
195
129
|
/**
|
|
196
130
|
* @typedef {Object} RuntimeObserver
|
|
197
131
|
* Per-call or host-level observer merged by createObserverHub (ai/observer.js).
|
|
@@ -254,10 +188,8 @@
|
|
|
254
188
|
* @typedef {Object} RuntimeRunOptions
|
|
255
189
|
* The options object a host passes to `createRuntime(host).run(systemPrompt, options)`.
|
|
256
190
|
* @property {RuntimeModelRef} model Resolved model reference; see parseRuntimeModelReference.
|
|
257
|
-
* @property {"sdk"|"cli"|"acp"} [executionMode] "sdk" (default), "cli", or "acp"; selects which bridge variant handles the model.
|
|
258
191
|
* @property {string} [sessionId] Host conversation/session key for resumable bridges.
|
|
259
192
|
* @property {string} [providerSessionId] Provider-owned resume id for resumable bridges.
|
|
260
|
-
* @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.
|
|
261
193
|
* @property {boolean} [sessionKeepAlive] Keep resumable provider state alive after the turn.
|
|
262
194
|
* @property {number} [sessionIdleTimeoutMs] Idle TTL for resumable provider state.
|
|
263
195
|
* @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.
|
|
@@ -266,7 +198,6 @@
|
|
|
266
198
|
* @property {RuntimeToolLifecycleSink} [toolLifecycleSink] Awaited host-owned incremental lifecycle persistence boundary.
|
|
267
199
|
* @property {ReadonlyArray<Object>} [messages]
|
|
268
200
|
* @property {string} [effort]
|
|
269
|
-
* @property {boolean} [fastMode]
|
|
270
201
|
* @property {string} [cwd]
|
|
271
202
|
* @property {Object<string, Object>} [mcpServers]
|
|
272
203
|
* @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.
|
|
@@ -285,36 +216,14 @@
|
|
|
285
216
|
* @property {RuntimeToolLimits} [toolLimits] Typed per-run tool-output limits (supported replacement for the deprecated `settings` tool keys).
|
|
286
217
|
* @property {RuntimeCompactionPolicy} [compaction] Typed per-run compaction policy (supported replacement for the deprecated `settings` compaction keys).
|
|
287
218
|
* @property {RuntimePromptOverrides} [prompts] Per-run prompt-fragment overrides (run wins over the host default).
|
|
288
|
-
* @property {import('./providers/acp-client.js').AcpClientHostOptions["resolveAcpProfile"]} [resolveAcpProfile] Per-run ACP profile resolver; wins over the host default.
|
|
289
|
-
* @property {import('./providers/acp-client.js').AcpClientHostOptions["onAcpInteractionRequest"]} [onAcpInteractionRequest] Per-run ACP permission/elicitation callback; wins over the host default.
|
|
290
|
-
* @property {Uint8Array} [acpSessionTokenKey] Host-owned 32-byte key for confidential authenticated ACP session handles. Required for every ACP task run.
|
|
291
219
|
* @property {{backend?: "auto"|"searxng"|"codex"|"keyless", endpoint?: string, codex?: {model?: string}}} [webSearchConfig] Run-scoped WebSearch backend configuration.
|
|
292
220
|
* @property {{render?: "never"|"auto", browserCommand?: string}} [webFetchConfig] Run-scoped WebFetch extraction/render configuration.
|
|
293
221
|
* @property {"sequential"|"safe-parallel"} [piToolExecutionMode] Pi built-in tool scheduling mode. Safe parallelism is the default.
|
|
294
222
|
* @property {"one-at-a-time"|"all"} [piToolParallelismMode] DEPRECATED. Compatibility alias mapped to piToolExecutionMode.
|
|
295
223
|
* @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).
|
|
296
|
-
* @property {ReadonlyArray<"user" | "project" | "local">} [settingSources] Claude Agent SDK only. Filesystem
|
|
297
|
-
* settings the SDK may load for this run. Omitted/empty disables user, project, and local sources, including their
|
|
298
|
-
* CLAUDE.md, hooks, plugins, and on-disk agent profiles. Anthropic managed settings remain in force and may still
|
|
299
|
-
* configure hooks or plugins; this option is not a managed-policy bypass. Each opted-in source may execute configured
|
|
300
|
-
* hooks and plugins, so enable only trusted settings and avoid these sources in an untrusted checkout. Include
|
|
301
|
-
* `"project"`/`"user"` to let the native `Task` tool discover `.claude/agents` definitions. Unrecognized entries are
|
|
302
|
-
* dropped. The Claude Code CLI bridge does not take this option: that binary performs its own settings discovery and
|
|
303
|
-
* mono-agent passes no `--setting-sources`, so a CLI run already reads the host config regardless of this value.
|
|
304
|
-
* @property {boolean} [codexLoadProjectDocs] Codex app-server only. Omitted/false starts the managed app-server with
|
|
305
|
-
* `project_doc_max_bytes=0`, preventing automatic repository-instruction discovery. True restores Codex's native
|
|
306
|
-
* project-doc loading defaults. An explicit `codexAppServerArgs` array wins over this convenience option.
|
|
307
|
-
* @property {boolean} [codexSandboxNetworkAccess] Codex app-server only, code-only. Strict `true` enables native
|
|
308
|
-
* network access for plan/read-only and default/acceptEdits/workspace-write turns; omitted or any other runtime
|
|
309
|
-
* value denies it. No-tool probes always deny network access, and bypass/danger-full-access remains unchanged. This
|
|
310
|
-
* is unrelated to `RuntimeRunOptions.sandboxPolicy`, which controls mono-agent's own sandbox and is not consumed by
|
|
311
|
-
* Codex's provider-owned tool loop. Default/acceptEdits workspace-write plus network true grants repository read and
|
|
312
|
-
* network egress in the same turn; prefer plan when only read-only browsing is needed.
|
|
313
|
-
* @property {RuntimeNativeSubagentsOptions} [nativeSubagents] Caller-defined Claude native `Task` profiles. Direct
|
|
314
|
-
* Codex owns its collaboration agents and rejects configured teammate definitions; `codexLoadProjectDocs` controls
|
|
315
|
-
* whether Codex loads repository instructions for its own agents.
|
|
316
224
|
* @property {RuntimeSubagentsOptions} [subagents] In-process `Agent` built-in: profiles, caps, and the nested-run callback.
|
|
317
225
|
* @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.
|
|
226
|
+
* @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.
|
|
318
227
|
* @property {Object} [diagnosticsSeed] Set by createRouterRuntime (ai/runtime/router.js) with a `resume_snapshot` when
|
|
319
228
|
* failing over mid-chain; a host-level coordinator may relay it forward (see agent/transcript.js), not read by any
|
|
320
229
|
* bridge in this package today.
|
|
@@ -325,7 +234,7 @@
|
|
|
325
234
|
|
|
326
235
|
/**
|
|
327
236
|
* @typedef {RuntimeRunOptions
|
|
328
|
-
* & Pick<AgentRuntimeHostOptions, "resolveCustomPricing" | "resolvePiApiKey" | "
|
|
237
|
+
* & Pick<AgentRuntimeHostOptions, "resolveCustomPricing" | "resolvePiApiKey" | "persistArtifact" | "onCompactionRecorded" | "onToolApprovalRequest" | "toolRiskTiers" | "approvalDefaultRiskTier" | "approvalTimeoutMs" | "approvalAlwaysAllowTools">
|
|
329
238
|
* & {runtimeBrand: import('../runtime-brand.js').RuntimeBrand, toolContext?: import('../agent/tools/shared/tool-context.js').ToolContext, observerHub: {emit: (event: RuntimeEvent) => void, flush: () => Promise<void>}}
|
|
330
239
|
* } RuntimeRequest
|
|
331
240
|
* The request shape a bridge's `execute(systemPrompt, req)` receives as its
|
|
@@ -407,8 +316,7 @@
|
|
|
407
316
|
* @property {Array<Object>} [runtimeWarnings]
|
|
408
317
|
* @property {Object} [diagnostics]
|
|
409
318
|
* @property {Object} [capabilitiesUsed]
|
|
410
|
-
* @property {Array<{model: RuntimeModelRef, failureKind: (string|null), requestId?: (string|null), retryableSubkind?: (string|null), retryIndex?: number, requirements?: Object
|
|
411
|
-
* @property {Array<{attemptIndex: number, model: RuntimeModelRef, routeSafety: RuntimeRouteSafetyMode, safetyContract: RuntimeRouteSafetyContract, status: string}>} [routeSafetyHistory] Bounded route-safety audit emitted by createRouterRuntime.
|
|
319
|
+
* @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.
|
|
412
320
|
*/
|
|
413
321
|
|
|
414
322
|
/**
|
|
@@ -428,8 +336,7 @@
|
|
|
428
336
|
* @property {boolean} [supports_builtin_tools]
|
|
429
337
|
* @property {boolean} [supports_live_input]
|
|
430
338
|
* @property {boolean} [supports_native_subagents] Whether the bridge exposes provider-native subagent surfaces and
|
|
431
|
-
* normalized activity.
|
|
432
|
-
* agents, while only the Claude bridges project caller-defined profiles.
|
|
339
|
+
* normalized activity. In-process delegation is the `Agent` tool, configured by the host.
|
|
433
340
|
* @property {boolean} [supports_request_tool_environment]
|
|
434
341
|
* @property {boolean} [supports_fast_mode]
|
|
435
342
|
* @property {"projected"|"allow_all_only"} [tool_policy] Whether the bridge can
|
|
@@ -508,11 +415,8 @@
|
|
|
508
415
|
* @property {RuntimePromptOverrides} [prompts] Host-level prompt-fragment override defaults; a per-run `options.prompts` field wins over these (see resolvePrompts, runtime.js).
|
|
509
416
|
* @property {ReadonlyArray<*>} [observers] Observer instances (see RuntimeObserver); loose because observer.js is not a kernel seam file.
|
|
510
417
|
* @property {*} [runtimeBrand] See resolveRuntimeBrand (runtime-brand.js); accepts a partial RuntimeBrand.
|
|
511
|
-
* @property {(parsed: {
|
|
418
|
+
* @property {(parsed: {provider: string, model: string}) => (import('./cost.js').NormalizedPricing|null)} [resolveCustomPricing] See resolvePricing (ai/cost.js).
|
|
512
419
|
* @property {import('../pi-auth.js').PiApiKeyResolver} [resolvePiApiKey] See createPiOAuthApiKeyResolver (pi-auth.js) for a ready-made implementation.
|
|
513
|
-
* @property {import('./providers/acp-client.js').AcpClientHostOptions["resolveAcpProfile"]} [resolveAcpProfile] Default ACP profile resolver; a per-run callback wins.
|
|
514
|
-
* @property {import('./providers/acp-client.js').AcpClientHostOptions["onAcpInteractionRequest"]} [onAcpInteractionRequest] Default ACP interaction callback; a per-run callback wins.
|
|
515
|
-
* @property {Uint8Array} [acpSessionTokenKey] Default host-owned 32-byte key for confidential authenticated ACP session handles.
|
|
516
420
|
* @property {(artifact: {filename: string, buffer: Buffer, toolName: string, toolUseId: (string|null)}) => (string|null)} [persistArtifact]
|
|
517
421
|
* @property {(record: CompactionRecordedPayload) => void} [onCompactionRecorded]
|
|
518
422
|
* @property {(payload: ApprovalRequestPayload) => Promise<ApprovalDecision>} [onToolApprovalRequest]
|
package/src/index.js
CHANGED
|
@@ -18,12 +18,6 @@ export {
|
|
|
18
18
|
DEFAULT_RUNTIME_BRAND,
|
|
19
19
|
resolveRuntimeBrand,
|
|
20
20
|
} from "./runtime-brand.js";
|
|
21
|
-
export {
|
|
22
|
-
CLAUDE_SDK_CATALOG_VERSION,
|
|
23
|
-
discoverClaudeSdkModels,
|
|
24
|
-
normalizeClaudeSdkCatalog,
|
|
25
|
-
normalizeClaudeSdkModelId,
|
|
26
|
-
} from "./ai/providers/claude-sdk-discovery.js";
|
|
27
21
|
|
|
28
22
|
export * from "./ai/index.js";
|
|
29
23
|
export * from "./agent/index.js";
|
package/src/runtime.js
CHANGED
|
@@ -5,14 +5,11 @@
|
|
|
5
5
|
// per-instance `ToolContext` (agent/tools/shared/tool-context.js) that this
|
|
6
6
|
// runtime instance threads to every bridge call via `options.toolContext`
|
|
7
7
|
// instead of a process-global, and returns a `.run(systemPrompt, options)`
|
|
8
|
-
// method that resolves the
|
|
9
|
-
// `options.executionMode`.
|
|
8
|
+
// method that resolves the Pi provider bridge based on `options.model`.
|
|
10
9
|
//
|
|
11
|
-
// The runtime registry
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
// control can keep using the named exports (resolveRuntimeBridge,
|
|
15
|
-
// generateClaudeResponse, etc.) directly.
|
|
10
|
+
// The runtime registry lazily imports the Pi implementation only when a run
|
|
11
|
+
// selects it. Hosts that need finer control can keep using the named exports
|
|
12
|
+
// directly.
|
|
16
13
|
//
|
|
17
14
|
// Return shape from `.run()`:
|
|
18
15
|
// { text, structuredResult, structuredResultSource, events, usage,
|
|
@@ -51,12 +48,13 @@ import { createToolLifecycleEventGate } from "./ai/tool-lifecycle.js";
|
|
|
51
48
|
* @typedef {import('./ai/types.js').RuntimeResult} RuntimeResult
|
|
52
49
|
*/
|
|
53
50
|
|
|
51
|
+
// Host-integration callbacks bound onto every request. This list is the runtime
|
|
52
|
+
// half of the `Pick<AgentRuntimeHostOptions, ...>` clause in the `RuntimeRequest`
|
|
53
|
+
// typedef (ai/types.js) -- the two must stay identical, or hosts get keys the
|
|
54
|
+
// declared request shape does not admit.
|
|
54
55
|
const HOST_KEYS = [
|
|
55
56
|
"resolveCustomPricing",
|
|
56
57
|
"resolvePiApiKey",
|
|
57
|
-
"resolveAcpProfile",
|
|
58
|
-
"onAcpInteractionRequest",
|
|
59
|
-
"acpSessionTokenKey",
|
|
60
58
|
"persistArtifact",
|
|
61
59
|
"onCompactionRecorded",
|
|
62
60
|
"onToolApprovalRequest",
|
|
@@ -177,7 +175,6 @@ export function createRuntime(host = {}) {
|
|
|
177
175
|
...(request.skills === undefined ? {} : { skills: request.skills }),
|
|
178
176
|
...(request.skillsRoot === undefined ? {} : { skillsRoot: request.skillsRoot }),
|
|
179
177
|
...(request.toolEnvironment === undefined ? {} : { toolEnvironment: request.toolEnvironment }),
|
|
180
|
-
...(request.executionMode === undefined ? {} : { executionMode: request.executionMode }),
|
|
181
178
|
...(request.cwd === undefined ? {} : { cwd: request.cwd }),
|
|
182
179
|
// A profile that pins effort — declared or authored at call time — means it
|
|
183
180
|
// on this path too; dropping it would silently run the child at the
|
|
@@ -203,10 +200,8 @@ export function createRuntime(host = {}) {
|
|
|
203
200
|
*/
|
|
204
201
|
async run(systemPrompt, options = {}) {
|
|
205
202
|
if (!options.model) throw new Error("createRuntime.run requires options.model");
|
|
206
|
-
const executionMode = typeof options.executionMode === "string" ? options.executionMode : "sdk";
|
|
207
203
|
const bridge = await resolveRuntimeBridge(options.model, {
|
|
208
204
|
liveInput: !!options.liveInput,
|
|
209
|
-
executionMode,
|
|
210
205
|
});
|
|
211
206
|
const callObservers = Array.isArray(options.observers) ? options.observers : [];
|
|
212
207
|
const hub = createObserverHub({
|
|
@@ -243,7 +238,6 @@ export function createRuntime(host = {}) {
|
|
|
243
238
|
// (spread reads the parameter's declared — Partial — type); re-assert
|
|
244
239
|
// the already-validated model so the request satisfies RuntimeRequest.
|
|
245
240
|
model: options.model,
|
|
246
|
-
executionMode,
|
|
247
241
|
runtimeBrand,
|
|
248
242
|
toolContext: runToolContext,
|
|
249
243
|
observerHub: hub,
|
|
@@ -38,12 +38,11 @@ export function subagentUsageForRun(subagents: any, parentRunId: string | undefi
|
|
|
38
38
|
* Build the `Agent` tool, or null when subagents are unavailable for this run.
|
|
39
39
|
*
|
|
40
40
|
* @param {RuntimeSubagentsOptions|null|undefined} subagents
|
|
41
|
-
* @param {{model?: *,
|
|
41
|
+
* @param {{model?: *, cwd?: string, parentRunId?: string, sandboxPolicy?: *, sandboxEngine?: *, skills?: {name: string, description?: string}[], skillsRoot?: string, toolEnvironment?: *, onEvent?: (event: *) => void}} [context]
|
|
42
42
|
* @returns {*|null}
|
|
43
43
|
*/
|
|
44
44
|
export function createAgentTool(subagents: RuntimeSubagentsOptions | null | undefined, context?: {
|
|
45
45
|
model?: any;
|
|
46
|
-
executionMode?: string;
|
|
47
46
|
cwd?: string;
|
|
48
47
|
parentRunId?: string;
|
|
49
48
|
sandboxPolicy?: any;
|
|
@@ -28,4 +28,4 @@ export function searchCodexSubscription(query: string, options?: {
|
|
|
28
28
|
/** Test hook for process-shared broker state. */
|
|
29
29
|
export function __resetCodexSubscriptionSearchForTests(): Promise<void>;
|
|
30
30
|
export const DEFAULT_CODEX_SEARCH_MODEL: "gpt-5.6-luna";
|
|
31
|
-
import { createCodexAppServerClient } from "../../ai/providers/codex-
|
|
31
|
+
import { createCodexAppServerClient } from "../../ai/providers/codex/app-server-client.js";
|
|
@@ -7,6 +7,7 @@ export { createWebToolController } from "./web-controller.js";
|
|
|
7
7
|
export { resolveRgPath } from "./shared/ripgrep.js";
|
|
8
8
|
export { bashToolImpl, bashToolRun, normalizeBackgroundBashTimeoutMs, normalizeBackgroundTimeoutMs, normalizeBashTimeoutMs, normalizeProcessTimeoutMs } from "./bash.js";
|
|
9
9
|
export { execToolImpl, execToolRun } from "./exec.js";
|
|
10
|
+
export { DEFAULT_MONITOR_TIMEOUT_MS, MIN_MONITOR_TIMEOUT_MS, monitorStopToolRun, monitorToolRun, normalizeMonitorTimeoutMs } from "./monitor.js";
|
|
10
11
|
export { webFetchToolImpl, performWebFetch } from "./web-fetch.js";
|
|
11
12
|
export { webSearchToolImpl, performWebSearch } from "./web-search.js";
|
|
12
13
|
export { DEFAULT_CODEX_SEARCH_MODEL, inspectCodexSubscriptionSearch, searchCodexSubscription } from "./codex-subscription-search.js";
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalize `timeout_ms` for a monitor. Unlike Bash there is no
|
|
3
|
+
* seconds-vs-milliseconds heuristic — this field is new, so it is exact
|
|
4
|
+
* milliseconds only. `undefined`/invalid falls back to the documented default;
|
|
5
|
+
* the host's own ceiling clamps the result on its side and reports what it
|
|
6
|
+
* actually granted.
|
|
7
|
+
*/
|
|
8
|
+
export function normalizeMonitorTimeoutMs(value: any, fallback?: number): number;
|
|
9
|
+
/**
|
|
10
|
+
* Structured Monitor execution used by the Pi bridge.
|
|
11
|
+
*
|
|
12
|
+
* Command preparation is deliberately byte-identical to Bash: the same
|
|
13
|
+
* `/bin/bash --noprofile --norc -c` shape, the same workdir rules, the same
|
|
14
|
+
* cleaned startup environment, and the same sandbox `prepareCommand` seam. A
|
|
15
|
+
* monitor must never be a way to run a command Bash could not.
|
|
16
|
+
*
|
|
17
|
+
* @param {{command?: string, description?: string, timeout_ms?: number, persistent?: boolean, workdir?: string}} params
|
|
18
|
+
* @param {{signal?: AbortSignal, sandboxPolicy?: any, sandboxEngine?: any, ctx?: any, monitorsController?: import("./shared/monitors.js").MonitorsController}} [options]
|
|
19
|
+
*/
|
|
20
|
+
export function monitorToolRun({ command, description, timeout_ms, persistent, workdir }: {
|
|
21
|
+
command?: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
timeout_ms?: number;
|
|
24
|
+
persistent?: boolean;
|
|
25
|
+
workdir?: string;
|
|
26
|
+
}, { sandboxPolicy, sandboxEngine, ctx, monitorsController }?: {
|
|
27
|
+
signal?: AbortSignal;
|
|
28
|
+
sandboxPolicy?: any;
|
|
29
|
+
sandboxEngine?: any;
|
|
30
|
+
ctx?: any;
|
|
31
|
+
monitorsController?: import("./shared/monitors.js").MonitorsController;
|
|
32
|
+
}): Promise<any>;
|
|
33
|
+
/**
|
|
34
|
+
* @param {{monitor_id?: string}} params
|
|
35
|
+
* @param {{monitorsController?: import("./shared/monitors.js").MonitorsController}} [options]
|
|
36
|
+
*/
|
|
37
|
+
export function monitorStopToolRun({ monitor_id }: {
|
|
38
|
+
monitor_id?: string;
|
|
39
|
+
}, { monitorsController }?: {
|
|
40
|
+
monitorsController?: import("./shared/monitors.js").MonitorsController;
|
|
41
|
+
}): Promise<any>;
|
|
42
|
+
/** Claude-Code-compatible defaults: 5 minutes, never below one second. */
|
|
43
|
+
export const DEFAULT_MONITOR_TIMEOUT_MS: 300000;
|
|
44
|
+
export const MIN_MONITOR_TIMEOUT_MS: 1000;
|
|
@@ -35,9 +35,9 @@ export function createStructuredOutputTool(outputSchema: any, onStructuredOutput
|
|
|
35
35
|
};
|
|
36
36
|
/**
|
|
37
37
|
* @param {any} allowedTools
|
|
38
|
-
* @param {{disallowedTools?: any[], skillNames?: any[], skills?: any[], skillsRoot?: any, dataDir?: any, cwd?: any, onEvent?: (event: any) => void, toolLimits?: any, persistArtifact?: any, onTruncate?: any, toolPayloadMaxBytes?: number, imageInlineMaxBytes?: any, toolPolicy?: any, sandboxPolicy?: any, sandboxEngine?: any, approvalManager?: any, approvalModel?: any, nodeReplController?: any, webController?: any, processJobsController?: any, toolExecutionMode?: "sequential"|"safe-parallel", subagents?: any, subagentContext?: any, ctx?: any}} [options]
|
|
38
|
+
* @param {{disallowedTools?: any[], skillNames?: any[], skills?: any[], skillsRoot?: any, dataDir?: any, cwd?: any, onEvent?: (event: any) => void, toolLimits?: any, persistArtifact?: any, onTruncate?: any, toolPayloadMaxBytes?: number, imageInlineMaxBytes?: any, toolPolicy?: any, sandboxPolicy?: any, sandboxEngine?: any, approvalManager?: any, approvalModel?: any, nodeReplController?: any, webController?: any, processJobsController?: any, monitorsController?: any, toolExecutionMode?: "sequential"|"safe-parallel", subagents?: any, subagentContext?: any, ctx?: any}} [options]
|
|
39
39
|
*/
|
|
40
|
-
export function getPiBuiltinTools(allowedTools: any, { disallowedTools, skillNames, skills, skillsRoot, dataDir, cwd, onEvent, toolLimits, persistArtifact, onTruncate, toolPayloadMaxBytes, imageInlineMaxBytes, toolPolicy, sandboxPolicy, sandboxEngine, approvalManager, approvalModel, nodeReplController, webController, processJobsController, subagents, subagentContext, toolExecutionMode, ctx, }?: {
|
|
40
|
+
export function getPiBuiltinTools(allowedTools: any, { disallowedTools, skillNames, skills, skillsRoot, dataDir, cwd, onEvent, toolLimits, persistArtifact, onTruncate, toolPayloadMaxBytes, imageInlineMaxBytes, toolPolicy, sandboxPolicy, sandboxEngine, approvalManager, approvalModel, nodeReplController, webController, processJobsController, monitorsController, subagents, subagentContext, toolExecutionMode, ctx, }?: {
|
|
41
41
|
disallowedTools?: any[];
|
|
42
42
|
skillNames?: any[];
|
|
43
43
|
skills?: any[];
|
|
@@ -58,6 +58,7 @@ export function getPiBuiltinTools(allowedTools: any, { disallowedTools, skillNam
|
|
|
58
58
|
nodeReplController?: any;
|
|
59
59
|
webController?: any;
|
|
60
60
|
processJobsController?: any;
|
|
61
|
+
monitorsController?: any;
|
|
61
62
|
toolExecutionMode?: "sequential" | "safe-parallel";
|
|
62
63
|
subagents?: any;
|
|
63
64
|
subagentContext?: any;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kernel-local structural controller seam. The typed public interface lives in
|
|
3
|
+
* runtime-adapter; this package deliberately has no workspace dependencies.
|
|
4
|
+
*
|
|
5
|
+
* @typedef {Object} MonitorsController
|
|
6
|
+
* @property {(request: {
|
|
7
|
+
* prepared: import("../../sandbox-seam.js").PreparedSandboxCommand,
|
|
8
|
+
* summary: string,
|
|
9
|
+
* description: string,
|
|
10
|
+
* timeoutMs?: number,
|
|
11
|
+
* persistent?: boolean,
|
|
12
|
+
* launch: (options?: {timeoutMs?: number, onStdout?: (chunk: Buffer) => void, onStderr?: (chunk: Buffer) => void}) => ReturnType<typeof startPreparedProcess>,
|
|
13
|
+
* }) => Promise<{monitorId: string, state: "starting"|"running", startedAt: string, maxRuntimeMs: number, persistent: boolean}>} start
|
|
14
|
+
* @property {(monitorId: string) => Promise<{monitorId: string, state: string, stopped: boolean}>} stop
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Transfer one prepared watch command to the injected host controller. From the
|
|
18
|
+
* instant `start()` is invoked, the controller owns cleanup on every path.
|
|
19
|
+
*
|
|
20
|
+
* @param {{
|
|
21
|
+
* controller: MonitorsController,
|
|
22
|
+
* prepared: import("../../sandbox-seam.js").PreparedSandboxCommand,
|
|
23
|
+
* summary: string,
|
|
24
|
+
* description: string,
|
|
25
|
+
* timeoutMs?: number,
|
|
26
|
+
* persistent?: boolean,
|
|
27
|
+
* startedAt: number,
|
|
28
|
+
* failed: (text: string, code: string, startedAt: number) => any,
|
|
29
|
+
* }} input
|
|
30
|
+
*/
|
|
31
|
+
export function handOffMonitor({ controller, prepared, summary, description, timeoutMs, persistent, startedAt, failed, }: {
|
|
32
|
+
controller: MonitorsController;
|
|
33
|
+
prepared: import("../../sandbox-seam.js").PreparedSandboxCommand;
|
|
34
|
+
summary: string;
|
|
35
|
+
description: string;
|
|
36
|
+
timeoutMs?: number;
|
|
37
|
+
persistent?: boolean;
|
|
38
|
+
startedAt: number;
|
|
39
|
+
failed: (text: string, code: string, startedAt: number) => any;
|
|
40
|
+
}): Promise<any>;
|
|
41
|
+
/**
|
|
42
|
+
* Stop one monitor by id. Idempotent: stopping an already-terminal monitor is a
|
|
43
|
+
* success that reports the state it settled in, never an error, so a model that
|
|
44
|
+
* re-issues a stop after a terminal wake is not pushed into a retry loop.
|
|
45
|
+
*
|
|
46
|
+
* @param {{controller: MonitorsController, monitorId: unknown, startedAt: number, failed: (text: string, code: string, startedAt: number) => any}} input
|
|
47
|
+
*/
|
|
48
|
+
export function handOffMonitorStop({ controller, monitorId, startedAt, failed }: {
|
|
49
|
+
controller: MonitorsController;
|
|
50
|
+
monitorId: unknown;
|
|
51
|
+
startedAt: number;
|
|
52
|
+
failed: (text: string, code: string, startedAt: number) => any;
|
|
53
|
+
}): Promise<any>;
|
|
54
|
+
/**
|
|
55
|
+
* Kernel-local structural controller seam. The typed public interface lives in
|
|
56
|
+
* runtime-adapter; this package deliberately has no workspace dependencies.
|
|
57
|
+
*/
|
|
58
|
+
export type MonitorsController = {
|
|
59
|
+
start: (request: {
|
|
60
|
+
prepared: import("../../sandbox-seam.js").PreparedSandboxCommand;
|
|
61
|
+
summary: string;
|
|
62
|
+
description: string;
|
|
63
|
+
timeoutMs?: number;
|
|
64
|
+
persistent?: boolean;
|
|
65
|
+
launch: (options?: {
|
|
66
|
+
timeoutMs?: number;
|
|
67
|
+
onStdout?: (chunk: Buffer) => void;
|
|
68
|
+
onStderr?: (chunk: Buffer) => void;
|
|
69
|
+
}) => ReturnType<typeof startPreparedProcess>;
|
|
70
|
+
}) => Promise<{
|
|
71
|
+
monitorId: string;
|
|
72
|
+
state: "starting" | "running";
|
|
73
|
+
startedAt: string;
|
|
74
|
+
maxRuntimeMs: number;
|
|
75
|
+
persistent: boolean;
|
|
76
|
+
}>;
|
|
77
|
+
stop: (monitorId: string) => Promise<{
|
|
78
|
+
monitorId: string;
|
|
79
|
+
state: string;
|
|
80
|
+
stopped: boolean;
|
|
81
|
+
}>;
|
|
82
|
+
};
|
|
83
|
+
import { startPreparedProcess } from "./process-runner.js";
|
|
@@ -28,7 +28,15 @@ export function runPreparedProcess(commandSpec: {
|
|
|
28
28
|
* descendant in the owned group is still alive.
|
|
29
29
|
*
|
|
30
30
|
* @param {{command: string, args?: string[], cwd?: string, env?: Record<string, string|undefined>}} commandSpec
|
|
31
|
-
*
|
|
31
|
+
* `outputMode` selects how output is handled. "buffer" (default) accumulates it
|
|
32
|
+
* under `maxBufferBytes` and terminates the process when that bound is crossed —
|
|
33
|
+
* the right contract for a job whose whole output is the result. "stream" hands
|
|
34
|
+
* every chunk to `onStdout`/`onStderr` and stores NEITHER, so an indefinitely
|
|
35
|
+
* long watch is never killed for producing output and the caller owns the only
|
|
36
|
+
* copy. Buffering stderr as well would hand a streaming caller two overlapping
|
|
37
|
+
* views of it: the runner's bounded PREFIX plus the caller's own tail.
|
|
38
|
+
*
|
|
39
|
+
* @param {{timeoutMs?: number, signal?: AbortSignal, maxBufferBytes?: number, input?: string|Buffer, waitForProcessGroup?: boolean, exactEnvironment?: boolean, outputMode?: "buffer"|"stream", onStdout?: (chunk: Buffer) => void, onStderr?: (chunk: Buffer) => void}} [options]
|
|
32
40
|
* For process jobs, `release()` is the persistence fence: the target cannot
|
|
33
41
|
* spawn until the host has durably recorded the returned ownership metadata.
|
|
34
42
|
* Foreground handles expose a harmless no-op release for one structural shape.
|
|
@@ -40,13 +48,14 @@ export function startPreparedProcess(commandSpec: {
|
|
|
40
48
|
args?: string[];
|
|
41
49
|
cwd?: string;
|
|
42
50
|
env?: Record<string, string | undefined>;
|
|
43
|
-
}, { timeoutMs, signal, maxBufferBytes, input, waitForProcessGroup, exactEnvironment, onStdout, onStderr, }?: {
|
|
51
|
+
}, { timeoutMs, signal, maxBufferBytes, input, waitForProcessGroup, exactEnvironment, outputMode, onStdout, onStderr, }?: {
|
|
44
52
|
timeoutMs?: number;
|
|
45
53
|
signal?: AbortSignal;
|
|
46
54
|
maxBufferBytes?: number;
|
|
47
55
|
input?: string | Buffer;
|
|
48
56
|
waitForProcessGroup?: boolean;
|
|
49
57
|
exactEnvironment?: boolean;
|
|
58
|
+
outputMode?: "buffer" | "stream";
|
|
50
59
|
onStdout?: (chunk: Buffer) => void;
|
|
51
60
|
onStderr?: (chunk: Buffer) => void;
|
|
52
61
|
}): {
|
package/types/ai/cost.d.ts
CHANGED
|
@@ -29,8 +29,7 @@ export function estimateCost({ resolveCustomPricing, model, inputTokens, outputT
|
|
|
29
29
|
cacheCreationTokens?: number;
|
|
30
30
|
}): number | null;
|
|
31
31
|
export type ParsedModelReference = {
|
|
32
|
-
|
|
33
|
-
provider?: string;
|
|
32
|
+
provider: string;
|
|
34
33
|
model: string;
|
|
35
34
|
};
|
|
36
35
|
export type NormalizedPricing = {
|
package/types/ai/index.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
export * from "./runtime/model-refs.js";
|
|
2
2
|
export * from "./runtime/registry.js";
|
|
3
|
-
export * from "./
|
|
3
|
+
export * from "./pi-interop.js";
|
|
4
4
|
export { createSessionRegistry, disposeAllProviderSessions, disposeProviderSession, invalidateProviderSession, refreshProviderSession, syncProviderSession } from "./runtime/sessions.js";
|
|
5
5
|
export { createMetricsObserver, createObserverHub } from "./observer.js";
|
|
6
6
|
export { generatePiNativeResponse, piNativeRuntimeBridge } from "./providers/pi-native.js";
|
|
7
|
-
export { generateAcpResponse, acpRuntimeBridge } from "./providers/acp.js";
|
|
8
|
-
export { getPiBuiltinModel, listPiBuiltinModels, loginPiOAuth, reasoningLevelsForPiModel, resolvePiOAuthApiKey } from "./pi-interop.js";
|
|
9
|
-
export { CLAUDE_SDK_CATALOG_VERSION, createClaudeSdkDiscoveryIsolation, curatedClaudeSdkModels, discoverClaudeSdkModels, normalizeClaudeSdkCatalog, normalizeClaudeSdkModelId } from "./providers/claude-sdk-discovery.js";
|
|
10
7
|
export { buildCapabilitiesUsed, toolCompactionAppliedFromWarnings, UNKNOWN_CAPABILITY } from "./runtime/capabilities-used.js";
|
package/types/ai/pi-interop.d.ts
CHANGED
|
@@ -13,6 +13,22 @@ export function listPiBuiltinModels(providerId: string): PiBuiltinModelSnapshot[
|
|
|
13
13
|
* @returns {PiBuiltinModelSnapshot|undefined}
|
|
14
14
|
*/
|
|
15
15
|
export function getPiBuiltinModel(providerId: string, modelId: string): PiBuiltinModelSnapshot | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* List defensive snapshots of Pi's static built-in providers (id + display
|
|
18
|
+
* label). The dynamic "radius" gateway is deliberately excluded: it has no
|
|
19
|
+
* static catalog and must not be advertised as a browsable provider.
|
|
20
|
+
*
|
|
21
|
+
* @returns {PiBuiltinProviderSnapshot[]}
|
|
22
|
+
*/
|
|
23
|
+
export function listPiBuiltinProviders(): PiBuiltinProviderSnapshot[];
|
|
24
|
+
/**
|
|
25
|
+
* Describe one static Pi built-in provider by id, or `undefined` for unknown
|
|
26
|
+
* ids (including the dynamic "radius" gateway).
|
|
27
|
+
*
|
|
28
|
+
* @param {string} providerId
|
|
29
|
+
* @returns {PiBuiltinProviderSnapshot|undefined}
|
|
30
|
+
*/
|
|
31
|
+
export function describePiBuiltinProvider(providerId: string): PiBuiltinProviderSnapshot | undefined;
|
|
16
32
|
/**
|
|
17
33
|
* Translate Pi's model-native thinking levels to mono-agent effort spelling.
|
|
18
34
|
*
|
|
@@ -78,6 +94,10 @@ export type PiBuiltinModelSnapshot = {
|
|
|
78
94
|
[key: string]: any;
|
|
79
95
|
};
|
|
80
96
|
export type PiReasoningLevel = "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
97
|
+
export type PiBuiltinProviderSnapshot = {
|
|
98
|
+
id: string;
|
|
99
|
+
label: string;
|
|
100
|
+
};
|
|
81
101
|
export type PiOAuthCredentialsSnapshot = {
|
|
82
102
|
refresh: string;
|
|
83
103
|
access: string;
|