opencode/packages/storybook/.storybook/mocks/app/context/server-sdk.ts
usrnk1 f7d5a1cbc7
feat(desktop): align provider onboarding dialogs (#36733)
Co-authored-by: Brendan Allan <git@brendonovich.dev>
2026-07-17 16:54:20 +08:00

47 lines
1.1 KiB
TypeScript

const providers = [
"opencode",
"opencode-go",
"anthropic",
"openai",
"google",
"openrouter",
"vercel",
"github-copilot",
"302ai",
"abacus",
"abliteration",
"alibaba",
"alibaba-cn",
"alibaba-coding-plan",
]
const client = {
provider: {
auth: async () => ({
data: Object.fromEntries(providers.map((provider) => [provider, [{ type: "api", label: "API key" }]])),
}),
oauth: {
authorize: async (input: { method?: number }) => ({
data: {
url: "https://example.com/oauth",
method: input.method === 1 ? ("code" as const) : ("auto" as const),
instructions: input.method === 1 ? "Paste the authorization code" : "Confirmation code: ABCD-EFGH",
},
}),
callback: async (input: { method?: number }) => {
if (input.method === 0) return new Promise<never>(() => {})
return { data: undefined }
},
},
},
auth: {
set: async () => ({ data: true }),
},
global: {
dispose: async () => ({ data: true }),
},
}
export function useServerSDK() {
return () => ({ client })
}