0agent 1.0.81 → 1.0.83
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/daemon.mjs +31 -13
- package/package.json +1 -1
package/dist/daemon.mjs
CHANGED
|
@@ -2135,6 +2135,8 @@ var init_LLMExecutor = __esm({
|
|
|
2135
2135
|
currentToolId = block.id;
|
|
2136
2136
|
toolInputBuffers[currentToolId] = "";
|
|
2137
2137
|
toolCalls.push({ id: currentToolId, name: block.name, input: {} });
|
|
2138
|
+
} else {
|
|
2139
|
+
currentToolId = "";
|
|
2138
2140
|
}
|
|
2139
2141
|
} else if (type === "content_block_delta") {
|
|
2140
2142
|
const delta = evt.delta;
|
|
@@ -2142,21 +2144,26 @@ var init_LLMExecutor = __esm({
|
|
|
2142
2144
|
const token = delta.text ?? "";
|
|
2143
2145
|
textContent += token;
|
|
2144
2146
|
if (onToken && token) onToken(token);
|
|
2145
|
-
} else if (delta?.type === "input_json_delta") {
|
|
2147
|
+
} else if (delta?.type === "input_json_delta" && currentToolId) {
|
|
2146
2148
|
toolInputBuffers[currentToolId] = (toolInputBuffers[currentToolId] ?? "") + (delta.partial_json ?? "");
|
|
2147
2149
|
}
|
|
2148
2150
|
} else if (type === "content_block_stop") {
|
|
2149
|
-
if (currentToolId && toolInputBuffers
|
|
2151
|
+
if (currentToolId && currentToolId in toolInputBuffers) {
|
|
2150
2152
|
const tc = toolCalls.find((t) => t.id === currentToolId);
|
|
2151
2153
|
if (tc) {
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2154
|
+
const buf2 = toolInputBuffers[currentToolId];
|
|
2155
|
+
if (buf2) {
|
|
2156
|
+
try {
|
|
2157
|
+
tc.input = JSON.parse(buf2);
|
|
2158
|
+
} catch {
|
|
2159
|
+
tc.input = { _parse_error: true, _raw: buf2.slice(0, 200) };
|
|
2160
|
+
}
|
|
2155
2161
|
}
|
|
2156
|
-
if (onToolUseBlock && tc.input && Object.keys(tc.input).length > 0) {
|
|
2162
|
+
if (onToolUseBlock && tc.input && Object.keys(tc.input).length > 0 && !tc.input._parse_error) {
|
|
2157
2163
|
onToolUseBlock(tc);
|
|
2158
2164
|
}
|
|
2159
2165
|
}
|
|
2166
|
+
currentToolId = "";
|
|
2160
2167
|
}
|
|
2161
2168
|
} else if (type === "message_delta") {
|
|
2162
2169
|
const usage = evt.usage;
|
|
@@ -2168,10 +2175,13 @@ var init_LLMExecutor = __esm({
|
|
|
2168
2175
|
}
|
|
2169
2176
|
}
|
|
2170
2177
|
}
|
|
2178
|
+
const validToolCalls = toolCalls.filter(
|
|
2179
|
+
(tc) => tc.input && Object.keys(tc.input).length > 0 && !tc.input._parse_error
|
|
2180
|
+
);
|
|
2171
2181
|
return {
|
|
2172
2182
|
content: textContent,
|
|
2173
|
-
tool_calls:
|
|
2174
|
-
stop_reason: stopReason,
|
|
2183
|
+
tool_calls: validToolCalls.length > 0 ? validToolCalls : null,
|
|
2184
|
+
stop_reason: validToolCalls.length > 0 && stopReason === "tool_use" ? "tool_use" : stopReason,
|
|
2175
2185
|
tokens_used: inputTokens + outputTokens,
|
|
2176
2186
|
input_tokens: inputTokens,
|
|
2177
2187
|
output_tokens: outputTokens,
|
|
@@ -2827,7 +2837,7 @@ var init_ShellCapability = __esm({
|
|
|
2827
2837
|
});
|
|
2828
2838
|
|
|
2829
2839
|
// packages/daemon/src/tools/FileCapability.ts
|
|
2830
|
-
import { readFileSync as readFileSync2, writeFileSync, readdirSync, mkdirSync, existsSync as existsSync2 } from "node:fs";
|
|
2840
|
+
import { readFileSync as readFileSync2, writeFileSync, readdirSync, mkdirSync, existsSync as existsSync2, statSync } from "node:fs";
|
|
2831
2841
|
import { resolve as resolve2, dirname } from "node:path";
|
|
2832
2842
|
var FileCapability;
|
|
2833
2843
|
var init_FileCapability = __esm({
|
|
@@ -2862,6 +2872,11 @@ var init_FileCapability = __esm({
|
|
|
2862
2872
|
try {
|
|
2863
2873
|
if (op === "read") {
|
|
2864
2874
|
if (!existsSync2(safe)) return { success: false, output: `Not found: ${rel}`, duration_ms: Date.now() - start };
|
|
2875
|
+
if (statSync(safe).isDirectory()) {
|
|
2876
|
+
const entries = readdirSync(safe, { withFileTypes: true }).filter((e) => !e.name.startsWith(".") && e.name !== "node_modules").map((e) => `${e.isDirectory() ? "d" : "f"} ${e.name}`).join("\n");
|
|
2877
|
+
return { success: true, output: `(directory listing for ${rel}):
|
|
2878
|
+
${entries || "(empty)"}`, duration_ms: Date.now() - start };
|
|
2879
|
+
}
|
|
2865
2880
|
const content = readFileSync2(safe, "utf8");
|
|
2866
2881
|
return {
|
|
2867
2882
|
success: true,
|
|
@@ -4232,7 +4247,7 @@ Run manually: pip3 install open-interpreter`,
|
|
|
4232
4247
|
|
|
4233
4248
|
// packages/daemon/src/tools/SurgeCapability.ts
|
|
4234
4249
|
import { execSync as execSync3 } from "node:child_process";
|
|
4235
|
-
import { existsSync as existsSync3, mkdirSync as mkdirSync2, copyFileSync, statSync } from "node:fs";
|
|
4250
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync2, copyFileSync, statSync as statSync2 } from "node:fs";
|
|
4236
4251
|
import { join } from "node:path";
|
|
4237
4252
|
var SurgeCapability;
|
|
4238
4253
|
var init_SurgeCapability = __esm({
|
|
@@ -4268,7 +4283,7 @@ var init_SurgeCapability = __esm({
|
|
|
4268
4283
|
return { success: false, output: `Path does not exist: ${target}`, duration_ms: 0 };
|
|
4269
4284
|
}
|
|
4270
4285
|
let publishDir = target;
|
|
4271
|
-
if (
|
|
4286
|
+
if (statSync2(target).isFile()) {
|
|
4272
4287
|
publishDir = join("/tmp", `surge-${Date.now()}`);
|
|
4273
4288
|
mkdirSync2(publishDir, { recursive: true });
|
|
4274
4289
|
copyFileSync(target, join(publishDir, "index.html"));
|
|
@@ -6597,6 +6612,9 @@ content = element.text if element else page.get_all_text()` : `content = page.ge
|
|
|
6597
6612
|
async _executeSingleTool(tc, signal, filesWritten, commandsRun) {
|
|
6598
6613
|
let result;
|
|
6599
6614
|
try {
|
|
6615
|
+
if (!tc.input || Object.keys(tc.input).length === 0) {
|
|
6616
|
+
return `Error: empty tool input for ${tc.name}. Provide required parameters.`;
|
|
6617
|
+
}
|
|
6600
6618
|
const capResult = await this.registry.execute(tc.name, tc.input, this.cwd, signal);
|
|
6601
6619
|
result = capResult.output;
|
|
6602
6620
|
const MAX_TOOL_OUTPUT = 4e3;
|
|
@@ -7085,7 +7103,7 @@ __export(ProactiveSurface_exports, {
|
|
|
7085
7103
|
ProactiveSurface: () => ProactiveSurface
|
|
7086
7104
|
});
|
|
7087
7105
|
import { execSync as execSync10 } from "node:child_process";
|
|
7088
|
-
import { existsSync as existsSync20, readFileSync as readFileSync16, statSync as
|
|
7106
|
+
import { existsSync as existsSync20, readFileSync as readFileSync16, statSync as statSync3, readdirSync as readdirSync5 } from "node:fs";
|
|
7089
7107
|
import { resolve as resolve16, join as join7 } from "node:path";
|
|
7090
7108
|
function readdirSafe(dir) {
|
|
7091
7109
|
try {
|
|
@@ -7183,7 +7201,7 @@ var init_ProactiveSurface = __esm({
|
|
|
7183
7201
|
const xmlFiles = readdirSafe(dir).filter((f) => f.endsWith(".xml"));
|
|
7184
7202
|
for (const xml of xmlFiles) {
|
|
7185
7203
|
const path = join7(dir, xml);
|
|
7186
|
-
const stat =
|
|
7204
|
+
const stat = statSync3(path);
|
|
7187
7205
|
if (stat.mtimeMs < this.lastPollAt) continue;
|
|
7188
7206
|
const content = readFileSync16(path, "utf8");
|
|
7189
7207
|
const failures = [...content.matchAll(/<failure[^>]*message="([^"]+)"/g)].length;
|