renderrefs

package
v0.60.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package renderrefs defines the sideband protocol for lifting references from tool output so the chat UI can render a rich card instead of a raw UUID.

The protocol is currently dormant: the former producers (the deleted stella CLI commands) are gone, and no production code calls Emit today. The consumer pipeline still runs Extract in the agent runner / LCM / Feishu paths so native tools can adopt Emit later without a storage migration. References are derived data: nothing is stored that a GET on the entity could not re-derive, so stale previews never lie — the frontend always hydrates by id.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Emit

func Emit(w io.Writer, ref Reference) error

Emit writes one sentinel line for ref to w (typically a tool's stderr). It is a no-op when ref carries no id/type, so callers can emit unconditionally without guarding on partial data.

Types

type Preview

type Preview struct {
	Title  string `json:"title,omitempty"`
	Status string `json:"status,omitempty"`
}

Preview is a best-effort snapshot used only as a loading placeholder. It is never trusted: the frontend hydrates the live entity by id, so a forged or stale preview cannot grant access or misrepresent state past first paint.

type Reference

type Reference struct {
	V       int      `json:"v"`
	Type    string   `json:"type"`               // "task" | "goal" | "recally_article" | future
	ID      string   `json:"id"`                 // entity UUID
	Intent  string   `json:"intent,omitempty"`   // "created" (default emitted) | "referenced"
	AgentID string   `json:"agent_id,omitempty"` // owning agent, for deep links to agent-scoped pages (task/goal)
	Preview *Preview `json:"preview,omitempty"`
}

Reference is one renderable entity reference. Type and ID are the only load- bearing fields; everything else is a hint.

func Extract

func Extract(text string) (clean string, refs []Reference)

Extract pulls every sentinel reference out of text and returns the text with those lines removed. Lines are matched anchored at their start (after leading whitespace), so a sentinel survives stdout/stderr interleaving and tail truncation as long as the line itself is intact. Malformed sentinel lines are dropped silently rather than surfaced as garbage to the user.

Jump to

Keyboard shortcuts

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