adhdev 0.9.76-rc.66 → 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
@@ -14659,13 +14659,25 @@ var init_pty_transport = __esm({
14659
14659
 
14660
14660
  // ../../oss/packages/daemon-core/src/cli-adapters/provider-cli-shared.ts
14661
14661
  function stripAnsi(str2) {
14662
- 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);
14663
14674
  }
14664
14675
  function stripTerminalNoise(str2) {
14665
- 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");
14666
14677
  }
14667
14678
  function sanitizeTerminalText(str2) {
14668
- return stripTerminalNoise(stripAnsi(str2));
14679
+ const accumulator = new TerminalTranscriptAccumulator();
14680
+ return stripTerminalNoise(stripAnsi(accumulator.append(str2)));
14669
14681
  }
14670
14682
  function listCliScriptNames(scripts) {
14671
14683
  if (!scripts) return [];
@@ -14844,7 +14856,7 @@ function normalizeCliProviderForRuntime(raw) {
14844
14856
  }
14845
14857
  };
14846
14858
  }
14847
- var os12, path15, import_child_process4, buildCliSpawnEnv;
14859
+ var os12, path15, import_child_process4, TerminalTranscriptAccumulator, buildCliSpawnEnv;
14848
14860
  var init_provider_cli_shared = __esm({
14849
14861
  "../../oss/packages/daemon-core/src/cli-adapters/provider-cli-shared.ts"() {
14850
14862
  "use strict";
@@ -14852,6 +14864,155 @@ var init_provider_cli_shared = __esm({
14852
14864
  path15 = __toESM(require("path"));
14853
14865
  import_child_process4 = require("child_process");
14854
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
+ };
14855
15016
  buildCliSpawnEnv = sanitizeSpawnEnv;
14856
15017
  }
14857
15018
  });
@@ -15199,8 +15360,10 @@ var init_provider_cli_adapter = __esm({
15199
15360
  // ─── CLI Scripts (script-based parsing) ───
15200
15361
  cliScripts;
15201
15362
  runtimeSettings = {};
15202
- /** Full accumulated ANSI-stripped PTY output */
15363
+ /** Full accumulated rendered PTY transcript for parser/readback use */
15203
15364
  accumulatedBuffer = "";
15365
+ /** Stateful rendered transcript accumulator; raw debug remains in accumulatedRawBuffer. */
15366
+ transcriptAccumulator = new TerminalTranscriptAccumulator();
15204
15367
  /** Full accumulated raw PTY output (with ANSI) */
15205
15368
  accumulatedRawBuffer = "";
15206
15369
  /** Current visible terminal screen snapshot */
@@ -15266,6 +15429,7 @@ ${lastSnapshot}`;
15266
15429
  }
15267
15430
  resetTerminalScreen(rows, cols) {
15268
15431
  this.terminalScreen.reset(rows, cols);
15432
+ this.transcriptAccumulator.reset();
15269
15433
  this.lastScreenText = "";
15270
15434
  this.lastScreenSnapshot = "";
15271
15435
  this.lastScreenChangeAt = 0;
@@ -15524,6 +15688,7 @@ ${lastSnapshot}`;
15524
15688
  handleOutput(rawData) {
15525
15689
  this.terminalScreen.write(rawData);
15526
15690
  const cleanData = sanitizeTerminalText(rawData);
15691
+ const renderedTranscript = this.transcriptAccumulator.append(rawData);
15527
15692
  const now = Date.now();
15528
15693
  const shouldReadScreen = this.shouldReadTerminalScreenSnapshot(now);
15529
15694
  const screenText = shouldReadScreen ? this.readTerminalScreenText(now) : this.lastScreenText;
@@ -15564,13 +15729,14 @@ ${lastSnapshot}`;
15564
15729
  }
15565
15730
  }
15566
15731
  const prevRecentLen = this.recentOutputBuffer.length;
15567
- const prevAccumulatedLen = this.accumulatedBuffer.length;
15568
15732
  const prevAccumulatedRawLen = this.accumulatedRawBuffer.length;
15569
- this.recentOutputBuffer = appendBoundedText(this.recentOutputBuffer, cleanData, _ProviderCliAdapter.MAX_RECENT_OUTPUT_BUFFER);
15570
- 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;
15571
15737
  this.accumulatedRawBuffer = appendBoundedText(this.accumulatedRawBuffer, rawData, _ProviderCliAdapter.MAX_ACCUMULATED_BUFFER);
15572
- const droppedRecent = this.recordBoundedAppendDrop(prevRecentLen, cleanData.length, this.recentOutputBuffer.length);
15573
- 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);
15574
15740
  const droppedRaw = this.recordBoundedAppendDrop(prevAccumulatedRawLen, rawData.length, this.accumulatedRawBuffer.length);
15575
15741
  this.recentOutputDroppedChars += droppedRecent;
15576
15742
  this.accumulatedBufferDroppedChars += droppedClean;
@@ -43786,6 +43952,9 @@ var init_mesh_coordinator = __esm({
43786
43952
  function readNonEmptyString(value) {
43787
43953
  return typeof value === "string" && value.trim() ? value.trim() : "";
43788
43954
  }
43955
+ function isMeshCoordinatorEvent(eventName) {
43956
+ return typeof eventName === "string" && MESH_COORDINATOR_EVENTS.has(eventName);
43957
+ }
43789
43958
  function formatCompletionMetadata(event) {
43790
43959
  const parts = [
43791
43960
  readNonEmptyString(event.targetSessionId) ? `session_id=${readNonEmptyString(event.targetSessionId)}` : "",
@@ -43802,6 +43971,12 @@ function buildMeshSystemMessage(args) {
43802
43971
  if (args.event === "agent:waiting_approval") {
43803
43972
  return `[System] ${args.nodeLabel} is waiting for approval to proceed${metadata}. You may use mesh_read_chat and mesh_approve to handle it.`;
43804
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
+ }
43805
43980
  return "";
43806
43981
  }
43807
43982
  function injectMeshSystemMessage(components, args) {
@@ -43827,7 +44002,7 @@ function injectMeshSystemMessage(components, args) {
43827
44002
  }
43828
44003
  function handleMeshForwardEvent(components, payload) {
43829
44004
  const eventName = readNonEmptyString(payload.event);
43830
- if (eventName !== "agent:generating_completed" && eventName !== "agent:waiting_approval") {
44005
+ if (!isMeshCoordinatorEvent(eventName)) {
43831
44006
  return { success: false, error: "unsupported mesh event" };
43832
44007
  }
43833
44008
  const meshId = readNonEmptyString(payload.meshId);
@@ -43848,7 +44023,7 @@ function handleMeshForwardEvent(components, payload) {
43848
44023
  }
43849
44024
  function setupMeshEventForwarding(components) {
43850
44025
  components.instanceManager.onEvent((event) => {
43851
- if (event.event !== "agent:generating_completed" && event.event !== "agent:waiting_approval") return;
44026
+ if (!isMeshCoordinatorEvent(event.event)) return;
43852
44027
  const instanceId = readNonEmptyString(event.instanceId);
43853
44028
  if (!instanceId) return;
43854
44029
  const sourceInstance = components.instanceManager.getInstance(instanceId);
@@ -43876,11 +44051,18 @@ function setupMeshEventForwarding(components) {
43876
44051
  });
43877
44052
  });
43878
44053
  }
44054
+ var MESH_COORDINATOR_EVENTS;
43879
44055
  var init_mesh_events = __esm({
43880
44056
  "../../oss/packages/daemon-core/src/mesh/mesh-events.ts"() {
43881
44057
  "use strict";
43882
44058
  init_mesh_config();
43883
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
+ ]);
43884
44066
  }
43885
44067
  });
43886
44068
 
@@ -94637,7 +94819,7 @@ var init_adhdev_daemon = __esm({
94637
94819
  init_version();
94638
94820
  init_src();
94639
94821
  init_runtime_defaults();
94640
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.76-rc.66" });
94822
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.76-rc.68" });
94641
94823
  AdhdevDaemon = class _AdhdevDaemon {
94642
94824
  localHttpServer = null;
94643
94825
  localWss = null;
@@ -95491,7 +95673,8 @@ ${err?.stack || ""}`);
95491
95673
  return typeof value === "string" && value.trim() ? value.trim() : "";
95492
95674
  }
95493
95675
  async relayRemoteMeshCoordinatorEvent(event, localDaemonId) {
95494
- 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;
95495
95678
  if (!this.meshManager || !this.components) return;
95496
95679
  const instanceId = this.readMeshString(event.instanceId);
95497
95680
  if (!instanceId) return;