ccdeck 3.82.3 → 4.0.0
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/login-item.js +5 -0
- package/bin/cli/tui.js +58 -4
- package/bin/deck.js +27 -1
- package/dist/web/assets/AccountBridge-OQHT5qmS.js +1 -0
- package/dist/web/assets/AccountSection-BpIHPhF3.js +1 -0
- package/dist/web/assets/BrowserWatchModal-DBdt52v7.js +1 -0
- package/dist/web/assets/FeedbackConversations-BJjgXI0-.js +1 -0
- package/dist/web/assets/IntegrationModal-DQ0vEz4X.js +7 -0
- package/dist/web/assets/IntegrationSkeleton-JCPbqp96.js +1 -0
- package/dist/web/assets/RadioPanel-Be6AkrKl.js +1 -0
- package/dist/web/assets/StageShell-Dq0JOQhd.js +4 -0
- package/dist/web/assets/TrafficRadar-7jqJbhaK.js +8 -0
- package/dist/web/assets/UsageHistoryModal-ckawZGoe.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-40gNTTfq.js +361 -0
- package/dist/web/assets/app-BRjYF6oD.css +1 -0
- package/dist/web/assets/{index-B4c5MZCc.js → index-XIY3yFiN.js} +1 -1
- package/dist/web/assets/inspector-status-pane-BV_m7eBv.js +1 -0
- package/dist/web/assets/screens-9_ivqfcF.js +12 -0
- package/dist/web/assets/screens-DUniTTbC.css +1 -0
- package/dist/web/assets/stage-board-NF_wgGRA.js +2 -0
- package/dist/web/assets/use-account-BUmI-A8e.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 +79 -0
- 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 +116 -14
- 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-BmRTh_xT.js +0 -1
- package/dist/web/assets/IntegrationModal-C_f526aV.js +0 -7
- package/dist/web/assets/RadioPanel-D2rkf9cg.js +0 -1
- package/dist/web/assets/TrafficRadar-BOgVBLIN.js +0 -8
- package/dist/web/assets/UsageHistoryModal-BJPTFwM9.js +0 -1
- package/dist/web/assets/app-CbXmr9rC.css +0 -1
- package/dist/web/assets/app-DZdZoqJ6.js +0 -358
package/src/server/reports.mjs
CHANGED
|
@@ -33,9 +33,11 @@
|
|
|
33
33
|
// Codex plan as its category ("max-20x", "plus") and nothing else from the
|
|
34
34
|
// credentials it is read off, and how many Claude accounts and paired
|
|
35
35
|
// machines the deck holds, as capped counts (depth-facts.mjs), and which
|
|
36
|
-
// trackers have a saved connection when it is sent
|
|
37
|
-
// "
|
|
38
|
-
//
|
|
36
|
+
// trackers have a saved connection when it is sent, and how many of each:
|
|
37
|
+
// "jira", "github", "gitlab", each with a capped count, and nothing else,
|
|
38
|
+
// never an address, an account, a token, a connection's id or its name
|
|
39
|
+
// (integrations/store.mjs; when that list cannot be read, only that it
|
|
40
|
+
// could not be, as `integrationsUnread`),
|
|
39
41
|
// - an "uninstall" event when somebody runs `ccdeck --uninstall`, with the
|
|
40
42
|
// reason they picked from a short list if they picked one (bin/cli/leaving.js),
|
|
41
43
|
// - an "activated" event, once, when a new install's first session arrives:
|
|
@@ -129,7 +131,7 @@ import { isWsl } from "./open-url.mjs";
|
|
|
129
131
|
import { osReleaseFields, osVersionOf } from "./os-version.mjs";
|
|
130
132
|
import { UI_LANGUAGE_MAX, uiLanguageCode } from "./ui-language.mjs";
|
|
131
133
|
import {
|
|
132
|
-
CLAUDE_PLANS, CODEX_PLANS, cappedCount, deckDepth, eventsBucket, installMarkFile, installVia, launchBucket,
|
|
134
|
+
CLAUDE_PLANS, CODEX_PLANS, COUNT_CAP, cappedCount, deckDepth, eventsBucket, installMarkFile, installVia, launchBucket,
|
|
133
135
|
memoryBucket, updateVia,
|
|
134
136
|
} from "./depth-facts.mjs";
|
|
135
137
|
import { daysUsedBucket, normaliseRating, ratingDue, ratingStage, scoreOf } from "./rating.mjs";
|
|
@@ -165,11 +167,18 @@ const ERRORS_PER_HOUR = 20;
|
|
|
165
167
|
const SAME_ERROR_QUIET_MS = 60 * 60 * 1000;
|
|
166
168
|
const MESSAGE_MAX = 500;
|
|
167
169
|
const STACK_MAX = 4000;
|
|
170
|
+
/** A disk with no room left, or a quota used up: see reportError. */
|
|
171
|
+
const NO_SPACE = new Set(["ENOSPC", "EDQUOT"]);
|
|
168
172
|
|
|
169
173
|
/** Why somebody uninstalled, when they said: the answers `ccdeck --uninstall`
|
|
170
174
|
* offers (bin/cli/leaving.js), and nothing else ever leaves as a reason. */
|
|
171
175
|
export const UNINSTALL_REASONS = Object.freeze(["not-useful", "too-noisy", "broken", "other-tool", "privacy", "other"]);
|
|
172
176
|
|
|
177
|
+
/** The trackers an "active" may name, in the order it names them — the three
|
|
178
|
+
* the integrations store counts (its REPORTED_KINDS), kept here as well so the
|
|
179
|
+
* reporter does not load the store to know what it may say. */
|
|
180
|
+
const TRACKER_KINDS = Object.freeze(["jira", "github", "gitlab"]);
|
|
181
|
+
|
|
173
182
|
const EMPTY_REPORT = Object.freeze({
|
|
174
183
|
installId: "", lastVersion: "", lastActiveDay: "", forget: "", usage: null,
|
|
175
184
|
installedAt: "", firstSessionAt: "", firstProvider: "", activationSent: false, ref: "", selfUpdate: null,
|
|
@@ -569,12 +578,40 @@ export const HOST_PATTERN = String.raw`(?<![\w.@/\\%-])(?!localhost(?![\w-]|\.\w
|
|
|
569
578
|
|
|
570
579
|
const escapeRegExp = s => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
571
580
|
|
|
581
|
+
/** What the path patterns end a path at and encodeURIComponent writes escaped:
|
|
582
|
+
* whitespace, a quote, an angle bracket, and `|?;,`. Kept escaped when the run
|
|
583
|
+
* around it is read back, see decodeEscapes. */
|
|
584
|
+
const KEPT_ESCAPED = /[\s"\x60<>|?;,]/g;
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* Every run of percent-escapes read back into the characters it stands for,
|
|
588
|
+
* before any pattern below looks. A stack that went through encodeURIComponent
|
|
589
|
+
* on its way — Puppeteer names the code it evaluates `pptr:…;` and the call
|
|
590
|
+
* site, encoded, `file%3A%2F%2F%2FUsers%2Falice%2F…` — hid the home folder and
|
|
591
|
+
* every path in it from each of them, and a page report sent one like that.
|
|
592
|
+
*
|
|
593
|
+
* A character the patterns end a path at stays escaped: read back,
|
|
594
|
+
* `Work%20Drive` would be two words, and only the first would go. A run that
|
|
595
|
+
* is not UTF-8 is left as it was, and a `%` with no two hex digits after it
|
|
596
|
+
* (`50% done`) is no run at all.
|
|
597
|
+
*/
|
|
598
|
+
function decodeEscapes(text) {
|
|
599
|
+
return text.replace(/(?:%[0-9A-Fa-f]{2})+/g, run => {
|
|
600
|
+
try {
|
|
601
|
+
return decodeURIComponent(run).replace(KEPT_ESCAPED, c => encodeURIComponent(c));
|
|
602
|
+
} catch {
|
|
603
|
+
return run;
|
|
604
|
+
}
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
|
|
572
608
|
/** Every spelling of `dir` a stack or a message can use — the path, and the
|
|
573
|
-
* file:// URL an ES module's frames carry
|
|
574
|
-
*
|
|
609
|
+
* file:// URL an ES module's frames carry, read back as scrub reads the text
|
|
610
|
+
* (decodeEscapes) — as a pattern for `dir` and the separator after it, so
|
|
611
|
+
* `/x/ccdeck-fork` is not taken for `/x/ccdeck`. */
|
|
575
612
|
function spellings(dir) {
|
|
576
613
|
const windows = /^(?:[A-Za-z]:[\\/]|\\\\)/.test(dir);
|
|
577
|
-
const url = pathToFileURL(dir, { windows }).href.replace(/\/$/, "");
|
|
614
|
+
const url = decodeEscapes(pathToFileURL(dir, { windows }).href).replace(/\/$/, "");
|
|
578
615
|
return new RegExp(`(?:${escapeRegExp(url)}|${escapeRegExp(dir)})(?=[\\\\/])`, windows ? "gi" : "g");
|
|
579
616
|
}
|
|
580
617
|
|
|
@@ -587,7 +624,8 @@ function spellings(dir) {
|
|
|
587
624
|
* machine; so does a dependency npx put beside it (`node_modules/ws/…`). Every
|
|
588
625
|
* other path becomes `<path>` (`~/.claude/<path>` under the home folder, see
|
|
589
626
|
* hidePath), and a project folder in Claude Code's encoding `<project>`: either
|
|
590
|
-
* would name what somebody works on.
|
|
627
|
+
* would name what somebody works on. A path written percent-encoded is read
|
|
628
|
+
* back first (decodeEscapes), so it goes the same way.
|
|
591
629
|
*
|
|
592
630
|
* No host leaves either. The page's frames name the machine the deck was opened
|
|
593
631
|
* by (`http://alices-macbook.local:4317/assets/…`); they become `<deck>/assets/…`,
|
|
@@ -608,7 +646,7 @@ function spellings(dir) {
|
|
|
608
646
|
* and addresses, email addresses, and strings shaped like keys and tokens.
|
|
609
647
|
*/
|
|
610
648
|
export function scrub(text, home = homedir(), root = PKG_ROOT) {
|
|
611
|
-
let out = String(text ?? "");
|
|
649
|
+
let out = decodeEscapes(String(text ?? ""));
|
|
612
650
|
if (root && root.length > 1) {
|
|
613
651
|
out = out.replace(spellings(root), "ccdeck");
|
|
614
652
|
if (basename(dirname(root)) === "node_modules") out = out.replace(spellings(dirname(root)), "node_modules");
|
|
@@ -616,6 +654,10 @@ export function scrub(text, home = homedir(), root = PKG_ROOT) {
|
|
|
616
654
|
// Never half a name: a home of /home/al is not the start of /home/alice.
|
|
617
655
|
if (home && home.length > 1) out = out.replace(new RegExp(`${escapeRegExp(home)}(?![\\w.-])`, "g"), "~");
|
|
618
656
|
return out
|
|
657
|
+
// The account's device token and device code (account-*.mjs), named by
|
|
658
|
+
// their prefixes so a short one is caught too, and first, so no pattern
|
|
659
|
+
// below can split one before it is recognised.
|
|
660
|
+
.replace(/\bccd[dc]_[A-Za-z0-9_-]{20,}/g, "<secret>")
|
|
619
661
|
.replace(/\/(?:home|Users)\/[^/\s:'"]+/g, "~")
|
|
620
662
|
.replace(/[A-Za-z]:\\(?:Users|Documents and Settings)\\[^\\\r\n:'"]+/gi, "~")
|
|
621
663
|
.replace(new RegExp(PATH_PATTERN, "g"), hidePath)
|
|
@@ -671,6 +713,12 @@ export function scrub(text, home = homedir(), root = PKG_ROOT) {
|
|
|
671
713
|
* plans, accounts and paired machines the "active" carries (depth-facts.mjs),
|
|
672
714
|
* read only when one is about to go. Default: none — the deck's own reporter
|
|
673
715
|
* passes deckDepth, so no test reads a real credentials file.
|
|
716
|
+
* @param {(() => Promise<unknown>) | null} [deps.integrations] how many tracker
|
|
717
|
+
* connections of each kind are saved, as integrations/store.mjs
|
|
718
|
+
* connectionCounts answers (null: the list could not be read), read only when
|
|
719
|
+
* an "active" is about to go. Default: none, and the "active" says nothing
|
|
720
|
+
* about trackers — the deck's own reporter passes the store's, so no test
|
|
721
|
+
* reads a real integrations.json.
|
|
674
722
|
* @param {() => number} [deps.launchedIn] ms from this process starting to the
|
|
675
723
|
* deck listening, read once by start(), which runs as the deck starts listening.
|
|
676
724
|
* @param {() => number} [deps.memory] the process's resident memory in bytes,
|
|
@@ -709,7 +757,7 @@ export function createReporter({
|
|
|
709
757
|
setupKnown = () => whenSetupKnown(),
|
|
710
758
|
reference = notedRef,
|
|
711
759
|
depth = async () => ({}),
|
|
712
|
-
integrations =
|
|
760
|
+
integrations = null,
|
|
713
761
|
launchedIn = () => process.uptime() * 1000,
|
|
714
762
|
memory = () => process.memoryUsage.rss(),
|
|
715
763
|
npx = false,
|
|
@@ -905,18 +953,26 @@ export function createReporter({
|
|
|
905
953
|
}
|
|
906
954
|
}
|
|
907
955
|
|
|
908
|
-
/** A snapshot of
|
|
909
|
-
* The provider owns the local read; only the three fixed
|
|
910
|
-
*
|
|
956
|
+
/** A snapshot of how many tracker connections of each kind are saved at
|
|
957
|
+
* report time. The provider owns the local read; only the three fixed
|
|
958
|
+
* provider names and a whole count for each, capped, leave — and the names
|
|
959
|
+
* alone again as `connectedIntegrations`, which older versions of the API
|
|
960
|
+
* read. An answer that is not a count for each of the three, or a provider
|
|
961
|
+
* that throws, is a list that could not be read, and says only that: a
|
|
962
|
+
* reading that cannot be trusted must not pass for "nothing connected". */
|
|
911
963
|
async function connectedProviders() {
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
964
|
+
if (!integrations) return {};
|
|
965
|
+
const unread = { integrationsUnread: true };
|
|
966
|
+
let value;
|
|
967
|
+
try { value = await integrations(); }
|
|
968
|
+
catch { return unread; }
|
|
969
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return unread;
|
|
970
|
+
const counts = {};
|
|
971
|
+
for (const kind of TRACKER_KINDS) {
|
|
972
|
+
if (!Number.isInteger(value[kind])) return unread;
|
|
973
|
+
counts[kind] = Math.min(Math.max(value[kind], 0), COUNT_CAP);
|
|
919
974
|
}
|
|
975
|
+
return { connectedIntegrations: TRACKER_KINDS.filter(k => counts[k] > 0), integrationCounts: counts };
|
|
920
976
|
}
|
|
921
977
|
|
|
922
978
|
/** What the "active" says about the deck beyond its day: how long this run
|
|
@@ -1413,8 +1469,17 @@ export function createReporter({
|
|
|
1413
1469
|
* Report an error, scrubbed. At most ERRORS_PER_HOUR an hour, and the same
|
|
1414
1470
|
* message is not repeated within SAME_ERROR_QUIET_MS: a handler that fails on
|
|
1415
1471
|
* every poll would otherwise send the same line all day.
|
|
1472
|
+
*
|
|
1473
|
+
* Never for a write that found the disk full (ENOSPC, EDQUOT). That is the
|
|
1474
|
+
* state of the machine, not a bug of the deck's, and no report can fix it:
|
|
1475
|
+
* the person whose disk it is has to free some space. It came in as an
|
|
1476
|
+
* error all the same, from every route that writes a file and lets the
|
|
1477
|
+
* failure fall to `guard` — the settings route names it to the page now
|
|
1478
|
+
* (prefs-refusal.mjs), the others still answer a bare 500. The deck's own
|
|
1479
|
+
* log still says it, with the path, for whoever looks.
|
|
1416
1480
|
*/
|
|
1417
1481
|
async function reportError(where, error) {
|
|
1482
|
+
if (NO_SPACE.has(error?.code)) return false;
|
|
1418
1483
|
const p = prefs.current();
|
|
1419
1484
|
if (!reportsOn(p, env) || !p.report.installId) return false;
|
|
1420
1485
|
const message = scrub(error?.message ?? error, home, root).slice(0, MESSAGE_MAX).trim();
|
|
@@ -1580,7 +1645,7 @@ export const reporter = createReporter({
|
|
|
1580
1645
|
versions: () => cliVersionCache, probe: probeCliVersions, depth: deckDepth, npx: isNpxInstall(PKG_ROOT),
|
|
1581
1646
|
integrations: async () => {
|
|
1582
1647
|
const { integrationsStore } = await import("./integrations/store.mjs");
|
|
1583
|
-
return integrationsStore.
|
|
1648
|
+
return integrationsStore.connectionCounts();
|
|
1584
1649
|
},
|
|
1585
1650
|
ratingKept: ratingFile(),
|
|
1586
1651
|
installMark: installMarkFile(),
|
|
@@ -163,7 +163,11 @@ export function isTrustedMutation({ origin, host, secFetchSite } = {}) {
|
|
|
163
163
|
// share envelope, with the OAuth token in it. A loopback literal has no DNS
|
|
164
164
|
// record to re-point, and `localhost` is reserved to loopback, so requiring one
|
|
165
165
|
// of them is what separates the deck's own UI from the rebound page.
|
|
166
|
-
|
|
166
|
+
//
|
|
167
|
+
// Exported for the terminal's WebSocket upgrade (terminal-socket.mjs), which
|
|
168
|
+
// Node hands to an 'upgrade' listener instead of the route table, and which
|
|
169
|
+
// therefore has to ask this question itself. One spelling of the rule, not two.
|
|
170
|
+
export function isLoopbackHost(host) {
|
|
167
171
|
if (typeof host !== "string") return false;
|
|
168
172
|
const authority = host.trim().toLowerCase();
|
|
169
173
|
// A real Host header is bare authority. Userinfo or a path would let
|
|
@@ -182,8 +186,9 @@ function isLoopbackHost(host) {
|
|
|
182
186
|
// Does `origin` name the same host:port the request was addressed to? Ports are
|
|
183
187
|
// part of an origin, so http://127.0.0.1:8000 is not http://127.0.0.1:4317 —
|
|
184
188
|
// and the default port is spelled both ways depending on the client, so it is
|
|
185
|
-
// normalised off both sides before comparing.
|
|
186
|
-
|
|
189
|
+
// normalised off both sides before comparing. Exported beside isLoopbackHost,
|
|
190
|
+
// for the same upgrade handler.
|
|
191
|
+
export function originMatchesHost(origin, host) {
|
|
187
192
|
if (typeof host !== "string" || host === "") return false;
|
|
188
193
|
let parsed;
|
|
189
194
|
try { parsed = new URL(origin); } catch { return false; }
|
|
@@ -431,6 +436,7 @@ export function isAuthorizedDataRead(req) {
|
|
|
431
436
|
* carries Sec-Fetch-Site: same-origin. */
|
|
432
437
|
export const GUARDED_READS = new Set([
|
|
433
438
|
"/api/tool-audit",
|
|
439
|
+
"/api/session/transcript",
|
|
434
440
|
"/api/tool-audit/storage",
|
|
435
441
|
"/api/system/traffic-radar",
|
|
436
442
|
"/api/system/traffic-radar/capture",
|
|
@@ -489,11 +495,32 @@ export const GUARDED_READS = new Set([
|
|
|
489
495
|
// only caller that needs it is the deck's own canvas, which sends
|
|
490
496
|
// Sec-Fetch-Site: same-origin on every fetch.
|
|
491
497
|
"/api/fm-station",
|
|
498
|
+
// The terminal panel's two reads (terminal-routes.mjs). /target is about
|
|
499
|
+
// one of the user's sessions — whether its process is running, in whose
|
|
500
|
+
// tmux, whether its project folder is still there — which is what the user
|
|
501
|
+
// is doing rather than what the machine is. /status says only whether tmux
|
|
502
|
+
// is usable here, but it has the same one caller, the deck's own page, and
|
|
503
|
+
// a family of routes with one open door is a family somebody has to reason
|
|
504
|
+
// about route by route. /hosts names the sessions still running on an older
|
|
505
|
+
// session host, with their folders.
|
|
506
|
+
"/api/terminal/status",
|
|
507
|
+
"/api/terminal/projects",
|
|
508
|
+
"/api/terminal/target",
|
|
509
|
+
"/api/terminal/hosts",
|
|
510
|
+
// The engine's install state (engine-install.mjs): which version is here,
|
|
511
|
+
// an install's progress and why one failed. The same one caller.
|
|
512
|
+
"/api/terminal/engine",
|
|
492
513
|
"/api/radio-stations",
|
|
493
514
|
"/api/radio-click",
|
|
494
515
|
// The trackers this deck is connected to (#2178): the list of connections
|
|
495
516
|
// with their accounts, and below it every read a provider adds.
|
|
496
517
|
"/api/integrations",
|
|
518
|
+
// The ccdeck account (account-flag.mjs): which account this deck is
|
|
519
|
+
// connected to, its email, the device and the settings it syncs, and the
|
|
520
|
+
// join preview's values. The user's own, and read by the deck's own page
|
|
521
|
+
// alone. Guarded whether the account is on or off, as every path here is.
|
|
522
|
+
"/api/account",
|
|
523
|
+
"/api/account/sync/preview",
|
|
497
524
|
]);
|
|
498
525
|
|
|
499
526
|
/** Whole namespaces of guarded reads, for routes whose path carries an id —
|
|
@@ -502,8 +529,10 @@ export const GUARDED_READS = new Set([
|
|
|
502
529
|
* work, read with the user's own token; every one of them is fetched by the
|
|
503
530
|
* deck's own page and nothing else. A prefix rather than a list because a
|
|
504
531
|
* provider adds its routes without touching this file, and a read it adds
|
|
505
|
-
* must be covered from the moment it exists.
|
|
506
|
-
|
|
532
|
+
* must be covered from the moment it exists. The account's feedback
|
|
533
|
+
* conversations are the same kind of read: what the person wrote to the
|
|
534
|
+
* people who make ccdeck, and their replies, a thread id in the path. */
|
|
535
|
+
export const GUARDED_READ_PREFIXES = Object.freeze(["/api/integrations/", "/api/account/feedback/"]);
|
|
507
536
|
|
|
508
537
|
/** Whether a GET to `pathname` must come from the deck's page or carry the
|
|
509
538
|
* token: listed in GUARDED_READS, or under one of GUARDED_READ_PREFIXES. */
|
|
@@ -97,7 +97,7 @@ export function recordRestartFailure({
|
|
|
97
97
|
if (!file) return;
|
|
98
98
|
const path = join(MARKER_DIR, file);
|
|
99
99
|
try {
|
|
100
|
-
mkdirSync(dirname(path), { recursive: true });
|
|
100
|
+
mkdirSync(dirname(path), { recursive: true, mode: 0o700 });
|
|
101
101
|
writeFileSync(path, JSON.stringify({
|
|
102
102
|
command,
|
|
103
103
|
error: error ? String(error).slice(0, 300) : null,
|