theokit 0.77.2 → 0.77.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/README.md +7 -2
  2. package/dist/{actions-virtual-module-UIX5YWZR.js → actions-virtual-module-CA4YEAL3.js} +3 -3
  3. package/dist/{actions-virtual-module-V5Q4XVL5.js → actions-virtual-module-QRTV4NHS.js} +2 -2
  4. package/dist/{agent-WE4WOLKC.js → agent-IBDE65UJ.js} +2 -2
  5. package/dist/{app-typed-client-6FQB5FQO.js → app-typed-client-ZCLFXBEC.js} +3 -3
  6. package/dist/{app-typed-client-JCBQGPMP.js → app-typed-client-ZCMCBS45.js} +2 -2
  7. package/dist/{aws-lambda-XT7ZDJ6B.js → aws-lambda-JXUPC5QM.js} +17 -6
  8. package/dist/aws-lambda-JXUPC5QM.js.map +1 -0
  9. package/dist/boot/index.js +3 -3
  10. package/dist/{build-DSVLRDZ6.js → build-WBQZWGED.js} +6 -6
  11. package/dist/{bun-PJLDELDT.js → bun-73JZLCKU.js} +16 -5
  12. package/dist/bun-73JZLCKU.js.map +1 -0
  13. package/dist/{chunk-EQJF2EH5.js → chunk-DDWF3UUI.js} +32 -1
  14. package/dist/chunk-DDWF3UUI.js.map +1 -0
  15. package/dist/{chunk-SEDZI7JF.js → chunk-FCBRWSBH.js} +2 -2
  16. package/dist/{chunk-BFDEEJOK.js → chunk-GNQKV2NP.js} +1 -1
  17. package/dist/{chunk-BFDEEJOK.js.map → chunk-GNQKV2NP.js.map} +1 -1
  18. package/dist/{chunk-KQBY62AE.js → chunk-HWRZUQPE.js} +31 -25
  19. package/dist/chunk-HWRZUQPE.js.map +1 -0
  20. package/dist/{chunk-ESSUFQ3H.js → chunk-IBZITTK7.js} +11 -9
  21. package/dist/chunk-IBZITTK7.js.map +1 -0
  22. package/dist/{chunk-3TCWOHLY.js → chunk-JZLNZOEL.js} +1 -1
  23. package/dist/{chunk-G3DDIEYE.js → chunk-MQCXYZEV.js} +4 -2
  24. package/dist/chunk-MQCXYZEV.js.map +1 -0
  25. package/dist/{chunk-E22GPCCO.js → chunk-MSSUMKFR.js} +61 -55
  26. package/dist/chunk-MSSUMKFR.js.map +1 -0
  27. package/dist/{chunk-XLFDYTWO.js → chunk-N7KDDYDB.js} +5 -3
  28. package/dist/chunk-N7KDDYDB.js.map +1 -0
  29. package/dist/{chunk-TODO6J42.js → chunk-PV6IO25S.js} +1 -1
  30. package/dist/chunk-PV6IO25S.js.map +1 -0
  31. package/dist/{chunk-N5YHENWJ.js → chunk-SHBPXX5E.js} +2 -2
  32. package/dist/{chunk-HZAXFD55.js → chunk-VSK5Y4ET.js} +2 -2
  33. package/dist/{chunk-GNV34JMI.js → chunk-XCPM72D6.js} +2 -2
  34. package/dist/{chunk-7IPWHWYV.js → chunk-YM6ONZYE.js} +11 -9
  35. package/dist/chunk-YM6ONZYE.js.map +1 -0
  36. package/dist/cli/index.js +6 -6
  37. package/dist/{cloudflare-F7KLBOU4.js → cloudflare-6ONK5HCO.js} +11 -3
  38. package/dist/cloudflare-6ONK5HCO.js.map +1 -0
  39. package/dist/{config-support-2TER2BYD.js → config-support-ZJIRVUWZ.js} +10 -5
  40. package/dist/config-support-ZJIRVUWZ.js.map +1 -0
  41. package/dist/{deno-deploy-LJ5JQQVR.js → deno-deploy-ZM2UR5ZI.js} +16 -5
  42. package/dist/deno-deploy-ZM2UR5ZI.js.map +1 -0
  43. package/dist/{dev-F4ZY7TZX.js → dev-AE7EWSB7.js} +5 -5
  44. package/dist/{index-C2lcEI-4.d.ts → index-CY_llLI7.d.ts} +4 -1
  45. package/dist/index.js +4 -4
  46. package/dist/{internal-api-H3C2ID6N.js → internal-api-JFA4JI3Z.js} +3 -3
  47. package/dist/{internal-api-5FTPYSEQ.js → internal-api-KQQHFTCG.js} +2 -2
  48. package/dist/{mcp-H3TNO6YV.js → mcp-UBGNYDMW.js} +2 -2
  49. package/dist/{netlify-ZPQNREFH.js → netlify-JLTQD3JJ.js} +78 -13
  50. package/dist/netlify-JLTQD3JJ.js.map +1 -0
  51. package/dist/{node-3EV3CVWB.js → node-UYRQNJNF.js} +2 -2
  52. package/dist/{preview-RYN7UI45.js → preview-VMMBMNMM.js} +3 -3
  53. package/dist/registry-XLKBFOPW.js +34 -0
  54. package/dist/server/define/index.d.ts +7 -2
  55. package/dist/server/define/index.js +1 -1
  56. package/dist/server/http/index.d.ts +2 -1
  57. package/dist/server/http/index.js +8 -2
  58. package/dist/server/index.d.ts +1 -1
  59. package/dist/server/index.js +10 -10
  60. package/dist/{server-boundary-5ZTBC2KF.js → server-boundary-JA3UOKJS.js} +2 -2
  61. package/dist/{server-boundary-DTF6ZEUO.js → server-boundary-OJ6YIPQT.js} +3 -3
  62. package/dist/{start-Y7VVCK6Q.js → start-AE5YCDVS.js} +6 -5
  63. package/dist/{start-Y7VVCK6Q.js.map → start-AE5YCDVS.js.map} +1 -1
  64. package/dist/{static-VNN4HYRN.js → static-C7PWUTQO.js} +2 -2
  65. package/dist/{theo-cloud-243SPOIA.js → theo-cloud-NKZUJO3H.js} +2 -2
  66. package/dist/{vercel-EXKSZ2OQ.js → vercel-MRZXLOIQ.js} +19 -5
  67. package/dist/vercel-MRZXLOIQ.js.map +1 -0
  68. package/dist/vite-plugin/index.js +4 -4
  69. package/dist/{vite-plugin-LDZJRFKT.js → vite-plugin-JMWUVMP3.js} +4 -4
  70. package/package.json +3 -3
  71. package/dist/aws-lambda-XT7ZDJ6B.js.map +0 -1
  72. package/dist/bun-PJLDELDT.js.map +0 -1
  73. package/dist/chunk-7IPWHWYV.js.map +0 -1
  74. package/dist/chunk-E22GPCCO.js.map +0 -1
  75. package/dist/chunk-EQJF2EH5.js.map +0 -1
  76. package/dist/chunk-ESSUFQ3H.js.map +0 -1
  77. package/dist/chunk-G3DDIEYE.js.map +0 -1
  78. package/dist/chunk-KQBY62AE.js.map +0 -1
  79. package/dist/chunk-TODO6J42.js.map +0 -1
  80. package/dist/chunk-XLFDYTWO.js.map +0 -1
  81. package/dist/cloudflare-F7KLBOU4.js.map +0 -1
  82. package/dist/config-support-2TER2BYD.js.map +0 -1
  83. package/dist/deno-deploy-LJ5JQQVR.js.map +0 -1
  84. package/dist/netlify-ZPQNREFH.js.map +0 -1
  85. package/dist/registry-3D2KR7UE.js +0 -34
  86. package/dist/vercel-EXKSZ2OQ.js.map +0 -1
  87. /package/dist/{actions-virtual-module-UIX5YWZR.js.map → actions-virtual-module-CA4YEAL3.js.map} +0 -0
  88. /package/dist/{actions-virtual-module-V5Q4XVL5.js.map → actions-virtual-module-QRTV4NHS.js.map} +0 -0
  89. /package/dist/{agent-WE4WOLKC.js.map → agent-IBDE65UJ.js.map} +0 -0
  90. /package/dist/{app-typed-client-6FQB5FQO.js.map → app-typed-client-ZCLFXBEC.js.map} +0 -0
  91. /package/dist/{app-typed-client-JCBQGPMP.js.map → app-typed-client-ZCMCBS45.js.map} +0 -0
  92. /package/dist/{build-DSVLRDZ6.js.map → build-WBQZWGED.js.map} +0 -0
  93. /package/dist/{chunk-SEDZI7JF.js.map → chunk-FCBRWSBH.js.map} +0 -0
  94. /package/dist/{chunk-3TCWOHLY.js.map → chunk-JZLNZOEL.js.map} +0 -0
  95. /package/dist/{chunk-N5YHENWJ.js.map → chunk-SHBPXX5E.js.map} +0 -0
  96. /package/dist/{chunk-HZAXFD55.js.map → chunk-VSK5Y4ET.js.map} +0 -0
  97. /package/dist/{chunk-GNV34JMI.js.map → chunk-XCPM72D6.js.map} +0 -0
  98. /package/dist/{dev-F4ZY7TZX.js.map → dev-AE7EWSB7.js.map} +0 -0
  99. /package/dist/{internal-api-H3C2ID6N.js.map → internal-api-JFA4JI3Z.js.map} +0 -0
  100. /package/dist/{internal-api-5FTPYSEQ.js.map → internal-api-KQQHFTCG.js.map} +0 -0
  101. /package/dist/{mcp-H3TNO6YV.js.map → mcp-UBGNYDMW.js.map} +0 -0
  102. /package/dist/{node-3EV3CVWB.js.map → node-UYRQNJNF.js.map} +0 -0
  103. /package/dist/{preview-RYN7UI45.js.map → preview-VMMBMNMM.js.map} +0 -0
  104. /package/dist/{registry-3D2KR7UE.js.map → registry-XLKBFOPW.js.map} +0 -0
  105. /package/dist/{server-boundary-5ZTBC2KF.js.map → server-boundary-JA3UOKJS.js.map} +0 -0
  106. /package/dist/{server-boundary-DTF6ZEUO.js.map → server-boundary-OJ6YIPQT.js.map} +0 -0
  107. /package/dist/{static-VNN4HYRN.js.map → static-C7PWUTQO.js.map} +0 -0
  108. /package/dist/{theo-cloud-243SPOIA.js.map → theo-cloud-NKZUJO3H.js.map} +0 -0
  109. /package/dist/{vite-plugin-LDZJRFKT.js.map → vite-plugin-JMWUVMP3.js.map} +0 -0
@@ -2,7 +2,7 @@
2
2
  import "tsx/esm";
3
3
  import {
4
4
  nodeAdapter
5
- } from "./chunk-G3DDIEYE.js";
5
+ } from "./chunk-MQCXYZEV.js";
6
6
  import {
7
7
  findRootDiv
8
8
  } from "./chunk-3PWQQWT6.js";
@@ -247,4 +247,4 @@ export {
247
247
  detectApiRoutes,
248
248
  staticAdapter
249
249
  };
250
- //# sourceMappingURL=static-VNN4HYRN.js.map
250
+ //# sourceMappingURL=static-C7PWUTQO.js.map
@@ -2,7 +2,7 @@
2
2
  import "tsx/esm";
3
3
  import {
4
4
  nodeAdapter
5
- } from "./chunk-G3DDIEYE.js";
5
+ } from "./chunk-MQCXYZEV.js";
6
6
  import {
7
7
  prepareTheoCloudArtifacts,
8
8
  readManifest
@@ -37,4 +37,4 @@ export {
37
37
  buildTheoCloud,
38
38
  theoCloudAdapter
39
39
  };
40
- //# sourceMappingURL=theo-cloud-243SPOIA.js.map
40
+ //# sourceMappingURL=theo-cloud-NKZUJO3H.js.map
@@ -12,20 +12,22 @@ import {
12
12
  } from "./chunk-IJQQNHL7.js";
13
13
  import {
14
14
  deployedEntryPreamble
15
- } from "./chunk-XLFDYTWO.js";
15
+ } from "./chunk-N7KDDYDB.js";
16
16
  import {
17
17
  JSON_NOT_FOUND_RESPONSE,
18
18
  deployedAgentsFragment,
19
19
  deployedRateLimitFragment,
20
+ deployedReservedRoutesFragment,
20
21
  deployedRuntimeConfigFragment,
21
22
  deployedTraceFragment,
22
23
  describeDeployedSecurityHeaders,
23
24
  rateLimitCheckFragment,
25
+ reservedRouteBranch,
24
26
  serverDirLiteral
25
- } from "./chunk-EQJF2EH5.js";
27
+ } from "./chunk-DDWF3UUI.js";
26
28
  import {
27
29
  nodeAdapter
28
- } from "./chunk-G3DDIEYE.js";
30
+ } from "./chunk-MQCXYZEV.js";
29
31
  import "./chunk-3PWQQWT6.js";
30
32
  import {
31
33
  buildSecurityHeaders
@@ -158,6 +160,7 @@ function vercelRouteRequestFragment(runtimeSpread, agentsBranch, agentsHostBypas
158
160
  return [
159
161
  `async function routeRequest(nodeReq) {`,
160
162
  ` const url = new URL(nodeReq.url ?? '/', 'http://' + (nodeReq.headers?.host ?? 'localhost'))`,
163
+ ...reservedRouteBranch("url.pathname", " "),
161
164
  ``,
162
165
  // B-317 — emitted only when this function does NOT render the document. With a document branch
163
166
  // every path is legitimate: `/api/*` is a route and everything else is a page, so refusing
@@ -274,7 +277,13 @@ import { executeRoute, extractTraceIdFromRequest, TRACE_HEADER, createCorsWebHan
274
277
  `// theo.config.ts to read. config.json routes only /api/* here, so this`,
275
278
  `// covers the API and not the document Vercel's static host serves`,
276
279
  `// (usetheokit/theokit#412).`,
277
- ...deployedEntryPreamble(runtimeConfig, agentsFragment, opts, "vercel"),
280
+ ...deployedEntryPreamble(
281
+ runtimeConfig,
282
+ agentsFragment,
283
+ opts,
284
+ "vercel",
285
+ deployedReservedRoutesFragment(opts)
286
+ ),
278
287
  ``,
279
288
  `// Vercel Functions invoke this default export with a (req, res) pair`,
280
289
  `// (Node IncomingMessage-style). \`routeRequest\` produces a Web Response for`,
@@ -300,6 +309,9 @@ function renderVercelConfigJson(securityHeaders, opts = {}) {
300
309
  continue: true
301
310
  },
302
311
  { src: "/api/(.*)", dest: "/api" },
312
+ // #1097 — the reserved routes the function answers. No file matches them, so without this
313
+ // rule they reached the last route below and were answered with the document.
314
+ { src: "/__theo/(health|ready)", dest: "/api" },
303
315
  { handle: "filesystem" },
304
316
  // B-317 — where a path with no matching file goes. `{ handle: 'filesystem' }` above still
305
317
  // serves every real file, so this is reached only by a page request: to the function when the
@@ -374,6 +386,8 @@ async function buildVercel(config, cwd, deps = {}, ctx) {
374
386
  csrf: config.security?.csrf,
375
387
  disallowed: config.security?.disallowed,
376
388
  cors: config.security?.cors,
389
+ // #1097 — a probe cannot ride as a literal; the entry fails `/__theo/ready` closed instead.
390
+ readyProbeDeclared: config.ready !== void 0,
377
391
  // #425 — a selector, not a transformer, so it rides as a literal like the values above.
378
392
  serialization: config.serialization
379
393
  }),
@@ -437,4 +451,4 @@ export {
437
451
  shouldCopyIntoStatic,
438
452
  vercelAdapter
439
453
  };
440
- //# sourceMappingURL=vercel-EXKSZ2OQ.js.map
454
+ //# sourceMappingURL=vercel-MRZXLOIQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/adapters/vercel.ts"],"sourcesContent":["/* eslint-disable security/detect-non-literal-fs-filename --\n * Vercel deploy adapter. All paths derived from `cwd` and a fixed\n * `.theokit/vercel/` output layout. Build-time tool — no HTTP input.\n */\nimport { existsSync, mkdirSync, writeFileSync, cpSync } from 'node:fs'\nimport { basename, resolve } from 'node:path'\n\nimport type { TheoConfig } from '../config/schema.js'\nimport type { SecurityHeadersConfig } from '../core/contracts/security-headers.js'\nimport { assertServicesUnsupported, readManifest } from '../services/index.js'\n\nimport {\n bundleDeployedFunction,\n type BundleDeployedFunctionOptions,\n} from './bundle-deployed-function.js'\nimport { deployedAgentsFragment, JSON_NOT_FOUND_RESPONSE } from './deployed-agents.js'\nimport { renderBakedRoutes, routeRuntimeLines, type BakedRoute } from './deployed-baked-routes.js'\nimport { readDocumentShell } from './deployed-document-shell.js'\nimport { deployedEntryPreamble } from './deployed-preamble.js'\nimport {\n deployedRateLimitFragment,\n rateLimitCheckFragment,\n type DeployedRateLimitOptions,\n} from './deployed-rate-limit.js'\nimport { deployedReservedRoutesFragment, reservedRouteBranch } from './deployed-reserved-routes.js'\nimport { deployedRuntimeConfigFragment, serverDirLiteral } from './deployed-runtime-config.js'\nimport { deployedTraceFragment } from './deployed-trace.js'\nimport { nodeAdapter } from './node.js'\nimport { buildSecurityHeaders, describeDeployedSecurityHeaders } from './security-headers.js'\nimport type { AdapterBuildContext, DeployAdapter, DeployedEntryOptions } from './types.js'\n\n/**\n * T2.2 — Vercel adapter rewritten to consume `theokit/adapters/web-shim`\n * instead of emitting an inline plain-object Request/Response shim and\n * lazy-importing internal `theo-server/` paths.\n */\n\n// Generated-code fragments — extracted so the parent emitter stays under the\n// max-lines-per-function ceiling.\n/** The exported function Vercel invokes: one security-header call, then the drain. */\nfunction vercelHandlerFragment(\n /** B-027 — passed, not read: this is a separate function from the parent emitter. */\n rateLimit: DeployedRateLimitOptions['rateLimit'],\n): string[] {\n return [\n // B-027 — only when a limit is declared. `createRateLimiterWeb` is used at module scope by\n // the fragment; `resolveClientIpFromRequest` reads the forwarded headers behind `trustProxy`.\n ...(rateLimit === undefined\n ? []\n : [\n `import { createRateLimiterWeb } from 'theokit/server/rate-limit'`,\n `import { resolveClientIpFromRequest } from 'theokit/server/rate-limit'`,\n ]),\n ...deployedRateLimitFragment(\n rateLimit,\n 'vercel',\n // The handler builds a real Web `Request` at the top — `corsRequest` — so the exported Web\n // resolver applies directly and nothing new has to parse a header. The plan expected a Node\n // sibling here on the ground that this handler \"has no Web Request\"; reading the emitted code\n // refuted that. With no `trustProxy` declared the resolver returns `undefined`, which is the\n // named 503: on this platform the socket address is always the platform's proxy, so a\n // fallback to it would be one shared bucket wearing a client's clothes.\n `resolveClientIpFromRequest(corsRequest, TRUST_PROXY)`,\n 'corsRequest',\n ),\n ...(rateLimit === undefined\n ? []\n : [\n ``,\n `/**`,\n ` * Write a small, known response and finish.`,\n ` *`,\n ` * Not the drain below: that one exists to stream an arbitrary route response chunk by`,\n ` * chunk, honouring backpressure. A 429 or a 503 is a short JSON literal, so reusing the`,\n ` * streaming path would buy nothing and duplicating it would be worse.`,\n ` */`,\n `async function sendSmall(res, response) {`,\n ` const h = {}`,\n ` response.headers.forEach((v, k) => { h[k] = v })`,\n ` res.writeHead(response.status, h)`,\n ` res.end(await response.text())`,\n `}`,\n ]),\n ``,\n `export default async function handler(nodeReq, nodeRes) {`,\n ` // #409 — CORS reads only the method and the \\`origin\\` / \\`access-control-request-method\\``,\n ` // headers, so this carries exactly those and no body. It is deliberately NOT the routing`,\n ` // Request: that one drains the request stream, and only after a route matched — building it`,\n ` // here would drain the body of every static path too.`,\n ` const corsHeaders = new Headers()`,\n ` for (const [k, v] of Object.entries(nodeReq.headers ?? {})) {`,\n ` if (typeof v === 'string') corsHeaders.set(k, v)`,\n ` }`,\n ` const corsRequest = new Request(`,\n ` new URL(nodeReq.url ?? '/', 'http://' + (nodeReq.headers?.host ?? 'localhost')),`,\n ` { method: (nodeReq.method ?? 'GET').toUpperCase(), headers: corsHeaders },`,\n ` )`,\n ``,\n ` // The preflight is answered BEFORE anything routes: an OPTIONS the router handles is an`,\n ` // OPTIONS the browser never gets a CORS answer to.`,\n ` const preflight = corsPreflight(corsRequest)`,\n ...rateLimitCheckFragment(\n rateLimit,\n ' ',\n 'corsRequest',\n // This handler returns NOTHING — it drains into `nodeRes`. A bare `return <Response>` would\n // answer the caller with nothing at all.\n 'return sendSmall(nodeRes, withCors(corsRequest, withSecurityHeaders(rateLimited(limit), SECURITY_HEADERS)))',\n 'return sendSmall(nodeRes, withCors(corsRequest, withSecurityHeaders(unnamedCaller(), SECURITY_HEADERS)))',\n ),\n ` const webResponse = preflight !== null`,\n ` ? withSecurityHeaders(preflight, SECURITY_HEADERS)`,\n ` : withCors(corsRequest, withSecurityHeaders(await routeRequest(nodeReq), SECURITY_HEADERS))`,\n ``,\n ` // \\`outHeaders\\`, not \\`headers\\`: this used to live in the same scope as the`,\n ` // request-side \\`const headers\\` below, which made the whole module a`,\n ` // SyntaxError — every Vercel build between #382 and #411 emitted a function`,\n ` // that could not be loaded.`,\n ` const outHeaders = {}`,\n ` webResponse.headers.forEach((v, k) => { outHeaders[k] = v })`,\n ` nodeRes.writeHead(webResponse.status, outHeaders)`,\n ` if (typeof nodeRes.flushHeaders === 'function') nodeRes.flushHeaders()`,\n ``,\n ` // #382 — this used to materialize the entire body as a string and hand`,\n ` // it to a single end(), which re-buffered the whole response inside the`,\n ` // function even after the shim was fixed. Drain chunk by chunk instead,`,\n ` // honouring Node backpressure so a slow client cannot grow the queue.`,\n ` if (webResponse.body === null) {`,\n ` nodeRes.end()`,\n ` return`,\n ` }`,\n ` const reader = webResponse.body.getReader()`,\n ` try {`,\n ` for (;;) {`,\n ` const { done, value } = await reader.read()`,\n ` if (done) break`,\n ` if (nodeRes.write(value) === false) {`,\n ` await new Promise((resolveDrain) => {`,\n ` const finish = () => {`,\n ` nodeRes.off('drain', finish)`,\n ` nodeRes.off('close', finish)`,\n ` nodeRes.off('error', finish)`,\n ` resolveDrain()`,\n ` }`,\n ` nodeRes.once('drain', finish)`,\n ` nodeRes.once('close', finish)`,\n ` nodeRes.once('error', finish)`,\n ` })`,\n ` }`,\n ` }`,\n ` nodeRes.end()`,\n ` } catch (streamErr) {`,\n ` // The handler failed after the head went out. Destroying the socket is`,\n ` // the only signal left that the body is incomplete — ending normally`,\n ` // would report a truncated response as a complete one (ADR-0002).`,\n ` nodeRes.destroy(streamErr)`,\n ` } finally {`,\n ` reader.releaseLock()`,\n ` }`,\n `}`,\n ``,\n ]\n}\n\n// Generated-code fragments — extracted so the parent emitter stays under the\n// max-lines-per-function ceiling.\n/** Everything that decides WHAT the response is, as a Web Response for every outcome. */\nfunction vercelRouteRequestFragment(\n runtimeSpread: string,\n agentsBranch: readonly string[],\n agentsHostBypass: string,\n /**\n * The document shell, when this function renders one (B-317).\n *\n * Its PRESENCE is the signal rather than a separate boolean: a shell with no renderer and a\n * renderer with no shell are both states this cannot be in, and a flag beside the data would\n * allow them.\n */\n document?: { htmlHead?: string; htmlTail?: string },\n): string[] {\n return [\n `async function routeRequest(nodeReq) {`,\n ` const url = new URL(nodeReq.url ?? '/', 'http://' + (nodeReq.headers?.host ?? 'localhost'))`,\n ...reservedRouteBranch('url.pathname', ' '),\n ``,\n // B-317 — emitted only when this function does NOT render the document. With a document branch\n // every path is legitimate: `/api/*` is a route and everything else is a page, so refusing\n // non-`/api` paths here would make that branch unreachable — which is exactly what it did, and\n // the first version of the fix shipped it: the branch was present, asserted present, and never\n // entered. `/` answered this 9-byte `Not Found` instead of a document.\n ...(document === undefined\n ? [\n ` if (!url.pathname.startsWith('/api/')${agentsHostBypass}) {`,\n ` return new Response('Not Found', {`,\n ` status: 404,`,\n ` headers: { 'content-type': 'text/plain; charset=utf-8' },`,\n ` })`,\n ` }`,\n ]\n : []),\n ``,\n ``,\n // B-235 — the Node-to-Web conversion is hoisted ABOVE the agents branch, which names\n // `request` like every other host's, and an agent path never reaches a route match. The\n // rename from `webRequest` is what lets this target share the one fragment instead of a\n // fourth near-copy of it.\n //\n // The body is therefore drained before `matchRoute` rather than after, so an unmatched POST\n // now has its body read. That is a real change and the safer direction: an unconsumed Node\n // request socket is what keeps a connection open, and the drain already happened for every\n // request that matched.\n ` // Convert Node-style req to a Web Request — for the agents branch and for the shim`,\n ` const headers = new Headers()`,\n ` for (const [k, v] of Object.entries(nodeReq.headers ?? {})) {`,\n ` if (typeof v === 'string') headers.set(k, v)`,\n ` }`,\n ` let body`,\n ` const method = (nodeReq.method ?? 'GET').toUpperCase()`,\n ` if (method !== 'GET' && method !== 'HEAD') {`,\n ` const chunks = []`,\n ` await new Promise((resolveProm, rejectProm) => {`,\n ` nodeReq.on('data', (c) => chunks.push(c))`,\n ` nodeReq.on('end', () => resolveProm())`,\n ` nodeReq.on('error', rejectProm)`,\n ` })`,\n ` body = Buffer.concat(chunks)`,\n ` }`,\n ` const request = new Request(url.toString(), { method, headers, body })`,\n ``,\n ...agentsBranch,\n ``,\n ` const match = matchRoute(url.pathname, routes)`,\n ...(document !== undefined\n ? [\n ` if (!match) {`,\n ` // B-317 — a path with no matching file arrives here because config.json routes it to this`,\n ` // function. Before this branch it answered a JSON 404, so the config sent every page to the`,\n ` // static shell instead and an SSR project was served an empty \\`<div id=\"root\">\\` while the`,\n ` // build announced SSR.`,\n ` //`,\n ` // Only OUTSIDE \\`/api/\\`: a path under it that matches no route is a routing miss and owes a`,\n ` // JSON 404, not a document. Rendering one there would answer a fetch with HTML.`,\n ` if (!url.pathname.startsWith('/api/')) {`,\n ` const nonce = generateNonce()`,\n ` return withSecurityHeaders(`,\n ` await renderStreamingWeb(request, {`,\n ` htmlHead: ${JSON.stringify(document.htmlHead ?? '')},`,\n ` htmlTail: ${JSON.stringify(document.htmlTail ?? '')},`,\n ` nonce,`,\n ` }),`,\n ` buildSecurityHeaders(SECURITY_HEADERS_CONFIG, { production: true }, { nonce }),`,\n ` )`,\n ` }`,\n ` return ${JSON_NOT_FOUND_RESPONSE}`,\n ` }`,\n ]\n : [` if (!match) return ${JSON_NOT_FOUND_RESPONSE}`]),\n ``,\n ` const { req, res, toResponse } = createWebShim(request)`,\n ...deployedTraceFragment('request', ' '),\n ` // #382 — executeRoute() is NOT awaited before the Response is taken:`,\n ` // toResponse() settles at the headers and carries a live body.`,\n ` return toResponse(executeRoute({`,\n ` route: match.route, method, params: match.params,`,\n ` req, res, loadModule, serverDir, requestId, ...CSRF_CONFIG, ${runtimeSpread}`,\n ` }))`,\n `}`,\n ]\n}\n\nexport function renderVercelFunctionEntry(\n opts: DeployedEntryOptions & {\n /**\n * The routes, scanned on the BUILD machine (B-319).\n *\n * Build Output API v3 uploads a `.func` directory as it is, so the emitted entry's runtime\n * `scanServerRoutes` was a `readdirSync` against a directory that is not there — measured on a\n * deployed function: every `/api/*` answered its own JSON 404. Baked here for the reason\n * Cloudflare bakes (#369), through the same emitter, so the two cannot drift.\n */\n routes?: readonly BakedRoute[]\n /** The agents, for the same reason and from the same scan. */\n agents?: readonly { filePath: string; agentPath: string; name: string }[]\n /**\n * Whether this function renders the DOCUMENT as well as the routes (B-317).\n *\n * `renderVercelConfigJson` sends a path with no matching file here when it is on, and Vercel's\n * `{ handle: 'filesystem' }` has already served every real file — so the branch below needs no\n * asset fallthrough, unlike the Cloudflare worker's, which owns `/` and therefore also receives\n * `/robots.txt`.\n */\n ssr?: boolean\n /** The document up to `<div id=\"root\">`, read from the built client shell. */\n htmlHead?: string\n /** The document from `<div id=\"root\">` on. */\n htmlTail?: string\n /** The app's identity module, when it has one. */\n contextModule?: string\n } = {},\n): string {\n const runtimeConfig = deployedRuntimeConfigFragment(opts)\n const { routeImports, routeModuleEntries, routeTableEntries } = renderBakedRoutes(\n opts.routes ?? [],\n )\n // B-235. This is the target the item's evidence was right about in form and wrong about in\n // consequence: the handler IS Node-shaped, and it already converts to a Web `Request` before\n // handing anything to the shim. Threading `nodeReq` through twelve sites says how the entry\n // RECEIVES a request, not whether it can produce the one this branch needs.\n // B-319 — ALWAYS baked, with no scan fallback. This platform uploads only what the build\n // bundled, so `scanAgents` cannot work here at any value: there is no source tree to read. A\n // fallback would preserve a behaviour that is broken by construction — an entry that scans, finds\n // nothing, and answers 404 while looking like it tried. With nothing baked the agents fragment is\n // empty, `/api/agents/<name>` falls through to the route matcher, and the 404 is honest.\n const agentsFragment = deployedAgentsFragment(\n { kind: 'baked', agents: opts.agents ?? [], contextModule: opts.contextModule },\n { notFound: JSON_NOT_FOUND_RESPONSE },\n )\n return [\n `// Generated by Theo — Vercel Functions adapter`,\n `// Environment variables are resolved at RUNTIME, not build time.`,\n ``,\n `import { resolve } from 'node:path'`,\n `import { matchRoute, compilePattern } from 'theokit/server/scan'\\nimport { executeRoute, extractTraceIdFromRequest, TRACE_HEADER, createCorsWebHandler } from 'theokit/server/http'`,\n ...routeImports,\n `import { createWebShim } from 'theokit/adapters/web-shim'`,\n opts.ssr === true\n ? `import { buildSecurityHeaders, generateNonce, withSecurityHeaders } from 'theokit/adapters/security-headers'`\n : `import { buildSecurityHeaders, withSecurityHeaders } from 'theokit/adapters/security-headers'`,\n ...(opts.ssr === true\n ? [`import { renderStreamingWeb } from '../server/entry-server.js'`]\n : []),\n ``,\n ...routeRuntimeLines(routeModuleEntries, routeTableEntries, 'vercel'),\n // B-318 / B-319 — `const cwd` used to be declared here, because the agents fragment emitted\n // `scanAgents(cwd, …)` and this was the one of its four callers that never declared the name.\n // B-319 then removed the scan entirely from this target — there is no source tree to read on a\n // platform that uploads only its bundle — so the declaration became dead code. The pairing is\n // still enforced for the three adapters that DO scan, by\n // `tests/unit/a-generated-entry-declares-every-name-it-uses.test.ts`.\n `const serverDir = resolve(process.cwd(), ${serverDirLiteral(opts)})`,\n ``,\n `// #410 — the security baseline \\`theokit start\\` puts on every response,`,\n `// carried here as a literal because the deployed function has no`,\n `// theo.config.ts to read. config.json routes only /api/* here, so this`,\n `// covers the API and not the document Vercel's static host serves`,\n `// (usetheokit/theokit#412).`,\n ...deployedEntryPreamble(\n runtimeConfig,\n agentsFragment,\n opts,\n 'vercel',\n deployedReservedRoutesFragment(opts),\n ),\n ``,\n `// Vercel Functions invoke this default export with a (req, res) pair`,\n `// (Node IncomingMessage-style). \\`routeRequest\\` produces a Web Response for`,\n `// every outcome — including the two 404s — so the security baseline is`,\n `// applied at ONE place and no branch can be added that skips it.`,\n ...vercelHandlerFragment(opts.rateLimit),\n ``,\n ...vercelRouteRequestFragment(\n runtimeConfig.executeRouteSpread,\n agentsFragment.branch,\n agentsFragment.hostBypass,\n opts.ssr === true ? { htmlHead: opts.htmlHead, htmlTail: opts.htmlTail } : undefined,\n ),\n ].join('\\n')\n}\n\nexport interface VercelRoutingRule {\n src?: string\n dest?: string\n handle?: string\n /** Build Output API v3 — response headers this rule adds. */\n headers?: Record<string, string>\n /**\n * Keep routing after this rule matches.\n *\n * Load-bearing for the header rule: without it a matching rule TERMINATES routing in Build\n * Output v3, so every request would receive the headers and no content.\n */\n continue?: boolean\n}\n\n/**\n * The routing table, plus the security baseline for the responses this build does NOT serve.\n *\n * The emitted function applies the baseline to every response IT returns — and it never returns the\n * HTML document: `{ handle: 'filesystem' }` hands the page to Vercel's static host, so the JSON was\n * protected and the page it renders in was not (usetheokit/theokit#412).\n *\n * The values come from `buildSecurityHeaders`, the same function the handler calls, rather than\n * being written out here. Two lists of headers that must agree are two lists that eventually do\n * not.\n *\n * Order matters twice: the header rule sits FIRST, because a rule after `handle: 'filesystem'`\n * never runs for a static file, and it carries `continue: true`, because a matching rule otherwise\n * ends routing and the request would get headers with no body.\n *\n * What this does NOT prove: that a deployed page carries them. That needs a deployment, and this\n * repository deploys to no Vercel project from CI. The emitted configuration is verifiable; the\n * platform honouring it is not, and the difference is stated rather than glossed.\n */\nexport function renderVercelConfigJson(\n securityHeaders?: SecurityHeadersConfig,\n opts: {\n /**\n * Whether a path with no matching file reaches the function instead of the static shell.\n *\n * A SECOND parameter rather than a field on the first, and the reason is a trap: the first is\n * `SecurityHeadersConfig`, which is all-optional, so `renderVercelConfigJson({ ssr: true })`\n * compiles, passes the flag as a headers object and does nothing. A bag in the position of another\n * all-optional bag is accepted by the type system and ignored by the code (B-317).\n */\n ssr?: boolean\n } = {},\n): {\n version: number\n routes: VercelRoutingRule[]\n} {\n return {\n version: 3,\n routes: [\n {\n src: '/(.*)',\n headers: buildSecurityHeaders(securityHeaders ?? {}, { production: true }),\n continue: true,\n },\n { src: '/api/(.*)', dest: '/api' },\n // #1097 — the reserved routes the function answers. No file matches them, so without this\n // rule they reached the last route below and were answered with the document.\n { src: '/__theo/(health|ready)', dest: '/api' },\n { handle: 'filesystem' },\n // B-317 — where a path with no matching file goes. `{ handle: 'filesystem' }` above still\n // serves every real file, so this is reached only by a page request: to the function when the\n // project renders one, and to the static shell when it does not. It sent every page to the shell\n // regardless, so an SSR project was served an empty `<div id=\"root\">` while the build announced\n // SSR.\n { src: '/(.*)', dest: opts.ssr === true ? '/api' : '/index.html' },\n ],\n }\n}\n\nexport function renderVercelVcConfigJson(): {\n runtime: string\n handler: string\n launcherType: string\n shouldAddHelpers: boolean\n supportsResponseStreaming: boolean\n} {\n return {\n runtime: 'nodejs22.x',\n handler: 'index.mjs',\n launcherType: 'Nodejs',\n shouldAddHelpers: true,\n // #382 — Build Output API v3 opt-in. Without it the platform buffers the\n // function's response no matter how the handler writes it, so the emitted\n // chunk-by-chunk drain above would never reach the client. We cannot\n // verify the platform side from here; see the streaming note in\n // `adapters/web-shim.ts` and the adapter's `streamsResponses` flag.\n supportsResponseStreaming: true,\n }\n}\n\n/**\n * Whether a file from the client build belongs in `.vercel/output/static`.\n *\n * With `ssr: true` the shell does NOT, and the reason is the routing layer rather than the file:\n * Vercel's `{ handle: 'filesystem' }` satisfies a directory path with the `index.html` inside it, so\n * `/` is a REAL FILE whenever the build copied one — and the SSR route below the handler is never\n * reached. Measured on the first real deploy of this adapter, 2026-09-29: `GET /` answered 200 with\n * 694 bytes and `<div id=\"root\">` carrying zero, while the build announced `(SSR)`.\n *\n * B-317 already made the last route point at the function when `ssr` is on, and its comment states\n * the premise that made that sufficient — *\"`{ handle: 'filesystem' }` above still serves every real\n * file, so this is reached only by a page request\"*. That premise is false for a path the platform\n * resolves to an `index.html`. This closes the half B-317 could not see without a deployment.\n *\n * **The basename is the mechanism, not a heuristic.** It is what the platform uses to satisfy a\n * directory path, so it is what shadows a page route, at any depth. `foo.html` is served at the\n * explicit `/foo.html`, which no page route claims, and dropping it would take a document the\n * project meant to publish.\n *\n * Directories always pass: `cpSync`'s filter is asked about them too, and refusing one prunes the\n * whole subtree — refusing `assets/` would turn one empty page into a site with no stylesheet.\n */\nexport function shouldCopyIntoStatic(source: string, ssr: boolean): boolean {\n if (!ssr) return true\n return basename(source) !== 'index.html'\n}\n\nexport interface VercelBuildDeps {\n runNodeBuild?: (config: TheoConfig, cwd: string, ctx?: AdapterBuildContext) => Promise<void>\n bundleFunction?: (options: BundleDeployedFunctionOptions) => Promise<void>\n}\n\n/**\n * The Vercel build, as a function with a dependency seam — the shape `buildNetlify` and\n * `buildAwsLambda` already have.\n *\n * It was inline on the adapter object until B-346, and nothing could drive it: measured, NO test\n * ran it to completion, so `buildVercel` carried zero coverage while a defect shipped inside it and\n * reached a live deployment. The seam is what lets a test assert the wiring — that the copy is\n * handed the filter that withholds the shell — without a client bundle.\n */\n/**\n * The injectable seam's defaults, in one place.\n *\n * The same shape `resolveNetlifyDeps` and `resolveAwsLambdaDeps` already have, and here for the same\n * reason plus one measured one: the two `??` defaults lived inside `buildVercel`, which put it at a\n * complexity of 16 against a maximum of 15. The body was unchanged from the method it was extracted\n * from — 14 — so the seam that made the copy testable is what crossed the line. Moving the defaults\n * out is the convention this file was not following, not a contortion to satisfy the counter.\n */\nfunction resolveVercelDeps(deps: VercelBuildDeps): {\n runNodeBuild: NonNullable<VercelBuildDeps['runNodeBuild']>\n bundleFunction: NonNullable<VercelBuildDeps['bundleFunction']>\n} {\n return {\n runNodeBuild: deps.runNodeBuild ?? nodeAdapter.build.bind(nodeAdapter),\n bundleFunction: deps.bundleFunction ?? bundleDeployedFunction,\n }\n}\n\nexport async function buildVercel(\n config: TheoConfig,\n cwd: string,\n deps: VercelBuildDeps = {},\n ctx?: AdapterBuildContext,\n): Promise<void> {\n const { runNodeBuild, bundleFunction } = resolveVercelDeps(deps)\n\n // Wave 2 (T2.2) — reject polyglot services on this adapter.\n // Per 2026-05-27 owner decision, polyglot is wired via `node` (local\n // docker-compose harness) + `theo-cloud` (Wave 3). Vercel adapter\n // wire-up is deferred to a fresh ADR with demand evidence.\n assertServicesUnsupported('vercel', readManifest(cwd))\n\n // 1. Run the standard Node build first (ctx forwarded so nodeAdapter has makeVitePlugins)\n await runNodeBuild(config, cwd, ctx)\n\n const clientDir = resolve(cwd, '.theokit/client')\n const outputDir = resolve(cwd, '.vercel/output')\n\n // 2. Create .vercel/output structure\n mkdirSync(resolve(outputDir, 'static'), { recursive: true })\n mkdirSync(resolve(outputDir, 'functions/api.func'), { recursive: true })\n\n // 3. Copy static assets\n if (existsSync(clientDir)) {\n // B-346 — the shell is withheld when this project renders its own document. See\n // `shouldCopyIntoStatic`: shipping it makes `/` a real file, and the SSR route never runs.\n cpSync(clientDir, resolve(outputDir, 'static'), {\n recursive: true,\n filter: (source) => shouldCopyIntoStatic(source, config.ssr),\n })\n }\n\n // B-319 — the routes, agents and identity module are resolved HERE, on the build machine, for\n // the reason #369 gives for Cloudflare: Build Output API v3 uploads the `.func` directory as it\n // is, so a runtime `scanServerRoutes` reads a directory that is not there. Measured on a\n // deployed function — every `/api/*` answered its own JSON 404 with the route files present in\n // the project. An absent provider bakes nothing and the entry falls back to the scan, which is\n // what it did before.\n const scanned = ctx?.scanRoutes?.(config.serverDir)\n\n // 4. Emit the serverless function, BUNDLED.\n //\n // B-316 / ADR 0020 — Build Output API v3 uploads a `.func` directory as it is: nothing installs\n // dependencies for it and nothing bundles it. Writing the rendered entry straight out produced a\n // function that could not start, measured on this repository's own scaffold:\n //\n // cp -a .vercel/output/functions/api.func/. /tmp/fn/ && cd /tmp/fn\n // node -e \"import('./index.mjs')\"\n // -> ERR_MODULE_NOT_FOUND: Cannot find package 'theokit'\n //\n // The staged entry goes inside the project root because a specifier resolves relative to the\n // importing file — an entry in `/tmp` makes rollup resolve `theokit/server/scan` from `/tmp`.\n await bundleFunction({\n projectRoot: cwd,\n entrySource: renderVercelFunctionEntry({\n // B-317 — the three options the renderer honoured and no build passed, which is the shape\n // B-185, B-235, B-312 and B-315 each fixed one target at a time. The shell is read here\n // rather than in the renderer because reading a file is the build's job, not a string\n // emitter's.\n ssr: config.ssr,\n ...readDocumentShell(cwd, config.ssr),\n routes: scanned?.routes,\n agents: scanned?.agents,\n contextModule: scanned?.contextModule,\n securityHeaders: config.security?.headers,\n // B-315 — the option existed, the renderer honoured it, and this build never passed\n // it, so a project declaring `src/server` got a deployed entry resolving `server`.\n // The fourth occurrence of that exact shape: B-185 (bun, deno), B-235 (`agentsDir`\n // here), B-312 (the build's agents scan). Measured on the emitted Vercel function.\n serverDir: config.serverDir,\n // B-235 — pillar (a): the option existed and no build passed it, so a project with a\n // configured agents directory got the default `agents` on this target. Same defect\n // B-185 fixed for bun and deno, one target over.\n agentsDir: config.agentsDir,\n csrf: config.security?.csrf,\n disallowed: config.security?.disallowed,\n cors: config.security?.cors,\n // #1097 — a probe cannot ride as a literal; the entry fails `/__theo/ready` closed instead.\n readyProbeDeclared: config.ready !== undefined,\n // #425 — a selector, not a transformer, so it rides as a literal like the values above.\n serialization: config.serialization,\n }),\n stagePath: '.theokit/vercel/entry.mjs',\n outDir: resolve(outputDir, 'functions/api.func'),\n entryFileName: 'index.mjs',\n })\n\n // 5. Emit .vc-config.json\n writeFileSync(\n resolve(outputDir, 'functions/api.func/.vc-config.json'),\n JSON.stringify(renderVercelVcConfigJson(), null, 2),\n )\n\n // 6. Emit config.json (routing)\n writeFileSync(\n resolve(outputDir, 'config.json'),\n JSON.stringify(renderVercelConfigJson(config.security?.headers, { ssr: config.ssr }), null, 2),\n )\n\n // eslint-disable-next-line no-console -- CLI build progress\n console.log('\\n ✓ Vercel output → .vercel/output/')\n // eslint-disable-next-line no-console -- CLI build progress\n console.log(\n `${describeDeployedSecurityHeaders({\n target: 'vercel',\n securityHeaders: config.security?.headers,\n // Derived, and it was a literal `false` for the hours between B-317 shipping and B-334. The\n // function B-317 emits calls `generateNonce()` and feeds the value to both `renderStreamingWeb`\n // and `buildSecurityHeaders`, so the deployment DID mint one while the build told the operator\n // it did not — and the printed advice was to move inline scripts out to work around a\n // restriction that was no longer there.\n mintsNonce: config.ssr,\n documentHeaders: 'platform-configured',\n })}\\n`,\n )\n}\n\nexport const vercelAdapter: DeployAdapter = {\n // B-316 / B-319 — Build Output API v3 uploads the `.func` directory as it is: nothing\n // installs and nothing bundles. Driven 2026-09-29 from a directory with no `node_modules`:\n // 200 with the trace header and the CSP (`records/acceptance/evidence/b263-vercel-function-driven-locally.txt`).\n readsSourceAtRunTime: false,\n specifiersResolvedBy: 'this-adapter',\n name: 'vercel',\n streamsResponses: true,\n // #409 / #410 — the generated entry calls `executeRoute` with routes, loader\n // and serverDir only. CSRF, route policy, file middleware and Zod validation\n // still run because they live inside `executeRoute`; none of the remaining\n // configurable concerns reach it. Declared explicitly rather than omitted so\n // the gap is a statement in the source and not an absence.\n //\n // `securityHeaders` IS applied -- to every response this function returns.\n // The document is served from `.vercel/output/static` and does not pass\n // through it (usetheokit/theokit#412).\n appliesConfig: ['securityHeaders', 'csrf', 'disallowed', 'cors', 'serialization'],\n // B-257 — per-invocation: an in-process counter does not survive, so a declared limit needs a durable store.\n enforcesRateLimit: 'with-a-store',\n\n async build(config: TheoConfig, cwd: string, ctx?: AdapterBuildContext): Promise<void> {\n return buildVercel(config, cwd, {}, ctx)\n },\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,SAAS,YAAY,WAAW,eAAe,cAAc;AAC7D,SAAS,UAAU,eAAe;AAmClC,SAAS,sBAEP,WACU;AACV,SAAO;AAAA;AAAA;AAAA,IAGL,GAAI,cAAc,SACd,CAAC,IACD;AAAA,MACE;AAAA,MACA;AAAA,IACF;AAAA,IACJ,GAAG;AAAA,MACD;AAAA,MACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAOA;AAAA,MACA;AAAA,IACF;AAAA,IACA,GAAI,cAAc,SACd,CAAC,IACD;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,MACD;AAAA,MACA;AAAA,MACA;AAAA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AC;AAAA,IACD,WAAW;AAAA,IACX,QAAQ,QAAQ,WAAW,oBAAoB;AAAA,IAC/C,eAAe;AAAA,EACjB,CAAC;AAGD;AAAA,IACE,QAAQ,WAAW,oCAAoC;AAAA,IACvD,KAAK,UAAU,yBAAyB,GAAG,MAAM,CAAC;AAAA,EACpD;AAGA;AAAA,IACE,QAAQ,WAAW,aAAa;AAAA,IAChC,KAAK,UAAU,uBAAuB,OAAO,UAAU,SAAS,EAAE,KAAK,OAAO,IAAI,CAAC,GAAG,MAAM,CAAC;AAAA,EAC/F;AAGA,UAAQ,IAAI,iDAAuC;AAEnD,UAAQ;AAAA,IACN,GAAG,gCAAgC;AAAA,MACjC,QAAQ;AAAA,MACR,iBAAiB,OAAO,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAMlC,YAAY,OAAO;AAAA,MACnB,iBAAiB;AAAA,IACnB,CAAC,CAAC;AAAA;AAAA,EACJ;AACF;AAEO,IAAM,gBAA+B;AAAA;AAAA;AAAA;AAAA,EAI1C,sBAAsB;AAAA,EACtB,sBAAsB;AAAA,EACtB,MAAM;AAAA,EACN,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUlB,eAAe,CAAC,mBAAmB,QAAQ,cAAc,QAAQ,eAAe;AAAA;AAAA,EAEhF,mBAAmB;AAAA,EAEnB,MAAM,MAAM,QAAoB,KAAa,KAA0C;AACrF,WAAO,YAAY,QAAQ,KAAK,CAAC,GAAG,GAAG;AAAA,EACzC;AACF;","names":[]}
@@ -6,10 +6,10 @@ import {
6
6
  defineTheoIntegration,
7
7
  theoPlugin,
8
8
  theoPluginAsync
9
- } from "../chunk-ESSUFQ3H.js";
9
+ } from "../chunk-IBZITTK7.js";
10
10
  import "../chunk-7NRFZBAL.js";
11
11
  import "../chunk-SSYDEKWF.js";
12
- import "../chunk-N5YHENWJ.js";
12
+ import "../chunk-SHBPXX5E.js";
13
13
  import "../chunk-7MCEJVGV.js";
14
14
  import "../chunk-4XZOUS5G.js";
15
15
  import "../chunk-OIGJOYX6.js";
@@ -17,7 +17,7 @@ import "../chunk-U3SPBLJF.js";
17
17
  import "../chunk-WSOAN4KN.js";
18
18
  import "../chunk-ENSFCKP6.js";
19
19
  import "../chunk-OGLS76RN.js";
20
- import "../chunk-KQBY62AE.js";
20
+ import "../chunk-HWRZUQPE.js";
21
21
  import "../chunk-36ZACTF3.js";
22
22
  import "../chunk-P6OS7652.js";
23
23
  import "../chunk-ZDUO4IYN.js";
@@ -34,9 +34,9 @@ import "../chunk-7HGZ3CKL.js";
34
34
  import "../chunk-A6UFN6QQ.js";
35
35
  import "../chunk-DV34VG3N.js";
36
36
  import "../chunk-V6Y2SMRG.js";
37
- import "../chunk-TRCJHFAX.js";
38
37
  import "../chunk-ACKBVBUI.js";
39
38
  import "../chunk-IZ3TIL6K.js";
39
+ import "../chunk-TRCJHFAX.js";
40
40
  import "../chunk-TQEE36VD.js";
41
41
  import "../chunk-54BIQFP4.js";
42
42
  import "../chunk-ZICY2CD7.js";
@@ -8,12 +8,12 @@ import {
8
8
  defineTheoIntegration,
9
9
  theoPlugin,
10
10
  theoPluginAsync
11
- } from "./chunk-7IPWHWYV.js";
12
- import "./chunk-HZAXFD55.js";
11
+ } from "./chunk-YM6ONZYE.js";
12
+ import "./chunk-VSK5Y4ET.js";
13
13
  import "./chunk-BDH5GKFZ.js";
14
14
  import "./chunk-3PWQQWT6.js";
15
15
  import "./chunk-FDOOBTXJ.js";
16
- import "./chunk-E22GPCCO.js";
16
+ import "./chunk-MSSUMKFR.js";
17
17
  import "./chunk-4JRXZTVQ.js";
18
18
  import "./chunk-FNJVSFEC.js";
19
19
  import "./chunk-WSMLSIS5.js";
@@ -43,4 +43,4 @@ export {
43
43
  theoPlugin,
44
44
  theoPluginAsync
45
45
  };
46
- //# sourceMappingURL=vite-plugin-LDZJRFKT.js.map
46
+ //# sourceMappingURL=vite-plugin-JMWUVMP3.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "theokit",
3
- "version": "0.77.2",
3
+ "version": "0.77.4",
4
4
  "description": "The TheoKit web framework — file-based routing, typed server surfaces, the Vite plugin, the CLI and the deploy adapters, around agents served from agents/*.ts.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -151,8 +151,8 @@
151
151
  "typescript": "^5.9.3",
152
152
  "vite": "^7.3.7",
153
153
  "@theokit/agents": "^16.1.1",
154
- "@theokit/presenter": "^0.10.0",
155
- "@theokit/http": "^2.3.1"
154
+ "@theokit/http": "^2.3.1",
155
+ "@theokit/presenter": "^0.10.0"
156
156
  },
157
157
  "peerDependencies": {
158
158
  "@theokit/sdk": "^5.11.0",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/adapters/aws-lambda.ts"],"sourcesContent":["/* eslint-disable security/detect-non-literal-fs-filename --\n * AWS Lambda adapter. Writes to `cwd/.theokit/lambda/`. Build-time tool.\n */\nimport { mkdirSync } from 'node:fs'\nimport { resolve } from 'node:path'\n\nimport type { TheoConfig } from '../config/schema.js'\nimport { assertServicesUnsupported, readManifest } from '../services/index.js'\n\nimport {\n bundleDeployedFunction,\n type BundleDeployedFunctionOptions,\n} from './bundle-deployed-function.js'\nimport { deployedAgentsFragment, JSON_NOT_FOUND_RESPONSE } from './deployed-agents.js'\nimport { renderBakedRoutes, routeRuntimeLines, type BakedRoute } from './deployed-baked-routes.js'\nimport { deployedEntryPreamble } from './deployed-preamble.js'\nimport {\n deployedRateLimitFragment,\n rateLimitCheckFragment,\n type DeployedRateLimitOptions,\n} from './deployed-rate-limit.js'\nimport { deployedRuntimeConfigFragment, serverDirLiteral } from './deployed-runtime-config.js'\nimport { deployedTraceFragment } from './deployed-trace.js'\nimport { nodeAdapter } from './node.js'\nimport { describeDeployedSecurityHeaders } from './security-headers.js'\nimport type { AdapterBuildContext, DeployAdapter, DeployedEntryOptions } from './types.js'\n\nexport interface AwsLambdaBuildDeps {\n runNodeBuild?: (config: TheoConfig, cwd: string, ctx?: AdapterBuildContext) => Promise<void>\n /**\n * Seam for the bundling step, alongside `runNodeBuild`.\n *\n * The entry imports five `theokit/…` sub-paths by bare specifier, and nothing resolves them for\n * an uploaded Lambda: measured 2026-09-29, copying the written handler to a directory with no\n * `node_modules` gave `ERR_MODULE_NOT_FOUND: Cannot find package 'theokit'`. ADR 0020 names this\n * target as needing the same call Vercel got.\n */\n bundleFunction?: (options: BundleDeployedFunctionOptions) => Promise<void>\n /**\n * RETIRED by B-344, kept out rather than left accepting a value nothing reads.\n *\n * The handler is bundled now, so there is no raw write for a caller to intercept. A dep a build\n * accepts and ignores is the same defect as a renderer option it accepts and ignores — see the\n * `agentsDir` note in `netlify.ts`. Nothing in this repository stubbed it.\n */\n ensureDir?: (path: string) => void\n}\n\nexport interface RequestShape {\n method: string\n path: string\n headers: Record<string, string>\n body?: string\n}\n\nexport interface LambdaResultV2 {\n statusCode: number\n headers: Record<string, string>\n body: string\n isBase64Encoded: boolean\n}\n\nconst BINARY_CONTENT_TYPES = [\n 'application/octet-stream',\n 'application/pdf',\n 'application/zip',\n 'image/',\n 'audio/',\n 'video/',\n]\n\nfunction isBinaryContentType(contentType: string | undefined): boolean {\n if (!contentType) return false\n const ct = contentType.toLowerCase()\n return BINARY_CONTENT_TYPES.some((prefix) => ct.startsWith(prefix))\n}\n\ninterface APIGatewayProxyEventV2 {\n version: string\n requestContext: {\n http: { method: string; path: string }\n }\n headers?: Record<string, string | undefined>\n body?: string\n isBase64Encoded?: boolean\n}\n\nexport function eventV2ToRequestShape(event: APIGatewayProxyEventV2): RequestShape {\n const headers: Record<string, string> = {}\n for (const [k, v] of Object.entries(event.headers ?? {})) {\n if (v !== undefined) headers[k] = v\n }\n let body: string | undefined = event.body\n if (body !== undefined && event.isBase64Encoded) {\n body = Buffer.from(body, 'base64').toString('utf-8')\n }\n return {\n method: event.requestContext.http.method,\n path: event.requestContext.http.path,\n headers,\n body,\n }\n}\n\nexport function responseToLambdaResultV2(\n statusCode: number,\n headers: Record<string, string>,\n body: string,\n): LambdaResultV2 {\n const isBinary = isBinaryContentType(headers['content-type'])\n return {\n statusCode,\n headers,\n body: isBinary ? Buffer.from(body, 'binary').toString('base64') : body,\n isBase64Encoded: isBinary,\n }\n}\n\n// Generated-code fragments — extracted so the parent emitter stays under the\n// max-lines-per-function ceiling.\n/** The v2 result conversion, the handler, and the routing that feeds them. */\n/** The target's name, in the five places that spell it — same gate deno-deploy tripped. */\n/* The name in the places a gate does NOT read. `assertServicesUnsupported` keeps the literal:\n * `services-other-adapters-reject.test.ts:30` requires each adapter to name ITSELF there, so a\n * copy-paste carrying another adapter's name cannot hide behind a constant. */\nconst TARGET = 'aws-lambda'\n\nfunction awsLambdaHandlerFragment(\n runtimeSpread: string,\n agentsBranch: readonly string[],\n agentsHostBypass: string,\n /** B-027 — passed, not read: this is a separate function from the parent emitter. */\n rateLimit: DeployedRateLimitOptions['rateLimit'],\n): string[] {\n return [\n `// #382 — this target is DELISTED for response streaming, by construction.`,\n `// The Lambda v2 result object below carries \\`body\\` as a string, so the`,\n `// response cannot exist until the run has finished, no matter how the`,\n `// framework's shim writes it. Streaming here would require`,\n `// \\`awslambda.streamifyResponse\\` plus a Function URL in RESPONSE_STREAM`,\n `// invoke mode — neither of which this adapter emits, and which would break`,\n `// every API Gateway deployment of it. Rather than degrade in silence, a`,\n `// response that is unambiguously a stream is named in the logs below.`,\n `async function responseToV2Result(response, routePath) {`,\n ` const headers = {}`,\n ` response.headers.forEach((v, k) => { headers[k] = v })`,\n ` const ct = headers['content-type'] ?? ''`,\n ` if (ct.includes('text/event-stream')) {`,\n ` console.warn(`,\n ` '[theo][aws-lambda] ' + routePath + ' returned a streaming response (' + ct + '), ' +`,\n ` 'but the aws-lambda target buffers it whole and delivers it when the run ends. ' +`,\n ` 'This target is delisted for streaming (theokit#382). Deploy streaming routes to ' +`,\n ` 'cloudflare, vercel, netlify, bun, deno-deploy or node.'`,\n ` )`,\n ` }`,\n ` const isBinary = /^application\\\\/(octet-stream|pdf|zip)|^(image|audio|video)\\\\//.test(ct)`,\n ` if (isBinary) {`,\n ` const buf = Buffer.from(await response.arrayBuffer())`,\n ` return {`,\n ` statusCode: response.status,`,\n ` headers,`,\n ` body: buf.toString('base64'),`,\n ` isBase64Encoded: true,`,\n ` }`,\n ` }`,\n ` return {`,\n ` statusCode: response.status,`,\n ` headers,`,\n ` body: await response.text(),`,\n ` isBase64Encoded: false,`,\n ` }`,\n `}`,\n ``,\n `// Every outcome — including both 404s — is produced as a Web Response by`,\n `// routeRequest, so the security baseline is applied at ONE place and the`,\n `// v2 result object is built from headers that already carry it.`,\n ...(rateLimit === undefined\n ? []\n : [\n `import { createRateLimiterWeb } from 'theokit/server/rate-limit'`,\n `import { resolveClientIpFromRequest } from 'theokit/server/rate-limit'`,\n ``,\n ]),\n ...deployedRateLimitFragment(\n rateLimit,\n TARGET,\n // The v2 payload's own answer, with the v1 `identity.sourceIp` beside it: a v1 event carries\n // no `http` object at all, and both reads are optional-chained so neither throws on the\n // other's shape. Same treatment `:153` already gives `requestContext?.http?.path`.\n `event.requestContext?.http?.sourceIp ?? event.requestContext?.identity?.sourceIp ?? resolveClientIpFromRequest(corsRequest, TRUST_PROXY)`,\n // `corsRequest`, not `request`: the Web request this entry builds is named that (`:157`).\n 'corsRequest, event',\n ),\n ``,\n `export const handler = async (event) => {`,\n ` const path = event.requestContext?.http?.path ?? '/'`,\n ` // #409 — the same event, read as a Web Request so the CORS matcher can see the method and`,\n ` // the \\`origin\\` header. \\`eventV2ToRequest\\` reads a body already present in the event, so`,\n ` // unlike the Node targets there is no stream to drain twice.`,\n ` const corsRequest = eventV2ToRequest(event)`,\n ``,\n ` // The preflight is answered BEFORE anything routes: an OPTIONS the router handles is an`,\n ` // OPTIONS the browser never gets a CORS answer to.`,\n ` const preflight = corsPreflight(corsRequest)`,\n ...rateLimitCheckFragment(\n rateLimit,\n ' ',\n 'corsRequest, event',\n // This handler returns a Lambda v2 RESULT, not a Response. A bare `return <Response>` would\n // hand the runtime an object it does not understand.\n 'return responseToV2Result(withCors(corsRequest, withSecurityHeaders(rateLimited(limit), SECURITY_HEADERS)), path)',\n 'return responseToV2Result(withCors(corsRequest, withSecurityHeaders(unnamedCaller(), SECURITY_HEADERS)), path)',\n ),\n ` const response = preflight !== null`,\n ` ? withSecurityHeaders(preflight, SECURITY_HEADERS)`,\n ` : withCors(corsRequest, withSecurityHeaders(await routeRequest(event, path), SECURITY_HEADERS))`,\n ` return responseToV2Result(response, path)`,\n `}`,\n ``,\n `async function routeRequest(event, path) {`,\n ` if (!path.startsWith('/api/')${agentsHostBypass}) {`,\n ` return new Response(`,\n ` 'Static assets must be served from CloudFront or a separate static host.',`,\n ` { status: 404, headers: { 'content-type': 'text/plain' } },`,\n ` )`,\n ` }`,\n ``,\n ``,\n // B-235 — hoisted above the agents branch, which names `request` like every other host's.\n // It was declared below `matchRoute`, and an agent path never reaches a route match. Building\n // it here costs nothing new: the outer handler already built one for the CORS matcher, and\n // `eventV2ToRequest` reads a body the event already carries, so there is no stream to drain\n // twice.\n ` const request = eventV2ToRequest(event)`,\n ``,\n ...agentsBranch,\n ``,\n ` const match = matchRoute(path, routes)`,\n ` if (!match) return ${JSON_NOT_FOUND_RESPONSE}`,\n ``,\n ` const { req, res, toResponse } = createWebShim(request)`,\n ...deployedTraceFragment('request', ' '),\n ` const method = request.method.toUpperCase()`,\n ` return toResponse(executeRoute({ route: match.route, method, params: match.params, req, res, loadModule, serverDir, requestId, ...CSRF_CONFIG, ${runtimeSpread} }))`,\n `}`,\n ]\n}\n\nexport function renderAwsLambdaEntry(\n opts: DeployedEntryOptions & {\n /**\n * The routes, baked at build time (B-344).\n *\n * The entry used to resolve them with a runtime `scanServerRoutes` — a `readdirSync` over\n * `serverDir`. An uploaded Lambda has no source tree, so every `/api/*` answered its own JSON 404:\n * measured 2026-09-29 by bundling this entry, copying it to a directory with no `node_modules`,\n * importing it and invoking it with a synthetic API Gateway v2 event. Where a tree IS uploaded the\n * route files are TypeScript, which a plain Node runtime cannot compile — the `SyntaxError`\n * Netlify answered with before B-338. The fix #369 made for Cloudflare, B-319 for Vercel and B-338\n * for Netlify, on the fifth target, through the same emitter so the five cannot drift.\n */\n routes?: readonly BakedRoute[]\n /** The agents, for the same reason and from the same scan. */\n agents?: readonly { filePath: string; agentPath: string; name: string }[]\n contextModule?: string\n } = {},\n): string {\n const runtimeConfig = deployedRuntimeConfigFragment(opts)\n const { routeImports, routeModuleEntries, routeTableEntries } = renderBakedRoutes(\n opts.routes ?? [],\n )\n // B-235. The entry already builds a Web `Request` — `eventV2ToRequest(event)`, for the CORS\n // matcher — so the shape this branch needs was here all along. `path` rather than `url.pathname`\n // because that is the name this host reads the route from.\n // B-344 — baked, for the reason the routes are: an uploaded function has no source tree, so a\n // runtime `scanAgents` finds nothing and `createProductionLoader()` would import a path that was\n // never shipped. Vercel's own note says it best — a fallback \"would preserve a behaviour that is\n // broken by construction: an entry that scans, finds nothing, and answers 404 while looking like it\n // tried.\"\n const agentsFragment = deployedAgentsFragment(\n { kind: 'baked', agents: opts.agents ?? [], contextModule: opts.contextModule },\n {\n pathname: 'path',\n // This entry has no `url` object: `eventV2ToRequest` builds a STRING, in another function.\n // `request` is what routeRequest holds, and it carries the same absolute URL that string was.\n baseUrl: 'new URL(request.url).origin',\n notFound: JSON_NOT_FOUND_RESPONSE,\n },\n )\n return [\n `// Generated by Theo — AWS Lambda Adapter`,\n `// Use with API Gateway HTTP API v2 (default).`,\n ``,\n `import { resolve } from 'node:path'`,\n `import { matchRoute, compilePattern } from 'theokit/server/scan'\\nimport { executeRoute, extractTraceIdFromRequest, TRACE_HEADER, createCorsWebHandler } from 'theokit/server/http'`,\n ...routeImports,\n `import { createWebShim } from 'theokit/adapters/web-shim'`,\n `import { buildSecurityHeaders, withSecurityHeaders } from 'theokit/adapters/security-headers'`,\n ``,\n `const cwd = process.cwd()`,\n `const serverDir = resolve(cwd, ${serverDirLiteral(opts)})`,\n ...routeRuntimeLines(routeModuleEntries, routeTableEntries, TARGET),\n ``,\n `// #410 — the security baseline \\`theokit start\\` puts on every response,`,\n `// carried here as a literal because the deployed function has no`,\n `// theo.config.ts to read. Non-API paths 404 here and the document is served`,\n `// from CloudFront or another static host, so this covers the API and not the`,\n `// page (usetheokit/theokit#412).`,\n ...deployedEntryPreamble(runtimeConfig, agentsFragment, opts, 'aws-lambda'),\n ``,\n `function eventV2ToRequest(event) {`,\n ` const method = event.requestContext?.http?.method ?? 'GET'`,\n ` const path = event.requestContext?.http?.path ?? '/'`,\n ` const host = event.headers?.host ?? 'lambda'`,\n ` const qs = event.rawQueryString ? '?' + event.rawQueryString : ''`,\n ` const url = 'https://' + host + path + qs`,\n ` const headers = new Headers()`,\n ` for (const [k, v] of Object.entries(event.headers ?? {})) {`,\n ` if (v !== undefined) headers.set(k, String(v))`,\n ` }`,\n ` let body = event.body`,\n ` if (body && event.isBase64Encoded) {`,\n ` body = Buffer.from(body, 'base64')`,\n ` }`,\n ` return new Request(url, {`,\n ` method,`,\n ` headers,`,\n ` body: method === 'GET' || method === 'HEAD' ? undefined : body,`,\n ` })`,\n `}`,\n ``,\n ...awsLambdaHandlerFragment(\n runtimeConfig.executeRouteSpread,\n agentsFragment.branch,\n agentsFragment.hostBypass,\n opts.rateLimit,\n ),\n ].join('\\n')\n}\n\n/**\n * Resolve the build's effective dependencies once.\n *\n * Extracted when `buildAwsLambda` crossed the complexity ceiling after B-344 added the bundling\n * seam. The defaults are a separate concern from the build's sequence (SRP), and the sequence is\n * the part a reader comes here to follow. Same extraction as `resolveNetlifyDeps`.\n */\nfunction resolveAwsLambdaDeps(deps: AwsLambdaBuildDeps): {\n runNodeBuild: NonNullable<AwsLambdaBuildDeps['runNodeBuild']>\n bundleFunction: NonNullable<AwsLambdaBuildDeps['bundleFunction']>\n ensureDir: NonNullable<AwsLambdaBuildDeps['ensureDir']>\n} {\n return {\n runNodeBuild: deps.runNodeBuild ?? nodeAdapter.build.bind(nodeAdapter),\n bundleFunction: deps.bundleFunction ?? bundleDeployedFunction,\n ensureDir: deps.ensureDir ?? ((path: string) => mkdirSync(path, { recursive: true })),\n }\n}\n\nexport async function buildAwsLambda(\n config: TheoConfig,\n cwd: string,\n deps: AwsLambdaBuildDeps = {},\n ctx?: AdapterBuildContext,\n): Promise<void> {\n const { runNodeBuild, bundleFunction, ensureDir } = resolveAwsLambdaDeps(deps)\n // Wave 2 (T2.2) — reject polyglot services on this adapter.\n assertServicesUnsupported('aws-lambda', readManifest(cwd))\n\n // #382 — refuse by name rather than build something that cannot do what was\n // asked. `ssrStreaming` is the config's declaration that responses stream,\n // and this target is delisted for that (see `awsLambdaAdapter.streamsResponses`).\n // Kept as a guard for a DIRECT call to this function, which bypasses the CLI. The normal path is\n // refused earlier, before anything is emptied — see `assertStreamingSupported` (B-336). One message,\n // declared in one place, so the two cannot drift apart.\n if (config.ssrStreaming) {\n const { assertStreamingSupported } = await import('./config-support.js')\n assertStreamingSupported(config, awsLambdaAdapter, 'aws-lambda')\n }\n\n await runNodeBuild(config, cwd, ctx)\n\n const outputDir = resolve(cwd, '.theokit/aws')\n ensureDir(outputDir)\n\n // B-344 — scanned on the BUILD machine, like cloudflare, vercel and netlify. An absent scanner\n // emits an entry with NO routes rather than falling back to a runtime scan: that fallback is what\n // answered 404 from a bundle with no source tree.\n const scanned = ctx?.scanRoutes?.(config.serverDir)\n\n const entry = renderAwsLambdaEntry({\n routes: scanned?.routes,\n agents: scanned?.agents,\n contextModule: scanned?.contextModule,\n securityHeaders: config.security?.headers,\n // B-315 — the same shape as the B-235 note below, one option over: this build never passed\n // `serverDir`, so a project declaring `src/server` got an entry resolving `server`.\n serverDir: config.serverDir,\n // B-235 — pillar (a): the option existed and no build passed it, so a project with a\n // configured agents directory got the default `agents` on this target. Same defect\n // B-185 fixed for bun and deno, one target over.\n agentsDir: config.agentsDir,\n csrf: config.security?.csrf,\n disallowed: config.security?.disallowed,\n cors: config.security?.cors,\n // #425 — a selector, not a transformer, so it rides as a literal like the values above.\n serialization: config.serialization,\n })\n // B-344 — bundled, not written as source. Unlike netlify the output goes into the directory\n // itself rather than a subdirectory: Lambda's handler is `<file>.<export>` and the operator zips\n // the directory, so the bundler's chunks travel without a per-function folder. Netlify needed one\n // because its platform treats each file in the functions directory as a separate function.\n await bundleFunction({\n projectRoot: cwd,\n entrySource: entry,\n stagePath: '.theokit/aws/handler.entry.mjs',\n outDir: outputDir,\n entryFileName: 'handler.mjs',\n })\n\n // eslint-disable-next-line no-console -- CLI build progress\n console.log('\\n ✓ AWS Lambda output → .theokit/aws/handler.mjs')\n // eslint-disable-next-line no-console -- CLI build progress\n console.log(\n `${describeDeployedSecurityHeaders({\n target: TARGET,\n securityHeaders: config.security?.headers,\n mintsNonce: false,\n documentHeaders: 'platform-unmanaged',\n })}\\n`,\n )\n}\n\nexport const awsLambdaAdapter: DeployAdapter = {\n // B-342 / B-344 — measured by INVOKING the handler from a directory with no `node_modules`:\n // `ERR_MODULE_NOT_FOUND: Cannot find package 'theokit'` as source, then 404 once bundled but\n // still scanning, then 200 with routes and agents baked.\n readsSourceAtRunTime: false,\n specifiersResolvedBy: 'this-adapter',\n name: TARGET,\n // #382 — delisted for streaming, deliberately. See DeployAdapter.\n streamsResponses: false,\n streamingUnsupportedDetail:\n 'The Lambda v2 result object carries the body as a string, so nothing can leave the function ' +\n 'before the run ends. Response streaming would need awslambda.streamifyResponse plus a Function ' +\n 'URL in RESPONSE_STREAM invoke mode, which this adapter does not emit.',\n // #409 / #410 — the generated entry calls `executeRoute` with routes, loader\n // and serverDir only. CSRF, route policy, file middleware and Zod validation\n // still run because they live inside `executeRoute`; none of the remaining\n // configurable concerns reach it. Declared explicitly rather than omitted so\n // the gap is a statement in the source and not an absence.\n //\n // `securityHeaders` IS applied -- to every response this function returns.\n // The document comes from CloudFront or another static host and does not pass\n // through it (usetheokit/theokit#412).\n appliesConfig: ['securityHeaders', 'csrf', 'disallowed', 'cors', 'serialization'],\n // B-257 — per-invocation: an in-process counter does not survive, so a declared limit needs a durable store.\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B;AAAA,EAClB,4BACE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYF,eAAe,CAAC,mBAAmB,QAAQ,cAAc,QAAQ,eAAe;AAAA;AAAA,EAEhF,mBAAmB;AAAA,EACnB,MAAM,QAAQ,KAAK,KAAK;AACtB,WAAO,eAAe,QAAQ,KAAK,CAAC,GAAG,GAAG;AAAA,EAC5C;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/adapters/bun.ts"],"sourcesContent":["/* eslint-disable security/detect-non-literal-fs-filename --\n * Bun deploy adapter. Writes to `cwd/.theokit/bun/`. Build-time.\n */\nimport { mkdirSync, writeFileSync } from 'node:fs'\nimport { resolve } from 'node:path'\n\nimport type { TheoConfig } from '../config/schema.js'\nimport type { SecurityHeadersConfig } from '../core/contracts/security-headers.js'\nimport { assertServicesUnsupported, readManifest } from '../services/index.js'\n\nimport { deployedAgentsFragment } from './deployed-agents.js'\nimport { type DeployedCorsOptions } from './deployed-cors.js'\nimport { type DeployedCsrfOptions } from './deployed-csrf.js'\nimport { readDocumentShell } from './deployed-document-shell.js'\nimport { planDeployedPlugins } from './deployed-plugins-module.js'\nimport { deployedEntryPreamble } from './deployed-preamble.js'\nimport {\n deployedRateLimitFragment,\n rateLimitCheckFragment,\n type DeployedRateLimitOptions,\n} from './deployed-rate-limit.js'\nimport {\n deployedRuntimeConfigFragment,\n agentsDirLiteral,\n serverDirLiteral,\n type DeployedRuntimeConfigOptions,\n type DeployedAgentsDirOptions,\n type DeployedServerDirOptions,\n} from './deployed-runtime-config.js'\nimport { deployedTraceFragment } from './deployed-trace.js'\nimport { nodeAdapter } from './node.js'\nimport { describeDeployedSecurityHeaders } from './security-headers.js'\nimport type { AdapterBuildContext, DeployAdapter } from './types.js'\n\nexport interface BunBuildDeps {\n runNodeBuild?: (config: TheoConfig, cwd: string, ctx?: AdapterBuildContext) => Promise<void>\n writeEntry?: (path: string, content: string) => void\n ensureDir?: (path: string) => void\n}\n\n/**\n * How a person starts the emitted entry. Printed by the build and repeated by the dev-mode guard,\n * because the guard is what someone meets after running the path the build printed without\n * `NODE_ENV` (measured 2026-10-02).\n */\nconst BUN_START_COMMAND = 'NODE_ENV=production bun .theokit/bun/server.mjs'\n\n/**\n * The module-scope refusals: this entry is production-only and Bun-only.\n *\n * Extracted from `renderBunEntry` when adding the configured-directory literal pushed it past the\n * per-function line budget. They are a cohesive block — three checks that all refuse to start —\n * and lifting them keeps the budget a signal about the renderer rather than about its preamble.\n */\nconst RUNTIME_GUARDS: readonly string[] = [\n `// EC-1: dev-mode guard`,\n `if (process.env.NODE_ENV !== 'production') {`,\n ` console.error('TheoBunAdapter is production-only: start it with \\\\'${BUN_START_COMMAND}\\\\' from the project root. For development, use \\\\'theokit dev\\\\' (Node).')`,\n ` process.exit(1)`,\n `}`,\n ``,\n `// Version check: Bun >= 1.1`,\n `if (typeof Bun === 'undefined') {`,\n ` console.error('TheoBunAdapter must run inside Bun. Got Node.js or unknown runtime.')`,\n ` process.exit(1)`,\n `}`,\n `{`,\n ` const [maj, min] = (Bun.version ?? '0.0').split('.').map(Number)`,\n ` if (maj < 1 || (maj === 1 && min < 1)) {`,\n ` console.error('TheoBunAdapter requires Bun >= 1.1; got ' + Bun.version)`,\n ` process.exit(1)`,\n ` }`,\n `}`,\n]\n\nexport function renderBunEntry(\n port: number,\n opts: {\n ssrStreaming?: boolean\n /**\n * Whether this build renders the document on the server.\n *\n * Bun is the one Web target whose own handler answers the HTML document, and it answered it from\n * `.theokit/client/index.html` — the client shell. So an `ssr: true` project was served an empty\n * `<div id=\"root\">` while the build printed `(SSR)` (B-334).\n */\n ssr?: boolean\n /** The document up to `<div id=\"root\">`, read from the built client shell. */\n htmlHead?: string\n /** The document from `<div id=\"root\">` on. */\n htmlTail?: string\n securityHeaders?: SecurityHeadersConfig\n } & DeployedAgentsDirOptions &\n DeployedCsrfOptions &\n DeployedRuntimeConfigOptions &\n DeployedServerDirOptions &\n DeployedCorsOptions &\n DeployedRateLimitOptions = {},\n): string {\n // The whole implementation of `ssrStreaming` in this adapter used to be the text of this comment:\n // `opts.ssrStreaming` was read, and its only effect was which string landed on line 4 of the emitted\n // file. `rules/foreign-config-surfaces.md` names that exact failure — \"A surface is read, or it is\n // refused with a reason. It is never accepted and ignored\" — and it was in this adapter.\n const document =\n opts.ssr === true ? { htmlHead: opts.htmlHead, htmlTail: opts.htmlTail } : undefined\n const streamingComment =\n document !== undefined\n ? `// ssr on — the document is rendered by this handler, not read from .theokit/client`\n : `// ssr off — the document is the built client shell, served from disk`\n const runtimeConfig = deployedRuntimeConfigFragment(opts)\n const agentsFragment = deployedAgentsFragment(\n {\n kind: 'scan',\n projectRoot: 'cwd',\n loadModule: 'loadModule',\n serverDir: 'serverDir',\n agentsDirLiteral: agentsDirLiteral(opts),\n },\n {\n pathname: 'pathname',\n // B-185 — bound only when the runtime-config fragment declared the const, which is\n // exactly when a plugins module was emitted. Referencing it otherwise would emit an\n // identifier the entry never declares.\n pluginRunnerExpr:\n opts.runtimeConfigModule === undefined ? undefined : 'await THEO_PLUGIN_RUNNER',\n },\n )\n return [\n `// Generated by Theo — Bun Adapter`,\n `// Run: bun run .theokit/bun/server.mjs`,\n `// Requires Bun >= 1.1`,\n streamingComment,\n ``,\n ...RUNTIME_GUARDS,\n ``,\n `import { resolve, join } from 'node:path'`,\n `import { existsSync } from 'node:fs'`,\n // One element per emitted line, like every neighbour, and the conditional import is a spread\n // rather than an interpolated `\\n`. That is not a style preference: this line carried the\n // fragment inside a nested double-quoted string, where an escaped backslash is a backslash, so\n // the import reached the module joined by two characters and Bun refused it. A construct that\n // cannot express a malformed line beats one escaped correctly (B-325), and `sonarjs` refuses the\n // nesting outright — the lint was naming the cause.\n `import { scanServerRoutes, matchRoute, createProductionLoader } from 'theokit/server/scan'`,\n `import { executeRoute, extractTraceIdFromRequest, TRACE_HEADER, createCorsWebHandler } from 'theokit/server/http'`,\n ...(opts.rateLimit === undefined\n ? []\n : [`import { createRateLimiterWeb } from 'theokit/server/rate-limit'`]),\n `import { createWebShim } from 'theokit/adapters/web-shim'`,\n `import { buildSecurityHeaders, withSecurityHeaders } from 'theokit/adapters/security-headers'`,\n // The renderer the node build already emits for this target and nothing imported. Its own header\n // names Bun: \"Web Standards streaming entry for edge runtimes (Cloudflare, Bun, Deno, Vercel\n // Edge)\". Measured on a real build: `.theokit/server/entry-server.js` is 95513 bytes and exports\n // the render, and `.theokit/bun/server.mjs` referenced it zero times.\n ...(document === undefined\n ? []\n : [`import { renderStreamingWeb } from '../server/entry-server.js'`]),\n `// T3.2 — WS bridge for Bun runtime`,\n `import { createBunWsBridge } from 'theokit/adapters/ws-shim'`,\n `import { scanWebSocketRoutes } from 'theokit/server/scan'`,\n ``,\n `const cwd = process.cwd()`,\n `const clientDir = resolve(cwd, '.theokit/client')`,\n `const serverDir = resolve(cwd, ${serverDirLiteral(opts)})`,\n `const port = process.env.PORT ? Number(process.env.PORT) : ${port}`,\n ``,\n `// #410 — the security baseline \\`theokit start\\` puts on every response,`,\n `// carried here as a literal because the deployed process has no`,\n `// theo.config.ts to read. Bun is the one Web target whose own handler serves`,\n `// the HTML document (static file + SPA fallback below), so the document gets`,\n `// these headers too -- with a nonce-less CSP, because that HTML was written`,\n `// at build time and carries no nonce on its script tags (EC-4).`,\n ...deployedEntryPreamble(runtimeConfig, agentsFragment, opts, 'bun'),\n ``,\n ...deployedRateLimitFragment(opts.rateLimit, 'bun', 'server.requestIP(request)?.address'),\n ``,\n `const routes = existsSync(serverDir) ? scanServerRoutes(serverDir) : []`,\n `const wsRoutes = existsSync(serverDir) ? scanWebSocketRoutes(serverDir) : []`,\n `const loadModule = createProductionLoader()`,\n ``,\n `// Bun WebSocket config — single handler dispatches to first ws route,`,\n `// or a default no-op when none declared. Per-route routing happens above`,\n `// (the upgrade decision is made in fetch handler before Bun.serve hands off).`,\n `const wsBridge = wsRoutes.length > 0`,\n ` ? createBunWsBridge({`,\n ` onOpen: () => {},`,\n ` onMessage: (ws, data) => { ws.send(data) },`,\n ` onClose: () => {},`,\n ` })`,\n ` : { open: () => {}, message: () => {}, close: () => {} }`,\n ``,\n `function notFoundResponse() {`,\n ` return new Response(JSON.stringify({ error: { code: 'NOT_FOUND', message: 'Route not found' } }), {`,\n ` status: 404,`,\n ` headers: { 'Content-Type': 'application/json' },`,\n ` })`,\n `}`,\n ``,\n `Bun.serve({`,\n ` port,`,\n ` websocket: wsBridge,`,\n ` async fetch(request, server) {`,\n ` // #409 — the preflight is answered BEFORE anything routes: an OPTIONS the router`,\n ` // handles is an OPTIONS the browser never gets a CORS answer to.`,\n ` const preflight = corsPreflight(request)`,\n ` if (preflight !== null) return withSecurityHeaders(preflight, SECURITY_HEADERS)`,\n ...rateLimitCheckFragment(opts.rateLimit, ' '),\n ` return withCors(request, withSecurityHeaders(await handleRequest(request), SECURITY_HEADERS))`,\n ` },`,\n `})`,\n ``,\n ...bunHandleRequestFragment(runtimeConfig.executeRouteSpread, agentsFragment.branch, document),\n ].join('\\n')\n}\n\n/**\n * The request handler, as generated source.\n *\n * Extracted for the reason `vercel.ts` extracts its own fragments: the emitter is one array\n * literal, so every line the entry gains counts against `max-lines-per-function`, and #410 added\n * the CSRF literal to an emitter that was already sitting exactly at the ceiling.\n */\nfunction bunHandleRequestFragment(\n runtimeSpread: string,\n agentBranch: readonly string[],\n document: { htmlHead?: string; htmlTail?: string } | undefined,\n): string[] {\n return [\n `async function handleRequest(request) {`,\n ` const url = new URL(request.url)`,\n ` const pathname = url.pathname`,\n ``,\n ` // 1) Static assets`,\n ...(document === undefined\n ? [\n ` const staticPath = pathname === '/' ? '/index.html' : pathname`,\n ` const fullStatic = join(clientDir, staticPath)`,\n ` if (existsSync(fullStatic)) {`,\n ` const file = Bun.file(fullStatic)`,\n ` if (await file.exists()) return new Response(file)`,\n ` }`,\n ]\n : [\n ` // \\`/\\` is deliberately NOT mapped to index.html here: that file is the client shell,`,\n ` // and answering the document from it is what served an empty <div id=\"root\"> on an`,\n ` // ssr build. Real assets still come from disk; the document falls through to (3).`,\n ` if (pathname !== '/') {`,\n ` const fullStatic = join(clientDir, pathname)`,\n ` if (existsSync(fullStatic)) {`,\n ` const file = Bun.file(fullStatic)`,\n ` if (await file.exists()) return new Response(file)`,\n ` }`,\n ` }`,\n ]),\n ``,\n ` // 2) API routes through the full executeRoute pipeline via the shim`,\n ` if (pathname.startsWith('/api/') || __theoIsAgentCardPath(pathname)) {`,\n ...agentBranch,\n ``,\n ` const match = matchRoute(pathname, routes)`,\n ` if (!match) return notFoundResponse()`,\n ` const { req, res, toResponse } = createWebShim(request)`,\n ...deployedTraceFragment('request', ' '),\n ` const method = request.method.toUpperCase()`,\n ` // #382 — not awaited: toResponse() settles at the headers and carries`,\n ` // a live body, so Bun.serve streams while the handler writes.`,\n ` return toResponse(executeRoute({ route: match.route, method, params: match.params, req, res, loadModule, serverDir, requestId, ...CSRF_CONFIG, ${runtimeSpread} }))`,\n ` }`,\n ``,\n ...(document === undefined\n ? [\n ` // 3) SPA fallback`,\n ` const indexPath = join(clientDir, 'index.html')`,\n ` if (existsSync(indexPath)) return new Response(Bun.file(indexPath))`,\n ]\n : [\n ` // 3) The document, rendered here rather than read from disk.`,\n ` //`,\n ` // No nonce is minted: the outer wrapper applies a precomputed SECURITY_HEADERS constant,`,\n ` // so a per-request value would have to be threaded through it. That is a separate change`,\n ` // with its own blast radius, and the shell this replaces carries only external`,\n ` // <script src> tags, which \\`script-src 'self'\\` already allows.`,\n ` return await renderStreamingWeb(request, {`,\n ` htmlHead: ${JSON.stringify(document.htmlHead ?? '')},`,\n ` htmlTail: ${JSON.stringify(document.htmlTail ?? '')},`,\n ` })`,\n ]),\n ``,\n ` return notFoundResponse()`,\n `}`,\n ``,\n `console.log('Theo (Bun) listening on http://localhost:' + port)`,\n ]\n}\n\nexport async function buildBun(\n config: TheoConfig,\n cwd: string,\n deps: BunBuildDeps = {},\n ctx?: AdapterBuildContext,\n): Promise<void> {\n // Wave 2 (T2.2) — reject polyglot services on this adapter.\n assertServicesUnsupported('bun', readManifest(cwd))\n\n const runNodeBuild = deps.runNodeBuild ?? nodeAdapter.build.bind(nodeAdapter)\n await runNodeBuild(config, cwd, ctx)\n\n const outputDir = resolve(cwd, '.theokit/bun')\n const ensureDir = deps.ensureDir ?? ((p: string) => mkdirSync(p, { recursive: true }))\n ensureDir(outputDir)\n\n const pluginsPlan = planDeployedPlugins(config.plugins, 'bun')\n const entry = renderBunEntry(config.port, {\n ssrStreaming: config.ssrStreaming,\n // B-334 — the sixth time this shape has been fixed one target at a time: the renderer honoured an\n // option no build passed (B-185, B-235, B-312, B-315, B-317). Here it was worse — the option only\n // changed a comment. The shell is read HERE rather than in the emitter, because reading a file is\n // the build's job and not a string emitter's.\n ssr: config.ssr,\n ...readDocumentShell(cwd, config.ssr),\n securityHeaders: config.security?.headers,\n csrf: config.security?.csrf,\n disallowed: config.security?.disallowed,\n cors: config.security?.cors,\n // #425 — a selector, not a transformer, so it rides as a literal like the values above.\n serialization: config.serialization,\n // #425 — the ONE concern that is not a literal. A closure cannot be baked, so a plugin\n // declared by module specifier is imported by the emitted module instead; a constructed one\n // is refused by name at build time rather than dropped in silence.\n runtimeConfigModule: pluginsPlan?.moduleSpecifier,\n // #95 — the configured directories, which `build.ts:210` already threads into the Vite\n // plugins. Without these two lines the literals above fall to their defaults and a project\n // with a custom dir deploys an entry that resolves a directory it does not have.\n serverDir: config.serverDir,\n agentsDir: config.agentsDir,\n })\n const write =\n deps.writeEntry ??\n ((p, c) => {\n writeFileSync(p, c)\n })\n if (pluginsPlan !== undefined) {\n // Beside the entry, so the emitted import is a sibling. Written through the same seam as\n // the entry so a test that captures one captures both (#425).\n write(resolve(outputDir, 'theo.plugins.mjs'), pluginsPlan.source)\n }\n write(resolve(outputDir, 'server.mjs'), entry)\n\n // eslint-disable-next-line no-console -- CLI build progress\n console.log('\\n ✓ Bun output → .theokit/bun/server.mjs')\n // eslint-disable-next-line no-console -- CLI build progress\n console.log(` start it with: ${BUN_START_COMMAND}`)\n // eslint-disable-next-line no-console -- CLI build progress\n console.log(\n `${describeDeployedSecurityHeaders({\n target: 'bun',\n securityHeaders: config.security?.headers,\n // Bun renders the document at request time when `ssr` is on (B-334), and still mints no nonce:\n // the outer wrapper applies a precomputed SECURITY_HEADERS constant, so a per-request value\n // would have to be threaded through it.\n //\n // This used to read \"No deploy target other than the streamed Cloudflare worker renders HTML at\n // request time, so none of the rest can mint a nonce.\" True when written, false the moment B-317\n // shipped — a CONSEQUENCE of the fleet at the time, never a prohibition, which is why rendering\n // here is consistent with the intent rather than against it.\n mintsNonce: false,\n // Bun serves `.theokit/client` itself, so the document DOES pass through\n // the handler these headers are attached to.\n documentHeaders: 'handler',\n })}\\n`,\n )\n}\n\nexport const bunAdapter: DeployAdapter = {\n // The entry runs IN the project: it resolves `serverDir` against `cwd`, so `node_modules` is\n // present and the scan has a tree to read. `docs/adr/0020` leaves this target alone for exactly\n // that reason.\n readsSourceAtRunTime: true,\n specifiersResolvedBy: 'the-project-at-run-time',\n name: 'bun',\n streamsResponses: true,\n // #409 / #410 — the generated entry calls `executeRoute` with routes, loader\n // and serverDir only. CSRF, route policy, file middleware and Zod validation\n // still run because they live inside `executeRoute`; none of the remaining\n // configurable concerns reach it. Declared explicitly rather than omitted so\n // the gap is a statement in the source and not an absence.\n //\n // `securityHeaders` IS applied: the entry carries `security.headers` as a\n // literal and puts the built baseline on every response, the served document\n // included.\n servesAgents: true,\n appliesConfig: [\n 'securityHeaders',\n 'csrf',\n 'disallowed',\n 'cors',\n 'serialization',\n 'plugins',\n // #508 — bun is the first Web target to ENFORCE a declared limit rather than refuse the\n // build: `Bun.serve` is long-lived, so the in-process counter survives, and its handler\n // already receives `server`, whose `requestIP` gives the peer address without a header.\n 'rateLimit',\n ],\n // B-257 — a long-lived process: the in-process counter survives between requests.\n enforcesRateLimit: 'always',\n build(config, cwd, ctx) {\n return buildBun(config, cwd, {}, ctx)\n },\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;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