@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,355 +0,0 @@
1
- /**
2
- * Tests for plugin-contributed skills (PR 33).
3
- *
4
- * Covers:
5
- * - A plugin declaring `skills: [...]` has its entries registered after
6
- * bootstrap's `init()` succeeds.
7
- * - The registered skill is discoverable via `loadSkillCatalog` and
8
- * resolvable via `loadSkillBySelector` (the exact entry points the model's
9
- * `skill_load` / `skill_execute` flow use).
10
- * - Shutdown (runShutdownHooks) unregisters the plugin's skills so repeated
11
- * bootstraps don't leak catalog entries.
12
- * - Ref-counted register/unregister semantics match the tool registry's
13
- * per-skill-id semantics (PR 13 precedent).
14
- *
15
- * Strategy mirrors `plugin-bootstrap.test.ts`: stub the credential store so
16
- * bootstrap doesn't hit real backends, and `resetPluginRegistryForTests` /
17
- * `resetPluginSkillContributionsForTests` between cases for isolation.
18
- */
19
-
20
- import { rm } from "node:fs/promises";
21
- import { tmpdir } from "node:os";
22
- import { join } from "node:path";
23
- import { beforeEach, describe, expect, mock, test } from "bun:test";
24
-
25
- // Stub credential store before importing bootstrap so the module captures
26
- // the fake binding.
27
- const getSecureKeyAsyncMock = mock(
28
- async (_account: string): Promise<string | undefined> => undefined,
29
- );
30
- mock.module("../security/secure-keys.js", () => ({
31
- getSecureKeyAsync: getSecureKeyAsyncMock,
32
- }));
33
-
34
- import { loadSkillBySelector, loadSkillCatalog } from "../config/skills.js";
35
- import { bootstrapPlugins } from "../daemon/external-plugins-bootstrap.js";
36
- import { runShutdownHooks } from "../daemon/shutdown-registry.js";
37
- import {
38
- getPluginContributedSkillDefinition,
39
- getPluginContributedSkillSummaries,
40
- getPluginSkillRefCount,
41
- registerPluginSkills,
42
- resetPluginSkillContributionsForTests,
43
- unregisterPluginSkills,
44
- } from "../plugins/plugin-skill-contributions.js";
45
- import {
46
- registerPlugin,
47
- resetPluginRegistryForTests,
48
- } from "../plugins/registry.js";
49
- import {
50
- type Plugin,
51
- PluginExecutionError,
52
- type PluginSkillRegistration,
53
- } from "../plugins/types.js";
54
-
55
- // Per-process temp tree so bootstrap's plugin-storage directory creation
56
- // doesn't touch the developer's real ~/.vellum.
57
- const TEST_WORKSPACE_DIR = join(
58
- tmpdir(),
59
- `vellum-plugin-skill-test-${process.pid}`,
60
- );
61
- process.env.VELLUM_WORKSPACE_DIR = TEST_WORKSPACE_DIR;
62
-
63
- /** Build a plugin that contributes one or more skills. */
64
- function buildSkillPlugin(
65
- name: string,
66
- skills: PluginSkillRegistration[],
67
- extras: Partial<Omit<Plugin, "manifest" | "skills">> = {},
68
- ): Plugin {
69
- return {
70
- manifest: {
71
- name,
72
- version: "0.0.1",
73
- },
74
- skills,
75
- ...extras,
76
- };
77
- }
78
-
79
- describe("plugin skill contributions", () => {
80
- beforeEach(async () => {
81
- resetPluginRegistryForTests();
82
- resetPluginSkillContributionsForTests();
83
- getSecureKeyAsyncMock.mockReset();
84
- getSecureKeyAsyncMock.mockImplementation(async () => undefined);
85
- await rm(TEST_WORKSPACE_DIR, { recursive: true, force: true });
86
- });
87
-
88
- test("plugin skills are registered after bootstrap and exposed by the catalog", async () => {
89
- const skill: PluginSkillRegistration = {
90
- id: "plugin-demo-skill",
91
- name: "plugin-demo",
92
- displayName: "Plugin Demo",
93
- description: "A skill contributed by a plugin",
94
- body: "# Plugin Demo\n\nThis is the plugin-provided body.",
95
- activationHints: ["demo", "plugin"],
96
- };
97
-
98
- registerPlugin(buildSkillPlugin("demo-plugin", [skill]));
99
- await bootstrapPlugins();
100
-
101
- // Ref count bumped to exactly 1 so we can tell register and unregister
102
- // are balanced downstream.
103
- expect(getPluginSkillRefCount("demo-plugin")).toBe(1);
104
-
105
- // In-memory registry query surfaces the summary form.
106
- const summaries = getPluginContributedSkillSummaries();
107
- const registered = summaries.find((s) => s.id === "plugin-demo-skill");
108
- expect(registered).toBeDefined();
109
- expect(registered?.source).toBe("plugin");
110
- expect(registered?.name).toBe("plugin-demo");
111
- expect(registered?.displayName).toBe("Plugin Demo");
112
- expect(registered?.activationHints).toEqual(["demo", "plugin"]);
113
- // Summary must not carry the body — bodies are definition-only.
114
- expect((registered as unknown as { body?: unknown }).body).toBeUndefined();
115
-
116
- // The full definition is retrievable by id.
117
- const def = getPluginContributedSkillDefinition("plugin-demo-skill");
118
- expect(def).toBeDefined();
119
- expect(def?.body).toContain("This is the plugin-provided body");
120
- });
121
-
122
- test("catalog and loadSkillBySelector discover plugin-contributed skills (skill_load pathway)", async () => {
123
- const skill: PluginSkillRegistration = {
124
- id: "catalog-visible-skill",
125
- name: "catalog-visible",
126
- description: "A plugin skill expected to surface in loadSkillCatalog",
127
- body: "# Catalog-Visible Skill\n\nBody content for skill_load.",
128
- };
129
-
130
- registerPlugin(buildSkillPlugin("catalog-plugin", [skill]));
131
- await bootstrapPlugins();
132
-
133
- // loadSkillCatalog is the exact entry point `skill_load` consults via
134
- // `loadSkillBySelector` -> `resolveSkillSelector`.
135
- const catalog = loadSkillCatalog();
136
- const found = catalog.find((s) => s.id === "catalog-visible-skill");
137
- expect(found).toBeDefined();
138
- expect(found?.source).toBe("plugin");
139
- expect(found?.description).toBe(skill.description);
140
-
141
- // loadSkillBySelector is what SkillLoadTool.execute calls — it must
142
- // return a fully-populated SkillDefinition, including the body.
143
- const lookup = loadSkillBySelector("catalog-visible-skill");
144
- expect(lookup.error).toBeUndefined();
145
- expect(lookup.skill).toBeDefined();
146
- expect(lookup.skill?.id).toBe("catalog-visible-skill");
147
- expect(lookup.skill?.body).toContain("Body content for skill_load");
148
-
149
- // And name-based resolution (what users type when the model picks a
150
- // skill by name) works the same way.
151
- const byName = loadSkillBySelector("catalog-visible");
152
- expect(byName.skill?.id).toBe("catalog-visible-skill");
153
- });
154
-
155
- test("shutdown unregisters plugin skills so the catalog no longer lists them", async () => {
156
- const skill: PluginSkillRegistration = {
157
- id: "ephemeral-skill",
158
- name: "ephemeral",
159
- description: "Disappears after shutdown",
160
- body: "Only visible while the plugin is alive.",
161
- };
162
-
163
- registerPlugin(buildSkillPlugin("ephemeral-plugin", [skill]));
164
- await bootstrapPlugins();
165
-
166
- // Sanity: present before shutdown.
167
- expect(loadSkillCatalog().some((s) => s.id === "ephemeral-skill")).toBe(
168
- true,
169
- );
170
- expect(getPluginSkillRefCount("ephemeral-plugin")).toBe(1);
171
-
172
- await runShutdownHooks("test-shutdown");
173
-
174
- // After shutdown, the plugin's skill is gone from both the in-memory
175
- // registry and any catalog view that consults it.
176
- expect(getPluginSkillRefCount("ephemeral-plugin")).toBe(0);
177
- expect(
178
- getPluginContributedSkillDefinition("ephemeral-skill"),
179
- ).toBeUndefined();
180
-
181
- const catalogAfter = loadSkillCatalog();
182
- expect(catalogAfter.some((s) => s.id === "ephemeral-skill")).toBe(false);
183
-
184
- // And the selector lookup the model would use fails closed.
185
- const lookup = loadSkillBySelector("ephemeral-skill");
186
- expect(lookup.skill).toBeUndefined();
187
- });
188
-
189
- test("bootstrap is a no-op for plugins without a skills list", async () => {
190
- // A plugin with no `skills` field must not bump ref counts or
191
- // populate the catalog at all.
192
- registerPlugin({
193
- manifest: {
194
- name: "no-skills-plugin",
195
- version: "0.0.1",
196
- },
197
- });
198
-
199
- await bootstrapPlugins();
200
-
201
- expect(getPluginSkillRefCount("no-skills-plugin")).toBe(0);
202
- expect(getPluginContributedSkillSummaries()).toEqual([]);
203
- });
204
-
205
- test("duplicate skill id across plugins fails bootstrap with the plugin named", async () => {
206
- const shared: PluginSkillRegistration = {
207
- id: "contested-id",
208
- name: "contested",
209
- description: "First",
210
- body: "from first plugin",
211
- };
212
- const duplicate: PluginSkillRegistration = {
213
- id: "contested-id",
214
- name: "contested",
215
- description: "Second",
216
- body: "from second plugin",
217
- };
218
-
219
- registerPlugin(buildSkillPlugin("first-plugin", [shared]));
220
- registerPlugin(buildSkillPlugin("second-plugin", [duplicate]));
221
-
222
- let caught: unknown;
223
- try {
224
- await bootstrapPlugins();
225
- } catch (err) {
226
- caught = err;
227
- }
228
- expect(caught).toBeInstanceOf(PluginExecutionError);
229
- // The error must identify which plugin tripped the collision so
230
- // operators can deploy a fix.
231
- const msg = (caught as PluginExecutionError).message;
232
- expect(msg).toContain("second-plugin");
233
- expect(msg).toContain("contested-id");
234
- });
235
-
236
- test("intra-batch duplicate skill id in one plugin is rejected at registration", () => {
237
- // Directly exercise the registry (no bootstrap) — a single plugin
238
- // declaring the same id twice is a configuration bug and must fail
239
- // loudly rather than silently overwrite.
240
- expect(() =>
241
- registerPluginSkills("dup-plugin", [
242
- {
243
- id: "dup-id",
244
- name: "one",
245
- description: "first",
246
- body: "A",
247
- },
248
- {
249
- id: "dup-id",
250
- name: "two",
251
- description: "second",
252
- body: "B",
253
- },
254
- ]),
255
- ).toThrow(PluginExecutionError);
256
- expect(() =>
257
- registerPluginSkills("dup-plugin", [
258
- { id: "x", name: "one", description: "a", body: "A" },
259
- { id: "x", name: "two", description: "b", body: "B" },
260
- ]),
261
- ).toThrow(/declared skill "x" more than once/);
262
- });
263
-
264
- test("ref-counted unregister: second unregister call after repeated registers drops skills", () => {
265
- const registrations: PluginSkillRegistration[] = [
266
- {
267
- id: "refcount-skill",
268
- name: "refcount",
269
- description: "Ref-count demo",
270
- body: "stays until the counter hits zero",
271
- },
272
- ];
273
-
274
- registerPluginSkills("refcount-plugin", registrations);
275
- // Second call is the "same plugin registered again" pattern (hot
276
- // reload). It must bump the counter without re-inserting.
277
- registerPluginSkills("refcount-plugin", registrations);
278
- expect(getPluginSkillRefCount("refcount-plugin")).toBe(2);
279
- expect(getPluginContributedSkillDefinition("refcount-skill")).toBeDefined();
280
-
281
- // One unregister decrements only — skill must still be registered.
282
- unregisterPluginSkills("refcount-plugin");
283
- expect(getPluginSkillRefCount("refcount-plugin")).toBe(1);
284
- expect(getPluginContributedSkillDefinition("refcount-skill")).toBeDefined();
285
-
286
- // Second unregister drops the entry for real.
287
- unregisterPluginSkills("refcount-plugin");
288
- expect(getPluginSkillRefCount("refcount-plugin")).toBe(0);
289
- expect(
290
- getPluginContributedSkillDefinition("refcount-skill"),
291
- ).toBeUndefined();
292
-
293
- // Third unregister (over-decrement) is a no-op, not a throw — mirrors
294
- // the tool-registry behavior so shutdown races don't crash the
295
- // daemon.
296
- expect(() => unregisterPluginSkills("refcount-plugin")).not.toThrow();
297
- });
298
-
299
- test("managed (filesystem) skill with the same id overrides a plugin-contributed skill", async () => {
300
- // Plugin skills sit below managed/workspace in the catalog precedence
301
- // chain so a user can shadow a plugin-provided skill by dropping a
302
- // SKILL.md with the same id under ~/.vellum/workspace/skills. The test
303
- // harness configures VELLUM_WORKSPACE_DIR via the bun test preload, so
304
- // we can synthesize a filesystem skill for the same id and assert it
305
- // wins.
306
- const { mkdirSync, writeFileSync, rmSync, existsSync } =
307
- await import("node:fs");
308
-
309
- const workspaceDir = process.env.VELLUM_WORKSPACE_DIR;
310
- // Skip the filesystem override check when the harness did not provide a
311
- // workspace dir — the other tests in this file still cover catalog
312
- // visibility, which is the core of PR 33.
313
- if (!workspaceDir) {
314
- return;
315
- }
316
-
317
- const skillsDir = join(workspaceDir, "skills", "shared-id");
318
- mkdirSync(skillsDir, { recursive: true });
319
- writeFileSync(
320
- join(skillsDir, "SKILL.md"),
321
- [
322
- "---",
323
- 'name: "filesystem-version"',
324
- 'description: "User-authored override"',
325
- "---",
326
- "",
327
- "# Filesystem Override",
328
- ].join("\n"),
329
- );
330
-
331
- const pluginSkill: PluginSkillRegistration = {
332
- id: "shared-id",
333
- name: "plugin-version",
334
- description: "Plugin-provided skill that should be shadowed",
335
- body: "plugin body",
336
- };
337
- registerPlugin(buildSkillPlugin("shadow-plugin", [pluginSkill]));
338
-
339
- try {
340
- await bootstrapPlugins();
341
-
342
- const catalog = loadSkillCatalog();
343
- const entry = catalog.find((s) => s.id === "shared-id");
344
- // The filesystem SKILL.md wins — source flips to "managed" and the
345
- // plugin's metadata is not what we see.
346
- expect(entry).toBeDefined();
347
- expect(entry?.source).toBe("managed");
348
- expect(entry?.name).toBe("filesystem-version");
349
- } finally {
350
- if (existsSync(skillsDir)) {
351
- rmSync(skillsDir, { recursive: true, force: true });
352
- }
353
- }
354
- });
355
- });
@@ -1,10 +0,0 @@
1
- // Browser interaction types.
2
- // CDP request/response messaging was removed — Playwright's connectOverCDP is broken
3
- // under Bun's runtime. Browser is now launched directly via Playwright.
4
-
5
- // --- Domain-level union aliases (consumed by the barrel file) ---
6
- // These must exist (even as `never`) so the barrel union compiles.
7
-
8
- export type _BrowserClientMessages = never;
9
-
10
- export type _BrowserServerMessages = never;
@@ -1,187 +0,0 @@
1
- /**
2
- * Verifies that `emitNotificationSignal` invokes the home-feed side
3
- * effect after dispatching, and that the side effect's background-only
4
- * filter correctly suppresses interactive signals.
5
- *
6
- * The side effect itself is unit-tested in `home-feed-side-effect.test.ts`;
7
- * this test exercises the wire-up boundary in `emit-signal.ts` by mocking
8
- * at the `appendFeedItem` / `getConversation` boundary so the real
9
- * background-filter logic runs end-to-end.
10
- */
11
- import { beforeEach, describe, expect, mock, test } from "bun:test";
12
-
13
- import type { FeedItem } from "../../home/feed-types.js";
14
- import type {
15
- NotificationDecision,
16
- NotificationDeliveryResult,
17
- } from "../types.js";
18
-
19
- // ── Module mocks ───────────────────────────────────────────────────────
20
- //
21
- // `mock.module` is hoisted, so these intercepts apply before the module
22
- // under test resolves its imports. Closures over module-scoped state
23
- // let each test reset and inspect captured calls afterwards.
24
-
25
- const appendCalls: FeedItem[] = [];
26
- let conversationRow: { conversationType: string } | null = null;
27
-
28
- mock.module("../../home/feed-writer.js", () => ({
29
- appendFeedItem: async (item: FeedItem) => {
30
- appendCalls.push(item);
31
- },
32
- }));
33
-
34
- // home-feed-side-effect.ts only consumes `getConversation`.
35
- mock.module("../../memory/conversation-crud.js", () => ({
36
- getConversation: () => conversationRow,
37
- reserveMessage: mock(async () => ({ id: "msg-reserve" })),
38
- }));
39
-
40
- // Stub the broadcaster so emit-signal's `getBroadcaster()` does not need
41
- // to build real adapters or pull in `conversation-pairing.ts` transitively
42
- // (which would force us to mirror the full `conversation-crud.js` surface).
43
- class StubBroadcaster {
44
- setOnConversationCreated() {}
45
- async broadcastDecision() {
46
- return [];
47
- }
48
- }
49
- mock.module("../broadcaster.js", () => ({
50
- NotificationBroadcaster: StubBroadcaster,
51
- }));
52
-
53
- mock.module("../adapters/macos.js", () => ({
54
- VellumAdapter: class {},
55
- isGuardianSensitiveEvent: () => false,
56
- }));
57
- mock.module("../adapters/slack.js", () => ({
58
- SlackAdapter: class {},
59
- }));
60
- mock.module("../adapters/telegram.js", () => ({
61
- TelegramAdapter: class {},
62
- }));
63
-
64
- // Stub out the persistence + channel resolution layers so emitNotificationSignal
65
- // can run end-to-end without touching the DB / contacts store / LLM.
66
-
67
- mock.module("../events-store.js", () => ({
68
- createEvent: (params: { id: string }) => ({
69
- id: params.id,
70
- sourceEventName: "schedule.notify",
71
- sourceChannel: "scheduler",
72
- sourceContextId: "conv-source-1",
73
- attentionHintsJson: "{}",
74
- payloadJson: "{}",
75
- dedupeKey: null,
76
- createdAt: 0,
77
- updatedAt: 0,
78
- }),
79
- updateEventDedupeKey: () => {},
80
- }));
81
-
82
- mock.module("../decisions-store.js", () => ({
83
- updateDecision: () => {},
84
- }));
85
-
86
- mock.module("../../contacts/contact-store.js", () => ({
87
- findGuardianForChannel: () => null,
88
- listGuardianChannels: () => [],
89
- }));
90
-
91
- const stubDecision: NotificationDecision = {
92
- shouldNotify: true,
93
- selectedChannels: ["vellum"],
94
- reasoningSummary: "test",
95
- renderedCopy: {
96
- vellum: { title: "Background job done", body: "Summary of what happened." },
97
- },
98
- dedupeKey: "dk-1",
99
- confidence: 1,
100
- fallbackUsed: false,
101
- };
102
-
103
- mock.module("../decision-engine.js", () => ({
104
- evaluateSignal: async () => stubDecision,
105
- // Pass the decision through unchanged — emit-signal calls this after
106
- // evaluateSignal and only re-persists when the reference changes.
107
- enforceRoutingIntent: (decision: NotificationDecision) => decision,
108
- }));
109
-
110
- mock.module("../deterministic-checks.js", () => ({
111
- runDeterministicChecks: async () => ({ passed: true }),
112
- }));
113
-
114
- const stubDeliveryResults: NotificationDeliveryResult[] = [
115
- {
116
- channel: "vellum",
117
- destination: "vellum-client",
118
- status: "sent",
119
- conversationId: "conv-vellum-1",
120
- },
121
- ];
122
-
123
- mock.module("../runtime-dispatch.js", () => ({
124
- dispatchDecision: async () => ({
125
- dispatched: true,
126
- reason: "Dispatched to 1/1 channels",
127
- deliveryResults: stubDeliveryResults,
128
- }),
129
- }));
130
-
131
- const { emitNotificationSignal } = await import("../emit-signal.js");
132
-
133
- // ── Tests ──────────────────────────────────────────────────────────────
134
-
135
- beforeEach(() => {
136
- appendCalls.length = 0;
137
- conversationRow = null;
138
- });
139
-
140
- describe("emitNotificationSignal home-feed wire-up", () => {
141
- test("background-conversation signal triggers appendFeedItem", async () => {
142
- conversationRow = { conversationType: "background" };
143
-
144
- const result = await emitNotificationSignal({
145
- sourceEventName: "schedule.notify",
146
- sourceChannel: "scheduler",
147
- sourceContextId: "conv-source-1",
148
- contextPayload: { title: "Background job done" },
149
- attentionHints: {
150
- requiresAction: false,
151
- urgency: "medium",
152
- isAsyncBackground: false,
153
- visibleInSourceNow: false,
154
- },
155
- });
156
-
157
- expect(result.dispatched).toBe(true);
158
- expect(appendCalls).toHaveLength(1);
159
- const appended = appendCalls[0]!;
160
- expect(appended.id).toBe(`notif:${result.signalId}`);
161
- expect(appended.title).toBe("Background job done");
162
- expect(appended.summary).toBe("Summary of what happened.");
163
- // The feed item's conversationId points to the source conversation
164
- // that emitted the signal, not the conversation the notification
165
- // pipeline spawned to handle it.
166
- expect(appended.conversationId).toBe("conv-source-1");
167
- });
168
-
169
- test("interactive standard conversation does NOT trigger appendFeedItem", async () => {
170
- conversationRow = { conversationType: "standard" };
171
-
172
- const result = await emitNotificationSignal({
173
- sourceEventName: "schedule.notify",
174
- sourceChannel: "scheduler",
175
- sourceContextId: "conv-source-1",
176
- attentionHints: {
177
- requiresAction: false,
178
- urgency: "medium",
179
- isAsyncBackground: false,
180
- visibleInSourceNow: true,
181
- },
182
- });
183
-
184
- expect(result.dispatched).toBe(true);
185
- expect(appendCalls).toHaveLength(0);
186
- });
187
- });