@kodycodes/cli 1.3.0 → 1.5.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 (40) hide show
  1. package/README.md +67 -3
  2. package/dist/api-token.d.ts +14 -0
  3. package/dist/api-token.js +21 -0
  4. package/dist/api-token.js.map +1 -0
  5. package/dist/auth.js +2 -2
  6. package/dist/auth.js.map +1 -1
  7. package/dist/capability-proxy.d.ts +46 -0
  8. package/dist/capability-proxy.js +151 -0
  9. package/dist/capability-proxy.js.map +1 -0
  10. package/dist/cli.d.ts +23 -1
  11. package/dist/cli.js +117 -4
  12. package/dist/cli.js.map +1 -1
  13. package/dist/defaults.d.ts +3 -0
  14. package/dist/defaults.js +3 -0
  15. package/dist/defaults.js.map +1 -1
  16. package/dist/help.js +20 -4
  17. package/dist/help.js.map +1 -1
  18. package/dist/invoke-passthrough.d.ts +8 -0
  19. package/dist/invoke-passthrough.js +46 -0
  20. package/dist/invoke-passthrough.js.map +1 -0
  21. package/dist/local-execute.d.ts +28 -0
  22. package/dist/local-execute.js +286 -0
  23. package/dist/local-execute.js.map +1 -0
  24. package/dist/local-runtime-source.d.ts +32 -0
  25. package/dist/local-runtime-source.js +199 -0
  26. package/dist/local-runtime-source.js.map +1 -0
  27. package/dist/network-error.d.ts +2 -0
  28. package/dist/network-error.js +11 -0
  29. package/dist/network-error.js.map +1 -0
  30. package/dist/open-api-client.d.ts +40 -0
  31. package/dist/open-api-client.js +152 -0
  32. package/dist/open-api-client.js.map +1 -0
  33. package/dist/remote-execute.d.ts +28 -0
  34. package/dist/remote-execute.js +99 -0
  35. package/dist/remote-execute.js.map +1 -0
  36. package/dist/workerd-binary.d.ts +31 -0
  37. package/dist/workerd-binary.js +98 -0
  38. package/dist/workerd-binary.js.map +1 -0
  39. package/package.json +1 -1
  40. package/skills/kody/SKILL.md +11 -0
@@ -0,0 +1,199 @@
1
+ /**
2
+ * Sources for the workerd process behind `execute --local`. User code sees the
3
+ * same `kody:runtime` surface as ad hoc cloud execute; every call becomes a
4
+ * `{ path, args }` hop to the CLI's loopback bridge, which adds the API token
5
+ * and forwards it to CapabilityProxy. The token never enters workerd.
6
+ */
7
+ export const localExecuteCompatibilityDate = '2026-04-16';
8
+ export const localExecuteCompatibilityFlags = ['nodejs_compat'];
9
+ export const localWorkerModuleNames = {
10
+ entry: '__kody_local_entry.js',
11
+ user: 'main.js',
12
+ runtime: 'kody:runtime',
13
+ };
14
+ /** Header carrying the per-run secret on workerd → bridge and CLI → workerd hops. */
15
+ export const runSecretHeader = 'x-kody-run-secret';
16
+ export const runSecretEnvVar = 'KODY_RUN_SECRET';
17
+ export function createLocalRuntimeModuleSource() {
18
+ return `
19
+ let __kodyBridge = null;
20
+
21
+ export function __kodyInstallLocalBridge(bridge) {
22
+ __kodyBridge = bridge;
23
+ }
24
+
25
+ function __kodyCall(path, args) {
26
+ if (__kodyBridge === null) {
27
+ throw new Error('kody:runtime is only available while an execute --local run is in progress.');
28
+ }
29
+ return __kodyBridge(path, args);
30
+ }
31
+
32
+ function __kodyNamespace(path) {
33
+ const label = '[KodyRuntime:' + path.join('.') + ']';
34
+ return new Proxy(function () {}, {
35
+ get(_target, property) {
36
+ if (typeof property === 'symbol' || property === 'then' || property === 'toJSON') {
37
+ return undefined;
38
+ }
39
+ if (property === 'toString' || property === 'inspect') return () => label;
40
+ return __kodyNamespace([...path, property]);
41
+ },
42
+ apply(_target, _thisArg, args) {
43
+ return __kodyCall(path, args);
44
+ },
45
+ });
46
+ }
47
+
48
+ export const kody = __kodyNamespace(['kody']);
49
+
50
+ export const workflows = {
51
+ create: async (input) => await __kodyCall(['workflows', 'create'], [input ?? {}]),
52
+ };
53
+
54
+ export const packages = {
55
+ invoke: async (specifier, options) => {
56
+ if (typeof specifier !== 'string') {
57
+ throw new Error(
58
+ 'Object-only packages.invoke was removed. Use a static import (import fn from "kody:@owner/package/export") when the name is known, or import(specifier) when the name is data.',
59
+ );
60
+ }
61
+ return await __kodyCall(['packages', 'invoke'], [specifier, options ?? {}]);
62
+ },
63
+ };
64
+
65
+ export function packageStorage() {
66
+ throw new Error(
67
+ 'packageStorage() requires package provenance: this module was not bundled from a saved package and the run has no package context. ' +
68
+ 'Ad hoc execute has no scratch SQLite helper. Persist durable state from a saved package with packageStorage().',
69
+ );
70
+ }
71
+
72
+ function __kodyPackageSecretsUnavailable() {
73
+ throw new Error(
74
+ 'packageSecrets is not available in this execution context. It is bound for stamped saved-package modules and saved-package runtime contexts.',
75
+ );
76
+ }
77
+
78
+ export const packageSecrets = {
79
+ get: async () => __kodyPackageSecretsUnavailable(),
80
+ has: async () => __kodyPackageSecretsUnavailable(),
81
+ };
82
+ export const packageContext = Object.freeze({});
83
+ export const email = null;
84
+ export const events = null;
85
+ export const createAuthenticatedFetch = undefined;
86
+ export const secretHeaders = undefined;
87
+ export const oauthClientCredentials = undefined;
88
+
89
+ const __kodyRuntimeDefault = Object.freeze({
90
+ kody,
91
+ packageStorage,
92
+ createAuthenticatedFetch,
93
+ secretHeaders,
94
+ oauthClientCredentials,
95
+ packageContext,
96
+ packageSecrets,
97
+ email,
98
+ workflows,
99
+ packages,
100
+ events,
101
+ });
102
+ export default __kodyRuntimeDefault;
103
+ export const KodyRuntime = Object.freeze({ defaultValue: __kodyRuntimeDefault });
104
+ `.trimStart();
105
+ }
106
+ export function createLocalEntrySource() {
107
+ return `
108
+ import { __kodyInstallLocalBridge } from ${JSON.stringify(localWorkerModuleNames.runtime)};
109
+
110
+ const __kodyRunSecretHeader = ${JSON.stringify(runSecretHeader)};
111
+ let __kodyClaimed = false;
112
+
113
+ function __kodyFormatLogArgs(args) {
114
+ return args.map(String).join(' ');
115
+ }
116
+
117
+ export default {
118
+ async fetch(request, env) {
119
+ const secret = env.${runSecretEnvVar};
120
+ if (__kodyClaimed || !secret || request.headers.get(__kodyRunSecretHeader) !== secret) {
121
+ return new Response('Forbidden', { status: 403 });
122
+ }
123
+ __kodyClaimed = true;
124
+ const { params } = await request.json();
125
+ __kodyInstallLocalBridge(async (path, args) => {
126
+ const response = await env.KODY_BRIDGE.fetch('http://kody-bridge/call', {
127
+ method: 'POST',
128
+ headers: { 'content-type': 'application/json', [__kodyRunSecretHeader]: secret },
129
+ body: JSON.stringify({ path, args }),
130
+ });
131
+ const data = await response.json();
132
+ if (data.error) throw new Error(data.error);
133
+ return data.result;
134
+ });
135
+ const logs = [];
136
+ const nativeConsole = globalThis.console;
137
+ globalThis.console = {
138
+ ...nativeConsole,
139
+ log: (...a) => { logs.push(__kodyFormatLogArgs(a)); },
140
+ info: (...a) => { logs.push('[info] ' + __kodyFormatLogArgs(a)); },
141
+ debug: (...a) => { logs.push('[debug] ' + __kodyFormatLogArgs(a)); },
142
+ warn: (...a) => { logs.push('[warn] ' + __kodyFormatLogArgs(a)); },
143
+ error: (...a) => { logs.push('[error] ' + __kodyFormatLogArgs(a)); },
144
+ };
145
+ try {
146
+ const module = await import(${JSON.stringify(`./${localWorkerModuleNames.user}`)});
147
+ if (typeof module?.default !== 'function') {
148
+ throw new Error('Kody execute modules must default export a function.');
149
+ }
150
+ const result = await module.default(params);
151
+ return new Response(JSON.stringify({ result, logs }), {
152
+ headers: { 'content-type': 'application/json' },
153
+ });
154
+ } catch (error) {
155
+ const message = error instanceof Error ? error.message : String(error);
156
+ return Response.json({ error: message, logs });
157
+ } finally {
158
+ globalThis.console = nativeConsole;
159
+ }
160
+ },
161
+ };
162
+ `.trimStart();
163
+ }
164
+ /**
165
+ * workerd text config. `files` are embedded relative to the config file.
166
+ * Outbound fetch reaches public and private networks: local execute runs as
167
+ * the user on their own machine, and reaching local services is part of why
168
+ * one would run locally.
169
+ */
170
+ export function createWorkerdConfig(input) {
171
+ const flags = localExecuteCompatibilityFlags.map((flag) => JSON.stringify(flag)).join(', ');
172
+ return `using Workerd = import "/workerd/workerd.capnp";
173
+
174
+ const config :Workerd.Config = (
175
+ services = [
176
+ (name = "main", worker = .kodyWorker),
177
+ (name = "kody-bridge", external = (address = "127.0.0.1:${input.bridgePort}", http = ())),
178
+ (name = "internet", network = (allow = ["public", "private", "local"], tlsOptions = (trustBrowserCas = true))),
179
+ ],
180
+ sockets = [ (name = "http", address = "127.0.0.1:0", http = (), service = "main") ],
181
+ );
182
+
183
+ const kodyWorker :Workerd.Worker = (
184
+ modules = [
185
+ (name = ${JSON.stringify(localWorkerModuleNames.entry)}, esModule = embed ${JSON.stringify(input.files.entry)}),
186
+ (name = ${JSON.stringify(localWorkerModuleNames.user)}, esModule = embed ${JSON.stringify(input.files.user)}),
187
+ (name = ${JSON.stringify(localWorkerModuleNames.runtime)}, esModule = embed ${JSON.stringify(input.files.runtime)}),
188
+ ],
189
+ compatibilityDate = ${JSON.stringify(localExecuteCompatibilityDate)},
190
+ compatibilityFlags = [${flags}],
191
+ globalOutbound = "internet",
192
+ bindings = [
193
+ (name = "KODY_BRIDGE", service = "kody-bridge"),
194
+ (name = ${JSON.stringify(runSecretEnvVar)}, fromEnvironment = ${JSON.stringify(runSecretEnvVar)}),
195
+ ],
196
+ );
197
+ `;
198
+ }
199
+ //# sourceMappingURL=local-runtime-source.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local-runtime-source.js","sourceRoot":"","sources":["../src/local-runtime-source.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,6BAA6B,GAAG,YAAY,CAAA;AACzD,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,eAAe,CAAU,CAAA;AAExE,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACrC,KAAK,EAAE,uBAAuB;IAC9B,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,cAAc;CACd,CAAA;AAEV,qFAAqF;AACrF,MAAM,CAAC,MAAM,eAAe,GAAG,mBAAmB,CAAA;AAClD,MAAM,CAAC,MAAM,eAAe,GAAG,iBAAiB,CAAA;AAEhD,MAAM,UAAU,8BAA8B;IAC7C,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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A;AACD,CAAC"}
@@ -0,0 +1,2 @@
1
+ /** `fetch failed` alone hides why; undici puts ECONNREFUSED / ENOTFOUND on `cause.code`. */
2
+ export declare function describeNetworkError(error: unknown): string;
@@ -0,0 +1,11 @@
1
+ /** `fetch failed` alone hides why; undici puts ECONNREFUSED / ENOTFOUND on `cause.code`. */
2
+ export function describeNetworkError(error) {
3
+ if (!(error instanceof Error))
4
+ return String(error);
5
+ const cause = error.cause;
6
+ const causeCode = cause && typeof cause === 'object' && 'code' in cause && typeof cause.code === 'string'
7
+ ? cause.code
8
+ : null;
9
+ return causeCode ? `${error.message}: ${causeCode}` : error.message;
10
+ }
11
+ //# sourceMappingURL=network-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network-error.js","sourceRoot":"","sources":["../src/network-error.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,MAAM,UAAU,oBAAoB,CAAC,KAAc;IAClD,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAA;IACnD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAA;IACzB,MAAM,SAAS,GACd,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;QACtF,CAAC,CAAC,KAAK,CAAC,IAAI;QACZ,CAAC,CAAC,IAAI,CAAA;IACR,OAAO,SAAS,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAA;AACpE,CAAC"}
@@ -0,0 +1,40 @@
1
+ import type { ToolCallResult } from './mcp.js';
2
+ export type OpenApiClientInput = {
3
+ apiUrl?: string;
4
+ token: string;
5
+ fetchFn?: typeof fetch;
6
+ };
7
+ export declare class OpenApiError extends Error {
8
+ readonly status: number | null;
9
+ readonly code: string | null;
10
+ constructor(message: string, options?: {
11
+ status?: number | null;
12
+ code?: string | null;
13
+ });
14
+ }
15
+ export declare function openApiGet(input: OpenApiClientInput & {
16
+ path: string;
17
+ query?: Record<string, string | number | undefined>;
18
+ }): Promise<unknown>;
19
+ export declare function searchWithApiToken(input: OpenApiClientInput & {
20
+ query?: string;
21
+ domain?: string;
22
+ limit?: number;
23
+ entity?: string;
24
+ }): Promise<ToolCallResult>;
25
+ export declare function whoamiWithApiToken(input: OpenApiClientInput): Promise<{
26
+ mcpUrl?: undefined;
27
+ apiUrl: string;
28
+ token: {
29
+ id: string;
30
+ name: string | null;
31
+ scopes: Array<string>;
32
+ expiresAt: string | null;
33
+ maxExpiresAt: string | null;
34
+ };
35
+ user: {
36
+ userId: string;
37
+ email: string;
38
+ displayName: string;
39
+ } | null;
40
+ }>;
@@ -0,0 +1,152 @@
1
+ import { apiTokenEnvVar, cliName, defaultApiUrl } from './defaults.js';
2
+ import { assertTokenSafeApiUrl, capabilityProxyUrl } from './capability-proxy.js';
3
+ import { describeNetworkError } from './network-error.js';
4
+ import { readPackageVersion } from './package-info.js';
5
+ export class OpenApiError extends Error {
6
+ status;
7
+ code;
8
+ constructor(message, options = {}) {
9
+ super(message);
10
+ this.name = 'OpenApiError';
11
+ this.status = options.status ?? null;
12
+ this.code = options.code ?? null;
13
+ }
14
+ }
15
+ export async function openApiGet(input) {
16
+ const apiUrl = input.apiUrl || defaultApiUrl;
17
+ assertTokenSafeApiUrl(apiUrl);
18
+ const url = capabilityProxyUrl(apiUrl, input.path);
19
+ if (input.query) {
20
+ for (const [key, value] of Object.entries(input.query)) {
21
+ if (value === undefined || value === '')
22
+ continue;
23
+ url.searchParams.set(key, String(value));
24
+ }
25
+ }
26
+ const fetchFn = input.fetchFn ?? fetch;
27
+ let response;
28
+ try {
29
+ response = await fetchFn(url, {
30
+ method: 'GET',
31
+ headers: {
32
+ accept: 'application/json',
33
+ authorization: `Bearer ${input.token}`,
34
+ 'user-agent': `${cliName}/${readPackageVersion()}`,
35
+ },
36
+ });
37
+ }
38
+ catch (error) {
39
+ const reason = describeNetworkError(error);
40
+ throw new OpenApiError(`Could not reach the Kody API at ${url.origin} (${reason}). Check --api-url / KODY_API_URL and your network.`);
41
+ }
42
+ const body = await readJson(response);
43
+ if (!response.ok) {
44
+ throw describeOpenApiFailure(response.status, body, url);
45
+ }
46
+ return body;
47
+ }
48
+ export async function searchWithApiToken(input) {
49
+ if (input.entity) {
50
+ throw new OpenApiError(`Open API search does not support --entity yet. Run \`kody login\` and use MCP search, or omit --entity.`, { status: null, code: 'unsupported' });
51
+ }
52
+ const body = await openApiGet({
53
+ ...input,
54
+ path: 'v1/search',
55
+ query: {
56
+ query: input.query,
57
+ domain: input.domain,
58
+ limit: input.limit,
59
+ },
60
+ });
61
+ const text = JSON.stringify(body, null, 2);
62
+ return {
63
+ content: [{ type: 'text', text }],
64
+ structuredContent: body,
65
+ isError: false,
66
+ };
67
+ }
68
+ export async function whoamiWithApiToken(input) {
69
+ const apiUrl = input.apiUrl || defaultApiUrl;
70
+ const current = (await openApiGet({
71
+ ...input,
72
+ apiUrl,
73
+ path: 'v1/tokens/current',
74
+ }));
75
+ let user = null;
76
+ try {
77
+ const me = (await openApiGet({
78
+ ...input,
79
+ apiUrl,
80
+ path: 'v1/me',
81
+ }));
82
+ user = {
83
+ userId: String(me.user_id ?? ''),
84
+ email: String(me.email ?? ''),
85
+ displayName: String(me.display_name ?? ''),
86
+ };
87
+ }
88
+ catch (error) {
89
+ // account:read is optional; tokens/current needs no scope.
90
+ if (!(error instanceof OpenApiError && error.status === 403))
91
+ throw error;
92
+ }
93
+ return {
94
+ apiUrl,
95
+ token: {
96
+ id: String(current.id ?? ''),
97
+ name: typeof current.name === 'string' ? current.name : null,
98
+ scopes: Array.isArray(current.scopes)
99
+ ? current.scopes.filter((scope) => typeof scope === 'string')
100
+ : [],
101
+ expiresAt: typeof current.expires_at === 'string' ? current.expires_at : null,
102
+ maxExpiresAt: typeof current.max_expires_at === 'string' ? current.max_expires_at : null,
103
+ },
104
+ user,
105
+ };
106
+ }
107
+ async function readJson(response) {
108
+ const text = await response.text();
109
+ if (!text)
110
+ return null;
111
+ try {
112
+ return JSON.parse(text);
113
+ }
114
+ catch {
115
+ return text;
116
+ }
117
+ }
118
+ function readErrorBody(body) {
119
+ if (!isRecord(body) || body.error == null)
120
+ return null;
121
+ const { error } = body;
122
+ if (typeof error === 'string')
123
+ return { code: null, message: error };
124
+ if (isRecord(error)) {
125
+ const code = typeof error.code === 'string' ? error.code : null;
126
+ const message = typeof error.message === 'string' ? error.message : code ?? JSON.stringify(error);
127
+ return { code, message };
128
+ }
129
+ return { code: null, message: String(error) };
130
+ }
131
+ function describeOpenApiFailure(status, body, url) {
132
+ const failure = readErrorBody(body);
133
+ const code = failure?.code ?? null;
134
+ const detail = failure?.message ? ` Server said: ${failure.message}` : '';
135
+ if (status === 401) {
136
+ return new OpenApiError(`Kody rejected the API token (expired, revoked, or malformed). Mint a fresh scoped token and pass it with --token or ${apiTokenEnvVar}.${detail}`, { status, code });
137
+ }
138
+ if (status === 403 && code === 'insufficient_scope') {
139
+ const required = isRecord(body) && isRecord(body.error) && isRecord(body.error.details)
140
+ ? body.error.details.required_scope
141
+ : null;
142
+ const scopeHint = typeof required === 'string'
143
+ ? ` Mint a token that includes "${required}".`
144
+ : ' Mint a token with the required scope.';
145
+ return new OpenApiError(`The API token is missing a required scope.${scopeHint}${detail}`, { status, code });
146
+ }
147
+ return new OpenApiError(failure?.message ?? `Kody API request failed with HTTP ${status} (${url.pathname}).`, { status, code });
148
+ }
149
+ function isRecord(value) {
150
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
151
+ }
152
+ //# sourceMappingURL=open-api-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"open-api-client.js","sourceRoot":"","sources":["../src/open-api-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AACtE,OAAO,EAAE,qBA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AChB,CAAA;IACF,CAAC;IACD,OAAO,IAAI,YAAY,CACtB,OAAO,EAAE,OAAO,IAAI,qCAAqC,MAAM,KAAK,GAAG,CAAC,QAAQ,IAAI,EACpF,EAAE,MAAM,EAAE,IAAI,EAAE,CAChB,CAAA;AACF,CAAC;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"}
@@ -0,0 +1,28 @@
1
+ import type { ToolCallResult } from './mcp.js';
2
+ export type RemoteExecuteInput = {
3
+ code?: string;
4
+ invoke?: string;
5
+ params?: unknown;
6
+ conversationId?: string;
7
+ token: string;
8
+ apiUrl: string;
9
+ fetchFn?: typeof fetch;
10
+ };
11
+ /**
12
+ * Cloud (non-`--local`) execute authenticated only with a scoped API token:
13
+ * CapabilityProxy session + `kody.execute`. The module runs in Kody's cloud
14
+ * sandbox; no `kody login` and no local workerd.
15
+ *
16
+ * Requires the `local-execute` feature flag and token scope (same as
17
+ * `execute --local`).
18
+ */
19
+ export declare function runRemoteExecuteWithToken(input: RemoteExecuteInput): Promise<ToolCallResult>;
20
+ export declare function resolveRemoteExecuteCode(input: {
21
+ code?: string;
22
+ invoke?: string;
23
+ }): string;
24
+ /**
25
+ * Map `kody.execute` capability output (returned as CapabilityProxy `result`)
26
+ * into the same ToolCallResult envelope MCP execute / local execute use.
27
+ */
28
+ export declare function formatExecuteCapabilityResult(payload: unknown): ToolCallResult;
@@ -0,0 +1,99 @@
1
+ import { assertTokenSafeApiUrl, callCapabilityProxy, openCapabilityProxySession, } from './capability-proxy.js';
2
+ import { resolveExecuteInvokeCode } from './invoke-passthrough.js';
3
+ /**
4
+ * Cloud (non-`--local`) execute authenticated only with a scoped API token:
5
+ * CapabilityProxy session + `kody.execute`. The module runs in Kody's cloud
6
+ * sandbox; no `kody login` and no local workerd.
7
+ *
8
+ * Requires the `local-execute` feature flag and token scope (same as
9
+ * `execute --local`).
10
+ */
11
+ export async function runRemoteExecuteWithToken(input) {
12
+ assertTokenSafeApiUrl(input.apiUrl);
13
+ const code = resolveRemoteExecuteCode(input);
14
+ const client = { apiUrl: input.apiUrl, token: input.token, fetchFn: input.fetchFn };
15
+ await openCapabilityProxySession(client);
16
+ const args = { code };
17
+ if (input.params !== undefined)
18
+ args.params = input.params;
19
+ if (input.conversationId !== undefined)
20
+ args.conversationId = input.conversationId;
21
+ const payload = await callCapabilityProxy({
22
+ ...client,
23
+ path: ['kody', 'execute'],
24
+ args: [args],
25
+ conversationId: input.conversationId,
26
+ });
27
+ return formatExecuteCapabilityResult(payload);
28
+ }
29
+ export function resolveRemoteExecuteCode(input) {
30
+ const code = input.code?.trim() ? input.code : undefined;
31
+ const invoke = input.invoke?.trim() ? input.invoke : undefined;
32
+ if (code && invoke) {
33
+ throw new Error('--invoke cannot be combined with --code, --file, or a module string.');
34
+ }
35
+ if (invoke)
36
+ return resolveExecuteInvokeCode(invoke);
37
+ if (code)
38
+ return code;
39
+ throw new Error('Provide --invoke, --code, --file, or a module string.');
40
+ }
41
+ /**
42
+ * Map `kody.execute` capability output (returned as CapabilityProxy `result`)
43
+ * into the same ToolCallResult envelope MCP execute / local execute use.
44
+ */
45
+ export function formatExecuteCapabilityResult(payload) {
46
+ const record = isRecord(payload) ? payload : null;
47
+ if (!record) {
48
+ const text = typeof payload === 'string' ? payload : JSON.stringify(payload, null, 2) ?? 'undefined';
49
+ return {
50
+ content: [{ type: 'text', text }],
51
+ structuredContent: { result: payload },
52
+ isError: false,
53
+ };
54
+ }
55
+ const ok = record.ok !== false && typeof record.error !== 'string';
56
+ const conversationId = typeof record.conversationId === 'string' ? record.conversationId : undefined;
57
+ const logs = Array.isArray(record.logs) ? record.logs : [];
58
+ const base = {
59
+ ...(conversationId !== undefined ? { conversationId } : {}),
60
+ logs,
61
+ };
62
+ for (const key of [
63
+ 'timing',
64
+ 'runId',
65
+ 'replayed',
66
+ 'inProgress',
67
+ 'status',
68
+ 'returnedBytes',
69
+ 'truncated',
70
+ 'note',
71
+ 'errorDetails',
72
+ 'entitlement',
73
+ 'serverTiming',
74
+ ]) {
75
+ if (record[key] !== undefined)
76
+ base[key] = record[key];
77
+ }
78
+ if (!ok) {
79
+ const error = typeof record.error === 'string'
80
+ ? record.error
81
+ : 'Execute failed without an error message.';
82
+ return {
83
+ content: [{ type: 'text', text: `Error: ${error}` }],
84
+ structuredContent: { ...base, error, result: record.result },
85
+ isError: true,
86
+ };
87
+ }
88
+ const result = record.result;
89
+ const text = typeof result === 'string' ? result : (JSON.stringify(result, null, 2) ?? 'undefined');
90
+ return {
91
+ content: [{ type: 'text', text }],
92
+ structuredContent: { ...base, result },
93
+ isError: false,
94
+ };
95
+ }
96
+ function isRecord(value) {
97
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
98
+ }
99
+ //# sourceMappingURL=remote-execute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote-execute.js","sourceRoot":"","sources":["../src/remote-execute.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,qBAAqB,EACrB,mBAAmB,EACnB,0BAA0B,GAC1B,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAA;AAYlE;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC9C,KAAyB;IAEzB,qBAAqB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IACnC,MAAM,IAAI,GAAG,wBAAwB,CAAC,KAAK,CAAC,CAAA;IAC5C,MAAM,MAAM,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAA;IACnF,MAAM,0BAA0B,CAAC,MAAM,CAAC,CAAA;IAExC,MAAM,IAAI,GAA4B,EAAE,IAAI,EAAE,CAAA;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;YAC/B,CAAC,CAAC,MAAM,CAAC,KAAK;YACd,CAAC,CAAC,0CAA0C,CAAA;QAC9C,OAAO;YACN,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,KAAK,EAAE,EAAE,CAAC;YACpD,iBAAiB,EAAE,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;YAC5D,OAAO,EAAE,IAAI;SACb,CAAA;IACF,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAA;IAC5B,MAAM,IAAI,GACT,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,WAAW,CAAC,CAAA;IACvF,OAAO;QACN,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;QACjC,iBAAiB,EAAE,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE;QACtC,OAAO,EAAE,KAAK;KACd,CAAA;AACF,CAAC;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"}
@@ -0,0 +1,31 @@
1
+ /** Matches the workerd the Kody platform runs; bump together with the digests. */
2
+ export declare const workerdVersion = "1.20260815.1";
3
+ /** sha256 of each gzipped release asset on github.com/cloudflare/workerd. */
4
+ export declare const workerdAssetDigests: {
5
+ readonly 'linux-64': "05099ec6f50832fcbc327490e5a971d682c97231fb01943b61726db07677e559";
6
+ readonly 'linux-arm64': "0331597b53771170df2ab8344d9ae81d38bad4959e47152dd86592eedd9264c7";
7
+ readonly 'darwin-64': "752ec91c01dfc44d660de6e3a654879cfc1277caa7f3c5312871c608c4c2d6df";
8
+ readonly 'darwin-arm64': "c189fc08f691739c37d8784945e943e33b66cbd4e14635a061fe516dc95f2b39";
9
+ };
10
+ export type WorkerdTarget = keyof typeof workerdAssetDigests;
11
+ export declare function workerdTargetFor(platform?: NodeJS.Platform, arch?: string): WorkerdTarget;
12
+ export declare function workerdAssetUrl(target: WorkerdTarget, version?: string): string;
13
+ export declare function userCacheDir(env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform, home?: string): string;
14
+ export declare function cachedWorkerdPath(cacheDir: string, target: WorkerdTarget): string;
15
+ /**
16
+ * Returns a runnable workerd path: `KODY_WORKERD_PATH` when set, otherwise the
17
+ * pinned release under the user cache dir (downloaded and verified on first use).
18
+ */
19
+ export declare function ensureWorkerdBinary(input?: {
20
+ env?: NodeJS.ProcessEnv;
21
+ cacheDir?: string;
22
+ target?: WorkerdTarget;
23
+ fetchFn?: typeof fetch;
24
+ onDownload?: (url: string) => void;
25
+ }): Promise<string>;
26
+ export declare function downloadVerifiedGzip(input: {
27
+ url: string;
28
+ sha256: string;
29
+ destination: string;
30
+ fetchFn: typeof fetch;
31
+ }): Promise<void>;