MCPcopy Create free account
hub / github.com/apache/maka / boundedText

Function boundedText

packages/runtime-host/src/protocol/artifact.ts:649–657  ·  view source on GitHub ↗
(value: unknown, label: string, maxBytes: number, allowEmpty = false)

Source from the content-addressed store, hash-verified

647}
648
649function boundedText(value: unknown, label: string, maxBytes: number, allowEmpty = false): string {
650 if (typeof value !== 'string' || (!allowEmpty && value.length === 0)) {
651 throw invalidProtocolFrame(`Invalid ${label}`);
652 }
653 if (Buffer.byteLength(value, 'utf8') > maxBytes) {
654 throw invalidProtocolFrame(`Invalid ${label}`);
655 }
656 return value;
657}
658
659function boundedIngestText(value: unknown, label: string, maxBytes: number): string {
660 const text = boundedText(value, label, maxBytes);

Callers 7

decodeArtifactQueryInputFunction · 0.70
decodeArtifactProjectionFunction · 0.70
decodeTextPreviewFunction · 0.70
decodeBinaryPreviewFunction · 0.70
boundedIngestTextFunction · 0.70

Calls 1

invalidProtocolFrameFunction · 0.85

Tested by

no test coverage detected