-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathutils.ts
More file actions
90 lines (78 loc) · 1.93 KB
/
utils.ts
File metadata and controls
90 lines (78 loc) · 1.93 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import { homedir } from "node:os";
import { join } from "node:path";
import { readFile, access } from "node:fs/promises";
interface IModel {
model: string;
name: string;
maxInputChars?: number;
capabilities: Array<"completion" | "tools" | "thinking" | "vision">;
}
let token: null | string = null;
const models: IModel[] = [
{
model: "deepseek",
name: "DeepSeek V3.1",
maxInputChars: 10000,
capabilities: ["completion", "tools", "thinking"]
},
{
model: "gemini",
name: "Gemini 2.5 Flash Lite",
capabilities: ["completion", "tools", "vision"]
},
{
model: "openai",
name: "OpenAI GPT-5 Nano",
maxInputChars: 7000,
capabilities: ["completion", "tools", "vision"]
},
{
model: "openai-fast",
name: "OpenAI GPT-4.1 Nano",
maxInputChars: 5000,
capabilities: ["completion", "tools", "vision"]
},
{
model: "openai-large",
name: "OpenAI GPT-5 Chat",
maxInputChars: 30000,
capabilities: ["completion", "tools", "vision"]
},
{
model: "openai-reasoning",
name: "OpenAI o4 Mini",
capabilities: ["completion", "tools", "thinking", "vision"]
},
{
model: "qwen-coder",
name: "Qwen 2.5 Coder 32B",
capabilities: ["completion", "tools", "vision"]
}
];
async function accessToken() {
const cfgFile = join(homedir(), ".beecoder");
try {
await access(cfgFile);
} catch {
return;
}
token = await readFile(cfgFile, { encoding: "utf8" });
}
function getAccessToken() {
return token;
}
function getModel(): IModel[];
function getModel(model: string): IModel;
function getModel(model?: string) {
if (model == undefined) return models;
return models.find(mod => mod.model === model)!;
}
class Logger {
static log(...msg: string[]) {
process.stdout.write(msg.join(" ") + "\n");
}
static error(...msg: string[]) {
process.stderr.write(msg.join(" ") + "\n");
}
}
export { accessToken, getAccessToken, getModel, Logger };