@ai21/gateway 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/README.md +26 -21
  2. package/dist/agents/claude-code/index.d.ts +7 -0
  3. package/dist/agents/claude-code/index.js +112 -0
  4. package/dist/agents/claude-code/index.js.map +1 -0
  5. package/dist/agents/claude-code/revert.d.ts +11 -0
  6. package/dist/{revert.js → agents/claude-code/revert.js} +2 -1
  7. package/dist/agents/claude-code/revert.js.map +1 -0
  8. package/dist/agents/claude-code/settings.d.ts +33 -0
  9. package/dist/{config.js → agents/claude-code/settings.js} +6 -57
  10. package/dist/agents/claude-code/settings.js.map +1 -0
  11. package/dist/{snippets.d.ts → agents/claude-code/snippets.d.ts} +1 -18
  12. package/dist/{snippets.js → agents/claude-code/snippets.js} +0 -19
  13. package/dist/agents/claude-code/snippets.js.map +1 -0
  14. package/dist/agents/claude-code/status.d.ts +12 -0
  15. package/dist/agents/claude-code/status.js +42 -0
  16. package/dist/agents/claude-code/status.js.map +1 -0
  17. package/dist/agents/claude-code/verify.d.ts +39 -0
  18. package/dist/{verify.js → agents/claude-code/verify.js} +4 -135
  19. package/dist/agents/claude-code/verify.js.map +1 -0
  20. package/dist/agents/codex/config.d.ts +20 -0
  21. package/dist/agents/codex/config.js +344 -0
  22. package/dist/agents/codex/config.js.map +1 -0
  23. package/dist/agents/codex/index.d.ts +2 -0
  24. package/dist/agents/codex/index.js +79 -0
  25. package/dist/agents/codex/index.js.map +1 -0
  26. package/dist/agents/codex/snippets.d.ts +23 -0
  27. package/dist/agents/codex/snippets.js +39 -0
  28. package/dist/agents/codex/snippets.js.map +1 -0
  29. package/dist/agents/codex/status.d.ts +8 -0
  30. package/dist/agents/codex/status.js +36 -0
  31. package/dist/agents/codex/status.js.map +1 -0
  32. package/dist/agents/codex/toml.d.ts +57 -0
  33. package/dist/agents/codex/toml.js +196 -0
  34. package/dist/agents/codex/toml.js.map +1 -0
  35. package/dist/agents/codex/verify.d.ts +2 -0
  36. package/dist/agents/codex/verify.js +43 -0
  37. package/dist/agents/codex/verify.js.map +1 -0
  38. package/dist/agents/deps.d.ts +3 -0
  39. package/dist/agents/deps.js +10 -0
  40. package/dist/agents/deps.js.map +1 -0
  41. package/dist/agents/registry.d.ts +10 -0
  42. package/dist/agents/registry.js +14 -0
  43. package/dist/agents/registry.js.map +1 -0
  44. package/dist/agents/types.d.ts +276 -0
  45. package/dist/agents/types.js +3 -0
  46. package/dist/agents/types.js.map +1 -0
  47. package/dist/args.d.ts +2 -3
  48. package/dist/args.js +7 -9
  49. package/dist/args.js.map +1 -1
  50. package/dist/cli.d.ts +1 -1
  51. package/dist/cli.js +21 -14
  52. package/dist/cli.js.map +1 -1
  53. package/dist/fs/safeFile.d.ts +20 -0
  54. package/dist/fs/safeFile.js +50 -0
  55. package/dist/fs/safeFile.js.map +1 -0
  56. package/dist/{snapshot.d.ts → fs/snapshot.d.ts} +2 -2
  57. package/dist/{snapshot.js → fs/snapshot.js} +2 -2
  58. package/dist/fs/snapshot.js.map +1 -0
  59. package/dist/login/keychain/linux.d.ts +1 -1
  60. package/dist/login/keychain/linux.js +1 -1
  61. package/dist/login/keychain/linux.js.map +1 -1
  62. package/dist/precheck.d.ts +4 -1
  63. package/dist/precheck.js +12 -9
  64. package/dist/precheck.js.map +1 -1
  65. package/dist/process.d.ts +26 -0
  66. package/dist/process.js +94 -0
  67. package/dist/process.js.map +1 -0
  68. package/dist/report.d.ts +17 -25
  69. package/dist/report.js +36 -62
  70. package/dist/report.js.map +1 -1
  71. package/dist/result.d.ts +5 -5
  72. package/dist/result.js +5 -5
  73. package/dist/result.js.map +1 -1
  74. package/dist/router.d.ts +6 -4
  75. package/dist/router.js +132 -120
  76. package/dist/router.js.map +1 -1
  77. package/dist/telemetry/amplitudeHttp.js +1 -0
  78. package/dist/telemetry/amplitudeHttp.js.map +1 -1
  79. package/dist/telemetry/events.d.ts +10 -5
  80. package/dist/telemetry/events.js +0 -6
  81. package/dist/telemetry/events.js.map +1 -1
  82. package/dist/telemetry/telemetry.d.ts +6 -2
  83. package/dist/telemetry/telemetry.js +19 -8
  84. package/dist/telemetry/telemetry.js.map +1 -1
  85. package/package.json +3 -3
  86. package/dist/config.d.ts +0 -83
  87. package/dist/config.js.map +0 -1
  88. package/dist/revert.d.ts +0 -60
  89. package/dist/revert.js.map +0 -1
  90. package/dist/snapshot.js.map +0 -1
  91. package/dist/snippets.js.map +0 -1
  92. package/dist/verify.d.ts +0 -119
  93. package/dist/verify.js.map +0 -1
@@ -0,0 +1,276 @@
1
+ /**
2
+ * The contract every coding agent implements. The router owns the flow that is the same
3
+ * for all of them — resolve the key, check it, gate on a subscription, snapshot, write,
4
+ * verify, undo when there is no subscription, report — and asks the agent for everything
5
+ * that differs: where its config lives, what goes in it, how to take it out again, how
6
+ * to tell whether its user is signed in, and how to prove the result works.
7
+ *
8
+ * Outcomes are agent-neutral (paths and key names are data), so `report.ts` renders any
9
+ * agent's result and reads only the agent's `text` for the words that name it.
10
+ */
11
+ import type { Client, ResolvedUrls, Target } from "../args.js";
12
+ import type { ConfigPaths } from "../fs/safeFile.js";
13
+ import type { PathLookup, RunCommand } from "../process.js";
14
+ /** What every agent's config is rendered from. */
15
+ export interface SnippetInputs {
16
+ readonly gatewayUrl: string;
17
+ readonly agentId: string;
18
+ readonly ai21Key: string;
19
+ /** Signed-in user id for per-user attribution. Absent on a normal CLI run. */
20
+ readonly userId?: string | undefined;
21
+ /**
22
+ * Marks the traffic as configured by this tool, e.g. `ai21-gateway-cli/0.4.0`.
23
+ *
24
+ * Set on what the CLI writes, and deliberately absent from the snippet builders the
25
+ * contract tests pin against the webapp: a config someone pasted by hand did not
26
+ * come from here and must not claim to have. Lets the gateway tell the two apart
27
+ * without the CLI reporting anything itself.
28
+ */
29
+ readonly client?: string | undefined;
30
+ }
31
+ /** Stand-in for the AI21 key in a preview, before one has been supplied. */
32
+ export declare const AI21_KEY_PLACEHOLDER = "<your-ai21-api-key>";
33
+ /** Injected rather than read from the process, so tests can use a temp directory. */
34
+ export interface PathContext {
35
+ readonly cwd: string;
36
+ readonly home: string;
37
+ }
38
+ /** What an agent may read to locate its config — some honour an env override. */
39
+ export interface AgentEnv extends PathContext {
40
+ readonly processEnv: Record<string, string | undefined>;
41
+ }
42
+ export interface AgentPaths extends ConfigPaths {
43
+ /**
44
+ * Where to run the agent's own CLI so that the file we wrote is the one it reads.
45
+ * Home for a user-level config, since a project-local one would outrank it.
46
+ */
47
+ readonly verifyCwd: string;
48
+ }
49
+ export interface Conflict {
50
+ readonly key: string;
51
+ readonly current: string;
52
+ readonly desired: string;
53
+ }
54
+ export type ConfigOutcome = {
55
+ readonly kind: "created";
56
+ readonly path: string;
57
+ } | {
58
+ readonly kind: "updated";
59
+ readonly path: string;
60
+ readonly backup: string;
61
+ readonly changed: readonly string[];
62
+ } | {
63
+ readonly kind: "unchanged";
64
+ readonly path: string;
65
+ } | {
66
+ readonly kind: "conflict";
67
+ readonly path: string;
68
+ readonly conflicts: readonly Conflict[];
69
+ } | {
70
+ readonly kind: "malformed";
71
+ readonly path: string;
72
+ readonly reason: string;
73
+ } | {
74
+ readonly kind: "failed";
75
+ readonly path: string;
76
+ readonly reason: string;
77
+ };
78
+ export type RevertOutcome = {
79
+ readonly kind: "reverted";
80
+ readonly path: string;
81
+ /** Keys we added, so reverting means deleting them. */
82
+ readonly removed: readonly string[];
83
+ /** Keys that held a value before we wrote, now put back. */
84
+ readonly restored: readonly string[];
85
+ /** A `.bak` was there but could not be parsed, so prior values were lost. */
86
+ readonly backupUnreadable: boolean;
87
+ } | {
88
+ readonly kind: "restored";
89
+ readonly path: string;
90
+ readonly backup: string;
91
+ }
92
+ /** None of the managed keys were there — not ours to revert. */
93
+ | {
94
+ readonly kind: "not-configured";
95
+ readonly path: string;
96
+ } | {
97
+ readonly kind: "agent-mismatch";
98
+ readonly path: string;
99
+ readonly expected: string;
100
+ readonly actual: string;
101
+ }
102
+ /** `--from-backup` would discard edits made since our write. */
103
+ | {
104
+ readonly kind: "drifted";
105
+ readonly path: string;
106
+ readonly backup: string;
107
+ } | {
108
+ readonly kind: "no-backup";
109
+ readonly path: string;
110
+ readonly backup: string;
111
+ } | {
112
+ readonly kind: "malformed";
113
+ readonly path: string;
114
+ readonly reason: string;
115
+ } | {
116
+ readonly kind: "failed";
117
+ readonly path: string;
118
+ readonly reason: string;
119
+ };
120
+ export interface RevertOptions {
121
+ /** Restore the `.bak` verbatim instead of removing our keys surgically. */
122
+ readonly fromBackup: boolean;
123
+ /** Proceed with a restore that discards drift. */
124
+ readonly force: boolean;
125
+ /** When set, the stored `x-agent-id` must equal this or nothing is written. */
126
+ readonly agentIdGuard?: string | undefined;
127
+ }
128
+ /** Whether the agent's own login can carry requests through the gateway. */
129
+ export type SubscriptionStatus = {
130
+ readonly kind: "present";
131
+ }
132
+ /** Definitely unusable; `reason` keys into `AgentText.noSubscription`. */
133
+ | {
134
+ readonly kind: "missing";
135
+ readonly reason: string;
136
+ }
137
+ /** Could not tell — never blocks an install. */
138
+ | {
139
+ readonly kind: "inconclusive";
140
+ };
141
+ /** Whether the agent can run on this machine at all, before anything else does. */
142
+ export type InstallStatus = {
143
+ readonly kind: "present";
144
+ } | {
145
+ readonly kind: "missing";
146
+ };
147
+ /** What `checkInstalled` may consult: an upstream key can stand in for a missing binary. */
148
+ export interface InstallContext {
149
+ readonly upstreamKey?: string | undefined;
150
+ readonly processEnv: Record<string, string | undefined>;
151
+ }
152
+ export interface VerifyContext {
153
+ readonly urls: ResolvedUrls;
154
+ readonly agentId: string;
155
+ readonly ai21Key: string;
156
+ readonly userId?: string | undefined;
157
+ /** The agent's own upstream credential for a direct check, when it has a flag for one. */
158
+ readonly upstreamKey?: string | undefined;
159
+ readonly processEnv: Record<string, string | undefined>;
160
+ /** `AgentPaths.verifyCwd`. */
161
+ readonly cwd: string;
162
+ }
163
+ /**
164
+ * How verification ended. Only `no-subscription` changes the exit code. `via` names the
165
+ * tier that ran and `reason` the missing credential; both key into the agent's `text`.
166
+ */
167
+ export type VerifyOutcome = {
168
+ readonly kind: "disabled";
169
+ } | {
170
+ readonly kind: "skipped";
171
+ readonly hint: string;
172
+ } | {
173
+ readonly kind: "passed";
174
+ readonly via: string;
175
+ } | {
176
+ readonly kind: "failed";
177
+ readonly via: string;
178
+ readonly reason: string;
179
+ } | {
180
+ readonly kind: "no-subscription";
181
+ readonly via: string;
182
+ readonly reason: string;
183
+ };
184
+ /** Just enough of `fetch` to send one request. `text` is optional; absent means inconclusive. */
185
+ export type FetchLike = (url: string, init: {
186
+ method: string;
187
+ headers: Record<string, string>;
188
+ body: string;
189
+ signal: AbortSignal;
190
+ }) => Promise<{
191
+ ok: boolean;
192
+ status: number;
193
+ text?: () => Promise<string>;
194
+ }>;
195
+ /** The outside world an agent touches while checking a login or verifying. */
196
+ export interface AgentDeps {
197
+ readonly lookup: PathLookup;
198
+ readonly runCommand: RunCommand;
199
+ readonly fetchImpl: FetchLike;
200
+ }
201
+ export interface Warning {
202
+ /** Stable identifier, so `--json` consumers match on this and not on prose. */
203
+ readonly code: string;
204
+ readonly message: string;
205
+ }
206
+ /**
207
+ * The agent's kind as the gateway's agents API spells it. Also the only place telemetry
208
+ * may name a product: every other telemetry value is agent-neutral.
209
+ */
210
+ export type AgentKind = "claude_code" | "codex";
211
+ /** Flags that feed only a verification tier some agents have. */
212
+ export type VerifyFlag = "anthropic-key";
213
+ /** What the no-subscription refusal says for one `SubscriptionStatus`/`VerifyOutcome` reason. */
214
+ export interface NoSubscriptionText {
215
+ readonly headline: string;
216
+ readonly nextStep: string;
217
+ /** Stable `--json` reason, spelled for a funnel rather than for a person. */
218
+ readonly jsonReason: string;
219
+ /** Fixed telemetry `errorMessage`. Agent-neutral: `agentKind` already says which agent. */
220
+ readonly telemetryReason: string;
221
+ }
222
+ /** What the not-installed refusal says. `jsonOutcome` and `jsonReason` are a contract: never renamed. */
223
+ export interface NotInstalledText {
224
+ readonly message: string;
225
+ readonly jsonOutcome: string;
226
+ readonly jsonReason: string;
227
+ /** Fixed telemetry `errorMessage`. Agent-neutral: `agentKind` already says which agent. */
228
+ readonly telemetryReason: string;
229
+ }
230
+ /** Every user-facing phrase that names the agent or its tooling. */
231
+ export interface AgentText {
232
+ /** The `--json` `outcome` of the no-subscription refusal. A contract: never renamed. */
233
+ readonly noSubscriptionOutcome: string;
234
+ readonly noSubscription: Readonly<Record<string, NoSubscriptionText>>;
235
+ /** How each verification tier reads once it has passed, keyed by `VerifyOutcome.via`. */
236
+ readonly verifiedVia: Readonly<Record<string, string>>;
237
+ /** Why verification was skipped, before the agent's manual hint. */
238
+ readonly skippedBecause: string;
239
+ readonly notInstalled: NotInstalledText;
240
+ /** The status line while `checkSubscription` runs: "Checking your Claude login…". */
241
+ readonly checkingLogin: string;
242
+ /** The done line once `checkSubscription` found a usable login: "Claude login found". */
243
+ readonly loginFound: string;
244
+ }
245
+ export interface CodingAgent {
246
+ readonly id: Client;
247
+ readonly kind: AgentKind;
248
+ /** "Claude Code", as a sentence would name it. */
249
+ readonly displayName: string;
250
+ /** The config file's name, for help and messages: "settings.json". */
251
+ readonly configLabel: string;
252
+ /** Which of `--user` / `--repo` this agent can be configured at. */
253
+ readonly targets: readonly Target[];
254
+ readonly verifyFlags: readonly VerifyFlag[];
255
+ /** Checked first by install, even under --no-verify: `missing` stops it before sign-in or any write. */
256
+ checkInstalled(ctx: InstallContext, deps: AgentDeps): InstallStatus;
257
+ resolvePaths(target: Target, env: AgentEnv): AgentPaths;
258
+ /** What `--print` shows: the file as text, and the fields `--json` adds beside target and urls. */
259
+ preview(inputs: SnippetInputs): {
260
+ readonly text: string;
261
+ readonly json: Readonly<Record<string, unknown>>;
262
+ };
263
+ /** Merge our config in. Never throws; nothing is written on `conflict` or `malformed`. */
264
+ write(paths: AgentPaths, inputs: SnippetInputs, options: {
265
+ readonly force: boolean;
266
+ }): ConfigOutcome;
267
+ revert(paths: AgentPaths, options: RevertOptions): RevertOutcome;
268
+ /** Blanks the AI21 key in a config value, so conflict output never prints it. */
269
+ redact(value: string): string;
270
+ /** Agent-specific things that make a correct config look broken later. */
271
+ warnings(paths: AgentPaths, processEnv: Record<string, string | undefined>): Warning[];
272
+ checkSubscription(paths: AgentPaths, deps: AgentDeps): Promise<SubscriptionStatus>;
273
+ /** Exactly one real request through the gateway, or none. */
274
+ verify(ctx: VerifyContext, deps: AgentDeps): Promise<VerifyOutcome>;
275
+ readonly text: AgentText;
276
+ }
@@ -0,0 +1,3 @@
1
+ /** Stand-in for the AI21 key in a preview, before one has been supplied. */
2
+ export const AI21_KEY_PLACEHOLDER = "<your-ai21-api-key>";
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/agents/types.ts"],"names":[],"mappings":"AAgCA,4EAA4E;AAC5E,MAAM,CAAC,MAAM,oBAAoB,GAAG,qBAAqB,CAAC"}
package/dist/args.d.ts CHANGED
@@ -31,9 +31,8 @@ export declare function resolveUrls(gatewayOverride?: string, appOverride?: stri
31
31
  * No caller since `login` stopped printing a dashboard link; kept for the verb that
32
32
  * reads the stored session. */
33
33
  export declare function dashboardUrl(urls: ResolvedUrls, workspaceId: string): string;
34
- /** Which coding agent's config to write. Only Claude Code is implemented; the flag
35
- * exists so the choice is explicit at the boundary rather than assumed throughout. */
36
- export declare const CLIENTS: readonly ["claude-code"];
34
+ /** Which coding agent's config to write. Each one has an agent in `agents/registry.ts`. */
35
+ export declare const CLIENTS: readonly ["claude-code", "codex"];
37
36
  export type Client = (typeof CLIENTS)[number];
38
37
  export declare const DEFAULT_CLIENT: Client;
39
38
  export declare const VERBS: readonly ["install", "login", "uninstall"];
package/dist/args.js CHANGED
@@ -61,9 +61,8 @@ export function resolveUrls(gatewayOverride, appOverride) {
61
61
  export function dashboardUrl(urls, workspaceId) {
62
62
  return `${urls.app}/w/${encodeURIComponent(workspaceId)}`;
63
63
  }
64
- /** Which coding agent's config to write. Only Claude Code is implemented; the flag
65
- * exists so the choice is explicit at the boundary rather than assumed throughout. */
66
- export const CLIENTS = ["claude-code"];
64
+ /** Which coding agent's config to write. Each one has an agent in `agents/registry.ts`. */
65
+ export const CLIENTS = ["claude-code", "codex"];
67
66
  export const DEFAULT_CLIENT = "claude-code";
68
67
  export const VERBS = ["install", "login", "uninstall"];
69
68
  export const DOCUMENTED_VERBS = ["install", "login", "uninstall"];
@@ -95,12 +94,11 @@ const ALLOWED_FLAGS = {
95
94
  * settings.json this verb never writes. Worth removing together with the verb's next
96
95
  * change, rather than one at a time. */
97
96
  login: ["gateway", "app", "client", "repo", "user", "print", "json", "anthropic-key", "no-verify", "workspace"],
98
- // `uninstall` needs --repo/--user for the same reason `install` does: it has to
99
- // revert whichever settings.json was written, and a --user config would
100
- // otherwise be unrevertable. It takes no --env/--gateway, though — it reads an
101
- // existing file rather than resolving an endpoint. It will need `--client` the
102
- // moment there is a second one, for the same unrevertable reason.
103
- uninstall: ["agent-id", "from-backup", "yes", "json", "repo", "user"],
97
+ // `uninstall` needs --repo/--user and --client for the same reason `install` does: it
98
+ // has to revert whichever file was written, and any other would be unrevertable. It
99
+ // takes no --env/--gateway, though — it reads an existing file rather than resolving
100
+ // an endpoint.
101
+ uninstall: ["agent-id", "client", "from-backup", "yes", "json", "repo", "user"],
104
102
  };
105
103
  const OPTION_SPEC = {
106
104
  help: { type: "boolean", short: "h" },
package/dist/args.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"args.js","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD;;;GAGG;AACH,2EAA2E;AAC3E,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,GAAG,EAAE,sBAAsB;IAC3B,OAAO,EAAE,8BAA8B;IACvC,QAAQ,EAAE,sBAAsB;CACxB,CAAC;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1
  #!/usr/bin/env node
2
2
  import { type RunResult } from "./result.js";
3
3
  export { EXIT, type RunResult } from "./result.js";
4
- export declare const USAGE = "ai21-gateway \u2014 point a local coding agent at the AI21 Intelligent Gateway\n\nUsage:\n ai21-gateway install --agent-id <id> configure this machine (default command)\n ai21-gateway login sign in and create an AI21 key\n ai21-gateway uninstall revert what this tool wrote\n ai21-gateway --help\n ai21-gateway --version\n\nInstall flags:\n --agent-id <id> agent to attribute requests to (required)\n --key <key> AI21 key. Omit it and the CLI uses the key from your signed-in\n session, signing you in through the browser if you are not\n already. A key passed here is kept in your shell history\n --workspace <id> workspace to create the key in; the default is chosen for you\n --user-id <id> adds the x-ai21-user-id attribution header\n --client <name> which agent to configure; 'claude-code' (default) is the only\n one supported so far\n --gateway <url> override the gateway URL outright\n --user | --repo write to the home directory (default) or repo-local\n --yes overwrite an existing conflicting value\n --print render the resolved configuration instead of writing it\n (the key is always masked)\n --json machine-readable output\n\nLogin flags:\n --workspace <id> workspace to create the key in. Without it one is chosen for\n you and named in the output\n --gateway <url> override the gateway URL outright\n --app <url> the webapp origin serving the sign-in page\n\n'login' opens your browser, creates an AI21 key in your workspace and stores it\nunder ~/.config/ai21-gateway. 'install' does this for you when you have no key\nyet, so it is only needed on its own to sign in ahead of time or to move to a\ndifferent workspace.\n\nUninstall flags:\n --agent-id <id> guard: refuse unless the stored agent matches\n --from-backup restore settings.json.bak verbatim instead of removing\n only this tool's keys \u2014 discards later edits\n --yes proceed with a --from-backup restore that discards changes\n --user | --repo which settings.json to revert (home by default)\n\nBy default 'uninstall' removes only the keys this tool wrote, leaving unrelated\nsettings and any later edits of your own intact.\n\nVerification flags:\n --anthropic-key <key> Anthropic credential for the verifying request; used\n only when 'claude' is not on PATH, never written to disk\n --no-verify write the configuration without verifying it\n\nAfter a successful write the CLI sends one request through the gateway to confirm\nthe configuration works: 'claude -p' when it is on PATH, otherwise a direct\nrequest if an Anthropic credential is available. With neither, 'install' stops\nbefore signing in and writes nothing: only the Claude Code CLI is supported.\n\nRe-running the same command is a no-op. An existing settings.json is backed up\nto settings.json.bak before it is changed, and is left untouched if the CLI\nrefuses.";
4
+ export declare const USAGE = "ai21-gateway \u2014 point a local coding agent at the AI21 Intelligent Gateway\n\nUsage:\n ai21-gateway install --agent-id <id> configure this machine (default command)\n ai21-gateway login sign in and create an AI21 key\n ai21-gateway uninstall revert what this tool wrote\n ai21-gateway --help\n ai21-gateway --version\n\nInstall flags:\n --agent-id <id> agent to attribute requests to (required)\n --key <key> AI21 key. Omit it and the CLI uses the key from your signed-in\n session, signing you in through the browser if you are not\n already. A key passed here is kept in your shell history\n --workspace <id> workspace to create the key in; the default is chosen for you\n --user-id <id> adds the x-ai21-user-id attribution header\n --client <name> which agent to configure: 'claude-code' (default), writing\n .claude/settings.json, or 'codex', writing ~/.codex/config.toml\n (or $CODEX_HOME/config.toml). Codex is user-level only\n --gateway <url> override the gateway URL outright\n --user | --repo write to the home directory (default) or repo-local\n --yes overwrite an existing conflicting value\n --print render the resolved configuration instead of writing it\n (the key is always masked)\n --json machine-readable output\n\nLogin flags:\n --workspace <id> workspace to create the key in. Without it one is chosen for\n you and named in the output\n --gateway <url> override the gateway URL outright\n --app <url> the webapp origin serving the sign-in page\n\n'login' opens your browser, creates an AI21 key in your workspace and stores it\nunder ~/.config/ai21-gateway. 'install' does this for you when you have no key\nyet, so it is only needed on its own to sign in ahead of time or to move to a\ndifferent workspace.\n\nUninstall flags:\n --agent-id <id> guard: refuse unless the stored agent matches\n --client <name> whose config to revert: 'claude-code' (default) or 'codex'\n --from-backup restore the .bak verbatim instead of removing only this\n tool's keys \u2014 discards later edits\n --yes proceed with a --from-backup restore that discards changes\n --user | --repo which settings.json to revert (home by default)\n\nBy default 'uninstall' removes only the keys this tool wrote, leaving unrelated\nsettings and any later edits of your own intact.\n\nVerification flags:\n --anthropic-key <key> Claude Code only: Anthropic credential for the verifying\n request, used only when 'claude' is not on PATH, never\n written to disk\n --no-verify write the configuration without verifying it\n\nBefore writing, 'install' checks that the agent's own login can be forwarded:\n'claude auth status' for Claude Code, 'codex login status' (a ChatGPT login)\nfor Codex. After a successful write it sends one request through the gateway\nto confirm the configuration works: 'claude -p', or a direct request with an\nAnthropic credential, for Claude Code; 'codex exec' for Codex. Without the\nagent's CLI (or, for Claude Code, an Anthropic key) 'install' stops before\nsigning in and writes nothing.\n\nRe-running the same command is a no-op. An existing config file is backed up\nbeside it (.bak) before it is changed, and is left untouched if the CLI\nrefuses.";
5
5
  export declare function readVersion(): string;
6
6
  /**
7
7
  * Pure entry point: argv in, streams-and-exit-code out. Keeping I/O at the edge
package/dist/cli.js CHANGED
@@ -7,7 +7,8 @@ import { parseCliArgs } from "./args.js";
7
7
  import { EXIT } from "./result.js";
8
8
  import { dispatch } from "./router.js";
9
9
  import { nodePrecheckDeps } from "./precheck.js";
10
- import { isExecutableFile, nodeVerifyDeps } from "./verify.js";
10
+ import { nodeAgentDeps } from "./agents/deps.js";
11
+ import { isExecutableFile } from "./process.js";
11
12
  import { nodeBrowserDeps, openBrowser } from "./login/browser.js";
12
13
  import { selectSecretStore } from "./login/keychain/select.js";
13
14
  import { runCredentialCommand } from "./login/keychain/runner.js";
@@ -34,8 +35,9 @@ Install flags:
34
35
  already. A key passed here is kept in your shell history
35
36
  --workspace <id> workspace to create the key in; the default is chosen for you
36
37
  --user-id <id> adds the x-ai21-user-id attribution header
37
- --client <name> which agent to configure; 'claude-code' (default) is the only
38
- one supported so far
38
+ --client <name> which agent to configure: 'claude-code' (default), writing
39
+ .claude/settings.json, or 'codex', writing ~/.codex/config.toml
40
+ (or $CODEX_HOME/config.toml). Codex is user-level only
39
41
  --gateway <url> override the gateway URL outright
40
42
  --user | --repo write to the home directory (default) or repo-local
41
43
  --yes overwrite an existing conflicting value
@@ -56,8 +58,9 @@ different workspace.
56
58
 
57
59
  Uninstall flags:
58
60
  --agent-id <id> guard: refuse unless the stored agent matches
59
- --from-backup restore settings.json.bak verbatim instead of removing
60
- only this tool's keys — discards later edits
61
+ --client <name> whose config to revert: 'claude-code' (default) or 'codex'
62
+ --from-backup restore the .bak verbatim instead of removing only this
63
+ tool's keys — discards later edits
61
64
  --yes proceed with a --from-backup restore that discards changes
62
65
  --user | --repo which settings.json to revert (home by default)
63
66
 
@@ -65,17 +68,21 @@ By default 'uninstall' removes only the keys this tool wrote, leaving unrelated
65
68
  settings and any later edits of your own intact.
66
69
 
67
70
  Verification flags:
68
- --anthropic-key <key> Anthropic credential for the verifying request; used
69
- only when 'claude' is not on PATH, never written to disk
71
+ --anthropic-key <key> Claude Code only: Anthropic credential for the verifying
72
+ request, used only when 'claude' is not on PATH, never
73
+ written to disk
70
74
  --no-verify write the configuration without verifying it
71
75
 
72
- After a successful write the CLI sends one request through the gateway to confirm
73
- the configuration works: 'claude -p' when it is on PATH, otherwise a direct
74
- request if an Anthropic credential is available. With neither, 'install' stops
75
- before signing in and writes nothing: only the Claude Code CLI is supported.
76
+ Before writing, 'install' checks that the agent's own login can be forwarded:
77
+ 'claude auth status' for Claude Code, 'codex login status' (a ChatGPT login)
78
+ for Codex. After a successful write it sends one request through the gateway
79
+ to confirm the configuration works: 'claude -p', or a direct request with an
80
+ Anthropic credential, for Claude Code; 'codex exec' for Codex. Without the
81
+ agent's CLI (or, for Claude Code, an Anthropic key) 'install' stops before
82
+ signing in and writes nothing.
76
83
 
77
- Re-running the same command is a no-op. An existing settings.json is backed up
78
- to settings.json.bak before it is changed, and is left untouched if the CLI
84
+ Re-running the same command is a no-op. An existing config file is backed up
85
+ beside it (.bak) before it is changed, and is left untouched if the CLI
79
86
  refuses.`;
80
87
  /** Absolute path to the package root, resolved from this module's location. */
81
88
  function packageRoot() {
@@ -149,7 +156,7 @@ export async function run(argv) {
149
156
  paths: { cwd: process.cwd(), home: homedir() },
150
157
  prompt: { input: process.stdin, output: process.stderr },
151
158
  processEnv: process.env,
152
- verify: nodeVerifyDeps(process.env),
159
+ verify: nodeAgentDeps(process.env),
153
160
  precheck: nodePrecheckDeps(),
154
161
  login: {
155
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M,CAAC,CAAC;IAC5D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,SAAS,MAAM;IACb,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAChC,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IAExC,IAAI,CAAC;QACH,8EAA8E;QAC9E,OAAO,YAAY,CAAC,OAAO,CAAC,KAAK,YAAY,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAChF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,IAAI,MAAM,EAAE,EAAE,CAAC;IACb,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5D,IAAI,GAAG,KAAK,EAAE;QAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAE1C,IAAI,GAAG,KAAK,EAAE;QAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAE1C,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACrB,CAAC"}
@@ -0,0 +1,20 @@
1
+ /** A config file and the backup kept beside it. */
2
+ export interface ConfigPaths {
3
+ /** The agent's config file. Named for Claude Code's settings.json, the first agent. */
4
+ readonly settings: string;
5
+ readonly backup: string;
6
+ }
7
+ /** A symlinked config is backed up beside its target, not beside the link. */
8
+ export declare function backupPathFor(paths: ConfigPaths, realPath: string): string;
9
+ /**
10
+ * Turns an fs error into something safe to print. The code is translated rather
11
+ * than forwarded so no stack frame, errno struct or internal path escapes.
12
+ */
13
+ export declare function describeFsError(err: unknown): string;
14
+ /**
15
+ * Write via a sibling temp file and rename. The rename is atomic within a
16
+ * filesystem, so a reader either sees the old file or the new one — never a
17
+ * half-written config. The temp file is removed on any failure so a crashed run
18
+ * leaves no litter next to the real file.
19
+ */
20
+ export declare function atomicWrite(target: string, contents: string | Buffer): void;
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Writing a file someone else owns: atomically, owner-only, with errors that are safe
3
+ * to print. Shared by every coding agent's config writer, revert and snapshot.
4
+ */
5
+ import { renameSync, rmSync, writeFileSync } from "node:fs";
6
+ /** A symlinked config is backed up beside its target, not beside the link. */
7
+ export function backupPathFor(paths, realPath) {
8
+ return realPath === paths.settings ? paths.backup : `${realPath}.bak`;
9
+ }
10
+ /**
11
+ * Turns an fs error into something safe to print. The code is translated rather
12
+ * than forwarded so no stack frame, errno struct or internal path escapes.
13
+ */
14
+ export function describeFsError(err) {
15
+ const code = err?.code;
16
+ switch (code) {
17
+ case "EACCES":
18
+ case "EPERM":
19
+ return "permission denied";
20
+ case "ENOSPC":
21
+ return "no space left on the device";
22
+ case "EROFS":
23
+ return "the filesystem is read-only";
24
+ case "EISDIR":
25
+ return "it is a directory, not a file";
26
+ default:
27
+ return "the write could not be completed";
28
+ }
29
+ }
30
+ /**
31
+ * Write via a sibling temp file and rename. The rename is atomic within a
32
+ * filesystem, so a reader either sees the old file or the new one — never a
33
+ * half-written config. The temp file is removed on any failure so a crashed run
34
+ * leaves no litter next to the real file.
35
+ */
36
+ export function atomicWrite(target, contents) {
37
+ // Same directory, so the rename cannot cross a filesystem boundary. The pid
38
+ // keeps two concurrent runs from fighting over one temp name.
39
+ const tmp = `${target}.${process.pid}.tmp`;
40
+ try {
41
+ // 0600: this file carries an API key.
42
+ writeFileSync(tmp, contents, { mode: 0o600 });
43
+ renameSync(tmp, target);
44
+ }
45
+ catch (err) {
46
+ rmSync(tmp, { force: true });
47
+ throw err;
48
+ }
49
+ }
50
+ //# sourceMappingURL=safeFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safeFile.js","sourceRoot":"","sources":["../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ConfigPaths } from "./config.js";
1
+ import { type ConfigPaths } from "./safeFile.js";
2
2
  /** One file as it was: its bytes and mode, or the fact that it did not exist. */
3
3
  type FileState = {
4
4
  readonly path: string;
@@ -11,7 +11,7 @@ type FileState = {
11
11
  };
12
12
  export interface ConfigSnapshot {
13
13
  readonly settings: FileState;
14
- /** Absent when settings.json did not exist, since the writer backs up nothing then. */
14
+ /** Absent when the config did not exist, since the writer backs up nothing then. */
15
15
  readonly backup?: FileState | undefined;
16
16
  }
17
17
  export type RestoreOutcome = {
@@ -1,12 +1,12 @@
1
1
  /**
2
- * The pre-run state of settings.json and its backup, held in memory so a write that
2
+ * The pre-run state of a config file and its backup, held in memory so a write that
3
3
  * turns out to be useless can be undone exactly. Deliberately not `uninstall`: that
4
4
  * removes our keys, which on a re-run over an older AI21 config would delete a setup
5
5
  * that was working before this run started.
6
6
  */
7
7
  import { chmodSync, existsSync, lstatSync, readFileSync, readlinkSync, realpathSync, rmSync, statSync } from "node:fs";
8
8
  import { dirname, resolve } from "node:path";
9
- import { atomicWrite, backupPathFor, describeFsError } from "./config.js";
9
+ import { atomicWrite, backupPathFor, describeFsError } from "./safeFile.js";
10
10
  function capture(path) {
11
11
  if (!existsSync(path))
12
12
  return { path, present: false };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../src/fs/snapshot.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACvH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAoB,WAAW,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAe9F,SAAS,OAAO,CAAC,IAAY;IAC3B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAA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QAAQ,CAAC,CAAC;IACxC,wEAAwE;IACxE,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;AACpC,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,aAAa,CAAC,QAAwB;IACpD,IAAI,CAAC;QACH,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACvB,IAAI,QAAQ,CAAC,MAAM,KAAK,SAAS;YAAE,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC1D,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC;IAC1D,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;AAC9B,CAAC"}
@@ -9,7 +9,7 @@
9
9
  * The secret goes in on stdin and comes out on stdout unchanged, so unlike macOS it needs
10
10
  * no encoding.
11
11
  */
12
- import { type PathLookup } from "../../verify.js";
12
+ import { type PathLookup } from "../../process.js";
13
13
  import type { SecretStore } from "../secretStore.js";
14
14
  import { type CommandRunner } from "./runner.js";
15
15
  export declare const SECRET_TOOL = "secret-tool";