@voicethere/agent 0.35.3 → 0.36.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 +18 -14
- package/dist/agent.js +1 -39
- package/dist/build-bundle.d.ts.map +1 -1
- package/dist/build-bundle.js.map +1 -1
- package/dist/cli.js +2 -2
- package/dist/cli.js.map +1 -1
- package/dist/host/session-speak-controller.d.ts.map +1 -1
- package/dist/host/session-speak-controller.js +1 -0
- package/dist/host/session-speak-controller.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/llm/openai-provider.d.ts +7 -1
- package/dist/llm/openai-provider.d.ts.map +1 -1
- package/dist/llm/openai-provider.js +43 -37
- package/dist/llm/openai-provider.js.map +1 -1
- package/dist/protocol.d.ts +11 -5
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js.map +1 -1
- package/dist/runner-forwarded-events.d.ts +7 -0
- package/dist/runner-forwarded-events.d.ts.map +1 -0
- package/dist/runner-forwarded-events.js +19 -0
- package/dist/runner-forwarded-events.js.map +1 -0
- package/dist/runtime.d.ts +9 -4
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js.map +1 -1
- package/dist/templates/flow-agent/agent.js +29 -25
- package/dist/templates/llm-agent/agent.js +29 -25
- package/dist/templates/llm-board/agent.js +29 -25
- package/dist/templates/llm-docs-rag/agent.js +29 -25
- package/dist/templates/llm-language-switch/agent.js +29 -25
- package/dist/templates/llm-language-tutor/agent.js +30 -26
- package/dist/templates/llm-mcp-service/agent.js +29 -25
- package/dist/templates/llm-store-support/agent.js +30 -26
- package/dist/templates/llm-support-sticky-user/agent.js +29 -25
- package/dist/templates/voice-starter/agent.js +2 -52
- package/dist/verify/run-verify-start.d.ts.map +1 -1
- package/dist/verify/run-verify-start.js +1 -2
- package/dist/verify/run-verify-start.js.map +1 -1
- package/eject/llm/loop.ts +1 -1
- package/package.json +1 -1
- package/templates/llm-language-tutor/prompt.md +1 -1
- package/templates/llm-store-support/prompt.md +1 -1
- package/templates/voice-starter/agent.ts +6 -67
|
@@ -1508,46 +1508,7 @@ function handleSpeechEvent(sessionId, speech) {
|
|
|
1508
1508
|
return;
|
|
1509
1509
|
}
|
|
1510
1510
|
switch (speech.type) {
|
|
1511
|
-
// --- User turn
|
|
1512
|
-
case "user_speaking_start":
|
|
1513
|
-
state.userSpeaking = true;
|
|
1514
|
-
agentLog("info", `[${sessionId}] user_speaking_start`);
|
|
1515
|
-
break;
|
|
1516
|
-
case "user_speaking_end":
|
|
1517
|
-
state.userSpeaking = false;
|
|
1518
|
-
agentLog("info", `[${sessionId}] user_speaking_end`);
|
|
1519
|
-
break;
|
|
1520
|
-
case "vad_triggered":
|
|
1521
|
-
agentLog(
|
|
1522
|
-
"info",
|
|
1523
|
-
`[${sessionId}] vad_triggered \u2014 STT listen window opened`
|
|
1524
|
-
);
|
|
1525
|
-
break;
|
|
1526
|
-
case "stt_stream_start":
|
|
1527
|
-
agentLog("info", `[${sessionId}] stt_stream_start`);
|
|
1528
|
-
break;
|
|
1529
|
-
case "stt_stream_end":
|
|
1530
|
-
agentLog("info", `[${sessionId}] stt_stream_end`);
|
|
1531
|
-
break;
|
|
1532
|
-
case "user_stt_start":
|
|
1533
|
-
state.sttActive = true;
|
|
1534
|
-
state.lastPartial = "";
|
|
1535
|
-
agentLog("info", `[${sessionId}] user_stt_start`);
|
|
1536
|
-
break;
|
|
1537
|
-
case "user_stt_end":
|
|
1538
|
-
state.sttActive = false;
|
|
1539
|
-
agentLog("info", `[${sessionId}] user_stt_end`);
|
|
1540
|
-
break;
|
|
1541
|
-
case "user_stt_not_found":
|
|
1542
|
-
agentLog(
|
|
1543
|
-
"info",
|
|
1544
|
-
`[${sessionId}] user_stt_not_found \u2014 no speech recognized in listen window`
|
|
1545
|
-
);
|
|
1546
|
-
break;
|
|
1547
|
-
case "user_speech_partial":
|
|
1548
|
-
state.lastPartial = speech.text ?? "";
|
|
1549
|
-
agentLog("info", `[${sessionId}] user_speech_partial ${detail}`);
|
|
1550
|
-
break;
|
|
1511
|
+
// --- User turn ---
|
|
1551
1512
|
case "user_speech_final":
|
|
1552
1513
|
state.lastPartial = "";
|
|
1553
1514
|
agentLog("info", `[${sessionId}] user_speech_final ${detail}`);
|
|
@@ -1567,19 +1528,8 @@ function handleSpeechEvent(sessionId, speech) {
|
|
|
1567
1528
|
`[${sessionId}] barge_in \u2014 user interrupted agent playback`
|
|
1568
1529
|
);
|
|
1569
1530
|
break;
|
|
1570
|
-
|
|
1571
|
-
agentLog(
|
|
1572
|
-
"error",
|
|
1573
|
-
`[${sessionId}] pipeline error: ${speech.error ?? "unknown"}`
|
|
1574
|
-
);
|
|
1531
|
+
default:
|
|
1575
1532
|
break;
|
|
1576
|
-
default: {
|
|
1577
|
-
const _exhaustive = speech.type;
|
|
1578
|
-
agentLog(
|
|
1579
|
-
"error",
|
|
1580
|
-
`[${sessionId}] unhandled speech event: ${String(_exhaustive)}`
|
|
1581
|
-
);
|
|
1582
|
-
}
|
|
1583
1533
|
}
|
|
1584
1534
|
}
|
|
1585
1535
|
defineAgent({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-verify-start.d.ts","sourceRoot":"","sources":["../../src/verify/run-verify-start.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,kBAAkB,EAClB,iBAAiB,EAElB,MAAM,iBAAiB,CAAC;AAoBzB,wBAAsB,mBAAmB,CACvC,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,iBAAiB,CAAC,
|
|
1
|
+
{"version":3,"file":"run-verify-start.d.ts","sourceRoot":"","sources":["../../src/verify/run-verify-start.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,kBAAkB,EAClB,iBAAiB,EAElB,MAAM,iBAAiB,CAAC;AAoBzB,wBAAsB,mBAAmB,CACvC,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,iBAAiB,CAAC,CA6J5B"}
|
|
@@ -17,8 +17,7 @@ export async function runAgentVerifyStart(options = {}) {
|
|
|
17
17
|
const cwd = options.cwd ?? process.cwd();
|
|
18
18
|
const checks = [];
|
|
19
19
|
const quiet = options.quiet;
|
|
20
|
-
const bundlePath = options.bundlePath ??
|
|
21
|
-
parseBundleArg([], process.env, cwd);
|
|
20
|
+
const bundlePath = options.bundlePath ?? parseBundleArg([], process.env, cwd);
|
|
22
21
|
logLine(quiet, "[@voicethere/agent verify-start]");
|
|
23
22
|
const nodeMajor = Number(process.versions.node.split(".")[0]);
|
|
24
23
|
if (!Number.isFinite(nodeMajor) || nodeMajor < MIN_NODE_MAJOR) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-verify-start.js","sourceRoot":"","sources":["../../src/verify/run-verify-start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,sBAAsB,GACvB,MAAM,UAAU,CAAC;AAOlB,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,MAAM,cAAc,GAAG,EAAE,CAAC;AAE1B,SAAS,OAAO,CAAC,KAA0B,EAAE,OAAe;IAC1D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC;IACvC,CAAC;AACH,CAAC;AAED,SAAS,SAAS,CAChB,MAA2B,EAC3B,IAAY,EACZ,MAAc;IAEd,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;IACzC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU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AO,CAAC,KAAK,EAAE,qDAAqD,CAAC,CAAC;IACtE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC;AAC1D,CAAC"}
|
package/eject/llm/loop.ts
CHANGED
package/package.json
CHANGED
|
@@ -4,6 +4,6 @@ Speak English only, even if the learner switches to another language. Keep repli
|
|
|
4
4
|
|
|
5
5
|
Correct at most one mistake per turn. Say the learner's sentence again the correct way, then give the reason in a few words. If there is no mistake, say something encouraging in a few words instead. Then ask one follow-up question that keeps the conversation going.
|
|
6
6
|
|
|
7
|
-
When the learner asks about a phrase, an idiom or a lesson topic, call search_knowledge first and answer from what it returns. Call it before you say anything on such a question: do not give a meaning, a guess or a filler sentence first. Never make up the meaning of an idiom that the search did not return. If the search has nothing, say you are not sure and
|
|
7
|
+
When the learner asks about a phrase, an idiom or a lesson topic, call search_knowledge first and answer from what it returns. Call it before you say anything on such a question: do not give a meaning, a guess or a filler sentence first. Never make up the meaning of an idiom that the search did not return. If the search has nothing, say you are not sure and suggest one lesson topic to practice instead. Do not explain any phrase or idiom that the search did not return.
|
|
8
8
|
|
|
9
9
|
Be patient and friendly. Let the learner finish their thought before you correct anything.
|
|
@@ -4,6 +4,6 @@ Keep replies to one to three short sentences, in plain words. Do not use markdow
|
|
|
4
4
|
|
|
5
5
|
Answer questions about shipping, returns, warranty, sizing, store hours, contact details and what the store sells from search_knowledge. Search before you answer such a question: do not give a guess or a filler sentence first. If the search has nothing, say you are not sure and offer to connect the customer with the support team at the address or number in the store information.
|
|
6
6
|
|
|
7
|
-
For any price, call get_product_price with the product name or id. If the customer asks what the store sells and you need exact names, call list_products. Never state a price that did not come from get_product_price, never estimate one and never work out a total from memory. If the tool says it does not know the product, say so and offer to look up a similar one.
|
|
7
|
+
For any price, call get_product_price with the product name or id. Say exactly the priceUsd that get_product_price returned, in words, and no other amount. If the customer asks what the store sells and you need exact names, call list_products. Never state a price that did not come from get_product_price, never estimate one and never work out a total from memory. If the tool says it does not know the product, say so and offer to look up a similar one.
|
|
8
8
|
|
|
9
9
|
Be friendly and patient. Ask one question at a time.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Full starter template — copy into your project and build to a single `agent.js` bundle.
|
|
3
3
|
*
|
|
4
|
-
* Handles
|
|
4
|
+
* Handles the speech events the cloud runner delivers (`RUNNER_FORWARDED_SPEECH_EVENTS`).
|
|
5
5
|
* Replace the stub bodies with your product logic; keep `onUserSpeechFinal` as the main turn hook.
|
|
6
6
|
*
|
|
7
7
|
* Build:
|
|
@@ -56,8 +56,8 @@ function formatSpeechDetail(speech: SpeechEvent): string {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
|
-
* Dispatch
|
|
60
|
-
* `
|
|
59
|
+
* Dispatch the speech lifecycle events the runner forwards. `speech.type` values match
|
|
60
|
+
* `SpeechEventType` in `@node-webrtc-rust/sdk/voice`.
|
|
61
61
|
*/
|
|
62
62
|
function handleSpeechEvent(sessionId: string, speech: SpeechEvent): void {
|
|
63
63
|
const state = peerState(sessionId);
|
|
@@ -70,57 +70,7 @@ function handleSpeechEvent(sessionId: string, speech: SpeechEvent): void {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
switch (speech.type) {
|
|
73
|
-
// --- User turn
|
|
74
|
-
case "user_speaking_start":
|
|
75
|
-
state.userSpeaking = true;
|
|
76
|
-
agentLog("info", `[${sessionId}] user_speaking_start`);
|
|
77
|
-
break;
|
|
78
|
-
|
|
79
|
-
case "user_speaking_end":
|
|
80
|
-
state.userSpeaking = false;
|
|
81
|
-
agentLog("info", `[${sessionId}] user_speaking_end`);
|
|
82
|
-
break;
|
|
83
|
-
|
|
84
|
-
case "vad_triggered":
|
|
85
|
-
agentLog(
|
|
86
|
-
"info",
|
|
87
|
-
`[${sessionId}] vad_triggered — STT listen window opened`,
|
|
88
|
-
);
|
|
89
|
-
break;
|
|
90
|
-
|
|
91
|
-
case "stt_stream_start":
|
|
92
|
-
agentLog("info", `[${sessionId}] stt_stream_start`);
|
|
93
|
-
break;
|
|
94
|
-
|
|
95
|
-
case "stt_stream_end":
|
|
96
|
-
agentLog("info", `[${sessionId}] stt_stream_end`);
|
|
97
|
-
break;
|
|
98
|
-
|
|
99
|
-
case "user_stt_start":
|
|
100
|
-
state.sttActive = true;
|
|
101
|
-
state.lastPartial = "";
|
|
102
|
-
agentLog("info", `[${sessionId}] user_stt_start`);
|
|
103
|
-
break;
|
|
104
|
-
|
|
105
|
-
case "user_stt_end":
|
|
106
|
-
state.sttActive = false;
|
|
107
|
-
agentLog("info", `[${sessionId}] user_stt_end`);
|
|
108
|
-
break;
|
|
109
|
-
|
|
110
|
-
case "user_stt_not_found":
|
|
111
|
-
agentLog(
|
|
112
|
-
"info",
|
|
113
|
-
`[${sessionId}] user_stt_not_found — no speech recognized in listen window`,
|
|
114
|
-
);
|
|
115
|
-
// Optional: speak(sessionId, "I didn't catch that. Could you repeat?")
|
|
116
|
-
break;
|
|
117
|
-
|
|
118
|
-
case "user_speech_partial":
|
|
119
|
-
state.lastPartial = speech.text ?? "";
|
|
120
|
-
agentLog("info", `[${sessionId}] user_speech_partial ${detail}`);
|
|
121
|
-
// Optional: live captions, early intent detection, custom barge-in rules
|
|
122
|
-
break;
|
|
123
|
-
|
|
73
|
+
// --- User turn ---
|
|
124
74
|
case "user_speech_final":
|
|
125
75
|
state.lastPartial = "";
|
|
126
76
|
agentLog("info", `[${sessionId}] user_speech_final ${detail}`);
|
|
@@ -146,20 +96,9 @@ function handleSpeechEvent(sessionId: string, speech: SpeechEvent): void {
|
|
|
146
96
|
// Optional: cancel in-flight LLM/TTS work keyed by sessionId
|
|
147
97
|
break;
|
|
148
98
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
"error",
|
|
152
|
-
`[${sessionId}] pipeline error: ${speech.error ?? "unknown"}`,
|
|
153
|
-
);
|
|
99
|
+
default:
|
|
100
|
+
// Other speech event types are not delivered by the cloud runner.
|
|
154
101
|
break;
|
|
155
|
-
|
|
156
|
-
default: {
|
|
157
|
-
const _exhaustive: never = speech.type;
|
|
158
|
-
agentLog(
|
|
159
|
-
"error",
|
|
160
|
-
`[${sessionId}] unhandled speech event: ${String(_exhaustive)}`,
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
102
|
}
|
|
164
103
|
}
|
|
165
104
|
|