@adhdev/daemon-standalone 0.9.82-rc.130 → 0.9.82-rc.131

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
@@ -39305,6 +39305,21 @@ ${effect.notification.body || ""}`.trim();
39305
39305
  });
39306
39306
  return { ...sessionHistory, lookup: "session" };
39307
39307
  }
39308
+ function readLiveCodexWorkspaceNativeHistory(agentStr, args) {
39309
+ if (agentStr !== "codex-cli") return null;
39310
+ const workspace = typeof args.workspace === "string" ? args.workspace.trim() : "";
39311
+ if (!workspace) return null;
39312
+ const history = readProviderChatHistory(agentStr, {
39313
+ canonicalHistory: args.canonicalHistory,
39314
+ workspace,
39315
+ offset: args.offset,
39316
+ limit: args.limit,
39317
+ excludeRecentCount: args.excludeRecentCount,
39318
+ historyBehavior: args.historyBehavior,
39319
+ scripts: args.scripts
39320
+ });
39321
+ return { ...history, lookup: "workspace" };
39322
+ }
39308
39323
  function isNativeHistoryFreshEnough(args) {
39309
39324
  const nativeNewest = getMessageNewestReceivedAt(args.nativeMessages);
39310
39325
  const ptyNewest = getMessageNewestReceivedAt(args.ptyMessages);
@@ -40057,18 +40072,7 @@ ${effect.notification.body || ""}`.trim();
40057
40072
  ptyStatusApprovalOnly: true
40058
40073
  });
40059
40074
  } else {
40060
- const fallbackReason = buildNativeHistoryFallbackReason({
40061
- providerType,
40062
- provider,
40063
- nativeSource: nativeHistory.source,
40064
- nativeHistoryCoverage,
40065
- unavailableReason,
40066
- nativeMessageCount: nativeMessages.length,
40067
- safeMapping,
40068
- freshEnough
40069
- });
40070
- const unsafeNativeFallback = adapter.cliType === "codex-cli" && isUnsafeNativeTranscriptFallback(fallbackReason);
40071
- const safeCurrentRuntimePtyMessages = unsafeNativeFallback && isCurrentRuntimePtySafelyAttributed({
40075
+ const liveCurrentRuntimePtySafe = isCurrentRuntimePtySafelyAttributed({
40072
40076
  adapter,
40073
40077
  helpers: h,
40074
40078
  readChatArgs: args,
@@ -40076,57 +40080,130 @@ ${effect.notification.body || ""}`.trim();
40076
40080
  intendedWorkspace,
40077
40081
  ptyMessages: returnedMessages
40078
40082
  });
40079
- const safeRuntimeAckMessages = unsafeNativeFallback && !safeCurrentRuntimePtyMessages ? selectRuntimeInputAckMessages(returnedMessages) : [];
40080
- const exactRuntimeMirrorMessages = unsafeNativeFallback && !safeCurrentRuntimePtyMessages && safeRuntimeAckMessages.length === 0 ? readExactRuntimeMirrorMessages({
40081
- providerType,
40082
- targetSessionId: typeof args?.targetSessionId === "string" ? args.targetSessionId : void 0,
40083
- currentSessionId: typeof h.currentSession?.sessionId === "string" ? h.currentSession.sessionId : void 0,
40084
- tailLimit: nativeHistoryLimit,
40085
- historyBehavior: provider?.historyBehavior
40086
- }) : [];
40087
- const safeDaemonMessages = safeRuntimeAckMessages.length > 0 ? safeRuntimeAckMessages : exactRuntimeMirrorMessages;
40088
- if (unsafeNativeFallback) {
40089
- if (safeCurrentRuntimePtyMessages) {
40090
- selectedMessages = returnedMessages;
40091
- selectedTranscriptAuthority = "daemon";
40092
- selectedCoverage = coverage || "current-turn";
40093
- selectedStatus = returnedStatus;
40094
- } else {
40095
- selectedMessages = safeDaemonMessages;
40096
- selectedTranscriptAuthority = safeDaemonMessages.length > 0 ? "daemon" : void 0;
40097
- selectedCoverage = safeDaemonMessages.length > 0 ? "tail" : void 0;
40098
- selectedStatus = coerceUnsafeNativeFallbackStatus(returnedStatus, activeModal);
40099
- }
40100
- }
40101
- messageSource = buildCliMessageSourceProvenance({
40102
- selected: "pty-parser",
40103
- provider: adapter.cliType,
40104
- nativeHandle: historyProviderSessionId || nativeHistorySessionId || historySessionId,
40105
- sessionWorkspace,
40106
- intendedWorkspace,
40107
- transcriptWorkspace,
40108
- fallbackReason,
40109
- nativeSource: nativeHistory.source,
40110
- sourcePath: nativeHistory.sourcePath,
40111
- sourceMtimeMs: nativeHistory.sourceMtimeMs,
40112
- nativeHistoryCoverage,
40113
- partialReason,
40114
- unavailableReason,
40115
- nativeMessages,
40083
+ const mayProbeLiveCodexWorkspaceNative = adapter.cliType === "codex-cli" && liveCurrentRuntimePtySafe && !(typeof args?.providerSessionId === "string" && args.providerSessionId.trim()) && !(providerSessionId && providerSessionId.trim()) && (!historyProviderSessionId || historyProviderSessionId === nativeHistorySessionId || historyProviderSessionId === historySessionId);
40084
+ const liveWorkspaceNativeHistory = mayProbeLiveCodexWorkspaceNative ? readLiveCodexWorkspaceNativeHistory(agentStr, {
40085
+ canonicalHistory: provider?.canonicalHistory,
40086
+ workspace,
40087
+ offset: 0,
40088
+ limit: nativeHistoryLimit,
40089
+ excludeRecentCount: 0,
40090
+ historyBehavior: provider?.historyBehavior,
40091
+ scripts: provider?.scripts
40092
+ }) : null;
40093
+ const liveWorkspaceNativeMessages = Array.isArray(liveWorkspaceNativeHistory?.messages) ? normalizeNativeHistoryMessages(agentStr, liveWorkspaceNativeHistory.messages, liveWorkspaceNativeHistory?.providerSessionId) : [];
40094
+ const liveWorkspaceNativeProviderSessionId = typeof liveWorkspaceNativeHistory?.providerSessionId === "string" ? liveWorkspaceNativeHistory.providerSessionId : readHistorySessionIdFromMessages(liveWorkspaceNativeMessages);
40095
+ const liveWorkspaceTranscriptWorkspace = typeof liveWorkspaceNativeHistory?.workspace === "string" ? liveWorkspaceNativeHistory.workspace : liveWorkspaceNativeMessages.map((message) => typeof message?.workspace === "string" ? message.workspace.trim() : "").find(Boolean);
40096
+ const liveWorkspaceNativeSafeMapping = liveWorkspaceNativeMessages.length > 0 && hasSafeNativeHistoryMapping({
40097
+ workspace,
40098
+ nativeMessages: liveWorkspaceNativeMessages,
40116
40099
  ptyMessages: returnedMessages,
40117
- returnedMessages: unsafeNativeFallback && !safeCurrentRuntimePtyMessages ? safeDaemonMessages : returnedMessages,
40118
- safeMapping,
40119
- freshEnough,
40120
- ptyStatusApprovalOnly: unsafeNativeFallback && !safeCurrentRuntimePtyMessages
40100
+ requireWorkspaceContentOverlap: true
40101
+ });
40102
+ const liveWorkspaceNativeFreshEnough = liveWorkspaceNativeMessages.length > 0 && isNativeHistoryFreshEnough({
40103
+ sourceMtimeMs: liveWorkspaceNativeHistory?.sourceMtimeMs,
40104
+ nativeMessages: liveWorkspaceNativeMessages,
40105
+ ptyMessages: returnedMessages
40121
40106
  });
40122
- if (safeCurrentRuntimePtyMessages) {
40123
- messageSource.selectedDaemonSource = "current-runtime-pty";
40124
- messageSource.transcriptAuthority = "daemon";
40107
+ const liveWorkspaceNativeUsable = liveWorkspaceNativeHistory?.source === "provider-native" && liveWorkspaceNativeMessages.length > 0 && liveWorkspaceNativeHistory?.nativeHistoryCoverage !== "partial" && liveWorkspaceNativeHistory?.nativeHistoryCoverage !== "unavailable" && liveWorkspaceNativeSafeMapping && liveWorkspaceNativeFreshEnough;
40108
+ if (liveWorkspaceNativeUsable) {
40109
+ selectedMessages = finalizeStreamingMessagesWhenIdle(liveWorkspaceNativeMessages, returnedStatus);
40110
+ selectedProviderSessionId = liveWorkspaceNativeProviderSessionId || providerSessionId;
40111
+ selectedTranscriptAuthority = "provider";
40112
+ selectedCoverage = liveWorkspaceNativeHistory.hasMore ? "tail" : "full";
40113
+ messageSource = buildCliMessageSourceProvenance({
40114
+ selected: "native-history",
40115
+ provider: adapter.cliType,
40116
+ nativeHandle: selectedProviderSessionId || nativeHistorySessionId || historySessionId,
40117
+ sessionWorkspace,
40118
+ intendedWorkspace,
40119
+ transcriptWorkspace: liveWorkspaceTranscriptWorkspace,
40120
+ nativeSource: liveWorkspaceNativeHistory.source,
40121
+ sourcePath: liveWorkspaceNativeHistory.sourcePath,
40122
+ sourceMtimeMs: liveWorkspaceNativeHistory.sourceMtimeMs,
40123
+ nativeHistoryCoverage: liveWorkspaceNativeHistory.nativeHistoryCoverage,
40124
+ partialReason: liveWorkspaceNativeHistory.partialReason,
40125
+ unavailableReason: liveWorkspaceNativeHistory.unavailableReason,
40126
+ nativeMessages: liveWorkspaceNativeMessages,
40127
+ ptyMessages: returnedMessages,
40128
+ returnedMessages: selectedMessages,
40129
+ safeMapping: true,
40130
+ freshEnough: true,
40131
+ ptyStatusApprovalOnly: true
40132
+ });
40133
+ messageSource.selectedDaemonSource = "live-workspace-native-history";
40125
40134
  messageSource.runtimeMappingSafe = true;
40126
- }
40127
- if (unsafeNativeFallback && exactRuntimeMirrorMessages.length > 0) {
40128
- messageSource.selectedDaemonSource = "exact-runtime-mirror";
40129
- messageSource.transcriptAuthority = "daemon";
40135
+ } else {
40136
+ const fallbackReason = buildNativeHistoryFallbackReason({
40137
+ providerType,
40138
+ provider,
40139
+ nativeSource: nativeHistory.source,
40140
+ nativeHistoryCoverage,
40141
+ unavailableReason,
40142
+ nativeMessageCount: nativeMessages.length,
40143
+ safeMapping,
40144
+ freshEnough
40145
+ });
40146
+ const unsafeNativeFallback = adapter.cliType === "codex-cli" && isUnsafeNativeTranscriptFallback(fallbackReason);
40147
+ const safeCurrentRuntimePtyMessages = unsafeNativeFallback && isCurrentRuntimePtySafelyAttributed({
40148
+ adapter,
40149
+ helpers: h,
40150
+ readChatArgs: args,
40151
+ sessionWorkspace,
40152
+ intendedWorkspace,
40153
+ ptyMessages: returnedMessages
40154
+ });
40155
+ const safeRuntimeAckMessages = unsafeNativeFallback && !safeCurrentRuntimePtyMessages ? selectRuntimeInputAckMessages(returnedMessages) : [];
40156
+ const exactRuntimeMirrorMessages = unsafeNativeFallback && !safeCurrentRuntimePtyMessages && safeRuntimeAckMessages.length === 0 ? readExactRuntimeMirrorMessages({
40157
+ providerType,
40158
+ targetSessionId: typeof args?.targetSessionId === "string" ? args.targetSessionId : void 0,
40159
+ currentSessionId: typeof h.currentSession?.sessionId === "string" ? h.currentSession.sessionId : void 0,
40160
+ tailLimit: nativeHistoryLimit,
40161
+ historyBehavior: provider?.historyBehavior
40162
+ }) : [];
40163
+ const safeDaemonMessages = safeRuntimeAckMessages.length > 0 ? safeRuntimeAckMessages : exactRuntimeMirrorMessages;
40164
+ if (unsafeNativeFallback) {
40165
+ if (safeCurrentRuntimePtyMessages) {
40166
+ selectedMessages = returnedMessages;
40167
+ selectedTranscriptAuthority = "daemon";
40168
+ selectedCoverage = coverage || "current-turn";
40169
+ selectedStatus = returnedStatus;
40170
+ } else {
40171
+ selectedMessages = safeDaemonMessages;
40172
+ selectedTranscriptAuthority = safeDaemonMessages.length > 0 ? "daemon" : void 0;
40173
+ selectedCoverage = safeDaemonMessages.length > 0 ? "tail" : void 0;
40174
+ selectedStatus = coerceUnsafeNativeFallbackStatus(returnedStatus, activeModal);
40175
+ }
40176
+ }
40177
+ messageSource = buildCliMessageSourceProvenance({
40178
+ selected: "pty-parser",
40179
+ provider: adapter.cliType,
40180
+ nativeHandle: historyProviderSessionId || nativeHistorySessionId || historySessionId,
40181
+ sessionWorkspace,
40182
+ intendedWorkspace,
40183
+ transcriptWorkspace,
40184
+ fallbackReason,
40185
+ nativeSource: nativeHistory.source,
40186
+ sourcePath: nativeHistory.sourcePath,
40187
+ sourceMtimeMs: nativeHistory.sourceMtimeMs,
40188
+ nativeHistoryCoverage,
40189
+ partialReason,
40190
+ unavailableReason,
40191
+ nativeMessages,
40192
+ ptyMessages: returnedMessages,
40193
+ returnedMessages: unsafeNativeFallback && !safeCurrentRuntimePtyMessages ? safeDaemonMessages : returnedMessages,
40194
+ safeMapping,
40195
+ freshEnough,
40196
+ ptyStatusApprovalOnly: unsafeNativeFallback && !safeCurrentRuntimePtyMessages
40197
+ });
40198
+ if (safeCurrentRuntimePtyMessages) {
40199
+ messageSource.selectedDaemonSource = "current-runtime-pty";
40200
+ messageSource.transcriptAuthority = "daemon";
40201
+ messageSource.runtimeMappingSafe = true;
40202
+ }
40203
+ if (unsafeNativeFallback && exactRuntimeMirrorMessages.length > 0) {
40204
+ messageSource.selectedDaemonSource = "exact-runtime-mirror";
40205
+ messageSource.transcriptAuthority = "daemon";
40206
+ }
40130
40207
  }
40131
40208
  }
40132
40209
  }