@adhdev/daemon-standalone 0.9.76-rc.65 → 0.9.76-rc.68

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.
package/dist/index.js CHANGED
@@ -31226,6 +31226,7 @@ var require_dist2 = __commonJS({
31226
31226
  requireApprovalForDestructiveGit: true,
31227
31227
  dirtyWorkspaceBehavior: "warn",
31228
31228
  maxParallelTasks: 2,
31229
+ spawnedSessionVisibility: "visible",
31229
31230
  sessionCleanupOnNodeRemove: "preserve"
31230
31231
  };
31231
31232
  }
@@ -31662,6 +31663,9 @@ var require_dist2 = __commonJS({
31662
31663
  if (!SESSION_CLEANUP_MODES.has(String(policy.sessionCleanupOnNodeRemove))) {
31663
31664
  policy.sessionCleanupOnNodeRemove = "preserve";
31664
31665
  }
31666
+ if (!SPAWNED_SESSION_VISIBILITY_MODES.has(String(policy.spawnedSessionVisibility))) {
31667
+ policy.spawnedSessionVisibility = "visible";
31668
+ }
31665
31669
  return policy;
31666
31670
  }
31667
31671
  function listMeshes() {
@@ -31770,6 +31774,7 @@ var require_dist2 = __commonJS({
31770
31774
  var import_path22;
31771
31775
  var import_crypto32;
31772
31776
  var SESSION_CLEANUP_MODES;
31777
+ var SPAWNED_SESSION_VISIBILITY_MODES;
31773
31778
  var init_mesh_config = __esm2({
31774
31779
  "src/config/mesh-config.ts"() {
31775
31780
  "use strict";
@@ -31779,6 +31784,7 @@ var require_dist2 = __commonJS({
31779
31784
  init_config();
31780
31785
  init_repo_mesh_types();
31781
31786
  SESSION_CLEANUP_MODES = /* @__PURE__ */ new Set(["preserve", "stop", "delete_stopped", "stop_and_delete"]);
31787
+ SPAWNED_SESSION_VISIBILITY_MODES = /* @__PURE__ */ new Set(["visible", "hidden"]);
31782
31788
  }
31783
31789
  });
31784
31790
  var coordinator_prompt_exports = {};
@@ -32544,13 +32550,25 @@ Before doing any coordinator work, confirm that the actual callable tool list in
32544
32550
  }
32545
32551
  });
32546
32552
  function stripAnsi(str) {
32547
- return str.replace(/\x1B\][^\x07]*\x07/g, "").replace(/\x1B\][\s\S]*?\x1B\\/g, "").replace(/\x1B[P^_X][\s\S]*?(?:\x07|\x1B\\)/g, "").replace(/\x1B\[\d*[A-HJKSTfG]/g, " ").replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g, "").replace(/ +/g, " ");
32553
+ return str.replace(/\x1B\][^\x07]*(?:\x07|\x1B\\)/g, "").replace(/\x1B[P^_X][\s\S]*?(?:\x07|\x1B\\)/g, "").replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g, "");
32554
+ }
32555
+ function parseCount(params, fallback = 1) {
32556
+ const first = Number(String(params || "").split(";")[0] || fallback);
32557
+ return Math.max(1, Number.isFinite(first) ? first : fallback);
32558
+ }
32559
+ function isCombiningMark(ch) {
32560
+ return /[\u0300-\u036F\u1AB0-\u1AFF\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/.test(ch);
32561
+ }
32562
+ function isWideCodePoint(ch) {
32563
+ const cp = ch.codePointAt(0) || 0;
32564
+ return cp >= 4352 && (cp <= 4447 || cp === 9001 || cp === 9002 || cp >= 11904 && cp <= 42191 && cp !== 12351 || cp >= 44032 && cp <= 55203 || cp >= 63744 && cp <= 64255 || cp >= 65040 && cp <= 65049 || cp >= 65072 && cp <= 65135 || cp >= 65280 && cp <= 65376 || cp >= 65504 && cp <= 65510 || cp >= 127744 && cp <= 129791);
32548
32565
  }
32549
32566
  function stripTerminalNoise(str) {
32550
- return String(str || "").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x9F]/g, "").replace(/(^|[\s([])(?:\??\d{1,4}(?:;\d{1,4})*[A-Za-z])(?=$|[\s)\]])/g, "$1").replace(/(^|[\s([])(?:\[\??\d{1,4}(?:;\d{1,4})*[A-Za-z])(?=$|[\s)\]])/g, "$1").replace(/(^|[\s([])(?:\d{1,4};\?)(?=$|[\s)\]])/g, "$1").replace(/(^|[\s([])(?:\d+\$r[0-9;\" ]*[A-Za-z]?)(?=$|[\s)\]])/g, "$1").replace(/(^|[\s([])(?:>\|[A-Za-z0-9_.:-]+(?:\([^)]*\))?)(?=$|[\s)\]])/g, "$1").replace(/(^|[\s([])(?:[A-Z]\d(?:\s+[A-Z]\d)+)(?=$|[\s)\]])/g, "$1").replace(/(^|[\s([])(?:\d+;[^\s)\]]+)(?=$|[\s)\]])/g, "$1").replace(/\r+/g, "\n").replace(/[ \t]+\n/g, "\n").replace(/\n{3,}/g, "\n\n").replace(/ {2,}/g, " ");
32567
+ return String(str || "").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x9F]/g, "").replace(/\r+/g, "\n").replace(/[ \t]+\n/g, "\n").replace(/\n{4,}/g, "\n\n\n");
32551
32568
  }
32552
32569
  function sanitizeTerminalText(str) {
32553
- return stripTerminalNoise(stripAnsi(str));
32570
+ const accumulator = new TerminalTranscriptAccumulator();
32571
+ return stripTerminalNoise(stripAnsi(accumulator.append(str)));
32554
32572
  }
32555
32573
  function listCliScriptNames(scripts) {
32556
32574
  if (!scripts) return [];
@@ -32732,6 +32750,7 @@ Before doing any coordinator work, confirm that the actual callable tool list in
32732
32750
  var os9;
32733
32751
  var path14;
32734
32752
  var import_child_process4;
32753
+ var TerminalTranscriptAccumulator;
32735
32754
  var buildCliSpawnEnv;
32736
32755
  var init_provider_cli_shared = __esm2({
32737
32756
  "src/cli-adapters/provider-cli-shared.ts"() {
@@ -32740,6 +32759,155 @@ Before doing any coordinator work, confirm that the actual callable tool list in
32740
32759
  path14 = __toESM2(require("path"));
32741
32760
  import_child_process4 = require("child_process");
32742
32761
  init_spawn_env();
32762
+ TerminalTranscriptAccumulator = class {
32763
+ lines = [[]];
32764
+ row = 0;
32765
+ col = 0;
32766
+ savedCursor = null;
32767
+ pendingEscape = "";
32768
+ append(data) {
32769
+ const input = this.pendingEscape + String(data || "");
32770
+ this.pendingEscape = "";
32771
+ for (let i = 0; i < input.length; i += 1) {
32772
+ let ch = input[i];
32773
+ if (ch === "\x1B") {
32774
+ const consumed = this.consumeEscape(input.slice(i));
32775
+ if (consumed === 0) {
32776
+ this.pendingEscape = input.slice(i);
32777
+ break;
32778
+ }
32779
+ i += consumed - 1;
32780
+ continue;
32781
+ }
32782
+ const cp = input.codePointAt(i);
32783
+ if (cp && cp > 65535) {
32784
+ ch = String.fromCodePoint(cp);
32785
+ i += 1;
32786
+ }
32787
+ this.writeControlOrChar(ch);
32788
+ }
32789
+ return this.getText();
32790
+ }
32791
+ reset() {
32792
+ this.lines = [[]];
32793
+ this.row = 0;
32794
+ this.col = 0;
32795
+ this.savedCursor = null;
32796
+ this.pendingEscape = "";
32797
+ }
32798
+ getText() {
32799
+ return this.lines.map((line) => line.join("").replace(/[ \t]+$/g, "")).join("\n");
32800
+ }
32801
+ ensureRow(row = this.row) {
32802
+ while (this.lines.length <= row) this.lines.push([]);
32803
+ }
32804
+ writeControlOrChar(ch) {
32805
+ if (ch === "\r") {
32806
+ this.col = 0;
32807
+ return;
32808
+ }
32809
+ if (ch === "\n") {
32810
+ this.row += 1;
32811
+ this.col = 0;
32812
+ this.ensureRow();
32813
+ return;
32814
+ }
32815
+ if (ch === "\b") {
32816
+ this.col = Math.max(0, this.col - 1);
32817
+ return;
32818
+ }
32819
+ if (ch < " " || ch === "\x7F") return;
32820
+ this.ensureRow();
32821
+ const line = this.lines[this.row];
32822
+ if (isCombiningMark(ch) && this.col > 0) {
32823
+ line[this.col - 1] = `${line[this.col - 1] || ""}${ch}`;
32824
+ return;
32825
+ }
32826
+ while (line.length < this.col) line.push(" ");
32827
+ line[this.col] = ch;
32828
+ this.col += isWideCodePoint(ch) ? 2 : 1;
32829
+ }
32830
+ consumeEscape(seq) {
32831
+ if (seq.length < 2) return 0;
32832
+ const next = seq[1];
32833
+ if (next === "7") {
32834
+ this.savedCursor = { row: this.row, col: this.col };
32835
+ return 2;
32836
+ }
32837
+ if (next === "8") {
32838
+ if (this.savedCursor) {
32839
+ this.row = this.savedCursor.row;
32840
+ this.col = this.savedCursor.col;
32841
+ this.ensureRow();
32842
+ }
32843
+ return 2;
32844
+ }
32845
+ if (next === "]") {
32846
+ const bel = seq.indexOf("\x07", 2);
32847
+ const st2 = seq.indexOf("\x1B\\", 2);
32848
+ const end = bel >= 0 && (st2 < 0 || bel < st2) ? bel + 1 : st2 >= 0 ? st2 + 2 : 0;
32849
+ return end;
32850
+ }
32851
+ if (next === "[") {
32852
+ const match = seq.match(/^\x1B\[([0-?]*)([ -/]*)([@-~])/);
32853
+ if (!match) return seq.length < 32 ? 0 : 1;
32854
+ this.applyCsi(match[1] || "", match[3]);
32855
+ return match[0].length;
32856
+ }
32857
+ if (/[P^_X]/.test(next)) {
32858
+ const bel = seq.indexOf("\x07", 2);
32859
+ const st2 = seq.indexOf("\x1B\\", 2);
32860
+ const end = bel >= 0 && (st2 < 0 || bel < st2) ? bel + 1 : st2 >= 0 ? st2 + 2 : 0;
32861
+ return end;
32862
+ }
32863
+ return 2;
32864
+ }
32865
+ applyCsi(params, final) {
32866
+ const count = parseCount(params);
32867
+ this.ensureRow();
32868
+ if (final === "A") this.row = Math.max(0, this.row - count);
32869
+ else if (final === "B") this.row += count;
32870
+ else if (final === "C") this.col += count;
32871
+ else if (final === "D") this.col = Math.max(0, this.col - count);
32872
+ else if (final === "G") this.col = Math.max(0, count - 1);
32873
+ else if (final === "H" || final === "f") {
32874
+ const parts = String(params || "").split(";");
32875
+ this.row = Math.max(0, (Number(parts[0] || 1) || 1) - 1);
32876
+ this.col = Math.max(0, (Number(parts[1] || 1) || 1) - 1);
32877
+ } else if (final === "J") {
32878
+ const mode = Number(params || 0) || 0;
32879
+ if (mode === 2 || mode === 3) {
32880
+ this.lines = [[]];
32881
+ this.row = 0;
32882
+ this.col = 0;
32883
+ } else if (mode === 0) {
32884
+ this.lines[this.row] = this.lines[this.row].slice(0, this.col);
32885
+ this.lines.splice(this.row + 1);
32886
+ } else if (mode === 1) {
32887
+ for (let r = 0; r < this.row; r += 1) this.lines[r] = [];
32888
+ const line = this.lines[this.row];
32889
+ for (let c = 0; c <= Math.min(this.col, line.length - 1); c += 1) line[c] = " ";
32890
+ }
32891
+ } else if (final === "K") {
32892
+ const mode = Number(params || 0) || 0;
32893
+ const line = this.lines[this.row];
32894
+ if (mode === 2) this.lines[this.row] = [];
32895
+ else if (mode === 1) {
32896
+ for (let c = 0; c <= Math.min(this.col, line.length - 1); c += 1) line[c] = " ";
32897
+ } else {
32898
+ this.lines[this.row] = line.slice(0, this.col);
32899
+ }
32900
+ } else if (final === "s") {
32901
+ this.savedCursor = { row: this.row, col: this.col };
32902
+ } else if (final === "u") {
32903
+ if (this.savedCursor) {
32904
+ this.row = this.savedCursor.row;
32905
+ this.col = this.savedCursor.col;
32906
+ }
32907
+ }
32908
+ this.ensureRow();
32909
+ }
32910
+ };
32743
32911
  buildCliSpawnEnv = import_session_host_core3.sanitizeSpawnEnv;
32744
32912
  }
32745
32913
  });
@@ -33082,8 +33250,10 @@ Before doing any coordinator work, confirm that the actual callable tool list in
33082
33250
  // ─── CLI Scripts (script-based parsing) ───
33083
33251
  cliScripts;
33084
33252
  runtimeSettings = {};
33085
- /** Full accumulated ANSI-stripped PTY output */
33253
+ /** Full accumulated rendered PTY transcript for parser/readback use */
33086
33254
  accumulatedBuffer = "";
33255
+ /** Stateful rendered transcript accumulator; raw debug remains in accumulatedRawBuffer. */
33256
+ transcriptAccumulator = new TerminalTranscriptAccumulator();
33087
33257
  /** Full accumulated raw PTY output (with ANSI) */
33088
33258
  accumulatedRawBuffer = "";
33089
33259
  /** Current visible terminal screen snapshot */
@@ -33149,6 +33319,7 @@ ${lastSnapshot}`;
33149
33319
  }
33150
33320
  resetTerminalScreen(rows, cols) {
33151
33321
  this.terminalScreen.reset(rows, cols);
33322
+ this.transcriptAccumulator.reset();
33152
33323
  this.lastScreenText = "";
33153
33324
  this.lastScreenSnapshot = "";
33154
33325
  this.lastScreenChangeAt = 0;
@@ -33407,6 +33578,7 @@ ${lastSnapshot}`;
33407
33578
  handleOutput(rawData) {
33408
33579
  this.terminalScreen.write(rawData);
33409
33580
  const cleanData = sanitizeTerminalText(rawData);
33581
+ const renderedTranscript = this.transcriptAccumulator.append(rawData);
33410
33582
  const now = Date.now();
33411
33583
  const shouldReadScreen = this.shouldReadTerminalScreenSnapshot(now);
33412
33584
  const screenText = shouldReadScreen ? this.readTerminalScreenText(now) : this.lastScreenText;
@@ -33447,13 +33619,14 @@ ${lastSnapshot}`;
33447
33619
  }
33448
33620
  }
33449
33621
  const prevRecentLen = this.recentOutputBuffer.length;
33450
- const prevAccumulatedLen = this.accumulatedBuffer.length;
33451
33622
  const prevAccumulatedRawLen = this.accumulatedRawBuffer.length;
33452
- this.recentOutputBuffer = appendBoundedText(this.recentOutputBuffer, cleanData, _ProviderCliAdapter.MAX_RECENT_OUTPUT_BUFFER);
33453
- this.accumulatedBuffer = appendBoundedText(this.accumulatedBuffer, cleanData, _ProviderCliAdapter.MAX_ACCUMULATED_BUFFER);
33623
+ const nextAccumulatedBuffer = renderedTranscript.length <= _ProviderCliAdapter.MAX_ACCUMULATED_BUFFER ? renderedTranscript : renderedTranscript.slice(-_ProviderCliAdapter.MAX_ACCUMULATED_BUFFER);
33624
+ const nextRecentOutputBuffer = nextAccumulatedBuffer.slice(-_ProviderCliAdapter.MAX_RECENT_OUTPUT_BUFFER);
33625
+ this.recentOutputBuffer = nextRecentOutputBuffer;
33626
+ this.accumulatedBuffer = nextAccumulatedBuffer;
33454
33627
  this.accumulatedRawBuffer = appendBoundedText(this.accumulatedRawBuffer, rawData, _ProviderCliAdapter.MAX_ACCUMULATED_BUFFER);
33455
- const droppedRecent = this.recordBoundedAppendDrop(prevRecentLen, cleanData.length, this.recentOutputBuffer.length);
33456
- const droppedClean = this.recordBoundedAppendDrop(prevAccumulatedLen, cleanData.length, this.accumulatedBuffer.length);
33628
+ const droppedRecent = Math.max(0, prevRecentLen - this.recentOutputBuffer.length);
33629
+ const droppedClean = Math.max(0, renderedTranscript.length - this.accumulatedBuffer.length);
33457
33630
  const droppedRaw = this.recordBoundedAppendDrop(prevAccumulatedRawLen, rawData.length, this.accumulatedRawBuffer.length);
33458
33631
  this.recentOutputDroppedChars += droppedRecent;
33459
33632
  this.accumulatedBufferDroppedChars += droppedClean;
@@ -52241,6 +52414,15 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
52241
52414
  function readNonEmptyString(value) {
52242
52415
  return typeof value === "string" && value.trim() ? value.trim() : "";
52243
52416
  }
52417
+ var MESH_COORDINATOR_EVENTS = /* @__PURE__ */ new Set([
52418
+ "agent:generating_completed",
52419
+ "agent:waiting_approval",
52420
+ "agent:stopped",
52421
+ "monitor:long_generating"
52422
+ ]);
52423
+ function isMeshCoordinatorEvent(eventName) {
52424
+ return typeof eventName === "string" && MESH_COORDINATOR_EVENTS.has(eventName);
52425
+ }
52244
52426
  function formatCompletionMetadata(event) {
52245
52427
  const parts = [
52246
52428
  readNonEmptyString(event.targetSessionId) ? `session_id=${readNonEmptyString(event.targetSessionId)}` : "",
@@ -52257,6 +52439,12 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
52257
52439
  if (args.event === "agent:waiting_approval") {
52258
52440
  return `[System] ${args.nodeLabel} is waiting for approval to proceed${metadata}. You may use mesh_read_chat and mesh_approve to handle it.`;
52259
52441
  }
52442
+ if (args.event === "agent:stopped") {
52443
+ return `[System] ${args.nodeLabel} has stopped${metadata}. Use mesh_read_chat once if you need to inspect its last output.`;
52444
+ }
52445
+ if (args.event === "monitor:long_generating") {
52446
+ return `[System] ${args.nodeLabel} has been generating for a long time${metadata}. Use mesh_read_chat once for a status check, but do not poll repeatedly.`;
52447
+ }
52260
52448
  return "";
52261
52449
  }
52262
52450
  function injectMeshSystemMessage(components, args) {
@@ -52282,7 +52470,7 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
52282
52470
  }
52283
52471
  function handleMeshForwardEvent(components, payload) {
52284
52472
  const eventName = readNonEmptyString(payload.event);
52285
- if (eventName !== "agent:generating_completed" && eventName !== "agent:waiting_approval") {
52473
+ if (!isMeshCoordinatorEvent(eventName)) {
52286
52474
  return { success: false, error: "unsupported mesh event" };
52287
52475
  }
52288
52476
  const meshId = readNonEmptyString(payload.meshId);
@@ -52303,7 +52491,7 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
52303
52491
  }
52304
52492
  function setupMeshEventForwarding(components) {
52305
52493
  components.instanceManager.onEvent((event) => {
52306
- if (event.event !== "agent:generating_completed" && event.event !== "agent:waiting_approval") return;
52494
+ if (!isMeshCoordinatorEvent(event.event)) return;
52307
52495
  const instanceId = readNonEmptyString(event.instanceId);
52308
52496
  if (!instanceId) return;
52309
52497
  const sourceInstance = components.instanceManager.getInstance(instanceId);