Documentation
¶
Index ¶
- func DetectLineEnding(content string) string
- func DetectSupportedImageMimeType(buffer []byte) string
- func FormatDimensionNote(result ResizedImage) string
- func GenerateUnifiedPatch(path, oldContent, newContent string, contextLines int) (string, error)
- func GetShellConfig(customShellPath string) (proctree.Shell, error)
- func GetShellEnv() (map[string]string, error)
- func KillTrackedDetachedChildren()
- func ManagedFDPath() string
- func NewBashTool(cwd string, options *BashToolOptions) engine.AgentTool
- func NewEditTool(cwd string, options *EditToolOptions) engine.AgentTool
- func NewFindTool(cwd string, options *FindToolOptions) engine.AgentTool
- func NewGrepTool(cwd string, options *GrepToolOptions) engine.AgentTool
- func NewLsTool(cwd string, options *LsToolOptions) engine.AgentTool
- func NewReadTool(cwd string, options *ReadToolOptions) engine.AgentTool
- func NewWriteTool(cwd string, options *WriteToolOptions) engine.AgentTool
- func NormalizeForFuzzyMatch(text string) string
- func NormalizeToLF(text string) string
- func NormalizeToolResultImages(content ai.ToolResultContent, autoResize bool, resize *ImageResizeOptions) (ai.ToolResultContent, bool)
- func PathExists(filePath string) bool
- func ResolveReadPath(filePath, cwd string) (string, error)
- func ResolveToCwd(filePath, cwd string) (string, error)
- func RestoreLineEndings(text, ending string) string
- func ShortenPath(path string) string
- func StripBOM(content string) (bom, text string)
- func WithFileMutationQueue[T any](filePath string, fn func() (T, error)) (T, error)
- type AppliedEditsResult
- type BashExecOptions
- type BashExecResult
- type BashOperations
- type BashResult
- type BashSessionEnvironment
- type BashSessionEnvironmentBinder
- type BashSessionEnvironmentSource
- type BashSpawnContext
- type BashSpawnHook
- type BashToolDetails
- type BashToolInput
- type BashToolOptions
- type DiffResult
- type Edit
- type EditOperations
- type EditToolDetails
- type EditToolInput
- type EditToolOptions
- type FindGlobOptions
- type FindOperations
- type FindToolDetails
- type FindToolInput
- type FindToolOptions
- type FuzzyMatchResult
- type GrepOperations
- type GrepToolDetails
- type GrepToolInput
- type GrepToolOptions
- type ImageResizeOptions
- type LocalBashOperationsOptions
- type LsOperations
- type LsPathStat
- type LsToolDetails
- type LsToolInput
- type LsToolOptions
- type OutputAccumulator
- func (output *OutputAccumulator) Append(data []byte) error
- func (output *OutputAccumulator) CloseTempFile() error
- func (output *OutputAccumulator) Finish() error
- func (output *OutputAccumulator) FullOutput() (content string, truncated bool)
- func (output *OutputAccumulator) LastLineBytes() int
- func (output *OutputAccumulator) Snapshot(options ...OutputSnapshotOptions) (OutputSnapshot, error)
- type OutputAccumulatorOptions
- type OutputSnapshot
- type OutputSnapshotOptions
- type PlainTextRenderer
- type ProcessImageOptions
- type ProcessImageResult
- type ReadImageOperations
- type ReadOperations
- type ReadToolDetails
- type ReadToolInput
- type ReadToolOptions
- type ResizedImage
- type ToolsOptions
- type WriteOperations
- type WriteToolInput
- type WriteToolOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DetectLineEnding ¶
func FormatDimensionNote ¶
func FormatDimensionNote(result ResizedImage) string
func GenerateUnifiedPatch ¶
func GetShellConfig ¶
GetShellConfig resolves upstream's bash: customShellPath when it is set, else Git Bash on win32 and bash or sh elsewhere.
func GetShellEnv ¶
GetShellEnv is the tool environment with the managed binary directory first on PATH.
func KillTrackedDetachedChildren ¶
func KillTrackedDetachedChildren()
KillTrackedDetachedChildren kills every running bash process tree, for exit paths.
func ManagedFDPath ¶
func ManagedFDPath() string
ManagedFDPath returns an already-installed fd, preferring the managed binary over a system one, or "" when neither is present. It never downloads and never spawns a probe process, so callers on interactive render paths can call it freely.
func NewBashTool ¶
func NewBashTool(cwd string, options *BashToolOptions) engine.AgentTool
func NewEditTool ¶
func NewEditTool(cwd string, options *EditToolOptions) engine.AgentTool
func NewFindTool ¶
func NewFindTool(cwd string, options *FindToolOptions) engine.AgentTool
func NewGrepTool ¶
func NewGrepTool(cwd string, options *GrepToolOptions) engine.AgentTool
func NewReadTool ¶
func NewReadTool(cwd string, options *ReadToolOptions) engine.AgentTool
func NewWriteTool ¶
func NewWriteTool(cwd string, options *WriteToolOptions) engine.AgentTool
func NormalizeForFuzzyMatch ¶
func NormalizeToLF ¶
func NormalizeToolResultImages ¶ added in v0.14.0
func NormalizeToolResultImages(content ai.ToolResultContent, autoResize bool, resize *ImageResizeOptions) (ai.ToolResultContent, bool)
NormalizeToolResultImages runs images a tool produced itself (extensions, MCP, screenshots) through ProcessImage as they enter history, since one oversized image makes providers reject the whole conversation. An image that fails to process stays as produced. It reports whether anything changed.
func PathExists ¶
PathExists reports whether a filesystem entry exists at filePath.
func ResolveReadPath ¶
ResolveReadPath adds the filename fallbacks used for macOS-generated files.
func ResolveToCwd ¶
ResolveToCwd resolves a normalized tool path relative to cwd.
func RestoreLineEndings ¶
func ShortenPath ¶
ShortenPath abbreviates a home-relative path with "~" for tool headers, matching upstream render-utils shortenPath.
Types ¶
type AppliedEditsResult ¶
type AppliedEditsResult struct {
BaseContent string `json:"baseContent"`
NewContent string `json:"newContent"`
}
func ApplyEditsToNormalizedContent ¶
func ApplyEditsToNormalizedContent(normalizedContent string, edits []Edit, path string) (AppliedEditsResult, error)
type BashExecOptions ¶
type BashExecResult ¶
type BashExecResult struct {
// ExitCode must be set when Exec succeeds. A nil value is a failed command.
ExitCode *int
}
type BashOperations ¶
type BashOperations interface {
Exec(context.Context, string, string, BashExecOptions) (BashExecResult, error)
}
BashOperations is the command-execution delegation seam used by local and remote backends.
func NewLocalBashOperations ¶
func NewLocalBashOperations(options ...LocalBashOperationsOptions) BashOperations
func ShellBashOperations ¶ added in v0.10.0
func ShellBashOperations(shell harness.Shell) BashOperations
ShellBashOperations adapts the Exec port (DECISIONS.md P10) to the bash tool. Timeouts keep the "timeout:<seconds>" message the tool renders, and cancellation keeps the bare "aborted" message of the local backend.
type BashResult ¶
type BashResult struct {
Output string `json:"output"`
ExitCode *int `json:"exitCode,omitempty"`
Cancelled bool `json:"cancelled"`
Truncated bool `json:"truncated"`
FullOutputPath string `json:"fullOutputPath,omitempty"`
}
func ExecuteBash ¶
func ExecuteBash(ctx context.Context, command, cwd, prefix, shellPath string, onChunk func(string)) (BashResult, error)
ExecuteBash mirrors the session-level bash executor rather than the bash tool: a non-zero exit is data in RPC mode, while cancellation is reported in the result instead of becoming a tool error. onChunk receives each sanitized output chunk as it streams.
type BashSessionEnvironment ¶
type BashSessionEnvironment struct {
SessionID string
SessionFile string
Provider string
Model string
ReasoningLevel string
}
BashSessionEnvironment carries the session metadata exposed to bash commands as ORB_* environment variables. It mirrors what the upstream bash tool reads from the ExtensionContext in resolveSpawnContext.
type BashSessionEnvironmentBinder ¶
type BashSessionEnvironmentBinder interface {
BindSessionEnvironment(BashSessionEnvironmentSource)
}
BashSessionEnvironmentBinder is the orb counterpart of upstream tools receiving the ExtensionContext at execute time: built-ins implement agent.AgentTool directly, so the session runtime binds a source instead.
type BashSessionEnvironmentSource ¶
type BashSessionEnvironmentSource func() *BashSessionEnvironment
BashSessionEnvironmentSource resolves the current session metadata at execution time. A nil result means no session context is available (the upstream `ctx === undefined` case).
type BashSpawnContext ¶
type BashSpawnHook ¶
type BashSpawnHook func(BashSpawnContext) BashSpawnContext
type BashToolDetails ¶
type BashToolInput ¶
type BashToolOptions ¶
type BashToolOptions struct {
Operations BashOperations
CommandPrefix string
ShellPath string
// ExposeSessionEnvironment exposes current Orb session metadata as ORB_*
// environment variables. Default: true.
ExposeSessionEnvironment *bool
SpawnHook BashSpawnHook
}
type DiffResult ¶
type DiffResult struct {
Diff string `json:"diff"`
FirstChangedLine *int `json:"firstChangedLine,omitempty"`
}
func ComputeEditsDiff ¶
func ComputeEditsDiff(path string, edits []Edit, cwd string) (DiffResult, error)
func GenerateDiffString ¶
func GenerateDiffString(oldContent, newContent string, contextLines int) DiffResult
type EditOperations ¶
type EditOperations interface {
ReadFile(context.Context, string) ([]byte, error)
WriteFile(context.Context, string, string) error
Access(context.Context, string) error
}
EditOperations is the delegation seam for the edit tool.
type EditToolDetails ¶
type EditToolInput ¶
type EditToolOptions ¶
type EditToolOptions struct {
Operations EditOperations
}
type FindGlobOptions ¶
type FindOperations ¶
type FindOperations interface {
Exists(context.Context, string) (bool, error)
Glob(context.Context, string, string, FindGlobOptions) ([]string, error)
}
FindOperations is the delegation seam for remote file discovery.
type FindToolDetails ¶
type FindToolInput ¶
type FindToolOptions ¶
type FindToolOptions struct {
Operations FindOperations
}
type FuzzyMatchResult ¶
type FuzzyMatchResult struct {
Found bool `json:"found"`
Index int `json:"index"`
MatchLength int `json:"matchLength"`
UsedFuzzyMatch bool `json:"usedFuzzyMatch"`
ContentForReplacement string `json:"contentForReplacement"`
}
func FuzzyFindText ¶
func FuzzyFindText(content, oldText string) FuzzyMatchResult
type GrepOperations ¶
type GrepOperations interface {
IsDirectory(context.Context, string) (bool, error)
ReadFile(context.Context, string) (string, error)
}
GrepOperations is the delegation seam for grep file metadata and context reads.
type GrepToolDetails ¶
type GrepToolInput ¶
type GrepToolInput struct {
Pattern string `json:"pattern"`
Path *string `json:"path,omitempty"`
Glob *string `json:"glob,omitempty"`
IgnoreCase *bool `json:"ignoreCase,omitempty"`
Literal *bool `json:"literal,omitempty"`
Context *float64 `json:"context,omitempty"`
Limit *float64 `json:"limit,omitempty"`
}
type GrepToolOptions ¶
type GrepToolOptions struct {
Operations GrepOperations
}
type ImageResizeOptions ¶
func ModelResizeOptions ¶ added in v0.14.0
func ModelResizeOptions(model *ai.Model) *ImageResizeOptions
ModelResizeOptions is the model's image resize profile (inputLimits), or nil for the conservative defaults.
type LocalBashOperationsOptions ¶
type LocalBashOperationsOptions struct {
ShellPath string
}
type LsOperations ¶
type LsOperations interface {
Exists(context.Context, string) (bool, error)
Stat(context.Context, string) (LsPathStat, error)
ReadDir(context.Context, string) ([]string, error)
}
LsOperations is the delegation seam for the ls tool.
type LsPathStat ¶
type LsPathStat struct {
Directory bool
}
func (LsPathStat) IsDirectory ¶
func (stat LsPathStat) IsDirectory() bool
type LsToolDetails ¶
type LsToolInput ¶
type LsToolOptions ¶
type LsToolOptions struct {
Operations LsOperations
}
type OutputAccumulator ¶
type OutputAccumulator struct {
// contains filtered or unexported fields
}
OutputAccumulator incrementally retains a bounded decoded tail while preserving the original byte stream if the output crosses either limit.
func NewOutputAccumulator ¶
func NewOutputAccumulator(options ...OutputAccumulatorOptions) *OutputAccumulator
func (*OutputAccumulator) Append ¶
func (output *OutputAccumulator) Append(data []byte) error
func (*OutputAccumulator) CloseTempFile ¶
func (output *OutputAccumulator) CloseTempFile() error
func (*OutputAccumulator) Finish ¶
func (output *OutputAccumulator) Finish() error
func (*OutputAccumulator) FullOutput ¶ added in v0.14.0
func (output *OutputAccumulator) FullOutput() (content string, truncated bool)
FullOutput is the whole output for programmatic callers, which receive far more than the model: up to 1 MiB, then its first and last 512 KiB around an omission marker, cut at character boundaries.
func (*OutputAccumulator) LastLineBytes ¶
func (output *OutputAccumulator) LastLineBytes() int
func (*OutputAccumulator) Snapshot ¶
func (output *OutputAccumulator) Snapshot(options ...OutputSnapshotOptions) (OutputSnapshot, error)
type OutputSnapshot ¶
type OutputSnapshotOptions ¶
type OutputSnapshotOptions struct {
PersistIfTruncated bool
}
type PlainTextRenderer ¶
type PlainTextRenderer interface {
RenderCall(args any) string
RenderResult(result engine.AgentToolResult) string
}
PlainTextRenderer is the tool-rendering seam used until the Phase 4 TUI replaces these strings with components.
type ProcessImageOptions ¶
type ProcessImageOptions struct {
AutoResizeImages *bool
ResizeOptions *ImageResizeOptions
}
type ProcessImageResult ¶
type ProcessImageResult struct {
OK bool
Data string
MimeType string
Hints []string
Message string
}
func ProcessImage ¶
func ProcessImage(input []byte, mimeType string, options *ProcessImageOptions) ProcessImageResult
type ReadImageOperations ¶
ReadImageOperations is the optional image-detection extension used by delegated filesystems that cannot be sniffed locally before reading.
type ReadOperations ¶
type ReadOperations interface {
ReadFile(context.Context, string) ([]byte, error)
Access(context.Context, string) error
}
ReadOperations is the delegation seam for the read tool.
type ReadToolDetails ¶
type ReadToolInput ¶
type ReadToolOptions ¶
type ReadToolOptions struct {
Operations ReadOperations
AutoResizeImages *bool
}
type ResizedImage ¶
type ResizedImage struct {
Data string
MimeType string
OriginalWidth int
OriginalHeight int
Width int
Height int
WasResized bool
}
func ResizeImage ¶
func ResizeImage(input []byte, mimeType string, options *ImageResizeOptions) *ResizedImage
type ToolsOptions ¶
type ToolsOptions struct {
Read *ReadToolOptions
Bash *BashToolOptions
Edit *EditToolOptions
Write *WriteToolOptions
Grep *GrepToolOptions
Find *FindToolOptions
Ls *LsToolOptions
}
ToolsOptions carries per-tool options for SDK tool construction (upstream core/tools ToolsOptions).
func FileSystemToolsOptions ¶ added in v0.10.0
func FileSystemToolsOptions(fsys harness.FileSystem) *ToolsOptions
FileSystemToolsOptions routes the read, write, edit, ls and find tools through a harness.FileSystem port, reporting the Node error codes the native operations report. Grep is absent: its search runs ripgrep and has no port-backed seam. The port cannot check permission bits, so Access only proves existence.
type WriteOperations ¶
type WriteOperations interface {
WriteFile(context.Context, string, string) error
MkdirAll(context.Context, string) error
}
WriteOperations is the delegation seam for the write tool.
type WriteToolInput ¶
type WriteToolOptions ¶
type WriteToolOptions struct {
Operations WriteOperations
}