tumwater 0.4.0 → 0.4.2
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 +4 -6
- package/dist/build-info.json +2 -2
- package/dist/src/agent/agent-backend.js +5 -2
- package/dist/src/agent/backend-traits.js +21 -0
- package/dist/src/agent/claude/claude-backend.js +1 -1
- package/dist/src/agent/claude/claude-stream.js +181 -182
- package/dist/src/agent/claude/{write-guard-hook.js → claude-write-guard-hook.js} +1 -1
- package/dist/src/agent/claude/claude-write-guard.js +5 -4
- package/dist/src/agent/codex/codex-backend.js +1 -1
- package/dist/src/agent/codex/codex-rollout.js +48 -45
- package/dist/src/agent/codex/codex-stream.js +269 -215
- package/dist/src/agent/codex/{write-guard-hook.js → codex-write-guard-hook.js} +2 -1
- package/dist/src/agent/codex/codex-write-guard.js +3 -3
- package/dist/src/agent/image-input.js +18 -87
- package/dist/src/agent/notes-shim.js +2 -2
- package/dist/src/agent/opencode/opencode-backend.js +2 -2
- package/dist/src/agent/opencode/opencode-catalog.js +2 -2
- package/dist/src/agent/opencode/opencode-config.js +2 -2
- package/dist/src/agent/opencode/opencode-stream.js +101 -92
- package/dist/src/agent/run-agent.js +76 -382
- package/dist/src/agent/run-settle.js +25 -15
- package/dist/src/agent/run-spawn.js +226 -0
- package/dist/src/agent/run-stream.js +185 -0
- package/dist/src/agent/session-ledger.js +16 -0
- package/dist/src/agent/write-guard.js +5 -3
- package/dist/src/backlog/backlog-archive.js +86 -170
- package/dist/src/backlog/backlog-cli-view.js +89 -70
- package/dist/src/backlog/backlog-eligibility.js +51 -59
- package/dist/src/backlog/backlog-file-bugs.js +133 -0
- package/dist/src/backlog/backlog-index-data.js +159 -0
- package/dist/src/backlog/backlog-index.js +7 -5
- package/dist/src/backlog/backlog-md.js +39 -28
- package/dist/src/backlog/backlog-release.js +21 -36
- package/dist/src/backlog/backlog-render.js +1 -1
- package/dist/src/backlog/backlog-structure.js +14 -145
- package/dist/src/backlog/backlog-write.js +31 -18
- package/dist/src/backlog/backlog.js +14 -4
- package/dist/src/backlog/question-answer.js +33 -15
- package/dist/src/baseline/main-baseline.js +71 -26
- package/dist/src/baseline/main-guardrails.js +76 -15
- package/dist/src/baseline/main-red.js +45 -94
- package/dist/src/baseline/main-watch.js +9 -3
- package/dist/src/brief/brief.js +40 -0
- package/dist/src/budget/budget-fallback-view.js +50 -8
- package/dist/src/budget/budget-wiring.js +15 -11
- package/dist/src/budget/budget.js +3 -2
- package/dist/src/build/build-check-events.js +4 -2
- package/dist/src/build/build-check-report.js +2 -1
- package/dist/src/build/build-check-scoped.js +70 -41
- package/dist/src/change/change-data.js +4 -2
- package/dist/src/cli/cli-args.js +9 -0
- package/dist/src/cli/cli-command-args.js +199 -98
- package/dist/src/cli/cli-flag-specs.js +6 -4
- package/dist/src/cli/cli-marker-commands.js +2 -2
- package/dist/src/cli/cli-query-commands.js +41 -6
- package/dist/src/cli/cli-review-commands.js +2 -1
- package/dist/src/cli/cli-role-command.js +46 -92
- package/dist/src/cli/cli-start.js +123 -47
- package/dist/src/cli/follow-view.js +3 -1
- package/dist/src/cli/help.js +19 -12
- package/dist/src/cli/log-commands.js +128 -107
- package/dist/src/cli/question-commands.js +82 -63
- package/dist/src/cli.js +396 -343
- package/dist/src/collections.js +46 -9
- package/dist/src/config/config-fallbacks.js +0 -4
- package/dist/src/config/config-live.js +179 -147
- package/dist/src/config/config-request.js +176 -51
- package/dist/src/config/config-validation-roles.js +271 -0
- package/dist/src/config/config-validation.js +10 -205
- package/dist/src/config/config-views.js +2 -7
- package/dist/src/config/config-write.js +205 -175
- package/dist/src/config/config.js +2 -1
- package/dist/src/doctor/doctor-backlog-bugs.js +24 -122
- package/dist/src/doctor/doctor-backlog-plans.js +24 -25
- package/dist/src/doctor/doctor-backlog.js +34 -42
- package/dist/src/doctor/doctor-check-names.js +4 -2
- package/dist/src/doctor/doctor-checks.js +16 -4
- package/dist/src/doctor/doctor-claude-checks.js +2 -2
- package/dist/src/doctor/doctor-codex-checks.js +9 -20
- package/dist/src/doctor/doctor-contention-checks.js +52 -19
- package/dist/src/doctor/doctor-holds.js +22 -20
- package/dist/src/doctor/doctor-model-checks.js +8 -184
- package/dist/src/doctor/doctor-notify.js +2 -5
- package/dist/src/doctor/doctor-opencode-checks.js +90 -41
- package/dist/src/doctor/doctor-principles.js +26 -0
- package/dist/src/doctor/doctor-project-checks.js +69 -19
- package/dist/src/doctor/doctor-role-notes.js +33 -0
- package/dist/src/doctor/doctor.js +13 -6
- package/dist/src/doctor/probe.js +1 -1
- package/dist/src/events/event-format.js +307 -162
- package/dist/src/events/event-labels.js +0 -1
- package/dist/src/events/event-legacy.js +1 -1
- package/dist/src/events/event-window.js +1 -1
- package/dist/src/events/events.js +15 -2
- package/dist/src/events/notify.js +1 -1
- package/dist/src/failure/failure-cluster.js +4 -3
- package/dist/src/failure/failure-data.js +126 -94
- package/dist/src/failure/failure-render.js +58 -17
- package/dist/src/failure/failure-state-change.js +308 -27
- package/dist/src/failure/time-spend.js +139 -106
- package/dist/src/files/files.js +7 -0
- package/dist/src/files/json-object.js +15 -2
- package/dist/src/gates/budget-gates.js +90 -68
- package/dist/src/gates/gate-polls.js +92 -61
- package/dist/src/gates/role-cap-gates.js +1 -1
- package/dist/src/gates/startup-gate.js +28 -28
- package/dist/src/gates/streak-gate.js +1 -1
- package/dist/src/git/git.js +1 -1
- package/dist/src/git/slot-salvage.js +9 -9
- package/dist/src/git/slots-state.js +12 -3
- package/dist/src/git/worktree-pool-startup.js +127 -0
- package/dist/src/git/worktree-pool.js +1 -120
- package/dist/src/gui/gui-admin-endpoints.js +3 -4
- package/dist/src/gui/gui-args.js +1 -1
- package/dist/src/gui/gui-backlog-commands.js +20 -11
- package/dist/src/gui/gui-backlog-endpoints.js +2 -8
- package/dist/src/gui/gui-config-commands.js +51 -76
- package/dist/src/gui/gui-endpoint-commands.js +4 -2
- package/dist/src/gui/gui-endpoint-common.js +4 -3
- package/dist/src/gui/gui-history-endpoints.js +36 -27
- package/dist/src/gui/gui-operator-commands.js +43 -17
- package/dist/src/gui/gui-prompt-commands.js +27 -21
- package/dist/src/gui/gui-quarantine-commands.js +30 -0
- package/dist/src/gui/gui-report-endpoints.js +13 -9
- package/dist/src/gui/gui-server.js +5 -3
- package/dist/src/gui/gui-team-commands.js +1 -1
- package/dist/src/history/history-data.js +7 -1
- package/dist/src/history/history-render.js +15 -10
- package/dist/src/history/history.js +103 -68
- package/dist/src/inbox/inbox-submit.js +1 -5
- package/dist/src/inbox/pending-prompt.js +3 -2
- package/dist/src/inbox/prompt-commands.js +194 -161
- package/dist/src/init/init.js +104 -25
- package/dist/src/merge/merge-core.js +1 -1
- package/dist/src/merge/merge-drain.js +1 -1
- package/dist/src/merge/merge-git.js +5 -5
- package/dist/src/merge/{merge-post-review.js → merge-post-review-drain.js} +1 -1
- package/dist/src/merge/merge-queue.js +2 -1
- package/dist/src/merge/merge-to-main.js +1 -1
- package/dist/src/merge/merge-verify.js +3 -2
- package/dist/src/operator/operator-commands.js +84 -52
- package/dist/src/operator/operator-intent.js +26 -3
- package/dist/src/operator/retire.js +2 -1
- package/dist/src/operator/revert.js +18 -12
- package/dist/src/orchestrator/orchestrator-poll.js +2 -2
- package/dist/src/orchestrator/orchestrator.js +1 -1
- package/dist/src/orchestrator/retention.js +6 -5
- package/dist/src/paths.js +10 -10
- package/dist/src/pi/pi-bin.js +2 -2
- package/dist/src/pi/pi-models.js +9 -0
- package/dist/src/pi/pi-stream.js +63 -41
- package/dist/src/pi/pi-watchdogs.js +84 -49
- package/dist/src/pi-extension/context-shake.js +55 -31
- package/dist/src/pi-extension/full-output.js +2 -3
- package/dist/src/process/process.js +24 -1
- package/dist/src/process/run-marker.js +2 -2
- package/dist/src/process/supervisor.js +24 -5
- package/dist/src/prompt/gate-notes.js +41 -16
- package/dist/src/prompt/notes-backlog.js +22 -29
- package/dist/src/prompt/principles.js +11 -0
- package/dist/src/prompt/prompt-followup.js +4 -12
- package/dist/src/prompt/prompt.js +15 -12
- package/dist/src/redeploy/redeploy-probes.js +11 -1
- package/dist/src/redeploy/redeployer.js +54 -7
- package/dist/src/redeploy/self-reload.js +7 -2
- package/dist/src/report/report-data.js +224 -320
- package/dist/src/report/report-fold.js +23 -231
- package/dist/src/report/report-main-red.js +70 -3
- package/dist/src/report/report-render.js +181 -48
- package/dist/src/report/report-since-data.js +218 -0
- package/dist/src/report/report-usage-fold.js +288 -0
- package/dist/src/report/report.js +2 -1
- package/dist/src/review/known-flakes.js +22 -3
- package/dist/src/review/post-merge-review-accept.js +3 -2
- package/dist/src/review/post-merge-review.js +16 -14
- package/dist/src/review/quarantine-render.js +29 -11
- package/dist/src/review/review-precheck.js +2 -1
- package/dist/src/roles/role-catalog.js +30 -29
- package/dist/src/roles/role-guidance.js +26 -43
- package/dist/src/roles/role-render.js +19 -0
- package/dist/src/roles/role-view.js +19 -5
- package/dist/src/roles/roles.js +2 -22
- package/dist/src/run/ci-parity.js +5 -6
- package/dist/src/run/feedback-filings.js +10 -1
- package/dist/src/run/qa-coverage.js +4 -4
- package/dist/src/run/run-apply.js +14 -2
- package/dist/src/run/run-detail-data.js +50 -10
- package/dist/src/run/run-detail-render.js +32 -1
- package/dist/src/run/run-detail.js +44 -22
- package/dist/src/run/run-dismiss.js +43 -0
- package/dist/src/run/run-finalize.js +75 -46
- package/dist/src/run/run-prompt.js +271 -187
- package/dist/src/run/run-resume.js +32 -31
- package/dist/src/run/run-stage.js +116 -64
- package/dist/src/run/run-timing.js +18 -4
- package/dist/src/run/run-verdict.js +119 -83
- package/dist/src/run/stage-backlog-checks.js +4 -31
- package/dist/src/run/stage-check.js +4 -12
- package/dist/src/run/stage-checks-shared.js +15 -0
- package/dist/src/run/stage-name-checks.js +3 -13
- package/dist/src/run/stage-path-checks.js +26 -29
- package/dist/src/runner/leftover.js +13 -4
- package/dist/src/runner/revision.js +2 -2
- package/dist/src/runner/runner-fallback.js +1 -1
- package/dist/src/runner/runner-outcome.js +0 -5
- package/dist/src/runner/runner-pi.js +72 -49
- package/dist/src/runner/runner-run.js +19 -102
- package/dist/src/runner/runner-state-load.js +0 -10
- package/dist/src/runner/runner.js +1 -32
- package/dist/src/scheduling/claims.js +4 -11
- package/dist/src/status/status-data.js +140 -91
- package/dist/src/status/status-polls.js +41 -5
- package/dist/src/status/status-role-notes.js +53 -0
- package/dist/src/status/status-roles.js +10 -37
- package/dist/src/text/datetime.js +8 -1
- package/dist/src/text/format.js +13 -1
- package/dist/src/text/phrases.js +16 -2
- package/dist/src/text/text.js +12 -0
- package/dist/src/ui/alert-feeds.js +115 -0
- package/dist/src/ui/badges.js +3 -4
- package/dist/src/ui/gui/gui-client-boot.js +78 -57
- package/dist/src/ui/gui/gui-client-drawer-config.js +8 -3
- package/dist/src/ui/gui/gui-client-drawer.js +18 -2
- package/dist/src/ui/gui/gui-client-feed.js +3 -8
- package/dist/src/ui/gui/gui-client-history.js +16 -16
- package/dist/src/ui/gui/gui-client-model.js +9 -9
- package/dist/src/ui/gui/gui-client-operator.js +6 -10
- package/dist/src/ui/gui/gui-client-pending.js +4 -4
- package/dist/src/ui/gui/gui-client-report-chart.js +111 -10
- package/dist/src/ui/gui/gui-client-report.js +70 -11
- package/dist/src/ui/gui/gui-client-roles.js +52 -12
- package/dist/src/ui/gui/gui-client-settings.js +31 -26
- package/dist/src/ui/gui/gui-client-team.js +28 -2
- package/dist/src/ui/gui/gui-client.js +33 -4
- package/dist/src/ui/gui/gui-icons.js +7 -1
- package/dist/src/ui/progress-data.js +2 -2
- package/dist/src/ui/run-progress-model.js +2 -2
- package/dist/src/ui/status-model.js +26 -16
- package/dist/src/ui/status-payload.js +149 -326
- package/dist/src/ui/status-render.js +131 -80
- package/dist/src/ui/team-alert-backlog.js +236 -0
- package/dist/src/ui/team-alert-shared.js +92 -0
- package/dist/src/ui/team-alert-status.js +326 -0
- package/dist/src/ui/team-alert-tail.js +238 -0
- package/dist/src/ui/team-alerts.js +16 -984
- package/dist/src/ui/transcript-tail.js +137 -94
- package/dist/src/ui/tui/tui-backlog.js +1 -1
- package/dist/src/ui/tui/tui-editor-answer.js +54 -44
- package/dist/src/ui/tui/tui-editor-attach.js +74 -63
- package/dist/src/ui/tui/tui-editor-backends.js +62 -56
- package/dist/src/ui/tui/tui-editor-brief.js +64 -54
- package/dist/src/ui/tui/tui-editor-budget.js +106 -89
- package/dist/src/ui/tui/tui-editor-config.js +2 -4
- package/dist/src/ui/tui/tui-editor-ctx.js +12 -1
- package/dist/src/ui/tui/tui-editor-entry.js +171 -153
- package/dist/src/ui/tui/tui-editor-instances.js +2 -1
- package/dist/src/ui/tui/tui-editor-instructions.js +50 -107
- package/dist/src/ui/tui/tui-editor-interval.js +39 -112
- package/dist/src/ui/tui/tui-editor-notes.js +28 -84
- package/dist/src/ui/tui/tui-editor-pause.js +210 -183
- package/dist/src/ui/tui/tui-editor-prompt.js +46 -35
- package/dist/src/ui/tui/tui-editor-queued.js +74 -64
- package/dist/src/ui/tui/tui-editor-quiet.js +122 -108
- package/dist/src/ui/tui/tui-editor-release.js +85 -0
- package/dist/src/ui/tui/tui-editor-retire.js +57 -46
- package/dist/src/ui/tui/tui-editor-role-enabled.js +90 -80
- package/dist/src/ui/tui/tui-editor-role-file.js +87 -0
- package/dist/src/ui/tui/tui-editor-role-key.js +50 -42
- package/dist/src/ui/tui/tui-editor-search.js +70 -58
- package/dist/src/ui/tui/tui-editor-session.js +3 -0
- package/dist/src/ui/tui/tui-editors.js +4 -1
- package/dist/src/ui/tui/tui-frame.js +7 -3
- package/dist/src/ui/tui/tui-history.js +12 -10
- package/dist/src/ui/tui/tui-keys.js +6 -1
- package/dist/src/ui/tui/tui-pane-activity.js +62 -50
- package/dist/src/ui/tui/tui-pane-backlog.js +4 -4
- package/dist/src/ui/tui/tui-pane-ctx.js +1 -1
- package/dist/src/ui/tui/tui-pane-health.js +45 -26
- package/dist/src/ui/tui/tui-pane-history.js +296 -264
- package/dist/src/ui/tui/tui-pane-report.js +74 -57
- package/dist/src/ui/tui/tui-pane-session.js +6 -2
- package/dist/src/ui/tui/tui-pane-transcript.js +158 -131
- package/dist/src/ui/tui/tui-pane.js +201 -174
- package/dist/src/ui/tui/tui-panes.js +211 -148
- package/dist/src/ui/tui/tui.js +4 -4
- package/dist/src/verdict/fix-claim.js +18 -6
- package/dist/src/verdict/refusal.js +32 -7
- package/package.json +1 -1
- package/dist/src/doctor/image-probe.js +0 -257
- /package/dist/src/gui/{http-body.js → gui-http-body.js} +0 -0
- /package/dist/src/merge/{backlog-conflicts.js → merge-backlog-conflicts.js} +0 -0
|
@@ -12,11 +12,9 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import fs from "node:fs";
|
|
14
14
|
import path from "node:path";
|
|
15
|
-
import {
|
|
15
|
+
import { walkFiles } from "../../files/files.js";
|
|
16
|
+
import { isJsonObject, nonNegativeNumber, objectOrEmpty, optionalString, parseJsonObject } from "../../files/json-object.js";
|
|
16
17
|
import { windowTypeName } from "./codex-stream.js";
|
|
17
|
-
function str(value) {
|
|
18
|
-
return typeof value === "string" ? value : undefined;
|
|
19
|
-
}
|
|
20
18
|
function finite(value) {
|
|
21
19
|
return nonNegativeNumber(value, undefined);
|
|
22
20
|
}
|
|
@@ -31,15 +29,11 @@ function windowStatus(windowType, rateLimitReachedType, usedPercent) {
|
|
|
31
29
|
return "allowed_warning";
|
|
32
30
|
return "allowed";
|
|
33
31
|
}
|
|
34
|
-
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
|
|
39
|
-
* (finding 4). `requestedModel` is the `-m` tumwater passed; a turn whose `turn_context.model`
|
|
40
|
-
* differs reports the switch. */
|
|
41
|
-
export function rolloutLines(text, opts) {
|
|
42
|
-
const { sinceTurnStart, requestedModel } = opts;
|
|
32
|
+
/** Scan ONE turn's records out of a rollout's text, tracking `task_started` blocks and
|
|
33
|
+
* collecting the read turn's `turn_context.model`, `token_usage_record` usage, `token_count`
|
|
34
|
+
* rate limits and `plan_type`. `rolloutLines` decides emptiness from `sawTurn`/`lastUsage`;
|
|
35
|
+
* this scanner never decides it. */
|
|
36
|
+
function scanTurnRecords(text, sinceTurnStart) {
|
|
43
37
|
let currentTurn;
|
|
44
38
|
let sawTurn = false;
|
|
45
39
|
let lastUsage;
|
|
@@ -56,9 +50,9 @@ export function rolloutLines(text, opts) {
|
|
|
56
50
|
// `task_started`, `task_complete` and `token_count` come wrapped in an `event_msg` whose
|
|
57
51
|
// `payload.type` discriminates; `turn_context` and `token_usage_record` name themselves in
|
|
58
52
|
// the outer `type`. Read either.
|
|
59
|
-
const ptype =
|
|
53
|
+
const ptype = optionalString(parsed.type) === "event_msg" ? optionalString(payload.type) : optionalString(parsed.type);
|
|
60
54
|
if (ptype === "task_started") {
|
|
61
|
-
currentTurn =
|
|
55
|
+
currentTurn = optionalString(payload.turn_id);
|
|
62
56
|
// Each new task_started begins a fresh turn (a resume appends a second run to the same
|
|
63
57
|
// file), so the collectors restart at the block we are reading. With no turn id (the
|
|
64
58
|
// adapter's read) every task_started restarts them and the last block wins; with one,
|
|
@@ -77,7 +71,7 @@ export function rolloutLines(text, opts) {
|
|
|
77
71
|
switch (ptype) {
|
|
78
72
|
case "turn_context":
|
|
79
73
|
if (model === undefined)
|
|
80
|
-
model =
|
|
74
|
+
model = optionalString(payload.model);
|
|
81
75
|
break;
|
|
82
76
|
case "token_usage_record": {
|
|
83
77
|
const turnUsage = objectOrEmpty(payload.turn_token_usage);
|
|
@@ -89,7 +83,7 @@ export function rolloutLines(text, opts) {
|
|
|
89
83
|
case "token_count": {
|
|
90
84
|
const rateLimits = objectOrEmpty(payload.rate_limits);
|
|
91
85
|
lastRateLimits = rateLimits;
|
|
92
|
-
const plan =
|
|
86
|
+
const plan = optionalString(rateLimits.plan_type);
|
|
93
87
|
if (plan !== undefined)
|
|
94
88
|
planType = plan;
|
|
95
89
|
break;
|
|
@@ -98,12 +92,15 @@ export function rolloutLines(text, opts) {
|
|
|
98
92
|
break;
|
|
99
93
|
}
|
|
100
94
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
95
|
+
return { sawTurn, lastUsage, lastRateLimits, model, planType };
|
|
96
|
+
}
|
|
97
|
+
/** Assemble the reading's canonical `run_usage`, `billing` and up-to-two `rate_limit` lines
|
|
98
|
+
* (in that order), plus the `switchedTo` model comparison, from scanned records. */
|
|
99
|
+
function buildRolloutLines(records, requestedModel) {
|
|
100
|
+
// `rolloutLines` guarantees `lastUsage` is a Json object before calling (its presence check
|
|
101
|
+
// stays there, so this builder never reads `sawTurn`); narrow the shared interface here.
|
|
102
|
+
const lastUsage = records.lastUsage;
|
|
103
|
+
const { lastRateLimits, model, planType } = records;
|
|
107
104
|
const lines = [];
|
|
108
105
|
const input = finite(lastUsage.input_tokens) ?? 0;
|
|
109
106
|
const cacheRead = finite(lastUsage.cached_input_tokens) ?? 0;
|
|
@@ -123,7 +120,7 @@ export function rolloutLines(text, opts) {
|
|
|
123
120
|
// rollout has a token_usage_record but no token_count, so it yields run_usage with no
|
|
124
121
|
// rate_limit (finding 23).
|
|
125
122
|
if (lastRateLimits !== undefined) {
|
|
126
|
-
const reached =
|
|
123
|
+
const reached = optionalString(lastRateLimits.rate_limit_reached_type);
|
|
127
124
|
for (const key of ["primary", "secondary"]) {
|
|
128
125
|
const windowRaw = lastRateLimits[key];
|
|
129
126
|
if (!isJsonObject(windowRaw))
|
|
@@ -145,6 +142,24 @@ export function rolloutLines(text, opts) {
|
|
|
145
142
|
const switchedTo = model !== undefined && requestedModel !== undefined && model !== requestedModel ? model : undefined;
|
|
146
143
|
return { lines, ...(switchedTo !== undefined ? { switchedTo } : {}) };
|
|
147
144
|
}
|
|
145
|
+
/** Read the records of ONE turn out of a rollout's text. A rollout is one file per thread that
|
|
146
|
+
* appends a new `task_started` block per run, so the adapter's `afterRun` read (which knows
|
|
147
|
+
* only the thread id that names the file, never a turn id) reads the LAST block — everything
|
|
148
|
+
* after the last `task_started`. `sinceTurnStart` (optional) selects a specific turn's block
|
|
149
|
+
* instead, which pins per-turn isolation: the thread total hides a resume's own figures
|
|
150
|
+
* (finding 4). `requestedModel` is the `-m` tumwater passed; a turn whose `turn_context.model`
|
|
151
|
+
* differs reports the switch. */
|
|
152
|
+
export function rolloutLines(text, opts) {
|
|
153
|
+
const { sinceTurnStart, requestedModel } = opts;
|
|
154
|
+
const records = scanTurnRecords(text, sinceTurnStart);
|
|
155
|
+
// No matching task_started, or the turn's usage record is missing or malformed (a truncated
|
|
156
|
+
// or torn file): there is no reading. (currentTurn will have moved on to a later run's
|
|
157
|
+
// task_started in a resume-shared file; sawTurn — not currentTurn — is the real signal.)
|
|
158
|
+
if (!records.sawTurn || !isJsonObject(records.lastUsage)) {
|
|
159
|
+
return { lines: [] };
|
|
160
|
+
}
|
|
161
|
+
return buildRolloutLines(records, requestedModel);
|
|
162
|
+
}
|
|
148
163
|
/** Locate the rollout file of `$CODEX_HOME` that names the session `id`: the first
|
|
149
164
|
* `sessions/…/rollout-*-<id>.jsonl` under `home`, or null. It takes no start date and does no
|
|
150
165
|
* date math — the id match alone decides (finding 5: Codex's rollout name carries local time,
|
|
@@ -155,25 +170,13 @@ export function findRollout(home, id) {
|
|
|
155
170
|
if (!fs.existsSync(sessionsRoot))
|
|
156
171
|
return null;
|
|
157
172
|
const suffix = `-${id}.jsonl`;
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
for (const entry of entries) {
|
|
169
|
-
const full = path.join(dir, entry.name);
|
|
170
|
-
if (entry.isDirectory()) {
|
|
171
|
-
stack.push(full);
|
|
172
|
-
}
|
|
173
|
-
else if (entry.isFile() && entry.name.startsWith("rollout-") && entry.name.endsWith(suffix)) {
|
|
174
|
-
return full;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
return null;
|
|
173
|
+
let found = null;
|
|
174
|
+
// The walk-and-swallow recursion is files.ts's walkFiles (an unreadable dir is no match);
|
|
175
|
+
// the id match alone decides, so only the one id's rollout can win. The sessions tree is one
|
|
176
|
+
// directory per active day, so walking it whole to the first match stays small.
|
|
177
|
+
walkFiles(sessionsRoot, (file, entry) => {
|
|
178
|
+
if (found === null && entry.name.startsWith("rollout-") && entry.name.endsWith(suffix))
|
|
179
|
+
found = file;
|
|
180
|
+
});
|
|
181
|
+
return found;
|
|
179
182
|
}
|