theokit 0.6.1 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{actions-virtual-module-4WVKHQ2X.js → actions-virtual-module-52C6RKDK.js} +4 -3
- package/dist/{actions-virtual-module-LTOXBSCF.js.map → actions-virtual-module-52C6RKDK.js.map} +1 -1
- package/dist/{actions-virtual-module-LTOXBSCF.js → actions-virtual-module-TESQ2T4F.js} +9 -7
- package/dist/{actions-virtual-module-4WVKHQ2X.js.map → actions-virtual-module-TESQ2T4F.js.map} +1 -1
- package/dist/{app-typed-client-SAETWZT5.js → app-typed-client-A4CP55NM.js} +4 -3
- package/dist/{app-typed-client-SAETWZT5.js.map → app-typed-client-A4CP55NM.js.map} +1 -1
- package/dist/{app-typed-client-4N5OGNOQ.js → app-typed-client-AJ65YXJM.js} +9 -7
- package/dist/{app-typed-client-4N5OGNOQ.js.map → app-typed-client-AJ65YXJM.js.map} +1 -1
- package/dist/boot/index.d.ts +39 -0
- package/dist/boot/index.js +35 -0
- package/dist/boot/index.js.map +1 -0
- package/dist/{build-KQD2EDU4.js → build-S73OUGYP.js} +2 -2
- package/dist/{chunk-CBGRFVF5.js → chunk-256WFVQQ.js} +2 -2
- package/dist/{chunk-4I47JW5O.js → chunk-2DXLN7FF.js} +5 -5
- package/dist/{chunk-6BUUZ2PK.js → chunk-4EL6OX3P.js} +1 -1
- package/dist/{chunk-6VSKLYT6.js → chunk-7BJ6YLKV.js} +19 -19
- package/dist/{chunk-3FYJ7R7N.js → chunk-BB4ISKOB.js} +93 -78
- package/dist/chunk-BB4ISKOB.js.map +1 -0
- package/dist/{chunk-3IOFTG3L.js → chunk-OPLICDUB.js} +1 -1
- package/dist/{server-error-to-envelope-UJK6OWDJ.js → chunk-UVXB2ER7.js} +42 -5
- package/dist/chunk-UVXB2ER7.js.map +1 -0
- package/dist/chunk-V3LJN2GS.js +38 -0
- package/dist/chunk-V3LJN2GS.js.map +1 -0
- package/dist/{chunk-Z5IGLBWE.js → chunk-WFNLNIJX.js} +1 -1
- package/dist/{chunk-TQYSPYKU.js → chunk-WS67ONGI.js} +4 -1
- package/dist/chunk-WS67ONGI.js.map +1 -0
- package/dist/chunk-X32XEJXR.js +35 -0
- package/dist/chunk-X32XEJXR.js.map +1 -0
- package/dist/{chunk-MV4LKTW6.js → chunk-Z374WCMZ.js} +55 -9
- package/dist/chunk-Z374WCMZ.js.map +1 -0
- package/dist/cli/index.js +3 -3
- package/dist/client/index.d.ts +77 -3
- package/dist/client/index.js +111 -3
- package/dist/client/index.js.map +1 -1
- package/dist/{dev-NDEZA2MP.js → dev-WLUBGVDM.js} +5 -4
- package/dist/{dev-NDEZA2MP.js.map → dev-WLUBGVDM.js.map} +1 -1
- package/dist/health-route-C0hk64_U.d.ts +57 -0
- package/dist/{index-DWZF8uQD.d.ts → index-B40qUSrQ.d.ts} +178 -2
- package/dist/index.js +10 -8
- package/dist/index.js.map +1 -1
- package/dist/server/auth/index.js +1 -1
- package/dist/server/define/index.d.ts +1 -0
- package/dist/server/define/index.js +14 -2
- package/dist/server/http/index.d.ts +4 -3
- package/dist/server/http/index.js +21 -3
- package/dist/server/index.d.ts +2 -1
- package/dist/server/index.js +105 -79
- package/dist/server/index.js.map +1 -1
- package/dist/server/jobs/index.js +4 -4
- package/dist/server/observability/index.js +1 -1
- package/dist/server/scan/index.js +1 -1
- package/dist/{server-error-to-envelope-NO4CCAFQ.js → server-error-to-envelope-EOFUIUNB.js} +2 -2
- package/dist/server-error-to-envelope-W7KJ6AXW.js +10 -0
- package/dist/{start-SPFWOGHL.js → start-WUFA2SRC.js} +48 -3
- package/dist/start-WUFA2SRC.js.map +1 -0
- package/dist/vite-plugin/index.js +10 -8
- package/dist/{vite-plugin-43KQU5S7.js → vite-plugin-TEHQFA6D.js} +5 -4
- package/dist/vite-plugin-TEHQFA6D.js.map +1 -0
- package/package.json +5 -1
- package/dist/chunk-3FYJ7R7N.js.map +0 -1
- package/dist/chunk-MV4LKTW6.js.map +0 -1
- package/dist/chunk-TQYSPYKU.js.map +0 -1
- package/dist/server-error-to-envelope-UJK6OWDJ.js.map +0 -1
- package/dist/start-SPFWOGHL.js.map +0 -1
- /package/dist/{build-KQD2EDU4.js.map → build-S73OUGYP.js.map} +0 -0
- /package/dist/{chunk-CBGRFVF5.js.map → chunk-256WFVQQ.js.map} +0 -0
- /package/dist/{chunk-4I47JW5O.js.map → chunk-2DXLN7FF.js.map} +0 -0
- /package/dist/{chunk-6BUUZ2PK.js.map → chunk-4EL6OX3P.js.map} +0 -0
- /package/dist/{chunk-6VSKLYT6.js.map → chunk-7BJ6YLKV.js.map} +0 -0
- /package/dist/{chunk-3IOFTG3L.js.map → chunk-OPLICDUB.js.map} +0 -0
- /package/dist/{chunk-Z5IGLBWE.js.map → chunk-WFNLNIJX.js.map} +0 -0
- /package/dist/{server-error-to-envelope-NO4CCAFQ.js.map → server-error-to-envelope-EOFUIUNB.js.map} +0 -0
- /package/dist/{vite-plugin-43KQU5S7.js.map → server-error-to-envelope-W7KJ6AXW.js.map} +0 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* M7-2 — health/ready reserved routes for the convention/filesystem-route
|
|
3
|
+
* server. Liveness (`/__theo/health`, always 200) and readiness
|
|
4
|
+
* (`/__theo/ready`, 200/503 from a probe) are registered on a reserved
|
|
5
|
+
* namespace BEFORE the user-route catch-all + 404 branch — mirroring nitro's
|
|
6
|
+
* `/_nitro/*` reserved-namespace pattern (knowledge-base/references/nitro/src/
|
|
7
|
+
* runtime/internal/routes/dev-tasks.ts). Liveness and readiness are kept
|
|
8
|
+
* separate by design: liveness says "the process is up", readiness says
|
|
9
|
+
* "dependencies are up".
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
/** Reserved path for the liveness endpoint. */
|
|
14
|
+
declare const HEALTH_PATH = "/__theo/health";
|
|
15
|
+
/** Reserved path for the readiness endpoint. */
|
|
16
|
+
declare const READY_PATH = "/__theo/ready";
|
|
17
|
+
/** Config produced by {@link defineHealthRoute}. */
|
|
18
|
+
interface HealthRouteConfig {
|
|
19
|
+
readonly kind: 'health';
|
|
20
|
+
/** Returns the liveness body (auto-serialized to JSON). Default: `{ status: 'ok' }`. */
|
|
21
|
+
readonly handler: () => unknown;
|
|
22
|
+
}
|
|
23
|
+
/** Config produced by {@link defineReadyRoute}. */
|
|
24
|
+
interface ReadyRouteConfig {
|
|
25
|
+
readonly kind: 'ready';
|
|
26
|
+
/** Resolves `true` when dependencies are ready. A throw/reject is treated as not-ready (503). */
|
|
27
|
+
readonly probe: () => boolean | Promise<boolean>;
|
|
28
|
+
}
|
|
29
|
+
/** The reserved-route registry consulted by {@link serveReservedRoute}. */
|
|
30
|
+
interface ReservedRoutes {
|
|
31
|
+
readonly health?: HealthRouteConfig;
|
|
32
|
+
readonly ready?: ReadyRouteConfig;
|
|
33
|
+
}
|
|
34
|
+
/** A reserved-route response: an HTTP status + a JSON-serializable body. */
|
|
35
|
+
interface ReservedResponse {
|
|
36
|
+
readonly status: number;
|
|
37
|
+
readonly body: unknown;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Define the liveness route. The default handler returns `{ status: 'ok' }`.
|
|
41
|
+
* Liveness is always 200 — it asserts the process is up, not that dependencies are.
|
|
42
|
+
*/
|
|
43
|
+
declare function defineHealthRoute(handler?: () => unknown): HealthRouteConfig;
|
|
44
|
+
/**
|
|
45
|
+
* Define the readiness route. The `probe` decides 200 (ready) vs 503 (not-ready).
|
|
46
|
+
* A probe that throws/rejects is treated as not-ready (503) — never a 500 crash.
|
|
47
|
+
*/
|
|
48
|
+
declare function defineReadyRoute(probe: () => boolean | Promise<boolean>): ReadyRouteConfig;
|
|
49
|
+
/**
|
|
50
|
+
* Pure dispatcher: map a request pathname to a reserved-route response, or
|
|
51
|
+
* `null` when the path is not reserved (so the user catch-all + 404 take over).
|
|
52
|
+
* Liveness defaults to 200 `{status:'ok'}`; readiness without a probe is
|
|
53
|
+
* trivially ready (200). Registered BEFORE the user catch-all by the caller.
|
|
54
|
+
*/
|
|
55
|
+
declare function serveReservedRoute(pathname: string, routes?: ReservedRoutes): Promise<ReservedResponse | null>;
|
|
56
|
+
|
|
57
|
+
export { HEALTH_PATH as H, type ReservedRoutes as R, type HealthRouteConfig as a, READY_PATH as b, type ReadyRouteConfig as c, type ReservedResponse as d, defineHealthRoute as e, defineReadyRoute as f, serveReservedRoute as s };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { a as TheoErrorCode, T as TheoErrorEnvelope } from './error-envelope-BsNzzAV5.js';
|
|
1
2
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
-
import {
|
|
3
|
+
import { P as PluginContext } from './plugin-types-DNJGxr4Z.js';
|
|
3
4
|
import { P as PluginRunner } from './plugin-runner-BGBkzgi0.js';
|
|
5
|
+
import { J as JobBackend } from './job-backend-CgC8Xf33.js';
|
|
4
6
|
import { L as LoadModule, S as ServerRouteNode } from './match-CfbEFRG4.js';
|
|
5
7
|
import { c as CsrfMode, D as DisallowedConfig } from './csrf-BBrEZSBW.js';
|
|
6
8
|
import { z } from 'zod';
|
|
@@ -294,6 +296,180 @@ declare function extractTraceId(req: IncomingMessage): string;
|
|
|
294
296
|
*/
|
|
295
297
|
declare function extractTraceIdFromRequest(request: Request): string;
|
|
296
298
|
|
|
299
|
+
/**
|
|
300
|
+
* `TheoError` — envelope-emitting `Error` subclass per plan
|
|
301
|
+
* g5-error-envelope-cross-layer v1.0 § Phase 1 / T1.2.
|
|
302
|
+
*
|
|
303
|
+
* Mirrors trpc's TRPCError ergonomic pattern (referencia:
|
|
304
|
+
* trpc/packages/server/src/unstable-core-do-not-import/error/TRPCError.ts:65-87)
|
|
305
|
+
* adapted for theokit's hybrid envelope model (blueprint Form 4).
|
|
306
|
+
*
|
|
307
|
+
* Per ADR D5: `meta.stack` is auto-stripped in non-dev builds when serialized
|
|
308
|
+
* via `toJSON()` — defense against accidental stack leak to clients (encore
|
|
309
|
+
* `json:"-"` analog).
|
|
310
|
+
*
|
|
311
|
+
* Lives in `core/contracts/` per architecture.md v3 invariant #3.
|
|
312
|
+
*/
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Constructor options. `code` and `message` are required; `cause` follows TC39
|
|
316
|
+
* proposal-error-cause; `meta` and `ext` are opt-in per blueprint ADR D2.
|
|
317
|
+
*/
|
|
318
|
+
interface TheoErrorOptions<TExt = unknown> {
|
|
319
|
+
readonly code: TheoErrorCode;
|
|
320
|
+
readonly message: string;
|
|
321
|
+
readonly cause?: unknown;
|
|
322
|
+
readonly meta?: Record<string, unknown>;
|
|
323
|
+
readonly ext?: TExt;
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* `TheoError` — envelope-emitting Error subclass. Use this anywhere in
|
|
327
|
+
* `theokit/server`, route handlers, or middleware to emit a typed,
|
|
328
|
+
* cross-layer-compatible error.
|
|
329
|
+
*
|
|
330
|
+
* Mirrors TRPCError pattern: `code` is required, `message` defaults to
|
|
331
|
+
* code if omitted, `cause` chain is preserved via TC39 proposal-error-cause.
|
|
332
|
+
*/
|
|
333
|
+
declare class TheoError<TExt = unknown> extends Error {
|
|
334
|
+
readonly name = "TheoError";
|
|
335
|
+
readonly code: TheoErrorCode;
|
|
336
|
+
readonly meta?: Record<string, unknown>;
|
|
337
|
+
readonly ext?: TExt;
|
|
338
|
+
constructor(opts: TheoErrorOptions<TExt>);
|
|
339
|
+
/**
|
|
340
|
+
* The canonical envelope view of this error. Use when crossing the wire
|
|
341
|
+
* boundary or feeding telemetry — exposes the shape consumers can rely on
|
|
342
|
+
* without depending on the class identity.
|
|
343
|
+
*/
|
|
344
|
+
get envelope(): TheoErrorEnvelope<TExt>;
|
|
345
|
+
/**
|
|
346
|
+
* JSON serialization — emits envelope shape only (no name/stack class
|
|
347
|
+
* internals). Per ADR D5, `meta.stack` is auto-stripped in non-dev to
|
|
348
|
+
* prevent accidental leak; other meta keys are preserved.
|
|
349
|
+
*/
|
|
350
|
+
toJSON(): TheoErrorEnvelope<TExt>;
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Coerce any unknown value into a TheoError envelope.
|
|
354
|
+
*
|
|
355
|
+
* - If value is already a TheoError, returns it unchanged (no double-wrap).
|
|
356
|
+
* - If value is a plain Error, wraps it as `INTERNAL_SERVER_ERROR` with
|
|
357
|
+
* `cause` chain preserving the original.
|
|
358
|
+
* - Other values (string, undefined, object) are coerced safely with a
|
|
359
|
+
* meaningful message.
|
|
360
|
+
*
|
|
361
|
+
* Use at framework boundaries (route handler catch-all, middleware catch,
|
|
362
|
+
* SDK egress) to ensure every error crossing the wire carries an envelope.
|
|
363
|
+
*/
|
|
364
|
+
/**
|
|
365
|
+
* `NotFoundError` — typed 404. A `TheoError` with code `NOT_FOUND`, so it
|
|
366
|
+
* carries a stable `code` (not a bare status literal) and maps to HTTP 404 via
|
|
367
|
+
* `envelopeCodeToStatus`. Throw it from a `defineRoute` handler for ergonomic
|
|
368
|
+
* 404s (M7-1).
|
|
369
|
+
*/
|
|
370
|
+
declare class NotFoundError extends TheoError {
|
|
371
|
+
constructor(message?: string, meta?: Record<string, unknown>);
|
|
372
|
+
}
|
|
373
|
+
declare function fromUnknown(value: unknown): TheoError;
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* G5 T2.5 — server-side boundary translation per blueprint ADR D3.
|
|
377
|
+
*
|
|
378
|
+
* Translates ad-hoc Error class instances (FileTooLargeError,
|
|
379
|
+
* AuthRequiredError, RouterConventionError, etc.) into the canonical
|
|
380
|
+
* `TheoErrorEnvelope` shape at the wire boundary. This is the SINGLE
|
|
381
|
+
* boundary translation point — class identities stay in place inside the
|
|
382
|
+
* codebase (no invasive call-site rewrites), but the envelope is what
|
|
383
|
+
* crosses to clients.
|
|
384
|
+
*
|
|
385
|
+
* Pure; no I/O. Lives in `core/contracts/` per architecture.md v3
|
|
386
|
+
* invariant #3 (canonical home for shared client↔server types). This file
|
|
387
|
+
* is the EXCEPTION-of-an-exception: it intentionally inspects Error names
|
|
388
|
+
* by string instead of `instanceof` to avoid `core/contracts/` taking a
|
|
389
|
+
* dependency on `server/`. The mapping table is small and grep-discoverable.
|
|
390
|
+
*/
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Translate any server-side Error instance into a canonical envelope.
|
|
394
|
+
*
|
|
395
|
+
* Pass-through behavior:
|
|
396
|
+
* - `TheoError` instances return their `.envelope` unchanged.
|
|
397
|
+
* - Plain `Error` with unknown name → `INTERNAL_SERVER_ERROR`.
|
|
398
|
+
* - Non-Error values → wrapped via `TheoError.fromUnknown` semantics.
|
|
399
|
+
*
|
|
400
|
+
* Meta carries the source class `name` plus class-specific fields when an
|
|
401
|
+
* extractor is registered. This keeps wire-side telemetry useful without
|
|
402
|
+
* leaking implementation details.
|
|
403
|
+
*/
|
|
404
|
+
declare function serverErrorToEnvelope(value: unknown): TheoErrorEnvelope;
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Maps a TheoErrorEnvelope `code` to its canonical HTTP status.
|
|
408
|
+
*
|
|
409
|
+
* Single source of truth — previously duplicated in `web-handler.ts` and
|
|
410
|
+
* `handle-request-error.ts` (architecture-remediation plan T1.2, 2026-06-12).
|
|
411
|
+
*
|
|
412
|
+
* Every TheoErrorCode value MUST have an explicit entry here. SDK-domain codes
|
|
413
|
+
* (AGENT_RUN_ERROR, PROVIDER_KEY_MISSING, BUDGET_EXCEEDED, CREDENTIAL_POOL_EXHAUSTED)
|
|
414
|
+
* intentionally map to 500 — they represent internal failures, not client errors.
|
|
415
|
+
*/
|
|
416
|
+
declare function envelopeCodeToStatus(code: string): number;
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Canonical error handler for HTTP request pipelines (T3.4 of
|
|
420
|
+
* architecture-review-remediation-plan, PV-9 DRY).
|
|
421
|
+
*
|
|
422
|
+
* Replaces the duplicated catch-block logic in `executeRoute` (1 site) and
|
|
423
|
+
* `executeAction` (1 site, via `handleActionError`). Both code paths now
|
|
424
|
+
* share this implementation.
|
|
425
|
+
*
|
|
426
|
+
* Behavior contract (preserved from previous inline catches):
|
|
427
|
+
* - Plugin `onError` fires first (swallowed if it throws — never amplify failure).
|
|
428
|
+
* - `AuthRequiredError` is detected via `instanceof` AND a duck-type shape
|
|
429
|
+
* check (`code === 'AUTH_REQUIRED' && status === 401`) — required because
|
|
430
|
+
* under Vite dev / vitest the module-loader can produce a duplicate
|
|
431
|
+
* AuthRequiredError class identity, breaking `instanceof`.
|
|
432
|
+
* - `onResponse({ inErrorPath: true })` always fires at the end (swallowed
|
|
433
|
+
* if it throws — EC-9).
|
|
434
|
+
*/
|
|
435
|
+
interface HandleRequestErrorCtx {
|
|
436
|
+
req: IncomingMessage;
|
|
437
|
+
res: ServerResponse;
|
|
438
|
+
requestId: string | undefined;
|
|
439
|
+
pluginRunner: PluginRunner | undefined;
|
|
440
|
+
buildPluginCtx: (ctxObj: Record<string, unknown>) => PluginContext;
|
|
441
|
+
}
|
|
442
|
+
declare function handleRequestError(err: unknown, c: HandleRequestErrorCtx): Promise<void>;
|
|
443
|
+
/**
|
|
444
|
+
* T5a.2 Phase G slice 3/N — Web-Standards request error handler.
|
|
445
|
+
*
|
|
446
|
+
* Mirror of `handleRequestError(err, c: HandleRequestErrorCtx)` for the
|
|
447
|
+
* Web `Request` shape. Returns a native `Response` directly instead of
|
|
448
|
+
* mutating `res`. Same behavioral contract:
|
|
449
|
+
*
|
|
450
|
+
* 1. Auth-error detection via `instanceof AuthRequiredError` PLUS a
|
|
451
|
+
* duck-type fallback (`code === 'AUTH_REQUIRED' && status === 401`)
|
|
452
|
+
* — needed because Vite dev / vitest can produce duplicate class
|
|
453
|
+
* identities, breaking `instanceof`.
|
|
454
|
+
* 2. Envelope-shaped JSON body using `serverErrorToEnvelope` (G5 D3
|
|
455
|
+
* boundary translation).
|
|
456
|
+
* 3. Status code derived from envelope.code via `envelopeCodeToStatus`
|
|
457
|
+
* mirror (already implemented inline in web-handler.ts; this slice
|
|
458
|
+
* uses the same mapping table).
|
|
459
|
+
*
|
|
460
|
+
* **Difference vs IncomingMessage path:** the Web path's plugin runner
|
|
461
|
+
* orchestration lives in `executeWebRequest`'s `runWithHooks` /
|
|
462
|
+
* `runErrorHooks` (Phase G slice 1/N) — `handleWebRequestError` is the
|
|
463
|
+
* leaf that builds the error Response WITHOUT touching plugin hooks.
|
|
464
|
+
* Callers compose: `executeWebRequest` (or future Web execute pipeline)
|
|
465
|
+
* catches a throw, calls `handleWebRequestError(err, { requestId })` to
|
|
466
|
+
* build the Response, then routes through onError hooks separately.
|
|
467
|
+
*/
|
|
468
|
+
interface HandleWebRequestErrorCtx {
|
|
469
|
+
requestId?: string;
|
|
470
|
+
}
|
|
471
|
+
declare function handleWebRequestError(err: unknown, ctx?: HandleWebRequestErrorCtx): Promise<Response>;
|
|
472
|
+
|
|
297
473
|
interface MiddlewareResult {
|
|
298
474
|
ctx: unknown;
|
|
299
475
|
aborted: boolean;
|
|
@@ -396,4 +572,4 @@ declare function loadCustomErrorPages(clientDir: string): CustomErrorPages;
|
|
|
396
572
|
|
|
397
573
|
declare function serveStaticFile(req: IncomingMessage, res: ServerResponse, clientDir: string): boolean;
|
|
398
574
|
|
|
399
|
-
export {
|
|
575
|
+
export { serveStaticFile as $, extractTraceId as A, BATCH_PATH as B, type CookieOptions as C, extractTraceIdFromRequest as D, type ExecuteActionOptions as E, fromUnknown as F, getCookie as G, type HandleBatchOptions as H, getCookieFromRequest as I, handleBatchRequest as J, handleRequestError as K, handleWebRequestError as L, MAX_ERROR_HTML_BYTES as M, NotFoundError as N, jsonTransformer as O, loadCustomErrorPages as P, matchesOrigin as Q, parseCookieHeader as R, STRIPPED_HEADERS as S, TRACE_HEADER as T, parseTraceparent as U, resolveTransformer as V, runMiddlewareAndContext as W, sendError as X, sendJson as Y, serializeCookie as Z, _resetMiddlewareCacheForTests as _, type BatchExecuteFn as a, serverErrorToEnvelope as a0, setCookie as a1, superjsonTransformer as a2, BatchPathConflictError as b, type BatchPayload as c, type BatchRequestItem as d, type BatchResponse as e, type BatchResultItem as f, type CorsConfig as g, type CorsHandler as h, type CorsOrigin as i, type CorsWebHandler as j, type CustomErrorPages as k, type ExecuteRouteContext as l, type MiddlewareResult as m, type SendErrorInput as n, type SendErrorOptions as o, TRACE_PARENT_HEADER as p, TheoError as q, type TheoTransformer as r, appendCookieToHeaders as s, appendDeleteCookieToHeaders as t, createCorsHandler as u, createCorsWebHandler as v, deleteCookie as w, envelopeCodeToStatus as x, executeAction as y, executeRoute as z };
|
package/dist/index.js
CHANGED
|
@@ -8,27 +8,29 @@ import {
|
|
|
8
8
|
scanRoutes,
|
|
9
9
|
theoConfigSchema,
|
|
10
10
|
theoPlugin
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-7BJ6YLKV.js";
|
|
12
|
+
import "./chunk-7BIM27LV.js";
|
|
12
13
|
import "./chunk-D7ZH7DTG.js";
|
|
13
14
|
import "./chunk-PPPR5DGR.js";
|
|
14
|
-
import "./chunk-7BIM27LV.js";
|
|
15
15
|
import "./chunk-PIVX3DYW.js";
|
|
16
|
+
import "./chunk-BB4ISKOB.js";
|
|
17
|
+
import "./chunk-GY5Q27BJ.js";
|
|
16
18
|
import "./chunk-5QW7IQQU.js";
|
|
19
|
+
import "./chunk-WFNLNIJX.js";
|
|
17
20
|
import "./chunk-IAJ2JVEH.js";
|
|
18
21
|
import "./chunk-VMEWD57H.js";
|
|
19
22
|
import "./chunk-JQSKBMXP.js";
|
|
20
23
|
import "./chunk-223EFY5X.js";
|
|
21
24
|
import "./chunk-WSJKACWB.js";
|
|
25
|
+
import "./chunk-ZEGYW52B.js";
|
|
22
26
|
import "./chunk-JBCHWRKF.js";
|
|
27
|
+
import "./chunk-TSLSIRBR.js";
|
|
28
|
+
import "./chunk-UD3LFGDL.js";
|
|
29
|
+
import "./chunk-X32XEJXR.js";
|
|
30
|
+
import "./chunk-UVXB2ER7.js";
|
|
23
31
|
import "./chunk-C3ZZ56YZ.js";
|
|
24
32
|
import "./chunk-7MQOHNHE.js";
|
|
25
33
|
import "./chunk-X2VVCJ4V.js";
|
|
26
|
-
import "./chunk-3FYJ7R7N.js";
|
|
27
|
-
import "./chunk-GY5Q27BJ.js";
|
|
28
|
-
import "./chunk-Z5IGLBWE.js";
|
|
29
|
-
import "./chunk-ZEGYW52B.js";
|
|
30
|
-
import "./chunk-TSLSIRBR.js";
|
|
31
|
-
import "./chunk-UD3LFGDL.js";
|
|
32
34
|
import "./chunk-DGUM43GV.js";
|
|
33
35
|
|
|
34
36
|
// src/config/define-config.ts
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/config/define-config.ts","../src/config/validate-structure.ts","../src/core/errors.ts"],"sourcesContent":["import type { TheoConfig } from './schema.js'\n\n/**\n * Define Theo framework configuration.\n * Identity function — provides type inference for theo.config.ts.\n * Runtime validation happens in loadConfig(), not here.\n */\nexport function defineConfig(config: Partial<TheoConfig>): Partial<TheoConfig> {\n return config\n}\n","/* eslint-disable security/detect-non-literal-fs-filename --\n * Project-structure validator. Reads paths joined onto `projectRoot`,\n * with names from a fixed `ValidationRule[]` table. No HTTP input.\n */\nimport { existsSync } from 'node:fs'\nimport { join } from 'node:path'\n\nimport { TheoProjectError } from '../core/errors.js'\n\ninterface ValidationRule {\n path: string\n errorMessage: string\n}\n\nconst REQUIRED_DIRS: ValidationRule[] = [\n {\n path: 'app',\n errorMessage: 'Missing required directory: app/',\n },\n]\n\nconst REQUIRED_FILES: ValidationRule[] = [\n {\n path: 'theo.config.ts',\n errorMessage: 'Missing required file: theo.config.ts',\n },\n {\n path: 'package.json',\n errorMessage: 'Missing required file: package.json',\n },\n]\n\nexport function validateProjectStructure(rootDir: string): void {\n if (!existsSync(rootDir)) {\n throw new TheoProjectError([`Project directory does not exist: ${rootDir}`], rootDir)\n }\n\n const errors: string[] = []\n\n for (const rule of REQUIRED_DIRS) {\n if (!existsSync(join(rootDir, rule.path))) {\n errors.push(rule.errorMessage)\n }\n }\n\n for (const rule of REQUIRED_FILES) {\n if (!existsSync(join(rootDir, rule.path))) {\n errors.push(rule.errorMessage)\n }\n }\n\n if (errors.length > 0) {\n throw new TheoProjectError(errors, rootDir)\n }\n}\n","export class TheoProjectError extends Error {\n public readonly errors: string[]\n public readonly rootDir: string\n\n constructor(errors: string[], rootDir: string) {\n const errorLines = errors.map((e) => ` - ${e}`).join('\\n')\n\n super(\n `Invalid Theo project structure\\n\\n` +\n ` Root: ${rootDir}\\n\\n` +\n (errorLines ? ` Errors:\\n${errorLines}\\n` : ''),\n )\n\n this.name = 'TheoProjectError'\n this.errors = errors\n this.rootDir = rootDir\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/config/define-config.ts","../src/config/validate-structure.ts","../src/core/errors.ts"],"sourcesContent":["import type { TheoConfig } from './schema.js'\n\n/**\n * Define Theo framework configuration.\n * Identity function — provides type inference for theo.config.ts.\n * Runtime validation happens in loadConfig(), not here.\n */\nexport function defineConfig(config: Partial<TheoConfig>): Partial<TheoConfig> {\n return config\n}\n","/* eslint-disable security/detect-non-literal-fs-filename --\n * Project-structure validator. Reads paths joined onto `projectRoot`,\n * with names from a fixed `ValidationRule[]` table. No HTTP input.\n */\nimport { existsSync } from 'node:fs'\nimport { join } from 'node:path'\n\nimport { TheoProjectError } from '../core/errors.js'\n\ninterface ValidationRule {\n path: string\n errorMessage: string\n}\n\nconst REQUIRED_DIRS: ValidationRule[] = [\n {\n path: 'app',\n errorMessage: 'Missing required directory: app/',\n },\n]\n\nconst REQUIRED_FILES: ValidationRule[] = [\n {\n path: 'theo.config.ts',\n errorMessage: 'Missing required file: theo.config.ts',\n },\n {\n path: 'package.json',\n errorMessage: 'Missing required file: package.json',\n },\n]\n\nexport function validateProjectStructure(rootDir: string): void {\n if (!existsSync(rootDir)) {\n throw new TheoProjectError([`Project directory does not exist: ${rootDir}`], rootDir)\n }\n\n const errors: string[] = []\n\n for (const rule of REQUIRED_DIRS) {\n if (!existsSync(join(rootDir, rule.path))) {\n errors.push(rule.errorMessage)\n }\n }\n\n for (const rule of REQUIRED_FILES) {\n if (!existsSync(join(rootDir, rule.path))) {\n errors.push(rule.errorMessage)\n }\n }\n\n if (errors.length > 0) {\n throw new TheoProjectError(errors, rootDir)\n }\n}\n","export class TheoProjectError extends Error {\n public readonly errors: string[]\n public readonly rootDir: string\n\n constructor(errors: string[], rootDir: string) {\n const errorLines = errors.map((e) => ` - ${e}`).join('\\n')\n\n super(\n `Invalid Theo project structure\\n\\n` +\n ` Root: ${rootDir}\\n\\n` +\n (errorLines ? ` Errors:\\n${errorLines}\\n` : ''),\n )\n\n this.name = 'TheoProjectError'\n this.errors = errors\n this.rootDir = rootDir\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOO,SAAS,aAAa,QAAkD;AAC7E,SAAO;AACT;;;ACLA,SAAS,kBAAkB;AAC3B,SAAS,YAAY;;;ACLd,IAAM,mBAAN,cAA+B,MAAM;AAAA,EAC1B;AAAA,EACA;AAAA,EAEhB,YAAY,QAAkB,SAAiB;AAC7C,UAAM,aAAa,OAAO,IAAI,CAAC,MAAM,OAAO,CAAC,EAAE,EAAE,KAAK,IAAI;AAE1D;AAAA,MACE;AAAA;AAAA,UACa,OAAO;AAAA;AAAA,KACjB,aAAa;AAAA,EAAc,UAAU;AAAA,IAAO;AAAA,IACjD;AAEA,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,UAAU;AAAA,EACjB;AACF;;;ADHA,IAAM,gBAAkC;AAAA,EACtC;AAAA,IACE,MAAM;AAAA,IACN,cAAc;AAAA,EAChB;AACF;AAEA,IAAM,iBAAmC;AAAA,EACvC;AAAA,IACE,MAAM;AAAA,IACN,cAAc;AAAA,EAChB;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,cAAc;AAAA,EAChB;AACF;AAEO,SAAS,yBAAyB,SAAuB;AAC9D,MAAI,CAAC,WAAW,OAAO,GAAG;AACxB,UAAM,IAAI,iBAAiB,CAAC,qCAAqC,OAAO,EAAE,GAAG,OAAO;AAAA,EACtF;AAEA,QAAM,SAAmB,CAAC;AAE1B,aAAW,QAAQ,eAAe;AAChC,QAAI,CAAC,WAAW,KAAK,SAAS,KAAK,IAAI,CAAC,GAAG;AACzC,aAAO,KAAK,KAAK,YAAY;AAAA,IAC/B;AAAA,EACF;AAEA,aAAW,QAAQ,gBAAgB;AACjC,QAAI,CAAC,WAAW,KAAK,SAAS,KAAK,IAAI,CAAC,GAAG;AACzC,aAAO,KAAK,KAAK,YAAY;AAAA,IAC/B;AAAA,EACF;AAEA,MAAI,OAAO,SAAS,GAAG;AACrB,UAAM,IAAI,iBAAiB,QAAQ,OAAO;AAAA,EAC5C;AACF;","names":[]}
|
|
@@ -24,10 +24,10 @@ import {
|
|
|
24
24
|
verifyOAuthState,
|
|
25
25
|
verifyTotp
|
|
26
26
|
} from "../../chunk-SJIRP73B.js";
|
|
27
|
+
import "../../chunk-ZJQ4O76G.js";
|
|
27
28
|
import {
|
|
28
29
|
generateNonce
|
|
29
30
|
} from "../../chunk-C3ZZ56YZ.js";
|
|
30
|
-
import "../../chunk-ZJQ4O76G.js";
|
|
31
31
|
import "../../chunk-DGUM43GV.js";
|
|
32
32
|
export {
|
|
33
33
|
AuthRequiredError,
|
|
@@ -4,6 +4,7 @@ import { b as WebSocketLike } from '../../define-websocket-CdK94O-D.js';
|
|
|
4
4
|
export { W as WebSocketHandler, a as WebSocketHandlerWeb, d as defineWebSocket, c as defineWebSocketWeb } from '../../define-websocket-CdK94O-D.js';
|
|
5
5
|
import { IncomingMessage } from 'node:http';
|
|
6
6
|
import { T as TheoPlugin } from '../../plugin-types-DNJGxr4Z.js';
|
|
7
|
+
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';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* core/contracts/route-config.ts
|
|
@@ -9,18 +9,30 @@ import {
|
|
|
9
9
|
defineWebChannel,
|
|
10
10
|
defineWebSocket,
|
|
11
11
|
defineWebSocketWeb
|
|
12
|
-
} from "../../chunk-
|
|
12
|
+
} from "../../chunk-4EL6OX3P.js";
|
|
13
|
+
import {
|
|
14
|
+
HEALTH_PATH,
|
|
15
|
+
READY_PATH,
|
|
16
|
+
defineHealthRoute,
|
|
17
|
+
defineReadyRoute,
|
|
18
|
+
serveReservedRoute
|
|
19
|
+
} from "../../chunk-V3LJN2GS.js";
|
|
13
20
|
import "../../chunk-DGUM43GV.js";
|
|
14
21
|
export {
|
|
22
|
+
HEALTH_PATH,
|
|
23
|
+
READY_PATH,
|
|
15
24
|
defineAction,
|
|
16
25
|
defineAgentEndpoint,
|
|
17
26
|
defineAgentTool,
|
|
18
27
|
defineChannel,
|
|
28
|
+
defineHealthRoute,
|
|
19
29
|
defineMiddleware,
|
|
30
|
+
defineReadyRoute,
|
|
20
31
|
defineRoute,
|
|
21
32
|
defineTheoPlugin,
|
|
22
33
|
defineWebChannel,
|
|
23
34
|
defineWebSocket,
|
|
24
|
-
defineWebSocketWeb
|
|
35
|
+
defineWebSocketWeb,
|
|
36
|
+
serveReservedRoute
|
|
25
37
|
};
|
|
26
38
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,8 +1,9 @@
|
|
|
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, S as STRIPPED_HEADERS, n as SendErrorInput, o as SendErrorOptions, T as TRACE_HEADER, p as TRACE_PARENT_HEADER, _ as _resetMiddlewareCacheForTests,
|
|
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';
|
|
2
3
|
import 'node:http';
|
|
3
|
-
import '../../job-backend-CgC8Xf33.js';
|
|
4
|
-
import '../../plugin-runner-BGBkzgi0.js';
|
|
5
4
|
import '../../plugin-types-DNJGxr4Z.js';
|
|
5
|
+
import '../../plugin-runner-BGBkzgi0.js';
|
|
6
|
+
import '../../job-backend-CgC8Xf33.js';
|
|
6
7
|
import '../../match-CfbEFRG4.js';
|
|
7
8
|
import 'vite';
|
|
8
9
|
import '../../csrf-BBrEZSBW.js';
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
MAX_ERROR_HTML_BYTES,
|
|
3
3
|
loadCustomErrorPages,
|
|
4
4
|
serveStaticFile
|
|
5
|
-
} from "../../chunk-
|
|
5
|
+
} from "../../chunk-OPLICDUB.js";
|
|
6
6
|
import {
|
|
7
7
|
BATCH_PATH,
|
|
8
8
|
BatchPathConflictError,
|
|
@@ -17,17 +17,28 @@ import {
|
|
|
17
17
|
extractTraceId,
|
|
18
18
|
extractTraceIdFromRequest,
|
|
19
19
|
handleBatchRequest,
|
|
20
|
+
handleRequestError,
|
|
21
|
+
handleWebRequestError,
|
|
20
22
|
matchesOrigin,
|
|
21
23
|
parseTraceparent,
|
|
22
24
|
runMiddlewareAndContext,
|
|
23
25
|
sendError,
|
|
24
26
|
sendJson
|
|
25
|
-
} from "../../chunk-
|
|
27
|
+
} from "../../chunk-BB4ISKOB.js";
|
|
26
28
|
import "../../chunk-GY5Q27BJ.js";
|
|
27
|
-
import "../../chunk-
|
|
29
|
+
import "../../chunk-WFNLNIJX.js";
|
|
28
30
|
import "../../chunk-ZEGYW52B.js";
|
|
29
31
|
import "../../chunk-TSLSIRBR.js";
|
|
30
32
|
import "../../chunk-UD3LFGDL.js";
|
|
33
|
+
import {
|
|
34
|
+
envelopeCodeToStatus
|
|
35
|
+
} from "../../chunk-X32XEJXR.js";
|
|
36
|
+
import {
|
|
37
|
+
NotFoundError,
|
|
38
|
+
TheoError,
|
|
39
|
+
fromUnknown,
|
|
40
|
+
serverErrorToEnvelope
|
|
41
|
+
} from "../../chunk-UVXB2ER7.js";
|
|
31
42
|
import {
|
|
32
43
|
appendCookieToHeaders,
|
|
33
44
|
appendDeleteCookieToHeaders,
|
|
@@ -43,22 +54,28 @@ export {
|
|
|
43
54
|
BATCH_PATH,
|
|
44
55
|
BatchPathConflictError,
|
|
45
56
|
MAX_ERROR_HTML_BYTES,
|
|
57
|
+
NotFoundError,
|
|
46
58
|
STRIPPED_HEADERS,
|
|
47
59
|
TRACE_HEADER,
|
|
48
60
|
TRACE_PARENT_HEADER,
|
|
61
|
+
TheoError,
|
|
49
62
|
_resetMiddlewareCacheForTests,
|
|
50
63
|
appendCookieToHeaders,
|
|
51
64
|
appendDeleteCookieToHeaders,
|
|
52
65
|
createCorsHandler,
|
|
53
66
|
createCorsWebHandler,
|
|
54
67
|
deleteCookie,
|
|
68
|
+
envelopeCodeToStatus,
|
|
55
69
|
executeAction,
|
|
56
70
|
executeRoute,
|
|
57
71
|
extractTraceId,
|
|
58
72
|
extractTraceIdFromRequest,
|
|
73
|
+
fromUnknown,
|
|
59
74
|
getCookie,
|
|
60
75
|
getCookieFromRequest,
|
|
61
76
|
handleBatchRequest,
|
|
77
|
+
handleRequestError,
|
|
78
|
+
handleWebRequestError,
|
|
62
79
|
loadCustomErrorPages,
|
|
63
80
|
matchesOrigin,
|
|
64
81
|
parseCookieHeader,
|
|
@@ -68,6 +85,7 @@ export {
|
|
|
68
85
|
sendJson,
|
|
69
86
|
serializeCookie,
|
|
70
87
|
serveStaticFile,
|
|
88
|
+
serverErrorToEnvelope,
|
|
71
89
|
setCookie
|
|
72
90
|
};
|
|
73
91
|
//# sourceMappingURL=index.js.map
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { RouteConfig } from './define/index.js';
|
|
2
2
|
export { ActionAccept, ActionConfig, AgentEndpointConfig, AgentEndpointHandlerArgs, ChannelHandler, CustomTool, DefineAgentToolSpec, MiddlewareHandler, WebChannelHandler, defineAction, defineAgentEndpoint, defineAgentTool, defineChannel, defineMiddleware, defineRoute, defineTheoPlugin, defineWebChannel } from './define/index.js';
|
|
3
3
|
export { W as WebSocketHandler, a as WebSocketHandlerWeb, b as WebSocketLike, d as defineWebSocket, c as defineWebSocketWeb } from '../define-websocket-CdK94O-D.js';
|
|
4
|
-
export {
|
|
4
|
+
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';
|
|
5
|
+
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, r as TheoTransformer, _ 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, O as jsonTransformer, P as loadCustomErrorPages, Q as matchesOrigin, R as parseCookieHeader, U as parseTraceparent, V as resolveTransformer, W as runMiddlewareAndContext, X as sendError, Y as sendJson, Z as serializeCookie, $ as serveStaticFile, a0 as serverErrorToEnvelope, a1 as setCookie, a2 as superjsonTransformer } from '../index-B40qUSrQ.js';
|
|
5
6
|
export { ActionNode, ActionScanError, LoadedManifest, ManifestAction, ManifestRoute, ManifestWebSocket, TheoManifest, WebSocketRouteNode, generateManifest, loadManifest, scanMiddlewares, scanServerActions, scanServerActionsEnriched, scanServerRoutes, scanWebSocketRoutes, writeManifest } from './scan/index.js';
|
|
6
7
|
export { L as LoadModule, S as ServerRouteNode, c as compilePattern, a as createProductionLoader, b as createViteLoader, m as matchRoute } from '../match-CfbEFRG4.js';
|
|
7
8
|
import { T as TheoErrorEnvelope, a as TheoErrorCode, V as ValidationFieldsExt } from '../error-envelope-BsNzzAV5.js';
|