Documentation
¶
Overview ¶
Package envelope defines domain-neutral JSON tool result envelopes and helpers.
Index ¶
- func AppendLimitHint(next []string, atLimit bool, hint string) []string
- func CapSlice[T any](items []T, limit int) (out []T, truncated bool)
- func Hint(tool string, parts ...string) string
- func HintParam(key, value string) string
- func MarshalIndent(env *Envelope) ([]byte, error)
- func MarshalText(env *Envelope) (string, error)
- func PreviewField(text string, limit int) (preview string, truncated bool)
- func SummarizeCount(count int, unit string, next []string) (summary string, out []string)
- func TruncateText(text string, limit int) (preview string, truncated bool)
- type BoundList
- type Builder
- func (b *Builder) AnswerContext(context string) *Builder
- func (b *Builder) Build() Envelope
- func (b *Builder) Data(data any) *Builder
- func (b *Builder) Diagnostic(items ...Diagnostic) *Builder
- func (b *Builder) Method(name string) *Builder
- func (b *Builder) NextActions(actions ...NextAction) *Builder
- func (b *Builder) NextHints(hints ...string) *Builder
- func (b *Builder) Quality(signals ...QualitySignal) *Builder
- func (b *Builder) Subject(kind, id string) *Builder
- func (b *Builder) SubjectRole(kind, id, role string) *Builder
- func (b *Builder) Subjects(subjects ...Subject) *Builder
- func (b *Builder) Summary(summary string) *Builder
- func (b *Builder) Tool(name string) *Builder
- type Diagnostic
- type Envelope
- type NextAction
- type QualitySignal
- type Subject
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendLimitHint ¶
AppendLimitHint appends a paging hint when a list response hit its limit.
func MarshalIndent ¶
MarshalIndent encodes an envelope as indented JSON.
func MarshalText ¶
MarshalText encodes an envelope as indented JSON text.
func PreviewField ¶
PreviewField is an alias for TruncateText.
func SummarizeCount ¶
SummarizeCount formats a count summary and optional next hints.
Types ¶
type BoundList ¶
BoundList is a capped slice with truncation metadata.
func CapSliceMeta ¶
CapSliceMeta returns a capped slice with truncation metadata.
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder constructs an Envelope fluently.
func (*Builder) AnswerContext ¶
AnswerContext sets concise LLM-facing synthesis context.
func (*Builder) Diagnostic ¶
func (b *Builder) Diagnostic(items ...Diagnostic) *Builder
Diagnostic appends diagnostics.
func (*Builder) NextActions ¶
func (b *Builder) NextActions(actions ...NextAction) *Builder
NextActions sets structured continuations.
func (*Builder) NextHints ¶
NextHints sets string continuation hints and derives structured next actions.
func (*Builder) Quality ¶
func (b *Builder) Quality(signals ...QualitySignal) *Builder
Quality appends quality signals.
func (*Builder) SubjectRole ¶
SubjectRole appends one subject with a role.
type Diagnostic ¶
type Diagnostic struct {
Code string `json:"code,omitempty"`
Message string `json:"message,omitempty"`
Severity string `json:"severity,omitempty"`
Detail any `json:"detail,omitempty"`
}
Diagnostic carries implementation detail kept separate from answer content.
type Envelope ¶
type Envelope struct {
OK bool `json:"ok"`
Tool string `json:"tool,omitempty"`
Method string `json:"method,omitempty"`
Summary string `json:"summary,omitempty"`
AnswerContext string `json:"answer_context,omitempty"`
Subjects []Subject `json:"subjects,omitempty"`
Data any `json:"data,omitempty"`
NextActions []NextAction `json:"next_actions,omitempty"`
Next []string `json:"next,omitempty"`
Quality []QualitySignal `json:"quality_signals,omitempty"`
Diagnostics []Diagnostic `json:"diagnostics,omitempty"`
Error string `json:"error,omitempty"`
}
Envelope is the agent-facing tool result payload.
type NextAction ¶
type NextAction struct {
Tool string `json:"tool,omitempty"`
Hint string `json:"hint,omitempty"`
Args map[string]string `json:"args,omitempty"`
}
NextAction describes a capability or continuation the caller can invoke next.
func HintsToActions ¶
func HintsToActions(hints ...string) []NextAction
HintsToActions converts string hints into structured next actions.
func NextActionFromHint ¶
func NextActionFromHint(hint string) NextAction
NextActionFromHint parses a simple `tool key=value` hint into a NextAction.
type QualitySignal ¶
type QualitySignal struct {
Name string `json:"name"`
Value any `json:"value,omitempty"`
Score float64 `json:"score,omitempty"`
Note string `json:"note,omitempty"`
}
QualitySignal carries optional confidence or completeness metadata.