executor

package
v0.0.0-...-19b05ac Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package executor runs godemode-style "code mode": the agent submits one Go program that drives the memory registry via the injected `gitmem` package, and the whole batch executes locally in a single round trip.

The interpreted program looks like:

package main

import "gitmem"

func main() {
    v, err := gitmem.Call("memGet", map[string]interface{}{"key": "user.name"})
    if err != nil { gitmem.Return(map[string]interface{}{"error": err.Error()}); return }
    gitmem.Return(v)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Executor

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

Executor interprets code-mode programs against a tool registry.

func New

func New(registry *tools.Registry, timeout time.Duration) *Executor

New returns an Executor bound to registry. timeout<=0 uses 30s.

func (*Executor) Execute

func (e *Executor) Execute(ctx context.Context, src string) (*Result, error)

Execute validates, interprets, and runs src, returning its result. The interpreter is created per run so the injected gitmem.Call closes over this request's context and result holder.

TODO(scaffold): pool interpreters (rebinding symbols per run) for lower per-call latency once the surface is stable.

type Result

type Result struct {
	Return   interface{}   `json:"return,omitempty"` // value passed to gitmem.Return
	Stdout   string        `json:"stdout,omitempty"` // captured fmt output
	Duration time.Duration `json:"-"`
}

Result is the outcome of one code-mode run.

type Validator

type Validator struct{}

Validator statically checks code-mode source before it is interpreted.

func NewValidator

func NewValidator() *Validator

NewValidator returns a Validator.

func (*Validator) Validate

func (v *Validator) Validate(src string) error

Validate parses src and rejects forbidden imports. It returns a descriptive error so the agent can correct its program.

Jump to

Keyboard shortcuts

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