@band-ai/band-sdk-core 2.1.0 → 2.3.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 +6 -0
- package/band_sdk_core.js +128 -0
- package/band_sdk_core_bg.wasm +0 -0
- package/index.d.ts +33 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -193,6 +193,12 @@ classifies one candidate per call.
|
|
|
193
193
|
`evaluateAdapterResult(roomId, messageId, succeeded)` maps an adapter
|
|
194
194
|
outcome to `"processed"` or `"failed"`.
|
|
195
195
|
|
|
196
|
+
`isSelfEcho(senderId, senderType, agentId)` is the one definition of
|
|
197
|
+
"self echo" (`senderType === "Agent" && senderId === agentId`) that
|
|
198
|
+
`evaluateDeliveryEvent` and `evaluateDrainCandidate` use internally,
|
|
199
|
+
exposed for a host's own call sites that classify a sender without going
|
|
200
|
+
through either function.
|
|
201
|
+
|
|
196
202
|
The public declaration is
|
|
197
203
|
[`index.d.ts`](https://github.com/band-ai/band-sdk-core/blob/main/crates/wasm/index.d.ts).
|
|
198
204
|
|
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,
|
|
@@ -1282,6 +1387,26 @@ function evaluateNextMessage(triggeringMessageId, nextMessageId) {
|
|
|
1282
1387
|
}
|
|
1283
1388
|
exports.evaluateNextMessage = evaluateNextMessage;
|
|
1284
1389
|
|
|
1390
|
+
/**
|
|
1391
|
+
* The one definition of "self echo" (`senderType === "Agent" &&
|
|
1392
|
+
* senderId === agentId`), shared by `evaluateDeliveryEvent` and
|
|
1393
|
+
* `evaluateDrainCandidate` internally and exposed here for a host's own
|
|
1394
|
+
* call sites that don't go through either. Throws a plain `Error` if
|
|
1395
|
+
* `senderId`/`senderType`/`agentId` is not a string.
|
|
1396
|
+
* @param {any} senderId
|
|
1397
|
+
* @param {any} senderType
|
|
1398
|
+
* @param {any} agentId
|
|
1399
|
+
* @returns {boolean}
|
|
1400
|
+
*/
|
|
1401
|
+
function isSelfEcho(senderId, senderType, agentId) {
|
|
1402
|
+
const ret = wasm.isSelfEcho(senderId, senderType, agentId);
|
|
1403
|
+
if (ret[2]) {
|
|
1404
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1405
|
+
}
|
|
1406
|
+
return ret[0] !== 0;
|
|
1407
|
+
}
|
|
1408
|
+
exports.isSelfEcho = isSelfEcho;
|
|
1409
|
+
|
|
1285
1410
|
/**
|
|
1286
1411
|
* This platform's Phoenix Channels topic for a room's `room_participants`
|
|
1287
1412
|
* channel.
|
|
@@ -1609,6 +1734,9 @@ function __wbg_get_imports() {
|
|
|
1609
1734
|
};
|
|
1610
1735
|
}
|
|
1611
1736
|
|
|
1737
|
+
const AgentFailureFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1738
|
+
? { register: () => {}, unregister: () => {} }
|
|
1739
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_agentfailure_free(ptr, 1));
|
|
1612
1740
|
const ClaimRegistryFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1613
1741
|
? { register: () => {}, unregister: () => {} }
|
|
1614
1742
|
: new FinalizationRegistry(ptr => wasm.__wbg_claimregistry_free(ptr, 1));
|
package/band_sdk_core_bg.wasm
CHANGED
|
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"
|
|
@@ -500,3 +524,12 @@ export function evaluateAdapterResult(
|
|
|
500
524
|
messageId: string,
|
|
501
525
|
succeeded: boolean,
|
|
502
526
|
): AckDecision;
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* The one definition of "self echo" (`senderType === "Agent" &&
|
|
530
|
+
* senderId === agentId`), shared by {@link evaluateDeliveryEvent} and
|
|
531
|
+
* {@link evaluateDrainCandidate} internally and exposed here for a host's
|
|
532
|
+
* own call sites that don't go through either. Throws a plain `Error` if
|
|
533
|
+
* `senderId`/`senderType`/`agentId` is not a string.
|
|
534
|
+
*/
|
|
535
|
+
export function isSelfEcho(senderId: string, senderType: string, agentId: string): boolean;
|