Skip to content

customize ​

Function, in @jr2/orchestrator/src/customize.ts. It is an export of @jr2/orchestrator, on the Authoring surface page, in Composition.

ts
function customize<M extends AnyStateMachine>(machine: M, parts: Customize<M>): M

Retune the parts that a Machine carries, without a change to the module that exports it. Use it where you register a Machine as a Workflow. It binds the parts that a packaged Machine leaves Open: its Repo Slots, an Agent's model, or an Effect's url, argv or secret. It also changes the parts that its author fixed: an Agent's instructions, the Sandbox Image, or the Size.

It gives back a new Machine of the same type. The original does not change, so two customize() calls on one import give two Machines. Only the parts the Machine declares can be retuned. You cannot add a part: a Machine that needs another Agent is a new Machine. The types refuse most mistakes when you compile. At run time, customize() also throws:

  • customize(): machine "<id>" carries no Agent slot "<slot>" — its Agents are: <slots>
  • customize(): machine "<id>" composes no Machine under "<slot>" — the Machines it composes are: <slots>
  • customize(): machine "<id>" carries no Effect slot "<slot>" — its Effects are: <slots>
  • customize(): machine "<id>" declares no Repo Slot "<slot>" — its slots are: <slots>
  • customize(): machine "<id>" declares its Repo Slots open as a map — name at least one
  • customize(): `repos` say what a SANDBOX is made of, how big it is and which Repos it attaches, and machine "<id>" composes none (for resources, the text starts customize(): `resources`; for image or user, it starts customize(): `image`/`user`)
  • customize(): machine "<id>": <errors>, when an Effect argv that you bind fails the checks that the Machine passed when it was built
  • the refusals of EffectBinding, RepoSlot, Size and UserContainer, which start with customize()

Parameters

  • machine: The Machine to retune: one you import from a package, or one you wrote. When its root is a workspace() or a pool(), customize() reaches through to the Machine inside, so you never name the wrapper's own slot.
  • parts: The parts to change. See Customize.

Returns: A new Machine of the same type, with the parts changed.

Example

ts
import { customize } from "@jr2/orchestrator";
import { task } from "@jr2/machines";

export const machine = customize(task, {
  repos: { app: { url: "https://github.com/you/app.git" } },
  agents: { coder: { model: "anthropic/claude-haiku-5-5" } },
  resources: { limits: { memory: "4Gi" } },
});

See also

The docs of Kit version 0.5.1. Each page is also at its .md URL.