diff --git a/.changeset/daemon-optional-arg.md b/.changeset/daemon-optional-arg.md new file mode 100644 index 0000000..94149e5 --- /dev/null +++ b/.changeset/daemon-optional-arg.md @@ -0,0 +1,5 @@ +--- +"coordinate": patch +--- + +Fix the compiled daemon failing to start with `expected string at $[0], got null`. The library hands an absent optional positional over as null, and the native binary's type claim rejects it before the string cast; the daemon handler now normalizes the slot before indexing. diff --git a/src/main.ts b/src/main.ts index 61bd215..498076e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1117,7 +1117,11 @@ function buildCommands(): Record { cmds["daemon"] = command("runs the claim loop on this machine", { args: [{ name: "action", description: "restart: hand off to the current binary", optional: true }], handler: (o: unknown, a: unknown[]) => { - return cmdDaemon(a as string[]); + // An optional arg absent from the argv arrives as null on the native + // path (the type claim rejects it before the string cast would), so + // normalize here before the rest[] index. + const rest = a.map((x) => (typeof x === "string" ? x : "")); + return cmdDaemon(rest); }, }) as unknown as CommandDef;