Machine Provider API
Declare a machine's manifest v3, its actions, holds, jobs and stop, and implement the provider session ABI v2 over host-owned I/O.
Machine Provider API
Import from @taucad/runtime/machine. A provider declares a model's manifest and connects a machine session. The host admits requests; the provider sends, observes and reports.
Provider definition
defineMachine takes a trusted MachineProviderDefinition and returns a callable MachineProviderFactory. Fields include identity, protocolVersion: 2, MachineManifestDefinition, binding and submission configurations, optional settings, discover and connect. Consumers read the serializable MachineProvider, validated by parseMachineProvider. /plugin exports ExpandPluginMachines for provider-tuple inference.
machineManifestOf produces a serializable MachineManifest, removing schemas and filling the start form. parseMachineManifest and machineManifestSchema reject unknown keys and dangling references. machineActionDefinitionOf retrieves an installed action or hold's trusted validation schema.
Manifest v3
A MachineManifest has version: 3 and these parts:
identity: type id, vendor, model and display name.connection:MachineConnectionFactsspecify transport, exclusivity, reset-on-open and identity authentication. Claimed identities are endpoint-pinned. Optionalcredentialisnoneorsecret, defaulting tosecretonly for authenticated identities. Up to 8 TLSservices({ id, port, required }) are pinned on first use inserviceTrust; unavailable required services refuse binding.axesandcomponents: eachMachineAxisthe controller moves, and eachMachineComponentwith its kind (motion,spindle,tools,probe,toolhead,material-system,interlock, simple kinds by name, orkind: 'vendor'with a namespacedtype,<vendor>.<name>).processes: eachMachineProcess, aMachineFffProcess, aMachineMillingProcessor a vendor process;fffProcessOfandmillingProcessOffind them.actions,holds,jobsandstop: what the machine can be asked to do, described below.observations: each group's freshness budget and whether it isretainedorlatest(coalesced, never replayed).qualifications: eachMachineQualificationProfile, the hardware or simulation evidence an action names when it is qualified.
Actions and holds
standardMachineAction and defineMachineAction declare standard or <vendor>.<area>.<verb> actions. Both return MachineActionDefinition: a MachineActionDescriptor and host validation schema. Providers may narrow schemas and raise authority, never reverse either. Actions remain designed until qualified; only people in Testing mode may try them. machineJogHold returns MachineHoldDefinition with lease and bound. machineActionDescriptorOf strips either definition's schema. Timed effects declare safety.maximumDuration and run as self-ending controller sequences even if Tau goes silent. If only Stop ends an effect early, refuse early off with a stop remedy.
jobs is unsupported or MachineJobFacts: each accepted container (MachineAcceptedContainer: a semantic contract, mediaType, technology, requiredMembers and payloadSelection, single for a G-code or NC program; optional extensions such as .gcode name the files a consumer offers), stored or streamed delivery, a remote or at-machine start, attestations a person makes before a start (always work-area-clear), and the start's attendance and interlocks; a person always approves a job, so it names no authority. stop is a MachineHaltOutcome: what motion, spindle, heaters and an optional beam emission do, whether position is kept, and the recovery remedies.
import { defineConfiguration } from '@taucad/runtime/schema';
import { machineJogHold, standardMachineAction } from '@taucad/runtime/machine';
import type { MachineManifestDefinition } from '@taucad/runtime/machine';
import { z } from 'zod';
export const manifest: MachineManifestDefinition = {
version: 3,
identity: { typeId: 'example.router', vendor: 'Example', model: 'router', displayName: 'Example router' },
connection: { transport: 'serial', exclusive: true, opening: 'resets-controller', identity: 'claimed' },
axes: ['x', 'y', 'z'].map((id) => ({
id,
label: id.toUpperCase(),
kind: 'linear',
unit: 'mm',
carries: 'tool',
reference: 'cycle',
})),
components: [
{ id: 'light', kind: 'light', label: 'Light' },
{ id: 'gantry', kind: 'motion', label: 'Gantry', axes: ['x', 'y', 'z'] },
],
processes: [],
actions: [
standardMachineAction({
id: 'switch.set',
componentId: 'light',
componentKind: 'light',
label: 'Light',
when: ['ready', 'active'],
}),
],
holds: [machineJogHold({ componentId: 'gantry', lease: 250, bound: 500 })],
jobs: { type: 'unsupported' },
stop: { motion: 'halts', spindle: 'stops', heaters: 'none', position: 'kept', recovery: [] },
observations: [],
qualifications: [],
};
export const binding = defineConfiguration({
id: 'example.router.binding',
version: '1.0.0',
// Only how to talk to it: the serial path is the discovery endpoint, and the person names the machine at bind.
schema: z.object({ baudRate: z.number().int().positive().default(115_200) }),
ui: { version: 1, rjsf: {} },
});Host services
The provider never receives a general filesystem, socket or secret grant. discover receives MachineDiscoveryInput, whose optional endpoint names where a person says the machine is (search only there), and a MachineDiscoveryRuntime: listenDatagrams admits a user-initiated listener (MachineDatagramListenInput) yielding MachineDatagram values with peer evidence, and listSerialPorts lists each MachineSerialPort. It yields MachineDiscoveryEvent values.
connect receives MachineConnectInput, whose MachineConnectionContext carries a host-local secret reference and each service's MachineTransportTrust (system or a pinned digest), and a MachineConnectionRuntime. That runtime opens a bounded MachineNetworkStream for a MachineNetworkRequest and streams an immutable MachineArtifactReference in chunks through MachineArtifactReadInput. Optional services, absent on a host without them: openSerial takes a MachineSerialRequest, captureNetworkStill captures one RTSPS JPEG for MachineNetworkStillInput, and uploadFile stores a file over implicit FTPS with MachineFileUploadInput, returning MachineFileUploadReceipt. Any provider may use them undeclared; the call carries every endpoint, account and trust detail. MachineClock is the host's time source; MachineLogEntry is redacted provider telemetry.
Session ABI v2
connect returns MachineSession. Reads: getDescriptor takes MachineGetDescriptorInput, returning MachineProviderDescriptor with MachineInstalledCapabilities; only the host adds revision, incarnation and manifest qualifications. getSnapshot takes MachineGetSnapshotInput, returning MachineReport. observe takes MachineObserveInput: each subscriber receives a snapshot MachineObservation before any changed deltas. Aborting returns without throwing.
Every session implements stop, ahead of queued work. reconcile takes MachineReconcileInput and reads proof of a late stop, transfer, start or action without sending. Both return MachineCommandReceipt: accepted, rejected with a code, or unknown, never retried by the host. close and dispose release the session.
Four required facets are each unsupported or supported:
actionsis aMachineActionCapability.applyreceives one admittedMachineProviderActionInputand sends it once. Before sending, callcheckMachineActionAtSendwith the current report and the manifest'sobservationsbudgets: it repeats state, run, freshness, homing, interlock and availability checks and returns the refusal to report. For an action confirmed by observation,confirmreads the most recent report and returns aMachineActionConfirmation; for an operation this session never sent, the answer ispending.holdsis aMachineHoldCapability.beginreceivesMachineProviderHoldInputand returns aMachineProviderHoldwhoseextendsends at most one self-ending segment and whosereleasestops now, or a refusal.jobs:MachineJobCapability. OptionalcompleteConfigurationtakesMachineCompleteConfigurationInput, filling provider keys from program facts before current setup.preparetakesMachineProviderJobInput, returning read-onlyMachinePreparation. Stored delivery addsremoteNamefortransferandstart; streamed delivery only starts (MachineProviderStartInput), returning after the first controller-accepted block while feeding continues.MachineJobFailureCodeaccepts host codes and providerMACHINE_JOB_orMACHINE_TRANSFER_codes, checked byisMachineJobFailureCode. Only check/prepare refusals retain provider codes; rejected transfer/start usesMACHINE_ACTION_PROVIDER_REJECTEDwith the provider code in its message.stillCaptureis aMachineStillCaptureCapability.capturetakesMachineCaptureStillInputand returns aMachineStill. Never infer still capture from a network endpoint.