content

package
v0.59.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package content owns the ordered text, media, and citation values shared by chat and tool output.

Example
package main

import (
	"fmt"

	"github.com/Tangerg/scope/core/content"
)

func main() {
	block := content.Block{Kind: content.Text, Text: "Report", Citations: []content.Citation{{Source: content.CitationSource{Kind: content.CitationSourceReference, Value: "report:2026"}}}}
	copy := block.Clone()
	copy.Citations[0].Source.Value = "another report"
	fmt.Println(block.Validate(), block.Citations[0].Source.Value)
}
Output:
<nil> report:2026

Index

Examples

Constants

View Source
const (
	Text  = "text"
	Media = "media"
)

Variables

View Source
var ErrInvalidBlock = errors.New("content: invalid block")
View Source
var ErrInvalidCitation = errors.New("content: invalid citation")

Functions

This section is empty.

Types

type Block

type Block struct {
	Kind      Kind         `json:"kind"`
	Text      string       `json:"text,omitempty"`
	Media     *media.Media `json:"media,omitzero"`
	Citations []Citation   `json:"citations,omitempty"`
	Metadata  metadata.Map `json:"metadata,omitzero"`
}

Block carries content, never a control instruction, tool call, or nested result.

func (Block) Clone

func (b Block) Clone() Block

func (Block) JSONSchemaModel

func (Block) JSONSchemaModel() any

func (Block) MarshalJSON

func (b Block) MarshalJSON() ([]byte, error)

func (*Block) UnmarshalJSON

func (b *Block) UnmarshalJSON(data []byte) error

func (Block) Validate

func (b Block) Validate() error

type Citation

type Citation struct {
	Source CitationSource `json:"source"`
	Title  string         `json:"title,omitempty"`
	Quote  string         `json:"quote,omitempty"`
}

Citation is the portable identity and quoted evidence attached to a text part. Exact provider coordinates remain available through response metadata.

func (Citation) Validate

func (c Citation) Validate() error

type CitationSource

type CitationSource struct {
	Kind  CitationSourceKind `json:"kind"`
	Value string             `json:"value"`
}

CitationSource identifies cited material without adopting a provider's location taxonomy. Provider-native page, block, and character coordinates remain in the preserved native response. URI sources may use any scheme, including file and urn, and may include a fragment. They require a non-empty target and contain no whitespace. Validation identifies material; it never resolves the URI or grants permission to access it.

func (CitationSource) Validate

func (c CitationSource) Validate() error

type CitationSourceKind

type CitationSourceKind string

CitationSourceKind distinguishes an absolute URI from an opaque source reference whose interpretation remains with the provider or host.

const (
	CitationSourceURI       CitationSourceKind = "uri"
	CitationSourceReference CitationSourceKind = "reference"
)

func (CitationSourceKind) Valid

func (c CitationSourceKind) Valid() bool

type Kind

type Kind string

Jump to

Keyboard shortcuts

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