@mono-agent/agent-runtime 0.18.0 → 0.18.2

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.
@@ -20,10 +20,75 @@
20
20
  * @property {string} [provider] Pi/OpenCode provider id when sdk === "pi" | "opencode".
21
21
  */
22
22
  /**
23
- * @typedef {{type: string, [key: string]: *}} RuntimeEvent
24
- * Structured runtime/telemetry event. `type` is the only required field;
25
- * every event kind (tool_approval_pending, provider_failover_started,
26
- * context_compaction_applied, ...) adds its own extra fields.
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
  /**
@@ -136,12 +201,26 @@
136
201
  * @property {RuntimePromptOverrides} [prompts] Per-run prompt-fragment overrides (run wins over the host default).
137
202
  * @property {import('./providers/acp-client.js').AcpClientHostOptions["resolveAcpProfile"]} [resolveAcpProfile] Per-run ACP profile resolver; wins over the host default.
138
203
  * @property {import('./providers/acp-client.js').AcpClientHostOptions["onAcpInteractionRequest"]} [onAcpInteractionRequest] Per-run ACP permission/elicitation callback; wins over the host default.
204
+ * @property {Uint8Array} [acpSessionTokenKey] Host-owned 32-byte key for confidential authenticated ACP session handles. Required for every ACP task run.
139
205
  * @property {{backend?: "auto"|"searxng"|"keyless", endpoint?: string}} [webSearchConfig] Run-scoped WebSearch backend configuration.
140
206
  * @property {{render?: "never"|"auto", browserCommand?: string}} [webFetchConfig] Run-scoped WebFetch extraction/render configuration.
141
207
  * @property {"sequential"|"safe-parallel"} [piToolExecutionMode] Pi built-in tool scheduling mode. Safe parallelism is the default.
142
208
  * @property {"one-at-a-time"|"all"} [piToolParallelismMode] DEPRECATED. Compatibility alias mapped to piToolExecutionMode.
143
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).
144
- * @property {Object} [nativeSubagents] Same-runtime teammate helpers exposed through native provider subagent surfaces.
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.
145
224
  * @property {RuntimeSubagentsOptions} [subagents] In-process `Agent` built-in: profiles, caps, and the nested-run callback.
146
225
  * @property {Object} [diagnosticsSeed] Set by createRouterRuntime (ai/runtime/router.js) with a `resume_snapshot` when
147
226
  * failing over mid-chain; a host-level coordinator may relay it forward (see agent/transcript.js), not read by any
@@ -152,7 +231,7 @@
152
231
  */
153
232
  /**
154
233
  * @typedef {RuntimeRunOptions
155
- * & Pick<AgentRuntimeHostOptions, "resolveCustomPricing" | "resolvePiApiKey" | "resolveAcpProfile" | "onAcpInteractionRequest" | "persistArtifact" | "onCompactionRecorded" | "onToolApprovalRequest" | "toolRiskTiers" | "approvalDefaultRiskTier" | "approvalTimeoutMs" | "approvalAlwaysAllowTools">
234
+ * & Pick<AgentRuntimeHostOptions, "resolveCustomPricing" | "resolvePiApiKey" | "resolveAcpProfile" | "onAcpInteractionRequest" | "acpSessionTokenKey" | "persistArtifact" | "onCompactionRecorded" | "onToolApprovalRequest" | "toolRiskTiers" | "approvalDefaultRiskTier" | "approvalTimeoutMs" | "approvalAlwaysAllowTools">
156
235
  * & {runtimeBrand: import('../runtime-brand.js').RuntimeBrand, toolContext?: import('../agent/tools/shared/tool-context.js').ToolContext, observerHub: {emit: (event: RuntimeEvent) => void, flush: () => Promise<void>}}
157
236
  * } RuntimeRequest
158
237
  * The request shape a bridge's `execute(systemPrompt, req)` receives as its
@@ -188,11 +267,14 @@
188
267
  */
189
268
  /**
190
269
  * @typedef {Object} RuntimeInlineSubagentsOptions
191
- * Policy for subagents the model authors at call time rather than picking from
192
- * `definitions`. Absent suppresses authoring entirely.
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.
193
273
  * @property {boolean} [enabled] Only `false` turns authoring off.
194
- * @property {ReadonlyArray<string>} [allowedTools] Ceiling on what an authored subagent may
195
- * request. Absent means the safe read-only default set, never every built-in.
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.
196
278
  */
197
279
  /**
198
280
  * @typedef {Object} RuntimeSubagentsOptions
@@ -245,7 +327,9 @@
245
327
  * @property {boolean} [supports_skills]
246
328
  * @property {boolean} [supports_builtin_tools]
247
329
  * @property {boolean} [supports_live_input]
248
- * @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.
249
333
  * @property {boolean} [supports_request_tool_environment]
250
334
  * @property {boolean} [supports_fast_mode]
251
335
  * @property {"projected"|"allow_all_only"} [tool_policy] Whether the bridge can
@@ -322,6 +406,7 @@
322
406
  * @property {import('../pi-auth.js').PiApiKeyResolver} [resolvePiApiKey] See createPiOAuthApiKeyResolver (pi-auth.js) for a ready-made implementation.
323
407
  * @property {import('./providers/acp-client.js').AcpClientHostOptions["resolveAcpProfile"]} [resolveAcpProfile] Default ACP profile resolver; a per-run callback wins.
324
408
  * @property {import('./providers/acp-client.js').AcpClientHostOptions["onAcpInteractionRequest"]} [onAcpInteractionRequest] Default ACP interaction callback; a per-run callback wins.
409
+ * @property {Uint8Array} [acpSessionTokenKey] Default host-owned 32-byte key for confidential authenticated ACP session handles.
325
410
  * @property {(artifact: {filename: string, buffer: Buffer, toolName: string, toolUseId: (string|null)}) => (string|null)} [persistArtifact]
326
411
  * @property {(record: CompactionRecordedPayload) => void} [onCompactionRecorded]
327
412
  * @property {(payload: ApprovalRequestPayload) => Promise<ApprovalDecision>} [onToolApprovalRequest]
@@ -388,11 +473,112 @@ export type RuntimeModelRef = {
388
473
  provider?: string;
389
474
  };
390
475
  /**
391
- * Structured runtime/telemetry event. `type` is the only required field;
392
- * every event kind (tool_approval_pending, provider_failover_started,
393
- * context_compaction_applied, ...) adds its own extra fields.
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.
394
498
  */
395
- export type RuntimeEvent = {
499
+ export type RuntimeNativeSubagentsOptions = {
500
+ provider: "claude";
501
+ teammates: ReadonlyArray<RuntimeNativeSubagentDefinition>;
502
+ };
503
+ /**
504
+ * Provider-neutral identity attached to every `subagent_activity` event.
505
+ */
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 | {
396
582
  type: string;
397
583
  [key: string]: any;
398
584
  };
@@ -642,6 +828,10 @@ export type RuntimeRunOptions = {
642
828
  * Per-run ACP permission/elicitation callback; wins over the host default.
643
829
  */
644
830
  onAcpInteractionRequest?: import("./providers/acp-client.js").AcpClientHostOptions["onAcpInteractionRequest"];
831
+ /**
832
+ * Host-owned 32-byte key for confidential authenticated ACP session handles. Required for every ACP task run.
833
+ */
834
+ acpSessionTokenKey?: Uint8Array;
645
835
  /**
646
836
  * Run-scoped WebSearch backend configuration.
647
837
  */
@@ -669,9 +859,28 @@ export type RuntimeRunOptions = {
669
859
  */
670
860
  settings?: any;
671
861
  /**
672
- * Same-runtime teammate helpers exposed through native provider subagent surfaces.
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.
673
870
  */
674
- nativeSubagents?: any;
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.
876
+ */
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;
675
884
  /**
676
885
  * In-process `Agent` built-in: profiles, caps, and the nested-run callback.
677
886
  */
@@ -698,7 +907,7 @@ export type RuntimeRunOptions = {
698
907
  * createRuntime), and the per-run observerHub (onEvent is overridden to the
699
908
  * hub's emit). `systemPrompt` is passed positionally, not folded into this object.
700
909
  */
701
- export type RuntimeRequest = RuntimeRunOptions & Pick<AgentRuntimeHostOptions, "resolveCustomPricing" | "resolvePiApiKey" | "resolveAcpProfile" | "onAcpInteractionRequest" | "persistArtifact" | "onCompactionRecorded" | "onToolApprovalRequest" | "toolRiskTiers" | "approvalDefaultRiskTier" | "approvalTimeoutMs" | "approvalAlwaysAllowTools"> & {
910
+ export type RuntimeRequest = RuntimeRunOptions & Pick<AgentRuntimeHostOptions, "resolveCustomPricing" | "resolvePiApiKey" | "resolveAcpProfile" | "onAcpInteractionRequest" | "acpSessionTokenKey" | "persistArtifact" | "onCompactionRecorded" | "onToolApprovalRequest" | "toolRiskTiers" | "approvalDefaultRiskTier" | "approvalTimeoutMs" | "approvalAlwaysAllowTools"> & {
702
911
  runtimeBrand: import("../runtime-brand.js").RuntimeBrand;
703
912
  toolContext?: import("../agent/tools/shared/tool-context.js").ToolContext;
704
913
  observerHub: {
@@ -746,8 +955,9 @@ export type RuntimeSubagentDefinition = {
746
955
  */
747
956
  export type RuntimeSubagentRun = (request: any) => Promise<RuntimeResult>;
748
957
  /**
749
- * Policy for subagents the model authors at call time rather than picking from
750
- * `definitions`. Absent suppresses authoring entirely.
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.
751
961
  */
752
962
  export type RuntimeInlineSubagentsOptions = {
753
963
  /**
@@ -755,8 +965,10 @@ export type RuntimeInlineSubagentsOptions = {
755
965
  */
756
966
  enabled?: boolean;
757
967
  /**
758
- * Ceiling on what an authored subagent may
759
- * request. Absent means the safe read-only default set, never every built-in.
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.
760
972
  */
761
973
  allowedTools?: ReadonlyArray<string>;
762
974
  };
@@ -858,6 +1070,11 @@ export type RuntimeCapabilities = {
858
1070
  supports_skills?: boolean;
859
1071
  supports_builtin_tools?: boolean;
860
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
+ */
861
1078
  supports_native_subagents?: boolean;
862
1079
  supports_request_tool_environment?: boolean;
863
1080
  supports_fast_mode?: boolean;
@@ -975,6 +1192,10 @@ export type AgentRuntimeHostOptions = {
975
1192
  * Default ACP interaction callback; a per-run callback wins.
976
1193
  */
977
1194
  onAcpInteractionRequest?: import("./providers/acp-client.js").AcpClientHostOptions["onAcpInteractionRequest"];
1195
+ /**
1196
+ * Default host-owned 32-byte key for confidential authenticated ACP session handles.
1197
+ */
1198
+ acpSessionTokenKey?: Uint8Array;
978
1199
  persistArtifact?: (artifact: {
979
1200
  filename: string;
980
1201
  buffer: Buffer;