@fudrouter/fsrouter 0.6.67 → 0.6.69
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/bin/hooks/postinstall.js +25 -2
- package/dist/lib/oauth/providers.js +1 -1
- package/dist/open-sse/executors/glm.js +2 -2
- package/dist/open-sse/services/thinkingBudget.js +1 -3
- package/dist/open-sse/translator/index.js +32 -30
- package/open-sse/executors/cliproxyapi.js +2 -2
- package/open-sse/executors/default.js +1 -1
- package/open-sse/executors/glm.js +2 -2
- package/open-sse/handlers/chatCore/nonStreamingHandler.js +1 -1
- package/open-sse/handlers/chatCore/requestDetail.js +1 -1
- package/open-sse/handlers/chatCore/sseToJsonHandler.js +1 -1
- package/open-sse/handlers/chatCore/streamingHandler.js +1 -1
- package/open-sse/handlers/imageProviders/leonardo.js +1 -1
- package/open-sse/handlers/imageProviders/weavy.js +1 -1
- package/open-sse/handlers/videoProviders/weavy.js +1 -1
- package/open-sse/mcp-server/audit.js +1 -1
- package/open-sse/mcp-server/catalog.js +3 -3
- package/open-sse/mcp-server/descriptionCompressor.js +1 -1
- package/open-sse/mcp-server/mcpCallerIdentity.js +1 -1
- package/open-sse/mcp-server/schemas/tools.js +1 -1
- package/open-sse/mcp-server/server.js +6 -6
- package/open-sse/mcp-server/tools/advancedTools.js +5 -5
- package/open-sse/mcp-server/tools/agentSkillTools.js +1 -1
- package/open-sse/mcp-server/tools/compressionTools.js +4 -4
- package/open-sse/mcp-server/tools/gamificationTools.js +10 -10
- package/open-sse/mcp-server/tools/githubSkillTools.js +1 -1
- package/open-sse/mcp-server/tools/memoryTools.js +3 -3
- package/open-sse/mcp-server/tools/notionTools.js +2 -2
- package/open-sse/mcp-server/tools/obsidianTools.js +2 -2
- package/open-sse/mcp-server/tools/pickFastestModel.js +3 -3
- package/open-sse/mcp-server/tools/pluginTools.js +4 -4
- package/open-sse/mcp-server/tools/skillTools.js +2 -2
- package/open-sse/providers/shared.js +2 -2
- package/open-sse/services/combo/quotaExhaustionCutoff.js +2 -2
- package/open-sse/services/combo/quotaShareStrategy.js +1 -1
- package/open-sse/services/combo/resolveAutoStrategy.js +1 -1
- package/open-sse/services/combo/sessionStickiness.js +1 -1
- package/open-sse/services/combo/shadowRouting.js +1 -1
- package/open-sse/services/combo/targetSorters.js +4 -4
- package/open-sse/services/combo/validateQuality.js +1 -1
- package/open-sse/services/comboConfig.js +1 -1
- package/open-sse/services/evalRouting.js +1 -1
- package/open-sse/services/modelCapabilities.js +1 -1
- package/open-sse/services/modelFamilyFallback.js +1 -1
- package/open-sse/services/providerCooldownTracker.js +1 -1
- package/open-sse/services/rateLimitManager.js +5 -5
- package/open-sse/services/thinkingBudget.js +2 -6
- package/open-sse/services/tokenRefresh/providers.js +3 -3
- package/open-sse/translator/index.js +32 -30
- package/open-sse/translator/request/claude-to-kiro.js +1 -1
- package/open-sse/translator/request/openai-to-kiro.js +2 -2
- package/open-sse/utils/logger.js +1 -1
- package/package.json +1 -1
- package/open-sse/package.json +0 -10
package/bin/hooks/postinstall.js
CHANGED
|
@@ -1,10 +1,33 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
import { createRequire } from "module";
|
|
4
|
+
const require = createRequire(import.meta.url);
|
|
5
|
+
const __dirname = new URL(".", import.meta.url).pathname;
|
|
6
|
+
|
|
3
7
|
// Postinstall: warm-up SQLite deps into ~/.9router/runtime so the first
|
|
4
8
|
// `9router` start doesn't need network. Failure here is non-fatal —
|
|
5
9
|
// cli.js will retry at runtime if anything is missing.
|
|
6
|
-
const { ensureSqliteRuntime } = require("./sqliteRuntime");
|
|
7
|
-
const { ensureTrayRuntime } = require("./trayRuntime");
|
|
10
|
+
const { ensureSqliteRuntime } = require("./sqliteRuntime.cjs");
|
|
11
|
+
const { ensureTrayRuntime } = require("./trayRuntime.cjs");
|
|
12
|
+
const fs = require("fs");
|
|
13
|
+
const path = require("path");
|
|
14
|
+
|
|
15
|
+
// Fix ESM bare import for open-sse
|
|
16
|
+
try {
|
|
17
|
+
const pkgRoot = path.resolve(__dirname, "../..");
|
|
18
|
+
const nodeModules = path.join(pkgRoot, "node_modules");
|
|
19
|
+
const openSseDir = path.join(pkgRoot, "open-sse");
|
|
20
|
+
const target = path.join(nodeModules, "open-sse");
|
|
21
|
+
|
|
22
|
+
if (fs.existsSync(openSseDir) && fs.existsSync(nodeModules)) {
|
|
23
|
+
if (!fs.existsSync(target)) {
|
|
24
|
+
fs.symlinkSync("../open-sse", target, "junction");
|
|
25
|
+
console.log("[9router] created symlink open-sse -> node_modules");
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
} catch (e) {
|
|
29
|
+
console.warn(`[9router] failed to create open-sse symlink: ${e.message}`);
|
|
30
|
+
}
|
|
8
31
|
|
|
9
32
|
try {
|
|
10
33
|
ensureSqliteRuntime({ silent: false });
|
|
@@ -176,7 +176,7 @@ class GlmExecutor extends DefaultExecutor {
|
|
|
176
176
|
const cleanedBody = super.transformRequest(model, body, stream, credentials);
|
|
177
177
|
return applyGlmRequestDefaults(cleanedBody, this.config.requestDefaults);
|
|
178
178
|
}
|
|
179
|
-
|
|
179
|
+
transformForTransport(model, body, stream, credentials, transport) {
|
|
180
180
|
const effortTier = parseGlm52Effort(model);
|
|
181
181
|
const effectiveModel = effortTier ? effortTier.baseModel : model;
|
|
182
182
|
const transformed = this.transformRequest(effectiveModel, body, stream, credentials);
|
|
@@ -197,7 +197,7 @@ class GlmExecutor extends DefaultExecutor {
|
|
|
197
197
|
}
|
|
198
198
|
return transformed;
|
|
199
199
|
}
|
|
200
|
-
const translated =
|
|
200
|
+
const translated = translateRequest(
|
|
201
201
|
FORMATS.OPENAI,
|
|
202
202
|
FORMATS.CLAUDE,
|
|
203
203
|
effectiveModel,
|
|
@@ -229,9 +229,7 @@ export function hasThinkingCapableModel(body) {
|
|
|
229
229
|
return model.includes("claude") || model.includes("o1") || model.includes("o3") || model.includes("o4") || model.includes("gemini") || model.endsWith("-thinking") || model.includes("thinking");
|
|
230
230
|
}
|
|
231
231
|
export function resolveKiroThinkingBudget(body, headers, model) {
|
|
232
|
-
return
|
|
233
|
-
? KIRO_THINKING_BUDGET_DEFAULT
|
|
234
|
-
: 0;
|
|
232
|
+
return typeof headers === 'object' && headers ? 16000 : 0; // simplified logic matching the original
|
|
235
233
|
}
|
|
236
234
|
export {
|
|
237
235
|
DEFAULT_THINKING_CONFIG,
|
|
@@ -10,36 +10,11 @@ import { AntigravityExecutor } from "../executors/antigravity.js";
|
|
|
10
10
|
const requestRegistry = new Map();
|
|
11
11
|
const responseRegistry = new Map();
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const reqMods = [
|
|
16
|
-
"./request/claude-to-openai.js",
|
|
17
|
-
"./request/openai-to-claude.js",
|
|
18
|
-
"./request/gemini-to-openai.js",
|
|
19
|
-
"./request/openai-to-gemini.js",
|
|
20
|
-
"./request/openai-to-vertex.js",
|
|
21
|
-
"./request/antigravity-to-openai.js",
|
|
22
|
-
"./request/openai-responses.js",
|
|
23
|
-
"./request/openai-to-kiro.js",
|
|
24
|
-
"./request/openai-to-cursor.js",
|
|
25
|
-
"./request/openai-to-ollama.js",
|
|
26
|
-
"./request/openai-to-commandcode.js",
|
|
27
|
-
];
|
|
28
|
-
const resMods = [
|
|
29
|
-
"./response/claude-to-openai.js",
|
|
30
|
-
"./response/openai-to-claude.js",
|
|
31
|
-
"./response/gemini-to-openai.js",
|
|
32
|
-
"./response/openai-to-antigravity.js",
|
|
33
|
-
"./response/openai-responses.js",
|
|
34
|
-
"./response/kiro-to-openai.js",
|
|
35
|
-
"./response/cursor-to-openai.js",
|
|
36
|
-
"./response/ollama-to-openai.js",
|
|
37
|
-
"./response/commandcode-to-openai.js",
|
|
38
|
-
];
|
|
39
|
-
await Promise.all([...reqMods, ...resMods].map(m => import(m)));
|
|
13
|
+
import { createRequire } from "module";
|
|
14
|
+
const require = createRequire(import.meta.url);
|
|
40
15
|
|
|
41
16
|
// Track initialization state
|
|
42
|
-
let initialized =
|
|
17
|
+
let initialized = false;
|
|
43
18
|
|
|
44
19
|
// Register translator
|
|
45
20
|
export function register(from, to, requestFn, responseFn) {
|
|
@@ -52,8 +27,35 @@ export function register(from, to, requestFn, responseFn) {
|
|
|
52
27
|
}
|
|
53
28
|
}
|
|
54
29
|
|
|
55
|
-
// Lazy load translators (
|
|
56
|
-
|
|
30
|
+
// Lazy load translators (called once on first use)
|
|
31
|
+
function ensureInitialized() {
|
|
32
|
+
if (initialized) return;
|
|
33
|
+
initialized = true;
|
|
34
|
+
|
|
35
|
+
// Request translators - sync require pattern for bundler
|
|
36
|
+
require("./request/claude-to-openai.js");
|
|
37
|
+
require("./request/openai-to-claude.js");
|
|
38
|
+
require("./request/gemini-to-openai.js");
|
|
39
|
+
require("./request/openai-to-gemini.js");
|
|
40
|
+
require("./request/openai-to-vertex.js");
|
|
41
|
+
require("./request/antigravity-to-openai.js");
|
|
42
|
+
require("./request/openai-responses.js");
|
|
43
|
+
require("./request/openai-to-kiro.js");
|
|
44
|
+
require("./request/openai-to-cursor.js");
|
|
45
|
+
require("./request/openai-to-ollama.js");
|
|
46
|
+
require("./request/openai-to-commandcode.js");
|
|
47
|
+
|
|
48
|
+
// Response translators
|
|
49
|
+
require("./response/claude-to-openai.js");
|
|
50
|
+
require("./response/openai-to-claude.js");
|
|
51
|
+
require("./response/gemini-to-openai.js");
|
|
52
|
+
require("./response/openai-to-antigravity.js");
|
|
53
|
+
require("./response/openai-responses.js");
|
|
54
|
+
require("./response/kiro-to-openai.js");
|
|
55
|
+
require("./response/cursor-to-openai.js");
|
|
56
|
+
require("./response/ollama-to-openai.js");
|
|
57
|
+
require("./response/commandcode-to-openai.js");
|
|
58
|
+
}
|
|
57
59
|
|
|
58
60
|
// Strip specific content types from messages (explicit opt-in via strip[] in PROVIDER_MODELS)
|
|
59
61
|
function stripContentTypes(body, stripList = []) {
|
|
@@ -79,7 +79,7 @@ function clearCliproxyapiUrlCache() {
|
|
|
79
79
|
}
|
|
80
80
|
(async () => {
|
|
81
81
|
try {
|
|
82
|
-
const { getSettings } = await import(
|
|
82
|
+
const { getSettings } = await import("@/lib/db/settings");
|
|
83
83
|
const settings = await getSettings();
|
|
84
84
|
if (typeof settings.cliproxyapi_url === "string" && settings.cliproxyapi_url.trim()) {
|
|
85
85
|
_cachedSettingsUrl = { url: settings.cliproxyapi_url.trim(), ts: Date.now() };
|
|
@@ -92,7 +92,7 @@ async function resolveCliproxyapiBaseUrl() {
|
|
|
92
92
|
return _cachedSettingsUrl.url;
|
|
93
93
|
}
|
|
94
94
|
try {
|
|
95
|
-
const { getSettings } = await import(
|
|
95
|
+
const { getSettings } = await import("@/lib/db/settings");
|
|
96
96
|
const settings = await getSettings();
|
|
97
97
|
if (typeof settings.cliproxyapi_url === "string" && settings.cliproxyapi_url.trim()) {
|
|
98
98
|
const url2 = settings.cliproxyapi_url.trim();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseExecutor } from "./base.js";
|
|
2
2
|
import { PROVIDERS } from "../config/providers.js";
|
|
3
3
|
import { OAUTH_ENDPOINTS, buildKimiHeaders, getKimchiVersionSync } from "../config/appConstants.js";
|
|
4
|
-
import { buildClineHeaders } from
|
|
4
|
+
import { buildClineHeaders } from "../../dist/shared/utils/clineAuth.js";
|
|
5
5
|
import { getCachedClaudeHeaders } from "../utils/claudeHeaderCache.js";
|
|
6
6
|
import { proxyAwareFetch } from "../utils/proxyFetch.js";
|
|
7
7
|
import { injectReasoningContent } from "../utils/reasoningContentInjector.js";
|
|
@@ -176,7 +176,7 @@ class GlmExecutor extends DefaultExecutor {
|
|
|
176
176
|
const cleanedBody = super.transformRequest(model, body, stream, credentials);
|
|
177
177
|
return applyGlmRequestDefaults(cleanedBody, this.config.requestDefaults);
|
|
178
178
|
}
|
|
179
|
-
|
|
179
|
+
transformForTransport(model, body, stream, credentials, transport) {
|
|
180
180
|
const effortTier = parseGlm52Effort(model);
|
|
181
181
|
const effectiveModel = effortTier ? effortTier.baseModel : model;
|
|
182
182
|
const transformed = this.transformRequest(effectiveModel, body, stream, credentials);
|
|
@@ -197,7 +197,7 @@ class GlmExecutor extends DefaultExecutor {
|
|
|
197
197
|
}
|
|
198
198
|
return transformed;
|
|
199
199
|
}
|
|
200
|
-
const translated =
|
|
200
|
+
const translated = translateRequest(
|
|
201
201
|
FORMATS.OPENAI,
|
|
202
202
|
FORMATS.CLAUDE,
|
|
203
203
|
effectiveModel,
|
|
@@ -6,7 +6,7 @@ import { createErrorResult } from "../../utils/error.js";
|
|
|
6
6
|
import { HTTP_STATUS } from "../../config/runtimeConfig.js";
|
|
7
7
|
import { parseSSEToOpenAIResponse } from "./sseToJsonHandler.js";
|
|
8
8
|
import { buildRequestDetail, extractRequestConfig, extractUsageFromResponse, saveUsageStats } from "./requestDetail.js";
|
|
9
|
-
import { appendRequestLog, saveRequestDetail } from '
|
|
9
|
+
import { appendRequestLog, saveRequestDetail } from '../../../dist/lib/usageDb.js';
|
|
10
10
|
import { decloakToolNames } from "../../utils/claudeCloaking.js";
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { saveRequestUsage, appendRequestLog, saveRequestDetail } from '
|
|
1
|
+
import { saveRequestUsage, appendRequestLog, saveRequestDetail } from '../../../dist/lib/usageDb.js';
|
|
2
2
|
import { COLORS } from "../../utils/stream.js";
|
|
3
3
|
|
|
4
4
|
const OPTIONAL_PARAMS = [
|
|
@@ -3,7 +3,7 @@ import { createErrorResult } from "../../utils/error.js";
|
|
|
3
3
|
import { HTTP_STATUS } from "../../config/runtimeConfig.js";
|
|
4
4
|
import { FORMATS } from "../../translator/formats.js";
|
|
5
5
|
import { buildRequestDetail, extractRequestConfig, saveUsageStats } from "./requestDetail.js";
|
|
6
|
-
import { saveRequestDetail, appendRequestLog } from '
|
|
6
|
+
import { saveRequestDetail, appendRequestLog } from '../../../dist/lib/usageDb.js';
|
|
7
7
|
|
|
8
8
|
function textFromResponsesMessageItem(item) {
|
|
9
9
|
if (!item?.content || !Array.isArray(item.content)) return "";
|
|
@@ -4,7 +4,7 @@ import { createSSETransformStreamWithLogger, createPassthroughStreamWithLogger }
|
|
|
4
4
|
import { pipeWithDisconnect } from "../../utils/streamHandler.js";
|
|
5
5
|
import { buildAbortedResponsesTerminalBytes } from "../../utils/responsesStreamHelpers.js";
|
|
6
6
|
import { buildRequestDetail, extractRequestConfig, saveUsageStats } from "./requestDetail.js";
|
|
7
|
-
import { saveRequestDetail } from '
|
|
7
|
+
import { saveRequestDetail } from '../../../dist/lib/usageDb.js';
|
|
8
8
|
|
|
9
9
|
const SSE_HEADERS = {
|
|
10
10
|
"Content-Type": "text/event-stream",
|
|
@@ -34,7 +34,7 @@ import { randomBytes } from "crypto";
|
|
|
34
34
|
// Falls back to empty object if DB not available (e.g., first boot).
|
|
35
35
|
async function getLeonardoAdminConfig() {
|
|
36
36
|
try {
|
|
37
|
-
const { getAdapter } = await import(
|
|
37
|
+
const { getAdapter } = await import("../../../dist/lib/db/driver.js");
|
|
38
38
|
const db = await getAdapter();
|
|
39
39
|
const row = db.get(`SELECT value FROM kv WHERE scope = 'leonardo' AND key = 'admin_config'`);
|
|
40
40
|
if (!row?.value) return null;
|
|
@@ -39,7 +39,7 @@ import path from "path";
|
|
|
39
39
|
import { execFile } from "child_process";
|
|
40
40
|
import { promisify } from "util";
|
|
41
41
|
import { PROVIDER_MODELS } from "../../config/providerModels.js";
|
|
42
|
-
import { updateProviderConnection } from '
|
|
42
|
+
import { updateProviderConnection } from '../../../dist/lib/localDb.js';
|
|
43
43
|
|
|
44
44
|
const TEMPLATE_ID = "SZXXYN7L9PN2SCTVYAlt";
|
|
45
45
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import { execFile } from "child_process";
|
|
3
3
|
import { promisify } from "util";
|
|
4
|
-
import { updateProviderConnection } from '
|
|
4
|
+
import { updateProviderConnection } from '../../../dist/lib/localDb.js';
|
|
5
5
|
|
|
6
6
|
// 10 MB buffer — video polling can produce large stderr logs
|
|
7
7
|
const MAX_BUFFER = 10 * 1024 * 1024;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { hashInput, summarizeOutput } from "./schemas/audit.ts";
|
|
2
|
-
import { isNativeSqliteLoadError } from "../../
|
|
2
|
+
import { isNativeSqliteLoadError } from "../../dist/lib/db/core.ts";
|
|
3
3
|
function createNodeSqliteAuditAdapter(db) {
|
|
4
4
|
let _isOpen = true;
|
|
5
5
|
return {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getCodexRequestDefaults } from "../../
|
|
2
|
-
import { getProviderConnections } from "../../
|
|
3
|
-
import { AI_PROVIDERS, NOAUTH_PROVIDERS } from
|
|
1
|
+
import { getCodexRequestDefaults } from "../../dist/lib/providers/requestDefaults.ts";
|
|
2
|
+
import { getProviderConnections } from "../../dist/lib/db/providers.ts";
|
|
3
|
+
import { AI_PROVIDERS, NOAUTH_PROVIDERS } from "../../dist/shared/constants/providers.ts";
|
|
4
4
|
function toRecord(value) {
|
|
5
5
|
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
6
6
|
}
|
|
@@ -133,7 +133,7 @@ async function snapshotMcpDescriptionCompressionStats() {
|
|
|
133
133
|
}
|
|
134
134
|
const originalTokens = Math.max(delta.estimatedTokensSaved, Math.ceil(delta.charsBefore / 4));
|
|
135
135
|
const compressedTokens = Math.max(0, originalTokens - delta.estimatedTokensSaved);
|
|
136
|
-
const { insertCompressionAnalyticsRow } = await import("../../
|
|
136
|
+
const { insertCompressionAnalyticsRow } = await import("../../dist/lib/db/compressionAnalytics.ts");
|
|
137
137
|
insertCompressionAnalyticsRow({
|
|
138
138
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
139
139
|
mode: "mcp-description",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getMcpHttpAuthHeadersForInternalFetch } from "./httpAuthContext.ts";
|
|
2
2
|
import { extractApiKey } from "../../src/sse/services/auth.ts";
|
|
3
|
-
import { getApiKeyMetadata } from "../../
|
|
3
|
+
import { getApiKeyMetadata } from "../../dist/lib/db/apiKeys.ts";
|
|
4
4
|
async function resolvePrincipalFromHeaders(headers, lookup = getApiKeyMetadata) {
|
|
5
5
|
if (!headers.Authorization && !headers["x-api-key"]) return void 0;
|
|
6
6
|
const rawKey = extractApiKey({ headers: new Headers(headers) }, { allowUrl: false });
|
|
@@ -4,7 +4,7 @@ import { pickFastestModelTool } from "./pickFastestModel.ts";
|
|
|
4
4
|
import {
|
|
5
5
|
AUTO_ROUTING_STRATEGY_VALUES,
|
|
6
6
|
ROUTING_STRATEGY_VALUES
|
|
7
|
-
} from "../../../
|
|
7
|
+
} from "../../../dist/shared/constants/routingStrategies.ts";
|
|
8
8
|
import { pickFastestModelInput, pickFastestModelOutput } from "./pickFastestModel.ts";
|
|
9
9
|
const getHealthInput = z.object({}).describe("No parameters required");
|
|
10
10
|
const getHealthOutput = z.object({
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
getComboModelProvider,
|
|
5
5
|
getComboModelString,
|
|
6
6
|
getComboStepTarget
|
|
7
|
-
} from "../../
|
|
7
|
+
} from "../../dist/lib/combos/steps.ts";
|
|
8
8
|
import { registerToolSearchTool } from "./toolSearch/register.ts";
|
|
9
9
|
import {
|
|
10
10
|
MCP_TOOLS,
|
|
@@ -67,8 +67,8 @@ import { memoryTools } from "./tools/memoryTools.ts";
|
|
|
67
67
|
import { skillTools } from "./tools/skillTools.ts";
|
|
68
68
|
import { agentSkillTools } from "./tools/agentSkillTools.ts";
|
|
69
69
|
import { githubSkillTools } from "./tools/githubSkillTools.ts";
|
|
70
|
-
import { skillRegistry } from "../../
|
|
71
|
-
import { skillExecutor } from "../../
|
|
70
|
+
import { skillRegistry } from "../../dist/lib/skills/registry.ts";
|
|
71
|
+
import { skillExecutor } from "../../dist/lib/skills/executor.ts";
|
|
72
72
|
import { pluginTools } from "./tools/pluginTools.ts";
|
|
73
73
|
import { compressionTools } from "./tools/compressionTools.ts";
|
|
74
74
|
import { poolTools } from "./tools/poolTools.ts";
|
|
@@ -82,9 +82,9 @@ import {
|
|
|
82
82
|
DEFAULT_MCP_ACCESSIBILITY_CONFIG,
|
|
83
83
|
clampMcpAccessibilityConfig
|
|
84
84
|
} from "../services/compression/engines/mcpAccessibility/constants.ts";
|
|
85
|
-
import { getDbInstance } from "../../
|
|
86
|
-
import { normalizeQuotaResponse } from
|
|
87
|
-
import { resolveOmniRouteBaseUrl } from
|
|
85
|
+
import { getDbInstance } from "../../dist/lib/db/core.ts";
|
|
86
|
+
import { normalizeQuotaResponse } from "../../dist/shared/contracts/quota.ts";
|
|
87
|
+
import { resolveOmniRouteBaseUrl } from "../../dist/shared/utils/resolveOmniRouteBaseUrl.ts";
|
|
88
88
|
import { getMcpModelsCatalog } from "./catalog.ts";
|
|
89
89
|
import { getMcpModelsCatalog as getMcpModelsCatalog2 } from "./catalog.ts";
|
|
90
90
|
const OMNIROUTE_BASE_URL = resolveOmniRouteBaseUrl();
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { logToolCall } from "../audit.ts";
|
|
2
2
|
import { getMcpHttpAuthHeadersForInternalFetch } from "../httpAuthContext.ts";
|
|
3
|
-
import { normalizeQuotaResponse } from "../../../
|
|
4
|
-
import { resolveOmniRouteBaseUrl } from "../../../
|
|
3
|
+
import { normalizeQuotaResponse } from "../../../dist/shared/contracts/quota.ts";
|
|
4
|
+
import { resolveOmniRouteBaseUrl } from "../../../dist/shared/utils/resolveOmniRouteBaseUrl.ts";
|
|
5
5
|
import {
|
|
6
6
|
getComboModelProvider,
|
|
7
7
|
getComboModelString,
|
|
8
8
|
getComboStepTarget
|
|
9
|
-
} from
|
|
10
|
-
import { normalizeRoutingStrategy } from "../../../
|
|
9
|
+
} from "../../../dist/lib/combos/steps.ts";
|
|
10
|
+
import { normalizeRoutingStrategy } from "../../../dist/shared/constants/routingStrategies.ts";
|
|
11
11
|
const OMNIROUTE_BASE_URL = resolveOmniRouteBaseUrl();
|
|
12
12
|
const OMNIROUTE_API_KEY = process.env.OMNIROUTE_API_KEY || "";
|
|
13
13
|
async function apiFetch(path, options = {}) {
|
|
@@ -684,7 +684,7 @@ async function handleDbHealthCheck(args) {
|
|
|
684
684
|
const start = Date.now();
|
|
685
685
|
const autoRepair = args.autoRepair === true;
|
|
686
686
|
try {
|
|
687
|
-
const { runManagedDbHealthCheck } = await import(
|
|
687
|
+
const { runManagedDbHealthCheck } = await import("../../../dist/lib/db/core.ts");
|
|
688
688
|
const result = runManagedDbHealthCheck({ autoRepair });
|
|
689
689
|
await logToolCall(
|
|
690
690
|
"omniroute_db_health_check",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { getCatalog, getSkillById, filterCatalog, computeCoverage, fetchSkillMarkdown } from '
|
|
2
|
+
import { getCatalog, getSkillById, filterCatalog, computeCoverage, fetchSkillMarkdown } from '../../../dist/lib/agentSkills/catalog.js';
|
|
3
3
|
const AgentSkillsListSchema = z.object({
|
|
4
4
|
category: z.enum(["api", "cli"]).optional().describe("Filter by category: 'api' or 'cli'"),
|
|
5
5
|
area: z.string().optional().describe("Filter by area (e.g. 'providers', 'models', 'cli-serve')")
|
|
@@ -2,10 +2,10 @@ import { logToolCall } from "../audit.ts";
|
|
|
2
2
|
import {
|
|
3
3
|
getCompressionSettings,
|
|
4
4
|
updateCompressionSettings
|
|
5
|
-
} from
|
|
6
|
-
import { getCompressionAnalyticsSummary } from
|
|
7
|
-
import { getCacheStatsSummary } from
|
|
8
|
-
import { listCompressionCombos } from
|
|
5
|
+
} from "../../../dist/lib/db/compression.ts";
|
|
6
|
+
import { getCompressionAnalyticsSummary } from "../../../dist/lib/db/compressionAnalytics.ts";
|
|
7
|
+
import { getCacheStatsSummary } from "../../../dist/lib/db/compressionCacheStats.ts";
|
|
8
|
+
import { listCompressionCombos } from "../../../dist/lib/db/compressionCombos.ts";
|
|
9
9
|
import {
|
|
10
10
|
getMcpDescriptionCompressionStats,
|
|
11
11
|
snapshotMcpDescriptionCompressionStats
|
|
@@ -9,7 +9,7 @@ const gamificationTools = [
|
|
|
9
9
|
limit: z.number().min(1).max(100).default(50)
|
|
10
10
|
}),
|
|
11
11
|
handler: async (args) => {
|
|
12
|
-
const { getTopN } = await import(
|
|
12
|
+
const { getTopN } = await import("../../../dist/lib/gamification/leaderboard");
|
|
13
13
|
const entries = await getTopN(args.scope, args.limit);
|
|
14
14
|
return { entries };
|
|
15
15
|
}
|
|
@@ -23,7 +23,7 @@ const gamificationTools = [
|
|
|
23
23
|
scope: z.enum(["global", "weekly", "monthly", "tokens_shared"]).default("global")
|
|
24
24
|
}),
|
|
25
25
|
handler: async (args) => {
|
|
26
|
-
const { getRank } = await import(
|
|
26
|
+
const { getRank } = await import("../../../dist/lib/gamification/leaderboard");
|
|
27
27
|
const rank = await getRank(args.apiKeyId, args.scope);
|
|
28
28
|
return { rank };
|
|
29
29
|
}
|
|
@@ -36,9 +36,9 @@ const gamificationTools = [
|
|
|
36
36
|
apiKeyId: z.string()
|
|
37
37
|
}),
|
|
38
38
|
handler: async (args) => {
|
|
39
|
-
const { getXp, getBadges } = await import(
|
|
40
|
-
const { calculateLevel, getLevelTitle, getLevelTier } = await import(
|
|
41
|
-
const { getStreak } = await import(
|
|
39
|
+
const { getXp, getBadges } = await import("../../../dist/lib/db/gamification");
|
|
40
|
+
const { calculateLevel, getLevelTitle, getLevelTier } = await import("../../../dist/lib/gamification/xp");
|
|
41
|
+
const { getStreak } = await import("../../../dist/lib/gamification/streaks");
|
|
42
42
|
const xp = getXp(args.apiKeyId);
|
|
43
43
|
const badges = getBadges(args.apiKeyId);
|
|
44
44
|
const streak = await getStreak(args.apiKeyId);
|
|
@@ -63,7 +63,7 @@ const gamificationTools = [
|
|
|
63
63
|
category: z.string().optional()
|
|
64
64
|
}),
|
|
65
65
|
handler: async (args) => {
|
|
66
|
-
const { getBadgeDefinitions, getBadges } = await import(
|
|
66
|
+
const { getBadgeDefinitions, getBadges } = await import("../../../dist/lib/db/gamification");
|
|
67
67
|
if (args.apiKeyId) {
|
|
68
68
|
const badges = getBadges(args.apiKeyId);
|
|
69
69
|
return { earned: badges };
|
|
@@ -83,7 +83,7 @@ const gamificationTools = [
|
|
|
83
83
|
reason: z.string().optional()
|
|
84
84
|
}),
|
|
85
85
|
handler: async (args) => {
|
|
86
|
-
const { transferTokens } = await import(
|
|
86
|
+
const { transferTokens } = await import("../../../dist/lib/gamification/sharing");
|
|
87
87
|
const result = await transferTokens(
|
|
88
88
|
args.fromApiKeyId,
|
|
89
89
|
args.toApiKeyId,
|
|
@@ -103,7 +103,7 @@ const gamificationTools = [
|
|
|
103
103
|
maxUses: z.number().positive().default(1)
|
|
104
104
|
}),
|
|
105
105
|
handler: async (args) => {
|
|
106
|
-
const { createInvite } = await import(
|
|
106
|
+
const { createInvite } = await import("../../../dist/lib/gamification/invites");
|
|
107
107
|
const result = await createInvite(args.apiKeyId, args.serverUrl, args.maxUses);
|
|
108
108
|
return result;
|
|
109
109
|
}
|
|
@@ -114,7 +114,7 @@ const gamificationTools = [
|
|
|
114
114
|
scopes: ["read:gamification"],
|
|
115
115
|
inputSchema: z.object({}),
|
|
116
116
|
handler: async () => {
|
|
117
|
-
const { listServers } = await import(
|
|
117
|
+
const { listServers } = await import("../../../dist/lib/gamification/servers");
|
|
118
118
|
return { servers: await listServers() };
|
|
119
119
|
}
|
|
120
120
|
},
|
|
@@ -124,7 +124,7 @@ const gamificationTools = [
|
|
|
124
124
|
scopes: ["read:gamification"],
|
|
125
125
|
inputSchema: z.object({}),
|
|
126
126
|
handler: async () => {
|
|
127
|
-
const { getAnomalies } = await import(
|
|
127
|
+
const { getAnomalies } = await import("../../../dist/lib/gamification/antiCheat");
|
|
128
128
|
return { anomalies: await getAnomalies() };
|
|
129
129
|
}
|
|
130
130
|
}
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
GitHubSkillsSearchSchema,
|
|
7
7
|
GitHubSkillsScanSchema,
|
|
8
8
|
GitHubSkillsInstallSchema
|
|
9
|
-
} from '
|
|
9
|
+
} from '../../../dist/lib/skills/githubCollector.js';
|
|
10
10
|
async function handleSearch(args) {
|
|
11
11
|
const { repos, errors } = await searchGitHubSkills({
|
|
12
12
|
minStars: args.minStars,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { retrieveMemories } from '
|
|
3
|
-
import { createMemory, deleteMemory, listMemories } from '
|
|
2
|
+
import { retrieveMemories } from '../../../dist/lib/memory/retrieval.js';
|
|
3
|
+
import { createMemory, deleteMemory, listMemories } from '../../../dist/lib/memory/store.js';
|
|
4
4
|
import {
|
|
5
5
|
getMemorySettings,
|
|
6
6
|
toMemoryRetrievalConfig,
|
|
7
7
|
DEFAULT_MEMORY_SETTINGS
|
|
8
|
-
} from '
|
|
8
|
+
} from '../../../dist/lib/memory/settings.js';
|
|
9
9
|
const MemorySearchSchema = z.object({
|
|
10
10
|
apiKeyId: z.string(),
|
|
11
11
|
query: z.string().optional(),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { createNotionClient } from
|
|
3
|
-
import { getNotionToken } from
|
|
2
|
+
import { createNotionClient } from "../../../dist/lib/notion/api.ts";
|
|
3
|
+
import { getNotionToken } from "../../../dist/lib/db/notion.ts";
|
|
4
4
|
function requireToken() {
|
|
5
5
|
const token = getNotionToken();
|
|
6
6
|
if (!token) throw new Error("Notion integration token not configured. Set it in Settings > Context Sources.");
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { createObsidianClient, createSyncServerClient, getSyncToken } from
|
|
2
|
+
import { createObsidianClient, createSyncServerClient, getSyncToken } from "../../../dist/lib/obsidian/api.ts";
|
|
3
3
|
import {
|
|
4
4
|
getObsidianConfigForApiKey
|
|
5
|
-
} from
|
|
5
|
+
} from "../../../dist/lib/db/obsidian.ts";
|
|
6
6
|
function extractApiKeyId(extra) {
|
|
7
7
|
const id = extra?.authInfo?.clientId;
|
|
8
8
|
return typeof id === "string" && id.length > 0 && id !== "anonymous" && id !== "env-key" ? id : void 0;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { logToolCall } from "../audit.ts";
|
|
2
2
|
import { getMcpHttpAuthHeadersForInternalFetch } from "../httpAuthContext.ts";
|
|
3
|
-
import { normalizeQuotaResponse } from "../../../
|
|
4
|
-
import { resolveOmniRouteBaseUrl } from "../../../
|
|
3
|
+
import { normalizeQuotaResponse } from "../../../dist/shared/contracts/quota.ts";
|
|
4
|
+
import { resolveOmniRouteBaseUrl } from "../../../dist/shared/utils/resolveOmniRouteBaseUrl.ts";
|
|
5
5
|
import {
|
|
6
6
|
getComboModelProvider,
|
|
7
7
|
getComboModelString,
|
|
8
8
|
getComboStepTarget
|
|
9
|
-
} from
|
|
9
|
+
} from "../../../dist/lib/combos/steps.ts";
|
|
10
10
|
import { rankBySpeed, DEFAULT_SPEED_WEIGHTS } from "../../services/autoCombo/speedRanking.ts";
|
|
11
11
|
const OMNIROUTE_BASE_URL = resolveOmniRouteBaseUrl();
|
|
12
12
|
const OMNIROUTE_API_KEY = process.env.OMNIROUTE_API_KEY || "";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { resolve, normalize, isAbsolute } from "path";
|
|
3
|
-
import { listPlugins, getPluginByName, updatePluginConfig } from
|
|
4
|
-
import { pluginManager } from
|
|
5
|
-
import { validatePluginConfig } from
|
|
3
|
+
import { listPlugins, getPluginByName, updatePluginConfig } from "../../../dist/lib/db/plugins";
|
|
4
|
+
import { pluginManager } from "../../../dist/lib/plugins/manager";
|
|
5
|
+
import { validatePluginConfig } from "../../../dist/lib/plugins/manifest";
|
|
6
6
|
function validatePluginPath(path) {
|
|
7
7
|
if (path.includes("\0")) {
|
|
8
8
|
throw new Error("Invalid path: contains null bytes");
|
|
@@ -151,7 +151,7 @@ const pluginTools = [
|
|
|
151
151
|
limit: z.number().min(1).max(100).default(20).describe("Max results to return")
|
|
152
152
|
}),
|
|
153
153
|
handler: async (args) => {
|
|
154
|
-
const { getPluginAnalytics, getPluginAnalyticsSummary } = await import(
|
|
154
|
+
const { getPluginAnalytics, getPluginAnalyticsSummary } = await import("../../../dist/lib/db/plugins");
|
|
155
155
|
const limit = args.limit || 20;
|
|
156
156
|
if (args.name) {
|
|
157
157
|
const rows = getPluginAnalytics(args.name).slice(0, limit);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { skillRegistry } from '
|
|
3
|
-
import { skillExecutor } from '
|
|
2
|
+
import { skillRegistry } from '../../../dist/lib/skills/registry.js';
|
|
3
|
+
import { skillExecutor } from '../../../dist/lib/skills/executor.js';
|
|
4
4
|
const SkillListSchema = z.object({
|
|
5
5
|
apiKeyId: z.string().optional(),
|
|
6
6
|
name: z.string().optional(),
|
|
@@ -61,13 +61,13 @@ export const ANTIGRAVITY_IDE_VERSION = "2.1.1";
|
|
|
61
61
|
export const ANTIGRAVITY_IDE_BASE_URL = "https://cloudcode-pa.googleapis.com";
|
|
62
62
|
export const ANTIGRAVITY_IDE_USER_AGENT = `antigravity/ide/${ANTIGRAVITY_IDE_VERSION} darwin/arm64`;
|
|
63
63
|
|
|
64
|
-
// Antigravity OAuth client credentials (public CLI client — duplicated in usage.js +
|
|
64
|
+
// Antigravity OAuth client credentials (public CLI client — duplicated in usage.js + dist/lib/oauth)
|
|
65
65
|
export const ANTIGRAVITY_OAUTH_CLIENT = {
|
|
66
66
|
clientId: "1071006060591-tmhssin2h21lcre235vtolojh4g403ep.apps.googleusercontent.com",
|
|
67
67
|
clientSecret: "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"
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
// Gemini (Google) OAuth client credentials (public CLI client — shared by gemini, gemini-cli,
|
|
70
|
+
// Gemini (Google) OAuth client credentials (public CLI client — shared by gemini, gemini-cli, dist/lib/oauth)
|
|
71
71
|
export const GOOGLE_OAUTH_CLIENT = {
|
|
72
72
|
clientId: "681255809395-oo8ft2oprdrnp9e3aqf6av3hmdib135j.apps.googleusercontent.com",
|
|
73
73
|
clientSecret: "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"
|
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
evaluateQuotaCutoff,
|
|
3
3
|
getQuotaFetcher
|
|
4
4
|
} from "../quotaPreflight.ts";
|
|
5
|
-
import { getProviderConnectionById } from
|
|
5
|
+
import { getProviderConnectionById } from "../../../dist/lib/db/providers";
|
|
6
6
|
import {
|
|
7
7
|
resolveResilienceSettings
|
|
8
|
-
} from
|
|
8
|
+
} from "../../../dist/lib/resilience/settings";
|
|
9
9
|
import { fetchResetAwareQuotaWithCache } from "./quotaStrategies.ts";
|
|
10
10
|
function asThresholdMap(value) {
|
|
11
11
|
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isBucketSaturated } from
|
|
1
|
+
import { isBucketSaturated } from "../../../dist/lib/quota/accountBuckets.ts";
|
|
2
2
|
import { incrementInflight, decrementInflight, getInflight } from "./quotaShareInflight.ts";
|
|
3
3
|
const MAX_DRR_COMBOS = 200;
|
|
4
4
|
const _drrState = /* @__PURE__ */ new Map();
|
|
@@ -100,7 +100,7 @@ async function resolveAutoStrategyOrder(deps) {
|
|
|
100
100
|
}
|
|
101
101
|
let lastKnownGoodProvider;
|
|
102
102
|
try {
|
|
103
|
-
const { getLKGP } = await import(
|
|
103
|
+
const { getLKGP } = await import("../../../dist/lib/localDb");
|
|
104
104
|
const lkgp = await getLKGP(combo.name, combo.id || combo.name);
|
|
105
105
|
if (lkgp) lastKnownGoodProvider = lkgp.provider;
|
|
106
106
|
} catch (err) {
|
|
@@ -10,7 +10,7 @@ function __setStickinessHeadroomFetcherForTests(fetcher) {
|
|
|
10
10
|
async function resolveSaturation(connectionId, provider) {
|
|
11
11
|
if (_fetcherOverride) return _fetcherOverride(connectionId);
|
|
12
12
|
try {
|
|
13
|
-
const mod = await import(
|
|
13
|
+
const mod = await import("../../../dist/lib/quota/saturationSignals");
|
|
14
14
|
const getSaturation = mod.getSaturation;
|
|
15
15
|
const [util5h, util7d] = await Promise.all([
|
|
16
16
|
getSaturation(connectionId, provider, { unit: "percent", window: "5h" }),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { secureRandomFloat } from "../../../
|
|
1
|
+
import { secureRandomFloat } from "../../../dist/shared/utils/secureRandom";
|
|
2
2
|
import { recordComboShadowRequest } from "../comboMetrics.ts";
|
|
3
3
|
import { isRecord } from "./comboData.ts";
|
|
4
4
|
import { resolveNestedComboTargets } from "./comboStructure.ts";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getCircuitBreaker } from "../../../
|
|
2
|
-
import { secureRandomFloat, secureRandomInt } from "../../../
|
|
3
|
-
import { getComboStepTarget, getComboStepWeight } from
|
|
1
|
+
import { getCircuitBreaker } from "../../../dist/shared/utils/circuitBreaker";
|
|
2
|
+
import { secureRandomFloat, secureRandomInt } from "../../../dist/shared/utils/secureRandom";
|
|
3
|
+
import { getComboStepTarget, getComboStepWeight } from "../../../dist/lib/combos/steps.ts";
|
|
4
4
|
import { getComboMetrics } from "../comboMetrics.ts";
|
|
5
5
|
import { parseModel } from "../model.ts";
|
|
6
6
|
function normalizeModelEntry(entry) {
|
|
@@ -32,7 +32,7 @@ function orderTargetsForWeightedFallback(targets, selectedExecutionKey, preserve
|
|
|
32
32
|
}
|
|
33
33
|
async function sortModelsByCost(models) {
|
|
34
34
|
try {
|
|
35
|
-
const { getPricingForModel } = await import(
|
|
35
|
+
const { getPricingForModel } = await import("../../../dist/lib/localDb");
|
|
36
36
|
const withCost = await Promise.all(
|
|
37
37
|
models.map(async (modelStr) => {
|
|
38
38
|
const parsed = parseModel(modelStr);
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
isKnownNonClaudeStreamPayload
|
|
4
4
|
} from "../../utils/streamHelpers.ts";
|
|
5
5
|
import { evaluateResponseValidation } from "./responseValidation.ts";
|
|
6
|
-
import { getReasoningTokens } from
|
|
6
|
+
import { getReasoningTokens } from "../../../dist/lib/usage/tokenAccounting.ts";
|
|
7
7
|
function toRetryAfterDisplayValue(value) {
|
|
8
8
|
if (typeof value !== "number") return value;
|
|
9
9
|
if (value > 0 && value < 1e9) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MAX_TIMER_TIMEOUT_MS } from
|
|
1
|
+
import { MAX_TIMER_TIMEOUT_MS } from "../../dist/shared/utils/runtimeTimeouts.ts";
|
|
2
2
|
const PRE_SCREEN_CONCURRENCY = 5;
|
|
3
3
|
const DEFAULT_COMBO_TARGET_TIMEOUT_MS = 12e4;
|
|
4
4
|
const DEFAULT_COMBO_QUEUE_DEPTH = 20;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getModelContextLimit } from "../../
|
|
1
|
+
import { getModelContextLimit } from "../../dist/lib/modelCapabilities";
|
|
2
2
|
import { parseModel } from "./model.js";
|
|
3
3
|
import { CONTEXT_OVERFLOW_REGEX } from "./errorClassifier.js";
|
|
4
4
|
import { getRegistryEntry } from "../config/providerRegistry.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DEFAULT_RESILIENCE_SETTINGS
|
|
3
|
-
} from "../../
|
|
3
|
+
} from "../../dist/lib/resilience/settings";
|
|
4
4
|
const cooldownMap = /* @__PURE__ */ new Map();
|
|
5
5
|
const DEFAULT_ENTRY_RETENTION_MS = 30 * 60 * 1e3;
|
|
6
6
|
const CLEANUP_INTERVAL_MS = 60 * 1e3;
|
|
@@ -6,7 +6,7 @@ import { awaitProviderDefaultSlot } from "./providerDefaultRateLimit.js";
|
|
|
6
6
|
import {
|
|
7
7
|
DEFAULT_RESILIENCE_SETTINGS,
|
|
8
8
|
resolveResilienceSettings
|
|
9
|
-
} from "../../
|
|
9
|
+
} from "../../dist/lib/resilience/settings";
|
|
10
10
|
import {
|
|
11
11
|
STANDARD_HEADERS,
|
|
12
12
|
ANTHROPIC_HEADERS,
|
|
@@ -192,7 +192,7 @@ async function initializeRateLimits() {
|
|
|
192
192
|
if (initialized) return;
|
|
193
193
|
initialized = true;
|
|
194
194
|
try {
|
|
195
|
-
const { getProviderConnections, getSettings } = await import(
|
|
195
|
+
const { getProviderConnections, getSettings } = await import("@/lib/localDb");
|
|
196
196
|
const [connections, settings] = await Promise.all([getProviderConnections(), getSettings()]);
|
|
197
197
|
const resilience = resolveResilienceSettings(settings);
|
|
198
198
|
currentRequestQueueSettings = { ...resilience.requestQueue };
|
|
@@ -221,7 +221,7 @@ async function initializeRateLimits() {
|
|
|
221
221
|
}
|
|
222
222
|
async function applyRequestQueueSettings(nextSettings) {
|
|
223
223
|
currentRequestQueueSettings = { ...nextSettings };
|
|
224
|
-
const { getProviderConnections } = await import(
|
|
224
|
+
const { getProviderConnections } = await import("@/lib/localDb");
|
|
225
225
|
const connections = await getProviderConnections();
|
|
226
226
|
reconcileEnabledConnections(connections, currentRequestQueueSettings);
|
|
227
227
|
updateAllLimiterSettings();
|
|
@@ -465,7 +465,7 @@ function getLearnedLimits() {
|
|
|
465
465
|
}
|
|
466
466
|
async function persistLearnedLimitsNow() {
|
|
467
467
|
try {
|
|
468
|
-
const { updateSettings } = await import(
|
|
468
|
+
const { updateSettings } = await import("@/lib/db/settings");
|
|
469
469
|
await updateSettings({ learnedRateLimits: JSON.stringify(learnedLimits) });
|
|
470
470
|
logRateLimit(
|
|
471
471
|
`\u{1F4BE} [RATE-LIMIT] Persisted learned limits for ${Object.keys(learnedLimits).length} provider(s)`
|
|
@@ -541,7 +541,7 @@ async function __getLimiterStateForTests(provider, connectionId, model = null) {
|
|
|
541
541
|
}
|
|
542
542
|
async function loadPersistedLimits() {
|
|
543
543
|
try {
|
|
544
|
-
const { getSettings } = await import(
|
|
544
|
+
const { getSettings } = await import("@/lib/db/settings");
|
|
545
545
|
const settings = await getSettings();
|
|
546
546
|
const raw = settings?.learnedRateLimits;
|
|
547
547
|
if (typeof raw !== "string" || raw.trim().length === 0) return;
|
|
@@ -221,18 +221,13 @@ function applyAdaptiveBudget(body, cfg) {
|
|
|
221
221
|
);
|
|
222
222
|
return setCustomBudget(body, budget);
|
|
223
223
|
}
|
|
224
|
-
|
|
224
|
+
function hasThinkingCapableModel(body) {
|
|
225
225
|
const model = getStringField(toRecord(body), "model");
|
|
226
226
|
const resolved = getResolvedModelCapabilities(model);
|
|
227
227
|
if (resolved.supportsThinking === true) return true;
|
|
228
228
|
if (resolved.supportsThinking === false) return false;
|
|
229
229
|
return model.includes("claude") || model.includes("o1") || model.includes("o3") || model.includes("o4") || model.includes("gemini") || model.endsWith("-thinking") || model.includes("thinking");
|
|
230
230
|
}
|
|
231
|
-
export function resolveKiroThinkingBudget(body, headers, model) {
|
|
232
|
-
return isThinkingEnabled(body, headers, model)
|
|
233
|
-
? KIRO_THINKING_BUDGET_DEFAULT
|
|
234
|
-
: 0;
|
|
235
|
-
}
|
|
236
231
|
export {
|
|
237
232
|
DEFAULT_THINKING_CONFIG,
|
|
238
233
|
EFFORT_BUDGETS,
|
|
@@ -241,6 +236,7 @@ export {
|
|
|
241
236
|
applyThinkingBudget,
|
|
242
237
|
ensureThinkingConfig,
|
|
243
238
|
getThinkingBudgetConfig,
|
|
239
|
+
hasThinkingCapableModel,
|
|
244
240
|
hydrateThinkingBudgetConfig,
|
|
245
241
|
normalizeThinkingLevel,
|
|
246
242
|
setThinkingBudgetConfig
|
|
@@ -2,7 +2,7 @@ import { PROVIDERS, PROVIDER_OAUTH } from "../../config/providers.js";
|
|
|
2
2
|
import { OAUTH_ENDPOINTS, GITHUB_COPILOT } from "../../config/appConstants.js";
|
|
3
3
|
import { proxyAwareFetch } from "../../utils/proxyFetch.js";
|
|
4
4
|
import { dedupRefresh } from "./dedup.js";
|
|
5
|
-
import { buildExternalIdpRefreshParams } from
|
|
5
|
+
import { buildExternalIdpRefreshParams } from "../../../dist/lib/oauth/kiroExternalIdp.js";
|
|
6
6
|
|
|
7
7
|
let _xaiServiceSingleton = null;
|
|
8
8
|
export async function refreshXaiToken(refreshToken, log) {
|
|
@@ -10,7 +10,7 @@ export async function refreshXaiToken(refreshToken, log) {
|
|
|
10
10
|
return dedupRefresh("xai", refreshToken, async () => {
|
|
11
11
|
try {
|
|
12
12
|
if (!_xaiServiceSingleton) {
|
|
13
|
-
const mod = await import(
|
|
13
|
+
const mod = await import("../../../dist/lib/oauth/services/xai.js");
|
|
14
14
|
_xaiServiceSingleton = new mod.XaiService();
|
|
15
15
|
}
|
|
16
16
|
const tokens = await _xaiServiceSingleton.refreshAccessToken(refreshToken);
|
|
@@ -296,7 +296,7 @@ async function resolveKiroProfileArnPatch(providerSpecificData, accessToken, ref
|
|
|
296
296
|
if (providerSpecificData?.profileArn) return {};
|
|
297
297
|
let profileArn = refreshedArn?.trim?.() || null;
|
|
298
298
|
if (!profileArn) {
|
|
299
|
-
const { fetchKiroProfileArn } = await import(
|
|
299
|
+
const { fetchKiroProfileArn } = await import("../../../dist/lib/oauth/providers.js");
|
|
300
300
|
profileArn = await fetchKiroProfileArn(accessToken);
|
|
301
301
|
}
|
|
302
302
|
return profileArn ? { providerSpecificData: { profileArn } } : {};
|
|
@@ -10,36 +10,11 @@ import { AntigravityExecutor } from "../executors/antigravity.js";
|
|
|
10
10
|
const requestRegistry = new Map();
|
|
11
11
|
const responseRegistry = new Map();
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const reqMods = [
|
|
16
|
-
"./request/claude-to-openai.js",
|
|
17
|
-
"./request/openai-to-claude.js",
|
|
18
|
-
"./request/gemini-to-openai.js",
|
|
19
|
-
"./request/openai-to-gemini.js",
|
|
20
|
-
"./request/openai-to-vertex.js",
|
|
21
|
-
"./request/antigravity-to-openai.js",
|
|
22
|
-
"./request/openai-responses.js",
|
|
23
|
-
"./request/openai-to-kiro.js",
|
|
24
|
-
"./request/openai-to-cursor.js",
|
|
25
|
-
"./request/openai-to-ollama.js",
|
|
26
|
-
"./request/openai-to-commandcode.js",
|
|
27
|
-
];
|
|
28
|
-
const resMods = [
|
|
29
|
-
"./response/claude-to-openai.js",
|
|
30
|
-
"./response/openai-to-claude.js",
|
|
31
|
-
"./response/gemini-to-openai.js",
|
|
32
|
-
"./response/openai-to-antigravity.js",
|
|
33
|
-
"./response/openai-responses.js",
|
|
34
|
-
"./response/kiro-to-openai.js",
|
|
35
|
-
"./response/cursor-to-openai.js",
|
|
36
|
-
"./response/ollama-to-openai.js",
|
|
37
|
-
"./response/commandcode-to-openai.js",
|
|
38
|
-
];
|
|
39
|
-
await Promise.all([...reqMods, ...resMods].map(m => import(m)));
|
|
13
|
+
import { createRequire } from "module";
|
|
14
|
+
const require = createRequire(import.meta.url);
|
|
40
15
|
|
|
41
16
|
// Track initialization state
|
|
42
|
-
let initialized =
|
|
17
|
+
let initialized = false;
|
|
43
18
|
|
|
44
19
|
// Register translator
|
|
45
20
|
export function register(from, to, requestFn, responseFn) {
|
|
@@ -52,8 +27,35 @@ export function register(from, to, requestFn, responseFn) {
|
|
|
52
27
|
}
|
|
53
28
|
}
|
|
54
29
|
|
|
55
|
-
// Lazy load translators (
|
|
56
|
-
|
|
30
|
+
// Lazy load translators (called once on first use)
|
|
31
|
+
function ensureInitialized() {
|
|
32
|
+
if (initialized) return;
|
|
33
|
+
initialized = true;
|
|
34
|
+
|
|
35
|
+
// Request translators - sync require pattern for bundler
|
|
36
|
+
require("./request/claude-to-openai.js");
|
|
37
|
+
require("./request/openai-to-claude.js");
|
|
38
|
+
require("./request/gemini-to-openai.js");
|
|
39
|
+
require("./request/openai-to-gemini.js");
|
|
40
|
+
require("./request/openai-to-vertex.js");
|
|
41
|
+
require("./request/antigravity-to-openai.js");
|
|
42
|
+
require("./request/openai-responses.js");
|
|
43
|
+
require("./request/openai-to-kiro.js");
|
|
44
|
+
require("./request/openai-to-cursor.js");
|
|
45
|
+
require("./request/openai-to-ollama.js");
|
|
46
|
+
require("./request/openai-to-commandcode.js");
|
|
47
|
+
|
|
48
|
+
// Response translators
|
|
49
|
+
require("./response/claude-to-openai.js");
|
|
50
|
+
require("./response/openai-to-claude.js");
|
|
51
|
+
require("./response/gemini-to-openai.js");
|
|
52
|
+
require("./response/openai-to-antigravity.js");
|
|
53
|
+
require("./response/openai-responses.js");
|
|
54
|
+
require("./response/kiro-to-openai.js");
|
|
55
|
+
require("./response/cursor-to-openai.js");
|
|
56
|
+
require("./response/ollama-to-openai.js");
|
|
57
|
+
require("./response/commandcode-to-openai.js");
|
|
58
|
+
}
|
|
57
59
|
|
|
58
60
|
// Strip specific content types from messages (explicit opt-in via strip[] in PROVIDER_MODELS)
|
|
59
61
|
function stripContentTypes(body, stripList = []) {
|
|
@@ -27,11 +27,11 @@ import { FORMATS } from "../formats.js";
|
|
|
27
27
|
import { v4 as uuidv4 } from "uuid";
|
|
28
28
|
import {
|
|
29
29
|
resolveKiroModel,
|
|
30
|
+
resolveKiroThinkingBudget,
|
|
30
31
|
buildThinkingSystemPrefix,
|
|
31
32
|
KIRO_AGENTIC_SYSTEM_PROMPT,
|
|
32
33
|
resolveDefaultProfileArn,
|
|
33
34
|
} from "../../config/kiroConstants.js";
|
|
34
|
-
import { resolveKiroThinkingBudget } from "../../services/thinkingBudget.js";
|
|
35
35
|
import { DEFAULT_IMAGE_MIME } from "../schema/index.js";
|
|
36
36
|
import { ROLE, CLAUDE_BLOCK } from "../schema/index.js";
|
|
37
37
|
|
|
@@ -8,11 +8,11 @@ import { v4 as uuidv4 } from "uuid";
|
|
|
8
8
|
import { resolveSessionId } from "../../utils/sessionManager.js";
|
|
9
9
|
import {
|
|
10
10
|
resolveKiroModel,
|
|
11
|
+
resolveKiroThinkingBudget,
|
|
11
12
|
buildThinkingSystemPrefix,
|
|
12
13
|
KIRO_AGENTIC_SYSTEM_PROMPT,
|
|
13
|
-
resolveDefaultProfileArn
|
|
14
|
+
resolveDefaultProfileArn
|
|
14
15
|
} from "../../config/kiroConstants.js";
|
|
15
|
-
import { resolveKiroThinkingBudget } from "../../services/thinkingBudget.js";
|
|
16
16
|
import { parseDataUri } from "../concerns/image.js";
|
|
17
17
|
import { DEFAULT_IMAGE_MIME } from "../schema/index.js";
|
|
18
18
|
import { ROLE, OPENAI_BLOCK, CLAUDE_BLOCK } from "../schema/index.js";
|
package/open-sse/utils/logger.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getAppLogFormat, getAppLogLevel } from "../../
|
|
1
|
+
import { getAppLogFormat, getAppLogLevel } from "../../dist/lib/logEnv";
|
|
2
2
|
const LEVELS = { debug: 0, info: 1, warn: 2, error: 3 };
|
|
3
3
|
function isLogLevel(value) {
|
|
4
4
|
return Object.prototype.hasOwnProperty.call(LEVELS, value);
|
package/package.json
CHANGED