ccdeck 3.82.4 → 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.
Files changed (145) hide show
  1. package/LICENSING.md +42 -4
  2. package/README.md +183 -72
  3. package/THIRD_PARTY_NOTICES.md +243 -17
  4. package/bin/cli/tui.js +58 -4
  5. package/bin/deck.js +27 -1
  6. package/dist/web/assets/AccountBridge-OQHT5qmS.js +1 -0
  7. package/dist/web/assets/AccountSection-BpIHPhF3.js +1 -0
  8. package/dist/web/assets/BrowserWatchModal-DBdt52v7.js +1 -0
  9. package/dist/web/assets/FeedbackConversations-BJjgXI0-.js +1 -0
  10. package/dist/web/assets/IntegrationModal-DQ0vEz4X.js +7 -0
  11. package/dist/web/assets/IntegrationSkeleton-JCPbqp96.js +1 -0
  12. package/dist/web/assets/RadioPanel-Be6AkrKl.js +1 -0
  13. package/dist/web/assets/StageShell-Dq0JOQhd.js +4 -0
  14. package/dist/web/assets/TrafficRadar-7jqJbhaK.js +8 -0
  15. package/dist/web/assets/UsageHistoryModal-ckawZGoe.js +1 -0
  16. package/dist/web/assets/addon-unicode-graphemes-DW3WJwyh.js +18 -0
  17. package/dist/web/assets/addon-web-links-BWjmmSgS.js +12 -0
  18. package/dist/web/assets/addon-webgl-CLK4R-_u.js +75 -0
  19. package/dist/web/assets/app-40gNTTfq.js +361 -0
  20. package/dist/web/assets/app-BRjYF6oD.css +1 -0
  21. package/dist/web/assets/{index-B-l-VxLm.js → index-XIY3yFiN.js} +1 -1
  22. package/dist/web/assets/inspector-status-pane-BV_m7eBv.js +1 -0
  23. package/dist/web/assets/screens-9_ivqfcF.js +12 -0
  24. package/dist/web/assets/screens-DUniTTbC.css +1 -0
  25. package/dist/web/assets/stage-board-NF_wgGRA.js +2 -0
  26. package/dist/web/assets/use-account-BUmI-A8e.js +1 -0
  27. package/dist/web/assets/xterm-4jYizCpg.js +27 -0
  28. package/dist/web/assets/xterm-sheet-6GBZ9nXN.css +32 -0
  29. package/dist/web/index.html +16 -6
  30. package/package.json +13 -1
  31. package/release-notes.json +67 -0
  32. package/src/server/account-client.mjs +196 -0
  33. package/src/server/account-connect.mjs +238 -0
  34. package/src/server/account-flag.mjs +106 -0
  35. package/src/server/account-projects.mjs +1 -1
  36. package/src/server/account-service.mjs +532 -0
  37. package/src/server/account-status.mjs +293 -0
  38. package/src/server/account-store.mjs +137 -0
  39. package/src/server/account-sync.mjs +473 -0
  40. package/src/server/account-token-store.mjs +216 -0
  41. package/src/server/account-ui-fields.mjs +126 -0
  42. package/src/server/account-watch.mjs +1 -1
  43. package/src/server/browser-watch-log.mjs +1 -1
  44. package/src/server/browser-watch-store.mjs +1 -1
  45. package/src/server/ccdeck-account-routes.mjs +252 -0
  46. package/src/server/ccusage-install.mjs +2 -2
  47. package/src/server/ccusage-registry.mjs +4 -4
  48. package/src/server/ccusage-session.mjs +11 -0
  49. package/src/server/claude-accounts.mjs +1 -1
  50. package/src/server/claude-recovery.mjs +9 -4
  51. package/src/server/claude-settings-catalog.mjs +6 -6
  52. package/src/server/claude-settings.mjs +1 -1
  53. package/src/server/codex-auto.mjs +1 -1
  54. package/src/server/codex-cost-usage.mjs +7 -2
  55. package/src/server/codex-live-checkpoint.mjs +24 -9
  56. package/src/server/codex-live-engine.mjs +14 -4
  57. package/src/server/codex-live-handoff.mjs +53 -9
  58. package/src/server/codex-names.mjs +49 -0
  59. package/src/server/codex-translate.mjs +1 -1
  60. package/src/server/codex-ultrafast.d.mts +3 -0
  61. package/src/server/codex-ultrafast.mjs +5 -0
  62. package/src/server/codex-watch.mjs +25 -0
  63. package/src/server/command-panel-engine.mjs +300 -0
  64. package/src/server/command-panel-platform.mjs +99 -0
  65. package/src/server/cswap-auto-choice.mjs +1 -1
  66. package/src/server/cswap-auto-loop.mjs +1 -1
  67. package/src/server/cswap-install.mjs +21 -40
  68. package/src/server/deck-home.mjs +6 -0
  69. package/src/server/deck-prefs.mjs +53 -1
  70. package/src/server/detach.mjs +1 -1
  71. package/src/server/engine-download.mjs +277 -0
  72. package/src/server/engine-install.mjs +378 -0
  73. package/src/server/engine-package.mjs +267 -0
  74. package/src/server/event-log.mjs +7 -1
  75. package/src/server/event-pipeline.mjs +29 -1
  76. package/src/server/ghostty-handoff.mjs +81 -0
  77. package/src/server/index.mjs +143 -5
  78. package/src/server/installer.mjs +4 -1
  79. package/src/server/integrations/jira-write-guard.mjs +14 -208
  80. package/src/server/integrations/store.mjs +37 -19
  81. package/src/server/integrations/write-guard.mjs +223 -0
  82. package/src/server/intel-cpu-temperature.mjs +26 -0
  83. package/src/server/lifecycle.mjs +69 -6
  84. package/src/server/log-replay.mjs +4 -0
  85. package/src/server/login-service.mjs +7 -1
  86. package/src/server/macmon.mjs +1 -1
  87. package/src/server/npm-latest.mjs +1 -1
  88. package/src/server/org-telemetry.mjs +1 -1
  89. package/src/server/output-watch.mjs +4 -1
  90. package/src/server/panel-provenance.mjs +390 -0
  91. package/src/server/pinned-build.mjs +14 -0
  92. package/src/server/prefs-refusal.mjs +8 -1
  93. package/src/server/prefs-routes.mjs +60 -11
  94. package/src/server/pro-engine-client.mjs +339 -0
  95. package/src/server/pro-engine-install.mjs +294 -0
  96. package/src/server/pro-engine-terminal.mjs +308 -0
  97. package/src/server/project-discovery.mjs +139 -0
  98. package/src/server/provider-session-name.mjs +58 -0
  99. package/src/server/quota-closes.mjs +1 -1
  100. package/src/server/quota-history.mjs +1 -1
  101. package/src/server/reports.mjs +86 -21
  102. package/src/server/request-gates.mjs +34 -5
  103. package/src/server/restart-note.mjs +1 -1
  104. package/src/server/seed-boundary.mjs +489 -0
  105. package/src/server/session-counts.mjs +244 -0
  106. package/src/server/session-deck-names.mjs +143 -0
  107. package/src/server/session-enrichment.mjs +43 -6
  108. package/src/server/session-name-route.mjs +73 -0
  109. package/src/server/session-summary.mjs +12 -1
  110. package/src/server/session-transcript-routes.mjs +167 -0
  111. package/src/server/swap-log.mjs +1 -1
  112. package/src/server/system-metrics.mjs +57 -0
  113. package/src/server/terminal-bridge.mjs +485 -0
  114. package/src/server/terminal-folder.mjs +61 -0
  115. package/src/server/terminal-js-routes.mjs +752 -0
  116. package/src/server/terminal-routes.mjs +553 -0
  117. package/src/server/terminal-sessions.mjs +759 -0
  118. package/src/server/terminal-socket.mjs +403 -0
  119. package/src/server/terminal-target.mjs +928 -0
  120. package/src/server/thermal-metrics.mjs +13 -9
  121. package/src/server/tmux-control.mjs +1319 -0
  122. package/src/server/tmux-download.mjs +220 -0
  123. package/src/server/tmux.mjs +542 -0
  124. package/src/server/token-redact.mjs +42 -3
  125. package/src/server/tool-audit-report.mjs +44 -6
  126. package/src/server/tool-audit-routes.mjs +12 -1
  127. package/src/server/tool-audit.mjs +42 -8
  128. package/src/server/traffic-radar-monitor.mjs +1 -1
  129. package/src/server/traffic-radar-permission.mjs +1 -1
  130. package/src/server/transcript-gate.mjs +1 -1
  131. package/src/server/transcript-scan.mjs +15 -7
  132. package/src/server/transcript-turns.mjs +154 -0
  133. package/src/server/tui-network.mjs +1 -0
  134. package/src/server/tui-view.mjs +28 -0
  135. package/src/server/utf8-carry.mjs +159 -0
  136. package/src/server/uv-bootstrap.mjs +2 -2
  137. package/src/server/windows-acl.mjs +158 -0
  138. package/src/server/ws-frames.mjs +690 -0
  139. package/dist/web/assets/BrowserWatchModal-CWVooKxD.js +0 -1
  140. package/dist/web/assets/IntegrationModal-DLX43RIK.js +0 -7
  141. package/dist/web/assets/RadioPanel-Cj6PjrvQ.js +0 -1
  142. package/dist/web/assets/TrafficRadar-Bq1YcuHB.js +0 -8
  143. package/dist/web/assets/UsageHistoryModal-CMSCca5_.js +0 -1
  144. package/dist/web/assets/app-BHxsMz3-.js +0 -358
  145. package/dist/web/assets/app-CbXmr9rC.css +0 -1
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Copyright (c) 2014 The xterm.js authors. All rights reserved.
3
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
4
+ * https://github.com/chjj/term.js
5
+ * @license MIT
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in
15
+ * all copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ * THE SOFTWARE.
24
+ *
25
+ * Originally forked from (with the author's permission):
26
+ * Fabrice Bellard's javascript vt100 for jslinux:
27
+ * http://bellard.org/jslinux/
28
+ * Copyright (c) 2011 Fabrice Bellard
29
+ * The original design remains. The terminal itself
30
+ * has been extended to include xterm CSI codes, among
31
+ * other features.
32
+ */.xterm{cursor:text;position:relative;user-select:none;-ms-user-select:none;-webkit-user-select:none}.xterm.focus,.xterm:focus{outline:none}.xterm .xterm-helpers{position:absolute;top:0;z-index:5}.xterm .xterm-helper-textarea{padding:0;border:0;margin:0;position:absolute;opacity:0;left:-9999em;top:0;width:0;height:0;z-index:-5;white-space:nowrap;overflow:hidden;resize:none}.xterm .composition-view{background:#000;color:#fff;display:none;position:absolute;white-space:nowrap;z-index:1}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{background-color:#000;overflow-y:scroll;cursor:default;position:absolute;right:0;left:0;top:0;bottom:0}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;left:0;top:0}.xterm-char-measure-element{display:inline-block;visibility:hidden;position:absolute;top:0;left:-9999em;line-height:normal}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer,.xterm .xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility:not(.debug),.xterm .xterm-message{position:absolute;left:0;top:0;bottom:0;right:0;z-index:10;color:transparent;pointer-events:none}.xterm .xterm-accessibility-tree:not(.debug) *::selection{color:transparent}.xterm .xterm-accessibility-tree{font-family:monospace;-webkit-user-select:text;user-select:text;white-space:pre}.xterm .xterm-accessibility-tree>div{transform-origin:left;width:fit-content}.xterm .live-region{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}.xterm-dim{opacity:1!important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{text-decoration:double underline}.xterm-underline-3{text-decoration:wavy underline}.xterm-underline-4{text-decoration:dotted underline}.xterm-underline-5{text-decoration:dashed underline}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:overline underline}.xterm-overline.xterm-underline-2{text-decoration:overline double underline}.xterm-overline.xterm-underline-3{text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;position:absolute;top:0;right:0;pointer-events:none}.xterm-decoration-top{z-index:2;position:relative}.xterm .xterm-scrollable-element>.scrollbar{cursor:default}.xterm .xterm-scrollable-element>.scrollbar>.scra{cursor:pointer;font-size:11px!important}.xterm .xterm-scrollable-element>.visible{opacity:1;background:#0000;transition:opacity .1s linear;z-index:11}.xterm .xterm-scrollable-element>.invisible{opacity:0;pointer-events:none}.xterm .xterm-scrollable-element>.invisible.fade{transition:opacity .8s linear}.xterm .xterm-scrollable-element>.shadow{position:absolute;display:none}.xterm .xterm-scrollable-element>.shadow.top{display:block;top:0;left:3px;height:3px;width:100%;box-shadow:var(--vscode-scrollbar-shadow, #000) 0 6px 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.left{display:block;top:3px;left:0;height:100%;width:3px;box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.top-left-corner{display:block;top:0;left:0;height:3px;width:3px}.xterm .xterm-scrollable-element>.shadow.top.left{box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}
@@ -53,8 +53,8 @@
53
53
  <script>
54
54
  (function () {
55
55
  // Generated from JSON alongside the CSS and Settings catalog.
56
- var themes = /* theme-ids:start */ ["light","dark","rider-black","vscode-black","omarchy","matrix","black-contrast","white-contrast","catppuccin-mocha","gruvbox-dark","gruvbox-light","gruvbox-material"] /* theme-ids:end */;
57
- var lightThemes = /* theme-light-ids:start */ ["light","white-contrast","gruvbox-light"] /* theme-light-ids:end */;
56
+ var themes = /* theme-ids:start */ ["light","dark","rider-black","vscode-black","omarchy","matrix","black-contrast","white-contrast","catppuccin-mocha","gruvbox-dark","gruvbox-light","gruvbox-material","ink"] /* theme-ids:end */;
57
+ var lightThemes = /* theme-light-ids:start */ ["light","white-contrast","gruvbox-light","ink"] /* theme-light-ids:end */;
58
58
  var stored = null;
59
59
  // `window.localStorage` is a GETTER that throws where site data is
60
60
  // blocked, so the property read is inside the try, not just getItem.
@@ -72,14 +72,24 @@
72
72
  try {
73
73
  size = window.localStorage.getItem("agent-dag.text-size");
74
74
  density = window.localStorage.getItem("agent-dag.density");
75
+ // V4 draws at Compact by default. Before it the app stored "default"
76
+ // on its first start whether or not anyone chose it, so a stored
77
+ // "default" moves to Compact once; a choice made after that stays.
78
+ if (window.localStorage.getItem("agent-dag.density-v4") === null) {
79
+ if (density === "default") {
80
+ density = "compact";
81
+ window.localStorage.setItem("agent-dag.density", density);
82
+ }
83
+ window.localStorage.setItem("agent-dag.density-v4", "1");
84
+ }
75
85
  } catch (e) {}
76
86
  document.documentElement.setAttribute("data-text-size", size === "smallest" || size === "smaller" || size === "larger" || size === "largest" ? size : "default");
77
- document.documentElement.setAttribute("data-density", density === "tightest" || density === "tighter" || density === "compact" || density === "comfortable" ? density : "default");
87
+ document.documentElement.setAttribute("data-density", density === "tightest" || density === "tighter" || density === "default" || density === "comfortable" ? density : "compact");
78
88
  })();
79
89
  </script>
80
- <script type="module" crossorigin src="/assets/index-B-l-VxLm.js"></script>
81
- <link rel="modulepreload" crossorigin href="/assets/app-BHxsMz3-.js">
82
- <link rel="stylesheet" crossorigin href="/assets/app-CbXmr9rC.css">
90
+ <script type="module" crossorigin src="/assets/index-XIY3yFiN.js"></script>
91
+ <link rel="modulepreload" crossorigin href="/assets/app-40gNTTfq.js">
92
+ <link rel="stylesheet" crossorigin href="/assets/app-BRjYF6oD.css">
83
93
  </head>
84
94
  <body>
85
95
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccdeck",
3
- "version": "3.82.4",
3
+ "version": "4.0.0",
4
4
  "description": "Local dashboard for Claude Code and Codex CLI sessions: which Claude Code session needs input, every tool call and Claude Code subagent live, token cost and quota, several Claude accounts. Run npx ccdeck.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -83,6 +83,11 @@
83
83
  "@types/react": "^18.3.12",
84
84
  "@types/react-dom": "^18.3.1",
85
85
  "@vitejs/plugin-react": "^4.3.4",
86
+ "@xterm/addon-unicode-graphemes": "0.4.0",
87
+ "@xterm/addon-web-links": "0.12.0",
88
+ "@xterm/addon-webgl": "0.19.0",
89
+ "@xterm/headless": "6.0.0",
90
+ "@xterm/xterm": "6.0.0",
86
91
  "dagre": "^0.8.5",
87
92
  "esbuild": "0.25.12",
88
93
  "hls.js": "^1.7.3",
@@ -101,6 +106,13 @@
101
106
  "fs-native-extensions": "1.5.2",
102
107
  "ws": "8.22.1"
103
108
  },
109
+ "optionalDependencies": {
110
+ "@ccdeck/engine-darwin-arm64": "0.1.5",
111
+ "@ccdeck/engine-darwin-x64": "0.1.5",
112
+ "@ccdeck/engine-linux-arm64": "0.1.5",
113
+ "@ccdeck/engine-linux-x64": "0.1.5",
114
+ "@ccdeck/engine-win32-x64": "0.1.5"
115
+ },
104
116
  "bundledDependencies": [
105
117
  "fs-native-extensions",
106
118
  "ws"
@@ -1,4 +1,70 @@
1
1
  {
2
+ "4.0.0": [
3
+ {
4
+ "title": "🖥️ Your sessions' terminals, inside the deck",
5
+ "body": "Open, resume or attach to a Claude Code or Codex session in a terminal pane on the board or in Workspace, on Linux, macOS and Windows.",
6
+ "priority": "highlight",
7
+ "noticeLabel": "Setup change",
8
+ "notice": "The terminal is on by default; Settings › General › Experimental turns it off. It runs through ccdeck's terminal engine, a separate program under its own licence that comes with ccdeck (npm installs the one for this machine, the desktop app carries it) and is checked before every start. Windows on ARM has no terminal yet.",
9
+ "details": "In Workspace, a Claude Code or Codex session's pane offers Chat | Term: Chat shows the conversation, and you can reply from it while the session's terminal is open here. The terminal has its own text size, apart from the page's: Aa, or Ctrl+= / Ctrl+- / Ctrl+0 (⌘ on a Mac)."
10
+ },
11
+ {
12
+ "title": "🧭 A calmer deck that shows what needs you",
13
+ "body": "The Sessions list reads like an inbox, colour on the board means state, and the Inspector offers each session's next step under its title.",
14
+ "priority": "highlight",
15
+ "details": "Each stripe keeps its everyday doors and puts the rest behind More. Counters at zero and key hints you have learned step aside, and the board's tools sit in one ⋯ menu. Quotas moved from Sessions to Usage, and Codex's helper agents stay inside their main conversation. Every key works as before."
16
+ },
17
+ {
18
+ "title": "🪟 Up to four sessions side by side in Workspace",
19
+ "body": "Drag a session onto a pane's edge, or press ⇧↵ on its row, to open it beside the others; one pane has the keys while the rest keep running.",
20
+ "priority": "highlight",
21
+ "details": "Rename a session where its name is drawn (double click, F2 or the pencil), and that name shows everywhere in the deck; for a Codex session, Codex itself gets the new name too. The Sessions list's edge drags to resize it."
22
+ },
23
+ {
24
+ "title": "🔀 Move a Claude session here from Ghostty",
25
+ "body": "On a Mac, a Claude Code session running in Ghostty 1.4 or later offers Move session here in its ccdeck pane: one click continues the same conversation in that pane."
26
+ },
27
+ {
28
+ "title": "🔁 A Codex account switch keeps the turn going",
29
+ "body": "Switching Codex accounts lets the running tool call finish first, and a turn stopped by a usage limit in the minutes before the switch continues on the new account."
30
+ },
31
+ {
32
+ "title": "🔔 A notification when a session finishes",
33
+ "body": "If Settings › Notifications › While the deck is closed is on, a session that ends its turn now notifies you too, as a waiting one already did."
34
+ },
35
+ {
36
+ "title": "🚪 A pane closes when its agent exits",
37
+ "body": "Ending an agent yourself (/exit or Ctrl+D) closes its pane, and the session stays in the list. After a crash or a kill, the pane keeps its last frame and offers Reopen here."
38
+ },
39
+ {
40
+ "title": "▶️ The board always stays live",
41
+ "body": "Pause is gone from the board's menu and the keyboard help, and Space no longer freezes the board."
42
+ },
43
+ {
44
+ "title": "👥 Accounts you can switch to now come first",
45
+ "body": "Other accounts are grouped by whether you can use them now, and the sort menu is gone. Rows stay put while your pointer is in the list."
46
+ },
47
+ {
48
+ "title": "📂 New session finds its folder by search",
49
+ "body": "One field searches your projects, remembered folders and Git repositories, and takes a full path; Worktrees groups each repository's worktrees. The deck says before starting if an agent cannot open that folder."
50
+ },
51
+ {
52
+ "title": "🎨 Ink, a new light theme",
53
+ "body": "Settings › Appearance now has Ink: warm paper surfaces with charcoal text."
54
+ },
55
+ {
56
+ "title": "📱 The board as a card stack on a phone",
57
+ "body": "On a phone, the board is a full-width stack of readable cards, and More opens the Command Panel."
58
+ },
59
+ {
60
+ "title": "🌡️ CPU temperature on Intel Macs",
61
+ "body": "This machine now shows the CPU temperature on Intel Macs too."
62
+ },
63
+ {
64
+ "title": "⌨️ ccdeck tui stays current after a deck restart",
65
+ "body": "The account screen in ccdeck tui keeps updating when the deck restarts underneath it."
66
+ }
67
+ ],
2
68
  "3.82.4": [
3
69
  {
4
70
  "title": "🪟 Start at login works on Windows without administrator rights",
@@ -118,6 +184,7 @@
118
184
  "without one."
119
185
  ],
120
186
  "//summaries": {
187
+ "4.0.0": "A calmer deck, with your sessions' terminals inside it",
121
188
  "3.82.3": "Windows CPU limits and more reliable session and usage history",
122
189
  "3.82.2": "Arrow keys show the selected row on ccdeck tui's Network tab",
123
190
  "3.82.1": "Clearer network shortcuts, accurate account capacity and Codex recovery fixes",
@@ -0,0 +1,196 @@
1
+ // The account's one channel to the API: JSON over HTTPS, on one dedicated
2
+ // keep-alive connection.
3
+ //
4
+ // ONE CONNECTION, NOT ONE PER REQUEST. The status frames go every 15 seconds
5
+ // and the settings calls ride between them, so the agent keeps one socket
6
+ // (maxSockets: 1) and every request queues on it — one TLS handshake for the
7
+ // life of the deck instead of one per frame, and through Cloudflare a request a
8
+ // quarter of a minute after the last one finds the same connection still up.
9
+ // Node 18 and 20 have no WebSocket client and the deck takes no dependencies,
10
+ // which is why this is request/response at all (design 1.4).
11
+ //
12
+ // NOTHING FROM THE REPORTS CHANNEL RIDES HERE. Usage reports (reports.mjs)
13
+ // carry an install id and a hashed device fingerprint; this channel carries
14
+ // neither, and reports never carry the device id this channel is given. The
15
+ // two are deliberately unlinkable, so nothing here imports reports.mjs and the
16
+ // headers are exactly the ones below. account-client.test.ts holds a request
17
+ // to that.
18
+ //
19
+ // The rules a request lives by are the reporter's (reports.mjs `call`): a six
20
+ // second ceiling, a user agent that names the version and nothing else, and a
21
+ // Retry-After honoured — read here and handed to the caller, who owns the
22
+ // schedule.
23
+ //
24
+ // TWO EXCEPTIONS, BOTH FOR FEEDBACK CONVERSATIONS. A thread page can be 50
25
+ // messages of 10,000 characters, which System.Text.Json escapes to six bytes a
26
+ // character past ASCII, so a read may ask for more than the 256 KB every other
27
+ // answer is held to (`maxBody`, per call). And a conversation started with
28
+ // screenshots is up to 12 MB of form: it goes on a connection of its own
29
+ // (`postForm`), so the status frames keep the kept socket instead of queueing
30
+ // behind two minutes of upload.
31
+ import http from "node:http";
32
+ import https from "node:https";
33
+
34
+ export const CLIENT_TIMEOUT_MS = 6_000;
35
+ /** The longest a Retry-After is waited for: a header asking for a week does
36
+ * not silence a deck for one. The reporter's cap. */
37
+ export const RETRY_AFTER_MAX_MS = 24 * 60 * 60 * 1000;
38
+ const BODY_MAX = 256 * 1024;
39
+ /** What a feedback read may answer: 50 items of 10,000 characters, escaped. */
40
+ export const FEEDBACK_READ_MAX = 4 * 1024 * 1024;
41
+ /** A form with images: twelve megabytes at a hotel's 2 Mbit/s up is fifty
42
+ * seconds before the API reads a byte (reports-routes.mjs FORM_TIMEOUT_MS). */
43
+ export const UPLOAD_TIMEOUT_MS = 120_000;
44
+
45
+ /** A Retry-After, in seconds or as an HTTP date, as milliseconds from `at` —
46
+ * or null when there is none or it will not read. */
47
+ export function retryAfterMs(raw, at = Date.now()) {
48
+ const value = String(raw ?? "").trim();
49
+ if (!value) return null;
50
+ const ms = /^\d+$/.test(value) ? Number(value) * 1000 : Date.parse(value) - at;
51
+ return Number.isFinite(ms) && ms > 0 ? Math.min(ms, RETRY_AFTER_MAX_MS) : null;
52
+ }
53
+
54
+ /**
55
+ * One request over `agent`, as the product makes it — or, `fresh`, over a
56
+ * connection of its own that closes after it. Resolves to the status, the
57
+ * headers (lower-case, as Node gives them) and the body text; rejects on a
58
+ * network failure, the deadline or an answer over `maxBody` bytes.
59
+ */
60
+ function nodeRequest({ method, url, headers, body, timeoutMs, maxBody = BODY_MAX, fresh = false, agents }) {
61
+ return new Promise((resolve, reject) => {
62
+ const target = new URL(url);
63
+ const lib = target.protocol === "https:" ? https : http;
64
+ const agent = fresh ? false : target.protocol === "https:" ? agents.https : agents.http;
65
+ let settled = false;
66
+ const fail = err => { if (!settled) { settled = true; clearTimeout(timer); reject(err); } };
67
+ const req = lib.request(target, { method, headers, agent }, res => {
68
+ let text = "";
69
+ let size = 0;
70
+ res.setEncoding("utf8");
71
+ res.on("data", c => {
72
+ text += c;
73
+ size += Buffer.byteLength(c);
74
+ if (size > maxBody) req.destroy(new Error("response too large"));
75
+ });
76
+ res.on("end", () => {
77
+ if (settled) return;
78
+ settled = true;
79
+ clearTimeout(timer);
80
+ resolve({ status: res.statusCode ?? 0, headers: res.headers, text });
81
+ });
82
+ res.on("error", fail);
83
+ });
84
+ const timer = setTimeout(() => { req.destroy(new Error("timeout")); fail(new Error("timeout")); }, timeoutMs);
85
+ timer.unref?.();
86
+ req.on("error", fail);
87
+ req.end(body);
88
+ });
89
+ }
90
+
91
+ /** Whether a content type is JSON, problem+json included. */
92
+ function isJson(type) {
93
+ const t = String(type ?? "").split(";")[0].trim().toLowerCase();
94
+ return t === "application/json" || t === "application/problem+json" || t.endsWith("+json");
95
+ }
96
+
97
+ /**
98
+ * The client. `request` is the suite's stand-in for the transport and takes
99
+ * the same object nodeRequest does; the product passes nothing and gets one
100
+ * keep-alive agent per protocol, owned by this client alone.
101
+ *
102
+ * Every call resolves — never rejects — to one of:
103
+ * { status, ok, body, error, retryAfterMs } the API answered
104
+ * { status: 0, ok: false, network: true } it did not (offline, timeout, reset)
105
+ * where `error` is a problem+json body's machine-readable `error`, if any.
106
+ */
107
+ export function createAccountClient({
108
+ apiBase,
109
+ version = "",
110
+ request = null,
111
+ timeoutMs = CLIENT_TIMEOUT_MS,
112
+ now = Date.now,
113
+ enabled = () => true,
114
+ } = {}) {
115
+ const agents = request ? null : {
116
+ http: new http.Agent({ keepAlive: true, maxSockets: 1 }),
117
+ https: new https.Agent({ keepAlive: true, maxSockets: 1 }),
118
+ };
119
+ const send = request ?? (opts => nodeRequest({ ...opts, agents }));
120
+ const userAgent = `ccdeck/${version || "unknown"}`;
121
+
122
+ /** A request as `send` takes it, and the answer as every call resolves. */
123
+ async function exchange({ method, path, headers, payload, timeout, maxBody = BODY_MAX, fresh = false }) {
124
+ let res;
125
+ try {
126
+ res = await send({
127
+ method, url: apiBase + path, headers, body: payload, timeoutMs: timeout, maxBody, ...(fresh ? { fresh: true } : {}),
128
+ });
129
+ } catch {
130
+ return { status: 0, ok: false, network: true, body: null, error: null, retryAfterMs: null };
131
+ }
132
+ let parsed = null;
133
+ const type = res.headers?.["content-type"];
134
+ if (res.text && (isJson(type) || !type)) {
135
+ try { parsed = JSON.parse(res.text); } catch { parsed = null; }
136
+ }
137
+ const status = res.status;
138
+ return {
139
+ status,
140
+ ok: status >= 200 && status < 300,
141
+ network: false,
142
+ body: parsed,
143
+ error: parsed && typeof parsed.error === "string" ? parsed.error : null,
144
+ retryAfterMs: retryAfterMs(res.headers?.["retry-after"], now()),
145
+ };
146
+ }
147
+
148
+ const DISABLED = Object.freeze({ status: 0, ok: false, network: true, disabled: true, body: null, error: null, retryAfterMs: null });
149
+
150
+ async function call(method, path, { body, token, timeout = timeoutMs, maxBody } = {}) {
151
+ // THE ONE GATE EVERY REQUEST PASSES. The account is asked about on every
152
+ // call, not once at boot: a hand-edited prefs.json that turned it off is
153
+ // picked up by the next settings write, and from then on nothing goes —
154
+ // the publisher, the sync and a rotation all see an unreachable API.
155
+ if (!enabled()) return { ...DISABLED };
156
+ const headers = { accept: "application/json", "user-agent": userAgent };
157
+ let payload;
158
+ if (body !== undefined) {
159
+ payload = JSON.stringify(body);
160
+ headers["content-type"] = "application/json";
161
+ headers["content-length"] = String(Buffer.byteLength(payload));
162
+ }
163
+ if (token) headers.authorization = `Bearer ${token}`;
164
+ return exchange({ method, path, headers, payload, timeout, maxBody });
165
+ }
166
+
167
+ /** A multipart form (feedback-form.mjs upstreamForm, a Blob whose type
168
+ * carries the boundary), POSTed on a fresh connection: the same gate, the
169
+ * same headers but its own content type, the same answer. */
170
+ async function postForm(path, blob, { token, timeout = UPLOAD_TIMEOUT_MS } = {}) {
171
+ if (!enabled()) return { ...DISABLED };
172
+ const payload = Buffer.from(await blob.arrayBuffer());
173
+ const headers = {
174
+ accept: "application/json",
175
+ "user-agent": userAgent,
176
+ "content-type": blob.type,
177
+ "content-length": String(payload.length),
178
+ };
179
+ if (token) headers.authorization = `Bearer ${token}`;
180
+ return exchange({ method: "POST", path, headers, payload, timeout, fresh: true });
181
+ }
182
+
183
+ return {
184
+ apiBase,
185
+ get: (path, opts) => call("GET", path, opts),
186
+ post: (path, body, opts) => call("POST", path, { ...opts, body }),
187
+ put: (path, body, opts) => call("PUT", path, { ...opts, body }),
188
+ del: (path, opts) => call("DELETE", path, opts),
189
+ postForm,
190
+ /** Close the kept connection: a disconnect, a revocation, a shutdown. */
191
+ close() {
192
+ agents?.http.destroy();
193
+ agents?.https.destroy();
194
+ },
195
+ };
196
+ }
@@ -0,0 +1,238 @@
1
+ // Connecting this deck to a ccdeck account: the device authorization grant,
2
+ // in the shape RFC 8628 gives it (design 1.5).
3
+ //
4
+ // 1. POST /v1/device/authorize with the name the person chose → a user code
5
+ // for the browser, and a device code that stays in this process.
6
+ // 2. The page opens the approval page; the person signs in and approves.
7
+ // 3. This polls POST /v1/device/token every `interval` seconds until the API
8
+ // says approved, denied or expired.
9
+ //
10
+ // NOT A LOOPBACK REDIRECT, and the reasons are this deck's: a redirect back to
11
+ // 127.0.0.1 is a cross-site navigation that has to act, which is exactly what
12
+ // request-gates.mjs refuses; the port moves; and the browser that approves is
13
+ // often on another machine. The browser only ever sees the short user code.
14
+ //
15
+ // THE ANSWERS, and what each does here:
16
+ // 200 approved: the token goes to `onApproved`, once
17
+ // authorization_pending poll again after `interval`
18
+ // slow_down poll again, with the longer interval it names
19
+ // access_denied stop: "Cancelled in the browser"
20
+ // expired_token stop: offer Connect again
21
+ // invalid_grant stop
22
+ // 401 / 404 the API has accounts off: "not open yet"
23
+ // 429 wait as asked, then poll again
24
+ // 5xx, no answer poll again at `interval` — which is also what
25
+ // recovers a LOST 200: the API mints a fresh token
26
+ // for a second success poll inside 120 s and kills
27
+ // the first, so the deck never needs the one it
28
+ // did not receive.
29
+ import { hostname } from "node:os";
30
+
31
+ /** The longest name a device may have (design 3.2). */
32
+ export const DEVICE_NAME_MAX = 48;
33
+
34
+ /** The name a deck offers before anybody has typed one: what LAN sync calls
35
+ * this machine when the user has not said (lan-engine.mjs defaultName) —
36
+ * repeated rather than imported, so the account never loads the LAN engine. */
37
+ export function defaultDeviceName(host = hostname()) {
38
+ return cleanDeviceName(String(host ?? "").replace(/\.local$/i, ""), "this machine");
39
+ }
40
+
41
+ /**
42
+ * A device name as the API will take it: C0 and C1 controls replaced, Unicode
43
+ * format characters (bidi overrides, zero-width marks) removed, whitespace
44
+ * collapsed, at most DEVICE_NAME_MAX characters. The rule lan-sync.mjs
45
+ * cleanName applies to a deck's LAN name, at the account's own length.
46
+ */
47
+ export function cleanDeviceName(raw, fallback = "") {
48
+ if (typeof raw !== "string") return fallback;
49
+ const stripped = raw
50
+ .replace(/[\u0000-\u001f\u007f-\u009f]/g, " ")
51
+ .replace(/\p{Cf}/gu, "")
52
+ .replace(/\s+/g, " ")
53
+ .trim();
54
+ return stripped ? [...stripped].slice(0, DEVICE_NAME_MAX).join("").trim() : fallback;
55
+ }
56
+
57
+ /** A field the API's token pattern takes (design 3.2: os, arch, channel, version). */
58
+ const TOKEN_PATTERN = /^[0-9A-Za-z.+_-]+$/;
59
+ export function deckToken(value, max) {
60
+ const s = String(value ?? "");
61
+ return s && s.length <= max && TOKEN_PATTERN.test(s) ? s : "unknown";
62
+ }
63
+
64
+ /** Whether a URL the API handed back may be opened: https, or http on this
65
+ * machine's loopback when the API itself is a development one there. */
66
+ export function openableUrl(raw) {
67
+ try {
68
+ const url = new URL(raw);
69
+ if (url.username || url.password) return false;
70
+ if (url.protocol === "https:") return true;
71
+ return url.protocol === "http:" && ["127.0.0.1", "localhost", "[::1]"].includes(url.hostname);
72
+ } catch {
73
+ return false;
74
+ }
75
+ }
76
+
77
+ /** The authorize answer, checked: everything the flow needs, or null. */
78
+ export function parseAuthorize(body, at = Date.now()) {
79
+ if (!body || typeof body !== "object") return null;
80
+ const { deviceCode, userCode, verificationUri, verificationUriComplete, expiresIn, interval } = body;
81
+ if (typeof deviceCode !== "string" || !/^ccdc_[A-Za-z0-9_-]{16,128}$/.test(deviceCode)) return null;
82
+ if (typeof userCode !== "string" || !/^[A-Z]{4}-[A-Z]{4}$/.test(userCode)) return null;
83
+ if (!openableUrl(verificationUri) || !openableUrl(verificationUriComplete)) return null;
84
+ if (!Number.isInteger(expiresIn) || expiresIn <= 0 || expiresIn > 3600) return null;
85
+ const every = Number.isInteger(interval) && interval > 0 && interval <= 60 ? interval : 5;
86
+ return {
87
+ deviceCode, userCode, verificationUri, verificationUriComplete,
88
+ expiresAt: at + expiresIn * 1000,
89
+ interval: every,
90
+ };
91
+ }
92
+
93
+ /** The token answer, checked: the fields the deck keeps, or null. */
94
+ export function parseTokenResponse(body) {
95
+ if (!body || typeof body !== "object") return null;
96
+ const { accessToken, deviceId, name, account, settings, status } = body;
97
+ if (typeof accessToken !== "string" || !/^ccdd_[A-Za-z0-9_-]{20,128}$/.test(accessToken)) return null;
98
+ if (typeof deviceId !== "string" || !deviceId) return null;
99
+ if (!account || typeof account.id !== "string" || typeof account.email !== "string") return null;
100
+ return {
101
+ accessToken,
102
+ deviceId,
103
+ name: typeof name === "string" ? name : "",
104
+ account: { id: account.id, email: account.email },
105
+ settings: settings && typeof settings === "object"
106
+ ? {
107
+ mode: settings.mode === "shared" ? "shared" : "independent",
108
+ profileId: typeof settings.profileId === "string" ? settings.profileId : null,
109
+ revision: Number.isInteger(settings.revision) && settings.revision >= 0 ? settings.revision : 0,
110
+ }
111
+ : { mode: "independent", profileId: null, revision: 0 },
112
+ everySec: Number.isInteger(status?.everySec) && status.everySec > 0 ? status.everySec : 15,
113
+ };
114
+ }
115
+
116
+ /**
117
+ * The flow. One connect at a time: starting again cancels the one before, and
118
+ * a poll that lands after a cancel is dropped by its generation.
119
+ *
120
+ * `onApproved(token)` is handed parseTokenResponse's answer, once; it stores
121
+ * the token and starts everything else, and may throw (a store that failed),
122
+ * which ends the flow with `connect-failed`. `onChange()` is told whenever
123
+ * `state()` would answer something new.
124
+ */
125
+ export function createConnectFlow({
126
+ client,
127
+ facts,
128
+ onApproved,
129
+ onChange = () => {},
130
+ now = Date.now,
131
+ setTimer = (fn, ms) => { const t = setTimeout(fn, ms); t.unref?.(); return t; },
132
+ clearTimer = t => clearTimeout(t),
133
+ }) {
134
+ let generation = 0;
135
+ let pending = null; // { deviceCode, userCode, verificationUri, verificationUriComplete, expiresAt, interval }
136
+ let timer = null;
137
+ let problem = null;
138
+
139
+ const state = () => ({
140
+ connecting: pending != null,
141
+ connect: pending ? {
142
+ userCode: pending.userCode,
143
+ verificationUri: pending.verificationUri,
144
+ verificationUriComplete: pending.verificationUriComplete,
145
+ expiresAt: new Date(pending.expiresAt).toISOString(),
146
+ } : null,
147
+ problem,
148
+ });
149
+
150
+ function stop(why = null) {
151
+ generation++;
152
+ if (timer) clearTimer(timer);
153
+ timer = null;
154
+ pending = null;
155
+ problem = why;
156
+ onChange();
157
+ }
158
+
159
+ function schedule(gen, ms) {
160
+ if (timer) clearTimer(timer);
161
+ timer = setTimer(() => { timer = null; void poll(gen); }, ms);
162
+ }
163
+
164
+ async function poll(gen) {
165
+ if (gen !== generation || !pending) return;
166
+ if (now() >= pending.expiresAt) return stop("connect-expired");
167
+ const res = await client.post("/v1/device/token", { deviceCode: pending.deviceCode });
168
+ if (gen !== generation || !pending) return;
169
+ if (res.ok) {
170
+ const token = parseTokenResponse(res.body);
171
+ if (!token) return schedule(gen, pending.interval * 1000);
172
+ // Stop polling BEFORE handing the token on: an approval is delivered
173
+ // once, and a second success poll would mint a new token and kill this.
174
+ generation++;
175
+ pending = null;
176
+ try {
177
+ await onApproved(token);
178
+ problem = null;
179
+ } catch {
180
+ problem = "connect-failed";
181
+ }
182
+ return onChange();
183
+ }
184
+ if (res.network || res.status >= 500) return schedule(gen, pending.interval * 1000);
185
+ if (res.status === 429) return schedule(gen, res.retryAfterMs ?? pending.interval * 1000);
186
+ if (res.status === 401 || res.status === 404) return stop("api-disabled");
187
+ const interval = Number.isInteger(res.body?.interval) && res.body.interval > 0 ? res.body.interval : null;
188
+ switch (res.error) {
189
+ case "authorization_pending":
190
+ if (interval) pending.interval = interval;
191
+ return schedule(gen, pending.interval * 1000);
192
+ case "slow_down":
193
+ pending.interval = interval ?? pending.interval + 5;
194
+ return schedule(gen, pending.interval * 1000);
195
+ case "access_denied": return stop("connect-denied");
196
+ case "expired_token": return stop("connect-expired");
197
+ default: return stop("connect-failed");
198
+ }
199
+ }
200
+
201
+ /** Ask the API for a code. Resolves when the code is in hand (or refused);
202
+ * the approval arrives later, through `onApproved`. */
203
+ async function start(name) {
204
+ stop(null);
205
+ const gen = generation;
206
+ const res = await client.post("/v1/device/authorize", {
207
+ name, os: facts.os, arch: facts.arch, version: facts.version, channel: facts.channel,
208
+ });
209
+ if (gen !== generation) return state();
210
+ if (!res.ok) {
211
+ problem = res.network ? "offline"
212
+ : res.status === 401 || res.status === 404 ? "api-disabled"
213
+ : res.status === 429 ? "rate-limited"
214
+ : "connect-failed";
215
+ onChange();
216
+ return state();
217
+ }
218
+ const code = parseAuthorize(res.body, now());
219
+ if (!code) {
220
+ problem = "connect-failed";
221
+ onChange();
222
+ return state();
223
+ }
224
+ pending = code;
225
+ problem = null;
226
+ schedule(gen, code.interval * 1000);
227
+ onChange();
228
+ return state();
229
+ }
230
+
231
+ return {
232
+ start,
233
+ cancel: () => stop(null),
234
+ state,
235
+ /** For the suite: poll now rather than after the interval. */
236
+ pollNow: () => poll(generation),
237
+ };
238
+ }