@automatalabs/acp-agents 1.2.7 → 1.3.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 (66) hide show
  1. package/README.md +67 -3
  2. package/dist/acp-client.d.ts +21 -1
  3. package/dist/acp-client.d.ts.map +1 -1
  4. package/dist/acp-client.js +29 -5
  5. package/dist/agent/acp-agent.d.ts +141 -0
  6. package/dist/agent/acp-agent.d.ts.map +1 -0
  7. package/dist/agent/acp-agent.js +832 -0
  8. package/dist/agent/errors.d.ts +17 -0
  9. package/dist/agent/errors.d.ts.map +1 -0
  10. package/dist/agent/errors.js +37 -0
  11. package/dist/agent/events.d.ts +26 -0
  12. package/dist/agent/events.d.ts.map +1 -0
  13. package/dist/agent/events.js +165 -0
  14. package/dist/agent/fork.d.ts +27 -0
  15. package/dist/agent/fork.d.ts.map +1 -0
  16. package/dist/agent/fork.js +28 -0
  17. package/dist/agent/probe.d.ts +14 -0
  18. package/dist/agent/probe.d.ts.map +1 -0
  19. package/dist/agent/probe.js +87 -0
  20. package/dist/agent/process-registry.d.ts +9 -0
  21. package/dist/agent/process-registry.d.ts.map +1 -0
  22. package/dist/agent/process-registry.js +28 -0
  23. package/dist/agent/queue.d.ts +19 -0
  24. package/dist/agent/queue.d.ts.map +1 -0
  25. package/dist/agent/queue.js +90 -0
  26. package/dist/agent/routing.d.ts +27 -0
  27. package/dist/agent/routing.d.ts.map +1 -0
  28. package/dist/agent/routing.js +87 -0
  29. package/dist/agent/structured.d.ts +47 -0
  30. package/dist/agent/structured.d.ts.map +1 -0
  31. package/dist/agent/structured.js +90 -0
  32. package/dist/agent/turn.d.ts +65 -0
  33. package/dist/agent/turn.d.ts.map +1 -0
  34. package/dist/agent/turn.js +187 -0
  35. package/dist/agent/types.d.ts +221 -0
  36. package/dist/agent/types.d.ts.map +1 -0
  37. package/dist/agent/types.js +9 -0
  38. package/dist/backend.d.ts +6 -0
  39. package/dist/backend.d.ts.map +1 -1
  40. package/dist/backends/claude.d.ts +1 -0
  41. package/dist/backends/claude.d.ts.map +1 -1
  42. package/dist/backends/claude.js +5 -0
  43. package/dist/config-catalog.d.ts +173 -0
  44. package/dist/config-catalog.d.ts.map +1 -0
  45. package/dist/config-catalog.js +408 -0
  46. package/dist/index.d.ts +10 -3
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +10 -1
  49. package/dist/protocol-coverage.d.ts +56 -0
  50. package/dist/protocol-coverage.d.ts.map +1 -1
  51. package/dist/protocol-coverage.js +52 -0
  52. package/dist/registry.d.ts +12 -0
  53. package/dist/registry.d.ts.map +1 -1
  54. package/dist/registry.js +22 -0
  55. package/dist/routing.d.ts +14 -0
  56. package/dist/routing.d.ts.map +1 -0
  57. package/dist/routing.js +53 -0
  58. package/dist/runner.d.ts.map +1 -1
  59. package/dist/runner.js +3 -64
  60. package/dist/session-ref.d.ts +8 -0
  61. package/dist/session-ref.d.ts.map +1 -0
  62. package/dist/session-ref.js +21 -0
  63. package/dist/structured-tool.d.ts +4 -0
  64. package/dist/structured-tool.d.ts.map +1 -1
  65. package/dist/structured-tool.js +5 -0
  66. package/package.json +3 -3
@@ -0,0 +1,221 @@
1
+ import type { PromptResponse, SessionConfigOption, SessionModeState, StopReason, ToolCallContent, ToolCallLocation, ToolCallStatus, ToolKind, Usage } from "@agentclientprotocol/sdk";
2
+ import type { AgentHistoryEntry, AgentUsage, McpServerConfig, PromptImage, WorkflowError } from "@automatalabs/shared-types";
3
+ import type { TSchema } from "typebox";
4
+ import type { AuthStore } from "../auth/auth-store.js";
5
+ import type { ClientHandlers } from "../client-handlers.js";
6
+ import type { HarnessConfigReport, HarnessModelsView } from "../config-catalog.js";
7
+ import type { AcpElicitationEvent, AcpPermissionEvent, AcpRunnerEventMap, AcpSessionUpdate } from "../events.js";
8
+ import type { ElicitationResolver, PermissionResolver, ToolPolicy } from "../permissions.js";
9
+ import type { ProviderStore } from "../provider-store.js";
10
+ import type { CustomBackendConfig } from "../registry.js";
11
+ export type { SessionConfigOption, SessionModeState };
12
+ export interface AcpAgentOptions {
13
+ /** ABSOLUTE path that exists and is a directory. Validated synchronously in the constructor and
14
+ * the statics BEFORE any process spawns (SCRIPT_VALIDATION_ERROR otherwise). Sent as the
15
+ * session/new|fork|resume|load `cwd`. */
16
+ cwd: string;
17
+ /** Model routing spec with the runner's grammar (`resolveModelRoute`): the first `/`-segment
18
+ * routes to a registered custom backend (wins) or a built-in; the remainder is the backend's
19
+ * model id VERBATIM and is sent as `session/set_config_option { configId: "model" }` right after
20
+ * the session opens. An unrouted spec (no known first segment) goes WHOLE to the default backend
21
+ * (`AGENTPRISM_DEFAULT_BACKEND`, else `claude`). Omitted = default backend, no model selection. */
22
+ model?: string;
23
+ /** Session mode. Explicit ids are strict (unadvertised → SCRIPT_VALIDATION_ERROR at open).
24
+ * Omitted = the backend's `defaultModeId` when advertised (claude `auto`, codex `agent`,
25
+ * opencode `build`; pi/custom none). */
26
+ mode?: string;
27
+ /** Applied verbatim via `session/set_config_option` in ascending option-id order after model
28
+ * selection. `"model"` is reserved (SCRIPT_VALIDATION_ERROR in the constructor). Ids not in the
29
+ * advertised catalog fail at open with SCRIPT_VALIDATION_ERROR listing the advertised ids. */
30
+ configOptions?: Record<string, string | boolean>;
31
+ /** Session-level structured-output contract (typebox). Claude: `_meta.claudeCode.options.outputFormat`
32
+ * at session/new|resume|load|fork; Codex: `_meta.outputSchema` on every turn; OpenCode/pi/custom:
33
+ * the client-hosted `StructuredOutput` HTTP MCP tool injected into `mcpServers` when the agent
34
+ * advertises `mcpCapabilities.http`, plus the in-prompt contract. Each turn reports
35
+ * `structured` / `structuredError`; there is no repair ladder. */
36
+ schema?: TSchema;
37
+ /** Client-provided MCP servers (stdio/http/sse/acp). Capability-gated by the connection exactly
38
+ * like the runner. */
39
+ mcpServers?: McpServerConfig[];
40
+ /** Headless permission auto-policy: allow/deny lists + `defaultOutcome` (default "allow"). */
41
+ tools?: ToolPolicy;
42
+ /** Session-scoped async permission resolver; wins over `tools` unless the request matches an
43
+ * explicit list (same precedence as the runner: resolver > policy). */
44
+ onPermissionRequest?: PermissionResolver;
45
+ /** Elicitation responder; its presence is what advertises `elicitation` at initialize. */
46
+ onElicitation?: ElicitationResolver;
47
+ /** Generic session/new `_meta` passthrough. Layered UNDER backend-computed keys (shallow, like
48
+ * the runner) and, when `raw !== false`, OVER `backend.rawMessagesMeta()`. */
49
+ meta?: Record<string, unknown>;
50
+ /** Codex-only session instructions → bare `_meta.baseInstructions` / `_meta.developerInstructions`. */
51
+ instructions?: {
52
+ base?: string;
53
+ developer?: string;
54
+ };
55
+ /** Human label stamped on every event context and every WorkflowError `agentLabel`; never on
56
+ * the wire. */
57
+ label?: string;
58
+ /** Custom backend registry merged over `AGENTPRISM_BACKENDS` exactly like
59
+ * `createAcpRunner({ backends })`. Read once in the constructor; malformed →
60
+ * SCRIPT_VALIDATION_ERROR. Forks inherit it and cannot override it. */
61
+ backends?: Record<string, CustomBackendConfig>;
62
+ /** Agent-lifetime abort: rejects queued work with `signal.reason`, cancels an in-flight turn,
63
+ * then closes. Not inherited by forks. */
64
+ signal?: AbortSignal;
65
+ /** Default true: the session log is retained across turns so `history`/`text` are cumulative
66
+ * and a fork can seed its child. `false` maps to `retainSessionLog: false` (history/text hold
67
+ * only the latest turn). */
68
+ retainHistory?: boolean;
69
+ /** Default true: ask the backend to emit its vendor notifications (`_claude/sdkMessage` on
70
+ * Claude) so they reach `on("raw_message")` and `turn.raw`. `false` skips
71
+ * `backend.rawMessagesMeta()` (a schema still turns raw messages on for Claude because the
72
+ * schema channel needs them). */
73
+ raw?: boolean;
74
+ /** Optional shared auth store (default off = each agent's own login). Forks share the parent's. */
75
+ authStore?: AuthStore;
76
+ /** Optional shared provider-intent store. Forks share the parent's. */
77
+ providerStore?: ProviderStore;
78
+ /** Client-side fs/terminal/mcp handlers advertised at initialize (validated with
79
+ * `validateClientHandlers`). */
80
+ clientHandlers?: ClientHandlers;
81
+ }
82
+ export interface AcpAgentPromptOptions {
83
+ /** Appended as image content blocks (validated with `validatePromptImages`; string prompts
84
+ * become `[text, ...images]`). */
85
+ images?: readonly PromptImage[];
86
+ /** Turn `_meta` passthrough, merged UNDER the backend's turn meta (backend keys win direct
87
+ * collisions, exactly like the runner's `mergeTurnMeta`). */
88
+ meta?: Record<string, unknown>;
89
+ /** Applied via `session/set_config_option` BEFORE this turn, inside the FIFO; STICKY for the
90
+ * session. Same validation as the constructor option. */
91
+ configOptions?: Record<string, string | boolean>;
92
+ /** Applied via `session/set_mode` before this turn, inside the FIFO; sticky; strict. */
93
+ mode?: string;
94
+ /** Per-turn schema override. Allowed ONLY when the backend carries the schema on the turn and
95
+ * does not embed it in the prompt (today: Codex). Otherwise SCRIPT_VALIDATION_ERROR naming the
96
+ * backend and pointing at the constructor `schema` option. */
97
+ schema?: TSchema;
98
+ /** Per-call abort: queued, or started but not yet on the wire (the lazy open, the per-turn
99
+ * `configOptions`/`mode`) → rejects with the reason without sending; in flight →
100
+ * `session/cancel`, then rejects with the reason. The one way to stop a turn `cancel()` cannot
101
+ * reach: `cancel()` targets only a turn whose `session/prompt` is on the wire. */
102
+ signal?: AbortSignal;
103
+ }
104
+ export interface AcpAgentSteerOptions {
105
+ images?: readonly PromptImage[];
106
+ meta?: Record<string, unknown>;
107
+ }
108
+ export interface AcpAgentCloseOptions {
109
+ /** true = skip `session/close` so the agent-persisted session stays re-openable via
110
+ * `AcpAgent.resume/load/fork(ref)`. The dedicated process is disposed either way. */
111
+ keep?: boolean;
112
+ }
113
+ /** Everything a fork may override. The backend is fixed by the parent: a `model` override must
114
+ * route to the same backend (poolKey-equal) or SCRIPT_VALIDATION_ERROR. `backends`, `authStore`,
115
+ * `providerStore`, `clientHandlers` are inherited and not overridable. `label` defaults to
116
+ * `<parent label>/fork-<n>` (or `fork-<n>`); `signal` is never inherited. `cwd` defaults to the
117
+ * parent's; a different cwd is rejected on `cwd: "source-only"` backends (`FORK_SESSION_TRAITS`). */
118
+ export type AcpAgentForkOptions = Partial<Omit<AcpAgentOptions, "backends" | "authStore" | "providerStore" | "clientHandlers">>;
119
+ /** Options for the cold statics. `cwd` defaults to `ref.cwd`; `model` must route to `ref.backendId`. */
120
+ export type AcpAgentReopenOptions = Partial<AcpAgentOptions>;
121
+ export interface AcpAgentProbeOptions {
122
+ /** One exact routed spec (`modelSpecs: [model]`): selected before the catalog is read. */
123
+ model?: string;
124
+ /** More exact specs. */
125
+ models?: string[];
126
+ /** Backend-only targets. Default (no `harnesses`, no model specs): every built-in plus every
127
+ * registered custom backend. */
128
+ harnesses?: string[];
129
+ /** Substring or `/regex/` over leaf model ids → `catalog.models[*].matches`. */
130
+ modelFilter?: string;
131
+ backends?: Record<string, CustomBackendConfig>;
132
+ cwd?: string;
133
+ probeTimeoutMs?: number;
134
+ probeConcurrency?: number;
135
+ signal?: AbortSignal;
136
+ }
137
+ export type AcpAgentCatalog = HarnessConfigReport & {
138
+ models: HarnessModelsView[];
139
+ };
140
+ export interface AcpAgentUpdateRecord {
141
+ readonly update: AcpSessionUpdate;
142
+ readonly receivedAt: number;
143
+ }
144
+ export interface AcpAgentRawRecord {
145
+ readonly method: string;
146
+ readonly message: unknown;
147
+ readonly receivedAt: number;
148
+ }
149
+ export interface AcpAgentToolCall {
150
+ readonly toolCallId: string;
151
+ /** SDK UNSTABLE `ToolCall.name` / `ToolCallUpdate.name`, verbatim. */
152
+ readonly name?: string;
153
+ readonly title: string;
154
+ readonly kind?: ToolKind;
155
+ /** Last seen; "pending" when the agent sent none. */
156
+ readonly status: ToolCallStatus;
157
+ readonly rawInput?: unknown;
158
+ readonly rawOutput?: unknown;
159
+ readonly content?: ToolCallContent[];
160
+ readonly locations?: ToolCallLocation[];
161
+ /** Shallow merge of every `_meta` seen for this id. */
162
+ readonly meta?: Record<string, unknown>;
163
+ }
164
+ export interface AcpAgentTurnUsage {
165
+ /** THIS turn's tokens: `response.usage` mapped to `AgentUsage` (every installed adapter reports
166
+ * the turn, not the session — `PROMPT_USAGE_SCOPES`); `cost` = the clamped delta of the
167
+ * cumulative `usage_update` cost gauge across the turn. When the response carries no `usage`,
168
+ * tokens fall back to the context-token gauge delta exactly like `UsageAccumulator.delta()`. */
169
+ readonly turn: AgentUsage;
170
+ /** Running per-field sum of every turn THIS AcpAgent ran (`cost` = the latest gauge value),
171
+ * including this one. Starts at zero at open/fork/resume/load — replayed history and the
172
+ * parent's turns are not counted. */
173
+ readonly session: AgentUsage;
174
+ /** `response.usage` verbatim. */
175
+ readonly response?: Usage;
176
+ }
177
+ export interface AcpAgentTurn {
178
+ /** The wire object, `_meta` intact (no SDK response mapping on session/prompt). */
179
+ readonly response: PromptResponse;
180
+ /** `= response.stopReason`; NEVER thrown on (refusal/max_tokens/cancelled included). */
181
+ readonly stopReason: StopReason;
182
+ /** This turn's assistant messages joined by "\n\n" (`SessionHandle.foldedTurnText()`). */
183
+ readonly text: string;
184
+ /** Every session/update of this turn, structuredClone'd (verbatim objects, `_meta` intact). */
185
+ readonly updates: ReadonlyArray<AcpAgentUpdateRecord>;
186
+ /** Every `raw_message` of this turn (Claude `_claude/sdkMessage`). */
187
+ readonly raw: ReadonlyArray<AcpAgentRawRecord>;
188
+ /** tool_call ⊕ tool_call_update folded by toolCallId, first-seen order. */
189
+ readonly toolCalls: ReadonlyArray<AcpAgentToolCall>;
190
+ readonly permissions: ReadonlyArray<AcpPermissionEvent>;
191
+ readonly elicitations: ReadonlyArray<AcpElicitationEvent>;
192
+ readonly usage: AcpAgentTurnUsage;
193
+ /** Validated (typebox Convert + Check) when a schema was active for the turn. */
194
+ readonly structured?: unknown;
195
+ /** Why `structured` is absent although a schema was active. */
196
+ readonly structuredError?: string;
197
+ /** This turn's accumulator entries (copies). Per CHUNK, not per message: one `assistant`/`text`
198
+ * entry per streamed `agent_message_chunk` and one `tool`/`toolCall` entry per `tool_call`, so
199
+ * `history.length` is not a message count — `text` is the folded, per-message view. */
200
+ readonly history: readonly AgentHistoryEntry[];
201
+ }
202
+ /** A `prompt()` rejection for a turn the agent walled with a typed session failure (codex-acp's
203
+ * negotiated extension): the runner's mapped `WorkflowError` (`mapTypedSessionFailure`, so codes,
204
+ * `recoverable` and `details` keep their tested contract) carrying the COMPLETE turn — verbatim
205
+ * `response` incl. `_meta`, `usage`, `updates`, `raw`, `toolCalls`, `history` — so nothing is
206
+ * stripped. Narrow with `isAcpAgentTurnError`. */
207
+ export type AcpAgentTurnError = WorkflowError & {
208
+ readonly turn: AcpAgentTurn;
209
+ };
210
+ /** Same keys/payloads as the runner bus (no new cross-cutting names); turn boundaries are the
211
+ * `prompt()` promise. */
212
+ export type AcpAgentEventMap = AcpRunnerEventMap;
213
+ export type AcpAgentEventName = keyof AcpAgentEventMap;
214
+ export type AcpAgentEventListener<K extends AcpAgentEventName> = (event: AcpAgentEventMap[K]) => void;
215
+ /** `idle` (constructed, nothing spawned) → `opening` → `ready` ⇄ `busy` (a queued op is executing)
216
+ * → `closed` (set the instant `close()` is called, the constructor signal aborts, or the process
217
+ * dies). */
218
+ export type AcpAgentState = "idle" | "opening" | "ready" | "busy" | "closed";
219
+ /** The all-zero `AgentUsage` every agent starts from (frozen; never mutated in place). */
220
+ export declare const ZERO_USAGE: AgentUsage;
221
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/agent/types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,QAAQ,EACR,KAAK,EACN,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EACV,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,WAAW,EACX,aAAa,EACd,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EA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,EAAE,MAAM,CAAC;IAClC;;4FAEwF;IACxF,QAAQ,CAAC,OAAO,EAAE,SAAS,iBAAiB,EAAE,CAAC;CAChD;AAED;;;;mDAImD;AACnD,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAA;CAAE,CAAC;AAEhF;0BAC0B;AAC1B,MAAM,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;AACjD,MAAM,MAAM,iBAAiB,GAAG,MAAM,gBAAgB,CAAC;AACvD,MAAM,MAAM,qBAAqB,CAAC,CAAC,SAAS,iBAAiB,IAAI,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;AAEtG;;aAEa;AACb,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE7E,0FAA0F;AAC1F,eAAO,MAAM,UAAU,EAAE,UAOvB,CAAC"}
@@ -0,0 +1,9 @@
1
+ /** The all-zero `AgentUsage` every agent starts from (frozen; never mutated in place). */
2
+ export const ZERO_USAGE = Object.freeze({
3
+ input: 0,
4
+ output: 0,
5
+ cacheRead: 0,
6
+ cacheWrite: 0,
7
+ total: 0,
8
+ cost: 0,
9
+ });
package/dist/backend.d.ts CHANGED
@@ -95,6 +95,12 @@ export interface Backend {
95
95
  * keys win over the generic user passthrough. `inputs` carries optional per-session extras
96
96
  * (e.g. Codex base/developer instructions); a backend that has no use for them ignores it. */
97
97
  sessionMeta(schema: TSchema | undefined, inputs?: SessionMetaInputs): Record<string, unknown> | undefined;
98
+ /** OPTIONAL session `_meta` that switches the agent's vendor notification stream on (the
99
+ * `raw_message` events — Claude's `_claude/sdkMessage`). Undefined when the agent has no such
100
+ * stream. The AcpAgent SDK layers it UNDER the caller's `meta` and OVER `sessionMetaDefaults`
101
+ * when `raw` is on; the one-shot runner never sends it (a schema run already enables the stream
102
+ * through `sessionMeta`). */
103
+ rawMessagesMeta?(): Record<string, unknown> | undefined;
98
104
  /** Protocol-critical `_meta` for session/prompt (undefined when this backend carries the schema
99
105
  * at session/new). These keys win direct collisions with caller prompt metadata; unrelated
100
106
  * caller keys are transported unchanged. */
@@ -1 +1 @@
1
- {"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../src/backend.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D,iGAAiG;AACjG,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D;sFACsF;AACtF,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAE/B,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;CACxB;AAED,8FAA8F;AAC9F,MAAM,WAAW,gBAAgB;IAC/B,8FAA8F;IAC9F,eAAe,IAAI,MAAM,CAAC;IAC1B;;;4FAGwF;IACxF,gBAAgB,IAAI,MAAM,CAAC;IAC3B,uGAAuG;IACvG,mBAAmB,IAAI,OAAO,CAAC;CAChC;AAED;+EAC+E;AAC/E,MAAM,WAAW,iBAAiB;IAChC,yFAAyF;IACzF,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,sFAAsF;IACtF,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,0FAA0F;IAC1F,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oGAAoG;IACpG,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,8FAA8F;AAC9F,MAAM,WAAW,qBAAqB;IACpC,2EAA2E;IAC3E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,gFAAgF;AAChF,MAAM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AAC,MAAM,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IAC7E,oGAAoG;IACpG,gBAAgB,CAAC,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC;CACtD;AAED,6FAA6F;AAC7F,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,EAAE,CAE7D"}
@@ -13,6 +13,7 @@ export declare class ClaudeBackend implements Backend {
13
13
  sessionMetaDefaults(inputs?: SessionMetaInputs): Record<string, unknown> | undefined;
14
14
  sessionMeta(schema: TSchema | undefined, inputs?: SessionMetaInputs): Record<string, unknown> | undefined;
15
15
  promptMeta(): Record<string, unknown> | undefined;
16
+ rawMessagesMeta(): Record<string, unknown> | undefined;
16
17
  nativeStructured(source: StructuredSource): unknown;
17
18
  }
18
19
  export declare const claudeBackendDefinition: import("./define.js").BuiltinBackendDefinition<"claude">;
@@ -1 +1 @@
1
- {"version":3,"file":"claude.d.ts","sourceRoot":"","sources":["../../src/backends/claude.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EACV,OAAO,EACP,2BAA2B,EAC3B,qBAAqB,EACrB,iBAAiB,EACjB,WAAW,EACX,gBAAgB,EACjB,MAAM,eAAe,CAAC;AASvB,+FAA+F;AAC/F,eAAO,MAAM,iBAAiB,EAAE,WAK/B,CAAC;AAEF,qBAAa,aAAc,YAAW,OAAO;IAI/B,QAAQ,CAAC,WAAW,EAAE,WAAW;IAH7C,QAAQ,CAAC,EAAE,EAAG,QAAQ,CAAU;IAChC,QAAQ,CAAC,aAAa,EAAG,MAAM,CAAU;gBAEpB,WAAW,GAAE,WAA+B;IAEjE,qBAAqB,CACnB,KAAK,EAAE,OAAO,EACd,QAAQ,CAAC,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M,EAAE,OAAO,CAAC,GAAG,SAAS;IAMpF,WAAW,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;IAuBzG,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;IAKjD,eAAe,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;IAMtD,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO;CAGpD;AAQD,eAAO,MAAM,uBAAuB,0DA2BlC,CAAC"}
@@ -86,6 +86,11 @@ export class ClaudeBackend {
86
86
  // Claude's schema is session-scoped (read at session/new); nothing on the turn.
87
87
  return undefined;
88
88
  }
89
+ rawMessagesMeta() {
90
+ // claude-agent-acp emits `_claude/sdkMessage` only when the session asks for it; a schema
91
+ // session already sets this through sessionMeta (the result rides that stream).
92
+ return { claudeCode: { emitRawSDKMessages: true } };
93
+ }
89
94
  nativeStructured(source) {
90
95
  return source.rawStructuredOutput();
91
96
  }
@@ -0,0 +1,173 @@
1
+ import type { SessionConfigOption, SessionModeState } from "@agentclientprotocol/sdk";
2
+ import { type CustomBackendConfig } from "./registry.js";
3
+ import { type ProbedConfigOptions } from "./runner.js";
4
+ export interface ValidateProbeRunner {
5
+ probeConfigOptions(spec?: string, opts?: {
6
+ cwd?: string;
7
+ selectModel?: boolean;
8
+ backends?: Record<string, CustomBackendConfig>;
9
+ signal?: AbortSignal;
10
+ }): Promise<ProbedConfigOptions>;
11
+ /** Every host-routable backend name. Used by protocol-native discovery. */
12
+ listBackends?(): string[];
13
+ /** Host-registered custom names, including deliberate built-in shadows. */
14
+ listCustomBackends?(): string[];
15
+ /** The host's backend selected when a workflow omits model. */
16
+ defaultBackendId?(): string;
17
+ /** Present on owned probe runners; shared host runners are never disposed by validation. */
18
+ dispose?(): Promise<void>;
19
+ }
20
+ export type ConfigProbeFactory = (backends: Record<string, CustomBackendConfig> | undefined) => ValidateProbeRunner;
21
+ /** Package-internal hermetic test seam. Deliberately absent from the public index export. */
22
+ export declare function setConfigProbeFactoryForTests(factory: ConfigProbeFactory): () => void;
23
+ export interface ValidateHarnessOptions {
24
+ backendId: string;
25
+ /** AgentPrism's explicit mode when the call omits mode; absent for no-mode/custom backends. */
26
+ defaultModeId?: string;
27
+ /** The call's verbatim selected model; absent means the harness/session default. */
28
+ model?: string;
29
+ probed: boolean;
30
+ /** Present when probed=false: the harness's spawn/auth/session error. */
31
+ error?: string;
32
+ /** Effective advertised ACP modes; null means this backend/model supports no session modes. */
33
+ modes?: SessionModeState | null;
34
+ options?: SessionConfigOption[];
35
+ }
36
+ type SelectConfigOption = Extract<SessionConfigOption, {
37
+ type: "select";
38
+ }>;
39
+ /** Every leaf {value,label} the select advertises, flattening any advertised optgroups. */
40
+ export declare function selectChoicePairs(option: SelectConfigOption): {
41
+ value: string;
42
+ label?: string;
43
+ }[];
44
+ export interface SelectChoiceGroup {
45
+ group: string;
46
+ count: number;
47
+ }
48
+ export interface SelectChoiceSummary {
49
+ total: number;
50
+ groups: SelectChoiceGroup[];
51
+ }
52
+ /**
53
+ * Group a select's choices for summary display. Prefers the harness-advertised optgroup
54
+ * labels; absent those, groups by the first "/"-segment of each value. Groups come back
55
+ * largest-first, ties broken by first appearance.
56
+ */
57
+ export declare function summarizeSelectChoices(option: SelectConfigOption): SelectChoiceSummary;
58
+ export interface ProbeHarnessConfigOptions {
59
+ /** Harness names to probe (built-in `claude` / `codex` / `opencode` / `pi` or a registered
60
+ * custom name; any model spec routes like an agent() call's). Default: every routable
61
+ * harness — the four built-ins plus each registered custom backend. */
62
+ harnesses?: string[];
63
+ /** Exact routed model specs to select before reading their model-specific option catalogs. */
64
+ modelSpecs?: string[];
65
+ /** Programmatic custom-backend registry, merged over the AGENTPRISM_BACKENDS env var
66
+ * exactly like `createAcpRunner({ backends })`. */
67
+ backends?: Record<string, CustomBackendConfig>;
68
+ /** Session cwd for the probes. Default `process.cwd()` — harnesses may resolve
69
+ * project-level configuration (and hence their catalog) from it. */
70
+ cwd?: string;
71
+ /** Host-owned no-prompt probe runner. When supplied it is reused and never disposed. */
72
+ probeRunner?: ValidateProbeRunner;
73
+ /** Per-probe cancellation deadline in milliseconds. Default 60,000; lifecycle
74
+ * diagnostics can use a shorter bound. Must be a positive timer-safe integer. */
75
+ probeTimeoutMs?: number;
76
+ /** Maximum concurrent probes, from 1 to 16. Default 4. */
77
+ probeConcurrency?: number;
78
+ /** Shared discovery cancellation budget. Completed catalogs are retained; active
79
+ * probes are aborted and queued targets become failed entries without starting. */
80
+ signal?: AbortSignal;
81
+ }
82
+ export interface HarnessConfigReport {
83
+ /** True when every requested harness probed successfully. */
84
+ ok: boolean;
85
+ /** 0 = all probed; 1 = at least one probe failed. */
86
+ exitCode: 0 | 1;
87
+ /** One entry per requested harness, in request order — the same shape validate reports. */
88
+ harnessOptions: ValidateHarnessOptions[];
89
+ /** Bounded presentation alongside the complete supported catalog. */
90
+ authoringSummary?: HarnessConfigSummary;
91
+ }
92
+ export declare const DEFAULT_PROBE_TIMEOUT_MS = 60000;
93
+ /**
94
+ * Probe each requested harness's advertised config-option catalog. A per-harness
95
+ * spawn/auth/session failure (or timeout) is reported as `probed:false` on that entry —
96
+ * never thrown. Only caller configuration errors throw: a malformed AGENTPRISM_BACKENDS /
97
+ * `backends` registry (loud at construction, mirroring `createAcpRunner`) or invalid options.
98
+ */
99
+ export declare function probeHarnessConfig(options?: ProbeHarnessConfigOptions): Promise<HarnessConfigReport>;
100
+ /** One harness's slice of the `config <harness> --models[=<filter>]` view. Without a
101
+ * filter it carries the provider/group breakdown (never the leaf ids); with a filter it
102
+ * carries only the matching leaf ids. There is no unfiltered leaf dump on any surface. */
103
+ export interface HarnessModelsView {
104
+ backendId: string;
105
+ probed: boolean;
106
+ /** Present when probed=false. */
107
+ error?: string;
108
+ /** False when the harness advertises no `model` select option. */
109
+ hasModelOption: boolean;
110
+ /** The filter as given, when one was supplied. */
111
+ filter?: string;
112
+ /** Breakdown mode (no filter): total leaf count and per-group counts. */
113
+ total?: number;
114
+ groups?: SelectChoiceGroup[];
115
+ /** Filter mode: the leaf model ids matching the filter. */
116
+ matches?: string[];
117
+ }
118
+ /** Compile a `--models=<filter>` value into a leaf-value matcher. A value wrapped in
119
+ * slashes (`/.../`) is a case-insensitive regex; anything else is a case-insensitive
120
+ * substring. Throws a TypeError on an invalid regex (surfaced as a CLI usage error). */
121
+ export declare function buildModelFilter(filter: string): (value: string) => boolean;
122
+ /** Build the per-harness `--models` view. `filter` undefined = breakdown mode. */
123
+ export declare function buildHarnessModelsView(report: HarnessConfigReport, filter?: string): HarnessModelsView[];
124
+ export interface HarnessConfigSummaryModel {
125
+ modelId: string;
126
+ /** Exact executable route; browse selectors never appear here. */
127
+ route: string;
128
+ }
129
+ export interface HarnessConfigSummaryGroup {
130
+ provider: string;
131
+ count: number;
132
+ kind: "provider" | "aggregator";
133
+ /** Presentation only. Expand with modelFilter; never pass to agent(). */
134
+ selector?: string;
135
+ modelFilter: string;
136
+ }
137
+ export interface HarnessConfigSummaryEntry {
138
+ backendId: string;
139
+ /** Exact-model probe scope, when selected before reading options. */
140
+ model?: string;
141
+ probed: boolean;
142
+ error?: string;
143
+ hasModelOption: boolean;
144
+ /** Actual complete live catalog size, before presentation limits/preferences. */
145
+ total: number;
146
+ /** Current selection is separate from preferred models; it need not be preferred. */
147
+ currentModel?: string;
148
+ /** Present only when the current model is an advertised executable leaf. */
149
+ currentRoute?: string;
150
+ omittedCurrentModel?: true;
151
+ models: HarnessConfigSummaryModel[];
152
+ omittedModels: number;
153
+ groups: HarnessConfigSummaryGroup[];
154
+ omittedGroups: number;
155
+ omittedGroupModels: number;
156
+ preferenceSource?: "enabledModels";
157
+ /** Available preferred models before presentation limits. */
158
+ preferredTotal?: number;
159
+ unmatched: string[];
160
+ omittedUnmatched: number;
161
+ }
162
+ export interface HarnessConfigSummary {
163
+ /** One entry per requested probe, including unavailable backends, in request order. */
164
+ harnesses: HarnessConfigSummaryEntry[];
165
+ }
166
+ /** Compact live authoring guidance. Does not mutate or restrict the supported catalog.
167
+ * Lists are bounded per harness; omitted counts and exact expansion filters are explicit.
168
+ * Options such as effort remain authoritative only for the exact probed model. */
169
+ export declare function buildHarnessConfigSummary(report: Pick<HarnessConfigReport, "harnessOptions">): HarnessConfigSummary;
170
+ /** Format the bounded summary for both explicit discovery and missing-route diagnostics. */
171
+ export declare function formatHarnessConfigSummary(summary: HarnessConfigSummary): string;
172
+ export {};
173
+ //# sourceMappingURL=config-catalog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-catalog.d.ts","sourceRoot":"","sources":["../src/config-catalog.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAGtF,OAAO,EAA0B,KAAK,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACjF,OAAO,EAAkB,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvE,MAAM,WAAW,mBAAmB;IAClC,kBAAkB,CAChB,IAAI,CAAC,EAAE,MAAM,EACb,IAAI,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;QAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GACnH,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAChC,2EAA2E;IAC3E,YAAY,CAAC,IAAI,MAAM,EAAE,CAAC;IAC1B,2EAA2E;IAC3E,kBAAkB,CAAC,IAAI,MAAM,EAAE,CAAC;IAChC,+DAA+D;IAC/D,gBAAgB,CAAC,IAAI,MAAM,CAAC;IAC5B,4FAA4F;IAC5F,OAAO,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B;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