Documentation
¶
Index ¶
- func SetExecToolExecutor(executor ExtensionToolExecutor)
- func Tools() []tool.Tool
- func WithSSHCache(ctx context.Context, cache *SSHClientCache) context.Context
- func WrapLocalTool(t tool.Tool) tool.Tool
- type ExtensionToolExecutor
- type LocalToolApprovalRequest
- type LocalToolConfirmFunc
- type LocalToolGate
- type SSHClientCache
- type ToolDef
- type ToolHandlerFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetExecToolExecutor ¶
func SetExecToolExecutor(executor ExtensionToolExecutor)
SetExecToolExecutor wires the extension executor into the exec_tool handler.
func Tools ¶
Tools 返回所有 cago 原生工具实例。各 *_tools_*.go 文件直接以 *tool.RawTool 字面量定义工具。 handler 内部按 cago 原生 (ctx, in) → (*ToolResultBlock, error) 签名构造返回值, 权限决策通过 setCheckResult 透出,审计写入由 auditMiddleware 异步完成。
func WithSSHCache ¶
func WithSSHCache(ctx context.Context, cache *SSHClientCache) context.Context
WithSSHCache 将 SSH 缓存注入 context。
Types ¶
type ExtensionToolExecutor ¶
type ExtensionToolExecutor interface {
FindExtensionByTool(extName, toolName string) *extension.Extension
GetExtensionPolicyGroups(extName, assetType string, assetID int64) []string
}
ExtensionToolExecutor provides extension tool execution to the AI system.
type LocalToolApprovalRequest ¶
type LocalToolApprovalRequest struct {
ToolName string // "local_bash" | "local_write" | "local_edit"
Command string // local_bash: 原始 command;local_write/local_edit: path
Detail string // local_write 内容预览 / local_edit 改动预览,local_bash 留空
SubCommands []string // local_bash 按 mvdan.cc/sh 拆分的子命令;local_write/local_edit 为单条 = path
DefaultPatterns []string // 默认 pattern("git pull" → "git *",path 默认原值),前端预填可编辑
}
LocalToolApprovalRequest 是 LocalToolGate 发往前端的本地工具审批载荷。
与 permission.ApprovalItem 不同:本地工具没有 asset/group 概念,只有命令/路径本体; SubCommands 用于 local_bash 复合命令的展示与默认 pattern 生成。
type LocalToolConfirmFunc ¶
type LocalToolConfirmFunc func(ctx context.Context, req LocalToolApprovalRequest) permission.ApprovalResponse
LocalToolConfirmFunc 由上层(App)注入,发起 Wails 事件并阻塞等待用户响应。
type LocalToolGate ¶
type LocalToolGate struct {
// contains filtered or unexported fields
}
LocalToolGate 拦截 coding system 的 local_bash/local_write/local_edit 工具调用 (即经 WrapLocalTool 重命名后的本地工具——见 internal/ai/local_tool_wrap.go)。
行为对齐 run_command:local_bash 按 && / || / ; / | 拆出子命令,全部命中已存 pattern (* 通配,path.Match 语义)才放行;否则发起审批。"本次会话允许" 把用户编辑后的 pattern 写入会话内存白名单,键为 conversationID。
func NewLocalToolGate ¶
func NewLocalToolGate(confirm LocalToolConfirmFunc) *LocalToolGate
NewLocalToolGate 构造 gate。 confirm 为 nil 时测试场景可用,但任何未命中调用将直接 aictx.Deny。
func (*LocalToolGate) Middleware ¶
func (g *LocalToolGate) Middleware() agent.ToolMiddleware
Middleware 返回挂到 coding system 的 cago tool middleware。 仅与 local_(bash|write|edit) 这三件本地工具配套;调用方在 runner.go 用 agent.Use(`^local_(bash|write|edit)$`, gate.Middleware()) 挂载。
行为:subjects 缺失或全部命中已存 pattern 时直接 Next 放行;无 confirm 回调 时 AbortWithDeny;用户 deny → AbortWithDeny;allowAll → 写白名单后 Next; 其他("allow" 或未知)按单次允许处理,不写白名单。
func (*LocalToolGate) Reset ¶
func (g *LocalToolGate) Reset(convID int64)
Reset 清空指定 convID 的白名单。在删除会话或重置 provider 时调用。
type SSHClientCache ¶
SSHClientCache 在同一次 AI Send 中复用 SSH 连接。
type ToolDef ¶
type ToolDef struct {
Name string
Handler ToolHandlerFunc
}
ToolDef opsctl 派发表条目,只保留 (name, handler) 对。
func AllToolDefs ¶
func AllToolDefs() []ToolDef
AllToolDefs 返回 opsctl CLI 派发用的工具列表。 它不是 Tools() 的镜像:run_serial_command 依赖桌面端已连接的串口 session; batch_command 在 opsctl 中有独立的 batch 子命令入口,不走 name→handler 派发表。