@0xmaxma/claude-gateway 2.1.3 → 2.1.5
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 +1 -1
- package/dist/agent/dreaming/reviewer.js +1 -1
- package/dist/agent/dreaming/reviewer.js.map +1 -1
- package/dist/agent/knowledge/shared-promote.d.ts +18 -29
- package/dist/agent/knowledge/shared-promote.d.ts.map +1 -1
- package/dist/agent/knowledge/shared-promote.js +26 -46
- package/dist/agent/knowledge/shared-promote.js.map +1 -1
- package/dist/agent/runner.d.ts +4 -1
- package/dist/agent/runner.d.ts.map +1 -1
- package/dist/agent/runner.js +6 -2
- package/dist/agent/runner.js.map +1 -1
- package/dist/agent/skill-learning/index.d.ts.map +1 -1
- package/dist/agent/skill-learning/index.js +2 -9
- package/dist/agent/skill-learning/index.js.map +1 -1
- package/dist/agent/skill-learning/telemetry.js +1 -1
- package/dist/agent/skill-learning/telemetry.js.map +1 -1
- package/dist/agent/skill-learning/trigger.d.ts +0 -1
- package/dist/agent/skill-learning/trigger.d.ts.map +1 -1
- package/dist/agent/skill-learning/trigger.js +1 -5
- package/dist/agent/skill-learning/trigger.js.map +1 -1
- package/dist/agent/skill-learning/types.d.ts +1 -3
- package/dist/agent/skill-learning/types.d.ts.map +1 -1
- package/dist/api/connectors-router.d.ts +4 -0
- package/dist/api/connectors-router.d.ts.map +1 -1
- package/dist/api/connectors-router.js +182 -2
- package/dist/api/connectors-router.js.map +1 -1
- package/dist/api/gateway-router.d.ts.map +1 -1
- package/dist/api/gateway-router.js +8 -0
- package/dist/api/gateway-router.js.map +1 -1
- package/dist/api/packages.js +7 -7
- package/dist/api/packages.js.map +1 -1
- package/dist/api/router.d.ts.map +1 -1
- package/dist/api/router.js +5 -3
- package/dist/api/router.js.map +1 -1
- package/dist/api/voice-call-router.js +1 -1
- package/dist/api/voice-call-router.js.map +1 -1
- package/dist/api/voice-router.js +4 -4
- package/dist/api/voice-router.js.map +1 -1
- package/dist/api/voice-settings-router.d.ts.map +1 -1
- package/dist/api/voice-settings-router.js +18 -4
- package/dist/api/voice-settings-router.js.map +1 -1
- package/dist/build-provenance.json +4 -4
- package/dist/cli/commands/update.d.ts.map +1 -1
- package/dist/cli/commands/update.js +48 -17
- package/dist/cli/commands/update.js.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +3 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/connectors/custom-connectors-store.d.ts +23 -0
- package/dist/connectors/custom-connectors-store.d.ts.map +1 -1
- package/dist/connectors/custom-connectors-store.js +23 -1
- package/dist/connectors/custom-connectors-store.js.map +1 -1
- package/dist/connectors/custom.d.ts +31 -0
- package/dist/connectors/custom.d.ts.map +1 -1
- package/dist/connectors/custom.js +37 -0
- package/dist/connectors/custom.js.map +1 -1
- package/dist/connectors/exposure.d.ts +23 -0
- package/dist/connectors/exposure.d.ts.map +1 -0
- package/dist/connectors/exposure.js +37 -0
- package/dist/connectors/exposure.js.map +1 -0
- package/dist/connectors/proxy.d.ts +84 -0
- package/dist/connectors/proxy.d.ts.map +1 -0
- package/dist/connectors/proxy.js +652 -0
- package/dist/connectors/proxy.js.map +1 -0
- package/dist/connectors/redirect.d.ts +12 -0
- package/dist/connectors/redirect.d.ts.map +1 -0
- package/dist/connectors/redirect.js +25 -0
- package/dist/connectors/redirect.js.map +1 -0
- package/dist/connectors/resolve.d.ts +11 -0
- package/dist/connectors/resolve.d.ts.map +1 -1
- package/dist/connectors/resolve.js +23 -2
- package/dist/connectors/resolve.js.map +1 -1
- package/dist/connectors/types.d.ts +18 -0
- package/dist/connectors/types.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/orchestration/capabilities.d.ts.map +1 -1
- package/dist/orchestration/capabilities.js +7 -1
- package/dist/orchestration/capabilities.js.map +1 -1
- package/dist/orchestration/config.d.ts +38 -0
- package/dist/orchestration/config.d.ts.map +1 -1
- package/dist/orchestration/config.js +16 -5
- package/dist/orchestration/config.js.map +1 -1
- package/dist/orchestration/display-stream.d.ts +5 -2
- package/dist/orchestration/display-stream.d.ts.map +1 -1
- package/dist/orchestration/display-stream.js +10 -10
- package/dist/orchestration/display-stream.js.map +1 -1
- package/dist/orchestration/progress-review.js +1 -1
- package/dist/orchestration/progress-review.js.map +1 -1
- package/dist/orchestration/report-promise.d.ts +0 -4
- package/dist/orchestration/report-promise.d.ts.map +1 -1
- package/dist/orchestration/report-promise.js +0 -29
- package/dist/orchestration/report-promise.js.map +1 -1
- package/dist/orchestration/response-schema.d.ts +9 -0
- package/dist/orchestration/response-schema.d.ts.map +1 -1
- package/dist/orchestration/response-schema.js +14 -1
- package/dist/orchestration/response-schema.js.map +1 -1
- package/dist/orchestration/runtime.d.ts.map +1 -1
- package/dist/orchestration/runtime.js +22 -15
- package/dist/orchestration/runtime.js.map +1 -1
- package/dist/orchestration/speech.d.ts +11 -2
- package/dist/orchestration/speech.d.ts.map +1 -1
- package/dist/orchestration/speech.js +25 -5
- package/dist/orchestration/speech.js.map +1 -1
- package/dist/orchestration/store.d.ts +2 -0
- package/dist/orchestration/store.d.ts.map +1 -1
- package/dist/orchestration/store.js.map +1 -1
- package/dist/orchestration/unanswered-inputs.d.ts +9 -0
- package/dist/orchestration/unanswered-inputs.d.ts.map +1 -1
- package/dist/orchestration/unanswered-inputs.js +39 -4
- package/dist/orchestration/unanswered-inputs.js.map +1 -1
- package/dist/packages/registry.d.ts +22 -3
- package/dist/packages/registry.d.ts.map +1 -1
- package/dist/packages/registry.js +33 -15
- package/dist/packages/registry.js.map +1 -1
- package/dist/session/codex-process.d.ts +2 -0
- package/dist/session/codex-process.d.ts.map +1 -1
- package/dist/session/codex-process.js +5 -1
- package/dist/session/codex-process.js.map +1 -1
- package/dist/session/container-connectors.d.ts +14 -1
- package/dist/session/container-connectors.d.ts.map +1 -1
- package/dist/session/container-connectors.js +36 -0
- package/dist/session/container-connectors.js.map +1 -1
- package/dist/session/managed-connectors.d.ts +9 -7
- package/dist/session/managed-connectors.d.ts.map +1 -1
- package/dist/session/managed-connectors.js +23 -9
- package/dist/session/managed-connectors.js.map +1 -1
- package/dist/session/process.d.ts +4 -0
- package/dist/session/process.d.ts.map +1 -1
- package/dist/session/process.js +32 -4
- package/dist/session/process.js.map +1 -1
- package/dist/ui/voice-call-client.d.ts +0 -14
- package/dist/ui/voice-call-client.d.ts.map +1 -1
- package/dist/ui/voice-call-client.js +1 -6
- package/dist/ui/voice-call-client.js.map +1 -1
- package/dist/ui/voice-call-ui.d.ts +3 -0
- package/dist/ui/voice-call-ui.d.ts.map +1 -1
- package/dist/ui/voice-call-ui.js +2 -1
- package/dist/ui/voice-call-ui.js.map +1 -1
- package/dist/voice/fast-ack.d.ts +13 -3
- package/dist/voice/fast-ack.d.ts.map +1 -1
- package/dist/voice/fast-ack.js +33 -15
- package/dist/voice/fast-ack.js.map +1 -1
- package/dist/voice/providers/elevenlabs-stt.d.ts +5 -1
- package/dist/voice/providers/elevenlabs-stt.d.ts.map +1 -1
- package/dist/voice/providers/elevenlabs-stt.js +5 -1
- package/dist/voice/providers/elevenlabs-stt.js.map +1 -1
- package/dist/voice/providers/registry.d.ts +5 -2
- package/dist/voice/providers/registry.d.ts.map +1 -1
- package/dist/voice/providers/registry.js +4 -3
- package/dist/voice/providers/registry.js.map +1 -1
- package/dist/voice/session.d.ts +16 -3
- package/dist/voice/session.d.ts.map +1 -1
- package/dist/voice/session.js +78 -15
- package/dist/voice/session.js.map +1 -1
- package/dist/voice/types.d.ts +14 -0
- package/dist/voice/types.d.ts.map +1 -1
- package/dist/voice/types.js +6 -1
- package/dist/voice/types.js.map +1 -1
- package/mcp/connector-bridge.ts +161 -0
- package/mcp/connector-launcher.mjs +44 -0
- package/package.json +2 -1
package/dist/ui/voice-call-ui.js
CHANGED
|
@@ -12,6 +12,7 @@ exports.generateVoiceCallGonePage = generateVoiceCallGonePage;
|
|
|
12
12
|
*/
|
|
13
13
|
const cli_viewer_ui_1 = require("./cli-viewer-ui");
|
|
14
14
|
const voice_call_client_1 = require("./voice-call-client");
|
|
15
|
+
const types_1 = require("../voice/types");
|
|
15
16
|
/** The page's refusal for a link that was used, or that expired or never existed. */
|
|
16
17
|
exports.VOICE_CALL_LINK_USED = (0, voice_call_client_1.voiceCallTicketFailure)(409, { error: 'Call link already used', code: 'CALL_LINK_USED' }).message;
|
|
17
18
|
exports.VOICE_CALL_LINK_EXPIRED = (0, voice_call_client_1.voiceCallTicketFailure)(410, { error: 'Call link expired' }).message;
|
|
@@ -169,7 +170,7 @@ const ICONS = {
|
|
|
169
170
|
end: '<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" style="transform: rotate(135deg)"><path d="M6.6 10.8a15.1 15.1 0 0 0 6.6 6.6l2.2-2.2a1 1 0 0 1 1-.25 11.4 11.4 0 0 0 3.6.57 1 1 0 0 1 1 1V20a1 1 0 0 1-1 1A17 17 0 0 1 3 4a1 1 0 0 1 1-1h3.5a1 1 0 0 1 1 1c0 1.25.2 2.45.57 3.57a1 1 0 0 1-.25 1z"/></svg>',
|
|
170
171
|
};
|
|
171
172
|
function generateVoiceCallPage(opts) {
|
|
172
|
-
const cfg = JSON.stringify({ pairingId: opts.pairingId, basePath: opts.basePath, maxUtteranceMs: opts.maxUtteranceMs, vad:
|
|
173
|
+
const cfg = JSON.stringify({ pairingId: opts.pairingId, basePath: opts.basePath, maxUtteranceMs: opts.maxUtteranceMs, vad: { ...types_1.VOICE_CALL_VAD, ...opts.vad }, playback: voice_call_client_1.VOICE_CALL_PLAYBACK, linkUsed: Boolean(opts.linkUsed) }).replace(/</g, '\\u003c');
|
|
173
174
|
const client = [voice_call_client_1.createResampler, voice_call_client_1.encodeVoiceCallFrame, voice_call_client_1.voiceCallLevel, voice_call_client_1.createVoiceCallVad, voice_call_client_1.createVoiceCallUplink, voice_call_client_1.voiceCallTicketFailure, voice_call_client_1.formatCallDuration, voice_call_client_1.voiceCallErrorView, voice_call_client_1.voiceCallReplyText].map(fn => fn.toString()).join(';\n');
|
|
174
175
|
const name = opts.botName ?? opts.agentId;
|
|
175
176
|
const initial = Array.from(name.trim())[0]?.toUpperCase() ?? '?';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"voice-call-ui.js","sourceRoot":"","sources":["../../src/ui/voice-call-ui.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"voice-call-ui.js","sourceRoot":"","sources":["../../src/ui/voice-call-ui.ts"],"names":[],"mappings":";;;AAiMA,sDAkWC;AAGD,8DAIC;AA1iBD;;;;;;GAMG;AACH,mDAA6E;AAC7E,2DAAyR;AACzR,0CAAgD;AAsBhD,qFAAqF;AACxE,QAAA,oBAAoB,GAAG,IAAA,0CAAsB,EAAC,GAAG,EAAE,EAAE,KAAK,EAAE,wBAAwB,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC,CAAC,OAAO,CAAC;AACxH,QAAA,uBAAuB,GAAG,IAAA,0CAAsB,EAAC,GAAG,EAAE,EAAE,KAAK,EAAE,mBAAmB,EAAE,CAAC,CAAC,OAAO,CAAC;AAE3G,6EAA6E;AAC7E,MAAM,eAAe,GAAG;;;;;;;;;;;;;;;2DAemC,CAAC;AAE5D;;;;;;GAMG;AACH,MAAM,cAAc,GAAG,GAAG,2CAAuB,CAAC,QAAQ,EAAE;;;;;;;;;;;;;;;;yDAgBH,CAAC;AAE1D;;;;;GAKG;AACH,MAAM,KAAK,GAAG,GAAG,0BAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+E1B,CAAC;AAEF;6FAC6F;AAC7F,MAAM,YAAY,GAAG;;MAEf,kCAAc,CAAC,QAAQ,EAAE;;;;;;;;;;;;YAYnB,CAAC;AAEb,MAAM,IAAI,GAAG,CAAC,GAAW,EAAE,KAAa,EAAE,EAAE,CAAC,eAAe,GAAG,8IAA8I,KAAK,QAAQ,CAAC;AAC3N,MAAM,OAAO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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAgUA,CAAC;IACX,OAAO,IAAA,oBAAI,EAAC,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,gBAAgB,4BAAY,aAAa,CAAC,CAAC;AACpF,CAAC;AAED,2FAA2F;AAC3F,SAAgB,yBAAyB,CAAC,OAAe;IACvD,MAAM,IAAI,GAAG,GAAG,YAAY;mFACqD,IAAA,0BAAU,EAAC,OAAO,CAAC,qBAAqB,CAAC;IAC1H,OAAO,IAAA,oBAAI,EAAC,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,gBAAgB,4BAAY,aAAa,CAAC,CAAC;AACpF,CAAC"}
|
package/dist/voice/fast-ack.d.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { type ModelConnection } from '../automation/model-choice-evaluator';
|
|
2
2
|
/** Bounds a spoken acknowledgement. It must say "I heard you" and nothing the answer could
|
|
3
|
-
* contradict, so a reply holding a
|
|
4
|
-
* spoken at all. */
|
|
5
|
-
export declare function fastAckText(reply: string): string | undefined;
|
|
3
|
+
* contradict, so a reply holding a link, markup, more than one short line, or a number the caller
|
|
4
|
+
* did not say (`heard`) is not spoken at all. */
|
|
5
|
+
export declare function fastAckText(reply: string, heard?: string): string | undefined;
|
|
6
|
+
/** A transcript with fewer than three letters or digits is too short to be a request: it gets no
|
|
7
|
+
* acknowledgement and costs no model call. Whether longer words are only hesitation or a restart
|
|
8
|
+
* is the model's call (it replies "-"), not a word list's. */
|
|
9
|
+
export declare function tooShort(transcript: string): boolean;
|
|
10
|
+
/** What the call has said so far: the caller's previous turns and the acknowledgements already spoken. */
|
|
11
|
+
export interface FastAckContext {
|
|
12
|
+
recentTurns: string[];
|
|
13
|
+
recentAcks: string[];
|
|
14
|
+
}
|
|
6
15
|
export interface FastAckResult {
|
|
7
16
|
text?: string;
|
|
8
17
|
inputTokens?: number;
|
|
@@ -21,6 +30,7 @@ export declare function fastAcknowledgement(transcript: string, options: {
|
|
|
21
30
|
timeoutMs: number;
|
|
22
31
|
gender?: string;
|
|
23
32
|
signal: AbortSignal;
|
|
33
|
+
context?: FastAckContext;
|
|
24
34
|
connection?: () => ModelConnection;
|
|
25
35
|
fetch?: typeof fetch;
|
|
26
36
|
}): Promise<FastAckResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fast-ack.d.ts","sourceRoot":"","sources":["../../src/voice/fast-ack.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fast-ack.d.ts","sourceRoot":"","sources":["../../src/voice/fast-ack.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsC,KAAK,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAIhH;;iDAEiD;AACjD,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,SAAK,GAAG,MAAM,GAAG,SAAS,CAMzE;AAED;;8DAE8D;AAC9D,wBAAgB,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAEpD;AAUD,0GAA0G;AAC1G,MAAM,WAAW,cAAc;IAAG,WAAW,EAAE,MAAM,EAAE,CAAC;IAAC,UAAU,EAAE,MAAM,EAAE,CAAA;CAAE;AAU/E,MAAM,WAAW,aAAa;IAAG,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE;AAExK;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,WAAW,CAAC;IAAC,OAAO,CAAC,EAAE,cAAc,CAAC;IACxK,UAAU,CAAC,EAAE,MAAM,eAAe,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAA;CAAE,GAAG,OAAO,CAAC,aAAa,CAAC,CAkBpF"}
|
package/dist/voice/fast-ack.js
CHANGED
|
@@ -1,28 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fastAckText = fastAckText;
|
|
4
|
+
exports.tooShort = tooShort;
|
|
4
5
|
exports.fastAcknowledgement = fastAcknowledgement;
|
|
5
6
|
const jev_gateway_1 = require("../orchestration/jev-gateway");
|
|
7
|
+
const speech_1 = require("../orchestration/speech");
|
|
6
8
|
const model_choice_evaluator_1 = require("../automation/model-choice-evaluator");
|
|
9
|
+
/** Thai digits as ASCII, so "623" and "๖๒๓" are the same number. */
|
|
10
|
+
const asciiDigits = (text) => text.replace(/[๐-๙]/g, digit => String(digit.charCodeAt(0) - 0x0e50));
|
|
7
11
|
/** Bounds a spoken acknowledgement. It must say "I heard you" and nothing the answer could
|
|
8
|
-
* contradict, so a reply holding a
|
|
9
|
-
* spoken at all. */
|
|
10
|
-
function fastAckText(reply) {
|
|
12
|
+
* contradict, so a reply holding a link, markup, more than one short line, or a number the caller
|
|
13
|
+
* did not say (`heard`) is not spoken at all. */
|
|
14
|
+
function fastAckText(reply, heard = '') {
|
|
11
15
|
const text = reply.trim();
|
|
12
|
-
if (!/\p{L}/u.test(text) || text.length > 80 || /[\r\
|
|
16
|
+
if (!/\p{L}/u.test(text) || text.length > 80 || /[\r\n{}[\]<>|*#`_~]|https?:|www\./i.test(text))
|
|
17
|
+
return undefined;
|
|
18
|
+
const said = new Set(asciiDigits(heard).match(/\d+/g) ?? []);
|
|
19
|
+
if ((asciiDigits(text).match(/\d+/g) ?? []).some(number => !said.has(number)))
|
|
13
20
|
return undefined;
|
|
14
21
|
return text;
|
|
15
22
|
}
|
|
23
|
+
/** A transcript with fewer than three letters or digits is too short to be a request: it gets no
|
|
24
|
+
* acknowledgement and costs no model call. Whether longer words are only hesitation or a restart
|
|
25
|
+
* is the model's call (it replies "-"), not a word list's. */
|
|
26
|
+
function tooShort(transcript) {
|
|
27
|
+
return transcript.replace(/[^\p{L}\p{M}\p{N}]+/gu, '').length < 3;
|
|
28
|
+
}
|
|
16
29
|
const SYSTEM = 'You voice a short acknowledgement in a live phone call while the assistant prepares its real answer. '
|
|
17
|
-
+ 'Reply with ONE short spoken phrase (at most 8 words) in the caller\'s language
|
|
18
|
-
+ '
|
|
19
|
-
+ '
|
|
20
|
-
+ '
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
30
|
+
+ 'Reply with ONE short spoken phrase (at most 8 words) in the caller\'s language that names the specific thing they just asked for, so they know they were understood '
|
|
31
|
+
+ '(for example "เดี๋ยวเปิด PR 623 ดูให้นะคะ" or "Let me look up that invoice"). '
|
|
32
|
+
+ 'Never answer, never state a fact, number, name, result or opinion the caller did not say, never promise an outcome, never ask a question. '
|
|
33
|
+
+ 'Never repeat or paraphrase an acknowledgement already spoken in this call, and never use a generic phrase that would fit any request. '
|
|
34
|
+
+ 'Reply with exactly "-" when the caller is only greeting, thanking, saying goodbye or making small talk, when their words are unclear, unfinished or only hesitation, '
|
|
35
|
+
+ 'or when no specific acknowledgement fits. When in doubt reply "-". Output only the phrase.';
|
|
36
|
+
function ackPrompt(transcript, context) {
|
|
37
|
+
const list = (items = []) => items.map(item => `- ${item.slice(0, 500)}`).join('\n');
|
|
38
|
+
const sections = [
|
|
39
|
+
context?.recentTurns.length ? `Earlier caller turns (context only):\n${list(context.recentTurns)}` : '',
|
|
40
|
+
context?.recentAcks.length ? `Acknowledgements already spoken in this call (do not repeat or paraphrase):\n${list(context.recentAcks)}` : '',
|
|
41
|
+
].filter(Boolean);
|
|
42
|
+
return sections.length ? `${sections.join('\n\n')}\n\nCaller's latest words:\n${transcript.slice(0, 2000)}` : transcript.slice(0, 2000);
|
|
43
|
+
}
|
|
26
44
|
/**
|
|
27
45
|
* One cheap model call for a spoken acknowledgement of the caller's words. It uses the same
|
|
28
46
|
* endpoint and credential as the agent's own Claude CLI (agentIdentity), so no new secret is
|
|
@@ -37,12 +55,12 @@ async function fastAcknowledgement(transcript, options) {
|
|
|
37
55
|
signal: AbortSignal.any([options.signal, AbortSignal.timeout(options.timeoutMs)]),
|
|
38
56
|
headers: { 'content-type': 'application/json', 'anthropic-version': '2023-06-01', ...(0, model_choice_evaluator_1.modelAuthHeaders)(connection, endpoint) },
|
|
39
57
|
body: JSON.stringify({ model: options.model, max_tokens: 60, thinking: { type: 'disabled' },
|
|
40
|
-
system: SYSTEM + (
|
|
58
|
+
system: SYSTEM + (0, speech_1.speechVoiceStyle)(options.gender), messages: [{ role: 'user', content: ackPrompt(transcript, options.context) }] }) });
|
|
41
59
|
const body = await response.json().catch(() => undefined);
|
|
42
60
|
const usage = { inputTokens: body?.usage?.input_tokens, outputTokens: body?.usage?.output_tokens };
|
|
43
61
|
if (!response.ok)
|
|
44
62
|
return { ...usage, elapsedMs: Date.now() - started, outcome: 'failed', code: `HTTP_${response.status}` };
|
|
45
|
-
const text = fastAckText((body?.content ?? []).filter(part => part.type === 'text').map(part => part.text ?? '').join(''));
|
|
63
|
+
const text = fastAckText((body?.content ?? []).filter(part => part.type === 'text').map(part => part.text ?? '').join(''), [transcript, ...(options.context?.recentTurns ?? [])].join(' '));
|
|
46
64
|
return { ...usage, text, elapsedMs: Date.now() - started, outcome: text ? 'ready' : 'skipped' };
|
|
47
65
|
}
|
|
48
66
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fast-ack.js","sourceRoot":"","sources":["../../src/voice/fast-ack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C;QAC3H,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,UAAU,EAAE,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,WAAW,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QAC5L,OAAO,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;IAClG,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;IAClM,CAAC;AACH,CAAC"}
|
|
@@ -5,12 +5,16 @@ export declare class ElevenLabsStt implements SttProvider {
|
|
|
5
5
|
private readonly model;
|
|
6
6
|
private readonly connect;
|
|
7
7
|
readonly id: string;
|
|
8
|
+
private readonly options;
|
|
8
9
|
readonly capabilities: {
|
|
9
10
|
partials: boolean;
|
|
10
11
|
manualCommit: boolean;
|
|
11
12
|
speechActivityEvents: boolean;
|
|
12
13
|
};
|
|
13
|
-
|
|
14
|
+
/** filterBackgroundAudio asks ElevenLabs to drop background speech and noise before transcribing; it can also drop quiet speech from the user. */
|
|
15
|
+
constructor(key: string, model?: string, connect?: SocketFactory, id?: string, options?: {
|
|
16
|
+
filterBackgroundAudio?: boolean;
|
|
17
|
+
});
|
|
14
18
|
open(options: {
|
|
15
19
|
format: AudioFormat;
|
|
16
20
|
language?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elevenlabs-stt.d.ts","sourceRoot":"","sources":["../../../src/voice/providers/elevenlabs-stt.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAY,UAAU,EAAE,WAAW,EAAmC,MAAM,UAAU,CAAC;AAE3G,OAAO,EAAsB,aAAa,EAAE,MAAM,UAAU,CAAC;AAE7D,qBAAa,aAAc,YAAW,WAAW;
|
|
1
|
+
{"version":3,"file":"elevenlabs-stt.d.ts","sourceRoot":"","sources":["../../../src/voice/providers/elevenlabs-stt.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAY,UAAU,EAAE,WAAW,EAAmC,MAAM,UAAU,CAAC;AAE3G,OAAO,EAAsB,aAAa,EAAE,MAAM,UAAU,CAAC;AAE7D,qBAAa,aAAc,YAAW,WAAW;IAGnC,OAAO,CAAC,QAAQ,CAAC,GAAG;IAAU,OAAO,CAAC,QAAQ,CAAC,KAAK;IAAyB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAAsC,QAAQ,CAAC,EAAE,EAAE,MAAM;IACxK,OAAO,CAAC,QAAQ,CAAC,OAAO;IAH1B,QAAQ,CAAC,YAAY;;;;MAAuE;IAC5F,kJAAkJ;gBACrH,GAAG,EAAE,MAAM,EAAmB,KAAK,SAAuB,EAAmB,OAAO,GAAE,aAAkC,EAAW,EAAE,GAAE,MAAqB,EACtK,OAAO,GAAE;QAAE,qBAAqB,CAAC,EAAE,OAAO,CAAA;KAAO;IAC9D,IAAI,CAAC,OAAO,EAAE;QAAE,MAAM,EAAE,WAAW,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,UAAU,CAAC;CAmD1G"}
|
|
@@ -6,11 +6,13 @@ const types_1 = require("../types");
|
|
|
6
6
|
const queue_1 = require("../queue");
|
|
7
7
|
const socket_1 = require("./socket");
|
|
8
8
|
class ElevenLabsStt {
|
|
9
|
-
|
|
9
|
+
/** filterBackgroundAudio asks ElevenLabs to drop background speech and noise before transcribing; it can also drop quiet speech from the user. */
|
|
10
|
+
constructor(key, model = 'scribe_v2_realtime', connect = socket_1.openProviderSocket, id = 'elevenlabs', options = {}) {
|
|
10
11
|
this.key = key;
|
|
11
12
|
this.model = model;
|
|
12
13
|
this.connect = connect;
|
|
13
14
|
this.id = id;
|
|
15
|
+
this.options = options;
|
|
14
16
|
this.capabilities = { partials: true, manualCommit: true, speechActivityEvents: false };
|
|
15
17
|
}
|
|
16
18
|
async open(options) {
|
|
@@ -24,6 +26,8 @@ class ElevenLabsStt {
|
|
|
24
26
|
url.searchParams.set('include_timestamps', 'false');
|
|
25
27
|
if (options.language)
|
|
26
28
|
url.searchParams.set('language_code', options.language);
|
|
29
|
+
if (this.options.filterBackgroundAudio)
|
|
30
|
+
url.searchParams.set('filter_background_audio', 'true');
|
|
27
31
|
const socket = await this.connect(url.toString(), { 'xi-api-key': this.key }, options.signal);
|
|
28
32
|
const events = new queue_1.BoundedQueue(65536, e => JSON.stringify(e).length);
|
|
29
33
|
let commitId, segment = 0, closed = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elevenlabs-stt.js","sourceRoot":"","sources":["../../../src/voice/providers/elevenlabs-stt.ts"],"names":[],"mappings":";;;AAAA,sCAA+C;AAC/C,oCAA2G;AAC3G,oCAAwC;AACxC,qCAA6D;AAE7D,MAAa,aAAa;IAExB,YAA6B,GAAW,EAAmB,QAAQ,oBAAoB,EAAmB,UAAyB,2BAAkB,EAAW,KAAa,YAAY;
|
|
1
|
+
{"version":3,"file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';
|
|
2
|
-
|
|
2
|
+
type SttConfig = {
|
|
3
3
|
provider: string;
|
|
4
4
|
model: string;
|
|
5
|
-
|
|
5
|
+
filterBackgroundAudio?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare function sttProvider(config: SttConfig): SttProvider;
|
|
6
8
|
export declare function ttsProvider(config: {
|
|
7
9
|
provider: string;
|
|
8
10
|
model: string;
|
|
9
11
|
}): TtsProvider;
|
|
12
|
+
export {};
|
|
10
13
|
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/voice/providers/registry.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAc,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/voice/providers/registry.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAc,MAAM,UAAU,CAAC;AAOhE,KAAK,SAAS,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAyBtF,wBAAgB,WAAW,CAAC,MAAM,EAAE,SAAS,GAAG,WAAW,CAO1D;AAeD,wBAAgB,WAAW,CAAC,MAAM,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,WAAW,CA4BpF"}
|
|
@@ -24,12 +24,13 @@ function makeSttProvider(config) {
|
|
|
24
24
|
return new openrouter_1.OpenRouterStt(config.provider, config.model);
|
|
25
25
|
if (['gemini', 'upstream:gemini'].includes(config.provider))
|
|
26
26
|
return config.model === 'gemini-3.5-transcribe-live' ? new gemini_live_stt_1.GeminiLiveStt(config.provider, config.model) : new gemini_1.GeminiStt(config.provider, config.model);
|
|
27
|
+
const elevenlabs = { filterBackgroundAudio: config.filterBackgroundAudio };
|
|
27
28
|
if (config.provider === 'managed:elevenlabs')
|
|
28
|
-
return new elevenlabs_stt_1.ElevenLabsStt((0, upstream_1.upstreamVoiceConnection)('elevenlabs', true).key, config.model, upstream_1.managedVoiceSocket, config.provider);
|
|
29
|
+
return new elevenlabs_stt_1.ElevenLabsStt((0, upstream_1.upstreamVoiceConnection)('elevenlabs', true).key, config.model, upstream_1.managedVoiceSocket, config.provider, elevenlabs);
|
|
29
30
|
if (config.provider === 'upstream:elevenlabs')
|
|
30
|
-
return new elevenlabs_stt_1.ElevenLabsStt((0, upstream_1.upstreamVoiceConnection)().key, config.model, upstream_1.upstreamVoiceSocket, 'upstream:elevenlabs');
|
|
31
|
+
return new elevenlabs_stt_1.ElevenLabsStt((0, upstream_1.upstreamVoiceConnection)().key, config.model, upstream_1.upstreamVoiceSocket, 'upstream:elevenlabs', elevenlabs);
|
|
31
32
|
if (config.provider === 'elevenlabs')
|
|
32
|
-
return new elevenlabs_stt_1.ElevenLabsStt(process.env.ELEVENLABS_API_KEY ?? '', config.model);
|
|
33
|
+
return new elevenlabs_stt_1.ElevenLabsStt(process.env.ELEVENLABS_API_KEY ?? '', config.model, undefined, undefined, elevenlabs);
|
|
33
34
|
if (['paxalabs', 'upstream:paxalabs', 'managed:paxalabs'].includes(config.provider))
|
|
34
35
|
return (0, paxalabs_live_stt_1.isPaxaRealtimeSttModel)(config.model) ? new paxalabs_live_stt_1.PaxaLabsLiveStt(config.provider, config.model) : new paxalabs_stt_1.PaxaLabsStt(config.provider, config.model);
|
|
35
36
|
if (config.provider === 'deepgram')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/voice/providers/registry.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/voice/providers/registry.ts"],"names":[],"mappings":";;AA0CA,kCAOC;AAeD,kCA4BC;AA5FD,oDAA6D;AAC7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E,EAAE,QAAQ,CAAC,EAAE,EAAE,YAAY,EAAE,QAAQ,CAAC,YAAY;QAC3D,cAAc,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,EAAC,OAAO,EAAC,EAAE;YACxD,MAAM,IAAA,yCAAyB,EAAC,MAAM,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;YAC5E,OAAO,QAAQ,CAAC,cAAe,CAAC,OAAO,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC,CAAC,SAAS;QACb,KAAK,CAAC,CAAC,UAAU,CAAC,OAAO;YACvB,MAAM,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACjC,KAAK,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACtC,CAAC,GACF,CAAC;AACJ,CAAC"}
|
package/dist/voice/session.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { VoiceDiagnosticSink } from './diagnostics';
|
|
|
2
2
|
import { VoicePlayback } from './playback';
|
|
3
3
|
import { SttProvider, TtsProvider } from './types';
|
|
4
4
|
import { VoiceFrame } from './protocol';
|
|
5
|
+
import { type FastAckContext } from './fast-ack';
|
|
5
6
|
export interface VoiceClient {
|
|
6
7
|
control(message: Record<string, unknown>): void;
|
|
7
8
|
audio(frame: Buffer): void;
|
|
@@ -16,9 +17,13 @@ export interface VoiceSessionOptions {
|
|
|
16
17
|
mergeWindowMs?: number;
|
|
17
18
|
/** A short spoken acknowledgement of the caller's words, played when the reply has not started speaking
|
|
18
19
|
* within fastAckAfterMs of admission. Undefined when no acknowledgement fits. */
|
|
19
|
-
acknowledge?: (transcript: string, signal: AbortSignal) => Promise<string | undefined>;
|
|
20
|
+
acknowledge?: (transcript: string, signal: AbortSignal, context: FastAckContext) => Promise<string | undefined>;
|
|
20
21
|
fastAckAfterMs?: number;
|
|
21
22
|
}
|
|
23
|
+
/** Per-turn facts the conversation turn is told. fastAck: a short acknowledgement may play before the reply. */
|
|
24
|
+
export interface VoiceTurnHints {
|
|
25
|
+
fastAck: boolean;
|
|
26
|
+
}
|
|
22
27
|
export declare class VoiceSession {
|
|
23
28
|
private readonly stt;
|
|
24
29
|
private readonly tts;
|
|
@@ -51,13 +56,18 @@ export declare class VoiceSession {
|
|
|
51
56
|
private silenceTimer?;
|
|
52
57
|
private admissionTimer?;
|
|
53
58
|
private pendingText;
|
|
59
|
+
/** This call's acknowledgement memory: the last caller turns, the acknowledgements actually spoken,
|
|
60
|
+
* and the admitted turn that was last acknowledged. */
|
|
61
|
+
private readonly acks;
|
|
62
|
+
/** Drops the current turn's acknowledgement if it has not begun playing. */
|
|
63
|
+
private supersedeAck?;
|
|
54
64
|
/** Speech candidates defer admission; only confirmed words interrupt inference. */
|
|
55
65
|
speechActivity(): void;
|
|
56
66
|
private scheduleAdmission;
|
|
57
67
|
private flushPending;
|
|
58
68
|
private readonly responses;
|
|
59
69
|
setVoice(voiceId: string): void;
|
|
60
|
-
constructor(stt: SttProvider, tts: TtsProvider, voiceId: string, client: VoiceClient, submit: (text: string, utteranceId: string, mark?: (phase: string) => void) => Promise<{
|
|
70
|
+
constructor(stt: SttProvider, tts: TtsProvider, voiceId: string, client: VoiceClient, submit: (text: string, utteranceId: string, mark?: (phase: string) => void, hints?: VoiceTurnHints) => Promise<{
|
|
61
71
|
inputId: string;
|
|
62
72
|
response: Promise<string>;
|
|
63
73
|
stream?: AsyncIterable<{
|
|
@@ -79,7 +89,9 @@ export declare class VoiceSession {
|
|
|
79
89
|
private admit;
|
|
80
90
|
private speakStream;
|
|
81
91
|
/** Starts the acknowledgement call with the turn. It is spoken only if the reply has not begun
|
|
82
|
-
* speaking `fastAckAfterMs` after admission, and never after barge-in
|
|
92
|
+
* speaking `fastAckAfterMs` after admission, and never after barge-in, the reply's own speech or
|
|
93
|
+
* another spoken response such as the turn's contextual acknowledgement. It is skipped on a transcript too
|
|
94
|
+
* short to be a request, right after an acknowledged turn, and when it repeats one already spoken in this call.
|
|
83
95
|
* It is audio only: no response text, chat message or history entry. */
|
|
84
96
|
private fastAck;
|
|
85
97
|
speechClaims(): string[];
|
|
@@ -91,6 +103,7 @@ export declare class VoiceSession {
|
|
|
91
103
|
requestId?: string;
|
|
92
104
|
speechOnly?: boolean;
|
|
93
105
|
}): void;
|
|
106
|
+
/** `begin`, when given, is asked as playback would start; false drops the speech unplayed. */
|
|
94
107
|
private enqueueSpeech;
|
|
95
108
|
private speak;
|
|
96
109
|
/** Each piece of spoken text is synthesized on its own provider stream, which ends as soon as the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/voice/session.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,mBAAmB,EAAiB,MAAM,eAAe,CAAC;AAK5F,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAc,WAAW,EAAoC,MAAM,SAAS,CAAC;AACjG,OAAO,EAAE,UAAU,EAAoB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/voice/session.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,mBAAmB,EAAiB,MAAM,eAAe,CAAC;AAK5F,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAc,WAAW,EAAoC,MAAM,SAAS,CAAC;AACjG,OAAO,EAAE,UAAU,EAAoB,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAE3D,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAChD,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,aAAa,IAAI,MAAM,CAAC;CACzB;AAGD,MAAM,WAAW,mBAAmB;I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IAW/B,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI;IAInD,OAAO,CAAC,cAAc;IAKtB,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,GAAG,QAAQ,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAK1E,SAAS;IAyBvB,OAAO,CAAC,iBAAiB;IACzB,OAAO,CAAC,OAAO;IAOf,OAAO,CAAC,KAAK;IACP,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAO7B"}
|
package/dist/voice/session.js
CHANGED
|
@@ -10,6 +10,36 @@ const turn_manager_1 = require("./turn-manager");
|
|
|
10
10
|
const playback_1 = require("./playback");
|
|
11
11
|
const types_1 = require("./types");
|
|
12
12
|
const protocol_1 = require("./protocol");
|
|
13
|
+
const fast_ack_1 = require("./fast-ack");
|
|
14
|
+
/** Acknowledgements more alike than this (character-bigram Dice) are heard as the same phrase. */
|
|
15
|
+
const ACK_SIMILARITY = 0.6;
|
|
16
|
+
function bigrams(text) {
|
|
17
|
+
const letters = text.toLowerCase().replace(/[^\p{L}\p{M}\p{N}]+/gu, '');
|
|
18
|
+
return Array.from({ length: Math.max(0, letters.length - 1) }, (_, i) => letters.slice(i, i + 2));
|
|
19
|
+
}
|
|
20
|
+
/** An acknowledgement repeats an earlier one when the two are nearly the same phrase and the new
|
|
21
|
+
* one adds nothing from the caller's words: "เดี๋ยวเช็คเมลให้นะคะ" after "เดี๋ยวเช็คปฏิทินให้นะคะ" names a
|
|
22
|
+
* new request, a second "รับทราบค่ะ กำลังดูให้นะคะ" does not. */
|
|
23
|
+
function repeats(earlier, reply, heard) {
|
|
24
|
+
const left = bigrams(earlier), right = bigrams(reply);
|
|
25
|
+
if (!left.length || !right.length)
|
|
26
|
+
return earlier.trim() === reply.trim();
|
|
27
|
+
const pool = new Map();
|
|
28
|
+
for (const pair of left)
|
|
29
|
+
pool.set(pair, (pool.get(pair) ?? 0) + 1);
|
|
30
|
+
const added = [];
|
|
31
|
+
for (const pair of right) {
|
|
32
|
+
const n = pool.get(pair);
|
|
33
|
+
if (n)
|
|
34
|
+
pool.set(pair, n - 1);
|
|
35
|
+
else
|
|
36
|
+
added.push(pair);
|
|
37
|
+
}
|
|
38
|
+
const caller = new Set(bigrams(heard));
|
|
39
|
+
if (added.filter(pair => caller.has(pair)).length >= 2 || added.some(pair => /\d\d/.test(pair) && caller.has(pair)))
|
|
40
|
+
return false;
|
|
41
|
+
return 2 * (right.length - added.length) / (left.length + right.length) >= ACK_SIMILARITY;
|
|
42
|
+
}
|
|
13
43
|
class VoiceSession {
|
|
14
44
|
/** Speech candidates defer admission; only confirmed words interrupt inference. */
|
|
15
45
|
speechActivity() {
|
|
@@ -56,6 +86,9 @@ class VoiceSession {
|
|
|
56
86
|
this.muteQueue = Promise.resolve();
|
|
57
87
|
this.speechQueue = Promise.resolve();
|
|
58
88
|
this.pendingText = [];
|
|
89
|
+
/** This call's acknowledgement memory: the last caller turns, the acknowledgements actually spoken,
|
|
90
|
+
* and the admitted turn that was last acknowledged. */
|
|
91
|
+
this.acks = { turns: [], spoken: [], admitted: 0 };
|
|
59
92
|
this.responses = new Set();
|
|
60
93
|
}
|
|
61
94
|
async start() {
|
|
@@ -238,14 +271,19 @@ class VoiceSession {
|
|
|
238
271
|
}
|
|
239
272
|
async admit(text, utteranceId, turn) {
|
|
240
273
|
this.client.control({ type: 'stt.final', utterance_id: utteranceId, text });
|
|
274
|
+
const index = this.acks.admitted++;
|
|
275
|
+
const context = { recentTurns: [...this.acks.turns], recentAcks: [...this.acks.spoken] };
|
|
276
|
+
this.acks.turns = [...this.acks.turns, text].slice(-2);
|
|
277
|
+
// Decided before submitting, so the turn knows whether an acknowledgement may precede its reply.
|
|
278
|
+
const skip = !this.options.acknowledge ? 'disabled' : (0, fast_ack_1.tooShort)(text) ? 'too_short' : this.acks.lastAcked === index - 1 ? 'cooldown' : undefined;
|
|
241
279
|
// The agent turn reports its own phases (process, first token, first spoken words) on this trace.
|
|
242
|
-
const accepted = await this.submit(text, utteranceId, phase => turn.trace.emit(phase));
|
|
280
|
+
const accepted = await this.submit(text, utteranceId, phase => turn.trace.emit(phase), { fastAck: !skip });
|
|
243
281
|
turn.ids.inputId = accepted.inputId;
|
|
244
282
|
turn.trace.emit('turn_admitted');
|
|
245
283
|
this.client.control({ type: 'utterance.accepted', utterance_id: utteranceId, input_id: accepted.inputId });
|
|
246
284
|
const epoch = this.interruption;
|
|
247
|
-
const ack = this.fastAck(text, epoch, turn);
|
|
248
|
-
void accepted.response.finally(ack.cancel).catch(() => { });
|
|
285
|
+
const ack = this.fastAck(text, epoch, turn, index, context, skip);
|
|
286
|
+
void accepted.response.finally(() => ack.cancel()).catch(() => { });
|
|
249
287
|
const streaming = accepted.stream ? this.speakStream(accepted.stream, epoch, accepted.response, turn, ack.cancel) : undefined;
|
|
250
288
|
const response = accepted.response.then(async (answer) => {
|
|
251
289
|
if (this.closed || epoch !== this.interruption)
|
|
@@ -270,7 +308,7 @@ class VoiceSession {
|
|
|
270
308
|
async speakStream(stream, epoch, response, turn, firstSpoken) {
|
|
271
309
|
const iterator = stream[Symbol.asyncIterator]();
|
|
272
310
|
const first = await iterator.next();
|
|
273
|
-
firstSpoken();
|
|
311
|
+
firstSpoken(!first.done);
|
|
274
312
|
if (this.closed)
|
|
275
313
|
return;
|
|
276
314
|
if (first.done) {
|
|
@@ -300,31 +338,50 @@ class VoiceSession {
|
|
|
300
338
|
}
|
|
301
339
|
}
|
|
302
340
|
/** Starts the acknowledgement call with the turn. It is spoken only if the reply has not begun
|
|
303
|
-
* speaking `fastAckAfterMs` after admission, and never after barge-in
|
|
341
|
+
* speaking `fastAckAfterMs` after admission, and never after barge-in, the reply's own speech or
|
|
342
|
+
* another spoken response such as the turn's contextual acknowledgement. It is skipped on a transcript too
|
|
343
|
+
* short to be a request, right after an acknowledged turn, and when it repeats one already spoken in this call.
|
|
304
344
|
* It is audio only: no response text, chat message or history entry. */
|
|
305
|
-
fastAck(text, interruption, turn) {
|
|
345
|
+
fastAck(text, interruption, turn, index, context, skip) {
|
|
306
346
|
const acknowledge = this.options.acknowledge;
|
|
307
|
-
if (!acknowledge)
|
|
347
|
+
if (!acknowledge || skip === 'disabled')
|
|
348
|
+
return { cancel: () => { } };
|
|
349
|
+
if (skip) {
|
|
350
|
+
turn.trace.emit('fast_ack_skipped', { code: skip });
|
|
308
351
|
return { cancel: () => { } };
|
|
352
|
+
}
|
|
309
353
|
const controller = new AbortController(), due = Date.now() + (this.options.fastAckAfterMs ?? 0);
|
|
310
|
-
let settled = false;
|
|
311
|
-
|
|
354
|
+
let settled = false, superseded = false;
|
|
355
|
+
// Before it is due the acknowledgement is simply cancelled; once queued, only speech that
|
|
356
|
+
// actually reaches the caller (`spoken`) replaces it.
|
|
357
|
+
const cancel = (spoken = false) => { if (spoken)
|
|
358
|
+
superseded = true; if (!settled) {
|
|
312
359
|
settled = true;
|
|
313
360
|
controller.abort();
|
|
314
361
|
} };
|
|
362
|
+
this.supersedeAck = () => cancel(true);
|
|
315
363
|
void (async () => {
|
|
316
|
-
const reply = await acknowledge(text, controller.signal).catch(() => undefined);
|
|
364
|
+
const reply = await acknowledge(text, controller.signal, context).catch(() => undefined);
|
|
317
365
|
if (!settled && reply)
|
|
318
366
|
await new Promise(resolve => setTimeout(resolve, Math.max(0, due - Date.now())));
|
|
319
367
|
if (settled || this.closed || interruption !== this.interruption)
|
|
320
368
|
return;
|
|
321
369
|
settled = true;
|
|
322
|
-
|
|
323
|
-
|
|
370
|
+
const code = !reply ? 'no_fit' : this.acks.spoken.some(spoken => repeats(spoken, reply, text)) ? 'duplicate' : undefined;
|
|
371
|
+
if (code) {
|
|
372
|
+
turn.trace.emit('fast_ack_skipped', { code });
|
|
324
373
|
return;
|
|
325
374
|
}
|
|
326
|
-
|
|
327
|
-
|
|
375
|
+
void this.enqueueSpeech((async function* () { yield reply; })(), undefined, interruption, turn, () => {
|
|
376
|
+
if (superseded) {
|
|
377
|
+
turn.trace.emit('fast_ack_skipped', { code: 'superseded' });
|
|
378
|
+
return false;
|
|
379
|
+
}
|
|
380
|
+
this.acks.spoken = [...this.acks.spoken, reply].slice(-3);
|
|
381
|
+
this.acks.lastAcked = index;
|
|
382
|
+
turn.trace.emit('fast_ack_sent');
|
|
383
|
+
return true;
|
|
384
|
+
});
|
|
328
385
|
})();
|
|
329
386
|
return { cancel };
|
|
330
387
|
}
|
|
@@ -333,6 +390,9 @@ class VoiceSession {
|
|
|
333
390
|
notifyResult(result) {
|
|
334
391
|
if (this.closed || this.claimedSpeech.has(result.responseId))
|
|
335
392
|
return;
|
|
393
|
+
// The agent's own spoken acknowledgement or clarification replaces a generic one that has not played yet.
|
|
394
|
+
if (result.speechOnly && result.spoken)
|
|
395
|
+
this.supersedeAck?.();
|
|
336
396
|
if (!result.speechOnly)
|
|
337
397
|
this.client.control({ type: 'response.text', response_id: result.responseId, request_id: result.requestId, text: result.text, final: true });
|
|
338
398
|
if (!result.spoken) {
|
|
@@ -345,7 +405,8 @@ class VoiceSession {
|
|
|
345
405
|
yield result.spoken;
|
|
346
406
|
})(), result.responseId);
|
|
347
407
|
}
|
|
348
|
-
|
|
408
|
+
/** `begin`, when given, is asked as playback would start; false drops the speech unplayed. */
|
|
409
|
+
enqueueSpeech(text, responseId, interruption = this.interruption, turn, begin) {
|
|
349
410
|
if (responseId) {
|
|
350
411
|
if (this.claimedSpeech.has(responseId))
|
|
351
412
|
return Promise.resolve();
|
|
@@ -363,6 +424,8 @@ class VoiceSession {
|
|
|
363
424
|
this.claimedSpeech.delete(responseId);
|
|
364
425
|
return;
|
|
365
426
|
}
|
|
427
|
+
if (begin && !begin())
|
|
428
|
+
return;
|
|
366
429
|
await this.speak(text, this.playback.epoch, responseId, trace, turn);
|
|
367
430
|
// Synthesis completion is not playback completion. Preserve the tail before
|
|
368
431
|
// the next utterance clears the playback epoch.
|