@adhdev/daemon-core 0.9.76-rc.34 → 0.9.76-rc.36
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.
|
@@ -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
|
@@ -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
|
+
}
|