Help us shape the future of Go! Take the 2026 Go Developer Survey

tools

package
v1.4.33 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package tools contains cross-cutting read-only AI tools backed by external sources.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterBaselineAuthorized added in v1.4.27

func FilterBaselineAuthorized(ctx context.Context, tools []core.Tool) []core.Tool

FilterBaselineAuthorized removes the baseline tool from unauthorized catalogs.

Types

type ChangeFeed

type ChangeFeed interface {
	// Changes returns every change record at or after `since`. A missing
	// or empty feed yields an empty slice and a nil error (a clean miss,
	// never a hard failure).
	Changes(ctx context.Context, since time.Time) ([]ChangeRecord, error)
}

ChangeFeed is the read-only feed of recent changes the recent_changes tool reads from. It is declared as a local interface so the tools package stays decoupled from config and pkg/agent.

func NewGitChangeFeed

func NewGitChangeFeed(repos []GitRepo) ChangeFeed

NewGitChangeFeed returns a ChangeFeed backed by the given remote git repositories. Repos with an empty URL are ignored; an empty (or all-empty) list yields nil so analyzetools.Default omits the recent_changes tool. No external git binary is required.

type ChangeRecord

type ChangeRecord struct {
	Timestamp time.Time `json:"timestamp"`
	Service   string    `json:"service"`
	Kind      string    `json:"kind"`
	Summary   string    `json:"summary"`
	Ref       string    `json:"ref,omitempty"`
}

ChangeRecord is one change derived from a git commit: a deploy, config change, or feature-flag flip recorded in the repository's history.

type DependencyGraph

type DependencyGraph struct {
	// contains filtered or unexported fields
}

DependencyGraph is the read-only service-dependency graph that powers the describe_dependencies tool. It is built from the operator-authored `depends_on` (upstream) edges; the reverse `depended_on_by` (downstream) edges are derived automatically. The graph is immutable after construction.

func NewDependencyGraph

func NewDependencyGraph(dependsOn map[string][]string) *DependencyGraph

NewDependencyGraph builds a DependencyGraph from per-service upstream edges. The map key is a service name; the value is the list of services it depends on. Self-edges and duplicate neighbours are dropped; the reverse edges are derived. A nil/empty input yields an empty graph (every lookup is then a miss).

func (*DependencyGraph) Len

func (g *DependencyGraph) Len() int

Len reports how many service nodes the graph knows about.

func (*DependencyGraph) Topology added in v1.4.27

func (g *DependencyGraph) Topology(maxNodes, maxEdges int) core.ServiceTopology

Topology returns a deterministic bounded projection of the same graph used by describe_dependencies. Limits below zero are treated as zero.

type DescribeBaseline added in v1.4.27

type DescribeBaseline struct {
	Provider core.BaselineProvider
	OrgID    string
	Now      func() time.Time
}

DescribeBaseline reads learned expectations from a trusted scoped provider.

func (DescribeBaseline) ArgsSchema added in v1.4.27

func (DescribeBaseline) ArgsSchema() map[string]any

func (DescribeBaseline) AvailabilityCapability added in v1.4.27

func (tool DescribeBaseline) AvailabilityCapability() (string, string, int)

AvailabilityCapability reports the constructed baseline surface.

func (DescribeBaseline) Description added in v1.4.27

func (DescribeBaseline) Description() string

func (DescribeBaseline) DisplayName added in v1.4.27

func (DescribeBaseline) DisplayName() string

func (DescribeBaseline) Invoke added in v1.4.27

func (tool DescribeBaseline) Invoke(ctx context.Context, raw json.RawMessage) (*core.ToolResult, error)

func (DescribeBaseline) Name added in v1.4.27

func (DescribeBaseline) Name() string

type DescribeDependencies

type DescribeDependencies struct {
	Graph *DependencyGraph
	// Store is optional. When nil, neighbours are returned without the
	// has_recent_incident annotation.
	Store storage.Provider
	// Scope is the ordered organization read scope. Its zero value is the
	// default-only OSS view.
	Scope tenancy.OrgScope
}

DescribeDependencies surfaces the upstream and downstream neighbours of a service from the operator-authored dependency graph, each annotated with whether that neighbour also has a recent incident. The agent uses it to reason about cascading failures.

func (DescribeDependencies) ArgsSchema

func (DescribeDependencies) ArgsSchema() map[string]any

ArgsSchema implements core.AnalyzeTool.

func (DescribeDependencies) Description

func (DescribeDependencies) Description() string

Description implements core.AnalyzeTool.

func (DescribeDependencies) DisplayName

func (DescribeDependencies) DisplayName() string

func (DescribeDependencies) Invoke

Invoke implements core.AnalyzeTool.

func (DescribeDependencies) Name

Name implements core.AnalyzeTool.

type FindRunbook

type FindRunbook struct {
	Embedder core.Embedder
	Index    RunbookSearcher
	Redactor LineRedactor
}

FindRunbook is the read-only runbook-RAG tool. During an investigation it embeds a redacted query derived from the incident, runs a top-K similarity search over the operator-supplied runbook corpus, and returns the best-matching excerpts so the model can ground its finding in the team's own remediation docs. It performs NO writes, NO ingestion, NO on-call trigger, and NO notification — it is search-only.

The query MUST be scrubbed through the redactor before it reaches the embedder: the embeddings call is the same external trust boundary as the chat-completion call, so incident-derived text never egresses raw.

func (FindRunbook) ArgsSchema

func (FindRunbook) ArgsSchema() map[string]any

ArgsSchema implements core.AnalyzeTool.

func (FindRunbook) Description

func (FindRunbook) Description() string

Description implements core.AnalyzeTool.

func (FindRunbook) DisplayName

func (FindRunbook) DisplayName() string

func (FindRunbook) Invoke

func (fr FindRunbook) Invoke(ctx context.Context, args json.RawMessage) (*core.ToolResult, error)

Invoke implements core.AnalyzeTool. Flow: scrub query -> embed -> top-K search -> scrub excerpts -> return.

func (FindRunbook) Name

func (FindRunbook) Name() string

Name implements core.AnalyzeTool.

type GitRepo

type GitRepo struct {
	// URL is the remote clone URL (https or scp-like git@host:org/repo).
	URL string
	// Branch optionally pins which branch to read; empty = default HEAD.
	Branch string
	// Service maps every commit in this repository to a service name.
	// Empty derives the service from the repository name in the URL.
	Service string
	// Token is an HTTPS access token / PAT used to authenticate to the
	// remote. Empty relies on ambient credentials.
	Token string
	// SSHKeyPath is the path to a private SSH key used for ssh / scp-like
	// remotes. Empty relies on the ambient SSH configuration.
	SSHKeyPath string
}

GitRepo describes one remote git repository the change feed reads.

type LineRedactor

type LineRedactor interface {
	Scrub(s string) string
}

LineRedactor scrubs sensitive substrings before they reach a model.

type RecentChanges

type RecentChanges struct {
	Feed ChangeFeed
}

RecentChanges surfaces recent deploys, config changes, and feature-flag flips so Chat and Analyze can correlate an incident with what changed just before it. It is strictly read-only.

func (RecentChanges) ArgsSchema

func (RecentChanges) ArgsSchema() map[string]any

ArgsSchema implements core.AnalyzeTool.

func (RecentChanges) Description

func (RecentChanges) Description() string

Description implements core.AnalyzeTool.

func (RecentChanges) DisplayName

func (RecentChanges) DisplayName() string

func (RecentChanges) Invoke

func (rc RecentChanges) Invoke(ctx context.Context, args json.RawMessage) (*core.ToolResult, error)

Invoke implements core.AnalyzeTool.

func (RecentChanges) Name

func (RecentChanges) Name() string

Name implements core.AnalyzeTool.

type RelatedLogs

type RelatedLogs struct {
	Reader   SignalReader
	Redactor LineRedactor
	Services ServiceExtractor
}

RelatedLogs pulls a raw-log slice from the configured signal sources around the incident window so the analyze agent can inspect the surrounding context. Every returned line is scrubbed through the same redactor used before any AI call, so secrets never reach the model.

func (RelatedLogs) ArgsSchema

func (RelatedLogs) ArgsSchema() map[string]any

ArgsSchema implements core.AnalyzeTool.

func (RelatedLogs) Description

func (RelatedLogs) Description() string

Description implements core.AnalyzeTool.

func (RelatedLogs) DisplayName

func (RelatedLogs) DisplayName() string

func (RelatedLogs) Invoke

func (rl RelatedLogs) Invoke(ctx context.Context, args json.RawMessage) (*core.ToolResult, error)

Invoke implements core.AnalyzeTool.

func (RelatedLogs) Name

func (RelatedLogs) Name() string

Name implements core.AnalyzeTool.

type RunbookMatch

type RunbookMatch struct {
	ID      string  `json:"id"`
	Title   string  `json:"title"`
	Service string  `json:"service,omitempty"`
	Score   float32 `json:"score"`
	Excerpt string  `json:"excerpt,omitempty"`
	Source  string  `json:"source,omitempty"`
}

RunbookMatch is one runbook hit returned to the model. It is the tools-package mirror of the vector index's result so the tool stays decoupled from pkg/runbook (the write path): the bridge in pkg/agent/analyze_adapter.go converts the concrete index results into this shape, keeping the import graph one-directional and the read-only guard green.

type RunbookSearcher

type RunbookSearcher interface {
	Search(ctx context.Context, query []float32, service string, limit int) ([]RunbookMatch, error)
}

RunbookSearcher is the read-only vector-search seam the find_runbook tool depends on. Declared as a local interface (not an import of pkg/runbook) so the tools package never pulls in the ingestion/write path — the import-graph guard enforces this. Search takes an already embedded query vector, an optional service filter, and a result cap.

type ServiceExtractor

type ServiceExtractor interface {
	Extract(message string) string
}

ServiceExtractor extracts an operator-configured service name from a message.

type SignalReader

type SignalReader interface {
	Sources() []string
	Pull(ctx context.Context, source string, since time.Time) ([]core.Signal, error)
}

SignalReader is the read-only slice of configured signal sources used by tools.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL