openfox 2.0.0-beta.11 → 2.0.0-beta.13
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/{chat-handler-NMJCOCCB.js → chat-handler-DKX2XFHA.js} +8 -8
- package/dist/{chunk-EQQDA4D3.js → chunk-5RP2ZU2G.js} +14 -16
- package/dist/{chunk-4RLDN2LL.js → chunk-BNFQMAH6.js} +160 -39
- package/dist/{chunk-BU56QFHW.js → chunk-DBDMMSCM.js} +7 -8
- package/dist/{chunk-NSBYORD5.js → chunk-DHAKJSE7.js} +4 -2
- package/dist/{chunk-EZUR7OEP.js → chunk-HZODNSSV.js} +15 -9
- package/dist/{chunk-LCRJWUW7.js → chunk-LDHRZRCP.js} +6 -6
- package/dist/{chunk-VIIRNJDT.js → chunk-LXX2CPM5.js} +203 -236
- package/dist/{chunk-EXYMWI7A.js → chunk-OKLV3ZNN.js} +9 -5
- package/dist/{chunk-UKTPL5ZG.js → chunk-SW7MQGY3.js} +123 -214
- package/dist/{chunk-DMH6JVPF.js → chunk-YLQGD5SE.js} +28 -8
- package/dist/cli/dev.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/{config-TDVA7MQN.js → config-FAT5XRFB.js} +5 -5
- package/dist/{events-UGTGGFG3.js → events-R7FRQEBE.js} +2 -2
- package/dist/{orchestrator-75L5UGDU.js → orchestrator-NNYZC7AY.js} +7 -7
- package/dist/package.json +1 -1
- package/dist/{processor-GHESQ2YV.js → processor-5T3CXD5I.js} +10 -5
- package/dist/{protocol-B9R1CUvt.d.ts → protocol-zn90yuIr.d.ts} +11 -2
- package/dist/{provider-BGH4MBLH.js → provider-2JYU6KGH.js} +9 -9
- package/dist/provider-manager-IP3HOGNB.js +16 -0
- package/dist/{serve-I6T7V62Z.js → serve-NSTNUQ2K.js} +13 -13
- package/dist/server/index.d.ts +21 -15
- package/dist/server/index.js +9 -9
- package/dist/shared/index.d.ts +2 -2
- package/dist/{tools-D3WWIOQD.js → tools-TJGSHOAR.js} +6 -6
- package/dist/web/assets/index-DIY3E8K9.js +299 -0
- package/dist/web/assets/{index-CSOB8dwI.css → index-Sdax8ayU.css} +1 -1
- package/dist/web/index.html +2 -2
- package/dist/web/sw.js +1 -1
- package/package.json +1 -1
- package/dist/web/assets/index-tJDr1ODC.js +0 -299
|
@@ -3,116 +3,16 @@ import {
|
|
|
3
3
|
buildNonStreamingCreateParams,
|
|
4
4
|
buildStreamingCreateParams,
|
|
5
5
|
ensureVersionPrefix,
|
|
6
|
-
extractThinking,
|
|
7
6
|
getBackendCapabilities,
|
|
8
7
|
getModelProfile,
|
|
8
|
+
getThinking,
|
|
9
9
|
mapFinishReason,
|
|
10
10
|
stripVersionPrefix
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-LXX2CPM5.js";
|
|
12
12
|
import {
|
|
13
13
|
logger
|
|
14
14
|
} from "./chunk-K44MW7JJ.js";
|
|
15
15
|
|
|
16
|
-
// src/server/llm/models.ts
|
|
17
|
-
var modelCache = /* @__PURE__ */ new Map();
|
|
18
|
-
var llmStatus = "unknown";
|
|
19
|
-
var lastActiveUrl = null;
|
|
20
|
-
var CACHE_TTL_MS = 3e4;
|
|
21
|
-
function getCacheKey(url) {
|
|
22
|
-
return stripVersionPrefix(url);
|
|
23
|
-
}
|
|
24
|
-
async function detectModel(llmBaseUrl, retries = 3, silent = false) {
|
|
25
|
-
const cacheKey = getCacheKey(llmBaseUrl);
|
|
26
|
-
const now = Date.now();
|
|
27
|
-
const cached = modelCache.get(cacheKey);
|
|
28
|
-
if (cached && now - cached.timestamp < CACHE_TTL_MS) {
|
|
29
|
-
lastActiveUrl = cacheKey;
|
|
30
|
-
llmStatus = "connected";
|
|
31
|
-
return cached.model;
|
|
32
|
-
}
|
|
33
|
-
const url = buildModelsUrl(llmBaseUrl);
|
|
34
|
-
for (let attempt = 1; attempt <= retries; attempt++) {
|
|
35
|
-
try {
|
|
36
|
-
if (silent) {
|
|
37
|
-
logger.debug("Fetching models from LLM server", { url, attempt });
|
|
38
|
-
}
|
|
39
|
-
const response = await fetch(url, {
|
|
40
|
-
signal: AbortSignal.timeout(1e4)
|
|
41
|
-
});
|
|
42
|
-
if (!response.ok) {
|
|
43
|
-
if (silent) {
|
|
44
|
-
logger.debug("Failed to fetch models from LLM server", { status: response.status, attempt });
|
|
45
|
-
} else {
|
|
46
|
-
logger.warn("Failed to fetch models from LLM server", { status: response.status, attempt });
|
|
47
|
-
}
|
|
48
|
-
if (attempt < retries) {
|
|
49
|
-
await new Promise((r) => setTimeout(r, 1e3 * attempt));
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
llmStatus = "disconnected";
|
|
53
|
-
return cached?.model ?? null;
|
|
54
|
-
}
|
|
55
|
-
const data = await response.json();
|
|
56
|
-
if (data.data && data.data.length > 0) {
|
|
57
|
-
const modelData = data.data[0];
|
|
58
|
-
const modelId = modelData.id;
|
|
59
|
-
modelCache.set(cacheKey, {
|
|
60
|
-
model: modelId,
|
|
61
|
-
modelInfo: modelData,
|
|
62
|
-
timestamp: now
|
|
63
|
-
});
|
|
64
|
-
lastActiveUrl = cacheKey;
|
|
65
|
-
llmStatus = "connected";
|
|
66
|
-
if (silent) {
|
|
67
|
-
logger.debug("Detected LLM model", {
|
|
68
|
-
model: modelId,
|
|
69
|
-
maxLen: modelData.max_model_len,
|
|
70
|
-
root: modelData.root
|
|
71
|
-
});
|
|
72
|
-
} else {
|
|
73
|
-
logger.info("Detected LLM model", {
|
|
74
|
-
model: modelId,
|
|
75
|
-
maxLen: modelData.max_model_len,
|
|
76
|
-
root: modelData.root
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
return modelId;
|
|
80
|
-
}
|
|
81
|
-
if (silent) {
|
|
82
|
-
logger.debug("LLM server returned empty models list");
|
|
83
|
-
} else {
|
|
84
|
-
logger.warn("LLM server returned empty models list");
|
|
85
|
-
}
|
|
86
|
-
llmStatus = "disconnected";
|
|
87
|
-
return null;
|
|
88
|
-
} catch (error) {
|
|
89
|
-
const errMsg = error instanceof Error ? error.message : String(error);
|
|
90
|
-
if (silent) {
|
|
91
|
-
logger.debug("Could not detect model from LLM server", { error: errMsg, attempt });
|
|
92
|
-
} else {
|
|
93
|
-
logger.warn("Could not detect model from LLM server", { error: errMsg, attempt });
|
|
94
|
-
}
|
|
95
|
-
if (attempt < retries) {
|
|
96
|
-
await new Promise((r) => setTimeout(r, 1e3 * attempt));
|
|
97
|
-
continue;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
llmStatus = "disconnected";
|
|
102
|
-
return cached?.model ?? null;
|
|
103
|
-
}
|
|
104
|
-
function getLlmStatus() {
|
|
105
|
-
return llmStatus;
|
|
106
|
-
}
|
|
107
|
-
function clearModelCache(url) {
|
|
108
|
-
if (url) {
|
|
109
|
-
modelCache.delete(getCacheKey(url));
|
|
110
|
-
} else {
|
|
111
|
-
modelCache.clear();
|
|
112
|
-
}
|
|
113
|
-
llmStatus = "unknown";
|
|
114
|
-
}
|
|
115
|
-
|
|
116
16
|
// src/server/llm/client.ts
|
|
117
17
|
import OpenAI from "openai";
|
|
118
18
|
|
|
@@ -149,7 +49,8 @@ function createLLMClient(config, initialBackend = "unknown") {
|
|
|
149
49
|
let profile = getModelProfile(model);
|
|
150
50
|
let backend = initialBackend;
|
|
151
51
|
let capabilities = getBackendCapabilities(backend);
|
|
152
|
-
const
|
|
52
|
+
const reasoningEffort = config.llm.reasoningEffort;
|
|
53
|
+
const thinkingField = config.llm.thinkingField;
|
|
153
54
|
const idleTimeout = config.llm.idleTimeout ?? 3e4;
|
|
154
55
|
return {
|
|
155
56
|
getModel() {
|
|
@@ -172,8 +73,7 @@ function createLLMClient(config, initialBackend = "unknown") {
|
|
|
172
73
|
from: model,
|
|
173
74
|
to: newModel,
|
|
174
75
|
profile: newProfile.name,
|
|
175
|
-
temperature: newProfile.temperature
|
|
176
|
-
supportsReasoning: newProfile.supportsReasoning
|
|
76
|
+
temperature: newProfile.temperature
|
|
177
77
|
});
|
|
178
78
|
model = newModel;
|
|
179
79
|
profile = newProfile;
|
|
@@ -183,16 +83,17 @@ function createLLMClient(config, initialBackend = "unknown") {
|
|
|
183
83
|
messageCount: request.messages.length,
|
|
184
84
|
hasTools: !!request.tools?.length,
|
|
185
85
|
profile: profile.name,
|
|
186
|
-
|
|
86
|
+
reasoningEffort: request.reasoningEffort ?? reasoningEffort
|
|
187
87
|
});
|
|
188
88
|
try {
|
|
189
|
-
const
|
|
89
|
+
const resolvedEffort = request.reasoningEffort ?? reasoningEffort;
|
|
190
90
|
const { params: createParams } = await buildNonStreamingCreateParams({
|
|
191
91
|
model,
|
|
192
92
|
request,
|
|
193
93
|
profile,
|
|
194
94
|
capabilities,
|
|
195
|
-
|
|
95
|
+
...resolvedEffort ? { reasoningEffort: resolvedEffort } : {},
|
|
96
|
+
...thinkingField ? { thinkingField } : {}
|
|
196
97
|
});
|
|
197
98
|
const response = await openai.chat.completions.create(createParams, {
|
|
198
99
|
signal: request.signal
|
|
@@ -202,25 +103,8 @@ function createLLMClient(config, initialBackend = "unknown") {
|
|
|
202
103
|
throw new LLMError("No completion choice returned");
|
|
203
104
|
}
|
|
204
105
|
const message = choice.message;
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
if (profile.supportsReasoning) {
|
|
208
|
-
if (capabilities.supportsReasoningField) {
|
|
209
|
-
thinkingContent = message.reasoning_content ?? message.reasoning ?? "";
|
|
210
|
-
} else {
|
|
211
|
-
const extracted = extractThinking(content);
|
|
212
|
-
content = extracted.content;
|
|
213
|
-
thinkingContent = extracted.thinkingContent ?? "";
|
|
214
|
-
}
|
|
215
|
-
if (profile.reasoningAsContent && thinkingContent.trim()) {
|
|
216
|
-
content = thinkingContent;
|
|
217
|
-
thinkingContent = "";
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
if (!content.trim() && thinkingContent.trim()) {
|
|
221
|
-
content = thinkingContent;
|
|
222
|
-
thinkingContent = "";
|
|
223
|
-
}
|
|
106
|
+
const content = message.content ?? "";
|
|
107
|
+
const thinkingContent = getThinking(message, thinkingField) ?? "";
|
|
224
108
|
const toolCalls = message.tool_calls?.map((tc) => ({
|
|
225
109
|
id: tc.id,
|
|
226
110
|
name: tc.function.name,
|
|
@@ -250,17 +134,18 @@ function createLLMClient(config, initialBackend = "unknown") {
|
|
|
250
134
|
messageCount: request.messages.length,
|
|
251
135
|
hasTools: !!request.tools?.length,
|
|
252
136
|
profile: profile.name,
|
|
253
|
-
|
|
137
|
+
reasoningEffort: request.reasoningEffort ?? reasoningEffort,
|
|
254
138
|
idleTimeout
|
|
255
139
|
});
|
|
256
140
|
try {
|
|
257
|
-
const
|
|
141
|
+
const resolvedEffort = request.reasoningEffort ?? reasoningEffort;
|
|
258
142
|
const createParams = await buildStreamingCreateParams({
|
|
259
143
|
model,
|
|
260
144
|
request,
|
|
261
145
|
profile,
|
|
262
146
|
capabilities,
|
|
263
|
-
|
|
147
|
+
...resolvedEffort ? { reasoningEffort: resolvedEffort } : {},
|
|
148
|
+
...thinkingField ? { thinkingField } : {}
|
|
264
149
|
});
|
|
265
150
|
const { params: streamingParams } = createParams;
|
|
266
151
|
const stream = await openai.chat.completions.create(streamingParams, {
|
|
@@ -268,8 +153,6 @@ function createLLMClient(config, initialBackend = "unknown") {
|
|
|
268
153
|
});
|
|
269
154
|
let fullContent = "";
|
|
270
155
|
let fullThinking = "";
|
|
271
|
-
let inThinking = false;
|
|
272
|
-
let tagBuffer = "";
|
|
273
156
|
const toolCalls = /* @__PURE__ */ new Map();
|
|
274
157
|
let finishReason = "stop";
|
|
275
158
|
let usage = { promptTokens: 0, completionTokens: 0, totalTokens: 0 };
|
|
@@ -305,73 +188,14 @@ function createLLMClient(config, initialBackend = "unknown") {
|
|
|
305
188
|
finishReason = mapFinishReason(choice.finish_reason);
|
|
306
189
|
}
|
|
307
190
|
const delta = choice.delta;
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
fullThinking += reasoning;
|
|
313
|
-
yield { type: "thinking_delta", content: reasoning };
|
|
314
|
-
} else {
|
|
315
|
-
fullContent += reasoning;
|
|
316
|
-
yield { type: "text_delta", content: reasoning };
|
|
317
|
-
}
|
|
318
|
-
}
|
|
191
|
+
const reasoning = getThinking(delta, thinkingField);
|
|
192
|
+
if (reasoning) {
|
|
193
|
+
fullThinking += reasoning;
|
|
194
|
+
yield { type: "thinking_delta", content: reasoning };
|
|
319
195
|
}
|
|
320
196
|
if (delta.content) {
|
|
321
197
|
fullContent += delta.content;
|
|
322
|
-
|
|
323
|
-
tagBuffer += delta.content;
|
|
324
|
-
while (tagBuffer.length > 0) {
|
|
325
|
-
if (inThinking) {
|
|
326
|
-
const closeIdx = tagBuffer.indexOf("</think>");
|
|
327
|
-
if (closeIdx !== -1) {
|
|
328
|
-
const thinkText = tagBuffer.slice(0, closeIdx);
|
|
329
|
-
if (thinkText) {
|
|
330
|
-
fullThinking += thinkText;
|
|
331
|
-
yield { type: "thinking_delta", content: thinkText };
|
|
332
|
-
}
|
|
333
|
-
tagBuffer = tagBuffer.slice(closeIdx + "</think>".length);
|
|
334
|
-
inThinking = false;
|
|
335
|
-
} else if (tagBuffer.includes("</")) {
|
|
336
|
-
const partialIdx = tagBuffer.lastIndexOf("</");
|
|
337
|
-
const before = tagBuffer.slice(0, partialIdx);
|
|
338
|
-
if (before) {
|
|
339
|
-
fullThinking += before;
|
|
340
|
-
yield { type: "thinking_delta", content: before };
|
|
341
|
-
}
|
|
342
|
-
tagBuffer = tagBuffer.slice(partialIdx);
|
|
343
|
-
break;
|
|
344
|
-
} else {
|
|
345
|
-
fullThinking += tagBuffer;
|
|
346
|
-
yield { type: "thinking_delta", content: tagBuffer };
|
|
347
|
-
tagBuffer = "";
|
|
348
|
-
}
|
|
349
|
-
} else {
|
|
350
|
-
const openIdx = tagBuffer.indexOf("<think>");
|
|
351
|
-
if (openIdx !== -1) {
|
|
352
|
-
const textBefore = tagBuffer.slice(0, openIdx);
|
|
353
|
-
if (textBefore) {
|
|
354
|
-
yield { type: "text_delta", content: textBefore };
|
|
355
|
-
}
|
|
356
|
-
tagBuffer = tagBuffer.slice(openIdx + "<think>".length);
|
|
357
|
-
inThinking = true;
|
|
358
|
-
} else if (tagBuffer.includes("<")) {
|
|
359
|
-
const partialIdx = tagBuffer.lastIndexOf("<");
|
|
360
|
-
const before = tagBuffer.slice(0, partialIdx);
|
|
361
|
-
if (before) {
|
|
362
|
-
yield { type: "text_delta", content: before };
|
|
363
|
-
}
|
|
364
|
-
tagBuffer = tagBuffer.slice(partialIdx);
|
|
365
|
-
break;
|
|
366
|
-
} else {
|
|
367
|
-
yield { type: "text_delta", content: tagBuffer };
|
|
368
|
-
tagBuffer = "";
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
} else {
|
|
373
|
-
yield { type: "text_delta", content: delta.content };
|
|
374
|
-
}
|
|
198
|
+
yield { type: "text_delta", content: delta.content };
|
|
375
199
|
}
|
|
376
200
|
if (delta.tool_calls) {
|
|
377
201
|
for (const tc of delta.tool_calls) {
|
|
@@ -401,23 +225,8 @@ function createLLMClient(config, initialBackend = "unknown") {
|
|
|
401
225
|
clearInterval(idleTimer);
|
|
402
226
|
request.signal?.removeEventListener("abort", onAbort);
|
|
403
227
|
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
fullThinking += tagBuffer;
|
|
407
|
-
}
|
|
408
|
-
tagBuffer = "";
|
|
409
|
-
}
|
|
410
|
-
let finalContent = fullContent.trim();
|
|
411
|
-
let finalThinking = fullThinking.trim();
|
|
412
|
-
if (!capabilities.supportsReasoningField && profile.supportsReasoning) {
|
|
413
|
-
const extracted = extractThinking(finalContent);
|
|
414
|
-
finalContent = extracted.content;
|
|
415
|
-
finalThinking = extracted.thinkingContent ?? "";
|
|
416
|
-
}
|
|
417
|
-
if (!finalContent && finalThinking) {
|
|
418
|
-
finalContent = finalThinking;
|
|
419
|
-
finalThinking = "";
|
|
420
|
-
}
|
|
228
|
+
const finalContent = fullContent.trim();
|
|
229
|
+
const finalThinking = fullThinking.trim();
|
|
421
230
|
const parsedToolCalls = [];
|
|
422
231
|
for (const [, tc] of toolCalls) {
|
|
423
232
|
try {
|
|
@@ -459,6 +268,106 @@ function createLLMClient(config, initialBackend = "unknown") {
|
|
|
459
268
|
};
|
|
460
269
|
}
|
|
461
270
|
|
|
271
|
+
// src/server/llm/models.ts
|
|
272
|
+
var modelCache = /* @__PURE__ */ new Map();
|
|
273
|
+
var llmStatus = "unknown";
|
|
274
|
+
var lastActiveUrl = null;
|
|
275
|
+
var CACHE_TTL_MS = 3e4;
|
|
276
|
+
function getCacheKey(url) {
|
|
277
|
+
return stripVersionPrefix(url);
|
|
278
|
+
}
|
|
279
|
+
async function detectModel(llmBaseUrl, retries = 3, silent = false) {
|
|
280
|
+
const cacheKey = getCacheKey(llmBaseUrl);
|
|
281
|
+
const now = Date.now();
|
|
282
|
+
const cached = modelCache.get(cacheKey);
|
|
283
|
+
if (cached && now - cached.timestamp < CACHE_TTL_MS) {
|
|
284
|
+
lastActiveUrl = cacheKey;
|
|
285
|
+
llmStatus = "connected";
|
|
286
|
+
return cached.model;
|
|
287
|
+
}
|
|
288
|
+
const url = buildModelsUrl(llmBaseUrl);
|
|
289
|
+
for (let attempt = 1; attempt <= retries; attempt++) {
|
|
290
|
+
try {
|
|
291
|
+
if (silent) {
|
|
292
|
+
logger.debug("Fetching models from LLM server", { url, attempt });
|
|
293
|
+
}
|
|
294
|
+
const response = await fetch(url, {
|
|
295
|
+
signal: AbortSignal.timeout(1e4)
|
|
296
|
+
});
|
|
297
|
+
if (!response.ok) {
|
|
298
|
+
if (silent) {
|
|
299
|
+
logger.debug("Failed to fetch models from LLM server", { status: response.status, attempt });
|
|
300
|
+
} else {
|
|
301
|
+
logger.warn("Failed to fetch models from LLM server", { status: response.status, attempt });
|
|
302
|
+
}
|
|
303
|
+
if (attempt < retries) {
|
|
304
|
+
await new Promise((r) => setTimeout(r, 1e3 * attempt));
|
|
305
|
+
continue;
|
|
306
|
+
}
|
|
307
|
+
llmStatus = "disconnected";
|
|
308
|
+
return cached?.model ?? null;
|
|
309
|
+
}
|
|
310
|
+
const data = await response.json();
|
|
311
|
+
if (data.data && data.data.length > 0) {
|
|
312
|
+
const modelData = data.data[0];
|
|
313
|
+
const modelId = modelData.id;
|
|
314
|
+
modelCache.set(cacheKey, {
|
|
315
|
+
model: modelId,
|
|
316
|
+
modelInfo: modelData,
|
|
317
|
+
timestamp: now
|
|
318
|
+
});
|
|
319
|
+
lastActiveUrl = cacheKey;
|
|
320
|
+
llmStatus = "connected";
|
|
321
|
+
if (silent) {
|
|
322
|
+
logger.debug("Detected LLM model", {
|
|
323
|
+
model: modelId,
|
|
324
|
+
maxLen: modelData.max_model_len,
|
|
325
|
+
root: modelData.root
|
|
326
|
+
});
|
|
327
|
+
} else {
|
|
328
|
+
logger.info("Detected LLM model", {
|
|
329
|
+
model: modelId,
|
|
330
|
+
maxLen: modelData.max_model_len,
|
|
331
|
+
root: modelData.root
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
return modelId;
|
|
335
|
+
}
|
|
336
|
+
if (silent) {
|
|
337
|
+
logger.debug("LLM server returned empty models list");
|
|
338
|
+
} else {
|
|
339
|
+
logger.warn("LLM server returned empty models list");
|
|
340
|
+
}
|
|
341
|
+
llmStatus = "disconnected";
|
|
342
|
+
return null;
|
|
343
|
+
} catch (error) {
|
|
344
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
345
|
+
if (silent) {
|
|
346
|
+
logger.debug("Could not detect model from LLM server", { error: errMsg, attempt });
|
|
347
|
+
} else {
|
|
348
|
+
logger.warn("Could not detect model from LLM server", { error: errMsg, attempt });
|
|
349
|
+
}
|
|
350
|
+
if (attempt < retries) {
|
|
351
|
+
await new Promise((r) => setTimeout(r, 1e3 * attempt));
|
|
352
|
+
continue;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
llmStatus = "disconnected";
|
|
357
|
+
return cached?.model ?? null;
|
|
358
|
+
}
|
|
359
|
+
function getLlmStatus() {
|
|
360
|
+
return llmStatus;
|
|
361
|
+
}
|
|
362
|
+
function clearModelCache(url) {
|
|
363
|
+
if (url) {
|
|
364
|
+
modelCache.delete(getCacheKey(url));
|
|
365
|
+
} else {
|
|
366
|
+
modelCache.clear();
|
|
367
|
+
}
|
|
368
|
+
llmStatus = "unknown";
|
|
369
|
+
}
|
|
370
|
+
|
|
462
371
|
export {
|
|
463
372
|
SessionNotFoundError,
|
|
464
373
|
createLLMClient,
|
|
@@ -466,4 +375,4 @@ export {
|
|
|
466
375
|
getLlmStatus,
|
|
467
376
|
clearModelCache
|
|
468
377
|
};
|
|
469
|
-
//# sourceMappingURL=chunk-
|
|
378
|
+
//# sourceMappingURL=chunk-SW7MQGY3.js.map
|
|
@@ -2,14 +2,14 @@ import {
|
|
|
2
2
|
clearModelCache,
|
|
3
3
|
createLLMClient,
|
|
4
4
|
detectModel
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-SW7MQGY3.js";
|
|
6
6
|
import {
|
|
7
7
|
buildModelsUrl,
|
|
8
8
|
detectBackend,
|
|
9
9
|
ensureVersionPrefix,
|
|
10
10
|
getModelProfile,
|
|
11
11
|
stripVersionPrefix
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-LXX2CPM5.js";
|
|
13
13
|
import {
|
|
14
14
|
logger
|
|
15
15
|
} from "./chunk-K44MW7JJ.js";
|
|
@@ -163,6 +163,7 @@ function parseDefaultModelSelection(selection) {
|
|
|
163
163
|
}
|
|
164
164
|
function createProviderManager(config) {
|
|
165
165
|
let providers = [...config.providers ?? []];
|
|
166
|
+
providers = providers.map((p) => ({ ...p, models: p.models.map((m) => enrichWithProfileDefaults(m)) }));
|
|
166
167
|
let defaultModelSelection = config.defaultModelSelection;
|
|
167
168
|
let llmClient = createLLMClient(config);
|
|
168
169
|
const providerStatus = /* @__PURE__ */ new Map();
|
|
@@ -175,7 +176,16 @@ function createProviderManager(config) {
|
|
|
175
176
|
for (const p of providers) {
|
|
176
177
|
providerStatus.set(p.id, "unknown");
|
|
177
178
|
}
|
|
179
|
+
function resolveModelThinkingConfig(provider, modelId) {
|
|
180
|
+
const modelConfig = provider.models.find((m) => m.id === modelId);
|
|
181
|
+
if (!modelConfig) return {};
|
|
182
|
+
if (modelConfig.thinkingEnabled && modelConfig.thinkingLevel) {
|
|
183
|
+
return { reasoningEffort: modelConfig.thinkingLevel };
|
|
184
|
+
}
|
|
185
|
+
return {};
|
|
186
|
+
}
|
|
178
187
|
function createConfigForProvider(provider, model) {
|
|
188
|
+
const modelThinking = resolveModelThinkingConfig(provider, model);
|
|
179
189
|
return {
|
|
180
190
|
...config,
|
|
181
191
|
llm: {
|
|
@@ -183,7 +193,9 @@ function createProviderManager(config) {
|
|
|
183
193
|
baseUrl: ensureVersionPrefix(provider.url),
|
|
184
194
|
model,
|
|
185
195
|
backend: provider.backend,
|
|
186
|
-
...provider.apiKey && { apiKey: provider.apiKey }
|
|
196
|
+
...provider.apiKey && { apiKey: provider.apiKey },
|
|
197
|
+
...provider.thinkingField && { thinkingField: provider.thinkingField },
|
|
198
|
+
...modelThinking.reasoningEffort && { reasoningEffort: modelThinking.reasoningEffort }
|
|
187
199
|
}
|
|
188
200
|
};
|
|
189
201
|
}
|
|
@@ -336,7 +348,7 @@ function createProviderManager(config) {
|
|
|
336
348
|
const newActiveProviderId = this.getActiveProviderId();
|
|
337
349
|
if (newActiveProviderId && newActiveProviderId !== wasActiveProviderId) {
|
|
338
350
|
const activeProvider = providers.find((p) => p.id === newActiveProviderId);
|
|
339
|
-
if (activeProvider) {
|
|
351
|
+
if (activeProvider && activeProvider.apiKey) {
|
|
340
352
|
const providerConfig = createConfigForProvider(activeProvider, this.getCurrentModel() ?? "auto");
|
|
341
353
|
llmClient = createLLMClient(providerConfig);
|
|
342
354
|
logger.info("setProviders: recreated LLM client for new active provider", {
|
|
@@ -440,7 +452,12 @@ function createProviderManager(config) {
|
|
|
440
452
|
...finalTopP !== void 0 && { topP: finalTopP },
|
|
441
453
|
...finalTopK !== void 0 && { topK: finalTopK },
|
|
442
454
|
...finalMaxTokens !== void 0 && { maxTokens: finalMaxTokens },
|
|
443
|
-
...finalSupportsVision !== void 0 && { supportsVision: finalSupportsVision }
|
|
455
|
+
...finalSupportsVision !== void 0 && { supportsVision: finalSupportsVision },
|
|
456
|
+
...settings.thinkingEnabled !== void 0 ? { thinkingEnabled: settings.thinkingEnabled } : existingModel?.thinkingEnabled !== void 0 ? { thinkingEnabled: existingModel.thinkingEnabled } : {},
|
|
457
|
+
...settings.thinkingLevel !== void 0 ? { thinkingLevel: settings.thinkingLevel } : existingModel?.thinkingLevel !== void 0 ? { thinkingLevel: existingModel.thinkingLevel } : {},
|
|
458
|
+
...settings.nonThinkingEnabled !== void 0 ? { nonThinkingEnabled: settings.nonThinkingEnabled } : existingModel?.nonThinkingEnabled !== void 0 ? { nonThinkingEnabled: existingModel.nonThinkingEnabled } : {},
|
|
459
|
+
...settings.thinkingExtraKwargs !== void 0 ? { thinkingExtraKwargs: settings.thinkingExtraKwargs } : existingModel?.thinkingExtraKwargs !== void 0 ? { thinkingExtraKwargs: existingModel.thinkingExtraKwargs } : {},
|
|
460
|
+
...settings.nonThinkingExtraKwargs !== void 0 ? { nonThinkingExtraKwargs: settings.nonThinkingExtraKwargs } : existingModel?.nonThinkingExtraKwargs !== void 0 ? { nonThinkingExtraKwargs: existingModel.nonThinkingExtraKwargs } : {}
|
|
444
461
|
});
|
|
445
462
|
if (existingModel) {
|
|
446
463
|
providers = providers.map(
|
|
@@ -452,16 +469,18 @@ function createProviderManager(config) {
|
|
|
452
469
|
logger.info("Model settings updated", { providerId, modelId, final: updatedModel });
|
|
453
470
|
return { success: true, model: updatedModel };
|
|
454
471
|
},
|
|
455
|
-
getModelSettings(modelId) {
|
|
472
|
+
getModelSettings(modelId, mode = "thinking") {
|
|
456
473
|
const provider = providers.find((p) => p.models.some((m) => m.id === modelId));
|
|
457
474
|
const model = provider?.models.find((m) => m.id === modelId);
|
|
458
475
|
if (!model) return void 0;
|
|
476
|
+
const kwargs = mode === "non-thinking" ? model.nonThinkingEnabled ? model.nonThinkingExtraKwargs : model.thinkingExtraKwargs : model.thinkingEnabled ? model.thinkingExtraKwargs : model.nonThinkingExtraKwargs;
|
|
459
477
|
return {
|
|
460
478
|
...model.temperature !== void 0 && { temperature: model.temperature },
|
|
461
479
|
...model.topP !== void 0 && { topP: model.topP },
|
|
462
480
|
...model.topK !== void 0 && { topK: model.topK },
|
|
463
481
|
...model.maxTokens !== void 0 && { maxTokens: model.maxTokens },
|
|
464
|
-
...model.supportsVision !== void 0 && { supportsVision: model.supportsVision }
|
|
482
|
+
...model.supportsVision !== void 0 && { supportsVision: model.supportsVision },
|
|
483
|
+
...kwargs ? { chatTemplateKwargs: JSON.parse(kwargs) } : {}
|
|
465
484
|
};
|
|
466
485
|
},
|
|
467
486
|
async refreshProviderModels(providerId) {
|
|
@@ -511,7 +530,8 @@ function createProviderManager(config) {
|
|
|
511
530
|
|
|
512
531
|
export {
|
|
513
532
|
fetchAvailableModelsFromBackend,
|
|
533
|
+
fetchModelsWithContext,
|
|
514
534
|
parseDefaultModelSelection,
|
|
515
535
|
createProviderManager
|
|
516
536
|
};
|
|
517
|
-
//# sourceMappingURL=chunk-
|
|
537
|
+
//# sourceMappingURL=chunk-YLQGD5SE.js.map
|
package/dist/cli/dev.js
CHANGED
package/dist/cli/index.js
CHANGED
|
@@ -14,11 +14,11 @@ import {
|
|
|
14
14
|
setDefaultModelSelection,
|
|
15
15
|
trySmartDefaults,
|
|
16
16
|
updateProvider
|
|
17
|
-
} from "./chunk-
|
|
18
|
-
import "./chunk-UKTPL5ZG.js";
|
|
19
|
-
import "./chunk-VIIRNJDT.js";
|
|
20
|
-
import "./chunk-K44MW7JJ.js";
|
|
17
|
+
} from "./chunk-HZODNSSV.js";
|
|
21
18
|
import "./chunk-CQGTEGKL.js";
|
|
19
|
+
import "./chunk-SW7MQGY3.js";
|
|
20
|
+
import "./chunk-LXX2CPM5.js";
|
|
21
|
+
import "./chunk-K44MW7JJ.js";
|
|
22
22
|
export {
|
|
23
23
|
activateProvider,
|
|
24
24
|
addProvider,
|
|
@@ -36,4 +36,4 @@ export {
|
|
|
36
36
|
trySmartDefaults,
|
|
37
37
|
updateProvider
|
|
38
38
|
};
|
|
39
|
-
//# sourceMappingURL=config-
|
|
39
|
+
//# sourceMappingURL=config-FAT5XRFB.js.map
|
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
isStoredEvent,
|
|
40
40
|
isTurnEvent,
|
|
41
41
|
truncateSessionMessages
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-DHAKJSE7.js";
|
|
43
43
|
import {
|
|
44
44
|
buildContextMessagesFromEventHistory,
|
|
45
45
|
buildContextMessagesFromMessages,
|
|
@@ -116,4 +116,4 @@ export {
|
|
|
116
116
|
isTurnEvent,
|
|
117
117
|
truncateSessionMessages
|
|
118
118
|
};
|
|
119
|
-
//# sourceMappingURL=events-
|
|
119
|
+
//# sourceMappingURL=events-R7FRQEBE.js.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
injectWorkflowKickoffIfNeeded,
|
|
3
3
|
runAgentTurn,
|
|
4
4
|
runChatTurn
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-DBDMMSCM.js";
|
|
6
6
|
import {
|
|
7
7
|
TurnMetrics,
|
|
8
8
|
createChatDoneEvent,
|
|
@@ -10,21 +10,21 @@ import {
|
|
|
10
10
|
createMessageStartEvent,
|
|
11
11
|
createToolCallEvent,
|
|
12
12
|
createToolResultEvent
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-5RP2ZU2G.js";
|
|
14
14
|
import "./chunk-DL6ZILAF.js";
|
|
15
15
|
import "./chunk-PBGOZMVY.js";
|
|
16
16
|
import "./chunk-VRGRAQDG.js";
|
|
17
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-XAMAYRDA.js";
|
|
18
|
+
import "./chunk-DHAKJSE7.js";
|
|
18
19
|
import "./chunk-ITWVFGFV.js";
|
|
19
20
|
import "./chunk-7TTEGAO6.js";
|
|
20
21
|
import "./chunk-BJYPTN5S.js";
|
|
21
22
|
import "./chunk-RFNEDBVO.js";
|
|
22
|
-
import "./chunk-XAMAYRDA.js";
|
|
23
23
|
import "./chunk-FBGWG4N6.js";
|
|
24
24
|
import "./chunk-BVHFMAVN.js";
|
|
25
|
-
import "./chunk-VIIRNJDT.js";
|
|
26
|
-
import "./chunk-K44MW7JJ.js";
|
|
27
25
|
import "./chunk-CQGTEGKL.js";
|
|
26
|
+
import "./chunk-LXX2CPM5.js";
|
|
27
|
+
import "./chunk-K44MW7JJ.js";
|
|
28
28
|
export {
|
|
29
29
|
TurnMetrics,
|
|
30
30
|
createChatDoneEvent,
|
|
@@ -36,4 +36,4 @@ export {
|
|
|
36
36
|
runAgentTurn,
|
|
37
37
|
runChatTurn
|
|
38
38
|
};
|
|
39
|
-
//# sourceMappingURL=orchestrator-
|
|
39
|
+
//# sourceMappingURL=orchestrator-NNYZC7AY.js.map
|