@kodycodes/cli 1.14.0 → 1.15.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 CHANGED
@@ -68,7 +68,7 @@ Or run via `npx @kodycodes/cli` without a global install.
68
68
  | `kody whoami` | Confirms the CLI MCP connection and lists tools. With a scoped API token (and no login), shows token identity via the Open API. |
69
69
  | `kody search [query]` | Calls Kody `search` from the CLI (prefer the host MCP tool). Token-only auth uses Open API `GET /v1/search`. |
70
70
  | `kody api <operationId>` | Thin Open API wrapper matching the MCP `api` tool: `operationId` + flat `--params` JSON. Auth: `--token` / `KODY_API_TOKEN` / stored `auth bootstrap` token. |
71
- | `kody execute` | Calls Kody `execute` from the CLI (`--invoke`, `--code`, `--file`, or stdin via `--file -`). With a scoped API token and no login (or with `--token`), cloud execute goes through CapabilityProxy → `kody.execute` — no `kody login`. Add `--local` to run the module (and static `kody:@…` package modules) on this machine instead. `--allow-private-network` opts local execution into private and local network access. |
71
+ | `kody execute` | Calls Kody `execute` from the CLI (`--invoke`, `--code`, `--file`, or stdin via `--file -`). With a scoped API token and no login (or with `--token`), cloud execute goes through CapabilityProxy → `kody.execute` — no `kody login`. Add `--local` to run the module (and static `kody:@…` package modules) on this machine instead. `--credential key=name` (repeatable; `org:name` / `personal:name` / empty `=` for none) picks ADR 0068 credentials for `--local` or a `kody login` MCP session. `--allow-private-network` opts local execution into private and local network access. |
72
72
 
73
73
  `--json` prints structured MCP results.
74
74
 
@@ -173,6 +173,10 @@ npx @kodycodes/cli execute --local --file ./task.js --params '{"to":"me@example.
173
173
  # Or a scoped API token (still wins over login / bootstrap store when set):
174
174
  export KODY_API_TOKEN=… # minted through the Kody `api` tool
175
175
  npx @kodycodes/cli execute --local --file ./task.js --params '{"to":"me@example.com"}'
176
+
177
+ # ADR 0068: pick credentials for credential(key) / credentials(key)
178
+ npx @kodycodes/cli execute --local --credential github=work --credential resend=personal:prod \
179
+ --code 'import { credential } from "kody:runtime"; export default async () => (await credential("github")).name'
176
180
  ```
177
181
 
178
182
  - **Auth:** `--token` / `KODY_API_TOKEN` when set; else stored `auth bootstrap`
@@ -206,12 +210,14 @@ npx @kodycodes/cli execute --local --file ./task.js --params '{"to":"me@example.
206
210
  imports `kody:@…`, it also calls `POST /v1/local-execute/package-graph` to
207
211
  download stamped package modules for local embedding
208
212
  ([platform issue](https://github.com/kentcdodds/kody/issues/2808)).
209
- CapabilityProxy requests use a dedicated HTTP agent that waits up to 7
210
- minutes for headers and between body chunks. Origin's 5-minute deadline for
211
- a `fetch` with `{{secret:…}}` placeholders ends that call first, with its own
212
- error. Node's default 300-second limit no longer cuts it short. With
213
- `NODE_USE_ENV_PROXY=1` or `--use-env-proxy`, these requests still honor
214
- `HTTP_PROXY` / `HTTPS_PROXY` / `NO_PROXY`, like Node's own fetch.
213
+ CapabilityProxy requests go through Node's own `node:http(s)` client with
214
+ one keep-alive connection and a 7-minute idle limit for headers and body
215
+ chunks. Origin's 5-minute deadline for a `fetch` with `{{secret:…}}`
216
+ placeholders ends that call first, with its own error. Node's default
217
+ 300-second fetch limit no longer cuts it short. With `NODE_USE_ENV_PROXY=1`
218
+ or `--use-env-proxy`, these requests honor `HTTP_PROXY` / `HTTPS_PROXY` /
219
+ `NO_PROXY` like Node's own fetch (Node 22.21 / 24.5 or later; older Node
220
+ fails with a clear error instead of silently bypassing the proxy).
215
221
  A PR preview's API host is `https://kody-pr-<n>-api.<subdomain>.workers.dev`;
216
222
  the app origin (`kody-pr-<n>`) answers `/v1/*` with an HTML 404.
217
223
  - **Errors:** an expired/revoked token or an account without the
@@ -1,4 +1,4 @@
1
- import type { Dispatcher } from 'undici';
1
+ import { type CredentialCallMapInput } from './credential-call-map.js';
2
2
  /**
3
3
  * HTTP contract for Kody's CapabilityProxy (Open API `/v1`). Local execute
4
4
  * runs user code in workerd and forwards every `kody:runtime` call here with
@@ -6,11 +6,13 @@ import type { Dispatcher } from 'undici';
6
6
  * OAuth access token.
7
7
  *
8
8
  * - `GET /v1/capability-proxy/session` validates the token before workerd
9
- * starts. 200 → `{ scopes?: string[], expiresAt?: string }`.
10
- * - `POST /v1/capability-proxy/call` with `{ path, args, conversationId? }`
11
- * where `path` is the runtime property path (`['kody', 'emailSend']`,
12
- * `['kody', 'mcp', server, tool]`, `['workflows', 'create']`) and `args`
13
- * is the positional argument list. 200 → `{ result }`.
9
+ * starts. 200 → `{ scopes?: string[], expiresAt?: string, features?: string[] }`.
10
+ * - `POST /v1/capability-proxy/call` with
11
+ * `{ path, args, conversationId?, credentials? }` where `path` is the runtime
12
+ * property path (`['kody', 'emailSend']`, `['kody', 'mcp', server, tool]`,
13
+ * `['workflows', 'create']`) and `args` is the positional argument list.
14
+ * `credentials` is the ADR 0068 call map (CLI `--credential`); local code
15
+ * controls only `args`, so it cannot pick by name. 200 → `{ result }`.
14
16
  *
15
17
  * Errors use `{ error: { code, message } }` (a bare string is accepted too).
16
18
  * 401 means the token is expired/revoked (or MCP OAuth until the platform
@@ -22,38 +24,56 @@ export declare const capabilityProxyCallPath = "v1/capability-proxy/call";
22
24
  * Origin runs a placeholder `fetch` under a 5-minute deadline that starts only
23
25
  * after quota checks and placeholder fill, buffers the whole upstream body,
24
26
  * and sends headers once that body has ended. Node's global fetch gives up
25
- * after 300s without headers (undici `headersTimeout`), which would cut the
26
- * call before the gateway's own deadline fires, so CapabilityProxy requests
27
- * use a dedicated undici Agent that waits longer than the deadline plus
28
- * origin overhead.
27
+ * after 300s without headers and that limit cannot be raised without the
28
+ * undici package, so CapabilityProxy requests go through Node's own HTTP
29
+ * client (`node:http` / `node:https`) with an idle timeout that outlasts the
30
+ * deadline plus origin overhead.
29
31
  */
30
32
  export declare const capabilityProxyGatewayDeadlineMs: number;
31
33
  export declare const capabilityProxyHttpTimeoutMs: number;
34
+ /** Bound DNS / TCP / TLS before the idle timer (undici Agent default was 10s). */
35
+ export declare const capabilityProxyConnectTimeoutMs = 10000;
32
36
  /**
33
37
  * Node routes global fetch through `HTTP_PROXY` / `HTTPS_PROXY` / `NO_PROXY`
34
- * only when `NODE_USE_ENV_PROXY=1` or `--use-env-proxy` is set. A dispatcher
35
- * passed to fetch replaces that global proxy agent, so mirror the same opt-in.
38
+ * only when `NODE_USE_ENV_PROXY=1` or `--use-env-proxy` is set. The
39
+ * CapabilityProxy agents mirror the same opt-in through the Agent `proxyEnv`
40
+ * option.
36
41
  */
37
42
  export declare function nodeUsesEnvProxy(env?: NodeJS.ProcessEnv, execArgv?: ReadonlyArray<string>): boolean;
38
- export declare function createCapabilityProxyAgent(timeoutMs?: number, options?: {
43
+ export declare function nodeAgentHonorsEnvProxy(version?: string): boolean;
44
+ export type CapabilityProxyFetchOptions = {
45
+ /** Idle limit while waiting for headers or between body chunks. */
46
+ timeoutMs?: number;
47
+ /** Bound for DNS / TCP / TLS before the socket is ready. */
48
+ connectTimeoutMs?: number;
39
49
  useEnvProxy?: boolean;
40
- }): Promise<Dispatcher>;
50
+ };
51
+ /**
52
+ * fetch-shaped sender for CapabilityProxy built on `node:http(s)`: keep-alive
53
+ * across the session, package-graph and proxied calls, `timeoutMs` as the
54
+ * only idle limit, and `HTTP_PROXY` / `HTTPS_PROXY` / `NO_PROXY` when Node's
55
+ * env-proxy opt-in is set. Bodies are strings; responses are buffered.
56
+ */
57
+ export declare function createCapabilityProxyFetch(options?: CapabilityProxyFetchOptions): typeof fetch;
41
58
  export type CapabilityProxySession = {
42
59
  scopes: Array<string>;
43
60
  expiresAt: string | null;
61
+ /** Host features, e.g. `credential-call-map` for `--credential`. */
62
+ features: Array<string>;
44
63
  };
45
64
  export type CapabilityProxyCall = {
46
65
  path: Array<string>;
47
66
  args: Array<unknown>;
48
67
  conversationId?: string;
68
+ /** ADR 0068 call map; top-level only (never nested under `args`). */
69
+ credentials?: CredentialCallMapInput;
49
70
  };
50
71
  export type CapabilityProxyClientInput = {
51
72
  apiUrl: string;
52
73
  token: string;
74
+ /** Defaults to the shared `createCapabilityProxyFetch()` sender. */
53
75
  fetchFn?: typeof fetch;
54
76
  signal?: AbortSignal;
55
- /** Defaults to the shared Agent from `createCapabilityProxyAgent()`. */
56
- dispatcher?: Dispatcher;
57
77
  };
58
78
  export declare class CapabilityProxyError extends Error {
59
79
  readonly status: number | null;
@@ -68,3 +88,17 @@ export declare function assertTokenSafeApiUrl(apiUrl: string): void;
68
88
  export declare function capabilityProxyUrl(apiUrl: string, path: string): URL;
69
89
  export declare function openCapabilityProxySession(input: CapabilityProxyClientInput): Promise<CapabilityProxySession>;
70
90
  export declare function callCapabilityProxy(input: CapabilityProxyClientInput & CapabilityProxyCall): Promise<unknown>;
91
+ /**
92
+ * Preflight ADR 0068 call-map picks via `kody.credentialClientCheck` before
93
+ * local code runs. Throws on a structured check failure; returns warnings for
94
+ * ad hoc (non-strict) unknown keys.
95
+ */
96
+ export declare function checkCredentialCallMap(input: CapabilityProxyClientInput & {
97
+ credentials: CredentialCallMapInput;
98
+ conversationId?: string;
99
+ /** Invoke / package entry: unknown keys are errors. */
100
+ strict?: boolean;
101
+ packageId?: string;
102
+ }): Promise<{
103
+ warnings: Array<string>;
104
+ }>;
@@ -1,4 +1,5 @@
1
1
  import { apiTokenMintInstructions, cliBootstrapInstructions, featureDisabledMessage, insufficientScopeMessage, readInsufficientScopeDetails, isScopedApiToken, rejectedOauthBearerMessage, } from './api-token.js';
2
+ import { formatCredentialClientError, } from './credential-call-map.js';
2
3
  import { apiTokenEnvVar, cliName } from './defaults.js';
3
4
  import { describeNetworkError } from './network-error.js';
4
5
  import { readPackageVersion } from './package-info.js';
@@ -9,11 +10,13 @@ import { readPackageVersion } from './package-info.js';
9
10
  * OAuth access token.
10
11
  *
11
12
  * - `GET /v1/capability-proxy/session` validates the token before workerd
12
- * starts. 200 → `{ scopes?: string[], expiresAt?: string }`.
13
- * - `POST /v1/capability-proxy/call` with `{ path, args, conversationId? }`
14
- * where `path` is the runtime property path (`['kody', 'emailSend']`,
15
- * `['kody', 'mcp', server, tool]`, `['workflows', 'create']`) and `args`
16
- * is the positional argument list. 200 → `{ result }`.
13
+ * starts. 200 → `{ scopes?: string[], expiresAt?: string, features?: string[] }`.
14
+ * - `POST /v1/capability-proxy/call` with
15
+ * `{ path, args, conversationId?, credentials? }` where `path` is the runtime
16
+ * property path (`['kody', 'emailSend']`, `['kody', 'mcp', server, tool]`,
17
+ * `['workflows', 'create']`) and `args` is the positional argument list.
18
+ * `credentials` is the ADR 0068 call map (CLI `--credential`); local code
19
+ * controls only `args`, so it cannot pick by name. 200 → `{ result }`.
17
20
  *
18
21
  * Errors use `{ error: { code, message } }` (a bare string is accepted too).
19
22
  * 401 means the token is expired/revoked (or MCP OAuth until the platform
@@ -25,17 +28,20 @@ export const capabilityProxyCallPath = 'v1/capability-proxy/call';
25
28
  * Origin runs a placeholder `fetch` under a 5-minute deadline that starts only
26
29
  * after quota checks and placeholder fill, buffers the whole upstream body,
27
30
  * and sends headers once that body has ended. Node's global fetch gives up
28
- * after 300s without headers (undici `headersTimeout`), which would cut the
29
- * call before the gateway's own deadline fires, so CapabilityProxy requests
30
- * use a dedicated undici Agent that waits longer than the deadline plus
31
- * origin overhead.
31
+ * after 300s without headers and that limit cannot be raised without the
32
+ * undici package, so CapabilityProxy requests go through Node's own HTTP
33
+ * client (`node:http` / `node:https`) with an idle timeout that outlasts the
34
+ * deadline plus origin overhead.
32
35
  */
33
36
  export const capabilityProxyGatewayDeadlineMs = 5 * 60_000;
34
37
  export const capabilityProxyHttpTimeoutMs = 7 * 60_000;
38
+ /** Bound DNS / TCP / TLS before the idle timer (undici Agent default was 10s). */
39
+ export const capabilityProxyConnectTimeoutMs = 10_000;
35
40
  /**
36
41
  * Node routes global fetch through `HTTP_PROXY` / `HTTPS_PROXY` / `NO_PROXY`
37
- * only when `NODE_USE_ENV_PROXY=1` or `--use-env-proxy` is set. A dispatcher
38
- * passed to fetch replaces that global proxy agent, so mirror the same opt-in.
42
+ * only when `NODE_USE_ENV_PROXY=1` or `--use-env-proxy` is set. The
43
+ * CapabilityProxy agents mirror the same opt-in through the Agent `proxyEnv`
44
+ * option.
39
45
  */
40
46
  export function nodeUsesEnvProxy(env = process.env, execArgv = process.execArgv) {
41
47
  if (env.NODE_USE_ENV_PROXY === '1')
@@ -43,18 +49,148 @@ export function nodeUsesEnvProxy(env = process.env, execArgv = process.execArgv)
43
49
  const flags = [...execArgv, ...(env.NODE_OPTIONS ?? '').split(/\s+/)];
44
50
  return flags.includes('--use-env-proxy');
45
51
  }
46
- export async function createCapabilityProxyAgent(timeoutMs = capabilityProxyHttpTimeoutMs, options = {}) {
47
- // undici costs ~55ms to load, so only the commands that send a request pay for it.
48
- const { Agent, EnvHttpProxyAgent } = await import('undici');
49
- const timeouts = { headersTimeout: timeoutMs, bodyTimeout: timeoutMs };
50
- return (options.useEnvProxy ?? nodeUsesEnvProxy())
51
- ? new EnvHttpProxyAgent(timeouts)
52
- : new Agent(timeouts);
52
+ /** `http.Agent({ proxyEnv })` exists from these releases; older Node ignores the option. */
53
+ const envProxyAgentMinimumNode = { 22: 21, 24: 5 };
54
+ export function nodeAgentHonorsEnvProxy(version = process.versions.node) {
55
+ const [major = 0, minor = 0] = version.split('.').map(Number);
56
+ const minimumMinor = envProxyAgentMinimumNode[major];
57
+ if (minimumMinor === undefined)
58
+ return major > 24;
59
+ return minor >= minimumMinor;
53
60
  }
54
- let defaultCapabilityProxyAgent = null;
55
- function capabilityProxyAgent() {
56
- defaultCapabilityProxyAgent ??= createCapabilityProxyAgent();
57
- return defaultCapabilityProxyAgent;
61
+ /**
62
+ * fetch-shaped sender for CapabilityProxy built on `node:http(s)`: keep-alive
63
+ * across the session, package-graph and proxied calls, `timeoutMs` as the
64
+ * only idle limit, and `HTTP_PROXY` / `HTTPS_PROXY` / `NO_PROXY` when Node's
65
+ * env-proxy opt-in is set. Bodies are strings; responses are buffered.
66
+ */
67
+ export function createCapabilityProxyFetch(options = {}) {
68
+ const timeoutMs = options.timeoutMs ?? capabilityProxyHttpTimeoutMs;
69
+ const connectTimeoutMs = options.connectTimeoutMs ?? capabilityProxyConnectTimeoutMs;
70
+ const useEnvProxy = options.useEnvProxy ?? nodeUsesEnvProxy();
71
+ if (useEnvProxy && !nodeAgentHonorsEnvProxy()) {
72
+ throw new Error(`Node ${process.version} cannot route CapabilityProxy requests through HTTP_PROXY / HTTPS_PROXY: env-proxy support needs Node 22.21 or 24.5 and later. Upgrade Node or unset NODE_USE_ENV_PROXY / --use-env-proxy.`);
73
+ }
74
+ let transports = null;
75
+ return async (input, init = {}) => {
76
+ const url = input instanceof URL ? input : new URL(input instanceof Request ? input.url : input);
77
+ // node:http and node:https cost ~7ms to load, so only commands that send a request pay for it.
78
+ transports ??= loadTransports(useEnvProxy);
79
+ const transport = (await transports)[url.protocol];
80
+ if (!transport) {
81
+ throw new TypeError(`Unsupported protocol for the Kody API: ${url.protocol}`);
82
+ }
83
+ const body = init.body;
84
+ if (body !== undefined && body !== null && typeof body !== 'string') {
85
+ throw new TypeError('CapabilityProxy requests send string bodies.');
86
+ }
87
+ return new Promise((resolve, reject) => {
88
+ const request = transport.request(url, {
89
+ agent: transport.agent,
90
+ method: init.method ?? 'GET',
91
+ headers: Object.fromEntries(new Headers(init.headers)),
92
+ }, (response) => {
93
+ clearTimeout(connectTimer);
94
+ const chunks = [];
95
+ response.on('data', (chunk) => chunks.push(chunk));
96
+ response.on('error', reject);
97
+ response.on('end', () => resolve(toResponse(response, Buffer.concat(chunks))));
98
+ });
99
+ // request.setTimeout only arms after the socket is connected; bound DNS/TCP/TLS separately.
100
+ const connectTimer = setTimeout(() => {
101
+ request.destroy(new Error(`Kody API did not connect within ${connectTimeoutMs}ms (${url.pathname}).`));
102
+ }, connectTimeoutMs);
103
+ request.on('socket', (socket) => {
104
+ const clearConnectTimer = () => clearTimeout(connectTimer);
105
+ if (url.protocol === 'https:') {
106
+ // `encrypted` is always true on TLSSocket; secureConnecting is the
107
+ // handshake flag (not always in @types/node). Keep-alive reuse skips
108
+ // secureConnect.
109
+ if (tlsHandshakePending(socket) === false) {
110
+ clearConnectTimer();
111
+ return;
112
+ }
113
+ socket.once('secureConnect', clearConnectTimer);
114
+ return;
115
+ }
116
+ if (!socket.connecting) {
117
+ clearConnectTimer();
118
+ return;
119
+ }
120
+ socket.once('connect', clearConnectTimer);
121
+ });
122
+ request.setTimeout(timeoutMs, () => request.destroy(new Error(`Kody API sent nothing for ${timeoutMs}ms (${url.pathname}).`)));
123
+ request.on('error', (error) => {
124
+ clearTimeout(connectTimer);
125
+ reject(error);
126
+ });
127
+ const { signal } = init;
128
+ if (signal) {
129
+ const abort = () => {
130
+ clearTimeout(connectTimer);
131
+ request.destroy(abortError(signal.reason));
132
+ };
133
+ if (signal.aborted) {
134
+ abort();
135
+ }
136
+ else {
137
+ signal.addEventListener('abort', abort, { once: true });
138
+ request.once('close', () => signal.removeEventListener('abort', abort));
139
+ }
140
+ }
141
+ request.end(body ?? undefined);
142
+ });
143
+ };
144
+ }
145
+ async function loadTransports(useEnvProxy) {
146
+ const [http, https] = await Promise.all([import('node:http'), import('node:https')]);
147
+ const agentOptions = { keepAlive: true, ...(useEnvProxy ? { proxyEnv: process.env } : {}) };
148
+ return {
149
+ 'http:': { agent: unrefFreeSockets(new http.Agent(agentOptions)), request: http.request },
150
+ 'https:': { agent: unrefFreeSockets(new https.Agent(agentOptions)), request: https.request },
151
+ };
152
+ }
153
+ /** Keep-alive free sockets must not pin the event loop after the last request. */
154
+ function unrefFreeSockets(agent) {
155
+ agent.on('free', (socket) => {
156
+ socket.unref();
157
+ });
158
+ return agent;
159
+ }
160
+ /** `true` while TLS handshake is in progress; `false` once established; else unknown. */
161
+ function tlsHandshakePending(socket) {
162
+ if (!('secureConnecting' in socket))
163
+ return null;
164
+ return socket.secureConnecting;
165
+ }
166
+ function abortError(reason) {
167
+ if (reason instanceof Error)
168
+ return reason;
169
+ return new DOMException(typeof reason === 'string' ? reason : 'This operation was aborted', 'AbortError');
170
+ }
171
+ function toResponse(response, body) {
172
+ const headers = new Headers();
173
+ for (const [name, value] of Object.entries(response.headers)) {
174
+ if (Array.isArray(value)) {
175
+ for (const entry of value)
176
+ headers.append(name, entry);
177
+ }
178
+ else if (value !== undefined) {
179
+ headers.set(name, value);
180
+ }
181
+ }
182
+ const status = response.statusCode ?? 0;
183
+ const bodyless = status === 204 || status === 205 || status === 304;
184
+ return new Response(bodyless ? null : body, {
185
+ status,
186
+ statusText: response.statusMessage ?? '',
187
+ headers,
188
+ });
189
+ }
190
+ let defaultCapabilityProxyFetch = null;
191
+ function capabilityProxyFetch() {
192
+ defaultCapabilityProxyFetch ??= createCapabilityProxyFetch();
193
+ return defaultCapabilityProxyFetch;
58
194
  }
59
195
  export class CapabilityProxyError extends Error {
60
196
  status;
@@ -99,6 +235,9 @@ export async function openCapabilityProxySession(input) {
99
235
  ? record.scopes.filter((scope) => typeof scope === 'string')
100
236
  : [],
101
237
  expiresAt: typeof record.expiresAt === 'string' ? record.expiresAt : null,
238
+ features: Array.isArray(record.features)
239
+ ? record.features.filter((feature) => typeof feature === 'string')
240
+ : [],
102
241
  };
103
242
  }
104
243
  export async function callCapabilityProxy(input) {
@@ -106,6 +245,8 @@ export async function callCapabilityProxy(input) {
106
245
  const payload = { path: input.path, args: input.args };
107
246
  if (input.conversationId !== undefined)
108
247
  payload.conversationId = input.conversationId;
248
+ if (input.credentials !== undefined)
249
+ payload.credentials = input.credentials;
109
250
  const response = await send(input, url, {
110
251
  method: 'POST',
111
252
  headers: { 'content-type': 'application/json' },
@@ -121,14 +262,46 @@ export async function callCapabilityProxy(input) {
121
262
  }
122
263
  return isRecord(body) ? body.result : undefined;
123
264
  }
265
+ /**
266
+ * Preflight ADR 0068 call-map picks via `kody.credentialClientCheck` before
267
+ * local code runs. Throws on a structured check failure; returns warnings for
268
+ * ad hoc (non-strict) unknown keys.
269
+ */
270
+ export async function checkCredentialCallMap(input) {
271
+ const args = {};
272
+ if (input.strict === true)
273
+ args.strict = true;
274
+ if (input.packageId !== undefined)
275
+ args.packageId = input.packageId;
276
+ const result = await callCapabilityProxy({
277
+ apiUrl: input.apiUrl,
278
+ token: input.token,
279
+ fetchFn: input.fetchFn,
280
+ signal: input.signal,
281
+ path: ['kody', 'credentialClientCheck'],
282
+ args: [args],
283
+ conversationId: input.conversationId,
284
+ credentials: input.credentials,
285
+ });
286
+ if (!isRecord(result)) {
287
+ throw new CapabilityProxyError('credentialClientCheck returned an unexpected result.');
288
+ }
289
+ if (result.ok === false) {
290
+ const error = isRecord(result.error) ? result.error : {};
291
+ const code = typeof error.code === 'string' ? error.code : 'credential_error';
292
+ throw new CapabilityProxyError(formatCredentialClientError(error), { code });
293
+ }
294
+ const value = isRecord(result.value) ? result.value : null;
295
+ const warnings = Array.isArray(value?.warnings)
296
+ ? value.warnings.filter((warning) => typeof warning === 'string')
297
+ : [];
298
+ return { warnings };
299
+ }
124
300
  async function send(input, url, init) {
125
- const fetchFn = input.fetchFn ?? fetch;
126
- // Global fetch on Node 22+ (bundled undici 6–8) accepts undici 7 dispatchers.
127
- const dispatcherInit = { dispatcher: input.dispatcher ?? (await capabilityProxyAgent()) };
301
+ const fetchFn = input.fetchFn ?? capabilityProxyFetch();
128
302
  try {
129
303
  return await fetchFn(url, {
130
304
  ...init,
131
- ...dispatcherInit,
132
305
  signal: input.signal,
133
306
  headers: {
134
307
  ...init.headers,
@@ -1 +1 @@
1
- {"version":3,"file":"capability-proxy.js","sourceRoot":"","sources":["../src/capability-proxy.ts"],"names":[],"mappings":"AACA,OAAO,EACN,wBAAwB,EACxB,wBAAwB,EACxB,sBAAsB,EACtB,wBAAwB,EACxB,4BAA4B,EAC5B,gBAAgB,EAChB,0BAA0B,GAC1B,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAEtD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,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AAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC/B,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAC5E,CAAC"}
package/dist/cli.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { resolveScopedApiToken } from './api-token.js';
2
+ import { type CredentialCallMapInput } from './credential-call-map.js';
2
3
  export { readApiToken, requireApiToken as resolveApiToken, resolveScopedApiToken, } from './api-token.js';
3
4
  export { resolveLocalExecuteBearer } from './local-execute-auth.js';
4
5
  export { authBootstrap, authBootstrapWithScopes, bootstrapRedeemRequestBody, cliTokenLifetimeAliases, cliTokenLifetimeMissingError, cliTokenLifetimePolicy, parseCliLifetimeSecondsFlag, parseCliScopesFlag, redeemBootstrapCode, resolveCliTokenLifetime, } from './auth-bootstrap.js';
@@ -24,6 +25,7 @@ declare function parseKnown(args: Array<string>): {
24
25
  'conversation-id'?: string | boolean | undefined;
25
26
  local?: string | boolean | undefined;
26
27
  'allow-private-network'?: string | boolean | undefined;
28
+ credential?: (string | boolean)[] | undefined;
27
29
  token?: string | boolean | undefined;
28
30
  'api-url'?: string | boolean | undefined;
29
31
  lifetime?: string | boolean | undefined;
@@ -63,6 +65,7 @@ export declare function buildExecuteToolArgs(input: {
63
65
  code?: string;
64
66
  paramsJson?: string;
65
67
  conversationId?: string;
68
+ credentials?: CredentialCallMapInput;
66
69
  }): Record<string, unknown>;
67
70
  /** Parse `--params` JSON for `kody api` (flat object, same as MCP `api`). */
68
71
  export declare function parseApiParamsJson(paramsJson?: string): Record<string, unknown>;
package/dist/cli.js CHANGED
@@ -3,6 +3,7 @@ import { readFile } from 'node:fs/promises';
3
3
  import { cliBootstrapMintCall, hasExplicitTokenFlag, requireApiToken, resolveScopedApiToken, } from './api-token.js';
4
4
  import { deleteStoredApiToken, loadStoredApiToken, } from './api-token-store.js';
5
5
  import { authBootstrap, authBootstrapWithScopes, bootstrapMintLifetimeFields, cliCredentialBootstrapOperationId, parseCliLifetimeSecondsFlag, parseCliScopesFlag, resolveCliTokenLifetime, } from './auth-bootstrap.js';
6
+ import { parseCredentialFlags, } from './credential-call-map.js';
6
7
  import { defaultApiUrl, defaultMcpUrl, modernMcpProtocolVersion } from './defaults.js';
7
8
  import { usage } from './help.js';
8
9
  import { deleteCredentials, loadCredentials } from './store.js';
@@ -40,6 +41,7 @@ function parseKnown(args) {
40
41
  'conversation-id': { type: 'string' },
41
42
  local: { type: 'boolean' },
42
43
  'allow-private-network': { type: 'boolean' },
44
+ credential: { type: 'string', multiple: true },
43
45
  token: { type: 'string' },
44
46
  'api-url': { type: 'string' },
45
47
  lifetime: { type: 'string' },
@@ -386,6 +388,11 @@ async function dispatch(parsed, write, writeErr) {
386
388
  : fileArg === '-'
387
389
  ? await readStdin()
388
390
  : positionalModule || undefined;
391
+ const credentials = parseCredentialFlags(Array.isArray(parsed.values.credential)
392
+ ? parsed.values.credential.filter((value) => typeof value === 'string')
393
+ : typeof parsed.values.credential === 'string'
394
+ ? [parsed.values.credential]
395
+ : undefined);
389
396
  const args = buildExecuteToolArgs({
390
397
  invoke,
391
398
  code: typeof code === 'string' ? code : undefined,
@@ -393,6 +400,7 @@ async function dispatch(parsed, write, writeErr) {
393
400
  conversationId: typeof parsed.values['conversation-id'] === 'string'
394
401
  ? parsed.values['conversation-id']
395
402
  : undefined,
403
+ credentials,
396
404
  });
397
405
  const apiUrl = apiUrlFrom({
398
406
  apiUrl: typeof parsed.values['api-url'] === 'string'
@@ -412,6 +420,7 @@ async function dispatch(parsed, write, writeErr) {
412
420
  ...(modulePath !== undefined ? { modulePath } : {}),
413
421
  params: args.params,
414
422
  conversationId: args.conversationId,
423
+ ...(credentials !== undefined ? { credentials } : {}),
415
424
  token: await resolveLocalExecuteBearer({
416
425
  tokenValues,
417
426
  mcpUrl,
@@ -428,6 +437,7 @@ async function dispatch(parsed, write, writeErr) {
428
437
  invoke,
429
438
  params: args.params,
430
439
  conversationId: args.conversationId,
440
+ ...(credentials !== undefined ? { credentials } : {}),
431
441
  token: requireApiToken(tokenValues, process.env, 'execute with an API token', { apiUrl }),
432
442
  apiUrl,
433
443
  })
@@ -525,6 +535,9 @@ function attachExecuteCommonArgs(args, input) {
525
535
  if (input.conversationId !== undefined) {
526
536
  args.conversationId = input.conversationId;
527
537
  }
538
+ if (input.credentials !== undefined) {
539
+ args.credentials = input.credentials;
540
+ }
528
541
  return args;
529
542
  }
530
543
  /**