Documentation
¶
Index ¶
- Constants
- func ElicitHint(args map[string]any) string
- func ExtractHint(argsJSON, toolName string) string
- func ImageDimensions(data []byte, mime string) (int, int, error)
- func IntArg(args map[string]any, key string) (int, bool)
- func IntValue(value any) (int, bool)
- func IsBackgroundOrigin(ctx context.Context) bool
- func IsImageResult(s string) bool
- func NonNegIntArg(args map[string]any, key string) (value int, present bool, err error)
- func OptionalIntArg(args map[string]any, key string) (int, bool, error)
- func PositiveIntArg(args map[string]any, key string) (value int, present bool, err error)
- func Progress(ctx context.Context) func(text string)
- func ReportUsage(ctx context.Context, d UsageDelta)
- func StaticEffect(effect Effect) func(map[string]any) Effect
- func TodoHint(argsJSON string) string
- func WithBackgroundOrigin(ctx context.Context) context.Context
- func WithProgressCall(ctx context.Context, callID string) context.Context
- func WithProgressSink(ctx context.Context, fn func(callID, text string)) context.Context
- func WithUsageSink(ctx context.Context, fn func(UsageDelta)) context.Context
- type Effect
- type ElicitAction
- type ElicitField
- type ElicitRequest
- type ElicitResult
- type Elicitation
- type TodoItem
- type Tool
- type ToolCall
- type UsageDelta
Constants ¶
const MaxImageDimension = 8000
MaxImageDimension matches the strictest input-image dimension accepted by supported model providers. Rejecting larger tool results keeps an otherwise valid image from poisoning the next model request.
const MaxImageResultBytes = 8 * 1024 * 1024
MaxImageResultBytes bounds a data-URL tool result that may be forwarded to the model as an image attachment; larger payloads stay ordinary text and fall under normal output truncation.
Variables ¶
This section is empty.
Functions ¶
func ElicitHint ¶ added in v0.10.1
ElicitHint summarizes an elicit tool call as its first question plus a count of the rest; shared by every surface that labels tool calls.
func ExtractHint ¶ added in v0.7.0
func ImageDimensions ¶ added in v0.10.4
ImageDimensions reads image dimensions without decoding the full bitmap.
func IsBackgroundOrigin ¶ added in v0.11.2
func IsImageResult ¶ added in v0.10.0
IsImageResult reports whether a tool result is a well-formed image data URL safe to send as an input image: declared type matches the decoded bytes, so a tool echoing an arbitrary data:-prefixed string cannot poison the request.
func NonNegIntArg ¶ added in v0.6.9
func OptionalIntArg ¶ added in v0.6.9
func PositiveIntArg ¶ added in v0.6.9
func Progress ¶ added in v0.11.2
Progress returns a reporter for transient status text from a running tool call, or nil when no sink is installed. Reported text is display-only and never reaches the model.
func ReportUsage ¶ added in v0.11.2
func ReportUsage(ctx context.Context, d UsageDelta)
ReportUsage reports internally incurred model usage; a no-op without a sink.
func WithBackgroundOrigin ¶ added in v0.11.2
WithBackgroundOrigin marks ctx as belonging to a detached background agent run, so session-scoped state (e.g. file freshness) can tell its tool calls apart from the main agent's.
func WithProgressCall ¶ added in v0.11.2
WithProgressCall tags ctx with the tool-call ID that subsequent Progress reports attribute to.
func WithProgressSink ¶ added in v0.11.2
WithProgressSink installs a UI callback that receives transient status text from running tool calls, keyed by tool-call ID.
func WithUsageSink ¶ added in v0.11.2
func WithUsageSink(ctx context.Context, fn func(UsageDelta)) context.Context
WithUsageSink installs a callback that credits model usage a tool incurred internally (e.g. a subagent run) to the session's accounting.
Types ¶
type ElicitAction ¶ added in v0.10.1
type ElicitAction string
const ( ElicitAccept ElicitAction = "accept" ElicitDecline ElicitAction = "decline" ElicitCancel ElicitAction = "cancel" )
type ElicitField ¶ added in v0.10.1
type ElicitField struct {
Name string `json:"name"`
Type string `json:"type,omitempty"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Required bool `json:"required,omitempty"`
Enum []string `json:"enum,omitempty"`
EnumDescriptions []string `json:"enum_descriptions,omitempty"`
EnumPreviews []string `json:"enum_previews,omitempty"`
// Strict marks enum values as a closed set (MCP requestedSchema contract):
// UIs must not offer a free-text alternative. The elicit tool's options
// are advisory and stay non-strict.
Strict bool `json:"strict,omitempty"`
// Multiple allows selecting several enum values; the content value is then
// a []string instead of a string. Never produced by the MCP bridge.
Multiple bool `json:"multiple,omitempty"`
Default any `json:"default,omitempty"`
}
ElicitField mirrors the MCP elicitation primitive schema: a flat, typed value request (string, number, integer, or boolean; optionally enum- constrained). EnumDescriptions extends the MCP shape with per-option help text; bridges to MCP drop it.
type ElicitRequest ¶ added in v0.10.1
type ElicitRequest struct {
Message string `json:"message"`
Fields []ElicitField `json:"fields,omitempty"`
}
type ElicitResult ¶ added in v0.10.1
type ElicitResult struct {
Action ElicitAction `json:"action"`
Content map[string]any `json:"content,omitempty"`
}
type Elicitation ¶ added in v0.6.2
type Elicitation struct {
Elicit func(ctx context.Context, req ElicitRequest) (ElicitResult, error)
Confirm func(ctx context.Context, message string) (bool, error)
}
type TodoItem ¶ added in v0.10.1
func ParseTodoItems ¶ added in v0.10.1
ParseTodoItems extracts the checklist from a todo tool call's arguments so UIs can render it richly instead of showing the raw JSON.
type Tool ¶
type Tool struct {
Name string
Description string
Parameters map[string]any
Execute func(ctx context.Context, args map[string]any) (string, error)
Hidden bool
Effect func(args map[string]any) Effect
// Timeout replaces the harness default tool timeout for this tool.
// An explicitly configured Config.ToolTimeout takes precedence; negative
// values disable the deadline.
Timeout time.Duration
}