@tekmidian/pai 0.54.0 → 0.54.1

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.
@@ -1362,8 +1362,19 @@ const SPLIT_SCRIPT = `on run(argv)
1362
1362
  end tell
1363
1363
  return "notfound"
1364
1364
  end run`;
1365
- /** Run an AppleScript with argv. Rejects when osascript itself cannot run. */
1366
- function osascript(script, args) {
1365
+ /**
1366
+ * True for the transient "every window doesn't understand the count message"
1367
+ * (-1708) failure iTerm throws while enumerating windows during a race with
1368
+ * window/session churn — seen to succeed on immediate retry. No other error
1369
+ * matches: a retry here only re-runs the enumeration, before any split, so it
1370
+ * cannot double-create a pane.
1371
+ */
1372
+ function isRetryableIterm2Error(stderr) {
1373
+ return stderr.includes("every window doesn") && stderr.includes("(-1708)");
1374
+ }
1375
+ const OSASCRIPT_MAX_ATTEMPTS = 6;
1376
+ const OSASCRIPT_RETRY_DELAY_MS = 500;
1377
+ function runOsascriptOnce(script, args) {
1367
1378
  return new Promise((resolve, reject) => {
1368
1379
  const proc = spawn("osascript", ["-", ...args], { stdio: [
1369
1380
  "pipe",
@@ -1383,6 +1394,15 @@ function osascript(script, args) {
1383
1394
  proc.stdin.end();
1384
1395
  });
1385
1396
  }
1397
+ /** Run an AppleScript with argv. Rejects when osascript itself cannot run. */
1398
+ async function osascript(script, args) {
1399
+ let result = await runOsascriptOnce(script, args);
1400
+ for (let attempt = 1; attempt < OSASCRIPT_MAX_ATTEMPTS && isRetryableIterm2Error(result.stderr); attempt++) {
1401
+ await new Promise((r) => setTimeout(r, OSASCRIPT_RETRY_DELAY_MS));
1402
+ result = await runOsascriptOnce(script, args);
1403
+ }
1404
+ return result;
1405
+ }
1386
1406
  function psOutput(format) {
1387
1407
  try {
1388
1408
  return execFileSync("ps", ["-axo", format], { encoding: "utf8" });
@@ -2750,7 +2770,7 @@ async function runWorker(opts) {
2750
2770
  const logDir = workersLogDir(config);
2751
2771
  mkdirSync(logDir, { recursive: true });
2752
2772
  if (opts.className === "plan" && !opts._planner) {
2753
- const { runPlanner } = await import("./planner-BLbCtBUa.mjs");
2773
+ const { runPlanner } = await import("./planner-D3keWys5.mjs");
2754
2774
  return runPlanner(opts);
2755
2775
  }
2756
2776
  const parent = launchParent(opts.parent);
@@ -3172,7 +3192,12 @@ async function executeRun(a) {
3172
3192
  ...a.capability ? { capability: a.capability } : {},
3173
3193
  ...a.specPath ? { spec: a.specPath } : {}
3174
3194
  });
3175
- if (headless && !noPane && config.pane.enabled && term && process.env.PAI_WORKER_AUTOPANE !== "0") openPaneForWorker(logDir, config, wid, term).catch(() => {});
3195
+ if (headless && !noPane && config.pane.enabled && term && process.env.PAI_WORKER_AUTOPANE !== "0") openPaneForWorker(logDir, config, wid, term).catch((e) => {
3196
+ appendLedger(ledger, "PANE-FAIL", {
3197
+ id: wid,
3198
+ error: (e instanceof Error ? e.message : String(e)).slice(0, 200)
3199
+ });
3200
+ });
3176
3201
  const t0 = Date.now();
3177
3202
  const proc = spawn(cmd[0], cmd.slice(1), {
3178
3203
  env,
@@ -3535,7 +3560,12 @@ async function executeCodexRun(a) {
3535
3560
  id: wid,
3536
3561
  note: `dropped for codex: ${dropped.join(", ")}`
3537
3562
  });
3538
- if (!noPane && config.pane.enabled && term && process.env.PAI_WORKER_AUTOPANE !== "0") openPaneForWorker(logDir, config, wid, term).catch(() => {});
3563
+ if (!noPane && config.pane.enabled && term && process.env.PAI_WORKER_AUTOPANE !== "0") openPaneForWorker(logDir, config, wid, term).catch((e) => {
3564
+ appendLedger(ledger, "PANE-FAIL", {
3565
+ id: wid,
3566
+ error: (e instanceof Error ? e.message : String(e)).slice(0, 200)
3567
+ });
3568
+ });
3539
3569
  const t0 = Date.now();
3540
3570
  const proc = spawn("codex", buildCodexArgs(prompt, parsed.callerModel ? void 0 : model), {
3541
3571
  env,
@@ -3785,4 +3815,4 @@ function resultFromOutput(out) {
3785
3815
 
3786
3816
  //#endregion
3787
3817
  export { contextLabel as A, setWorkerLabel as B, mergeWorker as C, UNLABELED as D, ledgerSummary as E, loadStatuses as F, describeMcp as G, longInlinePromptHint as H, newWorkerId as I, expandMcpNames as K, nowStamp as L, isChatPane as M, isLive as N, ageOf as O, loadStatus as P, ownsPid as R, discardWorker as S, appendLedger as T, parseRunnerArgs as U, waitForTerminalStatus as V, shortText as W, itermUuid as _, projectLaunchConfig as a, sessionTag as b, handoffFromInside as c, workerDepth as d, checkPaneForWorker as f, itermForClaudeSession as g, currentTabKey as h, usageContextTokens as i, contextPercent as j, alive as k, readInbox as l, openPaneForWorker as m, runWorker as n, parseWorkerReport as o, openFollowPane as p, testProvider as r, renderReport as s, printResult as t, sayToWorker as u, resolveSession as v, worktreesDir as w, workerInScope as x, sessionMapPath as y, saveStatus as z };
3788
- //# sourceMappingURL=run-C7EDdVAB.mjs.map
3818
+ //# sourceMappingURL=run-DLG25bzt.mjs.map