@mono-agent/agent-runtime 0.18.1 → 0.18.3
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 +32 -0
- package/README.md +50 -0
- package/package.json +1 -1
- package/src/agent/tools/agent-tool.js +16 -4
- package/src/agent/tools/web-controller.js +97 -7
- package/src/agent/tools/web-search.js +296 -60
- package/src/ai/providers/claude-cli.js +77 -22
- package/src/ai/providers/claude-sdk.js +54 -11
- package/src/ai/providers/claude-subagent-activity.js +719 -0
- package/src/ai/providers/codex-app.js +1039 -105
- package/src/ai/providers/pi-native/result-builder.js +11 -0
- package/src/ai/providers/pi-native.js +22 -2
- package/src/ai/providers/transport-errors.js +154 -0
- package/src/ai/runtime/router.js +42 -0
- package/src/ai/types.js +98 -10
- package/types/agent/tools/web-controller.d.ts +5 -1
- package/types/agent/tools/web-search.d.ts +13 -0
- package/types/ai/providers/claude-subagent-activity.d.ts +53 -0
- package/types/ai/providers/transport-errors.d.ts +44 -0
- package/types/ai/runtime/router.d.ts +9 -0
- package/types/ai/types.d.ts +231 -20
package/types/ai/types.d.ts
CHANGED
|
@@ -20,10 +20,75 @@
|
|
|
20
20
|
* @property {string} [provider] Pi/OpenCode provider id when sdk === "pi" | "opencode".
|
|
21
21
|
*/
|
|
22
22
|
/**
|
|
23
|
-
* @typedef {
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
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
|
+
*/
|
|
38
|
+
/**
|
|
39
|
+
* @typedef {Object} RuntimeNativeSubagentsOptions
|
|
40
|
+
* Caller-defined native profiles are supported only by the Claude bridges.
|
|
41
|
+
* Codex owns its collaboration agents; use `codexLoadProjectDocs` when those
|
|
42
|
+
* agents should receive repository instructions.
|
|
43
|
+
* @property {"claude"} provider
|
|
44
|
+
* @property {ReadonlyArray<RuntimeNativeSubagentDefinition>} teammates
|
|
45
|
+
*/
|
|
46
|
+
/**
|
|
47
|
+
* @typedef {Object} RuntimeSubagentIdentity
|
|
48
|
+
* Provider-neutral identity attached to every `subagent_activity` event.
|
|
49
|
+
* @property {string} id The canonical parent attachment key: the initiating
|
|
50
|
+
* parent tool-use id when the provider exposes it, or a stable synthetic key
|
|
51
|
+
* for an orphan lifecycle record. A provider-native task/thread id never replaces it.
|
|
52
|
+
* @property {string} [nativeId] Provider-native task or thread id, retained only
|
|
53
|
+
* as diagnostic/correlation metadata.
|
|
54
|
+
* @property {string} name Provider-neutral profile/agent name.
|
|
55
|
+
* @property {number} callIndex Provider call-order ordinal; consumers must not
|
|
56
|
+
* use it as an identity key.
|
|
57
|
+
* @property {string} [label] Short task label or description.
|
|
58
|
+
* @property {string} [agentPath] Provider-reported ancestry for a
|
|
59
|
+
* nested native agent. Informational only; `id` remains the attachment key.
|
|
60
|
+
* @property {number} [costUsd] Priced delegation cost, when the runtime can
|
|
61
|
+
* attribute it to this subagent.
|
|
62
|
+
*/
|
|
63
|
+
/**
|
|
64
|
+
* @typedef {"agent_started"|"started"|"completed"|"message"|"agent_completed"} RuntimeSubagentActivityPhase
|
|
65
|
+
* `agent_started`/`agent_completed` bracket the delegation; `started`/`completed`
|
|
66
|
+
* bracket one child tool call; `message` carries optional child-only prose or
|
|
67
|
+
* thinking and must never be treated as parent answer text or a completed tool.
|
|
68
|
+
*/
|
|
69
|
+
/**
|
|
70
|
+
* @typedef {Object} RuntimeSubagentActivityEvent
|
|
71
|
+
* One normalized native or in-process subagent activity event.
|
|
72
|
+
* @property {"subagent_activity"} type
|
|
73
|
+
* @property {RuntimeSubagentIdentity} subagent
|
|
74
|
+
* @property {RuntimeSubagentActivityPhase} phase
|
|
75
|
+
* @property {string} id Unique activity-row id, namespaced from the canonical
|
|
76
|
+
* `subagent.id` for lifecycle and tool rows.
|
|
77
|
+
* @property {string} [name]
|
|
78
|
+
* @property {*} [arguments]
|
|
79
|
+
* @property {*} [content]
|
|
80
|
+
* @property {"text"|"thinking"|"status"|"warning"|"error"} [kind] Present on a
|
|
81
|
+
* `message` phase when known.
|
|
82
|
+
* @property {"assistant"|"user"} [role] Present on a `message` phase when known.
|
|
83
|
+
* @property {boolean} [isError]
|
|
84
|
+
* @property {number} [executionMs]
|
|
85
|
+
* @property {number} [totalTokens]
|
|
86
|
+
*/
|
|
87
|
+
/**
|
|
88
|
+
* @typedef {RuntimeSubagentActivityEvent | {type: string, [key: string]: *}} RuntimeEvent
|
|
89
|
+
* Structured runtime/telemetry event. Subagent activity uses the normalized
|
|
90
|
+
* shape above; every other event kind (tool_approval_pending,
|
|
91
|
+
* provider_failover_started, context_compaction, ...) adds its own fields.
|
|
27
92
|
*/
|
|
28
93
|
/** @typedef {"uniform"|"per-route-native"} RuntimeRouteSafetyMode */
|
|
29
94
|
/**
|
|
@@ -142,7 +207,20 @@
|
|
|
142
207
|
* @property {"sequential"|"safe-parallel"} [piToolExecutionMode] Pi built-in tool scheduling mode. Safe parallelism is the default.
|
|
143
208
|
* @property {"one-at-a-time"|"all"} [piToolParallelismMode] DEPRECATED. Compatibility alias mapped to piToolExecutionMode.
|
|
144
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).
|
|
145
|
-
* @property {
|
|
210
|
+
* @property {ReadonlyArray<"user" | "project" | "local">} [settingSources] Claude Agent SDK only. Filesystem
|
|
211
|
+
* settings the SDK may load for this run. Omitted/empty disables user, project, and local sources, including their
|
|
212
|
+
* CLAUDE.md, hooks, plugins, and on-disk agent profiles. Anthropic managed settings remain in force and may still
|
|
213
|
+
* configure hooks or plugins; this option is not a managed-policy bypass. Each opted-in source may execute configured
|
|
214
|
+
* hooks and plugins, so enable only trusted settings and avoid these sources in an untrusted checkout. Include
|
|
215
|
+
* `"project"`/`"user"` to let the native `Task` tool discover `.claude/agents` definitions. Unrecognized entries are
|
|
216
|
+
* dropped. The Claude Code CLI bridge does not take this option: that binary performs its own settings discovery and
|
|
217
|
+
* mono-agent passes no `--setting-sources`, so a CLI run already reads the host config regardless of this value.
|
|
218
|
+
* @property {boolean} [codexLoadProjectDocs] Codex app-server only. Omitted/false starts the managed app-server with
|
|
219
|
+
* `project_doc_max_bytes=0`, preventing automatic repository-instruction discovery. True restores Codex's native
|
|
220
|
+
* project-doc loading defaults. An explicit `codexAppServerArgs` array wins over this convenience option.
|
|
221
|
+
* @property {RuntimeNativeSubagentsOptions} [nativeSubagents] Caller-defined Claude native `Task` profiles. Direct
|
|
222
|
+
* Codex owns its collaboration agents and rejects configured teammate definitions; `codexLoadProjectDocs` controls
|
|
223
|
+
* whether Codex loads repository instructions for its own agents.
|
|
146
224
|
* @property {RuntimeSubagentsOptions} [subagents] In-process `Agent` built-in: profiles, caps, and the nested-run callback.
|
|
147
225
|
* @property {Object} [diagnosticsSeed] Set by createRouterRuntime (ai/runtime/router.js) with a `resume_snapshot` when
|
|
148
226
|
* failing over mid-chain; a host-level coordinator may relay it forward (see agent/transcript.js), not read by any
|
|
@@ -189,11 +267,14 @@
|
|
|
189
267
|
*/
|
|
190
268
|
/**
|
|
191
269
|
* @typedef {Object} RuntimeInlineSubagentsOptions
|
|
192
|
-
* Policy for
|
|
193
|
-
* `definitions`. Absent
|
|
270
|
+
* Policy for the runtime-owned general-purpose helper and subagents the model
|
|
271
|
+
* authors at call time rather than picking from `definitions`. Absent
|
|
272
|
+
* suppresses authoring entirely and leaves general-purpose on its safe default.
|
|
194
273
|
* @property {boolean} [enabled] Only `false` turns authoring off.
|
|
195
|
-
* @property {ReadonlyArray<string>} [allowedTools] Ceiling on
|
|
196
|
-
*
|
|
274
|
+
* @property {ReadonlyArray<string>} [allowedTools] Ceiling on general-purpose's
|
|
275
|
+
* read-only tools and what an authored subagent may request. Configured
|
|
276
|
+
* definitions keep their explicit contracts. Absent means the safe read-only
|
|
277
|
+
* default set, never every built-in.
|
|
197
278
|
*/
|
|
198
279
|
/**
|
|
199
280
|
* @typedef {Object} RuntimeSubagentsOptions
|
|
@@ -246,7 +327,9 @@
|
|
|
246
327
|
* @property {boolean} [supports_skills]
|
|
247
328
|
* @property {boolean} [supports_builtin_tools]
|
|
248
329
|
* @property {boolean} [supports_live_input]
|
|
249
|
-
* @property {boolean} [supports_native_subagents]
|
|
330
|
+
* @property {boolean} [supports_native_subagents] Whether the bridge exposes provider-native subagent surfaces and
|
|
331
|
+
* normalized activity. This does not imply it accepts caller-defined `nativeSubagents`: Codex owns its collaboration
|
|
332
|
+
* agents, while only the Claude bridges project caller-defined profiles.
|
|
250
333
|
* @property {boolean} [supports_request_tool_environment]
|
|
251
334
|
* @property {boolean} [supports_fast_mode]
|
|
252
335
|
* @property {"projected"|"allow_all_only"} [tool_policy] Whether the bridge can
|
|
@@ -390,11 +473,112 @@ export type RuntimeModelRef = {
|
|
|
390
473
|
provider?: string;
|
|
391
474
|
};
|
|
392
475
|
/**
|
|
393
|
-
*
|
|
394
|
-
*
|
|
395
|
-
|
|
476
|
+
* One caller-defined Claude native `Task` profile. Codex collaboration-agent
|
|
477
|
+
* definitions are owned by Codex and are not represented by this type.
|
|
478
|
+
*/
|
|
479
|
+
export type RuntimeNativeSubagentDefinition = {
|
|
480
|
+
name: string;
|
|
481
|
+
displayName?: string;
|
|
482
|
+
description?: string;
|
|
483
|
+
helperSystemPrompt?: string;
|
|
484
|
+
instructions?: string;
|
|
485
|
+
allowedTools?: ReadonlyArray<string>;
|
|
486
|
+
disallowedTools?: ReadonlyArray<string>;
|
|
487
|
+
modelRef?: string | RuntimeModelRef;
|
|
488
|
+
model?: RuntimeModelRef;
|
|
489
|
+
effort?: string;
|
|
490
|
+
mcpServers?: {
|
|
491
|
+
[x: string]: any;
|
|
492
|
+
};
|
|
493
|
+
};
|
|
494
|
+
/**
|
|
495
|
+
* Caller-defined native profiles are supported only by the Claude bridges.
|
|
496
|
+
* Codex owns its collaboration agents; use `codexLoadProjectDocs` when those
|
|
497
|
+
* agents should receive repository instructions.
|
|
498
|
+
*/
|
|
499
|
+
export type RuntimeNativeSubagentsOptions = {
|
|
500
|
+
provider: "claude";
|
|
501
|
+
teammates: ReadonlyArray<RuntimeNativeSubagentDefinition>;
|
|
502
|
+
};
|
|
503
|
+
/**
|
|
504
|
+
* Provider-neutral identity attached to every `subagent_activity` event.
|
|
396
505
|
*/
|
|
397
|
-
export type
|
|
506
|
+
export type RuntimeSubagentIdentity = {
|
|
507
|
+
/**
|
|
508
|
+
* The canonical parent attachment key: the initiating
|
|
509
|
+
* parent tool-use id when the provider exposes it, or a stable synthetic key
|
|
510
|
+
* for an orphan lifecycle record. A provider-native task/thread id never replaces it.
|
|
511
|
+
*/
|
|
512
|
+
id: string;
|
|
513
|
+
/**
|
|
514
|
+
* Provider-native task or thread id, retained only
|
|
515
|
+
* as diagnostic/correlation metadata.
|
|
516
|
+
*/
|
|
517
|
+
nativeId?: string;
|
|
518
|
+
/**
|
|
519
|
+
* Provider-neutral profile/agent name.
|
|
520
|
+
*/
|
|
521
|
+
name: string;
|
|
522
|
+
/**
|
|
523
|
+
* Provider call-order ordinal; consumers must not
|
|
524
|
+
* use it as an identity key.
|
|
525
|
+
*/
|
|
526
|
+
callIndex: number;
|
|
527
|
+
/**
|
|
528
|
+
* Short task label or description.
|
|
529
|
+
*/
|
|
530
|
+
label?: string;
|
|
531
|
+
/**
|
|
532
|
+
* Provider-reported ancestry for a
|
|
533
|
+
* nested native agent. Informational only; `id` remains the attachment key.
|
|
534
|
+
*/
|
|
535
|
+
agentPath?: string;
|
|
536
|
+
/**
|
|
537
|
+
* Priced delegation cost, when the runtime can
|
|
538
|
+
* attribute it to this subagent.
|
|
539
|
+
*/
|
|
540
|
+
costUsd?: number;
|
|
541
|
+
};
|
|
542
|
+
/**
|
|
543
|
+
* `agent_started`/`agent_completed` bracket the delegation; `started`/`completed`
|
|
544
|
+
* bracket one child tool call; `message` carries optional child-only prose or
|
|
545
|
+
* thinking and must never be treated as parent answer text or a completed tool.
|
|
546
|
+
*/
|
|
547
|
+
export type RuntimeSubagentActivityPhase = "agent_started" | "started" | "completed" | "message" | "agent_completed";
|
|
548
|
+
/**
|
|
549
|
+
* One normalized native or in-process subagent activity event.
|
|
550
|
+
*/
|
|
551
|
+
export type RuntimeSubagentActivityEvent = {
|
|
552
|
+
type: "subagent_activity";
|
|
553
|
+
subagent: RuntimeSubagentIdentity;
|
|
554
|
+
phase: RuntimeSubagentActivityPhase;
|
|
555
|
+
/**
|
|
556
|
+
* Unique activity-row id, namespaced from the canonical
|
|
557
|
+
* `subagent.id` for lifecycle and tool rows.
|
|
558
|
+
*/
|
|
559
|
+
id: string;
|
|
560
|
+
name?: string;
|
|
561
|
+
arguments?: any;
|
|
562
|
+
content?: any;
|
|
563
|
+
/**
|
|
564
|
+
* Present on a
|
|
565
|
+
* `message` phase when known.
|
|
566
|
+
*/
|
|
567
|
+
kind?: "text" | "thinking" | "status" | "warning" | "error";
|
|
568
|
+
/**
|
|
569
|
+
* Present on a `message` phase when known.
|
|
570
|
+
*/
|
|
571
|
+
role?: "assistant" | "user";
|
|
572
|
+
isError?: boolean;
|
|
573
|
+
executionMs?: number;
|
|
574
|
+
totalTokens?: number;
|
|
575
|
+
};
|
|
576
|
+
/**
|
|
577
|
+
* Structured runtime/telemetry event. Subagent activity uses the normalized
|
|
578
|
+
* shape above; every other event kind (tool_approval_pending,
|
|
579
|
+
* provider_failover_started, context_compaction, ...) adds its own fields.
|
|
580
|
+
*/
|
|
581
|
+
export type RuntimeEvent = RuntimeSubagentActivityEvent | {
|
|
398
582
|
type: string;
|
|
399
583
|
[key: string]: any;
|
|
400
584
|
};
|
|
@@ -675,9 +859,28 @@ export type RuntimeRunOptions = {
|
|
|
675
859
|
*/
|
|
676
860
|
settings?: any;
|
|
677
861
|
/**
|
|
678
|
-
*
|
|
862
|
+
* Claude Agent SDK only. Filesystem
|
|
863
|
+
* settings the SDK may load for this run. Omitted/empty disables user, project, and local sources, including their
|
|
864
|
+
* CLAUDE.md, hooks, plugins, and on-disk agent profiles. Anthropic managed settings remain in force and may still
|
|
865
|
+
* configure hooks or plugins; this option is not a managed-policy bypass. Each opted-in source may execute configured
|
|
866
|
+
* hooks and plugins, so enable only trusted settings and avoid these sources in an untrusted checkout. Include
|
|
867
|
+
* `"project"`/`"user"` to let the native `Task` tool discover `.claude/agents` definitions. Unrecognized entries are
|
|
868
|
+
* dropped. The Claude Code CLI bridge does not take this option: that binary performs its own settings discovery and
|
|
869
|
+
* mono-agent passes no `--setting-sources`, so a CLI run already reads the host config regardless of this value.
|
|
870
|
+
*/
|
|
871
|
+
settingSources?: ReadonlyArray<"user" | "project" | "local">;
|
|
872
|
+
/**
|
|
873
|
+
* Codex app-server only. Omitted/false starts the managed app-server with
|
|
874
|
+
* `project_doc_max_bytes=0`, preventing automatic repository-instruction discovery. True restores Codex's native
|
|
875
|
+
* project-doc loading defaults. An explicit `codexAppServerArgs` array wins over this convenience option.
|
|
679
876
|
*/
|
|
680
|
-
|
|
877
|
+
codexLoadProjectDocs?: boolean;
|
|
878
|
+
/**
|
|
879
|
+
* Caller-defined Claude native `Task` profiles. Direct
|
|
880
|
+
* Codex owns its collaboration agents and rejects configured teammate definitions; `codexLoadProjectDocs` controls
|
|
881
|
+
* whether Codex loads repository instructions for its own agents.
|
|
882
|
+
*/
|
|
883
|
+
nativeSubagents?: RuntimeNativeSubagentsOptions;
|
|
681
884
|
/**
|
|
682
885
|
* In-process `Agent` built-in: profiles, caps, and the nested-run callback.
|
|
683
886
|
*/
|
|
@@ -752,8 +955,9 @@ export type RuntimeSubagentDefinition = {
|
|
|
752
955
|
*/
|
|
753
956
|
export type RuntimeSubagentRun = (request: any) => Promise<RuntimeResult>;
|
|
754
957
|
/**
|
|
755
|
-
* Policy for
|
|
756
|
-
* `definitions`. Absent
|
|
958
|
+
* Policy for the runtime-owned general-purpose helper and subagents the model
|
|
959
|
+
* authors at call time rather than picking from `definitions`. Absent
|
|
960
|
+
* suppresses authoring entirely and leaves general-purpose on its safe default.
|
|
757
961
|
*/
|
|
758
962
|
export type RuntimeInlineSubagentsOptions = {
|
|
759
963
|
/**
|
|
@@ -761,8 +965,10 @@ export type RuntimeInlineSubagentsOptions = {
|
|
|
761
965
|
*/
|
|
762
966
|
enabled?: boolean;
|
|
763
967
|
/**
|
|
764
|
-
* Ceiling on
|
|
765
|
-
*
|
|
968
|
+
* Ceiling on general-purpose's
|
|
969
|
+
* read-only tools and what an authored subagent may request. Configured
|
|
970
|
+
* definitions keep their explicit contracts. Absent means the safe read-only
|
|
971
|
+
* default set, never every built-in.
|
|
766
972
|
*/
|
|
767
973
|
allowedTools?: ReadonlyArray<string>;
|
|
768
974
|
};
|
|
@@ -864,6 +1070,11 @@ export type RuntimeCapabilities = {
|
|
|
864
1070
|
supports_skills?: boolean;
|
|
865
1071
|
supports_builtin_tools?: boolean;
|
|
866
1072
|
supports_live_input?: boolean;
|
|
1073
|
+
/**
|
|
1074
|
+
* Whether the bridge exposes provider-native subagent surfaces and
|
|
1075
|
+
* normalized activity. This does not imply it accepts caller-defined `nativeSubagents`: Codex owns its collaboration
|
|
1076
|
+
* agents, while only the Claude bridges project caller-defined profiles.
|
|
1077
|
+
*/
|
|
867
1078
|
supports_native_subagents?: boolean;
|
|
868
1079
|
supports_request_tool_environment?: boolean;
|
|
869
1080
|
supports_fast_mode?: boolean;
|