openfox 2.0.24 → 2.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auto-config-FZFXOEEG.js +169 -0
- package/dist/backend-AGXWAU7A.js +9 -0
- package/dist/{chat-handler-4ATHDLH4.js → chat-handler-XH3QUXIC.js} +28 -47
- package/dist/{chunk-XJ4SUDL7.js → chunk-2ELCWCO3.js} +32 -241
- package/dist/{chunk-QK6TYNUN.js → chunk-64NCACBV.js} +6 -6
- package/dist/{chunk-GI24G4OW.js → chunk-AYJTMZVU.js} +79 -59
- package/dist/{chunk-YVF3BLQS.js → chunk-GZOYGODG.js} +36 -22
- package/dist/chunk-HNCM3D7Y.js +28 -0
- package/dist/chunk-IEDE6VK4.js +124 -0
- package/dist/chunk-J2GP3J3X.js +97 -0
- package/dist/{chunk-INRKWEOH.js → chunk-L5FBH2YX.js} +116 -65
- package/dist/{chunk-4EDH3ZXL.js → chunk-LP5RXQW5.js} +3 -3
- package/dist/chunk-M3RB4IF6.js +114 -0
- package/dist/chunk-V4IE7HJY.js +175 -0
- package/dist/{chunk-MDRNKI7D.js → chunk-WCPFR6ZP.js} +55 -48
- package/dist/{chunk-CDIYCGCO.js → chunk-WEXW7ZXJ.js} +2 -2
- package/dist/{chunk-RYHCYZQ7.js → chunk-Y6STCE5Z.js} +26 -24
- package/dist/{chunk-YUHODMKY.js → chunk-YGSBVKFU.js} +11 -5
- package/dist/chunk-Z4FMBCJO.js +52 -0
- package/dist/chunk-ZJ4FP6RS.js +200 -0
- package/dist/cli/dev.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/client-725U6BTX.js +13 -0
- package/dist/client-pure-5NOTSIRK.js +19 -0
- package/dist/{compactor-SEZEZSML.js → compactor-JMGSZ4DQ.js} +7 -4
- package/dist/http-client-SIPAW7IM.js +8 -0
- package/dist/{orchestrator-MFN7COWT.js → orchestrator-FRFKYO77.js} +16 -13
- package/dist/package.json +1 -1
- package/dist/{processor-W2ZSJVOJ.js → processor-YAMVUA7K.js} +30 -55
- package/dist/profiles-Q36ELWQF.js +9 -0
- package/dist/{provider-IMW3ITB7.js → provider-KB7GB2O2.js} +15 -9
- package/dist/provider-manager-5VAVOKHC.js +22 -0
- package/dist/{serve-ABSUHKT3.js → serve-XBIN2DEU.js} +23 -17
- package/dist/server/index.d.ts +9 -1
- package/dist/server/index.js +19 -13
- package/dist/{server-7EAYI7T4.js → server-VXOP7JUX.js} +18 -12
- package/dist/{tools-7CKTYL2G.js → tools-JDYXXX2N.js} +11 -8
- package/dist/url-utils-QWAHP54Q.js +15 -0
- package/dist/web/assets/{index-CkUCxzzC.css → index-BLOGpuPE.css} +1 -1
- package/dist/web/assets/{index-Bi5R_oF2.js → index-CtG8oo36.js} +66 -66
- package/dist/web/index.html +2 -2
- package/dist/web/sw.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-UUFEE7VR.js +0 -505
- package/dist/provider-manager-DNBMBP4D.js +0 -16
|
@@ -1,21 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getProject
|
|
3
|
-
} from "./chunk-O4TED6AJ.js";
|
|
4
|
-
import {
|
|
5
|
-
COMPACTION_PROMPT,
|
|
6
|
-
TurnMetrics,
|
|
7
|
-
buildBasePrompt,
|
|
8
|
-
buildSubAgentSystemPrompt,
|
|
9
|
-
buildTopLevelSystemPrompt,
|
|
10
|
-
computeEffectiveTools,
|
|
11
|
-
consumeStreamGenerator,
|
|
12
|
-
createChatDoneEvent,
|
|
13
|
-
createMessageDoneEvent,
|
|
14
|
-
createMessageStartEvent,
|
|
15
|
-
createToolCallEvent,
|
|
16
|
-
createToolResultEvent,
|
|
17
|
-
streamLLMPure
|
|
18
|
-
} from "./chunk-YUHODMKY.js";
|
|
19
1
|
import {
|
|
20
2
|
startInspectProxy
|
|
21
3
|
} from "./chunk-DL6ZILAF.js";
|
|
@@ -35,21 +17,6 @@ import {
|
|
|
35
17
|
import {
|
|
36
18
|
createMcpTools
|
|
37
19
|
} from "./chunk-NWO6GRYE.js";
|
|
38
|
-
import {
|
|
39
|
-
getCurrentContextWindowId,
|
|
40
|
-
getCurrentWindowMessageOptions,
|
|
41
|
-
getEventStore,
|
|
42
|
-
getRuntimeConfig
|
|
43
|
-
} from "./chunk-YBWY4DKY.js";
|
|
44
|
-
import {
|
|
45
|
-
buildContextMessagesFromEventHistory,
|
|
46
|
-
foldContextState,
|
|
47
|
-
handleMessageDelta,
|
|
48
|
-
handleMessageThinking,
|
|
49
|
-
handleToolCall,
|
|
50
|
-
handleToolResult,
|
|
51
|
-
stripOrphanedToolCalls
|
|
52
|
-
} from "./chunk-6PLAWCHQ.js";
|
|
53
20
|
import {
|
|
54
21
|
createChatDoneMessage,
|
|
55
22
|
createChatMessageMessage,
|
|
@@ -66,6 +33,42 @@ import {
|
|
|
66
33
|
deleteSetting,
|
|
67
34
|
getSetting
|
|
68
35
|
} from "./chunk-RFNEDBVO.js";
|
|
36
|
+
import {
|
|
37
|
+
getProject
|
|
38
|
+
} from "./chunk-O4TED6AJ.js";
|
|
39
|
+
import {
|
|
40
|
+
COMPACTION_PROMPT,
|
|
41
|
+
TurnMetrics,
|
|
42
|
+
buildBasePrompt,
|
|
43
|
+
buildSubAgentSystemPrompt,
|
|
44
|
+
buildTopLevelSystemPrompt,
|
|
45
|
+
computeEffectiveTools,
|
|
46
|
+
consumeStreamGenerator,
|
|
47
|
+
createChatDoneEvent,
|
|
48
|
+
createMessageDoneEvent,
|
|
49
|
+
createMessageStartEvent,
|
|
50
|
+
createToolCallEvent,
|
|
51
|
+
createToolResultEvent,
|
|
52
|
+
streamLLMPure
|
|
53
|
+
} from "./chunk-YGSBVKFU.js";
|
|
54
|
+
import {
|
|
55
|
+
getCurrentContextWindowId,
|
|
56
|
+
getCurrentWindowMessageOptions,
|
|
57
|
+
getEventStore,
|
|
58
|
+
getRuntimeConfig
|
|
59
|
+
} from "./chunk-YBWY4DKY.js";
|
|
60
|
+
import {
|
|
61
|
+
buildContextMessagesFromEventHistory,
|
|
62
|
+
foldContextState,
|
|
63
|
+
handleMessageDelta,
|
|
64
|
+
handleMessageThinking,
|
|
65
|
+
handleToolCall,
|
|
66
|
+
handleToolResult,
|
|
67
|
+
stripOrphanedToolCalls
|
|
68
|
+
} from "./chunk-6PLAWCHQ.js";
|
|
69
|
+
import {
|
|
70
|
+
logger
|
|
71
|
+
} from "./chunk-K44MW7JJ.js";
|
|
69
72
|
import {
|
|
70
73
|
loadGlobalConfig,
|
|
71
74
|
saveGlobalConfig
|
|
@@ -75,10 +78,7 @@ import {
|
|
|
75
78
|
} from "./chunk-CQGTEGKL.js";
|
|
76
79
|
import {
|
|
77
80
|
modelSupportsVision
|
|
78
|
-
} from "./chunk-
|
|
79
|
-
import {
|
|
80
|
-
logger
|
|
81
|
-
} from "./chunk-K44MW7JJ.js";
|
|
81
|
+
} from "./chunk-V4IE7HJY.js";
|
|
82
82
|
|
|
83
83
|
// src/server/tools/read.ts
|
|
84
84
|
import { readFile as readFile2, stat, readdir } from "fs/promises";
|
|
@@ -2482,8 +2482,15 @@ ${CONTINUE_PROMPT}` : CONTINUE_PROMPT;
|
|
|
2482
2482
|
...config.subAgentMetadata ? { subAgentId: config.subAgentMetadata.subAgentId, subAgentType: config.subAgentMetadata.subAgentType } : {}
|
|
2483
2483
|
})
|
|
2484
2484
|
);
|
|
2485
|
-
const
|
|
2486
|
-
const
|
|
2485
|
+
const contextState = sessionManager.getContextState(sessionId);
|
|
2486
|
+
const previousContextTokens = contextState.currentTokens;
|
|
2487
|
+
const contextWindow = sessionManager.getCurrentModelContext();
|
|
2488
|
+
const availableForOutput = Math.max(256, contextWindow - contextState.currentTokens);
|
|
2489
|
+
let modelSettings = currentMaxTokensOverride !== void 0 ? { ...sessionManager.getCurrentModelSettings(), maxTokens: currentMaxTokensOverride } : sessionManager.getCurrentModelSettings();
|
|
2490
|
+
if (modelSettings) {
|
|
2491
|
+
const requestedMaxTokens = modelSettings.maxTokens ?? 16384;
|
|
2492
|
+
modelSettings = { ...modelSettings, maxTokens: Math.min(requestedMaxTokens, availableForOutput) };
|
|
2493
|
+
}
|
|
2487
2494
|
const streamGen = streamLLMPure({
|
|
2488
2495
|
messageId: assistantMsgId,
|
|
2489
2496
|
systemPrompt: assembledRequest.systemPrompt,
|
|
@@ -2549,9 +2556,9 @@ ${CONTINUE_PROMPT}` : CONTINUE_PROMPT;
|
|
|
2549
2556
|
);
|
|
2550
2557
|
sessionManager.setCurrentContextSize(sessionId, result.usage.promptTokens);
|
|
2551
2558
|
if (!compacting) {
|
|
2552
|
-
const
|
|
2553
|
-
const { shouldCompact, appendCompactionPrompt } = await import("./compactor-
|
|
2554
|
-
if (shouldCompact(
|
|
2559
|
+
const contextState2 = sessionManager.getContextState(sessionId);
|
|
2560
|
+
const { shouldCompact, appendCompactionPrompt } = await import("./compactor-JMGSZ4DQ.js");
|
|
2561
|
+
if (shouldCompact(contextState2.currentTokens, contextState2.maxTokens, runtimeConfig.context.compactionThreshold)) {
|
|
2555
2562
|
appendCompactionPrompt(sessionId, append);
|
|
2556
2563
|
compacting = true;
|
|
2557
2564
|
continue;
|
|
@@ -2562,8 +2569,8 @@ ${CONTINUE_PROMPT}` : CONTINUE_PROMPT;
|
|
|
2562
2569
|
truncationRetryCount += 1;
|
|
2563
2570
|
const currentMaxTokens = result.modelParams?.maxTokens ?? 16384;
|
|
2564
2571
|
const promptTokens = result.usage.promptTokens;
|
|
2565
|
-
const
|
|
2566
|
-
const newMaxTokens = Math.min(Math.floor(currentMaxTokens * 1.5),
|
|
2572
|
+
const contextWindow2 = sessionManager.getCurrentModelContext();
|
|
2573
|
+
const newMaxTokens = Math.min(Math.floor(currentMaxTokens * 1.5), contextWindow2 - promptTokens - 2048);
|
|
2567
2574
|
currentMaxTokensOverride = newMaxTokens;
|
|
2568
2575
|
const interimStats = turnMetrics.buildStats(statsIdentity, mode);
|
|
2569
2576
|
append(
|
|
@@ -3355,7 +3362,7 @@ var callSubAgentTool = {
|
|
|
3355
3362
|
};
|
|
3356
3363
|
}
|
|
3357
3364
|
try {
|
|
3358
|
-
const { getToolRegistryForAgent: getToolRegistryForAgent2 } = await import("./tools-
|
|
3365
|
+
const { getToolRegistryForAgent: getToolRegistryForAgent2 } = await import("./tools-JDYXXX2N.js");
|
|
3359
3366
|
const toolRegistry = getToolRegistryForAgent2(agentDef);
|
|
3360
3367
|
const turnMetrics = new TurnMetrics();
|
|
3361
3368
|
const result = await executeSubAgent({
|
|
@@ -4161,7 +4168,7 @@ async function computeContextHash(sessionManager, sessionId) {
|
|
|
4161
4168
|
const runtimeConfig = getRuntimeConfig();
|
|
4162
4169
|
const configDir = getGlobalConfigDir(runtimeConfig.mode ?? "production");
|
|
4163
4170
|
const skills = await getEnabledSkillMetadata(configDir, runtimeConfig.workdir);
|
|
4164
|
-
const { createToolRegistry: createToolRegistry2 } = await import("./tools-
|
|
4171
|
+
const { createToolRegistry: createToolRegistry2 } = await import("./tools-JDYXXX2N.js");
|
|
4165
4172
|
const allTools = createToolRegistry2().definitions;
|
|
4166
4173
|
const toolFingerprint = getToolFingerprint(allTools);
|
|
4167
4174
|
const hash = computeDynamicContextHash(instructionContent, skills, toolFingerprint);
|
|
@@ -4274,7 +4281,7 @@ var mcpConfigTool = createTool(
|
|
|
4274
4281
|
await saveGlobalConfig(mcpConfigMode, { ...globalConfig, mcpServers: updated });
|
|
4275
4282
|
}
|
|
4276
4283
|
async function rebuildTools() {
|
|
4277
|
-
const { setMcpTools: setMcpTools2 } = await import("./tools-
|
|
4284
|
+
const { setMcpTools: setMcpTools2 } = await import("./tools-JDYXXX2N.js");
|
|
4278
4285
|
const mcpTools = createMcpTools(mcpManagerForTools);
|
|
4279
4286
|
setMcpTools2(mcpTools);
|
|
4280
4287
|
}
|
|
@@ -4678,4 +4685,4 @@ export {
|
|
|
4678
4685
|
getToolRegistryForAgent,
|
|
4679
4686
|
createToolRegistry
|
|
4680
4687
|
};
|
|
4681
|
-
//# sourceMappingURL=chunk-
|
|
4688
|
+
//# sourceMappingURL=chunk-WCPFR6ZP.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
COMPACTION_PROMPT,
|
|
3
3
|
createMessageStartEvent
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-YGSBVKFU.js";
|
|
5
5
|
import {
|
|
6
6
|
getCurrentWindowMessageOptions
|
|
7
7
|
} from "./chunk-YBWY4DKY.js";
|
|
@@ -31,4 +31,4 @@ export {
|
|
|
31
31
|
shouldCompact,
|
|
32
32
|
getCompactionTarget
|
|
33
33
|
};
|
|
34
|
-
//# sourceMappingURL=chunk-
|
|
34
|
+
//# sourceMappingURL=chunk-WEXW7ZXJ.js.map
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
appendCompactionPrompt
|
|
3
|
-
} from "./chunk-CDIYCGCO.js";
|
|
4
1
|
import {
|
|
5
2
|
injectWorkflowKickoffIfNeeded,
|
|
6
3
|
runAgentTurn,
|
|
7
4
|
runChatTurn
|
|
8
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-64NCACBV.js";
|
|
9
6
|
import {
|
|
10
7
|
applyDynamicContext,
|
|
11
8
|
checkAborted,
|
|
@@ -22,20 +19,11 @@ import {
|
|
|
22
19
|
loadAllAgentsDefault,
|
|
23
20
|
saveItemToDir,
|
|
24
21
|
spawnShellProcess
|
|
25
|
-
} from "./chunk-
|
|
26
|
-
import {
|
|
27
|
-
TurnMetrics,
|
|
28
|
-
createMessageStartEvent
|
|
29
|
-
} from "./chunk-YUHODMKY.js";
|
|
22
|
+
} from "./chunk-WCPFR6ZP.js";
|
|
30
23
|
import {
|
|
31
24
|
getPlatformShell,
|
|
32
25
|
onProcessEvent
|
|
33
26
|
} from "./chunk-PBGOZMVY.js";
|
|
34
|
-
import {
|
|
35
|
-
getCurrentContextWindowId,
|
|
36
|
-
getEventStore,
|
|
37
|
-
getRuntimeConfig
|
|
38
|
-
} from "./chunk-YBWY4DKY.js";
|
|
39
27
|
import {
|
|
40
28
|
createChatErrorMessage,
|
|
41
29
|
createChatMessageMessage,
|
|
@@ -53,6 +41,27 @@ import {
|
|
|
53
41
|
import {
|
|
54
42
|
provideAnswer
|
|
55
43
|
} from "./chunk-EU3WWTFH.js";
|
|
44
|
+
import {
|
|
45
|
+
appendCompactionPrompt
|
|
46
|
+
} from "./chunk-WEXW7ZXJ.js";
|
|
47
|
+
import {
|
|
48
|
+
TurnMetrics,
|
|
49
|
+
createMessageStartEvent
|
|
50
|
+
} from "./chunk-YGSBVKFU.js";
|
|
51
|
+
import {
|
|
52
|
+
getCurrentContextWindowId,
|
|
53
|
+
getEventStore,
|
|
54
|
+
getRuntimeConfig
|
|
55
|
+
} from "./chunk-YBWY4DKY.js";
|
|
56
|
+
import {
|
|
57
|
+
createLLMClient
|
|
58
|
+
} from "./chunk-2ELCWCO3.js";
|
|
59
|
+
import {
|
|
60
|
+
ensureVersionPrefix
|
|
61
|
+
} from "./chunk-HNCM3D7Y.js";
|
|
62
|
+
import {
|
|
63
|
+
logger
|
|
64
|
+
} from "./chunk-K44MW7JJ.js";
|
|
56
65
|
import {
|
|
57
66
|
computeSessionStats
|
|
58
67
|
} from "./chunk-VUQCQXXJ.js";
|
|
@@ -62,13 +71,6 @@ import {
|
|
|
62
71
|
import {
|
|
63
72
|
getGlobalConfigDir
|
|
64
73
|
} from "./chunk-CQGTEGKL.js";
|
|
65
|
-
import {
|
|
66
|
-
createLLMClient,
|
|
67
|
-
ensureVersionPrefix
|
|
68
|
-
} from "./chunk-XJ4SUDL7.js";
|
|
69
|
-
import {
|
|
70
|
-
logger
|
|
71
|
-
} from "./chunk-K44MW7JJ.js";
|
|
72
74
|
|
|
73
75
|
// src/server/ws/server.ts
|
|
74
76
|
import { WebSocketServer, WebSocket as WebSocket2 } from "ws";
|
|
@@ -1775,7 +1777,7 @@ async function handleClientMessage(ws, client, message, _getLLMClient, _getActiv
|
|
|
1775
1777
|
const runtimeConfig = getRuntimeConfig();
|
|
1776
1778
|
const configDir = getGlobalConfigDir(runtimeConfig.mode ?? "production");
|
|
1777
1779
|
const skills = await getEnabledSkillMetadata(configDir, runtimeConfig.workdir);
|
|
1778
|
-
const { createToolRegistry } = await import("./tools-
|
|
1780
|
+
const { createToolRegistry } = await import("./tools-JDYXXX2N.js");
|
|
1779
1781
|
const allTools = createToolRegistry().definitions;
|
|
1780
1782
|
const toolFingerprint = getToolFingerprint(allTools);
|
|
1781
1783
|
const currentHash = computeDynamicContextHash(instructionContent, skills, toolFingerprint);
|
|
@@ -1848,7 +1850,7 @@ async function handleClientMessage(ws, client, message, _getLLMClient, _getActiv
|
|
|
1848
1850
|
const runtimeConfig = getRuntimeConfig();
|
|
1849
1851
|
const configDir = getGlobalConfigDir(runtimeConfig.mode ?? "production");
|
|
1850
1852
|
const skills = await getEnabledSkillMetadata(configDir, runtimeConfig.workdir);
|
|
1851
|
-
const { createToolRegistry } = await import("./tools-
|
|
1853
|
+
const { createToolRegistry } = await import("./tools-JDYXXX2N.js");
|
|
1852
1854
|
const allTools = createToolRegistry().definitions;
|
|
1853
1855
|
const toolFingerprint = getToolFingerprint(allTools);
|
|
1854
1856
|
const currentHash = computeDynamicContextHash(instructionContent, skills, toolFingerprint);
|
|
@@ -2069,4 +2071,4 @@ export {
|
|
|
2069
2071
|
signalMcpReady,
|
|
2070
2072
|
createWebSocketServer
|
|
2071
2073
|
};
|
|
2072
|
-
//# sourceMappingURL=chunk-
|
|
2074
|
+
//# sourceMappingURL=chunk-Y6STCE5Z.js.map
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
|
-
buildModelParams,
|
|
3
|
-
getBackendCapabilities,
|
|
4
|
-
getModelProfile,
|
|
5
2
|
streamWithSegments
|
|
6
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-J2GP3J3X.js";
|
|
4
|
+
import {
|
|
5
|
+
getBackendCapabilities
|
|
6
|
+
} from "./chunk-Z4FMBCJO.js";
|
|
7
|
+
import {
|
|
8
|
+
buildModelParams
|
|
9
|
+
} from "./chunk-ZJ4FP6RS.js";
|
|
7
10
|
import {
|
|
8
11
|
logger
|
|
9
12
|
} from "./chunk-K44MW7JJ.js";
|
|
13
|
+
import {
|
|
14
|
+
getModelProfile
|
|
15
|
+
} from "./chunk-V4IE7HJY.js";
|
|
10
16
|
|
|
11
17
|
// src/server/tools/tool-policy.ts
|
|
12
18
|
var ALWAYS_ALLOWED = /* @__PURE__ */ new Set(["step_done"]);
|
|
@@ -699,4 +705,4 @@ export {
|
|
|
699
705
|
createChatDoneEvent,
|
|
700
706
|
consumeStreamGenerator
|
|
701
707
|
};
|
|
702
|
-
//# sourceMappingURL=chunk-
|
|
708
|
+
//# sourceMappingURL=chunk-YGSBVKFU.js.map
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// src/server/llm/backend.ts
|
|
2
|
+
var BACKEND_CAPABILITIES = {
|
|
3
|
+
vllm: {
|
|
4
|
+
supportsChatTemplateKwargs: true,
|
|
5
|
+
supportsTopK: true
|
|
6
|
+
},
|
|
7
|
+
sglang: {
|
|
8
|
+
supportsChatTemplateKwargs: true,
|
|
9
|
+
supportsTopK: true
|
|
10
|
+
},
|
|
11
|
+
ollama: {
|
|
12
|
+
supportsChatTemplateKwargs: false,
|
|
13
|
+
supportsTopK: false
|
|
14
|
+
},
|
|
15
|
+
llamacpp: {
|
|
16
|
+
supportsChatTemplateKwargs: false,
|
|
17
|
+
supportsTopK: true
|
|
18
|
+
},
|
|
19
|
+
"opencode-go": {
|
|
20
|
+
supportsChatTemplateKwargs: false,
|
|
21
|
+
supportsTopK: true
|
|
22
|
+
},
|
|
23
|
+
unknown: {
|
|
24
|
+
supportsChatTemplateKwargs: true,
|
|
25
|
+
supportsTopK: true
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
function getBackendCapabilities(backend) {
|
|
29
|
+
return BACKEND_CAPABILITIES[backend];
|
|
30
|
+
}
|
|
31
|
+
function getBackendDisplayName(backend) {
|
|
32
|
+
switch (backend) {
|
|
33
|
+
case "vllm":
|
|
34
|
+
return "vLLM";
|
|
35
|
+
case "sglang":
|
|
36
|
+
return "SGLang";
|
|
37
|
+
case "ollama":
|
|
38
|
+
return "Ollama";
|
|
39
|
+
case "llamacpp":
|
|
40
|
+
return "llama.cpp";
|
|
41
|
+
case "opencode-go":
|
|
42
|
+
return "OpenCode Go";
|
|
43
|
+
case "unknown":
|
|
44
|
+
return "Other";
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export {
|
|
49
|
+
getBackendCapabilities,
|
|
50
|
+
getBackendDisplayName
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=chunk-Z4FMBCJO.js.map
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
// src/server/llm/client-pure.ts
|
|
2
|
+
function buildModelParams(params) {
|
|
3
|
+
return {
|
|
4
|
+
...params.temperature !== void 0 && { temperature: params.temperature },
|
|
5
|
+
...params.topP !== void 0 && { topP: params.topP },
|
|
6
|
+
...params.topK !== void 0 && { topK: params.topK },
|
|
7
|
+
...params.maxTokens !== void 0 && { maxTokens: params.maxTokens }
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
function buildAttachmentContent(msgContent, attachments, modelSupportsVision) {
|
|
11
|
+
const content = [];
|
|
12
|
+
if (msgContent?.trim()) {
|
|
13
|
+
content.push({ type: "text", text: msgContent });
|
|
14
|
+
}
|
|
15
|
+
for (const attachment of attachments) {
|
|
16
|
+
content.push(convertAttachmentSync(attachment, modelSupportsVision));
|
|
17
|
+
}
|
|
18
|
+
return content;
|
|
19
|
+
}
|
|
20
|
+
function convertToolCalls(toolCalls) {
|
|
21
|
+
return toolCalls.map((toolCall) => ({
|
|
22
|
+
id: toolCall.id,
|
|
23
|
+
type: "function",
|
|
24
|
+
function: {
|
|
25
|
+
name: toolCall.name,
|
|
26
|
+
arguments: JSON.stringify(toolCall.arguments)
|
|
27
|
+
}
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
function getThinking(msg, override) {
|
|
31
|
+
if (override) {
|
|
32
|
+
const val = msg[override];
|
|
33
|
+
if (val) return val;
|
|
34
|
+
}
|
|
35
|
+
return msg["reasoning"] ?? msg["reasoning_content"] ?? msg["thinking"];
|
|
36
|
+
}
|
|
37
|
+
function buildAssistantMessage(msg, thinkingField) {
|
|
38
|
+
const result = {
|
|
39
|
+
role: "assistant",
|
|
40
|
+
content: msg.content || null
|
|
41
|
+
};
|
|
42
|
+
if (msg.toolCalls?.length) {
|
|
43
|
+
result["tool_calls"] = convertToolCalls(msg.toolCalls);
|
|
44
|
+
}
|
|
45
|
+
if (msg.thinkingContent) {
|
|
46
|
+
result[thinkingField ?? "reasoning"] = msg.thinkingContent;
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
function convertAttachmentSync(attachment, modelSupportsVision) {
|
|
51
|
+
if (modelSupportsVision) {
|
|
52
|
+
return {
|
|
53
|
+
type: "image_url",
|
|
54
|
+
image_url: { url: attachment.data }
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
type: "text",
|
|
59
|
+
text: `[Image: ${attachment.filename || "image"}] (vision not supported, cannot describe)`
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function convertMessages(messages, modelSupportsVision, thinkingField) {
|
|
63
|
+
const filtered = messages.filter((msg) => {
|
|
64
|
+
return !(msg.role === "assistant" && !msg.content?.trim() && (!msg.toolCalls || msg.toolCalls.length === 0));
|
|
65
|
+
});
|
|
66
|
+
return filtered.map((msg) => {
|
|
67
|
+
if (msg.role === "tool") {
|
|
68
|
+
if (msg.attachments && msg.attachments.length > 0) {
|
|
69
|
+
const content = buildAttachmentContent(msg.content, msg.attachments, modelSupportsVision);
|
|
70
|
+
return {
|
|
71
|
+
role: "tool",
|
|
72
|
+
content,
|
|
73
|
+
tool_call_id: msg.toolCallId
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
role: "tool",
|
|
78
|
+
content: msg.content,
|
|
79
|
+
tool_call_id: msg.toolCallId
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
if (msg.role === "assistant") {
|
|
83
|
+
return buildAssistantMessage(msg, thinkingField);
|
|
84
|
+
}
|
|
85
|
+
if (msg.role === "user" && msg.attachments && msg.attachments.length > 0) {
|
|
86
|
+
const content = buildAttachmentContent(msg.content, msg.attachments, modelSupportsVision);
|
|
87
|
+
return {
|
|
88
|
+
role: "user",
|
|
89
|
+
content
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
role: msg.role,
|
|
94
|
+
content: msg.content
|
|
95
|
+
};
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function convertTools(tools) {
|
|
99
|
+
return tools.map((tool) => ({
|
|
100
|
+
type: "function",
|
|
101
|
+
function: {
|
|
102
|
+
name: tool.function.name,
|
|
103
|
+
description: tool.function.description,
|
|
104
|
+
parameters: tool.function.parameters
|
|
105
|
+
}
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
async function buildChatCompletionCreateParams(model, request, profile, capabilities, reasoningEffort, isStreaming, thinkingField) {
|
|
109
|
+
const userVisionOverride = request.modelSettings?.supportsVision;
|
|
110
|
+
const modelSupportsVision = userVisionOverride ?? profile.supportsVision ?? false;
|
|
111
|
+
const convertedMessages = convertMessages(request.messages, modelSupportsVision, thinkingField);
|
|
112
|
+
const temperature = request.modelSettings?.temperature ?? request.temperature ?? profile.temperature;
|
|
113
|
+
const maxTokens = request.modelSettings?.maxTokens ?? request.maxTokens ?? profile.defaultMaxTokens;
|
|
114
|
+
const topP = request.modelSettings?.topP ?? profile.topP;
|
|
115
|
+
const topK = capabilities.supportsTopK ? profile.topK : void 0;
|
|
116
|
+
const params = {
|
|
117
|
+
model,
|
|
118
|
+
messages: convertedMessages,
|
|
119
|
+
...request.tools?.length ? { tools: convertTools(request.tools) } : {},
|
|
120
|
+
...request.toolChoice ? { tool_choice: request.toolChoice } : {},
|
|
121
|
+
temperature,
|
|
122
|
+
max_tokens: maxTokens,
|
|
123
|
+
top_p: topP,
|
|
124
|
+
stream: isStreaming,
|
|
125
|
+
...isStreaming ? { stream_options: { include_usage: true } } : {}
|
|
126
|
+
};
|
|
127
|
+
if (topK !== void 0) {
|
|
128
|
+
;
|
|
129
|
+
params["top_k"] = topK;
|
|
130
|
+
}
|
|
131
|
+
const resolvedEffort = reasoningEffort ?? request.reasoningEffort;
|
|
132
|
+
const queryParams = request.modelSettings?.queryParams;
|
|
133
|
+
const hasQueryParams = queryParams && Object.keys(queryParams).length > 0;
|
|
134
|
+
const hasExplicitModelSettings = hasQueryParams || !!request.modelSettings?.chatTemplateKwargs;
|
|
135
|
+
if (hasQueryParams) {
|
|
136
|
+
Object.assign(params, queryParams);
|
|
137
|
+
if (resolvedEffort) {
|
|
138
|
+
;
|
|
139
|
+
params["reasoning_effort"] = resolvedEffort;
|
|
140
|
+
}
|
|
141
|
+
} else if (hasExplicitModelSettings) {
|
|
142
|
+
const chatTemplateKwargs = request.modelSettings.chatTemplateKwargs;
|
|
143
|
+
if (chatTemplateKwargs) {
|
|
144
|
+
;
|
|
145
|
+
params["chat_template_kwargs"] = chatTemplateKwargs;
|
|
146
|
+
}
|
|
147
|
+
} else {
|
|
148
|
+
if (resolvedEffort) {
|
|
149
|
+
;
|
|
150
|
+
params["reasoning_effort"] = resolvedEffort;
|
|
151
|
+
}
|
|
152
|
+
if (resolvedEffort && capabilities.supportsChatTemplateKwargs) {
|
|
153
|
+
;
|
|
154
|
+
params["chat_template_kwargs"] = {
|
|
155
|
+
enable_thinking: true
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
const modelParams = buildModelParams({ temperature, topP, topK, maxTokens });
|
|
160
|
+
return { params, modelParams };
|
|
161
|
+
}
|
|
162
|
+
async function buildCreateParamsFromInput(input, isStreaming) {
|
|
163
|
+
const { model, request, profile, capabilities, reasoningEffort, thinkingField } = input;
|
|
164
|
+
return buildChatCompletionCreateParams(
|
|
165
|
+
model,
|
|
166
|
+
request,
|
|
167
|
+
profile,
|
|
168
|
+
capabilities,
|
|
169
|
+
reasoningEffort,
|
|
170
|
+
isStreaming,
|
|
171
|
+
thinkingField
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
var buildNonStreamingCreateParams = (input) => buildCreateParamsFromInput(input, false);
|
|
175
|
+
var buildStreamingCreateParams = (input) => buildCreateParamsFromInput(input, true);
|
|
176
|
+
function mapFinishReason(reason) {
|
|
177
|
+
switch (reason) {
|
|
178
|
+
case "stop":
|
|
179
|
+
return "stop";
|
|
180
|
+
case "tool_calls":
|
|
181
|
+
return "tool_calls";
|
|
182
|
+
case "length":
|
|
183
|
+
return "length";
|
|
184
|
+
case "content_filter":
|
|
185
|
+
return "content_filter";
|
|
186
|
+
default:
|
|
187
|
+
return "stop";
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export {
|
|
192
|
+
buildModelParams,
|
|
193
|
+
getThinking,
|
|
194
|
+
convertMessages,
|
|
195
|
+
convertTools,
|
|
196
|
+
buildNonStreamingCreateParams,
|
|
197
|
+
buildStreamingCreateParams,
|
|
198
|
+
mapFinishReason
|
|
199
|
+
};
|
|
200
|
+
//# sourceMappingURL=chunk-ZJ4FP6RS.js.map
|
package/dist/cli/dev.js
CHANGED
package/dist/cli/index.js
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createLLMClient
|
|
3
|
+
} from "./chunk-2ELCWCO3.js";
|
|
4
|
+
import "./chunk-Z4FMBCJO.js";
|
|
5
|
+
import "./chunk-HNCM3D7Y.js";
|
|
6
|
+
import "./chunk-ZJ4FP6RS.js";
|
|
7
|
+
import "./chunk-IEDE6VK4.js";
|
|
8
|
+
import "./chunk-K44MW7JJ.js";
|
|
9
|
+
import "./chunk-V4IE7HJY.js";
|
|
10
|
+
export {
|
|
11
|
+
createLLMClient
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=client-725U6BTX.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildModelParams,
|
|
3
|
+
buildNonStreamingCreateParams,
|
|
4
|
+
buildStreamingCreateParams,
|
|
5
|
+
convertMessages,
|
|
6
|
+
convertTools,
|
|
7
|
+
getThinking,
|
|
8
|
+
mapFinishReason
|
|
9
|
+
} from "./chunk-ZJ4FP6RS.js";
|
|
10
|
+
export {
|
|
11
|
+
buildModelParams,
|
|
12
|
+
buildNonStreamingCreateParams,
|
|
13
|
+
buildStreamingCreateParams,
|
|
14
|
+
convertMessages,
|
|
15
|
+
convertTools,
|
|
16
|
+
getThinking,
|
|
17
|
+
mapFinishReason
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=client-pure-5NOTSIRK.js.map
|
|
@@ -2,16 +2,19 @@ import {
|
|
|
2
2
|
appendCompactionPrompt,
|
|
3
3
|
getCompactionTarget,
|
|
4
4
|
shouldCompact
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-WEXW7ZXJ.js";
|
|
6
|
+
import "./chunk-YGSBVKFU.js";
|
|
7
7
|
import "./chunk-YBWY4DKY.js";
|
|
8
8
|
import "./chunk-6PLAWCHQ.js";
|
|
9
9
|
import "./chunk-FBGWG4N6.js";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-J2GP3J3X.js";
|
|
11
|
+
import "./chunk-Z4FMBCJO.js";
|
|
12
|
+
import "./chunk-ZJ4FP6RS.js";
|
|
11
13
|
import "./chunk-K44MW7JJ.js";
|
|
14
|
+
import "./chunk-V4IE7HJY.js";
|
|
12
15
|
export {
|
|
13
16
|
appendCompactionPrompt,
|
|
14
17
|
getCompactionTarget,
|
|
15
18
|
shouldCompact
|
|
16
19
|
};
|
|
17
|
-
//# sourceMappingURL=compactor-
|
|
20
|
+
//# sourceMappingURL=compactor-JMGSZ4DQ.js.map
|