@adhdev/daemon-core 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 +137 -60
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +137 -60
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/commands/chat-commands.ts +178 -73
package/dist/index.js
CHANGED
|
@@ -17279,6 +17279,21 @@ function readCliProviderNativeHistory(agentStr, args) {
|
|
|
17279
17279
|
});
|
|
17280
17280
|
return { ...sessionHistory, lookup: "session" };
|
|
17281
17281
|
}
|
|
17282
|
+
function readLiveCodexWorkspaceNativeHistory(agentStr, args) {
|
|
17283
|
+
if (agentStr !== "codex-cli") return null;
|
|
17284
|
+
const workspace = typeof args.workspace === "string" ? args.workspace.trim() : "";
|
|
17285
|
+
if (!workspace) return null;
|
|
17286
|
+
const history = readProviderChatHistory(agentStr, {
|
|
17287
|
+
canonicalHistory: args.canonicalHistory,
|
|
17288
|
+
workspace,
|
|
17289
|
+
offset: args.offset,
|
|
17290
|
+
limit: args.limit,
|
|
17291
|
+
excludeRecentCount: args.excludeRecentCount,
|
|
17292
|
+
historyBehavior: args.historyBehavior,
|
|
17293
|
+
scripts: args.scripts
|
|
17294
|
+
});
|
|
17295
|
+
return { ...history, lookup: "workspace" };
|
|
17296
|
+
}
|
|
17282
17297
|
function isNativeHistoryFreshEnough(args) {
|
|
17283
17298
|
const nativeNewest = getMessageNewestReceivedAt(args.nativeMessages);
|
|
17284
17299
|
const ptyNewest = getMessageNewestReceivedAt(args.ptyMessages);
|
|
@@ -18031,18 +18046,7 @@ async function handleReadChat(h, args) {
|
|
|
18031
18046
|
ptyStatusApprovalOnly: true
|
|
18032
18047
|
});
|
|
18033
18048
|
} else {
|
|
18034
|
-
const
|
|
18035
|
-
providerType,
|
|
18036
|
-
provider,
|
|
18037
|
-
nativeSource: nativeHistory.source,
|
|
18038
|
-
nativeHistoryCoverage,
|
|
18039
|
-
unavailableReason,
|
|
18040
|
-
nativeMessageCount: nativeMessages.length,
|
|
18041
|
-
safeMapping,
|
|
18042
|
-
freshEnough
|
|
18043
|
-
});
|
|
18044
|
-
const unsafeNativeFallback = adapter.cliType === "codex-cli" && isUnsafeNativeTranscriptFallback(fallbackReason);
|
|
18045
|
-
const safeCurrentRuntimePtyMessages = unsafeNativeFallback && isCurrentRuntimePtySafelyAttributed({
|
|
18049
|
+
const liveCurrentRuntimePtySafe = isCurrentRuntimePtySafelyAttributed({
|
|
18046
18050
|
adapter,
|
|
18047
18051
|
helpers: h,
|
|
18048
18052
|
readChatArgs: args,
|
|
@@ -18050,57 +18054,130 @@ async function handleReadChat(h, args) {
|
|
|
18050
18054
|
intendedWorkspace,
|
|
18051
18055
|
ptyMessages: returnedMessages
|
|
18052
18056
|
});
|
|
18053
|
-
const
|
|
18054
|
-
const
|
|
18055
|
-
|
|
18056
|
-
|
|
18057
|
-
|
|
18058
|
-
|
|
18059
|
-
|
|
18060
|
-
|
|
18061
|
-
|
|
18062
|
-
|
|
18063
|
-
|
|
18064
|
-
|
|
18065
|
-
|
|
18066
|
-
|
|
18067
|
-
|
|
18068
|
-
|
|
18069
|
-
selectedMessages = safeDaemonMessages;
|
|
18070
|
-
selectedTranscriptAuthority = safeDaemonMessages.length > 0 ? "daemon" : void 0;
|
|
18071
|
-
selectedCoverage = safeDaemonMessages.length > 0 ? "tail" : void 0;
|
|
18072
|
-
selectedStatus = coerceUnsafeNativeFallbackStatus(returnedStatus, activeModal);
|
|
18073
|
-
}
|
|
18074
|
-
}
|
|
18075
|
-
messageSource = buildCliMessageSourceProvenance({
|
|
18076
|
-
selected: "pty-parser",
|
|
18077
|
-
provider: adapter.cliType,
|
|
18078
|
-
nativeHandle: historyProviderSessionId || nativeHistorySessionId || historySessionId,
|
|
18079
|
-
sessionWorkspace,
|
|
18080
|
-
intendedWorkspace,
|
|
18081
|
-
transcriptWorkspace,
|
|
18082
|
-
fallbackReason,
|
|
18083
|
-
nativeSource: nativeHistory.source,
|
|
18084
|
-
sourcePath: nativeHistory.sourcePath,
|
|
18085
|
-
sourceMtimeMs: nativeHistory.sourceMtimeMs,
|
|
18086
|
-
nativeHistoryCoverage,
|
|
18087
|
-
partialReason,
|
|
18088
|
-
unavailableReason,
|
|
18089
|
-
nativeMessages,
|
|
18057
|
+
const mayProbeLiveCodexWorkspaceNative = adapter.cliType === "codex-cli" && liveCurrentRuntimePtySafe && !(typeof args?.providerSessionId === "string" && args.providerSessionId.trim()) && !(providerSessionId && providerSessionId.trim()) && (!historyProviderSessionId || historyProviderSessionId === nativeHistorySessionId || historyProviderSessionId === historySessionId);
|
|
18058
|
+
const liveWorkspaceNativeHistory = mayProbeLiveCodexWorkspaceNative ? readLiveCodexWorkspaceNativeHistory(agentStr, {
|
|
18059
|
+
canonicalHistory: provider?.canonicalHistory,
|
|
18060
|
+
workspace,
|
|
18061
|
+
offset: 0,
|
|
18062
|
+
limit: nativeHistoryLimit,
|
|
18063
|
+
excludeRecentCount: 0,
|
|
18064
|
+
historyBehavior: provider?.historyBehavior,
|
|
18065
|
+
scripts: provider?.scripts
|
|
18066
|
+
}) : null;
|
|
18067
|
+
const liveWorkspaceNativeMessages = Array.isArray(liveWorkspaceNativeHistory?.messages) ? normalizeNativeHistoryMessages(agentStr, liveWorkspaceNativeHistory.messages, liveWorkspaceNativeHistory?.providerSessionId) : [];
|
|
18068
|
+
const liveWorkspaceNativeProviderSessionId = typeof liveWorkspaceNativeHistory?.providerSessionId === "string" ? liveWorkspaceNativeHistory.providerSessionId : readHistorySessionIdFromMessages(liveWorkspaceNativeMessages);
|
|
18069
|
+
const liveWorkspaceTranscriptWorkspace = typeof liveWorkspaceNativeHistory?.workspace === "string" ? liveWorkspaceNativeHistory.workspace : liveWorkspaceNativeMessages.map((message) => typeof message?.workspace === "string" ? message.workspace.trim() : "").find(Boolean);
|
|
18070
|
+
const liveWorkspaceNativeSafeMapping = liveWorkspaceNativeMessages.length > 0 && hasSafeNativeHistoryMapping({
|
|
18071
|
+
workspace,
|
|
18072
|
+
nativeMessages: liveWorkspaceNativeMessages,
|
|
18090
18073
|
ptyMessages: returnedMessages,
|
|
18091
|
-
|
|
18092
|
-
|
|
18093
|
-
|
|
18094
|
-
|
|
18074
|
+
requireWorkspaceContentOverlap: true
|
|
18075
|
+
});
|
|
18076
|
+
const liveWorkspaceNativeFreshEnough = liveWorkspaceNativeMessages.length > 0 && isNativeHistoryFreshEnough({
|
|
18077
|
+
sourceMtimeMs: liveWorkspaceNativeHistory?.sourceMtimeMs,
|
|
18078
|
+
nativeMessages: liveWorkspaceNativeMessages,
|
|
18079
|
+
ptyMessages: returnedMessages
|
|
18095
18080
|
});
|
|
18096
|
-
|
|
18097
|
-
|
|
18098
|
-
|
|
18081
|
+
const liveWorkspaceNativeUsable = liveWorkspaceNativeHistory?.source === "provider-native" && liveWorkspaceNativeMessages.length > 0 && liveWorkspaceNativeHistory?.nativeHistoryCoverage !== "partial" && liveWorkspaceNativeHistory?.nativeHistoryCoverage !== "unavailable" && liveWorkspaceNativeSafeMapping && liveWorkspaceNativeFreshEnough;
|
|
18082
|
+
if (liveWorkspaceNativeUsable) {
|
|
18083
|
+
selectedMessages = finalizeStreamingMessagesWhenIdle(liveWorkspaceNativeMessages, returnedStatus);
|
|
18084
|
+
selectedProviderSessionId = liveWorkspaceNativeProviderSessionId || providerSessionId;
|
|
18085
|
+
selectedTranscriptAuthority = "provider";
|
|
18086
|
+
selectedCoverage = liveWorkspaceNativeHistory.hasMore ? "tail" : "full";
|
|
18087
|
+
messageSource = buildCliMessageSourceProvenance({
|
|
18088
|
+
selected: "native-history",
|
|
18089
|
+
provider: adapter.cliType,
|
|
18090
|
+
nativeHandle: selectedProviderSessionId || nativeHistorySessionId || historySessionId,
|
|
18091
|
+
sessionWorkspace,
|
|
18092
|
+
intendedWorkspace,
|
|
18093
|
+
transcriptWorkspace: liveWorkspaceTranscriptWorkspace,
|
|
18094
|
+
nativeSource: liveWorkspaceNativeHistory.source,
|
|
18095
|
+
sourcePath: liveWorkspaceNativeHistory.sourcePath,
|
|
18096
|
+
sourceMtimeMs: liveWorkspaceNativeHistory.sourceMtimeMs,
|
|
18097
|
+
nativeHistoryCoverage: liveWorkspaceNativeHistory.nativeHistoryCoverage,
|
|
18098
|
+
partialReason: liveWorkspaceNativeHistory.partialReason,
|
|
18099
|
+
unavailableReason: liveWorkspaceNativeHistory.unavailableReason,
|
|
18100
|
+
nativeMessages: liveWorkspaceNativeMessages,
|
|
18101
|
+
ptyMessages: returnedMessages,
|
|
18102
|
+
returnedMessages: selectedMessages,
|
|
18103
|
+
safeMapping: true,
|
|
18104
|
+
freshEnough: true,
|
|
18105
|
+
ptyStatusApprovalOnly: true
|
|
18106
|
+
});
|
|
18107
|
+
messageSource.selectedDaemonSource = "live-workspace-native-history";
|
|
18099
18108
|
messageSource.runtimeMappingSafe = true;
|
|
18100
|
-
}
|
|
18101
|
-
|
|
18102
|
-
|
|
18103
|
-
|
|
18109
|
+
} else {
|
|
18110
|
+
const fallbackReason = buildNativeHistoryFallbackReason({
|
|
18111
|
+
providerType,
|
|
18112
|
+
provider,
|
|
18113
|
+
nativeSource: nativeHistory.source,
|
|
18114
|
+
nativeHistoryCoverage,
|
|
18115
|
+
unavailableReason,
|
|
18116
|
+
nativeMessageCount: nativeMessages.length,
|
|
18117
|
+
safeMapping,
|
|
18118
|
+
freshEnough
|
|
18119
|
+
});
|
|
18120
|
+
const unsafeNativeFallback = adapter.cliType === "codex-cli" && isUnsafeNativeTranscriptFallback(fallbackReason);
|
|
18121
|
+
const safeCurrentRuntimePtyMessages = unsafeNativeFallback && isCurrentRuntimePtySafelyAttributed({
|
|
18122
|
+
adapter,
|
|
18123
|
+
helpers: h,
|
|
18124
|
+
readChatArgs: args,
|
|
18125
|
+
sessionWorkspace,
|
|
18126
|
+
intendedWorkspace,
|
|
18127
|
+
ptyMessages: returnedMessages
|
|
18128
|
+
});
|
|
18129
|
+
const safeRuntimeAckMessages = unsafeNativeFallback && !safeCurrentRuntimePtyMessages ? selectRuntimeInputAckMessages(returnedMessages) : [];
|
|
18130
|
+
const exactRuntimeMirrorMessages = unsafeNativeFallback && !safeCurrentRuntimePtyMessages && safeRuntimeAckMessages.length === 0 ? readExactRuntimeMirrorMessages({
|
|
18131
|
+
providerType,
|
|
18132
|
+
targetSessionId: typeof args?.targetSessionId === "string" ? args.targetSessionId : void 0,
|
|
18133
|
+
currentSessionId: typeof h.currentSession?.sessionId === "string" ? h.currentSession.sessionId : void 0,
|
|
18134
|
+
tailLimit: nativeHistoryLimit,
|
|
18135
|
+
historyBehavior: provider?.historyBehavior
|
|
18136
|
+
}) : [];
|
|
18137
|
+
const safeDaemonMessages = safeRuntimeAckMessages.length > 0 ? safeRuntimeAckMessages : exactRuntimeMirrorMessages;
|
|
18138
|
+
if (unsafeNativeFallback) {
|
|
18139
|
+
if (safeCurrentRuntimePtyMessages) {
|
|
18140
|
+
selectedMessages = returnedMessages;
|
|
18141
|
+
selectedTranscriptAuthority = "daemon";
|
|
18142
|
+
selectedCoverage = coverage || "current-turn";
|
|
18143
|
+
selectedStatus = returnedStatus;
|
|
18144
|
+
} else {
|
|
18145
|
+
selectedMessages = safeDaemonMessages;
|
|
18146
|
+
selectedTranscriptAuthority = safeDaemonMessages.length > 0 ? "daemon" : void 0;
|
|
18147
|
+
selectedCoverage = safeDaemonMessages.length > 0 ? "tail" : void 0;
|
|
18148
|
+
selectedStatus = coerceUnsafeNativeFallbackStatus(returnedStatus, activeModal);
|
|
18149
|
+
}
|
|
18150
|
+
}
|
|
18151
|
+
messageSource = buildCliMessageSourceProvenance({
|
|
18152
|
+
selected: "pty-parser",
|
|
18153
|
+
provider: adapter.cliType,
|
|
18154
|
+
nativeHandle: historyProviderSessionId || nativeHistorySessionId || historySessionId,
|
|
18155
|
+
sessionWorkspace,
|
|
18156
|
+
intendedWorkspace,
|
|
18157
|
+
transcriptWorkspace,
|
|
18158
|
+
fallbackReason,
|
|
18159
|
+
nativeSource: nativeHistory.source,
|
|
18160
|
+
sourcePath: nativeHistory.sourcePath,
|
|
18161
|
+
sourceMtimeMs: nativeHistory.sourceMtimeMs,
|
|
18162
|
+
nativeHistoryCoverage,
|
|
18163
|
+
partialReason,
|
|
18164
|
+
unavailableReason,
|
|
18165
|
+
nativeMessages,
|
|
18166
|
+
ptyMessages: returnedMessages,
|
|
18167
|
+
returnedMessages: unsafeNativeFallback && !safeCurrentRuntimePtyMessages ? safeDaemonMessages : returnedMessages,
|
|
18168
|
+
safeMapping,
|
|
18169
|
+
freshEnough,
|
|
18170
|
+
ptyStatusApprovalOnly: unsafeNativeFallback && !safeCurrentRuntimePtyMessages
|
|
18171
|
+
});
|
|
18172
|
+
if (safeCurrentRuntimePtyMessages) {
|
|
18173
|
+
messageSource.selectedDaemonSource = "current-runtime-pty";
|
|
18174
|
+
messageSource.transcriptAuthority = "daemon";
|
|
18175
|
+
messageSource.runtimeMappingSafe = true;
|
|
18176
|
+
}
|
|
18177
|
+
if (unsafeNativeFallback && exactRuntimeMirrorMessages.length > 0) {
|
|
18178
|
+
messageSource.selectedDaemonSource = "exact-runtime-mirror";
|
|
18179
|
+
messageSource.transcriptAuthority = "daemon";
|
|
18180
|
+
}
|
|
18104
18181
|
}
|
|
18105
18182
|
}
|
|
18106
18183
|
}
|