@mono-agent/agent-runtime 0.20.11 → 0.21.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 (148) hide show
  1. package/ARCHITECTURE.md +50 -11
  2. package/MIGRATION.md +288 -26
  3. package/README.md +352 -477
  4. package/package.json +13 -44
  5. package/src/agent/tool-bloat.js +145 -9
  6. package/src/agent/tools/agent-tool.js +108 -9
  7. package/src/agent/tools/bash.js +11 -26
  8. package/src/agent/tools/codex-subscription-search.js +123 -29
  9. package/src/agent/tools/exec.js +10 -2
  10. package/src/agent/tools/index.js +7 -0
  11. package/src/agent/tools/monitor.js +149 -0
  12. package/src/agent/tools/pi-bridge.js +123 -19
  13. package/src/agent/tools/shared/bash-environment.js +31 -0
  14. package/src/agent/tools/shared/monitors.js +293 -0
  15. package/src/agent/tools/shared/path-resolver.js +25 -6
  16. package/src/agent/tools/shared/process-jobs.js +6 -1
  17. package/src/agent/tools/shared/process-runner.js +26 -6
  18. package/src/agent/tools/shared/tool-context.js +8 -0
  19. package/src/agent/tools/web-access-interstitial.js +70 -0
  20. package/src/agent/tools/web-browser-render.js +83 -58
  21. package/src/agent/tools/web-controller.js +112 -21
  22. package/src/agent/tools/web-document-extractor.js +379 -0
  23. package/src/agent/tools/web-fetch.js +271 -243
  24. package/src/agent/tools/web-request.js +65 -0
  25. package/src/agent/tools/web-search-output.js +165 -0
  26. package/src/agent/tools/web-search-state.js +75 -0
  27. package/src/agent/tools/web-search.js +532 -71
  28. package/src/ai/cost.js +13 -68
  29. package/src/ai/failure.js +3 -3
  30. package/src/ai/index.js +5 -17
  31. package/src/ai/observer.js +8 -0
  32. package/src/ai/pi-interop.js +221 -1
  33. package/src/ai/pi-oauth-compat.js +1 -1
  34. package/src/ai/provider-check.js +131 -0
  35. package/src/ai/providers/codex/app-server-client.js +592 -0
  36. package/src/ai/providers/pi-models.js +18 -10
  37. package/src/ai/providers/pi-native/compaction-driver.js +94 -42
  38. package/src/ai/providers/pi-native/compaction-summary.js +140 -0
  39. package/src/ai/providers/pi-native/harness-adapter.js +376 -0
  40. package/src/ai/providers/pi-native/prompt-cache-diagnostics.js +103 -0
  41. package/src/ai/providers/pi-native/provider-attribution.js +102 -0
  42. package/src/ai/providers/pi-native/result-builder.js +38 -14
  43. package/src/ai/providers/pi-native/session-lifecycle.js +253 -55
  44. package/src/ai/providers/pi-native/stream-subscriber.js +52 -6
  45. package/src/ai/providers/pi-native/terminal-recovery.js +40 -0
  46. package/src/ai/providers/pi-native/turn-runner.js +279 -28
  47. package/src/ai/providers/pi-native.js +206 -61
  48. package/src/ai/runtime/capabilities.js +11 -56
  49. package/src/ai/runtime/live-input-events.js +250 -54
  50. package/src/ai/runtime/model-refs.js +118 -153
  51. package/src/ai/runtime/registry.js +22 -56
  52. package/src/ai/runtime/router.js +76 -417
  53. package/src/ai/runtime/session-liveness.js +3 -4
  54. package/src/ai/runtime/sessions.js +4 -5
  55. package/src/ai/runtime/tool-policy.js +0 -2
  56. package/src/ai/tool-lifecycle.js +32 -18
  57. package/src/ai/types.js +37 -112
  58. package/src/index.js +0 -6
  59. package/src/runtime.js +29 -16
  60. package/types/agent/tool-bloat.d.ts +1 -1
  61. package/types/agent/tools/agent-tool.d.ts +4 -2
  62. package/types/agent/tools/bash.d.ts +5 -3
  63. package/types/agent/tools/codex-subscription-search.d.ts +7 -3
  64. package/types/agent/tools/exec.d.ts +5 -3
  65. package/types/agent/tools/index.d.ts +1 -0
  66. package/types/agent/tools/monitor.d.ts +47 -0
  67. package/types/agent/tools/pi-bridge.d.ts +7 -4
  68. package/types/agent/tools/shared/bash-environment.d.ts +4 -0
  69. package/types/agent/tools/shared/monitors.d.ts +98 -0
  70. package/types/agent/tools/shared/process-jobs.d.ts +5 -1
  71. package/types/agent/tools/shared/process-runner.d.ts +14 -4
  72. package/types/agent/tools/shared/tool-context.d.ts +2 -0
  73. package/types/agent/tools/web-access-interstitial.d.ts +23 -0
  74. package/types/agent/tools/web-browser-render.d.ts +4 -1
  75. package/types/agent/tools/web-controller.d.ts +4 -2
  76. package/types/agent/tools/web-document-extractor.d.ts +27 -0
  77. package/types/agent/tools/web-fetch.d.ts +19 -24
  78. package/types/agent/tools/web-request.d.ts +20 -0
  79. package/types/agent/tools/web-search-output.d.ts +31 -0
  80. package/types/agent/tools/web-search-state.d.ts +21 -0
  81. package/types/agent/tools/web-search.d.ts +10 -45
  82. package/types/ai/cost.d.ts +1 -2
  83. package/types/ai/index.d.ts +2 -4
  84. package/types/ai/observer.d.ts +6 -0
  85. package/types/ai/pi-interop.d.ts +81 -0
  86. package/types/ai/provider-check.d.ts +53 -0
  87. package/types/ai/providers/codex/app-server-client.d.ts +37 -0
  88. package/types/ai/providers/pi-native/compaction-driver.d.ts +2 -1
  89. package/types/ai/providers/pi-native/compaction-summary.d.ts +19 -0
  90. package/types/ai/providers/pi-native/harness-adapter.d.ts +58 -0
  91. package/types/ai/providers/pi-native/prompt-cache-diagnostics.d.ts +3 -0
  92. package/types/ai/providers/pi-native/provider-attribution.d.ts +26 -0
  93. package/types/ai/providers/pi-native/result-builder.d.ts +14 -4
  94. package/types/ai/providers/pi-native/session-lifecycle.d.ts +25 -6
  95. package/types/ai/providers/pi-native/stream-subscriber.d.ts +2 -2
  96. package/types/ai/providers/pi-native/terminal-recovery.d.ts +2 -0
  97. package/types/ai/providers/pi-native/turn-runner.d.ts +68 -10
  98. package/types/ai/providers/pi-native.d.ts +21 -4
  99. package/types/ai/runtime/capabilities.d.ts +21 -70
  100. package/types/ai/runtime/live-input-events.d.ts +32 -8
  101. package/types/ai/runtime/model-refs.d.ts +0 -24
  102. package/types/ai/runtime/router.d.ts +3 -10
  103. package/types/ai/runtime/tool-policy.d.ts +0 -2
  104. package/types/ai/tool-lifecycle.d.ts +4 -3
  105. package/types/ai/types.d.ts +162 -256
  106. package/types/index.d.ts +0 -1
  107. package/src/ai/providers/acp-client.js +0 -1149
  108. package/src/ai/providers/acp-privacy.js +0 -124
  109. package/src/ai/providers/acp-public.js +0 -21
  110. package/src/ai/providers/acp-session-tokens.js +0 -282
  111. package/src/ai/providers/acp-transport.js +0 -356
  112. package/src/ai/providers/acp.js +0 -543
  113. package/src/ai/providers/claude-cli.js +0 -883
  114. package/src/ai/providers/claude-sandbox.js +0 -71
  115. package/src/ai/providers/claude-sdk-discovery-worker.js +0 -53
  116. package/src/ai/providers/claude-sdk-discovery.js +0 -352
  117. package/src/ai/providers/claude-sdk.js +0 -1127
  118. package/src/ai/providers/claude-subagent-activity.js +0 -719
  119. package/src/ai/providers/claude-subagents.js +0 -88
  120. package/src/ai/providers/codex-app.js +0 -2946
  121. package/src/ai/providers/opencode-app.js +0 -1109
  122. package/src/ai/providers/opencode-discovery.js +0 -39
  123. package/src/ai/providers/opencode-server.js +0 -508
  124. package/src/ai/runtime/context-windows.js +0 -46
  125. package/src/ai/runtime/fast-mode.js +0 -8
  126. package/src/ai/streaming/codex-events.js +0 -146
  127. package/src/ai/streaming/opencode-events.js +0 -59
  128. package/types/ai/providers/acp-client.d.ts +0 -227
  129. package/types/ai/providers/acp-privacy.d.ts +0 -25
  130. package/types/ai/providers/acp-public.d.ts +0 -7
  131. package/types/ai/providers/acp-session-tokens.d.ts +0 -41
  132. package/types/ai/providers/acp-transport.d.ts +0 -45
  133. package/types/ai/providers/acp.d.ts +0 -93
  134. package/types/ai/providers/claude-cli.d.ts +0 -305
  135. package/types/ai/providers/claude-sandbox.d.ts +0 -79
  136. package/types/ai/providers/claude-sdk-discovery-worker.d.ts +0 -1
  137. package/types/ai/providers/claude-sdk-discovery.d.ts +0 -97
  138. package/types/ai/providers/claude-sdk.d.ts +0 -138
  139. package/types/ai/providers/claude-subagent-activity.d.ts +0 -53
  140. package/types/ai/providers/claude-subagents.d.ts +0 -18
  141. package/types/ai/providers/codex-app.d.ts +0 -151
  142. package/types/ai/providers/opencode-app.d.ts +0 -96
  143. package/types/ai/providers/opencode-discovery.d.ts +0 -4
  144. package/types/ai/providers/opencode-server.d.ts +0 -20
  145. package/types/ai/runtime/context-windows.d.ts +0 -9
  146. package/types/ai/runtime/fast-mode.d.ts +0 -2
  147. package/types/ai/streaming/codex-events.d.ts +0 -40
  148. package/types/ai/streaming/opencode-events.d.ts +0 -42
@@ -1,146 +0,0 @@
1
- import { toolLifecycleMetadata } from "../tool-lifecycle.js";
2
-
3
- const CODEX_ITEM_EVENTS = new Set(["item.started", "item.completed"]);
4
-
5
- export function normalizeCodexItemType(type) {
6
- if (type === "commandExecution") return "command_execution";
7
- if (type === "mcpToolCall") return "mcp_tool_call";
8
- if (type === "fileChange") return "file_change";
9
- if (type === "agentMessage") return "agent_message";
10
- return type || "";
11
- }
12
-
13
- function isCompleted(raw) {
14
- return raw?.type === "item.completed";
15
- }
16
-
17
- function itemId(item, fallback) {
18
- return item?.id || fallback;
19
- }
20
-
21
- function itemStatus(item, raw) {
22
- return item?.status || (isCompleted(raw) ? "completed" : "in_progress");
23
- }
24
-
25
- function itemFailed(item) {
26
- const status = String(item?.status || "").toLowerCase();
27
- const exitCode = item?.exit_code ?? item?.exitCode;
28
- return Boolean(
29
- item?.error ||
30
- status === "failed" ||
31
- status === "errored" ||
32
- status === "error" ||
33
- (typeof exitCode === "number" && exitCode !== 0),
34
- );
35
- }
36
-
37
- function itemLifecycle(item) {
38
- const exitCode = item?.exit_code ?? item?.exitCode;
39
- if (typeof exitCode === "number" && exitCode !== 0) {
40
- return toolLifecycleMetadata({ state: "exit_nonzero", failure_kind: "runtime_error", detail_code: `exit_${exitCode}` });
41
- }
42
- if (itemFailed(item)) {
43
- return toolLifecycleMetadata({ state: "error", failure_kind: "runtime_error", detail_code: "codex_item_failed" });
44
- }
45
- return toolLifecycleMetadata({ state: "success" });
46
- }
47
-
48
- function commandOutput(item) {
49
- return item?.aggregated_output ?? item?.aggregatedOutput ?? item?.output ?? "";
50
- }
51
-
52
- function mcpToolName(item) {
53
- return item?.server && item?.tool
54
- ? `mcp__${item.server}__${item.tool}`
55
- : item?.tool || "mcp_tool_call";
56
- }
57
-
58
- function mcpResultContent(item) {
59
- if (item?.error) return item.error;
60
- if (item?.result?.structuredContent != null) return item.result.structuredContent;
61
- if (item?.result?.structured_content != null) return item.result.structured_content;
62
- if (item?.result?.content != null) return item.result.content;
63
- return item?.result || "";
64
- }
65
-
66
- function fileChangePayload(raw, item, context = {}) {
67
- if (typeof context.fileChangePayload === "function") {
68
- const payload = context.fileChangePayload(raw, item);
69
- if (payload) return payload;
70
- }
71
- return {
72
- changes: Array.isArray(item.changes) ? item.changes : [],
73
- status: itemStatus(item, raw),
74
- ...(item.summary ? { summary: item.summary } : {}),
75
- };
76
- }
77
-
78
- export function normalizeCodexItemEvent(raw, context = {}) {
79
- if (!raw || !CODEX_ITEM_EVENTS.has(raw.type) || !raw.item) return null;
80
- const item = raw.item;
81
- const type = normalizeCodexItemType(item.type);
82
-
83
- if (type === "file_change") {
84
- const id = itemId(item, "file_change");
85
- const payload = fileChangePayload(raw, item, context);
86
- return {
87
- type: "file_change",
88
- id,
89
- status: payload.status,
90
- changes: payload.changes,
91
- ...(payload.summary ? { summary: payload.summary } : {}),
92
- ...(item.error ? { error: item.error } : {}),
93
- is_error: itemFailed(item),
94
- };
95
- }
96
-
97
- if (type === "mcp_tool_call") {
98
- const id = itemId(item, `${item.server || "mcp"}:${item.tool || "tool"}`);
99
- if (!isCompleted(raw)) {
100
- return {
101
- type: "assistant",
102
- message: { content: [{ type: "tool_use", id, name: mcpToolName(item), input: item.arguments || {} }] },
103
- };
104
- }
105
- return {
106
- type: "user",
107
- message: {
108
- content: [{
109
- type: "tool_result",
110
- tool_use_id: id,
111
- content: mcpResultContent(item),
112
- is_error: itemFailed(item),
113
- tool_lifecycle: itemLifecycle(item),
114
- }],
115
- },
116
- };
117
- }
118
-
119
- if (type === "command_execution") {
120
- const id = itemId(item, item.command || "command_execution");
121
- if (!isCompleted(raw)) {
122
- return {
123
- type: "assistant",
124
- message: { content: [{ type: "tool_use", id, name: "command_execution", input: { command: item.command || "" } }] },
125
- };
126
- }
127
- return {
128
- type: "user",
129
- message: {
130
- content: [{
131
- type: "tool_result",
132
- tool_use_id: id,
133
- content: commandOutput(item),
134
- is_error: itemFailed(item),
135
- tool_lifecycle: itemLifecycle(item),
136
- }],
137
- },
138
- };
139
- }
140
-
141
- if (type === "agent_message" && isCompleted(raw) && typeof item.text === "string") {
142
- return { type: "assistant", message: { content: [{ type: "text", text: item.text }] } };
143
- }
144
-
145
- return null;
146
- }
@@ -1,59 +0,0 @@
1
- // Normalizes OpenCode message parts (from `message.part.updated` events and the
2
- // final `session.prompt` response) into the Anthropic-shaped RuntimeEvents the
3
- // rest of the runtime/transcript layer consumes. Sibling of codex-events.js.
4
- //
5
- // OpenCode part shapes (from @opencode-ai/sdk types.gen):
6
- // ToolPart { type:"tool", callID, tool, state:{ status, input, output?, error? } }
7
- // ReasoningPart { type:"reasoning", text }
8
- // TextPart { type:"text", text }
9
-
10
- import { toolLifecycleMetadata } from "../tool-lifecycle.js";
11
-
12
- export function toolUseEvent(part) {
13
- return {
14
- type: "assistant",
15
- message: {
16
- content: [{ type: "tool_use", id: part.callID, name: part.tool, input: part.state?.input || {} }],
17
- },
18
- };
19
- }
20
-
21
- export function toolResultEvent(part) {
22
- const state = part.state || {};
23
- const isError = state.status === "error";
24
- return {
25
- type: "user",
26
- message: {
27
- content: [{
28
- type: "tool_result",
29
- tool_use_id: part.callID,
30
- content: isError ? (state.error || "") : (state.output || ""),
31
- is_error: isError,
32
- tool_lifecycle: toolLifecycleMetadata(isError
33
- ? { state: "error", failure_kind: "runtime_error", detail_code: "opencode_tool_error" }
34
- : { state: "success" }),
35
- }],
36
- },
37
- };
38
- }
39
-
40
- export function thinkingEvent(part) {
41
- return {
42
- type: "assistant",
43
- message: { content: [{ type: "thinking", text: part.text || "" }] },
44
- };
45
- }
46
-
47
- export function assistantTextEvent(text) {
48
- return {
49
- type: "assistant",
50
- message: { content: [{ type: "text", text: text || "" }] },
51
- };
52
- }
53
-
54
- // A tool part is "settled" once it has produced output or errored — that's when
55
- // we emit the tool_result half of the pair.
56
- export function toolPartSettled(part) {
57
- const status = part?.state?.status;
58
- return status === "completed" || status === "error";
59
- }
@@ -1,227 +0,0 @@
1
- /**
2
- * Open and initialize one owned ACP v1 stdio bridge process.
3
- * @param {string} profileId
4
- * @param {AcpClientHostOptions & {operation?: string}} options
5
- */
6
- export function connectAcpProfile(profileId: string, options: AcpClientHostOptions & {
7
- operation?: string;
8
- }): Promise<{
9
- profileId: string;
10
- descriptor: AcpProfileDescriptor & {
11
- args: string[];
12
- env: Record<string, string>;
13
- configurationOwner: "client" | "agent";
14
- workspaceOwner: "client" | "agent";
15
- mcpOwner: "client" | "agent";
16
- process: {
17
- startupTimeoutMs: number;
18
- requestTimeoutMs: number;
19
- shutdownGraceMs: number;
20
- killGraceMs: number;
21
- stderrTailBytes: number;
22
- maxLineBytes: number;
23
- };
24
- };
25
- initializeResult: any;
26
- clientCapabilities: {
27
- fs: {
28
- readTextFile: boolean;
29
- writeTextFile: boolean;
30
- };
31
- terminal: boolean;
32
- };
33
- hasCapability: (name: any) => boolean;
34
- onSessionUpdate: (sessionId: any, listener: any) => () => void;
35
- request: (method: string, params: any, requestOptions?: {
36
- timeoutMs?: number;
37
- signal?: AbortSignal;
38
- label?: string;
39
- }) => Promise<any>;
40
- authenticate(methodId: any): Promise<any>;
41
- logout(): Promise<any>;
42
- newSession(params: any): Promise<any>;
43
- loadSession(params: any): Promise<any>;
44
- resumeSession(params: any): Promise<any>;
45
- closeSession(sessionId: any): Promise<any>;
46
- listSessions(params?: {}): Promise<any>;
47
- deleteSession(sessionId: any): Promise<any>;
48
- setSessionMode(sessionId: any, modeId: any): Promise<any>;
49
- setSessionConfigOption(sessionId: any, configId: any, value: any): Promise<any>;
50
- cancel(sessionId: any): Promise<void>;
51
- prompt(sessionId: any, prompt: any, promptOptions?: {}): Promise<any>;
52
- close: () => Promise<void>;
53
- }>;
54
- /** @param {string} profileId @param {AcpClientHostOptions} options */
55
- export function probeAcpProfile(profileId: string, options: AcpClientHostOptions): Promise<{
56
- profileId: string;
57
- protocolVersion: any;
58
- agentInfo: any;
59
- agentCapabilities: any;
60
- authMethods: any;
61
- }>;
62
- /** @param {string} profileId @param {string} methodId @param {AcpClientHostOptions} options */
63
- export function authenticateAcpProfile(profileId: string, methodId: string, options: AcpClientHostOptions): Promise<{
64
- profileId: string;
65
- methodId: string;
66
- authenticated: boolean;
67
- }>;
68
- /** @param {string} profileId @param {AcpClientHostOptions} options */
69
- export function logoutAcpProfile(profileId: string, options: AcpClientHostOptions): Promise<{
70
- profileId: string;
71
- loggedOut: boolean;
72
- }>;
73
- /**
74
- * @param {string} profileId
75
- * @param {{cwd?: string|null, cursor?: string|null}} [request]
76
- * @param {AcpClientHostOptions} [options]
77
- * @returns {Promise<AcpSessionListResult>}
78
- */
79
- export function listAcpSessions(profileId: string, request?: {
80
- cwd?: string | null;
81
- cursor?: string | null;
82
- }, options?: AcpClientHostOptions): Promise<AcpSessionListResult>;
83
- /** @param {string} providerSessionId @param {AcpClientHostOptions} options */
84
- export function deleteAcpSession(providerSessionId: string, options: AcpClientHostOptions): Promise<{
85
- profileId: string;
86
- providerSessionId: string;
87
- deleted: boolean;
88
- }>;
89
- /**
90
- * Product-neutral description of one ACP stdio agent profile. The environment
91
- * is exact/minimal: agent-runtime never spreads process.env into the child.
92
- */
93
- export type AcpProfileDescriptor = {
94
- command: string;
95
- args?: ReadonlyArray<string>;
96
- cwd?: string;
97
- env?: Record<string, string>;
98
- configurationOwner?: "client" | "agent";
99
- workspaceOwner?: "client" | "agent";
100
- mcpOwner?: "client" | "agent";
101
- /**
102
- * Absolute canonical workspace path; required for agent-owned workspaces.
103
- */
104
- workspacePath?: string;
105
- capabilityPolicy?: {
106
- filesystem?: {
107
- readTextFile?: boolean;
108
- writeTextFile?: boolean;
109
- };
110
- terminal?: boolean;
111
- auth?: {
112
- terminal?: boolean;
113
- };
114
- elicitation?: {
115
- form?: boolean;
116
- url?: boolean;
117
- };
118
- sessionConfig?: {
119
- boolean?: boolean;
120
- };
121
- mcp?: {
122
- stdio?: boolean;
123
- http?: boolean;
124
- sse?: boolean;
125
- };
126
- };
127
- sessionConfig?: {
128
- additionalDirectories?: ReadonlyArray<string>;
129
- mcpServers?: ReadonlyArray<Record<string, unknown>>;
130
- resumeStrategy?: "auto" | "load" | "resume";
131
- modeId?: string;
132
- configOptions?: Record<string, string | boolean>;
133
- };
134
- clientCallbacks?: {
135
- requestPermission?: (request: AcpHostSessionPayload<import("@agentclientprotocol/sdk").RequestPermissionRequest>, context: AcpCallbackContext) => Promise<import("@agentclientprotocol/sdk").RequestPermissionResponse> | import("@agentclientprotocol/sdk").RequestPermissionResponse;
136
- createElicitation?: (request: AcpHostElicitationPayload, context: AcpCallbackContext) => Promise<import("@agentclientprotocol/sdk").CreateElicitationResponse> | import("@agentclientprotocol/sdk").CreateElicitationResponse;
137
- readTextFile?: (request: AcpHostSessionPayload<import("@agentclientprotocol/sdk").ReadTextFileRequest>, context: AcpCallbackContext) => Promise<import("@agentclientprotocol/sdk").ReadTextFileResponse> | import("@agentclientprotocol/sdk").ReadTextFileResponse;
138
- writeTextFile?: (request: AcpHostSessionPayload<import("@agentclientprotocol/sdk").WriteTextFileRequest>, context: AcpCallbackContext) => Promise<import("@agentclientprotocol/sdk").WriteTextFileResponse> | import("@agentclientprotocol/sdk").WriteTextFileResponse;
139
- createTerminal?: (request: AcpHostSessionPayload<import("@agentclientprotocol/sdk").CreateTerminalRequest>, context: AcpCallbackContext) => Promise<import("@agentclientprotocol/sdk").CreateTerminalResponse> | import("@agentclientprotocol/sdk").CreateTerminalResponse;
140
- terminalOutput?: (request: AcpHostSessionPayload<import("@agentclientprotocol/sdk").TerminalOutputRequest>, context: AcpCallbackContext) => Promise<import("@agentclientprotocol/sdk").TerminalOutputResponse> | import("@agentclientprotocol/sdk").TerminalOutputResponse;
141
- waitForTerminalExit?: (request: AcpHostSessionPayload<import("@agentclientprotocol/sdk").WaitForTerminalExitRequest>, context: AcpCallbackContext) => Promise<import("@agentclientprotocol/sdk").WaitForTerminalExitResponse> | import("@agentclientprotocol/sdk").WaitForTerminalExitResponse;
142
- killTerminal?: (request: AcpHostSessionPayload<import("@agentclientprotocol/sdk").KillTerminalRequest>, context: AcpCallbackContext) => Promise<import("@agentclientprotocol/sdk").KillTerminalResponse> | import("@agentclientprotocol/sdk").KillTerminalResponse;
143
- releaseTerminal?: (request: AcpHostSessionPayload<import("@agentclientprotocol/sdk").ReleaseTerminalRequest>, context: AcpCallbackContext) => Promise<import("@agentclientprotocol/sdk").ReleaseTerminalResponse> | import("@agentclientprotocol/sdk").ReleaseTerminalResponse;
144
- sessionUpdate?: (notification: AcpHostSessionPayload<import("@agentclientprotocol/sdk").SessionNotification>, context: AcpCallbackContext) => Promise<void> | void;
145
- elicitationComplete?: (notification: Omit<import("@agentclientprotocol/sdk").CompleteElicitationNotification, "_meta">, context: AcpCallbackContext) => Promise<void> | void;
146
- };
147
- process?: {
148
- startupTimeoutMs?: number;
149
- requestTimeoutMs?: number;
150
- shutdownGraceMs?: number;
151
- killGraceMs?: number;
152
- stderrTailBytes?: number;
153
- maxLineBytes?: number;
154
- };
155
- /**
156
- * Opaque host metadata; never returned in diagnostics.
157
- */
158
- metadata?: Record<string, unknown>;
159
- };
160
- export type AcpCallbackContext = {
161
- profileId: string;
162
- operation: string;
163
- /**
164
- * Opaque profile-bound session handle when the callback is session-scoped.
165
- */
166
- providerSessionId?: string;
167
- signal?: AbortSignal;
168
- requestId?: unknown;
169
- hostContext?: Record<string, unknown>;
170
- };
171
- export type WithoutSessionId<T> = T extends unknown ? Omit<T, "sessionId"> : never;
172
- export type AcpHostSessionPayload<T> = T extends unknown ? Omit<T, "sessionId" | "_meta"> : never;
173
- export type AcpHostElicitationPayload = WithoutSessionId<import("@agentclientprotocol/sdk").CreateElicitationRequest> & Pick<import("@agentclientprotocol/sdk").CreateElicitationRequest, "message" | "mode">;
174
- export type AcpListedSession = {
175
- /**
176
- * Opaque runtime handle for resume/delete.
177
- */
178
- providerSessionId: string;
179
- cwd: string;
180
- additionalDirectories?: ReadonlyArray<string>;
181
- title?: string | null;
182
- updatedAt?: string | null;
183
- };
184
- export type AcpSessionListResult = {
185
- profileId: string;
186
- sessions: AcpListedSession[];
187
- /**
188
- * Opaque runtime cursor; pass it back unchanged.
189
- */
190
- nextCursor: string | null;
191
- };
192
- export type AcpPermissionInteractionPayload = WithoutSessionId<import("@agentclientprotocol/sdk").RequestPermissionRequest>;
193
- /**
194
- * `CreateElicitationRequest` includes a future-mode string index signature.
195
- * Plain `Omit` preserves that openness but widens its named common fields to
196
- * unknown, so restore the protocol's concrete common-field types explicitly.
197
- */
198
- export type AcpElicitationInteractionPayload = WithoutSessionId<import("@agentclientprotocol/sdk").CreateElicitationRequest> & Pick<import("@agentclientprotocol/sdk").CreateElicitationRequest, "message" | "mode" | "_meta">;
199
- export type AcpInteractionRequest = {
200
- kind: "permission";
201
- profileId: string;
202
- payload: AcpPermissionInteractionPayload;
203
- } | {
204
- kind: "elicitation";
205
- profileId: string;
206
- payload: AcpElicitationInteractionPayload;
207
- };
208
- export type AcpClientHostOptions = {
209
- resolveAcpProfile: (profileId: string, context?: Record<string, unknown>) => Promise<AcpProfileDescriptor | null | undefined> | AcpProfileDescriptor | null | undefined;
210
- onAcpInteractionRequest?: (request: AcpInteractionRequest, context?: AcpCallbackContext) => Promise<unknown> | unknown;
211
- sandbox?: import("../../agent/sandbox-seam.js").RuntimeSandbox;
212
- sandboxPolicy?: import("../../agent/sandbox-seam.js").SandboxPolicy;
213
- sandboxEngine?: import("../../agent/sandbox-seam.js").RuntimeSandboxEngine;
214
- cwd?: string;
215
- signal?: AbortSignal;
216
- context?: Record<string, unknown>;
217
- /**
218
- * Host-owned 32-byte key required by operations that emit or consume opaque session handles.
219
- */
220
- acpSessionTokenKey?: Uint8Array;
221
- };
222
- import { AcpClientError } from "./acp-session-tokens.js";
223
- import { encodeAcpProviderSessionId } from "./acp-session-tokens.js";
224
- import { validateAcpProfileId } from "./acp-session-tokens.js";
225
- import { validateAcpProviderSessionId } from "./acp-session-tokens.js";
226
- import { PROTOCOL_VERSION } from "@agentclientprotocol/sdk";
227
- export { AcpClientError, encodeAcpProviderSessionId, validateAcpProfileId, validateAcpProviderSessionId, PROTOCOL_VERSION as ACP_PROTOCOL_VERSION };
@@ -1,25 +0,0 @@
1
- /**
2
- * ACP protocol session ids are connection state, not host-facing metadata.
3
- * Remove their canonical keys, discard extension metadata, and redact copies
4
- * embedded by an agent in otherwise public strings.
5
- *
6
- * @param {unknown} value
7
- * @param {ReadonlyArray<unknown>} [rawSecrets]
8
- * @returns {{value: any, truncated: boolean}}
9
- */
10
- export function sanitizeAcpHostValueWithStatus(value: unknown, rawSecrets?: ReadonlyArray<unknown>): {
11
- value: any;
12
- truncated: boolean;
13
- };
14
- /**
15
- * Compatibility wrapper for callback/list surfaces that intentionally accept
16
- * a bounded representation. Protocol normalization should use the status form
17
- * above so it can fail explicitly instead of consuming partial data.
18
- *
19
- * @param {unknown} value
20
- * @param {ReadonlyArray<unknown>} [rawSecrets]
21
- * @returns {any}
22
- */
23
- export function sanitizeAcpHostValue(value: unknown, rawSecrets?: ReadonlyArray<unknown>): any;
24
- /** @param {unknown} value @returns {string|null} */
25
- export function ownAcpSessionUpdateKind(value: unknown): string | null;
@@ -1,7 +0,0 @@
1
- export type AcpProfileDescriptor = import("./acp-client.js").AcpProfileDescriptor;
2
- export type AcpCallbackContext = import("./acp-client.js").AcpCallbackContext;
3
- export type AcpInteractionRequest = import("./acp-client.js").AcpInteractionRequest;
4
- export type AcpClientHostOptions = import("./acp-client.js").AcpClientHostOptions;
5
- export type AcpListedSession = import("./acp-client.js").AcpListedSession;
6
- export type AcpSessionListResult = import("./acp-client.js").AcpSessionListResult;
7
- export { ACP_PROTOCOL_VERSION, AcpClientError, authenticateAcpProfile, deleteAcpSession, listAcpSessions, logoutAcpProfile, probeAcpProfile, validateAcpProfileId, validateAcpProviderSessionId } from "./acp-client.js";
@@ -1,41 +0,0 @@
1
- /** @param {string} profileId @returns {string} */
2
- export function validateAcpProfileId(profileId: string): string;
3
- /** @param {unknown} key @returns {Buffer} */
4
- export function validateAcpSessionTokenKey(key: unknown): Buffer;
5
- /** @param {string} profileId @param {string} sessionId @param {Uint8Array} key */
6
- export function encodeAcpProviderSessionId(profileId: string, sessionId: string, key: Uint8Array): string;
7
- /**
8
- * Internal protocol-state decoder. This module is not a package export.
9
- * @param {string} providerSessionId
10
- * @param {Uint8Array} key
11
- */
12
- export function decodeAcpProviderSessionId(providerSessionId: string, key: Uint8Array): {
13
- profileId: string;
14
- sessionId: string;
15
- };
16
- /**
17
- * Validate an opaque provider-session handle and its profile binding without
18
- * exposing the remote agent's protocol session id.
19
- *
20
- * @param {string} providerSessionId
21
- * @param {string} expectedProfileId
22
- * @param {Uint8Array} key Host-owned 32-byte ACP session-token key.
23
- * @returns {string}
24
- */
25
- export function validateAcpProviderSessionId(providerSessionId: string, expectedProfileId: string, key: Uint8Array): string;
26
- /** @param {string} profileId @param {string} cursor @param {Uint8Array} key */
27
- export function encodeAcpSessionCursor(profileId: string, cursor: string, key: Uint8Array): string;
28
- /** @param {string} profileId @param {unknown} cursor @param {Uint8Array} key */
29
- export function decodeAcpSessionCursor(profileId: string, cursor: unknown, key: Uint8Array): string;
30
- export class AcpClientError extends Error {
31
- /**
32
- * @param {string} code
33
- * @param {string} message
34
- * @param {Record<string, unknown>} [details]
35
- */
36
- constructor(code: string, message: string, details?: Record<string, unknown>);
37
- code: string;
38
- details: {
39
- code: string;
40
- };
41
- }
@@ -1,45 +0,0 @@
1
- /**
2
- * Open one SDK connection inside an async context that strips payload-bearing
3
- * SDK console arguments. The SDK starts its detached receive loop during
4
- * `connect`, so descendants retain this scope without muting concurrent host
5
- * work or other ACP connections.
6
- *
7
- * @template {{closed: Promise<unknown>}} T
8
- * @param {() => T} connect
9
- * @returns {T}
10
- */
11
- export function connectWithSafeAcpSdkDiagnostics<T extends {
12
- closed: Promise<unknown>;
13
- }>(connect: () => T): T;
14
- /**
15
- * @param {unknown} value
16
- * @param {number} [fallback]
17
- * @returns {number}
18
- */
19
- export function normalizeAcpMaxLineBytes(value: unknown, fallback?: number): number;
20
- /**
21
- * Build the Stream shape consumed by @agentclientprotocol/sdk from a child
22
- * process's stdin/stdout. Both inbound and outbound payloads are capped.
23
- *
24
- * @param {{stdin: import('node:stream').Writable|null, stdout: import('node:stream').Readable|null}} child
25
- * @param {{maxLineBytes?: number}} [options]
26
- * @returns {{readable: ReadableStream<any>, writable: WritableStream<any>}}
27
- */
28
- export function createBoundedAcpStdioStream(child: {
29
- stdin: import("node:stream").Writable | null;
30
- stdout: import("node:stream").Readable | null;
31
- }, options?: {
32
- maxLineBytes?: number;
33
- }): {
34
- readable: ReadableStream<any>;
35
- writable: WritableStream<any>;
36
- };
37
- export class AcpTransportError extends Error {
38
- /**
39
- * @param {string} code
40
- * @param {string} message
41
- */
42
- constructor(code: string, message: string);
43
- code: string;
44
- }
45
- export const ACP_DEFAULT_MAX_LINE_BYTES: number;
@@ -1,93 +0,0 @@
1
- /**
2
- * Runtime bridge for one ACP v1 profile turn.
3
- * @param {string} systemPrompt
4
- * @param {any} req
5
- */
6
- export function generateAcpResponse(systemPrompt: string, req: any): Promise<{
7
- text: string;
8
- thinking: string;
9
- events: any[];
10
- usage: {
11
- total_tokens: any;
12
- context_window: any;
13
- cost: any;
14
- } | {
15
- total_tokens?: undefined;
16
- context_window?: undefined;
17
- cost?: undefined;
18
- };
19
- durationMs: number;
20
- numTurns: number;
21
- model: any;
22
- effort: any;
23
- sdk: string;
24
- cancelled: boolean;
25
- error: string;
26
- failureKind: string;
27
- providerSessionId: string;
28
- runtimeWarnings: any[];
29
- diagnostics: {
30
- acp_protocol_version: any;
31
- acp_profile_id: any;
32
- acp_session_id_encoded: boolean;
33
- acp_stop_reason: any;
34
- acp_resume_method: string;
35
- acp_mode_applied: boolean;
36
- acp_config_options_applied: any[];
37
- };
38
- capabilitiesUsed: {
39
- session_resume: boolean;
40
- session_load: boolean;
41
- session_config: boolean;
42
- mcp: boolean;
43
- };
44
- structuredResult: any;
45
- structuredResultSource: any;
46
- errorDetails?: undefined;
47
- } | {
48
- text: string;
49
- thinking: string;
50
- events: any[];
51
- usage: {
52
- total_tokens?: undefined;
53
- context_window?: undefined;
54
- cost?: undefined;
55
- };
56
- durationMs: number;
57
- numTurns: number;
58
- model: any;
59
- effort: any;
60
- sdk: string;
61
- cancelled: boolean;
62
- error: any;
63
- errorDetails: {
64
- acp_error_code: any;
65
- };
66
- failureKind: string;
67
- providerSessionId: string;
68
- runtimeWarnings: any[];
69
- diagnostics: {
70
- acp_profile_id: string;
71
- acp_session_id_encoded: boolean;
72
- acp_stop_reason: string;
73
- acp_protocol_version?: undefined;
74
- acp_resume_method?: undefined;
75
- acp_mode_applied?: undefined;
76
- acp_config_options_applied?: undefined;
77
- };
78
- capabilitiesUsed: {
79
- session_resume?: undefined;
80
- session_load?: undefined;
81
- session_config?: undefined;
82
- mcp?: undefined;
83
- };
84
- structuredResult: any;
85
- structuredResultSource: any;
86
- }>;
87
- export namespace acpRuntimeBridge {
88
- export let id: string;
89
- export let kind: string;
90
- export let capabilities: any;
91
- export function supports(ref: any, options: any): boolean;
92
- export { generateAcpResponse as execute };
93
- }