@vellumai/assistant 0.10.10-dev.202607211734.3ee8a7b → 0.10.10-dev.202607211915.ea3ba71
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/openapi.yaml +55 -0
- package/package.json +1 -1
- package/src/__tests__/config-schema.test.ts +23 -0
- package/src/__tests__/conversation-history-web-search.test.ts +7 -0
- package/src/__tests__/managed-profile-guard.test.ts +27 -0
- package/src/__tests__/tool-preview-lifecycle.test.ts +105 -0
- package/src/calls/__tests__/voice-session-bridge.test.ts +154 -1
- package/src/calls/voice-session-bridge.ts +49 -5
- package/src/cli/commands/memory/index.help.ts +16 -3
- package/src/cli/commands/memory/nodes.ts +29 -4
- package/src/cli/commands/plugins.help.ts +6 -2
- package/src/cli/commands/plugins.ts +33 -18
- package/src/cli/lib/__tests__/install-from-github.test.ts +94 -0
- package/src/cli/lib/__tests__/parse-github-plugin-spec.test.ts +60 -0
- package/src/cli/lib/install-from-github.ts +74 -0
- package/src/cli/lib/parse-github-plugin-spec.ts +73 -7
- package/src/config/schemas/__tests__/live-voice.test.ts +54 -0
- package/src/config/schemas/live-voice.ts +73 -1
- package/src/config/schemas/llm.ts +42 -0
- package/src/daemon/conversation-agent-loop-handlers.ts +5 -2
- package/src/live-voice/__tests__/front-decision.test.ts +405 -76
- package/src/live-voice/__tests__/live-voice-metrics.test.ts +26 -1
- package/src/live-voice/__tests__/live-voice-progress.test.ts +724 -0
- package/src/live-voice/__tests__/live-voice-tts-session.test.ts +1 -0
- package/src/live-voice/__tests__/live-voice-vad.test.ts +3 -0
- package/src/live-voice/ack-phrases.ts +23 -5
- package/src/live-voice/front-decision.ts +222 -44
- package/src/live-voice/live-voice-metrics.ts +28 -7
- package/src/live-voice/live-voice-session.ts +447 -51
- package/src/live-voice/protocol.ts +6 -0
- package/src/persistence/embeddings/__tests__/messages-lexical-index.test.ts +45 -0
- package/src/persistence/embeddings/messages-lexical-index.ts +73 -0
- package/src/plugins/defaults/memory/graph/capability-seed.ts +4 -4
- package/src/plugins/defaults/memory/graph/tool-handlers.ts +22 -9
- package/src/plugins/defaults/memory/graph/types.test.ts +91 -0
- package/src/plugins/defaults/memory/graph/types.ts +47 -0
- package/src/plugins/defaults/memory/src/memory-item-routes.test.ts +83 -1
- package/src/plugins/defaults/memory/src/memory-item-routes.ts +23 -1
- package/src/plugins/defaults/memory/v3/__tests__/capabilities.test.ts +42 -15
- package/src/plugins/defaults/memory/v3/__tests__/injection.test.ts +23 -0
- package/src/plugins/defaults/memory/v3/__tests__/maintain-job.test.ts +2 -2
- package/src/plugins/defaults/memory/v3/__tests__/shadow-plugin.test.ts +6 -5
- package/src/plugins/defaults/memory/v3/capabilities.ts +67 -23
- package/src/plugins/defaults/memory/v3/injector.ts +4 -0
- package/src/plugins/defaults/memory/v3/page-content.ts +3 -3
- package/src/plugins/defaults/memory/v3/shadow-plugin.ts +24 -16
- package/src/plugins/defaults/memory/v3/substrate/cli-command-content.ts +24 -1
- package/src/runtime/routes/__tests__/default-plugin-routes.test.ts +61 -2
- package/src/runtime/routes/__tests__/inference-profiles-routes.test.ts +14 -0
- package/src/runtime/routes/__tests__/user-routes-cli.test.ts +36 -0
- package/src/runtime/routes/conversation-query-routes.ts +43 -0
- package/src/runtime/routes/index.ts +2 -0
- package/src/runtime/routes/inference-profiles-routes.ts +13 -1
- package/src/runtime/routes/live-voice-routes.test.ts +73 -0
- package/src/runtime/routes/live-voice-routes.ts +65 -0
- package/src/runtime/routes/user-route-resolution.ts +26 -5
- package/src/runtime/routes/user-routes-cli.ts +7 -0
package/openapi.yaml
CHANGED
|
@@ -16357,6 +16357,50 @@ paths:
|
|
|
16357
16357
|
responses:
|
|
16358
16358
|
"200":
|
|
16359
16359
|
description: Successful response
|
|
16360
|
+
/v1/live-voice/preflight:
|
|
16361
|
+
post:
|
|
16362
|
+
operationId: livevoice_preflight_post
|
|
16363
|
+
summary: Live voice preflight
|
|
16364
|
+
description: Ensure managed speech defaulting has run, then report whether live voice can start.
|
|
16365
|
+
tags:
|
|
16366
|
+
- live-voice
|
|
16367
|
+
responses:
|
|
16368
|
+
"200":
|
|
16369
|
+
description: Successful response
|
|
16370
|
+
content:
|
|
16371
|
+
application/json:
|
|
16372
|
+
schema:
|
|
16373
|
+
type: object
|
|
16374
|
+
properties:
|
|
16375
|
+
status:
|
|
16376
|
+
type: string
|
|
16377
|
+
enum:
|
|
16378
|
+
- ready
|
|
16379
|
+
- not-ready
|
|
16380
|
+
missing:
|
|
16381
|
+
type: array
|
|
16382
|
+
items:
|
|
16383
|
+
type: object
|
|
16384
|
+
properties:
|
|
16385
|
+
kind:
|
|
16386
|
+
type: string
|
|
16387
|
+
enum:
|
|
16388
|
+
- stt
|
|
16389
|
+
- tts
|
|
16390
|
+
providerId:
|
|
16391
|
+
type: string
|
|
16392
|
+
reason:
|
|
16393
|
+
type: string
|
|
16394
|
+
required:
|
|
16395
|
+
- kind
|
|
16396
|
+
- providerId
|
|
16397
|
+
- reason
|
|
16398
|
+
additionalProperties: false
|
|
16399
|
+
userMessage:
|
|
16400
|
+
type: string
|
|
16401
|
+
required:
|
|
16402
|
+
- status
|
|
16403
|
+
additionalProperties: false
|
|
16360
16404
|
/v1/llm-request-logs/{id}/context:
|
|
16361
16405
|
get:
|
|
16362
16406
|
operationId: llmrequestlogs_by_id_context_get
|
|
@@ -17052,6 +17096,15 @@ paths:
|
|
|
17052
17096
|
schema:
|
|
17053
17097
|
type: integer
|
|
17054
17098
|
description: Max results (default 50, max 200)
|
|
17099
|
+
- name: kind
|
|
17100
|
+
in: query
|
|
17101
|
+
required: false
|
|
17102
|
+
schema:
|
|
17103
|
+
type: string
|
|
17104
|
+
enum:
|
|
17105
|
+
- skill
|
|
17106
|
+
- cli
|
|
17107
|
+
description: "Restrict to auto-seeded capability nodes: 'skill' or 'cli'"
|
|
17055
17108
|
responses:
|
|
17056
17109
|
"200":
|
|
17057
17110
|
description: Successful response
|
|
@@ -32342,6 +32395,8 @@ components:
|
|
|
32342
32395
|
- together
|
|
32343
32396
|
- litellm
|
|
32344
32397
|
- baseten
|
|
32398
|
+
- vellum
|
|
32399
|
+
- chatgpt
|
|
32345
32400
|
ProfilePatchEntry:
|
|
32346
32401
|
type: object
|
|
32347
32402
|
properties:
|
package/package.json
CHANGED
|
@@ -392,6 +392,22 @@ describe("AssistantConfigSchema", () => {
|
|
|
392
392
|
expect(result.success).toBe(false);
|
|
393
393
|
});
|
|
394
394
|
|
|
395
|
+
test("write-locks the vellum and chatgpt routing identities in profiles and call sites", () => {
|
|
396
|
+
// The enum admits the identities (so dispatch-layer types can carry
|
|
397
|
+
// them), but stored config rejects them — parse-level rejection covers
|
|
398
|
+
// every write path, not just the profiles route.
|
|
399
|
+
for (const provider of ["vellum", "chatgpt"]) {
|
|
400
|
+
const inProfile = AssistantConfigSchema.safeParse({
|
|
401
|
+
llm: { profiles: { custom: { provider } } },
|
|
402
|
+
});
|
|
403
|
+
expect(inProfile.success).toBe(false);
|
|
404
|
+
const inCallSite = AssistantConfigSchema.safeParse({
|
|
405
|
+
llm: { callSites: { mainAgent: { provider } } },
|
|
406
|
+
});
|
|
407
|
+
expect(inCallSite.success).toBe(false);
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
|
|
395
411
|
test("rejects negative llm.callSites maxTokens", () => {
|
|
396
412
|
const result = AssistantConfigSchema.safeParse({
|
|
397
413
|
llm: { callSites: { mainAgent: { maxTokens: -100 } } },
|
|
@@ -833,6 +849,13 @@ describe("AssistantConfigSchema", () => {
|
|
|
833
849
|
ackFirstDeltaTimeoutMs: 2500,
|
|
834
850
|
ackGenerationTimeoutMs: 600,
|
|
835
851
|
llmAckText: false,
|
|
852
|
+
progress: {
|
|
853
|
+
enabled: true,
|
|
854
|
+
opsThreshold: 3,
|
|
855
|
+
idleIntervalMs: 5000,
|
|
856
|
+
minGapMs: 6000,
|
|
857
|
+
generationTimeoutMs: 1500,
|
|
858
|
+
},
|
|
836
859
|
},
|
|
837
860
|
maxSessionDurationSeconds: 1800,
|
|
838
861
|
archiveAudio: false,
|
|
@@ -652,6 +652,13 @@ describe("web_search_tool_result structural guard", () => {
|
|
|
652
652
|
// provider, not the local tool executor, so they never flow here.
|
|
653
653
|
"agent/loop.ts",
|
|
654
654
|
|
|
655
|
+
// Matches the `tool_result` ServerMessage SSE event (api/events/
|
|
656
|
+
// tool-result.ts), not a conversation content block. There is no
|
|
657
|
+
// web_search_tool_result SSE event — web-search activity travels as
|
|
658
|
+
// activityMetadata on the same tool_result event. Same event-vs-block
|
|
659
|
+
// distinction as agent/loop.ts, one hop downstream.
|
|
660
|
+
"calls/voice-session-bridge.ts",
|
|
661
|
+
|
|
655
662
|
// Counts consecutive errors for locally-executed tools to bound retry
|
|
656
663
|
// coaching. Server-side web search results (web_search_tool_result) carry
|
|
657
664
|
// no is_error flag and are not produced by the tool executor, so only
|
|
@@ -195,6 +195,33 @@ describe("PUT /v1/config/llm/profiles/:name — managed profile guard", () => {
|
|
|
195
195
|
expect(committedRaw()).not.toBeNull();
|
|
196
196
|
});
|
|
197
197
|
|
|
198
|
+
test("rejects write-locked routing identities in a raw llm.default write", async () => {
|
|
199
|
+
// llm.default is a raw compatibility field outside the parsed schema; a
|
|
200
|
+
// raw PATCH can persist one and materialization uses the on-disk blob as
|
|
201
|
+
// its fill base, so the write-lock must cover it.
|
|
202
|
+
await expect(
|
|
203
|
+
patchRoute.handler({
|
|
204
|
+
body: { llm: { default: { provider: "vellum" } } },
|
|
205
|
+
}),
|
|
206
|
+
).rejects.toThrow(/not yet enabled/);
|
|
207
|
+
expect(committedRaw()).toBeNull();
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
test("rejects write-locked routing identities on the replace path", async () => {
|
|
211
|
+
// This route validates with ProfileEntry.safeParse only, so the
|
|
212
|
+
// commitConfigWrite choke-point guard is what keeps the schema-admitted
|
|
213
|
+
// identities from reaching disk.
|
|
214
|
+
for (const provider of ["vellum", "chatgpt"]) {
|
|
215
|
+
await expect(
|
|
216
|
+
replaceRoute.handler({
|
|
217
|
+
pathParams: { name: "my-custom" },
|
|
218
|
+
body: { provider, model: "claude-opus-4-8" },
|
|
219
|
+
}),
|
|
220
|
+
).rejects.toThrow(/not yet enabled/);
|
|
221
|
+
expect(committedRaw()).toBeNull();
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
|
|
198
225
|
// -------------------------------------------------------------------------
|
|
199
226
|
// Null-as-clear sentinel: clients send `{ label: null }` or
|
|
200
227
|
// `{ status: null }` to clear a managed profile's overrides back to the
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* - handleToolUsePreviewStart emits activity state with "tool_running" phase
|
|
7
7
|
* - handleInputJsonDelta includes toolUseId in emitted tool_input_delta
|
|
8
8
|
* - handleToolResult includes toolUseId in emitted tool_result
|
|
9
|
+
* - handleToolResult resolves toolName from the tool_use correlation map
|
|
9
10
|
* - Event ordering: tool_use_preview_start → input_json_delta → tool_use
|
|
10
11
|
*/
|
|
11
12
|
import { beforeEach, describe, expect, mock, test } from "bun:test";
|
|
@@ -798,6 +799,110 @@ describe("tool preview lifecycle", () => {
|
|
|
798
799
|
});
|
|
799
800
|
});
|
|
800
801
|
|
|
802
|
+
describe("tool_result toolName resolution", () => {
|
|
803
|
+
/** Deps wired to a fresh collector. */
|
|
804
|
+
function makeCollectingDeps(): {
|
|
805
|
+
deps: EventHandlerDeps;
|
|
806
|
+
events: ServerMessage[];
|
|
807
|
+
} {
|
|
808
|
+
const collector = createEventCollector();
|
|
809
|
+
const deps = createMockDeps({
|
|
810
|
+
onEvent: collector.onEvent,
|
|
811
|
+
ctx: {
|
|
812
|
+
...createMockDeps().ctx,
|
|
813
|
+
emitActivityState: collector.emitActivityState,
|
|
814
|
+
} as unknown as EventHandlerDeps["ctx"],
|
|
815
|
+
});
|
|
816
|
+
return { deps, events: collector.events };
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
function emittedToolResult(
|
|
820
|
+
events: ServerMessage[],
|
|
821
|
+
): Record<string, unknown> {
|
|
822
|
+
const toolResult = events.find((e) => e.type === "tool_result");
|
|
823
|
+
expect(toolResult).toBeDefined();
|
|
824
|
+
return toolResult as unknown as Record<string, unknown>;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
test("a result following its tool_use carries the resolved tool name", async () => {
|
|
828
|
+
// GIVEN a tool whose tool_use event was observed
|
|
829
|
+
const { deps, events } = makeCollectingDeps();
|
|
830
|
+
handleToolUse(state, deps, {
|
|
831
|
+
type: "tool_use",
|
|
832
|
+
id: "toolu_named",
|
|
833
|
+
name: "web_search",
|
|
834
|
+
input: { query: "weather" },
|
|
835
|
+
});
|
|
836
|
+
|
|
837
|
+
// WHEN its result arrives
|
|
838
|
+
await handleToolResult(state, deps, {
|
|
839
|
+
type: "tool_result",
|
|
840
|
+
toolUseId: "toolu_named",
|
|
841
|
+
content: "sunny",
|
|
842
|
+
isError: false,
|
|
843
|
+
});
|
|
844
|
+
|
|
845
|
+
// THEN the emitted event carries the name from the correlation map
|
|
846
|
+
expect(emittedToolResult(events).toolName).toBe("web_search");
|
|
847
|
+
});
|
|
848
|
+
|
|
849
|
+
test("a result for a never-observed toolUseId carries an empty toolName", async () => {
|
|
850
|
+
// GIVEN no tool_use event was ever observed for the id
|
|
851
|
+
const { deps, events } = makeCollectingDeps();
|
|
852
|
+
|
|
853
|
+
// WHEN a result arrives anyway
|
|
854
|
+
await handleToolResult(state, deps, {
|
|
855
|
+
type: "tool_result",
|
|
856
|
+
toolUseId: "toolu_unobserved",
|
|
857
|
+
content: "orphan",
|
|
858
|
+
isError: false,
|
|
859
|
+
});
|
|
860
|
+
|
|
861
|
+
// THEN the emitted event falls back to the empty name
|
|
862
|
+
expect(emittedToolResult(events).toolName).toBe("");
|
|
863
|
+
});
|
|
864
|
+
|
|
865
|
+
test("a cancelled synthesis resolves the name when its tool_use was observed", async () => {
|
|
866
|
+
// GIVEN a tool whose tool_use event was observed
|
|
867
|
+
const { deps, events } = makeCollectingDeps();
|
|
868
|
+
handleToolUse(state, deps, {
|
|
869
|
+
type: "tool_use",
|
|
870
|
+
id: "toolu_cancelled",
|
|
871
|
+
name: "bash",
|
|
872
|
+
input: { command: "sleep 60" },
|
|
873
|
+
});
|
|
874
|
+
|
|
875
|
+
// WHEN a synthesized cancellation result arrives (the tool never ran)
|
|
876
|
+
await handleToolResult(state, deps, {
|
|
877
|
+
type: "tool_result",
|
|
878
|
+
toolUseId: "toolu_cancelled",
|
|
879
|
+
content: "cancelled by user",
|
|
880
|
+
isError: true,
|
|
881
|
+
cancelled: true,
|
|
882
|
+
});
|
|
883
|
+
|
|
884
|
+
// THEN the cancellation-path emit still resolves the real name
|
|
885
|
+
expect(emittedToolResult(events).toolName).toBe("bash");
|
|
886
|
+
});
|
|
887
|
+
|
|
888
|
+
test("a cancelled synthesis for a never-observed toolUseId carries an empty toolName", async () => {
|
|
889
|
+
// GIVEN no tool_use event was ever observed for the id
|
|
890
|
+
const { deps, events } = makeCollectingDeps();
|
|
891
|
+
|
|
892
|
+
// WHEN a synthesized cancellation result arrives
|
|
893
|
+
await handleToolResult(state, deps, {
|
|
894
|
+
type: "tool_result",
|
|
895
|
+
toolUseId: "toolu_cancelled_unobserved",
|
|
896
|
+
content: "cancelled by user",
|
|
897
|
+
isError: true,
|
|
898
|
+
cancelled: true,
|
|
899
|
+
});
|
|
900
|
+
|
|
901
|
+
// THEN the emitted event falls back to the empty name
|
|
902
|
+
expect(emittedToolResult(events).toolName).toBe("");
|
|
903
|
+
});
|
|
904
|
+
});
|
|
905
|
+
|
|
801
906
|
describe("event ordering", () => {
|
|
802
907
|
test("events are emitted in correct order: tool_use_preview_start → tool_input_delta → tool_use", () => {
|
|
803
908
|
const collector = createEventCollector();
|
|
@@ -27,7 +27,10 @@ mock.module("../../daemon/conversation-store.js", () => ({
|
|
|
27
27
|
import { setConfig } from "../../__tests__/helpers/set-config.js";
|
|
28
28
|
import { ABORT_WATCHDOG_MS } from "../../daemon/abort-watchdog.js";
|
|
29
29
|
import { CALL_OPENING_MARKER } from "../voice-control-protocol.js";
|
|
30
|
-
import {
|
|
30
|
+
import {
|
|
31
|
+
startVoiceTurn,
|
|
32
|
+
TOOL_RESULT_PREVIEW_MAX_CHARS,
|
|
33
|
+
} from "../voice-session-bridge.js";
|
|
31
34
|
import {
|
|
32
35
|
escalatedContinuationRule,
|
|
33
36
|
ESCALATION_CONTINUATION_CONTENT,
|
|
@@ -1018,3 +1021,153 @@ describe("startVoiceTurn race-loss state restore", () => {
|
|
|
1018
1021
|
expect(waited.assistantId).toBe(winnerState.assistantId);
|
|
1019
1022
|
});
|
|
1020
1023
|
});
|
|
1024
|
+
|
|
1025
|
+
describe("startVoiceTurn tool-event forwarding", () => {
|
|
1026
|
+
// The agent loop's tool_use_start / tool_result events reach the voice
|
|
1027
|
+
// callbacks so the session can track per-turn tool activity. The bridge is
|
|
1028
|
+
// the single truncation point for tool results — the raw result can be
|
|
1029
|
+
// huge and must never travel further into the voice layer.
|
|
1030
|
+
|
|
1031
|
+
/** Scripts runAgentLoop to emit the given agent-loop events in order. */
|
|
1032
|
+
function makeEventEmittingConversation(events: unknown[]) {
|
|
1033
|
+
const fake = makeFakeConversation({ processing: false });
|
|
1034
|
+
fake.conversation.runAgentLoop = async (...args: unknown[]) => {
|
|
1035
|
+
const { onEvent } = args[2] as { onEvent: (msg: unknown) => void };
|
|
1036
|
+
for (const event of events) {
|
|
1037
|
+
onEvent(event);
|
|
1038
|
+
}
|
|
1039
|
+
};
|
|
1040
|
+
fakeConversation = fake.conversation;
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
test("tool_use_start delivers the tool name and toolUseId", async () => {
|
|
1044
|
+
makeEventEmittingConversation([
|
|
1045
|
+
{
|
|
1046
|
+
type: "tool_use_start",
|
|
1047
|
+
toolName: "web_search",
|
|
1048
|
+
input: { query: "weather" },
|
|
1049
|
+
toolUseId: "toolu-1",
|
|
1050
|
+
},
|
|
1051
|
+
]);
|
|
1052
|
+
|
|
1053
|
+
const starts: Array<{ toolName: string; detail?: unknown }> = [];
|
|
1054
|
+
await startVoiceTurn({
|
|
1055
|
+
...makeTurnOptions(),
|
|
1056
|
+
callbacks: {
|
|
1057
|
+
tool_use_start: (toolName, detail) => starts.push({ toolName, detail }),
|
|
1058
|
+
},
|
|
1059
|
+
});
|
|
1060
|
+
await flushMicrotasks();
|
|
1061
|
+
|
|
1062
|
+
expect(starts).toEqual([
|
|
1063
|
+
{ toolName: "web_search", detail: { toolUseId: "toolu-1" } },
|
|
1064
|
+
]);
|
|
1065
|
+
});
|
|
1066
|
+
|
|
1067
|
+
test("tool_result delivers name, id, isError, and a preview truncated to the max preview length", async () => {
|
|
1068
|
+
const longResult = "x".repeat(TOOL_RESULT_PREVIEW_MAX_CHARS + 100);
|
|
1069
|
+
makeEventEmittingConversation([
|
|
1070
|
+
{
|
|
1071
|
+
type: "tool_result",
|
|
1072
|
+
toolName: "web_search",
|
|
1073
|
+
result: longResult,
|
|
1074
|
+
isError: true,
|
|
1075
|
+
toolUseId: "toolu-1",
|
|
1076
|
+
},
|
|
1077
|
+
]);
|
|
1078
|
+
|
|
1079
|
+
const results: unknown[] = [];
|
|
1080
|
+
await startVoiceTurn({
|
|
1081
|
+
...makeTurnOptions(),
|
|
1082
|
+
callbacks: {
|
|
1083
|
+
tool_result: (event) => results.push(event),
|
|
1084
|
+
},
|
|
1085
|
+
});
|
|
1086
|
+
await flushMicrotasks();
|
|
1087
|
+
|
|
1088
|
+
// The shared `truncate` util caps at the max preview length including
|
|
1089
|
+
// its "..." truncation marker.
|
|
1090
|
+
const truncationMarker = "...";
|
|
1091
|
+
const expectedPreview =
|
|
1092
|
+
"x".repeat(TOOL_RESULT_PREVIEW_MAX_CHARS - truncationMarker.length) +
|
|
1093
|
+
truncationMarker;
|
|
1094
|
+
expect(expectedPreview).toHaveLength(TOOL_RESULT_PREVIEW_MAX_CHARS);
|
|
1095
|
+
expect(results).toEqual([
|
|
1096
|
+
{
|
|
1097
|
+
toolName: "web_search",
|
|
1098
|
+
toolUseId: "toolu-1",
|
|
1099
|
+
isError: true,
|
|
1100
|
+
resultPreview: expectedPreview,
|
|
1101
|
+
},
|
|
1102
|
+
]);
|
|
1103
|
+
});
|
|
1104
|
+
|
|
1105
|
+
test("tool_result forwards prod-shaped local-tool payloads, including one without a toolUseId", async () => {
|
|
1106
|
+
// Local tools emit tool_result with the tool's real name; toolUseId is
|
|
1107
|
+
// optional on the wire, so the name must survive the bridge for the
|
|
1108
|
+
// session's name-fallback correlation.
|
|
1109
|
+
makeEventEmittingConversation([
|
|
1110
|
+
{
|
|
1111
|
+
type: "tool_result",
|
|
1112
|
+
toolName: "bash",
|
|
1113
|
+
result: "total 4",
|
|
1114
|
+
isError: false,
|
|
1115
|
+
toolUseId: "toolu-1",
|
|
1116
|
+
},
|
|
1117
|
+
{
|
|
1118
|
+
type: "tool_result",
|
|
1119
|
+
toolName: "file_read",
|
|
1120
|
+
result: "file contents",
|
|
1121
|
+
},
|
|
1122
|
+
]);
|
|
1123
|
+
|
|
1124
|
+
const results: unknown[] = [];
|
|
1125
|
+
await startVoiceTurn({
|
|
1126
|
+
...makeTurnOptions(),
|
|
1127
|
+
callbacks: {
|
|
1128
|
+
tool_result: (event) => results.push(event),
|
|
1129
|
+
},
|
|
1130
|
+
});
|
|
1131
|
+
await flushMicrotasks();
|
|
1132
|
+
|
|
1133
|
+
expect(results).toEqual([
|
|
1134
|
+
{
|
|
1135
|
+
toolName: "bash",
|
|
1136
|
+
toolUseId: "toolu-1",
|
|
1137
|
+
isError: false,
|
|
1138
|
+
resultPreview: "total 4",
|
|
1139
|
+
},
|
|
1140
|
+
{
|
|
1141
|
+
toolName: "file_read",
|
|
1142
|
+
toolUseId: undefined,
|
|
1143
|
+
isError: undefined,
|
|
1144
|
+
resultPreview: "file contents",
|
|
1145
|
+
},
|
|
1146
|
+
]);
|
|
1147
|
+
});
|
|
1148
|
+
|
|
1149
|
+
test("a callbacks object without the tool-event members doesn't throw", async () => {
|
|
1150
|
+
makeEventEmittingConversation([
|
|
1151
|
+
{
|
|
1152
|
+
type: "tool_use_start",
|
|
1153
|
+
toolName: "web_search",
|
|
1154
|
+
input: {},
|
|
1155
|
+
toolUseId: "toolu-1",
|
|
1156
|
+
},
|
|
1157
|
+
{
|
|
1158
|
+
type: "tool_result",
|
|
1159
|
+
toolName: "web_search",
|
|
1160
|
+
result: "ok",
|
|
1161
|
+
toolUseId: "toolu-1",
|
|
1162
|
+
},
|
|
1163
|
+
]);
|
|
1164
|
+
|
|
1165
|
+
const handle = await startVoiceTurn({
|
|
1166
|
+
...makeTurnOptions(),
|
|
1167
|
+
callbacks: {},
|
|
1168
|
+
});
|
|
1169
|
+
await flushMicrotasks();
|
|
1170
|
+
|
|
1171
|
+
expect(handle.turnId).toBeString();
|
|
1172
|
+
});
|
|
1173
|
+
});
|
|
@@ -30,6 +30,7 @@ import { publishConversationMessagesChanged } from "../runtime/sync/resource-syn
|
|
|
30
30
|
import { computeToolApprovalDigest } from "../security/tool-approval-digest.js";
|
|
31
31
|
import { createAbortReason } from "../util/abort-reasons.js";
|
|
32
32
|
import { getLogger } from "../util/logger.js";
|
|
33
|
+
import { truncate } from "../util/truncate.js";
|
|
33
34
|
import {
|
|
34
35
|
CALL_OPENING_MARKER,
|
|
35
36
|
CALL_VERIFICATION_COMPLETE_MARKER,
|
|
@@ -149,6 +150,29 @@ export function getConversationTurnTeardown(
|
|
|
149
150
|
// Types
|
|
150
151
|
// ---------------------------------------------------------------------------
|
|
151
152
|
|
|
153
|
+
/**
|
|
154
|
+
* Max length of the tool-result preview forwarded to voice callbacks. The
|
|
155
|
+
* single truncation point for tool results entering the voice layer.
|
|
156
|
+
*/
|
|
157
|
+
export const TOOL_RESULT_PREVIEW_MAX_CHARS = 200;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* A finished tool invocation as forwarded to the voice layer.
|
|
161
|
+
* `toolName` is the name of the tool that produced the result; it is empty
|
|
162
|
+
* only when the daemon loop never observed a tool_use event for the id
|
|
163
|
+
* (e.g. a tool cancelled before it was proposed). `toolUseId` is optional
|
|
164
|
+
* on the wire, so consumers correlate by id when present and fall back to
|
|
165
|
+
* the name. `resultPreview` is the result truncated to
|
|
166
|
+
* {@link TOOL_RESULT_PREVIEW_MAX_CHARS} at the bridge — the raw result can
|
|
167
|
+
* be huge and must never travel further into the voice layer.
|
|
168
|
+
*/
|
|
169
|
+
export interface VoiceToolResultEvent {
|
|
170
|
+
toolName: string;
|
|
171
|
+
toolUseId?: string;
|
|
172
|
+
isError?: boolean;
|
|
173
|
+
resultPreview: string;
|
|
174
|
+
}
|
|
175
|
+
|
|
152
176
|
/**
|
|
153
177
|
* Real-time event sink for voice TTS streaming. Agent-loop events are
|
|
154
178
|
* forwarded here for real-time text-to-speech without modifying the
|
|
@@ -165,7 +189,12 @@ export interface VoiceRunEventSink {
|
|
|
165
189
|
>,
|
|
166
190
|
): void;
|
|
167
191
|
onError(message: string): void;
|
|
168
|
-
onToolUse(
|
|
192
|
+
onToolUse(
|
|
193
|
+
toolName: string,
|
|
194
|
+
input: Record<string, unknown>,
|
|
195
|
+
toolUseId?: string,
|
|
196
|
+
): void;
|
|
197
|
+
onToolResult(event: VoiceToolResultEvent): void;
|
|
169
198
|
}
|
|
170
199
|
|
|
171
200
|
export interface VoiceTurnCallbacks {
|
|
@@ -181,7 +210,9 @@ export interface VoiceTurnCallbacks {
|
|
|
181
210
|
persisted_user_message_id?: (messageId: string) => void;
|
|
182
211
|
persisted_assistant_message_id?: (messageId: string) => void;
|
|
183
212
|
/** Fired when the agent run starts a definitive tool use this turn. */
|
|
184
|
-
tool_use_start?: (toolName: string) => void;
|
|
213
|
+
tool_use_start?: (toolName: string, detail?: { toolUseId?: string }) => void;
|
|
214
|
+
/** Fired when a tool invocation finishes. */
|
|
215
|
+
tool_result?: (event: VoiceToolResultEvent) => void;
|
|
185
216
|
}
|
|
186
217
|
|
|
187
218
|
export interface VoiceTurnOptions {
|
|
@@ -420,9 +451,12 @@ export async function startVoiceTurn(
|
|
|
420
451
|
onError: (message) => {
|
|
421
452
|
opts.onError?.(message);
|
|
422
453
|
},
|
|
423
|
-
onToolUse: (toolName, input) => {
|
|
454
|
+
onToolUse: (toolName, input, toolUseId) => {
|
|
424
455
|
log.debug({ toolName, input }, "Voice turn tool_use event");
|
|
425
|
-
opts.callbacks?.tool_use_start?.(toolName);
|
|
456
|
+
opts.callbacks?.tool_use_start?.(toolName, { toolUseId });
|
|
457
|
+
},
|
|
458
|
+
onToolResult: (event) => {
|
|
459
|
+
opts.callbacks?.tool_result?.(event);
|
|
426
460
|
},
|
|
427
461
|
};
|
|
428
462
|
|
|
@@ -1011,7 +1045,17 @@ export async function startVoiceTurn(
|
|
|
1011
1045
|
} else if (msg.type === "conversation_error") {
|
|
1012
1046
|
eventSink.onError(msg.userMessage);
|
|
1013
1047
|
} else if (msg.type === "tool_use_start") {
|
|
1014
|
-
eventSink.onToolUse(msg.toolName, msg.input);
|
|
1048
|
+
eventSink.onToolUse(msg.toolName, msg.input, msg.toolUseId);
|
|
1049
|
+
} else if (msg.type === "tool_result") {
|
|
1050
|
+
eventSink.onToolResult({
|
|
1051
|
+
toolName: msg.toolName,
|
|
1052
|
+
toolUseId: msg.toolUseId,
|
|
1053
|
+
isError: msg.isError,
|
|
1054
|
+
resultPreview: truncate(
|
|
1055
|
+
msg.result,
|
|
1056
|
+
TOOL_RESULT_PREVIEW_MAX_CHARS,
|
|
1057
|
+
),
|
|
1058
|
+
});
|
|
1015
1059
|
}
|
|
1016
1060
|
// Note: tool_use_preview_start is intentionally not handled here.
|
|
1017
1061
|
// Voice only reacts to the definitive tool_use_start event.
|
|
@@ -84,6 +84,11 @@ Examples:
|
|
|
84
84
|
flags: "--search <query>",
|
|
85
85
|
description: "Filter nodes whose content contains <query>",
|
|
86
86
|
},
|
|
87
|
+
{
|
|
88
|
+
flags: "--kind <kind>",
|
|
89
|
+
description:
|
|
90
|
+
"Restrict to auto-seeded capability nodes: 'skill' or 'cli'",
|
|
91
|
+
},
|
|
87
92
|
{
|
|
88
93
|
flags: "--limit <n>",
|
|
89
94
|
description: "Max results (default 50, max 200)",
|
|
@@ -96,12 +101,20 @@ Examples:
|
|
|
96
101
|
helpText: `
|
|
97
102
|
Behavior:
|
|
98
103
|
Returns active (non-deleted) memory graph nodes ordered by significance.
|
|
99
|
-
With --search, all nodes are scanned so the filter is exhaustive
|
|
100
|
-
of graph size.
|
|
101
|
-
DB level for efficiency.
|
|
104
|
+
With --search or --kind, all nodes are scanned so the filter is exhaustive
|
|
105
|
+
regardless of graph size. With neither, the query is capped at --limit rows
|
|
106
|
+
at the DB level for efficiency.
|
|
107
|
+
|
|
108
|
+
--kind filters to the capability nodes auto-seeded from the assistant's
|
|
109
|
+
own catalog — one 'skill' node per enabled/catalog skill, one 'cli' node
|
|
110
|
+
per CLI command. This answers "which skills have a node in memory": each
|
|
111
|
+
matching row's content names the skill and its id. Combine with --search
|
|
112
|
+
to narrow to a specific capability. Filters compose (both must match).
|
|
102
113
|
|
|
103
114
|
Examples:
|
|
104
115
|
$ assistant memory nodes list
|
|
116
|
+
$ assistant memory nodes list --kind skill
|
|
117
|
+
$ assistant memory nodes list --kind skill --search "pdf"
|
|
105
118
|
$ assistant memory nodes list --search "coffee" --limit 10
|
|
106
119
|
$ assistant memory nodes list --json`,
|
|
107
120
|
},
|
|
@@ -50,7 +50,12 @@ export function registerMemoryNodesCommand(memory: Command): void {
|
|
|
50
50
|
.alias("ls")
|
|
51
51
|
.action(
|
|
52
52
|
async (
|
|
53
|
-
opts: {
|
|
53
|
+
opts: {
|
|
54
|
+
search?: string;
|
|
55
|
+
limit?: string;
|
|
56
|
+
kind?: string;
|
|
57
|
+
json?: boolean;
|
|
58
|
+
},
|
|
54
59
|
cmd: Command,
|
|
55
60
|
) => {
|
|
56
61
|
const queryParams: Record<string, string> = {};
|
|
@@ -60,6 +65,9 @@ export function registerMemoryNodesCommand(memory: Command): void {
|
|
|
60
65
|
if (opts.limit) {
|
|
61
66
|
queryParams.limit = opts.limit;
|
|
62
67
|
}
|
|
68
|
+
if (opts.kind) {
|
|
69
|
+
queryParams.kind = opts.kind;
|
|
70
|
+
}
|
|
63
71
|
const r = await cliIpcCall<ListMemoryNodesResult>("listMemoryNodes", {
|
|
64
72
|
queryParams,
|
|
65
73
|
});
|
|
@@ -80,9 +88,10 @@ export function registerMemoryNodesCommand(memory: Command): void {
|
|
|
80
88
|
}
|
|
81
89
|
|
|
82
90
|
if (result.nodes.length === 0) {
|
|
91
|
+
const suffix = describeFilters(opts);
|
|
83
92
|
log.info(
|
|
84
|
-
|
|
85
|
-
? `No memory nodes found
|
|
93
|
+
suffix
|
|
94
|
+
? `No memory nodes found ${suffix}.`
|
|
86
95
|
: "No memory nodes found. The memory graph is empty.",
|
|
87
96
|
);
|
|
88
97
|
return;
|
|
@@ -121,9 +130,10 @@ export function registerMemoryNodesCommand(memory: Command): void {
|
|
|
121
130
|
);
|
|
122
131
|
}
|
|
123
132
|
|
|
133
|
+
const suffix = describeFilters(opts);
|
|
124
134
|
console.log(
|
|
125
135
|
`\n${result.total} node${result.total === 1 ? "" : "s"}${
|
|
126
|
-
|
|
136
|
+
suffix ? ` ${suffix}` : ""
|
|
127
137
|
}`,
|
|
128
138
|
);
|
|
129
139
|
},
|
|
@@ -237,6 +247,21 @@ export function registerMemoryNodesCommand(memory: Command): void {
|
|
|
237
247
|
);
|
|
238
248
|
}
|
|
239
249
|
|
|
250
|
+
/**
|
|
251
|
+
* Human-readable trailing clause describing the active list filters, e.g.
|
|
252
|
+
* `of kind "skill" matching "coffee"`. Returns "" when no filter is set.
|
|
253
|
+
*/
|
|
254
|
+
function describeFilters(opts: { kind?: string; search?: string }): string {
|
|
255
|
+
const parts: string[] = [];
|
|
256
|
+
if (opts.kind) {
|
|
257
|
+
parts.push(`of kind "${opts.kind}"`);
|
|
258
|
+
}
|
|
259
|
+
if (opts.search) {
|
|
260
|
+
parts.push(`matching "${opts.search}"`);
|
|
261
|
+
}
|
|
262
|
+
return parts.join(" ");
|
|
263
|
+
}
|
|
264
|
+
|
|
240
265
|
const MEMORY_TYPES = [
|
|
241
266
|
"episodic",
|
|
242
267
|
"semantic",
|
|
@@ -51,7 +51,7 @@ Examples:
|
|
|
51
51
|
{ flags: "--force", description: "Overwrite an existing install" },
|
|
52
52
|
{
|
|
53
53
|
flags: "--ref <ref>",
|
|
54
|
-
description: `
|
|
54
|
+
description: `For a marketplace install, the manifest revision to read the pin from (default: ${DEFAULT_PLUGIN_REF}). For a GitHub URL, the git ref (branch/tag/SHA) to clone — states a slash-containing branch (e.g. feature/x) explicitly and skips the remote ref lookup a bare /tree/ URL otherwise does`,
|
|
55
55
|
},
|
|
56
56
|
{
|
|
57
57
|
flags: "--pin <sha>",
|
|
@@ -75,11 +75,15 @@ bypassing the marketplace whitelist. Such a plugin is UNTRUSTED — it has not
|
|
|
75
75
|
been reviewed and its hooks/tools run with full assistant access — so the
|
|
76
76
|
install prints a warning. Use it for a plugin still under development that is
|
|
77
77
|
not in the catalog yet. The ref comes from the URL's /tree/<ref>/ segment, or
|
|
78
|
-
defaults to the repository's default branch.
|
|
78
|
+
defaults to the repository's default branch. A branch whose name contains a
|
|
79
|
+
slash (e.g. feature/x) is resolved automatically against the repo's refs, just
|
|
80
|
+
as github.com does — paste the /tree/ URL as-is, or pass --ref to skip the
|
|
81
|
+
lookup (e.g. offline, or to force a specific ref).
|
|
79
82
|
|
|
80
83
|
Examples:
|
|
81
84
|
$ assistant plugins install https://github.com/owner/repo
|
|
82
85
|
$ assistant plugins install https://github.com/owner/repo/tree/my-branch/path/to/plugin
|
|
86
|
+
$ assistant plugins install https://github.com/owner/repo/tree/feat/results-viewer/path
|
|
83
87
|
$ assistant plugins install owner/repo --name my-plugin --force`,
|
|
84
88
|
},
|
|
85
89
|
{
|