u-foo 2.5.5 → 2.5.7

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.
@@ -1340,7 +1340,14 @@ function startDaemon({ projectRoot, provider, model, resumeMode = "auto" }) {
1340
1340
  log(`report bus event failed request=${meta.requestId || ""} error=${err.message || String(err)}`);
1341
1341
  }
1342
1342
  });
1343
- const deliveryScheduler = new DeliveryScheduler(projectRoot, { log });
1343
+ const deliveryScheduler = new DeliveryScheduler(projectRoot, {
1344
+ log,
1345
+ emitDelivery: async ({ subscriber, status, error } = {}) => {
1346
+ if (status === "error") {
1347
+ log(`delivery failed subscriber=${subscriber || "unknown"} error=${error || "unknown"}`);
1348
+ }
1349
+ },
1350
+ });
1344
1351
  deliveryScheduler.start();
1345
1352
 
1346
1353
  handleIpcRequest = async (req, socket) => {
@@ -282,11 +282,28 @@ function buildShellEnvPrefix(extraEnv = {}) {
282
282
  .join(" ");
283
283
  }
284
284
 
285
+ // osascript can hang forever on permission prompts or a stuck System Events;
286
+ // launch and close both await runAppleScript, so without a timeout the daemon
287
+ // would stay blocked until restart.
288
+ const APPLESCRIPT_TIMEOUT_MS = 10000;
289
+
290
+ function killAfterTimeout(proc, cmd, onTimeout) {
291
+ return setTimeout(() => {
292
+ try {
293
+ proc.kill("SIGKILL");
294
+ } catch {
295
+ // process already exited, nothing to kill
296
+ }
297
+ onTimeout(new Error(`${cmd} timeout after ${APPLESCRIPT_TIMEOUT_MS}ms`));
298
+ }, APPLESCRIPT_TIMEOUT_MS);
299
+ }
300
+
285
301
  function runAppleScript(lines) {
286
302
  return new Promise((resolve, reject) => {
287
303
  const proc = spawn("osascript", lines.flatMap((l) => ["-e", l]));
288
304
  let stderr = "";
289
305
  let stdout = "";
306
+ const timeout = killAfterTimeout(proc, "osascript", reject);
290
307
  proc.stderr.on("data", (d) => {
291
308
  stderr += d.toString("utf8");
292
309
  });
@@ -294,9 +311,14 @@ function runAppleScript(lines) {
294
311
  stdout += d.toString("utf8");
295
312
  });
296
313
  proc.on("close", (code) => {
314
+ clearTimeout(timeout);
297
315
  if (code === 0) resolve(stdout.trim());
298
316
  else reject(new Error(stderr || "osascript failed"));
299
317
  });
318
+ proc.on("error", (err) => {
319
+ clearTimeout(timeout);
320
+ reject(err);
321
+ });
300
322
  });
301
323
  }
302
324
 
@@ -1317,5 +1339,6 @@ module.exports = {
1317
1339
  toTerminalBinary,
1318
1340
  toTmuxBinary,
1319
1341
  buildResumeArgs,
1342
+ runAppleScript,
1320
1343
  },
1321
1344
  };