@voicethere/agent 0.24.0 → 0.25.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 +2 -0
- package/dist/agent.js +11 -2
- package/dist/llm/agent/create-llm-agent.d.ts.map +1 -1
- package/dist/llm/agent/create-llm-agent.js +18 -5
- package/dist/llm/agent/create-llm-agent.js.map +1 -1
- package/dist/protocol.d.ts +4 -0
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js.map +1 -1
- package/dist/runtime.d.ts +4 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +10 -0
- package/dist/runtime.js.map +1 -1
- package/dist/templates/echo/agent.js +12 -2
- package/dist/templates/language-switch/agent.js +12 -2
- package/dist/templates/llm-agent/agent.js +23 -7
- package/dist/templates/llm-docs-rag/agent.js +23 -7
- package/dist/templates/llm-mcp-service/agent.js +23 -7
- package/dist/templates/positional-tts/agent.js +12 -2
- package/dist/templates/recording-consent/agent.js +12 -2
- package/dist/templates/spatial-showcase/agent.js +12 -2
- package/dist/templates/voice-showcase/agent.js +12 -2
- package/dist/templates/voice-starter/agent.js +12 -2
- package/dist/templates/webhooks/agent.js +12 -2
- package/eject/llm/loop.ts +24 -4
- package/package.json +1 -1
- package/templates/llm-agent/README.md +4 -2
|
@@ -1096,6 +1096,14 @@ function buildIdleEnv(sessionId) {
|
|
|
1096
1096
|
...process.env.IDLE_TIMEOUT_SEC ? { IDLE_TIMEOUT_SEC: process.env.IDLE_TIMEOUT_SEC } : {}
|
|
1097
1097
|
};
|
|
1098
1098
|
}
|
|
1099
|
+
function speakKindFields(options) {
|
|
1100
|
+
if (options?.kind !== "filler")
|
|
1101
|
+
return {};
|
|
1102
|
+
return {
|
|
1103
|
+
kind: "filler",
|
|
1104
|
+
...options.fillerKind ? { fillerKind: options.fillerKind } : {}
|
|
1105
|
+
};
|
|
1106
|
+
}
|
|
1099
1107
|
function speakControlAvailableFor(sessionId) {
|
|
1100
1108
|
return speakControlAvailableBySessionId.get(sessionId) ?? false;
|
|
1101
1109
|
}
|
|
@@ -1133,7 +1141,8 @@ function speak(sessionId, text, options) {
|
|
|
1133
1141
|
type: "speak",
|
|
1134
1142
|
sessionId,
|
|
1135
1143
|
text,
|
|
1136
|
-
...options?.interruptible === false ? { interruptible: false } : {}
|
|
1144
|
+
...options?.interruptible === false ? { interruptible: false } : {},
|
|
1145
|
+
...speakKindFields(options)
|
|
1137
1146
|
});
|
|
1138
1147
|
warnSpeakControlUnavailable(sessionId);
|
|
1139
1148
|
return handle({ requestId, status: "unsupported", playedMs: 0 });
|
|
@@ -1165,7 +1174,8 @@ function speak(sessionId, text, options) {
|
|
|
1165
1174
|
requestId,
|
|
1166
1175
|
...options?.interruptible === false ? { interruptible: false } : {},
|
|
1167
1176
|
...turnId ? { turnId } : {},
|
|
1168
|
-
...inReplyTo ? { inReplyTo } : {}
|
|
1177
|
+
...inReplyTo ? { inReplyTo } : {},
|
|
1178
|
+
...speakKindFields(options)
|
|
1169
1179
|
});
|
|
1170
1180
|
return {
|
|
1171
1181
|
requestId,
|
|
@@ -1081,6 +1081,14 @@ function buildIdleEnv(sessionId) {
|
|
|
1081
1081
|
...process.env.IDLE_TIMEOUT_SEC ? { IDLE_TIMEOUT_SEC: process.env.IDLE_TIMEOUT_SEC } : {}
|
|
1082
1082
|
};
|
|
1083
1083
|
}
|
|
1084
|
+
function speakKindFields(options) {
|
|
1085
|
+
if (options?.kind !== "filler")
|
|
1086
|
+
return {};
|
|
1087
|
+
return {
|
|
1088
|
+
kind: "filler",
|
|
1089
|
+
...options.fillerKind ? { fillerKind: options.fillerKind } : {}
|
|
1090
|
+
};
|
|
1091
|
+
}
|
|
1084
1092
|
function speakControlAvailableFor(sessionId) {
|
|
1085
1093
|
return speakControlAvailableBySessionId.get(sessionId) ?? false;
|
|
1086
1094
|
}
|
|
@@ -1118,7 +1126,8 @@ function speak(sessionId, text, options) {
|
|
|
1118
1126
|
type: "speak",
|
|
1119
1127
|
sessionId,
|
|
1120
1128
|
text,
|
|
1121
|
-
...options?.interruptible === false ? { interruptible: false } : {}
|
|
1129
|
+
...options?.interruptible === false ? { interruptible: false } : {},
|
|
1130
|
+
...speakKindFields(options)
|
|
1122
1131
|
});
|
|
1123
1132
|
warnSpeakControlUnavailable(sessionId);
|
|
1124
1133
|
return handle({ requestId, status: "unsupported", playedMs: 0 });
|
|
@@ -1150,7 +1159,8 @@ function speak(sessionId, text, options) {
|
|
|
1150
1159
|
requestId,
|
|
1151
1160
|
...options?.interruptible === false ? { interruptible: false } : {},
|
|
1152
1161
|
...turnId ? { turnId } : {},
|
|
1153
|
-
...inReplyTo ? { inReplyTo } : {}
|
|
1162
|
+
...inReplyTo ? { inReplyTo } : {},
|
|
1163
|
+
...speakKindFields(options)
|
|
1154
1164
|
});
|
|
1155
1165
|
return {
|
|
1156
1166
|
requestId,
|
|
@@ -1111,6 +1111,14 @@ function buildIdleEnv(sessionId) {
|
|
|
1111
1111
|
...process.env.IDLE_TIMEOUT_SEC ? { IDLE_TIMEOUT_SEC: process.env.IDLE_TIMEOUT_SEC } : {}
|
|
1112
1112
|
};
|
|
1113
1113
|
}
|
|
1114
|
+
function speakKindFields(options) {
|
|
1115
|
+
if (options?.kind !== "filler")
|
|
1116
|
+
return {};
|
|
1117
|
+
return {
|
|
1118
|
+
kind: "filler",
|
|
1119
|
+
...options.fillerKind ? { fillerKind: options.fillerKind } : {}
|
|
1120
|
+
};
|
|
1121
|
+
}
|
|
1114
1122
|
function speakControlAvailableFor(sessionId) {
|
|
1115
1123
|
return speakControlAvailableBySessionId.get(sessionId) ?? false;
|
|
1116
1124
|
}
|
|
@@ -1148,7 +1156,8 @@ function speak(sessionId, text, options) {
|
|
|
1148
1156
|
type: "speak",
|
|
1149
1157
|
sessionId,
|
|
1150
1158
|
text,
|
|
1151
|
-
...options?.interruptible === false ? { interruptible: false } : {}
|
|
1159
|
+
...options?.interruptible === false ? { interruptible: false } : {},
|
|
1160
|
+
...speakKindFields(options)
|
|
1152
1161
|
});
|
|
1153
1162
|
warnSpeakControlUnavailable(sessionId);
|
|
1154
1163
|
return handle({ requestId, status: "unsupported", playedMs: 0 });
|
|
@@ -1180,7 +1189,8 @@ function speak(sessionId, text, options) {
|
|
|
1180
1189
|
requestId,
|
|
1181
1190
|
...options?.interruptible === false ? { interruptible: false } : {},
|
|
1182
1191
|
...turnId ? { turnId } : {},
|
|
1183
|
-
...inReplyTo ? { inReplyTo } : {}
|
|
1192
|
+
...inReplyTo ? { inReplyTo } : {},
|
|
1193
|
+
...speakKindFields(options)
|
|
1184
1194
|
});
|
|
1185
1195
|
return {
|
|
1186
1196
|
requestId,
|
|
@@ -1080,6 +1080,14 @@ function buildIdleEnv(sessionId) {
|
|
|
1080
1080
|
...process.env.IDLE_TIMEOUT_SEC ? { IDLE_TIMEOUT_SEC: process.env.IDLE_TIMEOUT_SEC } : {}
|
|
1081
1081
|
};
|
|
1082
1082
|
}
|
|
1083
|
+
function speakKindFields(options) {
|
|
1084
|
+
if (options?.kind !== "filler")
|
|
1085
|
+
return {};
|
|
1086
|
+
return {
|
|
1087
|
+
kind: "filler",
|
|
1088
|
+
...options.fillerKind ? { fillerKind: options.fillerKind } : {}
|
|
1089
|
+
};
|
|
1090
|
+
}
|
|
1083
1091
|
function speakControlAvailableFor(sessionId) {
|
|
1084
1092
|
return speakControlAvailableBySessionId.get(sessionId) ?? false;
|
|
1085
1093
|
}
|
|
@@ -1117,7 +1125,8 @@ function speak(sessionId, text, options) {
|
|
|
1117
1125
|
type: "speak",
|
|
1118
1126
|
sessionId,
|
|
1119
1127
|
text,
|
|
1120
|
-
...options?.interruptible === false ? { interruptible: false } : {}
|
|
1128
|
+
...options?.interruptible === false ? { interruptible: false } : {},
|
|
1129
|
+
...speakKindFields(options)
|
|
1121
1130
|
});
|
|
1122
1131
|
warnSpeakControlUnavailable(sessionId);
|
|
1123
1132
|
return handle({ requestId, status: "unsupported", playedMs: 0 });
|
|
@@ -1149,7 +1158,8 @@ function speak(sessionId, text, options) {
|
|
|
1149
1158
|
requestId,
|
|
1150
1159
|
...options?.interruptible === false ? { interruptible: false } : {},
|
|
1151
1160
|
...turnId ? { turnId } : {},
|
|
1152
|
-
...inReplyTo ? { inReplyTo } : {}
|
|
1161
|
+
...inReplyTo ? { inReplyTo } : {},
|
|
1162
|
+
...speakKindFields(options)
|
|
1153
1163
|
});
|
|
1154
1164
|
return {
|
|
1155
1165
|
requestId,
|
|
@@ -1080,6 +1080,14 @@ function buildIdleEnv(sessionId) {
|
|
|
1080
1080
|
...process.env.IDLE_TIMEOUT_SEC ? { IDLE_TIMEOUT_SEC: process.env.IDLE_TIMEOUT_SEC } : {}
|
|
1081
1081
|
};
|
|
1082
1082
|
}
|
|
1083
|
+
function speakKindFields(options) {
|
|
1084
|
+
if (options?.kind !== "filler")
|
|
1085
|
+
return {};
|
|
1086
|
+
return {
|
|
1087
|
+
kind: "filler",
|
|
1088
|
+
...options.fillerKind ? { fillerKind: options.fillerKind } : {}
|
|
1089
|
+
};
|
|
1090
|
+
}
|
|
1083
1091
|
function speakControlAvailableFor(sessionId) {
|
|
1084
1092
|
return speakControlAvailableBySessionId.get(sessionId) ?? false;
|
|
1085
1093
|
}
|
|
@@ -1117,7 +1125,8 @@ function speak(sessionId, text, options) {
|
|
|
1117
1125
|
type: "speak",
|
|
1118
1126
|
sessionId,
|
|
1119
1127
|
text,
|
|
1120
|
-
...options?.interruptible === false ? { interruptible: false } : {}
|
|
1128
|
+
...options?.interruptible === false ? { interruptible: false } : {},
|
|
1129
|
+
...speakKindFields(options)
|
|
1121
1130
|
});
|
|
1122
1131
|
warnSpeakControlUnavailable(sessionId);
|
|
1123
1132
|
return handle({ requestId, status: "unsupported", playedMs: 0 });
|
|
@@ -1149,7 +1158,8 @@ function speak(sessionId, text, options) {
|
|
|
1149
1158
|
requestId,
|
|
1150
1159
|
...options?.interruptible === false ? { interruptible: false } : {},
|
|
1151
1160
|
...turnId ? { turnId } : {},
|
|
1152
|
-
...inReplyTo ? { inReplyTo } : {}
|
|
1161
|
+
...inReplyTo ? { inReplyTo } : {},
|
|
1162
|
+
...speakKindFields(options)
|
|
1153
1163
|
});
|
|
1154
1164
|
return {
|
|
1155
1165
|
requestId,
|
|
@@ -1083,6 +1083,14 @@ function buildIdleEnv(sessionId) {
|
|
|
1083
1083
|
...process.env.IDLE_TIMEOUT_SEC ? { IDLE_TIMEOUT_SEC: process.env.IDLE_TIMEOUT_SEC } : {}
|
|
1084
1084
|
};
|
|
1085
1085
|
}
|
|
1086
|
+
function speakKindFields(options) {
|
|
1087
|
+
if (options?.kind !== "filler")
|
|
1088
|
+
return {};
|
|
1089
|
+
return {
|
|
1090
|
+
kind: "filler",
|
|
1091
|
+
...options.fillerKind ? { fillerKind: options.fillerKind } : {}
|
|
1092
|
+
};
|
|
1093
|
+
}
|
|
1086
1094
|
function speakControlAvailableFor(sessionId) {
|
|
1087
1095
|
return speakControlAvailableBySessionId.get(sessionId) ?? false;
|
|
1088
1096
|
}
|
|
@@ -1120,7 +1128,8 @@ function speak(sessionId, text, options) {
|
|
|
1120
1128
|
type: "speak",
|
|
1121
1129
|
sessionId,
|
|
1122
1130
|
text,
|
|
1123
|
-
...options?.interruptible === false ? { interruptible: false } : {}
|
|
1131
|
+
...options?.interruptible === false ? { interruptible: false } : {},
|
|
1132
|
+
...speakKindFields(options)
|
|
1124
1133
|
});
|
|
1125
1134
|
warnSpeakControlUnavailable(sessionId);
|
|
1126
1135
|
return handle({ requestId, status: "unsupported", playedMs: 0 });
|
|
@@ -1152,7 +1161,8 @@ function speak(sessionId, text, options) {
|
|
|
1152
1161
|
requestId,
|
|
1153
1162
|
...options?.interruptible === false ? { interruptible: false } : {},
|
|
1154
1163
|
...turnId ? { turnId } : {},
|
|
1155
|
-
...inReplyTo ? { inReplyTo } : {}
|
|
1164
|
+
...inReplyTo ? { inReplyTo } : {},
|
|
1165
|
+
...speakKindFields(options)
|
|
1156
1166
|
});
|
|
1157
1167
|
return {
|
|
1158
1168
|
requestId,
|
package/eject/llm/loop.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copied from @voicethere/agent 0.
|
|
1
|
+
// Copied from @voicethere/agent 0.25.0. Package updates no longer change this file.
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import {
|
|
4
4
|
type AgentHandlers,
|
|
@@ -448,16 +448,33 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
|
|
|
448
448
|
}
|
|
449
449
|
}
|
|
450
450
|
|
|
451
|
+
/**
|
|
452
|
+
* The one place where a filler reaches the client as text. Fillers are not
|
|
453
|
+
* reply text: never `assistant_delta`, never in `chat_reply`, never in history.
|
|
454
|
+
*/
|
|
455
|
+
function sendFillerMessage(
|
|
456
|
+
s: SessionState,
|
|
457
|
+
turnId: string,
|
|
458
|
+
text: string,
|
|
459
|
+
): void {
|
|
460
|
+
sendToClient(s.sessionId, { type: "assistant_filler", turnId, text });
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/** Speak options for a filler; replies carry no `kind`. */
|
|
451
464
|
function speakAnnouncement(
|
|
452
465
|
s: SessionState,
|
|
453
466
|
turnId: string,
|
|
454
467
|
text: string,
|
|
455
468
|
interruptible: boolean,
|
|
469
|
+
fillerKind?: FillerKind,
|
|
456
470
|
): SpeakHandle {
|
|
471
|
+
const opts = fillerKind
|
|
472
|
+
? { turnId, kind: "filler" as const, fillerKind }
|
|
473
|
+
: { turnId };
|
|
457
474
|
if (interruptible) {
|
|
458
|
-
return speak(s.sessionId, text,
|
|
475
|
+
return speak(s.sessionId, text, opts);
|
|
459
476
|
}
|
|
460
|
-
const h = announce(s.sessionId, text,
|
|
477
|
+
const h = announce(s.sessionId, text, opts);
|
|
461
478
|
trackAnnouncement(s, h.done);
|
|
462
479
|
return h;
|
|
463
480
|
}
|
|
@@ -540,7 +557,8 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
|
|
|
540
557
|
if (kind === "thinking") t.thinkingSpoken = true;
|
|
541
558
|
if (kind === "toolCall") t.toolCallSpoken = true;
|
|
542
559
|
if (kind === "toolWait") t.toolWaitSpoken += 1;
|
|
543
|
-
speakAnnouncement(s, t.turnId, text, fillersInterruptible);
|
|
560
|
+
speakAnnouncement(s, t.turnId, text, fillersInterruptible, kind);
|
|
561
|
+
sendFillerMessage(s, t.turnId, text);
|
|
544
562
|
return undefined;
|
|
545
563
|
}
|
|
546
564
|
|
|
@@ -1212,7 +1230,9 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
|
|
|
1212
1230
|
t.turnId,
|
|
1213
1231
|
fillerLegacy.text,
|
|
1214
1232
|
fillerLegacy.interruptible ?? D.fillerInterruptible,
|
|
1233
|
+
"toolWait",
|
|
1215
1234
|
);
|
|
1235
|
+
sendFillerMessage(s, t.turnId, fillerLegacy.text);
|
|
1216
1236
|
}, fillerLegacy.afterMs ?? D.fillerAfterMs);
|
|
1217
1237
|
}
|
|
1218
1238
|
let results: LlmToolResult[];
|
package/package.json
CHANGED
|
@@ -34,7 +34,9 @@ The `fillers` block in `voicethere.llm.json` lists short sentences the agent spe
|
|
|
34
34
|
- `toolWait`: a tool round is still running `afterMs` (1000 to 30000, default 4000) after it started. Once per tool round, twice per turn.
|
|
35
35
|
- At most 3 fillers per turn. Two fillers never play back to back unless the reply spoke in between or `afterMs` passed. Phrases are picked at random and never repeat the previous filler of the session. Each list takes up to 20 phrases.
|
|
36
36
|
- Callers can cut a filler by speaking (`interruptible`, default true). If the answer arrives while a filler plays, the answer follows it.
|
|
37
|
-
- Fillers are
|
|
37
|
+
- Fillers are not part of the conversation the model sees (`ConversationHistory`), so the model does not copy them, and they never appear in `assistant_delta`, `assistant_done` or `chat_reply` text.
|
|
38
|
+
- Each filler that is spoken also reaches the client once as `{ "type": "assistant_filler", "turnId", "text" }`, with the `turnId` of the turn it belongs to, so a chat UI can show it as its own line before the reply. A filler that is not spoken (typed chat with `speakChatReplies` off, a limit reached) sends nothing.
|
|
39
|
+
- The speak request for a filler carries `kind: "filler"` and `fillerKind` (`"thinking"`, `"toolCall"` or `"toolWait"`), so a runner can tag the stored utterance. Replies carry neither. Runners that predate the options ignore them.
|
|
38
40
|
- `tools.filler` (a single text) is deprecated. It still works when `toolCall` and `toolWait` have no phrases; otherwise `fillers` wins and a warning is logged.
|
|
39
41
|
|
|
40
42
|
## Speech coalescing
|
|
@@ -43,7 +45,7 @@ The `fillers` block in `voicethere.llm.json` lists short sentences the agent spe
|
|
|
43
45
|
|
|
44
46
|
## Client messages for voice replies
|
|
45
47
|
|
|
46
|
-
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`. Fillers are never
|
|
48
|
+
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`. Fillers are never part of this reply text; see `assistant_filler` below.
|
|
47
49
|
|
|
48
50
|
## Always search first
|
|
49
51
|
|