@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.
Files changed (97) hide show
  1. package/README.md +54 -1
  2. package/dist/{ClaudeSDKAdapter-CXud2DBE.d.ts → CopilotACPAdapter-BCpbHFB0.d.ts} +240 -19
  3. package/dist/{ClaudeSDKAdapter-Cx6zhSaG.d.cts → CopilotACPAdapter-D4VWg8lJ.d.cts} +240 -19
  4. package/dist/{opencode-2YdscIc1.d.cts → acp-client-D-I_5lK-.d.cts} +23 -4
  5. package/dist/{opencode-Bld62x5t.d.ts → acp-client-DUXyczlF.d.ts} +23 -4
  6. package/dist/acp-server-BlcYMxKt.d.ts +17 -0
  7. package/dist/acp-server-CJhclo6P.d.cts +17 -0
  8. package/dist/adapters.cjs +2217 -973
  9. package/dist/adapters.d.cts +21 -132
  10. package/dist/adapters.d.ts +21 -132
  11. package/dist/adapters.js +26 -1914
  12. package/dist/{backends-D-dBdDm-.d.ts → backends-CgsPQa9B.d.ts} +2 -2
  13. package/dist/{backends-ZLxmQrTZ.d.cts → backends-Dh2WXcHQ.d.cts} +2 -2
  14. package/dist/{chunk-JY75VSQK.js → chunk-4OVNFDD7.js} +14 -1
  15. package/dist/chunk-6BE2EG5P.js +128 -0
  16. package/dist/{chunk-U6AFCLYZ.js → chunk-6TGXV5TE.js} +1824 -514
  17. package/dist/{chunk-OH6VVVKT.js → chunk-CBCHTTUY.js} +10 -0
  18. package/dist/{chunk-K5KAEYPF.js → chunk-HNWZZXAE.js} +288 -120
  19. package/dist/chunk-I34SXMTJ.js +6 -0
  20. package/dist/{chunk-XWHWJP4I.js → chunk-JDW5WSGF.js} +2 -2
  21. package/dist/{chunk-KXJ74J73.js → chunk-JIZE4EC6.js} +4 -10
  22. package/dist/chunk-OGOXY43L.js +119 -0
  23. package/dist/{chunk-W5IAI6Z4.js → chunk-OVXVZUPO.js} +5 -5
  24. package/dist/{chunk-YJ42AZO4.js → chunk-RJNJUISR.js} +5 -2
  25. package/dist/{chunk-MQY74R7D.js → chunk-SHZBLLDQ.js} +21 -9
  26. package/dist/{chunk-JADCAMZY.js → chunk-TGDDFBYS.js} +45 -0
  27. package/dist/{chunk-US226AS4.js → chunk-UENIC5FJ.js} +14 -11
  28. package/dist/{chunk-WA7CHXUS.js → chunk-UL3Y5C4J.js} +2 -2
  29. package/dist/{chunk-WL2HNJZ6.js → chunk-VOMJRQOM.js} +3 -3
  30. package/dist/{chunk-MQBBWYRP.js → chunk-YF7K4UB3.js} +3352 -572
  31. package/dist/{chunk-OD2G5LFQ.js → chunk-ZYOXI4JL.js} +41 -2
  32. package/dist/config.cjs +2 -12
  33. package/dist/config.js +2 -2
  34. package/dist/converters.cjs +36 -11
  35. package/dist/converters.d.cts +7 -5
  36. package/dist/converters.d.ts +7 -5
  37. package/dist/converters.js +11 -13
  38. package/dist/core.cjs +239 -5
  39. package/dist/core.d.cts +71 -6
  40. package/dist/core.d.ts +71 -6
  41. package/dist/core.js +31 -6
  42. package/dist/{customTools-BzF0IISO.d.cts → customTools-Bfecd0mJ.d.cts} +1 -1
  43. package/dist/{customTools-BzF0IISO.d.ts → customTools-Bfecd0mJ.d.ts} +1 -1
  44. package/dist/{disconnectReason-IuADl6TH.d.ts → disconnectReason-Cctmg1SN.d.cts} +1 -1
  45. package/dist/{disconnectReason-IuADl6TH.d.cts → disconnectReason-Cctmg1SN.d.ts} +1 -1
  46. package/dist/{dtos-B8KU_q4d.d.ts → dtos-CjQsN1_h.d.cts} +5 -12
  47. package/dist/{dtos-B8KU_q4d.d.cts → dtos-CjQsN1_h.d.ts} +5 -12
  48. package/dist/index.cjs +5237 -1474
  49. package/dist/index.d.cts +61 -22
  50. package/dist/index.d.ts +61 -22
  51. package/dist/index.js +151 -43
  52. package/dist/linear.cjs +45 -7
  53. package/dist/linear.d.cts +4 -3
  54. package/dist/linear.d.ts +4 -3
  55. package/dist/linear.js +10 -10
  56. package/dist/mcp-claude.cjs +11 -6
  57. package/dist/mcp-claude.d.cts +4 -3
  58. package/dist/mcp-claude.d.ts +4 -3
  59. package/dist/mcp-claude.js +4 -5
  60. package/dist/mcp.cjs +13 -7
  61. package/dist/mcp.d.cts +6 -5
  62. package/dist/mcp.d.ts +6 -5
  63. package/dist/mcp.js +5 -6
  64. package/dist/{pagination-DqdkQArT.d.cts → pagination-BZDhB_nO.d.cts} +2 -2
  65. package/dist/{pagination-BgEx-HeL.d.ts → pagination-CPz0J_vQ.d.ts} +2 -2
  66. package/dist/{protocols-Bz1rxcUg.d.cts → protocols-CabgO52c.d.cts} +38 -3
  67. package/dist/{protocols-Bwwcql0h.d.ts → protocols-Dpci6uae.d.ts} +38 -3
  68. package/dist/rest.cjs +43 -1
  69. package/dist/rest.d.cts +6 -5
  70. package/dist/rest.d.ts +6 -5
  71. package/dist/rest.js +6 -5
  72. package/dist/runtime.cjs +2113 -597
  73. package/dist/runtime.d.cts +44 -25
  74. package/dist/runtime.d.ts +44 -25
  75. package/dist/runtime.js +11 -11
  76. package/dist/{schemas-BgJhlqqO.d.cts → schemas-BKnh4fKR.d.cts} +209 -24
  77. package/dist/{schemas-C4mK1WSs.d.ts → schemas-CDa3V_I5.d.ts} +209 -24
  78. package/dist/{sdk-BTciSLRQ.d.cts → sdk-CXNqzoY1.d.cts} +1 -1
  79. package/dist/{sdk-qKJtMma_.d.ts → sdk-Cin80BTC.d.ts} +1 -1
  80. package/dist/{simpleAdapter-BpT4XbZC.d.cts → simpleAdapter-D75rcz9n.d.cts} +3 -1
  81. package/dist/{simpleAdapter--wznuoOw.d.ts → simpleAdapter-eLvsAQNo.d.ts} +3 -1
  82. package/dist/testing.cjs +25 -7
  83. package/dist/testing.d.cts +5 -3
  84. package/dist/testing.d.ts +5 -3
  85. package/dist/testing.js +9 -6
  86. package/dist/{types-BivGO7I9.d.ts → types-42-HWeX8.d.cts} +10 -4
  87. package/dist/types-CKU1N0SK.d.ts +137 -0
  88. package/dist/{types-BgYFd_Yw.d.cts → types-CjxZekMH.d.ts} +10 -4
  89. package/dist/types-DtcOLALn.d.cts +137 -0
  90. package/package.json +25 -26
  91. package/dist/acp-server-CiUqN3G3.d.ts +0 -24
  92. package/dist/acp-server-Dlj7D563.d.cts +0 -24
  93. package/dist/chunk-AVVDPXP4.js +0 -39
  94. package/dist/chunk-F63TPOI3.js +0 -29
  95. package/dist/chunk-V5TSWS7P.js +0 -62
  96. package/dist/types-BNNtOXu3.d.cts +0 -446
  97. package/dist/types-DFUtpxah.d.ts +0 -446
@@ -1,16 +1,16 @@
1
- import { c as ContactEventConfig, g as MessageEvent, C as ContactEvent, f as PlatformEvent, P as PlatformMessage } from './types-BNNtOXu3.cjs';
2
- export { A as AgentConfig, b as ContactEventCallback, d as ContactEventStrategy, e as ConversationContext, H as HistoryProvider, M as MessageHandler, j as SYNTHETIC_CONTACT_EVENTS_SENDER_ID, k as SYNTHETIC_CONTACT_EVENTS_SENDER_NAME, l as SYNTHETIC_SENDER_TYPE, S as SessionConfig, m as ensureHandlePrefix } from './types-BNNtOXu3.cjs';
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, a as AgentToolsProtocol, h as AgentToolsCapabilities, C as ContactTools } from './protocols-Bz1rxcUg.cjs';
5
- import { e as AgentToolsRestApi, f as ChatMessagingRestApi, g as ChatRoomRestApi, h as ContactRestApi } from './types-BgYFd_Yw.cjs';
6
- import { B as BandLink, c as ExecutionContext } from './schemas-BgJhlqqO.cjs';
7
- export { e as ALL_TOOL_NAMES, A as AgentRuntime, f as BASE_TOOL_NAMES, C as CHAT_TOOL_NAMES, g as CONTACT_TOOL_NAMES, D as DefaultPreprocessor, E as ExecutionContextOptions, h as ExecutionState, M as MCP_SERVER_NAME, b as MCP_TOOL_PREFIX, i as MEMORY_TOOL_NAMES, P as PlatformRuntime, R as RoomPresence, T as TOOL_MODELS, j as getToolDescription, m as mcpToolNames } from './schemas-BgJhlqqO.cjs';
8
- import { ParticipantRoster } from '@band-ai/band-sdk-core';
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 { a as MentionInput, T as ToolOperationResult, M as MetadataMap, c as PaginatedList, d as PeerRecord, P as ParticipantRecord, b as ToolSchemaRecord, L as ListContactsArgs, C as ContactRecord, A as AddContactArgs, R as RemoveContactArgs, e as ListContactRequestsArgs, f as ContactRequestsResult, g as RespondContactRequestArgs, h as ListMemoriesArgs, i as MemoryRecord, S as StoreMemoryArgs, m as ToolModelMessage } from './dtos-B8KU_q4d.cjs';
11
- import 'zod';
12
- import './pagination-DqdkQArT.cjs';
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 drainedWsMessageIds;
78
- private readonly syncProcessedIds;
79
- private processTask;
80
- private firstWsMessageId;
81
- private syncComplete;
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, CHAT_EVENT_TYPES, CHAT_MESSAGE_TYPES, type ChatEventType, type ChatMessageType, ContactEventConfig, ContactEventHandler, ContactToolsImpl, Execution, ExecutionContext, type ExecutionHandler, GracefulShutdown, HUB_ROOM_SYSTEM_PROMPT, MEMORY_SECTION, PlatformMessage, type RenderSystemPromptOptions, TEMPLATES, assertChatEventType, buildParticipantsMessage, formatHistoryForLlm, formatMessageForLlm, isChatEventType, mentionSubjectsFromMetadata, renderSystemPrompt, replaceUuidMentions, runWithGracefulShutdown };
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-DFUtpxah.js';
2
- export { A as AgentConfig, b as ContactEventCallback, d as ContactEventStrategy, e as ConversationContext, H as HistoryProvider, M as MessageHandler, j as SYNTHETIC_CONTACT_EVENTS_SENDER_ID, k as SYNTHETIC_CONTACT_EVENTS_SENDER_NAME, l as SYNTHETIC_SENDER_TYPE, S as SessionConfig, m as ensureHandlePrefix } from './types-DFUtpxah.js';
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, a as AgentToolsProtocol, h as AgentToolsCapabilities, C as ContactTools } from './protocols-Bwwcql0h.js';
5
- import { e as AgentToolsRestApi, f as ChatMessagingRestApi, g as ChatRoomRestApi, h as ContactRestApi } from './types-BivGO7I9.js';
6
- import { B as BandLink, c as ExecutionContext } from './schemas-C4mK1WSs.js';
7
- export { e as ALL_TOOL_NAMES, A as AgentRuntime, f as BASE_TOOL_NAMES, C as CHAT_TOOL_NAMES, g as CONTACT_TOOL_NAMES, D as DefaultPreprocessor, E as ExecutionContextOptions, h as ExecutionState, M as MCP_SERVER_NAME, b as MCP_TOOL_PREFIX, i as MEMORY_TOOL_NAMES, P as PlatformRuntime, R as RoomPresence, T as TOOL_MODELS, j as getToolDescription, m as mcpToolNames } from './schemas-C4mK1WSs.js';
8
- import { ParticipantRoster } from '@band-ai/band-sdk-core';
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 { a as MentionInput, T as ToolOperationResult, M as MetadataMap, c as PaginatedList, d as PeerRecord, P as ParticipantRecord, b as ToolSchemaRecord, L as ListContactsArgs, C as ContactRecord, A as AddContactArgs, R as RemoveContactArgs, e as ListContactRequestsArgs, f as ContactRequestsResult, g as RespondContactRequestArgs, h as ListMemoriesArgs, i as MemoryRecord, S as StoreMemoryArgs, m as ToolModelMessage } from './dtos-B8KU_q4d.js';
11
- import 'zod';
12
- import './pagination-BgEx-HeL.js';
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 drainedWsMessageIds;
78
- private readonly syncProcessedIds;
79
- private processTask;
80
- private firstWsMessageId;
81
- private syncComplete;
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, CHAT_EVENT_TYPES, CHAT_MESSAGE_TYPES, type ChatEventType, type ChatMessageType, ContactEventConfig, ContactEventHandler, ContactToolsImpl, Execution, ExecutionContext, type ExecutionHandler, GracefulShutdown, HUB_ROOM_SYSTEM_PROMPT, MEMORY_SECTION, PlatformMessage, type RenderSystemPromptOptions, TEMPLATES, assertChatEventType, buildParticipantsMessage, formatHistoryForLlm, formatMessageForLlm, isChatEventType, mentionSubjectsFromMetadata, renderSystemPrompt, replaceUuidMentions, runWithGracefulShutdown };
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-U6AFCLYZ.js";
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-OH6VVVKT.js";
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-YJ42AZO4.js";
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-MQY74R7D.js";
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-F63TPOI3.js";
51
- import "./chunk-US226AS4.js";
52
- import "./chunk-W5IAI6Z4.js";
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";