@adhdev/daemon-standalone 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
@@ -9162,6 +9162,8 @@ var require_dist = __commonJS({
9162
9162
  var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
9163
9163
  var index_exports = {};
9164
9164
  __export2(index_exports, {
9165
+ DEFAULT_SESSION_HOST_COLS: () => DEFAULT_SESSION_HOST_COLS,
9166
+ DEFAULT_SESSION_HOST_ROWS: () => DEFAULT_SESSION_HOST_ROWS,
9165
9167
  SessionHostClient: () => SessionHostClient2,
9166
9168
  SessionHostRegistry: () => SessionHostRegistry,
9167
9169
  SessionRingBuffer: () => SessionRingBuffer,
@@ -9180,6 +9182,8 @@ var require_dist = __commonJS({
9180
9182
  isSessionHostRecoverySnapshot: () => isSessionHostRecoverySnapshot,
9181
9183
  resolveAttachableRuntimeRecord: () => resolveAttachableRuntimeRecord,
9182
9184
  resolveRuntimeRecord: () => resolveRuntimeRecord,
9185
+ resolveSessionHostCols: () => resolveSessionHostCols,
9186
+ resolveSessionHostRows: () => resolveSessionHostRows,
9183
9187
  sanitizeSpawnEnv: () => sanitizeSpawnEnv,
9184
9188
  writeEnvelope: () => writeEnvelope
9185
9189
  });
@@ -9245,6 +9249,19 @@ var require_dist = __commonJS({
9245
9249
  }
9246
9250
  };
9247
9251
  var import_crypto3 = require("crypto");
9252
+ var DEFAULT_SESSION_HOST_COLS = 80;
9253
+ var DEFAULT_SESSION_HOST_ROWS = 48;
9254
+ function normalizeSessionHostDimension(value, fallback) {
9255
+ if (typeof value !== "number" || !Number.isFinite(value)) return fallback;
9256
+ const rounded = Math.floor(value);
9257
+ return rounded > 0 ? rounded : fallback;
9258
+ }
9259
+ function resolveSessionHostCols(value) {
9260
+ return normalizeSessionHostDimension(value, DEFAULT_SESSION_HOST_COLS);
9261
+ }
9262
+ function resolveSessionHostRows(value) {
9263
+ return normalizeSessionHostDimension(value, DEFAULT_SESSION_HOST_ROWS);
9264
+ }
9248
9265
  var path5 = __toESM2(require("path"));
9249
9266
  function normalizeSlug(input) {
9250
9267
  return input.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 48);
@@ -9397,8 +9414,8 @@ var require_dist = __commonJS({
9397
9414
  meta: payload.meta || {}
9398
9415
  };
9399
9416
  record2.meta = {
9400
- sessionHostCols: payload.cols || 80,
9401
- sessionHostRows: payload.rows || 24,
9417
+ sessionHostCols: resolveSessionHostCols(payload.cols),
9418
+ sessionHostRows: resolveSessionHostRows(payload.rows),
9402
9419
  ...record2.meta
9403
9420
  };
9404
9421
  this.sessions.set(sessionId, {
@@ -29635,8 +29652,8 @@ var require_dist2 = __commonJS({
29635
29652
  isWin,
29636
29653
  useShell,
29637
29654
  ptyOptions: {
29638
- cols: 80,
29639
- rows: 24,
29655
+ cols: import_session_host_core22.DEFAULT_SESSION_HOST_COLS,
29656
+ rows: import_session_host_core22.DEFAULT_SESSION_HOST_ROWS,
29640
29657
  cwd: workingDir,
29641
29658
  env: buildCliSpawnEnv(process.env, spawnConfig.env)
29642
29659
  }
@@ -29689,11 +29706,13 @@ var require_dist2 = __commonJS({
29689
29706
  }
29690
29707
  var os9;
29691
29708
  var path10;
29709
+ var import_session_host_core22;
29692
29710
  var init_provider_cli_runtime = __esm2({
29693
29711
  "src/cli-adapters/provider-cli-runtime.ts"() {
29694
29712
  "use strict";
29695
29713
  os9 = __toESM2(require("os"));
29696
29714
  path10 = __toESM2(require("path"));
29715
+ import_session_host_core22 = require_dist();
29697
29716
  init_provider_cli_shared();
29698
29717
  }
29699
29718
  });
@@ -29702,6 +29721,28 @@ var require_dist2 = __commonJS({
29702
29721
  ProviderCliAdapter: () => ProviderCliAdapter,
29703
29722
  normalizeCliProviderForRuntime: () => normalizeCliProviderForRuntime
29704
29723
  });
29724
+ function normalizeComparableTranscriptText(value) {
29725
+ return sanitizeTerminalText(String(value || "")).replace(/\s+/g, " ").trim();
29726
+ }
29727
+ function parsedTranscriptIsRicherThanCommitted(parsedMessages, committedMessages) {
29728
+ if (!Array.isArray(parsedMessages) || !Array.isArray(committedMessages)) return false;
29729
+ if (parsedMessages.length > committedMessages.length) return true;
29730
+ if (parsedMessages.length !== committedMessages.length) return false;
29731
+ for (let index = 0; index < parsedMessages.length; index += 1) {
29732
+ const parsed = parsedMessages[index];
29733
+ const committed = committedMessages[index];
29734
+ if (!parsed || !committed) return false;
29735
+ if ((parsed.role || "") !== (committed.role || "")) return false;
29736
+ if (parsed.id && committed.id && String(parsed.id) !== String(committed.id)) return false;
29737
+ if (typeof parsed.index === "number" && typeof committed.index === "number" && parsed.index !== committed.index) return false;
29738
+ const parsedText = normalizeComparableTranscriptText(parsed.content);
29739
+ const committedText = normalizeComparableTranscriptText(committed.content);
29740
+ if (!parsedText || !committedText || parsedText === committedText) continue;
29741
+ if (parsedText.length > committedText.length && parsedText.startsWith(committedText)) return true;
29742
+ return false;
29743
+ }
29744
+ return false;
29745
+ }
29705
29746
  var os10;
29706
29747
  var ProviderCliAdapter;
29707
29748
  var init_provider_cli_adapter = __esm2({
@@ -31030,7 +31071,7 @@ var require_dist2 = __commonJS({
31030
31071
  }));
31031
31072
  const parsedLastAssistant = [...parsedHydratedMessages].reverse().find((message) => message.role === "assistant" && typeof message.content === "string" && message.content.trim());
31032
31073
  const visibleIdlePrompt = this.looksLikeVisibleIdlePrompt(screenText);
31033
- const shouldAdoptParsedIdleReplay = !this.currentTurnScope && !this.activeModal && !!parsedLastAssistant && parsedHydratedMessages.length > committedHydratedMessages.length && (this.currentStatus === "idle" || this.currentStatus === "generating" && this.isWaitingForResponse && parsed.status === "idle" && visibleIdlePrompt);
31074
+ const shouldAdoptParsedIdleReplay = !this.currentTurnScope && !this.activeModal && !!parsedLastAssistant && parsedTranscriptIsRicherThanCommitted(parsedHydratedMessages, committedHydratedMessages) && (this.currentStatus === "idle" || this.currentStatus === "generating" && this.isWaitingForResponse && parsed.status === "idle" && visibleIdlePrompt);
31034
31075
  if (shouldAdoptParsedIdleReplay) {
31035
31076
  this.committedMessages = normalizeCliParsedMessages(parsed.messages, {
31036
31077
  committedMessages: this.committedMessages,
@@ -40436,6 +40477,8 @@ ${effect.notification.body || ""}`.trim();
40436
40477
  generatingDebounceTimer = null;
40437
40478
  generatingDebouncePending = null;
40438
40479
  lastApprovalEventAt = 0;
40480
+ autoApproveBusy = false;
40481
+ autoApproveBusyTimer = null;
40439
40482
  controlValues = {};
40440
40483
  summaryMetadata = void 0;
40441
40484
  appliedEffectKeys = /* @__PURE__ */ new Set();
@@ -40727,7 +40770,13 @@ ${effect.notification.body || ""}`.trim();
40727
40770
  const parsedStatus = this.adapter.getScriptParsedStatus?.() || null;
40728
40771
  const rawStatus = adapterStatus.status;
40729
40772
  const autoApproveActive = rawStatus === "waiting_approval" && this.shouldAutoApprove();
40730
- if (autoApproveActive) {
40773
+ if (autoApproveActive && !this.autoApproveBusy) {
40774
+ this.autoApproveBusy = true;
40775
+ if (this.autoApproveBusyTimer) clearTimeout(this.autoApproveBusyTimer);
40776
+ this.autoApproveBusyTimer = setTimeout(() => {
40777
+ this.autoApproveBusy = false;
40778
+ this.autoApproveBusyTimer = null;
40779
+ }, 2e3);
40731
40780
  const { index: buttonIndex, label: buttonLabel } = pickApprovalButton(adapterStatus.activeModal?.buttons, this.provider);
40732
40781
  this.recordAutoApproval(adapterStatus.activeModal?.message, buttonLabel, now);
40733
40782
  setTimeout(() => {
@@ -53132,7 +53181,7 @@ data: ${JSON.stringify(msg.data)}
53132
53181
  };
53133
53182
  init_provider_cli_adapter();
53134
53183
  init_pty_transport();
53135
- var import_session_host_core22 = require_dist();
53184
+ var import_session_host_core32 = require_dist();
53136
53185
  init_logger();
53137
53186
  function shouldResumeAttachedSession(record2) {
53138
53187
  if (!record2) return false;
@@ -53144,7 +53193,7 @@ data: ${JSON.stringify(msg.data)}
53144
53193
  var SessionHostRuntimeTransport = class {
53145
53194
  constructor(options) {
53146
53195
  this.options = options;
53147
- this.client = new import_session_host_core22.SessionHostClient({
53196
+ this.client = new import_session_host_core32.SessionHostClient({
53148
53197
  endpoint: options.endpoint,
53149
53198
  appName: options.appName
53150
53199
  });
@@ -53546,11 +53595,11 @@ data: ${JSON.stringify(msg.data)}
53546
53595
  function resolveSessionHostAppName(options = {}) {
53547
53596
  return resolveSessionHostAppNameResolution2(options).appName;
53548
53597
  }
53549
- var import_session_host_core32 = require_dist();
53598
+ var import_session_host_core4 = require_dist();
53550
53599
  var STARTUP_TIMEOUT_MS = DEFAULT_SESSION_HOST_READY_TIMEOUT_MS2;
53551
53600
  var STARTUP_POLL_MS = 200;
53552
53601
  async function canConnect(endpoint) {
53553
- const client = new import_session_host_core32.SessionHostClient({ endpoint });
53602
+ const client = new import_session_host_core4.SessionHostClient({ endpoint });
53554
53603
  try {
53555
53604
  await client.connect();
53556
53605
  await client.close();
@@ -53568,14 +53617,14 @@ data: ${JSON.stringify(msg.data)}
53568
53617
  throw new Error(`Session host did not become ready within ${timeoutMs}ms`);
53569
53618
  }
53570
53619
  async function ensureSessionHostReady2(options) {
53571
- const endpoint = (0, import_session_host_core32.getDefaultSessionHostEndpoint)(options.appName || "adhdev");
53620
+ const endpoint = (0, import_session_host_core4.getDefaultSessionHostEndpoint)(options.appName || "adhdev");
53572
53621
  if (await canConnect(endpoint)) return endpoint;
53573
53622
  options.spawnHost();
53574
53623
  await waitForReady(endpoint, options.timeoutMs);
53575
53624
  return endpoint;
53576
53625
  }
53577
53626
  async function listHostedCliRuntimes2(endpoint) {
53578
- const client = new import_session_host_core32.SessionHostClient({ endpoint });
53627
+ const client = new import_session_host_core4.SessionHostClient({ endpoint });
53579
53628
  try {
53580
53629
  const response = await client.request({
53581
53630
  type: "list_sessions",