ccdeck 3.53.2 → 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.
- package/README.md +56 -4
- package/THIRD_PARTY_NOTICES.md +31 -1
- package/dist/web/assets/{BrowserWatchModal-DedhCY8E.js → BrowserWatchModal-Bfvo_8H6.js} +1 -1
- package/dist/web/assets/{IntegrationModal-1m1mQQhW.js → IntegrationModal-GS5jIQ_J.js} +1 -1
- package/dist/web/assets/{RadioPanel-Sgo5WNTi.js → RadioPanel-Bxd2ElWb.js} +1 -1
- package/dist/web/assets/{TrafficRadar-BqjzLlO_.js → TrafficRadar-FgHBI2Oh.js} +1 -1
- package/dist/web/assets/{UsageHistoryModal-2pcftBwX.js → UsageHistoryModal-APwKtE2J.js} +1 -1
- package/dist/web/assets/{app-BZaB84m4.js → app-BzHVsgB2.js} +90 -90
- package/dist/web/assets/{index-D1WZBFCw.js → index-7whwMaPX.js} +1 -1
- package/dist/web/index.html +2 -2
- package/node_modules/ws/LICENSE +20 -0
- package/node_modules/ws/README.md +540 -0
- package/node_modules/ws/browser.js +8 -0
- package/node_modules/ws/index.js +22 -0
- package/node_modules/ws/lib/buffer-util.js +142 -0
- package/node_modules/ws/lib/constants.js +19 -0
- package/node_modules/ws/lib/event-target.js +292 -0
- package/node_modules/ws/lib/extension.js +203 -0
- package/node_modules/ws/lib/limiter.js +55 -0
- package/node_modules/ws/lib/permessage-deflate.js +530 -0
- package/node_modules/ws/lib/receiver.js +743 -0
- package/node_modules/ws/lib/sender.js +610 -0
- package/node_modules/ws/lib/stream.js +161 -0
- package/node_modules/ws/lib/subprotocol.js +62 -0
- package/node_modules/ws/lib/validation.js +152 -0
- package/node_modules/ws/lib/websocket-server.js +562 -0
- package/node_modules/ws/lib/websocket.js +1426 -0
- package/node_modules/ws/package.json +74 -0
- package/node_modules/ws/wrapper.mjs +21 -0
- package/package.json +5 -3
- package/release-notes.json +39 -1
- package/src/server/account-engine.mjs +87 -0
- package/src/server/account-routes.mjs +31 -3
- package/src/server/codex-auto.mjs +7 -18
- package/src/server/codex-engine-adapter.mjs +272 -0
- package/src/server/codex-engine-bridge.mjs +47 -0
- package/src/server/codex-engine-config.mjs +42 -0
- package/src/server/codex-engine-rpc.mjs +88 -0
- package/src/server/codex-handoff.mjs +20 -0
- package/src/server/codex-interactive-engine.mjs +335 -0
- package/src/server/codex-live-checkpoint.mjs +55 -0
- package/src/server/codex-live-credentials.mjs +214 -0
- package/src/server/codex-live-engine.mjs +577 -0
- package/src/server/codex-live-handoff.mjs +300 -0
- package/src/server/codex-live-lease.mjs +64 -0
- package/src/server/codex-live-rpc.mjs +155 -0
- package/src/server/codex-quota.mjs +36 -2
- package/src/server/codex-selection.mjs +62 -8
- package/src/server/codex-share.mjs +193 -0
- package/src/server/codex-terminal-runner.mjs +38 -1
- package/src/server/codex-terminal.mjs +15 -3
- package/src/server/codex-watch.mjs +3 -1
- package/src/server/codex-windows-private.mjs +96 -0
- package/src/server/codex-windows-private.ps1 +140 -0
- package/src/server/codex-windows-proxy.mjs +53 -0
- package/src/server/deck-prefs.mjs +6 -1
- package/src/server/index.mjs +9 -2
- package/src/server/login-service.mjs +2 -0
- package/src/server/pinned-build.mjs +2 -0
- package/src/server/reports-routes.mjs +10 -0
- package/src/server/reports.mjs +46 -5
- package/src/server/ui-language.mjs +17 -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
|
+
}
|
|
@@ -49,6 +49,7 @@ import { normaliseOrigins } from "./account-origins.mjs";
|
|
|
49
49
|
import { normaliseUsage } from "./usage-day.mjs";
|
|
50
50
|
import { refSlug } from "./install-ref.mjs";
|
|
51
51
|
import { normaliseRating } from "./rating.mjs";
|
|
52
|
+
import { uiLanguageCode } from "./ui-language.mjs";
|
|
52
53
|
|
|
53
54
|
/** Set to "1" to keep the deck off the desktop whatever the stored preference
|
|
54
55
|
* says. Same sheet of switches as AGENTS_DECK_NO_DOWNLOAD and
|
|
@@ -121,11 +122,14 @@ export const DEFAULTS = Object.freeze({
|
|
|
121
122
|
// `firstSessionAt`/`firstProvider`/`activationSent` the install's first
|
|
122
123
|
// session and whether the "activated" event saying so got through — the times
|
|
123
124
|
// stay here, only a bucket leaves (activation.mjs); `rating` is the one
|
|
124
|
-
// question the deck asks about itself, answered or put off (rating.mjs)
|
|
125
|
+
// question the deck asks about itself, answered or put off (rating.mjs);
|
|
126
|
+
// `uiLanguage` is the language the page said it is showing, for the reports
|
|
127
|
+
// (ui-language.mjs).
|
|
125
128
|
report: Object.freeze({
|
|
126
129
|
installId: "", lastVersion: "", lastActiveDay: "", forget: "", usage: null,
|
|
127
130
|
installedAt: "", firstSessionAt: "", firstProvider: "", activationSent: false,
|
|
128
131
|
rating: Object.freeze(normaliseRating(null)),
|
|
132
|
+
uiLanguage: "",
|
|
129
133
|
}),
|
|
130
134
|
// The accounts this deck signed in itself, and the re-sign-in prompts
|
|
131
135
|
// somebody put off (#1893) — keyed by account identity, written by the deck
|
|
@@ -379,6 +383,7 @@ function normaliseReport(raw) {
|
|
|
379
383
|
ref: refSlug(src.ref) ?? "",
|
|
380
384
|
selfUpdate: selfUpdateMarker(src.selfUpdate),
|
|
381
385
|
rating: normaliseRating(src.rating),
|
|
386
|
+
uiLanguage: uiLanguageCode(src.uiLanguage),
|
|
382
387
|
};
|
|
383
388
|
}
|
|
384
389
|
|
package/src/server/index.mjs
CHANGED
|
@@ -151,7 +151,7 @@ import { handlePrefsGiveBack, handlePrefsRead, handlePrefsWrite } from "./prefs-
|
|
|
151
151
|
// Usage reports and the feedback dialog (#1853). The requests to
|
|
152
152
|
// api.ccdeck.dev are made in reports.mjs, never in this file.
|
|
153
153
|
import {
|
|
154
|
-
handleClientError, handleFeedback, handleFeedbackFacts, handleRatingRead, handleRatingWrite, handleReportsWrite,
|
|
154
|
+
handleClientError, handleFeedback, handleFeedbackFacts, handleRatingRead, handleRatingWrite, handleReportsWrite, handleUiLanguageWrite,
|
|
155
155
|
} from "./reports-routes.mjs";
|
|
156
156
|
import { reporter } from "./reports.mjs";
|
|
157
157
|
import { MANIFEST_PATH, offerManifest } from "./app-manifest.mjs";
|
|
@@ -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.
|
|
@@ -348,6 +348,7 @@ export async function startServer({ port = 4317, host = "127.0.0.1", persist = n
|
|
|
348
348
|
if (req.method === "POST" && url.pathname === "/api/prefs") return guard(handlePrefsWrite(req, res), res);
|
|
349
349
|
if (req.method === "POST" && url.pathname === "/api/prefs/give-back") return guard(handlePrefsGiveBack(req, res), res);
|
|
350
350
|
if (req.method === "POST" && url.pathname === "/api/reports") return guard(handleReportsWrite(req, res), res);
|
|
351
|
+
if (req.method === "POST" && url.pathname === "/api/ui-language") return guard(handleUiLanguageWrite(req, res), res);
|
|
351
352
|
if (req.method === "GET" && url.pathname === "/api/feedback") return handleFeedbackFacts(req, res);
|
|
352
353
|
if (req.method === "POST" && url.pathname === "/api/feedback") return guard(handleFeedback(req, res), res);
|
|
353
354
|
if (req.method === "POST" && url.pathname === "/api/client-error") return guard(handleClientError(req, res), res);
|
|
@@ -406,6 +407,8 @@ export async function startServer({ port = 4317, host = "127.0.0.1", persist = n
|
|
|
406
407
|
if (req.method === "GET" && url.pathname === "/api/codex-profile-launch") return guard(handleCodexProfileLaunch(req, res), res);
|
|
407
408
|
if (req.method === "GET" && url.pathname === "/api/codex-auto") return guard(handleCodexAuto(req, res), res);
|
|
408
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);
|
|
409
412
|
if (req.method === "POST" && url.pathname === "/api/codex-profile-select") return guard(handleCodexProfileMutation(req, res, "select"), res);
|
|
410
413
|
if (req.method === "POST" && url.pathname === "/api/codex-profile-add") return guard(handleCodexProfileMutation(req, res, "add"), res);
|
|
411
414
|
if (req.method === "POST" && url.pathname === "/api/codex-profile-remove") return guard(handleCodexProfileMutation(req, res, "remove"), res);
|
|
@@ -562,6 +565,10 @@ export async function startServer({ port = 4317, host = "127.0.0.1", persist = n
|
|
|
562
565
|
if (codex) {
|
|
563
566
|
startCodexWatcher(workspace);
|
|
564
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); });
|
|
565
572
|
}
|
|
566
573
|
if (claude) {
|
|
567
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",
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { reportsVetoed } from "./deck-prefs.mjs";
|
|
7
7
|
import { MAX_REQUEST_BYTES, isMultipart, readFeedbackForm, upstreamForm } from "./feedback-form.mjs";
|
|
8
8
|
import { readBody, readBytes, send } from "./http-io.mjs";
|
|
9
|
+
import { uiLanguageCode } from "./ui-language.mjs";
|
|
9
10
|
import { heldPrefs } from "./prefs-state.mjs";
|
|
10
11
|
import { REPORTS_API, deviceIdToken, installFacts, reporter, reportsOn } from "./reports.mjs";
|
|
11
12
|
|
|
@@ -28,6 +29,15 @@ export async function handleReportsWrite(req, res, { report = reporter } = {}) {
|
|
|
28
29
|
return send(res, 200, { ok: true, reports: heldPrefs.current().reports, reportsVetoed: reportsVetoed() });
|
|
29
30
|
}
|
|
30
31
|
|
|
32
|
+
/** `POST /api/ui-language` `{ code }`: the language the page is showing, kept for
|
|
33
|
+
* the usage reports (ui-language.mjs). Best effort: 400 for a code that is not
|
|
34
|
+
* a language tag, 200 `{ kept }` otherwise (not kept with reports off). */
|
|
35
|
+
export async function handleUiLanguageWrite(req, res, { report = reporter } = {}) {
|
|
36
|
+
const body = await readJson(req, res, 1_000);
|
|
37
|
+
if (!uiLanguageCode(body?.code)) return send(res, 400, { ok: false, reason: "bad_request" });
|
|
38
|
+
return send(res, 200, { ok: true, kept: await report.setUiLanguage(body.code) });
|
|
39
|
+
}
|
|
40
|
+
|
|
31
41
|
/** `GET /api/rating`: whether the page should ask "How useful is ccdeck to
|
|
32
42
|
* you?" now (rating.mjs says when). Nothing leaves the machine. */
|
|
33
43
|
export function handleRatingRead(_req, res, { report = reporter } = {}) {
|
package/src/server/reports.mjs
CHANGED
|
@@ -53,7 +53,10 @@
|
|
|
53
53
|
// Each event carries the install id, the version, the OS and CPU architecture,
|
|
54
54
|
// the channel (the desktop app, npm, or a source checkout) and the runtime, plus
|
|
55
55
|
// a coarse sketch of the environment: the logical CPU count, the RAM in MB, the
|
|
56
|
-
// locale, the
|
|
56
|
+
// locale, the language chosen in the deck's own page (`uiLanguage`, "ro" or
|
|
57
|
+
// "pt-BR": the page tells the server, which keeps it in prefs.json and omits it
|
|
58
|
+
// until a page has said it; never on the ping, errors or feedback), the shell
|
|
59
|
+
// and terminal names, and the Claude Code and Codex CLI
|
|
57
60
|
// versions — and, on install, update, active and activated, what the boot set
|
|
58
61
|
// up: whether the Claude hooks went in ("ok", "failed", "off") and whether
|
|
59
62
|
// Codex is watched ("on", "off"). Every one of those is a small fixed token or
|
|
@@ -104,6 +107,7 @@ import { RUNNING_VERSION } from "./running-version.mjs";
|
|
|
104
107
|
import { FEATURES, usageDay, utcDay } from "./usage-day.mjs";
|
|
105
108
|
import { setupFacts, sinceInstallBucket, whenSetupKnown } from "./activation.mjs";
|
|
106
109
|
import { notedRef, refSlug } from "./install-ref.mjs";
|
|
110
|
+
import { UI_LANGUAGE_MAX, uiLanguageCode } from "./ui-language.mjs";
|
|
107
111
|
import {
|
|
108
112
|
CLAUDE_PLANS, CODEX_PLANS, cappedCount, deckDepth, eventsBucket, launchBucket, memoryBucket, updateVia,
|
|
109
113
|
} from "./depth-facts.mjs";
|
|
@@ -142,6 +146,7 @@ const EMPTY_REPORT = Object.freeze({
|
|
|
142
146
|
installId: "", lastVersion: "", lastActiveDay: "", forget: "", usage: null,
|
|
143
147
|
installedAt: "", firstSessionAt: "", firstProvider: "", activationSent: false, ref: "", selfUpdate: null,
|
|
144
148
|
rating: normaliseRating(null),
|
|
149
|
+
uiLanguage: "",
|
|
145
150
|
});
|
|
146
151
|
|
|
147
152
|
/** Is this deck sending reports right now? The switch, which is on unless
|
|
@@ -165,7 +170,7 @@ export function reportsOn(prefs, env = process.env) {
|
|
|
165
170
|
// The keys the API caps, so a value that would be rejected for length is not
|
|
166
171
|
// sent: it is trimmed to the cap here instead. Only ever tokens the shape of a
|
|
167
172
|
// terminal name, a shell name, a locale or a version — never anything free.
|
|
168
|
-
const TOKEN_CAPS = { locale: 16, shell: 16, term: 32, claudeVersion: 32, codexVersion: 32, deviceId: 64 };
|
|
173
|
+
const TOKEN_CAPS = { locale: 16, shell: 16, term: 32, claudeVersion: 32, codexVersion: 32, deviceId: 64, uiLanguage: UI_LANGUAGE_MAX };
|
|
169
174
|
|
|
170
175
|
/** A value reduced to the API's token shape `^[0-9A-Za-z.+_-]+$`: spaces become
|
|
171
176
|
* "_" (so "Apple Terminal" rides as "Apple_Terminal"), every other disallowed
|
|
@@ -330,6 +335,7 @@ export function installFacts({
|
|
|
330
335
|
deviceId = deviceIdToken(),
|
|
331
336
|
claudeVersion,
|
|
332
337
|
codexVersion,
|
|
338
|
+
uiLanguage,
|
|
333
339
|
} = {}) {
|
|
334
340
|
const facts = {
|
|
335
341
|
version: String(version),
|
|
@@ -343,6 +349,9 @@ export function installFacts({
|
|
|
343
349
|
addIf(facts, "cpus", count(cpus));
|
|
344
350
|
addIf(facts, "memMb", count(memMb));
|
|
345
351
|
addIf(facts, "locale", token(locale, TOKEN_CAPS.locale));
|
|
352
|
+
// The language chosen in the deck's own page, which the reporter folds in
|
|
353
|
+
// from the prefs (factsNow); not the OS locale above.
|
|
354
|
+
addIf(facts, "uiLanguage", token(uiLanguage, TOKEN_CAPS.uiLanguage));
|
|
346
355
|
addIf(facts, "shell", token(shell, TOKEN_CAPS.shell));
|
|
347
356
|
addIf(facts, "term", token(term, TOKEN_CAPS.term));
|
|
348
357
|
// The one derived, hashed, personal field. Present on the events that carry
|
|
@@ -627,7 +636,39 @@ export function createReporter({
|
|
|
627
636
|
/** The full facts an event carries: the fixed install facts, plus whatever CLI
|
|
628
637
|
* versions are known this moment. */
|
|
629
638
|
function factsNow() {
|
|
630
|
-
return { ...facts, ...versionFacts() };
|
|
639
|
+
return { ...facts, ...versionFacts(), ...uiLanguageFact() };
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
/** The page's language, from the prefs; nothing until a page has said it, and
|
|
643
|
+
* nothing with reports off (switching them off empties it). Never throws. */
|
|
644
|
+
function uiLanguageFact() {
|
|
645
|
+
try {
|
|
646
|
+
const p = prefs.current();
|
|
647
|
+
if (!reportsOn(p, env)) return {};
|
|
648
|
+
const out = {};
|
|
649
|
+
addIf(out, "uiLanguage", token(uiLanguageCode(p.report.uiLanguage), TOKEN_CAPS.uiLanguage));
|
|
650
|
+
return out;
|
|
651
|
+
} catch {
|
|
652
|
+
return {};
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
/** The language a page is showing, kept for the reports. Only while reports
|
|
657
|
+
* are on (there is nothing to keep it for otherwise, and the page says it
|
|
658
|
+
* again on its next load); a code that is not a language tag is refused.
|
|
659
|
+
* Resolves to whether it was kept; never throws. */
|
|
660
|
+
async function setUiLanguage(code) {
|
|
661
|
+
try {
|
|
662
|
+
const next = uiLanguageCode(code);
|
|
663
|
+
if (!next) return false;
|
|
664
|
+
await Promise.resolve(ready).catch(() => {});
|
|
665
|
+
if (!reportsOn(prefs.current(), env)) return false;
|
|
666
|
+
if (prefs.current().report.uiLanguage === next) return true;
|
|
667
|
+
await prefs.update(prev => (reportsOn(prev, env) ? { report: { ...prev.report, uiLanguage: next } } : undefined));
|
|
668
|
+
return true;
|
|
669
|
+
} catch {
|
|
670
|
+
return false;
|
|
671
|
+
}
|
|
631
672
|
}
|
|
632
673
|
|
|
633
674
|
/** What the boot set up — the Claude hooks and the Codex watcher — as the two
|
|
@@ -1205,7 +1246,7 @@ export function createReporter({
|
|
|
1205
1246
|
const stack = typeof error?.stack === "string" ? scrub(error.stack, home, root).slice(0, STACK_MAX) : undefined;
|
|
1206
1247
|
// Less the runtime, and less the deviceId — an error is not one of the events
|
|
1207
1248
|
// the fingerprint rides on, so the personal field never leaves on one.
|
|
1208
|
-
const { runtime: _runtime, deviceId: _deviceId, ...fields } = factsNow();
|
|
1249
|
+
const { runtime: _runtime, deviceId: _deviceId, uiLanguage: _uiLanguage, ...fields } = factsNow();
|
|
1209
1250
|
return (await call("POST", "/v1/app/errors", { installId: p.report.installId, ...fields, where, message, stack })) === "sent";
|
|
1210
1251
|
}
|
|
1211
1252
|
|
|
@@ -1278,7 +1319,7 @@ export function createReporter({
|
|
|
1278
1319
|
|
|
1279
1320
|
return {
|
|
1280
1321
|
checkIn, ping, setReports, reportError, restoreUsage, restoreRating, saveUsage, sendActivation, willReport,
|
|
1281
|
-
reportUninstall, noteSelfUpdate, ratingAsk, rate, rateLater, sendRating, start, stop,
|
|
1322
|
+
reportUninstall, noteSelfUpdate, setUiLanguage, ratingAsk, rate, rateLater, sendRating, start, stop,
|
|
1282
1323
|
};
|
|
1283
1324
|
}
|
|
1284
1325
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// The language the user chose in ccdeck's own page ("ro", "pt-BR"), as the
|
|
2
|
+
// server keeps it for the usage reports (reports.mjs `uiLanguage`).
|
|
3
|
+
//
|
|
4
|
+
// The choice lives in the browser (localStorage, src/web/i18n), so the page
|
|
5
|
+
// tells the server (POST /api/ui-language) and the server keeps the answer in
|
|
6
|
+
// prefs.json under `report.uiLanguage`, where the reporter finds it with no
|
|
7
|
+
// page open. The server cannot import the web registry, so the check is the
|
|
8
|
+
// token's shape, and this file is the one place that shape is written.
|
|
9
|
+
|
|
10
|
+
/** A language tag as a token: "ro", "pt-BR", "zh-Hans". */
|
|
11
|
+
const SHAPE = /^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8})?$/;
|
|
12
|
+
export const UI_LANGUAGE_MAX = 16;
|
|
13
|
+
|
|
14
|
+
/** The code if it is a language tag, else "" (which means: not known). */
|
|
15
|
+
export function uiLanguageCode(value) {
|
|
16
|
+
return typeof value === "string" && value.length <= UI_LANGUAGE_MAX && SHAPE.test(value) ? value : "";
|
|
17
|
+
}
|