@band-ai/sdk 0.3.4 → 0.4.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 (97) hide show
  1. package/README.md +54 -1
  2. package/dist/{ClaudeSDKAdapter-CXud2DBE.d.ts → CopilotACPAdapter-BCpbHFB0.d.ts} +240 -19
  3. package/dist/{ClaudeSDKAdapter-Cx6zhSaG.d.cts → CopilotACPAdapter-D4VWg8lJ.d.cts} +240 -19
  4. package/dist/{opencode-2YdscIc1.d.cts → acp-client-D-I_5lK-.d.cts} +23 -4
  5. package/dist/{opencode-Bld62x5t.d.ts → acp-client-DUXyczlF.d.ts} +23 -4
  6. package/dist/acp-server-BlcYMxKt.d.ts +17 -0
  7. package/dist/acp-server-CJhclo6P.d.cts +17 -0
  8. package/dist/adapters.cjs +2205 -969
  9. package/dist/adapters.d.cts +21 -132
  10. package/dist/adapters.d.ts +21 -132
  11. package/dist/adapters.js +26 -1922
  12. package/dist/{backends-D-dBdDm-.d.ts → backends-CgsPQa9B.d.ts} +2 -2
  13. package/dist/{backends-ZLxmQrTZ.d.cts → backends-Dh2WXcHQ.d.cts} +2 -2
  14. package/dist/{chunk-JY75VSQK.js → chunk-4OVNFDD7.js} +14 -1
  15. package/dist/chunk-6BE2EG5P.js +128 -0
  16. package/dist/{chunk-U6AFCLYZ.js → chunk-6TGXV5TE.js} +1824 -514
  17. package/dist/{chunk-OH6VVVKT.js → chunk-CBCHTTUY.js} +10 -0
  18. package/dist/{chunk-K5KAEYPF.js → chunk-HNWZZXAE.js} +288 -120
  19. package/dist/chunk-I34SXMTJ.js +6 -0
  20. package/dist/{chunk-XWHWJP4I.js → chunk-JDW5WSGF.js} +2 -2
  21. package/dist/{chunk-KXJ74J73.js → chunk-JIZE4EC6.js} +4 -10
  22. package/dist/chunk-OGOXY43L.js +119 -0
  23. package/dist/{chunk-W5IAI6Z4.js → chunk-OVXVZUPO.js} +5 -5
  24. package/dist/{chunk-YJ42AZO4.js → chunk-RJNJUISR.js} +5 -2
  25. package/dist/{chunk-MQY74R7D.js → chunk-SHZBLLDQ.js} +21 -9
  26. package/dist/{chunk-JADCAMZY.js → chunk-TGDDFBYS.js} +45 -0
  27. package/dist/{chunk-US226AS4.js → chunk-UENIC5FJ.js} +14 -11
  28. package/dist/{chunk-WA7CHXUS.js → chunk-UL3Y5C4J.js} +2 -2
  29. package/dist/{chunk-WL2HNJZ6.js → chunk-VOMJRQOM.js} +3 -3
  30. package/dist/{chunk-MQBBWYRP.js → chunk-YF7K4UB3.js} +3352 -572
  31. package/dist/{chunk-OD2G5LFQ.js → chunk-ZYOXI4JL.js} +41 -2
  32. package/dist/config.cjs +2 -12
  33. package/dist/config.js +2 -2
  34. package/dist/converters.cjs +36 -11
  35. package/dist/converters.d.cts +7 -5
  36. package/dist/converters.d.ts +7 -5
  37. package/dist/converters.js +11 -13
  38. package/dist/core.cjs +239 -5
  39. package/dist/core.d.cts +71 -6
  40. package/dist/core.d.ts +71 -6
  41. package/dist/core.js +31 -6
  42. package/dist/{customTools-BzF0IISO.d.cts → customTools-Bfecd0mJ.d.cts} +1 -1
  43. package/dist/{customTools-BzF0IISO.d.ts → customTools-Bfecd0mJ.d.ts} +1 -1
  44. package/dist/{disconnectReason-IuADl6TH.d.ts → disconnectReason-Cctmg1SN.d.cts} +1 -1
  45. package/dist/{disconnectReason-IuADl6TH.d.cts → disconnectReason-Cctmg1SN.d.ts} +1 -1
  46. package/dist/{dtos-B8KU_q4d.d.ts → dtos-CjQsN1_h.d.cts} +5 -12
  47. package/dist/{dtos-B8KU_q4d.d.cts → dtos-CjQsN1_h.d.ts} +5 -12
  48. package/dist/index.cjs +5237 -1474
  49. package/dist/index.d.cts +61 -22
  50. package/dist/index.d.ts +61 -22
  51. package/dist/index.js +151 -43
  52. package/dist/linear.cjs +45 -7
  53. package/dist/linear.d.cts +4 -3
  54. package/dist/linear.d.ts +4 -3
  55. package/dist/linear.js +10 -10
  56. package/dist/mcp-claude.cjs +11 -6
  57. package/dist/mcp-claude.d.cts +4 -3
  58. package/dist/mcp-claude.d.ts +4 -3
  59. package/dist/mcp-claude.js +4 -5
  60. package/dist/mcp.cjs +13 -7
  61. package/dist/mcp.d.cts +6 -5
  62. package/dist/mcp.d.ts +6 -5
  63. package/dist/mcp.js +5 -6
  64. package/dist/{pagination-DqdkQArT.d.cts → pagination-BZDhB_nO.d.cts} +2 -2
  65. package/dist/{pagination-BgEx-HeL.d.ts → pagination-CPz0J_vQ.d.ts} +2 -2
  66. package/dist/{protocols-Bz1rxcUg.d.cts → protocols-CabgO52c.d.cts} +38 -3
  67. package/dist/{protocols-Bwwcql0h.d.ts → protocols-Dpci6uae.d.ts} +38 -3
  68. package/dist/rest.cjs +43 -1
  69. package/dist/rest.d.cts +6 -5
  70. package/dist/rest.d.ts +6 -5
  71. package/dist/rest.js +6 -5
  72. package/dist/runtime.cjs +2113 -597
  73. package/dist/runtime.d.cts +44 -25
  74. package/dist/runtime.d.ts +44 -25
  75. package/dist/runtime.js +11 -11
  76. package/dist/{schemas-BgJhlqqO.d.cts → schemas-BKnh4fKR.d.cts} +209 -24
  77. package/dist/{schemas-C4mK1WSs.d.ts → schemas-CDa3V_I5.d.ts} +209 -24
  78. package/dist/{sdk-BTciSLRQ.d.cts → sdk-CXNqzoY1.d.cts} +1 -1
  79. package/dist/{sdk-qKJtMma_.d.ts → sdk-Cin80BTC.d.ts} +1 -1
  80. package/dist/{simpleAdapter-BpT4XbZC.d.cts → simpleAdapter-D75rcz9n.d.cts} +3 -1
  81. package/dist/{simpleAdapter--wznuoOw.d.ts → simpleAdapter-eLvsAQNo.d.ts} +3 -1
  82. package/dist/testing.cjs +25 -7
  83. package/dist/testing.d.cts +5 -3
  84. package/dist/testing.d.ts +5 -3
  85. package/dist/testing.js +9 -6
  86. package/dist/{types-BivGO7I9.d.ts → types-42-HWeX8.d.cts} +10 -4
  87. package/dist/types-CKU1N0SK.d.ts +137 -0
  88. package/dist/{types-BgYFd_Yw.d.cts → types-CjxZekMH.d.ts} +10 -4
  89. package/dist/types-DtcOLALn.d.cts +137 -0
  90. package/package.json +25 -26
  91. package/dist/acp-server-CiUqN3G3.d.ts +0 -24
  92. package/dist/acp-server-Dlj7D563.d.cts +0 -24
  93. package/dist/chunk-AVVDPXP4.js +0 -39
  94. package/dist/chunk-F63TPOI3.js +0 -29
  95. package/dist/chunk-V5TSWS7P.js +0 -62
  96. package/dist/types-BNNtOXu3.d.cts +0 -446
  97. package/dist/types-DFUtpxah.d.ts +0 -446
@@ -1,14 +1,51 @@
1
+ // src/core/sensitiveTerms.ts
2
+ var SENSITIVE_KEY_TERMS = "authorization|api[-_ ]?key|token|secret|password|cookie";
3
+ var GATEWAY_FREE_TEXT_SENSITIVE_KEY_TERMS = `${SENSITIVE_KEY_TERMS}|session`;
4
+
1
5
  // src/core/logger.ts
2
6
  var noop = () => void 0;
3
7
  var REDACTED_VALUE = "[REDACTED]";
4
8
  var CIRCULAR_VALUE = "[Circular]";
5
- var SENSITIVE_KEY_PATTERN = /(authorization|api[-_]?key|token|secret|password|cookie)/i;
9
+ var SENSITIVE_KEY_PATTERN = new RegExp(`(${SENSITIVE_KEY_TERMS})`, "i");
6
10
  var NoopLogger = class {
7
11
  debug = noop;
8
12
  info = noop;
9
13
  warn = noop;
10
14
  error = noop;
11
15
  };
16
+ function resolveLogger(logger) {
17
+ if (!logger) {
18
+ return new NoopLogger();
19
+ }
20
+ return logger instanceof GuardedLogger ? logger : new GuardedLogger(logger);
21
+ }
22
+ var GuardedLogger = class {
23
+ constructor(inner) {
24
+ this.inner = inner;
25
+ }
26
+ debug(message, context) {
27
+ return this.emit("debug", message, context);
28
+ }
29
+ info(message, context) {
30
+ return this.emit("info", message, context);
31
+ }
32
+ warn(message, context) {
33
+ return this.emit("warn", message, context);
34
+ }
35
+ error(message, context) {
36
+ return this.emit("error", message, context);
37
+ }
38
+ emit(level, message, context) {
39
+ try {
40
+ const result = this.inner[level](message, context);
41
+ if (result instanceof Promise) {
42
+ result.catch(noop);
43
+ }
44
+ return result;
45
+ } catch {
46
+ }
47
+ }
48
+ };
12
49
  var ConsoleLogger = class {
13
50
  debug(message, context) {
14
51
  this.emit("debug", message, context);
@@ -25,7 +62,7 @@ var ConsoleLogger = class {
25
62
  `);
26
63
  }
27
64
  emit(level, message, context) {
28
- const fn = console[level];
65
+ const fn = console[level].bind(console);
29
66
  if (context === void 0) {
30
67
  fn(message);
31
68
  return;
@@ -73,6 +110,8 @@ function sanitizeValue(value, seen = /* @__PURE__ */ new WeakSet()) {
73
110
  }
74
111
 
75
112
  export {
113
+ GATEWAY_FREE_TEXT_SENSITIVE_KEY_TERMS,
76
114
  NoopLogger,
115
+ resolveLogger,
77
116
  ConsoleLogger
78
117
  };
package/dist/config.cjs CHANGED
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // src/config/index.ts
@@ -37,7 +27,7 @@ module.exports = __toCommonJS(config_exports);
37
27
 
38
28
  // src/config/loader.ts
39
29
  var import_node_fs = require("fs");
40
- var import_js_yaml = __toESM(require("js-yaml"), 1);
30
+ var import_js_yaml = require("js-yaml");
41
31
 
42
32
  // src/core/errors.ts
43
33
  var BandSdkError = class extends Error {
@@ -131,7 +121,7 @@ function loadAgentConfig(agentKey, configPath) {
131
121
  `Config file not found: ${filePath}. Copy agent_config.yaml.example to agent_config.yaml and configure your agents.`
132
122
  );
133
123
  }
134
- const parsed = import_js_yaml.default.load(raw, { schema: import_js_yaml.default.JSON_SCHEMA });
124
+ const parsed = (0, import_js_yaml.load)(raw, { schema: import_js_yaml.JSON_SCHEMA });
135
125
  if (!parsed || typeof parsed !== "object") {
136
126
  throw new ValidationError(`Invalid config file: ${filePath}. Expected a YAML object.`);
137
127
  }
package/dist/config.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  loadAgentConfig,
3
3
  loadAgentConfigFromEnv
4
- } from "./chunk-WL2HNJZ6.js";
5
- import "./chunk-JY75VSQK.js";
4
+ } from "./chunk-VOMJRQOM.js";
5
+ import "./chunk-4OVNFDD7.js";
6
6
  export {
7
7
  loadAgentConfig,
8
8
  loadAgentConfigFromEnv
@@ -240,6 +240,17 @@ var VercelAISDKHistoryConverter = class {
240
240
  // src/adapters/a2a/A2AAdapter.ts
241
241
  var import_node_crypto = require("crypto");
242
242
 
243
+ // src/core/sensitiveTerms.ts
244
+ var SENSITIVE_KEY_TERMS = "authorization|api[-_ ]?key|token|secret|password|cookie";
245
+ var GATEWAY_FREE_TEXT_SENSITIVE_KEY_TERMS = `${SENSITIVE_KEY_TERMS}|session`;
246
+
247
+ // src/core/logger.ts
248
+ var SENSITIVE_KEY_PATTERN = new RegExp(`(${SENSITIVE_KEY_TERMS})`, "i");
249
+
250
+ // src/contracts/chatEvents.ts
251
+ var CHAT_EVENT_TYPES = ["tool_call", "tool_result", "thought", "error", "task"];
252
+ var CHAT_MESSAGE_TYPES = ["text", ...CHAT_EVENT_TYPES];
253
+
243
254
  // src/adapters/shared/coercion.ts
244
255
  function asOptionalRecord(value) {
245
256
  if (!value || typeof value !== "object" || Array.isArray(value)) {
@@ -255,6 +266,9 @@ function asNonEmptyString(value) {
255
266
  return trimmed.length > 0 ? trimmed : null;
256
267
  }
257
268
 
269
+ // src/core/providerFailure.ts
270
+ var import_band_sdk_core = require("@band-ai/band-sdk-core");
271
+
258
272
  // src/adapters/shared/history.ts
259
273
  function findLatestTaskMetadata(raw, predicate) {
260
274
  for (let index = raw.length - 1; index >= 0; index -= 1) {
@@ -491,6 +505,13 @@ var import_node_crypto3 = require("crypto");
491
505
  // src/adapters/a2a-gateway/statusEvent.ts
492
506
  var import_node_crypto2 = require("crypto");
493
507
 
508
+ // src/adapters/a2a-gateway/failure.ts
509
+ var import_band_sdk_core2 = require("@band-ai/band-sdk-core");
510
+ var SENSITIVE_VALUE_PATTERN = new RegExp(
511
+ `(${GATEWAY_FREE_TEXT_SENSITIVE_KEY_TERMS})"?\\s*(?:[A-Za-z]+\\s*)?[:=]\\s*"?(?:[A-Za-z][\\w-]*\\s+)?[^\\s,;"]+`,
512
+ "gi"
513
+ );
514
+
494
515
  // src/adapters/a2a-gateway/A2AGatewayAdapter.ts
495
516
  var DEFAULT_PORT = 1e4;
496
517
  var DEFAULT_GATEWAY_URL = `http://localhost:${DEFAULT_PORT}`;
@@ -576,6 +597,7 @@ var BASE_INSTRUCTIONS = [
576
597
  ].join("\n\n") + "\n";
577
598
 
578
599
  // src/contracts/memory.ts
600
+ var import_band_sdk_core3 = require("@band-ai/band-sdk-core");
579
601
  var SENSORY_MEMORY_TYPES = [
580
602
  "iconic",
581
603
  // Visual input
@@ -619,18 +641,22 @@ var MEMORY_SEGMENTS = [
619
641
  // Behavioral rules or policies
620
642
  ];
621
643
  var MEMORY_STORE_SCOPES = [
644
+ "agent",
645
+ // Private to the storing agent; omit subject_id
622
646
  "subject",
623
647
  // About one person/agent; requires subject_id
624
648
  "organization"
625
649
  // Shared org-wide
626
650
  ];
627
651
  var MEMORY_LIST_SCOPES = [
652
+ "agent",
653
+ // Caller's private agent-scoped memories only
628
654
  "subject",
629
655
  // Subject-scoped memories only
630
656
  "organization",
631
657
  // Organization-scoped memories only
632
658
  "all"
633
- // Both scopes (no scope filter)
659
+ // All scopes (no scope filter)
634
660
  ];
635
661
  var MEMORY_STATUSES = [
636
662
  "active",
@@ -647,10 +673,6 @@ var MEMORY_TYPE = namedValues(MEMORY_TYPES);
647
673
  var MEMORY_SEGMENT = namedValues(MEMORY_SEGMENTS);
648
674
  var MEMORY_STORE_SCOPE = namedValues(MEMORY_STORE_SCOPES);
649
675
 
650
- // src/contracts/chatEvents.ts
651
- var CHAT_EVENT_TYPES = ["tool_call", "tool_result", "thought", "error", "task"];
652
- var CHAT_MESSAGE_TYPES = ["text", ...CHAT_EVENT_TYPES];
653
-
654
676
  // src/runtime/tools/schemas.ts
655
677
  var TOOL_MODELS = {
656
678
  band_send_message: {
@@ -830,7 +852,7 @@ var TOOL_MODELS = {
830
852
  required: ["action"]
831
853
  },
832
854
  band_list_memories: {
833
- description: "List memories accessible to the agent. Returns memories about the specified subject (cross-agent sharing) and organization-wide shared memories.",
855
+ description: `List memories accessible to the agent. Use scope="agent" for the caller's private memories, scope="subject" for memories about a specific person or agent, and scope="organization" for org-wide shared memories. Omit scope or use scope="all" to search across scopes.`,
834
856
  properties: {
835
857
  subject_id: {
836
858
  type: "string",
@@ -839,7 +861,7 @@ var TOOL_MODELS = {
839
861
  scope: {
840
862
  type: "string",
841
863
  enum: [...MEMORY_LIST_SCOPES],
842
- description: "Filter by scope."
864
+ description: `Filter by scope. "agent" returns the caller's private memories; "subject" and "organization" filter to those audiences; "all" omits the filter.`
843
865
  },
844
866
  system: {
845
867
  type: "string",
@@ -875,7 +897,7 @@ var TOOL_MODELS = {
875
897
  required: []
876
898
  },
877
899
  band_store_memory: {
878
- 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.",
900
+ description: 'Store a new memory entry. The memory will be associated with the authenticated agent as the source. Use scope="agent" for information private to this agent (no subject_id). Use scope="subject" with a subject_id for memories about a specific person or agent. Use scope="organization" for knowledge genuinely shared across the organization.',
879
901
  properties: {
880
902
  content: {
881
903
  type: "string",
@@ -903,11 +925,11 @@ var TOOL_MODELS = {
903
925
  scope: {
904
926
  type: "string",
905
927
  enum: [...MEMORY_STORE_SCOPES],
906
- description: "Visibility scope."
928
+ description: 'Visibility scope. "agent" is private to this agent; "subject" requires subject_id; "organization" is shared org-wide.'
907
929
  },
908
930
  subject_id: {
909
931
  type: "string",
910
- description: "UUID of the subject this memory is about (required for subject scope)."
932
+ description: "UUID of the subject this memory is about (required for subject scope; omit for agent scope)."
911
933
  },
912
934
  metadata: {
913
935
  type: "object",
@@ -987,6 +1009,7 @@ function longTermPattern(label, type, segment, scope) {
987
1009
  };
988
1010
  }
989
1011
  var COMMON_MEMORY_PATTERNS = [
1012
+ longTermPattern("Private notes for this agent only", MEMORY_TYPE.semantic, MEMORY_SEGMENT.guideline, MEMORY_STORE_SCOPE.agent),
990
1013
  longTermPattern("Facts learned about a specific agent/entity", MEMORY_TYPE.semantic, MEMORY_SEGMENT.agent, MEMORY_STORE_SCOPE.subject),
991
1014
  longTermPattern("Events involving a specific person/agent", MEMORY_TYPE.episodic, MEMORY_SEGMENT.agent, MEMORY_STORE_SCOPE.subject),
992
1015
  longTermPattern("A user's preferences or profile info", MEMORY_TYPE.semantic, MEMORY_SEGMENT.user, MEMORY_STORE_SCOPE.subject),
@@ -999,7 +1022,9 @@ var MEMORY_COMMON_PATTERNS = [
999
1022
  "Common patterns:",
1000
1023
  ...COMMON_MEMORY_PATTERNS.map(renderMemoryPattern)
1001
1024
  ].join("\n");
1002
- var MEMORY_SCOPE_GUIDANCE = `Prefer \`scope="${MEMORY_STORE_SCOPE.subject}"\` whenever the memory is about a specific person or agent, so it
1025
+ var MEMORY_SCOPE_GUIDANCE = `Use \`scope="${MEMORY_STORE_SCOPE.agent}"\` for information private to this agent that is not about an
1026
+ identified subject. Omitting \`scope\` and \`subject_id\` on store defaults to agent scope on the platform.
1027
+ Prefer \`scope="${MEMORY_STORE_SCOPE.subject}"\` whenever the memory is about a specific person or agent, so it
1003
1028
  stays attached to that subject rather than leaking org-wide. Storing with \`scope="${MEMORY_STORE_SCOPE.subject}"\` requires a
1004
1029
  real \`subject_id\` UUID, so resolve it first via \`band_lookup_peers\` or the participant list.
1005
1030
  Reserve \`scope="${MEMORY_STORE_SCOPE.organization}"\` for knowledge that is genuinely shared across the whole organization and
@@ -1,8 +1,10 @@
1
- export { b as ACPClientHistoryConverter, A as ACPClientSessionState, c as ACPServerHistoryConverter, a as ACPServerSessionState, G as GatewayHistoryConverter } from './acp-server-Dlj7D563.cjs';
2
- import { H as HistoryConverter } from './protocols-Bz1rxcUg.cjs';
3
- export { A as A2AAuth, d as A2AHistoryConverter, e as A2ASessionState, G as GatewaySessionState, q as GoogleADKHistoryConverter, r as GoogleADKMessage, s as GoogleADKMessages, O as OpencodeHistoryConverter, t as OpencodeSessionState, P as ParlantHistoryConverter, m as ParlantMessage, n as ParlantMessages, p as buildA2AAuthHeaders, u as extractGoogleAdkSessionId, v as extractOpencodeSessionId } from './opencode-2YdscIc1.cjs';
4
- import './dtos-B8KU_q4d.cjs';
5
- import './types-BgYFd_Yw.cjs';
1
+ export { A as A2AAuth, d as A2AHistoryConverter, e as A2ASessionState, q as ACPClientHistoryConverter, r as ACPClientSessionState, G as GatewaySessionState, s as GoogleADKHistoryConverter, t as GoogleADKMessage, u as GoogleADKMessages, O as OpencodeHistoryConverter, v as OpencodeSessionState, P as ParlantHistoryConverter, m as ParlantMessage, n as ParlantMessages, p as buildA2AAuthHeaders, w as extractGoogleAdkSessionId, x as extractOpencodeSessionId } from './acp-client-D-I_5lK-.cjs';
2
+ export { a as ACPServerHistoryConverter, A as ACPServerSessionState, G as GatewayHistoryConverter } from './acp-server-CJhclo6P.cjs';
3
+ import { H as HistoryConverter } from './protocols-CabgO52c.cjs';
4
+ import './types-42-HWeX8.cjs';
5
+ import './dtos-CjQsN1_h.cjs';
6
+ import '@band-ai/band-sdk-core';
7
+ import './logger-CABQOnlR.cjs';
6
8
 
7
9
  type VercelAISDKMessage = {
8
10
  role: "system";
@@ -1,8 +1,10 @@
1
- export { b as ACPClientHistoryConverter, A as ACPClientSessionState, c as ACPServerHistoryConverter, a as ACPServerSessionState, G as GatewayHistoryConverter } from './acp-server-CiUqN3G3.js';
2
- import { H as HistoryConverter } from './protocols-Bwwcql0h.js';
3
- export { A as A2AAuth, d as A2AHistoryConverter, e as A2ASessionState, G as GatewaySessionState, q as GoogleADKHistoryConverter, r as GoogleADKMessage, s as GoogleADKMessages, O as OpencodeHistoryConverter, t as OpencodeSessionState, P as ParlantHistoryConverter, m as ParlantMessage, n as ParlantMessages, p as buildA2AAuthHeaders, u as extractGoogleAdkSessionId, v as extractOpencodeSessionId } from './opencode-Bld62x5t.js';
4
- import './dtos-B8KU_q4d.js';
5
- import './types-BivGO7I9.js';
1
+ export { A as A2AAuth, d as A2AHistoryConverter, e as A2ASessionState, q as ACPClientHistoryConverter, r as ACPClientSessionState, G as GatewaySessionState, s as GoogleADKHistoryConverter, t as GoogleADKMessage, u as GoogleADKMessages, O as OpencodeHistoryConverter, v as OpencodeSessionState, P as ParlantHistoryConverter, m as ParlantMessage, n as ParlantMessages, p as buildA2AAuthHeaders, w as extractGoogleAdkSessionId, x as extractOpencodeSessionId } from './acp-client-DUXyczlF.js';
2
+ export { a as ACPServerHistoryConverter, A as ACPServerSessionState, G as GatewayHistoryConverter } from './acp-server-BlcYMxKt.js';
3
+ import { H as HistoryConverter } from './protocols-Dpci6uae.js';
4
+ import './types-CjxZekMH.js';
5
+ import './dtos-CjQsN1_h.js';
6
+ import '@band-ai/band-sdk-core';
7
+ import './logger-CABQOnlR.js';
6
8
 
7
9
  type VercelAISDKMessage = {
8
10
  role: "system";
@@ -1,9 +1,7 @@
1
- import {
2
- ACPClientHistoryConverter,
3
- ACPServerHistoryConverter
4
- } from "./chunk-V5TSWS7P.js";
5
1
  import {
6
2
  A2AHistoryConverter,
3
+ ACPClientHistoryConverter,
4
+ ACPServerHistoryConverter,
7
5
  ClaudeSDKHistoryConverter,
8
6
  GatewayHistoryConverter,
9
7
  GoogleADKHistoryConverter,
@@ -18,15 +16,15 @@ import {
18
16
  parseDate,
19
17
  parseToolCall,
20
18
  parseToolResult
21
- } from "./chunk-K5KAEYPF.js";
22
- import "./chunk-AVVDPXP4.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";
28
- import "./chunk-OD2G5LFQ.js";
29
- import "./chunk-JY75VSQK.js";
19
+ } from "./chunk-HNWZZXAE.js";
20
+ import "./chunk-OGOXY43L.js";
21
+ import "./chunk-RJNJUISR.js";
22
+ import "./chunk-SHZBLLDQ.js";
23
+ import "./chunk-JIZE4EC6.js";
24
+ import "./chunk-6BE2EG5P.js";
25
+ import "./chunk-TGDDFBYS.js";
26
+ import "./chunk-ZYOXI4JL.js";
27
+ import "./chunk-4OVNFDD7.js";
30
28
 
31
29
  // src/converters/vercel-ai-sdk.ts
32
30
  function flushPendingToolCalls(messages, pendingToolCalls) {
package/dist/core.cjs CHANGED
@@ -20,15 +20,25 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/core/index.ts
21
21
  var core_exports = {};
22
22
  __export(core_exports, {
23
+ AgentFailure: () => import_band_sdk_core3.AgentFailure,
23
24
  BandSdkError: () => BandSdkError,
24
25
  ConsoleLogger: () => ConsoleLogger,
26
+ DeliveryFailedError: () => DeliveryFailedError,
27
+ FAILURE_EVENT_TYPE: () => FAILURE_EVENT_TYPE,
28
+ FAILURE_METADATA_KEY: () => FAILURE_METADATA_KEY,
25
29
  NoopLogger: () => NoopLogger,
30
+ ProviderTurnFailedError: () => ProviderTurnFailedError,
31
+ RecoverableTurnError: () => RecoverableTurnError,
26
32
  RuntimeStateError: () => RuntimeStateError,
27
33
  SimpleAdapter: () => SimpleAdapter,
28
34
  TransportError: () => TransportError,
29
35
  UnsupportedFeatureError: () => UnsupportedFeatureError,
30
36
  ValidationError: () => ValidationError,
31
- WebSocketDisconnectError: () => WebSocketDisconnectError
37
+ WebSocketDisconnectError: () => WebSocketDisconnectError,
38
+ agentFailure: () => agentFailure,
39
+ deliverReply: () => deliverReply,
40
+ reportTurnFailure: () => reportTurnFailure,
41
+ toFailureEvent: () => toFailureEvent
32
42
  });
33
43
  module.exports = __toCommonJS(core_exports);
34
44
 
@@ -68,6 +78,9 @@ var SimpleAdapter = class {
68
78
  }
69
79
  };
70
80
 
81
+ // src/core/index.ts
82
+ var import_band_sdk_core3 = require("@band-ai/band-sdk-core");
83
+
71
84
  // src/core/errors.ts
72
85
  var BandSdkError = class extends Error {
73
86
  constructor(message, cause) {
@@ -99,9 +112,36 @@ var RuntimeStateError = class extends BandSdkError {
99
112
  this.name = "RuntimeStateError";
100
113
  }
101
114
  };
115
+ var RecoverableTurnError = class extends BandSdkError {
116
+ constructor(message, cause) {
117
+ super(message, cause);
118
+ this.name = "RecoverableTurnError";
119
+ }
120
+ };
121
+
122
+ // src/contracts/chatEvents.ts
123
+ var CHAT_EVENT_TYPES = ["tool_call", "tool_result", "thought", "error", "task"];
124
+ var CHAT_MESSAGE_TYPES = ["text", ...CHAT_EVENT_TYPES];
125
+ var VISIBLE_CONTENT_PATTERN = /[\p{L}\p{N}\p{P}\p{S}]/u;
126
+ function isBlankEventContent(content) {
127
+ return !VISIBLE_CONTENT_PATTERN.test(content);
128
+ }
129
+
130
+ // src/contracts/protocols.ts
131
+ var FAILURE_EVENT_TYPE = "error";
132
+ var FAILURE_METADATA_KEY = "failure";
133
+ function toFailureEvent(failure) {
134
+ const content = isBlankEventContent(failure.message) ? `${failure.provider} failed without an error message.` : failure.message;
135
+ return {
136
+ content,
137
+ messageType: FAILURE_EVENT_TYPE,
138
+ metadata: { [FAILURE_METADATA_KEY]: failure.toObject() }
139
+ };
140
+ }
102
141
 
103
142
  // src/platform/streaming/disconnectReason.ts
104
143
  var import_zod = require("zod");
144
+ var import_band_sdk_core = require("@band-ai/band-sdk-core");
105
145
  var UPGRADE_CODES = [
106
146
  "invalid_on_conflict",
107
147
  "connection_conflict",
@@ -130,7 +170,7 @@ var upgradeErrorSchema = import_zod.z.object({
130
170
  })
131
171
  })
132
172
  ),
133
- headers: import_zod.z.record(import_zod.z.unknown()).optional()
173
+ headers: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional()
134
174
  });
135
175
  var WebSocketDisconnectError = class extends Error {
136
176
  reason;
@@ -141,11 +181,15 @@ var WebSocketDisconnectError = class extends Error {
141
181
  }
142
182
  };
143
183
 
184
+ // src/core/sensitiveTerms.ts
185
+ var SENSITIVE_KEY_TERMS = "authorization|api[-_ ]?key|token|secret|password|cookie";
186
+ var GATEWAY_FREE_TEXT_SENSITIVE_KEY_TERMS = `${SENSITIVE_KEY_TERMS}|session`;
187
+
144
188
  // src/core/logger.ts
145
189
  var noop = () => void 0;
146
190
  var REDACTED_VALUE = "[REDACTED]";
147
191
  var CIRCULAR_VALUE = "[Circular]";
148
- var SENSITIVE_KEY_PATTERN = /(authorization|api[-_]?key|token|secret|password|cookie)/i;
192
+ var SENSITIVE_KEY_PATTERN = new RegExp(`(${SENSITIVE_KEY_TERMS})`, "i");
149
193
  var NoopLogger = class {
150
194
  debug = noop;
151
195
  info = noop;
@@ -168,7 +212,7 @@ var ConsoleLogger = class {
168
212
  `);
169
213
  }
170
214
  emit(level, message, context) {
171
- const fn = console[level];
215
+ const fn = console[level].bind(console);
172
216
  if (context === void 0) {
173
217
  fn(message);
174
218
  return;
@@ -214,15 +258,205 @@ function sanitizeValue(value, seen = /* @__PURE__ */ new WeakSet()) {
214
258
  }
215
259
  return sanitized;
216
260
  }
261
+
262
+ // src/core/coercion.ts
263
+ var MAX_ERROR_CAUSE_DEPTH = 5;
264
+ var MAX_ERROR_DETAIL_LENGTH = 500;
265
+ var LENGTH_TRUNCATED_MARKER = "... (truncated)";
266
+ var DEPTH_TRUNCATED_MARKER = "... (cause chain truncated)";
267
+ function asOptionalRecord(value) {
268
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
269
+ return void 0;
270
+ }
271
+ return value;
272
+ }
273
+ function asNonEmptyString(value) {
274
+ if (typeof value !== "string") {
275
+ return null;
276
+ }
277
+ const trimmed = value.trim();
278
+ return trimmed.length > 0 ? trimmed : null;
279
+ }
280
+ function toDisplayText(value) {
281
+ if (typeof value === "string") {
282
+ return value;
283
+ }
284
+ if (value == null) {
285
+ return "";
286
+ }
287
+ try {
288
+ const json = JSON.stringify(value);
289
+ return typeof json === "string" ? json : String(value);
290
+ } catch {
291
+ return String(value);
292
+ }
293
+ }
294
+ function asErrorMessage(error) {
295
+ return formatCaughtError(error, 0);
296
+ }
297
+ function formatCaughtError(error, depth) {
298
+ if (typeof error !== "object" || error === null) {
299
+ return truncate(String(error));
300
+ }
301
+ const message = truncate(asNestedMessage(error) ?? String(error));
302
+ const detail = selectDetail(asOptionalRecord(error));
303
+ if (detail === void 0) {
304
+ return message;
305
+ }
306
+ if (depth >= MAX_ERROR_CAUSE_DEPTH) {
307
+ return `${message} (${DEPTH_TRUNCATED_MARKER})`;
308
+ }
309
+ return `${message} (${formatErrorDetail(detail, depth + 1)})`;
310
+ }
311
+ function selectDetail(record) {
312
+ if (isPresentDetail(record?.data)) {
313
+ return record?.data;
314
+ }
315
+ if (isPresentDetail(record?.cause)) {
316
+ return record?.cause;
317
+ }
318
+ return void 0;
319
+ }
320
+ function isPresentDetail(value) {
321
+ if (value === void 0 || value === null) {
322
+ return false;
323
+ }
324
+ if (typeof value === "string") {
325
+ return asNonEmptyString(value) !== null;
326
+ }
327
+ if (value instanceof Error) {
328
+ return true;
329
+ }
330
+ if (Array.isArray(value)) {
331
+ return value.length > 0;
332
+ }
333
+ if (typeof value === "object") {
334
+ return isPlainObject(value) ? Object.keys(value).length > 0 : true;
335
+ }
336
+ return true;
337
+ }
338
+ function isPlainObject(value) {
339
+ const proto = Object.getPrototypeOf(value);
340
+ return proto === Object.prototype || proto === null;
341
+ }
342
+ function formatErrorDetail(detail, depth) {
343
+ if (detail instanceof Error || selectDetail(asOptionalRecord(detail)) !== void 0) {
344
+ return formatCaughtError(detail, depth);
345
+ }
346
+ return truncate(formatLeafDetail(detail));
347
+ }
348
+ function formatLeafDetail(detail) {
349
+ if (typeof detail === "string") {
350
+ return detail;
351
+ }
352
+ if (typeof detail === "number" && !Number.isFinite(detail)) {
353
+ return String(detail);
354
+ }
355
+ const builtin = formatNonEnumerableDetail(detail);
356
+ if (builtin !== null) {
357
+ return builtin;
358
+ }
359
+ const nested = asNestedMessage(detail);
360
+ if (nested !== null) {
361
+ return nested;
362
+ }
363
+ return toDisplayText(detail);
364
+ }
365
+ function formatNonEnumerableDetail(detail) {
366
+ if (detail instanceof RegExp) {
367
+ return detail.toString();
368
+ }
369
+ if (detail instanceof Map) {
370
+ return `Map ${toDisplayText([...detail])}`;
371
+ }
372
+ if (detail instanceof Set) {
373
+ return `Set ${toDisplayText([...detail])}`;
374
+ }
375
+ return null;
376
+ }
377
+ function truncate(text) {
378
+ return text.length > MAX_ERROR_DETAIL_LENGTH ? `${text.slice(0, MAX_ERROR_DETAIL_LENGTH)}${LENGTH_TRUNCATED_MARKER}` : text;
379
+ }
380
+ function asNestedMessage(value) {
381
+ const record = asOptionalRecord(value);
382
+ return asNonEmptyString(record?.message);
383
+ }
384
+
385
+ // src/core/deliveryFailedError.ts
386
+ var DeliveryFailedError = class extends RecoverableTurnError {
387
+ constructor(cause) {
388
+ super(asErrorMessage(cause), cause);
389
+ this.cause = cause;
390
+ this.name = "DeliveryFailedError";
391
+ }
392
+ };
393
+ async function deliverReply(tools, content, mentions = []) {
394
+ try {
395
+ return await tools.sendMessage(content, mentions);
396
+ } catch (error) {
397
+ throw new DeliveryFailedError(error);
398
+ }
399
+ }
400
+
401
+ // src/core/providerFailure.ts
402
+ var import_band_sdk_core2 = require("@band-ai/band-sdk-core");
403
+ var ProviderTurnFailedError = class extends RecoverableTurnError {
404
+ constructor(failure) {
405
+ super(failure.message);
406
+ this.failure = failure;
407
+ this.name = "ProviderTurnFailedError";
408
+ }
409
+ };
410
+ async function trySendFailure(tools, failure, logger, logContext) {
411
+ logger?.warn("provider_failure.reported", {
412
+ provider: failure.provider,
413
+ code: failure.code,
414
+ ...logContext
415
+ });
416
+ try {
417
+ await tools.sendFailure(failure);
418
+ } catch (error) {
419
+ logger?.warn("provider_failure.report_failed", {
420
+ provider: failure.provider,
421
+ code: failure.code,
422
+ ...logContext,
423
+ error
424
+ });
425
+ }
426
+ }
427
+ async function reportTurnFailure(tools, failure, logger, logContext) {
428
+ await trySendFailure(tools, failure, logger, logContext);
429
+ throw new ProviderTurnFailedError(failure);
430
+ }
431
+ function agentFailure(provider, message, code, detail) {
432
+ if (detail === void 0) {
433
+ return new import_band_sdk_core2.AgentFailure(provider, message, code);
434
+ }
435
+ try {
436
+ return new import_band_sdk_core2.AgentFailure(provider, message, code, detail);
437
+ } catch {
438
+ return new import_band_sdk_core2.AgentFailure(provider, message, code);
439
+ }
440
+ }
217
441
  // Annotate the CommonJS export names for ESM import in node:
218
442
  0 && (module.exports = {
443
+ AgentFailure,
219
444
  BandSdkError,
220
445
  ConsoleLogger,
446
+ DeliveryFailedError,
447
+ FAILURE_EVENT_TYPE,
448
+ FAILURE_METADATA_KEY,
221
449
  NoopLogger,
450
+ ProviderTurnFailedError,
451
+ RecoverableTurnError,
222
452
  RuntimeStateError,
223
453
  SimpleAdapter,
224
454
  TransportError,
225
455
  UnsupportedFeatureError,
226
456
  ValidationError,
227
- WebSocketDisconnectError
457
+ WebSocketDisconnectError,
458
+ agentFailure,
459
+ deliverReply,
460
+ reportTurnFailure,
461
+ toFailureEvent
228
462
  });