@band-ai/band-sdk-core 2.4.0 → 2.6.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
@@ -107,6 +107,31 @@ switch (tracker.recordRoomParticipantsJoinFailed("room-1", ticket, false)) {
107
107
  }
108
108
  ```
109
109
 
110
+ ### `DecisionRegistry` lifecycle
111
+
112
+ `DecisionRegistry` tracks chat-mediated asks: whoever claims one first owns
113
+ its outcome. Every registration returns `[token, ticket]`, with `ticket` a
114
+ `bigint`, and later calls name that exact registration, so a stale holder
115
+ gets `"stale"` instead of acting on a newer ask that reused the token.
116
+ `maxPending` must be an integer of at least `1`, or omitted/`null` for
117
+ unbounded; `seed` is an optional `bigint`. `cancelAll`/`cancelRoom` return a
118
+ plain `{ unclaimed, claimed }` object. `isAuthorizedSender` takes an array,
119
+ a `Set`, or `null`.
120
+
121
+ ```ts
122
+ import { DecisionRegistry, isAuthorizedSender } from "@band-ai/band-sdk-core";
123
+
124
+ const registry = new DecisionRegistry(10);
125
+ const registration = registry.registerMinted("room-1");
126
+ if (registration === undefined) throw new Error("tickets exhausted");
127
+ const [token, ticket] = registration;
128
+
129
+ if (registry.tryClaim(token, ticket) !== "claimed") throw new Error("not claimed");
130
+ if (registry.tryClaim(token, ticket) !== "already_claimed") throw new Error("claimed twice");
131
+ if (registry.cancelRoom("room-1").claimed[0] !== token) throw new Error("claim not reported");
132
+ if (!isAuthorizedSender(new Set(["alice"]), "alice")) throw new Error("alice refused");
133
+ ```
134
+
110
135
  ### `Session` — WebSocket reconnect state machine
111
136
 
112
137
  `Session`/`SessionPolicy` are a sans-io session state machine plus
package/band_sdk_core.js CHANGED
@@ -270,6 +270,182 @@ class ClaimRegistry {
270
270
  if (Symbol.dispose) ClaimRegistry.prototype[Symbol.dispose] = ClaimRegistry.prototype.free;
271
271
  exports.ClaimRegistry = ClaimRegistry;
272
272
 
273
+ /**
274
+ * Pending chat-mediated asks by token, oldest first. Every registration
275
+ * returns `[token, ticket]`; later calls name that exact registration, so a
276
+ * stale holder never acts on a newer ask that reused the token.
277
+ */
278
+ class DecisionRegistry {
279
+ __destroy_into_raw() {
280
+ const ptr = this.__wbg_ptr;
281
+ this.__wbg_ptr = 0;
282
+ DecisionRegistryFinalization.unregister(this);
283
+ return ptr;
284
+ }
285
+ free() {
286
+ const ptr = this.__destroy_into_raw();
287
+ wasm.__wbg_decisionregistry_free(ptr, 0);
288
+ }
289
+ /**
290
+ * Returns a plain `{ unclaimed, claimed }` object of token arrays.
291
+ * @returns {any}
292
+ */
293
+ cancelAll() {
294
+ const ret = wasm.decisionregistry_cancelAll(this.__wbg_ptr);
295
+ if (ret[2]) {
296
+ throw takeFromExternrefTable0(ret[1]);
297
+ }
298
+ return takeFromExternrefTable0(ret[0]);
299
+ }
300
+ /**
301
+ * Returns a plain `{ unclaimed, claimed }` object of token arrays.
302
+ * @param {any} roomId
303
+ * @returns {any}
304
+ */
305
+ cancelRoom(roomId) {
306
+ const ret = wasm.decisionregistry_cancelRoom(this.__wbg_ptr, roomId);
307
+ if (ret[2]) {
308
+ throw takeFromExternrefTable0(ret[1]);
309
+ }
310
+ return takeFromExternrefTable0(ret[0]);
311
+ }
312
+ /**
313
+ * @returns {string | undefined}
314
+ */
315
+ evictOldest() {
316
+ const ret = wasm.decisionregistry_evictOldest(this.__wbg_ptr);
317
+ let v1;
318
+ if (ret[0] !== 0) {
319
+ v1 = getStringFromWasm0(ret[0], ret[1]);
320
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
321
+ }
322
+ return v1;
323
+ }
324
+ /**
325
+ * @param {any} token
326
+ * @param {bigint} ticket
327
+ * @returns {boolean}
328
+ */
329
+ forget(token, ticket) {
330
+ const ret = wasm.decisionregistry_forget(this.__wbg_ptr, token, ticket);
331
+ if (ret[2]) {
332
+ throw takeFromExternrefTable0(ret[1]);
333
+ }
334
+ return ret[0] !== 0;
335
+ }
336
+ /**
337
+ * @returns {number | undefined}
338
+ */
339
+ get maxPending() {
340
+ const ret = wasm.decisionregistry_maxPending(this.__wbg_ptr);
341
+ return ret === Number.MAX_SAFE_INTEGER ? undefined : ret;
342
+ }
343
+ /**
344
+ * `maxPending` omitted or `null` never evicts. `seed` fixes the
345
+ * minted-token sequence; omitted, each registry draws its own.
346
+ * @param {number | null} [maxPending]
347
+ * @param {bigint | null} [seed]
348
+ */
349
+ constructor(maxPending, seed) {
350
+ const ret = wasm.decisionregistry_new(!isLikeNone(maxPending), isLikeNone(maxPending) ? 0 : maxPending, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
351
+ if (ret[2]) {
352
+ throw takeFromExternrefTable0(ret[1]);
353
+ }
354
+ this.__wbg_ptr = ret[0];
355
+ DecisionRegistryFinalization.register(this, this.__wbg_ptr, this);
356
+ return this;
357
+ }
358
+ /**
359
+ * @returns {string | undefined}
360
+ */
361
+ oldestUnclaimed() {
362
+ const ret = wasm.decisionregistry_oldestUnclaimed(this.__wbg_ptr);
363
+ let v1;
364
+ if (ret[0] !== 0) {
365
+ v1 = getStringFromWasm0(ret[0], ret[1]);
366
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
367
+ }
368
+ return v1;
369
+ }
370
+ /**
371
+ * @param {any} key
372
+ * @returns {Array<any> | undefined}
373
+ */
374
+ registerKeyed(key) {
375
+ const ret = wasm.decisionregistry_registerKeyed(this.__wbg_ptr, key);
376
+ if (ret[2]) {
377
+ throw takeFromExternrefTable0(ret[1]);
378
+ }
379
+ return takeFromExternrefTable0(ret[0]);
380
+ }
381
+ /**
382
+ * @param {any} roomId
383
+ * @returns {Array<any> | undefined}
384
+ */
385
+ registerMinted(roomId) {
386
+ const ret = wasm.decisionregistry_registerMinted(this.__wbg_ptr, roomId);
387
+ if (ret[2]) {
388
+ throw takeFromExternrefTable0(ret[1]);
389
+ }
390
+ return takeFromExternrefTable0(ret[0]);
391
+ }
392
+ /**
393
+ * @param {any} token
394
+ * @param {bigint} ticket
395
+ * @returns {string}
396
+ */
397
+ tryClaim(token, ticket) {
398
+ const ret = wasm.decisionregistry_tryClaim(this.__wbg_ptr, token, ticket);
399
+ if (ret[3]) {
400
+ throw takeFromExternrefTable0(ret[2]);
401
+ }
402
+ return getStringFromWasm0(ret[0], ret[1]);
403
+ }
404
+ /**
405
+ * @returns {number}
406
+ */
407
+ unclaimedCount() {
408
+ const ret = wasm.decisionregistry_unclaimedCount(this.__wbg_ptr);
409
+ return ret >>> 0;
410
+ }
411
+ /**
412
+ * @param {any} roomId
413
+ * @returns {string[]}
414
+ */
415
+ unclaimedInRoom(roomId) {
416
+ const ret = wasm.decisionregistry_unclaimedInRoom(this.__wbg_ptr, roomId);
417
+ if (ret[3]) {
418
+ throw takeFromExternrefTable0(ret[2]);
419
+ }
420
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
421
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
422
+ return v1;
423
+ }
424
+ /**
425
+ * @returns {string[]}
426
+ */
427
+ unclaimed() {
428
+ const ret = wasm.decisionregistry_unclaimed(this.__wbg_ptr);
429
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
430
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
431
+ return v1;
432
+ }
433
+ /**
434
+ * @param {any} token
435
+ * @param {bigint} ticket
436
+ * @returns {boolean}
437
+ */
438
+ withdraw(token, ticket) {
439
+ const ret = wasm.decisionregistry_withdraw(this.__wbg_ptr, token, ticket);
440
+ if (ret[2]) {
441
+ throw takeFromExternrefTable0(ret[1]);
442
+ }
443
+ return ret[0] !== 0;
444
+ }
445
+ }
446
+ if (Symbol.dispose) DecisionRegistry.prototype[Symbol.dispose] = DecisionRegistry.prototype.free;
447
+ exports.DecisionRegistry = DecisionRegistry;
448
+
273
449
  /**
274
450
  * The always-injected passive participant roster. A participant is any
275
451
  * plain object; `add`/`setAll` read `id`, `name`, `type`, `handle`,
@@ -1081,11 +1257,10 @@ class SubscriptionTracker {
1081
1257
  /**
1082
1258
  * @param {any} topic
1083
1259
  * @param {bigint} ticket
1084
- * @param {boolean} joined
1085
1260
  * @returns {boolean}
1086
1261
  */
1087
- recordAgentTopicJoin(topic, ticket, joined) {
1088
- const ret = wasm.subscriptiontracker_recordAgentTopicJoin(this.__wbg_ptr, topic, ticket, joined);
1262
+ recordAgentTopicJoinAmbiguous(topic, ticket) {
1263
+ const ret = wasm.subscriptiontracker_recordAgentTopicJoinAmbiguous(this.__wbg_ptr, topic, ticket);
1089
1264
  if (ret[2]) {
1090
1265
  throw takeFromExternrefTable0(ret[1]);
1091
1266
  }
@@ -1094,10 +1269,11 @@ class SubscriptionTracker {
1094
1269
  /**
1095
1270
  * @param {any} topic
1096
1271
  * @param {bigint} ticket
1272
+ * @param {boolean} joined
1097
1273
  * @returns {boolean}
1098
1274
  */
1099
- recordAgentTopicJoinAmbiguous(topic, ticket) {
1100
- const ret = wasm.subscriptiontracker_recordAgentTopicJoinAmbiguous(this.__wbg_ptr, topic, ticket);
1275
+ recordAgentTopicJoin(topic, ticket, joined) {
1276
+ const ret = wasm.subscriptiontracker_recordAgentTopicJoin(this.__wbg_ptr, topic, ticket, joined);
1101
1277
  if (ret[2]) {
1102
1278
  throw takeFromExternrefTable0(ret[1]);
1103
1279
  }
@@ -1387,6 +1563,24 @@ function evaluateNextMessage(triggeringMessageId, nextMessageId) {
1387
1563
  }
1388
1564
  exports.evaluateNextMessage = evaluateNextMessage;
1389
1565
 
1566
+ /**
1567
+ * Whether `senderId` may answer an ask: `null` admits anyone; any array or
1568
+ * `Set` -- empty included -- admits only its members. Throws a plain
1569
+ * `Error` if `authorizedSenders` is not an array or `Set` of strings (or
1570
+ * `null`), or `senderId` is not a string (or `null`).
1571
+ * @param {any} authorizedSenders
1572
+ * @param {any} senderId
1573
+ * @returns {boolean}
1574
+ */
1575
+ function isAuthorizedSender(authorizedSenders, senderId) {
1576
+ const ret = wasm.isAuthorizedSender(authorizedSenders, senderId);
1577
+ if (ret[2]) {
1578
+ throw takeFromExternrefTable0(ret[1]);
1579
+ }
1580
+ return ret[0] !== 0;
1581
+ }
1582
+ exports.isAuthorizedSender = isAuthorizedSender;
1583
+
1390
1584
  /**
1391
1585
  * The one definition of "self echo" (`senderType === "Agent" &&
1392
1586
  * senderId === agentId`), shared by `evaluateDeliveryEvent` and
@@ -1548,7 +1742,7 @@ exports.validateMemoryTypeForSystem = validateMemoryTypeForSystem;
1548
1742
  function __wbg_get_imports() {
1549
1743
  const import0 = {
1550
1744
  __proto__: null,
1551
- __wbg_Error_408e67f47ca7b58b: function(arg0, arg1) {
1745
+ __wbg_Error_67e7344beaa85059: function(arg0, arg1) {
1552
1746
  const ret = Error(getStringFromWasm0(arg0, arg1));
1553
1747
  return ret;
1554
1748
  },
@@ -1559,68 +1753,68 @@ function __wbg_get_imports() {
1559
1753
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1560
1754
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1561
1755
  },
1562
- __wbg___wbindgen_bigint_get_as_i64_c4ecf48528083721: function(arg0, arg1) {
1756
+ __wbg___wbindgen_bigint_get_as_i64_b482365c149396c8: function(arg0, arg1) {
1563
1757
  const v = arg1;
1564
1758
  const ret = typeof(v) === 'bigint' ? v : undefined;
1565
1759
  getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
1566
1760
  getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
1567
1761
  },
1568
- __wbg___wbindgen_boolean_get_c9c83ebd41b34df3: function(arg0) {
1762
+ __wbg___wbindgen_boolean_get_7a12af2b3f899c5a: function(arg0) {
1569
1763
  const v = arg0;
1570
1764
  const ret = typeof(v) === 'boolean' ? v : undefined;
1571
1765
  return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
1572
1766
  },
1573
- __wbg___wbindgen_debug_string_a57024b9c6e4a48b: function(arg0, arg1) {
1767
+ __wbg___wbindgen_debug_string_0e68cf47c9cbd9b0: function(arg0, arg1) {
1574
1768
  const ret = debugString(arg1);
1575
1769
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1576
1770
  const len1 = WASM_VECTOR_LEN;
1577
1771
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1578
1772
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1579
1773
  },
1580
- __wbg___wbindgen_in_ac983077f137f2e6: function(arg0, arg1) {
1774
+ __wbg___wbindgen_in_50072d4d6e45c193: function(arg0, arg1) {
1581
1775
  const ret = arg0 in arg1;
1582
1776
  return ret;
1583
1777
  },
1584
- __wbg___wbindgen_is_bigint_8ffbbef442139384: function(arg0) {
1778
+ __wbg___wbindgen_is_bigint_60fc0336cb14f5d7: function(arg0) {
1585
1779
  const ret = typeof(arg0) === 'bigint';
1586
1780
  return ret;
1587
1781
  },
1588
- __wbg___wbindgen_is_function_5e4570eb24ffa122: function(arg0) {
1782
+ __wbg___wbindgen_is_function_fcda5e3902d732fe: function(arg0) {
1589
1783
  const ret = typeof(arg0) === 'function';
1590
1784
  return ret;
1591
1785
  },
1592
- __wbg___wbindgen_is_null_7d13f41e1a2d5140: function(arg0) {
1786
+ __wbg___wbindgen_is_null_5160b3e381865372: function(arg0) {
1593
1787
  const ret = arg0 === null;
1594
1788
  return ret;
1595
1789
  },
1596
- __wbg___wbindgen_is_object_a2790eb24c211ea0: function(arg0) {
1790
+ __wbg___wbindgen_is_object_edb6b15aa3afe12e: function(arg0) {
1597
1791
  const val = arg0;
1598
1792
  const ret = typeof(val) === 'object' && val !== null;
1599
1793
  return ret;
1600
1794
  },
1601
- __wbg___wbindgen_is_string_e6f02f0ea5f20a32: function(arg0) {
1795
+ __wbg___wbindgen_is_string_c4f7cb494a2a21f1: function(arg0) {
1602
1796
  const ret = typeof(arg0) === 'string';
1603
1797
  return ret;
1604
1798
  },
1605
- __wbg___wbindgen_is_undefined_6cff064c44e0d823: function(arg0) {
1799
+ __wbg___wbindgen_is_undefined_8c687d0b90d5b524: function(arg0) {
1606
1800
  const ret = arg0 === undefined;
1607
1801
  return ret;
1608
1802
  },
1609
- __wbg___wbindgen_jsval_eq_0a18949a61670320: function(arg0, arg1) {
1803
+ __wbg___wbindgen_jsval_eq_9fdcd3c0a860dd3b: function(arg0, arg1) {
1610
1804
  const ret = arg0 === arg1;
1611
1805
  return ret;
1612
1806
  },
1613
- __wbg___wbindgen_jsval_loose_eq_acf2776254a8d832: function(arg0, arg1) {
1807
+ __wbg___wbindgen_jsval_loose_eq_3c30021c243b64cd: function(arg0, arg1) {
1614
1808
  const ret = arg0 == arg1;
1615
1809
  return ret;
1616
1810
  },
1617
- __wbg___wbindgen_number_get_136b9679cab35cfb: function(arg0, arg1) {
1811
+ __wbg___wbindgen_number_get_1dc732b810cb937c: function(arg0, arg1) {
1618
1812
  const obj = arg1;
1619
1813
  const ret = typeof(obj) === 'number' ? obj : undefined;
1620
1814
  getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
1621
1815
  getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
1622
1816
  },
1623
- __wbg___wbindgen_string_get_d154f1e671052120: function(arg0, arg1) {
1817
+ __wbg___wbindgen_string_get_92ab86bb19cbc12f: function(arg0, arg1) {
1624
1818
  const obj = arg1;
1625
1819
  const ret = typeof(obj) === 'string' ? obj : undefined;
1626
1820
  var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -1628,34 +1822,38 @@ function __wbg_get_imports() {
1628
1822
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1629
1823
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1630
1824
  },
1631
- __wbg___wbindgen_throw_bb96b2010945f0bc: function(arg0, arg1) {
1825
+ __wbg___wbindgen_throw_5d9e815e6fdf150f: function(arg0, arg1) {
1632
1826
  throw new Error(getStringFromWasm0(arg0, arg1));
1633
1827
  },
1634
- __wbg_call_1c5886ab9c57d1c7: function() { return handleError(function (arg0, arg1) {
1828
+ __wbg_call_269c5566fbede3eb: function() { return handleError(function (arg0, arg1) {
1635
1829
  const ret = arg0.call(arg1);
1636
1830
  return ret;
1637
1831
  }, arguments); },
1638
- __wbg_done_669171204c3dcae2: function(arg0) {
1832
+ __wbg_done_cffed884d87aa22e: function(arg0) {
1639
1833
  const ret = arg0.done;
1640
1834
  return ret;
1641
1835
  },
1642
- __wbg_entries_7774d489e1da5f4f: function(arg0) {
1836
+ __wbg_entries_972a87586902cf87: function(arg0) {
1643
1837
  const ret = Object.entries(arg0);
1644
1838
  return ret;
1645
1839
  },
1646
- __wbg_get_971a0c45d172643f: function() { return handleError(function (arg0, arg1) {
1840
+ __wbg_from_a39669ce566077da: function(arg0) {
1841
+ const ret = Array.from(arg0);
1842
+ return ret;
1843
+ },
1844
+ __wbg_get_6cf5a4d4d8ad3c5a: function() { return handleError(function (arg0, arg1) {
1647
1845
  const ret = Reflect.get(arg0, arg1);
1648
1846
  return ret;
1649
1847
  }, arguments); },
1650
- __wbg_get_c0c8f8d7da0c03dd: function(arg0, arg1) {
1651
- const ret = arg0[arg1 >>> 0];
1652
- return ret;
1653
- },
1654
- __wbg_get_d173c0308df22d37: function() { return handleError(function (arg0, arg1) {
1848
+ __wbg_get_989d0a1309644f2b: function() { return handleError(function (arg0, arg1) {
1655
1849
  const ret = Reflect.get(arg0, arg1);
1656
1850
  return ret;
1657
1851
  }, arguments); },
1658
- __wbg_get_unchecked_e20b893aeafc3fca: function(arg0, arg1) {
1852
+ __wbg_get_b1f0ab13c737f856: function(arg0, arg1) {
1853
+ const ret = arg0[arg1 >>> 0];
1854
+ return ret;
1855
+ },
1856
+ __wbg_get_unchecked_363572bdd397d473: function(arg0, arg1) {
1659
1857
  const ret = arg0[arg1 >>> 0];
1660
1858
  return ret;
1661
1859
  },
@@ -1663,7 +1861,7 @@ function __wbg_get_imports() {
1663
1861
  const ret = arg0[arg1];
1664
1862
  return ret;
1665
1863
  },
1666
- __wbg_instanceof_ArrayBuffer_993d02d2d254cad1: function(arg0) {
1864
+ __wbg_instanceof_ArrayBuffer_d4ff01f8247925ae: function(arg0) {
1667
1865
  let result;
1668
1866
  try {
1669
1867
  result = arg0 instanceof ArrayBuffer;
@@ -1673,7 +1871,7 @@ function __wbg_get_imports() {
1673
1871
  const ret = result;
1674
1872
  return ret;
1675
1873
  },
1676
- __wbg_instanceof_Map_9a4d6ead180ae3a9: function(arg0) {
1874
+ __wbg_instanceof_Map_1ff6a2b54c899f0d: function(arg0) {
1677
1875
  let result;
1678
1876
  try {
1679
1877
  result = arg0 instanceof Map;
@@ -1683,7 +1881,17 @@ function __wbg_get_imports() {
1683
1881
  const ret = result;
1684
1882
  return ret;
1685
1883
  },
1686
- __wbg_instanceof_Uint8Array_f935dbb0aa7cdeed: function(arg0) {
1884
+ __wbg_instanceof_Set_daa5e1ad3c6acaeb: function(arg0) {
1885
+ let result;
1886
+ try {
1887
+ result = arg0 instanceof Set;
1888
+ } catch (_) {
1889
+ result = false;
1890
+ }
1891
+ const ret = result;
1892
+ return ret;
1893
+ },
1894
+ __wbg_instanceof_Uint8Array_598adc0fef426aa8: function(arg0) {
1687
1895
  let result;
1688
1896
  try {
1689
1897
  result = arg0 instanceof Uint8Array;
@@ -1693,99 +1901,103 @@ function __wbg_get_imports() {
1693
1901
  const ret = result;
1694
1902
  return ret;
1695
1903
  },
1696
- __wbg_isArray_6339f732981044bf: function(arg0) {
1904
+ __wbg_isArray_5674713bb7b79043: function(arg0) {
1697
1905
  const ret = Array.isArray(arg0);
1698
1906
  return ret;
1699
1907
  },
1700
- __wbg_isSafeInteger_f3d6cd19ccfe4512: function(arg0) {
1908
+ __wbg_isSafeInteger_8f51c743827d1ec5: function(arg0) {
1701
1909
  const ret = Number.isSafeInteger(arg0);
1702
1910
  return ret;
1703
1911
  },
1704
- __wbg_iterator_5cebbb86e33c6dd6: function() {
1912
+ __wbg_iterator_22ddeb808cf55a6f: function() {
1705
1913
  const ret = Symbol.iterator;
1706
1914
  return ret;
1707
1915
  },
1708
- __wbg_length_36bd29c6848c2144: function(arg0) {
1916
+ __wbg_length_31bdaf014f5fbde2: function(arg0) {
1709
1917
  const ret = arg0.length;
1710
1918
  return ret;
1711
1919
  },
1712
- __wbg_length_ecfa2c63d3d0d82c: function(arg0) {
1920
+ __wbg_length_4e1adc0d42e23620: function(arg0) {
1713
1921
  const ret = arg0.length;
1714
1922
  return ret;
1715
1923
  },
1716
- __wbg_new_116be93542d39019: function() {
1717
- const ret = new Array();
1924
+ __wbg_new_1da3429bc3c4541c: function(arg0) {
1925
+ const ret = new Uint8Array(arg0);
1926
+ return ret;
1927
+ },
1928
+ __wbg_new_8d36e20aa758e411: function() {
1929
+ const ret = new Map();
1718
1930
  return ret;
1719
1931
  },
1720
- __wbg_new_358857d90afd5a2d: function(arg0, arg1) {
1932
+ __wbg_new_a32a1ab6c6655abe: function(arg0, arg1) {
1721
1933
  const ret = new Error(getStringFromWasm0(arg0, arg1));
1722
1934
  return ret;
1723
1935
  },
1724
- __wbg_new_77cc4f4f472aeb81: function(arg0) {
1725
- const ret = new Uint8Array(arg0);
1936
+ __wbg_new_bebc3f4757acf305: function() {
1937
+ const ret = new Object();
1726
1938
  return ret;
1727
1939
  },
1728
- __wbg_new_cdf041679ded4c5f: function() {
1729
- const ret = new Map();
1940
+ __wbg_new_ffa92086ea89f79c: function() {
1941
+ const ret = new Array();
1730
1942
  return ret;
1731
1943
  },
1732
- __wbg_new_ebe3e0f6837f0879: function() {
1733
- const ret = new Object();
1944
+ __wbg_next_95053e306b1c3aed: function(arg0) {
1945
+ const ret = arg0.next;
1734
1946
  return ret;
1735
1947
  },
1736
- __wbg_next_42cf16ee0dafc9e2: function() { return handleError(function (arg0) {
1948
+ __wbg_next_f31ecb8646d2c605: function() { return handleError(function (arg0) {
1737
1949
  const ret = arg0.next();
1738
1950
  return ret;
1739
1951
  }, arguments); },
1740
- __wbg_next_8f26b64fa5e9f64b: function(arg0) {
1741
- const ret = arg0.next;
1742
- return ret;
1743
- },
1744
- __wbg_of_598c0ff0cd48a890: function(arg0, arg1) {
1952
+ __wbg_of_1c173c2ad96e2f7e: function(arg0, arg1) {
1745
1953
  const ret = Array.of(arg0, arg1);
1746
1954
  return ret;
1747
1955
  },
1748
- __wbg_prototypesetcall_de8e0d9553586985: function(arg0, arg1, arg2) {
1956
+ __wbg_prototypesetcall_ae9f5e7459250748: function(arg0, arg1, arg2) {
1749
1957
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
1750
1958
  },
1751
- __wbg_push_adb0107829f02d75: function(arg0, arg1) {
1959
+ __wbg_push_bfdf956ba476f65b: function(arg0, arg1) {
1752
1960
  const ret = arg0.push(arg1);
1753
1961
  return ret;
1754
1962
  },
1755
- __wbg_set_014226dfeca53178: function(arg0, arg1, arg2) {
1756
- const ret = arg0.set(arg1, arg2);
1963
+ __wbg_random_7bce4e9e78e2e0d0: function() {
1964
+ const ret = Math.random();
1757
1965
  return ret;
1758
1966
  },
1967
+ __wbg_set_13d25b81ab403f5e: function(arg0, arg1, arg2) {
1968
+ arg0[arg1 >>> 0] = arg2;
1969
+ },
1759
1970
  __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
1760
1971
  arg0[arg1] = arg2;
1761
1972
  },
1762
- __wbg_set_8155bb79a948541b: function() { return handleError(function (arg0, arg1, arg2) {
1973
+ __wbg_set_a377297433dfea63: function() { return handleError(function (arg0, arg1, arg2) {
1763
1974
  const ret = Reflect.set(arg0, arg1, arg2);
1764
1975
  return ret;
1765
1976
  }, arguments); },
1766
- __wbg_set_a80955eb93b145c6: function(arg0, arg1, arg2) {
1767
- arg0[arg1 >>> 0] = arg2;
1977
+ __wbg_set_bf6dde4923b9b059: function(arg0, arg1, arg2) {
1978
+ const ret = arg0.set(arg1, arg2);
1979
+ return ret;
1768
1980
  },
1769
- __wbg_value_1e2369fab29b420e: function(arg0) {
1981
+ __wbg_value_c227f843d21da141: function(arg0) {
1770
1982
  const ret = arg0.value;
1771
1983
  return ret;
1772
1984
  },
1773
- __wbindgen_cast_0000000000000001: function(arg0) {
1985
+ __wbindgen_generic_0000000000000001: function(arg0) {
1774
1986
  // Cast intrinsic for `F64 -> Externref`.
1775
1987
  const ret = arg0;
1776
1988
  return ret;
1777
1989
  },
1778
- __wbindgen_cast_0000000000000002: function(arg0) {
1990
+ __wbindgen_generic_0000000000000002: function(arg0) {
1779
1991
  // Cast intrinsic for `I64 -> Externref`.
1780
1992
  const ret = arg0;
1781
1993
  return ret;
1782
1994
  },
1783
- __wbindgen_cast_0000000000000003: function(arg0, arg1) {
1995
+ __wbindgen_generic_0000000000000003: function(arg0, arg1) {
1784
1996
  // Cast intrinsic for `Ref(String) -> Externref`.
1785
1997
  const ret = getStringFromWasm0(arg0, arg1);
1786
1998
  return ret;
1787
1999
  },
1788
- __wbindgen_cast_0000000000000004: function(arg0) {
2000
+ __wbindgen_generic_0000000000000004: function(arg0) {
1789
2001
  // Cast intrinsic for `U64 -> Externref`.
1790
2002
  const ret = BigInt.asUintN(64, arg0);
1791
2003
  return ret;
@@ -1812,6 +2024,9 @@ const AgentFailureFinalization = (typeof FinalizationRegistry === 'undefined')
1812
2024
  const ClaimRegistryFinalization = (typeof FinalizationRegistry === 'undefined')
1813
2025
  ? { register: () => {}, unregister: () => {} }
1814
2026
  : new FinalizationRegistry(ptr => wasm.__wbg_claimregistry_free(ptr, 1));
2027
+ const DecisionRegistryFinalization = (typeof FinalizationRegistry === 'undefined')
2028
+ ? { register: () => {}, unregister: () => {} }
2029
+ : new FinalizationRegistry(ptr => wasm.__wbg_decisionregistry_free(ptr, 1));
1815
2030
  const ParticipantRosterFinalization = (typeof FinalizationRegistry === 'undefined')
1816
2031
  ? { register: () => {}, unregister: () => {} }
1817
2032
  : new FinalizationRegistry(ptr => wasm.__wbg_participantroster_free(ptr, 1));
Binary file
package/index.d.ts CHANGED
@@ -419,6 +419,56 @@ export class RoomRoster {
419
419
  clear(): string[];
420
420
  }
421
421
 
422
+ export type ClaimOutcome = "claimed" | "already_claimed" | "stale";
423
+
424
+ /** What a cancellation removed, oldest first. */
425
+ export interface CancelledDecisions {
426
+ /** Asks nobody claimed -- the caller resolves these. */
427
+ unclaimed: string[];
428
+ /** Asks whose claimant still resolves them. */
429
+ claimed: string[];
430
+ }
431
+
432
+ /**
433
+ * Pending chat-mediated asks by token, oldest first. Every registration
434
+ * returns `[token, ticket]`; later calls name that exact registration, so a
435
+ * stale holder never acts on a newer ask that reused the token.
436
+ *
437
+ * Throws if `maxPending` is not an integer in `1..=4294967295` -- a zero
438
+ * capacity would evict every ask the moment it arrives -- or if `seed` is
439
+ * not a `bigint`. Omitted or `null`, `maxPending` never evicts; omitted,
440
+ * `seed` is drawn fresh. Every `token`/`key`/`roomId` argument below throws
441
+ * a plain `Error` if it is not a string, and every `ticket` if it is not a
442
+ * `bigint`.
443
+ */
444
+ export class DecisionRegistry {
445
+ constructor(maxPending?: number | null, seed?: bigint);
446
+ readonly maxPending: number | undefined;
447
+ registerMinted(roomId?: string | null): [token: string, ticket: bigint] | undefined;
448
+ registerKeyed(key: string): [token: string, ticket: bigint] | undefined;
449
+ tryClaim(token: string, ticket: bigint): ClaimOutcome;
450
+ withdraw(token: string, ticket: bigint): boolean;
451
+ forget(token: string, ticket: bigint): boolean;
452
+ unclaimed(): string[];
453
+ unclaimedInRoom(roomId: string): string[];
454
+ unclaimedCount(): number;
455
+ oldestUnclaimed(): string | undefined;
456
+ evictOldest(): string | undefined;
457
+ cancelAll(): CancelledDecisions;
458
+ cancelRoom(roomId: string): CancelledDecisions;
459
+ }
460
+
461
+ /**
462
+ * Whether `senderId` may answer an ask: `null` admits anyone; any array or
463
+ * `Set` -- empty included -- admits only its members. Throws a plain `Error`
464
+ * if `authorizedSenders` is not an array or `Set` of strings (a bare string
465
+ * included) or `null`, or if `senderId` is not a string or `null`.
466
+ */
467
+ export function isAuthorizedSender(
468
+ authorizedSenders: readonly string[] | ReadonlySet<string> | null,
469
+ senderId: string | null,
470
+ ): boolean;
471
+
422
472
  // The one-shot delivery lifecycle decisions: evaluateDeliveryEvent,
423
473
  // evaluateNextMessage, evaluateDrainCandidate, evaluateAdapterResult.
424
474
  // Each returns a plain tagged object -- these functions carry no
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@band-ai/band-sdk-core",
3
- "version": "2.4.0",
3
+ "version": "2.6.0",
4
4
  "description": "Shared Band event-payload validation",
5
5
  "license": "MIT",
6
6
  "repository": {