Skip to content

factory/steps ​

Durable steps your workflows import from #jigs/steps. Each wrapper carries its own "use step" directive and stable factory identity.

Linear and human input ​

fetchTicketSnapshot() ​

ts
function fetchTicketSnapshot(ticket): Promise<TicketSnapshot>;

Read the ticket's current details, comments, and related issues from Linear.

Parameters ​

ParameterType
ticket{ installationName: string; issueId: string; }
ticket.installationNamestring
ticket.issueIdstring

Returns ​

Promise<TicketSnapshot>


postTicketHumanInputRequest() ​

ts
function postTicketHumanInputRequest(request): Promise<void>;

Ask in the ticket's Linear agent session for human input. Use haltForHuman() to also wait for a reply.

Parameters ​

ParameterType
request{ halt: Halt; installationName: string; issueId: string; sessionId: string; }
request.haltHalt
request.installationNamestring
request.issueIdstring
request.sessionIdstring

Returns ​

Promise<void>


postTicketNote() ​

ts
function postTicketNote(request): Promise<void>;

Post a note in the ticket's Linear agent session that asks for nothing and waits for nothing.

Parameters ​

ParameterType
request{ installationName: string; issueId: string; note: TicketNote; sessionId: string; }
request.installationNamestring
request.issueIdstring
request.noteTicketNote
request.sessionIdstring

Returns ​

Promise<void>


resolveLinearIssue() ​

ts
function resolveLinearIssue(request): Promise<LinearIssueRef>;

Resolve a Linear ticket identifier or issue ID before claiming it.

Parameters ​

ParameterType
request{ installationName: string; reference: string; }
request.installationNamestring
request.referencestring

Returns ​

Promise<LinearIssueRef>


setTicketStatus() ​

ts
function setTicketStatus(request): Promise<TicketStatusResult>;

Move a ticket to a named state when this workflow's policy says to.

Parameters ​

ParameterType
request{ installationName: string; issueId: string; stateName: string; }
request.installationNamestring
request.issueIdstring
request.stateNamestring

Returns ​

Promise<TicketStatusResult>

PagerDuty incidents ​

fetchIncidentSnapshot() ​

ts
function fetchIncidentSnapshot(incident): Promise<IncidentSnapshot>;

Read a snapshot of the PagerDuty incident.

Parameters ​

ParameterType
incident{ incidentId: string; installationName: string; }
incident.incidentIdstring
incident.installationNamestring

Returns ​

Promise<IncidentSnapshot>


postIncidentNote() ​

ts
function postIncidentNote(note): Promise<{
  noteId: string;
}>;

Add a plain-text note to the PagerDuty incident, ending in a line that names this run.

Parameters ​

ParameterType
note{ content: string; incidentId: string; installationName: string; }
note.contentstring
note.incidentIdstring
note.installationNamestring

Returns ​

Promise<{ noteId: string; }>

Pull requests ​

commentOnPullRequest() ​

ts
function commentOnPullRequest(pullRequest, body): Promise<{
  id: number;
}>;

Add a comment to the pull request's main conversation.

Parameters ​

ParameterType
pullRequestPullRequestRef
bodystring

Returns ​

Promise<{ id: number; }>


createPullRequest() ​

ts
function createPullRequest(request): Promise<OpenedPullRequest>;

Create a pull request for a branch that has already been pushed.

Parameters ​

ParameterType
request{ body: string; draft?: boolean; title: string; worktree: Worktree; }
request.bodystring
request.draft?boolean
request.titlestring
request.worktreeWorktree

Returns ​

Promise<OpenedPullRequest>


fetchPullRequestState() ​

ts
function fetchPullRequestState(pullRequest, options?): Promise<PullRequestSnapshot>;

Read a pull request's reviews, comments, CI results, approval, and merge state.

Parameters ​

ParameterType
pullRequestPullRequestRef
options?PullRequestReadOptions

Returns ​

Promise<PullRequestSnapshot>


markPullRequestReady() ​

ts
function markPullRequestReady(pullRequest): Promise<PullRequestSnapshot>;

Mark a draft pull request ready for review and return its current state.

Parameters ​

ParameterType
pullRequestPullRequestRef

Returns ​

Promise<PullRequestSnapshot>


mergePullRequest() ​

ts
function mergePullRequest(
   pullRequest, 
   expectedHeadSha, 
options?): Promise<MergeOutcome>;

Merge the pull request with the first method its repository allows of squash, merge commit and rebase, pinned to the approved head.

Parameters ​

ParameterType
pullRequestPullRequestRef
expectedHeadShastring
options?MergeOptions

Returns ​

Promise<MergeOutcome>


replyToPullRequestReviewThread() ​

ts
function replyToPullRequestReviewThread(
   pullRequest, 
   rootCommentId, 
   body): Promise<{
  id: number;
}>;

Reply to an existing code-review thread on a pull request.

Parameters ​

ParameterType
pullRequestPullRequestRef
rootCommentIdnumber
bodystring

Returns ​

Promise<{ id: number; }>


reviewPullRequest() ​

ts
function reviewPullRequest(pullRequest, review): Promise<{
  id: number;
}>;

Post a review on a pull request.

Parameters ​

ParameterType
pullRequestPullRequestRef
review{ body: string; comments?: object[]; event: "comment" | "approve" | "request-changes"; }
review.bodystring
review.comments?object[]
review.event"comment" | "approve" | "request-changes"

Returns ​

Promise<{ id: number; }>

Slack messages ​

fetchSlackMessage() ​

ts
function fetchSlackMessage(message): Promise<SlackMessageSnapshot>;

Read a Slack message and its thread replies, with each author's name and email.

Parameters ​

ParameterType
message{ channel: string; installationName: string; ts: string; }
message.channelstring
message.installationNamestring
message.tsstring

Returns ​

Promise<SlackMessageSnapshot>


postSlackMessage() ​

ts
function postSlackMessage(message): Promise<string>;

Post plain mrkdwn text to a Slack channel, or reply in the thread under threadTs.

Parameters ​

ParameterType
message{ channel: string; installationName: string; text: string; threadTs?: string; }
message.channelstring
message.installationNamestring
message.textstring
message.threadTs?string

Returns ​

Promise<string>

Git changes ​

pushApprovedChange() ​

ts
function pushApprovedChange(worktree, approvedCommit): Promise<{
  headSha: string;
}>;

Recheck approval and push only the reviewed commit, including on retries.

Parameters ​

ParameterType
worktreeWorktree
approvedCommitstring

Returns ​

Promise<{ headSha: string; }>


pushBranch() ​

ts
function pushBranch(worktree): Promise<{
  headSha: string;
}>;

Push the worktree's branch to its remote, including any newly committed changes.

Parameters ​

ParameterType
worktreeWorktree

Returns ​

Promise<{ headSha: string; }>


readBranchState() ​

ts
function readBranchState(worktree, baseSha?): Promise<{
  commits: number;
  dirty: boolean;
  headSha: string;
}>;

Check commits since the base, the branch's current commit, and uncommitted changes.

Parameters ​

ParameterType
worktreeWorktree
baseSha?string

Returns ​

Promise<{ commits: number; dirty: boolean; headSha: string; }>


readChange() ​

ts
function readChange(worktree, base?): Promise<ChangeSummary>;

Read committed file changes and subjects up to HEAD, defaulting to the worktree's base.

Parameters ​

ParameterType
worktreeWorktree
base?string

Returns ​

Promise<ChangeSummary>


readPatch() ​

ts
function readPatch(
   worktree, 
   base, 
   head, 
paths): Promise<ChangePatch>;

Read capped patches for literal named paths between the summary's commits.

Parameters ​

ParameterType
worktreeWorktree
basestring
headstring
pathsstring[]

Returns ​

Promise<ChangePatch>


readWorktreeDiff() ​

ts
function readWorktreeDiff(worktree, baseSha?): Promise<string>;

Read committed changes, defaulting to the worktree's base commit. Large diffs are truncated.

Parameters ​

ParameterType
worktreeWorktree
baseSha?string

Returns ​

Promise<string>

Agent execution ​

executeAgent() ​

ts
function executeAgent(request): Promise<
  | AgentResult
  | {
  jitFailure: object & object[];
}
  | {
  resumeFailed: string;
}>;

Execute an agent in a working directory. Use runAgent() to pass an output schema and parse its answer.

Parameters ​

ParameterType
requestAgentRequest

Returns ​

Promise< | AgentResult | { jitFailure: object & object[]; } | { resumeFailed: string; }>


executeJev() ​

ts
function executeJev<QUESTIONS>(request): Promise<JevResult<QUESTIONS>>;

Execute typed decision questions against one shared state.

Type Parameters ​

Type Parameter
QUESTIONS extends JevQuestions

Parameters ​

ParameterType
requestAskJevOptions<QUESTIONS>

Returns ​

Promise<JevResult<QUESTIONS>>


executeModel() ​

ts
function executeModel(request): Promise<ModelResult>;

Execute a model request without tools. Use askModel() to pass an output schema and parse its answer.

Parameters ​

ParameterType
requestModelRequest

Returns ​

Promise<ModelResult>

Workspaces and resources ​

createRunDirectory() ​

ts
function createRunDirectory(): Promise<string>;

Prepare this run's scratch directory, preserving it when the run resumes.

Returns ​

Promise<string>


listBindings() ​

ts
function listBindings(): Promise<RepositoryRef & object[]>;

List every binding in the factory's configuration on GitHub, with the repository it points at.

Returns ​

Promise<RepositoryRef & object[]>


provisionPullRequestWorktree() ​

ts
function provisionPullRequestWorktree(request): Promise<PullRequestWorktree>;

Check out a pull request's head commit in a worktree for this run, with no branch to push.

Parameters ​

ParameterType
requestPullRequestWorktreeRequest

Returns ​

Promise<PullRequestWorktree>


provisionWorktree() ​

ts
function provisionWorktree(request): Promise<Worktree>;

Prepare a worktree for this run, reusing it when the run resumes.

Parameters ​

ParameterType
requestWorktreeRequest

Returns ​

Promise<Worktree>


registerResource() ​

ts
function registerResource(resource): Promise<RunResource>;

Record a resource on this run independently of the workflow's return value.

Parameters ​

ParameterType
resourceRunResource

Returns ​

Promise<RunResource>

Remarks ​

Register anything a person may need to find in jigs status. Kind and identity together name the record; registering again updates its URL. Create external resources in a separate step when creation is not safe to repeat, then register them here so registration retries cannot repeat creation. The record is observation only: jigs never deletes what it names. The kinds jigs records and releases itself (worktree, branch, run-directory, codex-home, pi-home, claude-plugins) are reserved.


release() ​

ts
function release(policy?): Promise<ReleaseReport>;

Release this run's resources now and return the report. The service already does this when the run ends; call it to release early, to read the report, or to pass this run's policy.

Parameters ​

ParameterTypeDescription
policy?{ onFailure: "release" | "keep"; onSuccess: "release" | "keep"; }-
policy.onFailure?"release" | "keep"What to do with eligible resources after a failed or cancelled run.
policy.onSuccess?"release" | "keep"What to do with eligible resources after a completed run.

Returns ​

Promise<ReleaseReport>


removeRunDirectory() ​

ts
function removeRunDirectory(): Promise<void>;

Remove this run's scratch directory after its work is complete.

Returns ​

Promise<void>

Linear agent sessions ​

executeLinearAgentTurn() ​

ts
function executeLinearAgentTurn(request): Promise<TurnStepResult>;

Run one turn of a conversation in a Linear agent session, posting its status and answers there. Use linearAgentConversation() to hold the whole conversation.

Parameters ​

ParameterType
requestLinearAgentTurnRequest

Returns ​

Promise<TurnStepResult>


listLinearAgentSessionPrompts() ​

ts
function listLinearAgentSessionPrompts(session): Promise<LinearAgentPrompt[]>;

Read every message people sent into a Linear agent session, oldest first.

Parameters ​

ParameterType
session{ installationName: string; sessionId: string; }
session.installationNamestring
session.sessionIdstring

Returns ​

Promise<LinearAgentPrompt[]>


openLinearAgentSession() ​

ts
function openLinearAgentSession(request): Promise<{
  sessionId: string;
}>;

Open a Linear agent session on an issue as the factory's app, linked to this run.

Parameters ​

ParameterType
request{ installationName: string; issueId: string; }
request.installationNamestring
request.issueIdstring

Returns ​

Promise<{ sessionId: string; }>


postLinearAgentActivity() ​

ts
function postLinearAgentActivity(request): Promise<{
  createdAt: string;
  id: string;
}>;

Post a thought, action, elicitation, response or error into a Linear agent session as the factory's app.

Parameters ​

ParameterType
request{ content: LinearAgentActivityContent; ephemeral?: boolean; installationName: string; once?: string; sessionId: string; }
request.contentLinearAgentActivityContent
request.ephemeral?boolean
request.installationNamestring
request.once?string
request.sessionIdstring

Returns ​

Promise<{ createdAt: string; id: string; }>


setLinearAgentSessionUrls() ​

ts
function setLinearAgentSessionUrls(request): Promise<void>;

Replace the links a Linear agent session shows, after the run's dashboard.

Parameters ​

ParameterType
request{ installationName: string; sessionId: string; urls: object[]; }
request.installationNamestring
request.sessionIdstring
request.urlsobject[]

Returns ​

Promise<void>