Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 3 additions & 3 deletions packages/opencode/src/plugin/codex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,9 @@ export async function CodexAuthPlugin(input: PluginInput): Promise<Hooks> {
log.info("refreshing codex access token")
const tokens = await refreshAccessToken(currentAuth.refresh)
const newAccountId = extractAccountId(tokens) || authWithAccount.accountId
await input.client.auth.set({
path: { id: "codex" },
body: {
await input.clientNext.auth.set({
providerID: "codex",
auth: {
Comment on lines -408 to +410
Copy link
Copy Markdown
Contributor Author

@eXamadeus eXamadeus Jan 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be left with the v1 client, but I didn't see a compelling reason to leave it be.

type: "oauth",
refresh: tokens.refresh_token,
access: tokens.access_token,
Expand Down
12 changes: 9 additions & 3 deletions packages/opencode/src/plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import type { Hooks, PluginInput, Plugin as PluginInstance } from "@opencode-ai/
import { Config } from "../config/config"
import { Bus } from "../bus"
import { Log } from "../util/log"
import { createOpencodeClient } from "@opencode-ai/sdk"
import { createOpencodeClient as createV2Client } from "@opencode-ai/sdk/v2"
import { createOpencodeClient as createV1Client } from "@opencode-ai/sdk"
import { Server } from "../server/server"
import { BunProc } from "../bun"
import { Instance } from "../project/instance"
Expand All @@ -24,7 +25,12 @@ export namespace Plugin {
const INTERNAL_PLUGINS: PluginInstance[] = [CodexAuthPlugin]

const state = Instance.state(async () => {
const client = createOpencodeClient({
const client = createV1Client({
baseUrl: "http://localhost:4096",
// @ts-ignore - fetch type incompatibility
fetch: async (...args) => Server.App().fetch(...args),
})
const clientNext = createV2Client({
baseUrl: "http://localhost:4096",
// @ts-ignore - fetch type incompatibility
fetch: async (...args) => Server.App().fetch(...args),
Expand All @@ -33,6 +39,7 @@ export namespace Plugin {
const hooks: Hooks[] = []
const input: PluginInput = {
client,
clientNext,
project: Instance.project,
worktree: Instance.worktree,
directory: Instance.directory,
Expand Down Expand Up @@ -123,7 +130,6 @@ export namespace Plugin {
const hooks = await state().then((x) => x.hooks)
const config = await Config.get()
for (const hook of hooks) {
// @ts-expect-error this is because we haven't moved plugin to sdk v2
await hook.config?.(config)
}
Bus.subscribeAll(async (input) => {
Expand Down
23 changes: 19 additions & 4 deletions packages/plugin/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import type { createOpencodeClient as createOpencodeClientV1 } from "@opencode-ai/sdk"
import type {
Event,
createOpencodeClient,
Project,
Model,
Provider,
Permission,
UserMessage,
Message,
Part,
Auth,
Config,
} from "@opencode-ai/sdk"
} from "@opencode-ai/sdk/v2"

import type { BunShell } from "./shell"
import { type ToolDefinition } from "./tool"
Expand All @@ -24,7 +24,8 @@ export type ProviderContext = {
}

export type PluginInput = {
client: ReturnType<typeof createOpencodeClient>
client: ReturnType<typeof createOpencodeClientV1>
clientNext: ReturnType<typeof createOpencodeClient>
project: Project
directory: string
worktree: string
Expand Down Expand Up @@ -172,7 +173,21 @@ export interface Hooks {
input: { sessionID: string; agent: string; model: Model; provider: ProviderContext; message: UserMessage },
output: { temperature: number; topP: number; topK: number; options: Record<string, any> },
) => Promise<void>
"permission.ask"?: (input: Permission, output: { status: "ask" | "deny" | "allow" }) => Promise<void>
Comment thread
eXamadeus marked this conversation as resolved.
"permission.ask"?: (
// based on Permission.Info from Core
input: {
id: string
type: string
pattern?: string | Array<string>
sessionID: string
messageID: string
callID?: string
title: string
metadata: { [key: string]: unknown }
time: { created: number }
},
output: { status: "ask" | "deny" | "allow" },
) => Promise<void>
"tool.execute.before"?: (
input: { tool: string; sessionID: string; callID: string },
output: { args: any },
Expand Down