@tanstack/ai-devtools-core 0.5.10 → 0.5.11
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/Shell/{2X67PB7B.js → DCUFLPG6.js} +382 -77
- package/dist/{production/Shell/BJP2PZMD.js → Shell/JT2B6WKX.js} +591 -161
- package/dist/Shell/{YJTEAPIF.js → YBXRSRRK.js} +591 -161
- package/dist/dev.js +1 -1
- package/dist/index.js +1 -1
- package/dist/production/Shell/{2X67PB7B.js → DCUFLPG6.js} +382 -77
- package/dist/{Shell/BJP2PZMD.js → production/Shell/JT2B6WKX.js} +591 -161
- package/dist/production/Shell/{YJTEAPIF.js → YBXRSRRK.js} +591 -161
- package/dist/production/dev.js +1 -1
- package/dist/production/index.js +1 -1
- package/dist/production/server.js +1 -1
- package/dist/server.js +1 -1
- package/package.json +3 -3
- package/src/components/conversation/IterationCard.tsx +11 -5
- package/src/components/hooks/CompactionPanel.tsx +223 -0
- package/src/components/hooks/HookDashboard.tsx +3 -2
- package/src/components/hooks/HookDetails.tsx +22 -3
- package/src/components/hooks/index.ts +1 -0
- package/src/store/ai-context.tsx +113 -7
- package/src/store/compaction-registry.ts +121 -0
- package/src/styles/use-styles.ts +1 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
const MAX_EVENTS = 50
|
|
2
|
+
|
|
3
|
+
export type CompactionEventKind = 'started' | 'state' | 'ended'
|
|
4
|
+
|
|
5
|
+
export interface CompactionMessagePreview {
|
|
6
|
+
role: string
|
|
7
|
+
tokens: number
|
|
8
|
+
text: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface CompactionEventRecord {
|
|
12
|
+
id: string
|
|
13
|
+
kind: CompactionEventKind
|
|
14
|
+
timestamp: number
|
|
15
|
+
hookId?: string
|
|
16
|
+
clientId?: string
|
|
17
|
+
threadId?: string
|
|
18
|
+
runId?: string
|
|
19
|
+
before?: number
|
|
20
|
+
after?: number
|
|
21
|
+
messagesBefore?: number
|
|
22
|
+
messagesAfter?: number
|
|
23
|
+
reusedCheckpoint?: boolean
|
|
24
|
+
maxTokens?: number
|
|
25
|
+
strategyKey?: string
|
|
26
|
+
durationMs?: number
|
|
27
|
+
dropped?: Array<CompactionMessagePreview>
|
|
28
|
+
result?: Array<CompactionMessagePreview>
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface CompactionRegistryState {
|
|
32
|
+
events: Array<CompactionEventRecord>
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function createCompactionRegistryState(): CompactionRegistryState {
|
|
36
|
+
return { events: [] }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface CompactionLifecycleInput {
|
|
40
|
+
timestamp: number
|
|
41
|
+
eventId?: string
|
|
42
|
+
hookId?: string
|
|
43
|
+
clientId?: string
|
|
44
|
+
threadId?: string
|
|
45
|
+
runId?: string
|
|
46
|
+
before?: number
|
|
47
|
+
after?: number
|
|
48
|
+
messagesBefore?: number
|
|
49
|
+
messagesAfter?: number
|
|
50
|
+
reusedCheckpoint?: boolean
|
|
51
|
+
maxTokens?: number
|
|
52
|
+
strategyKey?: string
|
|
53
|
+
durationMs?: number
|
|
54
|
+
dropped?: Array<CompactionMessagePreview>
|
|
55
|
+
result?: Array<CompactionMessagePreview>
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function eventId(
|
|
59
|
+
kind: CompactionEventKind,
|
|
60
|
+
event: CompactionLifecycleInput,
|
|
61
|
+
): string {
|
|
62
|
+
return [
|
|
63
|
+
'cmp',
|
|
64
|
+
kind,
|
|
65
|
+
String(event.timestamp),
|
|
66
|
+
event.hookId ?? event.clientId ?? event.threadId ?? 'unknown',
|
|
67
|
+
String(event.before ?? event.after ?? ''),
|
|
68
|
+
].join('-')
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Append one compaction lifecycle event. Newest stays at the end. */
|
|
72
|
+
export function applyCompactionEvent(
|
|
73
|
+
state: CompactionRegistryState,
|
|
74
|
+
kind: CompactionEventKind,
|
|
75
|
+
event: CompactionLifecycleInput,
|
|
76
|
+
): void {
|
|
77
|
+
state.events.push({
|
|
78
|
+
id: event.eventId ?? eventId(kind, event),
|
|
79
|
+
kind,
|
|
80
|
+
timestamp: event.timestamp,
|
|
81
|
+
hookId: event.hookId,
|
|
82
|
+
clientId: event.clientId,
|
|
83
|
+
threadId: event.threadId,
|
|
84
|
+
runId: event.runId,
|
|
85
|
+
before: event.before,
|
|
86
|
+
after: event.after,
|
|
87
|
+
messagesBefore: event.messagesBefore,
|
|
88
|
+
messagesAfter: event.messagesAfter,
|
|
89
|
+
reusedCheckpoint: event.reusedCheckpoint,
|
|
90
|
+
maxTokens: event.maxTokens,
|
|
91
|
+
strategyKey: event.strategyKey,
|
|
92
|
+
durationMs: event.durationMs,
|
|
93
|
+
dropped: event.dropped,
|
|
94
|
+
result: event.result,
|
|
95
|
+
})
|
|
96
|
+
if (state.events.length > MAX_EVENTS) {
|
|
97
|
+
state.events.splice(0, state.events.length - MAX_EVENTS)
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function clearCompactionRegistry(state: CompactionRegistryState): void {
|
|
102
|
+
state.events = []
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function compactionEventsForHook(
|
|
106
|
+
state: CompactionRegistryState,
|
|
107
|
+
hook: { id: string; clientId?: string; threadId?: string },
|
|
108
|
+
): Array<CompactionEventRecord> {
|
|
109
|
+
const matched = state.events.filter((event) => {
|
|
110
|
+
if (event.hookId && event.hookId === hook.id) return true
|
|
111
|
+
if (event.clientId && hook.clientId && event.clientId === hook.clientId) {
|
|
112
|
+
return true
|
|
113
|
+
}
|
|
114
|
+
if (event.threadId && hook.threadId && event.threadId === hook.threadId) {
|
|
115
|
+
return true
|
|
116
|
+
}
|
|
117
|
+
return false
|
|
118
|
+
})
|
|
119
|
+
if (matched.length > 0) return matched
|
|
120
|
+
return state.events
|
|
121
|
+
}
|
package/src/styles/use-styles.ts
CHANGED
|
@@ -3650,6 +3650,7 @@ const stylesFactory = (theme: 'light' | 'dark') => {
|
|
|
3650
3650
|
grid-template-columns: repeat(2, minmax(320px, 1fr));
|
|
3651
3651
|
gap: ${size[3]};
|
|
3652
3652
|
align-items: start;
|
|
3653
|
+
padding-left: ${size[3]};
|
|
3653
3654
|
padding-right: ${size[3]};
|
|
3654
3655
|
@media (max-width: 760px) {
|
|
3655
3656
|
grid-template-columns: 1fr;
|