Documentation
¶
Overview ¶
Package htmlpreview provides the chatagent tool for sandboxed HTML artifacts.
Index ¶
- Constants
- func ActiveToolNames() []string
- func FormatResult(parsed ParsedArgs) string
- func HTMLAndTitleFromArguments(raw string) (html, title string)
- func HashHTML(html string) string
- func PrepareDocument(html, title string) string
- func Register(registry *tool.Registry) error
- type ParsedArgs
- type ResultMeta
- type Tool
Constants ¶
const ( // ToolName is the agent tool name for presenting HTML artifacts. ToolName = "present_html" // MaxHTMLBytes rejects html arguments above this size. MaxHTMLBytes = 256 << 10 // DefaultTitle is used when the model omits title. DefaultTitle = "HTML" // PreviewCSP is injected into the preview document. It is the network lock // complementing iframe sandbox="allow-scripts" (without allow-same-origin). PreviewCSP = "" /* 217-byte string literal not displayed */ )
Variables ¶
This section is empty.
Functions ¶
func ActiveToolNames ¶
func ActiveToolNames() []string
ActiveToolNames returns the default htmlpreview tool names.
func FormatResult ¶
func FormatResult(parsed ParsedArgs) string
FormatResult builds the stub tool result shown to the model and stored as stdout.
func HTMLAndTitleFromArguments ¶
HTMLAndTitleFromArguments reads html and title from a tool-call JSON string without generating an id or re-validating size (for UI / SSE hydration).
func PrepareDocument ¶
PrepareDocument wraps html as a complete document with CSP meta in <head>.
Types ¶
type ParsedArgs ¶
ParsedArgs is the validated present_html payload.
type ResultMeta ¶
ResultMeta is parsed from a present_html stub result.
func ParseResultMeta ¶
func ParseResultMeta(text string) ResultMeta
ParseResultMeta extracts id/title from a present_html stub result.
type Tool ¶
type Tool struct{}
Tool upserts a session HTML artifact. The full document lives in the tool-call arguments; the result is a short stub for the model.
func (Tool) Description ¶
Description explains the tool to the model.
func (Tool) Execute ¶
func (Tool) Execute(_ context.Context, callID string, args map[string]any, _ tool.UpdateHandler) (msg.ToolResultMessage, error)
Execute validates html, assigns an id when missing, and returns a stub summary.
func (Tool) Parameters ¶
Parameters returns the JSON schema for tool arguments.