@vellumai/assistant 0.10.7-dev.202607101459.27388eb → 0.10.7-dev.202607101646.b683a65

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.
@@ -127,12 +127,11 @@ on the incoming tool.
127
127
  ## Lifecycle position
128
128
 
129
129
  ```
130
+ loadUserPlugins() # populates the plugin mtime-cache (no registry writes)
130
131
  initializeTools() # core tools register
131
132
  → loadWorkspaceTools() # initial workspace tool reconcile
133
+ → loadPluginTools() # registry pulls the active user-plugin tool set
132
134
  → MCP tool registration
133
- → loadUserPlugins() # populates the plugin mtime-cache (no registry writes)
134
- → loadPluginTools() # registry pulls the active user-plugin tool set
135
- → bootstrapPlugins()
136
135
 
137
136
  # on every conversation turn (createResolveToolsCallback):
138
137
  resolveTools(history)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vellumai/assistant",
3
- "version": "0.10.7-dev.202607101459.27388eb",
3
+ "version": "0.10.7-dev.202607101646.b683a65",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -206,8 +206,6 @@ mock.module("../util/platform.js", () => {
206
206
  getProfilerRootDir: stub,
207
207
  getProfilerRunsDir: stub,
208
208
  getProfilerRunDir: stub,
209
- getSkillRuntimePath: stub,
210
- getBundledBunPath: () => undefined,
211
209
  ensureDataDir: () => {},
212
210
  };
213
211
  });
@@ -97,8 +97,6 @@ mock.module("../util/platform.js", () => ({
97
97
  getProfilerRunsDir: () => workspacePath("data", "profiler", "runs"),
98
98
  getProfilerRunDir: (runId: string) =>
99
99
  workspacePath("data", "profiler", "runs", runId),
100
- getSkillRuntimePath: () => undefined,
101
- getBundledBunPath: () => undefined,
102
100
  }));
103
101
 
104
102
  const {
@@ -73,7 +73,6 @@ import {
73
73
  unregisterSkillRoute,
74
74
  } from "../runtime/skill-route-registry.js";
75
75
  import {
76
- loadPluginTools,
77
76
  registerPluginTools,
78
77
  unregisterPluginTools,
79
78
  } from "../tools/registry.js";
@@ -153,12 +152,6 @@ function ensurePluginStorageDir(pluginName: string): string {
153
152
  export async function initializePlugins(): Promise<void> {
154
153
  registerDefaultPlugins();
155
154
  await loadUserPlugins();
156
- // Pull the user-plugin tool set the cache scan above discovered into the
157
- // tool registry. Kept in the same slot registration used to occupy (after
158
- // the user-plugin scan, before the default plugins' `init()` registers
159
- // their Plugin-object tools) so name-conflict precedence is unchanged.
160
- // `loadPluginTools` never rejects — a failed pull logs and boots degraded.
161
- await loadPluginTools();
162
155
  try {
163
156
  await bootstrapPlugins();
164
157
  } catch (err) {
@@ -85,8 +85,6 @@ mock.module("../../util/platform.js", () => ({
85
85
  getProfilerRunsDir: () => join(workspaceDir ?? fallbackDir, "profiler/runs"),
86
86
  getProfilerRunDir: (runId: string) =>
87
87
  join(workspaceDir ?? fallbackDir, "profiler/runs", runId),
88
- getSkillRuntimePath: () => join(workspaceDir ?? fallbackDir, "skill-runtime"),
89
- getBundledBunPath: () => undefined,
90
88
  ensureDataDir: () => {},
91
89
  }));
92
90
 
@@ -58,6 +58,7 @@ import {
58
58
  import { CONTACTS_INFO_IPC_METHODS } from "./routes/contacts-info-ipc-routes.js";
59
59
  import { CONTACTS_MIRROR_IPC_METHODS } from "./routes/contacts-mirror-ipc-routes.js";
60
60
  import { type DbProxyParams, handleDbProxy } from "./routes/db-proxy.js";
61
+ import { GUARDIAN_LABEL_IPC_METHODS } from "./routes/guardian-label-ipc-routes.js";
61
62
  import { INVITE_IPC_METHODS } from "./routes/invite-ipc-routes.js";
62
63
  import { routeDefinitionsToIpcMethods } from "./routes/route-adapter.js";
63
64
  import { ensureSocketPathFree } from "./socket-cleanup.js";
@@ -202,30 +203,17 @@ export class AssistantIpcServer {
202
203
  handleDbProxy(params as unknown as DbProxyParams),
203
204
  );
204
205
 
205
- // IPC-only invite methods (see ipc/routes/invite-ipc-routes.ts). The
206
- // gateway calls these back over IPC to mirror redeemed-invite contact
207
- // info locally. No HTTP surface; never in ROUTES.
208
- for (const [operationId, handler] of Object.entries(INVITE_IPC_METHODS)) {
209
- this.methods.set(operationId, handler);
210
- }
211
-
212
- // IPC-only contact INFO-READ methods (see ipc/routes/contacts-info-ipc-routes.ts).
213
- // The gateway calls these to read assistant-owned info fields + channel
214
- // identity, replacing raw db_proxy SELECTs. No HTTP surface; never in ROUTES.
215
- for (const [operationId, handler] of Object.entries(
206
+ // IPC-only gateway-facing method maps (see each map's route file in
207
+ // ipc/routes/ for its contract). No HTTP surface; never in ROUTES.
208
+ for (const methodMap of [
209
+ INVITE_IPC_METHODS,
216
210
  CONTACTS_INFO_IPC_METHODS,
217
- )) {
218
- this.methods.set(operationId, handler);
219
- }
220
-
221
- // IPC-only contact identity-mirror methods (see
222
- // ipc/routes/contacts-mirror-ipc-routes.ts). The gateway calls these back
223
- // over IPC to mirror single-row contact/channel identity locally after a
224
- // gateway-owned ACL write. No HTTP surface; never in ROUTES.
225
- for (const [operationId, handler] of Object.entries(
226
211
  CONTACTS_MIRROR_IPC_METHODS,
227
- )) {
228
- this.methods.set(operationId, handler);
212
+ GUARDIAN_LABEL_IPC_METHODS,
213
+ ]) {
214
+ for (const [operationId, handler] of Object.entries(methodMap)) {
215
+ this.methods.set(operationId, handler);
216
+ }
229
217
  }
230
218
 
231
219
  this.methods.set("$cancel", (params) => {
@@ -0,0 +1,74 @@
1
+ /**
2
+ * The gateway-facing guardian-label method is IPC-only: registered on the
3
+ * assistant IPC server by operationId and absent from the shared HTTP route
4
+ * set. The persona content is driven through a persona-resolver mock so the
5
+ * tests exercise the real `resolveGuardianName` priority chain without disk.
6
+ */
7
+
8
+ import { beforeEach, describe, expect, mock, test } from "bun:test";
9
+
10
+ // Mutable persona content — the value `resolveGuardianPersonaStrict()`
11
+ // returns (comment-stripped string, or null when no guardian / missing file).
12
+ let mockGuardianPersona: string | null = null;
13
+
14
+ // Snapshot-spread the real module so untouched exports (used elsewhere in the
15
+ // import chain) stay intact.
16
+ const actualPersonaResolver = await import(
17
+ "../../../prompts/persona-resolver.js"
18
+ );
19
+ mock.module("../../../prompts/persona-resolver.js", () => ({
20
+ ...actualPersonaResolver,
21
+ resolveGuardianPersonaStrict: () => mockGuardianPersona,
22
+ }));
23
+
24
+ const { GUARDIAN_LABEL_IPC_METHODS, handleResolveGuardianLabel } =
25
+ await import("../guardian-label-ipc-routes.js");
26
+ const { ROUTES: contactRoutes } = await import(
27
+ "../../../runtime/routes/contact-routes.js"
28
+ );
29
+
30
+ describe("resolve_guardian_label", () => {
31
+ beforeEach(() => {
32
+ mockGuardianPersona = null;
33
+ });
34
+
35
+ test("is reachable on the IPC surface by operationId", () => {
36
+ expect(typeof GUARDIAN_LABEL_IPC_METHODS.resolve_guardian_label).toBe(
37
+ "function",
38
+ );
39
+ });
40
+
41
+ test("is NOT in the shared contact ROUTES array", () => {
42
+ const sharedIds = new Set(contactRoutes.map((r) => r.operationId));
43
+ expect(sharedIds.has("resolve_guardian_label")).toBe(false);
44
+ });
45
+
46
+ test("returns the persona preferred name when present", () => {
47
+ mockGuardianPersona = "- Preferred name/reference: John\n";
48
+ expect(
49
+ handleResolveGuardianLabel({ body: { storedDisplayName: "Stored" } }),
50
+ ).toEqual({ label: "John" });
51
+ });
52
+
53
+ test("falls back to the stored displayName when no preferred name is set", () => {
54
+ mockGuardianPersona = "- Preferred name/reference:\n";
55
+ expect(
56
+ handleResolveGuardianLabel({ body: { storedDisplayName: "Stored" } }),
57
+ ).toEqual({ label: "Stored" });
58
+ });
59
+
60
+ test("falls back to the default reference when neither is set", () => {
61
+ expect(handleResolveGuardianLabel({ body: {} })).toEqual({
62
+ label: "my human",
63
+ });
64
+ expect(
65
+ handleResolveGuardianLabel({ body: { storedDisplayName: null } }),
66
+ ).toEqual({ label: "my human" });
67
+ });
68
+
69
+ test("rejects a non-string storedDisplayName", () => {
70
+ expect(() =>
71
+ handleResolveGuardianLabel({ body: { storedDisplayName: 42 } }),
72
+ ).toThrow();
73
+ });
74
+ });
@@ -0,0 +1,42 @@
1
+ /**
2
+ * IPC-only guardian display-label method called by the gateway over the
3
+ * assistant IPC socket (`ipcCallAssistant`).
4
+ *
5
+ * The gateway's native contact reads serve rows from the gateway DB, but the
6
+ * guardian's display label is derived from assistant-side state (the guardian
7
+ * persona file's preferred name). This method exposes that resolution so the
8
+ * gateway can present the same guardian label the daemon's read relay does.
9
+ *
10
+ * Like the other gateway-facing methods here, it has no HTTP surface: it is
11
+ * registered directly on the IPC server (see `assistant-server.ts`) and never
12
+ * enters the shared `ROUTES` array.
13
+ */
14
+
15
+ import { z } from "zod";
16
+
17
+ import { resolveGuardianName } from "../../prompts/user-reference.js";
18
+ import type { RouteHandlerArgs } from "../../runtime/routes/types.js";
19
+
20
+ const ResolveGuardianLabelParamsSchema = z.object({
21
+ storedDisplayName: z.string().nullable().optional(),
22
+ });
23
+
24
+ /**
25
+ * Resolve the guardian's display label: the persona-file preferred name when
26
+ * set, else the stored displayName, else the default user reference.
27
+ */
28
+ export function handleResolveGuardianLabel({ body = {} }: RouteHandlerArgs) {
29
+ const { storedDisplayName } = ResolveGuardianLabelParamsSchema.parse(body);
30
+ return { label: resolveGuardianName(storedDisplayName ?? null) };
31
+ }
32
+
33
+ /**
34
+ * IPC-only guardian-label methods, keyed by IPC operationId. Registered
35
+ * directly on the assistant IPC server (see `assistant-server.ts`).
36
+ */
37
+ export const GUARDIAN_LABEL_IPC_METHODS: Record<
38
+ string,
39
+ (args: RouteHandlerArgs) => unknown
40
+ > = {
41
+ resolve_guardian_label: handleResolveGuardianLabel,
42
+ };
@@ -179,8 +179,6 @@ mock.module("../../../../../util/platform.js", () => {
179
179
  getProfilerRootDir: stub,
180
180
  getProfilerRunsDir: stub,
181
181
  getProfilerRunDir: stub,
182
- getSkillRuntimePath: stub,
183
- getBundledBunPath: () => undefined,
184
182
  ensureDataDir: () => {},
185
183
  };
186
184
  });
@@ -242,8 +242,6 @@ mock.module("../../../util/platform.js", () => {
242
242
  getProfilerRootDir: stub,
243
243
  getProfilerRunsDir: stub,
244
244
  getProfilerRunDir: stub,
245
- getSkillRuntimePath: stub,
246
- getBundledBunPath: () => undefined,
247
245
  ensureDataDir: () => {},
248
246
  };
249
247
  });
@@ -37,61 +37,6 @@ const DEFAULT_TOOL_OWNER: OwnerInfo = Object.freeze({
37
37
  id: "default",
38
38
  });
39
39
 
40
- // ── External tool registry ───────────────────────────────────────────
41
- // Skills register their tools here at initialization time so the tool
42
- // manifest can include them without importing from `../skills/`.
43
- //
44
- // Each registration is stored as a provider closure. Closures are
45
- // resolved at `getExternalTools()` time (which `initializeTools()`
46
- // calls), not at registration time — this lets a skill defer its
47
- // feature-flag check until after the daemon has run
48
- // `mergeDefaultWorkspaceConfig()`, so skills see the merged config
49
- // instead of forcing an early `loadConfig()` against unmerged defaults.
50
- const externalToolProviders: Array<{
51
- owner: OwnerInfo;
52
- provider: () => Tool[];
53
- }> = [];
54
-
55
- /**
56
- * Register tools provided by an external skill. Called during skill
57
- * initialization (e.g. meet-join bootstrap).
58
- *
59
- * Accepts either a concrete `Tool[]` (resolved eagerly at the caller)
60
- * or a `() => Tool[]` closure (resolved lazily inside
61
- * `getExternalTools()`). Skills that perform feature-flag or config
62
- * reads to decide which tools to surface must pass a closure so the
63
- * read happens after daemon-startup config merging.
64
- *
65
- * Lives in registry.ts (not tool-manifest.ts) to avoid a circular
66
- * dependency: skills/load.ts → … → meet-join/register.ts → tool-manifest.ts
67
- * → skills/load.ts. Keeping it here lets external skill bootstraps import
68
- * from registry.ts, which is already a leaf in the dependency graph.
69
- *
70
- * `owner` records which extension produced these tools — typed
71
- * {@link OwnerInfo} so ownership flows through `ownersByName` at
72
- * `initializeTools()` time, the same way `register*` registers it for
73
- * IPC-loaded tools. Eager (boot-time) skill bootstraps go through this
74
- * path rather than `registerSkillTools`, so this is where their owner
75
- * lookup gets established.
76
- */
77
- export function registerExternalTools(
78
- owner: OwnerInfo,
79
- toolsOrProvider: Tool[] | (() => Tool[]),
80
- ): void {
81
- const provider =
82
- typeof toolsOrProvider === "function"
83
- ? toolsOrProvider
84
- : () => toolsOrProvider;
85
- externalToolProviders.push({ owner, provider });
86
- }
87
-
88
- /** Return all externally registered tools paired with their owners. */
89
- function getExternalTools(): Array<{ owner: OwnerInfo; tool: Tool }> {
90
- return externalToolProviders.flatMap(({ owner, provider }) =>
91
- provider().map((tool) => ({ owner, tool })),
92
- );
93
- }
94
-
95
40
  // Snapshot of core tools (with their owners) captured after initializeTools()
96
41
  // completes. Lets __resetRegistryForTesting() restore the core baseline — tools
97
42
  // and ownership together — synchronously, without re-running the async
@@ -226,9 +171,7 @@ export function registerTool(definition: ToolDefinition): void {
226
171
  }
227
172
  tools.set(name, tool);
228
173
  // A tool registered through this bare path has no explicit extension owner,
229
- // so it is a built-in: record the shared `default` owner by name. Callers
230
- // that own the tool (external skill bootstraps) overwrite this entry with
231
- // their own owner immediately after calling `registerTool`.
174
+ // so it is a built-in: record the shared `default` owner by name.
232
175
  ownersByName.set(name, DEFAULT_TOOL_OWNER);
233
176
  log.info({ name, category: tool.category }, "Tool registered");
234
177
  }
@@ -520,9 +463,10 @@ export function unregisterPluginTools(pluginName: string): void {
520
463
  *
521
464
  * Idempotent, cheap when nothing changed (one sentinel stat + fingerprint
522
465
  * compares), and concurrency-safe (concurrent callers coalesce onto one
523
- * in-flight reconcile). Called at boot after `loadUserPlugins()` populates
524
- * the cache, and fire-and-forget from the per-turn conversation tool
525
- * resolver — the same cadence `loadWorkspaceTools` runs on.
466
+ * in-flight reconcile). Runs as the final step of `initializeTools()` (at
467
+ * daemon boot the plugin cache is already populated by then), and
468
+ * fire-and-forget from the per-turn conversation tool resolver — the same
469
+ * cadence `loadWorkspaceTools` runs on.
526
470
  */
527
471
  export function loadPluginTools(): Promise<void> {
528
472
  if (pluginToolsReconcileInFlight) {
@@ -1147,18 +1091,6 @@ async function runToolInitialization(): Promise<void> {
1147
1091
  registerTool(tool);
1148
1092
  }
1149
1093
 
1150
- // External skill tools — registered by skill bootstrap modules via
1151
- // `registerExternalTools()`. Called at init time (not spread into
1152
- // `explicitTools`) so registrations that happen between module-load
1153
- // and `initializeTools()` are picked up. Each provider pairs its tools
1154
- // with an OwnerInfo so the registry can record ownership in
1155
- // {@link ownersByName} alongside the bare `registerTool()` install.
1156
- const extEntries = getExternalTools();
1157
- for (const { owner, tool } of extEntries) {
1158
- registerTool(tool);
1159
- ownersByName.set(tool.name, owner);
1160
- }
1161
-
1162
1094
  // Host tools are registered here so host access stays opt-in until this
1163
1095
  // point in startup.
1164
1096
  const hostTools = [
@@ -1181,16 +1113,14 @@ async function runToolInitialization(): Promise<void> {
1181
1113
  // arbitrary test tools that were registered before init.
1182
1114
  //
1183
1115
  // A pre-existing tool is included only if it is a known manifest tool
1184
- // (declared in explicitTools, hostTools, or any registered external
1185
- // skill tool) — e.g. a test registered a manifest tool directly before
1186
- // its first initializeTools() call.
1116
+ // (declared in explicitTools or hostTools) — e.g. a test registered a
1117
+ // manifest tool directly before its first initializeTools() call.
1187
1118
  if (!coreToolsSnapshot) {
1188
1119
  // Core tool literals always set `name` (verified by `registerTool` —
1189
1120
  // it throws on missing name). The `!` assertions reflect that
1190
1121
  // invariant at the iteration sites.
1191
1122
  const manifestToolNames = new Set<string>([
1192
1123
  ...explicitTools.map((t) => t.name!),
1193
- ...extEntries.map(({ tool }) => tool.name),
1194
1124
  ...hostTools.map((t) => t.name!),
1195
1125
  ...allUiSurfaceTools.map((t) => t.name!),
1196
1126
  ...coreAppProxyTools.map((t) => t.name!),
@@ -1231,6 +1161,15 @@ async function runToolInitialization(): Promise<void> {
1231
1161
  // here would create a registry ↔ loader cycle.
1232
1162
  const { loadWorkspaceTools } = await import("./workspace-tools/loader.js");
1233
1163
  await loadWorkspaceTools();
1164
+
1165
+ // Pull the active user-plugin tool set last, so core and workspace
1166
+ // registrations already own their names when plugin conflicts resolve.
1167
+ // At daemon boot the plugin mtime-cache is populated before this runs
1168
+ // (`initializePlugins()` precedes `initializeTools()` in the lifecycle);
1169
+ // in worker/standalone processes the cache is empty and this is a no-op.
1170
+ // Runtime changes keep flowing through the same reconcile, re-fired by
1171
+ // the per-turn conversation tool resolver.
1172
+ await loadPluginTools();
1234
1173
  }
1235
1174
 
1236
1175
  /**
@@ -1279,14 +1218,3 @@ export function __clearRegistryForTesting(): void {
1279
1218
  coreToolOverrides.clear();
1280
1219
  toolsInitPromise = null;
1281
1220
  }
1282
-
1283
- /**
1284
- * Drop every registered external-tool provider. Exposed exclusively for
1285
- * tests that want to verify a single `registerExternalTools()` call in
1286
- * isolation — the provider array otherwise accumulates across cases
1287
- * because ESM import caching prevents re-running the tool-manifest
1288
- * bootstrap.
1289
- */
1290
- export function __clearExternalToolProvidersForTesting(): void {
1291
- externalToolProviders.length = 0;
1292
- }
@@ -50,10 +50,4 @@ export const explicitTools: ToolDefinition[] = [
50
50
  recallTool,
51
51
  notifyParentTool,
52
52
  askQuestionTool,
53
- // NOTE: external skill tools (registered via registerExternalTools in
54
- // registry.ts) are intentionally NOT included here. `explicitTools` is a
55
- // module-level const whose value is fixed at first evaluation, so
56
- // external tools registered after this file loads would be missed.
57
- // `initializeTools()` in `registry.ts` calls `getExternalTools()`
58
- // separately at runtime so late registrations are picked up.
59
53
  ];
@@ -427,66 +427,6 @@ export function getProfilerRunDir(runId: string): string {
427
427
  return join(getProfilerRunsDir(), runId);
428
428
  }
429
429
 
430
- /**
431
- * Resolve the shipped source directory for a first-party skill (e.g.
432
- * `meet-join`) whose runtime is launched outside the compiled daemon
433
- * binary — notably the meet-host child process spawned via
434
- * `bun run <skill>/register.ts`.
435
- *
436
- * Layers on top of `getRepoSkillsDir()` from `skills/catalog-install.ts`:
437
- * that helper locates the first-party skills root (validated by
438
- * `catalog.json`); this helper appends the skill id and validates the
439
- * per-skill entry point (`register.ts`). Returns `undefined` when the
440
- * root is unavailable (e.g. dev-mode build without `VELLUM_DEV=1`) or
441
- * the skill directory has no `register.ts`.
442
- *
443
- * Implemented here instead of `skills/catalog-install.ts` to avoid
444
- * pulling that module's platform-API dependencies (fetch, memory graph)
445
- * into callers that only need a path resolution. Takes the first-party
446
- * skills root as a dependency to keep this module free of a reverse
447
- * import.
448
- */
449
- export function getSkillRuntimePath(
450
- skillId: string,
451
- firstPartySkillsRoot: string | undefined,
452
- ): string | undefined {
453
- if (!firstPartySkillsRoot) return undefined;
454
- const candidate = join(firstPartySkillsRoot, skillId);
455
- if (existsSync(join(candidate, "register.ts"))) {
456
- return candidate;
457
- }
458
- return undefined;
459
- }
460
-
461
- /**
462
- * Resolve the on-disk path to a standalone `bun` binary that the meet-host
463
- * supervisor (PR 27) uses to spawn external skills. Prefers the
464
- * packaging-site-bundled copy before falling back to the shared
465
- * download/PATH resolver in `bun-runtime.ts`.
466
- *
467
- * Resolution order:
468
- *
469
- * 1. macOS `.app` bundle: `Contents/Resources/bun` — bundled at a version
470
- * that matches `.tool-versions`.
471
- * 2. Next-to-binary: `<execDir>/bun` for Docker/generic compiled layouts
472
- * that stage a bun binary alongside the daemon (PR 29 wires this up).
473
- *
474
- * Returns `undefined` when no bundled copy is present; callers should
475
- * fall back to `ensureBun()` from `./bun-runtime.ts`, which handles PATH
476
- * lookup and JIT download for bare-metal dev.
477
- */
478
- export function getBundledBunPath(): string | undefined {
479
- const importDir = import.meta.dir;
480
- if (!importDir.startsWith("/$bunfs/")) return undefined;
481
-
482
- const execDir = dirname(process.execPath);
483
- const resourcesPath = join(execDir, "..", "Resources", "bun");
484
- if (existsSync(resourcesPath)) return resourcesPath;
485
- const execDirPath = join(execDir, "bun");
486
- if (existsSync(execDirPath)) return execDirPath;
487
- return undefined;
488
- }
489
-
490
430
  export function ensureDataDir(): void {
491
431
  const root = vellumRoot();
492
432
  const workspace = getWorkspaceDir();
@@ -1,63 +0,0 @@
1
- /**
2
- * Tests for `getSkillRuntimePath()` and `getBundledBunPath()` in
3
- * `assistant/src/util/platform.ts`.
4
- *
5
- * `getSkillRuntimePath()` takes the first-party-skills root as an
6
- * argument so the caller can source it from whichever layer owns that
7
- * resolution (typically `getRepoSkillsDir()` from
8
- * `skills/catalog-install.ts`). `getBundledBunPath()`'s compiled-binary
9
- * branches (macOS `.app` Resources, next-to-binary) key off
10
- * `import.meta.dir.startsWith("/$bunfs/")`, so at test time only the
11
- * source-mode early-return is exercised here; the compiled branch is
12
- * covered structurally via the Electron signing + packaging step in
13
- * `clients/macos/scripts/pack.sh`.
14
- */
15
-
16
- import { mkdirSync, rmSync, writeFileSync } from "node:fs";
17
- import { tmpdir } from "node:os";
18
- import { join } from "node:path";
19
- import { afterEach, beforeEach, describe, expect, test } from "bun:test";
20
-
21
- import { getBundledBunPath, getSkillRuntimePath } from "../util/platform.js";
22
-
23
- let skillsRoot: string;
24
-
25
- beforeEach(() => {
26
- skillsRoot = join(tmpdir(), `skill-runtime-path-test-${crypto.randomUUID()}`);
27
- mkdirSync(join(skillsRoot, "example-skill"), { recursive: true });
28
- writeFileSync(
29
- join(skillsRoot, "example-skill", "register.ts"),
30
- "export {};\n",
31
- );
32
- // A directory without a register.ts, to exercise the validation miss.
33
- mkdirSync(join(skillsRoot, "empty-skill"), { recursive: true });
34
- });
35
-
36
- afterEach(() => {
37
- rmSync(skillsRoot, { recursive: true, force: true });
38
- });
39
-
40
- describe("getSkillRuntimePath", () => {
41
- test("returns <root>/<skillId> when the skill has a register.ts", () => {
42
- const resolved = getSkillRuntimePath("example-skill", skillsRoot);
43
- expect(resolved).toBe(join(skillsRoot, "example-skill"));
44
- });
45
-
46
- test("returns undefined when the skill directory lacks register.ts", () => {
47
- expect(getSkillRuntimePath("empty-skill", skillsRoot)).toBeUndefined();
48
- });
49
-
50
- test("returns undefined for a missing skill id", () => {
51
- expect(getSkillRuntimePath("does-not-exist", skillsRoot)).toBeUndefined();
52
- });
53
-
54
- test("returns undefined when the first-party skills root is undefined", () => {
55
- expect(getSkillRuntimePath("example-skill", undefined)).toBeUndefined();
56
- });
57
- });
58
-
59
- describe("getBundledBunPath", () => {
60
- test("returns undefined in source mode (bundled bun only ships in compiled binaries)", () => {
61
- expect(getBundledBunPath()).toBeUndefined();
62
- });
63
- });