@adhdev/daemon-core 0.9.76-rc.33 → 0.9.76-rc.35
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 +22 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -0
- package/dist/index.mjs.map +1 -1
- package/dist/providers/chat-message-normalization.d.ts +11 -0
- package/package.json +1 -1
- package/src/commands/chat-commands.ts +26 -0
- package/src/providers/chat-message-normalization.ts +54 -0
|
@@ -63,3 +63,14 @@ export declare function buildUserChatMessage<T extends Omit<ChatMessage, 'role'
|
|
|
63
63
|
});
|
|
64
64
|
export declare function normalizeChatMessage<T extends ChatMessage>(message: T): T;
|
|
65
65
|
export declare function normalizeChatMessages<T extends ChatMessage>(messages: T[] | null | undefined): T[];
|
|
66
|
+
/**
|
|
67
|
+
* Product chat transcript visibility contract.
|
|
68
|
+
*
|
|
69
|
+
* read_chat/debug paths may preserve every normalized message, including tool,
|
|
70
|
+
* terminal, thought, status, and control rows. The default user-facing chat UX
|
|
71
|
+
* should only render meaningful conversation turns unless a producer explicitly
|
|
72
|
+
* marks a non-standard row as user-facing. This keeps internal tool/status/control
|
|
73
|
+
* plumbing out of the ordinary transcript without matching provider-specific text.
|
|
74
|
+
*/
|
|
75
|
+
export declare function isUserFacingChatMessage(message: ChatMessage | null | undefined): boolean;
|
|
76
|
+
export declare function filterUserFacingChatMessages<T extends ChatMessage>(messages: T[] | null | undefined): T[];
|
package/package.json
CHANGED
|
@@ -502,6 +502,18 @@ function buildChatDebugBundleSummary(bundle: Record<string, unknown>): Record<st
|
|
|
502
502
|
const readChat = bundle.readChat && typeof bundle.readChat === 'object' ? bundle.readChat as Record<string, unknown> : {};
|
|
503
503
|
const cli = bundle.cli && typeof bundle.cli === 'object' ? bundle.cli as Record<string, unknown> : null;
|
|
504
504
|
const frontend = bundle.frontend && typeof bundle.frontend === 'object' ? bundle.frontend as Record<string, unknown> : null;
|
|
505
|
+
const debugReadChat = readChat.debugReadChat && typeof readChat.debugReadChat === 'object'
|
|
506
|
+
? readChat.debugReadChat as Record<string, unknown>
|
|
507
|
+
: {};
|
|
508
|
+
const parsedStatus = cli?.parsedStatus && typeof cli.parsedStatus === 'object'
|
|
509
|
+
? cli.parsedStatus as Record<string, unknown>
|
|
510
|
+
: null;
|
|
511
|
+
const cliParsedMessageCount = Array.isArray(parsedStatus?.messages) ? parsedStatus.messages.length : undefined;
|
|
512
|
+
const readChatReturnedMessages = Array.isArray(readChat.messagesTail) ? readChat.messagesTail.length : undefined;
|
|
513
|
+
const cliPartialResponse = typeof cli?.partialResponse === 'string' ? cli.partialResponse : '';
|
|
514
|
+
const readChatStatus = typeof readChat.status === 'string' ? readChat.status : '';
|
|
515
|
+
const cliStatus = typeof cli?.status === 'string' ? cli.status : '';
|
|
516
|
+
const cliParsedStatus = typeof parsedStatus?.status === 'string' ? parsedStatus.status : '';
|
|
505
517
|
return {
|
|
506
518
|
createdAt: bundle.createdAt,
|
|
507
519
|
targetSessionId: target.targetSessionId,
|
|
@@ -510,8 +522,22 @@ function buildChatDebugBundleSummary(bundle: Record<string, unknown>): Record<st
|
|
|
510
522
|
readChatSuccess: readChat.success,
|
|
511
523
|
readChatStatus: readChat.status,
|
|
512
524
|
readChatTotalMessages: readChat.totalMessages,
|
|
525
|
+
readChatReturnedMessages,
|
|
513
526
|
cliStatus: cli?.status,
|
|
527
|
+
cliParsedStatus: cliParsedStatus || undefined,
|
|
514
528
|
cliMessageCount: cli?.messageCount,
|
|
529
|
+
cliParsedMessageCount,
|
|
530
|
+
cliPartialResponseChars: cliPartialResponse.length,
|
|
531
|
+
parserAdapterStatusMismatch: Boolean(cliStatus && cliParsedStatus && cliStatus !== cliParsedStatus),
|
|
532
|
+
parserReadChatStatusMismatch: Boolean(readChatStatus && cliParsedStatus && readChatStatus !== cliParsedStatus),
|
|
533
|
+
readChatDebug: Object.keys(debugReadChat).length ? {
|
|
534
|
+
adapterStatus: debugReadChat.adapterStatus,
|
|
535
|
+
parsedStatus: debugReadChat.parsedStatus,
|
|
536
|
+
returnedStatus: debugReadChat.returnedStatus,
|
|
537
|
+
parsedMsgCount: debugReadChat.parsedMsgCount,
|
|
538
|
+
returnedMsgCount: debugReadChat.returnedMsgCount,
|
|
539
|
+
shouldPreferAdapterMessages: debugReadChat.shouldPreferAdapterMessages,
|
|
540
|
+
} : undefined,
|
|
515
541
|
hasFrontendSnapshot: !!frontend,
|
|
516
542
|
};
|
|
517
543
|
}
|
|
@@ -171,3 +171,57 @@ export function normalizeChatMessage<T extends ChatMessage>(message: T): T {
|
|
|
171
171
|
export function normalizeChatMessages<T extends ChatMessage>(messages: T[] | null | undefined): T[] {
|
|
172
172
|
return (Array.isArray(messages) ? messages : []).map((message) => normalizeChatMessage(message));
|
|
173
173
|
}
|
|
174
|
+
|
|
175
|
+
function readMessageMeta(message: ChatMessage): Record<string, unknown> | null {
|
|
176
|
+
const meta = message?.meta;
|
|
177
|
+
return meta && typeof meta === 'object' && !Array.isArray(meta)
|
|
178
|
+
? meta as Record<string, unknown>
|
|
179
|
+
: null;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function isExplicitlyHiddenFromTranscript(meta: Record<string, unknown> | null): boolean {
|
|
183
|
+
if (!meta) return false;
|
|
184
|
+
const visibility = typeof meta.transcriptVisibility === 'string'
|
|
185
|
+
? meta.transcriptVisibility.trim().toLowerCase()
|
|
186
|
+
: '';
|
|
187
|
+
return visibility === 'hidden'
|
|
188
|
+
|| visibility === 'debug'
|
|
189
|
+
|| meta.internal === true
|
|
190
|
+
|| meta.debug === true
|
|
191
|
+
|| meta.statusOnly === true
|
|
192
|
+
|| meta.controlOnly === true;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function isExplicitlyVisibleInTranscript(meta: Record<string, unknown> | null): boolean {
|
|
196
|
+
if (!meta) return false;
|
|
197
|
+
const visibility = typeof meta.transcriptVisibility === 'string'
|
|
198
|
+
? meta.transcriptVisibility.trim().toLowerCase()
|
|
199
|
+
: '';
|
|
200
|
+
return visibility === 'visible' || meta.userFacing === true;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Product chat transcript visibility contract.
|
|
205
|
+
*
|
|
206
|
+
* read_chat/debug paths may preserve every normalized message, including tool,
|
|
207
|
+
* terminal, thought, status, and control rows. The default user-facing chat UX
|
|
208
|
+
* should only render meaningful conversation turns unless a producer explicitly
|
|
209
|
+
* marks a non-standard row as user-facing. This keeps internal tool/status/control
|
|
210
|
+
* plumbing out of the ordinary transcript without matching provider-specific text.
|
|
211
|
+
*/
|
|
212
|
+
export function isUserFacingChatMessage(message: ChatMessage | null | undefined): boolean {
|
|
213
|
+
if (!message) return false;
|
|
214
|
+
const meta = readMessageMeta(message);
|
|
215
|
+
if (isExplicitlyHiddenFromTranscript(meta)) return false;
|
|
216
|
+
if (isExplicitlyVisibleInTranscript(meta)) return true;
|
|
217
|
+
|
|
218
|
+
const role = typeof message.role === 'string' ? message.role.trim().toLowerCase() : '';
|
|
219
|
+
const kind = resolveChatMessageKind(message);
|
|
220
|
+
if (role === 'user' || role === 'human') return kind === 'standard' || kind === '';
|
|
221
|
+
if (role === 'assistant') return kind === 'standard' || kind === '';
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export function filterUserFacingChatMessages<T extends ChatMessage>(messages: T[] | null | undefined): T[] {
|
|
226
|
+
return (Array.isArray(messages) ? messages : []).filter((message) => isUserFacingChatMessage(message));
|
|
227
|
+
}
|