@adhdev/daemon-standalone 0.9.82-rc.87 → 0.9.82-rc.88
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 +95 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -38134,6 +38134,54 @@ ${effect.notification.body || ""}`.trim();
|
|
|
38134
38134
|
}
|
|
38135
38135
|
return newest;
|
|
38136
38136
|
}
|
|
38137
|
+
function readHistorySessionIdFromMessages(messages) {
|
|
38138
|
+
for (const message of messages) {
|
|
38139
|
+
const historySessionId = typeof message?.historySessionId === "string" ? message.historySessionId.trim() : "";
|
|
38140
|
+
if (historySessionId) return historySessionId;
|
|
38141
|
+
}
|
|
38142
|
+
return void 0;
|
|
38143
|
+
}
|
|
38144
|
+
function normalizeNativeHistoryMessages(providerType, messages) {
|
|
38145
|
+
let turnIndex = 0;
|
|
38146
|
+
return normalizeChatMessages(messages).map((message, index) => {
|
|
38147
|
+
const role = typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
|
|
38148
|
+
const kind = typeof message.kind === "string" && message.kind.trim() ? message.kind.trim() : role === "system" ? "system" : "standard";
|
|
38149
|
+
if ((role === "user" || role === "human") && index > 0) turnIndex += 1;
|
|
38150
|
+
const historySessionId = typeof message.historySessionId === "string" ? message.historySessionId.trim() : "";
|
|
38151
|
+
const contentHash = hashSignatureParts([
|
|
38152
|
+
providerType,
|
|
38153
|
+
historySessionId,
|
|
38154
|
+
String(message.receivedAt || message.timestamp || index),
|
|
38155
|
+
role,
|
|
38156
|
+
kind,
|
|
38157
|
+
flattenContent(message.content)
|
|
38158
|
+
]).slice(0, 12);
|
|
38159
|
+
const providerUnitKey = typeof message.providerUnitKey === "string" && message.providerUnitKey.trim() ? message.providerUnitKey.trim() : `${providerType}:native:${historySessionId || "workspace"}:${index}:${role || "message"}:${kind}:${contentHash}`;
|
|
38160
|
+
const meta3 = message.meta && typeof message.meta === "object" ? message.meta : void 0;
|
|
38161
|
+
const isSystemSessionStart = role === "system" || kind === "system" || kind === "session_start";
|
|
38162
|
+
const isActivity = role === "assistant" && (kind === "tool" || kind === "terminal" || kind === "thought");
|
|
38163
|
+
return {
|
|
38164
|
+
...message,
|
|
38165
|
+
role: role === "human" ? "user" : role || "assistant",
|
|
38166
|
+
kind: isSystemSessionStart ? "system" : kind,
|
|
38167
|
+
providerUnitKey,
|
|
38168
|
+
bubbleId: typeof message.bubbleId === "string" && message.bubbleId.trim() ? message.bubbleId.trim() : `bubble:${providerUnitKey}`,
|
|
38169
|
+
_turnKey: typeof message._turnKey === "string" && message._turnKey.trim() ? message._turnKey.trim() : `${providerType}:native-turn:${historySessionId || "workspace"}:${turnIndex}`,
|
|
38170
|
+
bubbleState: message.bubbleState || "final",
|
|
38171
|
+
...isSystemSessionStart ? {
|
|
38172
|
+
visibility: message.visibility || "hidden",
|
|
38173
|
+
transcriptVisibility: message.transcriptVisibility || "hidden",
|
|
38174
|
+
audience: message.audience || "internal",
|
|
38175
|
+
source: message.source || "runtime_status"
|
|
38176
|
+
} : isActivity ? {
|
|
38177
|
+
source: message.source || (kind === "terminal" ? "terminal_command" : "tool_call"),
|
|
38178
|
+
meta: { ...meta3, label: message.senderName || meta3?.label || (kind === "terminal" ? "Terminal" : "Tool") }
|
|
38179
|
+
} : {
|
|
38180
|
+
source: message.source || (role === "assistant" ? "assistant_text" : void 0)
|
|
38181
|
+
}
|
|
38182
|
+
};
|
|
38183
|
+
});
|
|
38184
|
+
}
|
|
38137
38185
|
function buildCliMessageSourceProvenance(args) {
|
|
38138
38186
|
const sourceMtimeMs = Number(args.sourceMtimeMs || 0);
|
|
38139
38187
|
const sourceMtimeAgeMs = sourceMtimeMs > 0 ? Math.max(0, Date.now() - sourceMtimeMs) : void 0;
|
|
@@ -38189,6 +38237,32 @@ ${effect.notification.body || ""}`.trim();
|
|
|
38189
38237
|
if (!workspace) return false;
|
|
38190
38238
|
return args.nativeMessages.some((message) => String(message?.workspace || "").trim() === workspace);
|
|
38191
38239
|
}
|
|
38240
|
+
function readCliProviderNativeHistory(agentStr, args) {
|
|
38241
|
+
const sessionHistory = readProviderChatHistory(agentStr, {
|
|
38242
|
+
canonicalHistory: args.canonicalHistory,
|
|
38243
|
+
historySessionId: args.historySessionId,
|
|
38244
|
+
workspace: args.workspace,
|
|
38245
|
+
offset: args.offset,
|
|
38246
|
+
limit: args.limit,
|
|
38247
|
+
excludeRecentCount: args.excludeRecentCount,
|
|
38248
|
+
historyBehavior: args.historyBehavior,
|
|
38249
|
+
scripts: args.scripts
|
|
38250
|
+
});
|
|
38251
|
+
if (sessionHistory.source !== "native-unavailable" || !args.historySessionId || !args.workspace) {
|
|
38252
|
+
return { ...sessionHistory, lookup: "session" };
|
|
38253
|
+
}
|
|
38254
|
+
const workspaceHistory = readProviderChatHistory(agentStr, {
|
|
38255
|
+
canonicalHistory: args.canonicalHistory,
|
|
38256
|
+
historySessionId: void 0,
|
|
38257
|
+
workspace: args.workspace,
|
|
38258
|
+
offset: args.offset,
|
|
38259
|
+
limit: args.limit,
|
|
38260
|
+
excludeRecentCount: args.excludeRecentCount,
|
|
38261
|
+
historyBehavior: args.historyBehavior,
|
|
38262
|
+
scripts: args.scripts
|
|
38263
|
+
});
|
|
38264
|
+
return { ...workspaceHistory, lookup: "workspace" };
|
|
38265
|
+
}
|
|
38192
38266
|
function isNativeHistoryFreshEnough(args) {
|
|
38193
38267
|
const nativeNewest = getMessageNewestReceivedAt(args.nativeMessages);
|
|
38194
38268
|
const ptyNewest = getMessageNewestReceivedAt(args.ptyMessages);
|
|
@@ -38798,7 +38872,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
38798
38872
|
);
|
|
38799
38873
|
let nativeHistory = null;
|
|
38800
38874
|
try {
|
|
38801
|
-
nativeHistory =
|
|
38875
|
+
nativeHistory = readCliProviderNativeHistory(agentStr, {
|
|
38802
38876
|
canonicalHistory: provider?.canonicalHistory,
|
|
38803
38877
|
historySessionId,
|
|
38804
38878
|
workspace,
|
|
@@ -38821,11 +38895,12 @@ ${effect.notification.body || ""}`.trim();
|
|
|
38821
38895
|
nativeHistory = null;
|
|
38822
38896
|
}
|
|
38823
38897
|
if (nativeHistory) {
|
|
38824
|
-
const nativeMessages = Array.isArray(nativeHistory.messages) ?
|
|
38825
|
-
const historyProviderSessionId = typeof nativeHistory?.providerSessionId === "string" ? nativeHistory.providerSessionId : historySessionId;
|
|
38898
|
+
const nativeMessages = Array.isArray(nativeHistory.messages) ? normalizeNativeHistoryMessages(agentStr, nativeHistory.messages) : [];
|
|
38899
|
+
const historyProviderSessionId = typeof nativeHistory?.providerSessionId === "string" ? nativeHistory.providerSessionId : readHistorySessionIdFromMessages(nativeMessages) || historySessionId;
|
|
38900
|
+
const lookup = nativeHistory.lookup === "workspace" ? "workspace" : "session";
|
|
38826
38901
|
const safeMapping = hasSafeNativeHistoryMapping({
|
|
38827
|
-
historySessionId,
|
|
38828
|
-
providerSessionId,
|
|
38902
|
+
historySessionId: lookup === "workspace" ? void 0 : historySessionId,
|
|
38903
|
+
providerSessionId: lookup === "workspace" ? void 0 : providerSessionId,
|
|
38829
38904
|
workspace,
|
|
38830
38905
|
nativeMessages
|
|
38831
38906
|
});
|
|
@@ -38909,7 +38984,16 @@ ${effect.notification.body || ""}`.trim();
|
|
|
38909
38984
|
try {
|
|
38910
38985
|
const agentStr = provider?.type || args?.agentType || getCurrentProviderType(h);
|
|
38911
38986
|
const workspace = typeof args?.workspace === "string" ? args.workspace : typeof h.currentSession?.workspace === "string" ? h.currentSession.workspace : void 0;
|
|
38912
|
-
const history =
|
|
38987
|
+
const history = supportsCliNativeTranscript(agentStr, provider) && isNativeSourceCanonicalHistory(provider?.canonicalHistory) ? readCliProviderNativeHistory(agentStr, {
|
|
38988
|
+
canonicalHistory: provider?.canonicalHistory,
|
|
38989
|
+
historySessionId,
|
|
38990
|
+
workspace,
|
|
38991
|
+
offset: 0,
|
|
38992
|
+
limit: historyLimit,
|
|
38993
|
+
excludeRecentCount: 0,
|
|
38994
|
+
historyBehavior: provider?.historyBehavior,
|
|
38995
|
+
scripts: provider?.scripts
|
|
38996
|
+
}) : readProviderChatHistory(agentStr, {
|
|
38913
38997
|
canonicalHistory: provider?.canonicalHistory,
|
|
38914
38998
|
historySessionId,
|
|
38915
38999
|
workspace,
|
|
@@ -38919,11 +39003,12 @@ ${effect.notification.body || ""}`.trim();
|
|
|
38919
39003
|
historyBehavior: provider?.historyBehavior,
|
|
38920
39004
|
scripts: provider?.scripts
|
|
38921
39005
|
});
|
|
38922
|
-
const
|
|
38923
|
-
const historyMessages = Array.isArray(history?.messages) ?
|
|
39006
|
+
const lookup = history.lookup === "workspace" ? "workspace" : "session";
|
|
39007
|
+
const historyMessages = Array.isArray(history?.messages) ? normalizeNativeHistoryMessages(agentStr, history.messages) : [];
|
|
39008
|
+
const historyProviderSessionId = typeof history?.providerSessionId === "string" ? history.providerSessionId : readHistorySessionIdFromMessages(historyMessages) || historySessionId;
|
|
38924
39009
|
const safeMapping = supportsCliNativeTranscript(agentStr, provider) ? hasSafeNativeHistoryMapping({
|
|
38925
|
-
historySessionId,
|
|
38926
|
-
providerSessionId: historyProviderSessionId,
|
|
39010
|
+
historySessionId: lookup === "workspace" ? void 0 : historySessionId,
|
|
39011
|
+
providerSessionId: lookup === "workspace" ? void 0 : historyProviderSessionId,
|
|
38927
39012
|
workspace,
|
|
38928
39013
|
nativeMessages: historyMessages
|
|
38929
39014
|
}) : false;
|