clawcompany 0.32.0 → 0.33.0
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/index.js +59 -20
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2149,7 +2149,7 @@ import { join } from "path";
|
|
|
2149
2149
|
import { existsSync, readFileSync, writeFileSync, mkdirSync } from "fs";
|
|
2150
2150
|
function banner() {
|
|
2151
2151
|
console.log("");
|
|
2152
|
-
console.log(" \u{1F99E} ClawCompany v0.
|
|
2152
|
+
console.log(" \u{1F99E} ClawCompany v0.33.0");
|
|
2153
2153
|
console.log(" Build for OPC. Every human being is a chairman.");
|
|
2154
2154
|
console.log("");
|
|
2155
2155
|
}
|
|
@@ -2643,11 +2643,28 @@ var OpenAICompatibleProvider = class _OpenAICompatibleProvider {
|
|
|
2643
2643
|
});
|
|
2644
2644
|
if (!response.ok) {
|
|
2645
2645
|
const errorBody = await response.text().catch(() => "");
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2646
|
+
const status = response.status;
|
|
2647
|
+
let friendly;
|
|
2648
|
+
switch (true) {
|
|
2649
|
+
case status === 429:
|
|
2650
|
+
friendly = "Rate limited \u2014 too many requests. Please wait and try again.";
|
|
2651
|
+
break;
|
|
2652
|
+
case status === 529:
|
|
2653
|
+
friendly = "Model overloaded \u2014 the API is currently busy. Try again in a moment.";
|
|
2654
|
+
break;
|
|
2655
|
+
case (status === 502 || status === 504):
|
|
2656
|
+
friendly = "Request timeout \u2014 the model took too long to respond. Try a different role or model.";
|
|
2657
|
+
break;
|
|
2658
|
+
case (status === 401 || status === 403):
|
|
2659
|
+
friendly = "Authentication failed \u2014 check your API key.";
|
|
2660
|
+
break;
|
|
2661
|
+
case status === 400:
|
|
2662
|
+
friendly = `Bad request \u2014 this model may not support the current settings. (${errorBody.slice(0, 120)})`;
|
|
2663
|
+
break;
|
|
2664
|
+
default:
|
|
2665
|
+
friendly = `API error ${status}: ${errorBody.slice(0, 200)}`;
|
|
2666
|
+
}
|
|
2667
|
+
throw new ProviderError(status, friendly, this.id);
|
|
2651
2668
|
}
|
|
2652
2669
|
let content = "";
|
|
2653
2670
|
let model = params.model;
|
|
@@ -2718,6 +2735,16 @@ var OpenAICompatibleProvider = class _OpenAICompatibleProvider {
|
|
|
2718
2735
|
for (const [, buf] of [...toolCallBuffers.entries()].sort((a, b) => a[0] - b[0])) {
|
|
2719
2736
|
toolCalls.push({ id: buf.id, type: "function", function: { name: buf.name, arguments: buf.args } });
|
|
2720
2737
|
}
|
|
2738
|
+
const cost = calculateCost(params.model, promptTokens, completionTokens);
|
|
2739
|
+
if (!content && toolCalls.length === 0 && cost === 0) {
|
|
2740
|
+
return {
|
|
2741
|
+
content: "\u26A0\uFE0F No response received from the model. This usually means the API is temporarily unavailable. Try again or switch to a different role.",
|
|
2742
|
+
model,
|
|
2743
|
+
provider: this.id,
|
|
2744
|
+
usage: { inputTokens: 0, outputTokens: 0, cost: 0 },
|
|
2745
|
+
finishReason
|
|
2746
|
+
};
|
|
2747
|
+
}
|
|
2721
2748
|
return {
|
|
2722
2749
|
content,
|
|
2723
2750
|
model,
|
|
@@ -2725,7 +2752,7 @@ var OpenAICompatibleProvider = class _OpenAICompatibleProvider {
|
|
|
2725
2752
|
usage: {
|
|
2726
2753
|
inputTokens: promptTokens,
|
|
2727
2754
|
outputTokens: completionTokens,
|
|
2728
|
-
cost
|
|
2755
|
+
cost
|
|
2729
2756
|
},
|
|
2730
2757
|
toolCalls: toolCalls.length > 0 ? toolCalls : void 0,
|
|
2731
2758
|
finishReason
|
|
@@ -3020,7 +3047,7 @@ function sleep(ms) {
|
|
|
3020
3047
|
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
3021
3048
|
}
|
|
3022
3049
|
|
|
3023
|
-
// ../packages/tools/src/executor.
|
|
3050
|
+
// ../packages/tools/src/executor.js
|
|
3024
3051
|
import { exec } from "child_process";
|
|
3025
3052
|
import { readFile, writeFile, readdir, unlink } from "fs/promises";
|
|
3026
3053
|
import { promisify } from "util";
|
|
@@ -3132,7 +3159,8 @@ ${text.slice(0, 5e3)}`;
|
|
|
3132
3159
|
}
|
|
3133
3160
|
return raw.slice(0, limit);
|
|
3134
3161
|
} catch (err) {
|
|
3135
|
-
if (err.name === "TimeoutError")
|
|
3162
|
+
if (err.name === "TimeoutError")
|
|
3163
|
+
return "Error: Request timed out (15s)";
|
|
3136
3164
|
return `Error: ${err.message}`;
|
|
3137
3165
|
}
|
|
3138
3166
|
}
|
|
@@ -3156,7 +3184,8 @@ ${text.slice(0, 5e3)}`;
|
|
|
3156
3184
|
for (let i = 1; i < resultBlocks.length && results.length < limit; i++) {
|
|
3157
3185
|
const block = resultBlocks[i];
|
|
3158
3186
|
const prevTail = resultBlocks[i - 1].slice(-300);
|
|
3159
|
-
if (prevTail.includes("result--ad"))
|
|
3187
|
+
if (prevTail.includes("result--ad"))
|
|
3188
|
+
continue;
|
|
3160
3189
|
const titleMatch = block.match(/class="result__a"[^>]*>([^<]+)/);
|
|
3161
3190
|
const title = titleMatch?.[1]?.replace(/&/g, "&")?.replace(/"/g, '"')?.replace(/'/g, "'")?.trim() ?? "";
|
|
3162
3191
|
const urlMatch = block.match(/href="\/\/duckduckgo\.com\/l\/\?[^"]*uddg=([^&"]+)/);
|
|
@@ -3186,7 +3215,8 @@ ${text.slice(0, 5e3)}`;
|
|
|
3186
3215
|
}
|
|
3187
3216
|
return output;
|
|
3188
3217
|
} catch (err) {
|
|
3189
|
-
if (err.name === "TimeoutError")
|
|
3218
|
+
if (err.name === "TimeoutError")
|
|
3219
|
+
return "Error: Search timed out (10s)";
|
|
3190
3220
|
return `Error: ${err.message}`;
|
|
3191
3221
|
}
|
|
3192
3222
|
}
|
|
@@ -3195,33 +3225,39 @@ ${text.slice(0, 5e3)}`;
|
|
|
3195
3225
|
let cmd;
|
|
3196
3226
|
switch (action) {
|
|
3197
3227
|
case "open":
|
|
3198
|
-
if (!url)
|
|
3228
|
+
if (!url)
|
|
3229
|
+
return "Error: url is required for open action";
|
|
3199
3230
|
cmd = `browser-use open ${JSON.stringify(url)}`;
|
|
3200
3231
|
break;
|
|
3201
3232
|
case "state":
|
|
3202
3233
|
cmd = "browser-use state --json";
|
|
3203
3234
|
break;
|
|
3204
3235
|
case "click":
|
|
3205
|
-
if (index === void 0)
|
|
3236
|
+
if (index === void 0)
|
|
3237
|
+
return "Error: index is required for click action";
|
|
3206
3238
|
cmd = `browser-use click ${index}`;
|
|
3207
3239
|
break;
|
|
3208
3240
|
case "type":
|
|
3209
|
-
if (!text)
|
|
3241
|
+
if (!text)
|
|
3242
|
+
return "Error: text is required for type action";
|
|
3210
3243
|
cmd = `browser-use type ${JSON.stringify(text)}`;
|
|
3211
3244
|
break;
|
|
3212
3245
|
case "input":
|
|
3213
|
-
if (index === void 0 || !text)
|
|
3246
|
+
if (index === void 0 || !text)
|
|
3247
|
+
return "Error: index and text are required for input action";
|
|
3214
3248
|
cmd = `browser-use input ${index} ${JSON.stringify(text)}`;
|
|
3215
3249
|
break;
|
|
3216
3250
|
case "screenshot":
|
|
3217
3251
|
cmd = `browser-use screenshot ${JSON.stringify(path ?? "/tmp/screenshot.png")}`;
|
|
3218
3252
|
break;
|
|
3219
3253
|
case "eval":
|
|
3220
|
-
if (!code)
|
|
3254
|
+
if (!code)
|
|
3255
|
+
return "Error: code is required for eval action";
|
|
3221
3256
|
cmd = `browser-use eval ${JSON.stringify(code)}`;
|
|
3222
3257
|
break;
|
|
3223
3258
|
case "scroll":
|
|
3224
|
-
if (!direction)
|
|
3259
|
+
if (!direction)
|
|
3260
|
+
return "Error: direction is required for scroll action";
|
|
3225
3261
|
cmd = `browser-use scroll ${direction}`;
|
|
3226
3262
|
break;
|
|
3227
3263
|
case "close":
|
|
@@ -3271,17 +3307,20 @@ STDERR: ${stderr}` : "");
|
|
|
3271
3307
|
24h Volume: $${vol24h ? (vol24h / 1e9).toFixed(2) + "B" : "N/A"}
|
|
3272
3308
|
24h Change: ${change24h?.toFixed(2) ?? "N/A"}%`;
|
|
3273
3309
|
} catch (err) {
|
|
3274
|
-
if (err.name === "AbortError")
|
|
3310
|
+
if (err.name === "AbortError")
|
|
3311
|
+
return "Error: Price feed timed out (10s)";
|
|
3275
3312
|
return `Error fetching price: ${err.message}`;
|
|
3276
3313
|
}
|
|
3277
3314
|
}
|
|
3278
3315
|
async execMemorySearch(args) {
|
|
3279
3316
|
const query = args.query;
|
|
3280
|
-
if (!query)
|
|
3317
|
+
if (!query)
|
|
3318
|
+
return "Error: query is required";
|
|
3281
3319
|
try {
|
|
3282
3320
|
const res = await fetch("http://localhost:3200/api/memory/search?q=" + encodeURIComponent(query));
|
|
3283
3321
|
const data = await res.json();
|
|
3284
|
-
if (data.totalMatches === 0)
|
|
3322
|
+
if (data.totalMatches === 0)
|
|
3323
|
+
return "No matches found for: " + query;
|
|
3285
3324
|
let result = `Found ${data.totalMatches} matches:
|
|
3286
3325
|
|
|
3287
3326
|
`;
|
package/package.json
CHANGED