@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
package/dist/cli.js CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  runDistillWorkerMain,
11
11
  spawnDistillAutoWorker,
12
12
  spawnDistillWorker
13
- } from "./chunks/chunk-3NHP7HK5.js";
13
+ } from "./chunks/chunk-OEQYEYB3.js";
14
14
  import {
15
15
  CLI_RETRY_MAX_RETRIES,
16
16
  classifyCliFailure,
@@ -27,7 +27,7 @@ import {
27
27
  logTransportLifecycle,
28
28
  setYoloGrantListener,
29
29
  truncateHeadTail
30
- } from "./chunks/chunk-GDIYSMTS.js";
30
+ } from "./chunks/chunk-BUDXV3TR.js";
31
31
  import {
32
32
  AuthStorage,
33
33
  FileAuthStorageBackend
@@ -76,7 +76,7 @@ import {
76
76
  shouldPreserveExecutionStateForUserText,
77
77
  supersedeExecutionState,
78
78
  todayKey
79
- } from "./chunks/chunk-PK72LVWQ.js";
79
+ } from "./chunks/chunk-7FEPQHYX.js";
80
80
  import {
81
81
  AGENTS_CONTEXT_FILE_NAME,
82
82
  AgentSessionController,
@@ -84,6 +84,8 @@ import {
84
84
  DEFAULT_COMPACTION_CONFIG,
85
85
  ExtensionResourceScope,
86
86
  FileSessionStore,
87
+ SUPERVISOR_PID_ENV,
88
+ SUPERVISOR_START_TIME_ENV,
87
89
  SessionTraceSnapshotWriter,
88
90
  attachAgentEventsToSessionTrace,
89
91
  buildProjectContextSection,
@@ -114,7 +116,7 @@ import {
114
116
  setEnablementInMap,
115
117
  setExtensionEnabledInSettings,
116
118
  verifyPreparedCompactionCommit
117
- } from "./chunks/chunk-RSL7E4R7.js";
119
+ } from "./chunks/chunk-3FRKOFSP.js";
118
120
  import "./chunks/chunk-GH4VW2OT.js";
119
121
  import {
120
122
  Deref,
@@ -52147,7 +52149,7 @@ function commandVersion(command, args = ["--version"]) {
52147
52149
  function checkShell() {
52148
52150
  const shell = process.platform === "win32" ? process.env.ComSpec || "cmd.exe" : process.env.SHELL || "/bin/sh";
52149
52151
  const args = process.platform === "win32" ? ["/d", "/s", "/c", "exit 0"] : ["-lc", "exit 0"];
52150
- const result = spawnSync(shell, args, { encoding: "utf8", shell: false });
52152
+ const result = spawnSync(shell, args, { encoding: "utf8", shell: false, windowsHide: true });
52151
52153
  const ok = (result.status ?? 1) === 0;
52152
52154
  return {
52153
52155
  id: "shell",
@@ -52231,7 +52233,7 @@ function checkChromeDevtoolsAxiCli() {
52231
52233
  message: "chrome-devtools-axi is not resolvable from Pie's runtime dependencies."
52232
52234
  };
52233
52235
  }
52234
- const result = spawnSync(process.execPath, [cliPath, "--version"], { encoding: "utf8", shell: false });
52236
+ const result = spawnSync(process.execPath, [cliPath, "--version"], { encoding: "utf8", shell: false, windowsHide: true });
52235
52237
  const ok = (result.status ?? 1) === 0;
52236
52238
  return {
52237
52239
  id: "chrome_devtools_axi",
@@ -53949,7 +53951,8 @@ async function performResumeRestart(decision, onSpawnFailure) {
53949
53951
  const child = spawn(process.execPath, [...process.execArgv, process.argv[1] ?? ".", ...decision.childArgv], {
53950
53952
  cwd: decision.targetCwd,
53951
53953
  stdio: "inherit",
53952
- env: buildChildEnv(decision.childEnv)
53954
+ env: buildChildEnv(decision.childEnv),
53955
+ windowsHide: true
53953
53956
  });
53954
53957
  child.on("spawn", () => announce());
53955
53958
  child.on("error", (error) => {
@@ -61811,7 +61814,7 @@ var Markdown = class {
61811
61814
  break;
61812
61815
  }
61813
61816
  case "list": {
61814
- const listLines = this.renderList(token, 0);
61817
+ const listLines = this.renderList(token, 0, void 0, width);
61815
61818
  appendLines(lines, listLines);
61816
61819
  break;
61817
61820
  }
@@ -61821,20 +61824,7 @@ var Markdown = class {
61821
61824
  break;
61822
61825
  }
61823
61826
  case "blockquote": {
61824
- const quoteStyle = (text) => this.theme.quote(this.theme.italic(text));
61825
- const quoteStyleContext = {
61826
- applyText: quoteStyle,
61827
- stylePrefix: this.getStylePrefix(quoteStyle)
61828
- };
61829
- const quoteText = this.renderInlineTokens(token.tokens || [], quoteStyleContext);
61830
- const quoteLines = quoteText.split("\n");
61831
- const quoteContentWidth = Math.max(1, width - 2);
61832
- for (const quoteLine of quoteLines) {
61833
- const wrappedLines = wrapTextWithAnsi(quoteLine, quoteContentWidth);
61834
- for (const wrappedLine of wrappedLines) {
61835
- lines.push(this.theme.quoteBorder("\u2502 ") + wrappedLine);
61836
- }
61837
- }
61827
+ appendLines(lines, this.renderBlockquote(token, width, void 0));
61838
61828
  if (nextTokenType !== "space") {
61839
61829
  lines.push("");
61840
61830
  }
@@ -61861,6 +61851,121 @@ var Markdown = class {
61861
61851
  }
61862
61852
  return lines;
61863
61853
  }
61854
+ /**
61855
+ * Render a blockquote token to bordered, wrapped lines.
61856
+ * Used both at top level and inside list items.
61857
+ */
61858
+ renderBlockquote(token, width, styleContext) {
61859
+ const lines = [];
61860
+ const quoteStyle = (text) => this.theme.quote(this.theme.italic(text));
61861
+ const quoteStyleContext = styleContext ?? {
61862
+ applyText: quoteStyle,
61863
+ stylePrefix: this.getStylePrefix(quoteStyle)
61864
+ };
61865
+ const quoteContentWidth = Math.max(1, width - 2);
61866
+ const innerTokens = token.tokens || [];
61867
+ const quoteTextLines = [];
61868
+ for (let i = 0; i < innerTokens.length; i++) {
61869
+ this.renderQuoteInnerToken(
61870
+ innerTokens[i],
61871
+ innerTokens[i + 1]?.type,
61872
+ quoteStyleContext,
61873
+ quoteContentWidth,
61874
+ quoteTextLines
61875
+ );
61876
+ }
61877
+ for (const quoteLine of quoteTextLines) {
61878
+ if (quoteLine === "") {
61879
+ lines.push(this.theme.quoteBorder("\u2502 "));
61880
+ continue;
61881
+ }
61882
+ const wrappedLines = wrapTextWithAnsi(quoteLine, quoteContentWidth);
61883
+ for (const wrappedLine of wrappedLines) {
61884
+ lines.push(this.theme.quoteBorder("\u2502 ") + wrappedLine);
61885
+ }
61886
+ }
61887
+ return lines;
61888
+ }
61889
+ /**
61890
+ * Render a block-level token inside a blockquote.
61891
+ * Produces UNWRAPPED, UNBORDERED lines; the caller adds wrapping + border.
61892
+ */
61893
+ renderQuoteInnerToken(token, nextTokenType, styleContext, width, target) {
61894
+ switch (token.type) {
61895
+ case "paragraph": {
61896
+ const text = this.renderInlineTokens(token.tokens || [], styleContext);
61897
+ appendLines(target, text.split("\n"));
61898
+ break;
61899
+ }
61900
+ case "space":
61901
+ target.push("");
61902
+ break;
61903
+ case "list":
61904
+ appendLines(target, this.renderList(token, 0, styleContext, width));
61905
+ break;
61906
+ case "blockquote": {
61907
+ const nestedBorder = this.theme.quoteBorder("\u2502 ");
61908
+ const nestedWidth = Math.max(1, width - 2);
61909
+ const nestedTokens = token.tokens || [];
61910
+ const nestedLines = [];
61911
+ for (let i = 0; i < nestedTokens.length; i++) {
61912
+ this.renderQuoteInnerToken(
61913
+ nestedTokens[i],
61914
+ nestedTokens[i + 1]?.type,
61915
+ styleContext,
61916
+ nestedWidth,
61917
+ nestedLines
61918
+ );
61919
+ }
61920
+ for (const nestedLine of nestedLines) {
61921
+ if (nestedLine === "") {
61922
+ target.push(nestedBorder);
61923
+ continue;
61924
+ }
61925
+ const wrappedNested = wrapTextWithAnsi(nestedLine, nestedWidth);
61926
+ for (const nestedWrappedLine of wrappedNested) {
61927
+ target.push(nestedBorder + nestedWrappedLine);
61928
+ }
61929
+ }
61930
+ break;
61931
+ }
61932
+ case "code": {
61933
+ const indent = this.theme.codeBlockIndent ?? " ";
61934
+ target.push(this.theme.codeBlockBorder(`\`\`\`${token.lang || ""}`));
61935
+ if (this.theme.highlightCode) {
61936
+ const highlightedLines = this.theme.highlightCode(token.text, token.lang);
61937
+ for (const hlLine of highlightedLines) {
61938
+ target.push(`${indent}${hlLine}`);
61939
+ }
61940
+ } else {
61941
+ const codeLines = token.text.split("\n");
61942
+ for (const codeLine of codeLines) {
61943
+ target.push(`${indent}${this.theme.codeBlock(codeLine)}`);
61944
+ }
61945
+ }
61946
+ target.push(this.theme.codeBlockBorder("```"));
61947
+ break;
61948
+ }
61949
+ case "hr":
61950
+ target.push(this.theme.hr("\u2500".repeat(Math.min(width, 80))));
61951
+ break;
61952
+ case "heading": {
61953
+ const headingText = this.renderInlineTokens(token.tokens || [], styleContext);
61954
+ target.push(this.theme.bold(headingText));
61955
+ if (nextTokenType !== void 0 && nextTokenType !== "space") {
61956
+ target.push("");
61957
+ }
61958
+ break;
61959
+ }
61960
+ default: {
61961
+ if ("text" in token && typeof token.text === "string") {
61962
+ appendLines(target, this.renderInlineTokens([token], styleContext).split("\n"));
61963
+ } else if ("raw" in token && typeof token.raw === "string") {
61964
+ appendLines(target, token.raw.split("\n"));
61965
+ }
61966
+ }
61967
+ }
61968
+ }
61864
61969
  renderInlineTokens(tokens, styleContext) {
61865
61970
  let result = "";
61866
61971
  const resolvedStyleContext = styleContext ?? this.getDefaultInlineStyleContext();
@@ -61907,6 +62012,14 @@ var Markdown = class {
61907
62012
  case "br":
61908
62013
  result += "\n";
61909
62014
  break;
62015
+ case "checkbox":
62016
+ result += applyText(token.checked ? "[x] " : "[ ] ");
62017
+ break;
62018
+ case "image": {
62019
+ const altText = this.renderInlineTokens(token.tokens || [], resolvedStyleContext) || token.text || "image";
62020
+ result += this.theme.link(this.theme.underline(altText)) + this.theme.linkUrl(` (${token.href})`) + stylePrefix;
62021
+ break;
62022
+ }
61910
62023
  case "del": {
61911
62024
  const delContent = this.renderInlineTokens(token.tokens || [], resolvedStyleContext);
61912
62025
  result += this.theme.strikethrough(delContent) + stylePrefix;
@@ -61926,32 +62039,36 @@ var Markdown = class {
61926
62039
  return result;
61927
62040
  }
61928
62041
  /**
61929
- * Render a list with proper nesting support
62042
+ * Render a list with proper nesting support.
62043
+ * Nested structure is tracked via ListItemFragment provenance metadata
62044
+ * (never inferred from the rendered string / its ANSI colors).
61930
62045
  */
61931
- renderList(token, depth) {
62046
+ renderList(token, depth, styleContext, availableWidth) {
61932
62047
  const lines = [];
61933
62048
  const indent = " ".repeat(depth);
61934
62049
  const startNumber = token.start ?? 1;
61935
62050
  for (let i = 0; i < token.items.length; i++) {
61936
62051
  const item = token.items[i];
61937
62052
  const bullet = token.ordered ? `${startNumber + i}. ` : "- ";
61938
- const itemLines = this.renderListItem(item.tokens || [], depth);
61939
- if (itemLines.length > 0) {
61940
- const firstLine = itemLines[0];
61941
- const isNestedList = /^\s+\x1b\[36m[-\d]/.test(firstLine);
61942
- if (isNestedList) {
61943
- lines.push(firstLine);
61944
- } else {
61945
- lines.push(indent + this.theme.listBullet(bullet) + firstLine);
61946
- }
61947
- for (let j2 = 1; j2 < itemLines.length; j2++) {
61948
- const line = itemLines[j2];
61949
- const isNestedListLine = /^\s+\x1b\[36m[-\d]/.test(line);
61950
- if (isNestedListLine) {
61951
- lines.push(line);
61952
- } else {
61953
- lines.push(`${indent} ${line}`);
62053
+ const fragments = this.renderListItem(item.tokens || [], depth, styleContext, availableWidth);
62054
+ if (fragments.length > 0) {
62055
+ let isFirstFragment = true;
62056
+ for (const fragment of fragments) {
62057
+ switch (fragment.kind) {
62058
+ case "positioned-list":
62059
+ lines.push(fragment.text);
62060
+ break;
62061
+ case "table":
62062
+ lines.push(indent + fragment.text);
62063
+ break;
62064
+ default:
62065
+ if (isFirstFragment) {
62066
+ lines.push(indent + this.theme.listBullet(bullet) + fragment.text);
62067
+ } else {
62068
+ lines.push(`${indent} ${fragment.text}`);
62069
+ }
61954
62070
  }
62071
+ isFirstFragment = false;
61955
62072
  }
61956
62073
  } else {
61957
62074
  lines.push(indent + this.theme.listBullet(bullet));
@@ -61960,44 +62077,98 @@ var Markdown = class {
61960
62077
  return lines;
61961
62078
  }
61962
62079
  /**
61963
- * Render list item tokens, handling nested lists
61964
- * Returns lines WITHOUT the parent indent (renderList will add it)
62080
+ * Render list item tokens, handling nested lists.
62081
+ * Returns fragments WITHOUT the parent indent (renderList will add it); each
62082
+ * fragment carries layout provenance so the parent never has to guess from
62083
+ * the rendered string.
61965
62084
  */
61966
- renderListItem(tokens, parentDepth) {
61967
- const lines = [];
62085
+ renderListItem(tokens, parentDepth, styleContext, availableWidth) {
62086
+ const fragments = [];
62087
+ let pendingPrefix = "";
62088
+ const push = (text) => {
62089
+ if (text !== "") {
62090
+ fragments.push({ kind: "local-content", text: pendingPrefix + text });
62091
+ pendingPrefix = "";
62092
+ }
62093
+ };
61968
62094
  for (const token of tokens) {
61969
62095
  if (token.type === "list") {
61970
- const nestedLines = this.renderList(token, parentDepth + 1);
61971
- appendLines(lines, nestedLines);
62096
+ const nestedLines = this.renderList(
62097
+ token,
62098
+ parentDepth + 1,
62099
+ styleContext,
62100
+ availableWidth
62101
+ );
62102
+ for (const nestedLine of nestedLines) {
62103
+ fragments.push({ kind: "positioned-list", text: nestedLine });
62104
+ }
61972
62105
  } else if (token.type === "text") {
61973
- const text = token.tokens && token.tokens.length > 0 ? this.renderInlineTokens(token.tokens) : token.text || "";
61974
- lines.push(text);
62106
+ const text = token.tokens && token.tokens.length > 0 ? this.renderInlineTokens(token.tokens, styleContext) : token.text || "";
62107
+ push(text);
61975
62108
  } else if (token.type === "paragraph") {
61976
- const text = this.renderInlineTokens(token.tokens || []);
61977
- lines.push(text);
62109
+ const text = this.renderInlineTokens(token.tokens || [], styleContext);
62110
+ push(text);
61978
62111
  } else if (token.type === "code") {
61979
62112
  const indent = this.theme.codeBlockIndent ?? " ";
61980
- lines.push(this.theme.codeBlockBorder(`\`\`\`${token.lang || ""}`));
62113
+ push(this.theme.codeBlockBorder(`\`\`\`${token.lang || ""}`));
61981
62114
  if (this.theme.highlightCode) {
61982
62115
  const highlightedLines = this.theme.highlightCode(token.text, token.lang);
61983
62116
  for (const hlLine of highlightedLines) {
61984
- lines.push(`${indent}${hlLine}`);
62117
+ push(`${indent}${hlLine}`);
61985
62118
  }
61986
62119
  } else {
61987
62120
  const codeLines = token.text.split("\n");
61988
62121
  for (const codeLine of codeLines) {
61989
- lines.push(`${indent}${this.theme.codeBlock(codeLine)}`);
62122
+ push(`${indent}${this.theme.codeBlock(codeLine)}`);
61990
62123
  }
61991
62124
  }
61992
- lines.push(this.theme.codeBlockBorder("```"));
62125
+ push(this.theme.codeBlockBorder("```"));
62126
+ } else if (token.type === "table") {
62127
+ if (availableWidth !== void 0) {
62128
+ const tableLines = this.renderTable(token, availableWidth);
62129
+ for (const tableLine of tableLines) {
62130
+ if (tableLine !== "") {
62131
+ fragments.push({ kind: "table", text: tableLine });
62132
+ }
62133
+ }
62134
+ } else if ("raw" in token && typeof token.raw === "string") {
62135
+ for (const rawLine of token.raw.split("\n")) {
62136
+ push(rawLine);
62137
+ }
62138
+ }
62139
+ } else if (token.type === "blockquote") {
62140
+ const quoteWidth = availableWidth !== void 0 ? Math.max(1, availableWidth - " ".repeat(parentDepth + 1).length - 2) : void 0;
62141
+ if (quoteWidth !== void 0) {
62142
+ const quoteLines = this.renderBlockquote(token, quoteWidth, styleContext);
62143
+ for (const quoteLine of quoteLines) {
62144
+ if (quoteLine !== "") {
62145
+ fragments.push({ kind: "local-content", text: quoteLine });
62146
+ }
62147
+ }
62148
+ } else if ("text" in token && typeof token.text === "string") {
62149
+ push(token.text);
62150
+ }
62151
+ } else if (token.type === "heading") {
62152
+ const headingText = this.renderInlineTokens(token.tokens || [], styleContext);
62153
+ push(this.theme.bold(headingText));
62154
+ } else if (token.type === "space") {
62155
+ fragments.push({ kind: "local-content", text: "" });
62156
+ } else if (token.type === "hr") {
62157
+ const ruleWidth = availableWidth !== void 0 ? Math.min(availableWidth, 40) : 40;
62158
+ push(this.theme.hr("\u2500".repeat(ruleWidth)));
62159
+ } else if (token.type === "checkbox") {
62160
+ pendingPrefix += token.checked ? "[x] " : "[ ] ";
61993
62161
  } else {
61994
- const text = this.renderInlineTokens([token]);
62162
+ const text = this.renderInlineTokens([token], styleContext);
61995
62163
  if (text) {
61996
- lines.push(text);
62164
+ push(text);
61997
62165
  }
61998
62166
  }
61999
62167
  }
62000
- return lines;
62168
+ if (pendingPrefix !== "") {
62169
+ fragments.push({ kind: "local-content", text: pendingPrefix });
62170
+ }
62171
+ return fragments;
62001
62172
  }
62002
62173
  /**
62003
62174
  * Get the visible width of the longest word in a string.
@@ -67571,7 +67742,7 @@ var FFmpegProcessor = class {
67571
67742
  // ============================================================================
67572
67743
  async checkAvailability() {
67573
67744
  return new Promise((resolve8) => {
67574
- const proc = spawn2(this.ffmpegPath, ["-version"]);
67745
+ const proc = spawn2(this.ffmpegPath, ["-version"], { windowsHide: true });
67575
67746
  proc.on("error", () => resolve8(false));
67576
67747
  proc.on("exit", (code) => resolve8(code === 0));
67577
67748
  });
@@ -67592,7 +67763,7 @@ var FFmpegProcessor = class {
67592
67763
  "json",
67593
67764
  videoPath
67594
67765
  ];
67595
- const proc = spawn2(this.ffprobePath, args);
67766
+ const proc = spawn2(this.ffprobePath, args, { windowsHide: true });
67596
67767
  let stdout = "";
67597
67768
  let stderr = "";
67598
67769
  proc.stdout.on("data", (data) => stdout += data);
@@ -67805,7 +67976,7 @@ var FFmpegProcessor = class {
67805
67976
  // ============================================================================
67806
67977
  runFFmpeg(args) {
67807
67978
  return new Promise((resolve8, reject) => {
67808
- const proc = spawn2(this.ffmpegPath, args);
67979
+ const proc = spawn2(this.ffmpegPath, args, { windowsHide: true });
67809
67980
  let stderr = "";
67810
67981
  proc.stderr.on("data", (data) => {
67811
67982
  stderr += data;
@@ -67842,7 +68013,7 @@ var FFmpegProcessor = class {
67842
68013
  "-progress",
67843
68014
  "pipe:1"
67844
68015
  ];
67845
- const proc = spawn2(this.ffmpegPath, progressArgs);
68016
+ const proc = spawn2(this.ffmpegPath, progressArgs, { windowsHide: true });
67846
68017
  let stderr = "";
67847
68018
  let progressData = "";
67848
68019
  proc.stdout.on("data", (data) => {
@@ -70906,6 +71077,94 @@ var TreeSelectorComponent = class {
70906
71077
  };
70907
71078
 
70908
71079
  // src/components/assistant-message.ts
71080
+ var STREAMING_SPLIT_MIN_CHARS = 256;
71081
+ var STREAMING_TAIL_MAX_CHARS = 8192;
71082
+ function matchOpenFence(line) {
71083
+ const match = /^ {0,3}(`{3,}|~{3,})(.*)$/.exec(line);
71084
+ if (!match) return null;
71085
+ const run = match[1];
71086
+ const rest = match[2] ?? "";
71087
+ if (run[0] === "`" && rest.includes("`")) return null;
71088
+ return { char: run[0], length: run.length };
71089
+ }
71090
+ function isCloseFence(line, fence) {
71091
+ const match = /^ {0,3}(`+|~+)[ \t]*$/.exec(line);
71092
+ if (!match) return false;
71093
+ const run = match[1];
71094
+ return run[0] === fence.char && run.length >= fence.length;
71095
+ }
71096
+ function isBoundarySafeSplit(nextLine) {
71097
+ if (nextLine.trim() === "") return false;
71098
+ if (/^(\t| {4})/.test(nextLine)) return false;
71099
+ if (/^\s*([-*+]|\d{1,9}[.)])\s/.test(nextLine)) return false;
71100
+ if (/^\s*</.test(nextLine)) return false;
71101
+ return true;
71102
+ }
71103
+ var RAW_HTML_UNTIL_CLOSED = /* @__PURE__ */ new Set(["script", "pre", "style", "textarea"]);
71104
+ function htmlBlockStateAt(line) {
71105
+ const comment = /^ {0,3}<!--/.test(line);
71106
+ if (comment) {
71107
+ return line.includes("-->") ? null : { kind: "comment" };
71108
+ }
71109
+ const match = /^ {0,3}<([a-zA-Z][a-zA-Z0-9-]*)/.exec(line);
71110
+ if (!match) return null;
71111
+ const tag = match[1].toLowerCase();
71112
+ if (!RAW_HTML_UNTIL_CLOSED.has(tag)) return { kind: "blank" };
71113
+ return new RegExp(`</${tag}\\s*>`).test(line) ? null : { kind: "tag", tag };
71114
+ }
71115
+ function closesHtmlBlock(line, state) {
71116
+ if (state.kind === "comment") return line.includes("-->");
71117
+ if (state.kind === "tag") {
71118
+ return new RegExp(`^ {0,3}</${state.tag}\\s*>?(\\s|$)`).test(line);
71119
+ }
71120
+ return false;
71121
+ }
71122
+ function findStablePrefixEnd(text) {
71123
+ let fence = null;
71124
+ let html = null;
71125
+ let lastSafe = -1;
71126
+ let pos = 0;
71127
+ let candidateBlankAt = -1;
71128
+ while (pos < text.length) {
71129
+ const lineEnd = text.indexOf("\n", pos);
71130
+ const line = lineEnd < 0 ? text.slice(pos) : text.slice(pos, lineEnd);
71131
+ const next = lineEnd < 0 ? text.length + 1 : lineEnd + 1;
71132
+ if (fence !== null) {
71133
+ if (isCloseFence(line, fence)) {
71134
+ fence = null;
71135
+ candidateBlankAt = -1;
71136
+ }
71137
+ } else if (html !== null) {
71138
+ if (html.kind === "blank") {
71139
+ if (line.trim() === "") html = null;
71140
+ } else if (closesHtmlBlock(line, html)) {
71141
+ html = null;
71142
+ }
71143
+ candidateBlankAt = -1;
71144
+ } else {
71145
+ const open = /^ {0,3}(`{3,}|~{3,})/.test(line) ? matchOpenFence(line) : null;
71146
+ const htmlState = line.trim() !== "" ? htmlBlockStateAt(line) : null;
71147
+ if (open) {
71148
+ fence = open;
71149
+ candidateBlankAt = -1;
71150
+ } else if (line.trim() === "") {
71151
+ candidateBlankAt = lineEnd >= 0 ? lineEnd : text.length - 1;
71152
+ } else if (htmlState) {
71153
+ html = htmlState;
71154
+ candidateBlankAt = -1;
71155
+ } else if (candidateBlankAt >= 0) {
71156
+ if (lineEnd >= 0 && isBoundarySafeSplit(line)) lastSafe = candidateBlankAt;
71157
+ candidateBlankAt = -1;
71158
+ }
71159
+ }
71160
+ pos = next;
71161
+ }
71162
+ if (lastSafe >= 0 && lastSafe + 1 >= STREAMING_SPLIT_MIN_CHARS) return lastSafe + 1;
71163
+ return -1;
71164
+ }
71165
+ function hasVisibleContentAfter(content, index) {
71166
+ return content.slice(index + 1).some((c) => c.type === "text" && c.text.trim() || c.type === "thinking" && c.thinking.trim());
71167
+ }
70909
71168
  var AssistantMessageComponent = class extends Container {
70910
71169
  contentContainer;
70911
71170
  hideThinkingBlock;
@@ -70916,6 +71175,15 @@ var AssistantMessageComponent = class extends Container {
70916
71175
  highlightCache = /* @__PURE__ */ new Map();
70917
71176
  usedHighlightKeys = /* @__PURE__ */ new Set();
70918
71177
  pruneHighlightCache = false;
71178
+ /** Streaming stable-prefix reuse (see tryStreamingSplitRebuild): a chain of
71179
+ * frozen Markdown chunks plus the text they cover. Advancing appends a new
71180
+ * chunk (renders only the NEW text) instead of re-rendering one growing
71181
+ * component, so an advance is O(chunk) at any message size. Text blocks
71182
+ * only: thinking content is usually hidden or restyled and stays on the
71183
+ * full-render path. */
71184
+ stablePrefix = "";
71185
+ stablePrefixChunks = [];
71186
+ stablePrefixKind = null;
70919
71187
  constructor(message, hideThinkingBlock = false, markdownTheme = getMarkdownTheme()) {
70920
71188
  super();
70921
71189
  this.hideThinkingBlock = hideThinkingBlock;
@@ -70945,6 +71213,9 @@ var AssistantMessageComponent = class extends Container {
70945
71213
  invalidate() {
70946
71214
  this.highlightCache.clear();
70947
71215
  this.usedHighlightKeys.clear();
71216
+ this.stablePrefixChunks = [];
71217
+ this.stablePrefix = "";
71218
+ this.stablePrefixKind = null;
70948
71219
  super.invalidate();
70949
71220
  if (this.lastMessage) {
70950
71221
  this.updateContent(this.lastMessage);
@@ -70968,9 +71239,20 @@ var AssistantMessageComponent = class extends Container {
70968
71239
  return this.calmMode;
70969
71240
  }
70970
71241
  /** The final frame may reuse streamed highlights; afterwards only the
70971
- * Markdown line cache is needed, so release the duplicate code strings. */
71242
+ * Markdown line cache is needed, so release the duplicate code strings.
71243
+ * Terminal paths (message_end, hard errors, interrupts) call this at
71244
+ * different points relative to the last updateContent — some BEFORE any
71245
+ * final update, some after one that still carried streaming=true and took
71246
+ * the split path. Always rebuild the full layout here so the committed
71247
+ * frame is byte-identical to the non-streaming renderer. */
70972
71248
  finalizeStreaming() {
70973
71249
  this.streaming = false;
71250
+ this.stablePrefixChunks = [];
71251
+ this.stablePrefix = "";
71252
+ this.stablePrefixKind = null;
71253
+ if (this.lastMessage) {
71254
+ this.updateContent(this.lastMessage);
71255
+ }
70974
71256
  }
70975
71257
  render(width) {
70976
71258
  this.usedHighlightKeys.clear();
@@ -70993,6 +71275,102 @@ var AssistantMessageComponent = class extends Container {
70993
71275
  this.usedHighlightKeys.clear();
70994
71276
  }
70995
71277
  }
71278
+ /** Spacer + frozen leading blocks shared by both streaming paths. */
71279
+ appendFrozenLeadingBlocks(message, lastEditableIndex, hasVisibleContent) {
71280
+ this.contentContainer.clear();
71281
+ if (hasVisibleContent) {
71282
+ this.contentContainer.addChild(new Spacer(1));
71283
+ }
71284
+ for (let i = 0; i < lastEditableIndex; i++) {
71285
+ const content = message.content[i];
71286
+ if (content.type === "text" && content.text.trim()) {
71287
+ this.contentContainer.addChild(new Markdown(content.text.trim(), 1, 0, this.markdownTheme));
71288
+ } else if (content.type === "thinking" && content.thinking.trim() && !this.calmMode) {
71289
+ this.contentContainer.addChild(this.createThinkingComponent(content.thinking, message.content, i));
71290
+ }
71291
+ }
71292
+ }
71293
+ /** Thinking block renderer shared by the streaming fast path and the full
71294
+ * rebuild, so both produce identical spacing and styling. `content`/`index`
71295
+ * only decide the trailing spacer (visible content after the block). */
71296
+ createThinkingComponent(thinking, content, index) {
71297
+ const wrapper = new Container();
71298
+ if (this.hideThinkingBlock) {
71299
+ wrapper.addChild(new Text(theme.italic(theme.fg("thinkingText", "Thinking...")), 1, 0));
71300
+ } else {
71301
+ wrapper.addChild(
71302
+ new Markdown(thinking.trim(), 1, 0, this.markdownTheme, {
71303
+ color: (text) => theme.fg("thinkingText", text),
71304
+ italic: true
71305
+ })
71306
+ );
71307
+ }
71308
+ if (content !== void 0 && index !== void 0 && hasVisibleContentAfter(content, index)) {
71309
+ wrapper.addChild(new Spacer(1));
71310
+ }
71311
+ return wrapper;
71312
+ }
71313
+ /** Streaming fast path: rebuild only the volatile tail each update.
71314
+ * Returns false when the message is final (or text too small to benefit),
71315
+ * in which case the caller falls through to the full rebuild. */
71316
+ tryStreamingSplitRebuild(message, hasVisibleContent) {
71317
+ if (!this.streaming) return false;
71318
+ if (message.stopReason !== void 0) return false;
71319
+ if (message.content.some((c) => c.type === "toolCall")) return false;
71320
+ let lastEditableIndex = -1;
71321
+ for (let i = message.content.length - 1; i >= 0; i--) {
71322
+ const c = message.content[i];
71323
+ if (c.type === "text" || c.type === "thinking") {
71324
+ lastEditableIndex = i;
71325
+ break;
71326
+ }
71327
+ }
71328
+ if (lastEditableIndex < 0) return false;
71329
+ const lastBlock = message.content[lastEditableIndex];
71330
+ if (lastBlock.type !== "text") return false;
71331
+ const fullText = lastBlock.text;
71332
+ if (fullText.length < STREAMING_SPLIT_MIN_CHARS) return false;
71333
+ const boundary = findStablePrefixEnd(fullText);
71334
+ if (boundary < 0) return false;
71335
+ const prefix = fullText.slice(0, boundary);
71336
+ const tail = fullText.slice(boundary);
71337
+ if (!tail.trim()) return false;
71338
+ const prefixStillValid = this.stablePrefixChunks.length > 0 && this.stablePrefixKind === "text" && this.stablePrefix.length > 0 && fullText.startsWith(this.stablePrefix) && fullText.length - this.stablePrefix.length <= STREAMING_TAIL_MAX_CHARS;
71339
+ if (prefixStillValid) {
71340
+ this.appendFrozenLeadingBlocks(message, lastEditableIndex, hasVisibleContent);
71341
+ for (const chunk of this.stablePrefixChunks) {
71342
+ this.contentContainer.addChild(chunk);
71343
+ }
71344
+ const reuseTail = fullText.slice(this.stablePrefix.length).trim();
71345
+ if (reuseTail) {
71346
+ this.contentContainer.addChild(new Markdown(reuseTail, 1, 0, this.markdownTheme));
71347
+ }
71348
+ return true;
71349
+ }
71350
+ let advanceFrom = 0;
71351
+ const chainStillApplies = this.stablePrefixChunks.length > 0 && this.stablePrefixKind === "text" && this.stablePrefix.length > 0 && prefix.startsWith(this.stablePrefix);
71352
+ if (chainStillApplies) {
71353
+ advanceFrom = this.stablePrefix.length;
71354
+ } else {
71355
+ this.stablePrefixChunks = [];
71356
+ this.stablePrefix = "";
71357
+ }
71358
+ this.appendFrozenLeadingBlocks(message, lastEditableIndex, hasVisibleContent);
71359
+ const newChunkText = prefix.slice(advanceFrom);
71360
+ if (newChunkText) {
71361
+ this.stablePrefixChunks.push(new Markdown(newChunkText, 1, 0, this.markdownTheme));
71362
+ }
71363
+ this.stablePrefix = prefix;
71364
+ this.stablePrefixKind = "text";
71365
+ for (const chunk of this.stablePrefixChunks) {
71366
+ this.contentContainer.addChild(chunk);
71367
+ }
71368
+ const tailTrimmed = tail.trim();
71369
+ if (tailTrimmed) {
71370
+ this.contentContainer.addChild(new Markdown(tailTrimmed, 1, 0, this.markdownTheme));
71371
+ }
71372
+ return true;
71373
+ }
70996
71374
  updateContent(message) {
70997
71375
  this.lastMessage = message;
70998
71376
  this.pruneHighlightCache = true;
@@ -71000,6 +71378,14 @@ var AssistantMessageComponent = class extends Container {
71000
71378
  const hasTextContent = message.content.some((c) => c.type === "text" && c.text.trim());
71001
71379
  const hasThinkingContent = message.content.some((c) => c.type === "thinking" && c.thinking.trim());
71002
71380
  const hasVisibleContent = this.calmMode ? hasTextContent : hasTextContent || hasThinkingContent;
71381
+ if (this.tryStreamingSplitRebuild(message, hasVisibleContent)) {
71382
+ return;
71383
+ }
71384
+ if (!this.streaming) {
71385
+ this.stablePrefixChunks = [];
71386
+ this.stablePrefix = "";
71387
+ this.stablePrefixKind = null;
71388
+ }
71003
71389
  if (hasVisibleContent) {
71004
71390
  this.contentContainer.addChild(new Spacer(1));
71005
71391
  }
@@ -71011,23 +71397,7 @@ var AssistantMessageComponent = class extends Container {
71011
71397
  if (this.calmMode) {
71012
71398
  continue;
71013
71399
  }
71014
- const hasVisibleContentAfter = message.content.slice(i + 1).some((c) => c.type === "text" && c.text.trim() || c.type === "thinking" && c.thinking.trim());
71015
- if (this.hideThinkingBlock) {
71016
- this.contentContainer.addChild(new Text(theme.italic(theme.fg("thinkingText", "Thinking...")), 1, 0));
71017
- if (hasVisibleContentAfter) {
71018
- this.contentContainer.addChild(new Spacer(1));
71019
- }
71020
- } else {
71021
- this.contentContainer.addChild(
71022
- new Markdown(content.thinking.trim(), 1, 0, this.markdownTheme, {
71023
- color: (text) => theme.fg("thinkingText", text),
71024
- italic: true
71025
- })
71026
- );
71027
- if (hasVisibleContentAfter) {
71028
- this.contentContainer.addChild(new Spacer(1));
71029
- }
71030
- }
71400
+ this.contentContainer.addChild(this.createThinkingComponent(content.thinking, message.content, i));
71031
71401
  }
71032
71402
  }
71033
71403
  const hasToolCalls = message.content.some((c) => c.type === "toolCall");
@@ -71930,7 +72300,8 @@ async function handleResumeCommand(host) {
71930
72300
  const child = spawn3(process.execPath, [...process.execArgv, process.argv[1] ?? ".", ...decision.childArgv], {
71931
72301
  cwd: decision.targetCwd,
71932
72302
  stdio: "inherit",
71933
- env: buildChildEnv(decision.childEnv)
72303
+ env: buildChildEnv(decision.childEnv),
72304
+ windowsHide: true
71934
72305
  });
71935
72306
  child.on("spawn", () => announce());
71936
72307
  child.on("exit", (code, signal) => {
@@ -72081,9 +72452,10 @@ function noteToolExecutionEnd(host, toolCallId) {
72081
72452
  function clearRunningToolExecutions(host) {
72082
72453
  runningToolExecutions.get(host)?.clear();
72083
72454
  }
72084
- function hasRunningToolWork(host) {
72085
- const set = runningToolExecutions.get(host);
72086
- return set !== void 0 && set.size > 0;
72455
+ function hasRunningTitleWork(host) {
72456
+ const recovery = host.agentSessionController?.turnRecoveryState;
72457
+ const tools = runningToolExecutions.get(host);
72458
+ return host.agent?.state?.isStreaming === true || host.isCompacting === true || recovery === "retry_pending" || recovery === "retrying" || recovery === "compacting" || tools !== void 0 && tools.size > 0;
72087
72459
  }
72088
72460
  var explicitSubmitLockHosts = /* @__PURE__ */ new WeakSet();
72089
72461
  var controllerBusyHosts = /* @__PURE__ */ new WeakSet();
@@ -72137,7 +72509,7 @@ function startTitleSpinner(host) {
72137
72509
  let stalled = false;
72138
72510
  titleActivityStamps.set(host, Date.now());
72139
72511
  const timer = setInterval(() => {
72140
- if (hasRunningToolWork(host)) titleActivityStamps.set(host, Date.now());
72512
+ if (hasRunningTitleWork(host)) titleActivityStamps.set(host, Date.now());
72141
72513
  const lastActivity = titleActivityStamps.get(host);
72142
72514
  if (lastActivity !== void 0 && Date.now() - lastActivity > TITLE_BUSY_STALL_MS) {
72143
72515
  if (!stalled) {
@@ -81198,7 +81570,8 @@ async function handleDirectBash(host, command) {
81198
81570
  const { spawn: spawn5 } = await import("child_process");
81199
81571
  const child = spawn5(shellCommand.file, shellCommand.args, {
81200
81572
  cwd: process.cwd(),
81201
- env: process.env
81573
+ env: process.env,
81574
+ windowsHide: true
81202
81575
  });
81203
81576
  const output = new DirectBashOutputCollector();
81204
81577
  child.stdout.on("data", (data) => {
@@ -85274,6 +85647,42 @@ Print Mode Options:
85274
85647
  `);
85275
85648
  }
85276
85649
 
85650
+ // src/runtime/supervisor-anchor.ts
85651
+ import { execFileSync } from "node:child_process";
85652
+ function selfStartTime() {
85653
+ if (process.platform === "win32") {
85654
+ try {
85655
+ return execFileSync(
85656
+ "powershell",
85657
+ [
85658
+ "-NoProfile",
85659
+ "-NonInteractive",
85660
+ "-Command",
85661
+ `$p = Get-CimInstance Win32_Process -Filter "ProcessId=${process.pid}"; if ($p) { $p.CreationDate.ToString('o') }`
85662
+ ],
85663
+ { timeout: 5e3, encoding: "utf8", windowsHide: true }
85664
+ ).trim() || void 0;
85665
+ } catch {
85666
+ return void 0;
85667
+ }
85668
+ }
85669
+ try {
85670
+ return execFileSync("ps", ["-p", String(process.pid), "-o", "lstart="], {
85671
+ timeout: 5e3,
85672
+ env: { ...process.env, LC_ALL: "C", LANG: "C", TZ: "UTC0" },
85673
+ encoding: "utf8"
85674
+ }).trim() || void 0;
85675
+ } catch {
85676
+ return void 0;
85677
+ }
85678
+ }
85679
+ function injectSupervisorAnchor(env = process.env) {
85680
+ env[SUPERVISOR_PID_ENV] = String(process.pid);
85681
+ const startTime = selfStartTime();
85682
+ if (startTime !== void 0) env[SUPERVISOR_START_TIME_ENV] = startTime;
85683
+ else delete env[SUPERVISOR_START_TIME_ENV];
85684
+ }
85685
+
85277
85686
  // src/cli.ts
85278
85687
  enableEarlyLogBuffer();
85279
85688
  var logError = (msg, err) => {
@@ -85450,6 +85859,7 @@ async function startChat(initialPrompt, testCommand, explicitSessionId) {
85450
85859
  }
85451
85860
  async function main() {
85452
85861
  const args = process.argv.slice(2);
85862
+ injectSupervisorAnchor();
85453
85863
  if (args[0] === "--version" || args[0] === "-v") {
85454
85864
  console.log(VERSION);
85455
85865
  return;