Skip to content

open ​

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

ts
const open: unique symbol

Leave a part of a Machine Open: for the Instance that registers the Machine to bind with customize(). Write it where a value goes, in a Machine that you publish as a package, for a part that the package cannot know or pay for:

  • a Repo Slot: repos: { app: open }, or the whole map: repos: open;
  • an Agent's model: agent({ model: open, … });
  • an Effect's url or argv: http({ url: open, … }), command(open);
  • the secret of an Effect's auth, of a header, or of a command's env: secret(open).

jr2 up refuses a Workflow with an Open part that nobody bound, and prints the customize() line that binds it: refusing: workflow "<name>" leaves <part> open — bind it where the Machine is registered: export const machine = customize(<import>, …) (<adr>). A run never sees an Open part.

Example

ts
import { z } from "zod";
import { agent, customize, defineEvent, fail, jr2Setup, open, workspace } from "@jr2/orchestrator";

const finish = defineEvent({
  name: "finish",
  description: "Call this when `node --test` passes.",
  input: z.object({}),
});

const body = jr2Setup({
  events: [finish],
  actors: { coder: agent({ model: open, instructions: "You fix the failing test." }), fail: fail() },
}).createMachine({
  id: "fix",
  on: { "workspace.lost": ".lost", "agent.fault": ".failed" },
  initial: "coding",
  states: {
    coding: {
      invoke: { src: "coder", input: { prompt: "Make `node --test` pass." } },
      on: { finish: "done" },
    },
    done: { type: "final" },
    failed: { invoke: { src: "fail", input: { reason: "the Agent's Turn could not go on" } } },
    lost: { invoke: { src: "fail", input: { reason: "the Sandbox is gone" } } },
  },
});

// What a package exports: the repository and the model are Open.
export const fix = workspace(body, {
  repos: { app: open },
  spec: () => ({ branch: "jr2/fix" }),
});

// What an Instance's `workflows/fix.ts` exports: the same Machine, its Open parts bound.
export const machine = customize(fix, {
  repos: { app: { url: "https://github.com/you/app.git" } },
  agents: { coder: { model: "anthropic/claude-haiku-5-5" } },
});

See also

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