@nextclaw/server 0.6.9 → 0.6.10
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 +19 -8
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -2027,6 +2027,17 @@ function readNonEmptyString(value) {
|
|
|
2027
2027
|
const trimmed = value.trim();
|
|
2028
2028
|
return trimmed || void 0;
|
|
2029
2029
|
}
|
|
2030
|
+
function formatUserFacingError(error, maxChars = 320) {
|
|
2031
|
+
const raw = error instanceof Error ? error.message || error.name || "Unknown error" : String(error ?? "Unknown error");
|
|
2032
|
+
const normalized = raw.replace(/\s+/g, " ").trim();
|
|
2033
|
+
if (!normalized) {
|
|
2034
|
+
return "Unknown error";
|
|
2035
|
+
}
|
|
2036
|
+
if (normalized.length <= maxChars) {
|
|
2037
|
+
return normalized;
|
|
2038
|
+
}
|
|
2039
|
+
return `${normalized.slice(0, Math.max(0, maxChars - 3)).trimEnd()}...`;
|
|
2040
|
+
}
|
|
2030
2041
|
function normalizeSessionType2(value) {
|
|
2031
2042
|
return readNonEmptyString(value)?.toLowerCase();
|
|
2032
2043
|
}
|
|
@@ -3371,7 +3382,7 @@ function createUiRouter(options) {
|
|
|
3371
3382
|
options.publish({ type: "config.updated", payload: { path: "session" } });
|
|
3372
3383
|
return c.json(ok(response));
|
|
3373
3384
|
} catch (error) {
|
|
3374
|
-
return c.json(err("CHAT_TURN_FAILED",
|
|
3385
|
+
return c.json(err("CHAT_TURN_FAILED", formatUserFacingError(error)), 500);
|
|
3375
3386
|
}
|
|
3376
3387
|
});
|
|
3377
3388
|
app.post("/api/chat/turn/stop", async (c) => {
|
|
@@ -3449,7 +3460,7 @@ function createUiRouter(options) {
|
|
|
3449
3460
|
try {
|
|
3450
3461
|
managedRun = await chatRuntime.startTurnRun(request);
|
|
3451
3462
|
} catch (error) {
|
|
3452
|
-
return c.json(err("CHAT_TURN_FAILED",
|
|
3463
|
+
return c.json(err("CHAT_TURN_FAILED", formatUserFacingError(error)), 500);
|
|
3453
3464
|
}
|
|
3454
3465
|
if (readNonEmptyString(managedRun.runId)) {
|
|
3455
3466
|
runId = readNonEmptyString(managedRun.runId);
|
|
@@ -3511,7 +3522,7 @@ function createUiRouter(options) {
|
|
|
3511
3522
|
if (typed.type === "error") {
|
|
3512
3523
|
push("error", {
|
|
3513
3524
|
code: "CHAT_TURN_FAILED",
|
|
3514
|
-
message: typed.error
|
|
3525
|
+
message: formatUserFacingError(typed.error)
|
|
3515
3526
|
});
|
|
3516
3527
|
return;
|
|
3517
3528
|
}
|
|
@@ -3572,7 +3583,7 @@ function createUiRouter(options) {
|
|
|
3572
3583
|
if (typed.type === "error") {
|
|
3573
3584
|
push("error", {
|
|
3574
3585
|
code: "CHAT_TURN_FAILED",
|
|
3575
|
-
message: typed.error
|
|
3586
|
+
message: formatUserFacingError(typed.error)
|
|
3576
3587
|
});
|
|
3577
3588
|
return;
|
|
3578
3589
|
}
|
|
@@ -3588,7 +3599,7 @@ function createUiRouter(options) {
|
|
|
3588
3599
|
} catch (error) {
|
|
3589
3600
|
push("error", {
|
|
3590
3601
|
code: "CHAT_TURN_FAILED",
|
|
3591
|
-
message:
|
|
3602
|
+
message: formatUserFacingError(error)
|
|
3592
3603
|
});
|
|
3593
3604
|
} finally {
|
|
3594
3605
|
controller.close();
|
|
@@ -3714,7 +3725,7 @@ function createUiRouter(options) {
|
|
|
3714
3725
|
if (typed.type === "error") {
|
|
3715
3726
|
push("error", {
|
|
3716
3727
|
code: "CHAT_TURN_FAILED",
|
|
3717
|
-
message: typed.error
|
|
3728
|
+
message: formatUserFacingError(typed.error)
|
|
3718
3729
|
});
|
|
3719
3730
|
return;
|
|
3720
3731
|
}
|
|
@@ -3724,7 +3735,7 @@ function createUiRouter(options) {
|
|
|
3724
3735
|
if (latestRun?.state === "failed") {
|
|
3725
3736
|
push("error", {
|
|
3726
3737
|
code: "CHAT_TURN_FAILED",
|
|
3727
|
-
message: latestRun.error ?? "chat run failed"
|
|
3738
|
+
message: formatUserFacingError(latestRun.error ?? "chat run failed")
|
|
3728
3739
|
});
|
|
3729
3740
|
return;
|
|
3730
3741
|
}
|
|
@@ -3733,7 +3744,7 @@ function createUiRouter(options) {
|
|
|
3733
3744
|
} catch (error) {
|
|
3734
3745
|
push("error", {
|
|
3735
3746
|
code: "CHAT_TURN_FAILED",
|
|
3736
|
-
message:
|
|
3747
|
+
message: formatUserFacingError(error)
|
|
3737
3748
|
});
|
|
3738
3749
|
} finally {
|
|
3739
3750
|
controller.close();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextclaw/server",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.10",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Nextclaw UI/API server.",
|
|
6
6
|
"type": "module",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"@hono/node-server": "^1.13.3",
|
|
19
19
|
"hono": "^4.6.2",
|
|
20
20
|
"ws": "^8.18.0",
|
|
21
|
-
"@nextclaw/openclaw-compat": "0.2.
|
|
22
|
-
"@nextclaw/
|
|
23
|
-
"@nextclaw/
|
|
21
|
+
"@nextclaw/openclaw-compat": "0.2.5",
|
|
22
|
+
"@nextclaw/runtime": "0.1.5",
|
|
23
|
+
"@nextclaw/core": "0.7.6"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/node": "^20.17.6",
|