(value: unknown)
| 603 | } |
| 604 | |
| 605 | function 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 | |
| 619 | function decodeBinaryPreview(value: unknown): ArtifactBinaryPreview { |
| 620 | const preview = requireRecord(value, 'artifact binary preview'); |
no test coverage detected