@nextclaw/server 0.15.16 → 0.15.18
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 +13 -6
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
2
|
import { compress } from "hono/compress";
|
|
3
3
|
import { serve } from "@hono/node-server";
|
|
4
|
-
import { AccessManager, PanelAppError, isPanelAppError, isPreferenceError, isProjectError, isServiceAppError, isSessionContextCompactionError, isSessionMessageCursorError, isSessionSettingsError } from "@nextclaw/kernel";
|
|
4
|
+
import { AccessManager, PanelAppError, injectUiContentParamsBootstrap, isPanelAppError, isPreferenceError, isProjectError, isServiceAppError, isSessionContextCompactionError, isSessionMessageCursorError, isSessionSettingsError } from "@nextclaw/kernel";
|
|
5
5
|
import { WebSocket, WebSocketServer } from "ws";
|
|
6
6
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
7
7
|
import { mkdir, open, readFile, readdir, realpath, stat } from "node:fs/promises";
|
|
@@ -461,6 +461,15 @@ const ingressKeys = {
|
|
|
461
461
|
}
|
|
462
462
|
};
|
|
463
463
|
//#endregion
|
|
464
|
+
//#region ../nextclaw-shared/src/utils/ui-content-params.utils.ts
|
|
465
|
+
const UI_CONTENT_PARAMS_HOST_CONTRACT = {
|
|
466
|
+
bootstrapQueryParam: "nextclawContentParams",
|
|
467
|
+
bootstrapQueryValue: "1",
|
|
468
|
+
maxDepth: 32,
|
|
469
|
+
maxSerializedBytes: 64 * 1024,
|
|
470
|
+
windowNamePrefix: "nextclaw:content-params:v1:"
|
|
471
|
+
};
|
|
472
|
+
//#endregion
|
|
464
473
|
//#region src/features/agents/stores/agents.store.ts
|
|
465
474
|
function listAgents(configPath) {
|
|
466
475
|
const config = loadConfig(configPath);
|
|
@@ -5022,10 +5031,7 @@ async function readFilePreviewBytes(params) {
|
|
|
5022
5031
|
const { maxBytes, resolvedPath, sizeBytes, targetLine } = params;
|
|
5023
5032
|
const fileHandle = await open(resolvedPath, "r");
|
|
5024
5033
|
try {
|
|
5025
|
-
const { offset, startLine } = (targetLine
|
|
5026
|
-
offset: 0,
|
|
5027
|
-
startLine: 1
|
|
5028
|
-
} : targetLine ? await findPreviewWindowLocation({
|
|
5034
|
+
const { offset, startLine } = (targetLine && targetLine > 1 && sizeBytes > maxBytes ? await findPreviewWindowLocation({
|
|
5029
5035
|
fileHandle,
|
|
5030
5036
|
maxBytes,
|
|
5031
5037
|
sizeBytes,
|
|
@@ -5483,7 +5489,8 @@ var ServerPathRoutesController = class {
|
|
|
5483
5489
|
sendContent = async (c, options) => {
|
|
5484
5490
|
try {
|
|
5485
5491
|
const payload = await readServerPathContent(options);
|
|
5486
|
-
|
|
5492
|
+
const content = payload.contentType.startsWith("text/html") && c.req.query(UI_CONTENT_PARAMS_HOST_CONTRACT.bootstrapQueryParam) === UI_CONTENT_PARAMS_HOST_CONTRACT.bootstrapQueryValue ? injectUiContentParamsBootstrap(payload.content.toString("utf8")) : payload.content;
|
|
5493
|
+
return new Response(content, { headers: {
|
|
5487
5494
|
"content-type": payload.contentType,
|
|
5488
5495
|
"cache-control": "no-store",
|
|
5489
5496
|
"content-disposition": `inline; filename*=UTF-8''${encodeContentDispositionFileName(payload.fileName)}`
|