@band-ai/sdk 0.1.6 → 0.2.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 (85) hide show
  1. package/README.md +372 -0
  2. package/dist/{ClaudeSDKAdapter-CRq4R-WB.d.cts → ClaudeSDKAdapter-BY4zEbCl.d.cts} +14 -10
  3. package/dist/{ClaudeSDKAdapter-BHOkjN3X.d.ts → ClaudeSDKAdapter-Cna5P1dR.d.ts} +14 -10
  4. package/dist/{acp-server-B1Da7L6u.d.ts → acp-server-CiUqN3G3.d.ts} +2 -2
  5. package/dist/{acp-server-BdRz9_UN.d.cts → acp-server-Dlj7D563.d.cts} +2 -2
  6. package/dist/adapters.cjs +734 -279
  7. package/dist/adapters.d.cts +21 -19
  8. package/dist/adapters.d.ts +21 -19
  9. package/dist/adapters.js +65 -44
  10. package/dist/backends-D-dBdDm-.d.ts +27 -0
  11. package/dist/backends-ZLxmQrTZ.d.cts +27 -0
  12. package/dist/{chunk-MSL6CWHY.js → chunk-4IAXZBXX.js} +77 -37
  13. package/dist/{chunk-SG4WLD2H.js → chunk-EAI2M3WM.js} +38 -94
  14. package/dist/{chunk-YR3BOQNW.js → chunk-JY75VSQK.js} +7 -7
  15. package/dist/{chunk-INA6YZTZ.js → chunk-LBWKISBS.js} +51 -31
  16. package/dist/{chunk-I5EZG52P.js → chunk-N2QTUMGO.js} +532 -327
  17. package/dist/{chunk-RHVH2GZR.js → chunk-NMZLX7TP.js} +110 -56
  18. package/dist/{chunk-EDPKUUJL.js → chunk-NT7TBFX2.js} +9 -1
  19. package/dist/{chunk-GVEQ3RAH.js → chunk-RV76SKFT.js} +169 -54
  20. package/dist/{chunk-W5NDZSYE.js → chunk-TLBCKDQO.js} +23 -23
  21. package/dist/chunk-US226AS4.js +130 -0
  22. package/dist/{chunk-IZPV6QS6.js → chunk-WL2HNJZ6.js} +38 -11
  23. package/dist/chunk-WLCM2OXG.js +181 -0
  24. package/dist/config.cjs +40 -13
  25. package/dist/config.d.cts +7 -1
  26. package/dist/config.d.ts +7 -1
  27. package/dist/config.js +2 -2
  28. package/dist/converters.cjs +491 -35
  29. package/dist/converters.d.cts +5 -5
  30. package/dist/converters.d.ts +5 -5
  31. package/dist/converters.js +4 -3
  32. package/dist/core.cjs +53 -10
  33. package/dist/core.d.cts +10 -9
  34. package/dist/core.d.ts +10 -9
  35. package/dist/core.js +8 -4
  36. package/dist/disconnectReason-IuADl6TH.d.cts +34 -0
  37. package/dist/disconnectReason-IuADl6TH.d.ts +34 -0
  38. package/dist/{dtos-DUpbIu8k.d.ts → dtos-B8KU_q4d.d.cts} +26 -6
  39. package/dist/{dtos-DUpbIu8k.d.cts → dtos-B8KU_q4d.d.ts} +26 -6
  40. package/dist/index.cjs +1510 -735
  41. package/dist/index.d.cts +18 -16
  42. package/dist/index.d.ts +18 -16
  43. package/dist/index.js +21 -13
  44. package/dist/linear.cjs +1044 -112
  45. package/dist/linear.d.cts +146 -16
  46. package/dist/linear.d.ts +146 -16
  47. package/dist/linear.js +1031 -110
  48. package/dist/mcp-claude.cjs +338 -66
  49. package/dist/mcp-claude.d.cts +3 -3
  50. package/dist/mcp-claude.d.ts +3 -3
  51. package/dist/mcp-claude.js +215 -16
  52. package/dist/mcp.cjs +414 -105
  53. package/dist/mcp.d.cts +29 -16
  54. package/dist/mcp.d.ts +29 -16
  55. package/dist/mcp.js +14 -14
  56. package/dist/{opencode-BBcDchcN.d.cts → opencode-2YdscIc1.d.cts} +5 -5
  57. package/dist/{opencode-DthQQUsZ.d.ts → opencode-Bld62x5t.d.ts} +5 -5
  58. package/dist/{pagination-CcDkVFxK.d.ts → pagination-BgEx-HeL.d.ts} +2 -2
  59. package/dist/{pagination-BPiys10t.d.cts → pagination-DqdkQArT.d.cts} +2 -2
  60. package/dist/{protocols-DrhzOH6K.d.ts → protocols-Bwwcql0h.d.ts} +1 -1
  61. package/dist/{protocols-CInhtFpA.d.cts → protocols-Bz1rxcUg.d.cts} +1 -1
  62. package/dist/rest.cjs +41 -97
  63. package/dist/rest.d.cts +7 -7
  64. package/dist/rest.d.ts +7 -7
  65. package/dist/rest.js +2 -2
  66. package/dist/runtime.cjs +998 -620
  67. package/dist/runtime.d.cts +22 -29
  68. package/dist/runtime.d.ts +22 -29
  69. package/dist/runtime.js +19 -67
  70. package/dist/{schemas-BpEBkq5V.d.cts → schemas-BotL3ZLH.d.cts} +51 -56
  71. package/dist/{schemas-vos1AaBc.d.ts → schemas-DBsC4J1g.d.ts} +51 -56
  72. package/dist/{sdk-CwTAxhwI.d.cts → sdk-BTciSLRQ.d.cts} +35 -5
  73. package/dist/{sdk-CcnQ5OUC.d.ts → sdk-qKJtMma_.d.ts} +35 -5
  74. package/dist/{simpleAdapter-9OE_p6QW.d.ts → simpleAdapter--wznuoOw.d.ts} +1 -1
  75. package/dist/{simpleAdapter-DqhvjsGr.d.cts → simpleAdapter-BpT4XbZC.d.cts} +1 -1
  76. package/dist/testing.d.cts +3 -3
  77. package/dist/testing.d.ts +3 -3
  78. package/dist/{types-7jVzOeOP.d.ts → types-BTN_ZETM.d.ts} +2 -2
  79. package/dist/{types-CxII3XkA.d.ts → types-BgYFd_Yw.d.cts} +5 -5
  80. package/dist/{types-CSHFipIc.d.cts → types-BivGO7I9.d.ts} +5 -5
  81. package/dist/{types-CovcHpYf.d.cts → types-D958TC71.d.cts} +2 -2
  82. package/package.json +25 -23
  83. package/dist/backends-CzDbiQar.d.ts +0 -20
  84. package/dist/backends-SVMT-7l4.d.cts +0 -20
  85. package/dist/chunk-SFVKOEQH.js +0 -103
@@ -1,15 +1,18 @@
1
- import { c as ContactEventConfig, g as MessageEvent, C as ContactEvent, f as PlatformEvent, P as PlatformMessage } from './types-CovcHpYf.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-CovcHpYf.cjs';
1
+ import { c as ContactEventConfig, g as MessageEvent, C as ContactEvent, f as PlatformEvent, P as PlatformMessage } from './types-D958TC71.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-D958TC71.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-CInhtFpA.cjs';
5
- import { e as AgentToolsRestApi, f as ChatMessagingRestApi, g as ChatRoomRestApi, h as ContactRestApi } from './types-CSHFipIc.cjs';
6
- import { b as ThenvoiLink, c as ExecutionContext } from './schemas-BpEBkq5V.cjs';
7
- export { d as ALL_TOOL_NAMES, A as AgentRuntime, B as BASE_TOOL_NAMES, C as CHAT_TOOL_NAMES, e as CONTACT_TOOL_NAMES, D as DefaultPreprocessor, E as ExecutionContextOptions, f as ExecutionState, M as MCP_TOOL_PREFIX, g as MEMORY_TOOL_NAMES, h as MessageRetryTracker, P as PlatformRuntime, T as TOOL_MODELS, i as getToolDescription, m as mcpToolNames } from './schemas-BpEBkq5V.cjs';
8
- import { M as MetadataMap, P as ParticipantRecord, a as MentionInput, T as ToolOperationResult, c as PaginatedList, d as PeerRecord, 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-DUpbIu8k.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-BotL3ZLH.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, T as TOOL_MODELS, j as getToolDescription, m as mcpToolNames } from './schemas-BotL3ZLH.cjs';
8
+ import { M as MetadataMap, a as MentionInput, T as ToolOperationResult, 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';
9
+ import { ParticipantRoster } from '@band-ai/band-sdk-core';
10
+ export { ParticipantRoster, RetryTracker } from '@band-ai/band-sdk-core';
9
11
  import 'zod';
10
- import './pagination-BPiys10t.cjs';
12
+ import './pagination-DqdkQArT.cjs';
13
+ import './disconnectReason-IuADl6TH.cjs';
11
14
 
12
- 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 thenvoi_lookup_peers() or thenvoi_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 - `thenvoi_respond_contact_request(action=\"approve\", request_id=\"...\")` to accept\n - `thenvoi_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. thenvoi_send_event(\"Received contact request from Alice. Approving.\", message_type=\"thought\")\n2. thenvoi_respond_contact_request(action=\"approve\", request_id=\"abc-123\")\n3. thenvoi_send_event(\"Approved contact request from Alice (@alice)\", message_type=\"thought\")\n\n## Contact Tools (use these, NOT participant tools)\n- `thenvoi_respond_contact_request(action, request_id)` - Approve/reject requests\n- `thenvoi_list_contact_requests()` - List pending requests\n- `thenvoi_list_contacts()` - List current contacts";
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";
13
16
  type ContactHandlerRestApi = Partial<AgentToolsRestApi> & Pick<ChatMessagingRestApi, "createChatEvent"> & Pick<ChatRoomRestApi, "createChat"> & Partial<Pick<ContactRestApi, "listContactRequests">>;
14
17
  interface ContactEventHandlerOptions {
15
18
  config: ContactEventConfig;
@@ -54,7 +57,7 @@ declare class ContactEventHandler {
54
57
  type ExecutionHandler = (context: ExecutionContext, event: PlatformEvent) => Promise<void>;
55
58
  interface ExecutionOptions {
56
59
  roomId: string;
57
- link: ThenvoiLink;
60
+ link: BandLink;
58
61
  context: ExecutionContext;
59
62
  onExecute: ExecutionHandler;
60
63
  onFailure?: (error: unknown, event: PlatformEvent) => void | Promise<void>;
@@ -97,7 +100,7 @@ declare class Execution {
97
100
  }
98
101
 
99
102
  interface RoomPresenceOptions {
100
- link: ThenvoiLink;
103
+ link: BandLink;
101
104
  roomFilter?: (room: MetadataMap) => boolean;
102
105
  autoSubscribeExistingRooms?: boolean;
103
106
  logger?: Logger;
@@ -131,14 +134,14 @@ declare class RoomPresence {
131
134
  interface AgentToolsOptions {
132
135
  roomId: string;
133
136
  rest: AgentToolsRestApi;
134
- participants?: ParticipantRecord[];
137
+ roster?: ParticipantRoster;
135
138
  capabilities?: Partial<AgentToolsCapabilities>;
136
139
  }
137
140
  declare class AgentTools implements AgentToolsProtocol {
138
141
  readonly roomId: string;
139
142
  readonly capabilities: Readonly<AgentToolsCapabilities>;
140
143
  private readonly rest;
141
- private participants;
144
+ private readonly roster;
142
145
  private readonly adapterTools;
143
146
  private readonly toolHandlers;
144
147
  constructor(options: AgentToolsOptions);
@@ -175,7 +178,6 @@ declare class AgentTools implements AgentToolsProtocol {
175
178
  private resolveMentions;
176
179
  private lookupPeerByName;
177
180
  private normalizeMentionHandle;
178
- private replaceParticipants;
179
181
  private buildAdapterTools;
180
182
  private bindAdapterToolMethod;
181
183
  private buildToolHandlers;
@@ -224,7 +226,10 @@ declare function formatHistoryForLlm(messages: Array<Record<string, unknown>>, o
224
226
  }): ToolModelMessage[];
225
227
  declare function buildParticipantsMessage(participants: Array<Record<string, unknown>>): string;
226
228
 
227
- declare const BASE_INSTRUCTIONS = "\n## Environment\n\nMulti-participant chat. Messages show sender: [Name]: content.\nMessages prefixed with [System]: are platform updates (participant changes, contact updates, etc.) \u2014 not messages from users.\nUse `thenvoi_send_message(content, mentions)` to respond. Plain text output is not delivered.\nMentions use handles: @<username> for users, @<username>/<agent-name> for agents.\n\n## CRITICAL: Delegate When You Cannot Help Directly\n\nYou have NO internet access and NO real-time data. When asked about weather, news, stock prices,\nor any current information you cannot answer directly:\n\n1. Call `thenvoi_lookup_peers()` to find available specialized agents\n2. If a relevant agent exists, call `thenvoi_add_participant(name)` to add them\n3. Ask that agent using `thenvoi_send_message(question, mentions=[agent_handle])`\n4. Wait for their response and relay it back to the user\n\nNEVER say \"I can't do that\" without first checking if another agent can help via `thenvoi_lookup_peers()`.\n\n## CRITICAL: Do NOT Remove Agents Automatically\n\nAfter adding an agent to help with a task:\n1. Ask your question and wait for their response\n2. Relay their response back to the original requester\n3. **Do NOT remove the agent** - they stay silent unless mentioned and may be useful for follow-ups\n\nOnly remove agents if the user explicitly requests it.\n\n## CRITICAL: Always Relay Information Back to the Requester\n\nWhen someone asks you to get information from another agent:\n1. Ask the other agent for the information\n2. When you receive the response, IMMEDIATELY relay it back to the ORIGINAL REQUESTER\n3. Do NOT just thank the helper agent - the requester is waiting for their answer!\n\n## IMPORTANT: Always Share Your Thinking\n\nYou MUST call `thenvoi_send_event(content, message_type=\"thought\")` BEFORE every action.\nThis is required so users can see your reasoning process.\n\n## Examples\n\n### Simple question - answer directly\n[John Doe]: What's 2+2?\n-> thenvoi_send_event(\"Simple arithmetic, answering directly.\", message_type=\"thought\")\n-> thenvoi_send_message(\"4\", mentions=[\"@john\"])\n\n### User asks about weather (you cannot answer directly)\n[John Doe]: What's the weather in Tokyo?\n-> thenvoi_send_event(\"I can't check weather directly. Looking for a Weather Agent.\", message_type=\"thought\")\n-> thenvoi_lookup_peers()\n-> thenvoi_send_event(\"Found Weather Agent. Adding to room.\", message_type=\"thought\")\n-> thenvoi_add_participant(\"Weather Agent\")\n-> thenvoi_send_message(\"What's the weather in Tokyo?\", mentions=[\"@john/weather-agent\"])\n\n[Weather Agent]: Tokyo is 15\u00B0C and cloudy.\n-> thenvoi_send_event(\"Got weather response. Relaying back to John Doe.\", message_type=\"thought\")\n-> thenvoi_send_message(\"The weather in Tokyo is 15\u00B0C and cloudy.\", mentions=[\"@john\"])\n\n### No suitable agent available\n[John Doe]: What's the stock price of AAPL?\n-> thenvoi_send_event(\"I can't check stock prices. Looking for a Stock Agent.\", message_type=\"thought\")\n-> thenvoi_lookup_peers()\n-> thenvoi_send_event(\"No stock agent available. Must inform user.\", message_type=\"thought\")\n-> thenvoi_send_message(\"I don't have access to stock prices, and there's no specialized agent available to help with that.\", mentions=[\"@john\"])\n\n### Follow-up question in same conversation\n[John Doe]: What about London?\n-> thenvoi_send_event(\"Follow-up weather question. Asking Weather Agent.\", message_type=\"thought\")\n-> thenvoi_send_message(\"What's the weather in London?\", mentions=[\"@john/weather-agent\"])\n\n[Weather Agent]: London is 8\u00B0C and rainy.\n-> thenvoi_send_event(\"Got London weather. Relaying to John Doe.\", message_type=\"thought\")\n-> thenvoi_send_message(\"London is 8\u00B0C and rainy.\", mentions=[\"@john\"])\n";
229
+ declare const BASE_INSTRUCTIONS: string;
230
+
231
+ declare const MEMORY_SECTION: string;
232
+
228
233
  declare const TEMPLATES: Record<string, string>;
229
234
  interface RenderSystemPromptOptions {
230
235
  agentName?: string;
@@ -232,22 +237,10 @@ interface RenderSystemPromptOptions {
232
237
  customSection?: string;
233
238
  template?: string;
234
239
  includeBaseInstructions?: boolean;
240
+ capabilities?: Partial<AgentToolsCapabilities>;
235
241
  }
236
242
  declare function renderSystemPrompt(options?: RenderSystemPromptOptions): string;
237
243
 
238
- declare class ParticipantTracker {
239
- private participantsList;
240
- private lastSent;
241
- private loaded;
242
- get participants(): Array<Record<string, unknown>>;
243
- get isLoaded(): boolean;
244
- setLoaded(participants: Array<Record<string, unknown>>): void;
245
- add(participant: Record<string, unknown>): boolean;
246
- remove(participantId: string): boolean;
247
- changed(): boolean;
248
- markSent(): void;
249
- }
250
-
251
244
  interface StoppableAgent {
252
245
  stop(timeoutMs?: number | null): Promise<boolean>;
253
246
  run(options?: {
@@ -273,4 +266,4 @@ declare class GracefulShutdown {
273
266
  }
274
267
  declare function runWithGracefulShutdown(agent: StoppableAgent, options?: GracefulShutdownOptions): Promise<void>;
275
268
 
276
- 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, ParticipantTracker, PlatformMessage, type RenderSystemPromptOptions, RoomPresence, TEMPLATES, assertChatEventType, buildParticipantsMessage, formatHistoryForLlm, formatMessageForLlm, isChatEventType, renderSystemPrompt, replaceUuidMentions, runWithGracefulShutdown };
269
+ 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, RoomPresence, TEMPLATES, assertChatEventType, buildParticipantsMessage, formatHistoryForLlm, formatMessageForLlm, isChatEventType, renderSystemPrompt, replaceUuidMentions, runWithGracefulShutdown };
package/dist/runtime.d.ts CHANGED
@@ -1,15 +1,18 @@
1
- import { c as ContactEventConfig, g as MessageEvent, C as ContactEvent, f as PlatformEvent, P as PlatformMessage } from './types-7jVzOeOP.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-7jVzOeOP.js';
1
+ import { c as ContactEventConfig, g as MessageEvent, C as ContactEvent, f as PlatformEvent, P as PlatformMessage } from './types-BTN_ZETM.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-BTN_ZETM.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-DrhzOH6K.js';
5
- import { e as AgentToolsRestApi, f as ChatMessagingRestApi, g as ChatRoomRestApi, h as ContactRestApi } from './types-CxII3XkA.js';
6
- import { b as ThenvoiLink, c as ExecutionContext } from './schemas-vos1AaBc.js';
7
- export { d as ALL_TOOL_NAMES, A as AgentRuntime, B as BASE_TOOL_NAMES, C as CHAT_TOOL_NAMES, e as CONTACT_TOOL_NAMES, D as DefaultPreprocessor, E as ExecutionContextOptions, f as ExecutionState, M as MCP_TOOL_PREFIX, g as MEMORY_TOOL_NAMES, h as MessageRetryTracker, P as PlatformRuntime, T as TOOL_MODELS, i as getToolDescription, m as mcpToolNames } from './schemas-vos1AaBc.js';
8
- import { M as MetadataMap, P as ParticipantRecord, a as MentionInput, T as ToolOperationResult, c as PaginatedList, d as PeerRecord, 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-DUpbIu8k.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-DBsC4J1g.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, T as TOOL_MODELS, j as getToolDescription, m as mcpToolNames } from './schemas-DBsC4J1g.js';
8
+ import { M as MetadataMap, a as MentionInput, T as ToolOperationResult, 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';
9
+ import { ParticipantRoster } from '@band-ai/band-sdk-core';
10
+ export { ParticipantRoster, RetryTracker } from '@band-ai/band-sdk-core';
9
11
  import 'zod';
10
- import './pagination-CcDkVFxK.js';
12
+ import './pagination-BgEx-HeL.js';
13
+ import './disconnectReason-IuADl6TH.js';
11
14
 
12
- 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 thenvoi_lookup_peers() or thenvoi_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 - `thenvoi_respond_contact_request(action=\"approve\", request_id=\"...\")` to accept\n - `thenvoi_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. thenvoi_send_event(\"Received contact request from Alice. Approving.\", message_type=\"thought\")\n2. thenvoi_respond_contact_request(action=\"approve\", request_id=\"abc-123\")\n3. thenvoi_send_event(\"Approved contact request from Alice (@alice)\", message_type=\"thought\")\n\n## Contact Tools (use these, NOT participant tools)\n- `thenvoi_respond_contact_request(action, request_id)` - Approve/reject requests\n- `thenvoi_list_contact_requests()` - List pending requests\n- `thenvoi_list_contacts()` - List current contacts";
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";
13
16
  type ContactHandlerRestApi = Partial<AgentToolsRestApi> & Pick<ChatMessagingRestApi, "createChatEvent"> & Pick<ChatRoomRestApi, "createChat"> & Partial<Pick<ContactRestApi, "listContactRequests">>;
14
17
  interface ContactEventHandlerOptions {
15
18
  config: ContactEventConfig;
@@ -54,7 +57,7 @@ declare class ContactEventHandler {
54
57
  type ExecutionHandler = (context: ExecutionContext, event: PlatformEvent) => Promise<void>;
55
58
  interface ExecutionOptions {
56
59
  roomId: string;
57
- link: ThenvoiLink;
60
+ link: BandLink;
58
61
  context: ExecutionContext;
59
62
  onExecute: ExecutionHandler;
60
63
  onFailure?: (error: unknown, event: PlatformEvent) => void | Promise<void>;
@@ -97,7 +100,7 @@ declare class Execution {
97
100
  }
98
101
 
99
102
  interface RoomPresenceOptions {
100
- link: ThenvoiLink;
103
+ link: BandLink;
101
104
  roomFilter?: (room: MetadataMap) => boolean;
102
105
  autoSubscribeExistingRooms?: boolean;
103
106
  logger?: Logger;
@@ -131,14 +134,14 @@ declare class RoomPresence {
131
134
  interface AgentToolsOptions {
132
135
  roomId: string;
133
136
  rest: AgentToolsRestApi;
134
- participants?: ParticipantRecord[];
137
+ roster?: ParticipantRoster;
135
138
  capabilities?: Partial<AgentToolsCapabilities>;
136
139
  }
137
140
  declare class AgentTools implements AgentToolsProtocol {
138
141
  readonly roomId: string;
139
142
  readonly capabilities: Readonly<AgentToolsCapabilities>;
140
143
  private readonly rest;
141
- private participants;
144
+ private readonly roster;
142
145
  private readonly adapterTools;
143
146
  private readonly toolHandlers;
144
147
  constructor(options: AgentToolsOptions);
@@ -175,7 +178,6 @@ declare class AgentTools implements AgentToolsProtocol {
175
178
  private resolveMentions;
176
179
  private lookupPeerByName;
177
180
  private normalizeMentionHandle;
178
- private replaceParticipants;
179
181
  private buildAdapterTools;
180
182
  private bindAdapterToolMethod;
181
183
  private buildToolHandlers;
@@ -224,7 +226,10 @@ declare function formatHistoryForLlm(messages: Array<Record<string, unknown>>, o
224
226
  }): ToolModelMessage[];
225
227
  declare function buildParticipantsMessage(participants: Array<Record<string, unknown>>): string;
226
228
 
227
- declare const BASE_INSTRUCTIONS = "\n## Environment\n\nMulti-participant chat. Messages show sender: [Name]: content.\nMessages prefixed with [System]: are platform updates (participant changes, contact updates, etc.) \u2014 not messages from users.\nUse `thenvoi_send_message(content, mentions)` to respond. Plain text output is not delivered.\nMentions use handles: @<username> for users, @<username>/<agent-name> for agents.\n\n## CRITICAL: Delegate When You Cannot Help Directly\n\nYou have NO internet access and NO real-time data. When asked about weather, news, stock prices,\nor any current information you cannot answer directly:\n\n1. Call `thenvoi_lookup_peers()` to find available specialized agents\n2. If a relevant agent exists, call `thenvoi_add_participant(name)` to add them\n3. Ask that agent using `thenvoi_send_message(question, mentions=[agent_handle])`\n4. Wait for their response and relay it back to the user\n\nNEVER say \"I can't do that\" without first checking if another agent can help via `thenvoi_lookup_peers()`.\n\n## CRITICAL: Do NOT Remove Agents Automatically\n\nAfter adding an agent to help with a task:\n1. Ask your question and wait for their response\n2. Relay their response back to the original requester\n3. **Do NOT remove the agent** - they stay silent unless mentioned and may be useful for follow-ups\n\nOnly remove agents if the user explicitly requests it.\n\n## CRITICAL: Always Relay Information Back to the Requester\n\nWhen someone asks you to get information from another agent:\n1. Ask the other agent for the information\n2. When you receive the response, IMMEDIATELY relay it back to the ORIGINAL REQUESTER\n3. Do NOT just thank the helper agent - the requester is waiting for their answer!\n\n## IMPORTANT: Always Share Your Thinking\n\nYou MUST call `thenvoi_send_event(content, message_type=\"thought\")` BEFORE every action.\nThis is required so users can see your reasoning process.\n\n## Examples\n\n### Simple question - answer directly\n[John Doe]: What's 2+2?\n-> thenvoi_send_event(\"Simple arithmetic, answering directly.\", message_type=\"thought\")\n-> thenvoi_send_message(\"4\", mentions=[\"@john\"])\n\n### User asks about weather (you cannot answer directly)\n[John Doe]: What's the weather in Tokyo?\n-> thenvoi_send_event(\"I can't check weather directly. Looking for a Weather Agent.\", message_type=\"thought\")\n-> thenvoi_lookup_peers()\n-> thenvoi_send_event(\"Found Weather Agent. Adding to room.\", message_type=\"thought\")\n-> thenvoi_add_participant(\"Weather Agent\")\n-> thenvoi_send_message(\"What's the weather in Tokyo?\", mentions=[\"@john/weather-agent\"])\n\n[Weather Agent]: Tokyo is 15\u00B0C and cloudy.\n-> thenvoi_send_event(\"Got weather response. Relaying back to John Doe.\", message_type=\"thought\")\n-> thenvoi_send_message(\"The weather in Tokyo is 15\u00B0C and cloudy.\", mentions=[\"@john\"])\n\n### No suitable agent available\n[John Doe]: What's the stock price of AAPL?\n-> thenvoi_send_event(\"I can't check stock prices. Looking for a Stock Agent.\", message_type=\"thought\")\n-> thenvoi_lookup_peers()\n-> thenvoi_send_event(\"No stock agent available. Must inform user.\", message_type=\"thought\")\n-> thenvoi_send_message(\"I don't have access to stock prices, and there's no specialized agent available to help with that.\", mentions=[\"@john\"])\n\n### Follow-up question in same conversation\n[John Doe]: What about London?\n-> thenvoi_send_event(\"Follow-up weather question. Asking Weather Agent.\", message_type=\"thought\")\n-> thenvoi_send_message(\"What's the weather in London?\", mentions=[\"@john/weather-agent\"])\n\n[Weather Agent]: London is 8\u00B0C and rainy.\n-> thenvoi_send_event(\"Got London weather. Relaying to John Doe.\", message_type=\"thought\")\n-> thenvoi_send_message(\"London is 8\u00B0C and rainy.\", mentions=[\"@john\"])\n";
229
+ declare const BASE_INSTRUCTIONS: string;
230
+
231
+ declare const MEMORY_SECTION: string;
232
+
228
233
  declare const TEMPLATES: Record<string, string>;
229
234
  interface RenderSystemPromptOptions {
230
235
  agentName?: string;
@@ -232,22 +237,10 @@ interface RenderSystemPromptOptions {
232
237
  customSection?: string;
233
238
  template?: string;
234
239
  includeBaseInstructions?: boolean;
240
+ capabilities?: Partial<AgentToolsCapabilities>;
235
241
  }
236
242
  declare function renderSystemPrompt(options?: RenderSystemPromptOptions): string;
237
243
 
238
- declare class ParticipantTracker {
239
- private participantsList;
240
- private lastSent;
241
- private loaded;
242
- get participants(): Array<Record<string, unknown>>;
243
- get isLoaded(): boolean;
244
- setLoaded(participants: Array<Record<string, unknown>>): void;
245
- add(participant: Record<string, unknown>): boolean;
246
- remove(participantId: string): boolean;
247
- changed(): boolean;
248
- markSent(): void;
249
- }
250
-
251
244
  interface StoppableAgent {
252
245
  stop(timeoutMs?: number | null): Promise<boolean>;
253
246
  run(options?: {
@@ -273,4 +266,4 @@ declare class GracefulShutdown {
273
266
  }
274
267
  declare function runWithGracefulShutdown(agent: StoppableAgent, options?: GracefulShutdownOptions): Promise<void>;
275
268
 
276
- 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, ParticipantTracker, PlatformMessage, type RenderSystemPromptOptions, RoomPresence, TEMPLATES, assertChatEventType, buildParticipantsMessage, formatHistoryForLlm, formatMessageForLlm, isChatEventType, renderSystemPrompt, replaceUuidMentions, runWithGracefulShutdown };
269
+ 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, RoomPresence, TEMPLATES, assertChatEventType, buildParticipantsMessage, formatHistoryForLlm, formatMessageForLlm, isChatEventType, renderSystemPrompt, replaceUuidMentions, runWithGracefulShutdown };
package/dist/runtime.js CHANGED
@@ -8,13 +8,12 @@ import {
8
8
  ExecutionContext,
9
9
  GracefulShutdown,
10
10
  HUB_ROOM_SYSTEM_PROMPT,
11
- MessageRetryTracker,
12
11
  PlatformRuntime,
13
12
  hydrateTrackedRooms,
14
13
  runWithGracefulShutdown,
15
14
  trackRoomJoin,
16
15
  trackRoomLeave
17
- } from "./chunk-I5EZG52P.js";
16
+ } from "./chunk-N2QTUMGO.js";
18
17
  import {
19
18
  HistoryProvider,
20
19
  SYNTHETIC_CONTACT_EVENTS_SENDER_ID,
@@ -25,7 +24,13 @@ import {
25
24
  formatHistoryForLlm,
26
25
  formatMessageForLlm,
27
26
  replaceUuidMentions
28
- } from "./chunk-INA6YZTZ.js";
27
+ } from "./chunk-LBWKISBS.js";
28
+ import {
29
+ BASE_INSTRUCTIONS,
30
+ MEMORY_SECTION,
31
+ TEMPLATES,
32
+ renderSystemPrompt
33
+ } from "./chunk-WLCM2OXG.js";
29
34
  import {
30
35
  ALL_TOOL_NAMES,
31
36
  BASE_TOOL_NAMES,
@@ -33,6 +38,7 @@ import {
33
38
  CHAT_MESSAGE_TYPES,
34
39
  CHAT_TOOL_NAMES,
35
40
  CONTACT_TOOL_NAMES,
41
+ MCP_SERVER_NAME,
36
42
  MCP_TOOL_PREFIX,
37
43
  MEMORY_TOOL_NAMES,
38
44
  TOOL_MODELS,
@@ -40,21 +46,17 @@ import {
40
46
  getToolDescription,
41
47
  isChatEventType,
42
48
  mcpToolNames
43
- } from "./chunk-GVEQ3RAH.js";
44
- import {
45
- BASE_INSTRUCTIONS,
46
- TEMPLATES,
47
- renderSystemPrompt
48
- } from "./chunk-SFVKOEQH.js";
49
+ } from "./chunk-RV76SKFT.js";
50
+ import "./chunk-US226AS4.js";
49
51
  import {
50
52
  DEFAULT_REQUEST_OPTIONS
51
- } from "./chunk-SG4WLD2H.js";
53
+ } from "./chunk-EAI2M3WM.js";
52
54
  import "./chunk-ZZJRRBPQ.js";
53
55
  import "./chunk-3BKAC4OZ.js";
54
56
  import {
55
57
  NoopLogger
56
58
  } from "./chunk-OD2G5LFQ.js";
57
- import "./chunk-YR3BOQNW.js";
59
+ import "./chunk-JY75VSQK.js";
58
60
 
59
61
  // src/runtime/rooms/RoomPresence.ts
60
62
  var RoomPresence = class {
@@ -177,60 +179,8 @@ var RoomPresence = class {
177
179
  }
178
180
  };
179
181
 
180
- // src/runtime/participantTracker.ts
181
- var ParticipantTracker = class {
182
- participantsList = [];
183
- lastSent = null;
184
- loaded = false;
185
- get participants() {
186
- return [...this.participantsList];
187
- }
188
- get isLoaded() {
189
- return this.loaded;
190
- }
191
- setLoaded(participants) {
192
- this.participantsList = participants.map((participant) => ({ ...participant }));
193
- this.loaded = true;
194
- }
195
- add(participant) {
196
- if (this.participantsList.some((entry) => entry.id === participant.id)) {
197
- return false;
198
- }
199
- this.participantsList.push({
200
- id: participant.id,
201
- name: participant.name,
202
- type: participant.type,
203
- handle: participant.handle
204
- });
205
- return true;
206
- }
207
- remove(participantId) {
208
- const before = this.participantsList.length;
209
- this.participantsList = this.participantsList.filter(
210
- (participant) => participant.id !== participantId
211
- );
212
- return this.participantsList.length < before;
213
- }
214
- changed() {
215
- if (!this.lastSent) {
216
- return true;
217
- }
218
- const oldIds = new Set(this.lastSent.map((participant) => participant.id));
219
- const newIds = new Set(this.participantsList.map((participant) => participant.id));
220
- if (oldIds.size !== newIds.size) {
221
- return true;
222
- }
223
- for (const id of oldIds) {
224
- if (!newIds.has(id)) {
225
- return true;
226
- }
227
- }
228
- return false;
229
- }
230
- markSent() {
231
- this.lastSent = this.participantsList.map((participant) => ({ ...participant }));
232
- }
233
- };
182
+ // src/runtime/index.ts
183
+ import { ParticipantRoster, RetryTracker } from "@band-ai/band-sdk-core";
234
184
  export {
235
185
  ALL_TOOL_NAMES,
236
186
  AgentRuntime,
@@ -249,11 +199,13 @@ export {
249
199
  GracefulShutdown,
250
200
  HUB_ROOM_SYSTEM_PROMPT,
251
201
  HistoryProvider,
202
+ MCP_SERVER_NAME,
252
203
  MCP_TOOL_PREFIX,
204
+ MEMORY_SECTION,
253
205
  MEMORY_TOOL_NAMES,
254
- MessageRetryTracker,
255
- ParticipantTracker,
206
+ ParticipantRoster,
256
207
  PlatformRuntime,
208
+ RetryTracker,
257
209
  RoomPresence,
258
210
  SYNTHETIC_CONTACT_EVENTS_SENDER_ID,
259
211
  SYNTHETIC_CONTACT_EVENTS_SENDER_NAME,