theokit 0.32.0 → 0.33.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 (53) hide show
  1. package/dist/{actions-virtual-module-LQDTEZKE.js → actions-virtual-module-AX6UMYF5.js} +2 -2
  2. package/dist/{actions-virtual-module-2F6LRE5F.js → actions-virtual-module-BCN7IEQC.js} +3 -3
  3. package/dist/{agent-KKKCDX4G.js → agent-4FJK6PRR.js} +3 -3
  4. package/dist/{app-typed-client-ZLHVLV7H.js → app-typed-client-LM2PNOCL.js} +3 -3
  5. package/dist/{app-typed-client-ZMGRQHIV.js → app-typed-client-U3OCOWYT.js} +2 -2
  6. package/dist/{build-WTULINA6.js → build-J6N4BQMF.js} +4 -4
  7. package/dist/{chunk-C55YF22U.js → chunk-5VRQVXHH.js} +6 -6
  8. package/dist/{chunk-FAU5PMAD.js → chunk-F46GSPV7.js} +3 -3
  9. package/dist/{chunk-X2MHT456.js → chunk-IHJZPQEF.js} +5 -2
  10. package/dist/chunk-IHJZPQEF.js.map +1 -0
  11. package/dist/{chunk-5ZS6RLVY.js → chunk-L4GCEMNW.js} +5 -2
  12. package/dist/chunk-L4GCEMNW.js.map +1 -0
  13. package/dist/{chunk-APQ62PWQ.js → chunk-NQRNDPZJ.js} +2 -2
  14. package/dist/{chunk-5IRPHJUC.js → chunk-OOS5LB5Y.js} +6 -6
  15. package/dist/cli/index.js +7 -7
  16. package/dist/{dev-7TXAFVYS.js → dev-PESPUGQU.js} +4 -4
  17. package/dist/{dev-emit-CRBRIRE2.js → dev-emit-2DL3MCLM.js} +2 -2
  18. package/dist/{dev-emit-J2CSGYD2.js → dev-emit-XVTJXZGA.js} +3 -3
  19. package/dist/{generate-SRK37SUU.js → generate-RO3X63ZC.js} +48 -24
  20. package/dist/generate-RO3X63ZC.js.map +1 -0
  21. package/dist/index.js +2 -2
  22. package/dist/{internal-api-UYI3FED6.js → internal-api-CCRY3HN4.js} +3 -3
  23. package/dist/{internal-api-UPNE2M7I.js → internal-api-CS3AG7MT.js} +2 -2
  24. package/dist/{mcp-4A4B6QZH.js → mcp-FMZSFEEQ.js} +3 -3
  25. package/dist/{openapi-I4HCBSPY.js → openapi-2HVGJMSN.js} +3 -3
  26. package/dist/server/index.js +1 -1
  27. package/dist/server/scan/index.js +1 -1
  28. package/dist/{start-K4ZI4WO6.js → start-CHMKI2KH.js} +3 -3
  29. package/dist/vite-plugin/index.js +2 -2
  30. package/dist/{vite-plugin-PGLI5JQU.js → vite-plugin-T3EXDNQQ.js} +4 -4
  31. package/package.json +3 -3
  32. package/dist/chunk-5ZS6RLVY.js.map +0 -1
  33. package/dist/chunk-X2MHT456.js.map +0 -1
  34. package/dist/generate-SRK37SUU.js.map +0 -1
  35. /package/dist/{actions-virtual-module-LQDTEZKE.js.map → actions-virtual-module-AX6UMYF5.js.map} +0 -0
  36. /package/dist/{actions-virtual-module-2F6LRE5F.js.map → actions-virtual-module-BCN7IEQC.js.map} +0 -0
  37. /package/dist/{agent-KKKCDX4G.js.map → agent-4FJK6PRR.js.map} +0 -0
  38. /package/dist/{app-typed-client-ZLHVLV7H.js.map → app-typed-client-LM2PNOCL.js.map} +0 -0
  39. /package/dist/{app-typed-client-ZMGRQHIV.js.map → app-typed-client-U3OCOWYT.js.map} +0 -0
  40. /package/dist/{build-WTULINA6.js.map → build-J6N4BQMF.js.map} +0 -0
  41. /package/dist/{chunk-C55YF22U.js.map → chunk-5VRQVXHH.js.map} +0 -0
  42. /package/dist/{chunk-FAU5PMAD.js.map → chunk-F46GSPV7.js.map} +0 -0
  43. /package/dist/{chunk-APQ62PWQ.js.map → chunk-NQRNDPZJ.js.map} +0 -0
  44. /package/dist/{chunk-5IRPHJUC.js.map → chunk-OOS5LB5Y.js.map} +0 -0
  45. /package/dist/{dev-7TXAFVYS.js.map → dev-PESPUGQU.js.map} +0 -0
  46. /package/dist/{dev-emit-CRBRIRE2.js.map → dev-emit-2DL3MCLM.js.map} +0 -0
  47. /package/dist/{dev-emit-J2CSGYD2.js.map → dev-emit-XVTJXZGA.js.map} +0 -0
  48. /package/dist/{internal-api-UPNE2M7I.js.map → internal-api-CCRY3HN4.js.map} +0 -0
  49. /package/dist/{internal-api-UYI3FED6.js.map → internal-api-CS3AG7MT.js.map} +0 -0
  50. /package/dist/{mcp-4A4B6QZH.js.map → mcp-FMZSFEEQ.js.map} +0 -0
  51. /package/dist/{openapi-I4HCBSPY.js.map → openapi-2HVGJMSN.js.map} +0 -0
  52. /package/dist/{start-K4ZI4WO6.js.map → start-CHMKI2KH.js.map} +0 -0
  53. /package/dist/{vite-plugin-PGLI5JQU.js.map → vite-plugin-T3EXDNQQ.js.map} +0 -0
@@ -8,7 +8,7 @@ import "./chunk-VMEWD57H.js";
8
8
  import "./chunk-JQSKBMXP.js";
9
9
  import {
10
10
  scanServerActionsEnriched
11
- } from "./chunk-X2MHT456.js";
11
+ } from "./chunk-IHJZPQEF.js";
12
12
  import "./chunk-WSJKACWB.js";
13
13
  import "./chunk-ZEGYW52B.js";
14
14
  import "./chunk-JBCHWRKF.js";
@@ -221,4 +221,4 @@ export const actions = manifest
221
221
  export {
222
222
  actionsVirtualModule
223
223
  };
224
- //# sourceMappingURL=actions-virtual-module-LQDTEZKE.js.map
224
+ //# sourceMappingURL=actions-virtual-module-AX6UMYF5.js.map
@@ -2,8 +2,8 @@
2
2
  import "tsx/esm";
3
3
  import "./chunk-KXA37ONC.js";
4
4
  import "./chunk-WR4F4EEZ.js";
5
- import "./chunk-APQ62PWQ.js";
6
- import "./chunk-5ZS6RLVY.js";
5
+ import "./chunk-NQRNDPZJ.js";
6
+ import "./chunk-L4GCEMNW.js";
7
7
  import {
8
8
  scanServerActionsEnriched
9
9
  } from "./chunk-FRUEDJFX.js";
@@ -211,4 +211,4 @@ export const actions = manifest
211
211
  export {
212
212
  actionsVirtualModule
213
213
  };
214
- //# sourceMappingURL=actions-virtual-module-2F6LRE5F.js.map
214
+ //# sourceMappingURL=actions-virtual-module-BCN7IEQC.js.map
@@ -3,13 +3,13 @@ import "tsx/esm";
3
3
  import {
4
4
  agentCommand,
5
5
  createAgentSsrLoader
6
- } from "./chunk-FAU5PMAD.js";
6
+ } from "./chunk-F46GSPV7.js";
7
7
  import "./chunk-M6NMS5LR.js";
8
8
  import "./chunk-GDN3PXFH.js";
9
- import "./chunk-5ZS6RLVY.js";
9
+ import "./chunk-L4GCEMNW.js";
10
10
  import "./chunk-P37RZRFV.js";
11
11
  export {
12
12
  agentCommand,
13
13
  createAgentSsrLoader
14
14
  };
15
- //# sourceMappingURL=agent-KKKCDX4G.js.map
15
+ //# sourceMappingURL=agent-4FJK6PRR.js.map
@@ -4,8 +4,8 @@ import "./chunk-KXA37ONC.js";
4
4
  import "./chunk-WR4F4EEZ.js";
5
5
  import {
6
6
  generateManifest
7
- } from "./chunk-APQ62PWQ.js";
8
- import "./chunk-5ZS6RLVY.js";
7
+ } from "./chunk-NQRNDPZJ.js";
8
+ import "./chunk-L4GCEMNW.js";
9
9
  import {
10
10
  HTTP_METHODS
11
11
  } from "./chunk-FRUEDJFX.js";
@@ -286,4 +286,4 @@ export {
286
286
  emitClientDts,
287
287
  generateClientDts
288
288
  };
289
- //# sourceMappingURL=app-typed-client-ZLHVLV7H.js.map
289
+ //# sourceMappingURL=app-typed-client-LM2PNOCL.js.map
@@ -8,7 +8,7 @@ import "./chunk-VMEWD57H.js";
8
8
  import "./chunk-JQSKBMXP.js";
9
9
  import {
10
10
  generateManifest
11
- } from "./chunk-X2MHT456.js";
11
+ } from "./chunk-IHJZPQEF.js";
12
12
  import {
13
13
  HTTP_METHODS
14
14
  } from "./chunk-WSJKACWB.js";
@@ -296,4 +296,4 @@ export {
296
296
  emitClientDts,
297
297
  generateClientDts
298
298
  };
299
- //# sourceMappingURL=app-typed-client-ZMGRQHIV.js.map
299
+ //# sourceMappingURL=app-typed-client-U3OCOWYT.js.map
@@ -25,8 +25,8 @@ import {
25
25
  import {
26
26
  generateManifest,
27
27
  writeManifest as writeManifest2
28
- } from "./chunk-APQ62PWQ.js";
29
- import "./chunk-5ZS6RLVY.js";
28
+ } from "./chunk-NQRNDPZJ.js";
29
+ import "./chunk-L4GCEMNW.js";
30
30
  import "./chunk-FRUEDJFX.js";
31
31
  import {
32
32
  walkSourceFiles
@@ -531,7 +531,7 @@ async function buildCommand(options) {
531
531
  `);
532
532
  }
533
533
  async function runAdapterBuild(target, config, cwd) {
534
- const { theoPluginAsync } = await import("./vite-plugin-PGLI5JQU.js");
534
+ const { theoPluginAsync } = await import("./vite-plugin-T3EXDNQQ.js");
535
535
  const { default: react } = await import("@vitejs/plugin-react");
536
536
  const ctx = {
537
537
  // `react()` may return Plugin or Plugin[] depending on version; spread the
@@ -616,4 +616,4 @@ function relativize3(absPath, root) {
616
616
  export {
617
617
  buildCommand
618
618
  };
619
- //# sourceMappingURL=build-WTULINA6.js.map
619
+ //# sourceMappingURL=build-J6N4BQMF.js.map
@@ -40,7 +40,7 @@ import {
40
40
  scanServerActions,
41
41
  scanServerRoutes,
42
42
  scanWebSocketRoutes
43
- } from "./chunk-X2MHT456.js";
43
+ } from "./chunk-IHJZPQEF.js";
44
44
  import {
45
45
  CSP_REPORT_PATH,
46
46
  CsrfReadinessStore,
@@ -2356,7 +2356,7 @@ async function runConfigureServer(server, ctx) {
2356
2356
  server.watcher.on("unlink", handleRouteChange);
2357
2357
  if (ctx.resolvedOpenApi !== void 0) {
2358
2358
  const openApiCfg = ctx.resolvedOpenApi;
2359
- const { reEmitOpenApi } = await import("./dev-emit-CRBRIRE2.js");
2359
+ const { reEmitOpenApi } = await import("./dev-emit-2DL3MCLM.js");
2360
2360
  const openApiServerDir = ctx.serverDir;
2361
2361
  const openApiDistDir = resolve6(ctx.projectRoot, ctx.resolvedDistDir);
2362
2362
  const isRouteFileForOpenApi = (file) => file.startsWith(openApiServerDir) && /\.(ts|tsx|js|mjs)$/.test(file);
@@ -3344,19 +3344,19 @@ async function theoPluginAsync(rootOrOptions) {
3344
3344
  })
3345
3345
  );
3346
3346
  }
3347
- const { appTypedClientPlugin } = await import("./app-typed-client-ZMGRQHIV.js");
3347
+ const { appTypedClientPlugin } = await import("./app-typed-client-U3OCOWYT.js");
3348
3348
  const appClientPlugin = appTypedClientPlugin({
3349
3349
  cwd: projectRoot,
3350
3350
  serverDir: serverDirAbs,
3351
3351
  distDir: resolve9(projectRoot, ".theokit")
3352
3352
  });
3353
- const { actionsVirtualModule } = await import("./actions-virtual-module-LQDTEZKE.js");
3353
+ const { actionsVirtualModule } = await import("./actions-virtual-module-AX6UMYF5.js");
3354
3354
  const actionsPlugin = actionsVirtualModule({
3355
3355
  serverDir: serverDirAbs,
3356
3356
  distDir: resolve9(projectRoot, ".theokit")
3357
3357
  });
3358
3358
  const { agentsTypedClientPlugin } = await import("./agents-typed-client-MAAILRI6.js");
3359
- const { generateManifest } = await import("./internal-api-UPNE2M7I.js");
3359
+ const { generateManifest } = await import("./internal-api-CS3AG7MT.js");
3360
3360
  const agentsClientPlugin = agentsTypedClientPlugin({
3361
3361
  projectRoot,
3362
3362
  agentsDir: agentsDirName,
@@ -3539,4 +3539,4 @@ export {
3539
3539
  theoPluginAsync,
3540
3540
  theoPlugin
3541
3541
  };
3542
- //# sourceMappingURL=chunk-C55YF22U.js.map
3542
+ //# sourceMappingURL=chunk-5VRQVXHH.js.map
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-GDN3PXFH.js";
10
10
  import {
11
11
  scanAgents
12
- } from "./chunk-5ZS6RLVY.js";
12
+ } from "./chunk-L4GCEMNW.js";
13
13
 
14
14
  // src/server/agent/run-terminal-agent.ts
15
15
  import {
@@ -178,7 +178,7 @@ async function agentCommand(name, message, deps = {}) {
178
178
  async function createAgentSsrLoader(projectRoot) {
179
179
  const { createServer } = await import("vite");
180
180
  const react = (await import("@vitejs/plugin-react")).default;
181
- const { theoPluginAsync } = await import("./vite-plugin-PGLI5JQU.js");
181
+ const { theoPluginAsync } = await import("./vite-plugin-T3EXDNQQ.js");
182
182
  const { loadConfig } = await import("./load-config-3EAQTXPH.js");
183
183
  const config = await loadConfig(projectRoot);
184
184
  const theoPlugins = await theoPluginAsync({
@@ -212,4 +212,4 @@ export {
212
212
  agentCommand,
213
213
  createAgentSsrLoader
214
214
  };
215
- //# sourceMappingURL=chunk-FAU5PMAD.js.map
215
+ //# sourceMappingURL=chunk-F46GSPV7.js.map
@@ -166,7 +166,10 @@ var AGENT_SUBFOLDERS = /* @__PURE__ */ new Set([
166
166
  "connections",
167
167
  "subagents",
168
168
  "schedules",
169
- "sandbox"
169
+ "sandbox",
170
+ "workflows",
171
+ "evals",
172
+ "memory"
170
173
  ]);
171
174
  function scanAgents(projectRoot, agentsDirName = "agents") {
172
175
  const agentsDir = join2(projectRoot, agentsDirName);
@@ -521,4 +524,4 @@ export {
521
524
  writeManifest,
522
525
  loadManifest
523
526
  };
524
- //# sourceMappingURL=chunk-X2MHT456.js.map
527
+ //# sourceMappingURL=chunk-IHJZPQEF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/server/scan/action-scan.ts","../src/server/scan/agent-scan.ts","../src/server/scan/match.ts","../src/server/scan/scan.ts","../src/server/scan/detect-http-methods.ts","../src/server/scan/errors.ts","../src/server/scan/ws-scan.ts","../src/server/scan/manifest.ts"],"sourcesContent":["/* eslint-disable security/detect-non-literal-fs-filename --\n * Build-time scanner: walks `serverDir/actions/` derived from cwd.\n * No HTTP input ever reaches these fs calls.\n */\nimport { existsSync, readFileSync, statSync } from 'node:fs'\nimport { extname, join, relative } from 'node:path'\n\nimport { walkSourceFiles } from '../_internal/scan-walker.js'\n\nexport interface ActionNode {\n filePath: string\n actionPath: string\n}\n\n/**\n * Enriched manifest entry per plan g3-server-actions-and-useaction v1.2\n * § Phase 1 / T1.4 + ADR D4. Consumed by virtual module `@theo/actions`\n * (T3.1) and G4 devtools \"Actions\" tab (T5.1).\n */\nexport interface ActionManifestEntry {\n name: string\n filePath: string\n urlPath: string\n accept: 'form' | 'json'\n hasInput: boolean\n /**\n * P#4 plugin-forms shared-schema convention (per plan p4-plugin-forms v1.1 T1.1).\n * When present, points to an isomorphic schema file at\n * `<serverDir>/actions/schemas/<basename>.ts` exporting `export const schema = z.object(...)`.\n * Virtual module emits `import {schema} from '<schemaFilePath>'` + attaches as\n * `actions.X.__zodSchema` so client-side <TheoForm> can drive zodResolver.\n * Undefined when convention not followed (graceful degrade — TheoForm still\n * works via explicit `schema={...}` prop escape hatch).\n */\n schemaFilePath?: string\n}\n\n/**\n * EC-2: structured error for scan-time defects (name collision, reserved\n * identifier, etc.). Throw at scan time to fail loud — silent shadowing is\n * a security/correctness footgun.\n */\nexport class ActionScanError extends Error {\n readonly code: 'NAME_COLLISION' | 'RESERVED_NAME'\n readonly conflictingPaths: readonly string[]\n\n constructor(\n code: 'NAME_COLLISION' | 'RESERVED_NAME',\n message: string,\n conflictingPaths: readonly string[],\n ) {\n super(message)\n // T4.1 fix: identify class by name so serverErrorToEnvelope boundary\n // translator can route via class-name lookup (without this, runtime\n // `err.name` defaults to 'Error' and the meta.name diagnostic is wrong).\n this.name = 'ActionScanError'\n this.code = code\n this.conflictingPaths = conflictingPaths\n }\n}\n\nconst ACTION_EXTENSIONS = new Set(['.ts', '.tsx', '.js', '.jsx'])\nconst TEST_FILE_RE = /\\.(test|spec)\\.(ts|tsx|js|jsx)$/\nconst RESERVED_NAMES = new Set(['index', 'constructor', '__proto__', 'prototype', 'hasOwnProperty'])\n\n/**\n * Backward-compatible: original simple-shape scanner used by existing\n * consumers. Preserved verbatim; new consumers should call\n * `scanServerActionsEnriched`.\n */\nexport function scanServerActions(serverDir: string): ActionNode[] {\n const actionsDir = join(serverDir, 'actions')\n if (!existsSync(actionsDir) || !statSync(actionsDir).isDirectory()) {\n return []\n }\n\n const results: ActionNode[] = []\n walkSourceFiles(actionsDir, { extensions: ACTION_EXTENSIONS }, (absPath) => {\n if (TEST_FILE_RE.test(absPath)) return\n let rel = relative(actionsDir, absPath)\n rel = rel.replace(/\\\\/g, '/')\n rel = rel.slice(0, -extname(rel).length)\n results.push({\n filePath: absPath,\n actionPath: rel,\n })\n })\n return results\n}\n\n/**\n * Enriched scan: light AST detection of `accept: 'form'|'json'` + `input:`\n * presence via regex-after-comment-stripping (EC-9). Throws ActionScanError\n * on file/dir name collision (EC-2) or reserved JS identifier names.\n *\n * Output `ActionManifestEntry[]` is sorted by `name` for deterministic\n * `.theokit/actions-manifest.json` emission.\n */\nexport function scanServerActionsEnriched(serverDir: string): ActionManifestEntry[] {\n const actionsDir = join(serverDir, 'actions')\n if (!existsSync(actionsDir) || !statSync(actionsDir).isDirectory()) {\n return []\n }\n\n const seenNames = new Set<string>()\n const entries: ActionManifestEntry[] = []\n\n // Collect first; collision-check after the full walk.\n walkSourceFiles(actionsDir, { extensions: ACTION_EXTENSIONS }, (absPath) => {\n if (TEST_FILE_RE.test(absPath)) return\n const rel = relative(actionsDir, absPath).replace(/\\\\/g, '/')\n // P#4 plugin-forms — `schemas/` subdir holds isomorphic zod schemas\n // for the shared-schema convention (T1.1). NOT executable actions; skip.\n if (rel.startsWith('schemas/')) return\n const name = rel.slice(0, -extname(rel).length)\n\n const basename = name.includes('/') ? (name.split('/').pop() ?? name) : name\n if (RESERVED_NAMES.has(basename)) {\n throw new ActionScanError(\n 'RESERVED_NAME',\n `Reserved JS identifier \"${basename}\" cannot be an action name (${absPath})`,\n [absPath],\n )\n }\n // File-level collision (one file appearing twice) is impossible via the\n // walker; per-export collision check happens inside the export loop below.\n const source = readFileSync(absPath, 'utf8')\n const stripped = stripComments(source)\n const accept = /\\baccept\\s*:\\s*['\"]form['\"]/.test(stripped) ? 'form' : 'json'\n const hasInput = /\\binput\\s*:\\s*z\\./.test(stripped) || /\\binput\\s*:\\s*\\w+\\(/.test(stripped)\n\n // T7.1 wire fix — extract exports so the urlPath includes the second\n // segment required by action-middleware (`/api/__actions/<file>/<export>`).\n // Each named action export becomes its own manifest entry.\n // Proxy key on the EXPORT name (so consumers write `actions.saveMemory(input)`).\n // URL keeps the runtime 2-segment shape `/api/__actions/<file>/<export>`\n // expected by action-middleware. Cross-file export collisions become a\n // scan error to surface the ambiguity early.\n const exportNames = extractActionExportNames(stripped)\n // P#4 plugin-forms shared-schema convention: check for\n // `<actionsDir>/schemas/<basename>.ts` (or .tsx/.js/.jsx).\n // Skip when actions live in subdirs (`schemas/` is flat by convention).\n const schemaFilePath = name.includes('/') ? undefined : detectSchemaFile(actionsDir, basename)\n for (const exportName of exportNames) {\n const proxyKey = exportName === 'default' ? name : exportName\n if (seenNames.has(proxyKey)) {\n throw new ActionScanError(\n 'NAME_COLLISION',\n `Duplicate action proxy key \"${proxyKey}\" (two files export the same name)`,\n [absPath],\n )\n }\n seenNames.add(proxyKey)\n const entry: ActionManifestEntry = {\n name: proxyKey,\n filePath: absPath,\n urlPath: `/api/__actions/${name}/${exportName}`,\n accept,\n hasInput,\n }\n if (schemaFilePath !== undefined) {\n entry.schemaFilePath = schemaFilePath\n }\n entries.push(entry)\n }\n })\n\n // EC-2: detect file vs dir collisions (e.g., foo.ts AND foo/bar.ts).\n // After walk completes, any name that has children prefixed `name/` triggers collision.\n for (const entry of entries) {\n const childPrefix = `${entry.name}/`\n const conflictingChild = entries.find((other) => other.name.startsWith(childPrefix))\n if (conflictingChild) {\n throw new ActionScanError(\n 'NAME_COLLISION',\n `Action \"${entry.name}\" conflicts with directory of same name containing \"${conflictingChild.name}\"`,\n [entry.filePath, conflictingChild.filePath],\n )\n }\n }\n\n entries.sort((a, b) => {\n if (a.name < b.name) return -1\n if (a.name > b.name) return 1\n return 0\n })\n return entries\n}\n\n/**\n * Strip JavaScript line + block comments from source. Simple state machine\n * (does not parse strings — false positives if a comment marker appears\n * inside a string literal, but that's an acceptable trade-off for v1 vs\n * full AST parse).\n */\n/**\n * Extract action export names via regex over comment-stripped source.\n * Matches `export const <name> = defineAction(...)`, `export default\n * defineAction(...)`, and `export function <name>(...)` forms. Returns\n * `['default']` when no named action exports are found (best-effort fallback\n * for default-export shapes the regex misses).\n */\nfunction extractActionExportNames(stripped: string): string[] {\n const names = new Set<string>()\n const namedRe = /\\bexport\\s+(?:const|let|var|function\\*?)\\s+([a-zA-Z_$][\\w$]*)\\s*[=(]/g\n let m: RegExpExecArray | null\n while ((m = namedRe.exec(stripped)) !== null) {\n const name = m[1]\n if (typeof name === 'string' && name.length > 0) names.add(name)\n }\n if (/\\bexport\\s+default\\s+defineAction\\b/.test(stripped)) {\n names.add('default')\n }\n if (names.size === 0) names.add('default')\n return [...names]\n}\n\n/**\n * P#4 plugin-forms shared-schema convention helper (per plan p4-plugin-forms v1.1 T1.1).\n * Returns the resolved path to `<actionsDir>/schemas/<basename>.<ext>` if it exists.\n * Tries `.ts`, `.tsx`, `.js`, `.jsx` in that order. Returns undefined when no match.\n */\nfunction detectSchemaFile(actionsDir: string, basename: string): string | undefined {\n const schemasDir = join(actionsDir, 'schemas')\n if (!existsSync(schemasDir)) return undefined\n for (const ext of ['.ts', '.tsx', '.js', '.jsx']) {\n const candidate = join(schemasDir, `${basename}${ext}`)\n if (existsSync(candidate)) return candidate\n }\n return undefined\n}\n\nfunction stripComments(source: string): string {\n let out = ''\n let i = 0\n while (i < source.length) {\n const ch = source[i]\n const next = source[i + 1]\n if (ch === '/' && next === '/') {\n // Line comment: skip until newline\n while (i < source.length && source[i] !== '\\n') i++\n continue\n }\n if (ch === '/' && next === '*') {\n // Block comment: skip until */\n i += 2\n while (i < source.length - 1 && !(source[i] === '*' && source[i + 1] === '/')) i++\n i += 2\n continue\n }\n out += ch\n i++\n }\n return out\n}\n","/* eslint-disable security/detect-non-literal-fs-filename --\n * Build-time scanner: walks `<projectRoot>/agents/` derived from cwd.\n * No HTTP input ever reaches these fs calls.\n */\nimport { existsSync, statSync } from 'node:fs'\nimport { extname, join, relative } from 'node:path'\n\nimport { walkSourceFiles } from '../_internal/scan-walker.js'\n\nconst AGENT_EXTENSIONS = new Set(['.ts', '.tsx', '.js', '.jsx'])\n// Convention § 5: a co-located test file is not an agent.\nconst TEST_FILE = /\\.(test|spec)$/\n\n/**\n * Folder-semantic discovery (Eve-style \"file = identity\"): an agent may be a self-contained folder that\n * co-locates its composition — `agents/<name>/{index.ts, tools/, skills/, prompts/, lib/}`. Files INSIDE\n * these conventional sub-folders are that concern (a tool, a skill, a prompt, a helper), NOT a routed\n * agent, so the scanner skips any file whose path passes through one of them. Only `<name>.ts` or\n * `<name>/index.ts` is served at `/api/agents/<name>`. A flat file literally named `tools.ts` is still a\n * valid agent (the reserved names only apply to intermediate DIRECTORIES, never the agent file itself).\n */\nconst AGENT_SUBFOLDERS = new Set([\n 'tools',\n 'skills',\n 'prompts',\n 'lib',\n 'hooks',\n 'channels',\n 'connections',\n 'subagents',\n 'schedules',\n 'sandbox',\n 'workflows',\n 'evals',\n 'memory',\n])\n\n/**\n * A discovered agent file. `name` is the client-facing key; `agentPath` is the mounted\n * SSE route (M0/M1 `UIMessageStream`).\n */\nexport interface AgentNode {\n filePath: string\n agentPath: string\n name: string\n}\n\n/**\n * M2 — scan the TOP-LEVEL `agents/` convention (sibling of `server/`, per the LOCKED naming\n * decision). Mirrors `scanWebSocketRoutes`: one file → one endpoint, `index` stripped.\n */\nexport function scanAgents(projectRoot: string, agentsDirName = 'agents'): AgentNode[] {\n // `agentsDirName` (config `agentsDir`, default \"agents\") — the dir holding `<name>.ts` agent\n // definitions, relative to the project root. May be nested (e.g. \"core/agents\"). (#95 follow-up)\n const agentsDir = join(projectRoot, agentsDirName)\n if (!existsSync(agentsDir) || !statSync(agentsDir).isDirectory()) {\n return []\n }\n\n const results: AgentNode[] = []\n walkSourceFiles(agentsDir, { extensions: AGENT_EXTENSIONS }, (absPath) => {\n let rel = relative(agentsDir, absPath)\n rel = rel.replace(/\\\\/g, '/')\n rel = rel.slice(0, -extname(rel).length)\n if (TEST_FILE.test(rel)) return\n // Eve-style: a file living under a composition sub-folder (tools/, skills/, prompts/, …) is that\n // concern, not a routed agent. Check the intermediate DIRECTORIES only — the agent file itself may\n // be named anything.\n const dirs = rel.split('/').slice(0, -1)\n if (dirs.some((segment) => AGENT_SUBFOLDERS.has(segment))) return\n // Unlike routes/ws, an agent needs an explicit name — a bare `agents/index.ts`\n // (name `''` → `/api/agents/`) is nonsensical for a typed `useAgent(name)` binding.\n // `agents/foo/index.ts` still collapses to `foo` (a named nested agent).\n if (rel.endsWith('/index')) rel = rel.slice(0, -6)\n if (rel === 'index' || rel === '') return\n results.push({\n filePath: absPath,\n agentPath: `/api/agents/${rel}`,\n name: rel,\n })\n })\n return results\n}\n","export interface ServerRouteNode {\n filePath: string\n routePath: string\n paramNames: string[]\n pattern: RegExp\n /** HTTP methods (uppercase) the route file exports. Optional for backward\n * compatibility with manifests generated before G1. Empty array means the\n * file has no HTTP exports (util-only); undefined means \"not detected\". */\n methods?: string[]\n}\n\nexport function compilePattern(routePath: string): {\n pattern: RegExp\n paramNames: string[]\n} {\n const paramNames: string[] = []\n // Single pass: handle both catch-all (:...name) and regular (:name) params\n const regexStr = routePath.replace(/:(?:\\.\\.\\.)?([^/]+)/g, (match: string, name: string) => {\n paramNames.push(name)\n // Catch-all matches across slashes, regular matches single segment\n return match.startsWith(':...') ? '(.+)' : '([^/]+)'\n })\n // `regexStr` is derived from a developer-authored route path (build-time\n // input, not HTTP-controlled). The `security/detect-non-literal-regexp`\n // rule cannot see this constraint — disable narrowly.\n // eslint-disable-next-line security/detect-non-literal-regexp -- route pattern from build-time scan, never HTTP input\n return { pattern: new RegExp(`^${regexStr}$`), paramNames }\n}\n\nexport function matchRoute(\n url: string,\n routes: ServerRouteNode[],\n): { route: ServerRouteNode; params: Record<string, string> } | null {\n // Strip query string and trailing slash\n let path = url.split('?')[0]\n if (path.length > 1 && path.endsWith('/')) {\n path = path.slice(0, -1)\n }\n\n for (const route of routes) {\n const match = route.pattern.exec(path)\n if (match) {\n const params: Record<string, string> = {}\n route.paramNames.forEach((name, i) => {\n params[name] = match[i + 1]\n })\n return { route, params }\n }\n }\n return null\n}\n","/* eslint-disable security/detect-non-literal-fs-filename --\n * Build-time scanner: walks `serverDir/routes/` derived from cwd.\n * No HTTP input ever reaches these fs calls.\n */\nimport { existsSync, statSync } from 'node:fs'\nimport { basename, extname, join, relative } from 'node:path'\n\nimport { walkSourceFiles } from '../_internal/scan-walker.js'\n\nimport { detectExportedHttpMethods } from './detect-http-methods.js'\nimport { RouterConventionError } from './errors.js'\nimport { compilePattern, type ServerRouteNode } from './match.js'\n\nconst ROUTE_EXTENSIONS = new Set(['.ts', '.tsx', '.js', '.jsx'])\n\n// EC-4: Co-located unit/spec tests must be silently skipped by the scanner,\n// BEFORE the dotted-basename check fires. Matches `*.test.ts|tsx|js|jsx`\n// and `*.spec.ts|tsx|js|jsx`.\nconst TEST_OR_SPEC_RE = /\\.(test|spec)\\.[jt]sx?$/\n\nfunction isTestOrSpecFile(filePath: string): boolean {\n return TEST_OR_SPEC_RE.test(basename(filePath))\n}\n\nfunction hasDotOutsideBrackets(segment: string): boolean {\n let depth = 0\n for (const ch of segment) {\n if (ch === '[') depth++\n else if (ch === ']') depth--\n else if (ch === '.' && depth === 0) return true\n }\n return false\n}\n\nfunction splitDottedSegmentOutsideBrackets(segment: string): string[] {\n const parts: string[] = []\n let current = ''\n let depth = 0\n for (const ch of segment) {\n if (ch === '[') {\n depth++\n current += ch\n } else if (ch === ']') {\n depth--\n current += ch\n } else if (ch === '.' && depth === 0) {\n if (current) parts.push(current)\n current = ''\n } else {\n current += ch\n }\n }\n if (current) parts.push(current)\n return parts\n}\n\nfunction buildDirectoryNestedSuggestion(filePath: string, routesDir: string): string {\n const rel = relative(routesDir, filePath).replace(/\\\\/g, '/')\n const ext = extname(rel)\n const withoutExt = rel.slice(0, -ext.length)\n const segments = withoutExt.split('/').flatMap(splitDottedSegmentOutsideBrackets)\n return `routes/${segments.join('/')}${ext}`\n}\n\nfunction assertNoDottedSegment(filePath: string, routesDir: string): void {\n const rel = relative(routesDir, filePath).replace(/\\\\/g, '/')\n const ext = extname(rel)\n const withoutExt = rel.slice(0, -ext.length)\n const segments = withoutExt.split('/')\n for (const seg of segments) {\n if (hasDotOutsideBrackets(seg)) {\n throw new RouterConventionError({\n file: filePath,\n suggestion: buildDirectoryNestedSuggestion(filePath, routesDir),\n })\n }\n }\n}\n\nfunction fileToRoutePath(filePath: string, routesDir: string): string {\n let rel = relative(routesDir, filePath)\n // Strip extension\n const ext = extname(rel)\n rel = rel.slice(0, -ext.length)\n // Normalize separators\n rel = rel.replace(/\\\\/g, '/')\n // Strip index suffix\n if (rel.endsWith('/index')) {\n rel = rel.slice(0, -6)\n } else if (rel === 'index') {\n rel = ''\n }\n // Replace [...param] with :...param (catch-all, before regular params).\n // Replace [param] with :param. Inputs are file paths bounded by the\n // OS filename limit; the bracket capture is bounded by `]`.\n rel = rel.replace(/\\[\\.\\.\\.([^\\]]+)\\]/g, ':...$1')\n // eslint-disable-next-line sonarjs/slow-regex -- bounded by `]`; input is a single filename\n rel = rel.replace(/\\[([^\\]]+)\\]/g, ':$1')\n return `/api/${rel}`\n}\n\nexport function scanServerRoutes(serverDir: string): ServerRouteNode[] {\n const routesDir = join(serverDir, 'routes')\n if (!existsSync(routesDir) || !statSync(routesDir).isDirectory()) {\n return []\n }\n\n const results: ServerRouteNode[] = []\n walkSourceFiles(routesDir, { extensions: ROUTE_EXTENSIONS }, (absPath) => {\n // EC-4: skip co-located test/spec files BEFORE the dotted-basename check\n if (isTestOrSpecFile(absPath)) return\n\n // G6 T1.1: reject dotted basenames (legacy convention that produced wrong\n // paramNames due to greedy `:(?:\\.\\.\\.)?([^/]+)` regex in compilePattern).\n assertNoDottedSegment(absPath, routesDir)\n\n const routePath = fileToRoutePath(absPath, routesDir)\n const { pattern, paramNames } = compilePattern(routePath)\n const methods = detectExportedHttpMethods(absPath)\n results.push({\n filePath: absPath,\n routePath,\n paramNames,\n pattern,\n methods,\n })\n })\n\n // T1.4 / EC-2 — refuse to scan if a user route collides with the reserved\n // batch endpoint path. User must rename or disable batching.\n const conflicting = results.find((r) => r.routePath === '/api/__theo_batch__')\n if (conflicting) {\n throw new Error(\n `Server route ${conflicting.filePath} resolves to '/api/__theo_batch__' which is reserved for the batch endpoint. Rename the route or disable batching in theo.config.ts.`,\n )\n }\n\n // Sort: static first, then dynamic, then catch-all last\n const isCatchAll = (route: ServerRouteNode) => route.routePath.includes(':...')\n results.sort((a, b) => {\n const aStatic = a.paramNames.length === 0\n const bStatic = b.paramNames.length === 0\n const aCatchAll = isCatchAll(a)\n const bCatchAll = isCatchAll(b)\n\n // Static routes first\n if (aStatic && !bStatic) return -1\n if (!aStatic && bStatic) return 1\n // Catch-all routes last\n if (aCatchAll && !bCatchAll) return 1\n if (!aCatchAll && bCatchAll) return -1\n return a.routePath.localeCompare(b.routePath)\n })\n\n return results\n}\n","/**\n * Detect which HTTP-method named exports a route file declares.\n *\n * Uses the TypeScript compiler API (not regex) per G1 edge-case review EC-4:\n * regex over file content emits false positives for `// export const GET = ...`\n * in comments and `` `export const GET = ...` `` in template literals. AST\n * walking avoids both classes of bug.\n *\n * `typescript` ships as CommonJS with internal dynamic `require('fs')`.\n * When loaded via ESM `import`, the dynamic requires fail at module-bootstrap.\n * We use `createRequire(import.meta.url)` to keep the package on its native\n * CJS path. The type-only namespace import gives us the AST helpers shape.\n *\n * Returns the set of HTTP methods (uppercase) the file exports. Empty array\n * means the file has no HTTP exports (the route file is util-only).\n */\n\nimport { readFileSync } from 'node:fs'\nimport { createRequire } from 'node:module'\n\nimport type * as TS from 'typescript'\n\nimport { HTTP_METHODS, type HttpMethod } from '../../core/contracts/http-methods.js'\n\nconst require_ = createRequire(import.meta.url)\n// eslint-disable-next-line @typescript-eslint/no-require-imports\nconst ts = require_('typescript') as typeof TS\n\nconst HTTP_METHOD_NAMES = new Set<string>(HTTP_METHODS)\n\nfunction hasExportModifier(modifiers: readonly TS.Modifier[] | undefined): boolean {\n if (!modifiers) return false\n for (const m of modifiers) {\n if (m.kind === ts.SyntaxKind.ExportKeyword) return true\n }\n return false\n}\n\nfunction collectFromStatement(stmt: TS.Statement, found: Set<HttpMethod>): void {\n // `export const GET = ...` / `export function GET ...` / `export async function GET ...`\n if (ts.isVariableStatement(stmt) && hasExportModifier(ts.getModifiers(stmt))) {\n for (const decl of stmt.declarationList.declarations) {\n if (ts.isIdentifier(decl.name) && HTTP_METHOD_NAMES.has(decl.name.text)) {\n found.add(decl.name.text as HttpMethod)\n }\n }\n return\n }\n\n if (\n (ts.isFunctionDeclaration(stmt) || ts.isClassDeclaration(stmt)) &&\n hasExportModifier(ts.getModifiers(stmt))\n ) {\n if (stmt.name && HTTP_METHOD_NAMES.has(stmt.name.text)) {\n found.add(stmt.name.text as HttpMethod)\n }\n return\n }\n\n // `export { GET }` / `export { handler as GET } from './shared'` (EC-5)\n if (ts.isExportDeclaration(stmt) && stmt.exportClause && ts.isNamedExports(stmt.exportClause)) {\n for (const spec of stmt.exportClause.elements) {\n // spec.name is the exported (re-)name; spec.propertyName is the original (when renamed)\n if (HTTP_METHOD_NAMES.has(spec.name.text)) {\n found.add(spec.name.text as HttpMethod)\n }\n }\n }\n}\n\nexport function detectExportedHttpMethods(filePath: string, content?: string): HttpMethod[] {\n const src = content ?? readFileSync(filePath, 'utf-8')\n const sourceFile = ts.createSourceFile(\n filePath,\n src,\n ts.ScriptTarget.Latest,\n /* setParentNodes */ false,\n ts.ScriptKind.TS,\n )\n const found = new Set<HttpMethod>()\n for (const stmt of sourceFile.statements) {\n collectFromStatement(stmt, found)\n }\n return [...found].sort()\n}\n","/**\n * Router-convention errors thrown by the server-route scanner.\n *\n * Plan: .claude/knowledge-base/plans/g6-router-convention-plan.md v1.1\n *\n * theokit 0.4.0+ enforces directory-nested file-system routing\n * (`auth/[provider]/login.ts`) and REJECTS dotted-basename routes\n * (`auth.[provider].login.ts`) because the legacy regex extracted the\n * dotted basename incorrectly — `params.provider` was undefined at request\n * time. Decision recorded in the plan above (`g6-router-convention-plan.md`) and CHANGELOG 0.4.0\n * (no standalone ADR was cut for this router-convention change).\n */\n\n/**\n * Canonical migration guide URL. T4.2 establishes this as the authoritative\n * landing page. EC-3: error message uses this constant so the URL never\n * drifts from the doc location.\n */\nexport const ROUTER_MIGRATION_GUIDE_URL = 'https://theokit.dev/migration/0.3-to-0.4-router'\n\nexport interface RouterConventionErrorOptions {\n /** Absolute path of the offending route file. */\n file: string\n /** Suggested directory-nested replacement path (relative, e.g. `routes/auth/[provider]/login.ts`). */\n suggestion: string\n /** Migration guide URL (defaults to `ROUTER_MIGRATION_GUIDE_URL`). */\n migrationUrl?: string\n}\n\n/**\n * Thrown by `scanServerRoutes` when a route file uses the legacy\n * dotted-basename convention (`auth.[provider].login.ts`).\n *\n * The error is FAIL-FAST by design — running with a route that has wrong\n * `paramNames` produces silent 404s at request time, which is strictly\n * worse than a build-time error.\n */\nexport class RouterConventionError extends Error {\n override readonly name = 'RouterConventionError'\n readonly file: string\n readonly suggestion: string\n readonly migrationUrl: string\n\n constructor(opts: RouterConventionErrorOptions) {\n const migrationUrl = opts.migrationUrl ?? ROUTER_MIGRATION_GUIDE_URL\n const message = [\n `Router convention violation: dotted route basename is not supported in theokit 0.4+.`,\n ``,\n ` File: ${opts.file}`,\n ` Use directory-nested form: ${opts.suggestion}`,\n ``,\n `Migration guide: ${migrationUrl}`,\n `Run \\`theokit migrate router\\` to convert all dotted basenames automatically.`,\n ].join('\\n')\n super(message)\n this.file = opts.file\n this.suggestion = opts.suggestion\n this.migrationUrl = migrationUrl\n }\n}\n","/* eslint-disable security/detect-non-literal-fs-filename --\n * Build-time scanner: walks `serverDir/ws/` derived from cwd.\n * No HTTP input ever reaches these fs calls.\n */\nimport { existsSync, statSync } from 'node:fs'\nimport { extname, join, relative } from 'node:path'\n\nimport { walkSourceFiles } from '../_internal/scan-walker.js'\n\nconst WS_EXTENSIONS = new Set(['.ts', '.tsx', '.js', '.jsx'])\n\nexport interface WebSocketRouteNode {\n filePath: string\n wsPath: string\n}\n\nexport function scanWebSocketRoutes(serverDir: string): WebSocketRouteNode[] {\n const wsDir = join(serverDir, 'ws')\n if (!existsSync(wsDir) || !statSync(wsDir).isDirectory()) {\n return []\n }\n\n const results: WebSocketRouteNode[] = []\n walkSourceFiles(wsDir, { extensions: WS_EXTENSIONS }, (absPath) => {\n let rel = relative(wsDir, absPath)\n rel = rel.replace(/\\\\/g, '/')\n rel = rel.slice(0, -extname(rel).length)\n if (rel.endsWith('/index')) rel = rel.slice(0, -6)\n else if (rel === 'index') rel = ''\n results.push({\n filePath: absPath,\n wsPath: `/ws/${rel}`,\n })\n })\n return results\n}\n","/* eslint-disable security/detect-non-literal-fs-filename --\n * Build-time manifest emitter / loader. All paths derived from `distDir`\n * + `serverDir`, themselves resolved from `process.cwd()`. No HTTP input.\n */\nimport { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs'\nimport { join, resolve, relative, dirname } from 'node:path'\n\nimport { scanServerActions } from './action-scan.js'\nimport type { ActionNode } from './action-scan.js'\nimport { scanAgents } from './agent-scan.js'\nimport type { AgentNode } from './agent-scan.js'\nimport { compilePattern } from './match.js'\nimport type { ServerRouteNode } from './match.js'\nimport { scanServerRoutes } from './scan.js'\nimport { scanWebSocketRoutes } from './ws-scan.js'\nimport type { WebSocketRouteNode } from './ws-scan.js'\n\n// --- Manifest Types ---\n\nexport interface ManifestRoute {\n filePath: string\n routePath: string\n paramNames: string[]\n /** HTTP methods (uppercase) the route file exports. Optional — manifests\n * generated before G1 omit this; loaders treat absence as \"unknown\". */\n methods?: string[]\n}\n\nexport interface ManifestAction {\n filePath: string\n actionPath: string\n}\n\nexport interface ManifestWebSocket {\n filePath: string\n wsPath: string\n}\n\n/** M2 — a top-level `agents/*.ts` convention entry. `filePath` is relative to the\n * project root (agents live OUTSIDE `serverDir`), unlike routes/actions/ws. */\nexport interface ManifestAgent {\n filePath: string\n agentPath: string\n name: string\n}\n\nexport interface TheoManifest {\n version: 1\n generatedAt: string\n routes: ManifestRoute[]\n actions: ManifestAction[]\n websockets: ManifestWebSocket[]\n /** M2 — optional for backward compat: manifests generated before M2 omit it. */\n agents?: ManifestAgent[]\n}\n\nexport interface LoadedManifest {\n routes: ServerRouteNode[]\n actions: ActionNode[]\n websockets: WebSocketRouteNode[]\n agents: AgentNode[]\n}\n\n// --- Generate ---\n\nexport function generateManifest(\n serverDir: string,\n // Agents live at `<projectRoot>/<agentsDir>`. Defaults to the server dir's parent; overridable\n // for tests / non-standard layouts.\n projectRoot: string = dirname(serverDir),\n // Agents dir NAME (config `agentsDir`, default \"agents\"), relative to projectRoot (#95 follow-up).\n agentsDir = 'agents',\n): TheoManifest {\n const routes = scanServerRoutes(serverDir)\n const actions = scanServerActions(serverDir)\n const websockets = scanWebSocketRoutes(serverDir)\n const agents = scanAgents(projectRoot, agentsDir)\n\n return {\n version: 1,\n generatedAt: new Date().toISOString(),\n routes: routes.map((r) => ({\n filePath: relative(serverDir, r.filePath),\n routePath: r.routePath,\n paramNames: r.paramNames,\n ...(r.methods !== undefined ? { methods: r.methods } : {}),\n })),\n actions: actions.map((a) => ({\n filePath: relative(serverDir, a.filePath),\n actionPath: a.actionPath,\n })),\n websockets: websockets.map((w) => ({\n filePath: relative(serverDir, w.filePath),\n wsPath: w.wsPath,\n })),\n agents: agents.map((a) => ({\n // Relative to projectRoot (agents/ is outside serverDir).\n filePath: relative(projectRoot, a.filePath),\n agentPath: a.agentPath,\n name: a.name,\n })),\n }\n}\n\n// --- Write ---\n\nexport function writeManifest(manifest: TheoManifest, outputDir: string): void {\n mkdirSync(outputDir, { recursive: true })\n const manifestPath = join(outputDir, 'manifest.json')\n writeFileSync(manifestPath, JSON.stringify(manifest, null, 2))\n}\n\n// --- Load ---\n\nexport function loadManifest(distDir: string, serverDir: string): LoadedManifest {\n const manifestPath = join(distDir, 'manifest.json')\n\n if (!existsSync(manifestPath)) {\n throw new Error(`No manifest found at ${manifestPath}. Run \"theo build\" first.`)\n }\n\n const raw = JSON.parse(readFileSync(manifestPath, 'utf-8')) as TheoManifest\n\n const routes: ServerRouteNode[] = raw.routes.map((r) => {\n const { pattern, paramNames } = compilePattern(r.routePath)\n return {\n filePath: resolve(serverDir, r.filePath),\n routePath: r.routePath,\n paramNames,\n pattern,\n ...(r.methods !== undefined ? { methods: r.methods } : {}),\n }\n })\n\n const actions: ActionNode[] = raw.actions.map((a) => ({\n filePath: resolve(serverDir, a.filePath),\n actionPath: a.actionPath,\n }))\n\n const websockets: WebSocketRouteNode[] = raw.websockets.map((w) => ({\n filePath: resolve(serverDir, w.filePath),\n wsPath: w.wsPath,\n }))\n\n // M2 — agents resolve relative to the project root (sibling of serverDir).\n // `?? []` keeps pre-M2 manifests (no `agents` field) loadable (fail-safe).\n const projectRoot = dirname(serverDir)\n const agents: AgentNode[] = (raw.agents ?? []).map((a) => ({\n filePath: resolve(projectRoot, a.filePath),\n agentPath: a.agentPath,\n name: a.name,\n }))\n\n return { routes, actions, websockets, agents }\n}\n"],"mappings":";;;;;;;;AAIA,SAAS,YAAY,cAAc,gBAAgB;AACnD,SAAS,SAAS,MAAM,gBAAgB;AAqCjC,IAAM,kBAAN,cAA8B,MAAM;AAAA,EAChC;AAAA,EACA;AAAA,EAET,YACE,MACA,SACA,kBACA;AACA,UAAM,OAAO;AAIb,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,mBAAmB;AAAA,EAC1B;AACF;AAEA,IAAM,oBAAoB,oBAAI,IAAI,CAAC,OAAO,QAAQ,OAAO,MAAM,CAAC;AAChE,IAAM,eAAe;AACrB,IAAM,iBAAiB,oBAAI,IAAI,CAAC,SAAS,eAAe,aAAa,aAAa,gBAAgB,CAAC;AAO5F,SAAS,kBAAkB,WAAiC;AACjE,QAAM,aAAa,KAAK,WAAW,SAAS;AAC5C,MAAI,CAAC,WAAW,UAAU,KAAK,CAAC,SAAS,UAAU,EAAE,YAAY,GAAG;AAClE,WAAO,CAAC;AAAA,EACV;AAEA,QAAM,UAAwB,CAAC;AAC/B,kBAAgB,YAAY,EAAE,YAAY,kBAAkB,GAAG,CAAC,YAAY;AAC1E,QAAI,aAAa,KAAK,OAAO,EAAG;AAChC,QAAI,MAAM,SAAS,YAAY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ACpD,gBAAc,cAAc,KAAK,UAAU,UAAU,MAAM,CAAC,CAAC;AAC/D;AAIO,SAAS,aAAa,SAAiB,WAAmC;AAC/E,QAAM,eAAeA,MAAK,SAAS,eAAe;AAElD,MAAI,CAACC,YAAW,YAAY,GAAG;AAC7B,UAAM,IAAI,MAAM,wBAAwB,YAAY,2BAA2B;AAAA,EACjF;AAEA,QAAM,MAAM,KAAK,MAAMC,cAAa,cAAc,OAAO,CAAC;AAE1D,QAAM,SAA4B,IAAI,OAAO,IAAI,CAAC,MAAM;AACtD,UAAM,EAAE,SAAS,WAAW,IAAI,eAAe,EAAE,SAAS;AAC1D,WAAO;AAAA,MACL,UAAU,QAAQ,WAAW,EAAE,QAAQ;AAAA,MACvC,WAAW,EAAE;AAAA,MACb;AAAA,MACA;AAAA,MACA,GAAI,EAAE,YAAY,SAAY,EAAE,SAAS,EAAE,QAAQ,IAAI,CAAC;AAAA,IAC1D;AAAA,EACF,CAAC;AAED,QAAM,UAAwB,IAAI,QAAQ,IAAI,CAAC,OAAO;AAAA,IACpD,UAAU,QAAQ,WAAW,EAAE,QAAQ;AAAA,IACvC,YAAY,EAAE;AAAA,EAChB,EAAE;AAEF,QAAM,aAAmC,IAAI,WAAW,IAAI,CAAC,OAAO;AAAA,IAClE,UAAU,QAAQ,WAAW,EAAE,QAAQ;AAAA,IACvC,QAAQ,EAAE;AAAA,EACZ,EAAE;AAIF,QAAM,cAAc,QAAQ,SAAS;AACrC,QAAM,UAAuB,IAAI,UAAU,CAAC,GAAG,IAAI,CAAC,OAAO;AAAA,IACzD,UAAU,QAAQ,aAAa,EAAE,QAAQ;AAAA,IACzC,WAAW,EAAE;AAAA,IACb,MAAM,EAAE;AAAA,EACV,EAAE;AAEF,SAAO,EAAE,QAAQ,SAAS,YAAY,OAAO;AAC/C;","names":["basename","existsSync","statSync","extname","join","relative","join","existsSync","statSync","relative","extname","existsSync","statSync","extname","join","relative","readFileSync","readFileSync","relative","extname","join","existsSync","statSync","existsSync","statSync","extname","join","relative","join","existsSync","statSync","relative","extname","existsSync","readFileSync","join","relative","relative","join","existsSync","readFileSync"]}
@@ -19,7 +19,10 @@ var AGENT_SUBFOLDERS = /* @__PURE__ */ new Set([
19
19
  "connections",
20
20
  "subagents",
21
21
  "schedules",
22
- "sandbox"
22
+ "sandbox",
23
+ "workflows",
24
+ "evals",
25
+ "memory"
23
26
  ]);
24
27
  function scanAgents(projectRoot, agentsDirName = "agents") {
25
28
  const agentsDir = join(projectRoot, agentsDirName);
@@ -48,4 +51,4 @@ function scanAgents(projectRoot, agentsDirName = "agents") {
48
51
  export {
49
52
  scanAgents
50
53
  };
51
- //# sourceMappingURL=chunk-5ZS6RLVY.js.map
54
+ //# sourceMappingURL=chunk-L4GCEMNW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/server/scan/agent-scan.ts"],"sourcesContent":["/* eslint-disable security/detect-non-literal-fs-filename --\n * Build-time scanner: walks `<projectRoot>/agents/` derived from cwd.\n * No HTTP input ever reaches these fs calls.\n */\nimport { existsSync, statSync } from 'node:fs'\nimport { extname, join, relative } from 'node:path'\n\nimport { walkSourceFiles } from '../_internal/scan-walker.js'\n\nconst AGENT_EXTENSIONS = new Set(['.ts', '.tsx', '.js', '.jsx'])\n// Convention § 5: a co-located test file is not an agent.\nconst TEST_FILE = /\\.(test|spec)$/\n\n/**\n * Folder-semantic discovery (Eve-style \"file = identity\"): an agent may be a self-contained folder that\n * co-locates its composition — `agents/<name>/{index.ts, tools/, skills/, prompts/, lib/}`. Files INSIDE\n * these conventional sub-folders are that concern (a tool, a skill, a prompt, a helper), NOT a routed\n * agent, so the scanner skips any file whose path passes through one of them. Only `<name>.ts` or\n * `<name>/index.ts` is served at `/api/agents/<name>`. A flat file literally named `tools.ts` is still a\n * valid agent (the reserved names only apply to intermediate DIRECTORIES, never the agent file itself).\n */\nconst AGENT_SUBFOLDERS = new Set([\n 'tools',\n 'skills',\n 'prompts',\n 'lib',\n 'hooks',\n 'channels',\n 'connections',\n 'subagents',\n 'schedules',\n 'sandbox',\n 'workflows',\n 'evals',\n 'memory',\n])\n\n/**\n * A discovered agent file. `name` is the client-facing key; `agentPath` is the mounted\n * SSE route (M0/M1 `UIMessageStream`).\n */\nexport interface AgentNode {\n filePath: string\n agentPath: string\n name: string\n}\n\n/**\n * M2 — scan the TOP-LEVEL `agents/` convention (sibling of `server/`, per the LOCKED naming\n * decision). Mirrors `scanWebSocketRoutes`: one file → one endpoint, `index` stripped.\n */\nexport function scanAgents(projectRoot: string, agentsDirName = 'agents'): AgentNode[] {\n // `agentsDirName` (config `agentsDir`, default \"agents\") — the dir holding `<name>.ts` agent\n // definitions, relative to the project root. May be nested (e.g. \"core/agents\"). (#95 follow-up)\n const agentsDir = join(projectRoot, agentsDirName)\n if (!existsSync(agentsDir) || !statSync(agentsDir).isDirectory()) {\n return []\n }\n\n const results: AgentNode[] = []\n walkSourceFiles(agentsDir, { extensions: AGENT_EXTENSIONS }, (absPath) => {\n let rel = relative(agentsDir, absPath)\n rel = rel.replace(/\\\\/g, '/')\n rel = rel.slice(0, -extname(rel).length)\n if (TEST_FILE.test(rel)) return\n // Eve-style: a file living under a composition sub-folder (tools/, skills/, prompts/, …) is that\n // concern, not a routed agent. Check the intermediate DIRECTORIES only — the agent file itself may\n // be named anything.\n const dirs = rel.split('/').slice(0, -1)\n if (dirs.some((segment) => AGENT_SUBFOLDERS.has(segment))) return\n // Unlike routes/ws, an agent needs an explicit name — a bare `agents/index.ts`\n // (name `''` → `/api/agents/`) is nonsensical for a typed `useAgent(name)` binding.\n // `agents/foo/index.ts` still collapses to `foo` (a named nested agent).\n if (rel.endsWith('/index')) rel = rel.slice(0, -6)\n if (rel === 'index' || rel === '') return\n results.push({\n filePath: absPath,\n agentPath: `/api/agents/${rel}`,\n name: rel,\n })\n })\n return results\n}\n"],"mappings":";;;;;;;AAIA,SAAS,YAAY,gBAAgB;AACrC,SAAS,SAAS,MAAM,gBAAgB;AAIxC,IAAM,mBAAmB,oBAAI,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,4 +86,4 @@ export {
86
86
  writeManifest,
87
87
  loadManifest
88
88
  };
89
- //# sourceMappingURL=chunk-APQ62PWQ.js.map
89
+ //# sourceMappingURL=chunk-NQRNDPZJ.js.map
@@ -56,7 +56,7 @@ import {
56
56
  } from "./chunk-WR4F4EEZ.js";
57
57
  import {
58
58
  scanAgents
59
- } from "./chunk-5ZS6RLVY.js";
59
+ } from "./chunk-L4GCEMNW.js";
60
60
  import {
61
61
  matchRoute,
62
62
  scanServerActions,
@@ -929,7 +929,7 @@ async function runConfigureServer(server, ctx) {
929
929
  server.watcher.on("unlink", handleRouteChange);
930
930
  if (ctx.resolvedOpenApi !== void 0) {
931
931
  const openApiCfg = ctx.resolvedOpenApi;
932
- const { reEmitOpenApi } = await import("./dev-emit-J2CSGYD2.js");
932
+ const { reEmitOpenApi } = await import("./dev-emit-XVTJXZGA.js");
933
933
  const openApiServerDir = ctx.serverDir;
934
934
  const openApiDistDir = resolve4(ctx.projectRoot, ctx.resolvedDistDir);
935
935
  const isRouteFileForOpenApi = (file) => file.startsWith(openApiServerDir) && /\.(ts|tsx|js|mjs)$/.test(file);
@@ -1917,19 +1917,19 @@ async function theoPluginAsync(rootOrOptions) {
1917
1917
  })
1918
1918
  );
1919
1919
  }
1920
- const { appTypedClientPlugin } = await import("./app-typed-client-ZLHVLV7H.js");
1920
+ const { appTypedClientPlugin } = await import("./app-typed-client-LM2PNOCL.js");
1921
1921
  const appClientPlugin = appTypedClientPlugin({
1922
1922
  cwd: projectRoot,
1923
1923
  serverDir: serverDirAbs,
1924
1924
  distDir: resolve7(projectRoot, ".theokit")
1925
1925
  });
1926
- const { actionsVirtualModule } = await import("./actions-virtual-module-2F6LRE5F.js");
1926
+ const { actionsVirtualModule } = await import("./actions-virtual-module-BCN7IEQC.js");
1927
1927
  const actionsPlugin = actionsVirtualModule({
1928
1928
  serverDir: serverDirAbs,
1929
1929
  distDir: resolve7(projectRoot, ".theokit")
1930
1930
  });
1931
1931
  const { agentsTypedClientPlugin } = await import("./agents-typed-client-5DCGDWFZ.js");
1932
- const { generateManifest } = await import("./internal-api-UYI3FED6.js");
1932
+ const { generateManifest } = await import("./internal-api-CCRY3HN4.js");
1933
1933
  const agentsClientPlugin = agentsTypedClientPlugin({
1934
1934
  projectRoot,
1935
1935
  agentsDir: agentsDirName,
@@ -2104,4 +2104,4 @@ export {
2104
2104
  theoPluginAsync,
2105
2105
  theoPlugin
2106
2106
  };
2107
- //# sourceMappingURL=chunk-5IRPHJUC.js.map
2107
+ //# sourceMappingURL=chunk-OOS5LB5Y.js.map
package/dist/cli/index.js CHANGED
@@ -5,12 +5,12 @@ import "tsx/esm";
5
5
  import cac from "cac";
6
6
  var cli = cac("theokit");
7
7
  cli.command("dev", "Start development server").option("--port <port>", "Port number").action(async (options) => {
8
- const { devCommand } = await import("../dev-7TXAFVYS.js");
8
+ const { devCommand } = await import("../dev-PESPUGQU.js");
9
9
  await devCommand({ port: options.port ? Number(options.port) : void 0 });
10
10
  });
11
11
  cli.command("build", "Build for production").option("--target <target>", "Deploy target (node, vercel, cloudflare)").action(async (options) => {
12
12
  try {
13
- const { buildCommand } = await import("../build-WTULINA6.js");
13
+ const { buildCommand } = await import("../build-J6N4BQMF.js");
14
14
  await buildCommand({ target: options.target });
15
15
  } catch (err) {
16
16
  const msg = err instanceof Error ? err.message : String(err);
@@ -22,7 +22,7 @@ cli.command("build", "Build for production").option("--target <target>", "Deploy
22
22
  });
23
23
  cli.command("start", "Start production server").option("--port <port>", "Port number").action(async (options) => {
24
24
  try {
25
- const { startCommand } = await import("../start-K4ZI4WO6.js");
25
+ const { startCommand } = await import("../start-CHMKI2KH.js");
26
26
  await startCommand({ port: options.port ? Number(options.port) : void 0 });
27
27
  } catch (err) {
28
28
  const msg = err instanceof Error ? err.message : String(err);
@@ -37,7 +37,7 @@ cli.command(
37
37
  "Scaffold a route, action, page, ws, controller, agent, toolbox, workflow, eval, sandbox, schedule, memory, or resource (resource accepts field:type args)"
38
38
  ).action(async (type, name, fields) => {
39
39
  try {
40
- const { generateCommand } = await import("../generate-SRK37SUU.js");
40
+ const { generateCommand } = await import("../generate-RO3X63ZC.js");
41
41
  await generateCommand(type, name, fields.length > 0 ? fields : void 0);
42
42
  } catch (err) {
43
43
  const msg = err instanceof Error ? err.message : String(err);
@@ -52,7 +52,7 @@ cli.command(
52
52
  "Run an agent in the terminal (stream + tool calls + approval)"
53
53
  ).action(async (name, message) => {
54
54
  try {
55
- const { agentCommand } = await import("../agent-KKKCDX4G.js");
55
+ const { agentCommand } = await import("../agent-4FJK6PRR.js");
56
56
  const { sawError } = await agentCommand(name, message);
57
57
  if (sawError) process.exit(1);
58
58
  } catch (err) {
@@ -65,7 +65,7 @@ cli.command(
65
65
  });
66
66
  cli.command("mcp <agent>", "Serve an agent as an MCP server over stdio (for desktop MCP clients)").action(async (agent) => {
67
67
  try {
68
- const { mcpCommand } = await import("../mcp-4A4B6QZH.js");
68
+ const { mcpCommand } = await import("../mcp-FMZSFEEQ.js");
69
69
  await mcpCommand(agent);
70
70
  } catch (err) {
71
71
  const msg = err instanceof Error ? err.message : String(err);
@@ -126,7 +126,7 @@ cli.command(
126
126
  "Generate <distDir>/openapi.json from route schemas (opt-in via config.openapi)"
127
127
  ).option("--dry-run", "Print the document to stdout without writing to disk (EC-3)").action(async (options) => {
128
128
  try {
129
- const { openapiCommand } = await import("../openapi-I4HCBSPY.js");
129
+ const { openapiCommand } = await import("../openapi-2HVGJMSN.js");
130
130
  await openapiCommand({ dryRun: Boolean(options.dryRun) });
131
131
  } catch (err) {
132
132
  const msg = err instanceof Error ? err.message : String(err);
@@ -8,7 +8,7 @@ import {
8
8
  } from "./chunk-HNBWZKIQ.js";
9
9
  import {
10
10
  theoPluginAsync
11
- } from "./chunk-5IRPHJUC.js";
11
+ } from "./chunk-OOS5LB5Y.js";
12
12
  import "./chunk-S7L6H3KP.js";
13
13
  import "./chunk-2CVV6CNN.js";
14
14
  import "./chunk-M6NMS5LR.js";
@@ -26,8 +26,8 @@ import {
26
26
  import "./chunk-5ODOE6EF.js";
27
27
  import "./chunk-KXA37ONC.js";
28
28
  import "./chunk-WR4F4EEZ.js";
29
- import "./chunk-APQ62PWQ.js";
30
- import "./chunk-5ZS6RLVY.js";
29
+ import "./chunk-NQRNDPZJ.js";
30
+ import "./chunk-L4GCEMNW.js";
31
31
  import "./chunk-FRUEDJFX.js";
32
32
  import "./chunk-P37RZRFV.js";
33
33
  import "./chunk-HGZL5EOI.js";
@@ -111,4 +111,4 @@ export {
111
111
  devCommand,
112
112
  startDevServer
113
113
  };
114
- //# sourceMappingURL=dev-7TXAFVYS.js.map
114
+ //# sourceMappingURL=dev-PESPUGQU.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  generateManifest
3
- } from "./chunk-X2MHT456.js";
3
+ } from "./chunk-IHJZPQEF.js";
4
4
  import "./chunk-WSJKACWB.js";
5
5
  import "./chunk-X2VVCJ4V.js";
6
6
  import "./chunk-DGUM43GV.js";
@@ -337,4 +337,4 @@ export {
337
337
  _resetInFlightForTests,
338
338
  reEmitOpenApi
339
339
  };
340
- //# sourceMappingURL=dev-emit-CRBRIRE2.js.map
340
+ //# sourceMappingURL=dev-emit-2DL3MCLM.js.map
@@ -6,8 +6,8 @@ import {
6
6
  } from "./chunk-JAIKGP3Q.js";
7
7
  import {
8
8
  generateManifest
9
- } from "./chunk-APQ62PWQ.js";
10
- import "./chunk-5ZS6RLVY.js";
9
+ } from "./chunk-NQRNDPZJ.js";
10
+ import "./chunk-L4GCEMNW.js";
11
11
  import "./chunk-FRUEDJFX.js";
12
12
  import "./chunk-P37RZRFV.js";
13
13
 
@@ -41,4 +41,4 @@ export {
41
41
  _resetInFlightForTests,
42
42
  reEmitOpenApi
43
43
  };
44
- //# sourceMappingURL=dev-emit-J2CSGYD2.js.map
44
+ //# sourceMappingURL=dev-emit-XVTJXZGA.js.map