duclaw-cli 1.9.14 → 1.9.15
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/bundle.js +70 -17
- package/dist/main.js +1 -1
- package/dist/worker-main.js +1 -1
- package/package.json +1 -1
package/dist/bundle.js
CHANGED
|
@@ -30242,7 +30242,7 @@ function printHelp() {
|
|
|
30242
30242
|
`);
|
|
30243
30243
|
}
|
|
30244
30244
|
function printVersion() {
|
|
30245
|
-
console.log(`duclaw-cli v${true ? "1.9.
|
|
30245
|
+
console.log(`duclaw-cli v${true ? "1.9.15" : "unknown"}`);
|
|
30246
30246
|
}
|
|
30247
30247
|
function getDuclawTemplate() {
|
|
30248
30248
|
return {
|
|
@@ -41823,6 +41823,7 @@ var controlPlaneBaseUrl = () => {
|
|
|
41823
41823
|
return process.env.DUCLAW_CONTROL_PLANE_BASE_URL?.replace(/\/$/, "");
|
|
41824
41824
|
};
|
|
41825
41825
|
var USER_IMAGE_REUPLOAD_MESSAGE = `\u8FD9\u5F20\u56FE\u7247\u6682\u65F6\u65E0\u6CD5\u6309\u56FE\u7247\u683C\u5F0F\u89E3\u6790\u3002\u8BF7\u91CD\u65B0\u53D1\u9001 JPG/PNG/WebP \u56FE\u7247\uFF0C\u6216\u8005\u5728\u624B\u673A\u4E0A\u622A\u56FE\u540E\u518D\u53D1\u4E00\u6B21\u3002`;
|
|
41826
|
+
var USER_IMAGE_UNDERSTAND_CREDIT_EXHAUSTED_MESSAGE = `Credit \u4F59\u989D\u4E0D\u8DB3\uFF0C\u65E0\u6CD5\u5B8C\u6210\u672C\u6B21\u56FE\u7247\u7406\u89E3\u3002\u8BF7\u5148\u5145\u503C\u6216\u4F7F\u7528\u6FC0\u6D3B\u7801\u589E\u52A0 Credit\u3002`;
|
|
41826
41827
|
var normalizeRuntimeAttachmentUrl = (input) => {
|
|
41827
41828
|
return input.replace("/api/mobile/attachments/", "/internal/runtime/mobile/attachments/");
|
|
41828
41829
|
};
|
|
@@ -41958,6 +41959,15 @@ var imageUnderstand = {
|
|
|
41958
41959
|
providerResponseId: response.providerResponseId,
|
|
41959
41960
|
authStyle,
|
|
41960
41961
|
userRequest
|
|
41962
|
+
}).catch((error) => {
|
|
41963
|
+
if (error instanceof ImageUnderstandMeteringError && (error.meteringStatus === "credit_exhausted" || error.statusCode === 402)) {
|
|
41964
|
+
throw new UserRecoverableToolError(
|
|
41965
|
+
"credit_exhausted",
|
|
41966
|
+
USER_IMAGE_UNDERSTAND_CREDIT_EXHAUSTED_MESSAGE,
|
|
41967
|
+
error.message
|
|
41968
|
+
);
|
|
41969
|
+
}
|
|
41970
|
+
throw error;
|
|
41961
41971
|
});
|
|
41962
41972
|
return resultText;
|
|
41963
41973
|
}
|
|
@@ -45366,12 +45376,11 @@ var createSaasCreditToolHookPlugin = () => ({
|
|
|
45366
45376
|
toolCallId: ctx.toolCallId,
|
|
45367
45377
|
requestId: ctx.userRequest?.requestId ?? null,
|
|
45368
45378
|
occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
45369
|
-
|
|
45370
|
-
|
|
45371
|
-
|
|
45372
|
-
|
|
45373
|
-
|
|
45374
|
-
}
|
|
45379
|
+
meterType: usage.meterType,
|
|
45380
|
+
provider: usage.provider,
|
|
45381
|
+
unit: usage.unit,
|
|
45382
|
+
quantity: usage.quantity,
|
|
45383
|
+
metadata: usage.metadata
|
|
45375
45384
|
})
|
|
45376
45385
|
});
|
|
45377
45386
|
const body = await parseJson2(response);
|
|
@@ -45379,7 +45388,7 @@ var createSaasCreditToolHookPlugin = () => ({
|
|
|
45379
45388
|
if (response.status === 402 || status === "credit_exhausted") {
|
|
45380
45389
|
throw new UserRecoverableToolError(
|
|
45381
45390
|
"credit_exhausted",
|
|
45382
|
-
|
|
45391
|
+
usage.userMessage,
|
|
45383
45392
|
`[saas-credit] ${ctx.toolName} credit exhausted`
|
|
45384
45393
|
);
|
|
45385
45394
|
}
|
|
@@ -45389,14 +45398,27 @@ var createSaasCreditToolHookPlugin = () => ({
|
|
|
45389
45398
|
}
|
|
45390
45399
|
});
|
|
45391
45400
|
function meteredToolUsage(ctx) {
|
|
45392
|
-
if (ctx.toolName
|
|
45393
|
-
|
|
45394
|
-
|
|
45395
|
-
|
|
45396
|
-
|
|
45397
|
-
|
|
45398
|
-
|
|
45399
|
-
|
|
45401
|
+
if (ctx.toolName === "websearch") {
|
|
45402
|
+
if (isWebSearchErrorResult(ctx.resultText)) return null;
|
|
45403
|
+
return {
|
|
45404
|
+
meterType: "web.content_retrieval",
|
|
45405
|
+
provider: "exa",
|
|
45406
|
+
unit: "content",
|
|
45407
|
+
quantity: normalizeNumResults(ctx.input.numResults),
|
|
45408
|
+
userMessage: "Credit \u4F59\u989D\u4E0D\u8DB3\uFF0C\u65E0\u6CD5\u5B8C\u6210\u672C\u6B21\u7F51\u9875\u641C\u7D22\u3002\u8BF7\u5148\u5145\u503C\u6216\u4F7F\u7528\u6FC0\u6D3B\u7801\u589E\u52A0 Credit\u3002",
|
|
45409
|
+
metadata: {
|
|
45410
|
+
platform: ctx.userRequest?.platform ?? null,
|
|
45411
|
+
departmentAgentId: ctx.userRequest?.departmentAgentId ?? null,
|
|
45412
|
+
input: sanitizedWebSearchInput(ctx.input)
|
|
45413
|
+
}
|
|
45414
|
+
};
|
|
45415
|
+
}
|
|
45416
|
+
if (ctx.toolName === "image_generate") {
|
|
45417
|
+
const usage = imageGenerateUsage(ctx);
|
|
45418
|
+
if (!usage) return null;
|
|
45419
|
+
return usage;
|
|
45420
|
+
}
|
|
45421
|
+
return null;
|
|
45400
45422
|
}
|
|
45401
45423
|
function normalizeNumResults(value) {
|
|
45402
45424
|
if (typeof value !== "number" || !Number.isFinite(value)) return DEFAULT_WEB_SEARCH_NUM_RESULTS;
|
|
@@ -45415,6 +45437,37 @@ function sanitizedWebSearchInput(input) {
|
|
|
45415
45437
|
contextMaxCharacters: typeof input.contextMaxCharacters === "number" ? input.contextMaxCharacters : null
|
|
45416
45438
|
};
|
|
45417
45439
|
}
|
|
45440
|
+
function imageGenerateUsage(ctx) {
|
|
45441
|
+
const result = parseResultJson(ctx.resultText);
|
|
45442
|
+
if (!result || result.ok !== true) return null;
|
|
45443
|
+
const savedFiles = Array.isArray(result.savedFiles) ? result.savedFiles : [];
|
|
45444
|
+
const quantity = savedFiles.length > 0 ? savedFiles.length : 1;
|
|
45445
|
+
return {
|
|
45446
|
+
meterType: "image.generate",
|
|
45447
|
+
provider: "shanyi",
|
|
45448
|
+
unit: "image",
|
|
45449
|
+
quantity,
|
|
45450
|
+
userMessage: "Credit \u4F59\u989D\u4E0D\u8DB3\uFF0C\u65E0\u6CD5\u751F\u6210\u56FE\u7247\u3002\u751F\u6210\u56FE\u7247\u6BCF\u5F20\u9700\u8981 20 Credit\uFF08\u7EA6 0.2 \u5143\uFF09\uFF0C\u8BF7\u5148\u5145\u503C\u6216\u4F7F\u7528\u6FC0\u6D3B\u7801\u589E\u52A0 Credit\u3002",
|
|
45451
|
+
metadata: {
|
|
45452
|
+
platform: ctx.userRequest?.platform ?? null,
|
|
45453
|
+
departmentAgentId: ctx.userRequest?.departmentAgentId ?? null,
|
|
45454
|
+
model: typeof result.model === "string" ? result.model : null,
|
|
45455
|
+
size: typeof result.size === "string" ? result.size : null,
|
|
45456
|
+
resolution: typeof result.resolution === "string" ? result.resolution : null,
|
|
45457
|
+
requestId: typeof result.requestId === "string" ? result.requestId : null,
|
|
45458
|
+
prompt: typeof ctx.input.prompt === "string" ? ctx.input.prompt.slice(0, 500) : null
|
|
45459
|
+
}
|
|
45460
|
+
};
|
|
45461
|
+
}
|
|
45462
|
+
function parseResultJson(value) {
|
|
45463
|
+
if (!value) return null;
|
|
45464
|
+
try {
|
|
45465
|
+
const parsed = JSON.parse(value);
|
|
45466
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
|
|
45467
|
+
} catch {
|
|
45468
|
+
return null;
|
|
45469
|
+
}
|
|
45470
|
+
}
|
|
45418
45471
|
async function parseJson2(response) {
|
|
45419
45472
|
try {
|
|
45420
45473
|
return await response.json();
|
|
@@ -54054,7 +54107,7 @@ var systemRoutes = new Hono2();
|
|
|
54054
54107
|
var startTime = Date.now();
|
|
54055
54108
|
systemRoutes.get("/system/info", (c) => {
|
|
54056
54109
|
return c.json({
|
|
54057
|
-
version: true ? "1.9.
|
|
54110
|
+
version: true ? "1.9.15" : "unknown",
|
|
54058
54111
|
uptime: Math.floor((Date.now() - startTime) / 1e3),
|
|
54059
54112
|
env: process.env.NODE_ENV || "development",
|
|
54060
54113
|
nodeVersion: process.version
|