@adhdev/daemon-standalone 0.9.82-rc.90 → 0.9.82-rc.92
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 +107 -28
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -31533,7 +31533,19 @@ ${lastSnapshot}`;
|
|
|
31533
31533
|
if (!node) return { staleReason: "direct task node is no longer in the live mesh" };
|
|
31534
31534
|
if (!sessionId) return {};
|
|
31535
31535
|
const candidates = [];
|
|
31536
|
-
for (const value of [
|
|
31536
|
+
for (const value of [
|
|
31537
|
+
node.sessions,
|
|
31538
|
+
node.activeSessions,
|
|
31539
|
+
node.active_sessions,
|
|
31540
|
+
node.activeSessionDetails,
|
|
31541
|
+
node.active_session_details,
|
|
31542
|
+
node.sessionDetails,
|
|
31543
|
+
node.session_details,
|
|
31544
|
+
node.lastProbe?.sessions,
|
|
31545
|
+
node.last_probe?.sessions,
|
|
31546
|
+
node.lastProbe?.status?.sessions,
|
|
31547
|
+
node.last_probe?.status?.sessions
|
|
31548
|
+
]) {
|
|
31537
31549
|
if (Array.isArray(value)) candidates.push(...value);
|
|
31538
31550
|
}
|
|
31539
31551
|
for (const value of [node.activeSession, node.active_session, node.currentSession, node.current_session, node.runtimeSession, node.runtime_session, node.session]) {
|
|
@@ -33847,15 +33859,6 @@ ${lastSnapshot}`;
|
|
|
33847
33859
|
if (text) return text.slice(0, maxChars);
|
|
33848
33860
|
}
|
|
33849
33861
|
}
|
|
33850
|
-
for (let i = messages.length - 1; i >= 0; i--) {
|
|
33851
|
-
const msg = messages[i];
|
|
33852
|
-
if (!msg) continue;
|
|
33853
|
-
const classification = classifyChatMessageVisibility(msg);
|
|
33854
|
-
if (classification.isUserFacing) {
|
|
33855
|
-
const text = flattenContent(msg.content).trim();
|
|
33856
|
-
if (text) return text.slice(0, maxChars);
|
|
33857
|
-
}
|
|
33858
|
-
}
|
|
33859
33862
|
return "";
|
|
33860
33863
|
}
|
|
33861
33864
|
var BUILTIN_CHAT_MESSAGE_KINDS = ["standard", "thought", "tool", "terminal", "system"];
|
|
@@ -38026,6 +38029,13 @@ ${effect.notification.body || ""}`.trim();
|
|
|
38026
38029
|
function getTargetedCliAdapter(h, args, providerType) {
|
|
38027
38030
|
return h.getCliAdapter(args?.targetSessionId || providerType || h.currentSession?.providerType || h.currentManagerKey);
|
|
38028
38031
|
}
|
|
38032
|
+
function getExplicitHistorySessionId(args) {
|
|
38033
|
+
const explicit = typeof args?.historySessionId === "string" ? args.historySessionId.trim() : "";
|
|
38034
|
+
if (explicit) return explicit;
|
|
38035
|
+
const explicitProviderSessionId = typeof args?.providerSessionId === "string" ? args.providerSessionId.trim() : "";
|
|
38036
|
+
if (explicitProviderSessionId) return explicitProviderSessionId;
|
|
38037
|
+
return void 0;
|
|
38038
|
+
}
|
|
38029
38039
|
function getTargetInstance(h, args) {
|
|
38030
38040
|
const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
|
|
38031
38041
|
const sessionId = targetSessionId || h.currentSession?.sessionId || "";
|
|
@@ -38094,13 +38104,14 @@ ${effect.notification.body || ""}`.trim();
|
|
|
38094
38104
|
await sleep(HERMES_CLI_STARTING_SEND_SETTLE_MS);
|
|
38095
38105
|
}
|
|
38096
38106
|
function getHistorySessionId(h, args) {
|
|
38097
|
-
const explicit =
|
|
38107
|
+
const explicit = getExplicitHistorySessionId(args);
|
|
38098
38108
|
if (explicit) return explicit;
|
|
38099
|
-
const explicitProviderSessionId = typeof args?.providerSessionId === "string" ? args.providerSessionId.trim() : "";
|
|
38100
|
-
if (explicitProviderSessionId) return explicitProviderSessionId;
|
|
38101
38109
|
const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
|
|
38102
38110
|
if (!targetSessionId) return void 0;
|
|
38103
|
-
const
|
|
38111
|
+
const session = h.ctx.sessionRegistry?.get(targetSessionId);
|
|
38112
|
+
const registeredProviderSessionId = typeof session?.providerSessionId === "string" ? session.providerSessionId.trim() : "";
|
|
38113
|
+
if (registeredProviderSessionId) return registeredProviderSessionId;
|
|
38114
|
+
const instance = getTargetInstance(h, args);
|
|
38104
38115
|
const state = instance?.getState?.();
|
|
38105
38116
|
const providerSessionId = typeof state?.providerSessionId === "string" ? state.providerSessionId.trim() : "";
|
|
38106
38117
|
if (providerSessionId) return providerSessionId;
|
|
@@ -38111,6 +38122,15 @@ ${effect.notification.body || ""}`.trim();
|
|
|
38111
38122
|
}
|
|
38112
38123
|
return targetSessionId;
|
|
38113
38124
|
}
|
|
38125
|
+
function resolveCliNativeHistorySessionId(args, currentHistorySessionId, parsedProviderSessionId) {
|
|
38126
|
+
const explicit = getExplicitHistorySessionId(args);
|
|
38127
|
+
if (explicit) return explicit;
|
|
38128
|
+
const parsed = typeof parsedProviderSessionId === "string" ? parsedProviderSessionId.trim() : "";
|
|
38129
|
+
const current = typeof currentHistorySessionId === "string" ? currentHistorySessionId.trim() : "";
|
|
38130
|
+
const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
|
|
38131
|
+
if (parsed && (!current || current === targetSessionId)) return parsed;
|
|
38132
|
+
return current || parsed || void 0;
|
|
38133
|
+
}
|
|
38114
38134
|
function getInteractionId(args) {
|
|
38115
38135
|
return typeof args?._interactionId === "string" && args._interactionId.trim() ? args._interactionId.trim() : void 0;
|
|
38116
38136
|
}
|
|
@@ -38255,6 +38275,29 @@ ${effect.notification.body || ""}`.trim();
|
|
|
38255
38275
|
if (CLI_NATIVE_TRANSCRIPT_PROVIDERS.has(providerType)) return true;
|
|
38256
38276
|
return provider?.category === "cli" && isNativeSourceCanonicalHistory(provider?.canonicalHistory);
|
|
38257
38277
|
}
|
|
38278
|
+
function getComparableVisibleText(message) {
|
|
38279
|
+
if (!message) return "";
|
|
38280
|
+
const role = String(message.role || "").trim().toLowerCase();
|
|
38281
|
+
if (role !== "user" && role !== "assistant") return "";
|
|
38282
|
+
const kind = String(message.kind || "standard").trim().toLowerCase();
|
|
38283
|
+
if (kind && kind !== "standard") return "";
|
|
38284
|
+
const content = flattenContent(message.content).replace(/\s+/g, " ").trim();
|
|
38285
|
+
return content;
|
|
38286
|
+
}
|
|
38287
|
+
function hasOverlappingVisibleConversationText(nativeMessages, ptyMessages) {
|
|
38288
|
+
const nativeTexts = nativeMessages.map(getComparableVisibleText).filter(Boolean);
|
|
38289
|
+
const ptyTexts = ptyMessages.map(getComparableVisibleText).filter(Boolean);
|
|
38290
|
+
if (nativeTexts.length === 0 || ptyTexts.length === 0) return false;
|
|
38291
|
+
for (const nativeText of nativeTexts) {
|
|
38292
|
+
for (const ptyText of ptyTexts) {
|
|
38293
|
+
if (nativeText === ptyText) return true;
|
|
38294
|
+
const shorter = nativeText.length <= ptyText.length ? nativeText : ptyText;
|
|
38295
|
+
const longer = nativeText.length <= ptyText.length ? ptyText : nativeText;
|
|
38296
|
+
if (shorter.length >= 32 && longer.includes(shorter)) return true;
|
|
38297
|
+
}
|
|
38298
|
+
}
|
|
38299
|
+
return false;
|
|
38300
|
+
}
|
|
38258
38301
|
function hasSafeNativeHistoryMapping(args) {
|
|
38259
38302
|
const explicitSessionId = String(args.historySessionId || args.providerSessionId || "").trim();
|
|
38260
38303
|
if (explicitSessionId) {
|
|
@@ -38264,7 +38307,10 @@ ${effect.notification.body || ""}`.trim();
|
|
|
38264
38307
|
}
|
|
38265
38308
|
const workspace = String(args.workspace || "").trim();
|
|
38266
38309
|
if (!workspace) return false;
|
|
38267
|
-
|
|
38310
|
+
const workspaceMatches = args.nativeMessages.some((message) => String(message?.workspace || "").trim() === workspace);
|
|
38311
|
+
if (!workspaceMatches) return false;
|
|
38312
|
+
if (!args.requireWorkspaceContentOverlap) return true;
|
|
38313
|
+
return hasOverlappingVisibleConversationText(args.nativeMessages, args.ptyMessages || []);
|
|
38268
38314
|
}
|
|
38269
38315
|
function readCliProviderNativeHistory(agentStr, args) {
|
|
38270
38316
|
const sessionHistory = readProviderChatHistory(agentStr, {
|
|
@@ -38277,8 +38323,8 @@ ${effect.notification.body || ""}`.trim();
|
|
|
38277
38323
|
historyBehavior: args.historyBehavior,
|
|
38278
38324
|
scripts: args.scripts
|
|
38279
38325
|
});
|
|
38280
|
-
if (sessionHistory.source !== "native-unavailable" || !args.historySessionId || !args.workspace) {
|
|
38281
|
-
return { ...sessionHistory, lookup: "session" };
|
|
38326
|
+
if (sessionHistory.source !== "native-unavailable" || args.exactSessionScoped || !args.historySessionId || !args.workspace) {
|
|
38327
|
+
return { ...sessionHistory, lookup: args.historySessionId ? "session" : "workspace" };
|
|
38282
38328
|
}
|
|
38283
38329
|
const workspaceHistory = readProviderChatHistory(agentStr, {
|
|
38284
38330
|
canonicalHistory: args.canonicalHistory,
|
|
@@ -38303,6 +38349,19 @@ ${effect.notification.body || ""}`.trim();
|
|
|
38303
38349
|
function shouldPreserveReadChatPayloadField(key) {
|
|
38304
38350
|
return key === "messageSource" || key === "transcriptProvenance";
|
|
38305
38351
|
}
|
|
38352
|
+
function updateMessageSourceReturnedCount(value, returnedMessageCount) {
|
|
38353
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return value;
|
|
38354
|
+
const record2 = value;
|
|
38355
|
+
const coverage = record2.coverage && typeof record2.coverage === "object" && !Array.isArray(record2.coverage) ? record2.coverage : void 0;
|
|
38356
|
+
if (!coverage) return value;
|
|
38357
|
+
return {
|
|
38358
|
+
...record2,
|
|
38359
|
+
coverage: {
|
|
38360
|
+
...coverage,
|
|
38361
|
+
returnedMessageCount
|
|
38362
|
+
}
|
|
38363
|
+
};
|
|
38364
|
+
}
|
|
38306
38365
|
function deriveHistoryDedupKey(message) {
|
|
38307
38366
|
const unitKey = typeof message._unitKey === "string" ? message._unitKey.trim() : "";
|
|
38308
38367
|
if (unitKey) return `read_chat:${unitKey}`;
|
|
@@ -38414,6 +38473,13 @@ ${effect.notification.body || ""}`.trim();
|
|
|
38414
38473
|
const visibleMessages = filterUserFacingChatMessages(messages);
|
|
38415
38474
|
const sync = buildFullTail(visibleMessages, normalizeReadChatTailLimit(args));
|
|
38416
38475
|
const hiddenMsgCount = Math.max(0, messages.length - visibleMessages.length);
|
|
38476
|
+
const preservedPayloadFields = Object.fromEntries(Object.entries(payload).filter(([key]) => shouldPreserveReadChatPayloadField(key)));
|
|
38477
|
+
if (preservedPayloadFields.messageSource) {
|
|
38478
|
+
preservedPayloadFields.messageSource = updateMessageSourceReturnedCount(preservedPayloadFields.messageSource, sync.messages.length);
|
|
38479
|
+
}
|
|
38480
|
+
if (preservedPayloadFields.transcriptProvenance) {
|
|
38481
|
+
preservedPayloadFields.transcriptProvenance = updateMessageSourceReturnedCount(preservedPayloadFields.transcriptProvenance, sync.messages.length);
|
|
38482
|
+
}
|
|
38417
38483
|
const returnedDebugReadChat = debugReadChat ? {
|
|
38418
38484
|
...debugReadChat,
|
|
38419
38485
|
fullMsgCount: typeof debugReadChat.fullMsgCount === "number" ? debugReadChat.fullMsgCount : messages.length,
|
|
@@ -38424,7 +38490,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
38424
38490
|
return {
|
|
38425
38491
|
success: true,
|
|
38426
38492
|
...validatedPayload,
|
|
38427
|
-
...
|
|
38493
|
+
...preservedPayloadFields,
|
|
38428
38494
|
messages: sync.messages,
|
|
38429
38495
|
totalMessages: sync.totalMessages,
|
|
38430
38496
|
...returnedDebugReadChat ? { debugReadChat: returnedDebugReadChat } : {}
|
|
@@ -38899,17 +38965,23 @@ ${effect.notification.body || ""}`.trim();
|
|
|
38899
38965
|
returnedMessages.length,
|
|
38900
38966
|
200
|
|
38901
38967
|
);
|
|
38968
|
+
const nativeHistorySessionId = resolveCliNativeHistorySessionId(args, historySessionId, providerSessionId);
|
|
38969
|
+
const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
|
|
38970
|
+
const exactNativeHistoryScope = Boolean(
|
|
38971
|
+
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()
|
|
38972
|
+
);
|
|
38902
38973
|
let nativeHistory = null;
|
|
38903
38974
|
try {
|
|
38904
38975
|
nativeHistory = readCliProviderNativeHistory(agentStr, {
|
|
38905
38976
|
canonicalHistory: provider?.canonicalHistory,
|
|
38906
|
-
historySessionId,
|
|
38977
|
+
historySessionId: nativeHistorySessionId,
|
|
38907
38978
|
workspace,
|
|
38908
38979
|
offset: 0,
|
|
38909
38980
|
limit: nativeHistoryLimit,
|
|
38910
38981
|
excludeRecentCount: 0,
|
|
38911
38982
|
historyBehavior: provider?.historyBehavior,
|
|
38912
|
-
scripts: provider?.scripts
|
|
38983
|
+
scripts: provider?.scripts,
|
|
38984
|
+
exactSessionScoped: exactNativeHistoryScope
|
|
38913
38985
|
});
|
|
38914
38986
|
} catch (error48) {
|
|
38915
38987
|
const fallbackReason = `native_history_error:${error48?.message || String(error48)}`;
|
|
@@ -38925,13 +38997,15 @@ ${effect.notification.body || ""}`.trim();
|
|
|
38925
38997
|
}
|
|
38926
38998
|
if (nativeHistory) {
|
|
38927
38999
|
const nativeMessages = Array.isArray(nativeHistory.messages) ? normalizeNativeHistoryMessages(agentStr, nativeHistory.messages) : [];
|
|
38928
|
-
const historyProviderSessionId = typeof nativeHistory?.providerSessionId === "string" ? nativeHistory.providerSessionId : readHistorySessionIdFromMessages(nativeMessages) || historySessionId;
|
|
39000
|
+
const historyProviderSessionId = typeof nativeHistory?.providerSessionId === "string" ? nativeHistory.providerSessionId : readHistorySessionIdFromMessages(nativeMessages) || nativeHistorySessionId || historySessionId;
|
|
38929
39001
|
const lookup = nativeHistory.lookup === "workspace" ? "workspace" : "session";
|
|
38930
39002
|
const safeMapping = hasSafeNativeHistoryMapping({
|
|
38931
|
-
historySessionId: lookup === "workspace" ? void 0 :
|
|
38932
|
-
providerSessionId: lookup === "workspace" ? void 0 : providerSessionId,
|
|
39003
|
+
historySessionId: lookup === "workspace" ? void 0 : nativeHistorySessionId,
|
|
39004
|
+
providerSessionId: lookup === "workspace" ? void 0 : historyProviderSessionId || providerSessionId,
|
|
38933
39005
|
workspace,
|
|
38934
|
-
nativeMessages
|
|
39006
|
+
nativeMessages,
|
|
39007
|
+
ptyMessages: returnedMessages,
|
|
39008
|
+
requireWorkspaceContentOverlap: lookup === "workspace" && !exactNativeHistoryScope
|
|
38935
39009
|
});
|
|
38936
39010
|
const freshEnough = isNativeHistoryFreshEnough({
|
|
38937
39011
|
sourceMtimeMs: nativeHistory.sourceMtimeMs,
|
|
@@ -38946,7 +39020,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
38946
39020
|
messageSource = buildCliMessageSourceProvenance({
|
|
38947
39021
|
selected: "native-history",
|
|
38948
39022
|
provider: adapter.cliType,
|
|
38949
|
-
nativeHandle: selectedProviderSessionId || historySessionId,
|
|
39023
|
+
nativeHandle: selectedProviderSessionId || nativeHistorySessionId || historySessionId,
|
|
38950
39024
|
nativeSource: nativeHistory.source,
|
|
38951
39025
|
sourcePath: nativeHistory.sourcePath,
|
|
38952
39026
|
sourceMtimeMs: nativeHistory.sourceMtimeMs,
|
|
@@ -38969,7 +39043,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
38969
39043
|
messageSource = buildCliMessageSourceProvenance({
|
|
38970
39044
|
selected: "pty-parser",
|
|
38971
39045
|
provider: adapter.cliType,
|
|
38972
|
-
nativeHandle: historyProviderSessionId || historySessionId,
|
|
39046
|
+
nativeHandle: historyProviderSessionId || nativeHistorySessionId || historySessionId,
|
|
38973
39047
|
fallbackReason,
|
|
38974
39048
|
nativeSource: nativeHistory.source,
|
|
38975
39049
|
sourcePath: nativeHistory.sourcePath,
|
|
@@ -39013,6 +39087,9 @@ ${effect.notification.body || ""}`.trim();
|
|
|
39013
39087
|
try {
|
|
39014
39088
|
const agentStr = provider?.type || args?.agentType || getCurrentProviderType(h);
|
|
39015
39089
|
const workspace = typeof args?.workspace === "string" ? args.workspace : typeof h.currentSession?.workspace === "string" ? h.currentSession.workspace : void 0;
|
|
39090
|
+
const exactNativeHistoryScope = Boolean(
|
|
39091
|
+
typeof args?.historySessionId === "string" && args.historySessionId.trim() || typeof args?.providerSessionId === "string" && args.providerSessionId.trim() || h.currentSession?.sessionId === args?.targetSessionId && typeof h.currentSession?.providerSessionId === "string" && h.currentSession.providerSessionId.trim()
|
|
39092
|
+
);
|
|
39016
39093
|
const history = supportsCliNativeTranscript(agentStr, provider) && isNativeSourceCanonicalHistory(provider?.canonicalHistory) ? readCliProviderNativeHistory(agentStr, {
|
|
39017
39094
|
canonicalHistory: provider?.canonicalHistory,
|
|
39018
39095
|
historySessionId,
|
|
@@ -39021,7 +39098,8 @@ ${effect.notification.body || ""}`.trim();
|
|
|
39021
39098
|
limit: historyLimit,
|
|
39022
39099
|
excludeRecentCount: 0,
|
|
39023
39100
|
historyBehavior: provider?.historyBehavior,
|
|
39024
|
-
scripts: provider?.scripts
|
|
39101
|
+
scripts: provider?.scripts,
|
|
39102
|
+
exactSessionScoped: exactNativeHistoryScope
|
|
39025
39103
|
}) : readProviderChatHistory(agentStr, {
|
|
39026
39104
|
canonicalHistory: provider?.canonicalHistory,
|
|
39027
39105
|
historySessionId,
|
|
@@ -41762,6 +41840,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
41762
41840
|
}
|
|
41763
41841
|
const runtime = this.adapter.getRuntimeMetadata();
|
|
41764
41842
|
this.maybeAppendRuntimeRecoveryMessage(runtime);
|
|
41843
|
+
const activeChatId = this.providerSessionId || runtime?.runtimeId || this.instanceId;
|
|
41765
41844
|
let parsedMessages = Array.isArray(parsedStatus?.messages) ? parsedStatus.messages : [];
|
|
41766
41845
|
const historyMessageCount = Number.isFinite(parsedStatus?.historyMessageCount) ? Math.max(0, Number(parsedStatus.historyMessageCount)) : null;
|
|
41767
41846
|
if (historyMessageCount !== null) {
|
|
@@ -41817,7 +41896,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
41817
41896
|
status: visibleStatus,
|
|
41818
41897
|
mode: this.presentationMode,
|
|
41819
41898
|
activeChat: {
|
|
41820
|
-
id:
|
|
41899
|
+
id: activeChatId,
|
|
41821
41900
|
title: parsedStatus?.title || dirName,
|
|
41822
41901
|
status: activeChatStatus,
|
|
41823
41902
|
messages: mergedMessages,
|