@memberjunction/realtime-widget 6.3.0-edge.1 → 6.3.0-edge.3
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/dist/embed/chunks/UserViewEngine-AQ4HVXDY.js +7 -0
- package/dist/embed/chunks/{chunk-KHEWGJIZ.js → chunk-CUZ32HGY.js} +4 -0
- package/dist/embed/chunks/{chunk-CIZSPKQR.js → chunk-IHM3SRNY.js} +777 -152
- package/dist/embed/chunks/{chunk-SXFIY47F.js → chunk-P3UR75T6.js} +81327 -52820
- package/dist/embed/chunks/{chunk-6RWWXOZB.js → chunk-VCGHPATD.js} +3179 -199
- package/dist/embed/chunks/{chunk-AJBMDBQR.js → chunk-YDXL5TNM.js} +3173 -303
- package/dist/embed/chunks/{dist-L2XMFU32.js → dist-JBQFIDL4.js} +5 -5
- package/dist/embed/chunks/{guest-tool-relay-JGHE3J5R.js → guest-tool-relay-INT64GMC.js} +4 -4
- package/dist/embed/chunks/{guest-voice-mint-I6KQRNKA.js → guest-voice-mint-G7TM5WCO.js} +4 -4
- package/dist/embed/chunks/{realtime-voice-controller-Z75RH5BM.js → realtime-voice-controller-ZWPWPCU6.js} +320 -28
- package/dist/embed/chunks/{runtime-widget-transport-UXJAHD5F.js → runtime-widget-transport-HC7OF453.js} +10 -10
- package/dist/embed/mj-widget.js +6 -6
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -9
- package/dist/embed/chunks/UserViewEngine-EEVXGC4A.js +0 -7
|
@@ -28,11 +28,11 @@ import {
|
|
|
28
28
|
SessionCardStatusChip,
|
|
29
29
|
SessionCardTitle,
|
|
30
30
|
SessionsObserver
|
|
31
|
-
} from "./chunk-
|
|
32
|
-
import "./chunk-
|
|
33
|
-
import "./chunk-
|
|
34
|
-
import "./chunk-
|
|
35
|
-
import "./chunk-
|
|
31
|
+
} from "./chunk-YDXL5TNM.js";
|
|
32
|
+
import "./chunk-P3UR75T6.js";
|
|
33
|
+
import "./chunk-VCGHPATD.js";
|
|
34
|
+
import "./chunk-IHM3SRNY.js";
|
|
35
|
+
import "./chunk-CUZ32HGY.js";
|
|
36
36
|
export {
|
|
37
37
|
BuildConversationTimeline,
|
|
38
38
|
ClientToolRegistry,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
g
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-P3UR75T6.js";
|
|
4
|
+
import "./chunk-VCGHPATD.js";
|
|
5
|
+
import "./chunk-IHM3SRNY.js";
|
|
6
|
+
import "./chunk-CUZ32HGY.js";
|
|
7
7
|
|
|
8
8
|
// dist/voice/guest-tool-relay.js
|
|
9
9
|
var EXECUTE_TOOL_MUTATION = `
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
g
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-P3UR75T6.js";
|
|
4
|
+
import "./chunk-VCGHPATD.js";
|
|
5
5
|
import {
|
|
6
6
|
ParseRealtimeClientTransport
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-IHM3SRNY.js";
|
|
8
|
+
import "./chunk-CUZ32HGY.js";
|
|
9
9
|
|
|
10
10
|
// dist/voice/guest-voice-mint.js
|
|
11
11
|
var MINT_FIELDS = ["AgentSessionId", "Provider", "Model", "EphemeralToken", "ExpiresAt", "SessionConfigJson"];
|
|
@@ -40,14 +40,14 @@ import {
|
|
|
40
40
|
VideoSourceSeenNote,
|
|
41
41
|
VideoSourceTurnedOffNote,
|
|
42
42
|
VideoSourceTurnedOnNote
|
|
43
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-IHM3SRNY.js";
|
|
44
44
|
import {
|
|
45
45
|
BaseSingleton,
|
|
46
46
|
MJGlobal,
|
|
47
47
|
RegisterClass,
|
|
48
48
|
__commonJS,
|
|
49
49
|
__toESM
|
|
50
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-CUZ32HGY.js";
|
|
51
51
|
|
|
52
52
|
// ../../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js
|
|
53
53
|
var require_retry_operation = __commonJS({
|
|
@@ -1050,6 +1050,14 @@ var BaseRealtimeClient = class _BaseRealtimeClient {
|
|
|
1050
1050
|
get RequiresFreshTokenPerReconnect() {
|
|
1051
1051
|
return true;
|
|
1052
1052
|
}
|
|
1053
|
+
/**
|
|
1054
|
+
* Whether a credential is minted ahead, shortly before the current one expires, for the next reconnect to use.
|
|
1055
|
+
* `false` for a driver whose credential only opens one connection, which outlives it: each reconnect mints its own,
|
|
1056
|
+
* so one minted ahead is never used.
|
|
1057
|
+
*/
|
|
1058
|
+
get RefreshesCredentialAhead() {
|
|
1059
|
+
return true;
|
|
1060
|
+
}
|
|
1053
1061
|
/**
|
|
1054
1062
|
* How many connections `credential` may open, or `undefined` for no limit (the default). A driver whose provider
|
|
1055
1063
|
* counts uses on a credential overrides it, so the client re-mints before it would open a connection the
|
|
@@ -1142,7 +1150,7 @@ var BaseRealtimeClient = class _BaseRealtimeClient {
|
|
|
1142
1150
|
return this.currentCredential;
|
|
1143
1151
|
}
|
|
1144
1152
|
scheduleCredentialRefresh() {
|
|
1145
|
-
if (!this.SupportsMidCallReconnect || !this.tokenRefreshCallback || this.reconnectController.IsDisposed) {
|
|
1153
|
+
if (!this.RefreshesCredentialAhead || !this.SupportsMidCallReconnect || !this.tokenRefreshCallback || this.reconnectController.IsDisposed) {
|
|
1146
1154
|
return;
|
|
1147
1155
|
}
|
|
1148
1156
|
this.reconnectController.ScheduleCredentialRefresh(this.currentCredential.ExpiresAt, () => {
|
|
@@ -27783,6 +27791,10 @@ var GeminiRealtimeClient = class GeminiRealtimeClient2 extends BaseRealtimeClien
|
|
|
27783
27791
|
this.interactionInProgress = false;
|
|
27784
27792
|
this.toolBatchBarrier = new RealtimeToolBatchBarrier();
|
|
27785
27793
|
this.assistantSafetyBackstopTimer = null;
|
|
27794
|
+
this.blockingBatchOwed = /* @__PURE__ */ new Set();
|
|
27795
|
+
this.blockingBatchExpired = /* @__PURE__ */ new Set();
|
|
27796
|
+
this.blockingBatchStarted = false;
|
|
27797
|
+
this.blockingBatchCommitHeld = false;
|
|
27786
27798
|
this.pendingAssistantText = "";
|
|
27787
27799
|
this.pendingUserText = "";
|
|
27788
27800
|
this.pendingThoughtText = "";
|
|
@@ -27801,6 +27813,9 @@ var GeminiRealtimeClient = class GeminiRealtimeClient2 extends BaseRealtimeClien
|
|
|
27801
27813
|
static {
|
|
27802
27814
|
this.ASSISTANT_SAFETY_BACKSTOP_MS = 15e3;
|
|
27803
27815
|
}
|
|
27816
|
+
static {
|
|
27817
|
+
this.BLOCKING_TOOL_REPLY_BACKSTOP_MS = 1e4;
|
|
27818
|
+
}
|
|
27804
27819
|
static {
|
|
27805
27820
|
this.GEMINI_LIVE_CONNECTION_SECONDS = 600;
|
|
27806
27821
|
}
|
|
@@ -27906,6 +27921,14 @@ var GeminiRealtimeClient = class GeminiRealtimeClient2 extends BaseRealtimeClien
|
|
|
27906
27921
|
get isNonBlocking() {
|
|
27907
27922
|
return !this.supportsBlocking;
|
|
27908
27923
|
}
|
|
27924
|
+
/**
|
|
27925
|
+
* Whether tool-call frames are tracked as blocking batches: blocking tooling on the `turnComplete`
|
|
27926
|
+
* idle signal. Gemini waits for every result of a frame before it answers, while one result marks
|
|
27927
|
+
* the client busy for the reply.
|
|
27928
|
+
*/
|
|
27929
|
+
get tracksBlockingBatch() {
|
|
27930
|
+
return !this.isNonBlocking && this.idleSignal === "turnComplete";
|
|
27931
|
+
}
|
|
27909
27932
|
// ── BaseRealtimeClient: connection lifecycle ───────────────────────────────
|
|
27910
27933
|
/**
|
|
27911
27934
|
* Opens the client-direct Gemini Live session: creates the playout engine, connects with
|
|
@@ -27964,6 +27987,7 @@ var GeminiRealtimeClient = class GeminiRealtimeClient2 extends BaseRealtimeClien
|
|
|
27964
27987
|
this.cameraStream = cameraStream ?? null;
|
|
27965
27988
|
this.clearSafetyBackstop();
|
|
27966
27989
|
this.toolBatchBarrier.Clear();
|
|
27990
|
+
this.closeBlockingBatch();
|
|
27967
27991
|
this.firstVideoSendTimestamp = 0;
|
|
27968
27992
|
this.lastVideoSendTimestamp = 0;
|
|
27969
27993
|
this.videoFramesSent = 0;
|
|
@@ -28329,7 +28353,8 @@ var GeminiRealtimeClient = class GeminiRealtimeClient2 extends BaseRealtimeClien
|
|
|
28329
28353
|
return false;
|
|
28330
28354
|
}
|
|
28331
28355
|
const name = this.pendingToolCallNames.get(callID) ?? "";
|
|
28332
|
-
|
|
28356
|
+
const waitsForTurn = !this.isNonBlocking && !this.skipsTurnWaitInBatch(callID);
|
|
28357
|
+
this.enqueueOrRun(() => this.sendToolResponseTurn(callID, name, outputJson), waitsForTurn, callID);
|
|
28333
28358
|
}
|
|
28334
28359
|
/**
|
|
28335
28360
|
* Mutes / unmutes by toggling the mic tracks' `enabled` flag: the capture pipeline stays
|
|
@@ -28726,6 +28751,7 @@ var GeminiRealtimeClient = class GeminiRealtimeClient2 extends BaseRealtimeClien
|
|
|
28726
28751
|
if (this.sendHeldMicAudio()) {
|
|
28727
28752
|
this.noteUnansweredSpeech();
|
|
28728
28753
|
}
|
|
28754
|
+
this.releaseHeldBatchCommitAfterMove();
|
|
28729
28755
|
this.flushQueuedSends();
|
|
28730
28756
|
return true;
|
|
28731
28757
|
}
|
|
@@ -28815,6 +28841,7 @@ var GeminiRealtimeClient = class GeminiRealtimeClient2 extends BaseRealtimeClien
|
|
|
28815
28841
|
for (const callID of this.pendingToolCallNames.keys()) {
|
|
28816
28842
|
this.callsFromBeforeReseed.add(callID);
|
|
28817
28843
|
}
|
|
28844
|
+
this.closeBlockingBatch();
|
|
28818
28845
|
}
|
|
28819
28846
|
if (!handle && context.ConversationSeed && context.ConversationSeed.Entries.length > 0) {
|
|
28820
28847
|
if (target.Transport === "relay") {
|
|
@@ -28922,6 +28949,7 @@ var GeminiRealtimeClient = class GeminiRealtimeClient2 extends BaseRealtimeClien
|
|
|
28922
28949
|
this.connectionReady = true;
|
|
28923
28950
|
this.setState("listening");
|
|
28924
28951
|
this.sendHeldMicAudio();
|
|
28952
|
+
this.releaseHeldBatchCommitAfterMove();
|
|
28925
28953
|
this.flushQueuedSends();
|
|
28926
28954
|
}
|
|
28927
28955
|
/** Every resume attempt failed: the session ends with a fatal error. */
|
|
@@ -28964,8 +28992,8 @@ var GeminiRealtimeClient = class GeminiRealtimeClient2 extends BaseRealtimeClien
|
|
|
28964
28992
|
this.scheduleSafetyBackstop();
|
|
28965
28993
|
}
|
|
28966
28994
|
} else if (status === "IDLE") {
|
|
28967
|
-
this.clearSafetyBackstop();
|
|
28968
28995
|
if (this.idleSignal === "interactionStatus") {
|
|
28996
|
+
this.clearSafetyBackstop();
|
|
28969
28997
|
this.handleIdleTerminal();
|
|
28970
28998
|
} else {
|
|
28971
28999
|
this.interactionInProgress = false;
|
|
@@ -29145,6 +29173,9 @@ var GeminiRealtimeClient = class GeminiRealtimeClient2 extends BaseRealtimeClien
|
|
|
29145
29173
|
}
|
|
29146
29174
|
for (const part of modelTurn.parts) {
|
|
29147
29175
|
if (part.thought && part.text) {
|
|
29176
|
+
if (this.tracksBlockingBatch && this.assistantSafetyBackstopTimer) {
|
|
29177
|
+
this.scheduleSafetyBackstop(GeminiRealtimeClient_1.BLOCKING_TOOL_REPLY_BACKSTOP_MS);
|
|
29178
|
+
}
|
|
29148
29179
|
this.pendingThoughtText += part.text;
|
|
29149
29180
|
this.emitTranscript({
|
|
29150
29181
|
Role: "Assistant",
|
|
@@ -29212,7 +29243,12 @@ var GeminiRealtimeClient = class GeminiRealtimeClient2 extends BaseRealtimeClien
|
|
|
29212
29243
|
if (this.currentState === "speaking") {
|
|
29213
29244
|
this.currentState = "connected";
|
|
29214
29245
|
}
|
|
29215
|
-
this.
|
|
29246
|
+
if (!this.blockingBatchInProgress) {
|
|
29247
|
+
this.responseActive = false;
|
|
29248
|
+
}
|
|
29249
|
+
}
|
|
29250
|
+
if (this.tracksBlockingBatch) {
|
|
29251
|
+
this.openBlockingBatch(functionCalls.map((call) => call.id ?? ""));
|
|
29216
29252
|
}
|
|
29217
29253
|
for (const call of functionCalls) {
|
|
29218
29254
|
const callID = call.id ?? "";
|
|
@@ -29239,10 +29275,12 @@ var GeminiRealtimeClient = class GeminiRealtimeClient2 extends BaseRealtimeClien
|
|
|
29239
29275
|
this.finalizeAssistantTranscript();
|
|
29240
29276
|
this.finalizeThoughtTranscript();
|
|
29241
29277
|
if (this.idleSignal === "turnComplete") {
|
|
29278
|
+
this.clearSafetyBackstop();
|
|
29242
29279
|
this.endTurnUnlessToolCallPending();
|
|
29243
29280
|
this.responseActive = false;
|
|
29244
29281
|
this.activeResponseKind = "normal";
|
|
29245
29282
|
this.openClientTurn = false;
|
|
29283
|
+
this.blockingBatchCommitHeld = false;
|
|
29246
29284
|
this.flushQueuedSends();
|
|
29247
29285
|
if (this.currentState === "speaking") {
|
|
29248
29286
|
this.setState("listening");
|
|
@@ -29264,11 +29302,15 @@ var GeminiRealtimeClient = class GeminiRealtimeClient2 extends BaseRealtimeClien
|
|
|
29264
29302
|
this.finalizeAssistantTranscript();
|
|
29265
29303
|
this.activeResponseKind = "normal";
|
|
29266
29304
|
this.finalizeThoughtTranscript();
|
|
29267
|
-
|
|
29268
|
-
|
|
29305
|
+
const keepBatchCommitForMove = this.blockingBatchCommitHeld && this.openClientTurn && !this.connectionReady;
|
|
29306
|
+
if (!keepBatchCommitForMove) {
|
|
29307
|
+
if (this.openClientTurn && (this.toolResponseAwaitsCommit || this.blockingBatchCommitHeld)) {
|
|
29308
|
+
this.session?.sendClientContent({ turnComplete: true });
|
|
29309
|
+
}
|
|
29310
|
+
this.openClientTurn = false;
|
|
29311
|
+
this.toolResponseAwaitsCommit = false;
|
|
29312
|
+
this.blockingBatchCommitHeld = false;
|
|
29269
29313
|
}
|
|
29270
|
-
this.openClientTurn = false;
|
|
29271
|
-
this.toolResponseAwaitsCommit = false;
|
|
29272
29314
|
this.flushQueuedSends();
|
|
29273
29315
|
if (this.currentState === "speaking" && !this.IsAudioPlaying) {
|
|
29274
29316
|
this.setState("listening");
|
|
@@ -29285,6 +29327,8 @@ var GeminiRealtimeClient = class GeminiRealtimeClient2 extends BaseRealtimeClien
|
|
|
29285
29327
|
if (this.idleSignal === "interactionStatus") {
|
|
29286
29328
|
this.interactionInProgress = true;
|
|
29287
29329
|
this.scheduleSafetyBackstop();
|
|
29330
|
+
} else {
|
|
29331
|
+
this.clearSafetyBackstop();
|
|
29288
29332
|
}
|
|
29289
29333
|
if (this.currentState !== "speaking") {
|
|
29290
29334
|
this.setState("speaking");
|
|
@@ -29381,11 +29425,12 @@ var GeminiRealtimeClient = class GeminiRealtimeClient2 extends BaseRealtimeClien
|
|
|
29381
29425
|
*
|
|
29382
29426
|
* @param send The send.
|
|
29383
29427
|
* @param waitsForTurn Whether the send waits for a turn in flight (`false` for a non-blocking
|
|
29384
|
-
* tool result, which goes out while the model talks).
|
|
29428
|
+
* tool result, which goes out while the model talks, and for a blocking batch's later results).
|
|
29429
|
+
* @param toolCallID The call a tool-result send answers, so {@link drainBlockingBatchResults} can find it.
|
|
29385
29430
|
*/
|
|
29386
|
-
enqueueOrRun(send, waitsForTurn = true) {
|
|
29431
|
+
enqueueOrRun(send, waitsForTurn = true, toolCallID) {
|
|
29387
29432
|
if (!this.connectionReady || waitsForTurn && this.responseActive) {
|
|
29388
|
-
this.queuedSends.push(send);
|
|
29433
|
+
this.queuedSends.push({ Run: send, ToolCallID: toolCallID });
|
|
29389
29434
|
return;
|
|
29390
29435
|
}
|
|
29391
29436
|
send();
|
|
@@ -29398,9 +29443,91 @@ var GeminiRealtimeClient = class GeminiRealtimeClient2 extends BaseRealtimeClien
|
|
|
29398
29443
|
flushQueuedSends() {
|
|
29399
29444
|
while (!this.responseActive && this.connectionReady && this.queuedSends.length > 0) {
|
|
29400
29445
|
const send = this.queuedSends.shift();
|
|
29401
|
-
send?.();
|
|
29446
|
+
send?.Run();
|
|
29447
|
+
}
|
|
29448
|
+
}
|
|
29449
|
+
// ── Blocking tool-call batch (see tracksBlockingBatch) ─────────────────────
|
|
29450
|
+
/** A `toolCall` frame: open a batch, or join the open one while its results are still owed. */
|
|
29451
|
+
openBlockingBatch(callIDs) {
|
|
29452
|
+
this.clearSafetyBackstop();
|
|
29453
|
+
this.blockingBatchExpired.clear();
|
|
29454
|
+
if (this.blockingBatchOwed.size === 0) {
|
|
29455
|
+
this.blockingBatchStarted = false;
|
|
29456
|
+
}
|
|
29457
|
+
for (const callID of callIDs) {
|
|
29458
|
+
this.blockingBatchOwed.add(callID);
|
|
29459
|
+
}
|
|
29460
|
+
}
|
|
29461
|
+
/**
|
|
29462
|
+
* Whether a blocking result goes out without waiting for the turn in flight: once the batch's first result
|
|
29463
|
+
* went out (and marked the client busy for the reply), the batch's other results do; so does a late result of
|
|
29464
|
+
* a batch the barrier expired. Before the first result nothing skips, so a user turn that took the floor first
|
|
29465
|
+
* keeps it. A call from before a re-seed never skips: its late result starts a reply of its own.
|
|
29466
|
+
*/
|
|
29467
|
+
skipsTurnWaitInBatch(callID) {
|
|
29468
|
+
if (!this.tracksBlockingBatch || this.callsFromBeforeReseed.has(callID)) {
|
|
29469
|
+
return false;
|
|
29470
|
+
}
|
|
29471
|
+
return this.blockingBatchStarted && this.blockingBatchOwed.has(callID) || this.blockingBatchExpired.has(callID);
|
|
29472
|
+
}
|
|
29473
|
+
/**
|
|
29474
|
+
* Whether the open batch still owes results other than this call's, so the reply is not next yet. Only OTHER
|
|
29475
|
+
* owed calls count: a result the batch does not owe (a duplicate, or a stale result of an expired batch) does not
|
|
29476
|
+
* complete it.
|
|
29477
|
+
*/
|
|
29478
|
+
batchOwesOtherResults(callID) {
|
|
29479
|
+
return this.blockingBatchOwed.size - (this.blockingBatchOwed.has(callID) ? 1 : 0) > 0;
|
|
29480
|
+
}
|
|
29481
|
+
/** A started batch still owes results: the reply comes after them, so the client stays busy for it. */
|
|
29482
|
+
get blockingBatchInProgress() {
|
|
29483
|
+
return this.tracksBlockingBatch && this.blockingBatchStarted && this.blockingBatchOwed.size > 0;
|
|
29484
|
+
}
|
|
29485
|
+
/** A queued send is a batch result that skips the turn wait (see {@link drainBlockingBatchResults}). */
|
|
29486
|
+
isQueuedBatchResult(send) {
|
|
29487
|
+
return send.ToolCallID !== void 0 && this.skipsTurnWaitInBatch(send.ToolCallID);
|
|
29488
|
+
}
|
|
29489
|
+
/**
|
|
29490
|
+
* Whether a batch result other than this call's is still queued and about to be drained (the barrier expired the
|
|
29491
|
+
* batch, or results were queued while the session moved): the commit waits for the last of them.
|
|
29492
|
+
*/
|
|
29493
|
+
batchResultQueuedAfter(callID) {
|
|
29494
|
+
return this.queuedSends.some((send) => send.ToolCallID !== callID && this.isQueuedBatchResult(send));
|
|
29495
|
+
}
|
|
29496
|
+
/**
|
|
29497
|
+
* A blocking result went out: when the batch still owes results, send the ones already queued (only those,
|
|
29498
|
+
* in queue order); when it is complete, arm the no-output backstop for the reply.
|
|
29499
|
+
*/
|
|
29500
|
+
afterBlockingResult(callID) {
|
|
29501
|
+
if (!this.tracksBlockingBatch) {
|
|
29502
|
+
return;
|
|
29503
|
+
}
|
|
29504
|
+
this.blockingBatchExpired.delete(callID);
|
|
29505
|
+
if (this.blockingBatchOwed.delete(callID) && this.blockingBatchOwed.size > 0) {
|
|
29506
|
+
this.blockingBatchStarted = true;
|
|
29507
|
+
}
|
|
29508
|
+
this.drainBlockingBatchResults();
|
|
29509
|
+
if (this.blockingBatchOwed.size === 0 && this.responseActive) {
|
|
29510
|
+
this.scheduleSafetyBackstop(GeminiRealtimeClient_1.BLOCKING_TOOL_REPLY_BACKSTOP_MS);
|
|
29511
|
+
}
|
|
29512
|
+
}
|
|
29513
|
+
/** Sends the batch's queued results in queue order; every other queued send stays where it is. Re-entrant. */
|
|
29514
|
+
drainBlockingBatchResults() {
|
|
29515
|
+
while (this.connectionReady) {
|
|
29516
|
+
const index = this.queuedSends.findIndex((send2) => this.isQueuedBatchResult(send2));
|
|
29517
|
+
if (index < 0) {
|
|
29518
|
+
return;
|
|
29519
|
+
}
|
|
29520
|
+
const [send] = this.queuedSends.splice(index, 1);
|
|
29521
|
+
send.Run();
|
|
29402
29522
|
}
|
|
29403
29523
|
}
|
|
29524
|
+
/** No batch any more (connect, disconnect, re-seed). */
|
|
29525
|
+
closeBlockingBatch() {
|
|
29526
|
+
this.blockingBatchOwed.clear();
|
|
29527
|
+
this.blockingBatchExpired.clear();
|
|
29528
|
+
this.blockingBatchStarted = false;
|
|
29529
|
+
this.blockingBatchCommitHeld = false;
|
|
29530
|
+
}
|
|
29404
29531
|
/**
|
|
29405
29532
|
* Sends a user turn that TRIGGERS generation (`turnComplete: true`), stamping the upcoming
|
|
29406
29533
|
* turn's kind at send time and eagerly marking the model busy. `emitSpeaking` mirrors the
|
|
@@ -29418,6 +29545,8 @@ var GeminiRealtimeClient = class GeminiRealtimeClient2 extends BaseRealtimeClien
|
|
|
29418
29545
|
if (this.idleSignal === "interactionStatus") {
|
|
29419
29546
|
this.interactionInProgress = true;
|
|
29420
29547
|
this.scheduleSafetyBackstop();
|
|
29548
|
+
} else {
|
|
29549
|
+
this.clearSafetyBackstop();
|
|
29421
29550
|
}
|
|
29422
29551
|
this.activeResponseKind = kind;
|
|
29423
29552
|
if (emitSpeaking) {
|
|
@@ -29494,16 +29623,23 @@ var GeminiRealtimeClient = class GeminiRealtimeClient2 extends BaseRealtimeClien
|
|
|
29494
29623
|
if (this.isNonBlocking) {
|
|
29495
29624
|
this.toolResponseAwaitsCommit = this.toolResponseAwaitsCommit || this.openClientTurn;
|
|
29496
29625
|
} else {
|
|
29497
|
-
|
|
29626
|
+
const othersOwed = this.tracksBlockingBatch && this.batchOwesOtherResults(callID);
|
|
29627
|
+
const batchResultsFollow = othersOwed || this.tracksBlockingBatch && this.batchResultQueuedAfter(callID);
|
|
29628
|
+
const holdCommit = this.openClientTurn && batchResultsFollow;
|
|
29629
|
+
if (this.openClientTurn && !holdCommit) {
|
|
29498
29630
|
session.sendClientContent({ turnComplete: true });
|
|
29499
29631
|
this.openClientTurn = false;
|
|
29500
29632
|
}
|
|
29501
|
-
this.
|
|
29502
|
-
this.
|
|
29503
|
-
|
|
29633
|
+
this.blockingBatchCommitHeld = holdCommit;
|
|
29634
|
+
if (!(othersOwed && !this.blockingBatchOwed.has(callID))) {
|
|
29635
|
+
this.responseActive = true;
|
|
29636
|
+
this.activeResponseKind = "normal";
|
|
29637
|
+
this.setState("speaking");
|
|
29638
|
+
}
|
|
29504
29639
|
}
|
|
29505
29640
|
this.pendingToolCallNames.delete(callID);
|
|
29506
29641
|
this.endTurnIfToolResultsIn(sched !== FunctionResponseScheduling.SILENT);
|
|
29642
|
+
this.afterBlockingResult(callID);
|
|
29507
29643
|
}
|
|
29508
29644
|
/**
|
|
29509
29645
|
* Parses a JSON-stringified tool result into the structured object Gemini's
|
|
@@ -29538,10 +29674,64 @@ var GeminiRealtimeClient = class GeminiRealtimeClient2 extends BaseRealtimeClien
|
|
|
29538
29674
|
handleSafetyBackstopTrigger() {
|
|
29539
29675
|
this.handleIdleTerminal();
|
|
29540
29676
|
}
|
|
29677
|
+
/**
|
|
29678
|
+
* The tool-batch barrier stopped waiting for a result. It records a result at SEND time, so the missing ones may
|
|
29679
|
+
* be slow, never coming (a cancelled call), or queued behind another turn. A blocking batch expires: its queued
|
|
29680
|
+
* results go out whatever {@link responseActive} is (a late one still skips the turn wait), a held commit goes
|
|
29681
|
+
* out, and the backstop guards the reply.
|
|
29682
|
+
*/
|
|
29541
29683
|
handleToolBatchTimeout() {
|
|
29684
|
+
if (this.tracksBlockingBatch) {
|
|
29685
|
+
for (const callID of this.blockingBatchOwed) {
|
|
29686
|
+
this.blockingBatchExpired.add(callID);
|
|
29687
|
+
}
|
|
29688
|
+
this.blockingBatchOwed.clear();
|
|
29689
|
+
this.blockingBatchStarted = false;
|
|
29690
|
+
this.drainBlockingBatchResults();
|
|
29691
|
+
this.releaseHeldBatchCommit();
|
|
29692
|
+
}
|
|
29542
29693
|
if (this.idleSignal === "turnComplete") {
|
|
29543
29694
|
this.flushQueuedSends();
|
|
29544
29695
|
}
|
|
29696
|
+
if (this.tracksBlockingBatch && this.responseActive) {
|
|
29697
|
+
this.scheduleSafetyBackstop(GeminiRealtimeClient_1.BLOCKING_TOOL_REPLY_BACKSTOP_MS);
|
|
29698
|
+
}
|
|
29699
|
+
}
|
|
29700
|
+
/**
|
|
29701
|
+
* Sends a commit held for a batch that will not reach its last result; a turn that already ended needs none. The
|
|
29702
|
+
* commit asks for the reply, so the client is busy for it and the no-output backstop guards it.
|
|
29703
|
+
*/
|
|
29704
|
+
releaseHeldBatchCommit() {
|
|
29705
|
+
if (!this.blockingBatchCommitHeld) {
|
|
29706
|
+
return;
|
|
29707
|
+
}
|
|
29708
|
+
if (!this.openClientTurn) {
|
|
29709
|
+
this.blockingBatchCommitHeld = false;
|
|
29710
|
+
return;
|
|
29711
|
+
}
|
|
29712
|
+
if (!this.connectionReady) {
|
|
29713
|
+
return;
|
|
29714
|
+
}
|
|
29715
|
+
this.session?.sendClientContent({ turnComplete: true });
|
|
29716
|
+
this.openClientTurn = false;
|
|
29717
|
+
this.blockingBatchCommitHeld = false;
|
|
29718
|
+
this.responseActive = true;
|
|
29719
|
+
this.activeResponseKind = "normal";
|
|
29720
|
+
this.scheduleSafetyBackstop(GeminiRealtimeClient_1.BLOCKING_TOOL_REPLY_BACKSTOP_MS);
|
|
29721
|
+
}
|
|
29722
|
+
/**
|
|
29723
|
+
* The session continues on a connection (a completed move, or the old one after a failed attempt). Batch results
|
|
29724
|
+
* queued during the move go out first; a commit still held while the batch owes nothing then goes out, so it is
|
|
29725
|
+
* not stranded. A re-seed closed the batch already, so this does nothing there.
|
|
29726
|
+
*/
|
|
29727
|
+
releaseHeldBatchCommitAfterMove() {
|
|
29728
|
+
if (!this.tracksBlockingBatch) {
|
|
29729
|
+
return;
|
|
29730
|
+
}
|
|
29731
|
+
this.drainBlockingBatchResults();
|
|
29732
|
+
if (this.blockingBatchOwed.size === 0) {
|
|
29733
|
+
this.releaseHeldBatchCommit();
|
|
29734
|
+
}
|
|
29545
29735
|
}
|
|
29546
29736
|
/** Resets the per-session response state machine (used on Disconnect). */
|
|
29547
29737
|
resetResponseState() {
|
|
@@ -29557,6 +29747,7 @@ var GeminiRealtimeClient = class GeminiRealtimeClient2 extends BaseRealtimeClien
|
|
|
29557
29747
|
this.queuedSends = [];
|
|
29558
29748
|
this.pendingToolCallNames.clear();
|
|
29559
29749
|
this.toolBatchBarrier.Clear();
|
|
29750
|
+
this.closeBlockingBatch();
|
|
29560
29751
|
this.clearSafetyBackstop();
|
|
29561
29752
|
}
|
|
29562
29753
|
/** Updates the client's own state view and emits the change to the host. */
|
|
@@ -31324,13 +31515,114 @@ AssemblyAIRealtimeClient = __decorate5([
|
|
|
31324
31515
|
RegisterClass(BaseRealtimeClient, "assemblyai")
|
|
31325
31516
|
], AssemblyAIRealtimeClient);
|
|
31326
31517
|
|
|
31327
|
-
// ../../AI/RealtimeClient/dist/drivers/
|
|
31518
|
+
// ../../AI/RealtimeClient/dist/drivers/assemblyAIVoiceRealtimeClient.js
|
|
31328
31519
|
var __decorate6 = function(decorators, target, key, desc) {
|
|
31329
31520
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
31330
31521
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
31331
31522
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
31332
31523
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
31333
31524
|
};
|
|
31525
|
+
var ASSEMBLYAI_VOICE_PCM_SAMPLE_RATE = 24e3;
|
|
31526
|
+
var AssemblyAIVoiceRealtimeClient = class AssemblyAIVoiceRealtimeClient2 extends OpenAIProtocolWebSocketRealtimeClient {
|
|
31527
|
+
constructor() {
|
|
31528
|
+
super(...arguments);
|
|
31529
|
+
this.timeLimitReached = false;
|
|
31530
|
+
}
|
|
31531
|
+
/** @inheritdoc */
|
|
31532
|
+
get providerDebugLabel() {
|
|
31533
|
+
return "AssemblyAIVoiceRealtimeClient";
|
|
31534
|
+
}
|
|
31535
|
+
/** @inheritdoc — the server decides when a connection must be replaced, and says so in the minted config. */
|
|
31536
|
+
get DefaultCallDurationSeconds() {
|
|
31537
|
+
return void 0;
|
|
31538
|
+
}
|
|
31539
|
+
/** @inheritdoc — a proxy ticket opens one connection, and the call outlives it. */
|
|
31540
|
+
get RefreshesCredentialAhead() {
|
|
31541
|
+
return false;
|
|
31542
|
+
}
|
|
31543
|
+
/** @inheritdoc — the proxy URL is the credential. */
|
|
31544
|
+
openProviderSocket(config) {
|
|
31545
|
+
this.timeLimitReached = false;
|
|
31546
|
+
return this.createSocket(config.EphemeralToken);
|
|
31547
|
+
}
|
|
31548
|
+
/** @inheritdoc — the agent sends it once it can hear and speak. */
|
|
31549
|
+
get waitsForSessionCreated() {
|
|
31550
|
+
return true;
|
|
31551
|
+
}
|
|
31552
|
+
/** @inheritdoc — none: the server applied it (see the class docs). */
|
|
31553
|
+
resolveSessionObject(_config) {
|
|
31554
|
+
return {};
|
|
31555
|
+
}
|
|
31556
|
+
/** @inheritdoc */
|
|
31557
|
+
resolveSampleRate(config) {
|
|
31558
|
+
const rate = config.SessionConfig?.["sampleRate"];
|
|
31559
|
+
return typeof rate === "number" && rate > 0 ? rate : ASSEMBLYAI_VOICE_PCM_SAMPLE_RATE;
|
|
31560
|
+
}
|
|
31561
|
+
/** @inheritdoc — the server always ends a reply with `response.done`, so a tool call need not release it early. */
|
|
31562
|
+
get releasesBusyFlagOnToolCall() {
|
|
31563
|
+
return false;
|
|
31564
|
+
}
|
|
31565
|
+
/** @inheritdoc */
|
|
31566
|
+
get unexpectedCloseMessage() {
|
|
31567
|
+
return "AssemblyAI voice connection closed unexpectedly";
|
|
31568
|
+
}
|
|
31569
|
+
/** @inheritdoc — a call that reached its time limit ends; any other lost connection is recovered. */
|
|
31570
|
+
handleSocketClose() {
|
|
31571
|
+
if (this.timeLimitReached && !this.closedByConsumer && this.currentState !== "error" && this.currentState !== "closed") {
|
|
31572
|
+
this.emitError({ Message: "Call time limit reached", Code: REALTIME_CLIENT_TIME_LIMIT_ERROR_CODE, Fatal: true });
|
|
31573
|
+
this.setState("error");
|
|
31574
|
+
return;
|
|
31575
|
+
}
|
|
31576
|
+
super.handleSocketClose();
|
|
31577
|
+
}
|
|
31578
|
+
/**
|
|
31579
|
+
* @inheritdoc — first finishes the transcript of a reply in progress. The server ends a reply when it has played, not
|
|
31580
|
+
* when it was written, so a hang-up during one would lose it from the conversation.
|
|
31581
|
+
*/
|
|
31582
|
+
async Disconnect() {
|
|
31583
|
+
const spoken = this.pendingAssistantText;
|
|
31584
|
+
this.pendingAssistantText = "";
|
|
31585
|
+
if (spoken.trim().length > 0) {
|
|
31586
|
+
this.emitTranscript({ Role: "Assistant", Text: spoken, IsFinal: true, Kind: this.activeResponseKind });
|
|
31587
|
+
}
|
|
31588
|
+
await super.Disconnect();
|
|
31589
|
+
}
|
|
31590
|
+
/** Creates the websocket. Production wraps the platform `WebSocket`. */
|
|
31591
|
+
createSocket(url) {
|
|
31592
|
+
const WS = globalThis.WebSocket;
|
|
31593
|
+
if (!WS) {
|
|
31594
|
+
throw new Error("AssemblyAIVoiceRealtimeClient requires a global WebSocket (browser or Node 22+).");
|
|
31595
|
+
}
|
|
31596
|
+
const ws = new WS(url);
|
|
31597
|
+
const seam = {
|
|
31598
|
+
onopen: null,
|
|
31599
|
+
onmessage: null,
|
|
31600
|
+
onerror: null,
|
|
31601
|
+
onclose: null,
|
|
31602
|
+
send: (data) => ws.send(data),
|
|
31603
|
+
close: () => ws.close()
|
|
31604
|
+
};
|
|
31605
|
+
ws.onopen = () => seam.onopen?.();
|
|
31606
|
+
ws.onmessage = (event) => seam.onmessage?.(String(event.data));
|
|
31607
|
+
ws.onerror = () => seam.onerror?.("AssemblyAI voice websocket error");
|
|
31608
|
+
ws.onclose = (event) => {
|
|
31609
|
+
this.timeLimitReached = event?.code === REALTIME_RELAY_TIME_LIMIT_CLOSE_CODE;
|
|
31610
|
+
seam.onclose?.();
|
|
31611
|
+
};
|
|
31612
|
+
return seam;
|
|
31613
|
+
}
|
|
31614
|
+
};
|
|
31615
|
+
AssemblyAIVoiceRealtimeClient = __decorate6([
|
|
31616
|
+
RegisterClass(BaseRealtimeClient, "assemblyai-voice")
|
|
31617
|
+
], AssemblyAIVoiceRealtimeClient);
|
|
31618
|
+
|
|
31619
|
+
// ../../AI/RealtimeClient/dist/drivers/xaiRealtimeClient.js
|
|
31620
|
+
var __decorate7 = function(decorators, target, key, desc) {
|
|
31621
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
31622
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
31623
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
31624
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
31625
|
+
};
|
|
31334
31626
|
var XAI_REALTIME_WS_URL = "wss://api.x.ai/v1/realtime";
|
|
31335
31627
|
var XAI_CLIENT_SECRET_SUBPROTOCOL_PREFIX = "xai-client-secret.";
|
|
31336
31628
|
var XAI_PCM_SAMPLE_RATE = 24e3;
|
|
@@ -31493,12 +31785,12 @@ var xAIRealtimeClient = class xAIRealtimeClient2 extends OpenAIProtocolWebSocket
|
|
|
31493
31785
|
}
|
|
31494
31786
|
}
|
|
31495
31787
|
};
|
|
31496
|
-
xAIRealtimeClient =
|
|
31788
|
+
xAIRealtimeClient = __decorate7([
|
|
31497
31789
|
RegisterClass(BaseRealtimeClient, "xai")
|
|
31498
31790
|
], xAIRealtimeClient);
|
|
31499
31791
|
|
|
31500
31792
|
// ../../AI/RealtimeClient/dist/drivers/elevenRealtimeClient.js
|
|
31501
|
-
var
|
|
31793
|
+
var __decorate8 = function(decorators, target, key, desc) {
|
|
31502
31794
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
31503
31795
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
31504
31796
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -31581,12 +31873,12 @@ var ElevenRealtimeClient = class ElevenRealtimeClient2 extends OpenAIProtocolWeb
|
|
|
31581
31873
|
}
|
|
31582
31874
|
}
|
|
31583
31875
|
};
|
|
31584
|
-
ElevenRealtimeClient =
|
|
31876
|
+
ElevenRealtimeClient = __decorate8([
|
|
31585
31877
|
RegisterClass(BaseRealtimeClient, "eleven-realtime")
|
|
31586
31878
|
], ElevenRealtimeClient);
|
|
31587
31879
|
|
|
31588
31880
|
// ../../AI/RealtimeClient/dist/drivers/huggingFaceRealtimeClient.js
|
|
31589
|
-
var
|
|
31881
|
+
var __decorate9 = function(decorators, target, key, desc) {
|
|
31590
31882
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
31591
31883
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
31592
31884
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -31670,12 +31962,12 @@ var HuggingFaceRealtimeClient = class HuggingFaceRealtimeClient2 extends OpenAIP
|
|
|
31670
31962
|
return seam;
|
|
31671
31963
|
}
|
|
31672
31964
|
};
|
|
31673
|
-
HuggingFaceRealtimeClient =
|
|
31965
|
+
HuggingFaceRealtimeClient = __decorate9([
|
|
31674
31966
|
RegisterClass(BaseRealtimeClient, "huggingface")
|
|
31675
31967
|
], HuggingFaceRealtimeClient);
|
|
31676
31968
|
|
|
31677
31969
|
// ../../AI/RealtimeClient/dist/drivers/openAILiveClient.js
|
|
31678
|
-
var
|
|
31970
|
+
var __decorate10 = function(decorators, target, key, desc) {
|
|
31679
31971
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
31680
31972
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
31681
31973
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -32555,7 +32847,7 @@ var OpenAILiveClient = class OpenAILiveClient2 extends BaseRealtimeClient {
|
|
|
32555
32847
|
}
|
|
32556
32848
|
}
|
|
32557
32849
|
};
|
|
32558
|
-
OpenAILiveClient = OpenAILiveClient_1 =
|
|
32850
|
+
OpenAILiveClient = OpenAILiveClient_1 = __decorate10([
|
|
32559
32851
|
RegisterClass(BaseRealtimeClient, "openai-live"),
|
|
32560
32852
|
RegisterClass(BaseRealtimeClient, "OpenAILiveRealtime")
|
|
32561
32853
|
], OpenAILiveClient);
|
|
@@ -32669,7 +32961,7 @@ var WidgetChannelHost = class {
|
|
|
32669
32961
|
};
|
|
32670
32962
|
|
|
32671
32963
|
// dist/voice/channels/whiteboard-channel.js
|
|
32672
|
-
var
|
|
32964
|
+
var __decorate11 = function(decorators, target, key, desc) {
|
|
32673
32965
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
32674
32966
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
32675
32967
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -32848,7 +33140,7 @@ var WidgetWhiteboardChannel = class WidgetWhiteboardChannel2 extends BaseWidgetC
|
|
|
32848
33140
|
return JSON.stringify({ ok: true, action: description, shapeCount: this.shapeCount });
|
|
32849
33141
|
}
|
|
32850
33142
|
};
|
|
32851
|
-
WidgetWhiteboardChannel =
|
|
33143
|
+
WidgetWhiteboardChannel = __decorate11([
|
|
32852
33144
|
RegisterClass(BaseWidgetChannel, CHANNEL_NAME)
|
|
32853
33145
|
], WidgetWhiteboardChannel);
|
|
32854
33146
|
function LoadWidgetWhiteboardChannel() {
|