tools

package
v1.0.0 Latest Latest
Warning

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

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

Documentation

Overview

Package tools is the tool subsystem: the per-request context values tools read, the middleware chain, the composition that assembles a run's tool set, and the built-in tools.

Eino tools receive a plain context.Context, so the runtime carries identity as typed context values, assembled once by the agent before the run starts. A tool reads them with tools.UserID.Get(ctx), never by string key.

Index

Constants

View Source
const (
	ToolNameCurrentDateTime = "CurrentDateTime"

	ToolNameReadFile  = "ReadFile"
	ToolNameWriteFile = "WriteFile"
	ToolNameListFiles = "ListFiles"
	ToolNameGrepFiles = "GrepFiles"

	ToolNameReadMemory    = "MemoryView"
	ToolNameWriteMemory   = "MemoryWrite"
	ToolNameCreateMemory  = "MemoryCreate"
	ToolNameInsertMemory  = "MemoryInsert"
	ToolNameReplaceMemory = "MemoryStrReplace"
	ToolNameRenameMemory  = "MemoryRename"
	ToolNameDeleteMemory  = "MemoryDelete"

	ToolNameListSkills    = "ListSkills"
	ToolNameReadSkillFile = "ReadSkillFile"
	ToolNameWriteSkill    = "WriteSkillFile"
	ToolNameDeleteSkill   = "DeleteSkill"

	ToolNameTodoWrite = "TodoWrite"

	ToolNameBash                  = "Bash"
	ToolNameBashOutput            = "BashOutput"
	ToolNameKillShell             = "KillShell"
	ToolNameRestartShellContainer = "RestartShellContainer"
	ToolNameRestartShellPod       = "RestartShellPod"
	ToolNameRestartSandbox        = "RestartSandbox"

	ToolNameSetCredential    = "SetCredential"
	ToolNameListCredentials  = "ListCredentials"
	ToolNameDeleteCredential = "DeleteCredential"

	ToolNamePublishFile         = "PublishFile"
	ToolNameUpdatePublishedFile = "UpdatePublishedFile"
	ToolNameUnpublishFile       = "UnpublishFile"
	ToolNameRenewPublishedFile  = "RenewPublishedFile"

	ToolNameAskUserQuestion = "AskUserQuestionTool"

	ToolNameCreateScheduledTask = "CreateScheduledTask"
	ToolNameListScheduledTasks  = "ListScheduledTasks"
	ToolNameCancelScheduledTask = "CancelScheduledTask"
	ToolNameUpdateScheduledTask = "UpdateScheduledTask"
	ToolNameStopScheduledTask   = "StopThisScheduledTask"
	ToolNameRescheduleTask      = "RescheduleThisScheduledTask"

	ToolNameListPlaybooks = "ListPlaybooks"
	ToolNameWritePlaybook = "WritePlaybook"

	// The subagent tools are registered by core/subagent (they need the
	// agent itself, which this package must not import) and excluded from
	// the SUBAGENT scenario by name, which is the depth cap: a subagent
	// cannot start one of its own.
	ToolNameStartSubagent  = "StartSubagent"
	ToolNameWaitSubagent   = "WaitForSubagent"
	ToolNameCancelSubagent = "CancelSubagent"
)

The built-in tool names. Constants rather than string literals because the ScheduledTask scenario excludes the schedule tools by name, and an integration filtering by a name it mis-spelled would silently filter nothing.

Variables

View Source
var (
	// UserID is the channel identity of the user whose words started the run.
	UserID = NewKey[string]("userId")
	// ChatID is the conversation the message arrived in.
	ChatID = NewKey[string]("chatId")
	// ChatType is "p2p" or "group".
	ChatType = NewKey[string]("chatType")
	// RootMessageID is the message a thread is rooted at.
	RootMessageID = NewKey[string]("rootMessageId")
	// ReplyMessageID is the message this run's reply will answer.
	ReplyMessageID = NewKey[string]("replyMessageId")
	// ConversationID is the memory conversation the run belongs to.
	ConversationID = NewKey[string]("conversationId")
	// RequestID is the id of the run the tool is executing in — what Cancel
	// stops, and what ties a subagent to the run that started it.
	RequestID = NewKey[string]("requestId")
	// GroupID is the group whose files and skills the run may read through,
	// empty when the run carries no group scope.
	GroupID = NewKey[string]("groupId")
	// TenantID is the tenant scope of the run, empty when there is none.
	TenantID = NewKey[string]("tenantId")
	// SituationID identifies the external-event situation being triaged. It is
	// empty for ordinary conversations and lets optional situation tools update
	// only the durable record they were given.
	SituationID = NewKey[string]("situationId")
	// ScheduledTaskID identifies the task whose firing is currently running.
	ScheduledTaskID = NewKey[string]("scheduledTaskId")
)

The identity keys the runtime forces onto every run, after the request's own values, so a surface cannot mis-state who is talking. The names match The names are also used in logs and diagnostics.

Functions

func EndTurnResult added in v1.0.0

func EndTurnResult(result string) string

EndTurnResult marks a tool result so the current run ends after the tool call. Use it from native Eino tool middleware when a tool needs to hand work to a later run, such as a question whose answer arrives asynchronously.

func IsValidCredentialName

func IsValidCredentialName(name string) bool

IsValidCredentialName reports whether name is safe as a POSIX environment variable and a credential filename.

func MustTool

func MustTool(t tool.InvokableTool, err error) tool.InvokableTool

MustTool builds a tool whose schema is inferred from a static Go struct — a build-time-shaped operation done at init time. A failure here is a programming error in the caller (an uninferable type), and failing the process at first use is the honest outcome; there is nothing a runtime caller could do about it later.

func NewLargeResponseMiddleware added in v1.0.0

func NewLargeResponseMiddleware(config LargeResponseMiddlewareConfig) compose.ToolMiddleware

NewLargeResponseMiddleware diverts an oversized tool result to a file in the user's workspace and hands the model a pointer instead. A large listing in the conversation crowds every later turn; a file and short pointer preserve the result without consuming the context window.

func RegisterBuiltins

func RegisterBuiltins(p *Provider, b Builtins) error

RegisterBuiltins constructs and registers every built-in family whose dependencies are provided. Call it during application setup, before the first Fire.

func SplitEndTurn

func SplitEndTurn(result string) (string, bool)

SplitEndTurn reports whether a tool result carries the end-turn sentinel, returning the result without it. InferTool JSON-encodes a string result, so this accepts both the raw form produced by a custom tool and the JSON string form produced by Eino's typed tool helper.

Types

type AskOptions

type AskOptions struct {
	// AnswersArriveLater is true when no handler can answer inline. The ask
	// then ends the turn: the result is recorded for the next run (which is
	// why AskedMessage matters) and the model is not asked to continue from
	// an answer it does not have.
	AnswersArriveLater bool

	// AskedMessage is the model-facing instruction recorded as the tool
	// result when the questions were presented and no answer came inside
	// the run — the i18n bundle's question-asked text. The next run reads
	// it in the history and knows an ask is outstanding.
	AskedMessage string
}

AskOptions parametrizes the ask tool for one run.

type AskUserQuestionTools

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

AskUserQuestionTools is the ask tool: the model's one way to put questions to the person behind the run.

func NewAskUserQuestionTools

func NewAskUserQuestionTools(handler QuestionHandler, opts AskOptions) *AskUserQuestionTools

NewAskUserQuestionTools returns the ask tools over one run's handler.

func (*AskUserQuestionTools) List

List lists the ask tools, satisfying Builtin.

type Builtin

type Builtin interface {
	List() []tool.InvokableTool
}

Builtin is a family of built-in tools exposed as one list. Every family — single-tool ones included — implements it, so registration and Compose treat them all the same way.

type Builtins

type Builtins struct {
	// Sandbox enables the shell and credential tools for one sandbox
	// backend. SandboxConfig.Credentials is filled from the provider's
	// store when nil.
	Sandbox       Sandbox
	SandboxConfig SandboxToolsConfig
}

Builtins names the process-wide built-in families to register. A nil field means the family is not registered. The per-user families (file, memory, skill, todo, ask, publish, clock) are not here: they are built per run by Provider.Compose, which is their registration.

type ComposeRequest

type ComposeRequest struct {
	ScenarioOffers func(name string) bool
	UserID         string
	ChatID         string
	GroupID        string
	TenantID       string
	TodoHandler    TodoEventHandler
	Questions      QuestionHandler
	// AnswersArriveLater is true when Questions cannot answer inline.
	AnswersArriveLater bool
	// AskedMessage is the ask tool's recorded instruction; see AskOptions.
	AskedMessage string
	// AskEnabled is the config gate on the ask tool.
	AskEnabled bool
}

ComposeRequest names what Compose needs from the run. ScenarioOffers is the resolved Scenario.Offers of the request; the rest is identity and the per-run handlers. GroupID and TenantID, when set, widen the run's reads: the group's and tenant's homes join the user's own for the file, skill and publish tools.

type Composition

type Composition struct {
	Tools []tool.InvokableTool
	Info  []*schema.ToolInfo
	Close func()
	// contains filtered or unexported fields
}

Composition is one run's tool set and its Eino ToolsNode. Close must be called when the run ends, whatever it ended by; it closes the MCP connections the composition opened, and is safe to call when there are none.

func (*Composition) Invoke added in v1.0.0

func (c *Composition) Invoke(ctx context.Context, assistant *schema.Message) ([]*schema.Message, bool, error)

Invoke executes the tool calls in an assistant message and reports whether one of them requested that the run end. Eino owns dispatch, argument handling, callbacks, and tool-message construction; the end-turn marker is the one piece of run policy that remains a golem concern.

type CredentialResolver

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

CredentialResolver supplies plaintext values only while a backend is creating a sandbox. A Docker backend injects them into the new container; a Kubernetes backend writes them into a Secret. Callers may provide a resolver backed by an encrypted store rather than using the helper above.

func CredentialsFromRepository

func CredentialsFromRepository(repo store.ShellCredentialStore) CredentialResolver

CredentialsFromRepository adapts the persistence contract for a sandbox backend. Backends call the resolver only while creating a fresh sandbox, so changing a credential takes effect after the corresponding restart tool.

type CredentialTools

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

CredentialTools are the three tools that manage credentials without ever returning a stored value to the model.

func NewCredentialTools

func NewCredentialTools(repo store.ShellCredentialStore, restartToolName string) *CredentialTools

NewCredentialTools creates the credential tools over one repository. A nil repository yields a family whose List is empty.

func (*CredentialTools) List

func (c *CredentialTools) List() []tool.InvokableTool

List lists the credential tools, satisfying Builtin.

type CurrentDateTimeTools

type CurrentDateTimeTools struct{}

CurrentDateTimeTools is the clock tool. The default system prompt sends the model here whenever an answer depends on "today" or "in two hours": a model's sense of now is its training cutoff, which is never now.

func NewCurrentDateTimeTools

func NewCurrentDateTimeTools() *CurrentDateTimeTools

NewCurrentDateTimeTools returns the clock tools.

func (*CurrentDateTimeTools) List

List lists the clock tools, satisfying Builtin.

type ErrNotAnswered

type ErrNotAnswered struct {
	// Message is what the model sees in place of a real result.
	Message string
}

ErrNotAnswered is the error the ask machinery and handlers use for "the questions were put to the user (or could not be), and no answer is coming inside this run". Its message is model-facing instructions — the tool result the model reads — so constructing it with a user-facing string is a behavior choice, not a formatting slip.

func AsErrNotAnswered

func AsErrNotAnswered(err error) *ErrNotAnswered

AsErrNotAnswered unwraps the marker error, nil for anything else.

func (*ErrNotAnswered) Error

func (e *ErrNotAnswered) Error() string

type FileSystemTools

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

FileSystemTools are the file tools of one run, rooted at the user's workspace. The roots are enforced on every path: a model-walked "../" must not turn the workspace into a file reader for the whole machine.

One instance per run (not one per process) because the roots are per user. A run with group or tenant scope reads across those homes' workspaces too; writes always land in the primary — what a run produces belongs to who asked.

func NewFileSystemTools

func NewFileSystemTools(home storage.Home) (*FileSystemTools, error)

NewFileSystemTools returns the file tools over the run's home. The home's primary root receives every write; the further roots (a group's, a tenant's) are read through.

func (*FileSystemTools) Grep

Grep searches file contents under a directory.

func (*FileSystemTools) List

func (f *FileSystemTools) List() []tool.InvokableTool

List lists the file tools, satisfying Builtin.

func (*FileSystemTools) ListFiles

func (f *FileSystemTools) ListFiles() tool.InvokableTool

ListFiles lists a directory, files first at one level, with sizes.

func (*FileSystemTools) Read

Read reads a file, optionally a window of lines.

func (*FileSystemTools) Write

func (f *FileSystemTools) Write() tool.InvokableTool

Write writes a file whole.

type InlineAnswers

type InlineAnswers interface {
	QuestionHandler

	// AnswersInline reports whether Ask blocks until the user replied.
	AnswersInline() bool
}

InlineAnswers is the capability a handler implements when it returns the answer inside the Ask call — the CLI's terminal prompt, say. Without it, the ask ends the turn: the answers can only arrive after the run is over (a form filled minutes later), so the model cannot be allowed to wait on them. InlineAnswers marks handlers that can answer during the current run; other handlers end the turn so a later event can provide the answer.

type Interceptor

type Interceptor interface {
	BeforeCall(ctx context.Context, name string, arguments string) (string, error)
	AfterCall(ctx context.Context, name string, arguments string, result string) (string, bool, error)
}

Interceptor is the convenient before/after facade for ordinary invokable tool calls. BeforeCall can rewrite the model's arguments; AfterCall can rewrite the result or request that the run end after the call.

Interceptors are adapted to Eino middleware by WithInterceptor. Use WithToolMiddleware directly when the full Eino hook surface is required.

type InterceptorFuncs

type InterceptorFuncs struct {
	Before func(ctx context.Context, name string, arguments string) (string, error)
	After  func(ctx context.Context, name string, arguments string, result string) (string, bool, error)
}

InterceptorFuncs adapts functions to Interceptor for hooks that only need one stage.

func (InterceptorFuncs) AfterCall

func (f InterceptorFuncs) AfterCall(ctx context.Context, name, arguments, result string) (string, bool, error)

func (InterceptorFuncs) BeforeCall

func (f InterceptorFuncs) BeforeCall(ctx context.Context, name, arguments string) (string, error)

type Key

type Key[T any] struct {
	// contains filtered or unexported fields
}

Key is a typed context key. The zero Key is not usable; construct with NewKey, package-level, next to the type it names.

func NewKey

func NewKey[T any](name string) Key[T]

NewKey names a typed context key. Each call creates an independent key; the name appears only in error messages and should still describe one concept.

func (Key[T]) Get

func (k Key[T]) Get(ctx context.Context) (T, error)

Get reads the value. A missing value is reported as a zero value and nil error; Require is the convenience for tools that need a non-empty value.

func (Key[T]) Require

func (k Key[T]) Require(ctx context.Context) (T, error)

Require reads the value and fails when it is absent or the string form is blank — for the identities a tool cannot do its job without.

func (Key[T]) With

func (k Key[T]) With(ctx context.Context, value T) context.Context

With returns a context carrying value under this key.

type LargeResponseMiddlewareConfig added in v1.0.0

type LargeResponseMiddlewareConfig struct {
	// GuideThreshold is the result length (in bytes) that triggers a divert.
	GuideThreshold int
	// Workspaces builds the per-user home the diverted file lands in.
	Workspaces *storage.WorkspaceFactory
	Log        Logger
}

LargeResponseMiddlewareConfig configures NewLargeResponseMiddleware.

type Logger

type Logger interface {
	Info(msg string, args ...any)
}

Logger is the small slice of slog the middleware needs; slog.Logger satisfies it. An interface rather than the concrete type so a test can capture the divert without a log buffer.

type MCPBuilder

type MCPBuilder interface {
	Build(ctx context.Context, userID, chatID string) (MCPTools, error)
}

MCPBuilder is what the mcp package supplies to the provider: the servers a user can reach, connected, and a way to close them when the run ends. An interface defined here so the provider does not depend on the mcp package's details (or its client library) — only on the tools it yields.

type MCPTools

type MCPTools struct {
	Tools  []tool.InvokableTool
	Closer io.Closer
}

MCPTools is one run's MCP connections. Tools without the Closer would leak a handshake per run; the Closer without the tools would be pointless.

type MemoryTools

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

MemoryTools are the agent's persistent notes about a user, kept in the memories folder of their home. The default system prompt asks the model to read MEMORY.md before replying, so memory remains an ordinary file tool.

func NewMemoryTools

func NewMemoryTools(home storage.Home) (*MemoryTools, error)

NewMemoryTools returns the memory tools over the run's memories folder. Memory is personal by design — the agent's notes about a user are not the group's to read — so only the home's primary root is consulted even when the run carries a group or tenant scope.

func (*MemoryTools) Create added in v1.0.0

func (m *MemoryTools) Create() tool.InvokableTool

Create makes a new memory file and refuses to overwrite an existing note.

func (*MemoryTools) Delete added in v1.0.0

func (m *MemoryTools) Delete() tool.InvokableTool

Delete removes one memory file, never a directory tree.

func (*MemoryTools) Insert added in v1.0.0

func (m *MemoryTools) Insert() tool.InvokableTool

Insert inserts text at a rune position, or appends when Position is -1. Rune positions keep the operation safe for UTF-8 notes.

func (*MemoryTools) List

func (m *MemoryTools) List() []tool.InvokableTool

List lists the memory tools, satisfying Builtin.

func (*MemoryTools) Read

func (m *MemoryTools) Read() tool.InvokableTool

Read is MemoryView.

func (*MemoryTools) Rename added in v1.0.0

func (m *MemoryTools) Rename() tool.InvokableTool

Rename moves a memory file without allowing an existing target to be overwritten accidentally.

func (*MemoryTools) Replace added in v1.0.0

func (m *MemoryTools) Replace() tool.InvokableTool

Replace performs a literal, single-pass string replacement in a memory file. The old text must occur so a misspelled edit is not reported as done.

func (*MemoryTools) Write

func (m *MemoryTools) Write() tool.InvokableTool

Write is MemoryWrite.

type MissingError

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

MissingError reports a required context value that is absent or blank.

func (*MissingError) Error

func (e *MissingError) Error() string

type Provider

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

Provider assembles the tool set for a run. It combines registered tools, per-user file, memory and skill tools, todo and question tools, publishing, and any MCP servers available to the user.

Registration is process-wide and read per run; Compose is the only thing that touches per-user state.

This package must not import core/agent: the agent depends on the tools, so the tools cannot depend back on it (the schedule feature lives in core/schedule for exactly that reason).

func NewProvider

func NewProvider(cfg config.Config, workspaces *storage.WorkspaceFactory, repos store.Backend, mcp MCPBuilder, options ...ProviderOption) *Provider

NewProvider constructs the provider and adds the built-in tool middleware.

func (*Provider) Compose

func (p *Provider) Compose(ctx context.Context, req ComposeRequest) (*Composition, error)

Compose assembles the run's tools. It is called from the run goroutine, not the Fire caller: MCP handshakes are blocking network work, and the callers may be event dispatchers with delivery deadlines, so connection setup remains inside the run rather than blocking the event receiver.

func (*Provider) Register

func (p *Provider) Register(t tool.InvokableTool, offers func(name string) bool)

Register makes a tool available to runs. Call it during application setup, before the first Fire; offers gates it by scenario.

func (*Provider) RegisterSandbox

func (p *Provider) RegisterSandbox(sandbox Sandbox, config SandboxToolsConfig) error

RegisterSandbox adds the common shell tools for one optional sandbox backend. The backend remains owned by the application and should be closed during application shutdown.

type ProviderOption

type ProviderOption func(*Provider)

ProviderOption configures a Provider during construction.

func WithInterceptor

func WithInterceptor(interceptor Interceptor) ProviderOption

WithInterceptor adds the convenient before/after interceptor facade to the provider's Eino tool chain. Use WithToolMiddleware when the native Eino middleware hooks or streamable/enhanced tools are needed.

func WithLogger

func WithLogger(log *slog.Logger) ProviderOption

WithLogger supplies the logger used for optional-tool failures.

func WithToolMiddleware added in v1.0.0

func WithToolMiddleware(middleware compose.ToolMiddleware) ProviderOption

WithToolMiddleware adds native Eino middleware to the provider's tool chain. The middleware order is the order in which options are applied, after golem's built-in middleware.

type PublishFileTools

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

PublishFileTools make a workspace file reachable by link. The link's authorization is an unguessable token stored in a PublishedResource together with visibility and expiry; the share handler checks all three before serving.

The storage layout mirrors the URL: {visibility}/{userId}/{token}/ under the storage root, so a published file's disk path is derivable from its link alone.

func NewPublishFileTools

func NewPublishFileTools(repos store.PublishedResourceStore, store storage.Storage, workspace storage.Home, baseURL string) *PublishFileTools

NewPublishFileTools constructs the publish tools. workspace is the run's home — the tools refuse anything outside the roots it spans (the user's own, and the group's or tenant's when the run carries that scope), the same containment check the share handler applies on the way out.

func (*PublishFileTools) List

func (p *PublishFileTools) List() []tool.InvokableTool

List lists the publish tools, satisfying Builtin.

func (*PublishFileTools) Publish

func (p *PublishFileTools) Publish() tool.InvokableTool

Publish publishes a workspace file or directory.

func (*PublishFileTools) Renew

func (p *PublishFileTools) Renew() tool.InvokableTool

Renew extends a link's expiry.

func (*PublishFileTools) Unpublish

func (p *PublishFileTools) Unpublish() tool.InvokableTool

Unpublish removes a link.

func (*PublishFileTools) Update

func (p *PublishFileTools) Update() tool.InvokableTool

Update replaces or refreshes a published file's content.

type Question

type Question struct {
	// Question is the text as the model phrased it.
	Question string `json:"question"`
	// Header is the short label a surface shows next to the answer channel,
	// used when the questions are rendered where the model is not.
	Header string `json:"header,omitempty"`
	// Options are the answers to choose among, safest first — the default
	// prompt asks the model to order them that way.
	Options []string `json:"options"`
	// MultiSelect allows more than one choice.
	MultiSelect bool `json:"multiSelect,omitempty"`
	// Other, when non-empty, offers a free-text answer alongside the
	// options, labelled with this text.
	Other string `json:"other,omitempty"`
}

Question is one question the model puts to the user.

type QuestionHandler

type QuestionHandler interface {
	Ask(ctx context.Context, questions []Question) (map[string]string, error)
}

QuestionHandler presents questions to the user and, on the synchronous flavour, returns their answers within the call. A handler that cannot present them returns ErrNotAnswered — anything else is a bug in the handler, and the ask machinery needs to tell the two apart.

type Questions

type Questions struct {
	Questions []Question `json:"questions"`
}

Questions is a whole ask: one or more questions presented together.

type Sandbox

type Sandbox interface {
	Ensure(ctx context.Context, identity SandboxIdentity) (SandboxSession, error)
	Remove(ctx context.Context, identity SandboxIdentity) (bool, error)
	io.Closer
}

Sandbox owns one disposable command environment per identity. The Docker and Kubernetes modules implement this contract; core only owns the tool protocol shared by both backends.

type SandboxExecResult

type SandboxExecResult struct {
	Stdout      string
	Stderr      string
	ExitCode    int
	ExitCodeSet bool
	Truncated   bool
}

SandboxExecResult is the backend-neutral result of one shell exec.

type SandboxIdentity added in v1.0.0

type SandboxIdentity struct {
	UserID   string
	GroupID  string
	TenantID string
}

SandboxIdentity names whose sandbox a backend manages: the user, plus the group and tenant scopes the run carries. The identity — not the user alone — is what a sandbox is keyed on, so two scopes never share a container even for one user.

func (SandboxIdentity) Key added in v1.0.0

func (i SandboxIdentity) Key() string

Key is the identity as a single string to key maps, labels and names by: the user alone when the run carries no scope, the composite otherwise. Components are joined with NUL, which no channel id contains.

func (SandboxIdentity) Scoped added in v1.0.0

func (i SandboxIdentity) Scoped() bool

Scoped reports whether the identity carries a group or tenant.

type SandboxSession

type SandboxSession interface {
	Exec(ctx context.Context, script string, stdin []byte, maxOutputBytes int) (SandboxExecResult, error)
}

SandboxSession executes bash scripts inside one user's sandbox. stdin is used by background commands to upload their command file without putting command text in an argument list or a shell-quoted wrapper.

type SandboxTools

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

SandboxTools are the common Bash, BashOutput, KillShell and restart tools. Credential tools are included when a repository is supplied.

func NewSandboxTools

func NewSandboxTools(sandbox Sandbox, config SandboxToolsConfig) (*SandboxTools, error)

NewSandboxTools creates the shell tools for one sandbox backend.

func (*SandboxTools) List

func (s *SandboxTools) List() []tool.InvokableTool

List lists the shell tools, satisfying Builtin.

type SandboxToolsConfig

type SandboxToolsConfig struct {
	MaxOutputBytes  int
	DefaultTimeout  time.Duration
	MaxTimeout      time.Duration
	RestartToolName string
	Credentials     store.ShellCredentialStore
}

SandboxToolsConfig controls the model-facing shell tools. Lifecycle and resource settings belong to each backend because a container and a Pod express them differently.

type SkillTools

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

SkillTools are the user's skill files: directories under skills/, each with a SKILL.md describing what it is for. Read-only view plus management, the read and management operations for user-owned skills.

func NewSkillTools

func NewSkillTools(home storage.Home) (*SkillTools, error)

NewSkillTools returns the skill tools over the run's skills folders: the primary home's for everything, plus the group's and tenant's for reading, so a skill the group shares is as usable as the user's own. A folder may not exist yet — listing then simply finds nothing.

func (*SkillTools) Delete

func (s *SkillTools) Delete() tool.InvokableTool

Delete removes a whole skill.

func (*SkillTools) List

func (s *SkillTools) List() []tool.InvokableTool

List lists the skill tools, satisfying Builtin.

func (*SkillTools) ListSkills

func (s *SkillTools) ListSkills() tool.InvokableTool

ListSkills lists the skills with their descriptions.

func (*SkillTools) Read

func (s *SkillTools) Read() tool.InvokableTool

Read reads one file inside a skill.

func (*SkillTools) Write

func (s *SkillTools) Write() tool.InvokableTool

Write writes a file inside a skill, creating the skill when new.

type Todo

type Todo struct {
	Content string
	Status  TodoStatus
}

Todo is one item of the list.

type TodoEvent

type TodoEvent struct {
	Todos []Todo
}

TodoEvent is one TodoWrite call, delivered whole to the run's todo handlers — a surface renders the list, it does not diff it, because the model's contract is "rewrite the list to what is true now".

type TodoEventHandler

type TodoEventHandler func(ctx context.Context, event TodoEvent)

TodoEventHandler receives todo updates during a run.

func TodoFanOut

func TodoFanOut(handlers []TodoEventHandler) TodoEventHandler

TodoFanOut combines handlers into one: every handler hears every event, and no handler's failure (or panic) reaches the tool call that produced the event.

type TodoStatus

type TodoStatus string

TodoStatus is one todo item's state.

const (
	TodoPending    TodoStatus = "pending"
	TodoInProgress TodoStatus = "in_progress"
	TodoCompleted  TodoStatus = "completed"
)

type TodoWriteTools

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

TodoWriteTools is the plan tool. The whole list is replaced on every call: a diffing protocol would make the model compute diffs, and the last call before the final answer is what leaves no item in progress.

func NewTodoWriteTools

func NewTodoWriteTools(handler TodoEventHandler) *TodoWriteTools

NewTodoWriteTools returns the plan tools over one run's todo handler.

func (*TodoWriteTools) List

func (t *TodoWriteTools) List() []tool.InvokableTool

List lists the plan tools, satisfying Builtin.

type TypeMismatchError

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

TypeMismatchError reports a context value stored under a name with an unexpected type.

func (*TypeMismatchError) Error

func (e *TypeMismatchError) Error() string

Jump to

Keyboard shortcuts

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