ccdeck 3.82.2 → 3.82.3
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 +9 -1
- package/dist/web/assets/{BrowserWatchModal-2_oD4OEZ.js → BrowserWatchModal-BmRTh_xT.js} +1 -1
- package/dist/web/assets/{IntegrationModal-C5Hg-4qW.js → IntegrationModal-C_f526aV.js} +1 -1
- package/dist/web/assets/{RadioPanel-D_qTIO0G.js → RadioPanel-D2rkf9cg.js} +1 -1
- package/dist/web/assets/{TrafficRadar-Br6HVrU-.js → TrafficRadar-BOgVBLIN.js} +1 -1
- package/dist/web/assets/{UsageHistoryModal-HQY6FX_t.js → UsageHistoryModal-BJPTFwM9.js} +1 -1
- package/dist/web/assets/{app-BP4tkqfl.js → app-DZdZoqJ6.js} +63 -63
- package/dist/web/assets/{index-BR00GbtO.js → index-B4c5MZCc.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/release-notes.json +24 -1
- package/src/server/account-projects.mjs +42 -14
- package/src/server/boot-lock.mjs +6 -1
- package/src/server/ccusage-runner.mjs +4 -1
- package/src/server/codex-engine-rpc.mjs +1 -0
- package/src/server/exec-children.mjs +21 -6
- package/src/server/exec.mjs +46 -3
- package/src/server/http-io.mjs +3 -19
- package/src/server/integrations/store.mjs +12 -5
- package/src/server/lan-routes.mjs +13 -3
- package/src/server/lifecycle.mjs +13 -5
- package/src/server/metrics-history.mjs +17 -8
- package/src/server/quota-closes.mjs +5 -2
- package/src/server/quota-history.mjs +38 -15
- package/src/server/session-summary.mjs +34 -10
- package/src/server/swap-log.mjs +9 -4
- package/src/server/thermal-metrics.mjs +31 -3
- package/src/server/tool-audit.mjs +24 -12
- package/src/server/tui-machine.mjs +2 -2
|
@@ -41,6 +41,8 @@ export const WAITING_KEEPERS = new Set([
|
|
|
41
41
|
* never the session's own traffic — the reducer's early returns, which stamp
|
|
42
42
|
* no provider and prove nothing about whether the session is alive. */
|
|
43
43
|
const SCANS = new Set([...WAITING_KEEPERS].filter(n => n !== "Notification"));
|
|
44
|
+
// Same session budget as parked-enrichment.ts; scans never grow a second ring.
|
|
45
|
+
const PENDING_ENRICHMENT_MAX = 256;
|
|
44
46
|
|
|
45
47
|
/** Two copies of one event inside this are the wire talking twice —
|
|
46
48
|
* HOOK_REDELIVERY_WINDOW_MS and PROMPT_REDELIVERY_WINDOW_MS in
|
|
@@ -85,6 +87,21 @@ function blankSession(id, at) {
|
|
|
85
87
|
};
|
|
86
88
|
}
|
|
87
89
|
|
|
90
|
+
function enrichSummary(s, p, name) {
|
|
91
|
+
if (!s.cwd && typeof p.cwd === "string" && p.cwd) s.cwd = p.cwd;
|
|
92
|
+
if (typeof p.model === "string" && p.model && !subagentKeyOf(p)) s.model = p.model;
|
|
93
|
+
if (name === "SessionNamed") s.name = p.sessionTitle ?? p.sessionName ?? s.name;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Scanned facts can wait for a session, but cannot give it a provider, a
|
|
97
|
+
* lifecycle or a start time. Only traffic or active recovery establishes it. */
|
|
98
|
+
function establishSession(sessions, pending, id, at) {
|
|
99
|
+
const s = Object.assign(blankSession(id, at), pending.get(id));
|
|
100
|
+
pending.delete(id);
|
|
101
|
+
sessions.set(id, s);
|
|
102
|
+
return s;
|
|
103
|
+
}
|
|
104
|
+
|
|
88
105
|
/** A prompt, filed in time order unless it is a copy of one already filed —
|
|
89
106
|
* recordPrompt in redelivery.ts. Only the newest is ever read, as evidence. */
|
|
90
107
|
function recordPrompt(s, at, text) {
|
|
@@ -99,7 +116,7 @@ function recordPrompt(s, at, text) {
|
|
|
99
116
|
}
|
|
100
117
|
|
|
101
118
|
/**
|
|
102
|
-
* `Stop` or `SessionEnd`: the root's turn is over — applyTurnEnd in
|
|
119
|
+
* `Stop`, `StopFailure` or `SessionEnd`: the root's turn is over — applyTurnEnd in
|
|
103
120
|
* session-lifecycle.ts, the parts of it a row can show.
|
|
104
121
|
*
|
|
105
122
|
* Refused whole when it is out of order (a boundary older than the prompt that
|
|
@@ -130,7 +147,7 @@ function endTurn(s, name, at) {
|
|
|
130
147
|
* session's prompt back up, and the scan arrives every second and a half),
|
|
131
148
|
* and a snapshot older than the session's own newest event says nothing.
|
|
132
149
|
*/
|
|
133
|
-
function recover(sessions, p, at) {
|
|
150
|
+
function recover(sessions, pending, p, at) {
|
|
134
151
|
const id = p.session_id;
|
|
135
152
|
if ((p.provider !== "codex" && p.provider !== "claude") || typeof id !== "string" || !id) return;
|
|
136
153
|
const s = sessions.get(id);
|
|
@@ -140,8 +157,7 @@ function recover(sessions, p, at) {
|
|
|
140
157
|
if (s) endTurn(s, p.recovery_session_closed === true ? "SessionEnd" : "Stop", at);
|
|
141
158
|
return;
|
|
142
159
|
}
|
|
143
|
-
const r = s ??
|
|
144
|
-
sessions.set(id, r);
|
|
160
|
+
const r = s ?? establishSession(sessions, pending, id, at);
|
|
145
161
|
r.recoveryLiveAt ??= s?.lastEventAt ?? 0;
|
|
146
162
|
r.provider = p.provider;
|
|
147
163
|
r.closed = false;
|
|
@@ -168,18 +184,27 @@ function recover(sessions, p, at) {
|
|
|
168
184
|
*/
|
|
169
185
|
export function summarizeSessions(envelopes, { now = Date.now(), staleMs = STALE_SESSION_MS } = {}) {
|
|
170
186
|
let sessions = new Map();
|
|
187
|
+
const pending = new Map();
|
|
171
188
|
for (const env of Array.isArray(envelopes) ? envelopes : []) {
|
|
172
189
|
const p = env?.payload;
|
|
173
190
|
if (!p || typeof p !== "object") continue;
|
|
174
191
|
const name = p.hook_event_name ?? "Unknown";
|
|
175
192
|
// POST /api/clear wipes the canvas with this; it wipes the list too.
|
|
176
|
-
if (name === "__clear") { sessions = new Map(); continue; }
|
|
193
|
+
if (name === "__clear") { sessions = new Map(); pending.clear(); continue; }
|
|
177
194
|
const at = Number(env.receivedAt) || now;
|
|
178
|
-
if (name === "ClaudeSessionRecovered" || name === "CodexSessionRecovered") { recover(sessions, p, at); continue; }
|
|
195
|
+
if (name === "ClaudeSessionRecovered" || name === "CodexSessionRecovered") { recover(sessions, pending, p, at); continue; }
|
|
179
196
|
const id = typeof p.session_id === "string" && p.session_id ? p.session_id : null;
|
|
180
197
|
if (!id) continue;
|
|
181
198
|
let s = sessions.get(id);
|
|
182
|
-
if (!s
|
|
199
|
+
if (!s && SCANS.has(name)) {
|
|
200
|
+
const facts = pending.get(id) ?? { cwd: null, model: null, name: null };
|
|
201
|
+
enrichSummary(facts, p, name);
|
|
202
|
+
pending.delete(id);
|
|
203
|
+
pending.set(id, facts);
|
|
204
|
+
if (pending.size > PENDING_ENRICHMENT_MAX) pending.delete(pending.keys().next().value);
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
if (!s) s = establishSession(sessions, pending, id, at);
|
|
183
208
|
// A Codex child thread named by its parent: a session of its own, and
|
|
184
209
|
// nothing the human did — linkCodexThread, which returns before any block
|
|
185
210
|
// is read.
|
|
@@ -194,9 +219,7 @@ export function summarizeSessions(envelopes, { now = Date.now(), staleMs = STALE
|
|
|
194
219
|
s.provider ??= p.provider === "codex" ? "codex" : "claude";
|
|
195
220
|
if (at >= (s.recoveryLiveAt ?? 0)) s.recoveryLiveAt = at;
|
|
196
221
|
}
|
|
197
|
-
|
|
198
|
-
if (typeof p.model === "string" && p.model && !subagentKeyOf(p)) s.model = p.model;
|
|
199
|
-
if (name === "SessionNamed") s.name = p.sessionTitle ?? p.sessionName ?? s.name;
|
|
222
|
+
enrichSummary(s, p, name);
|
|
200
223
|
|
|
201
224
|
switch (name) {
|
|
202
225
|
case "SessionStart":
|
|
@@ -213,6 +236,7 @@ export function summarizeSessions(envelopes, { now = Date.now(), staleMs = STALE
|
|
|
213
236
|
break;
|
|
214
237
|
}
|
|
215
238
|
case "Stop":
|
|
239
|
+
case "StopFailure":
|
|
216
240
|
case "SessionEnd":
|
|
217
241
|
endTurn(s, name, at);
|
|
218
242
|
break;
|
package/src/server/swap-log.mjs
CHANGED
|
@@ -65,9 +65,14 @@ export async function currentActiveSlot(root = backupRoot()) {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
/** Parse the log into swap entries sorted oldest-first. A truncated or garbage
|
|
68
|
-
* last line (a crash mid-append) is skipped, never fatal.
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
* last line (a crash mid-append) is skipped, never fatal. Strict readers make
|
|
69
|
+
* irreversible attribution decisions: only ENOENT means an empty timeline;
|
|
70
|
+
* other read failures must defer their work. Display callers stay best-effort. */
|
|
71
|
+
export async function readSwapLog(path = swapLogPath(), { strict = false } = {}) {
|
|
72
|
+
const text = await readFile(path, "utf8").catch(error => {
|
|
73
|
+
if (strict && error?.code !== "ENOENT") throw error;
|
|
74
|
+
return "";
|
|
75
|
+
});
|
|
71
76
|
const out = [];
|
|
72
77
|
for (const line of text.split("\n")) {
|
|
73
78
|
if (!line) continue;
|
|
@@ -142,7 +147,7 @@ export async function seedActive({ now = Date.now, root, path, projectsRoot } =
|
|
|
142
147
|
if (!slot) return null;
|
|
143
148
|
const id = await identityForSlot(slot, root ?? backupRoot());
|
|
144
149
|
if (!id) return null;
|
|
145
|
-
const entries = await readSwapLog(logPath);
|
|
150
|
+
const entries = await readSwapLog(logPath, { strict: true });
|
|
146
151
|
const scope = await swapProjectsRoot(projectsRoot);
|
|
147
152
|
const scoped = entries.filter(e => e.projectsRoot === scope);
|
|
148
153
|
const last = scoped[scoped.length - 1];
|
|
@@ -79,7 +79,14 @@ import { run } from "./metrics-run.mjs";
|
|
|
79
79
|
// for it, and the deck fetches its release binary itself — see
|
|
80
80
|
// macmon.mjs.
|
|
81
81
|
//
|
|
82
|
-
// Windows
|
|
82
|
+
// Windows CPU performance caps come from the invariant CIM class
|
|
83
|
+
// Win32_PerfFormattedData_Counters_ProcessorInformation. Its
|
|
84
|
+
// PercentPerformanceLimit reports guaranteed performance relative
|
|
85
|
+
// to nominal, including power-policy and firmware constraints.
|
|
86
|
+
// It is not a temperature or a complete hardware thermal detector.
|
|
87
|
+
// The source tag keeps the UI from claiming that every cap is heat.
|
|
88
|
+
//
|
|
89
|
+
// Temperatures use `\Thermal Zone Information(*)\High
|
|
83
90
|
// Precision Temperature`, in TENTHS OF A KELVIN, read through
|
|
84
91
|
// Get-Counter.
|
|
85
92
|
//
|
|
@@ -472,6 +479,9 @@ export const WIN_THERMAL_PS = [
|
|
|
472
479
|
+ "| ForEach-Object { @{ i = $_.InstanceName; v = $_.CookedValue } }) } "
|
|
473
480
|
+ "} catch {} }",
|
|
474
481
|
"if (-not $r.perf) { try { $r.acpi = @(Get-CimInstance -Namespace root/wmi -ClassName MSAcpi_ThermalZoneTemperature -EA Stop | ForEach-Object { @{ i = $_.InstanceName; v = $_.CurrentTemperature } }) } catch {} }",
|
|
482
|
+
// CIM names are invariant across display languages. This is a performance
|
|
483
|
+
// ceiling, not proof of heat: Windows also applies policy/firmware limits.
|
|
484
|
+
"try { $r.cpuLimit = @(Get-CimInstance -ClassName Win32_PerfFormattedData_Counters_ProcessorInformation -EA Stop | ForEach-Object { @{ v = $_.PercentPerformanceLimit } }) } catch {}",
|
|
475
485
|
// Depth matters: the default of 2 turns the inner hashtables into the string
|
|
476
486
|
// "System.Collections.Hashtable" and this parser would see nothing at all.
|
|
477
487
|
"$r | ConvertTo-Json -Compress -Depth 4",
|
|
@@ -634,11 +644,12 @@ export async function readWindowsThermal(since = null, deps = {}) {
|
|
|
634
644
|
?? (async () => (await import("./hwmonitor.mjs")).readHwMonitorTemps());
|
|
635
645
|
|
|
636
646
|
const out = await powershell();
|
|
647
|
+
const throttle = throttleFromWindows(out);
|
|
637
648
|
const zones = out ? parseWinThermal(out.trim()) : [];
|
|
638
649
|
const zonesSeen = zonesSeenAfter(zones, since?.zonesSeen);
|
|
639
650
|
const memory = Object.keys(zonesSeen).length ? { zonesSeen } : {};
|
|
640
651
|
const moved = zones.filter(z => zonesSeen[z.label].moved);
|
|
641
|
-
if (moved.length) return { celsius: moved, throttle
|
|
652
|
+
if (moved.length) return { celsius: moved, throttle, ...memory };
|
|
642
653
|
|
|
643
654
|
// Windows had no zone that has moved, which on a modern Intel laptop is
|
|
644
655
|
// every time: the firmware declares no ACPI thermal zone, or declares one
|
|
@@ -651,7 +662,8 @@ export async function readWindowsThermal(since = null, deps = {}) {
|
|
|
651
662
|
const rows = [];
|
|
652
663
|
if (t.cpu != null) rows.push({ label: "CPU", celsius: t.cpu, warnAt: WARN_C, critAt: CRIT_C });
|
|
653
664
|
if (t.gpu != null) rows.push({ label: "GPU", celsius: t.gpu, warnAt: WARN_C, critAt: CRIT_C });
|
|
654
|
-
if (rows.length) return { celsius: rows, throttle
|
|
665
|
+
if (rows.length) return { celsius: rows, throttle, ...memory };
|
|
666
|
+
if (throttle) return { celsius: [], throttle, ...memory };
|
|
655
667
|
|
|
656
668
|
// A zone that has not moved yet is still a zone, so this is an answer with
|
|
657
669
|
// nothing to draw rather than null. Null would let the sampler give up after
|
|
@@ -660,6 +672,22 @@ export async function readWindowsThermal(since = null, deps = {}) {
|
|
|
660
672
|
return zones.length ? { celsius: [], throttle: null, zonesSeen } : null;
|
|
661
673
|
}
|
|
662
674
|
|
|
675
|
+
/** Windows' guaranteed performance relative to nominal performance. Taking
|
|
676
|
+
* the lowest published processor limit keeps a limited core visible instead
|
|
677
|
+
* of averaging it away. Boost/clock frequency is deliberately not consulted.
|
|
678
|
+
* Values above 100 mean no cap below nominal, not negative throttling.
|
|
679
|
+
* Source: Windows Processor Information / % Performance Limit counter help. */
|
|
680
|
+
export function throttleFromWindows(json) {
|
|
681
|
+
let r;
|
|
682
|
+
try { r = typeof json === "string" ? JSON.parse(json) : json; }
|
|
683
|
+
catch { return null; }
|
|
684
|
+
if (!Array.isArray(r?.cpuLimit)) return null;
|
|
685
|
+
const limits = r.cpuLimit.map(x => x?.v)
|
|
686
|
+
.filter(v => typeof v === "number" && Number.isFinite(v) && v >= 0);
|
|
687
|
+
if (!limits.length) return null;
|
|
688
|
+
return { speedLimit: Math.min(100, ...limits), source: "windows-performance" };
|
|
689
|
+
}
|
|
690
|
+
|
|
663
691
|
/**
|
|
664
692
|
* Which Windows zones have been seen to change since the deck started, keyed by
|
|
665
693
|
* the zone's row label: the first value each one read, and whether it has
|
|
@@ -36,18 +36,30 @@ export function createToolAudit({ dir, now = Date.now, runReport = workerReport
|
|
|
36
36
|
// they did: that is what tells a wait for approval from hooks starting the tool.
|
|
37
37
|
const running = new Map();
|
|
38
38
|
const enqueue = fn => { const task = serial.then(fn); serial = task.catch(() => {}); return task; };
|
|
39
|
-
const ready = () =>
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
39
|
+
const ready = () => {
|
|
40
|
+
if (readyPromise) return readyPromise;
|
|
41
|
+
const attempt = (async () => {
|
|
42
|
+
await mkdir(dir, { recursive: true });
|
|
43
|
+
try { meta = JSON.parse(await readFile(join(dir, 'settings.json'), 'utf8')); }
|
|
44
|
+
catch (e) { if (e.code !== 'ENOENT') throw e; }
|
|
45
|
+
if (meta && !validMeta(meta)) throw new Error('Unreadable tool history settings');
|
|
46
|
+
if (!meta) { meta = { v: 1, deviceId: randomUUID(), epoch: randomUUID(), retentionDays: 90, startedAt: now(), skillsSince: now(), turnsSince: now() }; await saveMeta(); }
|
|
47
|
+
// A journal from before skills were counted: its Skill calls never named the skill.
|
|
48
|
+
if (!Number.isFinite(meta.skillsSince)) { meta.skillsSince = now(); await saveMeta(); }
|
|
49
|
+
// Nor did it hold turns, so the split of the time starts here.
|
|
50
|
+
if (!Number.isFinite(meta.turnsSince)) { meta.turnsSince = now(); await saveMeta(); }
|
|
51
|
+
await prune();
|
|
52
|
+
})();
|
|
53
|
+
readyPromise = attempt;
|
|
54
|
+
void attempt.catch(() => {
|
|
55
|
+
if (readyPromise !== attempt) return;
|
|
56
|
+
readyPromise = null;
|
|
57
|
+
// A failed migration or prune may have populated meta already. The
|
|
58
|
+
// retry must read disk again, never reuse that partial initialization.
|
|
59
|
+
meta = undefined;
|
|
60
|
+
});
|
|
61
|
+
return attempt;
|
|
62
|
+
};
|
|
51
63
|
const saveMeta = () => writeFileAtomic(join(dir, 'settings.json'), JSON.stringify(meta));
|
|
52
64
|
const files = async () => (await readdir(dir)).filter(n => /^\d{4}-\d{2}-\d{2}\.jsonl$/.test(n)).sort();
|
|
53
65
|
const prune = async () => {
|
|
@@ -66,8 +66,8 @@ export function readingsOf(snap) {
|
|
|
66
66
|
warnAt: num(r.warnAt), critAt: num(r.critAt),
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
|
-
// Linux
|
|
70
|
-
//
|
|
69
|
+
// Linux says how long the CPU was held back; macOS and Windows report a
|
|
70
|
+
// performance ceiling. One number either way, the deck's own (heldShare in
|
|
71
71
|
// machine-live.ts): the share held back.
|
|
72
72
|
const throttle = snap.thermal?.throttle;
|
|
73
73
|
const speed = num(throttle?.speedLimit);
|