-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcodex-reset.html
More file actions
667 lines (600 loc) · 20 KB
/
Copy pathcodex-reset.html
File metadata and controls
667 lines (600 loc) · 20 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta
http-equiv="Content-Security-Policy"
content="default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src 'self' data:; connect-src 'none'; form-action 'none'; base-uri 'none'; frame-ancestors 'none'"
>
<meta name="color-scheme" content="dark light">
<title>Codex Reset</title>
<style>
:root {
color-scheme: dark;
--canvas: #090b0f;
--surface: #11161c;
--panel: #151b23;
--raised: #1b232d;
--line: rgba(189, 204, 218, 0.2);
--line-strong: rgba(125, 215, 189, 0.58);
--text: #f4f7f5;
--muted: #a4b0bb;
--soft: #d6dee5;
--accent: #7dd7bd;
--accent-2: #8eb6ff;
--danger: #f08c86;
--warn: #f0c36a;
--focus: #9debd8;
--radius: 8px;
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
min-height: 100vh;
background:
linear-gradient(180deg, rgba(125, 215, 189, 0.06), transparent 260px),
var(--canvas);
color: var(--text);
line-height: 1.5;
}
main {
width: min(1120px, calc(100% - 32px));
margin: 0 auto;
padding: 36px 0 56px;
}
header {
display: grid;
gap: 18px;
border-bottom: 1px solid var(--line);
padding-bottom: 26px;
margin-bottom: 24px;
}
.eyebrow {
color: var(--accent);
font-size: 0.78rem;
font-weight: 760;
letter-spacing: 0.08em;
text-transform: uppercase;
}
h1,
h2,
h3,
p {
margin: 0;
letter-spacing: 0;
}
h1 {
max-width: 15ch;
font-size: clamp(3rem, 8vw, 6.8rem);
line-height: 0.9;
}
h2 {
color: var(--accent);
font-size: 0.98rem;
text-transform: uppercase;
margin-bottom: 14px;
}
h3 {
color: var(--soft);
font-size: 0.98rem;
margin-bottom: 8px;
}
.lead {
max-width: 760px;
color: var(--muted);
font-size: 1.08rem;
}
.notice {
max-width: 920px;
padding: 13px 14px;
border: 1px solid var(--line);
border-radius: var(--radius);
background: rgba(17, 22, 28, 0.82);
color: var(--soft);
}
.grid {
display: grid;
grid-template-columns: minmax(0, 1fr) minmax(320px, 0.78fr);
gap: 18px;
align-items: start;
}
.stack {
display: grid;
gap: 18px;
}
section {
border: 1px solid var(--line);
border-radius: var(--radius);
background: var(--surface);
padding: 18px;
}
.section-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 14px;
}
label {
display: grid;
gap: 8px;
color: var(--muted);
font-size: 0.88rem;
min-width: 0;
}
input,
select,
textarea,
button {
font: inherit;
}
input,
select,
textarea {
width: 100%;
min-height: 46px;
border: 1px solid var(--line);
border-radius: var(--radius);
background: #090b0e;
color: var(--text);
padding: 0 12px;
}
textarea {
min-height: 104px;
padding: 12px;
resize: vertical;
line-height: 1.45;
}
input[type="checkbox"] {
width: auto;
min-height: auto;
margin: 0;
}
.check-row {
display: flex;
align-items: center;
gap: 8px;
min-height: 34px;
}
.actions {
display: flex;
flex-wrap: wrap;
gap: 10px;
margin-top: 14px;
}
button {
min-height: 44px;
border: 1px solid var(--line);
border-radius: var(--radius);
background: var(--raised);
color: var(--text);
padding: 0 14px;
cursor: pointer;
font-weight: 700;
}
button.primary {
border-color: var(--line-strong);
background: var(--accent);
color: #03110c;
}
button.secondary {
color: var(--soft);
}
button:disabled,
button.primary:disabled {
border-color: var(--line);
background: #11171d;
color: var(--muted);
cursor: not-allowed;
}
a {
color: var(--accent);
overflow-wrap: anywhere;
text-underline-offset: 3px;
}
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
outline: 2px solid var(--focus);
outline-offset: 3px;
}
.result {
display: grid;
gap: 8px;
margin-top: 16px;
padding: 12px;
border: 1px solid var(--line);
border-radius: var(--radius);
background: #080a0d;
}
.result strong {
color: var(--muted);
font-size: 0.78rem;
text-transform: uppercase;
}
.mono {
font-family:
"SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
overflow-wrap: anywhere;
}
.status {
min-height: 22px;
margin-top: 10px;
color: var(--muted);
font-size: 0.92rem;
}
.status.ok {
color: var(--accent);
}
.status.error {
color: var(--danger);
}
.small {
color: var(--muted);
font-size: 0.9rem;
}
.pill-row {
display: flex;
flex-wrap: wrap;
gap: 8px;
margin-top: 14px;
}
.pill {
border: 1px solid var(--line);
border-radius: 999px;
padding: 6px 10px;
background: #0d1217;
color: var(--soft);
font-size: 0.82rem;
font-weight: 700;
}
ol,
ul {
margin: 0;
padding-left: 1.25rem;
}
li + li {
margin-top: 8px;
}
li::marker {
color: var(--accent);
}
.warning {
color: var(--warn);
}
@media (max-width: 880px) {
main {
width: min(100% - 20px, 1120px);
padding-top: 20px;
}
.grid,
.section-grid {
grid-template-columns: 1fr;
}
h1 {
max-width: none;
font-size: clamp(2.7rem, 14vw, 4.6rem);
}
.actions button {
flex: 1 1 100%;
}
}
</style>
</head>
<body>
<main>
<header>
<p class="eyebrow">Local companion page</p>
<h1>Codex Reset</h1>
<p class="lead">
A readable browser companion for Codex reset credits and manual Codex account handoffs.
The page helps you prepare commands, copy operational notes, and keep the flow tidy.
</p>
<p class="notice">
This page is static. It does not call OpenAI endpoints, does not read `auth.json`, does not read cookies, does not use local storage, and does not make network requests. The CLI remains the tool that reads `auth.json` and redeems banked reset credits.
</p>
<div class="pill-row" aria-label="Safety summary">
<span class="pill">Single HTML file</span>
<span class="pill">No backend</span>
<span class="pill">No token access</span>
<span class="pill">No network calls</span>
</div>
</header>
<div class="grid">
<div class="stack">
<section aria-labelledby="reset-title">
<h2 id="reset-title">Reset credit command builder</h2>
<div class="section-grid">
<label>
Auth file path
<input id="authPath" spellcheck="false" placeholder="default: $CODEX_HOME/auth.json or ~/.codex/auth.json">
</label>
<label>
Action
<select id="resetAction">
<option value="status">Show credits and usage</option>
<option value="consume">Redeem one credit</option>
<option value="invite-status">Show Codex helper diagnostics</option>
</select>
</label>
<label>
Credit ID
<input id="creditId" spellcheck="false" placeholder="optional for consume">
</label>
<label>
Cookie file for diagnostics
<input id="cookieFile" spellcheck="false" placeholder="optional; use - for stdin">
</label>
</div>
<div class="section-grid">
<label class="check-row">
<input id="jsonOutput" type="checkbox">
JSON output
</label>
<label class="check-row">
<input id="dryRun" type="checkbox">
Dry run for consume
</label>
<label class="check-row">
<input id="assumeYes" type="checkbox">
Skip consume confirmation
</label>
</div>
<div class="actions">
<button class="primary" id="copyCommand" type="button">Copy command</button>
<button id="copyInstall" type="button">Copy install</button>
<button id="resetCommandForm" class="secondary" type="button">Reset fields</button>
</div>
<div class="result" aria-live="polite">
<strong>Command preview</strong>
<span id="commandPreview" class="mono">codex-reset status</span>
</div>
<p id="commandStatus" class="status">Build a command, then run it in your terminal.</p>
</section>
<section aria-labelledby="email-title">
<h2 id="email-title">Official handoff</h2>
<label>
Recipient email
<input id="email" type="email" inputmode="email" autocomplete="off" spellcheck="false" placeholder="name@example.com">
</label>
<div class="actions">
<button class="primary" id="copyEmail" type="button" disabled>Copy email</button>
<button id="copyChecklist" type="button" disabled>Copy checklist</button>
<button id="copyRecipientNote" type="button" disabled>Copy recipient note</button>
<button id="clearEmail" class="secondary" type="button">Clear</button>
</div>
<div class="result" aria-live="polite">
<strong>Normalized email</strong>
<span id="normalized" class="mono">No email entered</span>
<strong>Masked preview</strong>
<span id="masked" class="mono">-</span>
</div>
<p id="emailStatus" class="status">Enter an email to enable handoff actions.</p>
</section>
</div>
<div class="stack">
<section aria-labelledby="flow-title">
<h2 id="flow-title">Manual flow</h2>
<ol>
<li>Use the CLI to inspect reset credits before taking action.</li>
<li>Use the official Codex or ChatGPT invite UI when an invite email needs to be sent.</li>
<li>Send only if the official UI says the account is eligible and the action is available.</li>
<li>After the invite is accepted and a first Codex message is sent, use `codex-reset` to spend a banked reset when needed.</li>
</ol>
</section>
<section aria-labelledby="audit-title">
<h2 id="audit-title">Audit notes</h2>
<ul>
<li>The page never sends invites or redeems credits.</li>
<li>The page never reads `auth.json`, cookies, tokens, or account data.</li>
<li>The generated commands are visible before you copy them.</li>
<li class="warning">Redeeming a reset credit is irreversible once the CLI POST succeeds.</li>
</ul>
</section>
<section aria-labelledby="source-title">
<h2 id="source-title">Download and source</h2>
<p class="small">
Download the browser companion as a single HTML file, inspect it, and open it locally:
</p>
<p>
<a id="downloadLink" href="https://github.com/aaamosh/codex-reset/raw/main/codex-reset.html" rel="noopener noreferrer">Download codex-reset.html</a>
</p>
<p>
<a id="sourceLink" href="https://github.com/aaamosh/codex-reset/blob/main/codex-reset.html" rel="noopener noreferrer">View source on GitHub</a>
</p>
</section>
</div>
</div>
</main>
<script>
const installCommand = "curl -fsSL https://raw.githubusercontent.com/aaamosh/codex-reset/main/codex_reset.py -o ~/.local/bin/codex-reset && chmod +x ~/.local/bin/codex-reset";
const fields = {
authPath: document.querySelector("#authPath"),
resetAction: document.querySelector("#resetAction"),
creditId: document.querySelector("#creditId"),
cookieFile: document.querySelector("#cookieFile"),
jsonOutput: document.querySelector("#jsonOutput"),
dryRun: document.querySelector("#dryRun"),
assumeYes: document.querySelector("#assumeYes"),
commandPreview: document.querySelector("#commandPreview"),
commandStatus: document.querySelector("#commandStatus"),
email: document.querySelector("#email"),
normalized: document.querySelector("#normalized"),
masked: document.querySelector("#masked"),
emailStatus: document.querySelector("#emailStatus"),
copyEmail: document.querySelector("#copyEmail"),
copyChecklist: document.querySelector("#copyChecklist"),
copyRecipientNote: document.querySelector("#copyRecipientNote")
};
function shellQuote(value) {
if (/^[A-Za-z0-9_./:=@%+-]+$/.test(value)) return value;
return "'" + value.replace(/'/g, "'\\''") + "'";
}
function normalizeEmail(value) {
return value.trim().toLowerCase();
}
function isValidEmail(value) {
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
}
function maskPart(value) {
if (value.length <= 2) return value[0] + "*";
return value[0] + "*".repeat(Math.min(3, value.length - 2)) + value[value.length - 1];
}
function maskEmail(value) {
const parts = value.split("@");
if (parts.length !== 2) return "-";
const domainParts = parts[1].split(".");
const domainName = domainParts.shift() || "";
const suffix = domainParts.length > 0 ? "." + domainParts.join(".") : "";
return maskPart(parts[0]) + "@" + maskPart(domainName) + suffix;
}
async function copyText(value) {
if (navigator.clipboard && window.isSecureContext) {
await navigator.clipboard.writeText(value);
return;
}
const element = document.createElement("textarea");
element.value = value;
element.setAttribute("readonly", "");
element.style.position = "fixed";
element.style.left = "-9999px";
document.body.appendChild(element);
element.select();
document.execCommand("copy");
element.remove();
}
function buildCommand() {
const parts = ["codex-reset"];
const authPath = fields.authPath.value.trim();
if (authPath) parts.push("--auth", shellQuote(authPath));
const action = fields.resetAction.value;
parts.push(action);
if (action === "status" && fields.jsonOutput.checked) {
parts.push("--json");
}
if (action === "invite-status") {
if (fields.jsonOutput.checked) parts.push("--json");
const cookieFile = fields.cookieFile.value.trim();
if (cookieFile) parts.push("--cookie-file", shellQuote(cookieFile));
}
if (action === "consume") {
const creditId = fields.creditId.value.trim();
if (creditId) parts.push("--credit-id", shellQuote(creditId));
if (fields.dryRun.checked) parts.push("--dry-run");
if (fields.assumeYes.checked) parts.push("--yes");
}
return parts.join(" ");
}
function refreshCommand() {
const action = fields.resetAction.value;
fields.creditId.disabled = action !== "consume";
fields.cookieFile.disabled = action !== "invite-status";
fields.dryRun.disabled = action !== "consume";
fields.assumeYes.disabled = action !== "consume";
fields.commandPreview.textContent = buildCommand();
}
function checklist(email) {
return [
"Codex Reset official handoff checklist",
"",
"1. Open the official Codex or ChatGPT invite UI.",
"2. Paste recipient email: " + email,
"3. Send only through the official OpenAI UI if eligible.",
"4. Ask the recipient to accept the invite, open Codex, and send a first message.",
"5. Use codex-reset to inspect and spend banked reset credits when needed.",
"",
"This page does not send invites, redeem credits, or call OpenAI endpoints."
].join("\n");
}
function recipientNote(email) {
return [
"I sent the Codex invite through the official OpenAI UI for " + email + ".",
"Please check your inbox and spam folder, accept the invite, open Codex, and send your first message.",
"After that, any granted banked reset credit should appear in Codex Reset / Codex usage diagnostics."
].join("\n");
}
function refreshEmail() {
const email = normalizeEmail(fields.email.value);
const valid = isValidEmail(email);
fields.normalized.textContent = email || "No email entered";
fields.masked.textContent = valid ? maskEmail(email) : "-";
fields.copyEmail.disabled = !valid;
fields.copyChecklist.disabled = !valid;
fields.copyRecipientNote.disabled = !valid;
if (!email) {
fields.emailStatus.textContent = "Enter an email to enable handoff actions.";
fields.emailStatus.className = "status";
} else if (!valid) {
fields.emailStatus.textContent = "This does not look like an email yet.";
fields.emailStatus.className = "status error";
} else {
fields.emailStatus.textContent = "Ready. Copy the email, then use the official invite UI manually.";
fields.emailStatus.className = "status ok";
}
}
for (const item of [
fields.authPath,
fields.resetAction,
fields.creditId,
fields.cookieFile,
fields.jsonOutput,
fields.dryRun,
fields.assumeYes
]) {
item.addEventListener("input", refreshCommand);
item.addEventListener("change", refreshCommand);
}
fields.email.addEventListener("input", refreshEmail);
document.querySelector("#copyCommand").addEventListener("click", async () => {
await copyText(buildCommand());
fields.commandStatus.textContent = "Command copied.";
fields.commandStatus.className = "status ok";
});
document.querySelector("#copyInstall").addEventListener("click", async () => {
await copyText(installCommand);
fields.commandStatus.textContent = "Install command copied.";
fields.commandStatus.className = "status ok";
});
document.querySelector("#resetCommandForm").addEventListener("click", () => {
fields.authPath.value = "";
fields.resetAction.value = "status";
fields.creditId.value = "";
fields.cookieFile.value = "";
fields.jsonOutput.checked = false;
fields.dryRun.checked = false;
fields.assumeYes.checked = false;
fields.commandStatus.textContent = "Build a command, then run it in your terminal.";
fields.commandStatus.className = "status";
refreshCommand();
});
fields.copyEmail.addEventListener("click", async () => {
await copyText(normalizeEmail(fields.email.value));
fields.emailStatus.textContent = "Email copied.";
fields.emailStatus.className = "status ok";
});
fields.copyChecklist.addEventListener("click", async () => {
await copyText(checklist(normalizeEmail(fields.email.value)));
fields.emailStatus.textContent = "Checklist copied.";
fields.emailStatus.className = "status ok";
});
fields.copyRecipientNote.addEventListener("click", async () => {
await copyText(recipientNote(normalizeEmail(fields.email.value)));
fields.emailStatus.textContent = "Recipient note copied.";
fields.emailStatus.className = "status ok";
});
document.querySelector("#clearEmail").addEventListener("click", () => {
fields.email.value = "";
fields.email.focus();
refreshEmail();
});
refreshCommand();
refreshEmail();
</script>
</body>
</html>