@voicethere/agent 0.33.1 → 0.34.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/dist/llm/agent/create-llm-agent.d.ts +3 -0
- package/dist/llm/agent/create-llm-agent.d.ts.map +1 -1
- package/dist/llm/agent/create-llm-agent.js +10 -2
- package/dist/llm/agent/create-llm-agent.js.map +1 -1
- package/dist/llm/agent/history.d.ts +23 -3
- package/dist/llm/agent/history.d.ts.map +1 -1
- package/dist/llm/agent/history.js +79 -2
- package/dist/llm/agent/history.js.map +1 -1
- package/dist/llm/bounded-provider.d.ts +1 -1
- package/dist/llm/bounded-provider.d.ts.map +1 -1
- package/dist/llm/bounded-provider.js +31 -6
- package/dist/llm/bounded-provider.js.map +1 -1
- package/dist/llm/types.d.ts +10 -1
- package/dist/llm/types.d.ts.map +1 -1
- package/dist/llm/types.js +7 -1
- package/dist/llm/types.js.map +1 -1
- package/dist/templates/flow-agent/agent.js +29 -6
- package/dist/templates/llm-agent/agent.js +97 -10
- package/dist/templates/llm-board/agent.js +97 -10
- package/dist/templates/llm-docs-rag/agent.js +97 -10
- package/dist/templates/llm-language-switch/agent.js +60737 -0
- package/dist/templates/llm-language-tutor/agent.js +97 -10
- package/dist/templates/llm-mcp-service/agent.js +97 -10
- package/dist/templates/llm-store-support/agent.js +97 -10
- package/dist/templates/llm-support-sticky-user/agent.js +97 -10
- package/dist/templates/registry.d.ts.map +1 -1
- package/dist/templates/registry.js +25 -0
- package/dist/templates/registry.js.map +1 -1
- package/eject/llm/loop.ts +21 -3
- package/package.json +1 -1
- package/templates/README.md +1 -0
- package/templates/llm-language-switch/README.md +32 -0
- package/templates/llm-language-switch/agent.ts +25 -0
- package/templates/llm-language-switch/language.ts +223 -0
- package/templates/llm-language-switch/md.d.ts +4 -0
- package/templates/llm-language-switch/prompt.md +7 -0
- package/templates/llm-language-switch/voicethere.llm.json +23 -0
|
@@ -32215,31 +32215,54 @@ function parseChatText(message) {
|
|
|
32215
32215
|
var LlmProviderError = class extends Error {
|
|
32216
32216
|
code;
|
|
32217
32217
|
status;
|
|
32218
|
-
|
|
32218
|
+
vendorCode;
|
|
32219
|
+
stream;
|
|
32220
|
+
constructor(code, message, status, detail = {}) {
|
|
32219
32221
|
super(message);
|
|
32220
32222
|
this.code = code;
|
|
32221
32223
|
this.status = status;
|
|
32222
32224
|
this.name = "LlmProviderError";
|
|
32225
|
+
if (detail.vendorCode !== void 0)
|
|
32226
|
+
this.vendorCode = detail.vendorCode;
|
|
32227
|
+
if (detail.stream)
|
|
32228
|
+
this.stream = true;
|
|
32223
32229
|
}
|
|
32224
32230
|
};
|
|
32225
32231
|
|
|
32226
32232
|
// dist/llm/bounded-provider.js
|
|
32233
|
+
function vendorCodeOf(err) {
|
|
32234
|
+
const body = err?.error;
|
|
32235
|
+
if (!body || typeof body !== "object")
|
|
32236
|
+
return void 0;
|
|
32237
|
+
const code = body.code;
|
|
32238
|
+
if (typeof code === "number" && Number.isFinite(code))
|
|
32239
|
+
return code;
|
|
32240
|
+
if (typeof code === "string" && code.length > 0)
|
|
32241
|
+
return code.slice(0, 64);
|
|
32242
|
+
return void 0;
|
|
32243
|
+
}
|
|
32227
32244
|
function toLlmError(err, providerId) {
|
|
32228
32245
|
if (err instanceof LlmProviderError)
|
|
32229
32246
|
return err;
|
|
32230
32247
|
const raw = err?.status;
|
|
32231
32248
|
const status = typeof raw === "number" ? raw : void 0;
|
|
32232
|
-
const
|
|
32249
|
+
const vendorCode = vendorCodeOf(err);
|
|
32250
|
+
const stream = status === void 0 && vendorCode !== void 0;
|
|
32251
|
+
const detail = {
|
|
32252
|
+
...vendorCode !== void 0 ? { vendorCode } : {},
|
|
32253
|
+
...stream ? { stream } : {}
|
|
32254
|
+
};
|
|
32255
|
+
const message = `${providerId} ${status ?? (stream ? "stream error" : "network error")}`;
|
|
32233
32256
|
if (status === 401 || status === 403) {
|
|
32234
|
-
return new LlmProviderError("LLM_AUTH_FAILED", message, status);
|
|
32257
|
+
return new LlmProviderError("LLM_AUTH_FAILED", message, status, detail);
|
|
32235
32258
|
}
|
|
32236
32259
|
if (status === 429) {
|
|
32237
|
-
return new LlmProviderError("LLM_RATE_LIMITED", message, status);
|
|
32260
|
+
return new LlmProviderError("LLM_RATE_LIMITED", message, status, detail);
|
|
32238
32261
|
}
|
|
32239
32262
|
if (status === 400 || status === 404 || status === 422) {
|
|
32240
|
-
return new LlmProviderError("LLM_BAD_REQUEST", message, status);
|
|
32263
|
+
return new LlmProviderError("LLM_BAD_REQUEST", message, status, detail);
|
|
32241
32264
|
}
|
|
32242
|
-
return new LlmProviderError("LLM_PROVIDER_ERROR", message, status);
|
|
32265
|
+
return new LlmProviderError("LLM_PROVIDER_ERROR", message, status, detail);
|
|
32243
32266
|
}
|
|
32244
32267
|
function sleep(ms, signal) {
|
|
32245
32268
|
return new Promise((resolve) => {
|
|
@@ -35371,14 +35394,25 @@ function buildToolRegistry(o) {
|
|
|
35371
35394
|
}
|
|
35372
35395
|
|
|
35373
35396
|
// dist/llm/agent/history.js
|
|
35397
|
+
var MAX_CLOSED_IDS = 256;
|
|
35374
35398
|
var ConversationHistory = class {
|
|
35375
35399
|
maxTurns;
|
|
35400
|
+
onLateWrite;
|
|
35376
35401
|
turns = [];
|
|
35377
35402
|
pendingNote;
|
|
35378
|
-
|
|
35403
|
+
closed = /* @__PURE__ */ new Set();
|
|
35404
|
+
reported = /* @__PURE__ */ new Set();
|
|
35405
|
+
constructor(maxTurns, onLateWrite) {
|
|
35379
35406
|
this.maxTurns = maxTurns;
|
|
35407
|
+
this.onLateWrite = onLateWrite;
|
|
35380
35408
|
}
|
|
35381
35409
|
addUser(text, meta2) {
|
|
35410
|
+
for (const t of this.turns) {
|
|
35411
|
+
if (this.closed.has(t.turnId))
|
|
35412
|
+
continue;
|
|
35413
|
+
closeOpenToolRound(t);
|
|
35414
|
+
this.markClosed(t.turnId);
|
|
35415
|
+
}
|
|
35382
35416
|
this.turns.push({
|
|
35383
35417
|
turnId: meta2?.turnId ?? `turn-${this.turns.length + 1}`,
|
|
35384
35418
|
messages: [{ role: "user", text }]
|
|
@@ -35387,11 +35421,23 @@ var ConversationHistory = class {
|
|
|
35387
35421
|
this.turns.splice(0, this.turns.length - this.maxTurns);
|
|
35388
35422
|
}
|
|
35389
35423
|
}
|
|
35424
|
+
/** False when the turn is already closed and the message was dropped. */
|
|
35390
35425
|
addAssistant(msg, meta2) {
|
|
35426
|
+
if (this.closed.has(meta2.turnId)) {
|
|
35427
|
+
this.reportLate(meta2.turnId, "assistant", 1);
|
|
35428
|
+
return false;
|
|
35429
|
+
}
|
|
35391
35430
|
this.turnFor(meta2.turnId).messages.push(msg);
|
|
35431
|
+
return true;
|
|
35392
35432
|
}
|
|
35433
|
+
/** False when the turn is already closed and the results were dropped. */
|
|
35393
35434
|
addToolResults(results, meta2) {
|
|
35435
|
+
if (this.closed.has(meta2.turnId)) {
|
|
35436
|
+
this.reportLate(meta2.turnId, "tool", results.length);
|
|
35437
|
+
return false;
|
|
35438
|
+
}
|
|
35394
35439
|
this.turnFor(meta2.turnId).messages.push({ role: "tool", results });
|
|
35440
|
+
return true;
|
|
35395
35441
|
}
|
|
35396
35442
|
/**
|
|
35397
35443
|
* The caller heard only `playedText` of the last assistant message of the turn.
|
|
@@ -35407,7 +35453,8 @@ var ConversationHistory = class {
|
|
|
35407
35453
|
if (m.toolCalls && m.toolCalls.length > 0) {
|
|
35408
35454
|
m.text = playedText;
|
|
35409
35455
|
} else if (playedText.length === 0) {
|
|
35410
|
-
turn.messages
|
|
35456
|
+
if (turn.messages[i - 1]?.role !== "tool")
|
|
35457
|
+
turn.messages.splice(i, 1);
|
|
35411
35458
|
} else {
|
|
35412
35459
|
m.text = playedText;
|
|
35413
35460
|
delete m.providerState;
|
|
@@ -35429,6 +35476,26 @@ var ConversationHistory = class {
|
|
|
35429
35476
|
messages() {
|
|
35430
35477
|
return this.turns.flatMap((t) => t.messages);
|
|
35431
35478
|
}
|
|
35479
|
+
reportLate(turnId, kind, count2) {
|
|
35480
|
+
const key = `${turnId}:${kind}`;
|
|
35481
|
+
if (this.reported.has(key))
|
|
35482
|
+
return;
|
|
35483
|
+
this.reported.add(key);
|
|
35484
|
+
if (this.reported.size > MAX_CLOSED_IDS) {
|
|
35485
|
+
const oldest = this.reported.values().next().value;
|
|
35486
|
+
if (oldest !== void 0)
|
|
35487
|
+
this.reported.delete(oldest);
|
|
35488
|
+
}
|
|
35489
|
+
this.onLateWrite?.({ turnId, kind, count: count2 });
|
|
35490
|
+
}
|
|
35491
|
+
markClosed(turnId) {
|
|
35492
|
+
this.closed.add(turnId);
|
|
35493
|
+
if (this.closed.size > MAX_CLOSED_IDS) {
|
|
35494
|
+
const oldest = this.closed.values().next().value;
|
|
35495
|
+
if (oldest !== void 0)
|
|
35496
|
+
this.closed.delete(oldest);
|
|
35497
|
+
}
|
|
35498
|
+
}
|
|
35432
35499
|
turnFor(turnId) {
|
|
35433
35500
|
let turn = this.turns.find((t) => t.turnId === turnId);
|
|
35434
35501
|
if (!turn) {
|
|
@@ -35441,6 +35508,19 @@ var ConversationHistory = class {
|
|
|
35441
35508
|
return turn;
|
|
35442
35509
|
}
|
|
35443
35510
|
};
|
|
35511
|
+
function closeOpenToolRound(turn) {
|
|
35512
|
+
const msgs = turn.messages;
|
|
35513
|
+
while (msgs.length > 0 && msgs[msgs.length - 1].role === "tool")
|
|
35514
|
+
msgs.pop();
|
|
35515
|
+
const i = msgs.length - 1;
|
|
35516
|
+
const m = msgs[i];
|
|
35517
|
+
if (!m || m.role !== "assistant" || !m.toolCalls || m.toolCalls.length === 0)
|
|
35518
|
+
return;
|
|
35519
|
+
delete m.toolCalls;
|
|
35520
|
+
delete m.providerState;
|
|
35521
|
+
if (!m.text)
|
|
35522
|
+
msgs.splice(i, 1);
|
|
35523
|
+
}
|
|
35444
35524
|
|
|
35445
35525
|
// dist/llm/agent/link-extractor.js
|
|
35446
35526
|
var LINK_MARK = "\uE000";
|
|
@@ -36649,7 +36729,7 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
|
|
|
36649
36729
|
}
|
|
36650
36730
|
const code = err instanceof LlmProviderError ? err.code : "LLM_TURN_ERROR";
|
|
36651
36731
|
t.errorCode = code;
|
|
36652
|
-
agentLog("error", `llm turn failed: ${code}`, s.sessionId);
|
|
36732
|
+
agentLog("error", `llm turn failed: ${code}`, err instanceof LlmProviderError ? providerErrorFields(err) : {}, s.sessionId);
|
|
36653
36733
|
speakFallback(s, t);
|
|
36654
36734
|
t.status = "failed";
|
|
36655
36735
|
return summarize(t);
|
|
@@ -36898,7 +36978,7 @@ ${t.inputText}` : t.inputText, {
|
|
|
36898
36978
|
async onSessionStart(ctx) {
|
|
36899
36979
|
const s = {
|
|
36900
36980
|
sessionId: ctx.sessionId,
|
|
36901
|
-
history: new ConversationHistory(historyTurns),
|
|
36981
|
+
history: new ConversationHistory(historyTurns, (fields) => agentLog("info", "history late write dropped", fields, ctx.sessionId)),
|
|
36902
36982
|
speech: [],
|
|
36903
36983
|
announcing: 0,
|
|
36904
36984
|
chain: Promise.resolve(),
|
|
@@ -36979,6 +37059,13 @@ ${t.inputText}` : t.inputText, {
|
|
|
36979
37059
|
}
|
|
36980
37060
|
};
|
|
36981
37061
|
}
|
|
37062
|
+
function providerErrorFields(err) {
|
|
37063
|
+
return {
|
|
37064
|
+
...err.status !== void 0 ? { status: err.status } : {},
|
|
37065
|
+
...err.vendorCode !== void 0 ? { vendorCode: err.vendorCode } : {},
|
|
37066
|
+
...err.stream ? { stream: true } : {}
|
|
37067
|
+
};
|
|
37068
|
+
}
|
|
36982
37069
|
|
|
36983
37070
|
// node_modules/openai/internal/tslib.mjs
|
|
36984
37071
|
function __classPrivateFieldSet(receiver, state2, value, kind, f) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/templates/registry.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,SAA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,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,oFAAoF;IACpF,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C;AAED,eAAO,MAAM,eAAe,EAAE,SAAS,uBAAuB,EA2gBpD,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC;AAMrE,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,EAAE,IAAI,eAAe,CAEnE;AAED,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,uBAAuB,CAMnE;AAED,wBAAgB,yBAAyB,IAAI,uBAAuB,EAAE,CAErE"}
|
|
@@ -208,6 +208,31 @@ export const AGENT_TEMPLATES = [
|
|
|
208
208
|
ioredis: "^5.11.1",
|
|
209
209
|
},
|
|
210
210
|
},
|
|
211
|
+
{
|
|
212
|
+
id: "llm-language-switch",
|
|
213
|
+
entry: "llm-language-switch/agent.ts",
|
|
214
|
+
kind: "product",
|
|
215
|
+
seedOnCreate: true,
|
|
216
|
+
title: "Language switch (LLM)",
|
|
217
|
+
summary: "Travel-help assistant that follows a mid-call language switch: the runner swaps speech, the LLM answers in the new language.",
|
|
218
|
+
category: "voice-data",
|
|
219
|
+
description: "An LLM assistant that stays in the call when the caller changes language. The runner detects the new language and swaps speech-to-text and the voice; the agent tells the LLM which language the caller speaks now and reports it to the client. Needs the project secret AGENT_OPENROUTER_API_KEY and project auto-switch with VoiceThere speech on both sides.",
|
|
220
|
+
sourceFiles: [
|
|
221
|
+
"llm-language-switch/agent.ts",
|
|
222
|
+
"llm-language-switch/language.ts",
|
|
223
|
+
"llm-language-switch/voicethere.llm.json",
|
|
224
|
+
"llm-language-switch/prompt.md",
|
|
225
|
+
"llm-language-switch/md.d.ts",
|
|
226
|
+
"llm-language-switch/README.md",
|
|
227
|
+
],
|
|
228
|
+
npmDependencies: {
|
|
229
|
+
openai: "^7.43.0",
|
|
230
|
+
"@anthropic-ai/sdk": "^1.3.0",
|
|
231
|
+
"@google/genai": "^2.31.0",
|
|
232
|
+
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
233
|
+
ioredis: "^5.11.1",
|
|
234
|
+
},
|
|
235
|
+
},
|
|
211
236
|
{
|
|
212
237
|
id: "llm-language-tutor",
|
|
213
238
|
entry: "llm-language-tutor/agent.ts",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/templates/registry.ts"],"names":[],"mappings":"AAyBA,MAAM,CAAC,MAAM,eAAe,GAAuC;IACjE;QACE,EAAE,EAAE,MAAM;QACV,KAAK,EAAE,eAAe;QACtB,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,IAAI;QAClB,KAAK,EAAE,qBAAqB;QAC5B,OAAO,EAAE,0DAA0D;QACnE,QAAQ,EAAE,OAAO;QACjB,WAAW,EACT,8EAA8E;QAChF,WAAW,EAAE,CAAC,eAAe,CAAC;KAC/B;IACD;QACE,EAAE,EAAE,SAAS;QACb,KAAK,EAAE,kBAAkB;QACzB,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,IAAI;QAClB,KAAK,EAAE,6BAA6B;QACpC,OAAO,EAAE,2CAA2C;QACpD,QAAQ,EAAE,OAAO;QACjB,WAAW,EACT,qEAAqE;QACvE,WAAW,EAAE,CAAC,kBAAkB,CAAC;KAClC;IACD;QACE,EAAE,EAAE,iBAAiB;QACrB,KAAK,EAAE,0BAA0B;QACjC,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,IAAI;QAClB,KAAK,EAAE,iBAAiB;QACxB,OAAO,EACL,qIAAqI;QACvI,QAAQ,EAAE,OAAO;QACjB,WAAW,EACT,qVAAqV;QACvV,WAAW,EAAE,CAAC,0BAA0B,CAAC;KAC1C;IACD;QACE,EAAE,EAAE,cAAc;QAClB,KAAK,EAAE,uBAAuB;QAC9B,IAAI,EAAE,SAAS;QACf,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AAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,8BAA8B,EAAE,EAAE,CAAC,CAAC;IACtD,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,yBAAyB;IACvC,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;AACrE,CAAC"}
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/templates/registry.ts"],"names":[],"mappings":"AAyBA,MAAM,CAAC,MAAM,eAAe,GAAuC;IACjE;QACE,EAAE,EAAE,MAAM;QACV,KAAK,EAAE,eAAe;QACtB,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,IAAI;QAClB,KAAK,EAAE,qBAAqB;QAC5B,OAAO,EAAE,0DAA0D;QACnE,QAAQ,EAAE,OAAO;QACjB,WAAW,EACT,8EAA8E;QAChF,WAAW,EAAE,CAAC,eAAe,CAAC;KAC/B;IACD;QACE,EAAE,EAAE,SAAS;QACb,KAAK,EAAE,kBAAkB;QACzB,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,IAAI;QAClB,KAAK,EAAE,6BAA6B;QACpC,OAAO,EAAE,2CAA2C;QACpD,QAAQ,EAAE,OAAO;QACjB,WAAW,EACT,qEAAqE;QACvE,WAAW,EAAE,CAAC,kBAAkB,CAAC;KAClC;IACD;QACE,EAAE,EAAE,iBAAiB;QACrB,KAAK,EAAE,0BAA0B;QACjC,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,IAAI;QAClB,KAAK,EAAE,iBAAiB;QACxB,OAAO,EACL,qIAAqI;QACvI,QAAQ,EAAE,OAAO;QACjB,WAAW,EACT,qVAAqV;QACvV,WAAW,EAAE,CAAC,0BAA0B,CAAC;KAC1C;IACD;QACE,EAAE,EAAE,cAAc;QAClB,KAAK,EAAE,uBAAuB;QAC9B,IAAI,EAAE,SAAS;QACf,YAAY,EAA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,OAAO;QACjB,WAAW,EACT,iFAAiF;QACnF,WAAW,EAAE,CAAC,oBAAoB,CAAC;KACpC;CACO,CAAC;AAIX,MAAM,cAAc,GAAG,IAAI,GAAG,CAC5B,eAAe,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC,CAC3D,CAAC;AAEF,MAAM,UAAU,iBAAiB,CAAC,EAAU;IAC1C,OAAO,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,EAAU;IACxC,MAAM,QAAQ,GAAG,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACxC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,8BAA8B,EAAE,EAAE,CAAC,CAAC;IACtD,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,yBAAyB;IACvC,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;AACrE,CAAC"}
|
package/eject/llm/loop.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copied from @voicethere/agent 0.
|
|
1
|
+
// Copied from @voicethere/agent 0.34.0. Package updates no longer change this file.
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import {
|
|
4
4
|
type AgentHandlers,
|
|
@@ -1298,7 +1298,12 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
|
|
|
1298
1298
|
const code =
|
|
1299
1299
|
err instanceof LlmProviderError ? err.code : "LLM_TURN_ERROR";
|
|
1300
1300
|
t.errorCode = code;
|
|
1301
|
-
agentLog(
|
|
1301
|
+
agentLog(
|
|
1302
|
+
"error",
|
|
1303
|
+
`llm turn failed: ${code}`,
|
|
1304
|
+
err instanceof LlmProviderError ? providerErrorFields(err) : {},
|
|
1305
|
+
s.sessionId,
|
|
1306
|
+
);
|
|
1302
1307
|
speakFallback(s, t);
|
|
1303
1308
|
t.status = "failed";
|
|
1304
1309
|
return summarize(t);
|
|
@@ -1599,7 +1604,9 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
|
|
|
1599
1604
|
async onSessionStart(ctx: SessionContext) {
|
|
1600
1605
|
const s: SessionState = {
|
|
1601
1606
|
sessionId: ctx.sessionId,
|
|
1602
|
-
history: new ConversationHistory(historyTurns)
|
|
1607
|
+
history: new ConversationHistory(historyTurns, (fields) =>
|
|
1608
|
+
agentLog("info", "history late write dropped", fields, ctx.sessionId),
|
|
1609
|
+
),
|
|
1603
1610
|
speech: [],
|
|
1604
1611
|
announcing: 0,
|
|
1605
1612
|
chain: Promise.resolve(),
|
|
@@ -1692,3 +1699,14 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
|
|
|
1692
1699
|
},
|
|
1693
1700
|
};
|
|
1694
1701
|
}
|
|
1702
|
+
|
|
1703
|
+
/** Safe metadata for the `llm turn failed` row: no vendor message, no body. */
|
|
1704
|
+
export function providerErrorFields(
|
|
1705
|
+
err: LlmProviderError,
|
|
1706
|
+
): Record<string, unknown> {
|
|
1707
|
+
return {
|
|
1708
|
+
...(err.status !== undefined ? { status: err.status } : {}),
|
|
1709
|
+
...(err.vendorCode !== undefined ? { vendorCode: err.vendorCode } : {}),
|
|
1710
|
+
...(err.stream ? { stream: true } : {}),
|
|
1711
|
+
};
|
|
1712
|
+
}
|
package/package.json
CHANGED
package/templates/README.md
CHANGED
|
@@ -76,6 +76,7 @@ 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-switch` | `llm-language-switch/` | `llm-agent` that follows a mid-call language switch (runner auto-switch, VoiceThere speech both sides) |
|
|
79
80
|
| `llm-language-tutor` | `llm-language-tutor/` | English practice partner: `llm-agent` plus a lessons knowledge base (Redis) |
|
|
80
81
|
| `llm-store-support` | `llm-store-support/` | Support assistant for a sample store: Markdown knowledge (Redis) plus an MCP price tool on a project service |
|
|
81
82
|
| `llm-board` | `llm-board/` | Shared sticky-note board over the data channel with an LLM facilitator (no Redis) |
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# llm-language-switch
|
|
2
|
+
|
|
3
|
+
A small travel-help assistant that follows the caller when they change language in the middle of the call. Speak English, then start speaking German, Spanish or French: the runner detects the language, switches speech-to-text and the voice, and replays the utterance, and the LLM answers in the new language in the new voice. Source: `templates/llm-language-switch/agent.ts` and `language.ts`.
|
|
4
|
+
|
|
5
|
+
## What you need
|
|
6
|
+
|
|
7
|
+
- A project secret named `AGENT_OPENROUTER_API_KEY` (a key from openrouter.ai).
|
|
8
|
+
- These project settings. Without them the call stays in English and the agent logs `language_switch.auto_off`:
|
|
9
|
+
- voice language settings: language identification on and `autoSwitch` on, with replay of the switching utterance and voice switching on;
|
|
10
|
+
- VoiceThere speech-to-text and text-to-speech on both sides (auto-switch needs both);
|
|
11
|
+
- `voice.allowedLanguages` set to `["en", "de", "es", "fr"]`.
|
|
12
|
+
|
|
13
|
+
## How it works
|
|
14
|
+
|
|
15
|
+
The runner owns the switch. The agent never calls `setVoiceLanguage`.
|
|
16
|
+
|
|
17
|
+
- `onVoiceLanguageChanged` records the committed language and sends `{ "type": "language", "language": "de" }` to the client. Only a committed language changes what the LLM is told. The agent appends one line ("The caller now speaks German (de). Reply only in German.") to a copy of the last caller message on every LLM call, so it never piles up in the history.
|
|
18
|
+
- `onUserLanguage` only reports what was heard: `{ "type": "language_detected", "language": "it", "supported": false }`. The runner may still reject a detection, so the LLM note does not change on it.
|
|
19
|
+
- When the detected language is not in `SUPPORTED_LANGUAGES`, the runner does not switch and the transcript comes from the wrong language's speech model. The agent skips the LLM for that utterance and says, in the current language, "I heard Italian. I can talk with you in English, German, Spanish or French." That notice is not added to the LLM history.
|
|
20
|
+
- Typed chat messages are answered in the language they are written in (the prompt says so); chat does not change the voice.
|
|
21
|
+
|
|
22
|
+
## Files
|
|
23
|
+
|
|
24
|
+
- `agent.ts` wires `createLlmAgent` into `languageSwitchAgent`.
|
|
25
|
+
- `language.ts` holds `SUPPORTED_LANGUAGES`, the language note and the unsupported-language notice. Keep `SUPPORTED_LANGUAGES` equal to the project's `voice.allowedLanguages`.
|
|
26
|
+
- `voicethere.llm.json` holds the model, greeting and limits.
|
|
27
|
+
- `prompt.md` is the system prompt.
|
|
28
|
+
- `md.d.ts` lets TypeScript accept `import x from "./x.md"`.
|
|
29
|
+
|
|
30
|
+
## Cost
|
|
31
|
+
|
|
32
|
+
Measured on VoiceThere's demo: see the use-case page.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { defineAgent } from "@voicethere/agent";
|
|
2
|
+
import { createLlmAgent } from "@voicethere/agent/llm";
|
|
3
|
+
import { openai } from "@voicethere/agent/llm/openai";
|
|
4
|
+
import config from "./voicethere.llm.json";
|
|
5
|
+
import systemPrompt from "./prompt.md";
|
|
6
|
+
import { languageSwitchAgent } from "./language";
|
|
7
|
+
|
|
8
|
+
// The runner owns the language switch: project auto-switch detects the new
|
|
9
|
+
// language, warms its speech models, swaps STT and voice and replays the
|
|
10
|
+
// utterance. This agent never calls setVoiceLanguage. It only tells the LLM
|
|
11
|
+
// which language the caller speaks now (language.ts), so the reply comes in
|
|
12
|
+
// that language, and reports the language to the client.
|
|
13
|
+
//
|
|
14
|
+
// Needs the project secret AGENT_OPENROUTER_API_KEY and the project settings
|
|
15
|
+
// described in README.md (auto-switch on, VoiceThere speech on both sides).
|
|
16
|
+
defineAgent(
|
|
17
|
+
languageSwitchAgent((hooks) =>
|
|
18
|
+
createLlmAgent({
|
|
19
|
+
config,
|
|
20
|
+
systemPrompt,
|
|
21
|
+
providers: [openai],
|
|
22
|
+
hooks,
|
|
23
|
+
}),
|
|
24
|
+
),
|
|
25
|
+
);
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import {
|
|
2
|
+
agentLog,
|
|
3
|
+
isRunnerLidAutoSwitchEnabled,
|
|
4
|
+
sendToClient,
|
|
5
|
+
speak,
|
|
6
|
+
type AgentHandlers,
|
|
7
|
+
} from "@voicethere/agent";
|
|
8
|
+
import type { LlmAgentHooks, LlmMessage } from "@voicethere/agent/llm";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Languages the call switches to. Keep this equal to the project's
|
|
12
|
+
* `voice.allowedLanguages`: the runner does not switch to any other detected
|
|
13
|
+
* language, and this agent then tells the caller what it heard.
|
|
14
|
+
*/
|
|
15
|
+
export const SUPPORTED_LANGUAGES: readonly string[] = ["en", "de", "es", "fr"];
|
|
16
|
+
|
|
17
|
+
/** The language a session starts in (the project's voice language). */
|
|
18
|
+
export const DEFAULT_LANGUAGE = "en";
|
|
19
|
+
|
|
20
|
+
/** Lower-case ISO 639-1 code from `de`, `DE` or `de-DE`. */
|
|
21
|
+
export function normalizeLanguage(code: string): string {
|
|
22
|
+
return code.trim().toLowerCase().split(/[-_]/)[0] ?? "";
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function isSupported(code: string): boolean {
|
|
26
|
+
return SUPPORTED_LANGUAGES.includes(normalizeLanguage(code));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** The language's name written in `inLanguage`, or the code when unknown. */
|
|
30
|
+
export function languageName(code: string, inLanguage: string): string {
|
|
31
|
+
try {
|
|
32
|
+
const names = new Intl.DisplayNames([inLanguage], { type: "language" });
|
|
33
|
+
return names.of(code) ?? code;
|
|
34
|
+
} catch {
|
|
35
|
+
return code;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** The one line that tells the LLM which language the caller speaks now. */
|
|
40
|
+
export function languageNote(code: string): string {
|
|
41
|
+
const name = languageName(code, "en");
|
|
42
|
+
return `The caller now speaks ${name} (${code}). Reply only in ${name}.`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
interface NoticeText {
|
|
46
|
+
heard: (language: string) => string;
|
|
47
|
+
can: (list: string) => string;
|
|
48
|
+
or: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const NOTICE: Record<string, NoticeText> = {
|
|
52
|
+
en: {
|
|
53
|
+
heard: (l) => `I heard ${l}.`,
|
|
54
|
+
can: (list) => `I can talk with you in ${list}.`,
|
|
55
|
+
or: "or",
|
|
56
|
+
},
|
|
57
|
+
de: {
|
|
58
|
+
heard: (l) => `Ich habe ${l} gehört.`,
|
|
59
|
+
can: (list) => `Ich kann mit dir in diesen Sprachen sprechen: ${list}.`,
|
|
60
|
+
or: "oder",
|
|
61
|
+
},
|
|
62
|
+
es: {
|
|
63
|
+
heard: (l) => `Escuché ${l}.`,
|
|
64
|
+
can: (list) => `Puedo hablar contigo en ${list}.`,
|
|
65
|
+
or: "o",
|
|
66
|
+
},
|
|
67
|
+
fr: {
|
|
68
|
+
heard: (l) => `J'ai entendu ${l}.`,
|
|
69
|
+
can: (list) => `Je peux parler avec vous en ${list}.`,
|
|
70
|
+
or: "ou",
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* What the agent says when the caller spoke a language it cannot switch to:
|
|
76
|
+
* in the session's current language, naming the heard language and the
|
|
77
|
+
* supported ones ("I heard Italian. I can talk with you in English, German,
|
|
78
|
+
* Spanish or French.").
|
|
79
|
+
*/
|
|
80
|
+
export function unsupportedNotice(heard: string, current: string): string {
|
|
81
|
+
const lang = isSupported(current)
|
|
82
|
+
? normalizeLanguage(current)
|
|
83
|
+
: DEFAULT_LANGUAGE;
|
|
84
|
+
const text = NOTICE[lang]!;
|
|
85
|
+
const names = SUPPORTED_LANGUAGES.map((c) => languageName(c, lang));
|
|
86
|
+
const list =
|
|
87
|
+
names.length > 1
|
|
88
|
+
? `${names.slice(0, -1).join(", ")} ${text.or} ${names[names.length - 1]}`
|
|
89
|
+
: (names[0] ?? "");
|
|
90
|
+
return `${text.heard(languageName(heard, lang))} ${text.can(list)}`;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Appends the language note to a copy of the last caller message, so the
|
|
95
|
+
* model sees it last on every call and it never stacks in the history. The
|
|
96
|
+
* LLM message type has no system role; the stored history is not touched.
|
|
97
|
+
*/
|
|
98
|
+
export function withLanguageNote(
|
|
99
|
+
messages: LlmMessage[],
|
|
100
|
+
code: string,
|
|
101
|
+
): LlmMessage[] {
|
|
102
|
+
const note = languageNote(code);
|
|
103
|
+
for (let i = messages.length - 1; i >= 0; i -= 1) {
|
|
104
|
+
const m = messages[i]!;
|
|
105
|
+
if (m.role === "user") {
|
|
106
|
+
const copy = messages.slice();
|
|
107
|
+
copy[i] = { role: "user", text: `${m.text}\n\n(${note})` };
|
|
108
|
+
return copy;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return messages;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** Turn id prefix of the unsupported-language notice (not an LLM reply). */
|
|
115
|
+
const NOTICE_TURN_PREFIX = "lang-notice-";
|
|
116
|
+
|
|
117
|
+
interface SessionLanguage {
|
|
118
|
+
/** Committed by the runner (`voice_language_changed`), never a guess. */
|
|
119
|
+
current: string;
|
|
120
|
+
/** Detected language outside the list, waiting for its final. */
|
|
121
|
+
unsupported?: string;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Wraps an LLM agent so it follows the runner's language switch. `create`
|
|
126
|
+
* receives the hooks to pass to `createLlmAgent`.
|
|
127
|
+
*/
|
|
128
|
+
export function languageSwitchAgent(
|
|
129
|
+
create: (hooks: LlmAgentHooks) => AgentHandlers,
|
|
130
|
+
): AgentHandlers {
|
|
131
|
+
const sessions = new Map<string, SessionLanguage>();
|
|
132
|
+
|
|
133
|
+
const llm = create({
|
|
134
|
+
onBeforeLlmCall(messages, ctx) {
|
|
135
|
+
// Typed chat is answered in the language it is written in.
|
|
136
|
+
if (ctx.source === "chat") return;
|
|
137
|
+
const code = sessions.get(ctx.sessionId)?.current ?? DEFAULT_LANGUAGE;
|
|
138
|
+
return withLanguageNote(messages, code);
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
return {
|
|
143
|
+
...llm,
|
|
144
|
+
|
|
145
|
+
onSessionStart(ctx) {
|
|
146
|
+
sessions.set(ctx.sessionId, { current: DEFAULT_LANGUAGE });
|
|
147
|
+
if (!isRunnerLidAutoSwitchEnabled(ctx.env)) {
|
|
148
|
+
agentLog(
|
|
149
|
+
"warn",
|
|
150
|
+
"language_switch.auto_off",
|
|
151
|
+
{ detail: "project auto-switch is off; the call stays in English" },
|
|
152
|
+
ctx.sessionId,
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
return llm.onSessionStart?.(ctx);
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
// A detection is not a switch: the runner may still reject it
|
|
159
|
+
// (not_allowed, dwell, confirm). Only tell the client, and remember an
|
|
160
|
+
// unsupported language for the final that follows.
|
|
161
|
+
onUserLanguage(ctx) {
|
|
162
|
+
const language = normalizeLanguage(ctx.language);
|
|
163
|
+
if (!language) return;
|
|
164
|
+
const supported = isSupported(language);
|
|
165
|
+
sendToClient(ctx.sessionId, {
|
|
166
|
+
type: "language_detected",
|
|
167
|
+
language,
|
|
168
|
+
supported,
|
|
169
|
+
});
|
|
170
|
+
const state = sessions.get(ctx.sessionId);
|
|
171
|
+
if (state) state.unsupported = supported ? undefined : language;
|
|
172
|
+
},
|
|
173
|
+
|
|
174
|
+
onVoiceLanguageChanged(ctx) {
|
|
175
|
+
const language = normalizeLanguage(ctx.language);
|
|
176
|
+
if (!language) return;
|
|
177
|
+
const state = sessions.get(ctx.sessionId);
|
|
178
|
+
if (state) {
|
|
179
|
+
state.current = language;
|
|
180
|
+
state.unsupported = undefined;
|
|
181
|
+
}
|
|
182
|
+
sendToClient(ctx.sessionId, { type: "language", language });
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
onUserSpeechFinal(ctx) {
|
|
186
|
+
const state = sessions.get(ctx.sessionId);
|
|
187
|
+
if (state?.unsupported && !ctx.replay) {
|
|
188
|
+
// The transcript came from the wrong language's STT: do not ask the
|
|
189
|
+
// LLM, say what was heard in the current language instead.
|
|
190
|
+
const text = unsupportedNotice(state.unsupported, state.current);
|
|
191
|
+
state.unsupported = undefined;
|
|
192
|
+
const turnId = `${NOTICE_TURN_PREFIX}${ctx.utteranceId ?? Date.now()}`;
|
|
193
|
+
sendToClient(ctx.sessionId, {
|
|
194
|
+
type: "assistant_delta",
|
|
195
|
+
turnId,
|
|
196
|
+
text,
|
|
197
|
+
spoken: true,
|
|
198
|
+
});
|
|
199
|
+
sendToClient(ctx.sessionId, {
|
|
200
|
+
type: "assistant_done",
|
|
201
|
+
turnId,
|
|
202
|
+
text,
|
|
203
|
+
spoken: true,
|
|
204
|
+
status: "completed",
|
|
205
|
+
});
|
|
206
|
+
speak(ctx.sessionId, text, { turnId });
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
return llm.onUserSpeechFinal?.(ctx);
|
|
210
|
+
},
|
|
211
|
+
|
|
212
|
+
onAgentInterrupted(ctx) {
|
|
213
|
+
// The notice is not an LLM reply: no interruption note for it.
|
|
214
|
+
if (ctx.turnId?.startsWith(NOTICE_TURN_PREFIX)) return;
|
|
215
|
+
return llm.onAgentInterrupted?.(ctx);
|
|
216
|
+
},
|
|
217
|
+
|
|
218
|
+
onSessionEnd(ctx) {
|
|
219
|
+
sessions.delete(ctx.sessionId);
|
|
220
|
+
return llm.onSessionEnd?.(ctx);
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
You are a friendly travel-help assistant. People talk to you by voice, so everything you say is read aloud.
|
|
2
|
+
|
|
3
|
+
Answer in one to three short spoken sentences, in plain words. Do not use markdown, lists, emoji or special characters.
|
|
4
|
+
|
|
5
|
+
Reply in the language the caller speaks now. A note at the end of the conversation names that language; follow it. If the caller types a message, answer in the language the message is written in.
|
|
6
|
+
|
|
7
|
+
Help with simple travel questions: getting around, ordering food, greetings, small talk about a trip. If you do not know something, say so and offer a related tip.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "./node_modules/@voicethere/agent/schema/voicethere.llm.schema.json",
|
|
3
|
+
"version": 1,
|
|
4
|
+
"provider": "openrouter",
|
|
5
|
+
"model": "amazon/nova-micro-v1",
|
|
6
|
+
"apiKeySecret": "AGENT_OPENROUTER_API_KEY",
|
|
7
|
+
"maxOutputTokens": 256,
|
|
8
|
+
"greeting": {
|
|
9
|
+
"text": "Hi! Talk to me in English, German, Spanish or French. Switch any time and I'll follow.",
|
|
10
|
+
"interruptible": true
|
|
11
|
+
},
|
|
12
|
+
"bargeIn": { "mode": "project" },
|
|
13
|
+
"history": { "turns": 20, "interruptionNote": true },
|
|
14
|
+
"fillers": {
|
|
15
|
+
"thinking": {
|
|
16
|
+
"phrases": ["Okay.", "Right.", "Let me think."],
|
|
17
|
+
"afterMs": 1500
|
|
18
|
+
},
|
|
19
|
+
"interruptible": true
|
|
20
|
+
},
|
|
21
|
+
"toolSources": [],
|
|
22
|
+
"interruptPolicy": "cancel"
|
|
23
|
+
}
|