@adhdev/daemon-core 0.8.96 → 0.8.98

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
@@ -1789,8 +1789,8 @@ function resolveCliSpawnPlan(options) {
1789
1789
  isWin,
1790
1790
  useShell,
1791
1791
  ptyOptions: {
1792
- cols: 80,
1793
- rows: 24,
1792
+ cols: import_session_host_core2.DEFAULT_SESSION_HOST_COLS,
1793
+ rows: import_session_host_core2.DEFAULT_SESSION_HOST_ROWS,
1794
1794
  cwd: workingDir,
1795
1795
  env: buildCliSpawnEnv(process.env, spawnConfig.env)
1796
1796
  }
@@ -1841,12 +1841,13 @@ function respondToCliTerminalQueries(options) {
1841
1841
  }
1842
1842
  return "";
1843
1843
  }
1844
- var os9, path10;
1844
+ var os9, path10, import_session_host_core2;
1845
1845
  var init_provider_cli_runtime = __esm({
1846
1846
  "src/cli-adapters/provider-cli-runtime.ts"() {
1847
1847
  "use strict";
1848
1848
  os9 = __toESM(require("os"));
1849
1849
  path10 = __toESM(require("path"));
1850
+ import_session_host_core2 = require("@adhdev/session-host-core");
1850
1851
  init_provider_cli_shared();
1851
1852
  }
1852
1853
  });
@@ -1857,6 +1858,28 @@ __export(provider_cli_adapter_exports, {
1857
1858
  ProviderCliAdapter: () => ProviderCliAdapter,
1858
1859
  normalizeCliProviderForRuntime: () => normalizeCliProviderForRuntime
1859
1860
  });
1861
+ function normalizeComparableTranscriptText(value) {
1862
+ return sanitizeTerminalText(String(value || "")).replace(/\s+/g, " ").trim();
1863
+ }
1864
+ function parsedTranscriptIsRicherThanCommitted(parsedMessages, committedMessages) {
1865
+ if (!Array.isArray(parsedMessages) || !Array.isArray(committedMessages)) return false;
1866
+ if (parsedMessages.length > committedMessages.length) return true;
1867
+ if (parsedMessages.length !== committedMessages.length) return false;
1868
+ for (let index = 0; index < parsedMessages.length; index += 1) {
1869
+ const parsed = parsedMessages[index];
1870
+ const committed = committedMessages[index];
1871
+ if (!parsed || !committed) return false;
1872
+ if ((parsed.role || "") !== (committed.role || "")) return false;
1873
+ if (parsed.id && committed.id && String(parsed.id) !== String(committed.id)) return false;
1874
+ if (typeof parsed.index === "number" && typeof committed.index === "number" && parsed.index !== committed.index) return false;
1875
+ const parsedText = normalizeComparableTranscriptText(parsed.content);
1876
+ const committedText = normalizeComparableTranscriptText(committed.content);
1877
+ if (!parsedText || !committedText || parsedText === committedText) continue;
1878
+ if (parsedText.length > committedText.length && parsedText.startsWith(committedText)) return true;
1879
+ return false;
1880
+ }
1881
+ return false;
1882
+ }
1860
1883
  var os10, ProviderCliAdapter;
1861
1884
  var init_provider_cli_adapter = __esm({
1862
1885
  "src/cli-adapters/provider-cli-adapter.ts"() {
@@ -3184,7 +3207,7 @@ var init_provider_cli_adapter = __esm({
3184
3207
  }));
3185
3208
  const parsedLastAssistant = [...parsedHydratedMessages].reverse().find((message) => message.role === "assistant" && typeof message.content === "string" && message.content.trim());
3186
3209
  const visibleIdlePrompt = this.looksLikeVisibleIdlePrompt(screenText);
3187
- const shouldAdoptParsedIdleReplay = !this.currentTurnScope && !this.activeModal && !!parsedLastAssistant && parsedHydratedMessages.length > committedHydratedMessages.length && (this.currentStatus === "idle" || this.currentStatus === "generating" && this.isWaitingForResponse && parsed.status === "idle" && visibleIdlePrompt);
3210
+ const shouldAdoptParsedIdleReplay = !this.currentTurnScope && !this.activeModal && !!parsedLastAssistant && parsedTranscriptIsRicherThanCommitted(parsedHydratedMessages, committedHydratedMessages) && (this.currentStatus === "idle" || this.currentStatus === "generating" && this.isWaitingForResponse && parsed.status === "idle" && visibleIdlePrompt);
3188
3211
  if (shouldAdoptParsedIdleReplay) {
3189
3212
  this.committedMessages = normalizeCliParsedMessages(parsed.messages, {
3190
3213
  committedMessages: this.committedMessages,
@@ -12696,6 +12719,8 @@ var CliProviderInstance = class {
12696
12719
  generatingDebounceTimer = null;
12697
12720
  generatingDebouncePending = null;
12698
12721
  lastApprovalEventAt = 0;
12722
+ autoApproveBusy = false;
12723
+ autoApproveBusyTimer = null;
12699
12724
  controlValues = {};
12700
12725
  summaryMetadata = void 0;
12701
12726
  appliedEffectKeys = /* @__PURE__ */ new Set();
@@ -12987,7 +13012,13 @@ var CliProviderInstance = class {
12987
13012
  const parsedStatus = this.adapter.getScriptParsedStatus?.() || null;
12988
13013
  const rawStatus = adapterStatus.status;
12989
13014
  const autoApproveActive = rawStatus === "waiting_approval" && this.shouldAutoApprove();
12990
- if (autoApproveActive) {
13015
+ if (autoApproveActive && !this.autoApproveBusy) {
13016
+ this.autoApproveBusy = true;
13017
+ if (this.autoApproveBusyTimer) clearTimeout(this.autoApproveBusyTimer);
13018
+ this.autoApproveBusyTimer = setTimeout(() => {
13019
+ this.autoApproveBusy = false;
13020
+ this.autoApproveBusyTimer = null;
13021
+ }, 2e3);
12991
13022
  const { index: buttonIndex, label: buttonLabel } = pickApprovalButton(adapterStatus.activeModal?.buttons, this.provider);
12992
13023
  this.recordAutoApproval(adapterStatus.activeModal?.message, buttonLabel, now);
12993
13024
  setTimeout(() => {
@@ -25464,7 +25495,7 @@ init_provider_cli_adapter();
25464
25495
  init_pty_transport();
25465
25496
 
25466
25497
  // src/cli-adapters/session-host-transport.ts
25467
- var import_session_host_core2 = require("@adhdev/session-host-core");
25498
+ var import_session_host_core3 = require("@adhdev/session-host-core");
25468
25499
  init_logger();
25469
25500
  function shouldResumeAttachedSession(record) {
25470
25501
  if (!record) return false;
@@ -25476,7 +25507,7 @@ function shouldResumeAttachedSession(record) {
25476
25507
  var SessionHostRuntimeTransport = class {
25477
25508
  constructor(options) {
25478
25509
  this.options = options;
25479
- this.client = new import_session_host_core2.SessionHostClient({
25510
+ this.client = new import_session_host_core3.SessionHostClient({
25480
25511
  endpoint: options.endpoint,
25481
25512
  appName: options.appName
25482
25513
  });
@@ -25882,11 +25913,11 @@ function resolveSessionHostAppName(options = {}) {
25882
25913
  }
25883
25914
 
25884
25915
  // src/session-host/runtime-support.ts
25885
- var import_session_host_core3 = require("@adhdev/session-host-core");
25916
+ var import_session_host_core4 = require("@adhdev/session-host-core");
25886
25917
  var STARTUP_TIMEOUT_MS = DEFAULT_SESSION_HOST_READY_TIMEOUT_MS;
25887
25918
  var STARTUP_POLL_MS = 200;
25888
25919
  async function canConnect(endpoint) {
25889
- const client = new import_session_host_core3.SessionHostClient({ endpoint });
25920
+ const client = new import_session_host_core4.SessionHostClient({ endpoint });
25890
25921
  try {
25891
25922
  await client.connect();
25892
25923
  await client.close();
@@ -25904,14 +25935,14 @@ async function waitForReady(endpoint, timeoutMs = STARTUP_TIMEOUT_MS) {
25904
25935
  throw new Error(`Session host did not become ready within ${timeoutMs}ms`);
25905
25936
  }
25906
25937
  async function ensureSessionHostReady(options) {
25907
- const endpoint = (0, import_session_host_core3.getDefaultSessionHostEndpoint)(options.appName || "adhdev");
25938
+ const endpoint = (0, import_session_host_core4.getDefaultSessionHostEndpoint)(options.appName || "adhdev");
25908
25939
  if (await canConnect(endpoint)) return endpoint;
25909
25940
  options.spawnHost();
25910
25941
  await waitForReady(endpoint, options.timeoutMs);
25911
25942
  return endpoint;
25912
25943
  }
25913
25944
  async function listHostedCliRuntimes(endpoint) {
25914
- const client = new import_session_host_core3.SessionHostClient({ endpoint });
25945
+ const client = new import_session_host_core4.SessionHostClient({ endpoint });
25915
25946
  try {
25916
25947
  const response = await client.request({
25917
25948
  type: "list_sessions",