@cydm/pie 2.8.1 → 3.0.0

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 (26) hide show
  1. package/dist/builtin/extensions/ask-user/index.js +2 -2
  2. package/dist/builtin/extensions/changelog/index.js +2 -2
  3. package/dist/builtin/extensions/cron/index.js +167 -14
  4. package/dist/builtin/extensions/document-attachments/index.js +1 -1
  5. package/dist/builtin/extensions/herdr-agent-state/index.js +2 -2
  6. package/dist/builtin/extensions/memory/index.js +15 -13
  7. package/dist/builtin/extensions/plan-mode/index.js +2 -2
  8. package/dist/builtin/extensions/subagent/index.js +4 -4
  9. package/dist/builtin/extensions/todo/index.js +2 -2
  10. package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-bridge.js +106 -2
  11. package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-cli.js +1 -0
  12. package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-runtime.js +1 -1
  13. package/dist/builtin/skills/chrome-devtools-axi/{chunk-BNSAEVRT.js → chunk-WOGAQ4P5.js} +2 -2
  14. package/dist/builtin/skills/chrome-devtools-axi/{cli-AO2ZTPRM.js → cli-CHC7XYFU.js} +27 -3
  15. package/dist/builtin/skills/computer-use-axi/computer-use-axi-broker.js +2 -2
  16. package/dist/builtin/skills/computer-use-axi/computer-use-axi-cli.js +1 -0
  17. package/dist/builtin/skills/computer-use-axi/scripts/setup-helper.mjs +6 -2
  18. package/dist/builtin/skills/tui-use/tui-use-daemon.cjs +130 -9
  19. package/dist/chunks/{chunk-RSL7E4R7.js → chunk-3FRKOFSP.js} +34 -1
  20. package/dist/chunks/{chunk-PK72LVWQ.js → chunk-7FEPQHYX.js} +1 -1
  21. package/dist/chunks/{chunk-GDIYSMTS.js → chunk-BUDXV3TR.js} +24 -16
  22. package/dist/chunks/{chunk-3NHP7HK5.js → chunk-OEQYEYB3.js} +4 -3
  23. package/dist/chunks/{src-BPSQMSSC.js → src-AE3OCAE6.js} +2 -2
  24. package/dist/chunks/{src-OPPYTPWG.js → src-RVTDUSPJ.js} +9 -1
  25. package/dist/cli.js +495 -85
  26. package/package.json +4 -4
@@ -12,6 +12,7 @@ import {
12
12
  needsPageId,
13
13
  overlaySessionSelected,
14
14
  parsePagesList,
15
+ readSelfStartTime,
15
16
  rememberToolRouting,
16
17
  resolveBridgeScript,
17
18
  resolveSessionName,
@@ -19,7 +20,7 @@ import {
19
20
  resolveSessionPort,
20
21
  resolveSessionStateDir,
21
22
  setSelectedPageId
22
- } from "./chunk-BNSAEVRT.js";
23
+ } from "./chunk-WOGAQ4P5.js";
23
24
  import "./chunk-OJ6N23UZ.js";
24
25
 
25
26
  // ../../node_modules/chrome-devtools-axi/node_modules/@toon-format/toon/dist/index.mjs
@@ -1661,10 +1662,31 @@ function isProcessAlive(pid) {
1661
1662
  return error?.code !== "ESRCH";
1662
1663
  }
1663
1664
  }
1665
+ var cachedLauncherHeader;
1666
+ function launcherHeader() {
1667
+ cachedLauncherHeader ??= (() => {
1668
+ const pid = process.env.PIE_SUPERVISOR_PID?.trim();
1669
+ if (pid && Number.isInteger(Number(pid)) && Number(pid) > 0) {
1670
+ const startTime = process.env.PIE_SUPERVISOR_START_TIME?.trim() ?? "";
1671
+ return `${pid}:${startTime}`;
1672
+ }
1673
+ return `${process.pid}:${readSelfStartTime() ?? ""}`;
1674
+ })();
1675
+ return cachedLauncherHeader;
1676
+ }
1664
1677
  function httpGet(port, path, timeoutMs = 2e3) {
1665
1678
  return new Promise((resolve3, reject) => {
1666
1679
  const req = request(
1667
- { hostname: "127.0.0.1", port, path, method: "GET", timeout: timeoutMs },
1680
+ {
1681
+ hostname: "127.0.0.1",
1682
+ port,
1683
+ path,
1684
+ method: "GET",
1685
+ timeout: timeoutMs,
1686
+ // Identify this launcher to the bridge so it can supervise our
1687
+ // liveness and reap its detached tree when we die (leak fix).
1688
+ headers: { "x-axi-launcher": launcherHeader() }
1689
+ },
1668
1690
  (res) => {
1669
1691
  res.setEncoding("utf8");
1670
1692
  let data = "";
@@ -1829,7 +1851,7 @@ function isBridgeProcess(pid, expectedStartTime) {
1829
1851
  "-Command",
1830
1852
  `(Get-CimInstance Win32_Process -Filter "ProcessId=${pid}").CommandLine`
1831
1853
  ],
1832
- { encoding: "utf-8", timeout: 4e3 }
1854
+ { encoding: "utf-8", timeout: 4e3, windowsHide: true }
1833
1855
  );
1834
1856
  if (!commandLineLooksLikeBridge(command)) return false;
1835
1857
  } catch {
@@ -1905,6 +1927,7 @@ function taskkillTree(pid) {
1905
1927
  try {
1906
1928
  execFileSync("taskkill", ["/PID", String(pid), "/T", "/F"], {
1907
1929
  stdio: "ignore",
1930
+ windowsHide: true,
1908
1931
  timeout: 1e4
1909
1932
  });
1910
1933
  return true;
@@ -1964,6 +1987,7 @@ function spawnBridgeProcess(port, sessionName) {
1964
1987
  runner === "tsx" ? ["tsx", script] : [script],
1965
1988
  {
1966
1989
  stdio: "ignore",
1990
+ windowsHide: true,
1967
1991
  env: {
1968
1992
  ...process.env,
1969
1993
  CHROME_DEVTOOLS_AXI_PORT: String(port),
@@ -7573,7 +7573,7 @@ async function runProcess3(command, args, timeoutMs, signal, env) {
7573
7573
  if (signal?.aborted) throw new Error("Operation aborted.");
7574
7574
  await new Promise((resolve2, reject) => {
7575
7575
  assertNativeBackendAllowed();
7576
- const child = spawn3(command, args, { stdio: ["ignore", "pipe", "pipe"], env });
7576
+ const child = spawn3(command, args, { stdio: ["ignore", "pipe", "pipe"], env, windowsHide: true });
7577
7577
  let stdout = "";
7578
7578
  let stderr = "";
7579
7579
  const cleanup = () => {
@@ -7643,7 +7643,7 @@ var WindowsHelperClient = class {
7643
7643
  await this.ensureInstalled(signal);
7644
7644
  if (this.child && this.child.exitCode === null && !this.child.killed) return this.child;
7645
7645
  assertNativeBackendAllowed();
7646
- const child = spawn3(WINDOWS_HELPER_PATH, [], { stdio: ["pipe", "pipe", "pipe"] });
7646
+ const child = spawn3(WINDOWS_HELPER_PATH, [], { stdio: ["pipe", "pipe", "pipe"], windowsHide: true });
7647
7647
  child.stdout.setEncoding("utf8");
7648
7648
  child.stderr.setEncoding("utf8");
7649
7649
  child.stdin.setDefaultEncoding("utf8");
@@ -27,6 +27,7 @@ export function resolveComputerUseAxiCli() {
27
27
  function main() {
28
28
  const runtime = resolveComputerUseAxiCli();
29
29
  const result = spawnSync(process.execPath, [runtime, ...process.argv.slice(2)], {
30
+ windowsHide: true,
30
31
  stdio: "inherit",
31
32
  shell: false,
32
33
  env: process.env,
@@ -123,7 +123,11 @@ async function copyIfChanged(sourcePath, destinationPath) {
123
123
 
124
124
  async function run(command, commandArgs) {
125
125
  await new Promise((resolve, reject) => {
126
- const child = spawn(command, commandArgs, { stdio: "inherit" });
126
+ // windowsHide: console-less hosts (Node spawning this script on Windows,
127
+ // e.g. the helper auto-install path) must not flash conhost windows at
128
+ // the user; when run interactively from a real terminal the flag is a
129
+ // no-op (the child still inherits stdio below).
130
+ const child = spawn(command, commandArgs, { stdio: "inherit", windowsHide: true });
127
131
  child.on("error", reject);
128
132
  child.on("close", (code) => {
129
133
  if (code === 0) {
@@ -140,7 +144,7 @@ function moduleCachePath(arch) {
140
144
  }
141
145
 
142
146
  async function commandOutput(command, commandArgs) {
143
- const { stdout } = await execFile(command, commandArgs, { encoding: "utf8" });
147
+ const { stdout } = await execFile(command, commandArgs, { encoding: "utf8", windowsHide: true });
144
148
  return stdout;
145
149
  }
146
150
 
@@ -7476,10 +7476,20 @@ Supported keys: ${supported}`
7476
7476
  async killProcess() {
7477
7477
  if (this._status === "running") {
7478
7478
  this.ptyProcess.kill();
7479
- const deadline = Date.now() + 3e3;
7479
+ let deadline = Date.now() + 1e3;
7480
7480
  while (this._status === "running" && Date.now() < deadline) {
7481
7481
  await new Promise((resolve) => setTimeout(resolve, 25));
7482
7482
  }
7483
+ if (this._status === "running") {
7484
+ try {
7485
+ this.ptyProcess.kill("SIGKILL");
7486
+ } catch {
7487
+ }
7488
+ deadline = Date.now() + 2e3;
7489
+ while (this._status === "running" && Date.now() < deadline) {
7490
+ await new Promise((resolve) => setTimeout(resolve, 25));
7491
+ }
7492
+ }
7483
7493
  if (this._status === "running") {
7484
7494
  throw new Error(`Session ${this.id} did not exit after kill.`);
7485
7495
  }
@@ -7674,6 +7684,59 @@ var PID_PATH = import_node_path3.default.join(STATE_DIR, "daemon.pid");
7674
7684
  var LOCK_PATH = import_node_path3.default.join(STATE_DIR, "startup.lock");
7675
7685
  var SOCKET_PATH = process.platform === "win32" ? `\\\\.\\pipe\\pie-tui-${(0, import_node_crypto.createHash)("sha256").update(STATE_DIR.toLowerCase()).digest("hex").slice(0, 24)}` : import_node_path3.default.join(STATE_DIR, "daemon.sock");
7676
7686
 
7687
+ // vendor/tui-use/src/supervisor-anchor-shared.ts
7688
+ var SUPERVISOR_PID_ENV = "PIE_SUPERVISOR_PID";
7689
+ var SUPERVISOR_START_TIME_ENV = "PIE_SUPERVISOR_START_TIME";
7690
+ function parseSupervisorAnchor(env = process.env) {
7691
+ const pidText = env[SUPERVISOR_PID_ENV]?.trim();
7692
+ if (!pidText || !/^\d+$/.test(pidText)) return void 0;
7693
+ const pid = Number(pidText);
7694
+ if (!Number.isSafeInteger(pid) || pid <= 0) return void 0;
7695
+ const startTime = env[SUPERVISOR_START_TIME_ENV]?.trim();
7696
+ return startTime ? { pid, startTime } : { pid };
7697
+ }
7698
+ function readStartTime(pid) {
7699
+ if (!Number.isInteger(pid) || pid <= 0) return void 0;
7700
+ if (process.platform === "win32") {
7701
+ try {
7702
+ const { execFileSync } = require("node:child_process");
7703
+ return execFileSync(
7704
+ "powershell",
7705
+ [
7706
+ "-NoProfile",
7707
+ "-NonInteractive",
7708
+ "-Command",
7709
+ `$p = Get-CimInstance Win32_Process -Filter "ProcessId=${pid}"; if ($p) { $p.CreationDate.ToString('o') }`
7710
+ ],
7711
+ { timeout: 5e3, encoding: "utf8", windowsHide: true }
7712
+ ).trim() || void 0;
7713
+ } catch {
7714
+ return void 0;
7715
+ }
7716
+ }
7717
+ try {
7718
+ const { execFileSync } = require("node:child_process");
7719
+ return execFileSync("ps", ["-p", String(pid), "-o", "lstart="], {
7720
+ timeout: 5e3,
7721
+ env: { ...process.env, LC_ALL: "C", LANG: "C", TZ: "UTC0" },
7722
+ encoding: "utf8"
7723
+ }).trim() || void 0;
7724
+ } catch {
7725
+ return void 0;
7726
+ }
7727
+ }
7728
+ function isSupervisorGone(anchor) {
7729
+ try {
7730
+ process.kill(anchor.pid, 0);
7731
+ } catch (error) {
7732
+ return error.code === "ESRCH";
7733
+ }
7734
+ const identity = { startTime: readStartTime(anchor.pid) };
7735
+ if (identity.startTime === void 0) return false;
7736
+ if (anchor.startTime === void 0) return false;
7737
+ return identity.startTime !== anchor.startTime;
7738
+ }
7739
+
7677
7740
  // vendor/tui-use/package.json
7678
7741
  var version = "0.1.18-pie.3";
7679
7742
 
@@ -7681,6 +7744,9 @@ var version = "0.1.18-pie.3";
7681
7744
  var sessions = /* @__PURE__ */ new Map();
7682
7745
  var exitedAt = /* @__PURE__ */ new Map();
7683
7746
  var busy = /* @__PURE__ */ new Map();
7747
+ var sessionAnchors = /* @__PURE__ */ new Map();
7748
+ var lastSessionActivity = /* @__PURE__ */ new Map();
7749
+ var SESSION_MAX_IDLE_AGE_MS = 12 * 60 * 60 * 1e3;
7684
7750
  var instanceId = (0, import_node_crypto2.randomUUID)();
7685
7751
  var idleSetting = Number(process.env.PIE_TUI_USE_IDLE_TIMEOUT_MS);
7686
7752
  var idleTimeout = Number.isInteger(idleSetting) && idleSetting >= 100 && idleSetting <= 3e5 ? idleSetting : 3e5;
@@ -7694,9 +7760,53 @@ function pruneExited() {
7694
7760
  sessions.get(id)?.dispose();
7695
7761
  sessions.delete(id);
7696
7762
  exitedAt.delete(id);
7763
+ sessionAnchors.delete(id);
7764
+ lastSessionActivity.delete(id);
7697
7765
  if (currentSession === id) currentSession = null;
7698
7766
  }
7699
7767
  }
7768
+ function reapOrphanedSessions() {
7769
+ if (shuttingDown) return;
7770
+ for (const id of [...sessionAnchors.keys()]) {
7771
+ if (!sessions.has(id)) sessionAnchors.delete(id);
7772
+ }
7773
+ for (const [id, anchor] of sessionAnchors) {
7774
+ if (!anchor || busy.get(id)) continue;
7775
+ const session = sessions.get(id);
7776
+ if (!session || session.status !== "running") continue;
7777
+ if (!isSupervisorGone(anchor)) continue;
7778
+ try {
7779
+ import_node_fs2.default.appendFileSync(LOG_PATH, `[reap] session ${id} creator pid ${anchor.pid} is gone; killing PTY tree
7780
+ `);
7781
+ } catch {
7782
+ }
7783
+ void session.kill().then(() => {
7784
+ exitedAt.set(id, Date.now());
7785
+ sessionAnchors.delete(id);
7786
+ pruneExited();
7787
+ updateIdleTimer();
7788
+ }).catch(() => {
7789
+ });
7790
+ }
7791
+ for (const [id, session] of sessions) {
7792
+ if (busy.get(id) || session.status !== "running") continue;
7793
+ const anchor = sessionAnchors.get(id);
7794
+ if (anchor && !isSupervisorGone(anchor)) continue;
7795
+ const last = lastSessionActivity.get(id) ?? session.startTime;
7796
+ if (Date.now() - last < SESSION_MAX_IDLE_AGE_MS) continue;
7797
+ try {
7798
+ import_node_fs2.default.appendFileSync(LOG_PATH, `[reap] session ${id} exceeded max idle age (${Math.round((Date.now() - last) / 6e4)}min, no live anchor); killing PTY tree
7799
+ `);
7800
+ } catch {
7801
+ }
7802
+ void session.kill().then(() => {
7803
+ exitedAt.set(id, Date.now());
7804
+ pruneExited();
7805
+ updateIdleTimer();
7806
+ }).catch(() => {
7807
+ });
7808
+ }
7809
+ }
7700
7810
  function updateIdleTimer() {
7701
7811
  clearTimeout(idleTimer);
7702
7812
  if (shuttingDown || [...sessions.values()].some((session) => session.status === "running") || busy.size) return;
@@ -7705,6 +7815,8 @@ function updateIdleTimer() {
7705
7815
  }, idleTimeout);
7706
7816
  idleTimer.unref();
7707
7817
  }
7818
+ var reapTimer = setInterval(() => reapOrphanedSessions(), 3e4);
7819
+ reapTimer.unref?.();
7708
7820
  async function shutdown() {
7709
7821
  if (shuttingDown) throw new Error("Daemon is already stopping.");
7710
7822
  shuttingDown = true;
@@ -7734,14 +7846,22 @@ async function handleRequest(req, signal) {
7734
7846
  do {
7735
7847
  id2 = (0, import_node_crypto2.randomUUID)();
7736
7848
  } while (sessions.has(id2));
7737
- const session2 = new Session(id2, req.command, {
7738
- ...req,
7739
- onExit: () => {
7740
- exitedAt.set(id2, Date.now());
7741
- pruneExited();
7742
- updateIdleTimer();
7743
- }
7744
- });
7849
+ sessionAnchors.set(id2, parseSupervisorAnchor(req.env ?? process.env));
7850
+ let session2;
7851
+ try {
7852
+ session2 = new Session(id2, req.command, {
7853
+ ...req,
7854
+ onExit: () => {
7855
+ exitedAt.set(id2, Date.now());
7856
+ sessionAnchors.delete(id2);
7857
+ pruneExited();
7858
+ updateIdleTimer();
7859
+ }
7860
+ });
7861
+ } catch (error) {
7862
+ sessionAnchors.delete(id2);
7863
+ throw error;
7864
+ }
7745
7865
  sessions.set(id2, session2);
7746
7866
  currentSession = id2;
7747
7867
  updateIdleTimer();
@@ -7765,6 +7885,7 @@ async function handleRequest(req, signal) {
7765
7885
  const session = sessions.get(id);
7766
7886
  if (!session) throw new Error(`Session not found: ${id}`);
7767
7887
  busy.set(id, (busy.get(id) ?? 0) + 1);
7888
+ lastSessionActivity.set(id, Date.now());
7768
7889
  updateIdleTimer();
7769
7890
  try {
7770
7891
  switch (req.type) {
@@ -9492,6 +9492,35 @@ function observeDelegationTool(observation, event) {
9492
9492
  if (observation.receipts.length > 32) observation.receipts.shift();
9493
9493
  }
9494
9494
 
9495
+ // ../../packages/agent-framework/src/supervisor-anchor.ts
9496
+ var SUPERVISOR_PID_ENV = "PIE_SUPERVISOR_PID";
9497
+ var SUPERVISOR_START_TIME_ENV = "PIE_SUPERVISOR_START_TIME";
9498
+ function parseSupervisorAnchor(env = process.env) {
9499
+ const pidText = env[SUPERVISOR_PID_ENV]?.trim();
9500
+ if (!pidText || !/^\d+$/.test(pidText)) return void 0;
9501
+ const pid = Number(pidText);
9502
+ if (!Number.isSafeInteger(pid) || pid <= 0) return void 0;
9503
+ const startTime = env[SUPERVISOR_START_TIME_ENV]?.trim();
9504
+ return startTime ? { pid, startTime } : { pid };
9505
+ }
9506
+ function isSupervisorGone(anchor, readIdentity) {
9507
+ try {
9508
+ process.kill(anchor.pid, 0);
9509
+ } catch (error) {
9510
+ return error.code === "ESRCH";
9511
+ }
9512
+ if (!readIdentity) return false;
9513
+ let identity;
9514
+ try {
9515
+ identity = readIdentity(anchor.pid);
9516
+ } catch {
9517
+ return false;
9518
+ }
9519
+ if (identity.startTime === void 0) return false;
9520
+ if (anchor.startTime === void 0) return false;
9521
+ return identity.startTime !== anchor.startTime;
9522
+ }
9523
+
9495
9524
  export {
9496
9525
  parseSkillFile,
9497
9526
  createSkill,
@@ -9630,5 +9659,9 @@ export {
9630
9659
  parseDelegationReport,
9631
9660
  observeDelegationPhase,
9632
9661
  createDelegationObservation,
9633
- observeDelegationTool
9662
+ observeDelegationTool,
9663
+ SUPERVISOR_PID_ENV,
9664
+ SUPERVISOR_START_TIME_ENV,
9665
+ parseSupervisorAnchor,
9666
+ isSupervisorGone
9634
9667
  };
@@ -13,7 +13,7 @@ import {
13
13
  parseEntryIdSeq,
14
14
  readAncestryPage,
15
15
  requestInteraction
16
- } from "./chunk-RSL7E4R7.js";
16
+ } from "./chunk-3FRKOFSP.js";
17
17
  import {
18
18
  Agent,
19
19
  getToolCallerIdentity
@@ -10,10 +10,10 @@ import {
10
10
  createSharedWebSearchTool,
11
11
  defaultShellKindForPlatform,
12
12
  interpretShellExit
13
- } from "./chunk-PK72LVWQ.js";
13
+ } from "./chunk-7FEPQHYX.js";
14
14
  import {
15
15
  requestInteraction
16
- } from "./chunk-RSL7E4R7.js";
16
+ } from "./chunk-3FRKOFSP.js";
17
17
  import {
18
18
  EMPTY_ASSISTANT_CONTENT_ERROR,
19
19
  OPENAI_COMPAT_PROTOCOL_ERROR_CODE,
@@ -589,8 +589,8 @@ function buildBashSchema(commandDescription) {
589
589
  timeout: Type.Optional(
590
590
  Type.Number({
591
591
  exclusiveMinimum: 0,
592
- maximum: 2147483,
593
- description: "Timeout in seconds. Default: 120s (2 minutes). The requested value is honored as-is for every command; set it to what the task needs (installs, builds, and tests often need more)."
592
+ maximum: 2147483e3,
593
+ description: "Timeout in MILLISECONDS (not seconds). Default: 120000 (2 minutes). Examples: 30000 = 30s, 300000 = 5 minutes."
594
594
  })
595
595
  ),
596
596
  cwd: Type.Optional(Type.String({ description: "Working directory for the command" })),
@@ -603,18 +603,25 @@ function buildBashSchema(commandDescription) {
603
603
  });
604
604
  }
605
605
  var DEFAULT_TIMEOUT_SECONDS = 120;
606
- var OUTPUT_DRAIN_TIMEOUT_MS = 1e3;
607
- var MAX_SHELL_EXIT_DRAIN_MS = 1e4;
608
- function resolveTimeoutPolicy(requestedTimeout) {
609
- const requestedSeconds = requestedTimeout ?? DEFAULT_TIMEOUT_SECONDS;
610
- if (!Number.isFinite(requestedSeconds) || requestedSeconds <= 0 || requestedSeconds > 2147483) {
611
- throw new Error("Invalid shell timeout: use a finite positive number of seconds within the supported timer range (2147483s).");
606
+ var TIMEOUT_MAX_MS = 2147483e3;
607
+ function resolveTimeoutPolicy(requestedTimeoutMs) {
608
+ if (requestedTimeoutMs === void 0) {
609
+ return { requestedSeconds: DEFAULT_TIMEOUT_SECONDS, effectiveSeconds: DEFAULT_TIMEOUT_SECONDS };
610
+ }
611
+ if (!Number.isFinite(requestedTimeoutMs) || requestedTimeoutMs <= 0) {
612
+ throw new Error("Invalid shell timeout: pass a positive number of milliseconds (e.g. 120000 for two minutes).");
612
613
  }
614
+ if (requestedTimeoutMs > TIMEOUT_MAX_MS) {
615
+ throw new Error(`Shell timeout ${requestedTimeoutMs}ms exceeds the supported timer range (2147483000ms \u2248 24.8 days).`);
616
+ }
617
+ const seconds = requestedTimeoutMs / 1e3;
613
618
  return {
614
- requestedSeconds,
615
- effectiveSeconds: requestedSeconds
619
+ requestedSeconds: seconds,
620
+ effectiveSeconds: seconds
616
621
  };
617
622
  }
623
+ var OUTPUT_DRAIN_TIMEOUT_MS = 1e3;
624
+ var MAX_SHELL_EXIT_DRAIN_MS = 1e4;
618
625
  function validateBashCommand(command) {
619
626
  const value = typeof command === "string" ? command : "";
620
627
  const trimmed = value.trim();
@@ -652,7 +659,7 @@ function buildBashDescription(contract) {
652
659
  return [
653
660
  "Execute a shell command in the current working directory.",
654
661
  contract.dialectBlock,
655
- `Returns stdout and stderr as a bounded head/tail preview of at most ${DEFAULT_MAX_LINES} lines or ${DEFAULT_MAX_BYTES / 1024}KB. If truncated, the result includes a private full-output artifact path. Default timeout: 120s. The timeout parameter is the budget: pass a larger value when a task legitimately needs it, and keep long waits focused rather than polling loops.`
662
+ `Returns stdout and stderr as a bounded head/tail preview of at most ${DEFAULT_MAX_LINES} lines or ${DEFAULT_MAX_BYTES / 1024}KB. If truncated, the result includes a private full-output artifact path. Default timeout: 120000ms (2 minutes). The timeout parameter is in milliseconds and is the budget: pass a larger value when a task legitimately needs it, and keep long waits focused rather than polling loops.`
656
663
  ].join(" ");
657
664
  }
658
665
  function buildSpawnCommand(shell, command) {
@@ -1041,7 +1048,7 @@ function createBashTool(defaultCwd, options) {
1041
1048
  });
1042
1049
  }
1043
1050
  const timeoutPolicy = resolveTimeoutPolicy(timeout);
1044
- const timeoutMs = timeoutPolicy.effectiveSeconds * 1e3;
1051
+ const timeoutMs = timeout ?? DEFAULT_TIMEOUT_SECONDS * 1e3;
1045
1052
  return new Promise((resolve2, reject) => {
1046
1053
  if (signal?.aborted) {
1047
1054
  reject(new Error("Operation aborted"));
@@ -1342,7 +1349,7 @@ ${commandNonzeroHint}`;
1342
1349
  outputText += `
1343
1350
 
1344
1351
  [Command timed out after ${timeoutPolicy.effectiveSeconds} seconds]`;
1345
- outputText += "\n[Timeout hint: the command ran longer than its requested budget. Inspect partial results/logs, then either raise the timeout to what the task needs or split long waits into smaller focused steps. Avoid repeating identical long waits.]";
1352
+ outputText += "\n[Timeout hint: the command ran longer than its requested budget. Inspect partial results/logs, then either raise the timeout (milliseconds) to what the task needs or split long waits into smaller focused steps. Avoid repeating identical long waits.]";
1346
1353
  }
1347
1354
  if (stdioIncomplete && !timedOut) {
1348
1355
  outputText += "\n\n[Output capture ended after the command exited because a descendant kept stdio open or the output artifact was still draining (bounded wait). Captured output may be incomplete.]";
@@ -1411,7 +1418,8 @@ function runAxi(args, options = {}) {
1411
1418
  stdio: ["ignore", "pipe", "pipe"],
1412
1419
  shell: false,
1413
1420
  env: options.env,
1414
- cwd: options.cwd
1421
+ cwd: options.cwd,
1422
+ windowsHide: true
1415
1423
  });
1416
1424
  let stdout = "";
1417
1425
  let stderr = "";
@@ -42,6 +42,7 @@ function spawnDistillCli(memoryRoot, modeArgs) {
42
42
  out = fs.openSync(logPath, "a");
43
43
  const child = spawn(process.execPath, args, {
44
44
  detached: true,
45
+ windowsHide: true,
45
46
  stdio: ["ignore", out, out],
46
47
  env: { ...process.env, PIE_MEMORY_WORKER: "1" }
47
48
  });
@@ -173,8 +174,8 @@ async function runDistillWorkerMain(memoryRoot, date, noExit = false) {
173
174
  const { ModelRegistry } = await import("./model-registry-LI5THXV4.js");
174
175
  const { AuthStorage } = await import("./auth-storage-3EGM3VTK.js");
175
176
  const { getSessionsDir } = await import("./config-74AUVDLT.js");
176
- const { FileSessionStore } = await import("./src-OPPYTPWG.js");
177
- const { MemoryStore, runDistillation } = await import("./src-BPSQMSSC.js");
177
+ const { FileSessionStore } = await import("./src-RVTDUSPJ.js");
178
+ const { MemoryStore, runDistillation } = await import("./src-AE3OCAE6.js");
178
179
  const store = new MemoryStore(memoryRoot);
179
180
  ledger = store;
180
181
  const registry = new ModelRegistry(AuthStorage.create());
@@ -251,7 +252,7 @@ async function runDistillAuto(memoryRoot, days = 7) {
251
252
  } catch {
252
253
  }
253
254
  };
254
- const { MemoryStore, todayKey } = await import("./src-BPSQMSSC.js");
255
+ const { MemoryStore, todayKey } = await import("./src-AE3OCAE6.js");
255
256
  const store = new MemoryStore(memoryRoot);
256
257
  const today = todayKey(Date.now());
257
258
  const dates = [];
@@ -209,8 +209,8 @@ import {
209
209
  understandFileWithModel,
210
210
  validateTodos,
211
211
  writeJournalNarrative
212
- } from "./chunk-PK72LVWQ.js";
213
- import "./chunk-RSL7E4R7.js";
212
+ } from "./chunk-7FEPQHYX.js";
213
+ import "./chunk-3FRKOFSP.js";
214
214
  import "./chunk-GH4VW2OT.js";
215
215
  import {
216
216
  hashText
@@ -17,6 +17,8 @@ import {
17
17
  ReplayStallCircuit,
18
18
  RuntimeExtensionRegistry,
19
19
  SUMMARY_PREFIX,
20
+ SUPERVISOR_PID_ENV,
21
+ SUPERVISOR_START_TIME_ENV,
20
22
  SessionManager,
21
23
  SessionTraceController,
22
24
  SessionTraceSnapshotWriter,
@@ -107,6 +109,7 @@ import {
107
109
  isExtensionEnabled,
108
110
  isExtensionEnabledByManifest,
109
111
  isHostContextBlock,
112
+ isSupervisorGone,
110
113
  isToolAvailable,
111
114
  leadingHostContextBlock,
112
115
  loadExtension,
@@ -121,6 +124,7 @@ import {
121
124
  parseEntryIdSeq,
122
125
  parseSkill,
123
126
  parseSkillFile,
127
+ parseSupervisorAnchor,
124
128
  planRetainedTail,
125
129
  prepareSessionCompaction,
126
130
  projectHostContextBlock,
@@ -138,7 +142,7 @@ import {
138
142
  substituteArgs,
139
143
  validateRetainedTailEntries,
140
144
  verifyPreparedCompactionCommit
141
- } from "./chunk-RSL7E4R7.js";
145
+ } from "./chunk-3FRKOFSP.js";
142
146
  import "./chunk-GH4VW2OT.js";
143
147
  import "./chunk-3BC5KGDQ.js";
144
148
  import "./chunk-XXGYUYXI.js";
@@ -161,6 +165,8 @@ export {
161
165
  ReplayStallCircuit,
162
166
  RuntimeExtensionRegistry,
163
167
  SUMMARY_PREFIX,
168
+ SUPERVISOR_PID_ENV,
169
+ SUPERVISOR_START_TIME_ENV,
164
170
  SessionManager,
165
171
  SessionTraceController,
166
172
  SessionTraceSnapshotWriter,
@@ -251,6 +257,7 @@ export {
251
257
  isExtensionEnabled,
252
258
  isExtensionEnabledByManifest,
253
259
  isHostContextBlock,
260
+ isSupervisorGone,
254
261
  isToolAvailable,
255
262
  leadingHostContextBlock,
256
263
  loadExtension,
@@ -265,6 +272,7 @@ export {
265
272
  parseEntryIdSeq,
266
273
  parseSkill,
267
274
  parseSkillFile,
275
+ parseSupervisorAnchor,
268
276
  planRetainedTail,
269
277
  prepareSessionCompaction,
270
278
  projectHostContextBlock,