@adhdev/daemon-standalone 0.9.82-rc.128 → 0.9.82-rc.129

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
@@ -39159,6 +39159,34 @@ ${effect.notification.body || ""}`.trim();
39159
39159
  if (status === "waiting_approval" && activeModal) return status;
39160
39160
  return "idle";
39161
39161
  }
39162
+ function isRuntimeInputAckMessage(message) {
39163
+ if (!message || typeof message !== "object") return false;
39164
+ const role = String(message.role || "").trim().toLowerCase();
39165
+ if (role !== "user" && role !== "human") return false;
39166
+ const meta3 = message.meta;
39167
+ return !!meta3 && typeof meta3 === "object" && !Array.isArray(meta3) && meta3.runtimeInputAck === true;
39168
+ }
39169
+ function selectRuntimeInputAckMessages(messages) {
39170
+ return messages.filter((message) => isRuntimeInputAckMessage(message));
39171
+ }
39172
+ function readExactRuntimeMirrorMessages(args) {
39173
+ const targetSessionId = String(args.targetSessionId || "").trim();
39174
+ const currentSessionId = String(args.currentSessionId || "").trim();
39175
+ if (!targetSessionId || targetSessionId !== currentSessionId) return [];
39176
+ const history = readChatHistory(
39177
+ args.providerType,
39178
+ 0,
39179
+ Math.max(args.tailLimit || 0, 200),
39180
+ targetSessionId,
39181
+ 0,
39182
+ args.historyBehavior
39183
+ );
39184
+ return normalizeChatMessages(history.messages || []).filter((message) => {
39185
+ const historySessionId = String(message.historySessionId || "").trim();
39186
+ const instanceId = String(message.instanceId || "").trim();
39187
+ return historySessionId === targetSessionId || instanceId === targetSessionId;
39188
+ });
39189
+ }
39162
39190
  function supportsCliNativeTranscript(providerType, provider) {
39163
39191
  if (CLI_NATIVE_TRANSCRIPT_PROVIDERS.has(providerType)) return true;
39164
39192
  return provider?.category === "cli" && isNativeSourceCanonicalHistory(provider?.canonicalHistory);
@@ -40007,10 +40035,19 @@ ${effect.notification.body || ""}`.trim();
40007
40035
  freshEnough
40008
40036
  });
40009
40037
  const unsafeNativeFallback = adapter.cliType === "codex-cli" && isUnsafeNativeTranscriptFallback(fallbackReason);
40038
+ const safeRuntimeAckMessages = unsafeNativeFallback ? selectRuntimeInputAckMessages(returnedMessages) : [];
40039
+ const exactRuntimeMirrorMessages = unsafeNativeFallback && safeRuntimeAckMessages.length === 0 ? readExactRuntimeMirrorMessages({
40040
+ providerType,
40041
+ targetSessionId: typeof args?.targetSessionId === "string" ? args.targetSessionId : void 0,
40042
+ currentSessionId: typeof h.currentSession?.sessionId === "string" ? h.currentSession.sessionId : void 0,
40043
+ tailLimit: nativeHistoryLimit,
40044
+ historyBehavior: provider?.historyBehavior
40045
+ }) : [];
40046
+ const safeDaemonMessages = safeRuntimeAckMessages.length > 0 ? safeRuntimeAckMessages : exactRuntimeMirrorMessages;
40010
40047
  if (unsafeNativeFallback) {
40011
- selectedMessages = [];
40012
- selectedTranscriptAuthority = void 0;
40013
- selectedCoverage = void 0;
40048
+ selectedMessages = safeDaemonMessages;
40049
+ selectedTranscriptAuthority = safeDaemonMessages.length > 0 ? "daemon" : void 0;
40050
+ selectedCoverage = safeDaemonMessages.length > 0 ? "tail" : void 0;
40014
40051
  selectedStatus = coerceUnsafeNativeFallbackStatus(returnedStatus, activeModal);
40015
40052
  }
40016
40053
  messageSource = buildCliMessageSourceProvenance({
@@ -40029,11 +40066,15 @@ ${effect.notification.body || ""}`.trim();
40029
40066
  unavailableReason,
40030
40067
  nativeMessages,
40031
40068
  ptyMessages: returnedMessages,
40032
- returnedMessages: unsafeNativeFallback ? [] : returnedMessages,
40069
+ returnedMessages: unsafeNativeFallback ? safeDaemonMessages : returnedMessages,
40033
40070
  safeMapping,
40034
40071
  freshEnough,
40035
40072
  ptyStatusApprovalOnly: unsafeNativeFallback
40036
40073
  });
40074
+ if (unsafeNativeFallback && exactRuntimeMirrorMessages.length > 0) {
40075
+ messageSource.selectedDaemonSource = "exact-runtime-mirror";
40076
+ messageSource.transcriptAuthority = "daemon";
40077
+ }
40037
40078
  }
40038
40079
  }
40039
40080
  }
@@ -40368,14 +40409,14 @@ ${effect.notification.body || ""}`.trim();
40368
40409
  try {
40369
40410
  const hasStructuredParts = input.parts.some((part) => part.type !== "text");
40370
40411
  if (hasStructuredParts) {
40371
- const target = getTargetInstance(h, args);
40372
- if (!target || target.category !== "cli") {
40412
+ const target2 = getTargetInstance(h, args);
40413
+ if (!target2 || target2.category !== "cli") {
40373
40414
  return { success: false, error: `CLI instance not found for ${provider?.type || args?.agentType || "unknown"}` };
40374
40415
  }
40375
40416
  assertProviderSupportsDeclaredInput(provider, input);
40376
40417
  await waitOnceForFreshHermesCliStart(adapter, _log);
40377
- target.onEvent("send_message", { input });
40378
- return _logSendSuccess(`${transport}-instance`, target.type);
40418
+ target2.onEvent("send_message", { input });
40419
+ return _logSendSuccess(`${transport}-instance`, target2.type);
40379
40420
  }
40380
40421
  assertTextOnlyInput(provider, input);
40381
40422
  if (!text) return { success: false, error: "text required for PTY send" };
@@ -40388,6 +40429,10 @@ ${effect.notification.body || ""}`.trim();
40388
40429
  } else {
40389
40430
  await adapter.sendMessage(text);
40390
40431
  }
40432
+ const target = getTargetInstance(h, args);
40433
+ if (target?.category === "cli" && target.type === adapter.cliType && typeof target.recordAcknowledgedUserInput === "function") {
40434
+ target.recordAcknowledgedUserInput(input);
40435
+ }
40391
40436
  return {
40392
40437
  ..._logSendSuccess(`${transport}-adapter`, adapter.cliType),
40393
40438
  ...forceSend ? { forceSent: true } : {}
@@ -43035,6 +43080,26 @@ ${effect.notification.body || ""}`.trim();
43035
43080
  this.applyProviderResponse(data, { phase: "immediate" });
43036
43081
  }
43037
43082
  }
43083
+ recordAcknowledgedUserInput(input) {
43084
+ const content = typeof input === "string" ? input.trim() : buildCliStructuredInputPrompt(input).trim();
43085
+ if (!content) return;
43086
+ const receivedAt = Date.now();
43087
+ const dedupKey = `user_input_ack:${crypto3.createHash("sha256").update(`${this.instanceId}:${content}:${receivedAt}`).digest("hex").slice(0, 24)}`;
43088
+ this.appendRuntimeMessage(buildChatMessage({
43089
+ role: "user",
43090
+ senderName: "User",
43091
+ kind: "standard",
43092
+ content,
43093
+ receivedAt,
43094
+ timestamp: receivedAt,
43095
+ source: "runtime_input_ack",
43096
+ meta: {
43097
+ runtimeInputAck: true,
43098
+ provider: this.type,
43099
+ workspace: this.workingDir
43100
+ }
43101
+ }), dedupKey);
43102
+ }
43038
43103
  dispose() {
43039
43104
  this.adapter.shutdown();
43040
43105
  this.monitor.reset();
@@ -43644,17 +43709,28 @@ ${effect.notification.body || ""}`.trim();
43644
43709
  index,
43645
43710
  source: "parsed"
43646
43711
  }));
43712
+ const getRole = (message) => typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
43647
43713
  const runtimeEntries = this.runtimeMessages.map((entry, index) => ({
43648
43714
  message: entry.message,
43649
43715
  index: parsedMessages.length + index,
43650
43716
  source: "runtime",
43651
43717
  runtimeKey: entry.key
43652
- }));
43718
+ })).filter((entry) => {
43719
+ const meta3 = entry.message.meta && typeof entry.message.meta === "object" && !Array.isArray(entry.message.meta) ? entry.message.meta : {};
43720
+ if (meta3.runtimeInputAck !== true) return true;
43721
+ const runtimeText = flattenContent(entry.message.content).replace(/\s+/g, " ").trim();
43722
+ if (!runtimeText) return false;
43723
+ return !parsedEntries.some((parsedEntry) => {
43724
+ const parsedRole = getRole(parsedEntry.message);
43725
+ if (parsedRole !== "user" && parsedRole !== "human") return false;
43726
+ const parsedText = flattenContent(parsedEntry.message.content).replace(/\s+/g, " ").trim();
43727
+ return parsedText === runtimeText;
43728
+ });
43729
+ });
43653
43730
  const getTime = (message) => {
43654
43731
  const value = typeof message.receivedAt === "number" ? message.receivedAt : typeof message.timestamp === "number" ? message.timestamp : 0;
43655
43732
  return Number.isFinite(value) && value > 0 ? value : 0;
43656
43733
  };
43657
- const getRole = (message) => typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
43658
43734
  const isRuntimeOverlay = (entry) => {
43659
43735
  if (entry.source !== "runtime") return false;
43660
43736
  const key = typeof entry.runtimeKey === "string" ? entry.runtimeKey.trim().toLowerCase() : "";