Documentation
¶
Index ¶
- Variables
- func AttachImage(ctx context.Context, ext string, data []byte) bool
- func AttachScreenshot(ctx context.Context, jpeg []byte) bool
- func Authorize(ctx context.Context, tool, command string) error
- func AuthorizePoll(ctx context.Context, tool, id string) error
- func BeforeFileMutation(ctx context.Context, path string)
- func BinaryPlaceholder(name string, size int) string
- func CommandRule(command string) string
- func Defs(ts []Tool) []ai.Tool
- func Execute(ctx context.Context, ts []Tool, name string, args json.RawMessage) string
- func IsBinary(data []byte) bool
- func IsStale(err error) bool
- func ResolvePath(ctx context.Context, path string) string
- func SuggestTool(name string, candidates []string) []string
- func ToolCallID(ctx context.Context) string
- func Truncate(s string) string
- func TruncateTail(s string) string
- func WithAsk(ctx context.Context, ask AskFunc) context.Context
- func WithComputerConfig(ctx context.Context, cfg config.ComputerConfig) context.Context
- func WithComputerRuntime(ctx context.Context, client *cua.Client) context.Context
- func WithFileMutationObserver(ctx context.Context, observe func(string)) context.Context
- func WithGate(ctx context.Context, gate func(GateRequest) (GateDecision, string)) context.Context
- func WithLiveAgentNamedRoots(ctx context.Context, roots map[string]WorkspaceRoot) context.Context
- func WithOnUpdate(ctx context.Context, onUpdate func(outputSoFar string)) context.Context
- func WithProcessStarted(ctx context.Context, record func(id string)) context.Context
- func WithReview(ctx context.Context, hooks ReviewHooks) context.Context
- func WithRunIdentity(ctx context.Context, identity RunIdentity) context.Context
- func WithSkillReadRoots(ctx context.Context, dirs []string) context.Context
- func WithToolCallID(ctx context.Context, id string) context.Context
- func WithWorkingDir(ctx context.Context, dir string) context.Context
- func WithWorkspaceRoots(ctx context.Context, roots []WorkspaceRoot) context.Context
- func WithWorktreeWorkspaceRoots(ctx context.Context, parent, worktree string) context.Context
- func WorkingDir(ctx context.Context) string
- type AskFunc
- type AskOption
- type AskQuestion
- type AskRequest
- type GateDecision
- type GateRequest
- type InteractiveRunner
- type LiveAgentToolMetadata
- type ManagedProcessManager
- type Result
- type ReviewHooks
- type RunIdentity
- type TerminalManager
- func (m *TerminalManager) CloseAll()
- func (m *TerminalManager) Handle(ctx context.Context, req TerminalRequest) (TerminalResponse, error)
- func (m *TerminalManager) HasRunningSessions() bool
- func (m *TerminalManager) Read(ctx context.Context, id string, maxBytes int) (string, error)
- func (m *TerminalManager) Start(ctx context.Context, command, cwd string) (string, error)
- type TerminalRecord
- type TerminalRequest
- type TerminalResponse
- type TerminalShellOption
- type Tool
- type WorkspaceRoot
Constants ¶
This section is empty.
Variables ¶
var Ask func(ctx context.Context, req AskRequest) (answers []string, ok bool)
var Browser *browser.Manager
var ComputerApprover func(app string) bool
var ComputerPolicy *computer.Policy
var Gate func(GateRequest) (GateDecision, string)
var LSP interface { WaitDiagnostics(ctx context.Context, path string) string }
var Suggester func(name string) []string
Functions ¶
func AttachImage ¶ added in v0.107.3
AttachImage attaches an image of the given extension (png, jpg, gif, webp) to the current tool result when the model supports vision.
func AttachScreenshot ¶ added in v0.103.0
func AuthorizePoll ¶ added in v0.107.6
AuthorizePoll gates a call that only reads the output of a process or terminal this session started; id names it. The caller still checks that the session owns it.
func BeforeFileMutation ¶ added in v0.107.0
func BinaryPlaceholder ¶
func CommandRule ¶
func SuggestTool ¶
func ToolCallID ¶ added in v0.107.0
func TruncateTail ¶
func WithComputerConfig ¶ added in v0.107.6
func WithComputerRuntime ¶ added in v0.107.6
func WithFileMutationObserver ¶ added in v0.107.0
WithFileMutationObserver records the pre-image immediately before a file tool mutates it.
func WithGate ¶ added in v0.103.0
func WithGate(ctx context.Context, gate func(GateRequest) (GateDecision, string)) context.Context
func WithLiveAgentNamedRoots ¶ added in v0.107.0
WithLiveAgentNamedRoots maps root:// aliases and enabled skill:// names to explicit grants. Unmapped names never fall back to arbitrary host paths.
func WithOnUpdate ¶
func WithProcessStarted ¶ added in v0.107.6
WithProcessStarted lets the caller learn the ids of the processes and terminal sessions a tool call starts. Tools report them when the start succeeds, so the ids never come from the call's output text, which a foreground command controls.
func WithReview ¶ added in v0.107.6
func WithReview(ctx context.Context, hooks ReviewHooks) context.Context
func WithRunIdentity ¶ added in v0.107.0
func WithRunIdentity(ctx context.Context, identity RunIdentity) context.Context
func WithSkillReadRoots ¶ added in v0.107.6
WithSkillReadRoots grants read-only access to the directories the system prompt advertises skills from. The prompt tells the model to read each skill's SKILL.md by absolute path, and those directories usually live outside the workspace. They extend the run's roots (or its default working-directory grant) and never replace them.
func WithToolCallID ¶ added in v0.107.0
func WithWorkingDir ¶ added in v0.103.0
func WithWorkspaceRoots ¶ added in v0.107.0
func WithWorkspaceRoots(ctx context.Context, roots []WorkspaceRoot) context.Context
func WithWorktreeWorkspaceRoots ¶ added in v0.107.6
WithWorktreeWorkspaceRoots transfers the parent's workspace grants to an isolated worktree. Preserve access levels and unrelated additional roots; an explicitly empty grant set must remain empty.
func WorkingDir ¶ added in v0.103.0
Types ¶
type AskQuestion ¶ added in v0.107.0
type AskRequest ¶
type AskRequest struct {
Question string `json:"question,omitempty"`
Options []AskOption `json:"options,omitempty"`
Multiple bool `json:"multiple,omitempty"`
Questions []AskQuestion `json:"questions,omitempty"`
}
type GateDecision ¶
type GateDecision int
const ( GateAllowOnce GateDecision = iota GateAllowAlways GateReject )
type GateRequest ¶
type GateRequest struct {
Context context.Context
Tool string
Command string
// Shell is the resolved shell that will run Command, for tools that run one;
// empty when unknown, which permission rules parse strictly.
Shell string
Rule string
Description string
// Poll marks a call that only reads the output of a process or terminal this
// session started; the tool checks ownership after the gate.
Poll bool
// OtherDir marks a command that runs outside the session's working directory
// because of a cwd argument.
OtherDir bool
}
func GateRequestFor ¶ added in v0.107.6
func GateRequestFor(ctx context.Context, tool string, args json.RawMessage) GateRequest
GateRequestFor builds the request a tool's own gate check makes for args, so that a caller gating the call before it runs (AI review) shows the same command, shell and path, and permission rules match it the same way. Tools without a known target keep the raw arguments as the command.
type InteractiveRunner ¶
type InteractiveRunner interface {
Run(ctx context.Context, command string, timeout time.Duration, keys <-chan []byte) string
}
var InteractiveBash InteractiveRunner
type LiveAgentToolMetadata ¶ added in v0.107.0
type LiveAgentToolMetadata struct {
ID string `json:"id"`
Icon string `json:"icon"`
ToolName string `json:"toolName"`
Category string `json:"categoryId"`
ReadOnly bool `json:"isReadOnly"`
RuntimeScope []string `json:"runtimeScopes"`
DefaultPolicy string `json:"defaultPolicy"`
}
LiveAgentToolMetadata mirrors the original builtinToolCatalog entries needed by provider/UI policy code without importing LiveAgent's TypeScript bundle.
func LiveAgentToolCatalogMetadata ¶ added in v0.107.0
func LiveAgentToolCatalogMetadata() []LiveAgentToolMetadata
type ManagedProcessManager ¶ added in v0.107.0
type ManagedProcessManager = liveagentProcessManager
ManagedProcessManager retains tool processes across model changes in a session.
func NewManagedProcessManager ¶ added in v0.107.0
func NewManagedProcessManager() *ManagedProcessManager
type Result ¶ added in v0.103.0
type Result struct {
Text string
Parts []ai.ContentPart
Failed bool
Cancelled bool
}
func ExecuteResult ¶ added in v0.103.0
type ReviewHooks ¶ added in v0.107.6
type RunIdentity ¶ added in v0.107.0
func RunIdentityFromContext ¶ added in v0.107.0
func RunIdentityFromContext(ctx context.Context) (RunIdentity, bool)
type TerminalManager ¶ added in v0.107.0
type TerminalManager struct {
// contains filtered or unexported fields
}
func NewTerminalManager ¶ added in v0.107.0
func NewTerminalManager() *TerminalManager
func (*TerminalManager) CloseAll ¶ added in v0.107.0
func (m *TerminalManager) CloseAll()
func (*TerminalManager) Handle ¶ added in v0.107.0
func (m *TerminalManager) Handle(ctx context.Context, req TerminalRequest) (TerminalResponse, error)
func (*TerminalManager) HasRunningSessions ¶ added in v0.107.6
func (m *TerminalManager) HasRunningSessions() bool
type TerminalRecord ¶ added in v0.107.0
type TerminalRecord struct {
ID string `json:"id"`
ProjectPathKey string `json:"project_path_key"`
CWD string `json:"cwd"`
Shell string `json:"shell"`
Title string `json:"title"`
PID int `json:"pid"`
Cols uint16 `json:"cols"`
Rows uint16 `json:"rows"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
FinishedAt int64 `json:"finished_at"`
ExitCode int `json:"exit_code"`
Running bool `json:"running"`
Kind string `json:"kind"`
}
type TerminalRequest ¶ added in v0.107.0
type TerminalRequest struct {
Action string `json:"action"`
ConversationID string `json:"conversation_id"`
RunID string `json:"run_id"`
SessionID string `json:"session_id"`
ProjectPathKey string `json:"project_path_key"`
CWD string `json:"cwd"`
Shell string `json:"shell"`
Title string `json:"title"`
Data string `json:"data"`
Cols uint16 `json:"cols"`
Rows uint16 `json:"rows"`
MaxBytes int `json:"max_bytes"`
}
TerminalRequest and TerminalResponse mirror the local Gateway v2 terminal protocol.
type TerminalResponse ¶ added in v0.107.0
type TerminalResponse struct {
Action string `json:"action"`
ConversationID string `json:"conversation_id"`
RunID string `json:"run_id"`
Session *TerminalRecord `json:"session,omitempty"`
Sessions []TerminalRecord `json:"sessions,omitempty"`
Output []byte `json:"output,omitempty"`
Truncated bool `json:"truncated"`
OutputStartOffset uint64 `json:"output_start_offset"`
OutputEndOffset uint64 `json:"output_end_offset"`
ShellOptions []TerminalShellOption `json:"shell_options,omitempty"`
DefaultShell string `json:"default_shell,omitempty"`
}
type TerminalShellOption ¶ added in v0.107.0
type Tool ¶
type Tool struct {
Def ai.Tool
Run func(ctx context.Context, args json.RawMessage) (string, error)
NoInherit bool
// Memory marks K-brain's own memory tools, which the memory switch hides; a
// client tool that happens to share a name is not one of them.
Memory bool
}
func BrowserExec ¶
func BrowserExec() Tool
func ComputerExec ¶
func ComputerExec() Tool
func LegacyComputerExec ¶ added in v0.107.6
func LegacyComputerExec() Tool
func LiveAgentCatalog ¶ added in v0.107.0
LiveAgentCatalog creates session-local tools without changing CLI defaults.
func LiveAgentCatalogWithManagers ¶ added in v0.107.0
func LiveAgentCatalogWithManagers(provider []string, terminalManager *TerminalManager, processManager *ManagedProcessManager) []Tool
func QuestionTool ¶
func QuestionTool() Tool
type WorkspaceRoot ¶ added in v0.107.0
WorkspaceRoot is the backend's authoritative filesystem boundary.
Source Files
¶
- attachments.go
- binary.go
- browser.go
- browser_lang.go
- computer.go
- computer_cua.go
- liveagent_catalog.go
- liveagent_documents.go
- liveagent_edit.go
- liveagent_policy.go
- liveagent_process.go
- liveagent_process_actions.go
- liveagent_read.go
- liveagent_schemas.go
- liveagent_search.go
- liveagent_shell.go
- liveagent_terminal.go
- liveagent_tools.go
- permission.go
- process_started.go
- question.go
- review.go
- run_identity.go
- suggest.go
- terminal.go
- terminal_unix.go
- tools.go