0agent 1.0.82 → 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.
Files changed (2) hide show
  1. package/dist/daemon.mjs +18 -8
  2. 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[currentToolId]) {
2151
+ if (currentToolId && currentToolId in toolInputBuffers) {
2150
2152
  const tc = toolCalls.find((t) => t.id === currentToolId);
2151
2153
  if (tc) {
2152
- try {
2153
- tc.input = JSON.parse(toolInputBuffers[currentToolId]);
2154
- } catch {
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: toolCalls.length > 0 ? toolCalls : null,
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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "0agent",
3
- "version": "1.0.82",
3
+ "version": "1.0.83",
4
4
  "description": "A persistent, learning AI agent that runs on your machine. An agent that learns.",
5
5
  "private": false,
6
6
  "license": "Apache-2.0",