@mono-agent/agent-runtime 0.15.3 → 0.16.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 (43) hide show
  1. package/MIGRATION.md +41 -13
  2. package/README.md +43 -6
  3. package/package.json +7 -3
  4. package/src/agent/tools/agent-tool.js +894 -0
  5. package/src/agent/tools/bash.js +241 -123
  6. package/src/agent/tools/exec.js +238 -0
  7. package/src/agent/tools/index.js +10 -3
  8. package/src/agent/tools/node-repl.js +231 -95
  9. package/src/agent/tools/pi-bridge.js +115 -24
  10. package/src/agent/tools/shared/process-runner.js +162 -0
  11. package/src/agent/tools/shared/semaphore.js +73 -0
  12. package/src/agent/tools/web-browser-render.js +221 -0
  13. package/src/agent/tools/web-controller.js +160 -0
  14. package/src/agent/tools/web-fetch.js +653 -68
  15. package/src/agent/tools/web-search.js +568 -16
  16. package/src/ai/pi-interop.js +7 -5
  17. package/src/ai/pi-oauth-compat.js +193 -0
  18. package/src/ai/providers/pi-native/stream-subscriber.js +37 -0
  19. package/src/ai/providers/pi-native/turn-runner.js +73 -8
  20. package/src/ai/providers/pi-native.js +67 -7
  21. package/src/ai/runtime/router.js +310 -166
  22. package/src/ai/types.js +54 -2
  23. package/src/pi-auth.js +2 -2
  24. package/src/runtime.js +58 -1
  25. package/types/agent/tools/agent-tool.d.ts +80 -0
  26. package/types/agent/tools/bash.d.ts +55 -7
  27. package/types/agent/tools/exec.d.ts +53 -0
  28. package/types/agent/tools/index.d.ts +5 -3
  29. package/types/agent/tools/node-repl.d.ts +28 -3
  30. package/types/agent/tools/pi-bridge.d.ts +6 -2
  31. package/types/agent/tools/shared/process-runner.d.ts +33 -0
  32. package/types/agent/tools/shared/semaphore.d.ts +29 -0
  33. package/types/agent/tools/web-browser-render.d.ts +16 -0
  34. package/types/agent/tools/web-controller.d.ts +20 -0
  35. package/types/agent/tools/web-fetch.d.ts +74 -5
  36. package/types/agent/tools/web-search.d.ts +81 -5
  37. package/types/ai/pi-oauth-compat.d.ts +57 -0
  38. package/types/ai/providers/pi-native/turn-runner.d.ts +33 -2
  39. package/types/ai/providers/pi-native.d.ts +12 -0
  40. package/types/ai/runtime/router.d.ts +23 -3
  41. package/types/ai/types.d.ts +174 -4
  42. package/types/ai/backend.d.ts +0 -57
  43. package/types/ai/registry.d.ts +0 -1
@@ -1,11 +1,87 @@
1
1
  /**
2
- * @param {{query: string, limit?: number}} params
3
- * @param {{sandboxPolicy?: any, ctx?: any}} [options]
2
+ * Compatibility wrapper for direct callers.
3
+ *
4
+ * @param {{query: string, limit?: number, alternate_queries?: string[], domains?: string[], exclude_domains?: string[], language?: string, time_range?: string}} params
5
+ * @param {{sandboxPolicy?: any, ctx?: any, signal?: AbortSignal, searchConfig?: any, fetchImpl?: typeof fetch}} [options]
4
6
  */
5
- export function webSearchToolImpl({ query, limit }: {
7
+ export function webSearchToolImpl(params: {
6
8
  query: string;
7
9
  limit?: number;
8
- }, { sandboxPolicy, ctx }?: {
10
+ alternate_queries?: string[];
11
+ domains?: string[];
12
+ exclude_domains?: string[];
13
+ language?: string;
14
+ time_range?: string;
15
+ }, options?: {
9
16
  sandboxPolicy?: any;
10
17
  ctx?: any;
11
- }): Promise<string>;
18
+ signal?: AbortSignal;
19
+ searchConfig?: any;
20
+ fetchImpl?: typeof fetch;
21
+ }): Promise<any>;
22
+ /**
23
+ * Search through an operator-owned SearXNG endpoint and/or the keyless HTML
24
+ * fallback chain. Returns a structured internal outcome for the Pi bridge.
25
+ *
26
+ * @param {{query: string, limit?: number, alternate_queries?: string[], domains?: string[], exclude_domains?: string[], language?: string, time_range?: string}} params
27
+ * @param {{sandboxPolicy?: any, ctx?: any, signal?: AbortSignal, searchConfig?: any, fetchImpl?: typeof fetch}} [options]
28
+ */
29
+ export function performWebSearch({ query, limit, alternate_queries, domains, exclude_domains, language, time_range, }: {
30
+ query: string;
31
+ limit?: number;
32
+ alternate_queries?: string[];
33
+ domains?: string[];
34
+ exclude_domains?: string[];
35
+ language?: string;
36
+ time_range?: string;
37
+ }, { sandboxPolicy, ctx, signal, searchConfig, fetchImpl, }?: {
38
+ sandboxPolicy?: any;
39
+ ctx?: any;
40
+ signal?: AbortSignal;
41
+ searchConfig?: any;
42
+ fetchImpl?: typeof fetch;
43
+ }): Promise<{
44
+ text: any;
45
+ outcome: {
46
+ status: string;
47
+ code: any;
48
+ retryable: boolean;
49
+ attempts: number;
50
+ backend: string;
51
+ cacheHit: boolean;
52
+ durationMs: number;
53
+ bytes: number;
54
+ truncated: boolean;
55
+ };
56
+ error: boolean;
57
+ } | {
58
+ text: string;
59
+ outcome: {
60
+ status: string;
61
+ code: string;
62
+ retryable: boolean;
63
+ attempts: number;
64
+ backend: any;
65
+ cacheHit: boolean;
66
+ durationMs: number;
67
+ bytes: number;
68
+ truncated: boolean;
69
+ resultCount: number;
70
+ providerFailureCount: number;
71
+ };
72
+ error: boolean;
73
+ }>;
74
+ export function parseDuckDuckGoResults(html: any): {
75
+ title: string;
76
+ url: string;
77
+ snippet: string;
78
+ backend: string;
79
+ }[];
80
+ export function parseStartpageResults(html: any): {
81
+ title: string;
82
+ url: string;
83
+ snippet: string;
84
+ backend: string;
85
+ }[];
86
+ export function canonicalizeSearchUrl(value: any, base: any): string;
87
+ export function mergeRankedResults(rankedLists: any, limit?: number): any[];
@@ -0,0 +1,57 @@
1
+ /** @internal Exported only so tests can force a rebuild of the memoized index. */
2
+ export function resetPiProviderIndexForTests(): void;
3
+ /**
4
+ * The OAuth implementation for a Pi provider id, or undefined when the provider
5
+ * is unknown or supports only API-key auth (e.g. `opencode-go`).
6
+ *
7
+ * @param {string} providerId
8
+ * @returns {OAuthAuth|undefined}
9
+ */
10
+ export function getPiOAuthAuth(providerId: string): OAuthAuth | undefined;
11
+ /**
12
+ * Every Pi provider id that supports OAuth. Replaces
13
+ * `getOAuthProviders().map((provider) => provider.id)`.
14
+ *
15
+ * @returns {string[]}
16
+ */
17
+ export function getPiOAuthProviderIds(): string[];
18
+ /**
19
+ * Resolve an API key from stored OAuth credentials, refreshing first when the
20
+ * token has expired.
21
+ *
22
+ * Reproduces pi-ai 0.80.6's `getOAuthApiKey(providerId, credentials)` contract
23
+ * so its call sites keep their shape: takes the whole provider-keyed credential
24
+ * map, returns `null` when this provider has no stored credential, and is
25
+ * *pure* — the refreshed credential comes back as `newCredentials` for the
26
+ * caller to persist rather than being written here.
27
+ *
28
+ * The refresh trigger is deliberately the old exact-expiry check. pi's own
29
+ * `Models.getAuth()` refreshes five minutes ahead of expiry; matching that would
30
+ * change live token rotation timing, which this migration does not intend.
31
+ *
32
+ * @param {string} providerId
33
+ * @param {Record<string, *>|undefined} credentials Provider-keyed credential map.
34
+ * @returns {Promise<{newCredentials: OAuthCredential, apiKey: string|undefined}|null>}
35
+ */
36
+ export function resolveOAuthApiKey(providerId: string, credentials: Record<string, any> | undefined): Promise<{
37
+ newCredentials: OAuthCredential;
38
+ apiKey: string | undefined;
39
+ } | null>;
40
+ /**
41
+ * Bridge the legacy six-callback OAuth surface onto 0.83.0's single
42
+ * `prompt`/`notify` pair.
43
+ *
44
+ * `manual_code` must stay wired to `onManualCodeInput`: Anthropic races its
45
+ * localhost callback against a pasted redirect URL, and that path is the reason
46
+ * `agent-app`'s `runPiOAuthLogin` exists at all.
47
+ *
48
+ * @param {OAuthLoginCallbacks} callbacks
49
+ * @returns {AuthInteraction}
50
+ */
51
+ export function toAuthInteraction(callbacks: OAuthLoginCallbacks): AuthInteraction;
52
+ export type OAuthAuth = import("@earendil-works/pi-ai").OAuthAuth;
53
+ export type OAuthCredential = import("@earendil-works/pi-ai").OAuthCredential;
54
+ export type AuthInteraction = import("@earendil-works/pi-ai").AuthInteraction;
55
+ export type AuthPrompt = import("@earendil-works/pi-ai").AuthPrompt;
56
+ export type AuthEvent = import("@earendil-works/pi-ai").AuthEvent;
57
+ export type OAuthLoginCallbacks = import("@earendil-works/pi-ai/oauth").OAuthLoginCallbacks;
@@ -9,7 +9,7 @@
9
9
  * @param {any} params
10
10
  * @returns {Promise<{tools: any[], structuredTool: any, mcpClients: any[], closeRunTools: () => Promise<void>}>}
11
11
  */
12
- export function buildTurnTools(runState: any, { options, capabilities, toolLimits, approvalManager, runtime, resolved, onEvent, runtimeWarnings, }: any): Promise<{
12
+ export function buildTurnTools(runState: any, { options, capabilities, toolLimits, approvalManager, runtime, resolved, onEvent, runtimeWarnings, toolExecutionMode, }: any): Promise<{
13
13
  tools: any[];
14
14
  structuredTool: any;
15
15
  mcpClients: any[];
@@ -32,7 +32,37 @@ export function thinkingLevelForEffort(effort: string, capabilities: any): strin
32
32
  * @param {any} params
33
33
  * @returns {any}
34
34
  */
35
- export function buildTurnHarness(runState: any, { cwd, session, piModels, model, thinkingLevel, systemPrompt, outputSchema, tools, transport, maxRetries, maxRetryDelayMs, steeringMode, onEvent, options, toolLimits, sdk, reference, }: any): any;
35
+ /**
36
+ * Restore the error flag on a tool result pi resolved successfully.
37
+ *
38
+ * pi hardcodes `isError: false` for every `execute()` that returns rather than
39
+ * throws, so any tool that reports failure in its payload needs this hook or
40
+ * the model is told the call succeeded.
41
+ *
42
+ * @param {*} details Tool-result details recorded by the bridge.
43
+ * @returns {{isError: true}|undefined}
44
+ */
45
+ export function toolResultErrorOverride(details: any): {
46
+ isError: true;
47
+ } | undefined;
48
+ export function buildTurnHarness(runState: any, { session, piModels, model, thinkingLevel, systemPrompt, outputSchema, tools, transport, maxRetries, maxRetryDelayMs, steeringMode, onEvent, options, toolLimits, sdk, reference, }: {
49
+ session: any;
50
+ piModels: any;
51
+ model: any;
52
+ thinkingLevel: any;
53
+ systemPrompt: any;
54
+ outputSchema: any;
55
+ tools: any;
56
+ transport: any;
57
+ maxRetries: any;
58
+ maxRetryDelayMs: any;
59
+ steeringMode: any;
60
+ onEvent: any;
61
+ options: any;
62
+ toolLimits: any;
63
+ sdk: any;
64
+ reference: any;
65
+ }): AgentHarness<undefined, import("@earendil-works/pi-agent-core").Skill, import("@earendil-works/pi-agent-core").PromptTemplate, import("@earendil-works/pi-agent-core").AgentHarnessTool<undefined>>;
36
66
  /**
37
67
  * Start the live-input steering consumer. Consumes follow-up messages and steers
38
68
  * the harness mid-run; the consumer is tied to run completion (an internal
@@ -60,3 +90,4 @@ export function startLiveInput({ harness, options, onEvent }: {
60
90
  export function runHarnessPrompt(harness: any, promptText: string, promptImages: Array<any>): Promise<{
61
91
  runError: any;
62
92
  }>;
93
+ import { AgentHarness } from "@earendil-works/pi-agent-core";
@@ -1,3 +1,15 @@
1
+ /**
2
+ * Pi 0.80.6 exposes per-tool execution markers but not AgentHarness's global
3
+ * toolExecution option. Resolve mono-agent's programmatic mode once per run;
4
+ * individual tool builders then mark stateful/mutating tools sequential.
5
+ */
6
+ export function resolvePiToolExecutionMode(options?: {}): {
7
+ mode: any;
8
+ warnings: {
9
+ warning_kind: string;
10
+ message: string;
11
+ }[];
12
+ };
1
13
  export function createDynamicCredentialStore(apiKeys: any, resolvePiApiKey: any, runtimeWarnings: any): any;
2
14
  export function splitPromptMessages(messages: any, model: any): {
3
15
  priorMessages: any[];
@@ -3,10 +3,12 @@
3
3
  * @param {AgentRuntimeHostOptions} [options.host]
4
4
  * @param {ReadonlyArray<RuntimeModelRef|RouterChainEntryInput>} [options.chain]
5
5
  * @param {"uniform"|"per-route-native"} [options.routeSafety]
6
- * @param {(input: {model: RuntimeModelRef, executionMode: string|null, attemptIndex: number, routeSafety: "uniform"|"per-route-native"}) => (RouterAttemptResolution|Promise<RouterAttemptResolution>)} [options.resolveAttempt]
6
+ * @param {(input: {model: RuntimeModelRef, executionMode: string|null, attemptIndex: number, retryIndex: number, routeSafety: "uniform"|"per-route-native"}) => (RouterAttemptResolution|Promise<RouterAttemptResolution>)} [options.resolveAttempt]
7
+ * @param {Partial<RouterRetryPolicy>} [options.retry] Backoff shape for same-model
8
+ * retries. Per-route retry counts live on each chain entry's `attempts`.
7
9
  * @returns {AgentRuntimeInstance & {chain: () => Array<RouterChainEntry>}}
8
10
  */
9
- export function createRouterRuntime({ host, chain, routeSafety, resolveAttempt }?: {
11
+ export function createRouterRuntime({ host, chain, routeSafety, resolveAttempt, retry }?: {
10
12
  host?: AgentRuntimeHostOptions;
11
13
  chain?: ReadonlyArray<RuntimeModelRef | RouterChainEntryInput>;
12
14
  routeSafety?: "uniform" | "per-route-native";
@@ -14,8 +16,10 @@ export function createRouterRuntime({ host, chain, routeSafety, resolveAttempt }
14
16
  model: RuntimeModelRef;
15
17
  executionMode: string | null;
16
18
  attemptIndex: number;
19
+ retryIndex: number;
17
20
  routeSafety: "uniform" | "per-route-native";
18
21
  }) => (RouterAttemptResolution | Promise<RouterAttemptResolution>);
22
+ retry?: Partial<RouterRetryPolicy>;
19
23
  }): AgentRuntimeInstance & {
20
24
  chain: () => Array<RouterChainEntry>;
21
25
  };
@@ -26,7 +30,8 @@ export type RuntimeRunOptions = import("../types.js").RuntimeRunOptions;
26
30
  export type RuntimeResult = import("../types.js").RuntimeResult;
27
31
  /**
28
32
  * A chain entry as accepted by createRouterRuntime: either the shorthand bare
29
- * RuntimeModelRef, or the full `{model, executionMode?, effort?, requires?}` form.
33
+ * RuntimeModelRef, or the full `{model, executionMode?, effort?, requires?,
34
+ * attempts?}` form.
30
35
  */
31
36
  export type RouterChainEntryInput = {
32
37
  model: RuntimeModelRef;
@@ -35,6 +40,7 @@ export type RouterChainEntryInput = {
35
40
  requires?: {
36
41
  [x: string]: any;
37
42
  };
43
+ attempts?: number;
38
44
  };
39
45
  export type RouterChainEntry = {
40
46
  model: RuntimeModelRef;
@@ -43,6 +49,20 @@ export type RouterChainEntry = {
43
49
  requires: {
44
50
  [x: string]: any;
45
51
  } | null;
52
+ /**
53
+ * Total attempts on this route including the first.
54
+ */
55
+ attempts: number;
56
+ };
57
+ export type RouterRetryPolicy = {
58
+ /**
59
+ * Delay before the first retry; doubles per retry.
60
+ */
61
+ backoffMs: number;
62
+ /**
63
+ * Ceiling for the doubled delay.
64
+ */
65
+ maxBackoffMs: number;
46
66
  };
47
67
  /**
48
68
  * Private host seam for route-specific provider options/runtime ownership.
@@ -118,7 +118,8 @@
118
118
  * @property {boolean} [fastMode]
119
119
  * @property {string} [cwd]
120
120
  * @property {Object<string, Object>} [mcpServers]
121
- * @property {ReadonlyArray<Object>} [skills] Runtime skill metadata for progressive disclosure.
121
+ * @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.
122
+ * @property {string} [skillsRoot] Directory holding `<name>/SKILL.md`. Required alongside `skills` for `ReadSkill` to be built.
122
123
  * @property {ReadonlyArray<string>} [allowedTools]
123
124
  * @property {ReadonlyArray<string>} [disallowedTools]
124
125
  * @property {string} [permissionMode]
@@ -132,8 +133,13 @@
132
133
  * @property {RuntimeToolLimits} [toolLimits] Typed per-run tool-output limits (supported replacement for the deprecated `settings` tool keys).
133
134
  * @property {RuntimeCompactionPolicy} [compaction] Typed per-run compaction policy (supported replacement for the deprecated `settings` compaction keys).
134
135
  * @property {RuntimePromptOverrides} [prompts] Per-run prompt-fragment overrides (run wins over the host default).
136
+ * @property {{backend?: "auto"|"searxng"|"keyless", endpoint?: string}} [webSearchConfig] Run-scoped WebSearch backend configuration.
137
+ * @property {{render?: "never"|"auto", browserCommand?: string}} [webFetchConfig] Run-scoped WebFetch extraction/render configuration.
138
+ * @property {"sequential"|"safe-parallel"} [piToolExecutionMode] Pi built-in tool scheduling mode. Safe parallelism is the default.
139
+ * @property {"one-at-a-time"|"all"} [piToolParallelismMode] DEPRECATED. Compatibility alias mapped to piToolExecutionMode.
135
140
  * @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).
136
141
  * @property {Object} [nativeSubagents] Same-runtime teammate helpers exposed through native provider subagent surfaces.
142
+ * @property {RuntimeSubagentsOptions} [subagents] In-process `Agent` built-in: profiles, caps, and the nested-run callback.
137
143
  * @property {Object} [diagnosticsSeed] Set by createRouterRuntime (ai/runtime/router.js) with a `resume_snapshot` when
138
144
  * failing over mid-chain; a host-level coordinator may relay it forward (see agent/transcript.js), not read by any
139
145
  * bridge in this package today.
@@ -154,6 +160,48 @@
154
160
  * createRuntime), and the per-run observerHub (onEvent is overridden to the
155
161
  * hub's emit). `systemPrompt` is passed positionally, not folded into this object.
156
162
  */
163
+ /**
164
+ * @typedef {Object} RuntimeSubagentDefinition
165
+ * One named subagent profile the `Agent` built-in can deploy.
166
+ * @property {string} name Model-visible identifier and the tool's `name` enum value.
167
+ * @property {string} description Model-visible: when to pick this profile.
168
+ * @property {string} systemPrompt Full system prompt for the child run.
169
+ * @property {RuntimeModelRef} [model] Absent inherits the parent's configured route.
170
+ * @property {string} [effort]
171
+ * @property {ReadonlyArray<string>} [allowedTools] Absent uses the safe read-only default set.
172
+ * @property {ReadonlyArray<string>} [disallowedTools]
173
+ * @property {Object<string, Object>} [mcpServers]
174
+ * @property {number} [maxTurns]
175
+ * @property {number} [timeoutMs]
176
+ */
177
+ /**
178
+ * @callback RuntimeSubagentRun
179
+ * Owning-layer callback that actually executes one child turn. The kernel
180
+ * supplies a self-run fallback so `createRuntime` works without host wiring;
181
+ * agent-app replaces it so subagent runs get the configured fallback chain,
182
+ * same-model retries, and run recording.
183
+ * @param {Object} request
184
+ * @returns {Promise<RuntimeResult>}
185
+ */
186
+ /**
187
+ * @typedef {Object} RuntimeInlineSubagentsOptions
188
+ * Policy for subagents the model authors at call time rather than picking from
189
+ * `definitions`. Absent suppresses authoring entirely.
190
+ * @property {boolean} [enabled] Only `false` turns authoring off.
191
+ * @property {ReadonlyArray<string>} [allowedTools] Ceiling on what an authored subagent may
192
+ * request. Absent means the safe read-only default set, never every built-in.
193
+ */
194
+ /**
195
+ * @typedef {Object} RuntimeSubagentsOptions
196
+ * @property {ReadonlyArray<RuntimeSubagentDefinition>} [definitions] Named profiles.
197
+ * @property {RuntimeInlineSubagentsOptions} [inline] Call-time authoring policy.
198
+ * @property {number} [maxConcurrent] In-flight subagents per parent turn. Default 5.
199
+ * @property {number} [maxPerTurn] Total Agent calls per parent turn. Default 20.
200
+ * @property {number} [maxTurns] Default per-subagent turn cap. Default 100.
201
+ * @property {number} [timeoutMs] Default per-subagent wall clock.
202
+ * @property {RuntimeSubagentRun} [run] Nested-run callback; absent uses the kernel self-run.
203
+ * @property {number} [depth] Kernel-owned. Absent/0 is the parent; >=1 suppresses the `Agent` tool.
204
+ */
157
205
  /**
158
206
  * @typedef {Object} RuntimeResult
159
207
  * @property {string|null} [text]
@@ -175,7 +223,7 @@
175
223
  * @property {Array<Object>} [runtimeWarnings]
176
224
  * @property {Object} [diagnostics]
177
225
  * @property {Object} [capabilitiesUsed]
178
- * @property {Array<{model: RuntimeModelRef, failureKind: (string|null), requestId?: (string|null), retryableSubkind?: (string|null), requirements?: Object, routeSafety?: RuntimeRouteSafetyMode, safetyContract?: RuntimeRouteSafetyContract}>} [failoverHistory] Set by createRouterRuntime (ai/runtime/router.js) on every failed/skipped attempt.
226
+ * @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.
179
227
  * @property {Array<{attemptIndex: number, model: RuntimeModelRef, routeSafety: RuntimeRouteSafetyMode, safetyContract: RuntimeRouteSafetyContract, status: string}>} [routeSafetyHistory] Bounded route-safety audit emitted by createRouterRuntime.
180
228
  */
181
229
  /**
@@ -531,9 +579,16 @@ export type RuntimeRunOptions = {
531
579
  [x: string]: any;
532
580
  };
533
581
  /**
534
- * Runtime skill metadata for progressive disclosure.
582
+ * 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.
583
+ */
584
+ skills?: ReadonlyArray<{
585
+ name: string;
586
+ description?: string;
587
+ }>;
588
+ /**
589
+ * Directory holding `<name>/SKILL.md`. Required alongside `skills` for `ReadSkill` to be built.
535
590
  */
536
- skills?: ReadonlyArray<any>;
591
+ skillsRoot?: string;
537
592
  allowedTools?: ReadonlyArray<string>;
538
593
  disallowedTools?: ReadonlyArray<string>;
539
594
  permissionMode?: string;
@@ -565,6 +620,28 @@ export type RuntimeRunOptions = {
565
620
  * Per-run prompt-fragment overrides (run wins over the host default).
566
621
  */
567
622
  prompts?: RuntimePromptOverrides;
623
+ /**
624
+ * Run-scoped WebSearch backend configuration.
625
+ */
626
+ webSearchConfig?: {
627
+ backend?: "auto" | "searxng" | "keyless";
628
+ endpoint?: string;
629
+ };
630
+ /**
631
+ * Run-scoped WebFetch extraction/render configuration.
632
+ */
633
+ webFetchConfig?: {
634
+ render?: "never" | "auto";
635
+ browserCommand?: string;
636
+ };
637
+ /**
638
+ * Pi built-in tool scheduling mode. Safe parallelism is the default.
639
+ */
640
+ piToolExecutionMode?: "sequential" | "safe-parallel";
641
+ /**
642
+ * DEPRECATED. Compatibility alias mapped to piToolExecutionMode.
643
+ */
644
+ piToolParallelismMode?: "one-at-a-time" | "all";
568
645
  /**
569
646
  * 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).
570
647
  */
@@ -573,6 +650,10 @@ export type RuntimeRunOptions = {
573
650
  * Same-runtime teammate helpers exposed through native provider subagent surfaces.
574
651
  */
575
652
  nativeSubagents?: any;
653
+ /**
654
+ * In-process `Agent` built-in: profiles, caps, and the nested-run callback.
655
+ */
656
+ subagents?: RuntimeSubagentsOptions;
576
657
  /**
577
658
  * Set by createRouterRuntime (ai/runtime/router.js) with a `resume_snapshot` when
578
659
  * failing over mid-chain; a host-level coordinator may relay it forward (see agent/transcript.js), not read by any
@@ -603,6 +684,94 @@ export type RuntimeRequest = RuntimeRunOptions & Pick<AgentRuntimeHostOptions, "
603
684
  flush: () => Promise<void>;
604
685
  };
605
686
  };
687
+ /**
688
+ * One named subagent profile the `Agent` built-in can deploy.
689
+ */
690
+ export type RuntimeSubagentDefinition = {
691
+ /**
692
+ * Model-visible identifier and the tool's `name` enum value.
693
+ */
694
+ name: string;
695
+ /**
696
+ * Model-visible: when to pick this profile.
697
+ */
698
+ description: string;
699
+ /**
700
+ * Full system prompt for the child run.
701
+ */
702
+ systemPrompt: string;
703
+ /**
704
+ * Absent inherits the parent's configured route.
705
+ */
706
+ model?: RuntimeModelRef;
707
+ effort?: string;
708
+ /**
709
+ * Absent uses the safe read-only default set.
710
+ */
711
+ allowedTools?: ReadonlyArray<string>;
712
+ disallowedTools?: ReadonlyArray<string>;
713
+ mcpServers?: {
714
+ [x: string]: any;
715
+ };
716
+ maxTurns?: number;
717
+ timeoutMs?: number;
718
+ };
719
+ /**
720
+ * Owning-layer callback that actually executes one child turn. The kernel
721
+ * supplies a self-run fallback so `createRuntime` works without host wiring;
722
+ * agent-app replaces it so subagent runs get the configured fallback chain,
723
+ * same-model retries, and run recording.
724
+ */
725
+ export type RuntimeSubagentRun = (request: any) => Promise<RuntimeResult>;
726
+ /**
727
+ * Policy for subagents the model authors at call time rather than picking from
728
+ * `definitions`. Absent suppresses authoring entirely.
729
+ */
730
+ export type RuntimeInlineSubagentsOptions = {
731
+ /**
732
+ * Only `false` turns authoring off.
733
+ */
734
+ enabled?: boolean;
735
+ /**
736
+ * Ceiling on what an authored subagent may
737
+ * request. Absent means the safe read-only default set, never every built-in.
738
+ */
739
+ allowedTools?: ReadonlyArray<string>;
740
+ };
741
+ export type RuntimeSubagentsOptions = {
742
+ /**
743
+ * Named profiles.
744
+ */
745
+ definitions?: ReadonlyArray<RuntimeSubagentDefinition>;
746
+ /**
747
+ * Call-time authoring policy.
748
+ */
749
+ inline?: RuntimeInlineSubagentsOptions;
750
+ /**
751
+ * In-flight subagents per parent turn. Default 5.
752
+ */
753
+ maxConcurrent?: number;
754
+ /**
755
+ * Total Agent calls per parent turn. Default 20.
756
+ */
757
+ maxPerTurn?: number;
758
+ /**
759
+ * Default per-subagent turn cap. Default 100.
760
+ */
761
+ maxTurns?: number;
762
+ /**
763
+ * Default per-subagent wall clock.
764
+ */
765
+ timeoutMs?: number;
766
+ /**
767
+ * Nested-run callback; absent uses the kernel self-run.
768
+ */
769
+ run?: RuntimeSubagentRun;
770
+ /**
771
+ * Kernel-owned. Absent/0 is the parent; >=1 suppresses the `Agent` tool.
772
+ */
773
+ depth?: number;
774
+ };
606
775
  export type RuntimeResult = {
607
776
  text?: string | null;
608
777
  structuredResult?: any;
@@ -634,6 +803,7 @@ export type RuntimeResult = {
634
803
  failureKind: (string | null);
635
804
  requestId?: (string | null);
636
805
  retryableSubkind?: (string | null);
806
+ retryIndex?: number;
637
807
  requirements?: any;
638
808
  routeSafety?: RuntimeRouteSafetyMode;
639
809
  safetyContract?: RuntimeRouteSafetyContract;
@@ -1,57 +0,0 @@
1
- export function backendCapabilities(sdkOrModel: any): any;
2
- export function backendUsesExecenvConfig(sdk: any): boolean;
3
- export function backendSupportsSessionResume(sdk: any): boolean;
4
- export const BACKEND_CAPABILITIES: {
5
- claude: {
6
- supports_session_resume: boolean;
7
- streaming: boolean;
8
- structured_output: boolean;
9
- native_runtime_config: any;
10
- supports_mcp: boolean;
11
- supports_skills: boolean;
12
- supports_builtin_tools: boolean;
13
- supports_live_input: boolean;
14
- supports_native_subagents: boolean;
15
- supports_fast_mode: boolean;
16
- runtime: string;
17
- };
18
- pi: {
19
- supports_session_resume: boolean;
20
- supports_native_subagents: boolean;
21
- streaming: boolean;
22
- structured_output: boolean;
23
- native_runtime_config: any;
24
- supports_mcp: boolean;
25
- supports_skills: boolean;
26
- supports_builtin_tools: boolean;
27
- supports_live_input: boolean;
28
- supports_fast_mode: boolean;
29
- runtime: string;
30
- };
31
- codex: {
32
- supports_session_resume: boolean;
33
- supports_fast_mode: boolean;
34
- streaming: boolean;
35
- structured_output: boolean;
36
- native_runtime_config: any;
37
- supports_mcp: boolean;
38
- supports_skills: boolean;
39
- supports_builtin_tools: boolean;
40
- supports_live_input: boolean;
41
- supports_native_subagents: boolean;
42
- runtime: string;
43
- };
44
- opencode: {
45
- structured_output: boolean;
46
- supports_session_resume: boolean;
47
- supports_mcp: boolean;
48
- supports_skills: boolean;
49
- supports_live_input: boolean;
50
- supports_native_subagents: boolean;
51
- streaming: boolean;
52
- native_runtime_config: any;
53
- supports_builtin_tools: boolean;
54
- supports_fast_mode: boolean;
55
- runtime: string;
56
- };
57
- };
@@ -1 +0,0 @@
1
- export { listRuntimeBridges as listProviders, resolveRuntimeBridge as findProviderForModel, runtimeCapabilities } from "./runtime/registry.js";