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/db/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as Checkpoint, F as FileBackup, M as ModelMessage, a as Message, S as Session, L as LoadedSkill, T as TodoItem, b as ToolExecution, A as ActiveStream, I as IndexStatusRecord, c as IndexedChunk, d as SubagentExecution, e as SubagentStep, f as Terminal } from '../schema-
|
|
2
|
-
export { N as NewActiveStream, g as NewCheckpoint, h as NewFileBackup, i as NewIndexStatusRecord, j as NewIndexedChunk, k as NewMessage, l as NewSession, m as NewSubagentExecution, n as NewTerminal, o as NewTodoItem, p as NewToolExecution, q as SessionConfig, r as TaskConfig, U as UserContentPart, s as UserFilePart, t as UserImagePart, u as UserModelMessage, v as UserTextPart } from '../schema-
|
|
1
|
+
import { C as Checkpoint, F as FileBackup, M as ModelMessage, a as Message, S as Session, L as LoadedSkill, T as TodoItem, b as ToolExecution, A as ActiveStream, I as IndexStatusRecord, c as IndexedChunk, d as SubagentExecution, e as SubagentStep, f as Terminal } from '../schema-XcP0dedO.js';
|
|
2
|
+
export { N as NewActiveStream, g as NewCheckpoint, h as NewFileBackup, i as NewIndexStatusRecord, j as NewIndexedChunk, k as NewMessage, l as NewSession, m as NewSubagentExecution, n as NewTerminal, o as NewTodoItem, p as NewToolExecution, q as SessionConfig, r as TaskConfig, U as UserContentPart, s as UserFilePart, t as UserImagePart, u as UserModelMessage, v as UserTextPart } from '../schema-XcP0dedO.js';
|
|
3
3
|
import 'drizzle-orm/sqlite-core';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ModelMessage, streamText } from 'ai';
|
|
2
|
-
import { S as Session, b as ToolExecution, r as TaskConfig } from './schema-
|
|
2
|
+
import { S as Session, b as ToolExecution, r as TaskConfig } from './schema-XcP0dedO.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { B as BashToolProgress, W as WriteFileProgress, S as SearchToolProgress } from './search-
|
|
4
|
+
import { B as BashToolProgress, W as WriteFileProgress, S as SearchToolProgress } from './search-CCffrVJE.js';
|
|
5
5
|
|
|
6
6
|
declare const ToolApprovalConfigSchema: z.ZodObject<{
|
|
7
7
|
bash: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
@@ -37,54 +37,54 @@ declare const SessionConfigSchema: z.ZodObject<{
|
|
|
37
37
|
error: z.ZodOptional<z.ZodString>;
|
|
38
38
|
iterations: z.ZodOptional<z.ZodNumber>;
|
|
39
39
|
}, "strip", z.ZodTypeAny, {
|
|
40
|
-
status: "
|
|
41
|
-
enabled: boolean;
|
|
40
|
+
status: "completed" | "failed" | "running";
|
|
42
41
|
outputSchema: Record<string, unknown>;
|
|
43
|
-
|
|
42
|
+
enabled: boolean;
|
|
43
|
+
error?: string | undefined;
|
|
44
44
|
maxIterations?: number | undefined;
|
|
45
|
+
webhookUrl?: string | undefined;
|
|
45
46
|
result?: unknown;
|
|
46
|
-
error?: string | undefined;
|
|
47
47
|
iterations?: number | undefined;
|
|
48
48
|
}, {
|
|
49
|
-
status: "
|
|
50
|
-
enabled: boolean;
|
|
49
|
+
status: "completed" | "failed" | "running";
|
|
51
50
|
outputSchema: Record<string, unknown>;
|
|
52
|
-
|
|
51
|
+
enabled: boolean;
|
|
52
|
+
error?: string | undefined;
|
|
53
53
|
maxIterations?: number | undefined;
|
|
54
|
+
webhookUrl?: string | undefined;
|
|
54
55
|
result?: unknown;
|
|
55
|
-
error?: string | undefined;
|
|
56
56
|
iterations?: number | undefined;
|
|
57
57
|
}>>;
|
|
58
58
|
}, "strip", z.ZodTypeAny, {
|
|
59
59
|
maxContextChars: number;
|
|
60
60
|
toolApprovals?: Record<string, boolean> | undefined;
|
|
61
61
|
approvalWebhook?: string | undefined;
|
|
62
|
-
skillsDirectory?: string | undefined;
|
|
63
62
|
task?: {
|
|
64
|
-
status: "
|
|
65
|
-
enabled: boolean;
|
|
63
|
+
status: "completed" | "failed" | "running";
|
|
66
64
|
outputSchema: Record<string, unknown>;
|
|
67
|
-
|
|
65
|
+
enabled: boolean;
|
|
66
|
+
error?: string | undefined;
|
|
68
67
|
maxIterations?: number | undefined;
|
|
68
|
+
webhookUrl?: string | undefined;
|
|
69
69
|
result?: unknown;
|
|
70
|
-
error?: string | undefined;
|
|
71
70
|
iterations?: number | undefined;
|
|
72
71
|
} | undefined;
|
|
72
|
+
skillsDirectory?: string | undefined;
|
|
73
73
|
}, {
|
|
74
74
|
toolApprovals?: Record<string, boolean> | undefined;
|
|
75
75
|
approvalWebhook?: string | undefined;
|
|
76
|
-
skillsDirectory?: string | undefined;
|
|
77
|
-
maxContextChars?: number | undefined;
|
|
78
76
|
task?: {
|
|
79
|
-
status: "
|
|
80
|
-
enabled: boolean;
|
|
77
|
+
status: "completed" | "failed" | "running";
|
|
81
78
|
outputSchema: Record<string, unknown>;
|
|
82
|
-
|
|
79
|
+
enabled: boolean;
|
|
80
|
+
error?: string | undefined;
|
|
83
81
|
maxIterations?: number | undefined;
|
|
82
|
+
webhookUrl?: string | undefined;
|
|
84
83
|
result?: unknown;
|
|
85
|
-
error?: string | undefined;
|
|
86
84
|
iterations?: number | undefined;
|
|
87
85
|
} | undefined;
|
|
86
|
+
skillsDirectory?: string | undefined;
|
|
87
|
+
maxContextChars?: number | undefined;
|
|
88
88
|
}>;
|
|
89
89
|
declare const SparkcoderConfigSchema: z.ZodObject<{
|
|
90
90
|
defaultModel: z.ZodDefault<z.ZodString>;
|
|
@@ -179,6 +179,7 @@ declare const SparkcoderConfigSchema: z.ZodObject<{
|
|
|
179
179
|
exclude?: string[] | undefined;
|
|
180
180
|
}>>;
|
|
181
181
|
}, "strip", z.ZodTypeAny, {
|
|
182
|
+
defaultModel: string;
|
|
182
183
|
toolApprovals: {
|
|
183
184
|
bash: boolean;
|
|
184
185
|
write_file: boolean;
|
|
@@ -186,7 +187,6 @@ declare const SparkcoderConfigSchema: z.ZodObject<{
|
|
|
186
187
|
load_skill: boolean;
|
|
187
188
|
todo: boolean;
|
|
188
189
|
};
|
|
189
|
-
defaultModel: string;
|
|
190
190
|
skills: {
|
|
191
191
|
directory: string;
|
|
192
192
|
additionalDirectories: string[];
|
|
@@ -202,8 +202,8 @@ declare const SparkcoderConfigSchema: z.ZodObject<{
|
|
|
202
202
|
publicUrl?: string | undefined;
|
|
203
203
|
};
|
|
204
204
|
databasePath: string;
|
|
205
|
-
approvalWebhook?: string | undefined;
|
|
206
205
|
workingDirectory?: string | undefined;
|
|
206
|
+
approvalWebhook?: string | undefined;
|
|
207
207
|
remoteServer?: {
|
|
208
208
|
url?: string | undefined;
|
|
209
209
|
authKey?: string | undefined;
|
|
@@ -217,6 +217,8 @@ declare const SparkcoderConfigSchema: z.ZodObject<{
|
|
|
217
217
|
namespace?: string | undefined;
|
|
218
218
|
} | undefined;
|
|
219
219
|
}, {
|
|
220
|
+
defaultModel?: string | undefined;
|
|
221
|
+
workingDirectory?: string | undefined;
|
|
220
222
|
toolApprovals?: {
|
|
221
223
|
bash?: boolean | undefined;
|
|
222
224
|
write_file?: boolean | undefined;
|
|
@@ -225,8 +227,6 @@ declare const SparkcoderConfigSchema: z.ZodObject<{
|
|
|
225
227
|
todo?: boolean | undefined;
|
|
226
228
|
} | undefined;
|
|
227
229
|
approvalWebhook?: string | undefined;
|
|
228
|
-
workingDirectory?: string | undefined;
|
|
229
|
-
defaultModel?: string | undefined;
|
|
230
230
|
skills?: {
|
|
231
231
|
directory?: string | undefined;
|
|
232
232
|
additionalDirectories?: string[] | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { R as ResolvedConfig } from './index-
|
|
2
|
-
export { A as Agent, a as AgentOptions, b as AgentRunOptions, c as AgentStreamResult, S as SparkcoderConfig, T as ToolApprovalConfig } from './index-
|
|
1
|
+
import { R as ResolvedConfig } from './index-DT1l57s0.js';
|
|
2
|
+
export { A as Agent, a as AgentOptions, b as AgentRunOptions, c as AgentStreamResult, S as SparkcoderConfig, T as ToolApprovalConfig } from './index-DT1l57s0.js';
|
|
3
3
|
export { ServerOptions, createApp, startServer, stopServer } from './server/index.js';
|
|
4
4
|
export { checkpointQueries, closeDatabase, fileBackupQueries, getDb, initDatabase, messageQueries, sessionQueries, skillQueries, todoQueries, toolExecutionQueries } from './db/index.js';
|
|
5
|
-
import { F as FileBackup, C as Checkpoint } from './schema-
|
|
6
|
-
export { a as Message, M as ModelMessage, S as Session, q as SessionConfig, f as Terminal, T as TodoItem, b as ToolExecution } from './schema-
|
|
5
|
+
import { F as FileBackup, C as Checkpoint } from './schema-XcP0dedO.js';
|
|
6
|
+
export { a as Message, M as ModelMessage, S as Session, q as SessionConfig, f as Terminal, T as TodoItem, b as ToolExecution } from './schema-XcP0dedO.js';
|
|
7
7
|
export { createLoadSkillTool, createReadFileTool, createTodoTool, createTools } from './tools/index.js';
|
|
8
|
-
export { c as createBashTool, a as createWriteFileTool } from './search-
|
|
8
|
+
export { c as createBashTool, a as createWriteFileTool } from './search-CCffrVJE.js';
|
|
9
9
|
import 'ai';
|
|
10
10
|
import 'zod';
|
|
11
11
|
import 'hono/types';
|
package/dist/index.js
CHANGED
|
@@ -2952,26 +2952,29 @@ function cacheKey(buffer) {
|
|
|
2952
2952
|
return createHash("sha256").update(buffer).digest("hex");
|
|
2953
2953
|
}
|
|
2954
2954
|
async function resizeImageIfNeeded(buffer, mediaType) {
|
|
2955
|
+
const inputMediaType = mediaType || "image/png";
|
|
2955
2956
|
let metadata;
|
|
2956
2957
|
try {
|
|
2957
2958
|
metadata = await sharp(buffer).metadata();
|
|
2958
2959
|
} catch {
|
|
2959
|
-
return buffer;
|
|
2960
|
+
return { buffer, mediaType: inputMediaType };
|
|
2960
2961
|
}
|
|
2961
2962
|
const { width, height } = metadata;
|
|
2962
|
-
if (!width || !height) return buffer;
|
|
2963
|
+
if (!width || !height) return { buffer, mediaType: inputMediaType };
|
|
2963
2964
|
const longEdge = Math.max(width, height);
|
|
2964
2965
|
const needsResize = longEdge > MAX_LONG_EDGE;
|
|
2965
2966
|
const needsShrink = buffer.length > MAX_FILE_BYTES;
|
|
2966
|
-
if (!needsResize && !needsShrink) return buffer;
|
|
2967
|
+
if (!needsResize && !needsShrink) return { buffer, mediaType: inputMediaType };
|
|
2967
2968
|
const key = cacheKey(buffer);
|
|
2968
2969
|
const cacheDir = getCacheDir();
|
|
2969
|
-
const isPng =
|
|
2970
|
-
const
|
|
2970
|
+
const isPng = inputMediaType.includes("png");
|
|
2971
|
+
const willConvertToJpeg = isPng && (needsShrink || buffer.length > 2 * 1024 * 1024);
|
|
2972
|
+
const outputMediaType = willConvertToJpeg || !isPng ? "image/jpeg" : "image/png";
|
|
2973
|
+
const ext = outputMediaType === "image/png" ? ".png" : ".jpg";
|
|
2971
2974
|
const cachePath = join3(cacheDir, key + ext);
|
|
2972
2975
|
if (existsSync3(cachePath)) {
|
|
2973
2976
|
console.log(`[image-resize] Cache hit for ${width}x${height} image`);
|
|
2974
|
-
return readFileSync2(cachePath);
|
|
2977
|
+
return { buffer: readFileSync2(cachePath), mediaType: outputMediaType };
|
|
2975
2978
|
}
|
|
2976
2979
|
let pipeline = sharp(buffer);
|
|
2977
2980
|
if (needsResize) {
|
|
@@ -2981,25 +2984,27 @@ async function resizeImageIfNeeded(buffer, mediaType) {
|
|
|
2981
2984
|
});
|
|
2982
2985
|
}
|
|
2983
2986
|
let result;
|
|
2984
|
-
if (
|
|
2987
|
+
if (willConvertToJpeg) {
|
|
2985
2988
|
result = await pipeline.jpeg({ quality: 85 }).toBuffer();
|
|
2986
2989
|
} else if (isPng) {
|
|
2987
2990
|
result = await pipeline.png().toBuffer();
|
|
2988
2991
|
} else {
|
|
2989
2992
|
result = await pipeline.jpeg({ quality: 85 }).toBuffer();
|
|
2990
2993
|
}
|
|
2994
|
+
let finalMediaType = outputMediaType;
|
|
2991
2995
|
if (result.length > MAX_FILE_BYTES) {
|
|
2992
2996
|
for (const quality of [70, 50, 30]) {
|
|
2993
2997
|
result = await sharp(buffer).resize(MAX_LONG_EDGE, MAX_LONG_EDGE, { fit: "inside", withoutEnlargement: true }).jpeg({ quality }).toBuffer();
|
|
2994
2998
|
if (result.length <= MAX_FILE_BYTES) break;
|
|
2995
2999
|
}
|
|
3000
|
+
finalMediaType = "image/jpeg";
|
|
2996
3001
|
}
|
|
2997
3002
|
writeFileSync2(cachePath, result);
|
|
2998
3003
|
const resultMeta = await sharp(result).metadata();
|
|
2999
3004
|
console.log(
|
|
3000
|
-
`[image-resize] ${width}x${height} -> ${resultMeta.width}x${resultMeta.height} (${(buffer.length / 1024).toFixed(0)}KB -> ${(result.length / 1024).toFixed(0)}KB)`
|
|
3005
|
+
`[image-resize] ${width}x${height} -> ${resultMeta.width}x${resultMeta.height} (${(buffer.length / 1024).toFixed(0)}KB -> ${(result.length / 1024).toFixed(0)}KB, ${finalMediaType})`
|
|
3001
3006
|
);
|
|
3002
|
-
return result;
|
|
3007
|
+
return { buffer: result, mediaType: finalMediaType };
|
|
3003
3008
|
}
|
|
3004
3009
|
|
|
3005
3010
|
// src/tools/read-file.ts
|
|
@@ -3066,15 +3071,15 @@ Use this to understand existing code, check file contents, view screenshots, or
|
|
|
3066
3071
|
};
|
|
3067
3072
|
}
|
|
3068
3073
|
const rawBuffer = await readFile2(absolutePath);
|
|
3069
|
-
const
|
|
3070
|
-
const
|
|
3071
|
-
const base64 = buffer.toString("base64");
|
|
3074
|
+
const originalMediaType = getImageMediaType(absolutePath);
|
|
3075
|
+
const resized = await resizeImageIfNeeded(rawBuffer, originalMediaType);
|
|
3076
|
+
const base64 = resized.buffer.toString("base64");
|
|
3072
3077
|
return {
|
|
3073
3078
|
success: true,
|
|
3074
3079
|
path: absolutePath,
|
|
3075
3080
|
relativePath: relative(options.workingDirectory, absolutePath),
|
|
3076
|
-
content: `[Image: ${relativePath} (${mediaType}, ${(stats.size / 1024).toFixed(1)}KB)]`,
|
|
3077
|
-
mediaType,
|
|
3081
|
+
content: `[Image: ${relativePath} (${resized.mediaType}, ${(stats.size / 1024).toFixed(1)}KB)]`,
|
|
3082
|
+
mediaType: resized.mediaType,
|
|
3078
3083
|
imageData: base64,
|
|
3079
3084
|
sizeBytes: stats.size
|
|
3080
3085
|
};
|
|
@@ -6836,6 +6841,13 @@ function truncateWriteFileInput(input) {
|
|
|
6836
6841
|
return out;
|
|
6837
6842
|
}
|
|
6838
6843
|
var approvalResolvers = /* @__PURE__ */ new Map();
|
|
6844
|
+
function stripDataUrlPrefix(data) {
|
|
6845
|
+
const commaIdx = data.indexOf(",");
|
|
6846
|
+
if (commaIdx !== -1 && data.startsWith("data:")) {
|
|
6847
|
+
return data.slice(commaIdx + 1);
|
|
6848
|
+
}
|
|
6849
|
+
return data;
|
|
6850
|
+
}
|
|
6839
6851
|
var Agent = class _Agent {
|
|
6840
6852
|
session;
|
|
6841
6853
|
context;
|
|
@@ -6936,8 +6948,7 @@ ${prompt}` });
|
|
|
6936
6948
|
if (attachment.type === "image") {
|
|
6937
6949
|
contentParts.push({
|
|
6938
6950
|
type: "image",
|
|
6939
|
-
image: attachment.data,
|
|
6940
|
-
// base64 data URL or raw base64
|
|
6951
|
+
image: stripDataUrlPrefix(attachment.data),
|
|
6941
6952
|
mediaType: attachment.mediaType,
|
|
6942
6953
|
filename: attachment.filename,
|
|
6943
6954
|
savedPath: attachment.savedPath
|
|
@@ -6945,7 +6956,7 @@ ${prompt}` });
|
|
|
6945
6956
|
} else {
|
|
6946
6957
|
contentParts.push({
|
|
6947
6958
|
type: "file",
|
|
6948
|
-
data: attachment.data,
|
|
6959
|
+
data: stripDataUrlPrefix(attachment.data),
|
|
6949
6960
|
mediaType: attachment.mediaType || "application/octet-stream",
|
|
6950
6961
|
filename: attachment.filename,
|
|
6951
6962
|
savedPath: attachment.savedPath
|
|
@@ -8634,14 +8645,22 @@ async function saveAttachmentToDisk(sessionId, attachment, index) {
|
|
|
8634
8645
|
}
|
|
8635
8646
|
let buffer = Buffer.from(base64Data, "base64");
|
|
8636
8647
|
if (attachment.type === "image") {
|
|
8637
|
-
|
|
8638
|
-
|
|
8639
|
-
attachment.
|
|
8648
|
+
const resized = await resizeImageIfNeeded(buffer, attachment.mediaType);
|
|
8649
|
+
buffer = resized.buffer;
|
|
8650
|
+
attachment.mediaType = resized.mediaType;
|
|
8651
|
+
attachment.data = buffer.toString("base64");
|
|
8640
8652
|
}
|
|
8641
8653
|
const filePath = join9(attachmentsDir, filename);
|
|
8642
8654
|
writeFileSync4(filePath, buffer);
|
|
8643
8655
|
return filePath;
|
|
8644
8656
|
}
|
|
8657
|
+
function stripDataUrlPrefix2(data) {
|
|
8658
|
+
const commaIdx = data.indexOf(",");
|
|
8659
|
+
if (commaIdx !== -1 && data.startsWith("data:")) {
|
|
8660
|
+
return data.slice(commaIdx + 1);
|
|
8661
|
+
}
|
|
8662
|
+
return data;
|
|
8663
|
+
}
|
|
8645
8664
|
function getExtensionFromMediaType(mediaType, type) {
|
|
8646
8665
|
if (!mediaType) {
|
|
8647
8666
|
return type === "image" ? ".png" : ".bin";
|
|
@@ -8733,7 +8752,7 @@ ${prompt}` });
|
|
|
8733
8752
|
if (attachment.type === "image") {
|
|
8734
8753
|
contentParts.push({
|
|
8735
8754
|
type: "image",
|
|
8736
|
-
image: attachment.data,
|
|
8755
|
+
image: stripDataUrlPrefix2(attachment.data),
|
|
8737
8756
|
mediaType: attachment.mediaType,
|
|
8738
8757
|
filename: attachment.filename,
|
|
8739
8758
|
savedPath: attachment.savedPath
|
|
@@ -8741,7 +8760,7 @@ ${prompt}` });
|
|
|
8741
8760
|
} else {
|
|
8742
8761
|
contentParts.push({
|
|
8743
8762
|
type: "file",
|
|
8744
|
-
data: attachment.data,
|
|
8763
|
+
data: stripDataUrlPrefix2(attachment.data),
|
|
8745
8764
|
mediaType: attachment.mediaType || "application/octet-stream",
|
|
8746
8765
|
filename: attachment.filename,
|
|
8747
8766
|
savedPath: attachment.savedPath
|
|
@@ -9028,8 +9047,7 @@ ${prompt}` });
|
|
|
9028
9047
|
if (attachment.type === "image") {
|
|
9029
9048
|
contentParts.push({
|
|
9030
9049
|
type: "image",
|
|
9031
|
-
image: attachment.data,
|
|
9032
|
-
// base64 data URL or raw base64
|
|
9050
|
+
image: stripDataUrlPrefix2(attachment.data),
|
|
9033
9051
|
mediaType: attachment.mediaType,
|
|
9034
9052
|
filename: attachment.filename,
|
|
9035
9053
|
savedPath: attachment.savedPath
|
|
@@ -9037,7 +9055,7 @@ ${prompt}` });
|
|
|
9037
9055
|
} else {
|
|
9038
9056
|
contentParts.push({
|
|
9039
9057
|
type: "file",
|
|
9040
|
-
data: attachment.data,
|
|
9058
|
+
data: stripDataUrlPrefix2(attachment.data),
|
|
9041
9059
|
mediaType: attachment.mediaType || "application/octet-stream",
|
|
9042
9060
|
filename: attachment.filename,
|
|
9043
9061
|
savedPath: attachment.savedPath
|