@atomic-chat/core 0.19.0 → 0.20.5
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/dist/app-daemon.js +5 -0
- package/dist/app-daemon.js.map +1 -1
- package/dist/cli/bin.js +0 -0
- package/dist/cli/launch.js +2 -0
- package/dist/cli/launch.js.map +1 -1
- package/dist/cli/main.d.ts +1 -1
- package/dist/cli/main.js +5 -0
- package/dist/cli/main.js.map +1 -1
- package/dist/cloud/registry.js +1 -0
- package/dist/cloud/registry.js.map +1 -1
- package/dist/config/paths.d.ts +1 -1
- package/dist/config/paths.js +12 -0
- package/dist/config/paths.js.map +1 -1
- package/dist/contracts/engine-builds.d.ts +6 -1
- package/dist/contracts/engine-builds.js +1 -1
- package/dist/contracts/engine-builds.js.map +1 -1
- package/dist/contracts/engines.d.ts +1 -1
- package/dist/contracts/engines.js +2 -0
- package/dist/contracts/engines.js.map +1 -1
- package/dist/contracts/errors.d.ts +7 -1
- package/dist/contracts/errors.js.map +1 -1
- package/dist/contracts/events.d.ts +3 -1
- package/dist/contracts/geniex.d.ts +98 -0
- package/dist/contracts/geniex.js +15 -0
- package/dist/contracts/geniex.js.map +1 -0
- package/dist/contracts/index.d.ts +1 -0
- package/dist/contracts/index.js +1 -0
- package/dist/contracts/index.js.map +1 -1
- package/dist/contracts/model-yml.d.ts +40 -0
- package/dist/contracts/model-yml.js +7 -0
- package/dist/contracts/model-yml.js.map +1 -1
- package/dist/contracts/session.d.ts +6 -1
- package/dist/contracts/session.js.map +1 -1
- package/dist/contracts/settings.d.ts +12 -1
- package/dist/contracts/settings.js.map +1 -1
- package/dist/core/app-lease.d.ts +56 -0
- package/dist/core/app-lease.js +50 -0
- package/dist/core/app-lease.js.map +1 -0
- package/dist/core/atomic-core.d.ts +1 -1
- package/dist/core/create.js +109 -5
- package/dist/core/create.js.map +1 -1
- package/dist/engine-builds/engines.d.ts +28 -7
- package/dist/engine-builds/engines.js +49 -5
- package/dist/engine-builds/engines.js.map +1 -1
- package/dist/engine-builds/geniex.d.ts +35 -0
- package/dist/engine-builds/geniex.js +111 -0
- package/dist/engine-builds/geniex.js.map +1 -0
- package/dist/engine-builds/manifest.d.ts +43 -0
- package/dist/engine-builds/manifest.js +92 -0
- package/dist/engine-builds/manifest.js.map +1 -1
- package/dist/engine-builds/order.d.ts +2 -1
- package/dist/engine-builds/order.js +2 -0
- package/dist/engine-builds/order.js.map +1 -1
- package/dist/engine-builds/select.d.ts +15 -0
- package/dist/engine-builds/select.js +14 -0
- package/dist/engine-builds/select.js.map +1 -1
- package/dist/engine-builds/service.d.ts +5 -3
- package/dist/engine-builds/service.js +21 -2
- package/dist/engine-builds/service.js.map +1 -1
- package/dist/engines/service.d.ts +2 -1
- package/dist/engines/service.js +3 -1
- package/dist/engines/service.js.map +1 -1
- package/dist/engines/versions.js +3 -0
- package/dist/engines/versions.js.map +1 -1
- package/dist/integrations/catalog.d.ts +3 -1
- package/dist/integrations/catalog.js +8 -2
- package/dist/integrations/catalog.js.map +1 -1
- package/dist/integrations/config-io.d.ts +45 -4
- package/dist/integrations/config-io.js +91 -6
- package/dist/integrations/config-io.js.map +1 -1
- package/dist/integrations/configure/codex-repair.d.ts +75 -0
- package/dist/integrations/configure/codex-repair.js +254 -0
- package/dist/integrations/configure/codex-repair.js.map +1 -0
- package/dist/integrations/configure/codex.d.ts +48 -10
- package/dist/integrations/configure/codex.js +126 -32
- package/dist/integrations/configure/codex.js.map +1 -1
- package/dist/integrations/configure/registry.d.ts +4 -1
- package/dist/integrations/configure/registry.js +1 -0
- package/dist/integrations/configure/registry.js.map +1 -1
- package/dist/models/gguf/kv-cache.d.ts +5 -0
- package/dist/models/gguf/kv-cache.js +35 -2
- package/dist/models/gguf/kv-cache.js.map +1 -1
- package/dist/models/gguf/reader.d.ts +5 -0
- package/dist/models/gguf/reader.js +15 -3
- package/dist/models/gguf/reader.js.map +1 -1
- package/dist/router/resolve.d.ts +3 -2
- package/dist/router/resolve.js +3 -1
- package/dist/router/resolve.js.map +1 -1
- package/dist/runtime/geniex/accelerators.d.ts +20 -0
- package/dist/runtime/geniex/accelerators.js +53 -0
- package/dist/runtime/geniex/accelerators.js.map +1 -0
- package/dist/runtime/geniex/check.d.ts +34 -0
- package/dist/runtime/geniex/check.js +117 -0
- package/dist/runtime/geniex/check.js.map +1 -0
- package/dist/runtime/geniex/chip.d.ts +29 -0
- package/dist/runtime/geniex/chip.js +35 -0
- package/dist/runtime/geniex/chip.js.map +1 -0
- package/dist/runtime/geniex/devices.d.ts +13 -0
- package/dist/runtime/geniex/devices.js +32 -0
- package/dist/runtime/geniex/devices.js.map +1 -0
- package/dist/runtime/geniex/geniex-host.d.ts +17 -0
- package/dist/runtime/geniex/geniex-host.js +26 -0
- package/dist/runtime/geniex/geniex-host.js.map +1 -0
- package/dist/runtime/geniex/host/args.d.ts +56 -0
- package/dist/runtime/geniex/host/args.js +115 -0
- package/dist/runtime/geniex/host/args.js.map +1 -0
- package/dist/runtime/geniex/host/engine.d.ts +76 -0
- package/dist/runtime/geniex/host/engine.js +122 -0
- package/dist/runtime/geniex/host/engine.js.map +1 -0
- package/dist/runtime/geniex/host/ffi-bun.d.ts +15 -0
- package/dist/runtime/geniex/host/ffi-bun.js +415 -0
- package/dist/runtime/geniex/host/ffi-bun.js.map +1 -0
- package/dist/runtime/geniex/host/grammar.d.ts +11 -0
- package/dist/runtime/geniex/host/grammar.js +223 -0
- package/dist/runtime/geniex/host/grammar.js.map +1 -0
- package/dist/runtime/geniex/host/inspect.d.ts +25 -0
- package/dist/runtime/geniex/host/inspect.js +177 -0
- package/dist/runtime/geniex/host/inspect.js.map +1 -0
- package/dist/runtime/geniex/host/library.d.ts +117 -0
- package/dist/runtime/geniex/host/library.js +38 -0
- package/dist/runtime/geniex/host/library.js.map +1 -0
- package/dist/runtime/geniex/host/openai.d.ts +62 -0
- package/dist/runtime/geniex/host/openai.js +458 -0
- package/dist/runtime/geniex/host/openai.js.map +1 -0
- package/dist/runtime/geniex/host/run.d.ts +48 -0
- package/dist/runtime/geniex/host/run.js +208 -0
- package/dist/runtime/geniex/host/run.js.map +1 -0
- package/dist/runtime/geniex/host/server.d.ts +39 -0
- package/dist/runtime/geniex/host/server.js +232 -0
- package/dist/runtime/geniex/host/server.js.map +1 -0
- package/dist/runtime/geniex/host/worker-protocol.d.ts +76 -0
- package/dist/runtime/geniex/host/worker-protocol.js +116 -0
- package/dist/runtime/geniex/host/worker-protocol.js.map +1 -0
- package/dist/runtime/geniex/host/worker-source.generated.d.ts +1 -0
- package/dist/runtime/geniex/host/worker-source.generated.js +4 -0
- package/dist/runtime/geniex/host/worker-source.generated.js.map +1 -0
- package/dist/runtime/geniex/host/worker.d.ts +7 -0
- package/dist/runtime/geniex/host/worker.js +19 -0
- package/dist/runtime/geniex/host/worker.js.map +1 -0
- package/dist/runtime/geniex/host-process.d.ts +48 -0
- package/dist/runtime/geniex/host-process.js +104 -0
- package/dist/runtime/geniex/host-process.js.map +1 -0
- package/dist/runtime/geniex/index.d.ts +11 -0
- package/dist/runtime/geniex/index.js +12 -0
- package/dist/runtime/geniex/index.js.map +1 -0
- package/dist/runtime/geniex/model-yml.d.ts +8 -0
- package/dist/runtime/geniex/model-yml.js +98 -0
- package/dist/runtime/geniex/model-yml.js.map +1 -0
- package/dist/runtime/geniex/runtime.d.ts +94 -0
- package/dist/runtime/geniex/runtime.js +366 -0
- package/dist/runtime/geniex/runtime.js.map +1 -0
- package/dist/runtime/litert-lm/host/openai.d.ts +4 -37
- package/dist/runtime/litert-lm/host/openai.js +11 -96
- package/dist/runtime/litert-lm/host/openai.js.map +1 -1
- package/dist/runtime/litert-lm/host/pool.d.ts +1 -7
- package/dist/runtime/litert-lm/host/pool.js +1 -17
- package/dist/runtime/litert-lm/host/pool.js.map +1 -1
- package/dist/runtime/litert-lm/host/server.js +11 -53
- package/dist/runtime/litert-lm/host/server.js.map +1 -1
- package/dist/runtime/llamacpp/args.d.ts +5 -0
- package/dist/runtime/llamacpp/args.js +2 -0
- package/dist/runtime/llamacpp/args.js.map +1 -1
- package/dist/runtime/llamacpp/fit-margin.d.ts +44 -0
- package/dist/runtime/llamacpp/fit-margin.js +50 -0
- package/dist/runtime/llamacpp/fit-margin.js.map +1 -1
- package/dist/runtime/llamacpp/load-plan.d.ts +5 -0
- package/dist/runtime/llamacpp/load-plan.js +57 -22
- package/dist/runtime/llamacpp/load-plan.js.map +1 -1
- package/dist/runtime/llamacpp/runtime.d.ts +5 -1
- package/dist/runtime/llamacpp/runtime.js +6 -1
- package/dist/runtime/llamacpp/runtime.js.map +1 -1
- package/dist/runtime/shared/external-sessions.js +1 -0
- package/dist/runtime/shared/external-sessions.js.map +1 -1
- package/dist/runtime/shared/fifo-lock.d.ts +10 -0
- package/dist/runtime/shared/fifo-lock.js +21 -0
- package/dist/runtime/shared/fifo-lock.js.map +1 -0
- package/dist/runtime/shared/index.d.ts +2 -0
- package/dist/runtime/shared/index.js +2 -0
- package/dist/runtime/shared/index.js.map +1 -1
- package/dist/runtime/shared/openai-sse.d.ts +112 -0
- package/dist/runtime/shared/openai-sse.js +178 -0
- package/dist/runtime/shared/openai-sse.js.map +1 -0
- package/dist/server/clients.d.ts +6 -0
- package/dist/server/clients.js +11 -0
- package/dist/server/clients.js.map +1 -1
- package/dist/server/control/router.js +2 -0
- package/dist/server/control/router.js.map +1 -1
- package/dist/server/control/routes/geniex.d.ts +7 -0
- package/dist/server/control/routes/geniex.js +22 -0
- package/dist/server/control/routes/geniex.js.map +1 -0
- package/dist/server/control/types.d.ts +11 -1
- package/dist/server/control/types.js.map +1 -1
- package/dist/server/http.js +2 -0
- package/dist/server/http.js.map +1 -1
- package/dist/server/public/embedding.d.ts +8 -7
- package/dist/server/public/embedding.js +15 -7
- package/dist/server/public/embedding.js.map +1 -1
- package/dist/server/public/forward.js +23 -6
- package/dist/server/public/forward.js.map +1 -1
- package/dist/server/public/listing.js +1 -0
- package/dist/server/public/listing.js.map +1 -1
- package/dist/server/public/responses.js +9 -0
- package/dist/server/public/responses.js.map +1 -1
- package/dist/server/public/telemetry.d.ts +7 -1
- package/dist/server/public/telemetry.js +11 -3
- package/dist/server/public/telemetry.js.map +1 -1
- package/dist/server/public/trace.d.ts +8 -4
- package/dist/server/public/trace.js +15 -7
- package/dist/server/public/trace.js.map +1 -1
- package/dist/server/public/validate.d.ts +32 -0
- package/dist/server/public/validate.js +146 -0
- package/dist/server/public/validate.js.map +1 -0
- package/dist/settings/schema/geniex.json +63 -0
- package/dist/settings/schema/mlx.json +1 -1
- package/dist/settings/schema.js +11 -0
- package/dist/settings/schema.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +7 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../src/integrations/catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA2BH,yFAAyF;AACzF,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAA;AAE3C,MAAM,CAAC,MAAM,MAAM,GAAqB;IACtC;QACE,EAAE,EAAE,MAAM;QACV,IAAI,EAAE,WAAW;QACjB,SAAS,EAAE,MAAM;QACjB,OAAO,EAAE,EAAE;QACX,aAAa,EAAE,IAAI;QACnB,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,sBAAsB;QAC/B,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,UAAU;KACpB;IACD;QACE,EAAE,EAAE,aAAa;QACjB,IAAI,EAAE,aAAa;QACnB,SAAS,EAAE,QAAQ;QACnB,OAAO,EAAE,CAAC,QAAQ,EAAE,YAAY,CAAC;QACjC,aAAa,EAAE,KAAK;QACpB,qCAAqC;QACrC,kBAAkB,EAAE,KAAK;QACzB,OAAO,EAAE,gDAAgD;QACzD,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,UAAU;KACpB;IACD;QACE,EAAE,EAAE,IAAI;QACR,IAAI,EAAE,IAAI;QACV,SAAS,EAAE,IAAI;QACf,OAAO,EAAE,EAAE;QACX,aAAa,EAAE,IAAI;QACnB,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,sCAAsC;QAC/C,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,UAAU;KACpB;IACD;QACE,EAAE,EAAE,OAAO;QACX,IAAI,EAAE,WAAW;QACjB,SAAS,EAAE,OAAO;QAClB,OAAO,EAAE,EAAE;QACX,aAAa,EAAE,IAAI;QACnB,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,iCAAiC;QAC1C,OAAO,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../src/integrations/catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA2BH,yFAAyF;AACzF,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAA;AAE3C,MAAM,CAAC,MAAM,MAAM,GAAqB;IACtC;QACE,EAAE,EAAE,MAAM;QACV,IAAI,EAAE,WAAW;QACjB,SAAS,EAAE,MAAM;QACjB,OAAO,EAAE,EAAE;QACX,aAAa,EAAE,IAAI;QACnB,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,sBAAsB;QAC/B,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,UAAU;KACpB;IACD;QACE,EAAE,EAAE,aAAa;QACjB,IAAI,EAAE,aAAa;QACnB,SAAS,EAAE,QAAQ;QACnB,OAAO,EAAE,CAAC,QAAQ,EAAE,YAAY,CAAC;QACjC,aAAa,EAAE,KAAK;QACpB,qCAAqC;QACrC,kBAAkB,EAAE,KAAK;QACzB,OAAO,EAAE,gDAAgD;QACzD,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,UAAU;KACpB;IACD;QACE,EAAE,EAAE,IAAI;QACR,IAAI,EAAE,IAAI;QACV,SAAS,EAAE,IAAI;QACf,OAAO,EAAE,EAAE;QACX,aAAa,EAAE,IAAI;QACnB,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,sCAAsC;QAC/C,OAA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O,GAAG,CAAA;IACZ,CAAC;IACD,OAAO,CAAC,kBAAkB,CAAC,CAAA;AAC7B,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,sEAAsE;IACtE,yEAAyE;IACzE,oCAAoC;IACpC,EAAE;IACF,qEAAqE;CACtE,CAAA"}
|
|
@@ -10,6 +10,14 @@
|
|
|
10
10
|
* diverge on any file with more than one key.
|
|
11
11
|
* - `serde_yaml` 0.9 does not indent sequence items under their key.
|
|
12
12
|
* - The managed shell-rc block has an exact shape, including where its blank lines fall.
|
|
13
|
+
*
|
|
14
|
+
* Codex is the exception to "rewrite the user's file": it gets a profile file of its own and only
|
|
15
|
+
* ever *repairs* the shared `config.toml` (`configure/codex-repair.ts`). A repair must never turn an
|
|
16
|
+
* unreadable file into an empty one, so it reads through `readStrict` ("not found" is the only
|
|
17
|
+
* absence), backs up through `createNew` (never over an earlier backup) and writes back with the
|
|
18
|
+
* file's own `permissions` — operations the lenient writers above do not need. Its writes also go
|
|
19
|
+
* through a symbolic link (`linkTarget`) rather than over it: dotfile managers link
|
|
20
|
+
* `~/.codex/config.toml` into their repository, and replacing the link would detach it.
|
|
13
21
|
*/
|
|
14
22
|
export declare const ATOMIC_MANAGED_BEGIN = "# >>> Atomic Chat (managed) >>>";
|
|
15
23
|
export declare const ATOMIC_MANAGED_END = "# <<< Atomic Chat (managed) <<<";
|
|
@@ -20,10 +28,37 @@ export declare const ATOMIC_MANAGED_END = "# <<< Atomic Chat (managed) <<<";
|
|
|
20
28
|
export interface ConfigFs {
|
|
21
29
|
/** Absolute path of the home directory. */
|
|
22
30
|
home: string;
|
|
31
|
+
/** The file's text, or `undefined` when it cannot be read for any reason. */
|
|
23
32
|
read: (relative: string) => Promise<string | undefined>;
|
|
33
|
+
/**
|
|
34
|
+
* `read` for a file whose loss would be worse than a refusal: only "not found" is `undefined`.
|
|
35
|
+
* Any other failure throws, and so does content that is not UTF-8 — decoding it lossily and
|
|
36
|
+
* writing it back would corrupt the user's file. A byte-order mark is kept, so the text encodes
|
|
37
|
+
* back to the exact bytes read.
|
|
38
|
+
*/
|
|
39
|
+
readStrict: (relative: string) => Promise<string | undefined>;
|
|
40
|
+
/**
|
|
41
|
+
* Atomic replace (temp file + rename). A `mode` is applied exactly, whatever the umask or a stale
|
|
42
|
+
* temp file would have left.
|
|
43
|
+
*/
|
|
24
44
|
write: (relative: string, contents: string, options?: {
|
|
25
45
|
mode?: number;
|
|
26
46
|
}) => Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Create a file only if nothing is at that path yet; resolves `false`, touching nothing, when
|
|
49
|
+
* something is. A failure after the file was created removes it again.
|
|
50
|
+
*/
|
|
51
|
+
createNew: (relative: string, contents: string, options?: {
|
|
52
|
+
mode?: number;
|
|
53
|
+
}) => Promise<boolean>;
|
|
54
|
+
/** Permission bits (`mode & 0o777`) of an existing file, `undefined` when there is none. */
|
|
55
|
+
permissions: (relative: string) => Promise<number | undefined>;
|
|
56
|
+
/**
|
|
57
|
+
* Where a write to this path should land so a symbolic link stays a link: the fully resolved real
|
|
58
|
+
* path when the path itself is a link, else the path unchanged (whether or not it exists). A link
|
|
59
|
+
* to nothing rejects with `ENOENT`.
|
|
60
|
+
*/
|
|
61
|
+
linkTarget: (relative: string) => Promise<string>;
|
|
27
62
|
mkdirp: (relative: string) => Promise<void>;
|
|
28
63
|
exists: (relative: string) => Promise<boolean>;
|
|
29
64
|
remove: (relative: string) => Promise<void>;
|
|
@@ -50,9 +85,10 @@ export declare function stripJsonComments(text: string): string;
|
|
|
50
85
|
export declare function canonicalYaml(value: unknown): string;
|
|
51
86
|
export declare function parseYaml(text: string, path: string): unknown;
|
|
52
87
|
/**
|
|
53
|
-
* Remove every `# >>> Atomic Chat (managed) >>> … # <<< Atomic Chat (managed) <<<` region.
|
|
54
|
-
*
|
|
55
|
-
*
|
|
88
|
+
* Remove every `# >>> Atomic Chat (managed) >>> … # <<< Atomic Chat (managed) <<<` region. It strips
|
|
89
|
+
* all of them, and — like the Rust original — it does not consume the newline after the closing
|
|
90
|
+
* marker, which is why blank-line residue is expected. The DeepSeek Harness writer uses it; Codex's
|
|
91
|
+
* legacy regions are removed by `configure/codex-repair.ts`, which only removes what it recognises.
|
|
56
92
|
*/
|
|
57
93
|
export declare function stripAtomicManagedBlock(content: string): string;
|
|
58
94
|
/** Which shell rc file the env-var agents write to, from `$SHELL` and the platform. */
|
|
@@ -78,7 +114,12 @@ export interface EnvEntry {
|
|
|
78
114
|
export declare function renderMarkedEnvBlock(existing: string, marker: string, prefix: string, entries: EnvEntry[]): string;
|
|
79
115
|
/** Write the block into the right rc file for this shell. */
|
|
80
116
|
export declare function writeMarkedEnvToShell(fs: ConfigFs, shell: string | undefined, platform: NodeJS.Platform, marker: string, prefix: string, entries: EnvEntry[]): Promise<void>;
|
|
81
|
-
/**
|
|
117
|
+
/**
|
|
118
|
+
* The inside of a TOML basic string. Everything TOML forbids raw is escaped — `\`, `"`, and every
|
|
119
|
+
* control character (the five with a short form use it, the rest and DEL become `\uXXXX`, upper-case
|
|
120
|
+
* hex) — so any value yields a file Codex can parse. The desktop writer escapes the same way, which is
|
|
121
|
+
* what keeps the two sides' profile files byte-identical.
|
|
122
|
+
*/
|
|
82
123
|
export declare function tomlBasicStringEscape(value: string): string;
|
|
83
124
|
/** The key an agent should use when the user configured none. Not uniform across agents. */
|
|
84
125
|
export declare function keyOr(apiKey: string, fallback: string): string;
|
|
@@ -10,30 +10,90 @@
|
|
|
10
10
|
* diverge on any file with more than one key.
|
|
11
11
|
* - `serde_yaml` 0.9 does not indent sequence items under their key.
|
|
12
12
|
* - The managed shell-rc block has an exact shape, including where its blank lines fall.
|
|
13
|
+
*
|
|
14
|
+
* Codex is the exception to "rewrite the user's file": it gets a profile file of its own and only
|
|
15
|
+
* ever *repairs* the shared `config.toml` (`configure/codex-repair.ts`). A repair must never turn an
|
|
16
|
+
* unreadable file into an empty one, so it reads through `readStrict` ("not found" is the only
|
|
17
|
+
* absence), backs up through `createNew` (never over an earlier backup) and writes back with the
|
|
18
|
+
* file's own `permissions` — operations the lenient writers above do not need. Its writes also go
|
|
19
|
+
* through a symbolic link (`linkTarget`) rather than over it: dotfile managers link
|
|
20
|
+
* `~/.codex/config.toml` into their repository, and replacing the link would detach it.
|
|
13
21
|
*/
|
|
14
|
-
import { mkdir, readFile, rename, rm, stat, writeFile } from 'node:fs/promises';
|
|
22
|
+
import { chmod, lstat, mkdir, readFile, realpath, rename, rm, stat, writeFile } from 'node:fs/promises';
|
|
15
23
|
import { dirname, isAbsolute, join, resolve } from 'node:path';
|
|
16
24
|
import { stringify as yamlStringify, parse as yamlParse } from 'yaml';
|
|
17
25
|
import { AtomicCoreError } from '../contracts/index.js';
|
|
18
26
|
export const ATOMIC_MANAGED_BEGIN = '# >>> Atomic Chat (managed) >>>';
|
|
19
27
|
export const ATOMIC_MANAGED_END = '# <<< Atomic Chat (managed) <<<';
|
|
28
|
+
const isNotFound = (e) => e.code === 'ENOENT';
|
|
20
29
|
export function nodeConfigFs(home) {
|
|
21
30
|
const abs = (relative) => (isAbsolute(relative) ? relative : join(home, ...relative.split('/')));
|
|
22
31
|
return {
|
|
23
32
|
home,
|
|
24
33
|
absolute: abs,
|
|
25
34
|
read: (relative) => readFile(abs(relative), 'utf8').then((t) => t, () => undefined),
|
|
35
|
+
readStrict: async (relative) => {
|
|
36
|
+
let bytes;
|
|
37
|
+
try {
|
|
38
|
+
bytes = await readFile(abs(relative));
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
if (isNotFound(e))
|
|
42
|
+
return undefined;
|
|
43
|
+
throw e;
|
|
44
|
+
}
|
|
45
|
+
return new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }).decode(bytes);
|
|
46
|
+
},
|
|
26
47
|
write: async (relative, contents, options = {}) => {
|
|
27
48
|
const path = abs(relative);
|
|
28
49
|
await mkdir(dirname(path), { recursive: true });
|
|
29
50
|
// Write beside the target and rename over it, so a crash cannot truncate a user's config.
|
|
30
51
|
const tmp = `${path}.atomic-tmp`;
|
|
31
52
|
await writeFile(tmp, contents, options.mode !== undefined ? { mode: options.mode } : {});
|
|
53
|
+
// `writeFile` applies `mode` only to a file it creates, and only through the umask.
|
|
54
|
+
if (options.mode !== undefined)
|
|
55
|
+
await chmod(tmp, options.mode);
|
|
32
56
|
await rename(tmp, path).catch(async (e) => {
|
|
33
57
|
await rm(tmp, { force: true }).catch(() => { });
|
|
34
58
|
throw e;
|
|
35
59
|
});
|
|
36
60
|
},
|
|
61
|
+
createNew: async (relative, contents, options = {}) => {
|
|
62
|
+
const path = abs(relative);
|
|
63
|
+
await mkdir(dirname(path), { recursive: true });
|
|
64
|
+
try {
|
|
65
|
+
await writeFile(path, contents, {
|
|
66
|
+
flag: 'wx',
|
|
67
|
+
...(options.mode !== undefined ? { mode: options.mode } : {}),
|
|
68
|
+
});
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
catch (e) {
|
|
72
|
+
if (e.code === 'EEXIST')
|
|
73
|
+
return false;
|
|
74
|
+
// `wx` failed after creating the file (a full disk): leave no half-written file behind.
|
|
75
|
+
await rm(path, { force: true }).catch(() => { });
|
|
76
|
+
throw e;
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
permissions: (relative) => stat(abs(relative)).then((s) => s.mode & 0o777, (e) => {
|
|
80
|
+
if (isNotFound(e))
|
|
81
|
+
return undefined;
|
|
82
|
+
throw e;
|
|
83
|
+
}),
|
|
84
|
+
linkTarget: async (relative) => {
|
|
85
|
+
const path = abs(relative);
|
|
86
|
+
let link;
|
|
87
|
+
try {
|
|
88
|
+
link = (await lstat(path)).isSymbolicLink();
|
|
89
|
+
}
|
|
90
|
+
catch (e) {
|
|
91
|
+
if (isNotFound(e))
|
|
92
|
+
return path;
|
|
93
|
+
throw e;
|
|
94
|
+
}
|
|
95
|
+
return link ? realpath(path) : path;
|
|
96
|
+
},
|
|
37
97
|
mkdirp: (relative) => mkdir(abs(relative), { recursive: true }).then(() => undefined),
|
|
38
98
|
exists: (relative) => stat(abs(relative)).then(() => true, () => false),
|
|
39
99
|
remove: (relative) => rm(abs(relative), { force: true }),
|
|
@@ -151,9 +211,10 @@ export function parseYaml(text, path) {
|
|
|
151
211
|
}
|
|
152
212
|
// ── managed blocks ──────────────────────────────────────────────────────────────────────────────
|
|
153
213
|
/**
|
|
154
|
-
* Remove every `# >>> Atomic Chat (managed) >>> … # <<< Atomic Chat (managed) <<<` region.
|
|
155
|
-
*
|
|
156
|
-
*
|
|
214
|
+
* Remove every `# >>> Atomic Chat (managed) >>> … # <<< Atomic Chat (managed) <<<` region. It strips
|
|
215
|
+
* all of them, and — like the Rust original — it does not consume the newline after the closing
|
|
216
|
+
* marker, which is why blank-line residue is expected. The DeepSeek Harness writer uses it; Codex's
|
|
217
|
+
* legacy regions are removed by `configure/codex-repair.ts`, which only removes what it recognises.
|
|
157
218
|
*/
|
|
158
219
|
export function stripAtomicManagedBlock(content) {
|
|
159
220
|
let result = content;
|
|
@@ -210,10 +271,34 @@ export async function writeMarkedEnvToShell(fs, shell, platform, marker, prefix,
|
|
|
210
271
|
await fs.write(rc, renderMarkedEnvBlock(existing, marker, prefix, entries));
|
|
211
272
|
}
|
|
212
273
|
// ── small shared helpers ────────────────────────────────────────────────────────────────────────
|
|
213
|
-
/**
|
|
274
|
+
/**
|
|
275
|
+
* The inside of a TOML basic string. Everything TOML forbids raw is escaped — `\`, `"`, and every
|
|
276
|
+
* control character (the five with a short form use it, the rest and DEL become `\uXXXX`, upper-case
|
|
277
|
+
* hex) — so any value yields a file Codex can parse. The desktop writer escapes the same way, which is
|
|
278
|
+
* what keeps the two sides' profile files byte-identical.
|
|
279
|
+
*/
|
|
214
280
|
export function tomlBasicStringEscape(value) {
|
|
215
|
-
|
|
281
|
+
let out = '';
|
|
282
|
+
for (const char of value) {
|
|
283
|
+
const short = TOML_SHORT_ESCAPES[char];
|
|
284
|
+
if (short !== undefined) {
|
|
285
|
+
out += short;
|
|
286
|
+
continue;
|
|
287
|
+
}
|
|
288
|
+
const code = char.codePointAt(0);
|
|
289
|
+
out += code < 0x20 || code === 0x7f ? `\\u${code.toString(16).toUpperCase().padStart(4, '0')}` : char;
|
|
290
|
+
}
|
|
291
|
+
return out;
|
|
216
292
|
}
|
|
293
|
+
const TOML_SHORT_ESCAPES = {
|
|
294
|
+
'\\': '\\\\',
|
|
295
|
+
'"': '\\"',
|
|
296
|
+
'\b': '\\b',
|
|
297
|
+
'\t': '\\t',
|
|
298
|
+
'\n': '\\n',
|
|
299
|
+
'\f': '\\f',
|
|
300
|
+
'\r': '\\r',
|
|
301
|
+
};
|
|
217
302
|
/** The key an agent should use when the user configured none. Not uniform across agents. */
|
|
218
303
|
export function keyOr(apiKey, fallback) {
|
|
219
304
|
return apiKey && apiKey.length > 0 ? apiKey : fallback;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-io.js","sourceRoot":"","sources":["../../src/integrations/config-io.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC/E,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAC9D,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAA;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,MAAM,CAAC,MAAM,oBAAoB,GAAG,iCAAiC,CAAA;AACrE,MAAM,CAAC,MAAM,kBAAkB,GAAG,iCAAiC,CAAA;AAkBnE,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,MAAM,GAAG,GAAG,CAAC,QAAgB,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CA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AC,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAA;IACvG,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,MAAM,kBAAkB,GAAqC;IAC3D,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,KAAK;CACZ,CAAA;AAED,4FAA4F;AAC5F,MAAM,UAAU,KAAK,CAAC,MAAc,EAAE,QAAgB;IACpD,OAAO,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAA;AACxD,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,WAAW,CAAC,IAAY,EAAE,IAAY;IACpD,IAAI,IAAI,KAAK,GAAG;QAAE,OAAO,IAAI,CAAA;IAC7B,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;IACxF,OAAO,IAAI,CAAA;AACb,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Undo what earlier Atomic Chat versions wrote into Codex's shared `config.toml`.
|
|
3
|
+
*
|
|
4
|
+
* Until the profile file (`codex.ts`), the Codex writer edited `<codex_home>/config.toml` itself,
|
|
5
|
+
* inside `# >>> Atomic Chat (managed) >>>` … `# <<< Atomic Chat (managed) <<<` regions. V1 (the first
|
|
6
|
+
* Launch page) appended one region: `[model_providers.atomic]` and `[profiles.atomic]`. V2 kept two:
|
|
7
|
+
* root `model` + `model_provider = "atomic"` at the very top, `[model_providers.atomic]` at the end.
|
|
8
|
+
* V2 is the incident: a user with a root `model` of their own got a duplicate key, and Codex — the CLI
|
|
9
|
+
* and the ChatGPT desktop app, which share the file — refused to start until it was fixed by hand.
|
|
10
|
+
*
|
|
11
|
+
* Deleting text from a file that is not ours is safe only for text we can prove is ours, so this is
|
|
12
|
+
* strict where it could be clever. A marker counts only as a whole line; the regions must pair up;
|
|
13
|
+
* each must parse on its own and hold nothing but keys some version wrote, with the values it wrote;
|
|
14
|
+
* the file without them must still parse; and it must not have changed since it was read. Anything
|
|
15
|
+
* else is a conflict: the file stays byte for byte as it was, and the message names it and says which
|
|
16
|
+
* lines to remove by hand. A repair keeps a backup of the original (never over an earlier one) and
|
|
17
|
+
* writes atomically with the file's own permission bits. A `config.toml` that is a symbolic link (a
|
|
18
|
+
* dotfile manager's) is written through: the temp file and the rename happen beside the real file,
|
|
19
|
+
* which gets the new text while the link stays a link; the backup still goes next to the link.
|
|
20
|
+
*
|
|
21
|
+
* The algorithm is shared with the desktop app, which runs it at startup and on disconnect; both
|
|
22
|
+
* sides must reach the same decision on the same bytes
|
|
23
|
+
* (ADR 2026-10-27-codex-runs-on-a-profile-of-its-own).
|
|
24
|
+
*/
|
|
25
|
+
import type { ConfigFs } from '../config-io.js';
|
|
26
|
+
/** What the removed regions said, for a caller that wants to carry the setup over to the profile. */
|
|
27
|
+
export interface CodexLegacySettings {
|
|
28
|
+
model?: string;
|
|
29
|
+
baseUrl?: string;
|
|
30
|
+
/** The provider named `ATOMIC_CHAT_API_KEY` as its key variable. */
|
|
31
|
+
keyed: boolean;
|
|
32
|
+
}
|
|
33
|
+
export type CodexRepairResult =
|
|
34
|
+
/** No `config.toml`, or nothing of ours in it. Nothing was written. */
|
|
35
|
+
{
|
|
36
|
+
kind: 'clean';
|
|
37
|
+
} | {
|
|
38
|
+
kind: 'repaired';
|
|
39
|
+
backupPath: string;
|
|
40
|
+
legacy: CodexLegacySettings;
|
|
41
|
+
}
|
|
42
|
+
/** Something we cannot prove is ours. Nothing was written; `reason` is the user-facing message. */
|
|
43
|
+
| {
|
|
44
|
+
kind: 'conflict';
|
|
45
|
+
reason: string;
|
|
46
|
+
};
|
|
47
|
+
/** The decision on one file's text, before any I/O: what to write instead, or why not. */
|
|
48
|
+
export type CodexRepairPlan = {
|
|
49
|
+
kind: 'clean';
|
|
50
|
+
} | {
|
|
51
|
+
kind: 'conflict';
|
|
52
|
+
reason: string;
|
|
53
|
+
} | {
|
|
54
|
+
kind: 'repair';
|
|
55
|
+
text: string;
|
|
56
|
+
legacy: CodexLegacySettings;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* The settings in one region when it holds exactly what some Atomic Chat version wrote, else
|
|
60
|
+
* `undefined`. Inline tables and dotted keys mean the same to Codex, so they are accepted too.
|
|
61
|
+
*/
|
|
62
|
+
export declare function recogniseLegacyRegion(doc: Record<string, unknown>): CodexLegacySettings | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Steps 2–6 of the repair on a file's text: find and pair the marker lines, recognise every region,
|
|
65
|
+
* remove them, and check what is left. Pure, so every rule is testable on a string.
|
|
66
|
+
*/
|
|
67
|
+
export declare function planCodexConfigRepair(original: string, path: string): CodexRepairPlan;
|
|
68
|
+
/** The first free backup name: `config.toml.atomic-chat-backup`, then `-2`, `-3`, … */
|
|
69
|
+
export declare function codexBackupPath(path: string, attempt: number): string;
|
|
70
|
+
/**
|
|
71
|
+
* Remove every legacy Atomic Chat region from `<dir>/config.toml`. Returns a conflict rather than
|
|
72
|
+
* throwing for a file it will not touch; throws only when the file could not be read, backed up or
|
|
73
|
+
* written. Either way a file that was not repaired is exactly as it was.
|
|
74
|
+
*/
|
|
75
|
+
export declare function repairLegacyCodexConfig(fs: ConfigFs, dir: string, platform: NodeJS.Platform): Promise<CodexRepairResult>;
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Undo what earlier Atomic Chat versions wrote into Codex's shared `config.toml`.
|
|
3
|
+
*
|
|
4
|
+
* Until the profile file (`codex.ts`), the Codex writer edited `<codex_home>/config.toml` itself,
|
|
5
|
+
* inside `# >>> Atomic Chat (managed) >>>` … `# <<< Atomic Chat (managed) <<<` regions. V1 (the first
|
|
6
|
+
* Launch page) appended one region: `[model_providers.atomic]` and `[profiles.atomic]`. V2 kept two:
|
|
7
|
+
* root `model` + `model_provider = "atomic"` at the very top, `[model_providers.atomic]` at the end.
|
|
8
|
+
* V2 is the incident: a user with a root `model` of their own got a duplicate key, and Codex — the CLI
|
|
9
|
+
* and the ChatGPT desktop app, which share the file — refused to start until it was fixed by hand.
|
|
10
|
+
*
|
|
11
|
+
* Deleting text from a file that is not ours is safe only for text we can prove is ours, so this is
|
|
12
|
+
* strict where it could be clever. A marker counts only as a whole line; the regions must pair up;
|
|
13
|
+
* each must parse on its own and hold nothing but keys some version wrote, with the values it wrote;
|
|
14
|
+
* the file without them must still parse; and it must not have changed since it was read. Anything
|
|
15
|
+
* else is a conflict: the file stays byte for byte as it was, and the message names it and says which
|
|
16
|
+
* lines to remove by hand. A repair keeps a backup of the original (never over an earlier one) and
|
|
17
|
+
* writes atomically with the file's own permission bits. A `config.toml` that is a symbolic link (a
|
|
18
|
+
* dotfile manager's) is written through: the temp file and the rename happen beside the real file,
|
|
19
|
+
* which gets the new text while the link stays a link; the backup still goes next to the link.
|
|
20
|
+
*
|
|
21
|
+
* The algorithm is shared with the desktop app, which runs it at startup and on disconnect; both
|
|
22
|
+
* sides must reach the same decision on the same bytes
|
|
23
|
+
* (ADR 2026-10-27-codex-runs-on-a-profile-of-its-own).
|
|
24
|
+
*/
|
|
25
|
+
import { join } from 'node:path';
|
|
26
|
+
import { parse as parseToml } from 'smol-toml';
|
|
27
|
+
import { AtomicCoreError } from '../../contracts/index.js';
|
|
28
|
+
import { ATOMIC_MANAGED_BEGIN, ATOMIC_MANAGED_END } from '../config-io.js';
|
|
29
|
+
const ROOT_KEYS = new Set(['model', 'model_provider', 'model_providers', 'profiles']);
|
|
30
|
+
const PROVIDER_KEYS = new Set(['name', 'base_url', 'env_key']);
|
|
31
|
+
const PROFILE_KEYS = new Set(['model', 'model_provider']);
|
|
32
|
+
/** A user's own big integers are valid TOML, not a reason to call their file broken. */
|
|
33
|
+
const parseTomlDocument = (text) => parseToml(text, { integersAsBigInt: 'asNeeded' });
|
|
34
|
+
function splitLines(content) {
|
|
35
|
+
const lines = [];
|
|
36
|
+
for (let start = 0; start < content.length;) {
|
|
37
|
+
const newline = content.indexOf('\n', start);
|
|
38
|
+
const end = newline < 0 ? content.length : newline + 1;
|
|
39
|
+
const raw = content.slice(start, end);
|
|
40
|
+
lines.push({ raw, text: raw.replace(/\n$/, '').replace(/\r$/, '') });
|
|
41
|
+
start = end;
|
|
42
|
+
}
|
|
43
|
+
return lines;
|
|
44
|
+
}
|
|
45
|
+
const conflict = (path, problem) => ({
|
|
46
|
+
kind: 'conflict',
|
|
47
|
+
reason: `Atomic Chat cannot remove its old settings from ${path}: ${problem}. ` +
|
|
48
|
+
`Remove the lines between "${ATOMIC_MANAGED_BEGIN}" and "${ATOMIC_MANAGED_END}" by hand, ` +
|
|
49
|
+
'markers included, then connect Codex again.',
|
|
50
|
+
});
|
|
51
|
+
/** The first line of a parser error, which is the message; the rest is a code frame. */
|
|
52
|
+
const parserMessage = (e) => String(e.message).split('\n')[0];
|
|
53
|
+
const isTable = (value) => typeof value === 'object' && value !== null && !Array.isArray(value) && !(value instanceof Date);
|
|
54
|
+
const only = (table, allowed) => Object.keys(table).every((key) => allowed.has(key));
|
|
55
|
+
/** `{ atomic = { … } }` and nothing else beside it. */
|
|
56
|
+
function soleAtomicTable(value) {
|
|
57
|
+
if (!isTable(value) || Object.keys(value).join() !== 'atomic')
|
|
58
|
+
return undefined;
|
|
59
|
+
const atomic = value['atomic'];
|
|
60
|
+
return isTable(atomic) ? atomic : undefined;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The settings in one region when it holds exactly what some Atomic Chat version wrote, else
|
|
64
|
+
* `undefined`. Inline tables and dotted keys mean the same to Codex, so they are accepted too.
|
|
65
|
+
*/
|
|
66
|
+
export function recogniseLegacyRegion(doc) {
|
|
67
|
+
if (Object.keys(doc).length === 0 || !only(doc, ROOT_KEYS))
|
|
68
|
+
return undefined;
|
|
69
|
+
const found = { keyed: false };
|
|
70
|
+
const has = (key) => Object.hasOwn(doc, key);
|
|
71
|
+
if (has('model')) {
|
|
72
|
+
const model = doc['model'];
|
|
73
|
+
if (typeof model !== 'string')
|
|
74
|
+
return undefined;
|
|
75
|
+
found.model = model;
|
|
76
|
+
}
|
|
77
|
+
if (has('model_provider') && doc['model_provider'] !== 'atomic')
|
|
78
|
+
return undefined;
|
|
79
|
+
if (has('model_providers')) {
|
|
80
|
+
const provider = soleAtomicTable(doc['model_providers']);
|
|
81
|
+
if (!provider || !only(provider, PROVIDER_KEYS))
|
|
82
|
+
return undefined;
|
|
83
|
+
const baseUrl = provider['base_url'];
|
|
84
|
+
if (provider['name'] !== 'Atomic Chat' || typeof baseUrl !== 'string')
|
|
85
|
+
return undefined;
|
|
86
|
+
const keyed = Object.hasOwn(provider, 'env_key');
|
|
87
|
+
if (keyed && provider['env_key'] !== 'ATOMIC_CHAT_API_KEY')
|
|
88
|
+
return undefined;
|
|
89
|
+
found.baseUrl = baseUrl;
|
|
90
|
+
found.keyed = keyed;
|
|
91
|
+
}
|
|
92
|
+
if (has('profiles')) {
|
|
93
|
+
const profile = soleAtomicTable(doc['profiles']);
|
|
94
|
+
if (!profile || !only(profile, PROFILE_KEYS))
|
|
95
|
+
return undefined;
|
|
96
|
+
const model = profile['model'];
|
|
97
|
+
if (typeof model !== 'string' || profile['model_provider'] !== 'atomic')
|
|
98
|
+
return undefined;
|
|
99
|
+
found.model ??= model;
|
|
100
|
+
}
|
|
101
|
+
return found;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Steps 2–6 of the repair on a file's text: find and pair the marker lines, recognise every region,
|
|
105
|
+
* remove them, and check what is left. Pure, so every rule is testable on a string.
|
|
106
|
+
*/
|
|
107
|
+
export function planCodexConfigRepair(original, path) {
|
|
108
|
+
const lines = splitLines(original);
|
|
109
|
+
const markers = [];
|
|
110
|
+
for (const [index, { text }] of lines.entries()) {
|
|
111
|
+
if (text === ATOMIC_MANAGED_BEGIN || text === ATOMIC_MANAGED_END) {
|
|
112
|
+
markers.push({ index, begin: text === ATOMIC_MANAGED_BEGIN });
|
|
113
|
+
}
|
|
114
|
+
else if (text.includes(ATOMIC_MANAGED_BEGIN) || text.includes(ATOMIC_MANAGED_END)) {
|
|
115
|
+
return conflict(path, `line ${index + 1} has an Atomic Chat marker inside other text`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (markers.length === 0)
|
|
119
|
+
return { kind: 'clean' };
|
|
120
|
+
const regions = [];
|
|
121
|
+
let open;
|
|
122
|
+
for (const { index, begin } of markers) {
|
|
123
|
+
if (begin && open !== undefined)
|
|
124
|
+
return conflict(path, `line ${index + 1} opens a block inside the one opened on line ${open + 1}`);
|
|
125
|
+
if (!begin && open === undefined)
|
|
126
|
+
return conflict(path, `line ${index + 1} closes a block that was never opened`);
|
|
127
|
+
if (begin)
|
|
128
|
+
open = index;
|
|
129
|
+
else {
|
|
130
|
+
regions.push({ begin: open, end: index });
|
|
131
|
+
open = undefined;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (open !== undefined)
|
|
135
|
+
return conflict(path, `the block opened on line ${open + 1} is never closed`);
|
|
136
|
+
const found = [];
|
|
137
|
+
for (const [n, { begin, end }] of regions.entries()) {
|
|
138
|
+
const where = `block ${n + 1} (lines ${begin + 1}–${end + 1})`;
|
|
139
|
+
let doc;
|
|
140
|
+
try {
|
|
141
|
+
doc = parseTomlDocument(lines
|
|
142
|
+
.slice(begin + 1, end)
|
|
143
|
+
.map((line) => line.raw)
|
|
144
|
+
.join(''));
|
|
145
|
+
}
|
|
146
|
+
catch (e) {
|
|
147
|
+
return conflict(path, `${where} is not valid TOML (${parserMessage(e)})`);
|
|
148
|
+
}
|
|
149
|
+
const settings = recogniseLegacyRegion(doc);
|
|
150
|
+
if (!settings)
|
|
151
|
+
return conflict(path, `${where} has settings Atomic Chat never writes`);
|
|
152
|
+
found.push(settings);
|
|
153
|
+
}
|
|
154
|
+
// V2 split one setup over two regions: the model in the head, the endpoint in the tail.
|
|
155
|
+
const model = found.find((s) => s.model !== undefined)?.model;
|
|
156
|
+
const baseUrl = found.find((s) => s.baseUrl !== undefined)?.baseUrl;
|
|
157
|
+
const legacy = {
|
|
158
|
+
...(model === undefined ? {} : { model }),
|
|
159
|
+
...(baseUrl === undefined ? {} : { baseUrl }),
|
|
160
|
+
keyed: found.some((s) => s.keyed),
|
|
161
|
+
};
|
|
162
|
+
const removed = new Set();
|
|
163
|
+
for (const { begin, end } of regions)
|
|
164
|
+
for (let index = begin; index <= end; index++)
|
|
165
|
+
removed.add(index);
|
|
166
|
+
let kept = [...lines.keys()].filter((index) => !removed.has(index));
|
|
167
|
+
// The V2 head was followed by a blank line (or, after reruns, several); at the top of the file
|
|
168
|
+
// they are ours too. A file that did not start with a region keeps its leading lines as they are.
|
|
169
|
+
if (removed.has(0)) {
|
|
170
|
+
const first = kept.findIndex((index) => lines[index].text.trim() !== '');
|
|
171
|
+
kept = first < 0 ? [] : kept.slice(first);
|
|
172
|
+
}
|
|
173
|
+
const body = kept
|
|
174
|
+
.map((index) => lines[index].raw)
|
|
175
|
+
.join('')
|
|
176
|
+
.trimEnd();
|
|
177
|
+
const text = body === '' ? '' : `${body}\n`;
|
|
178
|
+
try {
|
|
179
|
+
parseTomlDocument(text);
|
|
180
|
+
}
|
|
181
|
+
catch (e) {
|
|
182
|
+
// Report the line as the user sees it in the file now, not in the text we were about to write.
|
|
183
|
+
// `TomlError.line` is 1-based; a message without one (or past the end) names no line.
|
|
184
|
+
const original = kept[e.line - 1];
|
|
185
|
+
const at = original === undefined ? '' : ` (line ${original + 1})`;
|
|
186
|
+
return {
|
|
187
|
+
kind: 'conflict',
|
|
188
|
+
reason: `${path} would still not be valid TOML after removing Atomic Chat's settings: ` +
|
|
189
|
+
`${parserMessage(e)}${at}. Fix the file, or remove the lines between "${ATOMIC_MANAGED_BEGIN}" ` +
|
|
190
|
+
`and "${ATOMIC_MANAGED_END}" by hand, markers included, then connect Codex again.`,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
return { kind: 'repair', text, legacy };
|
|
194
|
+
}
|
|
195
|
+
/** The first free backup name: `config.toml.atomic-chat-backup`, then `-2`, `-3`, … */
|
|
196
|
+
export function codexBackupPath(path, attempt) {
|
|
197
|
+
return attempt === 1 ? `${path}.atomic-chat-backup` : `${path}.atomic-chat-backup-${attempt}`;
|
|
198
|
+
}
|
|
199
|
+
const readFailure = (path, e) => new AtomicCoreError('IO_ERROR', `Failed to read ${path}`, e.message);
|
|
200
|
+
async function readOrFail(fs, path) {
|
|
201
|
+
try {
|
|
202
|
+
return await fs.readStrict(path);
|
|
203
|
+
}
|
|
204
|
+
catch (e) {
|
|
205
|
+
throw readFailure(path, e);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Remove every legacy Atomic Chat region from `<dir>/config.toml`. Returns a conflict rather than
|
|
210
|
+
* throwing for a file it will not touch; throws only when the file could not be read, backed up or
|
|
211
|
+
* written. Either way a file that was not repaired is exactly as it was.
|
|
212
|
+
*/
|
|
213
|
+
export async function repairLegacyCodexConfig(fs, dir, platform) {
|
|
214
|
+
const path = join(dir, 'config.toml');
|
|
215
|
+
const original = await readOrFail(fs, path);
|
|
216
|
+
if (original === undefined)
|
|
217
|
+
return { kind: 'clean' };
|
|
218
|
+
const plan = planCodexConfigRepair(original, path);
|
|
219
|
+
if (plan.kind !== 'repair')
|
|
220
|
+
return plan;
|
|
221
|
+
let target;
|
|
222
|
+
let mode;
|
|
223
|
+
try {
|
|
224
|
+
target = await fs.linkTarget(path);
|
|
225
|
+
mode = platform === 'win32' ? undefined : await fs.permissions(target);
|
|
226
|
+
}
|
|
227
|
+
catch (e) {
|
|
228
|
+
throw readFailure(path, e);
|
|
229
|
+
}
|
|
230
|
+
// Another program (Codex itself, an editor) may have saved the file while we were deciding.
|
|
231
|
+
if ((await readOrFail(fs, path)) !== original) {
|
|
232
|
+
return conflict(path, 'it changed while Atomic Chat was reading it');
|
|
233
|
+
}
|
|
234
|
+
const options = mode === undefined ? {} : { mode };
|
|
235
|
+
let backupPath;
|
|
236
|
+
try {
|
|
237
|
+
for (let attempt = 1; backupPath === undefined; attempt++) {
|
|
238
|
+
const candidate = codexBackupPath(path, attempt);
|
|
239
|
+
if (await fs.createNew(candidate, original, options))
|
|
240
|
+
backupPath = candidate;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
catch (e) {
|
|
244
|
+
throw new AtomicCoreError('IO_ERROR', `Could not back up ${path} before removing Atomic Chat's old settings from it, so it was left as it was.`, e.message);
|
|
245
|
+
}
|
|
246
|
+
try {
|
|
247
|
+
await fs.write(target, plan.text, options);
|
|
248
|
+
}
|
|
249
|
+
catch (e) {
|
|
250
|
+
throw new AtomicCoreError('IO_ERROR', `Failed to write ${target}`, e.message);
|
|
251
|
+
}
|
|
252
|
+
return { kind: 'repaired', backupPath, legacy: plan.legacy };
|
|
253
|
+
}
|
|
254
|
+
//# sourceMappingURL=codex-repair.js.map
|