@vellumai/assistant 0.8.9 → 0.8.10-dev.202606092334.09948c8
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/AGENTS.md +1 -1
- package/examples/plugins/echo/README.md +3 -3
- package/node_modules/@vellumai/skill-host-contracts/src/tool-types.ts +2 -0
- package/openapi.yaml +38 -12
- package/package.json +1 -1
- package/scripts/sync-llm-catalog.ts +2 -0
- package/src/__tests__/agent-loop-exit-reason.test.ts +21 -15
- package/src/__tests__/approval-cascade.test.ts +1 -0
- package/src/__tests__/build-persisted-content.test.ts +75 -1
- package/src/__tests__/compaction-events.test.ts +1 -0
- package/src/__tests__/config-managed-gemini-defaults.test.ts +2 -46
- package/src/__tests__/context-overflow-reducer.test.ts +264 -124
- package/src/__tests__/context-window-manager-overflow-rung.test.ts +351 -0
- package/src/__tests__/conversation-abort-tool-results.test.ts +1 -0
- package/src/__tests__/conversation-agent-loop-inference-profile.test.ts +11 -0
- package/src/__tests__/conversation-agent-loop-overflow.test.ts +90 -49
- package/src/__tests__/conversation-agent-loop.test.ts +113 -64
- package/src/__tests__/conversation-confirmation-signals.test.ts +1 -0
- package/src/__tests__/conversation-fork-crud.test.ts +110 -0
- package/src/__tests__/conversation-process-callsite.test.ts +1 -0
- package/src/__tests__/conversation-provider-retry-repair.test.ts +48 -48
- package/src/__tests__/conversation-queue.test.ts +1 -0
- package/src/__tests__/conversation-runtime-assembly.test.ts +119 -8
- package/src/__tests__/conversation-slash-queue.test.ts +1 -0
- package/src/__tests__/conversation-slash-unknown.test.ts +1 -0
- package/src/__tests__/conversation-speed-override.test.ts +1 -0
- package/src/__tests__/conversation-surfaces-app-control.test.ts +4 -1
- package/src/__tests__/conversation-tool-setup-app-refresh.test.ts +91 -142
- package/src/__tests__/conversation-tool-setup-skill-attribution.test.ts +116 -0
- package/src/__tests__/conversation-tool-setup-test-helpers.ts +98 -0
- package/src/__tests__/conversation-workspace-cache-state.test.ts +1 -0
- package/src/__tests__/conversation-workspace-injection.test.ts +1 -0
- package/src/__tests__/conversation-workspace-tool-tracking.test.ts +1 -0
- package/src/__tests__/corrected-target.test.ts +93 -0
- package/src/__tests__/credential-execution-feature-gates.test.ts +3 -5
- package/src/__tests__/credential-security-invariants.test.ts +1 -0
- package/src/__tests__/embedding-managed-proxy-selection.test.ts +6 -40
- package/src/__tests__/external-plugin-loader.test.ts +0 -1
- package/src/__tests__/guardian-routing-invariants.test.ts +91 -0
- package/src/__tests__/history-repair-hook.test.ts +2 -0
- package/src/__tests__/host-app-control-proxy.test.ts +45 -0
- package/src/__tests__/llm-catalog-parity.test.ts +4 -0
- package/src/__tests__/memory-retrieval-hook.test.ts +29 -15
- package/src/__tests__/notification-decision-strategy.test.ts +3 -3
- package/src/__tests__/persistence-secret-redaction.test.ts +78 -0
- package/src/__tests__/plugin-bootstrap.test.ts +82 -73
- package/src/__tests__/plugin-tool-contribution.test.ts +7 -4
- package/src/__tests__/plugin-types.test.ts +0 -8
- package/src/__tests__/provider-catalog-visibility.test.ts +1 -9
- package/src/__tests__/retry-thinking-adaptive-only.test.ts +245 -0
- package/src/__tests__/server-history-render.test.ts +39 -0
- package/src/__tests__/skills.test.ts +123 -0
- package/src/__tests__/title-generate-hook.test.ts +2 -0
- package/src/__tests__/tool-audit-listener.test.ts +51 -0
- package/src/__tests__/tool-executor-lifecycle-events.test.ts +32 -0
- package/src/__tests__/tool-start-timestamp.test.ts +218 -0
- package/src/agent/loop.ts +26 -39
- package/src/api/events/tool-result.ts +9 -0
- package/src/api/events/tool-use-start.ts +7 -0
- package/src/api/responses/conversation-message.ts +91 -14
- package/src/approvals/guardian-request-resolvers.ts +26 -0
- package/src/cli/commands/channel-verification-sessions.ts +6 -6
- package/src/cli/commands/inference-providers.ts +0 -8
- package/src/cli/commands/plugins.ts +2 -2
- package/src/cli/lib/__tests__/install-from-github.test.ts +174 -18
- package/src/cli/lib/__tests__/plugin-catalog-cache.test.ts +1 -1
- package/src/cli/lib/__tests__/plugin-details.test.ts +1 -1
- package/src/cli/lib/__tests__/plugin-marketplace.test.ts +1 -1
- package/src/cli/lib/__tests__/search-plugins.test.ts +11 -11
- package/src/cli/lib/install-from-github.ts +130 -19
- package/src/cli/lib/plugin-catalog-cache.ts +1 -1
- package/src/cli/lib/plugin-details.ts +4 -4
- package/src/cli/lib/plugin-marketplace.ts +2 -2
- package/src/cli/lib/search-plugins.ts +6 -6
- package/src/config/bundled-skills/skill-management/SKILL.md +89 -1
- package/src/config/env-registry.ts +12 -0
- package/src/config/feature-flag-registry.json +0 -80
- package/src/config/loader.ts +5 -22
- package/src/config/seed-inference-profiles.ts +1 -1
- package/src/config/skills.ts +101 -47
- package/src/context/strip-injections.ts +7 -4
- package/src/daemon/conversation-agent-loop-handlers.ts +102 -6
- package/src/daemon/conversation-agent-loop.ts +126 -270
- package/src/daemon/conversation-runtime-assembly.ts +44 -8
- package/src/daemon/conversation-tool-setup.ts +9 -1
- package/src/daemon/conversation.ts +13 -0
- package/src/daemon/external-plugins-bootstrap.ts +33 -87
- package/src/daemon/handlers/config-channels.ts +11 -2
- package/src/daemon/handlers/shared.ts +9 -1
- package/src/daemon/handlers/skills.ts +6 -2
- package/src/daemon/host-app-control-proxy.ts +72 -57
- package/src/daemon/message-protocol.ts +0 -7
- package/src/daemon/message-types/skills.ts +4 -0
- package/src/events/tool-audit-listener.ts +7 -1
- package/src/memory/__tests__/tool-invocation-test-helpers.ts +69 -0
- package/src/memory/conversation-crud.ts +44 -1
- package/src/memory/db-init.ts +4 -0
- package/src/memory/embedding-backend.ts +5 -22
- package/src/memory/memory-retrospective-startup-cleanup.ts +1 -1
- package/src/memory/migrations/275-tool-invocations-add-skill-id.test.ts +81 -0
- package/src/memory/migrations/275-tool-invocations-add-skill-id.ts +20 -0
- package/src/memory/migrations/276-tool-invocations-created-at-id-index.test.ts +68 -0
- package/src/memory/migrations/276-tool-invocations-created-at-id-index.ts +20 -0
- package/src/memory/migrations/index.ts +2 -0
- package/src/memory/schema/conversations.ts +3 -0
- package/src/memory/tool-execution-events-store.test.ts +162 -0
- package/src/memory/tool-execution-events-store.ts +73 -0
- package/src/memory/tool-usage-store.ts +4 -3
- package/src/memory/v2/__tests__/injected-block-slugs.test.ts +51 -0
- package/src/memory/v2/activation-store.ts +50 -1
- package/src/memory/v2/injected-block-slugs.ts +30 -0
- package/src/notifications/__tests__/copy-composer.test.ts +244 -0
- package/src/notifications/access-request-copy.ts +298 -0
- package/src/notifications/adapters/slack.ts +3 -3
- package/src/notifications/adapters/telegram.ts +2 -1
- package/src/notifications/copy-composer.ts +49 -267
- package/src/notifications/decision-engine.ts +16 -35
- package/src/notifications/home-feed-side-effect.ts +1 -6
- package/src/platform/client.ts +1 -3
- package/src/platform/feature-gate.ts +3 -12
- package/src/plugin-api/constants.ts +2 -0
- package/src/plugin-api/index.ts +37 -6
- package/src/plugin-api/types.ts +75 -0
- package/src/plugins/defaults/compaction/compact.ts +39 -1
- package/src/plugins/defaults/compaction/context-overflow-reducer.ts +240 -32
- package/src/plugins/defaults/compaction/corrected-target.ts +53 -0
- package/src/plugins/defaults/compaction/window-manager.ts +195 -1
- package/src/plugins/defaults/index.ts +24 -0
- package/src/plugins/defaults/memory-retrieval/hooks/post-compact.ts +76 -112
- package/src/plugins/defaults/memory-retrieval/hooks/{user-prompt-submit-temp.ts → user-prompt-submit.ts} +36 -67
- package/src/plugins/defaults/memory-retrieval/package.json +14 -0
- package/src/plugins/external-api.ts +1 -1
- package/src/plugins/types.ts +5 -51
- package/src/providers/inference/__tests__/base-url-route-validation.test.ts +1 -2
- package/src/providers/model-catalog.ts +57 -1
- package/src/providers/registry.ts +0 -8
- package/src/providers/retry.ts +35 -7
- package/src/runtime/routes/__tests__/acp-routes.test.ts +151 -0
- package/src/runtime/routes/__tests__/inference-provider-connection-routes.test.ts +0 -62
- package/src/runtime/routes/__tests__/plugins-routes.test.ts +4 -4
- package/src/runtime/routes/acp-routes.test.ts +106 -0
- package/src/runtime/routes/acp-routes.ts +248 -2
- package/src/runtime/routes/browser-tabs-routes.ts +1 -1
- package/src/runtime/routes/channel-verification-routes.ts +14 -5
- package/src/runtime/routes/chatgpt-subscription-auth-routes.ts +0 -14
- package/src/runtime/routes/inbound-stages/acl-enforcement.ts +33 -34
- package/src/runtime/routes/inference-provider-connection-routes.ts +0 -45
- package/src/runtime/routes/plugins-routes.ts +3 -3
- package/src/runtime/verification-outbound-actions.ts +147 -2
- package/src/runtime/verification-templates.ts +29 -3
- package/src/telemetry/types.ts +25 -1
- package/src/telemetry/usage-telemetry-reporter.test.ts +141 -7
- package/src/telemetry/usage-telemetry-reporter.ts +63 -7
- package/src/tools/executor.ts +4 -1
- package/src/tools/skills/load.ts +11 -6
- package/src/tools/terminal/safe-env.ts +1 -0
- package/src/tools/types.ts +10 -0
- package/src/__tests__/plugin-skill-contribution.test.ts +0 -355
- package/src/daemon/message-types/browser.ts +0 -10
- package/src/notifications/__tests__/emit-signal-home-feed.test.ts +0 -187
- package/src/plugins/plugin-skill-contributions.ts +0 -292
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for `handleToolUse` stamping a tool start time both on the live
|
|
3
|
+
* `tool_use_start` event and on the already-durable persisted tool_use block.
|
|
4
|
+
*
|
|
5
|
+
* The live event carries `startedAt` so clients can anchor a running
|
|
6
|
+
* elapsed-time counter to the server clock instead of SSE receipt time. The
|
|
7
|
+
* persisted `_startedAt` (mapped to the wire `startedAt` in handlers/shared.ts)
|
|
8
|
+
* lets a `/messages` snapshot fetched mid-tool — e.g. after a refresh or
|
|
9
|
+
* reconnect, before the live event was seen — still render that counter.
|
|
10
|
+
*/
|
|
11
|
+
import { beforeEach, describe, expect, mock, test } from "bun:test";
|
|
12
|
+
|
|
13
|
+
// ── Mock platform (must precede imports that read it) ─────────────────────────
|
|
14
|
+
mock.module("../util/logger.js", () => ({
|
|
15
|
+
getLogger: () =>
|
|
16
|
+
new Proxy({} as Record<string, unknown>, {
|
|
17
|
+
get: () => () => {},
|
|
18
|
+
}),
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
mock.module("../config/loader.js", () => ({
|
|
22
|
+
getConfig: () => ({
|
|
23
|
+
skills: {
|
|
24
|
+
entries: {},
|
|
25
|
+
load: { extraDirs: [], watch: false, watchDebounceMs: 0 },
|
|
26
|
+
install: { nodeManager: "npm" },
|
|
27
|
+
allowBundled: null,
|
|
28
|
+
remoteProviders: {
|
|
29
|
+
skillssh: { enabled: true },
|
|
30
|
+
clawhub: { enabled: true },
|
|
31
|
+
},
|
|
32
|
+
remotePolicy: {
|
|
33
|
+
blockSuspicious: true,
|
|
34
|
+
blockMalware: true,
|
|
35
|
+
maxSkillsShRisk: "medium",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
}),
|
|
39
|
+
loadConfig: () => ({}),
|
|
40
|
+
}));
|
|
41
|
+
|
|
42
|
+
let mockedRowContent = "";
|
|
43
|
+
const updates: Array<{ id: string; content: string }> = [];
|
|
44
|
+
|
|
45
|
+
mock.module("../memory/conversation-crud.js", () => ({
|
|
46
|
+
addMessage: () => ({ id: "mock-msg-id" }),
|
|
47
|
+
getMessageById: (id: string) =>
|
|
48
|
+
mockedRowContent ? { id, content: mockedRowContent } : null,
|
|
49
|
+
updateMessageContent: (id: string, content: string) => {
|
|
50
|
+
updates.push({ id, content });
|
|
51
|
+
},
|
|
52
|
+
provenanceFromTrustContext: () => ({}),
|
|
53
|
+
reserveMessage: mock(async () => ({ id: "msg-reserve" })),
|
|
54
|
+
}));
|
|
55
|
+
|
|
56
|
+
mock.module("../memory/llm-request-log-store.js", () => ({
|
|
57
|
+
recordRequestLog: () => {},
|
|
58
|
+
backfillMessageIdOnLogs: () => {},
|
|
59
|
+
}));
|
|
60
|
+
|
|
61
|
+
mock.module("../runtime/assistant-stream-state.js", () => ({
|
|
62
|
+
getCurrentSeq: () => 0,
|
|
63
|
+
recordPersistedSeq: () => {},
|
|
64
|
+
}));
|
|
65
|
+
|
|
66
|
+
// ── Imports (after mocks) ─────────────────────────────────────────────────────
|
|
67
|
+
import type { AgentEvent } from "../agent/loop.js";
|
|
68
|
+
import type {
|
|
69
|
+
EventHandlerDeps,
|
|
70
|
+
EventHandlerState,
|
|
71
|
+
} from "../daemon/conversation-agent-loop-handlers.js";
|
|
72
|
+
import {
|
|
73
|
+
createEventHandlerState,
|
|
74
|
+
handleToolUse,
|
|
75
|
+
} from "../daemon/conversation-agent-loop-handlers.js";
|
|
76
|
+
import type { ServerMessage } from "../daemon/message-protocol.js";
|
|
77
|
+
|
|
78
|
+
// ── Helpers ───────────────────────────────────────────────────────────────────
|
|
79
|
+
|
|
80
|
+
function makeDeps(onEvent: (event: ServerMessage) => void): EventHandlerDeps {
|
|
81
|
+
return {
|
|
82
|
+
ctx: {
|
|
83
|
+
conversationId: "test-conv",
|
|
84
|
+
provider: { name: "anthropic" },
|
|
85
|
+
traceEmitter: { emit: () => {} },
|
|
86
|
+
streamThinking: false,
|
|
87
|
+
emitActivityState: () => {},
|
|
88
|
+
markWorkspaceTopLevelDirty: () => {},
|
|
89
|
+
currentTurnSurfaces: [],
|
|
90
|
+
} as unknown as EventHandlerDeps["ctx"],
|
|
91
|
+
onEvent,
|
|
92
|
+
reqId: "test-req",
|
|
93
|
+
isFirstMessage: false,
|
|
94
|
+
shouldGenerateTitle: false,
|
|
95
|
+
rlog: new Proxy({} as Record<string, unknown>, {
|
|
96
|
+
get: () => () => {},
|
|
97
|
+
}) as unknown as EventHandlerDeps["rlog"],
|
|
98
|
+
turnChannelContext: {
|
|
99
|
+
userMessageChannel: "vellum",
|
|
100
|
+
assistantMessageChannel: "vellum",
|
|
101
|
+
} as unknown as EventHandlerDeps["turnChannelContext"],
|
|
102
|
+
turnInterfaceContext: {
|
|
103
|
+
userMessageInterface: "web",
|
|
104
|
+
assistantMessageInterface: "web",
|
|
105
|
+
} as unknown as EventHandlerDeps["turnInterfaceContext"],
|
|
106
|
+
applyCompaction: async () => {},
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function toolUseEvent(
|
|
111
|
+
id: string,
|
|
112
|
+
name: string,
|
|
113
|
+
): Extract<AgentEvent, { type: "tool_use" }> {
|
|
114
|
+
return { type: "tool_use", id, name, input: { command: "ls" } };
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function findBlockById(
|
|
118
|
+
rawContent: string,
|
|
119
|
+
id: string,
|
|
120
|
+
): Record<string, unknown> {
|
|
121
|
+
const parsed = JSON.parse(rawContent) as Array<Record<string, unknown>>;
|
|
122
|
+
const block = parsed.find((b) => b.id === id);
|
|
123
|
+
if (!block) throw new Error(`block ${id} not found`);
|
|
124
|
+
return block;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// ── Tests ─────────────────────────────────────────────────────────────────────
|
|
128
|
+
|
|
129
|
+
describe("handleToolUse — tool start timestamp", () => {
|
|
130
|
+
beforeEach(() => {
|
|
131
|
+
updates.length = 0;
|
|
132
|
+
mockedRowContent = "";
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
test("emits a numeric startedAt on the tool_use_start event and records it in state", () => {
|
|
136
|
+
// GIVEN a fresh handler state with a persisted assistant message
|
|
137
|
+
const toolUseId = "tu_bash";
|
|
138
|
+
const state: EventHandlerState = createEventHandlerState();
|
|
139
|
+
state.lastAssistantMessageId = "msg-1";
|
|
140
|
+
mockedRowContent = JSON.stringify([
|
|
141
|
+
{
|
|
142
|
+
type: "tool_use",
|
|
143
|
+
id: toolUseId,
|
|
144
|
+
name: "bash",
|
|
145
|
+
input: { command: "ls" },
|
|
146
|
+
},
|
|
147
|
+
]);
|
|
148
|
+
const events: ServerMessage[] = [];
|
|
149
|
+
const before = Date.now();
|
|
150
|
+
|
|
151
|
+
// WHEN the tool begins
|
|
152
|
+
handleToolUse(
|
|
153
|
+
state,
|
|
154
|
+
makeDeps((e) => events.push(e)),
|
|
155
|
+
toolUseEvent(toolUseId, "bash"),
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
// THEN the emitted tool_use_start carries a numeric startedAt within the
|
|
159
|
+
// execution window AND the same value is recorded in toolCallTimestamps
|
|
160
|
+
const startEvent = events.find((e) => e.type === "tool_use_start");
|
|
161
|
+
expect(startEvent?.type).toBe("tool_use_start");
|
|
162
|
+
const startedAt =
|
|
163
|
+
startEvent?.type === "tool_use_start" ? startEvent.startedAt : undefined;
|
|
164
|
+
expect(typeof startedAt).toBe("number");
|
|
165
|
+
expect(startedAt).toBeGreaterThanOrEqual(before);
|
|
166
|
+
expect(startedAt).toBeLessThanOrEqual(Date.now());
|
|
167
|
+
expect(state.toolCallTimestamps.get(toolUseId)?.startedAt).toBe(startedAt);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
test("stamps _startedAt onto the in-flight persisted tool_use block", () => {
|
|
171
|
+
// GIVEN a durable tool_use block with no timing metadata yet
|
|
172
|
+
const toolUseId = "tu_bash";
|
|
173
|
+
const state: EventHandlerState = createEventHandlerState();
|
|
174
|
+
state.lastAssistantMessageId = "msg-1";
|
|
175
|
+
mockedRowContent = JSON.stringify([
|
|
176
|
+
{
|
|
177
|
+
type: "tool_use",
|
|
178
|
+
id: toolUseId,
|
|
179
|
+
name: "bash",
|
|
180
|
+
input: { command: "ls" },
|
|
181
|
+
},
|
|
182
|
+
]);
|
|
183
|
+
const events: ServerMessage[] = [];
|
|
184
|
+
|
|
185
|
+
// WHEN the tool begins
|
|
186
|
+
handleToolUse(
|
|
187
|
+
state,
|
|
188
|
+
makeDeps((e) => events.push(e)),
|
|
189
|
+
toolUseEvent(toolUseId, "bash"),
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
// THEN the persisted block is updated with _startedAt matching the event,
|
|
193
|
+
// so a mid-tool snapshot surfaces the start time via handlers/shared.ts
|
|
194
|
+
expect(updates).toHaveLength(1);
|
|
195
|
+
const block = findBlockById(updates[0].content, toolUseId);
|
|
196
|
+
const startEvent = events.find((e) => e.type === "tool_use_start");
|
|
197
|
+
const startedAt =
|
|
198
|
+
startEvent?.type === "tool_use_start" ? startEvent.startedAt : undefined;
|
|
199
|
+
expect(block._startedAt).toBe(startedAt);
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
test("does not write when no persisted block matches the tool id", () => {
|
|
203
|
+
// GIVEN a persisted message whose only block is unrelated to the tool
|
|
204
|
+
const state: EventHandlerState = createEventHandlerState();
|
|
205
|
+
state.lastAssistantMessageId = "msg-1";
|
|
206
|
+
mockedRowContent = JSON.stringify([{ type: "text", text: "thinking" }]);
|
|
207
|
+
|
|
208
|
+
// WHEN a tool begins
|
|
209
|
+
handleToolUse(
|
|
210
|
+
state,
|
|
211
|
+
makeDeps(() => {}),
|
|
212
|
+
toolUseEvent("tu_missing", "bash"),
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
// THEN no persisted-content write is attempted
|
|
216
|
+
expect(updates).toHaveLength(0);
|
|
217
|
+
});
|
|
218
|
+
});
|
package/src/agent/loop.ts
CHANGED
|
@@ -10,12 +10,12 @@ import {
|
|
|
10
10
|
estimateToolsTokens,
|
|
11
11
|
getCalibrationProviderKey,
|
|
12
12
|
} from "../context/token-estimator.js";
|
|
13
|
-
import type { InboundActorContext } from "../daemon/conversation-runtime-assembly.js";
|
|
14
13
|
import type { ToolActivityMetadata } from "../daemon/message-types/web-activity.js";
|
|
15
14
|
import type { TrustContext } from "../daemon/trust-context.js";
|
|
16
15
|
import { stripHistoricalWebSearchResults } from "../daemon/web-search-history.js";
|
|
17
16
|
import { HOOKS } from "../plugin-api/constants.js";
|
|
18
17
|
import type {
|
|
18
|
+
PostCompactContext,
|
|
19
19
|
PostModelCallContext,
|
|
20
20
|
PostToolUseContext,
|
|
21
21
|
PreModelCallContext,
|
|
@@ -23,7 +23,6 @@ import type {
|
|
|
23
23
|
} from "../plugin-api/types.js";
|
|
24
24
|
import { defaultCompact } from "../plugins/defaults/compaction/compact.js";
|
|
25
25
|
import type { ContextWindowResult } from "../plugins/defaults/compaction/window-manager.js";
|
|
26
|
-
import postCompact from "../plugins/defaults/memory-retrieval/hooks/post-compact.js";
|
|
27
26
|
import { runHook } from "../plugins/pipeline.js";
|
|
28
27
|
import type { CompactionCircuitEvent } from "../plugins/types.js";
|
|
29
28
|
import { normalizeThinkingConfigForWire } from "../providers/thinking-config.js";
|
|
@@ -311,7 +310,7 @@ export type AgentEvent =
|
|
|
311
310
|
* immediately before re-injection — whether or not the pipeline actually
|
|
312
311
|
* compacted. The daemon's event dispatcher always commits `basis` (the
|
|
313
312
|
* stripped pre-compaction history) as the conversation's durable message
|
|
314
|
-
* state, so re-injection (
|
|
313
|
+
* state, so re-injection (the post-compaction hook) re-applies
|
|
315
314
|
* injections onto the stripped base rather than stacking on top of the
|
|
316
315
|
* still-injected messages. When `result.compacted` is set it
|
|
317
316
|
* additionally commits the durable compaction result (DB-record fields,
|
|
@@ -455,8 +454,8 @@ export interface AgentLoopRunOptions {
|
|
|
455
454
|
* Trust classification and channel identity for the turn's inbound actor,
|
|
456
455
|
* supplied by the caller as the turn-start snapshot. Read only on the
|
|
457
456
|
* mid-loop in-place compaction path — to scope the compactor's image
|
|
458
|
-
* manifest (guardian-only attachments are excluded for untrusted actors)
|
|
459
|
-
*
|
|
457
|
+
* manifest (guardian-only attachments are excluded for untrusted actors).
|
|
458
|
+
* Callers without a meaningful actor (agent
|
|
460
459
|
* wakes, standalone unit tests) pass an `unknown`-class snapshot so the
|
|
461
460
|
* compactor fail-closes to excluding guardian-only attachments.
|
|
462
461
|
*/
|
|
@@ -488,7 +487,7 @@ export interface AgentLoopRunOptions {
|
|
|
488
487
|
* proactive turn-start compaction the orchestrator would otherwise perform
|
|
489
488
|
* inline before `run()` — as well as before each tool-use re-entry. When the
|
|
490
489
|
* gate trips it compacts the running history in place, re-applying runtime
|
|
491
|
-
* injections via the default post-compaction hook ({@link
|
|
490
|
+
* injections via the default post-compaction hook ({@link HOOKS.POST_COMPACT}), and
|
|
492
491
|
* continues instead of yielding `exitReason = "budget"`.
|
|
493
492
|
*
|
|
494
493
|
* The first-call pass honors the compaction circuit breaker and proceeds with
|
|
@@ -503,31 +502,20 @@ export interface AgentLoopRunOptions {
|
|
|
503
502
|
/**
|
|
504
503
|
* Whether the in-flight turn has no human present to answer clarification
|
|
505
504
|
* questions. Resolved once by the orchestrator at turn start and forwarded to
|
|
506
|
-
*
|
|
505
|
+
* the post-compaction hook so post-compaction
|
|
507
506
|
* re-injection uses the turn-start snapshot rather than re-reading mutable
|
|
508
507
|
* client/headless state mid-turn. Defaults to `false` when omitted.
|
|
509
508
|
*/
|
|
510
509
|
isNonInteractive?: boolean;
|
|
511
510
|
/**
|
|
512
|
-
* The
|
|
513
|
-
*
|
|
514
|
-
*
|
|
515
|
-
*
|
|
516
|
-
* re-
|
|
517
|
-
*
|
|
518
|
-
* `null` when omitted.
|
|
511
|
+
* The turn's resolved inference-profile key, or `null` when the active
|
|
512
|
+
* profile is unchanged since the last notified one. Forwarded to
|
|
513
|
+
* the post-compaction hook, which renders the `model_profile:` label from it so
|
|
514
|
+
* post-compaction re-injection re-emits the turn-start profile rather than
|
|
515
|
+
* re-deriving the change-detected value (which flips once the notification is
|
|
516
|
+
* persisted mid-turn). Defaults to `null` when omitted.
|
|
519
517
|
*/
|
|
520
|
-
|
|
521
|
-
/**
|
|
522
|
-
* Inbound actor identity and trust fields for the unified `<turn_context>`
|
|
523
|
-
* block, or `null` on guardian turns. Resolved once by the orchestrator at
|
|
524
|
-
* turn start via the actor-trust resolver, whose contact/member registry
|
|
525
|
-
* inputs can be mutated mid-turn by contact tools, and forwarded to
|
|
526
|
-
* {@link postCompact} so post-compaction
|
|
527
|
-
* re-injection re-emits the turn-start value rather than re-resolving it.
|
|
528
|
-
* Defaults to `null` when omitted.
|
|
529
|
-
*/
|
|
530
|
-
actorContext?: InboundActorContext | null;
|
|
518
|
+
modelProfileKey?: string | null;
|
|
531
519
|
}
|
|
532
520
|
|
|
533
521
|
/**
|
|
@@ -715,8 +703,7 @@ export class AgentLoop {
|
|
|
715
703
|
onEvent: (event: AgentEvent) => void | Promise<void>,
|
|
716
704
|
overrideProfile: string | null,
|
|
717
705
|
isNonInteractive: boolean,
|
|
718
|
-
|
|
719
|
-
actorContext: InboundActorContext | null,
|
|
706
|
+
modelProfileKey: string | null,
|
|
720
707
|
): Promise<Message[] | null> {
|
|
721
708
|
await onEvent({ type: "context_compacting" });
|
|
722
709
|
// Strip runtime injections so the compactor summarizes the raw persistent
|
|
@@ -767,18 +754,20 @@ export class AgentLoop {
|
|
|
767
754
|
// Re-inject onto the same base the `compaction_completed` dispatch commits:
|
|
768
755
|
// the compacted messages when the pipeline compacted, the stripped
|
|
769
756
|
// pre-compaction history otherwise.
|
|
770
|
-
const
|
|
757
|
+
const postCompactCtx: PostCompactContext = {
|
|
771
758
|
history: compactResult.compacted ? compactResult.messages : rawHistory,
|
|
772
759
|
requestId,
|
|
773
760
|
conversationId: this.conversationId,
|
|
774
|
-
trust,
|
|
775
761
|
isNonInteractive,
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
762
|
+
modelProfileKey,
|
|
763
|
+
};
|
|
764
|
+
// The hook chain writes the re-injected history back onto the context;
|
|
765
|
+
// read it from there once the chain settles.
|
|
766
|
+
const finalPostCompactCtx = await runHook(
|
|
767
|
+
HOOKS.POST_COMPACT,
|
|
768
|
+
postCompactCtx,
|
|
769
|
+
);
|
|
770
|
+
return finalPostCompactCtx.history;
|
|
782
771
|
}
|
|
783
772
|
|
|
784
773
|
async run(options: AgentLoopRunOptions): Promise<AgentLoopRunResult> {
|
|
@@ -795,8 +784,7 @@ export class AgentLoop {
|
|
|
795
784
|
resolveContextWindow,
|
|
796
785
|
compactInPlace = false,
|
|
797
786
|
isNonInteractive = false,
|
|
798
|
-
|
|
799
|
-
actorContext = null,
|
|
787
|
+
modelProfileKey = null,
|
|
800
788
|
} = options;
|
|
801
789
|
let history = [...messages];
|
|
802
790
|
// Index into `history` where this run's appended output begins. It starts
|
|
@@ -923,8 +911,7 @@ export class AgentLoop {
|
|
|
923
911
|
onEvent,
|
|
924
912
|
resolveEffectiveOverrideProfile() ?? null,
|
|
925
913
|
isNonInteractive,
|
|
926
|
-
|
|
927
|
-
actorContext,
|
|
914
|
+
modelProfileKey,
|
|
928
915
|
);
|
|
929
916
|
if (compacted) {
|
|
930
917
|
history = compacted;
|
|
@@ -124,6 +124,15 @@ export const ToolResultEventSchema = z.object({
|
|
|
124
124
|
approvalReason: z.string().optional(),
|
|
125
125
|
riskThreshold: z.string().optional(),
|
|
126
126
|
activityMetadata: ToolActivityMetadataSchema.optional(),
|
|
127
|
+
/**
|
|
128
|
+
* Unix ms when the daemon finished executing the tool. Pairs with
|
|
129
|
+
* `ToolUseStartEvent.startedAt` so clients can render a final duration that
|
|
130
|
+
* stays on the daemon's clock, matching the live elapsed-time counter and
|
|
131
|
+
* avoiding skew between a server-stamped start and a browser-stamped end.
|
|
132
|
+
* Absent on streams from older daemons; clients fall back to their own
|
|
133
|
+
* receipt time.
|
|
134
|
+
*/
|
|
135
|
+
completedAt: z.number().optional(),
|
|
127
136
|
});
|
|
128
137
|
|
|
129
138
|
export type ToolResultEvent = z.infer<typeof ToolResultEventSchema>;
|
|
@@ -25,6 +25,13 @@ export const ToolUseStartEventSchema = z.object({
|
|
|
25
25
|
toolUseId: z.string().optional(),
|
|
26
26
|
messageId: z.string().optional(),
|
|
27
27
|
conversationId: z.string().optional(),
|
|
28
|
+
/**
|
|
29
|
+
* Unix ms when the daemon began executing the tool. Lets clients anchor a
|
|
30
|
+
* live elapsed-time counter to the server clock instead of the moment the
|
|
31
|
+
* event was received over SSE. Absent on streams from older daemons that
|
|
32
|
+
* pre-date this field; clients fall back to their own receipt time.
|
|
33
|
+
*/
|
|
34
|
+
startedAt: z.number().optional(),
|
|
28
35
|
});
|
|
29
36
|
|
|
30
37
|
export type ToolUseStartEvent = z.infer<typeof ToolUseStartEventSchema>;
|
|
@@ -301,7 +301,14 @@ export type ConversationSlackMessage = z.infer<
|
|
|
301
301
|
*/
|
|
302
302
|
export const ConversationContentBlockSchema = z.discriminatedUnion("type", [
|
|
303
303
|
z.object({ type: z.literal("text"), text: z.string() }),
|
|
304
|
-
z.object({
|
|
304
|
+
z.object({
|
|
305
|
+
type: z.literal("thinking"),
|
|
306
|
+
thinking: z.string(),
|
|
307
|
+
/** Unix ms when the model began emitting this reasoning block. */
|
|
308
|
+
startedAt: z.number().optional(),
|
|
309
|
+
/** Unix ms when this reasoning block completed. */
|
|
310
|
+
completedAt: z.number().optional(),
|
|
311
|
+
}),
|
|
305
312
|
z.object({
|
|
306
313
|
type: z.literal("tool_use"),
|
|
307
314
|
toolCall: ConversationMessageToolCallSchema,
|
|
@@ -350,23 +357,93 @@ export const ConversationMessageSchema = z.object({
|
|
|
350
357
|
*/
|
|
351
358
|
role: z.enum(["user", "assistant"]),
|
|
352
359
|
/**
|
|
353
|
-
* Flat plain-text body (joined
|
|
354
|
-
* `textSegments`/`contentOrder` for clients
|
|
355
|
-
* arrays (web, CLI), but the legacy Swift
|
|
356
|
-
* directly and drops any history row missing it
|
|
357
|
-
* `HistoryReconstructionService` skips rows with empty text). The
|
|
358
|
-
* always emits it — do not remove without updating that client.
|
|
360
|
+
* @deprecated Superseded by `contentBlocks`. Flat plain-text body (joined
|
|
361
|
+
* text segments). Redundant with `textSegments`/`contentOrder` for clients
|
|
362
|
+
* that render from the positional arrays (web, CLI), but the legacy Swift
|
|
363
|
+
* macOS client reads `content` directly and drops any history row missing it
|
|
364
|
+
* (its `HistoryReconstructionService` skips rows with empty text). The
|
|
365
|
+
* serializer always emits it — do not remove without updating that client.
|
|
359
366
|
*/
|
|
360
|
-
content: z
|
|
367
|
+
content: z
|
|
368
|
+
.string()
|
|
369
|
+
.meta({
|
|
370
|
+
deprecated: true,
|
|
371
|
+
description:
|
|
372
|
+
"Deprecated: superseded by contentBlocks. Flat plain-text body (joined text segments).",
|
|
373
|
+
})
|
|
374
|
+
.optional(),
|
|
361
375
|
/** Display timestamp as an ISO-8601 string. */
|
|
362
376
|
timestamp: z.string(),
|
|
377
|
+
/**
|
|
378
|
+
* Flat list of attachment metadata for the row. Not yet supersedable by
|
|
379
|
+
* `contentBlocks`: `renderHistoryContent` emits an `attachment` content
|
|
380
|
+
* block only for file-block refs with an inline placement, so orphan rows
|
|
381
|
+
* (unmatched ids, count mismatch, no DB rows — see `alignAttachments`) ship
|
|
382
|
+
* here alone. Kept non-deprecated until `contentBlocks` reaches attachment
|
|
383
|
+
* parity, so clients that migrate off the positional arrays don't drop those
|
|
384
|
+
* chips.
|
|
385
|
+
*/
|
|
363
386
|
attachments: z.array(ConversationMessageAttachmentSchema),
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
387
|
+
/**
|
|
388
|
+
* @deprecated Superseded by `contentBlocks` (the `tool_use` variant). Flat
|
|
389
|
+
* list of tool calls for the row.
|
|
390
|
+
*/
|
|
391
|
+
toolCalls: z
|
|
392
|
+
.array(ConversationMessageToolCallSchema)
|
|
393
|
+
.meta({
|
|
394
|
+
deprecated: true,
|
|
395
|
+
description:
|
|
396
|
+
"Deprecated: superseded by contentBlocks (the tool_use variant). Flat list of tool calls.",
|
|
397
|
+
})
|
|
398
|
+
.optional(),
|
|
399
|
+
/**
|
|
400
|
+
* @deprecated Superseded by `contentBlocks` (the `surface` variant). Flat
|
|
401
|
+
* list of surfaces for the row.
|
|
402
|
+
*/
|
|
403
|
+
surfaces: z
|
|
404
|
+
.array(ConversationMessageSurfaceSchema)
|
|
405
|
+
.meta({
|
|
406
|
+
deprecated: true,
|
|
407
|
+
description:
|
|
408
|
+
"Deprecated: superseded by contentBlocks (the surface variant). Flat list of surfaces.",
|
|
409
|
+
})
|
|
410
|
+
.optional(),
|
|
411
|
+
/**
|
|
412
|
+
* @deprecated Superseded by `contentBlocks`. Text split by tool-call
|
|
413
|
+
* boundaries; positional sibling of `contentOrder`.
|
|
414
|
+
*/
|
|
415
|
+
textSegments: z
|
|
416
|
+
.array(z.string())
|
|
417
|
+
.meta({
|
|
418
|
+
deprecated: true,
|
|
419
|
+
description:
|
|
420
|
+
"Deprecated: superseded by contentBlocks. Text segments split by tool-call boundaries.",
|
|
421
|
+
})
|
|
422
|
+
.optional(),
|
|
423
|
+
/**
|
|
424
|
+
* @deprecated Superseded by `contentBlocks`. Reasoning text extracted from
|
|
425
|
+
* thinking blocks; positional sibling of `contentOrder`.
|
|
426
|
+
*/
|
|
427
|
+
thinkingSegments: z
|
|
428
|
+
.array(z.string())
|
|
429
|
+
.meta({
|
|
430
|
+
deprecated: true,
|
|
431
|
+
description:
|
|
432
|
+
"Deprecated: superseded by contentBlocks. Reasoning text extracted from thinking blocks.",
|
|
433
|
+
})
|
|
434
|
+
.optional(),
|
|
435
|
+
/**
|
|
436
|
+
* @deprecated Superseded by `contentBlocks`. Positional
|
|
437
|
+
* `"<type>:<index>"` content ordering (e.g. `"text:0"`, `"thinking:1"`).
|
|
438
|
+
*/
|
|
439
|
+
contentOrder: z
|
|
440
|
+
.array(z.string())
|
|
441
|
+
.meta({
|
|
442
|
+
deprecated: true,
|
|
443
|
+
description:
|
|
444
|
+
'Deprecated: superseded by contentBlocks. Positional "<type>:<index>" content ordering (e.g. "text:0", "thinking:1").',
|
|
445
|
+
})
|
|
446
|
+
.optional(),
|
|
370
447
|
/**
|
|
371
448
|
* Unified ordered content blocks — the display-ready projection of the
|
|
372
449
|
* row's model-native content. Ships alongside the positional
|
|
@@ -196,6 +196,32 @@ const pendingInteractionResolver: GuardianRequestResolver = {
|
|
|
196
196
|
// resolveConfirmation() owns pendingInteractions deregistration.
|
|
197
197
|
const userDecision: UserDecision =
|
|
198
198
|
decision.action === "reject" ? "deny" : "allow";
|
|
199
|
+
|
|
200
|
+
// Route-owned confirmations (e.g. the ACP spawn/steer approval gate in
|
|
201
|
+
// acp-routes.ts) carry a `directResolve` and are NOT owned by any
|
|
202
|
+
// Conversation.prompter, so handleConfirmationResponse below would no-op
|
|
203
|
+
// and the caller would block until timeout. Resolve them directly, exactly
|
|
204
|
+
// as the POST /v1/confirm route does (see approval-routes.ts).
|
|
205
|
+
if (interaction.directResolve) {
|
|
206
|
+
pendingInteractions.resolve(
|
|
207
|
+
request.id,
|
|
208
|
+
userDecision === "allow" ? "approved" : "rejected",
|
|
209
|
+
);
|
|
210
|
+
interaction.directResolve(userDecision);
|
|
211
|
+
log.info(
|
|
212
|
+
{
|
|
213
|
+
event: "resolver_tool_approval_applied",
|
|
214
|
+
requestId: request.id,
|
|
215
|
+
action: decision.action,
|
|
216
|
+
conversationId: request.conversationId,
|
|
217
|
+
toolName: request.toolName,
|
|
218
|
+
directResolve: true,
|
|
219
|
+
},
|
|
220
|
+
"Tool approval resolver: direct-resolve interaction resolved",
|
|
221
|
+
);
|
|
222
|
+
return { ok: true, applied: true };
|
|
223
|
+
}
|
|
224
|
+
|
|
199
225
|
const conversation = findConversation(interaction.conversationId);
|
|
200
226
|
if (!conversation) {
|
|
201
227
|
return {
|
|
@@ -79,7 +79,7 @@ export function registerChannelVerificationSessionsCommand(
|
|
|
79
79
|
"after",
|
|
80
80
|
`
|
|
81
81
|
Verification sessions are used to verify guardian bindings and trusted
|
|
82
|
-
contacts across channels (telegram, phone, slack). Three flows exist:
|
|
82
|
+
contacts across channels (telegram, phone, slack, email). Three flows exist:
|
|
83
83
|
|
|
84
84
|
1. Inbound challenge — the assistant generates a secret code and waits
|
|
85
85
|
for the guardian to send it back on the channel. Used when the
|
|
@@ -107,10 +107,10 @@ Examples:
|
|
|
107
107
|
cvs
|
|
108
108
|
.command("create")
|
|
109
109
|
.description("Create a new verification session")
|
|
110
|
-
.option("--channel <channel>", "Channel type (telegram, phone, slack)")
|
|
110
|
+
.option("--channel <channel>", "Channel type (telegram, phone, slack, email)")
|
|
111
111
|
.option(
|
|
112
112
|
"--destination <destination>",
|
|
113
|
-
"Destination address for outbound verification (handle, phone number, or
|
|
113
|
+
"Destination address for outbound verification (handle, phone number, user ID, or email address)",
|
|
114
114
|
)
|
|
115
115
|
.option("--rebind", "Replace existing guardian binding")
|
|
116
116
|
.option(
|
|
@@ -140,7 +140,7 @@ Routes between three creation modes based on the provided options:
|
|
|
140
140
|
|
|
141
141
|
2. Outbound: --channel <ch> --destination <dest>
|
|
142
142
|
Sends a verification code to the given destination. Supports telegram
|
|
143
|
-
(handle or chat ID), phone (E.164 number),
|
|
143
|
+
(handle or chat ID), phone (E.164 number), slack (user ID), and email.
|
|
144
144
|
Use --rebind to replace an existing guardian binding.
|
|
145
145
|
|
|
146
146
|
3. Inbound: --channel <ch> (no --destination)
|
|
@@ -240,7 +240,7 @@ Examples:
|
|
|
240
240
|
)
|
|
241
241
|
.requiredOption(
|
|
242
242
|
"--channel <channel>",
|
|
243
|
-
"Channel type (telegram, phone, slack)",
|
|
243
|
+
"Channel type (telegram, phone, slack, email)",
|
|
244
244
|
)
|
|
245
245
|
.option(
|
|
246
246
|
"--origin-conversation-id <id>",
|
|
@@ -290,7 +290,7 @@ Examples:
|
|
|
290
290
|
.description("Cancel all active verification sessions for a channel")
|
|
291
291
|
.requiredOption(
|
|
292
292
|
"--channel <channel>",
|
|
293
|
-
"Channel type (telegram, phone, slack)",
|
|
293
|
+
"Channel type (telegram, phone, slack, email)",
|
|
294
294
|
)
|
|
295
295
|
.addHelpText(
|
|
296
296
|
"after",
|
|
@@ -16,8 +16,6 @@
|
|
|
16
16
|
|
|
17
17
|
import type { Command } from "commander";
|
|
18
18
|
|
|
19
|
-
import { isAssistantFeatureFlagEnabled } from "../../config/assistant-feature-flags.js";
|
|
20
|
-
import { getConfig } from "../../config/loader.js";
|
|
21
19
|
import { cliIpcCall } from "../../ipc/cli-client.js";
|
|
22
20
|
import type { OAuth2Config } from "../../security/oauth2.js";
|
|
23
21
|
import { startOAuth2Flow } from "../../security/oauth2.js";
|
|
@@ -343,12 +341,6 @@ function attachLoginChatgptSubcommand(providers: Command): void {
|
|
|
343
341
|
.description("Authenticate with ChatGPT via browser OAuth flow")
|
|
344
342
|
.option("--json", "Output as JSON")
|
|
345
343
|
.action(async (opts: { json?: boolean }) => {
|
|
346
|
-
const config = getConfig();
|
|
347
|
-
if (!isAssistantFeatureFlagEnabled("chatgpt-subscription-auth", config)) {
|
|
348
|
-
writeCliError("This feature is not yet available", opts.json);
|
|
349
|
-
return;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
344
|
try {
|
|
353
345
|
// Step 1: Run browser-based PKCE OAuth flow
|
|
354
346
|
process.stdout.write("Opening browser for ChatGPT authentication...\n");
|
|
@@ -55,7 +55,7 @@ Examples:
|
|
|
55
55
|
plugins
|
|
56
56
|
.command("install <name>")
|
|
57
57
|
.description(
|
|
58
|
-
"Install a plugin from vellum-ai/vellum-assistant/
|
|
58
|
+
"Install a plugin from vellum-ai/vellum-assistant/plugins/<name>",
|
|
59
59
|
)
|
|
60
60
|
.option("--force", "Overwrite an existing install")
|
|
61
61
|
.option(
|
|
@@ -150,7 +150,7 @@ Examples:
|
|
|
150
150
|
plugins
|
|
151
151
|
.command("search <query>")
|
|
152
152
|
.description(
|
|
153
|
-
"Search vellum-ai/vellum-assistant/
|
|
153
|
+
"Search vellum-ai/vellum-assistant/plugins for plugin names matching <query> (case-insensitive regex)",
|
|
154
154
|
)
|
|
155
155
|
.option("--json", "Emit machine-readable JSON instead of a table")
|
|
156
156
|
.action(async (query: string, opts: { json?: boolean }) => {
|