@datename/fastcode-termux 0.0.0-stage → 0.1.6-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +418 -2
- package/bin/fastcode.mjs +59 -0
- package/dist/agent/approval.d.ts +50 -0
- package/dist/agent/approval.js +7 -0
- package/dist/agent/compaction.d.ts +39 -0
- package/dist/agent/compaction.js +227 -0
- package/dist/agent/context.d.ts +29 -0
- package/dist/agent/context.js +62 -0
- package/dist/agent/guards.d.ts +43 -0
- package/dist/agent/guards.js +269 -0
- package/dist/agent/ignore.d.ts +11 -0
- package/dist/agent/ignore.js +129 -0
- package/dist/agent/limits.d.ts +24 -0
- package/dist/agent/limits.js +71 -0
- package/dist/agent/process-tree.d.ts +2 -0
- package/dist/agent/process-tree.js +31 -0
- package/dist/agent/protocol-mode.d.ts +6 -0
- package/dist/agent/protocol-mode.js +51 -0
- package/dist/agent/protocol.d.ts +4 -0
- package/dist/agent/protocol.js +129 -0
- package/dist/agent/registry.d.ts +17 -0
- package/dist/agent/registry.js +90 -0
- package/dist/agent/runner.d.ts +106 -0
- package/dist/agent/runner.js +352 -0
- package/dist/agent/shell-session.d.ts +37 -0
- package/dist/agent/shell-session.js +400 -0
- package/dist/agent/stream.d.ts +29 -0
- package/dist/agent/stream.js +103 -0
- package/dist/agent/tool-schemas.d.ts +2 -0
- package/dist/agent/tool-schemas.js +63 -0
- package/dist/agent/tools/append_file.d.ts +2 -0
- package/dist/agent/tools/append_file.js +26 -0
- package/dist/agent/tools/apply_patch.d.ts +10 -0
- package/dist/agent/tools/apply_patch.js +52 -0
- package/dist/agent/tools/copy_file.d.ts +2 -0
- package/dist/agent/tools/copy_file.js +30 -0
- package/dist/agent/tools/delete_file.d.ts +2 -0
- package/dist/agent/tools/delete_file.js +24 -0
- package/dist/agent/tools/grep.d.ts +2 -0
- package/dist/agent/tools/grep.js +23 -0
- package/dist/agent/tools/index.d.ts +2 -0
- package/dist/agent/tools/index.js +32 -0
- package/dist/agent/tools/list_files.d.ts +2 -0
- package/dist/agent/tools/list_files.js +17 -0
- package/dist/agent/tools/make_dir.d.ts +2 -0
- package/dist/agent/tools/make_dir.js +24 -0
- package/dist/agent/tools/move_path.d.ts +2 -0
- package/dist/agent/tools/move_path.js +47 -0
- package/dist/agent/tools/paths.d.ts +7 -0
- package/dist/agent/tools/paths.js +84 -0
- package/dist/agent/tools/pwd.d.ts +2 -0
- package/dist/agent/tools/pwd.js +10 -0
- package/dist/agent/tools/read_file.d.ts +2 -0
- package/dist/agent/tools/read_file.js +21 -0
- package/dist/agent/tools/read_many.d.ts +2 -0
- package/dist/agent/tools/read_many.js +25 -0
- package/dist/agent/tools/readers.d.ts +6 -0
- package/dist/agent/tools/readers.js +216 -0
- package/dist/agent/tools/replace_in_file.d.ts +2 -0
- package/dist/agent/tools/replace_in_file.js +30 -0
- package/dist/agent/tools/shell.d.ts +2 -0
- package/dist/agent/tools/shell.js +48 -0
- package/dist/agent/tools/stat_path.d.ts +2 -0
- package/dist/agent/tools/stat_path.js +31 -0
- package/dist/agent/tools/types.d.ts +39 -0
- package/dist/agent/tools/types.js +1 -0
- package/dist/agent/tools/validate.d.ts +6 -0
- package/dist/agent/tools/validate.js +29 -0
- package/dist/agent/tools/write_file.d.ts +2 -0
- package/dist/agent/tools/write_file.js +26 -0
- package/dist/agent/tools.d.ts +3 -0
- package/dist/agent/tools.js +2 -0
- package/dist/app.d.ts +4 -0
- package/dist/app.js +708 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +569 -0
- package/dist/commands/about.d.ts +8 -0
- package/dist/commands/about.js +16 -0
- package/dist/commands/agent.d.ts +11 -0
- package/dist/commands/agent.js +18 -0
- package/dist/commands/attach.d.ts +9 -0
- package/dist/commands/attach.js +15 -0
- package/dist/commands/bg.d.ts +7 -0
- package/dist/commands/bg.js +9 -0
- package/dist/commands/cancel.d.ts +10 -0
- package/dist/commands/cancel.js +10 -0
- package/dist/commands/clear.d.ts +11 -0
- package/dist/commands/clear.js +9 -0
- package/dist/commands/compact.d.ts +10 -0
- package/dist/commands/compact.js +22 -0
- package/dist/commands/config.d.ts +7 -0
- package/dist/commands/config.js +24 -0
- package/dist/commands/context.d.ts +7 -0
- package/dist/commands/context.js +24 -0
- package/dist/commands/cost.d.ts +9 -0
- package/dist/commands/cost.js +13 -0
- package/dist/commands/cwd.d.ts +7 -0
- package/dist/commands/cwd.js +7 -0
- package/dist/commands/edit.d.ts +10 -0
- package/dist/commands/edit.js +36 -0
- package/dist/commands/effort.d.ts +25 -0
- package/dist/commands/effort.js +48 -0
- package/dist/commands/exit.d.ts +9 -0
- package/dist/commands/exit.js +8 -0
- package/dist/commands/expand.d.ts +10 -0
- package/dist/commands/expand.js +8 -0
- package/dist/commands/help.d.ts +6 -0
- package/dist/commands/help.js +18 -0
- package/dist/commands/index.d.ts +9 -0
- package/dist/commands/index.js +80 -0
- package/dist/commands/jobs.d.ts +7 -0
- package/dist/commands/jobs.js +16 -0
- package/dist/commands/kill.d.ts +7 -0
- package/dist/commands/kill.js +11 -0
- package/dist/commands/login.d.ts +18 -0
- package/dist/commands/login.js +63 -0
- package/dist/commands/logout.d.ts +9 -0
- package/dist/commands/logout.js +45 -0
- package/dist/commands/model.d.ts +24 -0
- package/dist/commands/model.js +50 -0
- package/dist/commands/plugin.d.ts +11 -0
- package/dist/commands/plugin.js +74 -0
- package/dist/commands/provider.d.ts +24 -0
- package/dist/commands/provider.js +39 -0
- package/dist/commands/reset.d.ts +9 -0
- package/dist/commands/reset.js +13 -0
- package/dist/commands/skills.d.ts +11 -0
- package/dist/commands/skills.js +106 -0
- package/dist/commands/steer.d.ts +11 -0
- package/dist/commands/steer.js +13 -0
- package/dist/commands/system.d.ts +11 -0
- package/dist/commands/system.js +20 -0
- package/dist/commands/theme.d.ts +11 -0
- package/dist/commands/theme.js +22 -0
- package/dist/commands/tools.d.ts +7 -0
- package/dist/commands/tools.js +29 -0
- package/dist/commands/whoami.d.ts +9 -0
- package/dist/commands/whoami.js +52 -0
- package/dist/config/paths.d.ts +4 -0
- package/dist/config/paths.js +59 -0
- package/dist/config/store.d.ts +89 -0
- package/dist/config/store.js +260 -0
- package/dist/config/themes.d.ts +73 -0
- package/dist/config/themes.js +77 -0
- package/dist/config/trust.d.ts +22 -0
- package/dist/config/trust.js +153 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +31 -0
- package/dist/lib/diagnostics.d.ts +66 -0
- package/dist/lib/diagnostics.js +195 -0
- package/dist/lib/http.d.ts +23 -0
- package/dist/lib/http.js +128 -0
- package/dist/lib/markdown.d.ts +1 -0
- package/dist/lib/markdown.js +32 -0
- package/dist/lib/model-meta.d.ts +19 -0
- package/dist/lib/model-meta.js +113 -0
- package/dist/lib/native-tools.d.ts +12 -0
- package/dist/lib/native-tools.js +21 -0
- package/dist/lib/net.d.ts +33 -0
- package/dist/lib/net.js +168 -0
- package/dist/lib/pkg.d.ts +5 -0
- package/dist/lib/pkg.js +27 -0
- package/dist/lib/platform.d.ts +7 -0
- package/dist/lib/platform.js +57 -0
- package/dist/lib/startup.d.ts +6 -0
- package/dist/lib/startup.js +25 -0
- package/dist/lib/uiMode.d.ts +2 -0
- package/dist/lib/uiMode.js +7 -0
- package/dist/patch/apply.d.ts +15 -0
- package/dist/patch/apply.js +172 -0
- package/dist/patch/parse.d.ts +29 -0
- package/dist/patch/parse.js +112 -0
- package/dist/patch/plan.d.ts +49 -0
- package/dist/patch/plan.js +273 -0
- package/dist/plugins/manager.d.ts +23 -0
- package/dist/plugins/manager.js +101 -0
- package/dist/providers/anthropic.d.ts +22 -0
- package/dist/providers/anthropic.js +119 -0
- package/dist/providers/custom.d.ts +33 -0
- package/dist/providers/custom.js +25 -0
- package/dist/providers/deepseek.d.ts +34 -0
- package/dist/providers/deepseek.js +16 -0
- package/dist/providers/google.d.ts +33 -0
- package/dist/providers/google.js +19 -0
- package/dist/providers/groq.d.ts +34 -0
- package/dist/providers/groq.js +21 -0
- package/dist/providers/index.d.ts +10 -0
- package/dist/providers/index.js +67 -0
- package/dist/providers/mistral.d.ts +34 -0
- package/dist/providers/mistral.js +20 -0
- package/dist/providers/moonshot.d.ts +34 -0
- package/dist/providers/moonshot.js +23 -0
- package/dist/providers/ollama.d.ts +33 -0
- package/dist/providers/ollama.js +22 -0
- package/dist/providers/openai.d.ts +34 -0
- package/dist/providers/openai.js +26 -0
- package/dist/providers/openaiCompatible.d.ts +26 -0
- package/dist/providers/openaiCompatible.js +158 -0
- package/dist/providers/openrouter.d.ts +34 -0
- package/dist/providers/openrouter.js +27 -0
- package/dist/providers/qwen.d.ts +34 -0
- package/dist/providers/qwen.js +24 -0
- package/dist/providers/xai.d.ts +34 -0
- package/dist/providers/xai.js +19 -0
- package/dist/providers/zhipu.d.ts +34 -0
- package/dist/providers/zhipu.js +24 -0
- package/dist/session/log.d.ts +52 -0
- package/dist/session/log.js +331 -0
- package/dist/session/projection.d.ts +43 -0
- package/dist/session/projection.js +257 -0
- package/dist/skills/manager.d.ts +18 -0
- package/dist/skills/manager.js +201 -0
- package/dist/skills/parser.d.ts +18 -0
- package/dist/skills/parser.js +65 -0
- package/dist/types.d.ts +205 -0
- package/dist/types.js +1 -0
- package/dist/ui/Banner.d.ts +5 -0
- package/dist/ui/Banner.js +65 -0
- package/dist/ui/Message.d.ts +1 -0
- package/dist/ui/Message.js +24 -0
- package/dist/ui/Picker.d.ts +8 -0
- package/dist/ui/Picker.js +24 -0
- package/dist/ui/Prompt.d.ts +9 -0
- package/dist/ui/Prompt.js +38 -0
- package/dist/ui/Spinner.d.ts +5 -0
- package/dist/ui/Spinner.js +39 -0
- package/dist/ui/StatusBar.d.ts +11 -0
- package/dist/ui/StatusBar.js +20 -0
- package/dist/ui/TrustGate.d.ts +5 -0
- package/dist/ui/TrustGate.js +26 -0
- package/package.json +96 -4
- package/src/agent/approval.ts +47 -0
- package/src/agent/compaction.ts +276 -0
- package/src/agent/context.ts +97 -0
- package/src/agent/guards.ts +270 -0
- package/src/agent/ignore.ts +147 -0
- package/src/agent/limits.ts +71 -0
- package/src/agent/process-tree.ts +32 -0
- package/src/agent/protocol-mode.ts +59 -0
- package/src/agent/protocol.ts +129 -0
- package/src/agent/registry.ts +98 -0
- package/src/agent/runner.ts +443 -0
- package/src/agent/shell-session.ts +449 -0
- package/src/agent/stream.ts +143 -0
- package/src/agent/tool-schemas.ts +67 -0
- package/src/agent/tools/append_file.ts +28 -0
- package/src/agent/tools/apply_patch.ts +54 -0
- package/src/agent/tools/copy_file.ts +32 -0
- package/src/agent/tools/delete_file.ts +26 -0
- package/src/agent/tools/grep.ts +25 -0
- package/src/agent/tools/index.ts +34 -0
- package/src/agent/tools/list_files.ts +19 -0
- package/src/agent/tools/make_dir.ts +26 -0
- package/src/agent/tools/move_path.ts +50 -0
- package/src/agent/tools/paths.ts +92 -0
- package/src/agent/tools/pwd.ts +12 -0
- package/src/agent/tools/read_file.ts +23 -0
- package/src/agent/tools/read_many.ts +27 -0
- package/src/agent/tools/readers.ts +228 -0
- package/src/agent/tools/replace_in_file.ts +32 -0
- package/src/agent/tools/shell.ts +53 -0
- package/src/agent/tools/stat_path.ts +33 -0
- package/src/agent/tools/types.ts +42 -0
- package/src/agent/tools/validate.ts +35 -0
- package/src/agent/tools/write_file.ts +28 -0
- package/src/agent/tools.ts +3 -0
- package/src/app.ts +708 -0
- package/src/cli.ts +335 -0
- package/src/commands/about.ts +16 -0
- package/src/commands/agent.ts +18 -0
- package/src/commands/attach.ts +16 -0
- package/src/commands/bg.ts +9 -0
- package/src/commands/cancel.ts +10 -0
- package/src/commands/clear.ts +9 -0
- package/src/commands/compact.ts +23 -0
- package/src/commands/config.ts +24 -0
- package/src/commands/context.ts +25 -0
- package/src/commands/cost.ts +13 -0
- package/src/commands/cwd.ts +7 -0
- package/src/commands/edit.ts +37 -0
- package/src/commands/effort.ts +49 -0
- package/src/commands/exit.ts +8 -0
- package/src/commands/expand.ts +8 -0
- package/src/commands/help.ts +18 -0
- package/src/commands/index.ts +80 -0
- package/src/commands/jobs.ts +17 -0
- package/src/commands/kill.ts +12 -0
- package/src/commands/login.ts +63 -0
- package/src/commands/logout.ts +45 -0
- package/src/commands/model.ts +50 -0
- package/src/commands/plugin.ts +74 -0
- package/src/commands/provider.ts +39 -0
- package/src/commands/reset.ts +13 -0
- package/src/commands/skills.ts +106 -0
- package/src/commands/steer.ts +13 -0
- package/src/commands/system.ts +20 -0
- package/src/commands/theme.ts +22 -0
- package/src/commands/tools.ts +29 -0
- package/src/commands/whoami.ts +52 -0
- package/src/config/paths.ts +59 -0
- package/src/config/store.ts +293 -0
- package/src/config/themes.ts +77 -0
- package/src/config/trust.ts +183 -0
- package/src/index.ts +31 -0
- package/src/lib/diagnostics.ts +195 -0
- package/src/lib/http.ts +132 -0
- package/src/lib/markdown.ts +32 -0
- package/src/lib/model-meta.ts +138 -0
- package/src/lib/native-tools.ts +32 -0
- package/src/lib/net.ts +204 -0
- package/src/lib/pkg.ts +35 -0
- package/src/lib/platform.ts +57 -0
- package/src/lib/startup.ts +25 -0
- package/src/lib/uiMode.ts +7 -0
- package/src/patch/apply.ts +194 -0
- package/src/patch/parse.ts +131 -0
- package/src/patch/plan.ts +317 -0
- package/src/plugins/manager.ts +101 -0
- package/src/providers/anthropic.ts +119 -0
- package/src/providers/custom.ts +25 -0
- package/src/providers/deepseek.ts +16 -0
- package/src/providers/google.ts +19 -0
- package/src/providers/groq.ts +21 -0
- package/src/providers/index.ts +68 -0
- package/src/providers/mistral.ts +20 -0
- package/src/providers/moonshot.ts +23 -0
- package/src/providers/ollama.ts +22 -0
- package/src/providers/openai.ts +26 -0
- package/src/providers/openaiCompatible.ts +158 -0
- package/src/providers/openrouter.ts +27 -0
- package/src/providers/qwen.ts +24 -0
- package/src/providers/xai.ts +19 -0
- package/src/providers/zhipu.ts +24 -0
- package/src/session/log.ts +374 -0
- package/src/session/projection.ts +308 -0
- package/src/skills/manager.ts +201 -0
- package/src/skills/parser.ts +65 -0
- package/src/types.ts +205 -0
- package/src/ui/Banner.ts +68 -0
- package/src/ui/Message.ts +24 -0
- package/src/ui/Picker.ts +24 -0
- package/src/ui/Prompt.ts +38 -0
- package/src/ui/Spinner.ts +39 -0
- package/src/ui/StatusBar.ts +20 -0
- package/src/ui/TrustGate.ts +26 -0
- package/tsconfig.json +22 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare const ollamaProvider: {
|
|
2
|
+
id: string;
|
|
3
|
+
label: string;
|
|
4
|
+
authEnv: any[];
|
|
5
|
+
readonly baseUrl: string;
|
|
6
|
+
defaultModel: string;
|
|
7
|
+
listModels: () => Promise<any>;
|
|
8
|
+
stream: (req: any) => AsyncGenerator<{
|
|
9
|
+
delta: string;
|
|
10
|
+
done: boolean;
|
|
11
|
+
reasoning?: undefined;
|
|
12
|
+
usage?: undefined;
|
|
13
|
+
toolCalls?: undefined;
|
|
14
|
+
} | {
|
|
15
|
+
delta: string;
|
|
16
|
+
done: boolean;
|
|
17
|
+
reasoning: string;
|
|
18
|
+
usage?: undefined;
|
|
19
|
+
toolCalls?: undefined;
|
|
20
|
+
} | {
|
|
21
|
+
delta: string;
|
|
22
|
+
done: boolean;
|
|
23
|
+
usage: any;
|
|
24
|
+
toolCalls: import("../types.js").NativeToolCall[];
|
|
25
|
+
reasoning?: undefined;
|
|
26
|
+
} | {
|
|
27
|
+
delta: string;
|
|
28
|
+
done: boolean;
|
|
29
|
+
usage: any;
|
|
30
|
+
reasoning?: undefined;
|
|
31
|
+
toolCalls?: undefined;
|
|
32
|
+
}, void, unknown>;
|
|
33
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { listModelsHttp, streamChatCompletion } from "./openaiCompatible.js";
|
|
2
|
+
function baseUrl() {
|
|
3
|
+
const host = (process.env["OLLAMA_HOST"] ?? "").trim() || "http://localhost:11434";
|
|
4
|
+
return host.endsWith("/v1") ? host : host + "/v1";
|
|
5
|
+
}
|
|
6
|
+
const STATIC = [
|
|
7
|
+
{ id: "qwen3-coder", label: "qwen3-coder (local)" },
|
|
8
|
+
{ id: "llama3.2", label: "llama3.2 (local)" },
|
|
9
|
+
{ id: "gpt-oss", label: "gpt-oss (local)" },
|
|
10
|
+
{ id: "deepseek-r1", label: "deepseek-r1 (local)" },
|
|
11
|
+
];
|
|
12
|
+
export const ollamaProvider = {
|
|
13
|
+
id: "ollama",
|
|
14
|
+
label: "Ollama (local)",
|
|
15
|
+
authEnv: [],
|
|
16
|
+
get baseUrl() {
|
|
17
|
+
return baseUrl();
|
|
18
|
+
},
|
|
19
|
+
defaultModel: "qwen3-coder",
|
|
20
|
+
listModels: () => listModelsHttp({ baseUrl: baseUrl(), apiKey: undefined, staticModels: STATIC }),
|
|
21
|
+
stream: (req) => streamChatCompletion(req, { baseUrl: baseUrl(), apiKey: undefined, staticModels: STATIC }),
|
|
22
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare const openaiProvider: {
|
|
2
|
+
id: string;
|
|
3
|
+
label: string;
|
|
4
|
+
authEnv: string[];
|
|
5
|
+
baseUrl: string;
|
|
6
|
+
defaultModel: string;
|
|
7
|
+
listModels: (apiKey: any) => Promise<any>;
|
|
8
|
+
stream: (req: any, apiKey: any) => AsyncGenerator<{
|
|
9
|
+
delta: string;
|
|
10
|
+
done: boolean;
|
|
11
|
+
reasoning?: undefined;
|
|
12
|
+
usage?: undefined;
|
|
13
|
+
toolCalls?: undefined;
|
|
14
|
+
} | {
|
|
15
|
+
delta: string;
|
|
16
|
+
done: boolean;
|
|
17
|
+
reasoning: string;
|
|
18
|
+
usage?: undefined;
|
|
19
|
+
toolCalls?: undefined;
|
|
20
|
+
} | {
|
|
21
|
+
delta: string;
|
|
22
|
+
done: boolean;
|
|
23
|
+
usage: any;
|
|
24
|
+
toolCalls: import("../types.js").NativeToolCall[];
|
|
25
|
+
reasoning?: undefined;
|
|
26
|
+
} | {
|
|
27
|
+
delta: string;
|
|
28
|
+
done: boolean;
|
|
29
|
+
usage: any;
|
|
30
|
+
reasoning?: undefined;
|
|
31
|
+
toolCalls?: undefined;
|
|
32
|
+
}, void, unknown>;
|
|
33
|
+
supportsReasoning: (model: any) => boolean;
|
|
34
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { listModelsHttp, streamChatCompletion } from "./openaiCompatible.js";
|
|
2
|
+
const BASE = "https://api.openai.com/v1";
|
|
3
|
+
const STATIC = [
|
|
4
|
+
{ id: "gpt-6.1-sol", label: "GPT-6.1 Sol" },
|
|
5
|
+
{ id: "gpt-6.1-sol-pro", label: "GPT-6.1 Sol Pro" },
|
|
6
|
+
{ id: "gpt-6-luna", label: "GPT-6 Luna" },
|
|
7
|
+
{ id: "gpt-6-luna-pro", label: "GPT-6 Luna Pro" },
|
|
8
|
+
{ id: "gpt-6-sol", label: "GPT-6 Sol" },
|
|
9
|
+
{ id: "gpt-5.6-terra", label: "GPT-5.6 Terra" },
|
|
10
|
+
{ id: "gpt-5.6-luna", label: "GPT-5.6 Luna" },
|
|
11
|
+
{ id: "gpt-4.1", label: "GPT-4.1", pricing: { inputUsdPerM: 2, outputUsdPerM: 8 } },
|
|
12
|
+
{ id: "gpt-4o", label: "GPT-4o", pricing: { inputUsdPerM: 2.5, outputUsdPerM: 10 } },
|
|
13
|
+
{ id: "gpt-4o-mini", label: "GPT-4o mini", pricing: { inputUsdPerM: 0.15, outputUsdPerM: 0.6 } },
|
|
14
|
+
{ id: "o4-mini", label: "o4-mini" },
|
|
15
|
+
{ id: "o3", label: "o3" },
|
|
16
|
+
];
|
|
17
|
+
export const openaiProvider = {
|
|
18
|
+
id: "openai",
|
|
19
|
+
label: "OpenAI",
|
|
20
|
+
authEnv: ["OPENAI_API_KEY"],
|
|
21
|
+
baseUrl: BASE,
|
|
22
|
+
defaultModel: "gpt-6-luna",
|
|
23
|
+
listModels: (apiKey) => listModelsHttp({ baseUrl: BASE, apiKey, staticModels: STATIC }),
|
|
24
|
+
stream: (req, apiKey) => streamChatCompletion(req, { baseUrl: BASE, apiKey, staticModels: STATIC, reasoning: "openai" }),
|
|
25
|
+
supportsReasoning: (model) => /^(o\d|gpt-5|gpt-6)/i.test(model),
|
|
26
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare function streamChatCompletion(req: any, opts: any): AsyncGenerator<{
|
|
2
|
+
delta: string;
|
|
3
|
+
done: boolean;
|
|
4
|
+
reasoning?: undefined;
|
|
5
|
+
usage?: undefined;
|
|
6
|
+
toolCalls?: undefined;
|
|
7
|
+
} | {
|
|
8
|
+
delta: string;
|
|
9
|
+
done: boolean;
|
|
10
|
+
reasoning: string;
|
|
11
|
+
usage?: undefined;
|
|
12
|
+
toolCalls?: undefined;
|
|
13
|
+
} | {
|
|
14
|
+
delta: string;
|
|
15
|
+
done: boolean;
|
|
16
|
+
usage: any;
|
|
17
|
+
toolCalls: import("../types.js").NativeToolCall[];
|
|
18
|
+
reasoning?: undefined;
|
|
19
|
+
} | {
|
|
20
|
+
delta: string;
|
|
21
|
+
done: boolean;
|
|
22
|
+
usage: any;
|
|
23
|
+
reasoning?: undefined;
|
|
24
|
+
toolCalls?: undefined;
|
|
25
|
+
}, void, unknown>;
|
|
26
|
+
export declare function listModelsHttp(opts: any): Promise<any>;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { fetchJson, streamSSE } from "../lib/http.js";
|
|
2
|
+
import { finalizeToolCalls, mergeToolCallDelta } from "../lib/native-tools.js";
|
|
3
|
+
/** Build a chat-completions body in the classic or the newer (compat) dialect. */
|
|
4
|
+
function buildBody(req, compat, opts, includeReasoning = true) {
|
|
5
|
+
const messages = [];
|
|
6
|
+
if (req.system)
|
|
7
|
+
messages.push({ role: "system", content: req.system });
|
|
8
|
+
for (const m of req.messages) {
|
|
9
|
+
if (m.role === "tool") {
|
|
10
|
+
messages.push({ role: "tool", tool_call_id: m.toolCallId, content: m.content });
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
if (m.role === "assistant" && m.toolCalls && m.toolCalls.length > 0) {
|
|
14
|
+
messages.push({
|
|
15
|
+
role: "assistant",
|
|
16
|
+
content: m.content || null,
|
|
17
|
+
tool_calls: m.toolCalls.map((call) => ({
|
|
18
|
+
id: call.id,
|
|
19
|
+
type: "function",
|
|
20
|
+
function: { name: call.name, arguments: call.arguments },
|
|
21
|
+
})),
|
|
22
|
+
});
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
messages.push({ role: m.role, content: m.content });
|
|
26
|
+
}
|
|
27
|
+
const body = { model: req.model, messages, stream: true };
|
|
28
|
+
if (req.tools && req.tools.length > 0) {
|
|
29
|
+
body.tools = req.tools;
|
|
30
|
+
body.tool_choice = "auto";
|
|
31
|
+
}
|
|
32
|
+
if (req.maxOutputTokens !== undefined) {
|
|
33
|
+
if (compat)
|
|
34
|
+
body.max_completion_tokens = req.maxOutputTokens;
|
|
35
|
+
else
|
|
36
|
+
body.max_tokens = req.maxOutputTokens;
|
|
37
|
+
}
|
|
38
|
+
if (req.temperature !== undefined && !compat)
|
|
39
|
+
body.temperature = req.temperature;
|
|
40
|
+
if (includeReasoning && req.reasoningEffort && req.reasoningEffort !== "auto") {
|
|
41
|
+
const effort = req.reasoningEffort === "max" ? "high" : req.reasoningEffort;
|
|
42
|
+
if (opts.reasoning === "openai")
|
|
43
|
+
body.reasoning_effort = effort;
|
|
44
|
+
else if (opts.reasoning === "openrouter")
|
|
45
|
+
body.reasoning = { effort };
|
|
46
|
+
}
|
|
47
|
+
return body;
|
|
48
|
+
}
|
|
49
|
+
export async function* streamChatCompletion(req, opts) {
|
|
50
|
+
const hasReasoning = Boolean(req.reasoningEffort && req.reasoningEffort !== "auto" && opts.reasoning && opts.reasoning !== "none");
|
|
51
|
+
const send = async (compat, includeReasoning = hasReasoning) => {
|
|
52
|
+
const headers = {
|
|
53
|
+
"content-type": "application/json",
|
|
54
|
+
accept: "text/event-stream",
|
|
55
|
+
...(opts.extraHeaders ?? {}),
|
|
56
|
+
};
|
|
57
|
+
if (opts.apiKey)
|
|
58
|
+
headers["authorization"] = (opts.authHeader ?? "Bearer") + " " + opts.apiKey;
|
|
59
|
+
if (req.clientRequestId)
|
|
60
|
+
headers["idempotency-key"] = req.clientRequestId;
|
|
61
|
+
return await fetch(trim(opts.baseUrl) + "/chat/completions", {
|
|
62
|
+
method: "POST",
|
|
63
|
+
headers,
|
|
64
|
+
body: JSON.stringify(buildBody(req, compat, opts, includeReasoning)),
|
|
65
|
+
signal: req.signal,
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
let res = await send(false);
|
|
69
|
+
if (!res.ok) {
|
|
70
|
+
let detail = await res.text().catch(() => "");
|
|
71
|
+
// Some models reject the thinking parameter even though the provider
|
|
72
|
+
// as a whole accepts it. Drop it once, then keep the request alive.
|
|
73
|
+
if (res.status === 400 && hasReasoning && /reasoning|thinking|effort|unsupported|unrecognized|unknown parameter/i.test(detail)) {
|
|
74
|
+
res = await send(false, false);
|
|
75
|
+
detail = res.ok ? detail : await res.text().catch(() => "");
|
|
76
|
+
}
|
|
77
|
+
// Newer OpenAI-style models reject max_tokens and temperature. Retry once
|
|
78
|
+
// in the compatibility dialect before surfacing the real error.
|
|
79
|
+
if (!res.ok && res.status === 400 && /max_tokens|max_completion_tokens|temperature|unsupported|unrecognized|unknown parameter/i.test(detail)) {
|
|
80
|
+
res = await send(true, false);
|
|
81
|
+
detail = res.ok ? detail : await res.text().catch(() => "");
|
|
82
|
+
}
|
|
83
|
+
if (!res.ok) {
|
|
84
|
+
throw new Error(res.status + " " + res.statusText + ": " + detail.slice(0, 500));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
let usage;
|
|
88
|
+
const toolCalls = new Map();
|
|
89
|
+
for await (const ev of streamSSE(res)) {
|
|
90
|
+
if (ev.data === "[DONE]")
|
|
91
|
+
break;
|
|
92
|
+
let payload;
|
|
93
|
+
try {
|
|
94
|
+
payload = JSON.parse(ev.data);
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
const obj = payload;
|
|
100
|
+
const choice = obj.choices?.[0];
|
|
101
|
+
const raw = choice?.delta?.content ?? choice?.text;
|
|
102
|
+
const reasoning = choice?.delta?.reasoning_content ?? choice?.delta?.reasoning;
|
|
103
|
+
if (Array.isArray(choice?.delta?.tool_calls)) {
|
|
104
|
+
for (const delta of choice.delta.tool_calls)
|
|
105
|
+
mergeToolCallDelta(toolCalls, delta);
|
|
106
|
+
}
|
|
107
|
+
if (Array.isArray(choice?.message?.tool_calls)) {
|
|
108
|
+
for (const delta of choice.message.tool_calls)
|
|
109
|
+
mergeToolCallDelta(toolCalls, delta);
|
|
110
|
+
}
|
|
111
|
+
if (obj.usage) {
|
|
112
|
+
usage = {
|
|
113
|
+
inputTokens: obj.usage.prompt_tokens,
|
|
114
|
+
outputTokens: obj.usage.completion_tokens,
|
|
115
|
+
totalTokens: obj.usage.total_tokens,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
const text = typeof raw === "string"
|
|
119
|
+
? raw
|
|
120
|
+
: Array.isArray(raw)
|
|
121
|
+
? raw.map((part) => (part?.text ?? "")).join("")
|
|
122
|
+
: "";
|
|
123
|
+
if (text)
|
|
124
|
+
yield { delta: text, done: false };
|
|
125
|
+
else if (typeof reasoning === "string" && reasoning)
|
|
126
|
+
yield { delta: "", done: false, reasoning };
|
|
127
|
+
}
|
|
128
|
+
const calls = finalizeToolCalls(toolCalls);
|
|
129
|
+
yield calls.length > 0 ? { delta: "", done: true, usage, toolCalls: calls } : { delta: "", done: true, usage };
|
|
130
|
+
}
|
|
131
|
+
export async function listModelsHttp(opts) {
|
|
132
|
+
const staticModels = opts.staticModels ?? [];
|
|
133
|
+
if (!opts.apiKey && staticModels.length)
|
|
134
|
+
return staticModels;
|
|
135
|
+
try {
|
|
136
|
+
const headers = {};
|
|
137
|
+
if (opts.apiKey)
|
|
138
|
+
headers["authorization"] = (opts.authHeader ?? "Bearer") + " " + opts.apiKey;
|
|
139
|
+
const json = await fetchJson(trim(opts.baseUrl) + "/models", { headers });
|
|
140
|
+
const ids = (json.data ?? [])
|
|
141
|
+
.map((m) => m.id)
|
|
142
|
+
.filter((id) => typeof id === "string" && id.length > 0);
|
|
143
|
+
if (ids.length === 0)
|
|
144
|
+
return staticModels;
|
|
145
|
+
// The provider's live list is authoritative: show exactly what it
|
|
146
|
+
// returns (enriched with our labels/pricing where the id is known).
|
|
147
|
+
// Static models the provider no longer returns are dropped so delisted
|
|
148
|
+
// models don't linger in the picker.
|
|
149
|
+
const known = new Map(staticModels.map((m) => [m.id, m]));
|
|
150
|
+
return ids.map((id) => known.get(id) ?? { id });
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
return staticModels;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function trim(url) {
|
|
157
|
+
return url.replace(/[/]+$/, "");
|
|
158
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare const openrouterProvider: {
|
|
2
|
+
id: string;
|
|
3
|
+
label: string;
|
|
4
|
+
authEnv: string[];
|
|
5
|
+
baseUrl: string;
|
|
6
|
+
defaultModel: string;
|
|
7
|
+
listModels: (apiKey: any) => Promise<any>;
|
|
8
|
+
stream: (req: any, apiKey: any) => AsyncGenerator<{
|
|
9
|
+
delta: string;
|
|
10
|
+
done: boolean;
|
|
11
|
+
reasoning?: undefined;
|
|
12
|
+
usage?: undefined;
|
|
13
|
+
toolCalls?: undefined;
|
|
14
|
+
} | {
|
|
15
|
+
delta: string;
|
|
16
|
+
done: boolean;
|
|
17
|
+
reasoning: string;
|
|
18
|
+
usage?: undefined;
|
|
19
|
+
toolCalls?: undefined;
|
|
20
|
+
} | {
|
|
21
|
+
delta: string;
|
|
22
|
+
done: boolean;
|
|
23
|
+
usage: any;
|
|
24
|
+
toolCalls: import("../types.js").NativeToolCall[];
|
|
25
|
+
reasoning?: undefined;
|
|
26
|
+
} | {
|
|
27
|
+
delta: string;
|
|
28
|
+
done: boolean;
|
|
29
|
+
usage: any;
|
|
30
|
+
reasoning?: undefined;
|
|
31
|
+
toolCalls?: undefined;
|
|
32
|
+
}, void, unknown>;
|
|
33
|
+
supportsReasoning: () => boolean;
|
|
34
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { listModelsHttp, streamChatCompletion } from "./openaiCompatible.js";
|
|
2
|
+
const BASE = "https://openrouter.ai/api/v1";
|
|
3
|
+
const STATIC = [
|
|
4
|
+
{ id: "anthropic/claude-sonnet-5.5", label: "Claude Sonnet 5.5" },
|
|
5
|
+
{ id: "openai/gpt-6-luna", label: "GPT-6 Luna" },
|
|
6
|
+
{ id: "google/gemini-3.8-flash", label: "Gemini 3.8 Flash" },
|
|
7
|
+
{ id: "deepseek/deepseek-v4-pro", label: "DeepSeek V4 Pro" },
|
|
8
|
+
{ id: "x-ai/grok-4.7", label: "Grok 4.7" },
|
|
9
|
+
{ id: "moonshotai/kimi-k3", label: "Kimi K3" },
|
|
10
|
+
{ id: "z-ai/glm-5.3", label: "GLM 5.3" },
|
|
11
|
+
{ id: "qwen/qwen3.8-max", label: "Qwen3.8 Max" },
|
|
12
|
+
{ id: "meta-llama/llama-4-maverick", label: "Llama 4 Maverick" },
|
|
13
|
+
];
|
|
14
|
+
const EXTRA_HEADERS = {
|
|
15
|
+
"http-referer": "https://github.com/dateName/fastcode-termux",
|
|
16
|
+
"x-title": "FastCode",
|
|
17
|
+
};
|
|
18
|
+
export const openrouterProvider = {
|
|
19
|
+
id: "openrouter",
|
|
20
|
+
label: "OpenRouter (400+ models)",
|
|
21
|
+
authEnv: ["OPENROUTER_API_KEY"],
|
|
22
|
+
baseUrl: BASE,
|
|
23
|
+
defaultModel: "anthropic/claude-sonnet-5.5",
|
|
24
|
+
listModels: (apiKey) => listModelsHttp({ baseUrl: BASE, apiKey, staticModels: STATIC, extraHeaders: EXTRA_HEADERS }),
|
|
25
|
+
stream: (req, apiKey) => streamChatCompletion(req, { baseUrl: BASE, apiKey, staticModels: STATIC, extraHeaders: EXTRA_HEADERS, reasoning: "openrouter" }),
|
|
26
|
+
supportsReasoning: () => true,
|
|
27
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare const qwenProvider: {
|
|
2
|
+
id: string;
|
|
3
|
+
label: string;
|
|
4
|
+
authEnv: string[];
|
|
5
|
+
readonly baseUrl: string;
|
|
6
|
+
defaultModel: string;
|
|
7
|
+
listModels: (apiKey: any) => Promise<any>;
|
|
8
|
+
stream: (req: any, apiKey: any) => AsyncGenerator<{
|
|
9
|
+
delta: string;
|
|
10
|
+
done: boolean;
|
|
11
|
+
reasoning?: undefined;
|
|
12
|
+
usage?: undefined;
|
|
13
|
+
toolCalls?: undefined;
|
|
14
|
+
} | {
|
|
15
|
+
delta: string;
|
|
16
|
+
done: boolean;
|
|
17
|
+
reasoning: string;
|
|
18
|
+
usage?: undefined;
|
|
19
|
+
toolCalls?: undefined;
|
|
20
|
+
} | {
|
|
21
|
+
delta: string;
|
|
22
|
+
done: boolean;
|
|
23
|
+
usage: any;
|
|
24
|
+
toolCalls: import("../types.js").NativeToolCall[];
|
|
25
|
+
reasoning?: undefined;
|
|
26
|
+
} | {
|
|
27
|
+
delta: string;
|
|
28
|
+
done: boolean;
|
|
29
|
+
usage: any;
|
|
30
|
+
reasoning?: undefined;
|
|
31
|
+
toolCalls?: undefined;
|
|
32
|
+
}, void, unknown>;
|
|
33
|
+
supportsReasoning: () => boolean;
|
|
34
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { listModelsHttp, streamChatCompletion } from "./openaiCompatible.js";
|
|
2
|
+
function baseUrl() {
|
|
3
|
+
return (process.env["DASHSCOPE_BASE_URL"] ?? "").trim() || "https://dashscope.aliyuncs.com/compatible-mode/v1";
|
|
4
|
+
}
|
|
5
|
+
const STATIC = [
|
|
6
|
+
{ id: "qwen3.8-max", label: "Qwen3.8 Max" },
|
|
7
|
+
{ id: "qwen3.8-flash", label: "Qwen3.8 Flash" },
|
|
8
|
+
{ id: "qwen3.7-max", label: "Qwen3.7 Max" },
|
|
9
|
+
{ id: "qwen3.7-plus", label: "Qwen3.7 Plus" },
|
|
10
|
+
{ id: "qwen3-coder-next", label: "Qwen3 Coder Next" },
|
|
11
|
+
{ id: "qwen3.6-27b", label: "Qwen3.6 27B" },
|
|
12
|
+
];
|
|
13
|
+
export const qwenProvider = {
|
|
14
|
+
id: "qwen",
|
|
15
|
+
label: "Qwen (DashScope)",
|
|
16
|
+
authEnv: ["DASHSCOPE_API_KEY", "QWEN_API_KEY"],
|
|
17
|
+
get baseUrl() {
|
|
18
|
+
return baseUrl();
|
|
19
|
+
},
|
|
20
|
+
defaultModel: "qwen3.8-max",
|
|
21
|
+
listModels: (apiKey) => listModelsHttp({ baseUrl: baseUrl(), apiKey, staticModels: STATIC }),
|
|
22
|
+
stream: (req, apiKey) => streamChatCompletion(req, { baseUrl: baseUrl(), apiKey, staticModels: STATIC, reasoning: "openai" }),
|
|
23
|
+
supportsReasoning: () => true,
|
|
24
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare const xaiProvider: {
|
|
2
|
+
id: string;
|
|
3
|
+
label: string;
|
|
4
|
+
authEnv: string[];
|
|
5
|
+
baseUrl: string;
|
|
6
|
+
defaultModel: string;
|
|
7
|
+
listModels: (apiKey: any) => Promise<any>;
|
|
8
|
+
stream: (req: any, apiKey: any) => AsyncGenerator<{
|
|
9
|
+
delta: string;
|
|
10
|
+
done: boolean;
|
|
11
|
+
reasoning?: undefined;
|
|
12
|
+
usage?: undefined;
|
|
13
|
+
toolCalls?: undefined;
|
|
14
|
+
} | {
|
|
15
|
+
delta: string;
|
|
16
|
+
done: boolean;
|
|
17
|
+
reasoning: string;
|
|
18
|
+
usage?: undefined;
|
|
19
|
+
toolCalls?: undefined;
|
|
20
|
+
} | {
|
|
21
|
+
delta: string;
|
|
22
|
+
done: boolean;
|
|
23
|
+
usage: any;
|
|
24
|
+
toolCalls: import("../types.js").NativeToolCall[];
|
|
25
|
+
reasoning?: undefined;
|
|
26
|
+
} | {
|
|
27
|
+
delta: string;
|
|
28
|
+
done: boolean;
|
|
29
|
+
usage: any;
|
|
30
|
+
reasoning?: undefined;
|
|
31
|
+
toolCalls?: undefined;
|
|
32
|
+
}, void, unknown>;
|
|
33
|
+
supportsReasoning: () => boolean;
|
|
34
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { listModelsHttp, streamChatCompletion } from "./openaiCompatible.js";
|
|
2
|
+
const BASE = "https://api.x.ai/v1";
|
|
3
|
+
const STATIC = [
|
|
4
|
+
{ id: "grok-4.7", label: "Grok 4.7" },
|
|
5
|
+
{ id: "grok-4.6", label: "Grok 4.6" },
|
|
6
|
+
{ id: "grok-4.5", label: "Grok 4.5" },
|
|
7
|
+
{ id: "grok-4.3", label: "Grok 4.3" },
|
|
8
|
+
{ id: "grok-4.20", label: "Grok 4.20" },
|
|
9
|
+
];
|
|
10
|
+
export const xaiProvider = {
|
|
11
|
+
id: "xai",
|
|
12
|
+
label: "xAI (Grok)",
|
|
13
|
+
authEnv: ["XAI_API_KEY", "GROK_API_KEY"],
|
|
14
|
+
baseUrl: BASE,
|
|
15
|
+
defaultModel: "grok-4.7",
|
|
16
|
+
listModels: (apiKey) => listModelsHttp({ baseUrl: BASE, apiKey, staticModels: STATIC }),
|
|
17
|
+
stream: (req, apiKey) => streamChatCompletion(req, { baseUrl: BASE, apiKey, staticModels: STATIC, reasoning: "openai" }),
|
|
18
|
+
supportsReasoning: () => true,
|
|
19
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare const zhipuProvider: {
|
|
2
|
+
id: string;
|
|
3
|
+
label: string;
|
|
4
|
+
authEnv: string[];
|
|
5
|
+
readonly baseUrl: string;
|
|
6
|
+
defaultModel: string;
|
|
7
|
+
listModels: (apiKey: any) => Promise<any>;
|
|
8
|
+
stream: (req: any, apiKey: any) => AsyncGenerator<{
|
|
9
|
+
delta: string;
|
|
10
|
+
done: boolean;
|
|
11
|
+
reasoning?: undefined;
|
|
12
|
+
usage?: undefined;
|
|
13
|
+
toolCalls?: undefined;
|
|
14
|
+
} | {
|
|
15
|
+
delta: string;
|
|
16
|
+
done: boolean;
|
|
17
|
+
reasoning: string;
|
|
18
|
+
usage?: undefined;
|
|
19
|
+
toolCalls?: undefined;
|
|
20
|
+
} | {
|
|
21
|
+
delta: string;
|
|
22
|
+
done: boolean;
|
|
23
|
+
usage: any;
|
|
24
|
+
toolCalls: import("../types.js").NativeToolCall[];
|
|
25
|
+
reasoning?: undefined;
|
|
26
|
+
} | {
|
|
27
|
+
delta: string;
|
|
28
|
+
done: boolean;
|
|
29
|
+
usage: any;
|
|
30
|
+
reasoning?: undefined;
|
|
31
|
+
toolCalls?: undefined;
|
|
32
|
+
}, void, unknown>;
|
|
33
|
+
supportsReasoning: () => boolean;
|
|
34
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { listModelsHttp, streamChatCompletion } from "./openaiCompatible.js";
|
|
2
|
+
function baseUrl() {
|
|
3
|
+
return (process.env["ZHIPU_BASE_URL"] ?? "").trim() || "https://open.bigmodel.cn/api/paas/v4";
|
|
4
|
+
}
|
|
5
|
+
const STATIC = [
|
|
6
|
+
{ id: "glm-5.3", label: "GLM 5.3" },
|
|
7
|
+
{ id: "glm-5.2", label: "GLM 5.2" },
|
|
8
|
+
{ id: "glm-5.1", label: "GLM 5.1" },
|
|
9
|
+
{ id: "glm-5", label: "GLM 5" },
|
|
10
|
+
{ id: "glm-4.7", label: "GLM 4.7" },
|
|
11
|
+
{ id: "glm-4.6", label: "GLM 4.6" },
|
|
12
|
+
];
|
|
13
|
+
export const zhipuProvider = {
|
|
14
|
+
id: "zhipu",
|
|
15
|
+
label: "Zhipu (GLM)",
|
|
16
|
+
authEnv: ["ZHIPUAI_API_KEY", "GLM_API_KEY", "ZHIPU_API_KEY"],
|
|
17
|
+
get baseUrl() {
|
|
18
|
+
return baseUrl();
|
|
19
|
+
},
|
|
20
|
+
defaultModel: "glm-5.3",
|
|
21
|
+
listModels: (apiKey) => listModelsHttp({ baseUrl: baseUrl(), apiKey, staticModels: STATIC }),
|
|
22
|
+
stream: (req, apiKey) => streamChatCompletion(req, { baseUrl: baseUrl(), apiKey, staticModels: STATIC, reasoning: "openai" }),
|
|
23
|
+
supportsReasoning: () => true,
|
|
24
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export interface ActiveFile {
|
|
2
|
+
path: string;
|
|
3
|
+
sha1_8: string;
|
|
4
|
+
mtime: string;
|
|
5
|
+
}
|
|
6
|
+
export interface SessionSummary {
|
|
7
|
+
id: string;
|
|
8
|
+
file: string;
|
|
9
|
+
cwd: string;
|
|
10
|
+
providerId: string;
|
|
11
|
+
model: string;
|
|
12
|
+
turns: number;
|
|
13
|
+
activeFiles: ActiveFile[];
|
|
14
|
+
messages: number;
|
|
15
|
+
lastTs: number;
|
|
16
|
+
}
|
|
17
|
+
export declare function sessionCacheLimitBytes(): number;
|
|
18
|
+
export declare function loggingEnabled(): boolean;
|
|
19
|
+
export declare function projectionPath(file: string): string;
|
|
20
|
+
export declare function fsyncMode(): "on" | "off" | "auto";
|
|
21
|
+
export declare function fsyncEnabled(type?: string): boolean;
|
|
22
|
+
export declare function createSessionLog(meta?: Record<string, any>): {
|
|
23
|
+
id: string;
|
|
24
|
+
file: string;
|
|
25
|
+
append: (entry: Record<string, any>) => number;
|
|
26
|
+
count(): number;
|
|
27
|
+
close(): void;
|
|
28
|
+
};
|
|
29
|
+
export declare function openSessionLog(file: string, meta?: Record<string, any>): {
|
|
30
|
+
id: string;
|
|
31
|
+
file: string;
|
|
32
|
+
append: (entry: Record<string, any>) => number;
|
|
33
|
+
count(): number;
|
|
34
|
+
close(): void;
|
|
35
|
+
};
|
|
36
|
+
export declare function listSessions(): {
|
|
37
|
+
id: string;
|
|
38
|
+
file: string;
|
|
39
|
+
bytes: number;
|
|
40
|
+
modified: string;
|
|
41
|
+
messages: number;
|
|
42
|
+
}[];
|
|
43
|
+
export declare function resolveSessionFile(idOrFile: string): string;
|
|
44
|
+
export declare function readSession(idOrFile: string): any[];
|
|
45
|
+
export declare function loadSessionMessages(idOrFile: string): {
|
|
46
|
+
role: any;
|
|
47
|
+
content: any;
|
|
48
|
+
}[];
|
|
49
|
+
export declare function latestSessionFile(): string | undefined;
|
|
50
|
+
export declare function findUnclosedSessions(): SessionSummary[];
|
|
51
|
+
export declare function latestUnclosedSession(): SessionSummary | undefined;
|
|
52
|
+
export declare function pruneSessions(limit?: number): number;
|