theokit 0.55.0 → 0.57.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/dist/{actions-virtual-module-PREAJNIS.js → actions-virtual-module-GMRXCAVN.js} +21 -21
  2. package/dist/{actions-virtual-module-TZFLCIIR.js → actions-virtual-module-XAWZOWSY.js} +4 -4
  3. package/dist/adapters/agent-mount.d.ts +1 -1
  4. package/dist/adapters/agent-mount.js +9 -9
  5. package/dist/{agent-2AELELAC.js → agent-LS7I3ZQB.js} +3 -3
  6. package/dist/{agents-typed-client-INR2E7B3.js → agents-typed-client-PVUZU65B.js} +3 -3
  7. package/dist/{app-typed-client-NEKRXPAQ.js → app-typed-client-NMKJ4DR7.js} +4 -4
  8. package/dist/{app-typed-client-KSFGMOQ6.js → app-typed-client-W74QO5LH.js} +21 -21
  9. package/dist/boot/index.js +3 -3
  10. package/dist/{build-ESSQS5F5.js → build-FHE72YXR.js} +5 -5
  11. package/dist/{bun-L7PP6ID5.js → bun-POLTY2HK.js} +118 -3
  12. package/dist/bun-POLTY2HK.js.map +1 -0
  13. package/dist/{chunk-5YPXXSYY.js → chunk-35QIWOHT.js} +9 -8
  14. package/dist/chunk-35QIWOHT.js.map +1 -0
  15. package/dist/{chunk-JDN5SAAD.js → chunk-44E7XIZC.js} +6 -6
  16. package/dist/{chunk-OQCRCXCP.js → chunk-4ERYQBL6.js} +2 -2
  17. package/dist/{chunk-52PDWL5S.js → chunk-5KRMDP46.js} +2 -2
  18. package/dist/{chunk-VQPHPQ5L.js → chunk-7NRFZBAL.js} +3 -3
  19. package/dist/{chunk-3PBAN2YE.js → chunk-CF2DNN5R.js} +9 -8
  20. package/dist/{chunk-3PBAN2YE.js.map → chunk-CF2DNN5R.js.map} +1 -1
  21. package/dist/chunk-CLBJTDI6.js +189 -0
  22. package/dist/chunk-CLBJTDI6.js.map +1 -0
  23. package/dist/{chunk-3DRALT3J.js → chunk-CMCEGW3B.js} +6 -6
  24. package/dist/{chunk-3DRALT3J.js.map → chunk-CMCEGW3B.js.map} +1 -1
  25. package/dist/{chunk-MWWFXYW3.js → chunk-CTRVTBGY.js} +3 -3
  26. package/dist/chunk-CTRVTBGY.js.map +1 -0
  27. package/dist/{chunk-HK4AZBKX.js → chunk-D5KBBTVD.js} +7 -7
  28. package/dist/{chunk-DADMEW4G.js → chunk-G5JYB2LO.js} +3 -3
  29. package/dist/{chunk-BU6RJPPJ.js → chunk-GO7UWJ47.js} +2 -2
  30. package/dist/{chunk-BU6RJPPJ.js.map → chunk-GO7UWJ47.js.map} +1 -1
  31. package/dist/{chunk-VZTYCAO6.js → chunk-IDEZ7FU2.js} +3 -3
  32. package/dist/{chunk-ITSNTHWN.js → chunk-JW5UFKQ3.js} +17 -17
  33. package/dist/{chunk-IRASEXOG.js → chunk-KDP2HURW.js} +6 -6
  34. package/dist/{chunk-VRELW5NF.js → chunk-KEDRCI2L.js} +9 -9
  35. package/dist/{chunk-GWE4MUKQ.js → chunk-KQ27YDLG.js} +8 -8
  36. package/dist/{chunk-WX6NHGKS.js → chunk-M357ILK5.js} +10 -10
  37. package/dist/{chunk-2PSKQWGM.js → chunk-NC2OPE22.js} +3 -3
  38. package/dist/{chunk-QZUIF64G.js → chunk-OKDCBENR.js} +4 -4
  39. package/dist/{chunk-ZQO37YQJ.js → chunk-PELXWPDF.js} +5 -5
  40. package/dist/{chunk-2OEN3YTE.js → chunk-PVNMLZ5G.js} +2 -2
  41. package/dist/{chunk-F6P6S5YS.js → chunk-Q6HS3NFG.js} +63 -63
  42. package/dist/{chunk-5K4TDLRG.js → chunk-SOYOYGWY.js} +3 -3
  43. package/dist/{chunk-4X6H2BXP.js → chunk-U3SPBLJF.js} +3 -3
  44. package/dist/{chunk-BX6EUYHU.js → chunk-V6Y2SMRG.js} +3 -3
  45. package/dist/{chunk-I2UN46ZX.js → chunk-XJOU425Y.js} +17 -17
  46. package/dist/{chunk-BND4YZTQ.js → chunk-ZDCCILMP.js} +2 -2
  47. package/dist/cli/index.js +6 -6
  48. package/dist/client/index.js +8 -5
  49. package/dist/client/index.js.map +1 -1
  50. package/dist/{controller-swc-transform-T7ZTD55V.js → controller-swc-transform-7EZKG2IS.js} +2 -2
  51. package/dist/cost-types-BALTuBpG.d.ts +79 -0
  52. package/dist/{dev-MWGPBGQP.js → dev-WDKROZBS.js} +6 -6
  53. package/dist/{dev-emit-W27J3DLU.js → dev-emit-FIQASO3D.js} +7 -7
  54. package/dist/index.js +23 -23
  55. package/dist/{internal-api-XSUP3NDI.js → internal-api-732K3H75.js} +4 -4
  56. package/dist/{internal-api-J3BYA3VU.js → internal-api-EVJSGGO3.js} +26 -26
  57. package/dist/{mcp-6IPY275L.js → mcp-PBUCHHAS.js} +3 -3
  58. package/dist/{preview-KPAKWBRW.js → preview-VFIFKVP4.js} +3 -3
  59. package/dist/{provider-resolver-Dx6QuWrw.d.ts → provider-resolver-VS61zqsw.d.ts} +0 -11
  60. package/dist/{registry-KBZDCFVQ.js → registry-3LUHO4IB.js} +2 -2
  61. package/dist/server/agent/index.d.ts +1 -1
  62. package/dist/server/agent/index.js +3 -3
  63. package/dist/server/cost/index.d.ts +3 -80
  64. package/dist/server/cost/sqlite/index.d.ts +21 -0
  65. package/dist/server/cost/sqlite/index.js +102 -0
  66. package/dist/server/cost/sqlite/index.js.map +1 -0
  67. package/dist/server/cron/index.js +4 -4
  68. package/dist/server/http/index.js +7 -7
  69. package/dist/server/index.d.ts +5 -4
  70. package/dist/server/index.js +79 -79
  71. package/dist/server/jobs/index.d.ts +2 -2
  72. package/dist/server/jobs/index.js +4 -4
  73. package/dist/server/observability/index.js +2 -2
  74. package/dist/server/scan/index.js +6 -6
  75. package/dist/server/storage/index.d.ts +2 -2
  76. package/dist/server/webhook/index.js +1 -1
  77. package/dist/{server-boundary-PGPFBJBH.js → server-boundary-B6U4DRRH.js} +4 -4
  78. package/dist/{server-boundary-7ZO4FZIV.js → server-boundary-QRVK3OIJ.js} +23 -23
  79. package/dist/{server-routes-hmr-BWN3WIGR.js → server-routes-hmr-TNI3FNGM.js} +2 -2
  80. package/dist/{services-typed-client-IXNOPVZA.js → services-typed-client-ACTJHAEP.js} +2 -2
  81. package/dist/{start-F3T2ZPPI.js → start-UAMJ5TSC.js} +6 -6
  82. package/dist/{storage-manager-C6hmsaer.d.ts → storage-manager-BtG38jYl.d.ts} +1 -1
  83. package/dist/{storage-types-DsDTCPbp.d.ts → storage-types-CFGPFIdB.d.ts} +1 -1
  84. package/dist/vite-plugin/index.js +21 -21
  85. package/dist/{vite-plugin-5O3D472R.js → vite-plugin-ABJIDKE6.js} +6 -6
  86. package/package.json +7 -3
  87. package/dist/bun-L7PP6ID5.js.map +0 -1
  88. package/dist/chunk-5YPXXSYY.js.map +0 -1
  89. package/dist/chunk-MWWFXYW3.js.map +0 -1
  90. package/dist/chunk-VSLY4KB3.js +0 -46
  91. package/dist/chunk-VSLY4KB3.js.map +0 -1
  92. /package/dist/{actions-virtual-module-PREAJNIS.js.map → actions-virtual-module-GMRXCAVN.js.map} +0 -0
  93. /package/dist/{actions-virtual-module-TZFLCIIR.js.map → actions-virtual-module-XAWZOWSY.js.map} +0 -0
  94. /package/dist/{agent-2AELELAC.js.map → agent-LS7I3ZQB.js.map} +0 -0
  95. /package/dist/{agents-typed-client-INR2E7B3.js.map → agents-typed-client-PVUZU65B.js.map} +0 -0
  96. /package/dist/{app-typed-client-NEKRXPAQ.js.map → app-typed-client-NMKJ4DR7.js.map} +0 -0
  97. /package/dist/{app-typed-client-KSFGMOQ6.js.map → app-typed-client-W74QO5LH.js.map} +0 -0
  98. /package/dist/{build-ESSQS5F5.js.map → build-FHE72YXR.js.map} +0 -0
  99. /package/dist/{chunk-JDN5SAAD.js.map → chunk-44E7XIZC.js.map} +0 -0
  100. /package/dist/{chunk-OQCRCXCP.js.map → chunk-4ERYQBL6.js.map} +0 -0
  101. /package/dist/{chunk-52PDWL5S.js.map → chunk-5KRMDP46.js.map} +0 -0
  102. /package/dist/{chunk-VQPHPQ5L.js.map → chunk-7NRFZBAL.js.map} +0 -0
  103. /package/dist/{chunk-HK4AZBKX.js.map → chunk-D5KBBTVD.js.map} +0 -0
  104. /package/dist/{chunk-DADMEW4G.js.map → chunk-G5JYB2LO.js.map} +0 -0
  105. /package/dist/{chunk-VZTYCAO6.js.map → chunk-IDEZ7FU2.js.map} +0 -0
  106. /package/dist/{chunk-ITSNTHWN.js.map → chunk-JW5UFKQ3.js.map} +0 -0
  107. /package/dist/{chunk-IRASEXOG.js.map → chunk-KDP2HURW.js.map} +0 -0
  108. /package/dist/{chunk-VRELW5NF.js.map → chunk-KEDRCI2L.js.map} +0 -0
  109. /package/dist/{chunk-GWE4MUKQ.js.map → chunk-KQ27YDLG.js.map} +0 -0
  110. /package/dist/{chunk-WX6NHGKS.js.map → chunk-M357ILK5.js.map} +0 -0
  111. /package/dist/{chunk-2PSKQWGM.js.map → chunk-NC2OPE22.js.map} +0 -0
  112. /package/dist/{chunk-QZUIF64G.js.map → chunk-OKDCBENR.js.map} +0 -0
  113. /package/dist/{chunk-ZQO37YQJ.js.map → chunk-PELXWPDF.js.map} +0 -0
  114. /package/dist/{chunk-2OEN3YTE.js.map → chunk-PVNMLZ5G.js.map} +0 -0
  115. /package/dist/{chunk-F6P6S5YS.js.map → chunk-Q6HS3NFG.js.map} +0 -0
  116. /package/dist/{chunk-5K4TDLRG.js.map → chunk-SOYOYGWY.js.map} +0 -0
  117. /package/dist/{chunk-4X6H2BXP.js.map → chunk-U3SPBLJF.js.map} +0 -0
  118. /package/dist/{chunk-BX6EUYHU.js.map → chunk-V6Y2SMRG.js.map} +0 -0
  119. /package/dist/{chunk-I2UN46ZX.js.map → chunk-XJOU425Y.js.map} +0 -0
  120. /package/dist/{chunk-BND4YZTQ.js.map → chunk-ZDCCILMP.js.map} +0 -0
  121. /package/dist/{controller-swc-transform-T7ZTD55V.js.map → controller-swc-transform-7EZKG2IS.js.map} +0 -0
  122. /package/dist/{dev-MWGPBGQP.js.map → dev-WDKROZBS.js.map} +0 -0
  123. /package/dist/{dev-emit-W27J3DLU.js.map → dev-emit-FIQASO3D.js.map} +0 -0
  124. /package/dist/{internal-api-XSUP3NDI.js.map → internal-api-732K3H75.js.map} +0 -0
  125. /package/dist/{internal-api-J3BYA3VU.js.map → internal-api-EVJSGGO3.js.map} +0 -0
  126. /package/dist/{mcp-6IPY275L.js.map → mcp-PBUCHHAS.js.map} +0 -0
  127. /package/dist/{preview-KPAKWBRW.js.map → preview-VFIFKVP4.js.map} +0 -0
  128. /package/dist/{registry-KBZDCFVQ.js.map → registry-3LUHO4IB.js.map} +0 -0
  129. /package/dist/{server-boundary-PGPFBJBH.js.map → server-boundary-B6U4DRRH.js.map} +0 -0
  130. /package/dist/{server-boundary-7ZO4FZIV.js.map → server-boundary-QRVK3OIJ.js.map} +0 -0
  131. /package/dist/{server-routes-hmr-BWN3WIGR.js.map → server-routes-hmr-TNI3FNGM.js.map} +0 -0
  132. /package/dist/{services-typed-client-IXNOPVZA.js.map → services-typed-client-ACTJHAEP.js.map} +0 -0
  133. /package/dist/{start-F3T2ZPPI.js.map → start-UAMJ5TSC.js.map} +0 -0
  134. /package/dist/{vite-plugin-5O3D472R.js.map → vite-plugin-ABJIDKE6.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/contracts/client-safe-error.ts","../src/server/http/send-response.ts","../src/server/http/node-request.ts","../src/server/http/controller-dispatch.ts","../src/server/security/csrf-warn-dispatch.ts","../src/server/observability/audit-log.ts","../src/server/security/csrf.ts"],"sourcesContent":["import type { TheoErrorEnvelope } from './error-envelope.js'\n\n/**\n * What an error is allowed to tell the caller.\n *\n * Most error codes describe something the caller did and can fix, so their message is the useful\n * part of the response. An *internal* failure is the opposite: its message describes the server —\n * a connection string, an upstream host, a stack of internal names — and the caller can act on\n * none of it. In production it is redacted; in development it is exactly what makes the framework\n * debuggable, so it stays.\n *\n * This lives in one place because it was previously stated in two and missing from a third. The\n * Node runner redacted, the Web error builder redacted, and an exception escaping a Web handler\n * took a hand-built path that did neither — same route, same failure, more disclosure depending\n * on which transport served it. That is the \"one contract, three transports\" rule in\n * `rules/three-target-parity.md` being broken by duplication rather than by design.\n */\n\n/** Both spellings the codebase uses for \"this is our fault, and the detail is ours too\". */\nconst INTERNAL_CODES: ReadonlySet<string> = new Set(['INTERNAL_ERROR', 'INTERNAL_SERVER_ERROR'])\n\nconst GENERIC_INTERNAL_MESSAGE = 'Internal server error'\n\nfunction redacts(code: string): boolean {\n return INTERNAL_CODES.has(code) && process.env.NODE_ENV === 'production'\n}\n\n/** The message this code may carry to the caller. */\nexport function clientSafeErrorMessage(code: string, message: string): string {\n return redacts(code) ? GENERIC_INTERNAL_MESSAGE : message\n}\n\n/**\n * The envelope this code may carry to the caller.\n *\n * When it redacts, `cause`, `meta` and `ext` go with the message rather than being filtered\n * field by field: they exist to describe the failure, and the whole point is that this failure is\n * not describable to the caller. Keeping the code is what lets a client branch on it.\n */\nexport function clientSafeErrorEnvelope(envelope: TheoErrorEnvelope): TheoErrorEnvelope {\n if (!redacts(envelope.code)) return envelope\n return { code: envelope.code, message: GENERIC_INTERNAL_MESSAGE }\n}\n","import type { ServerResponse } from 'node:http'\n\nimport { clientSafeErrorMessage } from '../../core/contracts/client-safe-error.js'\nimport type { TheoTransformer } from '../transformer.js'\n\n/**\n * Canonical HTTP response helpers (T5.1 extraction).\n *\n * Moved out of execute.ts so request-pipeline stages (execute-stages.ts,\n * handle-request-error.ts, etc.) can depend on these helpers without\n * creating a cycle through execute.ts.\n *\n * Public surface re-exported from execute.ts for backward compat — every\n * existing caller of `sendError` / `sendJson` continues to work via the\n * `theokit/server` barrel.\n */\n\nexport function sendJson(\n res: ServerResponse,\n data: unknown,\n status = 200,\n transformer?: TheoTransformer,\n): void {\n // T1.2 — transformer-aware serialization. Default (no transformer) uses\n // JSON.stringify direct for backward compat.\n const body = transformer ? transformer.serialize(data) : JSON.stringify(data)\n res.writeHead(status, {\n 'Content-Type': 'application/json',\n 'Content-Length': Buffer.byteLength(body),\n })\n res.end(body)\n}\n\n/** Render anything that would end the log line as a visible escape, so one call logs one line. */\nfunction oneLine(value: string): string {\n return value.replace(/[\\r\\n]/g, '\\\\n')\n}\n\nexport interface SendErrorOptions {\n custom404Html?: string\n custom500Html?: string\n}\n\n/**\n * Canonical error response.\n *\n * T6.3 (PV-17): the positional 7-param signature is preserved for backward\n * compat. New call sites should use the options-bag form:\n *\n * sendError(res, { code, message, status, issues?, requestId?, options? })\n *\n * Both shapes resolve to the same implementation.\n */\nexport interface SendErrorInput {\n code: string\n message: string\n status: number\n issues?: unknown[]\n requestId?: string\n options?: SendErrorOptions\n}\n\nexport function sendError(res: ServerResponse, input: SendErrorInput): void\n/* eslint-disable-next-line max-params -- T6.3: positional overload preserved\n for backward compat (callers across cli/server still use positional). The\n options-bag overload above is the recommended path. */\nexport function sendError(\n res: ServerResponse,\n code: string,\n message: string,\n status: number,\n issues?: unknown[],\n requestId?: string,\n options?: SendErrorOptions,\n): void\n/* eslint-disable-next-line max-params -- delegates to two surface overloads above; the parameter\n count mirrors the back-compat contract, not internal complexity. The `complexity` half of this\n suppression went away when the redaction rule stopped being restated inline. */\nexport function sendError(\n res: ServerResponse,\n codeOrInput: string | SendErrorInput,\n message?: string,\n status?: number,\n issues?: unknown[],\n requestId?: string,\n options?: SendErrorOptions,\n): void {\n let code: string\n if (typeof codeOrInput === 'string') {\n code = codeOrInput\n message = message ?? ''\n status = status ?? 500\n } else {\n code = codeOrInput.code\n message = codeOrInput.message\n status = codeOrInput.status\n issues = codeOrInput.issues\n requestId = codeOrInput.requestId\n options = codeOrInput.options\n }\n const errorMessage = clientSafeErrorMessage(code, message)\n\n if (code === 'INTERNAL_ERROR') {\n // One log entry per call, whatever the message contains. An exception message can be built\n // from request data and can therefore carry a newline; unescaped, that lets a caller append\n // whatever lines it likes to the log — including a plausible entry attributed to something\n // else (CodeQL `js/log-injection`).\n console.error(`[${oneLine(requestId ?? 'no-id')}] ${oneLine(message)}`)\n }\n\n if (status === 404 && options?.custom404Html) {\n const body = options.custom404Html\n res.writeHead(404, {\n 'Content-Type': 'text/html; charset=utf-8',\n 'Content-Length': Buffer.byteLength(body),\n })\n res.end(body)\n return\n }\n if (status === 500 && options?.custom500Html) {\n const body = options.custom500Html\n res.writeHead(500, {\n 'Content-Type': 'text/html; charset=utf-8',\n 'Content-Length': Buffer.byteLength(body),\n })\n res.end(body)\n return\n }\n\n sendJson(\n res,\n {\n error: {\n code,\n message: errorMessage,\n ...(requestId ? { requestId } : {}),\n ...(issues ? { issues } : {}),\n },\n },\n status,\n )\n}\n\n/**\n * T5a.2 Phase G slice 4/N — Web-Standards response helpers.\n *\n * Mirror of `sendJson` + `sendError` for the Web `Request`/`Response`\n * shape. Returns a native `Response` directly instead of mutating a\n * `ServerResponse`.\n *\n * v1.0 § Phase G.\n *\n * **Difference vs IncomingMessage path:**\n * - No `Content-Length` set explicitly — the runtime computes it from\n * the body when needed. CF Workers / Bun / Deno all do this; setting\n * it manually risks conflict if the body is a stream rather than a\n * fixed string.\n * - Custom 404/500 HTML options preserved (same opts shape).\n * - `requestId` flows into the response body's error envelope AND\n * surfaces as `x-request-id` header (parity with handleWebRequestError\n * Phase G slice 3/N).\n */\nexport function buildJsonResponse(\n data: unknown,\n status = 200,\n transformer?: TheoTransformer,\n): Response {\n const body = transformer ? transformer.serialize(data) : JSON.stringify(data)\n return new Response(body, {\n status,\n headers: { 'content-type': 'application/json' },\n })\n}\n\nexport function buildErrorResponse(input: SendErrorInput): Response {\n const { code, message, status, issues, requestId, options } = input\n const errorMessage = clientSafeErrorMessage(code, message)\n\n if (code === 'INTERNAL_ERROR') {\n // One log entry per call, whatever the message contains. An exception message can be built\n // from request data and can therefore carry a newline; unescaped, that lets a caller append\n // whatever lines it likes to the log — including a plausible entry attributed to something\n // else (CodeQL `js/log-injection`).\n console.error(`[${oneLine(requestId ?? 'no-id')}] ${oneLine(message)}`)\n }\n\n const headers: Record<string, string> = {}\n if (requestId !== undefined) headers['x-request-id'] = requestId\n\n if (status === 404 && options?.custom404Html !== undefined) {\n headers['content-type'] = 'text/html; charset=utf-8'\n return new Response(options.custom404Html, { status: 404, headers })\n }\n if (status === 500 && options?.custom500Html !== undefined) {\n headers['content-type'] = 'text/html; charset=utf-8'\n return new Response(options.custom500Html, { status: 500, headers })\n }\n\n headers['content-type'] = 'application/json'\n const body = JSON.stringify({\n error: {\n code,\n message: errorMessage,\n ...(requestId ? { requestId } : {}),\n ...(issues ? { issues } : {}),\n },\n })\n return new Response(body, { status, headers })\n}\n","/**\n * Pure Node `IncomingMessage` → Web `Request` converters.\n *\n * Kept free of any dependency on `web-handler.js` / `execute*.js` so the\n * executor (`execute.ts`) can build the handler-facing Web `Request` without\n * pulling the Web dispatch pipeline into its import graph (ADR-0028 R3a — the\n * Node adapter is the ONLY place IncomingMessage ↔ Request conversion lives;\n * these are the primitive converters it and the executor share).\n */\nimport type { IncomingMessage } from 'node:http'\nimport { Readable } from 'node:stream'\n\n/** Pick the first usable string from Node's `string | string[] | undefined` headers. */\nfunction pickHeaderString(value: string | string[] | undefined): string | undefined {\n if (typeof value === 'string') return value\n if (Array.isArray(value)) {\n for (const v of value) if (typeof v === 'string' && v.length > 0) return v\n }\n return undefined\n}\n\n/** Web Request requires an absolute URL; synthesize one from the Host header. */\nfunction synthesizeAbsoluteUrl(req: IncomingMessage): string {\n const host = pickHeaderString(req.headers.host) ?? 'localhost'\n return `http://${host}${req.url ?? '/'}`\n}\n\n/**\n * Collapse Node's `string | string[]` headers into a Web `Headers`. Repeated\n * headers are comma-joined (not `.append`ed) because `Headers.append` creates\n * multi-value entries that behave differently on `.get()` (EC-1).\n */\nfunction nodeHeadersToWeb(req: IncomingMessage): Headers {\n const headers = new Headers()\n for (const [key, value] of Object.entries(req.headers)) {\n if (value === undefined) continue\n if (Array.isArray(value)) {\n headers.set(key, value.join(', '))\n } else {\n headers.set(key, value)\n }\n }\n return headers\n}\n\n/**\n * Build a Web `Request` from a Node `IncomingMessage`, body included. The Web\n * Request spec requires an absolute URL; we synthesize one from the Host header\n * (fallback `localhost` for test doubles).\n *\n * For methods with a body (POST/PUT/PATCH/DELETE), the Node Readable stream is\n * wrapped as a Web ReadableStream via `Readable.toWeb()` so downstream consumers\n * can call `request.json()` / `request.formData()` / `request.text()` natively.\n */\nexport function incomingMessageToWebRequest(req: IncomingMessage): Request {\n const url = synthesizeAbsoluteUrl(req)\n const headers = nodeHeadersToWeb(req)\n\n const method = (req.method ?? 'GET').toUpperCase()\n const hasBody = method !== 'GET' && method !== 'HEAD'\n\n if (!hasBody) {\n return new Request(url, { method, headers })\n }\n\n // Drain Node's Readable into a Web ReadableStream. `Readable.toWeb` is\n // available in Node 18+ (theokit's engines.node floor is 22+, so safe).\n const webStream = Readable.toWeb(req) as ReadableStream\n return new Request(url, {\n method,\n headers,\n body: webStream,\n // EC-2: Node 18+ requires `duplex: 'half'` when body is a stream.\n // The `RequestInit` type omits it (Web spec gap); cast accordingly.\n ...({ duplex: 'half' } as { duplex: 'half' }),\n })\n}\n\n/**\n * A Node request that has NOT been converted yet — method now, body only if someone claims it.\n *\n * theokit#400. `incomingMessageToWebRequest` drains the Node stream, and a stream drains once. A\n * dispatcher that converts in order to decide whether it owns a path has already spent the body on\n * every path it does not own: the next branch attaches to a readable that has already ended, waits\n * for an `'end'` that cannot fire twice, and the request hangs with no status at all.\n *\n * The fix is an ordering one, so the type encodes the ordering: a router reads `method` (free) and\n * calls `toRequest()` only after it has decided the request is its own. Passing the source instead\n * of a `Request` is what makes \"did you convert before deciding?\" answerable by reading a signature.\n *\n * `toRequest()` memoizes, because a second conversion of the same `IncomingMessage` yields a\n * Request whose body is an empty closed stream — a silent truncation, which is worse than the hang\n * it would replace.\n */\nexport interface WebRequestSource {\n /** Uppercase HTTP method. Available without touching the body. */\n readonly method: string\n /** Convert on demand. Idempotent: repeated calls return the same `Request`. */\n toRequest: () => Request\n}\n\n/** Wrap `req` as a {@link WebRequestSource} — the conversion is deferred and memoized. */\nexport function createWebRequestSource(req: IncomingMessage): WebRequestSource {\n let converted: Request | undefined\n return {\n method: (req.method ?? 'GET').toUpperCase(),\n toRequest: () => (converted ??= incomingMessageToWebRequest(req)),\n }\n}\n\n/**\n * Build the Web `Request` handed to a route handler as `ctx.request` in the\n * Node server path (dev + `theokit start`). Method + absolute URL + headers\n * only — NO body.\n *\n * Why no body: the Node executor parses the request body BEFORE the handler\n * runs and exposes the parsed value as `ctx.body` (the typed, documented body\n * API). By the time the handler is called the Node stream is already drained,\n * so re-wrapping it would yield an empty/closed stream. Handlers read the body\n * via `ctx.body`; `ctx.request` is for the Web-standard header/cookie/URL/method\n * surface (e.g. `createSessionManagerWeb.getSession(ctx.request)`).\n *\n * Per ADR-0028 R3a, handlers see a Web `Request` in every runtime — this closes\n * the gap where the Node path leaked the raw `IncomingMessage` (whose `.headers`\n * is a plain object, so `.headers.get(...)` threw for Web-standard consumers).\n */\nexport function incomingMessageToHandlerRequest(req: IncomingMessage): Request {\n return new Request(synthesizeAbsoluteUrl(req), {\n method: (req.method ?? 'GET').toUpperCase(),\n headers: nodeHeadersToWeb(req),\n })\n}\n","/* eslint-disable security/detect-non-literal-fs-filename --\n * Controller files are walked from the developer's `serverDir/controllers`\n * (a build-time config path), never from HTTP input. No injection vector.\n */\nimport { readdirSync, type Dirent } from 'node:fs'\nimport type { IncomingMessage, ServerResponse } from 'node:http'\nimport { join } from 'node:path'\n\nimport { createDecoratorHandler, isControllerClass, type ServeAgent } from '@theokit/http'\n\nimport { dispatchCsrfWarn } from '../security/csrf-warn-dispatch.js'\nimport { enforceCsrf, type DisallowedConfig } from '../security/csrf.js'\n\nimport { incomingMessageToWebRequest } from './node-request.js'\nimport { sendError } from './send-response.js'\n\n/** A decorator controller constructor (`@Controller` class). */\ntype ControllerClass = new (...args: never[]) => object\n\n/** Loads a controller module by absolute path. In dev this is Vite's `ssrLoadModule`\n * (the Task 1.1 swc transform has already compiled the parameter decorators); tests\n * inject `@theokit/http`'s `loadControllerWithSwc`. */\nexport type ControllerModuleLoader = (absPath: string) => Promise<Record<string, unknown>>\n\n/** A built controller route table exposed as a pure Web-Standard handler. */\ninterface ControllerDispatcher {\n /** `null` = no controller route matched — the host owns the miss (404 / fall-through). */\n dispatch(request: Request): Promise<Response | null>\n /** Non-executing route probe — true when a controller route owns `method` + `pathname`. */\n matches(method: string, pathname: string): boolean\n}\n\n// State-mutating methods get CSRF, mirroring the file-route pipeline (execute.ts).\nconst CSRF_PROTECTED_METHODS = new Set(['POST', 'PUT', 'PATCH', 'DELETE'])\n\n/** Recursively collect `*.controller.ts` files under `dir` (absolute paths). */\n/**\n * Every `*.controller.ts` under `dir`, recursively. Exported for theokit#123: the build emitter\n * must find exactly the same set the dev dispatcher does, and two independent walks would be two\n * definitions of \"a controller\" that drift.\n */\nexport function findControllerFiles(dir: string): string[] {\n const found: string[] = []\n const walk = (current: string): void => {\n let entries: Dirent[]\n try {\n entries = readdirSync(current, { withFileTypes: true })\n } catch {\n return // dir doesn't exist — no controllers\n }\n for (const entry of entries) {\n const full = join(current, entry.name)\n if (entry.isDirectory()) walk(full)\n // theokit#123 — `.mjs` alongside `.ts`. Dev walks the SOURCE tree; production walks the\n // COMPILED tree under `dist/controllers`, where the same files exist as `*.controller.mjs`.\n // One walk for both keeps a single definition of \"a controller file\"; two would drift, and a\n // file that counts in dev and not in production is exactly the dev/prod split this fixes.\n else if (entry.name.endsWith('.controller.ts') || entry.name.endsWith('.controller.mjs'))\n found.push(full)\n }\n }\n walk(dir)\n return found\n}\n\n/** A discovered controller: its source file + the loaded `@Controller` class. */\ninterface ControllerModule {\n filePath: string\n cls: ControllerClass\n /**\n * The module's full export namespace — theokit#124.\n *\n * Kept alongside the class because it is the ONLY place a `@Body(schema)` regains a name. The\n * schema on `WalkResult.bodySchema` is a runtime `z.ZodType` with no source identifier, but it is\n * the very object this module exported, so matching it back by reference identity recovers the\n * exported name the typed-client codegen needs to write `z.infer<typeof ...>`.\n *\n * Unused by the dispatch path, which needs only the class.\n */\n exports: Readonly<Record<string, unknown>>\n}\n\n/**\n * Load every `@Controller` class under `controllersDir` via the injected loader,\n * keeping each class paired with its source file (needed by the typed-client\n * codegen to emit `import type { X } from '<file>'`). Non-controller exports are\n * ignored (`isControllerClass` — reused from @theokit/http).\n */\nexport async function scanControllerModules(\n controllersDir: string,\n loadModule: ControllerModuleLoader,\n): Promise<ControllerModule[]> {\n const files = findControllerFiles(controllersDir)\n const modules: ControllerModule[] = []\n for (const filePath of files) {\n const mod = await loadModule(filePath)\n for (const exported of Object.values(mod)) {\n if (typeof exported === 'function' && isControllerClass(exported)) {\n modules.push({ filePath, cls: exported as ControllerClass, exports: mod })\n }\n }\n }\n return modules\n}\n\n/** Load every `@Controller` class under `controllersDir` (classes only). */\nasync function scanControllers(\n controllersDir: string,\n loadModule: ControllerModuleLoader,\n): Promise<ControllerClass[]> {\n const modules = await scanControllerModules(controllersDir, loadModule)\n return modules.map((m) => m.cls)\n}\n\n/**\n * Scan `controllersDir` and build a Web-Standard dispatcher over the decorator\n * controllers found. Returns `null` when the directory has no controllers, so\n * the host can skip the controller path entirely (zero cost for routes-only apps).\n *\n * Dispatch REUSES @theokit/http's `createDecoratorHandler` (match + `@Param`\n * binding + `@Body` validation + Response building) — never re-implemented (ADR-1).\n */\nexport async function createControllerDispatcher(opts: {\n controllersDir: string\n loadModule: ControllerModuleLoader\n /** M47 — serves `@Expose`-bound agent routes (theo supplies a `mountAgent`-backed impl). */\n serveAgent?: ServeAgent\n}): Promise<ControllerDispatcher | null> {\n const classes = await scanControllers(opts.controllersDir, opts.loadModule)\n if (classes.length === 0) return null\n const handle = createDecoratorHandler({ controllers: classes, serveAgent: opts.serveAgent })\n return {\n dispatch: (request) => handle(request),\n matches: (method, pathname) => handle.matches(method, pathname),\n }\n}\n\n/**\n * Write a controller's Web `Response` to a Node response, byte for byte.\n *\n * The body used to be read with `await response.text()`, under a comment asserting that controllers\n * never stream. The comment was true of this path and hid the real problem: `text()` decodes as\n * UTF-8, so every byte >= 0x80 became `U+FFFD`. A payload of all 256 byte values arrived as 512\n * bytes; a 55 296-byte MPEG from `@theokit/plugin-voice` arrived as 76 790 bytes beginning\n * `ef bf bd`. Status 200, correct content-type, plausible length — invisible until someone opens\n * the file. File routes were never affected: `executeRoute` pumps the stream, so this was a silent\n * divergence between two paths meant to be at parity.\n *\n * `arrayBuffer()` fixes it without changing anything else. This path stays BUFFERED, exactly as\n * before — a controller returning a streamed body still has it collected here, so a plugin that\n * promises progressive delivery does not get it through a controller. That is a real limitation and\n * a separate change: making it stream alters when bytes reach the client, which is behaviour beyond\n * the corruption this repairs.\n */\nasync function writeControllerResponse(res: ServerResponse, response: Response): Promise<void> {\n const headersBag: Record<string, string> = {}\n for (const [k, v] of response.headers) {\n if (k.toLowerCase() !== 'set-cookie') headersBag[k] = v\n }\n const setCookies = response.headers.getSetCookie()\n if (setCookies.length > 0) res.setHeader('Set-Cookie', setCookies)\n res.writeHead(response.status, headersBag)\n // `Buffer.from(ArrayBuffer)` views the bytes as they are. Any string in between is a decode, and\n // a decode of arbitrary bytes is a loss.\n const body = response.body ? Buffer.from(await response.arrayBuffer()) : undefined\n res.end(body !== undefined && body.length > 0 ? body : undefined)\n}\n\n/**\n * The `api-middleware` fall-through in one call: scan `controllersDir`, build the\n * dispatcher, and serve the request. Builds a body-ful Web `Request` (`@Body`\n * needs the body; the raw stream is undrained at a route miss) and enforces CSRF\n * with the SAME gate file routes use (parity). Returns `true` when a controller\n * handled it (or CSRF blocked it), `false` when there are no controllers OR none\n * matched (the host continues to its own 404). Built per-miss so controller edits\n * reflect via HMR.\n */\nexport async function dispatchControllerRequest(args: {\n controllersDir: string\n loadModule: ControllerModuleLoader\n req: IncomingMessage\n res: ServerResponse\n csrfMode: 'off' | 'warn' | 'strict'\n disallowed?: DisallowedConfig\n requestId: string\n /** M47 — serves `@Expose`-bound agent routes (mountAgent-backed); omit for routes-only apps. */\n serveAgent?: ServeAgent\n}): Promise<boolean> {\n const { req, res, csrfMode, disallowed, requestId } = args\n const dispatcher = await createControllerDispatcher({\n controllersDir: args.controllersDir,\n loadModule: args.loadModule,\n serveAgent: args.serveAgent,\n })\n if (!dispatcher) return false\n\n const method = (req.method ?? 'GET').toUpperCase()\n const webRequest = incomingMessageToWebRequest(req)\n const pathname = new URL(webRequest.url).pathname\n\n // CSRF parity: enforce ONLY when a protected-method controller route actually\n // owns this path (probe with the non-executing matcher — never double-dispatch,\n // which would run the handler + its side effects). An unrouted path falls\n // through to the host's own 404, not a 403.\n if (CSRF_PROTECTED_METHODS.has(method) && dispatcher.matches(method, pathname)) {\n const decision = enforceCsrf(\n req,\n csrfMode,\n { warn: dispatchCsrfWarn, path: req.url },\n disallowed,\n )\n if (!decision.allow) {\n sendError(\n res,\n 'CSRF_INVALID',\n decision.reason ?? 'CSRF check failed',\n 403,\n undefined,\n requestId,\n )\n return true\n }\n }\n\n const response = await dispatcher.dispatch(webRequest)\n if (response === null) return false\n await writeControllerResponse(res, response)\n return true\n}\n","/**\n * Canonical CSRF warn dispatcher (T3.3 of architecture-review-remediation-plan).\n *\n * Consolidates the duplicated `warn: (payload) => { warnOnce(...) }` closure\n * that previously appeared in both `http/execute.ts` and\n * `http/action-execute.ts`. Resolves PV-10 (DRY).\n *\n * `warnOnce` dedupes by `event:method:path` so a request loop with 1000 POSTs\n * doesn't flood logs with identical warnings. Apps grep for `event\":\"csrf.warn\"`\n * (stable event shape — see [[enforcement-cutover.md]]).\n */\nimport { warnOnce } from '../observability/logger.js'\n\ninterface CsrfWarnPayload {\n event: string\n method: string\n path?: string\n reason: string\n code?: string\n docsUrl?: string\n warnOnce?: boolean\n}\n\n/**\n * Build the warn callback that `enforceCsrf` invokes for soft-mode warnings.\n * Returned function is suitable for the `warn` field of `enforceCsrf`'s options.\n */\nexport function dispatchCsrfWarn(payload: CsrfWarnPayload): void {\n const key = `${payload.event}:${payload.method}:${payload.path ?? ''}`\n warnOnce(key, payload as unknown as Record<string, unknown>)\n}\n","/**\n * T4.1 — Audit logging interface + default JSON stdout sink.\n *\n * Per ADR D4: define the interface; ship a zero-dep default; reserve\n * adapter shapes for Postgres, File, OpenTelemetry, Sentry as follow-up\n * packages. Persistence has heavy deps (`pg`, `better-sqlite3`); we\n * keep core dep-free and let users opt in.\n *\n * Compatibility:\n * - Node / Bun / Deno / Vercel — console.log is sync, captured.\n * - Edge runtimes (CF Workers, Vercel Edge) — console.log is captured\n * but may be rate-limited by the platform. For high-volume edge audit,\n * implement a custom sink writing to a queue / HTTP endpoint.\n */\n\nexport interface AuditEvent {\n /** Domain-qualified verb. Convention: `<domain>.<verb>` (e.g. csrf.warn, session.rotated). */\n action: string\n /** Who triggered the event. Anonymous = no auth at time of event. */\n actor?: { type: 'user' | 'system' | 'anonymous'; id?: string }\n /** What was operated on (optional). */\n resource?: { type: string; id?: string }\n /** Arbitrary event-specific metadata. JSON-serializable. */\n metadata?: Record<string, unknown>\n /** ISO 8601 timestamp. If absent, sink fills in `new Date().toISOString()`. */\n timestamp?: string\n /** Optional trace id (populated by middleware from `x-trace-id`). */\n traceId?: string\n}\n\nexport interface AuditLogger {\n log(event: AuditEvent): void | Promise<void>\n}\n\n/**\n * Default sink: one JSON line per event to stdout. Sync. Never throws.\n *\n * EC: circular refs / BigInt values fall back to a placeholder line so\n * the event is still observable (action + traceId) without crashing the\n * request lifecycle.\n */\nexport class JsonStdoutSink implements AuditLogger {\n log(event: AuditEvent): void {\n const enriched = {\n level: 'audit' as const,\n ...event,\n timestamp: event.timestamp ?? new Date().toISOString(),\n }\n try {\n // eslint-disable-next-line no-console -- JsonStdoutSink IS the audit output\n console.log(JSON.stringify(enriched, jsonReplacer))\n } catch {\n // eslint-disable-next-line no-console -- fallback when payload won't serialize\n console.log(\n `{\"level\":\"audit\",\"action\":${JSON.stringify(event.action)},\"timestamp\":${JSON.stringify(enriched.timestamp)},\"note\":\"payload could not be serialized\"}`,\n )\n }\n }\n}\n\n/**\n * Replacer that walks BigInt → string. Circular ref handling is via the\n * outer try/catch (JSON.stringify throws TypeError on cycles; we drop to\n * the fallback line). We don't implement custom cycle-breaking walker\n * because the audit payload is meant to be JSON — if user metadata has\n * a cycle, the right answer is to fix the caller, not silently lose\n * the structure.\n */\nfunction jsonReplacer(_key: string, value: unknown): unknown {\n if (typeof value === 'bigint') return value.toString()\n return value\n}\n\n/**\n * No-op logger. Returned when `config.audit` is unset. Zero overhead;\n * framework wiring sites null-check before calling.\n */\nexport function createNoOpLogger(): AuditLogger {\n return {\n log() {\n // intentionally empty\n },\n }\n}\n\n/**\n * T4.2 — Safe-emit wrapper. Used by framework wiring sites (csrf.ts,\n * rate-limit.ts, session.ts) so a logger throw NEVER propagates into\n * the request handler.\n */\nexport function safeAudit(logger: AuditLogger | undefined, event: AuditEvent): void {\n if (!logger) return\n try {\n const r = logger.log(event)\n // Discard the Promise — async sinks are fire-and-forget by design.\n if (r && typeof r.then === 'function') {\n r.catch(() => {\n // swallow async sink failures — audit must never crash the request\n })\n }\n } catch {\n // swallow sync sink failures — audit must never crash the request\n }\n}\n","import type { IncomingMessage } from 'node:http'\n\nimport type { AuditLogger } from '../observability/audit-log.js'\nimport { safeAudit } from '../observability/audit-log.js'\n\n/**\n * CSRF enforcement mode.\n *\n * - `off` — skip CSRF entirely. Use only when you have another defense\n * (e.g. you don't ship session cookies, all auth is bearer).\n * - `warn` — log a structured warning when the check would fail, but\n * still serve the request. Default for 0.2.0. Migration mode.\n * - `strict` — reject failing requests with 403 + code `CSRF_INVALID`.\n * Will become the default in 0.3.0.\n */\nexport type CsrfMode = 'off' | 'warn' | 'strict'\n\n/**\n * Per-request structured logger surface. Only `warn` is used by enforceCsrf;\n * we don't require a full Logger here so callers can pass a mock or the\n * console directly.\n */\nexport interface CsrfLogger {\n warn: (payload: CsrfWarnPayload) => void\n /** Optional path the request was destined for — used for log correlation. */\n path?: string\n}\n\n/**\n * T5.1 — Rails-inspired per-route escalation.\n *\n * `routes` accepts string (exact match) or RegExp entries. When a request\n * path matches AND the request would otherwise emit a warning, the\n * `behavior` field decides what happens:\n *\n * - `'warn'` → normal warn dispatch (no-op vs default)\n * - `'raise'` → escalate to 403 regardless of global `csrf` mode\n *\n * `'raise'` never downgrades: when global mode is `'off'`, validation is\n * skipped entirely and disallowed dispatch never runs.\n */\nexport interface DisallowedConfig {\n routes: (string | RegExp)[]\n behavior: 'warn' | 'raise'\n}\n\n/**\n * Test whether `path` matches any of the supplied patterns. String\n * patterns are EXACT (trailing slash matters — use RegExp for tolerance).\n *\n * EC-5: when a RegExp carries the `/g` flag, `.test()` mutates\n * `lastIndex` and the next invocation may miss. We reset `lastIndex`\n * before each test so the matcher is a pure function.\n */\nexport function matchDisallowed(path: string, patterns: readonly (string | RegExp)[]): boolean {\n for (const p of patterns) {\n if (typeof p === 'string') {\n if (path === p) return true\n } else if (p instanceof RegExp) {\n p.lastIndex = 0\n if (p.test(path)) return true\n }\n // Neither string nor RegExp: ignore silently (defensive — the public\n // type forbids it but runtime data may slip past).\n }\n return false\n}\n\n/**\n * T2.2 — Stable cutover identifier shipped with every csrf.warn payload.\n *\n * Convention borrowed from Vite's `deprecations.ts:74` — a `code` plus a\n * `docsUrl` lets users (a) grep their logs for a single stable identifier\n * to find every csrf.warn line, and (b) click through directly to the\n * migration guide. Strings are exported constants so the analyzer (T2.3)\n * and migration guide can reference the same source of truth.\n */\nexport const CSRF_WARN_CODE = 'CSRF_STRICT_CUTOVER' as const\nexport const CSRF_WARN_DOCS_URL = 'https://theokit.dev/upgrade/csrf-strict-cutover' as const\n\n/**\n * Pick a header value, choosing the first entry when an array (Node sets\n * arrays for headers that legitimately appear multiple times). Returns\n * `''` when the header is absent or empty — callers treat `''` as \"skip\".\n */\nfunction pickHeader(value: string | string[] | undefined): string {\n if (typeof value === 'string') return value\n if (Array.isArray(value) && value.length > 0) return value[0]\n return ''\n}\n\nexport interface CsrfWarnPayload {\n event: 'csrf.warn'\n method: string\n path: string | undefined\n reason: string\n /**\n * Stable identifier for the 0.2 → 0.3 CSRF strict cutover. Always\n * `'CSRF_STRICT_CUTOVER'`. Grep-able from prod logs.\n */\n code: string\n /**\n * Link to the section of the migration guide explaining how to clear\n * this specific warning class.\n */\n docsUrl: string\n}\n\n/**\n * T5a.2 Phase B (slice 1/6): pure header-only CSRF check extracted from\n * `validateCsrf(req: IncomingMessage)` so it can be re-used by the Web-\n * Standards `validateCsrfRequest(request: Request)` sibling. Per the T5a.2\n * plan v1.0 § Phase B, header-only leaves are first to migrate. This is\n * the dual-signature pattern (anti-pattern #2 avoidance): IncomingMessage\n * consumers unchanged; new Request consumers go through the same logic\n * via the shared helper.\n *\n * Pure logic — accepts pre-extracted header values as strings or null.\n */\nfunction isCsrfValidFromHeaders(opts: {\n csrfActionHeader: string | null\n origin: string | null\n host: string | null\n}): { valid: true } | { valid: false; reason: string } {\n // 1. Custom header must be present (primary defense — simple form posts\n // cannot set custom headers, browsers gate via CORS preflight)\n if (opts.csrfActionHeader !== '1') {\n return { valid: false, reason: 'Missing X-Theo-Action header' }\n }\n\n // 2. Origin matching (secondary defense)\n if (opts.origin === null || opts.origin === '') {\n // Browsers omit Origin for same-origin requests — treat as valid\n return { valid: true }\n }\n\n if (opts.host === null || opts.host === '') {\n return { valid: true }\n }\n\n try {\n const originHost = new URL(opts.origin).host\n if (originHost !== opts.host) {\n return { valid: false, reason: `Origin ${opts.origin} does not match host ${opts.host}` }\n }\n } catch {\n return { valid: false, reason: `Invalid origin: ${opts.origin}` }\n }\n\n return { valid: true }\n}\n\nexport function validateCsrf(\n req: IncomingMessage,\n): { valid: true } | { valid: false; reason: string } {\n // IncomingMessage adapter — normalize Node header shape to the pure\n // helper's input shape (string|null).\n const action = req.headers['x-theo-action']\n const origin = req.headers.origin\n const host = req.headers.host\n\n // RFC 6454: Origin is single-valued. A caller that synthesizes an\n // IncomingMessage — an adapter, a shim, a proxy library — can hand us an\n // array, and choosing one of two conflicting origins is a decision the\n // request never authorized. The disagreement IS the rejection.\n //\n // `node:http` itself joins a repeated Origin with `, ` rather than\n // producing an array, and that string already fails to parse as a URL\n // below. This branch covers the shape the type allows and `pickHeader`\n // used to resolve silently.\n if (Array.isArray(origin)) {\n return { valid: false, reason: 'Multiple Origin headers (RFC 6454 violation)' }\n }\n\n return isCsrfValidFromHeaders({\n csrfActionHeader: typeof action === 'string' ? action : null,\n origin: origin !== undefined ? origin || null : null,\n host: host !== undefined ? pickHeader(host) || null : null,\n })\n}\n\n/**\n * T5a.2 Phase B (slice 1/6) — Web-Standards-shaped CSRF validator.\n *\n * Mirror of `validateCsrf(req: IncomingMessage)` for the Web `Request`\n * shape. Consumes `request.headers.get(name)` (native Web `Headers` API)\n * instead of `req.headers[name]` (Node `IncomingMessage` indexer). Same\n * CSRF policy + same return shape — the difference is only the input\n * extraction.\n *\n * Used by `executeWebRequest` (T5a.2 Phase A) to enforce CSRF on the\n * Web-Standards request handler entry-point.\n */\nexport function validateCsrfRequest(\n request: Request,\n): { valid: true } | { valid: false; reason: string } {\n return isCsrfValidFromHeaders({\n csrfActionHeader: request.headers.get('x-theo-action'),\n origin: request.headers.get('origin'),\n host: request.headers.get('host'),\n })\n}\n\n/**\n * Enforce CSRF policy with mode-aware behavior. Wrapper over `validateCsrf`\n * that turns the boolean valid/invalid into a request-level allow decision,\n * gated by mode + structured warning in warn mode.\n *\n * Phase 5 — CSRF warn-first (EC-1).\n */\n/**\n * Dispatch the csrf.warn payload to both the structured logger and the\n * audit sink (when configured). Extracted from `enforceCsrf` to keep that\n * function's complexity within ceiling.\n */\nfunction dispatchCsrfWarn(\n req: IncomingMessage,\n reason: string,\n logger: CsrfLogger | undefined,\n auditLogger: AuditLogger | undefined,\n pathFallback = '',\n): void {\n const payload: CsrfWarnPayload = {\n event: 'csrf.warn',\n method: req.method ?? 'UNKNOWN',\n path: logger?.path ?? pathFallback,\n reason,\n code: CSRF_WARN_CODE,\n docsUrl: CSRF_WARN_DOCS_URL,\n }\n logger?.warn(payload)\n // `metadata` is typed as Record<string, unknown>; CsrfWarnPayload is a\n // structurally-equivalent shape but lacks the index signature.\n safeAudit(auditLogger, {\n action: 'csrf.warn',\n actor: { type: 'anonymous' },\n metadata: { ...payload },\n })\n}\n\nexport function enforceCsrf(\n req: IncomingMessage,\n mode: CsrfMode,\n logger?: CsrfLogger,\n disallowed?: DisallowedConfig,\n auditLogger?: AuditLogger,\n): { allow: boolean; reason?: string } {\n if (mode === 'off') {\n // `off` short-circuits before disallowed dispatch — users who set\n // csrf: 'off' globally have explicitly turned validation off, and\n // disallowed must never re-introduce it. The escape hatch is to\n // set csrf: 'warn' and use disallowed for surgical strict pockets.\n return { allow: true }\n }\n\n const check = validateCsrf(req)\n if (check.valid) {\n return { allow: true }\n }\n\n // T5.1 — disallowed dispatch: when the failing request matches a\n // disallowed pattern AND behavior is 'raise', escalate to 403 even if\n // global mode is 'warn'. Strict mode would 403 anyway, so the branch\n // is a no-op there.\n if (disallowed?.behavior === 'raise') {\n const path = logger?.path ?? req.url ?? ''\n if (matchDisallowed(path, disallowed.routes)) {\n return { allow: false, reason: check.reason }\n }\n }\n\n if (mode === 'warn') {\n // T2.1: emit via warnOnce by default — callers can override via the\n // injected logger.warn (tests, custom log routers).\n // T2.2: include the stable cutover code + docsUrl so logs are\n // grep-able and click-through-able.\n dispatchCsrfWarn(req, check.reason, logger, auditLogger)\n return { allow: true, reason: check.reason }\n }\n\n // strict — 403 the request, AND emit a warn payload so the dev (and\n // devtools UI) sees WHY it was blocked + the docsUrl to fix it.\n // Without this, strict-mode users get a silent 403 with no context.\n dispatchCsrfWarn(req, check.reason, logger, auditLogger)\n return { allow: false, reason: check.reason }\n}\n"],"mappings":";;;;;;;AAmBA,IAAM,iBAAsC,oBAAI,IAAI,CAAC,kBAAkB,uBAAuB,CAAC;AAE/F,IAAM,2BAA2B;AAEjC,SAAS,QAAQ,MAAuB;AACtC,SAAO,eAAe,IAAI,IAAI,KAAK,QAAQ,IAAI,aAAa;AAC9D;AAGO,SAAS,uBAAuB,MAAc,SAAyB;AAC5E,SAAO,QAAQ,IAAI,IAAI,2BAA2B;AACpD;;;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3C,SAAO;AACT;","names":["dispatchCsrfWarn"]}
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  writeAtomic
3
- } from "./chunk-VZTYCAO6.js";
3
+ } from "./chunk-IDEZ7FU2.js";
4
4
  import {
5
5
  generateNewTraceContext
6
6
  } from "./chunk-UMNXCU3K.js";
7
7
  import {
8
8
  importUserModule
9
- } from "./chunk-52PDWL5S.js";
9
+ } from "./chunk-5KRMDP46.js";
10
10
  import {
11
11
  walkSourceFiles
12
- } from "./chunk-5K4TDLRG.js";
12
+ } from "./chunk-SOYOYGWY.js";
13
13
  import {
14
14
  compareByCodeUnit
15
15
  } from "./chunk-ZWN3AODA.js";
@@ -96,7 +96,7 @@ function relativize(absPath, root) {
96
96
  }
97
97
 
98
98
  // src/server/cron/adapter-translators.ts
99
- import { existsSync, readFileSync } from "fs";
99
+ import { existsSync, readFileSync } from "node:fs";
100
100
  var ExistingConfigUnparseableError = class extends Error {
101
101
  constructor(filePath, parseError) {
102
102
  super(
@@ -308,8 +308,8 @@ function createCronScheduler(definitions) {
308
308
  }
309
309
 
310
310
  // src/server/cron/cron-scan.ts
311
- import { existsSync as existsSync2 } from "fs";
312
- import { basename } from "path";
311
+ import { existsSync as existsSync2 } from "node:fs";
312
+ import { basename } from "node:path";
313
313
  var DuplicateCronNameError = class extends Error {
314
314
  constructor(cronName, filePaths) {
315
315
  super(
@@ -395,4 +395,4 @@ export {
395
395
  scanCrons,
396
396
  scanCronDirs
397
397
  };
398
- //# sourceMappingURL=chunk-HK4AZBKX.js.map
398
+ //# sourceMappingURL=chunk-D5KBBTVD.js.map
@@ -2,7 +2,7 @@
2
2
  import "tsx/esm";
3
3
  import {
4
4
  getApprovalRegistry
5
- } from "./chunk-5YPXXSYY.js";
5
+ } from "./chunk-35QIWOHT.js";
6
6
  import {
7
7
  createWebRequestSource,
8
8
  dispatchCsrfWarn,
@@ -12,7 +12,7 @@ import {
12
12
  sendError,
13
13
  sendJson,
14
14
  validateCsrfRequest
15
- } from "./chunk-MWWFXYW3.js";
15
+ } from "./chunk-CTRVTBGY.js";
16
16
  import {
17
17
  buildSecurityHeaders
18
18
  } from "./chunk-RPET332G.js";
@@ -2616,4 +2616,4 @@ export {
2616
2616
  CsrfReadinessStore,
2617
2617
  applySecurityHeaders
2618
2618
  };
2619
- //# sourceMappingURL=chunk-DADMEW4G.js.map
2619
+ //# sourceMappingURL=chunk-G5JYB2LO.js.map
@@ -11,7 +11,7 @@ var cachedNodeImpl;
11
11
  function resolveNodeImpl() {
12
12
  if (cachedNodeImpl !== void 0) return cachedNodeImpl;
13
13
  try {
14
- const cryptoMod = __require("crypto");
14
+ const cryptoMod = __require("node:crypto");
15
15
  cachedNodeImpl = cryptoMod.timingSafeEqual ?? null;
16
16
  } catch {
17
17
  cachedNodeImpl = null;
@@ -418,4 +418,4 @@ export {
418
418
  telegram,
419
419
  discord
420
420
  };
421
- //# sourceMappingURL=chunk-BU6RJPPJ.js.map
421
+ //# sourceMappingURL=chunk-GO7UWJ47.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/server/webhook/timing-safe-equal.ts","../src/server/webhook/raw-body.ts","../src/server/webhook/define-webhook.ts","../src/server/webhook/providers/stripe.ts","../src/server/webhook/providers/github.ts","../src/server/webhook/providers/slack.ts","../src/server/webhook/providers/telegram.ts","../src/server/webhook/providers/discord.ts"],"mappings":";;;;;;;;;AAqBA,IAAI;AAEJ,SAAS,kBAA8C;AACrD,MAAI,mBAAmB,OAAW,QAAO;AACzC,MAAI;AAIF,UAAM,YAAY,UAAQ,QAAa;AAGvC,qBAAiB,UAAU,mBAAmB;AAAA,EAChD,QAAQ;AACN,qBAAiB;AAAA,EACnB;AACA,SAAO;AACT;AAQO,SAAS,gBAAgB,GAAe,GAAwB;AACrE,MAAI,EAAE,aAAa,eAAe,EAAE,aAAa,aAAa;AAC5D,UAAM,IAAI;AAAA,MACR,qDAAqD,OAAO,CAAC,QAAQ,OAAO,CAAC;AAAA,IAC/E;AAAA,EACF;AAEA,MA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Q,KAAK,SAAS;AAEvC,SAAO,OAAO,QAAwC;AACpD,QAAI,CAAC,SAAU,QAAO,EAAE,IAAI,OAAO,QAAQ,2BAA2B;AACtE,UAAM,SAAS,IAAI,QAAQ,IAAI,qBAAqB;AACpD,UAAM,YAAY,IAAI,QAAQ,IAAI,uBAAuB;AACzD,QAAI,CAAC,OAAQ,QAAO,EAAE,IAAI,OAAO,QAAQ,qCAAqC;AAC9E,QAAI,CAAC,UAAW,QAAO,EAAE,IAAI,OAAO,QAAQ,uCAAuC;AAEnF,UAAM,WAAWA,SAAQ,MAAM;AAC/B,QAAI,CAAC,SAAU,QAAO,EAAE,IAAI,OAAO,QAAQ,0BAA0B;AAErE,UAAM,UAAU,MAAM,IAAI,KAAK;AAC/B,UAAM,UAAU,IAAI,WAAW,IAAI,YAAY,EAAE,OAAO,YAAY,OAAO,CAAC;AAE5E,QAAI;AACF,YAAM,MAAM,MAAM,WAAW,OAAO,OAAO;AAAA,QACzC;AAAA,QACA;AAAA,QACA,EAAE,MAAM,UAAU;AAAA,QAClB;AAAA,QACA,CAAC,QAAQ;AAAA,MACX;AACA,YAAM,KAAK,MAAM,WAAW,OAAO,OAAO,OAAO,WAAW,KAAK,UAAU,OAAO;AAClF,aAAO,KAAK,EAAE,IAAI,KAAK,IAAI,EAAE,IAAI,OAAO,QAAQ,qBAAqB;AAAA,IACvE,SAAS,KAAK;AACZ,aAAO;AAAA,QACL,IAAI;AAAA,QACJ,QAAQ,wBAAwB,eAAe,QAAQ,IAAI,UAAU,SAAS;AAAA,MAChF;AAAA,IACF;AAAA,EACF;AACF;","names":["result","fromHex","enc","PREFIX","fromHex","enc","enc","fromHex"]}
1
+ {"version":3,"sources":["../src/server/webhook/timing-safe-equal.ts","../src/server/webhook/raw-body.ts","../src/server/webhook/define-webhook.ts","../src/server/webhook/providers/stripe.ts","../src/server/webhook/providers/github.ts","../src/server/webhook/providers/slack.ts","../src/server/webhook/providers/telegram.ts","../src/server/webhook/providers/discord.ts"],"mapp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;AAAA,IACvE,SAAS,KAAK;AACZ,aAAO;AAAA,QACL,IAAI;AAAA,QACJ,QAAQ,wBAAwB,eAAe,QAAQ,IAAI,UAAU,SAAS;AAAA,MAChF;AAAA,IACF;AAAA,EACF;AACF;","names":["result","fromHex","enc","PREFIX","fromHex","enc","enc","fromHex"]}
@@ -1,6 +1,6 @@
1
1
  // src/server/_internal/atomic-write.ts
2
- import { mkdirSync, renameSync, writeFileSync } from "fs";
3
- import { dirname } from "path";
2
+ import { mkdirSync, renameSync, writeFileSync } from "node:fs";
3
+ import { dirname } from "node:path";
4
4
  function writeAtomic(path, content) {
5
5
  mkdirSync(dirname(path), { recursive: true });
6
6
  const randBuf = new Uint8Array(4);
@@ -15,4 +15,4 @@ function writeAtomic(path, content) {
15
15
  export {
16
16
  writeAtomic
17
17
  };
18
- //# sourceMappingURL=chunk-VZTYCAO6.js.map
18
+ //# sourceMappingURL=chunk-IDEZ7FU2.js.map
@@ -1,7 +1,18 @@
1
+ import {
2
+ enforceCsrf,
3
+ validateCsrfRequest
4
+ } from "./chunk-P6OS7652.js";
1
5
  import {
2
6
  ActionError,
3
7
  ActionInputError
4
8
  } from "./chunk-ZDUO4IYN.js";
9
+ import {
10
+ WEB_SHAPED_MIDDLEWARE
11
+ } from "./chunk-D4VP2QPR.js";
12
+ import {
13
+ evaluateRoutePolicy,
14
+ subjectFromContext
15
+ } from "./chunk-YN4W7LCX.js";
5
16
  import {
6
17
  DuplicateContextKeyError,
7
18
  createOutbox,
@@ -12,14 +23,10 @@ import {
12
23
  RequestBodyConsumedError,
13
24
  parseRequestBody,
14
25
  warnOnce
15
- } from "./chunk-BND4YZTQ.js";
26
+ } from "./chunk-ZDCCILMP.js";
16
27
  import {
17
28
  scanMiddlewares
18
- } from "./chunk-BX6EUYHU.js";
19
- import {
20
- enforceCsrf,
21
- validateCsrfRequest
22
- } from "./chunk-P6OS7652.js";
29
+ } from "./chunk-V6Y2SMRG.js";
23
30
  import {
24
31
  envelopeCodeToStatus
25
32
  } from "./chunk-ACKBVBUI.js";
@@ -27,13 +34,6 @@ import {
27
34
  TheoError,
28
35
  serverErrorToEnvelope
29
36
  } from "./chunk-IZ3TIL6K.js";
30
- import {
31
- WEB_SHAPED_MIDDLEWARE
32
- } from "./chunk-D4VP2QPR.js";
33
- import {
34
- evaluateRoutePolicy,
35
- subjectFromContext
36
- } from "./chunk-YN4W7LCX.js";
37
37
 
38
38
  // src/core/contracts/client-safe-error.ts
39
39
  var INTERNAL_CODES = /* @__PURE__ */ new Set(["INTERNAL_ERROR", "INTERNAL_SERVER_ERROR"]);
@@ -112,7 +112,7 @@ function sendError(res, codeOrInput, message, status, issues, requestId, options
112
112
  }
113
113
 
114
114
  // src/server/http/node-request.ts
115
- import { Readable } from "stream";
115
+ import { Readable } from "node:stream";
116
116
  function pickHeaderString(value) {
117
117
  if (typeof value === "string") return value;
118
118
  if (Array.isArray(value)) {
@@ -572,8 +572,8 @@ async function runErrorHooks(err, hookCtx, onError) {
572
572
  }
573
573
 
574
574
  // src/server/http/middleware-runner.ts
575
- import { existsSync } from "fs";
576
- import { join } from "path";
575
+ import { existsSync } from "node:fs";
576
+ import { join } from "node:path";
577
577
 
578
578
  // src/server/http/node-web-adapter.ts
579
579
  async function writeWebResponseToServerResponse(response, res) {
@@ -1702,4 +1702,4 @@ export {
1702
1702
  createCorsHandler,
1703
1703
  createCorsWebHandler
1704
1704
  };
1705
- //# sourceMappingURL=chunk-ITSNTHWN.js.map
1705
+ //# sourceMappingURL=chunk-JW5UFKQ3.js.map
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  walkSourceFiles
3
- } from "./chunk-5K4TDLRG.js";
3
+ } from "./chunk-SOYOYGWY.js";
4
4
  import {
5
5
  compareByCodeUnit
6
6
  } from "./chunk-ZWN3AODA.js";
7
7
 
8
8
  // src/server/scan/agent-scan.ts
9
- import { existsSync, readFileSync, statSync as statSync2 } from "fs";
10
- import { extname, join, relative } from "path";
9
+ import { existsSync, readFileSync, statSync as statSync2 } from "node:fs";
10
+ import { extname, join, relative } from "node:path";
11
11
 
12
12
  // src/server/scan/detect-agent-policy.ts
13
- import { createRequire } from "module";
13
+ import { createRequire } from "node:module";
14
14
  var require_ = createRequire(import.meta.url);
15
15
  var ts = require_("typescript");
16
16
  var POLICY_EXPORT = "policy";
@@ -195,7 +195,7 @@ var RedundantApiSegmentError = class extends Error {
195
195
  };
196
196
 
197
197
  // src/server/scan/file-stamp-cache.ts
198
- import { statSync } from "fs";
198
+ import { statSync } from "node:fs";
199
199
  function createFileStampCache() {
200
200
  const entries = /* @__PURE__ */ new Map();
201
201
  return {
@@ -273,4 +273,4 @@ export {
273
273
  createFileStampCache,
274
274
  scanAgents
275
275
  };
276
- //# sourceMappingURL=chunk-IRASEXOG.js.map
276
+ //# sourceMappingURL=chunk-KDP2HURW.js.map
@@ -12,7 +12,7 @@ import {
12
12
  serveMatchedAuxRoute,
13
13
  serveThroughPluginLifecycle,
14
14
  setupSsrDevMiddleware
15
- } from "./chunk-QZUIF64G.js";
15
+ } from "./chunk-OKDCBENR.js";
16
16
  import {
17
17
  resolveTheoRootDir
18
18
  } from "./chunk-FDOOBTXJ.js";
@@ -38,17 +38,17 @@ import {
38
38
  mountAgent,
39
39
  readAgentPolicy,
40
40
  writeWebResponseToServerResponse
41
- } from "./chunk-DADMEW4G.js";
41
+ } from "./chunk-G5JYB2LO.js";
42
42
  import {
43
43
  getApprovalRegistry,
44
44
  resolveProvider
45
- } from "./chunk-5YPXXSYY.js";
45
+ } from "./chunk-35QIWOHT.js";
46
46
  import {
47
47
  createWebRequestSource,
48
48
  dispatchControllerRequest,
49
49
  incomingMessageToHandlerRequest,
50
50
  sendError
51
- } from "./chunk-MWWFXYW3.js";
51
+ } from "./chunk-CTRVTBGY.js";
52
52
  import {
53
53
  TRACE_HEADER,
54
54
  createObservabilityPluginFromConfig,
@@ -2179,19 +2179,19 @@ async function theoPluginAsync(rootOrOptions) {
2179
2179
  })
2180
2180
  );
2181
2181
  }
2182
- const { appTypedClientPlugin } = await import("./app-typed-client-NEKRXPAQ.js");
2182
+ const { appTypedClientPlugin } = await import("./app-typed-client-NMKJ4DR7.js");
2183
2183
  const appClientPlugin = appTypedClientPlugin({
2184
2184
  cwd: projectRoot,
2185
2185
  serverDir: serverDirAbs,
2186
2186
  distDir: resolve5(projectRoot, ".theokit")
2187
2187
  });
2188
- const { actionsVirtualModule } = await import("./actions-virtual-module-TZFLCIIR.js");
2188
+ const { actionsVirtualModule } = await import("./actions-virtual-module-XAWZOWSY.js");
2189
2189
  const actionsPlugin = actionsVirtualModule({
2190
2190
  serverDir: serverDirAbs,
2191
2191
  distDir: resolve5(projectRoot, ".theokit")
2192
2192
  });
2193
2193
  const { agentsTypedClientPlugin } = await import("./agents-typed-client-D4OA2TXB.js");
2194
- const { generateManifest } = await import("./internal-api-XSUP3NDI.js");
2194
+ const { generateManifest } = await import("./internal-api-732K3H75.js");
2195
2195
  const agentsClientPlugin = agentsTypedClientPlugin({
2196
2196
  projectRoot,
2197
2197
  agentsDir: agentsDirName,
@@ -2208,7 +2208,7 @@ async function theoPluginAsync(rootOrOptions) {
2208
2208
  const controllerTransformPlugin = controllerSwcTransformPlugin({
2209
2209
  serverDir: serverDirAbs
2210
2210
  });
2211
- const { serverOnlyImportBoundary } = await import("./server-boundary-PGPFBJBH.js");
2211
+ const { serverOnlyImportBoundary } = await import("./server-boundary-B6U4DRRH.js");
2212
2212
  const serverBoundaryPlugin = serverOnlyImportBoundary({
2213
2213
  projectRoot,
2214
2214
  serverDir: serverDirAbs
@@ -2383,4 +2383,4 @@ export {
2383
2383
  theoPluginAsync,
2384
2384
  theoPlugin
2385
2385
  };
2386
- //# sourceMappingURL=chunk-VRELW5NF.js.map
2386
+ //# sourceMappingURL=chunk-KEDRCI2L.js.map
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  validateRouteInput
3
- } from "./chunk-ITSNTHWN.js";
3
+ } from "./chunk-JW5UFKQ3.js";
4
4
  import {
5
5
  evaluateRoutePolicy,
6
6
  subjectFromContext
7
7
  } from "./chunk-YN4W7LCX.js";
8
8
 
9
9
  // src/server/http/error-pages.ts
10
- import { closeSync, fstatSync, openSync, readFileSync } from "fs";
11
- import { resolve } from "path";
10
+ import { closeSync, fstatSync, openSync, readFileSync } from "node:fs";
11
+ import { resolve } from "node:path";
12
12
  var MAX_ERROR_HTML_BYTES = 1048576;
13
13
  function loadIfSafe(dir, name) {
14
14
  const path = resolve(dir, name);
@@ -45,8 +45,8 @@ function loadCustomErrorPages(clientDir) {
45
45
  }
46
46
 
47
47
  // src/server/http/static.ts
48
- import { closeSync as closeSync2, fstatSync as fstatSync2, openSync as openSync2, readFileSync as readFileSync2, realpathSync } from "fs";
49
- import { resolve as resolve2, extname, sep } from "path";
48
+ import { closeSync as closeSync2, fstatSync as fstatSync2, openSync as openSync2, readFileSync as readFileSync2, realpathSync } from "node:fs";
49
+ import { resolve as resolve2, extname, sep } from "node:path";
50
50
  var MIME_TYPES = {
51
51
  ".html": "text/html",
52
52
  ".js": "application/javascript",
@@ -161,8 +161,8 @@ async function callProcedure(config, input = {}, ctx) {
161
161
  }
162
162
 
163
163
  // src/server/openapi/serve-docs.ts
164
- import { closeSync as closeSync3, fstatSync as fstatSync3, openSync as openSync3, readFileSync as readFileSync3 } from "fs";
165
- import { resolve as resolve3 } from "path";
164
+ import { closeSync as closeSync3, fstatSync as fstatSync3, openSync as openSync3, readFileSync as readFileSync3 } from "node:fs";
165
+ import { resolve as resolve3 } from "node:path";
166
166
  var MAX_SPEC_BYTES = 10 * 1024 * 1024;
167
167
  var DEFAULT_CDN = "https://cdn.jsdelivr.net/npm/@scalar/api-reference";
168
168
  function createOpenApiHandler(opts = {}) {
@@ -270,4 +270,4 @@ export {
270
270
  callProcedure,
271
271
  createOpenApiHandler
272
272
  };
273
- //# sourceMappingURL=chunk-GWE4MUKQ.js.map
273
+ //# sourceMappingURL=chunk-KQ27YDLG.js.map
@@ -1,25 +1,25 @@
1
+ import {
2
+ validateCsrfRequest
3
+ } from "./chunk-P6OS7652.js";
4
+ import {
5
+ evaluateRoutePolicy
6
+ } from "./chunk-YN4W7LCX.js";
1
7
  import {
2
8
  createObservabilityPlugin,
3
9
  requestTrace,
4
10
  resolveAdapter
5
- } from "./chunk-2OEN3YTE.js";
11
+ } from "./chunk-PVNMLZ5G.js";
6
12
  import {
7
13
  createLogger,
8
14
  warnOnce
9
- } from "./chunk-BND4YZTQ.js";
10
- import {
11
- validateCsrfRequest
12
- } from "./chunk-P6OS7652.js";
15
+ } from "./chunk-ZDCCILMP.js";
13
16
  import {
14
17
  processSingleton
15
- } from "./chunk-3PBAN2YE.js";
18
+ } from "./chunk-CF2DNN5R.js";
16
19
  import {
17
20
  newSpanId,
18
21
  newTraceId
19
22
  } from "./chunk-UMNXCU3K.js";
20
- import {
21
- evaluateRoutePolicy
22
- } from "./chunk-YN4W7LCX.js";
23
23
 
24
24
  // src/server/agent/mount-agent.ts
25
25
  import { compileAgentModule as compileAgentModule2, resolveEnabledSkills as resolveEnabledSkills2, streamAgentUIMessages as streamAgentUIMessages2 } from "@theokit/agents";
@@ -805,4 +805,4 @@ export {
805
805
  parseAgentRequestBody,
806
806
  mountAgent
807
807
  };
808
- //# sourceMappingURL=chunk-WX6NHGKS.js.map
808
+ //# sourceMappingURL=chunk-M357ILK5.js.map
@@ -3,7 +3,7 @@ import "tsx/esm";
3
3
  import {
4
4
  getApprovalRegistry,
5
5
  resolveProvider
6
- } from "./chunk-5YPXXSYY.js";
6
+ } from "./chunk-35QIWOHT.js";
7
7
  import {
8
8
  scanAgents
9
9
  } from "./chunk-5NNFO7R7.js";
@@ -178,7 +178,7 @@ async function agentCommand(name, message, deps = {}) {
178
178
  async function createAgentSsrLoader(projectRoot) {
179
179
  const { createServer } = await import("vite");
180
180
  const react = (await import("@vitejs/plugin-react")).default;
181
- const { theoPluginAsync } = await import("./vite-plugin-5O3D472R.js");
181
+ const { theoPluginAsync } = await import("./vite-plugin-ABJIDKE6.js");
182
182
  const { loadConfig } = await import("./load-config-BKUAMGO5.js");
183
183
  const config = await loadConfig(projectRoot);
184
184
  const theoPlugins = await theoPluginAsync({
@@ -212,4 +212,4 @@ export {
212
212
  agentCommand,
213
213
  createAgentSsrLoader
214
214
  };
215
- //# sourceMappingURL=chunk-2PSKQWGM.js.map
215
+ //# sourceMappingURL=chunk-NC2OPE22.js.map
@@ -25,14 +25,14 @@ import {
25
25
  parseAgentRequestBody,
26
26
  readAgentPolicy,
27
27
  subjectFromContext
28
- } from "./chunk-DADMEW4G.js";
28
+ } from "./chunk-G5JYB2LO.js";
29
29
  import {
30
30
  getApprovalRegistry
31
- } from "./chunk-5YPXXSYY.js";
31
+ } from "./chunk-35QIWOHT.js";
32
32
  import {
33
33
  sendError,
34
34
  validateCsrfRequest
35
- } from "./chunk-MWWFXYW3.js";
35
+ } from "./chunk-CTRVTBGY.js";
36
36
  import {
37
37
  generateNonce
38
38
  } from "./chunk-RPET332G.js";
@@ -867,4 +867,4 @@ export {
867
867
  applyNonceToInlineScripts,
868
868
  setupSsrDevMiddleware
869
869
  };
870
- //# sourceMappingURL=chunk-QZUIF64G.js.map
870
+ //# sourceMappingURL=chunk-OKDCBENR.js.map
@@ -1,9 +1,9 @@
1
- import {
2
- handleMcpJsonRpc
3
- } from "./chunk-YOIVCCZT.js";
4
1
  import {
5
2
  defineAgentTool
6
3
  } from "./chunk-BZF76LFM.js";
4
+ import {
5
+ handleMcpJsonRpc
6
+ } from "./chunk-YOIVCCZT.js";
7
7
 
8
8
  // src/server/agent/workflow-tool.ts
9
9
  import { z } from "zod";
@@ -33,7 +33,7 @@ function createWorkflowTool(workflow, config) {
33
33
  }
34
34
 
35
35
  // src/server/agent/acp-tool.ts
36
- import { spawn } from "child_process";
36
+ import { spawn } from "node:child_process";
37
37
  import { AcpClient } from "@theokit/agents";
38
38
  var NodeAcpTransport = class {
39
39
  // stdin=pipe, stdout=pipe, stderr=inherit → the third stream is null.
@@ -289,4 +289,4 @@ export {
289
289
  streamAgentTurnInProcess,
290
290
  InProcessApprovalRequiredError
291
291
  };
292
- //# sourceMappingURL=chunk-ZQO37YQJ.js.map
292
+ //# sourceMappingURL=chunk-PELXWPDF.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  extractW3CTraceContext
3
- } from "./chunk-BND4YZTQ.js";
3
+ } from "./chunk-ZDCCILMP.js";
4
4
  import {
5
5
  newSpanId,
6
6
  newTraceId
@@ -404,4 +404,4 @@ export {
404
404
  resolveAdapter,
405
405
  createObservabilityPlugin
406
406
  };
407
- //# sourceMappingURL=chunk-2OEN3YTE.js.map
407
+ //# sourceMappingURL=chunk-PVNMLZ5G.js.map