sparkecoder 0.1.67 → 0.1.68
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 +1 -1
- package/dist/agent/index.js +135 -13
- package/dist/agent/index.js.map +1 -1
- package/dist/cli.js +200 -48
- package/dist/cli.js.map +1 -1
- package/dist/{index-DHyVVhJY.d.ts → index-Dm6wGcYv.d.ts} +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +200 -48
- package/dist/index.js.map +1 -1
- package/dist/server/index.js +200 -48
- package/dist/server/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/.next/static/{static/tZkod5afiOX7T9AkN1yPO → 6Dlxqhgk8Mki7q7L-gDbl}/_buildManifest.js +0 -0
- /package/web/.next/standalone/web/.next/static/{static/tZkod5afiOX7T9AkN1yPO → 6Dlxqhgk8Mki7q7L-gDbl}/_clientMiddlewareManifest.json +0 -0
- /package/web/.next/standalone/web/.next/static/{static/tZkod5afiOX7T9AkN1yPO → 6Dlxqhgk8Mki7q7L-gDbl}/_ssgManifest.js +0 -0
- /package/web/.next/standalone/web/.next/static/{tZkod5afiOX7T9AkN1yPO → static/6Dlxqhgk8Mki7q7L-gDbl}/_buildManifest.js +0 -0
- /package/web/.next/standalone/web/.next/static/{tZkod5afiOX7T9AkN1yPO → static/6Dlxqhgk8Mki7q7L-gDbl}/_clientMiddlewareManifest.json +0 -0
- /package/web/.next/standalone/web/.next/static/{tZkod5afiOX7T9AkN1yPO → static/6Dlxqhgk8Mki7q7L-gDbl}/_ssgManifest.js +0 -0
- /package/web/.next/static/{tZkod5afiOX7T9AkN1yPO → 6Dlxqhgk8Mki7q7L-gDbl}/_buildManifest.js +0 -0
- /package/web/.next/static/{tZkod5afiOX7T9AkN1yPO → 6Dlxqhgk8Mki7q7L-gDbl}/_clientMiddlewareManifest.json +0 -0
- /package/web/.next/static/{tZkod5afiOX7T9AkN1yPO → 6Dlxqhgk8Mki7q7L-gDbl}/_ssgManifest.js +0 -0
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'ai';
|
|
2
2
|
import '../schema-XcP0dedO.js';
|
|
3
|
-
export { A as Agent, a as AgentOptions, b as AgentRunOptions, c as AgentStreamResult, C as ContextManager, M as MessageAttachment, d as buildSystemPrompt, e as buildTaskPromptAddendum } from '../index-
|
|
3
|
+
export { A as Agent, a as AgentOptions, b as AgentRunOptions, c as AgentStreamResult, C as ContextManager, M as MessageAttachment, d as buildSystemPrompt, e as buildTaskPromptAddendum } from '../index-Dm6wGcYv.js';
|
|
4
4
|
import '../search-CCffrVJE.js';
|
|
5
5
|
import 'drizzle-orm/sqlite-core';
|
|
6
6
|
import 'zod';
|
package/dist/agent/index.js
CHANGED
|
@@ -5922,6 +5922,21 @@ async function sendWebhook(url, event) {
|
|
|
5922
5922
|
}
|
|
5923
5923
|
|
|
5924
5924
|
// src/agent/index.ts
|
|
5925
|
+
var MAX_SSE_FIELD_LENGTH = 8 * 1024;
|
|
5926
|
+
var SSE_PREVIEW_LENGTH = 2 * 1024;
|
|
5927
|
+
function truncateWriteFileInput(input) {
|
|
5928
|
+
const out = { ...input };
|
|
5929
|
+
for (const key of ["content", "old_string", "new_string"]) {
|
|
5930
|
+
const val = out[key];
|
|
5931
|
+
if (typeof val === "string" && val.length > MAX_SSE_FIELD_LENGTH) {
|
|
5932
|
+
out[key] = `${val.slice(0, SSE_PREVIEW_LENGTH)}
|
|
5933
|
+
... (truncated)`;
|
|
5934
|
+
out[`${key}Truncated`] = true;
|
|
5935
|
+
out[`${key}Length`] = val.length;
|
|
5936
|
+
}
|
|
5937
|
+
}
|
|
5938
|
+
return out;
|
|
5939
|
+
}
|
|
5925
5940
|
var approvalResolvers = /* @__PURE__ */ new Map();
|
|
5926
5941
|
var Agent = class _Agent {
|
|
5927
5942
|
session;
|
|
@@ -6165,8 +6180,11 @@ ${prompt}` });
|
|
|
6165
6180
|
};
|
|
6166
6181
|
let taskRecorder = null;
|
|
6167
6182
|
const sessionId = this.session.id;
|
|
6183
|
+
const emit = options.writeSSE;
|
|
6168
6184
|
const bashProgressHandler = (progress) => {
|
|
6169
6185
|
options.onToolProgress?.({ toolName: "bash", data: progress });
|
|
6186
|
+
if (emit) emit(JSON.stringify({ type: "tool-progress", toolName: "bash", data: progress })).catch(() => {
|
|
6187
|
+
});
|
|
6170
6188
|
const port = progress.browserStreamPort;
|
|
6171
6189
|
if (port && progress.status === "started") {
|
|
6172
6190
|
Promise.resolve().then(() => (init_stream_proxy(), stream_proxy_exports)).then(({ getOrCreateProxy: getOrCreateProxy2 }) => {
|
|
@@ -6175,7 +6193,17 @@ ${prompt}` });
|
|
|
6175
6193
|
Promise.resolve().then(() => (init_recorder(), recorder_exports)).then(({ FrameRecorder: FrameRecorder2 }) => {
|
|
6176
6194
|
taskRecorder = new FrameRecorder2(sessionId);
|
|
6177
6195
|
taskRecorder.start();
|
|
6178
|
-
|
|
6196
|
+
});
|
|
6197
|
+
}
|
|
6198
|
+
if (proxy.listenerCount("frame") === 0) {
|
|
6199
|
+
proxy.on("frame", (frame) => {
|
|
6200
|
+
taskRecorder?.addFrame(frame);
|
|
6201
|
+
if (emit) emit(JSON.stringify({ type: "browser-frame", data: frame.data, metadata: frame.metadata })).catch(() => {
|
|
6202
|
+
});
|
|
6203
|
+
});
|
|
6204
|
+
proxy.on("status", (s) => {
|
|
6205
|
+
if (emit) emit(JSON.stringify({ type: "browser-status", ...s })).catch(() => {
|
|
6206
|
+
});
|
|
6179
6207
|
});
|
|
6180
6208
|
}
|
|
6181
6209
|
});
|
|
@@ -6186,8 +6214,16 @@ ${prompt}` });
|
|
|
6186
6214
|
workingDirectory: this.session.workingDirectory,
|
|
6187
6215
|
skillsDirectories: config.resolvedSkillsDirectories,
|
|
6188
6216
|
onBashProgress: bashProgressHandler,
|
|
6189
|
-
onWriteFileProgress:
|
|
6190
|
-
|
|
6217
|
+
onWriteFileProgress: (progress) => {
|
|
6218
|
+
options.onToolProgress?.({ toolName: "write_file", data: progress });
|
|
6219
|
+
if (emit) emit(JSON.stringify({ type: "tool-progress", toolName: "write_file", data: progress })).catch(() => {
|
|
6220
|
+
});
|
|
6221
|
+
},
|
|
6222
|
+
onSearchProgress: (progress) => {
|
|
6223
|
+
options.onToolProgress?.({ toolName: "explore_agent", data: progress });
|
|
6224
|
+
if (emit) emit(JSON.stringify({ type: "tool-progress", toolName: "explore_agent", data: progress })).catch(() => {
|
|
6225
|
+
});
|
|
6226
|
+
},
|
|
6191
6227
|
taskTools: {
|
|
6192
6228
|
outputSchema: options.taskConfig.outputSchema,
|
|
6193
6229
|
onComplete
|
|
@@ -6205,6 +6241,9 @@ ${prompt}` });
|
|
|
6205
6241
|
|
|
6206
6242
|
${taskAddendum}`;
|
|
6207
6243
|
fireWebhook("task.started", { prompt: options.prompt });
|
|
6244
|
+
if (emit) {
|
|
6245
|
+
await emit(JSON.stringify({ type: "data-user-message", data: { id: `user_${Date.now()}`, content: options.prompt } }));
|
|
6246
|
+
}
|
|
6208
6247
|
await this.context.addUserMessage(options.prompt);
|
|
6209
6248
|
let iteration = 0;
|
|
6210
6249
|
while (iteration < maxIterations) {
|
|
@@ -6216,7 +6255,15 @@ ${taskAddendum}`;
|
|
|
6216
6255
|
}
|
|
6217
6256
|
const messages = await this.context.getMessages();
|
|
6218
6257
|
const useAnthropic = isAnthropicModel(this.session.model);
|
|
6219
|
-
|
|
6258
|
+
if (emit) {
|
|
6259
|
+
await emit(JSON.stringify({ type: "start", messageId: `msg_${Date.now()}` }));
|
|
6260
|
+
}
|
|
6261
|
+
let textStarted = false;
|
|
6262
|
+
let textId = `text_${Date.now()}`;
|
|
6263
|
+
let reasoningId = `reasoning_${Date.now()}`;
|
|
6264
|
+
let reasoningStarted = false;
|
|
6265
|
+
const toolCallStarts = /* @__PURE__ */ new Set();
|
|
6266
|
+
const iterStream = streamText2({
|
|
6220
6267
|
model: resolveModel(this.session.model),
|
|
6221
6268
|
system: systemPrompt,
|
|
6222
6269
|
messages,
|
|
@@ -6225,21 +6272,94 @@ ${taskAddendum}`;
|
|
|
6225
6272
|
abortSignal: options.abortSignal,
|
|
6226
6273
|
providerOptions: useAnthropic ? {
|
|
6227
6274
|
anthropic: {
|
|
6275
|
+
toolStreaming: true,
|
|
6228
6276
|
thinking: { type: "enabled", budgetTokens: 1e4 }
|
|
6229
6277
|
}
|
|
6230
6278
|
} : void 0,
|
|
6231
|
-
onStepFinish: (step) => {
|
|
6279
|
+
onStepFinish: async (step) => {
|
|
6232
6280
|
options.onStepFinish?.(step);
|
|
6233
6281
|
fireWebhook("task.step_finished", { iteration, text: step.text });
|
|
6282
|
+
if (emit) {
|
|
6283
|
+
if (textStarted) {
|
|
6284
|
+
await emit(JSON.stringify({ type: "text-end", id: textId }));
|
|
6285
|
+
textStarted = false;
|
|
6286
|
+
textId = `text_${Date.now()}`;
|
|
6287
|
+
}
|
|
6288
|
+
await emit(JSON.stringify({ type: "finish-step" }));
|
|
6289
|
+
}
|
|
6234
6290
|
}
|
|
6235
6291
|
});
|
|
6236
|
-
const
|
|
6292
|
+
for await (const part of iterStream.fullStream) {
|
|
6293
|
+
if (part.type === "text-delta") {
|
|
6294
|
+
if (emit) {
|
|
6295
|
+
if (!textStarted) {
|
|
6296
|
+
await emit(JSON.stringify({ type: "text-start", id: textId }));
|
|
6297
|
+
textStarted = true;
|
|
6298
|
+
}
|
|
6299
|
+
await emit(JSON.stringify({ type: "text-delta", id: textId, delta: part.text }));
|
|
6300
|
+
}
|
|
6301
|
+
} else if (part.type === "reasoning-start") {
|
|
6302
|
+
if (emit) {
|
|
6303
|
+
await emit(JSON.stringify({ type: "reasoning-start", id: reasoningId }));
|
|
6304
|
+
reasoningStarted = true;
|
|
6305
|
+
}
|
|
6306
|
+
} else if (part.type === "reasoning-delta") {
|
|
6307
|
+
if (emit) {
|
|
6308
|
+
await emit(JSON.stringify({ type: "reasoning-delta", id: reasoningId, delta: part.text }));
|
|
6309
|
+
}
|
|
6310
|
+
} else if (part.type === "reasoning-end") {
|
|
6311
|
+
if (emit && reasoningStarted) {
|
|
6312
|
+
await emit(JSON.stringify({ type: "reasoning-end", id: reasoningId }));
|
|
6313
|
+
reasoningStarted = false;
|
|
6314
|
+
reasoningId = `reasoning_${Date.now()}`;
|
|
6315
|
+
}
|
|
6316
|
+
} else if (part.type === "tool-call-streaming-start") {
|
|
6317
|
+
if (emit) {
|
|
6318
|
+
const p = part;
|
|
6319
|
+
await emit(JSON.stringify({ type: "tool-input-start", toolCallId: p.toolCallId, toolName: p.toolName }));
|
|
6320
|
+
toolCallStarts.add(p.toolCallId);
|
|
6321
|
+
}
|
|
6322
|
+
} else if (part.type === "tool-call-delta") {
|
|
6323
|
+
if (emit) {
|
|
6324
|
+
const p = part;
|
|
6325
|
+
await emit(JSON.stringify({ type: "tool-input-delta", toolCallId: p.toolCallId, argsTextDelta: p.argsTextDelta }));
|
|
6326
|
+
}
|
|
6327
|
+
} else if (part.type === "tool-call") {
|
|
6328
|
+
if (emit) {
|
|
6329
|
+
if (!toolCallStarts.has(part.toolCallId)) {
|
|
6330
|
+
await emit(JSON.stringify({ type: "tool-input-start", toolCallId: part.toolCallId, toolName: part.toolName }));
|
|
6331
|
+
toolCallStarts.add(part.toolCallId);
|
|
6332
|
+
}
|
|
6333
|
+
const safeInput = part.toolName === "write_file" && part.input && typeof part.input === "object" ? truncateWriteFileInput(part.input) : part.input;
|
|
6334
|
+
await emit(JSON.stringify({ type: "tool-input-available", toolCallId: part.toolCallId, toolName: part.toolName, input: safeInput }));
|
|
6335
|
+
}
|
|
6336
|
+
} else if (part.type === "tool-result") {
|
|
6337
|
+
if (emit) {
|
|
6338
|
+
await emit(JSON.stringify({ type: "tool-output-available", toolCallId: part.toolCallId, output: part.output }));
|
|
6339
|
+
}
|
|
6340
|
+
} else if (part.type === "error") {
|
|
6341
|
+
console.error("Task stream error:", part.error);
|
|
6342
|
+
if (emit) {
|
|
6343
|
+
await emit(JSON.stringify({ type: "error", errorText: String(part.error) }));
|
|
6344
|
+
}
|
|
6345
|
+
}
|
|
6346
|
+
}
|
|
6347
|
+
if (emit && textStarted) {
|
|
6348
|
+
await emit(JSON.stringify({ type: "text-end", id: textId }));
|
|
6349
|
+
}
|
|
6350
|
+
if (emit && reasoningStarted) {
|
|
6351
|
+
await emit(JSON.stringify({ type: "reasoning-end", id: reasoningId }));
|
|
6352
|
+
}
|
|
6353
|
+
const iterResponse = await iterStream.response;
|
|
6354
|
+
const responseMessages = iterResponse.messages;
|
|
6237
6355
|
await this.context.addResponseMessages(responseMessages);
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
6356
|
+
const resultText = await iterStream.text;
|
|
6357
|
+
const resultSteps = await iterStream.steps;
|
|
6358
|
+
if (resultText) {
|
|
6359
|
+
options.onText?.(resultText);
|
|
6360
|
+
fireWebhook("task.message", { iteration, text: resultText });
|
|
6241
6361
|
}
|
|
6242
|
-
for (const step of
|
|
6362
|
+
for (const step of resultSteps) {
|
|
6243
6363
|
if (step.toolCalls) {
|
|
6244
6364
|
for (const tc of step.toolCalls) {
|
|
6245
6365
|
options.onToolCall?.({ toolCallId: tc.toolCallId, toolName: tc.toolName, input: tc.args });
|
|
@@ -6292,9 +6412,11 @@ ${taskAddendum}`;
|
|
|
6292
6412
|
iterations: iteration
|
|
6293
6413
|
};
|
|
6294
6414
|
}
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
|
|
6415
|
+
const continuationPrompt = "Continue working on the task. Before calling `complete_task`, VERIFY your work is correct \u2014 re-read edited files, run the linter, run tests if applicable, and check the browser/server if you made UI or API changes. Make sure you searched the right directories and found everything relevant. When fully verified, call `complete_task` with the result. If you cannot complete it, call `task_failed` with a reason.";
|
|
6416
|
+
if (emit) {
|
|
6417
|
+
await emit(JSON.stringify({ type: "data-user-message", data: { id: `user_${Date.now()}`, content: continuationPrompt } }));
|
|
6418
|
+
}
|
|
6419
|
+
await this.context.addUserMessage(continuationPrompt);
|
|
6298
6420
|
}
|
|
6299
6421
|
const timeoutError = `Task did not complete within ${maxIterations} iterations`;
|
|
6300
6422
|
const timeoutRecordingUrls = await this.finishTaskRecording(taskRecorder);
|