feat: add OllamaLocalExecutor and update provider handling

- Introduced OllamaLocalExecutor to handle requests for the "ollama-local" provider.
- Removed the direct URL construction for "ollama-local" from BaseExecutor.
- Updated index.js to include the new OllamaLocalExecutor in the executors mapping.
- Enhanced the ProvidersPage component to support dynamic addition of OpenAI/Anthropic compatible providers.
This commit is contained in:
decolua
2026-05-07 16:42:36 +07:00
parent 050e56f20b
commit 0d61a1d546
8 changed files with 127 additions and 94 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ const fs = require("fs");
const path = require("path");
const os = require("os");
const { log, err } = require("../logger");
const { TOOL_HOSTS } = require("../../shared/constants/mitmToolHosts");
const { TOOL_HOSTS } = require("../../shared/constants/mitmToolHosts.js");
const { runElevatedPowerShell, isAdmin } = require("../winElevated.js");
/**
+12 -3
View File
@@ -549,6 +549,15 @@ async function startServer(apiKey, sudoPassword, forceKillPort443 = false) {
}
// Step 2: Spawn server (Root CA already installed in Step 1.5)
// Verify server.js exists — recopy if runtime file was deleted (antivirus/cleanup)
let effectiveServerPath = SERVER_PATH;
if (!effectiveServerPath || !fs.existsSync(effectiveServerPath)) {
log(`[MITM] server.js missing at ${effectiveServerPath} → recopying`);
effectiveServerPath = ensureRuntimeServer(resolveBundledServerPath());
if (!effectiveServerPath || !fs.existsSync(effectiveServerPath)) {
throw new Error(`MITM server.js not found at ${effectiveServerPath}. Reinstall 9router.`);
}
}
const mitmRouterBase = await resolveMitmRouterBaseUrl();
log(`🚀 Starting server... (router: ${mitmRouterBase})`);
if (IS_WIN) {
@@ -569,7 +578,7 @@ async function startServer(apiKey, sudoPassword, forceKillPort443 = false) {
// Spawn directly — process already has admin rights
serverProcess = spawn(
process.execPath,
[SERVER_PATH],
[effectiveServerPath],
{
detached: false,
windowsHide: true,
@@ -593,7 +602,7 @@ async function startServer(apiKey, sudoPassword, forceKillPort443 = false) {
`MITM_ROUTER_BASE=${shellQuoteSingle(mitmRouterBase)}`,
"NODE_ENV=production",
shellQuoteSingle(process.execPath),
shellQuoteSingle(SERVER_PATH),
shellQuoteSingle(effectiveServerPath),
].join(" ");
serverProcess = spawn(
"sudo", ["-S", "-E", "sh", "-c", inlineCmd],
@@ -603,7 +612,7 @@ async function startServer(apiKey, sudoPassword, forceKillPort443 = false) {
serverProcess.stdin.end();
} else {
// Docker/minimal images: no sudo — same as Windows-style direct spawn
serverProcess = spawn(process.execPath, [SERVER_PATH], {
serverProcess = spawn(process.execPath, [effectiveServerPath], {
detached: false,
windowsHide: true,
stdio: ["ignore", "pipe", "pipe"],