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

Function decodeTextPreview

packages/runtime-host/src/protocol/artifact.ts:605–617  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

603}
604
605function decodeTextPreview(value: unknown): ArtifactTextPreview {
606 const preview = requireRecord(value, 'artifact text preview');
607 if (preview.ok === true) {
608 const exact = requireExactRecord(preview, 'artifact text preview', ['ok', 'text']);
609 return {
610 ok: true,
611 text: boundedText(exact.text, 'artifact text', ARTIFACT_PREVIEW_MAX_BYTES, true),
612 };
613 }
614 const exact = requireExactRecord(preview, 'artifact text unavailable', ['ok', 'reason']);
615 if (exact.ok !== false) throw invalidProtocolFrame('Invalid artifact text preview outcome');
616 return { ok: false, reason: readFailureReason(exact.reason) };
617}
618
619function decodeBinaryPreview(value: unknown): ArtifactBinaryPreview {
620 const preview = requireRecord(value, 'artifact binary preview');

Callers 1

Calls 5

invalidProtocolFrameFunction · 0.85
readFailureReasonFunction · 0.85
requireRecordFunction · 0.70
requireExactRecordFunction · 0.70
boundedTextFunction · 0.70

Tested by

no test coverage detected