tools

package
v0.62.5 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyHunks

func ApplyHunks(source string, hunks []PatchHunk) (string, error)

ApplyHunks applies a list of hunks to a source file body, returning the resulting body. Context (and removed) lines must match the source byte-for-byte.

Types

type ApplyPatchTool

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

ApplyPatchTool implements `apply_patch`. The patch text is parsed locally (in env-mcp) into structured FileOps; each op is then translated into fs/readFile + fs/writeFile + fs/remove + fs/copy RPCs on the remote.

Per-file outcomes are reported as `path: ok` / `path: error: ...` lines so the LLM sees which files succeeded even on partial failure.

func NewApplyPatchTool

func NewApplyPatchTool(pool *bridge.Pool, resolver *nameresolver.Resolver) *ApplyPatchTool

func (*ApplyPatchTool) Call

func (*ApplyPatchTool) Description

func (t *ApplyPatchTool) Description() string

func (*ApplyPatchTool) InputSchema

func (t *ApplyPatchTool) InputSchema() json.RawMessage

func (*ApplyPatchTool) Name

func (t *ApplyPatchTool) Name() string

type CopyPathTool

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

CopyPathTool copies a file or directory between executors.

v0.56.0: prefers HTTPS out-of-band relay (curl PUT on src + curl GET on dst → bytes flow direct executor↔gateway↔executor, never through env-mcp's ws bridge). When the relay path is unavailable (gateway not configured, executor missing curl, or recursive copy below) it falls back to the v0.55.x ws cat-pump path that shuttles each chunk through process/read+process/write RPCs.

See:

  • docs/superpowers/specs/2026-05-18-copy-path-http-relay.md (v0.56.0)
  • docs/superpowers/specs/2026-05-18-env-mcp-transfer-tool.md (v0.55.x)

func NewCopyPathTool

func NewCopyPathTool(pool *bridge.Pool, resolver *nameresolver.Resolver, relay *bridge.RelayClient) *CopyPathTool

func (*CopyPathTool) Call

func (*CopyPathTool) Description

func (t *CopyPathTool) Description() string

func (*CopyPathTool) InputSchema

func (t *CopyPathTool) InputSchema() json.RawMessage

func (*CopyPathTool) Name

func (t *CopyPathTool) Name() string

type FileOp

type FileOp struct {
	Kind    FileOpKind
	Path    string
	NewPath string      // only set when Kind == OpMove
	Content string      // full file body for OpAdd; empty for others
	Hunks   []PatchHunk // only set when Kind == OpUpdate or OpMove
}

FileOp is one entry in the parsed patch.

func ParsePatch

func ParsePatch(input string) ([]FileOp, error)

ParsePatch parses a complete apply_patch document.

type FileOpKind

type FileOpKind int

FileOpKind identifies the kind of operation.

const (
	OpAdd FileOpKind = iota + 1
	OpUpdate
	OpDelete
	OpMove
)

type HunkLine

type HunkLine struct {
	Kind HunkLineKind
	Text string
}

type HunkLineKind

type HunkLineKind int
const (
	HunkContext HunkLineKind = iota + 1
	HunkAdd
	HunkRemove
)

type ListEnvironmentsTool

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

ListEnvironmentsTool returns the workspace's connected executors. Per v0.54.0 the LLM-facing view shows only name + description + last_seen (no exe_id). The shared nameresolver.Resolver populates its cache as a side effect of every call, so subsequent shell/apply_patch/etc tool calls can look up name → exe_id.

func NewListEnvironmentsTool

func NewListEnvironmentsTool(resolver *nameresolver.Resolver) *ListEnvironmentsTool

func (*ListEnvironmentsTool) Call

func (*ListEnvironmentsTool) Description

func (t *ListEnvironmentsTool) Description() string

func (*ListEnvironmentsTool) InputSchema

func (t *ListEnvironmentsTool) InputSchema() json.RawMessage

func (*ListEnvironmentsTool) Name

func (t *ListEnvironmentsTool) Name() string

type MCPCallToolParams

type MCPCallToolParams struct {
	Name      string          `json:"name"`
	Arguments json.RawMessage `json:"arguments"`
}

MCPCallToolParams is the request body of `tools/call`.

type MCPCallToolResult

type MCPCallToolResult struct {
	Content           []MCPToolContent `json:"content"`
	StructuredContent json.RawMessage  `json:"structuredContent,omitempty"`
	IsError           bool             `json:"isError"`
}

MCPCallToolResult is the response body of `tools/call`.

StructuredContent carries machine-readable fields (e.g. shell's stdout/stderr/exit_code) parallel to the human-readable Content text. Per MCP spec it's an arbitrary JSON object; we use RawMessage so each tool can shape it as needed without a wider schema.

type MCPInitializeResult

type MCPInitializeResult struct {
	ProtocolVersion string         `json:"protocolVersion"`
	Capabilities    map[string]any `json:"capabilities"`
	ServerInfo      MCPServerInfo  `json:"serverInfo"`
}

MCPInitializeResult is the response to `initialize`.

type MCPListToolsResult

type MCPListToolsResult struct {
	Tools []MCPTool `json:"tools"`
}

MCPListToolsResult is the response to `tools/list`.

type MCPServerInfo

type MCPServerInfo struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

type MCPTool

type MCPTool struct {
	Name        string          `json:"name"`
	Description string          `json:"description"`
	InputSchema json.RawMessage `json:"inputSchema"`
}

type MCPToolContent

type MCPToolContent struct {
	Type string `json:"type"`
	Text string `json:"text"`
}

type PatchHunk

type PatchHunk struct {
	Context string
	Lines   []HunkLine
}

PatchHunk is one @@-delimited block in an Update File entry. Lines are stored in their original order so the application step can reconstruct the modified file. Context (when non-empty) is the "@@ <text>" anchor that the applier locates first; this matters when the body context appears in multiple places in the source.

type ReadFileTool

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

ReadFileTool implements `read_file` via exec-server fs/readFile. Offset/limit are applied to the decoded bytes after fetching the full file from the remote, matching codex's local read_file semantics (exec-server doesn't support partial reads server-side).

func NewReadFileTool

func NewReadFileTool(pool *bridge.Pool, resolver *nameresolver.Resolver) *ReadFileTool

func (*ReadFileTool) Call

func (*ReadFileTool) Description

func (t *ReadFileTool) Description() string

func (*ReadFileTool) InputSchema

func (t *ReadFileTool) InputSchema() json.RawMessage

func (*ReadFileTool) Name

func (t *ReadFileTool) Name() string

type ReadOutputTool

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

ReadOutputTool drains stdout/stderr buffered for a session.

func NewReadOutputTool

func NewReadOutputTool(pool *bridge.Pool, store *SessionStore) *ReadOutputTool

func (*ReadOutputTool) Call

func (*ReadOutputTool) Description

func (t *ReadOutputTool) Description() string

func (*ReadOutputTool) InputSchema

func (t *ReadOutputTool) InputSchema() json.RawMessage

func (*ReadOutputTool) Name

func (t *ReadOutputTool) Name() string

type SessionStore

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

SessionStore tracks open exec_command sessions and GCs old entries (anything older than sessionMaxAge gets reaped on each access). The GC is best-effort — sessions whose underlying process exited on its own simply linger until access pressure prunes them.

func NewSessionStore

func NewSessionStore() *SessionStore

NewSessionStore creates a new empty SessionStore.

type ShellTool

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

ShellTool implements the synchronous-shell MCP tool. Each call dispatches process/start on the selected executor then polls process/read until the process exits or the timeout elapses.

func NewShellTool

func NewShellTool(pool *bridge.Pool, resolver *nameresolver.Resolver) *ShellTool

func (*ShellTool) Call

func (*ShellTool) Description

func (t *ShellTool) Description() string

func (*ShellTool) InputSchema

func (t *ShellTool) InputSchema() json.RawMessage

func (*ShellTool) Name

func (t *ShellTool) Name() string

type TerminateTool

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

TerminateTool sends process/terminate then drops the session entry.

func NewTerminateTool

func NewTerminateTool(pool *bridge.Pool, store *SessionStore) *TerminateTool

func (*TerminateTool) Call

func (*TerminateTool) Description

func (t *TerminateTool) Description() string

func (*TerminateTool) InputSchema

func (t *TerminateTool) InputSchema() json.RawMessage

func (*TerminateTool) Name

func (t *TerminateTool) Name() string

type Tool

type Tool interface {
	Name() string
	Description() string
	InputSchema() json.RawMessage
	Call(ctx context.Context, args json.RawMessage) (MCPCallToolResult, error)
}

Tool is implemented by every MCP tool env-mcp exposes. tools/list builds its response by querying each registered Tool's metadata; tools/call dispatches by Name.

type UnifiedExecTool

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

UnifiedExecTool starts a long-lived process and returns a session_id the LLM uses with write_stdin / read_output / terminate.

func NewUnifiedExecTool

func NewUnifiedExecTool(pool *bridge.Pool, store *SessionStore, resolver *nameresolver.Resolver) *UnifiedExecTool

func (*UnifiedExecTool) Call

func (*UnifiedExecTool) Description

func (t *UnifiedExecTool) Description() string

func (*UnifiedExecTool) InputSchema

func (t *UnifiedExecTool) InputSchema() json.RawMessage

func (*UnifiedExecTool) Name

func (t *UnifiedExecTool) Name() string

type WriteFileTool

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

WriteFileTool implements `write_file` via exec-server fs/writeFile. The caller passes content_b64 (base64-encoded raw bytes); we validate the encoding locally and forward the same string to the bridge in bridge.FsWriteFileParams.DataBase64 — exec-server expects base64 on the wire, so a re-encode would be wasted work.

func NewWriteFileTool

func NewWriteFileTool(pool *bridge.Pool, resolver *nameresolver.Resolver) *WriteFileTool

func (*WriteFileTool) Call

func (*WriteFileTool) Description

func (t *WriteFileTool) Description() string

func (*WriteFileTool) InputSchema

func (t *WriteFileTool) InputSchema() json.RawMessage

func (*WriteFileTool) Name

func (t *WriteFileTool) Name() string

type WriteStdinTool

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

WriteStdinTool writes bytes to a session's stdin via process/write.

func NewWriteStdinTool

func NewWriteStdinTool(pool *bridge.Pool, store *SessionStore) *WriteStdinTool

func (*WriteStdinTool) Call

func (*WriteStdinTool) Description

func (t *WriteStdinTool) Description() string

func (*WriteStdinTool) InputSchema

func (t *WriteStdinTool) InputSchema() json.RawMessage

func (*WriteStdinTool) Name

func (t *WriteStdinTool) Name() string

Jump to

Keyboard shortcuts

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