Skip to content

Commit d8cbd3d

Browse files
committed
fix: restore builtin anthropic auth loading and update provider tool factories
1 parent 5b07c85 commit d8cbd3d

File tree

9 files changed

+67
-15
lines changed

9 files changed

+67
-15
lines changed

packages/opencode/src/plugin/index.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ export namespace Plugin {
6666

6767
const BUILTIN = ["op-anthropic-auth@0.0.2"]
6868

69+
export function plugins(list: Config.PluginSpec[] | undefined, pure: boolean) {
70+
if (pure) return []
71+
return Config.deduplicatePlugins([...BUILTIN, ...(list ?? [])])
72+
}
73+
6974
// Built-in plugins that are directly imported (not installed from npm)
7075
const INTERNAL_PLUGINS: PluginInstance[] = [CodexAuthPlugin, CopilotAuthPlugin, GitlabAuthPlugin, PoeAuthPlugin]
7176

@@ -228,9 +233,11 @@ export namespace Plugin {
228233
if (init._tag === "Some") hooks.push(init.value)
229234
}
230235

231-
const plugins = Flag.OPENCODE_PURE ? [] : (cfg.plugin ?? [])
232-
if (Flag.OPENCODE_PURE && cfg.plugin?.length) {
233-
log.info("skipping external plugins in pure mode", { count: cfg.plugin.length })
236+
const plugins = Plugin.plugins(cfg.plugin, Flag.OPENCODE_PURE)
237+
if (Flag.OPENCODE_PURE && (cfg.plugin?.length || BUILTIN.length)) {
238+
log.info("skipping external plugins in pure mode", {
239+
count: BUILTIN.length + (cfg.plugin?.length ?? 0),
240+
})
234241
}
235242
if (plugins.length) yield* config.waitForDependencies()
236243

packages/opencode/src/provider/sdk/copilot/responses/tool/code-interpreter.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createProviderToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils"
1+
import { createFactoryWithOutput } from "./factory"
22
import { z } from "zod/v4"
33

44
export const codeInterpreterInputSchema = z.object({
@@ -37,7 +37,7 @@ type CodeInterpreterArgs = {
3737
container?: string | { fileIds?: string[] }
3838
}
3939

40-
export const codeInterpreterToolFactory = createProviderToolFactoryWithOutputSchema<
40+
export const codeInterpreterToolFactory = createFactoryWithOutput<
4141
{
4242
/**
4343
* The code to run, or null if not available.
@@ -76,6 +76,7 @@ export const codeInterpreterToolFactory = createProviderToolFactoryWithOutputSch
7676
CodeInterpreterArgs
7777
>({
7878
id: "openai.code_interpreter",
79+
name: "code_interpreter",
7980
inputSchema: codeInterpreterInputSchema,
8081
outputSchema: codeInterpreterOutputSchema,
8182
})
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import * as util from "@ai-sdk/provider-utils"
2+
3+
export const createFactory =
4+
(
5+
util as typeof util & {
6+
createProviderToolFactory?: typeof util.createProviderDefinedToolFactory
7+
}
8+
).createProviderDefinedToolFactory ??
9+
(
10+
util as typeof util & {
11+
createProviderToolFactory?: typeof util.createProviderDefinedToolFactory
12+
}
13+
).createProviderToolFactory
14+
15+
export const createFactoryWithOutput =
16+
(
17+
util as typeof util & {
18+
createProviderToolFactoryWithOutputSchema?: typeof util.createProviderDefinedToolFactoryWithOutputSchema
19+
}
20+
).createProviderDefinedToolFactoryWithOutputSchema ??
21+
(
22+
util as typeof util & {
23+
createProviderToolFactoryWithOutputSchema?: typeof util.createProviderDefinedToolFactoryWithOutputSchema
24+
}
25+
).createProviderToolFactoryWithOutputSchema

packages/opencode/src/provider/sdk/copilot/responses/tool/file-search.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createProviderToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils"
1+
import { createFactoryWithOutput } from "./factory"
22
import type {
33
OpenAIResponsesFileSearchToolComparisonFilter,
44
OpenAIResponsesFileSearchToolCompoundFilter,
@@ -43,7 +43,7 @@ export const fileSearchOutputSchema = z.object({
4343
.nullable(),
4444
})
4545

46-
export const fileSearch = createProviderToolFactoryWithOutputSchema<
46+
export const fileSearch = createFactoryWithOutput<
4747
{},
4848
{
4949
/**
@@ -122,6 +122,7 @@ export const fileSearch = createProviderToolFactoryWithOutputSchema<
122122
}
123123
>({
124124
id: "openai.file_search",
125+
name: "file_search",
125126
inputSchema: z.object({}),
126127
outputSchema: fileSearchOutputSchema,
127128
})

packages/opencode/src/provider/sdk/copilot/responses/tool/image-generation.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createProviderToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils"
1+
import { createFactoryWithOutput } from "./factory"
22
import { z } from "zod/v4"
33

44
export const imageGenerationArgsSchema = z
@@ -92,7 +92,7 @@ type ImageGenerationArgs = {
9292
size?: "auto" | "1024x1024" | "1024x1536" | "1536x1024"
9393
}
9494

95-
const imageGenerationToolFactory = createProviderToolFactoryWithOutputSchema<
95+
const imageGenerationToolFactory = createFactoryWithOutput<
9696
{},
9797
{
9898
/**
@@ -103,6 +103,7 @@ const imageGenerationToolFactory = createProviderToolFactoryWithOutputSchema<
103103
ImageGenerationArgs
104104
>({
105105
id: "openai.image_generation",
106+
name: "image_generation",
106107
inputSchema: z.object({}),
107108
outputSchema: imageGenerationOutputSchema,
108109
})

packages/opencode/src/provider/sdk/copilot/responses/tool/local-shell.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createProviderToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils"
1+
import { createFactoryWithOutput } from "./factory"
22
import { z } from "zod/v4"
33

44
export const localShellInputSchema = z.object({
@@ -16,7 +16,7 @@ export const localShellOutputSchema = z.object({
1616
output: z.string(),
1717
})
1818

19-
export const localShell = createProviderToolFactoryWithOutputSchema<
19+
export const localShell = createFactoryWithOutput<
2020
{
2121
/**
2222
* Execute a shell command on the server.
@@ -59,6 +59,7 @@ export const localShell = createProviderToolFactoryWithOutputSchema<
5959
{}
6060
>({
6161
id: "openai.local_shell",
62+
name: "local_shell",
6263
inputSchema: localShellInputSchema,
6364
outputSchema: localShellOutputSchema,
6465
})

packages/opencode/src/provider/sdk/copilot/responses/tool/web-search-preview.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createProviderToolFactory } from "@ai-sdk/provider-utils"
1+
import { createFactory } from "./factory"
22
import { z } from "zod/v4"
33

44
// Args validation schema
@@ -40,7 +40,7 @@ export const webSearchPreviewArgsSchema = z.object({
4040
.optional(),
4141
})
4242

43-
export const webSearchPreview = createProviderToolFactory<
43+
export const webSearchPreview = createFactory<
4444
{
4545
// Web search doesn't take input parameters - it's controlled by the prompt
4646
},
@@ -81,6 +81,7 @@ export const webSearchPreview = createProviderToolFactory<
8181
}
8282
>({
8383
id: "openai.web_search_preview",
84+
name: "web_search_preview",
8485
inputSchema: z.object({
8586
action: z
8687
.discriminatedUnion("type", [

packages/opencode/src/provider/sdk/copilot/responses/tool/web-search.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createProviderToolFactory } from "@ai-sdk/provider-utils"
1+
import { createFactory } from "./factory"
22
import { z } from "zod/v4"
33

44
export const webSearchArgsSchema = z.object({
@@ -21,7 +21,7 @@ export const webSearchArgsSchema = z.object({
2121
.optional(),
2222
})
2323

24-
export const webSearchToolFactory = createProviderToolFactory<
24+
export const webSearchToolFactory = createFactory<
2525
{
2626
// Web search doesn't take input parameters - it's controlled by the prompt
2727
},
@@ -74,6 +74,7 @@ export const webSearchToolFactory = createProviderToolFactory<
7474
}
7575
>({
7676
id: "openai.web_search",
77+
name: "web_search",
7778
inputSchema: z.object({
7879
action: z
7980
.discriminatedUnion("type", [
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { describe, expect, test } from "bun:test"
2+
import path from "path"
3+
4+
const file = path.join(import.meta.dir, "../../src/plugin/index.ts")
5+
6+
describe("plugin builtin auth loading", () => {
7+
test("includes builtin anthropic auth plugin in runtime plugin list", async () => {
8+
const src = await Bun.file(file).text()
9+
10+
expect(src).toContain('const BUILTIN = ["op-anthropic-auth@0.0.2"]')
11+
expect(src).toContain("return Config.deduplicatePlugins([...BUILTIN, ...(list ?? [])])")
12+
expect(src).toContain("const plugins = Plugin.plugins(cfg.plugin, Flag.OPENCODE_PURE)")
13+
})
14+
})

0 commit comments

Comments
 (0)