runtime

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package runtime coordinates workspace capability bindings, sandbox execution, inline-safe response budgeting, live TUI status updates, and audit logging.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SessionIDFromContext added in v0.3.0

func SessionIDFromContext(ctx context.Context) string

SessionIDFromContext extracts the MCP session identifier from ctx, or "" for stdio/default sessions.

func WithSessionID added in v0.3.0

func WithSessionID(ctx context.Context, sessionID string) context.Context

WithSessionID attaches an MCP session identifier (e.g. HTTP Mcp-Session-Id) to ctx for task isolation.

Types

type Engine

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

Engine manages workspace-scoped capability instances, state stores, audit logs, and PTC program execution.

func NewEngine

func NewEngine(dataDir, defaultCwd string) *Engine

NewEngine creates a PTC runtime engine with Antigravity plugin defaults.

func NewEngineWithOptions

func NewEngineWithOptions(opts EngineOptions) *Engine

NewEngineWithOptions creates a runtime engine with explicit host profile options.

func (*Engine) Close

func (e *Engine) Close()

Close shuts down pooled external MCP processes and terminates all running background tasks.

func (*Engine) CloseSession added in v0.3.0

func (e *Engine) CloseSession(sessionID string) int

CloseSession terminates any running background tasks started by sessionID.

func (*Engine) EventHub added in v0.3.0

func (e *Engine) EventHub() *events.Hub

EventHub returns the real-time event hub for TUI and HTTP SSE consumers.

func (*Engine) RunMCPExec

func (e *Engine) RunMCPExec(ctx context.Context, in ExecInput) (text string, isError bool)

RunMCPExec executes a PTC TypeScript program and returns an inline-safe (`<= 9,600 B` UTF-8 by default) formatted response.

func (*Engine) RunReadTool added in v0.3.0

RunReadTool executes the standalone MCP `read` tool (line-range/tail/byteOffset text + native images).

func (*Engine) RunTaskManage added in v0.3.0

func (e *Engine) RunTaskManage(ctx context.Context, req tasks.ManageRequest) (*tasks.ManageResult, string, error)

RunTaskManage executes the standalone MCP `task` tool (list, status, logs, wait, input, kill, kill_all).

func (*Engine) RunTaskSpawn added in v0.3.0

func (e *Engine) RunTaskSpawn(ctx context.Context, req tasks.StartRequest) (*tasks.StartResult, string, error)

RunTaskSpawn executes the standalone MCP `spawn` tool to run long commands or daemons.

func (*Engine) SetClientWorkspace

func (e *Engine) SetClientWorkspace(ws string)

SetClientWorkspace records a workspace root reported by the MCP client during `initialize`.

type EngineOptions

type EngineOptions struct {
	DataDir               string
	DefaultCwd            string
	DefaultMaxOutputBytes int  // 0 -> output.DefaultInlineMaxBytes (9600)
	StrictWorkspace       bool // confine all file/shell access strictly to workspace + ExtraRoots
	ExtraRoots            []string
	PolicyFiles           []string
	MCPConfigPaths        []string
	TrustWorkspaceMCP     bool
	AntigravityMode       bool // true for agy-ptc plugin; false for standalone generic mcplex
	EnableTasks           bool // enable background tasks manager & sandbox tasks.* namespace
	EnableEvents          bool // record live CRUD & execution events for TUI / HTTP SSE
	EventHistory          int  // ring buffer capacity for EventHub (default 500)
}

EngineOptions configures a runtime Engine for either standalone MCPlex or Antigravity plugin mode.

type ExecInput

type ExecInput struct {
	Code           string            `json:"code"`
	Payloads       map[string]string `json:"payloads,omitempty"`
	Cwd            string            `json:"cwd,omitempty"`
	Title          string            `json:"title,omitempty"`
	TimeoutMs      int               `json:"timeoutMs,omitempty"`
	TimeoutSec     int               `json:"timeoutSec,omitempty"`
	MaxOutputBytes int               `json:"maxOutputBytes,omitempty"`
}

ExecInput represents the flat MCP arguments passed to `exec`.

type LiveStatus

type LiveStatus struct {
	Active       bool   `json:"active"`
	Title        string `json:"title,omitempty"`
	CurrentOp    string `json:"currentOp,omitempty"`
	TotalRuns    int64  `json:"totalRuns"`
	TotalHostOps int64  `json:"totalHostOps"`
	LastDurMs    int64  `json:"lastDurationMs"`
	LastStatus   string `json:"lastStatus"`
	UpdatedAt    string `json:"updatedAt"`
}

LiveStatus is written atomically to `${PLUGIN_DATA}/live-status.json` for `agy-ptc statusline`.

Jump to

Keyboard shortcuts

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