@adhdev/daemon-core 0.9.76-rc.55 → 0.9.76-rc.56
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 +25 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/commands/chat-commands.ts +12 -8
- package/src/providers/chat-message-normalization.ts +38 -19
- package/src/providers/cli-provider-instance.ts +6 -9
package/package.json
CHANGED
|
@@ -320,19 +320,23 @@ function buildReadChatCommandResult(payload: Record<string, any>, args: any): Co
|
|
|
320
320
|
const visibleMessages = filterUserFacingChatMessages(messages);
|
|
321
321
|
const sync = buildFullTail(visibleMessages, normalizeReadChatTailLimit(args));
|
|
322
322
|
const hiddenMsgCount = Math.max(0, messages.length - visibleMessages.length);
|
|
323
|
-
const
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
323
|
+
const returnedDebugReadChat = debugReadChat
|
|
324
|
+
? {
|
|
325
|
+
...debugReadChat,
|
|
326
|
+
fullMsgCount: typeof debugReadChat.fullMsgCount === 'number'
|
|
327
|
+
? debugReadChat.fullMsgCount
|
|
328
|
+
: messages.length,
|
|
329
|
+
visibleMsgCount: visibleMessages.length,
|
|
330
|
+
hiddenMsgCount,
|
|
331
|
+
returnedMsgCount: sync.messages.length,
|
|
332
|
+
}
|
|
333
|
+
: undefined;
|
|
330
334
|
return {
|
|
331
335
|
success: true,
|
|
332
336
|
...validatedPayload,
|
|
333
337
|
messages: sync.messages,
|
|
334
338
|
totalMessages: sync.totalMessages,
|
|
335
|
-
debugReadChat:
|
|
339
|
+
...(returnedDebugReadChat ? { debugReadChat: returnedDebugReadChat } : {}),
|
|
336
340
|
};
|
|
337
341
|
}
|
|
338
342
|
|
|
@@ -179,25 +179,44 @@ function readMessageMeta(message: ChatMessage): Record<string, unknown> | null {
|
|
|
179
179
|
: null;
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
-
function
|
|
183
|
-
|
|
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;
|
|
182
|
+
function readStringField(value: unknown): string {
|
|
183
|
+
return typeof value === 'string' ? value.trim().toLowerCase() : '';
|
|
193
184
|
}
|
|
194
185
|
|
|
195
|
-
function
|
|
196
|
-
|
|
197
|
-
const visibility =
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
186
|
+
function isExplicitlyHiddenFromTranscript(message: ChatMessage, meta: Record<string, unknown> | null): boolean {
|
|
187
|
+
const record = message as ChatMessage & Record<string, unknown>;
|
|
188
|
+
const visibility = readStringField(record.visibility || meta?.visibility || meta?.transcriptVisibility);
|
|
189
|
+
const audience = readStringField(record.audience || meta?.audience);
|
|
190
|
+
const source = readStringField(record.source || meta?.source);
|
|
191
|
+
|
|
192
|
+
return visibility === 'hidden'
|
|
193
|
+
|| visibility === 'debug'
|
|
194
|
+
|| visibility === 'internal'
|
|
195
|
+
|| audience === 'debug'
|
|
196
|
+
|| audience === 'trace'
|
|
197
|
+
|| audience === 'internal'
|
|
198
|
+
|| source === 'runtime_status'
|
|
199
|
+
|| source === 'provider_chrome'
|
|
200
|
+
|| source === 'control'
|
|
201
|
+
|| record.internal === true
|
|
202
|
+
|| record.isInternal === true
|
|
203
|
+
|| record.debug === true
|
|
204
|
+
|| meta?.internal === true
|
|
205
|
+
|| meta?.isInternal === true
|
|
206
|
+
|| meta?.debug === true
|
|
207
|
+
|| meta?.statusOnly === true
|
|
208
|
+
|| meta?.controlOnly === true;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function isExplicitlyVisibleInTranscript(message: ChatMessage, meta: Record<string, unknown> | null): boolean {
|
|
212
|
+
const record = message as ChatMessage & Record<string, unknown>;
|
|
213
|
+
const visibility = readStringField(record.visibility || meta?.visibility || meta?.transcriptVisibility);
|
|
214
|
+
const audience = readStringField(record.audience || meta?.audience);
|
|
215
|
+
return visibility === 'visible'
|
|
216
|
+
|| visibility === 'user'
|
|
217
|
+
|| audience === 'chat'
|
|
218
|
+
|| record.userFacing === true
|
|
219
|
+
|| meta?.userFacing === true;
|
|
201
220
|
}
|
|
202
221
|
|
|
203
222
|
/**
|
|
@@ -212,8 +231,8 @@ function isExplicitlyVisibleInTranscript(meta: Record<string, unknown> | null):
|
|
|
212
231
|
export function isUserFacingChatMessage(message: ChatMessage | null | undefined): boolean {
|
|
213
232
|
if (!message) return false;
|
|
214
233
|
const meta = readMessageMeta(message);
|
|
215
|
-
if (isExplicitlyHiddenFromTranscript(meta)) return false;
|
|
216
|
-
if (isExplicitlyVisibleInTranscript(meta)) return true;
|
|
234
|
+
if (isExplicitlyHiddenFromTranscript(message, meta)) return false;
|
|
235
|
+
if (isExplicitlyVisibleInTranscript(message, meta)) return true;
|
|
217
236
|
|
|
218
237
|
const role = typeof message.role === 'string' ? message.role.trim().toLowerCase() : '';
|
|
219
238
|
const kind = resolveChatMessageKind(message);
|
|
@@ -25,7 +25,7 @@ import { formatAutoApprovalMessage, pickApprovalButton } from './approval-utils.
|
|
|
25
25
|
import { getCliScriptCommand, parseCliScriptResult } from './cli-script-results.js';
|
|
26
26
|
import { mergeProviderPatchState, resolveProviderStateSurface } from './provider-patch-state.js';
|
|
27
27
|
import { normalizeProviderSessionId } from './provider-session-id.js';
|
|
28
|
-
import { buildChatMessage, buildRuntimeSystemChatMessage, normalizeChatMessages, resolveChatMessageKind } from './chat-message-normalization.js';
|
|
28
|
+
import { buildChatMessage, buildRuntimeSystemChatMessage, isUserFacingChatMessage, normalizeChatMessages, resolveChatMessageKind } from './chat-message-normalization.js';
|
|
29
29
|
|
|
30
30
|
type PersistableCliHistoryMessage = {
|
|
31
31
|
role: string;
|
|
@@ -1031,14 +1031,11 @@ export class CliProviderInstance implements ProviderInstance {
|
|
|
1031
1031
|
const getRole = (message: ChatMessage): string => typeof message.role === 'string'
|
|
1032
1032
|
? message.role.trim().toLowerCase()
|
|
1033
1033
|
: '';
|
|
1034
|
-
const
|
|
1034
|
+
const isRuntimeOverlay = (entry: MergeEntry): boolean => {
|
|
1035
1035
|
if (entry.source !== 'runtime') return false;
|
|
1036
1036
|
const key = typeof entry.runtimeKey === 'string' ? entry.runtimeKey.trim().toLowerCase() : '';
|
|
1037
1037
|
if (key.startsWith('auto_approval:')) return true;
|
|
1038
|
-
|
|
1039
|
-
? entry.message.content.trim().toLowerCase()
|
|
1040
|
-
: flattenContent(entry.message.content).trim().toLowerCase();
|
|
1041
|
-
return content.startsWith('auto-approved:');
|
|
1038
|
+
return !isUserFacingChatMessage(entry.message);
|
|
1042
1039
|
};
|
|
1043
1040
|
const shouldKeepParsedBeforeUntimedRuntime = (message: ChatMessage): boolean => {
|
|
1044
1041
|
const role = getRole(message);
|
|
@@ -1059,7 +1056,7 @@ export class CliProviderInstance implements ProviderInstance {
|
|
|
1059
1056
|
if (a.source !== b.source && aTime !== bTime) {
|
|
1060
1057
|
const parsedEntry = a.source === 'parsed' ? a : b.source === 'parsed' ? b : null;
|
|
1061
1058
|
const runtimeEntry = a.source === 'runtime' ? a : b.source === 'runtime' ? b : null;
|
|
1062
|
-
if (parsedEntry && runtimeEntry &&
|
|
1059
|
+
if (parsedEntry && runtimeEntry && isRuntimeOverlay(runtimeEntry) && getTime(parsedEntry.message) === 0 && getTime(runtimeEntry.message) > 0) {
|
|
1063
1060
|
if (shouldKeepParsedBeforeUntimedRuntime(parsedEntry.message)) {
|
|
1064
1061
|
return a.source === 'parsed' ? -1 : 1;
|
|
1065
1062
|
}
|
|
@@ -1072,8 +1069,8 @@ export class CliProviderInstance implements ProviderInstance {
|
|
|
1072
1069
|
// do not carry timestamps on parsed messages. In that case there is no safe
|
|
1073
1070
|
// clock basis for interleaving timestamped runtime/system messages into the
|
|
1074
1071
|
// provider transcript. Keep user prompts before runtime overlays, but do not
|
|
1075
|
-
// let timed runtime/system overlays become the final chat turns
|
|
1076
|
-
// untimed parsed assistant transcript.
|
|
1072
|
+
// let timed runtime/system/tool/internal overlays become the final chat turns
|
|
1073
|
+
// after an untimed parsed assistant transcript.
|
|
1077
1074
|
return a.index - b.index;
|
|
1078
1075
|
})
|
|
1079
1076
|
.map((entry) => entry.message));
|