process

package
v0.1.24 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildBaseEnv

func BuildBaseEnv(extraEnv map[string]string) []string

BuildBaseEnv 返回当前环境并附加额外的环境变量。

func BuildRunEnv

func BuildRunEnv(baseEnv []string, extraEnv []string, modelEnv map[string]string) []string

BuildRunEnv 为 CLI 进程组装环境变量条目。

func LerosMCPTokenEnvVar

func LerosMCPTokenEnvVar() string

LerosMCPTokenEnvVar returns the env var name used for CLI MCP bearer token registration.

func NormalizeMCPServerConfig

func NormalizeMCPServerConfig(cfg agent.MCPServerConfig) agent.MCPServerConfig

NormalizeMCPServerConfig fills defaults for an MCP server registration.

func ResolveRunWorkDir

func ResolveRunWorkDir(workDir string) (string, error)

ResolveRunWorkDir returns the configured run workdir.

func RunCLICommand

func RunCLICommand(ctx context.Context, cliPath string, args []string, extraEnv []string) error

RunCLICommand runs a CLI command with a bounded timeout.

func ScanJSONLines

func ScanJSONLines(r io.Reader, visit func(line string) bool)

ScanJSONLines 扫描换行符分隔的 JSON 日志,支持更大的 token 缓冲区。

Types

type CmdProcess

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

CmdProcess 实现 os/exec.Cmd 的 Process 接口。

func NewCmdProcess

func NewCmdProcess(cmd *exec.Cmd, done <-chan struct{}) *CmdProcess

NewCmdProcess 将 cmd 和调用方拥有的 Wait 完成信号包装为 Process。 调用方必须保持 cmd.Wait() 的唯一所有权,并在 Wait 返回后关闭 done。

func (*CmdProcess) PID

func (p *CmdProcess) PID() int

PID 返回命令启动后的进程 ID。

func (*CmdProcess) Stop

func (p *CmdProcess) Stop() error

Stop 优雅地终止子进程,不调用 cmd.Wait 或 cmd.Process.Wait。

关闭流程:

  1. 发送 SIGTERM 请求子进程自行清理
  2. 等待 gracefulShutdownTimeout
  3. 超时则强制 SIGKILL

Stop 是幂等的,多次调用安全。

type Process

type Process interface {
	PID() int
	Stop() error
}

Process is the minimal lifecycle handle exposed by a provider invocation.

Jump to

Keyboard shortcuts

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