@cueloop/daemon 0.1.0-alpha.60 → 0.1.0-alpha.62

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cueloop/daemon",
3
- "version": "0.1.0-alpha.60",
3
+ "version": "0.1.0-alpha.62",
4
4
  "description": "The cueloop session daemon and its client: socket protocol, atomic store, resumable waits",
5
5
  "homepage": "https://github.com/mmurakaru/cueloop#readme",
6
6
  "bugs": {
@@ -33,7 +33,7 @@
33
33
  "access": "public"
34
34
  },
35
35
  "dependencies": {
36
- "@cueloop/schema": "0.1.0-alpha.60",
36
+ "@cueloop/schema": "0.1.0-alpha.62",
37
37
  "valibot": "^1.4.2"
38
38
  },
39
39
  "engines": {
@@ -0,0 +1,24 @@
1
+ import { describe, expect, test } from "bun:test";
2
+ import { daemonSpawnCommand } from "./client";
3
+
4
+ describe("daemonSpawnCommand", () => {
5
+ test("re-execs the binary as `daemon` when compiled (bun virtual-fs markers)", () => {
6
+ for (const moduleUrl of [
7
+ "file:///$bunfs/root/cueloop",
8
+ "file:///B:/~BUN/root/cueloop",
9
+ "file:///B:/%7EBUN/root/cueloop",
10
+ ]) {
11
+ expect(daemonSpawnCommand("/usr/local/bin/cueloop", moduleUrl)).toEqual([
12
+ "/usr/local/bin/cueloop",
13
+ "daemon",
14
+ "--autostart",
15
+ ]);
16
+ }
17
+ });
18
+
19
+ test("runs main.ts with bun from source", () => {
20
+ expect(
21
+ daemonSpawnCommand("/path/to/bun", "file:///repo/packages/daemon/src/client.ts"),
22
+ ).toEqual(["/path/to/bun", "run", "/repo/packages/daemon/src/main.ts"]);
23
+ });
24
+ });
package/src/client.ts CHANGED
@@ -277,10 +277,19 @@ export class DaemonClientError extends Error {
277
277
  }
278
278
  }
279
279
 
280
- function spawnDaemon(home: string): void {
281
- const entry = new URL("./main.ts", import.meta.url).pathname;
280
+ // A compiled binary re-execs `cueloop daemon --autostart` (idle-exits like main.ts,
281
+ // unlike the never-exiting foreground daemon); from source, bun runs main.ts.
282
+ export function daemonSpawnCommand(execPath: string, moduleUrl: string): string[] {
283
+ const compiled =
284
+ moduleUrl.includes("$bunfs") || moduleUrl.includes("~BUN") || moduleUrl.includes("%7EBUN");
285
+
286
+ return compiled
287
+ ? [execPath, "daemon", "--autostart"]
288
+ : [execPath, "run", new URL("./main.ts", moduleUrl).pathname];
289
+ }
282
290
 
283
- Bun.spawn([process.execPath, "run", entry], {
291
+ function spawnDaemon(home: string): void {
292
+ Bun.spawn(daemonSpawnCommand(process.execPath, import.meta.url), {
284
293
  env: { ...process.env, CUELOOP_HOME: home },
285
294
  stdio: ["ignore", "ignore", "ignore"],
286
295
  }).unref();