theokit 0.53.0 → 0.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{actions-virtual-module-VJYKUIXE.js → actions-virtual-module-FGJR3I7V.js} +5 -5
- package/dist/{actions-virtual-module-SNG4JC35.js → actions-virtual-module-M4MTKOAX.js} +7 -7
- package/dist/adapters/agent-mount.js +1 -1
- package/dist/{agent-GX4RIRRX.js → agent-TKCC4WZ6.js} +3 -3
- package/dist/{app-typed-client-DFRID25X.js → app-typed-client-22BZ3KDX.js} +7 -7
- package/dist/{app-typed-client-IPWJWM2E.js → app-typed-client-6MNNVMJU.js} +5 -5
- package/dist/{build-IVLQ5TUQ.js → build-JH53TZJI.js} +8 -8
- package/dist/{chunk-XLLW46MB.js → chunk-2HWWJTOH.js} +7 -5
- package/dist/chunk-2HWWJTOH.js.map +1 -0
- package/dist/{chunk-FH3SQR6P.js → chunk-4OTIXAUY.js} +11 -3
- package/dist/chunk-4OTIXAUY.js.map +1 -0
- package/dist/{chunk-6AM7HIRM.js → chunk-5NNFO7R7.js} +1 -1
- package/dist/{chunk-6AM7HIRM.js.map → chunk-5NNFO7R7.js.map} +1 -1
- package/dist/{chunk-GSIOWE5B.js → chunk-5VLP3GQ2.js} +2 -2
- package/dist/{chunk-2E7JLV7L.js → chunk-6VYF5PMG.js} +2 -2
- package/dist/{chunk-YZCD3DWE.js → chunk-AI7GBBRB.js} +2 -2
- package/dist/{chunk-VGE6AKEJ.js → chunk-DAE7BJ7H.js} +2 -2
- package/dist/{chunk-5BOKW3GX.js → chunk-FVFYACYK.js} +2 -2
- package/dist/chunk-FVFYACYK.js.map +1 -0
- package/dist/{chunk-QTHVHNJJ.js → chunk-HA35FS7U.js} +2 -2
- package/dist/{chunk-LPNSZK3A.js → chunk-HLDXHDCB.js} +12 -12
- package/dist/{chunk-VHB2FSPM.js → chunk-I2UN46ZX.js} +39 -24
- package/dist/chunk-I2UN46ZX.js.map +1 -0
- package/dist/{chunk-E53UIFH6.js → chunk-IHAQUUT2.js} +3 -3
- package/dist/chunk-IHAQUUT2.js.map +1 -0
- package/dist/{chunk-YYOBMOO4.js → chunk-NO6HA4FG.js} +35 -22
- package/dist/chunk-NO6HA4FG.js.map +1 -0
- package/dist/{chunk-Q5L5EGWZ.js → chunk-NZDGV4YJ.js} +2 -2
- package/dist/{chunk-VI7ZANB3.js → chunk-OSBGZYXZ.js} +20 -2
- package/dist/chunk-OSBGZYXZ.js.map +1 -0
- package/dist/{chunk-67DBYOXI.js → chunk-S6RWUH3J.js} +19 -11
- package/dist/chunk-S6RWUH3J.js.map +1 -0
- package/dist/{chunk-Y5E7VFNJ.js → chunk-SIGUGCBS.js} +5 -5
- package/dist/{chunk-JUDNKBDQ.js → chunk-WX6NHGKS.js} +20 -2
- package/dist/chunk-WX6NHGKS.js.map +1 -0
- package/dist/cli/index.js +9 -9
- package/dist/{dev-TLVSKNSH.js → dev-6KDYNF5E.js} +12 -12
- package/dist/{dev-emit-SPSV6UU7.js → dev-emit-QGSMUZLU.js} +4 -4
- package/dist/{dev-emit-G2E2U3NP.js → dev-emit-W27J3DLU.js} +2 -2
- package/dist/{index-C8YN9dpF.d.ts → index-ADEV6pen.d.ts} +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +5 -5
- package/dist/{info-Y55RWS42.js → info-6WJ3JRNE.js} +4 -4
- package/dist/{internal-api-EL25ADPR.js → internal-api-TA37BXH7.js} +7 -7
- package/dist/{internal-api-S6BGJCZP.js → internal-api-VUDJUWYE.js} +5 -5
- package/dist/{load-config-4ATXQUN3.js → load-config-BKUAMGO5.js} +4 -4
- package/dist/{match-DmGgxjIU.d.ts → match-Dw4CNXJH.d.ts} +8 -0
- package/dist/{mcp-OZACRG7O.js → mcp-2RQCKWQR.js} +4 -4
- package/dist/{observability-bootstrap-M2WSDIDV.js → observability-bootstrap-H4NSILXD.js} +3 -3
- package/dist/{openapi-2IBBOS3Q.js → openapi-PKDDJ7M2.js} +7 -7
- package/dist/{preview-DCJPTZVW.js → preview-J57QZNTO.js} +3 -3
- package/dist/{routes-PP5PHHLR.js → routes-A2YLFEYC.js} +5 -5
- package/dist/{schema-SOAD43RQ.js → schema-WKTNTGX6.js} +3 -3
- package/dist/{schemas-4AXHQMV3.js → schemas-QCMSKQDK.js} +2 -2
- package/dist/server/http/index.d.ts +2 -2
- package/dist/server/http/index.js +2 -2
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js +3 -3
- package/dist/server/scan/index.d.ts +8 -2
- package/dist/server/scan/index.js +1 -1
- package/dist/{server-boundary-XRXVVUMO.js → server-boundary-4UIGB3G5.js} +5 -5
- package/dist/{server-boundary-RNM25WWD.js → server-boundary-A2PUD4JV.js} +7 -7
- package/dist/{start-WILEDDW2.js → start-3F4LVHWS.js} +95 -13
- package/dist/start-3F4LVHWS.js.map +1 -0
- package/dist/vite-plugin/index.js +5 -5
- package/dist/{vite-plugin-KIBK7OYL.js → vite-plugin-VYNUCEI2.js} +11 -11
- package/package.json +2 -2
- package/dist/chunk-5BOKW3GX.js.map +0 -1
- package/dist/chunk-67DBYOXI.js.map +0 -1
- package/dist/chunk-E53UIFH6.js.map +0 -1
- package/dist/chunk-FH3SQR6P.js.map +0 -1
- package/dist/chunk-JUDNKBDQ.js.map +0 -1
- package/dist/chunk-VHB2FSPM.js.map +0 -1
- package/dist/chunk-VI7ZANB3.js.map +0 -1
- package/dist/chunk-XLLW46MB.js.map +0 -1
- package/dist/chunk-YYOBMOO4.js.map +0 -1
- package/dist/start-WILEDDW2.js.map +0 -1
- /package/dist/{actions-virtual-module-VJYKUIXE.js.map → actions-virtual-module-FGJR3I7V.js.map} +0 -0
- /package/dist/{actions-virtual-module-SNG4JC35.js.map → actions-virtual-module-M4MTKOAX.js.map} +0 -0
- /package/dist/{agent-GX4RIRRX.js.map → agent-TKCC4WZ6.js.map} +0 -0
- /package/dist/{app-typed-client-DFRID25X.js.map → app-typed-client-22BZ3KDX.js.map} +0 -0
- /package/dist/{app-typed-client-IPWJWM2E.js.map → app-typed-client-6MNNVMJU.js.map} +0 -0
- /package/dist/{build-IVLQ5TUQ.js.map → build-JH53TZJI.js.map} +0 -0
- /package/dist/{chunk-GSIOWE5B.js.map → chunk-5VLP3GQ2.js.map} +0 -0
- /package/dist/{chunk-2E7JLV7L.js.map → chunk-6VYF5PMG.js.map} +0 -0
- /package/dist/{chunk-YZCD3DWE.js.map → chunk-AI7GBBRB.js.map} +0 -0
- /package/dist/{chunk-VGE6AKEJ.js.map → chunk-DAE7BJ7H.js.map} +0 -0
- /package/dist/{chunk-QTHVHNJJ.js.map → chunk-HA35FS7U.js.map} +0 -0
- /package/dist/{chunk-LPNSZK3A.js.map → chunk-HLDXHDCB.js.map} +0 -0
- /package/dist/{chunk-Q5L5EGWZ.js.map → chunk-NZDGV4YJ.js.map} +0 -0
- /package/dist/{chunk-Y5E7VFNJ.js.map → chunk-SIGUGCBS.js.map} +0 -0
- /package/dist/{dev-TLVSKNSH.js.map → dev-6KDYNF5E.js.map} +0 -0
- /package/dist/{dev-emit-SPSV6UU7.js.map → dev-emit-QGSMUZLU.js.map} +0 -0
- /package/dist/{dev-emit-G2E2U3NP.js.map → dev-emit-W27J3DLU.js.map} +0 -0
- /package/dist/{info-Y55RWS42.js.map → info-6WJ3JRNE.js.map} +0 -0
- /package/dist/{internal-api-EL25ADPR.js.map → internal-api-TA37BXH7.js.map} +0 -0
- /package/dist/{internal-api-S6BGJCZP.js.map → internal-api-VUDJUWYE.js.map} +0 -0
- /package/dist/{load-config-4ATXQUN3.js.map → load-config-BKUAMGO5.js.map} +0 -0
- /package/dist/{mcp-OZACRG7O.js.map → mcp-2RQCKWQR.js.map} +0 -0
- /package/dist/{observability-bootstrap-M2WSDIDV.js.map → observability-bootstrap-H4NSILXD.js.map} +0 -0
- /package/dist/{openapi-2IBBOS3Q.js.map → openapi-PKDDJ7M2.js.map} +0 -0
- /package/dist/{preview-DCJPTZVW.js.map → preview-J57QZNTO.js.map} +0 -0
- /package/dist/{routes-PP5PHHLR.js.map → routes-A2YLFEYC.js.map} +0 -0
- /package/dist/{schema-SOAD43RQ.js.map → schema-WKTNTGX6.js.map} +0 -0
- /package/dist/{schemas-4AXHQMV3.js.map → schemas-QCMSKQDK.js.map} +0 -0
- /package/dist/{server-boundary-XRXVVUMO.js.map → server-boundary-4UIGB3G5.js.map} +0 -0
- /package/dist/{server-boundary-RNM25WWD.js.map → server-boundary-A2PUD4JV.js.map} +0 -0
- /package/dist/{vite-plugin-KIBK7OYL.js.map → vite-plugin-VYNUCEI2.js.map} +0 -0
|
@@ -273,25 +273,34 @@ function propertyNameIsPolicy(name) {
|
|
|
273
273
|
if (ts2.isStringLiteral(name)) return name.text === POLICY_KEY;
|
|
274
274
|
return false;
|
|
275
275
|
}
|
|
276
|
-
function
|
|
276
|
+
function policyKindOfArgument(expression) {
|
|
277
|
+
const arg = unwrap(expression);
|
|
278
|
+
return ts2.isStringLiteral(arg) && arg.text === "public" ? "public" : "guarded";
|
|
279
|
+
}
|
|
280
|
+
function objectPolicyKind(literal) {
|
|
277
281
|
for (const property of literal.properties) {
|
|
278
282
|
if (ts2.isSpreadAssignment(property)) continue;
|
|
279
|
-
if (propertyNameIsPolicy(property.name))
|
|
283
|
+
if (!propertyNameIsPolicy(property.name)) continue;
|
|
284
|
+
return ts2.isPropertyAssignment(property) ? policyKindOfArgument(property.initializer) : "guarded";
|
|
280
285
|
}
|
|
281
|
-
return
|
|
286
|
+
return void 0;
|
|
282
287
|
}
|
|
283
|
-
function
|
|
288
|
+
function policyKind(expression) {
|
|
284
289
|
const expr = unwrap(expression);
|
|
285
|
-
if (ts2.isObjectLiteralExpression(expr)) return
|
|
286
|
-
if (!ts2.isCallExpression(expr)) return
|
|
290
|
+
if (ts2.isObjectLiteralExpression(expr)) return objectPolicyKind(expr);
|
|
291
|
+
if (!ts2.isCallExpression(expr)) return void 0;
|
|
287
292
|
const callee = unwrap(expr.expression);
|
|
288
|
-
if (ts2.isPropertyAccessExpression(callee) && callee.name.text === POLICY_KEY)
|
|
293
|
+
if (ts2.isPropertyAccessExpression(callee) && callee.name.text === POLICY_KEY) {
|
|
294
|
+
return expr.arguments.length === 0 ? "guarded" : policyKindOfArgument(expr.arguments[0]);
|
|
295
|
+
}
|
|
289
296
|
for (const argument of expr.arguments) {
|
|
290
297
|
const arg = unwrap(argument);
|
|
291
|
-
if (ts2.isObjectLiteralExpression(arg)
|
|
298
|
+
if (!ts2.isObjectLiteralExpression(arg)) continue;
|
|
299
|
+
const kind = objectPolicyKind(arg);
|
|
300
|
+
if (kind !== void 0) return kind;
|
|
292
301
|
}
|
|
293
|
-
if (ts2.isPropertyAccessExpression(callee)) return
|
|
294
|
-
return
|
|
302
|
+
if (ts2.isPropertyAccessExpression(callee)) return policyKind(callee.expression);
|
|
303
|
+
return void 0;
|
|
295
304
|
}
|
|
296
305
|
function collectLocalInitializers(sourceFile) {
|
|
297
306
|
const locals = /* @__PURE__ */ new Map();
|
|
@@ -309,9 +318,9 @@ function collectFromVariableStatement(stmt, declared) {
|
|
|
309
318
|
if (!hasExportModifier2(ts2.getModifiers(stmt))) return;
|
|
310
319
|
for (const decl of stmt.declarationList.declarations) {
|
|
311
320
|
if (!ts2.isIdentifier(decl.name) || !HTTP_METHOD_NAMES2.has(decl.name.text)) continue;
|
|
312
|
-
if (decl.initializer
|
|
313
|
-
|
|
314
|
-
|
|
321
|
+
if (decl.initializer === void 0) continue;
|
|
322
|
+
const kind = policyKind(decl.initializer);
|
|
323
|
+
if (kind !== void 0) declared.set(decl.name.text, kind);
|
|
315
324
|
}
|
|
316
325
|
}
|
|
317
326
|
function collectFromExportDeclaration(stmt, locals, declared) {
|
|
@@ -320,9 +329,9 @@ function collectFromExportDeclaration(stmt, locals, declared) {
|
|
|
320
329
|
for (const spec of stmt.exportClause.elements) {
|
|
321
330
|
if (!HTTP_METHOD_NAMES2.has(spec.name.text)) continue;
|
|
322
331
|
const local = locals.get((spec.propertyName ?? spec.name).text);
|
|
323
|
-
if (local
|
|
324
|
-
|
|
325
|
-
|
|
332
|
+
if (local === void 0) continue;
|
|
333
|
+
const kind = policyKind(local);
|
|
334
|
+
if (kind !== void 0) declared.set(spec.name.text, kind);
|
|
326
335
|
}
|
|
327
336
|
}
|
|
328
337
|
function collectFromStatement2(stmt, locals, declared) {
|
|
@@ -334,7 +343,7 @@ function collectFromStatement2(stmt, locals, declared) {
|
|
|
334
343
|
collectFromExportDeclaration(stmt, locals, declared);
|
|
335
344
|
}
|
|
336
345
|
}
|
|
337
|
-
function
|
|
346
|
+
function detectRoutePolicyKinds(filePath, content) {
|
|
338
347
|
const sourceFile = ts2.createSourceFile(
|
|
339
348
|
filePath,
|
|
340
349
|
content,
|
|
@@ -344,7 +353,7 @@ function detectMethodsWithDeclaredPolicy(filePath, content) {
|
|
|
344
353
|
ts2.ScriptKind.TS
|
|
345
354
|
);
|
|
346
355
|
const locals = collectLocalInitializers(sourceFile);
|
|
347
|
-
const declared = /* @__PURE__ */ new
|
|
356
|
+
const declared = /* @__PURE__ */ new Map();
|
|
348
357
|
for (const stmt of sourceFile.statements) {
|
|
349
358
|
collectFromStatement2(stmt, locals, declared);
|
|
350
359
|
}
|
|
@@ -431,8 +440,8 @@ function routeSourceFacts(absPath) {
|
|
|
431
440
|
return routeFactsCache.get(absPath, () => {
|
|
432
441
|
const source = readFileSync3(absPath, "utf-8");
|
|
433
442
|
const methods = detectExportedHttpMethods(absPath, source);
|
|
434
|
-
const
|
|
435
|
-
return { methods, declaredPolicy };
|
|
443
|
+
const policyKinds = methods.length === 0 ? /* @__PURE__ */ new Map() : detectRoutePolicyKinds(absPath, source);
|
|
444
|
+
return { methods, declaredPolicy: new Set(policyKinds.keys()), policyKinds };
|
|
436
445
|
});
|
|
437
446
|
}
|
|
438
447
|
function fileToRoutePath(filePath, routesDir) {
|
|
@@ -469,7 +478,11 @@ function scanServerRoutes(serverDir) {
|
|
|
469
478
|
routePath,
|
|
470
479
|
paramNames,
|
|
471
480
|
pattern,
|
|
472
|
-
methods
|
|
481
|
+
methods,
|
|
482
|
+
// Always set, even when empty — `public-exposure-gate.ts` reads the FIELD's presence as
|
|
483
|
+
// "this was measured" and its absence as "this predates the check". A scanned route was
|
|
484
|
+
// measured by definition, so it never reports the second.
|
|
485
|
+
publicMethods: [...facts.policyKinds].filter(([, kind]) => kind === "public").map(([method]) => method)
|
|
473
486
|
});
|
|
474
487
|
});
|
|
475
488
|
const conflicting = results.find((r) => r.routePath === "/api/__theo_batch__");
|
|
@@ -536,4 +549,4 @@ export {
|
|
|
536
549
|
scanServerRoutes,
|
|
537
550
|
scanWebSocketRoutes
|
|
538
551
|
};
|
|
539
|
-
//# sourceMappingURL=chunk-
|
|
552
|
+
//# sourceMappingURL=chunk-NO6HA4FG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/server/scan/action-scan.ts","../src/server/scan/match.ts","../src/core/contracts/http-methods.ts","../src/server/scan/scan.ts","../src/server/scan/detect-http-methods.ts","../src/server/scan/detect-route-policy.ts","../src/server/scan/ws-scan.ts"],"sourcesContent":["/* eslint-disable security/detect-non-literal-fs-filename --\n * Build-time scanner: walks `serverDir/actions/` derived from cwd.\n * No HTTP input ever reaches these fs calls.\n */\nimport { existsSync, readFileSync, statSync } from 'node:fs'\nimport { extname, join, relative } from 'node:path'\n\nimport { walkSourceFiles } from '../_internal/scan-walker.js'\n\nexport interface ActionNode {\n filePath: string\n actionPath: string\n}\n\n/**\n * Directory under `<serverDir>/actions/` reserved for ISOMORPHIC zod schemas.\n *\n * The one place in the whole server tree whose files are meant to reach the browser: the\n * `@theo/actions` virtual module emits `import { schema } from '<abs path>'` into the CLIENT\n * facade for each file here, so `<TheoForm>` can drive `zodResolver` with the same schema the\n * server validates against.\n *\n * Named once, and exported, because two rules now depend on knowing it. The scanner skips it (a\n * schema is not an executable action), and the server-only import boundary must NOT refuse it\n * (`vite-plugin/server-boundary.ts`). Restating the literal in the boundary would let the two\n * drift, and the drift would be invisible: renaming the convention here would silently turn the\n * exception into a refusal, breaking a shipped feature at build time in consumer projects only.\n */\nexport const ACTION_SCHEMAS_DIR = 'schemas'\n\n/**\n * Enriched manifest entry per plan g3-server-actions-and-useaction v1.2\n * § Phase 1 / T1.4 + ADR D4. Consumed by virtual module `@theo/actions`\n * (T3.1) and G4 devtools \"Actions\" tab (T5.1).\n */\nexport interface ActionManifestEntry {\n name: string\n filePath: string\n urlPath: string\n accept: 'form' | 'json'\n hasInput: boolean\n /**\n * P#4 plugin-forms shared-schema convention (per plan p4-plugin-forms v1.1 T1.1).\n * When present, points to an isomorphic schema file at\n * `<serverDir>/actions/schemas/<basename>.ts` exporting `export const schema = z.object(...)`.\n * Virtual module emits `import {schema} from '<schemaFilePath>'` + attaches as\n * `actions.X.__zodSchema` so client-side <TheoForm> can drive zodResolver.\n * Undefined when convention not followed (graceful degrade — TheoForm still\n * works via explicit `schema={...}` prop escape hatch).\n */\n schemaFilePath?: string\n}\n\n/**\n * EC-2: structured error for scan-time defects (name collision, reserved\n * identifier, etc.). Throw at scan time to fail loud — silent shadowing is\n * a security/correctness footgun.\n */\nexport class ActionScanError extends Error {\n readonly code: 'NAME_COLLISION' | 'RESERVED_NAME'\n readonly conflictingPaths: readonly string[]\n\n constructor(\n code: 'NAME_COLLISION' | 'RESERVED_NAME',\n message: string,\n conflictingPaths: readonly string[],\n ) {\n super(message)\n // T4.1 fix: identify class by name so serverErrorToEnvelope boundary\n // translator can route via class-name lookup (without this, runtime\n // `err.name` defaults to 'Error' and the meta.name diagnostic is wrong).\n this.name = 'ActionScanError'\n this.code = code\n this.conflictingPaths = conflictingPaths\n }\n}\n\nconst ACTION_EXTENSIONS = new Set(['.ts', '.tsx', '.js', '.jsx'])\nconst TEST_FILE_RE = /\\.(test|spec)\\.(ts|tsx|js|jsx)$/\nconst RESERVED_NAMES = new Set(['index', 'constructor', '__proto__', 'prototype', 'hasOwnProperty'])\n\n/**\n * Backward-compatible: original simple-shape scanner used by existing\n * consumers. Preserved verbatim; new consumers should call\n * `scanServerActionsEnriched`.\n */\nexport function scanServerActions(serverDir: string): ActionNode[] {\n const actionsDir = join(serverDir, 'actions')\n if (!existsSync(actionsDir) || !statSync(actionsDir).isDirectory()) {\n return []\n }\n\n const results: ActionNode[] = []\n walkSourceFiles(actionsDir, { extensions: ACTION_EXTENSIONS }, (absPath) => {\n if (TEST_FILE_RE.test(absPath)) return\n let rel = relative(actionsDir, absPath)\n rel = rel.replace(/\\\\/g, '/')\n rel = rel.slice(0, -extname(rel).length)\n results.push({\n filePath: absPath,\n actionPath: rel,\n })\n })\n return results\n}\n\n/**\n * Enriched scan: light AST detection of `accept: 'form'|'json'` + `input:`\n * presence via regex-after-comment-stripping (EC-9). Throws ActionScanError\n * on file/dir name collision (EC-2) or reserved JS identifier names.\n *\n * Output `ActionManifestEntry[]` is sorted by `name` for deterministic\n * `.theokit/actions-manifest.json` emission.\n */\nexport function scanServerActionsEnriched(serverDir: string): ActionManifestEntry[] {\n const actionsDir = join(serverDir, 'actions')\n if (!existsSync(actionsDir) || !statSync(actionsDir).isDirectory()) {\n return []\n }\n\n const seenNames = new Set<string>()\n const entries: ActionManifestEntry[] = []\n\n // Collect first; collision-check after the full walk.\n walkSourceFiles(actionsDir, { extensions: ACTION_EXTENSIONS }, (absPath) => {\n if (TEST_FILE_RE.test(absPath)) return\n const rel = relative(actionsDir, absPath).replace(/\\\\/g, '/')\n // P#4 plugin-forms — `schemas/` subdir holds isomorphic zod schemas\n // for the shared-schema convention (T1.1). NOT executable actions; skip.\n if (rel.startsWith(`${ACTION_SCHEMAS_DIR}/`)) return\n const name = rel.slice(0, -extname(rel).length)\n\n const basename = name.includes('/') ? (name.split('/').pop() ?? name) : name\n if (RESERVED_NAMES.has(basename)) {\n throw new ActionScanError(\n 'RESERVED_NAME',\n `Reserved JS identifier \"${basename}\" cannot be an action name (${absPath})`,\n [absPath],\n )\n }\n // File-level collision (one file appearing twice) is impossible via the\n // walker; per-export collision check happens inside the export loop below.\n const source = readFileSync(absPath, 'utf8')\n const stripped = stripComments(source)\n const accept = /\\baccept\\s*:\\s*['\"]form['\"]/.test(stripped) ? 'form' : 'json'\n const hasInput = /\\binput\\s*:\\s*z\\./.test(stripped) || /\\binput\\s*:\\s*\\w+\\(/.test(stripped)\n\n // T7.1 wire fix — extract exports so the urlPath includes the second\n // segment required by action-middleware (`/api/__actions/<file>/<export>`).\n // Each named action export becomes its own manifest entry.\n // Proxy key on the EXPORT name (so consumers write `actions.saveMemory(input)`).\n // URL keeps the runtime 2-segment shape `/api/__actions/<file>/<export>`\n // expected by action-middleware. Cross-file export collisions become a\n // scan error to surface the ambiguity early.\n const exportNames = extractActionExportNames(stripped)\n // P#4 plugin-forms shared-schema convention: check for\n // `<actionsDir>/schemas/<basename>.ts` (or .tsx/.js/.jsx).\n // Skip when actions live in subdirs (`schemas/` is flat by convention).\n const schemaFilePath = name.includes('/') ? undefined : detectSchemaFile(actionsDir, basename)\n for (const exportName of exportNames) {\n const proxyKey = exportName === 'default' ? name : exportName\n if (seenNames.has(proxyKey)) {\n throw new ActionScanError(\n 'NAME_COLLISION',\n `Duplicate action proxy key \"${proxyKey}\" (two files export the same name)`,\n [absPath],\n )\n }\n seenNames.add(proxyKey)\n const entry: ActionManifestEntry = {\n name: proxyKey,\n filePath: absPath,\n urlPath: `/api/__actions/${name}/${exportName}`,\n accept,\n hasInput,\n }\n if (schemaFilePath !== undefined) {\n entry.schemaFilePath = schemaFilePath\n }\n entries.push(entry)\n }\n })\n\n // EC-2: detect file vs dir collisions (e.g., foo.ts AND foo/bar.ts).\n // After walk completes, any name that has children prefixed `name/` triggers collision.\n for (const entry of entries) {\n const childPrefix = `${entry.name}/`\n const conflictingChild = entries.find((other) => other.name.startsWith(childPrefix))\n if (conflictingChild) {\n throw new ActionScanError(\n 'NAME_COLLISION',\n `Action \"${entry.name}\" conflicts with directory of same name containing \"${conflictingChild.name}\"`,\n [entry.filePath, conflictingChild.filePath],\n )\n }\n }\n\n entries.sort((a, b) => {\n if (a.name < b.name) return -1\n if (a.name > b.name) return 1\n return 0\n })\n return entries\n}\n\n/**\n * Strip JavaScript line + block comments from source. Simple state machine\n * (does not parse strings — false positives if a comment marker appears\n * inside a string literal, but that's an acceptable trade-off for v1 vs\n * full AST parse).\n */\n/**\n * Extract action export names via regex over comment-stripped source.\n * Matches `export const <name> = defineAction(...)`, `export default\n * defineAction(...)`, and `export function <name>(...)` forms. Returns\n * `['default']` when no named action exports are found (best-effort fallback\n * for default-export shapes the regex misses).\n */\nfunction extractActionExportNames(stripped: string): string[] {\n const names = new Set<string>()\n const namedRe = /\\bexport\\s+(?:const|let|var|function\\*?)\\s+([a-zA-Z_$][\\w$]*)\\s*[=(]/g\n let m: RegExpExecArray | null\n while ((m = namedRe.exec(stripped)) !== null) {\n const name = m[1]\n if (typeof name === 'string' && name.length > 0) names.add(name)\n }\n if (/\\bexport\\s+default\\s+defineAction\\b/.test(stripped)) {\n names.add('default')\n }\n if (names.size === 0) names.add('default')\n return [...names]\n}\n\n/**\n * P#4 plugin-forms shared-schema convention helper (per plan p4-plugin-forms v1.1 T1.1).\n * Returns the resolved path to `<actionsDir>/schemas/<basename>.<ext>` if it exists.\n * Tries `.ts`, `.tsx`, `.js`, `.jsx` in that order. Returns undefined when no match.\n */\nfunction detectSchemaFile(actionsDir: string, basename: string): string | undefined {\n const schemasDir = join(actionsDir, ACTION_SCHEMAS_DIR)\n if (!existsSync(schemasDir)) return undefined\n for (const ext of ['.ts', '.tsx', '.js', '.jsx']) {\n const candidate = join(schemasDir, `${basename}${ext}`)\n if (existsSync(candidate)) return candidate\n }\n return undefined\n}\n\nfunction stripComments(source: string): string {\n let out = ''\n let i = 0\n while (i < source.length) {\n const ch = source[i]\n const next = source[i + 1]\n if (ch === '/' && next === '/') {\n // Line comment: skip until newline\n while (i < source.length && source[i] !== '\\n') i++\n continue\n }\n if (ch === '/' && next === '*') {\n // Block comment: skip until */\n i += 2\n while (i < source.length - 1 && !(source[i] === '*' && source[i + 1] === '/')) i++\n i += 2\n continue\n }\n out += ch\n i++\n }\n return out\n}\n","export interface ServerRouteNode {\n filePath: string\n routePath: string\n paramNames: string[]\n pattern: RegExp\n /** HTTP methods (uppercase) the route file exports. Optional for backward\n * compatibility with manifests generated before G1. Empty array means the\n * file has no HTTP exports (util-only); undefined means \"not detected\". */\n methods?: string[]\n /**\n * The subset of `methods` whose policy is the literal `'public'` (ADR 0001).\n *\n * `undefined` means \"not detected\" — a manifest built before the field existed — and is NOT the\n * same as `[]`, which means \"detected, and nothing is public\". `public-exposure-gate.ts` depends\n * on that distinction: reading absence as safety is the failure it exists to prevent.\n */\n publicMethods?: string[]\n}\n\nexport function compilePattern(routePath: string): {\n pattern: RegExp\n paramNames: string[]\n} {\n const paramNames: string[] = []\n // Single pass: handle both catch-all (:...name) and regular (:name) params\n const regexStr = routePath.replace(/:(?:\\.\\.\\.)?([^/]+)/g, (match: string, name: string) => {\n paramNames.push(name)\n // Catch-all matches across slashes, regular matches single segment\n return match.startsWith(':...') ? '(.+)' : '([^/]+)'\n })\n // `regexStr` is derived from a developer-authored route path (build-time\n // input, not HTTP-controlled). The `security/detect-non-literal-regexp`\n // rule cannot see this constraint — disable narrowly.\n // eslint-disable-next-line security/detect-non-literal-regexp -- route pattern from build-time scan, never HTTP input\n return { pattern: new RegExp(`^${regexStr}$`), paramNames }\n}\n\nexport function matchRoute(\n url: string,\n routes: ServerRouteNode[],\n): { route: ServerRouteNode; params: Record<string, string> } | null {\n // Strip query string and trailing slash\n let path = url.split('?')[0]\n if (path.length > 1 && path.endsWith('/')) {\n path = path.slice(0, -1)\n }\n\n for (const route of routes) {\n const match = route.pattern.exec(path)\n if (match) {\n const params: Record<string, string> = {}\n route.paramNames.forEach((name, i) => {\n params[name] = match[i + 1]\n })\n return { route, params }\n }\n }\n return null\n}\n","/**\n * Canonical HTTP method set used by the typed client codegen + Proxy runtime.\n * Kept here (under `server/scan/`) because the SCAN is the first consumer —\n * `vite-plugin/app-typed-client.ts` (Phase 2) and `client/app-client.ts` (Phase 3)\n * import from here to ensure a single source of truth.\n *\n * Lowercase variants are derived via `.toLowerCase()` at call sites; we do not\n * export them separately to avoid drift between the two lists.\n */\n\nexport const HTTP_METHODS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS'] as const\n\nexport type HttpMethod = (typeof HTTP_METHODS)[number]\n\nexport const HTTP_METHOD_LOWERCASE = HTTP_METHODS.map((m) => m.toLowerCase()) as readonly string[]\n","/* eslint-disable security/detect-non-literal-fs-filename --\n * Build-time scanner: walks `serverDir/routes/` derived from cwd.\n * No HTTP input ever reaches these fs calls.\n */\nimport { existsSync, readFileSync, statSync } from 'node:fs'\nimport { basename, extname, join, relative } from 'node:path'\n\nimport type { HttpMethod } from '../../core/contracts/http-methods.js'\nimport { walkSourceFiles } from '../_internal/scan-walker.js'\n\nimport { detectExportedHttpMethods } from './detect-http-methods.js'\nimport { detectRoutePolicyKinds, type RoutePolicyKind } from './detect-route-policy.js'\nimport {\n MissingRoutePolicyError,\n RedundantApiSegmentError,\n RouterConventionError,\n} from './errors.js'\nimport { createFileStampCache } from './file-stamp-cache.js'\nimport { compilePattern, type ServerRouteNode } from './match.js'\n\nconst ROUTE_EXTENSIONS = new Set(['.ts', '.tsx', '.js', '.jsx'])\n\n// EC-4: Co-located unit/spec tests must be silently skipped by the scanner,\n// BEFORE the dotted-basename check fires. Matches `*.test.ts|tsx|js|jsx`\n// and `*.spec.ts|tsx|js|jsx`.\nconst TEST_OR_SPEC_RE = /\\.(test|spec)\\.[jt]sx?$/\n\nfunction isTestOrSpecFile(filePath: string): boolean {\n return TEST_OR_SPEC_RE.test(basename(filePath))\n}\n\nfunction hasDotOutsideBrackets(segment: string): boolean {\n let depth = 0\n for (const ch of segment) {\n if (ch === '[') depth++\n else if (ch === ']') depth--\n else if (ch === '.' && depth === 0) return true\n }\n return false\n}\n\nfunction splitDottedSegmentOutsideBrackets(segment: string): string[] {\n const parts: string[] = []\n let current = ''\n let depth = 0\n for (const ch of segment) {\n if (ch === '[') {\n depth++\n current += ch\n } else if (ch === ']') {\n depth--\n current += ch\n } else if (ch === '.' && depth === 0) {\n if (current) parts.push(current)\n current = ''\n } else {\n current += ch\n }\n }\n if (current) parts.push(current)\n return parts\n}\n\nfunction buildDirectoryNestedSuggestion(filePath: string, routesDir: string): string {\n const rel = relative(routesDir, filePath).replace(/\\\\/g, '/')\n const ext = extname(rel)\n const withoutExt = rel.slice(0, -ext.length)\n const segments = withoutExt.split('/').flatMap(splitDottedSegmentOutsideBrackets)\n return `routes/${segments.join('/')}${ext}`\n}\n\n/**\n * `routes/api/…` doubles the prefix `fileToRoutePath` adds unconditionally.\n *\n * Checked on the FIRST segment only. A file merely named `api-keys.ts` or `apiary.ts` is the\n * author's to choose and resolves fine; what doubles is the DIRECTORY, because it prefixes every\n * file beneath it — and carries the same redundant segment into the generated typed client.\n */\nfunction assertNoRedundantApiSegment(filePath: string, routesDir: string): void {\n const rel = relative(routesDir, filePath).replace(/\\\\/g, '/')\n const [first, ...rest] = rel.split('/')\n if (first !== 'api' || rest.length === 0) return\n\n const withoutExt = rel.slice(0, -extname(rel).length)\n throw new RedundantApiSegmentError({\n file: filePath,\n doubledRoutePath: `/api/${withoutExt}`,\n doubledClientChain: `client.${withoutExt.split('/').join('.')}`,\n suggestion: `routes/${rest.join('/')}`,\n })\n}\n\nfunction assertNoDottedSegment(filePath: string, routesDir: string): void {\n const rel = relative(routesDir, filePath).replace(/\\\\/g, '/')\n const ext = extname(rel)\n const withoutExt = rel.slice(0, -ext.length)\n const segments = withoutExt.split('/')\n for (const seg of segments) {\n if (hasDotOutsideBrackets(seg)) {\n throw new RouterConventionError({\n file: filePath,\n suggestion: buildDirectoryNestedSuggestion(filePath, routesDir),\n })\n }\n }\n}\n\n/**\n * ADR 0001, Decision point 5 — a route declares its policy explicitly, `public`\n * included, and absence stops meaning open.\n *\n * The refusal lives here, next to the dotted-basename refusal, because this is\n * the one place every entry point passes through: `theo build`, `theo start`,\n * `theo dev`, `theo routes` and each deployment adapter all reach routes by\n * calling `scanServerRoutes`. A gate wired into the build command instead would\n * have to be remembered by six adapters that generate their own entry file, and\n * a gate you can forget to call is a gate that reports on the routes somebody\n * remembered.\n *\n * The blast radius stops at the file system. A `RouteConfig` built in memory and\n * handed to `executeWebRequest` or `callProcedure` never passed a scanner, so it\n * never reaches this function — the runtime still treats an undeclared policy as\n * \"not declared\", exactly as `evaluateRoutePolicy` documents. Absence is refused\n * where an application DECLARES its routes, not where a caller passes one.\n */\nfunction assertEveryMethodDeclaresPolicy(\n filePath: string,\n routePath: string,\n { methods, declaredPolicy }: RouteSourceFacts,\n): void {\n if (methods.length === 0) return\n const missing = methods.filter((method) => !declaredPolicy.has(method))\n if (missing.length === 0) return\n throw new MissingRoutePolicyError({ file: filePath, routePath, methods: missing })\n}\n\n/** What the two AST passes over a route file answer, together. */\ninterface RouteSourceFacts {\n methods: HttpMethod[]\n /** The subset of `methods` that declared a `policy`. Empty when there are no methods. */\n declaredPolicy: Set<HttpMethod>\n /** What each declaring method declared. Keys are exactly `declaredPolicy`. */\n policyKinds: Map<HttpMethod, RoutePolicyKind>\n}\n\n/**\n * Per-file facts, recomputed only when the file changes (usetheokit/theokit#417).\n *\n * `theokit dev` calls `scanServerRoutes` on EVERY request, and this function parsed each route\n * file with the TypeScript AST TWICE per call — once for the exported methods, once for the policy\n * gate, sharing the source string but not the parse. `agent-scan.ts` had solved exactly this for\n * agent files and wrote down why; routes, which an application has far more of, had neither the\n * cache nor the reasoning.\n *\n * The refusal is deliberately NOT cached — only the facts are. A scan that found a missing policy\n * once must go on refusing on every later scan, so `assertEveryMethodDeclaresPolicy` re-derives the\n * set difference (cheap, no parse) from the cached facts each time.\n */\nconst routeFactsCache = createFileStampCache<RouteSourceFacts>()\n\n/** Test seam — the module-level cache would otherwise outlive a fixture directory. */\nexport function _resetRouteScanCacheForTests(): void {\n routeFactsCache.clear()\n}\n\nfunction routeSourceFacts(absPath: string): RouteSourceFacts {\n return routeFactsCache.get(absPath, () => {\n const source = readFileSync(absPath, 'utf-8')\n const methods = detectExportedHttpMethods(absPath, source)\n // Kept lazy exactly as the early return in the assert made it: a file exporting no HTTP method\n // has nothing for the policy gate to check, and parsing it a second time to learn that was the\n // cost this cache exists to remove.\n const policyKinds =\n methods.length === 0\n ? new Map<HttpMethod, RoutePolicyKind>()\n : detectRoutePolicyKinds(absPath, source)\n // One parse, one source of truth: the gate's set is a projection of the map, so the build gate\n // (\"did it declare?\") and the exposure gate (\"what did it declare?\") cannot drift apart.\n return { methods, declaredPolicy: new Set(policyKinds.keys()), policyKinds }\n })\n}\n\nfunction fileToRoutePath(filePath: string, routesDir: string): string {\n let rel = relative(routesDir, filePath)\n // Strip extension\n const ext = extname(rel)\n rel = rel.slice(0, -ext.length)\n // Normalize separators\n rel = rel.replace(/\\\\/g, '/')\n // Strip index suffix\n if (rel.endsWith('/index')) {\n rel = rel.slice(0, -6)\n } else if (rel === 'index') {\n rel = ''\n }\n // Replace [...param] with :...param (catch-all, before regular params).\n // Replace [param] with :param. Inputs are file paths bounded by the\n // OS filename limit; the bracket capture is bounded by `]`.\n rel = rel.replace(/\\[\\.\\.\\.([^\\]]+)\\]/g, ':...$1')\n // eslint-disable-next-line sonarjs/slow-regex -- bounded by `]`; input is a single filename\n rel = rel.replace(/\\[([^\\]]+)\\]/g, ':$1')\n return `/api/${rel}`\n}\n\nexport function scanServerRoutes(serverDir: string): ServerRouteNode[] {\n const routesDir = join(serverDir, 'routes')\n if (!existsSync(routesDir) || !statSync(routesDir).isDirectory()) {\n return []\n }\n\n const results: ServerRouteNode[] = []\n walkSourceFiles(routesDir, { extensions: ROUTE_EXTENSIONS }, (absPath) => {\n // EC-4: skip co-located test/spec files BEFORE the dotted-basename check\n if (isTestOrSpecFile(absPath)) return\n\n // G6 T1.1: reject dotted basenames (legacy convention that produced wrong\n // paramNames due to greedy `:(?:\\.\\.\\.)?([^/]+)` regex in compilePattern).\n assertNoRedundantApiSegment(absPath, routesDir)\n assertNoDottedSegment(absPath, routesDir)\n\n const routePath = fileToRoutePath(absPath, routesDir)\n const { pattern, paramNames } = compilePattern(routePath)\n const facts = routeSourceFacts(absPath)\n const { methods } = facts\n assertEveryMethodDeclaresPolicy(absPath, routePath, facts)\n results.push({\n filePath: absPath,\n routePath,\n paramNames,\n pattern,\n methods,\n // Always set, even when empty — `public-exposure-gate.ts` reads the FIELD's presence as\n // \"this was measured\" and its absence as \"this predates the check\". A scanned route was\n // measured by definition, so it never reports the second.\n publicMethods: [...facts.policyKinds]\n .filter(([, kind]) => kind === 'public')\n .map(([method]) => method),\n })\n })\n\n // T1.4 / EC-2 — refuse to scan if a user route collides with the reserved\n // batch endpoint path. User must rename or disable batching.\n const conflicting = results.find((r) => r.routePath === '/api/__theo_batch__')\n if (conflicting) {\n throw new Error(\n `Server route ${conflicting.filePath} resolves to '/api/__theo_batch__' which is reserved for the batch endpoint. Rename the route or disable batching in theo.config.ts.`,\n )\n }\n\n results.sort((a, b) => compareRouteSpecificity(a.routePath, b.routePath))\n\n return results\n}\n\n/** How constrained one path segment is. Lower is more specific. */\nconst SEGMENT_STATIC = 0\nconst SEGMENT_DYNAMIC = 1\nconst SEGMENT_CATCH_ALL = 2\n\nfunction segmentSpecificity(segment: string): number {\n if (segment.startsWith(':...')) return SEGMENT_CATCH_ALL\n if (segment.startsWith(':')) return SEGMENT_DYNAMIC\n return SEGMENT_STATIC\n}\n\n/**\n * Order two route paths by specificity, most specific first.\n *\n * `matchRoute` returns on the first pattern that matches, so this order IS the\n * precedence contract — not a presentation detail of the manifest.\n *\n * Segments are compared position by position, and the first position where they\n * disagree decides: a literal beats a parameter, and a parameter beats a\n * catch-all. That is the rule the URL itself expresses, and it is the rule a\n * whole-path comparison cannot express, because a whole-path comparison reads\n * characters across segment boundaries. Comparing `/api/:resource/settings`\n * with `/api/users/:id` that way put the generic route first — `:` precedes `u`\n * in every collation — so `/api/users/settings` reached the generic handler and\n * an authorization check placed on the specific route was bypassed\n * (usetheokit/theokit#348).\n *\n * Only the segments the two paths have in common are ranked. Past that point\n * one path is a strict prefix of the other, and two such routes cannot match\n * the same URL — so there is nothing to decide, only a stable order to pick.\n *\n * The final fallback compares by code unit rather than with `localeCompare`.\n * Collation is locale-dependent, so the same route table would order\n * differently under a different `LANG` — the cross-machine divergence\n * usetheokit/theokit#346 removed from the sibling scanner. The tiebreak only\n * has to be total and stable; it does not have to be alphabetical for a human.\n */\nexport function compareRouteSpecificity(a: string, b: string): number {\n const aSegments = a.split('/')\n const bSegments = b.split('/')\n const shared = Math.min(aSegments.length, bSegments.length)\n\n for (let i = 0; i < shared; i++) {\n const difference = segmentSpecificity(aSegments[i]) - segmentSpecificity(bSegments[i])\n if (difference !== 0) return difference\n }\n\n if (a < b) return -1\n if (a > b) return 1\n return 0\n}\n","/**\n * Detect which HTTP-method named exports a route file declares.\n *\n * Uses the TypeScript compiler API (not regex) per G1 edge-case review EC-4:\n * regex over file content emits false positives for `// export const GET = ...`\n * in comments and `` `export const GET = ...` `` in template literals. AST\n * walking avoids both classes of bug.\n *\n * `typescript` ships as CommonJS with internal dynamic `require('fs')`.\n * When loaded via ESM `import`, the dynamic requires fail at module-bootstrap.\n * We use `createRequire(import.meta.url)` to keep the package on its native\n * CJS path. The type-only namespace import gives us the AST helpers shape.\n *\n * Returns the set of HTTP methods (uppercase) the file exports. Empty array\n * means the file has no HTTP exports (the route file is util-only).\n */\n\nimport { readFileSync } from 'node:fs'\nimport { createRequire } from 'node:module'\n\nimport type * as TS from 'typescript'\n\nimport { HTTP_METHODS, type HttpMethod } from '../../core/contracts/http-methods.js'\nimport { compareByCodeUnit } from '../_internal/compare-by-code-unit.js'\n\nconst require_ = createRequire(import.meta.url)\n\nconst ts = require_('typescript') as typeof TS\n\nconst HTTP_METHOD_NAMES = new Set<string>(HTTP_METHODS)\n\nfunction hasExportModifier(modifiers: readonly TS.Modifier[] | undefined): boolean {\n if (!modifiers) return false\n for (const m of modifiers) {\n if (m.kind === ts.SyntaxKind.ExportKeyword) return true\n }\n return false\n}\n\n// An AST visitor over the export forms (const / function / named export) is inherently branchy;\n// the complexity is in the grammar it walks, not in tangled logic. Splitting it would scatter one\n// cohesive dispatch across helpers for no readability gain.\n// eslint-disable-next-line complexity -- AST visitor, see above\nfunction collectFromStatement(stmt: TS.Statement, found: Set<HttpMethod>): void {\n // `export const GET = ...` / `export function GET ...` / `export async function GET ...`\n if (ts.isVariableStatement(stmt) && hasExportModifier(ts.getModifiers(stmt))) {\n for (const decl of stmt.declarationList.declarations) {\n if (ts.isIdentifier(decl.name) && HTTP_METHOD_NAMES.has(decl.name.text)) {\n found.add(decl.name.text as HttpMethod)\n }\n }\n return\n }\n\n if (\n (ts.isFunctionDeclaration(stmt) || ts.isClassDeclaration(stmt)) &&\n hasExportModifier(ts.getModifiers(stmt))\n ) {\n if (stmt.name && HTTP_METHOD_NAMES.has(stmt.name.text)) {\n found.add(stmt.name.text as HttpMethod)\n }\n return\n }\n\n // `export { GET }` / `export { handler as GET } from './shared'` (EC-5)\n if (ts.isExportDeclaration(stmt) && stmt.exportClause && ts.isNamedExports(stmt.exportClause)) {\n for (const spec of stmt.exportClause.elements) {\n // spec.name is the exported (re-)name; spec.propertyName is the original (when renamed)\n if (HTTP_METHOD_NAMES.has(spec.name.text)) {\n found.add(spec.name.text as HttpMethod)\n }\n }\n }\n}\n\nexport function detectExportedHttpMethods(filePath: string, content?: string): HttpMethod[] {\n // `filePath` is a route module the framework itself discovered by globbing the project — never\n // user input at runtime. Reading it by a computed path is the whole job of a source scanner.\n // eslint-disable-next-line security/detect-non-literal-fs-filename -- framework-controlled path\n const src = content ?? readFileSync(filePath, 'utf-8')\n const sourceFile = ts.createSourceFile(\n filePath,\n src,\n ts.ScriptTarget.Latest,\n /* setParentNodes */ false,\n ts.ScriptKind.TS,\n )\n const found = new Set<HttpMethod>()\n for (const stmt of sourceFile.statements) {\n collectFromStatement(stmt, found)\n }\n // HTTP method names are ASCII, so no collation disagrees about them today.\n // Ordered by code unit anyway, so that \"build output orders by code unit\"\n // stays a rule a reader can check by grep rather than a rule with exceptions\n // each needing its own argument (usetheokit/theokit#351).\n return [...found].sort(compareByCodeUnit)\n}\n","/**\n * Detect which HTTP-method exports of a route file declare an access policy.\n *\n * The companion of `detect-http-methods.ts`, and deliberately the same shape:\n * the TypeScript AST rather than a regex, because `// policy: 'public'` in a\n * comment and `` `policy` `` in a doc string are both things a route file\n * legitimately contains, and neither declares anything.\n *\n * ADR 0001 decides that a route says who may call it, `'public'` included, and\n * that absence stops meaning open. This is the half of that decision the\n * scanner can answer: which exports said something. `scanServerRoutes` turns\n * the silence into a build error.\n *\n * ## What counts as a declaration\n *\n * Two forms, because the framework ships two ways to write a route:\n *\n * ```ts\n * export const GET = route().policy('public').handler(fn).build() // builder\n * export const GET = defineRoute({ policy: fn, handler: fn }) // object\n * ```\n *\n * Only the config position is inspected — the top level of an object literal\n * passed to a call, and `.policy(...)` links of a call chain. The handler's\n * BODY is never walked, so a handler that happens to return `{ policy: ... }`\n * does not satisfy the gate. Reading deeper would trade a false build error for\n * a false pass, and a false pass here is a route nobody protected that the gate\n * reported as protected.\n *\n * ## What it deliberately cannot see\n *\n * `export { GET } from './shared'` re-exports across a module boundary, and\n * `export const GET = makeAdminRoute(fn)` hides the config inside a helper.\n * Both come back \"not declared\", which fails the build. That direction is the\n * chosen one: the cost is an explicit declaration on a route that already had\n * one somewhere else, and the alternative cost is a route reported as declared\n * because the scanner guessed.\n */\nimport { createRequire } from 'node:module'\n\nimport type * as TS from 'typescript'\n\nimport { HTTP_METHODS, type HttpMethod } from '../../core/contracts/http-methods.js'\n\nconst require_ = createRequire(import.meta.url)\n\nconst ts = require_('typescript') as typeof TS\n\nconst HTTP_METHOD_NAMES = new Set<string>(HTTP_METHODS)\n\nconst POLICY_KEY = 'policy'\n\nfunction hasExportModifier(modifiers: readonly TS.Modifier[] | undefined): boolean {\n if (!modifiers) return false\n for (const m of modifiers) {\n if (m.kind === ts.SyntaxKind.ExportKeyword) return true\n }\n return false\n}\n\n/** Strip the wrappers that carry no runtime meaning (`(x)`, `x as T`, `x satisfies T`, `x!`). */\nfunction unwrap(expression: TS.Expression): TS.Expression {\n let current = expression\n for (;;) {\n if (\n ts.isParenthesizedExpression(current) ||\n ts.isAsExpression(current) ||\n ts.isSatisfiesExpression(current) ||\n ts.isNonNullExpression(current)\n ) {\n current = current.expression\n continue\n }\n return current\n }\n}\n\nfunction propertyNameIsPolicy(name: TS.PropertyName | undefined): boolean {\n if (name === undefined) return false\n if (ts.isIdentifier(name)) return name.text === POLICY_KEY\n if (ts.isStringLiteral(name)) return name.text === POLICY_KEY\n return false\n}\n\n/**\n * What a route said about who may call it.\n *\n * `'public'` is the string literal ADR 0001 gives a meaning to; everything else is a function this\n * pass cannot evaluate, and is reported `'guarded'`. That asymmetry is deliberate — see\n * `policyKindOfArgument`.\n */\nexport type RoutePolicyKind = 'public' | 'guarded'\n\n/**\n * The kind an argument in the `policy` position declares.\n *\n * Only the bare literal `'public'` is read as open. An identifier, a property access, a call, a\n * template — anything this pass cannot evaluate — comes back `'guarded'`.\n *\n * The two mistakes are not symmetric. Labelling an open route `'guarded'` costs a gate that fails\n * to fire on a route somebody left open on purpose. Labelling a guarded route `'public'` would put\n * a protected route on a list of exposures and, worse, train a reader to disbelieve the list. Only\n * the literal is legible, so only the literal is believed.\n */\nfunction policyKindOfArgument(expression: TS.Expression): RoutePolicyKind {\n const arg = unwrap(expression)\n return ts.isStringLiteral(arg) && arg.text === 'public' ? 'public' : 'guarded'\n}\n\n/** A `policy` key at the TOP level of a config object literal. Never deeper. */\nfunction objectPolicyKind(literal: TS.ObjectLiteralExpression): RoutePolicyKind | undefined {\n for (const property of literal.properties) {\n if (ts.isSpreadAssignment(property)) continue\n if (!propertyNameIsPolicy(property.name)) continue\n // `{ policy: x }` carries an initializer; `{ policy }` shorthand does not, and a shorthand\n // reference is exactly the unreadable case that takes the safe label.\n return ts.isPropertyAssignment(property)\n ? policyKindOfArgument(property.initializer)\n : 'guarded'\n }\n return undefined\n}\n\n/**\n * Does this initializer declare a policy?\n *\n * Walks the call chain leftwards (`.build()` -> `.handler()` -> `.policy()`) and\n * checks the arguments each call receives, which is where the object form puts\n * its config. Nothing else is visited.\n */\nfunction policyKind(expression: TS.Expression): RoutePolicyKind | undefined {\n const expr = unwrap(expression)\n\n if (ts.isObjectLiteralExpression(expr)) return objectPolicyKind(expr)\n\n if (!ts.isCallExpression(expr)) return undefined\n\n const callee = unwrap(expr.expression)\n\n if (ts.isPropertyAccessExpression(callee) && callee.name.text === POLICY_KEY) {\n // `.policy()` with no argument declares the key and says nothing readable.\n return expr.arguments.length === 0 ? 'guarded' : policyKindOfArgument(expr.arguments[0])\n }\n\n for (const argument of expr.arguments) {\n const arg = unwrap(argument)\n if (!ts.isObjectLiteralExpression(arg)) continue\n const kind = objectPolicyKind(arg)\n if (kind !== undefined) return kind\n }\n\n // Keep walking the chain: `route().policy(p).handler(h).build()` reaches\n // `.policy` only by stepping left through `.build` and `.handler`.\n if (ts.isPropertyAccessExpression(callee)) return policyKind(callee.expression)\n\n return undefined\n}\n\n/** Every top-level `const x = <expr>` in the file, so `export { x as GET }` can be resolved. */\nfunction collectLocalInitializers(sourceFile: TS.SourceFile): Map<string, TS.Expression> {\n const locals = new Map<string, TS.Expression>()\n for (const stmt of sourceFile.statements) {\n if (!ts.isVariableStatement(stmt)) continue\n for (const decl of stmt.declarationList.declarations) {\n if (ts.isIdentifier(decl.name) && decl.initializer !== undefined) {\n locals.set(decl.name.text, decl.initializer)\n }\n }\n }\n return locals\n}\n\n/** `export const GET = ...` */\nfunction collectFromVariableStatement(\n stmt: TS.VariableStatement,\n declared: Map<HttpMethod, RoutePolicyKind>,\n): void {\n if (!hasExportModifier(ts.getModifiers(stmt))) return\n for (const decl of stmt.declarationList.declarations) {\n if (!ts.isIdentifier(decl.name) || !HTTP_METHOD_NAMES.has(decl.name.text)) continue\n if (decl.initializer === undefined) continue\n const kind = policyKind(decl.initializer)\n if (kind !== undefined) declared.set(decl.name.text as HttpMethod, kind)\n }\n}\n\n/**\n * `export { GET }` / `export { handler as GET }` — resolvable only when the\n * declaration is in this file. A re-export with a module specifier is not.\n */\nfunction collectFromExportDeclaration(\n stmt: TS.ExportDeclaration,\n locals: Map<string, TS.Expression>,\n declared: Map<HttpMethod, RoutePolicyKind>,\n): void {\n if (stmt.moduleSpecifier !== undefined) return\n if (!stmt.exportClause || !ts.isNamedExports(stmt.exportClause)) return\n for (const spec of stmt.exportClause.elements) {\n if (!HTTP_METHOD_NAMES.has(spec.name.text)) continue\n const local = locals.get((spec.propertyName ?? spec.name).text)\n if (local === undefined) continue\n const kind = policyKind(local)\n if (kind !== undefined) declared.set(spec.name.text as HttpMethod, kind)\n }\n}\n\nfunction collectFromStatement(\n stmt: TS.Statement,\n locals: Map<string, TS.Expression>,\n declared: Map<HttpMethod, RoutePolicyKind>,\n): void {\n if (ts.isVariableStatement(stmt)) {\n collectFromVariableStatement(stmt, declared)\n return\n }\n if (ts.isExportDeclaration(stmt)) {\n collectFromExportDeclaration(stmt, locals, declared)\n }\n // `export function GET() {}` and `export class GET {}` reach neither branch,\n // on purpose: a bare function has no config object to carry a policy.\n}\n\n/**\n * What each HTTP-method export of this file declared — `'public'` or `'guarded'`.\n *\n * The KEYS answer the question ADR 0001 asks at build time: which methods declared a policy at all.\n * The VALUES answer the half it left open until now: whether the declaration protects anything.\n * One map, so the build gate and the exposure gate cannot disagree about which methods declared.\n *\n * `content` is passed in rather than read here so the scanner reads each route file once and hands\n * the same source to both detectors.\n */\nexport function detectRoutePolicyKinds(\n filePath: string,\n content: string,\n): Map<HttpMethod, RoutePolicyKind> {\n const sourceFile = ts.createSourceFile(\n filePath,\n content,\n ts.ScriptTarget.Latest,\n /* setParentNodes */ false,\n ts.ScriptKind.TS,\n )\n const locals = collectLocalInitializers(sourceFile)\n const declared = new Map<HttpMethod, RoutePolicyKind>()\n for (const stmt of sourceFile.statements) {\n collectFromStatement(stmt, locals, declared)\n }\n return declared\n}\n","/* eslint-disable security/detect-non-literal-fs-filename --\n * Build-time scanner: walks `serverDir/ws/` derived from cwd.\n * No HTTP input ever reaches these fs calls.\n */\nimport { existsSync, statSync } from 'node:fs'\nimport { extname, join, relative } from 'node:path'\n\nimport { walkSourceFiles } from '../_internal/scan-walker.js'\n\nconst WS_EXTENSIONS = new Set(['.ts', '.tsx', '.js', '.jsx'])\n\nexport interface WebSocketRouteNode {\n filePath: string\n wsPath: string\n}\n\nexport function scanWebSocketRoutes(serverDir: string): WebSocketRouteNode[] {\n const wsDir = join(serverDir, 'ws')\n if (!existsSync(wsDir) || !statSync(wsDir).isDirectory()) {\n return []\n }\n\n const results: WebSocketRouteNode[] = []\n walkSourceFiles(wsDir, { extensions: WS_EXTENSIONS }, (absPath) => {\n let rel = relative(wsDir, absPath)\n rel = rel.replace(/\\\\/g, '/')\n rel = rel.slice(0, -extname(rel).length)\n if (rel.endsWith('/index')) rel = rel.slice(0, -6)\n else if (rel === 'index') rel = ''\n results.push({\n filePath: absPath,\n wsPath: `/ws/${rel}`,\n })\n })\n return results\n}\n"],"mappings":";;;;;;;;;;;;AAIA,SAAS,YAAY,cAAc,gBAAgB;AACnD,SAAS,SAAS,MAAM,gBAAgB;AAuBjC,IAAM,qBAAqB;AA8B3B,IAAM,kBAAN,cAA8B,MAAM;AAAA,EAChC;AAAA,EACA;AAAA,EAET,YACE,MACA,SACA,kBACA;AACA,UAAM,OAAO;AAIb,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,mBAAmB;AAAA,EAC1B;AACF;AAEA,IAAM,oBAAoB,oBAAI,IAAI,CAAC,OAAO,QAAQ,OAAO,MAAM,CAAC;AAChE,IAAM,eAAe;AACrB,IAAM,iBAAiB,oBAAI,IAAI,CAAC,SAAS,eAAe,aAAa,aAAa,gBAAgB,CAAC;AAO5F,SAAS,kBAAkB,WAAiC;AACjE,QAAM,aAAa,KAAK,WAAW,SAAS;AAC5C,MAAI,CAAC,WAAW,UAAU,KAAK,CAAC,SAA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Q,QAAS,OAAM;AAChC,YAAQ,KAAK;AAAA,MACX,UAAU;AAAA,MACV,QAAQ,OAAO,GAAG;AAAA,IACpB,CAAC;AAAA,EACH,CAAC;AACD,SAAO;AACT;","names":["basename","existsSync","readFileSync","statSync","extname","join","relative","readFileSync","readFileSync","createRequire","require_","createRequire","ts","HTTP_METHOD_NAMES","hasExportModifier","collectFromStatement","relative","extname","readFileSync","relative","extname","join","existsSync","statSync","existsSync","statSync","extname","join","relative","join","existsSync","statSync","relative","extname"]}
|
|
@@ -6,7 +6,7 @@ async function initCacheEngineFromConfig(cacheConfig) {
|
|
|
6
6
|
if (cacheConfig === void 0 || cacheConfig === null) return;
|
|
7
7
|
const { initCacheEngine, isCacheEngineInitialized } = await import("./engine-singleton-X4R7AZBJ.js");
|
|
8
8
|
if (isCacheEngineInitialized()) return;
|
|
9
|
-
const { cacheSchema } = await import("./schemas-
|
|
9
|
+
const { cacheSchema } = await import("./schemas-QCMSKQDK.js");
|
|
10
10
|
const parsed = cacheSchema.parse(cacheConfig);
|
|
11
11
|
if (!parsed.enabled) return;
|
|
12
12
|
initCacheEngine({
|
|
@@ -23,4 +23,4 @@ async function initCacheEngineFromConfig(cacheConfig) {
|
|
|
23
23
|
export {
|
|
24
24
|
initCacheEngineFromConfig
|
|
25
25
|
};
|
|
26
|
-
//# sourceMappingURL=chunk-
|
|
26
|
+
//# sourceMappingURL=chunk-NZDGV4YJ.js.map
|
|
@@ -138,7 +138,25 @@ var securitySchema = z7.object({
|
|
|
138
138
|
/** T5.1 — per-route escalation (Rails disallowed_warnings pattern). */
|
|
139
139
|
disallowed: disallowedConfigSchema.optional(),
|
|
140
140
|
/** T1.2 — Cross-Origin Resource Sharing. Single global config; runs first in pipeline. */
|
|
141
|
-
cors: corsSchema.optional()
|
|
141
|
+
cors: corsSchema.optional(),
|
|
142
|
+
/**
|
|
143
|
+
* Permit binding a public network interface while write routes still declare `policy('public')`.
|
|
144
|
+
*
|
|
145
|
+
* Absent means `false`, and that is the point: `theo start` refuses that combination rather
|
|
146
|
+
* than serving it, because an unauthenticated POST reachable from a network is an open endpoint
|
|
147
|
+
* whether or not anyone meant it to be. See `cli/commands/start/public-exposure-gate.ts` for what
|
|
148
|
+
* is refused and — equally important — what is not.
|
|
149
|
+
*
|
|
150
|
+
* Setting it to `true` is a decision, not a switch: the routes stay open, the startup log goes on
|
|
151
|
+
* naming every one of them, and this line in `theo.config.ts` is what an auditor finds when they
|
|
152
|
+
* ask who agreed to it.
|
|
153
|
+
*
|
|
154
|
+
* `.optional()` rather than `.default(false)`: a Zod default lands in the OUTPUT type, so every
|
|
155
|
+
* caller constructing a `SecurityConfig` literal would have to name a field they do not care
|
|
156
|
+
* about. The reader supplies the fallback (`?? false`), which keeps absent and false identical
|
|
157
|
+
* where it matters and keeps the type unchanged for everyone else.
|
|
158
|
+
*/
|
|
159
|
+
allowUnauthenticatedWrites: z7.boolean().optional()
|
|
142
160
|
});
|
|
143
161
|
|
|
144
162
|
// src/config/schemas/storage.ts
|
|
@@ -190,4 +208,4 @@ export {
|
|
|
190
208
|
securitySchema,
|
|
191
209
|
storageSchema
|
|
192
210
|
};
|
|
193
|
-
//# sourceMappingURL=chunk-
|
|
211
|
+
//# sourceMappingURL=chunk-OSBGZYXZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/config/schemas/rate-limit.ts","../src/config/schemas/upload.ts","../src/config/schemas/logging.ts","../src/config/schemas/cache.ts","../src/config/schemas/observability.ts","../src/config/schemas/security.ts","../src/config/schemas/header-safe.ts","../src/config/schemas/storage.ts"],"sourcesContent":["import { z } from 'zod'\n\n/**\n * Base bucket config — legacy shape preserved for backwards compatibility.\n */\nconst baseRateLimitSchema = z.object({\n windowMs: z.number().min(1),\n max: z.number().int().min(1),\n})\n\n/**\n * T2.2 — Per-route + per-user rate limit. The new shape adds `routes`\n * (path map), `keyBy`, and `cookieName`. The legacy flat shape is still\n * accepted via the union — see `createRouteRateLimiter` for normalization.\n */\nexport const rateLimitSchema = z.union([\n baseRateLimitSchema,\n z.object({\n default: baseRateLimitSchema.optional(),\n routes: z.record(z.string(), baseRateLimitSchema).optional(),\n keyBy: z\n .union([\n z.enum(['ip', 'session', 'user']),\n z.function({ input: z.tuple([z.unknown()]), output: z.string() }),\n ])\n .optional(),\n cookieName: z.string().min(1).optional(),\n /**\n * How many reverse proxies sit in front of the app, for `keyBy: 'ip'`. `false` (default)\n * trusts none; `true` means one; a number names a longer chain.\n *\n * Required for correct limiting behind Caddy/nginx/a load balancer — without it every visitor\n * keys on the proxy address and shares a single bucket. Off by default because\n * `x-forwarded-for` is client-writable.\n */\n trustProxy: z.union([z.boolean(), z.number().int().min(0)]).optional(),\n }),\n])\n","import { z } from 'zod'\n\nexport const uploadSchema = z.object({\n maxFileSize: z\n .number()\n .min(1)\n .default(10 * 1024 * 1024), // 10MB\n maxFiles: z.number().int().min(1).default(10),\n maxFieldSize: z\n .number()\n .min(1)\n .default(1 * 1024 * 1024), // 1MB\n})\n","import { z } from 'zod'\n\nexport const loggingSchema = z.object({\n level: z.enum(['debug', 'info', 'warn', 'error', 'silent']).default('info'),\n})\n","import { z } from 'zod'\n\n// `.finite()` was removed from the 4 numeric schemas below (agent-builder#319): in zod 4 it is a\n// no-op — `z.number()` already rejects `Infinity`, `-Infinity` and `NaN` by default. Measured before\n// removing, against the installed zod 4.4.3, and not assumed from the deprecation message: all five\n// cases (`Infinity`, `-Infinity`, `NaN`, `1.5`, `0`) give the SAME verdict with and without it.\n\n/**\n * Cache subsystem config (caching-and-revalidation-plan).\n * Default `cache: undefined` keeps the framework backward-compatible\n * (no engine initialized → no cache primitives available).\n *\n * Setting `cache: {}` opts in with all defaults.\n */\nconst routeRuleSchema = z.object({\n maxAge: z.number().nonnegative().optional(),\n swr: z.number().nonnegative().optional(),\n tags: z.array(z.string()).optional(),\n})\n\nexport const cacheSchema = z.object({\n enabled: z.boolean().default(true),\n /** 'memory' uses InMemoryCacheAdapter; otherwise pass a custom adapter instance. */\n storage: z.union([z.literal('memory'), z.custom<unknown>()]).default('memory'),\n maxEntries: z.number().int().positive().default(1000),\n defaults: z\n .object({\n maxAge: z.number().nonnegative().default(1),\n swr: z.number().nonnegative().optional(),\n cacheErrors: z.boolean().default(false),\n })\n .default({ maxAge: 1, cacheErrors: false }),\n keyDerivation: z\n .object({\n excludeQuery: z.array(z.string()).optional(),\n sortQuery: z.boolean().default(true),\n lowercaseHost: z.boolean().default(true),\n })\n .default({ sortQuery: true, lowercaseHost: true }),\n routeRules: z.record(z.string(), routeRuleSchema).optional(),\n})\n","import { z } from 'zod'\n\n/**\n * Observability subsystem config.\n *\n * `adapter-registry.ts` has documented `theo.config.ts > observability.provider`\n * as the first source in its resolution chain since it was written, and the key\n * did not exist in the schema — so the chain's highest-priority entry was\n * unreachable and every consumer fell through to the environment\n * (usetheokit/theokit#353).\n *\n * Default `observability: undefined` keeps telemetry off, which is what an\n * application that never asked for it should get.\n */\nexport const observabilitySchema = z.object({\n /** Set `false` to opt out even when the environment would enable an exporter. */\n enabled: z.boolean().default(true),\n /**\n * An `ObservabilityAdapter` instance. Validated structurally rather than by\n * shape, for the same reason `storage` and `plugins` are: the config layer\n * cannot import the adapter contract without inverting the module graph, and\n * the adapter is a live object rather than data.\n */\n provider: z.custom<unknown>().optional(),\n})\n","import { z } from 'zod'\n\nimport { headerSafeString } from './header-safe.js'\n\n/**\n * Phase 5 — CSRF warn-first (EC-1).\n *\n * 0.2.0 default: `warn`. Existing apps keep working but get structured\n * warnings about every state-mutating request that does not carry the\n * `X-Theo-Action: 1` header. 0.3.0 will flip the default to `strict`.\n *\n * Set explicitly to `strict` to opt into the future default early,\n * or `off` to disable CSRF entirely (only valid when you have another\n * defense — bearer auth, no session cookies, etc).\n */\n\n/**\n * Phase 6 — Default security headers (D4 / EC-2).\n *\n * 0.2.0 defaults:\n * - CSP in `report-only` mode (EC-2: don't break existing apps)\n * - X-Frame-Options: DENY · X-Content-Type-Options: nosniff\n * - Referrer-Policy: strict-origin-when-cross-origin\n * - HSTS in production only (no TLS on localhost)\n *\n * Users override individual headers, swap CSP to `enforce`, or disable\n * CSP entirely (`csp: false` / `cspMode: 'off'`).\n */\nexport const securityHeadersSchema = z.object({\n csp: z.union([headerSafeString, z.literal(false)]).optional(),\n // T6.1 — default flipped from 'report-only' to 'enforce' for 0.3.0.\n // Users who want the old behaviour set `cspMode: 'report-only'`\n // explicitly.\n cspMode: z.enum(['enforce', 'report-only', 'off']).default('enforce'),\n hsts: z.union([headerSafeString, z.literal(false)]).optional(),\n frameOptions: z.enum(['DENY', 'SAMEORIGIN']).default('DENY'),\n contentTypeOptions: z.literal('nosniff').default('nosniff'),\n referrerPolicy: headerSafeString.default('strict-origin-when-cross-origin'),\n /**\n * T1.1 — Permissions-Policy directive string. EC-3-refined: rejects CR/LF.\n * Pass `false` to suppress the header.\n */\n permissionsPolicy: z.union([headerSafeString, z.literal(false)]).optional(),\n})\n\n/**\n * T5.1 — Disallowed-routes escalation pattern (Rails-inspired).\n *\n * `routes` accepts string (exact match — trailing slash matters) or\n * RegExp entries. Matched routes that would otherwise emit `csrf.warn`\n * dispatch through `disallowedBehavior` instead:\n * - `'warn'` : no-op vs the default warn-mode behavior\n * - `'raise'` : escalate to 403, even when global `csrf` mode is 'warn'\n *\n * Use to roll out strict mode per-route (e.g., flip /api/auth/* first)\n * without committing the entire surface to strict at once.\n */\nconst disallowedConfigSchema = z.object({\n routes: z.array(z.union([z.string(), z.instanceof(RegExp)])),\n behavior: z.enum(['warn', 'raise']).default('raise'),\n})\n\n/**\n * T1.2 — CORS configuration.\n *\n * `origins` accepts a single value (`'*'`, string, RegExp, callback) OR an\n * array of (string | RegExp). The spec-violating `origins: '*'` +\n * `credentials: true` combination is rejected at parse time (browsers\n * ignore wildcards when credentials are sent).\n *\n * EC-3 — `allowedHeaders` and `exposedHeaders` entries go through the\n * header-safe refinement (CR/LF rejected — CWE-113 mitigation).\n */\nexport const corsSchema = z\n .object({\n origins: z.union([\n z.literal('*'),\n headerSafeString,\n z.instanceof(RegExp),\n z.array(z.union([headerSafeString, z.instanceof(RegExp)])),\n z.function({ input: z.tuple([z.string()]), output: z.boolean() }),\n ]),\n methods: z\n .array(z.enum(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS', 'HEAD']))\n .optional(),\n allowedHeaders: z.array(headerSafeString).optional(),\n exposedHeaders: z.array(headerSafeString).optional(),\n credentials: z.boolean().default(false),\n maxAge: z.number().int().min(0).max(86400).default(600),\n })\n .refine((c) => !(c.origins === '*' && c.credentials), {\n message: 'CORS spec forbids origins:\"*\" with credentials:true — browsers ignore the wildcard',\n })\n\nexport const securitySchema = z.object({\n // T6.1 — default flipped from 'warn' to 'strict' for 0.3.0. Apps that\n // grep their warn-mode logs from 0.2.x already know which endpoints\n // break; opt back into 'warn' globally OR use disallowedRoutes for\n // surgical migration.\n csrf: z.enum(['off', 'warn', 'strict']).default('strict'),\n headers: securityHeadersSchema.optional(),\n /** T5.1 — per-route escalation (Rails disallowed_warnings pattern). */\n disallowed: disallowedConfigSchema.optional(),\n /** T1.2 — Cross-Origin Resource Sharing. Single global config; runs first in pipeline. */\n cors: corsSchema.optional(),\n /**\n * Permit binding a public network interface while write routes still declare `policy('public')`.\n *\n * Absent means `false`, and that is the point: `theo start` refuses that combination rather\n * than serving it, because an unauthenticated POST reachable from a network is an open endpoint\n * whether or not anyone meant it to be. See `cli/commands/start/public-exposure-gate.ts` for what\n * is refused and — equally important — what is not.\n *\n * Setting it to `true` is a decision, not a switch: the routes stay open, the startup log goes on\n * naming every one of them, and this line in `theo.config.ts` is what an auditor finds when they\n * ask who agreed to it.\n *\n * `.optional()` rather than `.default(false)`: a Zod default lands in the OUTPUT type, so every\n * caller constructing a `SecurityConfig` literal would have to name a field they do not care\n * about. The reader supplies the fallback (`?? false`), which keeps absent and false identical\n * where it matters and keeps the type unchanged for everyone else.\n */\n allowUnauthenticatedWrites: z.boolean().optional(),\n})\n","import { z } from 'zod'\n\n/**\n * EC-3 — CWE-113 HTTP Response Splitting mitigation.\n *\n * Every string that becomes a header value must reject CR/LF. Apps that\n * derive header values from untrusted input (feature flags, tenant config,\n * URL params) would otherwise let attackers inject Set-Cookie / Location\n * headers via `\\r\\n`. Apply this refinement to every header-bound string\n * field: permissionsPolicy, csp, hsts, referrerPolicy, CORS allow/expose.\n */\nexport const headerSafeString = z\n .string()\n .refine((s) => !/[\\r\\n]/.test(s), { message: 'Header value must not contain CR/LF' })\n","import { z } from 'zod'\n\n/**\n * StorageManager schemas (T1.1 / ADR-0007 D4).\n *\n * `theo.config.ts > storage` declares Postgres servers (credentials), the\n * databases on each server (TheoCloud / managed PG / self-host), and Redis\n * servers. The runtime `StorageManager` consumes this block; adapters\n * (PostgresJobBackend, PostgresConversationStorage, etc.) request pools by\n * database name and never see raw credentials at the call site.\n *\n * EC-1 (DOCUMENT in concept doc T4.1): Zod default strip-unknown mode\n * silently drops typo keys (`databasees` instead of `databases`). The\n * concept doc warns users to use exact names; runtime errors are still\n * actionable (`Database \"X\" not configured`).\n *\n * EC-2 (DEFERRED to use-time): `databases.X.server` references a key in\n * `servers`. Cross-field validation is intentionally NOT enforced at parse\n * time — `StorageManager.usePostgres()` throws an actionable error on the\n * first call with the dangling reference, matching Rails / Nitro behavior.\n */\nconst tlsConfigSchema = z.object({\n rejectUnauthorized: z.boolean().optional(),\n caCert: z.string().optional(),\n clientCert: z.string().optional(),\n clientKey: z.string().optional(),\n})\n\nconst serverConfigSchema = z.object({\n host: z.string().min(1),\n port: z.number().int().positive().max(65535).optional(),\n user: z.string().min(1),\n /** Password may be the empty string (some providers permit it). */\n password: z.string(),\n tls: tlsConfigSchema.optional(),\n})\n\nconst postgresPoolConfigSchema = z.object({\n min: z.number().int().nonnegative().optional(),\n max: z.number().int().positive().optional(),\n connectionTimeoutMillis: z.number().int().positive().optional(),\n idleTimeoutMillis: z.number().int().nonnegative().optional(),\n})\n\nconst postgresDatabaseConfigSchema = z.object({\n /** References a key in `storage.servers`. Resolved at `usePostgres()` call time. */\n server: z.string().min(1),\n database: z.string().min(1),\n pool: postgresPoolConfigSchema.optional(),\n})\n\nconst redisServerConfigSchema = serverConfigSchema.extend({\n db: z.number().int().nonnegative().optional(),\n maxRetriesPerRequest: z.number().int().nonnegative().optional(),\n})\n\nexport const storageSchema = z.object({\n servers: z.record(z.string(), serverConfigSchema).optional(),\n databases: z.record(z.string(), postgresDatabaseConfigSchema).optional(),\n redis: z.record(z.string(), redisServerConfigSchema).optional(),\n})\n\nexport type StorageConfig = z.infer<typeof storageSchema>\n"],"mappings":";;;;AAAA,SAAS,SAAS;AAKlB,IAAM,sBAAsB,EAAE,OAAO;AAAA,EACnC,UAAU,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EAC1B,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC;AAC7B,CAAC;AAOM,IAAM,kBAAkB,EAAE,MAAM;AAAA,EACrC;AAAA,EACA,EAAE,OAAO;AAAA,IACP,SAAS,oBAAoB,SAAS;AAAA,IACtC,QAAQ,EAAE,OAAO,EAAE,OAAO,GAAG,mBAAmB,EAAE,SAAS;AAAA,IAC3D,OAAO,EACJ,MAAM;AAAA,MACL,EAAE,KAAK,CAAC,MAAM,WAAW,MAAM,CAAC;AAAA,MAChC,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,QAAQ,CAAC,CAAC,GAAG,QAAQ,EAAE,OAAO,EAAE,CAAC;AAAA,IAClE,CAAC,EACA,SAAS;AAAA,IACZ,YAAY,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IASvC,YAAY,EAAE,MAAM,CAAC,EAAE,QAAQ,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,SAAS;AAAA,EACvE,CAAC;AACH,CAAC;;;ACrCD,SAAS,KAAAA,UAAS;AAEX,IAAM,eAAeA,GA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Y,EAAE,SAAS;AAC7D,CAAC;AAED,IAAM,+BAA+BA,GAAE,OAAO;AAAA;AAAA,EAE5C,QAAQA,GAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACxB,UAAUA,GAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EAC1B,MAAM,yBAAyB,SAAS;AAC1C,CAAC;AAED,IAAM,0BAA0B,mBAAmB,OAAO;AAAA,EACxD,IAAIA,GAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,SAAS;AAAA,EAC5C,sBAAsBA,GAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,SAAS;AAChE,CAAC;AAEM,IAAM,gBAAgBA,GAAE,OAAO;AAAA,EACpC,SAASA,GAAE,OAAOA,GAAE,OAAO,GAAG,kBAAkB,EAAE,SAAS;AAAA,EAC3D,WAAWA,GAAE,OAAOA,GAAE,OAAO,GAAG,4BAA4B,EAAE,SAAS;AAAA,EACvE,OAAOA,GAAE,OAAOA,GAAE,OAAO,GAAG,uBAAuB,EAAE,SAAS;AAChE,CAAC;","names":["z","z","z","z","z","z","z","z"]}
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "./chunk-SSYDEKWF.js";
|
|
8
8
|
import {
|
|
9
9
|
dispatchControllerRequest
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-DAE7BJ7H.js";
|
|
11
11
|
import {
|
|
12
12
|
broadcastToDevtools
|
|
13
13
|
} from "./chunk-OIGJOYX6.js";
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
securitySchema,
|
|
36
36
|
storageSchema,
|
|
37
37
|
uploadSchema
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-WX6NHGKS.js";
|
|
39
39
|
import {
|
|
40
40
|
loadEnv
|
|
41
41
|
} from "./chunk-4X6H2BXP.js";
|
|
@@ -53,7 +53,7 @@ import {
|
|
|
53
53
|
incomingMessageToHandlerRequest,
|
|
54
54
|
sendError,
|
|
55
55
|
writeWebResponseToServerResponse
|
|
56
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-FVFYACYK.js";
|
|
57
57
|
import {
|
|
58
58
|
findSuggestion
|
|
59
59
|
} from "./chunk-NTDN54XO.js";
|
|
@@ -76,7 +76,7 @@ import {
|
|
|
76
76
|
scanServerActions,
|
|
77
77
|
scanServerRoutes,
|
|
78
78
|
scanWebSocketRoutes
|
|
79
|
-
} from "./chunk-
|
|
79
|
+
} from "./chunk-I2UN46ZX.js";
|
|
80
80
|
import {
|
|
81
81
|
scanAgents
|
|
82
82
|
} from "./chunk-IRASEXOG.js";
|
|
@@ -300,7 +300,15 @@ var theoConfigSchema = z.object({
|
|
|
300
300
|
}).optional(),
|
|
301
301
|
port: z.number().int().min(1).max(65535).default(3e3),
|
|
302
302
|
/** Listen on all addresses (0.0.0.0) for LAN/mobile testing. */
|
|
303
|
-
|
|
303
|
+
/**
|
|
304
|
+
* Deliberately NOT defaulted. `resolveListenTarget` ranks an explicit `host` above `HOST`,
|
|
305
|
+
* because a value written into the project is a decision and an environment variable is a
|
|
306
|
+
* deployment detail — and a default applied here made every app look like it had decided.
|
|
307
|
+
* `HOST` was therefore inert everywhere, which is the opposite of what it was added for
|
|
308
|
+
* (containers, #402). The loopback default lives in `resolveListenTarget`, where "nobody said"
|
|
309
|
+
* is still distinguishable from "somebody said localhost".
|
|
310
|
+
*/
|
|
311
|
+
host: z.union([z.string(), z.boolean()]).optional(),
|
|
304
312
|
/** Automatically open browser on `theokit dev`. */
|
|
305
313
|
open: z.union([z.boolean(), z.string()]).default(false),
|
|
306
314
|
/** Exit if port is already in use instead of trying next available. */
|
|
@@ -2325,7 +2333,7 @@ async function runConfigureServer(server, ctx) {
|
|
|
2325
2333
|
server.watcher.on("unlink", handleRouteChange);
|
|
2326
2334
|
if (ctx.resolvedOpenApi !== void 0) {
|
|
2327
2335
|
const openApiCfg = ctx.resolvedOpenApi;
|
|
2328
|
-
const { reEmitOpenApi } = await import("./dev-emit-
|
|
2336
|
+
const { reEmitOpenApi } = await import("./dev-emit-W27J3DLU.js");
|
|
2329
2337
|
const openApiServerDir = ctx.serverDir;
|
|
2330
2338
|
const openApiDistDir = resolve8(ctx.projectRoot, ctx.resolvedDistDir);
|
|
2331
2339
|
const isRouteFileForOpenApi = (file) => file.startsWith(openApiServerDir) && /\.(ts|tsx|js|mjs)$/.test(file);
|
|
@@ -3476,19 +3484,19 @@ async function theoPluginAsync(rootOrOptions) {
|
|
|
3476
3484
|
})
|
|
3477
3485
|
);
|
|
3478
3486
|
}
|
|
3479
|
-
const { appTypedClientPlugin } = await import("./app-typed-client-
|
|
3487
|
+
const { appTypedClientPlugin } = await import("./app-typed-client-6MNNVMJU.js");
|
|
3480
3488
|
const appClientPlugin = appTypedClientPlugin({
|
|
3481
3489
|
cwd: projectRoot,
|
|
3482
3490
|
serverDir: serverDirAbs,
|
|
3483
3491
|
distDir: resolve10(projectRoot, ".theokit")
|
|
3484
3492
|
});
|
|
3485
|
-
const { actionsVirtualModule } = await import("./actions-virtual-module-
|
|
3493
|
+
const { actionsVirtualModule } = await import("./actions-virtual-module-FGJR3I7V.js");
|
|
3486
3494
|
const actionsPlugin = actionsVirtualModule({
|
|
3487
3495
|
serverDir: serverDirAbs,
|
|
3488
3496
|
distDir: resolve10(projectRoot, ".theokit")
|
|
3489
3497
|
});
|
|
3490
3498
|
const { agentsTypedClientPlugin } = await import("./agents-typed-client-INR2E7B3.js");
|
|
3491
|
-
const { generateManifest } = await import("./internal-api-
|
|
3499
|
+
const { generateManifest } = await import("./internal-api-VUDJUWYE.js");
|
|
3492
3500
|
const agentsClientPlugin = agentsTypedClientPlugin({
|
|
3493
3501
|
projectRoot,
|
|
3494
3502
|
agentsDir: agentsDirName,
|
|
@@ -3505,7 +3513,7 @@ async function theoPluginAsync(rootOrOptions) {
|
|
|
3505
3513
|
const controllerTransformPlugin = controllerSwcTransformPlugin({
|
|
3506
3514
|
serverDir: serverDirAbs
|
|
3507
3515
|
});
|
|
3508
|
-
const { serverOnlyImportBoundary } = await import("./server-boundary-
|
|
3516
|
+
const { serverOnlyImportBoundary } = await import("./server-boundary-4UIGB3G5.js");
|
|
3509
3517
|
const serverBoundaryPlugin = serverOnlyImportBoundary({
|
|
3510
3518
|
projectRoot,
|
|
3511
3519
|
serverDir: serverDirAbs
|
|
@@ -3688,4 +3696,4 @@ export {
|
|
|
3688
3696
|
theoPluginAsync,
|
|
3689
3697
|
theoPlugin
|
|
3690
3698
|
};
|
|
3691
|
-
//# sourceMappingURL=chunk-
|
|
3699
|
+
//# sourceMappingURL=chunk-S6RWUH3J.js.map
|