@ai-sdk/harness-codex 0.0.0-6b196531-20260710185421

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,391 @@
1
+ # @ai-sdk/harness-codex
2
+
3
+ ## 0.0.0-6b196531-20260710185421
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [036463b]
8
+ - Updated dependencies [9988975]
9
+ - @ai-sdk/provider-utils@0.0.0-6b196531-20260710185421
10
+ - @ai-sdk/harness@0.0.0-6b196531-20260710185421
11
+
12
+ ## 1.0.26
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies [44e988a]
17
+ - @ai-sdk/harness@1.0.25
18
+
19
+ ## 1.0.25
20
+
21
+ ### Patch Changes
22
+
23
+ - @ai-sdk/harness@1.0.24
24
+
25
+ ## 1.0.24
26
+
27
+ ### Patch Changes
28
+
29
+ - 39c8276: fix(harness): improve opaque sandbox bridge error handling
30
+ - 91fe6d8: fix(harness): emit `finish-step` stream parts correctly per the underlying model steps
31
+ - Updated dependencies [39c8276]
32
+ - Updated dependencies [91fe6d8]
33
+ - Updated dependencies [0be5014]
34
+ - @ai-sdk/harness@1.0.23
35
+
36
+ ## 1.0.23
37
+
38
+ ### Patch Changes
39
+
40
+ - @ai-sdk/harness@1.0.22
41
+ - @ai-sdk/provider-utils@5.0.7
42
+
43
+ ## 1.0.22
44
+
45
+ ### Patch Changes
46
+
47
+ - Updated dependencies [ac306ed]
48
+ - @ai-sdk/provider-utils@5.0.6
49
+ - @ai-sdk/harness@1.0.21
50
+
51
+ ## 1.0.21
52
+
53
+ ### Patch Changes
54
+
55
+ - b2d0306: feat(harness): send `User-Agent` and `x-client-app` headers in harness adapters
56
+ - Updated dependencies [b7aa06a]
57
+ - @ai-sdk/harness@1.0.20
58
+
59
+ ## 1.0.20
60
+
61
+ ### Patch Changes
62
+
63
+ - @ai-sdk/harness@1.0.19
64
+
65
+ ## 1.0.19
66
+
67
+ ### Patch Changes
68
+
69
+ - @ai-sdk/harness@1.0.18
70
+
71
+ ## 1.0.18
72
+
73
+ ### Patch Changes
74
+
75
+ - Updated dependencies [5c5c0f5]
76
+ - @ai-sdk/provider-utils@5.0.5
77
+ - @ai-sdk/harness@1.0.17
78
+
79
+ ## 1.0.17
80
+
81
+ ### Patch Changes
82
+
83
+ - @ai-sdk/harness@1.0.16
84
+
85
+ ## 1.0.16
86
+
87
+ ### Patch Changes
88
+
89
+ - Updated dependencies [c6f5e62]
90
+ - @ai-sdk/provider-utils@5.0.4
91
+ - @ai-sdk/harness@1.0.15
92
+
93
+ ## 1.0.15
94
+
95
+ ### Patch Changes
96
+
97
+ - @ai-sdk/harness@1.0.14
98
+
99
+ ## 1.0.14
100
+
101
+ ### Patch Changes
102
+
103
+ - Updated dependencies [8c616f0]
104
+ - @ai-sdk/provider-utils@5.0.3
105
+ - @ai-sdk/harness@1.0.13
106
+
107
+ ## 1.0.13
108
+
109
+ ### Patch Changes
110
+
111
+ - 7859cea: feat(harness): add tool filtering via `activeTools` and `inactiveTools`
112
+ - c857346: feat(harness): add utility functions for certain duplicated layers in harnesses
113
+ - Updated dependencies [7859cea]
114
+ - Updated dependencies [c857346]
115
+ - @ai-sdk/harness@1.0.12
116
+
117
+ ## 1.0.12
118
+
119
+ ### Patch Changes
120
+
121
+ - 2933383: fix(harness): fix harness relay auth
122
+ - @ai-sdk/harness@1.0.11
123
+
124
+ ## 1.0.11
125
+
126
+ ### Patch Changes
127
+
128
+ - 0d1cb8e: fix(harness-codex): improve Codex prompt framing and avoid placing relay shim file in session workdir
129
+
130
+ ## 1.0.10
131
+
132
+ ### Patch Changes
133
+
134
+ - @ai-sdk/harness@1.0.10
135
+ - @ai-sdk/provider-utils@5.0.2
136
+
137
+ ## 1.0.9
138
+
139
+ ### Patch Changes
140
+
141
+ - @ai-sdk/harness@1.0.9
142
+
143
+ ## 1.0.8
144
+
145
+ ### Patch Changes
146
+
147
+ - c0e991c: fix(harness-codex): fix Codex sometimes stopping after a single text response when using `workflow-harness`
148
+ - @ai-sdk/harness@1.0.8
149
+
150
+ ## 1.0.7
151
+
152
+ ### Patch Changes
153
+
154
+ - @ai-sdk/harness@1.0.7
155
+
156
+ ## 1.0.6
157
+
158
+ ### Patch Changes
159
+
160
+ - Updated dependencies [6a436e3]
161
+ - @ai-sdk/provider-utils@5.0.1
162
+ - @ai-sdk/harness@1.0.6
163
+
164
+ ## 1.0.5
165
+
166
+ ### Patch Changes
167
+
168
+ - 43a8c68: fix(harness): use `shellQuote` where appropriate in harness adapters
169
+ - @ai-sdk/harness@1.0.5
170
+
171
+ ## 1.0.4
172
+
173
+ ### Patch Changes
174
+
175
+ - c493634: fix(harness): fix harness Zod usage to be v3/v4 compatible
176
+ - Updated dependencies [c493634]
177
+ - @ai-sdk/harness@1.0.4
178
+
179
+ ## 1.0.3
180
+
181
+ ### Patch Changes
182
+
183
+ - Updated dependencies [51d10a0]
184
+ - @ai-sdk/harness@1.0.3
185
+
186
+ ## 1.0.2
187
+
188
+ ### Patch Changes
189
+
190
+ - @ai-sdk/harness@1.0.2
191
+
192
+ ## 1.0.1
193
+
194
+ ### Patch Changes
195
+
196
+ - @ai-sdk/harness@1.0.1
197
+
198
+ ## 1.0.0
199
+
200
+ ### Major Changes
201
+
202
+ - 3d9a50c: feat(harness): implement harness adapters for Claude Code, Codex, Pi
203
+
204
+ ### Patch Changes
205
+
206
+ - e5d4a24: chore(harness): update ws package
207
+ - bc77265: chore(harness): enforce more structural conventions in harness adapters
208
+ - aae0138: fix(harness): make listening for sandbox bridge readiness compatible with Bun
209
+ - 1ea15a3: fix(harness): fix various bugs with harness skills not being correctly processed by the harness adapters
210
+ - b8396f0: trigger initial beta release
211
+ - e551763: fix(harness): avoid using peer dependencies for underlying harness and sandbox SDKs
212
+ - 534dac6: fix(harness): fix incomplete OIDC token support for AI Gateway auth in harness adapters
213
+
214
+ ## 1.0.0-beta.24
215
+
216
+ ### Patch Changes
217
+
218
+ - @ai-sdk/harness@1.0.0-beta.27
219
+
220
+ ## 1.0.0-beta.23
221
+
222
+ ### Patch Changes
223
+
224
+ - Updated dependencies [a83a367]
225
+ - @ai-sdk/harness@1.0.0-beta.26
226
+
227
+ ## 1.0.0-beta.22
228
+
229
+ ### Patch Changes
230
+
231
+ - @ai-sdk/harness@1.0.0-beta.25
232
+
233
+ ## 1.0.0-beta.21
234
+
235
+ ### Patch Changes
236
+
237
+ - @ai-sdk/harness@1.0.0-beta.24
238
+
239
+ ## 1.0.0-beta.20
240
+
241
+ ### Patch Changes
242
+
243
+ - Updated dependencies [57e0a59]
244
+ - @ai-sdk/harness@1.0.0-beta.23
245
+
246
+ ## 1.0.0-beta.19
247
+
248
+ ### Patch Changes
249
+
250
+ - @ai-sdk/harness@1.0.0-beta.22
251
+ - @ai-sdk/provider-utils@5.0.0-beta.50
252
+
253
+ ## 1.0.0-beta.18
254
+
255
+ ### Patch Changes
256
+
257
+ - bc77265: chore(harness): enforce more structural conventions in harness adapters
258
+
259
+ ## 1.0.0-beta.17
260
+
261
+ ### Patch Changes
262
+
263
+ - @ai-sdk/harness@1.0.0-beta.21
264
+
265
+ ## 1.0.0-beta.16
266
+
267
+ ### Patch Changes
268
+
269
+ - e5d4a24: chore(harness): update ws package
270
+ - Updated dependencies [e5d4a24]
271
+ - @ai-sdk/harness@1.0.0-beta.20
272
+
273
+ ## 1.0.0-beta.15
274
+
275
+ ### Patch Changes
276
+
277
+ - @ai-sdk/harness@1.0.0-beta.19
278
+
279
+ ## 1.0.0-beta.14
280
+
281
+ ### Patch Changes
282
+
283
+ - @ai-sdk/harness@1.0.0-beta.18
284
+
285
+ ## 1.0.0-beta.13
286
+
287
+ ### Patch Changes
288
+
289
+ - 534dac6: fix(harness): fix incomplete OIDC token support for AI Gateway auth in harness adapters
290
+ - Updated dependencies [534dac6]
291
+ - @ai-sdk/harness@1.0.0-beta.17
292
+
293
+ ## 1.0.0-beta.12
294
+
295
+ ### Patch Changes
296
+
297
+ - @ai-sdk/harness@1.0.0-beta.16
298
+
299
+ ## 1.0.0-beta.11
300
+
301
+ ### Patch Changes
302
+
303
+ - @ai-sdk/harness@1.0.0-beta.15
304
+
305
+ ## 1.0.0-beta.10
306
+
307
+ ### Patch Changes
308
+
309
+ - b8396f0: trigger initial beta release
310
+ - Updated dependencies [b8396f0]
311
+ - @ai-sdk/harness@1.0.0-beta.14
312
+ - @ai-sdk/provider-utils@5.0.0-beta.49
313
+
314
+ ## 1.0.0-canary.9
315
+
316
+ ### Patch Changes
317
+
318
+ - @ai-sdk/harness@1.0.0-canary.13
319
+
320
+ ## 1.0.0-canary.8
321
+
322
+ ### Patch Changes
323
+
324
+ - @ai-sdk/harness@1.0.0-canary.12
325
+
326
+ ## 1.0.0-canary.7
327
+
328
+ ### Patch Changes
329
+
330
+ - Updated dependencies [be83911]
331
+ - @ai-sdk/harness@1.0.0-canary.11
332
+
333
+ ## 1.0.0-canary.6
334
+
335
+ ### Patch Changes
336
+
337
+ - @ai-sdk/harness@1.0.0-canary.10
338
+
339
+ ## 1.0.0-canary.5
340
+
341
+ ### Patch Changes
342
+
343
+ - @ai-sdk/harness@1.0.0-canary.9
344
+
345
+ ## 1.0.0-canary.4
346
+
347
+ ### Patch Changes
348
+
349
+ - aae0138: fix(harness): make listening for sandbox bridge readiness compatible with Bun
350
+ - Updated dependencies [aae0138]
351
+ - @ai-sdk/harness@1.0.0-canary.8
352
+
353
+ ## 1.0.0-canary.3
354
+
355
+ ### Patch Changes
356
+
357
+ - 1ea15a3: fix(harness): fix various bugs with harness skills not being correctly processed by the harness adapters
358
+ - e551763: fix(harness): avoid using peer dependencies for underlying harness and sandbox SDKs
359
+ - Updated dependencies [3d87086]
360
+ - Updated dependencies [aeda373]
361
+ - Updated dependencies [1ea15a3]
362
+ - Updated dependencies [375fdd7]
363
+ - Updated dependencies [b4507d5]
364
+ - @ai-sdk/harness@1.0.0-canary.7
365
+ - @ai-sdk/provider-utils@5.0.0-canary.48
366
+
367
+ ## 1.0.0-canary.2
368
+
369
+ ### Patch Changes
370
+
371
+ - @ai-sdk/harness@1.0.0-canary.6
372
+
373
+ ## 1.0.0-canary.1
374
+
375
+ ### Patch Changes
376
+
377
+ - Updated dependencies [d77bed4]
378
+ - Updated dependencies [bae5e2b]
379
+ - @ai-sdk/harness@1.0.0-canary.5
380
+ - @ai-sdk/provider-utils@5.0.0-canary.47
381
+
382
+ ## 1.0.0-canary.0
383
+
384
+ ### Major Changes
385
+
386
+ - 3d9a50c: feat(harness): implement harness adapters for Claude Code, Codex, Pi
387
+
388
+ ### Patch Changes
389
+
390
+ - Updated dependencies [3d9a50c]
391
+ - @ai-sdk/harness@1.0.0-canary.4
package/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2023 Vercel, Inc.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # AI SDK - Codex Harness
2
+
3
+ `HarnessV1` adapter backed by [`@openai/codex-sdk`](https://www.npmjs.com/package/@openai/codex-sdk), which drives the `codex` CLI. The adapter ships a bridge process that runs inside a sandbox and talks to the host over a WebSocket on a sandbox-proxied loopback port.
4
+
5
+ ## Setup
6
+
7
+ ```bash
8
+ npm i @ai-sdk/harness-codex @ai-sdk/harness @ai-sdk/sandbox-vercel
9
+ ```
10
+
11
+ The bridge installs `@openai/codex-sdk` (and the `codex` CLI it depends on) inside the sandbox the first time the session starts.
12
+
13
+ ## Usage
14
+
15
+ ```ts
16
+ import { HarnessAgent } from '@ai-sdk/harness/agent';
17
+ import { createCodex } from '@ai-sdk/harness-codex';
18
+ import { createVercelSandbox } from '@ai-sdk/sandbox-vercel';
19
+ import { tool } from 'ai';
20
+ import { z } from 'zod/v4';
21
+
22
+ const agent = new HarnessAgent({
23
+ harness: createCodex(),
24
+ id: 'demo',
25
+ sandbox: createVercelSandbox({
26
+ runtime: 'node24',
27
+ ports: [4000],
28
+ }),
29
+ tools: {
30
+ deploy: tool({
31
+ description: 'Deploy a service.',
32
+ inputSchema: z.object({ env: z.enum(['staging', 'production']) }),
33
+ execute: async ({ env }) => ({ url: `https://${env}.example.com` }),
34
+ }),
35
+ },
36
+ harnessOptions: {
37
+ codex: { reasoningEffort: 'high' },
38
+ },
39
+ });
40
+ ```
41
+
42
+ > Codex does not auto-discover a skills directory the way the `claude` CLI
43
+ > does, so when you supply `skills: [...]` on the factory the adapter
44
+ > injects every skill inline into the user prompt on each turn. Use fewer,
45
+ > larger skills rather than many tiny ones.
46
+
47
+ ```ts
48
+ const agent = new HarnessAgent({
49
+ harness: createCodex({
50
+ skills: [
51
+ { name: 'haiku-mode', description: 'Answer in haikus.', content: '...' },
52
+ ],
53
+ }),
54
+ sandbox: createVercelSandbox({
55
+ runtime: 'node24',
56
+ ports: [4000],
57
+ }),
58
+ });
59
+
60
+ const session = await agent.createSession();
61
+
62
+ try {
63
+ const result = await agent.generate({
64
+ session,
65
+ prompt: 'List the files in this workspace and describe their purpose.',
66
+ });
67
+ console.log(result.text);
68
+ } finally {
69
+ await session.destroy();
70
+ }
71
+ ```
72
+
73
+ The adapter requires a `HarnessV1SandboxProvider` whose handles expose at least one port — `@ai-sdk/sandbox-vercel` is the supported choice today. The agent calls `provider.createSession()` when a session starts. Use `session.detach()` to park the bridge and sandbox, `session.stop()` to save state and stop the sandbox, or `session.destroy()` to clean up without keeping resume state.
@@ -0,0 +1,103 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/bridge/host-tool-mcp.ts
4
+ import * as mcpServerModule from "@modelcontextprotocol/sdk/server/mcp.js";
5
+ import * as mcpStdioModule from "@modelcontextprotocol/sdk/server/stdio.js";
6
+ import { z } from "zod/v4";
7
+ var { McpServer } = mcpServerModule;
8
+ var { StdioServerTransport } = mcpStdioModule;
9
+ var schemas = JSON.parse(process.env.TOOL_SCHEMAS || "[]");
10
+ var relayUrl = process.env.TOOL_RELAY_URL || "";
11
+ if (!schemas.length || !relayUrl) {
12
+ process.stderr.write(
13
+ "[host-tool-mcp] Missing TOOL_SCHEMAS or TOOL_RELAY_URL; exiting\n"
14
+ );
15
+ process.exit(0);
16
+ }
17
+ var server = new McpServer({ name: "harness-tools", version: "1.0.0" });
18
+ for (const schema of schemas) {
19
+ const shape = toZodShape(schema.inputSchema);
20
+ server.tool(
21
+ schema.name,
22
+ schema.description ?? "",
23
+ shape,
24
+ async (input) => {
25
+ const requestId = crypto.randomUUID();
26
+ try {
27
+ const res = await fetch(relayUrl, {
28
+ method: "POST",
29
+ headers: {
30
+ "Content-Type": "application/json"
31
+ },
32
+ body: JSON.stringify({ requestId, toolName: schema.name, input })
33
+ });
34
+ if (!res.ok) {
35
+ const body = await res.text();
36
+ throw new Error(
37
+ `Tool relay ${schema.name} failed with ${res.status}: ${body.slice(0, 500)}`
38
+ );
39
+ }
40
+ const data = await res.json();
41
+ return {
42
+ content: [
43
+ {
44
+ type: "text",
45
+ text: JSON.stringify(data.result ?? null)
46
+ }
47
+ ]
48
+ };
49
+ } catch (err) {
50
+ return {
51
+ content: [{ type: "text", text: `Error: ${String(err)}` }],
52
+ isError: true
53
+ };
54
+ }
55
+ }
56
+ );
57
+ }
58
+ function toZodShape(schema) {
59
+ if (!schema?.properties) return {};
60
+ const required = new Set(schema.required ?? []);
61
+ const shape = {};
62
+ for (const [key, propSchema] of Object.entries(schema.properties)) {
63
+ const propType = toZodType(propSchema);
64
+ shape[key] = required.has(key) ? propType : propType.optional();
65
+ }
66
+ return shape;
67
+ }
68
+ function toZodType(schema) {
69
+ if (!schema) return z.any();
70
+ const types = Array.isArray(schema.type) ? schema.type.filter((t) => t !== "null") : [schema.type].filter(Boolean);
71
+ let zType;
72
+ switch (types[0]) {
73
+ case "string":
74
+ zType = z.string();
75
+ break;
76
+ case "number":
77
+ zType = z.number();
78
+ break;
79
+ case "integer":
80
+ zType = z.number().int();
81
+ break;
82
+ case "boolean":
83
+ zType = z.boolean();
84
+ break;
85
+ case "array":
86
+ zType = z.array(toZodType(schema.items));
87
+ break;
88
+ case "object":
89
+ zType = z.object(toZodShape(schema));
90
+ break;
91
+ case "null":
92
+ zType = z.null();
93
+ break;
94
+ default:
95
+ zType = z.any();
96
+ }
97
+ if (schema.description) zType = zType.describe(schema.description);
98
+ if (schema.nullable) zType = zType.nullable();
99
+ return zType;
100
+ }
101
+ var transport = new StdioServerTransport();
102
+ await server.connect(transport);
103
+ //# sourceMappingURL=host-tool-mcp.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/bridge/host-tool-mcp.ts"],"sourcesContent":["#!/usr/bin/env node\n// MCP-stdio tool server spawned by the codex CLI when\n// `mcp_servers.harness-tools` is configured. Exposes host-defined tools\n// over MCP-stdio and round-trips each call to the bridge's HTTP relay.\n//\n// Env vars (set by the bridge when starting a turn):\n// TOOL_SCHEMAS — JSON array of { name, description, inputSchema }\n// TOOL_RELAY_URL — http://127.0.0.1:<port> of the bridge relay server\n// Relay authorization is issued by bridge runtime events, not an env token.\n\n/*\n * CONSTRAINT — the third-party imports below are NEVER bundled into the\n * compiled `bridge/host-tool-mcp.mjs`. They are declared `external` in\n * tsup.config.ts and resolved at runtime from the node_modules that the\n * bridge installs *inside the sandbox* from `src/bridge/package.json` (and\n * its pinned `pnpm-lock.yaml`). That bridge package.json — NOT this host\n * package — is the single source of truth for these packages and their\n * versions; the published `@ai-sdk/harness-codex` package does not provide\n * them at runtime.\n *\n * When adding or changing a third-party import here you MUST keep all three\n * in sync, or this server will either get the dependency bundled in or fail\n * to resolve it in the sandbox:\n * 1. the import statement below,\n * 2. the `external` array in tsup.config.ts, and\n * 3. the dependency entry in `src/bridge/package.json`.\n */\nimport * as mcpServerModule from '@modelcontextprotocol/sdk/server/mcp.js';\nimport * as mcpStdioModule from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { z } from 'zod/v4';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst { McpServer } = mcpServerModule as any;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst { StdioServerTransport } = mcpStdioModule as any;\n\ntype ToolSchema = {\n name: string;\n description?: string;\n inputSchema?: JsonSchemaObject;\n};\n\ntype JsonSchemaObject = {\n type?: string | string[];\n description?: string;\n properties?: Record<string, JsonSchemaObject>;\n required?: string[];\n items?: JsonSchemaObject;\n enum?: unknown[];\n const?: unknown;\n oneOf?: JsonSchemaObject[];\n anyOf?: JsonSchemaObject[];\n additionalProperties?: boolean | JsonSchemaObject;\n nullable?: boolean;\n};\n\nconst schemas: ToolSchema[] = JSON.parse(process.env.TOOL_SCHEMAS || '[]');\nconst relayUrl = process.env.TOOL_RELAY_URL || '';\n\nif (!schemas.length || !relayUrl) {\n process.stderr.write(\n '[host-tool-mcp] Missing TOOL_SCHEMAS or TOOL_RELAY_URL; exiting\\n',\n );\n process.exit(0);\n}\n\nconst server = new McpServer({ name: 'harness-tools', version: '1.0.0' });\n\nfor (const schema of schemas) {\n const shape = toZodShape(schema.inputSchema);\n server.tool(\n schema.name,\n schema.description ?? '',\n shape,\n async (input: Record<string, unknown>) => {\n const requestId = crypto.randomUUID();\n try {\n const res = await fetch(relayUrl, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({ requestId, toolName: schema.name, input }),\n });\n if (!res.ok) {\n const body = await res.text();\n throw new Error(\n `Tool relay ${schema.name} failed with ${res.status}: ${body.slice(0, 500)}`,\n );\n }\n const data = (await res.json()) as { result?: unknown };\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(data.result ?? null),\n },\n ],\n };\n } catch (err) {\n return {\n content: [{ type: 'text' as const, text: `Error: ${String(err)}` }],\n isError: true,\n };\n }\n },\n );\n}\n\nfunction toZodShape(\n schema: JsonSchemaObject | undefined,\n): Record<string, z.ZodTypeAny> {\n if (!schema?.properties) return {};\n const required = new Set(schema.required ?? []);\n const shape: Record<string, z.ZodTypeAny> = {};\n for (const [key, propSchema] of Object.entries(schema.properties)) {\n const propType = toZodType(propSchema);\n shape[key] = required.has(key) ? propType : propType.optional();\n }\n return shape;\n}\n\nfunction toZodType(schema: JsonSchemaObject | undefined): z.ZodTypeAny {\n if (!schema) return z.any();\n const types = Array.isArray(schema.type)\n ? schema.type.filter((t): t is string => t !== 'null')\n : ([schema.type].filter(Boolean) as string[]);\n let zType: z.ZodTypeAny;\n switch (types[0]) {\n case 'string':\n zType = z.string();\n break;\n case 'number':\n zType = z.number();\n break;\n case 'integer':\n zType = z.number().int();\n break;\n case 'boolean':\n zType = z.boolean();\n break;\n case 'array':\n zType = z.array(toZodType(schema.items));\n break;\n case 'object':\n zType = z.object(toZodShape(schema));\n break;\n case 'null':\n zType = z.null();\n break;\n default:\n zType = z.any();\n }\n if (schema.description) zType = zType.describe(schema.description);\n if (schema.nullable) zType = zType.nullable();\n return zType;\n}\n\nconst transport = new StdioServerTransport();\nawait server.connect(transport);\n"],"mappings":";;;AA2BA,YAAY,qBAAqB;AACjC,YAAY,oBAAoB;AAChC,SAAS,SAAS;AAGlB,IAAM,EAAE,UAAU,IAAI;AAEtB,IAAM,EAAE,qBAAqB,IAAI;AAsBjC,IAAM,UAAwB,KAAK,MAAM,QAAQ,IAAI,gBAAgB,IAAI;AACzE,IAAM,WAAW,QAAQ,IAAI,kBAAkB;AAE/C,IAAI,CAAC,QAAQ,UAAU,CAAC,UAAU;AAChC,UAAQ,OAAO;AAAA,IACb;AAAA,EACF;AACA,UAAQ,KAAK,CAAC;AAChB;AAEA,IAAM,SAAS,IAAI,UAAU,EAAE,MAAM,iBAAiB,SAAS,QAAQ,CAAC;AAExE,WAAW,UAAU,SAAS;AAC5B,QAAM,QAAQ,WAAW,OAAO,WAAW;AAC3C,SAA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