Spaces:
Running
Running
File size: 1,482 Bytes
780d695 98c9143 780d695 98c9143 780d695 98c9143 780d695 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | #!/usr/bin/env node
import { defineCommand, runMain, parseArgs } from "citty"
import { bindElectronFetch } from "./lib/electron-fetch"
const cliArgs = {
"api-home": {
type: "string",
description: "Path to the API home directory.",
},
"oauth-app": {
type: "string",
description: "OAuth app identifier.",
},
"enterprise-url": {
type: "string",
description: "Enterprise URL for GitHub.",
},
} as const
const args = parseArgs(process.argv, cliArgs)
// Set environment variables before loading other modules
if (typeof args["api-home"] === "string") {
process.env.COPILOT_API_HOME = args["api-home"]
}
if (typeof args["oauth-app"] === "string") {
process.env.COPILOT_API_OAUTH_APP = args["oauth-app"]
}
if (typeof args["enterprise-url"] === "string") {
process.env.COPILOT_API_ENTERPRISE_URL = args["enterprise-url"]
}
bindElectronFetch()
// Dynamically import other modules to ensure environment variables are set
const { auth } = await import("./auth")
const { checkUsage } = await import("./check-usage")
const { debug } = await import("./debug")
const { mcp } = await import("./mcp")
const { start } = await import("./start")
const main = defineCommand({
meta: {
name: "copilot-api",
description:
"A wrapper around GitHub Copilot API to make it OpenAI compatible, making it usable for other tools.",
},
subCommands: { auth, start, "check-usage": checkUsage, debug, mcp },
args: cliArgs,
})
await runMain(main)
|