@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
@@ -158,8 +158,8 @@ mock.module("../telemetry/tool-usage-store.js", () => ({
158
158
  rotateToolInvocations: async () => 0,
159
159
  }));
160
160
 
161
- mock.module("../tools/registry.js", () => ({
162
- getTool: (name: string) => {
161
+ mock.module("../tools/registry.js", () => {
162
+ const lookup = (name: string) => {
163
163
  if (name === "unknown_tool") {
164
164
  return undefined;
165
165
  }
@@ -242,21 +242,25 @@ mock.module("../tools/registry.js", () => ({
242
242
  return fakeToolResult;
243
243
  },
244
244
  };
245
- },
246
- // Ownership lives on the registry post-refactor. Mirror that by surfacing
247
- // the optional `owner`-shaped field set inline on the override-produced
248
- // tool (see the skill_* branches above).
249
- getToolOwner: (name: string) => {
250
- if (
251
- name === "skill_host_tool" ||
252
- name === "skill_sandbox_tool" ||
253
- name === "host_skill_sandboxed"
254
- ) {
255
- return { kind: "skill" as const, id: "test-skill" };
256
- }
257
- return undefined;
258
- },
259
- }));
245
+ };
246
+ return {
247
+ getTool: lookup,
248
+ resolveTool: lookup,
249
+ // Ownership lives on the registry post-refactor. Mirror that by surfacing
250
+ // the optional `owner`-shaped field set inline on the override-produced
251
+ // tool (see the skill_* branches above).
252
+ getToolOwner: (name: string) => {
253
+ if (
254
+ name === "skill_host_tool" ||
255
+ name === "skill_sandbox_tool" ||
256
+ name === "host_skill_sandboxed"
257
+ ) {
258
+ return { kind: "skill" as const, id: "test-skill" };
259
+ }
260
+ return undefined;
261
+ },
262
+ };
263
+ });
260
264
 
261
265
  mock.module("../tools/shared/filesystem/path-policy.js", () => ({
262
266
  sandboxPolicy: () => ({ ok: false }),
@@ -116,9 +116,12 @@ mock.module("../permissions/checker.js", () => ({
116
116
  policyContext?: PolicyContext,
117
117
  ) => {
118
118
  lastCheckArgs = { toolName, input, workingDir, policyContext };
119
- if (checkFnOverride)
119
+ if (checkFnOverride) {
120
120
  return checkFnOverride(toolName, input, workingDir, policyContext);
121
- if (checkResultOverride) return checkResultOverride;
121
+ }
122
+ if (checkResultOverride) {
123
+ return checkResultOverride;
124
+ }
122
125
  return { decision: "allow", reason: "allowed" };
123
126
  },
124
127
  generateAllowlistOptions: () => [
@@ -137,19 +140,26 @@ mock.module("../telemetry/tool-usage-store.js", () => ({
137
140
  rotateToolInvocations: async () => 0,
138
141
  }));
139
142
 
143
+ const mockToolLookup = (name: string) => {
144
+ if (getToolOverride) {
145
+ return getToolOverride(name);
146
+ }
147
+ if (name === "unknown_tool") {
148
+ return undefined;
149
+ }
150
+ return {
151
+ name,
152
+ description: "test tool",
153
+ category: "test",
154
+ defaultRiskLevel: "low",
155
+ input_schema: {},
156
+ execute: async () => fakeToolResult,
157
+ };
158
+ };
159
+
140
160
  mock.module("../tools/registry.js", () => ({
141
- getTool: (name: string) => {
142
- if (getToolOverride) return getToolOverride(name);
143
- if (name === "unknown_tool") return undefined;
144
- return {
145
- name,
146
- description: "test tool",
147
- category: "test",
148
- defaultRiskLevel: "low",
149
- input_schema: {},
150
- execute: async () => fakeToolResult,
151
- };
152
- },
161
+ getTool: mockToolLookup,
162
+ resolveTool: mockToolLookup,
153
163
  getAllTools: () => (getAllToolsOverride ? getAllToolsOverride() : []),
154
164
  // Ownership lives on the registry post-refactor; production reads it via
155
165
  // getToolOwner(name) rather than a field on the Tool object. Mirror that by
@@ -386,7 +396,9 @@ describe("ToolExecutor allowedToolNames gating", () => {
386
396
  test("inactive skill tool names the owning skill in the load hint", async () => {
387
397
  const executor = new ToolExecutor(makePrompter());
388
398
  getToolOverride = (name: string) => {
389
- if (name !== "skill_tool_x") return undefined;
399
+ if (name !== "skill_tool_x") {
400
+ return undefined;
401
+ }
390
402
  return {
391
403
  name,
392
404
  description: "tool from a skill",
@@ -423,7 +435,9 @@ describe("ToolExecutor policy context plumbing", () => {
423
435
 
424
436
  test("passes PolicyContext with executionTarget for skill-origin tools", async () => {
425
437
  getToolOverride = (name: string) => {
426
- if (name === "unknown_tool") return undefined;
438
+ if (name === "unknown_tool") {
439
+ return undefined;
440
+ }
427
441
  return {
428
442
  name,
429
443
  description: "skill tool",
@@ -487,7 +501,9 @@ describe("ToolExecutor policy context plumbing", () => {
487
501
 
488
502
  test('passes undefined policyContext for tools with origin "core"', async () => {
489
503
  getToolOverride = (name: string) => {
490
- if (name === "unknown_tool") return undefined;
504
+ if (name === "unknown_tool") {
505
+ return undefined;
506
+ }
491
507
  return {
492
508
  name,
493
509
  description: "core tool",
@@ -520,7 +536,9 @@ describe("ToolExecutor policy context plumbing", () => {
520
536
 
521
537
  test('includes executionTarget "host" from skill tool metadata', async () => {
522
538
  getToolOverride = (name: string) => {
523
- if (name === "unknown_tool") return undefined;
539
+ if (name === "unknown_tool") {
540
+ return undefined;
541
+ }
524
542
  return {
525
543
  name,
526
544
  description: "host skill tool",
@@ -37,6 +37,7 @@ const fakeTool = {
37
37
 
38
38
  mock.module("../tools/registry.js", () => ({
39
39
  getTool: (name: string) => (name === "bash" ? fakeTool : undefined),
40
+ resolveTool: (name: string) => (name === "bash" ? fakeTool : undefined),
40
41
  getAllTools: () => [fakeTool],
41
42
  }));
42
43
 
@@ -66,6 +66,7 @@ const fakeTool = {
66
66
  };
67
67
  mock.module("../tools/registry.js", () => ({
68
68
  getTool: (name: string) => (name === "bash" ? fakeTool : undefined),
69
+ resolveTool: (name: string) => (name === "bash" ? fakeTool : undefined),
69
70
  getAllTools: () => [fakeTool],
70
71
  }));
71
72
 
@@ -119,6 +119,19 @@ mock.module("../tools/registry.js", () => ({
119
119
  execute: async () => fakeToolResult,
120
120
  };
121
121
  },
122
+ resolveTool: (name: string) => {
123
+ if (name === "unknown_tool") {
124
+ return undefined;
125
+ }
126
+ return {
127
+ name,
128
+ description: "test tool",
129
+ category: "test",
130
+ defaultRiskLevel: "low",
131
+ input_schema: {},
132
+ execute: async () => fakeToolResult,
133
+ };
134
+ },
122
135
  getAllTools: () => [],
123
136
  }));
124
137
 
@@ -2,7 +2,6 @@
2
2
  * Wire contract for the conversation history / messages endpoints.
3
3
  *
4
4
  * - `GET /v1/assistants/:id/messages` → `{ messages: ConversationMessage[] }`
5
- * - `POST /v1/messages` send acks echo an `assistantMessage: ConversationMessage`
6
5
  *
7
6
  * Holds the canonical history-row shape produced by the daemon's
8
7
  * `renderHistoryContent` + conversation-routes serializer and consumed by
@@ -480,20 +479,6 @@ export const ConversationMessageSchema = z.object({
480
479
  * scaffolding, never a displayed turn.
481
480
  */
482
481
  role: z.enum(["user", "assistant"]),
483
- /**
484
- * @deprecated Superseded by `contentBlocks`. Flat plain-text body (joined
485
- * text segments). Redundant with `textSegments`/`contentOrder` for clients
486
- * that render from the positional arrays (web, CLI). The serializer always
487
- * emits it — do not remove without auditing clients that read it directly.
488
- */
489
- content: z
490
- .string()
491
- .meta({
492
- deprecated: true,
493
- description:
494
- "Deprecated: superseded by contentBlocks. Flat plain-text body (joined text segments).",
495
- })
496
- .optional(),
497
482
  /** Display timestamp as an ISO-8601 string. */
498
483
  timestamp: z.string(),
499
484
  /**
@@ -3,16 +3,18 @@ import { describe, expect, test } from "bun:test";
3
3
  import { LlmRequestLogsConfigSchema } from "../llm-request-logs.js";
4
4
 
5
5
  describe("LlmRequestLogsConfigSchema", () => {
6
- test("parses undefined to the local default", () => {
6
+ test("parses undefined to the local default with logging enabled", () => {
7
7
  expect(LlmRequestLogsConfigSchema.parse(undefined)).toEqual({
8
8
  readSource: "local",
9
+ enabled: true,
9
10
  });
10
11
  });
11
12
 
12
- test("parses an explicit local readSource", () => {
13
- expect(
14
- LlmRequestLogsConfigSchema.parse({ readSource: "local" }),
15
- ).toEqual({ readSource: "local" });
13
+ test("parses an explicit local readSource with logging enabled by default", () => {
14
+ expect(LlmRequestLogsConfigSchema.parse({ readSource: "local" })).toEqual({
15
+ readSource: "local",
16
+ enabled: true,
17
+ });
16
18
  });
17
19
 
18
20
  test("parses an explicit clickhouse readSource with defaulted connection fields", () => {
@@ -20,6 +22,7 @@ describe("LlmRequestLogsConfigSchema", () => {
20
22
  LlmRequestLogsConfigSchema.parse({ readSource: "clickhouse" }),
21
23
  ).toEqual({
22
24
  readSource: "clickhouse",
25
+ enabled: true,
23
26
  clickhouse: {
24
27
  database: "default",
25
28
  table: "llm_request_logs",
@@ -28,6 +31,31 @@ describe("LlmRequestLogsConfigSchema", () => {
28
31
  });
29
32
  });
30
33
 
34
+ test("carries an explicit enabled flag on the local branch", () => {
35
+ expect(
36
+ LlmRequestLogsConfigSchema.parse({ readSource: "local", enabled: false }),
37
+ ).toEqual({ readSource: "local", enabled: false });
38
+ });
39
+
40
+ test("defaults a missing readSource to local so an enabled-only write still parses", () => {
41
+ // `config set llmRequestLogs.enabled false` writes `{ enabled: false }`
42
+ // with no discriminator; it must parse (on the local branch) rather than
43
+ // collapse the whole config to defaults via leaf-deletion recovery.
44
+ expect(LlmRequestLogsConfigSchema.parse({ enabled: false })).toEqual({
45
+ readSource: "local",
46
+ enabled: false,
47
+ });
48
+ });
49
+
50
+ test("rejects a non-boolean enabled flag", () => {
51
+ expect(() =>
52
+ LlmRequestLogsConfigSchema.parse({
53
+ readSource: "local",
54
+ enabled: "yes",
55
+ }),
56
+ ).toThrow();
57
+ });
58
+
31
59
  test("rejects an unknown readSource", () => {
32
60
  expect(() =>
33
61
  LlmRequestLogsConfigSchema.parse({ readSource: "postgres" }),
@@ -1,8 +1,17 @@
1
1
  /**
2
- * Configuration for LLM request log read source.
2
+ * Configuration for LLM request logging.
3
3
  *
4
- * Writes always land in the local SQLite `llm_request_logs` table; reads
5
- * can be switched between local and ClickHouse via `readSource`.
4
+ * Two independent concerns live here:
5
+ *
6
+ * 1. `enabled` — the master switch. When `false`, the daemon skips every
7
+ * `llm_request_logs` write and the inspector read routes return a 4xx
8
+ * (`LLM_REQUEST_LOGS_DISABLED`) instead of serving rows. Defaults to
9
+ * `true` (logging on). Existing rows are left untouched — this is a
10
+ * write/read gate, not a delete.
11
+ *
12
+ * 2. `readSource` — where reads are served from. Writes land in the local
13
+ * SQLite `llm_request_logs` table; reads can be switched between local
14
+ * and ClickHouse via `readSource`.
6
15
  *
7
16
  * When `readSource === "clickhouse"` the URL and password are resolved
8
17
  * from the credential store (`clickhouse:url`, `clickhouse:password`).
@@ -10,15 +19,37 @@
10
19
  *
11
20
  * The shape is a discriminated union on `readSource` so the `clickhouse`
12
21
  * block only exists on the ClickHouse branch — there's no stray defaults
13
- * sitting around when the source is local.
22
+ * sitting around when the source is local. Both branches extend a shared
23
+ * base (`LlmRequestLogsBaseSchema`) that carries the source-independent
24
+ * fields, and a `preprocess` step defaults a missing `readSource` to
25
+ * `"local"` so a partial write (e.g. `config set llmRequestLogs.enabled
26
+ * false`, which never mentions `readSource`) still parses instead of
27
+ * collapsing the whole config to defaults on the next load.
14
28
  *
15
29
  * Note: the existing retention setting lives under
16
30
  * `memory.cleanup.llmRequestLogRetentionMs` and is independent of this block.
17
- * That covers when local rows get pruned; this block governs where reads
18
- * are served from.
31
+ * That covers when local rows get pruned; this block governs whether logging
32
+ * happens at all and where reads are served from.
19
33
  */
20
34
  import { z } from "zod";
21
35
 
36
+ /**
37
+ * Source-independent fields shared by both read-source branches. Kept as a
38
+ * base object the discriminated-union branches `.extend()` so a field like
39
+ * `enabled` is declared once and lives at a stable top-level path
40
+ * (`llmRequestLogs.enabled`) regardless of `readSource`.
41
+ */
42
+ const LlmRequestLogsBaseSchema = z.object({
43
+ enabled: z
44
+ .boolean({ error: "llmRequestLogs.enabled must be a boolean" })
45
+ .default(true)
46
+ .describe(
47
+ "Master switch for LLM request logging. When false, skip all writes " +
48
+ "and return a 4xx from inspector read routes. Existing rows are not " +
49
+ "deleted.",
50
+ ),
51
+ });
52
+
22
53
  export const LlmRequestLogsClickHouseConfigSchema = z
23
54
  .object({
24
55
  database: z
@@ -41,22 +72,39 @@ export const LlmRequestLogsClickHouseConfigSchema = z
41
72
  "ClickHouse connection settings used when `readSource` is `clickhouse`",
42
73
  );
43
74
 
44
- const LocalLlmRequestLogsConfigSchema = z
45
- .object({
46
- readSource: z.literal("local"),
47
- })
48
- .describe("Read LLM request logs from local SQLite (default).");
75
+ const LocalLlmRequestLogsConfigSchema = LlmRequestLogsBaseSchema.extend({
76
+ readSource: z.literal("local"),
77
+ }).describe("Read LLM request logs from local SQLite (default).");
49
78
 
50
- const ClickHouseLlmRequestLogsConfigSchema = z
51
- .object({
52
- readSource: z.literal("clickhouse"),
53
- clickhouse: LlmRequestLogsClickHouseConfigSchema.default(
54
- LlmRequestLogsClickHouseConfigSchema.parse({}),
55
- ),
56
- })
57
- .describe(
58
- "Read LLM request logs from the ClickHouse mirror. Requires the `clickhouse:url` and `clickhouse:password` credentials to be set.",
59
- );
79
+ const ClickHouseLlmRequestLogsConfigSchema = LlmRequestLogsBaseSchema.extend({
80
+ readSource: z.literal("clickhouse"),
81
+ clickhouse: LlmRequestLogsClickHouseConfigSchema.default(
82
+ LlmRequestLogsClickHouseConfigSchema.parse({}),
83
+ ),
84
+ }).describe(
85
+ "Read LLM request logs from the ClickHouse mirror. Requires the `clickhouse:url` and `clickhouse:password` credentials to be set.",
86
+ );
87
+
88
+ /**
89
+ * Inject `readSource: "local"` when a caller supplies an object without it.
90
+ * A discriminated union cannot pick a branch without its discriminator, so a
91
+ * partial write like `{ enabled: false }` (from `config set
92
+ * llmRequestLogs.enabled false`) would otherwise fail to parse and — via the
93
+ * loader's leaf-deletion recovery — take the whole config down to defaults.
94
+ * Defaulting the discriminator keeps such writes on the `local` branch while
95
+ * preserving any sibling fields (e.g. `enabled`).
96
+ */
97
+ function defaultReadSourceToLocal(value: unknown): unknown {
98
+ if (
99
+ value !== null &&
100
+ typeof value === "object" &&
101
+ !Array.isArray(value) &&
102
+ !("readSource" in value)
103
+ ) {
104
+ return { readSource: "local", ...value };
105
+ }
106
+ return value;
107
+ }
60
108
 
61
109
  // The default is baked into the export so the schema matches the sibling
62
110
  // pattern across `assistant/src/config/schemas/*` — `Schema.parse(undefined)`
@@ -68,12 +116,15 @@ const ClickHouseLlmRequestLogsConfigSchema = z
68
116
  // union cannot pick a branch without a discriminator. Use `parse(undefined)`
69
117
  // or omit the field entirely to get the default.
70
118
  export const LlmRequestLogsConfigSchema = z
71
- .discriminatedUnion("readSource", [
72
- LocalLlmRequestLogsConfigSchema,
73
- ClickHouseLlmRequestLogsConfigSchema,
74
- ])
75
- .default({ readSource: "local" })
76
- .describe("LLM request log read source configuration");
119
+ .preprocess(
120
+ defaultReadSourceToLocal,
121
+ z.discriminatedUnion("readSource", [
122
+ LocalLlmRequestLogsConfigSchema,
123
+ ClickHouseLlmRequestLogsConfigSchema,
124
+ ]),
125
+ )
126
+ .default({ readSource: "local", enabled: true })
127
+ .describe("LLM request logging configuration");
77
128
 
78
129
  export type LlmRequestLogsConfig = z.infer<typeof LlmRequestLogsConfigSchema>;
79
130
  export type LlmRequestLogsClickHouseConfig = z.infer<
@@ -168,7 +168,9 @@ function loadManifestForSkill(skill: SkillSummary): SkillToolManifest | null {
168
168
  * never emit.
169
169
  */
170
170
  function isVellumProducedSkill(skill: SkillSummary): boolean {
171
- if (skill.source === "bundled") return true;
171
+ if (skill.source === "bundled") {
172
+ return true;
173
+ }
172
174
  if (skill.source === "managed") {
173
175
  return readInstallMeta(skill.directoryPath)?.origin === "vellum";
174
176
  }
@@ -186,9 +188,13 @@ function recordSkillLoadedTelemetry(
186
188
  skill: SkillSummary,
187
189
  telemetry: ProjectSkillToolsOptions["telemetry"],
188
190
  ): void {
189
- if (!telemetry) return;
191
+ if (!telemetry) {
192
+ return;
193
+ }
190
194
  try {
191
- if (!isVellumProducedSkill(skill)) return;
195
+ if (!isVellumProducedSkill(skill)) {
196
+ return;
197
+ }
192
198
  const catalogEntry = getCachedCatalogSync().find((s) => s.id === skill.id);
193
199
  recordSkillLoadedEvent({
194
200
  conversationId: telemetry.conversationId,
@@ -213,7 +219,9 @@ function recordSkillLoadedTelemetry(
213
219
  * plugin skills are skipped. Best-effort: the underlying write never throws.
214
220
  */
215
221
  function stampManagedSkillUsage(skill: SkillSummary): void {
216
- if (skill.source !== "managed") return;
222
+ if (skill.source !== "managed") {
223
+ return;
224
+ }
217
225
  try {
218
226
  const today = new Date().toLocaleDateString("en-CA");
219
227
  touchSkillLastUsed(skill.directoryPath, today);
@@ -243,7 +251,9 @@ function getCachedActiveSkills(
243
251
  history: Message[],
244
252
  cache?: SkillProjectionCache,
245
253
  ): ActiveSkillEntry[] {
246
- if (!cache) return deriveActiveSkills(history);
254
+ if (!cache) {
255
+ return deriveActiveSkills(history);
256
+ }
247
257
 
248
258
  const cached = cache.derived;
249
259
 
@@ -306,7 +316,9 @@ function getCachedActiveSkills(
306
316
  * directories changed on disk while the conversation is still processing).
307
317
  */
308
318
  function getCachedCatalog(cache?: SkillProjectionCache): SkillSummary[] {
309
- if (!cache) return loadSkillCatalog();
319
+ if (!cache) {
320
+ return loadSkillCatalog();
321
+ }
310
322
 
311
323
  if (!cache.catalog) {
312
324
  cache.catalog = loadSkillCatalog();
@@ -386,7 +398,9 @@ export function projectSkillTools(
386
398
  // with the no-tools sentinel never registered anything — skip them so we
387
399
  // don't decrement refcounts held by other conversations.
388
400
  for (const id of removedIds) {
389
- if (!hasRegisteredTools(prevActive.get(id))) continue;
401
+ if (!hasRegisteredTools(prevActive.get(id))) {
402
+ continue;
403
+ }
390
404
  log.info({ skillId: id }, "Unregistering tools for deactivated skill");
391
405
  unregisterSkillTools(id);
392
406
  }
@@ -514,7 +528,9 @@ export function projectSkillTools(
514
528
  // because the permission checker derives bundled state from the
515
529
  // live catalog instead of a stamped tool field.
516
530
  accepted = tools.filter((t) => {
517
- if (getTool(t.name) === undefined) return false;
531
+ if (getTool(t.name) === undefined) {
532
+ return false;
533
+ }
518
534
  const owner = getToolOwner(t.name);
519
535
  return owner?.kind === "skill" && owner.id === skillId;
520
536
  });
@@ -572,7 +588,9 @@ export function resetSkillToolProjection(
572
588
  // Sentinel entries (active skills without a manifest) registered no
573
589
  // tools — skip them so we don't decrement refcounts held by other
574
590
  // conversations.
575
- if (!hasRegisteredTools(hash)) continue;
591
+ if (!hasRegisteredTools(hash)) {
592
+ continue;
593
+ }
576
594
  unregisterSkillTools(id);
577
595
  }
578
596
  trackedIds.clear();
@@ -10,6 +10,7 @@ type TestMessage = {
10
10
  createdAt: number;
11
11
  metadata: string | null;
12
12
  clientMessageId: string | null;
13
+ finalized: number;
13
14
  };
14
15
 
15
16
  const parentMessages: TestMessage[] = [
@@ -21,6 +22,7 @@ const parentMessages: TestMessage[] = [
21
22
  createdAt: 1_700_000_000_000,
22
23
  metadata: null,
23
24
  clientMessageId: null,
25
+ finalized: 1,
24
26
  },
25
27
  {
26
28
  id: "msg-parent-2",
@@ -37,6 +39,7 @@ const parentMessages: TestMessage[] = [
37
39
  },
38
40
  }),
39
41
  clientMessageId: null,
42
+ finalized: 1,
40
43
  },
41
44
  ];
42
45
 
@@ -51,6 +54,7 @@ const childMessages: TestMessage[] = [
51
54
  createdAt: 1_700_000_002_000,
52
55
  metadata: null,
53
56
  clientMessageId: null,
57
+ finalized: 1,
54
58
  },
55
59
  {
56
60
  id: "msg-child-2",
@@ -62,6 +66,7 @@ const childMessages: TestMessage[] = [
62
66
  createdAt: 1_700_000_003_000,
63
67
  metadata: null,
64
68
  clientMessageId: null,
69
+ finalized: 1,
65
70
  },
66
71
  ];
67
72
 
@@ -133,6 +133,7 @@ mock.module("./workspace-policy.js", () => ({
133
133
  // owner, so it returns undefined.
134
134
  mock.module("../tools/registry.js", () => ({
135
135
  getTool: () => undefined,
136
+ resolveTool: async () => undefined,
136
137
  getToolOwner: () => undefined,
137
138
  }));
138
139
 
@@ -389,14 +390,10 @@ describe("Permission Checker (gateway IPC)", () => {
389
390
  matchType: "registry",
390
391
  scopeOptions: [],
391
392
  sandboxAutoApprove: true,
392
- sandboxPathArgs: [
393
- "/workspace/safe.txt",
394
- "/workspace/escape/passwd",
395
- ],
393
+ sandboxPathArgs: ["/workspace/safe.txt", "/workspace/escape/passwd"],
396
394
  };
397
395
  const result = await classifyRisk("bash", {
398
- command:
399
- "cat /workspace/safe.txt && cat /workspace/escape/passwd",
396
+ command: "cat /workspace/safe.txt && cat /workspace/escape/passwd",
400
397
  });
401
398
  expect((result as any).sandboxAutoApprove).toBe(false);
402
399
  mockIsPathWithinWorkspaceRoot = true;
@@ -16,7 +16,7 @@ import {
16
16
  looksLikeHostPortShorthand,
17
17
  looksLikePathOnlyInput,
18
18
  } from "../tools/network/url-safety.js";
19
- import { getTool, getToolOwner } from "../tools/registry.js";
19
+ import { getTool, getToolOwner, resolveTool } from "../tools/registry.js";
20
20
  import { resolveRealPath } from "../tools/shared/filesystem/path-policy.js";
21
21
  import type { Tool } from "../tools/types.js";
22
22
  import {
@@ -862,7 +862,7 @@ export async function check(
862
862
  const hasSandboxAutoApprove = classification.sandboxAutoApprove ?? false;
863
863
 
864
864
  // Build approval context from local variables
865
- const tool = getTool(toolName);
865
+ const tool = await resolveTool(toolName);
866
866
  const cellQuery = buildChannelPermissionCellQuery(policyContext);
867
867
  const threshold = await getAutoApproveThreshold(
868
868
  policyContext?.conversationId,