@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.
Files changed (161) hide show
  1. package/AGENTS.md +1 -1
  2. package/examples/plugins/echo/README.md +3 -3
  3. package/node_modules/@vellumai/skill-host-contracts/src/tool-types.ts +2 -0
  4. package/openapi.yaml +38 -12
  5. package/package.json +1 -1
  6. package/scripts/sync-llm-catalog.ts +2 -0
  7. package/src/__tests__/agent-loop-exit-reason.test.ts +21 -15
  8. package/src/__tests__/approval-cascade.test.ts +1 -0
  9. package/src/__tests__/build-persisted-content.test.ts +75 -1
  10. package/src/__tests__/compaction-events.test.ts +1 -0
  11. package/src/__tests__/config-managed-gemini-defaults.test.ts +2 -46
  12. package/src/__tests__/context-overflow-reducer.test.ts +264 -124
  13. package/src/__tests__/context-window-manager-overflow-rung.test.ts +351 -0
  14. package/src/__tests__/conversation-abort-tool-results.test.ts +1 -0
  15. package/src/__tests__/conversation-agent-loop-inference-profile.test.ts +11 -0
  16. package/src/__tests__/conversation-agent-loop-overflow.test.ts +90 -49
  17. package/src/__tests__/conversation-agent-loop.test.ts +113 -64
  18. package/src/__tests__/conversation-confirmation-signals.test.ts +1 -0
  19. package/src/__tests__/conversation-fork-crud.test.ts +110 -0
  20. package/src/__tests__/conversation-process-callsite.test.ts +1 -0
  21. package/src/__tests__/conversation-provider-retry-repair.test.ts +48 -48
  22. package/src/__tests__/conversation-queue.test.ts +1 -0
  23. package/src/__tests__/conversation-runtime-assembly.test.ts +119 -8
  24. package/src/__tests__/conversation-slash-queue.test.ts +1 -0
  25. package/src/__tests__/conversation-slash-unknown.test.ts +1 -0
  26. package/src/__tests__/conversation-speed-override.test.ts +1 -0
  27. package/src/__tests__/conversation-surfaces-app-control.test.ts +4 -1
  28. package/src/__tests__/conversation-tool-setup-app-refresh.test.ts +91 -142
  29. package/src/__tests__/conversation-tool-setup-skill-attribution.test.ts +116 -0
  30. package/src/__tests__/conversation-tool-setup-test-helpers.ts +98 -0
  31. package/src/__tests__/conversation-workspace-cache-state.test.ts +1 -0
  32. package/src/__tests__/conversation-workspace-injection.test.ts +1 -0
  33. package/src/__tests__/conversation-workspace-tool-tracking.test.ts +1 -0
  34. package/src/__tests__/corrected-target.test.ts +93 -0
  35. package/src/__tests__/credential-execution-feature-gates.test.ts +3 -5
  36. package/src/__tests__/credential-security-invariants.test.ts +1 -0
  37. package/src/__tests__/embedding-managed-proxy-selection.test.ts +6 -40
  38. package/src/__tests__/external-plugin-loader.test.ts +0 -1
  39. package/src/__tests__/guardian-routing-invariants.test.ts +91 -0
  40. package/src/__tests__/history-repair-hook.test.ts +2 -0
  41. package/src/__tests__/host-app-control-proxy.test.ts +45 -0
  42. package/src/__tests__/llm-catalog-parity.test.ts +4 -0
  43. package/src/__tests__/memory-retrieval-hook.test.ts +29 -15
  44. package/src/__tests__/notification-decision-strategy.test.ts +3 -3
  45. package/src/__tests__/persistence-secret-redaction.test.ts +78 -0
  46. package/src/__tests__/plugin-bootstrap.test.ts +82 -73
  47. package/src/__tests__/plugin-tool-contribution.test.ts +7 -4
  48. package/src/__tests__/plugin-types.test.ts +0 -8
  49. package/src/__tests__/provider-catalog-visibility.test.ts +1 -9
  50. package/src/__tests__/retry-thinking-adaptive-only.test.ts +245 -0
  51. package/src/__tests__/server-history-render.test.ts +39 -0
  52. package/src/__tests__/skills.test.ts +123 -0
  53. package/src/__tests__/title-generate-hook.test.ts +2 -0
  54. package/src/__tests__/tool-audit-listener.test.ts +51 -0
  55. package/src/__tests__/tool-executor-lifecycle-events.test.ts +32 -0
  56. package/src/__tests__/tool-start-timestamp.test.ts +218 -0
  57. package/src/agent/loop.ts +26 -39
  58. package/src/api/events/tool-result.ts +9 -0
  59. package/src/api/events/tool-use-start.ts +7 -0
  60. package/src/api/responses/conversation-message.ts +91 -14
  61. package/src/approvals/guardian-request-resolvers.ts +26 -0
  62. package/src/cli/commands/channel-verification-sessions.ts +6 -6
  63. package/src/cli/commands/inference-providers.ts +0 -8
  64. package/src/cli/commands/plugins.ts +2 -2
  65. package/src/cli/lib/__tests__/install-from-github.test.ts +174 -18
  66. package/src/cli/lib/__tests__/plugin-catalog-cache.test.ts +1 -1
  67. package/src/cli/lib/__tests__/plugin-details.test.ts +1 -1
  68. package/src/cli/lib/__tests__/plugin-marketplace.test.ts +1 -1
  69. package/src/cli/lib/__tests__/search-plugins.test.ts +11 -11
  70. package/src/cli/lib/install-from-github.ts +130 -19
  71. package/src/cli/lib/plugin-catalog-cache.ts +1 -1
  72. package/src/cli/lib/plugin-details.ts +4 -4
  73. package/src/cli/lib/plugin-marketplace.ts +2 -2
  74. package/src/cli/lib/search-plugins.ts +6 -6
  75. package/src/config/bundled-skills/skill-management/SKILL.md +89 -1
  76. package/src/config/env-registry.ts +12 -0
  77. package/src/config/feature-flag-registry.json +0 -80
  78. package/src/config/loader.ts +5 -22
  79. package/src/config/seed-inference-profiles.ts +1 -1
  80. package/src/config/skills.ts +101 -47
  81. package/src/context/strip-injections.ts +7 -4
  82. package/src/daemon/conversation-agent-loop-handlers.ts +102 -6
  83. package/src/daemon/conversation-agent-loop.ts +126 -270
  84. package/src/daemon/conversation-runtime-assembly.ts +44 -8
  85. package/src/daemon/conversation-tool-setup.ts +9 -1
  86. package/src/daemon/conversation.ts +13 -0
  87. package/src/daemon/external-plugins-bootstrap.ts +33 -87
  88. package/src/daemon/handlers/config-channels.ts +11 -2
  89. package/src/daemon/handlers/shared.ts +9 -1
  90. package/src/daemon/handlers/skills.ts +6 -2
  91. package/src/daemon/host-app-control-proxy.ts +72 -57
  92. package/src/daemon/message-protocol.ts +0 -7
  93. package/src/daemon/message-types/skills.ts +4 -0
  94. package/src/events/tool-audit-listener.ts +7 -1
  95. package/src/memory/__tests__/tool-invocation-test-helpers.ts +69 -0
  96. package/src/memory/conversation-crud.ts +44 -1
  97. package/src/memory/db-init.ts +4 -0
  98. package/src/memory/embedding-backend.ts +5 -22
  99. package/src/memory/memory-retrospective-startup-cleanup.ts +1 -1
  100. package/src/memory/migrations/275-tool-invocations-add-skill-id.test.ts +81 -0
  101. package/src/memory/migrations/275-tool-invocations-add-skill-id.ts +20 -0
  102. package/src/memory/migrations/276-tool-invocations-created-at-id-index.test.ts +68 -0
  103. package/src/memory/migrations/276-tool-invocations-created-at-id-index.ts +20 -0
  104. package/src/memory/migrations/index.ts +2 -0
  105. package/src/memory/schema/conversations.ts +3 -0
  106. package/src/memory/tool-execution-events-store.test.ts +162 -0
  107. package/src/memory/tool-execution-events-store.ts +73 -0
  108. package/src/memory/tool-usage-store.ts +4 -3
  109. package/src/memory/v2/__tests__/injected-block-slugs.test.ts +51 -0
  110. package/src/memory/v2/activation-store.ts +50 -1
  111. package/src/memory/v2/injected-block-slugs.ts +30 -0
  112. package/src/notifications/__tests__/copy-composer.test.ts +244 -0
  113. package/src/notifications/access-request-copy.ts +298 -0
  114. package/src/notifications/adapters/slack.ts +3 -3
  115. package/src/notifications/adapters/telegram.ts +2 -1
  116. package/src/notifications/copy-composer.ts +49 -267
  117. package/src/notifications/decision-engine.ts +16 -35
  118. package/src/notifications/home-feed-side-effect.ts +1 -6
  119. package/src/platform/client.ts +1 -3
  120. package/src/platform/feature-gate.ts +3 -12
  121. package/src/plugin-api/constants.ts +2 -0
  122. package/src/plugin-api/index.ts +37 -6
  123. package/src/plugin-api/types.ts +75 -0
  124. package/src/plugins/defaults/compaction/compact.ts +39 -1
  125. package/src/plugins/defaults/compaction/context-overflow-reducer.ts +240 -32
  126. package/src/plugins/defaults/compaction/corrected-target.ts +53 -0
  127. package/src/plugins/defaults/compaction/window-manager.ts +195 -1
  128. package/src/plugins/defaults/index.ts +24 -0
  129. package/src/plugins/defaults/memory-retrieval/hooks/post-compact.ts +76 -112
  130. package/src/plugins/defaults/memory-retrieval/hooks/{user-prompt-submit-temp.ts → user-prompt-submit.ts} +36 -67
  131. package/src/plugins/defaults/memory-retrieval/package.json +14 -0
  132. package/src/plugins/external-api.ts +1 -1
  133. package/src/plugins/types.ts +5 -51
  134. package/src/providers/inference/__tests__/base-url-route-validation.test.ts +1 -2
  135. package/src/providers/model-catalog.ts +57 -1
  136. package/src/providers/registry.ts +0 -8
  137. package/src/providers/retry.ts +35 -7
  138. package/src/runtime/routes/__tests__/acp-routes.test.ts +151 -0
  139. package/src/runtime/routes/__tests__/inference-provider-connection-routes.test.ts +0 -62
  140. package/src/runtime/routes/__tests__/plugins-routes.test.ts +4 -4
  141. package/src/runtime/routes/acp-routes.test.ts +106 -0
  142. package/src/runtime/routes/acp-routes.ts +248 -2
  143. package/src/runtime/routes/browser-tabs-routes.ts +1 -1
  144. package/src/runtime/routes/channel-verification-routes.ts +14 -5
  145. package/src/runtime/routes/chatgpt-subscription-auth-routes.ts +0 -14
  146. package/src/runtime/routes/inbound-stages/acl-enforcement.ts +33 -34
  147. package/src/runtime/routes/inference-provider-connection-routes.ts +0 -45
  148. package/src/runtime/routes/plugins-routes.ts +3 -3
  149. package/src/runtime/verification-outbound-actions.ts +147 -2
  150. package/src/runtime/verification-templates.ts +29 -3
  151. package/src/telemetry/types.ts +25 -1
  152. package/src/telemetry/usage-telemetry-reporter.test.ts +141 -7
  153. package/src/telemetry/usage-telemetry-reporter.ts +63 -7
  154. package/src/tools/executor.ts +4 -1
  155. package/src/tools/skills/load.ts +11 -6
  156. package/src/tools/terminal/safe-env.ts +1 -0
  157. package/src/tools/types.ts +10 -0
  158. package/src/__tests__/plugin-skill-contribution.test.ts +0 -355
  159. package/src/daemon/message-types/browser.ts +0 -10
  160. package/src/notifications/__tests__/emit-signal-home-feed.test.ts +0 -187
  161. package/src/plugins/plugin-skill-contributions.ts +0 -292
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Tests for the default `user-prompt-submit-temp` hook (memory retrieval +
2
+ * Tests for the default `user-prompt-submit` hook (memory retrieval +
3
3
  * runtime injection).
4
4
  *
5
5
  * Covers the retrieval behavior, the side effects the hook owns (injected-block
@@ -37,6 +37,7 @@ const applyRuntimeInjectionsMock = mock(async (messages: unknown) => ({
37
37
  mock.module("../daemon/conversation-runtime-assembly.js", () => ({
38
38
  applyRuntimeInjections: applyRuntimeInjectionsMock,
39
39
  resolveTurnInboundActorContext: () => null,
40
+ resolveTurnModelProfileLabel: () => null,
40
41
  }));
41
42
 
42
43
  // The hook self-resolves the live conversation and its trust class; both are
@@ -56,14 +57,22 @@ mock.module("../config/loader.js", () => ({
56
57
  getConfig: () => ({}) as AssistantConfig,
57
58
  }));
58
59
 
60
+ // The hook publishes `memory_recalled` (and forwards the sink into
61
+ // `prepareMemory` for `memory_status`) through the shared `broadcastMessage`
62
+ // hub. Stub it so tests can assert what the hook emits.
63
+ const broadcastMessageMock = mock((_msg: unknown) => {});
64
+ mock.module("../runtime/assistant-event-hub.js", () => ({
65
+ broadcastMessage: broadcastMessageMock,
66
+ }));
67
+
68
+ import type { UserPromptSubmitContext } from "@vellumai/plugin-api";
69
+
59
70
  import type { AssistantConfig } from "../config/schema.js";
60
71
  import type { Conversation } from "../daemon/conversation.js";
61
72
  import type { ServerMessage } from "../daemon/message-protocol.js";
62
73
  import type { ConversationGraphMemory } from "../memory/graph/conversation-graph-memory.js";
63
74
  import type { QdrantSparseVector } from "../memory/qdrant-client.js";
64
- import userPromptSubmitMemoryRetrieval, {
65
- type MemoryRetrievalHookContext,
66
- } from "../plugins/defaults/memory-retrieval/hooks/user-prompt-submit-temp.js";
75
+ import userPromptSubmitMemoryRetrieval from "../plugins/defaults/memory-retrieval/hooks/user-prompt-submit.js";
67
76
  import type { Message } from "../providers/types.js";
68
77
 
69
78
  /** Canonical metrics payload the graph retriever attaches to a real hit. */
@@ -136,19 +145,20 @@ function makeFakeGraphMemory(overrides?: {
136
145
  }
137
146
 
138
147
  function makeHookCtx(
139
- overrides: Partial<MemoryRetrievalHookContext> = {},
140
- ): MemoryRetrievalHookContext {
148
+ overrides: Partial<UserPromptSubmitContext> = {},
149
+ ): UserPromptSubmitContext {
141
150
  return {
142
- onEvent: () => {},
143
151
  conversationId: "conv-test",
144
152
  userMessageId: "msg-test",
145
153
  logger: {
146
154
  warn: () => {},
147
- } as unknown as MemoryRetrievalHookContext["logger"],
155
+ } as unknown as UserPromptSubmitContext["logger"],
148
156
  latestMessages: [],
149
157
  requestId: "req-test",
150
158
  isNonInteractive: false,
151
- modelProfile: null,
159
+ modelProfileKey: null,
160
+ prompt: "",
161
+ originalMessages: [],
152
162
  ...overrides,
153
163
  };
154
164
  }
@@ -160,7 +170,10 @@ function makeHookCtx(
160
170
  */
161
171
  function installConversation(
162
172
  graphMemory: ConversationGraphMemory,
163
- opts?: { trusted?: boolean; signal?: AbortSignal },
173
+ opts?: {
174
+ trusted?: boolean;
175
+ signal?: AbortSignal;
176
+ },
164
177
  ): void {
165
178
  currentTrustClass = opts?.trusted === false ? "unknown" : "guardian";
166
179
  currentConversation = {
@@ -175,11 +188,12 @@ beforeEach(() => {
175
188
  recordMemoryRecallLogMock.mockReset();
176
189
  applyRuntimeInjectionsMock.mockClear();
177
190
  findConversationOrSubagentMock.mockClear();
191
+ broadcastMessageMock.mockReset();
178
192
  currentConversation = undefined;
179
193
  currentTrustClass = "guardian";
180
194
  });
181
195
 
182
- describe("user-prompt-submit-temp hook (memory retrieval)", () => {
196
+ describe("user-prompt-submit hook (memory retrieval)", () => {
183
197
  test("adopts the injected run messages when the actor is trusted", async () => {
184
198
  const injected: Message[] = [
185
199
  { role: "user", content: [{ type: "text", text: "injected" }] },
@@ -299,14 +313,12 @@ describe("user-prompt-submit-temp hook (memory retrieval)", () => {
299
313
  });
300
314
 
301
315
  test("persists injected block, recall log, and emits memory_recalled", async () => {
302
- const received: ServerMessage[] = [];
303
316
  const { memory } = makeFakeGraphMemory({
304
317
  injectedBlockText: "injected-block",
305
318
  metrics: makeMetrics(),
306
319
  });
307
320
  installConversation(memory, { trusted: true });
308
321
  const ctx = makeHookCtx({
309
- onEvent: (msg) => received.push(msg),
310
322
  userMessageId: "msg-42",
311
323
  conversationId: "conv-42",
312
324
  });
@@ -323,8 +335,10 @@ describe("user-prompt-submit-temp hook (memory retrieval)", () => {
323
335
  };
324
336
  expect(logEntry.conversationId).toBe("conv-42");
325
337
  expect(logEntry.reason).toBe("graph:none");
326
- expect(received).toHaveLength(1);
327
- expect(received[0]?.type).toBe("memory_recalled");
338
+ // The `memory_recalled` summary publishes through the shared broadcast hub.
339
+ expect(broadcastMessageMock).toHaveBeenCalledTimes(1);
340
+ const emitted = broadcastMessageMock.mock.calls[0]?.[0] as ServerMessage;
341
+ expect(emitted.type).toBe("memory_recalled");
328
342
  });
329
343
 
330
344
  test("skips metadata persist when no block text is injected", async () => {
@@ -9,17 +9,17 @@
9
9
 
10
10
  import { describe, expect, test } from "bun:test";
11
11
 
12
- import type { ConversationCandidateSet } from "../notifications/conversation-candidates.js";
13
12
  import {
14
13
  buildAccessRequestContractText,
15
14
  buildAccessRequestIdentityLine,
16
- composeFallbackCopy,
17
15
  hasAccessRequestInstructions,
18
16
  hasInviteFlowDirective,
19
17
  normalizeForDirectiveMatching,
20
18
  sanitizeIdentityField,
21
19
  sanitizeMessagePreview,
22
- } from "../notifications/copy-composer.js";
20
+ } from "../notifications/access-request-copy.js";
21
+ import type { ConversationCandidateSet } from "../notifications/conversation-candidates.js";
22
+ import { composeFallbackCopy } from "../notifications/copy-composer.js";
23
23
  import {
24
24
  enforceGuardianCallConversationAffinity,
25
25
  validateConversationActions,
@@ -370,3 +370,81 @@ describe("persistence-layer secret redaction", () => {
370
370
  expect(textBlock?.text).toBe(text);
371
371
  });
372
372
  });
373
+
374
+ describe("thinking timing persistence", () => {
375
+ let state: EventHandlerState;
376
+
377
+ beforeEach(() => {
378
+ addMessageCalls.length = 0;
379
+ state = createEventHandlerState();
380
+ state.turnStartedAt = 1_700_000_000_000;
381
+ });
382
+
383
+ afterEach(() => {
384
+ addMessageCalls.length = 0;
385
+ });
386
+
387
+ function makeThinkingCompleteEvent(): Extract<
388
+ AgentEvent,
389
+ { type: "message_complete" }
390
+ > {
391
+ return {
392
+ type: "message_complete",
393
+ message: {
394
+ role: "assistant",
395
+ content: [
396
+ { type: "thinking", thinking: "let me reason", signature: "sig" },
397
+ { type: "text", text: "the answer" },
398
+ ],
399
+ },
400
+ };
401
+ }
402
+
403
+ test("stamps per-block thinking timing onto the persisted thinking block", async () => {
404
+ // GIVEN a turn whose row was reserved at llm_call_started
405
+ await handleLlmCallStarted(state, makeDeps());
406
+
407
+ // AND streaming then captured timing for one thinking block (startedAt when
408
+ // it opened, completedAt at its last reasoning delta). The reserve resets
409
+ // the accumulator, so deltas — and thus the timing — land after it.
410
+ state.currentThinkingTimestamps = [{ startedAt: 1000, completedAt: 1750 }];
411
+
412
+ // WHEN the message completes and content is persisted
413
+ await handleMessageComplete(state, makeDeps(), makeThinkingCompleteEvent());
414
+
415
+ // THEN the persisted thinking block carries the internal `_`-prefixed
416
+ // timing so a history reload can surface the duration + "Started at" hover
417
+ const persisted = lastPersisted("assistant");
418
+ const blocks = JSON.parse(persisted.content) as Array<{
419
+ type: string;
420
+ _startedAt?: number;
421
+ _completedAt?: number;
422
+ }>;
423
+ const thinkingBlock = blocks.find((b) => b.type === "thinking");
424
+ expect(thinkingBlock?._startedAt).toBe(1000);
425
+ expect(thinkingBlock?._completedAt).toBe(1750);
426
+ });
427
+
428
+ test("persists no thinking timing when none was captured this turn", async () => {
429
+ // GIVEN a turn that produced a thinking block but captured no timing
430
+ // (thinking streaming disabled, so the timing list stays empty)
431
+ expect(state.currentThinkingTimestamps).toEqual([]);
432
+
433
+ // WHEN the message completes and content is persisted
434
+ await handleLlmCallStarted(state, makeDeps());
435
+ await handleMessageComplete(state, makeDeps(), makeThinkingCompleteEvent());
436
+
437
+ // THEN the thinking block is persisted without timing, so the client hides
438
+ // the duration exactly as a tool call with no timing
439
+ const persisted = lastPersisted("assistant");
440
+ const blocks = JSON.parse(persisted.content) as Array<{
441
+ type: string;
442
+ _startedAt?: number;
443
+ _completedAt?: number;
444
+ }>;
445
+ const thinkingBlock = blocks.find((b) => b.type === "thinking");
446
+ expect(thinkingBlock).toBeDefined();
447
+ expect(thinkingBlock?._startedAt).toBeUndefined();
448
+ expect(thinkingBlock?._completedAt).toBeUndefined();
449
+ });
450
+ });
@@ -42,11 +42,7 @@ import {
42
42
  registerPlugin,
43
43
  resetPluginRegistryForTests,
44
44
  } from "../plugins/registry.js";
45
- import {
46
- type Plugin,
47
- PluginExecutionError,
48
- type PluginInitContext,
49
- } from "../plugins/types.js";
45
+ import { type Plugin, type PluginInitContext } from "../plugins/types.js";
50
46
  import { APP_VERSION } from "../version.js";
51
47
  import { setOverridesForTesting } from "./feature-flag-test-helpers.js";
52
48
 
@@ -174,9 +170,9 @@ describe("plugin bootstrap", () => {
174
170
  expect(received?.credentials).toEqual({ "some-key": "super-secret-value" });
175
171
  });
176
172
 
177
- test("credential resolution: missing credential fails bootstrap with the plugin named", async () => {
173
+ test("credential resolution: a plugin whose required credential is missing is skipped, not fatal", async () => {
174
+ // GIVEN a plugin that requires a credential the store cannot resolve
178
175
  getSecureKeyAsyncMock.mockImplementation(async () => undefined);
179
-
180
176
  registerPlugin(
181
177
  buildPlugin(
182
178
  "missing-cred",
@@ -185,16 +181,14 @@ describe("plugin bootstrap", () => {
185
181
  ),
186
182
  );
187
183
 
188
- let caught: unknown;
189
- try {
190
- await bootstrapPlugins();
191
- } catch (err) {
192
- caught = err;
193
- }
194
- expect(caught).toBeInstanceOf(PluginExecutionError);
195
- const msg = (caught as PluginExecutionError).message;
196
- expect(msg).toContain("missing-cred");
197
- expect(msg).toContain("absent-key");
184
+ // WHEN bootstrap runs
185
+ // THEN it completes without throwing — the unresolvable credential is
186
+ // contained to that plugin (same per-plugin isolation as an init throw)
187
+ await bootstrapPlugins();
188
+
189
+ // AND the plugin is dropped from the registry
190
+ const names = getRegisteredPlugins().map((p) => p.manifest.name);
191
+ expect(names).not.toContain("missing-cred");
198
192
  });
199
193
 
200
194
  test("version mismatch: external plugin loader rejects when peerDependency unsatisfied", async () => {
@@ -208,7 +202,8 @@ describe("plugin bootstrap", () => {
208
202
  expect(() => registerPlugin(plugin)).not.toThrow();
209
203
  });
210
204
 
211
- test("plugin init throw: bootstrap throws a PluginExecutionError naming the plugin", async () => {
205
+ test("plugin init throw: bootstrap contains the failure and does not throw", async () => {
206
+ // GIVEN a plugin whose init throws
212
207
  registerPlugin(
213
208
  buildPlugin("broken", {
214
209
  async init() {
@@ -217,65 +212,91 @@ describe("plugin bootstrap", () => {
217
212
  }),
218
213
  );
219
214
 
220
- let caught: unknown;
221
- try {
222
- await bootstrapPlugins();
223
- } catch (err) {
224
- caught = err;
225
- }
226
- expect(caught).toBeInstanceOf(PluginExecutionError);
227
- const msg = (caught as PluginExecutionError).message;
228
- expect(msg).toContain("broken");
229
- expect(msg).toContain("kaboom");
215
+ // WHEN bootstrap runs
216
+ // THEN it completes without throwing — a single plugin's init failure is
217
+ // contained to that plugin rather than aborting the whole plugin layer
218
+ await bootstrapPlugins();
219
+
220
+ // AND the failing plugin is dropped from the registry so its hooks never
221
+ // participate in the turn lifecycle
222
+ const names = getRegisteredPlugins().map((p) => p.manifest.name);
223
+ expect(names).not.toContain("broken");
230
224
  });
231
225
 
232
- test("partial-init failure: earlier plugins' onShutdown runs in reverse before the error propagates", async () => {
233
- // If plugin N throws during init, every plugin 1..N-1 that already made
234
- // it through its full init+contribution phase must have onShutdown()
235
- // invoked in reverse registration order before bootstrap re-throws.
236
- // Without this, earlier plugins leak live tools/routes/skills because
237
- // the shutdown hook is only registered once the entire loop completes.
238
- const callOrder: string[] = [];
226
+ test("mid-list init failure: surrounding plugins still initialize and survive", async () => {
227
+ // GIVEN two healthy plugins surrounding one whose init throws, registered
228
+ // in order
229
+ const initialized: string[] = [];
230
+ const shutDownDuringBootstrap: string[] = [];
239
231
  registerPlugin(
240
- buildPlugin("survivor-a", {
241
- async init() {},
232
+ buildPlugin("before", {
233
+ async init() {
234
+ initialized.push("before");
235
+ },
242
236
  async onShutdown() {
243
- callOrder.push("survivor-a");
237
+ shutDownDuringBootstrap.push("before");
244
238
  },
245
239
  }),
246
240
  );
247
241
  registerPlugin(
248
- buildPlugin("survivor-b", {
249
- async init() {},
250
- async onShutdown() {
251
- callOrder.push("survivor-b");
242
+ buildPlugin("failing", {
243
+ async init() {
244
+ throw new Error("mid-bootstrap failure");
252
245
  },
253
246
  }),
254
247
  );
255
248
  registerPlugin(
256
- buildPlugin("failing", {
249
+ buildPlugin("after", {
257
250
  async init() {
258
- throw new Error("mid-bootstrap failure");
251
+ initialized.push("after");
259
252
  },
260
253
  async onShutdown() {
261
- // Never called — this plugin never completes init, so it was never
262
- // added to the active list that teardown walks.
263
- callOrder.push("failing");
254
+ shutDownDuringBootstrap.push("after");
264
255
  },
265
256
  }),
266
257
  );
267
258
 
268
- let caught: unknown;
269
- try {
270
- await bootstrapPlugins();
271
- } catch (err) {
272
- caught = err;
273
- }
274
- expect(caught).toBeInstanceOf(PluginExecutionError);
275
-
276
- // Reverse order: survivor-b registered after survivor-a, so it tears
277
- // down first; "failing" never entered the active list.
278
- expect(callOrder).toEqual(["survivor-b", "survivor-a"]);
259
+ // WHEN bootstrap runs
260
+ await bootstrapPlugins();
261
+
262
+ // THEN both healthy plugins initialized — the one registered after the
263
+ // failure is not skipped
264
+ expect(initialized).toEqual(["before", "after"]);
265
+ // AND neither healthy plugin was torn down by the failure (their
266
+ // onShutdown only runs at real shutdown, not during bootstrap)
267
+ expect(shutDownDuringBootstrap).toEqual([]);
268
+ // AND the failing plugin is dropped while both survivors remain registered
269
+ const names = getRegisteredPlugins().map((p) => p.manifest.name);
270
+ expect(names).toContain("before");
271
+ expect(names).toContain("after");
272
+ expect(names).not.toContain("failing");
273
+ });
274
+
275
+ test("user-plugin init failure leaves the first-party defaults registered", async () => {
276
+ // GIVEN the first-party defaults are registered ahead of user plugins, as
277
+ // at daemon startup
278
+ registerDefaultPlugins();
279
+ // AND a user plugin registered after them whose init throws
280
+ registerPlugin(
281
+ buildPlugin("breaking-user-plugin", {
282
+ async init() {
283
+ throw new Error("user plugin boom");
284
+ },
285
+ }),
286
+ );
287
+
288
+ // WHEN bootstrap runs
289
+ await bootstrapPlugins();
290
+
291
+ // THEN the failing user plugin is dropped from the registry
292
+ const names = getRegisteredPlugins().map((p) => p.manifest.name);
293
+ expect(names).not.toContain("breaking-user-plugin");
294
+ // AND every first-party default survived, so core turn behavior (memory
295
+ // retrieval, history repair, title generation) keeps running in degraded
296
+ // mode instead of being torn down with the failing plugin
297
+ expect(names).toContain("default-memory-retrieval");
298
+ expect(names).toContain("default-history-repair");
299
+ expect(names).toContain("default-title-generate");
279
300
  });
280
301
 
281
302
  test("shutdown order: onShutdown fires in reverse registration order", async () => {
@@ -378,11 +399,11 @@ describe("plugin bootstrap", () => {
378
399
  expect(initFired).toBe(true);
379
400
  });
380
401
 
381
- test("requiresFlag disabled: init does not fire and no tools/routes/skills are registered", async () => {
402
+ test("requiresFlag disabled: init does not fire and no tools/routes are registered", async () => {
382
403
  setOverridesForTesting({ "plugin-gated-disabled": false });
383
404
 
384
405
  let initFired = false;
385
- // Attach tool/route/skill contributions alongside init. If gating works,
406
+ // Attach tool/route contributions alongside init. If gating works,
386
407
  // none of them should land in their respective registries.
387
408
  const plugin = buildPlugin(
388
409
  "gated-off",
@@ -409,24 +430,14 @@ describe("plugin bootstrap", () => {
409
430
  handler: async () => new Response("ok"),
410
431
  },
411
432
  ],
412
- skills: [
413
- {
414
- id: "gated-off/skill",
415
- name: "gated-off-skill",
416
- description: "should not be catalogued",
417
- body: "# unused",
418
- },
419
- ],
420
433
  },
421
434
  { requiresFlag: ["plugin-gated-disabled"] },
422
435
  );
423
436
  registerPlugin(plugin);
424
437
 
425
- // Grab tool / route / skill introspection helpers lazily so the import
438
+ // Grab tool / route introspection helpers lazily so the import
426
439
  // side effect happens after `mock.module` has taken effect.
427
440
  const { getTool } = await import("../tools/registry.js");
428
- const { getPluginSkillRefCount } =
429
- await import("../plugins/plugin-skill-contributions.js");
430
441
  const { matchSkillRoute } =
431
442
  await import("../runtime/skill-route-registry.js");
432
443
 
@@ -438,8 +449,6 @@ describe("plugin bootstrap", () => {
438
449
  expect(getTool("gated-off-tool")).toBeUndefined();
439
450
  // No route wired up — `matchSkillRoute` returns null when nothing matches.
440
451
  expect(matchSkillRoute("/_plugin/gated-off/status", "GET")).toBeNull();
441
- // No skill catalogued under this plugin's name — ref count stays 0.
442
- expect(getPluginSkillRefCount("gated-off")).toBe(0);
443
452
  });
444
453
 
445
454
  test("requiresFlag absent: plugin activates unconditionally", async () => {
@@ -218,9 +218,7 @@ describe("plugin tool contributions", () => {
218
218
  });
219
219
 
220
220
  test("tools are only registered after init() succeeds", async () => {
221
- // A plugin whose init throws must not contribute tools — the bootstrap
222
- // aborts with a PluginExecutionError, and nothing from this plugin
223
- // should leak into the tool registry.
221
+ // GIVEN a plugin that declares a tool but throws during init()
224
222
  const plugin = buildPlugin("delta-broken", {
225
223
  async init() {
226
224
  throw new Error("boom");
@@ -229,7 +227,12 @@ describe("plugin tool contributions", () => {
229
227
  });
230
228
  registerPlugin(plugin);
231
229
 
232
- await expect(bootstrapPlugins()).rejects.toThrow(/delta-broken/);
230
+ // WHEN bootstrap runs
231
+ // THEN it does not throw — the init failure is contained to this plugin
232
+ await bootstrapPlugins();
233
+
234
+ // AND the failing plugin's tool is rolled back, never leaking into the
235
+ // registry
233
236
  expect(getTool("delta-tool")).toBeUndefined();
234
237
  });
235
238
  });
@@ -78,14 +78,6 @@ describe("plugin core types", () => {
78
78
  handler: async () => new Response("ok", { status: 200 }),
79
79
  },
80
80
  ],
81
- skills: [
82
- {
83
- id: "sample-skill",
84
- name: "Sample Skill",
85
- description: "Demo plugin-contributed skill",
86
- body: "## Sample\n\nPlugin-provided skill body.",
87
- },
88
- ],
89
81
  } satisfies Plugin;
90
82
 
91
83
  // Minimal runtime check so the test body is non-empty.
@@ -19,19 +19,11 @@ function makeConfig(): AssistantConfig {
19
19
  }
20
20
 
21
21
  describe("getVisibleProviderCatalog", () => {
22
- test("hides openai-compatible endpoints by default", () => {
22
+ test("shows openai-compatible endpoints unconditionally (GA'ed)", () => {
23
23
  setOverridesForTesting({});
24
24
 
25
25
  const visible = getVisibleProviderCatalog(makeConfig());
26
26
 
27
- expect(visible.find((p) => p.id === "openai-compatible")).toBeUndefined();
28
- });
29
-
30
- test("shows openai-compatible endpoints when its flag is enabled", () => {
31
- setOverridesForTesting({ "openai-compatible-endpoints": true });
32
-
33
- const visible = getVisibleProviderCatalog(makeConfig());
34
-
35
27
  expect(visible.find((p) => p.id === "openai-compatible")).toBeDefined();
36
28
  });
37
29