sparkecoder 0.1.73 → 0.1.75
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 +84 -10
- package/dist/agent/index.js.map +1 -1
- package/dist/cli.js +84 -10
- package/dist/cli.js.map +1 -1
- package/dist/db/index.d.ts +2 -2
- package/dist/{index-dbWF1hyW.d.ts → index-DRscBFFX.d.ts} +31 -25
- package/dist/index.d.ts +5 -5
- package/dist/index.js +84 -10
- package/dist/index.js.map +1 -1
- package/dist/{schema-XcP0dedO.d.ts → schema-C7Mm4Ykn.d.ts} +3 -3
- package/dist/{search-CCffrVJE.d.ts → search-CVVfuBPZ.d.ts} +4 -4
- package/dist/server/index.js +84 -10
- package/dist/server/index.js.map +1 -1
- package/dist/tools/index.d.ts +3 -3
- package/dist/tools/index.js +16 -6
- 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/.next/static/{2xYE9FvjZmf0tU0NF5Jvj → static/xfMAecV1v1MVUkZE1r3BT}/_buildManifest.js +0 -0
- /package/web/.next/standalone/web/.next/static/{2xYE9FvjZmf0tU0NF5Jvj → static/xfMAecV1v1MVUkZE1r3BT}/_clientMiddlewareManifest.json +0 -0
- /package/web/.next/standalone/web/.next/static/{2xYE9FvjZmf0tU0NF5Jvj → static/xfMAecV1v1MVUkZE1r3BT}/_ssgManifest.js +0 -0
- /package/web/.next/standalone/web/.next/static/{static/2xYE9FvjZmf0tU0NF5Jvj → xfMAecV1v1MVUkZE1r3BT}/_buildManifest.js +0 -0
- /package/web/.next/standalone/web/.next/static/{static/2xYE9FvjZmf0tU0NF5Jvj → xfMAecV1v1MVUkZE1r3BT}/_clientMiddlewareManifest.json +0 -0
- /package/web/.next/standalone/web/.next/static/{static/2xYE9FvjZmf0tU0NF5Jvj → xfMAecV1v1MVUkZE1r3BT}/_ssgManifest.js +0 -0
- /package/web/.next/static/{2xYE9FvjZmf0tU0NF5Jvj → xfMAecV1v1MVUkZE1r3BT}/_buildManifest.js +0 -0
- /package/web/.next/static/{2xYE9FvjZmf0tU0NF5Jvj → xfMAecV1v1MVUkZE1r3BT}/_clientMiddlewareManifest.json +0 -0
- /package/web/.next/static/{2xYE9FvjZmf0tU0NF5Jvj → xfMAecV1v1MVUkZE1r3BT}/_ssgManifest.js +0 -0
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'ai';
|
|
2
|
-
import '../schema-
|
|
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-
|
|
4
|
-
import '../search-
|
|
2
|
+
import '../schema-C7Mm4Ykn.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-DRscBFFX.js';
|
|
4
|
+
import '../search-CVVfuBPZ.js';
|
|
5
5
|
import 'drizzle-orm/sqlite-core';
|
|
6
6
|
import 'zod';
|
package/dist/agent/index.js
CHANGED
|
@@ -1794,9 +1794,8 @@ function createRemoteModel(modelId, config) {
|
|
|
1794
1794
|
});
|
|
1795
1795
|
if (!res.ok) {
|
|
1796
1796
|
const err = await res.json().catch(() => ({}));
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
);
|
|
1797
|
+
const detail = formatRemoteError(res.status, modelId, err);
|
|
1798
|
+
throw new Error(detail);
|
|
1800
1799
|
}
|
|
1801
1800
|
const result = await res.json();
|
|
1802
1801
|
return deserializeValue(result);
|
|
@@ -1813,9 +1812,8 @@ function createRemoteModel(modelId, config) {
|
|
|
1813
1812
|
});
|
|
1814
1813
|
if (!res.ok) {
|
|
1815
1814
|
const err = await res.json().catch(() => ({}));
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
);
|
|
1815
|
+
const detail = formatRemoteError(res.status, modelId, err);
|
|
1816
|
+
throw new Error(detail);
|
|
1819
1817
|
}
|
|
1820
1818
|
const reader = res.body.getReader();
|
|
1821
1819
|
const decoder = new TextDecoder();
|
|
@@ -1873,6 +1871,18 @@ function createRemoteModel(modelId, config) {
|
|
|
1873
1871
|
}
|
|
1874
1872
|
};
|
|
1875
1873
|
}
|
|
1874
|
+
function formatRemoteError(status, modelId, body) {
|
|
1875
|
+
const parts = [`Remote inference failed (${status}) for ${modelId}`];
|
|
1876
|
+
if (body.error) parts.push(body.error);
|
|
1877
|
+
if (body.details) {
|
|
1878
|
+
const d = body.details;
|
|
1879
|
+
if (d.type) parts.push(`type=${d.type}`);
|
|
1880
|
+
if (d.statusCode && d.statusCode !== status) parts.push(`upstream=${d.statusCode}`);
|
|
1881
|
+
if (d.cause) parts.push(`cause: ${d.cause}`);
|
|
1882
|
+
if (d.orderWarnings?.length) parts.push(`prompt issues: ${d.orderWarnings.join("; ")}`);
|
|
1883
|
+
}
|
|
1884
|
+
return parts.join(" \u2014 ");
|
|
1885
|
+
}
|
|
1876
1886
|
|
|
1877
1887
|
// src/agent/model.ts
|
|
1878
1888
|
init_config();
|
|
@@ -5927,6 +5937,7 @@ ${summaryContent}`
|
|
|
5927
5937
|
...messages
|
|
5928
5938
|
];
|
|
5929
5939
|
}
|
|
5940
|
+
messages = repairToolPairing(messages);
|
|
5930
5941
|
return messages;
|
|
5931
5942
|
}
|
|
5932
5943
|
// ---------------------------------------------------------------------------
|
|
@@ -5935,25 +5946,43 @@ ${summaryContent}`
|
|
|
5935
5946
|
/**
|
|
5936
5947
|
* Strip non-essential content from messages older than the most recent
|
|
5937
5948
|
* `recentCount`. Operates in-memory only — does not touch the DB.
|
|
5949
|
+
*
|
|
5950
|
+
* Tracks removed tool-call IDs so matching tool-results are also removed,
|
|
5951
|
+
* preventing orphaned tool_result blocks that providers reject.
|
|
5938
5952
|
*/
|
|
5939
5953
|
compactOlderMessages(messages, recentCount) {
|
|
5940
5954
|
if (messages.length <= recentCount) return messages;
|
|
5941
5955
|
const boundary = messages.length - recentCount;
|
|
5942
5956
|
const olderMessages = messages.slice(0, boundary);
|
|
5943
5957
|
const recentMessages = messages.slice(boundary);
|
|
5958
|
+
const removedToolCallIds = /* @__PURE__ */ new Set();
|
|
5944
5959
|
const compacted = [];
|
|
5945
5960
|
for (const msg of olderMessages) {
|
|
5946
|
-
const processed = this.compactMessage(msg);
|
|
5961
|
+
const processed = this.compactMessage(msg, removedToolCallIds);
|
|
5947
5962
|
if (processed) compacted.push(processed);
|
|
5948
5963
|
}
|
|
5964
|
+
if (removedToolCallIds.size > 0) {
|
|
5965
|
+
const cleaned = [];
|
|
5966
|
+
for (const msg of compacted) {
|
|
5967
|
+
const result = stripOrphanedToolResults(msg, removedToolCallIds);
|
|
5968
|
+
if (result) cleaned.push(result);
|
|
5969
|
+
}
|
|
5970
|
+
return [...cleaned, ...recentMessages];
|
|
5971
|
+
}
|
|
5949
5972
|
return [...compacted, ...recentMessages];
|
|
5950
5973
|
}
|
|
5951
|
-
compactMessage(msg) {
|
|
5974
|
+
compactMessage(msg, removedToolCallIds) {
|
|
5952
5975
|
if (!Array.isArray(msg.content)) return msg;
|
|
5953
5976
|
const parts = [];
|
|
5954
5977
|
for (const part of msg.content) {
|
|
5955
|
-
if (part.type === "tool-call" && part.toolName === "todo")
|
|
5956
|
-
|
|
5978
|
+
if (part.type === "tool-call" && part.toolName === "todo") {
|
|
5979
|
+
if (part.toolCallId) removedToolCallIds.add(part.toolCallId);
|
|
5980
|
+
continue;
|
|
5981
|
+
}
|
|
5982
|
+
if (part.type === "tool-result" && part.toolName === "todo") {
|
|
5983
|
+
if (part.toolCallId) removedToolCallIds.add(part.toolCallId);
|
|
5984
|
+
continue;
|
|
5985
|
+
}
|
|
5957
5986
|
if (part.type === "reasoning" || part.type === "thinking") continue;
|
|
5958
5987
|
if (part.type === "tool-result" && COMPACTABLE_TOOLS.has(part.toolName)) {
|
|
5959
5988
|
parts.push(this.trimToolResult(part));
|
|
@@ -6103,6 +6132,51 @@ ${summaryContent}`
|
|
|
6103
6132
|
this.summaries = [];
|
|
6104
6133
|
}
|
|
6105
6134
|
};
|
|
6135
|
+
function stripOrphanedToolResults(msg, removedIds) {
|
|
6136
|
+
if (!Array.isArray(msg.content)) return msg;
|
|
6137
|
+
const parts = msg.content.filter((part) => {
|
|
6138
|
+
if (part.type === "tool-result" && removedIds.has(part.toolCallId)) return false;
|
|
6139
|
+
if (part.type === "tool-call" && removedIds.has(part.toolCallId)) return false;
|
|
6140
|
+
return true;
|
|
6141
|
+
});
|
|
6142
|
+
if (parts.length === 0) return null;
|
|
6143
|
+
return { ...msg, content: parts };
|
|
6144
|
+
}
|
|
6145
|
+
function repairToolPairing(messages) {
|
|
6146
|
+
const toolCallIds = /* @__PURE__ */ new Set();
|
|
6147
|
+
const toolResultIds = /* @__PURE__ */ new Set();
|
|
6148
|
+
for (const msg of messages) {
|
|
6149
|
+
if (!Array.isArray(msg.content)) continue;
|
|
6150
|
+
for (const part of msg.content) {
|
|
6151
|
+
if (part.type === "tool-call" && part.toolCallId) toolCallIds.add(part.toolCallId);
|
|
6152
|
+
if (part.type === "tool-result" && part.toolCallId) toolResultIds.add(part.toolCallId);
|
|
6153
|
+
}
|
|
6154
|
+
}
|
|
6155
|
+
const orphanedCalls = new Set([...toolCallIds].filter((id) => !toolResultIds.has(id)));
|
|
6156
|
+
const orphanedResults = new Set([...toolResultIds].filter((id) => !toolCallIds.has(id)));
|
|
6157
|
+
if (orphanedCalls.size === 0 && orphanedResults.size === 0) return messages;
|
|
6158
|
+
if (orphanedCalls.size > 0) {
|
|
6159
|
+
console.warn(`[tool-repair] Removing ${orphanedCalls.size} orphaned tool-call(s) with no matching result`);
|
|
6160
|
+
}
|
|
6161
|
+
if (orphanedResults.size > 0) {
|
|
6162
|
+
console.warn(`[tool-repair] Removing ${orphanedResults.size} orphaned tool-result(s) with no matching call`);
|
|
6163
|
+
}
|
|
6164
|
+
const repaired = [];
|
|
6165
|
+
for (const msg of messages) {
|
|
6166
|
+
if (!Array.isArray(msg.content)) {
|
|
6167
|
+
repaired.push(msg);
|
|
6168
|
+
continue;
|
|
6169
|
+
}
|
|
6170
|
+
const parts = msg.content.filter((part) => {
|
|
6171
|
+
if (part.type === "tool-call" && orphanedCalls.has(part.toolCallId)) return false;
|
|
6172
|
+
if (part.type === "tool-result" && orphanedResults.has(part.toolCallId)) return false;
|
|
6173
|
+
return true;
|
|
6174
|
+
});
|
|
6175
|
+
if (parts.length === 0) continue;
|
|
6176
|
+
repaired.push({ ...msg, content: parts });
|
|
6177
|
+
}
|
|
6178
|
+
return repaired;
|
|
6179
|
+
}
|
|
6106
6180
|
|
|
6107
6181
|
// src/utils/webhook.ts
|
|
6108
6182
|
async function sendWebhook(url, event) {
|