@band-ai/band-sdk-core 2.2.0 → 2.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.
package/README.md CHANGED
@@ -146,7 +146,27 @@ enum on this boundary, matching how `EventType` stays a plain string in
146
146
  native `Error` with the same `.issues`/`.traceContext` contract as
147
147
  `validateEventPayload` — an unrecognized `system` and an unrecognized
148
148
  `type` are independent issues, both reported when both strings are
149
- invalid.
149
+ invalid. See "Enumerating memory-taxonomy values" below for listing each
150
+ enum's members without introducing one.
151
+
152
+ ### Enumerating memory-taxonomy values
153
+
154
+ `memorySystems()`, `memoryTypes()`, `memorySegments()`, `memoryStoreScopes()`,
155
+ `memoryListScopes()`, and `memoryStatuses()` each return that enum's wire
156
+ names as a `string[]`, in declaration order — runtime enumeration without
157
+ introducing a class, matching `MemorySegment`/`MemoryStoreScope`/
158
+ `MemoryListScope`/`MemoryStatus` as string-literal types in `index.d.ts`.
159
+
160
+ ```ts
161
+ import { memorySystems, memoryStatuses } from "@band-ai/band-sdk-core";
162
+
163
+ if (!memorySystems().includes("sensory")) {
164
+ throw new Error("memorySystems() missing sensory");
165
+ }
166
+ if (!memoryStatuses().includes("active")) {
167
+ throw new Error("memoryStatuses() missing active");
168
+ }
169
+ ```
150
170
 
151
171
  ### One-shot delivery lifecycle
152
172
 
package/band_sdk_core.js CHANGED
@@ -1,5 +1,110 @@
1
1
  /* @ts-self-types="./index.d.ts" */
2
2
 
3
+ /**
4
+ * One agent-provider failure, surfaced verbatim rather than classified.
5
+ */
6
+ class AgentFailure {
7
+ __destroy_into_raw() {
8
+ const ptr = this.__wbg_ptr;
9
+ this.__wbg_ptr = 0;
10
+ AgentFailureFinalization.unregister(this);
11
+ return ptr;
12
+ }
13
+ free() {
14
+ const ptr = this.__destroy_into_raw();
15
+ wasm.__wbg_agentfailure_free(ptr, 0);
16
+ }
17
+ /**
18
+ * @returns {string | undefined}
19
+ */
20
+ get code() {
21
+ const ret = wasm.agentfailure_code(this.__wbg_ptr);
22
+ let v1;
23
+ if (ret[0] !== 0) {
24
+ v1 = getStringFromWasm0(ret[0], ret[1]);
25
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
26
+ }
27
+ return v1;
28
+ }
29
+ /**
30
+ * `undefined` when absent, matching every other optional getter in
31
+ * this crate (e.g. `SessionOutcome.deadReason`) -- `toObject()` below
32
+ * represents the same absence as JSON `null` instead, since it mirrors
33
+ * the wire shape rather than idiomatic JS/TS property access.
34
+ * @returns {any}
35
+ */
36
+ get detail() {
37
+ const ret = wasm.agentfailure_detail(this.__wbg_ptr);
38
+ if (ret[2]) {
39
+ throw takeFromExternrefTable0(ret[1]);
40
+ }
41
+ return takeFromExternrefTable0(ret[0]);
42
+ }
43
+ /**
44
+ * @returns {string}
45
+ */
46
+ get message() {
47
+ let deferred1_0;
48
+ let deferred1_1;
49
+ try {
50
+ const ret = wasm.agentfailure_message(this.__wbg_ptr);
51
+ deferred1_0 = ret[0];
52
+ deferred1_1 = ret[1];
53
+ return getStringFromWasm0(ret[0], ret[1]);
54
+ } finally {
55
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
56
+ }
57
+ }
58
+ /**
59
+ * Throws a plain `Error` if `provider`/`message` is not a string, or
60
+ * `code` is present but not a string or `null`. A `detail` that cannot
61
+ * be converted from JSON throws a plain `Error` too.
62
+ * @param {any} provider
63
+ * @param {any} message
64
+ * @param {any} code
65
+ * @param {any} detail
66
+ */
67
+ constructor(provider, message, code, detail) {
68
+ const ret = wasm.agentfailure_new(provider, message, code, detail);
69
+ if (ret[2]) {
70
+ throw takeFromExternrefTable0(ret[1]);
71
+ }
72
+ this.__wbg_ptr = ret[0];
73
+ AgentFailureFinalization.register(this, this.__wbg_ptr, this);
74
+ return this;
75
+ }
76
+ /**
77
+ * @returns {string}
78
+ */
79
+ get provider() {
80
+ let deferred1_0;
81
+ let deferred1_1;
82
+ try {
83
+ const ret = wasm.agentfailure_provider(this.__wbg_ptr);
84
+ deferred1_0 = ret[0];
85
+ deferred1_1 = ret[1];
86
+ return getStringFromWasm0(ret[0], ret[1]);
87
+ } finally {
88
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
89
+ }
90
+ }
91
+ /**
92
+ * The failure as a plain JSON-shaped object: unlike the getters above,
93
+ * an absent `code`/`detail` serializes as `null` here, matching the
94
+ * core type's own `Serialize` output.
95
+ * @returns {any}
96
+ */
97
+ toObject() {
98
+ const ret = wasm.agentfailure_toObject(this.__wbg_ptr);
99
+ if (ret[2]) {
100
+ throw takeFromExternrefTable0(ret[1]);
101
+ }
102
+ return takeFromExternrefTable0(ret[0]);
103
+ }
104
+ }
105
+ if (Symbol.dispose) AgentFailure.prototype[Symbol.dispose] = AgentFailure.prototype.free;
106
+ exports.AgentFailure = AgentFailure;
107
+
3
108
  /**
4
109
  * Ownership ledger for the inbound message-delivery lifecycle: in-flight,
5
110
  * ack-pending, and completed states, each scoped by `(roomId,
@@ -1302,6 +1407,78 @@ function isSelfEcho(senderId, senderType, agentId) {
1302
1407
  }
1303
1408
  exports.isSelfEcho = isSelfEcho;
1304
1409
 
1410
+ /**
1411
+ * r" Every [`MemoryListScope`] wire name, in declaration order.
1412
+ * @returns {string[]}
1413
+ */
1414
+ function memoryListScopes() {
1415
+ const ret = wasm.memoryListScopes();
1416
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
1417
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
1418
+ return v1;
1419
+ }
1420
+ exports.memoryListScopes = memoryListScopes;
1421
+
1422
+ /**
1423
+ * r" Every [`MemorySegment`] wire name, in declaration order.
1424
+ * @returns {string[]}
1425
+ */
1426
+ function memorySegments() {
1427
+ const ret = wasm.memorySegments();
1428
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
1429
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
1430
+ return v1;
1431
+ }
1432
+ exports.memorySegments = memorySegments;
1433
+
1434
+ /**
1435
+ * r" Every [`MemoryStatus`] wire name, in declaration order.
1436
+ * @returns {string[]}
1437
+ */
1438
+ function memoryStatuses() {
1439
+ const ret = wasm.memoryStatuses();
1440
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
1441
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
1442
+ return v1;
1443
+ }
1444
+ exports.memoryStatuses = memoryStatuses;
1445
+
1446
+ /**
1447
+ * r" Every [`MemoryStoreScope`] wire name, in declaration order.
1448
+ * @returns {string[]}
1449
+ */
1450
+ function memoryStoreScopes() {
1451
+ const ret = wasm.memoryStoreScopes();
1452
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
1453
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
1454
+ return v1;
1455
+ }
1456
+ exports.memoryStoreScopes = memoryStoreScopes;
1457
+
1458
+ /**
1459
+ * r" Every [`MemorySystem`] wire name, in declaration order.
1460
+ * @returns {string[]}
1461
+ */
1462
+ function memorySystems() {
1463
+ const ret = wasm.memorySystems();
1464
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
1465
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
1466
+ return v1;
1467
+ }
1468
+ exports.memorySystems = memorySystems;
1469
+
1470
+ /**
1471
+ * r" Every [`MemoryType`] wire name, in declaration order.
1472
+ * @returns {string[]}
1473
+ */
1474
+ function memoryTypes() {
1475
+ const ret = wasm.memoryTypes();
1476
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
1477
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
1478
+ return v1;
1479
+ }
1480
+ exports.memoryTypes = memoryTypes;
1481
+
1305
1482
  /**
1306
1483
  * This platform's Phoenix Channels topic for a room's `room_participants`
1307
1484
  * channel.
@@ -1629,6 +1806,9 @@ function __wbg_get_imports() {
1629
1806
  };
1630
1807
  }
1631
1808
 
1809
+ const AgentFailureFinalization = (typeof FinalizationRegistry === 'undefined')
1810
+ ? { register: () => {}, unregister: () => {} }
1811
+ : new FinalizationRegistry(ptr => wasm.__wbg_agentfailure_free(ptr, 1));
1632
1812
  const ClaimRegistryFinalization = (typeof FinalizationRegistry === 'undefined')
1633
1813
  ? { register: () => {}, unregister: () => {} }
1634
1814
  : new FinalizationRegistry(ptr => wasm.__wbg_claimregistry_free(ptr, 1));
Binary file
package/index.d.ts CHANGED
@@ -1,3 +1,27 @@
1
+ /**
2
+ * One agent-provider failure, surfaced verbatim rather than classified.
3
+ * `detail` is an opaque passthrough of whatever JSON shape the provider (or
4
+ * the adapter, for a self-declared failure such as `code: "timeout"`)
5
+ * attaches -- this package never inspects it.
6
+ *
7
+ * Throws a plain `Error` if `provider`/`message` is not a string, `code` is
8
+ * present but not a string or `null`/`undefined`, or `detail` cannot be
9
+ * converted from JSON.
10
+ */
11
+ export class AgentFailure {
12
+ constructor(provider: string, message: string, code?: string | null, detail?: unknown);
13
+ readonly provider: string;
14
+ readonly code: string | undefined;
15
+ readonly message: string;
16
+ /** `undefined` when absent; {@link toObject} represents the same absence as `null` instead. */
17
+ readonly detail: unknown | undefined;
18
+ /**
19
+ * The failure as a plain JSON-shaped object. Unlike the getters above, an
20
+ * absent `code`/`detail` serializes as `null` here, not `undefined`.
21
+ */
22
+ toObject(): Record<string, unknown>;
23
+ }
24
+
1
25
  /** Canonical inbound wire-event names `validateEventPayload` accepts. */
2
26
  export type EventType =
3
27
  | "message_created"
@@ -61,6 +85,36 @@ export function validateMemoryTypeForSystem(
61
85
  traceContext?: string | null,
62
86
  ): void;
63
87
 
88
+ /** Logical subject category for a stored memory -- not a store/list scope. */
89
+ export type MemorySegment = "user" | "agent" | "tool" | "guideline";
90
+
91
+ /** Visibility scope for storing a memory. */
92
+ export type MemoryStoreScope = "subject" | "organization";
93
+
94
+ /** Scope filter for listing memories. */
95
+ export type MemoryListScope = "subject" | "organization" | "all";
96
+
97
+ /** Lifecycle state; list filter and set by supersede/archive operations. */
98
+ export type MemoryStatus = "active" | "superseded" | "archived" | "all";
99
+
100
+ /** Every {@link MemorySystem} wire name, in declaration order. */
101
+ export function memorySystems(): MemorySystem[];
102
+
103
+ /** Every {@link MemoryType} wire name, in declaration order. */
104
+ export function memoryTypes(): MemoryType[];
105
+
106
+ /** Every {@link MemorySegment} wire name, in declaration order. */
107
+ export function memorySegments(): MemorySegment[];
108
+
109
+ /** Every {@link MemoryStoreScope} wire name, in declaration order. */
110
+ export function memoryStoreScopes(): MemoryStoreScope[];
111
+
112
+ /** Every {@link MemoryListScope} wire name, in declaration order. */
113
+ export function memoryListScopes(): MemoryListScope[];
114
+
115
+ /** Every {@link MemoryStatus} wire name, in declaration order. */
116
+ export function memoryStatuses(): MemoryStatus[];
117
+
64
118
  /** A roster entry read by `ParticipantRoster`; every other key is ignored. */
65
119
  export interface ParticipantFields {
66
120
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@band-ai/band-sdk-core",
3
- "version": "2.2.0",
3
+ "version": "2.4.0",
4
4
  "description": "Shared Band event-payload validation",
5
5
  "license": "MIT",
6
6
  "repository": {