theokit 0.68.0 → 0.70.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/README.md +21 -0
  2. package/dist/{actions-virtual-module-SE44BKR4.js → actions-virtual-module-ICWX5PZ2.js} +8 -8
  3. package/dist/{actions-virtual-module-3OPYLD76.js → actions-virtual-module-LY6VGJZ2.js} +5 -5
  4. package/dist/adapters/agent-mount.d.ts +191 -3
  5. package/dist/adapters/agent-mount.js +19 -4
  6. package/dist/adapters/security-headers.d.ts +17 -1
  7. package/dist/adapters/security-headers.js +7 -0
  8. package/dist/adapters/security-headers.js.map +1 -1
  9. package/dist/{agent-UBDDP2L5.js → agent-7DQ3TKJY.js} +4 -4
  10. package/dist/agent-scan-BLXaFL6R.d.ts +12 -0
  11. package/dist/{app-typed-client-BE3PV3JY.js → app-typed-client-2S76VTMB.js} +5 -5
  12. package/dist/{app-typed-client-RAFEBA7S.js → app-typed-client-6YQREFRS.js} +8 -8
  13. package/dist/{aws-lambda-R76PWR27.js → aws-lambda-OCJM5YGB.js} +35 -23
  14. package/dist/aws-lambda-OCJM5YGB.js.map +1 -0
  15. package/dist/{build-U4HVYY6F.js → build-NIHGHPYS.js} +12 -7
  16. package/dist/build-NIHGHPYS.js.map +1 -0
  17. package/dist/{bun-NPBIAWSU.js → bun-KRUAWYRW.js} +51 -39
  18. package/dist/bun-KRUAWYRW.js.map +1 -0
  19. package/dist/{chunk-GQNBZDYK.js → chunk-2FHNJ7LI.js} +1 -1
  20. package/dist/{chunk-GQNBZDYK.js.map → chunk-2FHNJ7LI.js.map} +1 -1
  21. package/dist/chunk-3NAKOWTX.js +573 -0
  22. package/dist/chunk-3NAKOWTX.js.map +1 -0
  23. package/dist/chunk-4D4YVXHR.js +816 -0
  24. package/dist/chunk-4D4YVXHR.js.map +1 -0
  25. package/dist/{chunk-G2NWAVGG.js → chunk-5XXXJ6DT.js} +65 -6
  26. package/dist/chunk-5XXXJ6DT.js.map +1 -0
  27. package/dist/{chunk-CO7Q75IS.js → chunk-6SK4MX2N.js} +10 -10
  28. package/dist/{chunk-UETVDZBE.js → chunk-BINRCILF.js} +4 -1
  29. package/dist/{chunk-UETVDZBE.js.map → chunk-BINRCILF.js.map} +1 -1
  30. package/dist/{chunk-AROOYXI5.js → chunk-BTDTHXUI.js} +2 -2
  31. package/dist/{chunk-GP6OJBXP.js → chunk-CPXIYCAY.js} +2 -2
  32. package/dist/chunk-FFGP2LGQ.js +465 -0
  33. package/dist/chunk-FFGP2LGQ.js.map +1 -0
  34. package/dist/{chunk-KDP2HURW.js → chunk-FHQP23Z5.js} +10 -2
  35. package/dist/{chunk-KDP2HURW.js.map → chunk-FHQP23Z5.js.map} +1 -1
  36. package/dist/{chunk-BCFA6LHL.js → chunk-GVJFVBCJ.js} +2 -2
  37. package/dist/{chunk-LADTWXOB.js → chunk-H5KSRGRS.js} +43 -554
  38. package/dist/chunk-H5KSRGRS.js.map +1 -0
  39. package/dist/{chunk-ENRT6DAU.js → chunk-IDWN2OSG.js} +15 -2
  40. package/dist/chunk-IDWN2OSG.js.map +1 -0
  41. package/dist/{chunk-GDF2XQOO.js → chunk-JMN4COMK.js} +5 -3
  42. package/dist/chunk-JMN4COMK.js.map +1 -0
  43. package/dist/{chunk-Q7T3UQ4L.js → chunk-KOG5K26V.js} +16 -738
  44. package/dist/chunk-KOG5K26V.js.map +1 -0
  45. package/dist/{chunk-FYYKMPST.js → chunk-MLF25NC4.js} +4 -4
  46. package/dist/{chunk-7THO4PRL.js → chunk-PGDBSK2L.js} +33 -11
  47. package/dist/chunk-PGDBSK2L.js.map +1 -0
  48. package/dist/{chunk-5NNFO7R7.js → chunk-R7G2B2WH.js} +10 -2
  49. package/dist/chunk-R7G2B2WH.js.map +1 -0
  50. package/dist/{chunk-GAJOZJWD.js → chunk-SX7ZAHNE.js} +15 -2
  51. package/dist/chunk-SX7ZAHNE.js.map +1 -0
  52. package/dist/chunk-V5SSTT3C.js +52 -0
  53. package/dist/chunk-V5SSTT3C.js.map +1 -0
  54. package/dist/chunk-XG6SQUEP.js +27 -0
  55. package/dist/chunk-XG6SQUEP.js.map +1 -0
  56. package/dist/{chunk-QGNSZ2ZK.js → chunk-YWWMYEAC.js} +3 -3
  57. package/dist/cli/index.js +7 -7
  58. package/dist/client/index.d.ts +20 -0
  59. package/dist/client/index.js.map +1 -1
  60. package/dist/{cloudflare-5HU56XIH.js → cloudflare-GK4VD3EU.js} +36 -13
  61. package/dist/cloudflare-GK4VD3EU.js.map +1 -0
  62. package/dist/{define-middleware-D2n71Svm.d.ts → define-middleware-BOHpPOBs.d.ts} +1 -1
  63. package/dist/{deno-deploy-BXOQ45LD.js → deno-deploy-WMNXRVGL.js} +37 -36
  64. package/dist/deno-deploy-WMNXRVGL.js.map +1 -0
  65. package/dist/{dev-E3USPAWQ.js → dev-KKO3JIN7.js} +7 -7
  66. package/dist/{dev-emit-ZLB2J5ME.js → dev-emit-23AA3V64.js} +3 -3
  67. package/dist/{dev-emit-7RT624PM.js → dev-emit-UJJXY3ET.js} +3 -3
  68. package/dist/{index-B9iVBHJI.d.ts → index-inRdhi59.d.ts} +39 -4
  69. package/dist/index.js +9 -8
  70. package/dist/index.js.map +1 -1
  71. package/dist/{internal-api-OOTVIOH2.js → internal-api-HUIBRF2X.js} +5 -5
  72. package/dist/{internal-api-VAKXXW6F.js → internal-api-S72T2XKD.js} +10 -9
  73. package/dist/match-DaKsL73w.d.ts +28 -0
  74. package/dist/{mcp-7UOQM4FW.js → mcp-I6MCW6KX.js} +4 -4
  75. package/dist/{match-Dw4CNXJH.d.ts → module-loader-DCip7NoL.d.ts} +1 -28
  76. package/dist/{netlify-LPJAPMQ2.js → netlify-VOL54SC7.js} +23 -20
  77. package/dist/netlify-VOL54SC7.js.map +1 -0
  78. package/dist/{openapi-SKKXWFX4.js → openapi-24PTE7P6.js} +3 -3
  79. package/dist/{preview-GPMF43QX.js → preview-EOL3LMK7.js} +3 -3
  80. package/dist/{registry-UOWTDUFL.js → registry-DDBXDHJ2.js} +7 -7
  81. package/dist/server/cost/index.d.ts +14 -1
  82. package/dist/server/cost/index.js +1 -1
  83. package/dist/server/define/index.d.ts +1 -1
  84. package/dist/server/define/index.js +2 -3
  85. package/dist/server/http/index.d.ts +4 -3
  86. package/dist/server/http/index.js +13 -8
  87. package/dist/server/index.d.ts +6 -5
  88. package/dist/server/index.js +17 -12
  89. package/dist/server/index.js.map +1 -1
  90. package/dist/server/scan/index.d.ts +4 -3
  91. package/dist/server/scan/index.js +2 -2
  92. package/dist/{server-boundary-A3HW27C7.js → server-boundary-ERBSHRHT.js} +5 -5
  93. package/dist/{server-boundary-V6PCM22J.js → server-boundary-I5XWYINJ.js} +8 -8
  94. package/dist/{start-6WEPXA3X.js → start-OD4DG4C6.js} +6 -6
  95. package/dist/{vercel-YUZADKGV.js → vercel-LZTDSDJF.js} +42 -28
  96. package/dist/vercel-LZTDSDJF.js.map +1 -0
  97. package/dist/vite-plugin/index.js +9 -8
  98. package/dist/{vite-plugin-WBF5NXGW.js → vite-plugin-SH3VGQEE.js} +7 -7
  99. package/package.json +4 -4
  100. package/dist/agent-scan-BZa-pagG.d.ts +0 -16
  101. package/dist/aws-lambda-R76PWR27.js.map +0 -1
  102. package/dist/build-U4HVYY6F.js.map +0 -1
  103. package/dist/bun-NPBIAWSU.js.map +0 -1
  104. package/dist/chunk-5NNFO7R7.js.map +0 -1
  105. package/dist/chunk-6B3CMPE4.js +0 -192
  106. package/dist/chunk-6B3CMPE4.js.map +0 -1
  107. package/dist/chunk-7L7LQ2GU.js +0 -16
  108. package/dist/chunk-7L7LQ2GU.js.map +0 -1
  109. package/dist/chunk-7THO4PRL.js.map +0 -1
  110. package/dist/chunk-ENRT6DAU.js.map +0 -1
  111. package/dist/chunk-G2NWAVGG.js.map +0 -1
  112. package/dist/chunk-GAJOZJWD.js.map +0 -1
  113. package/dist/chunk-GDF2XQOO.js.map +0 -1
  114. package/dist/chunk-LADTWXOB.js.map +0 -1
  115. package/dist/chunk-O55RLSGG.js +0 -127
  116. package/dist/chunk-O55RLSGG.js.map +0 -1
  117. package/dist/chunk-Q7T3UQ4L.js.map +0 -1
  118. package/dist/cloudflare-5HU56XIH.js.map +0 -1
  119. package/dist/deno-deploy-BXOQ45LD.js.map +0 -1
  120. package/dist/netlify-LPJAPMQ2.js.map +0 -1
  121. package/dist/vercel-YUZADKGV.js.map +0 -1
  122. /package/dist/{actions-virtual-module-SE44BKR4.js.map → actions-virtual-module-ICWX5PZ2.js.map} +0 -0
  123. /package/dist/{actions-virtual-module-3OPYLD76.js.map → actions-virtual-module-LY6VGJZ2.js.map} +0 -0
  124. /package/dist/{agent-UBDDP2L5.js.map → agent-7DQ3TKJY.js.map} +0 -0
  125. /package/dist/{app-typed-client-BE3PV3JY.js.map → app-typed-client-2S76VTMB.js.map} +0 -0
  126. /package/dist/{app-typed-client-RAFEBA7S.js.map → app-typed-client-6YQREFRS.js.map} +0 -0
  127. /package/dist/{chunk-CO7Q75IS.js.map → chunk-6SK4MX2N.js.map} +0 -0
  128. /package/dist/{chunk-AROOYXI5.js.map → chunk-BTDTHXUI.js.map} +0 -0
  129. /package/dist/{chunk-GP6OJBXP.js.map → chunk-CPXIYCAY.js.map} +0 -0
  130. /package/dist/{chunk-BCFA6LHL.js.map → chunk-GVJFVBCJ.js.map} +0 -0
  131. /package/dist/{chunk-FYYKMPST.js.map → chunk-MLF25NC4.js.map} +0 -0
  132. /package/dist/{chunk-QGNSZ2ZK.js.map → chunk-YWWMYEAC.js.map} +0 -0
  133. /package/dist/{dev-E3USPAWQ.js.map → dev-KKO3JIN7.js.map} +0 -0
  134. /package/dist/{dev-emit-ZLB2J5ME.js.map → dev-emit-23AA3V64.js.map} +0 -0
  135. /package/dist/{dev-emit-7RT624PM.js.map → dev-emit-UJJXY3ET.js.map} +0 -0
  136. /package/dist/{internal-api-OOTVIOH2.js.map → internal-api-HUIBRF2X.js.map} +0 -0
  137. /package/dist/{internal-api-VAKXXW6F.js.map → internal-api-S72T2XKD.js.map} +0 -0
  138. /package/dist/{mcp-7UOQM4FW.js.map → mcp-I6MCW6KX.js.map} +0 -0
  139. /package/dist/{openapi-SKKXWFX4.js.map → openapi-24PTE7P6.js.map} +0 -0
  140. /package/dist/{preview-GPMF43QX.js.map → preview-EOL3LMK7.js.map} +0 -0
  141. /package/dist/{registry-UOWTDUFL.js.map → registry-DDBXDHJ2.js.map} +0 -0
  142. /package/dist/{server-boundary-A3HW27C7.js.map → server-boundary-ERBSHRHT.js.map} +0 -0
  143. /package/dist/{server-boundary-V6PCM22J.js.map → server-boundary-I5XWYINJ.js.map} +0 -0
  144. /package/dist/{start-6WEPXA3X.js.map → start-OD4DG4C6.js.map} +0 -0
  145. /package/dist/{vite-plugin-WBF5NXGW.js.map → vite-plugin-SH3VGQEE.js.map} +0 -0
@@ -7,32 +7,29 @@ import {
7
7
  } from "./chunk-SSYDEKWF.js";
8
8
  import {
9
9
  dispatchControllerRequest
10
- } from "./chunk-GDF2XQOO.js";
10
+ } from "./chunk-JMN4COMK.js";
11
+ import {
12
+ createAgentSubjectResolver,
13
+ isAgentCardPath,
14
+ matchAgentAuxRoute,
15
+ serveMatchedAuxRoute
16
+ } from "./chunk-3NAKOWTX.js";
11
17
  import {
12
- RUN_ID_HEADER,
13
- SSE_BASE_HEADERS,
14
- SSE_DONE_FRAME,
15
18
  admitAgentRequest,
16
19
  agentAccessDenied,
17
20
  cacheSchema,
18
21
  closePauseSpan,
19
22
  createObservabilityPluginFromConfig,
20
- encodeSse,
21
- formatSseFrame,
22
23
  getApprovalRegistry,
23
- getRunEventCache,
24
24
  loggingSchema,
25
- makeThreadStartRun,
26
- mintRunId,
27
25
  mountAgent,
28
26
  observabilitySchema,
29
- parseAgentRequestBody,
30
27
  rateLimitSchema,
31
28
  readAgentPolicy,
32
29
  securitySchema,
33
30
  storageSchema,
34
31
  uploadSchema
35
- } from "./chunk-GAJOZJWD.js";
32
+ } from "./chunk-SX7ZAHNE.js";
36
33
  import {
37
34
  broadcastToDevtools
38
35
  } from "./chunk-OIGJOYX6.js";
@@ -52,21 +49,19 @@ import {
52
49
  import {
53
50
  BATCH_PATH,
54
51
  createCorsHandler,
55
- createServerContext,
56
- createWebRequestSource,
57
52
  executeAction,
58
53
  executeRoute,
59
- handleBatchRequest,
54
+ handleBatchRequest
55
+ } from "./chunk-KOG5K26V.js";
56
+ import {
57
+ createWebRequestSource,
60
58
  incomingMessageToHandlerRequest,
61
59
  sendError,
62
60
  writeWebResponseToServerResponse
63
- } from "./chunk-Q7T3UQ4L.js";
61
+ } from "./chunk-4D4YVXHR.js";
64
62
  import {
65
63
  validateCsrfRequest
66
64
  } from "./chunk-P6OS7652.js";
67
- import {
68
- subjectFromContext
69
- } from "./chunk-ENRT6DAU.js";
70
65
  import {
71
66
  findSuggestion
72
67
  } from "./chunk-NTDN54XO.js";
@@ -89,15 +84,10 @@ import {
89
84
  scanServerActions,
90
85
  scanServerRoutes,
91
86
  scanWebSocketRoutes
92
- } from "./chunk-GP6OJBXP.js";
87
+ } from "./chunk-CPXIYCAY.js";
93
88
  import {
94
89
  scanAgents
95
- } from "./chunk-KDP2HURW.js";
96
- import {
97
- extractAppResources,
98
- handleMcpJsonRpc,
99
- isMcpPath
100
- } from "./chunk-TQEE36VD.js";
90
+ } from "./chunk-FHQP23Z5.js";
101
91
  import {
102
92
  resolveProvider
103
93
  } from "./chunk-ICXXHV4V.js";
@@ -110,7 +100,7 @@ import {
110
100
 
111
101
  // src/vite-plugin/index.ts
112
102
  import { existsSync as existsSync8 } from "node:fs";
113
- import { resolve as resolve10, dirname as dirname4 } from "node:path";
103
+ import { resolve as resolve9, dirname as dirname4 } from "node:path";
114
104
  import { fileURLToPath } from "node:url";
115
105
 
116
106
  // src/vite-plugin/config-hook.ts
@@ -785,7 +775,7 @@ async function resolvePluginConfig(projectRoot) {
785
775
  }
786
776
 
787
777
  // src/vite-plugin/configure-server-hook.ts
788
- import { resolve as resolve8, basename } from "node:path";
778
+ import { resolve as resolve7, basename } from "node:path";
789
779
 
790
780
  // src/devtools/server-side/route-manifest.ts
791
781
  function buildPath(parents, segment) {
@@ -1025,52 +1015,6 @@ function createActionMiddleware(vite, serverDir, options) {
1025
1015
  // src/vite-plugin/agent-middleware.ts
1026
1016
  import { randomUUID as randomUUID2 } from "node:crypto";
1027
1017
 
1028
- // src/server/agent/agent-card-handler.ts
1029
- import { buildAgentCard, compileLoadedAgentModule } from "@theokit/agents";
1030
- var WELL_KNOWN = /^\/\.well-known\/([^/]+)\/agent-card\.json$/;
1031
- function isAgentCardPath(urlPath) {
1032
- const match = WELL_KNOWN.exec(urlPath);
1033
- return match ? decodeURIComponent(match[1]) : null;
1034
- }
1035
- function toManifestEntry(name, route, mod) {
1036
- const compiled = compileLoadedAgentModule(mod, `agent card for "${name}"`);
1037
- return {
1038
- name,
1039
- route,
1040
- stream: compiled.stream,
1041
- mainLoop: { method: "", strategy: "" },
1042
- guards: [],
1043
- interceptors: [],
1044
- tools: compiled.tools.map((t) => ({
1045
- name: t.name,
1046
- description: t.description,
1047
- approval: false,
1048
- trace: false,
1049
- audit: false
1050
- })),
1051
- subAgents: []
1052
- };
1053
- }
1054
- function handleAgentCard(mod, name, route, baseUrl) {
1055
- try {
1056
- const card = buildAgentCard(toManifestEntry(name, route, mod), { baseUrl });
1057
- return new Response(JSON.stringify(card), {
1058
- status: 200,
1059
- headers: { "content-type": "application/json; charset=utf-8" }
1060
- });
1061
- } catch (err) {
1062
- return new Response(
1063
- JSON.stringify({
1064
- error: {
1065
- code: "AGENT_CARD_FAILED",
1066
- message: err instanceof Error ? err.message : "card build failed"
1067
- }
1068
- }),
1069
- { status: 500, headers: { "content-type": "application/json; charset=utf-8" } }
1070
- );
1071
- }
1072
- }
1073
-
1074
1018
  // src/server/agent/approve-agent.ts
1075
1019
  var APPROVE_SEGMENT = "/approve/";
1076
1020
  var APPROVE_PATH = /^\/api\/agents\/([^/]+)\/approve\/([^/]+)$/;
@@ -1160,445 +1104,6 @@ async function handleAgentApproval(request, urlPath, registry, csrfMode = "stric
1160
1104
  });
1161
1105
  }
1162
1106
 
1163
- // src/server/agent/handle-agent-run-reconnect.ts
1164
- var RUN_STREAM_PATH = /^\/api\/agents\/([^/]+)\/runs\/([^/]+)\/stream$/;
1165
- function isAgentRunStreamPath(urlPath) {
1166
- const m = RUN_STREAM_PATH.exec(urlPath);
1167
- return m ? { name: decodeURIComponent(m[1]), runId: decodeURIComponent(m[2]) } : null;
1168
- }
1169
- function parseLastEventId(raw) {
1170
- if (raw === null) return -1;
1171
- const n = Number.parseInt(raw, 10);
1172
- return Number.isInteger(n) && n >= 0 ? n : -1;
1173
- }
1174
- function handleAgentRunReconnect(runId, request, cache) {
1175
- if (!cache.has(runId)) {
1176
- return new Response(
1177
- JSON.stringify({ error: { code: "RUN_NOT_FOUND", message: `Unknown run '${runId}'.` } }),
1178
- {
1179
- status: 404,
1180
- headers: { "content-type": "application/json" }
1181
- }
1182
- );
1183
- }
1184
- const afterSeq = parseLastEventId(request.headers.get("last-event-id"));
1185
- const stream = new ReadableStream({
1186
- start(controller) {
1187
- let closed = false;
1188
- const safeEnqueue = (text) => {
1189
- if (closed) return;
1190
- try {
1191
- controller.enqueue(encodeSse(text));
1192
- } catch {
1193
- }
1194
- };
1195
- const close = () => {
1196
- if (closed) return;
1197
- safeEnqueue(SSE_DONE_FRAME);
1198
- closed = true;
1199
- try {
1200
- controller.close();
1201
- } catch {
1202
- }
1203
- };
1204
- const res = cache.attach(
1205
- runId,
1206
- afterSeq,
1207
- (frame) => {
1208
- safeEnqueue(formatSseFrame(frame.seq, frame.data));
1209
- },
1210
- () => {
1211
- close();
1212
- }
1213
- );
1214
- if (!res.known) {
1215
- close();
1216
- return;
1217
- }
1218
- for (const frame of res.replay) {
1219
- safeEnqueue(formatSseFrame(frame.seq, frame.data));
1220
- }
1221
- if (res.ended) {
1222
- close();
1223
- return;
1224
- }
1225
- request.signal.addEventListener("abort", () => {
1226
- res.unsubscribe();
1227
- close();
1228
- });
1229
- }
1230
- });
1231
- return new Response(stream, { headers: { ...SSE_BASE_HEADERS, [RUN_ID_HEADER]: runId } });
1232
- }
1233
-
1234
- // src/server/agent/thread-dispatcher.ts
1235
- function postThreadFollowUp(deps, sessionId, message) {
1236
- if (deps.registry.getActive(sessionId) !== null) {
1237
- deps.registry.queue(sessionId, { message });
1238
- return { queued: true };
1239
- }
1240
- return { runId: startAndPump(deps, sessionId, message) };
1241
- }
1242
- function startAndPump(deps, sessionId, message) {
1243
- const runId = mintRunId();
1244
- deps.cache.begin(runId);
1245
- deps.registry.startRun(sessionId, runId);
1246
- pumpIntoCache(deps, sessionId, runId, deps.startRun(sessionId, message));
1247
- return runId;
1248
- }
1249
- function pumpIntoCache(deps, sessionId, runId, chunks) {
1250
- void (async () => {
1251
- try {
1252
- for await (const chunk of chunks) {
1253
- deps.cache.append(runId, JSON.stringify(chunk));
1254
- }
1255
- } catch {
1256
- } finally {
1257
- deps.cache.end(runId);
1258
- const next = deps.registry.endRun(sessionId, runId);
1259
- if (next !== void 0) startAndPump(deps, sessionId, next.message);
1260
- }
1261
- })();
1262
- }
1263
-
1264
- // src/server/agent/thread-run-registry.ts
1265
- function createInProcessThreadRunRegistry() {
1266
- const threads = /* @__PURE__ */ new Map();
1267
- const ensure = (sessionId) => {
1268
- let s = threads.get(sessionId);
1269
- if (s === void 0) {
1270
- s = { activeRunId: null, queue: [], waiters: /* @__PURE__ */ new Set() };
1271
- threads.set(sessionId, s);
1272
- }
1273
- return s;
1274
- };
1275
- return {
1276
- getActive(sessionId) {
1277
- return threads.get(sessionId)?.activeRunId ?? null;
1278
- },
1279
- startRun(sessionId, runId) {
1280
- const s = ensure(sessionId);
1281
- s.activeRunId = runId;
1282
- const waiters = [...s.waiters];
1283
- s.waiters.clear();
1284
- for (const cb of waiters) cb(runId);
1285
- },
1286
- endRun(sessionId, runId) {
1287
- const s = threads.get(sessionId);
1288
- if (s?.activeRunId !== runId) return void 0;
1289
- s.activeRunId = null;
1290
- return s.queue.shift();
1291
- },
1292
- queue(sessionId, followUp) {
1293
- ensure(sessionId).queue.push(followUp);
1294
- },
1295
- onNextRun(sessionId, cb) {
1296
- const s = ensure(sessionId);
1297
- s.waiters.add(cb);
1298
- return () => {
1299
- s.waiters.delete(cb);
1300
- };
1301
- }
1302
- };
1303
- }
1304
- var serverRegistry;
1305
- function getThreadRunRegistry() {
1306
- serverRegistry ??= createInProcessThreadRunRegistry();
1307
- return serverRegistry;
1308
- }
1309
-
1310
- // src/server/agent/handle-thread-routes.ts
1311
- var THREAD_MESSAGE_PATH = /^\/api\/agents\/([^/]+)\/threads\/([^/]+)\/message$/;
1312
- var THREAD_STREAM_PATH = /^\/api\/agents\/([^/]+)\/threads\/([^/]+)\/stream$/;
1313
- var DEFAULT_IDLE_WAIT_MS = 3e4;
1314
- function matchThread(re, urlPath) {
1315
- const m = re.exec(urlPath);
1316
- return m ? { name: decodeURIComponent(m[1]), sessionId: decodeURIComponent(m[2]) } : null;
1317
- }
1318
- var isThreadMessagePath = (urlPath) => matchThread(THREAD_MESSAGE_PATH, urlPath);
1319
- var isThreadStreamPath = (urlPath) => matchThread(THREAD_STREAM_PATH, urlPath);
1320
- function jsonError2(status, code, message) {
1321
- return new Response(JSON.stringify({ error: { code, message } }), {
1322
- status,
1323
- headers: { "content-type": "application/json; charset=utf-8" }
1324
- });
1325
- }
1326
- async function handleThreadMessage(args) {
1327
- const { mod, apiKey, sessionId, request, source, agentName, csrfMode = "strict" } = args;
1328
- if (csrfMode === "strict") {
1329
- const csrf = validateCsrfRequest(request);
1330
- if (!csrf.valid) return jsonError2(403, "CSRF_FAILED", `CSRF check failed: ${csrf.reason}`);
1331
- }
1332
- let body = null;
1333
- try {
1334
- body = await request.json();
1335
- } catch {
1336
- }
1337
- const input = parseAgentRequestBody(body);
1338
- if (input === null) {
1339
- return jsonError2(400, "BAD_REQUEST", "Request must contain a non-empty message.");
1340
- }
1341
- const result = postThreadFollowUp(
1342
- {
1343
- registry: getThreadRunRegistry(),
1344
- cache: getRunEventCache(),
1345
- // usetheokit/theokit#381 — the request goes with it, so the run's spans join the trace of
1346
- // the caller that queued it instead of opening one of their own.
1347
- startRun: makeThreadStartRun(mod, apiKey, source, agentName, request)
1348
- },
1349
- sessionId,
1350
- input.message
1351
- );
1352
- const headers = { "content-type": "application/json; charset=utf-8" };
1353
- if ("runId" in result) headers[RUN_ID_HEADER] = result.runId;
1354
- return new Response(JSON.stringify(result), { status: 202, headers });
1355
- }
1356
- function handleThreadStream(sessionId, request, registry = getThreadRunRegistry(), cache = getRunEventCache(), idleWaitMs = DEFAULT_IDLE_WAIT_MS) {
1357
- const active = registry.getActive(sessionId);
1358
- if (active !== null && cache.has(active)) {
1359
- return handleAgentRunReconnect(active, request, cache);
1360
- }
1361
- return waitThenAttachStream(sessionId, request, registry, cache, idleWaitMs);
1362
- }
1363
- function waitThenAttachStream(sessionId, request, registry, cache, idleWaitMs) {
1364
- const stream = new ReadableStream({
1365
- start(controller) {
1366
- let closed = false;
1367
- const send = (text) => {
1368
- if (closed) return;
1369
- try {
1370
- controller.enqueue(encodeSse(text));
1371
- } catch {
1372
- }
1373
- };
1374
- let detachAttach;
1375
- const close = () => {
1376
- if (closed) return;
1377
- send(SSE_DONE_FRAME);
1378
- closed = true;
1379
- try {
1380
- controller.close();
1381
- } catch {
1382
- }
1383
- };
1384
- const offNext = registry.onNextRun(sessionId, (runId) => {
1385
- const res = cache.attach(
1386
- runId,
1387
- -1,
1388
- (frame) => {
1389
- send(formatSseFrame(frame.seq, frame.data));
1390
- },
1391
- () => {
1392
- close();
1393
- }
1394
- );
1395
- if (!res.known) {
1396
- close();
1397
- return;
1398
- }
1399
- for (const frame of res.replay) send(formatSseFrame(frame.seq, frame.data));
1400
- if (res.ended) {
1401
- close();
1402
- return;
1403
- }
1404
- detachAttach = res.unsubscribe;
1405
- });
1406
- const teardownWaiter = () => {
1407
- offNext();
1408
- detachAttach?.();
1409
- };
1410
- const timer = setTimeout(() => {
1411
- teardownWaiter();
1412
- close();
1413
- }, idleWaitMs);
1414
- timer.unref();
1415
- request.signal.addEventListener("abort", () => {
1416
- teardownWaiter();
1417
- clearTimeout(timer);
1418
- close();
1419
- });
1420
- }
1421
- });
1422
- return new Response(stream, { headers: { ...SSE_BASE_HEADERS } });
1423
- }
1424
-
1425
- // src/server/agent/list-approvals-handler.ts
1426
- var LIST_PATH = /^\/api\/agents\/([^/]+)\/approvals$/;
1427
- function isListApprovalsPath(urlPath) {
1428
- const match = LIST_PATH.exec(urlPath);
1429
- return match ? decodeURIComponent(match[1]) : null;
1430
- }
1431
- function handleListApprovals(registry, subject) {
1432
- const visible = registry.list().filter((approval) => {
1433
- const owner = registry.ownerOf(approval.approvalId);
1434
- return owner === void 0 || owner === subject;
1435
- });
1436
- return new Response(JSON.stringify({ approvals: visible }), {
1437
- status: 200,
1438
- headers: { "content-type": "application/json; charset=utf-8" }
1439
- });
1440
- }
1441
-
1442
- // src/server/agent/serve-aux-routes.ts
1443
- function jsonError3(status, code, message) {
1444
- return new Response(JSON.stringify({ error: { code, message } }), {
1445
- status,
1446
- headers: { "content-type": "application/json; charset=utf-8" }
1447
- });
1448
- }
1449
- function routeFor(deps, name, build) {
1450
- if (name === null) return null;
1451
- const agent = deps.agents.find((a) => a.name === name);
1452
- return agent === void 0 ? null : build(agent);
1453
- }
1454
- function matchGetAuxRoute(verb, urlPath, deps) {
1455
- if (verb !== "GET") return null;
1456
- const card = routeFor(
1457
- deps,
1458
- isAgentCardPath(urlPath),
1459
- (agent) => ({ kind: "card", agent })
1460
- );
1461
- if (card !== null) return card;
1462
- const approvals = routeFor(
1463
- deps,
1464
- isListApprovalsPath(urlPath),
1465
- (agent) => ({ kind: "approvals", agent })
1466
- );
1467
- if (approvals !== null) return approvals;
1468
- const run = isAgentRunStreamPath(urlPath);
1469
- if (run !== null) {
1470
- return routeFor(
1471
- deps,
1472
- run.name,
1473
- (agent) => ({ kind: "run-stream", agent, runId: run.runId })
1474
- );
1475
- }
1476
- const stream = isThreadStreamPath(urlPath);
1477
- if (stream === null) return null;
1478
- return routeFor(
1479
- deps,
1480
- stream.name,
1481
- (agent) => ({ kind: "thread-stream", agent, sessionId: stream.sessionId })
1482
- );
1483
- }
1484
- async function matchPostAuxRoute(verb, urlPath, deps) {
1485
- if (verb !== "POST") return null;
1486
- const msg = isThreadMessagePath(urlPath);
1487
- if (msg !== null) {
1488
- return routeFor(
1489
- deps,
1490
- msg.name,
1491
- (agent2) => ({ kind: "thread-message", agent: agent2, sessionId: msg.sessionId })
1492
- );
1493
- }
1494
- const agent = routeFor(deps, isMcpPath(urlPath), (found) => found);
1495
- if (agent === null) return null;
1496
- const mod = await deps.loadModule(agent.filePath);
1497
- return isMcpExposed(mod) ? { kind: "mcp", agent, mod } : null;
1498
- }
1499
- async function matchAgentAuxRoute(method, urlPath, deps) {
1500
- const verb = method.toUpperCase();
1501
- return matchGetAuxRoute(verb, urlPath, deps) ?? await matchPostAuxRoute(verb, urlPath, deps);
1502
- }
1503
- async function admitAux(deps, agent, params, body) {
1504
- const mod = await deps.loadModule(agent.filePath);
1505
- const resolve11 = deps.resolveSubject;
1506
- const admitted = { subject: null };
1507
- const recording = resolve11 === void 0 ? void 0 : async () => {
1508
- admitted.subject = await resolve11();
1509
- return admitted.subject;
1510
- };
1511
- const decision = await admitAgentRequest(
1512
- readAgentPolicy(mod, agent.filePath),
1513
- recording,
1514
- params,
1515
- body
1516
- );
1517
- const refusal = decision.allowed ? null : agentAccessDenied(decision, params);
1518
- return { refusal, subject: admitted.subject?.id };
1519
- }
1520
- async function serveMatchedAuxRoute(route, request, deps) {
1521
- if (route.kind === "card") {
1522
- const mod = await deps.loadModule(route.agent.filePath);
1523
- return handleAgentCard(mod, route.agent.name, route.agent.agentPath, deps.baseUrl);
1524
- }
1525
- if (route.kind === "approvals") {
1526
- const admission = await admitAux(deps, route.agent, {
1527
- agent: route.agent.name,
1528
- endpoint: "approvals"
1529
- });
1530
- if (admission.refusal !== null) return admission.refusal;
1531
- return handleListApprovals(getApprovalRegistry(), admission.subject);
1532
- }
1533
- if (route.kind === "run-stream") {
1534
- return handleAgentRunReconnect(route.runId, request, getRunEventCache());
1535
- }
1536
- if (route.kind === "mcp") return serveMcpRoute(route, request, deps);
1537
- return serveThreadRoute(route, request, deps);
1538
- }
1539
- async function serveThreadRoute(route, request, deps) {
1540
- const { agent, sessionId } = route;
1541
- if (route.kind === "thread-stream") {
1542
- const { refusal: refusal2 } = await admitAux(deps, agent, {
1543
- agent: agent.name,
1544
- endpoint: "thread-stream",
1545
- sessionId
1546
- });
1547
- return refusal2 ?? handleThreadStream(sessionId, request);
1548
- }
1549
- const { refusal } = await admitAux(deps, agent, {
1550
- agent: agent.name,
1551
- endpoint: "thread-message",
1552
- sessionId
1553
- });
1554
- if (refusal !== null) return refusal;
1555
- if (deps.resolveApiKey === void 0) {
1556
- return jsonError3(
1557
- 501,
1558
- "NOT_CONFIGURED",
1559
- "Thread follow-up requires a provider API key (resolveApiKey was not provided to serveMatchedAuxRoute)."
1560
- );
1561
- }
1562
- const mod = await deps.loadModule(agent.filePath);
1563
- return handleThreadMessage({
1564
- mod,
1565
- // Passed unresolved: `makeThreadStartRun` calls it once the module is compiled and the
1566
- // model is known (theokit#328).
1567
- apiKey: deps.resolveApiKey,
1568
- sessionId,
1569
- request,
1570
- source: `agent "${agent.name}"`,
1571
- // usetheokit/theokit#406 — the label above reads well in an `AgentDefinitionError` and is not
1572
- // a name; the spans get the name, so the same agent is one series whichever route started it.
1573
- agentName: agent.name,
1574
- csrfMode: deps.csrfMode ?? "strict"
1575
- });
1576
- }
1577
- async function serveMcpRoute(route, request, deps) {
1578
- const { agent, mod } = route;
1579
- const mcpParams = { agent: agent.name, endpoint: "mcp" };
1580
- const mcpDecision = await admitAgentRequest(
1581
- readAgentPolicy(mod, agent.filePath),
1582
- deps.resolveSubject,
1583
- mcpParams
1584
- );
1585
- if (!mcpDecision.allowed) return agentAccessDenied(mcpDecision, mcpParams);
1586
- const csrfMode = deps.csrfMode ?? "strict";
1587
- if (csrfMode === "strict") {
1588
- const csrf = validateCsrfRequest(request);
1589
- if (!csrf.valid) return jsonError3(403, "CSRF_FAILED", `CSRF check failed: ${csrf.reason}`);
1590
- }
1591
- let body = null;
1592
- try {
1593
- body = await request.json();
1594
- } catch {
1595
- }
1596
- return handleMcpJsonRpc(mod, agent.name, body, extractAppResources(mod));
1597
- }
1598
- function isMcpExposed(mod) {
1599
- return mod?.mcp === true;
1600
- }
1601
-
1602
1107
  // src/server/http/plugin-lifecycle.ts
1603
1108
  function messageOf2(err, fallback) {
1604
1109
  return err instanceof Error ? err.message : fallback;
@@ -1627,22 +1132,6 @@ async function serveThroughPluginLifecycle(target, serve) {
1627
1132
  if (pluginRunner) await pluginRunner.runOnResponse(pluginCtx);
1628
1133
  }
1629
1134
 
1630
- // src/server/http/resolve-agent-subject.ts
1631
- function createAgentSubjectResolver(sources) {
1632
- let pending;
1633
- return () => {
1634
- pending ??= resolve5(sources);
1635
- return pending;
1636
- };
1637
- }
1638
- async function resolve5(sources) {
1639
- const { req, res, loadModule, serverDir, pluginRunner } = sources;
1640
- const produced = serverDir === void 0 ? {} : await createServerContext(req, res, loadModule, serverDir);
1641
- const ctx = produced ?? {};
1642
- pluginRunner?.applyDecorations(ctx);
1643
- return subjectFromContext(ctx);
1644
- }
1645
-
1646
1135
  // src/vite-plugin/agent-middleware.ts
1647
1136
  var PREFIX2 = "/api/agents/";
1648
1137
  async function serveApprove(req, res, urlPath, deps, log) {
@@ -1867,7 +1356,7 @@ async function serveAgentTurn(t) {
1867
1356
  }
1868
1357
 
1869
1358
  // src/vite-plugin/api-middleware.ts
1870
- import { resolve as resolve6 } from "node:path";
1359
+ import { resolve as resolve5 } from "node:path";
1871
1360
  function shouldBypassApiMiddleware(url, prefixes) {
1872
1361
  if (!url.startsWith("/api/")) return true;
1873
1362
  if (prefixes.length === 0) return false;
@@ -1915,10 +1404,10 @@ async function handleBatchIfMatch(req, res, ctx) {
1915
1404
  async function handleBatchInline(req, res, batching, requestId) {
1916
1405
  try {
1917
1406
  const chunks = [];
1918
- await new Promise((resolve11, reject) => {
1407
+ await new Promise((resolve10, reject) => {
1919
1408
  req.on("data", (c) => chunks.push(c));
1920
1409
  req.on("end", () => {
1921
- resolve11();
1410
+ resolve10();
1922
1411
  });
1923
1412
  req.on("error", reject);
1924
1413
  });
@@ -1974,7 +1463,7 @@ async function runPluginsBeforeRouteMatch(pluginRunner, reqCtx) {
1974
1463
  }
1975
1464
  async function tryControllerFallthrough(ctx) {
1976
1465
  const handled = await dispatchControllerRequest({
1977
- controllersDir: resolve6(ctx.serverDir, "controllers"),
1466
+ controllersDir: resolve5(ctx.serverDir, "controllers"),
1978
1467
  loadModule: ctx.loadModule,
1979
1468
  req: ctx.req,
1980
1469
  res: ctx.res,
@@ -2120,7 +1609,7 @@ function createApiMiddleware(vite, serverDir, rateLimitConfigOrOptions) {
2120
1609
 
2121
1610
  // src/vite-plugin/ssr-dev-middleware.ts
2122
1611
  import { readFileSync as readFileSync2 } from "node:fs";
2123
- import { resolve as resolve7 } from "node:path";
1612
+ import { resolve as resolve6 } from "node:path";
2124
1613
 
2125
1614
  // src/core/contracts/find-root-div.ts
2126
1615
  function maskHtmlComments(html) {
@@ -2211,7 +1700,7 @@ function setupSsrDevMiddleware(server, opts) {
2211
1700
  return;
2212
1701
  }
2213
1702
  try {
2214
- const indexPath = resolve7(opts.projectRoot, "index.html");
1703
+ const indexPath = resolve6(opts.projectRoot, "index.html");
2215
1704
  let template = readFileSync2(indexPath, "utf-8");
2216
1705
  const nonce = generateNonce();
2217
1706
  template = await server.transformIndexHtml(url, template);
@@ -2354,7 +1843,7 @@ async function runConfigureServer(server, ctx) {
2354
1843
  csrfReadinessStore
2355
1844
  })
2356
1845
  );
2357
- const configPath = resolve8(ctx.projectRoot, "theo.config.ts");
1846
+ const configPath = resolve7(ctx.projectRoot, "theo.config.ts");
2358
1847
  server.watcher.on("change", (file) => {
2359
1848
  if (file === configPath) {
2360
1849
  console.warn(
@@ -2382,9 +1871,9 @@ async function runConfigureServer(server, ctx) {
2382
1871
  server.watcher.on("unlink", handleRouteChange);
2383
1872
  if (ctx.resolvedOpenApi !== void 0) {
2384
1873
  const openApiCfg = ctx.resolvedOpenApi;
2385
- const { reEmitOpenApi } = await import("./dev-emit-7RT624PM.js");
1874
+ const { reEmitOpenApi } = await import("./dev-emit-UJJXY3ET.js");
2386
1875
  const openApiServerDir = ctx.serverDir;
2387
- const openApiDistDir = resolve8(ctx.projectRoot, ctx.resolvedDistDir);
1876
+ const openApiDistDir = resolve7(ctx.projectRoot, ctx.resolvedDistDir);
2388
1877
  const isRouteFileForOpenApi = (file) => file.startsWith(openApiServerDir) && /\.(ts|tsx|js|mjs)$/.test(file);
2389
1878
  void reEmitOpenApi(openApiServerDir, openApiDistDir, openApiCfg);
2390
1879
  server.watcher.on("change", (file) => {
@@ -2691,7 +2180,7 @@ async function integrateUseTheoUI(cwd, opts) {
2691
2180
 
2692
2181
  // src/vite-plugin/transform-html-hook.ts
2693
2182
  import { existsSync as existsSync7 } from "node:fs";
2694
- import { resolve as resolve9 } from "node:path";
2183
+ import { resolve as resolve8 } from "node:path";
2695
2184
 
2696
2185
  // src/vite-plugin/inject-devtools.ts
2697
2186
  var DEVTOOLS_VIRTUAL_ID = "/@theo/devtools/entry.js";
@@ -2791,7 +2280,7 @@ function runTransformIndexHtml(html, ctx) {
2791
2280
  next = devtools.html;
2792
2281
  const styles = injectStylesheets(next, {
2793
2282
  isDev: ctx.isDevMode.value,
2794
- hasPackage: (name) => existsSync7(resolve9(ctx.projectRoot, "node_modules", ...name.split("/")))
2283
+ hasPackage: (name) => existsSync7(resolve8(ctx.projectRoot, "node_modules", ...name.split("/")))
2795
2284
  });
2796
2285
  next = styles.html;
2797
2286
  return next;
@@ -3502,7 +2991,7 @@ function findConsumerConfig(projectRoot, basename2) {
3502
2991
  let dir = projectRoot;
3503
2992
  for (let level = 0; level < 3; level++) {
3504
2993
  for (const ext of extensions) {
3505
- const candidate = resolve10(dir, `${basename2}${ext}`);
2994
+ const candidate = resolve9(dir, `${basename2}${ext}`);
3506
2995
  if (existsSync8(candidate)) return candidate;
3507
2996
  }
3508
2997
  const parent = dirname4(dir);
@@ -3514,7 +3003,7 @@ function findConsumerConfig(projectRoot, basename2) {
3514
3003
  async function theoPluginAsync(rootOrOptions) {
3515
3004
  const options = typeof rootOrOptions === "string" ? { root: rootOrOptions } : rootOrOptions ?? {};
3516
3005
  const projectRoot = options.root ?? process.cwd();
3517
- const serverDirAbs = resolve10(projectRoot, options.serverDir ?? "server");
3006
+ const serverDirAbs = resolve9(projectRoot, options.serverDir ?? "server");
3518
3007
  const agentsDirName = options.agentsDir ?? "agents";
3519
3008
  const consumerTailwindConfig = findConsumerConfig(projectRoot, "tailwind.config");
3520
3009
  const consumerPostcssConfig = findConsumerConfig(projectRoot, "postcss.config");
@@ -3534,24 +3023,24 @@ async function theoPluginAsync(rootOrOptions) {
3534
3023
  );
3535
3024
  }
3536
3025
  const { assetsMapPlugin } = await import("./assets-map-CV2YZ3MY.js");
3537
- const assetsMap = assetsMapPlugin({ appDir: resolve10(projectRoot, options.appDir ?? "app") });
3538
- const { appTypedClientPlugin } = await import("./app-typed-client-RAFEBA7S.js");
3026
+ const assetsMap = assetsMapPlugin({ appDir: resolve9(projectRoot, options.appDir ?? "app") });
3027
+ const { appTypedClientPlugin } = await import("./app-typed-client-6YQREFRS.js");
3539
3028
  const appClientPlugin = appTypedClientPlugin({
3540
3029
  cwd: projectRoot,
3541
3030
  serverDir: serverDirAbs,
3542
- distDir: resolve10(projectRoot, ".theokit")
3031
+ distDir: resolve9(projectRoot, ".theokit")
3543
3032
  });
3544
- const { actionsVirtualModule } = await import("./actions-virtual-module-SE44BKR4.js");
3033
+ const { actionsVirtualModule } = await import("./actions-virtual-module-ICWX5PZ2.js");
3545
3034
  const actionsPlugin = actionsVirtualModule({
3546
3035
  serverDir: serverDirAbs,
3547
- distDir: resolve10(projectRoot, ".theokit")
3036
+ distDir: resolve9(projectRoot, ".theokit")
3548
3037
  });
3549
3038
  const { agentsTypedClientPlugin } = await import("./agents-typed-client-PVUZU65B.js");
3550
- const { generateManifest } = await import("./internal-api-VAKXXW6F.js");
3039
+ const { generateManifest } = await import("./internal-api-S72T2XKD.js");
3551
3040
  const agentsClientPlugin = agentsTypedClientPlugin({
3552
3041
  projectRoot,
3553
3042
  agentsDir: agentsDirName,
3554
- distDir: resolve10(projectRoot, ".theokit"),
3043
+ distDir: resolve9(projectRoot, ".theokit"),
3555
3044
  // Agents live at <projectRoot>/<agentsDir>; generateManifest scans them via the server dir's
3556
3045
  // parent (projectRoot for the canonical layout) + the agents dir name (#95 follow-up).
3557
3046
  scanManifest: () => generateManifest(serverDirAbs, projectRoot, agentsDirName)
@@ -3564,7 +3053,7 @@ async function theoPluginAsync(rootOrOptions) {
3564
3053
  const controllerTransformPlugin = controllerSwcTransformPlugin({
3565
3054
  serverDir: serverDirAbs
3566
3055
  });
3567
- const { serverOnlyImportBoundary } = await import("./server-boundary-V6PCM22J.js");
3056
+ const { serverOnlyImportBoundary } = await import("./server-boundary-I5XWYINJ.js");
3568
3057
  const serverBoundaryPlugin = serverOnlyImportBoundary({
3569
3058
  projectRoot,
3570
3059
  serverDir: serverDirAbs
@@ -3586,10 +3075,10 @@ async function theoPluginAsync(rootOrOptions) {
3586
3075
  }
3587
3076
  function buildOptimizeDepsInclude(projectRoot, viteOptimizeDeps) {
3588
3077
  const include = [];
3589
- if (existsSync8(resolve10(projectRoot, "node_modules", "@theokit", "ui"))) {
3078
+ if (existsSync8(resolve9(projectRoot, "node_modules", "@theokit", "ui"))) {
3590
3079
  include.push("@theokit/ui");
3591
3080
  }
3592
- if (existsSync8(resolve10(projectRoot, "node_modules", "lucide-react"))) {
3081
+ if (existsSync8(resolve9(projectRoot, "node_modules", "lucide-react"))) {
3593
3082
  include.push("lucide-react");
3594
3083
  }
3595
3084
  include.push("devalue");
@@ -3615,8 +3104,8 @@ var VIRTUAL_MODULE_IDS = {
3615
3104
  function theoPlugin(rootOrOptions) {
3616
3105
  const options = typeof rootOrOptions === "string" ? { root: rootOrOptions } : rootOrOptions ?? {};
3617
3106
  const projectRoot = options.root ?? process.cwd();
3618
- const appDir = resolve10(projectRoot, options.appDir ?? "app");
3619
- const serverDir = resolve10(projectRoot, options.serverDir ?? "server");
3107
+ const appDir = resolve9(projectRoot, options.appDir ?? "app");
3108
+ const serverDir = resolve9(projectRoot, options.serverDir ?? "server");
3620
3109
  const agentsDir = options.agentsDir ?? "agents";
3621
3110
  const ssrEnabled = options.ssr ?? false;
3622
3111
  const currentDir = dirname4(fileURLToPath(import.meta.url));
@@ -3748,4 +3237,4 @@ export {
3748
3237
  theoPluginAsync,
3749
3238
  theoPlugin
3750
3239
  };
3751
- //# sourceMappingURL=chunk-LADTWXOB.js.map
3240
+ //# sourceMappingURL=chunk-H5KSRGRS.js.map