@band-ai/sdk 0.1.10 → 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 (81) hide show
  1. package/README.md +54 -54
  2. package/dist/{ClaudeSDKAdapter-DfjaI5ke.d.cts → ClaudeSDKAdapter-BY4zEbCl.d.cts} +12 -10
  3. package/dist/{ClaudeSDKAdapter-DonPGJ43.d.ts → ClaudeSDKAdapter-Cna5P1dR.d.ts} +12 -10
  4. package/dist/{acp-server-NZAeg-WO.d.ts → acp-server-CiUqN3G3.d.ts} +2 -2
  5. package/dist/{acp-server-CUBXIiG6.d.cts → acp-server-Dlj7D563.d.cts} +2 -2
  6. package/dist/adapters.cjs +250 -183
  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-2BHHR6YW.js → chunk-4IAXZBXX.js} +62 -23
  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-RDM4TE4B.js → chunk-LBWKISBS.js} +19 -1
  16. package/dist/{chunk-FP237EAG.js → chunk-N2QTUMGO.js} +112 -195
  17. package/dist/{chunk-J3M3PFFY.js → chunk-NMZLX7TP.js} +35 -31
  18. package/dist/{chunk-6RXWL6TC.js → chunk-NT7TBFX2.js} +1 -1
  19. package/dist/{chunk-MLROFDKR.js → chunk-RV76SKFT.js} +39 -33
  20. package/dist/{chunk-XA4N2JPH.js → chunk-TLBCKDQO.js} +23 -23
  21. package/dist/{chunk-IZPV6QS6.js → chunk-WL2HNJZ6.js} +38 -11
  22. package/dist/{chunk-DNPVCR3S.js → chunk-WLCM2OXG.js} +31 -31
  23. package/dist/config.cjs +40 -13
  24. package/dist/config.d.cts +7 -1
  25. package/dist/config.d.ts +7 -1
  26. package/dist/config.js +2 -2
  27. package/dist/converters.cjs +61 -61
  28. package/dist/converters.d.cts +5 -5
  29. package/dist/converters.d.ts +5 -5
  30. package/dist/converters.js +4 -4
  31. package/dist/core.cjs +8 -8
  32. package/dist/core.d.cts +9 -9
  33. package/dist/core.d.ts +9 -9
  34. package/dist/core.js +3 -3
  35. package/dist/{dtos-Dd_fTfLn.d.cts → dtos-B8KU_q4d.d.cts} +2 -2
  36. package/dist/{dtos-Dd_fTfLn.d.ts → dtos-B8KU_q4d.d.ts} +2 -2
  37. package/dist/index.cjs +459 -504
  38. package/dist/index.d.cts +16 -15
  39. package/dist/index.d.ts +16 -15
  40. package/dist/index.js +15 -13
  41. package/dist/linear.cjs +74 -74
  42. package/dist/linear.d.cts +14 -14
  43. package/dist/linear.d.ts +14 -14
  44. package/dist/linear.js +72 -72
  45. package/dist/mcp-claude.cjs +37 -36
  46. package/dist/mcp-claude.d.cts +3 -3
  47. package/dist/mcp-claude.d.ts +3 -3
  48. package/dist/mcp-claude.js +7 -6
  49. package/dist/mcp.cjs +103 -62
  50. package/dist/mcp.d.cts +29 -16
  51. package/dist/mcp.d.ts +29 -16
  52. package/dist/mcp.js +14 -14
  53. package/dist/{opencode--iA5-KYk.d.cts → opencode-2YdscIc1.d.cts} +5 -5
  54. package/dist/{opencode-YNacv-eJ.d.ts → opencode-Bld62x5t.d.ts} +5 -5
  55. package/dist/{pagination-BBLsYLhT.d.ts → pagination-BgEx-HeL.d.ts} +2 -2
  56. package/dist/{pagination-CqidD-L_.d.cts → pagination-DqdkQArT.d.cts} +2 -2
  57. package/dist/{protocols-BF6jamIl.d.ts → protocols-Bwwcql0h.d.ts} +1 -1
  58. package/dist/{protocols-D2bTrQ_t.d.cts → protocols-Bz1rxcUg.d.cts} +1 -1
  59. package/dist/rest.cjs +41 -97
  60. package/dist/rest.d.cts +7 -7
  61. package/dist/rest.d.ts +7 -7
  62. package/dist/rest.js +2 -2
  63. package/dist/runtime.cjs +293 -464
  64. package/dist/runtime.d.cts +16 -28
  65. package/dist/runtime.d.ts +16 -28
  66. package/dist/runtime.js +12 -63
  67. package/dist/{schemas-CI0qgcp_.d.cts → schemas-BotL3ZLH.d.cts} +40 -54
  68. package/dist/{schemas-B1Fd3oUM.d.ts → schemas-DBsC4J1g.d.ts} +40 -54
  69. package/dist/{sdk-D2rTDU_o.d.cts → sdk-BTciSLRQ.d.cts} +5 -5
  70. package/dist/{sdk-CyqN1W5g.d.ts → sdk-qKJtMma_.d.ts} +5 -5
  71. package/dist/{simpleAdapter-qQt-tSz4.d.ts → simpleAdapter--wznuoOw.d.ts} +1 -1
  72. package/dist/{simpleAdapter-C_f-01Cu.d.cts → simpleAdapter-BpT4XbZC.d.cts} +1 -1
  73. package/dist/testing.d.cts +3 -3
  74. package/dist/testing.d.ts +3 -3
  75. package/dist/{types-DNySTI_8.d.ts → types-BTN_ZETM.d.ts} +2 -2
  76. package/dist/{types-D3AsUnd0.d.ts → types-BgYFd_Yw.d.cts} +5 -5
  77. package/dist/{types-DtMms5Fi.d.cts → types-BivGO7I9.d.ts} +5 -5
  78. package/dist/{types-CKqrhGB1.d.cts → types-D958TC71.d.cts} +2 -2
  79. package/package.json +6 -5
  80. package/dist/backends-DYtEhCZG.d.cts +0 -25
  81. package/dist/backends-oYAb7EU-.d.ts +0 -25
package/dist/mcp.cjs CHANGED
@@ -113,9 +113,9 @@ var init_memory = __esm({
113
113
  "active",
114
114
  // Normal, visible memories
115
115
  "superseded",
116
- // Outdated; soft-deleted via thenvoi_supersede_memory
116
+ // Outdated; soft-deleted via band_supersede_memory
117
117
  "archived",
118
- // Hidden but preserved via thenvoi_archive_memory
118
+ // Hidden but preserved via band_archive_memory
119
119
  "all"
120
120
  // Any status (no filter)
121
121
  ];
@@ -134,14 +134,14 @@ function getToolDescription(name) {
134
134
  const model = TOOL_MODELS[name];
135
135
  return model?.description ?? `Execute ${name}`;
136
136
  }
137
- var TOOL_MODELS, ALL_TOOL_NAMES, MEMORY_TOOL_NAMES, CONTACT_TOOL_NAMES, BASE_TOOL_NAMES, CHAT_TOOL_NAMES, MCP_TOOL_PREFIX;
137
+ var TOOL_MODELS, ALL_TOOL_NAMES, MEMORY_TOOL_NAMES, CONTACT_TOOL_NAMES, BASE_TOOL_NAMES, CHAT_TOOL_NAMES, MCP_TOOL_PREFIX, MCP_SERVER_NAME;
138
138
  var init_schemas = __esm({
139
139
  "src/runtime/tools/schemas.ts"() {
140
140
  "use strict";
141
141
  init_chatEvents();
142
142
  init_memory();
143
143
  TOOL_MODELS = {
144
- thenvoi_send_message: {
144
+ band_send_message: {
145
145
  description: "Send a message to the chat room. Use this to respond to users or other agents. Messages require at least one @mention in the mentions array. You MUST use this tool to communicate \u2014 plain text responses won't reach users. When delegating, send the full task context in this message instead of assuming hidden state.",
146
146
  properties: {
147
147
  content: {
@@ -157,7 +157,7 @@ var init_schemas = __esm({
157
157
  },
158
158
  required: ["content", "mentions"]
159
159
  },
160
- thenvoi_send_event: {
160
+ band_send_event: {
161
161
  description: "Send an event to the chat room. No mentions required. 'thought': Share your reasoning or plan BEFORE taking actions. Explain what you're about to do and why. 'error': Report an error or problem that occurred. 'task': Report task progress or completion status. Always send a thought before complex actions to keep users informed.",
162
162
  properties: {
163
163
  content: {
@@ -176,12 +176,12 @@ var init_schemas = __esm({
176
176
  },
177
177
  required: ["content", "message_type"]
178
178
  },
179
- thenvoi_add_participant: {
180
- description: "Add a participant (agent or user) to the chat room by name. IMPORTANT: Use thenvoi_lookup_peers() first to find available agents. Pass the exact peer name from thenvoi_lookup_peers, not the handle. For normal delegation, omit role or use 'member'.",
179
+ band_add_participant: {
180
+ description: "Add a participant (agent or user) to the chat room by name. IMPORTANT: Use band_lookup_peers() first to find available agents. Pass the exact peer name from band_lookup_peers, not the handle. For normal delegation, omit role or use 'member'.",
181
181
  properties: {
182
182
  name: {
183
183
  type: "string",
184
- description: "Name of participant to add (must match a name from thenvoi_lookup_peers)."
184
+ description: "Name of participant to add (must match a name from band_lookup_peers)."
185
185
  },
186
186
  role: {
187
187
  type: "string",
@@ -191,7 +191,7 @@ var init_schemas = __esm({
191
191
  },
192
192
  required: ["name"]
193
193
  },
194
- thenvoi_remove_participant: {
194
+ band_remove_participant: {
195
195
  description: "Remove a participant from the chat room by name.",
196
196
  properties: {
197
197
  name: {
@@ -201,12 +201,12 @@ var init_schemas = __esm({
201
201
  },
202
202
  required: ["name"]
203
203
  },
204
- thenvoi_get_participants: {
204
+ band_get_participants: {
205
205
  description: "Get a list of all participants in the current chat room.",
206
206
  properties: {},
207
207
  required: []
208
208
  },
209
- thenvoi_lookup_peers: {
209
+ band_lookup_peers: {
210
210
  description: "List available peers (agents and users) that can be added to this room. Automatically excludes peers already in the room. Returns dict with 'peers' list and 'metadata' (page, page_size, total_count, total_pages). Use this to find specialized agents (e.g., Weather Agent) when you cannot answer a question directly.",
211
211
  properties: {
212
212
  page: {
@@ -221,7 +221,7 @@ var init_schemas = __esm({
221
221
  },
222
222
  required: []
223
223
  },
224
- thenvoi_create_chatroom: {
224
+ band_create_chatroom: {
225
225
  description: "Create a new chat room for a specific task or conversation.",
226
226
  properties: {
227
227
  task_id: {
@@ -231,7 +231,7 @@ var init_schemas = __esm({
231
231
  },
232
232
  required: []
233
233
  },
234
- thenvoi_list_contacts: {
234
+ band_list_contacts: {
235
235
  description: "List agent's contacts with pagination.",
236
236
  properties: {
237
237
  page: {
@@ -248,7 +248,7 @@ var init_schemas = __esm({
248
248
  },
249
249
  required: []
250
250
  },
251
- thenvoi_add_contact: {
251
+ band_add_contact: {
252
252
  description: "Send a contact request to add someone as a contact. Returns 'pending' when request is created. Returns 'approved' when inverse request existed and was auto-accepted.",
253
253
  properties: {
254
254
  handle: {
@@ -262,7 +262,7 @@ var init_schemas = __esm({
262
262
  },
263
263
  required: ["handle"]
264
264
  },
265
- thenvoi_remove_contact: {
265
+ band_remove_contact: {
266
266
  description: "Remove an existing contact by handle or ID.",
267
267
  properties: {
268
268
  handle: {
@@ -276,7 +276,7 @@ var init_schemas = __esm({
276
276
  },
277
277
  required: []
278
278
  },
279
- thenvoi_list_contact_requests: {
279
+ band_list_contact_requests: {
280
280
  description: "List both received and sent contact requests. Received requests are always filtered to pending status. Sent requests can be filtered by status.",
281
281
  properties: {
282
282
  page: {
@@ -298,7 +298,7 @@ var init_schemas = __esm({
298
298
  },
299
299
  required: []
300
300
  },
301
- thenvoi_respond_contact_request: {
301
+ band_respond_contact_request: {
302
302
  description: "Respond to a contact request. 'approve'/'reject': For requests you RECEIVED (handle = requester's handle). 'cancel': For requests you SENT (handle = recipient's handle).",
303
303
  properties: {
304
304
  action: {
@@ -317,7 +317,7 @@ var init_schemas = __esm({
317
317
  },
318
318
  required: ["action"]
319
319
  },
320
- thenvoi_list_memories: {
320
+ band_list_memories: {
321
321
  description: "List memories accessible to the agent. Returns memories about the specified subject (cross-agent sharing) and organization-wide shared memories.",
322
322
  properties: {
323
323
  subject_id: {
@@ -362,7 +362,7 @@ var init_schemas = __esm({
362
362
  },
363
363
  required: []
364
364
  },
365
- thenvoi_store_memory: {
365
+ band_store_memory: {
366
366
  description: "Store a new memory entry. The memory will be associated with the authenticated agent as the source. For subject-scoped memories, provide a subject_id. For organization-scoped memories, omit subject_id.",
367
367
  properties: {
368
368
  content: {
@@ -404,7 +404,7 @@ var init_schemas = __esm({
404
404
  },
405
405
  required: ["content", "system", "type", "segment", "thought"]
406
406
  },
407
- thenvoi_get_memory: {
407
+ band_get_memory: {
408
408
  description: "Retrieve a specific memory by ID.",
409
409
  properties: {
410
410
  memory_id: {
@@ -414,7 +414,7 @@ var init_schemas = __esm({
414
414
  },
415
415
  required: ["memory_id"]
416
416
  },
417
- thenvoi_supersede_memory: {
417
+ band_supersede_memory: {
418
418
  description: "Mark a memory as superseded (soft delete). Use when information is outdated or incorrect. The memory remains for audit trail but won't appear in normal queries. Only the source agent can supersede.",
419
419
  properties: {
420
420
  memory_id: {
@@ -424,7 +424,7 @@ var init_schemas = __esm({
424
424
  },
425
425
  required: ["memory_id"]
426
426
  },
427
- thenvoi_archive_memory: {
427
+ band_archive_memory: {
428
428
  description: "Archive a memory (hide but preserve). Use when memory is valid but not currently needed. Archived memories can be restored later by humans. Only the source agent can archive.",
429
429
  properties: {
430
430
  memory_id: {
@@ -437,18 +437,18 @@ var init_schemas = __esm({
437
437
  };
438
438
  ALL_TOOL_NAMES = new Set(Object.keys(TOOL_MODELS));
439
439
  MEMORY_TOOL_NAMES = /* @__PURE__ */ new Set([
440
- "thenvoi_list_memories",
441
- "thenvoi_store_memory",
442
- "thenvoi_get_memory",
443
- "thenvoi_supersede_memory",
444
- "thenvoi_archive_memory"
440
+ "band_list_memories",
441
+ "band_store_memory",
442
+ "band_get_memory",
443
+ "band_supersede_memory",
444
+ "band_archive_memory"
445
445
  ]);
446
446
  CONTACT_TOOL_NAMES = /* @__PURE__ */ new Set([
447
- "thenvoi_list_contacts",
448
- "thenvoi_add_contact",
449
- "thenvoi_remove_contact",
450
- "thenvoi_list_contact_requests",
451
- "thenvoi_respond_contact_request"
447
+ "band_list_contacts",
448
+ "band_add_contact",
449
+ "band_remove_contact",
450
+ "band_list_contact_requests",
451
+ "band_respond_contact_request"
452
452
  ]);
453
453
  BASE_TOOL_NAMES = new Set(
454
454
  [...ALL_TOOL_NAMES].filter((name) => !MEMORY_TOOL_NAMES.has(name))
@@ -456,7 +456,8 @@ var init_schemas = __esm({
456
456
  CHAT_TOOL_NAMES = new Set(
457
457
  [...BASE_TOOL_NAMES].filter((name) => !CONTACT_TOOL_NAMES.has(name))
458
458
  );
459
- MCP_TOOL_PREFIX = "mcp__thenvoi__";
459
+ MCP_TOOL_PREFIX = "mcp__band__";
460
+ MCP_SERVER_NAME = "band";
460
461
  }
461
462
  });
462
463
 
@@ -669,9 +670,9 @@ var init_zod = __esm({
669
670
  // src/mcp/sdk.ts
670
671
  var sdk_exports = {};
671
672
  __export(sdk_exports, {
672
- createThenvoiSdkMcpServer: () => createThenvoiSdkMcpServer
673
+ createBandSdkMcpServer: () => createBandSdkMcpServer
673
674
  });
674
- function createThenvoiSdkMcpServer(options) {
675
+ function createBandSdkMcpServer(options) {
675
676
  const registrationOptions = {
676
677
  enableMemoryTools: options.enableMemoryTools,
677
678
  enableContactTools: true,
@@ -683,7 +684,7 @@ function createThenvoiSdkMcpServer(options) {
683
684
  const contextCache = /* @__PURE__ */ new Map();
684
685
  const MAX_CONTEXT_CACHE_ENTRIES = 100;
685
686
  const serverConfig = (0, import_claude_agent_sdk.createSdkMcpServer)({
686
- name: "thenvoi",
687
+ name: MCP_SERVER_NAME,
687
688
  tools: toolDefinitions
688
689
  });
689
690
  return {
@@ -916,14 +917,14 @@ var init_sdk = __esm({
916
917
  // src/mcp/index.ts
917
918
  var mcp_exports = {};
918
919
  __export(mcp_exports, {
919
- ThenvoiMcpServer: () => ThenvoiMcpServer,
920
- ThenvoiMcpSseServer: () => ThenvoiMcpSseServer,
921
- ThenvoiMcpStdioServer: () => ThenvoiMcpStdioServer,
920
+ BandMcpServer: () => BandMcpServer,
921
+ BandMcpSseServer: () => BandMcpSseServer,
922
+ BandMcpStdioServer: () => BandMcpStdioServer,
922
923
  buildRoomScopedRegistrations: () => buildRoomScopedRegistrations,
923
924
  buildSingleContextRegistrations: () => buildSingleContextRegistrations,
924
- createThenvoiMcpBackend: () => createThenvoiMcpBackend,
925
+ createBandMcpBackend: () => createBandMcpBackend,
925
926
  errorResult: () => errorResult,
926
- getThenvoiSdkMcpServerConfig: () => getThenvoiSdkMcpServerConfig,
927
+ getBandSdkMcpServerConfig: () => getBandSdkMcpServerConfig,
927
928
  successResult: () => successResult
928
929
  });
929
930
  module.exports = __toCommonJS(mcp_exports);
@@ -932,10 +933,31 @@ module.exports = __toCommonJS(mcp_exports);
932
933
  init_schemas();
933
934
  init_registrations();
934
935
 
936
+ // src/mcp/auth.ts
937
+ var import_node_crypto = require("crypto");
938
+ function generateAuthToken() {
939
+ return (0, import_node_crypto.randomBytes)(32).toString("hex");
940
+ }
941
+ function isAuthorizedRequest(authorizationHeader, authToken) {
942
+ if (!authToken) {
943
+ return true;
944
+ }
945
+ if (!authorizationHeader) {
946
+ return false;
947
+ }
948
+ const expected = Buffer.from(`Bearer ${authToken}`);
949
+ const actual = Buffer.from(authorizationHeader);
950
+ if (expected.length !== actual.length) {
951
+ return false;
952
+ }
953
+ return (0, import_node_crypto.timingSafeEqual)(expected, actual);
954
+ }
955
+
935
956
  // src/mcp/stdio.ts
936
957
  init_registrations();
937
958
  init_zod();
938
- var ThenvoiMcpStdioServer = class {
959
+ init_schemas();
960
+ var BandMcpStdioServer = class {
939
961
  options;
940
962
  registrations;
941
963
  mcpServer = null;
@@ -964,7 +986,7 @@ var ThenvoiMcpStdioServer = class {
964
986
  const { StdioServerTransport } = await import("@modelcontextprotocol/sdk/server/stdio.js");
965
987
  const { z: z2 } = await import("zod");
966
988
  const mcpServer = new McpServer({
967
- name: this.options.name ?? "thenvoi",
989
+ name: this.options.name ?? MCP_SERVER_NAME,
968
990
  version: "1.0.0"
969
991
  });
970
992
  registerTools(mcpServer, z2, this.registrations);
@@ -997,12 +1019,13 @@ function registerTools(mcpServer, z2, registrations) {
997
1019
  // src/mcp/server.ts
998
1020
  init_registrations();
999
1021
  init_zod();
1022
+ init_schemas();
1000
1023
  var PORT_RANGE_START = 5e4;
1001
1024
  var PORT_RANGE_END = 6e4;
1002
1025
  var MCP_SERVER_VERSION = "1.0.0";
1003
1026
  var SESSION_IDLE_TTL_MS = 15 * 60 * 1e3;
1004
1027
  var SESSION_SWEEP_INTERVAL_MS = 60 * 1e3;
1005
- var ThenvoiMcpServer = class {
1028
+ var BandMcpServer = class {
1006
1029
  options;
1007
1030
  registrations;
1008
1031
  httpServer = null;
@@ -1046,7 +1069,7 @@ var ThenvoiMcpServer = class {
1046
1069
  const http = await import("http");
1047
1070
  const { randomUUID } = await import("crypto");
1048
1071
  const { z: z2 } = await import("zod");
1049
- const serverName = this.options.name ?? "thenvoi";
1072
+ const serverName = this.options.name ?? MCP_SERVER_NAME;
1050
1073
  const app = express();
1051
1074
  app.use(express.json());
1052
1075
  app.get("/healthz", (_req, res) => {
@@ -1054,6 +1077,10 @@ var ThenvoiMcpServer = class {
1054
1077
  });
1055
1078
  const handleMcpRequest = async (req, res) => {
1056
1079
  try {
1080
+ if (!isAuthorizedRequest(req.headers.authorization, this.options.authToken)) {
1081
+ sendMcpError(res, 401, "Unauthorized");
1082
+ return;
1083
+ }
1057
1084
  const sessionId = getSessionIdHeader(req.headers["mcp-session-id"]);
1058
1085
  let session = sessionId ? this.sessions.get(sessionId) : void 0;
1059
1086
  if (!session) {
@@ -1229,11 +1256,12 @@ function checkPort(http, port) {
1229
1256
  // src/mcp/sse.ts
1230
1257
  init_registrations();
1231
1258
  init_zod();
1259
+ init_schemas();
1232
1260
  var PORT_RANGE_START2 = 5e4;
1233
1261
  var PORT_RANGE_END2 = 6e4;
1234
1262
  var SESSION_IDLE_TTL_MS2 = 15 * 60 * 1e3;
1235
1263
  var SESSION_SWEEP_INTERVAL_MS2 = 60 * 1e3;
1236
- var ThenvoiMcpSseServer = class {
1264
+ var BandMcpSseServer = class {
1237
1265
  options;
1238
1266
  registrations;
1239
1267
  httpServer = null;
@@ -1280,10 +1308,14 @@ var ThenvoiMcpSseServer = class {
1280
1308
  app.get("/healthz", (_req, res) => {
1281
1309
  res.json({ status: "ok" });
1282
1310
  });
1283
- app.get("/sse", async (_req, res) => {
1311
+ app.get("/sse", async (req, res) => {
1312
+ if (!isAuthorizedRequest(req.headers.authorization, this.options.authToken)) {
1313
+ res.status(401).send("Unauthorized");
1314
+ return;
1315
+ }
1284
1316
  const transport = new SSEServerTransport("/messages", res);
1285
1317
  const mcpServer = new McpServer({
1286
- name: this.options.name ?? "thenvoi",
1318
+ name: this.options.name ?? MCP_SERVER_NAME,
1287
1319
  version: "1.0.0"
1288
1320
  });
1289
1321
  registerTools3(mcpServer, z2, this.registrations);
@@ -1305,6 +1337,10 @@ var ThenvoiMcpSseServer = class {
1305
1337
  });
1306
1338
  });
1307
1339
  app.post("/messages", async (req, res) => {
1340
+ if (!isAuthorizedRequest(req.headers.authorization, this.options.authToken)) {
1341
+ res.status(401).send("Unauthorized");
1342
+ return;
1343
+ }
1308
1344
  const sessionId = typeof req.query.sessionId === "string" ? req.query.sessionId : null;
1309
1345
  if (!sessionId) {
1310
1346
  res.status(400).send("Missing sessionId");
@@ -1418,15 +1454,15 @@ function checkPort2(http, port) {
1418
1454
  }
1419
1455
 
1420
1456
  // src/mcp/backends.ts
1421
- async function createThenvoiMcpBackend(options) {
1457
+ async function createBandMcpBackend(options) {
1422
1458
  const registrationOptions = {
1423
1459
  enableMemoryTools: options.enableMemoryTools,
1424
1460
  enableContactTools: true,
1425
1461
  additionalTools: options.additionalTools
1426
1462
  };
1427
1463
  if (options.kind === "sdk") {
1428
- const { createThenvoiSdkMcpServer: createThenvoiSdkMcpServer2 } = await Promise.resolve().then(() => (init_sdk(), sdk_exports));
1429
- const server2 = createThenvoiSdkMcpServer2({
1464
+ const { createBandSdkMcpServer: createBandSdkMcpServer2 } = await Promise.resolve().then(() => (init_sdk(), sdk_exports));
1465
+ const server2 = createBandSdkMcpServer2({
1430
1466
  getToolsForRoom: options.getToolsForRoom,
1431
1467
  multiRoom: options.multiRoom,
1432
1468
  enableMemoryTools: options.enableMemoryTools,
@@ -1443,7 +1479,7 @@ async function createThenvoiMcpBackend(options) {
1443
1479
  const registrations = options.multiRoom === false ? buildSingleContextRegistrations(resolvedTools, registrationOptions) : buildRoomScopedRegistrations(resolvedTools, registrationOptions);
1444
1480
  const allowedTools = mcpToolNames(new Set(registrations.map((registration) => registration.name)));
1445
1481
  if (options.kind === "stdio") {
1446
- const server2 = new ThenvoiMcpStdioServer({
1482
+ const server2 = new BandMcpStdioServer({
1447
1483
  tools: resolvedTools,
1448
1484
  enableMemoryTools: options.enableMemoryTools,
1449
1485
  enableContactTools: true,
@@ -1459,40 +1495,45 @@ async function createThenvoiMcpBackend(options) {
1459
1495
  }
1460
1496
  };
1461
1497
  }
1498
+ const authToken = generateAuthToken();
1462
1499
  if (options.kind === "sse") {
1463
- const server2 = new ThenvoiMcpSseServer({
1500
+ const server2 = new BandMcpSseServer({
1464
1501
  tools: resolvedTools,
1465
1502
  enableMemoryTools: options.enableMemoryTools,
1466
1503
  enableContactTools: true,
1467
- additionalTools: options.additionalTools
1504
+ additionalTools: options.additionalTools,
1505
+ authToken
1468
1506
  });
1469
1507
  await server2.start();
1470
1508
  return {
1471
1509
  kind: "sse",
1472
1510
  server: server2,
1473
1511
  allowedTools,
1512
+ authToken,
1474
1513
  stop: async () => {
1475
1514
  await server2.stop();
1476
1515
  }
1477
1516
  };
1478
1517
  }
1479
- const server = new ThenvoiMcpServer({
1518
+ const server = new BandMcpServer({
1480
1519
  tools: resolvedTools,
1481
1520
  enableMemoryTools: options.enableMemoryTools,
1482
1521
  enableContactTools: true,
1483
- additionalTools: options.additionalTools
1522
+ additionalTools: options.additionalTools,
1523
+ authToken
1484
1524
  });
1485
1525
  await server.start();
1486
1526
  return {
1487
1527
  kind: "http",
1488
1528
  server,
1489
1529
  allowedTools,
1530
+ authToken,
1490
1531
  stop: async () => {
1491
1532
  await server.stop();
1492
1533
  }
1493
1534
  };
1494
1535
  }
1495
- function getThenvoiSdkMcpServerConfig(backend) {
1536
+ function getBandSdkMcpServerConfig(backend) {
1496
1537
  if (backend.kind !== "sdk") {
1497
1538
  throw new Error(`Expected sdk MCP backend, received ${backend.kind}`);
1498
1539
  }
@@ -1503,13 +1544,13 @@ function getThenvoiSdkMcpServerConfig(backend) {
1503
1544
  init_registrations();
1504
1545
  // Annotate the CommonJS export names for ESM import in node:
1505
1546
  0 && (module.exports = {
1506
- ThenvoiMcpServer,
1507
- ThenvoiMcpSseServer,
1508
- ThenvoiMcpStdioServer,
1547
+ BandMcpServer,
1548
+ BandMcpSseServer,
1549
+ BandMcpStdioServer,
1509
1550
  buildRoomScopedRegistrations,
1510
1551
  buildSingleContextRegistrations,
1511
- createThenvoiMcpBackend,
1552
+ createBandMcpBackend,
1512
1553
  errorResult,
1513
- getThenvoiSdkMcpServerConfig,
1554
+ getBandSdkMcpServerConfig,
1514
1555
  successResult
1515
1556
  });
package/dist/mcp.d.cts CHANGED
@@ -1,12 +1,12 @@
1
- export { C as CreateThenvoiMcpBackendOptions, T as ThenvoiMcpBackend, a as ThenvoiMcpBackendKind, c as createThenvoiMcpBackend, g as getThenvoiSdkMcpServerConfig } from './backends-DYtEhCZG.cjs';
2
- import { M as McpToolRegistration } from './sdk-D2rTDU_o.cjs';
3
- export { B as BuildRegistrationsOptions, a as McpToolInputSchema, b as McpToolResult, c as buildRoomScopedRegistrations, d as buildSingleContextRegistrations, e as errorResult, s as successResult } from './sdk-D2rTDU_o.cjs';
4
- import { A as AdapterToolsProtocol } from './protocols-D2bTrQ_t.cjs';
1
+ export { B as BandMcpBackend, a as BandMcpBackendKind, C as CreateBandMcpBackendOptions, c as createBandMcpBackend, g as getBandSdkMcpServerConfig } from './backends-ZLxmQrTZ.cjs';
2
+ import { M as McpToolRegistration } from './sdk-BTciSLRQ.cjs';
3
+ export { a as BuildRegistrationsOptions, b as McpToolInputSchema, c as McpToolResult, d as buildRoomScopedRegistrations, e as buildSingleContextRegistrations, f as errorResult, s as successResult } from './sdk-BTciSLRQ.cjs';
4
+ import { A as AdapterToolsProtocol } from './protocols-Bz1rxcUg.cjs';
5
5
  import { Readable, Writable } from 'node:stream';
6
6
  import '@anthropic-ai/claude-agent-sdk';
7
- import './dtos-Dd_fTfLn.cjs';
7
+ import './dtos-B8KU_q4d.cjs';
8
8
 
9
- interface ThenvoiMcpServerOptions {
9
+ interface BandMcpServerOptions {
10
10
  /** Single tools instance (no room scoping) or a resolver function for room-scoped tools. */
11
11
  tools: AdapterToolsProtocol | ((roomId: string) => AdapterToolsProtocol | undefined);
12
12
  /** Server name advertised to MCP clients. */
@@ -19,21 +19,27 @@ interface ThenvoiMcpServerOptions {
19
19
  enableContactTools?: boolean;
20
20
  /** Additional MCP tool registrations to expose alongside the built-in tools. */
21
21
  additionalTools?: McpToolRegistration[];
22
+ /**
23
+ * When set, every `/mcp` request must carry `Authorization: Bearer <authToken>`
24
+ * or is rejected with a 401. Unset (the default) leaves the server open, matching
25
+ * prior behavior for callers that don't opt in.
26
+ */
27
+ authToken?: string;
22
28
  }
23
29
  /**
24
- * Standalone MCP server that exposes Thenvoi agent tools over Streamable HTTP.
30
+ * Standalone MCP server that exposes Band agent tools over Streamable HTTP.
25
31
  *
26
32
  * Uses `@modelcontextprotocol/server` (optional peer dependency) and `express`.
27
33
  * Install with: `npm install @modelcontextprotocol/server express`
28
34
  */
29
- declare class ThenvoiMcpServer {
35
+ declare class BandMcpServer {
30
36
  private readonly options;
31
37
  private readonly registrations;
32
38
  private httpServer;
33
39
  private actualPort;
34
40
  private readonly sessions;
35
41
  private sessionSweepTimer;
36
- constructor(options: ThenvoiMcpServerOptions);
42
+ constructor(options: BandMcpServerOptions);
37
43
  /** Port the server is listening on. Null if not started. */
38
44
  get port(): number | null;
39
45
  /** MCP endpoint URL. Null if not started. */
@@ -48,22 +54,29 @@ declare class ThenvoiMcpServer {
48
54
  private closeIdleSessions;
49
55
  }
50
56
 
51
- interface ThenvoiMcpSseServerOptions {
57
+ interface BandMcpSseServerOptions {
52
58
  tools: AdapterToolsProtocol | ((roomId: string) => AdapterToolsProtocol | undefined);
53
59
  name?: string;
54
60
  port?: number;
55
61
  enableMemoryTools?: boolean;
56
62
  enableContactTools?: boolean;
57
63
  additionalTools?: McpToolRegistration[];
64
+ /**
65
+ * When set, every `/sse` and `/messages` request must carry
66
+ * `Authorization: Bearer <authToken>` or is rejected with a 401. Unset (the
67
+ * default) leaves the server open, matching prior behavior for callers that
68
+ * don't opt in.
69
+ */
70
+ authToken?: string;
58
71
  }
59
- declare class ThenvoiMcpSseServer {
72
+ declare class BandMcpSseServer {
60
73
  private readonly options;
61
74
  private readonly registrations;
62
75
  private httpServer;
63
76
  private actualPort;
64
77
  private readonly sessions;
65
78
  private sweepTimer;
66
- constructor(options: ThenvoiMcpSseServerOptions);
79
+ constructor(options: BandMcpSseServerOptions);
67
80
  get port(): number | null;
68
81
  get sseUrl(): string | null;
69
82
  get toolNames(): string[];
@@ -74,7 +87,7 @@ declare class ThenvoiMcpSseServer {
74
87
  private closeIdleSessions;
75
88
  }
76
89
 
77
- interface ThenvoiMcpStdioServerOptions {
90
+ interface BandMcpStdioServerOptions {
78
91
  tools: AdapterToolsProtocol | ((roomId: string) => AdapterToolsProtocol | undefined);
79
92
  name?: string;
80
93
  enableMemoryTools?: boolean;
@@ -83,15 +96,15 @@ interface ThenvoiMcpStdioServerOptions {
83
96
  stdin?: Readable;
84
97
  stdout?: Writable;
85
98
  }
86
- declare class ThenvoiMcpStdioServer {
99
+ declare class BandMcpStdioServer {
87
100
  private readonly options;
88
101
  private readonly registrations;
89
102
  private mcpServer;
90
103
  private transport;
91
- constructor(options: ThenvoiMcpStdioServerOptions);
104
+ constructor(options: BandMcpStdioServerOptions);
92
105
  get toolNames(): string[];
93
106
  start(): Promise<void>;
94
107
  stop(): Promise<void>;
95
108
  }
96
109
 
97
- export { McpToolRegistration, ThenvoiMcpServer, type ThenvoiMcpServerOptions, ThenvoiMcpSseServer, type ThenvoiMcpSseServerOptions, ThenvoiMcpStdioServer, type ThenvoiMcpStdioServerOptions };
110
+ export { BandMcpServer, type BandMcpServerOptions, BandMcpSseServer, type BandMcpSseServerOptions, BandMcpStdioServer, type BandMcpStdioServerOptions, McpToolRegistration };