Documentation
¶
Index ¶
- Constants
- func EnvNames(env []string) []string
- func ExtractJSONObject(text string) (json.RawMessage, error)
- func GitHubCLIDiagnostic(output string, envNames []string) string
- func HandoffSchemaPrompt(name string, schema json.RawMessage) string
- func ResolveHandoffSchema(name string, schema json.RawMessage) (json.RawMessage, string, error)
- func TruncateOutput(s string, maxChars int) string
- func ValidEnvName(name string) bool
- func ValidateJSONSchema(raw json.RawMessage, schema json.RawMessage) []string
- func ValidateStructuredHandoff(text string, schema json.RawMessage) (json.RawMessage, []string)
- func WebSearchEnabled() bool
- type AgentRunFn
- type AgentRunParams
- type AgentRunResult
- type BlobInfo
- type DangerLevel
- type PathTranslator
- type Registry
- func (r *Registry) Disable(name string)
- func (r *Registry) Effects(name string) ToolEffects
- func (r *Registry) Enable(name string)
- func (r *Registry) EnabledTools() []Tool
- func (r *Registry) Get(name string) (Tool, bool)
- func (r *Registry) IsDangerous(name string) bool
- func (r *Registry) IsEnabled(name string) bool
- func (r *Registry) List() []string
- func (r *Registry) Lookup(name string) (Tool, bool)
- func (r *Registry) MissingEnabledNames() []string
- func (r *Registry) Register(t Tool)
- func (r *Registry) RegisterAndEnable(t Tool)
- func (r *Registry) RegisteredTools() []Tool
- func (r *Registry) Specs() []providers.ToolSpec
- func (r *Registry) Unregister(name string)
- func (r *Registry) Validate() error
- type SecretRedactor
- type Tool
- func ATProtoAnonSynth(cfg *config.Config) Tool
- func ATProtoCommunityDetect(cfg *config.Config) Tool
- func ATProtoCreateRecord(cfg *config.Config) Tool
- func ATProtoDailyDigest(cfg *config.Config) Tool
- func ATProtoEngagementHealth(cfg *config.Config) Tool
- func ATProtoFeed(cfg *config.Config) Tool
- func ATProtoFollowerMomentum(cfg *config.Config) Tool
- func ATProtoGetFollowers(cfg *config.Config) Tool
- func ATProtoGetFollows(cfg *config.Config) Tool
- func ATProtoGetProfile(cfg *config.Config) Tool
- func ATProtoGraphExplorer(cfg *config.Config) Tool
- func ATProtoIndex(cfg *config.Config) Tool
- func ATProtoNotifications(cfg *config.Config) Tool
- func ATProtoPost(cfg *config.Config) Tool
- func ATProtoRecall(cfg *config.Config) Tool
- func ATProtoResolve(cfg *config.Config) Tool
- func ATProtoUploadBlob(cfg *config.Config) Tool
- func ATProtoVibeCheck(cfg *config.Config) Tool
- func BlackboardRead() Tool
- func BlackboardSearch() Tool
- func BlackboardStore() Tool
- func BlackboardWrite() Tool
- func CurlFetch() Tool
- func FSList() Tool
- func FSMkdir() Tool
- func FSOutline() Tool
- func FSRead() Tool
- func FSRenderImage() Tool
- func FSWrite() Tool
- func Fingerprint() Tool
- func GitCommit() Tool
- func GitDiff() Tool
- func GitPush() Tool
- func GitStatus() Tool
- func InspectTool() Tool
- func NewAgent(runFn AgentRunFn) Tool
- func NewDeepResearch(runFn AgentRunFn) Tool
- func NewDispatch(runFn AgentRunFn, listAgents func() []string) Tool
- func NewOrchestrate(runFn AgentRunFn, listAgents func() []string) Tool
- func NewReflect() Tool
- func NewsFetch() Tool
- func PatchApply() Tool
- func ProjectSearch() Tool
- func ProvenanceLookup() Tool
- func SemBlame() Tool
- func SemDiff() Tool
- func SemImpact() Tool
- func Sh() Tool
- func SourceCode() Tool
- func Translate() Tool
- func WebExtract() Tool
- func WebSearch() Tool
- func Wiki() Tool
- type ToolCallContext
- type ToolEffects
- type ToolResult
Constants ¶
const ( // DefaultToolResultChars is the default character cap for tool outputs. // Set slightly above the policy default (20000) to give the loop's // truncation logic the final word while preventing pathological cases. DefaultToolResultChars = 24000 // DefaultFetchBytes is the default byte cap for HTTP fetches (curl, web_extract). // HTML compresses heavily to text, so we allow more bytes than chars. // Was previously 128KB (6x policy default) — now 64KB (~3x policy default). DefaultFetchBytes int64 = 64 * 1024 // MaxFetchBytes is the absolute upper bound on HTTP fetch sizes // regardless of caller request. Prevents DoS via large remote responses. MaxFetchBytes int64 = 2 * 1024 * 1024 )
Default output caps for tools. These are slightly above the policy's MaxToolResultChars default (20000) so the policy's truncation layer has the final say, but tool-layer caps prevent runaway memory/IO from extremely large responses.
const (
// HandoffSchemaStandard is the built-in structured sub-agent result schema.
HandoffSchemaStandard = "standard"
)
Variables ¶
This section is empty.
Functions ¶
func ExtractJSONObject ¶
func ExtractJSONObject(text string) (json.RawMessage, error)
ExtractJSONObject extracts a JSON object from raw model text. It accepts pure JSON, fenced ```json blocks, or the first balanced object in the text.
func GitHubCLIDiagnostic ¶
GitHubCLIDiagnostic returns an actionable auth diagnostic for common gh errors.
func HandoffSchemaPrompt ¶
func HandoffSchemaPrompt(name string, schema json.RawMessage) string
HandoffSchemaPrompt returns compact instructions for schema-constrained child runs.
func ResolveHandoffSchema ¶
func ResolveHandoffSchema(name string, schema json.RawMessage) (json.RawMessage, string, error)
ResolveHandoffSchema returns the schema selected by a caller. Custom schemas take precedence over named schemas. An empty name and empty schema means the legacy markdown handoff contract should be used.
func TruncateOutput ¶
TruncateOutput truncates s to maxChars characters, appending a human-readable suffix indicating how many characters were elided. If maxChars <= 0 or s is already short enough, returns s unchanged.
func ValidEnvName ¶
ValidEnvName reports whether name is safe to use as an environment key.
func ValidateJSONSchema ¶
func ValidateJSONSchema(raw json.RawMessage, schema json.RawMessage) []string
ValidateJSONSchema implements the small JSON Schema subset needed by handoff contracts: type, required, properties, items, and enum.
func ValidateStructuredHandoff ¶
func ValidateStructuredHandoff(text string, schema json.RawMessage) (json.RawMessage, []string)
ValidateStructuredHandoff extracts a JSON object from model text and validates it against a resolved handoff schema.
func WebSearchEnabled ¶
func WebSearchEnabled() bool
WebSearchEnabled returns true if the Brave Search API key is configured.
Types ¶
type AgentRunFn ¶
type AgentRunFn func(ctx context.Context, params AgentRunParams) AgentRunResult
AgentRunFn runs a sub-agent with the given parameters and returns the result. It is injected by the wiring layer to avoid import cycles between tools and core.
type AgentRunParams ¶
type AgentRunParams struct {
CallID string
RunID string
StepID string
Agent string
Pattern string
Task string
Provider string
Model string
Tools []string
MaxSteps int
HandoffSchemaName string
HandoffSchema json.RawMessage
WorkspaceDir string
StateDir string
}
AgentRunParams describes the sub-agent invocation.
type AgentRunResult ¶
type AgentRunResult struct {
OK bool
AgentRunID string
Result string
Structured json.RawMessage
Diagnostics []string
UsedSteps int
UsedTokens int
CostUSD float64
}
AgentRunResult holds the sub-agent's outcome.
type BlobInfo ¶
BlobInfo is the subset of the uploadBlob response needed to embed a blob in a record (e.g. app.bsky.embed.images).
type DangerLevel ¶
type DangerLevel string
DangerLevel classifies how risky a tool operation is.
const ( Safe DangerLevel = "safe" Dangerous DangerLevel = "dangerous" )
type PathTranslator ¶
type PathTranslator interface {
ToSandbox(path string) string
ToVirtual(path string) string
SanitizeText(text string) string
SecurePath(path string) (string, bool)
}
PathTranslator defines the subset of core.PathMapper needed by tools.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds registered tools and enforces the enabled allowlist.
func NewRegistry ¶
NewRegistry creates a registry with the given tool allowlist.
func (*Registry) Effects ¶
func (r *Registry) Effects(name string) ToolEffects
Effects returns the execution effects metadata for a registered tool.
func (*Registry) EnabledTools ¶
EnabledTools returns all enabled Tool objects.
func (*Registry) IsDangerous ¶
IsDangerous returns true if the named tool is classified as Dangerous.
func (*Registry) MissingEnabledNames ¶
MissingEnabledNames returns enabled tool names that are not registered.
func (*Registry) RegisterAndEnable ¶
RegisterAndEnable adds or replaces a tool in the registry and marks it enabled.
func (*Registry) RegisteredTools ¶
RegisteredTools returns all currently registered Tool objects, regardless of enabled state.
func (*Registry) Specs ¶
Specs returns ToolSpec slices for all enabled tools (used to send to provider).
func (*Registry) Unregister ¶
Unregister removes a tool instance from the registry.
type SecretRedactor ¶
type SecretRedactor struct {
// contains filtered or unexported fields
}
SecretRedactor redacts configured secret values from tool-visible text.
func NewSecretRedactor ¶
func NewSecretRedactor(patterns []string, toolEnv []string) *SecretRedactor
NewSecretRedactor builds a redactor from explicit tool env entries and the parent env values whose names match configured redact patterns.
func (*SecretRedactor) RedactText ¶
func (r *SecretRedactor) RedactText(text string) string
type Tool ¶
type Tool interface {
Name() string
Description() string
InputSchema() json.RawMessage
OutputSchema() json.RawMessage
DangerLevel() DangerLevel
Effects() ToolEffects
Exec(ctx context.Context, call ToolCallContext, args json.RawMessage) (ToolResult, error)
}
Tool is the interface all agent tools implement.
func ATProtoAnonSynth ¶
ATProtoAnonSynth returns the atproto_anon_synth tool.
func ATProtoCommunityDetect ¶
ATProtoCommunityDetect returns the atproto_community_detect tool.
func ATProtoCreateRecord ¶
func ATProtoDailyDigest ¶
ATProtoDailyDigest returns the daily_digest tool.
func ATProtoEngagementHealth ¶
ATProtoEngagementHealth returns the engagement_health tool.
func ATProtoFeed ¶
ATProtoFeed returns the atproto_feed tool.
func ATProtoFollowerMomentum ¶
ATProtoFollowerMomentum returns the atproto_follower_momentum tool.
func ATProtoGetFollowers ¶
ATProtoGetFollowers returns the atproto_get_followers tool.
func ATProtoGetFollows ¶
ATProtoGetFollows returns the atproto_get_follows tool.
func ATProtoGetProfile ¶
ATProtoGetProfile returns the atproto_get_profile tool.
func ATProtoGraphExplorer ¶
ATProtoGraphExplorer returns the atproto_graph_explorer tool.
func ATProtoIndex ¶
ATProtoIndex returns the atproto_index tool.
func ATProtoNotifications ¶
ATProtoNotifications returns the atproto_notifications tool.
func ATProtoPost ¶
ATProtoPost returns the atproto_post tool.
func ATProtoRecall ¶
ATProtoRecall returns the atproto_recall tool.
func ATProtoResolve ¶
ATProtoResolve returns the atproto_resolve tool.
func ATProtoUploadBlob ¶
ATProtoUploadBlob returns the atproto_upload_blob tool.
func ATProtoVibeCheck ¶
ATProtoVibeCheck returns the vibe_check tool.
func BlackboardRead ¶
func BlackboardRead() Tool
func BlackboardSearch ¶
func BlackboardSearch() Tool
func BlackboardStore ¶
func BlackboardStore() Tool
func BlackboardWrite ¶
func BlackboardWrite() Tool
func FSRenderImage ¶
func FSRenderImage() Tool
func Fingerprint ¶
func Fingerprint() Tool
func InspectTool ¶
func InspectTool() Tool
func NewAgent ¶
func NewAgent(runFn AgentRunFn) Tool
NewAgent creates a new agent tool instance. The runFn callback is invoked at Exec time to run the child loop.
func NewDeepResearch ¶
func NewDeepResearch(runFn AgentRunFn) Tool
NewDeepResearch creates a web research harness that fans out Brave searches, fetches sources, asks model/sub-agent perspectives, and returns a cited report.
func NewDispatch ¶
func NewDispatch(runFn AgentRunFn, listAgents func() []string) Tool
NewDispatch creates a role-based dispatch tool.
func NewOrchestrate ¶
func NewOrchestrate(runFn AgentRunFn, listAgents func() []string) Tool
NewOrchestrate creates a coordination tool for fanout/pipeline dispatch.
func PatchApply ¶
func PatchApply() Tool
func ProjectSearch ¶
func ProjectSearch() Tool
func ProvenanceLookup ¶
func ProvenanceLookup() Tool
func SourceCode ¶
func SourceCode() Tool
SourceCode creates a read-only dependency/package source inspection tool.
func WebExtract ¶
func WebExtract() Tool
type ToolCallContext ¶
type ToolCallContext struct {
RunID string
StepID string
CallID string
WorkspaceDir string // host path to active workspace (sandbox if enabled)
HostWorkspaceDir string // original source workspace for shared state across runs
StateDir string // host path for run-scoped mutable state
TimeoutMS int
Provider providers.Provider
EmbedProvider providers.Provider // dedicated embedding provider; falls back to Provider if nil
Registry *Registry // access to other enabled tools
Session executor.Session // active sandbox session
Mapper PathTranslator // bidirectional path mapping
Env []string // explicit environment passthrough entries (KEY=value)
RedactText func(string) string // redacts secret values from tool-visible output
EmitOutputDelta func(stream, text string) error
}
ToolCallContext provides runtime context to a tool execution.
type ToolEffects ¶
type ToolEffects struct {
MutatesWorkspace bool
MutatesRunState bool
NeedsNetwork bool
ExternalSideEffect bool
}
ToolEffects captures execution semantics independent of confirmation risk.
type ToolResult ¶
type ToolResult struct {
OK bool `json:"ok"`
Output string `json:"output"`
Stdout string `json:"stdout,omitempty"`
Stderr string `json:"stderr,omitempty"`
Structured json.RawMessage `json:"structured,omitempty"`
TaintLevel string `json:"taint_level,omitempty"`
DurationMS int64 `json:"duration_ms"`
}
ToolResult holds the output of a tool execution.
func CapToolResult ¶
func CapToolResult(r ToolResult) ToolResult
CapToolResult applies DefaultToolResultChars to a ToolResult's Output and Stdout fields. Convenience wrapper for tools that build large string/JSON outputs and want consistent tool-layer truncation.
Source Files
¶
- agent.go
- atproto.go
- atproto_client.go
- atproto_digest.go
- atproto_graph.go
- atproto_rag.go
- atproto_synth.go
- blackboard.go
- caps.go
- credentials.go
- curl.go
- deep_research.go
- dispatch.go
- fingerprint.go
- fs.go
- git.go
- handoff.go
- meta.go
- news.go
- orchestrate.go
- patch.go
- provenance.go
- reflect.go
- registry.go
- search.go
- sem.go
- semantic.go
- sh.go
- source_code.go
- tool.go
- tool_safety.go
- translate.go
- web_extract.go
- web_search.go
- wiki.go