@automatalabs/acp-agents 0.7.0 → 0.9.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.
package/dist/backend.d.ts CHANGED
@@ -37,6 +37,13 @@ export interface Backend {
37
37
  * without the schema in the prompt, such an agent returns well-formed JSON with the WRONG
38
38
  * KEYS and the repair ladder can never converge (it can fix prose, not unseen contracts). */
39
39
  readonly embedSchemaInPrompt?: boolean;
40
+ /** The agentCapabilities._meta namespace this backend's agent advertises under, and the bare
41
+ * `_meta` keys gated by same-named boolean flags in that block; undefined = this backend has
42
+ * no custom-capability contract (its custom `_meta`, if any, is never gated). */
43
+ readonly customCapabilities?: {
44
+ readonly namespace: string;
45
+ readonly gatedKeys: readonly string[];
46
+ };
40
47
  /** How to launch this backend's ACP server over stdio. */
41
48
  spawnConfig(): SpawnConfig;
42
49
  /** OPTIONAL backend-level `_meta` DEFAULTS for session/new (e.g. a custom registry entry's
@@ -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;AAEvC,4FAA4F;AAC5F,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,OAAO,CAAC;AAClD;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,oDAAoD;IACpD,eAAe,IAAI,MAAM,CAAC;IAC1B,uGAAuG;IACvG,mBAAmB,IAAI,OAAO,CAAC;CAChC;AAED;+EAC+E;AAC/E,MAAM,WAAW,iBAAiB;IAChC,yFAAyF;IACzF,gBAAgB,CAAC,EAAE,MAAM,C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gB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,EAAE,CAE7D"}
@@ -2,6 +2,10 @@ import type { TSchema } from "typebox";
2
2
  import type { Backend, SessionMetaInputs, SpawnConfig, StructuredSource } from "../backend.js";
3
3
  export declare class CodexBackend implements Backend {
4
4
  readonly id: "codex";
5
+ readonly customCapabilities: {
6
+ readonly namespace: "@automatalabs/codex-acp";
7
+ readonly gatedKeys: readonly string[];
8
+ };
5
9
  spawnConfig(): SpawnConfig;
6
10
  sessionMeta(_schema: TSchema | undefined, inputs?: SessionMetaInputs): Record<string, unknown> | undefined;
7
11
  promptMeta(schema: TSchema | undefined): Record<string, unknown> | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"codex.d.ts","sourceRoot":"","sources":["../../src/backends/codex.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAO/F,qBAAa,YAAa,YAAW,OAAO;IAC1C,QAAQ,CAAC,EAAE,EAAG,OAAO,CAAU;IAE/B,WAAW,IAAI,WAAW;IAe1B,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;IAY1G,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;IAK5E,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO;CAKpD"}
1
+ {"version":3,"file":"codex.d.ts","sourceRoot":"","sources":["../../src/backends/codex.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAQ/F,qBAAa,YAAa,YAAW,OAAO;IAC1C,QAAQ,CAAC,EAAE,EAAG,OAAO,CAAU;IAC/B,QAAQ,CAAC,kBAAkB;;;MAGhB;IAEX,WAAW,IAAI,WAAW;IAe1B,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;IAY1G,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;IAK5E,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO;CAKpD"}
@@ -7,13 +7,18 @@
7
7
  // constrained final message flows back over the normal agent-message stream, so the backend
8
8
  // reads the final text and JSON.parses it.
9
9
  import { createRequire } from "node:module";
10
- import { CODEX_META_KEYS, META_KEYS } from "@automatalabs/shared-types";
10
+ import { CODEX_CUSTOM_CAPABILITY_NAMESPACE, CODEX_META_KEYS, META_KEYS } from "@automatalabs/shared-types";
11
11
  import { splitArgs } from "../backend.js";
12
+ import { GATED_CUSTOM_META_KEYS } from "../capabilities.js";
12
13
  import { toStrictJsonSchema } from "../schema-strict.js";
13
14
  import { parseFinalJson } from "../structured-output.js";
14
15
  const require = createRequire(import.meta.url);
15
16
  export class CodexBackend {
16
17
  id = "codex";
18
+ customCapabilities = {
19
+ namespace: CODEX_CUSTOM_CAPABILITY_NAMESPACE,
20
+ gatedKeys: GATED_CUSTOM_META_KEYS,
21
+ };
17
22
  spawnConfig() {
18
23
  const env = process.env;
19
24
  const override = env.AGENTPRISM_CODEX_ACP_CMD;
@@ -11,6 +11,7 @@ export declare class CustomAcpBackend implements Backend {
11
11
  * schema in the prompt — otherwise the model returns JSON with keys it invented and the
12
12
  * repair ladder can never converge on a contract the model was never shown. */
13
13
  readonly embedSchemaInPrompt = true;
14
+ readonly customCapabilities?: NonNullable<Backend["customCapabilities"]>;
14
15
  constructor(config: RegisteredBackend);
15
16
  spawnConfig(): SpawnConfig;
16
17
  sessionMetaDefaults(): Record<string, unknown> | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"custom.d.ts","sourceRoot":"","sources":["../../src/backends/custom.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAIxD,qBAAa,gBAAiB,YAAW,OAAO;IAUlC,OAAO,CAAC,QAAQ,CAAC,MAAM;IATnC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB;mGAC+F;IAC/F,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB;;oFAEgF;IAChF,QAAQ,CAAC,mBAAmB,QAAQ;gBAEP,MAAM,EAAE,iBAAiB;IAUtD,WAAW,IAAI,WAAW;IAS1B,mBAAmB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;IAQ1D,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;IAM9E,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;IAQ5E,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO;CAGpD"}
1
+ {"version":3,"file":"custom.d.ts","sourceRoot":"","sources":["../../src/backends/custom.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAIxD,qBAAa,gBAAiB,YAAW,OAAO;IAWlC,OAAO,CAAC,QAAQ,CAAC,MAAM;IAVnC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB;mGAC+F;IAC/F,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB;;oFAEgF;IAChF,QAAQ,CAAC,mBAAmB,QAAQ;IACpC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC;gBAE5C,MAAM,EAAE,iBAAiB;IAWtD,WAAW,IAAI,WAAW;IAS1B,mBAAmB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;IAQ1D,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;IAM9E,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;IAQ5E,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO;CAGpD"}
@@ -25,9 +25,12 @@ export class CustomAcpBackend {
25
25
  * schema in the prompt — otherwise the model returns JSON with keys it invented and the
26
26
  * repair ladder can never converge on a contract the model was never shown. */
27
27
  embedSchemaInPrompt = true;
28
+ customCapabilities;
28
29
  constructor(config) {
29
30
  this.config = config;
30
31
  this.id = config.name;
32
+ if (config.customCapabilities)
33
+ this.customCapabilities = config.customCapabilities;
31
34
  const spawnIdentity = JSON.stringify({
32
35
  command: config.command,
33
36
  args: config.args ?? [],
@@ -1,6 +1,7 @@
1
- import { type AgentCapabilities, type Implementation, type InitializeResponse } from "@agentclientprotocol/sdk";
1
+ import { type AgentCapabilities, type ContentBlock, type Implementation, type InitializeResponse } from "@agentclientprotocol/sdk";
2
2
  import { type McpServerConfig } from "@automatalabs/shared-types";
3
- /** The bare `_meta` keys whose emission is gated by the fork's custom-capability advertisement.
3
+ import type { Backend } from "./backend.js";
4
+ /** The bare `_meta` keys whose emission is gated by Codex's custom-capability advertisement.
4
5
  * Each is named EXACTLY like the advertised flag that gates it, so `support[key] === true` is the
5
6
  * whole test. session/new carries baseInstructions/developerInstructions and session/prompt carries
6
7
  * outputSchema — one list covers both (a key absent from a given `_meta` is simply skipped). */
@@ -17,23 +18,33 @@ export interface NegotiatedCapabilities {
17
18
  agentInfo: Implementation | undefined;
18
19
  /** Whether session/close is advertised (gates the best-effort release-time close). */
19
20
  supportsClose: boolean;
20
- /** The parsed @automatalabs/codex-acp custom-capability block (the namespaced `_meta` object), or
21
- * undefined when the agent did not advertise the namespace at all the legacy passthrough. */
21
+ /** The parsed backend-declared custom-capability block (the namespaced `_meta` object), or
22
+ * undefined when the backend declared none or the agent did not advertise it passthrough. */
22
23
  customMetaSupport: Record<string, unknown> | undefined;
24
+ /** The backend-declared bare `_meta` keys gated by customMetaSupport; undefined when this backend
25
+ * has no custom-capability contract, so custom `_meta` is never gated. */
26
+ gatedKeys: readonly string[] | undefined;
23
27
  }
24
28
  /** Parse an initialize response into the connection's derived capability state. */
25
- export declare function negotiateCapabilities(response: InitializeResponse): NegotiatedCapabilities;
29
+ export declare function negotiateCapabilities(response: InitializeResponse, customCapabilities?: Backend["customCapabilities"]): NegotiatedCapabilities;
26
30
  /** True only when the agent selected EXACTLY PROTOCOL_VERSION. This client implements that one wire
27
31
  * version and adapts its behavior to no other, so any other selected version — older or newer —
28
32
  * means close the connection per the ACP spec's SHOULD-close rule. Per the spec the agent echoes
29
33
  * the requested version when it supports it, else its own latest; we do NOT accept older versions
30
34
  * (we cannot speak them) — the equality is the whole test. */
31
35
  export declare function isSupportedProtocolVersion(version: number): boolean;
32
- /** Remove the fork's custom bare `_meta` keys the connected agent did NOT advertise support for.
36
+ /** Remove the declared custom bare `_meta` keys the connected agent did NOT advertise support for.
33
37
  * A no-op when the agent advertised no namespace (`support` undefined => legacy => every key
34
38
  * passes) or the meta is empty/undefined. Never mutates its input; collapses to undefined if
35
39
  * gating empties the object (so no `_meta` is sent at all). */
36
- export declare function gateCustomMeta(meta: Record<string, unknown> | undefined, support: Record<string, unknown> | undefined): Record<string, unknown> | undefined;
40
+ export declare function gateCustomMeta(meta: Record<string, unknown> | undefined, support: Record<string, unknown> | undefined, gatedKeys?: readonly string[]): Record<string, unknown> | undefined;
41
+ /** Adapt prompt content to the agent's PromptCapabilities. ACP baseline content (text and
42
+ * resource_link) is never gated; optional blocks follow the spec's capability table:
43
+ * image->promptCapabilities.image, audio->promptCapabilities.audio, and resource->
44
+ * promptCapabilities.embeddedContext. Unsupported optional blocks are represented as explicit
45
+ * bracketed text notes so context is never silently lost. Returns the SAME array reference when
46
+ * no block changes and never mutates the input or any surviving block. */
47
+ export declare function adaptPromptContent(blocks: ContentBlock[], agent: AgentCapabilities, backendId: string): ContentBlock[];
37
48
  /** The first client-provided MCP server whose transport the agent did NOT advertise, or undefined
38
49
  * when every server is serviceable. stdio is ALWAYS serviceable (the baseline transport); http/sse
39
50
  * are gated on mcpCapabilities.{http,sse}. Lenient for legacy agents: when the agent advertised no
@@ -1 +1 @@
1
- {"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../src/capabilities.ts"],"names":[],"mappings":"AAeA,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAIL,KAAK,eAAe,EACrB,MAAM,4BAA4B,CAAC;AAEpC;;;iGAGiG;AACjG,eAAO,MAAM,sBAAsB,EAAE,SAAS,MAAM,EAInD,CAAC;AAEF,qFAAqF;AACrF,MAAM,WAAW,sBAAsB;IACrC;0FACsF;IACtF,eAAe,EAAE,MAAM,CAAC;IACxB;4DACwD;IACxD,KAAK,EAAE,iBAAiB,CAAC;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
1
1
  // Negotiated ACP capabilities for one pooled connection — the derived state the connection acts on
2
- // after its ONE-TIME `initialize` handshake. Parses the InitializeResponse into: the agent's chosen
3
- // protocolVersion (validated against what this client speaks), its full advertised agentCapabilities
4
- // + agentInfo, whether session/close is supported, and the @automatalabs/codex-acp fork's custom
5
- // capability advertisement (the namespaced `_meta` block gating which bare `_meta` inputs the client
6
- // may send).
2
+ // after its ONE-TIME `initialize` handshake. Parses the InitializeResponse + the backend's optional
3
+ // custom-capability declaration into: the agent's chosen protocolVersion (validated against what this
4
+ // client speaks), its full advertised agentCapabilities + agentInfo, whether session/close is
5
+ // supported, and the declared custom-capability advertisement (the namespaced `_meta` block gating
6
+ // which backend-declared bare `_meta` inputs the client may send). The negotiated record is a pure
7
+ // parse of (response + declaration): `gatedKeys` captures the declaration at handshake time, and
8
+ // PooledConnection gates against that captured list.
7
9
  //
8
- // GATING PHILOSOPHY — lenient for legacy agents. An agent that advertises NOTHING is treated as
9
- // today's behavior (every gated key still sent), because the currently-published fork
10
- // (@automatalabs/codex-acp 1.2.0) and arbitrary custom ACP servers honor these inputs WITHOUT
11
- // advertising them; a strict "omitted => unsupported" reading would silently regress them. Only once
12
- // an agent DOES advertise the fork namespace (opts into negotiation) is each bare key gated on its
13
- // same-named flag and, symmetrically, only once an agent advertises mcpCapabilities is an
14
- // unsupported MCP transport rejected. Truthfully-advertised absence still gates (per spec) WITHIN an
15
- // advertised capability; total silence is the legacy passthrough.
10
+ // GATING PHILOSOPHY — backend-declared and lenient for legacy agents. A backend with NO declaration
11
+ // has NO custom-capability contract: its custom `_meta`, if any, is never gated, even when the agent
12
+ // advertises some other backend's namespace. Once a backend declares a namespace + bare keys, an
13
+ // agent that advertises NO usable namespace block is legacy passthrough (every declared key still
14
+ // sent); malformed namespace values (non-object or arrays) are treated as not advertised. Only once
15
+ // an agent DOES advertise the declared namespace object is each declared bare key gated on its
16
+ // same-named flag === true. Symmetrically, only once an agent advertises mcpCapabilities is an
17
+ // unsupported MCP transport rejected. Truthfully-advertised absence still gates WITHIN an advertised
18
+ // capability; total silence is the legacy passthrough.
16
19
  import { PROTOCOL_VERSION, } from "@agentclientprotocol/sdk";
17
- import { CODEX_CUSTOM_CAPABILITY_NAMESPACE, CODEX_META_KEYS, META_KEYS, } from "@automatalabs/shared-types";
18
- /** The bare `_meta` keys whose emission is gated by the fork's custom-capability advertisement.
20
+ import { CODEX_META_KEYS, META_KEYS, } from "@automatalabs/shared-types";
21
+ const PROMPT_CAPABILITY_BY_BLOCK_KIND = {
22
+ image: "image",
23
+ audio: "audio",
24
+ resource: "embeddedContext",
25
+ };
26
+ /** The bare `_meta` keys whose emission is gated by Codex's custom-capability advertisement.
19
27
  * Each is named EXACTLY like the advertised flag that gates it, so `support[key] === true` is the
20
28
  * whole test. session/new carries baseInstructions/developerInstructions and session/prompt carries
21
29
  * outputSchema — one list covers both (a key absent from a given `_meta` is simply skipped). */
@@ -25,20 +33,23 @@ export const GATED_CUSTOM_META_KEYS = [
25
33
  CODEX_META_KEYS.developerInstructions,
26
34
  ];
27
35
  /** Parse an initialize response into the connection's derived capability state. */
28
- export function negotiateCapabilities(response) {
36
+ export function negotiateCapabilities(response, customCapabilities) {
29
37
  const agent = response.agentCapabilities ?? {};
30
38
  return {
31
39
  protocolVersion: response.protocolVersion,
32
40
  agent,
33
41
  agentInfo: response.agentInfo ?? undefined,
34
42
  supportsClose: Boolean(agent.sessionCapabilities?.close),
35
- customMetaSupport: readCustomNamespace(agent._meta),
43
+ customMetaSupport: customCapabilities
44
+ ? readCustomNamespace(agent._meta, customCapabilities.namespace)
45
+ : undefined,
46
+ gatedKeys: customCapabilities ? [...customCapabilities.gatedKeys] : undefined,
36
47
  };
37
48
  }
38
- function readCustomNamespace(meta) {
49
+ function readCustomNamespace(meta, namespace) {
39
50
  if (!meta || typeof meta !== "object")
40
51
  return undefined;
41
- const block = meta[CODEX_CUSTOM_CAPABILITY_NAMESPACE];
52
+ const block = meta[namespace];
42
53
  return block && typeof block === "object" && !Array.isArray(block)
43
54
  ? block
44
55
  : undefined;
@@ -51,15 +62,15 @@ function readCustomNamespace(meta) {
51
62
  export function isSupportedProtocolVersion(version) {
52
63
  return version === PROTOCOL_VERSION;
53
64
  }
54
- /** Remove the fork's custom bare `_meta` keys the connected agent did NOT advertise support for.
65
+ /** Remove the declared custom bare `_meta` keys the connected agent did NOT advertise support for.
55
66
  * A no-op when the agent advertised no namespace (`support` undefined => legacy => every key
56
67
  * passes) or the meta is empty/undefined. Never mutates its input; collapses to undefined if
57
68
  * gating empties the object (so no `_meta` is sent at all). */
58
- export function gateCustomMeta(meta, support) {
69
+ export function gateCustomMeta(meta, support, gatedKeys = GATED_CUSTOM_META_KEYS) {
59
70
  if (!meta || !support)
60
71
  return meta;
61
72
  let gated;
62
- for (const key of GATED_CUSTOM_META_KEYS) {
73
+ for (const key of gatedKeys) {
63
74
  if (key in meta && support[key] !== true) {
64
75
  gated ??= { ...meta };
65
76
  delete gated[key];
@@ -68,6 +79,53 @@ export function gateCustomMeta(meta, support) {
68
79
  const result = gated ?? meta;
69
80
  return Object.keys(result).length > 0 ? result : undefined;
70
81
  }
82
+ /** Adapt prompt content to the agent's PromptCapabilities. ACP baseline content (text and
83
+ * resource_link) is never gated; optional blocks follow the spec's capability table:
84
+ * image->promptCapabilities.image, audio->promptCapabilities.audio, and resource->
85
+ * promptCapabilities.embeddedContext. Unsupported optional blocks are represented as explicit
86
+ * bracketed text notes so context is never silently lost. Returns the SAME array reference when
87
+ * no block changes and never mutates the input or any surviving block. */
88
+ export function adaptPromptContent(blocks, agent, backendId) {
89
+ let adapted;
90
+ for (let i = 0; i < blocks.length; i += 1) {
91
+ const block = blocks[i];
92
+ const replacement = unsupportedPromptBlockNote(block, agent, backendId);
93
+ if (replacement) {
94
+ adapted ??= blocks.slice(0, i);
95
+ adapted.push(replacement);
96
+ }
97
+ else if (adapted) {
98
+ adapted.push(block);
99
+ }
100
+ }
101
+ return adapted ?? blocks;
102
+ }
103
+ function unsupportedPromptBlockNote(block, agent, backendId) {
104
+ const capability = PROMPT_CAPABILITY_BY_BLOCK_KIND[block.type];
105
+ if (!capability || agent.promptCapabilities?.[capability] === true)
106
+ return undefined;
107
+ switch (block.type) {
108
+ case "image": {
109
+ const uriSuffix = typeof block.uri === "string" && block.uri.length > 0 ? `; uri=${block.uri}` : "";
110
+ return {
111
+ type: "text",
112
+ text: `[image omitted: ${block.mimeType}${uriSuffix} — the ${backendId} agent does not advertise promptCapabilities.image]`,
113
+ };
114
+ }
115
+ case "audio":
116
+ return {
117
+ type: "text",
118
+ text: `[audio omitted: ${block.mimeType} — the ${backendId} agent does not advertise promptCapabilities.audio]`,
119
+ };
120
+ case "resource":
121
+ return {
122
+ type: "text",
123
+ text: `[resource omitted: uri=${block.resource.uri} — the ${backendId} agent does not advertise promptCapabilities.embeddedContext]`,
124
+ };
125
+ default:
126
+ return undefined;
127
+ }
128
+ }
71
129
  /** The first client-provided MCP server whose transport the agent did NOT advertise, or undefined
72
130
  * when every server is serviceable. stdio is ALWAYS serviceable (the baseline transport); http/sse
73
131
  * are gated on mcpCapabilities.{http,sse}. Lenient for legacy agents: when the agent advertised no
@@ -0,0 +1,27 @@
1
+ import type { ClientCapabilities, CreateTerminalRequest, CreateTerminalResponse, KillTerminalRequest, KillTerminalResponse, ReadTextFileRequest, ReadTextFileResponse, ReleaseTerminalRequest, ReleaseTerminalResponse, TerminalOutputRequest, TerminalOutputResponse, WaitForTerminalExitRequest, WaitForTerminalExitResponse, WriteTextFileRequest, WriteTextFileResponse } from "@agentclientprotocol/sdk";
2
+ export interface AcpSessionContext {
3
+ readonly sessionId: string;
4
+ readonly cwd: string;
5
+ readonly label?: string;
6
+ readonly runId?: string;
7
+ }
8
+ export interface FsHandlers {
9
+ readTextFile?(params: ReadTextFileRequest, ctx: AcpSessionContext): Promise<ReadTextFileResponse> | ReadTextFileResponse;
10
+ writeTextFile?(params: WriteTextFileRequest, ctx: AcpSessionContext): Promise<WriteTextFileResponse | void> | WriteTextFileResponse | void;
11
+ }
12
+ export interface TerminalHandlers {
13
+ createTerminal(params: CreateTerminalRequest, ctx: AcpSessionContext): Promise<CreateTerminalResponse> | CreateTerminalResponse;
14
+ terminalOutput(params: TerminalOutputRequest, ctx: AcpSessionContext): Promise<TerminalOutputResponse> | TerminalOutputResponse;
15
+ waitForTerminalExit(params: WaitForTerminalExitRequest, ctx: AcpSessionContext): Promise<WaitForTerminalExitResponse> | WaitForTerminalExitResponse;
16
+ killTerminal(params: KillTerminalRequest, ctx: AcpSessionContext): Promise<KillTerminalResponse | void> | KillTerminalResponse | void;
17
+ releaseTerminal(params: ReleaseTerminalRequest, ctx: AcpSessionContext): Promise<ReleaseTerminalResponse | void> | ReleaseTerminalResponse | void;
18
+ }
19
+ export interface ClientHandlers {
20
+ fs?: FsHandlers;
21
+ terminal?: TerminalHandlers;
22
+ }
23
+ /** The client capability advertisement derived solely from registered consumer handlers. */
24
+ export declare function clientCapabilitiesFor(handlers: ClientHandlers | undefined): ClientCapabilities;
25
+ /** Fail-fast validation for JavaScript consumers bypassing the TerminalHandlers type. */
26
+ export declare function validateClientHandlers(handlers: ClientHandlers | undefined): void;
27
+ //# sourceMappingURL=client-handlers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-handlers.d.ts","sourceRoot":"","sources":["../src/client-handlers.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,sBAAsB,EACtB,0BAA0B,EAC1B,2BAA2B,EAC3B,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,0BAA0B,CAAC;AAElC,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KA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c,GAAG,SAAS,GAAG,kBAAkB,CAY9F;AAED,yFAAyF;AACzF,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,cAAc,GAAG,SAAS,GAAG,IAAI,CAMjF"}
@@ -0,0 +1,39 @@
1
+ const TERMINAL_HANDLER_METHODS = [
2
+ "createTerminal",
3
+ "terminalOutput",
4
+ "waitForTerminalExit",
5
+ "killTerminal",
6
+ "releaseTerminal",
7
+ ];
8
+ /** The client capability advertisement derived solely from registered consumer handlers. */
9
+ export function clientCapabilitiesFor(handlers) {
10
+ if (!handlers)
11
+ return {};
12
+ const capabilities = {};
13
+ const fs = handlers.fs;
14
+ const fsCapabilities = {};
15
+ if (typeof fs?.readTextFile === "function")
16
+ fsCapabilities.readTextFile = true;
17
+ if (typeof fs?.writeTextFile === "function")
18
+ fsCapabilities.writeTextFile = true;
19
+ if (Object.keys(fsCapabilities).length > 0)
20
+ capabilities.fs = fsCapabilities;
21
+ if (hasFullTerminalHandlers(handlers.terminal))
22
+ capabilities.terminal = true;
23
+ return capabilities;
24
+ }
25
+ /** Fail-fast validation for JavaScript consumers bypassing the TerminalHandlers type. */
26
+ export function validateClientHandlers(handlers) {
27
+ if (!handlers?.terminal)
28
+ return;
29
+ const missing = missingTerminalMethods(handlers.terminal);
30
+ if (missing.length > 0) {
31
+ throw new Error(`clientHandlers.terminal missing required methods: ${missing.join(", ")}`);
32
+ }
33
+ }
34
+ function hasFullTerminalHandlers(terminal) {
35
+ return Boolean(terminal && missingTerminalMethods(terminal).length === 0);
36
+ }
37
+ function missingTerminalMethods(terminal) {
38
+ return TERMINAL_HANDLER_METHODS.filter((method) => typeof terminal[method] !== "function");
39
+ }
package/dist/events.d.ts CHANGED
@@ -22,7 +22,16 @@ type AcpSessionUpdateEvents = {
22
22
  sessionUpdate: K;
23
23
  }> & AcpEventContext;
24
24
  };
25
- /** A tool-permission request the runner auto-answered, paired with the decision it returned. */
25
+ /** A tool-permission request parked on an async resolver. This is the FIRST phase of the
26
+ * resolver path only: it fires after the request is tracked for teardown cancellation and before
27
+ * the host resolver is invoked. It carries no outcome because no ACP response has been returned
28
+ * yet. Synchronous ToolPolicy decisions never emit this event. */
29
+ export interface AcpPermissionPendingEvent extends AcpEventContext {
30
+ request: RequestPermissionRequest;
31
+ }
32
+ /** A tool-permission request the runner answered, paired with the FINAL decision it returned.
33
+ * This is the SECOND phase for resolver-backed permissions and the ONLY phase for synchronous
34
+ * ToolPolicy permissions. It fires exactly once per request with the outcome sent to the agent. */
26
35
  export interface AcpPermissionEvent extends AcpEventContext {
27
36
  request: RequestPermissionRequest;
28
37
  outcome: RequestPermissionResponse;
@@ -48,7 +57,9 @@ export type AcpRunnerEventMap = AcpSessionUpdateEvents & {
48
57
  session_update: {
49
58
  update: AcpSessionUpdate;
50
59
  } & AcpEventContext;
51
- /** A permission request the runner auto-answered, with the decision returned. */
60
+ /** A permission request parked on an async resolver; resolver path only, no outcome yet. */
61
+ permission_pending: AcpPermissionPendingEvent;
62
+ /** A permission request the runner answered, with the FINAL decision returned. */
52
63
  permission_request: AcpPermissionEvent;
53
64
  /** A vendor extension notification arrived for a session. */
54
65
  raw_message: AcpRawMessageEvent;
@@ -1 +1 @@
1
- {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,wBAAwB,EACxB,yBAAyB,EACzB,mBAAmB,EACpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,+FAA+F;AAC/F,MAAM,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAC;AAC7D,qGAAqG;AACrG,MAAM,MAAM,aAAa,GAAG,gBAAgB,CAAC,eAAe,CAAC,CAAC;AAE9D;oGACoG;AACpG,MAAM,WAAW,eAAe;IAC9B,6CAA6C;IAC7C,SAAS,EAAE,MAAM,CAAC;IAClB,qDAAqD;IACrD,SAAS,EAAE,SAAS,CAAC;IACr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,GAAG,IAAI;IAOpF,kBAAkB,CAAC,IAAI,CAAC,EAAE,MAAM,QAAQ,GAAG,IAAI;IAK/C,aAAa,CAAC,IAAI,EAAE,MAAM,QAAQ,GAAG,MAAM;IAI3C,IAAI,CAAC,CAAC,SAAS,MAAM,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI;CAYlE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,EAAE,eAAe,GAAG,IAAI,CAI1G"}
package/dist/index.d.ts CHANGED
@@ -1,21 +1,25 @@
1
1
  export { AcpAgentRunner, createAcpRunner, selectBackend } from "./runner.js";
2
2
  export type { AcpRunnerOptions } from "./runner.js";
3
+ export { InteractiveSession } from "./interactive.js";
4
+ export type { InteractiveSessionOptions, InteractiveTurn } from "./interactive.js";
3
5
  export { BACKENDS_ENV, registryWithRunBackends, resolveBackendRegistry } from "./registry.js";
4
6
  export type { BackendRegistry, CustomBackendConfig, RegisteredBackend } from "./registry.js";
5
7
  export { PooledConnection, SessionHandle } from "./acp-client.js";
6
8
  export type { AcpSessionOptions, PooledConnectionDeps } from "./acp-client.js";
7
- export { GATED_CUSTOM_META_KEYS, gateCustomMeta, isSupportedProtocolVersion, negotiateCapabilities, unsupportedMcpServer, } from "./capabilities.js";
9
+ export { GATED_CUSTOM_META_KEYS, adaptPromptContent, gateCustomMeta, isSupportedProtocolVersion, negotiateCapabilities, unsupportedMcpServer, } from "./capabilities.js";
8
10
  export type { NegotiatedCapabilities } from "./capabilities.js";
9
11
  export { AcpAgentPool, resolvePoolSize } from "./pool.js";
10
12
  export type { AcpPoolOptions, AcpPoolDeps } from "./pool.js";
13
+ export { clientCapabilitiesFor } from "./client-handlers.js";
14
+ export type { AcpSessionContext, ClientHandlers, FsHandlers, TerminalHandlers } from "./client-handlers.js";
11
15
  export { TypedEventEmitter, emitSessionUpdate } from "./events.js";
12
- export type { AcpRunnerEventMap, AcpEventName, AcpEventListener, AcpEventContext, AcpEventSink, AcpSessionUpdate, AcpUpdateKind, AcpPermissionEvent, AcpRawMessageEvent, AcpBackendErrorEvent, } from "./events.js";
16
+ export type { AcpRunnerEventMap, AcpEventName, AcpEventListener, AcpEventContext, AcpEventSink, AcpSessionUpdate, AcpUpdateKind, AcpPermissionPendingEvent, AcpPermissionEvent, AcpRawMessageEvent, AcpBackendErrorEvent, } from "./events.js";
13
17
  export type { Backend, BackendId, BuiltinBackendId, SessionMetaInputs, SpawnConfig, StructuredSource, } from "./backend.js";
14
18
  export { ClaudeBackend } from "./backends/claude.js";
15
19
  export { CodexBackend } from "./backends/codex.js";
16
20
  export { CustomAcpBackend } from "./backends/custom.js";
17
21
  export { decidePermission } from "./permissions.js";
18
- export type { ToolPolicy } from "./permissions.js";
22
+ export type { PermissionResolver, ToolPolicy } from "./permissions.js";
19
23
  export { UsageAccumulator } from "./usage.js";
20
24
  export { toJsonSchema, toStrictJsonSchema } from "./schema-strict.js";
21
25
  export { extractValidated, findJsonBlock, parseFinalJson, resolveStructuredOutput, validateValue, } from "./structured-output.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC7E,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGpD,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAC9F,YAAY,EAAE,eAAe,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAE7F,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAClE,YAAY,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAI/E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,EAClB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAErB,YAAY,EACV,OAAO,EACP,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,WAAW,EACX,gBAAgB,GACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,YAAY,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAEtE,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,uBAAuB,EACvB,aAAa,GACd,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhF,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/index.js CHANGED
@@ -5,13 +5,17 @@
5
5
  // @automatalabs/workflow-engine; the two siblings meet ONLY at AgentRunner, injected by the
6
6
  // @automatalabs/workflows facade (which mcp-server builds on) via createAcpRunner().
7
7
  export { AcpAgentRunner, createAcpRunner, selectBackend } from "./runner.js";
8
+ export { InteractiveSession } from "./interactive.js";
8
9
  // The custom-backend registry: run ANY ACP agent as an agent() target.
9
10
  export { BACKENDS_ENV, registryWithRunBackends, resolveBackendRegistry } from "./registry.js";
10
11
  export { PooledConnection, SessionHandle } from "./acp-client.js";
11
12
  // ACP capability negotiation: parse/validate the initialize response and gate what the client
12
13
  // sends (custom `_meta` keys, MCP transports) on what the connected agent advertised.
13
- export { GATED_CUSTOM_META_KEYS, gateCustomMeta, isSupportedProtocolVersion, negotiateCapabilities, unsupportedMcpServer, } from "./capabilities.js";
14
+ export { GATED_CUSTOM_META_KEYS, adaptPromptContent, gateCustomMeta, isSupportedProtocolVersion, negotiateCapabilities, unsupportedMcpServer, } from "./capabilities.js";
14
15
  export { AcpAgentPool, resolvePoolSize } from "./pool.js";
16
+ // Consumer-provided client-side ACP handlers: fs/terminal routing plus truthful initialize
17
+ // clientCapabilities derived from the registered handler set.
18
+ export { clientCapabilitiesFor } from "./client-handlers.js";
15
19
  // The typed ACP event bus surfaced on AcpAgentRunner (`runner.on(name, evt => …)`).
16
20
  export { TypedEventEmitter, emitSessionUpdate } from "./events.js";
17
21
  export { ClaudeBackend } from "./backends/claude.js";
@@ -0,0 +1,114 @@
1
+ import type { ContentBlock, StopReason } from "@agentclientprotocol/sdk";
2
+ import type { McpServerConfig, PromptImage } from "@automatalabs/shared-types";
3
+ import type { RunOptions } from "@automatalabs/shared-types";
4
+ import type { Backend, BackendId } from "./backend.js";
5
+ import type { NegotiatedCapabilities } from "./capabilities.js";
6
+ import type { PooledConnection, SessionHandle } from "./acp-client.js";
7
+ import type { AcpEventListener, AcpEventName } from "./events.js";
8
+ import type { PermissionResolver } from "./permissions.js";
9
+ /** Options for AcpAgentRunner.openSession(): backend selection and session/new inputs for one
10
+ * held-open interactive ACP session. `cwd` is required and absolute; unlike run(), there is no
11
+ * default to process.cwd() because the session can span many turns. The session-scoped
12
+ * permission resolver wins over the runner-wide default; tool allow/deny policy is used only
13
+ * when no resolver is present. */
14
+ export interface InteractiveSessionOptions {
15
+ /** Model spec (`provider/modelId`, bare model id, or registered custom backend route). */
16
+ model?: string;
17
+ /** Coarse tier consulted only when `model` is unset. */
18
+ tier?: string;
19
+ /** Absolute working directory for ACP session/new. Required for held-open sessions. */
20
+ cwd: string;
21
+ /** Tool allow-list used by the headless permission auto-responder. */
22
+ toolNames?: string[];
23
+ /** Tool deny-list, applied after the allow-list. */
24
+ disallowedToolNames?: string[];
25
+ /** Session-scoped permission resolver; overrides the runner-wide resolver for this session. */
26
+ onPermissionRequest?: PermissionResolver;
27
+ /** The actually-resolved concrete model id (display/telemetry). */
28
+ onModelResolved?: RunOptions["onModelResolved"];
29
+ /** A requested model/tier spec that was not found and fell back to the session default. */
30
+ onModelFallback?: RunOptions["onModelFallback"];
31
+ /** Event/telemetry label stamped onto this session's emitted ACP events. */
32
+ label?: string;
33
+ /** Correlation id stamped into session/new `_meta` and emitted event context. */
34
+ runId?: string;
35
+ /** Generic session-scoped `_meta` passthrough merged under backend-computed session meta. */
36
+ meta?: Record<string, unknown>;
37
+ /** CODEX-ONLY base instruction override, forwarded at session/new. */
38
+ baseInstructions?: string;
39
+ /** CODEX-ONLY developer instruction override, forwarded at session/new. */
40
+ developerInstructions?: string;
41
+ /** Client-provided MCP servers to attach at session/new. */
42
+ mcpServers?: McpServerConfig[];
43
+ /** Host-owned cancellation. Aborting releases this interactive session. */
44
+ signal?: AbortSignal;
45
+ }
46
+ /** One completed interactive prompt turn. `text` is the assistant text from THIS turn only:
47
+ * it is read from SessionHandle.currentTurnText(), the same turn-segmented accessor run() uses
48
+ * for structured-output repair turns. */
49
+ export interface InteractiveTurn {
50
+ readonly stopReason: StopReason;
51
+ readonly text: string;
52
+ }
53
+ type Subscribe = <K extends AcpEventName>(name: K, listener: AcpEventListener<K>) => () => void;
54
+ /** Internal construction bag for the runner-owned wrapper around an already-open ACP session. */
55
+ interface InteractiveSessionDeps {
56
+ readonly session: SessionHandle;
57
+ readonly connection: PooledConnection;
58
+ readonly backend: Backend;
59
+ readonly subscribe: Subscribe;
60
+ readonly onRelease: (self: InteractiveSession) => void;
61
+ readonly signal?: AbortSignal;
62
+ readonly label?: string;
63
+ }
64
+ /** A held-open multi-turn ACP session backed by a dedicated agent process. Only one prompt may
65
+ * be in flight at a time; hosts that want queued turns should serialize calls themselves so
66
+ * cancellation, permissions, and turn text stay attributable to a single active turn. If the
67
+ * dedicated process dies, the runner observes that per session by auto-releasing this wrapper:
68
+ * session-scoped listeners are removed, later prompt() calls fail with the released-session
69
+ * error, and `session_close` is emitted on this session's event stream. The connection-scoped
70
+ * `backend_error` event is emitted on the runner bus only; it is not delivered through
71
+ * session.on(). */
72
+ export declare class InteractiveSession {
73
+ readonly sessionId: string;
74
+ readonly backendId: BackendId;
75
+ private readonly session;
76
+ private readonly connection;
77
+ private readonly backend;
78
+ private readonly subscribe;
79
+ private readonly onReleaseCallback;
80
+ private readonly signal;
81
+ private readonly label;
82
+ private readonly subscriptions;
83
+ private removeAbort;
84
+ private promptInFlight;
85
+ private releasePromise;
86
+ /** Construct the public wrapper around an already-open ACP session. Hosts normally receive
87
+ * instances from AcpAgentRunner.openSession(), which supplies the internal session/connection
88
+ * dependencies and owns lifecycle tracking. */
89
+ constructor(deps: InteractiveSessionDeps);
90
+ /** Negotiated initialize capabilities for this session's dedicated connection. */
91
+ get capabilities(): NegotiatedCapabilities | undefined;
92
+ /** Send one prompt turn. A concurrent prompt on the same InteractiveSession is rejected with a
93
+ * clear host-side error; queueing is deliberately left to the host so turn boundaries remain
94
+ * explicit. Per-turn images are appended only to this prompt, and SessionHandle.prompt()
95
+ * performs capability adaptation before sending. */
96
+ prompt(content: string | ContentBlock[], opts?: {
97
+ images?: readonly PromptImage[];
98
+ promptMeta?: Record<string, unknown>;
99
+ }): Promise<InteractiveTurn>;
100
+ /** Best-effort ACP session/cancel for the active turn. Pending permission resolvers are
101
+ * settled as cancelled by the SessionHandle/PooledConnection cancel path. */
102
+ cancel(): Promise<void>;
103
+ /** Subscribe to runner events for THIS ACP session only. Events from other one-shot or
104
+ * interactive sessions on the same runner are filtered out by sessionId. The returned
105
+ * unsubscribe thunk and every still-live subscription are removed automatically on release. */
106
+ on<K extends AcpEventName>(name: K, listener: AcpEventListener<K>): () => void;
107
+ /** Release the ACP session and close the dedicated process. Idempotent. Session close is
108
+ * best-effort and bounded by SessionHandle; process disposal mirrors pool teardown. */
109
+ release(): Promise<void>;
110
+ private doRelease;
111
+ private removeSubscriptions;
112
+ }
113
+ export {};
114
+ //# sourceMappingURL=interactive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interactive.d.ts","sourceRoot":"","sources":["../src/interactive.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAO3D;;;;mCAImC;AACnC,MAAM,WAAW,yBAAyB;IACxC,0FAA0F;IAC1F,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wDAAwD;IACxD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uFAAuF;IACvF,GAAG,EAAE,MAAM,CAAC;IACZ,sEAAsE;IACtE,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,oDAAoD;IACpD,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B,+FAA+F;IAC/F,mBAAmB,CAAC,EAAE,kBAAkB,CAAC;IACzC,mEAAmE;IACnE,eAAe,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAChD,2FAA2F;IAC3F,eAAe,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAChD,4EAA4E;IAC5E,KAAK,CAAC,EAAE,MAAM,CAA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