@proxysoul/soulforge 2.15.1 → 2.15.2
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/dist/index.js +1637 -610
- package/dist/workers/io.worker.js +522 -89
- package/package.json +1 -1
|
@@ -49517,12 +49517,148 @@ var init_dist8 = __esm(() => {
|
|
|
49517
49517
|
openai = createOpenAI();
|
|
49518
49518
|
});
|
|
49519
49519
|
|
|
49520
|
+
// src/core/utils/ensure-soulforge-dir.ts
|
|
49521
|
+
import { execSync } from "child_process";
|
|
49522
|
+
import { appendFileSync, existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
49523
|
+
import { join as join6 } from "path";
|
|
49524
|
+
function ensureSoulforgeDir(cwd) {
|
|
49525
|
+
const dir = join6(cwd, ENTRY);
|
|
49526
|
+
if (!existsSync2(dir))
|
|
49527
|
+
mkdirSync2(dir, {
|
|
49528
|
+
recursive: true
|
|
49529
|
+
});
|
|
49530
|
+
if (!patched.has(cwd)) {
|
|
49531
|
+
patched.add(cwd);
|
|
49532
|
+
try {
|
|
49533
|
+
ensureGitignore(cwd);
|
|
49534
|
+
} catch {}
|
|
49535
|
+
}
|
|
49536
|
+
return dir;
|
|
49537
|
+
}
|
|
49538
|
+
function ensureGitignore(cwd) {
|
|
49539
|
+
const status = gitCheckIgnoreStatus(cwd);
|
|
49540
|
+
if (status !== 1)
|
|
49541
|
+
return;
|
|
49542
|
+
const gitignorePath = join6(cwd, ".gitignore");
|
|
49543
|
+
if (existsSync2(gitignorePath)) {
|
|
49544
|
+
const content = readFileSync2(gitignorePath, "utf-8");
|
|
49545
|
+
const eol = content.includes(`\r
|
|
49546
|
+
`) ? `\r
|
|
49547
|
+
` : `
|
|
49548
|
+
`;
|
|
49549
|
+
const prefix = content.length > 0 && !content.endsWith(`
|
|
49550
|
+
`) ? eol : "";
|
|
49551
|
+
appendFileSync(gitignorePath, `${prefix}.soulforge${eol}`);
|
|
49552
|
+
} else {
|
|
49553
|
+
writeFileSync2(gitignorePath, `.soulforge
|
|
49554
|
+
`);
|
|
49555
|
+
}
|
|
49556
|
+
}
|
|
49557
|
+
function gitCheckIgnoreStatus(cwd) {
|
|
49558
|
+
try {
|
|
49559
|
+
execSync("git check-ignore -q .soulforge", {
|
|
49560
|
+
cwd,
|
|
49561
|
+
stdio: "pipe",
|
|
49562
|
+
timeout: 3000
|
|
49563
|
+
});
|
|
49564
|
+
return 0;
|
|
49565
|
+
} catch (err) {
|
|
49566
|
+
return err.status ?? 128;
|
|
49567
|
+
}
|
|
49568
|
+
}
|
|
49569
|
+
var ENTRY = ".soulforge", patched;
|
|
49570
|
+
var init_ensure_soulforge_dir = __esm(() => {
|
|
49571
|
+
patched = new Set;
|
|
49572
|
+
});
|
|
49573
|
+
|
|
49574
|
+
// src/config/index.ts
|
|
49575
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
49576
|
+
import { homedir as homedir4 } from "os";
|
|
49577
|
+
import { join as join7 } from "path";
|
|
49578
|
+
function loadConfig() {
|
|
49579
|
+
if (!existsSync3(CONFIG_DIR)) {
|
|
49580
|
+
mkdirSync3(CONFIG_DIR, {
|
|
49581
|
+
recursive: true,
|
|
49582
|
+
mode: 448
|
|
49583
|
+
});
|
|
49584
|
+
}
|
|
49585
|
+
if (!existsSync3(CONFIG_FILE)) {
|
|
49586
|
+
writeFileSync3(CONFIG_FILE, JSON.stringify(DEFAULT_CONFIG, null, 2));
|
|
49587
|
+
return DEFAULT_CONFIG;
|
|
49588
|
+
}
|
|
49589
|
+
try {
|
|
49590
|
+
const raw = readFileSync3(CONFIG_FILE, "utf-8");
|
|
49591
|
+
return {
|
|
49592
|
+
...DEFAULT_CONFIG,
|
|
49593
|
+
...JSON.parse(raw)
|
|
49594
|
+
};
|
|
49595
|
+
} catch (err) {
|
|
49596
|
+
logBackgroundError("config", `Failed to parse ${CONFIG_FILE}: ${err instanceof Error ? err.message : String(err)} \u2014 using defaults`);
|
|
49597
|
+
return DEFAULT_CONFIG;
|
|
49598
|
+
}
|
|
49599
|
+
}
|
|
49600
|
+
function loadProjectConfig(cwd) {
|
|
49601
|
+
const projectFile = join7(cwd, ".soulforge", "config.json");
|
|
49602
|
+
if (!existsSync3(projectFile))
|
|
49603
|
+
return null;
|
|
49604
|
+
try {
|
|
49605
|
+
const raw = readFileSync3(projectFile, "utf-8");
|
|
49606
|
+
return JSON.parse(raw);
|
|
49607
|
+
} catch (err) {
|
|
49608
|
+
logBackgroundError("config", `Failed to parse ${projectFile}: ${err instanceof Error ? err.message : String(err)} \u2014 ignoring project config`);
|
|
49609
|
+
return null;
|
|
49610
|
+
}
|
|
49611
|
+
}
|
|
49612
|
+
var CONFIG_DIR, CONFIG_FILE, DEFAULT_CONFIG;
|
|
49613
|
+
var init_config = __esm(() => {
|
|
49614
|
+
init_ensure_soulforge_dir();
|
|
49615
|
+
init_errors4();
|
|
49616
|
+
CONFIG_DIR = join7(homedir4(), ".soulforge");
|
|
49617
|
+
CONFIG_FILE = join7(CONFIG_DIR, "config.json");
|
|
49618
|
+
DEFAULT_CONFIG = {
|
|
49619
|
+
defaultModel: "none",
|
|
49620
|
+
routerRules: [],
|
|
49621
|
+
editor: {
|
|
49622
|
+
command: "nvim",
|
|
49623
|
+
args: []
|
|
49624
|
+
},
|
|
49625
|
+
theme: {
|
|
49626
|
+
name: "dark",
|
|
49627
|
+
transparent: true
|
|
49628
|
+
},
|
|
49629
|
+
nvimConfig: "default",
|
|
49630
|
+
editorIntegration: {
|
|
49631
|
+
diagnostics: true,
|
|
49632
|
+
symbols: true,
|
|
49633
|
+
hover: true,
|
|
49634
|
+
references: true,
|
|
49635
|
+
definition: true,
|
|
49636
|
+
codeActions: true,
|
|
49637
|
+
editorContext: true,
|
|
49638
|
+
rename: true,
|
|
49639
|
+
lspStatus: true,
|
|
49640
|
+
format: true,
|
|
49641
|
+
syncEditorOnEdit: false
|
|
49642
|
+
},
|
|
49643
|
+
codeExecution: true,
|
|
49644
|
+
webSearch: true,
|
|
49645
|
+
compaction: {
|
|
49646
|
+
strategy: "v2",
|
|
49647
|
+
triggerThreshold: 0.7,
|
|
49648
|
+
resetThreshold: 0.4,
|
|
49649
|
+
keepRecent: 4,
|
|
49650
|
+
maxToolResults: 30,
|
|
49651
|
+
llmExtraction: true
|
|
49652
|
+
}
|
|
49653
|
+
};
|
|
49654
|
+
});
|
|
49655
|
+
|
|
49520
49656
|
// package.json
|
|
49521
49657
|
var package_default;
|
|
49522
49658
|
var init_package = __esm(() => {
|
|
49523
49659
|
package_default = {
|
|
49524
49660
|
name: "@proxysoul/soulforge",
|
|
49525
|
-
version: "2.15.
|
|
49661
|
+
version: "2.15.2",
|
|
49526
49662
|
description: "Graph-powered code intelligence \u2014 multi-agent coding with codebase-aware AI",
|
|
49527
49663
|
repository: {
|
|
49528
49664
|
type: "git",
|
|
@@ -49625,19 +49761,97 @@ var init_package = __esm(() => {
|
|
|
49625
49761
|
});
|
|
49626
49762
|
|
|
49627
49763
|
// src/core/version.ts
|
|
49628
|
-
import { homedir as
|
|
49629
|
-
import { join as
|
|
49630
|
-
var
|
|
49764
|
+
import { homedir as homedir5 } from "os";
|
|
49765
|
+
import { join as join8 } from "path";
|
|
49766
|
+
var CONFIG_DIR2, VERSION_CACHE_FILE, CACHE_TTL, DISMISSED_FILE, _currentVersion, CURRENT_VERSION;
|
|
49631
49767
|
var init_version = __esm(() => {
|
|
49632
49768
|
init_package();
|
|
49633
|
-
|
|
49634
|
-
VERSION_CACHE_FILE =
|
|
49769
|
+
CONFIG_DIR2 = join8(homedir5(), ".soulforge");
|
|
49770
|
+
VERSION_CACHE_FILE = join8(CONFIG_DIR2, "version-cache.json");
|
|
49635
49771
|
CACHE_TTL = 30 * 60 * 1000;
|
|
49636
|
-
DISMISSED_FILE =
|
|
49772
|
+
DISMISSED_FILE = join8(CONFIG_DIR2, "update-dismissed.json");
|
|
49637
49773
|
_currentVersion = package_default.version ?? "0.0.0";
|
|
49638
49774
|
CURRENT_VERSION = _currentVersion;
|
|
49639
49775
|
});
|
|
49640
49776
|
|
|
49777
|
+
// src/core/llm/compat-reasoning.ts
|
|
49778
|
+
function parseProvider(modelId) {
|
|
49779
|
+
const slash = modelId.indexOf("/");
|
|
49780
|
+
if (slash === -1)
|
|
49781
|
+
return {
|
|
49782
|
+
provider: "",
|
|
49783
|
+
model: modelId
|
|
49784
|
+
};
|
|
49785
|
+
return {
|
|
49786
|
+
provider: modelId.slice(0, slash),
|
|
49787
|
+
model: modelId.slice(slash + 1)
|
|
49788
|
+
};
|
|
49789
|
+
}
|
|
49790
|
+
function baseModel(modelId) {
|
|
49791
|
+
const slash = modelId.lastIndexOf("/");
|
|
49792
|
+
return (slash >= 0 ? modelId.slice(slash + 1) : modelId).toLowerCase();
|
|
49793
|
+
}
|
|
49794
|
+
function getCompatReasoningBody(modelId, config2) {
|
|
49795
|
+
const {
|
|
49796
|
+
provider
|
|
49797
|
+
} = parseProvider(modelId);
|
|
49798
|
+
if (!COMPAT_PROVIDERS.has(provider))
|
|
49799
|
+
return {};
|
|
49800
|
+
const base = baseModel(modelId);
|
|
49801
|
+
let effort = config2.performance?.compatReasoningEffort;
|
|
49802
|
+
if (provider === "groq") {
|
|
49803
|
+
const g = config2.performance?.groqReasoningEffort;
|
|
49804
|
+
if (g)
|
|
49805
|
+
effort = g === "off" ? "off" : g;
|
|
49806
|
+
}
|
|
49807
|
+
if (!effort || effort === "off") {
|
|
49808
|
+
const e = config2.performance?.effort;
|
|
49809
|
+
if (e && e !== "off") {
|
|
49810
|
+
effort = e === "max" ? "xhigh" : e;
|
|
49811
|
+
}
|
|
49812
|
+
}
|
|
49813
|
+
if (!effort || effort === "off")
|
|
49814
|
+
return {};
|
|
49815
|
+
const isClaude = base.startsWith("claude");
|
|
49816
|
+
if (isClaude && provider === "opencode-zen") {
|
|
49817
|
+
const explicitBudget = config2.thinking?.budgetTokens;
|
|
49818
|
+
const budget = explicitBudget ?? {
|
|
49819
|
+
low: 2048,
|
|
49820
|
+
medium: 5000,
|
|
49821
|
+
high: 1e4,
|
|
49822
|
+
xhigh: 20000
|
|
49823
|
+
}[effort] ?? 5000;
|
|
49824
|
+
return {
|
|
49825
|
+
thinking: {
|
|
49826
|
+
type: "enabled",
|
|
49827
|
+
budget_tokens: budget
|
|
49828
|
+
}
|
|
49829
|
+
};
|
|
49830
|
+
}
|
|
49831
|
+
if (isClaude && provider !== "proxy") {
|
|
49832
|
+
return {};
|
|
49833
|
+
}
|
|
49834
|
+
if (provider === "groq" && /qwen3/.test(base)) {
|
|
49835
|
+
return {
|
|
49836
|
+
reasoning_effort: "default"
|
|
49837
|
+
};
|
|
49838
|
+
}
|
|
49839
|
+
const isDashscope = /qwen|glm-|kimi-/.test(base);
|
|
49840
|
+
const body = {
|
|
49841
|
+
reasoning_effort: effort,
|
|
49842
|
+
reasoning: {
|
|
49843
|
+
effort
|
|
49844
|
+
}
|
|
49845
|
+
};
|
|
49846
|
+
if (isDashscope)
|
|
49847
|
+
body.enable_thinking = true;
|
|
49848
|
+
return body;
|
|
49849
|
+
}
|
|
49850
|
+
var COMPAT_PROVIDERS;
|
|
49851
|
+
var init_compat_reasoning = __esm(() => {
|
|
49852
|
+
COMPAT_PROVIDERS = new Set(["deepseek", "groq", "fireworks", "minimax", "copilot", "github-models", "opencode-go", "opencode-zen", "lmstudio", "ollama", "proxy"]);
|
|
49853
|
+
});
|
|
49854
|
+
|
|
49641
49855
|
// src/core/llm/providers/copilot.ts
|
|
49642
49856
|
async function exchangeToken(githubToken) {
|
|
49643
49857
|
if (cachedBearer && Date.now() / 1000 < cachedBearer.expiresAt - 60) {
|
|
@@ -49697,7 +49911,8 @@ function detectInitiator(body) {
|
|
|
49697
49911
|
} catch {}
|
|
49698
49912
|
return "user";
|
|
49699
49913
|
}
|
|
49700
|
-
function createCopilotFetch(githubToken) {
|
|
49914
|
+
function createCopilotFetch(githubToken, reasoningBody) {
|
|
49915
|
+
const injectReasoning = Object.keys(reasoningBody).length > 0;
|
|
49701
49916
|
return async (url2, init) => {
|
|
49702
49917
|
let bearer;
|
|
49703
49918
|
try {
|
|
@@ -49706,15 +49921,26 @@ function createCopilotFetch(githubToken) {
|
|
|
49706
49921
|
invalidateBearer();
|
|
49707
49922
|
bearer = await exchangeToken(githubToken);
|
|
49708
49923
|
}
|
|
49924
|
+
let patchedBody = init?.body;
|
|
49925
|
+
if (injectReasoning && typeof init?.body === "string") {
|
|
49926
|
+
try {
|
|
49927
|
+
const parsed = JSON.parse(init.body);
|
|
49928
|
+
patchedBody = JSON.stringify({
|
|
49929
|
+
...parsed,
|
|
49930
|
+
...reasoningBody
|
|
49931
|
+
});
|
|
49932
|
+
} catch {}
|
|
49933
|
+
}
|
|
49709
49934
|
const buildHeaders = (token) => {
|
|
49710
49935
|
const h = new Headers(init?.headers);
|
|
49711
49936
|
h.set("Authorization", `Bearer ${token}`);
|
|
49712
49937
|
h.set("X-Request-Id", crypto.randomUUID());
|
|
49713
|
-
h.set("X-Initiator", detectInitiator(
|
|
49938
|
+
h.set("X-Initiator", detectInitiator(patchedBody));
|
|
49714
49939
|
return h;
|
|
49715
49940
|
};
|
|
49716
49941
|
const res = await fetch(url2, {
|
|
49717
49942
|
...init,
|
|
49943
|
+
body: patchedBody,
|
|
49718
49944
|
headers: buildHeaders(bearer)
|
|
49719
49945
|
});
|
|
49720
49946
|
if (res.status === 401) {
|
|
@@ -49722,6 +49948,7 @@ function createCopilotFetch(githubToken) {
|
|
|
49722
49948
|
const retryBearer = await exchangeToken(githubToken);
|
|
49723
49949
|
return fetch(url2, {
|
|
49724
49950
|
...init,
|
|
49951
|
+
body: patchedBody,
|
|
49725
49952
|
headers: buildHeaders(retryBearer)
|
|
49726
49953
|
});
|
|
49727
49954
|
}
|
|
@@ -49740,7 +49967,8 @@ function assertChatCompletionsSupported(modelId) {
|
|
|
49740
49967
|
function createCopilotModel(modelId) {
|
|
49741
49968
|
assertChatCompletionsSupported(modelId);
|
|
49742
49969
|
const githubToken = getGitHubToken();
|
|
49743
|
-
const
|
|
49970
|
+
const reasoningBody = getCompatReasoningBody(`copilot/${modelId}`, loadConfig());
|
|
49971
|
+
const copilotFetch = createCopilotFetch(githubToken, reasoningBody);
|
|
49744
49972
|
const client = createOpenAI({
|
|
49745
49973
|
baseURL: COPILOT_API,
|
|
49746
49974
|
apiKey: "copilot",
|
|
@@ -49754,8 +49982,10 @@ function createCopilotModel(modelId) {
|
|
|
49754
49982
|
var ENV_VAR = "COPILOT_API_KEY", COPILOT_API = "https://api.githubcopilot.com", TOKEN_EXCHANGE = "https://api.github.com/copilot_internal/v2/token", COPILOT_CHAT_VERSION = "0.26.7", COPILOT_API_VERSION = "2025-04-01", COPILOT_HEADERS, cachedBearer = null, bearerInflight = null, supportedEndpoints, copilot;
|
|
49755
49983
|
var init_copilot = __esm(() => {
|
|
49756
49984
|
init_dist8();
|
|
49985
|
+
init_config();
|
|
49757
49986
|
init_secrets();
|
|
49758
49987
|
init_version();
|
|
49988
|
+
init_compat_reasoning();
|
|
49759
49989
|
COPILOT_HEADERS = {
|
|
49760
49990
|
"Editor-Version": "vscode/1.95.0",
|
|
49761
49991
|
"Editor-Plugin-Version": `copilot-chat/${COPILOT_CHAT_VERSION}`,
|
|
@@ -51409,6 +51639,33 @@ var init_dist9 = __esm(() => {
|
|
|
51409
51639
|
});
|
|
51410
51640
|
});
|
|
51411
51641
|
|
|
51642
|
+
// src/core/llm/providers/reasoning-fetch.ts
|
|
51643
|
+
function createReasoningFetchWrapper(reasoningBody) {
|
|
51644
|
+
if (Object.keys(reasoningBody).length === 0) {
|
|
51645
|
+
return;
|
|
51646
|
+
}
|
|
51647
|
+
return async (input, init) => {
|
|
51648
|
+
if (!init?.body || typeof init.body !== "string") {
|
|
51649
|
+
return fetch(input, init);
|
|
51650
|
+
}
|
|
51651
|
+
let parsed;
|
|
51652
|
+
try {
|
|
51653
|
+
parsed = JSON.parse(init.body);
|
|
51654
|
+
} catch {
|
|
51655
|
+
return fetch(input, init);
|
|
51656
|
+
}
|
|
51657
|
+
const merged = {
|
|
51658
|
+
...parsed,
|
|
51659
|
+
...reasoningBody
|
|
51660
|
+
};
|
|
51661
|
+
const patchedInit = {
|
|
51662
|
+
...init,
|
|
51663
|
+
body: JSON.stringify(merged)
|
|
51664
|
+
};
|
|
51665
|
+
return fetch(input, patchedInit);
|
|
51666
|
+
};
|
|
51667
|
+
}
|
|
51668
|
+
|
|
51412
51669
|
// src/core/llm/providers/custom.ts
|
|
51413
51670
|
var init_custom = __esm(() => {
|
|
51414
51671
|
init_secrets();
|
|
@@ -51418,7 +51675,9 @@ var init_custom = __esm(() => {
|
|
|
51418
51675
|
var deepseek;
|
|
51419
51676
|
var init_deepseek = __esm(() => {
|
|
51420
51677
|
init_dist9();
|
|
51678
|
+
init_config();
|
|
51421
51679
|
init_secrets();
|
|
51680
|
+
init_compat_reasoning();
|
|
51422
51681
|
deepseek = {
|
|
51423
51682
|
id: "deepseek",
|
|
51424
51683
|
name: "DeepSeek",
|
|
@@ -51433,10 +51692,15 @@ var init_deepseek = __esm(() => {
|
|
|
51433
51692
|
if (!apiKey) {
|
|
51434
51693
|
throw new Error("DEEPSEEK_API_KEY is not set");
|
|
51435
51694
|
}
|
|
51695
|
+
const reasoningBody = getCompatReasoningBody(`deepseek/${modelId}`, loadConfig());
|
|
51696
|
+
const reasoningFetch = createReasoningFetchWrapper(reasoningBody);
|
|
51436
51697
|
const provider = createOpenAICompatible({
|
|
51437
51698
|
name: "deepseek",
|
|
51438
51699
|
baseURL: "https://api.deepseek.com/v1",
|
|
51439
|
-
apiKey
|
|
51700
|
+
apiKey,
|
|
51701
|
+
...reasoningFetch ? {
|
|
51702
|
+
fetch: reasoningFetch
|
|
51703
|
+
} : {}
|
|
51440
51704
|
});
|
|
51441
51705
|
return provider.chatModel(modelId);
|
|
51442
51706
|
},
|
|
@@ -51789,7 +52053,9 @@ var init_dist10 = __esm(() => {
|
|
|
51789
52053
|
var fireworks2;
|
|
51790
52054
|
var init_fireworks = __esm(() => {
|
|
51791
52055
|
init_dist10();
|
|
52056
|
+
init_config();
|
|
51792
52057
|
init_secrets();
|
|
52058
|
+
init_compat_reasoning();
|
|
51793
52059
|
fireworks2 = {
|
|
51794
52060
|
id: "fireworks",
|
|
51795
52061
|
name: "Fireworks",
|
|
@@ -51804,8 +52070,13 @@ var init_fireworks = __esm(() => {
|
|
|
51804
52070
|
if (!apiKey) {
|
|
51805
52071
|
throw new Error("FIREWORKS_API_KEY is not set");
|
|
51806
52072
|
}
|
|
52073
|
+
const reasoningBody = getCompatReasoningBody(`fireworks/${modelId}`, loadConfig());
|
|
52074
|
+
const reasoningFetch = createReasoningFetchWrapper(reasoningBody);
|
|
51807
52075
|
return createFireworks({
|
|
51808
|
-
apiKey
|
|
52076
|
+
apiKey,
|
|
52077
|
+
...reasoningFetch ? {
|
|
52078
|
+
fetch: reasoningFetch
|
|
52079
|
+
} : {}
|
|
51809
52080
|
})(modelId);
|
|
51810
52081
|
},
|
|
51811
52082
|
async fetchModels() {
|
|
@@ -51846,7 +52117,9 @@ var init_fireworks = __esm(() => {
|
|
|
51846
52117
|
var ENV_VAR2 = "GITHUB_MODELS_API_KEY", BASE_URL = "https://models.github.ai/inference", CATALOG_URL = "https://models.github.ai/catalog/models", GH_HEADERS, githubModels;
|
|
51847
52118
|
var init_github_models = __esm(() => {
|
|
51848
52119
|
init_dist8();
|
|
52120
|
+
init_config();
|
|
51849
52121
|
init_secrets();
|
|
52122
|
+
init_compat_reasoning();
|
|
51850
52123
|
GH_HEADERS = {
|
|
51851
52124
|
"X-GitHub-Api-Version": "2026-03-10",
|
|
51852
52125
|
Accept: "application/vnd.github+json"
|
|
@@ -51865,10 +52138,15 @@ var init_github_models = __esm(() => {
|
|
|
51865
52138
|
if (!apiKey) {
|
|
51866
52139
|
throw new Error(`${ENV_VAR2} is not set. Create a fine-grained PAT with models:read at github.com/settings/tokens`);
|
|
51867
52140
|
}
|
|
52141
|
+
const reasoningBody = getCompatReasoningBody(`github-models/${modelId}`, loadConfig());
|
|
52142
|
+
const reasoningFetch = createReasoningFetchWrapper(reasoningBody);
|
|
51868
52143
|
return createOpenAI({
|
|
51869
52144
|
baseURL: BASE_URL,
|
|
51870
52145
|
apiKey,
|
|
51871
|
-
headers: GH_HEADERS
|
|
52146
|
+
headers: GH_HEADERS,
|
|
52147
|
+
...reasoningFetch ? {
|
|
52148
|
+
fetch: reasoningFetch
|
|
52149
|
+
} : {}
|
|
51872
52150
|
}).chat(modelId);
|
|
51873
52151
|
},
|
|
51874
52152
|
async fetchModels() {
|
|
@@ -55549,7 +55827,9 @@ var init_dist12 = __esm(() => {
|
|
|
55549
55827
|
var groq2;
|
|
55550
55828
|
var init_groq = __esm(() => {
|
|
55551
55829
|
init_dist12();
|
|
55830
|
+
init_config();
|
|
55552
55831
|
init_secrets();
|
|
55832
|
+
init_compat_reasoning();
|
|
55553
55833
|
groq2 = {
|
|
55554
55834
|
id: "groq",
|
|
55555
55835
|
name: "Groq",
|
|
@@ -55564,8 +55844,13 @@ var init_groq = __esm(() => {
|
|
|
55564
55844
|
if (!apiKey) {
|
|
55565
55845
|
throw new Error("GROQ_API_KEY is not set");
|
|
55566
55846
|
}
|
|
55847
|
+
const reasoningBody = getCompatReasoningBody(`groq/${modelId}`, loadConfig());
|
|
55848
|
+
const reasoningFetch = createReasoningFetchWrapper(reasoningBody);
|
|
55567
55849
|
return createGroq({
|
|
55568
|
-
apiKey
|
|
55850
|
+
apiKey,
|
|
55851
|
+
...reasoningFetch ? {
|
|
55852
|
+
fetch: reasoningFetch
|
|
55853
|
+
} : {}
|
|
55569
55854
|
})(modelId);
|
|
55570
55855
|
},
|
|
55571
55856
|
async fetchModels() {
|
|
@@ -59187,6 +59472,8 @@ function authHeaders() {
|
|
|
59187
59472
|
var lmstudio;
|
|
59188
59473
|
var init_lmstudio = __esm(() => {
|
|
59189
59474
|
init_dist8();
|
|
59475
|
+
init_config();
|
|
59476
|
+
init_compat_reasoning();
|
|
59190
59477
|
lmstudio = {
|
|
59191
59478
|
id: "lmstudio",
|
|
59192
59479
|
name: "LM Studio",
|
|
@@ -59196,9 +59483,14 @@ var init_lmstudio = __esm(() => {
|
|
|
59196
59483
|
asciiIcon: "L",
|
|
59197
59484
|
description: "Local models via LM Studio \u2014 no key needed",
|
|
59198
59485
|
createModel(modelId) {
|
|
59486
|
+
const reasoningBody = getCompatReasoningBody(`lmstudio/${modelId}`, loadConfig());
|
|
59487
|
+
const reasoningFetch = createReasoningFetchWrapper(reasoningBody);
|
|
59199
59488
|
const client = createOpenAI({
|
|
59200
59489
|
baseURL: openaiBase(),
|
|
59201
|
-
apiKey: getApiToken()
|
|
59490
|
+
apiKey: getApiToken(),
|
|
59491
|
+
...reasoningFetch ? {
|
|
59492
|
+
fetch: reasoningFetch
|
|
59493
|
+
} : {}
|
|
59202
59494
|
});
|
|
59203
59495
|
return client.chat(modelId);
|
|
59204
59496
|
},
|
|
@@ -67456,7 +67748,9 @@ var init_dist19 = __esm(() => {
|
|
|
67456
67748
|
var minimax2;
|
|
67457
67749
|
var init_minimax = __esm(() => {
|
|
67458
67750
|
init_dist19();
|
|
67751
|
+
init_config();
|
|
67459
67752
|
init_secrets();
|
|
67753
|
+
init_compat_reasoning();
|
|
67460
67754
|
minimax2 = {
|
|
67461
67755
|
id: "minimax",
|
|
67462
67756
|
name: "MiniMax",
|
|
@@ -67471,8 +67765,13 @@ var init_minimax = __esm(() => {
|
|
|
67471
67765
|
if (!apiKey) {
|
|
67472
67766
|
throw new Error("MINIMAX_API_KEY is not set");
|
|
67473
67767
|
}
|
|
67768
|
+
const reasoningBody = getCompatReasoningBody(`minimax/${modelId}`, loadConfig());
|
|
67769
|
+
const reasoningFetch = createReasoningFetchWrapper(reasoningBody);
|
|
67474
67770
|
return createMinimaxAnthropic({
|
|
67475
|
-
apiKey
|
|
67771
|
+
apiKey,
|
|
67772
|
+
...reasoningFetch ? {
|
|
67773
|
+
fetch: reasoningFetch
|
|
67774
|
+
} : {}
|
|
67476
67775
|
})(modelId);
|
|
67477
67776
|
},
|
|
67478
67777
|
async fetchModels() {
|
|
@@ -68353,6 +68652,8 @@ function getOllamaHost() {
|
|
|
68353
68652
|
var ollama;
|
|
68354
68653
|
var init_ollama = __esm(() => {
|
|
68355
68654
|
init_dist8();
|
|
68655
|
+
init_config();
|
|
68656
|
+
init_compat_reasoning();
|
|
68356
68657
|
ollama = {
|
|
68357
68658
|
id: "ollama",
|
|
68358
68659
|
name: "Ollama",
|
|
@@ -68361,9 +68662,14 @@ var init_ollama = __esm(() => {
|
|
|
68361
68662
|
asciiIcon: "O",
|
|
68362
68663
|
description: "Local models \u2014 no key needed",
|
|
68363
68664
|
createModel(modelId) {
|
|
68665
|
+
const reasoningBody = getCompatReasoningBody(`ollama/${modelId}`, loadConfig());
|
|
68666
|
+
const reasoningFetch = createReasoningFetchWrapper(reasoningBody);
|
|
68364
68667
|
const client = createOpenAI({
|
|
68365
68668
|
baseURL: `${getOllamaHost()}/v1`,
|
|
68366
|
-
apiKey: "ollama"
|
|
68669
|
+
apiKey: "ollama",
|
|
68670
|
+
...reasoningFetch ? {
|
|
68671
|
+
fetch: reasoningFetch
|
|
68672
|
+
} : {}
|
|
68367
68673
|
});
|
|
68368
68674
|
return client.chat(modelId);
|
|
68369
68675
|
},
|
|
@@ -68478,7 +68784,9 @@ var init_openai = __esm(() => {
|
|
|
68478
68784
|
var BASE_URL2 = "https://opencode.ai/zen/go/v1", opencodeGo;
|
|
68479
68785
|
var init_opencode_go = __esm(() => {
|
|
68480
68786
|
init_dist9();
|
|
68787
|
+
init_config();
|
|
68481
68788
|
init_secrets();
|
|
68789
|
+
init_compat_reasoning();
|
|
68482
68790
|
opencodeGo = {
|
|
68483
68791
|
id: "opencode-go",
|
|
68484
68792
|
name: "OpenCode Go",
|
|
@@ -68493,10 +68801,15 @@ var init_opencode_go = __esm(() => {
|
|
|
68493
68801
|
if (!apiKey) {
|
|
68494
68802
|
throw new Error("OPENCODE_GO_API_KEY is not set");
|
|
68495
68803
|
}
|
|
68804
|
+
const reasoningBody = getCompatReasoningBody(`opencode-go/${modelId}`, loadConfig());
|
|
68805
|
+
const reasoningFetch = createReasoningFetchWrapper(reasoningBody);
|
|
68496
68806
|
const provider = createOpenAICompatible({
|
|
68497
68807
|
name: "opencode-go",
|
|
68498
68808
|
baseURL: BASE_URL2,
|
|
68499
|
-
apiKey
|
|
68809
|
+
apiKey,
|
|
68810
|
+
...reasoningFetch ? {
|
|
68811
|
+
fetch: reasoningFetch
|
|
68812
|
+
} : {}
|
|
68500
68813
|
});
|
|
68501
68814
|
return provider.chatModel(modelId);
|
|
68502
68815
|
},
|
|
@@ -68541,7 +68854,9 @@ var init_opencode_go = __esm(() => {
|
|
|
68541
68854
|
var BASE_URL3 = "https://opencode.ai/zen/v1", opencodeZen;
|
|
68542
68855
|
var init_opencode_zen = __esm(() => {
|
|
68543
68856
|
init_dist9();
|
|
68857
|
+
init_config();
|
|
68544
68858
|
init_secrets();
|
|
68859
|
+
init_compat_reasoning();
|
|
68545
68860
|
init_context_windows();
|
|
68546
68861
|
opencodeZen = {
|
|
68547
68862
|
id: "opencode-zen",
|
|
@@ -68558,10 +68873,15 @@ var init_opencode_zen = __esm(() => {
|
|
|
68558
68873
|
if (!apiKey) {
|
|
68559
68874
|
throw new Error("OPENCODE_ZEN_API_KEY is not set");
|
|
68560
68875
|
}
|
|
68876
|
+
const reasoningBody = getCompatReasoningBody(`opencode-zen/${modelId}`, loadConfig());
|
|
68877
|
+
const reasoningFetch = createReasoningFetchWrapper(reasoningBody);
|
|
68561
68878
|
const provider = createOpenAICompatible({
|
|
68562
68879
|
name: "opencode-zen",
|
|
68563
68880
|
baseURL: BASE_URL3,
|
|
68564
|
-
apiKey
|
|
68881
|
+
apiKey,
|
|
68882
|
+
...reasoningFetch ? {
|
|
68883
|
+
fetch: reasoningFetch
|
|
68884
|
+
} : {}
|
|
68565
68885
|
});
|
|
68566
68886
|
return provider.chatModel(modelId);
|
|
68567
68887
|
},
|
|
@@ -73621,11 +73941,11 @@ var init_openrouter = __esm(() => {
|
|
|
73621
73941
|
});
|
|
73622
73942
|
|
|
73623
73943
|
// src/core/proxy/key-resolver.ts
|
|
73624
|
-
import { existsSync as
|
|
73625
|
-
import { homedir as
|
|
73626
|
-
import { join as
|
|
73944
|
+
import { existsSync as existsSync4, readFileSync as readFileSync4 } from "fs";
|
|
73945
|
+
import { homedir as homedir6 } from "os";
|
|
73946
|
+
import { join as join9 } from "path";
|
|
73627
73947
|
function candidateConfigPaths() {
|
|
73628
|
-
const paths = [process.env.PROXY_CONFIG_PATH,
|
|
73948
|
+
const paths = [process.env.PROXY_CONFIG_PATH, join9(homedir6(), ".soulforge", "proxy", "config.yaml"), "/opt/homebrew/etc/cliproxyapi.conf", "/opt/homebrew/etc/cliproxyapi/config.yaml", "/usr/local/etc/cliproxyapi.conf", "/usr/local/etc/cliproxyapi/config.yaml", "/etc/cliproxyapi.conf", "/etc/cliproxyapi/config.yaml", join9(homedir6(), ".config", "cliproxyapi", "config.yaml"), join9(homedir6(), ".cli-proxy-api", "config.yaml")];
|
|
73629
73949
|
return paths.filter((p) => typeof p === "string" && p.length > 0);
|
|
73630
73950
|
}
|
|
73631
73951
|
function isPlausibleKey(value) {
|
|
@@ -73681,9 +74001,9 @@ function discoverApiKeys() {
|
|
|
73681
74001
|
const seen = new Set;
|
|
73682
74002
|
for (const path of candidateConfigPaths()) {
|
|
73683
74003
|
try {
|
|
73684
|
-
if (!
|
|
74004
|
+
if (!existsSync4(path))
|
|
73685
74005
|
continue;
|
|
73686
|
-
const content =
|
|
74006
|
+
const content = readFileSync4(path, "utf-8");
|
|
73687
74007
|
for (const k of parseApiKeys(content)) {
|
|
73688
74008
|
if (!isPlausibleKey(k))
|
|
73689
74009
|
continue;
|
|
@@ -73702,9 +74022,9 @@ function discoverApiKeys() {
|
|
|
73702
74022
|
function primaryConfigPath() {
|
|
73703
74023
|
for (const path of candidateConfigPaths()) {
|
|
73704
74024
|
try {
|
|
73705
|
-
if (!
|
|
74025
|
+
if (!existsSync4(path))
|
|
73706
74026
|
continue;
|
|
73707
|
-
const content =
|
|
74027
|
+
const content = readFileSync4(path, "utf-8");
|
|
73708
74028
|
if (/^api-keys\s*:\s*$/m.test(content))
|
|
73709
74029
|
return path;
|
|
73710
74030
|
} catch {}
|
|
@@ -73744,10 +74064,10 @@ var init_key_resolver = __esm(() => {
|
|
|
73744
74064
|
});
|
|
73745
74065
|
|
|
73746
74066
|
// src/core/setup/install.ts
|
|
73747
|
-
import { execSync } from "child_process";
|
|
73748
|
-
import { existsSync as
|
|
73749
|
-
import { homedir as
|
|
73750
|
-
import { join as
|
|
74067
|
+
import { execSync as execSync2 } from "child_process";
|
|
74068
|
+
import { existsSync as existsSync5, mkdirSync as mkdirSync4, readdirSync as readdirSync2, symlinkSync, unlinkSync } from "fs";
|
|
74069
|
+
import { homedir as homedir7, platform } from "os";
|
|
74070
|
+
import { join as join10 } from "path";
|
|
73751
74071
|
async function fetchLatestProxyVersion(timeoutMs = 5000) {
|
|
73752
74072
|
try {
|
|
73753
74073
|
const ctl = new AbortController;
|
|
@@ -73787,49 +74107,49 @@ async function installBinary(config2) {
|
|
|
73787
74107
|
ensureDirs();
|
|
73788
74108
|
const key = getPlatformKey();
|
|
73789
74109
|
const asset = config2.getAsset(key);
|
|
73790
|
-
const extractDir =
|
|
73791
|
-
if (!
|
|
74110
|
+
const extractDir = join10(INSTALLS_DIR, `${config2.name}-${config2.version}`);
|
|
74111
|
+
if (!existsSync5(asset.binPath)) {
|
|
73792
74112
|
await downloadAndExtract(asset.url, extractDir);
|
|
73793
74113
|
}
|
|
73794
|
-
if (!
|
|
74114
|
+
if (!existsSync5(asset.binPath)) {
|
|
73795
74115
|
throw new Error(`${config2.name} binary not found after extraction at ${asset.binPath}`);
|
|
73796
74116
|
}
|
|
73797
|
-
|
|
74117
|
+
execSync2(`chmod +x "${asset.binPath}"`, {
|
|
73798
74118
|
stdio: "ignore"
|
|
73799
74119
|
});
|
|
73800
|
-
createSymlink(asset.binPath,
|
|
73801
|
-
return
|
|
74120
|
+
createSymlink(asset.binPath, join10(BIN_DIR, config2.binName));
|
|
74121
|
+
return join10(BIN_DIR, config2.binName);
|
|
73802
74122
|
}
|
|
73803
74123
|
function getVendoredPath(binary) {
|
|
73804
|
-
const binLink =
|
|
73805
|
-
return
|
|
74124
|
+
const binLink = join10(BIN_DIR, binary);
|
|
74125
|
+
return existsSync5(binLink) ? binLink : null;
|
|
73806
74126
|
}
|
|
73807
74127
|
function ensureDirs() {
|
|
73808
|
-
|
|
74128
|
+
mkdirSync4(BIN_DIR, {
|
|
73809
74129
|
recursive: true
|
|
73810
74130
|
});
|
|
73811
|
-
|
|
74131
|
+
mkdirSync4(INSTALLS_DIR, {
|
|
73812
74132
|
recursive: true
|
|
73813
74133
|
});
|
|
73814
74134
|
}
|
|
73815
74135
|
async function downloadAndExtract(url2, extractDir) {
|
|
73816
|
-
|
|
74136
|
+
mkdirSync4(extractDir, {
|
|
73817
74137
|
recursive: true
|
|
73818
74138
|
});
|
|
73819
74139
|
const response = await fetch(url2);
|
|
73820
74140
|
if (!response.ok) {
|
|
73821
74141
|
throw new Error(`Download failed: ${response.status} ${response.statusText} (${url2})`);
|
|
73822
74142
|
}
|
|
73823
|
-
const tmpFile =
|
|
74143
|
+
const tmpFile = join10(extractDir, "download.tar.gz");
|
|
73824
74144
|
const buffer = await response.arrayBuffer();
|
|
73825
74145
|
await Bun.write(tmpFile, buffer);
|
|
73826
|
-
|
|
74146
|
+
execSync2(`tar xzf "${tmpFile}" -C "${extractDir}"`, {
|
|
73827
74147
|
stdio: "ignore"
|
|
73828
74148
|
});
|
|
73829
74149
|
unlinkSync(tmpFile);
|
|
73830
74150
|
}
|
|
73831
74151
|
function createSymlink(target, link) {
|
|
73832
|
-
if (
|
|
74152
|
+
if (existsSync5(link)) {
|
|
73833
74153
|
unlinkSync(link);
|
|
73834
74154
|
}
|
|
73835
74155
|
symlinkSync(target, link);
|
|
@@ -73838,7 +74158,7 @@ async function installProxy(version2) {
|
|
|
73838
74158
|
const v = version2 ?? await resolveProxyVersion();
|
|
73839
74159
|
const buildAsset = (suffix) => ({
|
|
73840
74160
|
url: `https://github.com/router-for-me/CLIProxyAPI/releases/download/v${v}/CLIProxyAPI_${v}_${suffix}.tar.gz`,
|
|
73841
|
-
binPath:
|
|
74161
|
+
binPath: join10(INSTALLS_DIR, `cliproxyapi-${v}`, "cli-proxy-api")
|
|
73842
74162
|
});
|
|
73843
74163
|
try {
|
|
73844
74164
|
const path = await installBinary({
|
|
@@ -73870,10 +74190,10 @@ async function installProxy(version2) {
|
|
|
73870
74190
|
}
|
|
73871
74191
|
var SOULFORGE_DIR, BIN_DIR, INSTALLS_DIR, FONTS_DIR, FALLBACK_PROXY_VERSION = "6.9.29", PROXY_RELEASES_URL = "https://api.github.com/repos/router-for-me/CLIProxyAPI/releases/latest", PROXY_SUFFIXES, PROXY_SUFFIXES_LEGACY;
|
|
73872
74192
|
var init_install = __esm(() => {
|
|
73873
|
-
SOULFORGE_DIR =
|
|
73874
|
-
BIN_DIR =
|
|
73875
|
-
INSTALLS_DIR =
|
|
73876
|
-
FONTS_DIR =
|
|
74193
|
+
SOULFORGE_DIR = join10(homedir7(), ".soulforge");
|
|
74194
|
+
BIN_DIR = join10(SOULFORGE_DIR, "bin");
|
|
74195
|
+
INSTALLS_DIR = join10(SOULFORGE_DIR, "installs");
|
|
74196
|
+
FONTS_DIR = join10(SOULFORGE_DIR, "fonts");
|
|
73877
74197
|
PROXY_SUFFIXES = {
|
|
73878
74198
|
"darwin-arm64": "darwin_aarch64",
|
|
73879
74199
|
"darwin-x64": "darwin_amd64",
|
|
@@ -73889,10 +74209,10 @@ var init_install = __esm(() => {
|
|
|
73889
74209
|
});
|
|
73890
74210
|
|
|
73891
74211
|
// src/core/proxy/lifecycle.ts
|
|
73892
|
-
import { execFileSync, execSync as
|
|
73893
|
-
import { existsSync as
|
|
73894
|
-
import { homedir as
|
|
73895
|
-
import { join as
|
|
74212
|
+
import { execFileSync, execSync as execSync3, spawn as spawn4 } from "child_process";
|
|
74213
|
+
import { existsSync as existsSync6, mkdirSync as mkdirSync5, readdirSync as readdirSync3, readFileSync as readFileSync5, unlinkSync as unlinkSync2, writeFileSync as writeFileSync4 } from "fs";
|
|
74214
|
+
import { homedir as homedir8 } from "os";
|
|
74215
|
+
import { join as join11 } from "path";
|
|
73896
74216
|
function setState(state, error48 = null) {
|
|
73897
74217
|
currentState = state;
|
|
73898
74218
|
lastError = error48;
|
|
@@ -73900,10 +74220,10 @@ function setState(state, error48 = null) {
|
|
|
73900
74220
|
fn(state, error48);
|
|
73901
74221
|
}
|
|
73902
74222
|
function saveInstalledProxyVersion(version2) {
|
|
73903
|
-
|
|
74223
|
+
mkdirSync5(PROXY_CONFIG_DIR, {
|
|
73904
74224
|
recursive: true
|
|
73905
74225
|
});
|
|
73906
|
-
|
|
74226
|
+
writeFileSync4(VERSION_FILE, version2);
|
|
73907
74227
|
}
|
|
73908
74228
|
function stripLegacyPerfBlock(content) {
|
|
73909
74229
|
if (!content.includes(LEGACY_PERF_MARKER_PREFIX))
|
|
@@ -73921,25 +74241,25 @@ function stripLegacyPerfBlock(content) {
|
|
|
73921
74241
|
`);
|
|
73922
74242
|
}
|
|
73923
74243
|
function ensureConfig() {
|
|
73924
|
-
|
|
74244
|
+
mkdirSync5(PROXY_CONFIG_DIR, {
|
|
73925
74245
|
recursive: true
|
|
73926
74246
|
});
|
|
73927
|
-
if (!
|
|
73928
|
-
|
|
74247
|
+
if (!existsSync6(PROXY_CONFIG_PATH)) {
|
|
74248
|
+
writeFileSync4(PROXY_CONFIG_PATH, ["host: 127.0.0.1", "port: 8317", 'auth-dir: "~/.cli-proxy-api"', "api-keys:", ' - "soulforge"', ""].join(`
|
|
73929
74249
|
`));
|
|
73930
74250
|
return;
|
|
73931
74251
|
}
|
|
73932
74252
|
try {
|
|
73933
|
-
const existing =
|
|
74253
|
+
const existing = readFileSync5(PROXY_CONFIG_PATH, "utf-8");
|
|
73934
74254
|
const cleaned = stripLegacyPerfBlock(existing);
|
|
73935
74255
|
if (cleaned !== existing) {
|
|
73936
|
-
|
|
74256
|
+
writeFileSync4(PROXY_CONFIG_PATH, cleaned);
|
|
73937
74257
|
}
|
|
73938
74258
|
} catch {}
|
|
73939
74259
|
}
|
|
73940
74260
|
function commandExists(cmd) {
|
|
73941
74261
|
try {
|
|
73942
|
-
|
|
74262
|
+
execSync3(`command -v ${cmd}`, {
|
|
73943
74263
|
stdio: "ignore"
|
|
73944
74264
|
});
|
|
73945
74265
|
return true;
|
|
@@ -74224,11 +74544,11 @@ var init_lifecycle = __esm(() => {
|
|
|
74224
74544
|
init_install();
|
|
74225
74545
|
init_key_resolver();
|
|
74226
74546
|
PROXY_URL = process.env.PROXY_API_URL || "http://127.0.0.1:8317/v1";
|
|
74227
|
-
PROXY_CONFIG_DIR =
|
|
74228
|
-
PROXY_CONFIG_PATH =
|
|
74547
|
+
PROXY_CONFIG_DIR = join11(homedir8(), ".soulforge", "proxy");
|
|
74548
|
+
PROXY_CONFIG_PATH = join11(PROXY_CONFIG_DIR, "config.yaml");
|
|
74229
74549
|
stateListeners = new Set;
|
|
74230
|
-
VERSION_FILE =
|
|
74231
|
-
AUTH_DIR =
|
|
74550
|
+
VERSION_FILE = join11(PROXY_CONFIG_DIR, "version");
|
|
74551
|
+
AUTH_DIR = join11(homedir8(), ".cli-proxy-api");
|
|
74232
74552
|
VERSION_CACHE_TTL = 10 * 60 * 1000;
|
|
74233
74553
|
});
|
|
74234
74554
|
|
|
@@ -74240,8 +74560,10 @@ var baseURL, proxy;
|
|
|
74240
74560
|
var init_proxy = __esm(() => {
|
|
74241
74561
|
init_dist6();
|
|
74242
74562
|
init_dist8();
|
|
74563
|
+
init_config();
|
|
74243
74564
|
init_key_resolver();
|
|
74244
74565
|
init_lifecycle();
|
|
74566
|
+
init_compat_reasoning();
|
|
74245
74567
|
init_context_windows();
|
|
74246
74568
|
baseURL = process.env.PROXY_API_URL || "http://127.0.0.1:8317/v1";
|
|
74247
74569
|
proxy = {
|
|
@@ -74259,9 +74581,14 @@ var init_proxy = __esm(() => {
|
|
|
74259
74581
|
apiKey
|
|
74260
74582
|
})(modelId);
|
|
74261
74583
|
}
|
|
74584
|
+
const reasoningBody = getCompatReasoningBody(`proxy/${modelId}`, loadConfig());
|
|
74585
|
+
const reasoningFetch = createReasoningFetchWrapper(reasoningBody);
|
|
74262
74586
|
return createOpenAI({
|
|
74263
74587
|
baseURL,
|
|
74264
|
-
apiKey
|
|
74588
|
+
apiKey,
|
|
74589
|
+
...reasoningFetch ? {
|
|
74590
|
+
fetch: reasoningFetch
|
|
74591
|
+
} : {}
|
|
74265
74592
|
}).chat(modelId);
|
|
74266
74593
|
},
|
|
74267
74594
|
async fetchModels() {
|
|
@@ -77498,9 +77825,115 @@ function supportsTemperature(modelId) {
|
|
|
77498
77825
|
return true;
|
|
77499
77826
|
return v.major < 5 && (v.major < 4 || v.minor < 7);
|
|
77500
77827
|
}
|
|
77828
|
+
var NO_SUPPORT, ANTHROPIC_FULL, OPENAI_FULL, GOOGLE_FULL, XAI_FULL, DEEPSEEK_FULL, OPENROUTER_FULL, GATEWAY_FULL, COMPAT_ONLY, PROVIDER_CONSTRAINTS;
|
|
77501
77829
|
var init_provider_options = __esm(() => {
|
|
77502
77830
|
init_models();
|
|
77503
77831
|
init_providers();
|
|
77832
|
+
NO_SUPPORT = {
|
|
77833
|
+
anthropicOptions: false,
|
|
77834
|
+
openaiOptions: false,
|
|
77835
|
+
googleOptions: false,
|
|
77836
|
+
xaiOptions: false,
|
|
77837
|
+
deepseekOptions: false,
|
|
77838
|
+
openrouterOptions: false,
|
|
77839
|
+
bedrockOptions: false,
|
|
77840
|
+
effort: false,
|
|
77841
|
+
speed: false,
|
|
77842
|
+
contextManagement: false,
|
|
77843
|
+
adaptiveThinking: false,
|
|
77844
|
+
interleavedThinking: false,
|
|
77845
|
+
compatReasoningBody: false
|
|
77846
|
+
};
|
|
77847
|
+
ANTHROPIC_FULL = {
|
|
77848
|
+
...NO_SUPPORT,
|
|
77849
|
+
anthropicOptions: true,
|
|
77850
|
+
effort: true,
|
|
77851
|
+
speed: true,
|
|
77852
|
+
contextManagement: true,
|
|
77853
|
+
adaptiveThinking: true,
|
|
77854
|
+
interleavedThinking: true
|
|
77855
|
+
};
|
|
77856
|
+
OPENAI_FULL = {
|
|
77857
|
+
...NO_SUPPORT,
|
|
77858
|
+
openaiOptions: true
|
|
77859
|
+
};
|
|
77860
|
+
GOOGLE_FULL = {
|
|
77861
|
+
...NO_SUPPORT,
|
|
77862
|
+
googleOptions: true
|
|
77863
|
+
};
|
|
77864
|
+
XAI_FULL = {
|
|
77865
|
+
...NO_SUPPORT,
|
|
77866
|
+
xaiOptions: true
|
|
77867
|
+
};
|
|
77868
|
+
DEEPSEEK_FULL = {
|
|
77869
|
+
...NO_SUPPORT,
|
|
77870
|
+
deepseekOptions: true,
|
|
77871
|
+
compatReasoningBody: true
|
|
77872
|
+
};
|
|
77873
|
+
OPENROUTER_FULL = {
|
|
77874
|
+
...NO_SUPPORT,
|
|
77875
|
+
openrouterOptions: true,
|
|
77876
|
+
anthropicOptions: true,
|
|
77877
|
+
openaiOptions: true,
|
|
77878
|
+
googleOptions: true,
|
|
77879
|
+
xaiOptions: true,
|
|
77880
|
+
deepseekOptions: true,
|
|
77881
|
+
effort: true,
|
|
77882
|
+
speed: true,
|
|
77883
|
+
adaptiveThinking: true,
|
|
77884
|
+
interleavedThinking: true
|
|
77885
|
+
};
|
|
77886
|
+
GATEWAY_FULL = {
|
|
77887
|
+
anthropicOptions: true,
|
|
77888
|
+
openaiOptions: true,
|
|
77889
|
+
googleOptions: true,
|
|
77890
|
+
xaiOptions: true,
|
|
77891
|
+
deepseekOptions: true,
|
|
77892
|
+
openrouterOptions: false,
|
|
77893
|
+
bedrockOptions: false,
|
|
77894
|
+
effort: true,
|
|
77895
|
+
speed: true,
|
|
77896
|
+
contextManagement: true,
|
|
77897
|
+
adaptiveThinking: true,
|
|
77898
|
+
interleavedThinking: true,
|
|
77899
|
+
compatReasoningBody: false
|
|
77900
|
+
};
|
|
77901
|
+
COMPAT_ONLY = {
|
|
77902
|
+
...NO_SUPPORT,
|
|
77903
|
+
compatReasoningBody: true
|
|
77904
|
+
};
|
|
77905
|
+
PROVIDER_CONSTRAINTS = {
|
|
77906
|
+
anthropic: ANTHROPIC_FULL,
|
|
77907
|
+
proxy: GATEWAY_FULL,
|
|
77908
|
+
openai: OPENAI_FULL,
|
|
77909
|
+
xai: XAI_FULL,
|
|
77910
|
+
google: GOOGLE_FULL,
|
|
77911
|
+
deepseek: DEEPSEEK_FULL,
|
|
77912
|
+
openrouter: OPENROUTER_FULL,
|
|
77913
|
+
groq: COMPAT_ONLY,
|
|
77914
|
+
fireworks: COMPAT_ONLY,
|
|
77915
|
+
minimax: COMPAT_ONLY,
|
|
77916
|
+
copilot: COMPAT_ONLY,
|
|
77917
|
+
"github-models": COMPAT_ONLY,
|
|
77918
|
+
"opencode-zen": {
|
|
77919
|
+
...GATEWAY_FULL,
|
|
77920
|
+
compatReasoningBody: true
|
|
77921
|
+
},
|
|
77922
|
+
"opencode-go": COMPAT_ONLY,
|
|
77923
|
+
lmstudio: COMPAT_ONLY,
|
|
77924
|
+
ollama: COMPAT_ONLY,
|
|
77925
|
+
vercel_gateway: GATEWAY_FULL,
|
|
77926
|
+
llmgateway: GATEWAY_FULL,
|
|
77927
|
+
bedrock: {
|
|
77928
|
+
...NO_SUPPORT,
|
|
77929
|
+
bedrockOptions: true,
|
|
77930
|
+
effort: true,
|
|
77931
|
+
speed: false,
|
|
77932
|
+
contextManagement: false,
|
|
77933
|
+
adaptiveThinking: true,
|
|
77934
|
+
interleavedThinking: false
|
|
77935
|
+
}
|
|
77936
|
+
};
|
|
77504
77937
|
});
|
|
77505
77938
|
|
|
77506
77939
|
// src/core/compaction/summarize.ts
|
|
@@ -77649,9 +78082,9 @@ var init_summarize = __esm(() => {
|
|
|
77649
78082
|
});
|
|
77650
78083
|
|
|
77651
78084
|
// src/core/workers/io.worker.ts
|
|
77652
|
-
import { existsSync as
|
|
78085
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync6, readdirSync as readdirSync4, readFileSync as readFileSync6, statSync } from "fs";
|
|
77653
78086
|
import { readFile, rename, writeFile as writeFile2 } from "fs/promises";
|
|
77654
|
-
import { extname, join as
|
|
78087
|
+
import { extname, join as join12 } from "path";
|
|
77655
78088
|
|
|
77656
78089
|
// node_modules/isbinaryfile/lib/index.js
|
|
77657
78090
|
import { open, stat } from "fs/promises";
|
|
@@ -78025,8 +78458,8 @@ var handlers = {
|
|
|
78025
78458
|
const dir = sessionDir;
|
|
78026
78459
|
const sessionMeta = meta3;
|
|
78027
78460
|
const entries = tabEntries;
|
|
78028
|
-
if (!
|
|
78029
|
-
|
|
78461
|
+
if (!existsSync7(dir)) {
|
|
78462
|
+
mkdirSync6(dir, {
|
|
78030
78463
|
recursive: true,
|
|
78031
78464
|
mode: 448
|
|
78032
78465
|
});
|
|
@@ -78053,8 +78486,8 @@ var handlers = {
|
|
|
78053
78486
|
const metaJson = JSON.stringify(updatedMeta, null, 2);
|
|
78054
78487
|
const lines = allMessages.map((m) => JSON.stringify(m)).join(`
|
|
78055
78488
|
`);
|
|
78056
|
-
const metaPath =
|
|
78057
|
-
const jsonlPath =
|
|
78489
|
+
const metaPath = join12(dir, "meta.json");
|
|
78490
|
+
const jsonlPath = join12(dir, "messages.jsonl");
|
|
78058
78491
|
const suffix = `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
78059
78492
|
const metaTmp = `${metaPath}.${suffix}.tmp`;
|
|
78060
78493
|
const jsonlTmp = `${jsonlPath}.${suffix}.tmp`;
|
|
@@ -78075,7 +78508,7 @@ var handlers = {
|
|
|
78075
78508
|
for (const [tabId, msgs] of cores) {
|
|
78076
78509
|
coreData[tabId] = msgs;
|
|
78077
78510
|
}
|
|
78078
|
-
const corePath =
|
|
78511
|
+
const corePath = join12(dir, "core.json");
|
|
78079
78512
|
const coreTmp = `${corePath}.${suffix}.tmp`;
|
|
78080
78513
|
await writeFile2(coreTmp, JSON.stringify(coreData), {
|
|
78081
78514
|
encoding: "utf-8",
|
|
@@ -78086,14 +78519,14 @@ var handlers = {
|
|
|
78086
78519
|
},
|
|
78087
78520
|
loadSession: async (sessionDir) => {
|
|
78088
78521
|
const dir = sessionDir;
|
|
78089
|
-
const metaPath =
|
|
78090
|
-
if (!
|
|
78522
|
+
const metaPath = join12(dir, "meta.json");
|
|
78523
|
+
if (!existsSync7(metaPath))
|
|
78091
78524
|
return null;
|
|
78092
|
-
const meta3 = JSON.parse(
|
|
78093
|
-
const jsonlPath =
|
|
78525
|
+
const meta3 = JSON.parse(readFileSync6(metaPath, "utf-8"));
|
|
78526
|
+
const jsonlPath = join12(dir, "messages.jsonl");
|
|
78094
78527
|
const allMessages = [];
|
|
78095
|
-
if (
|
|
78096
|
-
const content =
|
|
78528
|
+
if (existsSync7(jsonlPath)) {
|
|
78529
|
+
const content = readFileSync6(jsonlPath, "utf-8").trim();
|
|
78097
78530
|
if (content) {
|
|
78098
78531
|
for (const line of content.split(`
|
|
78099
78532
|
`)) {
|
|
@@ -78115,11 +78548,11 @@ var handlers = {
|
|
|
78115
78548
|
} = tab.messageRange;
|
|
78116
78549
|
tabEntries.push([tab.id, allMessages.slice(startLine, endLine)]);
|
|
78117
78550
|
}
|
|
78118
|
-
const corePath =
|
|
78551
|
+
const corePath = join12(dir, "core.json");
|
|
78119
78552
|
let coreEntries;
|
|
78120
|
-
if (
|
|
78553
|
+
if (existsSync7(corePath)) {
|
|
78121
78554
|
try {
|
|
78122
|
-
const coreData = JSON.parse(
|
|
78555
|
+
const coreData = JSON.parse(readFileSync6(corePath, "utf-8"));
|
|
78123
78556
|
coreEntries = Object.entries(coreData);
|
|
78124
78557
|
} catch {}
|
|
78125
78558
|
}
|
|
@@ -78131,27 +78564,27 @@ var handlers = {
|
|
|
78131
78564
|
},
|
|
78132
78565
|
listSessions: (sessionsDir) => {
|
|
78133
78566
|
const dir = sessionsDir;
|
|
78134
|
-
if (!
|
|
78567
|
+
if (!existsSync7(dir))
|
|
78135
78568
|
return [];
|
|
78136
78569
|
try {
|
|
78137
78570
|
const entries = readdirSync4(dir);
|
|
78138
78571
|
const metas = [];
|
|
78139
78572
|
for (const entry of entries) {
|
|
78140
78573
|
try {
|
|
78141
|
-
const fullPath =
|
|
78574
|
+
const fullPath = join12(dir, entry);
|
|
78142
78575
|
const s = statSync(fullPath);
|
|
78143
78576
|
if (!s.isDirectory())
|
|
78144
78577
|
continue;
|
|
78145
|
-
const metaPath =
|
|
78146
|
-
if (!
|
|
78578
|
+
const metaPath = join12(fullPath, "meta.json");
|
|
78579
|
+
if (!existsSync7(metaPath))
|
|
78147
78580
|
continue;
|
|
78148
|
-
const raw =
|
|
78581
|
+
const raw = readFileSync6(metaPath, "utf-8");
|
|
78149
78582
|
const meta3 = JSON.parse(raw);
|
|
78150
78583
|
const totalMessages = (meta3.tabs ?? []).reduce((sum, t) => sum + (t.messageRange.endLine - t.messageRange.startLine), 0);
|
|
78151
78584
|
let sizeBytes = 0;
|
|
78152
78585
|
for (const file2 of ["meta.json", "messages.jsonl"]) {
|
|
78153
78586
|
try {
|
|
78154
|
-
sizeBytes += statSync(
|
|
78587
|
+
sizeBytes += statSync(join12(fullPath, file2)).size;
|
|
78155
78588
|
} catch {}
|
|
78156
78589
|
}
|
|
78157
78590
|
metas.push({
|