@blockrun/clawrouter 0.10.7 → 0.10.8
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/cli.js +7 -2
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +20 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1057,12 +1057,12 @@ declare function getPartnerService(id: string): PartnerServiceDefinition | undef
|
|
|
1057
1057
|
type PartnerToolDefinition = {
|
|
1058
1058
|
name: string;
|
|
1059
1059
|
description: string;
|
|
1060
|
-
|
|
1060
|
+
parameters: {
|
|
1061
1061
|
type: "object";
|
|
1062
1062
|
properties: Record<string, unknown>;
|
|
1063
1063
|
required: string[];
|
|
1064
1064
|
};
|
|
1065
|
-
execute: (
|
|
1065
|
+
execute: (toolCallId: string, params: Record<string, unknown>) => Promise<unknown>;
|
|
1066
1066
|
};
|
|
1067
1067
|
/**
|
|
1068
1068
|
* Build OpenClaw tool definitions for all registered partner services.
|
package/dist/index.js
CHANGED
|
@@ -74,17 +74,17 @@ function buildTool(service, proxyBaseUrl) {
|
|
|
74
74
|
`Partner: ${service.partner}`,
|
|
75
75
|
`Pricing: ${service.pricing.perUnit} per ${service.pricing.unit} (min: ${service.pricing.minimum}, max: ${service.pricing.maximum})`
|
|
76
76
|
].join("\n"),
|
|
77
|
-
|
|
77
|
+
parameters: {
|
|
78
78
|
type: "object",
|
|
79
79
|
properties,
|
|
80
80
|
required
|
|
81
81
|
},
|
|
82
|
-
execute: async (
|
|
82
|
+
execute: async (_toolCallId, params) => {
|
|
83
83
|
const url = `${proxyBaseUrl}/v1${service.proxyPath}`;
|
|
84
84
|
const response = await fetch(url, {
|
|
85
85
|
method: service.method,
|
|
86
86
|
headers: { "Content-Type": "application/json" },
|
|
87
|
-
body: JSON.stringify(
|
|
87
|
+
body: JSON.stringify(params)
|
|
88
88
|
});
|
|
89
89
|
if (!response.ok) {
|
|
90
90
|
const errText = await response.text().catch(() => "");
|
|
@@ -92,7 +92,16 @@ function buildTool(service, proxyBaseUrl) {
|
|
|
92
92
|
`Partner API error (${response.status}): ${errText || response.statusText}`
|
|
93
93
|
);
|
|
94
94
|
}
|
|
95
|
-
|
|
95
|
+
const data = await response.json();
|
|
96
|
+
return {
|
|
97
|
+
content: [
|
|
98
|
+
{
|
|
99
|
+
type: "text",
|
|
100
|
+
text: JSON.stringify(data, null, 2)
|
|
101
|
+
}
|
|
102
|
+
],
|
|
103
|
+
details: data
|
|
104
|
+
};
|
|
96
105
|
}
|
|
97
106
|
};
|
|
98
107
|
}
|
|
@@ -160,6 +169,8 @@ var MODEL_ALIASES = {
|
|
|
160
169
|
reasoner: "deepseek/deepseek-reasoner",
|
|
161
170
|
// Kimi / Moonshot
|
|
162
171
|
kimi: "moonshot/kimi-k2.5",
|
|
172
|
+
moonshot: "moonshot/kimi-k2.5",
|
|
173
|
+
"kimi-k2.5": "moonshot/kimi-k2.5",
|
|
163
174
|
// Google
|
|
164
175
|
gemini: "google/gemini-2.5-pro",
|
|
165
176
|
flash: "google/gemini-2.5-flash",
|
|
@@ -4545,7 +4556,10 @@ var PROVIDER_ERROR_PATTERNS = [
|
|
|
4545
4556
|
/authentication.*failed/i,
|
|
4546
4557
|
/request too large/i,
|
|
4547
4558
|
/request.*size.*exceeds/i,
|
|
4548
|
-
/payload too large/i
|
|
4559
|
+
/payload too large/i,
|
|
4560
|
+
/payment.*verification.*failed/i,
|
|
4561
|
+
/model.*not.*allowed/i,
|
|
4562
|
+
/unknown.*model/i
|
|
4549
4563
|
];
|
|
4550
4564
|
var DEGRADED_RESPONSE_PATTERNS = [
|
|
4551
4565
|
/the ai service is temporarily overloaded/i,
|
|
@@ -4865,7 +4879,7 @@ function estimateAmount(modelId, bodyLength, maxTokens) {
|
|
|
4865
4879
|
const estimatedInputTokens = Math.ceil(bodyLength / 4);
|
|
4866
4880
|
const estimatedOutputTokens = maxTokens || model.maxOutput || 4096;
|
|
4867
4881
|
const costUsd = estimatedInputTokens / 1e6 * model.inputPrice + estimatedOutputTokens / 1e6 * model.outputPrice;
|
|
4868
|
-
const amountMicros = Math.max(
|
|
4882
|
+
const amountMicros = Math.max(1e3, Math.ceil(costUsd * 1.2 * 1e6));
|
|
4869
4883
|
return amountMicros.toString();
|
|
4870
4884
|
}
|
|
4871
4885
|
async function proxyPartnerRequest(req, res, apiBase, payFetch) {
|