forked from ericc-ch/copilot-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.ts
More file actions
32 lines (27 loc) · 896 Bytes
/
main.ts
File metadata and controls
32 lines (27 loc) · 896 Bytes
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
#!/usr/bin/env node
import { defineCommand, runMain } from "citty"
import { Agent, setGlobalDispatcher } from "undici"
import { auth } from "./auth"
import { checkUsage } from "./check-usage"
import { debug } from "./debug"
import { start } from "./start"
// Extend undici global timeouts to tolerate long GitHub Copilot upstream responses
// (subagent workloads routinely exceed default 300s headersTimeout).
setGlobalDispatcher(
new Agent({
headersTimeout: 600_000,
bodyTimeout: 600_000,
keepAliveTimeout: 120_000,
keepAliveMaxTimeout: 600_000,
connect: { timeout: 30_000 },
}),
)
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 },
})
await runMain(main)