@band-ai/sdk 0.2.1 → 0.3.1

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 (37) hide show
  1. package/dist/{ClaudeSDKAdapter-Cna5P1dR.d.ts → ClaudeSDKAdapter-CXud2DBE.d.ts} +2 -1
  2. package/dist/{ClaudeSDKAdapter-BY4zEbCl.d.cts → ClaudeSDKAdapter-Cx6zhSaG.d.cts} +2 -1
  3. package/dist/adapters.cjs +246 -116
  4. package/dist/adapters.d.cts +14 -3
  5. package/dist/adapters.d.ts +14 -3
  6. package/dist/adapters.js +143 -44
  7. package/dist/chunk-F63TPOI3.js +29 -0
  8. package/dist/{chunk-3BKAC4OZ.js → chunk-JADCAMZY.js} +8 -0
  9. package/dist/{chunk-N2QTUMGO.js → chunk-JJF44XWA.js} +365 -249
  10. package/dist/{chunk-TLBCKDQO.js → chunk-K5KAEYPF.js} +2 -2
  11. package/dist/{chunk-ZZJRRBPQ.js → chunk-KXJ74J73.js} +1 -1
  12. package/dist/{chunk-NMZLX7TP.js → chunk-MQBBWYRP.js} +52 -45
  13. package/dist/{chunk-RV76SKFT.js → chunk-MQY74R7D.js} +2 -20
  14. package/dist/{chunk-LBWKISBS.js → chunk-OH6VVVKT.js} +21 -0
  15. package/dist/{chunk-EAI2M3WM.js → chunk-W5IAI6Z4.js} +1 -1
  16. package/dist/{chunk-4IAXZBXX.js → chunk-WA7CHXUS.js} +2 -2
  17. package/dist/{chunk-NT7TBFX2.js → chunk-XWHWJP4I.js} +2 -2
  18. package/dist/{chunk-WLCM2OXG.js → chunk-YJ42AZO4.js} +1 -1
  19. package/dist/converters.js +6 -5
  20. package/dist/index.cjs +405 -277
  21. package/dist/index.d.cts +5 -5
  22. package/dist/index.d.ts +5 -5
  23. package/dist/index.js +12 -11
  24. package/dist/mcp-claude.js +4 -3
  25. package/dist/mcp.js +5 -4
  26. package/dist/rest.js +3 -3
  27. package/dist/runtime.cjs +387 -362
  28. package/dist/runtime.d.cts +10 -39
  29. package/dist/runtime.d.ts +10 -39
  30. package/dist/runtime.js +20 -142
  31. package/dist/{schemas-BotL3ZLH.d.cts → schemas-BgJhlqqO.d.cts} +57 -13
  32. package/dist/{schemas-DBsC4J1g.d.ts → schemas-C4mK1WSs.d.ts} +57 -13
  33. package/dist/testing.cjs +11 -0
  34. package/dist/testing.js +8 -1
  35. package/dist/{types-D958TC71.d.cts → types-BNNtOXu3.d.cts} +1 -1
  36. package/dist/{types-BTN_ZETM.d.ts → types-DFUtpxah.d.ts} +1 -1
  37. package/package.json +2 -2
@@ -3,12 +3,12 @@ import {
3
3
  } from "./chunk-AVVDPXP4.js";
4
4
  import {
5
5
  renderSystemPrompt
6
- } from "./chunk-WLCM2OXG.js";
6
+ } from "./chunk-YJ42AZO4.js";
7
7
  import {
8
8
  asErrorMessage,
9
9
  asNonEmptyString,
10
10
  asOptionalRecord
11
- } from "./chunk-ZZJRRBPQ.js";
11
+ } from "./chunk-KXJ74J73.js";
12
12
  import {
13
13
  NoopLogger
14
14
  } from "./chunk-OD2G5LFQ.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  toLegacyToolExecutorErrorMessage
3
- } from "./chunk-3BKAC4OZ.js";
3
+ } from "./chunk-JADCAMZY.js";
4
4
 
5
5
  // src/adapters/shared/coercion.ts
6
6
  function asOptionalRecord(value) {
@@ -1,35 +1,35 @@
1
1
  import {
2
2
  createBandMcpBackend
3
- } from "./chunk-4IAXZBXX.js";
3
+ } from "./chunk-WA7CHXUS.js";
4
4
  import {
5
5
  buildRoomScopedRegistrations,
6
6
  buildZodShape,
7
7
  errorResult,
8
8
  successResult
9
- } from "./chunk-NT7TBFX2.js";
9
+ } from "./chunk-XWHWJP4I.js";
10
10
  import {
11
11
  GoogleADKHistoryConverter,
12
12
  LazyAsyncValue,
13
13
  OpencodeHistoryConverter,
14
14
  extractClaudeSessionId,
15
15
  findLatestTaskMetadata
16
- } from "./chunk-TLBCKDQO.js";
16
+ } from "./chunk-K5KAEYPF.js";
17
17
  import {
18
18
  SimpleAdapter
19
19
  } from "./chunk-AVVDPXP4.js";
20
20
  import {
21
21
  formatHistoryForLlm,
22
22
  formatMessageForLlm
23
- } from "./chunk-LBWKISBS.js";
23
+ } from "./chunk-OH6VVVKT.js";
24
24
  import {
25
25
  renderSystemPrompt
26
- } from "./chunk-WLCM2OXG.js";
26
+ } from "./chunk-YJ42AZO4.js";
27
27
  import {
28
28
  MCP_SERVER_NAME,
29
29
  SEND_EVENT_TOOL_NAME,
30
30
  SEND_MESSAGE_TOOL_NAME,
31
31
  mcpToolNames
32
- } from "./chunk-RV76SKFT.js";
32
+ } from "./chunk-MQY74R7D.js";
33
33
  import {
34
34
  asErrorMessage,
35
35
  asNonEmptyString,
@@ -37,11 +37,12 @@ import {
37
37
  asRecord,
38
38
  toDisplayText,
39
39
  toWireString
40
- } from "./chunk-ZZJRRBPQ.js";
40
+ } from "./chunk-KXJ74J73.js";
41
41
  import {
42
+ isStructuredToolFailure,
42
43
  isToolExecutorError,
43
44
  toLegacyToolExecutorErrorMessage
44
- } from "./chunk-3BKAC4OZ.js";
45
+ } from "./chunk-JADCAMZY.js";
45
46
  import {
46
47
  NoopLogger
47
48
  } from "./chunk-OD2G5LFQ.js";
@@ -366,6 +367,34 @@ function toJsonRpcParams(value) {
366
367
  return record;
367
368
  }
368
369
 
370
+ // src/adapters/shared/conversationPrompt.ts
371
+ function systemUpdateParts(participantsMessage, contactsMessage) {
372
+ const parts = [];
373
+ if (participantsMessage) {
374
+ parts.push(`[System]: ${participantsMessage}`);
375
+ }
376
+ if (contactsMessage) {
377
+ parts.push(`[System]: ${contactsMessage}`);
378
+ }
379
+ return parts;
380
+ }
381
+ function buildConversationPrompt(options) {
382
+ const parts = [];
383
+ if (options.isSessionBootstrap && options.history.length > 0) {
384
+ const historyText = options.history.raw.slice(-(options.maxHistoryMessages ?? 50)).map(formatHistoryLine).join("\n");
385
+ parts.push(`${options.historyHeader}
386
+ ${historyText}`);
387
+ }
388
+ parts.push(...systemUpdateParts(options.participantsMessage, options.contactsMessage));
389
+ parts.push(options.currentMessage);
390
+ return parts.join("\n\n");
391
+ }
392
+ function formatHistoryLine(entry) {
393
+ const sender = String(entry.sender_name ?? entry.sender_type ?? "Unknown");
394
+ const content = String(entry.content ?? "");
395
+ return `[${sender}]: ${content}`;
396
+ }
397
+
369
398
  // src/runtime/tools/customTools.ts
370
399
  import "zod";
371
400
  import { zodToJsonSchema } from "zod-to-json-schema";
@@ -954,11 +983,8 @@ var CodexAdapter = class extends SimpleAdapter {
954
983
  items.push({ type: "text", text: context });
955
984
  }
956
985
  }
957
- if (input.participantsMessage) {
958
- items.push({ type: "text", text: `[System]: ${input.participantsMessage}` });
959
- }
960
- if (input.contactsMessage) {
961
- items.push({ type: "text", text: `[System]: ${input.contactsMessage}` });
986
+ for (const part of systemUpdateParts(input.participantsMessage, input.contactsMessage)) {
987
+ items.push({ type: "text", text: part });
962
988
  }
963
989
  items.push({
964
990
  type: "text",
@@ -1386,13 +1412,6 @@ var TURN_STATUS_VALUES = /* @__PURE__ */ new Set([
1386
1412
  "failed",
1387
1413
  "inProgress"
1388
1414
  ]);
1389
- function isStructuredToolFailure(value) {
1390
- if (!value || typeof value !== "object") {
1391
- return false;
1392
- }
1393
- const payload = value;
1394
- return payload.ok === false && typeof payload.message === "string";
1395
- }
1396
1415
  function isCodexToolOutputError(value) {
1397
1416
  return isToolExecutorError(value) || isStructuredToolFailure(value);
1398
1417
  }
@@ -2777,18 +2796,28 @@ var GoogleADKAdapter = class extends SimpleAdapter {
2777
2796
  }
2778
2797
  async reportExecutionEvent(sdk, event, tools) {
2779
2798
  for (const functionCall of sdk.getFunctionCalls(event)) {
2780
- await tools.sendEvent(JSON.stringify({
2799
+ const result = await tools.sendEvent(JSON.stringify({
2781
2800
  name: functionCall.name ?? "unknown",
2782
2801
  args: asToolArgs(functionCall.args),
2783
2802
  tool_call_id: functionCall.id ?? ""
2784
2803
  }), "tool_call");
2804
+ this.warnOnFailedSend(result, "Google ADK tool_call event send failed", { toolCallId: functionCall.id ?? "" });
2785
2805
  }
2786
2806
  for (const functionResponse of sdk.getFunctionResponses(event)) {
2787
- await tools.sendEvent(JSON.stringify({
2807
+ const result = await tools.sendEvent(JSON.stringify({
2788
2808
  name: functionResponse.name ?? "unknown",
2789
2809
  output: String(functionResponse.response ?? ""),
2790
2810
  tool_call_id: functionResponse.id ?? ""
2791
2811
  }), "tool_result");
2812
+ this.warnOnFailedSend(result, "Google ADK tool_result event send failed", { toolCallId: functionResponse.id ?? "" });
2813
+ }
2814
+ }
2815
+ warnOnFailedSend(result, message, meta) {
2816
+ if (result.ok === false) {
2817
+ try {
2818
+ this.logger.warn(message, meta);
2819
+ } catch {
2820
+ }
2792
2821
  }
2793
2822
  }
2794
2823
  };
@@ -5037,29 +5066,6 @@ function delay(ms) {
5037
5066
  });
5038
5067
  }
5039
5068
 
5040
- // src/adapters/shared/conversationPrompt.ts
5041
- function buildConversationPrompt(options) {
5042
- const parts = [];
5043
- if (options.isSessionBootstrap && options.history.length > 0) {
5044
- const historyText = options.history.raw.slice(-(options.maxHistoryMessages ?? 50)).map(formatHistoryLine).join("\n");
5045
- parts.push(`${options.historyHeader}
5046
- ${historyText}`);
5047
- }
5048
- if (options.participantsMessage) {
5049
- parts.push(`[System]: ${options.participantsMessage}`);
5050
- }
5051
- if (options.contactsMessage) {
5052
- parts.push(`[System]: ${options.contactsMessage}`);
5053
- }
5054
- parts.push(options.currentMessage);
5055
- return parts.join("\n\n");
5056
- }
5057
- function formatHistoryLine(entry) {
5058
- const sender = String(entry.sender_name ?? entry.sender_type ?? "Unknown");
5059
- const content = String(entry.content ?? "");
5060
- return `[${sender}]: ${content}`;
5061
- }
5062
-
5063
5069
  // src/adapters/claude-sdk/ClaudeSDKAdapter.ts
5064
5070
  import { z as z2 } from "zod";
5065
5071
  var DEFAULT_MODEL2 = "claude-sonnet-4-6";
@@ -5297,6 +5303,7 @@ function extractAssistantText3(event) {
5297
5303
 
5298
5304
  export {
5299
5305
  GenericAdapter,
5306
+ systemUpdateParts,
5300
5307
  CodexJsonRpcError,
5301
5308
  CodexAppServerStdioClient,
5302
5309
  CODEX_WEB_SEARCH_MODES,
@@ -1,20 +1,6 @@
1
1
  import {
2
- ValidationError
3
- } from "./chunk-JY75VSQK.js";
4
-
5
- // src/contracts/chatEvents.ts
6
- var CHAT_EVENT_TYPES = ["tool_call", "tool_result", "thought", "error", "task"];
7
- var CHAT_MESSAGE_TYPES = ["text", ...CHAT_EVENT_TYPES];
8
- function isChatEventType(value) {
9
- return CHAT_EVENT_TYPES.includes(value);
10
- }
11
- function assertChatEventType(value) {
12
- if (!isChatEventType(value)) {
13
- throw new ValidationError(
14
- `Invalid event message_type '${value}'. Expected one of: ${CHAT_EVENT_TYPES.join(", ")}`
15
- );
16
- }
17
- }
2
+ CHAT_EVENT_TYPES
3
+ } from "./chunk-F63TPOI3.js";
18
4
 
19
5
  // src/contracts/memory.ts
20
6
  var SENSORY_MEMORY_TYPES = [
@@ -448,10 +434,6 @@ function getToolDescription(name) {
448
434
  }
449
435
 
450
436
  export {
451
- CHAT_EVENT_TYPES,
452
- CHAT_MESSAGE_TYPES,
453
- isChatEventType,
454
- assertChatEventType,
455
437
  MEMORY_SYSTEM_TYPES,
456
438
  MEMORY_SYSTEMS,
457
439
  MEMORY_TYPES,
@@ -25,6 +25,26 @@ function ensureHandlePrefix(handle) {
25
25
  function isMetadataMap(value) {
26
26
  return value !== null && typeof value === "object" && !Array.isArray(value);
27
27
  }
28
+ function mentionSubjectsFromMetadata(metadata) {
29
+ const mentions = metadata?.mentions;
30
+ if (!Array.isArray(mentions)) {
31
+ return [];
32
+ }
33
+ const subjects = [];
34
+ for (const mention of mentions) {
35
+ if (!isMetadataMap(mention) || typeof mention.id !== "string") {
36
+ continue;
37
+ }
38
+ const label = [mention.handle, mention.username, mention.name].find(
39
+ (value) => typeof value === "string" && value.trim().length > 0
40
+ );
41
+ if (label === void 0) {
42
+ continue;
43
+ }
44
+ subjects.push({ id: mention.id, handle: label });
45
+ }
46
+ return subjects;
47
+ }
28
48
  function replaceUuidMentions(content, participants) {
29
49
  if (!content || participants.length === 0) {
30
50
  return content;
@@ -99,6 +119,7 @@ export {
99
119
  SYNTHETIC_CONTACT_EVENTS_SENDER_ID,
100
120
  SYNTHETIC_CONTACT_EVENTS_SENDER_NAME,
101
121
  ensureHandlePrefix,
122
+ mentionSubjectsFromMetadata,
102
123
  replaceUuidMentions,
103
124
  formatMessageForLlm,
104
125
  formatHistoryForLlm,
@@ -2,7 +2,7 @@ import {
2
2
  asNullableString,
3
3
  asOptionalRecord,
4
4
  asString
5
- } from "./chunk-ZZJRRBPQ.js";
5
+ } from "./chunk-KXJ74J73.js";
6
6
  import {
7
7
  NoopLogger
8
8
  } from "./chunk-OD2G5LFQ.js";
@@ -3,11 +3,11 @@ import {
3
3
  buildSingleContextRegistrations,
4
4
  buildZodShape,
5
5
  resolveSingleRoomTools
6
- } from "./chunk-NT7TBFX2.js";
6
+ } from "./chunk-XWHWJP4I.js";
7
7
  import {
8
8
  MCP_SERVER_NAME,
9
9
  mcpToolNames
10
- } from "./chunk-RV76SKFT.js";
10
+ } from "./chunk-MQY74R7D.js";
11
11
 
12
12
  // src/mcp/stdio.ts
13
13
  var BandMcpStdioServer = class {
@@ -4,11 +4,11 @@ import {
4
4
  MEMORY_TOOL_NAMES,
5
5
  TOOL_MODELS,
6
6
  getToolDescription
7
- } from "./chunk-RV76SKFT.js";
7
+ } from "./chunk-MQY74R7D.js";
8
8
  import {
9
9
  isToolExecutorError,
10
10
  toLegacyToolExecutorErrorMessage
11
- } from "./chunk-3BKAC4OZ.js";
11
+ } from "./chunk-JADCAMZY.js";
12
12
 
13
13
  // src/mcp/registrations.ts
14
14
  function buildRoomScopedRegistrations(resolver, options = {}) {
@@ -5,7 +5,7 @@ import {
5
5
  MEMORY_SYSTEM_TYPES,
6
6
  MEMORY_TYPE,
7
7
  TOOL_MODELS
8
- } from "./chunk-RV76SKFT.js";
8
+ } from "./chunk-MQY74R7D.js";
9
9
 
10
10
  // src/runtime/prompts/base.ts
11
11
  var ENVIRONMENT_SECTION = `
@@ -18,12 +18,13 @@ import {
18
18
  parseDate,
19
19
  parseToolCall,
20
20
  parseToolResult
21
- } from "./chunk-TLBCKDQO.js";
21
+ } from "./chunk-K5KAEYPF.js";
22
22
  import "./chunk-AVVDPXP4.js";
23
- import "./chunk-WLCM2OXG.js";
24
- import "./chunk-RV76SKFT.js";
25
- import "./chunk-ZZJRRBPQ.js";
26
- import "./chunk-3BKAC4OZ.js";
23
+ import "./chunk-YJ42AZO4.js";
24
+ import "./chunk-MQY74R7D.js";
25
+ import "./chunk-F63TPOI3.js";
26
+ import "./chunk-KXJ74J73.js";
27
+ import "./chunk-JADCAMZY.js";
27
28
  import "./chunk-OD2G5LFQ.js";
28
29
  import "./chunk-JY75VSQK.js";
29
30