ccdeck 3.82.4 → 4.0.1
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/LICENSING.md +42 -4
- package/README.md +183 -72
- package/THIRD_PARTY_NOTICES.md +243 -17
- package/bin/cli/tui.js +58 -4
- package/bin/deck.js +27 -1
- package/dist/web/assets/AccountBridge-fp-fsMx-.js +1 -0
- package/dist/web/assets/AccountSection-Cu-96Q00.js +1 -0
- package/dist/web/assets/BrowserWatchModal-CvUx07C6.js +1 -0
- package/dist/web/assets/FeedbackConversations-BgVk0nkA.js +1 -0
- package/dist/web/assets/IntegrationModal-CEj5oJg4.js +7 -0
- package/dist/web/assets/IntegrationSkeleton-DD7YiFgd.js +1 -0
- package/dist/web/assets/RadioPanel-BhnzWRCT.js +1 -0
- package/dist/web/assets/StageShell-DmJu3dU1.js +4 -0
- package/dist/web/assets/TrafficRadar-C8-ieIw5.js +8 -0
- package/dist/web/assets/UsageHistoryModal-BThv9Kja.js +1 -0
- package/dist/web/assets/addon-unicode-graphemes-DW3WJwyh.js +18 -0
- package/dist/web/assets/addon-web-links-BWjmmSgS.js +12 -0
- package/dist/web/assets/addon-webgl-CLK4R-_u.js +75 -0
- package/dist/web/assets/app-DtosBis5.css +1 -0
- package/dist/web/assets/app-ZMmmEHxF.js +361 -0
- package/dist/web/assets/{index-B-l-VxLm.js → index-zSxC5ueJ.js} +1 -1
- package/dist/web/assets/inspector-status-pane-BgQG0bQi.js +1 -0
- package/dist/web/assets/screens-DD0uCtat.js +12 -0
- package/dist/web/assets/screens-DUniTTbC.css +1 -0
- package/dist/web/assets/stage-board-J2rKA9Pg.js +2 -0
- package/dist/web/assets/use-account-DvFObI4M.js +1 -0
- package/dist/web/assets/xterm-4jYizCpg.js +27 -0
- package/dist/web/assets/xterm-sheet-6GBZ9nXN.css +32 -0
- package/dist/web/index.html +16 -6
- package/package.json +13 -1
- package/release-notes.json +69 -1
- package/src/server/account-client.mjs +196 -0
- package/src/server/account-connect.mjs +238 -0
- package/src/server/account-flag.mjs +106 -0
- package/src/server/account-projects.mjs +1 -1
- package/src/server/account-service.mjs +532 -0
- package/src/server/account-status.mjs +293 -0
- package/src/server/account-store.mjs +137 -0
- package/src/server/account-sync.mjs +473 -0
- package/src/server/account-token-store.mjs +216 -0
- package/src/server/account-ui-fields.mjs +126 -0
- package/src/server/account-watch.mjs +1 -1
- package/src/server/browser-watch-log.mjs +1 -1
- package/src/server/browser-watch-store.mjs +1 -1
- package/src/server/ccdeck-account-routes.mjs +252 -0
- package/src/server/ccusage-install.mjs +2 -2
- package/src/server/ccusage-registry.mjs +4 -4
- package/src/server/ccusage-session.mjs +11 -0
- package/src/server/claude-accounts.mjs +1 -1
- package/src/server/claude-recovery.mjs +9 -4
- package/src/server/claude-settings-catalog.mjs +6 -6
- package/src/server/claude-settings.mjs +1 -1
- package/src/server/codex-auto.mjs +1 -1
- package/src/server/codex-cost-usage.mjs +7 -2
- package/src/server/codex-live-checkpoint.mjs +24 -9
- package/src/server/codex-live-engine.mjs +14 -4
- package/src/server/codex-live-handoff.mjs +53 -9
- package/src/server/codex-names.mjs +49 -0
- package/src/server/codex-translate.mjs +1 -1
- package/src/server/codex-ultrafast.d.mts +3 -0
- package/src/server/codex-ultrafast.mjs +5 -0
- package/src/server/codex-watch.mjs +25 -0
- package/src/server/command-panel-engine.mjs +300 -0
- package/src/server/command-panel-platform.mjs +99 -0
- package/src/server/cswap-auto-choice.mjs +1 -1
- package/src/server/cswap-auto-loop.mjs +1 -1
- package/src/server/cswap-install.mjs +21 -40
- package/src/server/deck-home.mjs +6 -0
- package/src/server/deck-prefs.mjs +53 -1
- package/src/server/detach.mjs +1 -1
- package/src/server/engine-download.mjs +277 -0
- package/src/server/engine-install.mjs +378 -0
- package/src/server/engine-package.mjs +267 -0
- package/src/server/event-log.mjs +7 -1
- package/src/server/event-pipeline.mjs +29 -1
- package/src/server/ghostty-handoff.mjs +81 -0
- package/src/server/index.mjs +143 -5
- package/src/server/installer.mjs +4 -1
- package/src/server/integrations/jira-write-guard.mjs +14 -208
- package/src/server/integrations/store.mjs +37 -19
- package/src/server/integrations/write-guard.mjs +223 -0
- package/src/server/intel-cpu-temperature.mjs +26 -0
- package/src/server/lifecycle.mjs +69 -6
- package/src/server/log-replay.mjs +4 -0
- package/src/server/login-service.mjs +7 -1
- package/src/server/macmon.mjs +1 -1
- package/src/server/npm-latest.mjs +1 -1
- package/src/server/org-telemetry.mjs +1 -1
- package/src/server/output-watch.mjs +4 -1
- package/src/server/panel-provenance.mjs +390 -0
- package/src/server/pinned-build.mjs +14 -0
- package/src/server/prefs-refusal.mjs +8 -1
- package/src/server/prefs-routes.mjs +60 -11
- package/src/server/pro-engine-client.mjs +339 -0
- package/src/server/pro-engine-install.mjs +294 -0
- package/src/server/pro-engine-terminal.mjs +308 -0
- package/src/server/project-discovery.mjs +139 -0
- package/src/server/provider-session-name.mjs +58 -0
- package/src/server/quota-closes.mjs +1 -1
- package/src/server/quota-history.mjs +1 -1
- package/src/server/reports.mjs +86 -21
- package/src/server/request-gates.mjs +34 -5
- package/src/server/restart-note.mjs +1 -1
- package/src/server/seed-boundary.mjs +489 -0
- package/src/server/session-counts.mjs +244 -0
- package/src/server/session-deck-names.mjs +143 -0
- package/src/server/session-enrichment.mjs +43 -6
- package/src/server/session-name-route.mjs +73 -0
- package/src/server/session-summary.mjs +12 -1
- package/src/server/session-transcript-routes.mjs +167 -0
- package/src/server/swap-log.mjs +1 -1
- package/src/server/system-metrics.mjs +57 -0
- package/src/server/terminal-bridge.mjs +485 -0
- package/src/server/terminal-folder.mjs +61 -0
- package/src/server/terminal-js-routes.mjs +752 -0
- package/src/server/terminal-routes.mjs +553 -0
- package/src/server/terminal-sessions.mjs +759 -0
- package/src/server/terminal-socket.mjs +403 -0
- package/src/server/terminal-target.mjs +928 -0
- package/src/server/thermal-metrics.mjs +13 -9
- package/src/server/tmux-control.mjs +1319 -0
- package/src/server/tmux-download.mjs +220 -0
- package/src/server/tmux.mjs +542 -0
- package/src/server/token-redact.mjs +42 -3
- package/src/server/tool-audit-report.mjs +44 -6
- package/src/server/tool-audit-routes.mjs +12 -1
- package/src/server/tool-audit.mjs +42 -8
- package/src/server/traffic-radar-monitor.mjs +1 -1
- package/src/server/traffic-radar-permission.mjs +1 -1
- package/src/server/transcript-gate.mjs +1 -1
- package/src/server/transcript-scan.mjs +15 -7
- package/src/server/transcript-turns.mjs +154 -0
- package/src/server/tui-network.mjs +1 -0
- package/src/server/tui-view.mjs +28 -0
- package/src/server/utf8-carry.mjs +159 -0
- package/src/server/uv-bootstrap.mjs +2 -2
- package/src/server/windows-acl.mjs +158 -0
- package/src/server/ws-frames.mjs +690 -0
- package/dist/web/assets/BrowserWatchModal-CWVooKxD.js +0 -1
- package/dist/web/assets/IntegrationModal-DLX43RIK.js +0 -7
- package/dist/web/assets/RadioPanel-Cj6PjrvQ.js +0 -1
- package/dist/web/assets/TrafficRadar-Bq1YcuHB.js +0 -8
- package/dist/web/assets/UsageHistoryModal-CMSCca5_.js +0 -1
- package/dist/web/assets/app-BHxsMz3-.js +0 -358
- package/dist/web/assets/app-CbXmr9rC.css +0 -1
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
// Durable per-scope reservations, shared by every provider. Only the small
|
|
2
|
+
// allowlisted record the provider's scope builds is stored.
|
|
3
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
4
|
+
import { chmod, link, mkdir, open, readFile, readdir, unlink } from 'node:fs/promises';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
import { createConnection, createServer } from 'node:net';
|
|
7
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
8
|
+
import { createRequire } from 'node:module';
|
|
9
|
+
import { dirname } from 'node:path';
|
|
10
|
+
import { integrationError } from './errors.mjs';
|
|
11
|
+
import { createTemp, renameWithRetry } from '../atomic-write.mjs';
|
|
12
|
+
|
|
13
|
+
const require = createRequire(import.meta.url);
|
|
14
|
+
let binding;
|
|
15
|
+
function nativeLock() {
|
|
16
|
+
if (!binding) {
|
|
17
|
+
// The exact dependency version pins this N-API layout and ABI. Loading the
|
|
18
|
+
// shipped binding directly avoids its resolver's Node 20-only Array.with.
|
|
19
|
+
// Keep this lazy so unsupported targets can still run the read-only deck.
|
|
20
|
+
const root = dirname(require.resolve('fs-native-extensions/package.json'));
|
|
21
|
+
binding = require(join(root, 'prebuilds', `${process.platform}-${process.arch}`, 'fs-native-extensions.node'));
|
|
22
|
+
}
|
|
23
|
+
return binding;
|
|
24
|
+
}
|
|
25
|
+
const nativeLocks = {
|
|
26
|
+
tryLock(fd) {
|
|
27
|
+
try { nativeLock().tryLock(fd, 0, 0, true); return true; }
|
|
28
|
+
catch (err) { if (err.code === 'EAGAIN') return false; throw err; }
|
|
29
|
+
},
|
|
30
|
+
unlock(fd) { nativeLock().unlock(fd, 0, 0); },
|
|
31
|
+
};
|
|
32
|
+
const active = new Set();
|
|
33
|
+
const listeners = new Map();
|
|
34
|
+
const uuidPattern = /^[0-9a-f-]{36}$/;
|
|
35
|
+
const alive = pid => { try { process.kill(pid, 0); return true; } catch (e) { return e.code !== 'ESRCH'; } };
|
|
36
|
+
|
|
37
|
+
// Ephemeral sockets identify live writers without trusting reusable PIDs.
|
|
38
|
+
// Scope synchronization uses OS file locks below, never a fixed TCP port.
|
|
39
|
+
function listen(port, handler = socket => socket.destroy()) {
|
|
40
|
+
return new Promise((resolve, reject) => {
|
|
41
|
+
const server = createServer(handler);
|
|
42
|
+
server.once('error', reject);
|
|
43
|
+
server.listen({ port, host: '127.0.0.1', exclusive: true }, () => {
|
|
44
|
+
server.removeListener('error', reject);
|
|
45
|
+
resolve(server);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
const close = server => new Promise((resolve, reject) => server.close(err => err ? reject(err) : resolve()));
|
|
50
|
+
async function startMarker(op) {
|
|
51
|
+
const token = randomUUID();
|
|
52
|
+
let server;
|
|
53
|
+
do {
|
|
54
|
+
server = await listen(0, socket => {
|
|
55
|
+
socket.setTimeout(1000, () => socket.destroy());
|
|
56
|
+
socket.end(token);
|
|
57
|
+
});
|
|
58
|
+
} while (!server);
|
|
59
|
+
server.unref();
|
|
60
|
+
listeners.set(op.operationId, server);
|
|
61
|
+
return { port: server.address().port, token };
|
|
62
|
+
}
|
|
63
|
+
async function stopMarker(op) {
|
|
64
|
+
const server = listeners.get(op.operationId);
|
|
65
|
+
if (server) { listeners.delete(op.operationId); await close(server); }
|
|
66
|
+
}
|
|
67
|
+
function markerAlive(marker) {
|
|
68
|
+
return new Promise(resolve => {
|
|
69
|
+
let data = '';
|
|
70
|
+
let settled = false;
|
|
71
|
+
const socket = createConnection({ host: '127.0.0.1', port: marker.port });
|
|
72
|
+
const done = value => { if (!settled) { settled = true; socket.destroy(); resolve(value); } };
|
|
73
|
+
// Ambiguous failures are treated as live; never acknowledge on a timeout.
|
|
74
|
+
socket.setTimeout(1000, () => done(true));
|
|
75
|
+
socket.on('data', chunk => { data += chunk.toString(); if (data.length >= marker.token.length) done(data === marker.token); });
|
|
76
|
+
socket.on('end', () => done(data === marker.token));
|
|
77
|
+
socket.on('error', err => done(err.code !== 'ECONNREFUSED'));
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// The four outcomes a write can report. Failed is what a route says when the
|
|
82
|
+
// provider refused for certain; it never comes from a reservation.
|
|
83
|
+
export const WRITE_OUTCOMES = Object.freeze({ saving: 'saving', saved: 'saved', failed: 'failed', uncertain: 'uncertain' });
|
|
84
|
+
const outcomeOfRead = Object.freeze({ pending: WRITE_OUTCOMES.saving, confirmed: WRITE_OUTCOMES.saved, uncertain: WRITE_OUTCOMES.uncertain });
|
|
85
|
+
export const writeOutcome = record => outcomeOfRead[record?.state] ?? null;
|
|
86
|
+
|
|
87
|
+
// provider.record(input) validates the input and returns the stored record, or
|
|
88
|
+
// throws; provider.key(record) returns the string the scope hash is made from.
|
|
89
|
+
// list() and acknowledge() filter on connectionId, so every record must carry a
|
|
90
|
+
// top-level non-empty string connectionId.
|
|
91
|
+
export function createWriteGuard({ name, dir, locks = nativeLocks, scope: provider }) {
|
|
92
|
+
const scope = record => createHash('sha256').update(provider.key(record)).digest('hex');
|
|
93
|
+
async function prepare() {
|
|
94
|
+
const root = dir();
|
|
95
|
+
await mkdir(root, { recursive: true, mode: 0o700 });
|
|
96
|
+
if (process.platform !== 'win32') await chmod(root, 0o700);
|
|
97
|
+
return root;
|
|
98
|
+
}
|
|
99
|
+
async function syncDir(root) {
|
|
100
|
+
// Windows does not support opening directories for fsync.
|
|
101
|
+
if (process.platform === 'win32') return;
|
|
102
|
+
const h = await open(root, 'r'); try { await h.sync(); } finally { await h.close(); }
|
|
103
|
+
}
|
|
104
|
+
async function read(path) {
|
|
105
|
+
try { return JSON.parse(await readFile(path, 'utf8')); }
|
|
106
|
+
catch (e) { if (e.code === 'ENOENT') return null; throw e; }
|
|
107
|
+
}
|
|
108
|
+
async function running(root, op) {
|
|
109
|
+
if (active.has(op.operationId)) return true;
|
|
110
|
+
const names = await readdir(root);
|
|
111
|
+
const prefix = `running-${op.operationId}-`;
|
|
112
|
+
for (const name of names.filter(name => name.startsWith(prefix))) {
|
|
113
|
+
const marker = await read(join(root, name)).catch(err => {
|
|
114
|
+
// Older releases used empty PID-only marker files. Preserve their
|
|
115
|
+
// conservative behaviour while those processes may still be running.
|
|
116
|
+
if (err instanceof SyntaxError) return null;
|
|
117
|
+
throw err;
|
|
118
|
+
});
|
|
119
|
+
if (marker && Number.isInteger(marker.port) && marker.port > 0 && marker.port <= 65535 && typeof marker.token === 'string' && uuidPattern.test(marker.token)) {
|
|
120
|
+
if (await markerAlive(marker)) return true;
|
|
121
|
+
} else if (alive(Number(name.slice(prefix.length)))) return true;
|
|
122
|
+
}
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
async function state(root, op) { return { ...op, state: await running(root, op) ? 'pending' : op.state === 'confirmed' ? 'confirmed' : 'uncertain' }; }
|
|
126
|
+
async function lock(root, op, fn) {
|
|
127
|
+
// Keep the inode forever: unlinking/replacing a locked file would allow
|
|
128
|
+
// two processes to lock different inodes for the same scope. The kernel
|
|
129
|
+
// releases ownership on descriptor close or process death, not file age.
|
|
130
|
+
const handle = await open(join(root, `lock-${scope(op)}`), 'a+', 0o600);
|
|
131
|
+
let acquired = false;
|
|
132
|
+
try {
|
|
133
|
+
while (!(acquired = locks.tryLock(handle.fd))) await delay(10);
|
|
134
|
+
return await fn();
|
|
135
|
+
} finally {
|
|
136
|
+
try { if (acquired) locks.unlock(handle.fd); }
|
|
137
|
+
finally { await handle.close(); }
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
async begin(input) {
|
|
142
|
+
const op = { ...provider.record(input), operationId: randomUUID(), state: 'pending' };
|
|
143
|
+
if (typeof op.connectionId !== 'string' || !op.connectionId) throw new Error('Invalid guard scope');
|
|
144
|
+
const root = await prepare();
|
|
145
|
+
// Check the actual filesystem and native support before any write.
|
|
146
|
+
try { await lock(root, op, async () => {}); }
|
|
147
|
+
catch { throw integrationError('unavailable', `${name} writes are unavailable because this system cannot safely coordinate them.`); }
|
|
148
|
+
const path = join(root, `${scope(op)}.json`);
|
|
149
|
+
const marker = join(root, `running-${op.operationId}-${process.pid}`);
|
|
150
|
+
const temp = join(root, `tmp-${op.operationId}`);
|
|
151
|
+
let returned = false;
|
|
152
|
+
active.add(op.operationId);
|
|
153
|
+
try {
|
|
154
|
+
const identity = await startMarker(op);
|
|
155
|
+
const markerHandle = await open(marker, 'wx', 0o600);
|
|
156
|
+
try { await markerHandle.writeFile(JSON.stringify(identity)); } finally { await markerHandle.close(); }
|
|
157
|
+
const h = await open(temp, 'wx', 0o600);
|
|
158
|
+
try { await h.writeFile(JSON.stringify(op)); await h.sync(); } finally { await h.close(); }
|
|
159
|
+
try { await link(temp, path); }
|
|
160
|
+
catch (e) {
|
|
161
|
+
if (e.code !== 'EEXIST') throw e;
|
|
162
|
+
const existing = await read(path);
|
|
163
|
+
if (!existing) return await this.begin(input);
|
|
164
|
+
return { conflict: await state(root, existing) };
|
|
165
|
+
}
|
|
166
|
+
await syncDir(root);
|
|
167
|
+
returned = true;
|
|
168
|
+
return { operation: { ...op, state: 'pending' } };
|
|
169
|
+
} finally {
|
|
170
|
+
await unlink(temp).catch(() => {});
|
|
171
|
+
if (!returned) { active.delete(op.operationId); await stopMarker(op); await unlink(marker).catch(() => {}); }
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
async finish(op, outcome) {
|
|
175
|
+
const root = await prepare();
|
|
176
|
+
try {
|
|
177
|
+
if (outcome === true || outcome === 'confirmed') {
|
|
178
|
+
const result = await lock(root, op, async () => {
|
|
179
|
+
const path = join(root, `${scope(op)}.json`);
|
|
180
|
+
const current = await read(path);
|
|
181
|
+
if (current?.operationId !== op.operationId) return { ok: false };
|
|
182
|
+
if (outcome === true) await unlink(path);
|
|
183
|
+
else {
|
|
184
|
+
const { tmp, handle } = await createTemp(path, { mode: 0o600 });
|
|
185
|
+
try {
|
|
186
|
+
try { await handle.writeFile(JSON.stringify({ ...current, state: 'confirmed' })); await handle.sync(); }
|
|
187
|
+
finally { await handle.close(); }
|
|
188
|
+
await renameWithRetry(tmp, path);
|
|
189
|
+
} finally { await unlink(tmp).catch(() => {}); }
|
|
190
|
+
}
|
|
191
|
+
await syncDir(root);
|
|
192
|
+
return { ok: true };
|
|
193
|
+
});
|
|
194
|
+
if (!result.ok) throw new Error(`${name} write guard could not finalize the operation`);
|
|
195
|
+
}
|
|
196
|
+
} finally {
|
|
197
|
+
active.delete(op.operationId);
|
|
198
|
+
await stopMarker(op);
|
|
199
|
+
await unlink(join(root, `running-${op.operationId}-${process.pid}`)).catch(() => {});
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
async list(connectionId) {
|
|
203
|
+
const root = await prepare();
|
|
204
|
+
const names = (await readdir(root)).filter(n => /^[a-f0-9]{64}\.json$/.test(n));
|
|
205
|
+
const records = await Promise.all(names.map(n => read(join(root, n))));
|
|
206
|
+
return Promise.all(records.filter(x => x?.connectionId === connectionId).map(x => state(root, x)));
|
|
207
|
+
},
|
|
208
|
+
async acknowledge(connectionId, operationId) {
|
|
209
|
+
if (typeof operationId !== 'string' || !uuidPattern.test(operationId)) return { ok: false };
|
|
210
|
+
const root = await prepare();
|
|
211
|
+
const op = (await this.list(connectionId)).find(x => x.operationId === operationId);
|
|
212
|
+
if (!op) return { ok: false };
|
|
213
|
+
return lock(root, op, async () => {
|
|
214
|
+
const path = join(root, `${scope(op)}.json`);
|
|
215
|
+
const current = await read(path);
|
|
216
|
+
if (!current || current.operationId !== operationId) return { ok: false };
|
|
217
|
+
if (await running(root, current)) return { conflict: await state(root, current) };
|
|
218
|
+
await unlink(path); await syncDir(root);
|
|
219
|
+
return { ok: true };
|
|
220
|
+
});
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Optional Intel SMC reader. macOS's built-in powermetrics needs root; this
|
|
2
|
+
// installed command reads the CPU proximity sensor without elevation.
|
|
3
|
+
// The executable is separate software, not bundled or downloaded by ccdeck.
|
|
4
|
+
import { existsSync } from "node:fs";
|
|
5
|
+
import { run } from "./exec.mjs";
|
|
6
|
+
|
|
7
|
+
export const INTEL_CPU_TEMP_CANDIDATES = [
|
|
8
|
+
"/usr/local/bin/osx-cpu-temp",
|
|
9
|
+
"/opt/homebrew/bin/osx-cpu-temp",
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
export function cpuFromIntelSmc(text) {
|
|
13
|
+
const match = /^\s*(\d+(?:\.\d+)?)\s*°C\s*$/.exec(String(text ?? ""));
|
|
14
|
+
if (!match) return null;
|
|
15
|
+
const c = Number(match[1]);
|
|
16
|
+
return Number.isFinite(c) && c > 0 && c < 130 ? Math.round(c) : null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export async function readIntelCpuTemp(deps = {}) {
|
|
20
|
+
if ((deps.platform ?? process.platform) !== "darwin" || (deps.arch ?? process.arch) !== "x64") return null;
|
|
21
|
+
const exists = deps.exists ?? existsSync;
|
|
22
|
+
const binary = INTEL_CPU_TEMP_CANDIDATES.find(p => exists(p));
|
|
23
|
+
if (!binary) return null;
|
|
24
|
+
const result = await (deps.run ?? run)(binary, ["-c"], { timeout: 2000, maxBuffer: 1024 });
|
|
25
|
+
return result.ok ? cpuFromIntelSmc(result.stdout) : null;
|
|
26
|
+
}
|
package/src/server/lifecycle.mjs
CHANGED
|
@@ -30,6 +30,8 @@ import { presentsDeckToken } from "./request-gates.mjs";
|
|
|
30
30
|
// engine's card and /api/version give one answer — see running-version.mjs.
|
|
31
31
|
import { RUNNING_VERSION } from "./running-version.mjs";
|
|
32
32
|
import { terminalCliState, updateTerminalCli } from "./terminal-cli-update.mjs";
|
|
33
|
+
// How many terminal panels have a socket open on this deck — see deckPresence.
|
|
34
|
+
import { openTerminalCount } from "./terminal-socket.mjs";
|
|
33
35
|
|
|
34
36
|
// Resolved the way pinned-build.mjs resolves it, from a file in the same
|
|
35
37
|
// directory, so every lazy import below is the URL the pin has already evaluated.
|
|
@@ -359,14 +361,46 @@ async function handleStop(req, res) {
|
|
|
359
361
|
send(res, 200, { ok: true, pid: process.pid });
|
|
360
362
|
}
|
|
361
363
|
|
|
364
|
+
/**
|
|
365
|
+
* Presence as the away-update reads it: the tabs' own claims (presence.mjs,
|
|
366
|
+
* fed by POST /api/presence), and every terminal socket open on this deck
|
|
367
|
+
* counted as one more tab that is being looked at.
|
|
368
|
+
*
|
|
369
|
+
* A terminal panel is somebody at an agent's keyboard. A tab claims presence
|
|
370
|
+
* only while it is visible AND holds focus (src/web/presence.ts), so a person
|
|
371
|
+
* reading a running agent in the panel while their keyboard is in another
|
|
372
|
+
* window, or one whose tab sits behind the window they are typing a reply in,
|
|
373
|
+
* is not "looking" by that rule — and a restart then cuts their terminal: the
|
|
374
|
+
* socket closes with `server-shutdown`, the tickets die with the process, and
|
|
375
|
+
* whatever they type before the panel has reconnected goes nowhere. The tmux
|
|
376
|
+
* session survives all of it; the person's attention is what the away-update
|
|
377
|
+
* promises not to interrupt.
|
|
378
|
+
*
|
|
379
|
+
* The cost is that a panel left open holds the away-update off until it is
|
|
380
|
+
* closed. That is bounded: four sockets at most (MAX_TERMINALS); a tab that
|
|
381
|
+
* is closed takes its socket with it at once, and one that loses its network
|
|
382
|
+
* is dropped after two unanswered pings, about a minute (ws-frames.mjs) —
|
|
383
|
+
* which is when this stops counting it.
|
|
384
|
+
*
|
|
385
|
+
* `report` is the tabs' own; `openTerminals` answers how many sockets are
|
|
386
|
+
* open (terminal-socket's openTerminalCount).
|
|
387
|
+
*/
|
|
388
|
+
export function deckPresence(tabs, openTerminals) {
|
|
389
|
+
return {
|
|
390
|
+
report: (tab, looking, now) => tabs.report(tab, looking, now),
|
|
391
|
+
looking: (now) => tabs.looking(now) || openTerminals() > 0,
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
|
|
362
395
|
// The two facts the away-update waits on (awayUpdateTick): whether a turn is
|
|
363
|
-
// running, fed from pushEvent, and whether
|
|
364
|
-
// POST /api/presence
|
|
365
|
-
//
|
|
366
|
-
//
|
|
367
|
-
//
|
|
396
|
+
// running, fed from pushEvent, and whether anybody is at the deck — a tab
|
|
397
|
+
// being looked at, fed from POST /api/presence, or a terminal panel open on
|
|
398
|
+
// it. They sat at the top of index.mjs while pushEvent was that file's,
|
|
399
|
+
// because pushEvent can run before the module holding it has finished
|
|
400
|
+
// evaluating; made here, they exist before event-pipeline.mjs's own body runs
|
|
401
|
+
// at all.
|
|
368
402
|
const activity = createActivity();
|
|
369
|
-
const presence = createPresence();
|
|
403
|
+
const presence = deckPresence(createPresence(), openTerminalCount);
|
|
370
404
|
|
|
371
405
|
// ── updating while nobody is looking ────────────────────────────────────────
|
|
372
406
|
//
|
|
@@ -480,6 +514,35 @@ async function handlePresence(req, res) {
|
|
|
480
514
|
return send(res, ok ? 200 : 400, { ok });
|
|
481
515
|
}
|
|
482
516
|
|
|
517
|
+
/**
|
|
518
|
+
* What has to happen on the way out that the launcher cannot know about: the
|
|
519
|
+
* account's last status frame, so the console says "ccdeck stopped" at once
|
|
520
|
+
* rather than after 90 seconds of silence (account-status.mjs sendStopping).
|
|
521
|
+
* Registered by whatever needs it, while it needs it — nothing registers one
|
|
522
|
+
* on a deck with the account off, and then `beforeShutdown` is free.
|
|
523
|
+
*/
|
|
524
|
+
const _beforeShutdown = new Set();
|
|
525
|
+
|
|
526
|
+
/** Run `fn` on the way out; answers the unregister. */
|
|
527
|
+
export function onBeforeShutdown(fn) {
|
|
528
|
+
_beforeShutdown.add(fn);
|
|
529
|
+
return () => _beforeShutdown.delete(fn);
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/** The registered steps, all at once, bounded: bin/deck.js's shutdown awaits
|
|
533
|
+
* this on every way out — a signal, `ccdeck --stop`, a restart into an update
|
|
534
|
+
* — and never waits past `ms`, nor on a step that throws. */
|
|
535
|
+
export async function beforeShutdown(ms = 1_500) {
|
|
536
|
+
if (_beforeShutdown.size === 0) return;
|
|
537
|
+
const steps = [..._beforeShutdown].map(fn => Promise.resolve().then(fn).catch(() => {}));
|
|
538
|
+
let timer;
|
|
539
|
+
await Promise.race([
|
|
540
|
+
Promise.all(steps),
|
|
541
|
+
new Promise(r => { timer = setTimeout(r, ms); timer.unref?.(); }),
|
|
542
|
+
]);
|
|
543
|
+
clearTimeout(timer);
|
|
544
|
+
}
|
|
545
|
+
|
|
483
546
|
// What index.mjs calls besides the two exported above. Listed rather than
|
|
484
547
|
// marked at each declaration, so the declarations read as they did where they
|
|
485
548
|
// came from.
|
|
@@ -135,6 +135,10 @@ export function replayScope(workspace, platform = process.platform, providers =
|
|
|
135
135
|
function admits(payload) {
|
|
136
136
|
if (!payload || typeof payload !== "object") return false;
|
|
137
137
|
if (payload.hook_event_name === "__clear") return true;
|
|
138
|
+
// The deck's record of what its Command Panel started (panel-provenance.mjs):
|
|
139
|
+
// no cwd and no session_id, and not a session's own event, so neither scope
|
|
140
|
+
// decides it. Admitted, like `__clear`, only when the server recorded it.
|
|
141
|
+
if (payload.hook_event_name === "__panel_launch") return true;
|
|
138
142
|
// The provider gate, ahead of the workspace one and exempting `__clear` for
|
|
139
143
|
// the same reason it does: the marker carries no provider, and a deck that
|
|
140
144
|
// dropped it would replay a canvas the user had explicitly cleared.
|
|
@@ -459,6 +459,12 @@ export const SETTING_VARS = Object.freeze([
|
|
|
459
459
|
"AGENTS_DECK_NO_RADAR",
|
|
460
460
|
// Keep native Codex account control disabled after a login-service restart.
|
|
461
461
|
"AGENTS_DECK_NO_CODEX_LIVE",
|
|
462
|
+
// The account's veto (account-flag.mjs), carried because a veto is always
|
|
463
|
+
// safe to pass on — and the one name here the README's table does not list:
|
|
464
|
+
// the account it vetoes is hidden, so documenting the veto would announce
|
|
465
|
+
// it. login-item-opt-outs.test.ts names it as that exception. The switch
|
|
466
|
+
// that turns the account on, CCDECK_ACCOUNT, is not carried at all.
|
|
467
|
+
"AGENTS_DECK_NO_ACCOUNT",
|
|
462
468
|
]);
|
|
463
469
|
|
|
464
470
|
export function settingsEnv(env = process.env) {
|
|
@@ -568,7 +574,7 @@ export function installService({
|
|
|
568
574
|
// and both answer a missing one by failing the job silently. On a machine
|
|
569
575
|
// where the deck has never run — which is every machine `--install-service`
|
|
570
576
|
// is typed on first — that directory does not exist yet.
|
|
571
|
-
fs.mkdirSync(logPathDir(logPath), { recursive: true });
|
|
577
|
+
fs.mkdirSync(logPathDir(logPath), { recursive: true, mode: 0o700 });
|
|
572
578
|
if (platform === "win32") {
|
|
573
579
|
// The XML goes to a temp file beside the deck's own data rather than to
|
|
574
580
|
// %TEMP%: schtasks reads it once and this way a machine that refuses the
|
package/src/server/macmon.mjs
CHANGED
|
@@ -271,7 +271,7 @@ export async function bootstrapMacmon({
|
|
|
271
271
|
// rather than accepting a directory somebody else made.
|
|
272
272
|
// Staged beside the destination rather than in the system temp directory,
|
|
273
273
|
// so the rename below is same-filesystem and therefore atomic.
|
|
274
|
-
await mkdir(dir, { recursive: true });
|
|
274
|
+
await mkdir(dir, { recursive: true, mode: 0o700 });
|
|
275
275
|
staging = await mkdtemp(join(dir, "macmon-staging-"));
|
|
276
276
|
const archivePath = join(staging, "macmon.tar.gz");
|
|
277
277
|
await writeFile(archivePath, archive);
|
|
@@ -261,7 +261,7 @@ export function lastKnownLatest(name = PUBLISHED_NAME) {
|
|
|
261
261
|
function writeMarker(name, marker) {
|
|
262
262
|
const path = markerPath(name);
|
|
263
263
|
try {
|
|
264
|
-
mkdirSync(dirname(path), { recursive: true });
|
|
264
|
+
mkdirSync(dirname(path), { recursive: true, mode: 0o700 });
|
|
265
265
|
writeFileSync(path, JSON.stringify(marker));
|
|
266
266
|
} catch { /* a read-only home must not break the deck */ }
|
|
267
267
|
}
|
|
@@ -165,7 +165,7 @@ export async function observeOrgTelemetry({
|
|
|
165
165
|
writtenAt: Math.round(mtime),
|
|
166
166
|
},
|
|
167
167
|
};
|
|
168
|
-
await makeDir(dataDir, { recursive: true })
|
|
168
|
+
await makeDir(dataDir, { recursive: true, mode: 0o700 })
|
|
169
169
|
.then(() => write(recordsPath, `${JSON.stringify(_records, null, 2)}\n`))
|
|
170
170
|
.catch(() => {});
|
|
171
171
|
} catch { /* no file, or one that could not be read: nothing new to say */ }
|
|
@@ -143,6 +143,9 @@ export function createOutputWatch(io = {}) {
|
|
|
143
143
|
|
|
144
144
|
function forget(sid) { seen.delete(sid); }
|
|
145
145
|
|
|
146
|
+
/** Where a session's transcript is, as `note` last heard it, or undefined. */
|
|
147
|
+
function pathOf(sid) { return seen.get(sid)?.path; }
|
|
148
|
+
|
|
146
149
|
/** For the suite, and for the one place the server clears everything. */
|
|
147
150
|
function clear() { seen.clear(); }
|
|
148
151
|
function size() { return seen.size; }
|
|
@@ -270,5 +273,5 @@ export function createOutputWatch(io = {}) {
|
|
|
270
273
|
}
|
|
271
274
|
}
|
|
272
275
|
|
|
273
|
-
return { note, forget, clear, size, poll };
|
|
276
|
+
return { note, forget, clear, size, pathOf, poll };
|
|
274
277
|
}
|