codex-multi-auth 0.1.1 → 0.1.2
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/LICENSE +1 -1
- package/README.md +3 -2
- package/assets/readme-hero.svg +31 -31
- package/dist/lib/context-overflow.js +10 -10
- package/dist/lib/prompts/codex.js +2 -2
- package/dist/lib/runtime-paths.d.ts.map +1 -1
- package/dist/lib/runtime-paths.js +31 -5
- package/dist/lib/runtime-paths.js.map +1 -1
- package/dist/lib/storage/paths.d.ts.map +1 -1
- package/dist/lib/storage/paths.js +24 -6
- package/dist/lib/storage/paths.js.map +1 -1
- package/dist/lib/storage.d.ts.map +1 -1
- package/dist/lib/storage.js +184 -49
- package/dist/lib/storage.js.map +1 -1
- package/node_modules/@codex-ai/plugin/dist/index.d.ts +1 -1
- package/node_modules/@codex-ai/plugin/dist/tool.d.ts +41 -41
- package/node_modules/@codex-ai/plugin/dist/tool.js +28 -28
- package/package.json +1 -1
- package/scripts/audit-dev-allowlist.js +128 -128
- package/scripts/bench-format/hashline-v2.mjs +642 -642
- package/scripts/bench-format/render.mjs +496 -496
- package/scripts/bench-format/stats.mjs +54 -54
- package/scripts/bench-format/tasks.mjs +151 -151
- package/scripts/benchmark-render-dashboard.mjs +49 -49
- package/scripts/copy-oauth-success.js +37 -37
- package/scripts/test-all-models.sh +7 -7
- package/scripts/validate-model-map.sh +7 -7
- package/vendor/codex-ai-plugin/dist/index.d.ts +1 -1
- package/vendor/codex-ai-plugin/dist/tool.d.ts +41 -41
- package/vendor/codex-ai-plugin/dist/tool.js +28 -28
- package/vendor/codex-ai-sdk/dist/index.d.ts +3 -3
package/LICENSE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
package/README.md
CHANGED
|
@@ -268,8 +268,9 @@ codex auth doctor --json
|
|
|
268
268
|
|
|
269
269
|
## Release Notes
|
|
270
270
|
|
|
271
|
-
- Current stable: [docs/releases/v0.1.
|
|
272
|
-
- Previous stable: [docs/releases/v0.1.
|
|
271
|
+
- Current stable: [docs/releases/v0.1.2.md](docs/releases/v0.1.2.md)
|
|
272
|
+
- Previous stable: [docs/releases/v0.1.1.md](docs/releases/v0.1.1.md)
|
|
273
|
+
- Earlier stable: [docs/releases/v0.1.0.md](docs/releases/v0.1.0.md)
|
|
273
274
|
- Archived prerelease: [docs/releases/v0.1.0-beta.0.md](docs/releases/v0.1.0-beta.0.md)
|
|
274
275
|
|
|
275
276
|
## License
|
package/assets/readme-hero.svg
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="300" viewBox="0 0 1200 300" role="img" aria-label="Codex Multi-Auth OAuth">
|
|
2
|
-
<defs>
|
|
3
|
-
<linearGradient id="bg" x1="0" y1="0" x2="1" y2="1">
|
|
4
|
-
<stop offset="0%" stop-color="#0f172a" />
|
|
5
|
-
<stop offset="100%" stop-color="#1f2937" />
|
|
6
|
-
</linearGradient>
|
|
7
|
-
<linearGradient id="accent" x1="0" y1="0" x2="1" y2="0">
|
|
8
|
-
<stop offset="0%" stop-color="#38bdf8" />
|
|
9
|
-
<stop offset="100%" stop-color="#22d3ee" />
|
|
10
|
-
</linearGradient>
|
|
11
|
-
</defs>
|
|
12
|
-
<rect width="1200" height="300" rx="28" fill="url(#bg)" />
|
|
13
|
-
<g opacity="0.12">
|
|
14
|
-
<circle cx="1020" cy="70" r="120" fill="#38bdf8" />
|
|
15
|
-
<circle cx="150" cy="260" r="140" fill="#22d3ee" />
|
|
16
|
-
</g>
|
|
17
|
-
<g fill="none" stroke="url(#accent)" stroke-width="8" stroke-linecap="round" stroke-linejoin="round">
|
|
18
|
-
<path d="M160 95 L100 150 L160 205" />
|
|
19
|
-
<path d="M280 95 L340 150 L280 205" />
|
|
20
|
-
<path d="M205 80 L235 220" />
|
|
21
|
-
</g>
|
|
22
|
-
<text x="420" y="120" fill="#e2e8f0" font-size="42" font-family="'IBM Plex Sans','Segoe UI',Arial,sans-serif" font-weight="600">
|
|
23
|
-
Codex Multi-Auth OAuth
|
|
24
|
-
</text>
|
|
25
|
-
<text x="420" y="170" fill="#cbd5f5" font-size="24" font-family="'IBM Plex Sans','Segoe UI',Arial,sans-serif">
|
|
26
|
-
ChatGPT Plus/Pro auth for GPT-5.2 and Codex models
|
|
27
|
-
</text>
|
|
28
|
-
<text x="420" y="220" fill="#7dd3fc" font-size="18" font-family="'IBM Plex Sans','Segoe UI',Arial,sans-serif">
|
|
29
|
-
One-command install, modern variants, full tool support
|
|
30
|
-
</text>
|
|
31
|
-
</svg>
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="300" viewBox="0 0 1200 300" role="img" aria-label="Codex Multi-Auth OAuth">
|
|
2
|
+
<defs>
|
|
3
|
+
<linearGradient id="bg" x1="0" y1="0" x2="1" y2="1">
|
|
4
|
+
<stop offset="0%" stop-color="#0f172a" />
|
|
5
|
+
<stop offset="100%" stop-color="#1f2937" />
|
|
6
|
+
</linearGradient>
|
|
7
|
+
<linearGradient id="accent" x1="0" y1="0" x2="1" y2="0">
|
|
8
|
+
<stop offset="0%" stop-color="#38bdf8" />
|
|
9
|
+
<stop offset="100%" stop-color="#22d3ee" />
|
|
10
|
+
</linearGradient>
|
|
11
|
+
</defs>
|
|
12
|
+
<rect width="1200" height="300" rx="28" fill="url(#bg)" />
|
|
13
|
+
<g opacity="0.12">
|
|
14
|
+
<circle cx="1020" cy="70" r="120" fill="#38bdf8" />
|
|
15
|
+
<circle cx="150" cy="260" r="140" fill="#22d3ee" />
|
|
16
|
+
</g>
|
|
17
|
+
<g fill="none" stroke="url(#accent)" stroke-width="8" stroke-linecap="round" stroke-linejoin="round">
|
|
18
|
+
<path d="M160 95 L100 150 L160 205" />
|
|
19
|
+
<path d="M280 95 L340 150 L280 205" />
|
|
20
|
+
<path d="M205 80 L235 220" />
|
|
21
|
+
</g>
|
|
22
|
+
<text x="420" y="120" fill="#e2e8f0" font-size="42" font-family="'IBM Plex Sans','Segoe UI',Arial,sans-serif" font-weight="600">
|
|
23
|
+
Codex Multi-Auth OAuth
|
|
24
|
+
</text>
|
|
25
|
+
<text x="420" y="170" fill="#cbd5f5" font-size="24" font-family="'IBM Plex Sans','Segoe UI',Arial,sans-serif">
|
|
26
|
+
ChatGPT Plus/Pro auth for GPT-5.2 and Codex models
|
|
27
|
+
</text>
|
|
28
|
+
<text x="420" y="220" fill="#7dd3fc" font-size="18" font-family="'IBM Plex Sans','Segoe UI',Arial,sans-serif">
|
|
29
|
+
One-command install, modern variants, full tool support
|
|
30
|
+
</text>
|
|
31
|
+
</svg>
|
|
@@ -32,16 +32,16 @@ export function isContextOverflowError(status, bodyText) {
|
|
|
32
32
|
/**
|
|
33
33
|
* The message shown to users when context overflow occurs
|
|
34
34
|
*/
|
|
35
|
-
const CONTEXT_OVERFLOW_MESSAGE = `[Plugin Notice] Context is too long for this model.
|
|
36
|
-
|
|
37
|
-
Please use one of these commands to reduce context size:
|
|
38
|
-
|
|
39
|
-
• **/compact** - Compress conversation history (recommended)
|
|
40
|
-
• **/clear** - Start fresh with empty context
|
|
41
|
-
• **/undo** - Remove recent messages
|
|
42
|
-
|
|
43
|
-
Then retry your request.
|
|
44
|
-
|
|
35
|
+
const CONTEXT_OVERFLOW_MESSAGE = `[Plugin Notice] Context is too long for this model.
|
|
36
|
+
|
|
37
|
+
Please use one of these commands to reduce context size:
|
|
38
|
+
|
|
39
|
+
• **/compact** - Compress conversation history (recommended)
|
|
40
|
+
• **/clear** - Start fresh with empty context
|
|
41
|
+
• **/undo** - Remove recent messages
|
|
42
|
+
|
|
43
|
+
Then retry your request.
|
|
44
|
+
|
|
45
45
|
Alternatively, you can switch to a model with a larger context window.`;
|
|
46
46
|
/**
|
|
47
47
|
* Creates a synthetic SSE response for context overflow errors.
|
|
@@ -307,7 +307,7 @@ YOU ARE IN A DIFFERENT ENVIRONMENT. These instructions override ALL previous too
|
|
|
307
307
|
|
|
308
308
|
<tool_replacements priority="0">
|
|
309
309
|
<critical_rule priority="0">
|
|
310
|
-
apply_patch/applyPatch are Codex names, but host tool names vary by version.
|
|
310
|
+
apply_patch/applyPatch are Codex names, but host tool names vary by version.
|
|
311
311
|
- Inspect the actual tool list before editing.
|
|
312
312
|
- If edit exists: use edit for precise in-place string replacements and hashline edits.
|
|
313
313
|
- If edit is absent and apply_patch exists: use apply_patch for those precise/hashline edits in this plugin.
|
|
@@ -329,7 +329,7 @@ File Operations:
|
|
|
329
329
|
- write - Create new files (if available)
|
|
330
330
|
- edit - Modify existing files with string replacement (version-dependent)
|
|
331
331
|
- oldString must be literal text from the current file; never pass unresolved placeholders like \${TARGET_SNIPPET}
|
|
332
|
-
- apply_patch - May be the edit/patch tool name in newer host builds (version-dependent)
|
|
332
|
+
- apply_patch - May be the edit/patch tool name in newer host builds (version-dependent)
|
|
333
333
|
- hashline_read - Read lines with hashline refs (L<line>#<hash>) for deterministic edits
|
|
334
334
|
- patch - Apply diff patches (version-dependent)
|
|
335
335
|
- read - Read file contents
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-paths.d.ts","sourceRoot":"","sources":["../../lib/runtime-paths.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtime-paths.d.ts","sourceRoot":"","sources":["../../lib/runtime-paths.ts"],"names":[],"mappings":"AAkCA;;;;;;GAMG;AAEH,wBAAgB,eAAe,IAAI,MAAM,CAGxC;AAwFD;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAiC7C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C"}
|
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
import { homedir } from "node:os";
|
|
2
|
-
import { join } from "node:path";
|
|
2
|
+
import { join, win32 } from "node:path";
|
|
3
3
|
import { existsSync } from "node:fs";
|
|
4
|
+
function firstNonEmpty(values) {
|
|
5
|
+
for (const value of values) {
|
|
6
|
+
const trimmed = (value ?? "").trim();
|
|
7
|
+
if (trimmed.length > 0) {
|
|
8
|
+
return trimmed;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
function getResolvedUserHomeDir() {
|
|
14
|
+
if (process.platform === "win32") {
|
|
15
|
+
const homeDrive = (process.env.HOMEDRIVE ?? "").trim();
|
|
16
|
+
const homePath = (process.env.HOMEPATH ?? "").trim();
|
|
17
|
+
const drivePathHome = homeDrive.length > 0 && homePath.length > 0
|
|
18
|
+
? win32.resolve(`${homeDrive}\\`, homePath)
|
|
19
|
+
: undefined;
|
|
20
|
+
return (firstNonEmpty([
|
|
21
|
+
process.env.USERPROFILE,
|
|
22
|
+
process.env.HOME,
|
|
23
|
+
drivePathHome,
|
|
24
|
+
homedir(),
|
|
25
|
+
]) ?? homedir());
|
|
26
|
+
}
|
|
27
|
+
return firstNonEmpty([process.env.HOME, homedir()]) ?? homedir();
|
|
28
|
+
}
|
|
4
29
|
/**
|
|
5
30
|
* Resolve the Codex home directory path used by the CLI, honoring an environment override or a sensible default.
|
|
6
31
|
*
|
|
@@ -10,7 +35,7 @@ import { existsSync } from "node:fs";
|
|
|
10
35
|
*/
|
|
11
36
|
export function getCodexHomeDir() {
|
|
12
37
|
const fromEnv = (process.env.CODEX_HOME ?? "").trim();
|
|
13
|
-
return fromEnv.length > 0 ? fromEnv : join(
|
|
38
|
+
return fromEnv.length > 0 ? fromEnv : join(getResolvedUserHomeDir(), ".codex");
|
|
14
39
|
}
|
|
15
40
|
/**
|
|
16
41
|
* Returns a deduplicated list of path strings preserving the first occurrence order.
|
|
@@ -89,10 +114,11 @@ function hasAccountsStorage(dir) {
|
|
|
89
114
|
* @returns An array of unique, trimmed directory paths to probe for Codex home data, in prioritized order.
|
|
90
115
|
*/
|
|
91
116
|
function getFallbackCodexHomeDirs() {
|
|
117
|
+
const userHome = getResolvedUserHomeDir();
|
|
92
118
|
return deduplicatePaths([
|
|
93
119
|
getCodexHomeDir(),
|
|
94
|
-
join(
|
|
95
|
-
join(
|
|
120
|
+
join(userHome, "DevTools", "config", "codex"),
|
|
121
|
+
join(userHome, ".codex"),
|
|
96
122
|
]);
|
|
97
123
|
}
|
|
98
124
|
/**
|
|
@@ -177,6 +203,6 @@ export function getCodexLogDir() {
|
|
|
177
203
|
* @returns The filesystem path for the legacy directory (e.g. `/home/alice/.codex`).
|
|
178
204
|
*/
|
|
179
205
|
export function getLegacyCodexDir() {
|
|
180
|
-
return join(
|
|
206
|
+
return join(getResolvedUserHomeDir(), ".codex");
|
|
181
207
|
}
|
|
182
208
|
//# sourceMappingURL=runtime-paths.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-paths.js","sourceRoot":"","sources":["../../lib/runtime-paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"runtime-paths.js","sourceRoot":"","sources":["../../lib/runtime-paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,SAAS,aAAa,CAAC,MAAiC;IACvD,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC5B,MAAM,OAAO,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QACrC,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,OAAO,OAAO,CAAC;QAChB,CAAC;IACF,CAAC;IACD,OAAO,IAA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,iBAAiB,CAAC,SAAS,CAAC,EAAE,CAAC;YAClC,OAAO,SAAS,CAAC;QAClB,CAAC;IACF,CAAC;IAED,OAAO,OAAO,CAAC;AAChB,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gBAAgB;IAC/B,OAAO,IAAI,CAAC,oBAAoB,EAAE,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,cAAc;IAC7B,OAAO,IAAI,CAAC,oBAAoB,EAAE,EAAE,MAAM,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,iBAAiB;IAChC,OAAO,IAAI,CAAC,sBAAsB,EAAE,EAAE,QAAQ,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../../lib/storage/paths.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../../lib/storage/paths.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA+IH;;;;;;GAMG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE/D;AAwCD;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAQhE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAErE;AAED;;;;;;;;;GASG;AACH,wBAAgB,iCAAiC,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CA0C7E;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAqB/D;AAcD,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAoBpD"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Path resolution utilities for account storage.
|
|
3
3
|
* Extracted from storage.ts to reduce module size.
|
|
4
4
|
*/
|
|
5
|
-
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
5
|
+
import { existsSync, readFileSync, realpathSync, statSync } from "node:fs";
|
|
6
6
|
import { createHash } from "node:crypto";
|
|
7
7
|
import { basename, dirname, isAbsolute, join, relative, resolve, win32 } from "node:path";
|
|
8
8
|
import { homedir, tmpdir } from "node:os";
|
|
@@ -77,6 +77,21 @@ function normalizePathForIdentityCheck(pathValue) {
|
|
|
77
77
|
const normalizedResolved = normalizePathDelimiters(resolvedPath);
|
|
78
78
|
return process.platform === "win32" ? normalizedResolved.toLowerCase() : normalizedResolved;
|
|
79
79
|
}
|
|
80
|
+
function normalizeCanonicalPathForIdentityCheck(pathValue) {
|
|
81
|
+
const normalized = normalizePathForIdentityCheck(pathValue);
|
|
82
|
+
if (!normalized) {
|
|
83
|
+
return normalized;
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
const canonical = typeof realpathSync.native === "function"
|
|
87
|
+
? realpathSync.native(pathValue)
|
|
88
|
+
: realpathSync(pathValue);
|
|
89
|
+
return normalizePathForIdentityCheck(canonical);
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
return normalized;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
80
95
|
function worktreeGitDirBelongsToProject(projectRoot, gitDirPath) {
|
|
81
96
|
const gitdirBackRefPath = join(gitDirPath, "gitdir");
|
|
82
97
|
if (!existsSync(gitdirBackRefPath)) {
|
|
@@ -89,8 +104,8 @@ function worktreeGitDirBelongsToProject(projectRoot, gitDirPath) {
|
|
|
89
104
|
}
|
|
90
105
|
const resolvedBackRef = resolveGitPath(gitDirPath, gitdirBackRefRaw);
|
|
91
106
|
const expectedBackRef = join(projectRoot, ".git");
|
|
92
|
-
return (
|
|
93
|
-
|
|
107
|
+
return (normalizeCanonicalPathForIdentityCheck(resolvedBackRef) ===
|
|
108
|
+
normalizeCanonicalPathForIdentityCheck(expectedBackRef));
|
|
94
109
|
}
|
|
95
110
|
catch {
|
|
96
111
|
return false;
|
|
@@ -252,18 +267,21 @@ export function isProjectDirectory(dir) {
|
|
|
252
267
|
}
|
|
253
268
|
export function findProjectRoot(startDir) {
|
|
254
269
|
let current = startDir;
|
|
255
|
-
|
|
270
|
+
let firstMarkerRoot = null;
|
|
256
271
|
while (current) {
|
|
257
|
-
if (
|
|
272
|
+
if (existsSync(join(current, ".git"))) {
|
|
258
273
|
return current;
|
|
259
274
|
}
|
|
275
|
+
if (!firstMarkerRoot && isProjectDirectory(current)) {
|
|
276
|
+
firstMarkerRoot = current;
|
|
277
|
+
}
|
|
260
278
|
const parent = dirname(current);
|
|
261
279
|
if (parent === current) {
|
|
262
280
|
break;
|
|
263
281
|
}
|
|
264
282
|
current = parent;
|
|
265
283
|
}
|
|
266
|
-
return
|
|
284
|
+
return firstMarkerRoot;
|
|
267
285
|
}
|
|
268
286
|
function normalizePathForComparison(filePath) {
|
|
269
287
|
const resolvedPath = resolve(filePath);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../../lib/storage/paths.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../../lib/storage/paths.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,U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AC,yFAAyF,CAAC,CAAC;IAC5G,CAAC;IAED,OAAO,QAAQ,CAAC;AACjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../lib/storage.ts"],"names":[],"mappings":"AAeA,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACtB,MAAM,yBAAyB,CAAC;AAEjC,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../lib/storage.ts"],"names":[],"mappings":"AAeA,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACtB,MAAM,yBAAyB,CAAC;AAEjC,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;AAe3H,MAAM,WAAW,wBAAyB,SAAQ,iBAAiB;IAClE,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,uBAAuB;IACvC,OAAO,EAAE,CAAC,CAAC;IACX,QAAQ,EAAE,wBAAwB,EAAE,CAAC;CACrC;AAED;;GAEG;AACH,qBAAa,YAAa,SAAQ,KAAK;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,OAAO,EAAE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AG,IAAI,CAyF9E;AAED;;;;GAIG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAErE;AA2OD,wBAAsB,6BAA6B,CAAC,CAAC,EACnD,OAAO,EAAE,CACP,OAAO,EAAE,gBAAgB,GAAG,IAAI,EAChC,OAAO,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,KAClD,OAAO,CAAC,CAAC,CAAC,GACd,OAAO,CAAC,CAAC,CAAC,CAKZ;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAI3E;AAED;;;GAGG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAyBnD;AA8ED,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,uBAAuB,CAAC,CA+C5E;AAED,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAqBzF;AAED,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CAW1D;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,UAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBlF;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAyDpH"}
|
package/dist/lib/storage.js
CHANGED
|
@@ -13,6 +13,7 @@ const FLAGGED_ACCOUNTS_FILE_NAME = "openai-codex-flagged-accounts.json";
|
|
|
13
13
|
const LEGACY_FLAGGED_ACCOUNTS_FILE_NAME = "openai-codex-blocked-accounts.json";
|
|
14
14
|
const ACCOUNTS_BACKUP_SUFFIX = ".bak";
|
|
15
15
|
const ACCOUNTS_WAL_SUFFIX = ".wal";
|
|
16
|
+
const ACCOUNTS_BACKUP_HISTORY_DEPTH = 3;
|
|
16
17
|
const BACKUP_COPY_MAX_ATTEMPTS = 5;
|
|
17
18
|
const BACKUP_COPY_BASE_DELAY_MS = 10;
|
|
18
19
|
let storageBackupEnabled = true;
|
|
@@ -103,9 +104,156 @@ export function setStorageBackupEnabled(enabled) {
|
|
|
103
104
|
function getAccountsBackupPath(path) {
|
|
104
105
|
return `${path}${ACCOUNTS_BACKUP_SUFFIX}`;
|
|
105
106
|
}
|
|
107
|
+
function getAccountsBackupPathAtIndex(path, index) {
|
|
108
|
+
if (index <= 0) {
|
|
109
|
+
return getAccountsBackupPath(path);
|
|
110
|
+
}
|
|
111
|
+
return `${path}${ACCOUNTS_BACKUP_SUFFIX}.${index}`;
|
|
112
|
+
}
|
|
113
|
+
function getAccountsBackupRecoveryCandidates(path) {
|
|
114
|
+
const candidates = [];
|
|
115
|
+
for (let i = 0; i < ACCOUNTS_BACKUP_HISTORY_DEPTH; i += 1) {
|
|
116
|
+
candidates.push(getAccountsBackupPathAtIndex(path, i));
|
|
117
|
+
}
|
|
118
|
+
return candidates;
|
|
119
|
+
}
|
|
106
120
|
function getAccountsWalPath(path) {
|
|
107
121
|
return `${path}${ACCOUNTS_WAL_SUFFIX}`;
|
|
108
122
|
}
|
|
123
|
+
async function copyFileWithRetry(sourcePath, destinationPath, options) {
|
|
124
|
+
const allowMissingSource = options?.allowMissingSource ?? false;
|
|
125
|
+
for (let attempt = 0; attempt < BACKUP_COPY_MAX_ATTEMPTS; attempt += 1) {
|
|
126
|
+
try {
|
|
127
|
+
await fs.copyFile(sourcePath, destinationPath);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
const code = error.code;
|
|
132
|
+
if (allowMissingSource && code === "ENOENT") {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const canRetry = (code === "EPERM" || code === "EBUSY") &&
|
|
136
|
+
attempt + 1 < BACKUP_COPY_MAX_ATTEMPTS;
|
|
137
|
+
if (canRetry) {
|
|
138
|
+
await new Promise((resolve) => setTimeout(resolve, BACKUP_COPY_BASE_DELAY_MS * 2 ** attempt));
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
throw error;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
async function renameFileWithRetry(sourcePath, destinationPath) {
|
|
146
|
+
for (let attempt = 0; attempt < BACKUP_COPY_MAX_ATTEMPTS; attempt += 1) {
|
|
147
|
+
try {
|
|
148
|
+
await fs.rename(sourcePath, destinationPath);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
const code = error.code;
|
|
153
|
+
const canRetry = (code === "EPERM" || code === "EBUSY" || code === "EAGAIN") &&
|
|
154
|
+
attempt + 1 < BACKUP_COPY_MAX_ATTEMPTS;
|
|
155
|
+
if (!canRetry) {
|
|
156
|
+
throw error;
|
|
157
|
+
}
|
|
158
|
+
const jitterMs = Math.floor(Math.random() * BACKUP_COPY_BASE_DELAY_MS);
|
|
159
|
+
await new Promise((resolve) => setTimeout(resolve, BACKUP_COPY_BASE_DELAY_MS * 2 ** attempt + jitterMs));
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
async function createRotatingAccountsBackup(path) {
|
|
164
|
+
const candidates = getAccountsBackupRecoveryCandidates(path);
|
|
165
|
+
const rotationNonce = `${Date.now()}.${Math.random().toString(36).slice(2, 8)}`;
|
|
166
|
+
const stagedWrites = [];
|
|
167
|
+
const buildStagedPath = (targetPath, label) => `${targetPath}.rotate.${rotationNonce}.${label}.tmp`;
|
|
168
|
+
try {
|
|
169
|
+
for (let i = candidates.length - 1; i > 0; i -= 1) {
|
|
170
|
+
const previousPath = candidates[i - 1];
|
|
171
|
+
const currentPath = candidates[i];
|
|
172
|
+
if (!previousPath || !currentPath || !existsSync(previousPath)) {
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
const stagedPath = buildStagedPath(currentPath, `slot-${i}`);
|
|
176
|
+
await copyFileWithRetry(previousPath, stagedPath, { allowMissingSource: true });
|
|
177
|
+
if (existsSync(stagedPath)) {
|
|
178
|
+
stagedWrites.push({ targetPath: currentPath, stagedPath });
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
const latestBackupPath = candidates[0];
|
|
182
|
+
if (!latestBackupPath) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
const latestStagedPath = buildStagedPath(latestBackupPath, "latest");
|
|
186
|
+
await copyFileWithRetry(path, latestStagedPath);
|
|
187
|
+
if (existsSync(latestStagedPath)) {
|
|
188
|
+
stagedWrites.push({ targetPath: latestBackupPath, stagedPath: latestStagedPath });
|
|
189
|
+
}
|
|
190
|
+
for (const stagedWrite of stagedWrites) {
|
|
191
|
+
await renameFileWithRetry(stagedWrite.stagedPath, stagedWrite.targetPath);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
finally {
|
|
195
|
+
for (const stagedWrite of stagedWrites) {
|
|
196
|
+
if (!existsSync(stagedWrite.stagedPath)) {
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
try {
|
|
200
|
+
await fs.unlink(stagedWrite.stagedPath);
|
|
201
|
+
}
|
|
202
|
+
catch {
|
|
203
|
+
// Best effort cleanup for staged rotation artifacts.
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
function isRotatingBackupTempArtifact(storagePath, candidatePath) {
|
|
209
|
+
const backupPrefix = `${storagePath}${ACCOUNTS_BACKUP_SUFFIX}`;
|
|
210
|
+
if (!candidatePath.startsWith(backupPrefix) || !candidatePath.endsWith(".tmp")) {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
const suffix = candidatePath.slice(backupPrefix.length);
|
|
214
|
+
const rotateSeparatorIndex = suffix.indexOf(".rotate.");
|
|
215
|
+
if (rotateSeparatorIndex === -1) {
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
const backupIndexSuffix = suffix.slice(0, rotateSeparatorIndex);
|
|
219
|
+
if (backupIndexSuffix.length > 0 && !/^\.\d+$/.test(backupIndexSuffix)) {
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
async function cleanupStaleRotatingBackupArtifacts(path) {
|
|
225
|
+
const directoryPath = dirname(path);
|
|
226
|
+
try {
|
|
227
|
+
const directoryEntries = await fs.readdir(directoryPath, { withFileTypes: true });
|
|
228
|
+
const staleArtifacts = directoryEntries
|
|
229
|
+
.filter((entry) => entry.isFile())
|
|
230
|
+
.map((entry) => join(directoryPath, entry.name))
|
|
231
|
+
.filter((entryPath) => isRotatingBackupTempArtifact(path, entryPath));
|
|
232
|
+
for (const staleArtifactPath of staleArtifacts) {
|
|
233
|
+
try {
|
|
234
|
+
await fs.unlink(staleArtifactPath);
|
|
235
|
+
}
|
|
236
|
+
catch (error) {
|
|
237
|
+
const code = error.code;
|
|
238
|
+
if (code !== "ENOENT") {
|
|
239
|
+
log.warn("Failed to remove stale rotating backup artifact", {
|
|
240
|
+
path: staleArtifactPath,
|
|
241
|
+
error: String(error),
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
catch (error) {
|
|
248
|
+
const code = error.code;
|
|
249
|
+
if (code !== "ENOENT") {
|
|
250
|
+
log.warn("Failed to scan for stale rotating backup artifacts", {
|
|
251
|
+
path,
|
|
252
|
+
error: String(error),
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
109
257
|
function computeSha256(value) {
|
|
110
258
|
return createHash("sha256").update(value).digest("hex");
|
|
111
259
|
}
|
|
@@ -522,6 +670,7 @@ async function loadAccountsFromJournal(path) {
|
|
|
522
670
|
}
|
|
523
671
|
async function loadAccountsInternal(persistMigration) {
|
|
524
672
|
const path = getStoragePath();
|
|
673
|
+
await cleanupStaleRotatingBackupArtifacts(path);
|
|
525
674
|
const migratedLegacyStorage = persistMigration
|
|
526
675
|
? await migrateLegacyProjectStorageIfNeeded(persistMigration)
|
|
527
676
|
: null;
|
|
@@ -564,38 +713,40 @@ async function loadAccountsInternal(persistMigration) {
|
|
|
564
713
|
return recoveredFromWal;
|
|
565
714
|
}
|
|
566
715
|
if (storageBackupEnabled) {
|
|
567
|
-
const
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
716
|
+
const backupCandidates = getAccountsBackupRecoveryCandidates(path);
|
|
717
|
+
for (const backupPath of backupCandidates) {
|
|
718
|
+
try {
|
|
719
|
+
const backup = await loadAccountsFromPath(backupPath);
|
|
720
|
+
if (backup.schemaErrors.length > 0) {
|
|
721
|
+
log.warn("Backup account storage schema validation warnings", {
|
|
722
|
+
path: backupPath,
|
|
723
|
+
errors: backup.schemaErrors.slice(0, 5),
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
if (backup.normalized) {
|
|
727
|
+
log.warn("Recovered account storage from backup file", { path, backupPath });
|
|
728
|
+
if (persistMigration) {
|
|
729
|
+
try {
|
|
730
|
+
await persistMigration(backup.normalized);
|
|
731
|
+
}
|
|
732
|
+
catch (persistError) {
|
|
733
|
+
log.warn("Failed to persist recovered backup storage", {
|
|
734
|
+
path,
|
|
735
|
+
error: String(persistError),
|
|
736
|
+
});
|
|
737
|
+
}
|
|
587
738
|
}
|
|
739
|
+
return backup.normalized;
|
|
588
740
|
}
|
|
589
|
-
return backup.normalized;
|
|
590
741
|
}
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
}
|
|
742
|
+
catch (backupError) {
|
|
743
|
+
const backupCode = backupError.code;
|
|
744
|
+
if (backupCode !== "ENOENT") {
|
|
745
|
+
log.warn("Failed to load backup account storage", {
|
|
746
|
+
path: backupPath,
|
|
747
|
+
error: String(backupError),
|
|
748
|
+
});
|
|
749
|
+
}
|
|
599
750
|
}
|
|
600
751
|
}
|
|
601
752
|
}
|
|
@@ -614,29 +765,13 @@ async function saveAccountsUnlocked(storage) {
|
|
|
614
765
|
await fs.mkdir(dirname(path), { recursive: true });
|
|
615
766
|
await ensureGitignore(path);
|
|
616
767
|
if (storageBackupEnabled && existsSync(path)) {
|
|
617
|
-
const backupPath = getAccountsBackupPath(path);
|
|
618
768
|
try {
|
|
619
|
-
|
|
620
|
-
try {
|
|
621
|
-
await fs.copyFile(path, backupPath);
|
|
622
|
-
break;
|
|
623
|
-
}
|
|
624
|
-
catch (backupError) {
|
|
625
|
-
const code = backupError.code;
|
|
626
|
-
const canRetry = (code === "EPERM" || code === "EBUSY") &&
|
|
627
|
-
attempt + 1 < BACKUP_COPY_MAX_ATTEMPTS;
|
|
628
|
-
if (canRetry) {
|
|
629
|
-
await new Promise((resolve) => setTimeout(resolve, BACKUP_COPY_BASE_DELAY_MS * 2 ** attempt));
|
|
630
|
-
continue;
|
|
631
|
-
}
|
|
632
|
-
throw backupError;
|
|
633
|
-
}
|
|
634
|
-
}
|
|
769
|
+
await createRotatingAccountsBackup(path);
|
|
635
770
|
}
|
|
636
771
|
catch (backupError) {
|
|
637
772
|
log.warn("Failed to create account storage backup", {
|
|
638
773
|
path,
|
|
639
|
-
backupPath,
|
|
774
|
+
backupPath: getAccountsBackupPath(path),
|
|
640
775
|
error: String(backupError),
|
|
641
776
|
});
|
|
642
777
|
}
|
|
@@ -731,7 +866,7 @@ export async function clearAccounts() {
|
|
|
731
866
|
return withStorageLock(async () => {
|
|
732
867
|
const path = getStoragePath();
|
|
733
868
|
const walPath = getAccountsWalPath(path);
|
|
734
|
-
const
|
|
869
|
+
const backupPaths = getAccountsBackupRecoveryCandidates(path);
|
|
735
870
|
const clearPath = async (targetPath) => {
|
|
736
871
|
try {
|
|
737
872
|
await fs.unlink(targetPath);
|
|
@@ -747,7 +882,7 @@ export async function clearAccounts() {
|
|
|
747
882
|
}
|
|
748
883
|
};
|
|
749
884
|
try {
|
|
750
|
-
await Promise.all([clearPath(path), clearPath(walPath), clearPath
|
|
885
|
+
await Promise.all([clearPath(path), clearPath(walPath), ...backupPaths.map(clearPath)]);
|
|
751
886
|
}
|
|
752
887
|
catch {
|
|
753
888
|
// Individual path cleanup is already best-effort with per-artifact logging.
|