Skip to content

WorkspaceOptions ​

Type, in @jr2/orchestrator/src/workspace.ts. The signature of an export, or a type that it names, names this type. The Authoring surface page lists each export. This type is not an export of @jr2/orchestrator, so a workflow module does not import it by name.

ts
type WorkspaceOptions<TSchema extends z.ZodObject, TSlots extends string> = SandboxOptions<
  TSlots,
  z.infer<TSchema>
> & {
  input: TSchema;
  spec: (args: { input: WithoutEmptyIndex<z.infer<TSchema>> & HostInjectedInput }) => WorkspaceSpec;
};

The options of a workspace() that declares the input that starts a run.

Fields: each field of SandboxOptions, and these:

  • input: TSchema

    The input that starts a run, as a z.object. jr2 checks each start against it. It also types the input of spec and of a per-run Repo Slot, and the body must accept it plus the workspace handles. Write it here, not on the body.

  • spec: (args: { input: WithoutEmptyIndex<z.infer<TSchema>> & HostInjectedInput; }) => WorkspaceSpec

    A function from the run input to the Workspace's WorkspaceSpec: the branch it works on, and optionally reviewSha and workGroup. jr2 calls it when the run enters the Workspace.

    The input of spec also holds instanceId, the seed Instance ID of the run (see HostInjectedInput). Use it to give each run a branch of its own: spec: ({ input }) => ({ branch: `fix/${input.instanceId}` }). Only a root workspace() gets it from jr2. A workspace() that a different Machine invokes gets only the input that its parent gives it, so that parent must give instanceId when spec reads it.

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