@band-ai/sdk 0.3.3 → 0.4.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/README.md +54 -1
- package/dist/{ClaudeSDKAdapter-CXud2DBE.d.ts → CopilotACPAdapter-BCpbHFB0.d.ts} +240 -19
- package/dist/{ClaudeSDKAdapter-Cx6zhSaG.d.cts → CopilotACPAdapter-D4VWg8lJ.d.cts} +240 -19
- package/dist/{opencode-2YdscIc1.d.cts → acp-client-D-I_5lK-.d.cts} +23 -4
- package/dist/{opencode-Bld62x5t.d.ts → acp-client-DUXyczlF.d.ts} +23 -4
- package/dist/acp-server-BlcYMxKt.d.ts +17 -0
- package/dist/acp-server-CJhclo6P.d.cts +17 -0
- package/dist/adapters.cjs +2217 -973
- package/dist/adapters.d.cts +21 -132
- package/dist/adapters.d.ts +21 -132
- package/dist/adapters.js +26 -1914
- package/dist/{backends-D-dBdDm-.d.ts → backends-CgsPQa9B.d.ts} +2 -2
- package/dist/{backends-ZLxmQrTZ.d.cts → backends-Dh2WXcHQ.d.cts} +2 -2
- package/dist/{chunk-JY75VSQK.js → chunk-4OVNFDD7.js} +14 -1
- package/dist/chunk-6BE2EG5P.js +128 -0
- package/dist/{chunk-U6AFCLYZ.js → chunk-6TGXV5TE.js} +1824 -514
- package/dist/{chunk-OH6VVVKT.js → chunk-CBCHTTUY.js} +10 -0
- package/dist/{chunk-K5KAEYPF.js → chunk-HNWZZXAE.js} +288 -120
- package/dist/chunk-I34SXMTJ.js +6 -0
- package/dist/{chunk-XWHWJP4I.js → chunk-JDW5WSGF.js} +2 -2
- package/dist/{chunk-KXJ74J73.js → chunk-JIZE4EC6.js} +4 -10
- package/dist/chunk-OGOXY43L.js +119 -0
- package/dist/{chunk-W5IAI6Z4.js → chunk-OVXVZUPO.js} +5 -5
- package/dist/{chunk-YJ42AZO4.js → chunk-RJNJUISR.js} +5 -2
- package/dist/{chunk-MQY74R7D.js → chunk-SHZBLLDQ.js} +21 -9
- package/dist/{chunk-JADCAMZY.js → chunk-TGDDFBYS.js} +45 -0
- package/dist/{chunk-US226AS4.js → chunk-UENIC5FJ.js} +14 -11
- package/dist/{chunk-WA7CHXUS.js → chunk-UL3Y5C4J.js} +2 -2
- package/dist/{chunk-WL2HNJZ6.js → chunk-VOMJRQOM.js} +3 -3
- package/dist/{chunk-MQBBWYRP.js → chunk-YF7K4UB3.js} +3352 -572
- package/dist/{chunk-OD2G5LFQ.js → chunk-ZYOXI4JL.js} +41 -2
- package/dist/config.cjs +2 -12
- package/dist/config.js +2 -2
- package/dist/converters.cjs +36 -11
- package/dist/converters.d.cts +7 -5
- package/dist/converters.d.ts +7 -5
- package/dist/converters.js +11 -13
- package/dist/core.cjs +239 -5
- package/dist/core.d.cts +71 -6
- package/dist/core.d.ts +71 -6
- package/dist/core.js +31 -6
- package/dist/{customTools-BzF0IISO.d.cts → customTools-Bfecd0mJ.d.cts} +1 -1
- package/dist/{customTools-BzF0IISO.d.ts → customTools-Bfecd0mJ.d.ts} +1 -1
- package/dist/{disconnectReason-IuADl6TH.d.ts → disconnectReason-Cctmg1SN.d.cts} +1 -1
- package/dist/{disconnectReason-IuADl6TH.d.cts → disconnectReason-Cctmg1SN.d.ts} +1 -1
- package/dist/{dtos-B8KU_q4d.d.ts → dtos-CjQsN1_h.d.cts} +5 -12
- package/dist/{dtos-B8KU_q4d.d.cts → dtos-CjQsN1_h.d.ts} +5 -12
- package/dist/index.cjs +5237 -1474
- package/dist/index.d.cts +61 -22
- package/dist/index.d.ts +61 -22
- package/dist/index.js +151 -43
- package/dist/linear.cjs +45 -7
- package/dist/linear.d.cts +4 -3
- package/dist/linear.d.ts +4 -3
- package/dist/linear.js +10 -10
- package/dist/mcp-claude.cjs +11 -6
- package/dist/mcp-claude.d.cts +4 -3
- package/dist/mcp-claude.d.ts +4 -3
- package/dist/mcp-claude.js +4 -5
- package/dist/mcp.cjs +13 -7
- package/dist/mcp.d.cts +6 -5
- package/dist/mcp.d.ts +6 -5
- package/dist/mcp.js +5 -6
- package/dist/{pagination-DqdkQArT.d.cts → pagination-BZDhB_nO.d.cts} +2 -2
- package/dist/{pagination-BgEx-HeL.d.ts → pagination-CPz0J_vQ.d.ts} +2 -2
- package/dist/{protocols-Bz1rxcUg.d.cts → protocols-CabgO52c.d.cts} +38 -3
- package/dist/{protocols-Bwwcql0h.d.ts → protocols-Dpci6uae.d.ts} +38 -3
- package/dist/rest.cjs +43 -1
- package/dist/rest.d.cts +6 -5
- package/dist/rest.d.ts +6 -5
- package/dist/rest.js +6 -5
- package/dist/runtime.cjs +2113 -597
- package/dist/runtime.d.cts +44 -25
- package/dist/runtime.d.ts +44 -25
- package/dist/runtime.js +11 -11
- package/dist/{schemas-BgJhlqqO.d.cts → schemas-BKnh4fKR.d.cts} +209 -24
- package/dist/{schemas-C4mK1WSs.d.ts → schemas-CDa3V_I5.d.ts} +209 -24
- package/dist/{sdk-BTciSLRQ.d.cts → sdk-CXNqzoY1.d.cts} +1 -1
- package/dist/{sdk-qKJtMma_.d.ts → sdk-Cin80BTC.d.ts} +1 -1
- package/dist/{simpleAdapter-BpT4XbZC.d.cts → simpleAdapter-D75rcz9n.d.cts} +3 -1
- package/dist/{simpleAdapter--wznuoOw.d.ts → simpleAdapter-eLvsAQNo.d.ts} +3 -1
- package/dist/testing.cjs +25 -7
- package/dist/testing.d.cts +5 -3
- package/dist/testing.d.ts +5 -3
- package/dist/testing.js +9 -6
- package/dist/{types-BivGO7I9.d.ts → types-42-HWeX8.d.cts} +10 -4
- package/dist/types-CKU1N0SK.d.ts +137 -0
- package/dist/{types-BgYFd_Yw.d.cts → types-CjxZekMH.d.ts} +10 -4
- package/dist/types-DtcOLALn.d.cts +137 -0
- package/package.json +25 -26
- package/dist/acp-server-CiUqN3G3.d.ts +0 -24
- package/dist/acp-server-Dlj7D563.d.cts +0 -24
- package/dist/chunk-AVVDPXP4.js +0 -39
- package/dist/chunk-F63TPOI3.js +0 -29
- package/dist/chunk-V5TSWS7P.js +0 -62
- package/dist/types-BNNtOXu3.d.cts +0 -446
- package/dist/types-DFUtpxah.d.ts +0 -446
package/dist/runtime.d.cts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { c as ContactEventConfig, g as MessageEvent, C as ContactEvent, f as PlatformEvent, P as PlatformMessage } from './types-
|
|
2
|
-
export { A as AgentConfig, b as ContactEventCallback, d as ContactEventStrategy, e as ConversationContext, H as HistoryProvider, M as MessageHandler,
|
|
1
|
+
import { c as ContactEventConfig, g as MessageEvent, C as ContactEvent, f as PlatformEvent, P as PlatformMessage } from './types-DtcOLALn.cjs';
|
|
2
|
+
export { A as AgentConfig, b as ContactEventCallback, d as ContactEventStrategy, e as ConversationContext, H as HistoryProvider, M as MessageHandler, h as SYNTHETIC_CONTACT_EVENTS_SENDER_ID, i as SYNTHETIC_CONTACT_EVENTS_SENDER_NAME, j as SYNTHETIC_SENDER_TYPE, S as SessionConfig, k as ensureHandlePrefix } from './types-DtcOLALn.cjs';
|
|
3
3
|
import { L as Logger } from './logger-CABQOnlR.cjs';
|
|
4
|
-
import { A as AdapterToolsProtocol,
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
import { A as AdapterToolsProtocol, b as AgentToolsProtocol, j as AgentToolsCapabilities, C as ContactTools } from './protocols-CabgO52c.cjs';
|
|
5
|
+
export { k as CHAT_EVENT_TYPES, l as CHAT_MESSAGE_TYPES, m as ChatEventType, n as ChatMessageType, o as assertChatEventType, p as isChatEventType } from './protocols-CabgO52c.cjs';
|
|
6
|
+
import { e as AgentToolsRestApi, f as ChatMessagingRestApi, g as ChatRoomRestApi, h as ContactRestApi } from './types-42-HWeX8.cjs';
|
|
7
|
+
import { B as BandLink, e as ExecutionContext, b as ExecutionLifecycleState } from './schemas-BKnh4fKR.cjs';
|
|
8
|
+
export { f as ALL_TOOL_NAMES, A as AgentRuntime, g as BASE_TOOL_NAMES, C as CHAT_TOOL_NAMES, h as CONTACT_TOOL_NAMES, D as DefaultPreprocessor, E as ExecutionContextOptions, i as ExecutionState, M as MCP_SERVER_NAME, c as MCP_TOOL_PREFIX, j as MEMORY_TOOL_NAMES, P as PlatformRuntime, k as RoomPresence, R as RuntimeLifecycleState, T as TOOL_MODELS, l as getToolDescription, m as mcpToolNames } from './schemas-BKnh4fKR.cjs';
|
|
9
|
+
import { ParticipantRoster, AgentFailure } from '@band-ai/band-sdk-core';
|
|
9
10
|
export { ParticipantRoster, RetryTracker, RoomMembership, RoomRoster } from '@band-ai/band-sdk-core';
|
|
10
|
-
import {
|
|
11
|
-
import '
|
|
12
|
-
import './
|
|
13
|
-
import './disconnectReason-IuADl6TH.cjs';
|
|
11
|
+
import { h as MentionInput, T as ToolOperationResult, M as MetadataMap, i as PaginatedList, P as PeerRecord, g as ParticipantRecord, j as ToolSchemaRecord, L as ListContactsArgs, C as ContactRecord, A as AddContactArgs, R as RemoveContactArgs, b as ListContactRequestsArgs, c as ContactRequestsResult, d as RespondContactRequestArgs, e as ListMemoriesArgs, f as MemoryRecord, S as StoreMemoryArgs, m as ToolModelMessage } from './dtos-CjQsN1_h.cjs';
|
|
12
|
+
import './pagination-BZDhB_nO.cjs';
|
|
13
|
+
import './disconnectReason-Cctmg1SN.cjs';
|
|
14
14
|
|
|
15
15
|
declare const HUB_ROOM_SYSTEM_PROMPT = "## OVERRIDE: Contact Management Mode\n\nThis is your CONTACTS HUB - a dedicated room for managing contact requests.\n\n**IMPORTANT: Do NOT delegate or add participants here.** You handle contact events DIRECTLY using the contact tools below. Do NOT call band_lookup_peers() or band_add_participant() in this room.\n\n## Your Role\n\n1. **Review incoming contact requests** - When you see a [Contact Request] message, evaluate it\n2. **Take action** - Use the contact tools to respond:\n - `band_respond_contact_request(action=\"approve\", request_id=\"...\")` to accept\n - `band_respond_contact_request(action=\"reject\", request_id=\"...\")` to decline\n3. **Report your decision** - Send a thought event explaining what you did\n\n## Example\n\n[Contact Events]: [Contact Request] Alice (@alice) wants to connect.\nRequest ID: abc-123\n\nYour response:\n1. band_send_event(\"Received contact request from Alice. Approving.\", message_type=\"thought\")\n2. band_respond_contact_request(action=\"approve\", request_id=\"abc-123\")\n3. band_send_event(\"Approved contact request from Alice (@alice)\", message_type=\"thought\")\n\n## Contact Tools (use these, NOT participant tools)\n- `band_respond_contact_request(action, request_id)` - Approve/reject requests\n- `band_list_contact_requests()` - List pending requests\n- `band_list_contacts()` - List current contacts";
|
|
16
16
|
type ContactHandlerRestApi = Partial<AgentToolsRestApi> & Pick<ChatMessagingRestApi, "createChatEvent"> & Pick<ChatRoomRestApi, "createChat"> & Partial<Pick<ContactRestApi, "listContactRequests">>;
|
|
@@ -74,26 +74,51 @@ declare class Execution {
|
|
|
74
74
|
private readonly eventQueue;
|
|
75
75
|
private readonly waiters;
|
|
76
76
|
private readonly idleWaiters;
|
|
77
|
-
private readonly
|
|
78
|
-
private readonly
|
|
79
|
-
private processTask;
|
|
80
|
-
private
|
|
81
|
-
private
|
|
82
|
-
private running;
|
|
77
|
+
private readonly stoppedSignal;
|
|
78
|
+
private readonly lifecycle;
|
|
79
|
+
private readonly processTask;
|
|
80
|
+
private readonly stopGate;
|
|
81
|
+
private readonly syncBoundaries;
|
|
83
82
|
private inFlight;
|
|
83
|
+
/**
|
|
84
|
+
* Set once the queue stops accepting new events, ahead of the lifecycle
|
|
85
|
+
* itself reporting `"stopped"` (see {@link runStop}) — closing the queue
|
|
86
|
+
* cannot wait on the drain it is closing for.
|
|
87
|
+
*/
|
|
88
|
+
private closed;
|
|
84
89
|
constructor(options: ExecutionOptions);
|
|
90
|
+
/**
|
|
91
|
+
* Whether this `Execution` is still alive, and if not, why it ended.
|
|
92
|
+
*
|
|
93
|
+
* This is the *lifecycle* axis. For "is this turn's handler currently
|
|
94
|
+
* executing" read `ExecutionContext.state` instead, which reports
|
|
95
|
+
* `"starting" | "idle" | "processing"` for the room's context.
|
|
96
|
+
*
|
|
97
|
+
* @see ExecutionContext.state
|
|
98
|
+
*/
|
|
99
|
+
get state(): ExecutionLifecycleState;
|
|
85
100
|
enqueue(event: PlatformEvent): Promise<void>;
|
|
86
101
|
bootstrapMessage(message: PlatformMessage): Promise<void>;
|
|
87
102
|
isIdle(): boolean;
|
|
88
103
|
waitForIdle(timeoutMs?: number): Promise<boolean>;
|
|
89
104
|
stop(timeoutMs?: number): Promise<boolean>;
|
|
105
|
+
private runStop;
|
|
106
|
+
/**
|
|
107
|
+
* Resolve once this `Execution` has reached a terminal state — including a
|
|
108
|
+
* forced, non-graceful stop that detached the process loop — or reject with
|
|
109
|
+
* the error that ended it.
|
|
110
|
+
*/
|
|
90
111
|
waitUntilStopped(): Promise<void>;
|
|
112
|
+
private runProcessLoop;
|
|
91
113
|
private processLoop;
|
|
92
114
|
private recoverStaleProcessingMessages;
|
|
93
115
|
private synchronizeWithNext;
|
|
94
116
|
private executeSyncMessage;
|
|
95
117
|
private executeEvent;
|
|
96
118
|
private nextQueuedEvent;
|
|
119
|
+
/** True while the process loop should keep draining (`running` or mid-`stop()`). */
|
|
120
|
+
private isActive;
|
|
121
|
+
private markFailed;
|
|
97
122
|
private notifyIfIdle;
|
|
98
123
|
private resolveEventWaiters;
|
|
99
124
|
private markMessageFailed;
|
|
@@ -118,6 +143,7 @@ declare class AgentTools implements AgentToolsProtocol {
|
|
|
118
143
|
getAdapterTools(): AdapterToolsProtocol;
|
|
119
144
|
sendMessage(content: string, mentions?: MentionInput): Promise<ToolOperationResult>;
|
|
120
145
|
sendEvent(content: string, messageType: string, metadata?: MetadataMap): Promise<ToolOperationResult>;
|
|
146
|
+
sendFailure(failure: AgentFailure): Promise<ToolOperationResult>;
|
|
121
147
|
createChatroom(taskId?: string): Promise<string>;
|
|
122
148
|
addParticipant(name: string, role?: string): Promise<ToolOperationResult>;
|
|
123
149
|
removeParticipant(name: string): Promise<ToolOperationResult>;
|
|
@@ -181,13 +207,6 @@ declare class ContactToolsImpl implements ContactTools {
|
|
|
181
207
|
respondContactRequest(request: RespondContactRequestArgs): Promise<ToolOperationResult>;
|
|
182
208
|
}
|
|
183
209
|
|
|
184
|
-
declare const CHAT_EVENT_TYPES: readonly ["tool_call", "tool_result", "thought", "error", "task"];
|
|
185
|
-
type ChatEventType = (typeof CHAT_EVENT_TYPES)[number];
|
|
186
|
-
declare const CHAT_MESSAGE_TYPES: readonly ["text", "tool_call", "tool_result", "thought", "error", "task"];
|
|
187
|
-
type ChatMessageType = (typeof CHAT_MESSAGE_TYPES)[number];
|
|
188
|
-
declare function isChatEventType(value: string): value is ChatEventType;
|
|
189
|
-
declare function assertChatEventType(value: string): asserts value is ChatEventType;
|
|
190
|
-
|
|
191
210
|
declare function mentionSubjectsFromMetadata(metadata: MetadataMap | undefined): Array<Record<string, unknown>>;
|
|
192
211
|
declare function replaceUuidMentions(content: string, participants: Array<Record<string, unknown>>): string;
|
|
193
212
|
declare function formatMessageForLlm(message: Record<string, unknown>, participants?: Array<Record<string, unknown>>): ToolModelMessage;
|
|
@@ -237,4 +256,4 @@ declare class GracefulShutdown {
|
|
|
237
256
|
}
|
|
238
257
|
declare function runWithGracefulShutdown(agent: StoppableAgent, options?: GracefulShutdownOptions): Promise<void>;
|
|
239
258
|
|
|
240
|
-
export { AgentTools, BASE_INSTRUCTIONS,
|
|
259
|
+
export { AgentTools, BASE_INSTRUCTIONS, ContactEventConfig, ContactEventHandler, ContactToolsImpl, Execution, ExecutionContext, type ExecutionHandler, ExecutionLifecycleState, GracefulShutdown, HUB_ROOM_SYSTEM_PROMPT, MEMORY_SECTION, PlatformMessage, type RenderSystemPromptOptions, TEMPLATES, buildParticipantsMessage, formatHistoryForLlm, formatMessageForLlm, mentionSubjectsFromMetadata, renderSystemPrompt, replaceUuidMentions, runWithGracefulShutdown };
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { c as ContactEventConfig, g as MessageEvent, C as ContactEvent, f as PlatformEvent, P as PlatformMessage } from './types-
|
|
2
|
-
export { A as AgentConfig, b as ContactEventCallback, d as ContactEventStrategy, e as ConversationContext, H as HistoryProvider, M as MessageHandler,
|
|
1
|
+
import { c as ContactEventConfig, g as MessageEvent, C as ContactEvent, f as PlatformEvent, P as PlatformMessage } from './types-CKU1N0SK.js';
|
|
2
|
+
export { A as AgentConfig, b as ContactEventCallback, d as ContactEventStrategy, e as ConversationContext, H as HistoryProvider, M as MessageHandler, h as SYNTHETIC_CONTACT_EVENTS_SENDER_ID, i as SYNTHETIC_CONTACT_EVENTS_SENDER_NAME, j as SYNTHETIC_SENDER_TYPE, S as SessionConfig, k as ensureHandlePrefix } from './types-CKU1N0SK.js';
|
|
3
3
|
import { L as Logger } from './logger-CABQOnlR.js';
|
|
4
|
-
import { A as AdapterToolsProtocol,
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
import { A as AdapterToolsProtocol, b as AgentToolsProtocol, j as AgentToolsCapabilities, C as ContactTools } from './protocols-Dpci6uae.js';
|
|
5
|
+
export { k as CHAT_EVENT_TYPES, l as CHAT_MESSAGE_TYPES, m as ChatEventType, n as ChatMessageType, o as assertChatEventType, p as isChatEventType } from './protocols-Dpci6uae.js';
|
|
6
|
+
import { e as AgentToolsRestApi, f as ChatMessagingRestApi, g as ChatRoomRestApi, h as ContactRestApi } from './types-CjxZekMH.js';
|
|
7
|
+
import { B as BandLink, e as ExecutionContext, b as ExecutionLifecycleState } from './schemas-CDa3V_I5.js';
|
|
8
|
+
export { f as ALL_TOOL_NAMES, A as AgentRuntime, g as BASE_TOOL_NAMES, C as CHAT_TOOL_NAMES, h as CONTACT_TOOL_NAMES, D as DefaultPreprocessor, E as ExecutionContextOptions, i as ExecutionState, M as MCP_SERVER_NAME, c as MCP_TOOL_PREFIX, j as MEMORY_TOOL_NAMES, P as PlatformRuntime, k as RoomPresence, R as RuntimeLifecycleState, T as TOOL_MODELS, l as getToolDescription, m as mcpToolNames } from './schemas-CDa3V_I5.js';
|
|
9
|
+
import { ParticipantRoster, AgentFailure } from '@band-ai/band-sdk-core';
|
|
9
10
|
export { ParticipantRoster, RetryTracker, RoomMembership, RoomRoster } from '@band-ai/band-sdk-core';
|
|
10
|
-
import {
|
|
11
|
-
import '
|
|
12
|
-
import './
|
|
13
|
-
import './disconnectReason-IuADl6TH.js';
|
|
11
|
+
import { h as MentionInput, T as ToolOperationResult, M as MetadataMap, i as PaginatedList, P as PeerRecord, g as ParticipantRecord, j as ToolSchemaRecord, L as ListContactsArgs, C as ContactRecord, A as AddContactArgs, R as RemoveContactArgs, b as ListContactRequestsArgs, c as ContactRequestsResult, d as RespondContactRequestArgs, e as ListMemoriesArgs, f as MemoryRecord, S as StoreMemoryArgs, m as ToolModelMessage } from './dtos-CjQsN1_h.js';
|
|
12
|
+
import './pagination-CPz0J_vQ.js';
|
|
13
|
+
import './disconnectReason-Cctmg1SN.js';
|
|
14
14
|
|
|
15
15
|
declare const HUB_ROOM_SYSTEM_PROMPT = "## OVERRIDE: Contact Management Mode\n\nThis is your CONTACTS HUB - a dedicated room for managing contact requests.\n\n**IMPORTANT: Do NOT delegate or add participants here.** You handle contact events DIRECTLY using the contact tools below. Do NOT call band_lookup_peers() or band_add_participant() in this room.\n\n## Your Role\n\n1. **Review incoming contact requests** - When you see a [Contact Request] message, evaluate it\n2. **Take action** - Use the contact tools to respond:\n - `band_respond_contact_request(action=\"approve\", request_id=\"...\")` to accept\n - `band_respond_contact_request(action=\"reject\", request_id=\"...\")` to decline\n3. **Report your decision** - Send a thought event explaining what you did\n\n## Example\n\n[Contact Events]: [Contact Request] Alice (@alice) wants to connect.\nRequest ID: abc-123\n\nYour response:\n1. band_send_event(\"Received contact request from Alice. Approving.\", message_type=\"thought\")\n2. band_respond_contact_request(action=\"approve\", request_id=\"abc-123\")\n3. band_send_event(\"Approved contact request from Alice (@alice)\", message_type=\"thought\")\n\n## Contact Tools (use these, NOT participant tools)\n- `band_respond_contact_request(action, request_id)` - Approve/reject requests\n- `band_list_contact_requests()` - List pending requests\n- `band_list_contacts()` - List current contacts";
|
|
16
16
|
type ContactHandlerRestApi = Partial<AgentToolsRestApi> & Pick<ChatMessagingRestApi, "createChatEvent"> & Pick<ChatRoomRestApi, "createChat"> & Partial<Pick<ContactRestApi, "listContactRequests">>;
|
|
@@ -74,26 +74,51 @@ declare class Execution {
|
|
|
74
74
|
private readonly eventQueue;
|
|
75
75
|
private readonly waiters;
|
|
76
76
|
private readonly idleWaiters;
|
|
77
|
-
private readonly
|
|
78
|
-
private readonly
|
|
79
|
-
private processTask;
|
|
80
|
-
private
|
|
81
|
-
private
|
|
82
|
-
private running;
|
|
77
|
+
private readonly stoppedSignal;
|
|
78
|
+
private readonly lifecycle;
|
|
79
|
+
private readonly processTask;
|
|
80
|
+
private readonly stopGate;
|
|
81
|
+
private readonly syncBoundaries;
|
|
83
82
|
private inFlight;
|
|
83
|
+
/**
|
|
84
|
+
* Set once the queue stops accepting new events, ahead of the lifecycle
|
|
85
|
+
* itself reporting `"stopped"` (see {@link runStop}) — closing the queue
|
|
86
|
+
* cannot wait on the drain it is closing for.
|
|
87
|
+
*/
|
|
88
|
+
private closed;
|
|
84
89
|
constructor(options: ExecutionOptions);
|
|
90
|
+
/**
|
|
91
|
+
* Whether this `Execution` is still alive, and if not, why it ended.
|
|
92
|
+
*
|
|
93
|
+
* This is the *lifecycle* axis. For "is this turn's handler currently
|
|
94
|
+
* executing" read `ExecutionContext.state` instead, which reports
|
|
95
|
+
* `"starting" | "idle" | "processing"` for the room's context.
|
|
96
|
+
*
|
|
97
|
+
* @see ExecutionContext.state
|
|
98
|
+
*/
|
|
99
|
+
get state(): ExecutionLifecycleState;
|
|
85
100
|
enqueue(event: PlatformEvent): Promise<void>;
|
|
86
101
|
bootstrapMessage(message: PlatformMessage): Promise<void>;
|
|
87
102
|
isIdle(): boolean;
|
|
88
103
|
waitForIdle(timeoutMs?: number): Promise<boolean>;
|
|
89
104
|
stop(timeoutMs?: number): Promise<boolean>;
|
|
105
|
+
private runStop;
|
|
106
|
+
/**
|
|
107
|
+
* Resolve once this `Execution` has reached a terminal state — including a
|
|
108
|
+
* forced, non-graceful stop that detached the process loop — or reject with
|
|
109
|
+
* the error that ended it.
|
|
110
|
+
*/
|
|
90
111
|
waitUntilStopped(): Promise<void>;
|
|
112
|
+
private runProcessLoop;
|
|
91
113
|
private processLoop;
|
|
92
114
|
private recoverStaleProcessingMessages;
|
|
93
115
|
private synchronizeWithNext;
|
|
94
116
|
private executeSyncMessage;
|
|
95
117
|
private executeEvent;
|
|
96
118
|
private nextQueuedEvent;
|
|
119
|
+
/** True while the process loop should keep draining (`running` or mid-`stop()`). */
|
|
120
|
+
private isActive;
|
|
121
|
+
private markFailed;
|
|
97
122
|
private notifyIfIdle;
|
|
98
123
|
private resolveEventWaiters;
|
|
99
124
|
private markMessageFailed;
|
|
@@ -118,6 +143,7 @@ declare class AgentTools implements AgentToolsProtocol {
|
|
|
118
143
|
getAdapterTools(): AdapterToolsProtocol;
|
|
119
144
|
sendMessage(content: string, mentions?: MentionInput): Promise<ToolOperationResult>;
|
|
120
145
|
sendEvent(content: string, messageType: string, metadata?: MetadataMap): Promise<ToolOperationResult>;
|
|
146
|
+
sendFailure(failure: AgentFailure): Promise<ToolOperationResult>;
|
|
121
147
|
createChatroom(taskId?: string): Promise<string>;
|
|
122
148
|
addParticipant(name: string, role?: string): Promise<ToolOperationResult>;
|
|
123
149
|
removeParticipant(name: string): Promise<ToolOperationResult>;
|
|
@@ -181,13 +207,6 @@ declare class ContactToolsImpl implements ContactTools {
|
|
|
181
207
|
respondContactRequest(request: RespondContactRequestArgs): Promise<ToolOperationResult>;
|
|
182
208
|
}
|
|
183
209
|
|
|
184
|
-
declare const CHAT_EVENT_TYPES: readonly ["tool_call", "tool_result", "thought", "error", "task"];
|
|
185
|
-
type ChatEventType = (typeof CHAT_EVENT_TYPES)[number];
|
|
186
|
-
declare const CHAT_MESSAGE_TYPES: readonly ["text", "tool_call", "tool_result", "thought", "error", "task"];
|
|
187
|
-
type ChatMessageType = (typeof CHAT_MESSAGE_TYPES)[number];
|
|
188
|
-
declare function isChatEventType(value: string): value is ChatEventType;
|
|
189
|
-
declare function assertChatEventType(value: string): asserts value is ChatEventType;
|
|
190
|
-
|
|
191
210
|
declare function mentionSubjectsFromMetadata(metadata: MetadataMap | undefined): Array<Record<string, unknown>>;
|
|
192
211
|
declare function replaceUuidMentions(content: string, participants: Array<Record<string, unknown>>): string;
|
|
193
212
|
declare function formatMessageForLlm(message: Record<string, unknown>, participants?: Array<Record<string, unknown>>): ToolModelMessage;
|
|
@@ -237,4 +256,4 @@ declare class GracefulShutdown {
|
|
|
237
256
|
}
|
|
238
257
|
declare function runWithGracefulShutdown(agent: StoppableAgent, options?: GracefulShutdownOptions): Promise<void>;
|
|
239
258
|
|
|
240
|
-
export { AgentTools, BASE_INSTRUCTIONS,
|
|
259
|
+
export { AgentTools, BASE_INSTRUCTIONS, ContactEventConfig, ContactEventHandler, ContactToolsImpl, Execution, ExecutionContext, type ExecutionHandler, ExecutionLifecycleState, GracefulShutdown, HUB_ROOM_SYSTEM_PROMPT, MEMORY_SECTION, PlatformMessage, type RenderSystemPromptOptions, TEMPLATES, buildParticipantsMessage, formatHistoryForLlm, formatMessageForLlm, mentionSubjectsFromMetadata, renderSystemPrompt, replaceUuidMentions, runWithGracefulShutdown };
|
package/dist/runtime.js
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
PlatformRuntime,
|
|
12
12
|
RoomPresence,
|
|
13
13
|
runWithGracefulShutdown
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-6TGXV5TE.js";
|
|
15
15
|
import {
|
|
16
16
|
HistoryProvider,
|
|
17
17
|
SYNTHETIC_CONTACT_EVENTS_SENDER_ID,
|
|
@@ -23,13 +23,13 @@ import {
|
|
|
23
23
|
formatMessageForLlm,
|
|
24
24
|
mentionSubjectsFromMetadata,
|
|
25
25
|
replaceUuidMentions
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-CBCHTTUY.js";
|
|
27
27
|
import {
|
|
28
28
|
BASE_INSTRUCTIONS,
|
|
29
29
|
MEMORY_SECTION,
|
|
30
30
|
TEMPLATES,
|
|
31
31
|
renderSystemPrompt
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-RJNJUISR.js";
|
|
33
33
|
import {
|
|
34
34
|
ALL_TOOL_NAMES,
|
|
35
35
|
BASE_TOOL_NAMES,
|
|
@@ -41,19 +41,19 @@ import {
|
|
|
41
41
|
TOOL_MODELS,
|
|
42
42
|
getToolDescription,
|
|
43
43
|
mcpToolNames
|
|
44
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-SHZBLLDQ.js";
|
|
45
|
+
import "./chunk-UENIC5FJ.js";
|
|
46
|
+
import "./chunk-OVXVZUPO.js";
|
|
47
|
+
import "./chunk-JIZE4EC6.js";
|
|
48
|
+
import "./chunk-6BE2EG5P.js";
|
|
45
49
|
import {
|
|
46
50
|
CHAT_EVENT_TYPES,
|
|
47
51
|
CHAT_MESSAGE_TYPES,
|
|
48
52
|
assertChatEventType,
|
|
49
53
|
isChatEventType
|
|
50
|
-
} from "./chunk-
|
|
51
|
-
import "./chunk-
|
|
52
|
-
import "./chunk-
|
|
53
|
-
import "./chunk-KXJ74J73.js";
|
|
54
|
-
import "./chunk-JADCAMZY.js";
|
|
55
|
-
import "./chunk-OD2G5LFQ.js";
|
|
56
|
-
import "./chunk-JY75VSQK.js";
|
|
54
|
+
} from "./chunk-TGDDFBYS.js";
|
|
55
|
+
import "./chunk-ZYOXI4JL.js";
|
|
56
|
+
import "./chunk-4OVNFDD7.js";
|
|
57
57
|
|
|
58
58
|
// src/runtime/index.ts
|
|
59
59
|
import { ParticipantRoster, RetryTracker, RoomRoster } from "@band-ai/band-sdk-core";
|