@band-ai/band-sdk-core 1.0.1 → 1.2.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/band_sdk_core.js CHANGED
@@ -676,11 +676,16 @@ class SessionOutcome {
676
676
  return ret[0] === 0 ? undefined : ret[1];
677
677
  }
678
678
  /**
679
- * @returns {boolean}
679
+ * @returns {string | undefined}
680
680
  */
681
- get stale() {
682
- const ret = wasm.sessionoutcome_stale(this.__wbg_ptr);
683
- 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;
684
689
  }
685
690
  /**
686
691
  * @returns {string}
@@ -901,6 +906,17 @@ class SubscriptionTracker {
901
906
  }
902
907
  return ret[0] !== 0;
903
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
+ }
904
920
  /**
905
921
  * @param {any} room_id
906
922
  * @param {bigint} ticket
@@ -914,6 +930,17 @@ class SubscriptionTracker {
914
930
  }
915
931
  return ret[0] !== 0;
916
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
+ }
917
944
  constructor() {
918
945
  const ret = wasm.subscriptiontracker_new();
919
946
  this.__wbg_ptr = ret;
@@ -1008,6 +1035,106 @@ class SubscriptionTracker {
1008
1035
  if (Symbol.dispose) SubscriptionTracker.prototype[Symbol.dispose] = SubscriptionTracker.prototype.free;
1009
1036
  exports.SubscriptionTracker = SubscriptionTracker;
1010
1037
 
1038
+ /**
1039
+ * This platform's Phoenix Channels topic for the `agent_contacts` channel.
1040
+ * @param {any} agentId
1041
+ * @returns {string}
1042
+ */
1043
+ function agentContactsTopic(agentId) {
1044
+ let deferred2_0;
1045
+ let deferred2_1;
1046
+ try {
1047
+ const ret = wasm.agentContactsTopic(agentId);
1048
+ var ptr1 = ret[0];
1049
+ var len1 = ret[1];
1050
+ if (ret[3]) {
1051
+ ptr1 = 0; len1 = 0;
1052
+ throw takeFromExternrefTable0(ret[2]);
1053
+ }
1054
+ deferred2_0 = ptr1;
1055
+ deferred2_1 = len1;
1056
+ return getStringFromWasm0(ptr1, len1);
1057
+ } finally {
1058
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1059
+ }
1060
+ }
1061
+ exports.agentContactsTopic = agentContactsTopic;
1062
+
1063
+ /**
1064
+ * This platform's Phoenix Channels topic for the `agent_control` channel.
1065
+ * @param {any} agentId
1066
+ * @returns {string}
1067
+ */
1068
+ function agentControlTopic(agentId) {
1069
+ let deferred2_0;
1070
+ let deferred2_1;
1071
+ try {
1072
+ const ret = wasm.agentControlTopic(agentId);
1073
+ var ptr1 = ret[0];
1074
+ var len1 = ret[1];
1075
+ if (ret[3]) {
1076
+ ptr1 = 0; len1 = 0;
1077
+ throw takeFromExternrefTable0(ret[2]);
1078
+ }
1079
+ deferred2_0 = ptr1;
1080
+ deferred2_1 = len1;
1081
+ return getStringFromWasm0(ptr1, len1);
1082
+ } finally {
1083
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1084
+ }
1085
+ }
1086
+ exports.agentControlTopic = agentControlTopic;
1087
+
1088
+ /**
1089
+ * This platform's Phoenix Channels topic for the `agent_rooms` channel.
1090
+ * @param {any} agentId
1091
+ * @returns {string}
1092
+ */
1093
+ function agentRoomsTopic(agentId) {
1094
+ let deferred2_0;
1095
+ let deferred2_1;
1096
+ try {
1097
+ const ret = wasm.agentRoomsTopic(agentId);
1098
+ var ptr1 = ret[0];
1099
+ var len1 = ret[1];
1100
+ if (ret[3]) {
1101
+ ptr1 = 0; len1 = 0;
1102
+ throw takeFromExternrefTable0(ret[2]);
1103
+ }
1104
+ deferred2_0 = ptr1;
1105
+ deferred2_1 = len1;
1106
+ return getStringFromWasm0(ptr1, len1);
1107
+ } finally {
1108
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1109
+ }
1110
+ }
1111
+ exports.agentRoomsTopic = agentRoomsTopic;
1112
+
1113
+ /**
1114
+ * This platform's Phoenix Channels topic for a room's `chat_room` channel.
1115
+ * @param {any} roomId
1116
+ * @returns {string}
1117
+ */
1118
+ function chatRoomTopic(roomId) {
1119
+ let deferred2_0;
1120
+ let deferred2_1;
1121
+ try {
1122
+ const ret = wasm.chatRoomTopic(roomId);
1123
+ var ptr1 = ret[0];
1124
+ var len1 = ret[1];
1125
+ if (ret[3]) {
1126
+ ptr1 = 0; len1 = 0;
1127
+ throw takeFromExternrefTable0(ret[2]);
1128
+ }
1129
+ deferred2_0 = ptr1;
1130
+ deferred2_1 = len1;
1131
+ return getStringFromWasm0(ptr1, len1);
1132
+ } finally {
1133
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1134
+ }
1135
+ }
1136
+ exports.chatRoomTopic = chatRoomTopic;
1137
+
1011
1138
  /**
1012
1139
  * Classify a WebSocket close code. Returns `[terminal, delayRange]`.
1013
1140
  * @param {number | null} [closeCode]
@@ -1037,6 +1164,32 @@ function classifyUpgrade(status) {
1037
1164
  }
1038
1165
  exports.classifyUpgrade = classifyUpgrade;
1039
1166
 
1167
+ /**
1168
+ * This platform's Phoenix Channels topic for a room's `room_participants`
1169
+ * channel.
1170
+ * @param {any} roomId
1171
+ * @returns {string}
1172
+ */
1173
+ function roomParticipantsTopic(roomId) {
1174
+ let deferred2_0;
1175
+ let deferred2_1;
1176
+ try {
1177
+ const ret = wasm.roomParticipantsTopic(roomId);
1178
+ var ptr1 = ret[0];
1179
+ var len1 = ret[1];
1180
+ if (ret[3]) {
1181
+ ptr1 = 0; len1 = 0;
1182
+ throw takeFromExternrefTable0(ret[2]);
1183
+ }
1184
+ deferred2_0 = ptr1;
1185
+ deferred2_1 = len1;
1186
+ return getStringFromWasm0(ptr1, len1);
1187
+ } finally {
1188
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1189
+ }
1190
+ }
1191
+ exports.roomParticipantsTopic = roomParticipantsTopic;
1192
+
1040
1193
  /**
1041
1194
  * Validate and normalize an inbound platform event payload.
1042
1195
  *
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
  /**
@@ -193,13 +199,31 @@ export function classifyUpgrade(
193
199
  status: number,
194
200
  ): [boolean, [number, number] | undefined];
195
201
 
202
+ /** This platform's Phoenix Channels topic for the `agent_control` channel. */
203
+ export function agentControlTopic(agentId: string): string;
204
+
205
+ /** This platform's Phoenix Channels topic for the `agent_rooms` channel. */
206
+ export function agentRoomsTopic(agentId: string): string;
207
+
208
+ /** This platform's Phoenix Channels topic for the `agent_contacts` channel. */
209
+ export function agentContactsTopic(agentId: string): string;
210
+
211
+ /** This platform's Phoenix Channels topic for a room's `chat_room` channel. */
212
+ export function chatRoomTopic(roomId: string): string;
213
+
214
+ /**
215
+ * This platform's Phoenix Channels topic for a room's `room_participants`
216
+ * channel.
217
+ */
218
+ export function roomParticipantsTopic(roomId: string): string;
219
+
196
220
  /** The settled outcome of one {@link Session} call. */
197
221
  export class SessionOutcome {
198
222
  private constructor();
199
223
  readonly state: SessionState;
200
224
  readonly retryAfterS: number | undefined;
201
225
  readonly deadReason: DeadReason | undefined;
202
- readonly stale: boolean;
226
+ readonly staleReason: StaleReason | undefined;
203
227
  }
204
228
 
205
229
  /** {@link SessionPolicy}'s constructor fields. */
@@ -285,6 +309,7 @@ export class SubscriptionTracker {
285
309
  unsubscribeRoom(roomId: string): bigint | undefined;
286
310
  markRoomLeaveComplete(roomId: string, ticket: bigint, outcome: LeaveOutcome): boolean;
287
311
  acknowledgeRoomReconciled(roomId: string): boolean;
312
+ markRoomRejoinFailed(roomId: string): boolean;
288
313
  subscribedRoomIds(): string[];
289
314
  onReconnected(): void;
290
315
  endSession(): void;
@@ -296,6 +321,7 @@ export class SubscriptionTracker {
296
321
  leaveAgentTopic(topic: string): bigint | undefined;
297
322
  markAgentTopicLeaveComplete(topic: string, ticket: bigint, outcome: LeaveOutcome): boolean;
298
323
  acknowledgeAgentTopicReconciled(topic: string): boolean;
324
+ markAgentTopicRejoinFailed(topic: string): boolean;
299
325
  joinedAgentTopics(): string[];
300
326
  }
301
327
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@band-ai/band-sdk-core",
3
- "version": "1.0.1",
3
+ "version": "1.2.0",
4
4
  "description": "Shared Band event-payload validation",
5
5
  "license": "MIT",
6
6
  "repository": {