@vellumai/assistant 0.10.7-dev.202607100720.fba456e → 0.10.7-dev.202607101106.c87f4e3

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.
Files changed (58) hide show
  1. package/openapi.yaml +0 -4
  2. package/package.json +1 -1
  3. package/src/__tests__/compaction-trail-store.test.ts +2 -1
  4. package/src/__tests__/conversation-app-control-instantiation.test.ts +20 -3
  5. package/src/__tests__/conversation-runtime-assembly.test.ts +2 -0
  6. package/src/__tests__/conversation-skill-tools.test.ts +31 -6
  7. package/src/__tests__/list-messages-queued.test.ts +9 -3
  8. package/src/__tests__/llm-request-log-agent-loop-exit-reason.test.ts +9 -9
  9. package/src/__tests__/llm-request-log-call-site.test.ts +5 -5
  10. package/src/__tests__/llm-request-log-disabled-writes.test.ts +91 -0
  11. package/src/__tests__/media-generate-image.test.ts +20 -7
  12. package/src/__tests__/platform-bash-auto-approve.test.ts +19 -2
  13. package/src/__tests__/registry.test.ts +18 -0
  14. package/src/__tests__/require-fresh-approval.test.ts +15 -0
  15. package/src/__tests__/skill-projection-feature-flag.test.ts +35 -8
  16. package/src/__tests__/skill-projection.benchmark.test.ts +7 -2
  17. package/src/__tests__/subagent-detail.test.ts +1 -0
  18. package/src/__tests__/summarize-boundary.test.ts +1 -0
  19. package/src/__tests__/tool-approval-handler.test.ts +1 -0
  20. package/src/__tests__/tool-execution-pipeline.benchmark.test.ts +1 -0
  21. package/src/__tests__/tool-executor-lifecycle-events.test.ts +21 -17
  22. package/src/__tests__/tool-executor.test.ts +36 -18
  23. package/src/__tests__/tool-grant-request-escalation.test.ts +1 -0
  24. package/src/__tests__/trusted-contact-inline-approval-integration.test.ts +1 -0
  25. package/src/__tests__/verification-control-plane-policy.test.ts +13 -0
  26. package/src/api/responses/conversation-message.ts +0 -15
  27. package/src/config/schemas/__tests__/llm-request-logs.test.ts +33 -5
  28. package/src/config/schemas/llm-request-logs.ts +78 -27
  29. package/src/daemon/conversation-skill-tools.ts +27 -9
  30. package/src/export/__tests__/transcript-formatter.test.ts +5 -0
  31. package/src/permissions/checker.test.ts +3 -6
  32. package/src/permissions/checker.ts +2 -2
  33. package/src/persistence/__tests__/message-content-file.test.ts +150 -0
  34. package/src/persistence/__tests__/slow-query-log.test.ts +125 -0
  35. package/src/persistence/conversation-crud.ts +11 -1
  36. package/src/persistence/llm-request-log-store.ts +36 -2
  37. package/src/persistence/message-content-file.ts +190 -0
  38. package/src/persistence/migrations/324-message-finalized-column.ts +26 -0
  39. package/src/persistence/migrations/__tests__/297-move-llm-request-logs.test.ts +2 -2
  40. package/src/persistence/schema/conversations.ts +15 -0
  41. package/src/persistence/slow-query-log.ts +58 -21
  42. package/src/persistence/steps.ts +2 -0
  43. package/src/runtime/routes/__tests__/conversation-compaction-routes.test.ts +31 -2
  44. package/src/runtime/routes/__tests__/conversation-query-routes.test.ts +67 -1
  45. package/src/runtime/routes/conversation-compaction-routes.ts +5 -0
  46. package/src/runtime/routes/conversation-query-routes.ts +5 -0
  47. package/src/runtime/routes/conversation-routes.ts +2 -8
  48. package/src/runtime/routes/errors.ts +17 -0
  49. package/src/runtime/routes/llm-request-logs-access.ts +19 -0
  50. package/src/tasks/tool-sanitizer.ts +3 -1
  51. package/src/telemetry/turn-trace-store.test.ts +4 -0
  52. package/src/telemetry/turn-trace-store.ts +1 -4
  53. package/src/tools/registry.ts +89 -11
  54. package/src/tools/run-standalone.ts +5 -13
  55. package/src/tools/workspace-tools/loader.ts +24 -8
  56. package/src/util/sqlite-query-label.ts +51 -0
  57. package/src/util/sqlite-retry.ts +14 -2
  58. package/src/workflows/capabilities.ts +12 -4
@@ -20,11 +20,7 @@ import { v4 as uuid } from "uuid";
20
20
  import { PermissionPrompter } from "../permissions/prompter.js";
21
21
  import { getWorkspaceDir } from "../util/platform.js";
22
22
  import { ToolExecutor } from "./executor.js";
23
- import {
24
- areCoreToolsInitialized,
25
- getTool,
26
- initializeTools,
27
- } from "./registry.js";
23
+ import { resolveTool } from "./registry.js";
28
24
  import type { ToolContext } from "./types.js";
29
25
 
30
26
  /** Thrown when the requested tool is not present in the registry. */
@@ -59,14 +55,10 @@ export async function runToolStandalone(
59
55
  input: Record<string, unknown>,
60
56
  opts?: { workingDir?: string; signal?: AbortSignal },
61
57
  ): Promise<StandaloneToolResult> {
62
- // Populate the registry from the filesystem. The daemon does this at
63
- // startup; a short-lived CLI process has to do it itself. Guarded so a
64
- // repeat call in the same process is a no-op.
65
- if (!areCoreToolsInitialized()) {
66
- await initializeTools();
67
- }
68
-
69
- const tool = getTool(toolName);
58
+ // `resolveTool` lazily initializes the registry on first access (the daemon
59
+ // does this at startup; a short-lived CLI process relies on the same lazy
60
+ // ensure).
61
+ const tool = await resolveTool(toolName);
70
62
  if (!tool) {
71
63
  throw new UnknownToolError(toolName);
72
64
  }
@@ -144,8 +144,12 @@ const WORKSPACE_TOOL_DEFAULTS = Object.freeze({
144
144
  * .gitignore, etc.) cannot accidentally claim a tool.
145
145
  */
146
146
  function isValidToolFilenameStem(stem: string): boolean {
147
- if (stem.length === 0) return false;
148
- if (stem.startsWith(".")) return false;
147
+ if (stem.length === 0) {
148
+ return false;
149
+ }
150
+ if (stem.startsWith(".")) {
151
+ return false;
152
+ }
149
153
  return isProviderSafeToolName(stem);
150
154
  }
151
155
 
@@ -196,7 +200,9 @@ function selectLiveExtension(
196
200
  if (extensions.has(candidate)) {
197
201
  const shadowed: LiveToolExtension[] = [];
198
202
  for (const ext of LIVE_TOOL_EXTENSIONS) {
199
- if (ext !== candidate && extensions.has(ext)) shadowed.push(ext);
203
+ if (ext !== candidate && extensions.has(ext)) {
204
+ shadowed.push(ext);
205
+ }
200
206
  }
201
207
  return { ext: candidate, shadowed };
202
208
  }
@@ -314,7 +320,9 @@ async function importToolDefaultBounded(
314
320
  );
315
321
  return undefined;
316
322
  } finally {
317
- if (timeoutHandle !== undefined) clearTimeout(timeoutHandle);
323
+ if (timeoutHandle !== undefined) {
324
+ clearTimeout(timeoutHandle);
325
+ }
318
326
  }
319
327
  }
320
328
 
@@ -466,7 +474,9 @@ function scanWorkspaceToolsDir(toolsDir: string): {
466
474
  }
467
475
 
468
476
  const classified = classifyEntry(entry);
469
- if (!classified) continue;
477
+ if (!classified) {
478
+ continue;
479
+ }
470
480
  if (!isValidToolFilenameStem(classified.stem)) {
471
481
  log.error(
472
482
  { entry, stem: classified.stem, toolsDir },
@@ -557,7 +567,9 @@ async function loadDesiredLiveTool(
557
567
  entry.path,
558
568
  importTimeoutMs,
559
569
  );
560
- if (defaultExport === undefined) return undefined; // Failure already logged.
570
+ if (defaultExport === undefined) {
571
+ return undefined;
572
+ } // Failure already logged.
561
573
  if (defaultExport === null || typeof defaultExport !== "object") {
562
574
  log.error(
563
575
  { entryPath: entry.path, type: typeof defaultExport },
@@ -567,7 +579,9 @@ async function loadDesiredLiveTool(
567
579
  }
568
580
  toolSpec = defaultExport as ToolDefinition;
569
581
  }
570
- if (!toolSpec) return undefined;
582
+ if (!toolSpec) {
583
+ return undefined;
584
+ }
571
585
  return applyWorkspaceToolDefaults(toolSpec, stem);
572
586
  }
573
587
 
@@ -615,7 +629,9 @@ let inflightReconcile: Promise<LoadWorkspaceToolsResult> | null = null;
615
629
  export function loadWorkspaceTools(
616
630
  options: LoadWorkspaceToolsOptions = {},
617
631
  ): Promise<LoadWorkspaceToolsResult> {
618
- if (inflightReconcile) return inflightReconcile;
632
+ if (inflightReconcile) {
633
+ return inflightReconcile;
634
+ }
619
635
  // `reconcileWorkspaceTools` never rejects (all failures are caught and
620
636
  // logged); `.finally` clears the slot either way so the next caller scans
621
637
  // fresh.
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Ambient attribution label for SQLite statements, carried across an async
3
+ * call tree via `AsyncLocalStorage`.
4
+ *
5
+ * The slow-query reporter ({@link ../persistence/slow-query-log}) attributes
6
+ * an unlabeled statement by walking the stack, but some execution paths leave
7
+ * no usable application frame: a lazy Drizzle query awaited by a wrapper runs
8
+ * from a microtask, and a retried statement (after a backoff sleep) runs from
9
+ * a truncated stack that bottoms out in the retry helper itself. Wrappers that
10
+ * *do* know what operation they are running — {@link ./sqlite-retry
11
+ * withSqliteRetry} with its curated `op` — publish that name here, and the
12
+ * reporter reads it on the slow path as the statement's label.
13
+ *
14
+ * This module lives in `util/` (not beside the reporter in `persistence/`)
15
+ * because `util/` must not import from `persistence/`; both sides depend on
16
+ * this small shared seam instead.
17
+ *
18
+ * Scoping: the label applies to every statement executed inside `fn`'s
19
+ * synchronous and awaited continuations — exactly the work the wrapper is
20
+ * accountable for — and evaporates when `fn` settles. Nested scopes shadow
21
+ * naturally (innermost wins), and an explicit statement-level `.label()`
22
+ * always takes precedence over an ambient label.
23
+ */
24
+
25
+ import { AsyncLocalStorage } from "node:async_hooks";
26
+
27
+ const ambientLabel = new AsyncLocalStorage<string>();
28
+
29
+ /**
30
+ * Run `fn` (sync or async) with `label` as the ambient SQLite query label.
31
+ * Returns `fn`'s result unchanged; for an async `fn` the label stays in
32
+ * effect across its awaits.
33
+ *
34
+ * Caveat: the label covers only work performed *inside* the scope. If `fn`
35
+ * returns a lazy thenable (a Drizzle QueryPromise executes its statement when
36
+ * first awaited), the caller's own `await` happens after this scope has
37
+ * exited — pass `async () => await lazy()` so assimilation, and therefore the
38
+ * query, runs inside the scope.
39
+ */
40
+ export function runWithSqliteQueryLabel<T>(label: string, fn: () => T): T {
41
+ return ambientLabel.run(label, fn);
42
+ }
43
+
44
+ /**
45
+ * The innermost ambient label in effect, or `undefined` outside any
46
+ * {@link runWithSqliteQueryLabel} scope. Read by the slow-query reporter on
47
+ * its slow path only — never on the per-statement fast path.
48
+ */
49
+ export function getAmbientSqliteQueryLabel(): string | undefined {
50
+ return ambientLabel.getStore();
51
+ }
@@ -26,6 +26,7 @@
26
26
 
27
27
  import { getLogger } from "./logger.js";
28
28
  import { computeRetryDelay } from "./retry.js";
29
+ import { runWithSqliteQueryLabel } from "./sqlite-query-label.js";
29
30
 
30
31
  const log = getLogger("sqlite-retry");
31
32
 
@@ -34,7 +35,14 @@ const DEFAULT_MAX_RETRIES = 3;
34
35
  const DEFAULT_BASE_DELAY_MS = 50;
35
36
 
36
37
  export interface SqliteRetryOptions {
37
- /** Short identifier for the wrapped operation, used in retry logs. */
38
+ /**
39
+ * Short identifier for the wrapped operation, used in retry logs. Also
40
+ * published as the ambient SQLite query label while `fn` runs, so any
41
+ * slow-query WARN emitted for a statement inside it is attributed to this
42
+ * name instead of an unattributable stack (a lazy Drizzle query awaited
43
+ * here executes from a microtask; a post-backoff retry runs from a stack
44
+ * that bottoms out in this helper).
45
+ */
38
46
  op: string;
39
47
  /** Maximum retry attempts after the initial try (default 3). */
40
48
  maxRetries?: number;
@@ -69,7 +77,11 @@ export async function withSqliteRetry<T>(
69
77
  const baseDelayMs = options.baseDelayMs ?? DEFAULT_BASE_DELAY_MS;
70
78
  for (let attempt = 0; ; attempt++) {
71
79
  try {
72
- return await fn();
80
+ // The inner await must happen inside the label scope: a lazy thenable
81
+ // (e.g. a Drizzle QueryPromise) executes its statement only when
82
+ // awaited, so assimilating it outside the scope would run the query
83
+ // after the ambient label has already evaporated.
84
+ return await runWithSqliteQueryLabel(options.op, async () => await fn());
73
85
  } catch (err) {
74
86
  if (attempt < maxRetries && isRetryableSqliteError(err)) {
75
87
  log.warn(
@@ -246,7 +246,9 @@ const FORBIDDEN_SET: ReadonlySet<string> = new Set(WORKFLOW_FORBIDDEN_TOOLS);
246
246
  */
247
247
  function resolveBaselineTool(name: string): Tool | undefined {
248
248
  const owner = getToolOwner(name);
249
- if (owner && owner.kind !== "default") return getCoreToolOverride(name);
249
+ if (owner && owner.kind !== "default") {
250
+ return getCoreToolOverride(name);
251
+ }
250
252
  return getTool(name);
251
253
  }
252
254
 
@@ -294,16 +296,22 @@ export function resolveCapabilities(
294
296
  // convenience grant, not a declaration, so a missing entry should not fail
295
297
  // the run. Forbidden filtering still applies for defense in depth.
296
298
  for (const name of WORKFLOW_READONLY_BASELINE) {
297
- if (FORBIDDEN_SET.has(name)) continue;
299
+ if (FORBIDDEN_SET.has(name)) {
300
+ continue;
301
+ }
298
302
  // Defense in depth: the baseline is auto-granted with NO launch approval, so
299
303
  // it must never carry a side-effecting tool (e.g. web_fetch, whose URL can
300
304
  // exfiltrate read data or trigger external actions). isSideEffectTool is the
301
305
  // single source of truth; skip any baseline entry it flags so the no-consent
302
306
  // grant can never include a side effect, even if the list above drifts. A
303
307
  // run that needs such a tool must DECLARE it (forcing the launch approval).
304
- if (isSideEffectTool(name)) continue;
308
+ if (isSideEffectTool(name)) {
309
+ continue;
310
+ }
305
311
  const tool = resolveBaselineTool(name);
306
- if (tool) resolved.set(name, tool);
312
+ if (tool) {
313
+ resolved.set(name, tool);
314
+ }
307
315
  }
308
316
 
309
317
  // Declared tools must exist — a missing one is an authoring error.