pi-mega-compact 0.8.8 → 0.8.10
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/extensions/dashboard-server/api-contracts/core.js +7 -0
- package/dist/extensions/dashboard-server/api-contracts/endpoints.js +104 -0
- package/dist/extensions/dashboard-server/api-contracts/game.js +9 -0
- package/dist/extensions/dashboard-server/api-contracts/index.js +9 -0
- package/dist/extensions/dashboard-server/api-contracts/infrastructure.js +10 -0
- package/dist/extensions/dashboard-server/api-contracts/multi-repo.js +9 -0
- package/dist/extensions/dashboard-server/api-contracts/snapshot.js +8 -0
- package/dist/extensions/dashboard-server/api-contracts.js +8 -0
- package/dist/extensions/dashboard-server/api-contracts.test.js +869 -0
- package/dist/extensions/dashboard-server/auth.js +18 -0
- package/dist/extensions/dashboard-server/helpers.js +37 -0
- package/dist/extensions/dashboard-server/html/all-repos-tab.js +26 -0
- package/dist/extensions/dashboard-server/html/body-open.js +23 -0
- package/dist/extensions/dashboard-server/html/current-repo-tab.js +130 -0
- package/dist/extensions/dashboard-server/html/head-open.js +16 -0
- package/dist/extensions/dashboard-server/html/high-score-tab.js +25 -0
- package/dist/extensions/dashboard-server/html/repo-detail-modal.js +26 -0
- package/dist/extensions/dashboard-server/html/script.js +259 -0
- package/dist/extensions/dashboard-server/html/styles.js +103 -0
- package/dist/extensions/dashboard-server/html/summary-tab.js +19 -0
- package/dist/extensions/dashboard-server/html-template.js +41 -0
- package/dist/extensions/dashboard-server/server.js +191 -39
- package/dist/extensions/dashboard-server/tailscale.js +8 -0
- package/dist/extensions/dashboard-server/types.js +4 -0
- package/dist/src/store/sqlite/connection.js +35 -0
- package/dist/src/store/sqlite/index-store.js +167 -0
- package/dist/src/store/sqlite/memory.js +54 -0
- package/dist/src/store/sqlite/minhash-lsh.js +47 -0
- package/dist/src/store/sqlite/sessions.js +39 -0
- package/dist/src/store/sqlite/transaction.js +19 -0
- package/dist/src/vectorStore/add.js +260 -0
- package/dist/src/vectorStore/dedup.js +52 -0
- package/dist/src/vectorStore/index.js +10 -0
- package/dist/src/vectorStore/queries.js +83 -0
- package/dist/src/vectorStore/search.js +95 -0
- package/dist/src/vectorStore/session.js +19 -0
- package/dist/src/vectorStore/store.js +105 -0
- package/dist/src/vectorStore/types.js +6 -0
- package/dist/src/vectorStore/utils.js +23 -0
- package/extensions/dashboard-client/package-lock.json +1771 -0
- package/extensions/dashboard-client/package.json +27 -0
- package/extensions/dashboard-client/src/App.tsx +82 -0
- package/extensions/dashboard-client/src/api/client.ts +145 -0
- package/extensions/dashboard-client/src/components/CacheStatusPerModel.tsx +44 -0
- package/extensions/dashboard-client/src/components/CompressionCard.tsx +61 -0
- package/extensions/dashboard-client/src/components/ContextGauge.tsx +59 -0
- package/extensions/dashboard-client/src/components/DataSafetyCard.tsx +49 -0
- package/extensions/dashboard-client/src/components/ErrorBoundary.tsx +53 -0
- package/extensions/dashboard-client/src/components/EventCategoryFilter.tsx +16 -0
- package/extensions/dashboard-client/src/components/EventStream.tsx +152 -0
- package/extensions/dashboard-client/src/components/LoadingSpinner.tsx +7 -0
- package/extensions/dashboard-client/src/components/MemoryStatusCard.tsx +24 -0
- package/extensions/dashboard-client/src/components/ModelBadge.tsx +41 -0
- package/extensions/dashboard-client/src/components/PerfChart.tsx +160 -0
- package/extensions/dashboard-client/src/components/RepoDetailModal.tsx +126 -0
- package/extensions/dashboard-client/src/components/RepoTable.tsx +150 -0
- package/extensions/dashboard-client/src/components/SessionInfo.tsx +65 -0
- package/extensions/dashboard-client/src/components/SummaryTiles.tsx +52 -0
- package/extensions/dashboard-client/src/components/TabBar.tsx +34 -0
- package/extensions/dashboard-client/src/components/TriggerStatus.tsx +62 -0
- package/extensions/dashboard-client/src/hooks/useApi.ts +77 -0
- package/extensions/dashboard-client/src/hooks/useSSE.ts +87 -0
- package/extensions/dashboard-client/src/index.html +12 -0
- package/extensions/dashboard-client/src/main.tsx +23 -0
- package/extensions/dashboard-client/src/styles/base.css +121 -0
- package/extensions/dashboard-client/src/styles/overview-events.css +318 -0
- package/extensions/dashboard-client/src/styles/repos-metrics.css +307 -0
- package/extensions/dashboard-client/src/tabs/ConfigTab.tsx +16 -0
- package/extensions/dashboard-client/src/tabs/EventsTab.tsx +37 -0
- package/extensions/dashboard-client/src/tabs/MetricsTab.tsx +49 -0
- package/extensions/dashboard-client/src/tabs/OverviewTab.tsx +80 -0
- package/extensions/dashboard-client/src/tabs/ReposTab.tsx +59 -0
- package/extensions/dashboard-client/tsconfig.json +28 -0
- package/extensions/dashboard-client/vite.config.ts +38 -0
- package/extensions/dashboard-server/api-contracts/core.ts +302 -0
- package/extensions/dashboard-server/api-contracts/endpoints.ts +476 -0
- package/extensions/dashboard-server/api-contracts/game.ts +145 -0
- package/extensions/dashboard-server/api-contracts/index.ts +159 -0
- package/extensions/dashboard-server/api-contracts/infrastructure.ts +465 -0
- package/extensions/dashboard-server/api-contracts/multi-repo.ts +328 -0
- package/extensions/dashboard-server/api-contracts/snapshot.ts +386 -0
- package/extensions/dashboard-server/api-contracts.test.ts +1050 -0
- package/extensions/dashboard-server/api-contracts.ts +96 -0
- package/extensions/dashboard-server/auth.ts +20 -0
- package/extensions/dashboard-server/server.ts +862 -582
- package/extensions/dashboard-server/tailscale.ts +7 -0
- package/extensions/dashboard-server/types.ts +23 -114
- package/package.json +2 -1
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* api-contracts/snapshot.ts — Snapshot / store / compression / session contracts.
|
|
3
|
+
*
|
|
4
|
+
* Contains: SnapshotResponse, TriggerResponse, CompressionTotalsResponse,
|
|
5
|
+
* CompactHistoryEntry, CompactionRequest, CompactionResponse.
|
|
6
|
+
* Extracted from api-contracts.ts (Sprint A1 split).
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// ─── /api/snapshot ─────────────────────────────────────────────────────────
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Response body for `GET /api/snapshot`.
|
|
13
|
+
*
|
|
14
|
+
* Provides a comprehensive real-time view of the compaction engine state,
|
|
15
|
+
* including configuration, session info, context pressure, trigger status,
|
|
16
|
+
* store metrics, crew status, per-repo statistics, integrity, cache hits,
|
|
17
|
+
* time savings, and compression totals.
|
|
18
|
+
*/
|
|
19
|
+
export interface SnapshotResponse {
|
|
20
|
+
/** ISO 8601 timestamp of the last snapshot update, or `null` if never updated. */
|
|
21
|
+
updatedAt: string | null;
|
|
22
|
+
/** Currently active compaction tier name (e.g. `'ultra-compact'`, `'super-compact'`). */
|
|
23
|
+
tier: string;
|
|
24
|
+
/** Preset (default) compaction tier name before any override. */
|
|
25
|
+
presetTier: string;
|
|
26
|
+
/** Current context pressure (percent, 0–100). */
|
|
27
|
+
pressure: number;
|
|
28
|
+
/** Active compaction configuration. */
|
|
29
|
+
config: {
|
|
30
|
+
/** Fast-gate pressure threshold (percent, 0–100). Compaction fires early when pressure exceeds this. */
|
|
31
|
+
fastGatePct: number;
|
|
32
|
+
/** Token threshold at which standard compaction triggers (tokens). */
|
|
33
|
+
thresholdTokens: number;
|
|
34
|
+
/** Number of recent user messages preserved as anchors during compaction. */
|
|
35
|
+
anchorUserMessages: number;
|
|
36
|
+
/** Number of recent messages always preserved (never compacted). */
|
|
37
|
+
preserveRecent: number;
|
|
38
|
+
/** Whether auto-compaction is enabled. */
|
|
39
|
+
auto: boolean;
|
|
40
|
+
/** Number of recalled chunks to inline per compaction cycle. */
|
|
41
|
+
autoInlineK: number;
|
|
42
|
+
};
|
|
43
|
+
/** Current session state. */
|
|
44
|
+
session: {
|
|
45
|
+
/** Active session ID, or `null` when no session is active. */
|
|
46
|
+
id: string | null;
|
|
47
|
+
/** Session lifecycle state (e.g. `'idle'`, `'compacting'`), or `null` when no session is active. */
|
|
48
|
+
state: string | null;
|
|
49
|
+
/** Whether a checkpoint has been persisted during this session. */
|
|
50
|
+
persistedThisSession: boolean;
|
|
51
|
+
/** ID of the most recent checkpoint, or `null` if none exists. */
|
|
52
|
+
lastCheckpointId: string | null;
|
|
53
|
+
/** Token count the context had before the last compaction (tokens). */
|
|
54
|
+
lastCompactedFrom: number;
|
|
55
|
+
};
|
|
56
|
+
/** Current context window utilization. */
|
|
57
|
+
context: {
|
|
58
|
+
/** Current token count in the context window, or `null` if unknown (tokens). */
|
|
59
|
+
tokens: number | null;
|
|
60
|
+
/** Context window usage as a percentage of the window size, or `null` if unknown (percent, 0–100). */
|
|
61
|
+
percent: number | null;
|
|
62
|
+
/** Maximum context window size for the active model (tokens). */
|
|
63
|
+
contextWindow: number;
|
|
64
|
+
};
|
|
65
|
+
/** Compaction trigger status. */
|
|
66
|
+
trigger: {
|
|
67
|
+
/** Whether the trigger is armed (waiting for threshold). */
|
|
68
|
+
armed: boolean;
|
|
69
|
+
/** Whether the trigger is ready to fire (pressure at or above threshold). */
|
|
70
|
+
ready: boolean;
|
|
71
|
+
/** Current context token count, or `null` if unknown (tokens). */
|
|
72
|
+
currentTokens: number | null;
|
|
73
|
+
/** Token threshold for firing (tokens). */
|
|
74
|
+
thresholdTokens: number;
|
|
75
|
+
/** Fast-gate pressure threshold (percent, 0–100). */
|
|
76
|
+
fastGatePct: number;
|
|
77
|
+
};
|
|
78
|
+
/** Aggregate store metrics (all sessions). */
|
|
79
|
+
store: {
|
|
80
|
+
/** Total number of checkpoints across all sessions. */
|
|
81
|
+
checkpointCount: number;
|
|
82
|
+
/** Estimated total tokens across all checkpoints (tokens). */
|
|
83
|
+
totalTokenEstimate: number;
|
|
84
|
+
/** Original token count before any compaction (tokens). */
|
|
85
|
+
originalTokens: number;
|
|
86
|
+
/** Total tokens saved through compaction (tokens). */
|
|
87
|
+
tokensSaved: number;
|
|
88
|
+
/** Number of recalled chunks injected into contexts. */
|
|
89
|
+
injectedCount: number;
|
|
90
|
+
/** Deduplication hit rate (percent, 0–100). */
|
|
91
|
+
dedupHitRate: number;
|
|
92
|
+
/** Storage deduplication rate — fraction of bytes deduplicated (percent, 0–100). */
|
|
93
|
+
storageDedupRate: number;
|
|
94
|
+
/** Number of duplicate chunks collapsed by dedup. */
|
|
95
|
+
dedupCollapsed: number;
|
|
96
|
+
};
|
|
97
|
+
/** Crew (multi-agent) status. */
|
|
98
|
+
crew: {
|
|
99
|
+
/** Number of active crew agents. */
|
|
100
|
+
activeAgents: number;
|
|
101
|
+
/** Current turn index in the crew round-robin. */
|
|
102
|
+
currentTurn: number;
|
|
103
|
+
};
|
|
104
|
+
/** Per-repo (current repository) statistics. */
|
|
105
|
+
repo: {
|
|
106
|
+
/** Number of checkpoints for the current repo. */
|
|
107
|
+
checkpointCount: number;
|
|
108
|
+
/** Estimated total tokens for the current repo (tokens). */
|
|
109
|
+
totalTokenEstimate: number;
|
|
110
|
+
/** Original token count for the current repo before compaction (tokens). */
|
|
111
|
+
originalTokens: number;
|
|
112
|
+
/** Tokens saved for the current repo (tokens). */
|
|
113
|
+
tokensSaved: number;
|
|
114
|
+
/** Number of sessions recorded for the current repo. */
|
|
115
|
+
sessionCount: number;
|
|
116
|
+
/** Number of dedup attempts for the current repo. */
|
|
117
|
+
dedupAttempts: number;
|
|
118
|
+
/** Number of duplicate chunks collapsed for the current repo. */
|
|
119
|
+
dedupCollapsed: number;
|
|
120
|
+
/** Storage deduplication rate for the current repo (percent, 0–100). */
|
|
121
|
+
storageDedupRate: number;
|
|
122
|
+
};
|
|
123
|
+
/** Data integrity metrics. */
|
|
124
|
+
integrity: {
|
|
125
|
+
/** Number of regions retained after compaction. */
|
|
126
|
+
regionsRetained: number;
|
|
127
|
+
/** Original byte size of compressed data before dedup (bytes). */
|
|
128
|
+
compressedOriginalBytes: number;
|
|
129
|
+
/** Number of duplicate chunks collapsed. */
|
|
130
|
+
duplicatesCollapsed: number;
|
|
131
|
+
/** Bytes permanently deleted during compaction (bytes). */
|
|
132
|
+
bytesPermanentlyDeleted: number;
|
|
133
|
+
};
|
|
134
|
+
/** Cache hit statistics. */
|
|
135
|
+
cacheHits: {
|
|
136
|
+
/** Cache hits in the current session. */
|
|
137
|
+
session: number;
|
|
138
|
+
/** Total cache hits across all sessions. */
|
|
139
|
+
total: number;
|
|
140
|
+
/** Tokens saved by cache hits this session (tokens). */
|
|
141
|
+
sessionTokensSaved: number;
|
|
142
|
+
/** Total tokens saved by cache hits (tokens). */
|
|
143
|
+
totalTokensSaved: number;
|
|
144
|
+
};
|
|
145
|
+
/** Compaction run counts. */
|
|
146
|
+
compacts: {
|
|
147
|
+
/** Compactions performed this session. */
|
|
148
|
+
session: number;
|
|
149
|
+
/** Total compactions performed. */
|
|
150
|
+
total: number;
|
|
151
|
+
};
|
|
152
|
+
/** Estimated time saved by compaction and cache hits. */
|
|
153
|
+
timeSaved: {
|
|
154
|
+
/** Time saved by compaction. */
|
|
155
|
+
compact: {
|
|
156
|
+
/** Seconds saved by compaction this session (seconds). */
|
|
157
|
+
sessionSec: number;
|
|
158
|
+
/** Total seconds saved by compaction (seconds). */
|
|
159
|
+
totalSec: number;
|
|
160
|
+
};
|
|
161
|
+
/** Time saved by cache hits. */
|
|
162
|
+
cacheHit: {
|
|
163
|
+
/** Seconds saved by cache hits this session (seconds). */
|
|
164
|
+
sessionSec: number;
|
|
165
|
+
/** Total seconds saved by cache hits (seconds). */
|
|
166
|
+
totalSec: number;
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
/** Compression statistics for session and repo. */
|
|
170
|
+
compression: {
|
|
171
|
+
/** Session-level compression. */
|
|
172
|
+
session: {
|
|
173
|
+
/** Input tokens for the session (tokens). */
|
|
174
|
+
tokensIn: number;
|
|
175
|
+
/** Output tokens after compression for the session (tokens). */
|
|
176
|
+
tokensOut: number;
|
|
177
|
+
/** Tokens freed by compression for the session (tokens). */
|
|
178
|
+
tokensFreed: number;
|
|
179
|
+
/** Compression ratio for the session (percent, 0–100). */
|
|
180
|
+
compressionPct: number;
|
|
181
|
+
/** Dedup contribution for the session (percent, 0–100). */
|
|
182
|
+
dedupPct: number;
|
|
183
|
+
};
|
|
184
|
+
/** Repo-level compression. */
|
|
185
|
+
repo: {
|
|
186
|
+
/** Input tokens for the repo (tokens). */
|
|
187
|
+
tokensIn: number;
|
|
188
|
+
/** Output tokens after compression for the repo (tokens). */
|
|
189
|
+
tokensOut: number;
|
|
190
|
+
/** Tokens freed by compression for the repo (tokens). */
|
|
191
|
+
tokensFreed: number;
|
|
192
|
+
/** Compression ratio for the repo (percent, 0–100). */
|
|
193
|
+
compressionPct: number;
|
|
194
|
+
/** Dedup contribution for the repo (percent, 0–100). */
|
|
195
|
+
dedupPct: number;
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
/** Active model information. Present when a model is configured and active; absent otherwise. */
|
|
199
|
+
model?: {
|
|
200
|
+
/** Model name/identifier. */
|
|
201
|
+
name: string;
|
|
202
|
+
/** Machine-readable provider identifier. */
|
|
203
|
+
provider: string;
|
|
204
|
+
/** Human-readable provider name. */
|
|
205
|
+
providerName: string;
|
|
206
|
+
/** Model input processing rate (tokens per second). */
|
|
207
|
+
inputRate: number;
|
|
208
|
+
/** Model output processing rate (tokens per second). */
|
|
209
|
+
outputRate: number;
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// ─── /api/trigger ──────────────────────────────────────────────────────────
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Response body for `GET /api/trigger`.
|
|
217
|
+
*
|
|
218
|
+
* Reports the current compaction trigger status, mirroring the `trigger`
|
|
219
|
+
* sub-object from `SnapshotResponse`.
|
|
220
|
+
*/
|
|
221
|
+
export interface TriggerResponse {
|
|
222
|
+
/** Whether the trigger is armed (waiting for threshold). */
|
|
223
|
+
armed: boolean;
|
|
224
|
+
/** Whether the trigger is ready to fire (pressure at or above threshold). */
|
|
225
|
+
ready: boolean;
|
|
226
|
+
/** Current context token count, or `null` if unknown (tokens). */
|
|
227
|
+
currentTokens: number | null;
|
|
228
|
+
/** Token threshold for firing (tokens). */
|
|
229
|
+
thresholdTokens: number;
|
|
230
|
+
/** Fast-gate pressure threshold (percent, 0–100). */
|
|
231
|
+
fastGatePct: number;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// ─── /api/compression-totals ───────────────────────────────────────────────
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Response body for `GET /api/compression-totals`.
|
|
238
|
+
*
|
|
239
|
+
* Summarizes compression, dedup, cache hit, and time-saved metrics at both
|
|
240
|
+
* session and repo levels.
|
|
241
|
+
*/
|
|
242
|
+
export interface CompressionTotalsResponse {
|
|
243
|
+
/** Repo-level compression statistics. */
|
|
244
|
+
repo: {
|
|
245
|
+
/** Input tokens for the repo (tokens). */
|
|
246
|
+
tokensIn: number;
|
|
247
|
+
/** Output tokens after compression for the repo (tokens). */
|
|
248
|
+
tokensOut: number;
|
|
249
|
+
/** Tokens freed by compression for the repo (tokens). */
|
|
250
|
+
tokensFreed: number;
|
|
251
|
+
/** Compression ratio for the repo (percent, 0–100). */
|
|
252
|
+
compressionPct: number;
|
|
253
|
+
/** Dedup contribution for the repo (percent, 0–100). */
|
|
254
|
+
dedupPct: number;
|
|
255
|
+
};
|
|
256
|
+
/** Session-level compression statistics. */
|
|
257
|
+
session: {
|
|
258
|
+
/** Input tokens for the session (tokens). */
|
|
259
|
+
tokensIn: number;
|
|
260
|
+
/** Output tokens after compression for the session (tokens). */
|
|
261
|
+
tokensOut: number;
|
|
262
|
+
/** Tokens freed by compression for the session (tokens). */
|
|
263
|
+
tokensFreed: number;
|
|
264
|
+
/** Compression ratio for the session (percent, 0–100). */
|
|
265
|
+
compressionPct: number;
|
|
266
|
+
/** Dedup contribution for the session (percent, 0–100). */
|
|
267
|
+
dedupPct: number;
|
|
268
|
+
};
|
|
269
|
+
/** Compaction run counts. */
|
|
270
|
+
compacts: {
|
|
271
|
+
/** Compactions performed this session. */
|
|
272
|
+
session: number;
|
|
273
|
+
/** Total compactions performed. */
|
|
274
|
+
total: number;
|
|
275
|
+
};
|
|
276
|
+
/** Cache hit statistics. */
|
|
277
|
+
cacheHits: {
|
|
278
|
+
/** Cache hits in the current session. */
|
|
279
|
+
session: number;
|
|
280
|
+
/** Total cache hits across all sessions. */
|
|
281
|
+
total: number;
|
|
282
|
+
/** Tokens saved by cache hits this session (tokens). */
|
|
283
|
+
sessionTokensSaved: number;
|
|
284
|
+
/** Total tokens saved by cache hits (tokens). */
|
|
285
|
+
totalTokensSaved: number;
|
|
286
|
+
};
|
|
287
|
+
/** Estimated time saved by compaction and cache hits. */
|
|
288
|
+
timeSaved: {
|
|
289
|
+
/** Time saved by compaction. */
|
|
290
|
+
compact: {
|
|
291
|
+
/** Seconds saved by compaction this session (seconds). */
|
|
292
|
+
sessionSec: number;
|
|
293
|
+
/** Total seconds saved by compaction (seconds). */
|
|
294
|
+
totalSec: number;
|
|
295
|
+
};
|
|
296
|
+
/** Time saved by cache hits. */
|
|
297
|
+
cacheHit: {
|
|
298
|
+
/** Seconds saved by cache hits this session (seconds). */
|
|
299
|
+
sessionSec: number;
|
|
300
|
+
/** Total seconds saved by cache hits (seconds). */
|
|
301
|
+
totalSec: number;
|
|
302
|
+
};
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// ─── /api/compact-history ─────────────────────────────────────────────────
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Response body for `GET /api/compact-history` (individual entry).
|
|
310
|
+
*
|
|
311
|
+
* Represents a single compaction event in the history log.
|
|
312
|
+
*/
|
|
313
|
+
export interface CompactHistoryEntry {
|
|
314
|
+
/** Unique identifier for this history entry. */
|
|
315
|
+
id: string;
|
|
316
|
+
/** ISO 8601 timestamp of the compaction. */
|
|
317
|
+
ts: string;
|
|
318
|
+
/** Compaction tier used (e.g. `'ultra-compact'`, `'super-compact'`). */
|
|
319
|
+
tier: string;
|
|
320
|
+
/**
|
|
321
|
+
* What triggered the compaction.
|
|
322
|
+
* Allowed values: `'manual'`, `'auto'`, `'fast-gate'`, `'ctx-pressure'`.
|
|
323
|
+
*/
|
|
324
|
+
trigger: 'manual' | 'auto' | 'fast-gate' | 'ctx-pressure';
|
|
325
|
+
/** Checkpoint count before the compaction. */
|
|
326
|
+
checkpointBefore: number;
|
|
327
|
+
/** Checkpoint count after the compaction. */
|
|
328
|
+
checkpointAfter: number;
|
|
329
|
+
/** Context token count before the compaction (tokens). */
|
|
330
|
+
contextBefore: number;
|
|
331
|
+
/** Context token count after the compaction (tokens). */
|
|
332
|
+
contextAfter: number;
|
|
333
|
+
/** Input tokens consumed by the compaction (tokens). */
|
|
334
|
+
tokensIn: number;
|
|
335
|
+
/** Output tokens after the compaction (tokens). */
|
|
336
|
+
tokensOut: number;
|
|
337
|
+
/** Tokens freed by the compaction (tokens). */
|
|
338
|
+
tokensFreed: number;
|
|
339
|
+
/** Number of duplicate chunks collapsed during this compaction. Present when dedup ran; absent otherwise. */
|
|
340
|
+
dedupCollapsed?: number;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// ─── POST /api/compact ─────────────────────────────────────────────────────
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Request body for `POST /api/compact`.
|
|
347
|
+
*
|
|
348
|
+
* Optionally specifies a compaction target mode and reason.
|
|
349
|
+
*/
|
|
350
|
+
export interface CompactionRequest {
|
|
351
|
+
/**
|
|
352
|
+
* Compaction intensity target.
|
|
353
|
+
* Allowed values: `'aggressive'`, `'standard'`, `'fast-gate'`.
|
|
354
|
+
* Absent when default (`'standard'`) should be used.
|
|
355
|
+
*/
|
|
356
|
+
target?: 'aggressive' | 'standard' | 'fast-gate';
|
|
357
|
+
/** Human-readable reason for the compaction. Absent when no reason is provided. */
|
|
358
|
+
reason?: string;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Response body for `POST /api/compact`.
|
|
363
|
+
*
|
|
364
|
+
* Reports the outcome of a compaction request.
|
|
365
|
+
*/
|
|
366
|
+
export interface CompactionResponse {
|
|
367
|
+
/**
|
|
368
|
+
* Outcome status.
|
|
369
|
+
* Allowed values: `'ok'`, `'error'`, `'skipped'`.
|
|
370
|
+
*/
|
|
371
|
+
status: 'ok' | 'error' | 'skipped';
|
|
372
|
+
/** Token count before compaction (tokens). Present on successful compaction; absent otherwise. */
|
|
373
|
+
beforeTokens?: number;
|
|
374
|
+
/** Token count after compaction (tokens). Present on successful compaction; absent otherwise. */
|
|
375
|
+
afterTokens?: number;
|
|
376
|
+
/** Tokens freed by the compaction (tokens). Present on successful compaction; absent otherwise. */
|
|
377
|
+
tokensFreed?: number;
|
|
378
|
+
/** Compaction tier used. Present on successful compaction; absent otherwise. */
|
|
379
|
+
tier?: string;
|
|
380
|
+
/** Checkpoint ID produced. Present on successful compaction; absent otherwise. */
|
|
381
|
+
checkpointId?: string;
|
|
382
|
+
/** Duration of the compaction (milliseconds). Present on successful compaction; absent otherwise. */
|
|
383
|
+
durationMs?: number;
|
|
384
|
+
/** Human-readable message (e.g. error detail or skip reason). Present when a message is available; absent otherwise. */
|
|
385
|
+
message?: string;
|
|
386
|
+
}
|