ccdeck 3.53.3 → 3.80.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 (58) hide show
  1. package/README.md +55 -3
  2. package/THIRD_PARTY_NOTICES.md +31 -1
  3. package/dist/web/assets/{BrowserWatchModal-CJ0CW4Go.js → BrowserWatchModal-Bfvo_8H6.js} +1 -1
  4. package/dist/web/assets/{IntegrationModal-DlJzBN8b.js → IntegrationModal-GS5jIQ_J.js} +1 -1
  5. package/dist/web/assets/{RadioPanel-CHl3s3OH.js → RadioPanel-Bxd2ElWb.js} +1 -1
  6. package/dist/web/assets/{TrafficRadar-Cw3i0Hux.js → TrafficRadar-FgHBI2Oh.js} +1 -1
  7. package/dist/web/assets/{UsageHistoryModal-CiB5-CTH.js → UsageHistoryModal-APwKtE2J.js} +1 -1
  8. package/dist/web/assets/{app-2vj7uk2U.js → app-BzHVsgB2.js} +69 -69
  9. package/dist/web/assets/{index-D1YZbdq3.js → index-7whwMaPX.js} +1 -1
  10. package/dist/web/index.html +2 -2
  11. package/node_modules/ws/LICENSE +20 -0
  12. package/node_modules/ws/README.md +540 -0
  13. package/node_modules/ws/browser.js +8 -0
  14. package/node_modules/ws/index.js +22 -0
  15. package/node_modules/ws/lib/buffer-util.js +142 -0
  16. package/node_modules/ws/lib/constants.js +19 -0
  17. package/node_modules/ws/lib/event-target.js +292 -0
  18. package/node_modules/ws/lib/extension.js +203 -0
  19. package/node_modules/ws/lib/limiter.js +55 -0
  20. package/node_modules/ws/lib/permessage-deflate.js +530 -0
  21. package/node_modules/ws/lib/receiver.js +743 -0
  22. package/node_modules/ws/lib/sender.js +610 -0
  23. package/node_modules/ws/lib/stream.js +161 -0
  24. package/node_modules/ws/lib/subprotocol.js +62 -0
  25. package/node_modules/ws/lib/validation.js +152 -0
  26. package/node_modules/ws/lib/websocket-server.js +562 -0
  27. package/node_modules/ws/lib/websocket.js +1426 -0
  28. package/node_modules/ws/package.json +74 -0
  29. package/node_modules/ws/wrapper.mjs +21 -0
  30. package/package.json +5 -3
  31. package/release-notes.json +37 -0
  32. package/src/server/account-engine.mjs +87 -0
  33. package/src/server/account-routes.mjs +31 -3
  34. package/src/server/codex-auto.mjs +7 -18
  35. package/src/server/codex-engine-adapter.mjs +272 -0
  36. package/src/server/codex-engine-bridge.mjs +47 -0
  37. package/src/server/codex-engine-config.mjs +42 -0
  38. package/src/server/codex-engine-rpc.mjs +88 -0
  39. package/src/server/codex-handoff.mjs +20 -0
  40. package/src/server/codex-interactive-engine.mjs +335 -0
  41. package/src/server/codex-live-checkpoint.mjs +55 -0
  42. package/src/server/codex-live-credentials.mjs +214 -0
  43. package/src/server/codex-live-engine.mjs +577 -0
  44. package/src/server/codex-live-handoff.mjs +300 -0
  45. package/src/server/codex-live-lease.mjs +64 -0
  46. package/src/server/codex-live-rpc.mjs +155 -0
  47. package/src/server/codex-quota.mjs +36 -2
  48. package/src/server/codex-selection.mjs +62 -8
  49. package/src/server/codex-share.mjs +193 -0
  50. package/src/server/codex-terminal-runner.mjs +38 -1
  51. package/src/server/codex-terminal.mjs +15 -3
  52. package/src/server/codex-watch.mjs +3 -1
  53. package/src/server/codex-windows-private.mjs +96 -0
  54. package/src/server/codex-windows-private.ps1 +140 -0
  55. package/src/server/codex-windows-proxy.mjs +53 -0
  56. package/src/server/index.mjs +7 -1
  57. package/src/server/login-service.mjs +2 -0
  58. package/src/server/pinned-build.mjs +2 -0
@@ -0,0 +1,140 @@
1
+ param(
2
+ [ValidateSet('ensure','check','hold')][string]$Operation,
3
+ [Parameter(Mandatory=$true)][string]$TargetPath,
4
+ [ValidateSet('directory','file','socket')][string]$Kind = 'directory'
5
+ )
6
+ $ErrorActionPreference = 'Stop'
7
+ try {
8
+ # Fixed source only. Paths arrive via -File arguments, never interpolation.
9
+ Microsoft.PowerShell.Utility\Add-Type -TypeDefinition @'
10
+ using System;
11
+ using System.IO;
12
+ using System.Runtime.InteropServices;
13
+ using System.Security.AccessControl;
14
+ using System.Security.Principal;
15
+ using System.Text;
16
+ using Microsoft.Win32.SafeHandles;
17
+ public static class CodexPrivatePath {
18
+ [StructLayout(LayoutKind.Sequential)] struct SecurityAttributes {
19
+ public int Length; public IntPtr Descriptor; public int Inherit;
20
+ }
21
+ [StructLayout(LayoutKind.Sequential)] struct FileInfo {
22
+ public uint Attributes; public System.Runtime.InteropServices.ComTypes.FILETIME Created, Accessed, Written;
23
+ public uint Volume, SizeHigh, SizeLow, Links, IndexHigh, IndexLow;
24
+ }
25
+ [DllImport("kernel32.dll", CharSet=CharSet.Unicode, SetLastError=true)]
26
+ static extern SafeFileHandle CreateFileW(string p, uint access, uint share, IntPtr sa, uint creation, uint flags, IntPtr template);
27
+ [DllImport("kernel32.dll", CharSet=CharSet.Unicode, SetLastError=true)]
28
+ static extern bool CreateDirectoryW(string p, ref SecurityAttributes sa);
29
+ [DllImport("kernel32.dll", SetLastError=true)]
30
+ static extern bool GetFileInformationByHandle(SafeFileHandle h, out FileInfo info);
31
+ [StructLayout(LayoutKind.Sequential)] struct AttributeTagInfo { public uint Attributes, Tag; }
32
+ [DllImport("kernel32.dll", SetLastError=true)]
33
+ static extern bool GetFileInformationByHandleEx(SafeFileHandle h, int type, out AttributeTagInfo info, uint size);
34
+ [DllImport("kernel32.dll", CharSet=CharSet.Unicode, SetLastError=true)]
35
+ static extern uint GetFinalPathNameByHandleW(SafeFileHandle h, StringBuilder b, uint size, uint flags);
36
+ [DllImport("advapi32.dll", SetLastError=true)]
37
+ static extern uint GetSecurityInfo(SafeFileHandle h, uint type, uint what, out IntPtr owner, out IntPtr group, out IntPtr dacl, out IntPtr sacl, out IntPtr descriptor);
38
+ [DllImport("advapi32.dll")] static extern uint GetSecurityDescriptorLength(IntPtr sd);
39
+ [DllImport("kernel32.dll")] static extern IntPtr LocalFree(IntPtr p);
40
+ static void Require(bool valid) { if (!valid) throw new IOException("unsafe"); }
41
+ public static string Canonical(SafeFileHandle h) {
42
+ var b = new StringBuilder(32768);
43
+ uint length = GetFinalPathNameByHandleW(h, b, (uint)b.Capacity, 0);
44
+ Require(length > 0 && length < b.Capacity);
45
+ return b.ToString();
46
+ }
47
+ public static SafeFileHandle Open(string path, bool directory) {
48
+ // OPEN_REPARSE_POINT prevents following a substituted final link. Listing
49
+ // access makes omission of SHARE_DELETE actually pin a directory on Windows.
50
+ var h = CreateFileW(path, 0x20000u | 0x80u | 1u, directory ? 3u : 1u,
51
+ IntPtr.Zero, 3, 0x02000000u | 0x00200000u, IntPtr.Zero);
52
+ if (h.IsInvalid) { h.Dispose(); throw new IOException("unsafe"); }
53
+ try {
54
+ FileInfo info;
55
+ Require(GetFileInformationByHandle(h, out info));
56
+ Require((info.Attributes & 0x400u) == 0 && ((info.Attributes & 0x10u) != 0) == directory);
57
+ if (!directory) Require(info.Links == 1);
58
+ ValidateAcl(h, directory);
59
+ return h;
60
+ } catch { h.Dispose(); throw; }
61
+ }
62
+ static void ValidateAcl(SafeFileHandle h, bool directory) {
63
+ IntPtr owner, group, dacl, sacl, descriptor;
64
+ Require(GetSecurityInfo(h, 1, 5, out owner, out group, out dacl, out sacl, out descriptor) == 0);
65
+ try {
66
+ Require(owner != IntPtr.Zero && dacl != IntPtr.Zero);
67
+ var bytes = new byte[GetSecurityDescriptorLength(descriptor)];
68
+ Marshal.Copy(descriptor, bytes, 0, bytes.Length);
69
+ var sd = new RawSecurityDescriptor(bytes, 0);
70
+ var user = WindowsIdentity.GetCurrent().User;
71
+ Require(sd.Owner == user && sd.DiscretionaryAcl != null && sd.DiscretionaryAcl.Count > 0);
72
+ if (directory) Require((sd.ControlFlags & ControlFlags.DiscretionaryAclProtected) != 0);
73
+ bool userAccess = false;
74
+ foreach (GenericAce entry in sd.DiscretionaryAcl) {
75
+ var ace = entry as CommonAce;
76
+ Require(ace != null && !ace.IsCallback && ace.AceQualifier == AceQualifier.AccessAllowed);
77
+ Require(ace.SecurityIdentifier == user || ace.SecurityIdentifier.Value == "S-1-5-18");
78
+ if (ace.SecurityIdentifier == user && (ace.AceFlags & AceFlags.InheritOnly) == 0 && (ace.AccessMask & 0x1f01ff) == 0x1f01ff) {
79
+ if (directory) Require((ace.AceFlags & (AceFlags.ContainerInherit | AceFlags.ObjectInherit)) == (AceFlags.ContainerInherit | AceFlags.ObjectInherit));
80
+ userAccess = true;
81
+ }
82
+ }
83
+ Require(userAccess);
84
+ } finally { if (descriptor != IntPtr.Zero) LocalFree(descriptor); }
85
+ }
86
+ public static string SocketGeneration(string path) {
87
+ // Node/libuv lstat returns EACCES on Windows AF_UNIX entries. Open only
88
+ // reparse metadata, never follow a symlink/junction or read socket bytes.
89
+ using (var h = CreateFileW(path, 0x80u, 3, IntPtr.Zero, 3, 0x00200000u | 0x02000000u, IntPtr.Zero)) {
90
+ Require(!h.IsInvalid);
91
+ AttributeTagInfo tag; FileInfo info;
92
+ Require(GetFileInformationByHandleEx(h, 9, out tag, (uint)Marshal.SizeOf(typeof(AttributeTagInfo))));
93
+ Require((tag.Attributes & 0x400u) != 0 && tag.Tag == 0x80000023u && (tag.Attributes & 0x10u) == 0);
94
+ Require(GetFileInformationByHandle(h, out info));
95
+ return info.Volume + ":" + info.IndexHigh + ":" + info.IndexLow + ":" + (uint)info.Created.dwHighDateTime + ":" + (uint)info.Created.dwLowDateTime;
96
+ }
97
+ }
98
+ public static void Ensure(string path) {
99
+ // The security descriptor is supplied to creation, never applied afterwards.
100
+ var user = WindowsIdentity.GetCurrent().User;
101
+ var sd = new RawSecurityDescriptor("O:" + user.Value + "D:P(A;OICI;FA;;;" + user.Value + ")");
102
+ var bytes = new byte[sd.BinaryLength]; sd.GetBinaryForm(bytes, 0);
103
+ var pinned = GCHandle.Alloc(bytes, GCHandleType.Pinned);
104
+ try {
105
+ var sa = new SecurityAttributes { Length = Marshal.SizeOf(typeof(SecurityAttributes)), Descriptor = pinned.AddrOfPinnedObject(), Inherit = 0 };
106
+ if (!CreateDirectoryW(path, ref sa)) Require(Marshal.GetLastWin32Error() == 183);
107
+ } finally { pinned.Free(); }
108
+ }
109
+ }
110
+ '@
111
+ $guards = [System.Collections.Generic.List[System.IDisposable]]::new()
112
+ try {
113
+ $path = [IO.Path]::GetFullPath($TargetPath)
114
+ if ($Operation -eq 'ensure') {
115
+ if ($Kind -ne 'directory') { throw 'unsafe' }
116
+ [CodexPrivatePath]::Ensure($path)
117
+ }
118
+ if ($Kind -eq 'directory') {
119
+ $guard = [CodexPrivatePath]::Open($path, $true)
120
+ $guards.Add($guard)
121
+ $canonical = [CodexPrivatePath]::Canonical($guard)
122
+ } else {
123
+ $parent = [CodexPrivatePath]::Open([IO.Path]::GetDirectoryName($path), $true)
124
+ $guards.Add($parent)
125
+ $canonical = [IO.Path]::Combine([CodexPrivatePath]::Canonical($parent), [IO.Path]::GetFileName($path))
126
+ if ($Kind -eq 'file') {
127
+ $guard = [CodexPrivatePath]::Open($canonical, $false)
128
+ $guards.Add($guard)
129
+ $canonical = [CodexPrivatePath]::Canonical($guard)
130
+ } else {
131
+ $generation = [CodexPrivatePath]::SocketGeneration($canonical)
132
+ }
133
+ }
134
+ $result = @{ path = $canonical }
135
+ if ($Kind -eq 'socket') { $result.generation = $generation }
136
+ [Console]::Out.WriteLine(($result | Microsoft.PowerShell.Utility\ConvertTo-Json -Compress))
137
+ [Console]::Out.Flush()
138
+ if ($Operation -eq 'hold') { $null = [Console]::In.ReadLine() }
139
+ } finally { foreach ($guard in $guards) { $guard.Dispose() } }
140
+ } catch { [Console]::Error.WriteLine('windows_private_path_unsafe'); exit 1 }
@@ -0,0 +1,53 @@
1
+ // Codex 0.166's Windows endpoint is AF_UNIX, not a named pipe. Its official
2
+ // app-server proxy relays raw bytes, including the WebSocket HTTP handshake.
3
+ import { Duplex } from 'node:stream';
4
+ import { execFile, spawn } from 'node:child_process';
5
+ import { win32 } from 'node:path';
6
+ import { spawnSpec } from './exec-spec.mjs';
7
+
8
+ const disconnected = () => Object.assign(new Error('native_disconnected'), { code: 'native_disconnected' });
9
+ export function createCodexWindowsProxy(endpoint, options = {}) {
10
+ const env = { ...(options.env ?? process.env), CODEX_HOME: endpoint.home };
11
+ for (const key of Object.keys(env)) if (/^(OPENAI_API_KEY|CODEX_API_KEY)$/i.test(key)) delete env[key];
12
+ const spec = spawnSpec(endpoint.executable, ['app-server', 'proxy', '--sock', endpoint.socketPath], options.platform ?? process.platform);
13
+ const child = (options.spawnChild ?? spawn)(spec.file, spec.args,
14
+ { ...spec.opts, env, windowsHide: true, shell: false, stdio: ['pipe', 'pipe', 'ignore'] });
15
+ let timer, stopped = false;
16
+ const stream = new Duplex({
17
+ read() { child.stdout.resume(); },
18
+ write(data, encoding, done) { child.stdin.write(data, encoding, error => done(error ? disconnected() : null)); },
19
+ final(done) { child.stdin.end(done); },
20
+ destroy(error, done) {
21
+ clearTimeout(timer);
22
+ if (!stopped) {
23
+ stopped = true;
24
+ if (child.exitCode === null && child.signalCode === null) {
25
+ if ((options.platform ?? process.platform) === 'win32' && child.pid) {
26
+ // npm's .cmd/JS wrapper may own a child proxy. Stop this process tree
27
+ // only; never call daemon stop or target an advertised daemon PID.
28
+ const taskkill = win32.join(process.env.SystemRoot ?? 'C:\\Windows', 'System32', 'taskkill.exe');
29
+ (options.execFile ?? execFile)(taskkill, ['/PID', String(child.pid), '/T', '/F'],
30
+ { timeout: 2000, windowsHide: true, shell: false, maxBuffer: 4096 }, () => {});
31
+ } else child.kill();
32
+ }
33
+ child.stdin.destroy(); child.stdout.destroy();
34
+ }
35
+ done(error);
36
+ },
37
+ });
38
+ // HTTP/ws accept a Duplex but expect the small net.Socket tuning interface.
39
+ stream.setNoDelay = stream.setKeepAlive = () => stream;
40
+ stream.setTimeout = (ms, callback) => {
41
+ clearTimeout(timer);
42
+ if (callback) stream.once('timeout', callback);
43
+ if (ms) timer = setTimeout(() => stream.emit('timeout'), ms);
44
+ return stream;
45
+ };
46
+ child.stdout.on('data', data => { if (!stream.push(data)) child.stdout.pause(); });
47
+ child.stdout.on('end', () => stream.push(null));
48
+ child.stdout.on('error', () => stream.destroy(disconnected()));
49
+ child.stdin.on('error', () => stream.destroy(disconnected()));
50
+ child.on('error', () => stream.destroy(disconnected()));
51
+ child.on('exit', () => stream.destroy(disconnected()));
52
+ return stream;
53
+ }
@@ -164,7 +164,7 @@ export { sendInternalError };
164
164
  // The accounts surface's routes — see account-routes.mjs. The boot wires the
165
165
  // stale-copy repair and starts auto-switch through the same module.
166
166
  import { handleStopContinue, handleStopContinueRead } from "./stop-continue.mjs";
167
- import { cswapAutoModule, getProjectRollup, handleAccountLoginState, handleAccountProjects, handleClaudeAccountAdmin, handleClaudeAccountSwitch, handleClaudeAccounts, handleCodexProfiles, handleCodexProfileQuota, handleCodexProfileLaunch, handleCodexProfileMutation, handleCodexProfileLogin, handleCodexProfileLoginFlow, handleCodexTerminalCommand, handleCodexAuto, handleCodexAutoAction, handleCswapAuto, handleCswapAutoAction, wireAccountOrigins, wireStaleCopyRepair } from "./account-routes.mjs";
167
+ import { cswapAutoModule, getProjectRollup, handleAccountLoginState, handleAccountProjects, handleClaudeAccountAdmin, handleClaudeAccountSwitch, handleClaudeAccounts, handleCodexProfiles, handleCodexAccountShare, handleCodexProfileQuota, handleCodexProfileLaunch, handleCodexProfileMutation, handleCodexProfileLogin, handleCodexProfileLoginFlow, handleCodexTerminalCommand, handleCodexAuto, handleCodexAutoAction, handleCswapAuto, handleCswapAutoAction, wireAccountOrigins, wireStaleCopyRepair } from "./account-routes.mjs";
168
168
  // Browser Watch's three routes — see browser-watch-routes.mjs.
169
169
  import { handleBrowserWatch, handleBrowserWatchDismiss, handleBrowserWatchSettings } from "./browser-watch-routes.mjs";
170
170
  // The music routes, every one behind AGENTS_DECK_NO_MUSIC — see music-routes.mjs.
@@ -407,6 +407,8 @@ export async function startServer({ port = 4317, host = "127.0.0.1", persist = n
407
407
  if (req.method === "GET" && url.pathname === "/api/codex-profile-launch") return guard(handleCodexProfileLaunch(req, res), res);
408
408
  if (req.method === "GET" && url.pathname === "/api/codex-auto") return guard(handleCodexAuto(req, res), res);
409
409
  if (req.method === "POST" && url.pathname === "/api/codex-auto") return guard(handleCodexAutoAction(req, res), res);
410
+ if (req.method === "POST" && url.pathname === "/api/codex-accounts-share") return guard(handleCodexAccountShare(req, res, "export"), res);
411
+ if (req.method === "POST" && url.pathname === "/api/codex-accounts-import") return guard(handleCodexAccountShare(req, res, "import"), res);
410
412
  if (req.method === "POST" && url.pathname === "/api/codex-profile-select") return guard(handleCodexProfileMutation(req, res, "select"), res);
411
413
  if (req.method === "POST" && url.pathname === "/api/codex-profile-add") return guard(handleCodexProfileMutation(req, res, "add"), res);
412
414
  if (req.method === "POST" && url.pathname === "/api/codex-profile-remove") return guard(handleCodexProfileMutation(req, res, "remove"), res);
@@ -563,6 +565,10 @@ export async function startServer({ port = 4317, host = "127.0.0.1", persist = n
563
565
  if (codex) {
564
566
  startCodexWatcher(workspace);
565
567
  server.once("close", stopCodexEnrichment);
568
+ const liveOptions = { env: { ...process.env } };
569
+ const liveAccounts = await import("./codex-live-engine.mjs");
570
+ liveAccounts.startCodexLiveAccounts(liveOptions);
571
+ server.once("close", () => { void liveAccounts.stopCodexLiveAccounts(liveOptions); });
566
572
  }
567
573
  if (claude) {
568
574
  const recovery = createClaudeRecovery({ workspace });
@@ -409,6 +409,8 @@ export const SETTING_VARS = Object.freeze([
409
409
  // Radar's off switch (index.mjs). A deck started at login without it would
410
410
  // look for Claude Code's collector and capture it.
411
411
  "AGENTS_DECK_NO_RADAR",
412
+ // Keep native Codex account control disabled after a login-service restart.
413
+ "AGENTS_DECK_NO_CODEX_LIVE",
412
414
  ]);
413
415
 
414
416
  export function settingsEnv(env = process.env) {
@@ -64,6 +64,8 @@ const PINNED_MODULES = [
64
64
  "codex-terminal.mjs",
65
65
  "codex-native-account.mjs",
66
66
  "codex-auto.mjs",
67
+ "codex-profiles.mjs", "codex-selection.mjs", "codex-live-engine.mjs",
68
+ "codex-share.mjs", "codex-login.mjs",
67
69
  "ccusage.mjs",
68
70
  "browser-watch.mjs",
69
71
  "browser-watch-store.mjs",