theokit 0.55.0 → 0.56.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-TZFLCIIR.js → actions-virtual-module-3V7VG2YL.js} +3 -3
- package/dist/{actions-virtual-module-PREAJNIS.js → actions-virtual-module-KJBCM7PP.js} +21 -21
- package/dist/adapters/agent-mount.d.ts +1 -1
- package/dist/adapters/agent-mount.js +9 -9
- package/dist/{agent-2AELELAC.js → agent-NLG77PFN.js} +3 -3
- package/dist/{agents-typed-client-INR2E7B3.js → agents-typed-client-PVUZU65B.js} +3 -3
- package/dist/{app-typed-client-KSFGMOQ6.js → app-typed-client-XSXAORG6.js} +21 -21
- package/dist/{app-typed-client-NEKRXPAQ.js → app-typed-client-ZO3VKJ3O.js} +3 -3
- package/dist/boot/index.js +3 -3
- package/dist/{build-ESSQS5F5.js → build-4GQLIFTD.js} +3 -3
- package/dist/{bun-L7PP6ID5.js → bun-POLTY2HK.js} +118 -3
- package/dist/bun-POLTY2HK.js.map +1 -0
- package/dist/{chunk-DADMEW4G.js → chunk-22ZZSUKD.js} +2 -2
- package/dist/{chunk-5YPXXSYY.js → chunk-35QIWOHT.js} +9 -8
- package/dist/chunk-35QIWOHT.js.map +1 -0
- package/dist/{chunk-JDN5SAAD.js → chunk-44E7XIZC.js} +6 -6
- package/dist/{chunk-OQCRCXCP.js → chunk-4ERYQBL6.js} +2 -2
- package/dist/{chunk-52PDWL5S.js → chunk-5KRMDP46.js} +2 -2
- package/dist/{chunk-VRELW5NF.js → chunk-5TPBOAAH.js} +8 -8
- package/dist/{chunk-QZUIF64G.js → chunk-6PFF5HMY.js} +3 -3
- package/dist/{chunk-VQPHPQ5L.js → chunk-7NRFZBAL.js} +3 -3
- package/dist/{chunk-3PBAN2YE.js → chunk-CF2DNN5R.js} +9 -8
- package/dist/{chunk-3PBAN2YE.js.map → chunk-CF2DNN5R.js.map} +1 -1
- package/dist/{chunk-HK4AZBKX.js → chunk-D5KBBTVD.js} +7 -7
- package/dist/{chunk-BU6RJPPJ.js → chunk-GO7UWJ47.js} +2 -2
- package/dist/{chunk-BU6RJPPJ.js.map → chunk-GO7UWJ47.js.map} +1 -1
- package/dist/{chunk-VZTYCAO6.js → chunk-IDEZ7FU2.js} +3 -3
- package/dist/{chunk-ITSNTHWN.js → chunk-JW5UFKQ3.js} +17 -17
- package/dist/{chunk-IRASEXOG.js → chunk-KDP2HURW.js} +6 -6
- package/dist/{chunk-GWE4MUKQ.js → chunk-KQ27YDLG.js} +8 -8
- package/dist/{chunk-WX6NHGKS.js → chunk-M357ILK5.js} +10 -10
- package/dist/{chunk-ZQO37YQJ.js → chunk-PELXWPDF.js} +5 -5
- package/dist/{chunk-2OEN3YTE.js → chunk-PVNMLZ5G.js} +2 -2
- package/dist/{chunk-5K4TDLRG.js → chunk-SOYOYGWY.js} +3 -3
- package/dist/{chunk-2PSKQWGM.js → chunk-TUO2FE3S.js} +3 -3
- package/dist/{chunk-4X6H2BXP.js → chunk-U3SPBLJF.js} +3 -3
- package/dist/{chunk-BX6EUYHU.js → chunk-V6Y2SMRG.js} +3 -3
- package/dist/{chunk-I2UN46ZX.js → chunk-XJOU425Y.js} +17 -17
- package/dist/{chunk-3DRALT3J.js → chunk-XYVZJCZU.js} +4 -4
- package/dist/{chunk-BND4YZTQ.js → chunk-ZDCCILMP.js} +2 -2
- package/dist/{chunk-F6P6S5YS.js → chunk-ZTIB4QSV.js} +63 -63
- package/dist/cli/index.js +6 -6
- package/dist/{controller-swc-transform-T7ZTD55V.js → controller-swc-transform-7EZKG2IS.js} +2 -2
- package/dist/cost-types-BALTuBpG.d.ts +79 -0
- package/dist/{dev-MWGPBGQP.js → dev-ZNTHPBBN.js} +5 -5
- package/dist/{dev-emit-W27J3DLU.js → dev-emit-FIQASO3D.js} +7 -7
- package/dist/index.js +23 -23
- package/dist/{internal-api-XSUP3NDI.js → internal-api-D76JZGSC.js} +3 -3
- package/dist/{internal-api-J3BYA3VU.js → internal-api-JNX3MTIM.js} +26 -26
- package/dist/{mcp-6IPY275L.js → mcp-IMY3NUCL.js} +3 -3
- package/dist/{preview-KPAKWBRW.js → preview-K4NIQLAK.js} +3 -3
- package/dist/{provider-resolver-Dx6QuWrw.d.ts → provider-resolver-VS61zqsw.d.ts} +0 -11
- package/dist/{registry-KBZDCFVQ.js → registry-3LUHO4IB.js} +2 -2
- package/dist/server/agent/index.d.ts +1 -1
- package/dist/server/agent/index.js +3 -3
- package/dist/server/cost/index.d.ts +3 -80
- package/dist/server/cost/sqlite/index.d.ts +21 -0
- package/dist/server/cost/sqlite/index.js +102 -0
- package/dist/server/cost/sqlite/index.js.map +1 -0
- package/dist/server/cron/index.js +4 -4
- package/dist/server/http/index.js +7 -7
- package/dist/server/index.d.ts +5 -4
- package/dist/server/index.js +79 -79
- package/dist/server/jobs/index.d.ts +2 -2
- package/dist/server/jobs/index.js +4 -4
- package/dist/server/observability/index.js +2 -2
- package/dist/server/scan/index.js +6 -6
- package/dist/server/storage/index.d.ts +2 -2
- package/dist/server/webhook/index.js +1 -1
- package/dist/{server-boundary-7ZO4FZIV.js → server-boundary-654WC5SA.js} +23 -23
- package/dist/{server-boundary-PGPFBJBH.js → server-boundary-NW6LNNGK.js} +3 -3
- package/dist/{server-routes-hmr-BWN3WIGR.js → server-routes-hmr-TNI3FNGM.js} +2 -2
- package/dist/{services-typed-client-IXNOPVZA.js → services-typed-client-ACTJHAEP.js} +2 -2
- package/dist/{start-F3T2ZPPI.js → start-ONZXIWEG.js} +4 -4
- package/dist/{storage-manager-C6hmsaer.d.ts → storage-manager-BtG38jYl.d.ts} +1 -1
- package/dist/{storage-types-DsDTCPbp.d.ts → storage-types-CFGPFIdB.d.ts} +1 -1
- package/dist/vite-plugin/index.js +21 -21
- package/dist/{vite-plugin-5O3D472R.js → vite-plugin-UET2BUFW.js} +5 -5
- package/package.json +7 -3
- package/dist/bun-L7PP6ID5.js.map +0 -1
- package/dist/chunk-5YPXXSYY.js.map +0 -1
- /package/dist/{actions-virtual-module-TZFLCIIR.js.map → actions-virtual-module-3V7VG2YL.js.map} +0 -0
- /package/dist/{actions-virtual-module-PREAJNIS.js.map → actions-virtual-module-KJBCM7PP.js.map} +0 -0
- /package/dist/{agent-2AELELAC.js.map → agent-NLG77PFN.js.map} +0 -0
- /package/dist/{agents-typed-client-INR2E7B3.js.map → agents-typed-client-PVUZU65B.js.map} +0 -0
- /package/dist/{app-typed-client-KSFGMOQ6.js.map → app-typed-client-XSXAORG6.js.map} +0 -0
- /package/dist/{app-typed-client-NEKRXPAQ.js.map → app-typed-client-ZO3VKJ3O.js.map} +0 -0
- /package/dist/{build-ESSQS5F5.js.map → build-4GQLIFTD.js.map} +0 -0
- /package/dist/{chunk-DADMEW4G.js.map → chunk-22ZZSUKD.js.map} +0 -0
- /package/dist/{chunk-JDN5SAAD.js.map → chunk-44E7XIZC.js.map} +0 -0
- /package/dist/{chunk-OQCRCXCP.js.map → chunk-4ERYQBL6.js.map} +0 -0
- /package/dist/{chunk-52PDWL5S.js.map → chunk-5KRMDP46.js.map} +0 -0
- /package/dist/{chunk-VRELW5NF.js.map → chunk-5TPBOAAH.js.map} +0 -0
- /package/dist/{chunk-QZUIF64G.js.map → chunk-6PFF5HMY.js.map} +0 -0
- /package/dist/{chunk-VQPHPQ5L.js.map → chunk-7NRFZBAL.js.map} +0 -0
- /package/dist/{chunk-HK4AZBKX.js.map → chunk-D5KBBTVD.js.map} +0 -0
- /package/dist/{chunk-VZTYCAO6.js.map → chunk-IDEZ7FU2.js.map} +0 -0
- /package/dist/{chunk-ITSNTHWN.js.map → chunk-JW5UFKQ3.js.map} +0 -0
- /package/dist/{chunk-IRASEXOG.js.map → chunk-KDP2HURW.js.map} +0 -0
- /package/dist/{chunk-GWE4MUKQ.js.map → chunk-KQ27YDLG.js.map} +0 -0
- /package/dist/{chunk-WX6NHGKS.js.map → chunk-M357ILK5.js.map} +0 -0
- /package/dist/{chunk-ZQO37YQJ.js.map → chunk-PELXWPDF.js.map} +0 -0
- /package/dist/{chunk-2OEN3YTE.js.map → chunk-PVNMLZ5G.js.map} +0 -0
- /package/dist/{chunk-5K4TDLRG.js.map → chunk-SOYOYGWY.js.map} +0 -0
- /package/dist/{chunk-2PSKQWGM.js.map → chunk-TUO2FE3S.js.map} +0 -0
- /package/dist/{chunk-4X6H2BXP.js.map → chunk-U3SPBLJF.js.map} +0 -0
- /package/dist/{chunk-BX6EUYHU.js.map → chunk-V6Y2SMRG.js.map} +0 -0
- /package/dist/{chunk-I2UN46ZX.js.map → chunk-XJOU425Y.js.map} +0 -0
- /package/dist/{chunk-3DRALT3J.js.map → chunk-XYVZJCZU.js.map} +0 -0
- /package/dist/{chunk-BND4YZTQ.js.map → chunk-ZDCCILMP.js.map} +0 -0
- /package/dist/{chunk-F6P6S5YS.js.map → chunk-ZTIB4QSV.js.map} +0 -0
- /package/dist/{controller-swc-transform-T7ZTD55V.js.map → controller-swc-transform-7EZKG2IS.js.map} +0 -0
- /package/dist/{dev-MWGPBGQP.js.map → dev-ZNTHPBBN.js.map} +0 -0
- /package/dist/{dev-emit-W27J3DLU.js.map → dev-emit-FIQASO3D.js.map} +0 -0
- /package/dist/{internal-api-XSUP3NDI.js.map → internal-api-D76JZGSC.js.map} +0 -0
- /package/dist/{internal-api-J3BYA3VU.js.map → internal-api-JNX3MTIM.js.map} +0 -0
- /package/dist/{mcp-6IPY275L.js.map → mcp-IMY3NUCL.js.map} +0 -0
- /package/dist/{preview-KPAKWBRW.js.map → preview-K4NIQLAK.js.map} +0 -0
- /package/dist/{registry-KBZDCFVQ.js.map → registry-3LUHO4IB.js.map} +0 -0
- /package/dist/{server-boundary-7ZO4FZIV.js.map → server-boundary-654WC5SA.js.map} +0 -0
- /package/dist/{server-boundary-PGPFBJBH.js.map → server-boundary-NW6LNNGK.js.map} +0 -0
- /package/dist/{server-routes-hmr-BWN3WIGR.js.map → server-routes-hmr-TNI3FNGM.js.map} +0 -0
- /package/dist/{services-typed-client-IXNOPVZA.js.map → services-typed-client-ACTJHAEP.js.map} +0 -0
- /package/dist/{start-F3T2ZPPI.js.map → start-ONZXIWEG.js.map} +0 -0
- /package/dist/{vite-plugin-5O3D472R.js.map → vite-plugin-UET2BUFW.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import "tsx/esm";
|
|
3
|
-
import "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
import "./chunk-22ZZSUKD.js";
|
|
4
|
+
import "./chunk-35QIWOHT.js";
|
|
5
5
|
import "./chunk-MWWFXYW3.js";
|
|
6
6
|
import "./chunk-RPET332G.js";
|
|
7
7
|
import "./chunk-5VLP3GQ2.js";
|
|
@@ -218,4 +218,4 @@ export const actions = manifest
|
|
|
218
218
|
export {
|
|
219
219
|
actionsVirtualModule
|
|
220
220
|
};
|
|
221
|
-
//# sourceMappingURL=actions-virtual-module-
|
|
221
|
+
//# sourceMappingURL=actions-virtual-module-3V7VG2YL.js.map
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import "./chunk-
|
|
2
|
-
import "./chunk-
|
|
3
|
-
import "./chunk-
|
|
1
|
+
import "./chunk-XYVZJCZU.js";
|
|
2
|
+
import "./chunk-M357ILK5.js";
|
|
3
|
+
import "./chunk-BPYMC7SU.js";
|
|
4
|
+
import "./chunk-IRQGAC4L.js";
|
|
5
|
+
import "./chunk-JW5UFKQ3.js";
|
|
6
|
+
import "./chunk-P6OS7652.js";
|
|
4
7
|
import "./chunk-ZDUO4IYN.js";
|
|
8
|
+
import "./chunk-D4VP2QPR.js";
|
|
9
|
+
import "./chunk-YN4W7LCX.js";
|
|
5
10
|
import "./chunk-47FFT43U.js";
|
|
6
11
|
import "./chunk-NTDN54XO.js";
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-PVNMLZ5G.js";
|
|
13
|
+
import "./chunk-ZDCCILMP.js";
|
|
9
14
|
import "./chunk-CHTAWXC2.js";
|
|
15
|
+
import "./chunk-AVQU5CQF.js";
|
|
10
16
|
import "./chunk-VSLTKX5L.js";
|
|
11
17
|
import "./chunk-TNI4MARH.js";
|
|
12
|
-
import "./chunk-
|
|
18
|
+
import "./chunk-4ERYQBL6.js";
|
|
13
19
|
import {
|
|
14
20
|
scanServerActionsEnriched
|
|
15
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-XJOU425Y.js";
|
|
22
|
+
import "./chunk-KDP2HURW.js";
|
|
16
23
|
import "./chunk-DV34VG3N.js";
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-BX6EUYHU.js";
|
|
19
|
-
import "./chunk-BPYMC7SU.js";
|
|
20
|
-
import "./chunk-IRQGAC4L.js";
|
|
21
|
-
import "./chunk-P6OS7652.js";
|
|
22
|
-
import "./chunk-AVQU5CQF.js";
|
|
24
|
+
import "./chunk-V6Y2SMRG.js";
|
|
23
25
|
import "./chunk-ACKBVBUI.js";
|
|
24
26
|
import "./chunk-IZ3TIL6K.js";
|
|
25
|
-
import "./chunk-
|
|
27
|
+
import "./chunk-CF2DNN5R.js";
|
|
26
28
|
import "./chunk-YSJOZEI6.js";
|
|
27
29
|
import "./chunk-Z4PJMZLM.js";
|
|
28
30
|
import "./chunk-UMNXCU3K.js";
|
|
29
|
-
import "./chunk-
|
|
30
|
-
import "./chunk-
|
|
31
|
+
import "./chunk-5KRMDP46.js";
|
|
32
|
+
import "./chunk-SOYOYGWY.js";
|
|
31
33
|
import "./chunk-ZWN3AODA.js";
|
|
32
|
-
import "./chunk-D4VP2QPR.js";
|
|
33
|
-
import "./chunk-YN4W7LCX.js";
|
|
34
34
|
import "./chunk-XTHN6JBX.js";
|
|
35
35
|
|
|
36
36
|
// src/vite-plugin/actions-virtual-module.ts
|
|
37
|
-
import { existsSync, mkdirSync, renameSync, watch as fsWatch, writeFileSync } from "fs";
|
|
38
|
-
import { dirname, join, posix, resolve } from "path";
|
|
37
|
+
import { existsSync, mkdirSync, renameSync, watch as fsWatch, writeFileSync } from "node:fs";
|
|
38
|
+
import { dirname, join, posix, resolve } from "node:path";
|
|
39
39
|
var VIRTUAL_ID = "@theo/actions";
|
|
40
40
|
var RESOLVED_ID = `\0${VIRTUAL_ID}`;
|
|
41
41
|
function actionsVirtualModule(opts) {
|
|
@@ -234,4 +234,4 @@ export const actions = manifest
|
|
|
234
234
|
export {
|
|
235
235
|
actionsVirtualModule
|
|
236
236
|
};
|
|
237
|
-
//# sourceMappingURL=actions-virtual-module-
|
|
237
|
+
//# sourceMappingURL=actions-virtual-module-KJBCM7PP.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as RouteSubject, R as RoutePolicy } from '../route-policy-BxOycCDq.js';
|
|
2
2
|
import { C as CsrfMode } from '../csrf-Dgot9qSM.js';
|
|
3
|
-
export { r as resolveProvider } from '../provider-resolver-
|
|
3
|
+
export { r as resolveProvider } from '../provider-resolver-VS61zqsw.js';
|
|
4
4
|
export { s as scanAgents } from '../agent-scan-BZa-pagG.js';
|
|
5
5
|
import 'node:http';
|
|
6
6
|
import '../audit-log-BQWM5YLG.js';
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
mountAgent
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-M357ILK5.js";
|
|
4
|
+
import "../chunk-P6OS7652.js";
|
|
5
|
+
import "../chunk-YN4W7LCX.js";
|
|
6
|
+
import "../chunk-PVNMLZ5G.js";
|
|
7
|
+
import "../chunk-ZDCCILMP.js";
|
|
6
8
|
import "../chunk-CHTAWXC2.js";
|
|
9
|
+
import "../chunk-AVQU5CQF.js";
|
|
7
10
|
import {
|
|
8
11
|
scanAgents
|
|
9
|
-
} from "../chunk-
|
|
10
|
-
import "../chunk-P6OS7652.js";
|
|
11
|
-
import "../chunk-AVQU5CQF.js";
|
|
12
|
+
} from "../chunk-KDP2HURW.js";
|
|
12
13
|
import {
|
|
13
14
|
resolveProvider
|
|
14
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-CF2DNN5R.js";
|
|
15
16
|
import "../chunk-UMNXCU3K.js";
|
|
16
|
-
import "../chunk-
|
|
17
|
+
import "../chunk-SOYOYGWY.js";
|
|
17
18
|
import "../chunk-ZWN3AODA.js";
|
|
18
|
-
import "../chunk-YN4W7LCX.js";
|
|
19
19
|
import "../chunk-XTHN6JBX.js";
|
|
20
20
|
export {
|
|
21
21
|
mountAgent,
|
|
@@ -3,8 +3,8 @@ import "tsx/esm";
|
|
|
3
3
|
import {
|
|
4
4
|
agentCommand,
|
|
5
5
|
createAgentSsrLoader
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-TUO2FE3S.js";
|
|
7
|
+
import "./chunk-35QIWOHT.js";
|
|
8
8
|
import "./chunk-5NNFO7R7.js";
|
|
9
9
|
import "./chunk-Z7CJHDLS.js";
|
|
10
10
|
import "./chunk-3QPVEJ7D.js";
|
|
@@ -12,4 +12,4 @@ export {
|
|
|
12
12
|
agentCommand,
|
|
13
13
|
createAgentSsrLoader
|
|
14
14
|
};
|
|
15
|
-
//# sourceMappingURL=agent-
|
|
15
|
+
//# sourceMappingURL=agent-NLG77PFN.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "./chunk-XTHN6JBX.js";
|
|
2
2
|
|
|
3
3
|
// src/vite-plugin/agents-typed-client.ts
|
|
4
|
-
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "fs";
|
|
5
|
-
import { dirname, posix } from "path";
|
|
4
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
5
|
+
import { dirname, posix } from "node:path";
|
|
6
6
|
var FILE_HEADER = `// AUTO-GENERATED by theokit \u2014 do not edit.
|
|
7
7
|
// Source: theokit/packages/theo/src/vite-plugin/agents-typed-client.ts (M2).
|
|
8
8
|
// To refresh: \`pnpm dev\` or \`pnpm build\` regenerates this on every agents/ change.
|
|
@@ -181,4 +181,4 @@ export {
|
|
|
181
181
|
generateAgentsRuntimeModule,
|
|
182
182
|
handleIdentifier
|
|
183
183
|
};
|
|
184
|
-
//# sourceMappingURL=agents-typed-client-
|
|
184
|
+
//# sourceMappingURL=agents-typed-client-PVUZU65B.js.map
|
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
import {
|
|
2
2
|
scanControllerModules
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-XYVZJCZU.js";
|
|
4
|
+
import "./chunk-M357ILK5.js";
|
|
5
|
+
import "./chunk-BPYMC7SU.js";
|
|
6
|
+
import "./chunk-IRQGAC4L.js";
|
|
7
|
+
import "./chunk-JW5UFKQ3.js";
|
|
8
|
+
import "./chunk-P6OS7652.js";
|
|
6
9
|
import "./chunk-ZDUO4IYN.js";
|
|
10
|
+
import "./chunk-D4VP2QPR.js";
|
|
11
|
+
import "./chunk-YN4W7LCX.js";
|
|
7
12
|
import "./chunk-47FFT43U.js";
|
|
8
13
|
import "./chunk-NTDN54XO.js";
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
14
|
+
import "./chunk-PVNMLZ5G.js";
|
|
15
|
+
import "./chunk-ZDCCILMP.js";
|
|
11
16
|
import "./chunk-CHTAWXC2.js";
|
|
17
|
+
import "./chunk-AVQU5CQF.js";
|
|
12
18
|
import "./chunk-VSLTKX5L.js";
|
|
13
19
|
import "./chunk-TNI4MARH.js";
|
|
14
|
-
import "./chunk-
|
|
20
|
+
import "./chunk-4ERYQBL6.js";
|
|
15
21
|
import {
|
|
16
22
|
generateManifest
|
|
17
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-XJOU425Y.js";
|
|
24
|
+
import "./chunk-KDP2HURW.js";
|
|
18
25
|
import {
|
|
19
26
|
HTTP_METHODS
|
|
20
27
|
} from "./chunk-DV34VG3N.js";
|
|
21
|
-
import "./chunk-
|
|
22
|
-
import "./chunk-BX6EUYHU.js";
|
|
23
|
-
import "./chunk-BPYMC7SU.js";
|
|
24
|
-
import "./chunk-IRQGAC4L.js";
|
|
25
|
-
import "./chunk-P6OS7652.js";
|
|
26
|
-
import "./chunk-AVQU5CQF.js";
|
|
28
|
+
import "./chunk-V6Y2SMRG.js";
|
|
27
29
|
import "./chunk-ACKBVBUI.js";
|
|
28
30
|
import "./chunk-IZ3TIL6K.js";
|
|
29
|
-
import "./chunk-
|
|
31
|
+
import "./chunk-CF2DNN5R.js";
|
|
30
32
|
import "./chunk-YSJOZEI6.js";
|
|
31
33
|
import "./chunk-Z4PJMZLM.js";
|
|
32
34
|
import "./chunk-UMNXCU3K.js";
|
|
33
|
-
import "./chunk-
|
|
34
|
-
import "./chunk-
|
|
35
|
+
import "./chunk-5KRMDP46.js";
|
|
36
|
+
import "./chunk-SOYOYGWY.js";
|
|
35
37
|
import "./chunk-ZWN3AODA.js";
|
|
36
|
-
import "./chunk-D4VP2QPR.js";
|
|
37
|
-
import "./chunk-YN4W7LCX.js";
|
|
38
38
|
import "./chunk-XTHN6JBX.js";
|
|
39
39
|
|
|
40
40
|
// src/vite-plugin/app-typed-client.ts
|
|
41
|
-
import { mkdirSync, readFileSync, renameSync, writeFileSync, existsSync } from "fs";
|
|
42
|
-
import { dirname, isAbsolute, posix, relative, resolve } from "path";
|
|
41
|
+
import { mkdirSync, readFileSync, renameSync, writeFileSync, existsSync } from "node:fs";
|
|
42
|
+
import { dirname, isAbsolute, posix, relative, resolve } from "node:path";
|
|
43
43
|
|
|
44
44
|
// src/vite-plugin/controller-client-emit.ts
|
|
45
45
|
import { loadControllerWithSwc, walkControllerMetadata } from "@theokit/http";
|
|
@@ -427,4 +427,4 @@ export {
|
|
|
427
427
|
generateClientDts,
|
|
428
428
|
shouldReemitForFile
|
|
429
429
|
};
|
|
430
|
-
//# sourceMappingURL=app-typed-client-
|
|
430
|
+
//# sourceMappingURL=app-typed-client-XSXAORG6.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import "tsx/esm";
|
|
3
|
-
import "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
import "./chunk-22ZZSUKD.js";
|
|
4
|
+
import "./chunk-35QIWOHT.js";
|
|
5
5
|
import {
|
|
6
6
|
scanControllerModules
|
|
7
7
|
} from "./chunk-MWWFXYW3.js";
|
|
@@ -411,4 +411,4 @@ export {
|
|
|
411
411
|
generateClientDts,
|
|
412
412
|
shouldReemitForFile
|
|
413
413
|
};
|
|
414
|
-
//# sourceMappingURL=app-typed-client-
|
|
414
|
+
//# sourceMappingURL=app-typed-client-ZO3VKJ3O.js.map
|
package/dist/boot/index.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
serveReservedRoute
|
|
3
|
+
} from "../chunk-GAPBPRPP.js";
|
|
1
4
|
import {
|
|
2
5
|
envelopeCodeToStatus
|
|
3
6
|
} from "../chunk-ACKBVBUI.js";
|
|
@@ -5,9 +8,6 @@ import {
|
|
|
5
8
|
NotFoundError,
|
|
6
9
|
serverErrorToEnvelope
|
|
7
10
|
} from "../chunk-IZ3TIL6K.js";
|
|
8
|
-
import {
|
|
9
|
-
serveReservedRoute
|
|
10
|
-
} from "../chunk-GAPBPRPP.js";
|
|
11
11
|
import "../chunk-XTHN6JBX.js";
|
|
12
12
|
|
|
13
13
|
// src/server/boot.ts
|
|
@@ -554,7 +554,7 @@ async function buildCommand(options) {
|
|
|
554
554
|
`);
|
|
555
555
|
}
|
|
556
556
|
async function runAdapterBuild(target, config, cwd) {
|
|
557
|
-
const { theoPluginAsync } = await import("./vite-plugin-
|
|
557
|
+
const { theoPluginAsync } = await import("./vite-plugin-UET2BUFW.js");
|
|
558
558
|
const { default: react } = await import("@vitejs/plugin-react");
|
|
559
559
|
const ctx = {
|
|
560
560
|
// `react()` may return Plugin or Plugin[] depending on version; spread the
|
|
@@ -603,7 +603,7 @@ async function runAdapterBuild(target, config, cwd) {
|
|
|
603
603
|
};
|
|
604
604
|
}
|
|
605
605
|
};
|
|
606
|
-
const { resolveAdapter } = await import("./registry-
|
|
606
|
+
const { resolveAdapter } = await import("./registry-3LUHO4IB.js");
|
|
607
607
|
const adapter = await resolveAdapter(target);
|
|
608
608
|
const { warnUnappliedConfig, assertRateLimitEnforceable } = await import("./config-support-O4REYSK5.js");
|
|
609
609
|
assertRateLimitEnforceable(config, adapter, target);
|
|
@@ -676,4 +676,4 @@ function relativize3(absPath, root) {
|
|
|
676
676
|
export {
|
|
677
677
|
buildCommand
|
|
678
678
|
};
|
|
679
|
-
//# sourceMappingURL=build-
|
|
679
|
+
//# sourceMappingURL=build-4GQLIFTD.js.map
|
|
@@ -24,6 +24,107 @@ import {
|
|
|
24
24
|
// src/adapters/bun.ts
|
|
25
25
|
import { mkdirSync, writeFileSync } from "fs";
|
|
26
26
|
import { resolve } from "path";
|
|
27
|
+
|
|
28
|
+
// src/adapters/deployed-rate-limit.ts
|
|
29
|
+
var UnserialisableRateLimitError = class extends Error {
|
|
30
|
+
constructor(target, reason, ways) {
|
|
31
|
+
super(
|
|
32
|
+
[
|
|
33
|
+
`Refusing to build for \`${target}\`: theo.config.ts declares a rate limit this target cannot carry.`,
|
|
34
|
+
``,
|
|
35
|
+
` ${reason}`,
|
|
36
|
+
``,
|
|
37
|
+
` Ways forward:`,
|
|
38
|
+
...ways.map((w) => ` \u2022 ${w}`),
|
|
39
|
+
``,
|
|
40
|
+
` This refuses rather than dropping the key, because a rate limit that silently does not`,
|
|
41
|
+
` apply looks exactly like one that does (usetheokit/theokit#461, #508).`
|
|
42
|
+
].join("\n")
|
|
43
|
+
);
|
|
44
|
+
this.target = target;
|
|
45
|
+
this.reason = reason;
|
|
46
|
+
}
|
|
47
|
+
target;
|
|
48
|
+
reason;
|
|
49
|
+
name = "UnserialisableRateLimitError";
|
|
50
|
+
};
|
|
51
|
+
function bakeableRateLimit(rateLimit, target) {
|
|
52
|
+
if (rateLimit === void 0) return void 0;
|
|
53
|
+
const cfg = rateLimit;
|
|
54
|
+
if (typeof cfg.keyBy === "function") {
|
|
55
|
+
throw new UnserialisableRateLimitError(
|
|
56
|
+
target,
|
|
57
|
+
"`security.rateLimit.keyBy` is a function, and a deployed entry has no literal for a closure.",
|
|
58
|
+
[
|
|
59
|
+
"use `keyBy: 'ip'` (the default), which this target resolves from the connection",
|
|
60
|
+
"build for `node` and run `theokit start`, which can call the function"
|
|
61
|
+
]
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
if (cfg.keyBy === "session" || cfg.keyBy === "user") {
|
|
65
|
+
throw new UnserialisableRateLimitError(
|
|
66
|
+
target,
|
|
67
|
+
`\`security.rateLimit.keyBy: '${cfg.keyBy}'\` needs a resolved session, and the limit runs before routing.`,
|
|
68
|
+
[
|
|
69
|
+
"use `keyBy: 'ip'`, which is resolvable at that point",
|
|
70
|
+
"build for `node` and run `theokit start`"
|
|
71
|
+
]
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
if (cfg.routes !== void 0) {
|
|
75
|
+
throw new UnserialisableRateLimitError(
|
|
76
|
+
target,
|
|
77
|
+
"`security.rateLimit.routes` needs the matched route, which is decided after the limit runs here.",
|
|
78
|
+
[
|
|
79
|
+
"declare a single global limit (`windowMs` + `max`)",
|
|
80
|
+
"build for `node` and run `theokit start`, which applies per-route limits"
|
|
81
|
+
]
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
const windowMs = cfg.windowMs;
|
|
85
|
+
const max = cfg.max;
|
|
86
|
+
if (typeof windowMs !== "number" || typeof max !== "number") return void 0;
|
|
87
|
+
return { windowMs, max };
|
|
88
|
+
}
|
|
89
|
+
function deployedRateLimitFragment(rateLimit, target, addressExpression) {
|
|
90
|
+
const baked = bakeableRateLimit(rateLimit, target);
|
|
91
|
+
if (baked === void 0) return [];
|
|
92
|
+
return [
|
|
93
|
+
`// #508 \u2014 the limit the app declared, carried as a literal because a deployed entry has no`,
|
|
94
|
+
`// theo.config.ts to read. The counter lives in this process, which outlives a request here.`,
|
|
95
|
+
`const RATE_LIMIT = createRateLimiterWeb({ windowMs: ${baked.windowMs}, max: ${baked.max} })`,
|
|
96
|
+
``,
|
|
97
|
+
`/**`,
|
|
98
|
+
` * The caller's address, from the connection rather than from a header.`,
|
|
99
|
+
` *`,
|
|
100
|
+
` * A header a client can set is a key a client can choose, which makes the bucket theirs to`,
|
|
101
|
+
` * split. An unresolved address falls back to one shared bucket \u2014 rare here, since that only`,
|
|
102
|
+
` * happens for a connection already gone, and the same fallback \`theokit start\` uses.`,
|
|
103
|
+
` */`,
|
|
104
|
+
`function callerAddress(request, server) {`,
|
|
105
|
+
` return ${addressExpression} ?? 'unknown'`,
|
|
106
|
+
`}`,
|
|
107
|
+
``,
|
|
108
|
+
`/** The 429 a limited caller gets, carrying the limiter's own headers. */`,
|
|
109
|
+
`function rateLimited(result) {`,
|
|
110
|
+
` return new Response(JSON.stringify({ error: { code: 'RATE_LIMITED', message: 'Too many requests' } }), {`,
|
|
111
|
+
` status: 429,`,
|
|
112
|
+
` headers: { 'Content-Type': 'application/json', ...result.headers },`,
|
|
113
|
+
` })`,
|
|
114
|
+
`}`
|
|
115
|
+
];
|
|
116
|
+
}
|
|
117
|
+
function rateLimitCheckFragment(rateLimit, indent) {
|
|
118
|
+
if (rateLimit === void 0) return [];
|
|
119
|
+
return [
|
|
120
|
+
`${indent}const limit = RATE_LIMIT(callerAddress(request, server))`,
|
|
121
|
+
`${indent}if (limit.limited) {`,
|
|
122
|
+
`${indent} return withCors(request, withSecurityHeaders(rateLimited(limit), SECURITY_HEADERS))`,
|
|
123
|
+
`${indent}}`
|
|
124
|
+
];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// src/adapters/bun.ts
|
|
27
128
|
function renderBunEntry(port, opts = {}) {
|
|
28
129
|
const streamingComment = opts.ssrStreaming ? `// T2.3 \u2014 ssrStreaming on; renderStreamingWeb may be consumed by app code` : `// (ssrStreaming off)`;
|
|
29
130
|
const runtimeConfig = deployedRuntimeConfigFragment(opts);
|
|
@@ -58,7 +159,7 @@ function renderBunEntry(port, opts = {}) {
|
|
|
58
159
|
``,
|
|
59
160
|
`import { resolve, join } from 'node:path'`,
|
|
60
161
|
`import { existsSync } from 'node:fs'`,
|
|
61
|
-
`import { scanServerRoutes, matchRoute, executeRoute, createProductionLoader, extractTraceIdFromRequest, TRACE_HEADER, createCorsWebHandler } from 'theokit/server'`,
|
|
162
|
+
`import { scanServerRoutes, matchRoute, executeRoute, createProductionLoader, extractTraceIdFromRequest, TRACE_HEADER, createCorsWebHandler${opts.rateLimit === void 0 ? "" : ", createRateLimiterWeb"} } from 'theokit/server'`,
|
|
62
163
|
`import { createWebShim } from 'theokit/adapters/web-shim'`,
|
|
63
164
|
`import { buildSecurityHeaders, withSecurityHeaders } from 'theokit/adapters/security-headers'`,
|
|
64
165
|
`// T3.2 \u2014 WS bridge for Bun runtime`,
|
|
@@ -87,6 +188,8 @@ function renderBunEntry(port, opts = {}) {
|
|
|
87
188
|
``,
|
|
88
189
|
...deployedCorsFragment(opts.cors, "bun"),
|
|
89
190
|
``,
|
|
191
|
+
...deployedRateLimitFragment(opts.rateLimit, "bun", "server.requestIP(request)?.address"),
|
|
192
|
+
``,
|
|
90
193
|
`const routes = existsSync(serverDir) ? scanServerRoutes(serverDir) : []`,
|
|
91
194
|
`const wsRoutes = existsSync(serverDir) ? scanWebSocketRoutes(serverDir) : []`,
|
|
92
195
|
`const loadModule = createProductionLoader()`,
|
|
@@ -117,6 +220,7 @@ function renderBunEntry(port, opts = {}) {
|
|
|
117
220
|
` // handles is an OPTIONS the browser never gets a CORS answer to.`,
|
|
118
221
|
` const preflight = corsPreflight(request)`,
|
|
119
222
|
` if (preflight !== null) return withSecurityHeaders(preflight, SECURITY_HEADERS)`,
|
|
223
|
+
...rateLimitCheckFragment(opts.rateLimit, " "),
|
|
120
224
|
` return withCors(request, withSecurityHeaders(await handleRequest(request), SECURITY_HEADERS))`,
|
|
121
225
|
` },`,
|
|
122
226
|
`})`,
|
|
@@ -218,7 +322,18 @@ var bunAdapter = {
|
|
|
218
322
|
// literal and puts the built baseline on every response, the served document
|
|
219
323
|
// included.
|
|
220
324
|
servesAgents: true,
|
|
221
|
-
appliesConfig: [
|
|
325
|
+
appliesConfig: [
|
|
326
|
+
"securityHeaders",
|
|
327
|
+
"csrf",
|
|
328
|
+
"disallowed",
|
|
329
|
+
"cors",
|
|
330
|
+
"serialization",
|
|
331
|
+
"plugins",
|
|
332
|
+
// #508 — bun is the first Web target to ENFORCE a declared limit rather than refuse the
|
|
333
|
+
// build: `Bun.serve` is long-lived, so the in-process counter survives, and its handler
|
|
334
|
+
// already receives `server`, whose `requestIP` gives the peer address without a header.
|
|
335
|
+
"rateLimit"
|
|
336
|
+
],
|
|
222
337
|
build(config, cwd, ctx) {
|
|
223
338
|
return buildBun(config, cwd, {}, ctx);
|
|
224
339
|
}
|
|
@@ -228,4 +343,4 @@ export {
|
|
|
228
343
|
bunAdapter,
|
|
229
344
|
renderBunEntry
|
|
230
345
|
};
|
|
231
|
-
//# sourceMappingURL=bun-
|
|
346
|
+
//# sourceMappingURL=bun-POLTY2HK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/adapters/bun.ts","../src/adapters/deployed-rate-limit.ts"],"sourcesContent":["/* eslint-disable security/detect-non-literal-fs-filename --\n * Bun deploy adapter. Writes to `cwd/.theokit/bun/`. Build-time.\n */\nimport { mkdirSync, writeFileSync } from 'node:fs'\nimport { resolve } from 'node:path'\n\nimport type { TheoConfig } from '../config/schema.js'\nimport type { SecurityHeadersConfig } from '../core/contracts/security-headers.js'\nimport { assertServicesUnsupported, readManifest } from '../services/index.js'\n\nimport { deployedAgentsFragment } from './deployed-agents.js'\nimport { deployedCorsFragment, type DeployedCorsOptions } from './deployed-cors.js'\nimport { deployedCsrfFragment, type DeployedCsrfOptions } from './deployed-csrf.js'\nimport { planDeployedPlugins } from './deployed-plugins-module.js'\nimport {\n deployedRateLimitFragment,\n rateLimitCheckFragment,\n type DeployedRateLimitOptions,\n} from './deployed-rate-limit.js'\nimport {\n deployedRuntimeConfigFragment,\n type DeployedRuntimeConfigOptions,\n} from './deployed-runtime-config.js'\nimport { deployedTraceFragment } from './deployed-trace.js'\nimport { nodeAdapter } from './node.js'\nimport {\n describeDeployedSecurityHeaders,\n renderSecurityHeadersConfigLiteral,\n} from './security-headers.js'\nimport type { AdapterBuildContext, DeployAdapter } from './types.js'\n\nexport interface BunBuildDeps {\n runNodeBuild?: (config: TheoConfig, cwd: string, ctx?: AdapterBuildContext) => Promise<void>\n writeEntry?: (path: string, content: string) => void\n ensureDir?: (path: string) => void\n}\n\nexport function renderBunEntry(\n port: number,\n opts: {\n ssrStreaming?: boolean\n securityHeaders?: SecurityHeadersConfig\n } & DeployedCsrfOptions &\n DeployedRuntimeConfigOptions &\n DeployedCorsOptions &\n DeployedRateLimitOptions = {},\n): string {\n const streamingComment = opts.ssrStreaming\n ? `// T2.3 — ssrStreaming on; renderStreamingWeb may be consumed by app code`\n : `// (ssrStreaming off)`\n const runtimeConfig = deployedRuntimeConfigFragment(opts)\n const agentsFragment = deployedAgentsFragment(\n { kind: 'scan', projectRoot: 'cwd', loadModule: 'loadModule' },\n { pathname: 'pathname' },\n )\n return [\n `// Generated by Theo — Bun Adapter`,\n `// Run: bun run .theokit/bun/server.mjs`,\n `// Requires Bun >= 1.1`,\n streamingComment,\n ``,\n `// EC-1: dev-mode guard`,\n `if (process.env.NODE_ENV !== 'production') {`,\n ` console.error('TheoBunAdapter is production-only. Use \\\\'theokit dev\\\\' (Node) for development.')`,\n ` process.exit(1)`,\n `}`,\n ``,\n `// Version check: Bun >= 1.1`,\n `if (typeof Bun === 'undefined') {`,\n ` console.error('TheoBunAdapter must run inside Bun. Got Node.js or unknown runtime.')`,\n ` process.exit(1)`,\n `}`,\n `{`,\n ` const [maj, min] = (Bun.version ?? '0.0').split('.').map(Number)`,\n ` if (maj < 1 || (maj === 1 && min < 1)) {`,\n ` console.error('TheoBunAdapter requires Bun >= 1.1; got ' + Bun.version)`,\n ` process.exit(1)`,\n ` }`,\n `}`,\n ``,\n `import { resolve, join } from 'node:path'`,\n `import { existsSync } from 'node:fs'`,\n `import { scanServerRoutes, matchRoute, executeRoute, createProductionLoader, extractTraceIdFromRequest, TRACE_HEADER, createCorsWebHandler${opts.rateLimit === undefined ? '' : ', createRateLimiterWeb'} } from 'theokit/server'`,\n `import { createWebShim } from 'theokit/adapters/web-shim'`,\n `import { buildSecurityHeaders, withSecurityHeaders } from 'theokit/adapters/security-headers'`,\n `// T3.2 — WS bridge for Bun runtime`,\n `import { createBunWsBridge } from 'theokit/adapters/ws-shim'`,\n `import { scanWebSocketRoutes } from 'theokit/server'`,\n ``,\n `const cwd = process.cwd()`,\n `const clientDir = resolve(cwd, '.theokit/client')`,\n `const serverDir = resolve(cwd, 'server')`,\n `const port = process.env.PORT ? Number(process.env.PORT) : ${port}`,\n ``,\n `// #410 — the security baseline \\`theokit start\\` puts on every response,`,\n `// carried here as a literal because the deployed process has no`,\n `// theo.config.ts to read. Bun is the one Web target whose own handler serves`,\n `// the HTML document (static file + SPA fallback below), so the document gets`,\n `// these headers too -- with a nonce-less CSP, because that HTML was written`,\n `// at build time and carries no nonce on its script tags (EC-4).`,\n `const SECURITY_HEADERS_CONFIG = ${renderSecurityHeadersConfigLiteral(opts.securityHeaders)}`,\n `const SECURITY_HEADERS = buildSecurityHeaders(SECURITY_HEADERS_CONFIG, { production: true })`,\n ``,\n ...runtimeConfig.imports,\n ...agentsFragment.imports,\n ...runtimeConfig.declarations,\n ...agentsFragment.declarations,\n ...deployedCsrfFragment(opts),\n ``,\n ...deployedCorsFragment(opts.cors, 'bun'),\n ``,\n ...deployedRateLimitFragment(opts.rateLimit, 'bun', 'server.requestIP(request)?.address'),\n ``,\n `const routes = existsSync(serverDir) ? scanServerRoutes(serverDir) : []`,\n `const wsRoutes = existsSync(serverDir) ? scanWebSocketRoutes(serverDir) : []`,\n `const loadModule = createProductionLoader()`,\n ``,\n `// Bun WebSocket config — single handler dispatches to first ws route,`,\n `// or a default no-op when none declared. Per-route routing happens above`,\n `// (the upgrade decision is made in fetch handler before Bun.serve hands off).`,\n `const wsBridge = wsRoutes.length > 0`,\n ` ? createBunWsBridge({`,\n ` onOpen: () => {},`,\n ` onMessage: (ws, data) => { ws.send(data) },`,\n ` onClose: () => {},`,\n ` })`,\n ` : { open: () => {}, message: () => {}, close: () => {} }`,\n ``,\n `function notFoundResponse() {`,\n ` return new Response(JSON.stringify({ error: { code: 'NOT_FOUND', message: 'Route not found' } }), {`,\n ` status: 404,`,\n ` headers: { 'Content-Type': 'application/json' },`,\n ` })`,\n `}`,\n ``,\n `Bun.serve({`,\n ` port,`,\n ` websocket: wsBridge,`,\n ` async fetch(request, server) {`,\n ` // #409 — the preflight is answered BEFORE anything routes: an OPTIONS the router`,\n ` // handles is an OPTIONS the browser never gets a CORS answer to.`,\n ` const preflight = corsPreflight(request)`,\n ` if (preflight !== null) return withSecurityHeaders(preflight, SECURITY_HEADERS)`,\n ...rateLimitCheckFragment(opts.rateLimit, ' '),\n ` return withCors(request, withSecurityHeaders(await handleRequest(request), SECURITY_HEADERS))`,\n ` },`,\n `})`,\n ``,\n ...bunHandleRequestFragment(runtimeConfig.executeRouteSpread, agentsFragment.branch),\n ].join('\\n')\n}\n\n/**\n * The request handler, as generated source.\n *\n * Extracted for the reason `vercel.ts` extracts its own fragments: the emitter is one array\n * literal, so every line the entry gains counts against `max-lines-per-function`, and #410 added\n * the CSRF literal to an emitter that was already sitting exactly at the ceiling.\n */\nfunction bunHandleRequestFragment(runtimeSpread: string, agentBranch: readonly string[]): string[] {\n return [\n `async function handleRequest(request) {`,\n ` const url = new URL(request.url)`,\n ` const pathname = url.pathname`,\n ``,\n ` // 1) Static assets`,\n ` const staticPath = pathname === '/' ? '/index.html' : pathname`,\n ` const fullStatic = join(clientDir, staticPath)`,\n ` if (existsSync(fullStatic)) {`,\n ` const file = Bun.file(fullStatic)`,\n ` if (await file.exists()) return new Response(file)`,\n ` }`,\n ``,\n ` // 2) API routes through the full executeRoute pipeline via the shim`,\n ` if (pathname.startsWith('/api/')) {`,\n ...agentBranch,\n ``,\n ` const match = matchRoute(pathname, routes)`,\n ` if (!match) return notFoundResponse()`,\n ` const { req, res, toResponse } = createWebShim(request)`,\n ...deployedTraceFragment('request', ' '),\n ` const method = request.method.toUpperCase()`,\n ` // #382 — not awaited: toResponse() settles at the headers and carries`,\n ` // a live body, so Bun.serve streams while the handler writes.`,\n ` return toResponse(executeRoute({ route: match.route, method, params: match.params, req, res, loadModule, serverDir, requestId, ...CSRF_CONFIG, ${runtimeSpread} }))`,\n ` }`,\n ``,\n ` // 3) SPA fallback`,\n ` const indexPath = join(clientDir, 'index.html')`,\n ` if (existsSync(indexPath)) return new Response(Bun.file(indexPath))`,\n ``,\n ` return notFoundResponse()`,\n `}`,\n ``,\n `console.log('Theo (Bun) listening on http://localhost:' + port)`,\n ]\n}\n\nexport async function buildBun(\n config: TheoConfig,\n cwd: string,\n deps: BunBuildDeps = {},\n ctx?: AdapterBuildContext,\n): Promise<void> {\n // Wave 2 (T2.2) — reject polyglot services on this adapter.\n assertServicesUnsupported('bun', readManifest(cwd))\n\n const runNodeBuild = deps.runNodeBuild ?? nodeAdapter.build.bind(nodeAdapter)\n await runNodeBuild(config, cwd, ctx)\n\n const outputDir = resolve(cwd, '.theokit/bun')\n const ensureDir = deps.ensureDir ?? ((p: string) => mkdirSync(p, { recursive: true }))\n ensureDir(outputDir)\n\n const pluginsPlan = planDeployedPlugins(config.plugins, 'bun')\n const entry = renderBunEntry(config.port, {\n ssrStreaming: config.ssrStreaming,\n securityHeaders: config.security?.headers,\n csrf: config.security?.csrf,\n disallowed: config.security?.disallowed,\n cors: config.security?.cors,\n // #425 — a selector, not a transformer, so it rides as a literal like the values above.\n serialization: config.serialization,\n // #425 — the ONE concern that is not a literal. A closure cannot be baked, so a plugin\n // declared by module specifier is imported by the emitted module instead; a constructed one\n // is refused by name at build time rather than dropped in silence.\n runtimeConfigModule: pluginsPlan?.moduleSpecifier,\n })\n const write =\n deps.writeEntry ??\n ((p, c) => {\n writeFileSync(p, c)\n })\n if (pluginsPlan !== undefined) {\n // Beside the entry, so the emitted import is a sibling. Written through the same seam as\n // the entry so a test that captures one captures both (#425).\n write(resolve(outputDir, 'theo.plugins.mjs'), pluginsPlan.source)\n }\n write(resolve(outputDir, 'server.mjs'), entry)\n\n // eslint-disable-next-line no-console -- CLI build progress\n console.log('\\n ✓ Bun output → .theokit/bun/server.mjs')\n // eslint-disable-next-line no-console -- CLI build progress\n console.log(\n `${describeDeployedSecurityHeaders({\n target: 'bun',\n securityHeaders: config.security?.headers,\n // No deploy target other than the streamed Cloudflare worker renders HTML\n // at request time, so none of the rest can mint a nonce.\n mintsNonce: false,\n // Bun serves `.theokit/client` itself, so the document DOES pass through\n // the handler these headers are attached to.\n documentHeaders: 'handler',\n })}\\n`,\n )\n}\n\nexport const bunAdapter: DeployAdapter = {\n name: 'bun',\n streamsResponses: true,\n // #409 / #410 — the generated entry calls `executeRoute` with routes, loader\n // and serverDir only. CSRF, route policy, file middleware and Zod validation\n // still run because they live inside `executeRoute`; none of the remaining\n // configurable concerns reach it. Declared explicitly rather than omitted so\n // the gap is a statement in the source and not an absence.\n //\n // `securityHeaders` IS applied: the entry carries `security.headers` as a\n // literal and puts the built baseline on every response, the served document\n // included.\n servesAgents: true,\n appliesConfig: [\n 'securityHeaders',\n 'csrf',\n 'disallowed',\n 'cors',\n 'serialization',\n 'plugins',\n // #508 — bun is the first Web target to ENFORCE a declared limit rather than refuse the\n // build: `Bun.serve` is long-lived, so the in-process counter survives, and its handler\n // already receives `server`, whose `requestIP` gives the peer address without a header.\n 'rateLimit',\n ],\n build(config, cwd, ctx) {\n return buildBun(config, cwd, {}, ctx)\n },\n}\n","/**\n * The rate limit a deployed entry carries, baked at build time.\n *\n * ## What #508 asked for, and what this answers\n *\n * `theokit build` refuses the six Web-standards targets when `theo.config.ts` declares a\n * `rateLimit` (`UnenforceableRateLimitError`). That refusal is honest and it is not enforcement.\n * The issue names three things standing between the refusal and a working limit: per-runtime\n * caller-address resolution, a refusal that survives where the address cannot be resolved, and\n * storage that outlives one invocation.\n *\n * For `bun` all three already have answers, which is why it is the target that moves first:\n *\n * - **Address** — `Bun.serve`'s handler is `fetch(request, server)`, and `server.requestIP(request)`\n * returns the peer address without depending on a proxy header a client could set.\n * - **Storage** — `Bun.serve` is a long-lived process. `createRateLimiterWeb`'s default\n * `InMemoryStore` therefore behaves exactly as it does under `theokit start`, which is the\n * deployment `node` already ships.\n * - **Refusal** — see below: every shape whose key cannot be resolved in a deployed entry throws\n * at BUILD time rather than degrading.\n *\n * ## Why the other five are not here\n *\n * Cloudflare, AWS Lambda, Netlify and Vercel are per-invocation runtimes: an in-process counter\n * does not survive between requests, so a limiter built on one forgets. A limit that forgets is a\n * limit that does not limit — the same class of failure as the shared bucket, reached by a\n * different road. Deno Deploy evicts isolates for the same reason. Those need an external counter,\n * which is a storage design and not a wiring change, so they keep refusing by name.\n *\n * Being explicit about that boundary is the point. The failure this whole area exists to prevent is\n * a config that reads as protection while protecting nothing.\n */\nimport type { TheoConfig } from '../config/schema.js'\n\ntype RateLimitConfig = NonNullable<TheoConfig['rateLimit']>\n\n/** The rate-limit slice of an adapter's build options, named once like `DeployedCorsOptions`. */\nexport interface DeployedRateLimitOptions {\n rateLimit?: RateLimitConfig\n}\n\n/**\n * Thrown at BUILD time when a declared rate limit cannot be carried into a deployed entry.\n *\n * Distinct from {@link UnenforceableRateLimitError}, and the distinction is not cosmetic: that one\n * means *this target enforces no limit at all*, this one means *this target enforces limits, and\n * cannot carry THIS one*. An operator reading the first looks for another target; an operator\n * reading the second changes the key.\n */\nexport class UnserialisableRateLimitError extends Error {\n override readonly name = 'UnserialisableRateLimitError'\n constructor(\n readonly target: string,\n readonly reason: string,\n ways: readonly string[],\n ) {\n super(\n [\n `Refusing to build for \\`${target}\\`: theo.config.ts declares a rate limit this target cannot carry.`,\n ``,\n ` ${reason}`,\n ``,\n ` Ways forward:`,\n ...ways.map((w) => ` • ${w}`),\n ``,\n ` This refuses rather than dropping the key, because a rate limit that silently does not`,\n ` apply looks exactly like one that does (usetheokit/theokit#461, #508).`,\n ].join('\\n'),\n )\n }\n}\n\n/** The base shape every accepted config narrows to: a window, a ceiling, and an IP key. */\ninterface BakeableRateLimit {\n windowMs: number\n max: number\n}\n\n/**\n * Narrow a declared rate limit to what a deployed entry can actually enforce, or refuse by name.\n *\n * Accepts the base `{ windowMs, max }` and the explicit `keyBy: 'ip'`, which is what the address\n * resolution below can key. Everything else throws:\n *\n * - a **function** `keyBy` has no literal — the same wall `deployed-cors.ts` hits on a callback\n * origin, and refused for the same reason;\n * - `keyBy: 'session' | 'user'` needs a session the deployed entry does not resolve at the point\n * the limit runs, which is before routing;\n * - `routes` needs the matched route, decided after this check. Refusing it is honest today and is\n * the natural next slice.\n */\nfunction bakeableRateLimit(\n rateLimit: RateLimitConfig | undefined,\n target: string,\n): BakeableRateLimit | undefined {\n if (rateLimit === undefined) return undefined\n const cfg = rateLimit as Record<string, unknown>\n\n if (typeof cfg.keyBy === 'function') {\n throw new UnserialisableRateLimitError(\n target,\n '`security.rateLimit.keyBy` is a function, and a deployed entry has no literal for a closure.',\n [\n \"use `keyBy: 'ip'` (the default), which this target resolves from the connection\",\n 'build for `node` and run `theokit start`, which can call the function',\n ],\n )\n }\n if (cfg.keyBy === 'session' || cfg.keyBy === 'user') {\n throw new UnserialisableRateLimitError(\n target,\n `\\`security.rateLimit.keyBy: '${cfg.keyBy}'\\` needs a resolved session, and the limit runs before routing.`,\n [\n \"use `keyBy: 'ip'`, which is resolvable at that point\",\n 'build for `node` and run `theokit start`',\n ],\n )\n }\n if (cfg.routes !== undefined) {\n throw new UnserialisableRateLimitError(\n target,\n '`security.rateLimit.routes` needs the matched route, which is decided after the limit runs here.',\n [\n 'declare a single global limit (`windowMs` + `max`)',\n 'build for `node` and run `theokit start`, which applies per-route limits',\n ],\n )\n }\n\n const windowMs = cfg.windowMs\n const max = cfg.max\n if (typeof windowMs !== 'number' || typeof max !== 'number') return undefined\n return { windowMs, max }\n}\n\n/**\n * The generated declarations and helper for a target that keys on the connection's peer address.\n *\n * `addressExpression` is the per-runtime half the issue calls out — the one thing that genuinely\n * differs between targets. Bun passes `server`; a future Deno slice would pass its\n * `ServeHandlerInfo`. Everything else here is shared.\n *\n * Returns `[]` when nothing was declared, so an app without a limit emits no limiter at all rather\n * than an inert one.\n */\nexport function deployedRateLimitFragment(\n rateLimit: RateLimitConfig | undefined,\n target: string,\n addressExpression: string,\n): string[] {\n const baked = bakeableRateLimit(rateLimit, target)\n if (baked === undefined) return []\n return [\n `// #508 — the limit the app declared, carried as a literal because a deployed entry has no`,\n `// theo.config.ts to read. The counter lives in this process, which outlives a request here.`,\n `const RATE_LIMIT = createRateLimiterWeb({ windowMs: ${baked.windowMs}, max: ${baked.max} })`,\n ``,\n `/**`,\n ` * The caller's address, from the connection rather than from a header.`,\n ` *`,\n ` * A header a client can set is a key a client can choose, which makes the bucket theirs to`,\n ` * split. An unresolved address falls back to one shared bucket — rare here, since that only`,\n ` * happens for a connection already gone, and the same fallback \\`theokit start\\` uses.`,\n ` */`,\n `function callerAddress(request, server) {`,\n ` return ${addressExpression} ?? 'unknown'`,\n `}`,\n ``,\n `/** The 429 a limited caller gets, carrying the limiter's own headers. */`,\n `function rateLimited(result) {`,\n ` return new Response(JSON.stringify({ error: { code: 'RATE_LIMITED', message: 'Too many requests' } }), {`,\n ` status: 429,`,\n ` headers: { 'Content-Type': 'application/json', ...result.headers },`,\n ` })`,\n `}`,\n ]\n}\n\n/**\n * The check itself, as generated source, placed inside the runtime's request handler.\n *\n * Extracted for the reason `bun.ts` extracts its other fragments: the emitter is one array literal,\n * so every line the entry gains counts against `max-lines-per-function`, and this one pushed it\n * past the ceiling.\n *\n * Runs AFTER the CORS preflight and BEFORE routing: a limited caller should not reach a handler,\n * and a browser still needs its CORS answer to read the 429 as a 429 rather than as a network\n * failure.\n */\nexport function rateLimitCheckFragment(\n rateLimit: RateLimitConfig | undefined,\n indent: string,\n): string[] {\n if (rateLimit === undefined) return []\n return [\n `${indent}const limit = RATE_LIMIT(callerAddress(request, server))`,\n `${indent}if (limit.limited) {`,\n `${indent} return withCors(request, withSecurityHeaders(rateLimited(limit), SECURITY_HEADERS))`,\n `${indent}}`,\n ]\n}\n"],"mappings":"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","names":[]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import "tsx/esm";
|
|
3
3
|
import {
|
|
4
4
|
getApprovalRegistry
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-35QIWOHT.js";
|
|
6
6
|
import {
|
|
7
7
|
createWebRequestSource,
|
|
8
8
|
dispatchCsrfWarn,
|
|
@@ -2616,4 +2616,4 @@ export {
|
|
|
2616
2616
|
CsrfReadinessStore,
|
|
2617
2617
|
applySecurityHeaders
|
|
2618
2618
|
};
|
|
2619
|
-
//# sourceMappingURL=chunk-
|
|
2619
|
+
//# sourceMappingURL=chunk-22ZZSUKD.js.map
|
|
@@ -76,13 +76,14 @@ function declaredPrefixOf(modelId) {
|
|
|
76
76
|
function takesCredential(desc) {
|
|
77
77
|
return desc.envKey !== void 0;
|
|
78
78
|
}
|
|
79
|
+
var KEYLESS_API_KEY = "local";
|
|
79
80
|
function resolveProvider(modelId, options) {
|
|
80
81
|
const sorted = [...registryOf()].sort((a, b) => a.priority - b.priority);
|
|
81
82
|
const declared = modelId === void 0 ? void 0 : providerOf(modelId, sorted);
|
|
82
83
|
if (declared !== void 0 && modelId !== void 0) {
|
|
83
84
|
if (declared.envKey === void 0) {
|
|
84
85
|
announce(declared, "declared by the model", options);
|
|
85
|
-
return { name: declared.name, apiKey:
|
|
86
|
+
return { name: declared.name, apiKey: KEYLESS_API_KEY, baseUrl: baseUrlOf(declared) };
|
|
86
87
|
}
|
|
87
88
|
const apiKey = process.env[declared.envKey];
|
|
88
89
|
if (apiKey && apiKey.length > 0) {
|
|
@@ -93,6 +94,12 @@ function resolveProvider(modelId, options) {
|
|
|
93
94
|
`Model "${modelId}" declares provider "${declared.name}", but ${declared.envKey} is not set. Set ${declared.envKey}, or change the model's provider prefix.`
|
|
94
95
|
);
|
|
95
96
|
}
|
|
97
|
+
const unregisteredPrefix = declared === void 0 ? declaredPrefixOf(modelId) : void 0;
|
|
98
|
+
if (unregisteredPrefix !== void 0) {
|
|
99
|
+
throw new Error(
|
|
100
|
+
`Model "${String(modelId)}" declares provider "${unregisteredPrefix}", which is not registered. Registered providers: ${sorted.map((p) => p.name).join(", ")}. Register it with registerProvider({ name: '${unregisteredPrefix}', \u2026 }), or use a registered prefix.`
|
|
101
|
+
);
|
|
102
|
+
}
|
|
96
103
|
const credentialed = sorted.filter(takesCredential);
|
|
97
104
|
for (const desc of credentialed) {
|
|
98
105
|
const apiKey = process.env[desc.envKey];
|
|
@@ -105,12 +112,6 @@ function resolveProvider(modelId, options) {
|
|
|
105
112
|
};
|
|
106
113
|
}
|
|
107
114
|
}
|
|
108
|
-
const prefix = declaredPrefixOf(modelId);
|
|
109
|
-
if (prefix !== void 0) {
|
|
110
|
-
throw new Error(
|
|
111
|
-
`Model "${modelId}" declares provider "${prefix}", which is not registered. Registered providers: ${sorted.map((p) => p.name).join(", ")}. Register it with registerProvider({ name: '${prefix}', \u2026 }), or use a registered prefix.`
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
115
|
const envKeys = credentialed.map((p) => p.envKey).join(" OR ");
|
|
115
116
|
throw new Error(
|
|
116
117
|
`No LLM provider API key found in environment. Set one of: ${envKeys}. Get a free OpenRouter key at https://openrouter.ai/keys (recommended \u2014 one key, many models).`
|
|
@@ -178,4 +179,4 @@ export {
|
|
|
178
179
|
getApprovalRegistry,
|
|
179
180
|
resolveProvider
|
|
180
181
|
};
|
|
181
|
-
//# sourceMappingURL=chunk-
|
|
182
|
+
//# sourceMappingURL=chunk-35QIWOHT.js.map
|