@adhdev/daemon-standalone 0.9.82-rc.134 → 0.9.82-rc.136

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
@@ -26679,6 +26679,8 @@ Next step: ${nextStep}`;
26679
26679
  recentOutputBuffer,
26680
26680
  terminalScreenText,
26681
26681
  workingDir,
26682
+ providerSessionId,
26683
+ historySessionId,
26682
26684
  baseMessages,
26683
26685
  partialResponse,
26684
26686
  isWaitingForResponse,
@@ -26696,6 +26698,8 @@ Next step: ${nextStep}`;
26696
26698
  screenText,
26697
26699
  workspace: workingDir,
26698
26700
  workingDir,
26701
+ providerSessionId,
26702
+ historySessionId,
26699
26703
  screen: buildCliScreenSnapshot(screenText),
26700
26704
  bufferScreen: buildCliScreenSnapshot(buffer),
26701
26705
  recentScreen: buildCliScreenSnapshot(recentBuffer),
@@ -28248,6 +28252,8 @@ ${lastSnapshot}`;
28248
28252
  recentOutputBuffer: this.recentOutputBuffer,
28249
28253
  terminalScreenText: parseScreenText,
28250
28254
  workingDir: this.workingDir,
28255
+ providerSessionId: this.providerSessionId || void 0,
28256
+ historySessionId: this.providerSessionId || void 0,
28251
28257
  baseMessages: [],
28252
28258
  partialResponse: this.responseBuffer,
28253
28259
  isWaitingForResponse: this.isWaitingForResponse,
@@ -28472,6 +28478,8 @@ ${lastSnapshot}`;
28472
28478
  recentOutputBuffer: this.recentOutputBuffer,
28473
28479
  terminalScreenText: this.getParseScreenText(this.terminalScreen.getText()),
28474
28480
  workingDir: this.workingDir,
28481
+ providerSessionId: this.providerSessionId || void 0,
28482
+ historySessionId: this.providerSessionId || void 0,
28475
28483
  baseMessages: [],
28476
28484
  partialResponse: this.responseBuffer,
28477
28485
  isWaitingForResponse: this.isWaitingForResponse,
@@ -29029,6 +29037,10 @@ ${lastSnapshot}`;
29029
29037
  return this.ptyProcess.getMetadata();
29030
29038
  }
29031
29039
  updateRuntimeMeta(meta3, replace = false) {
29040
+ const nextProviderSessionId = typeof meta3?.providerSessionId === "string" ? meta3.providerSessionId.trim() : "";
29041
+ if (nextProviderSessionId) {
29042
+ this.providerSessionId = nextProviderSessionId;
29043
+ }
29032
29044
  if (!this.ptyProcess || typeof this.ptyProcess.updateMeta !== "function") return;
29033
29045
  this.ptyProcess.updateMeta(meta3, replace);
29034
29046
  }
@@ -29196,6 +29208,9 @@ ${lastSnapshot}`;
29196
29208
  await this.writeToPty(data);
29197
29209
  }
29198
29210
  resolveModal(buttonIndex) {
29211
+ if (this.lastApprovalResolvedAt && Date.now() - this.lastApprovalResolvedAt < this.timeouts.approvalCooldown) {
29212
+ return;
29213
+ }
29199
29214
  let modal = this.activeModal || this.runParseApproval(this.recentOutputBuffer);
29200
29215
  if (!modal && typeof this.cliScripts?.parseSession === "function") {
29201
29216
  try {
@@ -29237,6 +29252,10 @@ ${lastSnapshot}`;
29237
29252
  this.ptyProcess.write(keys);
29238
29253
  }
29239
29254
  }
29255
+ /** Returns true if an approval was resolved within the adapter's cooldown window. */
29256
+ isApprovalRecentlyResolved() {
29257
+ return !!(this.lastApprovalResolvedAt && Date.now() - this.lastApprovalResolvedAt < this.timeouts.approvalCooldown);
29258
+ }
29240
29259
  resize(cols, rows) {
29241
29260
  if (this.ptyProcess) {
29242
29261
  try {
@@ -37160,6 +37179,19 @@ ${effect.notification.body || ""}`.trim();
37160
37179
  if (cleanMessage) lines.push(cleanMessage);
37161
37180
  return lines.join("\n");
37162
37181
  }
37182
+ function looksLikeActiveApprovalPromptText(content) {
37183
+ const text = content.trim();
37184
+ if (!text || text.length > 2e3) return false;
37185
+ const hasApprovalQuestion = /do you want to (?:proceed|allow|run|make this edit|create)/i.test(text) || /this command requires approval/i.test(text) || /quick safety check/i.test(text) || /is this a project you trust/i.test(text);
37186
+ const hasNumberedChoices = /^\s*[❯›>]?\s*1[.)]\s+(?:yes|allow|proceed|run)/im.test(text) || /^\s*1[.)]\s+yes\b/im.test(text);
37187
+ if (hasApprovalQuestion && hasNumberedChoices) return true;
37188
+ const lastLines = text.split(/\r?\n/).slice(-12).join("\n");
37189
+ const hasDontAskAgain = /yes.*don'?t ask again/i.test(lastLines) || /yes.*always allow/i.test(lastLines);
37190
+ const hasNoOption = /^\s*[❯›>]?\s*\d+[.)]\s+no\b/im.test(lastLines);
37191
+ if (hasDontAskAgain && hasNoOption) return true;
37192
+ if (/what do you want to do\?/i.test(text) && /^\s*\d+[.)]\s+\S/m.test(text)) return true;
37193
+ return false;
37194
+ }
37163
37195
  async function withTimeout(promise2, timeoutMs, label) {
37164
37196
  let timer = null;
37165
37197
  try {
@@ -41135,6 +41167,10 @@ ${effect.notification.body || ""}`.trim();
41135
41167
  if (buttonIndex < 0) {
41136
41168
  return { success: false, error: "Approval action did not match any visible button" };
41137
41169
  }
41170
+ if (typeof adapter.isApprovalRecentlyResolved === "function" && adapter.isApprovalRecentlyResolved()) {
41171
+ LOG2.info("Command", `[resolveAction] CLI PTY \u2192 stale_prompt (already resolved within cooldown)`);
41172
+ return { success: true, stalePrompt: true, buttonIndex, button: buttons[buttonIndex] ?? button };
41173
+ }
41138
41174
  if (typeof adapter.resolveModal === "function") {
41139
41175
  adapter.resolveModal(buttonIndex);
41140
41176
  } else {
@@ -42917,6 +42953,9 @@ ${effect.notification.body || ""}`.trim();
42917
42953
  this.launchMode = options?.launchMode || "new";
42918
42954
  this.onProviderSessionResolved = options?.onProviderSessionResolved;
42919
42955
  this.adapter = new ProviderCliAdapter(provider, workingDir, cliArgs, options?.extraEnv || {}, transportFactory);
42956
+ if (this.providerSessionId) {
42957
+ this.adapter.updateRuntimeMeta({ providerSessionId: this.providerSessionId });
42958
+ }
42920
42959
  this.monitor = new StatusMonitor();
42921
42960
  this.historyWriter = new ChatHistoryWriter();
42922
42961
  }
@@ -43310,7 +43349,9 @@ ${effect.notification.body || ""}`.trim();
43310
43349
  const lastVisible = visibleMessages[visibleMessages.length - 1];
43311
43350
  const role = typeof lastVisible?.role === "string" ? lastVisible.role.trim().toLowerCase() : "";
43312
43351
  const content = lastVisible ? flattenContent(lastVisible.content).trim() : "";
43313
- return role === "assistant" && !!content;
43352
+ if (role !== "assistant" || !content) return false;
43353
+ if (looksLikeActiveApprovalPromptText(content)) return false;
43354
+ return true;
43314
43355
  }
43315
43356
  buildCompletedFinalizationDiagnostic(args) {
43316
43357
  let parsed = null;
@@ -43398,6 +43439,16 @@ ${effect.notification.body || ""}`.trim();
43398
43439
  }
43399
43440
  if (parsed?.activeModal || parsed?.modal) return { reason: "parsed_modal_active", terminal: true };
43400
43441
  if (!this.completionHasFinalAssistantMessage(parsed?.messages)) return { reason: "missing_final_assistant" };
43442
+ try {
43443
+ const screenText = typeof this.adapter.getScreenText === "function" ? String(this.adapter.getScreenText() || "") : "";
43444
+ if (screenText) {
43445
+ const tailLines = screenText.split(/\r?\n/).slice(-16).join("\n");
43446
+ if (looksLikeActiveApprovalPromptText(tailLines)) {
43447
+ return { reason: "screen_shows_approval_prompt", terminal: false };
43448
+ }
43449
+ }
43450
+ } catch {
43451
+ }
43401
43452
  return null;
43402
43453
  }
43403
43454
  scheduleCompletedDebounceFlush(delayMs) {
@@ -45696,7 +45747,9 @@ ${rawInput}` : rawInput;
45696
45747
  providerSessionId,
45697
45748
  attachExisting
45698
45749
  );
45699
- return new ProviderCliAdapter(resolvedProvider, workingDir, cliArgs, extraEnv || {}, transportFactory);
45750
+ const adapter = new ProviderCliAdapter(resolvedProvider, workingDir, cliArgs, extraEnv || {}, transportFactory);
45751
+ if (providerSessionId) adapter.updateRuntimeMeta({ providerSessionId });
45752
+ return adapter;
45700
45753
  }
45701
45754
  throw new Error(`No CLI provider found for '${cliType}'. Create a provider.js in providers/cli/${cliType}/`);
45702
45755
  }