@@ -22,11 +22,12 @@ import {
2222} from "openclaw/plugin-sdk/number-runtime" ;
2323import { readFiniteNumberParam , readPositiveIntegerParam } from "openclaw/plugin-sdk/param-readers" ;
2424import type { AnyAgentTool , OpenClawConfig } from "openclaw/plugin-sdk/plugin-entry" ;
25- import { readRegularFile , wrapExternalContent } from "openclaw/plugin-sdk/security-runtime" ;
2625import {
27- DEFAULT_MAX_LIVE_TOOL_RESULT_CHARS ,
28- truncateUtf16Safe ,
29- } from "openclaw/plugin-sdk/text-utility-runtime" ;
26+ readRegularFile ,
27+ truncateSanitizedExternalContent ,
28+ wrapExternalContent ,
29+ } from "openclaw/plugin-sdk/security-runtime" ;
30+ import { DEFAULT_MAX_LIVE_TOOL_RESULT_CHARS } from "openclaw/plugin-sdk/text-utility-runtime" ;
3031import { validateSupportedA2UIJsonl } from "./a2ui-jsonl.js" ;
3132import { normalizeCanvasSnapshotFileExtension , parseCanvasSnapshotPayload } from "./cli-helpers.js" ;
3233import { CanvasToolSchema } from "./tool-schema.js" ;
@@ -89,13 +90,15 @@ function serializeCanvasEvalResult(result: unknown, maxChars: number): string {
8990 typeof value === "string" ? neutralizeCanvasMediaDirectives ( value ) : value ,
9091 ) ;
9192 const serialized = json ?? neutralizeCanvasMediaDirectives ( String ( result ) ) ;
92- if ( serialized . length <= maxChars ) {
93- return serialized ;
93+ const bounded = truncateSanitizedExternalContent ( serialized , maxChars ) ;
94+ if ( ! bounded . truncated ) {
95+ return bounded . text ;
9496 }
95- return ` ${ truncateUtf16Safe (
97+ const marked = truncateSanitizedExternalContent (
9698 serialized ,
9799 Math . max ( 0 , maxChars - CANVAS_EVAL_TRUNCATION_MARKER . length ) ,
98- ) } ${ CANVAS_EVAL_TRUNCATION_MARKER } `;
100+ ) ;
101+ return `${ marked . text } ${ CANVAS_EVAL_TRUNCATION_MARKER } ` ;
99102}
100103
101104function wrapCanvasEvalResult ( result : unknown ) : string {
0 commit comments