openfox 2.0.62 → 2.0.64
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/README.md +14 -0
- package/dist/{chat-handler-TRAITVLO.js → chat-handler-LI4R4Z2E.js} +11 -11
- package/dist/{chunk-L4WACPUX.js → chunk-73N5CJH3.js} +5 -5
- package/dist/{chunk-BKTBHEPY.js → chunk-HZNY77HZ.js} +32 -42
- package/dist/{chunk-QZRS2RF5.js → chunk-JFQSQO2N.js} +362 -92
- package/dist/{chunk-3WL5YCP6.js → chunk-O3G6X5CT.js} +6 -6
- package/dist/{chunk-GJU35MDV.js → chunk-OESYKZCM.js} +2 -2
- package/dist/{chunk-JKLPWTUN.js → chunk-QBYQ7KDX.js} +9 -4
- package/dist/{chunk-NVPVDDQZ.js → chunk-QJ5FH5DP.js} +14 -10
- package/dist/{chunk-H774GQJW.js → chunk-RYIREJAW.js} +234 -40
- package/dist/{chunk-WEB4WBUF.js → chunk-WD75RSGR.js} +149 -117
- package/dist/{chunk-43UFGATL.js → chunk-WGAAQASA.js} +31 -9
- package/dist/{chunk-6VDCH5ML.js → chunk-X5YCWKNS.js} +4 -4
- package/dist/cli/dev.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/{client-KRFGMNGN.js → client-LAKW7TA5.js} +3 -3
- package/dist/{compactor-Q33AJPCQ.js → compactor-I3N56PSJ.js} +4 -4
- package/dist/{config-GMQUPNBY.js → config-EUMVEFHU.js} +2 -2
- package/dist/{orchestrator-TQ23BAFQ.js → orchestrator-PFN7C5JI.js} +14 -14
- package/dist/package.json +5 -1
- package/dist/{processor-3ZOFGZP5.js → processor-AYYXP5NS.js} +13 -12
- package/dist/protocol-Cq66hdDX.d.ts +375 -0
- package/dist/provider/index.d.ts +129 -0
- package/dist/provider/index.js +1 -0
- package/dist/{provider-LBYBC5AG.js → provider-GYOW4OWQ.js} +7 -9
- package/dist/{provider-manager-ABEUYU3K.js → provider-manager-HRHNF73A.js} +4 -5
- package/dist/{serve-CNA5NKOR.js → serve-54KALE6R.js} +15 -16
- package/dist/server/index.d.ts +6 -87
- package/dist/server/index.js +12 -13
- package/dist/{server-CI5IEBOC.js → server-Z2A5YZM6.js} +10 -14
- package/dist/shared/index.d.ts +3 -2
- package/dist/{tools-33FQNFKC.js → tools-R6LPK6OS.js} +7 -7
- package/dist/types-CDZakn7f.d.ts +89 -0
- package/dist/{protocol-J7khRG62.d.ts → types-akHmgvBk.d.ts} +17 -373
- package/dist/web/assets/{index-CETZPQXr.js → index-CkE65FP4.js} +74 -73
- package/dist/web/assets/{index-BGkyTfuQ.css → index-DvPmgi8F.css} +1 -1
- package/dist/web/index.html +2 -2
- package/dist/web/sw.js +1 -1
- package/package.json +5 -1
- package/dist/chunk-M3RB4IF6.js +0 -114
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
tokenFromPassword,
|
|
22
22
|
verifyPassword,
|
|
23
23
|
workflowExists
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-HZNY77HZ.js";
|
|
25
25
|
import {
|
|
26
26
|
agentExists,
|
|
27
27
|
createToolRegistry,
|
|
@@ -66,7 +66,12 @@ import {
|
|
|
66
66
|
setSkillEnabled,
|
|
67
67
|
skillExists,
|
|
68
68
|
updateOwnedSkill
|
|
69
|
-
} from "./chunk-
|
|
69
|
+
} from "./chunk-WD75RSGR.js";
|
|
70
|
+
import {
|
|
71
|
+
ALWAYS_ALLOWED,
|
|
72
|
+
ALWAYS_ALLOWED_FOR_SUBAGENTS,
|
|
73
|
+
TOP_LEVEL_ONLY_TOOLS
|
|
74
|
+
} from "./chunk-X5YCWKNS.js";
|
|
70
75
|
import {
|
|
71
76
|
getPathSeparator,
|
|
72
77
|
isAbsolutePath
|
|
@@ -74,25 +79,6 @@ import {
|
|
|
74
79
|
import {
|
|
75
80
|
createMcpTools
|
|
76
81
|
} from "./chunk-NWO6GRYE.js";
|
|
77
|
-
import {
|
|
78
|
-
createContextStateMessage
|
|
79
|
-
} from "./chunk-F4PMNP7S.js";
|
|
80
|
-
import {
|
|
81
|
-
EventEmitter
|
|
82
|
-
} from "./chunk-EU3WWTFH.js";
|
|
83
|
-
import {
|
|
84
|
-
deleteSetting,
|
|
85
|
-
getSetting,
|
|
86
|
-
setSetting
|
|
87
|
-
} from "./chunk-SVSKQYFH.js";
|
|
88
|
-
import {
|
|
89
|
-
getProject
|
|
90
|
-
} from "./chunk-YQ3SOPBI.js";
|
|
91
|
-
import {
|
|
92
|
-
ALWAYS_ALLOWED,
|
|
93
|
-
ALWAYS_ALLOWED_FOR_SUBAGENTS,
|
|
94
|
-
TOP_LEVEL_ONLY_TOOLS
|
|
95
|
-
} from "./chunk-6VDCH5ML.js";
|
|
96
82
|
import {
|
|
97
83
|
createSession,
|
|
98
84
|
deleteSession,
|
|
@@ -120,17 +106,32 @@ import {
|
|
|
120
106
|
updateSessionProvider,
|
|
121
107
|
updateSessionRunning
|
|
122
108
|
} from "./chunk-AIJE3RYH.js";
|
|
109
|
+
import {
|
|
110
|
+
createContextStateMessage
|
|
111
|
+
} from "./chunk-F4PMNP7S.js";
|
|
112
|
+
import {
|
|
113
|
+
EventEmitter
|
|
114
|
+
} from "./chunk-EU3WWTFH.js";
|
|
115
|
+
import {
|
|
116
|
+
deleteSetting,
|
|
117
|
+
getSetting,
|
|
118
|
+
setSetting
|
|
119
|
+
} from "./chunk-SVSKQYFH.js";
|
|
120
|
+
import {
|
|
121
|
+
getProject
|
|
122
|
+
} from "./chunk-YQ3SOPBI.js";
|
|
123
123
|
import {
|
|
124
124
|
initDatabase
|
|
125
125
|
} from "./chunk-ZPIZLTWU.js";
|
|
126
126
|
import {
|
|
127
127
|
createProviderManager,
|
|
128
|
+
detectModel,
|
|
129
|
+
getLlmStatus,
|
|
128
130
|
parseDefaultModelSelection
|
|
129
|
-
} from "./chunk-
|
|
131
|
+
} from "./chunk-RYIREJAW.js";
|
|
130
132
|
import {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
} from "./chunk-M3RB4IF6.js";
|
|
133
|
+
getModelProfile
|
|
134
|
+
} from "./chunk-V4IE7HJY.js";
|
|
134
135
|
import {
|
|
135
136
|
getBackendDisplayName
|
|
136
137
|
} from "./chunk-YHEQTVFV.js";
|
|
@@ -150,17 +151,14 @@ import {
|
|
|
150
151
|
import {
|
|
151
152
|
getGlobalConfigDir
|
|
152
153
|
} from "./chunk-CQGTEGKL.js";
|
|
153
|
-
import {
|
|
154
|
-
getModelProfile
|
|
155
|
-
} from "./chunk-V4IE7HJY.js";
|
|
156
154
|
|
|
157
155
|
// src/server/index.ts
|
|
158
156
|
import express from "express";
|
|
159
157
|
import cors from "cors";
|
|
160
158
|
import { createServer as createHttpServer } from "http";
|
|
161
|
-
import { fileURLToPath as
|
|
162
|
-
import { dirname as
|
|
163
|
-
import { readFile as
|
|
159
|
+
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
160
|
+
import { dirname as dirname7, resolve as resolve5, join as join8 } from "path";
|
|
161
|
+
import { readFile as readFile3 } from "fs/promises";
|
|
164
162
|
import { createServer as createViteServer } from "vite";
|
|
165
163
|
|
|
166
164
|
// src/server/llm/mock.ts
|
|
@@ -1923,19 +1921,19 @@ var LspServer = class {
|
|
|
1923
1921
|
*/
|
|
1924
1922
|
async getDiagnosticsWithWait(path, timeoutMs = DIAGNOSTIC_WAIT_MS) {
|
|
1925
1923
|
if (this.openDocuments.has(path)) {
|
|
1926
|
-
return new Promise((
|
|
1924
|
+
return new Promise((resolve6) => {
|
|
1927
1925
|
const existing = this.diagnostics.get(path);
|
|
1928
1926
|
if (existing !== void 0) {
|
|
1929
1927
|
setTimeout(() => {
|
|
1930
|
-
|
|
1928
|
+
resolve6(this.diagnostics.get(path) ?? []);
|
|
1931
1929
|
}, 100);
|
|
1932
1930
|
return;
|
|
1933
1931
|
}
|
|
1934
1932
|
const timeout = setTimeout(() => {
|
|
1935
1933
|
this.pendingDiagnostics.delete(path);
|
|
1936
|
-
|
|
1934
|
+
resolve6(this.diagnostics.get(path) ?? []);
|
|
1937
1935
|
}, timeoutMs);
|
|
1938
|
-
this.pendingDiagnostics.set(path, { resolve:
|
|
1936
|
+
this.pendingDiagnostics.set(path, { resolve: resolve6, timeout });
|
|
1939
1937
|
});
|
|
1940
1938
|
}
|
|
1941
1939
|
return this.diagnostics.get(path) ?? [];
|
|
@@ -4078,7 +4076,7 @@ import { Router as Router8 } from "express";
|
|
|
4078
4076
|
import { spawn as spawn2 } from "child_process";
|
|
4079
4077
|
|
|
4080
4078
|
// src/constants.ts
|
|
4081
|
-
var VERSION = "2.0.
|
|
4079
|
+
var VERSION = "2.0.64";
|
|
4082
4080
|
|
|
4083
4081
|
// src/server/routes/auto-update.ts
|
|
4084
4082
|
var updateInProgress = false;
|
|
@@ -4101,7 +4099,7 @@ function createAutoUpdateRoutes(options = {}) {
|
|
|
4101
4099
|
const isService = isRunningAsService();
|
|
4102
4100
|
const current = VERSION;
|
|
4103
4101
|
try {
|
|
4104
|
-
const latest = await new Promise((
|
|
4102
|
+
const latest = await new Promise((resolve6, reject) => {
|
|
4105
4103
|
const child = spawn2("npm", ["view", "openfox", "version"], {
|
|
4106
4104
|
stdio: ["ignore", "pipe", "pipe"],
|
|
4107
4105
|
windowsHide: true
|
|
@@ -4112,7 +4110,7 @@ function createAutoUpdateRoutes(options = {}) {
|
|
|
4112
4110
|
});
|
|
4113
4111
|
child.on("close", (code) => {
|
|
4114
4112
|
if (code === 0) {
|
|
4115
|
-
|
|
4113
|
+
resolve6(stdout.trim());
|
|
4116
4114
|
} else {
|
|
4117
4115
|
reject(new Error(`npm view exited with code ${code}`));
|
|
4118
4116
|
}
|
|
@@ -4156,9 +4154,9 @@ function createAutoUpdateRoutes(options = {}) {
|
|
|
4156
4154
|
const timeout = setTimeout(() => {
|
|
4157
4155
|
child.kill();
|
|
4158
4156
|
}, UPDATE_TIMEOUT);
|
|
4159
|
-
const exitCode = await new Promise((
|
|
4160
|
-
child.on("close",
|
|
4161
|
-
child.on("error", () =>
|
|
4157
|
+
const exitCode = await new Promise((resolve6) => {
|
|
4158
|
+
child.on("close", resolve6);
|
|
4159
|
+
child.on("error", () => resolve6(1));
|
|
4162
4160
|
});
|
|
4163
4161
|
clearTimeout(timeout);
|
|
4164
4162
|
if (exitCode === 0) {
|
|
@@ -4195,8 +4193,233 @@ function createAutoUpdateRoutes(options = {}) {
|
|
|
4195
4193
|
return router;
|
|
4196
4194
|
}
|
|
4197
4195
|
|
|
4196
|
+
// src/server/routes/provider-auth.ts
|
|
4197
|
+
import { Router as Router9 } from "express";
|
|
4198
|
+
function createProviderAuthRoutes(config3, providerManager, registry) {
|
|
4199
|
+
const router = Router9();
|
|
4200
|
+
function resolveAuthContext(providerId, res) {
|
|
4201
|
+
const provider = providerManager.getProviders().find((item) => item.id === providerId);
|
|
4202
|
+
if (!provider) {
|
|
4203
|
+
res.status(404).json({ error: "Provider not found" });
|
|
4204
|
+
return void 0;
|
|
4205
|
+
}
|
|
4206
|
+
return { provider, adapter: registry.getAuth(provider.authAdapter) };
|
|
4207
|
+
}
|
|
4208
|
+
function missingAuthPlugin(provider) {
|
|
4209
|
+
return `Missing provider auth plugin: ${provider.authAdapter ?? "unknown"}`;
|
|
4210
|
+
}
|
|
4211
|
+
router.post("/:providerId/login", async (req, res) => {
|
|
4212
|
+
const context = resolveAuthContext(req.params.providerId, res);
|
|
4213
|
+
if (!context) return;
|
|
4214
|
+
const { provider, adapter } = context;
|
|
4215
|
+
if (!adapter) return res.status(424).json({ error: missingAuthPlugin(provider) });
|
|
4216
|
+
try {
|
|
4217
|
+
const { challenge, completion } = await adapter.beginLogin({ providerId: provider.id });
|
|
4218
|
+
void completion.then(async ({ credentialRef }) => {
|
|
4219
|
+
const { loadGlobalConfig, saveGlobalConfig, updateProvider } = await import("./config-EUMVEFHU.js");
|
|
4220
|
+
const globalConfig = await loadGlobalConfig(config3.mode ?? "production", config3.globalConfigPath);
|
|
4221
|
+
const updatedConfig = updateProvider(globalConfig, provider.id, { credentialRef, authAdapter: adapter.id });
|
|
4222
|
+
await saveGlobalConfig(config3.mode ?? "production", updatedConfig, config3.globalConfigPath);
|
|
4223
|
+
providerManager.setProviders(updatedConfig.providers, updatedConfig.defaultModelSelection ?? void 0);
|
|
4224
|
+
}).catch((err) => {
|
|
4225
|
+
logger.error("Provider auth completion failed", {
|
|
4226
|
+
providerId: provider.id,
|
|
4227
|
+
authAdapter: adapter.id,
|
|
4228
|
+
error: err instanceof Error ? err.message : String(err)
|
|
4229
|
+
});
|
|
4230
|
+
});
|
|
4231
|
+
res.json(challenge);
|
|
4232
|
+
} catch (error) {
|
|
4233
|
+
res.status(502).json({ error: error instanceof Error ? error.message : "Unable to start provider login" });
|
|
4234
|
+
}
|
|
4235
|
+
});
|
|
4236
|
+
router.get("/:providerId/status", async (req, res) => {
|
|
4237
|
+
const context = resolveAuthContext(req.params.providerId, res);
|
|
4238
|
+
if (!context) return;
|
|
4239
|
+
const { provider, adapter } = context;
|
|
4240
|
+
if (!adapter) return res.json({ state: "disconnected", error: missingAuthPlugin(provider) });
|
|
4241
|
+
res.json(
|
|
4242
|
+
await adapter.getStatus({
|
|
4243
|
+
providerId: provider.id,
|
|
4244
|
+
...provider.credentialRef && { credentialRef: provider.credentialRef }
|
|
4245
|
+
})
|
|
4246
|
+
);
|
|
4247
|
+
});
|
|
4248
|
+
router.post("/:providerId/logout", async (req, res) => {
|
|
4249
|
+
const context = resolveAuthContext(req.params.providerId, res);
|
|
4250
|
+
if (!context) return;
|
|
4251
|
+
const { provider, adapter } = context;
|
|
4252
|
+
if (provider.credentialRef && adapter) await adapter.logout(provider.credentialRef);
|
|
4253
|
+
const { loadGlobalConfig, saveGlobalConfig } = await import("./config-EUMVEFHU.js");
|
|
4254
|
+
const globalConfig = await loadGlobalConfig(config3.mode ?? "production", config3.globalConfigPath);
|
|
4255
|
+
const updatedConfig = {
|
|
4256
|
+
...globalConfig,
|
|
4257
|
+
providers: globalConfig.providers.map((item) => {
|
|
4258
|
+
if (item.id !== provider.id) return item;
|
|
4259
|
+
const updated = { ...item };
|
|
4260
|
+
delete updated.credentialRef;
|
|
4261
|
+
return updated;
|
|
4262
|
+
})
|
|
4263
|
+
};
|
|
4264
|
+
await saveGlobalConfig(config3.mode ?? "production", updatedConfig, config3.globalConfigPath);
|
|
4265
|
+
providerManager.setProviders(updatedConfig.providers, updatedConfig.defaultModelSelection ?? void 0);
|
|
4266
|
+
res.json({ success: true });
|
|
4267
|
+
});
|
|
4268
|
+
return router;
|
|
4269
|
+
}
|
|
4270
|
+
|
|
4271
|
+
// src/server/providers/plugins/registry.ts
|
|
4272
|
+
var ProviderRegistry = class {
|
|
4273
|
+
constructor(runtime) {
|
|
4274
|
+
this.runtime = runtime;
|
|
4275
|
+
}
|
|
4276
|
+
authAdapters = /* @__PURE__ */ new Map();
|
|
4277
|
+
transportAdapters = /* @__PURE__ */ new Map();
|
|
4278
|
+
presets = /* @__PURE__ */ new Map();
|
|
4279
|
+
registerAuth(adapter) {
|
|
4280
|
+
this.register(this.authAdapters, adapter.id, adapter, "auth adapter");
|
|
4281
|
+
}
|
|
4282
|
+
registerTransport(adapter) {
|
|
4283
|
+
this.register(this.transportAdapters, adapter.id, adapter, "transport adapter");
|
|
4284
|
+
}
|
|
4285
|
+
registerPreset(preset) {
|
|
4286
|
+
this.register(this.presets, preset.id, preset, "preset");
|
|
4287
|
+
}
|
|
4288
|
+
getAuth(id) {
|
|
4289
|
+
return id ? this.authAdapters.get(id) : void 0;
|
|
4290
|
+
}
|
|
4291
|
+
getTransport(id) {
|
|
4292
|
+
return id ? this.transportAdapters.get(id) : void 0;
|
|
4293
|
+
}
|
|
4294
|
+
getPresets() {
|
|
4295
|
+
return [...this.presets.values()];
|
|
4296
|
+
}
|
|
4297
|
+
resolveProvider(provider) {
|
|
4298
|
+
if (!provider.preset) return provider;
|
|
4299
|
+
const preset = this.presets.get(provider.preset);
|
|
4300
|
+
if (!preset) return provider;
|
|
4301
|
+
return {
|
|
4302
|
+
...provider,
|
|
4303
|
+
name: provider.name === provider.id ? preset.defaults.name ?? preset.name : provider.name,
|
|
4304
|
+
url: provider.url || preset.defaults.url,
|
|
4305
|
+
backend: provider.backend === "unknown" ? preset.defaults.backend : provider.backend,
|
|
4306
|
+
models: provider.models.length > 0 ? provider.models : preset.defaults.models ?? [],
|
|
4307
|
+
...provider.authAdapter ?? preset.authAdapter ? { authAdapter: provider.authAdapter ?? preset.authAdapter } : {},
|
|
4308
|
+
...provider.transportAdapter ?? preset.transportAdapter ? { transportAdapter: provider.transportAdapter ?? preset.transportAdapter } : {}
|
|
4309
|
+
};
|
|
4310
|
+
}
|
|
4311
|
+
resolveProviders(providers) {
|
|
4312
|
+
return providers.map((provider) => this.resolveProvider(provider));
|
|
4313
|
+
}
|
|
4314
|
+
listAuthAdapters() {
|
|
4315
|
+
return [...this.authAdapters.keys()].map((id) => ({ id }));
|
|
4316
|
+
}
|
|
4317
|
+
listTransportAdapters() {
|
|
4318
|
+
return [...this.transportAdapters.keys()].map((id) => ({ id }));
|
|
4319
|
+
}
|
|
4320
|
+
register(map, id, value, kind) {
|
|
4321
|
+
if (!id.trim()) throw new Error(`Provider ${kind} id cannot be empty`);
|
|
4322
|
+
if (map.has(id)) throw new Error(`Provider ${kind} already registered: ${id}`);
|
|
4323
|
+
map.set(id, value);
|
|
4324
|
+
}
|
|
4325
|
+
};
|
|
4326
|
+
|
|
4327
|
+
// src/server/providers/plugins/loader.ts
|
|
4328
|
+
import { readdir as readdir2, readFile as readFile2, stat as stat2 } from "fs/promises";
|
|
4329
|
+
import { dirname as dirname6, join as join7, resolve as resolve4 } from "path";
|
|
4330
|
+
import { fileURLToPath as fileURLToPath5, pathToFileURL } from "url";
|
|
4331
|
+
async function packageDirectories(root) {
|
|
4332
|
+
let entries;
|
|
4333
|
+
try {
|
|
4334
|
+
entries = await readdir2(root, { withFileTypes: true });
|
|
4335
|
+
} catch {
|
|
4336
|
+
return [];
|
|
4337
|
+
}
|
|
4338
|
+
const directories = [];
|
|
4339
|
+
for (const entry of entries) {
|
|
4340
|
+
const entryPath = join7(root, entry.name);
|
|
4341
|
+
const isDirectory = entry.isDirectory() || entry.isSymbolicLink() && (await stat2(entryPath).catch(() => void 0))?.isDirectory();
|
|
4342
|
+
if (!isDirectory) continue;
|
|
4343
|
+
if (entry.name.startsWith("@")) {
|
|
4344
|
+
const scoped = await readdir2(entryPath, { withFileTypes: true }).catch(() => []);
|
|
4345
|
+
for (const child of scoped) {
|
|
4346
|
+
const childPath = join7(entryPath, child.name);
|
|
4347
|
+
const childIsDirectory = child.isDirectory() || child.isSymbolicLink() && (await stat2(childPath).catch(() => void 0))?.isDirectory();
|
|
4348
|
+
if (childIsDirectory) directories.push(childPath);
|
|
4349
|
+
}
|
|
4350
|
+
} else {
|
|
4351
|
+
directories.push(entryPath);
|
|
4352
|
+
}
|
|
4353
|
+
}
|
|
4354
|
+
return directories;
|
|
4355
|
+
}
|
|
4356
|
+
async function loadProviderPlugins(options) {
|
|
4357
|
+
const moduleDirectory = dirname6(fileURLToPath5(import.meta.url));
|
|
4358
|
+
const roots = [
|
|
4359
|
+
join7(options.configDirectory, "plugins"),
|
|
4360
|
+
join7(options.cwd ?? process.cwd(), "node_modules"),
|
|
4361
|
+
resolve4(moduleDirectory, "node_modules"),
|
|
4362
|
+
resolve4(moduleDirectory, "../../../../node_modules")
|
|
4363
|
+
];
|
|
4364
|
+
const seen = /* @__PURE__ */ new Set();
|
|
4365
|
+
const diagnostics = [];
|
|
4366
|
+
for (const root of roots) {
|
|
4367
|
+
for (const packageDir of await packageDirectories(root)) {
|
|
4368
|
+
const manifestPath = join7(packageDir, "package.json");
|
|
4369
|
+
let manifest;
|
|
4370
|
+
try {
|
|
4371
|
+
manifest = JSON.parse(await readFile2(manifestPath, "utf8"));
|
|
4372
|
+
} catch {
|
|
4373
|
+
continue;
|
|
4374
|
+
}
|
|
4375
|
+
const plugin = manifest.openfox?.plugin;
|
|
4376
|
+
const packageName = manifest.name;
|
|
4377
|
+
if (!plugin || !packageName || seen.has(packageName)) continue;
|
|
4378
|
+
seen.add(packageName);
|
|
4379
|
+
const diagnostic = {
|
|
4380
|
+
packageName,
|
|
4381
|
+
...manifest.version && { version: manifest.version },
|
|
4382
|
+
source: packageDir,
|
|
4383
|
+
loaded: false,
|
|
4384
|
+
authAdapters: [],
|
|
4385
|
+
transportAdapters: [],
|
|
4386
|
+
presets: []
|
|
4387
|
+
};
|
|
4388
|
+
diagnostics.push(diagnostic);
|
|
4389
|
+
if (manifest.openfox?.apiVersion !== 1) {
|
|
4390
|
+
diagnostic.error = `Unsupported OpenFox plugin API version: ${String(manifest.openfox?.apiVersion)}`;
|
|
4391
|
+
continue;
|
|
4392
|
+
}
|
|
4393
|
+
const trackingRegistry = {
|
|
4394
|
+
runtime: options.registry.runtime,
|
|
4395
|
+
registerAuth(adapter) {
|
|
4396
|
+
options.registry.registerAuth(adapter);
|
|
4397
|
+
diagnostic.authAdapters.push(adapter.id);
|
|
4398
|
+
},
|
|
4399
|
+
registerTransport(adapter) {
|
|
4400
|
+
options.registry.registerTransport(adapter);
|
|
4401
|
+
diagnostic.transportAdapters.push(adapter.id);
|
|
4402
|
+
},
|
|
4403
|
+
registerPreset(preset) {
|
|
4404
|
+
options.registry.registerPreset(preset);
|
|
4405
|
+
diagnostic.presets.push(preset.id);
|
|
4406
|
+
}
|
|
4407
|
+
};
|
|
4408
|
+
try {
|
|
4409
|
+
const module = await import(pathToFileURL(join7(packageDir, plugin)).href);
|
|
4410
|
+
if (typeof module.register !== "function") throw new Error("Plugin does not export register(registry)");
|
|
4411
|
+
await module.register(trackingRegistry);
|
|
4412
|
+
diagnostic.loaded = true;
|
|
4413
|
+
} catch (error) {
|
|
4414
|
+
diagnostic.error = error instanceof Error ? error.message : String(error);
|
|
4415
|
+
}
|
|
4416
|
+
}
|
|
4417
|
+
}
|
|
4418
|
+
return diagnostics;
|
|
4419
|
+
}
|
|
4420
|
+
|
|
4198
4421
|
// src/server/index.ts
|
|
4199
|
-
var __dirname3 =
|
|
4422
|
+
var __dirname3 = dirname7(fileURLToPath6(import.meta.url));
|
|
4200
4423
|
async function createServerHandle(config3) {
|
|
4201
4424
|
setRuntimeConfig(config3);
|
|
4202
4425
|
setLogLevel(config3.logging?.level ?? void 0, config3.mode);
|
|
@@ -4204,12 +4427,22 @@ async function createServerHandle(config3) {
|
|
|
4204
4427
|
const db = initDatabase(config3);
|
|
4205
4428
|
initEventStore(db);
|
|
4206
4429
|
const configDir = getGlobalConfigDir(config3.mode ?? "production");
|
|
4207
|
-
const
|
|
4430
|
+
const providerAdapters = new ProviderRegistry({
|
|
4431
|
+
mode: config3.mode === "development" ? "development" : "production",
|
|
4432
|
+
configDirectory: configDir
|
|
4433
|
+
});
|
|
4434
|
+
const pluginDiagnostics = await loadProviderPlugins({ registry: providerAdapters, configDirectory: configDir });
|
|
4435
|
+
for (const diagnostic of pluginDiagnostics) {
|
|
4436
|
+
if (!diagnostic.loaded) logger.warn("Provider plugin failed to load", { ...diagnostic });
|
|
4437
|
+
}
|
|
4438
|
+
config3.providers = providerAdapters.resolveProviders(config3.providers ?? []);
|
|
4439
|
+
const providerManager = createProviderManager(config3, { adapters: providerAdapters });
|
|
4208
4440
|
const sessionManager = new SessionManager(providerManager);
|
|
4209
4441
|
devServerManager.setSessionManager(sessionManager);
|
|
4210
4442
|
const useMock = process.env["OPENFOX_MOCK_LLM"] === "true";
|
|
4211
4443
|
const getMockClient = useMock ? createMockLLMClient : null;
|
|
4212
4444
|
const getLLMClient = () => getMockClient ? getMockClient() : providerManager.getLLMClient();
|
|
4445
|
+
const getLLMClientForProvider = (providerId, model) => getMockClient ? getMockClient() : providerManager.createClient(providerId, model);
|
|
4213
4446
|
if (useMock) {
|
|
4214
4447
|
logger.info("Using MOCK LLM client - deterministic responses for testing");
|
|
4215
4448
|
}
|
|
@@ -4252,7 +4485,7 @@ async function createServerHandle(config3) {
|
|
|
4252
4485
|
const mcpManager = new McpManager({
|
|
4253
4486
|
onToolsDiscovered: async (name, tools) => {
|
|
4254
4487
|
try {
|
|
4255
|
-
const { loadGlobalConfig, saveGlobalConfig } = await import("./config-
|
|
4488
|
+
const { loadGlobalConfig, saveGlobalConfig } = await import("./config-EUMVEFHU.js");
|
|
4256
4489
|
const mode = config3.mode ?? "production";
|
|
4257
4490
|
const globalConfig = await loadGlobalConfig(mode, config3.globalConfigPath);
|
|
4258
4491
|
const mcpServers2 = {
|
|
@@ -4283,7 +4516,7 @@ async function createServerHandle(config3) {
|
|
|
4283
4516
|
setMcpTools(mcpTools);
|
|
4284
4517
|
logger.info("MCP tools registered", { count: mcpTools.length });
|
|
4285
4518
|
}
|
|
4286
|
-
const { signalMcpReady } = await import("./server-
|
|
4519
|
+
const { signalMcpReady } = await import("./server-Z2A5YZM6.js");
|
|
4287
4520
|
signalMcpReady();
|
|
4288
4521
|
});
|
|
4289
4522
|
const app = express();
|
|
@@ -4476,7 +4709,7 @@ async function createServerHandle(config3) {
|
|
|
4476
4709
|
app.get("/api/sessions/:id", async (req, res) => {
|
|
4477
4710
|
const { getEventStore: getEventStore2 } = await import("./events-52XADT6Y.js");
|
|
4478
4711
|
const { buildMessagesFromStoredEvents } = await import("./folding-2BGFLV5J.js");
|
|
4479
|
-
const { getPendingQuestionsForSession } = await import("./tools-
|
|
4712
|
+
const { getPendingQuestionsForSession } = await import("./tools-R6LPK6OS.js");
|
|
4480
4713
|
const session = sessionManager.getSession(req.params.id);
|
|
4481
4714
|
if (!session) {
|
|
4482
4715
|
return res.status(404).json({ error: "Session not found" });
|
|
@@ -4495,8 +4728,8 @@ async function createServerHandle(config3) {
|
|
|
4495
4728
|
if (!session) {
|
|
4496
4729
|
return res.status(404).json({ error: "Session not found" });
|
|
4497
4730
|
}
|
|
4498
|
-
const { stopSessionExecution } = await import("./chat-handler-
|
|
4499
|
-
const { cancelQuestionsForSession, cancelPathConfirmationsForSession } = await import("./tools-
|
|
4731
|
+
const { stopSessionExecution } = await import("./chat-handler-LI4R4Z2E.js");
|
|
4732
|
+
const { cancelQuestionsForSession, cancelPathConfirmationsForSession } = await import("./tools-R6LPK6OS.js");
|
|
4500
4733
|
sessionManager.clearMessageQueue(sessionId);
|
|
4501
4734
|
stopSessionExecution(sessionId, sessionManager);
|
|
4502
4735
|
abortSession(sessionId);
|
|
@@ -4549,7 +4782,7 @@ async function createServerHandle(config3) {
|
|
|
4549
4782
|
if (!result.success) {
|
|
4550
4783
|
return res.status(500).json({ error: result.error ?? "Failed to set default model" });
|
|
4551
4784
|
}
|
|
4552
|
-
const { loadGlobalConfig, saveGlobalConfig, setDefaultModelSelection } = await import("./config-
|
|
4785
|
+
const { loadGlobalConfig, saveGlobalConfig, setDefaultModelSelection } = await import("./config-EUMVEFHU.js");
|
|
4553
4786
|
const globalConfig = await loadGlobalConfig(config3.mode ?? "production", config3.globalConfigPath);
|
|
4554
4787
|
const updatedConfig = setDefaultModelSelection(globalConfig, providerId, model);
|
|
4555
4788
|
await saveGlobalConfig(config3.mode ?? "production", updatedConfig, config3.globalConfigPath);
|
|
@@ -4650,7 +4883,7 @@ async function createServerHandle(config3) {
|
|
|
4650
4883
|
if (!callId || approved === void 0) {
|
|
4651
4884
|
return res.status(400).json({ error: "callId and approved are required" });
|
|
4652
4885
|
}
|
|
4653
|
-
const { providePathConfirmation } = await import("./tools-
|
|
4886
|
+
const { providePathConfirmation } = await import("./tools-R6LPK6OS.js");
|
|
4654
4887
|
const result = providePathConfirmation(callId, approved, alwaysAllow);
|
|
4655
4888
|
if (!result.found) {
|
|
4656
4889
|
return res.status(404).json({ error: "No pending path confirmation with that ID" });
|
|
@@ -4658,7 +4891,7 @@ async function createServerHandle(config3) {
|
|
|
4658
4891
|
const { getEventStore: getEventStore2 } = await import("./events-52XADT6Y.js");
|
|
4659
4892
|
const { buildMessagesFromStoredEvents, foldPendingConfirmations } = await import("./folding-2BGFLV5J.js");
|
|
4660
4893
|
const { createSessionStateMessage } = await import("./protocol-CTNE3ANP.js");
|
|
4661
|
-
const { getPendingQuestionsForSession } = await import("./tools-
|
|
4894
|
+
const { getPendingQuestionsForSession } = await import("./tools-R6LPK6OS.js");
|
|
4662
4895
|
const eventStore = getEventStore2();
|
|
4663
4896
|
const events = eventStore.getEvents(sessionId);
|
|
4664
4897
|
const messages = buildMessagesFromStoredEvents(events);
|
|
@@ -4679,7 +4912,7 @@ async function createServerHandle(config3) {
|
|
|
4679
4912
|
if (!skip && typeof answer !== "string") {
|
|
4680
4913
|
return res.status(400).json({ error: "answer is required when not skipping" });
|
|
4681
4914
|
}
|
|
4682
|
-
const { provideAnswer } = await import("./tools-
|
|
4915
|
+
const { provideAnswer } = await import("./tools-R6LPK6OS.js");
|
|
4683
4916
|
const found = provideAnswer(callId, answer ?? "", skip ?? false);
|
|
4684
4917
|
if (!found) {
|
|
4685
4918
|
return res.status(404).json({ error: "No pending question with that ID" });
|
|
@@ -4739,7 +4972,7 @@ async function createServerHandle(config3) {
|
|
|
4739
4972
|
backend: activeProvider?.backend ?? llmClient.getBackend(),
|
|
4740
4973
|
model: llmClient.getModel()
|
|
4741
4974
|
};
|
|
4742
|
-
const { runAgentTurn, TurnMetrics } = await import("./orchestrator-
|
|
4975
|
+
const { runAgentTurn, TurnMetrics } = await import("./orchestrator-PFN7C5JI.js");
|
|
4743
4976
|
runAgentTurn(
|
|
4744
4977
|
{
|
|
4745
4978
|
sessionManager,
|
|
@@ -4777,8 +5010,8 @@ async function createServerHandle(config3) {
|
|
|
4777
5010
|
if (!session) {
|
|
4778
5011
|
return res.status(404).json({ error: "Session not found" });
|
|
4779
5012
|
}
|
|
4780
|
-
const { stopSessionExecution } = await import("./chat-handler-
|
|
4781
|
-
const { cancelQuestionsForSession, cancelPathConfirmationsForSession } = await import("./tools-
|
|
5013
|
+
const { stopSessionExecution } = await import("./chat-handler-LI4R4Z2E.js");
|
|
5014
|
+
const { cancelQuestionsForSession, cancelPathConfirmationsForSession } = await import("./tools-R6LPK6OS.js");
|
|
4782
5015
|
const queuedMessages = sessionManager.getQueueState(sessionId);
|
|
4783
5016
|
sessionManager.clearMessageQueue(sessionId);
|
|
4784
5017
|
stopSessionExecution(sessionId, sessionManager);
|
|
@@ -4898,7 +5131,7 @@ async function createServerHandle(config3) {
|
|
|
4898
5131
|
let visionFallback;
|
|
4899
5132
|
let globalWorkdir;
|
|
4900
5133
|
try {
|
|
4901
|
-
const { loadGlobalConfig, getVisionFallback } = await import("./config-
|
|
5134
|
+
const { loadGlobalConfig, getVisionFallback } = await import("./config-EUMVEFHU.js");
|
|
4902
5135
|
const globalConfig = await loadGlobalConfig(config3.mode ?? "production", config3.globalConfigPath);
|
|
4903
5136
|
const fallback = getVisionFallback(globalConfig);
|
|
4904
5137
|
if (fallback) {
|
|
@@ -4956,6 +5189,10 @@ async function createServerHandle(config3) {
|
|
|
4956
5189
|
id: m.id,
|
|
4957
5190
|
contextWindow: m.contextWindow ?? 2e5,
|
|
4958
5191
|
source: "user",
|
|
5192
|
+
...m.name !== void 0 && { name: m.name },
|
|
5193
|
+
...m.apiModelId !== void 0 && { apiModelId: m.apiModelId },
|
|
5194
|
+
...m.requestBody !== void 0 && { requestBody: m.requestBody },
|
|
5195
|
+
...m.reasoningEfforts !== void 0 && { reasoningEfforts: m.reasoningEfforts },
|
|
4959
5196
|
...m.supportsVision !== void 0 && { supportsVision: m.supportsVision },
|
|
4960
5197
|
...m.thinkingEnabled !== void 0 && { thinkingEnabled: m.thinkingEnabled },
|
|
4961
5198
|
...m.thinkingLevel !== void 0 && { thinkingLevel: m.thinkingLevel },
|
|
@@ -5047,7 +5284,7 @@ async function createServerHandle(config3) {
|
|
|
5047
5284
|
const backend = req.query["backend"];
|
|
5048
5285
|
if (!url) return res.status(400).json({ error: "url is required" });
|
|
5049
5286
|
try {
|
|
5050
|
-
const { fetchModelsWithContext } = await import("./provider-manager-
|
|
5287
|
+
const { fetchModelsWithContext } = await import("./provider-manager-HRHNF73A.js");
|
|
5051
5288
|
const { getModelProfile: getModelProfile2 } = await import("./profiles-5J7F4BML.js");
|
|
5052
5289
|
const models = await fetchModelsWithContext(
|
|
5053
5290
|
url,
|
|
@@ -5096,11 +5333,25 @@ async function createServerHandle(config3) {
|
|
|
5096
5333
|
}
|
|
5097
5334
|
});
|
|
5098
5335
|
app.post("/api/providers/test-params", async (req, res) => {
|
|
5099
|
-
const { url, model, apiKey, backend, thinkingField, mode, modelConfig } = req.body;
|
|
5336
|
+
const { url, providerId, transportAdapter, model, apiKey, backend, thinkingField, mode, modelConfig } = req.body;
|
|
5100
5337
|
if (!url) return res.status(400).json({ error: "url is required" });
|
|
5101
5338
|
if (!model) return res.status(400).json({ error: "model is required" });
|
|
5102
5339
|
if (!mode) return res.status(400).json({ error: "mode is required" });
|
|
5103
5340
|
try {
|
|
5341
|
+
if (transportAdapter && providerId) {
|
|
5342
|
+
const provider = providerManager.getProviders().find((item) => item.id === providerId);
|
|
5343
|
+
if (!provider) return res.status(404).json({ error: "Provider not found" });
|
|
5344
|
+
const client = providerManager.createClient(providerId, model);
|
|
5345
|
+
if (!client) return res.status(424).json({ error: `Missing provider transport plugin: ${transportAdapter}` });
|
|
5346
|
+
const response2 = await client.complete({
|
|
5347
|
+
messages: [{ role: "user", content: "say hi in one word" }],
|
|
5348
|
+
tools: [],
|
|
5349
|
+
...mode === "thinking" ? { reasoningEffort: modelConfig?.thinkingLevel ?? "medium" } : {},
|
|
5350
|
+
...modelConfig?.maxTokens ? { maxTokens: modelConfig.maxTokens } : {},
|
|
5351
|
+
signal: AbortSignal.timeout(3e4)
|
|
5352
|
+
});
|
|
5353
|
+
return res.json({ success: true, message: { content: response2.content }, raw: response2 });
|
|
5354
|
+
}
|
|
5104
5355
|
const { getModelProfile: getModelProfile2 } = await import("./profiles-5J7F4BML.js");
|
|
5105
5356
|
const { getBackendCapabilities } = await import("./backend-P3GHHLHJ.js");
|
|
5106
5357
|
const { buildNonStreamingCreateParams } = await import("./client-pure-DO3S675T.js");
|
|
@@ -5165,13 +5416,15 @@ async function createServerHandle(config3) {
|
|
|
5165
5416
|
model,
|
|
5166
5417
|
isLocal,
|
|
5167
5418
|
thinkingField,
|
|
5168
|
-
models: modelConfigs
|
|
5419
|
+
models: modelConfigs,
|
|
5420
|
+
authAdapter,
|
|
5421
|
+
transportAdapter
|
|
5169
5422
|
} = req.body;
|
|
5170
5423
|
if (!name || !url || !backend) {
|
|
5171
5424
|
return res.status(400).json({ error: "name, url, and backend are required" });
|
|
5172
5425
|
}
|
|
5173
5426
|
try {
|
|
5174
|
-
const { loadGlobalConfig, saveGlobalConfig, addProvider, setDefaultModelSelection } = await import("./config-
|
|
5427
|
+
const { loadGlobalConfig, saveGlobalConfig, addProvider, setDefaultModelSelection } = await import("./config-EUMVEFHU.js");
|
|
5175
5428
|
const globalConfig = await loadGlobalConfig(config3.mode ?? "production", config3.globalConfigPath);
|
|
5176
5429
|
const providerBackend = backend;
|
|
5177
5430
|
const providerModels = modelConfigs?.length ? buildModelConfigs(modelConfigs) : model ? [{ id: model, contextWindow: 2e5, source: "user" }] : [];
|
|
@@ -5182,6 +5435,8 @@ async function createServerHandle(config3) {
|
|
|
5182
5435
|
apiKey,
|
|
5183
5436
|
...isLocal !== void 0 ? { isLocal } : {},
|
|
5184
5437
|
...thinkingField ? { thinkingField } : {},
|
|
5438
|
+
...authAdapter ? { authAdapter } : {},
|
|
5439
|
+
...transportAdapter ? { transportAdapter } : {},
|
|
5185
5440
|
models: providerModels,
|
|
5186
5441
|
isActive: true
|
|
5187
5442
|
});
|
|
@@ -5209,7 +5464,7 @@ async function createServerHandle(config3) {
|
|
|
5209
5464
|
app.post("/api/init/config", async (req, res) => {
|
|
5210
5465
|
const { workdir, visionFallback } = req.body;
|
|
5211
5466
|
try {
|
|
5212
|
-
const { loadGlobalConfig, saveGlobalConfig } = await import("./config-
|
|
5467
|
+
const { loadGlobalConfig, saveGlobalConfig } = await import("./config-EUMVEFHU.js");
|
|
5213
5468
|
const globalConfig = await loadGlobalConfig(config3.mode ?? "production", config3.globalConfigPath);
|
|
5214
5469
|
const updatedConfig = {
|
|
5215
5470
|
...globalConfig,
|
|
@@ -5225,6 +5480,16 @@ async function createServerHandle(config3) {
|
|
|
5225
5480
|
});
|
|
5226
5481
|
}
|
|
5227
5482
|
});
|
|
5483
|
+
app.get("/api/plugins", (_req, res) => res.json({ plugins: pluginDiagnostics }));
|
|
5484
|
+
app.get("/api/provider-presets", (_req, res) => res.json({ presets: providerAdapters.getPresets() }));
|
|
5485
|
+
app.get(
|
|
5486
|
+
"/api/provider-adapters",
|
|
5487
|
+
(_req, res) => res.json({
|
|
5488
|
+
authAdapters: providerAdapters.listAuthAdapters(),
|
|
5489
|
+
transportAdapters: providerAdapters.listTransportAdapters()
|
|
5490
|
+
})
|
|
5491
|
+
);
|
|
5492
|
+
app.use("/api/provider-auth", createProviderAuthRoutes(config3, providerManager, providerAdapters));
|
|
5228
5493
|
app.get("/api/providers", (_req, res) => {
|
|
5229
5494
|
const providers = providerManager.getProviders().map((p) => ({
|
|
5230
5495
|
...p,
|
|
@@ -5237,7 +5502,7 @@ async function createServerHandle(config3) {
|
|
|
5237
5502
|
});
|
|
5238
5503
|
app.delete("/api/providers/:id", async (req, res) => {
|
|
5239
5504
|
const { id } = req.params;
|
|
5240
|
-
const { loadGlobalConfig, saveGlobalConfig, removeProvider } = await import("./config-
|
|
5505
|
+
const { loadGlobalConfig, saveGlobalConfig, removeProvider } = await import("./config-EUMVEFHU.js");
|
|
5241
5506
|
const globalConfig = await loadGlobalConfig(config3.mode ?? "production", config3.globalConfigPath);
|
|
5242
5507
|
const updatedConfig = removeProvider(globalConfig, id);
|
|
5243
5508
|
await saveGlobalConfig(config3.mode ?? "production", updatedConfig, config3.globalConfigPath);
|
|
@@ -5249,7 +5514,7 @@ async function createServerHandle(config3) {
|
|
|
5249
5514
|
const { id } = req.params;
|
|
5250
5515
|
const { isLocal } = req.body;
|
|
5251
5516
|
try {
|
|
5252
|
-
const { loadGlobalConfig, saveGlobalConfig, updateProvider } = await import("./config-
|
|
5517
|
+
const { loadGlobalConfig, saveGlobalConfig, updateProvider } = await import("./config-EUMVEFHU.js");
|
|
5253
5518
|
const globalConfig = await loadGlobalConfig(config3.mode ?? "production", config3.globalConfigPath);
|
|
5254
5519
|
const provider = globalConfig.providers.find((p) => p.id === id);
|
|
5255
5520
|
if (!provider) {
|
|
@@ -5275,10 +5540,12 @@ async function createServerHandle(config3) {
|
|
|
5275
5540
|
apiKey,
|
|
5276
5541
|
isLocal,
|
|
5277
5542
|
thinkingField,
|
|
5278
|
-
models: modelConfigs
|
|
5543
|
+
models: modelConfigs,
|
|
5544
|
+
authAdapter,
|
|
5545
|
+
transportAdapter
|
|
5279
5546
|
} = req.body;
|
|
5280
5547
|
try {
|
|
5281
|
-
const { loadGlobalConfig, saveGlobalConfig, updateProvider } = await import("./config-
|
|
5548
|
+
const { loadGlobalConfig, saveGlobalConfig, updateProvider } = await import("./config-EUMVEFHU.js");
|
|
5282
5549
|
const globalConfig = await loadGlobalConfig(config3.mode ?? "production", config3.globalConfigPath);
|
|
5283
5550
|
const provider = globalConfig.providers.find((p) => p.id === id);
|
|
5284
5551
|
if (!provider) {
|
|
@@ -5291,6 +5558,8 @@ async function createServerHandle(config3) {
|
|
|
5291
5558
|
if (apiKey !== void 0) updates["apiKey"] = apiKey || void 0;
|
|
5292
5559
|
if (isLocal !== void 0) updates["isLocal"] = isLocal;
|
|
5293
5560
|
if (thinkingField !== void 0) updates["thinkingField"] = thinkingField || void 0;
|
|
5561
|
+
if (authAdapter !== void 0) updates["authAdapter"] = authAdapter || void 0;
|
|
5562
|
+
if (transportAdapter !== void 0) updates["transportAdapter"] = transportAdapter || void 0;
|
|
5294
5563
|
if (modelConfigs !== void 0) {
|
|
5295
5564
|
updates["models"] = buildModelConfigs(modelConfigs);
|
|
5296
5565
|
}
|
|
@@ -5316,7 +5585,7 @@ async function createServerHandle(config3) {
|
|
|
5316
5585
|
return res.status(400).json({ error: result.error });
|
|
5317
5586
|
}
|
|
5318
5587
|
const llmClient = getLLMClient();
|
|
5319
|
-
const { loadGlobalConfig, saveGlobalConfig, setDefaultModelSelection } = await import("./config-
|
|
5588
|
+
const { loadGlobalConfig, saveGlobalConfig, setDefaultModelSelection } = await import("./config-EUMVEFHU.js");
|
|
5320
5589
|
const globalConfig = await loadGlobalConfig(config3.mode ?? "production", config3.globalConfigPath);
|
|
5321
5590
|
const updatedConfig = setDefaultModelSelection(globalConfig, id, llmClient.getModel());
|
|
5322
5591
|
await saveGlobalConfig(config3.mode ?? "production", updatedConfig, config3.globalConfigPath);
|
|
@@ -5343,7 +5612,7 @@ async function createServerHandle(config3) {
|
|
|
5343
5612
|
});
|
|
5344
5613
|
async function rebuildMcpTools() {
|
|
5345
5614
|
const { createMcpTools: createMcpTools2 } = await import("./tool-adapter-MOGEI6TP.js");
|
|
5346
|
-
const { setMcpTools: setMcpTools2 } = await import("./tools-
|
|
5615
|
+
const { setMcpTools: setMcpTools2 } = await import("./tools-R6LPK6OS.js");
|
|
5347
5616
|
const mcpTools = createMcpTools2(mcpManager);
|
|
5348
5617
|
setMcpTools2(mcpTools);
|
|
5349
5618
|
}
|
|
@@ -5405,7 +5674,7 @@ async function createServerHandle(config3) {
|
|
|
5405
5674
|
};
|
|
5406
5675
|
await mcpManager.addServer(name, serverCfg);
|
|
5407
5676
|
const server = mcpManager.getServer(name);
|
|
5408
|
-
const { loadGlobalConfig, saveGlobalConfig } = await import("./config-
|
|
5677
|
+
const { loadGlobalConfig, saveGlobalConfig } = await import("./config-EUMVEFHU.js");
|
|
5409
5678
|
const globalConfig = await loadGlobalConfig(config3.mode ?? "production", config3.globalConfigPath);
|
|
5410
5679
|
const updatedMcpServers = { ...globalConfig.mcpServers ?? {}, [name]: serverCfg };
|
|
5411
5680
|
await saveGlobalConfig(
|
|
@@ -5435,7 +5704,7 @@ async function createServerHandle(config3) {
|
|
|
5435
5704
|
return res.status(404).json({ error: `MCP server '${name}' not found` });
|
|
5436
5705
|
}
|
|
5437
5706
|
mcpManager.removeServer(name);
|
|
5438
|
-
const { loadGlobalConfig, saveGlobalConfig } = await import("./config-
|
|
5707
|
+
const { loadGlobalConfig, saveGlobalConfig } = await import("./config-EUMVEFHU.js");
|
|
5439
5708
|
const globalConfig = await loadGlobalConfig(config3.mode ?? "production", config3.globalConfigPath);
|
|
5440
5709
|
const updatedMcpServers = { ...globalConfig.mcpServers ?? {} };
|
|
5441
5710
|
delete updatedMcpServers[name];
|
|
@@ -5464,7 +5733,7 @@ async function createServerHandle(config3) {
|
|
|
5464
5733
|
await mcpManager.setToolEnabled(name, toolName, enabled);
|
|
5465
5734
|
const server = mcpManager.getServer(name);
|
|
5466
5735
|
if (server) {
|
|
5467
|
-
const { loadGlobalConfig, saveGlobalConfig } = await import("./config-
|
|
5736
|
+
const { loadGlobalConfig, saveGlobalConfig } = await import("./config-EUMVEFHU.js");
|
|
5468
5737
|
const globalConfig = await loadGlobalConfig(config3.mode ?? "production", config3.globalConfigPath);
|
|
5469
5738
|
const mcpServers2 = { ...globalConfig.mcpServers ?? {} };
|
|
5470
5739
|
const serverCfg = mcpServers2[name];
|
|
@@ -5540,14 +5809,14 @@ async function createServerHandle(config3) {
|
|
|
5540
5809
|
});
|
|
5541
5810
|
app.use("/api/directories", createDirectoryRoutes());
|
|
5542
5811
|
app.use("/api/files", createFileSearchRoutes());
|
|
5543
|
-
const webDir =
|
|
5812
|
+
const webDir = resolve5(__dirname3, "../../web");
|
|
5544
5813
|
const isDev = config3.mode === "development";
|
|
5545
5814
|
let viteServer;
|
|
5546
5815
|
if (isDev) {
|
|
5547
5816
|
logger.info("Dev mode: using Vite middleware");
|
|
5548
5817
|
viteServer = await createViteServer({
|
|
5549
5818
|
root: webDir,
|
|
5550
|
-
configFile:
|
|
5819
|
+
configFile: resolve5(__dirname3, "../../web/vite.config.ts"),
|
|
5551
5820
|
server: { middlewareMode: true },
|
|
5552
5821
|
appType: "spa",
|
|
5553
5822
|
logLevel: "warn"
|
|
@@ -5567,7 +5836,7 @@ async function createServerHandle(config3) {
|
|
|
5567
5836
|
}
|
|
5568
5837
|
});
|
|
5569
5838
|
app.get("/fox.svg", (_req, res) => {
|
|
5570
|
-
|
|
5839
|
+
readFile3(join8(webDir, "fox.svg")).then((content) => {
|
|
5571
5840
|
res.set("Content-Type", "image/svg+xml");
|
|
5572
5841
|
res.send(content);
|
|
5573
5842
|
}).catch(() => {
|
|
@@ -5576,7 +5845,7 @@ async function createServerHandle(config3) {
|
|
|
5576
5845
|
});
|
|
5577
5846
|
app.use(
|
|
5578
5847
|
"/sounds",
|
|
5579
|
-
express.static(
|
|
5848
|
+
express.static(join8(webDir, "public", "sounds"), {
|
|
5580
5849
|
setHeaders: (res) => {
|
|
5581
5850
|
res.set("Content-Type", "audio/mpeg");
|
|
5582
5851
|
}
|
|
@@ -5585,13 +5854,13 @@ async function createServerHandle(config3) {
|
|
|
5585
5854
|
app.use("/__inspect__.js", (_req, res) => {
|
|
5586
5855
|
res.set("Access-Control-Allow-Origin", "*");
|
|
5587
5856
|
res.set("Content-Type", "application/javascript");
|
|
5588
|
-
|
|
5857
|
+
readFile3(join8(webDir, "public", "__inspect__.js")).then((content) => res.send(content)).catch(() => res.status(404).send("Not found"));
|
|
5589
5858
|
});
|
|
5590
5859
|
app.get("/*path", (req, res) => {
|
|
5591
5860
|
if (req.path.startsWith("/api/")) {
|
|
5592
5861
|
return;
|
|
5593
5862
|
}
|
|
5594
|
-
|
|
5863
|
+
readFile3(join8(webDir, "index.html"), "utf-8").then((indexHtml) => viteServer.transformIndexHtml(req.originalUrl, indexHtml)).then((transformed) => res.send(transformed)).catch((err) => {
|
|
5595
5864
|
logger.error("Error serving index.html", { error: err });
|
|
5596
5865
|
res.status(500).send("Server error");
|
|
5597
5866
|
});
|
|
@@ -5599,10 +5868,10 @@ async function createServerHandle(config3) {
|
|
|
5599
5868
|
logger.info("Vite middleware ready", { port: config3.server.port });
|
|
5600
5869
|
}
|
|
5601
5870
|
if (!isDev) {
|
|
5602
|
-
const distWebDir =
|
|
5871
|
+
const distWebDir = resolve5(__dirname3, "web");
|
|
5603
5872
|
app.use(
|
|
5604
5873
|
"/assets",
|
|
5605
|
-
express.static(
|
|
5874
|
+
express.static(join8(distWebDir, "assets"), {
|
|
5606
5875
|
setHeaders: (res, filepath) => {
|
|
5607
5876
|
if (filepath.endsWith(".css")) {
|
|
5608
5877
|
res.set("Content-Type", "text/css");
|
|
@@ -5610,11 +5879,11 @@ async function createServerHandle(config3) {
|
|
|
5610
5879
|
}
|
|
5611
5880
|
})
|
|
5612
5881
|
);
|
|
5613
|
-
app.use("/manifest.webmanifest", express.static(
|
|
5614
|
-
app.use("/registerSW.js", express.static(
|
|
5615
|
-
app.use("/sw.js", express.static(
|
|
5882
|
+
app.use("/manifest.webmanifest", express.static(join8(distWebDir, "manifest.webmanifest")));
|
|
5883
|
+
app.use("/registerSW.js", express.static(join8(distWebDir, "registerSW.js")));
|
|
5884
|
+
app.use("/sw.js", express.static(join8(distWebDir, "sw.js")));
|
|
5616
5885
|
app.get("/fox.svg", (_req, res) => {
|
|
5617
|
-
|
|
5886
|
+
readFile3(join8(distWebDir, "fox.svg")).then((content) => {
|
|
5618
5887
|
res.set("Content-Type", "image/svg+xml");
|
|
5619
5888
|
res.send(content);
|
|
5620
5889
|
}).catch(() => {
|
|
@@ -5623,7 +5892,7 @@ async function createServerHandle(config3) {
|
|
|
5623
5892
|
});
|
|
5624
5893
|
app.use(
|
|
5625
5894
|
"/sounds",
|
|
5626
|
-
express.static(
|
|
5895
|
+
express.static(join8(distWebDir, "sounds"), {
|
|
5627
5896
|
setHeaders: (res) => {
|
|
5628
5897
|
res.set("Content-Type", "audio/mpeg");
|
|
5629
5898
|
}
|
|
@@ -5632,10 +5901,10 @@ async function createServerHandle(config3) {
|
|
|
5632
5901
|
app.use("/__inspect__.js", (_req, res) => {
|
|
5633
5902
|
res.set("Access-Control-Allow-Origin", "*");
|
|
5634
5903
|
res.set("Content-Type", "application/javascript");
|
|
5635
|
-
|
|
5904
|
+
readFile3(join8(distWebDir, "__inspect__.js")).then((content) => res.send(content)).catch(() => res.status(404).send("Not found"));
|
|
5636
5905
|
});
|
|
5637
5906
|
app.get("/", (_req, res) => {
|
|
5638
|
-
|
|
5907
|
+
readFile3(join8(distWebDir, "index.html"), "utf-8").then((content) => res.send(content)).catch(() => {
|
|
5639
5908
|
res.status(404).send("Web UI not built. Run `npm run build:web`");
|
|
5640
5909
|
});
|
|
5641
5910
|
});
|
|
@@ -5643,7 +5912,7 @@ async function createServerHandle(config3) {
|
|
|
5643
5912
|
if (req.path.startsWith("/api/") || req.path.startsWith("/assets/") || req.path.startsWith("/sounds/") || req.path.startsWith("/manifest.webmanifest") || req.path.startsWith("/registerSW.js") || req.path.startsWith("/sw.js") || req.path === "/fox.svg") {
|
|
5644
5913
|
return;
|
|
5645
5914
|
}
|
|
5646
|
-
|
|
5915
|
+
readFile3(join8(distWebDir, "index.html"), "utf-8").then((content) => res.send(content)).catch(() => {
|
|
5647
5916
|
res.status(404).send("Web UI not built");
|
|
5648
5917
|
});
|
|
5649
5918
|
});
|
|
@@ -5663,11 +5932,12 @@ async function createServerHandle(config3) {
|
|
|
5663
5932
|
const state = sessionManager.getContextState(sessionId);
|
|
5664
5933
|
wssExports.broadcastForSession(sessionId, createContextStateMessage(state));
|
|
5665
5934
|
});
|
|
5666
|
-
const { QueueProcessor } = await import("./processor-
|
|
5935
|
+
const { QueueProcessor } = await import("./processor-AYYXP5NS.js");
|
|
5667
5936
|
const queueProcessor = new QueueProcessor({
|
|
5668
5937
|
sessionManager,
|
|
5669
5938
|
providerManager,
|
|
5670
5939
|
getLLMClient,
|
|
5940
|
+
getLLMClientForProvider,
|
|
5671
5941
|
getActiveProvider: () => providerManager.getActiveProvider(),
|
|
5672
5942
|
broadcastForSession: wssExports.broadcastForSession
|
|
5673
5943
|
});
|
|
@@ -5685,7 +5955,7 @@ async function createServerHandle(config3) {
|
|
|
5685
5955
|
return {
|
|
5686
5956
|
httpServer,
|
|
5687
5957
|
ctx: { config: config3, sessionManager, llmClient: getLLMClient(), toolRegistry, providerManager },
|
|
5688
|
-
start: (port) => new Promise((
|
|
5958
|
+
start: (port) => new Promise((resolve6, reject) => {
|
|
5689
5959
|
const listenPort = port ?? config3.server.port;
|
|
5690
5960
|
const host = config3.server.host;
|
|
5691
5961
|
httpServer.listen(listenPort, host, () => {
|
|
@@ -5695,11 +5965,11 @@ async function createServerHandle(config3) {
|
|
|
5695
5965
|
logger.info(`OpenFox server running at http://${host}:${actualPort}`);
|
|
5696
5966
|
logger.info(`WebSocket available at ws://${host}:${actualPort}/ws`);
|
|
5697
5967
|
logger.info(`LLM backend: ${client.getBackend()}, model: ${client.getModel()}, url: ${config3.llm.baseUrl}`);
|
|
5698
|
-
|
|
5968
|
+
resolve6({ port: actualPort });
|
|
5699
5969
|
});
|
|
5700
5970
|
httpServer.on("error", reject);
|
|
5701
5971
|
}),
|
|
5702
|
-
close: () => new Promise((
|
|
5972
|
+
close: () => new Promise((resolve6) => {
|
|
5703
5973
|
logger.info("Shutting down...");
|
|
5704
5974
|
void (async () => {
|
|
5705
5975
|
await devServerManager.stopAll();
|
|
@@ -5718,7 +5988,7 @@ async function createServerHandle(config3) {
|
|
|
5718
5988
|
client.terminate();
|
|
5719
5989
|
}
|
|
5720
5990
|
wss.close();
|
|
5721
|
-
httpServer.close(() =>
|
|
5991
|
+
httpServer.close(() => resolve6());
|
|
5722
5992
|
})();
|
|
5723
5993
|
})
|
|
5724
5994
|
};
|
|
@@ -5743,4 +6013,4 @@ export {
|
|
|
5743
6013
|
createServerHandle,
|
|
5744
6014
|
createServer
|
|
5745
6015
|
};
|
|
5746
|
-
//# sourceMappingURL=chunk-
|
|
6016
|
+
//# sourceMappingURL=chunk-JFQSQO2N.js.map
|