cotal-ai 0.164.13 → 0.164.15

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 (38) hide show
  1. package/dist/daemon/auto-update.js +62 -3
  2. package/dist/daemon/command.js +8 -2
  3. package/dist/daemon/desktop-path.js +17 -4
  4. package/dist/daemon/desktop.js +73 -16
  5. package/dist/daemon/install-native-run.js +6 -4
  6. package/dist/daemon/install-receipt.js +4 -1
  7. package/dist/daemon/install.js +125 -58
  8. package/dist/daemon/lifetime.js +19 -2
  9. package/dist/daemon/setup.js +5 -5
  10. package/dist/daemon/update-windows-activation.js +72 -0
  11. package/dist/daemon/update-windows-runner.js +89 -0
  12. package/dist/daemon/update-windows.js +234 -0
  13. package/package.json +19 -19
  14. package/seeded-connectors/_shared/docs-bundle.bin +0 -0
  15. package/seeded-connectors/_shared/docs-index.bin +0 -0
  16. package/seeded-connectors/_shared/placements.json +2 -2
  17. package/seeded-connectors/claude/dist/index.js +1 -1
  18. package/seeded-connectors/claude/dist/mcp.cjs +2 -2
  19. package/seeded-connectors/claude/package.json +1 -1
  20. package/seeded-connectors/codex/dist/host.js +2 -2
  21. package/seeded-connectors/codex/dist/index.js +1 -1
  22. package/seeded-connectors/codex/dist/personal.js +2 -2
  23. package/seeded-connectors/codex/package.json +1 -1
  24. package/seeded-connectors/hermes/dist/index.js +1 -1
  25. package/seeded-connectors/hermes/dist/launch.js +2 -2
  26. package/seeded-connectors/hermes/package.json +1 -1
  27. package/seeded-connectors/hermes/plugin/cotal/_sidecar/standalone.cjs +2 -2
  28. package/seeded-connectors/jcode/dist/host.js +2 -2
  29. package/seeded-connectors/jcode/dist/index.js +1 -1
  30. package/seeded-connectors/jcode/dist/mcp.js +1 -1
  31. package/seeded-connectors/jcode/package.json +1 -1
  32. package/seeded-connectors/opencode/dist/index.js +1 -1
  33. package/seeded-connectors/opencode/dist/plugin/index.js +2 -2
  34. package/seeded-connectors/opencode/package.json +1 -1
  35. package/seeded-connectors/pi/dist/index.js +2 -2
  36. package/seeded-connectors/pi/dist/standalone.js +2 -2
  37. package/seeded-connectors/pi/package.json +1 -1
  38. package/seeded-connectors/web/package.json +1 -1
@@ -4,6 +4,8 @@ import { fileURLToPath } from "node:url";
4
4
  import { join } from "node:path";
5
5
  import { openPrivateAppend, writeSecretFileAtomic } from "@cotal-ai/core";
6
6
  import { checkForUpdate, homeCotalDir, newerUpdate, readUpdateCheck, readUpdateRecovery, readUpdateSettings, recoveryDisposition, UPDATE_DAY_MS, UPDATE_HOUR_MS } from "@cotal-ai/workspace";
7
+ import { cleanWindowsUpdate, startWindowsUpdate } from "./update-windows.js";
8
+ import { WINDOWS_INTERRUPTED_UPDATE, readWindowsUpdatePause } from "@cotal-ai/workspace";
7
9
  import { cleanLaunchUpdate, startLaunchUpdate } from "./update-launchd.js";
8
10
  /** Schedule only the existing updater. Manager preparation holds its native empty-seat admission fence. */
9
11
  export function automaticUpdates(host) {
@@ -20,6 +22,7 @@ export function automaticUpdates(host) {
20
22
  if (error.code !== "ENOENT")
21
23
  state = { ...state, result: "automatic updates paused: unreadable attempt record", next: Number.MAX_SAFE_INTEGER };
22
24
  }
25
+ let windowsPending = process.platform === "win32" && existsSync(join(homeCotalDir(), "update-windows.json"));
23
26
  let child, busy, closed = false, launchdPending = process.platform === "darwin" && (existsSync(join(homeCotalDir(), "update-launchd.json")) || existsSync(join(homeCotalDir(), "update-launchd-result.json")));
24
27
  const persist = () => writeSecretFileAtomic(file, `${JSON.stringify(state)}\n`);
25
28
  try {
@@ -43,7 +46,7 @@ export function automaticUpdates(host) {
43
46
  try {
44
47
  const settings = readUpdateSettings();
45
48
  notify = settings.notify;
46
- automatic = ["linux", "darwin"].includes(process.platform) && !desktop && settings.auto && process.env.COTAL_NO_UPDATE_CHECK !== "1" && host.eligible();
49
+ automatic = ["linux", "darwin", "win32"].includes(process.platform) && !desktop && settings.auto && process.env.COTAL_NO_UPDATE_CHECK !== "1" && host.eligible();
47
50
  const recovery = readUpdateRecovery();
48
51
  if (recovery) {
49
52
  const decision = recoveryDisposition(recovery);
@@ -51,12 +54,31 @@ export function automaticUpdates(host) {
51
54
  automatic = false;
52
55
  reason = `automatic updates ${decision.action === "retire" ? "can resume" : "paused"}: installed ${recovery.installed}; ${recovery.reason}; ${decision.instruction}`;
53
56
  }
57
+ if (process.platform === "win32" && readWindowsUpdatePause()) {
58
+ automatic = false;
59
+ reason = WINDOWS_INTERRUPTED_UPDATE;
60
+ }
54
61
  }
55
62
  catch (error) {
56
63
  automatic = false;
57
64
  reason = `automatic updates paused: ${String(error)}`;
58
65
  }
59
- if (!["linux", "darwin"].includes(process.platform))
66
+ if (process.platform === "win32") {
67
+ try {
68
+ const activation = JSON.parse(readFileSync(join(homeCotalDir(), "update-windows-activation.json"), "utf8"));
69
+ if (activation?.v !== 1 || !["pending", "ready", "failed", "not-needed"].includes(activation.activation) || typeof activation.target !== "string" || !Number.isFinite(activation.deadline))
70
+ throw new Error("invalid Windows activation result");
71
+ if (activation.target === state.version && activation.activation === "failed" && !readWindowsUpdatePause())
72
+ reason = `release ${activation.target} installed; automatic activation failed; use Start service`;
73
+ }
74
+ catch (error) {
75
+ if (error.code !== "ENOENT") {
76
+ automatic = false;
77
+ reason = `automatic activation status unreadable: ${String(error)}`;
78
+ }
79
+ }
80
+ }
81
+ if (!["linux", "darwin", "win32"].includes(process.platform))
60
82
  reason = `${reason}. Automatic installation is unavailable on ${process.platform === "win32" ? "Windows" : process.platform} in this release. Run \`cotal update --self\` here`;
61
83
  if (desktop)
62
84
  reason = "update the desktop app with its signed platform installer";
@@ -81,6 +103,31 @@ export function automaticUpdates(host) {
81
103
  return;
82
104
  }
83
105
  }
106
+ if (process.platform === "win32") {
107
+ try {
108
+ windowsPending = true;
109
+ const custody = cleanWindowsUpdate();
110
+ if (custody === "pending")
111
+ return;
112
+ windowsPending = false;
113
+ if (custody === "paused") {
114
+ state = { ...state, result: WINDOWS_INTERRUPTED_UPDATE, next: Number.MAX_SAFE_INTEGER };
115
+ persist();
116
+ return;
117
+ }
118
+ const recorded = JSON.parse(readFileSync(file, "utf8"));
119
+ const cleared = recorded.next === Number.MAX_SAFE_INTEGER && recorded.result === WINDOWS_INTERRUPTED_UPDATE;
120
+ state = cleared ? { ...recorded, next: 0, result: "Windows automatic update interruption cleared" } : recorded;
121
+ if (cleared || custody !== "absent")
122
+ persist();
123
+ }
124
+ catch (error) {
125
+ state = { ...state, result: `Windows automatic update custody unresolved: ${error instanceof Error ? error.message : String(error)}`, next: Date.now() + UPDATE_HOUR_MS };
126
+ persist();
127
+ host.report(state.result);
128
+ return;
129
+ }
130
+ }
84
131
  const settings = readUpdateSettings();
85
132
  const cached = process.env.COTAL_NO_UPDATE_CHECK !== "1" && (settings.auto || settings.notify) ? await checkForUpdate() : readUpdateCheck();
86
133
  const recovery = readUpdateRecovery();
@@ -131,6 +178,18 @@ export function automaticUpdates(host) {
131
178
  return;
132
179
  state = { ...state, failures: state.failures, result: `updating to ${cached.latest}`, next: Date.now() + UPDATE_HOUR_MS };
133
180
  persist();
181
+ if (process.platform === "win32") {
182
+ try {
183
+ windowsPending = true;
184
+ startWindowsUpdate(state.failures);
185
+ }
186
+ catch (error) {
187
+ state = { ...state, result: `Windows automatic update handoff refused: ${error instanceof Error ? error.message : String(error)}`, next: Date.now() + UPDATE_HOUR_MS };
188
+ persist();
189
+ host.report(state.result);
190
+ }
191
+ return;
192
+ }
134
193
  if (process.platform === "darwin") {
135
194
  try {
136
195
  launchdPending = true;
@@ -175,7 +234,7 @@ export function automaticUpdates(host) {
175
234
  busy = tick().catch(error => { host.report(`automatic update: ${String(error)}`); }).finally(() => { busy = undefined; });
176
235
  }, 30_000);
177
236
  timer.unref();
178
- return { status, async check() { await checkForUpdate(); return status(); }, updating: () => child !== undefined || launchdPending, async close() {
237
+ return { status, async check() { await checkForUpdate(); return status(); }, updating: () => child !== undefined || launchdPending || windowsPending, async close() {
179
238
  closed = true;
180
239
  clearInterval(timer);
181
240
  if (child) {
@@ -517,9 +517,15 @@ async function serve(args) {
517
517
  const { recoverInterruptedUpdate } = await import("@cotal-ai/cli/update");
518
518
  // Unusable abandoned records retire under the updater lock. Unknown owners remain paused
519
519
  // without blocking startup. A valid snapshot whose restoration failed still waits for repair.
520
+ let automaticCustodyPaused = false;
521
+ if (process.platform === "win32") {
522
+ const { cleanWindowsUpdate } = await import("./update-windows.js");
523
+ const disposition = cleanWindowsUpdate();
524
+ automaticCustodyPaused = disposition === "paused" || disposition === "pending";
525
+ }
520
526
  const deferredRecovery = readUpdateRecovery();
521
- const observedLiveUpdater = deferredRecovery !== undefined && liveUpdateClosureOwner(deferredRecovery);
522
- if (await recoverInterruptedUpdate(undefined, true))
527
+ const observedLiveUpdater = !automaticCustodyPaused && deferredRecovery !== undefined && liveUpdateClosureOwner(deferredRecovery);
528
+ if (!automaticCustodyPaused && await recoverInterruptedUpdate(undefined, true))
523
529
  throw new Error("interrupted update restored the previous installation; restart the daemon with the restored CLI");
524
530
  const { paths, home } = resolveTarget(args);
525
531
  let running;
@@ -13,6 +13,19 @@ const run = (command, args) => new Promise((resolve, reject) => {
13
13
  resolve(stdout);
14
14
  });
15
15
  });
16
+ /** Keep only absolute POSIX entries for the desktop service and name any relative entries left out, in order and without duplicates. */
17
+ export function filterDesktopApplicationPath(raw, nodeDir) {
18
+ const entries = `${raw}${posix.delimiter}${nodeDir}`.split(posix.delimiter).filter((entry) => entry !== "");
19
+ const kept = [];
20
+ const omitted = [];
21
+ for (const entry of entries) {
22
+ if (posix.isAbsolute(entry))
23
+ kept.push(entry);
24
+ else if (!omitted.includes(entry))
25
+ omitted.push(entry);
26
+ }
27
+ return { path: pinnedPath(kept.join(posix.delimiter), posix), omittedRelativeEntries: omitted };
28
+ }
16
29
  /** Windows tasks do not pin PATH. Read the current machine and user values on each native start. */
17
30
  export async function windowsApplicationPath() {
18
31
  const root = process.env.SystemRoot ?? process.env.SYSTEMROOT;
@@ -22,10 +35,10 @@ export async function windowsApplicationPath() {
22
35
  const value = await run(join(root, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"), ["-NoLogo", "-NoProfile", "-NonInteractive", "-Command", script]);
23
36
  return pinnedPath(`${value};${dirname(process.execPath)}`, win32);
24
37
  }
25
- /** No renderer-supplied executable, argument, shell or environment is accepted. */
26
- export async function desktopApplicationPath() {
38
+ /** Discover the desktop application PATH and any relative entries left out of it. No renderer-supplied executable, argument, shell or environment is accepted. */
39
+ export async function discoverDesktopApplicationPath() {
27
40
  if (process.platform === "win32")
28
- return windowsApplicationPath();
41
+ return { path: await windowsApplicationPath(), omittedRelativeEntries: [] };
29
42
  if (process.platform !== "linux" && process.platform !== "darwin")
30
43
  throw new CommandFailure("refused", "UNSUPPORTED", "this OS has no desktop application discovery");
31
44
  const shell = userInfo().shell;
@@ -36,5 +49,5 @@ export async function desktopApplicationPath() {
36
49
  const parts = output.split(marker);
37
50
  if (parts.length !== 3)
38
51
  throw new CommandFailure("refused", "DEPENDENCY_UNAVAILABLE", "the login shell returned no bounded application PATH; no service was changed");
39
- return pinnedPath(`${parts[1]}:${dirname(process.execPath)}`, posix);
52
+ return filterDesktopApplicationPath(parts[1], dirname(process.execPath));
40
53
  }
@@ -3,14 +3,15 @@ import { randomUUID } from "node:crypto";
3
3
  import { defaultComputerName } from "./computer-name.js";
4
4
  import { computerName } from "./name-validation.js";
5
5
  import { arch, platform, release, totalmem } from "node:os";
6
- import { CommandFailure, readUpdateSettings, setUpdateSetting } from "@cotal-ai/workspace";
6
+ import { CommandFailure, readLocalRecordSource, readUpdateSettings, setUpdateSetting } from "@cotal-ai/workspace";
7
7
  import { normalizeIdpUrl } from "@cotal-ai/auth";
8
8
  import { loginViaDaemon, updateViaDaemon, openVerified, queryDaemon, readLine } from "./client.js";
9
9
  import { DAEMON_PROTOCOL_VERSION, MAX_LINE_BYTES, EndpointRefusal } from "./endpoint.js";
10
10
  import { applyInstall, planUninstall, startInstalled } from "./install.js";
11
+ import { nativeDaemonLog } from "./native-log.js";
11
12
  import { encode, isDaemonSpaceName } from "./protocol.js";
12
13
  import { runSetup } from "./setup.js";
13
- import { desktopApplicationPath } from "./desktop-path.js";
14
+ import { discoverDesktopApplicationPath } from "./desktop-path.js";
14
15
  import { assertDesktopSetupComplete } from "./desktop-setup.js";
15
16
  /** No renderer-supplied command, path, credentials or arbitrary arguments cross this boundary. */
16
17
  export function parseDesktopRequest(value) {
@@ -96,6 +97,43 @@ function serviceInstalled(target) {
96
97
  return false;
97
98
  }
98
99
  }
100
+ /** Read only a startup refusal line written during this install attempt, never an earlier launch's log. */
101
+ function attemptStartupRefusal(state, attemptStartedAt) {
102
+ let bytes;
103
+ try {
104
+ bytes = readLocalRecordSource(nativeDaemonLog(state), 64 * 1024 + 128, true);
105
+ }
106
+ catch {
107
+ return undefined;
108
+ }
109
+ if (!bytes)
110
+ return undefined;
111
+ const lines = bytes.toString("utf8")
112
+ .replace(/\u001b\[[0-9;]*[A-Za-z]/g, "")
113
+ .replace(/[\u0000-\u0008\u000b-\u001f\u007f]/g, "")
114
+ .replace(/eyJ[A-Za-z0-9_.-]*/g, "<redacted>")
115
+ .split(/\r?\n/);
116
+ let launchIndex = -1;
117
+ for (let i = 0; i < lines.length; i++) {
118
+ const match = /^daemon service launch (\S+)$/.exec(lines[i]);
119
+ if (!match)
120
+ continue;
121
+ const launchedAt = Date.parse(match[1]);
122
+ launchIndex = Number.isFinite(launchedAt) && launchedAt >= attemptStartedAt ? i : -1;
123
+ }
124
+ if (launchIndex < 0)
125
+ return undefined;
126
+ let refusal;
127
+ for (let i = launchIndex + 1; i < lines.length; i++) {
128
+ const line = lines[i];
129
+ if (!line.startsWith("daemon startup refused:"))
130
+ continue;
131
+ const reason = line.slice("daemon startup refused:".length).trim().slice(0, 500);
132
+ if (reason)
133
+ refusal = reason;
134
+ }
135
+ return refusal;
136
+ }
99
137
  /** Run one app operation through the stock local client. Closing the UI never stops the service. */
100
138
  export async function runDesktopBridge(opts) {
101
139
  const output = opts.output ?? process.stdout;
@@ -109,6 +147,8 @@ export async function runDesktopBridge(opts) {
109
147
  return;
110
148
  }
111
149
  let target;
150
+ let startedAt;
151
+ let omittedRelativePathEntries = [];
112
152
  try {
113
153
  if (req.op === "update-policy") {
114
154
  const settings = req.auto === undefined ? readUpdateSettings() : setUpdateSetting("auto", req.auto);
@@ -156,14 +196,23 @@ export async function runDesktopBridge(opts) {
156
196
  target = opts.resolveTarget();
157
197
  const { paths, home } = target;
158
198
  const client = { paths, peerUid: opts.peerUid, peerPid: opts.peerPid };
159
- if (req.op === "install" || req.op === "setup")
160
- process.env.PATH = await desktopApplicationPath();
199
+ if (req.op === "install" || req.op === "setup") {
200
+ const discovered = await discoverDesktopApplicationPath();
201
+ process.env.PATH = discovered.path;
202
+ omittedRelativePathEntries = discovered.omittedRelativeEntries;
203
+ if (omittedRelativePathEntries.length) {
204
+ const detail = `left out relative PATH entries: ${omittedRelativePathEntries.join(", ")}`;
205
+ emit({ v: 1, event: "setup-progress", line: `service: ${detail}`, progress: { step: "install", outcome: "running", detail } });
206
+ }
207
+ }
208
+ const omittedResult = omittedRelativePathEntries.length ? { omittedRelativePathEntries } : {};
161
209
  if (req.op === "setup") {
162
- const result = await runSetup({ ...client, daemonHome: home, space: req.space, idp: req.idp, version: opts.version, waitSeconds: 0,
210
+ startedAt = Date.now();
211
+ const result = await runSetup({ ...client, daemonHome: home, space: req.space, idp: req.idp, version: opts.version, waitSeconds: 0, ...omittedResult,
163
212
  report: (line, progress) => emit({ v: 1, event: "setup-progress", line, progress }),
164
213
  onPrompt: (prompt) => emit({ v: 1, event: "login-prompt", prompt }),
165
214
  });
166
- emit({ v: 1, event: "result", ok: true, result });
215
+ emit({ v: 1, event: "result", ok: true, result: { ...result, ...omittedResult } });
167
216
  return;
168
217
  }
169
218
  if (req.op === "install") {
@@ -189,13 +238,14 @@ export async function runDesktopBridge(opts) {
189
238
  throw new CommandFailure("refused", "CONFLICT", "an unowned daemon is already running; no service was installed");
190
239
  if (!answering.ok || answering.result.version !== opts.version)
191
240
  throw new CommandFailure("refused", "CONFLICT", "the installed daemon does not match this app; no service was started");
192
- emit({ v: 1, event: "result", ok: true, result: { installed: true, status: answering.result } });
241
+ emit({ v: 1, event: "result", ok: true, result: { installed: true, status: answering.result, ...omittedResult } });
193
242
  return;
194
243
  }
244
+ startedAt = Date.now();
195
245
  if (existing)
196
246
  await startInstalled(paths, home, opts.version, detail => emit({ v: 1, event: "setup-progress", line: `service: ${detail}`, progress: { step: "install", outcome: "running", detail } }));
197
247
  else
198
- applyInstall(paths, home);
248
+ applyInstall(paths, home, omittedRelativePathEntries);
199
249
  const deadline = Date.now() + 15_000;
200
250
  for (;;) {
201
251
  try {
@@ -204,14 +254,14 @@ export async function runDesktopBridge(opts) {
204
254
  throw new Error("daemon refused status");
205
255
  if (status.result.version !== opts.version)
206
256
  throw new Error("daemon version mismatch");
207
- emit({ v: 1, event: "result", ok: true, result: { installed: true, status: status.result } });
257
+ emit({ v: 1, event: "result", ok: true, result: { installed: true, status: status.result, ...omittedResult } });
208
258
  return;
209
259
  }
210
260
  catch (e) {
211
261
  if (!(e instanceof EndpointRefusal) || !["NOT_RUNNING", "PEER_NOT_LOCK_OWNER"].includes(e.code))
212
262
  throw e;
213
263
  if (Date.now() >= deadline)
214
- throw new CommandFailure("refused", "DEPENDENCY_UNAVAILABLE", "the installed daemon did not answer within 15 seconds of being started", { native: { code: "NOT_ANSWERING" } });
264
+ throw new CommandFailure("refused", "DEPENDENCY_UNAVAILABLE", "the installed daemon did not answer within 15 seconds of being started", { native: { code: "NOT_ANSWERING", detail: { waitSeconds: 15 } } });
215
265
  }
216
266
  await new Promise((resolve) => setTimeout(resolve, 250));
217
267
  }
@@ -247,17 +297,24 @@ export async function runDesktopBridge(opts) {
247
297
  }
248
298
  catch (e) {
249
299
  const code = e instanceof EndpointRefusal || e instanceof CommandFailure ? e.code : "OPERATION_FAILED";
250
- const message = e instanceof CommandFailure && (e.code === "CONFLICT" || req.op === "setup" || (req.op === "install" && e.native?.code !== "NOT_ANSWERING")) ? e.message
251
- : code === "NOT_RUNNING" ? (target && serviceInstalled(target)
252
- ? "The background service is installed but stopped. Choose Start service to start it."
253
- : "The daemon is not running. Install its background service first.")
254
- : e instanceof CommandFailure && e.code === "DEPENDENCY_UNAVAILABLE" && e.native?.code === "NOT_ANSWERING" ? "The background service was installed and a start was requested, but the daemon did not answer within 15 seconds. Use \`cotal daemon status\` for diagnostics."
300
+ const notAnswering = e instanceof CommandFailure && (req.op === "setup" || req.op === "install") && e.code === "DEPENDENCY_UNAVAILABLE" && e.native?.code === "NOT_ANSWERING";
301
+ const refusal = notAnswering && target && startedAt !== undefined ? attemptStartupRefusal(target.paths.state, startedAt) : undefined;
302
+ const rawWait = notAnswering && e.native?.detail && typeof e.native.detail === "object" ? e.native.detail.waitSeconds : undefined;
303
+ const waitSeconds = typeof rawWait === "number" && Number.isInteger(rawWait) && rawWait > 0 ? rawWait : undefined;
304
+ const baseMessage = notAnswering ? `Cotal asked the background service on this computer to start, and it ${waitSeconds !== undefined ? `did not answer within ${waitSeconds} seconds.` : "has not answered."}${refusal ? ` It refused to start: ${refusal}` : ""}`
305
+ : e instanceof CommandFailure && (e.code === "CONFLICT" || req.op === "setup" || req.op === "install") ? e.message
306
+ : code === "NOT_RUNNING" ? (target && serviceInstalled(target)
307
+ ? "The background service is installed but stopped. Choose Start service to start it."
308
+ : "The daemon is not running. Install its background service first.")
255
309
  : code === "NO_RUNTIME_DIR" ? "The daemon runtime path is unavailable or too long. On Linux, check XDG_RUNTIME_DIR for the intended operating-system user."
256
310
  : code === "UNSUPPORTED_PLATFORM" ? "This platform does not have the required native daemon support."
257
311
  : code === "PEER_UID_MISMATCH" || code === "PEER_NOT_LOCK_OWNER" ? "The local daemon identity could not be verified. The requested change was not sent."
258
312
  : "The operation could not be completed. Use the matching `cotal daemon` command for diagnostics; no success is assumed.";
313
+ const message = (req.op === "setup" || req.op === "install") && omittedRelativePathEntries.length
314
+ ? `${baseMessage}${baseMessage.endsWith(".") ? "" : "."} Left out relative PATH entries: ${omittedRelativePathEntries.join(", ")}.`
315
+ : baseMessage;
259
316
  emit({ v: 1, event: "result", ok: false, error: { code, message,
260
- ...(e instanceof CommandFailure && (req.op === "setup" || req.op === "install") ? { remedy: e.remedy, native: e.native } : {}),
317
+ ...(e instanceof CommandFailure && (req.op === "setup" || req.op === "install") ? { remedy: notAnswering ? "choose Check status." : e.remedy, native: e.native } : {}),
261
318
  } });
262
319
  }
263
320
  }
@@ -2,18 +2,20 @@ import { spawnSync } from "node:child_process";
2
2
  import { basename } from "node:path";
3
3
  import { CommandFailure } from "@cotal-ai/workspace/local-observation";
4
4
  /** Runs one native tool by absolute path with the existing bounds, never through a shell. */
5
- export function nativeRun(file, args, env) {
5
+ export function nativeRun(file, args, env, timeoutMs = 30_000) {
6
+ if (!Number.isFinite(timeoutMs) || timeoutMs <= 0)
7
+ throw new Error("native operation deadline expired");
6
8
  const started = Date.now();
7
- const result = spawnSync(file, args, { encoding: "utf8", timeout: 30_000, maxBuffer: 256 * 1024, stdio: ["ignore", "pipe", "pipe"], windowsHide: true, ...(env ? { env } : {}) });
9
+ const result = spawnSync(file, args, { encoding: "utf8", timeout: timeoutMs, maxBuffer: 256 * 1024, stdio: ["ignore", "pipe", "pipe"], windowsHide: true, ...(env ? { env } : {}) });
8
10
  if (result.error || result.signal) {
9
11
  const elapsedMs = Date.now() - started;
10
12
  const code = result.error?.code;
11
- const reason = code === "ETIMEDOUT" ? "timed out after 30 s"
13
+ const reason = code === "ETIMEDOUT" ? `timed out after ${timeoutMs / 1000} s`
12
14
  : code === "ENOBUFS" ? "exceeded its 256 KiB output limit"
13
15
  : code ? `could not start or complete (${code})`
14
16
  : `exited by signal ${result.signal}`;
15
17
  throw new CommandFailure("refused", "DEPENDENCY_UNAVAILABLE", `${basename(file)} ${reason} (elapsed ${elapsedMs} ms); no further native step was taken`, {
16
- native: { code: code ?? result.signal ?? "NATIVE_TOOL_FAILED", detail: { elapsedMs, timeoutMs: 30_000, signal: result.signal } },
18
+ native: { code: code ?? result.signal ?? "NATIVE_TOOL_FAILED", detail: { elapsedMs, timeoutMs, signal: result.signal } },
17
19
  });
18
20
  }
19
21
  const stdout = typeof result.stdout === "string" ? result.stdout : "";
@@ -20,5 +20,8 @@ export function readReceipt(paths) {
20
20
  return undefined;
21
21
  if (r.mechanism !== undefined && r.mechanism !== "systemd-user" && r.mechanism !== "launchd-agent" && r.mechanism !== "scheduled-task")
22
22
  return undefined;
23
- return { v: 1, ...(r.mechanism !== undefined ? { mechanism: r.mechanism } : {}), unit: r.unit, unitPath: r.unitPath, unitSha256: r.unitSha256, installedAt: r.installedAt, ...(typeof r.daemonHome === "string" ? { daemonHome: r.daemonHome } : {}) };
23
+ const omitted = Array.isArray(r.omittedRelativePathEntries) && r.omittedRelativePathEntries.every((item) => typeof item === "string" && item.length > 0)
24
+ ? r.omittedRelativePathEntries
25
+ : undefined;
26
+ return { v: 1, ...(r.mechanism !== undefined ? { mechanism: r.mechanism } : {}), unit: r.unit, unitPath: r.unitPath, unitSha256: r.unitSha256, installedAt: r.installedAt, ...(typeof r.daemonHome === "string" ? { daemonHome: r.daemonHome } : {}), ...(omitted?.length ? { omittedRelativePathEntries: omitted } : {}) };
24
27
  }