openfox 2.0.134 → 2.0.136
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/CHANGELOG.md +45 -0
- package/dist/CHANGELOG.md +45 -0
- package/dist/agent-defaults/builder.agent.md +1 -0
- package/dist/agent-defaults/planner.agent.md +1 -0
- package/dist/{ask-UBIRH3SO.js → ask-46J5WYRL.js} +2 -2
- package/dist/{auto-config-5VSNLVNI.js → auto-config-2A7Y2WOK.js} +25 -6
- package/dist/{backend-NDBY3DAQ.js → backend-24FTDSHF.js} +4 -2
- package/dist/{chat-handler-YCZE2XEJ.js → chat-handler-SYU4HJMI.js} +30 -26
- package/dist/{chunk-CSYOWFPU.js → chunk-342BKOTE.js} +29 -5
- package/dist/{chunk-7QMWYNVF.js → chunk-4LLGI372.js} +2 -2
- package/dist/chunk-4SBVW4UH.js +24 -0
- package/dist/{chunk-FAQDLL2X.js → chunk-5YPHN5NC.js} +8 -8
- package/dist/{chunk-ZMK4VX7V.js → chunk-64YDOCQR.js} +53 -21
- package/dist/{chunk-UV6IH6HK.js → chunk-AKWJMMEJ.js} +15 -1
- package/dist/{chunk-ORCQ3EXQ.js → chunk-BHVR2YS5.js} +2 -2
- package/dist/{chunk-7HGBJFIJ.js → chunk-CPVEONNS.js} +12 -10
- package/dist/{chunk-QDARWVQ2.js → chunk-DG2YSWMC.js} +40 -6
- package/dist/{chunk-J5HOUEPE.js → chunk-EXLCFEML.js} +86 -1010
- package/dist/chunk-FSSUPWYO.js +336 -0
- package/dist/{chunk-5UQ4CKOA.js → chunk-G5GUQKLS.js} +27 -6
- package/dist/{chunk-M4J2L4VH.js → chunk-GP5BYQMF.js} +23 -23
- package/dist/{chunk-7ET46SNE.js → chunk-HEYU7FAY.js} +3 -3
- package/dist/{chunk-MRE4OYKI.js → chunk-MILEZY2J.js} +4 -4
- package/dist/{chunk-O3RCSKUH.js → chunk-MOYWDP73.js} +2 -2
- package/dist/{chunk-J3NMNYGM.js → chunk-N5JKVNLH.js} +2 -2
- package/dist/{chunk-YLVOU7T7.js → chunk-PQKLOLGC.js} +162 -6
- package/dist/{chunk-DWA4IE65.js → chunk-Q33DL67W.js} +2 -2
- package/dist/{chunk-OZWHRBDY.js → chunk-QBWJCO5K.js} +12 -29
- package/dist/{chunk-EUOWCVU6.js → chunk-QMU3ZY2C.js} +37 -341
- package/dist/{chunk-5IXCCMFU.js → chunk-QQQBNL7A.js} +350 -157
- package/dist/{chunk-CTWZPN7G.js → chunk-QUAEH3MP.js} +29 -1
- package/dist/{chunk-5UMXFLET.js → chunk-SAGDTQXD.js} +3 -3
- package/dist/chunk-U6FHHT2B.js +1155 -0
- package/dist/{chunk-YOPXAI2W.js → chunk-UL7776XB.js} +21 -21
- package/dist/{chunk-JURM3RPZ.js → chunk-V5AC2TV7.js} +8 -13
- package/dist/{chunk-BZND27IB.js → chunk-VA2TYWQR.js} +4 -4
- package/dist/{chunk-JE7LW7Y6.js → chunk-VIJVLLPT.js} +12 -3
- package/dist/{chunk-2AI7VYPN.js → chunk-VKMPR25F.js} +9 -3
- package/dist/chunk-VWBPQZLO.js +7 -0
- package/dist/{chunk-ZTBKMVV6.js → chunk-X4PVR6AW.js} +15 -2
- package/dist/chunk-XG3AUMPI.js +72 -0
- package/dist/{chunk-MEEUXRFL.js → chunk-XGG4XCKP.js} +2 -2
- package/dist/{chunk-QICVOQNX.js → chunk-YDPC4FLR.js} +17 -11
- package/dist/cli/dev.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/client-MVI3J7SN.js +18 -0
- package/dist/{client-pure-FLKP6PTI.js → client-pure-YZ4IGCU4.js} +4 -2
- package/dist/{compactor-PD6DQ4NY.js → compactor-LBK53WAK.js} +14 -12
- package/dist/describe-image-4XDLSKAB.js +30 -0
- package/dist/{dynamic-context-WKEXQCTK.js → dynamic-context-RDBNQPPA.js} +12 -10
- package/dist/{events-3WSNI7XC.js → events-YTYYT3PR.js} +6 -6
- package/dist/export-import-GHRCOQHF.js +137 -0
- package/dist/{folding-H7JTX6KI.js → folding-3MMOPS4W.js} +4 -4
- package/dist/{http-client-A445WYZU.js → http-client-C6UYWVWZ.js} +3 -3
- package/dist/launch-YZ46OEFP.js +58 -0
- package/dist/{manager-ZACEUL5P.js → manager-FSPRJCYT.js} +4 -4
- package/dist/{model-catalog-2PCKTYGW.js → model-catalog-Y5MA5OZP.js} +2 -2
- package/dist/{orchestrator-OT66EDXO.js → orchestrator-6QGQ55NT.js} +29 -25
- package/dist/package.json +1 -1
- package/dist/{path-security-5CFMMULR.js → path-security-EC4Z2ZZG.js} +8 -8
- package/dist/{platform-XPMZKAUB.js → platform-KPKYBU54.js} +3 -3
- package/dist/{processor-CHMHMMIE.js → processor-B2RV7MVC.js} +29 -25
- package/dist/{provider-JWUNG2TD.js → provider-SOC6Z25R.js} +10 -8
- package/dist/{provider-manager-2KKZ37XJ.js → provider-manager-Y53SVVQ3.js} +10 -8
- package/dist/{registry-BEIR7Y5G.js → registry-FMDMGIUB.js} +3 -3
- package/dist/{serve-HSDVY37K.js → serve-EWA5HXC7.js} +41 -32
- package/dist/server/index.d.ts +16 -0
- package/dist/server/index.js +34 -30
- package/dist/server-ZAPAB3FS.js +61 -0
- package/dist/{service-XIUNS5XV.js → service-NKLQH647.js} +12 -9
- package/dist/{session-overrides-Y5B4XQPU.js → session-overrides-ANQBKV74.js} +11 -7
- package/dist/{sessions-IGINPPBP.js → sessions-GLYACE5R.js} +6 -4
- package/dist/{settings-ZJPM6PQV.js → settings-WH6BVQCP.js} +4 -2
- package/dist/{tasks-3JJWJJ3X.js → tasks-GPM3JAE6.js} +14 -10
- package/dist/tool-adapter-ZY4FC4C4.js +9 -0
- package/dist/{tools-WWIWD3O7.js → tools-EJOABHVO.js} +27 -23
- package/dist/{update-Q6SH7UP2.js → update-IPHJMRQZ.js} +2 -2
- package/dist/web/assets/index-CfFwerN2.js +313 -0
- package/dist/web/assets/{index-Y300llHY.css → index-ChJjYovg.css} +1 -1
- package/dist/web/index.html +2 -2
- package/dist/web/sw.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-QTLYD2FF.js +0 -7
- package/dist/client-VVYOWXRR.js +0 -16
- package/dist/launch-FJ65HRV4.js +0 -54
- package/dist/server-3UVLECD5.js +0 -57
- package/dist/tool-adapter-FJAFLDZA.js +0 -8
- package/dist/web/assets/index-C48qmBAI.js +0 -313
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
// src/server/tools/types.ts
|
|
2
|
+
var OUTPUT_LIMITS = {
|
|
3
|
+
read_file: {
|
|
4
|
+
maxLines: 2e3,
|
|
5
|
+
maxBytes: 1e5,
|
|
6
|
+
maxImageBytes: 2097152,
|
|
7
|
+
// 2MB for images
|
|
8
|
+
maxPdfPages: 50,
|
|
9
|
+
maxPdfImages: 20,
|
|
10
|
+
maxFileBytes: 20971520
|
|
11
|
+
// 20MB general file safety limit
|
|
12
|
+
},
|
|
13
|
+
run_command: {
|
|
14
|
+
maxLines: 2e3,
|
|
15
|
+
maxBytes: 5e4
|
|
16
|
+
},
|
|
17
|
+
glob: {
|
|
18
|
+
maxResults: 500
|
|
19
|
+
},
|
|
20
|
+
grep: {
|
|
21
|
+
maxMatches: 200
|
|
22
|
+
},
|
|
23
|
+
web_fetch: {
|
|
24
|
+
maxBytes: 1e5
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// src/server/tools/pdf-utils.ts
|
|
29
|
+
import { getDocument, OPS } from "pdfjs-dist/legacy/build/pdf.mjs";
|
|
30
|
+
import { PNG } from "pngjs";
|
|
31
|
+
var PDF_HEADER = Buffer.from("%PDF");
|
|
32
|
+
function isPdfBuffer(buffer) {
|
|
33
|
+
return buffer.length > 4 && buffer.subarray(0, 4).equals(PDF_HEADER);
|
|
34
|
+
}
|
|
35
|
+
function isPasswordError(err) {
|
|
36
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
37
|
+
return message.toLowerCase().includes("password") || message.toLowerCase().includes("encrypt");
|
|
38
|
+
}
|
|
39
|
+
function formatPdfErrorMessage(err) {
|
|
40
|
+
if (isPasswordError(err)) {
|
|
41
|
+
return "This PDF is password-protected. Unlock it with an external tool first.";
|
|
42
|
+
}
|
|
43
|
+
return `Failed to read PDF: ${err instanceof Error ? err.message : String(err)}`;
|
|
44
|
+
}
|
|
45
|
+
function processPdfContent(text, maxBytes) {
|
|
46
|
+
let output = text;
|
|
47
|
+
let truncated = false;
|
|
48
|
+
if (output.length > maxBytes) {
|
|
49
|
+
output = output.slice(0, maxBytes) + "\n\n[Output truncated due to size limit]";
|
|
50
|
+
truncated = true;
|
|
51
|
+
}
|
|
52
|
+
const isScanned = output.replace(/\[Page \d+\/\d+\]\n/g, "").trim().length === 0;
|
|
53
|
+
return { output, truncated, isScanned };
|
|
54
|
+
}
|
|
55
|
+
var IMAGE_KIND_GRAYSCALE_1BPP = 1;
|
|
56
|
+
var IMAGE_KIND_RGB_24BPP = 2;
|
|
57
|
+
var IMAGE_KIND_RGBA_32BPP = 3;
|
|
58
|
+
function getRgbaPixel(data, width, x, y, kind) {
|
|
59
|
+
if (kind === IMAGE_KIND_RGBA_32BPP) {
|
|
60
|
+
const i = (y * width + x) * 4;
|
|
61
|
+
return [data[i] ?? 0, data[i + 1] ?? 0, data[i + 2] ?? 0, data[i + 3] ?? 255];
|
|
62
|
+
}
|
|
63
|
+
if (kind === IMAGE_KIND_RGB_24BPP) {
|
|
64
|
+
const i = (y * width + x) * 3;
|
|
65
|
+
return [data[i] ?? 0, data[i + 1] ?? 0, data[i + 2] ?? 0, 255];
|
|
66
|
+
}
|
|
67
|
+
if (kind === IMAGE_KIND_GRAYSCALE_1BPP) {
|
|
68
|
+
const bytesPerRow = Math.ceil(width / 8);
|
|
69
|
+
const byteIdx = y * bytesPerRow + Math.floor(x / 8);
|
|
70
|
+
const bitIdx = 7 - x % 8;
|
|
71
|
+
const val = (data[byteIdx] ?? 0) >> bitIdx & 1 ? 255 : 0;
|
|
72
|
+
return [val, val, val, 255];
|
|
73
|
+
}
|
|
74
|
+
return [0, 0, 0, 255];
|
|
75
|
+
}
|
|
76
|
+
function toRgbaBuffer(data, width, height, kind) {
|
|
77
|
+
const rgba = new Uint8Array(width * height * 4);
|
|
78
|
+
for (let y = 0; y < height; y++) {
|
|
79
|
+
for (let x = 0; x < width; x++) {
|
|
80
|
+
const [r, g, b, a] = getRgbaPixel(data, width, x, y, kind);
|
|
81
|
+
const i = (y * width + x) * 4;
|
|
82
|
+
rgba[i] = r;
|
|
83
|
+
rgba[i + 1] = g;
|
|
84
|
+
rgba[i + 2] = b;
|
|
85
|
+
rgba[i + 3] = a;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return rgba;
|
|
89
|
+
}
|
|
90
|
+
function extractBitmapToRawImageData(bitmap) {
|
|
91
|
+
const canvas = new globalThis.OffscreenCanvas(bitmap.width, bitmap.height);
|
|
92
|
+
const ctx = canvas.getContext("2d");
|
|
93
|
+
ctx.drawImage(bitmap, 0, 0);
|
|
94
|
+
const imageData = ctx.getImageData(0, 0, bitmap.width, bitmap.height);
|
|
95
|
+
return {
|
|
96
|
+
width: bitmap.width,
|
|
97
|
+
height: bitmap.height,
|
|
98
|
+
data: new Uint8Array(imageData.data.buffer),
|
|
99
|
+
kind: IMAGE_KIND_RGBA_32BPP
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function encodeImageToDataUrl(imgData, maxDimension = 1024) {
|
|
103
|
+
try {
|
|
104
|
+
let { width, height } = imgData;
|
|
105
|
+
let { data, kind } = imgData;
|
|
106
|
+
if (imgData.bitmap && !data) {
|
|
107
|
+
const converted = extractBitmapToRawImageData(imgData.bitmap);
|
|
108
|
+
data = converted.data;
|
|
109
|
+
kind = converted.kind;
|
|
110
|
+
}
|
|
111
|
+
if (!data) return null;
|
|
112
|
+
if (width * height * 4 > 20971520) return null;
|
|
113
|
+
if (maxDimension > 0 && (width > maxDimension || height > maxDimension)) {
|
|
114
|
+
const scale = maxDimension / Math.max(width, height);
|
|
115
|
+
const newWidth = Math.round(width * scale);
|
|
116
|
+
const newHeight = Math.round(height * scale);
|
|
117
|
+
const scaled = new Uint8Array(newWidth * newHeight * 4);
|
|
118
|
+
for (let y = 0; y < newHeight; y++) {
|
|
119
|
+
for (let x = 0; x < newWidth; x++) {
|
|
120
|
+
const srcX = Math.floor(x / scale);
|
|
121
|
+
const srcY = Math.floor(y / scale);
|
|
122
|
+
const dstI = (y * newWidth + x) * 4;
|
|
123
|
+
const [r, g, b, a] = getRgbaPixel(data, width, srcX, srcY, kind);
|
|
124
|
+
scaled[dstI] = r;
|
|
125
|
+
scaled[dstI + 1] = g;
|
|
126
|
+
scaled[dstI + 2] = b;
|
|
127
|
+
scaled[dstI + 3] = a;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
width = newWidth;
|
|
131
|
+
height = newHeight;
|
|
132
|
+
const png2 = new PNG({ width, height });
|
|
133
|
+
Buffer.from(scaled.buffer, scaled.byteOffset, scaled.byteLength).copy(png2.data);
|
|
134
|
+
const pngBuffer2 = PNG.sync.write(png2);
|
|
135
|
+
return `data:image/png;base64,${pngBuffer2.toString("base64")}`;
|
|
136
|
+
}
|
|
137
|
+
let rgba;
|
|
138
|
+
if (kind === IMAGE_KIND_RGBA_32BPP) {
|
|
139
|
+
rgba = Uint8Array.from(
|
|
140
|
+
data instanceof Uint8ClampedArray ? new Uint8Array(data.buffer, data.byteOffset, data.byteLength) : data
|
|
141
|
+
);
|
|
142
|
+
} else {
|
|
143
|
+
rgba = toRgbaBuffer(data, width, height, kind);
|
|
144
|
+
}
|
|
145
|
+
const png = new PNG({ width, height });
|
|
146
|
+
Buffer.from(rgba.buffer, rgba.byteOffset, rgba.byteLength).copy(png.data);
|
|
147
|
+
const pngBuffer = PNG.sync.write(png);
|
|
148
|
+
return `data:image/png;base64,${pngBuffer.toString("base64")}`;
|
|
149
|
+
} catch {
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
async function extractPageBlocks(page, pageIndex, pageCount, imageCounter, maxImages) {
|
|
154
|
+
const [textContent, opList] = await Promise.all([page.getTextContent(), page.getOperatorList()]);
|
|
155
|
+
const textItems = textContent.items.filter(
|
|
156
|
+
(item) => "str" in item
|
|
157
|
+
);
|
|
158
|
+
const textStr = textItems.map((t) => t.str).join(" ").trim();
|
|
159
|
+
const imageOpIndices = [];
|
|
160
|
+
for (let i = 0; i < opList.fnArray.length; i++) {
|
|
161
|
+
const op = opList.fnArray[i];
|
|
162
|
+
if (op === OPS.paintImageXObject || op === OPS.paintInlineImageXObject || op === OPS.paintImageMaskXObject || op === OPS.paintImageMaskXObjectGroup || op === OPS.paintImageXObjectRepeat || op === OPS.paintImageMaskXObjectRepeat || op === OPS.paintInlineImageXObjectGroup || op === OPS.paintSolidColorImageMask) {
|
|
163
|
+
imageOpIndices.push(i);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
const blocks = [];
|
|
167
|
+
if (textStr) {
|
|
168
|
+
blocks.push({ type: "text", content: `[Page ${pageIndex}/${pageCount}]
|
|
169
|
+
${textStr}` });
|
|
170
|
+
}
|
|
171
|
+
for (let imageOpIdx = 0; imageOpIdx < imageOpIndices.length; imageOpIdx++) {
|
|
172
|
+
if (imageCounter.count >= maxImages) {
|
|
173
|
+
imageCounter.limitReached = true;
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
const opIdx = imageOpIndices[imageOpIdx];
|
|
177
|
+
if (opIdx === void 0) break;
|
|
178
|
+
const imgBlock = await extractImageBlock(page, opList, opIdx);
|
|
179
|
+
if (imgBlock) {
|
|
180
|
+
blocks.push(imgBlock);
|
|
181
|
+
imageCounter.count++;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return blocks;
|
|
185
|
+
}
|
|
186
|
+
function isValidPixelData(data) {
|
|
187
|
+
return data instanceof Uint8Array || data instanceof Uint8ClampedArray;
|
|
188
|
+
}
|
|
189
|
+
var IMAGE_RESOLVE_TIMEOUT_MS = 5e3;
|
|
190
|
+
async function getObjectWithFallback(objs, objId) {
|
|
191
|
+
try {
|
|
192
|
+
return objs.get(objId);
|
|
193
|
+
} catch {
|
|
194
|
+
}
|
|
195
|
+
return new Promise((resolve, reject) => {
|
|
196
|
+
const timeoutId = setTimeout(() => reject(new Error("timeout")), IMAGE_RESOLVE_TIMEOUT_MS);
|
|
197
|
+
try {
|
|
198
|
+
;
|
|
199
|
+
objs.get(objId, (data) => {
|
|
200
|
+
clearTimeout(timeoutId);
|
|
201
|
+
resolve(data);
|
|
202
|
+
});
|
|
203
|
+
} catch (e) {
|
|
204
|
+
clearTimeout(timeoutId);
|
|
205
|
+
reject(e);
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
async function extractImageBlock(page, opList, opIdx) {
|
|
210
|
+
const args = opList.argsArray[opIdx];
|
|
211
|
+
const objId = Array.isArray(args) ? args[0] : void 0;
|
|
212
|
+
let imgData = null;
|
|
213
|
+
if (objId && typeof objId === "string") {
|
|
214
|
+
try {
|
|
215
|
+
const store = objId.startsWith("g_") ? page.commonObjs : page.objs;
|
|
216
|
+
const raw = await getObjectWithFallback(store, objId);
|
|
217
|
+
if (raw && typeof raw === "object" && "width" in raw && "height" in raw) {
|
|
218
|
+
const r = raw;
|
|
219
|
+
if (isValidPixelData(r["data"])) {
|
|
220
|
+
imgData = raw;
|
|
221
|
+
} else if (r["bitmap"] && !r["data"]) {
|
|
222
|
+
imgData = raw;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
} catch {
|
|
226
|
+
}
|
|
227
|
+
} else if (Array.isArray(args) && args[0] && typeof args[0] === "object" && "width" in args[0]) {
|
|
228
|
+
const inline = args[0];
|
|
229
|
+
if (isValidPixelData(inline["data"])) {
|
|
230
|
+
imgData = args[0];
|
|
231
|
+
} else if (inline["bitmap"] && !inline["data"]) {
|
|
232
|
+
imgData = args[0];
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
if (imgData) {
|
|
236
|
+
const dataUrl = encodeImageToDataUrl(imgData);
|
|
237
|
+
if (dataUrl) {
|
|
238
|
+
return { type: "image", dataUrl };
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return null;
|
|
242
|
+
}
|
|
243
|
+
async function extractPdfContent(buffer) {
|
|
244
|
+
const doc = await getDocument({ data: Uint8Array.from(buffer) }).promise;
|
|
245
|
+
const pageCount = doc.numPages;
|
|
246
|
+
const allBlocks = [];
|
|
247
|
+
const limitedPageCount = Math.min(pageCount, OUTPUT_LIMITS.read_file.maxPdfPages);
|
|
248
|
+
const maxImages = OUTPUT_LIMITS.read_file.maxPdfImages;
|
|
249
|
+
const imageCounter = { count: 0, limitReached: false };
|
|
250
|
+
let title = null;
|
|
251
|
+
let author = null;
|
|
252
|
+
try {
|
|
253
|
+
const rawMeta = await doc.getMetadata();
|
|
254
|
+
const info = rawMeta.info;
|
|
255
|
+
title = info?.["Title"] || null;
|
|
256
|
+
author = info?.["Author"] || null;
|
|
257
|
+
} catch {
|
|
258
|
+
}
|
|
259
|
+
try {
|
|
260
|
+
for (let i = 1; i <= limitedPageCount; i++) {
|
|
261
|
+
const page = await doc.getPage(i);
|
|
262
|
+
try {
|
|
263
|
+
const blocks = await extractPageBlocks(page, i, pageCount, imageCounter, maxImages);
|
|
264
|
+
allBlocks.push(...blocks);
|
|
265
|
+
} finally {
|
|
266
|
+
page.cleanup();
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
} catch {
|
|
270
|
+
} finally {
|
|
271
|
+
doc.cleanup();
|
|
272
|
+
}
|
|
273
|
+
if (pageCount > limitedPageCount) {
|
|
274
|
+
allBlocks.push({
|
|
275
|
+
type: "text",
|
|
276
|
+
content: `[PDF has ${pageCount} pages, showing first ${limitedPageCount}. Use a shell command to process more.]`
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
if (imageCounter.limitReached) {
|
|
280
|
+
allBlocks.push({
|
|
281
|
+
type: "text",
|
|
282
|
+
content: `[Image limit reached: showing first ${maxImages} images out of more in this document.]`
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
return {
|
|
286
|
+
blocks: allBlocks,
|
|
287
|
+
pageCount,
|
|
288
|
+
title,
|
|
289
|
+
author,
|
|
290
|
+
imageCount: imageCounter.count,
|
|
291
|
+
imageLimitReached: imageCounter.limitReached
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
async function extractPdfText(buffer) {
|
|
295
|
+
const result = await extractPdfContent(buffer);
|
|
296
|
+
const text = result.blocks.filter((b) => b.type === "text").map((b) => b.content ?? "").join("\n\n");
|
|
297
|
+
return { text, pageCount: result.pageCount, title: result.title, author: result.author };
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// src/server/utils/cache.ts
|
|
301
|
+
import { createHash } from "crypto";
|
|
302
|
+
function contentHash(data) {
|
|
303
|
+
return createHash("sha256").update(data).digest("hex").slice(0, 16);
|
|
304
|
+
}
|
|
305
|
+
function cacheSet(cache, key, value) {
|
|
306
|
+
const max = 50;
|
|
307
|
+
if (cache.size >= max) {
|
|
308
|
+
const first = cache.keys().next().value;
|
|
309
|
+
if (first !== void 0) cache.delete(first);
|
|
310
|
+
}
|
|
311
|
+
cache.set(key, value);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// src/server/utils/data-url.ts
|
|
315
|
+
function decodeDataUrl(data) {
|
|
316
|
+
const match = data.match(/^data:.*?;base64,(.+)$/);
|
|
317
|
+
if (!match?.[1]) return null;
|
|
318
|
+
try {
|
|
319
|
+
return Buffer.from(match[1], "base64");
|
|
320
|
+
} catch {
|
|
321
|
+
return null;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export {
|
|
326
|
+
OUTPUT_LIMITS,
|
|
327
|
+
isPdfBuffer,
|
|
328
|
+
formatPdfErrorMessage,
|
|
329
|
+
processPdfContent,
|
|
330
|
+
extractPdfContent,
|
|
331
|
+
extractPdfText,
|
|
332
|
+
contentHash,
|
|
333
|
+
cacheSet,
|
|
334
|
+
decodeDataUrl
|
|
335
|
+
};
|
|
336
|
+
//# sourceMappingURL=chunk-FSSUPWYO.js.map
|
|
@@ -4,14 +4,15 @@ import {
|
|
|
4
4
|
} from "./chunk-OA2FURC3.js";
|
|
5
5
|
import {
|
|
6
6
|
createLLMClient
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-64YDOCQR.js";
|
|
8
8
|
import {
|
|
9
9
|
getModelProfile
|
|
10
10
|
} from "./chunk-TS5WKTFB.js";
|
|
11
11
|
import {
|
|
12
12
|
detectBackendFromUrl,
|
|
13
|
+
detectProviderDefaultsFromUrl,
|
|
13
14
|
getBackendCapabilities
|
|
14
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-AKWJMMEJ.js";
|
|
15
16
|
import {
|
|
16
17
|
buildModelsUrl,
|
|
17
18
|
ensureVersionPrefix,
|
|
@@ -19,12 +20,15 @@ import {
|
|
|
19
20
|
} from "./chunk-HNCM3D7Y.js";
|
|
20
21
|
import {
|
|
21
22
|
resolveAttachmentsInMessages
|
|
22
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-QMU3ZY2C.js";
|
|
24
|
+
import {
|
|
25
|
+
sanitizeToolSchema
|
|
26
|
+
} from "./chunk-XG3AUMPI.js";
|
|
23
27
|
import {
|
|
24
28
|
getCatalogEntry,
|
|
25
29
|
resolveEffortForModel,
|
|
26
30
|
resolveModeModelId
|
|
27
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-VKMPR25F.js";
|
|
28
32
|
import {
|
|
29
33
|
logger
|
|
30
34
|
} from "./chunk-K44MW7JJ.js";
|
|
@@ -79,6 +83,15 @@ function createTransportLLMClient(provider, modelId, transport, reasoningEffort)
|
|
|
79
83
|
request: {
|
|
80
84
|
...request,
|
|
81
85
|
messages: await resolveAttachmentsInMessages(request.messages, supportsVision),
|
|
86
|
+
...request.tools ? {
|
|
87
|
+
tools: request.tools.map((t) => ({
|
|
88
|
+
...t,
|
|
89
|
+
function: {
|
|
90
|
+
...t.function,
|
|
91
|
+
parameters: sanitizeToolSchema(t.function.parameters)
|
|
92
|
+
}
|
|
93
|
+
}))
|
|
94
|
+
} : {},
|
|
82
95
|
...resolvedEffort && !send.suppressEffort ? { reasoningEffort: resolvedEffort } : {}
|
|
83
96
|
},
|
|
84
97
|
effort: resolvedEffort
|
|
@@ -265,6 +278,7 @@ function mergeModelsWithUserOverrides(backendModels, userModels, preserveMissing
|
|
|
265
278
|
const claimedByMergedModes = /* @__PURE__ */ new Set();
|
|
266
279
|
for (const userModel of userModels) {
|
|
267
280
|
if (!userModel.modes?.length) continue;
|
|
281
|
+
claimedByMergedModes.add(normalizeModelId(userModel.id));
|
|
268
282
|
for (const mode of userModel.modes) {
|
|
269
283
|
if (mode.apiModelId) claimedByMergedModes.add(normalizeModelId(mode.apiModelId));
|
|
270
284
|
}
|
|
@@ -449,6 +463,10 @@ function createProviderManager(config, options = {}) {
|
|
|
449
463
|
});
|
|
450
464
|
return effort ? { reasoningEffort: effort } : {};
|
|
451
465
|
}
|
|
466
|
+
function resolveThinkingField(provider) {
|
|
467
|
+
if (provider.thinkingField) return provider.thinkingField;
|
|
468
|
+
return detectProviderDefaultsFromUrl(provider.url)?.thinkingField;
|
|
469
|
+
}
|
|
452
470
|
function createConfigForProvider(provider, model, reasoningEffort) {
|
|
453
471
|
const modelThinking = resolveModelThinkingConfig(provider, model, reasoningEffort);
|
|
454
472
|
const configureModel = provider.models.find((m) => m.id === model);
|
|
@@ -458,6 +476,7 @@ function createProviderManager(config, options = {}) {
|
|
|
458
476
|
configureModel?.apiModelId,
|
|
459
477
|
model
|
|
460
478
|
);
|
|
479
|
+
const thinkingField = resolveThinkingField(provider);
|
|
461
480
|
return {
|
|
462
481
|
...config,
|
|
463
482
|
llm: {
|
|
@@ -466,7 +485,7 @@ function createProviderManager(config, options = {}) {
|
|
|
466
485
|
model: send.modelId,
|
|
467
486
|
backend: resolveBackend(provider),
|
|
468
487
|
...provider.apiKey && { apiKey: provider.apiKey },
|
|
469
|
-
...
|
|
488
|
+
...thinkingField ? { thinkingField } : {},
|
|
470
489
|
...provider.sendReasoningInMessages !== void 0 ? { sendReasoningInMessages: provider.sendReasoningInMessages } : {},
|
|
471
490
|
...modelThinking.reasoningEffort && !send.suppressEffort && { reasoningEffort: modelThinking.reasoningEffort }
|
|
472
491
|
}
|
|
@@ -767,7 +786,9 @@ function createProviderManager(config, options = {}) {
|
|
|
767
786
|
source: "user",
|
|
768
787
|
...existingModel?.name !== void 0 && { name: existingModel.name },
|
|
769
788
|
...existingModel?.apiModelId !== void 0 && { apiModelId: existingModel.apiModelId },
|
|
789
|
+
...existingModel?.requestBody !== void 0 && { requestBody: existingModel.requestBody },
|
|
770
790
|
...existingModel?.modes !== void 0 && { modes: existingModel.modes },
|
|
791
|
+
...existingModel?.selected !== void 0 && { selected: existingModel.selected },
|
|
771
792
|
...finalTemp !== void 0 && { temperature: finalTemp },
|
|
772
793
|
...finalTopP !== void 0 && { topP: finalTopP },
|
|
773
794
|
...finalTopK !== void 0 && { topK: finalTopK },
|
|
@@ -895,4 +916,4 @@ export {
|
|
|
895
916
|
parseDefaultModelSelection,
|
|
896
917
|
createProviderManager
|
|
897
918
|
};
|
|
898
|
-
//# sourceMappingURL=chunk-
|
|
919
|
+
//# sourceMappingURL=chunk-G5GUQKLS.js.map
|
|
@@ -2,55 +2,55 @@ import {
|
|
|
2
2
|
generateSessionNameForSession,
|
|
3
3
|
getSessionMessageCount,
|
|
4
4
|
needsNameGeneration
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-5YPHN5NC.js";
|
|
6
6
|
import {
|
|
7
7
|
launchWorkflowRun
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-CPVEONNS.js";
|
|
9
9
|
import {
|
|
10
10
|
runChatTurn
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-UL7776XB.js";
|
|
12
|
+
import {
|
|
13
|
+
applyDynamicContext,
|
|
14
|
+
computeSessionHash,
|
|
15
|
+
computeUnifiedDiff
|
|
16
|
+
} from "./chunk-YDPC4FLR.js";
|
|
12
17
|
import {
|
|
13
18
|
devServerManager
|
|
14
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-EXLCFEML.js";
|
|
15
20
|
import {
|
|
16
21
|
gitSpawnEnv
|
|
17
22
|
} from "./chunk-J7GAZGZT.js";
|
|
18
23
|
import {
|
|
19
24
|
serverT
|
|
20
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-4SBVW4UH.js";
|
|
21
26
|
import {
|
|
22
27
|
appendCompactionPrompt
|
|
23
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-VA2TYWQR.js";
|
|
24
29
|
import {
|
|
25
30
|
hasRecentLLMFailure,
|
|
26
31
|
interruptLLMRetryWait
|
|
27
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-HEYU7FAY.js";
|
|
28
33
|
import {
|
|
29
34
|
onProcessEvent
|
|
30
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-SAGDTQXD.js";
|
|
31
36
|
import {
|
|
32
37
|
killProcessTree
|
|
33
38
|
} from "./chunk-I72ACQ6R.js";
|
|
34
|
-
import {
|
|
35
|
-
applyDynamicContext,
|
|
36
|
-
computeSessionHash,
|
|
37
|
-
computeUnifiedDiff
|
|
38
|
-
} from "./chunk-QICVOQNX.js";
|
|
39
39
|
import {
|
|
40
40
|
getPendingQuestionsForSession,
|
|
41
41
|
provideAnswer
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-V5AC2TV7.js";
|
|
43
43
|
import {
|
|
44
44
|
combineEventsWithSnapshot,
|
|
45
45
|
getEventStore
|
|
46
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-342BKOTE.js";
|
|
47
47
|
import {
|
|
48
48
|
buildMessagesFromStoredEvents,
|
|
49
49
|
foldPendingConfirmations
|
|
50
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-XGG4XCKP.js";
|
|
51
51
|
import {
|
|
52
52
|
getRuntimeConfig
|
|
53
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-BHVR2YS5.js";
|
|
54
54
|
import {
|
|
55
55
|
createChatErrorMessage,
|
|
56
56
|
createChatMessageMessage,
|
|
@@ -68,10 +68,10 @@ import {
|
|
|
68
68
|
} from "./chunk-AATMPL7S.js";
|
|
69
69
|
import {
|
|
70
70
|
getPlatformShell
|
|
71
|
-
} from "./chunk-
|
|
71
|
+
} from "./chunk-MOYWDP73.js";
|
|
72
72
|
import {
|
|
73
73
|
getMaxVisibleItems
|
|
74
|
-
} from "./chunk-
|
|
74
|
+
} from "./chunk-QUAEH3MP.js";
|
|
75
75
|
import {
|
|
76
76
|
logger
|
|
77
77
|
} from "./chunk-K44MW7JJ.js";
|
|
@@ -1344,8 +1344,8 @@ async function handleClientMessage(ws, client, message, _getLLMClient, _getActiv
|
|
|
1344
1344
|
}
|
|
1345
1345
|
const session = sessionManager.requireSession(sessionId);
|
|
1346
1346
|
try {
|
|
1347
|
-
const { buildCachedPrompt, computePreviewToolDiff } = await import("./dynamic-context-
|
|
1348
|
-
const allAgents = await import("./registry-
|
|
1347
|
+
const { buildCachedPrompt, computePreviewToolDiff } = await import("./dynamic-context-RDBNQPPA.js");
|
|
1348
|
+
const allAgents = await import("./registry-FMDMGIUB.js");
|
|
1349
1349
|
const agentDef = allAgents.findAgentById(session.mode, await allAgents.loadAllAgentsDefault()) ?? allAgents.findAgentById("planner", await allAgents.loadAllAgentsDefault());
|
|
1350
1350
|
const modelName = session.providerModel ?? _providerManager?.getCurrentModel();
|
|
1351
1351
|
const {
|
|
@@ -1356,7 +1356,7 @@ async function handleClientMessage(ws, client, message, _getLLMClient, _getActiv
|
|
|
1356
1356
|
const oldCached = sessionManager.getCachedPrompt(sessionId);
|
|
1357
1357
|
const oldPrompt = oldCached?.systemPrompt;
|
|
1358
1358
|
const diff = oldPrompt ? computeUnifiedDiff(oldPrompt, newPrompt) : [];
|
|
1359
|
-
const { getToolRegistryForAgent } = await import("./tools-
|
|
1359
|
+
const { getToolRegistryForAgent } = await import("./tools-EJOABHVO.js");
|
|
1360
1360
|
const unfilteredTools = getToolRegistryForAgent(agentDef).definitions;
|
|
1361
1361
|
const toolDiff = computePreviewToolDiff(oldCached?.tools, unfilteredTools, newTools);
|
|
1362
1362
|
send({
|
|
@@ -1729,4 +1729,4 @@ export {
|
|
|
1729
1729
|
signalMcpReady,
|
|
1730
1730
|
createWebSocketServer
|
|
1731
1731
|
};
|
|
1732
|
-
//# sourceMappingURL=chunk-
|
|
1732
|
+
//# sourceMappingURL=chunk-GP5BYQMF.js.map
|
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
} from "./chunk-TS5WKTFB.js";
|
|
7
7
|
import {
|
|
8
8
|
getBackendCapabilities
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-AKWJMMEJ.js";
|
|
10
10
|
import {
|
|
11
11
|
buildModelParams
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-QMU3ZY2C.js";
|
|
13
13
|
import {
|
|
14
14
|
logger
|
|
15
15
|
} from "./chunk-K44MW7JJ.js";
|
|
@@ -518,4 +518,4 @@ export {
|
|
|
518
518
|
createChatDoneEvent,
|
|
519
519
|
consumeStreamGenerator
|
|
520
520
|
};
|
|
521
|
-
//# sourceMappingURL=chunk-
|
|
521
|
+
//# sourceMappingURL=chunk-HEYU7FAY.js.map
|
|
@@ -207,7 +207,7 @@ async function runCli(options) {
|
|
|
207
207
|
break;
|
|
208
208
|
}
|
|
209
209
|
case "provider": {
|
|
210
|
-
const { runProviderCommand } = await import("./provider-
|
|
210
|
+
const { runProviderCommand } = await import("./provider-SOC6Z25R.js");
|
|
211
211
|
const [, subcommand] = positionals;
|
|
212
212
|
await runProviderCommand(mode, subcommand);
|
|
213
213
|
break;
|
|
@@ -252,7 +252,7 @@ async function runCli(options) {
|
|
|
252
252
|
break;
|
|
253
253
|
}
|
|
254
254
|
case "update": {
|
|
255
|
-
const { runUpdate } = await import("./update-
|
|
255
|
+
const { runUpdate } = await import("./update-IPHJMRQZ.js");
|
|
256
256
|
const code = await runUpdate();
|
|
257
257
|
if (code !== 0) {
|
|
258
258
|
process.exit(code);
|
|
@@ -265,7 +265,7 @@ async function runCli(options) {
|
|
|
265
265
|
if (!configExists) {
|
|
266
266
|
await runNetworkSetup(mode);
|
|
267
267
|
}
|
|
268
|
-
const { runServe } = await import("./serve-
|
|
268
|
+
const { runServe } = await import("./serve-EWA5HXC7.js");
|
|
269
269
|
const serveOptions = { mode };
|
|
270
270
|
if (values.port) serveOptions.port = parseInt(values.port);
|
|
271
271
|
if (values["no-browser"] === true) serveOptions.openBrowser = false;
|
|
@@ -277,4 +277,4 @@ async function runCli(options) {
|
|
|
277
277
|
export {
|
|
278
278
|
runCli
|
|
279
279
|
};
|
|
280
|
-
//# sourceMappingURL=chunk-
|
|
280
|
+
//# sourceMappingURL=chunk-MILEZY2J.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SETTINGS_KEYS,
|
|
3
3
|
getSetting
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-QUAEH3MP.js";
|
|
5
5
|
|
|
6
6
|
// src/server/utils/platform.ts
|
|
7
7
|
import os from "os";
|
|
@@ -63,4 +63,4 @@ export {
|
|
|
63
63
|
isWindowsPath,
|
|
64
64
|
isAbsolutePath
|
|
65
65
|
};
|
|
66
|
-
//# sourceMappingURL=chunk-
|
|
66
|
+
//# sourceMappingURL=chunk-MOYWDP73.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SETTINGS_KEYS,
|
|
3
3
|
getSetting
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-QUAEH3MP.js";
|
|
5
5
|
import {
|
|
6
6
|
logger
|
|
7
7
|
} from "./chunk-K44MW7JJ.js";
|
|
@@ -194,4 +194,4 @@ export {
|
|
|
194
194
|
ChatHttpClient,
|
|
195
195
|
OpenAIHttpClient
|
|
196
196
|
};
|
|
197
|
-
//# sourceMappingURL=chunk-
|
|
197
|
+
//# sourceMappingURL=chunk-N5JKVNLH.js.map
|