tools

package
v0.0.0-...-c474aa3 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultReadLineLimit       = 1000
	DefaultReadByteLimit       = 64 * 1024
	DefaultReadOutputCharLimit = 100000
	DefaultToolOutputLimit     = 64 * 1024
	DefaultBashTimeout         = 5 * time.Minute
	MaxBashTimeout             = 10 * time.Minute
)
View Source
const MaxPresentedMediaItems = 20
View Source
const MaxRemoteMediaBytes = 25 * 1024 * 1024

Variables

This section is empty.

Functions

func AllowedMilestoneKey

func AllowedMilestoneKey(runtime Runtime, requested string) (string, error)

func ArgumentByteLimits

func ArgumentByteLimits() map[string]int

func AssignedMilestoneKey

func AssignedMilestoneKey(runtime Runtime) string

func AssignedTaskRef

func AssignedTaskRef(runtime Runtime) string

func BoolString

func BoolString(value bool) string

func BuildToolResult

func BuildToolResult(req Request, result Result) (domain.ToolResult, string, error)

func ChatIDFromContext

func ChatIDFromContext(ctx context.Context) (id.ID, bool)

func CompactModelTextForPart

func CompactModelTextForPart(part domain.Part, diff string, limits CompactFormatLimits) (string, bool)

CompactModelTextForPart returns a bounded text-only rendering of a stored result for compaction.

func DefaultSummarizeResult

func DefaultSummarizeResult(req Request, result Result) (string, string)

func DefinitionFor

func DefinitionFor(kind ID, runtime Runtime) (provider.ToolDefinition, bool)

DefinitionFor returns the provider tool definition for a registered tool.

func Definitions

func Definitions(runtime Runtime) []provider.ToolDefinition

func DeniedMessage

func DeniedMessage(err error) string

func DisplayTextForPart

func DisplayTextForPart(part domain.Part) (string, bool)

func DisplayTextForStored

func DisplayTextForStored(tool ID, payload any) string

func EnsureSessionTmpDir

func EnsureSessionTmpDir(settings accesssettings.Settings) error

func FinalizeResult

func FinalizeResult(ctx context.Context, runtime Runtime, req Request, result Result) (domain.ToolResult, string, error)

func FirstArg

func FirstArg(args map[string]string, keys ...string) string

func FormatMilestoneOutput

func FormatMilestoneOutput(result MilestonePlanStoredResult) string

func FormatTaskID

func FormatTaskID(key string) string

func FormatTaskOutput

func FormatTaskOutput(result TaskListStoredResult) string

func IsBuiltinID

func IsBuiltinID(id ID) bool

func IsDenied

func IsDenied(err error) bool

func IsHTTPURL

func IsHTTPURL(input string) bool

func ListDirectory

func ListDirectory(abs string) ([]string, error)

func MCPImageStoredResultForPart

func MCPImageStoredResultForPart(part domain.Part) ([]byte, string, bool)

MCPImageStoredResultForPart returns the first complete image emitted by a successful MCP tool call. Binary output remains out of model-visible text.

func MilestonePlanForKey

func MilestonePlanForKey(plan planning.Plan, ref string) planning.Plan

func ModelTextForPart

func ModelTextForPart(part domain.Part, diff string) (string, bool)

func NormalizeMediaArgs

func NormalizeMediaArgs(args map[string]string) (map[string]string, error)

func NormalizePathInput

func NormalizePathInput(raw string) string

func NormalizePathOrHTTPURL

func NormalizePathOrHTTPURL(input string) (string, error)

func ParseFlexibleInt

func ParseFlexibleInt(raw string) (int, error)

func Preview

func Preview(req Request) string

func ReadTextFile

func ReadTextFile(abs string, lineLimit int, byteLimit int) (string, bool, error)

func ReadablePath

func ReadablePath(root string, raw string) (abs string, label string, err error)

func Register

func Register(tool Tool, spec ToolSpec)

func RequireExecControl

func RequireExecControl(runtime Runtime) (execruntime.Control, error)

func RequireService

func RequireService[T any](runtime Runtime, key string) (T, error)

func ResolvePath

func ResolvePath(runtime Runtime, raw string, kind accesssettings.AccessKind) (abs string, label string, err error)

ResolvePath translates a path from the session's sandbox namespace to the host namespace and enforces the requested access against the resolved target.

func ScopedMilestonePlan

func ScopedMilestonePlan(runtime Runtime, plan planning.Plan) planning.Plan

func ScopedTasks

func ScopedTasks(runtime Runtime, tasks []planning.Task) []planning.Task

func ShellResult

func ShellResult(ctx context.Context, dir string, timeout time.Duration, command string, settings accesssettings.Settings) (string, int, error)

func StoredResultInfoForPart

func StoredResultInfoForPart(part domain.Part) (ID, StoredResultStatus, bool)

func SummarizePaths

func SummarizePaths(paths []string, limit int) string

func SummarizeResult

func SummarizeResult(req Request, result Result) (string, string)

func TaskScopeAllows

func TaskScopeAllows(runtime Runtime, taskID string) error

func ToolCall

func ToolCall(req Request) provider.ToolCall

func TruncateText

func TruncateText(input string, limit int) (string, bool)

func WithChatID

func WithChatID(ctx context.Context, chatID id.ID) context.Context

func WorkspaceDir

func WorkspaceDir(root string, raw string) (abs string, rel string, err error)

func WorkspacePath

func WorkspacePath(root string, raw string) (abs string, rel string, err error)

func WriteFile

func WriteFile(abs string, data []byte, mode fs.FileMode) error

func WriteTextFile

func WriteTextFile(abs string, content string, mode fs.FileMode) error

Types

type ActionRoute

type ActionRoute struct {
	Action    string
	Tool      ID
	FixedArgs map[string]string
}

ActionRoute maps one model-facing resource action to an existing operation. Keeping the operation as a normal registered tool preserves its validation, policy, result, and stored-history behavior during migrations.

type ActionTool

type ActionTool struct {
	Kind              ID
	Routes            []ActionRoute
	BypassPermissions bool
	// RequirePersistedChat hides and rejects resources whose results need a
	// durable client-visible destination.
	RequirePersistedChat bool
	// DefaultAction accepts historical calls that predate the action field when
	// a canonical resource reuses an older single-operation name.
	DefaultAction string
}

ActionTool exposes a coherent resource API while delegating each action to an existing operation handler. Its Parameters schema must contain an action string enum; unavailable actions are removed from that enum at definition time according to role, interaction mode, session settings, and runtime availability.

func (ActionTool) BypassesPermission

func (t ActionTool) BypassesPermission() bool

func (ActionTool) Call

func (t ActionTool) Call(ctx context.Context, opts Options) (Result, error)

func (ActionTool) Definition

func (t ActionTool) Definition(runtime Runtime, spec ToolSpec) (ToolSpec, bool)

func (ActionTool) FinalizeResult

func (t ActionTool) FinalizeResult(ctx context.Context, runtime Runtime, req Request, result Result) (Result, error)

func (ActionTool) ID

func (t ActionTool) ID() ID

func (ActionTool) NormalizeArgs

func (t ActionTool) NormalizeArgs(args map[string]string) (map[string]string, error)

func (ActionTool) Presentation

func (t ActionTool) Presentation(req Request) Presentation

func (ActionTool) Preview

func (t ActionTool) Preview(req Request) string

func (ActionTool) SummarizeResult

func (t ActionTool) SummarizeResult(req Request, result Result) (string, string)

type BashStoredResult

type BashStoredResult struct {
	Command   string `json:"command"`
	Workdir   string `json:"workdir"`
	TimeoutMS int64  `json:"timeout_ms"`
	ExitCode  int    `json:"exit_code"`
	Output    string `json:"output,omitempty"`
}

type BrowserStoredResult

type BrowserStoredResult struct {
	Kind       string               `json:"kind"`
	SessionID  string               `json:"session_id,omitempty"`
	Path       string               `json:"path,omitempty"`
	Summary    string               `json:"summary,omitempty"`
	Text       string               `json:"text,omitempty"`
	Attachment *attachment.Metadata `json:"attachment,omitempty"`
}

func BrowserStoredResultForPart

func BrowserStoredResultForPart(part domain.Part) (BrowserStoredResult, bool)

type ChatListStoredResult

type ChatListStoredResult struct {
	Items []ChatStoredItem `json:"items,omitempty"`
}

type ChatStatusControl

type ChatStatusControl interface {
	SetChatActivity(context.Context, domain.ChatActivity) (domain.Chat, error)
}

ChatStatusControl updates durable descriptive activity for the owning chat.

func RequireChatStatusControl

func RequireChatStatusControl(runtime Runtime) (ChatStatusControl, error)

RequireChatStatusControl returns the activity capability for the current chat.

type ChatStoredItem

type ChatStoredItem struct {
	ID                 id.ID  `json:"id"`
	Title              string `json:"title"`
	Role               string `json:"role,omitempty"`
	Backend            string `json:"backend,omitempty"`
	InteractionMode    string `json:"interaction_mode,omitempty"`
	ModelID            string `json:"model_id,omitempty"`
	PermissionProfile  string `json:"permission_profile,omitempty"`
	State              string `json:"state,omitempty"`
	Archived           bool   `json:"archived,omitempty"`
	QueuedInputs       int    `json:"queued_inputs,omitempty"`
	ActiveMilestoneKey string `json:"active_milestone_key,omitempty"`
	AssignedTaskRef    string `json:"assigned_task_ref,omitempty"`
	StatusText         string `json:"status_text,omitempty"`
	Response           string `json:"response,omitempty"`
}

type CompactFormatLimits

type CompactFormatLimits struct {
	MaxBytes      int
	HeadLines     int
	TailLines     int
	ReadMaxLines  int
	ExecHeadLines int
	ExecTailLines int
}

CompactFormatLimits controls lossy text rendering for compaction prompts.

func DefaultCompactFormatLimits

func DefaultCompactFormatLimits() CompactFormatLimits

DefaultCompactFormatLimits returns conservative limits for compaction input.

type DeniedError

type DeniedError struct {
	Tool   ID
	Reason string
}

func (DeniedError) Error

func (e DeniedError) Error() string

type DeniedStoredResult

type DeniedStoredResult struct {
	Message string `json:"message"`
}

type DiagnosticReportStored

type DiagnosticReportStored struct {
	Diagnostics []DiagnosticStored `json:"diagnostics,omitempty"`
	Skipped     []string           `json:"skipped,omitempty"`
}

type DiagnosticStored

type DiagnosticStored struct {
	Source   string `json:"source,omitempty"`
	Path     string `json:"path,omitempty"`
	Line     int    `json:"line,omitempty"`
	Column   int    `json:"column,omitempty"`
	Severity string `json:"severity,omitempty"`
	Tool     string `json:"tool,omitempty"`
	Code     string `json:"code,omitempty"`
	Message  string `json:"message,omitempty"`
}

type EditStoredHunk

type EditStoredHunk struct {
	OldStart int      `json:"old_start"`
	NewStart int      `json:"new_start"`
	OldLines []string `json:"old_lines,omitempty"`
	NewLines []string `json:"new_lines,omitempty"`
}

type EditStoredResult

type EditStoredResult struct {
	Path             string                 `json:"path"`
	ReplaceAll       bool                   `json:"replace_all,omitempty"`
	Occurrences      int                    `json:"occurrences,omitempty"`
	Summary          string                 `json:"summary,omitempty"`
	Matcher          string                 `json:"matcher,omitempty"`
	Verification     string                 `json:"verification,omitempty"`
	Diagnostics      string                 `json:"diagnostics,omitempty"`
	DiagnosticReport DiagnosticReportStored `json:"diagnostic_report,omitempty"`
	Diff             string                 `json:"diff,omitempty"`
	Hunks            []EditStoredHunk       `json:"hunks,omitempty"`
	Truncated        bool                   `json:"truncated,omitempty"`
}

func EditStoredResultForPart

func EditStoredResultForPart(part domain.Part) (EditStoredResult, bool)

type ErrorStoredResult

type ErrorStoredResult struct {
	Message string `json:"message"`
}

type ExecListStoredItem

type ExecListStoredItem struct {
	ProcessID string `json:"process_id"`
	Command   string `json:"command"`
	State     string `json:"state"`
	TTY       bool   `json:"tty,omitempty"`
	ExitCode  *int   `json:"exit_code,omitempty"`
	Output    string `json:"output,omitempty"`
}

type ExecListStoredResult

type ExecListStoredResult struct {
	Scope   string               `json:"scope,omitempty"`
	Message string               `json:"message,omitempty"`
	Items   []ExecListStoredItem `json:"items,omitempty"`
}

type ExecProcess

type ExecProcess struct {
	ProcessID   string `json:"process_id"`
	Command     string `json:"command"`
	Workdir     string `json:"workdir,omitempty"`
	Shell       string `json:"shell,omitempty"`
	TTY         bool   `json:"tty,omitempty"`
	State       string `json:"state"`
	ExitCode    *int   `json:"exit_code,omitempty"`
	TimeoutMS   int64  `json:"timeout_ms,omitempty"`
	Output      string `json:"output,omitempty"`
	OutputBytes int    `json:"output_bytes,omitempty"`
	StdinClosed bool   `json:"stdin_closed,omitempty"`
	Lost        bool   `json:"lost,omitempty"`
}

type ExecStoredResult

type ExecStoredResult struct {
	ProcessID   string `json:"process_id"`
	Command     string `json:"command"`
	Comment     string `json:"comment,omitempty"`
	Workdir     string `json:"workdir,omitempty"`
	Shell       string `json:"shell,omitempty"`
	TTY         bool   `json:"tty,omitempty"`
	State       string `json:"state"`
	ExitCode    *int   `json:"exit_code,omitempty"`
	TimeoutMS   int64  `json:"timeout_ms,omitempty"`
	Output      string `json:"output,omitempty"`
	OutputMode  string `json:"output_mode,omitempty"`
	OutputBytes int    `json:"output_bytes,omitempty"`
	StdinClosed bool   `json:"stdin_closed,omitempty"`
	Message     string `json:"message,omitempty"`
}

type FileTracker

type FileTracker interface {
	TouchFile(context.Context, string, string)
}

type GlobStoredResult

type GlobStoredResult struct {
	Pattern   string   `json:"pattern"`
	BasePath  string   `json:"base_path,omitempty"`
	Matches   []string `json:"matches,omitempty"`
	Footer    string   `json:"footer,omitempty"`
	Truncated bool     `json:"truncated,omitempty"`
}

type GrepStoredResult

type GrepStoredResult struct {
	Pattern   string `json:"pattern"`
	BasePath  string `json:"base_path,omitempty"`
	Include   string `json:"include,omitempty"`
	Output    string `json:"output,omitempty"`
	Truncated bool   `json:"truncated,omitempty"`
}

type ID

type ID = domain.ToolKind
const (
	FileRead            ID = domain.ToolKindFileRead
	ViewImage           ID = domain.ToolKindViewImage
	ViewPDF             ID = domain.ToolKindViewPDF
	ShowImage           ID = domain.ToolKindShowImage
	ShowMedia           ID = domain.ToolKindShowMedia
	OfferFile           ID = domain.ToolKindOfferFile
	FileGlob            ID = domain.ToolKindFileGlob
	FileGrep            ID = domain.ToolKindFileGrep
	CodeSearch          ID = domain.ToolKindCodeSearch
	Lint                ID = domain.ToolKindLint
	Bash                ID = domain.ToolKindBash
	ExecCommand         ID = domain.ToolKindExecCommand
	ExecSession         ID = domain.ToolKindExecSession
	ExecStatus          ID = domain.ToolKindExecStatus
	ExecList            ID = domain.ToolKindExecList
	ExecWriteStdin      ID = domain.ToolKindExecWriteStdin
	ExecResize          ID = domain.ToolKindExecResize
	ExecTerminate       ID = domain.ToolKindExecTerminate
	ExecCleanup         ID = domain.ToolKindExecCleanup
	FileEdit            ID = domain.ToolKindFileEdit
	FileWrite           ID = domain.ToolKindFileWrite
	Task                ID = domain.ToolKindTask
	Question            ID = domain.ToolKindQuestion
	RequestUserInput    ID = domain.ToolKindRequestUserInput
	Milestones          ID = domain.ToolKindMilestones
	MilestoneList       ID = domain.ToolKindMilestoneList
	MilestoneAdd        ID = domain.ToolKindMilestoneAdd
	MilestoneUpdate     ID = domain.ToolKindMilestoneUpdate
	MilestoneDepend     ID = domain.ToolKindMilestoneDepend
	MilestoneArchive    ID = domain.ToolKindMilestoneArchive
	MilestoneDelete     ID = domain.ToolKindMilestoneDelete
	MilestonePlan       ID = domain.ToolKindMilestonePlan
	MilestoneWrite      ID = domain.ToolKindMilestoneWrite
	Tasks               ID = domain.ToolKindTasks
	TaskList            ID = domain.ToolKindTaskList
	TaskAddItems        ID = domain.ToolKindTaskAddItems
	TaskUpdateItem      ID = domain.ToolKindTaskUpdateItem
	TaskFetchNext       ID = domain.ToolKindTaskFetchNext
	TaskArchive         ID = domain.ToolKindTaskArchive
	TaskDelete          ID = domain.ToolKindTaskDelete
	TasksAdd            ID = domain.ToolKindTasksAdd
	TasksUpdate         ID = domain.ToolKindTasksUpdate
	Chats               ID = domain.ToolKindChats
	ChatList            ID = domain.ToolKindChatList
	ChatStart           ID = domain.ToolKindChatStart
	ChatSend            ID = domain.ToolKindChatSend
	ChatCancel          ID = domain.ToolKindChatCancel
	ChatArchive         ID = domain.ToolKindChatArchive
	ChatRename          ID = domain.ToolKindChatRename
	ChatCleanup         ID = domain.ToolKindChatCleanup
	ChatStatus          ID = domain.ToolKindChatStatus
	Sessions            ID = domain.ToolKindSessions
	SessionList         ID = domain.ToolKindSessionList
	SessionDelegate     ID = domain.ToolKindSessionDelegate
	SessionStart        ID = domain.ToolKindSessionStart
	Phone               ID = domain.ToolKindPhone
	PhoneDevice         ID = domain.ToolKindPhoneDevice
	PhoneLocation       ID = domain.ToolKindPhoneLocation
	PhoneContacts       ID = domain.ToolKindPhoneContacts
	PhoneCalendar       ID = domain.ToolKindPhoneCalendar
	PhoneMessages       ID = domain.ToolKindPhoneMessages
	PhoneCalls          ID = domain.ToolKindPhoneCalls
	PhoneNotifications  ID = domain.ToolKindPhoneNotifications
	PhoneClock          ID = domain.ToolKindPhoneClock
	PhoneClipboard      ID = domain.ToolKindPhoneClipboard
	PhoneApps           ID = domain.ToolKindPhoneApps
	PhoneMedia          ID = domain.ToolKindPhoneMedia
	PhoneShare          ID = domain.ToolKindPhoneShare
	PhoneOpen           ID = domain.ToolKindPhoneOpen
	PhonePhotos         ID = domain.ToolKindPhonePhotos
	PhonePhotosSearch   ID = domain.ToolKindPhonePhotosSearch
	PhonePhotosThumbs   ID = domain.ToolKindPhonePhotosThumbs
	PhonePhotoView      ID = domain.ToolKindPhonePhotoView
	PhonePhotoTransfer  ID = domain.ToolKindPhonePhotoTransfer
	Present             ID = domain.ToolKindPresent
	PresentContentOld   ID = domain.ToolKindPresentContentOld
	Skill               ID = domain.ToolKindSkill
	WebFetch            ID = domain.ToolKindWebFetch
	WebSearch           ID = domain.ToolKindWebSearch
	Memory              ID = domain.ToolKindMemory
	MCP                 ID = domain.ToolKindMCP
	BrowserStatus       ID = domain.ToolKindBrowserStatus
	BrowserTabs         ID = domain.ToolKindBrowserTabs
	BrowserNavigation   ID = domain.ToolKindBrowserNavigation
	BrowserPage         ID = domain.ToolKindBrowserPage
	BrowserInteract     ID = domain.ToolKindBrowserInteract
	BrowserCapture      ID = domain.ToolKindBrowserCapture
	BrowserNetwork      ID = domain.ToolKindBrowserNetwork
	BrowserTabList      ID = domain.ToolKindBrowserTabList
	BrowserTabNew       ID = domain.ToolKindBrowserTabNew
	BrowserTabClaim     ID = domain.ToolKindBrowserTabClaim
	BrowserTabSelect    ID = domain.ToolKindBrowserTabSelect
	BrowserTabClose     ID = domain.ToolKindBrowserTabClose
	BrowserNavigate     ID = domain.ToolKindBrowserNavigate
	BrowserBack         ID = domain.ToolKindBrowserBack
	BrowserForward      ID = domain.ToolKindBrowserForward
	BrowserReload       ID = domain.ToolKindBrowserReload
	BrowserSnapshot     ID = domain.ToolKindBrowserSnapshot
	BrowserFind         ID = domain.ToolKindBrowserFind
	BrowserClick        ID = domain.ToolKindBrowserClick
	BrowserFill         ID = domain.ToolKindBrowserFill
	BrowserType         ID = domain.ToolKindBrowserType
	BrowserPress        ID = domain.ToolKindBrowserPress
	BrowserSelect       ID = domain.ToolKindBrowserSelect
	BrowserCheck        ID = domain.ToolKindBrowserCheck
	BrowserUncheck      ID = domain.ToolKindBrowserUncheck
	BrowserHover        ID = domain.ToolKindBrowserHover
	BrowserDrag         ID = domain.ToolKindBrowserDrag
	BrowserScroll       ID = domain.ToolKindBrowserScroll
	BrowserWait         ID = domain.ToolKindBrowserWait
	BrowserUpload       ID = domain.ToolKindBrowserUpload
	BrowserEvaluate     ID = domain.ToolKindBrowserEvaluate
	BrowserScreenshot   ID = domain.ToolKindBrowserScreenshot
	BrowserImage        ID = domain.ToolKindBrowserImage
	BrowserPDF          ID = domain.ToolKindBrowserPDF
	BrowserConsole      ID = domain.ToolKindBrowserConsole
	BrowserRequests     ID = domain.ToolKindBrowserRequests
	BrowserRequest      ID = domain.ToolKindBrowserRequest
	BrowserResponseBody ID = domain.ToolKindBrowserResponseBody
	BrowserDownloads    ID = domain.ToolKindBrowserDownloads
	BrowserDownloadsOld ID = domain.ToolKindBrowserDownloadsOld
	BrowserDownload     ID = domain.ToolKindBrowserDownload
)

func BuiltinIDs

func BuiltinIDs() []ID

func RegisteredIDs

func RegisteredIDs() []ID

type LintStoredResult

type LintStoredResult struct {
	Path             string                 `json:"path"`
	Mode             string                 `json:"mode,omitempty"`
	Summary          string                 `json:"summary,omitempty"`
	Diagnostics      string                 `json:"diagnostics,omitempty"`
	DiagnosticReport DiagnosticReportStored `json:"diagnostic_report,omitempty"`
}

type MCPExecutor

type MCPExecutor interface {
	ExecuteTool(context.Context, string, string, map[string]any) (Result, error)
}

type MCPStoredContentItem

type MCPStoredContentItem struct {
	Type        string `json:"type"`
	Text        string `json:"text,omitempty"`
	URI         string `json:"uri,omitempty"`
	MIMEType    string `json:"mime_type,omitempty"`
	Description string `json:"description,omitempty"`
	Data        []byte `json:"data,omitempty"`
	Size        int64  `json:"size,omitempty"`
	SHA256      string `json:"sha256,omitempty"`
	Truncated   bool   `json:"truncated,omitempty"`
}

type MCPStoredResult

type MCPStoredResult struct {
	ServerID          string                 `json:"server_id"`
	ServerName        string                 `json:"server_name,omitempty"`
	ToolName          string                 `json:"tool_name"`
	StructuredContent string                 `json:"structured_content,omitempty"`
	IsError           bool                   `json:"is_error,omitempty"`
	NeedsInput        bool                   `json:"needs_input,omitempty"`
	InputRequests     string                 `json:"input_requests,omitempty"`
	RequestState      string                 `json:"request_state,omitempty"`
	Content           []MCPStoredContentItem `json:"content,omitempty"`
}

type MediaInput

type MediaInput struct {
	Path  string `json:"path"`
	Title string `json:"title,omitempty"`
}

func DecodeMediaInputs

func DecodeMediaInputs(value string) ([]MediaInput, error)

func MediaInputs

func MediaInputs(args map[string]string) ([]MediaInput, error)

type MilestonePlanStoredResult

type MilestonePlanStoredResult struct {
	Summary    string                `json:"summary,omitempty"`
	Milestones []MilestoneStoredItem `json:"milestones,omitempty"`
}

func MilestoneStoredResult

func MilestoneStoredResult(plan planning.Plan) MilestonePlanStoredResult

func MilestoneStoredResultWithTaskSummaries

func MilestoneStoredResultWithTaskSummaries(plan planning.Plan, summaries map[string]string) MilestonePlanStoredResult

type MilestoneStoredItem

type MilestoneStoredItem struct {
	ID                 id.ID  `json:"id,omitempty"`
	Key                string `json:"key,omitempty"`
	LegacyRef          string `json:"ref,omitempty"`
	Title              string `json:"title"`
	Status             string `json:"status"`
	Archived           bool   `json:"archived,omitempty"`
	Notes              string `json:"notes,omitempty"`
	DependsOnKey       string `json:"depends_on_key,omitempty"`
	LegacyDependsOnKey string `json:"depends_on_ref,omitempty"`
	OwnerChatID        string `json:"owner_chat_id,omitempty"`
	TaskSummary        string `json:"task_summary,omitempty"`
}

type OfferFileStoredResult

type OfferFileStoredResult struct {
	Token    string `json:"token"`
	Name     string `json:"name"`
	MIMEType string `json:"mime_type,omitempty"`
	Size     int64  `json:"size"`
	Title    string `json:"title,omitempty"`
	Summary  string `json:"summary,omitempty"`
}

type Options

type Options struct {
	Runtime Runtime
	Request Request
}

type PlanStoredStep

type PlanStoredStep struct {
	Step   string `json:"step"`
	Status string `json:"status"`
}

type PlanUpdateStoredResult

type PlanUpdateStoredResult struct {
	Explanation string           `json:"explanation,omitempty"`
	Steps       []PlanStoredStep `json:"steps"`
}

PlanUpdateStoredResult preserves rendering for historical plan-update parts. Koder no longer exposes a tool that creates these records.

type PlanningLifecycleStoredResult

type PlanningLifecycleStoredResult struct {
	Entity string `json:"entity"`
	Key    string `json:"key"`
	Action string `json:"action"`
}

type Presentation

type Presentation struct {
	Title    string
	Subtitle string
	Preview  string
}

func PresentationForRequest

func PresentationForRequest(req Request) Presentation

func PresentationForTool

func PresentationForTool(kind ID, preview string) Presentation

func SharedPresentation

func SharedPresentation(kind ID, preview string) Presentation

type PresentationStoredResult

type PresentationStoredResult struct {
	Title    string `json:"title,omitempty"`
	MIMEType string `json:"mime_type"`
	Content  string `json:"content"`
}

PresentationStoredResult is deliberate inline visual material for a voice client. It remains MIME-typed so clients can provide generic fallbacks.

type Presenter

type Presenter interface {
	Presentation(req Request) Presentation
}

type ProviderCallError

type ProviderCallError struct {
	Request Request
	Err     error
}

func (ProviderCallError) Error

func (e ProviderCallError) Error() string

func (ProviderCallError) Unwrap

func (e ProviderCallError) Unwrap() error

type QuestionStoredResult

type QuestionStoredResult struct {
	Question string            `json:"question,omitempty"`
	Answers  []UserInputAnswer `json:"answers,omitempty"`
}

type ReadStoredLine

type ReadStoredLine struct {
	Number int    `json:"number"`
	Text   string `json:"text"`
}

func ParseReadStoredLines

func ParseReadStoredLines(output string) ([]ReadStoredLine, string)

type ReadStoredMode

type ReadStoredMode string
const (
	ReadStoredModeFile      ReadStoredMode = "file"
	ReadStoredModeDirectory ReadStoredMode = "dir"
)

type ReadStoredResult

type ReadStoredResult struct {
	Path           string           `json:"path"`
	Mode           ReadStoredMode   `json:"mode"`
	Lines          []ReadStoredLine `json:"lines,omitempty"`
	Entries        []string         `json:"entries,omitempty"`
	Footer         string           `json:"footer,omitempty"`
	StartLine      string           `json:"start_line,omitempty"`
	EndLine        string           `json:"end_line,omitempty"`
	Offset         string           `json:"offset,omitempty"`
	Limit          string           `json:"limit,omitempty"`
	Start          int              `json:"start,omitempty"`
	End            int              `json:"end,omitempty"`
	Total          int              `json:"total,omitempty"`
	NextStartLine  int              `json:"next_start_line,omitempty"`
	NextOffset     int              `json:"next_offset,omitempty"`
	EffectiveLimit int              `json:"effective_limit,omitempty"`
	AutoCapped     bool             `json:"auto_capped,omitempty"`
	RangeCapped    bool             `json:"range_capped,omitempty"`
	ByteCapped     bool             `json:"byte_capped,omitempty"`
	HasMore        bool             `json:"has_more,omitempty"`
	Truncated      bool             `json:"truncated,omitempty"`
}

type RemoteMedia

type RemoteMedia struct {
	Data     []byte
	Name     string
	MIMEType string
	URL      string
}

func FetchRemoteMedia

func FetchRemoteMedia(ctx context.Context, client *http.Client, rawURL string) (RemoteMedia, error)

type Request

type Request struct {
	Tool       ID                `json:"tool"`
	ToolCallID string            `json:"tool_call_id,omitempty"`
	Args       map[string]string `json:"-"`
}

func CanonicalRequest

func CanonicalRequest(req Request) Request

CanonicalRequest translates a historical operation call into the current resource/action shape for provider replay. Persisted data and execution keep their original identity; only newly built model context is canonicalized.

func Normalize

func Normalize(req Request) (Request, error)

func ParseProviderCall

func ParseProviderCall(call provider.ToolCall) (Request, error)

func RequestFromMeta

func RequestFromMeta(raw string) (Request, error)

func RequestFromMetaMap

func RequestFromMetaMap(raw map[string]string) (Request, error)

func RequestFromStored

func RequestFromStored(kind ID, raw string) (Request, error)

func (Request) ArgumentsJSON

func (r Request) ArgumentsJSON() string

func (Request) ContextString

func (r Request) ContextString() string

func (Request) Identity

func (r Request) Identity() string

Identity returns the permission and observability identity for a request. Resource tools include their selected action so materially different effects remain distinguishable even though they share one model-facing tool name.

func (Request) MarshalJSON

func (r Request) MarshalJSON() ([]byte, error)

func (Request) Meta

func (r Request) Meta() map[string]string

func (*Request) UnmarshalJSON

func (r *Request) UnmarshalJSON(data []byte) error

type Result

type Result = domain.ToolResult

func Call

func Call(ctx context.Context, options Options) (Result, error)

func MilestonePlanResult

func MilestonePlanResult(plan planning.Plan) Result

func MilestonePlanResultWithTaskSummaries

func MilestonePlanResultWithTaskSummaries(plan planning.Plan, summaries map[string]string) Result

func TaskBucketResult

func TaskBucketResult(plan planning.Plan, ref string, tasks []planning.Task, message string) Result

func TaskBucketResultWithTitle

func TaskBucketResultWithTitle(ref, title string, tasks []planning.Task, message string) Result

type Runtime

type Runtime struct {
	Workdir               string
	HTTPClient            *http.Client
	SessionID             id.ID
	SessionKind           domain.SessionKind
	ChatID                id.ID
	ChatRole              chatrole.Role
	InteractionMode       chatinteraction.Mode
	ActiveMilestoneKey    string
	AssignedTaskBucketKey string
	AssignedTaskRef       string
	SessionControl        SessionControl
	TaskControl           TaskControl
	ChatStatusControl     ChatStatusControl
	Services              map[string]any
	AllowedTools          map[ID]bool
	ManagedSkillsDir      string
	DisabledSkillPaths    []string
	SkillCatalogMaxChars  int
	Exec                  execruntime.Control
	MCP                   MCPExecutor
	Browser               browserapi.Service
	Attachments           *attachment.Manager
	OfferedFiles          *offeredfile.Manager
	FileTracker           FileTracker
	AccessSettings        accesssettings.Settings
}

func (Runtime) CheckNetworkAccess

func (r Runtime) CheckNetworkAccess() error

func (Runtime) SessionTmpDir

func (r Runtime) SessionTmpDir() string

func (Runtime) TouchFile

func (r Runtime) TouchFile(ctx context.Context, path, content string)

func (Runtime) VoiceInteraction

func (r Runtime) VoiceInteraction() bool

VoiceInteraction reports whether tools are being offered to a voice conversation. The legacy role fallback keeps stored/test callers compatible while voice migrates to an orthogonal interaction mode.

type SessionControl

type SessionControl interface {
	GetMilestonePlan(context.Context, id.ID) (planning.Plan, error)
	SetMilestonePlan(context.Context, id.ID, string, []planning.Milestone) (planning.Plan, error)
	ArchiveMilestone(context.Context, id.ID, string, bool) (planning.Milestone, error)
	DeleteMilestone(context.Context, id.ID, string) error
	AddTasks(context.Context, id.ID, string, []string) ([]planning.Task, error)
	UpdateTask(context.Context, string, planning.TaskStatus, string, string) (planning.Task, error)
	ArchiveTask(context.Context, string, bool) (planning.Task, error)
	DeleteTask(context.Context, string) error
	ListTasks(context.Context, id.ID, string) ([]planning.Task, error)
}

func RequireSessionControl

func RequireSessionControl(runtime Runtime) (SessionControl, error)

type ShowImageStoredResult

type ShowImageStoredResult = ShowMediaStoredResult

ShowImageStoredResult is retained for decoding old show_image results.

func ShowImageStoredResultForPart

func ShowImageStoredResultForPart(part domain.Part) (ShowImageStoredResult, bool)

type ShowMediaStoredItem

type ShowMediaStoredItem struct {
	Path       string               `json:"path"`
	SourcePath string               `json:"source_path,omitempty"`
	MIMEType   string               `json:"mime_type"`
	MediaKind  string               `json:"media_kind,omitempty"`
	Title      string               `json:"title,omitempty"`
	SessionID  string               `json:"session_id,omitempty"`
	Attachment *attachment.Metadata `json:"attachment,omitempty"`
}

type ShowMediaStoredResult

type ShowMediaStoredResult struct {
	Path       string                `json:"path"`
	SourcePath string                `json:"source_path,omitempty"`
	MIMEType   string                `json:"mime_type"`
	MediaKind  string                `json:"media_kind,omitempty"`
	Title      string                `json:"title,omitempty"`
	SessionID  string                `json:"session_id,omitempty"`
	Attachment *attachment.Metadata  `json:"attachment,omitempty"`
	Summary    string                `json:"summary,omitempty"`
	Items      []ShowMediaStoredItem `json:"items,omitempty"`
	Errors     []string              `json:"errors,omitempty"`
}

func ShowMediaStoredResultForPart

func ShowMediaStoredResultForPart(part domain.Part) (ShowMediaStoredResult, bool)

type SkillStoredResult

type SkillStoredResult struct {
	Name      string `json:"name"`
	Path      string `json:"path"`
	Content   string `json:"content,omitempty"`
	Truncated bool   `json:"truncated,omitempty"`
}

func (SkillStoredResult) ModelText

func (result SkillStoredResult) ModelText() string

ModelText adds runtime location context that a portable SKILL.md cannot know ahead of time. This lets the model use bundled scripts and references directly instead of searching the filesystem to rediscover the loaded skill directory.

type StoredResultPayload

type StoredResultPayload interface {
	// contains filtered or unexported methods
}

type StoredResultStatus

type StoredResultStatus string
const (
	StoredResultStatusOK     StoredResultStatus = "ok"
	StoredResultStatusDenied StoredResultStatus = "denied"
	StoredResultStatusError  StoredResultStatus = "error"
)

type TaskControl

type TaskControl interface {
	AddTask(context.Context, id.ID, string, planning.LegacyTaskStatus) (planning.LegacyTask, error)
}

func RequireTaskControl

func RequireTaskControl(runtime Runtime) (TaskControl, error)

type TaskListStoredResult

type TaskListStoredResult struct {
	MilestoneKey       string           `json:"milestone_key,omitempty"`
	LegacyMilestoneKey string           `json:"milestone_ref,omitempty"`
	MilestoneTitle     string           `json:"milestone_title,omitempty"`
	Message            string           `json:"message,omitempty"`
	Items              []TaskStoredItem `json:"items,omitempty"`
}

func BuildTaskListStoredResult

func BuildTaskListStoredResult(plan planning.Plan, ref string, tasks []planning.Task, message string) TaskListStoredResult

type TaskStoredItem

type TaskStoredItem struct {
	ID       id.ID  `json:"id"`
	Key      string `json:"key,omitempty"`
	Content  string `json:"content"`
	Note     string `json:"note,omitempty"`
	Status   string `json:"status"`
	Archived bool   `json:"archived,omitempty"`
}

type TaskStoredResult

type TaskStoredResult struct {
	Body   string                    `json:"body"`
	Status planning.LegacyTaskStatus `json:"status"`
}

type Tool

type Tool interface {
	ID() ID
	BypassesPermission() bool
	NormalizeArgs(map[string]string) (map[string]string, error)
	Preview(req Request) string
	Call(ctx context.Context, options Options) (Result, error)
}

func Lookup

func Lookup(kind ID) (Tool, bool)

type ToolInt

type ToolInt int

ToolInt is the canonical integer representation used by tool arguments.

func ParseToolInt

func ParseToolInt(raw string) (ToolInt, error)

ParseToolInt accepts JSON integer syntax and integral decimal/exponent forms sometimes emitted by providers, such as "2000.00000" and "2e3".

func (ToolInt) Int

func (v ToolInt) Int() int

func (ToolInt) String

func (v ToolInt) String() string

type ToolSpec

type ToolSpec struct {
	Title       string
	Description string
	Usage       string
	Parameters  string
	ExposeToLLM bool
	// Legacy keeps a tool executable for stored transcripts and compatibility
	// while excluding its definition from new model requests.
	Legacy bool
}

ToolSpec describes a registered tool for local presentation and LLM exposure.

func Info

func Info(kind ID) ToolSpec

type UserInputAnswer

type UserInputAnswer struct {
	ToolCallID string `json:"tool_call_id"`
	QuestionID string `json:"question_id"`
	Selected   string `json:"selected,omitempty"`
	Comment    string `json:"comment,omitempty"`
}

type UserInputOption

type UserInputOption struct {
	Label       string `json:"label"`
	Description string `json:"description"`
}

type UserInputQuestion

type UserInputQuestion struct {
	ID       string            `json:"id"`
	Header   string            `json:"header"`
	Question string            `json:"question"`
	Options  []UserInputOption `json:"options"`
}

func ParseUserInputQuestions

func ParseUserInputQuestions(raw string) ([]UserInputQuestion, error)

type ViewImageStoredResult

type ViewImageStoredResult struct {
	Path       string               `json:"path"`
	SourcePath string               `json:"source_path,omitempty"`
	MIMEType   string               `json:"mime_type"`
	Detail     string               `json:"detail,omitempty"`
	SessionID  string               `json:"session_id,omitempty"`
	Attachment *attachment.Metadata `json:"attachment,omitempty"`
	Summary    string               `json:"summary,omitempty"`
	Page       int                  `json:"page,omitempty"`
	PageCount  int                  `json:"page_count,omitempty"`
}

func ViewImageStoredResultForPart

func ViewImageStoredResultForPart(part domain.Part) (ViewImageStoredResult, bool)

type WebFetchStoredResult

type WebFetchStoredResult struct {
	URL         string `json:"url"`
	FinalURL    string `json:"final_url,omitempty"`
	Format      string `json:"format,omitempty"`
	Status      int    `json:"status"`
	ContentType string `json:"content_type,omitempty"`
	Body        string `json:"body,omitempty"`
	Truncated   bool   `json:"truncated,omitempty"`
}

type WebSearchStoredItem

type WebSearchStoredItem struct {
	Title   string `json:"title"`
	URL     string `json:"url"`
	Snippet string `json:"snippet,omitempty"`
}

type WebSearchStoredResult

type WebSearchStoredResult struct {
	Query          string                `json:"query"`
	AllowedDomains string                `json:"allowed_domains,omitempty"`
	BlockedDomains string                `json:"blocked_domains,omitempty"`
	Items          []WebSearchStoredItem `json:"items,omitempty"`
}

type WriteStoredResult

type WriteStoredResult struct {
	Path             string                 `json:"path"`
	Action           string                 `json:"action,omitempty"`
	Summary          string                 `json:"summary,omitempty"`
	Content          string                 `json:"content,omitempty"`
	Diagnostics      string                 `json:"diagnostics,omitempty"`
	DiagnosticReport DiagnosticReportStored `json:"diagnostic_report,omitempty"`
	Truncated        bool                   `json:"truncated,omitempty"`
}

Directories

Path Synopsis
Package chatstatustool publishes descriptive chat activity to users and coordinators.
Package chatstatustool publishes descriptive chat activity to users and coordinators.
Package memorytool exposes Koder's durable memory graph through one model-facing, multi-action tool.
Package memorytool exposes Koder's durable memory graph through one model-facing, multi-action tool.

Jump to

Keyboard shortcuts

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