block

package
v0.4.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 2 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package block defines the reserved content-block envelope (xyz-spec §12.7): a result value whose JSON is an object with the single key "content", holding items of exactly the shapes

{"type": "text", "text": "..."}
{"type": "image", "mimeType": "...", "data": "<base64>"}

Handlers may return block.Envelope directly, or any equivalent shape — the frontends detect the envelope duck-typed, so the reserve is not tied to this package. Binary payloads are base64 on the wire, never bare bytes; use block.Image to construct them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Envelope

type Envelope struct {
	Content []Item `json:"content"`
}

Envelope is the reserved block envelope shape.

func DetectJSON

func DetectJSON(raw []byte) (*Envelope, bool)

DetectJSON reports whether raw is exactly the reserved envelope and, if so, returns the decoded envelope. Anything else — extra top-level keys, item shapes beyond text/image, unknown types — is not the envelope.

type Item

type Item struct {
	Type     string `json:"type"`
	Text     string `json:"text,omitempty"`
	MIMEType string `json:"mimeType,omitempty"`
	Data     string `json:"data,omitempty"`
}

Item is one block in the envelope. Use the Text/Image constructors; the struct is exported for direct literal use by handlers.

func Image

func Image(mimeType string, data []byte) Item

Image constructs an image block; data is base64-encoded on the wire.

func Text

func Text(s string) Item

Text constructs a text block.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL