theokit 0.68.0 → 0.70.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 (145) hide show
  1. package/README.md +21 -0
  2. package/dist/{actions-virtual-module-SE44BKR4.js → actions-virtual-module-ICWX5PZ2.js} +8 -8
  3. package/dist/{actions-virtual-module-3OPYLD76.js → actions-virtual-module-LY6VGJZ2.js} +5 -5
  4. package/dist/adapters/agent-mount.d.ts +191 -3
  5. package/dist/adapters/agent-mount.js +19 -4
  6. package/dist/adapters/security-headers.d.ts +17 -1
  7. package/dist/adapters/security-headers.js +7 -0
  8. package/dist/adapters/security-headers.js.map +1 -1
  9. package/dist/{agent-UBDDP2L5.js → agent-7DQ3TKJY.js} +4 -4
  10. package/dist/agent-scan-BLXaFL6R.d.ts +12 -0
  11. package/dist/{app-typed-client-BE3PV3JY.js → app-typed-client-2S76VTMB.js} +5 -5
  12. package/dist/{app-typed-client-RAFEBA7S.js → app-typed-client-6YQREFRS.js} +8 -8
  13. package/dist/{aws-lambda-R76PWR27.js → aws-lambda-OCJM5YGB.js} +35 -23
  14. package/dist/aws-lambda-OCJM5YGB.js.map +1 -0
  15. package/dist/{build-U4HVYY6F.js → build-NIHGHPYS.js} +12 -7
  16. package/dist/build-NIHGHPYS.js.map +1 -0
  17. package/dist/{bun-NPBIAWSU.js → bun-KRUAWYRW.js} +51 -39
  18. package/dist/bun-KRUAWYRW.js.map +1 -0
  19. package/dist/{chunk-GQNBZDYK.js → chunk-2FHNJ7LI.js} +1 -1
  20. package/dist/{chunk-GQNBZDYK.js.map → chunk-2FHNJ7LI.js.map} +1 -1
  21. package/dist/chunk-3NAKOWTX.js +573 -0
  22. package/dist/chunk-3NAKOWTX.js.map +1 -0
  23. package/dist/chunk-4D4YVXHR.js +816 -0
  24. package/dist/chunk-4D4YVXHR.js.map +1 -0
  25. package/dist/{chunk-G2NWAVGG.js → chunk-5XXXJ6DT.js} +65 -6
  26. package/dist/chunk-5XXXJ6DT.js.map +1 -0
  27. package/dist/{chunk-CO7Q75IS.js → chunk-6SK4MX2N.js} +10 -10
  28. package/dist/{chunk-UETVDZBE.js → chunk-BINRCILF.js} +4 -1
  29. package/dist/{chunk-UETVDZBE.js.map → chunk-BINRCILF.js.map} +1 -1
  30. package/dist/{chunk-AROOYXI5.js → chunk-BTDTHXUI.js} +2 -2
  31. package/dist/{chunk-GP6OJBXP.js → chunk-CPXIYCAY.js} +2 -2
  32. package/dist/chunk-FFGP2LGQ.js +465 -0
  33. package/dist/chunk-FFGP2LGQ.js.map +1 -0
  34. package/dist/{chunk-KDP2HURW.js → chunk-FHQP23Z5.js} +10 -2
  35. package/dist/{chunk-KDP2HURW.js.map → chunk-FHQP23Z5.js.map} +1 -1
  36. package/dist/{chunk-BCFA6LHL.js → chunk-GVJFVBCJ.js} +2 -2
  37. package/dist/{chunk-LADTWXOB.js → chunk-H5KSRGRS.js} +43 -554
  38. package/dist/chunk-H5KSRGRS.js.map +1 -0
  39. package/dist/{chunk-ENRT6DAU.js → chunk-IDWN2OSG.js} +15 -2
  40. package/dist/chunk-IDWN2OSG.js.map +1 -0
  41. package/dist/{chunk-GDF2XQOO.js → chunk-JMN4COMK.js} +5 -3
  42. package/dist/chunk-JMN4COMK.js.map +1 -0
  43. package/dist/{chunk-Q7T3UQ4L.js → chunk-KOG5K26V.js} +16 -738
  44. package/dist/chunk-KOG5K26V.js.map +1 -0
  45. package/dist/{chunk-FYYKMPST.js → chunk-MLF25NC4.js} +4 -4
  46. package/dist/{chunk-7THO4PRL.js → chunk-PGDBSK2L.js} +33 -11
  47. package/dist/chunk-PGDBSK2L.js.map +1 -0
  48. package/dist/{chunk-5NNFO7R7.js → chunk-R7G2B2WH.js} +10 -2
  49. package/dist/chunk-R7G2B2WH.js.map +1 -0
  50. package/dist/{chunk-GAJOZJWD.js → chunk-SX7ZAHNE.js} +15 -2
  51. package/dist/chunk-SX7ZAHNE.js.map +1 -0
  52. package/dist/chunk-V5SSTT3C.js +52 -0
  53. package/dist/chunk-V5SSTT3C.js.map +1 -0
  54. package/dist/chunk-XG6SQUEP.js +27 -0
  55. package/dist/chunk-XG6SQUEP.js.map +1 -0
  56. package/dist/{chunk-QGNSZ2ZK.js → chunk-YWWMYEAC.js} +3 -3
  57. package/dist/cli/index.js +7 -7
  58. package/dist/client/index.d.ts +20 -0
  59. package/dist/client/index.js.map +1 -1
  60. package/dist/{cloudflare-5HU56XIH.js → cloudflare-GK4VD3EU.js} +36 -13
  61. package/dist/cloudflare-GK4VD3EU.js.map +1 -0
  62. package/dist/{define-middleware-D2n71Svm.d.ts → define-middleware-BOHpPOBs.d.ts} +1 -1
  63. package/dist/{deno-deploy-BXOQ45LD.js → deno-deploy-WMNXRVGL.js} +37 -36
  64. package/dist/deno-deploy-WMNXRVGL.js.map +1 -0
  65. package/dist/{dev-E3USPAWQ.js → dev-KKO3JIN7.js} +7 -7
  66. package/dist/{dev-emit-ZLB2J5ME.js → dev-emit-23AA3V64.js} +3 -3
  67. package/dist/{dev-emit-7RT624PM.js → dev-emit-UJJXY3ET.js} +3 -3
  68. package/dist/{index-B9iVBHJI.d.ts → index-inRdhi59.d.ts} +39 -4
  69. package/dist/index.js +9 -8
  70. package/dist/index.js.map +1 -1
  71. package/dist/{internal-api-OOTVIOH2.js → internal-api-HUIBRF2X.js} +5 -5
  72. package/dist/{internal-api-VAKXXW6F.js → internal-api-S72T2XKD.js} +10 -9
  73. package/dist/match-DaKsL73w.d.ts +28 -0
  74. package/dist/{mcp-7UOQM4FW.js → mcp-I6MCW6KX.js} +4 -4
  75. package/dist/{match-Dw4CNXJH.d.ts → module-loader-DCip7NoL.d.ts} +1 -28
  76. package/dist/{netlify-LPJAPMQ2.js → netlify-VOL54SC7.js} +23 -20
  77. package/dist/netlify-VOL54SC7.js.map +1 -0
  78. package/dist/{openapi-SKKXWFX4.js → openapi-24PTE7P6.js} +3 -3
  79. package/dist/{preview-GPMF43QX.js → preview-EOL3LMK7.js} +3 -3
  80. package/dist/{registry-UOWTDUFL.js → registry-DDBXDHJ2.js} +7 -7
  81. package/dist/server/cost/index.d.ts +14 -1
  82. package/dist/server/cost/index.js +1 -1
  83. package/dist/server/define/index.d.ts +1 -1
  84. package/dist/server/define/index.js +2 -3
  85. package/dist/server/http/index.d.ts +4 -3
  86. package/dist/server/http/index.js +13 -8
  87. package/dist/server/index.d.ts +6 -5
  88. package/dist/server/index.js +17 -12
  89. package/dist/server/index.js.map +1 -1
  90. package/dist/server/scan/index.d.ts +4 -3
  91. package/dist/server/scan/index.js +2 -2
  92. package/dist/{server-boundary-A3HW27C7.js → server-boundary-ERBSHRHT.js} +5 -5
  93. package/dist/{server-boundary-V6PCM22J.js → server-boundary-I5XWYINJ.js} +8 -8
  94. package/dist/{start-6WEPXA3X.js → start-OD4DG4C6.js} +6 -6
  95. package/dist/{vercel-YUZADKGV.js → vercel-LZTDSDJF.js} +42 -28
  96. package/dist/vercel-LZTDSDJF.js.map +1 -0
  97. package/dist/vite-plugin/index.js +9 -8
  98. package/dist/{vite-plugin-WBF5NXGW.js → vite-plugin-SH3VGQEE.js} +7 -7
  99. package/package.json +4 -4
  100. package/dist/agent-scan-BZa-pagG.d.ts +0 -16
  101. package/dist/aws-lambda-R76PWR27.js.map +0 -1
  102. package/dist/build-U4HVYY6F.js.map +0 -1
  103. package/dist/bun-NPBIAWSU.js.map +0 -1
  104. package/dist/chunk-5NNFO7R7.js.map +0 -1
  105. package/dist/chunk-6B3CMPE4.js +0 -192
  106. package/dist/chunk-6B3CMPE4.js.map +0 -1
  107. package/dist/chunk-7L7LQ2GU.js +0 -16
  108. package/dist/chunk-7L7LQ2GU.js.map +0 -1
  109. package/dist/chunk-7THO4PRL.js.map +0 -1
  110. package/dist/chunk-ENRT6DAU.js.map +0 -1
  111. package/dist/chunk-G2NWAVGG.js.map +0 -1
  112. package/dist/chunk-GAJOZJWD.js.map +0 -1
  113. package/dist/chunk-GDF2XQOO.js.map +0 -1
  114. package/dist/chunk-LADTWXOB.js.map +0 -1
  115. package/dist/chunk-O55RLSGG.js +0 -127
  116. package/dist/chunk-O55RLSGG.js.map +0 -1
  117. package/dist/chunk-Q7T3UQ4L.js.map +0 -1
  118. package/dist/cloudflare-5HU56XIH.js.map +0 -1
  119. package/dist/deno-deploy-BXOQ45LD.js.map +0 -1
  120. package/dist/netlify-LPJAPMQ2.js.map +0 -1
  121. package/dist/vercel-YUZADKGV.js.map +0 -1
  122. /package/dist/{actions-virtual-module-SE44BKR4.js.map → actions-virtual-module-ICWX5PZ2.js.map} +0 -0
  123. /package/dist/{actions-virtual-module-3OPYLD76.js.map → actions-virtual-module-LY6VGJZ2.js.map} +0 -0
  124. /package/dist/{agent-UBDDP2L5.js.map → agent-7DQ3TKJY.js.map} +0 -0
  125. /package/dist/{app-typed-client-BE3PV3JY.js.map → app-typed-client-2S76VTMB.js.map} +0 -0
  126. /package/dist/{app-typed-client-RAFEBA7S.js.map → app-typed-client-6YQREFRS.js.map} +0 -0
  127. /package/dist/{chunk-CO7Q75IS.js.map → chunk-6SK4MX2N.js.map} +0 -0
  128. /package/dist/{chunk-AROOYXI5.js.map → chunk-BTDTHXUI.js.map} +0 -0
  129. /package/dist/{chunk-GP6OJBXP.js.map → chunk-CPXIYCAY.js.map} +0 -0
  130. /package/dist/{chunk-BCFA6LHL.js.map → chunk-GVJFVBCJ.js.map} +0 -0
  131. /package/dist/{chunk-FYYKMPST.js.map → chunk-MLF25NC4.js.map} +0 -0
  132. /package/dist/{chunk-QGNSZ2ZK.js.map → chunk-YWWMYEAC.js.map} +0 -0
  133. /package/dist/{dev-E3USPAWQ.js.map → dev-KKO3JIN7.js.map} +0 -0
  134. /package/dist/{dev-emit-ZLB2J5ME.js.map → dev-emit-23AA3V64.js.map} +0 -0
  135. /package/dist/{dev-emit-7RT624PM.js.map → dev-emit-UJJXY3ET.js.map} +0 -0
  136. /package/dist/{internal-api-OOTVIOH2.js.map → internal-api-HUIBRF2X.js.map} +0 -0
  137. /package/dist/{internal-api-VAKXXW6F.js.map → internal-api-S72T2XKD.js.map} +0 -0
  138. /package/dist/{mcp-7UOQM4FW.js.map → mcp-I6MCW6KX.js.map} +0 -0
  139. /package/dist/{openapi-SKKXWFX4.js.map → openapi-24PTE7P6.js.map} +0 -0
  140. /package/dist/{preview-GPMF43QX.js.map → preview-EOL3LMK7.js.map} +0 -0
  141. /package/dist/{registry-UOWTDUFL.js.map → registry-DDBXDHJ2.js.map} +0 -0
  142. /package/dist/{server-boundary-A3HW27C7.js.map → server-boundary-ERBSHRHT.js.map} +0 -0
  143. /package/dist/{server-boundary-V6PCM22J.js.map → server-boundary-I5XWYINJ.js.map} +0 -0
  144. /package/dist/{start-6WEPXA3X.js.map → start-OD4DG4C6.js.map} +0 -0
  145. /package/dist/{vite-plugin-WBF5NXGW.js.map → vite-plugin-SH3VGQEE.js.map} +0 -0
package/README.md CHANGED
@@ -38,6 +38,27 @@ Node `>= 22.12.0`. Peers: `react`, `react-dom`, `react-router`, `zod`, and — w
38
38
  | `server/ws/chat.ts` | `ws://…/ws/chat` |
39
39
  | `server/middleware/01-cors.ts` | request middleware, in filename order |
40
40
 
41
+ ### `next` is supported on one of the two paths
42
+
43
+ A middleware receives `(request, context, next)`. What `next` does depends on which runner is
44
+ executing it, and the two differ today:
45
+
46
+ | path | `next` |
47
+ |---|---|
48
+ | `executeWebRequest` — the Web runner | runs the rest of the chain **and the route**, so code after `await next()` observes the route's response |
49
+ | `server/middleware/*.ts` — the file-scan runner | **refuses.** It runs BEFORE routing, so there is no downstream to await |
50
+
51
+ The file-scan path throws `MiddlewareNextUnavailableError`, naming the alternative. It used to
52
+ accept the call and continue silently, which meant the code after `await next()` never ran and
53
+ nothing said so.
54
+
55
+ **This is a real limitation, not a bug being hidden.** Closing it means either folding the
56
+ file-scan path so the chain wraps the route, or retiring this contract for a single one; both are
57
+ large and the choice is open — `docs/adr/0003` § *AMENDED 2026-09-21* records what each costs.
58
+
59
+ Write a `server/middleware/*.ts` middleware that returns a `Response` to answer the request, or
60
+ returns nothing to continue. Use the Web path when you need code to run after the route.
61
+
41
62
  ## Authoring surfaces
42
63
 
43
64
  Every surface is a fluent builder whose `.build()` is a compile error while a required link is
@@ -1,12 +1,12 @@
1
- import "./chunk-GDF2XQOO.js";
2
- import "./chunk-GAJOZJWD.js";
1
+ import "./chunk-JMN4COMK.js";
2
+ import "./chunk-SX7ZAHNE.js";
3
3
  import "./chunk-WSOAN4KN.js";
4
4
  import "./chunk-ENSFCKP6.js";
5
- import "./chunk-Q7T3UQ4L.js";
5
+ import "./chunk-KOG5K26V.js";
6
+ import "./chunk-4D4YVXHR.js";
6
7
  import "./chunk-P6OS7652.js";
7
8
  import "./chunk-ZDUO4IYN.js";
8
- import "./chunk-7L7LQ2GU.js";
9
- import "./chunk-ENRT6DAU.js";
9
+ import "./chunk-IDWN2OSG.js";
10
10
  import "./chunk-47FFT43U.js";
11
11
  import "./chunk-NTDN54XO.js";
12
12
  import "./chunk-PVNMLZ5G.js";
@@ -18,8 +18,8 @@ import "./chunk-TNI4MARH.js";
18
18
  import "./chunk-4ERYQBL6.js";
19
19
  import {
20
20
  scanServerActionsEnriched
21
- } from "./chunk-GP6OJBXP.js";
22
- import "./chunk-KDP2HURW.js";
21
+ } from "./chunk-CPXIYCAY.js";
22
+ import "./chunk-FHQP23Z5.js";
23
23
  import "./chunk-DV34VG3N.js";
24
24
  import "./chunk-V6Y2SMRG.js";
25
25
  import "./chunk-ACKBVBUI.js";
@@ -234,4 +234,4 @@ export const actions = manifest
234
234
  export {
235
235
  actionsVirtualModule
236
236
  };
237
- //# sourceMappingURL=actions-virtual-module-SE44BKR4.js.map
237
+ //# sourceMappingURL=actions-virtual-module-ICWX5PZ2.js.map
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  import "tsx/esm";
3
- import "./chunk-G2NWAVGG.js";
4
- import "./chunk-UETVDZBE.js";
3
+ import "./chunk-5XXXJ6DT.js";
4
+ import "./chunk-BINRCILF.js";
5
5
  import "./chunk-QD5X56I3.js";
6
6
  import "./chunk-WSMLSIS5.js";
7
7
  import "./chunk-MS4A7N77.js";
8
8
  import "./chunk-C27VRUVN.js";
9
9
  import "./chunk-7UZZHCRN.js";
10
- import "./chunk-BCFA6LHL.js";
11
- import "./chunk-5NNFO7R7.js";
10
+ import "./chunk-GVJFVBCJ.js";
11
+ import "./chunk-R7G2B2WH.js";
12
12
  import {
13
13
  scanServerActionsEnriched
14
14
  } from "./chunk-NO6HA4FG.js";
@@ -218,4 +218,4 @@ export const actions = manifest
218
218
  export {
219
219
  actionsVirtualModule
220
220
  };
221
- //# sourceMappingURL=actions-virtual-module-3OPYLD76.js.map
221
+ //# sourceMappingURL=actions-virtual-module-LY6VGJZ2.js.map
@@ -1,9 +1,14 @@
1
1
  import { a as RouteSubject, R as RoutePolicy } from '../route-policy-BHXQDzBF.js';
2
2
  import { C as CsrfMode } from '../csrf-Dgot9qSM.js';
3
3
  export { r as resolveProvider } from '../provider-resolver-Cc9C3-Rb.js';
4
- export { s as scanAgents } from '../agent-scan-BZa-pagG.js';
5
- import 'node:http';
4
+ import { A as AgentNode } from '../agent-scan-BLXaFL6R.js';
5
+ export { s as scanAgents } from '../agent-scan-BLXaFL6R.js';
6
+ import { IncomingMessage, ServerResponse } from 'node:http';
7
+ import { P as PluginRunner } from '../plugin-runner-BVMOSxvb.js';
8
+ import { L as LoadModule } from '../module-loader-DCip7NoL.js';
6
9
  import '../audit-log-BQWM5YLG.js';
10
+ import '../plugin-types-BUVfUQ0V.js';
11
+ import 'vite';
7
12
 
8
13
  /**
9
14
  * ADR 0001, applied to the agent surface (usetheokit/theokit#365).
@@ -132,4 +137,187 @@ interface MountAgentOptions {
132
137
  */
133
138
  declare function mountAgent(mod: unknown, request: Request, apiKey: string | ApiKeyResolver, { source, csrfMode, projectRoot, agentName, policy, resolveSubject, }?: MountAgentOptions): Promise<Response>;
134
139
 
135
- export { mountAgent };
140
+ /** Dependencies the aux dispatcher needs from its caller (dev or prod). */
141
+ interface AuxRouteDeps {
142
+ /** Discovered agents (from `scanAgents`). */
143
+ agents: readonly AgentNode[];
144
+ /** Load an agent module from its file path (dev: vite loader; prod: dynamic import). */
145
+ loadModule: (filePath: string) => Promise<unknown>;
146
+ /** Absolute base URL (`http(s)://host`) for the agent-card endpoint URLs. */
147
+ baseUrl: string;
148
+ /**
149
+ * M34 (#97) — CSRF enforcement mode for the MCP route. `POST /api/agents/<name>/mcp` drives the
150
+ * agent (spends LLM tokens), so a cross-origin POST MUST be rejected in `'strict'` — parity with
151
+ * the agent-run route (`mount-agent.ts:83-91`). Defaults to `'strict'` (safe-by-default); a caller
152
+ * that already gated upstream may pass `'off'`.
153
+ */
154
+ csrfMode?: CsrfMode;
155
+ /**
156
+ * M39 — lazily resolve the provider apiKey. Required only for the thread
157
+ * follow-up route (which drives the agent); resolved on demand so non-agent
158
+ * aux routes (card, approvals, stream) never need a provider key.
159
+ *
160
+ * theokit#328 — it receives the model the agent declares, so the credential matches the provider
161
+ * the agent asked for. It was called with no argument, before the module was even compiled, so
162
+ * an agent declaring `anthropic/…` was handed whichever key env priority found first.
163
+ */
164
+ resolveApiKey?: ApiKeyResolver;
165
+ /**
166
+ * Who is asking (usetheokit/theokit#365). Invoked ONLY from {@link serveMatchedAuxRoute}, and only
167
+ * when the matched path's agent declares a policy — so the application's `createContext` never
168
+ * runs for a url this dispatcher merely declines. {@link matchAgentAuxRoute} is not given it, for
169
+ * the same reason it is not given the request body: deciding must cost nothing.
170
+ */
171
+ resolveSubject?: AgentSubjectResolver;
172
+ }
173
+ /**
174
+ * One aux route, already decided. Carries what the match resolved so the serve half re-derives
175
+ * nothing: the agent node it looked up, and for MCP the module it had to open in order to answer
176
+ * the opt-in question at all.
177
+ */
178
+ type AgentAuxRoute = {
179
+ readonly kind: 'card';
180
+ readonly agent: AgentNode;
181
+ } | {
182
+ readonly kind: 'approvals';
183
+ readonly agent: AgentNode;
184
+ } | {
185
+ readonly kind: 'run-stream';
186
+ readonly agent: AgentNode;
187
+ readonly runId: string;
188
+ } | {
189
+ readonly kind: 'thread-stream';
190
+ readonly agent: AgentNode;
191
+ readonly sessionId: string;
192
+ } | {
193
+ readonly kind: 'thread-message';
194
+ readonly agent: AgentNode;
195
+ readonly sessionId: string;
196
+ } | {
197
+ readonly kind: 'mcp';
198
+ readonly agent: AgentNode;
199
+ readonly mod: unknown;
200
+ };
201
+ /**
202
+ * Does this dispatcher own `urlPath`? Returns the matched route, or `null` to fall through (not an
203
+ * aux path, wrong method, unknown agent, or an agent that did not opt into MCP).
204
+ *
205
+ * theokit#400 — this function is where the "convert only on a path you are about to answer" rule
206
+ * now lives, and it is enforced by the signature rather than by discipline: it is handed a method
207
+ * and a url and has no request to convert. Converting in order to decide is what drained the Node
208
+ * body stream on every path this dispatcher declined, so an ordinary `POST /api/…` file route then
209
+ * waited forever for an `'end'` that had already fired — no status, no timeout, no response.
210
+ *
211
+ * The one branch that does real work here is MCP, which must open the module to read its
212
+ * `export const mcp` opt-in. That is deliberate: a match that could still fall through would hand
213
+ * the caller a request it had already started a lifecycle for, and the span opened for it would
214
+ * either double-count or never close.
215
+ */
216
+ declare function matchAgentAuxRoute(method: string, urlPath: string, deps: AuxRouteDeps): Promise<AgentAuxRoute | null>;
217
+ /**
218
+ * Answer a route {@link matchAgentAuxRoute} already claimed. Always returns a `Response` — every
219
+ * fall-through was decided upstream, which is what lets a caller open a request span before this
220
+ * runs and be sure something will close it.
221
+ */
222
+ declare function serveMatchedAuxRoute(route: AgentAuxRoute, request: Request, deps: AuxRouteDeps): Promise<Response>;
223
+
224
+ /**
225
+ * Who is asking, on the Node dispatch path that serves the agent endpoints
226
+ * (usetheokit/theokit#365).
227
+ *
228
+ * `executeRoute` answers this with `subjectFromContext(ctx)`, where `ctx` is the run context built
229
+ * from the application's `server/context.ts` plus plugin decorations. The agent branches build no
230
+ * such context — which is why `mountAgent`'s `subject` option had nowhere to come from and every
231
+ * caller left it out. This builds the same context from the same two sources, so the agent surface
232
+ * reads identity from the seam the routes already read it from rather than from a second one.
233
+ *
234
+ * ## Why it returns a resolver instead of a subject
235
+ *
236
+ * `tryServeAgentAux` runs for EVERY url, including the ones it does not own. Resolving eagerly
237
+ * there would execute the application's `createContext` twice on every route request — once in the
238
+ * aux branch that falls through, once in the route executor. So callers get a memoized thunk and
239
+ * invoke it only on a path they are about to answer, which is the same discipline theokit#400
240
+ * imposed on `source.toRequest()` for the same dispatcher.
241
+ *
242
+ * ## What `createContext` can read here, and what it cannot (usetheokit/theokit#415)
243
+ *
244
+ * **Headers and cookies: yes. The request body: no.**
245
+ *
246
+ * This used to state the opposite as a MUST — "invoke it before converting the request to a Web
247
+ * `Request`" — and no caller could honour it. The laziness argued for directly above is what makes
248
+ * it unsatisfiable: the invocation necessarily happens INSIDE the handler, and the handler is
249
+ * entered after `serveThroughPluginLifecycle` has already called `source.toRequest()` at the top of
250
+ * its bracket. `incomingMessageToWebRequest` attaches the Node readable as the request body
251
+ * (`body: webStream, duplex: 'half'`), so by the time an application's `createContext` receives
252
+ * that `IncomingMessage`, the stream is consumed.
253
+ *
254
+ * The contract was written for an EAGER resolver and kept when the resolver became lazy. Both
255
+ * decisions were right on their own; the sentence joining them was not, and it pointed callers at
256
+ * something impossible while implying a capability that does not exist.
257
+ *
258
+ * Practically this costs little — identity is overwhelmingly a header or a cookie, and both survive
259
+ * the conversion untouched. What it costs an application that resolves identity from the BODY is an
260
+ * empty read or a wait for an `'end'` that already fired, which is why saying so plainly matters
261
+ * more than the frequency suggests.
262
+ *
263
+ * Restoring body access would mean resolving eagerly — running the application's `createContext`
264
+ * twice on every route request, which is exactly what the laziness exists to prevent — or buffering
265
+ * every agent request body to replay it, which is a cost paid by every caller for a case almost
266
+ * none has.
267
+ */
268
+
269
+ /** What {@link createAgentSubjectResolver} needs in order to build the run context. */
270
+ interface AgentSubjectSources {
271
+ req: IncomingMessage;
272
+ res: ServerResponse;
273
+ loadModule: LoadModule;
274
+ /** The app's `server/` directory. Absent ⇒ there is no `context.ts` to consult. */
275
+ serverDir: string | undefined;
276
+ pluginRunner: PluginRunner | undefined;
277
+ }
278
+ /**
279
+ * Build a memoized resolver for the caller's identity.
280
+ *
281
+ * Decorations are applied ON TOP of the factory's result, matching `executeRoute`: a plugin
282
+ * decoration wins only where `context.ts` did not set the same key.
283
+ *
284
+ * A `createContext` that throws is not swallowed — an application whose identity resolution is
285
+ * broken must not be treated as an anonymous caller, because that reads as a clean refusal and
286
+ * hides the fault. The throw reaches the branch's own error handler and becomes a 500.
287
+ */
288
+ declare function createAgentSubjectResolver(sources: AgentSubjectSources): () => Promise<RouteSubject | null>;
289
+ /**
290
+ * The app's `createContext`, as a host that is not Node sees it.
291
+ *
292
+ * Deliberately NOT `middleware-runner`'s `ContextFactory`, which types its argument as
293
+ * `IncomingMessage`/`ServerResponse`. Those are exactly right for the dev path and wrong here: on
294
+ * every deploy target the pair is what `createWebShim` synthesises over a Web `Request`. Widening
295
+ * to `unknown` says what is actually true at this boundary rather than casting a lie past the
296
+ * type system — the app's own `createContext` is typed by the app, and a generated fragment is the
297
+ * one caller that cannot promise it Node objects.
298
+ */
299
+ type HostContextFactory = (args: {
300
+ request: unknown;
301
+ response: unknown;
302
+ }) => unknown;
303
+ /**
304
+ * The half that CALLS an already-resolved context factory (B-185, ADR 0014).
305
+ *
306
+ * {@link createAgentSubjectResolver} does two things: it LOCATES `context.ts` on a filesystem —
307
+ * `existsSync` plus `loadModule`, inside `createServerContext` — and then CALLS what it found. A
308
+ * deploy target with no filesystem can do the second and not the first, so the generator bakes the
309
+ * module as a static import (the way routes, agents and plugins already are) and hands the factory
310
+ * here directly.
311
+ *
312
+ * Measured before this existed: passing `serverDir: undefined` to the resolver above takes its
313
+ * `produced = {}` branch, never touches `req`/`res`/`loadModule`, and returns
314
+ * `subjectFromContext({})` — which is null for every caller. Satisfying its types would have
315
+ * satisfied nothing.
316
+ *
317
+ * `request`/`response` are whatever the host has. On every deploy target that is the
318
+ * `ShimRequest`/`ShimResponse` pair `createWebShim` synthesises over a Web `Request`, which is the
319
+ * same contract routes on those targets have crossed since they were baked.
320
+ */
321
+ declare function createSubjectResolverFromFactory(createContext: HostContextFactory | undefined, request: unknown, response: unknown, pluginRunner?: PluginRunner): () => Promise<RouteSubject | null>;
322
+
323
+ export { createAgentSubjectResolver, createSubjectResolverFromFactory, matchAgentAuxRoute, mountAgent, serveMatchedAuxRoute };
@@ -1,15 +1,26 @@
1
+ import {
2
+ createAgentSubjectResolver,
3
+ createSubjectResolverFromFactory,
4
+ matchAgentAuxRoute,
5
+ serveMatchedAuxRoute
6
+ } from "../chunk-3NAKOWTX.js";
1
7
  import {
2
8
  mountAgent
3
- } from "../chunk-GAJOZJWD.js";
9
+ } from "../chunk-SX7ZAHNE.js";
10
+ import "../chunk-4D4YVXHR.js";
4
11
  import "../chunk-P6OS7652.js";
5
- import "../chunk-ENRT6DAU.js";
12
+ import "../chunk-IDWN2OSG.js";
6
13
  import "../chunk-PVNMLZ5G.js";
7
14
  import "../chunk-ZDCCILMP.js";
8
15
  import "../chunk-CHTAWXC2.js";
9
16
  import "../chunk-AVQU5CQF.js";
10
17
  import {
11
18
  scanAgents
12
- } from "../chunk-KDP2HURW.js";
19
+ } from "../chunk-FHQP23Z5.js";
20
+ import "../chunk-V6Y2SMRG.js";
21
+ import "../chunk-ACKBVBUI.js";
22
+ import "../chunk-IZ3TIL6K.js";
23
+ import "../chunk-TQEE36VD.js";
13
24
  import {
14
25
  resolveProvider
15
26
  } from "../chunk-ICXXHV4V.js";
@@ -18,8 +29,12 @@ import "../chunk-SOYOYGWY.js";
18
29
  import "../chunk-ZWN3AODA.js";
19
30
  import "../chunk-XTHN6JBX.js";
20
31
  export {
32
+ createAgentSubjectResolver,
33
+ createSubjectResolverFromFactory,
34
+ matchAgentAuxRoute,
21
35
  mountAgent,
22
36
  resolveProvider,
23
- scanAgents
37
+ scanAgents,
38
+ serveMatchedAuxRoute
24
39
  };
25
40
  //# sourceMappingURL=agent-mount.js.map
@@ -57,6 +57,22 @@ export { b as buildSecurityHeaders } from '../security-headers-vris2MQq.js';
57
57
  * (`cli/commands/start/index.ts`). An app with no security block gets the same
58
58
  * baseline deployed as it gets locally.
59
59
  */
60
+ /**
61
+ * The two declarations every deploy entry emits to carry the security baseline.
62
+ *
63
+ * Four adapters wrote these same two lines — `netlify`, `vercel`, `aws-lambda`, `deno-deploy` —
64
+ * each under a comment naming its own host's static-asset boundary. The COMMENT differs and is
65
+ * meant to; the declarations do not.
66
+ *
67
+ * Extracted after SonarCloud's duplication gate failed a PR at 4.0% against a 3% ceiling and named
68
+ * this as the largest repeated block among the changed files. The gate was measuring something
69
+ * real: a literal renderer and a builder call, copied four times, is four places to update when
70
+ * either changes.
71
+ *
72
+ * Returns the lines rather than a joined string, because every caller splices them into an array
73
+ * of emitted lines.
74
+ */
75
+ declare function securityHeadersDeclarations(config: SecurityHeadersConfig | undefined): string[];
60
76
  declare function renderSecurityHeadersConfigLiteral(headers: SecurityHeadersConfig | undefined): string;
61
77
  /**
62
78
  * Put the headers on a response, without overruling the handler.
@@ -129,4 +145,4 @@ interface DeployedSecurityHeaderLimits {
129
145
  */
130
146
  declare function describeDeployedSecurityHeaders(limits: DeployedSecurityHeaderLimits): string;
131
147
 
132
- export { type DeployedSecurityHeaderLimits, describeDeployedSecurityHeaders, renderSecurityHeadersConfigLiteral, withSecurityHeaders };
148
+ export { type DeployedSecurityHeaderLimits, describeDeployedSecurityHeaders, renderSecurityHeadersConfigLiteral, securityHeadersDeclarations, withSecurityHeaders };
@@ -7,6 +7,12 @@ import {
7
7
  import "../chunk-XTHN6JBX.js";
8
8
 
9
9
  // src/adapters/security-headers.ts
10
+ function securityHeadersDeclarations(config) {
11
+ return [
12
+ `const SECURITY_HEADERS_CONFIG = ${renderSecurityHeadersConfigLiteral(config)}`,
13
+ `const SECURITY_HEADERS = buildSecurityHeaders(SECURITY_HEADERS_CONFIG, { production: true })`
14
+ ];
15
+ }
10
16
  function renderSecurityHeadersConfigLiteral(headers) {
11
17
  return JSON.stringify(headers ?? {});
12
18
  }
@@ -59,6 +65,7 @@ export {
59
65
  describeDeployedSecurityHeaders,
60
66
  generateNonce,
61
67
  renderSecurityHeadersConfigLiteral,
68
+ securityHeadersDeclarations,
62
69
  withSecurityHeaders
63
70
  };
64
71
  //# sourceMappingURL=security-headers.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/adapters/security-headers.ts"],"mappings":";;;;;;;;;AA8EO,SAAS,mCACd,SACQ;AACR,SAAO,KAAK,UAAU,WAAW,CAAC,CAAC;AACrC;AAyBO,SAAS,oBAAoB,UAAoB,SAA2C;AACjG,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,OAAO,GAAG;AAClD,QAAI,CAAC,SAAS,QAAQ,IAAI,GAAG,EAAG,UAAS,QAAQ,IAAI,KAAK,KAAK;AAAA,EACjE;AACA,SAAO;AACT;AAgDO,SAAS,gCAAgC,QAA8C;AAC5F,QAAM,UAAU,qBAAqB,OAAO,mBAAmB,CAAC,GAAG,EAAE,YAAY,KAAK,CAAC;AACvF,QAAM,QAAQ,OAAO,KAAK,OAAO;AACjC,MAAI,MAAM,WAAW,GAAG;AACtB,WAAO,SAAS,OAAO,MAAM;AAAA,EAC/B;AAEA,QAAM,QAAQ;AAAA,IACZ,iDAA4C,OAAO,MAAM,eAAe,MAAM,KAAK,IAAI,CAAC;AAAA,EAC1F;AACA,QAAM,WAAW,MAAM,KAAK,CAAC,SAAS,KAAK,WAAW,yBAAyB,CAAC;AAChF,MAAI,YAAY,CAAC,OAAO,YAAY;AAClC,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACA,MAAI,OAAO,oBAAoB,uBAAuB;AACpD,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACA,MAAI,OAAO,oBAAoB,sBAAsB;AACnD,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACA,SAAO,MAAM,KAAK,IAAI;AACxB;","names":[]}
1
+ {"version":3,"sources":["../../src/adapters/security-headers.ts"],"mappings":";;;;;;;;;AA6FO,SAAS,4BAA4B,QAAqD;AAC/F,SAAO;AAAA,IACL,mCAAmC,mCAAmC,MAAM,CAAC;AAAA,IAC7E;AAAA,EACF;AACF;AAEO,SAAS,mCACd,SACQ;AACR,SAAO,KAAK,UAAU,WAAW,CAAC,CAAC;AACrC;AAyBO,SAAS,oBAAoB,UAAoB,SAA2C;AACjG,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,OAAO,GAAG;AAClD,QAAI,CAAC,SAAS,QAAQ,IAAI,GAAG,EAAG,UAAS,QAAQ,IAAI,KAAK,KAAK;AAAA,EACjE;AACA,SAAO;AACT;AAgDO,SAAS,gCAAgC,QAA8C;AAC5F,QAAM,UAAU,qBAAqB,OAAO,mBAAmB,CAAC,GAAG,EAAE,YAAY,KAAK,CAAC;AACvF,QAAM,QAAQ,OAAO,KAAK,OAAO;AACjC,MAAI,MAAM,WAAW,GAAG;AACtB,WAAO,SAAS,OAAO,MAAM;AAAA,EAC/B;AAEA,QAAM,QAAQ;AAAA,IACZ,iDAA4C,OAAO,MAAM,eAAe,MAAM,KAAK,IAAI,CAAC;AAAA,EAC1F;AACA,QAAM,WAAW,MAAM,KAAK,CAAC,SAAS,KAAK,WAAW,yBAAyB,CAAC;AAChF,MAAI,YAAY,CAAC,OAAO,YAAY;AAClC,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACA,MAAI,OAAO,oBAAoB,uBAAuB;AACpD,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACA,MAAI,OAAO,oBAAoB,sBAAsB;AACnD,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACA,SAAO,MAAM,KAAK,IAAI;AACxB;","names":[]}
@@ -3,13 +3,13 @@ import "tsx/esm";
3
3
  import {
4
4
  agentCommand,
5
5
  createAgentSsrLoader
6
- } from "./chunk-FYYKMPST.js";
7
- import "./chunk-UETVDZBE.js";
8
- import "./chunk-5NNFO7R7.js";
6
+ } from "./chunk-MLF25NC4.js";
7
+ import "./chunk-BINRCILF.js";
8
+ import "./chunk-R7G2B2WH.js";
9
9
  import "./chunk-Z7CJHDLS.js";
10
10
  import "./chunk-3QPVEJ7D.js";
11
11
  export {
12
12
  agentCommand,
13
13
  createAgentSsrLoader
14
14
  };
15
- //# sourceMappingURL=agent-UBDDP2L5.js.map
15
+ //# sourceMappingURL=agent-7DQ3TKJY.js.map
@@ -0,0 +1,12 @@
1
+ /**
2
+ * A discovered agent file. `name` is the client-facing key; `agentPath` is the mounted
3
+ * SSE route (M0/M1 `UIMessageStream`).
4
+ */
5
+ interface AgentNode {
6
+ filePath: string;
7
+ agentPath: string;
8
+ name: string;
9
+ }
10
+ declare function scanAgents(projectRoot: string, configured?: string): AgentNode[];
11
+
12
+ export { type AgentNode as A, scanAgents as s };
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import "tsx/esm";
3
- import "./chunk-G2NWAVGG.js";
4
- import "./chunk-UETVDZBE.js";
3
+ import "./chunk-5XXXJ6DT.js";
4
+ import "./chunk-BINRCILF.js";
5
5
  import {
6
6
  scanControllerModules
7
7
  } from "./chunk-QD5X56I3.js";
@@ -11,8 +11,8 @@ import "./chunk-C27VRUVN.js";
11
11
  import "./chunk-7UZZHCRN.js";
12
12
  import {
13
13
  generateManifest
14
- } from "./chunk-BCFA6LHL.js";
15
- import "./chunk-5NNFO7R7.js";
14
+ } from "./chunk-GVJFVBCJ.js";
15
+ import "./chunk-R7G2B2WH.js";
16
16
  import {
17
17
  HTTP_METHODS
18
18
  } from "./chunk-NO6HA4FG.js";
@@ -411,4 +411,4 @@ export {
411
411
  generateClientDts,
412
412
  shouldReemitForFile
413
413
  };
414
- //# sourceMappingURL=app-typed-client-BE3PV3JY.js.map
414
+ //# sourceMappingURL=app-typed-client-2S76VTMB.js.map
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  scanControllerModules
3
- } from "./chunk-GDF2XQOO.js";
4
- import "./chunk-GAJOZJWD.js";
3
+ } from "./chunk-JMN4COMK.js";
4
+ import "./chunk-SX7ZAHNE.js";
5
5
  import "./chunk-WSOAN4KN.js";
6
6
  import "./chunk-ENSFCKP6.js";
7
- import "./chunk-Q7T3UQ4L.js";
7
+ import "./chunk-KOG5K26V.js";
8
+ import "./chunk-4D4YVXHR.js";
8
9
  import "./chunk-P6OS7652.js";
9
10
  import "./chunk-ZDUO4IYN.js";
10
- import "./chunk-7L7LQ2GU.js";
11
- import "./chunk-ENRT6DAU.js";
11
+ import "./chunk-IDWN2OSG.js";
12
12
  import "./chunk-47FFT43U.js";
13
13
  import "./chunk-NTDN54XO.js";
14
14
  import "./chunk-PVNMLZ5G.js";
@@ -20,8 +20,8 @@ import "./chunk-TNI4MARH.js";
20
20
  import "./chunk-4ERYQBL6.js";
21
21
  import {
22
22
  generateManifest
23
- } from "./chunk-GP6OJBXP.js";
24
- import "./chunk-KDP2HURW.js";
23
+ } from "./chunk-CPXIYCAY.js";
24
+ import "./chunk-FHQP23Z5.js";
25
25
  import {
26
26
  HTTP_METHODS
27
27
  } from "./chunk-DV34VG3N.js";
@@ -427,4 +427,4 @@ export {
427
427
  generateClientDts,
428
428
  shouldReemitForFile
429
429
  };
430
- //# sourceMappingURL=app-typed-client-RAFEBA7S.js.map
430
+ //# sourceMappingURL=app-typed-client-6YQREFRS.js.map
@@ -1,14 +1,18 @@
1
1
  #!/usr/bin/env node
2
2
  import "tsx/esm";
3
3
  import {
4
- deployedCorsFragment,
5
- deployedCsrfFragment,
4
+ deployedEntryPreamble
5
+ } from "./chunk-XG6SQUEP.js";
6
+ import {
7
+ JSON_NOT_FOUND_RESPONSE,
8
+ agentsDirLiteral,
9
+ deployedAgentsFragment,
6
10
  deployedRuntimeConfigFragment,
7
11
  deployedTraceFragment,
8
12
  describeDeployedSecurityHeaders,
9
- renderSecurityHeadersConfigLiteral,
13
+ scannedFromLoaderCache,
10
14
  serverDirLiteral
11
- } from "./chunk-6B3CMPE4.js";
15
+ } from "./chunk-FFGP2LGQ.js";
12
16
  import {
13
17
  nodeAdapter
14
18
  } from "./chunk-KI4DOTN4.js";
@@ -59,7 +63,7 @@ function responseToLambdaResultV2(statusCode, headers, body) {
59
63
  isBase64Encoded: isBinary
60
64
  };
61
65
  }
62
- function awsLambdaHandlerFragment(runtimeSpread) {
66
+ function awsLambdaHandlerFragment(runtimeSpread, agentsBranch, agentsHostBypass) {
63
67
  return [
64
68
  `// #382 \u2014 this target is DELISTED for response streaming, by construction.`,
65
69
  `// The Lambda v2 result object below carries \`body\` as a string, so the`,
@@ -119,7 +123,7 @@ function awsLambdaHandlerFragment(runtimeSpread) {
119
123
  `}`,
120
124
  ``,
121
125
  `async function routeRequest(event, path) {`,
122
- ` if (!path.startsWith('/api/')) {`,
126
+ ` if (!path.startsWith('/api/')${agentsHostBypass}) {`,
123
127
  ` return new Response(`,
124
128
  ` 'Static assets must be served from CloudFront or a separate static host.',`,
125
129
  ` { status: 404, headers: { 'content-type': 'text/plain' } },`,
@@ -129,15 +133,18 @@ function awsLambdaHandlerFragment(runtimeSpread) {
129
133
  ` if (!routesCache) routesCache = scanServerRoutes(serverDir)`,
130
134
  ` if (!loaderCache) loaderCache = createProductionLoader()`,
131
135
  ``,
136
+ // B-235 — hoisted above the agents branch, which names `request` like every other host's.
137
+ // It was declared below `matchRoute`, and an agent path never reaches a route match. Building
138
+ // it here costs nothing new: the outer handler already built one for the CORS matcher, and
139
+ // `eventV2ToRequest` reads a body the event already carries, so there is no stream to drain
140
+ // twice.
141
+ ` const request = eventV2ToRequest(event)`,
142
+ ``,
143
+ ...agentsBranch,
144
+ ``,
132
145
  ` const match = matchRoute(path, routesCache)`,
133
- ` if (!match) {`,
134
- ` return new Response(JSON.stringify({ error: { code: 'NOT_FOUND' } }), {`,
135
- ` status: 404,`,
136
- ` headers: { 'content-type': 'application/json' },`,
137
- ` })`,
138
- ` }`,
146
+ ` if (!match) return ${JSON_NOT_FOUND_RESPONSE}`,
139
147
  ``,
140
- ` const request = eventV2ToRequest(event)`,
141
148
  ` const { req, res, toResponse } = createWebShim(request)`,
142
149
  ...deployedTraceFragment("request", " "),
143
150
  ` const method = request.method.toUpperCase()`,
@@ -147,6 +154,10 @@ function awsLambdaHandlerFragment(runtimeSpread) {
147
154
  }
148
155
  function renderAwsLambdaEntry(opts = {}) {
149
156
  const runtimeConfig = deployedRuntimeConfigFragment(opts);
157
+ const agentsFragment = deployedAgentsFragment(scannedFromLoaderCache(agentsDirLiteral(opts)), {
158
+ pathname: "path",
159
+ notFound: JSON_NOT_FOUND_RESPONSE
160
+ });
150
161
  return [
151
162
  `// Generated by Theo \u2014 AWS Lambda Adapter`,
152
163
  `// Use with API Gateway HTTP API v2 (default).`,
@@ -166,14 +177,7 @@ function renderAwsLambdaEntry(opts = {}) {
166
177
  `// theo.config.ts to read. Non-API paths 404 here and the document is served`,
167
178
  `// from CloudFront or another static host, so this covers the API and not the`,
168
179
  `// page (usetheokit/theokit#412).`,
169
- `const SECURITY_HEADERS_CONFIG = ${renderSecurityHeadersConfigLiteral(opts.securityHeaders)}`,
170
- `const SECURITY_HEADERS = buildSecurityHeaders(SECURITY_HEADERS_CONFIG, { production: true })`,
171
- ``,
172
- ...runtimeConfig.imports,
173
- ...runtimeConfig.declarations,
174
- ...deployedCsrfFragment(opts),
175
- ``,
176
- ...deployedCorsFragment(opts.cors, "aws-lambda"),
180
+ ...deployedEntryPreamble(runtimeConfig, agentsFragment, opts, "aws-lambda"),
177
181
  ``,
178
182
  `function eventV2ToRequest(event) {`,
179
183
  ` const method = event.requestContext?.http?.method ?? 'GET'`,
@@ -196,7 +200,11 @@ function renderAwsLambdaEntry(opts = {}) {
196
200
  ` })`,
197
201
  `}`,
198
202
  ``,
199
- ...awsLambdaHandlerFragment(runtimeConfig.executeRouteSpread)
203
+ ...awsLambdaHandlerFragment(
204
+ runtimeConfig.executeRouteSpread,
205
+ agentsFragment.branch,
206
+ agentsFragment.hostBypass
207
+ )
200
208
  ].join("\n");
201
209
  }
202
210
  async function buildAwsLambda(config, cwd, deps = {}, ctx) {
@@ -213,6 +221,10 @@ async function buildAwsLambda(config, cwd, deps = {}, ctx) {
213
221
  ensureDir(outputDir);
214
222
  const entry = renderAwsLambdaEntry({
215
223
  securityHeaders: config.security?.headers,
224
+ // B-235 — pillar (a): the option existed and no build passed it, so a project with a
225
+ // configured agents directory got the default `agents` on this target. Same defect
226
+ // B-185 fixed for bun and deno, one target over.
227
+ agentsDir: config.agentsDir,
216
228
  csrf: config.security?.csrf,
217
229
  disallowed: config.security?.disallowed,
218
230
  cors: config.security?.cors,
@@ -259,4 +271,4 @@ export {
259
271
  renderAwsLambdaEntry,
260
272
  responseToLambdaResultV2
261
273
  };
262
- //# sourceMappingURL=aws-lambda-R76PWR27.js.map
274
+ //# sourceMappingURL=aws-lambda-OCJM5YGB.js.map