theokit 0.19.2 → 0.19.3
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/dist/{actions-virtual-module-J3XSNY6L.js → actions-virtual-module-JB5ZTS5U.js} +2 -2
- package/dist/{actions-virtual-module-HD3D75C2.js → actions-virtual-module-Z2IXNF72.js} +3 -3
- package/dist/{agent-UGVJJXRY.js → agent-LFS3MXL7.js} +3 -3
- package/dist/{agents-typed-client-LQ36PCHL.js → agents-typed-client-2K3UAOUF.js} +2 -2
- package/dist/agents-typed-client-2K3UAOUF.js.map +1 -0
- package/dist/{agents-typed-client-D3LXWGCF.js → agents-typed-client-DPFVM2OY.js} +2 -2
- package/dist/agents-typed-client-DPFVM2OY.js.map +1 -0
- package/dist/{app-typed-client-OTXG3VZB.js → app-typed-client-VMSRQGKL.js} +2 -2
- package/dist/{app-typed-client-X6WKTFX2.js → app-typed-client-YCQC3MZ7.js} +3 -3
- package/dist/{build-KZBSHSKG.js → build-B675HLFR.js} +7 -7
- package/dist/build-B675HLFR.js.map +1 -0
- package/dist/{chunk-7BYQD7IE.js → chunk-5YBUPJC2.js} +10 -7
- package/dist/{chunk-7BYQD7IE.js.map → chunk-5YBUPJC2.js.map} +1 -1
- package/dist/{chunk-567NA7Y6.js → chunk-AFVTEAES.js} +2 -2
- package/dist/{chunk-YJAUJXZS.js → chunk-GSO77FSM.js} +7 -1
- package/dist/chunk-GSO77FSM.js.map +1 -0
- package/dist/{chunk-2YS3CNO4.js → chunk-QSLNS5EZ.js} +26 -16
- package/dist/chunk-QSLNS5EZ.js.map +1 -0
- package/dist/{chunk-AKTGTUU5.js → chunk-RKDH4DWL.js} +5 -5
- package/dist/chunk-RKDH4DWL.js.map +1 -0
- package/dist/{chunk-34YQOXGM.js → chunk-TERFLG67.js} +3 -3
- package/dist/chunk-TERFLG67.js.map +1 -0
- package/dist/{chunk-RRJ66UTS.js → chunk-UGK6KR4D.js} +21 -17
- package/dist/{chunk-RRJ66UTS.js.map → chunk-UGK6KR4D.js.map} +1 -1
- package/dist/{chunk-TIZBKEDV.js → chunk-YJWEADAW.js} +4 -4
- package/dist/chunk-YJWEADAW.js.map +1 -0
- package/dist/cli/index.js +8 -8
- package/dist/{dev-RQLE5W72.js → dev-ORWXOTNX.js} +8 -6
- package/dist/dev-ORWXOTNX.js.map +1 -0
- package/dist/{dev-emit-YSQ7SMXA.js → dev-emit-5FVWJIKR.js} +2 -2
- package/dist/{dev-emit-M4KBDBB6.js → dev-emit-EFQRBVYS.js} +3 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -2
- package/dist/{info-7PE2PZJI.js → info-2OOXFTJX.js} +3 -3
- package/dist/{internal-api-IBZ4QZAC.js → internal-api-KPULK7ZK.js} +2 -2
- package/dist/{internal-api-U3ARINWN.js → internal-api-Y5REPVUS.js} +3 -3
- package/dist/{load-config-JKYO5RFK.js → load-config-3EAQTXPH.js} +3 -3
- package/dist/{mcp-H5GWOGD7.js → mcp-MQTG6IS4.js} +6 -5
- package/dist/mcp-MQTG6IS4.js.map +1 -0
- package/dist/{openapi-PAXSR4UA.js → openapi-ERYWAT3A.js} +5 -5
- package/dist/{routes-WKG3UKDX.js → routes-TJQIXCOS.js} +3 -3
- package/dist/{schema-7CAY6IZR.js → schema-LYOLNHZ7.js} +2 -2
- package/dist/server/index.js +1 -1
- package/dist/server/scan/index.d.ts +1 -1
- package/dist/server/scan/index.js +1 -1
- package/dist/{start-TGNHQ7NZ.js → start-ILT6E25Q.js} +10 -10
- package/dist/start-ILT6E25Q.js.map +1 -0
- package/dist/vite-plugin/index.d.ts +6 -0
- package/dist/vite-plugin/index.js +2 -2
- package/dist/{vite-plugin-H2SMD2Q4.js → vite-plugin-WIJ5RMQQ.js} +6 -6
- package/package.json +1 -1
- package/dist/agents-typed-client-D3LXWGCF.js.map +0 -1
- package/dist/agents-typed-client-LQ36PCHL.js.map +0 -1
- package/dist/build-KZBSHSKG.js.map +0 -1
- package/dist/chunk-2YS3CNO4.js.map +0 -1
- package/dist/chunk-34YQOXGM.js.map +0 -1
- package/dist/chunk-AKTGTUU5.js.map +0 -1
- package/dist/chunk-TIZBKEDV.js.map +0 -1
- package/dist/chunk-YJAUJXZS.js.map +0 -1
- package/dist/dev-RQLE5W72.js.map +0 -1
- package/dist/mcp-H5GWOGD7.js.map +0 -1
- package/dist/start-TGNHQ7NZ.js.map +0 -1
- /package/dist/{actions-virtual-module-J3XSNY6L.js.map → actions-virtual-module-JB5ZTS5U.js.map} +0 -0
- /package/dist/{actions-virtual-module-HD3D75C2.js.map → actions-virtual-module-Z2IXNF72.js.map} +0 -0
- /package/dist/{agent-UGVJJXRY.js.map → agent-LFS3MXL7.js.map} +0 -0
- /package/dist/{app-typed-client-OTXG3VZB.js.map → app-typed-client-VMSRQGKL.js.map} +0 -0
- /package/dist/{app-typed-client-X6WKTFX2.js.map → app-typed-client-YCQC3MZ7.js.map} +0 -0
- /package/dist/{chunk-567NA7Y6.js.map → chunk-AFVTEAES.js.map} +0 -0
- /package/dist/{dev-emit-YSQ7SMXA.js.map → dev-emit-5FVWJIKR.js.map} +0 -0
- /package/dist/{dev-emit-M4KBDBB6.js.map → dev-emit-EFQRBVYS.js.map} +0 -0
- /package/dist/{info-7PE2PZJI.js.map → info-2OOXFTJX.js.map} +0 -0
- /package/dist/{internal-api-IBZ4QZAC.js.map → internal-api-KPULK7ZK.js.map} +0 -0
- /package/dist/{internal-api-U3ARINWN.js.map → internal-api-Y5REPVUS.js.map} +0 -0
- /package/dist/{load-config-JKYO5RFK.js.map → load-config-3EAQTXPH.js.map} +0 -0
- /package/dist/{openapi-PAXSR4UA.js.map → openapi-ERYWAT3A.js.map} +0 -0
- /package/dist/{routes-WKG3UKDX.js.map → routes-TJQIXCOS.js.map} +0 -0
- /package/dist/{schema-7CAY6IZR.js.map → schema-LYOLNHZ7.js.map} +0 -0
- /package/dist/{vite-plugin-H2SMD2Q4.js.map → vite-plugin-WIJ5RMQQ.js.map} +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import "tsx/esm";
|
|
3
3
|
import {
|
|
4
4
|
scanAgents
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-TERFLG67.js";
|
|
6
6
|
import {
|
|
7
7
|
compilePattern,
|
|
8
8
|
scanServerActions,
|
|
@@ -13,11 +13,11 @@ import {
|
|
|
13
13
|
// src/server/scan/manifest.ts
|
|
14
14
|
import { existsSync, readFileSync, writeFileSync, mkdirSync } from "fs";
|
|
15
15
|
import { join, resolve, relative, dirname } from "path";
|
|
16
|
-
function generateManifest(serverDir, projectRoot = dirname(serverDir)) {
|
|
16
|
+
function generateManifest(serverDir, projectRoot = dirname(serverDir), agentsDir = "agents") {
|
|
17
17
|
const routes = scanServerRoutes(serverDir);
|
|
18
18
|
const actions = scanServerActions(serverDir);
|
|
19
19
|
const websockets = scanWebSocketRoutes(serverDir);
|
|
20
|
-
const agents = scanAgents(projectRoot);
|
|
20
|
+
const agents = scanAgents(projectRoot, agentsDir);
|
|
21
21
|
return {
|
|
22
22
|
version: 1,
|
|
23
23
|
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -86,4 +86,4 @@ export {
|
|
|
86
86
|
writeManifest,
|
|
87
87
|
loadManifest
|
|
88
88
|
};
|
|
89
|
-
//# sourceMappingURL=chunk-
|
|
89
|
+
//# sourceMappingURL=chunk-YJWEADAW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/server/scan/manifest.ts"],"sourcesContent":["/* 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,eAAe,iBAAiB;AACnE,SAAS,MA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7B,UAAM,IAAI,MAAM,wBAAwB,YAAY,2BAA2B;AAAA,EACjF;AAEA,QAAM,MAAM,KAAK,MAAM,aAAa,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":[]}
|
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-
|
|
8
|
+
const { devCommand } = await import("../dev-ORWXOTNX.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-
|
|
13
|
+
const { buildCommand } = await import("../build-B675HLFR.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-
|
|
25
|
+
const { startCommand } = await import("../start-ILT6E25Q.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);
|
|
@@ -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-
|
|
55
|
+
const { agentCommand } = await import("../agent-LFS3MXL7.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-
|
|
68
|
+
const { mcpCommand } = await import("../mcp-MQTG6IS4.js");
|
|
69
69
|
await mcpCommand(agent);
|
|
70
70
|
} catch (err) {
|
|
71
71
|
const msg = err instanceof Error ? err.message : String(err);
|
|
@@ -77,7 +77,7 @@ cli.command("mcp <agent>", "Serve an agent as an MCP server over stdio (for desk
|
|
|
77
77
|
});
|
|
78
78
|
cli.command("routes", "List all routes, actions, and WebSocket endpoints").action(async () => {
|
|
79
79
|
try {
|
|
80
|
-
const { routesCommand } = await import("../routes-
|
|
80
|
+
const { routesCommand } = await import("../routes-TJQIXCOS.js");
|
|
81
81
|
await routesCommand();
|
|
82
82
|
} catch (err) {
|
|
83
83
|
const msg = err instanceof Error ? err.message : String(err);
|
|
@@ -118,7 +118,7 @@ cli.command("add <package>", "Install a known TheoKit adapter or plugin (whiteli
|
|
|
118
118
|
await addCommand(pkg);
|
|
119
119
|
});
|
|
120
120
|
cli.command("info", "Print environment info (runtime, config, routes)").action(async () => {
|
|
121
|
-
const { infoCommand } = await import("../info-
|
|
121
|
+
const { infoCommand } = await import("../info-2OOXFTJX.js");
|
|
122
122
|
await infoCommand();
|
|
123
123
|
});
|
|
124
124
|
cli.command(
|
|
@@ -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-
|
|
129
|
+
const { openapiCommand } = await import("../openapi-ERYWAT3A.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,26 +8,26 @@ import {
|
|
|
8
8
|
} from "./chunk-HNBWZKIQ.js";
|
|
9
9
|
import {
|
|
10
10
|
theoPluginAsync
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-UGK6KR4D.js";
|
|
12
12
|
import "./chunk-DXF64KS5.js";
|
|
13
13
|
import "./chunk-DMC6HYUR.js";
|
|
14
14
|
import "./chunk-M6NMS5LR.js";
|
|
15
15
|
import "./chunk-IEES3CHD.js";
|
|
16
16
|
import {
|
|
17
17
|
loadConfig
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-AFVTEAES.js";
|
|
19
19
|
import {
|
|
20
20
|
loadEnv
|
|
21
21
|
} from "./chunk-GDN3PXFH.js";
|
|
22
|
-
import "./chunk-
|
|
22
|
+
import "./chunk-GSO77FSM.js";
|
|
23
23
|
import {
|
|
24
24
|
orchestrateDev
|
|
25
25
|
} from "./chunk-45C3WUQ7.js";
|
|
26
26
|
import "./chunk-5ODOE6EF.js";
|
|
27
27
|
import "./chunk-KXA37ONC.js";
|
|
28
28
|
import "./chunk-WR4F4EEZ.js";
|
|
29
|
-
import "./chunk-
|
|
30
|
-
import "./chunk-
|
|
29
|
+
import "./chunk-YJWEADAW.js";
|
|
30
|
+
import "./chunk-TERFLG67.js";
|
|
31
31
|
import "./chunk-FRUEDJFX.js";
|
|
32
32
|
import "./chunk-P37RZRFV.js";
|
|
33
33
|
import "./chunk-HGZL5EOI.js";
|
|
@@ -60,6 +60,8 @@ async function startDevServer(cwd, options) {
|
|
|
60
60
|
ssr: config.ssr,
|
|
61
61
|
// #95 — honor config `serverDir` (default "server") so route/action discovery scans it.
|
|
62
62
|
serverDir: config.serverDir,
|
|
63
|
+
// #95 follow-up — honor config `agentsDir` (default "agents") for the agent scan/middleware.
|
|
64
|
+
agentsDir: config.agentsDir,
|
|
63
65
|
// Wave 2 (T3.1) — wire typed-client plugin when services declared.
|
|
64
66
|
services: config.services,
|
|
65
67
|
// T4.1 (canvas-ecosystem-refactor / ADR D6) — passthrough peer-deps
|
|
@@ -107,4 +109,4 @@ export {
|
|
|
107
109
|
devCommand,
|
|
108
110
|
startDevServer
|
|
109
111
|
};
|
|
110
|
-
//# sourceMappingURL=dev-
|
|
112
|
+
//# sourceMappingURL=dev-ORWXOTNX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/commands/dev.ts"],"sourcesContent":["import react from '@vitejs/plugin-react'\nimport { createServer, type Plugin, type ViteDevServer } from 'vite'\n\nimport { loadConfig } from '../../config/load-config.js'\nimport { loadEnv } from '../../config/load-env.js'\nimport { validateProjectStructure } from '../../config/validate-structure.js'\nimport { orchestrateDev } from '../../services/index.js'\nimport { theoPluginAsync } from '../../vite-plugin/index.js'\nimport { preflightNodeAndBindings } from '../preflight-node-version.js'\n\ninterface DevOptions {\n port?: number\n}\n\nexport async function startDevServer(cwd: string, options?: DevOptions): Promise<ViteDevServer> {\n // Preflight (FIRST — BEFORE anything that touches native bindings):\n // verifies Node version + native binding ABI match. Emits actionable\n // error referencing `nvm use` + `pnpm rebuild` when the dev server\n // was spawned under the wrong Node (common gotcha with `nohup env ...`\n // stripping the nvm PATH prefix).\n preflightNodeAndBindings(cwd)\n\n // Phase 1 (T1.2) — Load .env files into process.env BEFORE any module\n // reads them. Must run before loadConfig() so theo.config.ts functions\n // referencing process.env.* resolve correctly.\n loadEnv({ cwd, mode: 'development' })\n\n const config = await loadConfig(cwd)\n validateProjectStructure(cwd)\n\n // Wave 2 (T1.1) — spawn polyglot services BEFORE Vite. Healthcheck gates\n // readiness. Empty `services: {}` → early return (Wave 1 BC preserved).\n const orchestration = await orchestrateDev({\n cwd,\n services: config.services,\n })\n if (!orchestration.allHealthy) {\n await orchestration.stop()\n throw new Error(\n `[services] services failed healthcheck: ${orchestration.unhealthy.join(', ')}. ` +\n `Check that each declared service binds its port and responds 200 on its ` +\n `healthcheck path within 30s.`,\n )\n }\n\n // Phase 7 — legacy fs-mtime sweep removed: SDK's Agent.registry handles\n // LRU + idle eviction natively (configurable via theo.config.ts >\n // agents.registry; lazy-configured on first request).\n\n const port = options?.port ?? config.port\n // Narrow the rateLimit union: only the legacy flat shape (windowMs+max)\n // flows into the theoPlugin's RateLimitConfig parameter. The per-route\n // variant is consumed inside the api-middleware via the loaded user\n // config separately.\n const flatRateLimit =\n config.rateLimit && 'windowMs' in config.rateLimit && 'max' in config.rateLimit\n ? config.rateLimit\n : undefined\n // theoPluginAsync auto-chains @theokit/ui + @tailwindcss/vite via\n // top-level Plugin[] return (sync `theoPlugin()` factory's config()\n // hook returning {plugins:[...]} is silently dropped by Vite — see\n // commit history). Spread the result so Vite flattens them.\n let server: ViteDevServer\n try {\n const theoPlugins = await theoPluginAsync({\n root: cwd,\n rateLimit: flatRateLimit,\n ssr: config.ssr,\n // #95 — honor config `serverDir` (default \"server\") so route/action discovery scans it.\n serverDir: config.serverDir,\n // #95 follow-up — honor config `agentsDir` (default \"agents\") for the agent scan/middleware.\n agentsDir: config.agentsDir,\n // Wave 2 (T3.1) — wire typed-client plugin when services declared.\n services: config.services,\n // T4.1 (canvas-ecosystem-refactor / ADR D6) — passthrough peer-deps\n // that plugins import dynamically (e.g., mermaid via plugin-canvas).\n viteOptimizeDeps: config.viteOptimizeDeps,\n })\n server = await createServer({\n root: cwd,\n plugins: [react(), ...theoPlugins] as Plugin[],\n server: {\n port,\n host: config.host,\n open: config.open,\n strictPort: config.strictPort,\n warmup: config.warmup ?? {\n clientFiles: ['./app/**/*.tsx', './app/**/*.ts'],\n },\n },\n logLevel: options?.port === 0 ? 'silent' : undefined,\n })\n\n await server.listen()\n } catch (err) {\n // EC-1 / try-finally pattern: if Vite create/listen fails AFTER services\n // started, stop them so we don't leak child processes.\n await orchestration.stop()\n throw err\n }\n\n // EC-1 fix: attach orchestration.stop() to the underlying HTTP server's\n // close event via Node-native API. We do NOT mutate `server.close`\n // (fragile across Vite upgrades). httpServer is `http.Server | null`.\n server.httpServer?.on('close', () => {\n void orchestration.stop()\n })\n\n return server\n}\n\nexport async function devCommand(options: DevOptions): Promise<void> {\n try {\n const cwd = process.cwd()\n const server = await startDevServer(cwd, options)\n server.printUrls()\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err)\n console.error(`\\n ✗ ${msg}\\n`)\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,WAAW;AAClB,SAAS,oBAAqD;AAa9D,eAAsB,eAAe,KAAa,SAA8C;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AAAA,EAC1B,CAAC;AAED,SAAO;AACT;AAEA,eAAsB,WAAW,SAAoC;AACnE,MAAI;AACF,UAAM,MAAM,QAAQ,IAAI;AACxB,UAAM,SAAS,MAAM,eAAe,KAAK,OAAO;AAChD,WAAO,UAAU;AAAA,EACnB,SAAS,KAAK;AACZ,UAAM,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAC3D,YAAQ,MAAM;AAAA,WAAS,GAAG;AAAA,CAAI;AAC9B,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
generateManifest
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-RKDH4DWL.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-
|
|
340
|
+
//# sourceMappingURL=dev-emit-5FVWJIKR.js.map
|
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
} from "./chunk-JAIKGP3Q.js";
|
|
7
7
|
import {
|
|
8
8
|
generateManifest
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-YJWEADAW.js";
|
|
10
|
+
import "./chunk-TERFLG67.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-
|
|
44
|
+
//# sourceMappingURL=dev-emit-EFQRBVYS.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ declare const theoConfigSchema: z.ZodObject<{
|
|
|
36
36
|
name: z.ZodOptional<z.ZodString>;
|
|
37
37
|
appDir: z.ZodDefault<z.ZodString>;
|
|
38
38
|
serverDir: z.ZodDefault<z.ZodString>;
|
|
39
|
+
agentsDir: z.ZodDefault<z.ZodString>;
|
|
39
40
|
distDir: z.ZodDefault<z.ZodString>;
|
|
40
41
|
agents: z.ZodOptional<z.ZodObject<{
|
|
41
42
|
maxRegistries: z.ZodDefault<z.ZodNumber>;
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
scanRoutes,
|
|
9
9
|
theoConfigSchema,
|
|
10
10
|
theoPlugin
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-QSLNS5EZ.js";
|
|
12
12
|
import "./chunk-D7ZH7DTG.js";
|
|
13
13
|
import "./chunk-RSVN727G.js";
|
|
14
14
|
import "./chunk-7BIM27LV.js";
|
|
@@ -17,7 +17,7 @@ import "./chunk-5QW7IQQU.js";
|
|
|
17
17
|
import "./chunk-IAJ2JVEH.js";
|
|
18
18
|
import "./chunk-VMEWD57H.js";
|
|
19
19
|
import "./chunk-JQSKBMXP.js";
|
|
20
|
-
import "./chunk-
|
|
20
|
+
import "./chunk-RKDH4DWL.js";
|
|
21
21
|
import "./chunk-WSJKACWB.js";
|
|
22
22
|
import "./chunk-JBCHWRKF.js";
|
|
23
23
|
import "./chunk-C3ZZ56YZ.js";
|
|
@@ -5,9 +5,9 @@ import {
|
|
|
5
5
|
} from "./chunk-IEES3CHD.js";
|
|
6
6
|
import {
|
|
7
7
|
loadConfig
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-AFVTEAES.js";
|
|
9
9
|
import "./chunk-GDN3PXFH.js";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-GSO77FSM.js";
|
|
11
11
|
import "./chunk-45C3WUQ7.js";
|
|
12
12
|
|
|
13
13
|
// src/cli/commands/info.ts
|
|
@@ -101,4 +101,4 @@ export {
|
|
|
101
101
|
buildInfo,
|
|
102
102
|
infoCommand
|
|
103
103
|
};
|
|
104
|
-
//# sourceMappingURL=info-
|
|
104
|
+
//# sourceMappingURL=info-2OOXFTJX.js.map
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
scanServerActionsEnriched,
|
|
20
20
|
scanServerRoutes,
|
|
21
21
|
scanWebSocketRoutes
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-RKDH4DWL.js";
|
|
23
23
|
import "./chunk-WSJKACWB.js";
|
|
24
24
|
import {
|
|
25
25
|
CSP_REPORT_PATH,
|
|
@@ -80,4 +80,4 @@ export {
|
|
|
80
80
|
scanWebSocketRoutes,
|
|
81
81
|
sendError
|
|
82
82
|
};
|
|
83
|
-
//# sourceMappingURL=internal-api-
|
|
83
|
+
//# sourceMappingURL=internal-api-KPULK7ZK.js.map
|
|
@@ -25,10 +25,10 @@ import {
|
|
|
25
25
|
} from "./chunk-WR4F4EEZ.js";
|
|
26
26
|
import {
|
|
27
27
|
generateManifest
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-YJWEADAW.js";
|
|
29
29
|
import {
|
|
30
30
|
scanAgents
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-TERFLG67.js";
|
|
32
32
|
import {
|
|
33
33
|
matchRoute,
|
|
34
34
|
scanServerActions,
|
|
@@ -66,4 +66,4 @@ export {
|
|
|
66
66
|
scanWebSocketRoutes,
|
|
67
67
|
sendError
|
|
68
68
|
};
|
|
69
|
-
//# sourceMappingURL=internal-api-
|
|
69
|
+
//# sourceMappingURL=internal-api-Y5REPVUS.js.map
|
|
@@ -3,12 +3,12 @@ import "tsx/esm";
|
|
|
3
3
|
import {
|
|
4
4
|
deepMerge,
|
|
5
5
|
loadConfig
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-AFVTEAES.js";
|
|
7
7
|
import "./chunk-GDN3PXFH.js";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-GSO77FSM.js";
|
|
9
9
|
import "./chunk-45C3WUQ7.js";
|
|
10
10
|
export {
|
|
11
11
|
deepMerge,
|
|
12
12
|
loadConfig
|
|
13
13
|
};
|
|
14
|
-
//# sourceMappingURL=load-config-
|
|
14
|
+
//# sourceMappingURL=load-config-3EAQTXPH.js.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import "tsx/esm";
|
|
3
3
|
import {
|
|
4
4
|
createAgentSsrLoader
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-5YBUPJC2.js";
|
|
6
6
|
import {
|
|
7
7
|
extractAppResources,
|
|
8
8
|
handleMcpJsonRpc
|
|
@@ -11,7 +11,7 @@ import "./chunk-M6NMS5LR.js";
|
|
|
11
11
|
import "./chunk-GDN3PXFH.js";
|
|
12
12
|
import {
|
|
13
13
|
scanAgents
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-TERFLG67.js";
|
|
15
15
|
import "./chunk-P37RZRFV.js";
|
|
16
16
|
|
|
17
17
|
// src/cli/commands/mcp.ts
|
|
@@ -46,9 +46,10 @@ async function serveMcpStdio(mod, name, appResources, streams) {
|
|
|
46
46
|
// src/cli/commands/mcp.ts
|
|
47
47
|
async function mcpCommand(name, deps = {}) {
|
|
48
48
|
const projectRoot = deps.projectRoot ?? process.cwd();
|
|
49
|
-
const
|
|
49
|
+
const agentsDir = deps.agentsDir ?? (await (await import("./load-config-3EAQTXPH.js")).loadConfig(projectRoot)).agentsDir;
|
|
50
|
+
const agent = scanAgents(projectRoot, agentsDir).find((a) => a.name === name);
|
|
50
51
|
if (!agent) {
|
|
51
|
-
const names = scanAgents(projectRoot).map((a) => a.name).join(", ");
|
|
52
|
+
const names = scanAgents(projectRoot, agentsDir).map((a) => a.name).join(", ");
|
|
52
53
|
throw new Error(
|
|
53
54
|
`theokit mcp: agent '${name}' not found. Available: ${names || "(none in agents/)"}`
|
|
54
55
|
);
|
|
@@ -74,4 +75,4 @@ async function mcpCommand(name, deps = {}) {
|
|
|
74
75
|
export {
|
|
75
76
|
mcpCommand
|
|
76
77
|
};
|
|
77
|
-
//# sourceMappingURL=mcp-
|
|
78
|
+
//# sourceMappingURL=mcp-MQTG6IS4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/commands/mcp.ts","../src/server/agent/mcp-stdio.ts"],"sourcesContent":["/**\n * `theokit mcp <agent>` — expose a scanned agent as an MCP server over stdio.\n *\n * The stdio sibling of the M16 HTTP route (`POST /api/agents/<name>/mcp`): a desktop MCP client\n * (e.g. Claude Desktop) spawns this command and speaks newline-delimited JSON-RPC over the pipe.\n * It reuses the framework's OWN `serveMcpStdio` / `handleMcpJsonRpc` (no LLM call, no runtime — a\n * TRANSPORT, like the HTTP route). `deps` is injectable so the routing is tested without Vite/stdin.\n */\nimport { createInterface } from 'node:readline'\n\nimport { extractAppResources } from '../../server/agent/mcp-app-resources.js'\nimport { type StdioStreams, serveMcpStdio } from '../../server/agent/mcp-stdio.js'\nimport { scanAgents } from '../../server/scan/agent-scan.js'\n\nimport { createAgentSsrLoader } from './agent.js'\n\nexport interface McpCommandDeps {\n projectRoot?: string\n /** Load a TS agent module; defaults to the framework's Vite SSR loader (same transpile as dev). */\n loadModule?: (filePath: string) => Promise<Record<string, unknown>>\n /** stdio streams; defaults to `readline(process.stdin)` + `process.stdout`. Injected in tests. */\n streams?: StdioStreams\n /** Agents dir name (config `agentsDir`); defaults to the loaded config's value (\"agents\"). Tests inject it. */\n agentsDir?: string\n}\n\nexport async function mcpCommand(name: string, deps: McpCommandDeps = {}): Promise<void> {\n const projectRoot = deps.projectRoot ?? process.cwd()\n // #95 follow-up — resolve agents dir from config (default \"agents\") so `agentsDir` is honored here too.\n const agentsDir =\n deps.agentsDir ??\n (await (await import('../../config/load-config.js')).loadConfig(projectRoot)).agentsDir\n const agent = scanAgents(projectRoot, agentsDir).find((a) => a.name === name)\n if (!agent) {\n const names = scanAgents(projectRoot, agentsDir)\n .map((a) => a.name)\n .join(', ')\n throw new Error(\n `theokit mcp: agent '${name}' not found. Available: ${names || '(none in agents/)'}`,\n )\n }\n\n let loadModule = deps.loadModule\n let dispose: (() => Promise<void>) | undefined\n if (!loadModule) {\n const loader = await createAgentSsrLoader(projectRoot)\n loadModule = loader.load\n dispose = loader.dispose\n }\n\n const streams =\n deps.streams ??\n ({\n lines: createInterface({ input: process.stdin }),\n write: (line: string) => process.stdout.write(line),\n } satisfies StdioStreams)\n\n try {\n const mod = await loadModule(agent.filePath)\n await serveMcpStdio(mod, agent.name, extractAppResources(mod), streams)\n } finally {\n if (dispose) await dispose()\n }\n}\n","/**\n * MCP stdio transport (M16 follow-up) — expose a TheoKit agent as an MCP server over stdin/stdout,\n * the sibling of the M16 HTTP route (`POST /api/agents/<name>/mcp`). A desktop MCP client (e.g.\n * Claude Desktop) spawns `theokit mcp <agent>` and speaks newline-delimited JSON-RPC over the pipe.\n *\n * This is a TRANSPORT over the framework's OWN {@link handleMcpJsonRpc} — it reuses the exact handler\n * the HTTP route uses; it calls no LLM, spawns no MCP client, and reimplements no runtime (G2 /\n * sdk-runtime.md). Distinct from the SDK's MCP CLIENT stdio (which spawns external MCP servers via\n * `mcpServers` command/args) — that stays SDK-side. Here TheoKit is the SERVER. The framework-side\n * placement of this server-exposure transport is recorded in ADR-0042 (refining ADR-0040's M16 note).\n */\nimport type { AppResource } from './mcp-app-resources.js'\nimport { handleMcpJsonRpc } from './mcp-handler.js'\n\n/**\n * Handle one newline-delimited JSON-RPC line. Returns the response line to write to stdout, or\n * `null` for a blank line (nothing to emit). A malformed JSON line yields a `-32700` (Parse error)\n * envelope — never throws, so the stdio loop never dies on bad input.\n */\nexport async function handleMcpStdioLine(\n line: string,\n mod: unknown,\n name: string,\n appResources: readonly AppResource[] = [],\n): Promise<string | null> {\n const trimmed = line.trim()\n if (trimmed.length === 0) return null\n let body: unknown\n try {\n body = JSON.parse(trimmed)\n } catch {\n return JSON.stringify({\n jsonrpc: '2.0',\n id: null,\n error: { code: -32700, message: 'Parse error' },\n })\n }\n const response = handleMcpJsonRpc(mod, name, body, appResources)\n const payload: unknown = await response.json()\n return JSON.stringify(payload)\n}\n\n/** A minimal readable line source (an async iterable of lines) + a writable sink. */\nexport interface StdioStreams {\n /** Async iterable of newline-delimited input lines (e.g. `readline.createInterface({ input })`). */\n lines: AsyncIterable<string>\n /** Write a response line (the caller appends no newline). */\n write: (line: string) => void\n}\n\n/**\n * Drive the MCP stdio server loop: for each input line, dispatch via {@link handleMcpStdioLine} and\n * write the response line (with a trailing `\\n`). Returns when the input stream ends (EOF).\n */\nexport async function serveMcpStdio(\n mod: unknown,\n name: string,\n appResources: readonly AppResource[],\n streams: StdioStreams,\n): Promise<void> {\n for await (const line of streams.lines) {\n const out = await handleMcpStdioLine(line, mod, name, appResources)\n if (out !== null) streams.write(`${out}\\n`)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAQA,SAAS,uBAAuB;;;ACWhC,eAAsB,mBACpB,MACA,KACA,MACA,eAAuC,CAAC,GAChB;AACxB,QAAM,UAAU,KAAK,KAAK;AAC1B,MAAI,QAAQ,WAAW,EAAG,QAAO;AACjC,MAAI;AACJ,MAAI;AACF,WAAO,KAAK,MAAM,OAAO;AAAA,EAC3B,QAAQ;AACN,WAAO,KAAK,UAAU;AAAA,MACpB,SAAS;AAAA,MACT,IAAI;AAAA,MACJ,OAAO,EAAE,MAAM,QAAQ,SAAS,cAAc;AAAA,IAChD,CAAC;AAAA,EACH;AACA,QAAM,WAAW,iBAAiB,KAAK,MAAM,MAAM,YAAY;AAC/D,QAAM,UAAmB,MAAM,SAAS,KAAK;AAC7C,SAAO,KAAK,UAAU,OAAO;AAC/B;AAcA,eAAsB,cACpB,KACA,MACA,cACA,SACe;AACf,mBAAiB,QAAQ,QAAQ,OAAO;AACtC,UAAM,MAAM,MAAM,mBAAmB,MAAM,KAA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DN3PXFH.js";
|
|
11
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-GSO77FSM.js";
|
|
12
12
|
import "./chunk-45C3WUQ7.js";
|
|
13
13
|
import {
|
|
14
14
|
generateManifest
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import "./chunk-
|
|
15
|
+
} from "./chunk-YJWEADAW.js";
|
|
16
|
+
import "./chunk-TERFLG67.js";
|
|
17
17
|
import "./chunk-FRUEDJFX.js";
|
|
18
18
|
import "./chunk-P37RZRFV.js";
|
|
19
19
|
|
|
@@ -82,4 +82,4 @@ function emitOpenApiInMemory(manifest, config) {
|
|
|
82
82
|
export {
|
|
83
83
|
openapiCommand
|
|
84
84
|
};
|
|
85
|
-
//# sourceMappingURL=openapi-
|
|
85
|
+
//# sourceMappingURL=openapi-ERYWAT3A.js.map
|
|
@@ -5,9 +5,9 @@ import {
|
|
|
5
5
|
} from "./chunk-JQSFBJR5.js";
|
|
6
6
|
import {
|
|
7
7
|
loadConfig
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-AFVTEAES.js";
|
|
9
9
|
import "./chunk-GDN3PXFH.js";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-GSO77FSM.js";
|
|
11
11
|
import "./chunk-45C3WUQ7.js";
|
|
12
12
|
import {
|
|
13
13
|
scanServerActions,
|
|
@@ -62,4 +62,4 @@ async function routesCommand() {
|
|
|
62
62
|
export {
|
|
63
63
|
routesCommand
|
|
64
64
|
};
|
|
65
|
-
//# sourceMappingURL=routes-
|
|
65
|
+
//# sourceMappingURL=routes-TJQIXCOS.js.map
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
storageSchema,
|
|
13
13
|
theoConfigSchema,
|
|
14
14
|
uploadSchema
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-GSO77FSM.js";
|
|
16
16
|
import "./chunk-45C3WUQ7.js";
|
|
17
17
|
export {
|
|
18
18
|
cacheSchema,
|
|
@@ -27,4 +27,4 @@ export {
|
|
|
27
27
|
theoConfigSchema,
|
|
28
28
|
uploadSchema
|
|
29
29
|
};
|
|
30
|
-
//# sourceMappingURL=schema-
|
|
30
|
+
//# sourceMappingURL=schema-LYOLNHZ7.js.map
|
package/dist/server/index.js
CHANGED
|
@@ -110,7 +110,7 @@ interface LoadedManifest {
|
|
|
110
110
|
websockets: WebSocketRouteNode[];
|
|
111
111
|
agents: AgentNode[];
|
|
112
112
|
}
|
|
113
|
-
declare function generateManifest(serverDir: string, projectRoot?: string): TheoManifest;
|
|
113
|
+
declare function generateManifest(serverDir: string, projectRoot?: string, agentsDir?: string): TheoManifest;
|
|
114
114
|
declare function writeManifest(manifest: TheoManifest, outputDir: string): void;
|
|
115
115
|
declare function loadManifest(distDir: string, serverDir: string): LoadedManifest;
|
|
116
116
|
|
|
@@ -19,11 +19,11 @@ import {
|
|
|
19
19
|
} from "./chunk-M6NMS5LR.js";
|
|
20
20
|
import {
|
|
21
21
|
loadConfig
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-AFVTEAES.js";
|
|
23
23
|
import {
|
|
24
24
|
loadEnv
|
|
25
25
|
} from "./chunk-GDN3PXFH.js";
|
|
26
|
-
import "./chunk-
|
|
26
|
+
import "./chunk-GSO77FSM.js";
|
|
27
27
|
import "./chunk-45C3WUQ7.js";
|
|
28
28
|
import {
|
|
29
29
|
buildSecurityHeaders,
|
|
@@ -40,10 +40,10 @@ import {
|
|
|
40
40
|
} from "./chunk-WR4F4EEZ.js";
|
|
41
41
|
import {
|
|
42
42
|
loadManifest
|
|
43
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-YJWEADAW.js";
|
|
44
44
|
import {
|
|
45
45
|
scanAgents
|
|
46
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-TERFLG67.js";
|
|
47
47
|
import {
|
|
48
48
|
matchRoute,
|
|
49
49
|
scanServerActions,
|
|
@@ -115,7 +115,7 @@ async function configureStorageManagerFromConfig(storageConfig) {
|
|
|
115
115
|
if (storageConfig === void 0 || storageConfig === null) return;
|
|
116
116
|
try {
|
|
117
117
|
const { getStorageManager } = await import("./storage-manager-ZSQFLEYT.js");
|
|
118
|
-
const { storageSchema } = await import("./schema-
|
|
118
|
+
const { storageSchema } = await import("./schema-LYOLNHZ7.js");
|
|
119
119
|
const parsed = storageSchema.parse(storageConfig);
|
|
120
120
|
getStorageManager().configure(parsed);
|
|
121
121
|
} catch (err) {
|
|
@@ -192,7 +192,7 @@ function installGracefulShutdown(server) {
|
|
|
192
192
|
import { existsSync as existsSync2 } from "fs";
|
|
193
193
|
import { join } from "path";
|
|
194
194
|
import { dirname } from "path";
|
|
195
|
-
function loadRoutesAndActions(distDir, serverDir) {
|
|
195
|
+
function loadRoutesAndActions(distDir, serverDir, agentsDir = "agents") {
|
|
196
196
|
const manifestPath = join(distDir, "manifest.json");
|
|
197
197
|
if (existsSync2(manifestPath)) {
|
|
198
198
|
const manifest = loadManifest(distDir, serverDir);
|
|
@@ -212,8 +212,8 @@ function loadRoutesAndActions(distDir, serverDir) {
|
|
|
212
212
|
routes: scanServerRoutes(serverDir),
|
|
213
213
|
actions: scanServerActions(serverDir),
|
|
214
214
|
wsRoutes: scanWebSocketRoutes(serverDir),
|
|
215
|
-
// Agents live at <projectRoot
|
|
216
|
-
agents: scanAgents(dirname(serverDir))
|
|
215
|
+
// Agents live at <projectRoot>/<agentsDir>; projectRoot = serverDir's parent for the canonical layout.
|
|
216
|
+
agents: scanAgents(dirname(serverDir), agentsDir)
|
|
217
217
|
};
|
|
218
218
|
}
|
|
219
219
|
|
|
@@ -762,7 +762,7 @@ async function startCommand(options) {
|
|
|
762
762
|
actions: cachedActions,
|
|
763
763
|
wsRoutes: cachedWsRoutes,
|
|
764
764
|
agents: cachedAgents
|
|
765
|
-
} = loadRoutesAndActions(distDir, serverDir);
|
|
765
|
+
} = loadRoutesAndActions(distDir, serverDir, config.agentsDir);
|
|
766
766
|
const flatRateLimit = config.rateLimit && "windowMs" in config.rateLimit && "max" in config.rateLimit ? config.rateLimit : void 0;
|
|
767
767
|
const rateLimiter = flatRateLimit ? createRateLimiter(flatRateLimit) : null;
|
|
768
768
|
const ssr = await setupSsr({
|
|
@@ -819,4 +819,4 @@ export {
|
|
|
819
819
|
resolveSsrEntry,
|
|
820
820
|
startCommand
|
|
821
821
|
};
|
|
822
|
-
//# sourceMappingURL=start-
|
|
822
|
+
//# sourceMappingURL=start-ILT6E25Q.js.map
|