theokit 0.2.0 → 0.2.2

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 (130) hide show
  1. package/dist/actions-virtual-module-E6PU47GV.js +175 -0
  2. package/dist/actions-virtual-module-E6PU47GV.js.map +1 -0
  3. package/dist/actions-virtual-module-E7IELVHL.js +174 -0
  4. package/dist/actions-virtual-module-E7IELVHL.js.map +1 -0
  5. package/dist/app-typed-client-RZMVWHJ3.js +289 -0
  6. package/dist/app-typed-client-RZMVWHJ3.js.map +1 -0
  7. package/dist/app-typed-client-YIBP6JWH.js +289 -0
  8. package/dist/app-typed-client-YIBP6JWH.js.map +1 -0
  9. package/dist/{aws-lambda-PONVF3UX.js → aws-lambda-XYCGZH3I.js} +2 -2
  10. package/dist/{build-IQQYCA3B.js → build-NCGIV4LL.js} +41 -14
  11. package/dist/build-NCGIV4LL.js.map +1 -0
  12. package/dist/build-request-body-preview-EOP2Y4F3.js +52 -0
  13. package/dist/build-request-body-preview-EOP2Y4F3.js.map +1 -0
  14. package/dist/build-request-body-preview-II2235E6.js +54 -0
  15. package/dist/build-request-body-preview-II2235E6.js.map +1 -0
  16. package/dist/{bun-DITMZMKL.js → bun-K73TQEWC.js} +2 -2
  17. package/dist/{chunk-GQSTRXXB.js → chunk-2BQYEBCK.js} +77 -68
  18. package/dist/chunk-2BQYEBCK.js.map +1 -0
  19. package/dist/chunk-7DHGV77J.js +140 -0
  20. package/dist/chunk-7DHGV77J.js.map +1 -0
  21. package/dist/{chunk-WQCPKA2L.js → chunk-C27AZN46.js} +570 -165
  22. package/dist/chunk-C27AZN46.js.map +1 -0
  23. package/dist/chunk-ERAZNHHR.js +73 -0
  24. package/dist/chunk-ERAZNHHR.js.map +1 -0
  25. package/dist/{chunk-ZK5JCE5J.js → chunk-EXJWO2HB.js} +201 -43
  26. package/dist/chunk-EXJWO2HB.js.map +1 -0
  27. package/dist/chunk-F3TG5FJV.js +97 -0
  28. package/dist/chunk-F3TG5FJV.js.map +1 -0
  29. package/dist/{chunk-OK2PJOLK.js → chunk-KJVEJILQ.js} +7 -3
  30. package/dist/chunk-KJVEJILQ.js.map +1 -0
  31. package/dist/{chunk-JBC7PFV4.js → chunk-M23FP2AS.js} +2 -2
  32. package/dist/chunk-M23FP2AS.js.map +1 -0
  33. package/dist/{chunk-FRBYJANT.js → chunk-M6MYZSD2.js} +195 -41
  34. package/dist/chunk-M6MYZSD2.js.map +1 -0
  35. package/dist/{chunk-S3JBIFKS.js → chunk-MG7H3LAW.js} +2 -2
  36. package/dist/chunk-MOT42NAH.js +165 -0
  37. package/dist/chunk-MOT42NAH.js.map +1 -0
  38. package/dist/{chunk-OEB3OIYP.js → chunk-OJHO2X7C.js} +497 -168
  39. package/dist/chunk-OJHO2X7C.js.map +1 -0
  40. package/dist/chunk-QLGES2HC.js +189 -0
  41. package/dist/chunk-QLGES2HC.js.map +1 -0
  42. package/dist/{chunk-JZ5WEG3S.js → chunk-SEVYARIU.js} +9 -5
  43. package/dist/chunk-SEVYARIU.js.map +1 -0
  44. package/dist/chunk-WSJKACWB.js +17 -0
  45. package/dist/chunk-WSJKACWB.js.map +1 -0
  46. package/dist/{chunk-3Q36SEDK.js → chunk-ZBWROIIO.js} +43 -2
  47. package/dist/{chunk-3Q36SEDK.js.map → chunk-ZBWROIIO.js.map} +1 -1
  48. package/dist/{chunk-Y5KE6YFP.js → chunk-ZJW5FFYJ.js} +3 -3
  49. package/dist/chunk-ZJW5FFYJ.js.map +1 -0
  50. package/dist/chunk-ZOXNJV2O.js +358 -0
  51. package/dist/chunk-ZOXNJV2O.js.map +1 -0
  52. package/dist/cli/index.js +22 -7
  53. package/dist/cli/index.js.map +1 -1
  54. package/dist/client/index.d.ts +31 -1
  55. package/dist/client/index.js +100 -0
  56. package/dist/client/index.js.map +1 -1
  57. package/dist/{cloudflare-RBANU3SE.js → cloudflare-LCAOTRYZ.js} +2 -2
  58. package/dist/{deno-deploy-J7LI6HNL.js → deno-deploy-ZN4RE5HF.js} +2 -2
  59. package/dist/{dev-VN6WS3CM.js → dev-WDXC74CK.js} +15 -7
  60. package/dist/dev-WDXC74CK.js.map +1 -0
  61. package/dist/dev-emit-3CHM73TV.js +390 -0
  62. package/dist/dev-emit-3CHM73TV.js.map +1 -0
  63. package/dist/dev-emit-I3CKOHML.js +44 -0
  64. package/dist/dev-emit-I3CKOHML.js.map +1 -0
  65. package/dist/devtools/entry.js +545 -181
  66. package/dist/devtools/entry.js.map +1 -1
  67. package/dist/{dispatcher-IK3FVMX5.js → dispatcher-AQJGI3HU.js} +2 -2
  68. package/dist/dispatcher-E6QV32BO.js +83 -0
  69. package/dist/dispatcher-E6QV32BO.js.map +1 -0
  70. package/dist/{dist-Q5VBFWVL.js → dist-R2Q7GVDW.js} +10357 -12068
  71. package/dist/dist-R2Q7GVDW.js.map +1 -0
  72. package/dist/{generate-SIO4JSKJ.js → generate-DT4IIAHF.js} +88 -22
  73. package/dist/generate-DT4IIAHF.js.map +1 -0
  74. package/dist/index.d.ts +108 -1
  75. package/dist/index.js +5 -2
  76. package/dist/index.js.map +1 -1
  77. package/dist/{info-B3UOXFUF.js → info-VM7EK4JC.js} +3 -3
  78. package/dist/{netlify-IFY6ZGFV.js → netlify-5VQ22Z2P.js} +2 -2
  79. package/dist/{node-KWZI3CKV.js → node-3APTLGWB.js} +2 -2
  80. package/dist/openapi-CBASKC7W.js +84 -0
  81. package/dist/openapi-CBASKC7W.js.map +1 -0
  82. package/dist/registry-5QFTLOL2.js +25 -0
  83. package/dist/{routes-CAGFZKUK.js → routes-7O4NUDYS.js} +9 -7
  84. package/dist/{routes-CAGFZKUK.js.map → routes-7O4NUDYS.js.map} +1 -1
  85. package/dist/{schema-Cxq2qqwh.d.ts → schema-CjVly9c_.d.ts} +43 -1
  86. package/dist/{schema-MVB2FVK6.js → schema-JAKF23GR.js} +2 -2
  87. package/dist/server/cost/index.js +1 -1
  88. package/dist/server/index.d.ts +219 -47
  89. package/dist/server/index.js +35 -116
  90. package/dist/server/index.js.map +1 -1
  91. package/dist/{start-ZGWW5MOL.js → start-5JTFWF4T.js} +20 -14
  92. package/dist/start-5JTFWF4T.js.map +1 -0
  93. package/dist/{static-BH6JQNM2.js → static-TZBVBDTB.js} +4 -4
  94. package/dist/{upgrade-readiness-OHL36FQL.js → upgrade-readiness-Q46KTG2J.js} +6 -1
  95. package/dist/upgrade-readiness-Q46KTG2J.js.map +1 -0
  96. package/dist/{vercel-RHADE5IP.js → vercel-MWW24ABC.js} +2 -2
  97. package/dist/vite-plugin/index.d.ts +25 -1
  98. package/dist/vite-plugin/index.js +5 -2
  99. package/dist/{vite-plugin-WA3G45YY.js → vite-plugin-4WZ3C2AC.js} +7 -6
  100. package/package.json +4 -2
  101. package/dist/build-IQQYCA3B.js.map +0 -1
  102. package/dist/chunk-FRBYJANT.js.map +0 -1
  103. package/dist/chunk-GQSTRXXB.js.map +0 -1
  104. package/dist/chunk-JBC7PFV4.js.map +0 -1
  105. package/dist/chunk-JZ5WEG3S.js.map +0 -1
  106. package/dist/chunk-OEB3OIYP.js.map +0 -1
  107. package/dist/chunk-OK2PJOLK.js.map +0 -1
  108. package/dist/chunk-WQCPKA2L.js.map +0 -1
  109. package/dist/chunk-Y5KE6YFP.js.map +0 -1
  110. package/dist/chunk-ZK5JCE5J.js.map +0 -1
  111. package/dist/dev-VN6WS3CM.js.map +0 -1
  112. package/dist/dist-Q5VBFWVL.js.map +0 -1
  113. package/dist/generate-SIO4JSKJ.js.map +0 -1
  114. package/dist/registry-BB3UYAOG.js +0 -25
  115. package/dist/start-ZGWW5MOL.js.map +0 -1
  116. package/dist/upgrade-readiness-OHL36FQL.js.map +0 -1
  117. /package/dist/{aws-lambda-PONVF3UX.js.map → aws-lambda-XYCGZH3I.js.map} +0 -0
  118. /package/dist/{bun-DITMZMKL.js.map → bun-K73TQEWC.js.map} +0 -0
  119. /package/dist/{chunk-S3JBIFKS.js.map → chunk-MG7H3LAW.js.map} +0 -0
  120. /package/dist/{cloudflare-RBANU3SE.js.map → cloudflare-LCAOTRYZ.js.map} +0 -0
  121. /package/dist/{deno-deploy-J7LI6HNL.js.map → deno-deploy-ZN4RE5HF.js.map} +0 -0
  122. /package/dist/{dispatcher-IK3FVMX5.js.map → dispatcher-AQJGI3HU.js.map} +0 -0
  123. /package/dist/{info-B3UOXFUF.js.map → info-VM7EK4JC.js.map} +0 -0
  124. /package/dist/{netlify-IFY6ZGFV.js.map → netlify-5VQ22Z2P.js.map} +0 -0
  125. /package/dist/{node-KWZI3CKV.js.map → node-3APTLGWB.js.map} +0 -0
  126. /package/dist/{registry-BB3UYAOG.js.map → registry-5QFTLOL2.js.map} +0 -0
  127. /package/dist/{schema-MVB2FVK6.js.map → schema-JAKF23GR.js.map} +0 -0
  128. /package/dist/{static-BH6JQNM2.js.map → static-TZBVBDTB.js.map} +0 -0
  129. /package/dist/{vercel-RHADE5IP.js.map → vercel-MWW24ABC.js.map} +0 -0
  130. /package/dist/{vite-plugin-WA3G45YY.js.map → vite-plugin-4WZ3C2AC.js.map} +0 -0
@@ -1,3 +1,8 @@
1
+ import {
2
+ generateManifest,
3
+ loadManifest,
4
+ writeManifest
5
+ } from "../chunk-ERAZNHHR.js";
1
6
  import {
2
7
  _resetKeyCacheForTests,
3
8
  assertProductionSecret,
@@ -28,7 +33,7 @@ import {
28
33
  InMemoryUsageStorage,
29
34
  trackAgentRun,
30
35
  trackAgentTools
31
- } from "../chunk-JBC7PFV4.js";
36
+ } from "../chunk-M23FP2AS.js";
32
37
  import {
33
38
  CRON_MANIFEST_SCHEMA_VERSION,
34
39
  DuplicateCronNameError,
@@ -62,6 +67,8 @@ import {
62
67
  generateNewTraceContext
63
68
  } from "../chunk-YLBSSEHX.js";
64
69
  import {
70
+ ActionError,
71
+ ActionInputError,
65
72
  BATCH_PATH,
66
73
  BatchPathConflictError,
67
74
  CSP_REPORT_PATH,
@@ -69,6 +76,7 @@ import {
69
76
  CSRF_READINESS_RESET_PATH,
70
77
  CSRF_WARN_CODE,
71
78
  CSRF_WARN_DOCS_URL,
79
+ CsrfReadinessStore,
72
80
  DEFAULT_CSP,
73
81
  DEFAULT_PERMISSIONS_POLICY,
74
82
  DuplicateDecorationError,
@@ -86,7 +94,6 @@ import {
86
94
  _resetWarnOnceForTests,
87
95
  applySecurityHeaders,
88
96
  buildSecurityHeaders,
89
- compilePattern,
90
97
  createCorsHandler,
91
98
  createLogger,
92
99
  createNoOpLogger,
@@ -98,16 +105,18 @@ import {
98
105
  executeAction,
99
106
  executeRoute,
100
107
  extractTraceId,
108
+ extractUniversalIssues,
101
109
  findSuggestion,
102
110
  handleBatchRequest,
103
111
  handleCspReport,
104
112
  handleCsrfReadiness,
113
+ isActionError,
114
+ isInputError,
105
115
  jsonTransformer,
106
116
  levenshtein,
107
117
  loadEnv,
108
118
  logRequest,
109
119
  matchDisallowed,
110
- matchRoute,
111
120
  matchesOrigin,
112
121
  normalizeLegacy,
113
122
  normalizeNew,
@@ -117,15 +126,23 @@ import {
117
126
  runMiddlewareAndContext,
118
127
  safeAudit,
119
128
  scanMiddlewares,
120
- scanServerActions,
121
- scanServerRoutes,
122
- scanWebSocketRoutes,
123
129
  sendError,
124
130
  sendJson,
125
131
  superjsonTransformer,
126
132
  validateCsrf,
127
133
  warnOnce
128
- } from "../chunk-OEB3OIYP.js";
134
+ } from "../chunk-OJHO2X7C.js";
135
+ import {
136
+ compilePattern,
137
+ matchRoute,
138
+ scanServerRoutes,
139
+ scanWebSocketRoutes
140
+ } from "../chunk-2BQYEBCK.js";
141
+ import {
142
+ ActionScanError,
143
+ scanServerActions,
144
+ scanServerActionsEnriched
145
+ } from "../chunk-7DHGV77J.js";
129
146
  import {
130
147
  AuthRequiredError,
131
148
  generateNonce,
@@ -138,6 +155,7 @@ import {
138
155
  createQueueClient
139
156
  } from "../chunk-GY5Q27BJ.js";
140
157
  import "../chunk-X2VVCJ4V.js";
158
+ import "../chunk-WSJKACWB.js";
141
159
  import {
142
160
  __require
143
161
  } from "../chunk-DGUM43GV.js";
@@ -399,62 +417,6 @@ function serveStaticFile(req, res, clientDir) {
399
417
  return true;
400
418
  }
401
419
 
402
- // src/server/scan/manifest.ts
403
- import { existsSync as existsSync3, readFileSync as readFileSync3, writeFileSync, mkdirSync } from "fs";
404
- import { join, resolve as resolve3, relative } from "path";
405
- function generateManifest(serverDir) {
406
- const routes = scanServerRoutes(serverDir);
407
- const actions = scanServerActions(serverDir);
408
- const websockets = scanWebSocketRoutes(serverDir);
409
- return {
410
- version: 1,
411
- generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
412
- routes: routes.map((r) => ({
413
- filePath: relative(serverDir, r.filePath),
414
- routePath: r.routePath,
415
- paramNames: r.paramNames
416
- })),
417
- actions: actions.map((a) => ({
418
- filePath: relative(serverDir, a.filePath),
419
- actionPath: a.actionPath
420
- })),
421
- websockets: websockets.map((w) => ({
422
- filePath: relative(serverDir, w.filePath),
423
- wsPath: w.wsPath
424
- }))
425
- };
426
- }
427
- function writeManifest(manifest, outputDir) {
428
- mkdirSync(outputDir, { recursive: true });
429
- const manifestPath = join(outputDir, "manifest.json");
430
- writeFileSync(manifestPath, JSON.stringify(manifest, null, 2));
431
- }
432
- function loadManifest(distDir, serverDir) {
433
- const manifestPath = join(distDir, "manifest.json");
434
- if (!existsSync3(manifestPath)) {
435
- throw new Error(`No manifest found at ${manifestPath}. Run "theo build" first.`);
436
- }
437
- const raw = JSON.parse(readFileSync3(manifestPath, "utf-8"));
438
- const routes = raw.routes.map((r) => {
439
- const { pattern, paramNames } = compilePattern(r.routePath);
440
- return {
441
- filePath: resolve3(serverDir, r.filePath),
442
- routePath: r.routePath,
443
- paramNames,
444
- pattern
445
- };
446
- });
447
- const actions = raw.actions.map((a) => ({
448
- filePath: resolve3(serverDir, a.filePath),
449
- actionPath: a.actionPath
450
- }));
451
- const websockets = raw.websockets.map((w) => ({
452
- filePath: resolve3(serverDir, w.filePath),
453
- wsPath: w.wsPath
454
- }));
455
- return { routes, actions, websockets };
456
- }
457
-
458
420
  // src/server/agent/stream-agent-run.ts
459
421
  function safeJsonStringify(value) {
460
422
  try {
@@ -711,9 +673,7 @@ function autoResolveProviderIfNeeded(options) {
711
673
  ...options,
712
674
  apiKey: resolved.apiKey,
713
675
  providers: {
714
- routes: [
715
- { capability: "chat", provider: resolved.name, baseUrl: resolved.baseUrl }
716
- ]
676
+ routes: [{ capability: "chat", provider: resolved.name, baseUrl: resolved.baseUrl }]
717
677
  }
718
678
  };
719
679
  }
@@ -871,54 +831,6 @@ var ChannelManager = class {
871
831
  }
872
832
  };
873
833
 
874
- // src/server/security/csrf-readiness-store.ts
875
- var CsrfReadinessStore = class _CsrfReadinessStore {
876
- static MAX_ENTRIES = 1e3;
877
- entries = /* @__PURE__ */ new Map();
878
- keyFor(event) {
879
- return `${event.method}\0${event.path}\0${event.reason}`;
880
- }
881
- record(event) {
882
- const key = this.keyFor(event);
883
- const now = (/* @__PURE__ */ new Date()).toISOString();
884
- const existing = this.entries.get(key);
885
- if (existing) {
886
- existing.count++;
887
- existing.lastSeen = now;
888
- return;
889
- }
890
- if (this.entries.size >= _CsrfReadinessStore.MAX_ENTRIES) {
891
- const firstKey = this.entries.keys().next().value;
892
- if (firstKey !== void 0) this.entries.delete(firstKey);
893
- }
894
- this.entries.set(key, { count: 1, firstSeen: now, lastSeen: now });
895
- }
896
- summary() {
897
- let total = 0;
898
- const routes = [];
899
- for (const [key, entry] of this.entries) {
900
- const [method, path, reason] = key.split("\0");
901
- routes.push({
902
- method,
903
- path,
904
- reason,
905
- count: entry.count,
906
- firstSeen: entry.firstSeen,
907
- lastSeen: entry.lastSeen
908
- });
909
- total += entry.count;
910
- }
911
- return {
912
- generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
913
- totalEvents: total,
914
- routes
915
- };
916
- }
917
- reset() {
918
- this.entries.clear();
919
- }
920
- };
921
-
922
834
  // src/server/storage/storage-manager.ts
923
835
  var StorageManager = class {
924
836
  #config;
@@ -1689,8 +1601,8 @@ function createCacheEngine(opts) {
1689
1601
  function claimAndRun(key, fn, options, skipWrite) {
1690
1602
  let resolveOuter;
1691
1603
  let rejectOuter;
1692
- const outerPromise = new Promise((resolve4, reject) => {
1693
- resolveOuter = resolve4;
1604
+ const outerPromise = new Promise((resolve3, reject) => {
1605
+ resolveOuter = resolve3;
1694
1606
  rejectOuter = reject;
1695
1607
  });
1696
1608
  void outerPromise.catch(() => {
@@ -2033,6 +1945,9 @@ function definePlugin(plugin) {
2033
1945
  return plugin;
2034
1946
  }
2035
1947
  export {
1948
+ ActionError,
1949
+ ActionInputError,
1950
+ ActionScanError,
2036
1951
  AuthRequiredError,
2037
1952
  BATCH_PATH,
2038
1953
  BatchPathConflictError,
@@ -2138,6 +2053,7 @@ export {
2138
2053
  executeAction,
2139
2054
  executeRoute,
2140
2055
  extractTraceId,
2056
+ extractUniversalIssues,
2141
2057
  findSuggestion,
2142
2058
  generateBackupCodes,
2143
2059
  generateManifest,
@@ -2154,6 +2070,8 @@ export {
2154
2070
  handleCspReport,
2155
2071
  handleCsrfReadiness,
2156
2072
  initCacheEngine,
2073
+ isActionError,
2074
+ isInputError,
2157
2075
  jsonTransformer,
2158
2076
  levenshtein,
2159
2077
  loadCustomErrorPages,
@@ -2184,6 +2102,7 @@ export {
2184
2102
  scanJobs,
2185
2103
  scanMiddlewares,
2186
2104
  scanServerActions,
2105
+ scanServerActionsEnriched,
2187
2106
  scanServerRoutes,
2188
2107
  scanWebSocketRoutes,
2189
2108
  sendError,