sparkecoder 0.1.76 → 0.1.78
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/agent/index.d.ts +3 -3
- package/dist/agent/index.js +28 -17
- package/dist/agent/index.js.map +1 -1
- package/dist/cli.js +43 -25
- package/dist/cli.js.map +1 -1
- package/dist/db/index.d.ts +2 -2
- package/dist/{index-DRscBFFX.d.ts → index-DT1l57s0.d.ts} +25 -25
- package/dist/index.d.ts +5 -5
- package/dist/index.js +43 -25
- package/dist/index.js.map +1 -1
- package/dist/{schema-C7Mm4Ykn.d.ts → schema-XcP0dedO.d.ts} +3 -3
- package/dist/{search-CVVfuBPZ.d.ts → search-CCffrVJE.d.ts} +4 -4
- package/dist/server/index.js +43 -25
- package/dist/server/index.js.map +1 -1
- package/dist/tools/index.d.ts +3 -3
- package/dist/tools/index.js +19 -14
- package/dist/tools/index.js.map +1 -1
- package/package.json +1 -1
- package/web/.next/BUILD_ID +1 -1
- package/web/.next/standalone/web/.next/BUILD_ID +1 -1
- package/web/.next/standalone/web/.next/build-manifest.json +2 -2
- package/web/.next/standalone/web/.next/prerender-manifest.json +3 -3
- package/web/.next/standalone/web/.next/server/app/_global-error.html +2 -2
- package/web/.next/standalone/web/.next/server/app/_global-error.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/_not-found.html +1 -1
- package/web/.next/standalone/web/.next/server/app/_not-found.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/installation.html +2 -2
- package/web/.next/standalone/web/.next/server/app/docs/installation.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/installation.segments/_full.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/installation.segments/_head.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/installation.segments/_index.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/installation.segments/_tree.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/installation.segments/docs/installation/__PAGE__.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/installation.segments/docs/installation.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/installation.segments/docs.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/skills.html +2 -2
- package/web/.next/standalone/web/.next/server/app/docs/skills.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/skills.segments/_full.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/skills.segments/_head.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/skills.segments/_index.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/skills.segments/_tree.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/skills.segments/docs/skills/__PAGE__.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/skills.segments/docs/skills.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/skills.segments/docs.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/tools.html +2 -2
- package/web/.next/standalone/web/.next/server/app/docs/tools.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/tools.segments/_full.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/tools.segments/_head.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/tools.segments/_index.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/tools.segments/_tree.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/tools.segments/docs/tools/__PAGE__.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/tools.segments/docs/tools.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/tools.segments/docs.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs.html +2 -2
- package/web/.next/standalone/web/.next/server/app/docs.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs.segments/_full.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs.segments/_head.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs.segments/_index.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs.segments/_tree.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs.segments/docs/__PAGE__.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs.segments/docs.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/index.html +1 -1
- package/web/.next/standalone/web/.next/server/app/index.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/index.segments/!KG1haW4p/__PAGE__.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/index.segments/!KG1haW4p.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/index.segments/_full.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/pages/404.html +1 -1
- package/web/.next/standalone/web/.next/server/pages/500.html +2 -2
- package/web/.next/standalone/web/.next/server/server-reference-manifest.js +1 -1
- package/web/.next/standalone/web/.next/server/server-reference-manifest.json +1 -1
- package/web/.next/standalone/web/package-lock.json +3 -3
- /package/web/.next/standalone/web/.next/static/{nZpzcWd5nqIPZFd3PiefU → q5xKLVzzjdkOykOwVu4eK}/_buildManifest.js +0 -0
- /package/web/.next/standalone/web/.next/static/{nZpzcWd5nqIPZFd3PiefU → q5xKLVzzjdkOykOwVu4eK}/_clientMiddlewareManifest.json +0 -0
- /package/web/.next/standalone/web/.next/static/{nZpzcWd5nqIPZFd3PiefU → q5xKLVzzjdkOykOwVu4eK}/_ssgManifest.js +0 -0
- /package/web/.next/standalone/web/.next/static/static/{nZpzcWd5nqIPZFd3PiefU → q5xKLVzzjdkOykOwVu4eK}/_buildManifest.js +0 -0
- /package/web/.next/standalone/web/.next/static/static/{nZpzcWd5nqIPZFd3PiefU → q5xKLVzzjdkOykOwVu4eK}/_clientMiddlewareManifest.json +0 -0
- /package/web/.next/standalone/web/.next/static/static/{nZpzcWd5nqIPZFd3PiefU → q5xKLVzzjdkOykOwVu4eK}/_ssgManifest.js +0 -0
- /package/web/.next/static/{nZpzcWd5nqIPZFd3PiefU → q5xKLVzzjdkOykOwVu4eK}/_buildManifest.js +0 -0
- /package/web/.next/static/{nZpzcWd5nqIPZFd3PiefU → q5xKLVzzjdkOykOwVu4eK}/_clientMiddlewareManifest.json +0 -0
- /package/web/.next/static/{nZpzcWd5nqIPZFd3PiefU → q5xKLVzzjdkOykOwVu4eK}/_ssgManifest.js +0 -0
package/dist/cli.js
CHANGED
|
@@ -3735,26 +3735,29 @@ function cacheKey(buffer) {
|
|
|
3735
3735
|
return createHash("sha256").update(buffer).digest("hex");
|
|
3736
3736
|
}
|
|
3737
3737
|
async function resizeImageIfNeeded(buffer, mediaType) {
|
|
3738
|
+
const inputMediaType = mediaType || "image/png";
|
|
3738
3739
|
let metadata;
|
|
3739
3740
|
try {
|
|
3740
3741
|
metadata = await sharp(buffer).metadata();
|
|
3741
3742
|
} catch {
|
|
3742
|
-
return buffer;
|
|
3743
|
+
return { buffer, mediaType: inputMediaType };
|
|
3743
3744
|
}
|
|
3744
3745
|
const { width, height } = metadata;
|
|
3745
|
-
if (!width || !height) return buffer;
|
|
3746
|
+
if (!width || !height) return { buffer, mediaType: inputMediaType };
|
|
3746
3747
|
const longEdge = Math.max(width, height);
|
|
3747
3748
|
const needsResize = longEdge > MAX_LONG_EDGE;
|
|
3748
3749
|
const needsShrink = buffer.length > MAX_FILE_BYTES;
|
|
3749
|
-
if (!needsResize && !needsShrink) return buffer;
|
|
3750
|
+
if (!needsResize && !needsShrink) return { buffer, mediaType: inputMediaType };
|
|
3750
3751
|
const key = cacheKey(buffer);
|
|
3751
3752
|
const cacheDir = getCacheDir();
|
|
3752
|
-
const isPng =
|
|
3753
|
-
const
|
|
3753
|
+
const isPng = inputMediaType.includes("png");
|
|
3754
|
+
const willConvertToJpeg = isPng && (needsShrink || buffer.length > 2 * 1024 * 1024);
|
|
3755
|
+
const outputMediaType = willConvertToJpeg || !isPng ? "image/jpeg" : "image/png";
|
|
3756
|
+
const ext = outputMediaType === "image/png" ? ".png" : ".jpg";
|
|
3754
3757
|
const cachePath = join3(cacheDir, key + ext);
|
|
3755
3758
|
if (existsSync3(cachePath)) {
|
|
3756
3759
|
console.log(`[image-resize] Cache hit for ${width}x${height} image`);
|
|
3757
|
-
return readFileSync2(cachePath);
|
|
3760
|
+
return { buffer: readFileSync2(cachePath), mediaType: outputMediaType };
|
|
3758
3761
|
}
|
|
3759
3762
|
let pipeline = sharp(buffer);
|
|
3760
3763
|
if (needsResize) {
|
|
@@ -3764,25 +3767,27 @@ async function resizeImageIfNeeded(buffer, mediaType) {
|
|
|
3764
3767
|
});
|
|
3765
3768
|
}
|
|
3766
3769
|
let result;
|
|
3767
|
-
if (
|
|
3770
|
+
if (willConvertToJpeg) {
|
|
3768
3771
|
result = await pipeline.jpeg({ quality: 85 }).toBuffer();
|
|
3769
3772
|
} else if (isPng) {
|
|
3770
3773
|
result = await pipeline.png().toBuffer();
|
|
3771
3774
|
} else {
|
|
3772
3775
|
result = await pipeline.jpeg({ quality: 85 }).toBuffer();
|
|
3773
3776
|
}
|
|
3777
|
+
let finalMediaType = outputMediaType;
|
|
3774
3778
|
if (result.length > MAX_FILE_BYTES) {
|
|
3775
3779
|
for (const quality of [70, 50, 30]) {
|
|
3776
3780
|
result = await sharp(buffer).resize(MAX_LONG_EDGE, MAX_LONG_EDGE, { fit: "inside", withoutEnlargement: true }).jpeg({ quality }).toBuffer();
|
|
3777
3781
|
if (result.length <= MAX_FILE_BYTES) break;
|
|
3778
3782
|
}
|
|
3783
|
+
finalMediaType = "image/jpeg";
|
|
3779
3784
|
}
|
|
3780
3785
|
writeFileSync2(cachePath, result);
|
|
3781
3786
|
const resultMeta = await sharp(result).metadata();
|
|
3782
3787
|
console.log(
|
|
3783
|
-
`[image-resize] ${width}x${height} -> ${resultMeta.width}x${resultMeta.height} (${(buffer.length / 1024).toFixed(0)}KB -> ${(result.length / 1024).toFixed(0)}KB)`
|
|
3788
|
+
`[image-resize] ${width}x${height} -> ${resultMeta.width}x${resultMeta.height} (${(buffer.length / 1024).toFixed(0)}KB -> ${(result.length / 1024).toFixed(0)}KB, ${finalMediaType})`
|
|
3784
3789
|
);
|
|
3785
|
-
return result;
|
|
3790
|
+
return { buffer: result, mediaType: finalMediaType };
|
|
3786
3791
|
}
|
|
3787
3792
|
|
|
3788
3793
|
// src/tools/read-file.ts
|
|
@@ -3849,15 +3854,15 @@ Use this to understand existing code, check file contents, view screenshots, or
|
|
|
3849
3854
|
};
|
|
3850
3855
|
}
|
|
3851
3856
|
const rawBuffer = await readFile2(absolutePath);
|
|
3852
|
-
const
|
|
3853
|
-
const
|
|
3854
|
-
const base64 = buffer.toString("base64");
|
|
3857
|
+
const originalMediaType = getImageMediaType(absolutePath);
|
|
3858
|
+
const resized = await resizeImageIfNeeded(rawBuffer, originalMediaType);
|
|
3859
|
+
const base64 = resized.buffer.toString("base64");
|
|
3855
3860
|
return {
|
|
3856
3861
|
success: true,
|
|
3857
3862
|
path: absolutePath,
|
|
3858
3863
|
relativePath: relative(options.workingDirectory, absolutePath),
|
|
3859
|
-
content: `[Image: ${relativePath} (${mediaType}, ${(stats.size / 1024).toFixed(1)}KB)]`,
|
|
3860
|
-
mediaType,
|
|
3864
|
+
content: `[Image: ${relativePath} (${resized.mediaType}, ${(stats.size / 1024).toFixed(1)}KB)]`,
|
|
3865
|
+
mediaType: resized.mediaType,
|
|
3861
3866
|
imageData: base64,
|
|
3862
3867
|
sizeBytes: stats.size
|
|
3863
3868
|
};
|
|
@@ -7619,6 +7624,13 @@ function truncateWriteFileInput(input) {
|
|
|
7619
7624
|
return out;
|
|
7620
7625
|
}
|
|
7621
7626
|
var approvalResolvers = /* @__PURE__ */ new Map();
|
|
7627
|
+
function stripDataUrlPrefix(data) {
|
|
7628
|
+
const commaIdx = data.indexOf(",");
|
|
7629
|
+
if (commaIdx !== -1 && data.startsWith("data:")) {
|
|
7630
|
+
return data.slice(commaIdx + 1);
|
|
7631
|
+
}
|
|
7632
|
+
return data;
|
|
7633
|
+
}
|
|
7622
7634
|
var Agent = class _Agent {
|
|
7623
7635
|
session;
|
|
7624
7636
|
context;
|
|
@@ -7719,8 +7731,7 @@ ${prompt}` });
|
|
|
7719
7731
|
if (attachment.type === "image") {
|
|
7720
7732
|
contentParts.push({
|
|
7721
7733
|
type: "image",
|
|
7722
|
-
image: attachment.data,
|
|
7723
|
-
// base64 data URL or raw base64
|
|
7734
|
+
image: stripDataUrlPrefix(attachment.data),
|
|
7724
7735
|
mediaType: attachment.mediaType,
|
|
7725
7736
|
filename: attachment.filename,
|
|
7726
7737
|
savedPath: attachment.savedPath
|
|
@@ -7728,7 +7739,7 @@ ${prompt}` });
|
|
|
7728
7739
|
} else {
|
|
7729
7740
|
contentParts.push({
|
|
7730
7741
|
type: "file",
|
|
7731
|
-
data: attachment.data,
|
|
7742
|
+
data: stripDataUrlPrefix(attachment.data),
|
|
7732
7743
|
mediaType: attachment.mediaType || "application/octet-stream",
|
|
7733
7744
|
filename: attachment.filename,
|
|
7734
7745
|
savedPath: attachment.savedPath
|
|
@@ -9397,14 +9408,22 @@ async function saveAttachmentToDisk(sessionId, attachment, index) {
|
|
|
9397
9408
|
}
|
|
9398
9409
|
let buffer = Buffer.from(base64Data, "base64");
|
|
9399
9410
|
if (attachment.type === "image") {
|
|
9400
|
-
|
|
9401
|
-
|
|
9402
|
-
attachment.
|
|
9411
|
+
const resized = await resizeImageIfNeeded(buffer, attachment.mediaType);
|
|
9412
|
+
buffer = resized.buffer;
|
|
9413
|
+
attachment.mediaType = resized.mediaType;
|
|
9414
|
+
attachment.data = buffer.toString("base64");
|
|
9403
9415
|
}
|
|
9404
9416
|
const filePath = join9(attachmentsDir, filename);
|
|
9405
9417
|
writeFileSync4(filePath, buffer);
|
|
9406
9418
|
return filePath;
|
|
9407
9419
|
}
|
|
9420
|
+
function stripDataUrlPrefix2(data) {
|
|
9421
|
+
const commaIdx = data.indexOf(",");
|
|
9422
|
+
if (commaIdx !== -1 && data.startsWith("data:")) {
|
|
9423
|
+
return data.slice(commaIdx + 1);
|
|
9424
|
+
}
|
|
9425
|
+
return data;
|
|
9426
|
+
}
|
|
9408
9427
|
function getExtensionFromMediaType(mediaType, type) {
|
|
9409
9428
|
if (!mediaType) {
|
|
9410
9429
|
return type === "image" ? ".png" : ".bin";
|
|
@@ -9496,7 +9515,7 @@ ${prompt}` });
|
|
|
9496
9515
|
if (attachment.type === "image") {
|
|
9497
9516
|
contentParts.push({
|
|
9498
9517
|
type: "image",
|
|
9499
|
-
image: attachment.data,
|
|
9518
|
+
image: stripDataUrlPrefix2(attachment.data),
|
|
9500
9519
|
mediaType: attachment.mediaType,
|
|
9501
9520
|
filename: attachment.filename,
|
|
9502
9521
|
savedPath: attachment.savedPath
|
|
@@ -9504,7 +9523,7 @@ ${prompt}` });
|
|
|
9504
9523
|
} else {
|
|
9505
9524
|
contentParts.push({
|
|
9506
9525
|
type: "file",
|
|
9507
|
-
data: attachment.data,
|
|
9526
|
+
data: stripDataUrlPrefix2(attachment.data),
|
|
9508
9527
|
mediaType: attachment.mediaType || "application/octet-stream",
|
|
9509
9528
|
filename: attachment.filename,
|
|
9510
9529
|
savedPath: attachment.savedPath
|
|
@@ -9791,8 +9810,7 @@ ${prompt}` });
|
|
|
9791
9810
|
if (attachment.type === "image") {
|
|
9792
9811
|
contentParts.push({
|
|
9793
9812
|
type: "image",
|
|
9794
|
-
image: attachment.data,
|
|
9795
|
-
// base64 data URL or raw base64
|
|
9813
|
+
image: stripDataUrlPrefix2(attachment.data),
|
|
9796
9814
|
mediaType: attachment.mediaType,
|
|
9797
9815
|
filename: attachment.filename,
|
|
9798
9816
|
savedPath: attachment.savedPath
|
|
@@ -9800,7 +9818,7 @@ ${prompt}` });
|
|
|
9800
9818
|
} else {
|
|
9801
9819
|
contentParts.push({
|
|
9802
9820
|
type: "file",
|
|
9803
|
-
data: attachment.data,
|
|
9821
|
+
data: stripDataUrlPrefix2(attachment.data),
|
|
9804
9822
|
mediaType: attachment.mediaType || "application/octet-stream",
|
|
9805
9823
|
filename: attachment.filename,
|
|
9806
9824
|
savedPath: attachment.savedPath
|