Documentation
¶
Index ¶
- Constants
- Variables
- func HoldsSecrets(path string) bool
- func InvalidArgs(toolID string, err error) error
- func WorkingDirKey(dir string) string
- type ApprovalRequest
- type Await
- type BashParams
- type BashResponseMetadata
- type Call
- type Category
- type Command
- type CommandResult
- type ConcurrencyKeyProvider
- type Definition
- type DuplicateToolError
- type EditOperation
- type EditParams
- type Effect
- type Executor
- func CoreExecutors() []Executor
- func NewEditExecutor() Executor
- func NewGlobExecutor() Executor
- func NewGrepExecutor() Executor
- func NewLSExecutor() Executor
- func NewMultiEditExecutor() Executor
- func NewReadExecutor() Executor
- func NewShellExecutors(tasks ShellTasks) []Executor
- func NewWriteExecutor() Executor
- type FileChange
- type FilesystemPathMetadata
- type FilesystemPathPolicy
- type GlobParams
- type GlobResponseMetadata
- type GrepParams
- type GrepResponseMetadata
- type InvalidArgsError
- type InvalidToolSpecError
- type LSParams
- type LSResponseMetadata
- type MultiEditParams
- type NodeType
- type Previewer
- type ReadParams
- type ReadResponseMetadata
- type Registry
- func (r *Registry) ConcurrencyKey(toolID string, call Call) string
- func (r *Registry) Err() error
- func (r *Registry) Execute(ctx context.Context, toolID string, call Call) (Result, error)
- func (r *Registry) List() []Spec
- func (r *Registry) Preview(ctx context.Context, toolID string, call Call) (ApprovalRequest, *Result)
- func (r *Registry) Register(executors ...Executor) error
- func (r *Registry) Spec(toolID string) (Spec, bool)
- func (r *Registry) Subject(toolID string, call Call) permission.Subject
- type Result
- type ResultStatus
- type ShellTasks
- type SkillManagePermissionsParams
- type Spec
- type SubjectProvider
- type TaskInfo
- type TaskKillParams
- type TaskOutput
- type TaskOutputParams
- type TaskRead
- type TreeNode
- type WriteParams
Constants ¶
const ( DefaultCommandTimeout = 10 * time.Minute MaxCommandTimeout = time.Hour DefaultAutoBackground = 2 * time.Minute )
A foreground command is killed after its timeout, 10 minutes unless the call names up to 60, and moves to the background after 2 minutes.
const MaxReadBytes = 5 * 1024 * 1024
MaxReadBytes is the largest file the read tool opens.
Variables ¶
var ErrInvalidArgs = errors.New("invalid tool arguments")
Functions ¶
func HoldsSecrets ¶ added in v0.2.0
HoldsSecrets reports whether path is in a place where keys and login tokens usually live (SSH, GPG, cloud and registry credentials), which a read-only tool may touch only after the user agrees.
func InvalidArgs ¶
func WorkingDirKey ¶ added in v0.2.0
WorkingDirKey is the concurrency key of calls that change dir.
Types ¶
type ApprovalRequest ¶
type ApprovalRequest struct {
Description string `json:"description,omitempty"`
Path string `json:"path,omitempty"`
Params any `json:"params,omitempty"`
// Suggestion is the rule an "Always allow" answer keeps; core sets it.
Suggestion *permission.Suggestion `json:"suggestion,omitempty"`
}
ApprovalRequest is what the user sees before a call runs: what it does, the file or directory it changes and tool-specific details such as a diff.
type Await ¶ added in v0.2.0
Await is what a run waits for: any of TaskIDs, or any background task of its session when there are none, until Until.
type BashParams ¶
type BashParams struct {
Description string `json:"description,omitempty"`
Command string `json:"command"`
WorkingDir string `json:"working_dir,omitempty"`
RunInBackground bool `json:"run_in_background,omitempty"`
Timeout int `json:"timeout,omitempty"`
AutoBackgroundAfter int `json:"auto_background_after,omitempty"`
}
type BashResponseMetadata ¶
type BashResponseMetadata struct {
StartTime int64 `json:"start_time"`
EndTime int64 `json:"end_time"`
Output string `json:"output"`
ExitCode int `json:"exit_code,omitempty"`
Description string `json:"description,omitempty"`
WorkingDirectory string `json:"working_directory"`
Background bool `json:"background,omitempty"`
TaskID string `json:"task_id,omitempty"`
TimedOut bool `json:"timed_out,omitempty"`
OutputPath string `json:"output_path,omitempty"`
}
type Call ¶
type Call struct {
SessionID string `json:"session_id,omitempty"`
RunID string `json:"run_id,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
Client string `json:"client,omitempty"`
ExternalKey string `json:"external_key,omitempty"`
WorkingDir string `json:"working_dir,omitempty"`
Args json.RawMessage `json:"args,omitempty"`
// Recheck applies the permission rules to another subject the call reaches,
// such as a redirect's host; nil when no rules apply.
Recheck func(context.Context, permission.Subject) error `json:"-"`
}
type Command ¶ added in v0.2.0
type Command struct {
Command string
Description string
WorkingDir string
Background bool
Timeout time.Duration
AutoBackground time.Duration
OutputLimit int
}
Command is a shell command to run for a call. Background starts it as a background task at once; otherwise Timeout kills it and, when shorter than Timeout, AutoBackground moves it to the background while it still runs. OutputLimit caps the output a finished command returns.
type CommandResult ¶ added in v0.2.0
type CommandResult struct {
TaskID string
Output string
OutputPath string
ExitCode int
TimedOut bool
StartedAt time.Time
EndedAt time.Time
}
CommandResult is how a command ended, or the task it went on as (TaskID). OutputPath names the file holding the whole output when Output was cut.
type ConcurrencyKeyProvider ¶ added in v0.2.0
ConcurrencyKeyProvider is implemented by executors whose calls need another concurrency key than their spec's default.
type Definition ¶ added in v0.1.2
Definition is a core tool; one whose executor needs the daemon's services (the shell tools) has no NewExecutor and is registered on its own.
type DuplicateToolError ¶ added in v0.1.1
type DuplicateToolError struct {
ID string
}
func (DuplicateToolError) Error ¶ added in v0.1.1
func (e DuplicateToolError) Error() string
type EditOperation ¶
type EditParams ¶
type Executor ¶
func CoreExecutors ¶ added in v0.2.0
func CoreExecutors() []Executor
CoreExecutors returns the core tools that need no daemon services.
func NewEditExecutor ¶
func NewEditExecutor() Executor
func NewGlobExecutor ¶
func NewGlobExecutor() Executor
func NewGrepExecutor ¶
func NewGrepExecutor() Executor
func NewLSExecutor ¶
func NewLSExecutor() Executor
func NewMultiEditExecutor ¶
func NewMultiEditExecutor() Executor
func NewReadExecutor ¶
func NewReadExecutor() Executor
func NewShellExecutors ¶ added in v0.2.0
func NewShellExecutors(tasks ShellTasks) []Executor
NewShellExecutors returns bash, task_output and task_kill over tasks.
func NewWriteExecutor ¶
func NewWriteExecutor() Executor
type FileChange ¶ added in v0.2.0
type FileChange struct {
Path string `json:"file_path"`
OldContent string `json:"old_content,omitempty"`
NewContent string `json:"new_content,omitempty"`
Additions int `json:"additions"`
Removals int `json:"removals"`
}
FileChange is what write, edit and multiedit do to one file: the result's metadata and, reduced by preview, what their approval shows.
type FilesystemPathMetadata ¶ added in v0.1.2
type FilesystemPathMetadata struct {
RequestedPath string `json:"requested_path,omitempty"`
ResolvedPath string `json:"resolved_path,omitempty"`
WorkingDir string `json:"working_dir,omitempty"`
RealPath string `json:"real_path,omitempty"`
RealWorkingDir string `json:"real_working_dir,omitempty"`
BoundaryKnown bool `json:"boundary_known,omitempty"`
WithinWorkingDir bool `json:"within_working_dir,omitempty"`
SymlinkEvalApplied bool `json:"symlink_eval_applied,omitempty"`
}
type FilesystemPathPolicy ¶
type FilesystemPathPolicy struct {
Input string
WorkingDir string
Path string
RealPath string
RealWorkingDir string
BoundaryKnown bool
WithinWorkingDir bool
EscapesWorkingDir bool
SymlinkEvalApplied bool
}
func ResolveFilesystemPath ¶
func ResolveFilesystemPath(workingDir string, value string) (FilesystemPathPolicy, error)
type GlobParams ¶
type GlobResponseMetadata ¶
type GlobResponseMetadata struct {
FilesystemPathMetadata
NumberOfFiles int `json:"number_of_files"`
Truncated bool `json:"truncated"`
}
type GrepParams ¶
type GrepResponseMetadata ¶
type GrepResponseMetadata struct {
FilesystemPathMetadata
NumberOfMatches int `json:"number_of_matches"`
Truncated bool `json:"truncated"`
}
type InvalidArgsError ¶
func (*InvalidArgsError) Error ¶
func (e *InvalidArgsError) Error() string
func (*InvalidArgsError) Is ¶
func (e *InvalidArgsError) Is(target error) bool
func (*InvalidArgsError) Unwrap ¶
func (e *InvalidArgsError) Unwrap() error
type InvalidToolSpecError ¶ added in v0.1.1
type InvalidToolSpecError struct {
Reason string
}
func (InvalidToolSpecError) Error ¶ added in v0.1.1
func (e InvalidToolSpecError) Error() string
type LSResponseMetadata ¶
type LSResponseMetadata struct {
FilesystemPathMetadata
NumberOfFiles int `json:"number_of_files"`
Truncated bool `json:"truncated"`
}
type MultiEditParams ¶
type MultiEditParams struct {
FilePath string `json:"file_path"`
Edits []EditOperation `json:"edits"`
}
type Previewer ¶ added in v0.2.0
type Previewer interface {
Preview(ctx context.Context, call Call) (ApprovalRequest, error)
}
Previewer is implemented by tools whose approval shows more than the call's arguments. Preview has no side effects; its error answers the call instead.
type ReadParams ¶
type ReadResponseMetadata ¶
type ReadResponseMetadata struct {
FilesystemPathMetadata
FilePath string `json:"file_path"`
Content string `json:"content"`
}
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func (*Registry) ConcurrencyKey ¶ added in v0.2.0
ConcurrencyKey is the key a call of the tool runs under; "" for an unknown tool.
type Result ¶
type Result struct {
Content string `json:"content"`
Metadata any `json:"metadata,omitempty"`
MIMEType string `json:"mime_type,omitempty"`
// Status is how the call went; empty is success.
Status ResultStatus `json:"status,omitempty"`
// OutputPath is the file holding the full output when Content was cut.
OutputPath string `json:"output_path,omitempty"`
// Await parks the run once its batch is done, until one of the tasks
// finishes, the user writes or Until passes.
Await *Await `json:"await,omitempty"`
// Waiting marks a result that only reports a task still running after the
// call waited for it; the no-progress guard skips it.
Waiting bool `json:"waiting,omitempty"`
}
type ResultStatus ¶
type ResultStatus string
const ( ResultStatusSuccess ResultStatus = "success" ResultStatusError ResultStatus = "error" ResultStatusNeutral ResultStatus = "neutral" )
type ShellTasks ¶ added in v0.2.0
type ShellTasks interface {
RunCommand(ctx context.Context, call Call, command Command) (CommandResult, error)
ReadTaskOutput(ctx context.Context, call Call, read TaskRead) (TaskOutput, error)
StopTask(ctx context.Context, call Call, taskID string) (TaskInfo, error)
}
ShellTasks runs the commands of bash calls; a command that outlives its call becomes a background task of the call's session.
type SkillManagePermissionsParams ¶ added in v0.1.11
type Spec ¶
type Spec struct {
ID string `json:"id"`
Description string `json:"description,omitempty"`
Effect Effect `json:"effect,omitempty"`
// Asks makes a call no permission rule decides wait for the user's approval.
Asks bool `json:"asks,omitempty"`
Namespace string `json:"namespace,omitempty"`
Category Category `json:"category,omitempty"`
InputJSONSchema json.RawMessage `json:"input_json_schema,omitempty"`
}
Spec describes a tool to the model and to the engine: Effect and Category drive concurrency, Asks approvals, Namespace groups a module's tools.
func (Spec) ConcurrencyKey ¶ added in v0.2.0
ConcurrencyKey names what a call must not share with a concurrent call of the same key: "" runs freely (read-only tools), an MCP tool shares its server, a mutating filesystem or shell tool its working directory and any other mutating tool its namespace.
func (Spec) IsFilesystemMutation ¶ added in v0.1.2
type SubjectProvider ¶ added in v0.2.0
type SubjectProvider interface {
PermissionSubject(call Call) permission.Subject
}
SubjectProvider is implemented by executors whose calls permission rules can name more narrowly than the whole tool.
type TaskInfo ¶ added in v0.2.0
type TaskInfo struct {
TaskID string `json:"task_id"`
Kind string `json:"kind"`
Command string `json:"command"`
Description string `json:"description,omitempty"`
Status string `json:"status"`
ExitCode *int `json:"exit_code,omitempty"`
OutputPath string `json:"output_path,omitempty"`
}
TaskInfo describes a background task to the model and clients.
type TaskKillParams ¶ added in v0.2.0
type TaskKillParams struct {
ID string `json:"id"`
}
type TaskOutput ¶ added in v0.2.0
TaskOutput is a task's output since the last read. Skipped counts bytes dropped from the file before Text; More is set when more output is waiting; Running is set while the task has not finished.
type TaskOutputParams ¶ added in v0.2.0
type TaskRead ¶ added in v0.2.0
TaskRead asks for a task's output since the last read, waiting up to Wait for the task to finish; Filter keeps the lines matching a regular expression.