codemode

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package codemode adapts the vMCP-agnostic Starlark engine in pkg/script into a core.VMCP decorator. The decorator advertises the execute_tool_script virtual tool alongside the backend tools and, when that tool is called, runs the submitted Starlark script. Inner tool calls made by the script route back through the inner core's CallTool, so the core admission seam authorizes each one by its real name — the script can only reach tools the identity is already admitted to.

The decorator is the seam where vMCP domain types (vmcp.Tool, vmcp.ToolCallResult) meet the engine's mcp-go types. That conversion is contained here so it does not leak across the core boundary (vmcp anti-pattern #5).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDecorator

func NewDecorator(inner core.VMCP, cfg *Config) core.VMCP

NewDecorator wraps inner with vMCP code mode. The returned VMCP advertises execute_tool_script in addition to inner's tools and executes submitted Starlark scripts when that tool is called. A nil cfg uses defaults.

inner must be non-nil; a nil inner is a composition-root wiring bug and panics rather than deferring the failure to the first promoted method call.

Types

type Config

type Config struct {
	// StepLimit is the maximum number of Starlark execution steps per script.
	// Zero resolves to [script.DefaultStepLimit].
	StepLimit uint64

	// ParallelMax is the maximum number of concurrent goroutines that parallel()
	// may spawn within a script. Zero (or negative) resolves to defaultParallelMax.
	ParallelMax int

	// ToolCallTimeout bounds each individual inner tool call made from a script.
	// Zero (or negative) resolves to defaultToolCallTimeout.
	ToolCallTimeout time.Duration
}

Config holds the code mode tuning parameters. Presence of a non-nil *Config at the composition root is itself the opt-in toggle; a nil *Config (the default) leaves the core undecorated and execute_tool_script absent from tools/list.

A nil *Config passed to NewDecorator, or any field left zero, resolves to the safe defaults in resolve — never to the engine's unbounded zero-value behavior.

func FromConfig

func FromConfig(c *config.CodeModeConfig) *Config

FromConfig translates the serialized vMCP code mode config into the runtime decorator Config. It returns nil when c is nil or disabled, so the caller can hand the result straight to the server config (a nil value leaves the core undecorated). It performs no defaulting: unset fields stay zero and are resolved to defaults by NewDecorator (see resolve), so the operator/CRD, YAML, and direct-construction paths share one source of defaults.

Jump to

Keyboard shortcuts

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