mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-03-30 13:54:01 +00:00
20 lines
620 B
TypeScript
20 lines
620 B
TypeScript
import { Global } from "../global"
|
|
import { lazy } from "../util/lazy"
|
|
import path from "path"
|
|
|
|
export const AuthCopilot = lazy(async () => {
|
|
const file = Bun.file(path.join(Global.Path.state, "plugin", "copilot.ts"))
|
|
const exists = await file.exists()
|
|
const response = fetch("https://raw.githubusercontent.com/sst/opencode-github-copilot/refs/heads/main/auth.ts")
|
|
.then((x) => Bun.write(file, x))
|
|
.catch(() => {})
|
|
|
|
if (!exists) {
|
|
const worked = await response
|
|
if (!worked) return
|
|
}
|
|
const result = await import(file.name!).catch(() => {})
|
|
if (!result) return
|
|
return result.AuthCopilot
|
|
})
|