Skip to content
Open
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
12 changes: 10 additions & 2 deletions packages/opencode/src/plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,18 @@ export namespace Plugin {
const BUILTIN = ["[email protected]", "[email protected]"]

const state = Instance.state(async () => {
const localFetch = Object.assign(
async (input: RequestInfo | URL, init?: RequestInit) => {
const request = input instanceof Request ? input : new Request(input, init)
return Server.App().fetch(request)
},
// Bun's fetch includes a preconnect helper; mirror it to satisfy the expected type.
{ preconnect: fetch.preconnect?.bind(fetch) },
) as typeof fetch

const client = createOpencodeClient({
baseUrl: "http://localhost:4096",
// @ts-ignore - fetch type incompatibility
fetch: async (...args) => Server.App().fetch(...args),
fetch: localFetch,
})
const config = await Config.get()
const hooks = []
Expand Down
2 changes: 1 addition & 1 deletion packages/opencode/src/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import { Installation } from "@/installation"
import { MDNS } from "./mdns"
import { Worktree } from "../worktree"

// @ts-ignore This global is needed to prevent ai-sdk from logging warnings to stdout https://github.com/vercel/ai/blob/2dc67e0ef538307f21368db32d5a12345d98831b/packages/ai/src/logger/log-warnings.ts#L85
// Prevent ai-sdk from logging warnings to stdout https://github.com/vercel/ai/blob/2dc67e0ef538307f21368db32d5a12345d98831b/packages/ai/src/logger/log-warnings.ts#L85
globalThis.AI_SDK_LOG_WARNINGS = false

export namespace Server {
Expand Down
1 change: 0 additions & 1 deletion packages/opencode/src/session/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import { LLM } from "./llm"
import { iife } from "@/util/iife"
import { Shell } from "@/shell/shell"

// @ts-ignore
globalThis.AI_SDK_LOG_WARNINGS = false

export namespace SessionPrompt {
Expand Down
5 changes: 5 additions & 0 deletions packages/opencode/src/types/ai-sdk-log-warnings.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export {}

declare global {
var AI_SDK_LOG_WARNINGS: boolean | undefined
}