tools

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PDFSurfaceUnified    = "pdf_unified"
	PDFSurfaceSpecialist = "pdf_specialist"
)
View Source
const ToolSourceBuiltin = agentxtools.ToolSourceBuiltin

Variables

This section is empty.

Functions

func DocumentParseDefinition

func DocumentParseDefinition() types.Tool

DocumentParseDefinition returns the model-facing document_parse contract.

func DocumentSpecRecommendDefinition

func DocumentSpecRecommendDefinition() types.Tool

DocumentSpecRecommendDefinition returns the read-only recommendation contract.

func IsBuiltinCoreTool

func IsBuiltinCoreTool(name string) bool

func IsPDFSpecialistToolName

func IsPDFSpecialistToolName(name string) bool

func IsPDFUnifiedToolName

func IsPDFUnifiedToolName(name string) bool

func NormalizePDFSurface

func NormalizePDFSurface(raw string) string

func PDFAllToolNames

func PDFAllToolNames() []string

func PDFDefinition

func PDFDefinition(name string, unifiedAvailable bool) (types.Tool, bool)

PDFDefinition returns one model-facing PDF tool declaration. The boolean controls only specialist guidance text and never enables execution.

func PDFSpecialistToolNames

func PDFSpecialistToolNames() []string

func PDFSurfaceFallbackEntrypoint

func PDFSurfaceFallbackEntrypoint(surface string) string

func PDFSurfaceForToolName

func PDFSurfaceForToolName(name string) string

func PDFToolMetadata

func PDFToolMetadata(defs []types.Tool) map[string]ToolMetadata

func PDFUnifiedToolNames

func PDFUnifiedToolNames() []string

func RegisterDocumentParseTools

func RegisterDocumentParseTools(reg toolcontract.Registrar, opts DocumentParseToolOptions) error

func RegisterPDFTools

func RegisterPDFTools(reg toolcontract.Registrar, opts PDFToolOptions) error

func ResolvePDFSurface

func ResolvePDFSurface(surface string, entrypoint string) (string, string)

Types

type ArtifactLister

type ArtifactLister interface {
	ListArtifacts(context.Context, string) ([]string, error)
}

ArtifactLister returns display-safe files written by an already authorized output directory.

type ArtifactListerFunc

type ArtifactListerFunc func(context.Context, string) ([]string, error)

ArtifactListerFunc adapts a function to ArtifactLister.

func (ArtifactListerFunc) ListArtifacts

func (f ArtifactListerFunc) ListArtifacts(ctx context.Context, outputDir string) ([]string, error)

type DocumentHost

type DocumentHost struct {
	Runtime       DocumentParser
	Paths         PathResolver
	Text          DocumentTextLoader
	Artifacts     ArtifactLister
	Errors        ErrorProjector
	LoadSpec      func(string) (*configs.DocSpec, error)
	RecommendSpec func(string, []*configs.DocSpec) []configs.SpecRecommendation
}

DocumentHost is the explicit construction seam for document_parse and document_spec_recommend. Runtime owns the portable parsing implementation; the remaining ports own authorization and concrete file access.

type DocumentParseToolOptions

type DocumentParseToolOptions struct {
	Root                  string
	DefaultModel          string
	DefaultArtifactPolicy pipeline.ArtifactPolicy
	DefaultExtractionMode pipeline.DocumentExtractionMode
	DefaultTimeoutMs      int
	MaxResponseBytes      int
	Host                  DocumentHost
	// EnabledTools is intentionally required for registration. document_parse
	// is a specialist surface and must not become visible by helper defaults.
	EnabledTools []string
}

type DocumentParser

type DocumentParser interface {
	Run(context.Context, pipeline.ParseRequest) (*types.DocumentResult, error)
}

DocumentParser is the narrow execution seam consumed by document_parse. *pipeline.Runtime satisfies it directly; compatibility Hosts can adapt an existing entry point without exposing their construction graph.

type DocumentParserFunc

type DocumentParserFunc func(context.Context, pipeline.ParseRequest) (*types.DocumentResult, error)

DocumentParserFunc adapts a function to DocumentParser.

func (DocumentParserFunc) Run

type DocumentTextLoader

type DocumentTextLoader interface {
	LoadDocumentText(context.Context, DocumentTextRequest) ([]string, error)
}

DocumentTextLoader owns concrete file decoding, OCR routing and filesystem access used by document_spec_recommend.

type DocumentTextLoaderFunc

type DocumentTextLoaderFunc func(context.Context, DocumentTextRequest) ([]string, error)

DocumentTextLoaderFunc adapts a function to DocumentTextLoader.

func (DocumentTextLoaderFunc) LoadDocumentText

func (f DocumentTextLoaderFunc) LoadDocumentText(ctx context.Context, request DocumentTextRequest) ([]string, error)

type DocumentTextRequest

type DocumentTextRequest struct {
	Path           string
	PageLimit      int
	PDFParseMode   pipeline.PDFParseMode
	ExtractionMode pipeline.DocumentExtractionMode
}

DocumentTextRequest asks the Host for a bounded page representation.

type ErrorProjector

type ErrorProjector interface {
	Classify(error) string
	Display(error, string, string) string
}

ErrorProjector maps Host errors to stable, display-safe tool output.

type ErrorProjectorFuncs

type ErrorProjectorFuncs struct {
	ClassifyFunc func(error) string
	DisplayFunc  func(error, string, string) string
}

ErrorProjectorFuncs is the function adapter for ErrorProjector.

func (ErrorProjectorFuncs) Classify

func (p ErrorProjectorFuncs) Classify(err error) string

func (ErrorProjectorFuncs) Display

func (p ErrorProjectorFuncs) Display(err error, toolName, class string) string

type PDFBackend

type PDFBackend interface {
	Name() string
	Availability(context.Context) PDFBackendAvailability
	ExtractAllText(context.Context, string) (PDFTextResult, error)
	ExtractPageText(context.Context, string, []int) (PDFTextResult, error)
	ReadMetadata(context.Context, string, bool) (PDFMetadataResult, error)
}

PDFBackend owns concrete PDF extraction and metadata access.

type PDFBackendAvailability

type PDFBackendAvailability struct {
	Name      string `json:"name"`
	Available bool   `json:"available"`
	Reason    string `json:"reason,omitempty"`
}

PDFBackendAvailability is an explicit Host probe result. Canonical tools do not discover binaries, Python installations or commercial SDK licenses.

type PDFBackendAvailabilityDetails

type PDFBackendAvailabilityDetails struct {
	Primary  PDFBackendAvailability `json:"primary"`
	Fallback PDFBackendAvailability `json:"fallback"`
}

PDFBackendAvailabilityDetails describes the configured primary/fallback pair.

type PDFFont

type PDFFont struct {
	Name string  `json:"name"`
	Size float64 `json:"size"`
}

PDFFont is a provider-neutral font projection used by pdf_outline.

type PDFHost

PDFHost contains every side-effecting/model capability needed by the portable PDF implementation. Nil optional capabilities fail closed or follow the existing deterministic fallback path.

type PDFInputRequest

type PDFInputRequest struct {
	Root       string
	Reference  string
	TimeoutMS  int
	MaxBytes   int
	Parameters map[string]any
}

PDFInputRequest asks the Host to authorize and materialize one local, file-URL or remote reference. Remote fetch policy belongs entirely to Host.

type PDFInputResolver

type PDFInputResolver interface {
	ResolvePDFInput(context.Context, PDFInputRequest) (ResolvedPDFInput, error)
}

PDFInputResolver is the only local/remote input access used by PDF tools.

type PDFInputResolverFunc

type PDFInputResolverFunc func(context.Context, PDFInputRequest) (ResolvedPDFInput, error)

PDFInputResolverFunc adapts a function to PDFInputResolver.

func (PDFInputResolverFunc) ResolvePDFInput

func (f PDFInputResolverFunc) ResolvePDFInput(ctx context.Context, request PDFInputRequest) (ResolvedPDFInput, error)

type PDFLayoutBackend

type PDFLayoutBackend interface {
	ExtractLayoutText(context.Context, string, []int) (PDFTextResult, error)
}

PDFLayoutBackend is the optional layout-preserving extension used for table and field-alignment evidence.

type PDFMetadataResult

type PDFMetadataResult struct {
	PageCount         int
	Outline           *PDFOutline
	Fonts             []PDFFont
	TotalRects        int
	PagesWithGraphics int
	MaxRectsPerPage   int
	GraphicPages      []int
	RectsByPage       map[int]int
}

PDFMetadataResult contains portable metadata required by the tool layer.

type PDFModelCandidate

type PDFModelCandidate struct {
	Name           string `json:"name"`
	Client         string `json:"client,omitempty"`
	Model          string `json:"model,omitempty"`
	NativePDF      bool   `json:"native_pdf,omitempty"`
	SupportsVision bool   `json:"-"`
	ConfigKey      string `json:"-"`
	Vendor         string `json:"-"`
}

PDFModelCandidate is one explicitly supplied model route. Model discovery, provider credentials and product routing remain Host-owned.

type PDFNativeRequest

type PDFNativeRequest struct {
	Candidate PDFModelCandidate
	Prompt    string
	Paths     []string
}

PDFNativeRequest contains no credential or provider client. The Host chooses and executes the concrete native-PDF provider.

type PDFOCRRequest

type PDFOCRRequest struct {
	Profile string
	Path    string
}

PDFOCRRequest delegates optional OCR enrichment to the Host.

type PDFOutline

type PDFOutline struct {
	Title    string       `json:"title"`
	Children []PDFOutline `json:"children,omitempty"`
}

PDFOutline is a recursive document outline item.

type PDFPageText

type PDFPageText struct {
	Page int    `json:"page"`
	Text string `json:"text"`
}

PDFPageText is one physical page and its extracted text.

type PDFRenderedPage

type PDFRenderedPage struct {
	Page     int
	Path     string
	Data     []byte
	MIMEType string
}

PDFRenderedPage is an explicitly rendered page owned by a Host adapter.

type PDFTextResult

type PDFTextResult struct {
	Pages []PDFPageText `json:"pages"`
}

PDFTextResult is the ordered text returned by a PDFBackend.

type PDFToolOptions

type PDFToolOptions struct {
	Root                      string
	EnabledTools              []string
	MaxExtractChars           int
	MaxPageChars              int
	MaxPages                  int
	TimeoutMs                 int
	MaxResponseBytes          int
	Backend                   PDFBackend
	FallbackBackend           PDFBackend
	OCRProfile                string
	PreferredModel            string
	FallbackModels            []string
	PreferNative              *bool
	NativePageSelectionPolicy string
	ArtifactCacheSize         int
	Models                    []PDFModelCandidate
	Host                      PDFHost
}

type PathRequest

type PathRequest struct {
	Root      string
	Value     string
	Field     string
	MustExist bool
	FileOnly  bool
}

PathRequest describes one Host-authorized workspace path resolution. Canonical tools never infer an allowlist from the process working directory.

type PathResolver

type PathResolver interface {
	ResolvePath(context.Context, PathRequest) (ResolvedPath, error)
}

PathResolver is the authorization seam for document and artifact paths.

type PathResolverFunc

type PathResolverFunc func(context.Context, PathRequest) (ResolvedPath, error)

PathResolverFunc adapts a function to PathResolver.

func (PathResolverFunc) ResolvePath

func (f PathResolverFunc) ResolvePath(ctx context.Context, request PathRequest) (ResolvedPath, error)

type ResolvedPDFInput

type ResolvedPDFInput struct {
	Path          string
	Display       string
	CacheIdentity string
	Remote        bool
	Cleanup       func()
}

ResolvedPDFInput is the bounded local materialization consumed by portable PDF coordination.

type ResolvedPath

type ResolvedPath struct {
	Path    string
	Display string
}

ResolvedPath separates a backend path from the display-safe path returned to the model.

type ToolMetadata

type ToolMetadata = agentxtools.ToolMetadata

func PDFToolMetadataForName

func PDFToolMetadataForName(name string) ToolMetadata

PDFToolMetadataForName returns canonical descriptive metadata for one PDF entrypoint. It grants no authorization or backend access.

Jump to

Keyboard shortcuts

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