diff options
| author | Dax <[email protected]> | 2025-08-18 17:12:21 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-08-18 17:12:21 -0400 |
| commit | f19586cebd77a4d2092e6ff66fb184a1366a9ce4 (patch) | |
| tree | bc1c2f4dbd6e12ed0d4e058c80b16a8071d8f427 /packages | |
| parent | 5d12cadba7d03ca25becd5942cb8a959be1ddf00 (diff) | |
| download | opencode-f19586cebd77a4d2092e6ff66fb184a1366a9ce4.tar.gz opencode-f19586cebd77a4d2092e6ff66fb184a1366a9ce4.zip | |
fix anthropic console auth (#2049)
Diffstat (limited to 'packages')
| -rw-r--r-- | packages/opencode/src/cli/cmd/auth.ts | 40 | ||||
| -rw-r--r-- | packages/opencode/src/cli/cmd/opentui/opentui.ts | 0 | ||||
| -rw-r--r-- | packages/opencode/src/plugin/index.ts | 2 | ||||
| -rw-r--r-- | packages/plugin/src/index.ts | 28 |
4 files changed, 47 insertions, 23 deletions
diff --git a/packages/opencode/src/cli/cmd/auth.ts b/packages/opencode/src/cli/cmd/auth.ts index ab06d5bf3..cf736486a 100644 --- a/packages/opencode/src/cli/cmd/auth.ts +++ b/packages/opencode/src/cli/cmd/auth.ts @@ -176,12 +176,20 @@ export const AuthLoginCommand = cmd({ spinner.stop("Failed to authorize", 1) } if (result.type === "success") { - await Auth.set(provider, { - type: "oauth", - refresh: result.refresh, - access: result.access, - expires: result.expires, - }) + if ("refresh" in result) { + await Auth.set(provider, { + type: "oauth", + refresh: result.refresh, + access: result.access, + expires: result.expires, + }) + } + if ("key" in result) { + await Auth.set(provider, { + type: "api", + key: result.key, + }) + } spinner.stop("Login successful") } } @@ -197,12 +205,20 @@ export const AuthLoginCommand = cmd({ prompts.log.error("Failed to authorize") } if (result.type === "success") { - await Auth.set(provider, { - type: "oauth", - refresh: result.refresh, - access: result.access, - expires: result.expires, - }) + if ("refresh" in result) { + await Auth.set(provider, { + type: "oauth", + refresh: result.refresh, + access: result.access, + expires: result.expires, + }) + } + if ("key" in result) { + await Auth.set(provider, { + type: "api", + key: result.key, + }) + } prompts.log.success("Login successful") } } diff --git a/packages/opencode/src/cli/cmd/opentui/opentui.ts b/packages/opencode/src/cli/cmd/opentui/opentui.ts new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/packages/opencode/src/cli/cmd/opentui/opentui.ts diff --git a/packages/opencode/src/plugin/index.ts b/packages/opencode/src/plugin/index.ts index 8fbd38c67..633dc850e 100644 --- a/packages/opencode/src/plugin/index.ts +++ b/packages/opencode/src/plugin/index.ts @@ -26,7 +26,7 @@ export namespace Plugin { const plugins = [...(config.plugin ?? [])] if (!Flag.OPENCODE_DISABLE_DEFAULT_PLUGINS) { plugins.push("opencode-copilot-auth") - plugins.push("opencode-anthropic-auth") + plugins.push("[email protected]") } for (let plugin of plugins) { log.info("loading plugin", { path: plugin }) diff --git a/packages/plugin/src/index.ts b/packages/plugin/src/index.ts index 1a6cbf124..a214af110 100644 --- a/packages/plugin/src/index.ts +++ b/packages/plugin/src/index.ts @@ -32,12 +32,16 @@ export interface Hooks { | { method: "auto" callback(): Promise< - | { + | ({ type: "success" - refresh: string - access: string - expires: number - } + } & ( + | { + refresh: string + access: string + expires: number + } + | { key: string } + )) | { type: "failed" } @@ -46,12 +50,16 @@ export interface Hooks { | { method: "code" callback(code: string): Promise< - | { + | ({ type: "success" - refresh: string - access: string - expires: number - } + } & ( + | { + refresh: string + access: string + expires: number + } + | { key: string } + )) | { type: "failed" } |
