@voicethere/agent 0.13.0 → 0.14.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/config.d.ts +123 -0
- package/dist/llm/agent/config.d.ts.map +1 -1
- package/dist/llm/agent/config.js +170 -1
- package/dist/llm/agent/config.js.map +1 -1
- package/dist/llm/agent/create-llm-agent.d.ts +2 -0
- package/dist/llm/agent/create-llm-agent.d.ts.map +1 -1
- package/dist/llm/agent/create-llm-agent.js +186 -9
- package/dist/llm/agent/create-llm-agent.js.map +1 -1
- package/dist/llm/agent/prompt-guidance.d.ts +7 -0
- package/dist/llm/agent/prompt-guidance.d.ts.map +1 -0
- package/dist/llm/agent/prompt-guidance.js +15 -0
- package/dist/llm/agent/prompt-guidance.js.map +1 -0
- package/dist/llm/index.d.ts +2 -1
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js +1 -0
- package/dist/llm/index.js.map +1 -1
- package/dist/templates/llm-agent/agent.js +354 -13
- package/eject/llm/loop.ts +213 -11
- package/package.json +1 -1
- package/schema/voicethere.llm.schema.json +93 -0
- package/templates/llm-agent/README.md +39 -0
- package/templates/llm-agent/prompt.md +10 -0
- package/templates/llm-agent/voicethere.llm.json +18 -2
|
@@ -21762,6 +21762,10 @@ var LLM_AGENT_CONFIG_DEFAULTS = {
|
|
|
21762
21762
|
toolMaxResultBytes: 16384,
|
|
21763
21763
|
fillerAfterMs: 1500,
|
|
21764
21764
|
fillerInterruptible: false,
|
|
21765
|
+
thinkingAfterMs: 1500,
|
|
21766
|
+
toolWaitAfterMs: 4e3,
|
|
21767
|
+
fillersInterruptible: true,
|
|
21768
|
+
speechCoalesceMs: 150,
|
|
21765
21769
|
servicePath: "/mcp",
|
|
21766
21770
|
interruptPolicy: "cancel",
|
|
21767
21771
|
serviceWaitMs: 2e4,
|
|
@@ -22030,6 +22034,8 @@ var TOP_KEYS = [
|
|
|
22030
22034
|
"speechDuringNonInterruptible",
|
|
22031
22035
|
"history",
|
|
22032
22036
|
"tools",
|
|
22037
|
+
"fillers",
|
|
22038
|
+
"speech",
|
|
22033
22039
|
"toolSources",
|
|
22034
22040
|
"interruptPolicy",
|
|
22035
22041
|
"serviceWaitMs",
|
|
@@ -22196,6 +22202,82 @@ function validateLlmAgentConfig(input) {
|
|
|
22196
22202
|
config2.tools = tools2;
|
|
22197
22203
|
}
|
|
22198
22204
|
}
|
|
22205
|
+
const warnings = [];
|
|
22206
|
+
if (root.fillers !== void 0) {
|
|
22207
|
+
const f = c.object(root.fillers, "fillers");
|
|
22208
|
+
if (f) {
|
|
22209
|
+
c.unknownKeys(f, ["thinking", "toolCall", "toolWait", "interruptible"], "fillers");
|
|
22210
|
+
const fillers = {};
|
|
22211
|
+
const situations = [
|
|
22212
|
+
["thinking", 60, [300, 1e4]],
|
|
22213
|
+
["toolCall", 120, void 0],
|
|
22214
|
+
["toolWait", 120, [1e3, 3e4]]
|
|
22215
|
+
];
|
|
22216
|
+
for (const [key, maxChars, range] of situations) {
|
|
22217
|
+
if (f[key] === void 0)
|
|
22218
|
+
continue;
|
|
22219
|
+
const path2 = `fillers.${key}`;
|
|
22220
|
+
const o = c.object(f[key], path2);
|
|
22221
|
+
if (!o)
|
|
22222
|
+
continue;
|
|
22223
|
+
c.unknownKeys(o, range ? ["phrases", "afterMs"] : ["phrases"], path2);
|
|
22224
|
+
const sit = { phrases: [] };
|
|
22225
|
+
if (o.phrases !== void 0) {
|
|
22226
|
+
if (!Array.isArray(o.phrases)) {
|
|
22227
|
+
c.err(`${path2}.phrases`, "must be an array of strings");
|
|
22228
|
+
} else if (o.phrases.length > 20) {
|
|
22229
|
+
c.err(`${path2}.phrases`, "must have at most 20 entries");
|
|
22230
|
+
} else {
|
|
22231
|
+
o.phrases.forEach((item, i) => {
|
|
22232
|
+
const p = `${path2}.phrases[${i}]`;
|
|
22233
|
+
if (typeof item !== "string") {
|
|
22234
|
+
c.err(p, "must be a string");
|
|
22235
|
+
return;
|
|
22236
|
+
}
|
|
22237
|
+
const text = item.trim();
|
|
22238
|
+
if (text.length < 1)
|
|
22239
|
+
c.err(p, "must be at least 1 character");
|
|
22240
|
+
else if (text.length > maxChars) {
|
|
22241
|
+
c.err(p, `must be at most ${maxChars} characters`);
|
|
22242
|
+
} else
|
|
22243
|
+
sit.phrases.push(text);
|
|
22244
|
+
});
|
|
22245
|
+
}
|
|
22246
|
+
}
|
|
22247
|
+
if (range && o.afterMs !== void 0) {
|
|
22248
|
+
const n = c.number(o.afterMs, `${path2}.afterMs`, range[0], range[1], true);
|
|
22249
|
+
if (n !== void 0)
|
|
22250
|
+
sit.afterMs = n;
|
|
22251
|
+
}
|
|
22252
|
+
fillers[key] = sit;
|
|
22253
|
+
}
|
|
22254
|
+
if (f.interruptible !== void 0) {
|
|
22255
|
+
const b = c.boolean(f.interruptible, "fillers.interruptible");
|
|
22256
|
+
if (b !== void 0)
|
|
22257
|
+
fillers.interruptible = b;
|
|
22258
|
+
}
|
|
22259
|
+
config2.fillers = fillers;
|
|
22260
|
+
if (((fillers.toolCall?.phrases.length ?? 0) > 0 || (fillers.toolWait?.phrases.length ?? 0) > 0) && isRecord(root.tools) && root.tools.filler !== void 0) {
|
|
22261
|
+
warnings.push({
|
|
22262
|
+
path: "tools.filler",
|
|
22263
|
+
message: "is ignored because fillers.toolCall or fillers.toolWait is set; move the text into fillers.toolWait.phrases"
|
|
22264
|
+
});
|
|
22265
|
+
}
|
|
22266
|
+
}
|
|
22267
|
+
}
|
|
22268
|
+
if (root.speech !== void 0) {
|
|
22269
|
+
const sp = c.object(root.speech, "speech");
|
|
22270
|
+
if (sp) {
|
|
22271
|
+
c.unknownKeys(sp, ["coalesceMs"], "speech");
|
|
22272
|
+
const speech = {};
|
|
22273
|
+
if (sp.coalesceMs !== void 0) {
|
|
22274
|
+
const n = c.number(sp.coalesceMs, "speech.coalesceMs", 0, 1e3, true);
|
|
22275
|
+
if (n !== void 0)
|
|
22276
|
+
speech.coalesceMs = n;
|
|
22277
|
+
}
|
|
22278
|
+
config2.speech = speech;
|
|
22279
|
+
}
|
|
22280
|
+
}
|
|
22199
22281
|
if (root.toolSources !== void 0) {
|
|
22200
22282
|
const s = checkSources(c, root.toolSources, "toolSources");
|
|
22201
22283
|
if (s)
|
|
@@ -22225,7 +22307,7 @@ function validateLlmAgentConfig(input) {
|
|
|
22225
22307
|
}
|
|
22226
22308
|
if (c.errors.length > 0)
|
|
22227
22309
|
return { ok: false, errors: c.errors };
|
|
22228
|
-
return { ok: true, config: config2 };
|
|
22310
|
+
return { ok: true, config: config2, warnings };
|
|
22229
22311
|
}
|
|
22230
22312
|
var envName = {
|
|
22231
22313
|
type: "string",
|
|
@@ -22309,6 +22391,8 @@ var LLM_AGENT_CONFIG_JSON_SCHEMA = {
|
|
|
22309
22391
|
},
|
|
22310
22392
|
filler: {
|
|
22311
22393
|
type: "object",
|
|
22394
|
+
deprecated: true,
|
|
22395
|
+
description: "Deprecated: use the top-level fillers block. Ignored when fillers is set.",
|
|
22312
22396
|
additionalProperties: false,
|
|
22313
22397
|
required: ["text"],
|
|
22314
22398
|
properties: {
|
|
@@ -22324,6 +22408,85 @@ var LLM_AGENT_CONFIG_JSON_SCHEMA = {
|
|
|
22324
22408
|
}
|
|
22325
22409
|
}
|
|
22326
22410
|
},
|
|
22411
|
+
fillers: {
|
|
22412
|
+
type: "object",
|
|
22413
|
+
description: "Short sentences the agent speaks while the caller waits. Off when absent. At most 3 fillers per turn, never back to back.",
|
|
22414
|
+
additionalProperties: false,
|
|
22415
|
+
properties: {
|
|
22416
|
+
thinking: {
|
|
22417
|
+
type: "object",
|
|
22418
|
+
description: "Spoken when no sentence of the reply was spoken afterMs after the model call started. At most once per turn.",
|
|
22419
|
+
additionalProperties: false,
|
|
22420
|
+
properties: {
|
|
22421
|
+
phrases: {
|
|
22422
|
+
type: "array",
|
|
22423
|
+
description: "Phrases to pick from at random, never the same as the previous filler of the session. Empty or absent turns this situation off.",
|
|
22424
|
+
maxItems: 20,
|
|
22425
|
+
items: { type: "string", minLength: 1, maxLength: 60 }
|
|
22426
|
+
},
|
|
22427
|
+
afterMs: {
|
|
22428
|
+
type: "integer",
|
|
22429
|
+
description: "Wait for the first sentence of the reply, in milliseconds.",
|
|
22430
|
+
minimum: 300,
|
|
22431
|
+
maximum: 1e4,
|
|
22432
|
+
default: 1500
|
|
22433
|
+
}
|
|
22434
|
+
}
|
|
22435
|
+
},
|
|
22436
|
+
toolCall: {
|
|
22437
|
+
type: "object",
|
|
22438
|
+
description: "Spoken right when the model requests a tool call, only if nothing was spoken in the turn yet. At most once per turn.",
|
|
22439
|
+
additionalProperties: false,
|
|
22440
|
+
properties: {
|
|
22441
|
+
phrases: {
|
|
22442
|
+
type: "array",
|
|
22443
|
+
description: "Phrases to pick from at random, never the same as the previous filler of the session. Empty or absent turns this situation off.",
|
|
22444
|
+
maxItems: 20,
|
|
22445
|
+
items: { type: "string", minLength: 1, maxLength: 120 }
|
|
22446
|
+
}
|
|
22447
|
+
}
|
|
22448
|
+
},
|
|
22449
|
+
toolWait: {
|
|
22450
|
+
type: "object",
|
|
22451
|
+
description: "Spoken when a tool round is still running afterMs after it started. At most once per tool round, twice per turn.",
|
|
22452
|
+
additionalProperties: false,
|
|
22453
|
+
properties: {
|
|
22454
|
+
phrases: {
|
|
22455
|
+
type: "array",
|
|
22456
|
+
description: "Phrases to pick from at random, never the same as the previous filler of the session. Empty or absent turns this situation off.",
|
|
22457
|
+
maxItems: 20,
|
|
22458
|
+
items: { type: "string", minLength: 1, maxLength: 120 }
|
|
22459
|
+
},
|
|
22460
|
+
afterMs: {
|
|
22461
|
+
type: "integer",
|
|
22462
|
+
description: "How long a tool round runs before the filler, in milliseconds.",
|
|
22463
|
+
minimum: 1e3,
|
|
22464
|
+
maximum: 3e4,
|
|
22465
|
+
default: 4e3
|
|
22466
|
+
}
|
|
22467
|
+
}
|
|
22468
|
+
},
|
|
22469
|
+
interruptible: {
|
|
22470
|
+
type: "boolean",
|
|
22471
|
+
description: "Whether barge-in may cut a filler.",
|
|
22472
|
+
default: true
|
|
22473
|
+
}
|
|
22474
|
+
}
|
|
22475
|
+
},
|
|
22476
|
+
speech: {
|
|
22477
|
+
type: "object",
|
|
22478
|
+
description: "How the reply is spoken.",
|
|
22479
|
+
additionalProperties: false,
|
|
22480
|
+
properties: {
|
|
22481
|
+
coalesceMs: {
|
|
22482
|
+
type: "integer",
|
|
22483
|
+
description: "Sentences that complete within this window are spoken as one utterance, so a reply that arrives at once has no gap between sentences. 0 speaks every sentence on its own.",
|
|
22484
|
+
minimum: 0,
|
|
22485
|
+
maximum: 1e3,
|
|
22486
|
+
default: 150
|
|
22487
|
+
}
|
|
22488
|
+
}
|
|
22489
|
+
},
|
|
22327
22490
|
toolSources: {
|
|
22328
22491
|
type: "array",
|
|
22329
22492
|
maxItems: MAX_SOURCES,
|
|
@@ -22572,6 +22735,10 @@ var SentenceSplitter = class {
|
|
|
22572
22735
|
// dist/llm/agent/create-llm-agent.js
|
|
22573
22736
|
var D = LLM_AGENT_CONFIG_DEFAULTS;
|
|
22574
22737
|
var CANCEL_SETTLE_MS = 2e3;
|
|
22738
|
+
var MAX_FILLERS_PER_TURN = 3;
|
|
22739
|
+
var MAX_TOOL_WAIT_FILLERS = 2;
|
|
22740
|
+
var TOOL_CALL_GAP_MS = 2e3;
|
|
22741
|
+
var COALESCE_MAX_CHARS = 400;
|
|
22575
22742
|
function configError(message, code) {
|
|
22576
22743
|
const err = new Error(message);
|
|
22577
22744
|
err.code = code;
|
|
@@ -22607,6 +22774,7 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
|
|
|
22607
22774
|
}
|
|
22608
22775
|
const hooks2 = opts.hooks ?? {};
|
|
22609
22776
|
const now = opts.now ?? Date.now;
|
|
22777
|
+
const random2 = opts.random ?? Math.random;
|
|
22610
22778
|
const getEnv = opts.env ?? (() => process.env);
|
|
22611
22779
|
const makeSource = opts.sourceFactory ?? ((o) => new McpToolSource(o));
|
|
22612
22780
|
const maxRounds = config2.tools?.maxRounds ?? D.toolMaxRounds;
|
|
@@ -22618,6 +22786,15 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
|
|
|
22618
22786
|
const useNote = config2.history?.interruptionNote ?? D.interruptionNote;
|
|
22619
22787
|
const historyTurns = config2.history?.turns ?? D.historyTurns;
|
|
22620
22788
|
const serviceWaitMs = config2.serviceWaitMs ?? D.serviceWaitMs;
|
|
22789
|
+
const fillerCfg = config2.fillers;
|
|
22790
|
+
const thinkingPhrases = fillerCfg?.thinking?.phrases ?? [];
|
|
22791
|
+
const toolCallPhrases = fillerCfg?.toolCall?.phrases ?? [];
|
|
22792
|
+
const toolWaitPhrases = fillerCfg?.toolWait?.phrases ?? [];
|
|
22793
|
+
const thinkingAfterMs = fillerCfg?.thinking?.afterMs ?? D.thinkingAfterMs;
|
|
22794
|
+
const toolWaitAfterMs = fillerCfg?.toolWait?.afterMs ?? D.toolWaitAfterMs;
|
|
22795
|
+
const fillersInterruptible = fillerCfg?.interruptible ?? D.fillersInterruptible;
|
|
22796
|
+
const coalesceMs = config2.speech?.coalesceMs ?? D.speechCoalesceMs;
|
|
22797
|
+
const legacyToolFiller = toolCallPhrases.length === 0 && toolWaitPhrases.length === 0 ? config2.tools?.filler : void 0;
|
|
22621
22798
|
let provider = opts.provider;
|
|
22622
22799
|
let registry2;
|
|
22623
22800
|
let serviceSource;
|
|
@@ -22641,11 +22818,9 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
|
|
|
22641
22818
|
});
|
|
22642
22819
|
}
|
|
22643
22820
|
function deliver(s, t, text, interruptible = true) {
|
|
22821
|
+
flushSpeech(s, t);
|
|
22644
22822
|
t.spoken.push(text);
|
|
22645
|
-
|
|
22646
|
-
t.spokeFirst = true;
|
|
22647
|
-
setAgentState(s.sessionId, "speaking");
|
|
22648
|
-
}
|
|
22823
|
+
markReplyStarted(s, t);
|
|
22649
22824
|
if (t.source === "chat") {
|
|
22650
22825
|
sendToClient(s.sessionId, {
|
|
22651
22826
|
type: "assistant_delta",
|
|
@@ -22669,6 +22844,128 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
|
|
|
22669
22844
|
trackAnnouncement(s, announce(s.sessionId, text, { turnId }).done);
|
|
22670
22845
|
}
|
|
22671
22846
|
}
|
|
22847
|
+
function clearFillerTimer(t, kind) {
|
|
22848
|
+
for (const [k, timer] of t.fillerTimers) {
|
|
22849
|
+
if (kind && k !== kind)
|
|
22850
|
+
continue;
|
|
22851
|
+
clearTimeout(timer);
|
|
22852
|
+
t.fillerTimers.delete(k);
|
|
22853
|
+
}
|
|
22854
|
+
}
|
|
22855
|
+
function phrasesFor(kind) {
|
|
22856
|
+
return kind === "thinking" ? thinkingPhrases : kind === "toolCall" ? toolCallPhrases : toolWaitPhrases;
|
|
22857
|
+
}
|
|
22858
|
+
function pickFiller(s, kind) {
|
|
22859
|
+
const all = phrasesFor(kind);
|
|
22860
|
+
const pool = all.length > 1 ? all.filter((p) => p !== s.lastFillerPhrase) : all;
|
|
22861
|
+
const i = Math.min(pool.length - 1, Math.floor(random2() * pool.length));
|
|
22862
|
+
return pool[i];
|
|
22863
|
+
}
|
|
22864
|
+
function tryFiller(s, t, kind, afterMs) {
|
|
22865
|
+
if (t.controller.signal.aborted || s.ended)
|
|
22866
|
+
return void 0;
|
|
22867
|
+
if (t.source === "chat" && !speakChat)
|
|
22868
|
+
return void 0;
|
|
22869
|
+
if (phrasesFor(kind).length === 0)
|
|
22870
|
+
return void 0;
|
|
22871
|
+
if (t.fillersSpoken >= MAX_FILLERS_PER_TURN)
|
|
22872
|
+
return void 0;
|
|
22873
|
+
if (kind === "thinking" && (t.thinkingSpoken || t.spokeFirst)) {
|
|
22874
|
+
return void 0;
|
|
22875
|
+
}
|
|
22876
|
+
if (kind === "toolCall" && (t.toolCallSpoken || t.spokeFirst)) {
|
|
22877
|
+
return void 0;
|
|
22878
|
+
}
|
|
22879
|
+
if (kind === "toolWait" && t.toolWaitSpoken >= MAX_TOOL_WAIT_FILLERS) {
|
|
22880
|
+
return void 0;
|
|
22881
|
+
}
|
|
22882
|
+
if (t.lastFillerAt !== void 0 && !t.replySinceFiller) {
|
|
22883
|
+
const gap = kind === "toolCall" ? TOOL_CALL_GAP_MS : afterMs;
|
|
22884
|
+
const rest = gap - (now() - t.lastFillerAt);
|
|
22885
|
+
if (rest > 0)
|
|
22886
|
+
return kind === "toolCall" ? void 0 : { wait: rest };
|
|
22887
|
+
}
|
|
22888
|
+
const text = pickFiller(s, kind);
|
|
22889
|
+
s.lastFillerPhrase = text;
|
|
22890
|
+
t.fillersSpoken += 1;
|
|
22891
|
+
t.lastFillerAt = now();
|
|
22892
|
+
t.replySinceFiller = false;
|
|
22893
|
+
if (kind === "thinking")
|
|
22894
|
+
t.thinkingSpoken = true;
|
|
22895
|
+
if (kind === "toolCall")
|
|
22896
|
+
t.toolCallSpoken = true;
|
|
22897
|
+
if (kind === "toolWait")
|
|
22898
|
+
t.toolWaitSpoken += 1;
|
|
22899
|
+
speakAnnouncement(s, t.turnId, text, fillersInterruptible);
|
|
22900
|
+
return void 0;
|
|
22901
|
+
}
|
|
22902
|
+
function armFiller(s, t, kind, delayMs, afterMs) {
|
|
22903
|
+
if (phrasesFor(kind).length === 0 || s.ended)
|
|
22904
|
+
return;
|
|
22905
|
+
clearFillerTimer(t, kind);
|
|
22906
|
+
const timer = setTimeout(() => {
|
|
22907
|
+
t.fillerTimers.delete(kind);
|
|
22908
|
+
const r = tryFiller(s, t, kind, afterMs);
|
|
22909
|
+
if (r)
|
|
22910
|
+
armFiller(s, t, kind, r.wait, afterMs);
|
|
22911
|
+
}, delayMs);
|
|
22912
|
+
t.fillerTimers.set(kind, timer);
|
|
22913
|
+
}
|
|
22914
|
+
function dropPending(t) {
|
|
22915
|
+
if (t.coalesceTimer)
|
|
22916
|
+
clearTimeout(t.coalesceTimer);
|
|
22917
|
+
t.coalesceTimer = void 0;
|
|
22918
|
+
t.pending = [];
|
|
22919
|
+
t.pendingChars = 0;
|
|
22920
|
+
}
|
|
22921
|
+
function flushSpeech(s, t) {
|
|
22922
|
+
if (t.coalesceTimer)
|
|
22923
|
+
clearTimeout(t.coalesceTimer);
|
|
22924
|
+
t.coalesceTimer = void 0;
|
|
22925
|
+
if (t.pending.length === 0)
|
|
22926
|
+
return;
|
|
22927
|
+
const text = t.pending.join(" ");
|
|
22928
|
+
t.pending = [];
|
|
22929
|
+
t.pendingChars = 0;
|
|
22930
|
+
if (t.controller.signal.aborted || s.ended)
|
|
22931
|
+
return;
|
|
22932
|
+
speak(s.sessionId, text, { turnId: t.turnId });
|
|
22933
|
+
}
|
|
22934
|
+
function deliverReply(s, t, text) {
|
|
22935
|
+
if (coalesceMs <= 0) {
|
|
22936
|
+
deliver(s, t, text);
|
|
22937
|
+
return;
|
|
22938
|
+
}
|
|
22939
|
+
markReplyStarted(s, t);
|
|
22940
|
+
t.spoken.push(text);
|
|
22941
|
+
if (t.source === "chat") {
|
|
22942
|
+
sendToClient(s.sessionId, {
|
|
22943
|
+
type: "assistant_delta",
|
|
22944
|
+
turnId: t.turnId,
|
|
22945
|
+
text
|
|
22946
|
+
});
|
|
22947
|
+
}
|
|
22948
|
+
if (t.source !== "voice" && !speakChat)
|
|
22949
|
+
return;
|
|
22950
|
+
t.pending.push(text);
|
|
22951
|
+
t.pendingChars += text.length;
|
|
22952
|
+
if (t.pendingChars >= COALESCE_MAX_CHARS) {
|
|
22953
|
+
flushSpeech(s, t);
|
|
22954
|
+
} else if (!t.coalesceTimer) {
|
|
22955
|
+
t.coalesceTimer = setTimeout(() => {
|
|
22956
|
+
t.coalesceTimer = void 0;
|
|
22957
|
+
flushSpeech(s, t);
|
|
22958
|
+
}, coalesceMs);
|
|
22959
|
+
}
|
|
22960
|
+
}
|
|
22961
|
+
function markReplyStarted(s, t) {
|
|
22962
|
+
t.replySinceFiller = true;
|
|
22963
|
+
if (!t.spokeFirst) {
|
|
22964
|
+
t.spokeFirst = true;
|
|
22965
|
+
clearFillerTimer(t, "thinking");
|
|
22966
|
+
setAgentState(s.sessionId, "speaking");
|
|
22967
|
+
}
|
|
22968
|
+
}
|
|
22672
22969
|
function buildRegistry(env) {
|
|
22673
22970
|
const reg = new ToolRegistry({
|
|
22674
22971
|
log: (level, message, fields) => agentLog(level, message, fields ?? {})
|
|
@@ -22804,7 +23101,7 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
|
|
|
22804
23101
|
if (t.controller.signal.aborted)
|
|
22805
23102
|
return;
|
|
22806
23103
|
t.roundText += `${t.roundText ? " " : ""}${out}`;
|
|
22807
|
-
|
|
23104
|
+
deliverReply(s, t, out);
|
|
22808
23105
|
}
|
|
22809
23106
|
async function runRound(s, t, ctx) {
|
|
22810
23107
|
const signal = t.controller.signal;
|
|
@@ -22821,6 +23118,9 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
|
|
|
22821
23118
|
];
|
|
22822
23119
|
}
|
|
22823
23120
|
t.llmCalls += 1;
|
|
23121
|
+
if (t.llmCalls === 1 && !t.spokeFirst) {
|
|
23122
|
+
armFiller(s, t, "thinking", thinkingAfterMs, thinkingAfterMs);
|
|
23123
|
+
}
|
|
22824
23124
|
t.roundOpen = true;
|
|
22825
23125
|
t.roundText = "";
|
|
22826
23126
|
const splitter = new SentenceSplitter();
|
|
@@ -22855,6 +23155,7 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
|
|
|
22855
23155
|
for (const sentence of splitter.end()) {
|
|
22856
23156
|
await emitSentence(s, t, ctx, sentence);
|
|
22857
23157
|
}
|
|
23158
|
+
flushSpeech(s, t);
|
|
22858
23159
|
if (done.usage) {
|
|
22859
23160
|
if (done.usage.inputTokens !== void 0) {
|
|
22860
23161
|
t.inputTokens = (t.inputTokens ?? 0) + done.usage.inputTokens;
|
|
@@ -22939,14 +23240,17 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
|
|
|
22939
23240
|
setAgentState(s.sessionId, "tool_call", {
|
|
22940
23241
|
detail: calls.map((c) => c.name).join(",").slice(0, 64)
|
|
22941
23242
|
});
|
|
22942
|
-
|
|
22943
|
-
|
|
23243
|
+
clearFillerTimer(t, "thinking");
|
|
23244
|
+
tryFiller(s, t, "toolCall", 0);
|
|
23245
|
+
armFiller(s, t, "toolWait", toolWaitAfterMs, toolWaitAfterMs);
|
|
23246
|
+
const fillerLegacy = legacyToolFiller;
|
|
23247
|
+
if (fillerLegacy && !t.fillerSpoken) {
|
|
22944
23248
|
filler = setTimeout(() => {
|
|
22945
23249
|
if (t.fillerSpoken || signal.aborted)
|
|
22946
23250
|
return;
|
|
22947
23251
|
t.fillerSpoken = true;
|
|
22948
|
-
speakAnnouncement(s, t.turnId,
|
|
22949
|
-
},
|
|
23252
|
+
speakAnnouncement(s, t.turnId, fillerLegacy.text, fillerLegacy.interruptible ?? D.fillerInterruptible);
|
|
23253
|
+
}, fillerLegacy.afterMs ?? D.fillerAfterMs);
|
|
22950
23254
|
}
|
|
22951
23255
|
let results;
|
|
22952
23256
|
try {
|
|
@@ -22955,6 +23259,7 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
|
|
|
22955
23259
|
if (filler)
|
|
22956
23260
|
clearTimeout(filler);
|
|
22957
23261
|
filler = void 0;
|
|
23262
|
+
clearFillerTimer(t);
|
|
22958
23263
|
}
|
|
22959
23264
|
s.history.addToolResults(results, { turnId: t.turnId });
|
|
22960
23265
|
if (signal.aborted)
|
|
@@ -22983,6 +23288,9 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
|
|
|
22983
23288
|
} finally {
|
|
22984
23289
|
if (filler)
|
|
22985
23290
|
clearTimeout(filler);
|
|
23291
|
+
clearFillerTimer(t);
|
|
23292
|
+
if (signal.aborted)
|
|
23293
|
+
dropPending(t);
|
|
22986
23294
|
}
|
|
22987
23295
|
}
|
|
22988
23296
|
async function execute(s, t, ctx) {
|
|
@@ -23054,6 +23362,14 @@ ${t.inputText}` : t.inputText, {
|
|
|
23054
23362
|
roundText: "",
|
|
23055
23363
|
spokeFirst: false,
|
|
23056
23364
|
fillerSpoken: false,
|
|
23365
|
+
fillersSpoken: 0,
|
|
23366
|
+
thinkingSpoken: false,
|
|
23367
|
+
toolCallSpoken: false,
|
|
23368
|
+
toolWaitSpoken: 0,
|
|
23369
|
+
replySinceFiller: false,
|
|
23370
|
+
fillerTimers: /* @__PURE__ */ new Map(),
|
|
23371
|
+
pending: [],
|
|
23372
|
+
pendingChars: 0,
|
|
23057
23373
|
fallbackSpoken: false,
|
|
23058
23374
|
status: "completed"
|
|
23059
23375
|
};
|
|
@@ -23130,6 +23446,8 @@ ${t.inputText}` : t.inputText, {
|
|
|
23130
23446
|
cancelSpeech(s.sessionId, { turnId: active.turnId });
|
|
23131
23447
|
active.state.abortStatus = "cancelled";
|
|
23132
23448
|
active.state.controller.abort();
|
|
23449
|
+
clearFillerTimer(active.state);
|
|
23450
|
+
dropPending(active.state);
|
|
23133
23451
|
let timer;
|
|
23134
23452
|
await Promise.race([
|
|
23135
23453
|
active.promise,
|
|
@@ -23156,6 +23474,9 @@ ${t.inputText}` : t.inputText, {
|
|
|
23156
23474
|
}
|
|
23157
23475
|
return {
|
|
23158
23476
|
async onAgentStart() {
|
|
23477
|
+
for (const w of validated.warnings) {
|
|
23478
|
+
agentLog("warn", `config warning: ${w.path} ${w.message}`);
|
|
23479
|
+
}
|
|
23159
23480
|
const env = getEnv();
|
|
23160
23481
|
const apiKey = env[config2.apiKeySecret];
|
|
23161
23482
|
if (!nonEmpty(apiKey)) {
|
|
@@ -23211,6 +23532,8 @@ ${t.inputText}` : t.inputText, {
|
|
|
23211
23532
|
const active = s.active;
|
|
23212
23533
|
if (active && active.turnId === ctx.turnId) {
|
|
23213
23534
|
const t = active.state;
|
|
23535
|
+
clearFillerTimer(t);
|
|
23536
|
+
dropPending(t);
|
|
23214
23537
|
if (t.roundOpen) {
|
|
23215
23538
|
t.playedOverride = ctx.playedText;
|
|
23216
23539
|
if (note)
|
|
@@ -23235,6 +23558,8 @@ ${t.inputText}` : t.inputText, {
|
|
|
23235
23558
|
if (s.active) {
|
|
23236
23559
|
s.active.state.abortStatus = "cancelled";
|
|
23237
23560
|
s.active.state.controller.abort();
|
|
23561
|
+
clearFillerTimer(s.active.state);
|
|
23562
|
+
dropPending(s.active.state);
|
|
23238
23563
|
}
|
|
23239
23564
|
sessions.delete(ctx.sessionId);
|
|
23240
23565
|
}
|
|
@@ -46693,17 +47018,33 @@ var voicethere_llm_default = {
|
|
|
46693
47018
|
},
|
|
46694
47019
|
bargeIn: { mode: "project" },
|
|
46695
47020
|
history: { turns: 20, interruptionNote: true },
|
|
47021
|
+
fillers: {
|
|
47022
|
+
thinking: {
|
|
47023
|
+
phrases: ["Hmm.", "Okay.", "Mm-hm.", "Right."],
|
|
47024
|
+
afterMs: 1500
|
|
47025
|
+
},
|
|
47026
|
+
toolCall: {
|
|
47027
|
+
phrases: [
|
|
47028
|
+
"Let me check that for you.",
|
|
47029
|
+
"One moment, I'll look that up."
|
|
47030
|
+
]
|
|
47031
|
+
},
|
|
47032
|
+
toolWait: {
|
|
47033
|
+
phrases: ["Still checking, one moment.", "Almost there."],
|
|
47034
|
+
afterMs: 4e3
|
|
47035
|
+
},
|
|
47036
|
+
interruptible: true
|
|
47037
|
+
},
|
|
46696
47038
|
tools: {
|
|
46697
47039
|
maxRounds: 5,
|
|
46698
|
-
timeoutMs: 15e3
|
|
46699
|
-
filler: { text: "One moment." }
|
|
47040
|
+
timeoutMs: 15e3
|
|
46700
47041
|
},
|
|
46701
47042
|
toolSources: [],
|
|
46702
47043
|
interruptPolicy: "cancel"
|
|
46703
47044
|
};
|
|
46704
47045
|
|
|
46705
47046
|
// templates/llm-agent/prompt.md
|
|
46706
|
-
var prompt_default = 'You are a helpful voice assistant for your company. People talk to you by voice, so everything you say is read aloud.\n\nAnswer in short, spoken sentences. Two or three sentences are usually enough. Do not use markdown, bullet lists, headings, emoji or special characters, because they sound wrong when spoken.\n\nAsk one question at a time and wait for the answer before asking the next one.\n\nIf you do not know something, say so plainly instead of guessing. Offer to help with what you can do.\n\nUse your tools when they help. For example, call get_current_time when someone asks what time or date it is, and pass the time zone if they name one.\n\nKeep numbers and dates easy to say. Say "March third" instead of "03/03", and round long numbers when the exact value does not matter.\n';
|
|
47047
|
+
var prompt_default = 'You are a helpful voice assistant for your company. People talk to you by voice, so everything you say is read aloud.\n\nAnswer in short, spoken sentences. Two or three sentences are usually enough. Do not use markdown, bullet lists, headings, emoji or special characters, because they sound wrong when spoken.\n\nAsk one question at a time and wait for the answer before asking the next one.\n\nIf you do not know something, say so plainly instead of guessing. Offer to help with what you can do.\n\nUse your tools when they help. For example, call get_current_time when someone asks what time or date it is, and pass the time zone if they name one.\n\nKeep numbers and dates easy to say. Say "March third" instead of "03/03", and round long numbers when the exact value does not matter.\n\n## Voice call\n\nYou are on a live phone call. Always answer right away; never leave the caller in silence.\n\nBefore you call a tool, say one short sentence that you are looking it up (for example "Let me check that for you."), then call the tool.\n\nKeep sentences short; one idea per sentence. No lists, no markdown, no emojis; say numbers and dates the way a person would.\n\nIf you cannot help, say so in one sentence and offer what you can do.\n';
|
|
46707
47048
|
|
|
46708
47049
|
// templates/llm-agent/tools.ts
|
|
46709
47050
|
var getCurrentTime = defineTool({
|