ops

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 1 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ops defines the canonical catalog of ghostchrome agent operations.

This is the single source of truth for op names, summaries, argument shapes, and which surfaces expose each op. The three live surfaces are:

  • "jsonl" — internal/runtime dispatch table, framed by cmd/agent.go
  • "mcp" — internal/surface/mcp (tool registration)
  • "ai" — internal/surface/ai (ToolSpecs)

The catalog is EXECUTABLE, not documentation: `go generate ./internal/ops/...` emits, from Catalog() alone,

  • contracts/commands.json — the frozen SDK contract
  • internal/runtime/handlers_gen.go — the JSONL name -> method bindings
  • internal/surface/mcp/tools_gen.go — the MCP tool schemas + handler pairs
  • internal/surface/ai/tools_gen.go — the AI tool specs

Adding an op therefore means editing this file and running go generate. The generated bindings reference a hand-written handler method, so the build fails until the behaviour is written; registration can no longer drift from the catalog because no surface declares its own list any more.

What the catalog does NOT own: handler bodies. Args/Summary describe the contract, MCP/AI describe the wire; the behaviour behind them stays hand written in internal/runtime and internal/surface/mcp.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Validate added in v0.7.0

func Validate() []error

Validate reports every internal inconsistency of the catalog. The generator refuses to write any file while this returns a non-empty slice, so a catalog that would produce broken or ambiguous code never reaches the surfaces.

It checks the catalog against itself only: whether the surfaces actually implement what is declared here is no longer testable, it is generated.

Types

type Arg

type Arg struct {
	Name     string  `json:"name"`
	Type     ArgType `json:"type"`
	Required bool    `json:"required"`
	// Description is a short human-readable note (optional).
	Description string `json:"description,omitempty"`
}

Arg describes one argument accepted by an op.

type ArgType

type ArgType string

ArgType describes the JSON type of an argument.

const (
	ArgString  ArgType = "string"
	ArgInteger ArgType = "integer"
	ArgNumber  ArgType = "number"
	ArgBoolean ArgType = "boolean"
	ArgArray   ArgType = "array"
	ArgObject  ArgType = "object"
)

type Op

type Op struct {
	Name    string `json:"name"`
	Summary string `json:"summary"`
	Args    []Arg  `json:"args"`
	// Surfaces lists which protocol surfaces expose this op.
	// Known values: "jsonl", "mcp", "ai".
	Surfaces []string `json:"surfaces"`

	// MCP and AI carry the wire declaration for those two surfaces. They are
	// excluded from contracts/commands.json on purpose: the contract the SDKs
	// are typed against is frozen, and it describes ops, not per-surface
	// schemas. The generator refuses to run if the Surfaces list and the
	// presence of these specs disagree.
	MCP *SurfaceSpec `json:"-"`
	AI  *SurfaceSpec `json:"-"`
}

Op is one entry in the canonical operation catalog.

func Catalog

func Catalog() []Op

Catalog returns the full canonical list of ghostchrome agent operations, sorted alphabetically by name.

Surface coverage notes (divergences are intentional, not bugs):

  • "snapshot" is MCP-only: it bundles navigate+extract+errors into one call to amortize the per-tool token cost in MCP's tools/list. JSONL has dedicated ops for each concern.
  • "done" is AI-only: it is a meta-tool that signals goal completion to the Anthropic tool-use loop. It has no CDP side-effect and no JSONL/MCP equivalent.
  • "wait_for" is MCP-only: it extends the basic "wait" op with text-match and a timeout_ms parameter. The JSONL surface uses "wait" with selector/ms.
  • "fill" and "init" and "close" are JSONL-only: fill is a convenience multi-field wrapper; init/close manage session lifecycle that MCP/AI handle implicitly.
  • "extract" and "hover" and "scroll_by"/"scroll_to" appear in JSONL and AI but not MCP (snapshot replaces extract in MCP; hover/scroll are available via eval in MCP).
  • "errors" and "url" appear in JSONL and AI but not MCP (covered by snapshot).
  • "screenshot" appears in JSONL and MCP but not AI.
  • "emulate" and "swipe" are MCP-only: the CLI covers them with the `emulate` command plus a session-persisted profile, and the JSONL loop runs in one process where `ghostchrome batch` can carry an emulate verb. MCP holds a long-lived browser, so it needs its own device switch and a touch-event gesture (drag is mouse-only and a mobile PWA ignores it).

The MCP and AI specs below are the texts those surfaces published before the catalog became executable, kept verbatim: they are read by MCP clients and by models, so generation reproduces them rather than rewriting them from Summary.

type SurfaceArg added in v0.7.0

type SurfaceArg struct {
	Name        string
	Type        ArgType
	Required    bool
	Description string
	// Enum restricts the accepted values (JSON Schema "enum").
	Enum []string
	// Items is the element type when Type is ArgArray.
	Items ArgType
	// Default is the schema default: string, bool, int or float64.
	// nil means the surface declares no default.
	Default any
}

SurfaceArg is one argument exactly as a single surface puts it on the wire: its name on that surface, its schema keywords, its default. It is deliberately separate from Arg — Arg is the contract-level description shared by the SDKs, SurfaceArg is what a client actually sends, and the two legitimately differ (MCP calls eval's argument "expression", JSONL calls it "expr").

type SurfaceSpec added in v0.7.0

type SurfaceSpec struct {
	Description string
	Args        []SurfaceArg
	// Order fixes the position of the tool in the list handed to an LLM, where
	// order carries a weak recall bias. Only the AI surface uses it; MCP sorts
	// its tools by name before answering tools/list. Ops sharing an Order fall
	// back to alphabetical.
	Order int
}

SurfaceSpec is an op's declaration on one surface: the description a client or a model reads, and the arguments in declaration order (the order also fixes the JSON Schema "required" array).

Directories

Path Synopsis
Package gen turns the canonical ops catalog into the artefacts every surface reads.
Package gen turns the canonical ops catalog into the artefacts every surface reads.

Jump to

Keyboard shortcuts

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