ccdeck 3.81.4 → 3.82.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -17
- package/bin/cli/help.js +3 -2
- package/bin/cli/uninstall.js +19 -0
- package/dist/web/assets/{BrowserWatchModal-C2JIHDVZ.js → BrowserWatchModal-5txXQWqr.js} +1 -1
- package/dist/web/assets/{IntegrationModal-CO1SrDXf.js → IntegrationModal-2caOGb1q.js} +1 -1
- package/dist/web/assets/{RadioPanel-CQ7ILyIZ.js → RadioPanel-DuvwS-TT.js} +1 -1
- package/dist/web/assets/{TrafficRadar-KOunicu_.js → TrafficRadar-BD_S2b0e.js} +1 -1
- package/dist/web/assets/{UsageHistoryModal-BXiOEbuk.js → UsageHistoryModal-CXDbKfIt.js} +1 -1
- package/dist/web/assets/{app-BIrh5Q0W.css → app-CbXmr9rC.css} +1 -1
- package/dist/web/assets/{app-0jqgYDft.js → app-CoVinTuS.js} +68 -68
- package/dist/web/assets/{index-K55Tw-ZZ.js → index-DpfbtL3r.js} +1 -1
- package/dist/web/index.html +3 -3
- package/package.json +1 -1
- package/release-notes.json +53 -0
- package/src/server/codex-live-credentials.mjs +3 -3
- package/src/server/codex-live-engine.mjs +67 -19
- package/src/server/codex-live-rpc.mjs +13 -2
- package/src/server/codex-terminal.mjs +75 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./app-
|
|
1
|
+
import"./app-CoVinTuS.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const e of document.querySelectorAll('link[rel="modulepreload"]'))i(e);new MutationObserver(e=>{for(const r of e)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function s(e){const r={};return e.integrity&&(r.integrity=e.integrity),e.referrerPolicy&&(r.referrerPolicy=e.referrerPolicy),e.crossOrigin==="use-credentials"?r.credentials="include":e.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(e){if(e.ep)return;e.ep=!0;const r=s(e);fetch(e.href,r)}})();
|
package/dist/web/index.html
CHANGED
|
@@ -77,9 +77,9 @@
|
|
|
77
77
|
document.documentElement.setAttribute("data-density", density === "tightest" || density === "tighter" || density === "compact" || density === "comfortable" ? density : "default");
|
|
78
78
|
})();
|
|
79
79
|
</script>
|
|
80
|
-
<script type="module" crossorigin src="/assets/index-
|
|
81
|
-
<link rel="modulepreload" crossorigin href="/assets/app-
|
|
82
|
-
<link rel="stylesheet" crossorigin href="/assets/app-
|
|
80
|
+
<script type="module" crossorigin src="/assets/index-DpfbtL3r.js"></script>
|
|
81
|
+
<link rel="modulepreload" crossorigin href="/assets/app-CoVinTuS.js">
|
|
82
|
+
<link rel="stylesheet" crossorigin href="/assets/app-CbXmr9rC.css">
|
|
83
83
|
</head>
|
|
84
84
|
<body>
|
|
85
85
|
<div id="root"></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ccdeck",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.82.1",
|
|
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": {
|
package/release-notes.json
CHANGED
|
@@ -84,6 +84,8 @@
|
|
|
84
84
|
"without one."
|
|
85
85
|
],
|
|
86
86
|
"//summaries": {
|
|
87
|
+
"3.82.1": "Clearer network shortcuts, accurate account capacity and Codex recovery fixes",
|
|
88
|
+
"3.82.0": "Steadier Codex switching, and uninstall cleans up Codex's terminal selection",
|
|
87
89
|
"3.81.4": "Codex account switching works with Windows sandbox logins",
|
|
88
90
|
"3.81.3": "More reliable Codex switching and quieter account rows",
|
|
89
91
|
"3.81.2": "Codex account switches wait through activity changes",
|
|
@@ -140,6 +142,57 @@
|
|
|
140
142
|
"3.53.1",
|
|
141
143
|
"3.53.3"
|
|
142
144
|
],
|
|
145
|
+
"3.82.1": [
|
|
146
|
+
{
|
|
147
|
+
"title": "Local network controls, easier to find",
|
|
148
|
+
"body": "Open this deck’s network settings or the network graph directly from the Local network row.",
|
|
149
|
+
"priority": "highlight"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"title": "More accurate account capacity",
|
|
153
|
+
"body": "Accounts at their weekly limit no longer inflate the average remaining five-hour capacity.",
|
|
154
|
+
"priority": "highlight",
|
|
155
|
+
"icon": "accounts"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"title": "Codex account recovery fixes",
|
|
159
|
+
"body": "Codex account control can recover after temporary startup timeouts and checks account changes again when reconnecting.",
|
|
160
|
+
"priority": "highlight",
|
|
161
|
+
"icon": "accounts"
|
|
162
|
+
}
|
|
163
|
+
],
|
|
164
|
+
"3.82.0": [
|
|
165
|
+
{
|
|
166
|
+
"title": "🔄 Codex switching recovers instead of staying stuck",
|
|
167
|
+
"body": "A failed reconnect or manual switch no longer leaves Codex account control disconnected, and turning Auto-switch off stops a switch it had already queued.",
|
|
168
|
+
"priority": "highlight",
|
|
169
|
+
"icon": "accounts",
|
|
170
|
+
"details": "On Windows, a Codex connection that never answers now fails after 30 seconds instead of waiting forever."
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"title": "⏱️ Slow Codex logins get more time and a Retry button",
|
|
174
|
+
"body": "ccdeck now gives Codex more time to read a login during a switch, and if it still runs out, the panel says why and offers Retry selected account.",
|
|
175
|
+
"priority": "highlight",
|
|
176
|
+
"icon": "accounts"
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
"title": "🧹 Uninstall also removes Codex's terminal selection",
|
|
180
|
+
"body": "ccdeck --uninstall now takes the codex block that Enable terminal selection added out of your shell profiles, and names any file it could not clean.",
|
|
181
|
+
"priority": "highlight"
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"title": "⌨️ A opens Codex accounts on a Codex-only deck",
|
|
185
|
+
"body": "With Codex alone, the Codex accounts door now shows its A key, and its name follows your interface language."
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
"title": "🔑 Jira token help names the permission for comments and statuses",
|
|
189
|
+
"body": "A scoped Jira Cloud token needs write:jira-work to add comments and change statuses, and the token help and Settings › Integrations now say so."
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"title": "🌍 Codex messages read correctly in every language",
|
|
193
|
+
"body": "The message about a Codex login folder that is not private enough had lost its accented and non-Latin letters; it is whole again, and the new timeout message is translated."
|
|
194
|
+
}
|
|
195
|
+
],
|
|
143
196
|
"3.81.4": [
|
|
144
197
|
{
|
|
145
198
|
"title": "🔄 Switch Codex accounts without another sign-in",
|
|
@@ -12,10 +12,10 @@ import { pathLookup } from './exec-spec.mjs';
|
|
|
12
12
|
import { holdWindowsPrivatePath, snapshotWindowsCodexLogin } from './codex-windows-private.mjs';
|
|
13
13
|
|
|
14
14
|
const MAX_AUTH_BYTES = 1024 * 1024;
|
|
15
|
-
// A
|
|
16
|
-
//
|
|
15
|
+
// A cold CLI or workspace routing discovery can exceed three seconds on any
|
|
16
|
+
// platform. Bound initialization/reads together at thirty seconds,
|
|
17
17
|
// plus the owned process's four-second shutdown; never retry a native request.
|
|
18
|
-
const NATIVE_DEADLINE_MS =
|
|
18
|
+
const NATIVE_DEADLINE_MS = 34000;
|
|
19
19
|
// startEngineRpc.stop() closes stdin, then escalates at 2s and 4s. Reserve its
|
|
20
20
|
// full shutdown window rather than giving each request another seven seconds.
|
|
21
21
|
const STOP_RESERVE_MS = 4000;
|
|
@@ -146,20 +146,30 @@ export function createCodexLiveAccountController(input = {}) {
|
|
|
146
146
|
return;
|
|
147
147
|
}
|
|
148
148
|
try {
|
|
149
|
+
if (!await lease?.valid()) throw liveError('native_control_lost');
|
|
150
|
+
if (owner !== rpc || !owned || closed || ownershipPaused || epoch !== ownershipEpoch) return;
|
|
149
151
|
const next = await credentialFor(credential.profileId, { refresh: true });
|
|
150
152
|
if (closed || owner !== rpc || !owned || ownershipPaused || epoch !== ownershipEpoch) return;
|
|
151
153
|
if (next.accountId !== previous) throw liveError('profile_changed');
|
|
152
154
|
const actual = await owner.request('account/read', { refreshToken: false });
|
|
153
155
|
if (closed || owner !== rpc || ownershipPaused || epoch !== ownershipEpoch) return;
|
|
154
156
|
if (!sameAccount(actual, next)) { await externalChange(); return; }
|
|
157
|
+
// A profile can be removed after its credential read has finished.
|
|
158
|
+
// Do not keep renewing a login whose row/home is no longer available.
|
|
159
|
+
const latest = await selection();
|
|
160
|
+
if (!latest.profiles?.some(p => p.id === credential.profileId && p.available !== false)) throw liveError('profile_unavailable');
|
|
161
|
+
if (!await lease?.valid()) throw liveError('native_control_lost');
|
|
162
|
+
if (closed || owner !== rpc || !owned || ownershipPaused || epoch !== ownershipEpoch) return;
|
|
155
163
|
// ExternalAuthBridge::refresh returns the auth directly; it does not
|
|
156
164
|
// emit account/updated. Do not leave a notification-suppression window.
|
|
157
165
|
credential = next; lastRefresh = Date.now();
|
|
158
166
|
owner.send({ id: message.id, result: { accessToken: next.accessToken, chatgptAccountId: next.accountId, chatgptPlanType: next.planType } });
|
|
159
|
-
} catch {
|
|
167
|
+
} catch (error) {
|
|
168
|
+
if (closed || owner !== rpc || !owned || ownershipPaused || epoch !== ownershipEpoch) return;
|
|
160
169
|
// Never return paths, token values or provider error text on the wire.
|
|
161
170
|
try { owner.send({ id: message.id, error: { code: -32000, message: 'Selected Codex login could not be renewed.' } }); } catch { /* connection ended */ }
|
|
162
|
-
|
|
171
|
+
if (['native_control_lost', 'profile_unavailable'].includes(error?.code)) await externalChange(error.code);
|
|
172
|
+
else update({ state: 'failed', reason: 'credential_refresh_failed' });
|
|
163
173
|
}
|
|
164
174
|
});
|
|
165
175
|
}
|
|
@@ -210,8 +220,12 @@ export function createCodexLiveAccountController(input = {}) {
|
|
|
210
220
|
} finally { clearTimeout(timeout); }
|
|
211
221
|
account = await rpc.request('account/read', { refreshToken: false });
|
|
212
222
|
}
|
|
213
|
-
}
|
|
214
|
-
|
|
223
|
+
} catch (error) {
|
|
224
|
+
// Manual switches and renewals can also create this connection while
|
|
225
|
+
// retaining a previous login. Never retain an unattested bootstrap.
|
|
226
|
+
await disconnect();
|
|
227
|
+
throw error;
|
|
228
|
+
} finally { readingInitialAccount = false; }
|
|
215
229
|
if (account.account && account.account.type !== 'chatgpt') { rpc.close(); rpc = null; owned = false; throw liveError('unsupported_auth_mode'); }
|
|
216
230
|
}
|
|
217
231
|
async function loginCredential(id, refresh = false) {
|
|
@@ -252,6 +266,15 @@ export function createCodexLiveAccountController(input = {}) {
|
|
|
252
266
|
journal.phase = journal.entries.every(e => ['continued', 'skipped'].includes(e.phase)) ? 'finished' : 'pending';
|
|
253
267
|
await saveHandoff(journal);
|
|
254
268
|
};
|
|
269
|
+
const assertAutoEnabled = async () => {
|
|
270
|
+
if (automatic && !(await (options.readAuto ?? (() => readCodexAuto({ ...options, store })))()).enabled) {
|
|
271
|
+
throw liveError('auto_switch_disabled');
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
const assertProfileAvailable = async () => {
|
|
275
|
+
const latest = await selection();
|
|
276
|
+
if (!latest.profiles?.some(p => p.id === intent.id && p.available !== false)) throw liveError('profile_unavailable');
|
|
277
|
+
};
|
|
255
278
|
const authCurrent = () => !closed && !ownershipPaused && epoch === ownershipEpoch;
|
|
256
279
|
const owner = () => authCurrent() && currentIntent()?.revision === intent.revision && currentIntent()?.id === intent.id;
|
|
257
280
|
const verifyOwnership = async () => {
|
|
@@ -277,12 +300,17 @@ export function createCodexLiveAccountController(input = {}) {
|
|
|
277
300
|
if (!s.profiles?.some(p => p.id === intent.id && p.available !== false)) throw liveError('profile_unavailable');
|
|
278
301
|
await ensureRpc(s.originalHome);
|
|
279
302
|
const next = await loginCredential(intent.id, refresh);
|
|
303
|
+
await assertProfileAvailable();
|
|
304
|
+
await assertAutoEnabled();
|
|
280
305
|
if (!owner()) throw liveError('account_changed_outside_deck');
|
|
281
306
|
if (!await lease.valid()) throw liveError('native_control_lost');
|
|
282
307
|
const before = await rpc.request('account/read', { refreshToken: false });
|
|
283
308
|
resumeIdentity = before;
|
|
284
309
|
handoff = await prepareCodexLiveHandoff(rpc, { isCurrent: owner,
|
|
285
310
|
beforeInterrupt: async entry => {
|
|
311
|
+
await assertProfileAvailable();
|
|
312
|
+
await assertAutoEnabled();
|
|
313
|
+
if (!owner()) throw liveError('account_changed_outside_deck');
|
|
286
314
|
await record(entry, 'interrupt_sent');
|
|
287
315
|
if (!owner()) throw liveError('account_changed_outside_deck');
|
|
288
316
|
}, afterInterrupt: (entry, phase) => record(entry, phase) });
|
|
@@ -312,6 +340,9 @@ export function createCodexLiveAccountController(input = {}) {
|
|
|
312
340
|
const current = await rpc.request('account/read', { refreshToken: false });
|
|
313
341
|
if (!owner() || !sameNativeAccount(current, before)) throw liveError('account_changed_outside_deck');
|
|
314
342
|
if (!await lease.valid()) throw liveError('native_control_lost');
|
|
343
|
+
await assertProfileAvailable();
|
|
344
|
+
await assertAutoEnabled();
|
|
345
|
+
if (!owner()) throw liveError('account_changed_outside_deck');
|
|
315
346
|
// Authentication crosses only this owner-validated local socket. Codex
|
|
316
347
|
// stores external tokens in memory, not either profile's credential file.
|
|
317
348
|
maybeApplied = true;
|
|
@@ -365,7 +396,8 @@ export function createCodexLiveAccountController(input = {}) {
|
|
|
365
396
|
if (journal.entries.length && journal.phase !== 'finished') update({ continuation: 'manual_required' });
|
|
366
397
|
if (maybeApplied) { credential = null; owned = false; }
|
|
367
398
|
const reason = publicReason(error);
|
|
368
|
-
update({ state:
|
|
399
|
+
update({ state: reason === 'auto_switch_disabled' && !maybeApplied ? (owned ? 'applied' : 'idle')
|
|
400
|
+
: ['native_not_running', 'cli_unavailable'].includes(reason) ? 'unavailable' : 'failed',
|
|
369
401
|
...(maybeApplied ? { profileId: null } : {}), reason });
|
|
370
402
|
if (!owned) await disconnect();
|
|
371
403
|
} finally {
|
|
@@ -407,10 +439,13 @@ export function createCodexLiveAccountController(input = {}) {
|
|
|
407
439
|
});
|
|
408
440
|
return pendingSwitch;
|
|
409
441
|
}
|
|
410
|
-
async function restorePrevious(saved, intent
|
|
411
|
-
restorePending = null;
|
|
442
|
+
async function restorePrevious(saved, intent) {
|
|
412
443
|
const epoch = ownershipEpoch;
|
|
413
444
|
const previous = await loginCredential(saved.profileId);
|
|
445
|
+
const actual = await rpc.request('account/read', { refreshToken: false });
|
|
446
|
+
if (!await lease?.valid()) throw liveError('native_control_lost');
|
|
447
|
+
if (closed) return;
|
|
448
|
+
restorePending = null;
|
|
414
449
|
if (ownershipPaused || epoch !== ownershipEpoch) { await externalChange(); return; }
|
|
415
450
|
if (endpointKey(endpoint) === saved.endpoint && sameAccount(actual, previous, true)) {
|
|
416
451
|
credential = previous; appliedIntent = { id: saved.profileId, revision: saved.revision }; owned = true;
|
|
@@ -439,7 +474,7 @@ export function createCodexLiveAccountController(input = {}) {
|
|
|
439
474
|
if (closed || restorePending !== saved) return;
|
|
440
475
|
desired = intent;
|
|
441
476
|
await ensureRpc(s.originalHome);
|
|
442
|
-
|
|
477
|
+
let actual = await rpc.request('account/read', { refreshToken: false });
|
|
443
478
|
if (!accountIds(actual).length) {
|
|
444
479
|
restorePending = null; await externalChange('native_identity_unattested'); return;
|
|
445
480
|
}
|
|
@@ -447,14 +482,19 @@ export function createCodexLiveAccountController(input = {}) {
|
|
|
447
482
|
try { next = await loginCredential(intent.id); }
|
|
448
483
|
catch (error) {
|
|
449
484
|
if (intent.revision <= saved.revision) throw error;
|
|
450
|
-
await restorePrevious(saved, intent
|
|
485
|
+
await restorePrevious(saved, intent); return;
|
|
451
486
|
}
|
|
487
|
+
// Credential preparation can outlive both the native account and our
|
|
488
|
+
// control lease. Reattest after it, rather than adopting the old read.
|
|
489
|
+
actual = await rpc.request('account/read', { refreshToken: false });
|
|
490
|
+
if (!await lease?.valid()) throw liveError('native_control_lost');
|
|
452
491
|
if (closed || restorePending !== saved) return;
|
|
453
492
|
if (ownershipPaused || epoch !== ownershipEpoch) { restorePending = null; await externalChange(); return; }
|
|
493
|
+
if (!accountIds(actual).length) { restorePending = null; await externalChange('native_identity_unattested'); return; }
|
|
454
494
|
if (intent.revision > saved.revision && !sameAccount(actual, next, true)) {
|
|
455
495
|
// The newer request has no persisted acknowledgement. It may have
|
|
456
496
|
// timed out after sending: reconcile it, never replay it on restart.
|
|
457
|
-
await restorePrevious(saved, intent
|
|
497
|
+
await restorePrevious(saved, intent); return;
|
|
458
498
|
}
|
|
459
499
|
if (intent.revision === saved.revision && endpointKey(endpoint) === saved.endpoint && !sameAccount(actual, next, true)) {
|
|
460
500
|
restorePending = null; await externalChange(); return;
|
|
@@ -473,7 +513,8 @@ export function createCodexLiveAccountController(input = {}) {
|
|
|
473
513
|
} catch (error) {
|
|
474
514
|
if (!owned) await disconnect();
|
|
475
515
|
const reason = publicReason(error);
|
|
476
|
-
const retry = ['native_not_running', 'cli_unavailable', 'native_unavailable', 'native_connection_failed', 'native_disconnected', 'native_control_busy'
|
|
516
|
+
const retry = ['native_not_running', 'cli_unavailable', 'native_unavailable', 'native_connection_failed', 'native_disconnected', 'native_control_busy',
|
|
517
|
+
'native_request_timeout', 'native_initial_account_unconfirmed'].includes(reason);
|
|
477
518
|
update({ state: retry ? 'unavailable' : 'failed', reason });
|
|
478
519
|
if (!retry) restorePending = null;
|
|
479
520
|
restoreRetryAt = Date.now() + (options.restoreRetryMs ?? 5000);
|
|
@@ -553,14 +594,21 @@ export function createCodexLiveAccountController(input = {}) {
|
|
|
553
594
|
} catch { /* Keep the durable recovery intent until its outcome is known. */ }
|
|
554
595
|
}
|
|
555
596
|
async function reconnect() {
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
597
|
+
try {
|
|
598
|
+
const s = await selection(); await ensureRpc(s.originalHome);
|
|
599
|
+
const actual = await rpc.request('account/read', { refreshToken: false });
|
|
600
|
+
// Notifications were unobservable during the gap. Email/workspace labels
|
|
601
|
+
// cannot restore authority; require a native ID or a fresh manual selection.
|
|
602
|
+
if (!accountIds(actual).length) await externalChange('native_identity_unattested');
|
|
603
|
+
else if (!ownershipPaused && sameAccount(actual, credential, true)) {
|
|
604
|
+
lastCheck = Date.now(); update({ state: 'applied', profileId: credential.profileId, reason: null });
|
|
605
|
+
} else await externalChange();
|
|
606
|
+
} catch (error) {
|
|
607
|
+
// A partially initialized connection cannot attest ownership. Drop only
|
|
608
|
+
// our control connection so the next poll can reconnect and read IDs.
|
|
609
|
+
await disconnect();
|
|
610
|
+
throw error;
|
|
611
|
+
}
|
|
564
612
|
}
|
|
565
613
|
async function tick() {
|
|
566
614
|
if (closed || ticking) return;
|
|
@@ -113,7 +113,7 @@ export async function connectCodexLiveRpc(endpoint, options = {}) {
|
|
|
113
113
|
let ws;
|
|
114
114
|
try {
|
|
115
115
|
ws = new WebSocket(windows ? 'ws://localhost/' : `ws+unix://${endpoint.socketPath}:/`, {
|
|
116
|
-
handshakeTimeout: 5000, maxPayload: 64 * 1024 * 1024, perMessageDeflate: false,
|
|
116
|
+
handshakeTimeout: windows ? 30000 : 5000, maxPayload: 64 * 1024 * 1024, perMessageDeflate: false,
|
|
117
117
|
...(windows ? { createConnection: () => { proxy = createCodexWindowsProxy(endpoint, options); return proxy; } } : {}),
|
|
118
118
|
});
|
|
119
119
|
} catch { await guard?.release(); proxy?.destroy(); throw liveError('native_connection_failed'); }
|
|
@@ -161,7 +161,18 @@ export async function connectCodexLiveRpc(endpoint, options = {}) {
|
|
|
161
161
|
close() { closing = true; rejectPending(); ws.close(); const timer = setTimeout(() => { ws.terminate(); proxy?.destroy(); }, 500); timer.unref(); },
|
|
162
162
|
};
|
|
163
163
|
try {
|
|
164
|
-
await new Promise((ready, reject) => {
|
|
164
|
+
await new Promise((ready, reject) => {
|
|
165
|
+
// The Windows stdio Duplex does not emit a net.Socket connect event, so
|
|
166
|
+
// the HTTP client's socket timeout alone cannot bound its handshake.
|
|
167
|
+
const finish = error => {
|
|
168
|
+
clearTimeout(timer);
|
|
169
|
+
ws.off('open', opened); ws.off('error', failed); ws.off('close', failed);
|
|
170
|
+
if (error) reject(liveError('native_connection_failed')); else ready();
|
|
171
|
+
};
|
|
172
|
+
const opened = () => finish(false), failed = () => finish(true);
|
|
173
|
+
const timer = setTimeout(failed, windows ? 30000 : 5000);
|
|
174
|
+
ws.once('open', opened); ws.once('error', failed); ws.once('close', failed);
|
|
175
|
+
});
|
|
165
176
|
const after = windows ? await inspectWindowsPrivateSocket(endpoint.socketPath, options.windowsPrivate) : await inspectPosixSocket(endpoint.socketPath);
|
|
166
177
|
if (after.generation !== endpoint.generation) throw liveError('native_endpoint_changed');
|
|
167
178
|
if (guard && !guard.valid()) throw liveError('untrusted_native_socket');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';
|
|
2
|
-
import { readFile, mkdir, chmod, access, stat, cp } from 'node:fs/promises';
|
|
2
|
+
import { readFile, mkdir, chmod, access, stat, cp, rm } from 'node:fs/promises';
|
|
3
3
|
import { constants } from 'node:fs';
|
|
4
|
-
import { basename, dirname, join, isAbsolute } from 'node:path';
|
|
4
|
+
import { basename, dirname, join, isAbsolute, relative } from 'node:path';
|
|
5
5
|
import { homedir } from 'node:os';
|
|
6
6
|
import { execFile } from 'node:child_process';
|
|
7
7
|
import { promisify } from 'node:util';
|
|
@@ -48,6 +48,10 @@ async function rcFor(shell, home, env, platform) {
|
|
|
48
48
|
}
|
|
49
49
|
return join(home, '.bashrc');
|
|
50
50
|
}
|
|
51
|
+
return powershellProfile(shell);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async function powershellProfile(shell) {
|
|
51
55
|
const executable = shell === 'powershell5' ? 'powershell.exe' : 'pwsh.exe';
|
|
52
56
|
const { stdout } = await promisify(execFile)(executable, ['-NoProfile', '-Command', '$PROFILE.CurrentUserAllHosts'], { encoding: 'utf8', timeout: 5000, maxBuffer: 4096 });
|
|
53
57
|
const rc = stdout.trim();
|
|
@@ -119,3 +123,72 @@ export async function configureCodexTerminal(action, options = {}) {
|
|
|
119
123
|
if (action === 'install') await chmod(join(options.store ?? deckDataDir(undefined, env, home), 'codex-terminal'), 0o700);
|
|
120
124
|
return { shell, rc, action };
|
|
121
125
|
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* For `--uninstall`: take the block Enable terminal selection wrote out of every
|
|
129
|
+
* shell profile it may be in, and the helper it calls with it.
|
|
130
|
+
*
|
|
131
|
+
* Nothing records which shell the person set it up in (they ran the command
|
|
132
|
+
* themselves), so every profile `rcFor` can pick is read: zsh's in ZDOTDIR and
|
|
133
|
+
* in the home folder, bash's on Linux and the three macOS picks the first of
|
|
134
|
+
* (an earlier setup may have picked another), and on Windows both PowerShells'
|
|
135
|
+
* CurrentUserAllHosts profile in Documents, and in OneDrive's Documents when
|
|
136
|
+
* OneDrive keeps that folder. Left behind, the block outlives ccdeck: `codex`
|
|
137
|
+
* runs through a helper that the desktop app's removal takes away, and it no
|
|
138
|
+
* longer starts.
|
|
139
|
+
*
|
|
140
|
+
* The PowerShell profiles are found from the home folder, not by asking
|
|
141
|
+
* PowerShell: `$PROFILE` follows the Documents folder Windows has on record,
|
|
142
|
+
* whatever HOME or USERPROFILE say, so asking would reach past an isolated
|
|
143
|
+
* home into the real one. A OneDrive folder outside the home is skipped for
|
|
144
|
+
* the same reason.
|
|
145
|
+
*
|
|
146
|
+
* A file whose markers are incomplete is not touched and is named. The helper
|
|
147
|
+
* goes only when no profile still holds a block, since a block left anywhere
|
|
148
|
+
* still calls it. Answers { removed, refused, kept, helper, directory }.
|
|
149
|
+
*/
|
|
150
|
+
export async function removeCodexTerminalEverywhere(options = {}) {
|
|
151
|
+
const env = options.env ?? process.env;
|
|
152
|
+
const platform = options.platform ?? process.platform;
|
|
153
|
+
const home = options.home ?? homedir();
|
|
154
|
+
const store = options.store ?? deckDataDir(undefined, env, home);
|
|
155
|
+
const candidates = [];
|
|
156
|
+
const zdot = env.ZDOTDIR?.trim();
|
|
157
|
+
if (zdot) candidates.push(join(zdot, '.zshrc'));
|
|
158
|
+
candidates.push(...['.zshrc', '.bashrc', '.bash_profile', '.bash_login', '.profile'].map(name => join(home, name)));
|
|
159
|
+
if (platform === 'win32') {
|
|
160
|
+
const inHome = dir => { const r = relative(home, dir); return r !== '' && !r.startsWith('..') && !isAbsolute(r); };
|
|
161
|
+
const documents = [join(home, 'Documents'),
|
|
162
|
+
...[env.OneDrive, env.OneDriveConsumer, env.OneDriveCommercial].filter(dir => dir?.trim() && inHome(dir)).map(dir => join(dir, 'Documents'))];
|
|
163
|
+
for (const dir of documents) candidates.push(join(dir, 'PowerShell', 'profile.ps1'), join(dir, 'WindowsPowerShell', 'profile.ps1'));
|
|
164
|
+
}
|
|
165
|
+
const removed = [], refused = [];
|
|
166
|
+
for (const rc of new Set(candidates)) {
|
|
167
|
+
let text;
|
|
168
|
+
try { text = await readFile(rc, 'utf8'); }
|
|
169
|
+
catch (error) {
|
|
170
|
+
if (error.code !== 'ENOENT' && error.code !== 'ENOTDIR') refused.push({ path: rc, why: error.message });
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
if (!text.includes(BEGIN) && !text.includes(END)) continue;
|
|
174
|
+
try {
|
|
175
|
+
await writeFileAtomic(await resolveWriteTarget(rc), stripIntegration(text));
|
|
176
|
+
removed.push(rc);
|
|
177
|
+
} catch (error) {
|
|
178
|
+
refused.push({ path: rc, why: error.message });
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
const directory = join(store, 'codex-terminal');
|
|
182
|
+
let helper = false;
|
|
183
|
+
const kept = refused.length > 0;
|
|
184
|
+
if (!kept) {
|
|
185
|
+
try {
|
|
186
|
+
await stat(directory);
|
|
187
|
+
await rm(directory, { recursive: true, force: true });
|
|
188
|
+
helper = true;
|
|
189
|
+
} catch (error) {
|
|
190
|
+
if (error.code !== 'ENOENT') refused.push({ path: directory, why: error.message });
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return { removed, refused, kept, helper, directory };
|
|
194
|
+
}
|