theokit 0.21.0 → 0.22.1

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 (37) hide show
  1. package/dist/{agent-76WK2CZJ.js → agent-7IGDT55V.js} +2 -2
  2. package/dist/{build-TBV4KVXI.js → build-G7WWVZTL.js} +2 -2
  3. package/dist/chunk-2CVV6CNN.js +174 -0
  4. package/dist/chunk-2CVV6CNN.js.map +1 -0
  5. package/dist/{chunk-3WOODHXK.js → chunk-AYZCGJXA.js} +12 -6
  6. package/dist/chunk-AYZCGJXA.js.map +1 -0
  7. package/dist/{chunk-7PFHQ56Q.js → chunk-BLL5LY7R.js} +39 -15
  8. package/dist/chunk-BLL5LY7R.js.map +1 -0
  9. package/dist/{chunk-23T4CO4M.js → chunk-JITNAZXE.js} +2 -2
  10. package/dist/{chunk-DXF64KS5.js → chunk-LGVVX3BV.js} +30 -12
  11. package/dist/chunk-LGVVX3BV.js.map +1 -0
  12. package/dist/{chunk-W4YO6S4I.js → chunk-W4XWVTN4.js} +112 -67
  13. package/dist/chunk-W4XWVTN4.js.map +1 -0
  14. package/dist/cli/index.js +5 -5
  15. package/dist/{dev-NHHTXOA4.js → dev-SHAN56K5.js} +4 -4
  16. package/dist/index.js +2 -2
  17. package/dist/{mcp-HP5RVOOZ.js → mcp-P4MHP3VA.js} +4 -4
  18. package/dist/{mcp-HP5RVOOZ.js.map → mcp-P4MHP3VA.js.map} +1 -1
  19. package/dist/server/index.d.ts +162 -1
  20. package/dist/server/index.js +60 -3
  21. package/dist/server/index.js.map +1 -1
  22. package/dist/{start-ILT6E25Q.js → start-RD5WQMIH.js} +6 -4
  23. package/dist/{start-ILT6E25Q.js.map → start-RD5WQMIH.js.map} +1 -1
  24. package/dist/vite-plugin/index.js +2 -2
  25. package/dist/{vite-plugin-3UDOJGO5.js → vite-plugin-A7WGYEMD.js} +4 -4
  26. package/package.json +1 -1
  27. package/dist/chunk-3WOODHXK.js.map +0 -1
  28. package/dist/chunk-7PFHQ56Q.js.map +0 -1
  29. package/dist/chunk-DMC6HYUR.js +0 -141
  30. package/dist/chunk-DMC6HYUR.js.map +0 -1
  31. package/dist/chunk-DXF64KS5.js.map +0 -1
  32. package/dist/chunk-W4YO6S4I.js.map +0 -1
  33. /package/dist/{agent-76WK2CZJ.js.map → agent-7IGDT55V.js.map} +0 -0
  34. /package/dist/{build-TBV4KVXI.js.map → build-G7WWVZTL.js.map} +0 -0
  35. /package/dist/{chunk-23T4CO4M.js.map → chunk-JITNAZXE.js.map} +0 -0
  36. /package/dist/{dev-NHHTXOA4.js.map → dev-SHAN56K5.js.map} +0 -0
  37. /package/dist/{vite-plugin-3UDOJGO5.js.map → vite-plugin-A7WGYEMD.js.map} +0 -0
@@ -3,7 +3,7 @@ import "tsx/esm";
3
3
  import {
4
4
  agentCommand,
5
5
  createAgentSsrLoader
6
- } from "./chunk-23T4CO4M.js";
6
+ } from "./chunk-JITNAZXE.js";
7
7
  import "./chunk-M6NMS5LR.js";
8
8
  import "./chunk-GDN3PXFH.js";
9
9
  import "./chunk-TERFLG67.js";
@@ -12,4 +12,4 @@ export {
12
12
  agentCommand,
13
13
  createAgentSsrLoader
14
14
  };
15
- //# sourceMappingURL=agent-76WK2CZJ.js.map
15
+ //# sourceMappingURL=agent-7IGDT55V.js.map
@@ -531,7 +531,7 @@ async function buildCommand(options) {
531
531
  `);
532
532
  }
533
533
  async function runAdapterBuild(target, config, cwd) {
534
- const { theoPluginAsync } = await import("./vite-plugin-3UDOJGO5.js");
534
+ const { theoPluginAsync } = await import("./vite-plugin-A7WGYEMD.js");
535
535
  const { default: react } = await import("@vitejs/plugin-react");
536
536
  const ctx = {
537
537
  // `react()` may return Plugin or Plugin[] depending on version; spread the
@@ -616,4 +616,4 @@ function relativize3(absPath, root) {
616
616
  export {
617
617
  buildCommand
618
618
  };
619
- //# sourceMappingURL=build-TBV4KVXI.js.map
619
+ //# sourceMappingURL=build-G7WWVZTL.js.map
@@ -0,0 +1,174 @@
1
+ #!/usr/bin/env node
2
+ import "tsx/esm";
3
+
4
+ // src/server/agent/mcp-app-resources.ts
5
+ function buildResourceDescriptors(resources) {
6
+ return resources.map((r) => ({
7
+ uri: r.uri,
8
+ name: r.name,
9
+ mimeType: r.mimeType,
10
+ ...r.description !== void 0 ? { description: r.description } : {}
11
+ }));
12
+ }
13
+ function readAppResource(resources, uri) {
14
+ const found = resources.find((r) => r.uri === uri);
15
+ if (!found) return null;
16
+ return { contents: [{ uri: found.uri, mimeType: "text/html", text: found.html }] };
17
+ }
18
+ function isAppResource(v) {
19
+ if (typeof v !== "object" || v === null) return false;
20
+ const r = v;
21
+ return typeof r.uri === "string" && r.uri.startsWith("ui://") && r.mimeType === "text/html" && typeof r.html === "string";
22
+ }
23
+ function extractAppResources(mod) {
24
+ const raw = mod?.appResources;
25
+ if (!Array.isArray(raw)) return [];
26
+ return raw.filter(isAppResource);
27
+ }
28
+
29
+ // src/server/agent/mcp-handler.ts
30
+ import { compileAgentModule } from "@theokit/agents";
31
+ var MCP_PATH = /^\/api\/agents\/([^/]+)\/mcp$/;
32
+ var MCP_PROTOCOL_VERSION = "2025-06-18";
33
+ function toolDescriptors(tools) {
34
+ return tools.map((t) => ({
35
+ name: t.name,
36
+ description: t.description,
37
+ // The compiled tool already carries a JSON Schema (via `z.toJSONSchema()` in defineAgentTool).
38
+ // Fall back to a permissive object only when a tool genuinely declared no schema.
39
+ inputSchema: t.inputSchema && typeof t.inputSchema === "object" ? t.inputSchema : { type: "object", properties: {} }
40
+ }));
41
+ }
42
+ function isMcpPath(urlPath) {
43
+ const match = MCP_PATH.exec(urlPath);
44
+ return match ? decodeURIComponent(match[1]) : null;
45
+ }
46
+ function isJsonRpcRequest(body) {
47
+ return typeof body === "object" && body !== null && body.jsonrpc === "2.0" && typeof body.method === "string";
48
+ }
49
+ function jsonResponse(payload) {
50
+ return new Response(JSON.stringify(payload), {
51
+ status: 200,
52
+ headers: { "content-type": "application/json; charset=utf-8" }
53
+ });
54
+ }
55
+ async function callTool(tools, toolName, args, hitl) {
56
+ if (typeof toolName !== "string") {
57
+ return {
58
+ content: [{ type: "text", text: "tools/call requires a string `name`." }],
59
+ isError: true
60
+ };
61
+ }
62
+ const tool = tools.find((t) => t.name === toolName);
63
+ if (!tool) {
64
+ return { content: [{ type: "text", text: `Unknown tool: ${toolName}` }], isError: true };
65
+ }
66
+ if (hitl?.has(toolName)) {
67
+ return {
68
+ content: [
69
+ {
70
+ type: "text",
71
+ text: `Tool "${toolName}" requires human approval, which is not available over MCP. Refused.`
72
+ }
73
+ ],
74
+ isError: true
75
+ };
76
+ }
77
+ try {
78
+ const result = await tool.handler(args);
79
+ const text = typeof result === "string" ? result : JSON.stringify(result);
80
+ return { content: [{ type: "text", text }] };
81
+ } catch (err) {
82
+ return {
83
+ content: [
84
+ { type: "text", text: err instanceof Error ? err.message : "Tool execution failed" }
85
+ ],
86
+ isError: true
87
+ };
88
+ }
89
+ }
90
+ function handleResourcesRead(id, params, appResources) {
91
+ const uri = params?.uri;
92
+ if (typeof uri !== "string") {
93
+ return jsonResponse({
94
+ jsonrpc: "2.0",
95
+ id,
96
+ error: { code: -32602, message: "resources/read requires a string `uri` param." }
97
+ });
98
+ }
99
+ const contents = readAppResource(appResources, uri);
100
+ if (contents === null) {
101
+ return jsonResponse({
102
+ jsonrpc: "2.0",
103
+ id,
104
+ error: { code: -32602, message: `Resource not found: ${uri}` }
105
+ });
106
+ }
107
+ return jsonResponse({ jsonrpc: "2.0", id, result: contents });
108
+ }
109
+ async function handleMcpJsonRpc(mod, name, body, appResources = []) {
110
+ if (!isJsonRpcRequest(body)) {
111
+ return jsonResponse({
112
+ jsonrpc: "2.0",
113
+ id: null,
114
+ error: { code: -32600, message: "Invalid Request" }
115
+ });
116
+ }
117
+ const { id, method, params } = body;
118
+ try {
119
+ const compiled = compileAgentModule(mod, `mcp server for "${name}"`);
120
+ if (method === "initialize") {
121
+ const capabilities = { tools: {} };
122
+ if (appResources.length > 0) capabilities.resources = {};
123
+ return jsonResponse({
124
+ jsonrpc: "2.0",
125
+ id,
126
+ result: {
127
+ protocolVersion: MCP_PROTOCOL_VERSION,
128
+ capabilities,
129
+ serverInfo: { name, version: "1.0" }
130
+ }
131
+ });
132
+ }
133
+ if (method === "tools/list") {
134
+ return jsonResponse({
135
+ jsonrpc: "2.0",
136
+ id,
137
+ result: { tools: toolDescriptors(compiled.tools) }
138
+ });
139
+ }
140
+ if (method === "tools/call") {
141
+ const p = params;
142
+ const result = await callTool(compiled.tools, p?.name, p?.arguments ?? {}, compiled.hitl);
143
+ return jsonResponse({ jsonrpc: "2.0", id, result });
144
+ }
145
+ if (method === "resources/list") {
146
+ return jsonResponse({
147
+ jsonrpc: "2.0",
148
+ id,
149
+ result: { resources: buildResourceDescriptors(appResources) }
150
+ });
151
+ }
152
+ if (method === "resources/read") {
153
+ return handleResourcesRead(id, params, appResources);
154
+ }
155
+ return jsonResponse({
156
+ jsonrpc: "2.0",
157
+ id,
158
+ error: { code: -32601, message: `Method not found: ${method}` }
159
+ });
160
+ } catch (err) {
161
+ return jsonResponse({
162
+ jsonrpc: "2.0",
163
+ id,
164
+ error: { code: -32603, message: err instanceof Error ? err.message : "Internal error" }
165
+ });
166
+ }
167
+ }
168
+
169
+ export {
170
+ extractAppResources,
171
+ isMcpPath,
172
+ handleMcpJsonRpc
173
+ };
174
+ //# sourceMappingURL=chunk-2CVV6CNN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/server/agent/mcp-app-resources.ts","../src/server/agent/mcp-handler.ts"],"sourcesContent":["/**\n * M30 (ADR-0041) — MCP Apps: `ui://` HTML resources for the MCP server (M16).\n *\n * A tool can declare a `ui://` HTML resource; the MCP server advertises it via `resources/list` and\n * serves the HTML via `resources/read`. The client renders it in a SANDBOXED iframe (see\n * `mcp-app-host.ts`). Pure data transforms here — no LLM, no runtime (ADR-0040 § D2 home concern).\n *\n * Security: only the `ui://` scheme is accepted (an app UI resource), never `http(s)://` — the HTML\n * is rendered sandboxed on the client, and the scheme gate keeps a tool from smuggling a remote URL\n * into the app surface.\n */\n\n/** A declared `ui://` app resource. */\nexport interface AppResource {\n uri: string\n name: string\n mimeType: 'text/html'\n html: string\n description?: string\n}\n\n/** Input to {@link defineAppResource}. */\nexport interface AppResourceInput {\n /** MUST start with `ui://`. */\n uri: string\n name: string\n html: string\n description?: string\n}\n\n/** An MCP `resources/list` descriptor (no HTML body — that comes from `resources/read`). */\nexport interface McpResourceDescriptor {\n uri: string\n name: string\n mimeType: 'text/html'\n description?: string\n}\n\n/** An MCP `resources/read` result. */\nexport interface McpResourceContents {\n contents: { uri: string; mimeType: 'text/html'; text: string }[]\n}\n\n/**\n * Declare a `ui://` HTML app resource. Fails fast if the uri is not a `ui://` scheme or the HTML is\n * empty (error-handling.md) — a misconfigured resource is caught at definition time.\n */\nexport function defineAppResource(input: AppResourceInput): AppResource {\n if (!input.uri.startsWith('ui://')) {\n throw new Error(\n `defineAppResource: uri must use the ui:// scheme (an app UI resource). Got: ${JSON.stringify(input.uri)}`,\n )\n }\n if (input.html.length === 0) {\n throw new Error(`defineAppResource(${JSON.stringify(input.uri)}): html must be non-empty.`)\n }\n return {\n uri: input.uri,\n name: input.name,\n mimeType: 'text/html',\n html: input.html,\n ...(input.description !== undefined ? { description: input.description } : {}),\n }\n}\n\n/** Map app resources to MCP `resources/list` descriptors (the HTML body is omitted from the list). */\nexport function buildResourceDescriptors(\n resources: readonly AppResource[],\n): McpResourceDescriptor[] {\n return resources.map((r) => ({\n uri: r.uri,\n name: r.name,\n mimeType: r.mimeType,\n ...(r.description !== undefined ? { description: r.description } : {}),\n }))\n}\n\n/** Serve the HTML for `uri` as an MCP `resources/read` result, or `null` when unknown. */\nexport function readAppResource(\n resources: readonly AppResource[],\n uri: string,\n): McpResourceContents | null {\n const found = resources.find((r) => r.uri === uri)\n if (!found) return null\n return { contents: [{ uri: found.uri, mimeType: 'text/html', text: found.html }] }\n}\n\n/** True when `v` is a well-formed {@link AppResource} (from `defineAppResource`). */\nfunction isAppResource(v: unknown): v is AppResource {\n if (typeof v !== 'object' || v === null) return false\n const r = v as Record<string, unknown>\n return (\n typeof r.uri === 'string' &&\n r.uri.startsWith('ui://') &&\n r.mimeType === 'text/html' &&\n typeof r.html === 'string'\n )\n}\n\n/**\n * M30 wiring — extract the App resources an agent module declares via a named `appResources` export\n * (`export const appResources = [defineAppResource(...)]`). Returns only the well-formed entries; a\n * module without the export (or with a malformed one) yields `[]`. This is how per-agent `ui://`\n * resources reach the MCP server's `resources/list` + `resources/read` without a runtime dependency\n * from `@theokit/agents` on this theo-side type (the module exports them; the serving path reads them).\n */\nexport function extractAppResources(mod: unknown): AppResource[] {\n const raw = (mod as { appResources?: unknown } | null | undefined)?.appResources\n if (!Array.isArray(raw)) return []\n return raw.filter(isAppResource)\n}\n","/**\n * M16 (theokit-ai-first) — serve an agent as an MCP server over HTTP at `/api/agents/<name>/mcp`.\n *\n * Answers the two core MCP methods over JSON-RPC 2.0: `initialize` (server info + capabilities) and\n * `tools/list` (the agent's tools as MCP descriptors, via `buildMcpToolDescriptors`). M30 adds\n * `resources/list` + `resources/read` for `ui://` App resources. Unknown methods return `-32601`\n * (method not found). Web Standards Response (G8). The stdio transport + full method set stay\n * SDK-side (sdk-runtime.md); this exposes the agent over the app's own HTTP route.\n */\nimport { type CompiledTool, compileAgentModule } from '@theokit/agents'\n\nimport { type AppResource, buildResourceDescriptors, readAppResource } from './mcp-app-resources.js'\n\nconst MCP_PATH = /^\\/api\\/agents\\/([^/]+)\\/mcp$/\n\n/**\n * The MCP protocol revision THIS server transport implements (M34). The protocol version is a\n * property of the server that speaks it (this handler), not of the manifest data generator — so the\n * handler owns it. Current MCP revision (`2025-06-18`); replaces the stale `2024-11-05` the manifest\n * generator carried.\n */\nconst MCP_PROTOCOL_VERSION = '2025-06-18'\n\n/** An MCP `tools/list` descriptor with the tool's REAL input schema retained (M34 — no longer dropped). */\ninterface McpToolDescriptor {\n name: string\n description: string\n inputSchema: Record<string, unknown>\n}\n\n/** Build tool descriptors from the compiled tools, retaining each tool's real JSON-Schema input (M34). */\nfunction toolDescriptors(tools: readonly CompiledTool[]): McpToolDescriptor[] {\n return tools.map((t) => ({\n name: t.name,\n description: t.description,\n // The compiled tool already carries a JSON Schema (via `z.toJSONSchema()` in defineAgentTool).\n // Fall back to a permissive object only when a tool genuinely declared no schema.\n inputSchema:\n t.inputSchema && typeof t.inputSchema === 'object'\n ? (t.inputSchema as Record<string, unknown>)\n : { type: 'object', properties: {} },\n }))\n}\n\n/** An MCP `CallToolResult` — `content[]` + `isError` (the shape MCP clients expect). */\ninterface CallToolResult {\n content: { type: 'text'; text: string }[]\n isError?: boolean\n}\n\n/** Return the agent name when `urlPath` is the MCP endpoint, else `null`. */\nexport function isMcpPath(urlPath: string): string | null {\n const match = MCP_PATH.exec(urlPath)\n return match ? decodeURIComponent(match[1]) : null\n}\n\ninterface JsonRpcRequest {\n jsonrpc: '2.0'\n id: number | string | null\n method: string\n params?: unknown\n}\n\nfunction isJsonRpcRequest(body: unknown): body is JsonRpcRequest {\n return (\n typeof body === 'object' &&\n body !== null &&\n (body as { jsonrpc?: unknown }).jsonrpc === '2.0' &&\n typeof (body as { method?: unknown }).method === 'string'\n )\n}\n\nfunction jsonResponse(payload: unknown): Response {\n return new Response(JSON.stringify(payload), {\n status: 200,\n headers: { 'content-type': 'application/json; charset=utf-8' },\n })\n}\n\n/**\n * Execute an MCP `tools/call` against the compiled tools (M34). Finds the tool by name, runs its\n * handler with the supplied `arguments`, and shapes the result into a `CallToolResult`. An unknown\n * tool or a throwing handler yields `{ isError: true }` (MCP convention — the model sees the failure)\n * rather than a JSON-RPC crash.\n */\nasync function callTool(\n tools: readonly CompiledTool[],\n toolName: unknown,\n args: unknown,\n hitl?: ReadonlyMap<string, unknown>,\n): Promise<CallToolResult> {\n if (typeof toolName !== 'string') {\n return {\n content: [{ type: 'text', text: 'tools/call requires a string `name`.' }],\n isError: true,\n }\n }\n const tool = tools.find((t) => t.name === toolName)\n if (!tool) {\n return { content: [{ type: 'text', text: `Unknown tool: ${toolName}` }], isError: true }\n }\n // #99 — REFUSE a HITL-gated tool. The approval gate (`compiled.hitl`) lives in the SDK run-loop,\n // not in the raw tool handler; executing the handler here would BYPASS the human approval the web/\n // TUI surfaces enforce. Over MCP there is no approval mechanism, so a gated tool is not callable —\n // return an error result instead of running it unguarded (fail-closed, Rule 8).\n if (hitl?.has(toolName)) {\n return {\n content: [\n {\n type: 'text',\n text: `Tool \"${toolName}\" requires human approval, which is not available over MCP. Refused.`,\n },\n ],\n isError: true,\n }\n }\n try {\n const result = await tool.handler(args)\n const text = typeof result === 'string' ? result : JSON.stringify(result)\n return { content: [{ type: 'text', text }] }\n } catch (err) {\n return {\n content: [\n { type: 'text', text: err instanceof Error ? err.message : 'Tool execution failed' },\n ],\n isError: true,\n }\n }\n}\n\n/** `resources/read` (M30) — extracted to keep `handleMcpJsonRpc` within the complexity budget. */\nfunction handleResourcesRead(\n id: number | string | null,\n params: unknown,\n appResources: readonly AppResource[],\n): Response {\n const uri = (params as { uri?: unknown } | undefined)?.uri\n if (typeof uri !== 'string') {\n return jsonResponse({\n jsonrpc: '2.0',\n id,\n error: { code: -32602, message: 'resources/read requires a string `uri` param.' },\n })\n }\n const contents = readAppResource(appResources, uri)\n if (contents === null) {\n return jsonResponse({\n jsonrpc: '2.0',\n id,\n error: { code: -32602, message: `Resource not found: ${uri}` },\n })\n }\n return jsonResponse({ jsonrpc: '2.0', id, result: contents })\n}\n\n/**\n * Handle one MCP JSON-RPC request for an agent module. Always returns a 200 JSON-RPC envelope.\n *\n * M30 — `appResources` (optional) are the agent's declared `ui://` App resources; when present the\n * server advertises `capabilities.resources` and answers `resources/list` + `resources/read`.\n */\nexport async function handleMcpJsonRpc(\n mod: unknown,\n name: string,\n body: unknown,\n appResources: readonly AppResource[] = [],\n): Promise<Response> {\n if (!isJsonRpcRequest(body)) {\n return jsonResponse({\n jsonrpc: '2.0',\n id: null,\n error: { code: -32600, message: 'Invalid Request' },\n })\n }\n const { id, method, params } = body\n try {\n const compiled = compileAgentModule(mod, `mcp server for \"${name}\"`)\n if (method === 'initialize') {\n const capabilities: Record<string, unknown> = { tools: {} }\n if (appResources.length > 0) capabilities.resources = {}\n return jsonResponse({\n jsonrpc: '2.0',\n id,\n result: {\n protocolVersion: MCP_PROTOCOL_VERSION,\n capabilities,\n serverInfo: { name, version: '1.0' },\n },\n })\n }\n if (method === 'tools/list') {\n return jsonResponse({\n jsonrpc: '2.0',\n id,\n result: { tools: toolDescriptors(compiled.tools) },\n })\n }\n if (method === 'tools/call') {\n const p = params as { name?: unknown; arguments?: unknown } | undefined\n const result = await callTool(compiled.tools, p?.name, p?.arguments ?? {}, compiled.hitl)\n return jsonResponse({ jsonrpc: '2.0', id, result })\n }\n if (method === 'resources/list') {\n return jsonResponse({\n jsonrpc: '2.0',\n id,\n result: { resources: buildResourceDescriptors(appResources) },\n })\n }\n if (method === 'resources/read') {\n return handleResourcesRead(id, params, appResources)\n }\n return jsonResponse({\n jsonrpc: '2.0',\n id,\n error: { code: -32601, message: `Method not found: ${method}` },\n })\n } catch (err) {\n return jsonResponse({\n jsonrpc: '2.0',\n id,\n error: { code: -32603, message: err instanceof Error ? err.message : 'Internal error' },\n })\n }\n}\n"],"mappings":";;;;AAkEO,SAAS,yBACd,WACyB;AACzB,SAAO,UAAU,IAAI,CAAC,OAAO;AAAA,IAC3B,KAAK,EAAE;AAAA,IACP,MAAM,EAAE;AAAA,IACR,UAAU,EAAE;AAAA,IACZ,GAAI,EAAE,gBAAgB,SAAY,EAAE,aAAa,EAAE,YAAY,IAAI,CAAC;AAAA,EACtE,EAAE;AACJ;AAGO,SAAS,gBACd,WACA,KAC4B;AAC5B,QAAM,QAAQ,UAAU,KAAK,CAAC,MAAM,EAAE,QAAQ,GAAG;AACjD,MAAI,CAAC,MAAO,QAAO;AACnB,SAAO,EAAE,UAAU,CAAC,EAAE,KAAK,MAAM,KAAK,UAAU,aAAa,MAAM,MAAM,K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ACA,WAAO,aAAa;AAAA,MAClB,SAAS;AAAA,MACT;AAAA,MACA,OAAO,EAAE,MAAM,QAAQ,SAAS,qBAAqB,MAAM,GAAG;AAAA,IAChE,CAAC;AAAA,EACH,SAAS,KAAK;AACZ,WAAO,aAAa;AAAA,MAClB,SAAS;AAAA,MACT;AAAA,MACA,OAAO,EAAE,MAAM,QAAQ,SAAS,eAAe,QAAQ,IAAI,UAAU,iBAAiB;AAAA,IACxF,CAAC;AAAA,EACH;AACF;","names":[]}
@@ -10,10 +10,10 @@ import {
10
10
  resolveTransformer,
11
11
  serveAgentAuxRoute,
12
12
  writeWebResponseToServerResponse
13
- } from "./chunk-DXF64KS5.js";
13
+ } from "./chunk-LGVVX3BV.js";
14
14
  import {
15
15
  isMcpPath
16
- } from "./chunk-DMC6HYUR.js";
16
+ } from "./chunk-2CVV6CNN.js";
17
17
  import {
18
18
  getApprovalRegistry,
19
19
  resolveProvider
@@ -453,7 +453,8 @@ async function serveAux(req, res, next, urlPath, deps) {
453
453
  const response = await serveAgentAuxRoute(request, urlPath, {
454
454
  agents: scanAgents(deps.projectRoot, deps.agentsDir),
455
455
  loadModule: deps.loadModule,
456
- baseUrl: `http://${req.headers.host ?? "localhost"}`
456
+ baseUrl: `http://${req.headers.host ?? "localhost"}`,
457
+ csrfMode: deps.csrfMode
457
458
  });
458
459
  if (response === null) {
459
460
  next();
@@ -486,7 +487,12 @@ function createAgentMiddleware(vite, projectRoot, csrfMode = "strict", agentsDir
486
487
  void (async () => {
487
488
  const url = req.url ?? "";
488
489
  if (isAgentCardPath(url.split("?")[0]) !== null) {
489
- await serveAux(req, res, next, url.split("?")[0], { projectRoot, loadModule, agentsDir });
490
+ await serveAux(req, res, next, url.split("?")[0], {
491
+ projectRoot,
492
+ loadModule,
493
+ agentsDir,
494
+ csrfMode
495
+ });
490
496
  return;
491
497
  }
492
498
  if (!url.startsWith(PREFIX2)) {
@@ -502,7 +508,7 @@ function createAgentMiddleware(vite, projectRoot, csrfMode = "strict", agentsDir
502
508
  return;
503
509
  }
504
510
  if (isListApprovalsPath(urlPath) !== null || isMcpPath(urlPath) !== null) {
505
- await serveAux(req, res, next, urlPath, { projectRoot, loadModule, agentsDir });
511
+ await serveAux(req, res, next, urlPath, { projectRoot, loadModule, agentsDir, csrfMode });
506
512
  return;
507
513
  }
508
514
  const agent = scanAgents(projectRoot, agentsDir).find((a) => a.agentPath === urlPath);
@@ -2096,4 +2102,4 @@ export {
2096
2102
  theoPluginAsync,
2097
2103
  theoPlugin
2098
2104
  };
2099
- //# sourceMappingURL=chunk-3WOODHXK.js.map
2105
+ //# sourceMappingURL=chunk-AYZCGJXA.js.map