@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
|
@@ -30884,6 +30884,12 @@ function isSetSpeakerGateResultMessage(value) {
|
|
|
30884
30884
|
const msg = value;
|
|
30885
30885
|
return msg.type === "setSpeakerGateResult" && typeof msg.requestId === "string";
|
|
30886
30886
|
}
|
|
30887
|
+
function isSpeakerGateStateMessage(value) {
|
|
30888
|
+
if (!value || typeof value !== "object")
|
|
30889
|
+
return false;
|
|
30890
|
+
const msg = value;
|
|
30891
|
+
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));
|
|
30892
|
+
}
|
|
30887
30893
|
function isResetSpeakerEnrollmentResultMessage(value) {
|
|
30888
30894
|
if (!value || typeof value !== "object")
|
|
30889
30895
|
return false;
|
|
@@ -30938,7 +30944,7 @@ function isParentMessage(value) {
|
|
|
30938
30944
|
if (!value || typeof value !== "object")
|
|
30939
30945
|
return false;
|
|
30940
30946
|
const msg = value;
|
|
30941
|
-
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";
|
|
30947
|
+
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";
|
|
30942
30948
|
}
|
|
30943
30949
|
function isSessionScopedParentMessage(value) {
|
|
30944
30950
|
return isParentMessage(value) && !isWebhookMessage(value);
|
|
@@ -30959,6 +30965,7 @@ var voiceLanguageSwitchAvailableBySessionId = /* @__PURE__ */ new Map();
|
|
|
30959
30965
|
var lastVoiceLanguageBySessionId = /* @__PURE__ */ new Map();
|
|
30960
30966
|
var speakerGateBySessionId = /* @__PURE__ */ new Map();
|
|
30961
30967
|
var pendingSpeakerGateAcks = /* @__PURE__ */ new Map();
|
|
30968
|
+
var pendingSpeakerGateStateBySessionId = /* @__PURE__ */ new Map();
|
|
30962
30969
|
var pendingSpeakerResets = /* @__PURE__ */ new Map();
|
|
30963
30970
|
var ttsPoseAvailableBySessionId = /* @__PURE__ */ new Map();
|
|
30964
30971
|
var speakControlAvailableBySessionId = /* @__PURE__ */ new Map();
|
|
@@ -31249,6 +31256,41 @@ function handleResetSpeakerEnrollmentResult(message) {
|
|
|
31249
31256
|
pendingSpeakerResets.delete(message.requestId);
|
|
31250
31257
|
pending.resolve(message.ok ? { ok: true } : { ok: false, reason: message.reason });
|
|
31251
31258
|
}
|
|
31259
|
+
function applySpeakerGateState(prev, message) {
|
|
31260
|
+
return {
|
|
31261
|
+
available: true,
|
|
31262
|
+
mode: message.mode,
|
|
31263
|
+
bargeIn: message.bargeIn ?? prev.bargeIn
|
|
31264
|
+
};
|
|
31265
|
+
}
|
|
31266
|
+
function handleSpeakerGateState(message) {
|
|
31267
|
+
if (endedSessionIds.has(message.sessionId))
|
|
31268
|
+
return;
|
|
31269
|
+
const prev = speakerGateBySessionId.get(message.sessionId);
|
|
31270
|
+
if (prev) {
|
|
31271
|
+
if (prev.available) {
|
|
31272
|
+
speakerGateBySessionId.set(message.sessionId, applySpeakerGateState(prev, message));
|
|
31273
|
+
}
|
|
31274
|
+
return;
|
|
31275
|
+
}
|
|
31276
|
+
pendingSpeakerGateStateBySessionId.set(message.sessionId, message);
|
|
31277
|
+
}
|
|
31278
|
+
function clearPendingSpeakerRequestsForSession(sessionId, reason) {
|
|
31279
|
+
for (const [requestId, pending] of pendingSpeakerGateAcks) {
|
|
31280
|
+
if (pending.sessionId !== sessionId)
|
|
31281
|
+
continue;
|
|
31282
|
+
clearTimeout(pending.timer);
|
|
31283
|
+
pendingSpeakerGateAcks.delete(requestId);
|
|
31284
|
+
pending.resolve({ ok: false, reason });
|
|
31285
|
+
}
|
|
31286
|
+
for (const [requestId, pending] of pendingSpeakerResets) {
|
|
31287
|
+
if (pending.sessionId !== sessionId)
|
|
31288
|
+
continue;
|
|
31289
|
+
clearTimeout(pending.timer);
|
|
31290
|
+
pendingSpeakerResets.delete(requestId);
|
|
31291
|
+
pending.resolve({ ok: false, reason });
|
|
31292
|
+
}
|
|
31293
|
+
}
|
|
31252
31294
|
function handleVoiceReplayLastResult(message) {
|
|
31253
31295
|
const pending = pendingVoiceReplays.get(message.requestId);
|
|
31254
31296
|
if (!pending)
|
|
@@ -31478,7 +31520,12 @@ async function handleParentMessage(message, handlers) {
|
|
|
31478
31520
|
speakControlAvailableBySessionId.set(message.sessionId, message.speakControlAvailable ?? false);
|
|
31479
31521
|
chatReplyRecordAvailableBySessionId.set(message.sessionId, message.chatReplyRecordAvailable ?? false);
|
|
31480
31522
|
sessionTimeLimitAvailableBySessionId.set(message.sessionId, message.sessionTimeLimitAvailable ?? false);
|
|
31481
|
-
|
|
31523
|
+
{
|
|
31524
|
+
const initial = message.speakerGate?.available === true ? message.speakerGate : { available: false };
|
|
31525
|
+
const early = pendingSpeakerGateStateBySessionId.get(message.sessionId);
|
|
31526
|
+
pendingSpeakerGateStateBySessionId.delete(message.sessionId);
|
|
31527
|
+
speakerGateBySessionId.set(message.sessionId, early && initial.available ? applySpeakerGateState(initial, early) : initial);
|
|
31528
|
+
}
|
|
31482
31529
|
if (message.voiceLanguageSwitch) {
|
|
31483
31530
|
voiceLanguageSwitchSettingsBySessionId.set(message.sessionId, message.voiceLanguageSwitch);
|
|
31484
31531
|
} else {
|
|
@@ -31605,6 +31652,8 @@ async function handleParentMessage(message, handlers) {
|
|
|
31605
31652
|
mixAvailableBySessionId.delete(message.sessionId);
|
|
31606
31653
|
voiceLanguageSwitchAvailableBySessionId.delete(message.sessionId);
|
|
31607
31654
|
speakerGateBySessionId.delete(message.sessionId);
|
|
31655
|
+
pendingSpeakerGateStateBySessionId.delete(message.sessionId);
|
|
31656
|
+
clearPendingSpeakerRequestsForSession(message.sessionId, "session_ended");
|
|
31608
31657
|
voiceLanguageSwitchSettingsBySessionId.delete(message.sessionId);
|
|
31609
31658
|
lastVoiceLanguageBySessionId.delete(message.sessionId);
|
|
31610
31659
|
ttsPoseAvailableBySessionId.delete(message.sessionId);
|
|
@@ -31698,6 +31747,10 @@ function defineAgent(handlers) {
|
|
|
31698
31747
|
handleResetSpeakerEnrollmentResult(message);
|
|
31699
31748
|
return;
|
|
31700
31749
|
}
|
|
31750
|
+
if (isSpeakerGateStateMessage(message)) {
|
|
31751
|
+
handleSpeakerGateState(message);
|
|
31752
|
+
return;
|
|
31753
|
+
}
|
|
31701
31754
|
if (isWebhookMessage(message)) {
|
|
31702
31755
|
void agentStartReady.then(() => handleWebhookMessage(message, handlers));
|
|
31703
31756
|
return;
|
|
@@ -31706,6 +31759,8 @@ function defineAgent(handlers) {
|
|
|
31706
31759
|
return;
|
|
31707
31760
|
if (message.type === "session_end") {
|
|
31708
31761
|
endedSessionIds.add(message.sessionId);
|
|
31762
|
+
pendingSpeakerGateStateBySessionId.delete(message.sessionId);
|
|
31763
|
+
clearPendingSpeakerRequestsForSession(message.sessionId, "session_ended");
|
|
31709
31764
|
clearPendingSpeakForSession(message.sessionId, "session_ended");
|
|
31710
31765
|
clearPendingRecordingAcksForSession(message.sessionId, "session_ended");
|
|
31711
31766
|
clearPendingConversationHistoryAcksForSession(message.sessionId, "session_ended");
|
|
@@ -32033,6 +32088,8 @@ function setAgentState(sessionId, state2, options) {
|
|
|
32033
32088
|
...detail ? { detail: detail.slice(0, 64) } : {}
|
|
32034
32089
|
});
|
|
32035
32090
|
}
|
|
32091
|
+
var SPEAKER_GATE_MODES = ["disabled", "auto", "manual"];
|
|
32092
|
+
var SPEAKER_GATE_BARGE_IN = ["caller_only", "anyone"];
|
|
32036
32093
|
function getSessionUser(sessionId) {
|
|
32037
32094
|
return endUserBySessionId.get(sessionId);
|
|
32038
32095
|
}
|
|
@@ -32867,15 +32924,21 @@ var PHONE_RE = /(?<![\w.:/+-])(?:\+|\()?\d[\d ().-]{6,22}\d(?![\w.:/-])/g;
|
|
|
32867
32924
|
var MAX_PII_CHARS = 65536;
|
|
32868
32925
|
var IPV4_RE = /^\d{1,3}(?:\.\d{1,3}){3}$/;
|
|
32869
32926
|
var ISO_DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
32927
|
+
var NON_DIGIT_RE = /\D/g;
|
|
32928
|
+
var PHONE_SEP_RE = /[ .-]/g;
|
|
32929
|
+
var SPACE_RE = / /g;
|
|
32930
|
+
var DIGITS_RE = /^[0-9]+$/;
|
|
32931
|
+
var IBAN_HEAD_RE = /[A-Z]{2}\d{2}/;
|
|
32932
|
+
var CARD_SEP_RE = /[ -]/g;
|
|
32870
32933
|
function isPhone(m) {
|
|
32871
|
-
const d = m.replace(
|
|
32934
|
+
const d = m.replace(NON_DIGIT_RE, "");
|
|
32872
32935
|
if (d.length < 8 || d.length > 15)
|
|
32873
32936
|
return false;
|
|
32874
32937
|
if (IPV4_RE.test(m) || ISO_DATE_RE.test(m))
|
|
32875
32938
|
return false;
|
|
32876
32939
|
if (m.startsWith("+") || m.includes("("))
|
|
32877
32940
|
return true;
|
|
32878
|
-
return (m.match(
|
|
32941
|
+
return (m.match(PHONE_SEP_RE) ?? []).length >= 2;
|
|
32879
32942
|
}
|
|
32880
32943
|
var NON_SECRET_AGENT_KEYS = /* @__PURE__ */ new Set([
|
|
32881
32944
|
"AGENT_CUSTOMER_CONTEXT",
|
|
@@ -32906,7 +32969,7 @@ function luhn(digits) {
|
|
|
32906
32969
|
return sum % 10 === 0;
|
|
32907
32970
|
}
|
|
32908
32971
|
function ibanValid(raw) {
|
|
32909
|
-
const s = raw.replace(
|
|
32972
|
+
const s = raw.replace(SPACE_RE, "").toUpperCase();
|
|
32910
32973
|
if (s.length < 15 || s.length > 34)
|
|
32911
32974
|
return false;
|
|
32912
32975
|
const rearranged = s.slice(4) + s.slice(0, 4);
|
|
@@ -32914,7 +32977,7 @@ function ibanValid(raw) {
|
|
|
32914
32977
|
for (const ch of rearranged) {
|
|
32915
32978
|
const code = ch.charCodeAt(0);
|
|
32916
32979
|
const v = code >= 65 && code <= 90 ? String(code - 55) : ch;
|
|
32917
|
-
if (
|
|
32980
|
+
if (!DIGITS_RE.test(v))
|
|
32918
32981
|
return false;
|
|
32919
32982
|
for (const digit of v)
|
|
32920
32983
|
rem = (rem * 10 + (digit.charCodeAt(0) - 48)) % 97;
|
|
@@ -32929,7 +32992,7 @@ function redactIbanCandidate(m) {
|
|
|
32929
32992
|
if (ibanValid(head))
|
|
32930
32993
|
return `[redacted:iban]${m.slice(end)}`;
|
|
32931
32994
|
}
|
|
32932
|
-
const next = m.slice(1).search(
|
|
32995
|
+
const next = m.slice(1).search(IBAN_HEAD_RE);
|
|
32933
32996
|
if (next >= 0) {
|
|
32934
32997
|
const at = next + 1;
|
|
32935
32998
|
return m.slice(0, at) + redactIbanCandidate(m.slice(at));
|
|
@@ -32939,7 +33002,7 @@ function redactIbanCandidate(m) {
|
|
|
32939
33002
|
function redactPii(input) {
|
|
32940
33003
|
const text = input.length > MAX_PII_CHARS ? `${input.slice(0, MAX_PII_CHARS)}[truncated]` : input;
|
|
32941
33004
|
return text.replace(EMAIL_RE, "[redacted:email]").replace(IBAN_CANDIDATE_RE, redactIbanCandidate).replace(CARD_RE, (m) => {
|
|
32942
|
-
const digits = m.replace(
|
|
33005
|
+
const digits = m.replace(CARD_SEP_RE, "");
|
|
32943
33006
|
return [15, 16, 19].includes(digits.length) && "3456".includes(digits[0]) && luhn(digits) ? "[redacted:card]" : m;
|
|
32944
33007
|
}).replace(PHONE_RE, (m) => isPhone(m) ? "[redacted:phone]" : m);
|
|
32945
33008
|
}
|
|
@@ -36552,7 +36615,11 @@ ${t.inputText}` : t.inputText, {
|
|
|
36552
36615
|
turnId: t.turnId,
|
|
36553
36616
|
text
|
|
36554
36617
|
});
|
|
36555
|
-
sendToClient(s.sessionId, {
|
|
36618
|
+
sendToClient(s.sessionId, {
|
|
36619
|
+
type: "chat_reply",
|
|
36620
|
+
text,
|
|
36621
|
+
turnId: t.turnId
|
|
36622
|
+
});
|
|
36556
36623
|
if (!speakChat && text.trim() !== "")
|
|
36557
36624
|
recordReply(s.sessionId, text, { turnId: t.turnId });
|
|
36558
36625
|
}
|