openfox 2.0.0-beta.5 → 2.0.0-beta.7
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-BM6EBFKS.js → chat-handler-XIAY7O5X.js} +14 -27
- package/dist/{chunk-NNEHZT3V.js → chunk-2ZS2B5HW.js} +11 -3
- package/dist/{chunk-HGAMIPFO.js → chunk-7FDY3EOH.js} +18 -176
- package/dist/{chunk-V6DYJV5R.js → chunk-7TTEGAO6.js} +12 -10
- package/dist/{chunk-T4HV6GS5.js → chunk-BVHFMAVN.js} +1 -1
- package/dist/{chunk-OBD6D5ZO.js → chunk-CDDMHSZF.js} +4 -4
- package/dist/{chunk-X36JIWSF.js → chunk-DFITQ75T.js} +135 -147
- package/dist/{chunk-HHAJ3QF6.js → chunk-EMJGF3A7.js} +9 -24
- package/dist/{chunk-RF2JGDSS.js → chunk-IGSZUXQP.js} +3 -3
- package/dist/{chunk-I67T2E5K.js → chunk-KAYUPVHQ.js} +6 -6
- package/dist/{chunk-CLGRPDZT.js → chunk-LN22TXNK.js} +196 -91
- package/dist/{chunk-UH27FDT7.js → chunk-NPHYEUYE.js} +124 -12
- package/dist/{chunk-DFWGWULB.js → chunk-QN5ST54E.js} +2935 -3127
- package/dist/{chunk-PSJIT5LZ.js → chunk-RFNEDBVO.js} +4 -4
- package/dist/chunk-RI6GAMNP.js +13 -0
- package/dist/{chunk-XL7SW5B4.js → chunk-XJEOP6XU.js} +5 -4
- package/dist/cli/dev.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/compactor-TDNRM3A7.js +9 -0
- package/dist/{config-YU7NYZYG.js → config-QUT7YZQ7.js} +9 -8
- package/dist/{events-T37KTNCX.js → events-PQ3KTI5H.js} +8 -7
- package/dist/{folding-IIKWAGG2.js → folding-CXORTBAU.js} +2 -2
- package/dist/{orchestrator-JTUHXF7C.js → orchestrator-GAOENX5Q.js} +18 -22
- package/dist/package.json +1 -1
- package/dist/{processor-66YBBQ6B.js → processor-6VIYGURD.js} +8 -9
- package/dist/{protocol-CiYlonA5.d.ts → protocol-CDOV1pyc.d.ts} +11 -0
- package/dist/{protocol-ALBHLBBF.js → protocol-CN24IKQN.js} +3 -5
- package/dist/{provider-HTJEB3ON.js → provider-4T6BVPMD.js} +25 -10
- package/dist/{serve-EUEQ6ERI.js → serve-W3ETJJP3.js} +25 -26
- package/dist/server/index.d.ts +1 -6
- package/dist/server/index.js +15 -16
- package/dist/{settings-VRAOAPLA.js → settings-6XX56F3F.js} +2 -2
- package/dist/shared/index.d.ts +2 -2
- package/dist/shared/index.js +1 -1
- package/dist/{tools-56LACLKH.js → tools-SDXWIYSA.js} +11 -13
- package/dist/web/assets/index-Dm6t3VVB.js +299 -0
- package/dist/web/assets/{index-C5gaXnFj.css → index-aa3jRAZ9.css} +2 -2
- package/dist/web/index.html +2 -2
- package/dist/web/sw.js +1 -1
- package/dist/workflow-defaults/default.workflow.json +3 -3
- package/package.json +1 -1
- package/dist/auto-compaction-2ZAYDXGF.js +0 -27
- package/dist/chunk-CGZHLM3K.js +0 -70
- package/dist/chunk-SZKEGZIB.js +0 -140
- package/dist/runtime-config-NPSPMRDA.js +0 -9
- package/dist/vision-fallback-3MIZZ6NQ.js +0 -22
- package/dist/web/assets/index-DQ2Vv-Yl.js +0 -317
- /package/dist/web/{workbox-7fc22fbe.js → workbox-8c29f6e4.js} +0 -0
|
@@ -5,40 +5,38 @@ import {
|
|
|
5
5
|
generateSessionName,
|
|
6
6
|
getSessionMessageCount,
|
|
7
7
|
needsNameGenerationCheck
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-CDDMHSZF.js";
|
|
9
9
|
import {
|
|
10
10
|
runChatTurn
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-PSJIT5LZ.js";
|
|
14
|
-
import "./chunk-XAMAYRDA.js";
|
|
11
|
+
} from "./chunk-DFITQ75T.js";
|
|
12
|
+
import "./chunk-QN5ST54E.js";
|
|
15
13
|
import "./chunk-DL6ZILAF.js";
|
|
16
14
|
import "./chunk-PBGOZMVY.js";
|
|
17
15
|
import "./chunk-VRGRAQDG.js";
|
|
18
|
-
import "./chunk-HGAMIPFO.js";
|
|
19
16
|
import {
|
|
20
17
|
getEventStore
|
|
21
|
-
} from "./chunk-
|
|
22
|
-
import "./chunk-
|
|
23
|
-
import "./chunk-XL7SW5B4.js";
|
|
18
|
+
} from "./chunk-NPHYEUYE.js";
|
|
19
|
+
import "./chunk-XJEOP6XU.js";
|
|
24
20
|
import {
|
|
25
21
|
createChatMessageMessage,
|
|
26
22
|
createPhaseChangedMessage,
|
|
27
23
|
createSessionRunningMessage
|
|
28
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-7TTEGAO6.js";
|
|
29
25
|
import "./chunk-BJYPTN5S.js";
|
|
30
|
-
import "./chunk-
|
|
31
|
-
import "./chunk-
|
|
32
|
-
import "./chunk-
|
|
33
|
-
import "./chunk-
|
|
26
|
+
import "./chunk-RFNEDBVO.js";
|
|
27
|
+
import "./chunk-XAMAYRDA.js";
|
|
28
|
+
import "./chunk-FBGWG4N6.js";
|
|
29
|
+
import "./chunk-BVHFMAVN.js";
|
|
30
|
+
import "./chunk-7FDY3EOH.js";
|
|
34
31
|
import {
|
|
35
32
|
logger
|
|
36
33
|
} from "./chunk-K44MW7JJ.js";
|
|
34
|
+
import "./chunk-CQGTEGKL.js";
|
|
37
35
|
|
|
38
36
|
// src/server/session/chat-handler.ts
|
|
39
37
|
var activeAgents = /* @__PURE__ */ new Map();
|
|
40
38
|
async function startChatSession(sessionId, content, deps, options) {
|
|
41
|
-
const { sessionManager, llmClient,
|
|
39
|
+
const { sessionManager, llmClient, broadcastForSession } = deps;
|
|
42
40
|
const session = sessionManager.getSession(sessionId);
|
|
43
41
|
if (!session) {
|
|
44
42
|
throw new Error("Session not found");
|
|
@@ -60,17 +58,6 @@ async function startChatSession(sessionId, content, deps, options) {
|
|
|
60
58
|
sessionManager.setRunning(sessionId, true);
|
|
61
59
|
broadcastForSession(sessionId, createSessionRunningMessage(true));
|
|
62
60
|
try {
|
|
63
|
-
const { maybeAutoCompactContext } = await import("./auto-compaction-2ZAYDXGF.js");
|
|
64
|
-
await maybeAutoCompactContext({
|
|
65
|
-
sessionManager,
|
|
66
|
-
sessionId,
|
|
67
|
-
llmClient,
|
|
68
|
-
statsIdentity,
|
|
69
|
-
signal: controller.signal
|
|
70
|
-
});
|
|
71
|
-
if (controller.signal.aborted) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
61
|
const userMessage = sessionManager.addMessage(sessionId, {
|
|
75
62
|
role: "user",
|
|
76
63
|
content,
|
|
@@ -174,4 +161,4 @@ export {
|
|
|
174
161
|
startChatSession,
|
|
175
162
|
stopSessionExecution
|
|
176
163
|
};
|
|
177
|
-
//# sourceMappingURL=chat-handler-
|
|
164
|
+
//# sourceMappingURL=chat-handler-XIAY7O5X.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
detectModel
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-EMJGF3A7.js";
|
|
4
4
|
import {
|
|
5
5
|
detectBackend
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-7FDY3EOH.js";
|
|
7
7
|
import {
|
|
8
8
|
getGlobalConfigPath
|
|
9
9
|
} from "./chunk-CQGTEGKL.js";
|
|
@@ -71,6 +71,7 @@ var providerSchema = z.object({
|
|
|
71
71
|
models: z.array(modelConfigSchema).default([]),
|
|
72
72
|
isActive: z.boolean(),
|
|
73
73
|
createdAt: z.string(),
|
|
74
|
+
isLocal: z.boolean().optional(),
|
|
74
75
|
// Deprecated: model field kept for migration, will be removed after migration
|
|
75
76
|
model: z.string().optional(),
|
|
76
77
|
// Deprecated: maxContext kept for migration
|
|
@@ -323,6 +324,12 @@ function addProvider(config, provider) {
|
|
|
323
324
|
}
|
|
324
325
|
};
|
|
325
326
|
}
|
|
327
|
+
function updateProvider(config, providerId, updates) {
|
|
328
|
+
return {
|
|
329
|
+
...config,
|
|
330
|
+
providers: config.providers.map((p) => p.id === providerId ? { ...p, ...updates } : p)
|
|
331
|
+
};
|
|
332
|
+
}
|
|
326
333
|
function removeProvider(config, providerId) {
|
|
327
334
|
const currentProviders = config.providers ?? [];
|
|
328
335
|
const filtered = currentProviders.filter((p) => p.id !== providerId);
|
|
@@ -431,8 +438,9 @@ export {
|
|
|
431
438
|
getDefaultModel,
|
|
432
439
|
setDefaultModelSelection,
|
|
433
440
|
addProvider,
|
|
441
|
+
updateProvider,
|
|
434
442
|
removeProvider,
|
|
435
443
|
activateProvider,
|
|
436
444
|
mergeConfigs
|
|
437
445
|
};
|
|
438
|
-
//# sourceMappingURL=chunk-
|
|
446
|
+
//# sourceMappingURL=chunk-2ZS2B5HW.js.map
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
describeImageFromDataUrl
|
|
3
|
-
} from "./chunk-SZKEGZIB.js";
|
|
4
1
|
import {
|
|
5
2
|
logger
|
|
6
3
|
} from "./chunk-K44MW7JJ.js";
|
|
@@ -362,6 +359,9 @@ function getModelProfile(modelName) {
|
|
|
362
359
|
}
|
|
363
360
|
return DEFAULT_PROFILE;
|
|
364
361
|
}
|
|
362
|
+
function modelSupportsVision(modelName) {
|
|
363
|
+
return getModelProfile(modelName).supportsVision;
|
|
364
|
+
}
|
|
365
365
|
|
|
366
366
|
// src/server/llm/client-pure.ts
|
|
367
367
|
function buildModelParams(params) {
|
|
@@ -372,27 +372,16 @@ function buildModelParams(params) {
|
|
|
372
372
|
...params.maxTokens !== void 0 && { maxTokens: params.maxTokens }
|
|
373
373
|
};
|
|
374
374
|
}
|
|
375
|
-
function buildAttachmentContent(msgContent, attachments,
|
|
375
|
+
function buildAttachmentContent(msgContent, attachments, modelSupportsVision2) {
|
|
376
376
|
const content = [];
|
|
377
377
|
if (msgContent?.trim()) {
|
|
378
378
|
content.push({ type: "text", text: msgContent });
|
|
379
379
|
}
|
|
380
380
|
for (const attachment of attachments) {
|
|
381
|
-
content.push(convertAttachmentSync(attachment,
|
|
381
|
+
content.push(convertAttachmentSync(attachment, modelSupportsVision2));
|
|
382
382
|
}
|
|
383
383
|
return content;
|
|
384
384
|
}
|
|
385
|
-
async function convertMessagesWithOptions(messages, profile, visionFallbackEnabled, userVisionOverride, signal, onVisionFallbackStart, onVisionFallbackDone) {
|
|
386
|
-
const modelSupportsVision = userVisionOverride ?? profile.supportsVision ?? false;
|
|
387
|
-
const options = {
|
|
388
|
-
modelSupportsVision,
|
|
389
|
-
visionFallbackEnabled,
|
|
390
|
-
signal,
|
|
391
|
-
onVisionFallbackStart,
|
|
392
|
-
onVisionFallbackDone
|
|
393
|
-
};
|
|
394
|
-
return needsVisionFallback(messages, modelSupportsVision, visionFallbackEnabled) ? await convertMessagesWithFallback(messages, options) : convertMessages(messages, { modelSupportsVision, visionFallbackEnabled: false });
|
|
395
|
-
}
|
|
396
385
|
function convertToolCalls(toolCalls) {
|
|
397
386
|
return toolCalls.map((toolCall) => ({
|
|
398
387
|
id: toolCall.id,
|
|
@@ -416,8 +405,8 @@ function buildAssistantMessage(msg) {
|
|
|
416
405
|
}
|
|
417
406
|
return result;
|
|
418
407
|
}
|
|
419
|
-
function convertAttachmentSync(attachment,
|
|
420
|
-
if (
|
|
408
|
+
function convertAttachmentSync(attachment, modelSupportsVision2) {
|
|
409
|
+
if (modelSupportsVision2) {
|
|
421
410
|
return {
|
|
422
411
|
type: "image_url",
|
|
423
412
|
image_url: { url: attachment.data }
|
|
@@ -428,68 +417,14 @@ function convertAttachmentSync(attachment, modelSupportsVision) {
|
|
|
428
417
|
text: `[Image: ${attachment.filename || "image"}] (vision not supported, cannot describe)`
|
|
429
418
|
};
|
|
430
419
|
}
|
|
431
|
-
function
|
|
432
|
-
return {
|
|
433
|
-
data,
|
|
434
|
-
...filename !== void 0 && { filename },
|
|
435
|
-
...id !== void 0 && { id }
|
|
436
|
-
};
|
|
437
|
-
}
|
|
438
|
-
async function convertAttachmentWithFallback(attachment, options) {
|
|
439
|
-
logger.debug("[VisionFallback] convertAttachmentWithFallback called", {
|
|
440
|
-
filename: attachment.filename,
|
|
441
|
-
id: attachment.id,
|
|
442
|
-
hasCallbacks: !!options.onVisionFallbackStart
|
|
443
|
-
});
|
|
444
|
-
if (options.modelSupportsVision) {
|
|
445
|
-
logger.debug("[VisionFallback] Model supports vision - passing image directly");
|
|
446
|
-
return {
|
|
447
|
-
type: "image_url",
|
|
448
|
-
image_url: { url: attachment.data }
|
|
449
|
-
};
|
|
450
|
-
}
|
|
451
|
-
if (!options.visionFallbackEnabled) {
|
|
452
|
-
logger.debug("[VisionFallback] Fallback disabled - returning placeholder");
|
|
453
|
-
return {
|
|
454
|
-
type: "text",
|
|
455
|
-
text: `[Image: ${attachment.filename || "image"}] (vision not supported)`
|
|
456
|
-
};
|
|
457
|
-
}
|
|
458
|
-
const attachmentId = attachment.id ?? crypto.randomUUID();
|
|
459
|
-
const filename = attachment.filename;
|
|
460
|
-
logger.debug("[VisionFallback] Starting delegation for:", { attachmentId, filename });
|
|
461
|
-
options.onVisionFallbackStart?.(attachmentId, filename);
|
|
462
|
-
const context = filename ? `File: ${filename}` : void 0;
|
|
463
|
-
const description = await describeImageFromDataUrl(attachment.data, { context, signal: options.signal });
|
|
464
|
-
logger.debug("[VisionFallback] Delegation complete:", { attachmentId, descriptionLength: description.length });
|
|
465
|
-
options.onVisionFallbackDone?.(attachmentId, description);
|
|
466
|
-
return {
|
|
467
|
-
type: "text",
|
|
468
|
-
text: `[Image: ${attachment.filename || "image"}] ${description}`
|
|
469
|
-
};
|
|
470
|
-
}
|
|
471
|
-
async function buildAttachmentContentWithFallback(msgContent, attachments, options) {
|
|
472
|
-
const content = [];
|
|
473
|
-
if (msgContent?.trim()) {
|
|
474
|
-
content.push({ type: "text", text: msgContent });
|
|
475
|
-
}
|
|
476
|
-
for (const attachment of attachments) {
|
|
477
|
-
const convertedContent = await convertAttachmentWithFallback(
|
|
478
|
-
createAttachmentForConversion(attachment.data, attachment.filename, attachment.id),
|
|
479
|
-
options
|
|
480
|
-
);
|
|
481
|
-
content.push(convertedContent);
|
|
482
|
-
}
|
|
483
|
-
return content;
|
|
484
|
-
}
|
|
485
|
-
function convertMessages(messages, options) {
|
|
420
|
+
function convertMessages(messages, modelSupportsVision2) {
|
|
486
421
|
const filtered = messages.filter((msg) => {
|
|
487
422
|
return !(msg.role === "assistant" && !msg.content?.trim() && (!msg.toolCalls || msg.toolCalls.length === 0));
|
|
488
423
|
});
|
|
489
424
|
return filtered.map((msg) => {
|
|
490
425
|
if (msg.role === "tool") {
|
|
491
426
|
if (msg.attachments && msg.attachments.length > 0) {
|
|
492
|
-
const content = buildAttachmentContent(msg.content, msg.attachments,
|
|
427
|
+
const content = buildAttachmentContent(msg.content, msg.attachments, modelSupportsVision2);
|
|
493
428
|
return {
|
|
494
429
|
role: "tool",
|
|
495
430
|
content,
|
|
@@ -506,7 +441,7 @@ function convertMessages(messages, options) {
|
|
|
506
441
|
return buildAssistantMessage(msg);
|
|
507
442
|
}
|
|
508
443
|
if (msg.role === "user" && msg.attachments && msg.attachments.length > 0) {
|
|
509
|
-
const content = buildAttachmentContent(msg.content, msg.attachments,
|
|
444
|
+
const content = buildAttachmentContent(msg.content, msg.attachments, modelSupportsVision2);
|
|
510
445
|
return {
|
|
511
446
|
role: "user",
|
|
512
447
|
content
|
|
@@ -518,49 +453,6 @@ function convertMessages(messages, options) {
|
|
|
518
453
|
};
|
|
519
454
|
});
|
|
520
455
|
}
|
|
521
|
-
async function convertMessagesWithFallback(messages, options) {
|
|
522
|
-
logger.debug("[VisionFallback] convertMessagesWithFallback called", { messageCount: messages.length });
|
|
523
|
-
const filtered = messages.filter((msg) => {
|
|
524
|
-
return !(msg.role === "assistant" && !msg.content?.trim() && (!msg.toolCalls || msg.toolCalls.length === 0));
|
|
525
|
-
});
|
|
526
|
-
const converted = [];
|
|
527
|
-
for (const msg of filtered) {
|
|
528
|
-
if (msg.role === "tool") {
|
|
529
|
-
if (msg.attachments && msg.attachments.length > 0) {
|
|
530
|
-
const content = await buildAttachmentContentWithFallback(msg.content, msg.attachments, options);
|
|
531
|
-
converted.push({
|
|
532
|
-
role: "tool",
|
|
533
|
-
content,
|
|
534
|
-
tool_call_id: msg.toolCallId
|
|
535
|
-
});
|
|
536
|
-
} else {
|
|
537
|
-
converted.push({
|
|
538
|
-
role: "tool",
|
|
539
|
-
content: msg.content,
|
|
540
|
-
tool_call_id: msg.toolCallId
|
|
541
|
-
});
|
|
542
|
-
}
|
|
543
|
-
continue;
|
|
544
|
-
}
|
|
545
|
-
if (msg.role === "assistant") {
|
|
546
|
-
converted.push(buildAssistantMessage(msg));
|
|
547
|
-
continue;
|
|
548
|
-
}
|
|
549
|
-
if (msg.role === "user" && msg.attachments && msg.attachments.length > 0) {
|
|
550
|
-
const content = await buildAttachmentContentWithFallback(msg.content, msg.attachments, options);
|
|
551
|
-
converted.push({
|
|
552
|
-
role: "user",
|
|
553
|
-
content
|
|
554
|
-
});
|
|
555
|
-
continue;
|
|
556
|
-
}
|
|
557
|
-
converted.push({
|
|
558
|
-
role: msg.role,
|
|
559
|
-
content: msg.content
|
|
560
|
-
});
|
|
561
|
-
}
|
|
562
|
-
return converted;
|
|
563
|
-
}
|
|
564
456
|
function convertTools(tools) {
|
|
565
457
|
return tools.map((tool) => ({
|
|
566
458
|
type: "function",
|
|
@@ -571,30 +463,10 @@ function convertTools(tools) {
|
|
|
571
463
|
}
|
|
572
464
|
}));
|
|
573
465
|
}
|
|
574
|
-
function
|
|
575
|
-
const hasAttachments = messages.some(
|
|
576
|
-
(msg) => msg.attachments && msg.attachments.length > 0 || msg.role === "tool" && msg.attachments && msg.attachments.length > 0
|
|
577
|
-
);
|
|
578
|
-
const result = hasAttachments && !modelSupportsVision && visionFallbackEnabled;
|
|
579
|
-
logger.debug("[VisionFallback] needsVisionFallback check", {
|
|
580
|
-
hasAttachments,
|
|
581
|
-
modelSupportsVision,
|
|
582
|
-
visionFallbackEnabled,
|
|
583
|
-
result
|
|
584
|
-
});
|
|
585
|
-
return result;
|
|
586
|
-
}
|
|
587
|
-
async function buildChatCompletionCreateParams(model, request, profile, capabilities, disableThinking, visionFallbackEnabled, isStreaming, onVisionFallbackStart, onVisionFallbackDone) {
|
|
466
|
+
async function buildChatCompletionCreateParams(model, request, profile, capabilities, disableThinking, isStreaming) {
|
|
588
467
|
const userVisionOverride = request.modelSettings?.supportsVision;
|
|
589
|
-
const
|
|
590
|
-
|
|
591
|
-
profile,
|
|
592
|
-
visionFallbackEnabled,
|
|
593
|
-
userVisionOverride,
|
|
594
|
-
request.signal,
|
|
595
|
-
onVisionFallbackStart,
|
|
596
|
-
onVisionFallbackDone
|
|
597
|
-
);
|
|
468
|
+
const modelSupportsVision2 = userVisionOverride ?? profile.supportsVision ?? false;
|
|
469
|
+
const convertedMessages = convertMessages(request.messages, modelSupportsVision2);
|
|
598
470
|
const temperature = request.modelSettings?.temperature ?? request.temperature ?? profile.temperature;
|
|
599
471
|
const maxTokens = request.modelSettings?.maxTokens ?? request.maxTokens ?? profile.defaultMaxTokens;
|
|
600
472
|
const topP = request.modelSettings?.topP ?? profile.topP;
|
|
@@ -623,26 +495,14 @@ async function buildChatCompletionCreateParams(model, request, profile, capabili
|
|
|
623
495
|
return { params, modelParams };
|
|
624
496
|
}
|
|
625
497
|
async function buildCreateParamsFromInput(input, isStreaming) {
|
|
626
|
-
const {
|
|
627
|
-
model,
|
|
628
|
-
request,
|
|
629
|
-
profile,
|
|
630
|
-
capabilities,
|
|
631
|
-
disableThinking,
|
|
632
|
-
visionFallbackEnabled = false,
|
|
633
|
-
onVisionFallbackStart,
|
|
634
|
-
onVisionFallbackDone
|
|
635
|
-
} = input;
|
|
498
|
+
const { model, request, profile, capabilities, disableThinking } = input;
|
|
636
499
|
return buildChatCompletionCreateParams(
|
|
637
500
|
model,
|
|
638
501
|
request,
|
|
639
502
|
profile,
|
|
640
503
|
capabilities,
|
|
641
504
|
!!disableThinking,
|
|
642
|
-
|
|
643
|
-
isStreaming,
|
|
644
|
-
onVisionFallbackStart,
|
|
645
|
-
onVisionFallbackDone
|
|
505
|
+
isStreaming
|
|
646
506
|
);
|
|
647
507
|
}
|
|
648
508
|
var buildNonStreamingCreateParams = (input) => buildCreateParamsFromInput(input, false);
|
|
@@ -677,13 +537,7 @@ function extractThinking(content) {
|
|
|
677
537
|
}
|
|
678
538
|
|
|
679
539
|
// src/server/llm/streaming.ts
|
|
680
|
-
var XML_TOOL_PATTERNS = ["<tool_call>", "<function=", "</tool_call>", "<parameter="];
|
|
681
|
-
function hasXmlToolPattern(text) {
|
|
682
|
-
return XML_TOOL_PATTERNS.some((p) => text.includes(p));
|
|
683
|
-
}
|
|
684
540
|
async function* streamWithSegments(client, request) {
|
|
685
|
-
const xmlAbortController = new AbortController();
|
|
686
|
-
const combinedSignal = request.signal ? AbortSignal.any([request.signal, xmlAbortController.signal]) : xmlAbortController.signal;
|
|
687
541
|
let content = "";
|
|
688
542
|
let thinkingContent = "";
|
|
689
543
|
let response = null;
|
|
@@ -705,7 +559,7 @@ async function* streamWithSegments(client, request) {
|
|
|
705
559
|
currentThinkingSegment = "";
|
|
706
560
|
};
|
|
707
561
|
try {
|
|
708
|
-
for await (const event of client.stream(
|
|
562
|
+
for await (const event of client.stream(request)) {
|
|
709
563
|
switch (event.type) {
|
|
710
564
|
case "text_delta":
|
|
711
565
|
if (firstTokenTime === null) {
|
|
@@ -714,11 +568,6 @@ async function* streamWithSegments(client, request) {
|
|
|
714
568
|
flushThinking();
|
|
715
569
|
content += event.content;
|
|
716
570
|
currentTextSegment += event.content;
|
|
717
|
-
if (!request.disableXmlProtection && hasXmlToolPattern(content)) {
|
|
718
|
-
xmlAbortController.abort();
|
|
719
|
-
yield { type: "xml_tool_abort" };
|
|
720
|
-
return null;
|
|
721
|
-
}
|
|
722
571
|
yield { type: "text_delta", content: event.content };
|
|
723
572
|
break;
|
|
724
573
|
case "thinking_delta":
|
|
@@ -728,11 +577,6 @@ async function* streamWithSegments(client, request) {
|
|
|
728
577
|
flushText();
|
|
729
578
|
thinkingContent += event.content;
|
|
730
579
|
currentThinkingSegment += event.content;
|
|
731
|
-
if (!request.disableXmlProtection && hasXmlToolPattern(thinkingContent)) {
|
|
732
|
-
xmlAbortController.abort();
|
|
733
|
-
yield { type: "xml_tool_abort" };
|
|
734
|
-
return null;
|
|
735
|
-
}
|
|
736
580
|
yield { type: "thinking_delta", content: event.content };
|
|
737
581
|
break;
|
|
738
582
|
case "tool_call_delta":
|
|
@@ -756,9 +600,6 @@ async function* streamWithSegments(client, request) {
|
|
|
756
600
|
}
|
|
757
601
|
}
|
|
758
602
|
} catch (error) {
|
|
759
|
-
if (error instanceof Error && error.name === "AbortError") {
|
|
760
|
-
return null;
|
|
761
|
-
}
|
|
762
603
|
yield { type: "error", error: error instanceof Error ? error.message : "Unknown error" };
|
|
763
604
|
return null;
|
|
764
605
|
}
|
|
@@ -791,6 +632,7 @@ async function* streamWithSegments(client, request) {
|
|
|
791
632
|
|
|
792
633
|
export {
|
|
793
634
|
getModelProfile,
|
|
635
|
+
modelSupportsVision,
|
|
794
636
|
getBackendCapabilities,
|
|
795
637
|
detectBackend,
|
|
796
638
|
getBackendDisplayName,
|
|
@@ -801,4 +643,4 @@ export {
|
|
|
801
643
|
extractThinking,
|
|
802
644
|
streamWithSegments
|
|
803
645
|
};
|
|
804
|
-
//# sourceMappingURL=chunk-
|
|
646
|
+
//# sourceMappingURL=chunk-7FDY3EOH.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createServerMessage,
|
|
3
3
|
isClientMessage
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-BVHFMAVN.js";
|
|
5
5
|
|
|
6
6
|
// src/server/ws/protocol.ts
|
|
7
7
|
function enrichMessagesWithToolResults(messages) {
|
|
@@ -94,8 +94,14 @@ function createChatTodoMessage(todos) {
|
|
|
94
94
|
function createChatProgressMessage(message, phase) {
|
|
95
95
|
return createServerMessage("chat.progress", { message, ...phase ? { phase } : {} });
|
|
96
96
|
}
|
|
97
|
-
function createChatFormatRetryMessage(attempt, maxAttempts) {
|
|
98
|
-
return createServerMessage("chat.format_retry", {
|
|
97
|
+
function createChatFormatRetryMessage(attempt, maxAttempts, pattern, field, matchedContent) {
|
|
98
|
+
return createServerMessage("chat.format_retry", {
|
|
99
|
+
attempt,
|
|
100
|
+
maxAttempts,
|
|
101
|
+
...pattern !== void 0 ? { pattern } : {},
|
|
102
|
+
...field !== void 0 ? { field } : {},
|
|
103
|
+
...matchedContent !== void 0 ? { matchedContent } : {}
|
|
104
|
+
});
|
|
99
105
|
}
|
|
100
106
|
function createChatMessageMessage(message) {
|
|
101
107
|
return createServerMessage("chat.message", { message });
|
|
@@ -120,9 +126,6 @@ function createChatPathConfirmationMessage(callId, tool, paths, workdir, reason)
|
|
|
120
126
|
function createChatAskUserMessage(callId, question) {
|
|
121
127
|
return createServerMessage("chat.ask_user", { callId, question });
|
|
122
128
|
}
|
|
123
|
-
function createChatVisionFallbackMessage(payload) {
|
|
124
|
-
return createServerMessage("chat.vision_fallback", payload);
|
|
125
|
-
}
|
|
126
129
|
function createModeChangedMessage(mode, auto, reason) {
|
|
127
130
|
return createServerMessage("mode.changed", { mode, auto, ...reason ? { reason } : {} });
|
|
128
131
|
}
|
|
@@ -280,9 +283,9 @@ function storedEventToServerMessage(event) {
|
|
|
280
283
|
const data = event.data;
|
|
281
284
|
return createChatAskUserMessage(data.callId, data.question);
|
|
282
285
|
}
|
|
283
|
-
case "
|
|
286
|
+
case "pattern.retry": {
|
|
284
287
|
const data = event.data;
|
|
285
|
-
return createChatFormatRetryMessage(data.attempt, data.maxAttempts);
|
|
288
|
+
return createChatFormatRetryMessage(data.attempt, data.maxAttempts, data.pattern, data.field, data.matchedContent);
|
|
286
289
|
}
|
|
287
290
|
case "turn.snapshot":
|
|
288
291
|
case "context.compacted":
|
|
@@ -317,7 +320,6 @@ export {
|
|
|
317
320
|
createChatErrorMessage,
|
|
318
321
|
createChatPathConfirmationMessage,
|
|
319
322
|
createChatAskUserMessage,
|
|
320
|
-
createChatVisionFallbackMessage,
|
|
321
323
|
createModeChangedMessage,
|
|
322
324
|
createPhaseChangedMessage,
|
|
323
325
|
createCriteriaUpdatedMessage,
|
|
@@ -331,4 +333,4 @@ export {
|
|
|
331
333
|
createQueueStateMessage,
|
|
332
334
|
storedEventToServerMessage
|
|
333
335
|
};
|
|
334
|
-
//# sourceMappingURL=chunk-
|
|
336
|
+
//# sourceMappingURL=chunk-7TTEGAO6.js.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getEventStore,
|
|
3
3
|
updateSessionMetadata
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-NPHYEUYE.js";
|
|
5
5
|
import {
|
|
6
6
|
buildMessagesFromStoredEvents,
|
|
7
7
|
foldPendingConfirmations
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-XJEOP6XU.js";
|
|
9
9
|
import {
|
|
10
10
|
createContextStateMessage,
|
|
11
11
|
createSessionStateMessage
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-7TTEGAO6.js";
|
|
13
13
|
import {
|
|
14
14
|
logger
|
|
15
15
|
} from "./chunk-K44MW7JJ.js";
|
|
@@ -143,4 +143,4 @@ export {
|
|
|
143
143
|
needsNameGenerationCheck,
|
|
144
144
|
applyGeneratedSessionName
|
|
145
145
|
};
|
|
146
|
-
//# sourceMappingURL=chunk-
|
|
146
|
+
//# sourceMappingURL=chunk-CDDMHSZF.js.map
|