Documentation
¶
Overview ¶
Package tools implements application-owned coding tools for one workspace.
Index ¶
- Constants
- func NewCatalog(tree *workspace.Tree, limits Limits, options ...CatalogOption) (*catalog.Catalog, error)
- func NewTaskCatalog() (*catalog.Catalog, error)
- type CatalogOption
- type Limits
- type PlanFile
- type RecoveryError
- type ResultCounts
- type ResultExecution
- type ResultExecutionStream
- type ResultHeader
- type ResultNext
- type ResultProblem
- type ShellHandler
Constants ¶
const ApplyPatchName = "apply_patch"
ApplyPatchName is the model-facing workspace edit tool.
const PlanCatalogID = "coding.plan"
PlanCatalogID is the exact local provenance of the plan-mode tool pair.
Variables ¶
This section is empty.
Functions ¶
func NewCatalog ¶
func NewCatalog( tree *workspace.Tree, limits Limits, options ...CatalogOption, ) (*catalog.Catalog, error)
NewCatalog returns the application-owned coding tool catalog.
func NewTaskCatalog ¶
NewTaskCatalog returns the Agent-mode application task progress tool.
Types ¶
type CatalogOption ¶
type CatalogOption func(*catalogConfig) error
CatalogOption adds an explicitly constructed coding tool.
func WithControlledShell ¶
func WithControlledShell(tool agent.Tool) CatalogOption
WithControlledShell adds the shell wrapper returned by approval.Controller. Passing the raw ShellHandler is impossible because it does not implement agent.Tool.
func WithPlanFile ¶
func WithPlanFile(file PlanFile) CatalogOption
WithPlanFile admits the plan-mode file as an additional patch target while plan mode is active.
type Limits ¶
type Limits struct {
OutputBytes int
FileBytes int64
ReadLines int
ListEntries int
GlobEntries int
GrepMatches int
GrepLineBytes int
ScanEntries int
GrepFiles int
GlobTimeout time.Duration
GrepTimeout time.Duration
PatchBytes int
PatchFiles int
PatchTotalBytes int64
PatchTimeout time.Duration
}
Limits bounds filesystem work and model-visible output for coding tools.
func DefaultLimits ¶
func DefaultLimits() Limits
DefaultLimits returns production coding-tool budgets.
type PlanFile ¶
type PlanFile struct {
Path func() string
Admitted func() bool
Read func(context.Context) (string, error)
Write func(context.Context, string) error
}
PlanFile is the injected plan-mode file boundary. The patch tool applies changes to this exact file when plan mode admits it.
type RecoveryError ¶
type RecoveryError struct {
Applied bool
RecoveryPaths []string
// contains filtered or unexported fields
}
RecoveryError means the patch could not finish or cleanly restore every path. RecoveryPaths are workspace-relative materials retained for recovery.
func (*RecoveryError) Unwrap ¶
func (e *RecoveryError) Unwrap() error
Unwrap returns the transaction or cleanup failure.
type ResultCounts ¶
type ResultCounts struct {
Lines int `json:"lines,omitempty"`
Bytes int `json:"bytes,omitempty"`
Entries int `json:"entries,omitempty"`
Files int `json:"files,omitempty"`
Matches int `json:"matches,omitempty"`
Scanned int `json:"scanned,omitempty"`
Skipped int `json:"skipped,omitempty"`
TruncatedLines int `json:"truncated_lines,omitempty"`
}
ResultCounts summarizes bounded work performed by a coding tool.
type ResultExecution ¶
type ResultExecution struct {
Status string `json:"status"`
ExitCode *int `json:"exit_code,omitempty"`
Signal string `json:"signal,omitempty"`
DurationMS int64 `json:"duration_ms"`
Stdout ResultExecutionStream `json:"stdout"`
Stderr ResultExecutionStream `json:"stderr"`
}
ResultExecution summarizes one bounded local process outcome.
type ResultExecutionStream ¶
type ResultExecutionStream struct {
Bytes int64 `json:"bytes"`
Truncated bool `json:"truncated,omitempty"`
Sanitized bool `json:"sanitized,omitempty"`
}
ResultExecutionStream summarizes observed output without embedding content.
type ResultHeader ¶
type ResultHeader struct {
Schema string `json:"schema"`
OK bool `json:"ok"`
Tool string `json:"tool"`
Code string `json:"code,omitempty"`
Truncated bool `json:"truncated,omitempty"`
Reason string `json:"reason,omitempty"`
Problem *ResultProblem `json:"problem,omitempty"`
Counts ResultCounts `json:"counts,omitzero"`
Next ResultNext `json:"next,omitzero"`
Execution *ResultExecution `json:"execution,omitempty"`
Diagnostic *execution.SandboxDiagnostic `json:"diagnostic,omitempty"`
}
ResultHeader is the machine-readable first line of every coding-tool result.
func ParseResult ¶
func ParseResult(value string) (ResultHeader, string, error)
ParseResult decodes a coding-tool result without making consumers redefine the versioned envelope contract. Body is returned without transformation.
type ResultNext ¶
type ResultNext struct {
Offset *int `json:"offset,omitempty"`
}
ResultNext identifies a continuation point for a truncated result.
type ResultProblem ¶
type ResultProblem struct {
Field string `json:"field,omitempty"`
Retryable bool `json:"retryable"`
Hint string `json:"hint,omitempty"`
}
ResultProblem describes a safe correction for a failed tool call.
type ShellHandler ¶
type ShellHandler struct {
// contains filtered or unexported fields
}
ShellHandler prepares and renders shell operations. It deliberately does not implement agent.Tool; only an approval Controller may create the registerable wrapper.
func NewShellHandler ¶
func NewShellHandler() *ShellHandler
NewShellHandler constructs the non-registerable shell operation handler.
func NewShellHandlerForNetwork ¶
func NewShellHandlerForNetwork(mode config.SandboxNetworkMode) *ShellHandler
NewShellHandlerForNetwork constructs a Shell handler with the user-owned workspace-write network policy. The Config boundary validates mode.
func NewShellHandlerForSandbox ¶
func NewShellHandlerForSandbox( sandbox config.SandboxMode, networkMode config.SandboxNetworkMode, ) *ShellHandler
NewShellHandlerForSandbox constructs a Shell handler for one effective filesystem profile and Network policy. Read-only profiles request the read-only operation boundary so safe shell reads remain available while Policy rejects workspace and external writes before approval.
func (*ShellHandler) Decl ¶
func (h *ShellHandler) Decl() ai.Tool
Decl returns the shell declaration consumed by the approval Controller.
func (*ShellHandler) Operation ¶
func (h *ShellHandler) Operation( ctx context.Context, call agent.ToolCall, ) (execution.OperationSpec, error)
Operation strictly decodes one call into the fixed /bin/sh contract.