@adhdev/daemon-core 0.9.82-rc.113 → 0.9.82-rc.114
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 +20 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/commands/chat-commands.ts +28 -10
package/package.json
CHANGED
|
@@ -279,7 +279,18 @@ function readHistorySessionIdFromMessages(messages: ChatMessage[]): string | und
|
|
|
279
279
|
return undefined;
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
-
function
|
|
282
|
+
function shouldPreserveNativeIdentity(providerType: string, sessionId: string, message: ChatMessage): boolean {
|
|
283
|
+
const providerUnitKey = typeof message.providerUnitKey === 'string' ? message.providerUnitKey.trim() : '';
|
|
284
|
+
const turnKey = typeof message._turnKey === 'string' ? message._turnKey.trim() : '';
|
|
285
|
+
if (!providerUnitKey || !turnKey) return false;
|
|
286
|
+
if (providerType === 'hermes-cli' && sessionId) {
|
|
287
|
+
return providerUnitKey.startsWith(`${providerType}:native:${sessionId}:`)
|
|
288
|
+
&& turnKey.startsWith(`${providerType}:native-turn:${sessionId}:`);
|
|
289
|
+
}
|
|
290
|
+
return true;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function normalizeNativeHistoryMessages(providerType: string, messages: ChatMessage[], nativeSessionId?: string): ChatMessage[] {
|
|
283
294
|
let turnIndex = 0;
|
|
284
295
|
return normalizeChatMessages(messages).map((message, index) => {
|
|
285
296
|
const role = typeof message.role === 'string' ? message.role.trim().toLowerCase() : '';
|
|
@@ -296,9 +307,13 @@ function normalizeNativeHistoryMessages(providerType: string, messages: ChatMess
|
|
|
296
307
|
kind,
|
|
297
308
|
flattenContent(message.content),
|
|
298
309
|
]).slice(0, 12);
|
|
299
|
-
const
|
|
300
|
-
|
|
301
|
-
|
|
310
|
+
const nativeIdentitySessionId = historySessionId || (typeof nativeSessionId === 'string' ? nativeSessionId.trim() : '');
|
|
311
|
+
const preserveNativeIdentity = shouldPreserveNativeIdentity(providerType, nativeIdentitySessionId, message);
|
|
312
|
+
const existingProviderUnitKey = typeof message.providerUnitKey === 'string' ? message.providerUnitKey.trim() : '';
|
|
313
|
+
const existingTurnKey = typeof message._turnKey === 'string' ? message._turnKey.trim() : '';
|
|
314
|
+
const providerUnitKey = preserveNativeIdentity
|
|
315
|
+
? existingProviderUnitKey
|
|
316
|
+
: `${providerType}:native:${nativeIdentitySessionId || 'workspace'}:${index}:${role || 'message'}:${kind}:${contentHash}`;
|
|
302
317
|
const meta = message.meta && typeof message.meta === 'object' ? message.meta as Record<string, unknown> : undefined;
|
|
303
318
|
const isSystemSessionStart = role === 'system' || kind === 'system' || kind === 'session_start';
|
|
304
319
|
const isActivity = role === 'assistant' && (kind === 'tool' || kind === 'terminal' || kind === 'thought');
|
|
@@ -308,11 +323,12 @@ function normalizeNativeHistoryMessages(providerType: string, messages: ChatMess
|
|
|
308
323
|
kind: isSystemSessionStart ? 'system' : kind,
|
|
309
324
|
providerUnitKey,
|
|
310
325
|
bubbleId: typeof message.bubbleId === 'string' && message.bubbleId.trim()
|
|
326
|
+
&& preserveNativeIdentity
|
|
311
327
|
? message.bubbleId.trim()
|
|
312
328
|
: `bubble:${providerUnitKey}`,
|
|
313
|
-
_turnKey:
|
|
314
|
-
?
|
|
315
|
-
: `${providerType}:native-turn:${
|
|
329
|
+
_turnKey: preserveNativeIdentity
|
|
330
|
+
? existingTurnKey
|
|
331
|
+
: `${providerType}:native-turn:${nativeIdentitySessionId || 'workspace'}:${turnIndex}`,
|
|
316
332
|
bubbleState: message.bubbleState || 'final',
|
|
317
333
|
...(isSystemSessionStart ? {
|
|
318
334
|
visibility: message.visibility || 'hidden',
|
|
@@ -1194,7 +1210,9 @@ export async function handleChatHistory(h: CommandHelpers, args: any): Promise<C
|
|
|
1194
1210
|
});
|
|
1195
1211
|
if (supportsCliNativeTranscript(agentStr, provider) && isNativeSourceCanonicalHistory(provider?.canonicalHistory)) {
|
|
1196
1212
|
const lookup = (result as any).lookup === 'workspace' ? 'workspace' : 'session';
|
|
1197
|
-
const messages = Array.isArray((result as any).messages)
|
|
1213
|
+
const messages = Array.isArray((result as any).messages)
|
|
1214
|
+
? normalizeNativeHistoryMessages(agentStr, (result as any).messages as ChatMessage[], (result as any)?.providerSessionId)
|
|
1215
|
+
: [];
|
|
1198
1216
|
const historyProviderSessionId = typeof (result as any)?.providerSessionId === 'string'
|
|
1199
1217
|
? (result as any).providerSessionId
|
|
1200
1218
|
: readHistorySessionIdFromMessages(messages) || historySessionId;
|
|
@@ -1335,7 +1353,7 @@ export async function handleReadChat(h: CommandHelpers, args: any): Promise<Comm
|
|
|
1335
1353
|
|
|
1336
1354
|
if (nativeHistory) {
|
|
1337
1355
|
const nativeMessages = Array.isArray((nativeHistory as any).messages)
|
|
1338
|
-
? normalizeNativeHistoryMessages(agentStr, (nativeHistory as any).messages as ChatMessage[])
|
|
1356
|
+
? normalizeNativeHistoryMessages(agentStr, (nativeHistory as any).messages as ChatMessage[], (nativeHistory as any)?.providerSessionId)
|
|
1339
1357
|
: [];
|
|
1340
1358
|
const historyProviderSessionId = typeof (nativeHistory as any)?.providerSessionId === 'string'
|
|
1341
1359
|
? (nativeHistory as any).providerSessionId
|
|
@@ -1497,7 +1515,7 @@ export async function handleReadChat(h: CommandHelpers, args: any): Promise<Comm
|
|
|
1497
1515
|
});
|
|
1498
1516
|
const lookup = (history as any).lookup === 'workspace' ? 'workspace' : 'session';
|
|
1499
1517
|
const historyMessages = Array.isArray((history as any)?.messages)
|
|
1500
|
-
? normalizeNativeHistoryMessages(agentStr, (history as any).messages as ChatMessage[])
|
|
1518
|
+
? normalizeNativeHistoryMessages(agentStr, (history as any).messages as ChatMessage[], (history as any)?.providerSessionId)
|
|
1501
1519
|
: [];
|
|
1502
1520
|
const historyProviderSessionId = typeof (history as any)?.providerSessionId === 'string'
|
|
1503
1521
|
? (history as any).providerSessionId
|