@ai21/gateway 1.3.0 → 1.3.1
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/README.md +5 -4
- package/dist/agents/claude-code/revert.d.ts +11 -0
- package/dist/{revert.js → agents/claude-code/revert.js} +2 -1
- package/dist/agents/claude-code/revert.js.map +1 -0
- package/dist/agents/claude-code/settings.d.ts +33 -0
- package/dist/{config.js → agents/claude-code/settings.js} +6 -57
- package/dist/agents/claude-code/settings.js.map +1 -0
- package/dist/{snippets.d.ts → agents/claude-code/snippets.d.ts} +1 -18
- package/dist/{snippets.js → agents/claude-code/snippets.js} +0 -19
- package/dist/agents/claude-code/snippets.js.map +1 -0
- package/dist/agents/claude-code/status.d.ts +12 -0
- package/dist/agents/claude-code/status.js +42 -0
- package/dist/agents/claude-code/status.js.map +1 -0
- package/dist/{verify.d.ts → agents/claude-code/verify.d.ts} +14 -54
- package/dist/{verify.js → agents/claude-code/verify.js} +2 -133
- package/dist/agents/claude-code/verify.js.map +1 -0
- package/dist/agents/deps.d.ts +3 -0
- package/dist/agents/deps.js +10 -0
- package/dist/agents/deps.js.map +1 -0
- package/dist/agents/types.d.ts +266 -0
- package/dist/agents/types.js +3 -0
- package/dist/agents/types.js.map +1 -0
- package/dist/cli.js +3 -2
- package/dist/cli.js.map +1 -1
- package/dist/fs/safeFile.d.ts +19 -0
- package/dist/fs/safeFile.js +50 -0
- package/dist/fs/safeFile.js.map +1 -0
- package/dist/{snapshot.d.ts → fs/snapshot.d.ts} +1 -1
- package/dist/{snapshot.js → fs/snapshot.js} +1 -1
- package/dist/fs/snapshot.js.map +1 -0
- package/dist/login/keychain/linux.d.ts +1 -1
- package/dist/login/keychain/linux.js +1 -1
- package/dist/login/keychain/linux.js.map +1 -1
- package/dist/process.d.ts +26 -0
- package/dist/process.js +94 -0
- package/dist/process.js.map +1 -0
- package/dist/report.d.ts +3 -8
- package/dist/report.js.map +1 -1
- package/dist/router.d.ts +2 -3
- package/dist/router.js +26 -16
- package/dist/router.js.map +1 -1
- package/dist/telemetry/amplitudeHttp.js +1 -0
- package/dist/telemetry/amplitudeHttp.js.map +1 -1
- package/dist/telemetry/events.d.ts +7 -3
- package/dist/telemetry/telemetry.d.ts +6 -2
- package/dist/telemetry/telemetry.js +19 -8
- package/dist/telemetry/telemetry.js.map +1 -1
- package/package.json +3 -3
- package/dist/config.d.ts +0 -83
- package/dist/config.js.map +0 -1
- package/dist/revert.d.ts +0 -60
- package/dist/revert.js.map +0 -1
- package/dist/snapshot.js.map +0 -1
- package/dist/snippets.js.map +0 -1
- package/dist/verify.js.map +0 -1
package/README.md
CHANGED
|
@@ -102,10 +102,11 @@ mistake.
|
|
|
102
102
|
|
|
103
103
|
`install` reports onboarding events to AI21's product analytics (Amplitude), so we can
|
|
104
104
|
see where setup fails: when it started, then whether it completed or at which step it
|
|
105
|
-
failed, with the CLI version, OS, workspace id and a random per-run
|
|
106
|
-
reported as a fixed reason, never the message you saw, so no key, email,
|
|
107
|
-
or argument is ever sent. Setup counts as completed only once the written
|
|
108
|
-
been verified.
|
|
105
|
+
failed, with your AI21 user id, the CLI version, OS, workspace id and a random per-run
|
|
106
|
+
id. A failure is reported as a fixed reason, never the message you saw, so no key, email,
|
|
107
|
+
path, agent id or argument is ever sent. Setup counts as completed only once the written
|
|
108
|
+
config has been verified. A setup run while no one is signed in to that gateway is not
|
|
109
|
+
reported. Only the production and staging gateways report; any other `--gateway`
|
|
109
110
|
sends nothing. Reporting never delays or fails a command (`src/telemetry/`).
|
|
110
111
|
|
|
111
112
|
> **Internal only.** The package is published to AI21's Artifact Registry, not
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ConfigPaths } from "../../fs/safeFile.js";
|
|
2
|
+
import type { RevertOptions, RevertOutcome } from "../types.js";
|
|
3
|
+
type JsonObject = Record<string, unknown>;
|
|
4
|
+
/**
|
|
5
|
+
* The `x-agent-id` currently stored in the `\n`-joined header value. Returns
|
|
6
|
+
* undefined when the header, or the whole value, is absent or unparseable — an
|
|
7
|
+
* absent id can never satisfy the guard, which is the safe direction.
|
|
8
|
+
*/
|
|
9
|
+
export declare function storedAgentId(env: JsonObject | undefined): string | undefined;
|
|
10
|
+
export declare function revertConfig(paths: ConfigPaths, options: RevertOptions): RevertOutcome;
|
|
11
|
+
export {};
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { copyFileSync, existsSync, lstatSync, readFileSync, readlinkSync, realpathSync } from "node:fs";
|
|
13
13
|
import { dirname, resolve } from "node:path";
|
|
14
|
-
import {
|
|
14
|
+
import { atomicWrite, describeFsError } from "../../fs/safeFile.js";
|
|
15
|
+
import { MANAGED_KEYS, isOurConfig, isPlainObject, serialize } from "./settings.js";
|
|
15
16
|
/**
|
|
16
17
|
* Resolve a symlinked settings.json to what it names, so a revert writes through
|
|
17
18
|
* the link rather than replacing it — the same reason the writer does this.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revert.js","sourceRoot":"","sources":["../../../src/agents/claude-code/revert.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACxG,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAoB,WAAW,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEtF,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAIpF;;;GAGG;AACH,SAAS,UAAU,CAAC,IAAY;IAC9B,IAAI,CAAC;QACH,IAAI,SAAS,CAAC,IAAI,EAAE,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,EAAE,cAAc,EAAE,KAAK,IAAI,EAAE,CAAC;YAC1E,OAAO,OAAO,CAAC,OAAO,CAAC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AC,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;QAClC,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC;IAC1C,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,IAAI,SAAS,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC,OAAO,CAAC;IAE/C,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;IAExB,8EAA8E;IAC9E,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QAC3B,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC;IAC1C,CAAC;IAED,wEAAwE;IACxE,wDAAwD;IACxD,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;QACvC,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACvC,IAAI,MAAM,KAAK,OAAO,CAAC,YAAY,EAAE,CAAC;YACpC,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,IAAI,MAAM,EAAE,CAAC;QACpG,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AACvG,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Target } from "../../args.js";
|
|
2
|
+
import { type ConfigPaths } from "../../fs/safeFile.js";
|
|
3
|
+
import type { ConfigOutcome, PathContext } from "../types.js";
|
|
4
|
+
/** The `env` keys this tool owns. Anything else in the file is not ours. */
|
|
5
|
+
export declare const MANAGED_KEYS: readonly ["ANTHROPIC_BASE_URL", "ANTHROPIC_CUSTOM_HEADERS", "ENABLE_TOOL_SEARCH"];
|
|
6
|
+
/**
|
|
7
|
+
* Whether this file is *ours*, judged by a marker rather than by key names. Key names
|
|
8
|
+
* cannot tell our `ENABLE_TOOL_SEARCH` from one the developer set, so a hand-added key
|
|
9
|
+
* would be deleted by the next `uninstall`. Only this tool writes an `x-ai21-key`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function isOurConfig(env: Record<string, unknown> | undefined): boolean;
|
|
12
|
+
/** Claude Code reads `settings.local.json` after ours, so its env wins. */
|
|
13
|
+
export declare function shadowingLocalConfig(paths: ConfigPaths): {
|
|
14
|
+
path: string;
|
|
15
|
+
agentId?: string;
|
|
16
|
+
} | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* `--user` (the default) targets the home directory, `--repo` the project. A
|
|
19
|
+
* literal `~` is never expanded, so a directory named `~` is treated as one.
|
|
20
|
+
*/
|
|
21
|
+
export declare function resolvePaths(target: Target, ctx: PathContext): ConfigPaths;
|
|
22
|
+
type JsonObject = Record<string, unknown>;
|
|
23
|
+
export declare function isPlainObject(value: unknown): value is JsonObject;
|
|
24
|
+
export declare function serialize(settings: JsonObject): string;
|
|
25
|
+
/**
|
|
26
|
+
* Merge `desiredEnv` into `paths.settings`. Returns what happened rather than
|
|
27
|
+
* throwing, so the caller owns reporting and the exit code. Nothing is written on
|
|
28
|
+
* the `conflict` or `malformed` outcomes.
|
|
29
|
+
*/
|
|
30
|
+
export declare function writeConfig(paths: ConfigPaths, desiredEnv: Record<string, string>, options?: {
|
|
31
|
+
readonly force: boolean;
|
|
32
|
+
}): ConfigOutcome;
|
|
33
|
+
export {};
|
|
@@ -5,20 +5,14 @@
|
|
|
5
5
|
* for us. Every path leaves it byte-identical or replaces it atomically with a
|
|
6
6
|
* backup alongside, and no refusal path touches it at all.
|
|
7
7
|
*
|
|
8
|
-
* Helpers are exported for `revert.ts` and `snapshot.ts`, which uphold the same
|
|
8
|
+
* Helpers are exported for `revert.ts` and `fs/snapshot.ts`, which uphold the same
|
|
9
9
|
* guarantees on the way back out — a second atomic write is a second chance to get it wrong.
|
|
10
10
|
*/
|
|
11
|
-
import { chmodSync, copyFileSync, existsSync, lstatSync, mkdirSync, readFileSync, readlinkSync, realpathSync,
|
|
11
|
+
import { chmodSync, copyFileSync, existsSync, lstatSync, mkdirSync, readFileSync, readlinkSync, realpathSync, } from "node:fs";
|
|
12
12
|
import { dirname, join, resolve } from "node:path";
|
|
13
|
-
import {
|
|
13
|
+
import { atomicWrite, backupPathFor, describeFsError } from "../../fs/safeFile.js";
|
|
14
14
|
/** The `env` keys this tool owns. Anything else in the file is not ours. */
|
|
15
15
|
export const MANAGED_KEYS = ["ANTHROPIC_BASE_URL", "ANTHROPIC_CUSTOM_HEADERS", "ENABLE_TOOL_SEARCH"];
|
|
16
|
-
/* Where each client's config lives, relative to whichever root the target selects.
|
|
17
|
-
* A second client needs more than a row here — MANAGED_KEYS and the snippet builders
|
|
18
|
-
* are Claude Code's env shape — but this is the fork the rest of the code reads. */
|
|
19
|
-
const CLIENT_CONFIG = {
|
|
20
|
-
"claude-code": { dir: ".claude", file: "settings.json" },
|
|
21
|
-
};
|
|
22
16
|
/**
|
|
23
17
|
* Whether this file is *ours*, judged by a marker rather than by key names. Key names
|
|
24
18
|
* cannot tell our `ENABLE_TOOL_SEARCH` from one the developer set, so a hand-added key
|
|
@@ -50,61 +44,16 @@ export function shadowingLocalConfig(paths) {
|
|
|
50
44
|
* `--user` (the default) targets the home directory, `--repo` the project. A
|
|
51
45
|
* literal `~` is never expanded, so a directory named `~` is treated as one.
|
|
52
46
|
*/
|
|
53
|
-
export function resolvePaths(target, ctx
|
|
54
|
-
const
|
|
55
|
-
const settings = join(target === "user" ? ctx.home : ctx.cwd, dir, file);
|
|
47
|
+
export function resolvePaths(target, ctx) {
|
|
48
|
+
const settings = join(target === "user" ? ctx.home : ctx.cwd, ".claude", "settings.json");
|
|
56
49
|
return { settings, backup: `${settings}.bak` };
|
|
57
50
|
}
|
|
58
|
-
/**
|
|
59
|
-
* Turns an fs error into something safe to print. The code is translated rather
|
|
60
|
-
* than forwarded so no stack frame, errno struct or internal path escapes.
|
|
61
|
-
*/
|
|
62
|
-
export function describeFsError(err) {
|
|
63
|
-
const code = err?.code;
|
|
64
|
-
switch (code) {
|
|
65
|
-
case "EACCES":
|
|
66
|
-
case "EPERM":
|
|
67
|
-
return "permission denied";
|
|
68
|
-
case "ENOSPC":
|
|
69
|
-
return "no space left on the device";
|
|
70
|
-
case "EROFS":
|
|
71
|
-
return "the filesystem is read-only";
|
|
72
|
-
case "EISDIR":
|
|
73
|
-
return "it is a directory, not a file";
|
|
74
|
-
default:
|
|
75
|
-
return "the write could not be completed";
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
51
|
export function isPlainObject(value) {
|
|
79
52
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
80
53
|
}
|
|
81
|
-
/**
|
|
82
|
-
* Write via a sibling temp file and rename. The rename is atomic within a
|
|
83
|
-
* filesystem, so a reader either sees the old file or the new one — never a
|
|
84
|
-
* half-written config. The temp file is removed on any failure so a crashed run
|
|
85
|
-
* leaves no litter next to the real file.
|
|
86
|
-
*/
|
|
87
|
-
export function atomicWrite(target, contents) {
|
|
88
|
-
// Same directory, so the rename cannot cross a filesystem boundary. The pid
|
|
89
|
-
// keeps two concurrent runs from fighting over one temp name.
|
|
90
|
-
const tmp = `${target}.${process.pid}.tmp`;
|
|
91
|
-
try {
|
|
92
|
-
// 0600: this file carries an API key.
|
|
93
|
-
writeFileSync(tmp, contents, { mode: 0o600 });
|
|
94
|
-
renameSync(tmp, target);
|
|
95
|
-
}
|
|
96
|
-
catch (err) {
|
|
97
|
-
rmSync(tmp, { force: true });
|
|
98
|
-
throw err;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
54
|
export function serialize(settings) {
|
|
102
55
|
return `${JSON.stringify(settings, null, 2)}\n`;
|
|
103
56
|
}
|
|
104
|
-
/** A symlinked settings.json is backed up beside its target, not beside the link. */
|
|
105
|
-
export function backupPathFor(paths, realPath) {
|
|
106
|
-
return realPath === paths.settings ? paths.backup : `${realPath}.bak`;
|
|
107
|
-
}
|
|
108
57
|
/**
|
|
109
58
|
* Merge `desiredEnv` into `paths.settings`. Returns what happened rather than
|
|
110
59
|
* throwing, so the caller owns reporting and the exit code. Nothing is written on
|
|
@@ -206,4 +155,4 @@ export function writeConfig(paths, desiredEnv, options = { force: false }) {
|
|
|
206
155
|
}
|
|
207
156
|
return { kind: "updated", path, backup: backupPath, changed };
|
|
208
157
|
}
|
|
209
|
-
//# sourceMappingURL=
|
|
158
|
+
//# sourceMappingURL=settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../../src/agents/claude-code/settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,SAAS,EACT,YAAY,EACZ,UAAU,EACV,SAAS,EACT,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,YAAY,GACb,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGnD,OAAO,EAAoB,WAAW,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGrG,4EAA4E;AAC5E,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,oBAAoB,EAAE,0BAA0B,EAAE,oBAAoB,CAAU,CAAC;AAE9G;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,GAAwC;IAClE,MAAM,OAAO,GAAG,GAAG,EAAE,wBAAwB,CAAC;IAE9C,OAAO,OAAO,OAAO,KAAK,QAAQ,IAAI,2BAA2B,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAClF,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,oBAAoB,CAAC,KAAkB;IACrD,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,CA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AAE,GAAG,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC;IACzF,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC;IAChE,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC;AAChE,CAAC"}
|
|
@@ -15,26 +15,9 @@
|
|
|
15
15
|
* signed-in user. The CLI is unauthenticated, so that line is absent entirely
|
|
16
16
|
* unless `--user-id` supplies one — not blank, and no trailing newline.
|
|
17
17
|
*/
|
|
18
|
+
import type { SnippetInputs } from "../types.js";
|
|
18
19
|
/** Stand-in for the caller's own Anthropic key, which the CLI never holds. */
|
|
19
20
|
export declare const ANTHROPIC_KEY_PLACEHOLDER = "<your-anthropic-api-key>";
|
|
20
|
-
/** Stand-in for the AI21 key in a preview, before one has been supplied. */
|
|
21
|
-
export declare const AI21_KEY_PLACEHOLDER = "<your-ai21-api-key>";
|
|
22
|
-
export interface SnippetInputs {
|
|
23
|
-
readonly gatewayUrl: string;
|
|
24
|
-
readonly agentId: string;
|
|
25
|
-
readonly ai21Key: string;
|
|
26
|
-
/** Signed-in user id for per-user attribution. Absent on a normal CLI run. */
|
|
27
|
-
readonly userId?: string | undefined;
|
|
28
|
-
/**
|
|
29
|
-
* Marks the traffic as configured by this tool, e.g. `ai21-gateway-cli/0.4.0`.
|
|
30
|
-
*
|
|
31
|
-
* Set on what the CLI writes, and deliberately absent from the snippet builders the
|
|
32
|
-
* contract test pins against the webapp: a config someone pasted by hand did not
|
|
33
|
-
* come from here and must not claim to have. Lets the gateway tell the two apart
|
|
34
|
-
* without the CLI reporting anything itself.
|
|
35
|
-
*/
|
|
36
|
-
readonly client?: string | undefined;
|
|
37
|
-
}
|
|
38
21
|
/** Claude Code's `ANTHROPIC_CUSTOM_HEADERS` value. Header order is contractual. */
|
|
39
22
|
export declare function ccCustomHeaders({ agentId, ai21Key, userId, client }: SnippetInputs): string;
|
|
40
23
|
/**
|
|
@@ -1,24 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Snippet builders duplicated from the gateway webapp, so what the CLI writes is
|
|
3
|
-
* byte-identical to what the UI tells people to copy.
|
|
4
|
-
*
|
|
5
|
-
* Copied from AI21Labs/ai21-intelligent-gateway-webapp:
|
|
6
|
-
* src/pages/docs/integrations.tsx — the builders
|
|
7
|
-
* src/pages/docs/snippetContext.tsx — the placeholder constants
|
|
8
|
-
*
|
|
9
|
-
* A webapp edit cannot fail our CI, so this drifts silently — re-copy when the
|
|
10
|
-
* gateway's snippets change. `test/fixtures/webapp-snippets.json` is what catches
|
|
11
|
-
* a divergence. Only the Claude Code path is mirrored; the LangChain snippets are
|
|
12
|
-
* now a four-way client matrix whose port is a design question, not a copy job.
|
|
13
|
-
*
|
|
14
|
-
* One deliberate divergence: the webapp always emits `x-ai21-user-id`, having a
|
|
15
|
-
* signed-in user. The CLI is unauthenticated, so that line is absent entirely
|
|
16
|
-
* unless `--user-id` supplies one — not blank, and no trailing newline.
|
|
17
|
-
*/
|
|
18
1
|
/** Stand-in for the caller's own Anthropic key, which the CLI never holds. */
|
|
19
2
|
export const ANTHROPIC_KEY_PLACEHOLDER = "<your-anthropic-api-key>";
|
|
20
|
-
/** Stand-in for the AI21 key in a preview, before one has been supplied. */
|
|
21
|
-
export const AI21_KEY_PLACEHOLDER = "<your-ai21-api-key>";
|
|
22
3
|
/** Drops the lines that only exist when a user id was supplied. */
|
|
23
4
|
function joinLines(lines) {
|
|
24
5
|
return lines.filter((line) => line !== undefined).join("\n");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snippets.js","sourceRoot":"","sources":["../../../src/agents/claude-code/snippets.ts"],"names":[],"mappings":"AAmBA,8EAA8E;AAC9E,MAAM,CAAC,MAAM,yBAAyB,GAAG,0BAA0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MAAM;QAClC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,yBAAyB,MAAM,MAAM;QACxE,0CAA0C;QAC1C,wDAAwD;QACxD,iFAAiF;KAClF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AgentDeps } from "../types.js";
|
|
2
|
+
/** `claude auth status` is local and answers in about a second. */
|
|
3
|
+
export declare const AUTH_STATUS_TIMEOUT_MS = 5000;
|
|
4
|
+
export type ClaudeLogin = "logged-in" | "logged-out" | "inconclusive";
|
|
5
|
+
/**
|
|
6
|
+
* Asks `claude auth status`, which reads local state only, whether Claude Code has any
|
|
7
|
+
* credential — so a missing one is caught before anything is written. Only an explicit
|
|
8
|
+
* `"loggedIn": false` with no auth method counts as logged out, and only for Anthropic's
|
|
9
|
+
* own API: an older `claude` without the subcommand, unparseable output, or a Bedrock or
|
|
10
|
+
* Vertex setup are all inconclusive and leave the decision to verification.
|
|
11
|
+
*/
|
|
12
|
+
export declare function checkClaudeLogin(cwd: string, deps: AgentDeps): Promise<ClaudeLogin>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether Claude Code has a login the gateway can forward, asked before anything is
|
|
3
|
+
* written so a missing one never leaves a config behind.
|
|
4
|
+
*/
|
|
5
|
+
import { findOnPath } from "../../process.js";
|
|
6
|
+
import { CLAUDE_COMMAND } from "./verify.js";
|
|
7
|
+
/** `claude auth status` is local and answers in about a second. */
|
|
8
|
+
export const AUTH_STATUS_TIMEOUT_MS = 5_000;
|
|
9
|
+
/**
|
|
10
|
+
* Asks `claude auth status`, which reads local state only, whether Claude Code has any
|
|
11
|
+
* credential — so a missing one is caught before anything is written. Only an explicit
|
|
12
|
+
* `"loggedIn": false` with no auth method counts as logged out, and only for Anthropic's
|
|
13
|
+
* own API: an older `claude` without the subcommand, unparseable output, or a Bedrock or
|
|
14
|
+
* Vertex setup are all inconclusive and leave the decision to verification.
|
|
15
|
+
*/
|
|
16
|
+
export async function checkClaudeLogin(cwd, deps) {
|
|
17
|
+
const executable = findOnPath(CLAUDE_COMMAND, deps.lookup);
|
|
18
|
+
if (executable === undefined)
|
|
19
|
+
return "inconclusive";
|
|
20
|
+
const result = await deps.runCommand(executable, ["auth", "status"], { cwd, timeoutMs: AUTH_STATUS_TIMEOUT_MS });
|
|
21
|
+
if (result.timedOut || result.code === null)
|
|
22
|
+
return "inconclusive";
|
|
23
|
+
const start = result.output.indexOf("{");
|
|
24
|
+
const end = result.output.lastIndexOf("}");
|
|
25
|
+
if (start === -1 || end < start)
|
|
26
|
+
return "inconclusive";
|
|
27
|
+
let status;
|
|
28
|
+
try {
|
|
29
|
+
status = JSON.parse(result.output.slice(start, end + 1));
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return "inconclusive";
|
|
33
|
+
}
|
|
34
|
+
if (typeof status !== "object" || status === null)
|
|
35
|
+
return "inconclusive";
|
|
36
|
+
const { loggedIn, authMethod, apiProvider } = status;
|
|
37
|
+
if (loggedIn === true)
|
|
38
|
+
return "logged-in";
|
|
39
|
+
const firstParty = apiProvider === undefined || apiProvider === "firstParty";
|
|
40
|
+
return loggedIn === false && authMethod === "none" && firstParty ? "logged-out" : "inconclusive";
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/agents/claude-code/status.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,mEAAmE;AACnE,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,CAAC;AAI5C;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,GAAW,EAAE,IAAe;IACjE,MAAM,UAAU,GAAG,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CAAC,cAAc,CAAC;AACnG,CAAC"}
|
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* One real request through the gateway, to prove the written config works and flip
|
|
3
|
+
* the agent's `used` latch. Three tiers, because the CLI holds no Anthropic
|
|
4
|
+
* credential and the gateway requires one: `claude -p` if it is on PATH, else a
|
|
5
|
+
* direct ping if a key is available, else skip.
|
|
6
|
+
*
|
|
7
|
+
* Two invariants: exactly one request is fired — a winning tier means no later tier
|
|
8
|
+
* runs — and only a definite missing-credential result changes the exit code. A
|
|
9
|
+
* timeout or unrecognised failure stays a warning, so a flaky network never undoes a
|
|
10
|
+
* good write.
|
|
11
|
+
*/
|
|
12
|
+
import { type ResolvedUrls } from "../../args.js";
|
|
13
|
+
import type { AgentDeps } from "../types.js";
|
|
2
14
|
export declare const CLAUDE_COMMAND = "claude";
|
|
3
15
|
export declare const CLAUDE_PROMPT = "ai21-gateway CLI connectivity check \u2014 reply with OK and nothing else.";
|
|
4
16
|
export declare const PING_PATH = "/v1/messages";
|
|
@@ -57,44 +69,6 @@ export interface VerifyContext {
|
|
|
57
69
|
*/
|
|
58
70
|
readonly cwd: string;
|
|
59
71
|
}
|
|
60
|
-
export interface CommandResult {
|
|
61
|
-
/** `null` when the process was killed or could not be started at all. */
|
|
62
|
-
readonly code: number | null;
|
|
63
|
-
readonly timedOut: boolean;
|
|
64
|
-
/** Combined stdout+stderr, used only to explain a failure. */
|
|
65
|
-
readonly output: string;
|
|
66
|
-
}
|
|
67
|
-
/** Just enough of `fetch` to ping with. `text` is optional; absent means inconclusive. */
|
|
68
|
-
export type FetchLike = (url: string, init: {
|
|
69
|
-
method: string;
|
|
70
|
-
headers: Record<string, string>;
|
|
71
|
-
body: string;
|
|
72
|
-
signal: AbortSignal;
|
|
73
|
-
}) => Promise<{
|
|
74
|
-
ok: boolean;
|
|
75
|
-
status: number;
|
|
76
|
-
text?: () => Promise<string>;
|
|
77
|
-
}>;
|
|
78
|
-
export interface PathLookup {
|
|
79
|
-
readonly platform: string;
|
|
80
|
-
readonly processEnv: Record<string, string | undefined>;
|
|
81
|
-
/** Injected so the tier-1 tests never depend on what is installed. */
|
|
82
|
-
readonly isExecutableFile: (candidate: string) => boolean;
|
|
83
|
-
}
|
|
84
|
-
export interface VerifyDeps {
|
|
85
|
-
readonly lookup: PathLookup;
|
|
86
|
-
readonly runCommand: (executable: string, args: readonly string[], opts: {
|
|
87
|
-
readonly cwd: string;
|
|
88
|
-
readonly timeoutMs: number;
|
|
89
|
-
}) => Promise<CommandResult>;
|
|
90
|
-
readonly fetchImpl: FetchLike;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Hand-rolled rather than shelling out to `which`/`where`, which is slower and
|
|
94
|
-
* absent from stripped Windows images. `node:path`'s `join` and `delimiter` follow
|
|
95
|
-
* the *host* platform, so they cannot resolve a Windows PATH under test on macOS.
|
|
96
|
-
*/
|
|
97
|
-
export declare function findOnPath(command: string, lookup: PathLookup): string | undefined;
|
|
98
72
|
/** What the direct ping would send: `--anthropic-key`, else a non-empty ANTHROPIC_API_KEY. */
|
|
99
73
|
export declare function resolveAnthropicKey(ctx: Pick<VerifyContext, "anthropicKey" | "processEnv">): string | undefined;
|
|
100
74
|
/**
|
|
@@ -102,18 +76,4 @@ export declare function resolveAnthropicKey(ctx: Pick<VerifyContext, "anthropicK
|
|
|
102
76
|
* `x-api-key` cannot succeed, so whichever layer answers is the answer.
|
|
103
77
|
*/
|
|
104
78
|
export type CredentialVerdict = "ai21-rejected" | "ai21-accepted" | "inconclusive";
|
|
105
|
-
|
|
106
|
-
export declare const AUTH_STATUS_TIMEOUT_MS = 5000;
|
|
107
|
-
export type ClaudeLogin = "logged-in" | "logged-out" | "inconclusive";
|
|
108
|
-
/**
|
|
109
|
-
* Asks `claude auth status`, which reads local state only, whether Claude Code has any
|
|
110
|
-
* credential — so a missing one is caught before anything is written. Only an explicit
|
|
111
|
-
* `"loggedIn": false` with no auth method counts as logged out, and only for Anthropic's
|
|
112
|
-
* own API: an older `claude` without the subcommand, unparseable output, or a Bedrock or
|
|
113
|
-
* Vertex setup are all inconclusive and leave the decision to verification.
|
|
114
|
-
*/
|
|
115
|
-
export declare function checkClaudeLogin(cwd: string, deps: VerifyDeps): Promise<ClaudeLogin>;
|
|
116
|
-
export declare function verify(ctx: VerifyContext, deps: VerifyDeps): Promise<VerifyOutcome>;
|
|
117
|
-
export declare function isExecutableFile(candidate: string): boolean;
|
|
118
|
-
/** The real-world adapters, kept here so `cli.ts` stays a thin edge. */
|
|
119
|
-
export declare function nodeVerifyDeps(processEnv: Record<string, string | undefined>): VerifyDeps;
|
|
79
|
+
export declare function verify(ctx: VerifyContext, deps: AgentDeps): Promise<VerifyOutcome>;
|
|
@@ -9,9 +9,8 @@
|
|
|
9
9
|
* timeout or unrecognised failure stays a warning, so a flaky network never undoes a
|
|
10
10
|
* good write.
|
|
11
11
|
*/
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { DEFAULT_URLS, isInsecureGateway } from "./args.js";
|
|
12
|
+
import { DEFAULT_URLS, isInsecureGateway } from "../../args.js";
|
|
13
|
+
import { findOnPath } from "../../process.js";
|
|
15
14
|
export const CLAUDE_COMMAND = "claude";
|
|
16
15
|
/* An instruction with a trivial answer, and it names itself so a gateway trace shows
|
|
17
16
|
* why the request happened. Both halves matter: "ai21-gateway CLI verification" alone
|
|
@@ -40,29 +39,6 @@ export const PING_BODY = {
|
|
|
40
39
|
max_tokens: 64,
|
|
41
40
|
messages: [{ role: "user", content: "Hello through the gateway" }],
|
|
42
41
|
};
|
|
43
|
-
/** npm installs the Claude Code CLI as `claude.cmd`, so this must not be empty. */
|
|
44
|
-
const DEFAULT_PATHEXT = ".COM;.EXE;.BAT;.CMD";
|
|
45
|
-
/**
|
|
46
|
-
* Hand-rolled rather than shelling out to `which`/`where`, which is slower and
|
|
47
|
-
* absent from stripped Windows images. `node:path`'s `join` and `delimiter` follow
|
|
48
|
-
* the *host* platform, so they cannot resolve a Windows PATH under test on macOS.
|
|
49
|
-
*/
|
|
50
|
-
export function findOnPath(command, lookup) {
|
|
51
|
-
const windows = lookup.platform === "win32";
|
|
52
|
-
const separator = windows ? ";" : ":";
|
|
53
|
-
const raw = lookup.processEnv.PATH ?? (windows ? lookup.processEnv.Path : undefined) ?? "";
|
|
54
|
-
const extensions = windows ? (lookup.processEnv.PATHEXT ?? DEFAULT_PATHEXT).split(";") : [""];
|
|
55
|
-
for (const dir of raw.split(separator)) {
|
|
56
|
-
if (dir === "")
|
|
57
|
-
continue;
|
|
58
|
-
for (const extension of extensions) {
|
|
59
|
-
const candidate = `${dir.replace(/[\\/]+$/, "")}${windows ? "\\" : "/"}${command}${extension}`;
|
|
60
|
-
if (lookup.isExecutableFile(candidate))
|
|
61
|
-
return candidate;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return undefined;
|
|
65
|
-
}
|
|
66
42
|
/** Blanks every credential in play, wherever it appears. */
|
|
67
43
|
function redactSecrets(text, ctx) {
|
|
68
44
|
let redacted = text;
|
|
@@ -258,41 +234,6 @@ async function viaDirectPing(anthropicKey, ctx, deps) {
|
|
|
258
234
|
return failed(`the gateway could not be reached at ${ctx.urls.gateway}`);
|
|
259
235
|
}
|
|
260
236
|
}
|
|
261
|
-
/** `claude auth status` is local and answers in about a second. */
|
|
262
|
-
export const AUTH_STATUS_TIMEOUT_MS = 5_000;
|
|
263
|
-
/**
|
|
264
|
-
* Asks `claude auth status`, which reads local state only, whether Claude Code has any
|
|
265
|
-
* credential — so a missing one is caught before anything is written. Only an explicit
|
|
266
|
-
* `"loggedIn": false` with no auth method counts as logged out, and only for Anthropic's
|
|
267
|
-
* own API: an older `claude` without the subcommand, unparseable output, or a Bedrock or
|
|
268
|
-
* Vertex setup are all inconclusive and leave the decision to verification.
|
|
269
|
-
*/
|
|
270
|
-
export async function checkClaudeLogin(cwd, deps) {
|
|
271
|
-
const executable = findOnPath(CLAUDE_COMMAND, deps.lookup);
|
|
272
|
-
if (executable === undefined)
|
|
273
|
-
return "inconclusive";
|
|
274
|
-
const result = await deps.runCommand(executable, ["auth", "status"], { cwd, timeoutMs: AUTH_STATUS_TIMEOUT_MS });
|
|
275
|
-
if (result.timedOut || result.code === null)
|
|
276
|
-
return "inconclusive";
|
|
277
|
-
const start = result.output.indexOf("{");
|
|
278
|
-
const end = result.output.lastIndexOf("}");
|
|
279
|
-
if (start === -1 || end < start)
|
|
280
|
-
return "inconclusive";
|
|
281
|
-
let status;
|
|
282
|
-
try {
|
|
283
|
-
status = JSON.parse(result.output.slice(start, end + 1));
|
|
284
|
-
}
|
|
285
|
-
catch {
|
|
286
|
-
return "inconclusive";
|
|
287
|
-
}
|
|
288
|
-
if (typeof status !== "object" || status === null)
|
|
289
|
-
return "inconclusive";
|
|
290
|
-
const { loggedIn, authMethod, apiProvider } = status;
|
|
291
|
-
if (loggedIn === true)
|
|
292
|
-
return "logged-in";
|
|
293
|
-
const firstParty = apiProvider === undefined || apiProvider === "firstParty";
|
|
294
|
-
return loggedIn === false && authMethod === "none" && firstParty ? "logged-out" : "inconclusive";
|
|
295
|
-
}
|
|
296
237
|
export async function verify(ctx, deps) {
|
|
297
238
|
const executable = findOnPath(CLAUDE_COMMAND, deps.lookup);
|
|
298
239
|
if (executable !== undefined)
|
|
@@ -302,76 +243,4 @@ export async function verify(ctx, deps) {
|
|
|
302
243
|
return viaDirectPing(anthropicKey, ctx, deps);
|
|
303
244
|
return { kind: "skipped", hint: `${manualHint(ctx.cwd)}.` };
|
|
304
245
|
}
|
|
305
|
-
/** Cap on captured subprocess output — only the first line is ever quoted. */
|
|
306
|
-
const MAX_CAPTURED_OUTPUT = 4_096;
|
|
307
|
-
function runCommand(executable, args, opts) {
|
|
308
|
-
return new Promise((resolve) => {
|
|
309
|
-
// A .cmd cannot be spawned without a shell since the CVE-2024-27980 fix. Safe
|
|
310
|
-
// here because every argument is a literal. Killing the shell may orphan the
|
|
311
|
-
// real `claude`, which exits on its own shortly after.
|
|
312
|
-
const shell = /\.(cmd|bat)$/i.test(executable);
|
|
313
|
-
const child = spawn(shell ? `"${executable}"` : executable, [...args], {
|
|
314
|
-
cwd: opts.cwd,
|
|
315
|
-
shell,
|
|
316
|
-
// stdin closed: `claude` must never sit waiting on input we will not send.
|
|
317
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
318
|
-
});
|
|
319
|
-
let output = "";
|
|
320
|
-
const capture = (chunk) => {
|
|
321
|
-
if (output.length < MAX_CAPTURED_OUTPUT)
|
|
322
|
-
output += chunk.toString("utf8");
|
|
323
|
-
};
|
|
324
|
-
child.stdout?.on("data", capture);
|
|
325
|
-
child.stderr?.on("data", capture);
|
|
326
|
-
let done = false;
|
|
327
|
-
const settle = (result) => {
|
|
328
|
-
if (done)
|
|
329
|
-
return;
|
|
330
|
-
done = true;
|
|
331
|
-
clearTimeout(timer);
|
|
332
|
-
resolve(result);
|
|
333
|
-
};
|
|
334
|
-
/**
|
|
335
|
-
* Our own timer, not spawn's `timeout`: Windows reports a killed process as an
|
|
336
|
-
* ordinary non-zero exit, so an inferred timeout would be wrong there.
|
|
337
|
-
*
|
|
338
|
-
* It resolves the promise itself rather than killing and waiting for `close`.
|
|
339
|
-
* `close` fires when the *stdio* closes, and anything `claude` spawned inherits
|
|
340
|
-
* those pipes — an MCP server or a hook outliving its parent holds them open, so
|
|
341
|
-
* the kill lands and `close` never comes. That hung the CLI indefinitely after a
|
|
342
|
-
* write it had already completed. The budget is now a guarantee, not a hope.
|
|
343
|
-
*/
|
|
344
|
-
let timedOut = false;
|
|
345
|
-
const timer = setTimeout(() => {
|
|
346
|
-
timedOut = true;
|
|
347
|
-
child.kill("SIGKILL");
|
|
348
|
-
settle({ code: null, timedOut, output: output.trim() });
|
|
349
|
-
}, opts.timeoutMs);
|
|
350
|
-
// A spawn error may never emit `close`, so both paths settle. Only the errno is
|
|
351
|
-
// kept — the message carries an absolute path.
|
|
352
|
-
child.once("error", (err) => settle({ code: null, timedOut, output: err.code ?? "" }));
|
|
353
|
-
child.once("close", (code) => settle({ code, timedOut, output: output.trim() }));
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
export function isExecutableFile(candidate) {
|
|
357
|
-
try {
|
|
358
|
-
if (!statSync(candidate).isFile())
|
|
359
|
-
return false;
|
|
360
|
-
// The execute bit is meaningless on Windows, where the extension decides.
|
|
361
|
-
if (process.platform !== "win32")
|
|
362
|
-
accessSync(candidate, constants.X_OK);
|
|
363
|
-
return true;
|
|
364
|
-
}
|
|
365
|
-
catch {
|
|
366
|
-
return false;
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
/** The real-world adapters, kept here so `cli.ts` stays a thin edge. */
|
|
370
|
-
export function nodeVerifyDeps(processEnv) {
|
|
371
|
-
return {
|
|
372
|
-
lookup: { platform: process.platform, processEnv, isExecutableFile },
|
|
373
|
-
runCommand,
|
|
374
|
-
fetchImpl: fetch,
|
|
375
|
-
};
|
|
376
|
-
}
|
|
377
246
|
//# sourceMappingURL=verify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.js","sourceRoot":"","sources":["../../../src/agents/claude-code/verify.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,YAAY,EAAqB,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C,MAAM,CAAC,MAAM,cAAc,GAAG,QAAQ,CAAC;AACvC;;;wDAGwD;AACxD,MAAM,CAAC,MAAM,aAAa,GAAG,uEAAuE,CAAC;AACrG,MAAM,CAAC,MAAM,SAAS,GAAG,cAAc,CAAC;AAExC,uFAAuF;AACvF,MAAM,aAAa,GAAG,oBAAoB,CAAC;AAE3C;iFACiF;AACjF,SAAS,UAAU,CAAC,GAAW;IAC7B,OAAO,SAAS,cAAc,QAAQ,aAAa,UAAU,GAAG,oBAAoB,CAAC;AACvF,CAAC;AAED;;;;;GAKG;AACH,M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,CAAC,CAAC,CAAC,EAAE,CAAC;QAEjE,OAAO,MAAM,CAAC,wBAAwB,QAAQ,CAAC,MAAM,GAAG,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,GAAG,IAAI,EAAE,CAAC,CAAC;IAC3G,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YACjB,OAAO,MAAM,CAAC,qCAAqC,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC;QAChF,CAAC;QAED,0EAA0E;QAC1E,wEAAwE;QACxE,OAAO,MAAM,CAAC,uCAAuC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IAC3E,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,GAAkB,EAAE,IAAe;IAC9D,MAAM,UAAU,GAAG,UAAU,CAAC,cAAc,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAC3D,IAAI,UAAU,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC,UAAU,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;IAEtE,MAAM,YAAY,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;IAC9C,IAAI,YAAY,KAAK,SAAS;QAAE,OAAO,aAAa,CAAC,YAAY,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;IAE9E,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { isExecutableFile, runCommand } from "../process.js";
|
|
2
|
+
/** The real-world adapters, kept here so `cli.ts` stays a thin edge. */
|
|
3
|
+
export function nodeAgentDeps(processEnv) {
|
|
4
|
+
return {
|
|
5
|
+
lookup: { platform: process.platform, processEnv, isExecutableFile },
|
|
6
|
+
runCommand,
|
|
7
|
+
fetchImpl: fetch,
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=deps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deps.js","sourceRoot":"","sources":["../../src/agents/deps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG7D,wEAAwE;AACxE,MAAM,UAAU,aAAa,CAAC,UAA8C;IAC1E,OAAO;QACL,MAAM,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,UAAU,EAAE,gBAAgB,EAAE;QACpE,UAAU;QACV,SAAS,EAAE,KAA6B;KACzC,CAAC;AACJ,CAAC"}
|