@kodycodes/cli 1.20.0 → 1.20.2

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 (44) hide show
  1. package/dist/cli.js +109 -15
  2. package/dist/cli.js.map +1 -1
  3. package/dist/dev-command.d.ts +2 -0
  4. package/dist/dev-command.js +1 -0
  5. package/dist/dev-command.js.map +1 -1
  6. package/dist/help.js +13 -10
  7. package/dist/help.js.map +1 -1
  8. package/dist/local-bundle.js +5 -1
  9. package/dist/local-bundle.js.map +1 -1
  10. package/dist/local-execute.js +1 -0
  11. package/dist/local-execute.js.map +1 -1
  12. package/dist/local-package-graph.d.ts +21 -3
  13. package/dist/local-package-graph.js +109 -13
  14. package/dist/local-package-graph.js.map +1 -1
  15. package/dist/local-package-run.js +1 -0
  16. package/dist/local-package-run.js.map +1 -1
  17. package/dist/mock/load-package-mocks.js +39 -21
  18. package/dist/mock/load-package-mocks.js.map +1 -1
  19. package/dist/mock/mock-fetch-gateway.d.ts +28 -4
  20. package/dist/mock/mock-fetch-gateway.js +119 -49
  21. package/dist/mock/mock-fetch-gateway.js.map +1 -1
  22. package/dist/mock/mock-server.d.ts +3 -0
  23. package/dist/mock/mock-server.js +98 -60
  24. package/dist/mock/mock-server.js.map +1 -1
  25. package/dist/mock/mock-storage.d.ts +11 -0
  26. package/dist/mock/mock-storage.js +65 -0
  27. package/dist/mock/mock-storage.js.map +1 -1
  28. package/dist/mock/mock-supported.d.ts +1 -1
  29. package/dist/mock/mock-supported.js +7 -1
  30. package/dist/mock/mock-supported.js.map +1 -1
  31. package/dist/mock-local-deps.d.ts +43 -0
  32. package/dist/mock-local-deps.js +189 -0
  33. package/dist/mock-local-deps.js.map +1 -0
  34. package/dist/package-app-dev.js +2 -0
  35. package/dist/package-app-dev.js.map +1 -1
  36. package/dist/package-local-runtime-source.js +8 -0
  37. package/dist/package-local-runtime-source.js.map +1 -1
  38. package/dist/package-manifest.d.ts +3 -1
  39. package/dist/package-manifest.js +4 -3
  40. package/dist/package-manifest.js.map +1 -1
  41. package/dist/target.d.ts +1 -1
  42. package/dist/target.js +5 -1
  43. package/dist/target.js.map +1 -1
  44. package/package.json +1 -1
@@ -2,6 +2,12 @@
2
2
  * Node-side mock outbound fetch gateway: match MSW handlers from
3
3
  * `.kody/mocks.ts`, optionally passthrough allowlisted hosts to real network,
4
4
  * otherwise fail closed with `unmocked_request` + a paste-ready handler stub.
5
+ *
6
+ * On `--target mock`, *every* outbound hop (ambient `fetch`, `credential().fetch`,
7
+ * `createAuthenticatedFetch` / `kody.authenticatedFetch`, and `kody.gatewayFetch`)
8
+ * goes through this gateway. Packages without `.kody/mocks.ts` use passthrough-all
9
+ * for ambient/gatewayFetch (public hosts only); authenticatedFetch still fails
10
+ * closed so leaky placeholder stubs never reach package code.
5
11
  */
6
12
  import { getResponse, isPassthroughResponse } from 'msw';
7
13
  import { StructuredCliError } from '../structured-error.js';
@@ -19,9 +25,12 @@ export function parsePassthroughHosts(raw) {
19
25
  export function createMockFetchGateway(input) {
20
26
  const passthroughHosts = input.passthroughHosts ?? [];
21
27
  const allowPrivateNetwork = input.allowPrivateNetwork === true;
28
+ const passthroughAll = input.passthroughAll === true;
22
29
  const fetchFn = input.fetchFn ?? fetch;
30
+ const mode = passthroughAll ? 'passthrough-all' : 'msw';
23
31
  return {
24
- enabled: true,
32
+ enabled: !passthroughAll,
33
+ mode,
25
34
  handlers: input.handlers,
26
35
  passthroughHosts,
27
36
  allowPrivateNetwork,
@@ -31,6 +40,21 @@ export function createMockFetchGateway(input) {
31
40
  handlers: input.handlers,
32
41
  passthroughHosts,
33
42
  allowPrivateNetwork,
43
+ passthroughAll,
44
+ request,
45
+ fetchFn,
46
+ signal,
47
+ });
48
+ },
49
+ handleAuthenticatedFetch: async (args, signal) => {
50
+ const request = readAuthenticatedFetchRequest(args);
51
+ // Authenticated / OAuth hops never get a fake stub. Without an MSW
52
+ // match (or explicit --passthrough host), fail closed.
53
+ return await dispatchMockGatewayFetch({
54
+ handlers: input.handlers,
55
+ passthroughHosts,
56
+ allowPrivateNetwork,
57
+ passthroughAll: false,
34
58
  request,
35
59
  fetchFn,
36
60
  signal,
@@ -62,8 +86,32 @@ export async function dispatchMockGatewayFetch(input) {
62
86
  fix: 'Use an absolute https:// URL in package code under --target mock.',
63
87
  });
64
88
  }
65
- if (hostMatchesPassthrough(parsed.hostname, input.passthroughHosts)) {
66
- assertPassthroughAllowed(parsed, input.allowPrivateNetwork);
89
+ const passthrough = input.passthroughAll === true ||
90
+ hostMatchesPassthrough(parsed.hostname, input.passthroughHosts);
91
+ // MSW handlers may target private hosts without --allow-private-network.
92
+ // Real network (passthrough) still requires the flag for private/local hosts.
93
+ if (!passthrough && input.handlers.length > 0) {
94
+ const headers = new Headers(input.request.headers ?? {});
95
+ const body = input.request.bodyBase64 != null && input.request.bodyBase64 !== ''
96
+ ? Buffer.from(input.request.bodyBase64, 'base64')
97
+ : undefined;
98
+ const requestInit = {
99
+ method,
100
+ headers,
101
+ ...(body !== undefined && method !== 'GET' && method !== 'HEAD'
102
+ ? { body }
103
+ : {}),
104
+ signal: input.signal,
105
+ };
106
+ const request = new Request(parsed.href, requestInit);
107
+ const response = await getResponse([...input.handlers], request);
108
+ if (response && !isPassthroughResponse(response)) {
109
+ return await serializeResponse(response);
110
+ }
111
+ throw unmockedRequestError(method, parsed.href);
112
+ }
113
+ if (passthrough) {
114
+ assertOutboundAllowed(parsed, input.allowPrivateNetwork);
67
115
  return await realNetworkFetch({
68
116
  request: input.request,
69
117
  method,
@@ -72,24 +120,8 @@ export async function dispatchMockGatewayFetch(input) {
72
120
  signal: input.signal,
73
121
  });
74
122
  }
75
- const headers = new Headers(input.request.headers ?? {});
76
- const body = input.request.bodyBase64 != null && input.request.bodyBase64 !== ''
77
- ? Buffer.from(input.request.bodyBase64, 'base64')
78
- : undefined;
79
- const requestInit = {
80
- method,
81
- headers,
82
- ...(body !== undefined && method !== 'GET' && method !== 'HEAD'
83
- ? { body }
84
- : {}),
85
- signal: input.signal,
86
- };
87
- const request = new Request(parsed.href, requestInit);
88
- const response = await getResponse([...input.handlers], request);
89
- if (!response || isPassthroughResponse(response)) {
90
- throw unmockedRequestError(method, parsed.href);
91
- }
92
- return await serializeResponse(response);
123
+ assertOutboundAllowed(parsed, input.allowPrivateNetwork);
124
+ throw unmockedRequestError(method, parsed.href);
93
125
  }
94
126
  function readGatewayRequest(args) {
95
127
  const record = args && typeof args === 'object' && !Array.isArray(args)
@@ -107,6 +139,22 @@ function readGatewayRequest(args) {
107
139
  bodyBase64: typeof nested.bodyBase64 === 'string' ? nested.bodyBase64 : undefined,
108
140
  };
109
141
  }
142
+ function readAuthenticatedFetchRequest(args) {
143
+ const record = args && typeof args === 'object' && !Array.isArray(args)
144
+ ? args
145
+ : {};
146
+ const nested = record.request && typeof record.request === 'object' && !Array.isArray(record.request)
147
+ ? record.request
148
+ : record;
149
+ return {
150
+ url: typeof nested.url === 'string' ? nested.url : undefined,
151
+ method: typeof nested.method === 'string' ? nested.method : undefined,
152
+ headers: nested.headers && typeof nested.headers === 'object' && !Array.isArray(nested.headers)
153
+ ? nested.headers
154
+ : undefined,
155
+ bodyBase64: typeof nested.bodyBase64 === 'string' ? nested.bodyBase64 : undefined,
156
+ };
157
+ }
110
158
  export function hostMatchesPassthrough(hostname, hosts) {
111
159
  const target = hostname.toLowerCase();
112
160
  return hosts.some((entry) => {
@@ -120,36 +168,40 @@ export function hostMatchesPassthrough(hostname, hosts) {
120
168
  return target === normalized;
121
169
  });
122
170
  }
123
- function assertPassthroughAllowed(url, allowPrivateNetwork) {
171
+ /** Refuse private/local hosts unless `--allow-private-network` (clear error). */
172
+ export function assertOutboundAllowed(url, allowPrivateNetwork) {
124
173
  if (allowPrivateNetwork)
125
174
  return;
126
175
  if (url.protocol !== 'http:' && url.protocol !== 'https:') {
127
176
  throw new StructuredCliError({
128
177
  code: 'unmocked_request',
129
- message: `Passthrough refused for non-http(s) URL ${url.href}.`,
178
+ message: `Mock outbound fetch refused for non-http(s) URL ${url.href}.`,
130
179
  target: 'mock',
131
180
  where: url.href,
181
+ fix: 'Use http(s) URLs, or mock this request in .kody/mocks.ts.',
132
182
  });
133
183
  }
134
- const host = url.hostname.toLowerCase();
135
- const privateHost = host === 'localhost' ||
136
- host === '127.0.0.1' ||
137
- host === '::1' ||
138
- host === '[::1]' ||
139
- host.endsWith('.local') ||
140
- /^10\./.test(host) ||
141
- /^192\.168\./.test(host) ||
142
- /^172\.(1[6-9]|2\d|3[0-1])\./.test(host);
143
- if (privateHost) {
184
+ if (isPrivateOrLocalHost(url.hostname)) {
144
185
  throw new StructuredCliError({
145
186
  code: 'unmocked_request',
146
- message: `Passthrough to private/local host ${JSON.stringify(host)} requires --allow-private-network.`,
187
+ message: `Blocked private/local fetch to ${JSON.stringify(url.hostname)} under --target mock.`,
147
188
  target: 'mock',
148
189
  where: url.href,
149
- fix: 'Add --allow-private-network, or mock this host in .kody/mocks.ts instead of --passthrough.',
190
+ fix: 'Pass --allow-private-network, or mock this host in .kody/mocks.ts instead of hitting the private network.',
150
191
  });
151
192
  }
152
193
  }
194
+ export function isPrivateOrLocalHost(hostname) {
195
+ const host = hostname.toLowerCase();
196
+ return (host === 'localhost' ||
197
+ host === '127.0.0.1' ||
198
+ host === '::1' ||
199
+ host === '[::1]' ||
200
+ host.endsWith('.local') ||
201
+ /^10\./.test(host) ||
202
+ /^192\.168\./.test(host) ||
203
+ /^172\.(1[6-9]|2\d|3[0-1])\./.test(host));
204
+ }
153
205
  async function realNetworkFetch(input) {
154
206
  const headers = new Headers(input.request.headers ?? {});
155
207
  // Credentials stay fake on mock — never forward opaque credential handles
@@ -212,31 +264,49 @@ function safeHost(url) {
212
264
  return 'example.com';
213
265
  }
214
266
  }
215
- /** Bridge interceptor: handle `kody.gatewayFetch` when a mock gateway is active. */
267
+ /**
268
+ * Bridge interceptor: handle `kody.gatewayFetch` and `kody.authenticatedFetch`
269
+ * when a mock gateway is active (always on `--target mock`).
270
+ */
216
271
  export function tryHandleMockGatewayFetchCall(input) {
217
- if (!input.gateway?.enabled)
272
+ if (!input.gateway)
218
273
  return null;
219
- if (input.path.join('.') !== 'kody.gatewayFetch')
220
- return null;
221
- return input.gateway.handle(input.args[0], input.signal);
274
+ const pathKey = input.path.join('.');
275
+ if (pathKey === 'kody.gatewayFetch') {
276
+ return input.gateway.handle(input.args[0], input.signal);
277
+ }
278
+ if (pathKey === 'kody.authenticatedFetch') {
279
+ return input.gateway.handleAuthenticatedFetch(input.args[0], input.signal);
280
+ }
281
+ return null;
222
282
  }
223
283
  /**
224
- * Load `.kody/mocks.ts` only for `--target mock` when the file exists.
225
- * Packages without the file keep native workerd fetch (no shim).
284
+ * Always build a mock fetch gateway for `--target mock`.
285
+ * With `.kody/mocks.ts`: MSW fail-closed (+ `--passthrough`).
286
+ * Without: public-network passthrough for ambient/gatewayFetch; authenticatedFetch
287
+ * still fails closed (no placeholder stubs).
226
288
  */
227
289
  export async function resolveMockFetchGateway(input) {
228
290
  if (input.target !== 'mock')
229
291
  return undefined;
230
- if (!input.packageRoot)
231
- return undefined;
232
- const loaded = await loadPackageMocks(input.packageRoot);
233
- if (!loaded)
234
- return undefined;
235
- input.onStatus?.(`Loaded ${loaded.handlers.length} MSW handler${loaded.handlers.length === 1 ? '' : 's'} from .kody/mocks.ts (outbound fetch fail-closed on mock).`);
292
+ const loaded = input.packageRoot ? await loadPackageMocks(input.packageRoot) : null;
293
+ if (loaded) {
294
+ input.onStatus?.(`Loaded ${loaded.handlers.length} MSW handler${loaded.handlers.length === 1 ? '' : 's'} from .kody/mocks.ts (outbound fetch fail-closed on mock).`);
295
+ return createMockFetchGateway({
296
+ handlers: loaded.handlers,
297
+ passthroughHosts: input.passthroughHosts,
298
+ allowPrivateNetwork: input.allowPrivateNetwork,
299
+ passthroughAll: false,
300
+ });
301
+ }
302
+ if (input.passthroughHosts?.length) {
303
+ input.onStatus?.(`No .kody/mocks.ts — --passthrough hosts are unused until you add MSW handlers (ambient fetch uses public-network passthrough on mock).`);
304
+ }
236
305
  return createMockFetchGateway({
237
- handlers: loaded.handlers,
306
+ handlers: [],
238
307
  passthroughHosts: input.passthroughHosts,
239
308
  allowPrivateNetwork: input.allowPrivateNetwork,
309
+ passthroughAll: true,
240
310
  });
241
311
  }
242
312
  //# sourceMappingURL=mock-fetch-gateway.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mock-fetch-gateway.js","sourceRoot":"","sources":["../../src/mock/mock-fetch-gateway.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAuB,MAAM,KAAK,CAAA;AAC7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAE3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAyB1D,MAAM,UAAU,qBAAqB,CAAC,GAAuB;IAC5D,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE;QAAE,OAAO,EAAE,CAAA;IAC3B,OAAO;QACN,GAAG,IAAI,GAAG,CACT,GAAG;aACD,KAAK,CAAC,GAAG,CAAC;aACV,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;aACxC,MAAM,CAAC,OAAO,CAAC,CACjB;KACD,CAAA;AACF,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,KAKtC;IACA,MAAM,gBAAgB,GAAG,KAAK,CAAC,gBAAgB,IAAI,EAAE,CAAA;IACrD,MAAM,mBAAmB,GAAG,KAAK,CAAC,mBAAmB,KAAK,IAAI,CAAA;IAC9D,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,IAAI,KAAK,CAAA;IACtC,OAAO;QACN,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,gBAAgB;QAChB,mBAAmB;QACnB,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;YAC9B,M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AAC,MAAM,KAAK,MAAM;QAAE,OAAO,SAAS,CAAA;IAC7C,MAAM,MAAM,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,gBAAgB,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;IACnF,IAAI,MAAM,EAAE,CAAC;QACZ,KAAK,CAAC,QAAQ,EAAE,CACf,UAAU,MAAM,CAAC,QAAQ,CAAC,MAAM,eAAe,MAAM,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,4DAA4D,CAClJ,CAAA;QACD,OAAO,sBAAsB,CAAC;YAC7B,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;YACxC,mBAAmB,EAAE,KAAK,CAAC,mBAAmB;YAC9C,cAAc,EAAE,KAAK;SACrB,CAAC,CAAA;IACH,CAAC;IACD,IAAI,KAAK,CAAC,gBAAgB,EAAE,MAAM,EAAE,CAAC;QACpC,KAAK,CAAC,QAAQ,EAAE,CACf,wIAAwI,CACxI,CAAA;IACF,CAAC;IACD,OAAO,sBAAsB,CAAC;QAC7B,QAAQ,EAAE,EAAE;QACZ,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;QACxC,mBAAmB,EAAE,KAAK,CAAC,mBAAmB;QAC9C,cAAc,EAAE,IAAI;KACpB,CAAC,CAAA;AACH,CAAC"}
@@ -11,6 +11,8 @@ export type MockServerOptions = {
11
11
  port?: number;
12
12
  /** Fixed package id for scratch packageStorage in local package runs. */
13
13
  packageId?: string;
14
+ /** `--org` slug reflected by metaGetCurrentUser on mock. */
15
+ orgSlug?: string;
14
16
  env?: NodeJS.ProcessEnv;
15
17
  };
16
18
  export type MockServer = {
@@ -29,6 +31,7 @@ export declare function ensureMockTarget(input: {
29
31
  sessionId?: string;
30
32
  resetStorage?: boolean;
31
33
  packageId?: string;
34
+ orgSlug?: string;
32
35
  env?: NodeJS.ProcessEnv;
33
36
  /** Reuse an already-started server (e.g. long-lived `kody dev`). */
34
37
  existing?: MockServer;
@@ -6,7 +6,7 @@
6
6
  import { createServer, } from 'node:http';
7
7
  import { notImplementedInMock, StructuredCliError } from '../structured-error.js';
8
8
  import { isMockCapabilityPath, isMockOpenApiOperation, mockOpenApiOperationIds, } from './mock-supported.js';
9
- import { loadMockSession, packageStorageDelete, packageStorageGet, packageStorageList, packageStorageSet, persistMockSession, } from './mock-storage.js';
9
+ import { closePackageSqlDbsForSession, defaultMockSessionId, loadMockSession, packageStorageDelete, packageStorageGet, packageStorageList, packageStorageSet, packageStorageSql, persistMockSession, } from './mock-storage.js';
10
10
  const mockTokenPrefix = 'kody_mock_';
11
11
  export function isMockApiToken(token) {
12
12
  return token.startsWith(mockTokenPrefix) || token === 'mock';
@@ -16,20 +16,30 @@ export function mintMockApiToken(sessionId) {
16
16
  return `${mockTokenPrefix}${sessionId}`;
17
17
  }
18
18
  export async function startMockServer(options = {}) {
19
+ const sessionIdForClose = options.sessionId?.trim() || defaultMockSessionId(options.env ?? process.env);
20
+ if (options.resetStorage) {
21
+ // Close SQLite handles before wiping the session directory so reset
22
+ // does not leave a live connection to a deleted file.
23
+ closePackageSqlDbsForSession(sessionIdForClose);
24
+ }
19
25
  let state = await loadMockSession({
20
26
  sessionId: options.sessionId,
21
27
  env: options.env,
22
28
  reset: options.resetStorage,
23
29
  });
24
30
  const packageId = options.packageId ?? `local-${state.sessionId}`;
31
+ const orgSlug = options.orgSlug?.trim() || 'mock-org';
32
+ const env = options.env;
25
33
  const server = createServer((req, res) => {
26
34
  void handleRequest(req, res, {
27
35
  getState: () => state,
28
36
  setState: async (next) => {
29
37
  state = next;
30
- await persistMockSession(state, options.env);
38
+ await persistMockSession(state, env);
31
39
  },
32
40
  packageId,
41
+ orgSlug,
42
+ env,
33
43
  });
34
44
  });
35
45
  const host = options.host ?? '127.0.0.1';
@@ -64,6 +74,7 @@ export async function ensureMockTarget(input) {
64
74
  sessionId: input.sessionId,
65
75
  resetStorage: input.resetStorage,
66
76
  packageId: input.packageId,
77
+ orgSlug: input.orgSlug,
67
78
  env: input.env,
68
79
  });
69
80
  return {
@@ -78,6 +89,9 @@ async function handleRequest(req, res, ctx) {
78
89
  const url = new URL(req.url ?? '/', 'http://127.0.0.1');
79
90
  const method = (req.method ?? 'GET').toUpperCase();
80
91
  const body = await readJsonBody(req);
92
+ const requestOrg = url.searchParams.get('org')?.trim() || undefined;
93
+ const effectiveOrg = requestOrg || ctx.orgSlug;
94
+ const callCtx = { ...ctx, orgSlug: effectiveOrg };
81
95
  if (method === 'GET' && url.pathname === '/openapi.json') {
82
96
  return sendJson(res, 200, mockOpenApiDocument());
83
97
  }
@@ -104,12 +118,13 @@ async function handleRequest(req, res, ctx) {
104
118
  return sendJson(res, 501, { error: err.toJSON() });
105
119
  }
106
120
  try {
107
- const result = await dispatchCapabilityCall(pathKey, args, ctx);
121
+ const result = await dispatchCapabilityCall(pathKey, args, callCtx);
108
122
  return sendJson(res, 200, { result });
109
123
  }
110
124
  catch (error) {
111
125
  if (error instanceof StructuredCliError) {
112
- return sendJson(res, 501, { error: error.toJSON() });
126
+ const status = error.code === 'unmocked_request' ? 400 : 501;
127
+ return sendJson(res, status, { error: error.toJSON() });
113
128
  }
114
129
  throw error;
115
130
  }
@@ -130,11 +145,11 @@ async function handleRequest(req, res, ctx) {
130
145
  assertMockAuth(req);
131
146
  const query = url.searchParams.get('query') ?? '';
132
147
  const entity = url.searchParams.get('entity') ?? undefined;
133
- return sendJson(res, 200, mockSearch(ctx.getState(), { query, entity }));
148
+ return sendJson(res, 200, mockSearch(callCtx.getState(), { query, entity }));
134
149
  }
135
150
  if (method === 'GET' && url.pathname === '/v1/me') {
136
151
  assertMockAuth(req);
137
- return sendJson(res, 200, mockCurrentUser(ctx.getState()));
152
+ return sendJson(res, 200, mockCurrentUser(callCtx.getState(), callCtx.orgSlug));
138
153
  }
139
154
  // Generic Open API POST /v1/... by operation is not fully routed; refuse.
140
155
  if (url.pathname.startsWith('/v1/')) {
@@ -182,7 +197,7 @@ async function dispatchCapabilityCall(pathKey, args, ctx) {
182
197
  const state = ctx.getState();
183
198
  switch (pathKey) {
184
199
  case 'kody.metaGetCurrentUser':
185
- return mockCurrentUser(state);
200
+ return mockCurrentUser(state, ctx.orgSlug);
186
201
  case 'kody.search': {
187
202
  const params = (args[0] ?? {});
188
203
  return mockSearch(state, params);
@@ -223,6 +238,15 @@ async function dispatchCapabilityCall(pathKey, args, ctx) {
223
238
  case 'kody.packageStorageList': {
224
239
  return { entries: packageStorageList(state, ctx.packageId) };
225
240
  }
241
+ case 'kody.__mockPackageStorageSql':
242
+ case 'kody.packageStorageSql': {
243
+ const input = (args[0] ?? {});
244
+ const query = String(input.query ?? '');
245
+ if (!query.trim()) {
246
+ throw new Error('packageStorage().sql requires a non-empty query string.');
247
+ }
248
+ return packageStorageSql(state, ctx.packageId, query, Array.isArray(input.bindings) ? input.bindings : [], ctx.env);
249
+ }
226
250
  case 'kody.credentialClientOpen': {
227
251
  const input = (args[0] ?? {});
228
252
  const key = String(input.key ?? input.name ?? args[0] ?? '').trim();
@@ -245,37 +269,76 @@ async function dispatchCapabilityCall(pathKey, args, ctx) {
245
269
  return { ok: true, value: { warnings: [], checked: args[0] ?? null, strict: false } };
246
270
  case 'kody.credentialClientRefresh':
247
271
  return { ok: true, value: { refreshed: false, mock: true } };
248
- case 'kody.authenticatedFetch': {
249
- const input = (args[0] ?? {});
250
- const providerName = String(input.providerName ?? '').trim() || 'unknown';
251
- const requestUrl = String(input.request?.url ?? '');
252
- const body = JSON.stringify(mockAuthenticatedFetchBody({
253
- providerName,
254
- url: requestUrl,
255
- method: String(input.request?.method ?? 'GET'),
256
- }));
257
- return {
258
- status: 200,
259
- statusText: 'OK',
260
- headers: { 'content-type': 'application/json; charset=utf-8' },
261
- bodyBase64: Buffer.from(body, 'utf8').toString('base64'),
262
- };
272
+ case 'kody.authenticatedFetch':
273
+ case 'kody.gatewayFetch': {
274
+ // Primary path is the Node MSW bridge (local-package-run / local-execute).
275
+ // If a call reaches the HTTP mock, fail closed — never return placeholder shapes.
276
+ const request = (args[0] ?? {});
277
+ const nested = request.request ?? request;
278
+ const method = String(nested.method ?? 'GET').toUpperCase();
279
+ const url = String(nested.url ?? '');
280
+ throw new StructuredCliError({
281
+ code: 'unmocked_request',
282
+ message: url
283
+ ? `Unmocked ${method} ${url} under --target mock.`
284
+ : `Unmocked ${pathKey} under --target mock (missing request.url).`,
285
+ target: 'mock',
286
+ where: url ? `${method} ${url}` : pathKey,
287
+ fix: 'Add a handler in .kody/mocks.ts for this URL, or pass --passthrough <host> for real network without secrets. createAuthenticatedFetch and credential().fetch go through the same MSW gateway.',
288
+ });
263
289
  }
264
290
  case 'kody.adminUserList': {
265
291
  const params = (args[0] ?? {});
292
+ const page = typeof params.page === 'number' ? params.page : 1;
293
+ const pageSize = typeof params.pageSize === 'number'
294
+ ? params.pageSize
295
+ : typeof params.limit === 'number'
296
+ ? params.limit
297
+ : 20;
266
298
  return {
299
+ total: 1,
300
+ page,
301
+ pageSize,
267
302
  users: [
268
303
  {
269
- id: 'user_mock',
304
+ stableUserId: 'user_mock',
270
305
  username: 'mock-user',
271
306
  email: 'mock@example.com',
272
- display_name: 'Mock User',
307
+ email_verified: true,
308
+ email_verified_at: '2026-01-01T00:00:00.000Z',
309
+ plan: 'free',
310
+ manualPlan: 'free',
311
+ stripePlan: null,
312
+ effectivePlan: 'free',
313
+ secondAgentGiftExpiresAt: null,
314
+ referralCreditExpiresAt: null,
315
+ overlayExpiresAt: null,
316
+ isProOverlay: false,
317
+ overlayType: null,
318
+ entitlementLadder: 'public',
319
+ stripeCustomerLinked: false,
320
+ suspended_at: null,
321
+ email_outbound_paused_at: null,
322
+ email_verification_delivery: null,
323
+ email_verification_delivery_detail: null,
324
+ utm_source: null,
325
+ utm_medium: null,
326
+ utm_campaign: null,
327
+ utm_content: null,
328
+ utm_term: null,
329
+ first_touch_landing_path: null,
330
+ first_touch_referrer: null,
331
+ first_mcp_connected_at: null,
332
+ first_execute_at: null,
333
+ first_search_at: null,
334
+ first_saved_package_at: null,
335
+ mcp_client_name: null,
336
+ last_active_at: null,
337
+ created_at: '2026-01-01T00:00:00.000Z',
338
+ updated_at: '2026-01-01T00:00:00.000Z',
339
+ roles: ['user'],
273
340
  },
274
341
  ],
275
- page: typeof params.page === 'number' ? params.page : 1,
276
- limit: typeof params.limit === 'number' ? params.limit : 20,
277
- total: 1,
278
- mock: true,
279
342
  };
280
343
  }
281
344
  default: {
@@ -312,40 +375,15 @@ function mockOpenedCredential(cred) {
312
375
  metadata: { mock: true },
313
376
  };
314
377
  }
315
- /** Provider-shaped fixtures so OAuth packages can smoke end-to-end on mock. */
316
- function mockAuthenticatedFetchBody(input) {
317
- const provider = input.providerName.toLowerCase();
318
- if (provider === 'linkedin' || /linkedin\.com/i.test(input.url)) {
319
- return {
320
- sub: 'mock-linkedin-sub',
321
- name: 'Mock LinkedIn User',
322
- email: 'mock-linkedin@example.com',
323
- picture: null,
324
- mock: true,
325
- providerName: input.providerName,
326
- url: input.url,
327
- method: input.method,
328
- };
329
- }
330
- return {
331
- mock: true,
332
- providerName: input.providerName,
333
- url: input.url,
334
- method: input.method,
335
- note: 'CLI mock authenticatedFetch fixture — not a real OAuth upstream response.',
336
- };
337
- }
338
- function mockCurrentUser(state) {
378
+ /** Prod-shaped identity (flat user_id); honors `--org` / `?org=` on mock. */
379
+ function mockCurrentUser(state, orgSlug) {
339
380
  return {
340
- user: {
341
- id: 'user_mock',
342
- username: 'mock-user',
343
- email: 'mock@example.com',
344
- },
381
+ user_id: 'user_mock',
382
+ username: 'mock-user',
383
+ email: 'mock@example.com',
384
+ display_name: 'Mock User',
345
385
  org: {
346
- id: 'org_mock',
347
- slug: 'mock-org',
348
- name: 'Mock Org',
386
+ slug: orgSlug || 'mock-org',
349
387
  },
350
388
  mockSessionId: state.sessionId,
351
389
  };