summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDax Raad <[email protected]>2025-06-12 23:50:26 -0400
committerDax Raad <[email protected]>2025-06-12 23:50:26 -0400
commitf03637b1fc433fd2e4d0361fd81a28e7135fb83a (patch)
tree2adf7cdafae26d14411aff3ff3b12b1c468d1d06
parent2c376c5abc764d99ebb62742c6f427c6cf6fbe4d (diff)
downloadopencode-f03637b1fc433fd2e4d0361fd81a28e7135fb83a.tar.gz
opencode-f03637b1fc433fd2e4d0361fd81a28e7135fb83a.zip
Refactor AI SDK provider loading to use BunProc.install
Simplifies provider installation by using BunProc.install() instead of manual path construction and file system checks. 🤖 Generated with [OpenCode](https://opencode.ai) Co-Authored-By: OpenCode <[email protected]>
-rw-r--r--packages/opencode/src/provider/provider.ts16
1 files changed, 2 insertions, 14 deletions
diff --git a/packages/opencode/src/provider/provider.ts b/packages/opencode/src/provider/provider.ts
index a2bdfd5cc..bd1d9d99a 100644
--- a/packages/opencode/src/provider/provider.ts
+++ b/packages/opencode/src/provider/provider.ts
@@ -181,21 +181,9 @@ export namespace Provider {
const s = await state()
const existing = s.sdk.get(providerID)
if (existing) return existing
- const dir = path.join(
- Global.Path.cache,
- `node_modules`,
- `@ai-sdk`,
- providerID,
+ const mod = await import(
+ await BunProc.install(`@ai-sdk/${providerID}`, "alpha")
)
- if (!(await Bun.file(path.join(dir, "package.json")).exists())) {
- log.info("installing", {
- providerID,
- })
- await BunProc.run(["add", `@ai-sdk/${providerID}@alpha`], {
- cwd: Global.Path.cache,
- })
- }
- const mod = await import(path.join(dir))
const fn = mod[Object.keys(mod).find((key) => key.startsWith("create"))!]
const loaded = fn(s.providers[providerID]?.options)
s.sdk.set(providerID, loaded)