@adhdev/daemon-core 0.9.82-rc.91 → 0.9.82-rc.93
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 +82 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +82 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/cli-adapters/provider-cli-adapter.ts +2 -1
- package/src/commands/chat-commands.ts +99 -13
package/dist/index.js
CHANGED
|
@@ -5881,7 +5881,7 @@ ${lastSnapshot}`;
|
|
|
5881
5881
|
const parseScreenText = this.getParseScreenText(screenText);
|
|
5882
5882
|
const cached = this.parsedStatusCache;
|
|
5883
5883
|
const accumulatedRawBufferKey = this.getAccumulatedRawBufferCacheKey();
|
|
5884
|
-
if (cached && cached.responseBuffer === this.responseBuffer && cached.currentTurnScope === this.currentTurnScope && cached.recentOutputBuffer === this.recentOutputBuffer && cached.accumulatedBuffer === this.accumulatedBuffer && cached.accumulatedRawBufferKey === accumulatedRawBufferKey && cached.screenText === parseScreenText && cached.currentStatus === this.currentStatus && cached.activeModal === this.activeModal && cached.cliName === this.cliName) {
|
|
5884
|
+
if (!this.providerOwnsTranscript() && cached && cached.responseBuffer === this.responseBuffer && cached.currentTurnScope === this.currentTurnScope && cached.recentOutputBuffer === this.recentOutputBuffer && cached.accumulatedBuffer === this.accumulatedBuffer && cached.accumulatedRawBufferKey === accumulatedRawBufferKey && cached.screenText === parseScreenText && cached.currentStatus === this.currentStatus && cached.activeModal === this.activeModal && cached.cliName === this.cliName) {
|
|
5885
5885
|
return cached.result;
|
|
5886
5886
|
}
|
|
5887
5887
|
const parsed = this.runParseSession();
|
|
@@ -15999,6 +15999,13 @@ function getCurrentManagerKey(h) {
|
|
|
15999
15999
|
function getTargetedCliAdapter(h, args, providerType) {
|
|
16000
16000
|
return h.getCliAdapter(args?.targetSessionId || providerType || h.currentSession?.providerType || h.currentManagerKey);
|
|
16001
16001
|
}
|
|
16002
|
+
function getExplicitHistorySessionId(args) {
|
|
16003
|
+
const explicit = typeof args?.historySessionId === "string" ? args.historySessionId.trim() : "";
|
|
16004
|
+
if (explicit) return explicit;
|
|
16005
|
+
const explicitProviderSessionId = typeof args?.providerSessionId === "string" ? args.providerSessionId.trim() : "";
|
|
16006
|
+
if (explicitProviderSessionId) return explicitProviderSessionId;
|
|
16007
|
+
return void 0;
|
|
16008
|
+
}
|
|
16002
16009
|
function getTargetInstance(h, args) {
|
|
16003
16010
|
const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
|
|
16004
16011
|
const sessionId = targetSessionId || h.currentSession?.sessionId || "";
|
|
@@ -16067,13 +16074,14 @@ async function waitOnceForFreshHermesCliStart(adapter, log) {
|
|
|
16067
16074
|
await sleep(HERMES_CLI_STARTING_SEND_SETTLE_MS);
|
|
16068
16075
|
}
|
|
16069
16076
|
function getHistorySessionId(h, args) {
|
|
16070
|
-
const explicit =
|
|
16077
|
+
const explicit = getExplicitHistorySessionId(args);
|
|
16071
16078
|
if (explicit) return explicit;
|
|
16072
|
-
const explicitProviderSessionId = typeof args?.providerSessionId === "string" ? args.providerSessionId.trim() : "";
|
|
16073
|
-
if (explicitProviderSessionId) return explicitProviderSessionId;
|
|
16074
16079
|
const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
|
|
16075
16080
|
if (!targetSessionId) return void 0;
|
|
16076
|
-
const
|
|
16081
|
+
const session = h.ctx.sessionRegistry?.get(targetSessionId);
|
|
16082
|
+
const registeredProviderSessionId = typeof session?.providerSessionId === "string" ? session.providerSessionId.trim() : "";
|
|
16083
|
+
if (registeredProviderSessionId) return registeredProviderSessionId;
|
|
16084
|
+
const instance = getTargetInstance(h, args);
|
|
16077
16085
|
const state = instance?.getState?.();
|
|
16078
16086
|
const providerSessionId = typeof state?.providerSessionId === "string" ? state.providerSessionId.trim() : "";
|
|
16079
16087
|
if (providerSessionId) return providerSessionId;
|
|
@@ -16084,6 +16092,15 @@ function getHistorySessionId(h, args) {
|
|
|
16084
16092
|
}
|
|
16085
16093
|
return targetSessionId;
|
|
16086
16094
|
}
|
|
16095
|
+
function resolveCliNativeHistorySessionId(args, currentHistorySessionId, parsedProviderSessionId) {
|
|
16096
|
+
const explicit = getExplicitHistorySessionId(args);
|
|
16097
|
+
if (explicit) return explicit;
|
|
16098
|
+
const parsed = typeof parsedProviderSessionId === "string" ? parsedProviderSessionId.trim() : "";
|
|
16099
|
+
const current = typeof currentHistorySessionId === "string" ? currentHistorySessionId.trim() : "";
|
|
16100
|
+
const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
|
|
16101
|
+
if (parsed && (!current || current === targetSessionId)) return parsed;
|
|
16102
|
+
return current || parsed || void 0;
|
|
16103
|
+
}
|
|
16087
16104
|
function getInteractionId(args) {
|
|
16088
16105
|
return typeof args?._interactionId === "string" && args._interactionId.trim() ? args._interactionId.trim() : void 0;
|
|
16089
16106
|
}
|
|
@@ -16228,6 +16245,29 @@ function supportsCliNativeTranscript(providerType, provider) {
|
|
|
16228
16245
|
if (CLI_NATIVE_TRANSCRIPT_PROVIDERS.has(providerType)) return true;
|
|
16229
16246
|
return provider?.category === "cli" && isNativeSourceCanonicalHistory(provider?.canonicalHistory);
|
|
16230
16247
|
}
|
|
16248
|
+
function getComparableVisibleText(message) {
|
|
16249
|
+
if (!message) return "";
|
|
16250
|
+
const role = String(message.role || "").trim().toLowerCase();
|
|
16251
|
+
if (role !== "user" && role !== "assistant") return "";
|
|
16252
|
+
const kind = String(message.kind || "standard").trim().toLowerCase();
|
|
16253
|
+
if (kind && kind !== "standard") return "";
|
|
16254
|
+
const content = flattenContent(message.content).replace(/\s+/g, " ").trim();
|
|
16255
|
+
return content;
|
|
16256
|
+
}
|
|
16257
|
+
function hasOverlappingVisibleConversationText(nativeMessages, ptyMessages) {
|
|
16258
|
+
const nativeTexts = nativeMessages.map(getComparableVisibleText).filter(Boolean);
|
|
16259
|
+
const ptyTexts = ptyMessages.map(getComparableVisibleText).filter(Boolean);
|
|
16260
|
+
if (nativeTexts.length === 0 || ptyTexts.length === 0) return false;
|
|
16261
|
+
for (const nativeText of nativeTexts) {
|
|
16262
|
+
for (const ptyText of ptyTexts) {
|
|
16263
|
+
if (nativeText === ptyText) return true;
|
|
16264
|
+
const shorter = nativeText.length <= ptyText.length ? nativeText : ptyText;
|
|
16265
|
+
const longer = nativeText.length <= ptyText.length ? ptyText : nativeText;
|
|
16266
|
+
if (shorter.length >= 32 && longer.includes(shorter)) return true;
|
|
16267
|
+
}
|
|
16268
|
+
}
|
|
16269
|
+
return false;
|
|
16270
|
+
}
|
|
16231
16271
|
function hasSafeNativeHistoryMapping(args) {
|
|
16232
16272
|
const explicitSessionId = String(args.historySessionId || args.providerSessionId || "").trim();
|
|
16233
16273
|
if (explicitSessionId) {
|
|
@@ -16237,7 +16277,10 @@ function hasSafeNativeHistoryMapping(args) {
|
|
|
16237
16277
|
}
|
|
16238
16278
|
const workspace = String(args.workspace || "").trim();
|
|
16239
16279
|
if (!workspace) return false;
|
|
16240
|
-
|
|
16280
|
+
const workspaceMatches = args.nativeMessages.some((message) => String(message?.workspace || "").trim() === workspace);
|
|
16281
|
+
if (!workspaceMatches) return false;
|
|
16282
|
+
if (!args.requireWorkspaceContentOverlap) return true;
|
|
16283
|
+
return hasOverlappingVisibleConversationText(args.nativeMessages, args.ptyMessages || []);
|
|
16241
16284
|
}
|
|
16242
16285
|
function readCliProviderNativeHistory(agentStr, args) {
|
|
16243
16286
|
const sessionHistory = readProviderChatHistory(agentStr, {
|
|
@@ -16276,6 +16319,19 @@ function isNativeHistoryFreshEnough(args) {
|
|
|
16276
16319
|
function shouldPreserveReadChatPayloadField(key) {
|
|
16277
16320
|
return key === "messageSource" || key === "transcriptProvenance";
|
|
16278
16321
|
}
|
|
16322
|
+
function updateMessageSourceReturnedCount(value, returnedMessageCount) {
|
|
16323
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return value;
|
|
16324
|
+
const record = value;
|
|
16325
|
+
const coverage = record.coverage && typeof record.coverage === "object" && !Array.isArray(record.coverage) ? record.coverage : void 0;
|
|
16326
|
+
if (!coverage) return value;
|
|
16327
|
+
return {
|
|
16328
|
+
...record,
|
|
16329
|
+
coverage: {
|
|
16330
|
+
...coverage,
|
|
16331
|
+
returnedMessageCount
|
|
16332
|
+
}
|
|
16333
|
+
};
|
|
16334
|
+
}
|
|
16279
16335
|
function deriveHistoryDedupKey(message) {
|
|
16280
16336
|
const unitKey = typeof message._unitKey === "string" ? message._unitKey.trim() : "";
|
|
16281
16337
|
if (unitKey) return `read_chat:${unitKey}`;
|
|
@@ -16387,6 +16443,13 @@ function buildReadChatCommandResult(payload, args) {
|
|
|
16387
16443
|
const visibleMessages = filterUserFacingChatMessages(messages);
|
|
16388
16444
|
const sync = buildFullTail(visibleMessages, normalizeReadChatTailLimit(args));
|
|
16389
16445
|
const hiddenMsgCount = Math.max(0, messages.length - visibleMessages.length);
|
|
16446
|
+
const preservedPayloadFields = Object.fromEntries(Object.entries(payload).filter(([key]) => shouldPreserveReadChatPayloadField(key)));
|
|
16447
|
+
if (preservedPayloadFields.messageSource) {
|
|
16448
|
+
preservedPayloadFields.messageSource = updateMessageSourceReturnedCount(preservedPayloadFields.messageSource, sync.messages.length);
|
|
16449
|
+
}
|
|
16450
|
+
if (preservedPayloadFields.transcriptProvenance) {
|
|
16451
|
+
preservedPayloadFields.transcriptProvenance = updateMessageSourceReturnedCount(preservedPayloadFields.transcriptProvenance, sync.messages.length);
|
|
16452
|
+
}
|
|
16390
16453
|
const returnedDebugReadChat = debugReadChat ? {
|
|
16391
16454
|
...debugReadChat,
|
|
16392
16455
|
fullMsgCount: typeof debugReadChat.fullMsgCount === "number" ? debugReadChat.fullMsgCount : messages.length,
|
|
@@ -16397,7 +16460,7 @@ function buildReadChatCommandResult(payload, args) {
|
|
|
16397
16460
|
return {
|
|
16398
16461
|
success: true,
|
|
16399
16462
|
...validatedPayload,
|
|
16400
|
-
...
|
|
16463
|
+
...preservedPayloadFields,
|
|
16401
16464
|
messages: sync.messages,
|
|
16402
16465
|
totalMessages: sync.totalMessages,
|
|
16403
16466
|
...returnedDebugReadChat ? { debugReadChat: returnedDebugReadChat } : {}
|
|
@@ -16872,14 +16935,16 @@ async function handleReadChat(h, args) {
|
|
|
16872
16935
|
returnedMessages.length,
|
|
16873
16936
|
200
|
|
16874
16937
|
);
|
|
16938
|
+
const nativeHistorySessionId = resolveCliNativeHistorySessionId(args, historySessionId, providerSessionId);
|
|
16939
|
+
const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
|
|
16875
16940
|
const exactNativeHistoryScope = Boolean(
|
|
16876
|
-
typeof args?.historySessionId === "string" && args.historySessionId.trim() || typeof args?.providerSessionId === "string" && args.providerSessionId.trim() || providerSessionId || h.currentSession?.sessionId === args?.targetSessionId && typeof h.currentSession?.providerSessionId === "string" && h.currentSession.providerSessionId.trim()
|
|
16941
|
+
typeof args?.historySessionId === "string" && args.historySessionId.trim() || typeof args?.providerSessionId === "string" && args.providerSessionId.trim() || providerSessionId || nativeHistorySessionId && nativeHistorySessionId !== targetSessionId || h.currentSession?.sessionId === args?.targetSessionId && typeof h.currentSession?.providerSessionId === "string" && h.currentSession.providerSessionId.trim()
|
|
16877
16942
|
);
|
|
16878
16943
|
let nativeHistory = null;
|
|
16879
16944
|
try {
|
|
16880
16945
|
nativeHistory = readCliProviderNativeHistory(agentStr, {
|
|
16881
16946
|
canonicalHistory: provider?.canonicalHistory,
|
|
16882
|
-
historySessionId,
|
|
16947
|
+
historySessionId: nativeHistorySessionId,
|
|
16883
16948
|
workspace,
|
|
16884
16949
|
offset: 0,
|
|
16885
16950
|
limit: nativeHistoryLimit,
|
|
@@ -16902,13 +16967,15 @@ async function handleReadChat(h, args) {
|
|
|
16902
16967
|
}
|
|
16903
16968
|
if (nativeHistory) {
|
|
16904
16969
|
const nativeMessages = Array.isArray(nativeHistory.messages) ? normalizeNativeHistoryMessages(agentStr, nativeHistory.messages) : [];
|
|
16905
|
-
const historyProviderSessionId = typeof nativeHistory?.providerSessionId === "string" ? nativeHistory.providerSessionId : readHistorySessionIdFromMessages(nativeMessages) || historySessionId;
|
|
16970
|
+
const historyProviderSessionId = typeof nativeHistory?.providerSessionId === "string" ? nativeHistory.providerSessionId : readHistorySessionIdFromMessages(nativeMessages) || nativeHistorySessionId || historySessionId;
|
|
16906
16971
|
const lookup = nativeHistory.lookup === "workspace" ? "workspace" : "session";
|
|
16907
16972
|
const safeMapping = hasSafeNativeHistoryMapping({
|
|
16908
|
-
historySessionId: lookup === "workspace" ? void 0 :
|
|
16909
|
-
providerSessionId: lookup === "workspace" ? void 0 : providerSessionId,
|
|
16973
|
+
historySessionId: lookup === "workspace" ? void 0 : nativeHistorySessionId,
|
|
16974
|
+
providerSessionId: lookup === "workspace" ? void 0 : historyProviderSessionId || providerSessionId,
|
|
16910
16975
|
workspace,
|
|
16911
|
-
nativeMessages
|
|
16976
|
+
nativeMessages,
|
|
16977
|
+
ptyMessages: returnedMessages,
|
|
16978
|
+
requireWorkspaceContentOverlap: lookup === "workspace" && !exactNativeHistoryScope
|
|
16912
16979
|
});
|
|
16913
16980
|
const freshEnough = isNativeHistoryFreshEnough({
|
|
16914
16981
|
sourceMtimeMs: nativeHistory.sourceMtimeMs,
|
|
@@ -16923,7 +16990,7 @@ async function handleReadChat(h, args) {
|
|
|
16923
16990
|
messageSource = buildCliMessageSourceProvenance({
|
|
16924
16991
|
selected: "native-history",
|
|
16925
16992
|
provider: adapter.cliType,
|
|
16926
|
-
nativeHandle: selectedProviderSessionId || historySessionId,
|
|
16993
|
+
nativeHandle: selectedProviderSessionId || nativeHistorySessionId || historySessionId,
|
|
16927
16994
|
nativeSource: nativeHistory.source,
|
|
16928
16995
|
sourcePath: nativeHistory.sourcePath,
|
|
16929
16996
|
sourceMtimeMs: nativeHistory.sourceMtimeMs,
|
|
@@ -16946,7 +17013,7 @@ async function handleReadChat(h, args) {
|
|
|
16946
17013
|
messageSource = buildCliMessageSourceProvenance({
|
|
16947
17014
|
selected: "pty-parser",
|
|
16948
17015
|
provider: adapter.cliType,
|
|
16949
|
-
nativeHandle: historyProviderSessionId || historySessionId,
|
|
17016
|
+
nativeHandle: historyProviderSessionId || nativeHistorySessionId || historySessionId,
|
|
16950
17017
|
fallbackReason,
|
|
16951
17018
|
nativeSource: nativeHistory.source,
|
|
16952
17019
|
sourcePath: nativeHistory.sourcePath,
|