@wrongstack/acp 0.292.1 → 0.295.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 (55) hide show
  1. package/README.md +22 -2
  2. package/dist/agent/protocol-contract.d.ts +210 -0
  3. package/dist/agent/protocol-contract.d.ts.map +1 -0
  4. package/dist/agent/protocol-handler.d.ts +6 -189
  5. package/dist/agent/protocol-handler.d.ts.map +1 -1
  6. package/dist/agent/server-agent-turn.d.ts +7 -1
  7. package/dist/agent/server-agent-turn.d.ts.map +1 -1
  8. package/dist/agent/stdio-transport.d.ts +12 -1
  9. package/dist/agent/stdio-transport.d.ts.map +1 -1
  10. package/dist/agent/tools-registry.d.ts +1 -1
  11. package/dist/agent/tools-registry.d.ts.map +1 -1
  12. package/dist/agent/wrongstack-acp-agent.d.ts +2 -0
  13. package/dist/agent/wrongstack-acp-agent.d.ts.map +1 -1
  14. package/dist/agent.js +172 -22
  15. package/dist/agent.js.map +4 -4
  16. package/dist/client/acp-session.d.ts +19 -6
  17. package/dist/client/acp-session.d.ts.map +1 -1
  18. package/dist/client/index.d.ts +11 -9
  19. package/dist/client/index.d.ts.map +1 -1
  20. package/dist/client/permission.d.ts +7 -3
  21. package/dist/client/permission.d.ts.map +1 -1
  22. package/dist/client/terminal-server.d.ts +5 -0
  23. package/dist/client/terminal-server.d.ts.map +1 -1
  24. package/dist/client/tool-translator.d.ts +1 -1
  25. package/dist/client/tool-translator.d.ts.map +1 -1
  26. package/dist/client/trust-boundary-permission.d.ts +16 -0
  27. package/dist/client/trust-boundary-permission.d.ts.map +1 -0
  28. package/dist/client/websocket-transport.d.ts +6 -0
  29. package/dist/client/websocket-transport.d.ts.map +1 -1
  30. package/dist/client.js +440 -225
  31. package/dist/client.js.map +4 -4
  32. package/dist/index.d.ts +29 -29
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +2433 -2121
  35. package/dist/index.js.map +4 -4
  36. package/dist/integration/acp-subagent-runner.d.ts +3 -3
  37. package/dist/integration/acp-subagent-runner.d.ts.map +1 -1
  38. package/dist/integration/ensemble-runner.d.ts.map +1 -1
  39. package/dist/legacy.d.ts +8 -0
  40. package/dist/legacy.d.ts.map +1 -0
  41. package/dist/legacy.js +6 -0
  42. package/dist/legacy.js.map +7 -0
  43. package/dist/sdk.d.ts +10 -8
  44. package/dist/sdk.d.ts.map +1 -1
  45. package/dist/sdk.js +22 -0
  46. package/dist/sdk.js.map +3 -3
  47. package/dist/v1.d.ts +3 -0
  48. package/dist/v1.d.ts.map +1 -0
  49. package/dist/v1.js +12 -0
  50. package/dist/v1.js.map +7 -0
  51. package/dist/version.d.ts +2 -0
  52. package/dist/version.d.ts.map +1 -0
  53. package/dist/wrongstack-acp-agent.js +107 -16
  54. package/dist/wrongstack-acp-agent.js.map +4 -4
  55. package/package.json +10 -2
@@ -11,7 +11,7 @@
11
11
  * Connected to the Director / MultiAgentCoordinator via the
12
12
  * `SubagentRunner` interface (same shape as `AgentSubagentRunner`).
13
13
  */
14
- import type { SubagentRunner } from '@wrongstack/core';
14
+ import type { SubagentRunner } from '@wrongstack/core/types';
15
15
  import { ACPSession, type ACPProgressHandler } from '../client/acp-session.js';
16
16
  import type { PermissionPolicy } from '../client/permission.js';
17
17
  import type { McpServer } from '../types/acp-v1.js';
@@ -101,7 +101,8 @@ export declare function describeAgent(id: string): {
101
101
  } | null;
102
102
  /**
103
103
  * Per-agent ACP invocation overrides, sourced from the user's
104
- * `~/.wrongstack/config.json` (`config.acp.agents`). Lets a user point an
104
+ * active profile config (`~/.wrongstack/profiles/<name>/config.json`,
105
+ * `config.acp.agents`). Lets a user point an
105
106
  * agent id at the correct ACP entry — e.g. the Zed Claude-Code adapter —
106
107
  * without a code change. NEVER honoured from in-project config (it is an
107
108
  * arbitrary-command exec surface); see `config-loader.ts`.
@@ -142,7 +143,6 @@ export declare const REGISTRY_ID_ALIASES: Readonly<Record<string, string>>;
142
143
  * override of the curated 12. Users force a specific command via the override.
143
144
  */
144
145
  export declare function resolveAcpAgentCommand(id: string, overrides?: AcpAgentCommandOverrides, live?: AcpLiveCatalog): ACPSubagentRunnerOptions | null;
145
- export { runOneAcpTask, type RunOneAcpTaskOptions, type RunOneAcpTaskResult, } from './run-one-acp-task.js';
146
146
  export interface AcpProbeResult {
147
147
  id: string;
148
148
  ok: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"acp-subagent-runner.d.ts","sourceRoot":"","sources":["../../src/integration/acp-subagent-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAKV,cAAc,EAEf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,UAAU,EAIV,KAAK,kBAAkB,EACxB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,WAAW,wBAAwB;IACvC,uCAAuC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IACzC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,qEAAqE;IACrE,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC;;;;OAIG;IACH,UAAU,CAAC,EAAE,kBAAkB,GAAG,SAAS,CAAC;IAC5C;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAC;IAChD;;;;OAIG;IACH,UAAU,CAAC,EAAE,SAAS,EAAE,GAAG,SAAS,CAAC;I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ONTRACT_VERSION: 'pre-v1-draft';
3
+ /**
4
+ * @deprecated Import stable protocol contracts from `@wrongstack/acp/v1`.
5
+ * These shapes remain available only for compatibility with older transports.
6
+ */
7
+ export type { ACPImageContent, ACPInputSchema, ACPMessage, ACPProgressContent, ACPResourceContent, ACPSessionInfo, ACPTextContent, ACPToolCallRequest, ACPToolCallResponse, ACPToolDefinition, ACPToolList, ACPToolResult, ContentBlock, } from './types/acp-messages.js';
8
+ //# sourceMappingURL=legacy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacy.d.ts","sourceRoot":"","sources":["../src/legacy.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,eAAO,MAAM,2BAA2B,EAAG,cAAuB,CAAC;AAEnE;;;GAGG;AACH,YAAY,EACV,eAAe,EACf,cAAc,EACd,UAAU,EACV,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,YAAY,GACb,MAAM,yBAAyB,CAAC"}
package/dist/legacy.js ADDED
@@ -0,0 +1,6 @@
1
+ // src/legacy.ts
2
+ var LEGACY_ACP_CONTRACT_VERSION = "pre-v1-draft";
3
+ export {
4
+ LEGACY_ACP_CONTRACT_VERSION
5
+ };
6
+ //# sourceMappingURL=legacy.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/legacy.ts"],
4
+ "sourcesContent": ["/** Identifies the isolated pre-v1 draft contract at runtime. */\nexport const LEGACY_ACP_CONTRACT_VERSION = 'pre-v1-draft' as const;\n\n/**\n * @deprecated Import stable protocol contracts from `@wrongstack/acp/v1`.\n * These shapes remain available only for compatibility with older transports.\n */\nexport type {\n ACPImageContent,\n ACPInputSchema,\n ACPMessage,\n ACPProgressContent,\n ACPResourceContent,\n ACPSessionInfo,\n ACPTextContent,\n ACPToolCallRequest,\n ACPToolCallResponse,\n ACPToolDefinition,\n ACPToolList,\n ACPToolResult,\n ContentBlock,\n} from './types/acp-messages.js';\n"],
5
+ "mappings": ";AACO,IAAM,8BAA8B;",
6
+ "names": []
7
+ }
package/dist/sdk.d.ts CHANGED
@@ -1,9 +1,11 @@
1
- export {};
2
- /**
3
- * @wrongstack/acp/sdk reserved for re-exports from @agentclientprotocol/sdk.
4
- *
5
- * No re-exports are currently active. Restore from git history if needed.
6
- * All prior exports were removed because no consumer in the monorepo imported
7
- * from this path.
8
- */
1
+ /** Official upstream ACP SDK surface, deliberately separate from WrongStack's implementation. */
2
+ export * from '@agentclientprotocol/sdk';
3
+ export type { AcpCookieStore, HttpStreamOptions, } from '@agentclientprotocol/sdk/experimental/http-client';
4
+ export { createHttpStream, MemoryAcpCookieStore, } from '@agentclientprotocol/sdk/experimental/http-client';
5
+ export type { NodeHttpHandlerOptions, NodeWebSocketUpgradeServer, } from '@agentclientprotocol/sdk/experimental/node';
6
+ export { createNodeHttpHandler, createNodeWebSocketUpgradeHandler, DEFAULT_MAX_REQUEST_BODY_BYTES, } from '@agentclientprotocol/sdk/experimental/node';
7
+ export type { AcpServerOptions, AgentFactory, HandleRequestOptions, PreparedWebSocketUpgrade, PrepareWebSocketUpgradeOptions, } from '@agentclientprotocol/sdk/experimental/server';
8
+ export { AcpServer } from '@agentclientprotocol/sdk/experimental/server';
9
+ export type { WebSocketConstructor, WebSocketLike, WebSocketStreamOptions, } from '@agentclientprotocol/sdk/experimental/ws-client';
10
+ export { createWebSocketStream } from '@agentclientprotocol/sdk/experimental/ws-client';
9
11
  //# sourceMappingURL=sdk.d.ts.map
package/dist/sdk.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG"}
1
+ {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,cAAc,0BAA0B,CAAC;AACzC,YAAY,EACV,cAAc,EACd,iBAAiB,GAClB,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EACL,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,mDAAmD,CAAC;AAC3D,YAAY,EACV,sBAAsB,EACtB,0BAA0B,GAC3B,MAAM,4CAA4C,CAAC;AACpD,OAAO,EACL,qBAAqB,EACrB,iCAAiC,EACjC,8BAA8B,GAC/B,MAAM,4CAA4C,CAAC;AACpD,YAAY,EACV,gBAAgB,EAChB,YAAY,EACZ,oBAAoB,EACpB,wBAAwB,EACxB,8BAA8B,GAC/B,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,8CAA8C,CAAC;AACzE,YAAY,EACV,oBAAoB,EACpB,aAAa,EACb,sBAAsB,GACvB,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,iDAAiD,CAAC"}
package/dist/sdk.js CHANGED
@@ -1 +1,23 @@
1
+ // src/sdk.ts
2
+ export * from "@agentclientprotocol/sdk";
3
+ import {
4
+ createHttpStream,
5
+ MemoryAcpCookieStore
6
+ } from "@agentclientprotocol/sdk/experimental/http-client";
7
+ import {
8
+ createNodeHttpHandler,
9
+ createNodeWebSocketUpgradeHandler,
10
+ DEFAULT_MAX_REQUEST_BODY_BYTES
11
+ } from "@agentclientprotocol/sdk/experimental/node";
12
+ import { AcpServer } from "@agentclientprotocol/sdk/experimental/server";
13
+ import { createWebSocketStream } from "@agentclientprotocol/sdk/experimental/ws-client";
14
+ export {
15
+ AcpServer,
16
+ DEFAULT_MAX_REQUEST_BODY_BYTES,
17
+ MemoryAcpCookieStore,
18
+ createHttpStream,
19
+ createNodeHttpHandler,
20
+ createNodeWebSocketUpgradeHandler,
21
+ createWebSocketStream
22
+ };
1
23
  //# sourceMappingURL=sdk.js.map
package/dist/sdk.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": [],
4
- "sourcesContent": [],
5
- "mappings": "",
3
+ "sources": ["../src/sdk.ts"],
4
+ "sourcesContent": ["/** Official upstream ACP SDK surface, deliberately separate from WrongStack's implementation. */\nexport * from '@agentclientprotocol/sdk';\nexport type {\n AcpCookieStore,\n HttpStreamOptions,\n} from '@agentclientprotocol/sdk/experimental/http-client';\nexport {\n createHttpStream,\n MemoryAcpCookieStore,\n} from '@agentclientprotocol/sdk/experimental/http-client';\nexport type {\n NodeHttpHandlerOptions,\n NodeWebSocketUpgradeServer,\n} from '@agentclientprotocol/sdk/experimental/node';\nexport {\n createNodeHttpHandler,\n createNodeWebSocketUpgradeHandler,\n DEFAULT_MAX_REQUEST_BODY_BYTES,\n} from '@agentclientprotocol/sdk/experimental/node';\nexport type {\n AcpServerOptions,\n AgentFactory,\n HandleRequestOptions,\n PreparedWebSocketUpgrade,\n PrepareWebSocketUpgradeOptions,\n} from '@agentclientprotocol/sdk/experimental/server';\nexport { AcpServer } from '@agentclientprotocol/sdk/experimental/server';\nexport type {\n WebSocketConstructor,\n WebSocketLike,\n WebSocketStreamOptions,\n} from '@agentclientprotocol/sdk/experimental/ws-client';\nexport { createWebSocketStream } from '@agentclientprotocol/sdk/experimental/ws-client';\n"],
5
+ "mappings": ";AACA,cAAc;AAKd;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAKP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAQP,SAAS,iBAAiB;AAM1B,SAAS,6BAA6B;",
6
6
  "names": []
7
7
  }
package/dist/v1.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ /** Stable WrongStack-owned ACP v1 protocol contracts. */
2
+ export * from './types/acp-v1.js';
3
+ //# sourceMappingURL=v1.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v1.d.ts","sourceRoot":"","sources":["../src/v1.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,cAAc,mBAAmB,CAAC"}
package/dist/v1.js ADDED
@@ -0,0 +1,12 @@
1
+ // src/types/acp-v1.ts
2
+ var ACP_PROTOCOL_VERSION = 1;
3
+ function assertNeverSessionUpdate(x) {
4
+ throw new Error(
5
+ `Unhandled sessionUpdate: ${JSON.stringify(x)}`
6
+ );
7
+ }
8
+ export {
9
+ ACP_PROTOCOL_VERSION,
10
+ assertNeverSessionUpdate
11
+ };
12
+ //# sourceMappingURL=v1.js.map
package/dist/v1.js.map ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/types/acp-v1.ts"],
4
+ "sourcesContent": ["/**\n * ACP v1 type definitions \u2014 Agent Client Protocol, stable v1 spec.\n *\n * Scope: discriminated union for the `session/update` notification payload\n * (the `update` field of a `session/update` JSON-RPC notification), plus the\n * subset of supporting types it depends on.\n *\n * Spec: https://agentclientprotocol.com/protocol/v1/overview\n *\n * Design notes\n * \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n * \u2022 The stable v1 spec defines 11 `sessionUpdate` discriminator values. We\n * type exactly those 11, plus an `_unstable_*` escape hatch for v2-RFD\n * kinds (e.g. `next_edit_suggestions`, `elicitation`) that real agents\n * may emit before the spec stabilises them, and an `unknown` fallback for\n * everything else. We do NOT synthesise 32 fake variants to match a\n * number cited in passing \u2014 the union is honest about the surface.\n *\n * \u2022 Per the spec's conventions, discriminator values use snake_case. The\n * property keys inside each variant are camelCase (the JSON-RPC envelope\n * is JSON-RPC 2.0, everything else is camelCase unless the spec says\n * otherwise).\n *\n * \u2022 Optional fields that the spec marks optional are marked `?:`. Required\n * fields have no `?`. We do not include spec fields the spec marks\n * \"SHOULD NOT\" or \"reserved\".\n *\n * \u2022 The existing `acp-messages.ts` types describe an older draft of the\n * protocol (string `protocolVersion: '2024-11'`, fake `tools/call`\n * method, etc.). Do NOT import from it here \u2014 `acp-v1.ts` is\n * self-contained so the new code path can be reviewed in isolation and\n * deleted wholesale if the rewrite is ever reverted.\n */\n\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// Shared building blocks\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/** Stable protocol version (integer per the spec, not a date-string). */\nexport const ACP_PROTOCOL_VERSION = 1 as const;\nexport type ACPProtocolVersion = typeof ACP_PROTOCOL_VERSION;\n\n/** Per the spec: opaque, unique id. We type as branded string. */\nexport type SessionId = string & { readonly __acpSessionId: unique symbol };\nexport type ToolCallId = string & { readonly __acpToolCallId: unique symbol };\nexport type MessageId = string & { readonly __acpMessageId: unique symbol };\nexport type TerminalId = string & { readonly __acpTerminalId: unique symbol };\nexport type PlanEntryId = string & { readonly __acpPlanEntryId: unique symbol };\n\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// Implementation metadata\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport interface Implementation {\n /** Programmatic/logical name \u2014 also a display-name fallback if title is absent. */\n name: string;\n /** Human-readable display name for UI contexts. */\n title?: string | undefined;\n /** Version string (display/debug/metrics). */\n version: string;\n}\n\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// Client capabilities \u2014 sent in the initialize request\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport interface ClientCapabilities {\n fs?: {\n readTextFile?: boolean | undefined;\n writeTextFile?: boolean | undefined;\n } | undefined;\n terminal?: boolean | undefined;\n}\n\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// Agent capabilities \u2014 received in the initialize response\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport interface PromptCapabilities {\n image?: boolean | undefined;\n audio?: boolean | undefined;\n embeddedContext?: boolean | undefined;\n}\n\nexport interface McpCapabilities {\n http?: boolean | undefined;\n sse?: boolean | undefined;\n}\n\nexport interface SessionCapabilities {\n close?: Record<string, unknown> | undefined;\n list?: Record<string, unknown> | undefined;\n delete?: Record<string, unknown> | undefined;\n resume?: Record<string, unknown> | undefined;\n additionalDirectories?: Record<string, unknown> | undefined;\n}\n\nexport interface AuthCapabilities {\n logout?: Record<string, unknown> | undefined;\n}\n\nexport interface AgentCapabilities {\n loadSession?: boolean | undefined;\n promptCapabilities?: PromptCapabilities | undefined;\n mcpCapabilities?: McpCapabilities | undefined;\n sessionCapabilities?: SessionCapabilities | undefined;\n auth?: AuthCapabilities | undefined;\n}\n\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// Authentication\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport interface AuthMethod {\n id: string;\n name: string;\n description?: string | undefined;\n type?: 'agent' | 'oauth' | 'http' | undefined;\n}\n\nexport interface AuthenticateRequest {\n methodId: string;\n}\n\nexport type AuthenticateResponse = {}\n\nexport type LogoutRequest = {}\n\nexport type LogoutResponse = {}\n\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// MCP server configuration \u2014 sent in session lifecycle requests\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport interface StdioMcpServer {\n name: string;\n command: string;\n args?: string[] | undefined;\n env?: { name: string; value: string }[] | undefined;\n}\n\nexport interface HttpMcpServer {\n type: 'http';\n name: string;\n url: string;\n headers?: { name: string; value: string }[] | undefined;\n}\n\nexport interface SseMcpServer {\n type: 'sse';\n name: string;\n url: string;\n headers?: { name: string; value: string }[] | undefined;\n}\n\nexport type McpServer = StdioMcpServer | HttpMcpServer | SseMcpServer;\n\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// Session lifecycle \u2014 request/response types\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport interface NewSessionRequest {\n cwd: string;\n mcpServers: McpServer[];\n additionalDirectories?: string[] | undefined;\n}\n\nexport interface NewSessionResponse {\n sessionId: SessionId;\n initialMode?: SessionModeState | null | undefined;\n configOptions?: SessionConfigOption[] | null | undefined;\n}\n\nexport interface LoadSessionRequest {\n sessionId: SessionId;\n cwd: string;\n mcpServers: McpServer[];\n additionalDirectories?: string[] | undefined;\n}\n\nexport interface LoadSessionResponse {\n initialMode?: SessionModeState | null | undefined;\n configOptions?: SessionConfigOption[] | null | undefined;\n}\n\nexport interface ResumeSessionRequest {\n sessionId: SessionId;\n cwd: string;\n mcpServers: McpServer[];\n additionalDirectories?: string[] | undefined;\n}\n\nexport interface ResumeSessionResponse {\n initialMode?: SessionModeState | null | undefined;\n configOptions?: SessionConfigOption[] | null | undefined;\n}\n\nexport interface CloseSessionRequest {\n sessionId: SessionId;\n}\n\nexport type CloseSessionResponse = {}\n\nexport interface ListSessionsRequest {\n cursor?: string | undefined;\n cwd?: string | undefined;\n}\n\nexport interface ListSessionsResponse {\n sessions: SessionInfo[];\n nextCursor?: string | undefined;\n}\n\nexport interface DeleteSessionRequest {\n sessionId: SessionId;\n}\n\nexport type DeleteSessionResponse = {}\n\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// Session config options\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport interface SessionConfigOption {\n id: string;\n name: string;\n description?: string | undefined;\n category?: ConfigOptionCategory | undefined;\n type: ConfigOptionType;\n defaultValue?: string | undefined;\n currentValue: string;\n options: ConfigOptionValue[];\n}\n\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// Content blocks \u2014 reused from MCP per the spec\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/**\n * Annotations attached to a content block. Optional, agent-supplied hint\n * about audience/priority. Spec leaves shape open; we mirror the fields\n * the spec shows in its examples.\n */\nexport interface ContentAnnotations {\n audience?: ('user' | 'assistant')[] | undefined;\n priority?: number | undefined;\n [key: string]: unknown;\n}\n\nexport interface TextContent {\n type: 'text';\n text: string;\n annotations?: ContentAnnotations | undefined;\n}\n\nexport interface ImageContent {\n type: 'image';\n mimeType: string;\n /** Base64-encoded image data. */\n data: string;\n uri?: string | undefined;\n annotations?: ContentAnnotations | undefined;\n}\n\nexport interface AudioContent {\n type: 'audio';\n mimeType: string;\n /** Base64-encoded audio data. */\n data: string;\n annotations?: ContentAnnotations | undefined;\n}\n\nexport interface TextResourceContents {\n uri: string;\n mimeType?: string | undefined;\n text: string;\n}\n\nexport interface BlobResourceContents {\n uri: string;\n mimeType?: string | undefined;\n /** Base64-encoded binary. */\n blob: string;\n}\n\nexport type EmbeddedResourceContents = TextResourceContents | BlobResourceContents;\n\nexport interface EmbeddedResourceContent {\n type: 'resource';\n resource: EmbeddedResourceContents;\n annotations?: ContentAnnotations | undefined;\n}\n\nexport interface ResourceLinkContent {\n type: 'resource_link';\n uri: string;\n name: string;\n mimeType?: string | undefined;\n title?: string | undefined;\n description?: string | undefined;\n size?: number | undefined;\n annotations?: ContentAnnotations | undefined;\n}\n\nexport type ContentBlock =\n | TextContent\n | ImageContent\n | AudioContent\n | EmbeddedResourceContent\n | ResourceLinkContent;\n\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// Tool calls\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport type ToolKind =\n | 'read'\n | 'edit'\n | 'delete'\n | 'move'\n | 'search'\n | 'execute'\n | 'think'\n | 'fetch'\n | 'switch_mode'\n | 'other';\n\nexport type ToolCallStatus = 'pending' | 'in_progress' | 'completed' | 'failed';\n\n/** A single concrete content payload attached to a tool call. */\nexport type ToolCallContent =\n | { type: 'content'; content: ContentBlock }\n | {\n type: 'diff';\n path: string;\n oldText: string | null;\n newText: string;\n }\n | { type: 'terminal'; terminalId: TerminalId };\n\nexport interface ToolCallLocation {\n path: string;\n /** 1-based per the spec's argument requirements. */\n line?: number | undefined;\n}\n\nexport interface ToolCall {\n toolCallId: ToolCallId;\n title: string;\n kind?: ToolKind | undefined;\n status?: ToolCallStatus | undefined;\n content?: ToolCallContent[] | undefined;\n locations?: ToolCallLocation[] | undefined;\n rawInput?: Record<string, unknown> | undefined;\n rawOutput?: Record<string, unknown> | undefined;\n}\n\n/**\n * Partial update of a previously-emitted tool call. All fields except\n * `toolCallId` are optional \u2014 only the changed fields are included.\n * Declared standalone (not `extends ToolCall`) because `title` is required\n * on `ToolCall` but optional here; the structural variance is the point.\n */\nexport interface ToolCallUpdateFields {\n toolCallId: ToolCallId;\n status?: ToolCallStatus | undefined;\n content?: ToolCallContent[] | undefined;\n title?: string | undefined;\n kind?: ToolKind | undefined;\n locations?: ToolCallLocation[] | undefined;\n rawInput?: Record<string, unknown> | undefined;\n rawOutput?: Record<string, unknown> | undefined;\n}\n\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// Plan\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport type PlanEntryPriority = 'high' | 'medium' | 'low';\nexport type PlanEntryStatus = 'pending' | 'in_progress' | 'completed';\n\nexport interface PlanEntry {\n /** Required by the spec for the array shape, but per-entry id is optional. */\n content: string;\n priority: PlanEntryPriority;\n status: PlanEntryStatus;\n}\n\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// Slash commands\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport interface AvailableCommandInput {\n hint: string;\n}\n\nexport interface AvailableCommand {\n name: string;\n description: string;\n input?: AvailableCommandInput | undefined;\n}\n\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// Session modes\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport type SessionModeId = string & { readonly __acpModeId: unique symbol };\n\nexport interface SessionMode {\n id: SessionModeId;\n name: string;\n description?: string | undefined;\n}\n\nexport interface SessionModeState {\n currentModeId: SessionModeId;\n availableModes: SessionMode[];\n}\n\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// Config options\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/** Reserved spec categories. Underscore-prefixed names are free for custom use. */\nexport type ConfigOptionCategory =\n | 'mode'\n | 'model'\n | 'thought_level'\n | `_${string}`;\n\nexport type ConfigOptionType = 'select' | string;\n\nexport interface ConfigOptionValue {\n value: string;\n name: string;\n description?: string | undefined;\n}\n\nexport interface ConfigOption {\n id: string;\n name: string;\n description?: string | undefined;\n category?: ConfigOptionCategory | undefined;\n type: ConfigOptionType;\n currentValue: string;\n options: ConfigOptionValue[];\n}\n\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// Session info\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport interface SessionInfo {\n sessionId: SessionId;\n cwd: string;\n title?: string | undefined;\n updatedAt?: string | undefined;\n /** Agent-supplied extension metadata; opaque to clients. */\n _meta?: Record<string, unknown> | undefined;\n}\n\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// Usage (token / cost) updates\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport interface UsageCost {\n amount: number;\n /** ISO 4217 currency code, e.g. \"USD\". */\n currency: string;\n}\n\nexport interface UsageUpdate {\n /** Tokens used in the current session context. Required, non-null. */\n used: number;\n /** Total context window size in tokens. Required, non-null. */\n size: number;\n cost?: UsageCost | undefined;\n}\n\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// Permission requests\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport type PermissionOptionKind =\n | 'allow_once'\n | 'allow_always'\n | 'reject_once'\n | 'reject_always';\n\nexport interface PermissionOption {\n optionId: string;\n name: string;\n kind: PermissionOptionKind;\n}\n\nexport type RequestPermissionOutcome =\n | { outcome: 'cancelled' }\n | { outcome: 'selected'; optionId: string };\n\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// Stop reasons\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport type StopReason =\n | 'end_turn'\n | 'max_tokens'\n | 'max_turn_requests'\n | 'refusal'\n | 'cancelled'\n | string;\n\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// SessionUpdate \u2014 the discriminated union\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/** Stable v1 variants. The spec currently defines exactly 11. */\nexport type SessionUpdate =\n | UserMessageChunkUpdate\n | AgentMessageChunkUpdate\n | ThoughtChunkUpdate\n | ToolCallUpdateUpdate\n | ToolCallUpdateNotification\n | PlanUpdate\n | AvailableCommandsUpdate\n | CurrentModeUpdate\n | ConfigOptionUpdate\n | SessionInfoUpdate\n | UsageUpdateUpdate;\n\n// --- Streaming message chunks -----------------------------------------------\n\nexport interface UserMessageChunkUpdate {\n sessionUpdate: 'user_message_chunk';\n messageId?: MessageId | undefined;\n content: ContentBlock;\n}\n\nexport interface AgentMessageChunkUpdate {\n sessionUpdate: 'agent_message_chunk';\n messageId?: MessageId | undefined;\n content: ContentBlock;\n}\n\nexport interface ThoughtChunkUpdate {\n sessionUpdate: 'thought_chunk';\n messageId?: MessageId | undefined;\n content: ContentBlock;\n}\n\n// --- Tool calls ------------------------------------------------------------\n\n/** First notification for a new tool call. */\nexport interface ToolCallUpdateUpdate {\n sessionUpdate: 'tool_call';\n toolCallId: ToolCallId;\n title: string;\n kind?: ToolKind | undefined;\n status?: ToolCallStatus | undefined;\n content?: ToolCallContent[] | undefined;\n locations?: ToolCallLocation[] | undefined;\n rawInput?: Record<string, unknown> | undefined;\n}\n\n/** Subsequent updates to a previously-emitted tool call. */\nexport interface ToolCallUpdateNotification {\n sessionUpdate: 'tool_call_update';\n toolCallId: ToolCallId;\n status?: ToolCallStatus | undefined;\n content?: ToolCallContent[] | undefined;\n title?: string | undefined;\n kind?: ToolKind | undefined;\n locations?: ToolCallLocation[] | undefined;\n rawInput?: Record<string, unknown> | undefined;\n rawOutput?: Record<string, unknown> | undefined;\n}\n\n// --- Plan ------------------------------------------------------------------\n\nexport interface PlanUpdate {\n sessionUpdate: 'plan';\n entries: PlanEntry[];\n}\n\n// --- Commands / modes / config ---------------------------------------------\n\nexport interface AvailableCommandsUpdate {\n sessionUpdate: 'available_commands_update';\n availableCommands: AvailableCommand[];\n}\n\nexport interface CurrentModeUpdate {\n sessionUpdate: 'current_mode_update';\n modeId: SessionModeId;\n}\n\nexport interface ConfigOptionUpdate {\n sessionUpdate: 'config_option_update';\n configOptions: ConfigOption[];\n}\n\n// --- Session metadata ------------------------------------------------------\n\nexport interface SessionInfoUpdate {\n sessionUpdate: 'session_info_update';\n title?: string | null | undefined;\n updatedAt?: string | null | undefined;\n _meta?: Record<string, unknown> | undefined;\n}\n\n// --- Usage -----------------------------------------------------------------\n\nexport interface UsageUpdateUpdate {\n sessionUpdate: 'usage_update';\n used: number;\n size: number;\n cost?: UsageCost | undefined;\n}\n\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// Escape hatches: unknown / unstable\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/**\n * Escape hatch for v2-RFD `sessionUpdate` kinds that have been published\n * but are not yet stabilised in the v1 spec. Examples seen in the wild:\n * `next_edit_suggestions`, `elicitation`, `proxy_extension`. We surface\n * the raw payload so forward-compat code can switch on\n * `kind === 'next_edit_suggestions'` etc. without losing the data.\n */\nexport interface UnstableSessionUpdate {\n sessionUpdate: `_unstable_${string}`;\n [key: string]: unknown;\n}\n\n/**\n * Last-resort variant: the agent sent a discriminator string we don't\n * recognise at all. The full payload is preserved as a record so consumers\n * can still log/inspect it. Prefer matching the known variants first.\n */\nexport interface UnknownSessionUpdate {\n sessionUpdate: string;\n [key: string]: unknown;\n}\n\n/** The full union, including escape hatches. */\nexport type AnySessionUpdate = SessionUpdate | UnstableSessionUpdate | UnknownSessionUpdate;\n\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// Top-level notification envelope\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport interface SessionUpdateNotification {\n jsonrpc?: '2.0' | undefined;\n method: 'session/update';\n params: {\n sessionId: SessionId;\n update: AnySessionUpdate;\n };\n}\n\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// Type guards\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/**\n * Exhaustiveness helper. Call from the `default:` branch of a switch on\n * `sessionUpdate` to get a compile-time error when a new variant is added\n * without updating the consumer.\n */\nexport function assertNeverSessionUpdate(x: never): never {\n throw new Error(\n `Unhandled sessionUpdate: ${JSON.stringify(x)}`,\n );\n}\n"],
5
+ "mappings": ";AAuCO,IAAM,uBAAuB;AAsnB7B,SAAS,yBAAyB,GAAiB;AACxD,QAAM,IAAI;AAAA,IACR,4BAA4B,KAAK,UAAU,CAAC,CAAC;AAAA,EAC/C;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ export declare const ACP_PACKAGE_VERSION: string;
2
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,mBAAmB,QAAuB,CAAC"}
@@ -1,16 +1,33 @@
1
1
  // src/agent/wrongstack-acp-agent.ts
2
2
  import { fileURLToPath } from "node:url";
3
3
  import { createServer } from "node:http";
4
- import { writeErr as writeErr2 } from "@wrongstack/core";
4
+ import { writeErr as writeErr2 } from "@wrongstack/core/utils";
5
5
 
6
6
  // src/types/acp-v1.ts
7
7
  var ACP_PROTOCOL_VERSION = 1;
8
8
 
9
- // src/agent/protocol-handler.ts
9
+ // src/version.ts
10
+ import { createRequire } from "node:module";
11
+ var require2 = createRequire(import.meta.url);
12
+ function readPackageVersion() {
13
+ try {
14
+ const packageJson = require2("../package.json");
15
+ if (typeof packageJson.version === "string" && packageJson.version.length > 0) {
16
+ return packageJson.version;
17
+ }
18
+ } catch {
19
+ }
20
+ return "dev";
21
+ }
22
+ var ACP_PACKAGE_VERSION = readPackageVersion();
23
+
24
+ // src/agent/protocol-contract.ts
10
25
  function toWire(msg) {
11
26
  return msg;
12
27
  }
13
- var WRONGSTACK_VERSION = "0.274.1";
28
+ var WRONGSTACK_VERSION = ACP_PACKAGE_VERSION;
29
+
30
+ // src/agent/protocol-handler.ts
14
31
  var WRONGSTACK_AUTH_METHODS = [
15
32
  {
16
33
  id: "wrongstack-auth",
@@ -21,6 +38,7 @@ var WRONGSTACK_AUTH_METHODS = [
21
38
  }
22
39
  ];
23
40
  var DEFAULT_MODE_ID = "code";
41
+ var DEFAULT_MAX_SESSIONS = 64;
24
42
  var DEFAULT_MODES = [
25
43
  {
26
44
  id: DEFAULT_MODE_ID,
@@ -38,6 +56,8 @@ var ACPProtocolHandler = class {
38
56
  agentName;
39
57
  replayFor;
40
58
  seedFor;
59
+ disposeFor;
60
+ maxSessions;
41
61
  store;
42
62
  initialized = false;
43
63
  clientCapabilities = {};
@@ -58,6 +78,8 @@ var ACPProtocolHandler = class {
58
78
  this.agentName = opts.agentName ?? "wrongstack";
59
79
  this.replayFor = opts.replayFor;
60
80
  this.seedFor = opts.seedFor;
81
+ this.disposeFor = opts.disposeFor;
82
+ this.maxSessions = Number.isFinite(opts.maxSessions) && (opts.maxSessions ?? 0) > 0 ? Math.floor(opts.maxSessions) : DEFAULT_MAX_SESSIONS;
61
83
  this.store = opts.store;
62
84
  if (typeof this.transport.onMessage === "function") {
63
85
  this.transport.onMessage((m) => this.maybeResolvePending(m));
@@ -115,8 +137,9 @@ var ACPProtocolHandler = class {
115
137
  }
116
138
  /** Abort all active turns and drop session state. */
117
139
  close() {
118
- for (const [, session] of this.sessions) {
140
+ for (const [sessionId, session] of this.sessions) {
119
141
  session.abort.abort();
142
+ this.disposeSession(sessionId);
120
143
  }
121
144
  this.sessions.clear();
122
145
  for (const [, p] of this.pendingOut) {
@@ -125,6 +148,12 @@ var ACPProtocolHandler = class {
125
148
  }
126
149
  this.pendingOut.clear();
127
150
  }
151
+ disposeSession(sessionId) {
152
+ try {
153
+ this.disposeFor?.(sessionId);
154
+ } catch {
155
+ }
156
+ }
128
157
  // ────────────────────────────────────────────────────────────────────
129
158
  // Requests
130
159
  // ────────────────────────────────────────────────────────────────────
@@ -244,6 +273,10 @@ var ACPProtocolHandler = class {
244
273
  return false;
245
274
  }
246
275
  async handleSessionNew(id, params) {
276
+ if (this.sessions.size >= this.maxSessions) {
277
+ await this.sendError(id, -32e3, `active session limit reached (${this.maxSessions})`);
278
+ return false;
279
+ }
247
280
  const p = params ?? {};
248
281
  const cwd = typeof p.cwd === "string" ? p.cwd : this.defaultCwd;
249
282
  const sessionId = `sess_${this.allocId()}`;
@@ -294,6 +327,10 @@ var ACPProtocolHandler = class {
294
327
  if (!existing && sessionId && this.store) {
295
328
  const persisted = await this.store.load(sessionId);
296
329
  if (persisted) {
330
+ if (this.sessions.size >= this.maxSessions) {
331
+ await this.sendError(id, -32e3, `active session limit reached (${this.maxSessions})`);
332
+ return false;
333
+ }
297
334
  const restored = {
298
335
  id: sessionId,
299
336
  cwd: persisted.cwd ?? loadCwd ?? this.defaultCwd,
@@ -389,7 +426,10 @@ var ACPProtocolHandler = class {
389
426
  return false;
390
427
  }
391
428
  session.abort.abort();
392
- if (sessionId) this.sessions.delete(sessionId);
429
+ if (sessionId) {
430
+ this.sessions.delete(sessionId);
431
+ this.disposeSession(sessionId);
432
+ }
393
433
  await this.transport.send(toWire({
394
434
  jsonrpc: "2.0",
395
435
  id,
@@ -411,6 +451,7 @@ var ACPProtocolHandler = class {
411
451
  const session = this.sessions.get(sessionId);
412
452
  session.abort.abort();
413
453
  this.sessions.delete(sessionId);
454
+ this.disposeSession(sessionId);
414
455
  await this.transport.send(toWire({
415
456
  jsonrpc: "2.0",
416
457
  id,
@@ -426,6 +467,10 @@ var ACPProtocolHandler = class {
426
467
  await this.sendError(id, -32e3, `session not found: ${sourceId}`);
427
468
  return false;
428
469
  }
470
+ if (this.sessions.size >= this.maxSessions) {
471
+ await this.sendError(id, -32e3, `active session limit reached (${this.maxSessions})`);
472
+ return false;
473
+ }
429
474
  const now = (/* @__PURE__ */ new Date()).toISOString();
430
475
  const sessionId = `sess_${this.allocId()}`;
431
476
  const forked = {
@@ -692,7 +737,12 @@ function errorToJsonRpc(err) {
692
737
  }
693
738
 
694
739
  // src/agent/stdio-transport.ts
695
- import { expectDefined, writeErr } from "@wrongstack/core";
740
+ import { expectDefined, writeErr } from "@wrongstack/core/utils";
741
+ var DEFAULT_MAX_FRAME_CHARS = 20 * 1024 * 1024;
742
+ var DEFAULT_MAX_QUEUED_MESSAGES = 1e3;
743
+ function positiveLimit(value, fallback) {
744
+ return Number.isFinite(value) && (value ?? 0) > 0 ? Math.floor(value) : fallback;
745
+ }
696
746
  var StdioTransport = class {
697
747
  stdin = process.stdin;
698
748
  stdout = process.stdout;
@@ -702,7 +752,14 @@ var StdioTransport = class {
702
752
  closed = false;
703
753
  resolveRead = null;
704
754
  messageQueue = [];
705
- constructor() {
755
+ maxFrameChars;
756
+ maxQueuedMessages;
757
+ constructor(opts = {}) {
758
+ this.maxFrameChars = positiveLimit(opts.maxFrameChars, DEFAULT_MAX_FRAME_CHARS);
759
+ this.maxQueuedMessages = positiveLimit(
760
+ opts.maxQueuedMessages,
761
+ DEFAULT_MAX_QUEUED_MESSAGES
762
+ );
706
763
  this.stdin.resume();
707
764
  this.stdin.setEncoding("utf8");
708
765
  this.stdin.on("data", (chunk) => this.onData(chunk));
@@ -738,13 +795,34 @@ var StdioTransport = class {
738
795
  this.stdin.pause();
739
796
  this.resolveRead?.(null);
740
797
  this.resolveRead = null;
798
+ this.buffer = "";
799
+ this.messageQueue.length = 0;
800
+ this.handlers.clear();
741
801
  }
742
802
  onData(chunk) {
743
803
  this.buffer += chunk;
744
804
  const lines = this.buffer.split("\n");
745
805
  this.buffer = lines.pop() ?? "";
806
+ if (this.buffer.length > this.maxFrameChars) {
807
+ this.stderr.write(
808
+ `[wstack-acp frame error] pending frame exceeds ${this.maxFrameChars} characters
809
+ `,
810
+ "utf8"
811
+ );
812
+ this.close();
813
+ return;
814
+ }
746
815
  for (const raw of lines) {
747
816
  if (!raw.trim()) continue;
817
+ if (raw.length > this.maxFrameChars) {
818
+ this.stderr.write(
819
+ `[wstack-acp frame error] frame exceeds ${this.maxFrameChars} characters
820
+ `,
821
+ "utf8"
822
+ );
823
+ this.close();
824
+ return;
825
+ }
748
826
  try {
749
827
  this.dispatch(JSON.parse(raw));
750
828
  } catch (err) {
@@ -759,6 +837,15 @@ var StdioTransport = class {
759
837
  this.resolveRead = null;
760
838
  resolve(msg);
761
839
  } else {
840
+ if (this.messageQueue.length >= this.maxQueuedMessages) {
841
+ this.stderr.write(
842
+ `[wstack-acp queue error] pending message queue exceeds ${this.maxQueuedMessages} entries
843
+ `,
844
+ "utf8"
845
+ );
846
+ this.close();
847
+ return;
848
+ }
762
849
  this.messageQueue.push(msg);
763
850
  }
764
851
  for (const handler of this.handlers) {
@@ -771,9 +858,7 @@ var StdioTransport = class {
771
858
  }
772
859
  }
773
860
  handleClose() {
774
- this.closed = true;
775
- this.resolveRead?.(null);
776
- this.resolveRead = null;
861
+ this.close();
777
862
  }
778
863
  failAll(err) {
779
864
  this.stderr.write(`[wstack-acp stdin error] ${err.message}
@@ -801,6 +886,7 @@ var WrongStackACPServer = class {
801
886
  agentName: opts.agentName,
802
887
  ...opts.replayFor ? { replayFor: opts.replayFor } : {},
803
888
  ...opts.seedFor ? { seedFor: opts.seedFor } : {},
889
+ ...opts.disposeFor ? { disposeFor: opts.disposeFor } : {},
804
890
  ...opts.store ? { store: opts.store } : {}
805
891
  });
806
892
  }
@@ -822,13 +908,17 @@ var WrongStackACPServer = class {
822
908
  this.transport.sendStartupMarker();
823
909
  }
824
910
  this.running = true;
825
- while (this.running) {
826
- const msg = await this.transport.read();
827
- if (!msg) break;
828
- const terminal = await this.handler.handleMessage(msg);
829
- if (terminal) break;
911
+ try {
912
+ while (this.running) {
913
+ const msg = await this.transport.read();
914
+ if (!msg) break;
915
+ const terminal = await this.handler.handleMessage(msg);
916
+ if (terminal) break;
917
+ }
918
+ } finally {
919
+ this.handler.close();
920
+ this.transport.close();
830
921
  }
831
- this.transport.close();
832
922
  }
833
923
  async startHttp(port) {
834
924
  const host = this.options.host ?? "127.0.0.1";
@@ -943,6 +1033,7 @@ var WrongStackACPServer = class {
943
1033
  /** Stop the server. */
944
1034
  stop() {
945
1035
  this.running = false;
1036
+ this.handler.close();
946
1037
  this.transport.close();
947
1038
  if (this.httpServer) {
948
1039
  this.httpServer.close();