@band-ai/band-sdk-core 1.0.0 → 1.1.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
@@ -55,8 +55,8 @@ exception class.
55
55
  ### Delivery-state runtime classes
56
56
 
57
57
  `ClaimRegistry`, `RetryTracker`, `ParticipantRoster`, and `SubscriptionTracker` are the
58
- inbound-delivery runtime state classes — lifecycle and design decisions:
59
- [`runtime-state-policy.md`](https://github.com/band-ai/band-sdk-core/blob/main/crates/core/docs/runtime-state-policy.md).
58
+ inbound-delivery runtime state classes — lifecycle and design decisions
59
+ live as rustdoc on each type in `crates/core/src/runtime/`.
60
60
 
61
61
  A participant is any plain object; `add`/`setAll` read `id`, `name`,
62
62
  `type`, `handle`, `description` from it and `list()` returns objects with
@@ -115,10 +115,8 @@ classify a WebSocket close code or HTTP upgrade-rejection status.
115
115
  `Session` never sleeps, connects, or closes a socket itself — the caller
116
116
  drives its own transport and reports what happened through `onConnected`/
117
117
  `onSocketClose`/`onUpgradeRejected`/`onSupersede`. Its epoch tickets are
118
- JavaScript `bigint` values, matching `SubscriptionTracker`'s. Confirmed
119
- decisions:
120
- [`runtime-state-policy.md`](https://github.com/band-ai/band-sdk-core/blob/main/crates/core/docs/runtime-state-policy.md)'s
121
- `## Session` section.
118
+ JavaScript `bigint` values, matching `SubscriptionTracker`'s. Decisions
119
+ live as rustdoc in `crates/core/src/runtime/session.rs`.
122
120
 
123
121
  ### `Session` lifecycle
124
122
 
@@ -139,8 +137,8 @@ if (disconnected.retryAfterS === undefined) throw new Error("expected a retry de
139
137
 
140
138
  ### `validateMemoryTypeForSystem(system, type, traceContext?)`
141
139
 
142
- Validates the canonical memory taxonomy — design decisions:
143
- [`memory-taxonomy-policy.md`](https://github.com/band-ai/band-sdk-core/blob/main/crates/core/docs/memory-taxonomy-policy.md).
140
+ Validates the canonical memory taxonomy — design decisions live as
141
+ rustdoc in `crates/core/src/memory.rs`.
144
142
  `system` and `type` are wire-name strings (`MemorySystem`/`MemoryType` in
145
143
  `index.d.ts` are string-literal types, not classes — there is no runtime
146
144
  enum on this boundary, matching how `EventType` stays a plain string in
package/band_sdk_core.js CHANGED
@@ -513,8 +513,7 @@ if (Symbol.dispose) RoomRoster.prototype[Symbol.dispose] = RoomRoster.prototype.
513
513
  exports.RoomRoster = RoomRoster;
514
514
 
515
515
  /**
516
- * One WebSocket session's state machine. Behavior contract:
517
- * `docs/runtime-state-policy.md`'s `## Session` section.
516
+ * One WebSocket session's state machine.
518
517
  */
519
518
  class Session {
520
519
  __destroy_into_raw() {
@@ -677,11 +676,16 @@ class SessionOutcome {
677
676
  return ret[0] === 0 ? undefined : ret[1];
678
677
  }
679
678
  /**
680
- * @returns {boolean}
679
+ * @returns {string | undefined}
681
680
  */
682
- get stale() {
683
- const ret = wasm.sessionoutcome_stale(this.__wbg_ptr);
684
- return ret !== 0;
681
+ get staleReason() {
682
+ const ret = wasm.sessionoutcome_staleReason(this.__wbg_ptr);
683
+ let v1;
684
+ if (ret[0] !== 0) {
685
+ v1 = getStringFromWasm0(ret[0], ret[1]);
686
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
687
+ }
688
+ return v1;
685
689
  }
686
690
  /**
687
691
  * @returns {string}
@@ -704,8 +708,7 @@ exports.SessionOutcome = SessionOutcome;
704
708
 
705
709
  /**
706
710
  * Reconnect backoff/jitter policy, plus the graduated rapid-disconnect
707
- * cooldown ladder. Behavior contract: `docs/runtime-state-policy.md`'s
708
- * `## Session` section.
711
+ * cooldown ladder.
709
712
  */
710
713
  class SessionPolicy {
711
714
  static __wrap(ptr) {
@@ -903,6 +906,17 @@ class SubscriptionTracker {
903
906
  }
904
907
  return ret[0] !== 0;
905
908
  }
909
+ /**
910
+ * @param {any} topic
911
+ * @returns {boolean}
912
+ */
913
+ markAgentTopicRejoinFailed(topic) {
914
+ const ret = wasm.subscriptiontracker_markAgentTopicRejoinFailed(this.__wbg_ptr, topic);
915
+ if (ret[2]) {
916
+ throw takeFromExternrefTable0(ret[1]);
917
+ }
918
+ return ret[0] !== 0;
919
+ }
906
920
  /**
907
921
  * @param {any} room_id
908
922
  * @param {bigint} ticket
@@ -916,6 +930,17 @@ class SubscriptionTracker {
916
930
  }
917
931
  return ret[0] !== 0;
918
932
  }
933
+ /**
934
+ * @param {any} room_id
935
+ * @returns {boolean}
936
+ */
937
+ markRoomRejoinFailed(room_id) {
938
+ const ret = wasm.subscriptiontracker_markRoomRejoinFailed(this.__wbg_ptr, room_id);
939
+ if (ret[2]) {
940
+ throw takeFromExternrefTable0(ret[1]);
941
+ }
942
+ return ret[0] !== 0;
943
+ }
919
944
  constructor() {
920
945
  const ret = wasm.subscriptiontracker_new();
921
946
  this.__wbg_ptr = ret;
Binary file
package/index.d.ts CHANGED
@@ -173,6 +173,12 @@ export type SessionState = "connecting" | "up" | "reconnecting" | "dead";
173
173
 
174
174
  export type DeadReason = "classified" | "rapid_disconnect";
175
175
 
176
+ export type StaleReason =
177
+ | "wrong_epoch"
178
+ | "clock_regression"
179
+ | "duplicate_connected"
180
+ | "supersede_predates_epoch";
181
+
176
182
  export type RoomMembership = "unadmitted" | "admitting" | "admitted";
177
183
 
178
184
  /**
@@ -199,7 +205,7 @@ export class SessionOutcome {
199
205
  readonly state: SessionState;
200
206
  readonly retryAfterS: number | undefined;
201
207
  readonly deadReason: DeadReason | undefined;
202
- readonly stale: boolean;
208
+ readonly staleReason: StaleReason | undefined;
203
209
  }
204
210
 
205
211
  /** {@link SessionPolicy}'s constructor fields. */
@@ -220,8 +226,7 @@ export interface SessionPolicyConfig {
220
226
 
221
227
  /**
222
228
  * Reconnect backoff/jitter policy, plus the graduated rapid-disconnect
223
- * cooldown ladder. A recommended, not final, starting design -- see
224
- * `docs/runtime-state-policy.md`'s `## Session` section.
229
+ * cooldown ladder. A recommended, not final, starting design.
225
230
  *
226
231
  * Throws a native `Error` with `.issues`/`.traceContext` if `factor < 1.0`
227
232
  * or `baseDelayS > maxDelayS`. Throws a plain `Error` if `config` is
@@ -286,6 +291,7 @@ export class SubscriptionTracker {
286
291
  unsubscribeRoom(roomId: string): bigint | undefined;
287
292
  markRoomLeaveComplete(roomId: string, ticket: bigint, outcome: LeaveOutcome): boolean;
288
293
  acknowledgeRoomReconciled(roomId: string): boolean;
294
+ markRoomRejoinFailed(roomId: string): boolean;
289
295
  subscribedRoomIds(): string[];
290
296
  onReconnected(): void;
291
297
  endSession(): void;
@@ -297,6 +303,7 @@ export class SubscriptionTracker {
297
303
  leaveAgentTopic(topic: string): bigint | undefined;
298
304
  markAgentTopicLeaveComplete(topic: string, ticket: bigint, outcome: LeaveOutcome): boolean;
299
305
  acknowledgeAgentTopicReconciled(topic: string): boolean;
306
+ markAgentTopicRejoinFailed(topic: string): boolean;
300
307
  joinedAgentTopics(): string[];
301
308
  }
302
309
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@band-ai/band-sdk-core",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Shared Band event-payload validation",
5
5
  "license": "MIT",
6
6
  "repository": {