@kodycodes/cli 1.17.0 → 1.19.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.
- package/README.md +51 -5
- package/dist/auth.d.ts +30 -4
- package/dist/auth.js +94 -13
- package/dist/auth.js.map +1 -1
- package/dist/capability-proxy.d.ts +7 -0
- package/dist/capability-proxy.js +8 -2
- package/dist/capability-proxy.js.map +1 -1
- package/dist/cli.d.ts +9 -1
- package/dist/cli.js +426 -100
- package/dist/cli.js.map +1 -1
- package/dist/dev-command.d.ts +93 -0
- package/dist/dev-command.js +369 -0
- package/dist/dev-command.js.map +1 -0
- package/dist/discover-org.d.ts +10 -0
- package/dist/discover-org.js +62 -0
- package/dist/discover-org.js.map +1 -0
- package/dist/help.d.ts +13 -1
- package/dist/help.js +112 -15
- package/dist/help.js.map +1 -1
- package/dist/local-execute-auth.d.ts +1 -0
- package/dist/local-execute-auth.js +7 -1
- package/dist/local-execute-auth.js.map +1 -1
- package/dist/local-execute.d.ts +2 -0
- package/dist/local-execute.js +6 -1
- package/dist/local-execute.js.map +1 -1
- package/dist/local-package-graph.js +2 -0
- package/dist/local-package-graph.js.map +1 -1
- package/dist/local-package-run.d.ts +28 -0
- package/dist/local-package-run.js +299 -0
- package/dist/local-package-run.js.map +1 -0
- package/dist/mcp.d.ts +4 -0
- package/dist/mcp.js +3 -0
- package/dist/mcp.js.map +1 -1
- package/dist/mock/mock-server.d.ts +42 -0
- package/dist/mock/mock-server.js +373 -0
- package/dist/mock/mock-server.js.map +1 -0
- package/dist/mock/mock-storage.d.ts +46 -0
- package/dist/mock/mock-storage.js +96 -0
- package/dist/mock/mock-storage.js.map +1 -0
- package/dist/mock/mock-supported.d.ts +18 -0
- package/dist/mock/mock-supported.js +43 -0
- package/dist/mock/mock-supported.js.map +1 -0
- package/dist/oauth-provider.d.ts +1 -2
- package/dist/oauth-provider.js +2 -8
- package/dist/oauth-provider.js.map +1 -1
- package/dist/open-api-client.d.ts +5 -0
- package/dist/open-api-client.js +4 -0
- package/dist/open-api-client.js.map +1 -1
- package/dist/org-resolve.d.ts +9 -0
- package/dist/org-resolve.js +16 -0
- package/dist/org-resolve.js.map +1 -0
- package/dist/org-slug.d.ts +4 -0
- package/dist/org-slug.js +11 -0
- package/dist/org-slug.js.map +1 -0
- package/dist/org.d.ts +22 -0
- package/dist/org.js +100 -0
- package/dist/org.js.map +1 -0
- package/dist/package-app-dev.d.ts +43 -0
- package/dist/package-app-dev.js +356 -0
- package/dist/package-app-dev.js.map +1 -0
- package/dist/package-local-runtime-source.d.ts +35 -0
- package/dist/package-local-runtime-source.js +317 -0
- package/dist/package-local-runtime-source.js.map +1 -0
- package/dist/package-manifest.d.ts +43 -0
- package/dist/package-manifest.js +264 -0
- package/dist/package-manifest.js.map +1 -0
- package/dist/remote-execute.d.ts +2 -0
- package/dist/remote-execute.js +6 -1
- package/dist/remote-execute.js.map +1 -1
- package/dist/store.d.ts +93 -3
- package/dist/store.js +454 -23
- package/dist/store.js.map +1 -1
- package/dist/structured-error.d.ts +28 -0
- package/dist/structured-error.js +57 -0
- package/dist/structured-error.js.map +1 -0
- package/dist/target.d.ts +25 -0
- package/dist/target.js +45 -0
- package/dist/target.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `kody:runtime` for unpublished package runs (`kody dev`, local export/job/
|
|
3
|
+
* webhook/subscription). Same CapabilityProxy bridge as local-execute, plus a
|
|
4
|
+
* real `packageContext` and mock-backed `packageStorage()` hops.
|
|
5
|
+
*/
|
|
6
|
+
import { credentialClientRuntimeSource } from './credential-client-runtime-source.js';
|
|
7
|
+
import { kodyRuntimeStorageSymbolDescription, localExecuteCompatibilityDate, localExecuteCompatibilityFlags, localWorkerModuleNames, runSecretEnvVar, runSecretHeader, } from './local-runtime-source.js';
|
|
8
|
+
export { localExecuteCompatibilityDate, localExecuteCompatibilityFlags, localWorkerModuleNames, runSecretEnvVar, runSecretHeader, };
|
|
9
|
+
/**
|
|
10
|
+
* Runtime module for package-local workerd. `packageStorage()` hops through the
|
|
11
|
+
* bridge to mock `__mockPackageStorage*` (or refuses clearly on prod until the
|
|
12
|
+
* package is published).
|
|
13
|
+
*/
|
|
14
|
+
export function createPackageLocalRuntimeModuleSource(input) {
|
|
15
|
+
const ctxLiteral = JSON.stringify(input.packageContext);
|
|
16
|
+
const storageBlock = input.mockStorage
|
|
17
|
+
? `
|
|
18
|
+
export function packageStorage() {
|
|
19
|
+
return {
|
|
20
|
+
async get(key) {
|
|
21
|
+
const result = await __kodyCall(['kody', '__mockPackageStorageGet'], [{ key: String(key) }]);
|
|
22
|
+
return result?.value ?? null;
|
|
23
|
+
},
|
|
24
|
+
async set(key, value) {
|
|
25
|
+
await __kodyCall(['kody', '__mockPackageStorageSet'], [{ key: String(key), value }]);
|
|
26
|
+
},
|
|
27
|
+
async delete(key) {
|
|
28
|
+
const result = await __kodyCall(['kody', '__mockPackageStorageDelete'], [{ key: String(key) }]);
|
|
29
|
+
return Boolean(result?.deleted);
|
|
30
|
+
},
|
|
31
|
+
async list() {
|
|
32
|
+
const result = await __kodyCall(['kody', '__mockPackageStorageList'], [{}]);
|
|
33
|
+
return result?.entries ?? [];
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
`
|
|
38
|
+
: `
|
|
39
|
+
export function packageStorage() {
|
|
40
|
+
throw new Error(
|
|
41
|
+
'packageStorage() against --target prod requires a published package with real storage. ' +
|
|
42
|
+
'Use \`--target mock\` for scratch storage while iterating on an unpublished package.',
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
`;
|
|
46
|
+
return `
|
|
47
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
48
|
+
|
|
49
|
+
let __kodyBridge = null;
|
|
50
|
+
|
|
51
|
+
export function __kodyInstallLocalBridge(bridge) {
|
|
52
|
+
__kodyBridge = bridge;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function __kodyCall(path, args) {
|
|
56
|
+
if (__kodyBridge === null) {
|
|
57
|
+
throw new Error('kody:runtime is only available while a local package run is in progress.');
|
|
58
|
+
}
|
|
59
|
+
return __kodyBridge(path, args);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function __kodyNamespace(path) {
|
|
63
|
+
const label = '[KodyRuntime:' + path.join('.') + ']';
|
|
64
|
+
return new Proxy(function () {}, {
|
|
65
|
+
get(_target, property) {
|
|
66
|
+
if (typeof property === 'symbol' || property === 'then' || property === 'toJSON') {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
if (property === 'toString' || property === 'inspect') return () => label;
|
|
70
|
+
return __kodyNamespace([...path, property]);
|
|
71
|
+
},
|
|
72
|
+
apply(_target, _thisArg, args) {
|
|
73
|
+
return __kodyCall(path, args);
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export const kody = __kodyNamespace(['kody']);
|
|
79
|
+
|
|
80
|
+
export const workflows = {
|
|
81
|
+
create: async (input) => await __kodyCall(['workflows', 'create'], [input ?? {}]),
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export const packages = null;
|
|
85
|
+
${storageBlock}
|
|
86
|
+
|
|
87
|
+
function __kodyPackageSecretsUnavailable() {
|
|
88
|
+
throw new Error(
|
|
89
|
+
'packageSecrets is not available in this local package context on the CLI mock/prod bridge yet.',
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export const packageSecrets = {
|
|
94
|
+
get: async () => __kodyPackageSecretsUnavailable(),
|
|
95
|
+
has: async () => __kodyPackageSecretsUnavailable(),
|
|
96
|
+
};
|
|
97
|
+
export const packageContext = Object.freeze(${ctxLiteral});
|
|
98
|
+
export const email = null;
|
|
99
|
+
export const events = null;
|
|
100
|
+
|
|
101
|
+
const __kodyNullBodyStatuses = new Set([204, 205, 304]);
|
|
102
|
+
|
|
103
|
+
function __kodyBytesToBase64(bytes) {
|
|
104
|
+
let binary = '';
|
|
105
|
+
for (let i = 0; i < bytes.length; i += 1) {
|
|
106
|
+
binary += String.fromCharCode(bytes[i]);
|
|
107
|
+
}
|
|
108
|
+
return btoa(binary);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function __kodyBase64ToBytes(value) {
|
|
112
|
+
const binary = atob(value);
|
|
113
|
+
const bytes = new Uint8Array(binary.length);
|
|
114
|
+
for (let i = 0; i < binary.length; i += 1) {
|
|
115
|
+
bytes[i] = binary.charCodeAt(i);
|
|
116
|
+
}
|
|
117
|
+
return bytes;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function createAuthenticatedFetch(input) {
|
|
121
|
+
return async (resource, init) => {
|
|
122
|
+
return await __kodyCall(['kody', 'createAuthenticatedFetch'], [
|
|
123
|
+
{ input, resource: String(resource), init: init ?? {} },
|
|
124
|
+
]);
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export const secretHeaders = {
|
|
129
|
+
bearer(input) {
|
|
130
|
+
const name = String(input?.name ?? input ?? '').trim();
|
|
131
|
+
if (!name) throw new Error('secretHeaders.bearer requires a secret name.');
|
|
132
|
+
const scope =
|
|
133
|
+
typeof input?.scope === 'string' && input.scope.trim()
|
|
134
|
+
? input.scope.trim()
|
|
135
|
+
: null;
|
|
136
|
+
return scope
|
|
137
|
+
? \`{{secret-bearer:\${name}|scope=\${scope}}}\`
|
|
138
|
+
: \`{{secret-bearer:\${name}}}\`;
|
|
139
|
+
},
|
|
140
|
+
basic(input) {
|
|
141
|
+
const usernameSecret = String(input?.usernameSecret ?? '').trim();
|
|
142
|
+
const passwordSecret = String(input?.passwordSecret ?? '').trim();
|
|
143
|
+
if (!usernameSecret || !passwordSecret) {
|
|
144
|
+
throw new Error(
|
|
145
|
+
'secretHeaders.basic requires usernameSecret and passwordSecret.',
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
const scope =
|
|
149
|
+
typeof input?.scope === 'string' && input.scope.trim()
|
|
150
|
+
? input.scope.trim()
|
|
151
|
+
: null;
|
|
152
|
+
return scope
|
|
153
|
+
? \`{{secret-basic:username=\${usernameSecret},password=\${passwordSecret}|scope=\${scope}}}\`
|
|
154
|
+
: \`{{secret-basic:username=\${usernameSecret},password=\${passwordSecret}}}\`;
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export async function oauthClientCredentials(input) {
|
|
159
|
+
return await __kodyCall(['kody', 'oauthClientCredentials'], [input ?? {}]);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
${credentialClientRuntimeSource}
|
|
163
|
+
const __kodyCredentialRuntime = __kodyCreateCredentialRuntime((name, args) =>
|
|
164
|
+
__kodyCall(['kody', name], [args ?? {}]),
|
|
165
|
+
);
|
|
166
|
+
export const credential = __kodyCredentialRuntime.credential;
|
|
167
|
+
export const credentials = __kodyCredentialRuntime.credentials;
|
|
168
|
+
|
|
169
|
+
const __kodyRuntimeStorageSymbol = Symbol.for(${JSON.stringify(kodyRuntimeStorageSymbolDescription)});
|
|
170
|
+
const __globalAny = globalThis;
|
|
171
|
+
const __kodyRuntimeStorage =
|
|
172
|
+
__globalAny[__kodyRuntimeStorageSymbol] ??
|
|
173
|
+
(__globalAny[__kodyRuntimeStorageSymbol] = new AsyncLocalStorage());
|
|
174
|
+
|
|
175
|
+
const __kodyRuntimeDefault = Object.freeze({
|
|
176
|
+
kody,
|
|
177
|
+
packageStorage,
|
|
178
|
+
createAuthenticatedFetch,
|
|
179
|
+
secretHeaders,
|
|
180
|
+
oauthClientCredentials,
|
|
181
|
+
credential,
|
|
182
|
+
credentials,
|
|
183
|
+
packageContext,
|
|
184
|
+
packageSecrets,
|
|
185
|
+
email,
|
|
186
|
+
workflows,
|
|
187
|
+
packages,
|
|
188
|
+
events,
|
|
189
|
+
});
|
|
190
|
+
export default __kodyRuntimeDefault;
|
|
191
|
+
export const KodyRuntime = Object.freeze({ defaultValue: __kodyRuntimeDefault });
|
|
192
|
+
|
|
193
|
+
export function __kodyRunInLocalRuntime(callback) {
|
|
194
|
+
return __kodyRuntimeStorage.run(__kodyRuntimeDefault, callback);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Keep unused helpers referenced so esbuild/workerd does not strip them in future.
|
|
198
|
+
void __kodyNullBodyStatuses;
|
|
199
|
+
void __kodyBytesToBase64;
|
|
200
|
+
void __kodyBase64ToBytes;
|
|
201
|
+
`.trimStart();
|
|
202
|
+
}
|
|
203
|
+
/** Execute-style entry: default export function(params). */
|
|
204
|
+
export function createPackageModuleEntrySource() {
|
|
205
|
+
return `
|
|
206
|
+
import {
|
|
207
|
+
__kodyInstallLocalBridge,
|
|
208
|
+
__kodyRunInLocalRuntime,
|
|
209
|
+
} from ${JSON.stringify(localWorkerModuleNames.runtime)};
|
|
210
|
+
|
|
211
|
+
const __kodyRunSecretHeader = ${JSON.stringify(runSecretHeader)};
|
|
212
|
+
let __kodyClaimed = false;
|
|
213
|
+
|
|
214
|
+
function __kodyFormatLogArgs(args) {
|
|
215
|
+
return args.map(String).join(' ');
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export default {
|
|
219
|
+
async fetch(request, env) {
|
|
220
|
+
const secret = env.${runSecretEnvVar};
|
|
221
|
+
if (__kodyClaimed || !secret || request.headers.get(__kodyRunSecretHeader) !== secret) {
|
|
222
|
+
return new Response('Forbidden', { status: 403 });
|
|
223
|
+
}
|
|
224
|
+
__kodyClaimed = true;
|
|
225
|
+
const { params } = await request.json();
|
|
226
|
+
__kodyInstallLocalBridge(async (path, args) => {
|
|
227
|
+
const response = await env.KODY_BRIDGE.fetch('http://kody-bridge/call', {
|
|
228
|
+
method: 'POST',
|
|
229
|
+
headers: { 'content-type': 'application/json', [__kodyRunSecretHeader]: secret },
|
|
230
|
+
body: JSON.stringify({ path, args }),
|
|
231
|
+
});
|
|
232
|
+
const data = await response.json();
|
|
233
|
+
if (data.error) throw new Error(data.error);
|
|
234
|
+
return data.result;
|
|
235
|
+
});
|
|
236
|
+
const logs = [];
|
|
237
|
+
const nativeConsole = globalThis.console;
|
|
238
|
+
globalThis.console = {
|
|
239
|
+
...nativeConsole,
|
|
240
|
+
log: (...a) => { logs.push(__kodyFormatLogArgs(a)); },
|
|
241
|
+
info: (...a) => { logs.push('[info] ' + __kodyFormatLogArgs(a)); },
|
|
242
|
+
debug: (...a) => { logs.push('[debug] ' + __kodyFormatLogArgs(a)); },
|
|
243
|
+
warn: (...a) => { logs.push('[warn] ' + __kodyFormatLogArgs(a)); },
|
|
244
|
+
error: (...a) => { logs.push('[error] ' + __kodyFormatLogArgs(a)); },
|
|
245
|
+
};
|
|
246
|
+
try {
|
|
247
|
+
const result = await __kodyRunInLocalRuntime(async () => {
|
|
248
|
+
const module = await import(${JSON.stringify(`./${localWorkerModuleNames.user}`)});
|
|
249
|
+
if (typeof module?.default !== 'function') {
|
|
250
|
+
throw new Error('Package modules must default export a function.');
|
|
251
|
+
}
|
|
252
|
+
return await module.default(params);
|
|
253
|
+
});
|
|
254
|
+
return new Response(JSON.stringify({ result, logs }), {
|
|
255
|
+
headers: { 'content-type': 'application/json' },
|
|
256
|
+
});
|
|
257
|
+
} catch (error) {
|
|
258
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
259
|
+
return Response.json({ error: message, logs });
|
|
260
|
+
} finally {
|
|
261
|
+
globalThis.console = nativeConsole;
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
};
|
|
265
|
+
`.trimStart();
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* App fetch entry: wraps user `kody.app.entry` so the host always sees a Worker
|
|
269
|
+
* `{ fetch }` export. Mount is already stripped by the Node proxy before this
|
|
270
|
+
* request reaches workerd (pathname is the rest path).
|
|
271
|
+
*/
|
|
272
|
+
export function createPackageAppEntrySource() {
|
|
273
|
+
return `
|
|
274
|
+
import {
|
|
275
|
+
__kodyInstallLocalBridge,
|
|
276
|
+
__kodyRunInLocalRuntime,
|
|
277
|
+
} from ${JSON.stringify(localWorkerModuleNames.runtime)};
|
|
278
|
+
|
|
279
|
+
const __kodyRunSecretHeader = ${JSON.stringify(runSecretHeader)};
|
|
280
|
+
|
|
281
|
+
function __kodyResolveFetch(module) {
|
|
282
|
+
if (typeof module?.default === 'function') return module.default.bind(module);
|
|
283
|
+
if (module?.default && typeof module.default.fetch === 'function') {
|
|
284
|
+
return module.default.fetch.bind(module.default);
|
|
285
|
+
}
|
|
286
|
+
if (typeof module?.fetch === 'function') return module.fetch.bind(module);
|
|
287
|
+
throw new Error(
|
|
288
|
+
'kody.app.entry must default-export a fetch handler, { fetch }, or a named fetch export.',
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export default {
|
|
293
|
+
async fetch(request, env) {
|
|
294
|
+
const secret = env.${runSecretEnvVar};
|
|
295
|
+
if (!secret || request.headers.get(__kodyRunSecretHeader) !== secret) {
|
|
296
|
+
return new Response('Forbidden', { status: 403 });
|
|
297
|
+
}
|
|
298
|
+
__kodyInstallLocalBridge(async (path, args) => {
|
|
299
|
+
const response = await env.KODY_BRIDGE.fetch('http://kody-bridge/call', {
|
|
300
|
+
method: 'POST',
|
|
301
|
+
headers: { 'content-type': 'application/json', [__kodyRunSecretHeader]: secret },
|
|
302
|
+
body: JSON.stringify({ path, args }),
|
|
303
|
+
});
|
|
304
|
+
const data = await response.json();
|
|
305
|
+
if (data.error) throw new Error(data.error);
|
|
306
|
+
return data.result;
|
|
307
|
+
});
|
|
308
|
+
return await __kodyRunInLocalRuntime(async () => {
|
|
309
|
+
const module = await import(${JSON.stringify(`./${localWorkerModuleNames.user}`)});
|
|
310
|
+
const fetchHandler = __kodyResolveFetch(module);
|
|
311
|
+
return await fetchHandler(request, env);
|
|
312
|
+
});
|
|
313
|
+
},
|
|
314
|
+
};
|
|
315
|
+
`.trimStart();
|
|
316
|
+
}
|
|
317
|
+
//# sourceMappingURL=package-local-runtime-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-local-runtime-source.js","sourceRoot":"","sources":["../src/package-local-runtime-source.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAA;AACrF,OAAO,EACN,mCAAmC,EACnC,6BAA6B,EAC7B,8BAA8B,EAC9B,sBAAsB,EACtB,eAAe,EACf,eAAe,GACf,MAAM,2BAA2B,CAAA;AAalC,OAAO,EACN,6BAA6B,EAC7B,8BAA8B,EAC9B,sBAAsB,EACtB,eAAe,EACf,eAAe,GACf,CAAA;AAED;;;;GAIG;AACH,MAAM,UAAU,qCAAqC,CAAC,KAIrD;IACA,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,cAAc,CAAC,CAAA;IACvD,MAAM,YAAY,GAAG,KAAK,CAAC,WAAW;QACrC,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;CAoBH;QACC,CAAC,CAAC;;;;;;;CAOH,CAAA;IAEA,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuCN,YAAY;;;;;;;;;;;;8CAYgC,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiEtD,6BAA6B;;;;;;;gDAOiB,IAAI,CAAC,SAAS,CAAC,mCAAmC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgClG,CAAC,SAAS,EAAE,CAAA;AACb,CAAC;AAED,4DAA4D;AAC5D,MAAM,UAAU,8BAA8B;IAC7C,OAAO;;;;SAIC,IAAI,CAAC,SAAS,CAAC,sBAAsB,CAAC,OAAO,CAAC;;gCAEvB,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC;;;;;;;;;uBASxC,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;kCA4BJ,IAAI,CAAC,SAAS,CAAC,KAAK,sBAAsB,CAAC,IAAI,EAAE,CAAC;;;;;;;;;;;;;;;;;CAiBnF,CAAC,SAAS,EAAE,CAAA;AACb,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,2BAA2B;IAC1C,OAAO;;;;SAIC,IAAI,CAAC,SAAS,CAAC,sBAAsB,CAAC,OAAO,CAAC;;gCAEvB,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC;;;;;;;;;;;;;;;uBAexC,eAAe;;;;;;;;;;;;;;;iCAeL,IAAI,CAAC,SAAS,CAAC,KAAK,sBAAsB,CAAC,IAAI,EAAE,CAAC;;;;;;CAMlF,CAAC,SAAS,EAAE,CAAA;AACb,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read and validate the authored package.json `kody` surface used by `kody dev`.
|
|
3
|
+
*/
|
|
4
|
+
export type PackageAppManifest = {
|
|
5
|
+
entry: string;
|
|
6
|
+
client?: string;
|
|
7
|
+
assets?: string;
|
|
8
|
+
};
|
|
9
|
+
export type PackageJobManifest = {
|
|
10
|
+
entry: string;
|
|
11
|
+
schedule: string;
|
|
12
|
+
timezone?: string;
|
|
13
|
+
enabled?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export type PackageWebhookManifest = {
|
|
16
|
+
export: string;
|
|
17
|
+
description?: string;
|
|
18
|
+
inputMode?: 'request' | 'params';
|
|
19
|
+
};
|
|
20
|
+
export type PackageSubscriptionManifest = {
|
|
21
|
+
handler: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
filters?: unknown;
|
|
24
|
+
};
|
|
25
|
+
export type KodyPackageManifest = {
|
|
26
|
+
/** Absolute path to package.json */
|
|
27
|
+
packageJsonPath: string;
|
|
28
|
+
/** Package root directory */
|
|
29
|
+
root: string;
|
|
30
|
+
name: string;
|
|
31
|
+
kodyId: string;
|
|
32
|
+
description?: string;
|
|
33
|
+
exports: Record<string, string>;
|
|
34
|
+
app?: PackageAppManifest;
|
|
35
|
+
jobs: Record<string, PackageJobManifest>;
|
|
36
|
+
webhooks: Record<string, PackageWebhookManifest>;
|
|
37
|
+
subscriptions: Record<string, PackageSubscriptionManifest>;
|
|
38
|
+
};
|
|
39
|
+
export declare function loadPackageManifest(cwd?: string): Promise<KodyPackageManifest>;
|
|
40
|
+
/** Resolve a package-relative path against the package root. */
|
|
41
|
+
export declare function resolvePackagePath(manifest: KodyPackageManifest, relativePath: string): string;
|
|
42
|
+
/** Resolve an export key (`.` / `./foo`) or filesystem-ish ref to an absolute module path. */
|
|
43
|
+
export declare function resolveExportModulePath(manifest: KodyPackageManifest, exportRef: string): string;
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read and validate the authored package.json `kody` surface used by `kody dev`.
|
|
3
|
+
*/
|
|
4
|
+
import { readFile } from 'node:fs/promises';
|
|
5
|
+
import { dirname, join, resolve } from 'node:path';
|
|
6
|
+
import { StructuredCliError } from './structured-error.js';
|
|
7
|
+
export async function loadPackageManifest(cwd = process.cwd()) {
|
|
8
|
+
const packageJsonPath = await findPackageJson(cwd);
|
|
9
|
+
const root = dirname(packageJsonPath);
|
|
10
|
+
let raw;
|
|
11
|
+
try {
|
|
12
|
+
raw = JSON.parse(await readFile(packageJsonPath, 'utf8'));
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
throw new StructuredCliError({
|
|
16
|
+
code: 'package_manifest_invalid',
|
|
17
|
+
message: `Could not read package.json at ${packageJsonPath}.`,
|
|
18
|
+
where: packageJsonPath,
|
|
19
|
+
fix: 'Run `kody dev` from a package directory with a valid package.json.',
|
|
20
|
+
details: { cause: error instanceof Error ? error.message : String(error) },
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {
|
|
24
|
+
throw new StructuredCliError({
|
|
25
|
+
code: 'package_manifest_invalid',
|
|
26
|
+
message: 'package.json must be a JSON object.',
|
|
27
|
+
where: packageJsonPath,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
const pkg = raw;
|
|
31
|
+
const name = typeof pkg.name === 'string' ? pkg.name : '';
|
|
32
|
+
const kody = asRecord(pkg.kody) ?? {};
|
|
33
|
+
const kodyId = typeof kody.id === 'string' && kody.id.trim()
|
|
34
|
+
? kody.id.trim()
|
|
35
|
+
: name.includes('/')
|
|
36
|
+
? name.slice(name.lastIndexOf('/') + 1)
|
|
37
|
+
: name || 'local-package';
|
|
38
|
+
const exportsField = normalizeExports(pkg.exports);
|
|
39
|
+
const app = parseApp(kody.app, packageJsonPath);
|
|
40
|
+
const jobs = parseJobs(kody.jobs, packageJsonPath);
|
|
41
|
+
const webhooks = parseWebhooks(kody.webhooks, packageJsonPath);
|
|
42
|
+
const subscriptions = parseSubscriptions(kody.subscriptions, packageJsonPath);
|
|
43
|
+
return {
|
|
44
|
+
packageJsonPath,
|
|
45
|
+
root,
|
|
46
|
+
name: name || `@local/${kodyId}`,
|
|
47
|
+
kodyId,
|
|
48
|
+
description: typeof kody.description === 'string' ? kody.description : undefined,
|
|
49
|
+
exports: exportsField,
|
|
50
|
+
app,
|
|
51
|
+
jobs,
|
|
52
|
+
webhooks,
|
|
53
|
+
subscriptions,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
async function findPackageJson(start) {
|
|
57
|
+
let dir = resolve(start);
|
|
58
|
+
for (;;) {
|
|
59
|
+
const candidate = join(dir, 'package.json');
|
|
60
|
+
try {
|
|
61
|
+
await readFile(candidate);
|
|
62
|
+
return candidate;
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
const parent = dirname(dir);
|
|
66
|
+
if (parent === dir) {
|
|
67
|
+
throw new StructuredCliError({
|
|
68
|
+
code: 'package_manifest_invalid',
|
|
69
|
+
message: `No package.json found from ${start}.`,
|
|
70
|
+
fix: 'cd into a Kody package directory (one with package.json and a kody block).',
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
dir = parent;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function normalizeExports(exportsField) {
|
|
78
|
+
const out = {};
|
|
79
|
+
if (typeof exportsField === 'string') {
|
|
80
|
+
out['.'] = exportsField;
|
|
81
|
+
return out;
|
|
82
|
+
}
|
|
83
|
+
if (!exportsField || typeof exportsField !== 'object' || Array.isArray(exportsField)) {
|
|
84
|
+
return out;
|
|
85
|
+
}
|
|
86
|
+
for (const [key, value] of Object.entries(exportsField)) {
|
|
87
|
+
if (typeof value === 'string') {
|
|
88
|
+
out[key] = value;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
92
|
+
const cond = value;
|
|
93
|
+
const pick = (typeof cond.default === 'string' && cond.default) ||
|
|
94
|
+
(typeof cond.import === 'string' && cond.import) ||
|
|
95
|
+
(typeof cond.require === 'string' && cond.require);
|
|
96
|
+
if (pick)
|
|
97
|
+
out[key] = pick;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return out;
|
|
101
|
+
}
|
|
102
|
+
function parseApp(raw, where) {
|
|
103
|
+
if (raw === undefined || raw === null)
|
|
104
|
+
return undefined;
|
|
105
|
+
const record = asRecord(raw);
|
|
106
|
+
if (!record || typeof record.entry !== 'string' || !record.entry.trim()) {
|
|
107
|
+
throw new StructuredCliError({
|
|
108
|
+
code: 'package_manifest_invalid',
|
|
109
|
+
message: 'kody.app.entry must be a non-empty string path.',
|
|
110
|
+
where,
|
|
111
|
+
fix: 'Set `"kody": { "app": { "entry": "./app/router.ts" } }` in package.json.',
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
entry: record.entry,
|
|
116
|
+
client: typeof record.client === 'string' ? record.client : undefined,
|
|
117
|
+
assets: typeof record.assets === 'string' ? record.assets : undefined,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function parseJobs(raw, where) {
|
|
121
|
+
if (raw === undefined || raw === null)
|
|
122
|
+
return {};
|
|
123
|
+
const record = asRecord(raw);
|
|
124
|
+
if (!record) {
|
|
125
|
+
throw new StructuredCliError({
|
|
126
|
+
code: 'package_manifest_invalid',
|
|
127
|
+
message: 'kody.jobs must be an object.',
|
|
128
|
+
where,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
const out = {};
|
|
132
|
+
for (const [name, value] of Object.entries(record)) {
|
|
133
|
+
const job = asRecord(value);
|
|
134
|
+
if (!job || typeof job.entry !== 'string' || typeof job.schedule !== 'string') {
|
|
135
|
+
throw new StructuredCliError({
|
|
136
|
+
code: 'package_manifest_invalid',
|
|
137
|
+
message: `kody.jobs.${name} requires entry and schedule strings.`,
|
|
138
|
+
where,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
out[name] = {
|
|
142
|
+
entry: job.entry,
|
|
143
|
+
schedule: job.schedule,
|
|
144
|
+
timezone: typeof job.timezone === 'string' ? job.timezone : undefined,
|
|
145
|
+
enabled: typeof job.enabled === 'boolean' ? job.enabled : undefined,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
return out;
|
|
149
|
+
}
|
|
150
|
+
function parseWebhooks(raw, where) {
|
|
151
|
+
if (raw === undefined || raw === null)
|
|
152
|
+
return {};
|
|
153
|
+
if (Array.isArray(raw)) {
|
|
154
|
+
const out = {};
|
|
155
|
+
for (const item of raw) {
|
|
156
|
+
const webhook = asRecord(item);
|
|
157
|
+
if (!webhook || typeof webhook.name !== 'string' || typeof webhook.export !== 'string') {
|
|
158
|
+
throw new StructuredCliError({
|
|
159
|
+
code: 'package_manifest_invalid',
|
|
160
|
+
message: 'Each kody.webhooks[] entry needs name and export.',
|
|
161
|
+
where,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
out[webhook.name] = {
|
|
165
|
+
export: webhook.export,
|
|
166
|
+
description: typeof webhook.description === 'string' ? webhook.description : undefined,
|
|
167
|
+
inputMode: webhook.inputMode === 'params' ? 'params' : 'request',
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
return out;
|
|
171
|
+
}
|
|
172
|
+
const record = asRecord(raw);
|
|
173
|
+
if (!record) {
|
|
174
|
+
throw new StructuredCliError({
|
|
175
|
+
code: 'package_manifest_invalid',
|
|
176
|
+
message: 'kody.webhooks must be an object or array.',
|
|
177
|
+
where,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
const out = {};
|
|
181
|
+
for (const [name, value] of Object.entries(record)) {
|
|
182
|
+
const webhook = asRecord(value);
|
|
183
|
+
if (!webhook || typeof webhook.export !== 'string') {
|
|
184
|
+
throw new StructuredCliError({
|
|
185
|
+
code: 'package_manifest_invalid',
|
|
186
|
+
message: `kody.webhooks.${name} requires an export string.`,
|
|
187
|
+
where,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
out[name] = {
|
|
191
|
+
export: webhook.export,
|
|
192
|
+
description: typeof webhook.description === 'string' ? webhook.description : undefined,
|
|
193
|
+
inputMode: webhook.inputMode === 'params' ? 'params' : 'request',
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
return out;
|
|
197
|
+
}
|
|
198
|
+
function parseSubscriptions(raw, where) {
|
|
199
|
+
if (raw === undefined || raw === null)
|
|
200
|
+
return {};
|
|
201
|
+
const record = asRecord(raw);
|
|
202
|
+
if (!record) {
|
|
203
|
+
throw new StructuredCliError({
|
|
204
|
+
code: 'package_manifest_invalid',
|
|
205
|
+
message: 'kody.subscriptions must be an object keyed by event topic.',
|
|
206
|
+
where,
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
const out = {};
|
|
210
|
+
for (const [topic, value] of Object.entries(record)) {
|
|
211
|
+
const sub = asRecord(value);
|
|
212
|
+
if (!sub || typeof sub.handler !== 'string') {
|
|
213
|
+
throw new StructuredCliError({
|
|
214
|
+
code: 'package_manifest_invalid',
|
|
215
|
+
message: `kody.subscriptions[${JSON.stringify(topic)}] requires a handler path.`,
|
|
216
|
+
where,
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
out[topic] = {
|
|
220
|
+
handler: sub.handler,
|
|
221
|
+
description: typeof sub.description === 'string' ? sub.description : undefined,
|
|
222
|
+
filters: sub.filters,
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
return out;
|
|
226
|
+
}
|
|
227
|
+
function asRecord(value) {
|
|
228
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
229
|
+
return null;
|
|
230
|
+
return value;
|
|
231
|
+
}
|
|
232
|
+
/** Resolve a package-relative path against the package root. */
|
|
233
|
+
export function resolvePackagePath(manifest, relativePath) {
|
|
234
|
+
return resolve(manifest.root, relativePath);
|
|
235
|
+
}
|
|
236
|
+
/** Resolve an export key (`.` / `./foo`) or filesystem-ish ref to an absolute module path. */
|
|
237
|
+
export function resolveExportModulePath(manifest, exportRef) {
|
|
238
|
+
const trimmed = exportRef.trim();
|
|
239
|
+
if (!trimmed) {
|
|
240
|
+
throw new StructuredCliError({
|
|
241
|
+
code: 'dev_surface_missing',
|
|
242
|
+
message: 'Export reference is empty.',
|
|
243
|
+
fix: 'Pass an export key from package.json#exports (e.g. `.` or `./on-user-deleted`).',
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
if (trimmed in manifest.exports) {
|
|
247
|
+
return resolvePackagePath(manifest, manifest.exports[trimmed]);
|
|
248
|
+
}
|
|
249
|
+
const withDot = trimmed.startsWith('./') ? trimmed : `./${trimmed}`;
|
|
250
|
+
if (withDot in manifest.exports) {
|
|
251
|
+
return resolvePackagePath(manifest, manifest.exports[withDot]);
|
|
252
|
+
}
|
|
253
|
+
// Bare path into the package
|
|
254
|
+
if (trimmed.startsWith('.') || trimmed.startsWith('/')) {
|
|
255
|
+
return resolvePackagePath(manifest, trimmed);
|
|
256
|
+
}
|
|
257
|
+
throw new StructuredCliError({
|
|
258
|
+
code: 'dev_surface_missing',
|
|
259
|
+
message: `No package export ${JSON.stringify(trimmed)}.`,
|
|
260
|
+
where: manifest.packageJsonPath,
|
|
261
|
+
fix: `Known exports: ${Object.keys(manifest.exports).join(', ') || '(none)'}.`,
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
//# sourceMappingURL=package-manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-manifest.js","sourceRoot":"","sources":["../src/package-manifest.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AA0C1D,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACxC,MAAc,OAAO,CAAC,GAAG,EAAE;IAE3B,MAAM,eAAe,GAAG,MAAM,eAAe,CAAC,GAAG,CAAC,CAAA;IAClD,MAAM,IAAI,GAAG,OAAO,CAAC,eAAe,CAAC,CAAA;IACrC,IAAI,GAAY,CAAA;IAChB,IAAI,CAAC;QACJ,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,CAAA;IAC1D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,IAAI,kBAAkB,CAAC;YAC5B,IAAI,EAAE,0BAA0B;YAChC,OAAO,EAAE,kCAAkC,eAAe,GAAG;YAC7D,KAAK,EAAE,eAAe;YACtB,GAAG,EAAE,oEAAoE;YACzE,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;SAC1E,CAAC,CAAA;IACH,CAAC;IACD,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAC3D,MAAM,IAAI,kBAAkB,CAAC;YAC5B,IAAI,EAA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4B;YACrC,GAAG,EAAE,iFAAiF;SACtF,CAAC,CAAA;IACH,CAAC;IACD,IAAI,OAAO,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;QACjC,OAAO,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAE,CAAC,CAAA;IAChE,CAAC;IACD,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE,CAAA;IACnE,IAAI,OAAO,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;QACjC,OAAO,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAE,CAAC,CAAA;IAChE,CAAC;IACD,6BAA6B;IAC7B,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACxD,OAAO,kBAAkB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IAC7C,CAAC;IACD,MAAM,IAAI,kBAAkB,CAAC;QAC5B,IAAI,EAAE,qBAAqB;QAC3B,OAAO,EAAE,qBAAqB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG;QACxD,KAAK,EAAE,QAAQ,CAAC,eAAe;QAC/B,GAAG,EAAE,kBAAkB,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,QAAQ,GAAG;KAC9E,CAAC,CAAA;AACH,CAAC"}
|
package/dist/remote-execute.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export type RemoteExecuteInput = {
|
|
|
13
13
|
token: string;
|
|
14
14
|
apiUrl: string;
|
|
15
15
|
fetchFn?: typeof fetch;
|
|
16
|
+
/** User-owned token org selection (`?org=`). */
|
|
17
|
+
org?: string;
|
|
16
18
|
};
|
|
17
19
|
export declare const credentialFlagRequiresLocalOrMcpMessage = "--credential picks a credential for this run, but token-auth cloud execute goes through CapabilityProxy \u2192 kody.execute, which does not take a call map (package code must not pick by name). Use `execute --local --credential \u2026`, or omit --token / KODY_API_TOKEN and use a `kody login` MCP session so execute receives credentials.";
|
|
18
20
|
/**
|
package/dist/remote-execute.js
CHANGED
|
@@ -15,7 +15,12 @@ export async function runRemoteExecuteWithToken(input) {
|
|
|
15
15
|
throw new Error(credentialFlagRequiresLocalOrMcpMessage);
|
|
16
16
|
}
|
|
17
17
|
const code = resolveRemoteExecuteCode(input);
|
|
18
|
-
const client = {
|
|
18
|
+
const client = {
|
|
19
|
+
apiUrl: input.apiUrl,
|
|
20
|
+
token: input.token,
|
|
21
|
+
fetchFn: input.fetchFn,
|
|
22
|
+
...(input.org ? { org: input.org } : {}),
|
|
23
|
+
};
|
|
19
24
|
await openCapabilityProxySession(client);
|
|
20
25
|
const args = { code };
|
|
21
26
|
if (input.params !== undefined)
|