@band-ai/sdk 0.1.4 → 0.1.10

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 (73) hide show
  1. package/README.md +372 -0
  2. package/dist/{ClaudeSDKAdapter-CRq4R-WB.d.cts → ClaudeSDKAdapter-DfjaI5ke.d.cts} +9 -7
  3. package/dist/{ClaudeSDKAdapter-BHOkjN3X.d.ts → ClaudeSDKAdapter-DonPGJ43.d.ts} +9 -7
  4. package/dist/{acp-server-BdRz9_UN.d.cts → acp-server-CUBXIiG6.d.cts} +2 -2
  5. package/dist/{acp-server-B1Da7L6u.d.ts → acp-server-NZAeg-WO.d.ts} +2 -2
  6. package/dist/adapters.cjs +494 -106
  7. package/dist/adapters.d.cts +12 -12
  8. package/dist/adapters.d.ts +12 -12
  9. package/dist/adapters.js +7 -7
  10. package/dist/{backends-SVMT-7l4.d.cts → backends-DYtEhCZG.d.cts} +7 -2
  11. package/dist/{backends-CzDbiQar.d.ts → backends-oYAb7EU-.d.ts} +7 -2
  12. package/dist/{chunk-MSL6CWHY.js → chunk-2BHHR6YW.js} +17 -16
  13. package/dist/{chunk-EDPKUUJL.js → chunk-6RXWL6TC.js} +9 -1
  14. package/dist/{chunk-SFVKOEQH.js → chunk-DNPVCR3S.js} +92 -14
  15. package/dist/{chunk-I5EZG52P.js → chunk-FP237EAG.js} +424 -136
  16. package/dist/{chunk-RHVH2GZR.js → chunk-J3M3PFFY.js} +81 -31
  17. package/dist/{chunk-GVEQ3RAH.js → chunk-MLROFDKR.js} +132 -23
  18. package/dist/{chunk-INA6YZTZ.js → chunk-RDM4TE4B.js} +32 -30
  19. package/dist/chunk-US226AS4.js +130 -0
  20. package/dist/{chunk-W5NDZSYE.js → chunk-XA4N2JPH.js} +1 -1
  21. package/dist/converters.cjs +469 -13
  22. package/dist/converters.d.cts +5 -5
  23. package/dist/converters.d.ts +5 -5
  24. package/dist/converters.js +3 -2
  25. package/dist/core.cjs +45 -2
  26. package/dist/core.d.cts +4 -3
  27. package/dist/core.d.ts +4 -3
  28. package/dist/core.js +5 -1
  29. package/dist/disconnectReason-IuADl6TH.d.cts +34 -0
  30. package/dist/disconnectReason-IuADl6TH.d.ts +34 -0
  31. package/dist/{dtos-DUpbIu8k.d.cts → dtos-Dd_fTfLn.d.cts} +26 -6
  32. package/dist/{dtos-DUpbIu8k.d.ts → dtos-Dd_fTfLn.d.ts} +26 -6
  33. package/dist/index.cjs +1089 -269
  34. package/dist/index.d.cts +16 -15
  35. package/dist/index.d.ts +16 -15
  36. package/dist/index.js +14 -8
  37. package/dist/linear.cjs +985 -53
  38. package/dist/linear.d.cts +137 -7
  39. package/dist/linear.d.ts +137 -7
  40. package/dist/linear.js +974 -53
  41. package/dist/mcp-claude.cjs +303 -32
  42. package/dist/mcp-claude.d.cts +3 -3
  43. package/dist/mcp-claude.d.ts +3 -3
  44. package/dist/mcp-claude.js +210 -12
  45. package/dist/mcp.cjs +313 -45
  46. package/dist/mcp.d.cts +5 -5
  47. package/dist/mcp.d.ts +5 -5
  48. package/dist/mcp.js +3 -3
  49. package/dist/{opencode-BBcDchcN.d.cts → opencode--iA5-KYk.d.cts} +2 -2
  50. package/dist/{opencode-DthQQUsZ.d.ts → opencode-YNacv-eJ.d.ts} +2 -2
  51. package/dist/{pagination-CcDkVFxK.d.ts → pagination-BBLsYLhT.d.ts} +2 -2
  52. package/dist/{pagination-BPiys10t.d.cts → pagination-CqidD-L_.d.cts} +2 -2
  53. package/dist/{protocols-DrhzOH6K.d.ts → protocols-BF6jamIl.d.ts} +1 -1
  54. package/dist/{protocols-CInhtFpA.d.cts → protocols-D2bTrQ_t.d.cts} +1 -1
  55. package/dist/rest.d.cts +5 -5
  56. package/dist/rest.d.ts +5 -5
  57. package/dist/runtime.cjs +721 -172
  58. package/dist/runtime.d.cts +15 -10
  59. package/dist/runtime.d.ts +15 -10
  60. package/dist/runtime.js +11 -8
  61. package/dist/{schemas-vos1AaBc.d.ts → schemas-B1Fd3oUM.d.ts} +17 -8
  62. package/dist/{schemas-BpEBkq5V.d.cts → schemas-CI0qgcp_.d.cts} +17 -8
  63. package/dist/{sdk-CcnQ5OUC.d.ts → sdk-CyqN1W5g.d.ts} +32 -2
  64. package/dist/{sdk-CwTAxhwI.d.cts → sdk-D2rTDU_o.d.cts} +32 -2
  65. package/dist/{simpleAdapter-DqhvjsGr.d.cts → simpleAdapter-C_f-01Cu.d.cts} +1 -1
  66. package/dist/{simpleAdapter-9OE_p6QW.d.ts → simpleAdapter-qQt-tSz4.d.ts} +1 -1
  67. package/dist/testing.d.cts +3 -3
  68. package/dist/testing.d.ts +3 -3
  69. package/dist/{types-CovcHpYf.d.cts → types-CKqrhGB1.d.cts} +2 -2
  70. package/dist/{types-CxII3XkA.d.ts → types-D3AsUnd0.d.ts} +1 -1
  71. package/dist/{types-7jVzOeOP.d.ts → types-DNySTI_8.d.ts} +2 -2
  72. package/dist/{types-CSHFipIc.d.cts → types-DtMms5Fi.d.cts} +1 -1
  73. package/package.json +22 -21
package/dist/mcp.cjs CHANGED
@@ -48,6 +48,84 @@ var init_chatEvents = __esm({
48
48
  }
49
49
  });
50
50
 
51
+ // src/contracts/memory.ts
52
+ function namedValues(values) {
53
+ return Object.fromEntries(values.map((value) => [value, value]));
54
+ }
55
+ var SENSORY_MEMORY_TYPES, COGNITIVE_MEMORY_TYPES, MEMORY_SYSTEM_TYPES, MEMORY_SYSTEMS, MEMORY_TYPES, MEMORY_SEGMENTS, MEMORY_STORE_SCOPES, MEMORY_LIST_SCOPES, MEMORY_STATUSES, MEMORY_SYSTEM, MEMORY_TYPE, MEMORY_SEGMENT, MEMORY_STORE_SCOPE;
56
+ var init_memory = __esm({
57
+ "src/contracts/memory.ts"() {
58
+ "use strict";
59
+ SENSORY_MEMORY_TYPES = [
60
+ "iconic",
61
+ // Visual input
62
+ "echoic",
63
+ // Auditory input
64
+ "haptic"
65
+ // Tactile input
66
+ ];
67
+ COGNITIVE_MEMORY_TYPES = [
68
+ "episodic",
69
+ // Events that occurred
70
+ "semantic",
71
+ // Facts, preferences, learned knowledge
72
+ "procedural"
73
+ // How to perform tasks
74
+ ];
75
+ MEMORY_SYSTEM_TYPES = {
76
+ sensory: SENSORY_MEMORY_TYPES,
77
+ // Brief sensory inputs
78
+ working: COGNITIVE_MEMORY_TYPES,
79
+ // Short-term session context
80
+ long_term: COGNITIVE_MEMORY_TYPES
81
+ // Persistent cross-conversation memory
82
+ };
83
+ MEMORY_SYSTEMS = Object.keys(MEMORY_SYSTEM_TYPES);
84
+ MEMORY_TYPES = [
85
+ ...SENSORY_MEMORY_TYPES,
86
+ ...COGNITIVE_MEMORY_TYPES
87
+ ];
88
+ MEMORY_SEGMENTS = [
89
+ "user",
90
+ // User preferences or profile info
91
+ "agent",
92
+ // Facts or events about agents/entities
93
+ "tool",
94
+ // Tool usage or task procedures
95
+ "guideline"
96
+ // Behavioral rules or policies
97
+ ];
98
+ MEMORY_STORE_SCOPES = [
99
+ "subject",
100
+ // About one person/agent; requires subject_id
101
+ "organization"
102
+ // Shared org-wide
103
+ ];
104
+ MEMORY_LIST_SCOPES = [
105
+ "subject",
106
+ // Subject-scoped memories only
107
+ "organization",
108
+ // Organization-scoped memories only
109
+ "all"
110
+ // Both scopes (no scope filter)
111
+ ];
112
+ MEMORY_STATUSES = [
113
+ "active",
114
+ // Normal, visible memories
115
+ "superseded",
116
+ // Outdated; soft-deleted via thenvoi_supersede_memory
117
+ "archived",
118
+ // Hidden but preserved via thenvoi_archive_memory
119
+ "all"
120
+ // Any status (no filter)
121
+ ];
122
+ MEMORY_SYSTEM = namedValues(MEMORY_SYSTEMS);
123
+ MEMORY_TYPE = namedValues(MEMORY_TYPES);
124
+ MEMORY_SEGMENT = namedValues(MEMORY_SEGMENTS);
125
+ MEMORY_STORE_SCOPE = namedValues(MEMORY_STORE_SCOPES);
126
+ }
127
+ });
128
+
51
129
  // src/runtime/tools/schemas.ts
52
130
  function mcpToolNames(names) {
53
131
  return [...names].sort((a, b) => a.localeCompare(b)).map((name) => `${MCP_TOOL_PREFIX}${name}`);
@@ -61,6 +139,7 @@ var init_schemas = __esm({
61
139
  "src/runtime/tools/schemas.ts"() {
62
140
  "use strict";
63
141
  init_chatEvents();
142
+ init_memory();
64
143
  TOOL_MODELS = {
65
144
  thenvoi_send_message: {
66
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.",
@@ -247,29 +326,22 @@ var init_schemas = __esm({
247
326
  },
248
327
  scope: {
249
328
  type: "string",
250
- enum: ["subject", "organization", "all"],
329
+ enum: [...MEMORY_LIST_SCOPES],
251
330
  description: "Filter by scope."
252
331
  },
253
332
  system: {
254
333
  type: "string",
255
- enum: ["sensory", "working", "long_term"],
334
+ enum: [...MEMORY_SYSTEMS],
256
335
  description: "Filter by memory system."
257
336
  },
258
337
  type: {
259
338
  type: "string",
260
- enum: [
261
- "iconic",
262
- "echoic",
263
- "haptic",
264
- "episodic",
265
- "semantic",
266
- "procedural"
267
- ],
339
+ enum: [...MEMORY_TYPES],
268
340
  description: "Filter by memory type."
269
341
  },
270
342
  segment: {
271
343
  type: "string",
272
- enum: ["user", "agent", "tool", "guideline"],
344
+ enum: [...MEMORY_SEGMENTS],
273
345
  description: "Filter by segment."
274
346
  },
275
347
  content_query: {
@@ -284,7 +356,7 @@ var init_schemas = __esm({
284
356
  },
285
357
  status: {
286
358
  type: "string",
287
- enum: ["active", "superseded", "archived", "all"],
359
+ enum: [...MEMORY_STATUSES],
288
360
  description: "Filter by status."
289
361
  }
290
362
  },
@@ -299,24 +371,17 @@ var init_schemas = __esm({
299
371
  },
300
372
  system: {
301
373
  type: "string",
302
- enum: ["sensory", "working", "long_term"],
374
+ enum: [...MEMORY_SYSTEMS],
303
375
  description: "Memory system tier."
304
376
  },
305
377
  type: {
306
378
  type: "string",
307
- enum: [
308
- "iconic",
309
- "echoic",
310
- "haptic",
311
- "episodic",
312
- "semantic",
313
- "procedural"
314
- ],
379
+ enum: [...MEMORY_TYPES],
315
380
  description: "Memory type (must be valid for selected system)."
316
381
  },
317
382
  segment: {
318
383
  type: "string",
319
- enum: ["user", "agent", "tool", "guideline"],
384
+ enum: [...MEMORY_SEGMENTS],
320
385
  description: "Logical segment."
321
386
  },
322
387
  thought: {
@@ -325,7 +390,7 @@ var init_schemas = __esm({
325
390
  },
326
391
  scope: {
327
392
  type: "string",
328
- enum: ["subject", "organization"],
393
+ enum: [...MEMORY_STORE_SCOPES],
329
394
  description: "Visibility scope."
330
395
  },
331
396
  subject_id: {
@@ -542,6 +607,13 @@ function serializeValue(value) {
542
607
  return String(value);
543
608
  }
544
609
  }
610
+ function resolveSingleRoomTools(getToolsForRoom) {
611
+ const tools = getToolsForRoom("");
612
+ if (!tools) {
613
+ throw new Error('Single-room mode requires getToolsForRoom("") to return a tools instance');
614
+ }
615
+ return tools;
616
+ }
545
617
  var init_registrations = __esm({
546
618
  "src/mcp/registrations.ts"() {
547
619
  "use strict";
@@ -600,16 +672,16 @@ __export(sdk_exports, {
600
672
  createThenvoiSdkMcpServer: () => createThenvoiSdkMcpServer
601
673
  });
602
674
  function createThenvoiSdkMcpServer(options) {
603
- const registrations = buildRoomScopedRegistrations(
604
- options.getToolsForRoom,
605
- {
606
- enableMemoryTools: options.enableMemoryTools,
607
- enableContactTools: true,
608
- additionalTools: options.additionalTools
609
- }
610
- );
675
+ const registrationOptions = {
676
+ enableMemoryTools: options.enableMemoryTools,
677
+ enableContactTools: true,
678
+ additionalTools: options.additionalTools
679
+ };
680
+ const registrations = options.multiRoom === false ? buildSingleContextRegistrations(resolveSingleRoomTools(options.getToolsForRoom), registrationOptions) : buildRoomScopedRegistrations(options.getToolsForRoom, registrationOptions);
611
681
  const toolDefinitions = registrations.map(toSdkToolDefinition);
612
682
  const toolNames = new Set(registrations.map((r) => r.name));
683
+ const contextCache = /* @__PURE__ */ new Map();
684
+ const MAX_CONTEXT_CACHE_ENTRIES = 100;
613
685
  const serverConfig = (0, import_claude_agent_sdk.createSdkMcpServer)({
614
686
  name: "thenvoi",
615
687
  tools: toolDefinitions
@@ -617,9 +689,205 @@ function createThenvoiSdkMcpServer(options) {
617
689
  return {
618
690
  serverConfig,
619
691
  allowedTools: mcpToolNames(toolNames),
620
- toolDefinitions
692
+ toolDefinitions,
693
+ getSystemPromptContext: async (roomId, contextOptions) => {
694
+ const context = await getOrBuildSystemPromptContext(
695
+ roomId,
696
+ contextOptions,
697
+ options.getToolsForRoom,
698
+ contextCache,
699
+ MAX_CONTEXT_CACHE_ENTRIES
700
+ );
701
+ return context.markdown;
702
+ },
703
+ getSystemPromptContextData: (roomId, contextOptions) => {
704
+ return getOrBuildSystemPromptContext(
705
+ roomId,
706
+ contextOptions,
707
+ options.getToolsForRoom,
708
+ contextCache,
709
+ MAX_CONTEXT_CACHE_ENTRIES
710
+ );
711
+ }
712
+ };
713
+ }
714
+ async function getOrBuildSystemPromptContext(roomId, contextOptions, getToolsForRoom, contextCache, maxEntries) {
715
+ const ttlMs = contextOptions?.ttlMs ?? 3e4;
716
+ const now = Date.now();
717
+ const cached = contextCache.get(roomId);
718
+ if (cached && cached.expiresAt > now) {
719
+ cached.lastAccessedAt = now;
720
+ return cached.value;
721
+ }
722
+ if (cached) {
723
+ contextCache.delete(roomId);
724
+ }
725
+ const tools = getToolsForRoom(roomId);
726
+ if (!tools) {
727
+ return buildUnavailableSystemPromptContext(roomId);
728
+ }
729
+ const context = await buildSystemPromptContext(roomId, tools);
730
+ contextCache.set(roomId, {
731
+ value: context,
732
+ expiresAt: now + ttlMs,
733
+ lastAccessedAt: now
734
+ });
735
+ evictLeastRecentlyUsedContext(contextCache, maxEntries);
736
+ return context;
737
+ }
738
+ async function buildSystemPromptContext(roomId, tools) {
739
+ const participants = await tools.getParticipants();
740
+ const warnings = [];
741
+ const agentResolution = await resolveAgentIdentity(tools);
742
+ if (agentResolution.warning) {
743
+ warnings.push(agentResolution.warning);
744
+ }
745
+ const roomResolution = await resolveRoomTitle(tools, roomId);
746
+ if (roomResolution.warning) {
747
+ warnings.push(roomResolution.warning);
748
+ }
749
+ const agentIdentity = agentResolution.value;
750
+ const roomTitle = roomResolution.value;
751
+ const normalizedParticipants = participants.map((participant) => ({
752
+ id: String(participant.id),
753
+ name: String(participant.name ?? "Unknown"),
754
+ type: String(participant.type ?? "Unknown"),
755
+ handle: normalizeHandle(participant.handle),
756
+ isSelf: participant.id === agentIdentity?.id
757
+ }));
758
+ const selfHandle = normalizeHandle(agentIdentity?.handle);
759
+ const selfName = agentIdentity?.name ?? "Agent";
760
+ const mentionHandles = normalizedParticipants.filter((participant) => !participant.isSelf).map((participant) => participant.handle).filter((handle) => Boolean(handle));
761
+ const mentionFormat = mentionHandles.length > 0 ? mentionHandles.join(", ") : "No participant handles available";
762
+ const roomLabel = roomTitle ? `"${roomTitle}"` : "this room";
763
+ const agentLabel = selfHandle ? `${selfName} (${selfHandle})` : selfName;
764
+ const participantLines = normalizedParticipants.length > 0 ? normalizedParticipants.map((participant) => {
765
+ const suffix = participant.isSelf ? " (you)" : "";
766
+ const handle = participant.handle ? ` (${participant.handle})` : "";
767
+ return `- **${participant.name}**${handle} -- ${participant.type}${suffix}`;
768
+ }).join("\n") : "- No participants found";
769
+ const markdown = [
770
+ "## Room Context",
771
+ "",
772
+ `You are **${agentLabel}** in room ${roomLabel} (id: ${roomId}).`,
773
+ "",
774
+ "### Participants",
775
+ participantLines,
776
+ "",
777
+ "### Mention Format",
778
+ `To address someone, use their exact handle: ${mentionFormat}`,
779
+ ...warnings.length > 0 ? ["", "### Warnings", ...warnings.map((warning) => `- ${warning}`)] : []
780
+ ].join("\n");
781
+ return {
782
+ roomId,
783
+ roomTitle,
784
+ agent: {
785
+ id: agentIdentity?.id ?? "unknown-agent",
786
+ name: selfName,
787
+ handle: selfHandle,
788
+ description: agentIdentity?.description ?? null
789
+ },
790
+ participants: normalizedParticipants,
791
+ mentionFormat,
792
+ warnings,
793
+ markdown
794
+ };
795
+ }
796
+ async function resolveAgentIdentity(tools) {
797
+ const maybeTools = tools;
798
+ try {
799
+ if (maybeTools.getAgentIdentity) {
800
+ return { value: await maybeTools.getAgentIdentity(), warning: null };
801
+ }
802
+ if (maybeTools.rest?.getAgentMe) {
803
+ return { value: await maybeTools.rest.getAgentMe(), warning: null };
804
+ }
805
+ } catch (error) {
806
+ return {
807
+ value: null,
808
+ warning: `Unable to resolve agent identity: ${error instanceof Error ? error.message : String(error)}`
809
+ };
810
+ }
811
+ return { value: null, warning: null };
812
+ }
813
+ async function resolveRoomTitle(tools, roomId) {
814
+ const maybeTools = tools;
815
+ const rest = maybeTools.rest;
816
+ if (!rest?.listChats) {
817
+ return { value: null, warning: null };
818
+ }
819
+ try {
820
+ let page = 1;
821
+ const pageSize = 100;
822
+ while (true) {
823
+ const response = await rest.listChats({ page, pageSize });
824
+ const room = response?.data?.find((entry) => entry.id === roomId);
825
+ if (typeof room?.title === "string" && room.title.length > 0) {
826
+ return { value: room.title, warning: null };
827
+ }
828
+ const totalPages = response?.metadata?.totalPages ?? page;
829
+ if (page >= totalPages) {
830
+ return { value: null, warning: null };
831
+ }
832
+ page += 1;
833
+ }
834
+ } catch (error) {
835
+ return {
836
+ value: null,
837
+ warning: `Unable to resolve room title: ${error instanceof Error ? error.message : String(error)}`
838
+ };
839
+ }
840
+ }
841
+ function buildUnavailableSystemPromptContext(roomId) {
842
+ const warnings = [`No tool context found for room_id ${roomId}`];
843
+ const markdown = [
844
+ "## Room Context",
845
+ "",
846
+ `You are **Agent** in this room (id: ${roomId}).`,
847
+ "",
848
+ "### Participants",
849
+ "- No participants found",
850
+ "",
851
+ "### Mention Format",
852
+ "No participant handles available",
853
+ "",
854
+ "### Warnings",
855
+ ...warnings.map((warning) => `- ${warning}`)
856
+ ].join("\n");
857
+ return {
858
+ roomId,
859
+ roomTitle: null,
860
+ agent: {
861
+ id: "unknown-agent",
862
+ name: "Agent",
863
+ handle: null,
864
+ description: null
865
+ },
866
+ participants: [],
867
+ mentionFormat: "No participant handles available",
868
+ warnings,
869
+ markdown
621
870
  };
622
871
  }
872
+ function evictLeastRecentlyUsedContext(contextCache, maxEntries) {
873
+ if (contextCache.size <= maxEntries) {
874
+ return;
875
+ }
876
+ let oldestKey = null;
877
+ let oldestAccessedAt = Number.POSITIVE_INFINITY;
878
+ for (const [key, entry] of contextCache.entries()) {
879
+ if (entry.lastAccessedAt < oldestAccessedAt) {
880
+ oldestAccessedAt = entry.lastAccessedAt;
881
+ oldestKey = key;
882
+ }
883
+ }
884
+ if (oldestKey) {
885
+ contextCache.delete(oldestKey);
886
+ }
887
+ }
888
+ function normalizeHandle(handle) {
889
+ return typeof handle === "string" && handle.trim().length > 0 ? handle.trim() : null;
890
+ }
623
891
  function toSdkToolDefinition(registration) {
624
892
  const shape = buildZodShape(
625
893
  import_zod4.z,
@@ -1151,20 +1419,17 @@ function checkPort2(http, port) {
1151
1419
 
1152
1420
  // src/mcp/backends.ts
1153
1421
  async function createThenvoiMcpBackend(options) {
1154
- const registrations = buildRoomScopedRegistrations(
1155
- options.getToolsForRoom,
1156
- {
1157
- enableMemoryTools: options.enableMemoryTools,
1158
- enableContactTools: true,
1159
- additionalTools: options.additionalTools
1160
- }
1161
- );
1162
- const allowedTools = mcpToolNames(new Set(registrations.map((registration) => registration.name)));
1422
+ const registrationOptions = {
1423
+ enableMemoryTools: options.enableMemoryTools,
1424
+ enableContactTools: true,
1425
+ additionalTools: options.additionalTools
1426
+ };
1163
1427
  if (options.kind === "sdk") {
1164
1428
  const { createThenvoiSdkMcpServer: createThenvoiSdkMcpServer2 } = await Promise.resolve().then(() => (init_sdk(), sdk_exports));
1165
1429
  const server2 = createThenvoiSdkMcpServer2({
1166
- enableMemoryTools: options.enableMemoryTools,
1167
1430
  getToolsForRoom: options.getToolsForRoom,
1431
+ multiRoom: options.multiRoom,
1432
+ enableMemoryTools: options.enableMemoryTools,
1168
1433
  additionalTools: options.additionalTools
1169
1434
  });
1170
1435
  return {
@@ -1174,9 +1439,12 @@ async function createThenvoiMcpBackend(options) {
1174
1439
  stop: async () => void 0
1175
1440
  };
1176
1441
  }
1442
+ const resolvedTools = options.multiRoom === false ? resolveSingleRoomTools(options.getToolsForRoom) : options.getToolsForRoom;
1443
+ const registrations = options.multiRoom === false ? buildSingleContextRegistrations(resolvedTools, registrationOptions) : buildRoomScopedRegistrations(resolvedTools, registrationOptions);
1444
+ const allowedTools = mcpToolNames(new Set(registrations.map((registration) => registration.name)));
1177
1445
  if (options.kind === "stdio") {
1178
1446
  const server2 = new ThenvoiMcpStdioServer({
1179
- tools: options.getToolsForRoom,
1447
+ tools: resolvedTools,
1180
1448
  enableMemoryTools: options.enableMemoryTools,
1181
1449
  enableContactTools: true,
1182
1450
  additionalTools: options.additionalTools
@@ -1193,7 +1461,7 @@ async function createThenvoiMcpBackend(options) {
1193
1461
  }
1194
1462
  if (options.kind === "sse") {
1195
1463
  const server2 = new ThenvoiMcpSseServer({
1196
- tools: options.getToolsForRoom,
1464
+ tools: resolvedTools,
1197
1465
  enableMemoryTools: options.enableMemoryTools,
1198
1466
  enableContactTools: true,
1199
1467
  additionalTools: options.additionalTools
@@ -1209,7 +1477,7 @@ async function createThenvoiMcpBackend(options) {
1209
1477
  };
1210
1478
  }
1211
1479
  const server = new ThenvoiMcpServer({
1212
- tools: options.getToolsForRoom,
1480
+ tools: resolvedTools,
1213
1481
  enableMemoryTools: options.enableMemoryTools,
1214
1482
  enableContactTools: true,
1215
1483
  additionalTools: options.additionalTools
package/dist/mcp.d.cts CHANGED
@@ -1,10 +1,10 @@
1
- export { C as CreateThenvoiMcpBackendOptions, T as ThenvoiMcpBackend, a as ThenvoiMcpBackendKind, c as createThenvoiMcpBackend, g as getThenvoiSdkMcpServerConfig } from './backends-SVMT-7l4.cjs';
2
- import { M as McpToolRegistration } from './sdk-CwTAxhwI.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-CwTAxhwI.cjs';
4
- import { A as AdapterToolsProtocol } from './protocols-CInhtFpA.cjs';
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';
5
5
  import { Readable, Writable } from 'node:stream';
6
6
  import '@anthropic-ai/claude-agent-sdk';
7
- import './dtos-DUpbIu8k.cjs';
7
+ import './dtos-Dd_fTfLn.cjs';
8
8
 
9
9
  interface ThenvoiMcpServerOptions {
10
10
  /** Single tools instance (no room scoping) or a resolver function for room-scoped tools. */
package/dist/mcp.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- export { C as CreateThenvoiMcpBackendOptions, T as ThenvoiMcpBackend, a as ThenvoiMcpBackendKind, c as createThenvoiMcpBackend, g as getThenvoiSdkMcpServerConfig } from './backends-CzDbiQar.js';
2
- import { M as McpToolRegistration } from './sdk-CcnQ5OUC.js';
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-CcnQ5OUC.js';
4
- import { A as AdapterToolsProtocol } from './protocols-DrhzOH6K.js';
1
+ export { C as CreateThenvoiMcpBackendOptions, T as ThenvoiMcpBackend, a as ThenvoiMcpBackendKind, c as createThenvoiMcpBackend, g as getThenvoiSdkMcpServerConfig } from './backends-oYAb7EU-.js';
2
+ import { M as McpToolRegistration } from './sdk-CyqN1W5g.js';
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-CyqN1W5g.js';
4
+ import { A as AdapterToolsProtocol } from './protocols-BF6jamIl.js';
5
5
  import { Readable, Writable } from 'node:stream';
6
6
  import '@anthropic-ai/claude-agent-sdk';
7
- import './dtos-DUpbIu8k.js';
7
+ import './dtos-Dd_fTfLn.js';
8
8
 
9
9
  interface ThenvoiMcpServerOptions {
10
10
  /** Single tools instance (no room scoping) or a resolver function for room-scoped tools. */
package/dist/mcp.js CHANGED
@@ -4,14 +4,14 @@ import {
4
4
  ThenvoiMcpStdioServer,
5
5
  createThenvoiMcpBackend,
6
6
  getThenvoiSdkMcpServerConfig
7
- } from "./chunk-MSL6CWHY.js";
7
+ } from "./chunk-2BHHR6YW.js";
8
8
  import {
9
9
  buildRoomScopedRegistrations,
10
10
  buildSingleContextRegistrations,
11
11
  errorResult,
12
12
  successResult
13
- } from "./chunk-EDPKUUJL.js";
14
- import "./chunk-GVEQ3RAH.js";
13
+ } from "./chunk-6RXWL6TC.js";
14
+ import "./chunk-MLROFDKR.js";
15
15
  import "./chunk-3BKAC4OZ.js";
16
16
  import "./chunk-YR3BOQNW.js";
17
17
  export {
@@ -1,5 +1,5 @@
1
- import { H as HistoryConverter } from './protocols-CInhtFpA.cjs';
2
- import { R as RestApi } from './types-CSHFipIc.cjs';
1
+ import { H as HistoryConverter } from './protocols-D2bTrQ_t.cjs';
2
+ import { R as RestApi } from './types-DtMms5Fi.cjs';
3
3
 
4
4
  interface GoogleADKMessage {
5
5
  role: "user" | "model";
@@ -1,5 +1,5 @@
1
- import { H as HistoryConverter } from './protocols-DrhzOH6K.js';
2
- import { R as RestApi } from './types-CxII3XkA.js';
1
+ import { H as HistoryConverter } from './protocols-BF6jamIl.js';
2
+ import { R as RestApi } from './types-D3AsUnd0.js';
3
3
 
4
4
  interface GoogleADKMessage {
5
5
  role: "user" | "model";
@@ -1,5 +1,5 @@
1
- import { P as PaginatedResponse, a as PaginationMetadata } from './types-CxII3XkA.js';
2
- import { M as MetadataMap } from './dtos-DUpbIu8k.js';
1
+ import { P as PaginatedResponse, a as PaginationMetadata } from './types-D3AsUnd0.js';
2
+ import { M as MetadataMap } from './dtos-Dd_fTfLn.js';
3
3
 
4
4
  interface FetchPageRequest {
5
5
  page: number;
@@ -1,5 +1,5 @@
1
- import { P as PaginatedResponse, a as PaginationMetadata } from './types-CSHFipIc.cjs';
2
- import { M as MetadataMap } from './dtos-DUpbIu8k.cjs';
1
+ import { P as PaginatedResponse, a as PaginationMetadata } from './types-DtMms5Fi.cjs';
2
+ import { M as MetadataMap } from './dtos-Dd_fTfLn.cjs';
3
3
 
4
4
  interface FetchPageRequest {
5
5
  page: number;
@@ -1,4 +1,4 @@
1
- import { a as MentionInput, T as ToolOperationResult, M as MetadataMap, P as ParticipantRecord, b as ToolSchemaRecord, c as PaginatedList, d as PeerRecord, 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 } from './dtos-DUpbIu8k.js';
1
+ import { a as MentionInput, T as ToolOperationResult, M as MetadataMap, P as ParticipantRecord, b as ToolSchemaRecord, c as PaginatedList, d as PeerRecord, 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 } from './dtos-Dd_fTfLn.js';
2
2
 
3
3
  interface HistoryConverter<T> {
4
4
  convert(raw: MetadataMap[]): T;
@@ -1,4 +1,4 @@
1
- import { a as MentionInput, T as ToolOperationResult, M as MetadataMap, P as ParticipantRecord, b as ToolSchemaRecord, c as PaginatedList, d as PeerRecord, 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 } from './dtos-DUpbIu8k.cjs';
1
+ import { a as MentionInput, T as ToolOperationResult, M as MetadataMap, P as ParticipantRecord, b as ToolSchemaRecord, c as PaginatedList, d as PeerRecord, 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 } from './dtos-Dd_fTfLn.cjs';
2
2
 
3
3
  interface HistoryConverter<T> {
4
4
  convert(raw: MetadataMap[]): T;
package/dist/rest.d.cts CHANGED
@@ -1,9 +1,9 @@
1
- import { R as RestApi, F as FernThenvoiClientLike, b as RestRequestOptions, A as AgentIdentity, C as ChatParticipant, c as PlatformChatMessage, P as PaginatedResponse } from './types-CSHFipIc.cjs';
2
- export { d as ChatMessageMention, D as DEFAULT_REQUEST_OPTIONS, a as PaginationMetadata } from './types-CSHFipIc.cjs';
3
- import { P as PaginationOptions } from './pagination-BPiys10t.cjs';
4
- export { f as fetchPaginated, n as normalizePaginationMetadata } from './pagination-BPiys10t.cjs';
1
+ import { R as RestApi, F as FernThenvoiClientLike, b as RestRequestOptions, A as AgentIdentity, C as ChatParticipant, c as PlatformChatMessage, P as PaginatedResponse } from './types-DtMms5Fi.cjs';
2
+ export { d as ChatMessageMention, D as DEFAULT_REQUEST_OPTIONS, a as PaginationMetadata } from './types-DtMms5Fi.cjs';
3
+ import { P as PaginationOptions } from './pagination-CqidD-L_.cjs';
4
+ export { f as fetchPaginated, n as normalizePaginationMetadata } from './pagination-CqidD-L_.cjs';
5
5
  import { L as Logger } from './logger-CABQOnlR.cjs';
6
- import { M as MetadataMap, j as MentionReference, T as ToolOperationResult, d as PeerRecord, 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 } from './dtos-DUpbIu8k.cjs';
6
+ import { M as MetadataMap, j as MentionReference, T as ToolOperationResult, d as PeerRecord, 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 } from './dtos-Dd_fTfLn.cjs';
7
7
 
8
8
  declare class FernRestAdapter implements RestApi {
9
9
  private readonly client;
package/dist/rest.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { R as RestApi, F as FernThenvoiClientLike, b as RestRequestOptions, A as AgentIdentity, C as ChatParticipant, c as PlatformChatMessage, P as PaginatedResponse } from './types-CxII3XkA.js';
2
- export { d as ChatMessageMention, D as DEFAULT_REQUEST_OPTIONS, a as PaginationMetadata } from './types-CxII3XkA.js';
3
- import { P as PaginationOptions } from './pagination-CcDkVFxK.js';
4
- export { f as fetchPaginated, n as normalizePaginationMetadata } from './pagination-CcDkVFxK.js';
1
+ import { R as RestApi, F as FernThenvoiClientLike, b as RestRequestOptions, A as AgentIdentity, C as ChatParticipant, c as PlatformChatMessage, P as PaginatedResponse } from './types-D3AsUnd0.js';
2
+ export { d as ChatMessageMention, D as DEFAULT_REQUEST_OPTIONS, a as PaginationMetadata } from './types-D3AsUnd0.js';
3
+ import { P as PaginationOptions } from './pagination-BBLsYLhT.js';
4
+ export { f as fetchPaginated, n as normalizePaginationMetadata } from './pagination-BBLsYLhT.js';
5
5
  import { L as Logger } from './logger-CABQOnlR.js';
6
- import { M as MetadataMap, j as MentionReference, T as ToolOperationResult, d as PeerRecord, 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 } from './dtos-DUpbIu8k.js';
6
+ import { M as MetadataMap, j as MentionReference, T as ToolOperationResult, d as PeerRecord, 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 } from './dtos-Dd_fTfLn.js';
7
7
 
8
8
  declare class FernRestAdapter implements RestApi {
9
9
  private readonly client;