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

Function utf8String

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

Source from the content-addressed store, hash-verified

1001}
1002
1003function utf8String(value: unknown, label: string, maxBytes: number, allowEmpty = false): string {
1004 if (
1005 typeof value !== 'string' ||
1006 (!allowEmpty && value.length === 0) ||
1007 Buffer.byteLength(value, 'utf8') > maxBytes
1008 ) {
1009 throw invalidProtocolFrame(`Invalid ${label}`);
1010 }
1011 return value;
1012}
1013
1014function id(value: unknown, label: string): string {
1015 const decoded = utf8String(value, label, ID_MAX_BYTES);

Callers 12

decodeQueryInputFunction · 0.85
decodeQueryResultFunction · 0.85
governanceItemFunction · 0.85
bundledItemFunction · 0.85
managedSourceItemFunction · 0.85
decodePreviewResultFunction · 0.85
invocableItemFunction · 0.85
idFunction · 0.85
wireIdentityFunction · 0.85
stringArrayFunction · 0.85

Calls 1

invalidProtocolFrameFunction · 0.85

Tested by

no test coverage detected