@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
package/src/telemetry/types.ts
CHANGED
|
@@ -225,10 +225,34 @@ export interface AuthFallbackTelemetryEvent extends TelemetryEventBase {
|
|
|
225
225
|
window_end: number;
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
+
/**
|
|
229
|
+
* Tool execution event — one per tool invocation, sourced from the
|
|
230
|
+
* `tool_invocations` audit table. Skill-routed calls appear under their
|
|
231
|
+
* underlying tool name; `skill_id` identifies the triggering skill.
|
|
232
|
+
* Carries NO raw input/output — only tool identity, permission
|
|
233
|
+
* outcome, risk class, duration, and parent conversation.
|
|
234
|
+
*/
|
|
235
|
+
export interface ToolExecutionTelemetryEvent extends TelemetryEventBase {
|
|
236
|
+
type: "tool_execution";
|
|
237
|
+
tool_name: string;
|
|
238
|
+
/**
|
|
239
|
+
* Triggering skill id for skill-routed calls. Null for direct tool
|
|
240
|
+
* calls and for rows recorded before the `skill_id` column existed.
|
|
241
|
+
*/
|
|
242
|
+
skill_id: string | null;
|
|
243
|
+
/** Permission outcome: "allow" | "error" | "denied". */
|
|
244
|
+
decision: string;
|
|
245
|
+
/** Executor risk classification. */
|
|
246
|
+
risk_level: string;
|
|
247
|
+
duration_ms: number;
|
|
248
|
+
conversation_id: string;
|
|
249
|
+
}
|
|
250
|
+
|
|
228
251
|
/** Discriminated union of all telemetry event types. */
|
|
229
252
|
export type TelemetryEvent =
|
|
230
253
|
| LlmUsageTelemetryEvent
|
|
231
254
|
| TurnTelemetryEvent
|
|
232
255
|
| LifecycleTelemetryEvent
|
|
233
256
|
| OnboardingTelemetryEvent
|
|
234
|
-
| AuthFallbackTelemetryEvent
|
|
257
|
+
| AuthFallbackTelemetryEvent
|
|
258
|
+
| ToolExecutionTelemetryEvent;
|
|
@@ -143,19 +143,29 @@ mock.module("../memory/onboarding-events-store.js", () => ({
|
|
|
143
143
|
queryUnreportedOnboardingEvents: mockQueryUnreportedOnboardingEvents,
|
|
144
144
|
}));
|
|
145
145
|
|
|
146
|
-
// The auth-fallback
|
|
147
|
-
// DB-backed tests, and Bun's `mock.module` is
|
|
148
|
-
// here would leak into those tests when files
|
|
149
|
-
// real DB instead so every auth-fallback
|
|
146
|
+
// The auth-fallback and tool-execution stores are intentionally NOT mocked —
|
|
147
|
+
// they have their own DB-backed tests, and Bun's `mock.module` is
|
|
148
|
+
// process-global, so mocking them here would leak into those tests when files
|
|
149
|
+
// share an invocation. We seed the real DB instead so every auth-fallback /
|
|
150
|
+
// tool-execution test stays order-independent.
|
|
150
151
|
|
|
151
152
|
// ---------------------------------------------------------------------------
|
|
152
153
|
// Production import (after mocks)
|
|
153
154
|
// ---------------------------------------------------------------------------
|
|
154
155
|
|
|
156
|
+
import {
|
|
157
|
+
seedToolInvocation,
|
|
158
|
+
type SeedToolInvocationSpec,
|
|
159
|
+
TOOL_INVOCATION_PII_SENTINEL,
|
|
160
|
+
} from "../memory/__tests__/tool-invocation-test-helpers.js";
|
|
155
161
|
import { recordAuthFallbackCounts } from "../memory/auth-fallback-events-store.js";
|
|
156
162
|
import { getDb } from "../memory/db-connection.js";
|
|
157
163
|
import { initializeDb } from "../memory/db-init.js";
|
|
158
|
-
import {
|
|
164
|
+
import {
|
|
165
|
+
authFallbackEvents,
|
|
166
|
+
conversations,
|
|
167
|
+
toolInvocations,
|
|
168
|
+
} from "../memory/schema.js";
|
|
159
169
|
import type { UsageEvent } from "../usage/types.js";
|
|
160
170
|
import {
|
|
161
171
|
ACTIVATION_FUNNEL_VERSION,
|
|
@@ -238,6 +248,17 @@ function makeOnboardingEvent(
|
|
|
238
248
|
};
|
|
239
249
|
}
|
|
240
250
|
|
|
251
|
+
const TOOL_EXEC_CONVERSATION_ID = "conv-tool-exec-reporter-test";
|
|
252
|
+
|
|
253
|
+
function insertInvocation(
|
|
254
|
+
spec: Omit<SeedToolInvocationSpec, "conversationId">,
|
|
255
|
+
): void {
|
|
256
|
+
seedToolInvocation(
|
|
257
|
+
{ db: getDb(), conversations, toolInvocations },
|
|
258
|
+
{ ...spec, conversationId: TOOL_EXEC_CONVERSATION_ID },
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
|
|
241
262
|
const originalFetch = globalThis.fetch;
|
|
242
263
|
let mockFetch: ReturnType<typeof mock>;
|
|
243
264
|
|
|
@@ -258,6 +279,7 @@ beforeEach(() => {
|
|
|
258
279
|
mockQueryUnreportedOnboardingEvents.mockReset();
|
|
259
280
|
mockQueryUnreportedOnboardingEvents.mockReturnValue([]);
|
|
260
281
|
getDb().delete(authFallbackEvents).run();
|
|
282
|
+
getDb().delete(toolInvocations).run();
|
|
261
283
|
mockPlatformClient = null;
|
|
262
284
|
mockGetPlatformBaseUrl.mockReset();
|
|
263
285
|
mockGetDeviceId.mockReset();
|
|
@@ -956,6 +978,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
956
978
|
mockCollectUsageData = false;
|
|
957
979
|
const events = [makeUsageEvent()];
|
|
958
980
|
mockQueryUnreportedUsageEvents.mockReturnValue(events);
|
|
981
|
+
insertInvocation({ id: "ti-opt-out", createdAt: 1700000000000 });
|
|
959
982
|
mockFetch.mockImplementation(() =>
|
|
960
983
|
Promise.resolve(new Response('{"accepted":1}', { status: 200 })),
|
|
961
984
|
);
|
|
@@ -966,9 +989,9 @@ describe("UsageTelemetryReporter", () => {
|
|
|
966
989
|
// No HTTP call should have been made
|
|
967
990
|
expect(mockFetch).not.toHaveBeenCalled();
|
|
968
991
|
|
|
969
|
-
// All
|
|
992
|
+
// All 6 timestamp watermarks should have been advanced (IDs left untouched
|
|
970
993
|
// so the compound-cursor branch stays active)
|
|
971
|
-
expect(mockSetMemoryCheckpoint).toHaveBeenCalledTimes(
|
|
994
|
+
expect(mockSetMemoryCheckpoint).toHaveBeenCalledTimes(6);
|
|
972
995
|
|
|
973
996
|
const calls = mockSetMemoryCheckpoint.mock.calls;
|
|
974
997
|
const keys = calls.map((c) => c[0]);
|
|
@@ -977,6 +1000,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
977
1000
|
expect(keys).toContain("telemetry:lifecycle:last_reported_at");
|
|
978
1001
|
expect(keys).toContain("telemetry:onboarding:last_reported_at");
|
|
979
1002
|
expect(keys).toContain("telemetry:auth_fallback:last_reported_at");
|
|
1003
|
+
expect(keys).toContain("telemetry:tool_execution:last_reported_at");
|
|
980
1004
|
});
|
|
981
1005
|
|
|
982
1006
|
test("events sent normally after re-enabling collectUsageData", async () => {
|
|
@@ -1222,6 +1246,116 @@ describe("UsageTelemetryReporter", () => {
|
|
|
1222
1246
|
expect(idCalls[idCalls.length - 1][1]).toBe(lastRow.id);
|
|
1223
1247
|
});
|
|
1224
1248
|
|
|
1249
|
+
// -------------------------------------------------------------------------
|
|
1250
|
+
// Tool-execution events
|
|
1251
|
+
// -------------------------------------------------------------------------
|
|
1252
|
+
|
|
1253
|
+
test("tool_invocations rows flush as tool_execution events with mapped fields and no raw input/result", async () => {
|
|
1254
|
+
mockQueryUnreportedUsageEvents.mockReturnValue([]);
|
|
1255
|
+
insertInvocation({
|
|
1256
|
+
id: "ti-flush-direct",
|
|
1257
|
+
createdAt: 1700000900000,
|
|
1258
|
+
toolName: "calendar_list_events",
|
|
1259
|
+
decision: "denied",
|
|
1260
|
+
riskLevel: "high",
|
|
1261
|
+
durationMs: 137,
|
|
1262
|
+
});
|
|
1263
|
+
insertInvocation({
|
|
1264
|
+
id: "ti-flush-skill",
|
|
1265
|
+
createdAt: 1700000950000,
|
|
1266
|
+
toolName: "task_create",
|
|
1267
|
+
skillId: "tasks-skill",
|
|
1268
|
+
});
|
|
1269
|
+
mockFetch.mockImplementation(() =>
|
|
1270
|
+
Promise.resolve(new Response('{"accepted":2}', { status: 200 })),
|
|
1271
|
+
);
|
|
1272
|
+
|
|
1273
|
+
const reporter = new UsageTelemetryReporter();
|
|
1274
|
+
await reporter.flush();
|
|
1275
|
+
|
|
1276
|
+
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
1277
|
+
const body = JSON.parse(
|
|
1278
|
+
(mockFetch.mock.calls[0] as [string, RequestInit])[1].body as string,
|
|
1279
|
+
);
|
|
1280
|
+
expect(body.events.length).toBe(2);
|
|
1281
|
+
|
|
1282
|
+
const direct = body.events.find(
|
|
1283
|
+
(e: { daemon_event_id: string }) =>
|
|
1284
|
+
e.daemon_event_id === "ti-flush-direct",
|
|
1285
|
+
);
|
|
1286
|
+
expect(direct).toMatchObject({
|
|
1287
|
+
type: "tool_execution",
|
|
1288
|
+
daemon_event_id: "ti-flush-direct",
|
|
1289
|
+
recorded_at: 1700000900000,
|
|
1290
|
+
tool_name: "calendar_list_events",
|
|
1291
|
+
// Direct (non-skill) tool call — skill_id stays null on the wire.
|
|
1292
|
+
skill_id: null,
|
|
1293
|
+
decision: "denied",
|
|
1294
|
+
risk_level: "high",
|
|
1295
|
+
duration_ms: 137,
|
|
1296
|
+
conversation_id: TOOL_EXEC_CONVERSATION_ID,
|
|
1297
|
+
assistant_version: "1.2.3-test",
|
|
1298
|
+
});
|
|
1299
|
+
|
|
1300
|
+
const skillRouted = body.events.find(
|
|
1301
|
+
(e: { daemon_event_id: string }) =>
|
|
1302
|
+
e.daemon_event_id === "ti-flush-skill",
|
|
1303
|
+
);
|
|
1304
|
+
expect(skillRouted).toMatchObject({
|
|
1305
|
+
type: "tool_execution",
|
|
1306
|
+
tool_name: "task_create",
|
|
1307
|
+
skill_id: "tasks-skill",
|
|
1308
|
+
});
|
|
1309
|
+
|
|
1310
|
+
// The raw tool args/outputs persisted in the audit rows are potentially
|
|
1311
|
+
// PII and must NEVER appear anywhere in the payload.
|
|
1312
|
+
expect(JSON.stringify(body)).not.toContain(TOOL_INVOCATION_PII_SENTINEL);
|
|
1313
|
+
expect(direct.input).toBeUndefined();
|
|
1314
|
+
expect(direct.result).toBeUndefined();
|
|
1315
|
+
});
|
|
1316
|
+
|
|
1317
|
+
test("tool_execution watermark advances to the last reported row on success", async () => {
|
|
1318
|
+
mockQueryUnreportedUsageEvents.mockReturnValue([]);
|
|
1319
|
+
insertInvocation({ id: "ti-wm-1", createdAt: 1700001000000 });
|
|
1320
|
+
insertInvocation({ id: "ti-wm-2", createdAt: 1700001001000 });
|
|
1321
|
+
mockFetch.mockImplementation(() =>
|
|
1322
|
+
Promise.resolve(new Response('{"accepted":2}', { status: 200 })),
|
|
1323
|
+
);
|
|
1324
|
+
|
|
1325
|
+
const reporter = new UsageTelemetryReporter();
|
|
1326
|
+
await reporter.flush();
|
|
1327
|
+
|
|
1328
|
+
const watermarkCalls = mockSetMemoryCheckpoint.mock.calls.filter(
|
|
1329
|
+
(c) => c[0] === "telemetry:tool_execution:last_reported_at",
|
|
1330
|
+
);
|
|
1331
|
+
expect(watermarkCalls.length).toBeGreaterThanOrEqual(1);
|
|
1332
|
+
expect(watermarkCalls[watermarkCalls.length - 1][1]).toBe(
|
|
1333
|
+
String(1700001001000),
|
|
1334
|
+
);
|
|
1335
|
+
|
|
1336
|
+
const idCalls = mockSetMemoryCheckpoint.mock.calls.filter(
|
|
1337
|
+
(c) => c[0] === "telemetry:tool_execution:last_reported_id",
|
|
1338
|
+
);
|
|
1339
|
+
expect(idCalls.length).toBeGreaterThanOrEqual(1);
|
|
1340
|
+
expect(idCalls[idCalls.length - 1][1]).toBe("ti-wm-2");
|
|
1341
|
+
});
|
|
1342
|
+
|
|
1343
|
+
test("tool_execution watermark stays on failed upload", async () => {
|
|
1344
|
+
mockQueryUnreportedUsageEvents.mockReturnValue([]);
|
|
1345
|
+
insertInvocation({ id: "ti-fail-1", createdAt: 1700001100000 });
|
|
1346
|
+
mockFetch.mockImplementation(() =>
|
|
1347
|
+
Promise.resolve(new Response("error", { status: 500 })),
|
|
1348
|
+
);
|
|
1349
|
+
|
|
1350
|
+
const reporter = new UsageTelemetryReporter();
|
|
1351
|
+
await reporter.flush();
|
|
1352
|
+
|
|
1353
|
+
const watermarkCalls = mockSetMemoryCheckpoint.mock.calls.filter((c) =>
|
|
1354
|
+
c[0].startsWith("telemetry:tool_execution:"),
|
|
1355
|
+
);
|
|
1356
|
+
expect(watermarkCalls.length).toBe(0);
|
|
1357
|
+
});
|
|
1358
|
+
|
|
1225
1359
|
// -------------------------------------------------------------------------
|
|
1226
1360
|
// Onboarding / activation funnel events
|
|
1227
1361
|
// -------------------------------------------------------------------------
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
import { queryUnreportedLifecycleEvents } from "../memory/lifecycle-events-store.js";
|
|
24
24
|
import { queryUnreportedUsageEvents } from "../memory/llm-usage-store.js";
|
|
25
25
|
import { queryUnreportedOnboardingEvents } from "../memory/onboarding-events-store.js";
|
|
26
|
+
import { queryUnreportedToolExecutionEvents } from "../memory/tool-execution-events-store.js";
|
|
26
27
|
import { queryUnreportedTurnEvents } from "../memory/turn-events-store.js";
|
|
27
28
|
import { VellumPlatformClient } from "../platform/client.js";
|
|
28
29
|
import { getDeviceId } from "../util/device-id.js";
|
|
@@ -56,6 +57,10 @@ const CHECKPOINT_KEY_AUTH_FALLBACK_WATERMARK =
|
|
|
56
57
|
"telemetry:auth_fallback:last_reported_at";
|
|
57
58
|
const CHECKPOINT_KEY_AUTH_FALLBACK_WATERMARK_ID =
|
|
58
59
|
"telemetry:auth_fallback:last_reported_id";
|
|
60
|
+
const CHECKPOINT_KEY_TOOL_EXECUTION_WATERMARK =
|
|
61
|
+
"telemetry:tool_execution:last_reported_at";
|
|
62
|
+
const CHECKPOINT_KEY_TOOL_EXECUTION_WATERMARK_ID =
|
|
63
|
+
"telemetry:tool_execution:last_reported_id";
|
|
59
64
|
const REPORT_INTERVAL_MS = 5 * 60 * 1000;
|
|
60
65
|
const INITIAL_FLUSH_DELAY_MS = 30_000; // Delay first flush to let CES handshake complete
|
|
61
66
|
const BATCH_SIZE = 500;
|
|
@@ -149,6 +154,7 @@ export class UsageTelemetryReporter {
|
|
|
149
154
|
setMemoryCheckpoint(CHECKPOINT_KEY_LIFECYCLE_WATERMARK, now);
|
|
150
155
|
setMemoryCheckpoint(CHECKPOINT_KEY_ONBOARDING_WATERMARK, now);
|
|
151
156
|
setMemoryCheckpoint(CHECKPOINT_KEY_AUTH_FALLBACK_WATERMARK, now);
|
|
157
|
+
setMemoryCheckpoint(CHECKPOINT_KEY_TOOL_EXECUTION_WATERMARK, now);
|
|
152
158
|
return;
|
|
153
159
|
}
|
|
154
160
|
|
|
@@ -189,6 +195,14 @@ export class UsageTelemetryReporter {
|
|
|
189
195
|
getMemoryCheckpoint(CHECKPOINT_KEY_AUTH_FALLBACK_WATERMARK_ID) ??
|
|
190
196
|
undefined;
|
|
191
197
|
|
|
198
|
+
// Read tool-execution watermark (compound cursor: createdAt + id)
|
|
199
|
+
const toolExecutionWatermark = Number(
|
|
200
|
+
getMemoryCheckpoint(CHECKPOINT_KEY_TOOL_EXECUTION_WATERMARK) ?? "0",
|
|
201
|
+
);
|
|
202
|
+
const toolExecutionWatermarkId =
|
|
203
|
+
getMemoryCheckpoint(CHECKPOINT_KEY_TOOL_EXECUTION_WATERMARK_ID) ??
|
|
204
|
+
undefined;
|
|
205
|
+
|
|
192
206
|
// Query unreported events
|
|
193
207
|
const events = queryUnreportedUsageEvents(
|
|
194
208
|
watermark,
|
|
@@ -215,13 +229,19 @@ export class UsageTelemetryReporter {
|
|
|
215
229
|
authFallbackWatermarkId,
|
|
216
230
|
BATCH_SIZE,
|
|
217
231
|
);
|
|
232
|
+
const toolExecutionEvents = queryUnreportedToolExecutionEvents(
|
|
233
|
+
toolExecutionWatermark,
|
|
234
|
+
toolExecutionWatermarkId,
|
|
235
|
+
BATCH_SIZE,
|
|
236
|
+
);
|
|
218
237
|
|
|
219
238
|
if (
|
|
220
239
|
events.length === 0 &&
|
|
221
240
|
turnEvents.length === 0 &&
|
|
222
241
|
lifecycleEvents.length === 0 &&
|
|
223
242
|
onboardingEvents.length === 0 &&
|
|
224
|
-
authFallbackEvents.length === 0
|
|
243
|
+
authFallbackEvents.length === 0 &&
|
|
244
|
+
toolExecutionEvents.length === 0
|
|
225
245
|
)
|
|
226
246
|
return;
|
|
227
247
|
|
|
@@ -236,6 +256,7 @@ export class UsageTelemetryReporter {
|
|
|
236
256
|
lifecycleCount: lifecycleEvents.length,
|
|
237
257
|
onboardingCount: onboardingEvents.length,
|
|
238
258
|
authFallbackCount: authFallbackEvents.length,
|
|
259
|
+
toolExecutionCount: toolExecutionEvents.length,
|
|
239
260
|
},
|
|
240
261
|
"Telemetry flush: resolved auth context",
|
|
241
262
|
);
|
|
@@ -375,11 +396,11 @@ export class UsageTelemetryReporter {
|
|
|
375
396
|
...(e.stepIndex != null ? { step_index: e.stepIndex } : {}),
|
|
376
397
|
...(e.completedAt ? { completed_at: e.completedAt } : {}),
|
|
377
398
|
...(e.funnelVersion ? { funnel_version: e.funnelVersion } : {}),
|
|
378
|
-
// Onboarding events fall back to the envelope `assistant_version
|
|
379
|
-
//
|
|
380
|
-
//
|
|
381
|
-
//
|
|
382
|
-
//
|
|
399
|
+
// Onboarding events fall back to the envelope `assistant_version`,
|
|
400
|
+
// so events recorded under an older build are attributed to the
|
|
401
|
+
// version running at upload time. Adding a record-time column to
|
|
402
|
+
// `onboarding_events` (mirroring `llm_usage_events`) is a known
|
|
403
|
+
// follow-up.
|
|
383
404
|
assistant_version: APP_VERSION,
|
|
384
405
|
}),
|
|
385
406
|
),
|
|
@@ -402,6 +423,26 @@ export class UsageTelemetryReporter {
|
|
|
402
423
|
assistant_version: APP_VERSION,
|
|
403
424
|
}),
|
|
404
425
|
),
|
|
426
|
+
...toolExecutionEvents.map(
|
|
427
|
+
(e): TelemetryEvent => ({
|
|
428
|
+
type: "tool_execution",
|
|
429
|
+
daemon_event_id: e.id,
|
|
430
|
+
recorded_at: e.createdAt,
|
|
431
|
+
tool_name: e.toolName,
|
|
432
|
+
skill_id: e.skillId,
|
|
433
|
+
decision: e.decision,
|
|
434
|
+
risk_level: e.riskLevel,
|
|
435
|
+
duration_ms: e.durationMs,
|
|
436
|
+
conversation_id: e.conversationId,
|
|
437
|
+
// `tool_invocations` has no record-time version column — stamp
|
|
438
|
+
// the running binary's `APP_VERSION` so the wire value is
|
|
439
|
+
// concrete rather than an explicit null that would override the
|
|
440
|
+
// envelope under the platform's per-event-wins contract. Adding
|
|
441
|
+
// the record-time column is a separate follow-up that mirrors
|
|
442
|
+
// what migration 267 did for `llm_usage_events`.
|
|
443
|
+
assistant_version: APP_VERSION,
|
|
444
|
+
}),
|
|
445
|
+
),
|
|
405
446
|
];
|
|
406
447
|
|
|
407
448
|
const organizationId = getPlatformOrganizationId() || undefined;
|
|
@@ -501,13 +542,28 @@ export class UsageTelemetryReporter {
|
|
|
501
542
|
);
|
|
502
543
|
}
|
|
503
544
|
|
|
545
|
+
// Advance tool-execution watermark (compound cursor)
|
|
546
|
+
if (toolExecutionEvents.length > 0) {
|
|
547
|
+
const lastToolExecution =
|
|
548
|
+
toolExecutionEvents[toolExecutionEvents.length - 1];
|
|
549
|
+
setMemoryCheckpoint(
|
|
550
|
+
CHECKPOINT_KEY_TOOL_EXECUTION_WATERMARK,
|
|
551
|
+
String(lastToolExecution.createdAt),
|
|
552
|
+
);
|
|
553
|
+
setMemoryCheckpoint(
|
|
554
|
+
CHECKPOINT_KEY_TOOL_EXECUTION_WATERMARK_ID,
|
|
555
|
+
lastToolExecution.id,
|
|
556
|
+
);
|
|
557
|
+
}
|
|
558
|
+
|
|
504
559
|
// If we got a full batch of any type, there may be more — recurse
|
|
505
560
|
if (
|
|
506
561
|
events.length === BATCH_SIZE ||
|
|
507
562
|
turnEvents.length === BATCH_SIZE ||
|
|
508
563
|
lifecycleEvents.length === BATCH_SIZE ||
|
|
509
564
|
onboardingEvents.length === BATCH_SIZE ||
|
|
510
|
-
authFallbackEvents.length === BATCH_SIZE
|
|
565
|
+
authFallbackEvents.length === BATCH_SIZE ||
|
|
566
|
+
toolExecutionEvents.length === BATCH_SIZE
|
|
511
567
|
) {
|
|
512
568
|
await this._doFlush(batchCount + 1);
|
|
513
569
|
}
|
package/src/tools/executor.ts
CHANGED
|
@@ -485,9 +485,12 @@ function emitLifecycleEvent(
|
|
|
485
485
|
const handler = context.onToolLifecycleEvent;
|
|
486
486
|
if (!handler) return;
|
|
487
487
|
|
|
488
|
-
// Redact sensitive fields from tool inputs before they reach audit
|
|
488
|
+
// Redact sensitive fields from tool inputs before they reach audit
|
|
489
|
+
// listeners, and stamp the triggering skill id (if any) so audit/telemetry
|
|
490
|
+
// consumers can attribute skill-routed calls.
|
|
489
491
|
const sanitizedEvent = {
|
|
490
492
|
...event,
|
|
493
|
+
skillId: context.skillId,
|
|
491
494
|
input: sanitizeToolInput(event.toolName, event.input),
|
|
492
495
|
};
|
|
493
496
|
|
package/src/tools/skills/load.ts
CHANGED
|
@@ -290,11 +290,13 @@ export const skillLoadTool = {
|
|
|
290
290
|
skill.inlineCommandExpansions && skill.inlineCommandExpansions.length > 0;
|
|
291
291
|
|
|
292
292
|
if (hasInlineCommands) {
|
|
293
|
-
if (skill.source === "extra") {
|
|
294
|
-
// Third-party
|
|
295
|
-
//
|
|
293
|
+
if (skill.source === "extra" || skill.source === "plugin") {
|
|
294
|
+
// Third-party skill roots — `extra` dirs and skills shipped inside
|
|
295
|
+
// installed plugins — are out of scope for inline command expansion.
|
|
296
|
+
// Their bodies are untrusted, so reject explicitly rather than
|
|
297
|
+
// executing shell from them.
|
|
296
298
|
return {
|
|
297
|
-
content: `Error: skill "${skill.id}" contains inline command expansions but inline commands are not supported for third-party (
|
|
299
|
+
content: `Error: skill "${skill.id}" contains inline command expansions but inline commands are not supported for third-party (${skill.source}) skill sources.`,
|
|
298
300
|
isError: true,
|
|
299
301
|
};
|
|
300
302
|
}
|
|
@@ -367,9 +369,12 @@ export const skillLoadTool = {
|
|
|
367
369
|
childLoaded.skill.inlineCommandExpansions.length > 0;
|
|
368
370
|
|
|
369
371
|
if (childHasInlineCommands) {
|
|
370
|
-
if (
|
|
372
|
+
if (
|
|
373
|
+
childLoaded.skill.source === "extra" ||
|
|
374
|
+
childLoaded.skill.source === "plugin"
|
|
375
|
+
) {
|
|
371
376
|
return {
|
|
372
|
-
content: `Error: included skill "${childId}" contains inline command expansions but inline commands are not supported for third-party (
|
|
377
|
+
content: `Error: included skill "${childId}" contains inline command expansions but inline commands are not supported for third-party (${childLoaded.skill.source}) skill sources.`,
|
|
373
378
|
isError: true,
|
|
374
379
|
};
|
|
375
380
|
}
|
package/src/tools/types.ts
CHANGED
|
@@ -172,6 +172,8 @@ export interface ToolExecutedEvent {
|
|
|
172
172
|
conversationId: string;
|
|
173
173
|
requestId?: string;
|
|
174
174
|
executionTarget?: ExecutionTarget;
|
|
175
|
+
/** Id of the skill whose `skill_execute` dispatch triggered this tool call. Absent for direct tool calls. */
|
|
176
|
+
skillId?: string;
|
|
175
177
|
riskLevel: string;
|
|
176
178
|
/** ID of the trust rule that matched this invocation (if any). */
|
|
177
179
|
matchedTrustRuleId?: string;
|
|
@@ -210,6 +212,14 @@ export interface ToolContext {
|
|
|
210
212
|
assistantId?: string;
|
|
211
213
|
/** When set, the tool execution is part of a task run. Used to retrieve ephemeral permission rules. */
|
|
212
214
|
taskRunId?: string;
|
|
215
|
+
/**
|
|
216
|
+
* Id of the skill whose `skill_execute` dispatch triggered this tool
|
|
217
|
+
* invocation. Set by the `skill_execute` interception in
|
|
218
|
+
* `daemon/conversation-tool-setup.ts`; the executor stamps it onto every
|
|
219
|
+
* lifecycle event so audit/telemetry consumers can attribute skill-routed
|
|
220
|
+
* calls. Absent for direct (non-skill) tool calls.
|
|
221
|
+
*/
|
|
222
|
+
skillId?: string;
|
|
213
223
|
/** Optional callback for tool lifecycle events (start/prompt/deny/execute/error). */
|
|
214
224
|
onToolLifecycleEvent?: ToolLifecycleEventHandler;
|
|
215
225
|
/** Optional resolver for proxy tools - delegates execution to an external client. */
|