theokit 0.12.0 → 0.13.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 (131) hide show
  1. package/dist/{actions-virtual-module-SQDY3V5X.js → actions-virtual-module-3CDQTWOC.js} +6 -6
  2. package/dist/{actions-virtual-module-PNPRCEOS.js → actions-virtual-module-EIPXX4ZB.js} +3 -3
  3. package/dist/adapters/web-shim.d.ts +67 -0
  4. package/dist/adapters/ws-shim.d.ts +55 -0
  5. package/dist/agent-events-DosDXkSV.d.ts +94 -0
  6. package/dist/agents-typed-client-SAWAAH7K.js +142 -0
  7. package/dist/agents-typed-client-SAWAAH7K.js.map +1 -0
  8. package/dist/agents-typed-client-UTEQUA63.js +143 -0
  9. package/dist/agents-typed-client-UTEQUA63.js.map +1 -0
  10. package/dist/{app-typed-client-5GYEOYP3.js → app-typed-client-7PBFWZUE.js} +3 -3
  11. package/dist/{app-typed-client-QG7BVZYW.js → app-typed-client-CSOK7NPC.js} +6 -6
  12. package/dist/audit-log-BQWM5YLG.d.ts +60 -0
  13. package/dist/body-parser-web-FV5HWCY3.js +71 -0
  14. package/dist/body-parser-web-FV5HWCY3.js.map +1 -0
  15. package/dist/boot/index.d.ts +39 -0
  16. package/dist/{build-QFRLSEZ4.js → build-HXND27XG.js} +11 -11
  17. package/dist/{chunk-223EFY5X.js → chunk-2J7XU3PW.js} +68 -27
  18. package/dist/chunk-2J7XU3PW.js.map +1 -0
  19. package/dist/{chunk-RESN62GB.js → chunk-2KZQPDYR.js} +5 -48
  20. package/dist/chunk-2KZQPDYR.js.map +1 -0
  21. package/dist/chunk-3S3BNW5K.js +445 -0
  22. package/dist/chunk-3S3BNW5K.js.map +1 -0
  23. package/dist/{chunk-6FYD34NX.js → chunk-BQDGES7C.js} +28 -28
  24. package/dist/{chunk-6FYD34NX.js.map → chunk-BQDGES7C.js.map} +1 -1
  25. package/dist/chunk-EXP56GFQ.js +52 -0
  26. package/dist/chunk-EXP56GFQ.js.map +1 -0
  27. package/dist/chunk-F4YUPDJ2.js +115 -0
  28. package/dist/chunk-F4YUPDJ2.js.map +1 -0
  29. package/dist/{chunk-NAZ4E2GT.js → chunk-KXA37ONC.js} +2 -2
  30. package/dist/chunk-NHJMZCAS.js +32 -0
  31. package/dist/chunk-NHJMZCAS.js.map +1 -0
  32. package/dist/{chunk-43D6XNDR.js → chunk-O62MW4MT.js} +91 -18
  33. package/dist/chunk-O62MW4MT.js.map +1 -0
  34. package/dist/chunk-RSVN727G.js +1 -0
  35. package/dist/{chunk-7CBRKNQA.js → chunk-RYTZYFSD.js} +198 -6
  36. package/dist/chunk-RYTZYFSD.js.map +1 -0
  37. package/dist/chunk-UNLA45FY.js +235 -0
  38. package/dist/chunk-UNLA45FY.js.map +1 -0
  39. package/dist/{chunk-GFMQJHXX.js → chunk-WR4F4EEZ.js} +1082 -1074
  40. package/dist/chunk-WR4F4EEZ.js.map +1 -0
  41. package/dist/{chunk-AD74EAK3.js → chunk-ZSTZXR2D.js} +1 -30
  42. package/dist/chunk-ZSTZXR2D.js.map +1 -0
  43. package/dist/cli/index.js +5 -5
  44. package/dist/client/index.d.ts +418 -0
  45. package/dist/client/index.js +84 -3
  46. package/dist/client/index.js.map +1 -1
  47. package/dist/csrf-BBrEZSBW.d.ts +107 -0
  48. package/dist/csrf-readiness-store-CjIoub3U.d.ts +43 -0
  49. package/dist/define-websocket-CdK94O-D.d.ts +64 -0
  50. package/dist/{dev-GBXOTXUP.js → dev-OWW4XVIH.js} +10 -10
  51. package/dist/{dev-emit-FEFEDLZF.js → dev-emit-5MDSBP5D.js} +3 -3
  52. package/dist/{dev-emit-O4EGOSNV.js → dev-emit-QH2YGZXN.js} +2 -2
  53. package/dist/devtools/entry.d.ts +5 -0
  54. package/dist/error-envelope-BsNzzAV5.d.ts +62 -0
  55. package/dist/health-route-C0hk64_U.d.ts +57 -0
  56. package/dist/index-B40qUSrQ.d.ts +575 -0
  57. package/dist/index.d.ts +361 -0
  58. package/dist/index.js +6 -4
  59. package/dist/index.js.map +1 -1
  60. package/dist/internal-api-4YTJDITC.js +83 -0
  61. package/dist/internal-api-EFKZWIYZ.js +66 -0
  62. package/dist/internal-api-EFKZWIYZ.js.map +1 -0
  63. package/dist/job-backend-CgC8Xf33.d.ts +68 -0
  64. package/dist/match-CfbEFRG4.d.ts +26 -0
  65. package/dist/{openapi-VR6AFBLJ.js → openapi-FHY6HC6I.js} +7 -7
  66. package/dist/plugin-runner-BGBkzgi0.d.ts +95 -0
  67. package/dist/plugin-types-DNJGxr4Z.d.ts +79 -0
  68. package/dist/rate-limit-BdNDZ3vt.d.ts +58 -0
  69. package/dist/rate-limit-store-BEJnhWdw.d.ts +72 -0
  70. package/dist/react-query/index.d.ts +33 -0
  71. package/dist/{registry-Q2TZQLUH.js → registry-34LL7NF4.js} +1 -1
  72. package/dist/{routes-LRYOIIAI.js → routes-EW7TP7NJ.js} +2 -2
  73. package/dist/schema-BpH6ivDY.d.ts +74 -0
  74. package/dist/server/agent/index.d.ts +229 -0
  75. package/dist/server/agent/index.js +2 -1
  76. package/dist/server/auth/index.d.ts +419 -0
  77. package/dist/server/cost/index.d.ts +177 -0
  78. package/dist/server/cron/index.d.ts +208 -0
  79. package/dist/server/define/index.d.ts +313 -0
  80. package/dist/server/define/index.js +4 -2
  81. package/dist/server/http/index.d.ts +11 -0
  82. package/dist/server/index.d.ts +848 -0
  83. package/dist/server/index.js +9 -294
  84. package/dist/server/index.js.map +1 -1
  85. package/dist/server/jobs/index.d.ts +348 -0
  86. package/dist/server/observability/index.d.ts +324 -0
  87. package/dist/server/plugins/index.d.ts +17 -0
  88. package/dist/server/rate-limit/index.d.ts +105 -0
  89. package/dist/server/realtime/index.d.ts +15 -0
  90. package/dist/server/scan/index.d.ts +126 -0
  91. package/dist/server/scan/index.js +1 -1
  92. package/dist/server/security/index.d.ts +193 -0
  93. package/dist/server/storage/index.d.ts +22 -0
  94. package/dist/server/webhook/index.d.ts +148 -0
  95. package/dist/{start-3ZHAXSJE.js → start-KIQ5TTLR.js} +76 -13
  96. package/dist/start-KIQ5TTLR.js.map +1 -0
  97. package/dist/storage-manager-C4jsO0Tp.d.ts +89 -0
  98. package/dist/storage-types-DsDTCPbp.d.ts +96 -0
  99. package/dist/vite-plugin/index.d.ts +115 -0
  100. package/dist/vite-plugin/index.js +6 -4
  101. package/dist/{vite-plugin-WO72VLYR.js → vite-plugin-RK66K26Z.js} +7 -7
  102. package/dist/vite-plugin-RK66K26Z.js.map +1 -0
  103. package/package.json +4 -4
  104. package/dist/chunk-223EFY5X.js.map +0 -1
  105. package/dist/chunk-3LVRAGAZ.js +0 -73
  106. package/dist/chunk-3LVRAGAZ.js.map +0 -1
  107. package/dist/chunk-43D6XNDR.js.map +0 -1
  108. package/dist/chunk-7CBRKNQA.js.map +0 -1
  109. package/dist/chunk-AD74EAK3.js.map +0 -1
  110. package/dist/chunk-GFMQJHXX.js.map +0 -1
  111. package/dist/chunk-PBEH6NXR.js +0 -44
  112. package/dist/chunk-PBEH6NXR.js.map +0 -1
  113. package/dist/chunk-PIVX3DYW.js +0 -142
  114. package/dist/chunk-PIVX3DYW.js.map +0 -1
  115. package/dist/chunk-PPPR5DGR.js +0 -1
  116. package/dist/chunk-RESN62GB.js.map +0 -1
  117. package/dist/start-3ZHAXSJE.js.map +0 -1
  118. /package/dist/{actions-virtual-module-SQDY3V5X.js.map → actions-virtual-module-3CDQTWOC.js.map} +0 -0
  119. /package/dist/{actions-virtual-module-PNPRCEOS.js.map → actions-virtual-module-EIPXX4ZB.js.map} +0 -0
  120. /package/dist/{app-typed-client-5GYEOYP3.js.map → app-typed-client-7PBFWZUE.js.map} +0 -0
  121. /package/dist/{app-typed-client-QG7BVZYW.js.map → app-typed-client-CSOK7NPC.js.map} +0 -0
  122. /package/dist/{build-QFRLSEZ4.js.map → build-HXND27XG.js.map} +0 -0
  123. /package/dist/{chunk-NAZ4E2GT.js.map → chunk-KXA37ONC.js.map} +0 -0
  124. /package/dist/{chunk-PPPR5DGR.js.map → chunk-RSVN727G.js.map} +0 -0
  125. /package/dist/{dev-GBXOTXUP.js.map → dev-OWW4XVIH.js.map} +0 -0
  126. /package/dist/{dev-emit-FEFEDLZF.js.map → dev-emit-5MDSBP5D.js.map} +0 -0
  127. /package/dist/{dev-emit-O4EGOSNV.js.map → dev-emit-QH2YGZXN.js.map} +0 -0
  128. /package/dist/{vite-plugin-WO72VLYR.js.map → internal-api-4YTJDITC.js.map} +0 -0
  129. /package/dist/{openapi-VR6AFBLJ.js.map → openapi-FHY6HC6I.js.map} +0 -0
  130. /package/dist/{registry-Q2TZQLUH.js.map → registry-34LL7NF4.js.map} +0 -0
  131. /package/dist/{routes-LRYOIIAI.js.map → routes-EW7TP7NJ.js.map} +0 -0
@@ -0,0 +1,313 @@
1
+ import { z } from 'zod';
2
+ import { A as AgentEvent } from '../../agent-events-DosDXkSV.js';
3
+ import { UIMessageChunk } from 'ai';
4
+ import { b as WebSocketLike } from '../../define-websocket-CdK94O-D.js';
5
+ export { W as WebSocketHandler, a as WebSocketHandlerWeb, d as defineWebSocket, c as defineWebSocketWeb } from '../../define-websocket-CdK94O-D.js';
6
+ import { IncomingMessage } from 'node:http';
7
+ import { T as TheoPlugin } from '../../plugin-types-DNJGxr4Z.js';
8
+ export { H as HEALTH_PATH, a as HealthRouteConfig, b as READY_PATH, c as ReadyRouteConfig, d as ReservedResponse, R as ReservedRoutes, e as defineHealthRoute, f as defineReadyRoute, s as serveReservedRoute } from '../../health-route-C0hk64_U.js';
9
+
10
+ /**
11
+ * core/contracts/route-config.ts
12
+ *
13
+ * Canonical home for `RouteConfig<TQuery, TBody, TParams, TCtx, TResponse>` —
14
+ * the contract shape consumed by `defineRoute()` (server) and
15
+ * `defineCachedRoute()` (cache).
16
+ *
17
+ * Moved here in T2.2 of architecture-cleanup so `cache → core/contracts`
18
+ * is the legal edge (replacing the prior `cache → server` violation).
19
+ *
20
+ * GAP-4 (plan v1.1): the 5-arity generic shape `<TQuery, TBody, TParams, TCtx, TResponse>`
21
+ * MUST be preserved byte-by-byte. Type tests assert this in
22
+ * `tests/unit/route-config-generic-arity.test.ts`.
23
+ */
24
+
25
+ interface RouteConfig<TQuery extends z.ZodType = z.ZodUndefined, TBody extends z.ZodType = z.ZodUndefined, TParams extends z.ZodType = z.ZodUndefined, TCtx = unknown, TResponse = unknown> {
26
+ query?: TQuery;
27
+ body?: TBody;
28
+ params?: TParams;
29
+ status?: number;
30
+ /**
31
+ * Optional Zod schema for the handler's plain-object return value. When
32
+ * present, BOTH runtimes (Node `executeRoute` + Web `executeWebRequest`)
33
+ * validate the handler's plain-object return against it BEFORE serializing.
34
+ *
35
+ * A mismatch is a SERVER fault (the handler violated its own declared
36
+ * contract) → 500 `INTERNAL_SERVER_ERROR`, distinct from the 400 used for
37
+ * input (`query`/`body`/`params`) validation failures.
38
+ *
39
+ * `Response`-instance returns (and `undefined`/`null` → 204) are NOT
40
+ * validated. This is a plain optional field — runtime validation only; the
41
+ * handler return type is NOT statically inferred from `response` (YAGNI).
42
+ */
43
+ response?: z.ZodType;
44
+ /**
45
+ * Opt out of CSRF enforcement for this route. Use for endpoints that
46
+ * legitimately receive third-party POSTs (Stripe webhooks, GitHub
47
+ * webhooks, OAuth callbacks). Defaults to enforced per `config.security.csrf`.
48
+ *
49
+ * Setting `csrf: false` only disables the per-route check — it does NOT
50
+ * disable the global mode setting for other routes.
51
+ */
52
+ csrf?: false;
53
+ handler: (ctx: {
54
+ query: z.infer<TQuery>;
55
+ body: z.infer<TBody>;
56
+ params: z.infer<TParams>;
57
+ request: Request;
58
+ ctx: TCtx;
59
+ }) => TResponse | Promise<TResponse>;
60
+ }
61
+
62
+ /**
63
+ * Define a typed HTTP route.
64
+ * Identity function — provides type inference for route handlers.
65
+ */
66
+ declare function defineRoute<TQuery extends z.ZodType = z.ZodUndefined, TBody extends z.ZodType = z.ZodUndefined, TParams extends z.ZodType = z.ZodUndefined, TCtx = unknown, TResponse = unknown>(config: RouteConfig<TQuery, TBody, TParams, TCtx, TResponse>): RouteConfig<TQuery, TBody, TParams, TCtx, TResponse>;
67
+
68
+ /**
69
+ * Action wire-protocol accept mode per plan g3-server-actions-and-useaction
70
+ * v1.2 ADR D1. Default behavior (when omitted) is `'json'`. `'form'` opts the
71
+ * action into FormData multipart parsing for progressive-enhancement forms;
72
+ * the runtime in `server/http/action-execute.ts` will coerce FormData entries
73
+ * against the `input` schema via `formDataToObject` (Astro pattern).
74
+ */
75
+ type ActionAccept = 'form' | 'json';
76
+ interface ActionConfig<TInput extends z.ZodType, TCtx = unknown> {
77
+ /**
78
+ * Zod input schema. Required: every action declares its input contract via
79
+ * Zod (architecture rule: zod-is-SSOT). The shape becomes the handler's
80
+ * typed `input` parameter via `z.infer<TInput>`.
81
+ */
82
+ input: TInput;
83
+ /**
84
+ * Wire-protocol accept mode. Defaults to `'json'` when omitted. Setting
85
+ * `'form'` switches the runtime to FormData multipart parsing — the input
86
+ * schema MUST be `z.object(...)` so field-by-field coercion can drive
87
+ * boolean string / number / array coercion (Astro pattern).
88
+ */
89
+ accept?: ActionAccept;
90
+ /**
91
+ * Opt OUT of CSRF enforcement for this action. Default (omitted) keeps the
92
+ * multi-header CSRF gate active. Set `false` for endpoints intentionally
93
+ * callable without the `X-Theo-Action` header (e.g. public webhooks). The
94
+ * runtime in `server/http/action-execute.ts` reads this flag.
95
+ */
96
+ csrf?: false;
97
+ handler: (ctx: {
98
+ input: z.infer<TInput>;
99
+ ctx: TCtx;
100
+ }) => unknown;
101
+ }
102
+ /**
103
+ * Define a typed server action.
104
+ *
105
+ * Identity function — provides type inference for action handlers. The
106
+ * runtime that consumes the config (validation + invocation + serialization)
107
+ * lives in `server/http/action-execute.ts`.
108
+ *
109
+ * Per plan g3-server-actions-and-useaction v1.2 § Phase 1 / T1.2: the new
110
+ * `accept?: 'form' | 'json'` field is the only contract change vs the
111
+ * pre-G3 identity. Existing callsites (`defineAction({input, handler})`)
112
+ * continue to compile — `accept` is opt-in.
113
+ */
114
+ declare function defineAction<TInput extends z.ZodType, TCtx = unknown>(config: ActionConfig<TInput, TCtx>): ActionConfig<TInput, TCtx>;
115
+
116
+ type MiddlewareHandler = (request: Request, next: (request: Request) => Promise<Response>) => Response | Promise<Response>;
117
+ /**
118
+ * Define a middleware handler.
119
+ * Identity function — provides type annotation for middleware.
120
+ */
121
+ declare function defineMiddleware(handler: MiddlewareHandler): MiddlewareHandler;
122
+
123
+ /**
124
+ * T5.1 — defineAgentEndpoint
125
+ *
126
+ * Sugar over defineRoute (ADR D4). Accepts an async generator that yields
127
+ * AgentEvents and produces a RouteConfig whose handler returns a Response
128
+ * streaming Server-Sent Events (SSE).
129
+ *
130
+ * Wire format: `data: <JSON>\n\n` per event. Standards-compliant.
131
+ *
132
+ * The generator may throw — the wrapper catches and emits a final
133
+ * `{ type: 'error', message }` event before closing the stream.
134
+ *
135
+ * The wrapper observes `request.signal` (EC-7) — when aborted, the
136
+ * underlying generator is told to `return()` and the stream closes
137
+ * promptly.
138
+ *
139
+ * Note (EC-12, Out of Scope): SSE backpressure (slow consumer) is not
140
+ * handled here. For high-frequency token streaming consider a different
141
+ * transport (WS) or a buffer policy. This MVP enqueues each event
142
+ * immediately.
143
+ */
144
+ interface AgentEndpointHandlerArgs<TCtx = unknown, TBody = unknown, TParams extends z.ZodType = z.ZodUndefined> {
145
+ query: undefined;
146
+ body: TBody;
147
+ params: z.infer<TParams>;
148
+ request: Request;
149
+ ctx: TCtx;
150
+ /**
151
+ * Mutable headers bag that the wrapper merges into the SSE response BEFORE
152
+ * the stream starts. Used by `createConversationHistory` to issue a
153
+ * conversation-id cookie on first request. Append entries via
154
+ * `cookieHeaders.append('set-cookie', '<cookie-string>')`.
155
+ *
156
+ * Cookies appended AFTER the first yield are NOT applied — the response
157
+ * headers commit when the wrapper constructs the Response, before the
158
+ * async generator runs. This is per HTTP semantics, not a wrapper choice.
159
+ */
160
+ cookieHeaders: Headers;
161
+ /**
162
+ * Phase 3 (Production-Readiness #5) — request abort signal.
163
+ *
164
+ * Fires when the SSE client disconnects (browser closes tab, abort fetch,
165
+ * etc.). Thread this to `agent.send(msg, { signal })` so the SDK cancels
166
+ * the in-flight provider call — STOPS TOKENS FROM CHARGING for output
167
+ * the user will never receive.
168
+ *
169
+ * EC-1 (MUST FIX): the signal is derived via duck-type detection
170
+ * (`'aborted' in r.signal && typeof r.signal.addEventListener === 'function'`)
171
+ * to survive cross-realm scenarios (Node 18 polyfills, undici, Edge
172
+ * runtimes with their own AbortSignal globals). `instanceof AbortSignal`
173
+ * would fail in those cases.
174
+ */
175
+ signal: AbortSignal;
176
+ }
177
+ interface AgentEndpointConfig<TCtx = unknown, TBody = unknown, TParams extends z.ZodType = z.ZodUndefined> {
178
+ /**
179
+ * Optional Zod schema for path params (e.g. `z.object({ id: z.string() })`).
180
+ * When present, the runner validates path params and returns 400 on mismatch
181
+ * BEFORE the generator runs; the validated params are threaded to the
182
+ * generator typed as `z.infer<TParams>` (D4).
183
+ */
184
+ params?: TParams;
185
+ handler: (args: AgentEndpointHandlerArgs<TCtx, TBody, TParams>) => AsyncGenerator<AgentEvent, void, unknown>;
186
+ }
187
+ declare function defineAgentEndpoint<TBody = unknown, TCtx = unknown, TParams extends z.ZodType = z.ZodUndefined>(config: AgentEndpointConfig<TCtx, TBody, TParams>): RouteConfig<z.ZodUndefined, z.ZodUndefined, TParams, TCtx, Response>;
188
+
189
+ declare function uiMessageStreamResponse(chunks: AsyncIterable<UIMessageChunk>): Response;
190
+
191
+ /**
192
+ * Item #4 — `defineAgentTool`
193
+ *
194
+ * Sugar over the `@theokit/sdk` `CustomTool` contract. Takes a Zod schema +
195
+ * handler and produces a structurally-compatible `CustomTool` that
196
+ * `Agent.create({ tools: [...] })` accepts.
197
+ *
198
+ * Uses Zod v4's native `z.toJSONSchema()` to convert the input schema to
199
+ * JSON Schema for LLM providers.
200
+ *
201
+ * Handler error propagation:
202
+ * `defineAgentTool` parses the input via the Zod schema BEFORE calling the
203
+ * user handler. Invalid input throws a `ZodError`, which the SDK's tool-
204
+ * dispatcher (or the `streamAgentRun` adapter) sees as a tool failure and
205
+ * surfaces as an `error` AgentEvent on the SSE wire (ADR D3).
206
+ */
207
+ /**
208
+ * Local mirror of the SDK's `CustomTool` interface. We don't `import type`
209
+ * from `@theokit/sdk` because the SDK is an optional peer (consumers who
210
+ * never call `defineAgentTool` shouldn't need it installed). The shape is
211
+ * the wire contract; any structurally-matching object is accepted by
212
+ * `Agent.create({ tools })`.
213
+ *
214
+ * @public
215
+ */
216
+ interface CustomTool {
217
+ name: string;
218
+ description: string;
219
+ inputSchema: Record<string, unknown>;
220
+ handler: (input: Record<string, unknown>) => string | Promise<string>;
221
+ }
222
+ /**
223
+ * Spec accepted by {@link defineAgentTool}. `inputSchema` is a Zod 3 schema
224
+ * rooted in `z.object(...)`. The `handler` argument type is inferred via
225
+ * `z.infer<T>`.
226
+ *
227
+ * @public
228
+ */
229
+ interface DefineAgentToolSpec<T extends z.ZodType> {
230
+ /** Tool name surfaced to the LLM. Must match `^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`. */
231
+ name: string;
232
+ /** Description surfaced to the LLM. Required — drives tool-selection accuracy. */
233
+ description: string;
234
+ /** Zod schema describing the input. Must be `z.object(...)` at the root. */
235
+ inputSchema: T;
236
+ /** Handler invoked with the parsed input. */
237
+ handler: (input: z.infer<T>) => string | Promise<string>;
238
+ }
239
+ /**
240
+ * Build a {@link CustomTool} from a Zod 3 schema + handler.
241
+ *
242
+ * Behavior:
243
+ * - Validates `name` matches the LLM tool-name regex.
244
+ * - Requires `inputSchema` to be a `ZodObject` (Anthropic + SDK contract).
245
+ * - Warns (not throws) if `description` is empty — empty descriptions
246
+ * degrade LLM tool selection.
247
+ * - Converts the Zod schema to JSON Schema 7 inline (no `$ref`s — LLMs handle
248
+ * inline schemas more reliably).
249
+ * - Strips the top-level `$schema` field (Anthropic rejects schemas with
250
+ * `$schema` at root in some provider modes).
251
+ * - Wraps the handler to parse the input via the Zod schema BEFORE invoking
252
+ * the user code — bad LLM-supplied input throws `ZodError`, which the SDK
253
+ * converts to `tool_result(isError)`.
254
+ *
255
+ * @public
256
+ */
257
+ declare function defineAgentTool<T extends z.ZodType>(spec: DefineAgentToolSpec<T>): CustomTool;
258
+
259
+ interface ChannelHandler<TMessage = unknown> {
260
+ onSubscribe?: (ws: WebSocketLike, room: string, req: IncomingMessage) => void;
261
+ onMessage?: (ws: WebSocketLike, room: string, data: TMessage) => void;
262
+ onUnsubscribe?: (ws: WebSocketLike, room: string) => void;
263
+ }
264
+ /**
265
+ * Define a channel handler for WebSocket rooms.
266
+ * Identity function — provides type inference for channel handlers.
267
+ */
268
+ declare function defineChannel<TMessage = unknown>(handler: ChannelHandler<TMessage>): ChannelHandler<TMessage>;
269
+ /**
270
+ * T5a.2 Phase F slice 2/3 — Web-Standards channel handler.
271
+ *
272
+ * Mirror of `ChannelHandler<TMessage>` for the Web `Request` shape.
273
+ * `onSubscribe` receives `request: Request` instead of `req: IncomingMessage`
274
+ * — the rest of the surface (onMessage, onUnsubscribe) is shape-agnostic
275
+ * (WebSocketLike is already Web-standards-compatible per `define-websocket.ts`).
276
+ *
277
+ * Per `docs/plans/t5a2-incoming-message-to-request-shape-refactor-plan.md`
278
+ * v1.0 § Phase F.
279
+ *
280
+ * **Architectural note:** WebSocket upgrade semantics differ across
281
+ * runtimes:
282
+ * - Node: `WebSocketServer.handleUpgrade(req, socket, head, cb)` —
283
+ * hands you `req: IncomingMessage` at the upgrade handshake.
284
+ * - CF Workers: `new WebSocketPair()` + `request.headers` (the upgrade
285
+ * handshake IS a Web Request) — hands you `request: Request`.
286
+ * - Bun: `server.upgrade(request, { data })` — same Web Request shape.
287
+ * - Deno: `Deno.upgradeWebSocket(request)` — same Web Request shape.
288
+ *
289
+ * Channel handlers targeting CF/Bun/Deno use `WebChannelHandler`; legacy
290
+ * Node consumers stay on `ChannelHandler`. Cross-runtime channels ship
291
+ * both shapes.
292
+ */
293
+ interface WebChannelHandler<TMessage = unknown> {
294
+ onSubscribe?: (ws: WebSocketLike, room: string, request: Request) => void;
295
+ onMessage?: (ws: WebSocketLike, room: string, data: TMessage) => void;
296
+ onUnsubscribe?: (ws: WebSocketLike, room: string) => void;
297
+ }
298
+ /**
299
+ * Web-Standards `defineChannel` sibling. Identity function — provides
300
+ * type inference for Web channel handlers.
301
+ */
302
+ declare function defineWebChannel<TMessage = unknown>(handler: WebChannelHandler<TMessage>): WebChannelHandler<TMessage>;
303
+
304
+ /**
305
+ * Identity function for defining a Theo plugin.
306
+ *
307
+ * **Note:** Prefer `definePlugin` (shorter, canonical name per ADR-0008 D6).
308
+ * Both functions are identical — `defineTheoPlugin` is kept as an alias for
309
+ * existing in-tree consumers without forcing a migration sweep.
310
+ */
311
+ declare function defineTheoPlugin(plugin: TheoPlugin): TheoPlugin;
312
+
313
+ export { type ActionAccept, type ActionConfig, type AgentEndpointConfig, type AgentEndpointHandlerArgs, type ChannelHandler, type CustomTool, type DefineAgentToolSpec, type MiddlewareHandler, type RouteConfig, type WebChannelHandler, WebSocketLike, defineAction, defineAgentEndpoint, defineAgentTool, defineChannel, defineMiddleware, defineRoute, defineTheoPlugin, defineWebChannel, uiMessageStreamResponse };
@@ -8,9 +8,11 @@ import {
8
8
  defineTheoPlugin,
9
9
  defineWebChannel,
10
10
  defineWebSocket,
11
- defineWebSocketWeb,
11
+ defineWebSocketWeb
12
+ } from "../../chunk-ZSTZXR2D.js";
13
+ import {
12
14
  uiMessageStreamResponse
13
- } from "../../chunk-AD74EAK3.js";
15
+ } from "../../chunk-NHJMZCAS.js";
14
16
  import {
15
17
  HEALTH_PATH,
16
18
  READY_PATH,
@@ -0,0 +1,11 @@
1
+ export { B as BATCH_PATH, a as BatchExecuteFn, b as BatchPathConflictError, c as BatchPayload, d as BatchRequestItem, e as BatchResponse, f as BatchResultItem, C as CookieOptions, g as CorsConfig, h as CorsHandler, i as CorsOrigin, j as CorsWebHandler, k as CustomErrorPages, E as ExecuteActionOptions, l as ExecuteRouteContext, H as HandleBatchOptions, M as MAX_ERROR_HTML_BYTES, m as MiddlewareResult, N as NotFoundError, S as STRIPPED_HEADERS, n as SendErrorInput, o as SendErrorOptions, T as TRACE_HEADER, p as TRACE_PARENT_HEADER, q as TheoError, _ as _resetMiddlewareCacheForTests, s as appendCookieToHeaders, t as appendDeleteCookieToHeaders, u as createCorsHandler, v as createCorsWebHandler, w as deleteCookie, x as envelopeCodeToStatus, y as executeAction, z as executeRoute, A as extractTraceId, D as extractTraceIdFromRequest, F as fromUnknown, G as getCookie, I as getCookieFromRequest, J as handleBatchRequest, K as handleRequestError, L as handleWebRequestError, P as loadCustomErrorPages, Q as matchesOrigin, R as parseCookieHeader, U as parseTraceparent, W as runMiddlewareAndContext, X as sendError, Y as sendJson, Z as serializeCookie, $ as serveStaticFile, a0 as serverErrorToEnvelope, a1 as setCookie } from '../../index-B40qUSrQ.js';
2
+ import '../../error-envelope-BsNzzAV5.js';
3
+ import 'node:http';
4
+ import '../../plugin-types-DNJGxr4Z.js';
5
+ import '../../plugin-runner-BGBkzgi0.js';
6
+ import '../../job-backend-CgC8Xf33.js';
7
+ import '../../match-CfbEFRG4.js';
8
+ import 'vite';
9
+ import '../../csrf-BBrEZSBW.js';
10
+ import '../../audit-log-BQWM5YLG.js';
11
+ import 'zod';