@openclaw/voice-call 2026.10.10 → 2026.11.5-beta.1
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/.setup/{carrier-api-BgJdQC-e.mjs → carrier-api-CZQtPnYQ.mjs} +15 -28
- package/dist/.setup/{cli-CI9QzIaT.mjs → cli-BUVmNuk8.mjs} +113 -61
- package/dist/.setup/{config-BxESUUSm.mjs → config-D_w9HzxP.mjs} +55 -111
- package/dist/.setup/{mock-BO3pptb-.mjs → mock-fux1a_i_.mjs} +3 -4
- package/dist/.setup/{plivo-C5cLYAup.mjs → plivo-Cpxxx8BT.mjs} +6 -21
- package/dist/.setup/{realtime-handler-B2JJ-8wv.mjs → realtime-handler-BkoZ-ZYd.mjs} +190 -265
- package/dist/.setup/{response-generator-B2nVYBf_.mjs → response-generator-COluXT2F.mjs} +11 -15
- package/dist/.setup/{runtime-entry-CKPPin7r.mjs → runtime-entry-Br7ttAwq.mjs} +382 -522
- package/dist/.setup/{state-retention-api-y5WYfZsQ.mjs → state-retention-api-BDJR8dnG.mjs} +1 -1
- package/dist/.setup/{store-path-Bn3bLr8y.mjs → store-path-C0yJCDE8.mjs} +2 -2
- package/dist/.setup/{telnyx-ZopMHuZl.mjs → telnyx-DdFzdUEf.mjs} +4 -5
- package/dist/.setup/{twilio-BGLnhzpD.mjs → twilio-BqUbz9jp.mjs} +7 -15
- package/dist/.setup/webhook-replay-DnlMxw4z.mjs +30 -0
- package/dist/.source-module-urls/8b7cb5a3dc0f034090cbbda318ba348c0d48853d04f0e3b500529cf7666abe03.json +1 -1
- package/dist/doctor-contract-api.js +21 -2
- package/dist/index.js +106 -195
- package/dist/runtime-entry.js +1 -1
- package/dist/setup-api.js +1 -2
- package/dist/state-retention-api.js +1 -1
- package/node_modules/typebox/build/format/duration.d.mts +2 -2
- package/node_modules/typebox/build/format/duration.mjs +2 -2
- package/node_modules/typebox/build/format/idn_email.d.mts +1 -0
- package/node_modules/typebox/build/format/idn_email.mjs +1 -0
- package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -1
- package/node_modules/typebox/build/format/idn_hostname.mjs +1 -1
- package/node_modules/typebox/build/format/ipv4.d.mts +2 -2
- package/node_modules/typebox/build/format/ipv4.mjs +2 -2
- package/node_modules/typebox/build/format/ipv6.d.mts +1 -1
- package/node_modules/typebox/build/format/ipv6.mjs +1 -1
- package/node_modules/typebox/build/format/relative_json_pointer.d.mts +2 -2
- package/node_modules/typebox/build/format/relative_json_pointer.mjs +2 -2
- package/node_modules/typebox/build/schema/build.mjs +1 -0
- package/node_modules/typebox/build/schema/engine/_unique.d.mts +4 -2
- package/node_modules/typebox/build/schema/engine/_unique.mjs +7 -3
- package/node_modules/typebox/build/schema/engine/additionalItems.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/additionalProperties.d.mts +0 -3
- package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +15 -17
- package/node_modules/typebox/build/schema/engine/contains.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/index.d.mts +1 -0
- package/node_modules/typebox/build/schema/engine/index.mjs +1 -0
- package/node_modules/typebox/build/schema/engine/items.mjs +7 -4
- package/node_modules/typebox/build/schema/engine/maxContains.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/minContains.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/oneOf.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/patternProperties.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/propertyNames.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/unevaluatedItems.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/unevaluatedProperties.mjs +2 -2
- package/node_modules/typebox/build/system/hashing/hash.mjs +63 -34
- package/node_modules/typebox/build/system/locale/en_US.mjs +2 -1
- package/node_modules/typebox/build/system/memory/assign.d.mts +2 -8
- package/node_modules/typebox/build/system/memory/assign.mjs +13 -6
- package/node_modules/typebox/build/system/memory/clone.d.mts +4 -5
- package/node_modules/typebox/build/system/memory/clone.mjs +8 -96
- package/node_modules/typebox/build/system/memory/create.d.mts +1 -5
- package/node_modules/typebox/build/system/memory/create.mjs +18 -13
- package/node_modules/typebox/build/system/memory/deep.d.mts +2 -0
- package/node_modules/typebox/build/system/memory/deep.mjs +108 -0
- package/node_modules/typebox/build/system/memory/discard.d.mts +1 -1
- package/node_modules/typebox/build/system/memory/discard.mjs +9 -8
- package/node_modules/typebox/build/system/memory/finalize.d.mts +4 -0
- package/node_modules/typebox/build/system/memory/finalize.mjs +30 -0
- package/node_modules/typebox/build/system/memory/keys.d.mts +2 -0
- package/node_modules/typebox/build/system/memory/keys.mjs +8 -0
- package/node_modules/typebox/build/system/memory/update.d.mts +1 -4
- package/node_modules/typebox/build/system/memory/update.mjs +43 -16
- package/node_modules/typebox/build/type/engine/call/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/call/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +2 -24
- package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +2 -29
- package/node_modules/typebox/build/type/engine/evaluate/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/evaluate/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +5 -1
- package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +6 -1
- package/node_modules/typebox/build/type/engine/evaluate/property.d.mts +30 -0
- package/node_modules/typebox/build/type/engine/evaluate/property.mjs +29 -0
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.d.mts +1 -3
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +1 -4
- package/node_modules/typebox/build/type/engine/object/from_intersect.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/object/from_intersect.mjs +2 -2
- package/node_modules/typebox/build/type/engine/object/from_union.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/object/from_union.mjs +2 -2
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.d.mts +1 -3
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +1 -4
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.d.mts +1 -3
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +1 -4
- package/node_modules/typebox/build/type/engine/this/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/this/index.mjs +1 -0
- package/node_modules/typebox/build/value/clone/clone.d.mts +4 -3
- package/node_modules/typebox/build/value/clone/clone.mjs +5 -7
- package/node_modules/typebox/build/value/repair/from_cyclic.d.mts +2 -0
- package/node_modules/typebox/build/value/repair/from_cyclic.mjs +6 -0
- package/node_modules/typebox/build/value/shared/union_priority_sort.mjs +25 -14
- package/node_modules/typebox/package.json +1 -1
- package/node_modules/typebox/readme.md +1 -1
- package/node_modules/zod/package.json +1 -1
- package/node_modules/zod/src/v4/classic/tests/array.test.ts +27 -0
- package/node_modules/zod/src/v4/classic/tests/map.test.ts +7 -0
- package/node_modules/zod/src/v4/classic/tests/set.test.ts +6 -0
- package/node_modules/zod/src/v4/core/compile.ts +9 -0
- package/node_modules/zod/src/v4/core/schemas.ts +35 -1
- package/node_modules/zod/src/v4/core/util.ts +13 -0
- package/node_modules/zod/src/v4/core/versions.ts +1 -1
- package/node_modules/zod/v4/core/compile.cjs +8 -0
- package/node_modules/zod/v4/core/compile.js +8 -0
- package/node_modules/zod/v4/core/schemas.cjs +30 -0
- package/node_modules/zod/v4/core/schemas.d.cts +3 -1
- package/node_modules/zod/v4/core/schemas.d.ts +3 -1
- package/node_modules/zod/v4/core/schemas.js +30 -0
- package/node_modules/zod/v4/core/util.cjs +15 -0
- package/node_modules/zod/v4/core/util.d.cts +2 -0
- package/node_modules/zod/v4/core/util.d.ts +2 -0
- package/node_modules/zod/v4/core/util.js +14 -0
- package/node_modules/zod/v4/core/versions.cjs +1 -1
- package/node_modules/zod/v4/core/versions.js +1 -1
- package/openclaw.plugin.json +9 -2
- package/package.json +6 -6
- package/dist/.setup/webhook-replay-B0Eo3Ll5.mjs +0 -42
- package/node_modules/typebox/build/system/memory/freeze.d.mts +0 -4
- package/node_modules/typebox/build/system/memory/freeze.mjs +0 -6
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { h as CallBriefSchema, o as resolveVoiceCallPublicPathPrefix, u as REALTIME_VOICE_END_CALL_TOOL_NAME } from "./config-D_w9HzxP.mjs";
|
|
2
|
+
import { o as canonicalizeVoiceCallMediaBase64 } from "./runtime-entry-Br7ttAwq.mjs";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
3
4
|
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
5
|
+
import { isFutureDateTimestampMs, resolveExpiresAtMsFromDurationMs } from "openclaw/plugin-sdk/number-runtime";
|
|
4
6
|
import { asNullableRecord, asOptionalObjectRecord, asOptionalRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
5
|
-
import {
|
|
7
|
+
import { sleep } from "openclaw/plugin-sdk/runtime-env";
|
|
6
8
|
import { REALTIME_VOICE_AGENT_CONSULT_TOOL_NAME, REALTIME_VOICE_AUDIO_FORMAT_G711_ULAW_8KHZ, buildRealtimeVoiceAgentConsultWorkingResponse, buildRealtimeVoiceAgentErrorProviderResult, buildRealtimeVoiceSpeakExactMessage, calculateMulawRms, createRealtimeVoiceSessionHarness, createSpeechThresholdGate, readRealtimeVoiceConsultQuestion, readSpeakableRealtimeVoiceToolResult, resolveRealtimeVoiceBargeIn, resolveRealtimeVoiceSessionPolicy } from "openclaw/plugin-sdk/realtime-voice";
|
|
7
9
|
import { normalizeWebhookPath } from "openclaw/plugin-sdk/webhook-ingress";
|
|
8
|
-
import { isFutureDateTimestampMs, resolveExpiresAtMsFromDurationMs } from "openclaw/plugin-sdk/number-runtime";
|
|
9
|
-
import { randomUUID } from "node:crypto";
|
|
10
10
|
import { safeParseJson, sliceUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
11
11
|
import "node:http";
|
|
12
12
|
import { WebSocket, WebSocketServer, rejectWebSocketUpgrade } from "openclaw/plugin-sdk/websocket-runtime";
|
|
@@ -40,10 +40,9 @@ var RealtimeAudioPacer = class {
|
|
|
40
40
|
/** Queue mulaw audio and split it into 20ms-ish telephony chunks. */
|
|
41
41
|
sendAudio(muLaw, metadata) {
|
|
42
42
|
if (this.closed || muLaw.length === 0) return;
|
|
43
|
-
const maxQueuedAudioBytes = this.params.maxQueuedAudioBytes ?? DEFAULT_MAX_QUEUED_AUDIO_BYTES;
|
|
44
43
|
for (let offset = 0; offset < muLaw.length; offset += TELEPHONY_CHUNK_BYTES) {
|
|
45
44
|
const chunk = Buffer.from(muLaw.subarray(offset, offset + TELEPHONY_CHUNK_BYTES));
|
|
46
|
-
if (this.queuedAudioBytes + chunk.length >
|
|
45
|
+
if (this.queuedAudioBytes + chunk.length > DEFAULT_MAX_QUEUED_AUDIO_BYTES) {
|
|
47
46
|
this.failBackpressure();
|
|
48
47
|
return;
|
|
49
48
|
}
|
|
@@ -291,10 +290,8 @@ function createOutboundGreetingController(params) {
|
|
|
291
290
|
let readySession;
|
|
292
291
|
let timer;
|
|
293
292
|
const clearTimer = () => {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
timer = void 0;
|
|
297
|
-
}
|
|
293
|
+
clearTimeout(timer);
|
|
294
|
+
timer = void 0;
|
|
298
295
|
};
|
|
299
296
|
const triggerOpening = () => {
|
|
300
297
|
if (!closed && readySession && params.instructions && claim()) readySession.triggerGreeting(params.instructions);
|
|
@@ -352,7 +349,7 @@ function createOutboundGreetingController(params) {
|
|
|
352
349
|
triggerOpening();
|
|
353
350
|
}
|
|
354
351
|
}, params.holdOpeningMaxMs ?? 3e4);
|
|
355
|
-
timer.unref
|
|
352
|
+
timer.unref();
|
|
356
353
|
}
|
|
357
354
|
return;
|
|
358
355
|
}
|
|
@@ -360,8 +357,8 @@ function createOutboundGreetingController(params) {
|
|
|
360
357
|
clearTimer();
|
|
361
358
|
timer = setTimeout(() => {
|
|
362
359
|
if (claim()) session.triggerGreeting(params.instructions);
|
|
363
|
-
},
|
|
364
|
-
timer.unref
|
|
360
|
+
}, OUTBOUND_GREETING_FALLBACK_MS);
|
|
361
|
+
timer.unref();
|
|
365
362
|
}
|
|
366
363
|
};
|
|
367
364
|
}
|
|
@@ -372,22 +369,17 @@ function createRealtimeCallActivityController(params) {
|
|
|
372
369
|
let idleTimer;
|
|
373
370
|
let mediaTimer;
|
|
374
371
|
const clearIdle = () => {
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
idleTimer = void 0;
|
|
378
|
-
}
|
|
372
|
+
clearTimeout(idleTimer);
|
|
373
|
+
idleTimer = void 0;
|
|
379
374
|
};
|
|
380
375
|
const clearMedia = () => {
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
mediaTimer = void 0;
|
|
384
|
-
}
|
|
376
|
+
clearTimeout(mediaTimer);
|
|
377
|
+
mediaTimer = void 0;
|
|
385
378
|
};
|
|
386
379
|
const resetIdle = () => {
|
|
387
380
|
clearIdle();
|
|
388
381
|
if (closed || !started || !params.idleHangupMs || consultsInFlight > 0 || params.isPaused?.() === true) return;
|
|
389
|
-
idleTimer = setTimeout(params.onIdle, params.idleHangupMs);
|
|
390
|
-
idleTimer.unref?.();
|
|
382
|
+
idleTimer = setTimeout(params.onIdle, params.idleHangupMs).unref();
|
|
391
383
|
};
|
|
392
384
|
return {
|
|
393
385
|
beginConsult() {
|
|
@@ -409,10 +401,9 @@ function createRealtimeCallActivityController(params) {
|
|
|
409
401
|
clearMedia();
|
|
410
402
|
mediaTimer = setTimeout(() => {
|
|
411
403
|
params.onMediaWarning();
|
|
412
|
-
mediaTimer = setTimeout(params.onMediaTimeout,
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
mediaTimer.unref?.();
|
|
404
|
+
mediaTimer = setTimeout(params.onMediaTimeout, REALTIME_DISCONNECT_HANGUP_GRACE_MS).unref();
|
|
405
|
+
}, REALTIME_MEDIA_INACTIVITY_TIMEOUT_MS);
|
|
406
|
+
mediaTimer.unref();
|
|
416
407
|
},
|
|
417
408
|
noteSpeech: resetIdle,
|
|
418
409
|
start() {
|
|
@@ -471,56 +462,6 @@ function createRealtimeCallAudioController(params) {
|
|
|
471
462
|
cancelOutputAudioForBargeIn
|
|
472
463
|
};
|
|
473
464
|
}
|
|
474
|
-
// extensions/voice-call/src/webhook/realtime-host-speech.ts
|
|
475
|
-
/** One host-requested utterance, completed by audible output rather than model receipts. */
|
|
476
|
-
function createRealtimeHostSpeechController(params) {
|
|
477
|
-
let closed = false;
|
|
478
|
-
let pending;
|
|
479
|
-
let quietTimer;
|
|
480
|
-
let deadline;
|
|
481
|
-
const finish = (error) => {
|
|
482
|
-
const current = pending;
|
|
483
|
-
pending = void 0;
|
|
484
|
-
clearTimeout(quietTimer);
|
|
485
|
-
clearTimeout(deadline);
|
|
486
|
-
if (error) current?.reject(error);
|
|
487
|
-
else current?.resolve();
|
|
488
|
-
};
|
|
489
|
-
return {
|
|
490
|
-
isActive: () => Boolean(pending),
|
|
491
|
-
speak(instructions) {
|
|
492
|
-
if (closed) return Promise.reject(/* @__PURE__ */ new Error("Realtime bridge is closed"));
|
|
493
|
-
finish(/* @__PURE__ */ new Error("Host speech replaced"));
|
|
494
|
-
return new Promise((resolve, reject) => {
|
|
495
|
-
try {
|
|
496
|
-
params.interrupt();
|
|
497
|
-
if (closed) throw new Error("Realtime bridge is closed");
|
|
498
|
-
pending = {
|
|
499
|
-
resolve,
|
|
500
|
-
reject
|
|
501
|
-
};
|
|
502
|
-
deadline = setTimeout(() => finish(/* @__PURE__ */ new Error("Realtime speech did not finish within 45 seconds")), 45e3);
|
|
503
|
-
deadline.unref?.();
|
|
504
|
-
params.trigger(instructions);
|
|
505
|
-
} catch (error) {
|
|
506
|
-
const rejection = error instanceof Error ? error : new Error(String(error));
|
|
507
|
-
finish(rejection);
|
|
508
|
-
reject(rejection);
|
|
509
|
-
}
|
|
510
|
-
});
|
|
511
|
-
},
|
|
512
|
-
noteAudibleOutput() {
|
|
513
|
-
if (!pending) return;
|
|
514
|
-
clearTimeout(quietTimer);
|
|
515
|
-
quietTimer = setTimeout(() => finish(), 1500);
|
|
516
|
-
quietTimer.unref?.();
|
|
517
|
-
},
|
|
518
|
-
close() {
|
|
519
|
-
closed = true;
|
|
520
|
-
finish(/* @__PURE__ */ new Error("Realtime bridge closed during host speech"));
|
|
521
|
-
}
|
|
522
|
-
};
|
|
523
|
-
}
|
|
524
465
|
// extensions/voice-call/src/webhook/realtime-call-playback.ts
|
|
525
466
|
const MAX_REALTIME_WS_BUFFERED_BYTES$1 = 1048576;
|
|
526
467
|
function createRealtimeCallPlayback(params) {
|
|
@@ -566,23 +507,59 @@ function createRealtimeCallPlayback(params) {
|
|
|
566
507
|
});
|
|
567
508
|
}
|
|
568
509
|
});
|
|
569
|
-
const
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
510
|
+
const hostSpeech = (() => {
|
|
511
|
+
let closed = false;
|
|
512
|
+
let pending;
|
|
513
|
+
let quietTimer;
|
|
514
|
+
let deadline;
|
|
515
|
+
const finish = (error) => {
|
|
516
|
+
const current = pending;
|
|
517
|
+
pending = void 0;
|
|
518
|
+
clearTimeout(quietTimer);
|
|
519
|
+
clearTimeout(deadline);
|
|
520
|
+
if (error) current?.reject(error);
|
|
521
|
+
else current?.resolve();
|
|
522
|
+
};
|
|
523
|
+
return {
|
|
524
|
+
isActive: () => Boolean(pending),
|
|
525
|
+
speak(instructions) {
|
|
526
|
+
if (closed) return Promise.reject(/* @__PURE__ */ new Error("Realtime bridge is closed"));
|
|
527
|
+
finish(/* @__PURE__ */ new Error("Host speech replaced"));
|
|
528
|
+
return new Promise((resolve, reject) => {
|
|
529
|
+
try {
|
|
530
|
+
params.getSession()?.handleBargeIn({
|
|
531
|
+
audioPlaybackActive: true,
|
|
532
|
+
force: true
|
|
533
|
+
});
|
|
534
|
+
audioController.cancelOutputAudioForBargeIn("local");
|
|
535
|
+
if (closed) throw new Error("Realtime bridge is closed");
|
|
536
|
+
pending = {
|
|
537
|
+
resolve,
|
|
538
|
+
reject
|
|
539
|
+
};
|
|
540
|
+
deadline = setTimeout(() => finish(/* @__PURE__ */ new Error("Realtime speech did not finish within 45 seconds")), 45e3);
|
|
541
|
+
deadline.unref();
|
|
542
|
+
const session = params.getSession();
|
|
543
|
+
if (!session) throw new Error("No active realtime bridge for call");
|
|
544
|
+
session.triggerGreeting(instructions);
|
|
545
|
+
} catch (error) {
|
|
546
|
+
const rejection = error instanceof Error ? error : new Error(String(error));
|
|
547
|
+
finish(rejection);
|
|
548
|
+
reject(rejection);
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
},
|
|
552
|
+
noteAudibleOutput() {
|
|
553
|
+
if (!pending) return;
|
|
554
|
+
clearTimeout(quietTimer);
|
|
555
|
+
quietTimer = setTimeout(() => finish(), 1500).unref();
|
|
556
|
+
},
|
|
557
|
+
close() {
|
|
558
|
+
closed = true;
|
|
559
|
+
finish(/* @__PURE__ */ new Error("Realtime bridge closed during host speech"));
|
|
560
|
+
}
|
|
561
|
+
};
|
|
562
|
+
})();
|
|
586
563
|
const audioController = createRealtimeCallAudioController({
|
|
587
564
|
audioPacer,
|
|
588
565
|
callId,
|
|
@@ -677,6 +654,7 @@ var StreamFrameAdapter = class {
|
|
|
677
654
|
this.provider = provider;
|
|
678
655
|
this.streamSid = provider === "twilio" ? "" : void 0;
|
|
679
656
|
}
|
|
657
|
+
/** Normalized inbound media stream frame. */
|
|
680
658
|
parseInbound(rawMessage) {
|
|
681
659
|
const msg = asNullableRecord(safeParseJson(rawMessage));
|
|
682
660
|
if (!msg) return { kind: "ignored" };
|
|
@@ -753,13 +731,11 @@ const MAX_REALTIME_WS_BUFFERED_BYTES = 1048576;
|
|
|
753
731
|
const FORCED_CONSULT_FALLBACK_DELAY_MS = 200;
|
|
754
732
|
const FORCED_CONSULT_NATIVE_DEDUPE_MS = 2e3;
|
|
755
733
|
const FORCED_CONSULT_RESULT_MAX_CHARS = 1800;
|
|
756
|
-
const FORCED_CONSULT_REASON = "provider_final_transcript_without_openclaw_agent_consult";
|
|
757
734
|
const CONSULT_TRANSCRIPT_SETTLE_MS = 350;
|
|
758
735
|
const CONSULT_TRANSCRIPT_SETTLE_MAX_MS = 1e3;
|
|
759
736
|
const RECENT_FINAL_USER_TRANSCRIPT_TTL_MS = 2e3;
|
|
760
737
|
const BARGE_IN_REQUIRED_LOUD_CHUNKS = 2;
|
|
761
738
|
const CALLER_SPEECH_RMS_THRESHOLD = .035;
|
|
762
|
-
const logger = createSubsystemLogger("voice-call/realtime");
|
|
763
739
|
function withFallbackConsultQuestion(args, fallback) {
|
|
764
740
|
const providerQuestion = readRealtimeVoiceConsultQuestion(args);
|
|
765
741
|
const question = fallback?.trim();
|
|
@@ -1053,8 +1029,7 @@ var RealtimeCallHandler = class {
|
|
|
1053
1029
|
const host = this.publicOrigin || DEFAULT_HOST;
|
|
1054
1030
|
const streamPathPattern = this.getStreamPathPattern();
|
|
1055
1031
|
setTimeout(() => {
|
|
1056
|
-
if (!this.pendingStreamTokens.
|
|
1057
|
-
this.pendingStreamTokens.delete(token);
|
|
1032
|
+
if (!this.pendingStreamTokens.delete(token)) return;
|
|
1058
1033
|
if (this.closing) return;
|
|
1059
1034
|
const call = meta.callId ? ` for call ${meta.callId}` : "";
|
|
1060
1035
|
const endpoints = [meta.from ? `from ${meta.from}` : "", meta.to ? `to ${meta.to}` : ""].filter(Boolean).join(" ");
|
|
@@ -1199,11 +1174,6 @@ var RealtimeCallHandler = class {
|
|
|
1199
1174
|
providerCallId: callSid,
|
|
1200
1175
|
reason
|
|
1201
1176
|
})
|
|
1202
|
-
},
|
|
1203
|
-
onTalkEvent: (event) => {
|
|
1204
|
-
this.manager.updateCallMetadata(callRecord, (metadata) => appendRecentTalkEventMetadata(metadata, event, "realtime")).catch((error) => {
|
|
1205
|
-
console.warn("[voice-call] Failed to update realtime call metadata:", error);
|
|
1206
|
-
});
|
|
1207
1177
|
}
|
|
1208
1178
|
});
|
|
1209
1179
|
const providerHandlesInputAudioBargeIn = (capabilities ?? realtimeProvider.capabilities)?.handlesInputAudioBargeIn === true;
|
|
@@ -1261,6 +1231,81 @@ var RealtimeCallHandler = class {
|
|
|
1261
1231
|
if (failures.length === 1) throw failures[0];
|
|
1262
1232
|
if (failures.length > 1) throw new AggregateError(failures, "Realtime provider and transcript cleanup failed");
|
|
1263
1233
|
};
|
|
1234
|
+
const scheduleForcedAgentConsult = (transcript, consultTranscript) => {
|
|
1235
|
+
if (this.config.consultPolicy !== "always" || this.activeBridgesByCallId.get(callId) !== session) return;
|
|
1236
|
+
const question = transcript.trim();
|
|
1237
|
+
if (!question) return;
|
|
1238
|
+
const handler = this.toolHandlers.get(REALTIME_VOICE_AGENT_CONSULT_TOOL_NAME);
|
|
1239
|
+
if (!handler) return;
|
|
1240
|
+
const existingForcedConsult = this.forcedConsultsByCallId.get(callId);
|
|
1241
|
+
if (existingForcedConsult && !existingForcedConsult.completedAt) return;
|
|
1242
|
+
const coordinator = harness.forcedConsults;
|
|
1243
|
+
if (coordinator.hasRecentNativeConsult(question, { allowUnknownQuestion: true })) return;
|
|
1244
|
+
coordinator.clearPending();
|
|
1245
|
+
const pending = coordinator.prepare(question);
|
|
1246
|
+
if (!pending) return;
|
|
1247
|
+
const runForcedAgentConsult = async (handle) => {
|
|
1248
|
+
coordinator.markStarted(handle);
|
|
1249
|
+
audioPacer.clearAudio();
|
|
1250
|
+
activity.beginConsult();
|
|
1251
|
+
const abortController = new AbortController();
|
|
1252
|
+
const state = {
|
|
1253
|
+
owner: session,
|
|
1254
|
+
handle,
|
|
1255
|
+
sendSpeechPrompt: true,
|
|
1256
|
+
cancelled: false,
|
|
1257
|
+
cancel: () => {
|
|
1258
|
+
abortController.abort(/* @__PURE__ */ new Error("Realtime forced consult owner was cancelled."));
|
|
1259
|
+
coordinator.markCancelled(handle);
|
|
1260
|
+
},
|
|
1261
|
+
promise: Promise.resolve().then(() => {
|
|
1262
|
+
abortController.signal.throwIfAborted();
|
|
1263
|
+
return handler({ question: handle.question }, callId, { abortSignal: abortController.signal });
|
|
1264
|
+
})
|
|
1265
|
+
};
|
|
1266
|
+
this.forcedConsultsByCallId.set(callId, state);
|
|
1267
|
+
try {
|
|
1268
|
+
const result = await state.promise;
|
|
1269
|
+
if (state.cancelled || this.forcedConsultsByCallId.get(callId) !== state) return;
|
|
1270
|
+
state.completedAt = Date.now();
|
|
1271
|
+
coordinator.markDelivered(handle);
|
|
1272
|
+
const text = readSpeakableRealtimeVoiceToolResult(result, {
|
|
1273
|
+
keys: ["text", "output"],
|
|
1274
|
+
maxChars: FORCED_CONSULT_RESULT_MAX_CHARS
|
|
1275
|
+
});
|
|
1276
|
+
if (!text) {
|
|
1277
|
+
console.warn(`[voice-call] realtime forced agent consult returned no speakable text callId=${callId} providerCallId=${callSid}`);
|
|
1278
|
+
return;
|
|
1279
|
+
}
|
|
1280
|
+
if (state.sendSpeechPrompt) {
|
|
1281
|
+
audioPacer.clearAudio();
|
|
1282
|
+
session.sendUserMessage(buildForcedConsultSpeechPrompt(text));
|
|
1283
|
+
}
|
|
1284
|
+
consumeUserTranscript(userTranscriptOwner, consultTranscript);
|
|
1285
|
+
} catch (error) {
|
|
1286
|
+
if (!state.cancelled) {
|
|
1287
|
+
const failed = "error" in buildRealtimeVoiceAgentErrorProviderResult(error);
|
|
1288
|
+
(failed ? console.warn : console.log)(`[voice-call] realtime forced agent consult ${failed ? "failed" : "cancelled"} callId=${callId} providerCallId=${callSid}`);
|
|
1289
|
+
}
|
|
1290
|
+
} finally {
|
|
1291
|
+
activity.endConsult();
|
|
1292
|
+
if (!state.cancelled) {
|
|
1293
|
+
if (this.forcedConsultsByCallId.get(callId) !== state) coordinator.remove(handle);
|
|
1294
|
+
else setTimeout(() => {
|
|
1295
|
+
if (this.forcedConsultsByCallId.get(callId) === state) {
|
|
1296
|
+
this.forcedConsultsByCallId.delete(callId);
|
|
1297
|
+
coordinator.remove(handle);
|
|
1298
|
+
}
|
|
1299
|
+
}, FORCED_CONSULT_NATIVE_DEDUPE_MS).unref?.();
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
};
|
|
1303
|
+
coordinator.schedule(pending, FORCED_CONSULT_FALLBACK_DELAY_MS, (handle) => {
|
|
1304
|
+
const activeForcedConsult = this.forcedConsultsByCallId.get(callId);
|
|
1305
|
+
if (activeForcedConsult && !activeForcedConsult.completedAt) return;
|
|
1306
|
+
runForcedAgentConsult(handle);
|
|
1307
|
+
});
|
|
1308
|
+
};
|
|
1264
1309
|
const bridgeParams = {
|
|
1265
1310
|
provider: realtimeProvider,
|
|
1266
1311
|
cfg: this.coreConfig,
|
|
@@ -1332,7 +1377,6 @@ var RealtimeCallHandler = class {
|
|
|
1332
1377
|
partial.text = limitPartialUserTranscript(appendTranscriptText(partial.text, text));
|
|
1333
1378
|
partial.raw = limitPartialUserTranscript(`${partial.raw ?? ""}${text}`);
|
|
1334
1379
|
partial.updatedAt = Date.now();
|
|
1335
|
-
console.log(`[voice-call] realtime input transcript callId=${callId} providerCallId=${callSid} final=false chars=${text.trim().length} aggregateChars=${partial.text.length}`);
|
|
1336
1380
|
}
|
|
1337
1381
|
return;
|
|
1338
1382
|
}
|
|
@@ -1360,7 +1404,6 @@ var RealtimeCallHandler = class {
|
|
|
1360
1404
|
}, RECENT_FINAL_USER_TRANSCRIPT_TTL_MS);
|
|
1361
1405
|
timer.unref?.();
|
|
1362
1406
|
state.recentFinalTimer = timer;
|
|
1363
|
-
console.log(`[voice-call] realtime input transcript callId=${callId} providerCallId=${callSid} final=true chars=${text.trim().length} aggregateChars=${transcript.length}`);
|
|
1364
1407
|
}
|
|
1365
1408
|
const event = {
|
|
1366
1409
|
id: `realtime-${role === "user" ? "speech" : "bot"}-${callSid}-${randomUUID()}`,
|
|
@@ -1375,21 +1418,7 @@ var RealtimeCallHandler = class {
|
|
|
1375
1418
|
};
|
|
1376
1419
|
transcriptPersistence = this.manager.processEvent(event).then(() => {
|
|
1377
1420
|
if (role !== "user" || handlesAgentConsult || sessionClosed || !this.isActiveBridgeOwner(callId, session)) return;
|
|
1378
|
-
|
|
1379
|
-
harness,
|
|
1380
|
-
session,
|
|
1381
|
-
callId,
|
|
1382
|
-
callSid,
|
|
1383
|
-
transcript,
|
|
1384
|
-
consultTranscript,
|
|
1385
|
-
userTranscriptOwner,
|
|
1386
|
-
clearAudio: () => {
|
|
1387
|
-
const clearedBytes = audioPacer.clearAudio();
|
|
1388
|
-
console.log(`[voice-call] realtime forced consult cleared outbound audio callId=${callId} providerCallId=${callSid} queuedBytes=${clearedBytes}`);
|
|
1389
|
-
},
|
|
1390
|
-
beginConsultActivity: () => activity.beginConsult(),
|
|
1391
|
-
endConsultActivity: () => activity.endConsult()
|
|
1392
|
-
});
|
|
1421
|
+
scheduleForcedAgentConsult(transcript, consultTranscript);
|
|
1393
1422
|
});
|
|
1394
1423
|
transcriptPersistence.catch(reportTranscriptFailure);
|
|
1395
1424
|
},
|
|
@@ -1412,7 +1441,6 @@ var RealtimeCallHandler = class {
|
|
|
1412
1441
|
args: toolEvent.args
|
|
1413
1442
|
}
|
|
1414
1443
|
});
|
|
1415
|
-
console.log(`[voice-call] realtime tool call received callId=${callId} providerCallId=${callSid} tool=${toolEvent.name}`);
|
|
1416
1444
|
await this.executeToolCall(sessionLocal, callId, invocationId, toolEvent.name, toolEvent.args, turnId, harness, userTranscriptOwner, transcript);
|
|
1417
1445
|
} finally {
|
|
1418
1446
|
if (isConsult) activity.endConsult();
|
|
@@ -1548,7 +1576,6 @@ var RealtimeCallHandler = class {
|
|
|
1548
1576
|
peak: 0
|
|
1549
1577
|
})) {
|
|
1550
1578
|
outboundGreeting.claim();
|
|
1551
|
-
console.log(`[voice-call] realtime local speech detected callId=${callId} providerCallId=${callSid}`);
|
|
1552
1579
|
if (localBargeIn && !activity.isPaused()) audioController.cancelOutputAudioForBargeIn("local", (audioPlaybackActive) => {
|
|
1553
1580
|
session.handleBargeIn({ audioPlaybackActive });
|
|
1554
1581
|
});
|
|
@@ -1558,7 +1585,7 @@ var RealtimeCallHandler = class {
|
|
|
1558
1585
|
};
|
|
1559
1586
|
const closeSession = session.close.bind(session);
|
|
1560
1587
|
let sessionClosePromise;
|
|
1561
|
-
|
|
1588
|
+
const closeBridgeSession = () => {
|
|
1562
1589
|
if (sessionClosed) return sessionClosePromise ?? Promise.resolve();
|
|
1563
1590
|
sessionClosed = true;
|
|
1564
1591
|
outboundGreeting.close();
|
|
@@ -1573,6 +1600,7 @@ var RealtimeCallHandler = class {
|
|
|
1573
1600
|
});
|
|
1574
1601
|
return sessionClosePromise;
|
|
1575
1602
|
};
|
|
1603
|
+
session.close = closeBridgeSession;
|
|
1576
1604
|
let bindingClosed = false;
|
|
1577
1605
|
let bindingClosePromise;
|
|
1578
1606
|
const closeBinding = (cause) => {
|
|
@@ -1580,21 +1608,14 @@ var RealtimeCallHandler = class {
|
|
|
1580
1608
|
bindingClosed = true;
|
|
1581
1609
|
activity.close();
|
|
1582
1610
|
const ownsCall = this.activeTelephonyBindingsByCallId.get(callId) === telephonyBinding;
|
|
1583
|
-
const finishClose = () => {
|
|
1611
|
+
const finishClose = async () => {
|
|
1584
1612
|
const stillOwnsCall = this.activeTelephonyBindingsByCallId.get(callId) === telephonyBinding;
|
|
1585
1613
|
if (stillOwnsCall) this.activeTelephonyBindingsByCallId.delete(callId);
|
|
1586
1614
|
if (cause === "disconnect") this.streamDisconnectLifecycle.disconnect(callSid, streamSid);
|
|
1587
1615
|
else this.streamDisconnectLifecycle.retire(callSid, streamSid);
|
|
1588
1616
|
if (ownsCall && stillOwnsCall && cause && cause !== "disconnect") return emitCallEnd(cause);
|
|
1589
|
-
return Promise.resolve();
|
|
1590
1617
|
};
|
|
1591
|
-
|
|
1592
|
-
try {
|
|
1593
|
-
pending = Promise.resolve(session.close());
|
|
1594
|
-
} catch (error) {
|
|
1595
|
-
pending = Promise.reject(error instanceof Error ? error : new Error("Realtime provider close failed", { cause: error }));
|
|
1596
|
-
}
|
|
1597
|
-
bindingClosePromise = pending.then(finishClose, async (error) => {
|
|
1618
|
+
bindingClosePromise = closeBridgeSession().then(finishClose, async (error) => {
|
|
1598
1619
|
console.warn(`[voice-call] Failed to close realtime bridge ${callSid}: ${formatErrorMessage(error)}`);
|
|
1599
1620
|
try {
|
|
1600
1621
|
await finishClose();
|
|
@@ -1675,91 +1696,6 @@ var RealtimeCallHandler = class {
|
|
|
1675
1696
|
await sleep(Math.min(CONSULT_TRANSCRIPT_SETTLE_MS - quietFor, deadline - now));
|
|
1676
1697
|
}
|
|
1677
1698
|
}
|
|
1678
|
-
scheduleForcedAgentConsult(params) {
|
|
1679
|
-
if (this.config.consultPolicy !== "always" || this.activeBridgesByCallId.get(params.callId) !== params.session) return;
|
|
1680
|
-
const question = params.transcript.trim();
|
|
1681
|
-
if (!question) return;
|
|
1682
|
-
const handler = this.toolHandlers.get(REALTIME_VOICE_AGENT_CONSULT_TOOL_NAME);
|
|
1683
|
-
if (!handler) return;
|
|
1684
|
-
const existingForcedConsult = this.forcedConsultsByCallId.get(params.callId);
|
|
1685
|
-
if (existingForcedConsult && !existingForcedConsult.completedAt) return;
|
|
1686
|
-
const coordinator = params.harness.forcedConsults;
|
|
1687
|
-
if (coordinator.hasRecentNativeConsult(question, { allowUnknownQuestion: true })) return;
|
|
1688
|
-
coordinator.clearPending();
|
|
1689
|
-
const pending = coordinator.prepare(question);
|
|
1690
|
-
if (!pending) return;
|
|
1691
|
-
coordinator.schedule(pending, FORCED_CONSULT_FALLBACK_DELAY_MS, (handle) => {
|
|
1692
|
-
const activeForcedConsult = this.forcedConsultsByCallId.get(params.callId);
|
|
1693
|
-
if (activeForcedConsult && !activeForcedConsult.completedAt) return;
|
|
1694
|
-
this.runForcedAgentConsult({
|
|
1695
|
-
...params,
|
|
1696
|
-
handle,
|
|
1697
|
-
handler
|
|
1698
|
-
});
|
|
1699
|
-
});
|
|
1700
|
-
}
|
|
1701
|
-
async runForcedAgentConsult(params) {
|
|
1702
|
-
const coordinator = params.harness.forcedConsults;
|
|
1703
|
-
coordinator.markStarted(params.handle);
|
|
1704
|
-
const startedAt = Date.now();
|
|
1705
|
-
logger.debug(`[voice-call] realtime forced agent consult reason=${FORCED_CONSULT_REASON} consultPolicy=always callId=${params.callId} providerCallId=${params.callSid} chars=${params.handle.question.length}`);
|
|
1706
|
-
console.log(`[voice-call] realtime forced agent consult starting callId=${params.callId} providerCallId=${params.callSid} chars=${params.handle.question.length}`);
|
|
1707
|
-
params.clearAudio();
|
|
1708
|
-
params.beginConsultActivity();
|
|
1709
|
-
const abortController = new AbortController();
|
|
1710
|
-
const state = {
|
|
1711
|
-
owner: params.session,
|
|
1712
|
-
handle: params.handle,
|
|
1713
|
-
sendSpeechPrompt: true,
|
|
1714
|
-
cancelled: false,
|
|
1715
|
-
cancel: () => {
|
|
1716
|
-
abortController.abort(/* @__PURE__ */ new Error("Realtime forced consult owner was cancelled."));
|
|
1717
|
-
coordinator.markCancelled(params.handle);
|
|
1718
|
-
},
|
|
1719
|
-
promise: Promise.resolve().then(() => {
|
|
1720
|
-
abortController.signal.throwIfAborted();
|
|
1721
|
-
return params.handler({ question: params.handle.question }, params.callId, { abortSignal: abortController.signal });
|
|
1722
|
-
})
|
|
1723
|
-
};
|
|
1724
|
-
this.forcedConsultsByCallId.set(params.callId, state);
|
|
1725
|
-
try {
|
|
1726
|
-
const result = await state.promise;
|
|
1727
|
-
if (state.cancelled || this.forcedConsultsByCallId.get(params.callId) !== state) return;
|
|
1728
|
-
state.completedAt = Date.now();
|
|
1729
|
-
coordinator.markDelivered(params.handle);
|
|
1730
|
-
const text = readSpeakableRealtimeVoiceToolResult(result, {
|
|
1731
|
-
keys: ["text", "output"],
|
|
1732
|
-
maxChars: FORCED_CONSULT_RESULT_MAX_CHARS
|
|
1733
|
-
});
|
|
1734
|
-
if (!text) {
|
|
1735
|
-
console.warn(`[voice-call] realtime forced agent consult returned no speakable text callId=${params.callId} providerCallId=${params.callSid}`);
|
|
1736
|
-
return;
|
|
1737
|
-
}
|
|
1738
|
-
if (state.sendSpeechPrompt) {
|
|
1739
|
-
params.clearAudio();
|
|
1740
|
-
params.session.sendUserMessage(buildForcedConsultSpeechPrompt(text));
|
|
1741
|
-
}
|
|
1742
|
-
console.log(`[voice-call] realtime forced agent consult completed callId=${params.callId} providerCallId=${params.callSid} elapsedMs=${Date.now() - startedAt}`);
|
|
1743
|
-
consumeUserTranscript(params.userTranscriptOwner, params.consultTranscript);
|
|
1744
|
-
} catch (error) {
|
|
1745
|
-
if (!state.cancelled) {
|
|
1746
|
-
const result = buildRealtimeVoiceAgentErrorProviderResult(error);
|
|
1747
|
-
const failed = "error" in result;
|
|
1748
|
-
(failed ? console.warn : console.log)(`[voice-call] realtime forced agent consult ${failed ? "failed" : "cancelled"} callId=${params.callId} providerCallId=${params.callSid}${failed ? ` error=${result.error}` : ""}`);
|
|
1749
|
-
}
|
|
1750
|
-
} finally {
|
|
1751
|
-
params.endConsultActivity();
|
|
1752
|
-
if (!state.cancelled) {
|
|
1753
|
-
if (this.forcedConsultsByCallId.get(params.callId) !== state) coordinator.remove(params.handle);
|
|
1754
|
-
else setTimeout(() => {
|
|
1755
|
-
if (this.forcedConsultsByCallId.get(params.callId) === state) {
|
|
1756
|
-
this.forcedConsultsByCallId.delete(params.callId);
|
|
1757
|
-
coordinator.remove(params.handle);
|
|
1758
|
-
}
|
|
1759
|
-
}, FORCED_CONSULT_NATIVE_DEDUPE_MS).unref?.();
|
|
1760
|
-
}
|
|
1761
|
-
}
|
|
1762
|
-
}
|
|
1763
1699
|
async prepareCallInManager(callSid, callerMeta = {}) {
|
|
1764
1700
|
const baseFields = {
|
|
1765
1701
|
providerCallId: callSid,
|
|
@@ -1786,55 +1722,46 @@ var RealtimeCallHandler = class {
|
|
|
1786
1722
|
baseFields
|
|
1787
1723
|
} : null;
|
|
1788
1724
|
}
|
|
1789
|
-
async
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1725
|
+
async executeToolCall(bridge, callId, bridgeCallId, name, args, turnId, harness, userTranscriptOwner, consultTranscript, delegation) {
|
|
1726
|
+
if (name === "openclaw_end_call") {
|
|
1727
|
+
const binding = this.activeTelephonyBindingsByCallId.get(callId);
|
|
1728
|
+
if (!binding || binding.bridge !== bridge || !this.isActiveBridgeOwner(callId, bridge)) return;
|
|
1729
|
+
let result;
|
|
1730
|
+
try {
|
|
1731
|
+
result = await this.manager.endCall(callId);
|
|
1732
|
+
} catch (error) {
|
|
1733
|
+
result = {
|
|
1734
|
+
success: false,
|
|
1735
|
+
error: formatErrorMessage(error)
|
|
1736
|
+
};
|
|
1737
|
+
}
|
|
1738
|
+
if (this.activeTelephonyBindingsByCallId.get(callId) !== binding || !this.isActiveBridgeOwner(callId, bridge)) return;
|
|
1739
|
+
if (!result.success) {
|
|
1740
|
+
const toolResult = { error: `Could not end the current phone call: ${result.error?.trim() || "the telephony provider returned no reason"}. Tell the caller the call could not be ended and they can hang up or ask you to try again.` };
|
|
1741
|
+
await bridge.submitToolResult(bridgeCallId, toolResult);
|
|
1742
|
+
harness.emit({
|
|
1743
|
+
type: "tool.error",
|
|
1744
|
+
turnId,
|
|
1745
|
+
callId: bridgeCallId,
|
|
1746
|
+
payload: {
|
|
1747
|
+
name: REALTIME_VOICE_END_CALL_TOOL_NAME,
|
|
1748
|
+
result: toolResult
|
|
1749
|
+
},
|
|
1750
|
+
final: true
|
|
1751
|
+
});
|
|
1752
|
+
return;
|
|
1753
|
+
}
|
|
1754
|
+
harness.emit({
|
|
1755
|
+
type: "tool.result",
|
|
1756
|
+
turnId,
|
|
1757
|
+
callId: bridgeCallId,
|
|
1809
1758
|
payload: {
|
|
1810
1759
|
name: REALTIME_VOICE_END_CALL_TOOL_NAME,
|
|
1811
|
-
result:
|
|
1760
|
+
result: { success: true }
|
|
1812
1761
|
},
|
|
1813
1762
|
final: true
|
|
1814
1763
|
});
|
|
1815
|
-
|
|
1816
|
-
}
|
|
1817
|
-
params.harness.emit({
|
|
1818
|
-
type: "tool.result",
|
|
1819
|
-
turnId: params.turnId,
|
|
1820
|
-
callId: params.bridgeCallId,
|
|
1821
|
-
payload: {
|
|
1822
|
-
name: REALTIME_VOICE_END_CALL_TOOL_NAME,
|
|
1823
|
-
result: { success: true }
|
|
1824
|
-
},
|
|
1825
|
-
final: true
|
|
1826
|
-
});
|
|
1827
|
-
binding.endCall();
|
|
1828
|
-
}
|
|
1829
|
-
async executeToolCall(bridge, callId, bridgeCallId, name, args, turnId, harness, userTranscriptOwner, consultTranscript, delegation) {
|
|
1830
|
-
if (name === "openclaw_end_call") {
|
|
1831
|
-
await this.executeEndCallTool({
|
|
1832
|
-
bridge,
|
|
1833
|
-
callId,
|
|
1834
|
-
bridgeCallId,
|
|
1835
|
-
turnId,
|
|
1836
|
-
harness
|
|
1837
|
-
});
|
|
1764
|
+
binding.endCall();
|
|
1838
1765
|
return;
|
|
1839
1766
|
}
|
|
1840
1767
|
const handler = this.toolHandlers.get(name);
|
|
@@ -1857,7 +1784,6 @@ var RealtimeCallHandler = class {
|
|
|
1857
1784
|
return result;
|
|
1858
1785
|
};
|
|
1859
1786
|
const invokeHandler = async (handlerArgs, context) => {
|
|
1860
|
-
console.log(`[voice-call] realtime tool call executing callId=${callId} tool=${name} hasHandler=${Boolean(handler)}`);
|
|
1861
1787
|
try {
|
|
1862
1788
|
return handler ? await handler(handlerArgs, callId, context) : { error: `Tool "${name}" not available` };
|
|
1863
1789
|
} catch (error) {
|
|
@@ -1866,8 +1792,7 @@ var RealtimeCallHandler = class {
|
|
|
1866
1792
|
};
|
|
1867
1793
|
const logResult = (result) => {
|
|
1868
1794
|
const failed = hasResultError(result);
|
|
1869
|
-
|
|
1870
|
-
console.log(`[voice-call] realtime tool call completed callId=${callId} tool=${name} status=${failed ? "error" : "ok"} elapsedMs=${Date.now() - startedAt}${error ? ` error=${error}` : ""}`);
|
|
1795
|
+
if (failed) console.warn(`[voice-call] realtime tool call failed callId=${callId} tool=${name} elapsedMs=${Date.now() - startedAt}`);
|
|
1871
1796
|
return failed;
|
|
1872
1797
|
};
|
|
1873
1798
|
const submitWorkingResponse = async () => {
|