@band-ai/sdk 0.1.2

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 (91) hide show
  1. package/dist/CodexAdapter-A1k_LMdZ.d.ts +1278 -0
  2. package/dist/CodexAdapter-BbZD-nBd.d.cts +1278 -0
  3. package/dist/adapters.cjs +10643 -0
  4. package/dist/adapters.d.cts +217 -0
  5. package/dist/adapters.d.ts +217 -0
  6. package/dist/adapters.js +92 -0
  7. package/dist/backends-BnOLsG7w.d.cts +20 -0
  8. package/dist/backends-C4n6cKOf.d.ts +20 -0
  9. package/dist/chunk-3BKAC4OZ.js +44 -0
  10. package/dist/chunk-5CXIMAH2.js +52 -0
  11. package/dist/chunk-6AJA2OPC.js +3682 -0
  12. package/dist/chunk-A3TDK6GP.js +6674 -0
  13. package/dist/chunk-AVVDPXP4.js +39 -0
  14. package/dist/chunk-EDPKUUJL.js +177 -0
  15. package/dist/chunk-FUODYQRE.js +2562 -0
  16. package/dist/chunk-GVEQ3RAH.js +373 -0
  17. package/dist/chunk-INA6YZTZ.js +88 -0
  18. package/dist/chunk-IZPV6QS6.js +115 -0
  19. package/dist/chunk-LY55KYVI.js +0 -0
  20. package/dist/chunk-NIAQBANR.js +577 -0
  21. package/dist/chunk-OD2G5LFQ.js +78 -0
  22. package/dist/chunk-SFVKOEQH.js +103 -0
  23. package/dist/chunk-SG4WLD2H.js +1093 -0
  24. package/dist/chunk-YR3BOQNW.js +39 -0
  25. package/dist/chunk-ZZJRRBPQ.js +82 -0
  26. package/dist/claude-CcnQ5OUC.d.ts +53 -0
  27. package/dist/claude-CwTAxhwI.d.cts +53 -0
  28. package/dist/config.cjs +164 -0
  29. package/dist/config.d.cts +19 -0
  30. package/dist/config.d.ts +19 -0
  31. package/dist/config.js +9 -0
  32. package/dist/converters.cjs +1086 -0
  33. package/dist/converters.d.cts +143 -0
  34. package/dist/converters.d.ts +143 -0
  35. package/dist/converters.js +468 -0
  36. package/dist/core.cjs +185 -0
  37. package/dist/core.d.cts +22 -0
  38. package/dist/core.d.ts +22 -0
  39. package/dist/core.js +24 -0
  40. package/dist/customTools-BzF0IISO.d.cts +10 -0
  41. package/dist/customTools-BzF0IISO.d.ts +10 -0
  42. package/dist/dtos-DUpbIu8k.d.cts +163 -0
  43. package/dist/dtos-DUpbIu8k.d.ts +163 -0
  44. package/dist/history-ByessXNq.d.ts +24 -0
  45. package/dist/history-i6yN7neC.d.cts +24 -0
  46. package/dist/index.cjs +13914 -0
  47. package/dist/index.d.cts +63 -0
  48. package/dist/index.d.ts +63 -0
  49. package/dist/index.js +198 -0
  50. package/dist/linear.cjs +2207 -0
  51. package/dist/linear.d.cts +167 -0
  52. package/dist/linear.d.ts +167 -0
  53. package/dist/linear.js +2139 -0
  54. package/dist/logger-CABQOnlR.d.cts +21 -0
  55. package/dist/logger-CABQOnlR.d.ts +21 -0
  56. package/dist/mcp-claude.cjs +584 -0
  57. package/dist/mcp-claude.d.cts +4 -0
  58. package/dist/mcp-claude.d.ts +4 -0
  59. package/dist/mcp-claude.js +11 -0
  60. package/dist/mcp.cjs +1247 -0
  61. package/dist/mcp.d.cts +97 -0
  62. package/dist/mcp.d.ts +97 -0
  63. package/dist/mcp.js +27 -0
  64. package/dist/opencode-BBcDchcN.d.cts +159 -0
  65. package/dist/opencode-DthQQUsZ.d.ts +159 -0
  66. package/dist/pagination-BPiys10t.d.cts +25 -0
  67. package/dist/pagination-CcDkVFxK.d.ts +25 -0
  68. package/dist/protocols-CInhtFpA.d.cts +116 -0
  69. package/dist/protocols-DrhzOH6K.d.ts +116 -0
  70. package/dist/rest.cjs +1159 -0
  71. package/dist/rest.d.cts +144 -0
  72. package/dist/rest.d.ts +144 -0
  73. package/dist/rest.js +18 -0
  74. package/dist/runtime.cjs +5353 -0
  75. package/dist/runtime.d.cts +276 -0
  76. package/dist/runtime.d.ts +276 -0
  77. package/dist/runtime.js +274 -0
  78. package/dist/schemas-BpEBkq5V.d.cts +592 -0
  79. package/dist/schemas-vos1AaBc.d.ts +592 -0
  80. package/dist/sdk-HJUVSSWA.js +10 -0
  81. package/dist/simpleAdapter-9OE_p6QW.d.ts +29 -0
  82. package/dist/simpleAdapter-DqhvjsGr.d.cts +29 -0
  83. package/dist/testing.cjs +217 -0
  84. package/dist/testing.d.cts +126 -0
  85. package/dist/testing.d.ts +126 -0
  86. package/dist/testing.js +186 -0
  87. package/dist/types-7jVzOeOP.d.ts +446 -0
  88. package/dist/types-CSHFipIc.d.cts +331 -0
  89. package/dist/types-CovcHpYf.d.cts +446 -0
  90. package/dist/types-CxII3XkA.d.ts +331 -0
  91. package/package.json +189 -0
@@ -0,0 +1,274 @@
1
+ import {
2
+ AgentRuntime,
3
+ AgentTools,
4
+ ContactEventHandler,
5
+ ContactToolsImpl,
6
+ DefaultPreprocessor,
7
+ Execution,
8
+ ExecutionContext,
9
+ GracefulShutdown,
10
+ HUB_ROOM_SYSTEM_PROMPT,
11
+ MessageRetryTracker,
12
+ PlatformRuntime,
13
+ hydrateTrackedRooms,
14
+ runWithGracefulShutdown,
15
+ trackRoomJoin,
16
+ trackRoomLeave
17
+ } from "./chunk-6AJA2OPC.js";
18
+ import {
19
+ HistoryProvider,
20
+ SYNTHETIC_CONTACT_EVENTS_SENDER_ID,
21
+ SYNTHETIC_CONTACT_EVENTS_SENDER_NAME,
22
+ SYNTHETIC_SENDER_TYPE,
23
+ buildParticipantsMessage,
24
+ ensureHandlePrefix,
25
+ formatHistoryForLlm,
26
+ formatMessageForLlm,
27
+ replaceUuidMentions
28
+ } from "./chunk-INA6YZTZ.js";
29
+ import {
30
+ ALL_TOOL_NAMES,
31
+ BASE_TOOL_NAMES,
32
+ CHAT_EVENT_TYPES,
33
+ CHAT_MESSAGE_TYPES,
34
+ CHAT_TOOL_NAMES,
35
+ CONTACT_TOOL_NAMES,
36
+ MCP_TOOL_PREFIX,
37
+ MEMORY_TOOL_NAMES,
38
+ TOOL_MODELS,
39
+ assertChatEventType,
40
+ getToolDescription,
41
+ isChatEventType,
42
+ mcpToolNames
43
+ } from "./chunk-GVEQ3RAH.js";
44
+ import {
45
+ BASE_INSTRUCTIONS,
46
+ TEMPLATES,
47
+ renderSystemPrompt
48
+ } from "./chunk-SFVKOEQH.js";
49
+ import {
50
+ DEFAULT_REQUEST_OPTIONS
51
+ } from "./chunk-SG4WLD2H.js";
52
+ import "./chunk-ZZJRRBPQ.js";
53
+ import "./chunk-3BKAC4OZ.js";
54
+ import {
55
+ NoopLogger
56
+ } from "./chunk-OD2G5LFQ.js";
57
+ import "./chunk-YR3BOQNW.js";
58
+
59
+ // src/runtime/rooms/RoomPresence.ts
60
+ var RoomPresence = class {
61
+ rooms = /* @__PURE__ */ new Set();
62
+ onRoomJoined = null;
63
+ onRoomLeft = null;
64
+ onRoomEvent = null;
65
+ onContactEvent = null;
66
+ link;
67
+ roomFilter;
68
+ autoSubscribeExistingRooms;
69
+ logger;
70
+ eventController = null;
71
+ eventTask = null;
72
+ contactsSubscribed = false;
73
+ constructor(options) {
74
+ this.link = options.link;
75
+ this.roomFilter = options.roomFilter;
76
+ this.autoSubscribeExistingRooms = options.autoSubscribeExistingRooms ?? true;
77
+ this.logger = options.logger ?? new NoopLogger();
78
+ }
79
+ async start() {
80
+ if (this.eventTask) {
81
+ return;
82
+ }
83
+ if (!this.link.isConnected()) {
84
+ await this.link.connect();
85
+ }
86
+ try {
87
+ await this.link.subscribeAgentRooms();
88
+ } catch {
89
+ }
90
+ if (this.autoSubscribeExistingRooms) {
91
+ await this.subscribeExistingRooms();
92
+ }
93
+ if (this.link.capabilities.contacts) {
94
+ await this.link.subscribeAgentContacts();
95
+ this.contactsSubscribed = true;
96
+ }
97
+ this.eventController = new AbortController();
98
+ this.eventTask = this.consumeEvents(this.eventController.signal);
99
+ }
100
+ async stop() {
101
+ this.eventController?.abort();
102
+ await this.eventTask;
103
+ this.eventTask = null;
104
+ this.eventController = null;
105
+ if (this.contactsSubscribed) {
106
+ await this.link.unsubscribeAgentContacts();
107
+ this.contactsSubscribed = false;
108
+ }
109
+ for (const roomId of [...this.rooms]) {
110
+ await trackRoomLeave({
111
+ link: this.link,
112
+ roomId,
113
+ trackedRooms: this.rooms,
114
+ onLeft: this.onRoomLeft ?? void 0
115
+ });
116
+ }
117
+ }
118
+ async consumeEvents(signal) {
119
+ while (!signal.aborted) {
120
+ const event = await this.link.nextEvent(signal);
121
+ if (!event) {
122
+ return;
123
+ }
124
+ switch (event.type) {
125
+ case "room_added":
126
+ await this.handleRoomAdded(event.roomId, event.payload);
127
+ break;
128
+ case "room_removed":
129
+ case "room_deleted":
130
+ await this.handleRoomRemoved(event.roomId);
131
+ break;
132
+ case "contact_request_received":
133
+ case "contact_request_updated":
134
+ case "contact_added":
135
+ case "contact_removed":
136
+ await this.onContactEvent?.(event);
137
+ break;
138
+ default:
139
+ if (event.roomId && this.rooms.has(event.roomId)) {
140
+ await this.onRoomEvent?.(event.roomId, event);
141
+ }
142
+ break;
143
+ }
144
+ }
145
+ }
146
+ async handleRoomAdded(roomId, payload) {
147
+ await trackRoomJoin({
148
+ link: this.link,
149
+ roomId,
150
+ payload,
151
+ trackedRooms: this.rooms,
152
+ roomFilter: this.roomFilter,
153
+ onJoined: this.onRoomJoined ?? void 0
154
+ });
155
+ }
156
+ async handleRoomRemoved(roomId) {
157
+ await trackRoomLeave({
158
+ link: this.link,
159
+ roomId,
160
+ trackedRooms: this.rooms,
161
+ onLeft: this.onRoomLeft ?? void 0
162
+ });
163
+ }
164
+ async subscribeExistingRooms() {
165
+ await hydrateTrackedRooms({
166
+ link: this.link,
167
+ trackedRooms: this.rooms,
168
+ requestOptions: DEFAULT_REQUEST_OPTIONS,
169
+ roomFilter: this.roomFilter,
170
+ onJoined: this.onRoomJoined ?? void 0,
171
+ onError: async (error) => {
172
+ this.logger.warn("RoomPresence failed to subscribe existing rooms", {
173
+ error
174
+ });
175
+ }
176
+ });
177
+ }
178
+ };
179
+
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
+ };
234
+ export {
235
+ ALL_TOOL_NAMES,
236
+ AgentRuntime,
237
+ AgentTools,
238
+ BASE_INSTRUCTIONS,
239
+ BASE_TOOL_NAMES,
240
+ CHAT_EVENT_TYPES,
241
+ CHAT_MESSAGE_TYPES,
242
+ CHAT_TOOL_NAMES,
243
+ CONTACT_TOOL_NAMES,
244
+ ContactEventHandler,
245
+ ContactToolsImpl,
246
+ DefaultPreprocessor,
247
+ Execution,
248
+ ExecutionContext,
249
+ GracefulShutdown,
250
+ HUB_ROOM_SYSTEM_PROMPT,
251
+ HistoryProvider,
252
+ MCP_TOOL_PREFIX,
253
+ MEMORY_TOOL_NAMES,
254
+ MessageRetryTracker,
255
+ ParticipantTracker,
256
+ PlatformRuntime,
257
+ RoomPresence,
258
+ SYNTHETIC_CONTACT_EVENTS_SENDER_ID,
259
+ SYNTHETIC_CONTACT_EVENTS_SENDER_NAME,
260
+ SYNTHETIC_SENDER_TYPE,
261
+ TEMPLATES,
262
+ TOOL_MODELS,
263
+ assertChatEventType,
264
+ buildParticipantsMessage,
265
+ ensureHandlePrefix,
266
+ formatHistoryForLlm,
267
+ formatMessageForLlm,
268
+ getToolDescription,
269
+ isChatEventType,
270
+ mcpToolNames,
271
+ renderSystemPrompt,
272
+ replaceUuidMentions,
273
+ runWithGracefulShutdown
274
+ };