theokit 0.48.6 → 0.48.8

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 (46) hide show
  1. package/dist/{actions-virtual-module-GB5FWUPS.js → actions-virtual-module-IICWQK43.js} +2 -3
  2. package/dist/{actions-virtual-module-GB5FWUPS.js.map → actions-virtual-module-IICWQK43.js.map} +1 -1
  3. package/dist/{agent-4LB2KLP5.js → agent-WZLCEXD4.js} +2 -2
  4. package/dist/{app-typed-client-5QDNHANF.js → app-typed-client-4GDSR5T3.js} +2 -3
  5. package/dist/{app-typed-client-5QDNHANF.js.map → app-typed-client-4GDSR5T3.js.map} +1 -1
  6. package/dist/{build-L6JM3QJS.js → build-5TKAROT4.js} +3 -3
  7. package/dist/chunk-3PWQQWT6.js +21 -0
  8. package/dist/chunk-3PWQQWT6.js.map +1 -0
  9. package/dist/{chunk-H6YBKIUN.js → chunk-ABUVJU3P.js} +574 -161
  10. package/dist/chunk-ABUVJU3P.js.map +1 -0
  11. package/dist/{chunk-S54RXGBP.js → chunk-HENNMZUH.js} +2 -2
  12. package/dist/{chunk-3AB5XP2R.js → chunk-RPIL7VRZ.js} +89 -4
  13. package/dist/chunk-RPIL7VRZ.js.map +1 -0
  14. package/dist/{chunk-7QAYC757.js → chunk-XSCZWSE3.js} +21 -5
  15. package/dist/chunk-XSCZWSE3.js.map +1 -0
  16. package/dist/{chunk-SNOKEQVL.js → chunk-ZGNA66JK.js} +39 -119
  17. package/dist/chunk-ZGNA66JK.js.map +1 -0
  18. package/dist/cli/index.js +5 -5
  19. package/dist/{dev-7BIZPKP6.js → dev-XGAJQ7DH.js} +5 -5
  20. package/dist/index.js +1 -1
  21. package/dist/{internal-api-ICU7ITJD.js → internal-api-AKYIRMT2.js} +7 -9
  22. package/dist/{mcp-D2JOFMM2.js → mcp-D7K6NJMW.js} +2 -2
  23. package/dist/{registry-UJ6KNQPJ.js → registry-GKR3EWRW.js} +2 -2
  24. package/dist/{start-FT33OMIF.js → start-YR4TQQP2.js} +17 -13
  25. package/dist/start-YR4TQQP2.js.map +1 -0
  26. package/dist/{static-R25HSXEF.js → static-M2W4HUWS.js} +9 -2
  27. package/dist/static-M2W4HUWS.js.map +1 -0
  28. package/dist/vite-plugin/index.js +1 -1
  29. package/dist/{vite-plugin-HLAVDD5K.js → vite-plugin-PUUCR6LR.js} +5 -5
  30. package/package.json +3 -3
  31. package/dist/chunk-3AB5XP2R.js.map +0 -1
  32. package/dist/chunk-7CQ6DEWZ.js +0 -421
  33. package/dist/chunk-7CQ6DEWZ.js.map +0 -1
  34. package/dist/chunk-7QAYC757.js.map +0 -1
  35. package/dist/chunk-H6YBKIUN.js.map +0 -1
  36. package/dist/chunk-SNOKEQVL.js.map +0 -1
  37. package/dist/start-FT33OMIF.js.map +0 -1
  38. package/dist/static-R25HSXEF.js.map +0 -1
  39. /package/dist/{agent-4LB2KLP5.js.map → agent-WZLCEXD4.js.map} +0 -0
  40. /package/dist/{build-L6JM3QJS.js.map → build-5TKAROT4.js.map} +0 -0
  41. /package/dist/{chunk-S54RXGBP.js.map → chunk-HENNMZUH.js.map} +0 -0
  42. /package/dist/{dev-7BIZPKP6.js.map → dev-XGAJQ7DH.js.map} +0 -0
  43. /package/dist/{internal-api-ICU7ITJD.js.map → internal-api-AKYIRMT2.js.map} +0 -0
  44. /package/dist/{mcp-D2JOFMM2.js.map → mcp-D7K6NJMW.js.map} +0 -0
  45. /package/dist/{registry-UJ6KNQPJ.js.map → registry-GKR3EWRW.js.map} +0 -0
  46. /package/dist/{vite-plugin-HLAVDD5K.js.map → vite-plugin-PUUCR6LR.js.map} +0 -0
@@ -2,14 +2,14 @@
2
2
  import "tsx/esm";
3
3
  import {
4
4
  handleAgentApproval,
5
- hoistHeadTags,
6
5
  isAgentCardPath,
7
6
  isApprovalPath,
8
7
  isListApprovalsPath,
9
8
  resolveTransformer,
10
9
  serveAgentAuxRoute,
10
+ setupSsrDevMiddleware,
11
11
  writeWebResponseToServerResponse
12
- } from "./chunk-3AB5XP2R.js";
12
+ } from "./chunk-RPIL7VRZ.js";
13
13
  import {
14
14
  isMcpPath
15
15
  } from "./chunk-2CVV6CNN.js";
@@ -31,23 +31,20 @@ import {
31
31
  CSP_REPORT_PATH,
32
32
  CsrfReadinessStore,
33
33
  TRACE_HEADER,
34
- createCorsHandler,
35
- extractTraceId,
36
- handleBatchRequest,
37
- handleCspReport,
38
- handleCsrfReadiness
39
- } from "./chunk-7CQ6DEWZ.js";
40
- import {
41
34
  applySecurityHeaders,
35
+ createCorsHandler,
42
36
  createPluginRunnerFromConfig,
43
37
  createRateLimiter,
44
38
  createViteLoader,
45
39
  executeAction,
46
40
  executeRoute,
41
+ extractTraceId,
47
42
  findSuggestion,
48
- generateNonce,
43
+ handleBatchRequest,
44
+ handleCspReport,
45
+ handleCsrfReadiness,
49
46
  mountAgent
50
- } from "./chunk-H6YBKIUN.js";
47
+ } from "./chunk-ABUVJU3P.js";
51
48
  import {
52
49
  getApprovalRegistry,
53
50
  resolveProvider
@@ -71,7 +68,7 @@ import {
71
68
 
72
69
  // src/vite-plugin/index.ts
73
70
  import { existsSync as existsSync7 } from "fs";
74
- import { resolve as resolve7, dirname as dirname4 } from "path";
71
+ import { resolve as resolve6, dirname as dirname4 } from "path";
75
72
  import { fileURLToPath } from "url";
76
73
 
77
74
  // src/vite-plugin/config-hook.ts
@@ -290,7 +287,7 @@ async function resolvePluginConfig(projectRoot) {
290
287
  }
291
288
 
292
289
  // src/vite-plugin/configure-server-hook.ts
293
- import { resolve as resolve4, basename } from "path";
290
+ import { resolve as resolve3, basename } from "path";
294
291
 
295
292
  // src/devtools/server-side/route-manifest.ts
296
293
  function buildPath(parents, segment) {
@@ -618,10 +615,10 @@ async function handleBatchIfMatch(req, res, ctx) {
618
615
  async function handleBatchInline(req, res, batching, requestId) {
619
616
  try {
620
617
  const chunks = [];
621
- await new Promise((resolve8, reject) => {
618
+ await new Promise((resolve7, reject) => {
622
619
  req.on("data", (c) => chunks.push(c));
623
620
  req.on("end", () => {
624
- resolve8();
621
+ resolve7();
625
622
  });
626
623
  req.on("error", reject);
627
624
  });
@@ -808,83 +805,6 @@ function createApiMiddleware(vite, serverDir, rateLimitConfigOrOptions) {
808
805
  };
809
806
  }
810
807
 
811
- // src/vite-plugin/ssr-dev-middleware.ts
812
- import { readFileSync as readFileSync2 } from "fs";
813
- import { resolve as resolve3 } from "path";
814
- function applyNonceToInlineScripts(html, nonce) {
815
- return html.replace(
816
- /<script(?![^>]*\ssrc=)(?![^>]*\snonce=)([^>]*)>/gi,
817
- `<script nonce="${nonce}"$1>`
818
- );
819
- }
820
- function isSsrRenderResult(value) {
821
- if (typeof value !== "object" || value === null) return false;
822
- if (!("html" in value)) return false;
823
- return typeof value.html === "string";
824
- }
825
- function setupSsrDevMiddleware(server, opts) {
826
- server.middlewares.use((req, res, next) => {
827
- void (async () => {
828
- const url = req.url ?? "/";
829
- if (url.startsWith("/api/") || url.startsWith("/@") || url.startsWith("/node_modules/") || url.includes(".")) {
830
- next();
831
- return;
832
- }
833
- try {
834
- const indexPath = resolve3(opts.projectRoot, "index.html");
835
- let template = readFileSync2(indexPath, "utf-8");
836
- const nonce = generateNonce();
837
- template = await server.transformIndexHtml(url, template);
838
- template = applyNonceToInlineScripts(template, nonce);
839
- applySecurityHeaders(
840
- res,
841
- opts.securityHeaders ?? {},
842
- { production: process.env.NODE_ENV === "production" },
843
- { nonce }
844
- );
845
- const mod = await server.ssrLoadModule(opts.virtualEntryServerId);
846
- const result = await mod.render(url, { nonce });
847
- if (result && typeof result === "object" && "redirect" in result) {
848
- res.writeHead(302, {
849
- Location: result.redirect.headers.get("location") ?? "/"
850
- });
851
- res.end();
852
- return;
853
- }
854
- let ssrHtml;
855
- let hydrationScript = "";
856
- if (typeof result === "string") {
857
- ssrHtml = result;
858
- } else if (isSsrRenderResult(result)) {
859
- ssrHtml = result.html;
860
- const dataJson = JSON.stringify(result.hydrationData).replace(/</g, "\\u003c");
861
- hydrationScript = `<script nonce="${nonce}">window.__staticRouterHydrationData=${dataJson}</script>`;
862
- } else {
863
- ssrHtml = "";
864
- }
865
- const hoisted = hoistHeadTags(template, ssrHtml);
866
- template = hoisted.template;
867
- ssrHtml = hoisted.html;
868
- const rootDivMatch = /<div id=["']root["'][^>]*>/.exec(template);
869
- if (!rootDivMatch) {
870
- res.writeHead(200, { "Content-Type": "text/html" });
871
- res.end(template);
872
- return;
873
- }
874
- const splitIdx = template.indexOf(rootDivMatch[0]) + rootDivMatch[0].length;
875
- const html = template.slice(0, splitIdx) + ssrHtml + hydrationScript + template.slice(splitIdx);
876
- res.writeHead(200, { "Content-Type": "text/html" });
877
- res.end(html);
878
- } catch (err) {
879
- server.ssrFixStacktrace(err);
880
- console.error("[SSR Dev Error]", err);
881
- next();
882
- return;
883
- }
884
- })();
885
- });
886
- }
887
-
888
808
  // src/vite-plugin/ws-upgrade.ts
889
809
  function setupWsUpgrade(server, serverDir) {
890
810
  const wsRoutes = scanWebSocketRoutes(serverDir);
@@ -969,7 +889,7 @@ async function runConfigureServer(server, ctx) {
969
889
  csrfReadinessStore
970
890
  })
971
891
  );
972
- const configPath = resolve4(ctx.projectRoot, "theo.config.ts");
892
+ const configPath = resolve3(ctx.projectRoot, "theo.config.ts");
973
893
  server.watcher.on("change", (file) => {
974
894
  if (file === configPath) {
975
895
  console.warn(
@@ -999,7 +919,7 @@ async function runConfigureServer(server, ctx) {
999
919
  const openApiCfg = ctx.resolvedOpenApi;
1000
920
  const { reEmitOpenApi } = await import("./dev-emit-GWD6IXV7.js");
1001
921
  const openApiServerDir = ctx.serverDir;
1002
- const openApiDistDir = resolve4(ctx.projectRoot, ctx.resolvedDistDir);
922
+ const openApiDistDir = resolve3(ctx.projectRoot, ctx.resolvedDistDir);
1003
923
  const isRouteFileForOpenApi = (file) => file.startsWith(openApiServerDir) && /\.(ts|tsx|js|mjs)$/.test(file);
1004
924
  void reEmitOpenApi(openApiServerDir, openApiDistDir, openApiCfg);
1005
925
  server.watcher.on("change", (file) => {
@@ -1047,16 +967,16 @@ async function integrateStudio(importStudio = () => import(
1047
967
  }
1048
968
 
1049
969
  // src/vite-plugin/integrate-ui.ts
1050
- import { existsSync as existsSync4, readFileSync as readFileSync4 } from "fs";
970
+ import { existsSync as existsSync4, readFileSync as readFileSync3 } from "fs";
1051
971
  import { dirname as dirname3, join as join3 } from "path";
1052
972
  import { pathToFileURL } from "url";
1053
973
 
1054
974
  // src/vite-plugin/auto-detect.ts
1055
- import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
975
+ import { existsSync as existsSync3, readFileSync as readFileSync2 } from "fs";
1056
976
  import { dirname as dirname2, join as join2 } from "path";
1057
977
  function isDeclared(name, projectRoot) {
1058
978
  try {
1059
- const raw = readFileSync3(join2(projectRoot, "package.json"), "utf-8");
979
+ const raw = readFileSync2(join2(projectRoot, "package.json"), "utf-8");
1060
980
  const pkg = JSON.parse(raw);
1061
981
  return Boolean(
1062
982
  pkg.dependencies?.[name] ?? pkg.devDependencies?.[name] ?? pkg.peerDependencies?.[name]
@@ -1071,7 +991,7 @@ function resolvePackageJson(name, cwd) {
1071
991
  const pkgJsonPath = join2(dir, "node_modules", ...name.split("/"), "package.json");
1072
992
  if (existsSync3(pkgJsonPath)) {
1073
993
  try {
1074
- const raw = readFileSync3(pkgJsonPath, "utf-8");
994
+ const raw = readFileSync2(pkgJsonPath, "utf-8");
1075
995
  const pkg = JSON.parse(raw);
1076
996
  if (pkg.name === name) {
1077
997
  return { path: pkgJsonPath, version: pkg.version };
@@ -1106,7 +1026,7 @@ function findOwningPackageJson(entry, expectedName) {
1106
1026
  const candidate = join2(dir, "package.json");
1107
1027
  if (existsSync3(candidate)) {
1108
1028
  try {
1109
- const raw = readFileSync3(candidate, "utf-8");
1029
+ const raw = readFileSync2(candidate, "utf-8");
1110
1030
  const pkg = JSON.parse(raw);
1111
1031
  if (pkg.name === expectedName) {
1112
1032
  return { path: candidate, version: pkg.version };
@@ -1138,7 +1058,7 @@ function detectPackage(name, cwd) {
1138
1058
  const nmPkgJson = join2(nmPath, "package.json");
1139
1059
  if (existsSync3(nmPkgJson)) {
1140
1060
  try {
1141
- const raw = readFileSync3(nmPkgJson, "utf-8");
1061
+ const raw = readFileSync2(nmPkgJson, "utf-8");
1142
1062
  const pkg = JSON.parse(raw);
1143
1063
  if (pkg.name === name) {
1144
1064
  return { installed: true, version: pkg.version, resolvedPath: nmPkgJson };
@@ -1170,7 +1090,7 @@ function resolveConsumerImport(name, cwd) {
1170
1090
  const pkgJsonPath = join3(pkgDir, "package.json");
1171
1091
  if (existsSync4(pkgJsonPath)) {
1172
1092
  try {
1173
- const raw = readFileSync4(pkgJsonPath, "utf-8");
1093
+ const raw = readFileSync3(pkgJsonPath, "utf-8");
1174
1094
  const pkg = JSON.parse(raw);
1175
1095
  let entry;
1176
1096
  const dotExport = pkg.exports?.["."];
@@ -1306,17 +1226,17 @@ async function integrateUseTheoUI(cwd, opts) {
1306
1226
 
1307
1227
  // src/vite-plugin/resolve-theo-root.ts
1308
1228
  import { existsSync as existsSync5 } from "fs";
1309
- import { resolve as resolve5 } from "path";
1229
+ import { resolve as resolve4 } from "path";
1310
1230
  function resolveTheoRootDir(currentDir) {
1311
- if (existsSync5(resolve5(currentDir, "client"))) {
1231
+ if (existsSync5(resolve4(currentDir, "client"))) {
1312
1232
  return currentDir;
1313
1233
  }
1314
- return resolve5(currentDir, "..");
1234
+ return resolve4(currentDir, "..");
1315
1235
  }
1316
1236
 
1317
1237
  // src/vite-plugin/transform-html-hook.ts
1318
1238
  import { existsSync as existsSync6 } from "fs";
1319
- import { resolve as resolve6 } from "path";
1239
+ import { resolve as resolve5 } from "path";
1320
1240
 
1321
1241
  // src/vite-plugin/inject-devtools.ts
1322
1242
  var DEVTOOLS_VIRTUAL_ID = "/@theo/devtools/entry.js";
@@ -1416,7 +1336,7 @@ function runTransformIndexHtml(html, ctx) {
1416
1336
  next = devtools.html;
1417
1337
  const styles = injectStylesheets(next, {
1418
1338
  isDev: ctx.isDevMode.value,
1419
- hasPackage: (name) => existsSync6(resolve6(ctx.projectRoot, "node_modules", ...name.split("/")))
1339
+ hasPackage: (name) => existsSync6(resolve5(ctx.projectRoot, "node_modules", ...name.split("/")))
1420
1340
  });
1421
1341
  next = styles.html;
1422
1342
  return next;
@@ -1976,7 +1896,7 @@ function findConsumerConfig(projectRoot, basename2) {
1976
1896
  let dir = projectRoot;
1977
1897
  for (let level = 0; level < 3; level++) {
1978
1898
  for (const ext of extensions) {
1979
- const candidate = resolve7(dir, `${basename2}${ext}`);
1899
+ const candidate = resolve6(dir, `${basename2}${ext}`);
1980
1900
  if (existsSync7(candidate)) return candidate;
1981
1901
  }
1982
1902
  const parent = dirname4(dir);
@@ -1988,7 +1908,7 @@ function findConsumerConfig(projectRoot, basename2) {
1988
1908
  async function theoPluginAsync(rootOrOptions) {
1989
1909
  const options = typeof rootOrOptions === "string" ? { root: rootOrOptions } : rootOrOptions ?? {};
1990
1910
  const projectRoot = options.root ?? process.cwd();
1991
- const serverDirAbs = resolve7(projectRoot, options.serverDir ?? "server");
1911
+ const serverDirAbs = resolve6(projectRoot, options.serverDir ?? "server");
1992
1912
  const agentsDirName = options.agentsDir ?? "agents";
1993
1913
  const consumerTailwindConfig = findConsumerConfig(projectRoot, "tailwind.config");
1994
1914
  const consumerPostcssConfig = findConsumerConfig(projectRoot, "postcss.config");
@@ -2007,23 +1927,23 @@ async function theoPluginAsync(rootOrOptions) {
2007
1927
  })
2008
1928
  );
2009
1929
  }
2010
- const { appTypedClientPlugin } = await import("./app-typed-client-5QDNHANF.js");
1930
+ const { appTypedClientPlugin } = await import("./app-typed-client-4GDSR5T3.js");
2011
1931
  const appClientPlugin = appTypedClientPlugin({
2012
1932
  cwd: projectRoot,
2013
1933
  serverDir: serverDirAbs,
2014
- distDir: resolve7(projectRoot, ".theokit")
1934
+ distDir: resolve6(projectRoot, ".theokit")
2015
1935
  });
2016
- const { actionsVirtualModule } = await import("./actions-virtual-module-GB5FWUPS.js");
1936
+ const { actionsVirtualModule } = await import("./actions-virtual-module-IICWQK43.js");
2017
1937
  const actionsPlugin = actionsVirtualModule({
2018
1938
  serverDir: serverDirAbs,
2019
- distDir: resolve7(projectRoot, ".theokit")
1939
+ distDir: resolve6(projectRoot, ".theokit")
2020
1940
  });
2021
1941
  const { agentsTypedClientPlugin } = await import("./agents-typed-client-D4OA2TXB.js");
2022
- const { generateManifest } = await import("./internal-api-ICU7ITJD.js");
1942
+ const { generateManifest } = await import("./internal-api-AKYIRMT2.js");
2023
1943
  const agentsClientPlugin = agentsTypedClientPlugin({
2024
1944
  projectRoot,
2025
1945
  agentsDir: agentsDirName,
2026
- distDir: resolve7(projectRoot, ".theokit"),
1946
+ distDir: resolve6(projectRoot, ".theokit"),
2027
1947
  // Agents live at <projectRoot>/<agentsDir>; generateManifest scans them via the server dir's
2028
1948
  // parent (projectRoot for the canonical layout) + the agents dir name (#95 follow-up).
2029
1949
  scanManifest: () => generateManifest(serverDirAbs, projectRoot, agentsDirName)
@@ -2051,10 +1971,10 @@ async function theoPluginAsync(rootOrOptions) {
2051
1971
  }
2052
1972
  function buildOptimizeDepsInclude(projectRoot, viteOptimizeDeps) {
2053
1973
  const include = [];
2054
- if (existsSync7(resolve7(projectRoot, "node_modules", "@theokit", "ui"))) {
1974
+ if (existsSync7(resolve6(projectRoot, "node_modules", "@theokit", "ui"))) {
2055
1975
  include.push("@theokit/ui");
2056
1976
  }
2057
- if (existsSync7(resolve7(projectRoot, "node_modules", "lucide-react"))) {
1977
+ if (existsSync7(resolve6(projectRoot, "node_modules", "lucide-react"))) {
2058
1978
  include.push("lucide-react");
2059
1979
  }
2060
1980
  include.push("devalue");
@@ -2080,8 +2000,8 @@ var VIRTUAL_MODULE_IDS = {
2080
2000
  function theoPlugin(rootOrOptions) {
2081
2001
  const options = typeof rootOrOptions === "string" ? { root: rootOrOptions } : rootOrOptions ?? {};
2082
2002
  const projectRoot = options.root ?? process.cwd();
2083
- const appDir = resolve7(projectRoot, options.appDir ?? "app");
2084
- const serverDir = resolve7(projectRoot, options.serverDir ?? "server");
2003
+ const appDir = resolve6(projectRoot, options.appDir ?? "app");
2004
+ const serverDir = resolve6(projectRoot, options.serverDir ?? "server");
2085
2005
  const agentsDir = options.agentsDir ?? "agents";
2086
2006
  const ssrEnabled = options.ssr ?? false;
2087
2007
  const currentDir = dirname4(fileURLToPath(import.meta.url));
@@ -2201,4 +2121,4 @@ export {
2201
2121
  theoPluginAsync,
2202
2122
  theoPlugin
2203
2123
  };
2204
- //# sourceMappingURL=chunk-SNOKEQVL.js.map
2124
+ //# sourceMappingURL=chunk-ZGNA66JK.js.map