TauDOCS

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: MachineConnectionFacts specify transport, exclusivity, reset-on-open and identity authentication. Claimed identities are endpoint-pinned. Optional credential is none or secret, defaulting to secret only for authenticated identities. Up to 8 TLS services ({ id, port, required }) are pinned on first use in serviceTrust; unavailable required services refuse binding.
  • axes and components: each MachineAxis the controller moves, and each MachineComponent with its kind (motion, spindle, tools, probe, toolhead, material-system, interlock, simple kinds by name, or kind: 'vendor' with a namespaced type, <vendor>.<name>).
  • processes: each MachineProcess, a MachineFffProcess, a MachineMillingProcess or a vendor process; fffProcessOf and millingProcessOf find them.
  • actions, holds, jobs and stop: what the machine can be asked to do, described below.
  • observations: each group's freshness budget and whether it is retained or latest (coalesced, never replayed).
  • qualifications: each MachineQualificationProfile, 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:

  • actions is a MachineActionCapability. apply receives one admitted MachineProviderActionInput and sends it once. Before sending, call checkMachineActionAtSend with the current report and the manifest's observations budgets: it repeats state, run, freshness, homing, interlock and availability checks and returns the refusal to report. For an action confirmed by observation, confirm reads the most recent report and returns a MachineActionConfirmation; for an operation this session never sent, the answer is pending.
  • holds is a MachineHoldCapability. begin receives MachineProviderHoldInput and returns a MachineProviderHold whose extend sends at most one self-ending segment and whose release stops now, or a refusal.
  • jobs: MachineJobCapability. Optional completeConfiguration takes MachineCompleteConfigurationInput, filling provider keys from program facts before current setup. prepare takes MachineProviderJobInput, returning read-only MachinePreparation. Stored delivery adds remoteName for transfer and start; streamed delivery only starts (MachineProviderStartInput), returning after the first controller-accepted block while feeding continues. MachineJobFailureCode accepts host codes and provider MACHINE_JOB_ or MACHINE_TRANSFER_ codes, checked by isMachineJobFailureCode. Only check/prepare refusals retain provider codes; rejected transfer/start uses MACHINE_ACTION_PROVIDER_REJECTED with the provider code in its message.
  • stillCapture is a MachineStillCaptureCapability. capture takes MachineCaptureStillInput and returns a MachineStill. Never infer still capture from a network endpoint.

On this page