mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-23 04:09:49 +00:00
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:
@@ -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
@@ -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"],
|
||||
|
||||
Reference in New Issue
Block a user