@taco-ai/cli 0.2.4 → 0.2.6

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.
@@ -156,7 +156,13 @@ export function execFile(
156
156
  opts: { allowFailure?: boolean } = {},
157
157
  ): Promise<ExecResult> {
158
158
  return new Promise((resolve, reject) => {
159
- const child = spawn(program, args, { stdio: ["ignore", "pipe", "pipe"] });
159
+ const child = spawn(program, args, {
160
+ stdio: ["ignore", "pipe", "pipe"],
161
+ // Windows: schtasks.exe is a console binary. Hide its window so
162
+ // `taco install` / `taco uninstall` don't flash a cmd while
163
+ // registering the logon task. Ignored on POSIX.
164
+ windowsHide: true,
165
+ });
160
166
  const chunks: Buffer[] = [];
161
167
  const errChunks: Buffer[] = [];
162
168
  child.stdout.on("data", (c: Buffer) => chunks.push(c));
@@ -3,9 +3,18 @@
3
3
  * creating user at logon — ONLOGON without /RU — never elevated, so the
4
4
  * installer can terminate the process when upgrading over a live daemon.
5
5
  * The wrapper bakes in the per-user home and runtime paths because schtasks
6
- * cannot define environment variables. */
7
-
8
- import { writeFileSync } from "node:fs";
6
+ * cannot define environment variables.
7
+ *
8
+ * The scheduled-task action is `wscript.exe //nologo <wrapper.vbs>`, not a
9
+ * `.cmd`. A `.cmd` is launched through `cmd.exe` (console subsystem), which
10
+ * flashes a console at logon; `wscript.exe` is a GUI-subsystem host, and
11
+ * the VBS starts node with `Run(..., 0, True)` (SW_HIDE + wait) so neither
12
+ * wscript nor the console-subsystem node binary pops a window. Wait=True
13
+ * keeps the task "Running" for the daemon's lifetime so `schtasks /End`
14
+ * still tears the tree down. macOS launchd is a separate file and is not
15
+ * involved here. */
16
+
17
+ import { existsSync, unlinkSync, writeFileSync } from "node:fs";
9
18
  import { join } from "node:path";
10
19
  import type { InstallResult } from "./install.ts";
11
20
  import { execFile, type PlatformPkgPaths } from "./installHelpers.ts";
@@ -15,15 +24,22 @@ export const SCHTASKS_NAME = "TacoSidecar";
15
24
 
16
25
  /** Windows wrapper script name under $TACO_HOME\bin\. */
17
26
  export function windowsWrapperPath(tacoHome: string): string {
27
+ return join(tacoHome, "bin", "taco-sidecar-daemon.vbs");
28
+ }
29
+
30
+ /** Pre-vbs wrapper left behind by older installs. Inert once the task
31
+ * points at the .vbs; removed on re-install so operators don't keep two
32
+ * launchers around. */
33
+ export function legacyWindowsCmdPath(tacoHome: string): string {
18
34
  return join(tacoHome, "bin", "taco-sidecar-daemon.cmd");
19
35
  }
20
36
 
21
- /** Escape characters that cmd treats as syntax (`& | < > ^ " %`) when they
22
- * appear inside a `set VAR=value` line. Delimiters like `%` and `!` are
23
- * also escaped for safety (delayed expansion + for-variable substitution
24
- * can otherwise leak through to the sidecar). */
25
- export function escapeCmd(value: string): string {
26
- return value.replace(/[&|<>^"%!]/g, "^$&");
37
+ /** Escape a string for embedding inside a VBScript `"..."` literal.
38
+ * The only metacharacter VBS strings have is `"` itself (doubled). `&`
39
+ * is concatenation only outside quotes, so paths like `C:\R&D` pass
40
+ * through unchanged — unlike the old `.cmd` `set` lines. */
41
+ export function escapeVbs(value: string): string {
42
+ return value.replace(/"/g, '""');
27
43
  }
28
44
 
29
45
  export interface WindowsWrapperOptions {
@@ -35,41 +51,45 @@ export interface WindowsWrapperOptions {
35
51
  resourcesRoot: string;
36
52
  }
37
53
 
38
- /** Generate the Windows .cmd wrapper content. Every value is baked in so
39
- * schtasks can invoke the .cmd with no args — schtasks /TR passes the
40
- * script path verbatim. The wrapper resolves TACO_HOME at runtime (with
41
- * the install-time value as fallback) so re-running `taco install` from
42
- * a different user still lands the daemon under the right home. */
54
+ /** Generate the Windows .vbs wrapper content. Every value is baked in so
55
+ * schtasks can invoke wscript with no extra args. The wrapper sets
56
+ * process-level env (inherited by node) because Task Scheduler has no
57
+ * env-var field, then `Run`s the bundled node hidden and waits. */
43
58
  export function renderWindowsWrapper(opts: WindowsWrapperOptions): string {
44
- const tacoHome = escapeCmd(opts.tacoHome);
45
- const socket = escapeCmd(opts.socketPath);
46
- const control = escapeCmd(opts.controlSocketPath);
47
- const nodeBin = escapeCmd(opts.nodeBin);
48
- const bundle = escapeCmd(opts.bundle);
49
- const resourcesRoot = escapeCmd(opts.resourcesRoot);
50
- return `@echo off
51
- rem Generated by 'taco install' — do not edit.
52
- rem Invokes the bundled sidecar in daemon mode under schtasks.
53
- setlocal EnableExtensions EnableDelayedExpansion
54
-
55
- rem Scheduled tasks do not inherit the installer's environment, so bake the
56
- rem per-user TACO_HOME into the wrapper.
57
- set "TACO_HOME=${tacoHome}"
58
-
59
- rem Socket paths (must match packages/cli/lib/paths.ts on Windows).
60
- set "TACO_SOCKET=${socket}"
61
- set "TACO_CONTROL_SOCKET=${control}"
62
-
63
- rem Daemon-mode env the sidecar bundle reads on startup.
64
- set "TACO_DAEMON_MODE=1"
65
- set "TACO_SIDECAR_RESOURCES=${resourcesRoot}"
66
-
67
- rem Bundled node + sidecar entry (resolved at install time).
68
- set "NODE_BIN=${nodeBin}"
69
- set "BUNDLE=${bundle}"
70
-
71
- "!NODE_BIN!" "!BUNDLE!"
72
- endlocal
59
+ const tacoHome = escapeVbs(opts.tacoHome);
60
+ const socket = escapeVbs(opts.socketPath);
61
+ const control = escapeVbs(opts.controlSocketPath);
62
+ const nodeBin = escapeVbs(opts.nodeBin);
63
+ const bundle = escapeVbs(opts.bundle);
64
+ const resourcesRoot = escapeVbs(opts.resourcesRoot);
65
+ // Backslash join, not `path.join`: this renderer is unit-tested on
66
+ // POSIX CI too, and `path.join` would emit `/logs/` there.
67
+ const stderrLog = escapeVbs(`${opts.tacoHome}\\logs\\daemon.err.log`);
68
+ return `' Generated by 'taco install' — do not edit.
69
+ ' Invokes the bundled sidecar in daemon mode under schtasks.
70
+ ' Window style 0 (SW_HIDE) + wait so logon does not flash a console.
71
+ Option Explicit
72
+ Dim sh, env
73
+ Set sh = CreateObject("WScript.Shell")
74
+ Set env = sh.Environment("Process")
75
+
76
+ ' Scheduled tasks do not inherit the installer's environment, so bake the
77
+ ' per-user TACO_HOME into the wrapper.
78
+ env("TACO_HOME") = "${tacoHome}"
79
+
80
+ ' Socket paths (must match packages/cli/lib/paths.ts on Windows).
81
+ env("TACO_SOCKET") = "${socket}"
82
+ env("TACO_CONTROL_SOCKET") = "${control}"
83
+
84
+ ' Daemon-mode env the sidecar bundle reads on startup.
85
+ env("TACO_DAEMON_MODE") = "1"
86
+ env("TACO_SIDECAR_RESOURCES") = "${resourcesRoot}"
87
+
88
+ ' No console to inherit, so tee sidecar stderr to the same file launchd
89
+ ' gets via StandardErrorPath.
90
+ env("TACO_STDERR_LOG") = "${stderrLog}"
91
+
92
+ WScript.Quit sh.Run("""${nodeBin}"" ""${bundle}""", 0, True)
73
93
  `;
74
94
  }
75
95
 
@@ -89,12 +109,25 @@ export interface InstallSchtasksInput {
89
109
  * - No /RL HIGHEST: the daemon is pure user-mode; elevation only breaks
90
110
  * the installer's ability to terminate it.
91
111
  * - /F overwrites any prior registration; re-running `taco install` is the
92
- * supported update path. */
112
+ * supported update path.
113
+ * - /TR is `wscript.exe //nologo "<wrapper.vbs>"` rather than the .vbs
114
+ * path alone, so Task Scheduler never resolves the action through
115
+ * `cmd.exe` / the `.vbs` file association (either of which can flash
116
+ * a console). The wrapper path is quoted so usernames with spaces work. */
93
117
  export function schtasksCreateArgs(wrapperPath: string): string[] {
94
- return ["/Create", "/SC", "ONLOGON", "/TN", SCHTASKS_NAME, "/TR", `"${wrapperPath}"`, "/F"];
118
+ return [
119
+ "/Create",
120
+ "/SC",
121
+ "ONLOGON",
122
+ "/TN",
123
+ SCHTASKS_NAME,
124
+ "/TR",
125
+ `wscript.exe //nologo "${wrapperPath}"`,
126
+ "/F",
127
+ ];
95
128
  }
96
129
 
97
- /** Run the Windows install: write the .cmd wrapper + create the scheduled
130
+ /** Run the Windows install: write the .vbs wrapper + create the scheduled
98
131
  * task via schtasks. We don't wait for the daemon socket (Windows named
99
132
  * pipes don't have a stable readiness signal without a probe round-trip
100
133
  * matching the sidecar's hello frame); the desktop's `resolve_sidecar`
@@ -110,10 +143,24 @@ export async function installSchtasks(input: InstallSchtasksInput): Promise<Inst
110
143
  bundle: input.pkg.bundle,
111
144
  resourcesRoot: input.pkg.resources,
112
145
  });
113
- writeFileSync(wrapperPath, wrapperContent, { mode: 0o755 });
146
+ // UTF-16 LE + BOM: wscript reads .vbs as the system ANSI code page
147
+ // unless the file is Unicode, and TACO_HOME for a non-ASCII username
148
+ // would otherwise be garbled.
149
+ writeFileSync(wrapperPath, `\uFEFF${wrapperContent}`, { encoding: "utf16le" });
114
150
 
115
151
  await execFile("schtasks", schtasksCreateArgs(wrapperPath));
116
152
 
153
+ // Drop the pre-vbs .cmd only after /Create succeeds. Doing it first
154
+ // would leave a failed install pointing at a missing launcher (the
155
+ // old ONLOGON task still targets taco-sidecar-daemon.cmd). Once the
156
+ // task is retargeted at the .vbs the leftover is inert.
157
+ const legacyCmd = legacyWindowsCmdPath(input.tacoHome);
158
+ try {
159
+ if (existsSync(legacyCmd)) unlinkSync(legacyCmd);
160
+ } catch {
161
+ // Best-effort: the .cmd is unused once the task points at the .vbs.
162
+ }
163
+
117
164
  // Kick the task immediately so the user doesn't have to sign out + in
118
165
  // to see the install take effect. `/Run` returns once the task is
119
166
  // dispatched, not when the daemon is ready — the desktop handles
package/lib/paths.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * Shared user data lives under $TACO_HOME. Daemon coordination state lives
5
5
  * under $TACO_RUNTIME_DIR when it is set, otherwise $TACO_HOME/run:
6
6
  * runtime/ # socket, control socket, pid, and start lock (Unix)
7
- * bin/ # launcher wrapper scripts (taco-sidecar-daemon[.cmd])
7
+ * bin/ # launcher wrapper scripts (taco-sidecar-daemon[.vbs])
8
8
  * logs/ # service stdout/stderr targets
9
9
  * staging/ # upgrade staging area
10
10
  * jobs/ # scheduler job definitions
@@ -17,6 +17,7 @@
17
17
  * 2. $HOME/.taco
18
18
  */
19
19
 
20
+ import { createHash } from "node:crypto";
20
21
  import { mkdir } from "node:fs/promises";
21
22
  import { homedir } from "node:os";
22
23
  import { join } from "node:path";
@@ -50,18 +51,35 @@ export function resolveTacoRuntimeDir(
50
51
  export const RUNTIME_DIR = resolveTacoRuntimeDir();
51
52
  export const BIN_DIR = join(TACO_HOME, "bin");
52
53
 
53
- /** NDJSON socket path. Unix: filesystem path under the runtime directory. Windows: named pipe. */
54
+ /** Normalize a runtime directory so debug/release/verbatim Windows paths hash
55
+ * to the same pipe slug. Slash direction, a trailing separator, and the
56
+ * `\\?\` prefix must not produce a second daemon for the same directory.
57
+ * The step order and the ASCII-only case fold must match the Rust twin
58
+ * (`paths.rs::windows_pipe_slug`) byte for byte — the desktop connects to the
59
+ * pipe this slug names, so `toLowerCase()`'s Unicode folding would split
60
+ * `C:\Users\Ü…` into two different pipes. */
61
+ export function windowsPipeSlug(runtimeDir: string): string {
62
+ let normalized = runtimeDir.replace(/\//g, "\\");
63
+ if (normalized.startsWith("\\\\?\\")) normalized = normalized.slice(4);
64
+ normalized = normalized.replace(/\\+$/, "").replace(/[A-Z]/g, (c) => c.toLowerCase());
65
+ return createHash("sha256").update(normalized, "utf8").digest("hex").slice(0, 16);
66
+ }
67
+
68
+ /** NDJSON socket path. Unix: filesystem path under the runtime directory.
69
+ * Windows: named pipe derived from the runtime directory so debug
70
+ * (`~/.taco-dev/run`) and release (`~/.taco/run`) do not collide on the
71
+ * previously-global `\\.\pipe\taco-sidecar`. */
54
72
  export function ndjsonSocketPath(runtimeDir: string = RUNTIME_DIR): string {
55
73
  if (process.platform === "win32") {
56
- return "\\\\.\\pipe\\taco-sidecar";
74
+ return `\\\\.\\pipe\\taco-sidecar-${windowsPipeSlug(runtimeDir)}`;
57
75
  }
58
76
  return join(runtimeDir, "sidecar.sock");
59
77
  }
60
78
 
61
- /** Control socket path. Unix: filesystem path under the runtime directory. Windows: named pipe. */
79
+ /** Control socket path. Same layout as {@link ndjsonSocketPath}. */
62
80
  export function controlSocketPath(runtimeDir: string = RUNTIME_DIR): string {
63
81
  if (process.platform === "win32") {
64
- return "\\\\.\\pipe\\taco-sidecar-ctl";
82
+ return `\\\\.\\pipe\\taco-sidecar-ctl-${windowsPipeSlug(runtimeDir)}`;
65
83
  }
66
84
  return join(runtimeDir, "sidecar-ctl.sock");
67
85
  }
@@ -3,8 +3,12 @@
3
3
  *
4
4
  * Two launch modes:
5
5
  * - dev (TACO_SIDECAR_DEV=1 or this file is in repo's packages/cli): spawn
6
- * `tsx <repo>/packages/sidecar/src/index.ts` so the developer gets hot
7
- * reload + TypeScript source.
6
+ * `node --import tsx/dist/loader.mjs <repo>/packages/sidecar/src/index.ts`
7
+ * so the developer gets TypeScript source in one process. Never spawn
8
+ * `tsx/dist/cli.mjs` — that CLI re-forks node without inheriting
9
+ * windowsHide, which is the console flash on Windows. Never spawn the
10
+ * `node_modules/.bin/tsx` shim either: on Windows that file is
11
+ * `tsx.cmd` and Node 22+ rejects it with `spawn EINVAL`.
8
12
  * - prod: locate the platform-specific optional dep
9
13
  * (`@taco-ai/sidecar-<platform>`) via `createRequire`, read its
10
14
  * `manifest.json` to find the node binary + bundle, spawn them.
@@ -18,13 +22,13 @@
18
22
  */
19
23
 
20
24
  import { type ChildProcess, spawn } from "node:child_process";
21
- import { existsSync, readFileSync } from "node:fs";
25
+ import { closeSync, existsSync, mkdirSync, openSync, readFileSync } from "node:fs";
22
26
  import { createRequire } from "node:module";
23
27
  import { dirname, join } from "node:path";
24
- import { fileURLToPath } from "node:url";
28
+ import { fileURLToPath, pathToFileURL } from "node:url";
25
29
  import { PLATFORM_KEYS } from "./upgradePlatform.ts";
26
30
 
27
- interface LaunchedBundle {
31
+ export interface LaunchedBundle {
28
32
  program: string;
29
33
  args: string[];
30
34
  cwd?: string;
@@ -69,20 +73,41 @@ export function isDevCheckout(repoRoot: string | null = findRepoRoot()): boolean
69
73
  return repoRoot !== null && process.env.TACO_SIDECAR_DEV !== "0";
70
74
  }
71
75
 
72
- /** When the CLI is launched from a development checkout (sibling of `packages/`),
73
- * prefer `tsx <repo>/packages/sidecar/src/index.ts` over the bundled platform pkg
74
- * so devs see hot-reload + line numbers in stack traces. */
75
- function devLauncher(repoRoot: string): LaunchedBundle {
76
- const repoTsx = join(
77
- repoRoot,
78
- "node_modules",
79
- ".bin",
80
- process.platform === "win32" ? "tsx.cmd" : "tsx",
76
+ /** Locate `tsx/dist/loader.mjs` so we can
77
+ * `spawn(process.execPath, ["--import", loader, entry])`.
78
+ *
79
+ * In-process loader instead of `tsx/dist/cli.mjs`: the CLI re-forks node
80
+ * without inheriting windowsHide, which flashes a console on Windows.
81
+ * Never spawn the `node_modules/.bin/tsx` shim either: on Windows that
82
+ * file is `tsx.cmd`, and Node 22+ rejects `.cmd`/`.bat` with `spawn EINVAL`
83
+ * (CVE-2024-27980). */
84
+ export function locateTsxLoader(repoRoot: string): string {
85
+ const fromRepo = join(repoRoot, "node_modules", "tsx", "dist", "loader.mjs");
86
+ if (existsSync(fromRepo)) return fromRepo;
87
+ let dir = dirname(fileURLToPath(import.meta.url));
88
+ for (let i = 0; i < 8; i++) {
89
+ const candidate = join(dir, "node_modules", "tsx", "dist", "loader.mjs");
90
+ if (existsSync(candidate)) return candidate;
91
+ const parent = dirname(dir);
92
+ if (parent === dir) break;
93
+ dir = parent;
94
+ }
95
+ throw new Error(
96
+ "tsx loader not found (node_modules/tsx/dist/loader.mjs). Run `pnpm install` in the taco checkout.",
81
97
  );
82
- const program = existsSync(repoTsx) ? repoTsx : "tsx";
98
+ }
99
+
100
+ /** When the CLI is launched from a development checkout (sibling of `packages/`),
101
+ * prefer TypeScript source over the bundled platform pkg so devs see line
102
+ * numbers in stack traces. One process: `--import` the tsx loader rather
103
+ * than spawning `tsx/dist/cli.mjs`, which re-forks node. */
104
+ export function resolveDevLaunch(repoRoot: string): LaunchedBundle {
105
+ const loader = locateTsxLoader(repoRoot);
106
+ // file:// so Node's --import accepts a Windows path with drive letters.
107
+ const loaderUrl = pathToFileURL(loader).href;
83
108
  return {
84
- program,
85
- args: [join(repoRoot, "packages", "sidecar", "src", "index.ts")],
109
+ program: process.execPath,
110
+ args: ["--import", loaderUrl, join(repoRoot, "packages", "sidecar", "src", "index.ts")],
86
111
  cwd: repoRoot,
87
112
  };
88
113
  }
@@ -158,8 +183,9 @@ export interface LaunchResult {
158
183
  * forward signals / wait for exit. The child is spawned detached: on POSIX it gets
159
184
  * its own process group (terminal signals aimed at the launcher don't reach the
160
185
  * daemon) and is reparented to init once the launcher exits; on Windows detaching
161
- * releases it from the launcher's job object so it outlives the launcher (PR3 wraps
162
- * the daemon in a service anyway). */
186
+ * releases it from the launcher's job object so it outlives `taco start`.
187
+ * Paired with `child.unref()` in start.ts. `windowsHide` still applies — the
188
+ * leftover console was tsx/dist/cli.mjs re-forking node, not DETACHED_PROCESS. */
163
189
  export function launchSidecar(opts: LaunchOptions): LaunchResult {
164
190
  const repoRoot = findRepoRoot();
165
191
  const useDev = opts.forceDev === true || isDevCheckout(repoRoot);
@@ -168,7 +194,7 @@ export function launchSidecar(opts: LaunchOptions): LaunchResult {
168
194
  let resourcesRoot: string | undefined;
169
195
 
170
196
  if (useDev && repoRoot) {
171
- bundle = devLauncher(repoRoot);
197
+ bundle = resolveDevLaunch(repoRoot);
172
198
  resourcesRoot = join(repoRoot, "packages", "sidecar", "src");
173
199
  } else {
174
200
  const prod = prodBundlePaths();
@@ -194,21 +220,53 @@ export function launchSidecar(opts: LaunchOptions): LaunchResult {
194
220
  TACO_SIDECAR_RESOURCES: resourcesRoot,
195
221
  };
196
222
 
223
+ // stdin/stdout stay "ignore" — NDJSON goes via the socket, not stdio.
224
+ //
225
+ // Windows: "inherit" is forbidden with `detached: true` (EINVAL), and a
226
+ // detached child whose stdio handles are all "ignore" does not outlive the
227
+ // launcher, so stderr goes to a file the daemon owns. That fd owns
228
+ // $TACO_HOME/logs/daemon.err.log, so drop TACO_STDERR_LOG too: the Tauri
229
+ // desktop sets it on every spawn path, and the sidecar would answer by
230
+ // installing its own stderr tee against the same file, appending every line
231
+ // twice. One writer owns the file.
232
+ //
233
+ // POSIX keeps the long-standing `inherit` — both the desktop's stderr
234
+ // reader (launch-failure tail, Debug tab, `[taco:llm]` → llm-dump.log) and
235
+ // the sidecar's own tee hang off it, so nothing there needs to move.
236
+ let stderr: "ignore" | "inherit" | number = "inherit";
237
+ if (process.platform === "win32") {
238
+ delete env.TACO_STDERR_LOG;
239
+ stderr = "ignore";
240
+ try {
241
+ const logDir = join(opts.tacoHome, "logs");
242
+ mkdirSync(logDir, { recursive: true });
243
+ stderr = openSync(join(logDir, "daemon.err.log"), "a");
244
+ } catch {
245
+ stderr = "ignore";
246
+ }
247
+ }
248
+
197
249
  const child = spawn(bundle.program, bundle.args, {
198
250
  cwd: bundle.cwd,
199
251
  env,
200
252
  // Detached daemon: own process group on POSIX, released from the
201
- // launcher's job object on Windows. Paired with child.unref() in
202
- // start.ts so the daemon's lifetime is fully decoupled from whoever
203
- // ran `taco start`.
253
+ // launcher's job object on Windows. Without this on Windows, `taco
254
+ // start` exiting (or the desktop killing the launcher after the
255
+ // socket is ready) takes the sidecar with it — the follower then
256
+ // waits 20s on a pipe that never appears.
204
257
  detached: true,
205
- // Daemon mode: NDJSON goes via the socket, stderr goes to the daemon's
206
- // own log file (sidecar opens LogFiles at $TACO_HOME/logs/), stdin is
207
- // ignored (control socket is the inbound path).
208
- stdio: ["ignore", "ignore", "inherit"],
209
- // Windows: don't pop a conhost window for the daemon.
258
+ stdio: ["ignore", "ignore", stderr],
259
+ // Windows: hide the console of this node process. The previous
260
+ // leftover flash was tsx/dist/cli.mjs re-forking a second node
261
+ // that did not inherit this flag — that path is gone (`--import`
262
+ // loader). DETACHED_PROCESS and CREATE_NO_WINDOW can coexist here
263
+ // because we never inherit stdio on Windows.
210
264
  ...(process.platform === "win32" ? { windowsHide: true } : {}),
211
265
  });
212
266
 
267
+ // libuv dups the fd into the child, so the parent's copy is dead weight the
268
+ // moment spawn returns — without this every launch on Windows leaks one fd.
269
+ if (typeof stderr === "number") closeSync(stderr);
270
+
213
271
  return { child, dev: useDev };
214
272
  }
package/lib/start.ts CHANGED
@@ -423,10 +423,14 @@ export async function startCommand(opts: StartOptions = {}): Promise<void> {
423
423
  runtimeDir,
424
424
  });
425
425
 
426
- // If the bundle exits before binding the socket, surface its stderr
427
- // (already inherited) and a clear error rather than letting the caller
428
- // hang on the ready timeout.
426
+ // If the bundle exits before binding the socket, surface the cause
427
+ // rather than letting the caller hang on the ready timeout.
429
428
  const exitedEarly = new Promise<never>((_, reject) => {
429
+ // Spawn failures (Windows EINVAL on a .cmd, ENOENT, …) emit `error`
430
+ // without a corresponding `exit`. Listen for both so the start.lock
431
+ // `finally` still runs; otherwise a failed spawn wedges every later
432
+ // `taco start` until the 15s TTL.
433
+ child.once("error", (err) => reject(err));
430
434
  child.once("exit", (code, sig) => {
431
435
  reject(new Error(`sidecar exited before binding socket (code=${code} sig=${sig})`));
432
436
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taco-ai/cli",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "private": false,
5
5
  "description": "Taco CLI — launcher + daemon supervisor for the sidecar. Wraps @taco-ai/sidecar with user-facing subcommands (start, status, install, upgrade).",
6
6
  "type": "module",
@@ -22,8 +22,8 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "tar": "^7.5.22",
25
- "@taco-ai/shared": "0.2.4",
26
- "@taco-ai/sidecar": "0.2.4"
25
+ "@taco-ai/shared": "0.2.6",
26
+ "@taco-ai/sidecar": "0.2.6"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/node": "^22.7.0",