Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/opencode-2-2-1-carrier.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"agents": patch
---

`agents/models/opencode`: keep Cloudflare models working on OpenCode 2.2.1, which no longer bundles `@ai-sdk/vercel`; the provider now names `gitlab-ai-provider`, which every OpenCode release from 2.0.24 to 2.2.1 loads in-process. See [the OpenCode harness example](https://github.com/cloudflare/agents/blob/main/examples/next/harnesses/opencode/README.md#what-it-shows).
4 changes: 2 additions & 2 deletions examples/next/harnesses/opencode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"dependencies": {
"@cloudflare/computer": "^0.8.0",
"@cloudflare/kumo": "^2.6.0",
"@opencode/plugin": "2.0.24",
"@opencode/sdk": "2.0.24",
"@opencode/plugin": "2.2.1",
"@opencode/sdk": "2.2.1",
"@phosphor-icons/react": "^2.1.10",
"@streamdown/code": "^1.1.1",
"agents": "*",
Expand Down
2 changes: 1 addition & 1 deletion examples/next/harnesses/opencode/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default defineConfig({
name: "empty-httpapi-scalar",
enforce: "pre",
load: (id) =>
id.includes("/effect/dist/unstable/httpapi/internal/httpApiScalar.js")
id.includes("/effect/dist/http-api/internal/httpApiScalar.js")
? 'export const javascript = "";'
: null
},
Expand Down
4 changes: 2 additions & 2 deletions packages/agents/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
"@modelcontextprotocol/conformance-v2": "npm:@modelcontextprotocol/conformance@0.2.0-alpha.12",
"@modelcontextprotocol/sdk": "1.32.2",
"@modelcontextprotocol/server": "2.4.0",
"@opencode/plugin": "2.0.24",
"@opencode/sdk": "2.0.24",
"@opencode/plugin": "2.2.1",
"@opencode/sdk": "2.2.1",
"@tanstack/ai": "0.38.0",
"@types/react": "^19.2.17",
"@valibot/to-json-schema": "1.3.0",
Expand Down
18 changes: 17 additions & 1 deletion packages/agents/src/harness/opencode/tests/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,26 @@ export default defineConfig({
name: "empty-httpapi-scalar",
enforce: "pre",
load: (id) =>
id.includes("/effect/dist/unstable/httpapi/internal/httpApiScalar.js")
id.includes("/effect/dist/http-api/internal/httpApiScalar.js")
? 'export const javascript = "";'
: null
},
{
// OpenCode inlines models.dev's catalog as one 8 MB string, too large
// for the message that carries a module into the test runtime. These
// tests turn catalog fetches off and use only the Cloudflare provider,
// so an empty catalog stands in.
name: "empty-models-dev-snapshot",
enforce: "pre",
transform: (code, id) =>
id.includes("/@opencode/core/dist/") &&
code.includes("// src/models-dev/snapshot.txt")
? code.replace(
/(\/\/ src\/models-dev\/snapshot\.txt\nvar snapshot_default = )'.*';/,
"$1'{}';"
)
: null
},
stripNodeModulesSourceMapReferences(),
cloudflareTest({
wrangler: { configPath: path.join(testsDir, "wrangler.jsonc") }
Expand Down
10 changes: 6 additions & 4 deletions packages/agents/src/models/opencode/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,13 @@ export const CLOUDFLARE_PROVIDER_ID = "cloudflare";
* (make the model). Its `sdk` step can only load packages it bundles; any
* other is handed to an npm installer that cannot run in workerd, and an
* external plugin's `sdk` hook runs after that installer. So the provider
* names `@ai-sdk/vercel`, which OpenCode bundles and loads in-process, and
* this plugin's `language` hook replaces the model it would make. The
* Vercel client is built but never called: its base URL does not resolve.
* names `gitlab-ai-provider`, which OpenCode bundles and loads in-process
* for any provider that names it (OpenCode 2.2.1 stopped bundling
* `@ai-sdk/vercel`, the package used before), and this plugin's `language`
* hook replaces the model it would make. The GitLab client is built but
* never called.
*/
const CARRIER_PACKAGE = "aisdk:@ai-sdk/vercel";
const CARRIER_PACKAGE = "aisdk:gitlab-ai-provider";
const UNREACHABLE_BASE_URL = "https://workers-ai.binding.invalid/v1";

/**
Expand Down
Loading
Loading