theokit 0.76.0 → 0.76.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/{actions-virtual-module-34PJIOI6.js → actions-virtual-module-52O6HJZT.js} +7 -7
- package/dist/adapters/agent-mount.js +5 -5
- package/dist/{app-typed-client-FR4M4VND.js → app-typed-client-CJCOALMM.js} +7 -7
- package/dist/{chunk-33DGAR6Q.js → chunk-36ZACTF3.js} +5 -5
- package/dist/{chunk-LCP5FT55.js → chunk-3GM4GACM.js} +2 -2
- package/dist/{chunk-GLD7UXOG.js → chunk-4XZOUS5G.js} +5 -5
- package/dist/{chunk-NWUZMJN2.js → chunk-7MCEJVGV.js} +3 -3
- package/dist/{chunk-2FZYZHZM.js → chunk-BXQCJJPT.js} +3 -3
- package/dist/{chunk-C5FBN5LO.js → chunk-FEK25JUL.js} +13 -13
- package/dist/{chunk-ISTKIQNY.js → chunk-LXV5IEBB.js} +10 -1
- package/dist/chunk-LXV5IEBB.js.map +1 -0
- package/dist/{chunk-KKLXKR2B.js → chunk-OED37LE5.js} +2 -2
- package/dist/{chunk-3HRANFEN.js → chunk-OIYSUQM7.js} +2 -2
- package/dist/{chunk-PVI6HM6E.js → chunk-PVCXREGE.js} +6 -6
- package/dist/{chunk-OO3PHTRT.js → chunk-QBK6YYZA.js} +25 -23
- package/dist/chunk-QBK6YYZA.js.map +1 -0
- package/dist/{chunk-I27DTFV4.js → chunk-UQQQ3V43.js} +10 -5
- package/dist/chunk-UQQQ3V43.js.map +1 -0
- package/dist/chunk-ZN5H7CUR.js +24 -0
- package/dist/chunk-ZN5H7CUR.js.map +1 -0
- package/dist/cli/index.js +4 -4
- package/dist/{cron-lock-C3YpKDz2.d.ts → cron-lock-CfAvLApv.d.ts} +3 -0
- package/dist/{dev-R6U3JOYM.js → dev-R2ZYHZV4.js} +2 -2
- package/dist/{generate-2VAWEL7X.js → generate-VXBSMUMW.js} +106 -40
- package/dist/generate-VXBSMUMW.js.map +1 -0
- package/dist/index.js +8 -8
- package/dist/{internal-api-LJOFLJSS.js → internal-api-YGFPLQ4E.js} +9 -9
- package/dist/{preview-AX2TMD26.js → preview-DLIVPM7A.js} +2 -2
- package/dist/server/cron/index.d.ts +2 -2
- package/dist/server/cron/index.js +5 -2
- package/dist/server/http/index.js +8 -8
- package/dist/server/index.d.ts +12 -4
- package/dist/server/index.js +77 -30
- package/dist/server/index.js.map +1 -1
- package/dist/server/jobs/index.d.ts +1 -1
- package/dist/server/jobs/index.js +4 -3
- package/dist/server/observability/index.js +1 -1
- package/dist/server/storage/index.d.ts +4 -0
- package/dist/server/storage/index.js +3 -2
- package/dist/{server-boundary-WSGVQAXP.js → server-boundary-IDWIB24L.js} +7 -7
- package/dist/{start-4FY3TLM7.js → start-LNT5UVSY.js} +3 -3
- package/dist/{storage-manager-O3APCXYX.js → storage-manager-3IUIEG2P.js} +22 -19
- package/dist/storage-manager-3IUIEG2P.js.map +1 -0
- package/dist/vite-plugin/index.js +8 -8
- package/package.json +1 -1
- package/dist/chunk-I27DTFV4.js.map +0 -1
- package/dist/chunk-ISTKIQNY.js.map +0 -1
- package/dist/chunk-OO3PHTRT.js.map +0 -1
- package/dist/generate-2VAWEL7X.js.map +0 -1
- package/dist/storage-manager-O3APCXYX.js.map +0 -1
- /package/dist/{actions-virtual-module-34PJIOI6.js.map → actions-virtual-module-52O6HJZT.js.map} +0 -0
- /package/dist/{app-typed-client-FR4M4VND.js.map → app-typed-client-CJCOALMM.js.map} +0 -0
- /package/dist/{chunk-33DGAR6Q.js.map → chunk-36ZACTF3.js.map} +0 -0
- /package/dist/{chunk-LCP5FT55.js.map → chunk-3GM4GACM.js.map} +0 -0
- /package/dist/{chunk-GLD7UXOG.js.map → chunk-4XZOUS5G.js.map} +0 -0
- /package/dist/{chunk-NWUZMJN2.js.map → chunk-7MCEJVGV.js.map} +0 -0
- /package/dist/{chunk-2FZYZHZM.js.map → chunk-BXQCJJPT.js.map} +0 -0
- /package/dist/{chunk-C5FBN5LO.js.map → chunk-FEK25JUL.js.map} +0 -0
- /package/dist/{chunk-KKLXKR2B.js.map → chunk-OED37LE5.js.map} +0 -0
- /package/dist/{chunk-3HRANFEN.js.map → chunk-OIYSUQM7.js.map} +0 -0
- /package/dist/{chunk-PVI6HM6E.js.map → chunk-PVCXREGE.js.map} +0 -0
- /package/dist/{dev-R6U3JOYM.js.map → dev-R2ZYHZV4.js.map} +0 -0
- /package/dist/{internal-api-LJOFLJSS.js.map → internal-api-YGFPLQ4E.js.map} +0 -0
- /package/dist/{preview-AX2TMD26.js.map → preview-DLIVPM7A.js.map} +0 -0
- /package/dist/{server-boundary-WSGVQAXP.js.map → server-boundary-IDWIB24L.js.map} +0 -0
- /package/dist/{start-4FY3TLM7.js.map → start-LNT5UVSY.js.map} +0 -0
package/dist/cli/index.js
CHANGED
|
@@ -15,7 +15,7 @@ function cliVersion() {
|
|
|
15
15
|
// src/cli/index.ts
|
|
16
16
|
var cli = cac("theokit");
|
|
17
17
|
cli.command("dev", "Start development server").option("--port <port>", "Port number").option("--crons", "Schedule the crons in dev too (off by default)").action(async (options) => {
|
|
18
|
-
const { devCommand } = await import("../dev-
|
|
18
|
+
const { devCommand } = await import("../dev-R2ZYHZV4.js");
|
|
19
19
|
await devCommand({
|
|
20
20
|
port: options.port ? Number(options.port) : void 0,
|
|
21
21
|
crons: options.crons === true
|
|
@@ -35,7 +35,7 @@ cli.command("build", "Build for production").option("--target <target>", "Deploy
|
|
|
35
35
|
});
|
|
36
36
|
cli.command("start", "Start production server").option("--port <port>", "Port number").action(async (options) => {
|
|
37
37
|
try {
|
|
38
|
-
const { startCommand } = await import("../start-
|
|
38
|
+
const { startCommand } = await import("../start-LNT5UVSY.js");
|
|
39
39
|
await startCommand({ port: options.port ? Number(options.port) : void 0 });
|
|
40
40
|
} catch (err) {
|
|
41
41
|
const msg = err instanceof Error ? err.message : String(err);
|
|
@@ -47,7 +47,7 @@ cli.command("start", "Start production server").option("--port <port>", "Port nu
|
|
|
47
47
|
});
|
|
48
48
|
cli.command("preview", "Build for production, then serve it \u2014 one step (B-030)").option("--port <port>", "Port number").option("--target <target>", "Deploy target (node, vercel, cloudflare)").action(async (options) => {
|
|
49
49
|
try {
|
|
50
|
-
const { previewCommand } = await import("../preview-
|
|
50
|
+
const { previewCommand } = await import("../preview-DLIVPM7A.js");
|
|
51
51
|
await previewCommand({
|
|
52
52
|
port: options.port ? Number(options.port) : void 0,
|
|
53
53
|
target: options.target
|
|
@@ -65,7 +65,7 @@ cli.command(
|
|
|
65
65
|
"Scaffold a route, action, page, ws, controller, agent, toolbox, workflow, eval, sandbox, schedule, memory, or resource (resource accepts field:type args)"
|
|
66
66
|
).action(async (type, name, fields) => {
|
|
67
67
|
try {
|
|
68
|
-
const { generateCommand } = await import("../generate-
|
|
68
|
+
const { generateCommand } = await import("../generate-VXBSMUMW.js");
|
|
69
69
|
await generateCommand(type, name, fields.length > 0 ? fields : void 0);
|
|
70
70
|
} catch (err) {
|
|
71
71
|
const msg = err instanceof Error ? err.message : String(err);
|
|
@@ -27,6 +27,9 @@ interface PostgresCronLockOptions {
|
|
|
27
27
|
*
|
|
28
28
|
* Each row is also a record of when the tick fired and nothing else; rows past `retentionDays` are
|
|
29
29
|
* removed as the cron keeps firing.
|
|
30
|
+
*
|
|
31
|
+
* When `pool` has an event API and no `error` listener, one is attached that logs a structured
|
|
32
|
+
* warning instead of letting a dropped idle connection exit the process (usetheokit/theokit#1037).
|
|
30
33
|
*/
|
|
31
34
|
declare function createPostgresCronLock(pool: PoolLike, options?: PostgresCronLockOptions): CronLock;
|
|
32
35
|
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
loadCronModules,
|
|
18
18
|
loadJobModules,
|
|
19
19
|
startJobWorker
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-OED37LE5.js";
|
|
21
21
|
import {
|
|
22
22
|
preflightNodeAndBindings
|
|
23
23
|
} from "./chunk-KTMQUYED.js";
|
|
@@ -177,4 +177,4 @@ export {
|
|
|
177
177
|
devCommand,
|
|
178
178
|
startDevServer
|
|
179
179
|
};
|
|
180
|
-
//# sourceMappingURL=dev-
|
|
180
|
+
//# sourceMappingURL=dev-R2ZYHZV4.js.map
|
|
@@ -19,8 +19,8 @@ import "./chunk-L4V5V2TI.js";
|
|
|
19
19
|
import "./chunk-MAJZ2L3A.js";
|
|
20
20
|
|
|
21
21
|
// src/cli/commands/generate.ts
|
|
22
|
-
import { existsSync, mkdirSync as mkdirSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
23
|
-
import { resolve as resolve4, dirname as dirname3 } from "path";
|
|
22
|
+
import { existsSync as existsSync2, mkdirSync as mkdirSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
23
|
+
import { posix, resolve as resolve4, dirname as dirname3 } from "path";
|
|
24
24
|
|
|
25
25
|
// src/cli/commands/generate-containment.ts
|
|
26
26
|
import { isAbsolute, relative, resolve, sep } from "path";
|
|
@@ -56,7 +56,7 @@ function undecidedPolicyDeclaration(routePath, what) {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
// src/cli/commands/generate-resource.ts
|
|
59
|
-
import { mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
59
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
60
60
|
import { dirname, join, resolve as resolve2 } from "path";
|
|
61
61
|
var ALLOWED_FIELD_TYPES = /* @__PURE__ */ new Set(["string", "text", "number", "boolean"]);
|
|
62
62
|
var RESERVED_FIELDS = /* @__PURE__ */ new Set(["id", "createdAt", "created_at"]);
|
|
@@ -91,6 +91,12 @@ function parseResourceFields(args) {
|
|
|
91
91
|
var DIALECTS = {
|
|
92
92
|
sqlite: {
|
|
93
93
|
module: "drizzle-orm/sqlite-core",
|
|
94
|
+
dbIndexExample: [
|
|
95
|
+
`import Database from 'better-sqlite3'`,
|
|
96
|
+
`import { drizzle } from 'drizzle-orm/better-sqlite3'`,
|
|
97
|
+
`import * as schema from './schema.js'`,
|
|
98
|
+
`export const db = drizzle(new Database('data.db'), { schema })`
|
|
99
|
+
],
|
|
94
100
|
importPattern: /import\s*\{([^}]*)\}\s*from\s*['"]drizzle-orm\/sqlite-core['"]/,
|
|
95
101
|
table: "sqliteTable",
|
|
96
102
|
columns: ["integer", "text"],
|
|
@@ -114,6 +120,14 @@ var DIALECTS = {
|
|
|
114
120
|
},
|
|
115
121
|
postgresql: {
|
|
116
122
|
module: "drizzle-orm/pg-core",
|
|
123
|
+
dbIndexExample: [
|
|
124
|
+
`import pg from 'pg'`,
|
|
125
|
+
`import { drizzle } from 'drizzle-orm/node-postgres'`,
|
|
126
|
+
`import * as schema from './schema.js'`,
|
|
127
|
+
`const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL })`,
|
|
128
|
+
`pool.on('error', (err) => console.warn('[pg] idle client error:', err.message))`,
|
|
129
|
+
`export const db = drizzle(pool, { schema })`
|
|
130
|
+
],
|
|
117
131
|
importPattern: /import\s*\{([^}]*)\}\s*from\s*['"]drizzle-orm\/pg-core['"]/,
|
|
118
132
|
table: "pgTable",
|
|
119
133
|
columns: ["boolean", "integer", "serial", "text", "timestamp"],
|
|
@@ -331,6 +345,7 @@ function readIfPresent(path) {
|
|
|
331
345
|
throw err;
|
|
332
346
|
}
|
|
333
347
|
}
|
|
348
|
+
var DB_INDEX_FILES = ["index.ts", "index.tsx", "index.js"];
|
|
334
349
|
function createExclusive(path, content) {
|
|
335
350
|
try {
|
|
336
351
|
writeFileSync(path, content, { flag: "wx" });
|
|
@@ -379,6 +394,18 @@ function generateResource(cwd, name, fieldArgs, serverDir = "server") {
|
|
|
379
394
|
}
|
|
380
395
|
const dialect = DIALECTS[dialectName];
|
|
381
396
|
const queries = QUERIES[dialectName];
|
|
397
|
+
const dbIndexRel = join(serverDir, "db", "index.ts");
|
|
398
|
+
if (!DB_INDEX_FILES.some((file) => existsSync(resolve2(cwd, serverDir, "db", file)))) {
|
|
399
|
+
const example = dialect.dbIndexExample.map((line) => " " + line).join("\n");
|
|
400
|
+
return {
|
|
401
|
+
status: "not_a_project",
|
|
402
|
+
message: `${dbIndexRel} not found. The routes \`theokit generate resource\` writes import \`db\` from it, so the build would fail to resolve it. Create it with \`export const db\`, for example (${dialectName}):
|
|
403
|
+
|
|
404
|
+
${example}
|
|
405
|
+
|
|
406
|
+
Nothing was written.`
|
|
407
|
+
};
|
|
408
|
+
}
|
|
382
409
|
mkdirSync(dirname(routeIndexPath), { recursive: true });
|
|
383
410
|
const template = { resourceName: name, fields, queries };
|
|
384
411
|
if (!createExclusive(
|
|
@@ -566,15 +593,12 @@ function toCamelCase(name) {
|
|
|
566
593
|
const pascal = toPascalCase(name);
|
|
567
594
|
return pascal.charAt(0).toLowerCase() + pascal.slice(1);
|
|
568
595
|
}
|
|
569
|
-
function generateRouteTemplate(name) {
|
|
596
|
+
function generateRouteTemplate(name, displayPath) {
|
|
570
597
|
return [
|
|
571
598
|
`import { route, type AccessDecision } from 'theokit/server'`,
|
|
572
599
|
`import { z } from 'zod'`,
|
|
573
600
|
``,
|
|
574
|
-
...undecidedPolicyDeclaration(
|
|
575
|
-
`server/routes/${name}.ts`,
|
|
576
|
-
"a stub today is a real handler tomorrow"
|
|
577
|
-
),
|
|
601
|
+
...undecidedPolicyDeclaration(displayPath, "a stub today is a real handler tomorrow"),
|
|
578
602
|
``,
|
|
579
603
|
`export const GET = route()`,
|
|
580
604
|
` .policy(${UNDECIDED_POLICY_IDENT})`,
|
|
@@ -617,13 +641,18 @@ function generateActionTemplate(name) {
|
|
|
617
641
|
``
|
|
618
642
|
].join("\n");
|
|
619
643
|
}
|
|
620
|
-
function generateAgentTemplate(name) {
|
|
644
|
+
function generateAgentTemplate(name, displayPath) {
|
|
621
645
|
return [
|
|
622
646
|
`import { AgentBuilder } from '@theokit/agents'`,
|
|
647
|
+
`import type { AccessDecision } from 'theokit/server'`,
|
|
623
648
|
`import { z } from 'zod'`,
|
|
624
649
|
``,
|
|
625
650
|
`// Zero-config: this file is auto-served at POST /api/agents/${name}.`,
|
|
626
651
|
`// Add tools with tool('name')...build() and chain them via .tool(...).`,
|
|
652
|
+
``,
|
|
653
|
+
...undecidedPolicyDeclaration(displayPath, "an agent endpoint runs a model on your key"),
|
|
654
|
+
`export const policy = ${UNDECIDED_POLICY_IDENT}`,
|
|
655
|
+
``,
|
|
627
656
|
`export default AgentBuilder.create()`,
|
|
628
657
|
` .input(z.object({ message: z.string() }))`,
|
|
629
658
|
` .model('openai/gpt-4o-mini')`,
|
|
@@ -739,31 +768,75 @@ function generateMemoryTemplate(_name) {
|
|
|
739
768
|
].join("\n");
|
|
740
769
|
}
|
|
741
770
|
var SINGLE_FILE_KINDS = {
|
|
742
|
-
// Agent-capability generators. These live UNDER `
|
|
743
|
-
// not standalone top-level concerns — and the folder-semantic scanner treats each as
|
|
744
|
-
// (never a phantom route).
|
|
745
|
-
workflow: {
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
771
|
+
// Agent-capability generators. These live UNDER `agentsDir` — they are facets of the agent
|
|
772
|
+
// domain, not standalone top-level concerns — and the folder-semantic scanner treats each as
|
|
773
|
+
// composition (never a phantom route).
|
|
774
|
+
workflow: {
|
|
775
|
+
path: (name, { agentsDir }) => posix.join(agentsDir, "workflows", `${name}.ts`),
|
|
776
|
+
template: generateWorkflowTemplate
|
|
777
|
+
},
|
|
778
|
+
eval: {
|
|
779
|
+
path: (name, { agentsDir }) => posix.join(agentsDir, "evals", `${name}.ts`),
|
|
780
|
+
template: generateEvalTemplate
|
|
781
|
+
},
|
|
782
|
+
sandbox: {
|
|
783
|
+
path: (name, { agentsDir }) => posix.join(agentsDir, "sandbox", `${name}.ts`),
|
|
784
|
+
template: generateSandboxTemplate
|
|
785
|
+
},
|
|
786
|
+
memory: {
|
|
787
|
+
path: (name, { agentsDir }) => posix.join(agentsDir, "memory", `${name}.ts`),
|
|
788
|
+
template: generateMemoryTemplate
|
|
789
|
+
},
|
|
790
|
+
route: {
|
|
791
|
+
path: (name, { serverDir }) => posix.join(serverDir, "routes", `${name}.ts`),
|
|
792
|
+
template: generateRouteTemplate
|
|
793
|
+
},
|
|
794
|
+
action: {
|
|
795
|
+
path: (name, { serverDir }) => posix.join(serverDir, "actions", `${name}.ts`),
|
|
796
|
+
template: generateActionTemplate
|
|
797
|
+
},
|
|
798
|
+
page: {
|
|
799
|
+
path: (name, { appDir }) => posix.join(appDir, name, "page.tsx"),
|
|
800
|
+
template: generatePageTemplate
|
|
801
|
+
},
|
|
802
|
+
ws: {
|
|
803
|
+
path: (name, { serverDir }) => posix.join(serverDir, "ws", `${name}.ts`),
|
|
804
|
+
template: generateWsTemplate
|
|
805
|
+
},
|
|
753
806
|
controller: {
|
|
754
|
-
path: (name) =>
|
|
807
|
+
path: (name, { serverDir }) => posix.join(serverDir, "controllers", `${name}.controller.ts`),
|
|
755
808
|
template: generateControllerTemplate
|
|
756
809
|
},
|
|
757
|
-
agent
|
|
810
|
+
// `<agentsDir>/<name>.ts` is what the agent scanner serves at `/api/agents/<name>`, the URL the
|
|
811
|
+
// template promises. The old `server/agents/<name>.agent.ts` was outside `agentsDir` in both the
|
|
812
|
+
// flat and the scaffold layout, so the agent was never served.
|
|
813
|
+
agent: {
|
|
814
|
+
path: (name, { agentsDir }) => posix.join(agentsDir, `${name}.ts`),
|
|
815
|
+
template: generateAgentTemplate
|
|
816
|
+
},
|
|
758
817
|
toolbox: {
|
|
759
|
-
path: (name) =>
|
|
818
|
+
path: (name, { serverDir }) => posix.join(serverDir, "toolboxes", `${name}.tools.ts`),
|
|
760
819
|
template: generateToolboxTemplate
|
|
761
820
|
}
|
|
762
821
|
};
|
|
763
|
-
function
|
|
822
|
+
async function readLayout(cwd) {
|
|
823
|
+
try {
|
|
824
|
+
const { appDir, serverDir, agentsDir } = await loadConfig(cwd);
|
|
825
|
+
return { appDir, serverDir, agentsDir };
|
|
826
|
+
} catch (err) {
|
|
827
|
+
return {
|
|
828
|
+
status: "invalid_config",
|
|
829
|
+
message: `Cannot read ${resolve4(cwd, "theo.config.ts")}: ${err.message}`
|
|
830
|
+
};
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
async function resolveTemplate(cwd, kind, name) {
|
|
764
834
|
const spec = SINGLE_FILE_KINDS[kind];
|
|
765
835
|
if (spec === void 0) return null;
|
|
766
|
-
|
|
836
|
+
const layout = await readLayout(cwd);
|
|
837
|
+
if ("status" in layout) return layout;
|
|
838
|
+
const displayPath = spec.path(name, layout);
|
|
839
|
+
return { filePath: resolve4(cwd, displayPath), content: spec.template(name, displayPath) };
|
|
767
840
|
}
|
|
768
841
|
function generateActionTestTemplate(name) {
|
|
769
842
|
const camel = toCamelCase(name);
|
|
@@ -809,7 +882,7 @@ function isGeneratorType(value) {
|
|
|
809
882
|
return VALID_TYPES.includes(value);
|
|
810
883
|
}
|
|
811
884
|
function refuseOptions({ cwd, type, name }) {
|
|
812
|
-
if (!
|
|
885
|
+
if (!existsSync2(resolve4(cwd, "theo.config.ts")) && !existsSync2(resolve4(cwd, "theo.config.js"))) {
|
|
813
886
|
return {
|
|
814
887
|
status: "not_a_project",
|
|
815
888
|
message: "Not a Theo project. cwd has no theo.config.ts or theo.config.js"
|
|
@@ -837,21 +910,21 @@ function refuseOptions({ cwd, type, name }) {
|
|
|
837
910
|
}
|
|
838
911
|
async function resolveTarget(cwd, type, name) {
|
|
839
912
|
if (type === "schedule") return resolveScheduleTarget(cwd, name);
|
|
840
|
-
const target = resolveTemplate(cwd, type, name);
|
|
913
|
+
const target = await resolveTemplate(cwd, type, name);
|
|
841
914
|
if (target === null) return { status: "invalid_kind", message: `Unknown type: ${type}` };
|
|
842
915
|
return target;
|
|
843
916
|
}
|
|
844
917
|
function writeTarget(cwd, type, name, { filePath, content }) {
|
|
845
918
|
const escaped = pathTraversalRefusal(cwd, filePath);
|
|
846
919
|
if (escaped !== void 0) return escaped;
|
|
847
|
-
if (
|
|
920
|
+
if (existsSync2(filePath)) {
|
|
848
921
|
return { status: "already_exists", filePath, kind: type, name };
|
|
849
922
|
}
|
|
850
923
|
mkdirSync2(dirname3(filePath), { recursive: true });
|
|
851
924
|
writeFileSync2(filePath, content);
|
|
852
925
|
if (type === "action") {
|
|
853
926
|
const testPath = filePath.replace(/\.ts$/, ".test.ts");
|
|
854
|
-
if (!
|
|
927
|
+
if (!existsSync2(testPath)) {
|
|
855
928
|
writeFileSync2(testPath, generateActionTestTemplate(name));
|
|
856
929
|
}
|
|
857
930
|
}
|
|
@@ -863,16 +936,9 @@ async function generate(opts) {
|
|
|
863
936
|
const { cwd, name } = opts;
|
|
864
937
|
const kind = opts.type;
|
|
865
938
|
if (kind === "resource") {
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
} catch (err) {
|
|
870
|
-
return {
|
|
871
|
-
status: "invalid_config",
|
|
872
|
-
message: `Cannot read ${resolve4(cwd, "theo.config.ts")}: ${err.message}`
|
|
873
|
-
};
|
|
874
|
-
}
|
|
875
|
-
return generateResource(cwd, name, opts.fields ?? [], serverDir);
|
|
939
|
+
const layout = await readLayout(cwd);
|
|
940
|
+
if ("status" in layout) return layout;
|
|
941
|
+
return generateResource(cwd, name, opts.fields ?? [], layout.serverDir);
|
|
876
942
|
}
|
|
877
943
|
const resolved = await resolveTarget(cwd, kind, name);
|
|
878
944
|
if ("status" in resolved) return resolved;
|
|
@@ -907,4 +973,4 @@ export {
|
|
|
907
973
|
generate,
|
|
908
974
|
generateCommand
|
|
909
975
|
};
|
|
910
|
-
//# sourceMappingURL=generate-
|
|
976
|
+
//# sourceMappingURL=generate-VXBSMUMW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/commands/generate.ts","../src/cli/commands/generate-containment.ts","../src/cli/commands/generate-policy-placeholder.ts","../src/cli/commands/generate-resource.ts","../src/cli/commands/generate-schedule.ts","../src/server/cron/define-cron.ts","../src/cli/commands/generate-types.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'node:fs'\nimport { posix, resolve, dirname } from 'node:path'\n\nimport { loadConfig } from '../../config/load-config.js'\n\nimport { pathTraversalRefusal } from './generate-containment.js'\nimport {\n UNDECIDED_POLICY_IDENT,\n undecidedPolicyDeclaration,\n} from './generate-policy-placeholder.js'\nimport { generateResource } from './generate-resource.js'\nimport { resolveScheduleTarget } from './generate-schedule.js'\nimport {\n VALID_TYPES,\n type GeneratorType,\n type GenerateOptions,\n type GenerateResult,\n type GenerateStatus,\n} from './generate-types.js'\n\nexport {}\n\nfunction toKebabCase(name: string): boolean {\n return /^[a-z][a-z0-9/-]*$/.test(name)\n}\n\n/**\n * Reserved JS identifier names that conflict with object prototype machinery\n * or would shadow built-in module shapes if used as action/route names.\n * Mirrors action-scan's RESERVED_NAMES (T1.4).\n */\nconst RESERVED_BASENAMES = new Set([\n 'index',\n 'constructor',\n '__proto__',\n 'prototype',\n 'hasOwnProperty',\n])\n\n/**\n * Validate that a name segment doesn't hit the reserved-identifier list.\n * Checks the BASENAME (last `/` segment) — nested `admin/constructor` still\n * rejected because the file `constructor.ts` would be the conflict.\n */\nfunction hasReservedSegment(name: string): boolean {\n const basename = name.includes('/') ? (name.split('/').pop() ?? name) : name\n return RESERVED_BASENAMES.has(basename)\n}\n\nfunction toPascalCase(name: string): string {\n return name\n .split(/[-/]/)\n .map((s) => s.charAt(0).toUpperCase() + s.slice(1))\n .join('')\n}\n\nfunction toCamelCase(name: string): string {\n const pascal = toPascalCase(name)\n return pascal.charAt(0).toLowerCase() + pascal.slice(1)\n}\n\nfunction generateRouteTemplate(name: string, displayPath: string): string {\n return [\n `import { route, type AccessDecision } from 'theokit/server'`,\n `import { z } from 'zod'`,\n ``,\n ...undecidedPolicyDeclaration(displayPath, 'a stub today is a real handler tomorrow'),\n ``,\n `export const GET = route()`,\n ` .policy(${UNDECIDED_POLICY_IDENT})`,\n ` .handler(({ ctx }) => {`,\n ` return { message: 'TODO: implement ${name} GET' }`,\n ` })`,\n ` .build()`,\n ``,\n ].join('\\n')\n}\n\nfunction generateControllerTemplate(name: string): string {\n const className = toPascalCase(name) + 'Controller'\n const baseName = name.split('/').pop() ?? name\n return [\n `// AUTO-GENERATED by \\`theokit generate controller ${name}\\``,\n `import { Controller, Get } from '@theokit/http'`,\n ``,\n `@Controller('${baseName}')`,\n `export class ${className} {`,\n ` @Get()`,\n ` findAll(): string {`,\n ` return 'This action returns all ${baseName}'`,\n ` }`,\n `}`,\n ``,\n ].join('\\n')\n}\n\nfunction generateActionTemplate(name: string): string {\n const camel = toCamelCase(name)\n return [\n `import { action } from 'theokit/server'`,\n `import { z } from 'zod'`,\n ``,\n `export const ${camel} = action()`,\n ` .input(z.object({}))`,\n ` .handler(({ input, ctx }) => {`,\n ` return { message: 'TODO: implement ${name}' }`,\n ` })`,\n ` .build()`,\n ``,\n ].join('\\n')\n}\n\n/**\n * Co-located test template for `theokit generate action <name>` (T5.2 +\n * plan Q4 scenario 1: roundtrip serialize). Skeleton uses vitest BDD shape\n * per testing.md.\n */\nfunction generateAgentTemplate(name: string, displayPath: string): string {\n return [\n `import { AgentBuilder } from '@theokit/agents'`,\n `import type { AccessDecision } from 'theokit/server'`,\n `import { z } from 'zod'`,\n ``,\n `// Zero-config: this file is auto-served at POST /api/agents/${name}.`,\n `// Add tools with tool('name')...build() and chain them via .tool(...).`,\n ``,\n ...undecidedPolicyDeclaration(displayPath, 'an agent endpoint runs a model on your key'),\n `export const policy = ${UNDECIDED_POLICY_IDENT}`,\n ``,\n `export default AgentBuilder.create()`,\n ` .input(z.object({ message: z.string() }))`,\n ` .model('openai/gpt-4o-mini')`,\n ` .system('You are a helpful ${name} assistant.')`,\n ` .build()`,\n ``,\n ].join('\\n')\n}\n\nfunction generateToolboxTemplate(name: string): string {\n const camel = toCamelCase(name)\n return [\n `import { tool } from 'theokit/server'`,\n `import { z } from 'zod'`,\n ``,\n `export const ${camel}Hello = tool('${name}_hello')`,\n ` .describe('Say hello')`,\n ` .input(z.object({ name: z.string() }))`,\n ` .execute(({ name }) => \\`Hello, \\${name}!\\`)`,\n ` .build()`,\n ``,\n ].join('\\n')\n}\n\nfunction generateWorkflowTemplate(name: string): string {\n const camel = toCamelCase(name)\n return [\n `import { Workflow, fn } from '@theokit/sdk/workflow'`,\n ``,\n `/**`,\n ` * A minimal workflow — a typed, multi-step pipeline (@theokit/sdk). Each \\`fn(...)\\` step is a pure`,\n ` * function; a step can also run an agent via \\`agentStep(name, agent, mapInput)\\`. Import + run it from`,\n ` * a route, action, cron job, or tool:`,\n ` *`,\n ` * const run = await ${camel}Workflow.run({ name: 'Ada' })`,\n ` * console.log(run.status, run.output) // 'completed' 'Hello, Ada!'`,\n ` */`,\n `export const ${camel}Workflow = Workflow.create({ name: '${name}' })`,\n ` .then(fn('normalize', (input: { name: string }) => ({ name: input.name.trim() })))`,\n ` .then(fn('greet', (step: { name: string }) => \\`Hello, \\${step.name}!\\`))`,\n ` .commit()`,\n ``,\n ].join('\\n')\n}\n\nfunction generateEvalTemplate(name: string): string {\n const camel = toCamelCase(name)\n return [\n `import { Eval, Scorers } from '@theokit/sdk/eval'`,\n ``,\n `/**`,\n ` * An eval for your agent (@theokit/sdk) — runs the model over a dataset and scores each output.`,\n ` * To score the REAL agent, mirror its config: point \\`agent.model\\` (and, ideally, a \\`systemPrompt\\`)`,\n ` * at the same values your \\`agents/chat.ts\\` uses. Run it (needs a provider key in the environment):`,\n ` *`,\n ` * const run = await ${camel}Eval.run()`,\n ` * console.log(run.aggregate.meanScore)`,\n ` */`,\n `export const ${camel}Eval = Eval.create({`,\n ` name: '${name}',`,\n ` dataset: [{ input: 'Say ok', expected: 'ok' }],`,\n ` scorers: [Scorers.containsExpected({ caseSensitive: false })],`,\n ` // Mirror your agent: same model (+ systemPrompt) so this evaluates the agent your users talk to.`,\n ` agent: { apiKey: process.env.OPENROUTER_API_KEY ?? '', model: { id: 'openai/gpt-4o-mini' } },`,\n `})`,\n ``,\n ].join('\\n')\n}\n\nfunction generateSandboxTemplate(name: string): string {\n const camel = toCamelCase(name)\n const base = name.split('/').pop() ?? name\n const snake = base.replace(/-/g, '_')\n return [\n `import { tool } from 'theokit/server'`,\n `import { LocalSandbox } from '@theokit/sdk/sandbox'`,\n `import { z } from 'zod'`,\n ``,\n `/**`,\n ` * A sandbox-backed agent tool. \\`LocalSandbox\\` (@theokit/sdk) runs a shell command with a timeout +`,\n ` * output cap, isolated from your app process — so the agent can run commands SAFELY. This IS an agent`,\n ` * capability: connect it to your agent with \\`.tool(...)\\`:`,\n ` *`,\n ` * // agents/chat.ts`,\n ` * import { ${camel}Tool } from './sandbox/${base}.js'`,\n ` * AgentBuilder.create().model(...).tool(${camel}Tool).build()`,\n ` */`,\n `export const ${camel}Tool = tool('${snake}')`,\n ` .describe('Run a shell command in an isolated sandbox and return its output.')`,\n ` .input(z.object({ command: z.string().describe('The shell command to run, e.g. \"ls -la\"') }))`,\n ` .execute(async ({ command }) => {`,\n ` const sandbox = new LocalSandbox({ timeoutMs: 5_000 })`,\n ` const { stdout, stderr, exitCode } = await sandbox.execute(command)`,\n ` return exitCode === 0 ? stdout : \\`exit \\${exitCode}: \\${stderr}\\``,\n ` })`,\n ` .build()`,\n ``,\n ].join('\\n')\n}\n\nfunction generateMemoryTemplate(_name: string): string {\n return [\n `/**`,\n ` * Conversation memory — nothing to wire.`,\n ` *`,\n ` * Since @theokit/sdk 4.0, every agent session persists AUTOMATICALLY to a native Claude-shaped`,\n ` * transcript. TheoKit roots it at your app under \\`.data/agent-sessions/projects/<cwd>/<agentId>.jsonl\\`,`,\n ` * keyed by the conversation's session id — a same-session follow-up request resumes prior turns with`,\n ` * zero setup. There is no storage adapter to construct or pass to the agent anymore.`,\n ` *`,\n ` * Keep these transcripts out of git — add \\`.data/\\` to your \\`.gitignore\\`.`,\n ` *`,\n ` * Advanced: to change WHERE sessions are written (e.g. \\`~/.claude\\` so the Claude Code CLI can`,\n ` * \\`--continue\\` them), set the SDK's \\`local.baseDir\\` where you create the agent. Most apps never need to.`,\n ` */`,\n `export {}`,\n ``,\n ].join('\\n')\n}\n\n/** The project directories from `theo.config.ts`, each relative to the project root. */\ninterface ProjectLayout {\n appDir: string\n serverDir: string\n agentsDir: string\n}\n\n/** Where a single-file kind is written, relative to the project root, and what it says. */\ninterface SingleFileKind {\n path: (name: string, layout: ProjectLayout) => string\n /** `displayPath` is the project-relative path, for a template that names its own file. */\n template: (name: string, displayPath: string) => string\n}\n\n/**\n * The single-file kinds. `resource` writes several files and `schedule` checks more than its\n * directory, so neither is here. Every path starts from a directory `theo.config.ts` declares: the\n * scaffold puts them under `src/`, and a hardcoded `server/` wrote files no scanner reads (#1031).\n */\nconst SINGLE_FILE_KINDS: Partial<Record<GeneratorType, SingleFileKind>> = {\n // Agent-capability generators. These live UNDER `agentsDir` — they are facets of the agent\n // domain, not standalone top-level concerns — and the folder-semantic scanner treats each as\n // composition (never a phantom route).\n workflow: {\n path: (name, { agentsDir }) => posix.join(agentsDir, 'workflows', `${name}.ts`),\n template: generateWorkflowTemplate,\n },\n eval: {\n path: (name, { agentsDir }) => posix.join(agentsDir, 'evals', `${name}.ts`),\n template: generateEvalTemplate,\n },\n sandbox: {\n path: (name, { agentsDir }) => posix.join(agentsDir, 'sandbox', `${name}.ts`),\n template: generateSandboxTemplate,\n },\n memory: {\n path: (name, { agentsDir }) => posix.join(agentsDir, 'memory', `${name}.ts`),\n template: generateMemoryTemplate,\n },\n route: {\n path: (name, { serverDir }) => posix.join(serverDir, 'routes', `${name}.ts`),\n template: generateRouteTemplate,\n },\n action: {\n path: (name, { serverDir }) => posix.join(serverDir, 'actions', `${name}.ts`),\n template: generateActionTemplate,\n },\n page: {\n path: (name, { appDir }) => posix.join(appDir, name, 'page.tsx'),\n template: generatePageTemplate,\n },\n ws: {\n path: (name, { serverDir }) => posix.join(serverDir, 'ws', `${name}.ts`),\n template: generateWsTemplate,\n },\n controller: {\n path: (name, { serverDir }) => posix.join(serverDir, 'controllers', `${name}.controller.ts`),\n template: generateControllerTemplate,\n },\n // `<agentsDir>/<name>.ts` is what the agent scanner serves at `/api/agents/<name>`, the URL the\n // template promises. The old `server/agents/<name>.agent.ts` was outside `agentsDir` in both the\n // flat and the scaffold layout, so the agent was never served.\n agent: {\n path: (name, { agentsDir }) => posix.join(agentsDir, `${name}.ts`),\n template: generateAgentTemplate,\n },\n toolbox: {\n path: (name, { serverDir }) => posix.join(serverDir, 'toolboxes', `${name}.tools.ts`),\n template: generateToolboxTemplate,\n },\n}\n\n/** The project layout from `theo.config.ts`, or the refusal naming why it could not be read. */\nasync function readLayout(cwd: string): Promise<ProjectLayout | GenerateResult> {\n try {\n const { appDir, serverDir, agentsDir } = await loadConfig(cwd)\n return { appDir, serverDir, agentsDir }\n } catch (err) {\n return {\n status: 'invalid_config',\n message: `Cannot read ${resolve(cwd, 'theo.config.ts')}: ${(err as Error).message}`,\n }\n }\n}\n\nasync function resolveTemplate(\n cwd: string,\n kind: GeneratorType,\n name: string,\n): Promise<Target | GenerateResult | null> {\n const spec = SINGLE_FILE_KINDS[kind]\n if (spec === undefined) return null\n const layout = await readLayout(cwd)\n if ('status' in layout) return layout\n const displayPath = spec.path(name, layout)\n return { filePath: resolve(cwd, displayPath), content: spec.template(name, displayPath) }\n}\n\nfunction generateActionTestTemplate(name: string): string {\n const camel = toCamelCase(name)\n return [\n `import { describe, it, expect } from 'vitest'`,\n ``,\n `import { ${camel} } from './${name.split('/').pop()}.js'`,\n ``,\n `describe('${name} action', () => {`,\n ` it('should accept a valid input shape', () => {`,\n ` expect(${camel}.input).toBeDefined()`,\n ` expect(typeof ${camel}.handler).toBe('function')`,\n ` })`,\n ``,\n ` it('should reject invalid input via zod schema', () => {`,\n ` const parsed = ${camel}.input.safeParse({ __invalid: true })`,\n ` // Empty object schema accepts {}; tighten this assertion when adding fields.`,\n ` expect(parsed.success).toBe(true)`,\n ` })`,\n `})`,\n ``,\n ].join('\\n')\n}\n\nfunction generatePageTemplate(name: string): string {\n const pascal = toPascalCase(name)\n return [`export default function ${pascal}Page() {`, ` return <h1>${pascal}</h1>`, `}`, ``].join(\n '\\n',\n )\n}\n\nfunction generateWsTemplate(_name: string): string {\n return [\n `import { defineWebSocket } from 'theokit/server'`,\n ``,\n `export default defineWebSocket({`,\n ` onMessage(ws, data) {`,\n ` ws.send(\\`echo: \\${data}\\`)`,\n ` },`,\n `})`,\n ``,\n ].join('\\n')\n}\n\n/** A file to write: where it goes and what it says. */\ninterface Target {\n filePath: string\n content: string\n}\n\n/** Whether `value` names a generator kind. */\nfunction isGeneratorType(value: string): value is GeneratorType {\n return (VALID_TYPES as readonly string[]).includes(value)\n}\n\n/**\n * The refusal for options `generate` cannot act on: not a project, an unknown kind, a name that is\n * not kebab-case, or a reserved basename. `undefined` when the options are acceptable.\n */\nfunction refuseOptions({ cwd, type, name }: GenerateOptions): GenerateResult | undefined {\n if (!existsSync(resolve(cwd, 'theo.config.ts')) && !existsSync(resolve(cwd, 'theo.config.js'))) {\n return {\n status: 'not_a_project',\n message: 'Not a Theo project. cwd has no theo.config.ts or theo.config.js',\n }\n }\n\n if (!isGeneratorType(type)) {\n return {\n status: 'invalid_kind',\n message: `Invalid generator type \"${type}\". Available: ${VALID_TYPES.join(', ')}`,\n }\n }\n\n if (!name || !toKebabCase(name)) {\n return {\n status: 'invalid_name',\n message: `Invalid name \"${name}\". Use kebab-case: lowercase letters, numbers, hyphens. Example: my-route`,\n }\n }\n\n // EC-2-related: reject reserved JS identifier basenames (would shadow\n // built-in prototype machinery in virtual module emit or scan).\n if (hasReservedSegment(name)) {\n return {\n status: 'invalid_name',\n message: `Reserved name \"${name}\" — basename collides with built-in identifier (index/constructor/__proto__/prototype/hasOwnProperty).`,\n }\n }\n return undefined\n}\n\n/** Where a single-file kind goes and what it says, or the refusal that explains why it cannot. */\nasync function resolveTarget(\n cwd: string,\n type: GeneratorType,\n name: string,\n): Promise<Target | GenerateResult> {\n // A schedule's directory comes from the project config, so resolving it is async and may refuse.\n if (type === 'schedule') return resolveScheduleTarget(cwd, name)\n const target = await resolveTemplate(cwd, type, name)\n if (target === null) return { status: 'invalid_kind', message: `Unknown type: ${type}` }\n return target\n}\n\n/** Write `target` unless it escapes the project or already exists. */\nfunction writeTarget(\n cwd: string,\n type: GeneratorType,\n name: string,\n { filePath, content }: Target,\n): GenerateResult {\n // EC-4: confirm the resolved filePath stays inside cwd. `toKebabCase` rejects most traversal\n // vectors in the name, but a directory read from config (`agentsDir`) can still point outside.\n const escaped = pathTraversalRefusal(cwd, filePath)\n if (escaped !== undefined) return escaped\n\n if (existsSync(filePath)) {\n return { status: 'already_exists', filePath, kind: type, name }\n }\n\n mkdirSync(dirname(filePath), { recursive: true })\n writeFileSync(filePath, content)\n\n // T5.2 + plan Q4: emit co-located test file alongside actions (only\n // for action type; routes/pages/ws keep prior single-file behavior).\n // Skip if existing test file present (preserve user-customized tests).\n if (type === 'action') {\n const testPath = filePath.replace(/\\.ts$/, '.test.ts')\n if (!existsSync(testPath)) {\n writeFileSync(testPath, generateActionTestTemplate(name))\n }\n }\n\n return { status: 'created', filePath, kind: type, name }\n}\n\n/**\n * Programmatic generate. Returns a structured result instead of throwing —\n * Studio (`theokit_generate` tool) consumes this directly. The CLI wrapper\n * below maps the structured result to console output + exit code semantics.\n */\nexport async function generate(opts: GenerateOptions): Promise<GenerateResult> {\n const refused = refuseOptions(opts)\n if (refused !== undefined) return refused\n const { cwd, name } = opts\n // refuseOptions refused every value that is not a generator kind.\n const kind = opts.type as GeneratorType\n\n // Resource generates multiple files — handle separately\n if (kind === 'resource') {\n const layout = await readLayout(cwd)\n if ('status' in layout) return layout\n return generateResource(cwd, name, opts.fields ?? [], layout.serverDir)\n }\n\n const resolved = await resolveTarget(cwd, kind, name)\n if ('status' in resolved) return resolved\n return writeTarget(cwd, kind, name, resolved)\n}\n\n/** The statuses the CLI reports by throwing, and the message each throws. */\nconst CLI_REFUSALS: Record<\n Exclude<GenerateStatus, 'created' | 'already_exists'>,\n (result: GenerateResult, name: string) => string\n> = {\n // The generator's own reason when it gave one: `generate resource` refuses a project that HAS a\n // theo.config.ts when the schema file is missing, and the generic text blamed the config (#1022).\n not_a_project: (result) =>\n result.message ?? 'Not a Theo project. Run this from a project root with theo.config.ts',\n invalid_kind: (result) => result.message ?? 'Invalid kind',\n // `generate` returns invalid_name for a malformed name, a reserved name and a path that\n // resolves outside the project; each message says which, so the CLI must not replace it.\n invalid_name: (result, name) => result.message ?? `Invalid name \"${name}\"`,\n invalid_config: (result) => result.message ?? 'Invalid theo.config.ts',\n agent_not_found: (result) => result.message ?? 'No chat agent found',\n}\n\n/**\n * CLI entry point — preserves the original surface (throws + console.log).\n * Wraps the programmatic `generate` function.\n */\nexport async function generateCommand(\n type: string,\n name: string,\n fields?: string[],\n): Promise<void> {\n const result = await generate({ cwd: process.cwd(), type, name, fields })\n if (result.status === 'already_exists') {\n console.log(`\\n ⚠ ${result.filePath} already exists. Skipping.\\n`)\n } else if (result.status === 'created') {\n console.log(`\\n ✓ Created ${type}: ${result.filePath}\\n`)\n } else {\n throw new Error(CLI_REFUSALS[result.status](result, name))\n }\n}\n","/**\n * The one rule every generator applies before writing: the file stays inside the project. Shared\n * by `generate` and the schedule generator, which checks it before looking for the chat agent so an\n * `agentsDir` outside the project is refused as traversal, never reported as a missing agent there.\n */\nimport { isAbsolute, relative, resolve, sep } from 'node:path'\n\nimport type { GenerateResult } from './generate-types.js'\n\n/**\n * Whether `filePath` lies strictly inside `cwd`. Decided by `path.relative`, never by a string\n * prefix: `/tmp/x/app-outside/...` starts with `/tmp/x/app` and is still outside it. A null byte,\n * an absolute path and a `..` escape are all outside.\n */\nfunction isPathInside(cwd: string, filePath: string): boolean {\n if (filePath.includes('\\x00')) return false\n const fromRoot = relative(resolve(cwd), filePath)\n return fromRoot !== '' && !isAbsolute(fromRoot) && fromRoot.split(sep)[0] !== '..'\n}\n\n/** The refusal for a `filePath` outside the project at `cwd`, or `undefined` when it is inside. */\nexport function pathTraversalRefusal(cwd: string, filePath: string): GenerateResult | undefined {\n if (isPathInside(cwd, filePath)) return undefined\n return {\n status: 'invalid_name',\n message: `Path traversal denied: \"${filePath}\" is outside the project root ${resolve(cwd)}.`,\n }\n}\n","/**\n * The access policy a generated route carries until its author decides one.\n *\n * ADR 0001 made an undeclared `policy` a build error because \"a route that nobody had thought\n * about was indistinguishable from a route deliberately left open\". The generators then wrote\n * `'public'` — including on five methods that read and write a database table — so a generated\n * file was the not-thought-about case wearing the deliberate value, which is the precise state\n * the gate exists to make impossible (usetheokit/theokit#416). `theo build` accepted it, because\n * `assertEveryMethodDeclaresPolicy` asks whether a policy was declared, not which one.\n *\n * A generated route now REFUSES. The author still has to write the answer down — the gate's whole\n * purpose — but the value standing in until they do is the safe one rather than the open one.\n *\n * ## Why an AccessDecision and not `() => false`\n *\n * `evaluateRoutePolicy` maps a bare `false` to \"access denied by route policy\", which tells the\n * reader nothing about where to go. The contract already says a denial \"carries its reason so the\n * caller can say it\", so the refusal names its own file: the first `curl` against a forgotten\n * route prints the path to edit.\n *\n * ## Why a named const rather than a lambda per method\n *\n * Five methods would mean five copies, and deleting four of them is the kind of chore that leaves\n * the fifth behind. One const is one thing to replace, and `grep -rn undecidedPolicy` counts the\n * routes still awaiting a decision — which is the number ADR 0001 wanted to make greppable, and\n * which `grep -c \"policy('public')\"` could not give once generated placeholders were mixed in with\n * real decisions.\n */\n\n/** The identifier the generated methods reference. Exported so callers cannot misspell it. */\nexport const UNDECIDED_POLICY_IDENT = 'undecidedPolicy'\n\n/**\n * Lines declaring the placeholder, to splice into a generated module.\n *\n * @param routePath - the generated file's own path, repo-relative, so the refusal can name it\n * @param what - what the route does, in one clause, for the TODO comment\n */\nexport function undecidedPolicyDeclaration(routePath: string, what: string): string[] {\n return [\n `// TODO(policy): every route declares who may call it (ADR 0001). Generated as a REFUSAL`,\n `// rather than 'public', because the generator cannot know your access model —`,\n `// ${what}.`,\n `// Replace this with 'public' if the route is genuinely open, or with a check such as`,\n `// \\`({ subject, params }) => requireOwner(subject, ownerOf(params.id))\\`, then delete the const.`,\n `const ${UNDECIDED_POLICY_IDENT} = (): AccessDecision => ({`,\n ` allowed: false,`,\n ` reason:`,\n ` '${routePath} still carries the policy the generator wrote, which refuses everyone. ' +`,\n ` 'Declare who may call this route (ADR 0001).',`,\n `})`,\n ]\n}\n","import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'\nimport { dirname, join, resolve } from 'node:path'\n\nimport {\n UNDECIDED_POLICY_IDENT,\n undecidedPolicyDeclaration,\n} from './generate-policy-placeholder.js'\nimport type { GenerateResult } from './generate-types.js'\n\n// --- Field parsing ---\n\nconst ALLOWED_FIELD_TYPES = new Set(['string', 'text', 'number', 'boolean'])\nconst RESERVED_FIELDS = new Set(['id', 'createdAt', 'created_at'])\n\ninterface ResourceField {\n name: string\n type: 'string' | 'text' | 'number' | 'boolean'\n zodType: string\n}\n\nfunction parseResourceFields(args: string[]): ResourceField[] {\n if (args.length === 0) {\n throw new Error(\n 'Resource requires at least one field. Example: theokit generate resource posts title:string',\n )\n }\n return args.map((arg) => {\n const parts = arg.split(':')\n if (parts.length !== 2 || !parts[0] || !parts[1]) {\n throw new Error(`Invalid field \"${arg}\". Use name:type format (e.g. title:string)`)\n }\n const [name, type] = parts\n if (!ALLOWED_FIELD_TYPES.has(type)) {\n throw new Error(\n `Unknown field type \"${type}\" in \"${arg}\". Valid types: ${[...ALLOWED_FIELD_TYPES].join(', ')}`,\n )\n }\n if (RESERVED_FIELDS.has(name)) {\n throw new Error(`Field \"${name}\" is reserved (auto-generated by the framework)`)\n }\n const fieldType = type as ResourceField['type']\n return {\n name,\n type: fieldType,\n zodType: mapZodType(fieldType),\n }\n })\n}\n\n// --- Dialects ---\n\n/**\n * The SQL dialects the generator writes code for. Drizzle's synchronous SQLite drivers expose\n * `.all()`/`.get()`/`.run()` on a query; the Postgres drivers do not, so the two need different\n * table builders AND different handler bodies (usetheokit/theokit#1022).\n */\ntype ResourceDialect = 'sqlite' | 'postgresql'\n\ninterface DialectSpec {\n /** The Drizzle module the table builders come from. */\n readonly module: string\n /** A minimal `<serverDir>/db/index.ts` exporting `db`, shown when the project has none. */\n readonly dbIndexExample: readonly string[]\n /** Matches an existing named import from `module`; group 1 is the list of names. */\n readonly importPattern: RegExp\n /** The table builder function. */\n readonly table: string\n /** Every column builder the generated table may use, imported up front. */\n readonly columns: readonly string[]\n readonly idColumn: string\n readonly createdAtColumn: readonly string[]\n readonly column: (name: string, type: ResourceField['type']) => string\n}\n\nconst DIALECTS: Record<ResourceDialect, DialectSpec> = {\n sqlite: {\n module: 'drizzle-orm/sqlite-core',\n dbIndexExample: [\n `import Database from 'better-sqlite3'`,\n `import { drizzle } from 'drizzle-orm/better-sqlite3'`,\n `import * as schema from './schema.js'`,\n `export const db = drizzle(new Database('data.db'), { schema })`,\n ],\n importPattern: /import\\s*\\{([^}]*)\\}\\s*from\\s*['\"]drizzle-orm\\/sqlite-core['\"]/,\n table: 'sqliteTable',\n columns: ['integer', 'text'],\n idColumn: `integer('id').primaryKey({ autoIncrement: true })`,\n createdAtColumn: [\n `text('created_at')`,\n ` .notNull()`,\n ` .$defaultFn(() => new Date().toISOString().split('T')[0])`,\n ],\n column: (name, type) => {\n switch (type) {\n case 'string':\n case 'text':\n return `text('${name}').notNull()`\n case 'number':\n return `integer('${name}').notNull()`\n case 'boolean':\n return `integer('${name}', { mode: 'boolean' }).notNull().default(false)`\n }\n },\n },\n postgresql: {\n module: 'drizzle-orm/pg-core',\n dbIndexExample: [\n `import pg from 'pg'`,\n `import { drizzle } from 'drizzle-orm/node-postgres'`,\n `import * as schema from './schema.js'`,\n `const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL })`,\n `pool.on('error', (err) => console.warn('[pg] idle client error:', err.message))`,\n `export const db = drizzle(pool, { schema })`,\n ],\n importPattern: /import\\s*\\{([^}]*)\\}\\s*from\\s*['\"]drizzle-orm\\/pg-core['\"]/,\n table: 'pgTable',\n columns: ['boolean', 'integer', 'serial', 'text', 'timestamp'],\n idColumn: `serial('id').primaryKey()`,\n createdAtColumn: [`timestamp('created_at').notNull().defaultNow()`],\n column: (name, type) => {\n switch (type) {\n case 'string':\n case 'text':\n return `text('${name}').notNull()`\n case 'number':\n return `integer('${name}').notNull()`\n case 'boolean':\n return `boolean('${name}').notNull().default(false)`\n }\n },\n },\n}\n\n/** A `dialect:` value in `drizzle.config.ts`, mapped to what the generator does with it. */\nconst DIALECT_ALIASES: Record<string, ResourceDialect | undefined> = {\n sqlite: 'sqlite',\n turso: 'sqlite',\n postgresql: 'postgresql',\n}\n\nconst SCHEMA_IMPORT_DIALECTS: [RegExp, string][] = [\n [/from ['\"]drizzle-orm\\/sqlite-core['\"]/, 'sqlite'],\n [/from ['\"]drizzle-orm\\/pg-core['\"]/, 'postgresql'],\n [/from ['\"]drizzle-orm\\/mysql-core['\"]/, 'mysql'],\n [/from ['\"]drizzle-orm\\/singlestore-core['\"]/, 'singlestore'],\n]\n\n/**\n * The project's dialect: `drizzle.config.ts` says it outright; failing that, the core module the\n * schema already imports from does. A schema that imports from nothing (a fresh file) and no config\n * leaves the historical default, SQLite.\n *\n * @returns the dialect, or the raw name of one the generator cannot write code for.\n */\nfunction detectDialect(cwd: string, schemaSource: string): string {\n const config = readIfPresent(resolve(cwd, 'drizzle.config.ts'))\n if (config !== undefined) {\n const declared = /dialect\\s*:\\s*['\"]([a-z0-9-]+)['\"]/.exec(config)\n if (declared) return declared[1]\n }\n for (const [pattern, dialect] of SCHEMA_IMPORT_DIALECTS) {\n if (pattern.test(schemaSource)) return dialect\n }\n return 'sqlite'\n}\n\nfunction mapZodType(type: ResourceField['type']): string {\n switch (type) {\n case 'string':\n case 'text':\n return 'z.string()'\n case 'number':\n return 'z.number()'\n case 'boolean':\n return 'z.boolean()'\n }\n}\n\n// --- Template generators ---\n\nfunction generateSchemaEntry(\n resourceName: string,\n fields: ResourceField[],\n dialect: DialectSpec,\n): string {\n const [createdAtFirst, ...createdAtRest] = dialect.createdAtColumn\n const cols = [\n ` id: ${dialect.idColumn},`,\n ...fields.map((f) => ` ${f.name}: ${dialect.column(f.name, f.type)},`),\n ` createdAt: ${createdAtFirst}`,\n ...createdAtRest,\n ]\n cols[cols.length - 1] += ','\n return [\n ``,\n `export const ${resourceName} = ${dialect.table}('${resourceName}', {`,\n ...cols,\n `})`,\n ``,\n ].join('\\n')\n}\n\n/**\n * The schema source with the table builders the appended table uses imported. The generator used to\n * append `sqliteTable(...)` with no import at all, so the schema file stopped compiling.\n *\n * An existing named import from the dialect module gains the missing names; without one, an import\n * line goes on top. Names already imported are not repeated.\n */\nfunction withDialectImports(source: string, dialect: DialectSpec): string {\n const needed = [dialect.table, ...dialect.columns]\n const existing = dialect.importPattern.exec(source)\n if (existing) {\n const have = existing[1]\n .split(',')\n .map((n) => n.trim())\n .filter(Boolean)\n const merged = [...new Set([...have, ...needed])].sort((a, b) => a.localeCompare(b))\n return source.replace(existing[0], `import { ${merged.join(', ')} } from '${dialect.module}'`)\n }\n return `import { ${[...needed].sort((a, b) => a.localeCompare(b)).join(', ')} } from '${dialect.module}'\\n${source}`\n}\n\n/**\n * Query expressions per dialect. SQLite's synchronous drivers finish a query with `.all()`, `.get()`\n * or `.run()`; the Postgres drivers return a promise and have none of the three, so the Postgres\n * handlers await the builder and take the first row of `returning()`.\n */\ninterface QueryShapes {\n readonly async: boolean\n list(table: string): string\n insert(table: string): string\n findById(table: string): string\n updateById(table: string): string\n deleteById(table: string): string\n}\n\nconst QUERIES: Record<ResourceDialect, QueryShapes> = {\n sqlite: {\n async: false,\n list: (t) => `db.select().from(${t}).all()`,\n insert: (t) => `db.insert(${t}).values(body).returning().get()`,\n findById: (t) => `db.select().from(${t}).where(eq(${t}.id, params.id)).get()`,\n updateById: (t) => `db.update(${t}).set(body).where(eq(${t}.id, params.id)).returning().get()`,\n deleteById: (t) => `db.delete(${t}).where(eq(${t}.id, params.id)).run()`,\n },\n postgresql: {\n async: true,\n list: (t) => `await db.select().from(${t})`,\n insert: (t) => `(await db.insert(${t}).values(body).returning())[0]`,\n findById: (t) => `(await db.select().from(${t}).where(eq(${t}.id, params.id)))[0]`,\n updateById: (t) =>\n `(await db.update(${t}).set(body).where(eq(${t}.id, params.id)).returning())[0]`,\n deleteById: (t) => `await db.delete(${t}).where(eq(${t}.id, params.id))`,\n },\n}\n\ninterface RouteTemplateInput {\n resourceName: string\n fields: ResourceField[]\n queries: QueryShapes\n /** Project-relative path of the file being written, named by the placeholder policy. */\n displayPath: string\n}\n\nfunction generateRouteIndex({\n resourceName,\n fields,\n queries,\n displayPath,\n}: RouteTemplateInput): string {\n const bodyFields = fields.map((f) => ` ${f.name}: ${f.zodType},`).join('\\n')\n const asyncKw = queries.async ? 'async ' : ''\n return [\n `import { route, type AccessDecision } from 'theokit/server/define'`,\n `import { z } from 'zod'`,\n `import { db } from '../../db/index.js'`,\n `import { ${resourceName} } from '../../db/schema.js'`,\n ``,\n ...undecidedPolicyDeclaration(displayPath, 'these methods read and write a table'),\n ``,\n `export const GET = route()`,\n ` .policy(${UNDECIDED_POLICY_IDENT})`,\n ` .handler(${asyncKw}() => ${queries.list(resourceName)})`,\n ` .build()`,\n ``,\n `export const POST = route()`,\n ` .policy(${UNDECIDED_POLICY_IDENT})`,\n ` .body(`,\n ` z.object({`,\n bodyFields,\n ` }),`,\n ` )`,\n ` .status(201)`,\n ` .handler(${asyncKw}({ body }) => {`,\n ` const result = ${queries.insert(resourceName)}`,\n ` return result`,\n ` })`,\n ` .build()`,\n ``,\n ].join('\\n')\n}\n\nfunction generateRouteId({\n resourceName,\n fields,\n queries,\n displayPath,\n}: RouteTemplateInput): string {\n const updateFields = fields.map((f) => ` ${f.name}: ${f.zodType}.optional(),`).join('\\n')\n const asyncKw = queries.async ? 'async ' : ''\n return [\n `import { route, type AccessDecision } from 'theokit/server/define'`,\n `import { z } from 'zod'`,\n `import { db } from '../../db/index.js'`,\n `import { ${resourceName} } from '../../db/schema.js'`,\n `import { eq } from 'drizzle-orm'`,\n ``,\n ...undecidedPolicyDeclaration(\n displayPath,\n 'these methods read, update and delete rows of a table',\n ),\n ``,\n `export const GET = route()`,\n ` .policy(${UNDECIDED_POLICY_IDENT})`,\n ` .params(z.object({ id: z.coerce.number() }))`,\n ` .handler(${asyncKw}({ params }) => {`,\n ` const item = ${queries.findById(resourceName)}`,\n ` if (!item) return new Response(JSON.stringify({ error: 'Not found' }), { status: 404 })`,\n ` return item`,\n ` })`,\n ` .build()`,\n ``,\n `export const PUT = route()`,\n ` .policy(${UNDECIDED_POLICY_IDENT})`,\n ` .params(z.object({ id: z.coerce.number() }))`,\n ` .body(`,\n ` z.object({`,\n updateFields,\n ` }),`,\n ` )`,\n ` .handler(${asyncKw}({ params, body }) => {`,\n ` const result = ${queries.updateById(resourceName)}`,\n ` if (!result) return new Response(JSON.stringify({ error: 'Not found' }), { status: 404 })`,\n ` return result`,\n ` })`,\n ` .build()`,\n ``,\n `export const DELETE = route()`,\n ` .policy(${UNDECIDED_POLICY_IDENT})`,\n ` .params(z.object({ id: z.coerce.number() }))`,\n ` .status(204)`,\n ` .handler(${asyncKw}({ params }) => {`,\n ` ${queries.deleteById(resourceName)}`,\n ` })`,\n ` .build()`,\n ``,\n ].join('\\n')\n}\n\nfunction generateTestTemplate(resourceName: string, serverDir: string): string {\n return [\n `import { describe, it, expect } from 'vitest'`,\n ``,\n `describe('${resourceName} API', () => {`,\n ` it('should have a schema defined', async () => {`,\n ` const schema = await import('../${serverDir}/db/schema.js')`,\n ` expect(schema.${resourceName}).toBeDefined()`,\n ` })`,\n ``,\n ` it('should have route handlers', async () => {`,\n ` const index = await import('../${serverDir}/routes/${resourceName}/index.js')`,\n ` expect(index.GET).toBeDefined()`,\n ` expect(index.POST).toBeDefined()`,\n ` })`,\n `})`,\n ``,\n ].join('\\n')\n}\n\n// --- Orchestrator ---\n\n/**\n * Generate a CRUD resource: a table appended to `<serverDir>/db/schema.ts`, two route files under\n * `<serverDir>/routes/<name>/` and a test.\n *\n * @param serverDir - the project-relative `serverDir` from `theo.config.ts`. The generator used to\n * assume `server/`, so in the scaffold (`src/server`) it refused every time.\n */\nfunction readIfPresent(path: string): string | undefined {\n try {\n return readFileSync(path, 'utf-8')\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') return undefined\n throw err\n }\n}\n\n/** The files TypeScript resolves `../../db/index.js` to. */\nconst DB_INDEX_FILES = ['index.ts', 'index.tsx', 'index.js']\n\n/** Create `path` only if it does not exist; `false` when it already did. */\nfunction createExclusive(path: string, content: string): boolean {\n try {\n writeFileSync(path, content, { flag: 'wx' })\n return true\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === 'EEXIST') return false\n throw err\n }\n}\n\nexport function generateResource(\n cwd: string,\n name: string,\n fieldArgs: string[],\n serverDir = 'server',\n): GenerateResult {\n let fields: ResourceField[]\n try {\n fields = parseResourceFields(fieldArgs)\n } catch (err) {\n return { status: 'invalid_name', message: err instanceof Error ? err.message : String(err) }\n }\n\n const schemaRel = join(serverDir, 'db', 'schema.ts')\n const routeDirRel = join(serverDir, 'routes', name)\n const schemaPath = resolve(cwd, schemaRel)\n const routeIndexPath = resolve(cwd, routeDirRel, 'index.ts')\n const routeIdPath = resolve(cwd, routeDirRel, '[id].ts')\n const testPath = resolve(cwd, `tests/${name}.test.ts`)\n\n // Read rather than check-then-read, and create the new files with `wx` rather than\n // check-then-write: the answer can change between a check and the write that trusts it.\n const existingSchema = readIfPresent(schemaPath)\n if (existingSchema === undefined) {\n return {\n status: 'not_a_project',\n message:\n `${schemaRel} not found. \\`theokit generate resource\\` appends the table to the Drizzle ` +\n `schema under the configured serverDir (\"${serverDir}\"); create it first.`,\n }\n }\n if (existingSchema.includes(`export const ${name} =`)) {\n return {\n status: 'already_exists',\n filePath: schemaPath,\n kind: 'resource',\n name,\n message: `Table \"${name}\" already exists in ${schemaRel}`,\n }\n }\n\n const detected = detectDialect(cwd, existingSchema)\n const dialectName = DIALECT_ALIASES[detected]\n if (dialectName === undefined) {\n return {\n status: 'invalid_config',\n message:\n `\\`theokit generate resource\\` writes code for SQLite and PostgreSQL; this project uses ` +\n `\"${detected}\" (from drizzle.config.ts or the imports in ${schemaRel}). Nothing was written.`,\n }\n }\n const dialect = DIALECTS[dialectName]\n const queries = QUERIES[dialectName]\n\n // The routes import `db` from `<serverDir>/db/index.js`. Without the file the command reported\n // success and the next build failed with `Could not resolve` (usetheokit/theokit#1038). Which\n // driver to install is the project's choice, so the generator refuses rather than writing one.\n const dbIndexRel = join(serverDir, 'db', 'index.ts')\n if (!DB_INDEX_FILES.some((file) => existsSync(resolve(cwd, serverDir, 'db', file)))) {\n const example = dialect.dbIndexExample.map((line) => ' ' + line).join('\\n')\n return {\n status: 'not_a_project',\n message:\n `${dbIndexRel} not found. The routes \\`theokit generate resource\\` writes import \\`db\\` ` +\n `from it, so the build would fail to resolve it. Create it with \\`export const db\\`, for ` +\n `example (${dialectName}):\\n\\n${example}\\n\\n` +\n `Nothing was written.`,\n }\n }\n\n // 1. Create the route files first: an existing route refuses before the schema is touched.\n mkdirSync(dirname(routeIndexPath), { recursive: true })\n const template = { resourceName: name, fields, queries }\n if (\n !createExclusive(\n routeIndexPath,\n generateRouteIndex({ ...template, displayPath: join(routeDirRel, 'index.ts') }),\n )\n ) {\n return { status: 'already_exists', filePath: routeIndexPath, kind: 'resource', name }\n }\n writeFileSync(\n routeIdPath,\n generateRouteId({ ...template, displayPath: join(routeDirRel, '[id].ts') }),\n )\n\n // 2. Append the table, with the builders it uses imported.\n writeFileSync(\n schemaPath,\n withDialectImports(existingSchema, dialect) + generateSchemaEntry(name, fields, dialect),\n )\n\n // 3. Create the test file, keeping one the user already has.\n mkdirSync(dirname(testPath), { recursive: true })\n createExclusive(testPath, generateTestTemplate(name, serverDir))\n\n return { status: 'created', filePath: routeIndexPath, kind: 'resource', name }\n}\n","/**\n * The `theokit generate schedule` generator.\n *\n * A schedule must land where `theokit build` scans (`<agentsDir>/schedules`), so its directory is\n * read from the project config through `loadConfig`, the same reader the build uses. When the\n * config cannot be read the generator refuses by name instead of guessing a directory.\n *\n * A schedule runs the app's `chat` agent, so a project without one is refused too: a schedule\n * importing a module that does not exist would make `theokit build` fail on it.\n *\n * The schedule declares `defineCron('<last segment of the name>')`, so that segment is checked with\n * `defineCron`'s own rule and the scanner's own discovery: a name the build would reject, skip, or\n * find already used by another cron file is refused as `invalid_name` before anything is written.\n */\nimport { basename, dirname, extname, relative, resolve, sep } from 'node:path'\n\nimport { loadConfig } from '../../config/load-config.js'\nimport { cronScanDirs, isDiscoverableCronFile, listCronFiles } from '../../server/cron/cron-scan.js'\nimport { CRON_NAME_RULE, isValidCronName } from '../../server/cron/define-cron.js'\nimport { findAgentFile } from '../../server/scan/agent-scan.js'\n\nimport { pathTraversalRefusal } from './generate-containment.js'\nimport type { GenerateResult } from './generate-types.js'\n\n/** Where the schedule goes and what it says, or the refusal that explains why it cannot be written. */\nexport async function resolveScheduleTarget(\n cwd: string,\n name: string,\n): Promise<{ filePath: string; content: string } | GenerateResult> {\n const malformed = cronNameRefusal(name)\n if (malformed !== undefined) return malformed\n let config: Awaited<ReturnType<typeof loadConfig>>\n try {\n config = await loadConfig(cwd)\n } catch (err) {\n return {\n status: 'invalid_config',\n message: `Cannot read ${resolve(cwd, 'theo.config.ts')}: ${(err as Error).message}`,\n }\n }\n const { agentsDir, serverDir } = config\n const agentsRoot = resolve(cwd, agentsDir)\n const cronDirs = cronScanDirs(cwd, serverDir, agentsDir)\n const filePath = resolve(cronDirs.schedules, `${name}.ts`)\n // Before the agent lookup: a chat agent missing from a directory outside the project is not\n // something to create, and the refusal must name the escape, not the missing file.\n const escaped = pathTraversalRefusal(cwd, filePath)\n if (escaped !== undefined) return escaped\n // The agent scanner's own rule, so the file found is the one the build serves as `chat`.\n const chatPath = findAgentFile(agentsRoot, 'chat')\n if (chatPath === undefined) {\n return {\n status: 'agent_not_found',\n message:\n `No \"chat\" agent in ${agentsRoot} (the build serves it from chat.{ts,tsx,js,jsx} or ` +\n 'chat/index.{ts,tsx,js,jsx}). A schedule runs the chat agent; create it first.',\n }\n }\n // The build scans both homes with one duplicate-name guard (build.ts, emitCronArtifacts).\n const taken = cronNameTaken(name, filePath, [cronDirs.crons, cronDirs.schedules])\n if (taken !== undefined) return taken\n return { filePath, content: generateScheduleTemplate(name, importSpecifier(filePath, chatPath)) }\n}\n\n/** The cron name a schedule called `name` declares: its last `/` segment. */\nexport function cronNameOf(name: string): string {\n return name.split('/').pop() ?? name\n}\n\n/** A refusal when the build would skip the file or `defineCron` would reject its name. */\nfunction cronNameRefusal(name: string): GenerateResult | undefined {\n const cronName = cronNameOf(name)\n if (!isDiscoverableCronFile(`${cronName}.ts`)) {\n return {\n status: 'invalid_name',\n message: `Invalid schedule name \"${name}\": the build does not discover a cron file named \"${cronName}.ts\".`,\n }\n }\n if (!isValidCronName(cronName)) {\n return {\n status: 'invalid_name',\n message: `Invalid schedule name \"${name}\": its cron name \"${cronName}\" is one defineCron rejects. ${CRON_NAME_RULE}`,\n }\n }\n return undefined\n}\n\n/**\n * A refusal when another cron file already carries this schedule's cron name. The generator names\n * a cron after its file, so a file of the same name in either cron home is the clash the build's\n * duplicate-name guard would fail on. The target itself is left to the `already_exists` answer.\n *\n * Compared by FILE name, while the build compares the name each file passes to `defineCron`, which\n * it learns only by importing the file. A hand-written `foo.ts` declaring `defineCron('bar')` is\n * not seen here, so schedule `bar` is written and the build then fails with\n * `DuplicateCronNameError`; and a `bar.ts` declaring another name refuses schedule `bar` although\n * the build would accept it. Importing every cron file to read its name would run user code at\n * generate time, which this generator does not do.\n */\nfunction cronNameTaken(\n name: string,\n filePath: string,\n cronDirs: readonly string[],\n): GenerateResult | undefined {\n const cronName = cronNameOf(name)\n const clash = listCronFiles(cronDirs).find(\n (path) => path !== filePath && basename(path, extname(path)) === cronName,\n )\n if (clash === undefined) return undefined\n return {\n status: 'invalid_name',\n message: `Invalid schedule name \"${name}\": the cron name \"${cronName}\" is already used by ${clash}. Cron names must be unique across server/crons/ and agents/schedules/.`,\n }\n}\n\n/**\n * The ESM specifier the schedule at `fromFile` uses to import `toFile` (`../chat.js`). A TypeScript\n * source is imported by its `.js` name, as TypeScript and tsx resolve it; a `.js` or `.jsx` file\n * keeps its own extension.\n */\nexport function importSpecifier(fromFile: string, toFile: string): string {\n const path = relative(dirname(fromFile), toFile)\n .split(sep)\n .join('/')\n .replace(/\\.tsx?$/, '.js')\n return path.startsWith('.') ? path : `./${path}`\n}\n\nfunction generateScheduleTemplate(name: string, chatSpecifier: string): string {\n const base = cronNameOf(name)\n return [\n `import { defineCron } from 'theokit/server/cron'`,\n `import { resolveProvider } from 'theokit/server/agent'`,\n `import { streamAgentTurnInProcess } from '@theokit/agents'`,\n ``,\n `import chat from '${chatSpecifier}'`,\n ``,\n `/**`,\n ` * A scheduled agent run, a first-class TheoKit cron. \\`theokit build\\` discovers it and translates the`,\n ` * schedule to your deploy target's native cron; \\`theokit start\\` runs it in-process.`,\n ` *`,\n ` * Each fire is one model run of your \\`chat\\` agent, so it spends tokens. Nobody is present to approve`,\n ` * a gated tool, so the run uses the \\`auto-reject\\` posture: every approval is answered \"no\" and the`,\n ` * gated tool does not run.`,\n ` *`,\n ` * Schedules are UTC (https://crontab.guru). \\`signal\\` aborts when the scheduler stops.`,\n ` */`,\n `export default defineCron('${base}', {`,\n ` schedule: '0 9 * * *', // every day at 09:00 UTC`,\n ` async handler({ traceId, scheduledAt, signal }) {`,\n ` let outcome = 'ok'`,\n ` try {`,\n ` const agent = chat as { model?: string; plugins?: readonly unknown[] }`,\n ` const { apiKey } = resolveProvider(agent.model, { plugins: agent.plugins })`,\n ` const run = streamAgentTurnInProcess(chat, apiKey, {`,\n ` message: \\`Scheduled run \"${base}\" at \\${scheduledAt.toISOString()}\\`,`,\n ` signal,`,\n ` approvals: {`,\n ` kind: 'auto-reject',`,\n ` reason: 'unattended schedule \"${base}\": nobody is present to approve',`,\n ` },`,\n ` })`,\n ` for await (const chunk of run) {`,\n ` // The SDK can report a failed run as a chunk rather than a rejection.`,\n ` if (chunk.type === 'error') {`,\n ` throw new Error(\\`[${base}] agent run failed: \\${chunk.errorText ?? 'no error text'}\\`)`,\n ` }`,\n ` }`,\n ` } catch (err) {`,\n ` outcome = \\`failed: \\${err instanceof Error ? err.message : String(err)}\\``,\n ` throw err`,\n ` } finally {`,\n ` // One traced line per fire, failed fires included: the scheduler's own error line has no trace id.`,\n ` console.log(\\`[${base}] fire \\${outcome} at \\${scheduledAt.toISOString()} (trace \\${traceId})\\`)`,\n ` }`,\n ` },`,\n `})`,\n ``,\n ].join('\\n')\n}\n","import type { CronDefinition, CronOptions } from './cron-types.js'\nimport { validateCronSchedule } from './cron-validate.js'\n\nconst NAME_RE = /^[a-z0-9][a-z0-9-]{0,63}$/\n\n/** What {@link isValidCronName} requires, in words, for an error message. */\nexport const CRON_NAME_RULE =\n 'Must be 1-64 chars, lowercase alphanumeric + hyphen, starting with [a-z0-9].'\n\n/** Whether `defineCron` accepts `name`. The generator asks this before writing a cron. */\nexport function isValidCronName(name: string): boolean {\n return typeof name === 'string' && NAME_RE.test(name)\n}\n\nfunction validateName(name: string): void {\n if (!isValidCronName(name)) {\n throw new Error(`defineCron: invalid name \"${name}\". ${CRON_NAME_RULE}`)\n }\n}\n\n/**\n * Declare a time-triggered handler. Pure identity helper — no\n * registration side effect; the build-time scanner (T1.3) discovers\n * definitions by walking `server/crons/` and emits a manifest the\n * adapters translate at deploy.\n *\n * @example\n * ```ts\n * // server/crons/morning-summary.ts\n * export default defineCron('morning-summary', {\n * schedule: '0 9 * * *', // 09:00 UTC\n * async handler({ traceId, scheduledAt, signal }) {\n * // ...\n * },\n * })\n * ```\n */\nexport function defineCron(name: string, options: CronOptions): CronDefinition {\n validateName(name)\n validateCronSchedule(options.schedule)\n return {\n name,\n schedule: options.schedule,\n handler: options.handler,\n concurrency: options.concurrency ?? 'forbid',\n }\n}\n","/**\n * Shared types for the `theokit generate` CLI command family.\n *\n * Extracted to break the circular dependency between generate.ts ↔ generate-resource.ts\n * (architecture-remediation plan T1.1, 2026-06-12).\n */\n\nexport const VALID_TYPES = [\n 'route',\n 'action',\n 'page',\n 'ws',\n 'controller',\n 'agent',\n 'toolbox',\n 'workflow',\n 'eval',\n 'sandbox',\n 'schedule',\n 'memory',\n 'resource',\n] as const\nexport type GeneratorType = (typeof VALID_TYPES)[number]\n\nexport interface GenerateOptions {\n cwd: string\n type: string\n name: string\n fields?: string[]\n}\n\nexport type GenerateStatus =\n | 'created'\n | 'already_exists'\n | 'invalid_kind'\n | 'invalid_name'\n | 'not_a_project'\n | 'invalid_config'\n | 'agent_not_found'\n\nexport interface GenerateResult {\n status: GenerateStatus\n filePath?: string\n kind?: GeneratorType\n name?: string\n message?: string\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,cAAAA,aAAY,aAAAC,YAAW,iBAAAC,sBAAqB;AACrD,SAAS,OAAO,WAAAC,UAAS,WAAAC,gBAAe;;;ACIxC,SAAS,YAAY,UAAU,SAAS,WAAW;AASnD,SAAS,aAAa,KAAa,UAA2B;AAC5D,MAAI,SAAS,SAAS,IAAM,EAAG,QAAO;AACtC,QAAM,WAAW,SAAS,QAAQ,GAAG,GAAG,QAAQ;AAChD,SAAO,aAAa,MAAM,CAAC,WAAW,QAAQ,KAAK,SAAS,MAAM,GAAG,EAAE,CAAC,MAAM;AAChF;AAGO,SAAS,qBAAqB,KAAa,UAA8C;AAC9F,MAAI,aAAa,KAAK,QAAQ,EAAG,QAAO;AACxC,SAAO;AAAA,IACL,QAAQ;AAAA,IACR,SAAS,2BAA2B,QAAQ,iCAAiC,QAAQ,GAAG,CAAC;AAAA,EAC3F;AACF;;;ACGO,IAAM,yBAAyB;AAQ/B,SAAS,2BAA2B,WAAmB,MAAwB;AACpF,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,MAAM,IAAI;AAAA,IACV;AAAA,IACA;AAAA,IACA,SAAS,sBAAsB;AAAA,IAC/B;AAAA,IACA;AAAA,IACA,QAAQ,SAAS;AAAA,IACjB;AAAA,IACA;AAAA,EACF;AACF;;;ACpDA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QAAQ,IAAI,CAAC;AAAA,EAC3D;AACF;","names":["existsSync","mkdirSync","writeFileSync","resolve","dirname","resolve","resolve","dirname","relative","resolve","sep","resolve","relative","dirname","sep","basename","resolve","existsSync","mkdirSync","dirname","writeFileSync"]}
|
package/dist/index.js
CHANGED
|
@@ -8,19 +8,19 @@ import {
|
|
|
8
8
|
scanRoutes,
|
|
9
9
|
theoConfigSchema,
|
|
10
10
|
theoPlugin
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-FEK25JUL.js";
|
|
12
12
|
import "./chunk-7NRFZBAL.js";
|
|
13
13
|
import "./chunk-SSYDEKWF.js";
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
14
|
+
import "./chunk-BXQCJJPT.js";
|
|
15
|
+
import "./chunk-7MCEJVGV.js";
|
|
16
|
+
import "./chunk-4XZOUS5G.js";
|
|
17
17
|
import "./chunk-OIGJOYX6.js";
|
|
18
18
|
import "./chunk-U3SPBLJF.js";
|
|
19
19
|
import "./chunk-WSOAN4KN.js";
|
|
20
20
|
import "./chunk-ENSFCKP6.js";
|
|
21
21
|
import "./chunk-OGLS76RN.js";
|
|
22
|
-
import "./chunk-
|
|
23
|
-
import "./chunk-
|
|
22
|
+
import "./chunk-PVCXREGE.js";
|
|
23
|
+
import "./chunk-36ZACTF3.js";
|
|
24
24
|
import "./chunk-P6OS7652.js";
|
|
25
25
|
import "./chunk-ZDUO4IYN.js";
|
|
26
26
|
import "./chunk-IDWN2OSG.js";
|
|
@@ -29,8 +29,6 @@ import "./chunk-NTDN54XO.js";
|
|
|
29
29
|
import "./chunk-JO462JZM.js";
|
|
30
30
|
import "./chunk-IXXZBZF7.js";
|
|
31
31
|
import "./chunk-AVQU5CQF.js";
|
|
32
|
-
import "./chunk-TQTEKNOL.js";
|
|
33
|
-
import "./chunk-CHTAWXC2.js";
|
|
34
32
|
import "./chunk-VSLTKX5L.js";
|
|
35
33
|
import "./chunk-SFGGRC35.js";
|
|
36
34
|
import "./chunk-4Z5XO4O4.js";
|
|
@@ -46,6 +44,8 @@ import "./chunk-ZICY2CD7.js";
|
|
|
46
44
|
import "./chunk-YSJOZEI6.js";
|
|
47
45
|
import "./chunk-Z4PJMZLM.js";
|
|
48
46
|
import "./chunk-UMNXCU3K.js";
|
|
47
|
+
import "./chunk-TQTEKNOL.js";
|
|
48
|
+
import "./chunk-CHTAWXC2.js";
|
|
49
49
|
import "./chunk-AHYOVVJ7.js";
|
|
50
50
|
import "./chunk-SOYOYGWY.js";
|
|
51
51
|
import "./chunk-ZWN3AODA.js";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
dispatchControllerRequest
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-BXQCJJPT.js";
|
|
4
4
|
import {
|
|
5
5
|
mountAgent
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-4XZOUS5G.js";
|
|
7
7
|
import {
|
|
8
8
|
CSP_REPORT_PATH,
|
|
9
9
|
CsrfReadinessStore,
|
|
@@ -18,11 +18,11 @@ import {
|
|
|
18
18
|
executeAction,
|
|
19
19
|
executeRoute,
|
|
20
20
|
handleBatchRequest
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-PVCXREGE.js";
|
|
22
22
|
import {
|
|
23
23
|
incomingMessageToHandlerRequest,
|
|
24
24
|
sendError
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-36ZACTF3.js";
|
|
26
26
|
import "./chunk-P6OS7652.js";
|
|
27
27
|
import "./chunk-ZDUO4IYN.js";
|
|
28
28
|
import "./chunk-IDWN2OSG.js";
|
|
@@ -36,10 +36,6 @@ import {
|
|
|
36
36
|
extractTraceId
|
|
37
37
|
} from "./chunk-IXXZBZF7.js";
|
|
38
38
|
import "./chunk-AVQU5CQF.js";
|
|
39
|
-
import {
|
|
40
|
-
logRequest
|
|
41
|
-
} from "./chunk-TQTEKNOL.js";
|
|
42
|
-
import "./chunk-CHTAWXC2.js";
|
|
43
39
|
import {
|
|
44
40
|
createPluginRunnerFromConfig
|
|
45
41
|
} from "./chunk-VSLTKX5L.js";
|
|
@@ -74,6 +70,10 @@ import {
|
|
|
74
70
|
generateNonce
|
|
75
71
|
} from "./chunk-Z4PJMZLM.js";
|
|
76
72
|
import "./chunk-UMNXCU3K.js";
|
|
73
|
+
import {
|
|
74
|
+
logRequest
|
|
75
|
+
} from "./chunk-TQTEKNOL.js";
|
|
76
|
+
import "./chunk-CHTAWXC2.js";
|
|
77
77
|
import "./chunk-AHYOVVJ7.js";
|
|
78
78
|
import "./chunk-SOYOYGWY.js";
|
|
79
79
|
import "./chunk-ZWN3AODA.js";
|
|
@@ -111,4 +111,4 @@ export {
|
|
|
111
111
|
scanWebSocketRoutes,
|
|
112
112
|
sendError
|
|
113
113
|
};
|
|
114
|
-
//# sourceMappingURL=internal-api-
|
|
114
|
+
//# sourceMappingURL=internal-api-YGFPLQ4E.js.map
|
|
@@ -5,7 +5,7 @@ import "tsx/esm";
|
|
|
5
5
|
async function defaultSteps() {
|
|
6
6
|
const [{ buildCommand }, { startCommand }] = await Promise.all([
|
|
7
7
|
import("./build-Y3CWTWP6.js"),
|
|
8
|
-
import("./start-
|
|
8
|
+
import("./start-LNT5UVSY.js")
|
|
9
9
|
]);
|
|
10
10
|
return {
|
|
11
11
|
build: (opts) => buildCommand(opts),
|
|
@@ -20,4 +20,4 @@ async function previewCommand(options = {}, steps) {
|
|
|
20
20
|
export {
|
|
21
21
|
previewCommand
|
|
22
22
|
};
|
|
23
|
-
//# sourceMappingURL=preview-
|
|
23
|
+
//# sourceMappingURL=preview-DLIVPM7A.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as CronLock } from '../../cron-lock-
|
|
2
|
-
export { P as PostgresCronLockOptions, c as createPostgresCronLock } from '../../cron-lock-
|
|
1
|
+
import { C as CronLock } from '../../cron-lock-CfAvLApv.js';
|
|
2
|
+
export { P as PostgresCronLockOptions, c as createPostgresCronLock } from '../../cron-lock-CfAvLApv.js';
|
|
3
3
|
import '../../storage-types-ndO0ZZqH.js';
|
|
4
4
|
|
|
5
5
|
/**
|