Skip to content
Français

defineIsolatedTask

import { defineIsolatedTask } from "@elie-laloum/outpost";

Declare a task that runs dispatch() at each attempt with the repository, provider, agent and options returned by request; each attempt allocates and closes its own sandbox. The output is the full DispatchResult with its resume() and fork() methods, so a checkpointed run must wrap the task in a defineTask() that returns JSON. cache is rejected.

Complete example and detailed rules.

  • optionsRequired
    Omit<TaskOptions<DispatchResult<T>>, "cache" | "perform"> & IsolatedTaskOptions<T>
    Task scheduling settings and request factory selecting a separate repository and sandbox for each attempt.
  • options.retryOptional
    Retry | undefined
    Retry policy for failed attempts; without it the task runs once. A retried attempt repeats its side effects.
  • options.gateOptional
    WorkflowGate | undefined
    Persisted approval or pause definition; execution requires a checkpoint and a matching trusted decision.
  • options.keyRequired
    string
    Unique key in the workflow, matching [A-Za-z0-9][A-Za-z0-9._-]*. Records, events and checkpoints identify the task by it.
  • options.afterOptional
    readonly Task<unknown>[] | undefined
    Tasks that must be done before this one starts, default none; only these can be read with context.value().
  • options.interactionOptional
    TaskInteraction | undefined
    Opt-in durable human-input contract; requires checkpointed scheduling and cannot be combined with a gate.
  • options.conditionOptional
    ((context: TaskContext) => boolean | Promise<boolean>) | undefined
    Evaluated with attempt 0 before the task runs, including when a later start() resumes it; false ends the task as skipped, which skips its dependents.
  • options.timeoutMsOptional
    number | undefined
    Deadline in milliseconds for each attempt, a positive integer up to 2147483647. Expiry aborts context.signal and fails the attempt, which retry may repeat.
  • options.requestRequired
    (context: TaskContext) => IsolatedTaskRequest<T> | Promise<IsolatedTaskRequest<T>>
    Build the repository, sandbox provider, agent and dispatch options for each attempt; may be async.
  • options.quotaResumeOptional
    QuotaResumePolicy | undefined
    After a quota pause, continue the captured conversation in the new dispatch (continue, default) or start a new one (restart). Automatically integrated workspaces then start from the interrupted branch; uncommitted changes stay in its retained worktree.

Task<DispatchResult<T>>

export declare function defineIsolatedTask<T>(
  options: Omit<TaskOptions<DispatchResult<T>>, "perform" | "cache"> &
    IsolatedTaskOptions<T>,
): Task<DispatchResult<T>>;