@beeos-ai/bma-executor-sdk 0.0.0-stage → 0.4.1

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/client.js ADDED
@@ -0,0 +1,610 @@
1
+ // Executor end of the BMA executor protocol: registration, heartbeat,
2
+ // reconnect with resume, session lifecycle, tool dispatch and cancellation,
3
+ // retried tool results and the raw MCP channel. Mirrors go/executor Client.
4
+ import { ChannelScope, ConnectionState, JsonRpcErrorCode, methods, ProtocolVersion, } from './generated/executor.js';
5
+ import { AgentRuntime } from './agent.js';
6
+ import { ClientStoppedError, deferred, NotConnectedError, RequestTimeoutError, RpcError } from './errors.js';
7
+ import { DEFAULT_PROTOCOLS } from './local.js';
8
+ import { RpcPeer } from './rpc.js';
9
+ import { dialWebSocket, FrameChannel } from './transport.js';
10
+ export const DEFAULT_BASE_URL = 'https://api.bma.beeos.ai';
11
+ export const DEFAULT_REQUEST_TIMEOUT_MS = 30_000;
12
+ export const DEFAULT_MAX_RECONNECT_ATTEMPTS = 10;
13
+ export const DEFAULT_RECONNECT_BASE_DELAY_MS = 500;
14
+ export const DEFAULT_TOOL_RESULT_RETRY_ATTEMPTS = 5;
15
+ export const DEFAULT_TOOL_RESULT_RETRY_BASE_DELAY_MS = 250;
16
+ const DEFAULT_HEARTBEAT_INTERVAL_MS = 15_000;
17
+ const MAX_TRACKED_TOOL_CALLS = 8192;
18
+ const MAX_TOOL_RESULT_RETRY_DELAY_MS = 10_000;
19
+ const MAX_RECONNECT_DELAY_MS = 30_000;
20
+ /** Close codes after which the executor must not reconnect (1008 policy, 4002 revoked, 4003 protocol, 4004 replaced, 4005 drained). */
21
+ export function isTerminalCloseCode(code) {
22
+ return code === 1008 || code === 4002 || code === 4003 || code === 4004 || code === 4005;
23
+ }
24
+ /** A TokenSource for a harness reached directly: ws://127.0.0.1, unix:///path.sock or npipe:////./pipe/<name>. */
25
+ export function staticToken(wsUrl, token = '') {
26
+ return async () => ({ token, ws_url: wsUrl });
27
+ }
28
+ export function channelUrl(rawUrl, target) {
29
+ const url = new URL(rawUrl);
30
+ if (!['ws:', 'wss:', 'unix:', 'npipe:'].includes(url.protocol)) {
31
+ throw new Error('executor channel URL must use ws, wss, unix or npipe');
32
+ }
33
+ if (target.channel === ChannelScope.Mcp) {
34
+ url.searchParams.set('channel', 'mcp');
35
+ url.searchParams.set('session_id', target.sessionId ?? '');
36
+ url.searchParams.set('server_key', target.serverKey ?? '');
37
+ }
38
+ return url.toString();
39
+ }
40
+ /** The cloud dialer: token bootstrap, then an outbound WebSocket with the bearer token. */
41
+ export function webSocketDialer(options) {
42
+ if (!options.tokenSource && !options.environmentKey?.trim())
43
+ throw new Error('environmentKey or tokenSource is required');
44
+ const fetchToken = options.tokenSource ??
45
+ (async () => {
46
+ const base = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, '');
47
+ const response = await (options.fetch ?? fetch)(`${base}/v1/executors/token`, {
48
+ method: 'POST',
49
+ headers: { Authorization: `Bearer ${options.environmentKey}`, 'Content-Type': 'application/json' },
50
+ body: JSON.stringify({ environment_id: options.environmentId, executor: options.executor }),
51
+ });
52
+ if (response.status !== 200) {
53
+ const detail = (await response.text()).slice(0, 4096).trim();
54
+ throw new Error(`executor token request failed: ${response.status}: ${detail}`);
55
+ }
56
+ const token = (await response.json());
57
+ if (!token.token || !token.ws_url)
58
+ throw new Error('executor token response is missing token or ws_url');
59
+ return token;
60
+ });
61
+ return async (target) => {
62
+ const token = await fetchToken();
63
+ const wsUrl = options.wsUrl || token.ws_url;
64
+ if (!wsUrl)
65
+ throw new Error('token source returned no ws_url');
66
+ if (target.channel === ChannelScope.Mcp && token.channel_scope?.length && !token.channel_scope.includes(ChannelScope.Mcp)) {
67
+ throw new Error('executor token does not allow the mcp channel');
68
+ }
69
+ return dialWebSocket(channelUrl(wsUrl, target), { protocols: options.protocols ?? DEFAULT_PROTOCOLS, token: token.token });
70
+ };
71
+ }
72
+ /** Remembers up to MAX_TRACKED_TOOL_CALLS ids, evicting the oldest. */
73
+ class BoundedSet {
74
+ items = new Set();
75
+ has(id) {
76
+ return this.items.has(id);
77
+ }
78
+ add(id) {
79
+ if (this.items.size >= MAX_TRACKED_TOOL_CALLS) {
80
+ const oldest = this.items.values().next().value;
81
+ if (oldest !== undefined)
82
+ this.items.delete(oldest);
83
+ }
84
+ this.items.add(id);
85
+ }
86
+ delete(id) {
87
+ this.items.delete(id);
88
+ }
89
+ }
90
+ function sleep(ms, signal) {
91
+ return new Promise((resolve, reject) => {
92
+ if (signal.aborted)
93
+ return reject(new ClientStoppedError());
94
+ const timer = setTimeout(() => {
95
+ signal.removeEventListener('abort', onAbort);
96
+ resolve();
97
+ }, ms);
98
+ const onAbort = () => {
99
+ clearTimeout(timer);
100
+ reject(new ClientStoppedError());
101
+ };
102
+ signal.addEventListener('abort', onAbort, { once: true });
103
+ });
104
+ }
105
+ /** An executor client. One client is one logical executor connection to one harness. */
106
+ export class ExecutorClient {
107
+ options;
108
+ dialer;
109
+ peer;
110
+ currentState = ConnectionState.Disconnected;
111
+ stopped = false;
112
+ stopController = new AbortController();
113
+ registerResult;
114
+ currentConnectionId = '';
115
+ currentExecutorId = '';
116
+ heartbeatIntervalMs;
117
+ heartbeatTimer;
118
+ reconnectAttempts = 0;
119
+ sessions = new Set();
120
+ completedToolResults = new BoundedSet();
121
+ seenToolCalls = new BoundedSet();
122
+ running = new Map();
123
+ tools = new Map();
124
+ toolCallHandler;
125
+ sessionAssignHandler;
126
+ sessionStopHandler;
127
+ drainHandler;
128
+ requestHandlers = new Map();
129
+ notificationHandlers = new Map();
130
+ registration = deferred();
131
+ agent;
132
+ constructor(options) {
133
+ if (options.environmentId === undefined)
134
+ throw new Error('environmentId is required');
135
+ if (!options.executor?.name)
136
+ throw new Error('executor.name is required');
137
+ this.options = options;
138
+ this.dialer = options.dialer ?? webSocketDialer(options);
139
+ this.heartbeatIntervalMs = options.heartbeatIntervalMs ?? DEFAULT_HEARTBEAT_INTERVAL_MS;
140
+ }
141
+ get state() {
142
+ return this.currentState;
143
+ }
144
+ get executorId() {
145
+ return this.currentExecutorId;
146
+ }
147
+ get connectionId() {
148
+ return this.currentConnectionId;
149
+ }
150
+ /** The negotiated protocol of the current connection. */
151
+ get protocol() {
152
+ return this.peer?.conn.protocol;
153
+ }
154
+ get activeSessions() {
155
+ return [...this.sessions];
156
+ }
157
+ /** Registers the handler for every tool without a handleTool handler. */
158
+ onToolCall(handler) {
159
+ this.toolCallHandler = handler;
160
+ }
161
+ /** Registers the handler for one tool name (bash, read, ..., or a custom name). */
162
+ handleTool(name, handler) {
163
+ this.tools.set(name, handler);
164
+ }
165
+ onSessionAssign(handler) {
166
+ this.sessionAssignHandler = handler;
167
+ }
168
+ onSessionStop(handler) {
169
+ this.sessionStopHandler = handler;
170
+ }
171
+ onDrain(handler) {
172
+ this.drainHandler = handler;
173
+ }
174
+ /** Registers a handler for another harness-to-executor request (process.*, terminal.*, skill.install). */
175
+ onRequest(method, handler) {
176
+ this.requestHandlers.set(method, handler);
177
+ }
178
+ onNotification(method, handler) {
179
+ this.notificationHandlers.set(method, handler);
180
+ }
181
+ /** Advertises the agent capability and serves turn.*, session.close and interaction.response. Call before start. */
182
+ serveAgent(handler, capability = {}) {
183
+ this.agent = new AgentRuntime(this.agentHost(), handler, { ...capability, enabled: true });
184
+ }
185
+ /** Dials, registers and starts heartbeats. */
186
+ async start() {
187
+ if (this.stopped)
188
+ throw new ClientStoppedError();
189
+ if (this.peer)
190
+ throw new Error('executor client already started');
191
+ try {
192
+ await this.connect();
193
+ }
194
+ catch (error) {
195
+ this.currentState = ConnectionState.Disconnected;
196
+ throw error;
197
+ }
198
+ this.scheduleHeartbeat();
199
+ return this.registerResult;
200
+ }
201
+ /** Sends executor.close, closes the channel and stops reconnecting. */
202
+ stop(reason = 'stopped') {
203
+ if (this.stopped)
204
+ return;
205
+ this.stopped = true;
206
+ this.currentState = ConnectionState.Closed;
207
+ clearTimeout(this.heartbeatTimer);
208
+ const peer = this.peer;
209
+ this.peer = undefined;
210
+ if (peer && !peer.closed) {
211
+ try {
212
+ peer.notify('executor.close', { reason });
213
+ }
214
+ catch {
215
+ // already gone
216
+ }
217
+ peer.close(1000, reason);
218
+ }
219
+ this.stopController.abort(new ClientStoppedError());
220
+ }
221
+ /** Sends a request on the control channel. */
222
+ call(method, params) {
223
+ const peer = this.peer;
224
+ if (!peer)
225
+ return Promise.reject(this.stopped ? new ClientStoppedError() : new NotConnectedError());
226
+ return peer.call(method, params, this.options.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS);
227
+ }
228
+ /** Sends a notification on the control channel. */
229
+ notify(method, params) {
230
+ const peer = this.peer;
231
+ if (!peer)
232
+ throw new NotConnectedError();
233
+ peer.notify(method, params);
234
+ }
235
+ /** Reports that the session is prepared; call after workspace and MCP setup. */
236
+ sessionReady(params) {
237
+ return this.call('session.ready', params);
238
+ }
239
+ /** Reports that every process and MCP server of the session stopped. */
240
+ async sessionEnded(params) {
241
+ const result = await this.call('session.ended', params);
242
+ this.sessions.delete(params.session_id);
243
+ return result;
244
+ }
245
+ /** session.event for a tool executor (v1 shape, without agent fields). */
246
+ sessionEvent(params) {
247
+ return this.call('session.event', params);
248
+ }
249
+ sessionStatus(params) {
250
+ this.notify('session.status', params);
251
+ }
252
+ toolProgress(params) {
253
+ this.notify('tool.progress', params);
254
+ }
255
+ /** Replaces the advertised capabilities; they are also sent on every re-register. */
256
+ updateCapabilities(capabilities) {
257
+ this.options.capabilities = capabilities;
258
+ const params = { capabilities: this.registeredCapabilities() };
259
+ this.notify('executor.capabilities.update', params);
260
+ }
261
+ /**
262
+ * Sends tool.result once per tool_call_id, retrying retryable failures with
263
+ * exponential backoff. A repeat for an accepted id resolves without a frame.
264
+ */
265
+ async reportToolResult(params) {
266
+ if (this.completedToolResults.has(params.tool_call_id))
267
+ return { accepted: true };
268
+ this.completedToolResults.add(params.tool_call_id);
269
+ const attempts = this.options.toolResultRetryAttempts ?? DEFAULT_TOOL_RESULT_RETRY_ATTEMPTS;
270
+ let lastError;
271
+ for (let attempt = 1; attempt <= attempts; attempt++) {
272
+ try {
273
+ return await this.call('tool.result', params);
274
+ }
275
+ catch (error) {
276
+ lastError = error;
277
+ if (attempt === attempts || !retryableToolResultError(error))
278
+ break;
279
+ this.log('warn', `tool.result for ${params.tool_call_id} failed on attempt ${attempt}, retrying`, error);
280
+ try {
281
+ await sleep(this.toolResultRetryDelay(attempt), this.stopController.signal);
282
+ }
283
+ catch (stopped) {
284
+ lastError = stopped;
285
+ break;
286
+ }
287
+ }
288
+ }
289
+ this.completedToolResults.delete(params.tool_call_id);
290
+ throw lastError;
291
+ }
292
+ /** Opens the raw MCP channel for one session.assign mcp_servers entry. */
293
+ async openMcpChannel(sessionId, serverKey) {
294
+ if (!sessionId.trim())
295
+ throw new Error('sessionId is required');
296
+ if (!serverKey.trim())
297
+ throw new Error('serverKey is required');
298
+ if (this.stopped)
299
+ throw new ClientStoppedError();
300
+ return new FrameChannel(await this.dialer({ channel: ChannelScope.Mcp, sessionId, serverKey }));
301
+ }
302
+ // --- connection -----------------------------------------------------------
303
+ registeredCapabilities() {
304
+ const capabilities = { ...(this.options.capabilities ?? {}) };
305
+ if (this.agent)
306
+ capabilities.agent = this.agent.capability;
307
+ return capabilities;
308
+ }
309
+ resumeState() {
310
+ if (!this.currentExecutorId && !this.currentConnectionId && this.sessions.size === 0)
311
+ return undefined;
312
+ return {
313
+ active_sessions: this.activeSessions,
314
+ ...(this.currentExecutorId ? { executor_id: this.currentExecutorId } : {}),
315
+ ...(this.currentConnectionId ? { last_connection_id: this.currentConnectionId } : {}),
316
+ };
317
+ }
318
+ async connect() {
319
+ this.currentState = ConnectionState.Connecting;
320
+ const conn = await this.dialer({ channel: ChannelScope.Control });
321
+ if (this.stopped) {
322
+ conn.close(1000, 'stopped');
323
+ throw new ClientStoppedError();
324
+ }
325
+ const peer = new RpcPeer(conn, {
326
+ idPrefix: 'req_',
327
+ requestTimeoutMs: this.options.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS,
328
+ onRequest: (method, params) => this.dispatchRequest(method, params),
329
+ onNotification: (method, params) => this.dispatchNotification(peer, method, params),
330
+ onClose: (code) => this.disconnected(peer, code),
331
+ log: this.options.onLog,
332
+ });
333
+ this.peer = peer;
334
+ const protocol = (conn.protocol || ProtocolVersion.BmaExecutorV11);
335
+ const resume = this.resumeState();
336
+ const params = {
337
+ protocol,
338
+ environment_id: this.options.environmentId,
339
+ executor: this.options.executor,
340
+ capabilities: this.registeredCapabilities(),
341
+ ...(resume ? { resume } : {}),
342
+ };
343
+ let result;
344
+ try {
345
+ result = await this.call('executor.register', params);
346
+ }
347
+ catch (error) {
348
+ if (this.peer === peer)
349
+ this.peer = undefined;
350
+ peer.close(1011, 'registration failed');
351
+ throw error;
352
+ }
353
+ this.registerResult = result;
354
+ this.currentConnectionId = result.connection_id;
355
+ this.currentExecutorId = result.executor_id;
356
+ this.heartbeatIntervalMs =
357
+ result.heartbeat_interval_ms > 0 ? result.heartbeat_interval_ms : (this.options.heartbeatIntervalMs ?? DEFAULT_HEARTBEAT_INTERVAL_MS);
358
+ this.currentState = result.drain ? ConnectionState.Draining : ConnectionState.Ready;
359
+ this.reconnectAttempts = 0;
360
+ const registered = this.registration;
361
+ this.registration = deferred();
362
+ registered.resolve();
363
+ this.log('info', `executor registered as ${result.executor_id}`);
364
+ }
365
+ disconnected(peer, code) {
366
+ if (this.peer !== peer)
367
+ return;
368
+ this.peer = undefined;
369
+ if (this.stopped) {
370
+ this.currentState = ConnectionState.Closed;
371
+ return;
372
+ }
373
+ this.currentState = ConnectionState.Disconnected;
374
+ if (isTerminalCloseCode(code) || this.options.reconnect === false) {
375
+ this.currentState = ConnectionState.Closed;
376
+ this.log('warn', `executor channel closed with ${code}; not reconnecting`);
377
+ return;
378
+ }
379
+ this.scheduleReconnect();
380
+ }
381
+ scheduleReconnect() {
382
+ if (this.stopped)
383
+ return;
384
+ const max = this.options.maxReconnectAttempts ?? DEFAULT_MAX_RECONNECT_ATTEMPTS;
385
+ if (this.reconnectAttempts >= max) {
386
+ this.currentState = ConnectionState.Closed;
387
+ this.log('error', 'executor reconnect attempts exhausted');
388
+ return;
389
+ }
390
+ const attempt = this.reconnectAttempts++;
391
+ const base = this.options.reconnectBaseDelayMs ?? DEFAULT_RECONNECT_BASE_DELAY_MS;
392
+ const delay = Math.min(base * 2 ** attempt, MAX_RECONNECT_DELAY_MS) * (0.5 + this.random() * 0.5);
393
+ this.log('info', `reconnecting executor channel in ${Math.round(delay)}ms`);
394
+ setTimeout(() => void this.reconnect(), delay);
395
+ }
396
+ async reconnect() {
397
+ if (this.stopped)
398
+ return;
399
+ try {
400
+ await this.connect();
401
+ }
402
+ catch (error) {
403
+ this.log('warn', 'executor reconnect failed', error);
404
+ this.currentState = ConnectionState.Disconnected;
405
+ this.scheduleReconnect();
406
+ }
407
+ }
408
+ scheduleHeartbeat() {
409
+ if (this.stopped)
410
+ return;
411
+ this.heartbeatTimer = setTimeout(() => {
412
+ void this.heartbeat().finally(() => this.scheduleHeartbeat());
413
+ }, this.heartbeatIntervalMs);
414
+ this.heartbeatTimer.unref?.();
415
+ }
416
+ async heartbeat() {
417
+ if (this.currentState !== ConnectionState.Ready && this.currentState !== ConnectionState.Draining)
418
+ return;
419
+ const load = this.options.heartbeatLoad?.();
420
+ const params = {
421
+ connection_id: this.currentConnectionId,
422
+ active_sessions: this.activeSessions,
423
+ ...(load ? { load } : {}),
424
+ };
425
+ try {
426
+ const result = await this.call('executor.heartbeat', params);
427
+ if (result.drain && this.currentState === ConnectionState.Ready)
428
+ this.currentState = ConnectionState.Draining;
429
+ }
430
+ catch (error) {
431
+ this.log('warn', 'executor heartbeat failed', error);
432
+ }
433
+ }
434
+ // --- inbound --------------------------------------------------------------
435
+ dispatchRequest(method, params) {
436
+ switch (method) {
437
+ case 'tool.call':
438
+ return this.acceptToolCall(params);
439
+ case 'tool.cancel':
440
+ return this.cancelToolCall(params);
441
+ case 'session.assign':
442
+ return this.assignSession(params);
443
+ case 'session.stop':
444
+ return this.stopSession(params);
445
+ case 'executor.drain':
446
+ return this.drain(params);
447
+ }
448
+ const agentResult = this.agent?.dispatch(method, params);
449
+ if (agentResult !== undefined)
450
+ return agentResult;
451
+ const handler = this.requestHandlers.get(method);
452
+ if (!handler)
453
+ throw unregisteredMethodError(method);
454
+ return handler(params);
455
+ }
456
+ dispatchNotification(peer, method, params) {
457
+ if (method === 'executor.close') {
458
+ this.stopped = true;
459
+ this.currentState = ConnectionState.Closed;
460
+ clearTimeout(this.heartbeatTimer);
461
+ if (this.peer === peer)
462
+ this.peer = undefined;
463
+ peer.close(1000, 'executor.close');
464
+ this.stopController.abort(new ClientStoppedError());
465
+ return;
466
+ }
467
+ this.notificationHandlers.get(method)?.(params);
468
+ }
469
+ async assignSession(params) {
470
+ if (this.currentState === ConnectionState.Draining)
471
+ return { accepted: false, session_id: params.session_id };
472
+ const result = this.sessionAssignHandler
473
+ ? await this.sessionAssignHandler(params)
474
+ : { accepted: true, session_id: params.session_id };
475
+ if (result.accepted)
476
+ this.sessions.add(params.session_id);
477
+ return result;
478
+ }
479
+ async stopSession(params) {
480
+ const result = this.sessionStopHandler ? await this.sessionStopHandler(params) : { stopped: true };
481
+ this.sessions.delete(params.session_id);
482
+ return result;
483
+ }
484
+ async drain(params) {
485
+ this.currentState = ConnectionState.Draining;
486
+ if (this.drainHandler)
487
+ return this.drainHandler(params);
488
+ return { accepted: true, active_sessions: this.activeSessions };
489
+ }
490
+ /** Accepts a tool.call at most once per tool_call_id; a resent call is acknowledged and ignored. */
491
+ acceptToolCall(call) {
492
+ if (!call || typeof call.tool_call_id !== 'string' || typeof call.session_id !== 'string') {
493
+ throw new RpcError(JsonRpcErrorCode.InvalidParams, 'invalid tool.call params');
494
+ }
495
+ if (this.seenToolCalls.has(call.tool_call_id) || this.running.has(call.tool_call_id)) {
496
+ this.log('debug', `duplicate tool.call for ${call.tool_call_id} ignored`);
497
+ return { accepted: true };
498
+ }
499
+ this.seenToolCalls.add(call.tool_call_id);
500
+ const running = { abort: new AbortController(), canceled: false, reason: '' };
501
+ this.running.set(call.tool_call_id, running);
502
+ // Starts after the acknowledgement is written.
503
+ setImmediate(() => void this.runToolCall(call, running));
504
+ return { accepted: true };
505
+ }
506
+ cancelToolCall(params) {
507
+ const running = this.running.get(params.tool_call_id);
508
+ if (!running)
509
+ return { canceled: false };
510
+ running.canceled = true;
511
+ running.reason = params.reason ?? '';
512
+ running.abort.abort(new Error(`canceled: ${params.reason}`));
513
+ this.log('info', `canceled tool.call ${params.tool_call_id}`);
514
+ return { canceled: true };
515
+ }
516
+ async runToolCall(call, running) {
517
+ const handler = this.tools.get(call.tool) ?? this.toolCallHandler;
518
+ const onStop = () => running.abort.abort(new ClientStoppedError());
519
+ this.stopController.signal.addEventListener('abort', onStop, { once: true });
520
+ const deadline = call.deadline_ms && call.deadline_ms > 0
521
+ ? setTimeout(() => running.abort.abort(new RequestTimeoutError('tool.call')), call.deadline_ms)
522
+ : undefined;
523
+ let result;
524
+ try {
525
+ if (!handler)
526
+ throw new Error(`no tool handler registered for ${call.tool}`);
527
+ result = await handler(call, {
528
+ signal: running.abort.signal,
529
+ progress: (message) => {
530
+ try {
531
+ this.toolProgress({ session_id: call.session_id, tool_call_id: call.tool_call_id, message });
532
+ }
533
+ catch (error) {
534
+ this.log('debug', 'tool.progress dropped', error);
535
+ }
536
+ },
537
+ });
538
+ }
539
+ catch (error) {
540
+ result = failedToolResult(error instanceof Error ? error.message : String(error));
541
+ }
542
+ finally {
543
+ clearTimeout(deadline);
544
+ this.stopController.signal.removeEventListener('abort', onStop);
545
+ this.running.delete(call.tool_call_id);
546
+ }
547
+ if (running.canceled)
548
+ result = canceledToolResult(running.reason);
549
+ // The result identifies the dispatched call whatever the handler returned.
550
+ const params = { ...result, session_id: call.session_id, tool_call_id: call.tool_call_id };
551
+ try {
552
+ await this.reportToolResult(params);
553
+ }
554
+ catch (error) {
555
+ this.log('error', `failed to report tool result for ${call.tool_call_id}`, error);
556
+ this.options.onToolResultLost?.(params, error);
557
+ }
558
+ }
559
+ toolResultRetryDelay(attempt) {
560
+ const base = this.options.toolResultRetryBaseDelayMs ?? DEFAULT_TOOL_RESULT_RETRY_BASE_DELAY_MS;
561
+ const delay = Math.min(base * 2 ** (attempt - 1), MAX_TOOL_RESULT_RETRY_DELAY_MS);
562
+ return delay * (0.5 + this.random() * 0.5);
563
+ }
564
+ random() {
565
+ return (this.options.random ?? Math.random)();
566
+ }
567
+ log(level, message, error) {
568
+ this.options.onLog?.({ level, message, error });
569
+ }
570
+ agentHost() {
571
+ return {
572
+ call: (method, params) => this.call(method, params),
573
+ notify: (method, params) => this.notify(method, params),
574
+ stopSignal: this.stopController.signal,
575
+ connected: () => this.currentState === ConnectionState.Ready || this.currentState === ConnectionState.Draining,
576
+ nextRegistration: () => this.registration.promise,
577
+ addSession: (id) => this.sessions.add(id),
578
+ removeSession: (id) => this.sessions.delete(id),
579
+ sessionEnded: (params) => this.sessionEnded(params),
580
+ log: (level, message, error) => this.log(level, message, error),
581
+ };
582
+ }
583
+ }
584
+ export function retryableToolResultError(error) {
585
+ if (error instanceof RpcError) {
586
+ if (error.data?.retryable !== undefined)
587
+ return error.data.retryable;
588
+ return error.code === JsonRpcErrorCode.ExecutorBusy || error.code === JsonRpcErrorCode.Timeout;
589
+ }
590
+ return error instanceof NotConnectedError || error instanceof RequestTimeoutError;
591
+ }
592
+ function failedToolResult(message) {
593
+ return { outcome: 'failed', is_error: true, content: [{ type: 'text', text: message }] };
594
+ }
595
+ function canceledToolResult(reason) {
596
+ return { outcome: 'canceled', is_error: false, content: [{ type: 'text', text: reason ? `canceled: ${reason}` : 'canceled' }] };
597
+ }
598
+ /**
599
+ * A contract method behind a capability this executor did not register is
600
+ * capability_unavailable naming that capability; anything else is
601
+ * method_not_found.
602
+ */
603
+ function unregisteredMethodError(method) {
604
+ const spec = Object.hasOwn(methods, method) ? methods[method] : undefined;
605
+ if (!spec?.capability || spec.direction === 'executor-to-harness') {
606
+ return new RpcError(JsonRpcErrorCode.MethodNotFound, `unknown method ${method}`);
607
+ }
608
+ return new RpcError(JsonRpcErrorCode.CapabilityUnavailable, 'capability_unavailable', { capability: spec.capability });
609
+ }
610
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,4EAA4E;AAC5E,4EAA4E;AAE5E,OAAO,EACL,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,OAAO,EACP,eAAe,GA6BhB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,YAAY,EAAqC,MAAM,YAAY,CAAA;AAC5E,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAC5G,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAC9C,OAAO,EAAE,OAAO,EAA8B,MAAM,UAAU,CAAA;AAC9D,OAAO,EAAE,aAAa,EAAE,YAAY,EAAa,MAAM,gBAAgB,CAAA;AAEvE,MAAM,CAAC,MAAM,gBAAgB,GAAG,0BAA0B,CAAA;AAC1D,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAA;AAChD,MAAM,CAAC,MAAM,8BAA8B,GAAG,EAAE,CAAA;AAChD,MAAM,CAAC,MAAM,+BAA+B,GAAG,GAAG,CAAA;AAClD,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,CAAA;AACnD,MAAM,CAAC,MAAM,uCAAuC,GAAG,GAAG,CAAA;AAC1D,MAAM,6BAA6B,GAAG,MAAM,CAAA;AAC5C,MAAM,sBAAsB,GAAG,IAAI,CAAA;AACnC,MAAM,8BAA8B,GAAG,MAAM,CAAA;AAC7C,MAAM,sBAAsB,GAAG,MAAM,CAAA;AAErC,uIAAuI;AACvI,MAAM,UAAU,mBAAmB,CAAC,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