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/index.js CHANGED
@@ -46,6 +46,7 @@ var init_repo_mesh_types = __esm({
46
46
  requireApprovalForDestructiveGit: true,
47
47
  dirtyWorkspaceBehavior: "warn",
48
48
  maxParallelTasks: 2,
49
+ spawnedSessionVisibility: "visible",
49
50
  sessionCleanupOnNodeRemove: "preserve"
50
51
  };
51
52
  }
@@ -2370,6 +2371,9 @@ function mergeMeshPolicy(base, patch) {
2370
2371
  if (!SESSION_CLEANUP_MODES.has(String(policy.sessionCleanupOnNodeRemove))) {
2371
2372
  policy.sessionCleanupOnNodeRemove = "preserve";
2372
2373
  }
2374
+ if (!SPAWNED_SESSION_VISIBILITY_MODES.has(String(policy.spawnedSessionVisibility))) {
2375
+ policy.spawnedSessionVisibility = "visible";
2376
+ }
2373
2377
  return policy;
2374
2378
  }
2375
2379
  function listMeshes() {
@@ -2474,7 +2478,7 @@ function updateNode(meshId, nodeId, opts) {
2474
2478
  saveMeshConfig(config2);
2475
2479
  return node;
2476
2480
  }
2477
- var import_fs2, import_path2, import_crypto3, SESSION_CLEANUP_MODES;
2481
+ var import_fs2, import_path2, import_crypto3, SESSION_CLEANUP_MODES, SPAWNED_SESSION_VISIBILITY_MODES;
2478
2482
  var init_mesh_config = __esm({
2479
2483
  "../../oss/packages/daemon-core/src/config/mesh-config.ts"() {
2480
2484
  "use strict";
@@ -2484,6 +2488,7 @@ var init_mesh_config = __esm({
2484
2488
  init_config();
2485
2489
  init_repo_mesh_types();
2486
2490
  SESSION_CLEANUP_MODES = /* @__PURE__ */ new Set(["preserve", "stop", "delete_stopped", "stop_and_delete"]);
2491
+ SPAWNED_SESSION_VISIBILITY_MODES = /* @__PURE__ */ new Set(["visible", "hidden"]);
2487
2492
  }
2488
2493
  });
2489
2494
 
@@ -13675,13 +13680,25 @@ var init_pty_transport = __esm({
13675
13680
 
13676
13681
  // ../../oss/packages/daemon-core/src/cli-adapters/provider-cli-shared.ts
13677
13682
  function stripAnsi(str2) {
13678
- 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, " ");
13683
+ return str2.replace(/\x1B\][^\x07]*(?:\x07|\x1B\\)/g, "").replace(/\x1B[P^_X][\s\S]*?(?:\x07|\x1B\\)/g, "").replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g, "");
13684
+ }
13685
+ function parseCount(params, fallback2 = 1) {
13686
+ const first = Number(String(params || "").split(";")[0] || fallback2);
13687
+ return Math.max(1, Number.isFinite(first) ? first : fallback2);
13688
+ }
13689
+ function isCombiningMark(ch) {
13690
+ return /[\u0300-\u036F\u1AB0-\u1AFF\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/.test(ch);
13691
+ }
13692
+ function isWideCodePoint(ch) {
13693
+ const cp = ch.codePointAt(0) || 0;
13694
+ 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);
13679
13695
  }
13680
13696
  function stripTerminalNoise(str2) {
13681
- 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, " ");
13697
+ 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");
13682
13698
  }
13683
13699
  function sanitizeTerminalText(str2) {
13684
- return stripTerminalNoise(stripAnsi(str2));
13700
+ const accumulator = new TerminalTranscriptAccumulator();
13701
+ return stripTerminalNoise(stripAnsi(accumulator.append(str2)));
13685
13702
  }
13686
13703
  function listCliScriptNames(scripts) {
13687
13704
  if (!scripts) return [];
@@ -13860,7 +13877,7 @@ function normalizeCliProviderForRuntime(raw) {
13860
13877
  }
13861
13878
  };
13862
13879
  }
13863
- var os11, path14, import_child_process4, buildCliSpawnEnv;
13880
+ var os11, path14, import_child_process4, TerminalTranscriptAccumulator, buildCliSpawnEnv;
13864
13881
  var init_provider_cli_shared = __esm({
13865
13882
  "../../oss/packages/daemon-core/src/cli-adapters/provider-cli-shared.ts"() {
13866
13883
  "use strict";
@@ -13868,6 +13885,155 @@ var init_provider_cli_shared = __esm({
13868
13885
  path14 = __toESM(require("path"));
13869
13886
  import_child_process4 = require("child_process");
13870
13887
  init_spawn_env();
13888
+ TerminalTranscriptAccumulator = class {
13889
+ lines = [[]];
13890
+ row = 0;
13891
+ col = 0;
13892
+ savedCursor = null;
13893
+ pendingEscape = "";
13894
+ append(data) {
13895
+ const input = this.pendingEscape + String(data || "");
13896
+ this.pendingEscape = "";
13897
+ for (let i = 0; i < input.length; i += 1) {
13898
+ let ch = input[i];
13899
+ if (ch === "\x1B") {
13900
+ const consumed = this.consumeEscape(input.slice(i));
13901
+ if (consumed === 0) {
13902
+ this.pendingEscape = input.slice(i);
13903
+ break;
13904
+ }
13905
+ i += consumed - 1;
13906
+ continue;
13907
+ }
13908
+ const cp = input.codePointAt(i);
13909
+ if (cp && cp > 65535) {
13910
+ ch = String.fromCodePoint(cp);
13911
+ i += 1;
13912
+ }
13913
+ this.writeControlOrChar(ch);
13914
+ }
13915
+ return this.getText();
13916
+ }
13917
+ reset() {
13918
+ this.lines = [[]];
13919
+ this.row = 0;
13920
+ this.col = 0;
13921
+ this.savedCursor = null;
13922
+ this.pendingEscape = "";
13923
+ }
13924
+ getText() {
13925
+ return this.lines.map((line) => line.join("").replace(/[ \t]+$/g, "")).join("\n");
13926
+ }
13927
+ ensureRow(row = this.row) {
13928
+ while (this.lines.length <= row) this.lines.push([]);
13929
+ }
13930
+ writeControlOrChar(ch) {
13931
+ if (ch === "\r") {
13932
+ this.col = 0;
13933
+ return;
13934
+ }
13935
+ if (ch === "\n") {
13936
+ this.row += 1;
13937
+ this.col = 0;
13938
+ this.ensureRow();
13939
+ return;
13940
+ }
13941
+ if (ch === "\b") {
13942
+ this.col = Math.max(0, this.col - 1);
13943
+ return;
13944
+ }
13945
+ if (ch < " " || ch === "\x7F") return;
13946
+ this.ensureRow();
13947
+ const line = this.lines[this.row];
13948
+ if (isCombiningMark(ch) && this.col > 0) {
13949
+ line[this.col - 1] = `${line[this.col - 1] || ""}${ch}`;
13950
+ return;
13951
+ }
13952
+ while (line.length < this.col) line.push(" ");
13953
+ line[this.col] = ch;
13954
+ this.col += isWideCodePoint(ch) ? 2 : 1;
13955
+ }
13956
+ consumeEscape(seq2) {
13957
+ if (seq2.length < 2) return 0;
13958
+ const next = seq2[1];
13959
+ if (next === "7") {
13960
+ this.savedCursor = { row: this.row, col: this.col };
13961
+ return 2;
13962
+ }
13963
+ if (next === "8") {
13964
+ if (this.savedCursor) {
13965
+ this.row = this.savedCursor.row;
13966
+ this.col = this.savedCursor.col;
13967
+ this.ensureRow();
13968
+ }
13969
+ return 2;
13970
+ }
13971
+ if (next === "]") {
13972
+ const bel = seq2.indexOf("\x07", 2);
13973
+ const st = seq2.indexOf("\x1B\\", 2);
13974
+ const end = bel >= 0 && (st < 0 || bel < st) ? bel + 1 : st >= 0 ? st + 2 : 0;
13975
+ return end;
13976
+ }
13977
+ if (next === "[") {
13978
+ const match = seq2.match(/^\x1B\[([0-?]*)([ -/]*)([@-~])/);
13979
+ if (!match) return seq2.length < 32 ? 0 : 1;
13980
+ this.applyCsi(match[1] || "", match[3]);
13981
+ return match[0].length;
13982
+ }
13983
+ if (/[P^_X]/.test(next)) {
13984
+ const bel = seq2.indexOf("\x07", 2);
13985
+ const st = seq2.indexOf("\x1B\\", 2);
13986
+ const end = bel >= 0 && (st < 0 || bel < st) ? bel + 1 : st >= 0 ? st + 2 : 0;
13987
+ return end;
13988
+ }
13989
+ return 2;
13990
+ }
13991
+ applyCsi(params, final) {
13992
+ const count = parseCount(params);
13993
+ this.ensureRow();
13994
+ if (final === "A") this.row = Math.max(0, this.row - count);
13995
+ else if (final === "B") this.row += count;
13996
+ else if (final === "C") this.col += count;
13997
+ else if (final === "D") this.col = Math.max(0, this.col - count);
13998
+ else if (final === "G") this.col = Math.max(0, count - 1);
13999
+ else if (final === "H" || final === "f") {
14000
+ const parts = String(params || "").split(";");
14001
+ this.row = Math.max(0, (Number(parts[0] || 1) || 1) - 1);
14002
+ this.col = Math.max(0, (Number(parts[1] || 1) || 1) - 1);
14003
+ } else if (final === "J") {
14004
+ const mode = Number(params || 0) || 0;
14005
+ if (mode === 2 || mode === 3) {
14006
+ this.lines = [[]];
14007
+ this.row = 0;
14008
+ this.col = 0;
14009
+ } else if (mode === 0) {
14010
+ this.lines[this.row] = this.lines[this.row].slice(0, this.col);
14011
+ this.lines.splice(this.row + 1);
14012
+ } else if (mode === 1) {
14013
+ for (let r = 0; r < this.row; r += 1) this.lines[r] = [];
14014
+ const line = this.lines[this.row];
14015
+ for (let c = 0; c <= Math.min(this.col, line.length - 1); c += 1) line[c] = " ";
14016
+ }
14017
+ } else if (final === "K") {
14018
+ const mode = Number(params || 0) || 0;
14019
+ const line = this.lines[this.row];
14020
+ if (mode === 2) this.lines[this.row] = [];
14021
+ else if (mode === 1) {
14022
+ for (let c = 0; c <= Math.min(this.col, line.length - 1); c += 1) line[c] = " ";
14023
+ } else {
14024
+ this.lines[this.row] = line.slice(0, this.col);
14025
+ }
14026
+ } else if (final === "s") {
14027
+ this.savedCursor = { row: this.row, col: this.col };
14028
+ } else if (final === "u") {
14029
+ if (this.savedCursor) {
14030
+ this.row = this.savedCursor.row;
14031
+ this.col = this.savedCursor.col;
14032
+ }
14033
+ }
14034
+ this.ensureRow();
14035
+ }
14036
+ };
13871
14037
  buildCliSpawnEnv = sanitizeSpawnEnv;
13872
14038
  }
13873
14039
  });
@@ -14215,8 +14381,10 @@ var init_provider_cli_adapter = __esm({
14215
14381
  // ─── CLI Scripts (script-based parsing) ───
14216
14382
  cliScripts;
14217
14383
  runtimeSettings = {};
14218
- /** Full accumulated ANSI-stripped PTY output */
14384
+ /** Full accumulated rendered PTY transcript for parser/readback use */
14219
14385
  accumulatedBuffer = "";
14386
+ /** Stateful rendered transcript accumulator; raw debug remains in accumulatedRawBuffer. */
14387
+ transcriptAccumulator = new TerminalTranscriptAccumulator();
14220
14388
  /** Full accumulated raw PTY output (with ANSI) */
14221
14389
  accumulatedRawBuffer = "";
14222
14390
  /** Current visible terminal screen snapshot */
@@ -14282,6 +14450,7 @@ ${lastSnapshot}`;
14282
14450
  }
14283
14451
  resetTerminalScreen(rows, cols) {
14284
14452
  this.terminalScreen.reset(rows, cols);
14453
+ this.transcriptAccumulator.reset();
14285
14454
  this.lastScreenText = "";
14286
14455
  this.lastScreenSnapshot = "";
14287
14456
  this.lastScreenChangeAt = 0;
@@ -14540,6 +14709,7 @@ ${lastSnapshot}`;
14540
14709
  handleOutput(rawData) {
14541
14710
  this.terminalScreen.write(rawData);
14542
14711
  const cleanData = sanitizeTerminalText(rawData);
14712
+ const renderedTranscript = this.transcriptAccumulator.append(rawData);
14543
14713
  const now = Date.now();
14544
14714
  const shouldReadScreen = this.shouldReadTerminalScreenSnapshot(now);
14545
14715
  const screenText = shouldReadScreen ? this.readTerminalScreenText(now) : this.lastScreenText;
@@ -14580,13 +14750,14 @@ ${lastSnapshot}`;
14580
14750
  }
14581
14751
  }
14582
14752
  const prevRecentLen = this.recentOutputBuffer.length;
14583
- const prevAccumulatedLen = this.accumulatedBuffer.length;
14584
14753
  const prevAccumulatedRawLen = this.accumulatedRawBuffer.length;
14585
- this.recentOutputBuffer = appendBoundedText(this.recentOutputBuffer, cleanData, _ProviderCliAdapter.MAX_RECENT_OUTPUT_BUFFER);
14586
- this.accumulatedBuffer = appendBoundedText(this.accumulatedBuffer, cleanData, _ProviderCliAdapter.MAX_ACCUMULATED_BUFFER);
14754
+ const nextAccumulatedBuffer = renderedTranscript.length <= _ProviderCliAdapter.MAX_ACCUMULATED_BUFFER ? renderedTranscript : renderedTranscript.slice(-_ProviderCliAdapter.MAX_ACCUMULATED_BUFFER);
14755
+ const nextRecentOutputBuffer = nextAccumulatedBuffer.slice(-_ProviderCliAdapter.MAX_RECENT_OUTPUT_BUFFER);
14756
+ this.recentOutputBuffer = nextRecentOutputBuffer;
14757
+ this.accumulatedBuffer = nextAccumulatedBuffer;
14587
14758
  this.accumulatedRawBuffer = appendBoundedText(this.accumulatedRawBuffer, rawData, _ProviderCliAdapter.MAX_ACCUMULATED_BUFFER);
14588
- const droppedRecent = this.recordBoundedAppendDrop(prevRecentLen, cleanData.length, this.recentOutputBuffer.length);
14589
- const droppedClean = this.recordBoundedAppendDrop(prevAccumulatedLen, cleanData.length, this.accumulatedBuffer.length);
14759
+ const droppedRecent = Math.max(0, prevRecentLen - this.recentOutputBuffer.length);
14760
+ const droppedClean = Math.max(0, renderedTranscript.length - this.accumulatedBuffer.length);
14590
14761
  const droppedRaw = this.recordBoundedAppendDrop(prevAccumulatedRawLen, rawData.length, this.accumulatedRawBuffer.length);
14591
14762
  this.recentOutputDroppedChars += droppedRecent;
14592
14763
  this.accumulatedBufferDroppedChars += droppedClean;
@@ -42802,6 +42973,9 @@ var init_mesh_coordinator = __esm({
42802
42973
  function readNonEmptyString(value) {
42803
42974
  return typeof value === "string" && value.trim() ? value.trim() : "";
42804
42975
  }
42976
+ function isMeshCoordinatorEvent(eventName) {
42977
+ return typeof eventName === "string" && MESH_COORDINATOR_EVENTS.has(eventName);
42978
+ }
42805
42979
  function formatCompletionMetadata(event) {
42806
42980
  const parts = [
42807
42981
  readNonEmptyString(event.targetSessionId) ? `session_id=${readNonEmptyString(event.targetSessionId)}` : "",
@@ -42818,6 +42992,12 @@ function buildMeshSystemMessage(args) {
42818
42992
  if (args.event === "agent:waiting_approval") {
42819
42993
  return `[System] ${args.nodeLabel} is waiting for approval to proceed${metadata}. You may use mesh_read_chat and mesh_approve to handle it.`;
42820
42994
  }
42995
+ if (args.event === "agent:stopped") {
42996
+ return `[System] ${args.nodeLabel} has stopped${metadata}. Use mesh_read_chat once if you need to inspect its last output.`;
42997
+ }
42998
+ if (args.event === "monitor:long_generating") {
42999
+ 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.`;
43000
+ }
42821
43001
  return "";
42822
43002
  }
42823
43003
  function injectMeshSystemMessage(components, args) {
@@ -42843,7 +43023,7 @@ function injectMeshSystemMessage(components, args) {
42843
43023
  }
42844
43024
  function handleMeshForwardEvent(components, payload) {
42845
43025
  const eventName = readNonEmptyString(payload.event);
42846
- if (eventName !== "agent:generating_completed" && eventName !== "agent:waiting_approval") {
43026
+ if (!isMeshCoordinatorEvent(eventName)) {
42847
43027
  return { success: false, error: "unsupported mesh event" };
42848
43028
  }
42849
43029
  const meshId = readNonEmptyString(payload.meshId);
@@ -42864,7 +43044,7 @@ function handleMeshForwardEvent(components, payload) {
42864
43044
  }
42865
43045
  function setupMeshEventForwarding(components) {
42866
43046
  components.instanceManager.onEvent((event) => {
42867
- if (event.event !== "agent:generating_completed" && event.event !== "agent:waiting_approval") return;
43047
+ if (!isMeshCoordinatorEvent(event.event)) return;
42868
43048
  const instanceId = readNonEmptyString(event.instanceId);
42869
43049
  if (!instanceId) return;
42870
43050
  const sourceInstance = components.instanceManager.getInstance(instanceId);
@@ -42892,11 +43072,18 @@ function setupMeshEventForwarding(components) {
42892
43072
  });
42893
43073
  });
42894
43074
  }
43075
+ var MESH_COORDINATOR_EVENTS;
42895
43076
  var init_mesh_events = __esm({
42896
43077
  "../../oss/packages/daemon-core/src/mesh/mesh-events.ts"() {
42897
43078
  "use strict";
42898
43079
  init_mesh_config();
42899
43080
  init_logger();
43081
+ MESH_COORDINATOR_EVENTS = /* @__PURE__ */ new Set([
43082
+ "agent:generating_completed",
43083
+ "agent:waiting_approval",
43084
+ "agent:stopped",
43085
+ "monitor:long_generating"
43086
+ ]);
42900
43087
  }
42901
43088
  });
42902
43089
 
@@ -63468,7 +63655,7 @@ var init_adhdev_daemon = __esm({
63468
63655
  init_version();
63469
63656
  init_src();
63470
63657
  init_runtime_defaults();
63471
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.76-rc.65" });
63658
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.76-rc.68" });
63472
63659
  AdhdevDaemon = class _AdhdevDaemon {
63473
63660
  localHttpServer = null;
63474
63661
  localWss = null;
@@ -64322,7 +64509,8 @@ ${err?.stack || ""}`);
64322
64509
  return typeof value === "string" && value.trim() ? value.trim() : "";
64323
64510
  }
64324
64511
  async relayRemoteMeshCoordinatorEvent(event, localDaemonId) {
64325
- if (event.event !== "agent:generating_completed" && event.event !== "agent:waiting_approval") return;
64512
+ const coordinatorEvents = /* @__PURE__ */ new Set(["agent:generating_completed", "agent:waiting_approval", "agent:stopped", "monitor:long_generating"]);
64513
+ if (!coordinatorEvents.has(this.readMeshString(event.event))) return;
64326
64514
  if (!this.meshManager || !this.components) return;
64327
64515
  const instanceId = this.readMeshString(event.instanceId);
64328
64516
  if (!instanceId) return;