@voicethere/agent 0.29.1 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/agent.js +61 -5
- package/dist/flow/effects-node.d.ts.map +1 -1
- package/dist/flow/effects-node.js +5 -1
- package/dist/flow/effects-node.js.map +1 -1
- package/dist/llm/agent/create-llm-agent.d.ts.map +1 -1
- package/dist/llm/agent/create-llm-agent.js +5 -1
- package/dist/llm/agent/create-llm-agent.js.map +1 -1
- package/dist/llm/agent/redact.d.ts +16 -0
- package/dist/llm/agent/redact.d.ts.map +1 -1
- package/dist/llm/agent/redact.js +28 -6
- package/dist/llm/agent/redact.js.map +1 -1
- package/dist/protocol.d.ts +16 -3
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js.map +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +75 -4
- package/dist/runtime.js.map +1 -1
- package/dist/templates/echo/agent.js +59 -2
- package/dist/templates/echo-dc/agent.js +59 -2
- package/dist/templates/flow-agent/agent.js +76 -9
- package/dist/templates/game-sync/agent.js +59 -2
- package/dist/templates/language-switch/agent.js +59 -2
- package/dist/templates/llm-agent/agent.js +76 -9
- package/dist/templates/llm-board/agent.js +60746 -0
- package/dist/templates/llm-docs-rag/agent.js +76 -9
- package/dist/templates/llm-language-tutor/agent.js +60549 -0
- package/dist/templates/llm-mcp-service/agent.js +76 -9
- package/dist/templates/llm-support-sticky-user/agent.js +76 -9
- package/dist/templates/positional-tts/agent.js +59 -2
- package/dist/templates/recording-consent/agent.js +59 -2
- package/dist/templates/registry.d.ts.map +1 -1
- package/dist/templates/registry.js +50 -0
- package/dist/templates/registry.js.map +1 -1
- package/dist/templates/spatial-showcase/agent.js +59 -2
- package/dist/templates/speaker-gate/agent.js +61 -4
- package/dist/templates/voice-showcase/agent.js +59 -2
- package/dist/templates/voice-starter/agent.js +59 -2
- package/dist/templates/webhooks/agent.js +59 -2
- package/dist/templates/webhooks-redis/agent.js +59 -2
- package/dist/templates/world-sync/agent.js +59 -2
- package/dist/templates/world-sync-binary/agent.js +59 -2
- package/eject/llm/loop.ts +6 -2
- package/package.json +2 -1
- package/templates/README.md +7 -5
- package/templates/llm-agent/README.md +1 -1
- package/templates/llm-board/README.md +44 -0
- package/templates/llm-board/agent.ts +235 -0
- package/templates/llm-board/board.ts +196 -0
- package/templates/llm-board/md.d.ts +4 -0
- package/templates/llm-board/prompt.md +11 -0
- package/templates/llm-board/voicethere.llm.json +49 -0
- package/templates/llm-language-tutor/README.md +32 -0
- package/templates/llm-language-tutor/agent.ts +22 -0
- package/templates/llm-language-tutor/knowledge/lessons.md +121 -0
- package/templates/llm-language-tutor/md.d.ts +4 -0
- package/templates/llm-language-tutor/prompt.md +9 -0
- package/templates/llm-language-tutor/voicethere.llm.json +39 -0
- package/templates/speaker-gate/README.md +3 -1
- package/templates/speaker-gate/agent.ts +5 -1
|
@@ -244,6 +244,12 @@ function isSetSpeakerGateResultMessage(value) {
|
|
|
244
244
|
const msg = value;
|
|
245
245
|
return msg.type === "setSpeakerGateResult" && typeof msg.requestId === "string";
|
|
246
246
|
}
|
|
247
|
+
function isSpeakerGateStateMessage(value) {
|
|
248
|
+
if (!value || typeof value !== "object")
|
|
249
|
+
return false;
|
|
250
|
+
const msg = value;
|
|
251
|
+
return msg.type === "speaker_gate_state" && typeof msg.sessionId === "string" && typeof msg.mode === "string" && SPEAKER_GATE_MODES.includes(msg.mode) && (msg.bargeIn === void 0 || typeof msg.bargeIn === "string" && SPEAKER_GATE_BARGE_IN.includes(msg.bargeIn));
|
|
252
|
+
}
|
|
247
253
|
function isResetSpeakerEnrollmentResultMessage(value) {
|
|
248
254
|
if (!value || typeof value !== "object")
|
|
249
255
|
return false;
|
|
@@ -298,7 +304,7 @@ function isParentMessage(value) {
|
|
|
298
304
|
if (!value || typeof value !== "object")
|
|
299
305
|
return false;
|
|
300
306
|
const msg = value;
|
|
301
|
-
return msg.type === "session_start" || msg.type === "speech_event" || msg.type === "session_end" || msg.type === "data_channel_message" || msg.type === "data_channel_binary" || msg.type === "idle_timeout" || msg.type === "session_time_limit" || msg.type === "session_time_limit_control_ack" || msg.type === "recording_control_ack" || msg.type === "conversation_history_control_ack" || msg.type === "user_identified" || msg.type === "user_history_response" || msg.type === "play_ack" || msg.type === "play_status_ack" || msg.type === "play_stop_ack" || msg.type === "play_pose_ack" || msg.type === "mix_control_ack" || msg.type === "stt_control_ack" || msg.type === "voice_language_control_ack" || msg.type === "voice_language_prepare_result" || msg.type === "voice_replay_last_result" || msg.type === "setSpeakerGateResult" || msg.type === "resetSpeakerEnrollmentResult" || msg.type === "speak_result" || msg.type === "barge_in_control_ack" || msg.type === "agent_interrupted" || msg.type === "webhook";
|
|
307
|
+
return msg.type === "session_start" || msg.type === "speech_event" || msg.type === "session_end" || msg.type === "data_channel_message" || msg.type === "data_channel_binary" || msg.type === "idle_timeout" || msg.type === "session_time_limit" || msg.type === "session_time_limit_control_ack" || msg.type === "recording_control_ack" || msg.type === "conversation_history_control_ack" || msg.type === "user_identified" || msg.type === "user_history_response" || msg.type === "play_ack" || msg.type === "play_status_ack" || msg.type === "play_stop_ack" || msg.type === "play_pose_ack" || msg.type === "mix_control_ack" || msg.type === "stt_control_ack" || msg.type === "voice_language_control_ack" || msg.type === "voice_language_prepare_result" || msg.type === "voice_replay_last_result" || msg.type === "setSpeakerGateResult" || msg.type === "resetSpeakerEnrollmentResult" || msg.type === "speaker_gate_state" || msg.type === "speak_result" || msg.type === "barge_in_control_ack" || msg.type === "agent_interrupted" || msg.type === "webhook";
|
|
302
308
|
}
|
|
303
309
|
function isSessionScopedParentMessage(value) {
|
|
304
310
|
return isParentMessage(value) && !isWebhookMessage(value);
|
|
@@ -319,6 +325,7 @@ var voiceLanguageSwitchAvailableBySessionId = /* @__PURE__ */ new Map();
|
|
|
319
325
|
var lastVoiceLanguageBySessionId = /* @__PURE__ */ new Map();
|
|
320
326
|
var speakerGateBySessionId = /* @__PURE__ */ new Map();
|
|
321
327
|
var pendingSpeakerGateAcks = /* @__PURE__ */ new Map();
|
|
328
|
+
var pendingSpeakerGateStateBySessionId = /* @__PURE__ */ new Map();
|
|
322
329
|
var pendingSpeakerResets = /* @__PURE__ */ new Map();
|
|
323
330
|
var ttsPoseAvailableBySessionId = /* @__PURE__ */ new Map();
|
|
324
331
|
var speakControlAvailableBySessionId = /* @__PURE__ */ new Map();
|
|
@@ -607,6 +614,41 @@ function handleResetSpeakerEnrollmentResult(message) {
|
|
|
607
614
|
pendingSpeakerResets.delete(message.requestId);
|
|
608
615
|
pending.resolve(message.ok ? { ok: true } : { ok: false, reason: message.reason });
|
|
609
616
|
}
|
|
617
|
+
function applySpeakerGateState(prev, message) {
|
|
618
|
+
return {
|
|
619
|
+
available: true,
|
|
620
|
+
mode: message.mode,
|
|
621
|
+
bargeIn: message.bargeIn ?? prev.bargeIn
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
function handleSpeakerGateState(message) {
|
|
625
|
+
if (endedSessionIds.has(message.sessionId))
|
|
626
|
+
return;
|
|
627
|
+
const prev = speakerGateBySessionId.get(message.sessionId);
|
|
628
|
+
if (prev) {
|
|
629
|
+
if (prev.available) {
|
|
630
|
+
speakerGateBySessionId.set(message.sessionId, applySpeakerGateState(prev, message));
|
|
631
|
+
}
|
|
632
|
+
return;
|
|
633
|
+
}
|
|
634
|
+
pendingSpeakerGateStateBySessionId.set(message.sessionId, message);
|
|
635
|
+
}
|
|
636
|
+
function clearPendingSpeakerRequestsForSession(sessionId, reason) {
|
|
637
|
+
for (const [requestId, pending] of pendingSpeakerGateAcks) {
|
|
638
|
+
if (pending.sessionId !== sessionId)
|
|
639
|
+
continue;
|
|
640
|
+
clearTimeout(pending.timer);
|
|
641
|
+
pendingSpeakerGateAcks.delete(requestId);
|
|
642
|
+
pending.resolve({ ok: false, reason });
|
|
643
|
+
}
|
|
644
|
+
for (const [requestId, pending] of pendingSpeakerResets) {
|
|
645
|
+
if (pending.sessionId !== sessionId)
|
|
646
|
+
continue;
|
|
647
|
+
clearTimeout(pending.timer);
|
|
648
|
+
pendingSpeakerResets.delete(requestId);
|
|
649
|
+
pending.resolve({ ok: false, reason });
|
|
650
|
+
}
|
|
651
|
+
}
|
|
610
652
|
function handleVoiceReplayLastResult(message) {
|
|
611
653
|
const pending = pendingVoiceReplays.get(message.requestId);
|
|
612
654
|
if (!pending)
|
|
@@ -836,7 +878,12 @@ async function handleParentMessage(message, handlers) {
|
|
|
836
878
|
speakControlAvailableBySessionId.set(message.sessionId, message.speakControlAvailable ?? false);
|
|
837
879
|
chatReplyRecordAvailableBySessionId.set(message.sessionId, message.chatReplyRecordAvailable ?? false);
|
|
838
880
|
sessionTimeLimitAvailableBySessionId.set(message.sessionId, message.sessionTimeLimitAvailable ?? false);
|
|
839
|
-
|
|
881
|
+
{
|
|
882
|
+
const initial = message.speakerGate?.available === true ? message.speakerGate : { available: false };
|
|
883
|
+
const early = pendingSpeakerGateStateBySessionId.get(message.sessionId);
|
|
884
|
+
pendingSpeakerGateStateBySessionId.delete(message.sessionId);
|
|
885
|
+
speakerGateBySessionId.set(message.sessionId, early && initial.available ? applySpeakerGateState(initial, early) : initial);
|
|
886
|
+
}
|
|
840
887
|
if (message.voiceLanguageSwitch) {
|
|
841
888
|
voiceLanguageSwitchSettingsBySessionId.set(message.sessionId, message.voiceLanguageSwitch);
|
|
842
889
|
} else {
|
|
@@ -963,6 +1010,8 @@ async function handleParentMessage(message, handlers) {
|
|
|
963
1010
|
mixAvailableBySessionId.delete(message.sessionId);
|
|
964
1011
|
voiceLanguageSwitchAvailableBySessionId.delete(message.sessionId);
|
|
965
1012
|
speakerGateBySessionId.delete(message.sessionId);
|
|
1013
|
+
pendingSpeakerGateStateBySessionId.delete(message.sessionId);
|
|
1014
|
+
clearPendingSpeakerRequestsForSession(message.sessionId, "session_ended");
|
|
966
1015
|
voiceLanguageSwitchSettingsBySessionId.delete(message.sessionId);
|
|
967
1016
|
lastVoiceLanguageBySessionId.delete(message.sessionId);
|
|
968
1017
|
ttsPoseAvailableBySessionId.delete(message.sessionId);
|
|
@@ -1056,6 +1105,10 @@ function defineAgent(handlers) {
|
|
|
1056
1105
|
handleResetSpeakerEnrollmentResult(message);
|
|
1057
1106
|
return;
|
|
1058
1107
|
}
|
|
1108
|
+
if (isSpeakerGateStateMessage(message)) {
|
|
1109
|
+
handleSpeakerGateState(message);
|
|
1110
|
+
return;
|
|
1111
|
+
}
|
|
1059
1112
|
if (isWebhookMessage(message)) {
|
|
1060
1113
|
void agentStartReady.then(() => handleWebhookMessage(message, handlers));
|
|
1061
1114
|
return;
|
|
@@ -1064,6 +1117,8 @@ function defineAgent(handlers) {
|
|
|
1064
1117
|
return;
|
|
1065
1118
|
if (message.type === "session_end") {
|
|
1066
1119
|
endedSessionIds.add(message.sessionId);
|
|
1120
|
+
pendingSpeakerGateStateBySessionId.delete(message.sessionId);
|
|
1121
|
+
clearPendingSpeakerRequestsForSession(message.sessionId, "session_ended");
|
|
1067
1122
|
clearPendingSpeakForSession(message.sessionId, "session_ended");
|
|
1068
1123
|
clearPendingRecordingAcksForSession(message.sessionId, "session_ended");
|
|
1069
1124
|
clearPendingConversationHistoryAcksForSession(message.sessionId, "session_ended");
|
|
@@ -1354,6 +1409,8 @@ function cancelSpeech(sessionId, target) {
|
|
|
1354
1409
|
...target?.turnId ? { turnId: target.turnId } : {}
|
|
1355
1410
|
});
|
|
1356
1411
|
}
|
|
1412
|
+
var SPEAKER_GATE_MODES = ["disabled", "auto", "manual"];
|
|
1413
|
+
var SPEAKER_GATE_BARGE_IN = ["caller_only", "anyone"];
|
|
1357
1414
|
function sendToClient(sessionId, payload) {
|
|
1358
1415
|
sendParentMessage({ type: "send_to_client", sessionId, payload });
|
|
1359
1416
|
}
|
|
@@ -10996,6 +10996,12 @@ function isSetSpeakerGateResultMessage(value) {
|
|
|
10996
10996
|
const msg = value;
|
|
10997
10997
|
return msg.type === "setSpeakerGateResult" && typeof msg.requestId === "string";
|
|
10998
10998
|
}
|
|
10999
|
+
function isSpeakerGateStateMessage(value) {
|
|
11000
|
+
if (!value || typeof value !== "object")
|
|
11001
|
+
return false;
|
|
11002
|
+
const msg = value;
|
|
11003
|
+
return msg.type === "speaker_gate_state" && typeof msg.sessionId === "string" && typeof msg.mode === "string" && SPEAKER_GATE_MODES.includes(msg.mode) && (msg.bargeIn === void 0 || typeof msg.bargeIn === "string" && SPEAKER_GATE_BARGE_IN.includes(msg.bargeIn));
|
|
11004
|
+
}
|
|
10999
11005
|
function isResetSpeakerEnrollmentResultMessage(value) {
|
|
11000
11006
|
if (!value || typeof value !== "object")
|
|
11001
11007
|
return false;
|
|
@@ -11050,7 +11056,7 @@ function isParentMessage(value) {
|
|
|
11050
11056
|
if (!value || typeof value !== "object")
|
|
11051
11057
|
return false;
|
|
11052
11058
|
const msg = value;
|
|
11053
|
-
return msg.type === "session_start" || msg.type === "speech_event" || msg.type === "session_end" || msg.type === "data_channel_message" || msg.type === "data_channel_binary" || msg.type === "idle_timeout" || msg.type === "session_time_limit" || msg.type === "session_time_limit_control_ack" || msg.type === "recording_control_ack" || msg.type === "conversation_history_control_ack" || msg.type === "user_identified" || msg.type === "user_history_response" || msg.type === "play_ack" || msg.type === "play_status_ack" || msg.type === "play_stop_ack" || msg.type === "play_pose_ack" || msg.type === "mix_control_ack" || msg.type === "stt_control_ack" || msg.type === "voice_language_control_ack" || msg.type === "voice_language_prepare_result" || msg.type === "voice_replay_last_result" || msg.type === "setSpeakerGateResult" || msg.type === "resetSpeakerEnrollmentResult" || msg.type === "speak_result" || msg.type === "barge_in_control_ack" || msg.type === "agent_interrupted" || msg.type === "webhook";
|
|
11059
|
+
return msg.type === "session_start" || msg.type === "speech_event" || msg.type === "session_end" || msg.type === "data_channel_message" || msg.type === "data_channel_binary" || msg.type === "idle_timeout" || msg.type === "session_time_limit" || msg.type === "session_time_limit_control_ack" || msg.type === "recording_control_ack" || msg.type === "conversation_history_control_ack" || msg.type === "user_identified" || msg.type === "user_history_response" || msg.type === "play_ack" || msg.type === "play_status_ack" || msg.type === "play_stop_ack" || msg.type === "play_pose_ack" || msg.type === "mix_control_ack" || msg.type === "stt_control_ack" || msg.type === "voice_language_control_ack" || msg.type === "voice_language_prepare_result" || msg.type === "voice_replay_last_result" || msg.type === "setSpeakerGateResult" || msg.type === "resetSpeakerEnrollmentResult" || msg.type === "speaker_gate_state" || msg.type === "speak_result" || msg.type === "barge_in_control_ack" || msg.type === "agent_interrupted" || msg.type === "webhook";
|
|
11054
11060
|
}
|
|
11055
11061
|
function isSessionScopedParentMessage(value) {
|
|
11056
11062
|
return isParentMessage(value) && !isWebhookMessage(value);
|
|
@@ -11071,6 +11077,7 @@ var voiceLanguageSwitchAvailableBySessionId = /* @__PURE__ */ new Map();
|
|
|
11071
11077
|
var lastVoiceLanguageBySessionId = /* @__PURE__ */ new Map();
|
|
11072
11078
|
var speakerGateBySessionId = /* @__PURE__ */ new Map();
|
|
11073
11079
|
var pendingSpeakerGateAcks = /* @__PURE__ */ new Map();
|
|
11080
|
+
var pendingSpeakerGateStateBySessionId = /* @__PURE__ */ new Map();
|
|
11074
11081
|
var pendingSpeakerResets = /* @__PURE__ */ new Map();
|
|
11075
11082
|
var ttsPoseAvailableBySessionId = /* @__PURE__ */ new Map();
|
|
11076
11083
|
var speakControlAvailableBySessionId = /* @__PURE__ */ new Map();
|
|
@@ -11358,6 +11365,41 @@ function handleResetSpeakerEnrollmentResult(message) {
|
|
|
11358
11365
|
pendingSpeakerResets.delete(message.requestId);
|
|
11359
11366
|
pending.resolve(message.ok ? { ok: true } : { ok: false, reason: message.reason });
|
|
11360
11367
|
}
|
|
11368
|
+
function applySpeakerGateState(prev, message) {
|
|
11369
|
+
return {
|
|
11370
|
+
available: true,
|
|
11371
|
+
mode: message.mode,
|
|
11372
|
+
bargeIn: message.bargeIn ?? prev.bargeIn
|
|
11373
|
+
};
|
|
11374
|
+
}
|
|
11375
|
+
function handleSpeakerGateState(message) {
|
|
11376
|
+
if (endedSessionIds.has(message.sessionId))
|
|
11377
|
+
return;
|
|
11378
|
+
const prev = speakerGateBySessionId.get(message.sessionId);
|
|
11379
|
+
if (prev) {
|
|
11380
|
+
if (prev.available) {
|
|
11381
|
+
speakerGateBySessionId.set(message.sessionId, applySpeakerGateState(prev, message));
|
|
11382
|
+
}
|
|
11383
|
+
return;
|
|
11384
|
+
}
|
|
11385
|
+
pendingSpeakerGateStateBySessionId.set(message.sessionId, message);
|
|
11386
|
+
}
|
|
11387
|
+
function clearPendingSpeakerRequestsForSession(sessionId, reason) {
|
|
11388
|
+
for (const [requestId, pending] of pendingSpeakerGateAcks) {
|
|
11389
|
+
if (pending.sessionId !== sessionId)
|
|
11390
|
+
continue;
|
|
11391
|
+
clearTimeout(pending.timer);
|
|
11392
|
+
pendingSpeakerGateAcks.delete(requestId);
|
|
11393
|
+
pending.resolve({ ok: false, reason });
|
|
11394
|
+
}
|
|
11395
|
+
for (const [requestId, pending] of pendingSpeakerResets) {
|
|
11396
|
+
if (pending.sessionId !== sessionId)
|
|
11397
|
+
continue;
|
|
11398
|
+
clearTimeout(pending.timer);
|
|
11399
|
+
pendingSpeakerResets.delete(requestId);
|
|
11400
|
+
pending.resolve({ ok: false, reason });
|
|
11401
|
+
}
|
|
11402
|
+
}
|
|
11361
11403
|
function handleVoiceReplayLastResult(message) {
|
|
11362
11404
|
const pending = pendingVoiceReplays.get(message.requestId);
|
|
11363
11405
|
if (!pending)
|
|
@@ -11584,7 +11626,12 @@ async function handleParentMessage(message, handlers) {
|
|
|
11584
11626
|
speakControlAvailableBySessionId.set(message.sessionId, message.speakControlAvailable ?? false);
|
|
11585
11627
|
chatReplyRecordAvailableBySessionId.set(message.sessionId, message.chatReplyRecordAvailable ?? false);
|
|
11586
11628
|
sessionTimeLimitAvailableBySessionId.set(message.sessionId, message.sessionTimeLimitAvailable ?? false);
|
|
11587
|
-
|
|
11629
|
+
{
|
|
11630
|
+
const initial = message.speakerGate?.available === true ? message.speakerGate : { available: false };
|
|
11631
|
+
const early = pendingSpeakerGateStateBySessionId.get(message.sessionId);
|
|
11632
|
+
pendingSpeakerGateStateBySessionId.delete(message.sessionId);
|
|
11633
|
+
speakerGateBySessionId.set(message.sessionId, early && initial.available ? applySpeakerGateState(initial, early) : initial);
|
|
11634
|
+
}
|
|
11588
11635
|
if (message.voiceLanguageSwitch) {
|
|
11589
11636
|
voiceLanguageSwitchSettingsBySessionId.set(message.sessionId, message.voiceLanguageSwitch);
|
|
11590
11637
|
} else {
|
|
@@ -11711,6 +11758,8 @@ async function handleParentMessage(message, handlers) {
|
|
|
11711
11758
|
mixAvailableBySessionId.delete(message.sessionId);
|
|
11712
11759
|
voiceLanguageSwitchAvailableBySessionId.delete(message.sessionId);
|
|
11713
11760
|
speakerGateBySessionId.delete(message.sessionId);
|
|
11761
|
+
pendingSpeakerGateStateBySessionId.delete(message.sessionId);
|
|
11762
|
+
clearPendingSpeakerRequestsForSession(message.sessionId, "session_ended");
|
|
11714
11763
|
voiceLanguageSwitchSettingsBySessionId.delete(message.sessionId);
|
|
11715
11764
|
lastVoiceLanguageBySessionId.delete(message.sessionId);
|
|
11716
11765
|
ttsPoseAvailableBySessionId.delete(message.sessionId);
|
|
@@ -11804,6 +11853,10 @@ function defineAgent(handlers) {
|
|
|
11804
11853
|
handleResetSpeakerEnrollmentResult(message);
|
|
11805
11854
|
return;
|
|
11806
11855
|
}
|
|
11856
|
+
if (isSpeakerGateStateMessage(message)) {
|
|
11857
|
+
handleSpeakerGateState(message);
|
|
11858
|
+
return;
|
|
11859
|
+
}
|
|
11807
11860
|
if (isWebhookMessage(message)) {
|
|
11808
11861
|
void agentStartReady.then(() => handleWebhookMessage(message, handlers));
|
|
11809
11862
|
return;
|
|
@@ -11812,6 +11865,8 @@ function defineAgent(handlers) {
|
|
|
11812
11865
|
return;
|
|
11813
11866
|
if (message.type === "session_end") {
|
|
11814
11867
|
endedSessionIds.add(message.sessionId);
|
|
11868
|
+
pendingSpeakerGateStateBySessionId.delete(message.sessionId);
|
|
11869
|
+
clearPendingSpeakerRequestsForSession(message.sessionId, "session_ended");
|
|
11815
11870
|
clearPendingSpeakForSession(message.sessionId, "session_ended");
|
|
11816
11871
|
clearPendingRecordingAcksForSession(message.sessionId, "session_ended");
|
|
11817
11872
|
clearPendingConversationHistoryAcksForSession(message.sessionId, "session_ended");
|
|
@@ -12001,6 +12056,8 @@ function buildIdleEnv(sessionId) {
|
|
|
12001
12056
|
...process.env.IDLE_TIMEOUT_SEC ? { IDLE_TIMEOUT_SEC: process.env.IDLE_TIMEOUT_SEC } : {}
|
|
12002
12057
|
};
|
|
12003
12058
|
}
|
|
12059
|
+
var SPEAKER_GATE_MODES = ["disabled", "auto", "manual"];
|
|
12060
|
+
var SPEAKER_GATE_BARGE_IN = ["caller_only", "anyone"];
|
|
12004
12061
|
function sendToClient(sessionId, payload) {
|
|
12005
12062
|
sendParentMessage({ type: "send_to_client", sessionId, payload });
|
|
12006
12063
|
}
|
|
@@ -241,6 +241,12 @@ function isSetSpeakerGateResultMessage(value) {
|
|
|
241
241
|
const msg = value;
|
|
242
242
|
return msg.type === "setSpeakerGateResult" && typeof msg.requestId === "string";
|
|
243
243
|
}
|
|
244
|
+
function isSpeakerGateStateMessage(value) {
|
|
245
|
+
if (!value || typeof value !== "object")
|
|
246
|
+
return false;
|
|
247
|
+
const msg = value;
|
|
248
|
+
return msg.type === "speaker_gate_state" && typeof msg.sessionId === "string" && typeof msg.mode === "string" && SPEAKER_GATE_MODES.includes(msg.mode) && (msg.bargeIn === void 0 || typeof msg.bargeIn === "string" && SPEAKER_GATE_BARGE_IN.includes(msg.bargeIn));
|
|
249
|
+
}
|
|
244
250
|
function isResetSpeakerEnrollmentResultMessage(value) {
|
|
245
251
|
if (!value || typeof value !== "object")
|
|
246
252
|
return false;
|
|
@@ -295,7 +301,7 @@ function isParentMessage(value) {
|
|
|
295
301
|
if (!value || typeof value !== "object")
|
|
296
302
|
return false;
|
|
297
303
|
const msg = value;
|
|
298
|
-
return msg.type === "session_start" || msg.type === "speech_event" || msg.type === "session_end" || msg.type === "data_channel_message" || msg.type === "data_channel_binary" || msg.type === "idle_timeout" || msg.type === "session_time_limit" || msg.type === "session_time_limit_control_ack" || msg.type === "recording_control_ack" || msg.type === "conversation_history_control_ack" || msg.type === "user_identified" || msg.type === "user_history_response" || msg.type === "play_ack" || msg.type === "play_status_ack" || msg.type === "play_stop_ack" || msg.type === "play_pose_ack" || msg.type === "mix_control_ack" || msg.type === "stt_control_ack" || msg.type === "voice_language_control_ack" || msg.type === "voice_language_prepare_result" || msg.type === "voice_replay_last_result" || msg.type === "setSpeakerGateResult" || msg.type === "resetSpeakerEnrollmentResult" || msg.type === "speak_result" || msg.type === "barge_in_control_ack" || msg.type === "agent_interrupted" || msg.type === "webhook";
|
|
304
|
+
return msg.type === "session_start" || msg.type === "speech_event" || msg.type === "session_end" || msg.type === "data_channel_message" || msg.type === "data_channel_binary" || msg.type === "idle_timeout" || msg.type === "session_time_limit" || msg.type === "session_time_limit_control_ack" || msg.type === "recording_control_ack" || msg.type === "conversation_history_control_ack" || msg.type === "user_identified" || msg.type === "user_history_response" || msg.type === "play_ack" || msg.type === "play_status_ack" || msg.type === "play_stop_ack" || msg.type === "play_pose_ack" || msg.type === "mix_control_ack" || msg.type === "stt_control_ack" || msg.type === "voice_language_control_ack" || msg.type === "voice_language_prepare_result" || msg.type === "voice_replay_last_result" || msg.type === "setSpeakerGateResult" || msg.type === "resetSpeakerEnrollmentResult" || msg.type === "speaker_gate_state" || msg.type === "speak_result" || msg.type === "barge_in_control_ack" || msg.type === "agent_interrupted" || msg.type === "webhook";
|
|
299
305
|
}
|
|
300
306
|
function isSessionScopedParentMessage(value) {
|
|
301
307
|
return isParentMessage(value) && !isWebhookMessage(value);
|
|
@@ -316,6 +322,7 @@ var voiceLanguageSwitchAvailableBySessionId = /* @__PURE__ */ new Map();
|
|
|
316
322
|
var lastVoiceLanguageBySessionId = /* @__PURE__ */ new Map();
|
|
317
323
|
var speakerGateBySessionId = /* @__PURE__ */ new Map();
|
|
318
324
|
var pendingSpeakerGateAcks = /* @__PURE__ */ new Map();
|
|
325
|
+
var pendingSpeakerGateStateBySessionId = /* @__PURE__ */ new Map();
|
|
319
326
|
var pendingSpeakerResets = /* @__PURE__ */ new Map();
|
|
320
327
|
var ttsPoseAvailableBySessionId = /* @__PURE__ */ new Map();
|
|
321
328
|
var speakControlAvailableBySessionId = /* @__PURE__ */ new Map();
|
|
@@ -603,6 +610,41 @@ function handleResetSpeakerEnrollmentResult(message) {
|
|
|
603
610
|
pendingSpeakerResets.delete(message.requestId);
|
|
604
611
|
pending.resolve(message.ok ? { ok: true } : { ok: false, reason: message.reason });
|
|
605
612
|
}
|
|
613
|
+
function applySpeakerGateState(prev, message) {
|
|
614
|
+
return {
|
|
615
|
+
available: true,
|
|
616
|
+
mode: message.mode,
|
|
617
|
+
bargeIn: message.bargeIn ?? prev.bargeIn
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
function handleSpeakerGateState(message) {
|
|
621
|
+
if (endedSessionIds.has(message.sessionId))
|
|
622
|
+
return;
|
|
623
|
+
const prev = speakerGateBySessionId.get(message.sessionId);
|
|
624
|
+
if (prev) {
|
|
625
|
+
if (prev.available) {
|
|
626
|
+
speakerGateBySessionId.set(message.sessionId, applySpeakerGateState(prev, message));
|
|
627
|
+
}
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
630
|
+
pendingSpeakerGateStateBySessionId.set(message.sessionId, message);
|
|
631
|
+
}
|
|
632
|
+
function clearPendingSpeakerRequestsForSession(sessionId, reason) {
|
|
633
|
+
for (const [requestId, pending] of pendingSpeakerGateAcks) {
|
|
634
|
+
if (pending.sessionId !== sessionId)
|
|
635
|
+
continue;
|
|
636
|
+
clearTimeout(pending.timer);
|
|
637
|
+
pendingSpeakerGateAcks.delete(requestId);
|
|
638
|
+
pending.resolve({ ok: false, reason });
|
|
639
|
+
}
|
|
640
|
+
for (const [requestId, pending] of pendingSpeakerResets) {
|
|
641
|
+
if (pending.sessionId !== sessionId)
|
|
642
|
+
continue;
|
|
643
|
+
clearTimeout(pending.timer);
|
|
644
|
+
pendingSpeakerResets.delete(requestId);
|
|
645
|
+
pending.resolve({ ok: false, reason });
|
|
646
|
+
}
|
|
647
|
+
}
|
|
606
648
|
function handleVoiceReplayLastResult(message) {
|
|
607
649
|
const pending = pendingVoiceReplays.get(message.requestId);
|
|
608
650
|
if (!pending)
|
|
@@ -829,7 +871,12 @@ async function handleParentMessage(message, handlers) {
|
|
|
829
871
|
speakControlAvailableBySessionId.set(message.sessionId, message.speakControlAvailable ?? false);
|
|
830
872
|
chatReplyRecordAvailableBySessionId.set(message.sessionId, message.chatReplyRecordAvailable ?? false);
|
|
831
873
|
sessionTimeLimitAvailableBySessionId.set(message.sessionId, message.sessionTimeLimitAvailable ?? false);
|
|
832
|
-
|
|
874
|
+
{
|
|
875
|
+
const initial = message.speakerGate?.available === true ? message.speakerGate : { available: false };
|
|
876
|
+
const early = pendingSpeakerGateStateBySessionId.get(message.sessionId);
|
|
877
|
+
pendingSpeakerGateStateBySessionId.delete(message.sessionId);
|
|
878
|
+
speakerGateBySessionId.set(message.sessionId, early && initial.available ? applySpeakerGateState(initial, early) : initial);
|
|
879
|
+
}
|
|
833
880
|
if (message.voiceLanguageSwitch) {
|
|
834
881
|
voiceLanguageSwitchSettingsBySessionId.set(message.sessionId, message.voiceLanguageSwitch);
|
|
835
882
|
} else {
|
|
@@ -956,6 +1003,8 @@ async function handleParentMessage(message, handlers) {
|
|
|
956
1003
|
mixAvailableBySessionId.delete(message.sessionId);
|
|
957
1004
|
voiceLanguageSwitchAvailableBySessionId.delete(message.sessionId);
|
|
958
1005
|
speakerGateBySessionId.delete(message.sessionId);
|
|
1006
|
+
pendingSpeakerGateStateBySessionId.delete(message.sessionId);
|
|
1007
|
+
clearPendingSpeakerRequestsForSession(message.sessionId, "session_ended");
|
|
959
1008
|
voiceLanguageSwitchSettingsBySessionId.delete(message.sessionId);
|
|
960
1009
|
lastVoiceLanguageBySessionId.delete(message.sessionId);
|
|
961
1010
|
ttsPoseAvailableBySessionId.delete(message.sessionId);
|
|
@@ -1049,6 +1098,10 @@ function defineAgent(handlers) {
|
|
|
1049
1098
|
handleResetSpeakerEnrollmentResult(message);
|
|
1050
1099
|
return;
|
|
1051
1100
|
}
|
|
1101
|
+
if (isSpeakerGateStateMessage(message)) {
|
|
1102
|
+
handleSpeakerGateState(message);
|
|
1103
|
+
return;
|
|
1104
|
+
}
|
|
1052
1105
|
if (isWebhookMessage(message)) {
|
|
1053
1106
|
void agentStartReady.then(() => handleWebhookMessage(message, handlers));
|
|
1054
1107
|
return;
|
|
@@ -1057,6 +1110,8 @@ function defineAgent(handlers) {
|
|
|
1057
1110
|
return;
|
|
1058
1111
|
if (message.type === "session_end") {
|
|
1059
1112
|
endedSessionIds.add(message.sessionId);
|
|
1113
|
+
pendingSpeakerGateStateBySessionId.delete(message.sessionId);
|
|
1114
|
+
clearPendingSpeakerRequestsForSession(message.sessionId, "session_ended");
|
|
1060
1115
|
clearPendingSpeakForSession(message.sessionId, "session_ended");
|
|
1061
1116
|
clearPendingRecordingAcksForSession(message.sessionId, "session_ended");
|
|
1062
1117
|
clearPendingConversationHistoryAcksForSession(message.sessionId, "session_ended");
|
|
@@ -1246,6 +1301,8 @@ function buildIdleEnv(sessionId) {
|
|
|
1246
1301
|
...process.env.IDLE_TIMEOUT_SEC ? { IDLE_TIMEOUT_SEC: process.env.IDLE_TIMEOUT_SEC } : {}
|
|
1247
1302
|
};
|
|
1248
1303
|
}
|
|
1304
|
+
var SPEAKER_GATE_MODES = ["disabled", "auto", "manual"];
|
|
1305
|
+
var SPEAKER_GATE_BARGE_IN = ["caller_only", "anyone"];
|
|
1249
1306
|
function sendToClient(sessionId, payload) {
|
|
1250
1307
|
sendParentMessage({ type: "send_to_client", sessionId, payload });
|
|
1251
1308
|
}
|
|
@@ -241,6 +241,12 @@ function isSetSpeakerGateResultMessage(value) {
|
|
|
241
241
|
const msg = value;
|
|
242
242
|
return msg.type === "setSpeakerGateResult" && typeof msg.requestId === "string";
|
|
243
243
|
}
|
|
244
|
+
function isSpeakerGateStateMessage(value) {
|
|
245
|
+
if (!value || typeof value !== "object")
|
|
246
|
+
return false;
|
|
247
|
+
const msg = value;
|
|
248
|
+
return msg.type === "speaker_gate_state" && typeof msg.sessionId === "string" && typeof msg.mode === "string" && SPEAKER_GATE_MODES.includes(msg.mode) && (msg.bargeIn === void 0 || typeof msg.bargeIn === "string" && SPEAKER_GATE_BARGE_IN.includes(msg.bargeIn));
|
|
249
|
+
}
|
|
244
250
|
function isResetSpeakerEnrollmentResultMessage(value) {
|
|
245
251
|
if (!value || typeof value !== "object")
|
|
246
252
|
return false;
|
|
@@ -295,7 +301,7 @@ function isParentMessage(value) {
|
|
|
295
301
|
if (!value || typeof value !== "object")
|
|
296
302
|
return false;
|
|
297
303
|
const msg = value;
|
|
298
|
-
return msg.type === "session_start" || msg.type === "speech_event" || msg.type === "session_end" || msg.type === "data_channel_message" || msg.type === "data_channel_binary" || msg.type === "idle_timeout" || msg.type === "session_time_limit" || msg.type === "session_time_limit_control_ack" || msg.type === "recording_control_ack" || msg.type === "conversation_history_control_ack" || msg.type === "user_identified" || msg.type === "user_history_response" || msg.type === "play_ack" || msg.type === "play_status_ack" || msg.type === "play_stop_ack" || msg.type === "play_pose_ack" || msg.type === "mix_control_ack" || msg.type === "stt_control_ack" || msg.type === "voice_language_control_ack" || msg.type === "voice_language_prepare_result" || msg.type === "voice_replay_last_result" || msg.type === "setSpeakerGateResult" || msg.type === "resetSpeakerEnrollmentResult" || msg.type === "speak_result" || msg.type === "barge_in_control_ack" || msg.type === "agent_interrupted" || msg.type === "webhook";
|
|
304
|
+
return msg.type === "session_start" || msg.type === "speech_event" || msg.type === "session_end" || msg.type === "data_channel_message" || msg.type === "data_channel_binary" || msg.type === "idle_timeout" || msg.type === "session_time_limit" || msg.type === "session_time_limit_control_ack" || msg.type === "recording_control_ack" || msg.type === "conversation_history_control_ack" || msg.type === "user_identified" || msg.type === "user_history_response" || msg.type === "play_ack" || msg.type === "play_status_ack" || msg.type === "play_stop_ack" || msg.type === "play_pose_ack" || msg.type === "mix_control_ack" || msg.type === "stt_control_ack" || msg.type === "voice_language_control_ack" || msg.type === "voice_language_prepare_result" || msg.type === "voice_replay_last_result" || msg.type === "setSpeakerGateResult" || msg.type === "resetSpeakerEnrollmentResult" || msg.type === "speaker_gate_state" || msg.type === "speak_result" || msg.type === "barge_in_control_ack" || msg.type === "agent_interrupted" || msg.type === "webhook";
|
|
299
305
|
}
|
|
300
306
|
function isSessionScopedParentMessage(value) {
|
|
301
307
|
return isParentMessage(value) && !isWebhookMessage(value);
|
|
@@ -316,6 +322,7 @@ var voiceLanguageSwitchAvailableBySessionId = /* @__PURE__ */ new Map();
|
|
|
316
322
|
var lastVoiceLanguageBySessionId = /* @__PURE__ */ new Map();
|
|
317
323
|
var speakerGateBySessionId = /* @__PURE__ */ new Map();
|
|
318
324
|
var pendingSpeakerGateAcks = /* @__PURE__ */ new Map();
|
|
325
|
+
var pendingSpeakerGateStateBySessionId = /* @__PURE__ */ new Map();
|
|
319
326
|
var pendingSpeakerResets = /* @__PURE__ */ new Map();
|
|
320
327
|
var ttsPoseAvailableBySessionId = /* @__PURE__ */ new Map();
|
|
321
328
|
var speakControlAvailableBySessionId = /* @__PURE__ */ new Map();
|
|
@@ -603,6 +610,41 @@ function handleResetSpeakerEnrollmentResult(message) {
|
|
|
603
610
|
pendingSpeakerResets.delete(message.requestId);
|
|
604
611
|
pending.resolve(message.ok ? { ok: true } : { ok: false, reason: message.reason });
|
|
605
612
|
}
|
|
613
|
+
function applySpeakerGateState(prev, message) {
|
|
614
|
+
return {
|
|
615
|
+
available: true,
|
|
616
|
+
mode: message.mode,
|
|
617
|
+
bargeIn: message.bargeIn ?? prev.bargeIn
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
function handleSpeakerGateState(message) {
|
|
621
|
+
if (endedSessionIds.has(message.sessionId))
|
|
622
|
+
return;
|
|
623
|
+
const prev = speakerGateBySessionId.get(message.sessionId);
|
|
624
|
+
if (prev) {
|
|
625
|
+
if (prev.available) {
|
|
626
|
+
speakerGateBySessionId.set(message.sessionId, applySpeakerGateState(prev, message));
|
|
627
|
+
}
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
630
|
+
pendingSpeakerGateStateBySessionId.set(message.sessionId, message);
|
|
631
|
+
}
|
|
632
|
+
function clearPendingSpeakerRequestsForSession(sessionId, reason) {
|
|
633
|
+
for (const [requestId, pending] of pendingSpeakerGateAcks) {
|
|
634
|
+
if (pending.sessionId !== sessionId)
|
|
635
|
+
continue;
|
|
636
|
+
clearTimeout(pending.timer);
|
|
637
|
+
pendingSpeakerGateAcks.delete(requestId);
|
|
638
|
+
pending.resolve({ ok: false, reason });
|
|
639
|
+
}
|
|
640
|
+
for (const [requestId, pending] of pendingSpeakerResets) {
|
|
641
|
+
if (pending.sessionId !== sessionId)
|
|
642
|
+
continue;
|
|
643
|
+
clearTimeout(pending.timer);
|
|
644
|
+
pendingSpeakerResets.delete(requestId);
|
|
645
|
+
pending.resolve({ ok: false, reason });
|
|
646
|
+
}
|
|
647
|
+
}
|
|
606
648
|
function handleVoiceReplayLastResult(message) {
|
|
607
649
|
const pending = pendingVoiceReplays.get(message.requestId);
|
|
608
650
|
if (!pending)
|
|
@@ -829,7 +871,12 @@ async function handleParentMessage(message, handlers) {
|
|
|
829
871
|
speakControlAvailableBySessionId.set(message.sessionId, message.speakControlAvailable ?? false);
|
|
830
872
|
chatReplyRecordAvailableBySessionId.set(message.sessionId, message.chatReplyRecordAvailable ?? false);
|
|
831
873
|
sessionTimeLimitAvailableBySessionId.set(message.sessionId, message.sessionTimeLimitAvailable ?? false);
|
|
832
|
-
|
|
874
|
+
{
|
|
875
|
+
const initial = message.speakerGate?.available === true ? message.speakerGate : { available: false };
|
|
876
|
+
const early = pendingSpeakerGateStateBySessionId.get(message.sessionId);
|
|
877
|
+
pendingSpeakerGateStateBySessionId.delete(message.sessionId);
|
|
878
|
+
speakerGateBySessionId.set(message.sessionId, early && initial.available ? applySpeakerGateState(initial, early) : initial);
|
|
879
|
+
}
|
|
833
880
|
if (message.voiceLanguageSwitch) {
|
|
834
881
|
voiceLanguageSwitchSettingsBySessionId.set(message.sessionId, message.voiceLanguageSwitch);
|
|
835
882
|
} else {
|
|
@@ -956,6 +1003,8 @@ async function handleParentMessage(message, handlers) {
|
|
|
956
1003
|
mixAvailableBySessionId.delete(message.sessionId);
|
|
957
1004
|
voiceLanguageSwitchAvailableBySessionId.delete(message.sessionId);
|
|
958
1005
|
speakerGateBySessionId.delete(message.sessionId);
|
|
1006
|
+
pendingSpeakerGateStateBySessionId.delete(message.sessionId);
|
|
1007
|
+
clearPendingSpeakerRequestsForSession(message.sessionId, "session_ended");
|
|
959
1008
|
voiceLanguageSwitchSettingsBySessionId.delete(message.sessionId);
|
|
960
1009
|
lastVoiceLanguageBySessionId.delete(message.sessionId);
|
|
961
1010
|
ttsPoseAvailableBySessionId.delete(message.sessionId);
|
|
@@ -1049,6 +1098,10 @@ function defineAgent(handlers) {
|
|
|
1049
1098
|
handleResetSpeakerEnrollmentResult(message);
|
|
1050
1099
|
return;
|
|
1051
1100
|
}
|
|
1101
|
+
if (isSpeakerGateStateMessage(message)) {
|
|
1102
|
+
handleSpeakerGateState(message);
|
|
1103
|
+
return;
|
|
1104
|
+
}
|
|
1052
1105
|
if (isWebhookMessage(message)) {
|
|
1053
1106
|
void agentStartReady.then(() => handleWebhookMessage(message, handlers));
|
|
1054
1107
|
return;
|
|
@@ -1057,6 +1110,8 @@ function defineAgent(handlers) {
|
|
|
1057
1110
|
return;
|
|
1058
1111
|
if (message.type === "session_end") {
|
|
1059
1112
|
endedSessionIds.add(message.sessionId);
|
|
1113
|
+
pendingSpeakerGateStateBySessionId.delete(message.sessionId);
|
|
1114
|
+
clearPendingSpeakerRequestsForSession(message.sessionId, "session_ended");
|
|
1060
1115
|
clearPendingSpeakForSession(message.sessionId, "session_ended");
|
|
1061
1116
|
clearPendingRecordingAcksForSession(message.sessionId, "session_ended");
|
|
1062
1117
|
clearPendingConversationHistoryAcksForSession(message.sessionId, "session_ended");
|
|
@@ -1246,6 +1301,8 @@ function buildIdleEnv(sessionId) {
|
|
|
1246
1301
|
...process.env.IDLE_TIMEOUT_SEC ? { IDLE_TIMEOUT_SEC: process.env.IDLE_TIMEOUT_SEC } : {}
|
|
1247
1302
|
};
|
|
1248
1303
|
}
|
|
1304
|
+
var SPEAKER_GATE_MODES = ["disabled", "auto", "manual"];
|
|
1305
|
+
var SPEAKER_GATE_BARGE_IN = ["caller_only", "anyone"];
|
|
1249
1306
|
function asOutboundBuffer(data) {
|
|
1250
1307
|
return Buffer.isBuffer(data) ? data : Buffer.from(data.buffer, data.byteOffset, data.byteLength);
|
|
1251
1308
|
}
|
package/eject/llm/loop.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copied from @voicethere/agent 0.
|
|
1
|
+
// Copied from @voicethere/agent 0.30.0. Package updates no longer change this file.
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import {
|
|
4
4
|
type AgentHandlers,
|
|
@@ -1253,7 +1253,11 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
|
|
|
1253
1253
|
turnId: t.turnId,
|
|
1254
1254
|
text,
|
|
1255
1255
|
});
|
|
1256
|
-
sendToClient(s.sessionId, {
|
|
1256
|
+
sendToClient(s.sessionId, {
|
|
1257
|
+
type: "chat_reply",
|
|
1258
|
+
text,
|
|
1259
|
+
turnId: t.turnId,
|
|
1260
|
+
});
|
|
1257
1261
|
if (!speakChat && text.trim() !== "")
|
|
1258
1262
|
recordReply(s.sessionId, text, { turnId: t.turnId });
|
|
1259
1263
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voicethere/agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.30.0",
|
|
4
4
|
"description": "VoiceThere customer agent SDK — IPC types and runtime helpers for sandboxed child bundles",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -174,6 +174,7 @@
|
|
|
174
174
|
"ioredis": "5.11.1",
|
|
175
175
|
"openai": "7.43.0",
|
|
176
176
|
"prettier": "3.9.10",
|
|
177
|
+
"recheck": "4.6.2",
|
|
177
178
|
"tsx": "4.19.2",
|
|
178
179
|
"typescript": "5.9.3",
|
|
179
180
|
"vitest": "3.2.7",
|
package/templates/README.md
CHANGED
|
@@ -17,10 +17,10 @@ import {
|
|
|
17
17
|
|
|
18
18
|
## Product vs e2e
|
|
19
19
|
|
|
20
|
-
| Kind | Dashboard create | Prebuilt seed bundle | Typical consumer
|
|
21
|
-
| ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ |
|
|
22
|
-
| **product** | Yes (`echo`, `echo-dc`, `voice-starter`, `language-switch`, `speaker-gate`, `world-sync`, `world-sync-binary`, `game-sync`, `voice-showcase`, `recording-consent`, `positional-tts`, `spatial-showcase`, `webhooks`, `webhooks-redis`) | Yes — `dist/templates/<id>/agent.js` | Platform project create
|
|
23
|
-
| **e2e** | No | No — build from sources at test time |
|
|
20
|
+
| Kind | Dashboard create | Prebuilt seed bundle | Typical consumer |
|
|
21
|
+
| ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ | --------------------------------- |
|
|
22
|
+
| **product** | Yes (`echo`, `echo-dc`, `voice-starter`, `language-switch`, `speaker-gate`, `world-sync`, `world-sync-binary`, `game-sync`, `voice-showcase`, `recording-consent`, `positional-tts`, `spatial-showcase`, `webhooks`, `webhooks-redis`) | Yes — `dist/templates/<id>/agent.js` | Platform project create |
|
|
23
|
+
| **e2e** | No | No — build from sources at test time | VoiceThere end-to-end smoke tests |
|
|
24
24
|
|
|
25
25
|
Product templates always set `seedOnCreate: true`. CI fails if a product template is missing its prebuilt bundle after `npm run build`.
|
|
26
26
|
|
|
@@ -76,13 +76,15 @@ Each folder has its own README. Summary:
|
|
|
76
76
|
| `webhooks` | `webhooks/` | Inbound HMAC webhooks |
|
|
77
77
|
| `webhooks-redis` | `webhooks-redis/` | Webhooks plus Redis counter |
|
|
78
78
|
| `llm-agent` | `llm-agent/` | LLM voice and chat agent, tools, MCP, optional knowledge (RAG) |
|
|
79
|
+
| `llm-language-tutor` | `llm-language-tutor/` | English practice partner: `llm-agent` plus a lessons knowledge base (Redis) |
|
|
80
|
+
| `llm-board` | `llm-board/` | Shared sticky-note board over the data channel with an LLM facilitator (no Redis) |
|
|
79
81
|
| `llm-mcp-service` | `llm-mcp-service/` | `llm-agent` plus a project service that serves MCP tools |
|
|
80
82
|
| `llm-docs-rag` | `llm-docs-rag/` | `llm-agent` answering from your docs via the `docs-rag-mcp` image |
|
|
81
83
|
| `llm-support-sticky-user` | `llm-support-sticky-user/` | `llm-agent` for support: verified users get their tickets and earlier conversations |
|
|
82
84
|
|
|
83
85
|
## E2e templates
|
|
84
86
|
|
|
85
|
-
These
|
|
87
|
+
These were the end-to-end test fixtures; the tests resolve entries from the package, build them into ephemeral workdirs, and upload `dist/agent.js`.
|
|
86
88
|
|
|
87
89
|
| Id | Source | Purpose |
|
|
88
90
|
| ----------------- | ----------------------------------------- | ------------------------------------------------------ |
|
|
@@ -49,7 +49,7 @@ The `fillers` block in `voicethere.llm.json` lists short sentences the agent spe
|
|
|
49
49
|
|
|
50
50
|
## Client messages for voice replies
|
|
51
51
|
|
|
52
|
-
A voice reply also reaches the client as text. Each spoken sentence arrives as `{ "type": "assistant_delta", "turnId", "text", "spoken": true }`, and the turn ends with one `{ "type": "assistant_done", "turnId", "text", "spoken": true, "status" }`. `status` is `completed`, `failed`, `interrupted` or `cancelled`, and `text` holds the sentences delivered so far. When the runner sends an utterance id for the caller's final (`SpeechContext.utteranceId` in `onUserSpeechFinal`), both messages also carry `inReplyTo`, the caller utterance the reply answers. Render one line per `turnId` and reveal it as the speech plays. Typed (chat) turns keep sending `assistant_delta`, `assistant_done` and `chat_reply` without `spoken
|
|
52
|
+
A voice reply also reaches the client as text. Each spoken sentence arrives as `{ "type": "assistant_delta", "turnId", "text", "spoken": true }`, and the turn ends with one `{ "type": "assistant_done", "turnId", "text", "spoken": true, "status" }`. `status` is `completed`, `failed`, `interrupted` or `cancelled`, and `text` holds the sentences delivered so far. When the runner sends an utterance id for the caller's final (`SpeechContext.utteranceId` in `onUserSpeechFinal`), both messages also carry `inReplyTo`, the caller utterance the reply answers. Render one line per `turnId` and reveal it as the speech plays. Typed (chat) turns keep sending `assistant_delta`, `assistant_done` and `chat_reply` without `spoken`; the `chat_reply` is `{ "type": "chat_reply", "text", "turnId" }` with the `turnId` of the `assistant_done` before it. Fillers are never part of this reply text; see `assistant_filler` below.
|
|
53
53
|
|
|
54
54
|
## Always search first
|
|
55
55
|
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# llm-board
|
|
2
|
+
|
|
3
|
+
A shared brainstorming board with an LLM facilitator. People add sticky notes from the browser; the facilitator reads, adds and edits notes by voice or chat through three tools. Source: `templates/llm-board/agent.ts`.
|
|
4
|
+
|
|
5
|
+
## What you need
|
|
6
|
+
|
|
7
|
+
A project secret named `AGENT_OPENROUTER_API_KEY` (a key from openrouter.ai). No Redis: boards live in the agent process and are deleted when the last session in the room ends.
|
|
8
|
+
|
|
9
|
+
## Files
|
|
10
|
+
|
|
11
|
+
- `agent.ts` routes board messages first and passes everything else to the LLM as chat. It also defines the tools `list_notes`, `add_note` and `update_note`.
|
|
12
|
+
- `board.ts` is the board itself and the message parser, with no VoiceThere imports.
|
|
13
|
+
- `voicethere.llm.json` holds the model (`amazon/nova-micro-v1` on OpenRouter), greeting and settings. Knowledge is off.
|
|
14
|
+
- `prompt.md` is the facilitator's system prompt.
|
|
15
|
+
- `md.d.ts` lets TypeScript accept `import x from "./x.md"`.
|
|
16
|
+
|
|
17
|
+
## Message protocol
|
|
18
|
+
|
|
19
|
+
Data channel messages from the client:
|
|
20
|
+
|
|
21
|
+
| Message | Effect |
|
|
22
|
+
| ---------------------------------------------------------------- | --------------------------------------------------------------------------- |
|
|
23
|
+
| `{ "type": "note.add", "text", "x"?, "y"?, "color"? }` | Adds a note with author `user` |
|
|
24
|
+
| `{ "type": "note.update", "id", "text"?, "x"?, "y"?, "color"? }` | Changes the given fields |
|
|
25
|
+
| `{ "type": "note.remove", "id" }` | Deletes the note |
|
|
26
|
+
| `{ "type": "board.join", "room" }` | Joins a room (`a-z`, `0-9`, `-`, 6 to 40 characters) and leaves the old one |
|
|
27
|
+
| `{ "type": "board.sync" }` | Sends the current board to the requester only |
|
|
28
|
+
|
|
29
|
+
One agent process serves many sessions, so boards are scoped to rooms. A session that never sends `board.join` has a private board. Sessions that join the same room share one board and one set of notes, and the facilitator's tools read and change the board of the room the session is in. Anyone who knows a room id can join it, so use a long random id for a private room.
|
|
30
|
+
|
|
31
|
+
The agent answers every change with `{ "type": "board", "notes": Note[] }` to every session in the room. A `board.sync` is answered to the requester only.
|
|
32
|
+
|
|
33
|
+
A note is `{ id, text, x, y, color, author }`:
|
|
34
|
+
|
|
35
|
+
- `text`: 1 to 200 characters.
|
|
36
|
+
- `x`, `y`: 0 to 1, from the top left corner. Without them a new note takes a free spot on a grid.
|
|
37
|
+
- `color`: `yellow` (default), `blue`, `green` or `pink`.
|
|
38
|
+
- `author`: `user` or `ai`.
|
|
39
|
+
|
|
40
|
+
The board holds at most 60 notes. A message that fails validation (a 201 character text, a coordinate outside 0 to 1, an unknown id) changes nothing, and the board is sent back unchanged. Chat messages `{ "type": "chat", "text" }` go to the LLM as before.
|
|
41
|
+
|
|
42
|
+
## Cost
|
|
43
|
+
|
|
44
|
+
Measured on VoiceThere's demo: see the use-case page.
|