@band-ai/sdk 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ClaudeSDKAdapter-Cna5P1dR.d.ts → ClaudeSDKAdapter-CXud2DBE.d.ts} +2 -1
- package/dist/{ClaudeSDKAdapter-BY4zEbCl.d.cts → ClaudeSDKAdapter-Cx6zhSaG.d.cts} +2 -1
- package/dist/adapters.cjs +347 -172
- package/dist/adapters.d.cts +22 -5
- package/dist/adapters.d.ts +22 -5
- package/dist/adapters.js +204 -60
- package/dist/chunk-F63TPOI3.js +29 -0
- package/dist/{chunk-3BKAC4OZ.js → chunk-JADCAMZY.js} +8 -0
- package/dist/{chunk-N2QTUMGO.js → chunk-JJF44XWA.js} +365 -249
- package/dist/{chunk-TLBCKDQO.js → chunk-K5KAEYPF.js} +2 -2
- package/dist/{chunk-ZZJRRBPQ.js → chunk-KXJ74J73.js} +1 -1
- package/dist/{chunk-NMZLX7TP.js → chunk-MQBBWYRP.js} +52 -45
- package/dist/{chunk-RV76SKFT.js → chunk-MQY74R7D.js} +2 -20
- package/dist/{chunk-LBWKISBS.js → chunk-OH6VVVKT.js} +21 -0
- package/dist/{chunk-EAI2M3WM.js → chunk-W5IAI6Z4.js} +1 -1
- package/dist/{chunk-4IAXZBXX.js → chunk-WA7CHXUS.js} +2 -2
- package/dist/{chunk-NT7TBFX2.js → chunk-XWHWJP4I.js} +2 -2
- package/dist/{chunk-WLCM2OXG.js → chunk-YJ42AZO4.js} +1 -1
- package/dist/converters.js +6 -5
- package/dist/index.cjs +405 -277
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +12 -11
- package/dist/mcp-claude.js +4 -3
- package/dist/mcp.js +5 -4
- package/dist/rest.js +3 -3
- package/dist/runtime.cjs +387 -362
- package/dist/runtime.d.cts +10 -39
- package/dist/runtime.d.ts +10 -39
- package/dist/runtime.js +20 -142
- package/dist/{schemas-BotL3ZLH.d.cts → schemas-BgJhlqqO.d.cts} +57 -13
- package/dist/{schemas-DBsC4J1g.d.ts → schemas-C4mK1WSs.d.ts} +57 -13
- package/dist/testing.cjs +11 -0
- package/dist/testing.js +8 -1
- package/dist/{types-D958TC71.d.cts → types-BNNtOXu3.d.cts} +1 -1
- package/dist/{types-BTN_ZETM.d.ts → types-DFUtpxah.d.ts} +1 -1
- package/package.json +2 -2
package/dist/adapters.d.cts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export { A as A2AAdapter, a as A2AAdapterOptions, K as A2AClientFactory, M as A2AClientLike, b as A2AGatewayAdapter, c as AnthropicAdapter, d as AnthropicAdapterOptions, N as AnthropicClientFactory, Q as AnthropicToolCallingModel, R as AnthropicToolCallingModelOptions, C as CODEX_REASONING_EFFORTS, e as CODEX_REASONING_SUMMARIES, f as CODEX_WEB_SEARCH_MODES, g as ClaudePermissionMode, h as ClaudeSDKAdapter, i as ClaudeSDKAdapterOptions, S as ClaudeSDKQuery, U as ClaudeSDKQueryParams, j as CodexAdapter, k as CodexAdapterConfig, W as CodexAppServerStdioClient, l as CodexApprovalPolicy, X as CodexClientLike, Y as CodexJsonRpcError, m as CodexReasoningEffort, n as CodexReasoningSummary, o as CodexSandboxMode, p as CodexWebSearchMode, Z as DynamicToolCallParams, _ as DynamicToolCallResponse, $ as DynamicToolSpec, G as GeminiAdapter, q as GeminiAdapterOptions, a0 as GeminiClientFactory, a1 as GeminiToolCallingModel, a2 as GeminiToolCallingModelOptions, r as GenericAdapter, s as GenericAdapterHandler, t as GoogleADKAdapter, u as GoogleADKAdapterOptions, a3 as HttpOpencodeClient, a4 as HttpOpencodeClientOptions, a5 as HttpStatusError, L as LangGraphAdapter, v as LangGraphAdapterOptions, w as LangGraphGraph, x as LettaAdapter, y as LettaAdapterOptions, a6 as LettaAgentCreateParams, a7 as LettaClientFactory, a8 as LettaClientLike, a9 as LettaHistoryConverter, aa as LettaMessage, ab as LettaMessageCreateParams, ac as LettaMessages, ad as LettaRequestOptions, ae as LettaResponse, af as LettaResponseMessage, O as OpenAIAdapter, z as OpenAIAdapterOptions, ag as OpenAIClientFactory, ah as OpenAIToolCallingModel, ai as OpenAIToolCallingModelOptions, B as OpencodeAdapter, D as OpencodeAdapterConfig, E as OpencodeApprovalMode, F as OpencodeApprovalReply, aj as OpencodeClientLike, H as OpencodeQuestionMode, P as ParlantAdapter, I as ParlantAdapterOptions, ak as ParlantClientFactory, al as ParlantClientLike, am as ToolCall, an as ToolCallingAdapter, ao as ToolCallingAdapterOptions, T as ToolCallingModel, ap as ToolCallingModelRequest, aq as ToolCallingResponse, ar as ToolResult, as as TurnStartParams, V as VercelAISDKAdapter, J as VercelAISDKAdapterOptions, at as VercelAISDKToolCallingModel, au as VercelAISDKToolCallingModelOptions, av as runSingleToolRound } from './ClaudeSDKAdapter-
|
|
1
|
+
export { A as A2AAdapter, a as A2AAdapterOptions, K as A2AClientFactory, M as A2AClientLike, b as A2AGatewayAdapter, c as AnthropicAdapter, d as AnthropicAdapterOptions, N as AnthropicClientFactory, Q as AnthropicToolCallingModel, R as AnthropicToolCallingModelOptions, C as CODEX_REASONING_EFFORTS, e as CODEX_REASONING_SUMMARIES, f as CODEX_WEB_SEARCH_MODES, g as ClaudePermissionMode, h as ClaudeSDKAdapter, i as ClaudeSDKAdapterOptions, S as ClaudeSDKQuery, U as ClaudeSDKQueryParams, j as CodexAdapter, k as CodexAdapterConfig, W as CodexAppServerStdioClient, l as CodexApprovalPolicy, X as CodexClientLike, Y as CodexJsonRpcError, m as CodexReasoningEffort, n as CodexReasoningSummary, o as CodexSandboxMode, p as CodexWebSearchMode, Z as DynamicToolCallParams, _ as DynamicToolCallResponse, $ as DynamicToolSpec, G as GeminiAdapter, q as GeminiAdapterOptions, a0 as GeminiClientFactory, a1 as GeminiToolCallingModel, a2 as GeminiToolCallingModelOptions, r as GenericAdapter, s as GenericAdapterHandler, t as GoogleADKAdapter, u as GoogleADKAdapterOptions, a3 as HttpOpencodeClient, a4 as HttpOpencodeClientOptions, a5 as HttpStatusError, L as LangGraphAdapter, v as LangGraphAdapterOptions, w as LangGraphGraph, x as LettaAdapter, y as LettaAdapterOptions, a6 as LettaAgentCreateParams, a7 as LettaClientFactory, a8 as LettaClientLike, a9 as LettaHistoryConverter, aa as LettaMessage, ab as LettaMessageCreateParams, ac as LettaMessages, ad as LettaRequestOptions, ae as LettaResponse, af as LettaResponseMessage, O as OpenAIAdapter, z as OpenAIAdapterOptions, ag as OpenAIClientFactory, ah as OpenAIToolCallingModel, ai as OpenAIToolCallingModelOptions, B as OpencodeAdapter, D as OpencodeAdapterConfig, E as OpencodeApprovalMode, F as OpencodeApprovalReply, aj as OpencodeClientLike, H as OpencodeQuestionMode, P as ParlantAdapter, I as ParlantAdapterOptions, ak as ParlantClientFactory, al as ParlantClientLike, am as ToolCall, an as ToolCallingAdapter, ao as ToolCallingAdapterOptions, T as ToolCallingModel, ap as ToolCallingModelRequest, aq as ToolCallingResponse, ar as ToolResult, as as TurnStartParams, V as VercelAISDKAdapter, J as VercelAISDKAdapterOptions, at as VercelAISDKToolCallingModel, au as VercelAISDKToolCallingModelOptions, av as runSingleToolRound } from './ClaudeSDKAdapter-Cx6zhSaG.cjs';
|
|
2
2
|
import * as _agentclientprotocol_sdk from '@agentclientprotocol/sdk';
|
|
3
|
-
import { Client, ClientSideConnection, McpServer, ClientCapabilities, SessionMode, AgentSideConnection, SessionModeState, Agent, InitializeResponse, Implementation, Stream, InitializeRequest, LoadSessionRequest, LoadSessionResponse, ListSessionsRequest, ListSessionsResponse, ForkSessionRequest, ForkSessionResponse, ResumeSessionRequest, ResumeSessionResponse, SetSessionModeRequest, SetSessionModeResponse, SetSessionModelRequest, SetSessionModelResponse, SetSessionConfigOptionRequest, SetSessionConfigOptionResponse, AuthenticateRequest, AuthenticateResponse, PromptRequest, PromptResponse } from '@agentclientprotocol/sdk';
|
|
3
|
+
import { Client, ClientSideConnection, McpServer, ClientCapabilities, RequestPermissionRequest, SessionModeId, SessionMode, AgentSideConnection, SessionModeState, Agent, InitializeResponse, Implementation, Stream, InitializeRequest, LoadSessionRequest, LoadSessionResponse, ListSessionsRequest, ListSessionsResponse, ForkSessionRequest, ForkSessionResponse, ResumeSessionRequest, ResumeSessionResponse, SetSessionModeRequest, SetSessionModeResponse, SetSessionModelRequest, SetSessionModelResponse, SetSessionConfigOptionRequest, SetSessionConfigOptionResponse, AuthenticateRequest, AuthenticateResponse, PromptRequest, PromptResponse } from '@agentclientprotocol/sdk';
|
|
4
4
|
import { A as ACPClientSessionState, a as ACPServerSessionState } from './acp-server-Dlj7D563.cjs';
|
|
5
5
|
export { G as GatewayHistoryConverter } from './acp-server-Dlj7D563.cjs';
|
|
6
6
|
import { S as SimpleAdapter } from './simpleAdapter-BpT4XbZC.cjs';
|
|
7
|
+
import { L as Logger } from './logger-CABQOnlR.cjs';
|
|
7
8
|
import { A as AdapterToolsProtocol, c as MessagingTools } from './protocols-Bz1rxcUg.cjs';
|
|
8
|
-
import { P as PlatformMessage } from './types-
|
|
9
|
+
import { P as PlatformMessage } from './types-BNNtOXu3.cjs';
|
|
9
10
|
import { M as McpToolRegistration } from './sdk-BTciSLRQ.cjs';
|
|
10
11
|
import { R as RestApi } from './types-BgYFd_Yw.cjs';
|
|
11
12
|
import { b as GatewayServerLike, c as GatewayServerOptions } from './opencode-2YdscIc1.cjs';
|
|
12
13
|
export { A as A2AAuth, a as A2AGatewayAdapterOptions, d as A2AHistoryConverter, e as A2ASessionState, f as GatewayA2AMessage, g as GatewayA2AStatusUpdateEvent, h as GatewayCancelRequest, i as GatewayPeer, j as GatewayRequest, k as GatewayServerFactory, G as GatewaySessionState, l as GatewayTaskState, P as ParlantHistoryConverter, m as ParlantMessage, n as ParlantMessages, o as PendingA2ATask, p as buildA2AAuthHeaders } from './opencode-2YdscIc1.cjs';
|
|
13
|
-
import './logger-CABQOnlR.cjs';
|
|
14
14
|
import './customTools-BzF0IISO.cjs';
|
|
15
15
|
import 'zod';
|
|
16
16
|
import './dtos-B8KU_q4d.cjs';
|
|
@@ -52,6 +52,10 @@ interface ACPClientAdapterOptions {
|
|
|
52
52
|
additionalMcpTools?: McpToolRegistration[];
|
|
53
53
|
clientCapabilities?: ClientCapabilities;
|
|
54
54
|
connectionFactory?: ACPClientConnectionFactory;
|
|
55
|
+
resolvePermission?: (request: RequestPermissionRequest, signal: AbortSignal) => Promise<string | undefined>;
|
|
56
|
+
permissionTimeoutMs?: number;
|
|
57
|
+
requestedPermissionMode?: SessionModeId;
|
|
58
|
+
logger?: Logger;
|
|
55
59
|
}
|
|
56
60
|
declare class ACPClientAdapter extends SimpleAdapter<ACPClientSessionState, AdapterToolsProtocol> {
|
|
57
61
|
private readonly command;
|
|
@@ -68,6 +72,11 @@ declare class ACPClientAdapter extends SimpleAdapter<ACPClientSessionState, Adap
|
|
|
68
72
|
private readonly roomTools;
|
|
69
73
|
private readonly activeSessions;
|
|
70
74
|
private readonly bootstrappedSessions;
|
|
75
|
+
private readonly pendingPermissions;
|
|
76
|
+
private readonly resolvePermission?;
|
|
77
|
+
private readonly permissionTimeoutMs;
|
|
78
|
+
private readonly requestedPermissionMode?;
|
|
79
|
+
private readonly logger;
|
|
71
80
|
private backend;
|
|
72
81
|
private backendPromise;
|
|
73
82
|
private client;
|
|
@@ -79,7 +88,7 @@ declare class ACPClientAdapter extends SimpleAdapter<ACPClientSessionState, Adap
|
|
|
79
88
|
private spawnPromise;
|
|
80
89
|
constructor(options: ACPClientAdapterOptions);
|
|
81
90
|
onStarted(agentName: string, agentDescription: string): Promise<void>;
|
|
82
|
-
onMessage(message: PlatformMessage, tools: AdapterToolsProtocol, history: ACPClientSessionState,
|
|
91
|
+
onMessage(message: PlatformMessage, tools: AdapterToolsProtocol, history: ACPClientSessionState, participantsMessage: string | null, contactsMessage: string | null, context: {
|
|
83
92
|
isSessionBootstrap: boolean;
|
|
84
93
|
roomId: string;
|
|
85
94
|
}): Promise<void>;
|
|
@@ -91,11 +100,19 @@ declare class ACPClientAdapter extends SimpleAdapter<ACPClientSessionState, Adap
|
|
|
91
100
|
private spawnConnection;
|
|
92
101
|
private getOrCreateSession;
|
|
93
102
|
private tryRestoreSession;
|
|
103
|
+
private applyRequestedPermissionMode;
|
|
94
104
|
private buildSessionMcpServers;
|
|
95
105
|
private getOrCreateBackend;
|
|
96
106
|
private createBackend;
|
|
97
107
|
private buildSystemContext;
|
|
98
108
|
private handlePermissionRequest;
|
|
109
|
+
private toResponse;
|
|
110
|
+
private safeWarn;
|
|
111
|
+
private resolveManually;
|
|
112
|
+
private trackPending;
|
|
113
|
+
private untrackPending;
|
|
114
|
+
private cancelPendingPermissions;
|
|
115
|
+
private cancelAllPendingPermissions;
|
|
99
116
|
private flushChunks;
|
|
100
117
|
}
|
|
101
118
|
|
package/dist/adapters.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export { A as A2AAdapter, a as A2AAdapterOptions, K as A2AClientFactory, M as A2AClientLike, b as A2AGatewayAdapter, c as AnthropicAdapter, d as AnthropicAdapterOptions, N as AnthropicClientFactory, Q as AnthropicToolCallingModel, R as AnthropicToolCallingModelOptions, C as CODEX_REASONING_EFFORTS, e as CODEX_REASONING_SUMMARIES, f as CODEX_WEB_SEARCH_MODES, g as ClaudePermissionMode, h as ClaudeSDKAdapter, i as ClaudeSDKAdapterOptions, S as ClaudeSDKQuery, U as ClaudeSDKQueryParams, j as CodexAdapter, k as CodexAdapterConfig, W as CodexAppServerStdioClient, l as CodexApprovalPolicy, X as CodexClientLike, Y as CodexJsonRpcError, m as CodexReasoningEffort, n as CodexReasoningSummary, o as CodexSandboxMode, p as CodexWebSearchMode, Z as DynamicToolCallParams, _ as DynamicToolCallResponse, $ as DynamicToolSpec, G as GeminiAdapter, q as GeminiAdapterOptions, a0 as GeminiClientFactory, a1 as GeminiToolCallingModel, a2 as GeminiToolCallingModelOptions, r as GenericAdapter, s as GenericAdapterHandler, t as GoogleADKAdapter, u as GoogleADKAdapterOptions, a3 as HttpOpencodeClient, a4 as HttpOpencodeClientOptions, a5 as HttpStatusError, L as LangGraphAdapter, v as LangGraphAdapterOptions, w as LangGraphGraph, x as LettaAdapter, y as LettaAdapterOptions, a6 as LettaAgentCreateParams, a7 as LettaClientFactory, a8 as LettaClientLike, a9 as LettaHistoryConverter, aa as LettaMessage, ab as LettaMessageCreateParams, ac as LettaMessages, ad as LettaRequestOptions, ae as LettaResponse, af as LettaResponseMessage, O as OpenAIAdapter, z as OpenAIAdapterOptions, ag as OpenAIClientFactory, ah as OpenAIToolCallingModel, ai as OpenAIToolCallingModelOptions, B as OpencodeAdapter, D as OpencodeAdapterConfig, E as OpencodeApprovalMode, F as OpencodeApprovalReply, aj as OpencodeClientLike, H as OpencodeQuestionMode, P as ParlantAdapter, I as ParlantAdapterOptions, ak as ParlantClientFactory, al as ParlantClientLike, am as ToolCall, an as ToolCallingAdapter, ao as ToolCallingAdapterOptions, T as ToolCallingModel, ap as ToolCallingModelRequest, aq as ToolCallingResponse, ar as ToolResult, as as TurnStartParams, V as VercelAISDKAdapter, J as VercelAISDKAdapterOptions, at as VercelAISDKToolCallingModel, au as VercelAISDKToolCallingModelOptions, av as runSingleToolRound } from './ClaudeSDKAdapter-
|
|
1
|
+
export { A as A2AAdapter, a as A2AAdapterOptions, K as A2AClientFactory, M as A2AClientLike, b as A2AGatewayAdapter, c as AnthropicAdapter, d as AnthropicAdapterOptions, N as AnthropicClientFactory, Q as AnthropicToolCallingModel, R as AnthropicToolCallingModelOptions, C as CODEX_REASONING_EFFORTS, e as CODEX_REASONING_SUMMARIES, f as CODEX_WEB_SEARCH_MODES, g as ClaudePermissionMode, h as ClaudeSDKAdapter, i as ClaudeSDKAdapterOptions, S as ClaudeSDKQuery, U as ClaudeSDKQueryParams, j as CodexAdapter, k as CodexAdapterConfig, W as CodexAppServerStdioClient, l as CodexApprovalPolicy, X as CodexClientLike, Y as CodexJsonRpcError, m as CodexReasoningEffort, n as CodexReasoningSummary, o as CodexSandboxMode, p as CodexWebSearchMode, Z as DynamicToolCallParams, _ as DynamicToolCallResponse, $ as DynamicToolSpec, G as GeminiAdapter, q as GeminiAdapterOptions, a0 as GeminiClientFactory, a1 as GeminiToolCallingModel, a2 as GeminiToolCallingModelOptions, r as GenericAdapter, s as GenericAdapterHandler, t as GoogleADKAdapter, u as GoogleADKAdapterOptions, a3 as HttpOpencodeClient, a4 as HttpOpencodeClientOptions, a5 as HttpStatusError, L as LangGraphAdapter, v as LangGraphAdapterOptions, w as LangGraphGraph, x as LettaAdapter, y as LettaAdapterOptions, a6 as LettaAgentCreateParams, a7 as LettaClientFactory, a8 as LettaClientLike, a9 as LettaHistoryConverter, aa as LettaMessage, ab as LettaMessageCreateParams, ac as LettaMessages, ad as LettaRequestOptions, ae as LettaResponse, af as LettaResponseMessage, O as OpenAIAdapter, z as OpenAIAdapterOptions, ag as OpenAIClientFactory, ah as OpenAIToolCallingModel, ai as OpenAIToolCallingModelOptions, B as OpencodeAdapter, D as OpencodeAdapterConfig, E as OpencodeApprovalMode, F as OpencodeApprovalReply, aj as OpencodeClientLike, H as OpencodeQuestionMode, P as ParlantAdapter, I as ParlantAdapterOptions, ak as ParlantClientFactory, al as ParlantClientLike, am as ToolCall, an as ToolCallingAdapter, ao as ToolCallingAdapterOptions, T as ToolCallingModel, ap as ToolCallingModelRequest, aq as ToolCallingResponse, ar as ToolResult, as as TurnStartParams, V as VercelAISDKAdapter, J as VercelAISDKAdapterOptions, at as VercelAISDKToolCallingModel, au as VercelAISDKToolCallingModelOptions, av as runSingleToolRound } from './ClaudeSDKAdapter-CXud2DBE.js';
|
|
2
2
|
import * as _agentclientprotocol_sdk from '@agentclientprotocol/sdk';
|
|
3
|
-
import { Client, ClientSideConnection, McpServer, ClientCapabilities, SessionMode, AgentSideConnection, SessionModeState, Agent, InitializeResponse, Implementation, Stream, InitializeRequest, LoadSessionRequest, LoadSessionResponse, ListSessionsRequest, ListSessionsResponse, ForkSessionRequest, ForkSessionResponse, ResumeSessionRequest, ResumeSessionResponse, SetSessionModeRequest, SetSessionModeResponse, SetSessionModelRequest, SetSessionModelResponse, SetSessionConfigOptionRequest, SetSessionConfigOptionResponse, AuthenticateRequest, AuthenticateResponse, PromptRequest, PromptResponse } from '@agentclientprotocol/sdk';
|
|
3
|
+
import { Client, ClientSideConnection, McpServer, ClientCapabilities, RequestPermissionRequest, SessionModeId, SessionMode, AgentSideConnection, SessionModeState, Agent, InitializeResponse, Implementation, Stream, InitializeRequest, LoadSessionRequest, LoadSessionResponse, ListSessionsRequest, ListSessionsResponse, ForkSessionRequest, ForkSessionResponse, ResumeSessionRequest, ResumeSessionResponse, SetSessionModeRequest, SetSessionModeResponse, SetSessionModelRequest, SetSessionModelResponse, SetSessionConfigOptionRequest, SetSessionConfigOptionResponse, AuthenticateRequest, AuthenticateResponse, PromptRequest, PromptResponse } from '@agentclientprotocol/sdk';
|
|
4
4
|
import { A as ACPClientSessionState, a as ACPServerSessionState } from './acp-server-CiUqN3G3.js';
|
|
5
5
|
export { G as GatewayHistoryConverter } from './acp-server-CiUqN3G3.js';
|
|
6
6
|
import { S as SimpleAdapter } from './simpleAdapter--wznuoOw.js';
|
|
7
|
+
import { L as Logger } from './logger-CABQOnlR.js';
|
|
7
8
|
import { A as AdapterToolsProtocol, c as MessagingTools } from './protocols-Bwwcql0h.js';
|
|
8
|
-
import { P as PlatformMessage } from './types-
|
|
9
|
+
import { P as PlatformMessage } from './types-DFUtpxah.js';
|
|
9
10
|
import { M as McpToolRegistration } from './sdk-qKJtMma_.js';
|
|
10
11
|
import { R as RestApi } from './types-BivGO7I9.js';
|
|
11
12
|
import { b as GatewayServerLike, c as GatewayServerOptions } from './opencode-Bld62x5t.js';
|
|
12
13
|
export { A as A2AAuth, a as A2AGatewayAdapterOptions, d as A2AHistoryConverter, e as A2ASessionState, f as GatewayA2AMessage, g as GatewayA2AStatusUpdateEvent, h as GatewayCancelRequest, i as GatewayPeer, j as GatewayRequest, k as GatewayServerFactory, G as GatewaySessionState, l as GatewayTaskState, P as ParlantHistoryConverter, m as ParlantMessage, n as ParlantMessages, o as PendingA2ATask, p as buildA2AAuthHeaders } from './opencode-Bld62x5t.js';
|
|
13
|
-
import './logger-CABQOnlR.js';
|
|
14
14
|
import './customTools-BzF0IISO.js';
|
|
15
15
|
import 'zod';
|
|
16
16
|
import './dtos-B8KU_q4d.js';
|
|
@@ -52,6 +52,10 @@ interface ACPClientAdapterOptions {
|
|
|
52
52
|
additionalMcpTools?: McpToolRegistration[];
|
|
53
53
|
clientCapabilities?: ClientCapabilities;
|
|
54
54
|
connectionFactory?: ACPClientConnectionFactory;
|
|
55
|
+
resolvePermission?: (request: RequestPermissionRequest, signal: AbortSignal) => Promise<string | undefined>;
|
|
56
|
+
permissionTimeoutMs?: number;
|
|
57
|
+
requestedPermissionMode?: SessionModeId;
|
|
58
|
+
logger?: Logger;
|
|
55
59
|
}
|
|
56
60
|
declare class ACPClientAdapter extends SimpleAdapter<ACPClientSessionState, AdapterToolsProtocol> {
|
|
57
61
|
private readonly command;
|
|
@@ -68,6 +72,11 @@ declare class ACPClientAdapter extends SimpleAdapter<ACPClientSessionState, Adap
|
|
|
68
72
|
private readonly roomTools;
|
|
69
73
|
private readonly activeSessions;
|
|
70
74
|
private readonly bootstrappedSessions;
|
|
75
|
+
private readonly pendingPermissions;
|
|
76
|
+
private readonly resolvePermission?;
|
|
77
|
+
private readonly permissionTimeoutMs;
|
|
78
|
+
private readonly requestedPermissionMode?;
|
|
79
|
+
private readonly logger;
|
|
71
80
|
private backend;
|
|
72
81
|
private backendPromise;
|
|
73
82
|
private client;
|
|
@@ -79,7 +88,7 @@ declare class ACPClientAdapter extends SimpleAdapter<ACPClientSessionState, Adap
|
|
|
79
88
|
private spawnPromise;
|
|
80
89
|
constructor(options: ACPClientAdapterOptions);
|
|
81
90
|
onStarted(agentName: string, agentDescription: string): Promise<void>;
|
|
82
|
-
onMessage(message: PlatformMessage, tools: AdapterToolsProtocol, history: ACPClientSessionState,
|
|
91
|
+
onMessage(message: PlatformMessage, tools: AdapterToolsProtocol, history: ACPClientSessionState, participantsMessage: string | null, contactsMessage: string | null, context: {
|
|
83
92
|
isSessionBootstrap: boolean;
|
|
84
93
|
roomId: string;
|
|
85
94
|
}): Promise<void>;
|
|
@@ -91,11 +100,19 @@ declare class ACPClientAdapter extends SimpleAdapter<ACPClientSessionState, Adap
|
|
|
91
100
|
private spawnConnection;
|
|
92
101
|
private getOrCreateSession;
|
|
93
102
|
private tryRestoreSession;
|
|
103
|
+
private applyRequestedPermissionMode;
|
|
94
104
|
private buildSessionMcpServers;
|
|
95
105
|
private getOrCreateBackend;
|
|
96
106
|
private createBackend;
|
|
97
107
|
private buildSystemContext;
|
|
98
108
|
private handlePermissionRequest;
|
|
109
|
+
private toResponse;
|
|
110
|
+
private safeWarn;
|
|
111
|
+
private resolveManually;
|
|
112
|
+
private trackPending;
|
|
113
|
+
private untrackPending;
|
|
114
|
+
private cancelPendingPermissions;
|
|
115
|
+
private cancelAllPendingPermissions;
|
|
99
116
|
private flushChunks;
|
|
100
117
|
}
|
|
101
118
|
|
package/dist/adapters.js
CHANGED
|
@@ -23,14 +23,15 @@ import {
|
|
|
23
23
|
ToolCallingAdapter,
|
|
24
24
|
VercelAISDKAdapter,
|
|
25
25
|
VercelAISDKToolCallingModel,
|
|
26
|
-
runSingleToolRound
|
|
27
|
-
|
|
26
|
+
runSingleToolRound,
|
|
27
|
+
systemUpdateParts
|
|
28
|
+
} from "./chunk-MQBBWYRP.js";
|
|
28
29
|
import {
|
|
29
30
|
BandMcpServer,
|
|
30
31
|
BandMcpSseServer,
|
|
31
32
|
generateAuthToken
|
|
32
|
-
} from "./chunk-
|
|
33
|
-
import "./chunk-
|
|
33
|
+
} from "./chunk-WA7CHXUS.js";
|
|
34
|
+
import "./chunk-XWHWJP4I.js";
|
|
34
35
|
import {
|
|
35
36
|
ACPClientHistoryConverter,
|
|
36
37
|
ACPServerHistoryConverter
|
|
@@ -48,30 +49,53 @@ import {
|
|
|
48
49
|
createGatewayServer,
|
|
49
50
|
parseToolCall,
|
|
50
51
|
parseToolResult
|
|
51
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-K5KAEYPF.js";
|
|
52
53
|
import {
|
|
53
54
|
SimpleAdapter
|
|
54
55
|
} from "./chunk-AVVDPXP4.js";
|
|
55
56
|
import {
|
|
56
|
-
ensureHandlePrefix
|
|
57
|
-
|
|
57
|
+
ensureHandlePrefix,
|
|
58
|
+
mentionSubjectsFromMetadata,
|
|
59
|
+
replaceUuidMentions
|
|
60
|
+
} from "./chunk-OH6VVVKT.js";
|
|
58
61
|
import {
|
|
59
62
|
renderSystemPrompt
|
|
60
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-YJ42AZO4.js";
|
|
61
64
|
import {
|
|
62
65
|
MCP_SERVER_NAME
|
|
63
|
-
} from "./chunk-
|
|
64
|
-
import
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
} from "./chunk-MQY74R7D.js";
|
|
67
|
+
import {
|
|
68
|
+
isBlankEventContent
|
|
69
|
+
} from "./chunk-F63TPOI3.js";
|
|
70
|
+
import "./chunk-KXJ74J73.js";
|
|
71
|
+
import "./chunk-JADCAMZY.js";
|
|
67
72
|
import {
|
|
68
|
-
|
|
73
|
+
NoopLogger
|
|
74
|
+
} from "./chunk-OD2G5LFQ.js";
|
|
75
|
+
import {
|
|
76
|
+
UnsupportedFeatureError,
|
|
77
|
+
ValidationError
|
|
69
78
|
} from "./chunk-JY75VSQK.js";
|
|
70
79
|
|
|
71
80
|
// src/adapters/acp/ACPClientAdapter.ts
|
|
72
81
|
import { spawn } from "child_process";
|
|
73
82
|
import { Readable, Writable } from "stream";
|
|
74
83
|
|
|
84
|
+
// src/adapters/shared/withTimeout.ts
|
|
85
|
+
async function withTimeout(promise, timeoutMs, message) {
|
|
86
|
+
let timer;
|
|
87
|
+
try {
|
|
88
|
+
return await Promise.race([
|
|
89
|
+
promise,
|
|
90
|
+
new Promise((_, reject) => {
|
|
91
|
+
timer = setTimeout(() => reject(new Error(message)), timeoutMs);
|
|
92
|
+
})
|
|
93
|
+
]);
|
|
94
|
+
} finally {
|
|
95
|
+
clearTimeout(timer);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
75
99
|
// src/adapters/acp/types.ts
|
|
76
100
|
var DEFAULT_ACP_SERVER_MODES = [
|
|
77
101
|
{
|
|
@@ -344,6 +368,8 @@ var acpModule = new LazyAsyncValue({
|
|
|
344
368
|
});
|
|
345
369
|
|
|
346
370
|
// src/adapters/acp/ACPClientAdapter.ts
|
|
371
|
+
var DEFAULT_PERMISSION_TIMEOUT_MS = 5 * 6e4;
|
|
372
|
+
var SET_SESSION_MODE_TIMEOUT_MS = 1e4;
|
|
347
373
|
var ACPClientAdapter = class extends SimpleAdapter {
|
|
348
374
|
command;
|
|
349
375
|
cwd;
|
|
@@ -359,6 +385,11 @@ var ACPClientAdapter = class extends SimpleAdapter {
|
|
|
359
385
|
roomTools = /* @__PURE__ */ new Map();
|
|
360
386
|
activeSessions = /* @__PURE__ */ new Set();
|
|
361
387
|
bootstrappedSessions = /* @__PURE__ */ new Set();
|
|
388
|
+
pendingPermissions = /* @__PURE__ */ new Map();
|
|
389
|
+
resolvePermission;
|
|
390
|
+
permissionTimeoutMs;
|
|
391
|
+
requestedPermissionMode;
|
|
392
|
+
logger;
|
|
362
393
|
backend = null;
|
|
363
394
|
backendPromise = null;
|
|
364
395
|
client = null;
|
|
@@ -385,6 +416,16 @@ var ACPClientAdapter = class extends SimpleAdapter {
|
|
|
385
416
|
this.additionalMcpTools = [...options.additionalMcpTools ?? []];
|
|
386
417
|
this.clientCapabilities = options.clientCapabilities;
|
|
387
418
|
this.connectionFactory = options.connectionFactory ?? createSubprocessConnection;
|
|
419
|
+
this.resolvePermission = options.resolvePermission;
|
|
420
|
+
this.logger = options.logger ?? new NoopLogger();
|
|
421
|
+
this.permissionTimeoutMs = options.permissionTimeoutMs ?? DEFAULT_PERMISSION_TIMEOUT_MS;
|
|
422
|
+
this.requestedPermissionMode = options.requestedPermissionMode;
|
|
423
|
+
if (this.requestedPermissionMode !== void 0 && this.requestedPermissionMode.length === 0) {
|
|
424
|
+
throw new ValidationError("requestedPermissionMode must be a non-empty mode id, got an empty string");
|
|
425
|
+
}
|
|
426
|
+
if (this.resolvePermission && (!Number.isFinite(this.permissionTimeoutMs) || this.permissionTimeoutMs <= 0)) {
|
|
427
|
+
throw new ValidationError(`permissionTimeoutMs must be a positive finite number, got ${options.permissionTimeoutMs}`);
|
|
428
|
+
}
|
|
388
429
|
}
|
|
389
430
|
async onStarted(agentName, agentDescription) {
|
|
390
431
|
await super.onStarted(agentName, agentDescription);
|
|
@@ -396,7 +437,7 @@ var ACPClientAdapter = class extends SimpleAdapter {
|
|
|
396
437
|
});
|
|
397
438
|
await this.ensureConnection();
|
|
398
439
|
}
|
|
399
|
-
async onMessage(message, tools, history,
|
|
440
|
+
async onMessage(message, tools, history, participantsMessage, contactsMessage, context) {
|
|
400
441
|
if (context.isSessionBootstrap) {
|
|
401
442
|
this.rehydrate(history);
|
|
402
443
|
}
|
|
@@ -412,9 +453,11 @@ var ACPClientAdapter = class extends SimpleAdapter {
|
|
|
412
453
|
sessionId,
|
|
413
454
|
(params) => this.handlePermissionRequest(tools, context.roomId, params)
|
|
414
455
|
);
|
|
415
|
-
const
|
|
456
|
+
const content = replaceUuidMentions(message.content, mentionSubjectsFromMetadata(message.metadata));
|
|
457
|
+
const messageWithContext = [...systemUpdateParts(participantsMessage, contactsMessage), content].join("\n\n");
|
|
458
|
+
const promptText = this.bootstrappedSessions.has(sessionId) ? messageWithContext : `${this.buildSystemContext(context.roomId, message)}
|
|
416
459
|
|
|
417
|
-
${
|
|
460
|
+
${messageWithContext}`;
|
|
418
461
|
this.bootstrappedSessions.add(sessionId);
|
|
419
462
|
try {
|
|
420
463
|
await connection.prompt({
|
|
@@ -450,6 +493,7 @@ ${message.content}`;
|
|
|
450
493
|
this.activeSessions.delete(sessionId);
|
|
451
494
|
this.bootstrappedSessions.delete(sessionId);
|
|
452
495
|
this.client?.setPermissionHandler(sessionId, void 0);
|
|
496
|
+
this.cancelPendingPermissions(sessionId);
|
|
453
497
|
}
|
|
454
498
|
}
|
|
455
499
|
async onRuntimeStop() {
|
|
@@ -462,6 +506,7 @@ ${message.content}`;
|
|
|
462
506
|
this.bootstrappedSessions.clear();
|
|
463
507
|
this.roomToSession.clear();
|
|
464
508
|
this.roomTools.clear();
|
|
509
|
+
this.cancelAllPendingPermissions();
|
|
465
510
|
this.client = null;
|
|
466
511
|
this.connection = null;
|
|
467
512
|
if (this.backend) {
|
|
@@ -539,9 +584,10 @@ ${message.content}`;
|
|
|
539
584
|
const mcpServers = await this.buildSessionMcpServers();
|
|
540
585
|
if (existingSessionId) {
|
|
541
586
|
const restored = await this.tryRestoreSession(connection, existingSessionId, mcpServers);
|
|
542
|
-
if (restored) {
|
|
587
|
+
if (restored.ok) {
|
|
543
588
|
this.activeSessions.add(existingSessionId);
|
|
544
589
|
this.bootstrappedSessions.add(existingSessionId);
|
|
590
|
+
await this.applyRequestedPermissionMode(connection, existingSessionId, restored.modes);
|
|
545
591
|
return existingSessionId;
|
|
546
592
|
}
|
|
547
593
|
}
|
|
@@ -551,30 +597,52 @@ ${message.content}`;
|
|
|
551
597
|
});
|
|
552
598
|
this.roomToSession.set(roomId, created.sessionId);
|
|
553
599
|
this.activeSessions.add(created.sessionId);
|
|
600
|
+
await this.applyRequestedPermissionMode(connection, created.sessionId, created.modes);
|
|
554
601
|
return created.sessionId;
|
|
555
602
|
}
|
|
556
603
|
async tryRestoreSession(connection, sessionId, mcpServers) {
|
|
604
|
+
const capabilities = this.connectionState?.agentCapabilities;
|
|
605
|
+
const params = { cwd: this.cwd, mcpServers, sessionId };
|
|
606
|
+
const restore = capabilities?.loadSession ? () => connection.loadSession(params) : capabilities?.sessionCapabilities?.resume ? () => connection.unstable_resumeSession(params) : null;
|
|
607
|
+
if (!restore) {
|
|
608
|
+
return { ok: false };
|
|
609
|
+
}
|
|
557
610
|
try {
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
cwd: this.cwd,
|
|
561
|
-
mcpServers,
|
|
562
|
-
sessionId
|
|
563
|
-
});
|
|
564
|
-
return true;
|
|
565
|
-
}
|
|
566
|
-
if (this.connectionState?.agentCapabilities?.sessionCapabilities?.resume) {
|
|
567
|
-
await connection.unstable_resumeSession({
|
|
568
|
-
cwd: this.cwd,
|
|
569
|
-
mcpServers,
|
|
570
|
-
sessionId
|
|
571
|
-
});
|
|
572
|
-
return true;
|
|
573
|
-
}
|
|
611
|
+
const restored = await restore();
|
|
612
|
+
return { ok: true, modes: restored?.modes };
|
|
574
613
|
} catch {
|
|
575
|
-
return false;
|
|
614
|
+
return { ok: false };
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
// Best-effort: never throws, so a mode switch going wrong can't take a
|
|
618
|
+
// session establishment down with it.
|
|
619
|
+
async applyRequestedPermissionMode(connection, sessionId, modes) {
|
|
620
|
+
const requestedModeId = this.requestedPermissionMode;
|
|
621
|
+
if (!requestedModeId || !modes || modes.currentModeId === requestedModeId) {
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
624
|
+
const availableModes = Array.isArray(modes.availableModes) ? modes.availableModes : [];
|
|
625
|
+
if (!availableModes.some((mode) => mode?.id === requestedModeId)) {
|
|
626
|
+
this.safeWarn("requested permission mode is not advertised by this session", {
|
|
627
|
+
sessionId,
|
|
628
|
+
requestedModeId,
|
|
629
|
+
availableModeIds: availableModes.map((mode) => mode?.id)
|
|
630
|
+
});
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
633
|
+
try {
|
|
634
|
+
await withTimeout(
|
|
635
|
+
connection.setSessionMode({ sessionId, modeId: requestedModeId }),
|
|
636
|
+
SET_SESSION_MODE_TIMEOUT_MS,
|
|
637
|
+
`setSessionMode did not respond within ${SET_SESSION_MODE_TIMEOUT_MS}ms`
|
|
638
|
+
);
|
|
639
|
+
} catch (error) {
|
|
640
|
+
this.safeWarn("failed to switch session into the requested permission mode", {
|
|
641
|
+
sessionId,
|
|
642
|
+
requestedModeId,
|
|
643
|
+
error: String(error)
|
|
644
|
+
});
|
|
576
645
|
}
|
|
577
|
-
return false;
|
|
578
646
|
}
|
|
579
647
|
async buildSessionMcpServers() {
|
|
580
648
|
const mcpServers = [...this.mcpServers];
|
|
@@ -684,28 +752,103 @@ ${message.content}`;
|
|
|
684
752
|
].join("\n");
|
|
685
753
|
}
|
|
686
754
|
async handlePermissionRequest(tools, roomId, params) {
|
|
687
|
-
const selected = choosePermissionOption(params.options);
|
|
688
755
|
const toolName = params.toolCall.title ?? "unknown";
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
756
|
+
const autoSelection = this.resolvePermission ? void 0 : choosePermissionOption(params.options);
|
|
757
|
+
const controller = this.resolvePermission ? new AbortController() : void 0;
|
|
758
|
+
if (controller) {
|
|
759
|
+
this.trackPending(params.sessionId, controller);
|
|
760
|
+
}
|
|
761
|
+
const [, chosenId] = await Promise.all([
|
|
762
|
+
// This is the room's only "a permission request is pending" signal,
|
|
763
|
+
// and the only one other room participants ever see — started
|
|
764
|
+
// immediately rather than serialized in front of a manual wait that
|
|
765
|
+
// can take up to `permissionTimeoutMs`.
|
|
766
|
+
tools.sendEvent(`Permission requested: ${toolName}`, "tool_call", {
|
|
767
|
+
permission_request: true,
|
|
768
|
+
tool_name: toolName,
|
|
769
|
+
tool_call_id: params.toolCall.toolCallId,
|
|
770
|
+
acp_session_id: params.sessionId,
|
|
771
|
+
auto_allowed: autoSelection !== void 0 && autoSelection !== null
|
|
772
|
+
}),
|
|
773
|
+
controller ? this.resolveManually(params.sessionId, params, controller) : Promise.resolve(autoSelection?.optionId)
|
|
774
|
+
]);
|
|
775
|
+
return this.toResponse(chosenId, params.options);
|
|
776
|
+
}
|
|
777
|
+
// `undefined`, or an id absent from this request's own `options` (a buggy
|
|
778
|
+
// or stale caller), both map to `cancelled` — never silently treated as a
|
|
779
|
+
// deny. A real match, reject-kind options included, maps to `selected`.
|
|
780
|
+
toResponse(chosenId, options) {
|
|
781
|
+
const matched = chosenId !== void 0 && options.some((option) => option.optionId === chosenId);
|
|
782
|
+
return matched ? { outcome: { outcome: "selected", optionId: chosenId } } : { outcome: { outcome: "cancelled" } };
|
|
783
|
+
}
|
|
784
|
+
// A caller-supplied `Logger` isn't guaranteed to be synchronous or
|
|
785
|
+
// non-throwing. Every best-effort warning in this file routes through here
|
|
786
|
+
// so one failing sink — a synchronous throw, or an `async` implementation
|
|
787
|
+
// rejecting (the `Logger` interface's `void` return type permits either;
|
|
788
|
+
// a bare try/catch only ever catches the former) — can't turn a warning
|
|
789
|
+
// into an unhandled rejection in its place.
|
|
790
|
+
safeWarn(message, context) {
|
|
791
|
+
try {
|
|
792
|
+
Promise.resolve(this.logger.warn(message, context)).catch(() => void 0);
|
|
793
|
+
} catch {
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
// Races the caller-supplied resolver against a timeout and against
|
|
797
|
+
// `controller`'s own abort signal — aborted externally by
|
|
798
|
+
// `cancelPendingPermissions`/`cancelAllPendingPermissions` (fired from
|
|
799
|
+
// `onCleanup`/`stop()` below) when a room or the whole adapter tears down
|
|
800
|
+
// while this is still pending. `controller` is the same object tracked in
|
|
801
|
+
// `pendingPermissions` by the caller, so there is exactly one cancellation
|
|
802
|
+
// channel here, not a second hand-rolled one alongside it.
|
|
803
|
+
async resolveManually(sessionId, params, controller) {
|
|
804
|
+
let timer;
|
|
805
|
+
const cancelled = new Promise((resolve) => {
|
|
806
|
+
controller.signal.addEventListener("abort", () => resolve(void 0));
|
|
695
807
|
});
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
808
|
+
try {
|
|
809
|
+
const timeout = new Promise((resolve) => {
|
|
810
|
+
timer = setTimeout(() => resolve(void 0), this.permissionTimeoutMs);
|
|
811
|
+
});
|
|
812
|
+
return await Promise.race([
|
|
813
|
+
// `resolvePermission` is caller-supplied; nothing guarantees it's
|
|
814
|
+
// `async` or otherwise well-behaved. `Promise.resolve().then(...)`
|
|
815
|
+
// normalizes a synchronous throw the same way it normalizes a
|
|
816
|
+
// rejected promise, so both land in the `.catch` below rather than
|
|
817
|
+
// escaping this race uncaught.
|
|
818
|
+
Promise.resolve().then(() => this.resolvePermission(params, controller.signal)).catch((error) => {
|
|
819
|
+
this.safeWarn("resolvePermission threw; treating as no answer", { error: String(error) });
|
|
820
|
+
return void 0;
|
|
821
|
+
}),
|
|
822
|
+
timeout,
|
|
823
|
+
cancelled
|
|
824
|
+
]);
|
|
825
|
+
} finally {
|
|
826
|
+
clearTimeout(timer);
|
|
827
|
+
this.untrackPending(sessionId, controller);
|
|
828
|
+
controller.abort();
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
trackPending(sessionId, controller) {
|
|
832
|
+
const pending = this.pendingPermissions.get(sessionId) ?? /* @__PURE__ */ new Set();
|
|
833
|
+
pending.add(controller);
|
|
834
|
+
this.pendingPermissions.set(sessionId, pending);
|
|
835
|
+
}
|
|
836
|
+
untrackPending(sessionId, controller) {
|
|
837
|
+
const pending = this.pendingPermissions.get(sessionId);
|
|
838
|
+
pending?.delete(controller);
|
|
839
|
+
if (pending?.size === 0) {
|
|
840
|
+
this.pendingPermissions.delete(sessionId);
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
cancelPendingPermissions(sessionId) {
|
|
844
|
+
for (const controller of this.pendingPermissions.get(sessionId) ?? []) {
|
|
845
|
+
controller.abort();
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
cancelAllPendingPermissions() {
|
|
849
|
+
for (const sessionId of this.pendingPermissions.keys()) {
|
|
850
|
+
this.cancelPendingPermissions(sessionId);
|
|
702
851
|
}
|
|
703
|
-
return {
|
|
704
|
-
outcome: {
|
|
705
|
-
outcome: "selected",
|
|
706
|
-
optionId: selected.optionId
|
|
707
|
-
}
|
|
708
|
-
};
|
|
709
852
|
}
|
|
710
853
|
async flushChunks(input) {
|
|
711
854
|
const client = this.client;
|
|
@@ -713,13 +856,14 @@ ${message.content}`;
|
|
|
713
856
|
return;
|
|
714
857
|
}
|
|
715
858
|
for (const chunk of client.getCollectedChunks(input.sessionId)) {
|
|
859
|
+
if (isBlankEventContent(chunk.content)) {
|
|
860
|
+
continue;
|
|
861
|
+
}
|
|
716
862
|
if (chunk.chunkType === "text") {
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
}]);
|
|
722
|
-
}
|
|
863
|
+
await input.tools.sendMessage(chunk.content, [{
|
|
864
|
+
id: input.senderId,
|
|
865
|
+
handle: input.senderHandle
|
|
866
|
+
}]);
|
|
723
867
|
continue;
|
|
724
868
|
}
|
|
725
869
|
const messageType = chunk.chunkType === "plan" ? "task" : chunk.chunkType;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ValidationError
|
|
3
|
+
} from "./chunk-JY75VSQK.js";
|
|
4
|
+
|
|
5
|
+
// src/contracts/chatEvents.ts
|
|
6
|
+
var CHAT_EVENT_TYPES = ["tool_call", "tool_result", "thought", "error", "task"];
|
|
7
|
+
var CHAT_MESSAGE_TYPES = ["text", ...CHAT_EVENT_TYPES];
|
|
8
|
+
function isChatEventType(value) {
|
|
9
|
+
return CHAT_EVENT_TYPES.includes(value);
|
|
10
|
+
}
|
|
11
|
+
function assertChatEventType(value) {
|
|
12
|
+
if (!isChatEventType(value)) {
|
|
13
|
+
throw new ValidationError(
|
|
14
|
+
`Invalid event message_type '${value}'. Expected one of: ${CHAT_EVENT_TYPES.join(", ")}`
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
var VISIBLE_CONTENT_PATTERN = /[\p{L}\p{N}\p{P}\p{S}]/u;
|
|
19
|
+
function isBlankEventContent(content) {
|
|
20
|
+
return !VISIBLE_CONTENT_PATTERN.test(content);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export {
|
|
24
|
+
CHAT_EVENT_TYPES,
|
|
25
|
+
CHAT_MESSAGE_TYPES,
|
|
26
|
+
isChatEventType,
|
|
27
|
+
assertChatEventType,
|
|
28
|
+
isBlankEventContent
|
|
29
|
+
};
|
|
@@ -21,6 +21,13 @@ function isToolExecutorError(value) {
|
|
|
21
21
|
const candidate = value;
|
|
22
22
|
return candidate.ok === false && typeof candidate.errorType === "string" && TOOL_EXECUTOR_ERROR_TYPES.includes(candidate.errorType) && typeof candidate.toolName === "string" && typeof candidate.message === "string" && typeof candidate.legacyMessage === "string";
|
|
23
23
|
}
|
|
24
|
+
function isStructuredToolFailure(value) {
|
|
25
|
+
if (!value || typeof value !== "object") {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
const payload = value;
|
|
29
|
+
return payload.ok === false && typeof payload.message === "string";
|
|
30
|
+
}
|
|
24
31
|
function toLegacyToolExecutorErrorMessage(value) {
|
|
25
32
|
if (typeof value === "string") {
|
|
26
33
|
return value;
|
|
@@ -39,6 +46,7 @@ var DEFAULT_AGENT_TOOLS_CAPABILITIES = {
|
|
|
39
46
|
export {
|
|
40
47
|
createToolExecutorError,
|
|
41
48
|
isToolExecutorError,
|
|
49
|
+
isStructuredToolFailure,
|
|
42
50
|
toLegacyToolExecutorErrorMessage,
|
|
43
51
|
DEFAULT_AGENT_TOOLS_CAPABILITIES
|
|
44
52
|
};
|