llmtop 0.1.4 → 0.1.6
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/README.md +70 -67
- package/dashboard/dist/assets/be-vietnam-pro-latin-400-normal-PpnXBOrz.woff2 +0 -0
- package/dashboard/dist/assets/be-vietnam-pro-latin-500-normal-B6LVzGNe.woff2 +0 -0
- package/dashboard/dist/assets/be-vietnam-pro-latin-600-normal-BZDkUTrt.woff2 +0 -0
- package/dashboard/dist/assets/be-vietnam-pro-latin-700-normal-DlW1Zbsh.woff2 +0 -0
- package/dashboard/dist/assets/be-vietnam-pro-latin-800-normal-BpHZASpI.woff2 +0 -0
- package/dashboard/dist/assets/be-vietnam-pro-latin-ext-400-normal-CiZNW1ec.woff2 +0 -0
- package/dashboard/dist/assets/be-vietnam-pro-latin-ext-500-normal-h0Fp6aX0.woff2 +0 -0
- package/dashboard/dist/assets/be-vietnam-pro-latin-ext-600-normal-BNd8euf0.woff2 +0 -0
- package/dashboard/dist/assets/be-vietnam-pro-latin-ext-700-normal-C8_gqRu2.woff2 +0 -0
- package/dashboard/dist/assets/be-vietnam-pro-latin-ext-800-normal-GEpNgheG.woff2 +0 -0
- package/dashboard/dist/assets/be-vietnam-pro-vietnamese-400-normal-CRcqvyg1.woff2 +0 -0
- package/dashboard/dist/assets/be-vietnam-pro-vietnamese-500-normal-DREgrEoJ.woff2 +0 -0
- package/dashboard/dist/assets/be-vietnam-pro-vietnamese-600-normal-nyU-ZL2p.woff2 +0 -0
- package/dashboard/dist/assets/be-vietnam-pro-vietnamese-700-normal-Csr0PCuG.woff2 +0 -0
- package/dashboard/dist/assets/be-vietnam-pro-vietnamese-800-normal-D4LFh2W4.woff2 +0 -0
- package/dashboard/dist/assets/index-C6JlgSDz.js +9 -0
- package/dashboard/dist/assets/index-CeDllzpB.css +1 -0
- package/dashboard/dist/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/dashboard/dist/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/dashboard/dist/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- package/dashboard/dist/index.html +2 -2
- package/dashboard/src/App.tsx +224 -88
- package/dashboard/src/controls/DateRange.tsx +3 -3
- package/dashboard/src/controls/Search.tsx +2 -2
- package/dashboard/src/controls/popover.tsx +24 -4
- package/dashboard/src/format.ts +1 -1
- package/dashboard/src/i18n.tsx +32 -4
- package/dashboard/src/main.tsx +11 -2
- package/dashboard/src/model.ts +1 -1
- package/dashboard/src/overview-flow.css +24 -0
- package/dashboard/src/overviewFlow.tsx +76 -0
- package/dashboard/src/sessionDetail.test.ts +19 -0
- package/dashboard/src/sessionScope.tsx +28 -0
- package/dashboard/src/shell/ConsoleFilters.tsx +203 -0
- package/dashboard/src/shell/Header.tsx +29 -0
- package/dashboard/src/shell/MobileSheet.tsx +29 -0
- package/dashboard/src/shell/Palette.tsx +114 -0
- package/dashboard/src/shell/Settings.tsx +37 -0
- package/dashboard/src/shell/SpecialStates.tsx +145 -0
- package/dashboard/src/shell/preferences.ts +71 -0
- package/dashboard/src/shell/styleColors.ts +5 -0
- package/dashboard/src/shell/useShortcuts.ts +67 -0
- package/dashboard/src/state.test.ts +9 -0
- package/dashboard/src/state.ts +13 -2
- package/dashboard/src/styles/commands.css +61 -0
- package/dashboard/src/styles/console.css +149 -0
- package/dashboard/src/styles/donut.css +83 -0
- package/dashboard/src/styles/fonts/be-vietnam-pro-LICENSE +93 -0
- package/dashboard/src/styles/fonts/be-vietnam-pro-latin-400-normal.woff2 +0 -0
- package/dashboard/src/styles/fonts/be-vietnam-pro-latin-500-normal.woff2 +0 -0
- package/dashboard/src/styles/fonts/be-vietnam-pro-latin-600-normal.woff2 +0 -0
- package/dashboard/src/styles/fonts/be-vietnam-pro-latin-700-normal.woff2 +0 -0
- package/dashboard/src/styles/fonts/be-vietnam-pro-latin-800-normal.woff2 +0 -0
- package/dashboard/src/styles/fonts/be-vietnam-pro-latin-ext-400-normal.woff2 +0 -0
- package/dashboard/src/styles/fonts/be-vietnam-pro-latin-ext-500-normal.woff2 +0 -0
- package/dashboard/src/styles/fonts/be-vietnam-pro-latin-ext-600-normal.woff2 +0 -0
- package/dashboard/src/styles/fonts/be-vietnam-pro-latin-ext-700-normal.woff2 +0 -0
- package/dashboard/src/styles/fonts/be-vietnam-pro-latin-ext-800-normal.woff2 +0 -0
- package/dashboard/src/styles/fonts/be-vietnam-pro-vietnamese-400-normal.woff2 +0 -0
- package/dashboard/src/styles/fonts/be-vietnam-pro-vietnamese-500-normal.woff2 +0 -0
- package/dashboard/src/styles/fonts/be-vietnam-pro-vietnamese-600-normal.woff2 +0 -0
- package/dashboard/src/styles/fonts/be-vietnam-pro-vietnamese-700-normal.woff2 +0 -0
- package/dashboard/src/styles/fonts/be-vietnam-pro-vietnamese-800-normal.woff2 +0 -0
- package/dashboard/src/styles/fonts/jetbrains-mono-LICENSE +93 -0
- package/dashboard/src/styles/fonts/jetbrains-mono-latin-ext-wght-normal.woff2 +0 -0
- package/dashboard/src/styles/fonts/jetbrains-mono-latin-wght-normal.woff2 +0 -0
- package/dashboard/src/styles/fonts/jetbrains-mono-vietnamese-wght-normal.woff2 +0 -0
- package/dashboard/src/styles/fonts.css +240 -0
- package/dashboard/src/styles/shell.css +151 -0
- package/dashboard/src/styles/states.css +32 -0
- package/dashboard/src/styles/tokens.css +159 -0
- package/dashboard/src/styles.css +13 -44
- package/dashboard/src/tip.ts +3 -1
- package/dashboard/src/treemap.ts +3 -0
- package/dashboard/src/ui.tsx +21 -32
- package/dashboard/src/views/Breakdown.tsx +46 -0
- package/dashboard/src/views/SessionDetail.tsx +67 -0
- package/dashboard/src/views/breakdown.css +33 -0
- package/dashboard/src/views/{Activity.tsx → classic/Activity.tsx} +31 -50
- package/dashboard/src/views/classic/Context.tsx +140 -0
- package/dashboard/src/views/{Models.tsx → classic/Models.tsx} +18 -35
- package/dashboard/src/views/classic/Overview.tsx +80 -0
- package/dashboard/src/views/classic/Projects.tsx +98 -0
- package/dashboard/src/views/{Sessions.tsx → classic/Sessions.tsx} +14 -17
- package/dashboard/src/views/{Subagents.tsx → classic/Subagents.tsx} +10 -34
- package/dashboard/src/views/console/Activity.tsx +241 -0
- package/dashboard/src/views/console/ConsoleBoot.tsx +73 -0
- package/dashboard/src/views/console/Context.tsx +162 -0
- package/dashboard/src/views/console/Models.tsx +187 -0
- package/dashboard/src/views/console/Overview.tsx +91 -0
- package/dashboard/src/views/console/Projects.tsx +6 -0
- package/dashboard/src/views/console/ProviderMeters.tsx +35 -0
- package/dashboard/src/views/console/Sessions.tsx +6 -0
- package/dashboard/src/views/console/Subagents.tsx +137 -0
- package/dashboard/src/views/console/activity-context.css +92 -0
- package/dashboard/src/views/console/console-boot.css +137 -0
- package/dashboard/src/views/console/modelVisuals.tsx +29 -0
- package/dashboard/src/views/console/models-subagents.css +203 -0
- package/dashboard/src/views/donut/Activity.tsx +247 -0
- package/dashboard/src/views/donut/Context.tsx +169 -0
- package/dashboard/src/views/donut/DonutBoot.tsx +68 -0
- package/dashboard/src/views/donut/Models.tsx +58 -0
- package/dashboard/src/views/donut/Overview.tsx +49 -0
- package/dashboard/src/views/donut/Projects.tsx +6 -0
- package/dashboard/src/views/donut/Ring.tsx +30 -0
- package/dashboard/src/views/donut/Sessions.tsx +6 -0
- package/dashboard/src/views/donut/Subagents.tsx +131 -0
- package/dashboard/src/views/donut/activity-context.css +154 -0
- package/dashboard/src/views/donut/donut-boot.css +165 -0
- package/dashboard/src/views/donut/models-subagents.css +157 -0
- package/dashboard/src/views/records/Projects.tsx +140 -0
- package/dashboard/src/views/records/Sessions.tsx +125 -0
- package/dashboard/src/views/records/records.css +119 -0
- package/dashboard/src/views/session-detail.css +44 -0
- package/dashboard/src/vm/activity.ts +72 -0
- package/dashboard/src/vm/colors.ts +57 -0
- package/dashboard/src/vm/context.ts +81 -0
- package/dashboard/src/vm/filterChoices.ts +27 -0
- package/dashboard/src/vm/models.ts +50 -0
- package/dashboard/src/vm/overview.ts +46 -0
- package/dashboard/src/vm/palette.ts +63 -0
- package/dashboard/src/vm/projects.ts +63 -0
- package/dashboard/src/vm/providerBreakdown.ts +19 -0
- package/dashboard/src/vm/sessionDetail.ts +16 -0
- package/dashboard/src/vm/sessions.ts +36 -0
- package/dashboard/src/vm/specialStates.ts +64 -0
- package/dashboard/src/vm/subagents.ts +36 -0
- package/dashboard/src/vm.test.ts +183 -0
- package/package.json +1 -1
- package/src/api.mjs +6 -1
- package/src/dashboard.mjs +4 -1
- package/src/db.mjs +5 -2
- package/src/providers/codex.mjs +121 -19
- package/src/serve.mjs +20 -10
- package/dashboard/dist/assets/index-Ba0kF2tG.js +0 -9
- package/dashboard/dist/assets/index-NQzaBVIY.css +0 -1
- package/dashboard/dist/assets/montserrat-cyrillic-ext-wght-normal-CO5hGrJv.woff2 +0 -0
- package/dashboard/dist/assets/montserrat-cyrillic-wght-normal-EAA9jha_.woff2 +0 -0
- package/dashboard/dist/assets/roboto-mono-cyrillic-ext-wght-normal-BUDPrIko.woff2 +0 -0
- package/dashboard/dist/assets/roboto-mono-cyrillic-wght-normal-HUlVHixE.woff2 +0 -0
- package/dashboard/dist/assets/roboto-mono-greek-wght-normal-BJJTbwTT.woff2 +0 -0
- package/dashboard/src/views/Context.tsx +0 -183
- package/dashboard/src/views/Overview.tsx +0 -83
- package/dashboard/src/views/Projects.tsx +0 -116
package/src/providers/codex.mjs
CHANGED
|
@@ -222,6 +222,18 @@ function extractDollarSkills(text) {
|
|
|
222
222
|
return [...seen];
|
|
223
223
|
}
|
|
224
224
|
|
|
225
|
+
const str = (v) => (typeof v === "string" && v ? v : null);
|
|
226
|
+
const modelOf = (v) => str(v) ?? str(v?.model);
|
|
227
|
+
function parseParserState(raw) {
|
|
228
|
+
if (!raw) return null;
|
|
229
|
+
try {
|
|
230
|
+
const o = JSON.parse(raw);
|
|
231
|
+
return o && typeof o === "object" ? o : null;
|
|
232
|
+
} catch {
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
225
237
|
export function createIngester(db, timeZone) {
|
|
226
238
|
const zone = zoner(timeZone);
|
|
227
239
|
const q = {
|
|
@@ -241,12 +253,17 @@ export function createIngester(db, timeZone) {
|
|
|
241
253
|
subagent_type = COALESCE(excluded.subagent_type, file_meta.subagent_type),
|
|
242
254
|
tool_use_id = COALESCE(excluded.tool_use_id, file_meta.tool_use_id),
|
|
243
255
|
repo_url = COALESCE(excluded.repo_url, file_meta.repo_url)`),
|
|
244
|
-
getStats: db.prepare("SELECT api_ms, tool_ms, lines_added, lines_removed, target_paths FROM file_meta WHERE file_id = ?"),
|
|
256
|
+
getStats: db.prepare("SELECT api_ms, tool_ms, lines_added, lines_removed, target_paths, parser_state FROM file_meta WHERE file_id = ?"),
|
|
245
257
|
upsertStats: db.prepare(`INSERT INTO file_meta(file_id, api_ms, tool_ms, lines_added, lines_removed) VALUES (?, ?, ?, ?, ?)
|
|
246
258
|
ON CONFLICT(file_id) DO UPDATE SET api_ms = excluded.api_ms, tool_ms = excluded.tool_ms,
|
|
247
259
|
lines_added = excluded.lines_added, lines_removed = excluded.lines_removed`),
|
|
248
260
|
upsertTargetPaths: db.prepare(`INSERT INTO file_meta(file_id, target_paths) VALUES (?, ?)
|
|
249
261
|
ON CONFLICT(file_id) DO UPDATE SET target_paths = excluded.target_paths`),
|
|
262
|
+
upsertParserState: db.prepare(`INSERT INTO file_meta(file_id, parser_state) VALUES (?, ?)
|
|
263
|
+
ON CONFLICT(file_id) DO UPDATE SET parser_state = excluded.parser_state`),
|
|
264
|
+
backfillReqModel: db.prepare("UPDATE requests SET model = ?, family = ? WHERE file_id = ? AND model = 'unknown'"),
|
|
265
|
+
backfillCallModel: db.prepare("UPDATE tool_calls SET model = ? WHERE file_id = ? AND model IS NULL"),
|
|
266
|
+
backfillReqEffort: db.prepare("UPDATE requests SET effort = ? WHERE file_id = ? AND effort IS NULL"),
|
|
250
267
|
};
|
|
251
268
|
const stateByFile = new Map();
|
|
252
269
|
|
|
@@ -261,17 +278,25 @@ export function createIngester(db, timeZone) {
|
|
|
261
278
|
let st = stateByFile.get(file.id);
|
|
262
279
|
if (!st) {
|
|
263
280
|
const prevStats = file.lines > 0 ? q.getStats.get(file.id) : null;
|
|
281
|
+
const ps = parseParserState(prevStats?.parser_state);
|
|
264
282
|
st = {
|
|
265
283
|
launchCwd: file.cwd ?? null,
|
|
266
|
-
cwd: file.cwd ?? null,
|
|
267
|
-
model:
|
|
284
|
+
cwd: str(ps?.cwd) ?? file.cwd ?? null,
|
|
285
|
+
model: str(ps?.model) ?? null,
|
|
286
|
+
effort: str(ps?.effort) ?? null,
|
|
287
|
+
sawTokenRec: Boolean(ps?.sawTokenRec),
|
|
288
|
+
lastTotal: str(ps?.lastTotal) ?? null,
|
|
289
|
+
lastCompactionLine: typeof ps?.lastCompactionLine === "number" ? ps.lastCompactionLine : -999,
|
|
268
290
|
callStart: new Map(), callSkills: new Map(),
|
|
269
291
|
turnStartMs: null, turnToolMs: 0, openApiMs: 0, lastWaitFromMs: null,
|
|
270
292
|
completedApiMs: prevStats?.api_ms ?? 0, toolMs: prevStats?.tool_ms ?? 0,
|
|
271
293
|
baseAdded: prevStats?.lines_added ?? 0, baseRemoved: prevStats?.lines_removed ?? 0,
|
|
272
|
-
sawFileChange:
|
|
294
|
+
sawFileChange: Boolean(ps?.sawFileChange),
|
|
295
|
+
fcAdded: 0, fcRemoved: 0, patchAdded: 0, patchRemoved: 0,
|
|
273
296
|
paths: createPathTracker(prevStats?.target_paths ?? null),
|
|
274
|
-
|
|
297
|
+
hadUnknownModel: Boolean(ps?.hadUnknownModel),
|
|
298
|
+
hadNullEffort: Boolean(ps?.hadNullEffort),
|
|
299
|
+
statsDirty: false, pathsDirty: false, stateDirty: false,
|
|
275
300
|
};
|
|
276
301
|
stateByFile.set(file.id, st);
|
|
277
302
|
}
|
|
@@ -286,6 +311,34 @@ export function createIngester(db, timeZone) {
|
|
|
286
311
|
let cwd = p.cwd ?? null;
|
|
287
312
|
let added = 0;
|
|
288
313
|
|
|
314
|
+
const setModel = (raw) => {
|
|
315
|
+
const next = modelOf(raw);
|
|
316
|
+
if (!next) return;
|
|
317
|
+
if (!st.model && st.hadUnknownModel) {
|
|
318
|
+
q.backfillReqModel.run(next, familyOf(next), file.id);
|
|
319
|
+
q.backfillCallModel.run(next, file.id);
|
|
320
|
+
st.hadUnknownModel = false;
|
|
321
|
+
st.stateDirty = true;
|
|
322
|
+
}
|
|
323
|
+
if (st.model !== next) {
|
|
324
|
+
st.model = next;
|
|
325
|
+
st.stateDirty = true;
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
const setEffort = (raw) => {
|
|
329
|
+
const next = str(raw);
|
|
330
|
+
if (!next) return;
|
|
331
|
+
if (!st.effort && st.hadNullEffort) {
|
|
332
|
+
q.backfillReqEffort.run(next, file.id);
|
|
333
|
+
st.hadNullEffort = false;
|
|
334
|
+
st.stateDirty = true;
|
|
335
|
+
}
|
|
336
|
+
if (st.effort !== next) {
|
|
337
|
+
st.effort = next;
|
|
338
|
+
st.stateDirty = true;
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
|
|
289
342
|
const consumeOpenWait = () => {
|
|
290
343
|
if (tsMs !== null && st.lastWaitFromMs !== null) {
|
|
291
344
|
const dt = tsMs - st.lastWaitFromMs;
|
|
@@ -310,6 +363,14 @@ export function createIngester(db, timeZone) {
|
|
|
310
363
|
const output = u.output_tokens ?? 0;
|
|
311
364
|
const thinking = u.reasoning_output_tokens ?? 0;
|
|
312
365
|
if (!input && !output && !cacheRead && !cacheWrite) return false;
|
|
366
|
+
if (!st.model && !st.hadUnknownModel) {
|
|
367
|
+
st.hadUnknownModel = true;
|
|
368
|
+
st.stateDirty = true;
|
|
369
|
+
}
|
|
370
|
+
if (!st.effort && !st.hadNullEffort) {
|
|
371
|
+
st.hadNullEffort = true;
|
|
372
|
+
st.stateDirty = true;
|
|
373
|
+
}
|
|
313
374
|
const model = st.model ?? "unknown";
|
|
314
375
|
const { day, hour } = zone(ts);
|
|
315
376
|
q.record.run(`codex:${ownId}:${line}`, file.id, line, rec.type, ts);
|
|
@@ -321,40 +382,52 @@ export function createIngester(db, timeZone) {
|
|
|
321
382
|
if (rec.type === "session_meta") {
|
|
322
383
|
if (p.cwd) {
|
|
323
384
|
st.launchCwd ??= p.cwd;
|
|
324
|
-
st.cwd
|
|
385
|
+
if (st.cwd !== p.cwd) {
|
|
386
|
+
st.cwd = p.cwd;
|
|
387
|
+
st.stateDirty = true;
|
|
388
|
+
}
|
|
325
389
|
}
|
|
326
390
|
const subType = subagentTypeOf(p.source);
|
|
327
391
|
const metaSub = p.parent_thread_id || subType ? (subType ?? "subagent") : null;
|
|
328
392
|
const repoUrl = p.git?.repository_url ?? null;
|
|
329
393
|
if (metaSub || repoUrl) q.fileMeta.run(file.id, p.parent_thread_id ?? null, metaSub, null, repoUrl);
|
|
330
|
-
|
|
394
|
+
setModel(p.model);
|
|
331
395
|
} else if (rec.type === "turn_context") {
|
|
332
396
|
if (p.cwd) {
|
|
333
397
|
st.launchCwd ??= p.cwd;
|
|
334
|
-
st.cwd
|
|
398
|
+
if (st.cwd !== p.cwd) {
|
|
399
|
+
st.cwd = p.cwd;
|
|
400
|
+
st.stateDirty = true;
|
|
401
|
+
}
|
|
335
402
|
if (p.cwd !== st.launchCwd && st.paths.add(p.cwd, { write: false })) st.pathsDirty = true;
|
|
336
403
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
if (eff) st.effort = eff;
|
|
404
|
+
setModel(p.model ?? p.collaboration_mode?.settings?.model);
|
|
405
|
+
setEffort(p.effort ?? p.collaboration_mode?.settings?.reasoning_effort);
|
|
340
406
|
} else if (rec.type === "world_state") {
|
|
341
|
-
|
|
342
|
-
|
|
407
|
+
setModel(modelOf(p.state?.model) ?? modelOf(p.state?.collaboration_mode?.model) ?? modelOf(p.state?.collaboration_mode?.settings?.model));
|
|
408
|
+
setEffort(p.state?.effort ?? p.state?.reasoning_effort ?? p.state?.collaboration_mode?.settings?.reasoning_effort);
|
|
343
409
|
} else if (rec.type === "token_usage_record") {
|
|
344
410
|
consumeOpenWait();
|
|
345
|
-
st.sawTokenRec
|
|
411
|
+
if (!st.sawTokenRec) {
|
|
412
|
+
st.sawTokenRec = true;
|
|
413
|
+
st.stateDirty = true;
|
|
414
|
+
}
|
|
346
415
|
const msgId = `codex:${p.response_id || `${ownId}:${line}`}`;
|
|
347
416
|
if (recordUsage(msgId, p.usage)) added = 1;
|
|
348
417
|
} else if (rec.type === "compacted") {
|
|
418
|
+
if (!st.model) setModel(p.resume_metadata?.previous_turn_settings?.model);
|
|
419
|
+
if (!st.effort) setEffort(p.resume_metadata?.previous_turn_settings?.reasoning_effort ?? p.resume_metadata?.previous_turn_settings?.effort);
|
|
349
420
|
if (line - st.lastCompactionLine > 5) {
|
|
350
421
|
st.lastCompactionLine = line;
|
|
422
|
+
st.stateDirty = true;
|
|
351
423
|
q.record.run(`codex:${ownId}:${line}`, file.id, line, rec.type, ts);
|
|
352
424
|
q.compaction.run(`codex:${ownId}:${line}`, file.id, line, session, agent, ts, "auto", null, null, null);
|
|
353
425
|
added = 1;
|
|
354
426
|
}
|
|
355
427
|
} else if (rec.type === "response_item") {
|
|
356
|
-
if (p.type === "configuration_update"
|
|
357
|
-
|
|
428
|
+
if (p.type === "configuration_update") {
|
|
429
|
+
setModel(p.model);
|
|
430
|
+
setEffort(p.reasoning?.effort ?? p.effort);
|
|
358
431
|
} else if (p.type === "message" && p.role === "user") {
|
|
359
432
|
const msg = userMessageText(p.content);
|
|
360
433
|
if (msg) {
|
|
@@ -373,6 +446,10 @@ export function createIngester(db, timeZone) {
|
|
|
373
446
|
consumeOpenWait();
|
|
374
447
|
} else if (p.type === "function_call" || p.type === "custom_tool_call") {
|
|
375
448
|
consumeOpenWait();
|
|
449
|
+
if (!st.model && !st.hadUnknownModel) {
|
|
450
|
+
st.hadUnknownModel = true;
|
|
451
|
+
st.stateDirty = true;
|
|
452
|
+
}
|
|
376
453
|
q.record.run(`codex:${ownId}:${line}`, file.id, line, p.type, ts);
|
|
377
454
|
q.call.run(`codex:${p.call_id || `${ownId}:${line}`}`, file.id, line, session, agent, ts, p.name ?? "unknown", st.model ?? null);
|
|
378
455
|
if (tsMs !== null && p.call_id) st.callStart.set(p.call_id, tsMs);
|
|
@@ -434,13 +511,18 @@ export function createIngester(db, timeZone) {
|
|
|
434
511
|
} else if (p.type === "compaction") {
|
|
435
512
|
if (line - st.lastCompactionLine > 5) {
|
|
436
513
|
st.lastCompactionLine = line;
|
|
514
|
+
st.stateDirty = true;
|
|
437
515
|
q.record.run(`codex:${ownId}:${line}`, file.id, line, p.type, ts);
|
|
438
516
|
q.compaction.run(`codex:${ownId}:${line}`, file.id, line, session, agent, ts, "auto", null, null, null);
|
|
439
517
|
added = 1;
|
|
440
518
|
}
|
|
441
519
|
}
|
|
442
520
|
} else if (rec.type === "event_msg") {
|
|
443
|
-
if (p.type === "
|
|
521
|
+
if (p.type === "thread_settings_applied") {
|
|
522
|
+
const tsSettings = p.thread_settings;
|
|
523
|
+
setModel(tsSettings?.model ?? tsSettings?.collaboration_mode?.settings?.model);
|
|
524
|
+
setEffort(tsSettings?.reasoning_effort ?? tsSettings?.effort ?? tsSettings?.collaboration_mode?.settings?.reasoning_effort);
|
|
525
|
+
} else if (p.type === "task_started" || p.type === "turn_started") {
|
|
444
526
|
if (tsMs !== null) {
|
|
445
527
|
st.turnStartMs = tsMs;
|
|
446
528
|
st.turnToolMs = 0;
|
|
@@ -486,7 +568,10 @@ export function createIngester(db, timeZone) {
|
|
|
486
568
|
st.fcRemoved += d.removed;
|
|
487
569
|
}
|
|
488
570
|
}
|
|
489
|
-
st.sawFileChange
|
|
571
|
+
if (!st.sawFileChange) {
|
|
572
|
+
st.sawFileChange = true;
|
|
573
|
+
st.stateDirty = true;
|
|
574
|
+
}
|
|
490
575
|
st.statsDirty = true;
|
|
491
576
|
}
|
|
492
577
|
} else if (p.type === "token_count" && !st.sawTokenRec && p.info?.last_token_usage) {
|
|
@@ -494,7 +579,10 @@ export function createIngester(db, timeZone) {
|
|
|
494
579
|
const tot = p.info.total_token_usage;
|
|
495
580
|
const totKey = tot ? `${tot.total_tokens}|${tot.input_tokens}|${tot.output_tokens}|${tot.cached_input_tokens}` : null;
|
|
496
581
|
if (!totKey || totKey !== st.lastTotal) {
|
|
497
|
-
st.lastTotal
|
|
582
|
+
if (st.lastTotal !== totKey) {
|
|
583
|
+
st.lastTotal = totKey;
|
|
584
|
+
st.stateDirty = true;
|
|
585
|
+
}
|
|
498
586
|
if (recordUsage(`codex:${ownId}:${line}`, p.info.last_token_usage)) added = 1;
|
|
499
587
|
}
|
|
500
588
|
}
|
|
@@ -519,6 +607,20 @@ export function createIngester(db, timeZone) {
|
|
|
519
607
|
const json = st.paths.toJSON();
|
|
520
608
|
if (json) q.upsertTargetPaths.run(fileId, json);
|
|
521
609
|
}
|
|
610
|
+
if (st.stateDirty) {
|
|
611
|
+
st.stateDirty = false;
|
|
612
|
+
q.upsertParserState.run(fileId, JSON.stringify({
|
|
613
|
+
cwd: st.cwd,
|
|
614
|
+
model: st.model,
|
|
615
|
+
effort: st.effort,
|
|
616
|
+
sawTokenRec: st.sawTokenRec,
|
|
617
|
+
lastTotal: st.lastTotal,
|
|
618
|
+
lastCompactionLine: st.lastCompactionLine,
|
|
619
|
+
sawFileChange: st.sawFileChange,
|
|
620
|
+
hadUnknownModel: st.hadUnknownModel,
|
|
621
|
+
hadNullEffort: st.hadNullEffort,
|
|
622
|
+
}));
|
|
623
|
+
}
|
|
522
624
|
};
|
|
523
625
|
ingestLine.reset = (fileId) => { stateByFile.delete(fileId); };
|
|
524
626
|
return ingestLine;
|
package/src/serve.mjs
CHANGED
|
@@ -23,18 +23,28 @@ const TEXT = { "content-type": "text/plain; charset=utf-8" };
|
|
|
23
23
|
export function serve(config, { port, onScan = () => {}, dist = DIST, routes }) {
|
|
24
24
|
const api = createApi(config, { onScan, routes });
|
|
25
25
|
const server = createServer(async (req, res) => {
|
|
26
|
-
if (await api(req, res)) return;
|
|
27
|
-
if (req.method !== "GET") return res.writeHead(405, TEXT).end("method not allowed\n");
|
|
28
|
-
const path = normalize(decodeURIComponent(new URL(req.url, "http://localhost").pathname));
|
|
29
|
-
const file = join(dist, path);
|
|
30
|
-
const asset = file.startsWith(dist + sep) && extname(path) ? file : join(dist, "index.html");
|
|
31
26
|
try {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
if (await api(req, res)) return;
|
|
28
|
+
if (req.method !== "GET") return res.writeHead(405, TEXT).end("method not allowed\n");
|
|
29
|
+
let path;
|
|
30
|
+
try {
|
|
31
|
+
path = normalize(decodeURIComponent(new URL(req.url, "http://localhost").pathname));
|
|
32
|
+
} catch {
|
|
33
|
+
return res.writeHead(400, TEXT).end("bad request\n");
|
|
34
|
+
}
|
|
35
|
+
const file = join(dist, path);
|
|
36
|
+
const asset = file.startsWith(dist + sep) && extname(path) ? file : join(dist, "index.html");
|
|
37
|
+
try {
|
|
38
|
+
const body = await readFile(asset);
|
|
39
|
+
const cacheControl = asset.startsWith(join(dist, "assets") + sep) ? "max-age=31536000, immutable" : "no-store";
|
|
40
|
+
res.writeHead(200, { "content-type": TYPES[extname(asset)] ?? "application/octet-stream", "cache-control": cacheControl }).end(body);
|
|
41
|
+
} catch {
|
|
42
|
+
if (asset.endsWith("index.html")) res.writeHead(503, TEXT).end("the dashboard is not built: run npm run build, or npm run dev\n");
|
|
43
|
+
else res.writeHead(404, TEXT).end("not found\n");
|
|
44
|
+
}
|
|
35
45
|
} catch {
|
|
36
|
-
if (
|
|
37
|
-
else res.
|
|
46
|
+
if (!res.headersSent) res.writeHead(500, TEXT).end("internal server error\n");
|
|
47
|
+
else if (!res.writableEnded) res.end();
|
|
38
48
|
}
|
|
39
49
|
});
|
|
40
50
|
return new Promise((resolve, reject) => {
|