@ai-sdk/harness-opencode 0.0.0-07500555-20260730161446

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,322 @@
1
+ # @ai-sdk/harness-opencode
2
+
3
+ ## 0.0.0-07500555-20260730161446
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [5f65e61]
8
+ - @ai-sdk/harness@0.0.0-07500555-20260730161446
9
+ - @ai-sdk/provider-utils@0.0.0-07500555-20260730161446
10
+
11
+ ## 1.0.40
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [86a84c9]
16
+ - @ai-sdk/harness@1.0.39
17
+
18
+ ## 1.0.39
19
+
20
+ ### Patch Changes
21
+
22
+ - f5cdb2d: chore(harness): update primary SDK dependencies
23
+ - Updated dependencies [02ffdcb]
24
+ - Updated dependencies [76cb673]
25
+ - @ai-sdk/provider-utils@5.0.12
26
+ - @ai-sdk/harness@1.0.38
27
+
28
+ ## 1.0.38
29
+
30
+ ### Patch Changes
31
+
32
+ - ab7f97a: fix(harness-opencode): route OpenCode reasoning deltas to the reasoning part instead of duplicating them as text
33
+ - Updated dependencies [b460541]
34
+ - Updated dependencies [079591e]
35
+ - @ai-sdk/harness@1.0.37
36
+
37
+ ## 1.0.37
38
+
39
+ ### Patch Changes
40
+
41
+ - Updated dependencies [cd06458]
42
+ - @ai-sdk/provider-utils@5.0.11
43
+ - @ai-sdk/harness@1.0.36
44
+
45
+ ## 1.0.36
46
+
47
+ ### Patch Changes
48
+
49
+ - @ai-sdk/harness@1.0.35
50
+
51
+ ## 1.0.35
52
+
53
+ ### Patch Changes
54
+
55
+ - @ai-sdk/harness@1.0.34
56
+
57
+ ## 1.0.34
58
+
59
+ ### Patch Changes
60
+
61
+ - @ai-sdk/harness@1.0.33
62
+
63
+ ## 1.0.33
64
+
65
+ ### Patch Changes
66
+
67
+ - Updated dependencies [31c7be8]
68
+ - @ai-sdk/provider-utils@5.0.10
69
+ - @ai-sdk/harness@1.0.32
70
+
71
+ ## 1.0.32
72
+
73
+ ### Patch Changes
74
+
75
+ - @ai-sdk/harness@1.0.31
76
+
77
+ ## 1.0.31
78
+
79
+ ### Patch Changes
80
+
81
+ - Updated dependencies [4be62c1]
82
+ - Updated dependencies [7805e4a]
83
+ - Updated dependencies [cd12954]
84
+ - @ai-sdk/provider-utils@5.0.9
85
+ - @ai-sdk/harness@1.0.30
86
+
87
+ ## 1.0.30
88
+
89
+ ### Patch Changes
90
+
91
+ - Updated dependencies [e193290]
92
+ - @ai-sdk/provider-utils@5.0.8
93
+ - @ai-sdk/harness@1.0.29
94
+
95
+ ## 1.0.29
96
+
97
+ ### Patch Changes
98
+
99
+ - @ai-sdk/harness@1.0.28
100
+
101
+ ## 1.0.28
102
+
103
+ ### Patch Changes
104
+
105
+ - c93803d: fix(harness): improve CLI relay tool invocation logic
106
+
107
+ ## 1.0.27
108
+
109
+ ### Patch Changes
110
+
111
+ - @ai-sdk/harness@1.0.27
112
+
113
+ ## 1.0.26
114
+
115
+ ### Patch Changes
116
+
117
+ - @ai-sdk/harness@1.0.26
118
+
119
+ ## 1.0.25
120
+
121
+ ### Patch Changes
122
+
123
+ - 79fa6bc: fix(harness-opencode): fix OpenCode hitting `undici` headers timeout during long turns
124
+ - Updated dependencies [44e988a]
125
+ - @ai-sdk/harness@1.0.25
126
+
127
+ ## 1.0.24
128
+
129
+ ### Patch Changes
130
+
131
+ - @ai-sdk/harness@1.0.24
132
+
133
+ ## 1.0.23
134
+
135
+ ### Patch Changes
136
+
137
+ - 39c8276: fix(harness): improve opaque sandbox bridge error handling
138
+ - 91fe6d8: fix(harness): emit `finish-step` stream parts correctly per the underlying model steps
139
+ - Updated dependencies [39c8276]
140
+ - Updated dependencies [91fe6d8]
141
+ - Updated dependencies [0be5014]
142
+ - @ai-sdk/harness@1.0.23
143
+
144
+ ## 1.0.22
145
+
146
+ ### Patch Changes
147
+
148
+ - @ai-sdk/harness@1.0.22
149
+ - @ai-sdk/provider-utils@5.0.7
150
+
151
+ ## 1.0.21
152
+
153
+ ### Patch Changes
154
+
155
+ - Updated dependencies [ac306ed]
156
+ - @ai-sdk/provider-utils@5.0.6
157
+ - @ai-sdk/harness@1.0.21
158
+
159
+ ## 1.0.20
160
+
161
+ ### Patch Changes
162
+
163
+ - b2d0306: feat(harness): send `User-Agent` and `x-client-app` headers in harness adapters
164
+ - Updated dependencies [b7aa06a]
165
+ - @ai-sdk/harness@1.0.20
166
+
167
+ ## 1.0.19
168
+
169
+ ### Patch Changes
170
+
171
+ - @ai-sdk/harness@1.0.19
172
+
173
+ ## 1.0.18
174
+
175
+ ### Patch Changes
176
+
177
+ - @ai-sdk/harness@1.0.18
178
+
179
+ ## 1.0.17
180
+
181
+ ### Patch Changes
182
+
183
+ - Updated dependencies [5c5c0f5]
184
+ - @ai-sdk/provider-utils@5.0.5
185
+ - @ai-sdk/harness@1.0.17
186
+
187
+ ## 1.0.16
188
+
189
+ ### Patch Changes
190
+
191
+ - @ai-sdk/harness@1.0.16
192
+
193
+ ## 1.0.15
194
+
195
+ ### Patch Changes
196
+
197
+ - Updated dependencies [c6f5e62]
198
+ - @ai-sdk/provider-utils@5.0.4
199
+ - @ai-sdk/harness@1.0.15
200
+
201
+ ## 1.0.14
202
+
203
+ ### Patch Changes
204
+
205
+ - @ai-sdk/harness@1.0.14
206
+
207
+ ## 1.0.13
208
+
209
+ ### Patch Changes
210
+
211
+ - Updated dependencies [8c616f0]
212
+ - @ai-sdk/provider-utils@5.0.3
213
+ - @ai-sdk/harness@1.0.13
214
+
215
+ ## 1.0.12
216
+
217
+ ### Patch Changes
218
+
219
+ - 7859cea: feat(harness): add tool filtering via `activeTools` and `inactiveTools`
220
+ - c857346: feat(harness): add utility functions for certain duplicated layers in harnesses
221
+ - Updated dependencies [7859cea]
222
+ - Updated dependencies [c857346]
223
+ - @ai-sdk/harness@1.0.12
224
+
225
+ ## 1.0.11
226
+
227
+ ### Patch Changes
228
+
229
+ - 2933383: fix(harness): fix harness relay auth
230
+ - @ai-sdk/harness@1.0.11
231
+
232
+ ## 1.0.10
233
+
234
+ ### Patch Changes
235
+
236
+ - @ai-sdk/harness@1.0.10
237
+ - @ai-sdk/provider-utils@5.0.2
238
+
239
+ ## 1.0.9
240
+
241
+ ### Patch Changes
242
+
243
+ - @ai-sdk/harness@1.0.9
244
+
245
+ ## 1.0.8
246
+
247
+ ### Patch Changes
248
+
249
+ - @ai-sdk/harness@1.0.8
250
+
251
+ ## 1.0.7
252
+
253
+ ### Patch Changes
254
+
255
+ - @ai-sdk/harness@1.0.7
256
+
257
+ ## 1.0.6
258
+
259
+ ### Patch Changes
260
+
261
+ - Updated dependencies [6a436e3]
262
+ - @ai-sdk/provider-utils@5.0.1
263
+ - @ai-sdk/harness@1.0.6
264
+
265
+ ## 1.0.5
266
+
267
+ ### Patch Changes
268
+
269
+ - ba6d510: chore: fix deprecated use of zod `.passthrough()`
270
+ - @ai-sdk/harness@1.0.5
271
+
272
+ ## 1.0.4
273
+
274
+ ### Patch Changes
275
+
276
+ - c493634: fix(harness): fix harness Zod usage to be v3/v4 compatible
277
+ - Updated dependencies [c493634]
278
+ - @ai-sdk/harness@1.0.4
279
+
280
+ ## 1.0.3
281
+
282
+ ### Patch Changes
283
+
284
+ - Updated dependencies [51d10a0]
285
+ - @ai-sdk/harness@1.0.3
286
+
287
+ ## 1.0.2
288
+
289
+ ### Patch Changes
290
+
291
+ - @ai-sdk/harness@1.0.2
292
+
293
+ ## 1.0.1
294
+
295
+ ### Patch Changes
296
+
297
+ - @ai-sdk/harness@1.0.1
298
+
299
+ ## 1.0.0
300
+
301
+ ### Major Changes
302
+
303
+ - 34158ac: feat(harness-opencode): implement harness adapter for OpenCode
304
+
305
+ ### Patch Changes
306
+
307
+ ## 1.0.0-beta.1
308
+
309
+ ### Patch Changes
310
+
311
+ - @ai-sdk/harness@1.0.0-beta.27
312
+
313
+ ## 1.0.0-beta.0
314
+
315
+ ### Major Changes
316
+
317
+ - 34158ac: feat(harness-opencode): implement harness adapter for OpenCode
318
+
319
+ ### Patch Changes
320
+
321
+ - Updated dependencies [a83a367]
322
+ - @ai-sdk/harness@1.0.0-beta.26
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,6 @@
1
+ # AI SDK OpenCode Harness
2
+
3
+ The OpenCode harness connects `HarnessAgent` to OpenCode through a sandboxed
4
+ bridge.
5
+
6
+ See the AI SDK documentation for usage.
@@ -0,0 +1,101 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/bridge/host-tool-mcp.ts
4
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
5
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
6
+ import { z } from "zod/v4";
7
+ var schemas = JSON.parse(process.env.TOOL_SCHEMAS || "[]");
8
+ var relayUrl = process.env.TOOL_RELAY_URL || "";
9
+ if (!schemas.length || !relayUrl) {
10
+ process.stderr.write(
11
+ "[host-tool-mcp] Missing TOOL_SCHEMAS or TOOL_RELAY_URL; exiting\n"
12
+ );
13
+ process.exit(0);
14
+ }
15
+ var server = new McpServer({ name: "harness-tools", version: "1.0.0" });
16
+ for (const schema of schemas) {
17
+ const shape = toZodShape(schema.inputSchema);
18
+ server.tool(
19
+ schema.name,
20
+ schema.description ?? "",
21
+ shape,
22
+ async (input) => {
23
+ const requestId = crypto.randomUUID();
24
+ try {
25
+ const res = await fetch(relayUrl, {
26
+ method: "POST",
27
+ headers: {
28
+ "Content-Type": "application/json"
29
+ },
30
+ body: JSON.stringify({ requestId, toolName: schema.name, input })
31
+ });
32
+ if (!res.ok) {
33
+ const body = await res.text();
34
+ throw new Error(
35
+ `Tool relay ${schema.name} failed with ${res.status}: ${body.slice(0, 500)}`
36
+ );
37
+ }
38
+ const data = await res.json();
39
+ return {
40
+ content: [
41
+ {
42
+ type: "text",
43
+ text: JSON.stringify(data.result ?? null)
44
+ }
45
+ ]
46
+ };
47
+ } catch (err) {
48
+ return {
49
+ content: [{ type: "text", text: `Error: ${String(err)}` }],
50
+ isError: true
51
+ };
52
+ }
53
+ }
54
+ );
55
+ }
56
+ function toZodShape(schema) {
57
+ if (!schema?.properties) return {};
58
+ const required = new Set(schema.required ?? []);
59
+ const shape = {};
60
+ for (const [key, propSchema] of Object.entries(schema.properties)) {
61
+ const propType = toZodType(propSchema);
62
+ shape[key] = required.has(key) ? propType : propType.optional();
63
+ }
64
+ return shape;
65
+ }
66
+ function toZodType(schema) {
67
+ if (!schema) return z.any();
68
+ const types = Array.isArray(schema.type) ? schema.type.filter((t) => t !== "null") : [schema.type].filter(Boolean);
69
+ let zType;
70
+ switch (types[0]) {
71
+ case "string":
72
+ zType = z.string();
73
+ break;
74
+ case "number":
75
+ zType = z.number();
76
+ break;
77
+ case "integer":
78
+ zType = z.number().int();
79
+ break;
80
+ case "boolean":
81
+ zType = z.boolean();
82
+ break;
83
+ case "array":
84
+ zType = z.array(toZodType(schema.items));
85
+ break;
86
+ case "object":
87
+ zType = z.object(toZodShape(schema));
88
+ break;
89
+ case "null":
90
+ zType = z.null();
91
+ break;
92
+ default:
93
+ zType = z.any();
94
+ }
95
+ if (schema.description) zType = zType.describe(schema.description);
96
+ if (schema.nullable) zType = zType.nullable();
97
+ return zType;
98
+ }
99
+ var transport = new StdioServerTransport();
100
+ await server.connect(transport);
101
+ //# 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/*\n * These bridge imports are externalized by tsup and resolved inside the\n * sandbox from src/bridge/package.json and its lockfile. Keep this file,\n * tsup.config.ts, and the bridge package dependency list in sync.\n */\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { z } from 'zod/v4';\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\ntype ZodShape = Record<string, z.ZodTypeAny>;\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(schema: JsonSchemaObject | undefined): ZodShape {\n if (!schema?.properties) return {};\n const required = new Set(schema.required ?? []);\n const shape: ZodShape = {};\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":";;;AAMA,SAAS,iBAAiB;AAC1B,SAAS,4BAA4B;AACrC,SAAS,SAAS;AAwBlB,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,SAAO;AAAA,IACL,OAAO;AAAA,IACP,OAAO,eAAe;AAAA,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