cloudaxe-opencode/packages/opencode/src/auth/copilot.ts

20 lines
620 B
TypeScript
Raw Normal View History

2025-06-24 14:42:10 +00:00
import { Global } from "../global"
import { lazy } from "../util/lazy"
import path from "path"
export const AuthCopilot = lazy(async () => {
2025-06-24 18:59:27 +00:00
const file = Bun.file(path.join(Global.Path.state, "plugin", "copilot.ts"))
2025-07-19 23:19:38 +00:00
const exists = await file.exists()
const response = fetch("https://raw.githubusercontent.com/sst/opencode-github-copilot/refs/heads/main/auth.ts")
2025-06-24 14:42:10 +00:00
.then((x) => Bun.write(file, x))
.catch(() => {})
2025-07-19 23:19:38 +00:00
if (!exists) {
2025-06-24 14:42:10 +00:00
const worked = await response
if (!worked) return
}
const result = await import(file.name!).catch(() => {})
if (!result) return
return result.AuthCopilot
})