@voicethere/agent 0.24.0 → 0.26.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 +28 -0
- package/dist/agent.js +11 -2
- package/dist/cli.d.ts +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +11 -0
- package/dist/cli.js.map +1 -1
- package/dist/flow/classify.d.ts +12 -0
- package/dist/flow/classify.d.ts.map +1 -0
- package/dist/flow/classify.js +37 -0
- package/dist/flow/classify.js.map +1 -0
- package/dist/flow/cli-flow.d.ts +19 -0
- package/dist/flow/cli-flow.d.ts.map +1 -0
- package/dist/flow/cli-flow.js +566 -0
- package/dist/flow/cli-flow.js.map +1 -0
- package/dist/flow/core/compile.d.ts +131 -0
- package/dist/flow/core/compile.d.ts.map +1 -0
- package/dist/flow/core/compile.js +197 -0
- package/dist/flow/core/compile.js.map +1 -0
- package/dist/flow/core/conditions.d.ts +5 -0
- package/dist/flow/core/conditions.d.ts.map +1 -0
- package/dist/flow/core/conditions.js +70 -0
- package/dist/flow/core/conditions.js.map +1 -0
- package/dist/flow/core/effects.d.ts +105 -0
- package/dist/flow/core/effects.d.ts.map +1 -0
- package/dist/flow/core/effects.js +2 -0
- package/dist/flow/core/effects.js.map +1 -0
- package/dist/flow/core/generate-mock.d.ts +16 -0
- package/dist/flow/core/generate-mock.d.ts.map +1 -0
- package/dist/flow/core/generate-mock.js +206 -0
- package/dist/flow/core/generate-mock.js.map +1 -0
- package/dist/flow/core/host.d.ts +9 -0
- package/dist/flow/core/host.d.ts.map +1 -0
- package/dist/flow/core/host.js +99 -0
- package/dist/flow/core/host.js.map +1 -0
- package/dist/flow/core/index.d.ts +17 -0
- package/dist/flow/core/index.d.ts.map +1 -0
- package/dist/flow/core/index.js +17 -0
- package/dist/flow/core/index.js.map +1 -0
- package/dist/flow/core/interpreter.d.ts +69 -0
- package/dist/flow/core/interpreter.d.ts.map +1 -0
- package/dist/flow/core/interpreter.js +738 -0
- package/dist/flow/core/interpreter.js.map +1 -0
- package/dist/flow/core/json-pointer.d.ts +6 -0
- package/dist/flow/core/json-pointer.d.ts.map +1 -0
- package/dist/flow/core/json-pointer.js +28 -0
- package/dist/flow/core/json-pointer.js.map +1 -0
- package/dist/flow/core/migrate.d.ts +16 -0
- package/dist/flow/core/migrate.d.ts.map +1 -0
- package/dist/flow/core/migrate.js +29 -0
- package/dist/flow/core/migrate.js.map +1 -0
- package/dist/flow/core/mock-effects.d.ts +14 -0
- package/dist/flow/core/mock-effects.d.ts.map +1 -0
- package/dist/flow/core/mock-effects.js +90 -0
- package/dist/flow/core/mock-effects.js.map +1 -0
- package/dist/flow/core/mocks.d.ts +55 -0
- package/dist/flow/core/mocks.d.ts.map +1 -0
- package/dist/flow/core/mocks.js +73 -0
- package/dist/flow/core/mocks.js.map +1 -0
- package/dist/flow/core/route.d.ts +29 -0
- package/dist/flow/core/route.d.ts.map +1 -0
- package/dist/flow/core/route.js +61 -0
- package/dist/flow/core/route.js.map +1 -0
- package/dist/flow/core/schema.d.ts +19 -0
- package/dist/flow/core/schema.d.ts.map +1 -0
- package/dist/flow/core/schema.js +317 -0
- package/dist/flow/core/schema.js.map +1 -0
- package/dist/flow/core/template.d.ts +16 -0
- package/dist/flow/core/template.d.ts.map +1 -0
- package/dist/flow/core/template.js +65 -0
- package/dist/flow/core/template.js.map +1 -0
- package/dist/flow/core/trace.d.ts +26 -0
- package/dist/flow/core/trace.d.ts.map +1 -0
- package/dist/flow/core/trace.js +2 -0
- package/dist/flow/core/trace.js.map +1 -0
- package/dist/flow/core/types.d.ts +159 -0
- package/dist/flow/core/types.d.ts.map +1 -0
- package/dist/flow/core/types.js +2 -0
- package/dist/flow/core/types.js.map +1 -0
- package/dist/flow/core/validate.d.ts +3 -0
- package/dist/flow/core/validate.d.ts.map +1 -0
- package/dist/flow/core/validate.js +550 -0
- package/dist/flow/core/validate.js.map +1 -0
- package/dist/flow/create-flow-agent.d.ts +36 -0
- package/dist/flow/create-flow-agent.d.ts.map +1 -0
- package/dist/flow/create-flow-agent.js +175 -0
- package/dist/flow/create-flow-agent.js.map +1 -0
- package/dist/flow/effects-node.d.ts +21 -0
- package/dist/flow/effects-node.d.ts.map +1 -0
- package/dist/flow/effects-node.js +189 -0
- package/dist/flow/effects-node.js.map +1 -0
- package/dist/flow/index.d.ts +12 -0
- package/dist/flow/index.d.ts.map +1 -0
- package/dist/flow/index.js +7 -0
- package/dist/flow/index.js.map +1 -0
- package/dist/flow/llm-node.d.ts +24 -0
- package/dist/flow/llm-node.d.ts.map +1 -0
- package/dist/flow/llm-node.js +251 -0
- package/dist/flow/llm-node.js.map +1 -0
- package/dist/flow/record.d.ts +22 -0
- package/dist/flow/record.d.ts.map +1 -0
- package/dist/flow/record.js +126 -0
- package/dist/flow/record.js.map +1 -0
- package/dist/llm/agent/build-tool-registry.d.ts +26 -0
- package/dist/llm/agent/build-tool-registry.d.ts.map +1 -0
- package/dist/llm/agent/build-tool-registry.js +106 -0
- package/dist/llm/agent/build-tool-registry.js.map +1 -0
- package/dist/llm/agent/create-llm-agent.d.ts.map +1 -1
- package/dist/llm/agent/create-llm-agent.js +45 -106
- package/dist/llm/agent/create-llm-agent.js.map +1 -1
- package/dist/llm/anthropic-provider.d.ts.map +1 -1
- package/dist/llm/anthropic-provider.js +10 -0
- package/dist/llm/anthropic-provider.js.map +1 -1
- package/dist/llm/catalog.d.ts +4 -0
- package/dist/llm/catalog.d.ts.map +1 -1
- package/dist/llm/catalog.js +7 -0
- package/dist/llm/catalog.js.map +1 -1
- package/dist/llm/gemini-provider.d.ts.map +1 -1
- package/dist/llm/gemini-provider.js +12 -0
- package/dist/llm/gemini-provider.js.map +1 -1
- package/dist/llm/index.d.ts +2 -0
- 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/llm/openai-provider.d.ts.map +1 -1
- package/dist/llm/openai-provider.js +10 -0
- package/dist/llm/openai-provider.js.map +1 -1
- package/dist/llm/types.d.ts +7 -2
- package/dist/llm/types.d.ts.map +1 -1
- package/dist/llm/types.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/flow-agent/agent.js +49085 -0
- package/dist/templates/language-switch/agent.js +12 -2
- package/dist/templates/llm-agent/agent.js +156 -106
- package/dist/templates/llm-docs-rag/agent.js +156 -106
- package/dist/templates/llm-mcp-service/agent.js +156 -106
- package/dist/templates/positional-tts/agent.js +12 -2
- package/dist/templates/recording-consent/agent.js +12 -2
- package/dist/templates/registry.d.ts.map +1 -1
- package/dist/templates/registry.js +23 -0
- package/dist/templates/registry.js.map +1 -1
- 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 +51 -104
- package/package.json +19 -2
- package/schema/voicethere.flow.schema.json +681 -0
- package/templates/flow-agent/README.md +38 -0
- package/templates/flow-agent/agent.ts +14 -0
- package/templates/flow-agent/tools.ts +5 -0
- package/templates/flow-agent/voicethere.flow.json +80 -0
- package/templates/flow-agent/voicethere.flow.mocks.json +17 -0
- package/templates/llm-agent/README.md +4 -2
package/eject/llm/loop.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copied from @voicethere/agent 0.
|
|
1
|
+
// Copied from @voicethere/agent 0.26.0. Package updates no longer change this file.
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import {
|
|
4
4
|
type AgentHandlers,
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
} from "@voicethere/agent";
|
|
18
18
|
import {
|
|
19
19
|
type AgentContent,
|
|
20
|
+
buildToolRegistry,
|
|
20
21
|
cleanLinkSentence,
|
|
21
22
|
ConversationHistory,
|
|
22
23
|
countLinkMarks,
|
|
@@ -50,7 +51,7 @@ import {
|
|
|
50
51
|
SentenceSplitter,
|
|
51
52
|
stripThinking,
|
|
52
53
|
ThinkingStripper,
|
|
53
|
-
ToolRegistry,
|
|
54
|
+
type ToolRegistry,
|
|
54
55
|
type TurnContext,
|
|
55
56
|
type TurnSummary,
|
|
56
57
|
validateLlmAgentConfig,
|
|
@@ -448,16 +449,33 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
|
|
|
448
449
|
}
|
|
449
450
|
}
|
|
450
451
|
|
|
452
|
+
/**
|
|
453
|
+
* The one place where a filler reaches the client as text. Fillers are not
|
|
454
|
+
* reply text: never `assistant_delta`, never in `chat_reply`, never in history.
|
|
455
|
+
*/
|
|
456
|
+
function sendFillerMessage(
|
|
457
|
+
s: SessionState,
|
|
458
|
+
turnId: string,
|
|
459
|
+
text: string,
|
|
460
|
+
): void {
|
|
461
|
+
sendToClient(s.sessionId, { type: "assistant_filler", turnId, text });
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/** Speak options for a filler; replies carry no `kind`. */
|
|
451
465
|
function speakAnnouncement(
|
|
452
466
|
s: SessionState,
|
|
453
467
|
turnId: string,
|
|
454
468
|
text: string,
|
|
455
469
|
interruptible: boolean,
|
|
470
|
+
fillerKind?: FillerKind,
|
|
456
471
|
): SpeakHandle {
|
|
472
|
+
const opts = fillerKind
|
|
473
|
+
? { turnId, kind: "filler" as const, fillerKind }
|
|
474
|
+
: { turnId };
|
|
457
475
|
if (interruptible) {
|
|
458
|
-
return speak(s.sessionId, text,
|
|
476
|
+
return speak(s.sessionId, text, opts);
|
|
459
477
|
}
|
|
460
|
-
const h = announce(s.sessionId, text,
|
|
478
|
+
const h = announce(s.sessionId, text, opts);
|
|
461
479
|
trackAnnouncement(s, h.done);
|
|
462
480
|
return h;
|
|
463
481
|
}
|
|
@@ -540,7 +558,8 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
|
|
|
540
558
|
if (kind === "thinking") t.thinkingSpoken = true;
|
|
541
559
|
if (kind === "toolCall") t.toolCallSpoken = true;
|
|
542
560
|
if (kind === "toolWait") t.toolWaitSpoken += 1;
|
|
543
|
-
speakAnnouncement(s, t.turnId, text, fillersInterruptible);
|
|
561
|
+
speakAnnouncement(s, t.turnId, text, fillersInterruptible, kind);
|
|
562
|
+
sendFillerMessage(s, t.turnId, text);
|
|
544
563
|
return undefined;
|
|
545
564
|
}
|
|
546
565
|
|
|
@@ -742,106 +761,32 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
|
|
|
742
761
|
}
|
|
743
762
|
|
|
744
763
|
function buildRegistry(env: Record<string, string | undefined>): void {
|
|
745
|
-
const
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
]),
|
|
769
|
-
emit: (fields, sid) =>
|
|
770
|
-
agentLog("info", "llm tool call", { ...fields }, sid),
|
|
771
|
-
},
|
|
764
|
+
const built = buildToolRegistry({
|
|
765
|
+
env,
|
|
766
|
+
toolSources: config.toolSources ?? [],
|
|
767
|
+
customTools: [
|
|
768
|
+
...(opts.tools ?? []),
|
|
769
|
+
...(knowledgeTool ? [knowledgeTool] : []),
|
|
770
|
+
],
|
|
771
|
+
secretNames: [
|
|
772
|
+
config.apiKeySecret,
|
|
773
|
+
"AGENT_SERVICE_TOKEN",
|
|
774
|
+
...(config.knowledge?.embeddings
|
|
775
|
+
? [config.knowledge.embeddings.apiKeySecret]
|
|
776
|
+
: []),
|
|
777
|
+
...(config.knowledge?.supabase
|
|
778
|
+
? [
|
|
779
|
+
config.knowledge.supabase.keySecret,
|
|
780
|
+
config.knowledge.supabase.urlSecret,
|
|
781
|
+
]
|
|
782
|
+
: []),
|
|
783
|
+
],
|
|
784
|
+
toolCallLogs: config.toolCallLogs ?? D.toolCallLogs,
|
|
785
|
+
servicePath: D.servicePath,
|
|
786
|
+
makeSource,
|
|
772
787
|
});
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
const sources: McpToolSource[] = [];
|
|
776
|
-
for (const src of config.toolSources ?? []) {
|
|
777
|
-
if (src.kind === "service") {
|
|
778
|
-
const base = env.AGENT_SERVICE_URL;
|
|
779
|
-
if (!nonEmpty(base)) {
|
|
780
|
-
agentLog(
|
|
781
|
-
"warn",
|
|
782
|
-
"toolSources: service configured but this project has no service",
|
|
783
|
-
);
|
|
784
|
-
continue;
|
|
785
|
-
}
|
|
786
|
-
const headers: Record<string, string> = {};
|
|
787
|
-
const token = env.AGENT_SERVICE_TOKEN;
|
|
788
|
-
if (nonEmpty(token)) {
|
|
789
|
-
headers.Authorization = `Bearer ${token}`;
|
|
790
|
-
} else {
|
|
791
|
-
agentLog("warn", "toolSources: AGENT_SERVICE_TOKEN is not set");
|
|
792
|
-
}
|
|
793
|
-
const source = makeSource({
|
|
794
|
-
name: "service",
|
|
795
|
-
kind: "service",
|
|
796
|
-
url: `${base}${src.path ?? D.servicePath}`,
|
|
797
|
-
headers,
|
|
798
|
-
allow: src.allow,
|
|
799
|
-
deny: src.deny,
|
|
800
|
-
log: (level, message, fields) =>
|
|
801
|
-
agentLog(level, message, fields ?? {}),
|
|
802
|
-
});
|
|
803
|
-
serviceSource = source;
|
|
804
|
-
sources.push(source);
|
|
805
|
-
} else {
|
|
806
|
-
const headers: Record<string, string> = {};
|
|
807
|
-
let missing: string | undefined;
|
|
808
|
-
const auth = src.auth ?? { type: "none" as const };
|
|
809
|
-
if (auth.type === "bearer") {
|
|
810
|
-
const v = env[auth.secret];
|
|
811
|
-
if (nonEmpty(v)) headers.Authorization = `Bearer ${v}`;
|
|
812
|
-
else missing = auth.secret;
|
|
813
|
-
} else if (auth.type === "headers") {
|
|
814
|
-
for (const [header, envName] of Object.entries(auth.headers)) {
|
|
815
|
-
const v = env[envName];
|
|
816
|
-
if (nonEmpty(v)) headers[header] = v;
|
|
817
|
-
else missing = envName;
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
if (missing) {
|
|
821
|
-
agentLog(
|
|
822
|
-
"warn",
|
|
823
|
-
`toolSources: ${src.name} skipped, environment variable ${missing} is not set`,
|
|
824
|
-
);
|
|
825
|
-
continue;
|
|
826
|
-
}
|
|
827
|
-
sources.push(
|
|
828
|
-
makeSource({
|
|
829
|
-
name: src.name,
|
|
830
|
-
url: src.url,
|
|
831
|
-
headers,
|
|
832
|
-
allow: src.allow,
|
|
833
|
-
deny: src.deny,
|
|
834
|
-
log: (level, message, fields) =>
|
|
835
|
-
agentLog(level, message, fields ?? {}),
|
|
836
|
-
}),
|
|
837
|
-
);
|
|
838
|
-
}
|
|
839
|
-
}
|
|
840
|
-
for (const source of sources) {
|
|
841
|
-
reg.addSource(source);
|
|
842
|
-
source.start();
|
|
843
|
-
}
|
|
844
|
-
registry = reg;
|
|
788
|
+
if (built.serviceSource) serviceSource = built.serviceSource;
|
|
789
|
+
registry = built.registry;
|
|
845
790
|
}
|
|
846
791
|
|
|
847
792
|
async function runTools(
|
|
@@ -1212,7 +1157,9 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
|
|
|
1212
1157
|
t.turnId,
|
|
1213
1158
|
fillerLegacy.text,
|
|
1214
1159
|
fillerLegacy.interruptible ?? D.fillerInterruptible,
|
|
1160
|
+
"toolWait",
|
|
1215
1161
|
);
|
|
1162
|
+
sendFillerMessage(s, t.turnId, fillerLegacy.text);
|
|
1216
1163
|
}, fillerLegacy.afterMs ?? D.fillerAfterMs);
|
|
1217
1164
|
}
|
|
1218
1165
|
let results: LlmToolResult[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voicethere/agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"description": "VoiceThere customer agent SDK — IPC types and runtime helpers for sandboxed child bundles",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -46,11 +46,28 @@
|
|
|
46
46
|
"require": "./dist/llm/index.js",
|
|
47
47
|
"default": "./dist/llm/index.js"
|
|
48
48
|
},
|
|
49
|
+
"./flow": {
|
|
50
|
+
"types": "./dist/flow/index.d.ts",
|
|
51
|
+
"import": "./dist/flow/index.js",
|
|
52
|
+
"require": "./dist/flow/index.js",
|
|
53
|
+
"default": "./dist/flow/index.js"
|
|
54
|
+
},
|
|
55
|
+
"./flow/core": {
|
|
56
|
+
"types": "./dist/flow/core/index.d.ts",
|
|
57
|
+
"import": "./dist/flow/core/index.js",
|
|
58
|
+
"require": "./dist/flow/core/index.js",
|
|
59
|
+
"default": "./dist/flow/core/index.js"
|
|
60
|
+
},
|
|
49
61
|
"./llm/schema.json": {
|
|
50
62
|
"import": "./schema/voicethere.llm.schema.json",
|
|
51
63
|
"require": "./schema/voicethere.llm.schema.json",
|
|
52
64
|
"default": "./schema/voicethere.llm.schema.json"
|
|
53
65
|
},
|
|
66
|
+
"./flow/schema.json": {
|
|
67
|
+
"import": "./schema/voicethere.flow.schema.json",
|
|
68
|
+
"require": "./schema/voicethere.flow.schema.json",
|
|
69
|
+
"default": "./schema/voicethere.flow.schema.json"
|
|
70
|
+
},
|
|
54
71
|
"./verify": {
|
|
55
72
|
"types": "./dist/verify/run-verify.d.ts",
|
|
56
73
|
"import": "./dist/verify/run-verify.js",
|
|
@@ -93,7 +110,7 @@
|
|
|
93
110
|
],
|
|
94
111
|
"scripts": {
|
|
95
112
|
"build:lib": "tsc -p tsconfig.json && mkdir -p dist/sandbox && cp src/sandbox/loader-entry.js src/sandbox/warning-forwarder.cjs dist/sandbox/",
|
|
96
|
-
"build:schema": "node scripts/build-llm-schema.mjs",
|
|
113
|
+
"build:schema": "node scripts/build-llm-schema.mjs && node scripts/build-flow-schema.mjs",
|
|
97
114
|
"build:eject": "node scripts/build-llm-eject.mjs",
|
|
98
115
|
"build:templates": "node dist/templates/build-seed-bundles-cli.js",
|
|
99
116
|
"build:example": "node dist/cli.js build --entry examples/agent.ts --outfile dist/agent.js",
|