adhdev 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/cli/index.js CHANGED
@@ -566,6 +566,7 @@ var init_repo_mesh_types = __esm({
566
566
  requireApprovalForDestructiveGit: true,
567
567
  dirtyWorkspaceBehavior: "warn",
568
568
  maxParallelTasks: 2,
569
+ spawnedSessionVisibility: "visible",
569
570
  sessionCleanupOnNodeRemove: "preserve"
570
571
  };
571
572
  }
@@ -2890,6 +2891,9 @@ function mergeMeshPolicy(base, patch) {
2890
2891
  if (!SESSION_CLEANUP_MODES.has(String(policy.sessionCleanupOnNodeRemove))) {
2891
2892
  policy.sessionCleanupOnNodeRemove = "preserve";
2892
2893
  }
2894
+ if (!SPAWNED_SESSION_VISIBILITY_MODES.has(String(policy.spawnedSessionVisibility))) {
2895
+ policy.spawnedSessionVisibility = "visible";
2896
+ }
2893
2897
  return policy;
2894
2898
  }
2895
2899
  function listMeshes() {
@@ -2994,7 +2998,7 @@ function updateNode(meshId, nodeId, opts) {
2994
2998
  saveMeshConfig(config2);
2995
2999
  return node;
2996
3000
  }
2997
- var import_fs2, import_path2, import_crypto3, SESSION_CLEANUP_MODES;
3001
+ var import_fs2, import_path2, import_crypto3, SESSION_CLEANUP_MODES, SPAWNED_SESSION_VISIBILITY_MODES;
2998
3002
  var init_mesh_config = __esm({
2999
3003
  "../../oss/packages/daemon-core/src/config/mesh-config.ts"() {
3000
3004
  "use strict";
@@ -3004,6 +3008,7 @@ var init_mesh_config = __esm({
3004
3008
  init_config();
3005
3009
  init_repo_mesh_types();
3006
3010
  SESSION_CLEANUP_MODES = /* @__PURE__ */ new Set(["preserve", "stop", "delete_stopped", "stop_and_delete"]);
3011
+ SPAWNED_SESSION_VISIBILITY_MODES = /* @__PURE__ */ new Set(["visible", "hidden"]);
3007
3012
  }
3008
3013
  });
3009
3014
 
@@ -14654,13 +14659,25 @@ var init_pty_transport = __esm({
14654
14659
 
14655
14660
  // ../../oss/packages/daemon-core/src/cli-adapters/provider-cli-shared.ts
14656
14661
  function stripAnsi(str2) {
14657
- return str2.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, " ");
14662
+ return str2.replace(/\x1B\][^\x07]*(?:\x07|\x1B\\)/g, "").replace(/\x1B[P^_X][\s\S]*?(?:\x07|\x1B\\)/g, "").replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g, "");
14663
+ }
14664
+ function parseCount(params, fallback2 = 1) {
14665
+ const first = Number(String(params || "").split(";")[0] || fallback2);
14666
+ return Math.max(1, Number.isFinite(first) ? first : fallback2);
14667
+ }
14668
+ function isCombiningMark(ch) {
14669
+ return /[\u0300-\u036F\u1AB0-\u1AFF\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/.test(ch);
14670
+ }
14671
+ function isWideCodePoint(ch) {
14672
+ const cp = ch.codePointAt(0) || 0;
14673
+ 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);
14658
14674
  }
14659
14675
  function stripTerminalNoise(str2) {
14660
- return String(str2 || "").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, " ");
14676
+ return String(str2 || "").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");
14661
14677
  }
14662
14678
  function sanitizeTerminalText(str2) {
14663
- return stripTerminalNoise(stripAnsi(str2));
14679
+ const accumulator = new TerminalTranscriptAccumulator();
14680
+ return stripTerminalNoise(stripAnsi(accumulator.append(str2)));
14664
14681
  }
14665
14682
  function listCliScriptNames(scripts) {
14666
14683
  if (!scripts) return [];
@@ -14839,7 +14856,7 @@ function normalizeCliProviderForRuntime(raw) {
14839
14856
  }
14840
14857
  };
14841
14858
  }
14842
- var os12, path15, import_child_process4, buildCliSpawnEnv;
14859
+ var os12, path15, import_child_process4, TerminalTranscriptAccumulator, buildCliSpawnEnv;
14843
14860
  var init_provider_cli_shared = __esm({
14844
14861
  "../../oss/packages/daemon-core/src/cli-adapters/provider-cli-shared.ts"() {
14845
14862
  "use strict";
@@ -14847,6 +14864,155 @@ var init_provider_cli_shared = __esm({
14847
14864
  path15 = __toESM(require("path"));
14848
14865
  import_child_process4 = require("child_process");
14849
14866
  init_spawn_env();
14867
+ TerminalTranscriptAccumulator = class {
14868
+ lines = [[]];
14869
+ row = 0;
14870
+ col = 0;
14871
+ savedCursor = null;
14872
+ pendingEscape = "";
14873
+ append(data) {
14874
+ const input = this.pendingEscape + String(data || "");
14875
+ this.pendingEscape = "";
14876
+ for (let i = 0; i < input.length; i += 1) {
14877
+ let ch = input[i];
14878
+ if (ch === "\x1B") {
14879
+ const consumed = this.consumeEscape(input.slice(i));
14880
+ if (consumed === 0) {
14881
+ this.pendingEscape = input.slice(i);
14882
+ break;
14883
+ }
14884
+ i += consumed - 1;
14885
+ continue;
14886
+ }
14887
+ const cp = input.codePointAt(i);
14888
+ if (cp && cp > 65535) {
14889
+ ch = String.fromCodePoint(cp);
14890
+ i += 1;
14891
+ }
14892
+ this.writeControlOrChar(ch);
14893
+ }
14894
+ return this.getText();
14895
+ }
14896
+ reset() {
14897
+ this.lines = [[]];
14898
+ this.row = 0;
14899
+ this.col = 0;
14900
+ this.savedCursor = null;
14901
+ this.pendingEscape = "";
14902
+ }
14903
+ getText() {
14904
+ return this.lines.map((line) => line.join("").replace(/[ \t]+$/g, "")).join("\n");
14905
+ }
14906
+ ensureRow(row = this.row) {
14907
+ while (this.lines.length <= row) this.lines.push([]);
14908
+ }
14909
+ writeControlOrChar(ch) {
14910
+ if (ch === "\r") {
14911
+ this.col = 0;
14912
+ return;
14913
+ }
14914
+ if (ch === "\n") {
14915
+ this.row += 1;
14916
+ this.col = 0;
14917
+ this.ensureRow();
14918
+ return;
14919
+ }
14920
+ if (ch === "\b") {
14921
+ this.col = Math.max(0, this.col - 1);
14922
+ return;
14923
+ }
14924
+ if (ch < " " || ch === "\x7F") return;
14925
+ this.ensureRow();
14926
+ const line = this.lines[this.row];
14927
+ if (isCombiningMark(ch) && this.col > 0) {
14928
+ line[this.col - 1] = `${line[this.col - 1] || ""}${ch}`;
14929
+ return;
14930
+ }
14931
+ while (line.length < this.col) line.push(" ");
14932
+ line[this.col] = ch;
14933
+ this.col += isWideCodePoint(ch) ? 2 : 1;
14934
+ }
14935
+ consumeEscape(seq2) {
14936
+ if (seq2.length < 2) return 0;
14937
+ const next = seq2[1];
14938
+ if (next === "7") {
14939
+ this.savedCursor = { row: this.row, col: this.col };
14940
+ return 2;
14941
+ }
14942
+ if (next === "8") {
14943
+ if (this.savedCursor) {
14944
+ this.row = this.savedCursor.row;
14945
+ this.col = this.savedCursor.col;
14946
+ this.ensureRow();
14947
+ }
14948
+ return 2;
14949
+ }
14950
+ if (next === "]") {
14951
+ const bel = seq2.indexOf("\x07", 2);
14952
+ const st = seq2.indexOf("\x1B\\", 2);
14953
+ const end = bel >= 0 && (st < 0 || bel < st) ? bel + 1 : st >= 0 ? st + 2 : 0;
14954
+ return end;
14955
+ }
14956
+ if (next === "[") {
14957
+ const match = seq2.match(/^\x1B\[([0-?]*)([ -/]*)([@-~])/);
14958
+ if (!match) return seq2.length < 32 ? 0 : 1;
14959
+ this.applyCsi(match[1] || "", match[3]);
14960
+ return match[0].length;
14961
+ }
14962
+ if (/[P^_X]/.test(next)) {
14963
+ const bel = seq2.indexOf("\x07", 2);
14964
+ const st = seq2.indexOf("\x1B\\", 2);
14965
+ const end = bel >= 0 && (st < 0 || bel < st) ? bel + 1 : st >= 0 ? st + 2 : 0;
14966
+ return end;
14967
+ }
14968
+ return 2;
14969
+ }
14970
+ applyCsi(params, final) {
14971
+ const count = parseCount(params);
14972
+ this.ensureRow();
14973
+ if (final === "A") this.row = Math.max(0, this.row - count);
14974
+ else if (final === "B") this.row += count;
14975
+ else if (final === "C") this.col += count;
14976
+ else if (final === "D") this.col = Math.max(0, this.col - count);
14977
+ else if (final === "G") this.col = Math.max(0, count - 1);
14978
+ else if (final === "H" || final === "f") {
14979
+ const parts = String(params || "").split(";");
14980
+ this.row = Math.max(0, (Number(parts[0] || 1) || 1) - 1);
14981
+ this.col = Math.max(0, (Number(parts[1] || 1) || 1) - 1);
14982
+ } else if (final === "J") {
14983
+ const mode = Number(params || 0) || 0;
14984
+ if (mode === 2 || mode === 3) {
14985
+ this.lines = [[]];
14986
+ this.row = 0;
14987
+ this.col = 0;
14988
+ } else if (mode === 0) {
14989
+ this.lines[this.row] = this.lines[this.row].slice(0, this.col);
14990
+ this.lines.splice(this.row + 1);
14991
+ } else if (mode === 1) {
14992
+ for (let r = 0; r < this.row; r += 1) this.lines[r] = [];
14993
+ const line = this.lines[this.row];
14994
+ for (let c = 0; c <= Math.min(this.col, line.length - 1); c += 1) line[c] = " ";
14995
+ }
14996
+ } else if (final === "K") {
14997
+ const mode = Number(params || 0) || 0;
14998
+ const line = this.lines[this.row];
14999
+ if (mode === 2) this.lines[this.row] = [];
15000
+ else if (mode === 1) {
15001
+ for (let c = 0; c <= Math.min(this.col, line.length - 1); c += 1) line[c] = " ";
15002
+ } else {
15003
+ this.lines[this.row] = line.slice(0, this.col);
15004
+ }
15005
+ } else if (final === "s") {
15006
+ this.savedCursor = { row: this.row, col: this.col };
15007
+ } else if (final === "u") {
15008
+ if (this.savedCursor) {
15009
+ this.row = this.savedCursor.row;
15010
+ this.col = this.savedCursor.col;
15011
+ }
15012
+ }
15013
+ this.ensureRow();
15014
+ }
15015
+ };
14850
15016
  buildCliSpawnEnv = sanitizeSpawnEnv;
14851
15017
  }
14852
15018
  });
@@ -15194,8 +15360,10 @@ var init_provider_cli_adapter = __esm({
15194
15360
  // ─── CLI Scripts (script-based parsing) ───
15195
15361
  cliScripts;
15196
15362
  runtimeSettings = {};
15197
- /** Full accumulated ANSI-stripped PTY output */
15363
+ /** Full accumulated rendered PTY transcript for parser/readback use */
15198
15364
  accumulatedBuffer = "";
15365
+ /** Stateful rendered transcript accumulator; raw debug remains in accumulatedRawBuffer. */
15366
+ transcriptAccumulator = new TerminalTranscriptAccumulator();
15199
15367
  /** Full accumulated raw PTY output (with ANSI) */
15200
15368
  accumulatedRawBuffer = "";
15201
15369
  /** Current visible terminal screen snapshot */
@@ -15261,6 +15429,7 @@ ${lastSnapshot}`;
15261
15429
  }
15262
15430
  resetTerminalScreen(rows, cols) {
15263
15431
  this.terminalScreen.reset(rows, cols);
15432
+ this.transcriptAccumulator.reset();
15264
15433
  this.lastScreenText = "";
15265
15434
  this.lastScreenSnapshot = "";
15266
15435
  this.lastScreenChangeAt = 0;
@@ -15519,6 +15688,7 @@ ${lastSnapshot}`;
15519
15688
  handleOutput(rawData) {
15520
15689
  this.terminalScreen.write(rawData);
15521
15690
  const cleanData = sanitizeTerminalText(rawData);
15691
+ const renderedTranscript = this.transcriptAccumulator.append(rawData);
15522
15692
  const now = Date.now();
15523
15693
  const shouldReadScreen = this.shouldReadTerminalScreenSnapshot(now);
15524
15694
  const screenText = shouldReadScreen ? this.readTerminalScreenText(now) : this.lastScreenText;
@@ -15559,13 +15729,14 @@ ${lastSnapshot}`;
15559
15729
  }
15560
15730
  }
15561
15731
  const prevRecentLen = this.recentOutputBuffer.length;
15562
- const prevAccumulatedLen = this.accumulatedBuffer.length;
15563
15732
  const prevAccumulatedRawLen = this.accumulatedRawBuffer.length;
15564
- this.recentOutputBuffer = appendBoundedText(this.recentOutputBuffer, cleanData, _ProviderCliAdapter.MAX_RECENT_OUTPUT_BUFFER);
15565
- this.accumulatedBuffer = appendBoundedText(this.accumulatedBuffer, cleanData, _ProviderCliAdapter.MAX_ACCUMULATED_BUFFER);
15733
+ const nextAccumulatedBuffer = renderedTranscript.length <= _ProviderCliAdapter.MAX_ACCUMULATED_BUFFER ? renderedTranscript : renderedTranscript.slice(-_ProviderCliAdapter.MAX_ACCUMULATED_BUFFER);
15734
+ const nextRecentOutputBuffer = nextAccumulatedBuffer.slice(-_ProviderCliAdapter.MAX_RECENT_OUTPUT_BUFFER);
15735
+ this.recentOutputBuffer = nextRecentOutputBuffer;
15736
+ this.accumulatedBuffer = nextAccumulatedBuffer;
15566
15737
  this.accumulatedRawBuffer = appendBoundedText(this.accumulatedRawBuffer, rawData, _ProviderCliAdapter.MAX_ACCUMULATED_BUFFER);
15567
- const droppedRecent = this.recordBoundedAppendDrop(prevRecentLen, cleanData.length, this.recentOutputBuffer.length);
15568
- const droppedClean = this.recordBoundedAppendDrop(prevAccumulatedLen, cleanData.length, this.accumulatedBuffer.length);
15738
+ const droppedRecent = Math.max(0, prevRecentLen - this.recentOutputBuffer.length);
15739
+ const droppedClean = Math.max(0, renderedTranscript.length - this.accumulatedBuffer.length);
15569
15740
  const droppedRaw = this.recordBoundedAppendDrop(prevAccumulatedRawLen, rawData.length, this.accumulatedRawBuffer.length);
15570
15741
  this.recentOutputDroppedChars += droppedRecent;
15571
15742
  this.accumulatedBufferDroppedChars += droppedClean;
@@ -43781,6 +43952,9 @@ var init_mesh_coordinator = __esm({
43781
43952
  function readNonEmptyString(value) {
43782
43953
  return typeof value === "string" && value.trim() ? value.trim() : "";
43783
43954
  }
43955
+ function isMeshCoordinatorEvent(eventName) {
43956
+ return typeof eventName === "string" && MESH_COORDINATOR_EVENTS.has(eventName);
43957
+ }
43784
43958
  function formatCompletionMetadata(event) {
43785
43959
  const parts = [
43786
43960
  readNonEmptyString(event.targetSessionId) ? `session_id=${readNonEmptyString(event.targetSessionId)}` : "",
@@ -43797,6 +43971,12 @@ function buildMeshSystemMessage(args) {
43797
43971
  if (args.event === "agent:waiting_approval") {
43798
43972
  return `[System] ${args.nodeLabel} is waiting for approval to proceed${metadata}. You may use mesh_read_chat and mesh_approve to handle it.`;
43799
43973
  }
43974
+ if (args.event === "agent:stopped") {
43975
+ return `[System] ${args.nodeLabel} has stopped${metadata}. Use mesh_read_chat once if you need to inspect its last output.`;
43976
+ }
43977
+ if (args.event === "monitor:long_generating") {
43978
+ 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.`;
43979
+ }
43800
43980
  return "";
43801
43981
  }
43802
43982
  function injectMeshSystemMessage(components, args) {
@@ -43822,7 +44002,7 @@ function injectMeshSystemMessage(components, args) {
43822
44002
  }
43823
44003
  function handleMeshForwardEvent(components, payload) {
43824
44004
  const eventName = readNonEmptyString(payload.event);
43825
- if (eventName !== "agent:generating_completed" && eventName !== "agent:waiting_approval") {
44005
+ if (!isMeshCoordinatorEvent(eventName)) {
43826
44006
  return { success: false, error: "unsupported mesh event" };
43827
44007
  }
43828
44008
  const meshId = readNonEmptyString(payload.meshId);
@@ -43843,7 +44023,7 @@ function handleMeshForwardEvent(components, payload) {
43843
44023
  }
43844
44024
  function setupMeshEventForwarding(components) {
43845
44025
  components.instanceManager.onEvent((event) => {
43846
- if (event.event !== "agent:generating_completed" && event.event !== "agent:waiting_approval") return;
44026
+ if (!isMeshCoordinatorEvent(event.event)) return;
43847
44027
  const instanceId = readNonEmptyString(event.instanceId);
43848
44028
  if (!instanceId) return;
43849
44029
  const sourceInstance = components.instanceManager.getInstance(instanceId);
@@ -43871,11 +44051,18 @@ function setupMeshEventForwarding(components) {
43871
44051
  });
43872
44052
  });
43873
44053
  }
44054
+ var MESH_COORDINATOR_EVENTS;
43874
44055
  var init_mesh_events = __esm({
43875
44056
  "../../oss/packages/daemon-core/src/mesh/mesh-events.ts"() {
43876
44057
  "use strict";
43877
44058
  init_mesh_config();
43878
44059
  init_logger();
44060
+ MESH_COORDINATOR_EVENTS = /* @__PURE__ */ new Set([
44061
+ "agent:generating_completed",
44062
+ "agent:waiting_approval",
44063
+ "agent:stopped",
44064
+ "monitor:long_generating"
44065
+ ]);
43879
44066
  }
43880
44067
  });
43881
44068
 
@@ -94632,7 +94819,7 @@ var init_adhdev_daemon = __esm({
94632
94819
  init_version();
94633
94820
  init_src();
94634
94821
  init_runtime_defaults();
94635
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.76-rc.65" });
94822
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.76-rc.68" });
94636
94823
  AdhdevDaemon = class _AdhdevDaemon {
94637
94824
  localHttpServer = null;
94638
94825
  localWss = null;
@@ -95486,7 +95673,8 @@ ${err?.stack || ""}`);
95486
95673
  return typeof value === "string" && value.trim() ? value.trim() : "";
95487
95674
  }
95488
95675
  async relayRemoteMeshCoordinatorEvent(event, localDaemonId) {
95489
- if (event.event !== "agent:generating_completed" && event.event !== "agent:waiting_approval") return;
95676
+ const coordinatorEvents = /* @__PURE__ */ new Set(["agent:generating_completed", "agent:waiting_approval", "agent:stopped", "monitor:long_generating"]);
95677
+ if (!coordinatorEvents.has(this.readMeshString(event.event))) return;
95490
95678
  if (!this.meshManager || !this.components) return;
95491
95679
  const instanceId = this.readMeshString(event.instanceId);
95492
95680
  if (!instanceId) return;