Documentation
¶
Overview ¶
Package tools provides a provider-neutral tool catalog and portable tools.
Index ¶
- Constants
- func AppendToolResultMiddlewareTelemetryAttrs(attrs map[string]any, event ToolResultMiddlewareEvent) map[string]any
- func AppendToolResultTransformTelemetryAttrs(attrs map[string]any, result ToolResultTransformResult) map[string]any
- func NormalizeToolName(name string) string
- func SanitizeToolDefinitionForBackendCompatibility(def types.Tool) types.Tool
- func SanitizeToolDefinitionsForBackendCompatibility(defs []types.Tool) []types.Tool
- func SortByName(definitions []toolcontract.Definition)
- func ToolSessionIDFromContext(ctx context.Context) string
- func WithToolRuntimeNetworkGuard(ctx context.Context, guard RuntimeNetworkGuard) context.Context
- func WithToolSessionID(ctx context.Context, sessionID string) context.Context
- type ChainExecutor
- type Executor
- type Handler
- type OptionalBool
- type OptionalInts
- type OptionalStrings
- type Registry
- func (r *Registry) Definitions() []toolcontract.Definition
- func (r *Registry) Execute(ctx context.Context, call toolcontract.Call) (toolcontract.Result, error)
- func (r *Registry) Register(definition toolcontract.Definition, handler Handler)
- func (r *Registry) Reset()
- func (r *Registry) Version() uint64
- type RuntimeNetworkGuard
- type ToolContentClassifier
- type ToolMetadata
- type ToolNameError
- type ToolNameRepairResolution
- type ToolResultArgumentsSummary
- type ToolResultContentSummary
- type ToolResultMiddlewareEvent
- type ToolResultMiddlewareInput
- type ToolResultOutputSchema
- type ToolResultTerminalObservationSummary
- type ToolResultTransformInput
- type ToolResultTransformResult
- type ToolResultTransformSummary
Constants ¶
const ( ToolSourceUnknown = "unknown" ToolSourceBuiltin = "builtin" ToolSourceExtension = "extension" ToolSourceProject = "project" ToolSourceCustom = "custom" )
Tool source values describe where a catalog entry is owned. They are descriptive metadata only; they do not grant authorization or select a backend.
const ( ToolResultMiddlewareModeObserveOnly = "observe_only" ToolResultMiddlewareReasonLargeResult = "large_result" ToolResultMiddlewareReasonRuntimeGuardTruncated = "runtime_guard_truncated" ToolResultMiddlewareReasonSensitiveKeyPresent = "sensitive_key_present" ToolResultMiddlewareReasonEmbeddedBinaryPayload = "embedded_binary_payload" ToolResultMiddlewareStrategySummarizeWithRawRef = "summarize_with_raw_ref" ToolResultMiddlewareStrategyPreserveRawArtifact = "preserve_raw_artifact" ToolResultMiddlewareStrategyRedactSensitiveKeys = "redact_sensitive_keys" ToolResultMiddlewareStrategyExtractArtifactRef = "extract_artifact_ref" )
const ( ToolResultMiddlewareModeControlledTransform = "controlled_transform" ToolResultTransformReasonMissingRawResultRef = "missing_raw_result_ref" )
Variables ¶
This section is empty.
Functions ¶
func AppendToolResultMiddlewareTelemetryAttrs ¶
func AppendToolResultMiddlewareTelemetryAttrs(attrs map[string]any, event ToolResultMiddlewareEvent) map[string]any
func AppendToolResultTransformTelemetryAttrs ¶
func AppendToolResultTransformTelemetryAttrs(attrs map[string]any, result ToolResultTransformResult) map[string]any
func NormalizeToolName ¶
NormalizeToolName returns the stable lower-case catalog name and applies the two legacy aliases already accepted by AgentX hosts.
func SanitizeToolDefinitionsForBackendCompatibility ¶
SanitizeToolDefinitionsForBackendCompatibility normalizes tool schemas before they reach model/provider request assembly. It keeps the canonical tool owner unchanged while making the final exposed schema shape backend-friendly.
func SortByName ¶
func SortByName(definitions []toolcontract.Definition)
SortByName sorts definitions by their normalized function name.
func ToolSessionIDFromContext ¶
ToolSessionIDFromContext returns the normalized session identity, if any.
func WithToolRuntimeNetworkGuard ¶
func WithToolRuntimeNetworkGuard(ctx context.Context, guard RuntimeNetworkGuard) context.Context
WithToolRuntimeNetworkGuard returns a context carrying normalized, host-selected network overrides. An empty guard is a no-op.
Types ¶
type ChainExecutor ¶
type ChainExecutor struct {
Executors []toolcontract.Executor
}
ChainExecutor dispatches calls across multiple executors. It falls back only when the current executor does not know the tool.
func (ChainExecutor) Definitions ¶
func (c ChainExecutor) Definitions() []toolcontract.Definition
func (ChainExecutor) Execute ¶
func (c ChainExecutor) Execute(ctx context.Context, call toolcontract.Call) (toolcontract.Result, error)
type OptionalBool ¶
OptionalBool distinguishes an explicit false value from no override.
type OptionalInts ¶
OptionalInts distinguishes an explicitly empty list from no override.
type OptionalStrings ¶
OptionalStrings distinguishes an explicitly empty list from no override.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is a concurrency-safe catalog and executor.
func (*Registry) Definitions ¶
func (r *Registry) Definitions() []toolcontract.Definition
Definitions returns a stable, name-sorted snapshot.
func (*Registry) Execute ¶
func (r *Registry) Execute(ctx context.Context, call toolcontract.Call) (toolcontract.Result, error)
Execute invokes a registered handler, including deterministic name repair.
func (*Registry) Register ¶
func (r *Registry) Register(definition toolcontract.Definition, handler Handler)
Register associates a function name with its handler. Empty or nil values are ignored.
type RuntimeNetworkGuard ¶
type RuntimeNetworkGuard struct {
WebSearchAllowPrivateHosts OptionalBool
WebSearchTrustedEnvProxy OptionalBool
WebSearchAllowCIDRs OptionalStrings
WebSearchDenyCIDRs OptionalStrings
WebSearchAllowPorts OptionalInts
WebSearchDenyPorts OptionalInts
WebFetchAllowPrivateHosts OptionalBool
WebFetchTrustedEnvProxy OptionalBool
WebFetchAllowCIDRs OptionalStrings
WebFetchDenyCIDRs OptionalStrings
WebFetchAllowPorts OptionalInts
WebFetchDenyPorts OptionalInts
HTTPRequestAllowPrivateHosts OptionalBool
HTTPRequestTrustedEnvProxy OptionalBool
HTTPRequestAllowCIDRs OptionalStrings
HTTPRequestDenyCIDRs OptionalStrings
HTTPRequestAllowPorts OptionalInts
HTTPRequestDenyPorts OptionalInts
BrowserProxyAllowPrivateHosts OptionalBool
BrowserProxyTrustedEnvProxy OptionalBool
BrowserProxyAllowCIDRs OptionalStrings
BrowserProxyDenyCIDRs OptionalStrings
BrowserProxyAllowPorts OptionalInts
BrowserProxyDenyPorts OptionalInts
NodesGatewayAllowPrivateHosts OptionalBool
NodesGatewayTrustedEnvProxy OptionalBool
NodesGatewayAllowCIDRs OptionalStrings
NodesGatewayDenyCIDRs OptionalStrings
NodesGatewayAllowPorts OptionalInts
NodesGatewayDenyPorts OptionalInts
}
RuntimeNetworkGuard carries host-selected per-run network-policy overrides. It does not decide defaults and it does not perform network I/O.
func ToolRuntimeNetworkGuardFromContext ¶
func ToolRuntimeNetworkGuardFromContext(ctx context.Context) (RuntimeNetworkGuard, bool)
ToolRuntimeNetworkGuardFromContext returns normalized network overrides.
type ToolContentClassifier ¶
ToolContentClassifier classifies the trust boundary of one tool result. Implementations must be deterministic and must not perform side effects.
type ToolMetadata ¶
type ToolMetadata struct {
Plugin string
Groups []string
Type string
Source string
Capabilities []string
AuditTags []string
RiskProfile string
ReadOnly *bool
ConcurrencySafe *bool
Destructive *bool
}
ToolMetadata describes a tool catalog entry without owning authorization, approval, sandbox, credential, or backend policy.
Pointer booleans preserve the distinction between an explicit false value and an unspecified hint.
type ToolNameError ¶
type ToolNameError struct {
Requested string
NormalizedKey string
Candidates []string
Ambiguous bool
Reason string
}
ToolNameError reports a missing or ambiguous tool name.
func AsToolNameError ¶
func AsToolNameError(err error) (*ToolNameError, bool)
AsToolNameError extracts a typed tool-name error.
func NewToolNameError ¶
func NewToolNameError(requested string, resolution ToolNameRepairResolution) *ToolNameError
NewToolNameError constructs a defensive typed error.
func (*ToolNameError) Code ¶
func (e *ToolNameError) Code() string
Code returns a stable error classification.
func (*ToolNameError) Error ¶
func (e *ToolNameError) Error() string
func (*ToolNameError) Repairable ¶
func (e *ToolNameError) Repairable() bool
Repairable reports whether the caller can retry with one suggested candidate.
type ToolNameRepairResolution ¶
type ToolNameRepairResolution struct {
Requested string
Name string
NormalizedKey string
Candidates []string
Repaired bool
Ambiguous bool
Reason string
Confidence string
}
ToolNameRepairResolution describes deterministic normalization and candidate selection.
func RepairToolName ¶
func RepairToolName(requested string, registered []string) ToolNameRepairResolution
RepairToolName resolves a model-emitted name against registered names.
type ToolResultContentSummary ¶
type ToolResultContentSummary struct {
Bytes int `json:"bytes"`
Chars int `json:"chars"`
Lines int `json:"lines"`
LooksBinary bool `json:"looks_binary,omitempty"`
JSONValid bool `json:"json_valid,omitempty"`
JSONTopLevelKeys []string `json:"json_top_level_keys,omitempty"`
SensitiveKeyHits []string `json:"sensitive_key_hits,omitempty"`
EmbeddedBinaryKeys []string `json:"embedded_binary_keys,omitempty"`
OriginalBytes int `json:"original_bytes,omitempty"`
KeptBytes int `json:"kept_bytes,omitempty"`
Truncated bool `json:"truncated,omitempty"`
GuardStrategy string `json:"guard_strategy,omitempty"`
}
type ToolResultMiddlewareEvent ¶
type ToolResultMiddlewareEvent struct {
ToolName string `json:"tool_name"`
Mode string `json:"mode"`
SessionID string `json:"session_id,omitempty"`
RunID string `json:"run_id,omitempty"`
ObservationOnly bool `json:"observation_only"`
IsError bool `json:"is_error,omitempty"`
ExternalContent bool `json:"external_content,omitempty"`
UntrustedContent bool `json:"untrusted_content,omitempty"`
Arguments ToolResultArgumentsSummary `json:"arguments,omitempty"`
RawResultRef string `json:"raw_result_ref,omitempty"`
ArtifactRefs []string `json:"artifact_refs,omitempty"`
Content ToolResultContentSummary `json:"content"`
OutputSchema *ToolResultOutputSchema `json:"output_schema,omitempty"`
TerminalObservation *ToolResultTerminalObservationSummary `json:"terminal_observation,omitempty"`
Details []string `json:"details,omitempty"`
WouldTransform bool `json:"would_transform"`
WouldTransformReasons []string `json:"would_transform_reasons,omitempty"`
SuggestedStrategies []string `json:"suggested_strategies,omitempty"`
}
func BuildToolResultMiddlewareEvent ¶
func BuildToolResultMiddlewareEvent(input ToolResultMiddlewareInput) ToolResultMiddlewareEvent
type ToolResultMiddlewareInput ¶
type ToolResultMiddlewareInput struct {
ToolName string
SessionID string
RunID string
Arguments string
Output string
OutputSchema map[string]any
RawResultRef string
ArtifactRefs []string
IsError bool
OutputOriginalBytes int
OutputKeptBytes int
OutputTruncated bool
OutputGuardStrategy string
LargeResultBytes int
LargeResultLines int
// ClassifyContent lets a Host preserve product-specific trust classification
// without moving browser, document, process or network policy into this module.
ClassifyContent ToolContentClassifier
}
type ToolResultOutputSchema ¶
type ToolResultOutputSchema struct {
Present bool `json:"present"`
Closed bool `json:"closed"`
PropertyCount int `json:"property_count,omitempty"`
Required []string `json:"required,omitempty"`
MatchedTopLevelKeys []string `json:"matched_top_level_keys,omitempty"`
MissingRequired []string `json:"missing_required,omitempty"`
UnexpectedTopLevelKeys []string `json:"unexpected_top_level_keys,omitempty"`
Drift bool `json:"drift"`
}
type ToolResultTerminalObservationSummary ¶
type ToolResultTerminalObservationSummary struct {
Present bool `json:"present"`
Kind string `json:"kind,omitempty"`
Visibility string `json:"visibility,omitempty"`
Surface string `json:"surface,omitempty"`
Action string `json:"action,omitempty"`
DisplayCommand string `json:"display_command,omitempty"`
UserVisible bool `json:"user_visible,omitempty"`
Reason string `json:"reason,omitempty"`
}
type ToolResultTransformInput ¶
type ToolResultTransformInput struct {
Event ToolResultMiddlewareEvent
Output string
RawResultRef string
ArtifactRefs []string
}
type ToolResultTransformResult ¶
type ToolResultTransformResult struct {
Applied bool `json:"applied"`
Mode string `json:"mode"`
Output string `json:"output"`
RawResultRef string `json:"raw_result_ref,omitempty"`
ArtifactRefs []string `json:"artifact_refs,omitempty"`
Reasons []string `json:"reasons,omitempty"`
Strategies []string `json:"strategies,omitempty"`
Details []string `json:"details,omitempty"`
ErrorPreserved bool `json:"error_preserved,omitempty"`
Summary *ToolResultTransformSummary `json:"summary,omitempty"`
}
func BuildControlledToolResultTransform ¶
func BuildControlledToolResultTransform(input ToolResultTransformInput) ToolResultTransformResult
type ToolResultTransformSummary ¶
type ToolResultTransformSummary struct {
ToolName string `json:"tool_name,omitempty"`
ContentBytes int `json:"content_bytes,omitempty"`
ContentChars int `json:"content_chars,omitempty"`
ContentLines int `json:"content_lines,omitempty"`
OriginalBytes int `json:"original_bytes,omitempty"`
KeptBytes int `json:"kept_bytes,omitempty"`
Truncated bool `json:"truncated,omitempty"`
GuardStrategy string `json:"guard_strategy,omitempty"`
JSONValid bool `json:"json_valid,omitempty"`
JSONTopLevelKeys []string `json:"json_top_level_keys,omitempty"`
SensitiveKeyHits []string `json:"sensitive_key_hits,omitempty"`
EmbeddedBinaryKeys []string `json:"embedded_binary_keys,omitempty"`
ExternalContent bool `json:"external_content,omitempty"`
UntrustedContent bool `json:"untrusted_content,omitempty"`
RawResultRef string `json:"raw_result_ref,omitempty"`
ArtifactRefs []string `json:"artifact_refs,omitempty"`
OutputSchema *ToolResultOutputSchema `json:"output_schema,omitempty"`
}
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package agent provides the model-facing Task, Session child and Subagent tool contract over a Host-owned durable lifecycle.
|
Package agent provides the model-facing Task, Session child and Subagent tool contract over a Host-owned durable lifecycle. |
|
Package diffs implements the portable text-only diffs tool.
|
Package diffs implements the portable text-only diffs tool. |
|
Package filesystem provides portable filesystem tool coordination.
|
Package filesystem provides portable filesystem tool coordination. |
|
Package httprequest provides portable HTTP tool request/response coordination.
|
Package httprequest provides portable HTTP tool request/response coordination. |
|
Package llmtask provides one bounded, model-only JSON subtask tool.
|
Package llmtask provides one bounded, model-only JSON subtask tool. |
|
Package memory provides portable memory search/get tool coordination.
|
Package memory provides portable memory search/get tool coordination. |
|
Package message provides the portable AgentX channel message tool.
|
Package message provides the portable AgentX channel message tool. |
|
Package process provides an explicit, bounded local process adapter.
|
Package process provides an explicit, bounded local process adapter. |
|
Package scheduler provides portable scheduled-command tool coordination.
|
Package scheduler provides portable scheduled-command tool coordination. |
|
Package videoframes provides an explicit, opt-in local video-frame adapter.
|
Package videoframes provides an explicit, opt-in local video-frame adapter. |
|
Package web provides portable Web Search, Fetch, OpenPage and FindInPage tools.
|
Package web provides portable Web Search, Fetch, OpenPage and FindInPage tools. |