@ai21/gateway 0.6.0 → 1.0.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 (58) hide show
  1. package/README.md +42 -12
  2. package/dist/args.d.ts +4 -2
  3. package/dist/args.js +15 -6
  4. package/dist/args.js.map +1 -1
  5. package/dist/cli.d.ts +1 -1
  6. package/dist/cli.js +45 -5
  7. package/dist/cli.js.map +1 -1
  8. package/dist/login/apiKeys.d.ts +20 -0
  9. package/dist/login/apiKeys.js +75 -0
  10. package/dist/login/apiKeys.js.map +1 -0
  11. package/dist/login/credentials.d.ts +21 -8
  12. package/dist/login/credentials.js +149 -41
  13. package/dist/login/credentials.js.map +1 -1
  14. package/dist/login/fileAcl.d.ts +29 -0
  15. package/dist/login/fileAcl.js +129 -0
  16. package/dist/login/fileAcl.js.map +1 -0
  17. package/dist/login/keychain/linux.d.ts +28 -0
  18. package/dist/login/keychain/linux.js +57 -0
  19. package/dist/login/keychain/linux.js.map +1 -0
  20. package/dist/login/keychain/macos.d.ts +30 -0
  21. package/dist/login/keychain/macos.js +52 -0
  22. package/dist/login/keychain/macos.js.map +1 -0
  23. package/dist/login/keychain/runner.d.ts +30 -0
  24. package/dist/login/keychain/runner.js +88 -0
  25. package/dist/login/keychain/runner.js.map +1 -0
  26. package/dist/login/keychain/select.d.ts +14 -0
  27. package/dist/login/keychain/select.js +74 -0
  28. package/dist/login/keychain/select.js.map +1 -0
  29. package/dist/login/lock.d.ts +16 -0
  30. package/dist/login/lock.js +139 -0
  31. package/dist/login/lock.js.map +1 -0
  32. package/dist/login/secretStore.d.ts +21 -0
  33. package/dist/login/secretStore.js +12 -0
  34. package/dist/login/secretStore.js.map +1 -0
  35. package/dist/login/session.d.ts +3 -0
  36. package/dist/login/session.js.map +1 -1
  37. package/dist/login/workspaces.d.ts +18 -1
  38. package/dist/login/workspaces.js +46 -2
  39. package/dist/login/workspaces.js.map +1 -1
  40. package/dist/precheck.d.ts +46 -0
  41. package/dist/precheck.js +86 -0
  42. package/dist/precheck.js.map +1 -0
  43. package/dist/prompt.d.ts +4 -19
  44. package/dist/prompt.js +1 -71
  45. package/dist/prompt.js.map +1 -1
  46. package/dist/report.d.ts +18 -9
  47. package/dist/report.js +86 -13
  48. package/dist/report.js.map +1 -1
  49. package/dist/result.d.ts +2 -0
  50. package/dist/result.js +2 -0
  51. package/dist/result.js.map +1 -1
  52. package/dist/router.d.ts +2 -0
  53. package/dist/router.js +240 -69
  54. package/dist/router.js.map +1 -1
  55. package/dist/verify.d.ts +1 -0
  56. package/dist/verify.js +1 -1
  57. package/dist/verify.js.map +1 -1
  58. package/package.json +1 -1
package/README.md CHANGED
@@ -11,25 +11,55 @@ npx @ai21/gateway install --agent-id <AGENT_ID>
11
11
 
12
12
  Merges `~/.claude/settings.json` so Claude Code routes through the gateway from
13
13
  every project on the machine (pass `--repo` to configure only the current one), then
14
- sends one request to prove it works. The AI21 key is prompted for without echo —
15
- pass `--key` only for scripting, since a key in argv stays in your shell history.
14
+ sends one request to prove it works. With no key stored it signs you in through the
15
+ browser first and creates an AI21 key for you, all in the one command — pass `--key`
16
+ only for scripting, since a key in argv stays in your shell history.
17
+
18
+ The key is checked against the gateway *before* anything is written, so a key the
19
+ gateway will not take — or an agent id the key does not carry — stops the command
20
+ instead of leaving a config that fails every later request. There is no flag to skip
21
+ that check, and it needs none: only a definite rejection stops the install. If the
22
+ gateway cannot be reached, or answers something we cannot read, the config is written
23
+ and a warning says the key went unchecked.
24
+
25
+ `--no-verify` turns off the *post-write* check — the one that proves end to end that
26
+ Claude Code reaches the gateway. It does not affect the pre-write key check.
16
27
 
17
28
  The dashboard prints this command for you (Add agent, or Reconnect on an existing
18
29
  agent) and offers the key as a separate copy.
19
30
 
20
- | Command | Does |
21
- | ----------- | ------------------------------------------------ |
22
- | `install` | write the config and verify it (default command) |
23
- | `uninstall` | revert what this tool wrote |
31
+ | Command | Does |
32
+ | ----------- | -------------------------------------------------- |
33
+ | `install` | write the config and verify it (default command) |
34
+ | `login` | sign in through the browser and create an AI21 key |
35
+ | `uninstall` | revert what this tool wrote |
24
36
 
25
37
  `configure` is accepted as an alias for `install`: it was the verb's name through
26
38
  0.3.x, so commands copied from an older dashboard keep working.
27
39
 
28
- There is a third verb, `login`, which signs in through the browser and stores the
29
- session. It parses and runs but is **left out of `--help`**, because nothing spends
30
- that session yet: after signing in you still configure a repo with
31
- `install --agent-id … --key …`, so advertising it would promise a shortcut that is
32
- not there. Agent creation from a stored session is what makes it worth showing.
40
+ `login` opens the browser, creates an AI21 key in your workspace and stores it with
41
+ your session, keyed by gateway URL so a staging session cannot be handed to production.
42
+ `install` does all this for you when you have no key yet, so `login` is only needed on
43
+ its own to sign in ahead of time, or to move to a different workspace with
44
+ `--workspace <id>`.
45
+
46
+ The two secrets, the session's refresh token and the AI21 key, go in the macOS
47
+ keychain or the Linux Secret Service when one is reachable. Otherwise, and always on
48
+ Windows, they go in `~/.config/ai21-gateway/credentials.json`, readable only by you:
49
+ mode `0600` on macOS and Linux, an owner-only ACL on Windows. That file always holds
50
+ the rest of the session. A session written by an older version moves into the keychain
51
+ on the next sign-in. Either way, `install` writes the key in plaintext into the agent's
52
+ own config, because that is where the agent reads it.
53
+
54
+ The workspace is chosen without a prompt: the legacy per-user `personal` workspace is
55
+ dropped, then public workspaces are preferred over private and ties broken by id, so
56
+ the same machine picks the same workspace every run. The chosen one is named in the
57
+ output. Signing in again reuses the key already stored for that gateway and workspace
58
+ rather than minting another.
59
+
60
+ Keys created this way are named `ai21-gateway-cli (<hostname>)` so they can be told
61
+ apart in the dashboard's key list. They **do not expire**, and a fresh clone or a new
62
+ home directory mints an additional one — revoking them is a dashboard job for now.
33
63
 
34
64
  The loopback callback itself does work from a deployed dashboard. Chrome gates a
35
65
  public page's `fetch` to `127.0.0.1` behind Local Network Access and Safari refuses
@@ -79,7 +109,7 @@ last tag. `package.json` stays at `0.0.0`; the git tag is the record.
79
109
  `403` misleads: it reads as though the AI21 gateway rejected you, but it is npm
80
110
  failing to reach the registry — before the CLI has run at all.
81
111
 
82
- The last one catches people out: this project _is_ `@ai21/gateway`, so npx
112
+ The last one catches people out: this project *is* `@ai21/gateway`, so npx
83
113
  resolves the name to the working directory instead of the registry, finds no
84
114
  linked binary, and fails. The published artifact can never be exercised from its
85
115
  own source tree — use a scratch directory.
package/dist/args.d.ts CHANGED
@@ -52,6 +52,7 @@ export interface ParsedArgs {
52
52
  readonly agentIdGuard?: string | undefined;
53
53
  /** Anthropic credential for the direct verifying ping. Never written to disk. */
54
54
  readonly anthropicKey?: string | undefined;
55
+ readonly workspaceId?: string | undefined;
55
56
  readonly noVerify: boolean;
56
57
  readonly print: boolean;
57
58
  readonly json: boolean;
@@ -70,8 +71,9 @@ export type ParseOutcome = {
70
71
  readonly message: string;
71
72
  };
72
73
  /**
73
- * Shared with the interactive prompt, which is a second way these values enter
74
- * the program and must not be a second way the rule is skipped.
74
+ * Every AI21 key ends up as a line in the newline-separated ANTHROPIC_CUSTOM_HEADERS,
75
+ * so a control character in one forges an extra header on every agent request. The
76
+ * header flags apply the same rule at parse time; this covers keys minted or stored.
75
77
  */
76
78
  export declare function containsControlCharacters(value: string): boolean;
77
79
  /**
package/dist/args.js CHANGED
@@ -6,6 +6,7 @@
6
6
  * spawning anything.
7
7
  */
8
8
  import { parseArgs } from "node:util";
9
+ import { isWorkspaceId } from "./login/contract.js";
9
10
  /**
10
11
  * Baked-in endpoints. Shipping these means the happy path needs no URL, and the
11
12
  * snippets we tell people to copy carry no hostname that can go stale.
@@ -65,9 +66,7 @@ export function dashboardUrl(urls, workspaceId) {
65
66
  export const CLIENTS = ["claude-code"];
66
67
  export const DEFAULT_CLIENT = "claude-code";
67
68
  export const VERBS = ["install", "login", "uninstall"];
68
- /* `login` is accepted but not advertised: nothing spends the session it stores yet, so
69
- * the reader would still have to `install --agent-id … --key …` afterwards. */
70
- export const DOCUMENTED_VERBS = ["install", "uninstall"];
69
+ export const DOCUMENTED_VERBS = ["install", "login", "uninstall"];
71
70
  /** `configure` was this verb's name through 0.3.x, and the dashboard printed it. Still
72
71
  * accepted so a copied command keeps working; deliberately absent from help. (`setup`
73
72
  * was never released, so it needs no alias.) */
@@ -88,13 +87,14 @@ const ALLOWED_FLAGS = {
88
87
  "yes",
89
88
  "anthropic-key",
90
89
  "no-verify",
90
+ "workspace",
91
91
  ],
92
92
  /* `--app` names the webapp when the gateway host does not (see appOriginFor).
93
93
  * `--print`, `--client`, `--repo`, `--user`, `--anthropic-key` and `--no-verify` are all
94
94
  * dead here since login stopped writing and verifying — `--print` still renders a
95
95
  * settings.json this verb never writes. Worth removing together with the verb's next
96
96
  * change, rather than one at a time. */
97
- login: ["gateway", "app", "client", "repo", "user", "print", "json", "anthropic-key", "no-verify"],
97
+ login: ["gateway", "app", "client", "repo", "user", "print", "json", "anthropic-key", "no-verify", "workspace"],
98
98
  // `uninstall` needs --repo/--user for the same reason `install` does: it has to
99
99
  // revert whichever settings.json was written, and a --user config would
100
100
  // otherwise be unrevertable. It takes no --env/--gateway, though — it reads an
@@ -119,6 +119,7 @@ const OPTION_SPEC = {
119
119
  "anthropic-key": { type: "string" },
120
120
  app: { type: "string" },
121
121
  "no-verify": { type: "boolean" },
122
+ workspace: { type: "string" },
122
123
  };
123
124
  function fail(message) {
124
125
  return { kind: "error", message };
@@ -151,8 +152,9 @@ const VERIFY_FLAGS = ["anthropic-key", "no-verify"];
151
152
  // eslint-disable-next-line no-control-regex
152
153
  const CONTROL_CHARS = /[\u0000-\u001F\u007F]/;
153
154
  /**
154
- * Shared with the interactive prompt, which is a second way these values enter
155
- * the program and must not be a second way the rule is skipped.
155
+ * Every AI21 key ends up as a line in the newline-separated ANTHROPIC_CUSTOM_HEADERS,
156
+ * so a control character in one forges an extra header on every agent request. The
157
+ * header flags apply the same rule at parse time; this covers keys minted or stored.
156
158
  */
157
159
  export function containsControlCharacters(value) {
158
160
  return CONTROL_CHARS.test(value);
@@ -282,6 +284,12 @@ export function parseCliArgs(argv) {
282
284
  if (problem !== undefined)
283
285
  return fail(problem);
284
286
  }
287
+ const workspaceId = typeof values.workspace === "string" ? values.workspace : undefined;
288
+ /* Same shape the callback's workspace id is held to: it lands in a query parameter and
289
+ * must not be able to carry anything else there. */
290
+ if (workspaceId !== undefined && !isWorkspaceId(workspaceId)) {
291
+ return fail(`--workspace must be a workspace id, got '${workspaceId}'.`);
292
+ }
285
293
  if (values.repo === true && values.user === true) {
286
294
  return fail("--repo and --user are mutually exclusive; pass at most one.");
287
295
  }
@@ -322,6 +330,7 @@ export function parseCliArgs(argv) {
322
330
  userId: typeof values["user-id"] === "string" ? values["user-id"] : undefined,
323
331
  agentIdGuard: verb === "uninstall" && typeof values["agent-id"] === "string" ? values["agent-id"] : undefined,
324
332
  anthropicKey: typeof values["anthropic-key"] === "string" ? values["anthropic-key"] : undefined,
333
+ workspaceId,
325
334
  noVerify: values["no-verify"] === true,
326
335
  print: values.print === true,
327
336
  json: values.json === true,
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;;;GAGG;AACH,2EAA2E;AAC3E,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,GAAG,EAAE,sBAAsB;IAC3B,OAAO,EAAE,8BAA8B;IACvC,QAAQ,EAAE,sBAAsB;CACxB,CAAC;AASX;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,UAAkB;IAC7C,IAAI,MAAW,CAAC;IAChB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,SAAS,CAAC;IAE1D,4DAA4D;IAC5D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C,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS;YAC7G,YAAY,EAAE,OAAO,MAAM,CAAC,eAAe,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,SAAS;YAC/F,WAAW;YACX,QAAQ,EAAE,MAAM,CAAC,WAAW,CAAC,KAAK,IAAI;YACtC,KAAK,EAAE,MAAM,CAAC,KAAK,KAAK,IAAI;YAC5B,IAAI,EAAE,MAAM,CAAC,IAAI,KAAK,IAAI;YAC1B,GAAG,EAAE,MAAM,CAAC,GAAG,KAAK,IAAI;YACxB,UAAU,EAAE,MAAM,CAAC,aAAa,CAAC,KAAK,IAAI;SAC3C;KACF,CAAC;AACJ,CAAC"}
package/dist/cli.d.ts CHANGED
@@ -1,7 +1,7 @@
1
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 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; prompted for without echo when omitted. Prefer the\n prompt: a key passed here is kept in your shell history\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\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, verification is\nskipped with a warning \u2014 it never changes the exit code.\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) 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, verification is\nskipped with a warning \u2014 it never changes the exit code.\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.";
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
@@ -6,22 +6,28 @@ import { fileURLToPath } from "node:url";
6
6
  import { parseCliArgs } from "./args.js";
7
7
  import { EXIT } from "./result.js";
8
8
  import { dispatch } from "./router.js";
9
- import { nodeVerifyDeps } from "./verify.js";
9
+ import { nodePrecheckDeps } from "./precheck.js";
10
+ import { isExecutableFile, nodeVerifyDeps } from "./verify.js";
10
11
  import { nodeBrowserDeps, openBrowser } from "./login/browser.js";
12
+ import { selectSecretStore } from "./login/keychain/select.js";
13
+ import { runCredentialCommand } from "./login/keychain/runner.js";
11
14
  import { startLoopback } from "./login/loopback.js";
12
15
  export { EXIT } from "./result.js";
13
16
  export const USAGE = `ai21-gateway — point a local coding agent at the AI21 Intelligent Gateway
14
17
 
15
18
  Usage:
16
19
  ai21-gateway install --agent-id <id> configure this machine (default command)
20
+ ai21-gateway login sign in and create an AI21 key
17
21
  ai21-gateway uninstall revert what this tool wrote
18
22
  ai21-gateway --help
19
23
  ai21-gateway --version
20
24
 
21
25
  Install flags:
22
26
  --agent-id <id> agent to attribute requests to (required)
23
- --key <key> AI21 key; prompted for without echo when omitted. Prefer the
24
- prompt: a key passed here is kept in your shell history
27
+ --key <key> AI21 key. Omit it and the CLI uses the key from your signed-in
28
+ session, signing you in through the browser if you are not
29
+ already. A key passed here is kept in your shell history
30
+ --workspace <id> workspace to create the key in; the default is chosen for you
25
31
  --user-id <id> adds the x-ai21-user-id attribution header
26
32
  --client <name> which agent to configure; 'claude-code' (default) is the only
27
33
  one supported so far
@@ -32,6 +38,17 @@ Install flags:
32
38
  (the key is always masked)
33
39
  --json machine-readable output
34
40
 
41
+ Login flags:
42
+ --workspace <id> workspace to create the key in. Without it one is chosen for
43
+ you and named in the output
44
+ --gateway <url> override the gateway URL outright
45
+ --app <url> the webapp origin serving the sign-in page
46
+
47
+ 'login' opens your browser, creates an AI21 key in your workspace and stores it
48
+ under ~/.config/ai21-gateway. 'install' does this for you when you have no key
49
+ yet, so it is only needed on its own to sign in ahead of time or to move to a
50
+ different workspace.
51
+
35
52
  Uninstall flags:
36
53
  --agent-id <id> guard: refuse unless the stored agent matches
37
54
  --from-backup restore settings.json.bak verbatim instead of removing
@@ -98,7 +115,9 @@ export async function run(argv) {
98
115
  return versionResult();
99
116
  case "error":
100
117
  return { code: EXIT.USAGE, out: "", err: `${outcome.message}\n\n${USAGE}\n` };
101
- case "args":
118
+ case "args": {
119
+ // One stream for login's progress and credential-file warnings, so neither is missed.
120
+ const notify = (message) => void process.stderr.write(`${message}\n`);
102
121
  // Everything the CLI needs from the outside world is gathered here, at the
103
122
  // edge, so every layer below stays pure and testable against a temp
104
123
  // directory and a pair of fake streams.
@@ -107,15 +126,36 @@ export async function run(argv) {
107
126
  prompt: { input: process.stdin, output: process.stderr },
108
127
  processEnv: process.env,
109
128
  verify: nodeVerifyDeps(process.env),
129
+ precheck: nodePrecheckDeps(),
110
130
  login: {
111
131
  startListener: startLoopback,
112
132
  openBrowser: (url) => openBrowser(url, nodeBrowserDeps()),
113
133
  fetchImpl: fetch,
134
+ secrets: selectSecretStore({
135
+ paths: { home: homedir(), warn: notify },
136
+ run: runCredentialCommand,
137
+ platform: process.platform,
138
+ lookup: { platform: process.platform, processEnv: process.env, isExecutableFile },
139
+ osRelease: readOsRelease,
140
+ }),
114
141
  },
115
142
  // stderr, so `--json` on stdout stays a single parseable object even while
116
143
  // login narrates its progress.
117
- notify: (message) => process.stderr.write(`${message}\n`),
144
+ notify,
118
145
  });
146
+ }
147
+ }
148
+ }
149
+ /**
150
+ * WSL identifies itself here, and the Linux keychain tier skips it. Absent on macOS and
151
+ * Windows, where the tier never asks.
152
+ */
153
+ function readOsRelease() {
154
+ try {
155
+ return readFileSync("/proc/sys/kernel/osrelease", "utf8");
156
+ }
157
+ catch {
158
+ return undefined;
119
159
  }
120
160
  }
121
161
  function isMain() {
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,IAAI,EAAkB,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,IAAI,EAAkB,MAAM,aAAa,CAAC;AAEnD,MAAM,CAAC,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SA4CZ,CAAC;AAEV,+EAA+E;AAC/E,SAAS,WAAW;IAClB,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;AAC7D,CAAC;A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,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
+ import type { FetchLike } from "./tokens.js";
2
+ export type MintOutcome = {
3
+ readonly kind: "key";
4
+ readonly value: string;
5
+ }
6
+ /** The message is shown to the user, so it names the cause and never the credential. */
7
+ | {
8
+ readonly kind: "failed";
9
+ readonly reason: string;
10
+ };
11
+ /**
12
+ * Names the machine in the dashboard's key list, so someone with several can tell which
13
+ * laptop a key belongs to and revoke the right one.
14
+ */
15
+ export declare function keyName(machine?: string): string;
16
+ /**
17
+ * Mints one key in `workspaceId`. Never throws: a failure here is reported to the user
18
+ * with the session already stored, so signing in again is not the remedy.
19
+ */
20
+ export declare function mintApiKey(gatewayUrl: string, idToken: string, workspaceId: string, name?: string, fetchImpl?: FetchLike): Promise<MintOutcome>;
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Minting the AI21 key `install` writes, so nobody has to fetch one from the dashboard
3
+ * by hand.
4
+ *
5
+ * Identity's `POST /identity/api-keys` takes `workspace_id` and `key_name` as query
6
+ * parameters — not a body — and authenticates with the same `firebase-token` header the
7
+ * workspace listing uses (language-studio-identity: api_keys/api_keys_router.py,
8
+ * auth/middleware.py). It answers with the key value in full; `GET` masks it, which is
9
+ * why a minted key is kept locally rather than re-read later.
10
+ */
11
+ import { hostname } from "node:os";
12
+ import { containsControlCharacters } from "../args.js";
13
+ import { identityBase } from "./workspaces.js";
14
+ const API_KEYS_PATH = "/identity/api-keys";
15
+ const TIMEOUT_MS = 20_000;
16
+ /** Identity's own default is "API Key", which says nothing in a list of them. */
17
+ const KEY_NAME_PREFIX = "ai21-gateway-cli";
18
+ const MAX_HOST_LENGTH = 48;
19
+ /**
20
+ * Names the machine in the dashboard's key list, so someone with several can tell which
21
+ * laptop a key belongs to and revoke the right one.
22
+ */
23
+ export function keyName(machine = hostname()) {
24
+ // eslint-disable-next-line no-control-regex
25
+ const cleaned = machine.replace(/[\u0000-\u001F\u007F]/g, "").trim();
26
+ return cleaned === "" ? KEY_NAME_PREFIX : `${KEY_NAME_PREFIX} (${cleaned.slice(0, MAX_HOST_LENGTH)})`;
27
+ }
28
+ /**
29
+ * Mints one key in `workspaceId`. Never throws: a failure here is reported to the user
30
+ * with the session already stored, so signing in again is not the remedy.
31
+ */
32
+ export async function mintApiKey(gatewayUrl, idToken, workspaceId, name = keyName(), fetchImpl = fetch) {
33
+ const base = identityBase(gatewayUrl);
34
+ if (base === undefined)
35
+ return { kind: "failed", reason: `'${gatewayUrl}' is not a URL a key can be minted from` };
36
+ const url = `${base}${API_KEYS_PATH}?workspace_id=${encodeURIComponent(workspaceId)}&key_name=${encodeURIComponent(name)}`;
37
+ let response;
38
+ try {
39
+ response = await fetchImpl(url, {
40
+ method: "POST",
41
+ headers: { "firebase-token": idToken },
42
+ signal: AbortSignal.timeout(TIMEOUT_MS),
43
+ });
44
+ }
45
+ catch (err) {
46
+ return { kind: "failed", reason: `could not reach identity: ${err instanceof Error ? err.message : String(err)}` };
47
+ }
48
+ if (!response.ok) {
49
+ /* 403 is the one worth naming: identity returns it both for an unverified email and
50
+ * for a workspace the user cannot manage keys in, and neither is retryable. */
51
+ return {
52
+ kind: "failed",
53
+ reason: response.status === 403
54
+ ? "identity refused (403) — check the email on the account is verified, and that you can manage keys in this workspace"
55
+ : `identity refused the request (${response.status})`,
56
+ };
57
+ }
58
+ let payload;
59
+ try {
60
+ payload = JSON.parse(await response.text());
61
+ }
62
+ catch {
63
+ return { kind: "failed", reason: "identity returned a body that is not JSON" };
64
+ }
65
+ const value = payload.key_value;
66
+ if (typeof value !== "string" || value === "") {
67
+ return { kind: "failed", reason: "identity returned no key value" };
68
+ }
69
+ // The same rule as `--key`: this value becomes a header line.
70
+ if (containsControlCharacters(value)) {
71
+ return { kind: "failed", reason: "identity returned a key containing control characters" };
72
+ }
73
+ return { kind: "key", value };
74
+ }
75
+ //# sourceMappingURL=apiKeys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apiKeys.js","sourceRoot":"","sources":["../../src/login/apiKeys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,aAAa,GAAG,oBAAoB,CAAC;AAC3C,MAAM,UAAU,GAAG,MAAM,CAAC;AAE1B,iFAAiF;AACjF,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAC3C,MAAM,eAAe,GAAG,EAAE,CAAC;AAO3B;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,UAAkB,QAAQ,EAAE;IAClD,4CAA4C;IAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,wBAAwB,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAErE,OAAO,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,GAAG,eAAe,KAAK,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,eAAe,CAAC,GAAG,CAAC;AACxG,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,UAAkB,EAClB,OAAe,EACf,WAAmB,EACnB,OAAe,OAAO,EAAE,EACxB,YAAuB,KAAK;IAE5B,MAAM,IAAI,GAAG,YAAY,CAAC,UAAU,CAAC,CAAC;IACtC,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,UAAU,yCAAyC,EAAE,CAAC;IAEnH,MAAM,GAAG,GAAG,GAAG,IAAI,GAAG,aAAa,iBAAiB,k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AAC;IACtE,CAAC;IAED,8DAA8D;IAC9D,IAAI,yBAAyB,CAAC,KAAK,CAAC,EAAE,CAAC;QACrC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,uDAAuD,EAAE,CAAC;IAC7F,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAChC,CAAC"}
@@ -1,5 +1,7 @@
1
- export interface StoredCredential {
2
- readonly refreshToken: string;
1
+ import { type FileAcl } from "./fileAcl.js";
2
+ import type { SecretStore } from "./secretStore.js";
3
+ /** The non-secret half of a stored session. Safe to log; none of it authenticates. */
4
+ export interface StoredMetadata {
3
5
  readonly firebaseApiKey: string;
4
6
  readonly projectId: string;
5
7
  readonly userId: string;
@@ -8,16 +10,20 @@ export interface StoredCredential {
8
10
  /** ISO 8601, for `whoami` to say how old the session is. */
9
11
  readonly obtainedAt: string;
10
12
  }
11
- /** Injected so tests never touch a real home directory. */
13
+ /** Injected so tests never touch a real home directory or a real ACL. */
12
14
  export interface CredentialPaths {
13
15
  readonly home: string;
16
+ /** Replaces the POSIX mode as the owner-only mechanism. Defaults to NTFS ACLs on Windows only. */
17
+ readonly acl?: FileAcl | undefined;
18
+ /** Hears about ACL problems, which never fail a command. */
19
+ readonly warn?: ((message: string) => void) | undefined;
14
20
  }
15
21
  export declare function credentialsPath(ctx: CredentialPaths): string;
16
22
  export type LoadOutcome = {
17
23
  readonly kind: "none";
18
24
  } | {
19
25
  readonly kind: "credential";
20
- readonly credential: StoredCredential;
26
+ readonly credential: StoredMetadata;
21
27
  }
22
28
  /** The file exists but cannot be trusted or read — the message says what to do. */
23
29
  | {
@@ -25,10 +31,17 @@ export type LoadOutcome = {
25
31
  readonly reason: string;
26
32
  };
27
33
  export declare function load(gateway: string, ctx: CredentialPaths): LoadOutcome;
34
+ /** Sits beside the credentials file, so one lock covers every gateway's entry. */
35
+ export declare function lockPath(ctx: CredentialPaths): string;
28
36
  /**
29
- * Writes one gateway's credential, leaving the others alone. Created at 0600 rather than
30
- * chmodded after: the gap between the two is openable by another local user.
37
+ * Replaces the metadata and keeps only the secret fields. Not a blanket merge: an
38
+ * optional field such as `workspaceId` would otherwise survive from the previous user.
39
+ */
40
+ export declare function save(gateway: string, metadata: StoredMetadata, ctx: CredentialPaths): void;
41
+ /** Keeps secrets in the credentials file itself; the fallback where no keychain is reachable. */
42
+ export declare function fileSecretStore(ctx: CredentialPaths): SecretStore;
43
+ /**
44
+ * Removes one gateway's entry from this file. Returns false when there was none.
45
+ * Secrets held by another tier are not touched; forget them through the store.
31
46
  */
32
- export declare function save(gateway: string, credential: StoredCredential, ctx: CredentialPaths): void;
33
- /** Forgets one gateway's session. Returns false when there was nothing to forget. */
34
47
  export declare function clear(gateway: string, ctx: CredentialPaths): boolean;