runcommand

package
v0.5.1 Latest Latest
Warning

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

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

Documentation

Overview

Package runcommand 提供 run_command 工具:工作区内 shell 命令执行(P1b 简版——超时/输出头尾截断/cwd 圈进工作区;后台任务形态 P2 随编码子代理)。 输出截断策略参照 openai/codex unified_exec/head_tail_buffer.rs(Apache-2.0, 头尾保留中间省略——构建日志的头尾才是定位关键);命令安全分类 (IsSafeReadCommand)供装配层做参数级审批豁免(白名单只读命令直过, 思路参照 codex exec_policy 的规则版)。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsSafeReadCommand

func IsSafeReadCommand(args string) bool

IsSafeReadCommand 参数级审批豁免判定:纯只读命令(无元字符组合、无重定向、 无命令替换)直过;其余(rm/mvn/sudo/管道/重定向/任何白名单外)必审批。 判定从宽于「无害」从严于「白名单」:白名单程序 + 零元字符 + 参数形态只读 才豁免(写型形态显式拒:find 写型 flag、git branch/tag/remote 非纯列表 形态、tree 整体)。

func NewTools

func NewTools(cfg Config) ([]contract.Tool, error)

NewTools 构造 run_command / task_output / task_stop(run 写面进审批名单, 白名单只读命令经 IsSafeReadCommand 参数级豁免;task_output 读直过, task_stop 管自己起的后台任务不进审批)。

Types

type Config

type Config struct {
	Root            string
	Sandbox         *sandbox.Policy
	SandboxProvider sandbox.Provider
	Egress          *egress.Validator
}

Config 构造配置。Root = 工作区根(空 = 拒绝构造,P0 纪律);Sandbox = 可选沙箱策略(nil = 不沙箱——默认零行为变化,2026-08-26 沙箱设计定案 §5.2);SandboxProvider = 可选沙箱后端(nil = sandbox.OSProvider 平台内建;容器类后端经此注入——engine.Options 同名 字段透传);Egress = 可选出口校验器(nil = 不预检,真源 §9——Network 开放形态下命令串 URL 预检是命令面的唯一网络治理层)。

Jump to

Keyboard shortcuts

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