Skip to content
docsv0.1.0

Operation

The atom: one operation defined once — schema of inputs + handler + metadata — that the family projects to N surfaces (CLI, MCP, HTTP, web, TUI). A `SurfaceProjector` turns this into each surface's native shape; the operation is written once and surfaced wherever it is enabled. `readonly` (not `final`) so that the deprecated `Milpa\Runtime\CommandDefinition` can remain a subclass during the transition — a readonly class may only be extended by a readonly class.

Operation::__construct()

public function __construct(string $name, string $description, ?mixed $handler, ?array $inputSchema = null, bool $mutating = false, bool $requiresConfirmation = false, array $scopes = [], ?array $outputSchema = null, ?string $version = null, ?string $path = null, ?array $surfaces = null):

Parameters

Parameters of __construct()
NameTypeDescription
$namestring
$descriptionstring
$handler(callable | array{0: class-string, 1: string})A plain PHP callable, or a `[class-string, method]` pair a host resolves through DI. Typed `mixed` because PHP forbids the native `callable` type on a property. Called with the coerced `array<string,mixed> $input`; returns domain data.
$inputSchema(array<string, mixed> | null)JSON-Schema-shaped input definition; null = no typed inputs.
$mutatingbool
$requiresConfirmationbool
$scopeslist<string>Auth scopes enforced by a policy gate on surfaces that have one wired — MCP today (via tool-runtime's PolicyGate); HTTP scope enforcement lands with per-route middleware in a later slice.
$outputSchema(array<string, mixed> | null)JSON-Schema-shaped output definition.
$version?string
$path(string | null)HTTP path; declared here, or (null) derived from `$name`.
$surfaces(list<string> | null)Surfaces this operation opts into; null = all.

Operation::supportsSurface()

public function supportsSurface(string $surface): bool

Whether this operation is projected to the given surface. `null` $surfaces means every surface; a list is an explicit opt-in.

Parameters

Parameters of supportsSurface()
NameTypeDescription
$surfacestring