# @jigs-ai/jigs v0.110.4

Factory and workflow definitions, harness and model descriptors, types and pure helpers.

Durable steps and routines come from the factory-generated `#jigs/steps` and
`#jigs/routines`.

## Example

```ts
import { defineWorkflow, harnesses } from "@jigs-ai/jigs";
import { runAgent } from "#jigs/routines";
```

## Factory and workflows

### EventTrigger

A trigger that starts one run per occurrence its source reports, at most
once per occurrence. Each run gets the reference the source hands it,
merged over the fixed `inputs`.

#### Remarks

A new trigger starts from the moment the service first runs it, with no
backfill. After the service was down, it starts runs only for occurrences
within `lookbackMinutes` and records older ones as skipped.

#### Properties

##### active

> **active**: `boolean`

An inactive trigger is not armed: its source's occurrences start no runs.

##### inputs?

> `optional` **inputs**: `Record`\<`string`, `unknown`\>

##### lookbackMinutes?

> `optional` **lookbackMinutes**: `number`

How far back to catch up after the service was down. Defaults to 60.

##### maxActive?

> `optional` **maxActive**: `number`

Runs of this trigger active at once. Defaults to 20; further occurrences wait, oldest first.

##### source

> **source**: [`SourceDescriptor`](#sourcedescriptor)

##### workflow

> **workflow**: `string`

***

### Factory

What a factory repo hands the service: its workflows, keyed by name, and
the schedules and event triggers that start them. A schedule is keyed by
its own name rather than nested under a workflow. The name is what runs,
status and `jigs doctor` refer to, and one workflow can carry several.

#### Properties

##### schedules?

> `optional` **schedules**: `Record`\<`string`, [`Schedule`](#schedule)\>

##### triggers?

> `optional` **triggers**: `Record`\<`string`, [`EventTrigger`](#eventtrigger)\>

##### workflows

> **workflows**: `Record`\<`string`, `AnyWorkflowDefinition`\>

***

### LinearDelegationInputs

The inputs a `linear.delegations` source hands each run it starts.

#### Extended by

- [`LinearMentionInputs`](#linearmentioninputs)

#### Properties

##### creator

> **creator**: `object`

The person who delegated the issue, or mentioned the app.

###### email

> **email**: `string`

###### id

> **id**: `string`

###### name

> **name**: `string`

##### installationName

> **installationName**: `string`

The Linear installation, as named on the hub, the session is in.

##### issue

> **issue**: `object`

###### id

> **id**: `string`

###### identifier

> **identifier**: `string`

###### title

> **title**: `string`

###### url

> **url**: `string`

##### promptContext

> **promptContext**: `string` \| `null`

Linear's formatted context for the session: the issue, its description and the comments
around it, or null if Linear sent none.

##### session

> **session**: `string`

The Linear agent session's id.

***

### LinearMentionInputs

The inputs a `linear.mentions` source hands each run it starts.

#### Extends

- [`LinearDelegationInputs`](#lineardelegationinputs)

#### Properties

##### comment

> **comment**: `string`

The body of the comment that mentioned the app.

##### creator

> **creator**: `object`

The person who delegated the issue, or mentioned the app.

###### email

> **email**: `string`

###### id

> **id**: `string`

###### name

> **name**: `string`

###### Inherited from

[`LinearDelegationInputs`](#lineardelegationinputs).[`creator`](#creator)

##### installationName

> **installationName**: `string`

The Linear installation, as named on the hub, the session is in.

###### Inherited from

[`LinearDelegationInputs`](#lineardelegationinputs).[`installationName`](#installationname)

##### issue

> **issue**: `object`

###### id

> **id**: `string`

###### identifier

> **identifier**: `string`

###### title

> **title**: `string`

###### url

> **url**: `string`

###### Inherited from

[`LinearDelegationInputs`](#lineardelegationinputs).[`issue`](#issue)

##### promptContext

> **promptContext**: `string` \| `null`

Linear's formatted context for the session: the issue, its description and the comments
around it, or null if Linear sent none.

###### Inherited from

[`LinearDelegationInputs`](#lineardelegationinputs).[`promptContext`](#promptcontext)

##### session

> **session**: `string`

The Linear agent session's id.

###### Inherited from

[`LinearDelegationInputs`](#lineardelegationinputs).[`session`](#session)

***

### Schedule

One recurring trigger: a workflow, when to fire it, and the inputs to
 fire it with. *

#### Properties

##### active

> **active**: `boolean`

An inactive schedule never fires.

##### cron

> **cron**: `string`

Five fields, evaluated in the service host's local time zone.

##### inputs

> **inputs**: `Record`\<`string`, `unknown`\>

##### workflow

> **workflow**: `string`

***

### SourceDescriptor

What an event trigger watches: a source kind and the provider's own query
parameters for it. Plain data, so it can sit in `jigs.config.ts`; a source's
constructor builds it.

#### Properties

##### kind

> **kind**: `string`

##### params

> **params**: `Record`\<`string`, `unknown`\>

***

### WorkflowDefinition

A workflow: its function, its input schema, and what a run needs before it
may start.

#### Type Parameters

##### S

`S` *extends* `z.ZodType` = `z.ZodType`

#### Properties

##### inputs

> **inputs**: `S`

##### release?

> `optional` **release**: `object`

###### onFailure

> **onFailure**: `"release"` \| `"keep"` = `releaseAction`

What to do with eligible resources after a failed or cancelled run.

###### onSuccess

> **onSuccess**: `"release"` \| `"keep"` = `releaseAction`

What to do with eligible resources after a completed run.

##### requires?

> `optional` **requires**: `WorkflowRequires`

What the workflow needs before a run can start: the agents it runs, the
integrations, bindings and API model sources it uses, and the names of the
environment variables its steps read as `secrets`. The service checks the
CLI of every agent's harness when it starts, and preflight checks
everything listed before every run. List only what the workflow uses.

###### Remarks

A secret is set in the factory's environment and read in a step from the
process environment. The variables an agent's MCP servers name count as secrets
without being listed. Listing a secret does not pass it to agents.

###### Example

Pass this value as `requires` when calling `defineWorkflow`.
```ts
import { harnesses, type WorkflowDefinition } from "@jigs-ai/jigs";

const agents = {
  builder: harnesses.claude({ model: "opus" }),
  reviewer: harnesses.codex({ model: "gpt-5.6-sol" }),
};

const requires = {
  agents,
  integrations: ["linear", "github"],
  bindings: ["app"],
  secrets: ["SNOWFLAKE_TOKEN"],
} satisfies WorkflowDefinition["requires"];
```

##### workflow()

> **workflow**: (`inputs`) => `Promise`\<`unknown`\>

###### Parameters

###### inputs

[`WorkflowInputs`](#workflowinputs)\<`S`\>

###### Returns

`Promise`\<`unknown`\>

***

### AgentsDefinition

> **AgentsDefinition** = `z.input`\<*typeof* `agentsSchema`\>

Settings for the agent harnesses this factory runs.

***

### BindingDefinition

> **BindingDefinition** = `z.input`\<*typeof* `bindingSchema`\>

A repository this factory works in: its remote, the GitHub installation
that reaches it, and how a worktree cut from it is provisioned.

#### Remarks

`installationName` is the name an admin gave the GitHub App installation on
the hub. Pushes, pull requests and their events go through it.

#### Example

Use this value for `bindings.api` in `jigs.config.ts`.
```ts
import type { BindingDefinition } from "@jigs-ai/jigs";

const api = {
  remote: "git@github.com:acme/api.git",
  installationName: "github-acme",
  postCreate: ["pnpm install"],
} satisfies BindingDefinition;
```

***

### FactoryDefinition

> **FactoryDefinition** = `z.input`\<*typeof* `factoryConfigSchema`\> & `object`

Operating settings and deferred workflow modules declared by a factory.

#### Type Declaration

##### workflows

> **workflows**: `Record`\<`string`, `WorkflowImport`\>

***

### GitHubDefinition

> **GitHubDefinition** = `z.input`\<*typeof* `githubSchema`\>

Who the operator is on GitHub.

#### Remarks

jigs acts on GitHub as the GitHub App the hub assigns this factory, so its pull requests come
from `<app-slug>[bot]` and the operator approves them with a review.

#### Example

Use this value for `github` in `jigs.config.ts`.
```ts
import type { GitHubDefinition } from "@jigs-ai/jigs";

const github = {
  operator: "octocat",
  coAuthor: "Octo Cat <octocat@example.com>",
} satisfies GitHubDefinition;
```

***

### GitHubIssueInputs

> **GitHubIssueInputs** = [`RepositoryRef`](#repositoryref) & `object`

The inputs a `github.issues` source hands each run it starts.

#### Type Declaration

##### number

> **number**: `number`

The repository-local issue number.

***

### GitHubIssuesParams

> **GitHubIssuesParams** = `z.input`\<*typeof* `gitHubIssuesParamsSchema`\>

Which issues a `github.issues` source starts runs for. Each list matches
any of its values; leaving one out does not filter on it.

- `installationName`: the GitHub App installation, as named on the hub,
  whose repositories it watches.
- `repositories`: `owner/repo` names, such as `acme/api`, in any case.
- `authors`: GitHub logins of who opened the issue.
- `labels`: label names; an issue with any of them matches.

***

### GitHubPullRequestsParams

> **GitHubPullRequestsParams** = `z.input`\<*typeof* `gitHubPullRequestsParamsSchema`\>

Which pull requests a `github.pullRequests` source starts runs for. Each
list matches any of its values; leaving one out does not filter on it.

- `installationName`: the GitHub App installation, as named on the hub,
  whose repositories it watches.
- `repositories`: `owner/repo` names, such as `acme/api`, in any case.
- `authors`: GitHub logins of who opened the pull request, such as
  `dependabot[bot]`.
- `labels`: label names; a pull request with any of them matches.
- `baseBranches`: the branches the pull request merges into, such as `main`.

***

### GitHubPushesParams

> **GitHubPushesParams** = `z.input`\<*typeof* `gitHubPushesParamsSchema`\>

Which pushes a `github.pushes` source starts runs for. Each list matches
any of its values; leaving one out does not filter on it.

- `installationName`: the GitHub App installation, as named on the hub,
  whose repositories it watches.
- `repositories`: `owner/repo` names, such as `acme/api`, in any case.
- `branches`: branch names, such as `main`.

***

### GitHubPushInputs

> **GitHubPushInputs** = [`RepositoryRef`](#repositoryref) & `object`

The inputs a `github.pushes` source hands each run it starts.

#### Type Declaration

##### after

> **after**: `string`

The commit the branch points at after the push.

##### before

> **before**: `string`

The commit the branch pointed at before the push, all zeros for a new branch.

##### branch

> **branch**: `string`

The branch pushed to, such as `main`.

***

### GitHubReleaseInputs

> **GitHubReleaseInputs** = [`RepositoryRef`](#repositoryref) & `object`

The inputs a `github.releases` source hands each run it starts.

#### Type Declaration

##### tag

> **tag**: `string`

The release's tag, such as `v1.2.0`.

***

### GitHubReleasesParams

> **GitHubReleasesParams** = `z.input`\<*typeof* `gitHubReleasesParamsSchema`\>

Which releases a `github.releases` source starts runs for.

- `installationName`: the GitHub App installation, as named on the hub,
  whose repositories it watches.
- `repositories`: `owner/repo` names, such as `acme/api`, in any case;
  leaving it out watches them all.

***

### HarnessesDefinition

> **HarnessesDefinition** = `z.input`\<*typeof* `harnessesSchema`\>

Factory-wide defaults for the harnesses this factory's workflows build.

#### Remarks

`claude.credential` is how every Claude harness that sets no `credential` of its own pays for
its calls. Leave it out for the claude.ai subscription login. Workflow code cannot read the
environment, but `jigs.config.ts` can, so each copy can choose its own: the subscription login
on a laptop and an API key on a server, from the same workflows. The service reads it when it
starts.

#### Example

Use this value for `harnesses` in `jigs.config.ts`.
```ts
import type { HarnessesDefinition } from "@jigs-ai/jigs";

const harnesses = {
  claude: { credential: process.env.ANTHROPIC_API_KEY ? { kind: "api-key" } : undefined },
} satisfies HarnessesDefinition;
```

***

### LinearAgentSessionsParams

> **LinearAgentSessionsParams** = `z.input`\<*typeof* `linearAgentSessionsParamsSchema`\>

Which Linear agent sessions a `linear.delegations` or `linear.mentions`
source starts runs for. Each list matches any of its values; leaving one out
does not filter on it.

- `installationName`: the Linear installation, as named on the hub, whose
  sessions it watches.
- `teams`: team keys, such as `ENG`, or team ids.
- `projects`: project ids, or the id at the end of a project's URL.
- `labels`: label names, as Linear shows them.
- `creators`: emails of the people who delegated the issue or mentioned the
  app, in any case.

***

### LinearDefinition

> **LinearDefinition** = `z.input`\<*typeof* `linearSchema`\>

Who a ticket run's Linear questions and notes mention.

#### Remarks

`operator` is the email of the Linear user who runs the factory. With it,
every question and note a ticket run posts mentions the operator and the
ticket's assignee; without it, the ticket's creator and assignee.
`jigs doctor` fails when no Linear user has the email. Steps read it from
the built factory, so a change takes effect after a rebuild, which
`jigs up` does.

#### Example

Use this value for `linear` in `jigs.config.ts`.
```ts
import type { LinearDefinition } from "@jigs-ai/jigs";

const linear = {
  operator: "salim@example.com",
} satisfies LinearDefinition;
```

***

### PagerDutyIncidentsParams

> **PagerDutyIncidentsParams** = `z.input`\<*typeof* `pagerDutyIncidentsParamsSchema`\>

Which incidents a `pagerduty.incidents` source starts runs for. Each list
matches any of its values; leaving one out does not filter on it.

- `installationName`: the PagerDuty installation, as named on the hub,
  whose incidents it watches.
- `services`: PagerDuty service IDs, such as `P48FPG2`.
- `teams`: PagerDuty team IDs.
- `urgencies`: `high`, `low` or both.

***

### TicketWorkflowInputs

> **TicketWorkflowInputs**\<`S`\> = [`WorkflowInputs`](#workflowinputs)\<`S`\>

Ticket references are ordinary inputs; resolve them explicitly in a step.

#### Type Parameters

##### S

`S` *extends* `z.ZodType`\<\{ `ticket`: `string`; \}\>

***

### WorkflowInputs

> **WorkflowInputs**\<`S`\> = `z.output`\<`S`\> & `Injected`

Parsed workflow inputs with the trigger that started the run.

#### Type Parameters

##### S

`S` *extends* `z.ZodType`

***

### github

> `const` **github**: `object`

Event-trigger sources on GitHub.

#### Type Declaration

##### issues()

> `readonly` **issues**(`params`): [`SourceDescriptor`](#sourcedescriptor)

Start a run for each issue, with [GitHubIssueInputs](#githubissueinputs) as its inputs.
An issue starts at most one run, ever: the first time any of its events
shows it open and matching the filters, such as when it is opened or
labeled. An issue reopened after its run ended starts no new one; rerun
it with `jigs run`.

###### Parameters

###### params

###### authors?

`string`[] = `...`

###### installationName

`string` = `installationNameSchema`

###### labels?

`string`[] = `...`

###### repositories?

`string`[] = `...`

###### Returns

[`SourceDescriptor`](#sourcedescriptor)

###### Remarks

The GitHub App must subscribe to the **Issues** event. Events the
factory's own GitHub App caused start no run, so an issue the App opens
starts one only once a person acts on it, such as by adding a label the
trigger filters on.

###### Example

```ts
import { github } from "@jigs-ai/jigs";

const source = github.issues({
  installationName: "github-acme",
  repositories: ["acme/api"],
  labels: ["agent"],
});
```

##### pullRequests()

> `readonly` **pullRequests**(`params`): [`SourceDescriptor`](#sourcedescriptor)

Start a run for each pull request, with its [PullRequestRef](#pullrequestref) as
the inputs. A pull request starts at most one run, ever: the first time
any of its events shows it open, not a draft and matching the filters,
such as when it is opened, labeled or marked ready for review. A pull
request reopened after its run ended starts no new one; rerun it with
`jigs run`.

###### Parameters

###### params

###### authors?

`string`[] = `...`

###### baseBranches?

`string`[] = `...`

###### installationName

`string` = `installationNameSchema`

###### labels?

`string`[] = `...`

###### repositories?

`string`[] = `...`

###### Returns

[`SourceDescriptor`](#sourcedescriptor)

###### Remarks

Events the factory's own GitHub App caused start no run, so a pull
request the App opens starts one only once a person acts on it, such as
by adding a label the trigger filters on.

###### Example

```ts
import { github } from "@jigs-ai/jigs";

const source = github.pullRequests({
  installationName: "github-acme",
  repositories: ["acme/api"],
  authors: ["dependabot[bot]"],
});
```

##### pushes()

> `readonly` **pushes**(`params`): [`SourceDescriptor`](#sourcedescriptor)

Start a run for each push to a branch, with [GitHubPushInputs](#githubpushinputs) as
its inputs. Each push starts at most one run, ever. Tag pushes and
branch deletions start none. A push the factory's own GitHub App made,
such as merging a person's pull request, starts runs like any other.

###### Parameters

###### params

###### branches?

`string`[] = `...`

###### installationName

`string` = `installationNameSchema`

###### repositories?

`string`[] = `...`

###### Returns

[`SourceDescriptor`](#sourcedescriptor)

###### Remarks

The GitHub App must subscribe to the **Push** event.

###### Example

```ts
import { github } from "@jigs-ai/jigs";

const source = github.pushes({
  installationName: "github-acme",
  repositories: ["acme/api"],
  branches: ["main"],
});
```

##### releases()

> `readonly` **releases**(`params`): [`SourceDescriptor`](#sourcedescriptor)

Start a run for each published release, with [GitHubReleaseInputs](#githubreleaseinputs)
as its inputs. A release starts at most one run, ever, once it is
published and not a prerelease: a prerelease starts its run when it
becomes a release. Drafts start none.

###### Parameters

###### params

###### installationName

`string` = `installationNameSchema`

###### repositories?

`string`[] = `...`

###### Returns

[`SourceDescriptor`](#sourcedescriptor)

###### Remarks

The GitHub App must subscribe to the **Release** event and needs
**Contents: read**.

###### Example

```ts
import { github } from "@jigs-ai/jigs";

const source = github.releases({
  installationName: "github-acme",
  repositories: ["acme/api"],
});
```

***

### installationNameSchema

> `const` **installationNameSchema**: `ZodString`

An installation's name, as an admin set it on the hub: lowercase letters, digits and hyphens,
starting with a letter. Use it for a workflow input that names an installation.

***

### linear

> `const` **linear**: `object`

Event-trigger sources on Linear.

#### Type Declaration

##### delegations()

> `readonly` **delegations**(`params`): [`SourceDescriptor`](#sourcedescriptor)

Start a run whenever someone delegates an issue to the factory's Linear
app, with [LinearDelegationInputs](#lineardelegationinputs) as its inputs.

###### Parameters

###### params

###### creators?

`string`[] = `...`

###### installationName

`string` = `installationNameSchema`

###### labels?

`string`[] = `...`

###### projects?

`string`[] = `...`

###### teams?

`string`[] = `...`

###### Returns

[`SourceDescriptor`](#sourcedescriptor)

###### Example

```ts
import { linear } from "@jigs-ai/jigs";

const source = linear.delegations({ installationName: "acme", teams: ["ENG"] });
```

##### mentions()

> `readonly` **mentions**(`params`): [`SourceDescriptor`](#sourcedescriptor)

Start a run whenever someone mentions the factory's Linear app in a
comment on an issue, with [LinearMentionInputs](#linearmentioninputs) as its inputs.

###### Parameters

###### params

###### creators?

`string`[] = `...`

###### installationName

`string` = `installationNameSchema`

###### labels?

`string`[] = `...`

###### projects?

`string`[] = `...`

###### teams?

`string`[] = `...`

###### Returns

[`SourceDescriptor`](#sourcedescriptor)

###### Example

```ts
import { linear } from "@jigs-ai/jigs";

const source = linear.mentions({ installationName: "acme", labels: ["agent"] });
```

#### Remarks

Delegating an issue to the factory's Linear app, or mentioning the app in a
comment, opens a Linear agent session. Each session starts at most one run
per trigger, ever. The hub posts the session's first reply, so Linear shows
the app at work while the run starts. That reply appears even when no
trigger matches, so make the filters match what the app is for. Every
factory assigned the app hears every session, and each matching trigger
starts its own run. Sessions not on an issue, and sessions the app opened
itself, start no run.

***

### pagerduty

> `const` **pagerduty**: `object`

Event-trigger sources on PagerDuty.

#### Type Declaration

##### incidents()

> `readonly` **incidents**(`params`): [`SourceDescriptor`](#sourcedescriptor)

Watch for new incidents. Every new incident starts at most one run, ever,
with `{ installationName, incident: "<id>" }` as its inputs, even one acknowledged or
resolved before the service saw it; the workflow can check the status and
skip one that is already handled. The run starts as soon as the hub
passes on PagerDuty's `incident.triggered` event.

###### Parameters

###### params

###### installationName

`string` = `installationNameSchema`

###### services?

`string`[] = `...`

###### teams?

`string`[] = `...`

###### urgencies?

(`"low"` \| `"high"`)[] = `...`

###### Returns

[`SourceDescriptor`](#sourcedescriptor)

###### Example

```ts
import { pagerduty } from "@jigs-ai/jigs";

const source = pagerduty.incidents({
  installationName: "acme",
  services: ["P48FPG2"],
  urgencies: ["high"],
});
```

***

### slack

> `const` **slack**: `object`

Event-trigger sources for Slack, one per trigger in `jigs.config.ts`.

#### Type Declaration

##### mentions()

> **mentions**: (`__namedParameters`) => [`SourceDescriptor`](#sourcedescriptor)

Only the top-level messages that mention the factory's bot.

###### Parameters

###### \_\_namedParameters

###### channels

`string`[]

###### installationName

`string`

###### Returns

[`SourceDescriptor`](#sourcedescriptor)

##### messages()

> **messages**: (`__namedParameters`) => [`SourceDescriptor`](#sourcedescriptor)

Every top-level message in the channels.

###### Parameters

###### \_\_namedParameters

###### channels

`string`[]

###### installationName

`string`

###### Returns

[`SourceDescriptor`](#sourcedescriptor)

#### Remarks

Both read top-level messages in the listed channels of one Slack
installation, named as on the hub, whose bot must be a member of them, and
start one run per message with the inputs `{ installationName, channel, ts }`. Posts from people, other bots and apps count, including
posts with files. The factory's own posts never count, and neither do
thread replies, edits, deletes, joins or other channel events. Direct
messages are never read. Channels are listed by ID, such as `C0123ABCD`,
not by name.

#### Example

Start a run for every message that mentions the bot in one channel.
```ts
import { slack } from "@jigs-ai/jigs";

const triggers = {
  "answer-questions": {
    active: process.env.ANSWER_QUESTIONS_ACTIVE === "true",
    workflow: "answer",
    source: slack.mentions({ installationName: "acme", channels: ["C0123ABCD"] }),
  },
};
```

***

### ticketInputSchema

> `const` **ticketInputSchema**: `ZodUnion`\<readonly \[`ZodUUID`, `ZodString`\]\>

Accept a Linear issue UUID or an uppercase team-and-number ticket identifier.

***

### defineFactory()

> **defineFactory**\<`T`\>(`factory`): `T`

Check the declaration against what jigs accepts and preserve its inferred keys, without loading
its workflows.

#### Type Parameters

##### T

`T` *extends* [`FactoryDefinition`](#factorydefinition)

#### Parameters

##### factory

`T` & `Record`\<`Exclude`\<keyof `T`, `"github"` \| `"linear"` \| `"hub"` \| `"agents"` \| `"release"` \| `"bindings"` \| `"deployments"` \| `"harnesses"` \| `"workflows"` \| `"schedules"` \| `"triggers"`\>, `never`\>

#### Returns

`T`

***

### defineWorkflow()

> **defineWorkflow**\<`S`\>(`definition`): [`WorkflowDefinition`](#workflowdefinition)\<`S`\>

Declare a workflow as the default export of its file. It returns the
definition unchanged; it exists so TypeScript checks the workflow's
parameter against the input schema.

#### Type Parameters

##### S

`S` *extends* `ZodType`\<`unknown`, `unknown`, `$ZodTypeInternals`\<`unknown`, `unknown`\>\>

#### Parameters

##### definition

[`WorkflowDefinition`](#workflowdefinition)\<`S`\>

#### Returns

[`WorkflowDefinition`](#workflowdefinition)\<`S`\>

#### Example

```ts
import { defineWorkflow, type WorkflowInputs } from "@jigs-ai/jigs";
import { z } from "zod";

const inputs = z.object({ name: z.string() });

export async function hello(input: WorkflowInputs<typeof inputs>) {
  "use workflow";
  return `Hello, ${input.name}!`;
}

export default defineWorkflow({ inputs, workflow: hello });
```

## Harnesses and models

### AgentInstallation

> **AgentInstallation** = `object`

Names the installation, as an admin named it on the hub, an agent acts through.

#### Remarks

On `github`, the agent gets a fresh token of that GitHub App installation in `GH_TOKEN`, so
`gh` works as the App's bot, and git reaches the installation account's repositories over
HTTPS with that token. Its commits are authored by the bot, while your own git configuration
stays the committer and signer. On `linear`, the workspace's token goes in
`JIGS_LINEAR_TOKEN`; on `pagerduty`, the account's token goes in `JIGS_PAGERDUTY_TOKEN`.

#### Example

```ts
import { harnesses } from "@jigs-ai/jigs";

const builder = harnesses.codex({
  model: "gpt-5.6-sol",
  github: { installationName: "github-acme" },
});
```

#### Properties

##### installationName

> **installationName**: `string`

***

### AskableHarness

> **AskableHarness** = [`ClaudeHarness`](#claudeharness) & [`ToolFree`](#toolfree) \| [`PiHarness`](#piharness) & [`ToolFree`](#toolfree)

A harness `askAgent` can run with no tools: Claude Code or Pi, without MCP
servers, provider access or a Pi tool allowlist. Codex has no mode without tools.

***

### AskableModelSource

> **AskableModelSource** = `Exclude`\<[`ModelSource`](#modelsource), [`OpenaiCodexSource`](#openaicodexsource)\>

A model source accepted by a direct model call.

***

### ClaudeApiKeyCredential

> **ClaudeApiKeyCredential** = `object`

Claude Code pays for its calls with an Anthropic API key, read from `apiKeyEnv` in the
factory's environment, or `ANTHROPIC_API_KEY` when that is left out.

#### Properties

##### apiKeyEnv?

> `optional` **apiKeyEnv**: `string`

##### kind

> **kind**: `"api-key"`

***

### ClaudeBedrockCredential

> **ClaudeBedrockCredential** = `object`

Claude Code calls its models through Amazon Bedrock, with the AWS credentials and region the
factory's environment holds: static keys, a profile, or the credentials an ECS task, a Fargate
task or an EKS pod is given.

#### Properties

##### kind

> **kind**: `"bedrock"`

***

### ClaudeCredential

> **ClaudeCredential** = [`ClaudeApiKeyCredential`](#claudeapikeycredential) \| [`ClaudeBedrockCredential`](#claudebedrockcredential)

How Claude Code pays for its calls when not through a claude.ai subscription login.

#### Remarks

A harness without one uses the factory's default, `harnesses.claude.credential` in
`jigs.config.ts`, and without that the account `claude auth login` signed in. Set the default
there to choose per copy from its environment, since workflow code cannot read it. Workflow
code never holds a key: `api-key` names the variable the step reads when the agent starts, and
`bedrock` passes the AWS variables the service has through to the agent.

#### Example

```ts
import { harnesses } from "@jigs-ai/jigs";

const hosted = harnesses.claude({ model: "opus", credential: { kind: "api-key" } });
const onAws = harnesses.claude({ model: "opus", credential: { kind: "bedrock" } });
```

***

### ClaudeHarness

> **ClaudeHarness** = [`JsonOnly`](#jsononly)\<`Omit`\<`ClaudeAgentOptions`, [`ClaudePolicyKey`](#claudepolicykey)\>\> & [`HarnessSkills`](#harnessskills) & `object`

A Claude Code harness descriptor: the Claude Agent SDK's own options that are data, minus each
[ClaudePolicyKey](#claudepolicykey), plus the model, jigs' MCP server shape, [HarnessSkills](#harnessskills) and an
optional [ClaudeCredential](#claudecredential).

#### Type Declaration

##### credential?

> `optional` **credential**: [`ClaudeCredential`](#claudecredential)

An API key or Bedrock; left out, the factory's default or the subscription login.

##### github?

> `optional` **github**: [`AgentInstallation`](#agentinstallation)

Acts on GitHub as the factory's App, through this installation.

##### kind

> **kind**: `"claude"`

##### linear?

> `optional` **linear**: [`AgentInstallation`](#agentinstallation)

Acts on Linear as the factory's app, through this installation.

##### mcpServers?

> `optional` **mcpServers**: `Record`\<`string`, [`McpServerConfig`](#mcpserverconfig)\>

##### model

> **model**: `string`

##### pagerduty?

> `optional` **pagerduty**: [`AgentInstallation`](#agentinstallation)

Acts on PagerDuty as the factory's app, through this installation.

***

### ClaudeHarnessSettings

> **ClaudeHarnessSettings** = `Omit`\<[`ClaudeHarness`](#claudeharness), `"kind"`\>

The one argument `harnesses.claude` takes: the model and any Claude Code settings.

***

### ClaudePolicyKey

> **ClaudePolicyKey** = *typeof* `claudePolicyKeys`\[`number`\]

A Claude Code option a descriptor cannot name, because jigs sets it itself or holds it as
policy.

#### Remarks

jigs sets the working directory, environment, executable, session and output format for every
step, and holds permissions, setting sources and MCP servers as policy. `extraArgs` would
rewrite any of those. `agents`, `settings`, `plugins` and `projectConfigRoot` would bring in
unprobed MCP servers, environment, permissions and hooks from outside the worktree; they come
from the repository's project settings instead. jigs fills `plugins` itself to load the
descriptor's `skills`, which replace Claude Code's own `skills` option.

***

### CodexHarness

> **CodexHarness** = [`JsonOnly`](#jsononly)\<`Omit`\<`CodexAppServerSettings`, [`CodexPolicyKey`](#codexpolicykey)\>\> & [`HarnessSkills`](#harnessskills) & `object`

A Codex harness descriptor: the provider's own settings that are data, minus each
[CodexPolicyKey](#codexpolicykey), plus the model, jigs' MCP server shape and [HarnessSkills](#harnessskills).

#### Type Declaration

##### github?

> `optional` **github**: [`AgentInstallation`](#agentinstallation)

Acts on GitHub as the factory's App, through this installation.

##### kind

> **kind**: `"codex"`

##### linear?

> `optional` **linear**: [`AgentInstallation`](#agentinstallation)

Acts on Linear as the factory's app, through this installation.

##### mcpServers?

> `optional` **mcpServers**: `Record`\<`string`, [`McpServerConfig`](#mcpserverconfig)\>

##### model

> **model**: `string`

##### pagerduty?

> `optional` **pagerduty**: [`AgentInstallation`](#agentinstallation)

Acts on PagerDuty as the factory's app, through this installation.

***

### CodexHarnessSettings

> **CodexHarnessSettings** = `Omit`\<[`CodexHarness`](#codexharness), `"kind"`\>

The one argument `harnesses.codex` takes: the model and any Codex settings.

***

### CodexPolicyKey

> **CodexPolicyKey** = *typeof* `codexPolicyKeys`\[`number`\]

A Codex setting a descriptor cannot name, because jigs sets it itself or holds it as policy.

#### Remarks

jigs sets the working directory, environment, executable, thread and session for every step,
and holds the approval and sandbox policies and MCP servers. `configOverrides` would rewrite
the sandbox and MCP tables.

***

### GithubMcpOptions

> **GithubMcpOptions** = `object`

Options for [githubMcp](#githubmcp) on a Pi harness.

#### Properties

##### tools

> **tools**: `string`[]

Raw MCP tool names the model may call. jigs adds the probe tool, `search_repositories`.

***

### Harness

> **Harness** = [`ClaudeHarness`](#claudeharness) \| [`CodexHarness`](#codexharness) \| [`PiHarness`](#piharness)

A serializable agent-program descriptor.

***

### HarnessForOptions

> **HarnessForOptions**\<`H`, `O`\> = \[`Extract`\<keyof `O`, keyof [`ToolFree`](#toolfree)\>\] *extends* \[`never`\] ? `H` & [`ToolFree`](#toolfree) : `H`

The descriptor a harness constructor returns for its options. It is also
[ToolFree](#toolfree), so `askAgent` accepts it, when the options name no tools,
MCP servers or provider access.

#### Type Parameters

##### H

`H`

##### O

`O`

***

### HarnessKind

> **HarnessKind** = [`Harness`](#harness-3)\[`"kind"`\]

The stable name of an agent harness.

***

### HarnessSkills

> **HarnessSkills** = `object`

Skill folders an agent loads, each holding a `SKILL.md` and any files it refers to.

#### Remarks

Each path is relative to the factory root, or absolute. jigs copies every folder into a private
place for each agent call, so the skills reach the agent whatever its working directory and
nothing the agent changes there reaches the factory. Each folder is copied under its own name,
so two folders cannot share one; keep it the same as the `name` in its `SKILL.md`. A run whose
folder is missing or has no `SKILL.md` fails its checks before the agent starts. Skills apply
when an agent runs in a directory, not to `askAgent`.

#### Properties

##### skills?

> `optional` **skills**: `string`[]

***

### JsonOnly

> **JsonOnly**\<`T`\> = `{ [K in keyof T as false extends IsData<Exclude<T[K], undefined>> ? never : K]: T[K] }`

The keys of a settings type whose values are data, so they can cross into a step.

#### Type Parameters

##### T

`T`

***

### LinearMcpOptions

> **LinearMcpOptions** = `object`

Options for [linearMcp](#linearmcp) on a Pi harness.

#### Properties

##### tools

> **tools**: `string`[]

Raw MCP tool names the model may call. jigs adds the probe tool, `list_teams`.

***

### McpHttpServerConfig

> **McpHttpServerConfig** = `object`

Configuration for an MCP server reached over HTTP.

#### Remarks

Credentials never appear in workflow code: each `headers` value and `bearerTokenEnv` name an
environment variable of the service, read when the step starts the agent. A step whose named
variable is not set fails before the agent starts.

#### Properties

##### bearerTokenEnv?

> `optional` **bearerTokenEnv**: `string`

Names the service variable holding a token sent as `Authorization: Bearer <token>`.

##### disabledTools?

> `optional` **disabledTools**: `string`[]

Raw MCP tool names the model may not call. Pi takes its `tools` allowlist instead.

##### headers?

> `optional` **headers**: `Record`\<`string`, `string`\>

Maps HTTP header names to the names of the service variables holding their values.

##### probe

> **probe**: [`McpToolProbe`](#mcptoolprobe)

##### url

> **url**: `string`

***

### McpServerConfig

> **McpServerConfig** = [`McpStdioServerConfig`](#mcpstdioserverconfig) \| [`McpHttpServerConfig`](#mcphttpserverconfig)

An MCP server an agent harness can expose to the model.

***

### McpStdioServerConfig

> **McpStdioServerConfig** = `object`

Configuration for an MCP server launched as a child process.

#### Remarks

Credentials never appear in workflow code: each `env` value names an environment variable of
the service, read when the step starts the agent. A step whose named variable is not set fails
before the agent starts.

#### Example

```ts
import { harnesses } from "@jigs-ai/jigs";

// The server reads BRAVE_API_KEY; its value comes from the service's SEARCH_API_KEY.
const researcher = harnesses.claude({
  model: "opus",
  mcpServers: {
    search: {
      command: "npx",
      args: ["-y", "@brave/brave-search-mcp-server"],
      env: { BRAVE_API_KEY: "SEARCH_API_KEY" },
      probe: { tool: "brave_web_search", arguments: { query: "jigs", count: 1 } },
    },
  },
});
```

#### Properties

##### args?

> `optional` **args**: `string`[]

##### command

> **command**: `string`

##### disabledTools?

> `optional` **disabledTools**: `string`[]

Raw MCP tool names the model may not call. Pi takes its `tools` allowlist instead.

##### env?

> `optional` **env**: `Record`\<`string`, `string`\>

Maps the server's variable names to the names of the service variables holding their values.

##### probe

> **probe**: [`McpToolProbe`](#mcptoolprobe)

***

### McpToolProbe

> **McpToolProbe** = `object`

A harmless MCP tool call used to prove that a configured server is available.

#### Properties

##### arguments?

> `optional` **arguments**: `Record`\<`string`, `unknown`\>

##### tool

> **tool**: `string`

***

### ModelKind

> **ModelKind** = [`ModelSource`](#modelsource)\[`"kind"`\]

The stable name of a model source.

***

### ModelSource

> **ModelSource** = [`OpenrouterSource`](#openroutersource) \| [`OpenaiCompatibleSource`](#openaicompatiblesource) \| [`OpenaiCodexSource`](#openaicodexsource)

Any configured source from which a model can answer.

***

### OpenaiCodexSource

> **OpenaiCodexSource** = `object`

The Codex subscription model source used only by the Pi harness.

#### Properties

##### kind

> **kind**: `"openai-codex"`

##### model

> **model**: `string`

***

### OpenaiCompatibleSource

> **OpenaiCompatibleSource** = `object`

An OpenAI-compatible API model source.

#### Properties

##### apiKeyEnv?

> `optional` **apiKeyEnv**: `string`

##### baseUrl

> **baseUrl**: `string`

##### kind

> **kind**: `"openai-compatible"`

##### model

> **model**: `string`

##### name

> **name**: `string`

***

### OpenrouterSource

> **OpenrouterSource** = `object`

An OpenRouter API model source.

#### Properties

##### apiKeyEnv

> **apiKeyEnv**: `string`

##### kind

> **kind**: `"openrouter"`

##### model

> **model**: `string`

***

### PagerdutyMcpOptions

> **PagerdutyMcpOptions** = `object`

Options for [pagerdutyMcp](#pagerdutymcp) on a Pi harness.

#### Properties

##### tools

> **tools**: `string`[]

Raw MCP tool names the model may call. jigs adds the probe tool, `list_incidents`.

***

### PiHarness

> **PiHarness** = [`PiOpenaiCompatibleHarness`](#piopenaicompatibleharness) \| [`PiOtherHarness`](#piotherharness)

A Pi harness descriptor backed by a nested model source.

***

### PiHarnessOptions

> **PiHarnessOptions** = `Pick`\<[`PiHarness`](#piharness), `"thinking"` \| `"tools"` \| `"mcpServers"` \| `"github"` \| `"linear"` \| `"pagerduty"` \| `"skills"`\> & `object`

Options for `harnesses.pi`. `compat` applies only to an OpenAI-compatible
model source.

#### Type Declaration

##### compat?

> `optional` **compat**: `Partial`\<[`PiOpenaiCompatibleOptions`](#piopenaicompatibleoptions)\>

***

### PiMcpHttpServerConfig

> **PiMcpHttpServerConfig** = `Omit`\<[`McpHttpServerConfig`](#mcphttpserverconfig), `"bearerTokenEnv"` \| `"disabledTools"`\> & `object` & \{ `auth`: `"oauth"`; `bearerTokenEnv?`: `never`; \} \| \{ `auth?`: `false`; `bearerTokenEnv?`: `never`; \} \| \{ `auth?`: `never`; `bearerTokenEnv`: `string`; \}

An HTTP MCP server Pi exposes through an explicit direct-tool allowlist.

#### Type Declaration

##### tools

> **tools**: `string`[]

Raw MCP tool names the model may call. This must include the probe tool.

***

### PiMcpServerConfig

> **PiMcpServerConfig** = [`PiMcpStdioServerConfig`](#pimcpstdioserverconfig) \| [`PiMcpHttpServerConfig`](#pimcphttpserverconfig)

An explicitly configured MCP server accepted by the Pi harness.

***

### PiMcpStdioServerConfig

> **PiMcpStdioServerConfig** = `Omit`\<[`McpStdioServerConfig`](#mcpstdioserverconfig), `"disabledTools"`\> & `object`

A stdio MCP server Pi exposes through an explicit direct-tool allowlist.

#### Type Declaration

##### tools

> **tools**: `string`[]

Raw MCP tool names the model may call. This must include the probe tool.

***

### PiOpenaiCompatibleHarness

> **PiOpenaiCompatibleHarness** = `SharedPiHarness` & `object`

A Pi harness descriptor backed by an OpenAI-compatible source, with its compatibility hints.

#### Type Declaration

##### compat

> **compat**: [`PiOpenaiCompatibleOptions`](#piopenaicompatibleoptions)

##### model

> **model**: [`OpenaiCompatibleSource`](#openaicompatiblesource)

***

### PiOpenaiCompatibleOptions

> **PiOpenaiCompatibleOptions** = `object`

Pi-specific compatibility hints for an OpenAI-compatible model.

#### Properties

##### supportsDeveloperRole

> **supportsDeveloperRole**: `boolean`

##### supportsReasoningEffort

> **supportsReasoningEffort**: `boolean`

***

### PiOtherHarness

> **PiOtherHarness** = `SharedPiHarness` & `object`

A Pi harness descriptor backed by any source other than an OpenAI-compatible one.

#### Type Declaration

##### compat?

> `optional` **compat**: `never`

##### model

> **model**: `Exclude`\<[`ModelSource`](#modelsource), [`OpenaiCompatibleSource`](#openaicompatiblesource)\>

***

### ToolFree

> **ToolFree** = `object`

Marks a descriptor that names no tools, MCP servers or provider access.

#### Properties

##### github?

> `optional` **github**: `never`

##### linear?

> `optional` **linear**: `never`

##### mcpServers?

> `optional` **mcpServers**: `never`

##### pagerduty?

> `optional` **pagerduty**: `never`

##### tools?

> `optional` **tools**: `never`

***

### harnesses

> `const` **harnesses**: `object`

Constructors for agent-harness descriptors.

#### Type Declaration

##### claude()

> `readonly` **claude**: \<`O`\>(`settings`) => [`HarnessForOptions`](#harnessforoptions)\<[`ClaudeHarness`](#claudeharness), `O`\> = `claudeHarness`

Build a Claude Code harness from the model and any Claude Code settings. Without `tools` or
`mcpServers` it also works with `askAgent`. A `credential` the drivers cannot forward throws
here, when the workflow module loads.

###### Type Parameters

###### O

`O` *extends* [`ClaudeHarnessSettings`](#claudeharnesssettings)

###### Parameters

###### settings

`Exactly`\<[`ClaudeHarnessSettings`](#claudeharnesssettings), `O`\>

###### Returns

[`HarnessForOptions`](#harnessforoptions)\<[`ClaudeHarness`](#claudeharness), `O`\>

###### Examples

```ts
import { harnesses } from "@jigs-ai/jigs";

const builder = harnesses.claude({ model: "opus", effort: "high", maxTurns: 40 });
```

`credential` pays with an Anthropic API key or through Amazon Bedrock instead of the
subscription login.
```ts
import { harnesses } from "@jigs-ai/jigs";

const hosted = harnesses.claude({ model: "opus", credential: { kind: "api-key" } });
```

`skills` names skill folders relative to the factory root. On Claude Code they join the
repository's own `.claude/skills` under the `jigs-skills:` prefix.
```ts
import { harnesses } from "@jigs-ai/jigs";

const analyst = harnesses.claude({ model: "opus", skills: ["skills/snowflake"] });
```

##### codex()

> `readonly` **codex**: \<`O`\>(`settings`) => [`CodexHarness`](#codexharness) = `codexHarness`

Build a Codex harness from the model and any Codex settings. Only `runAgent` accepts it: Codex
has no mode without tools.

###### Type Parameters

###### O

`O` *extends* [`CodexHarnessSettings`](#codexharnesssettings)

###### Parameters

###### settings

`Exactly`\<[`CodexHarnessSettings`](#codexharnesssettings), `O`\>

###### Returns

[`CodexHarness`](#codexharness)

###### Example

```ts
import { harnesses } from "@jigs-ai/jigs";

const builder = harnesses.codex({ model: "gpt-5.6-sol", personality: "pragmatic" });
```

##### pi()

> `readonly` **pi**: \{\<`O`\>(`model`, `options?`): [`HarnessForOptions`](#harnessforoptions)\<[`PiOpenaiCompatibleHarness`](#piopenaicompatibleharness), `O`\>; \<`O`\>(`model`, `options?`): [`HarnessForOptions`](#harnessforoptions)\<[`PiOtherHarness`](#piotherharness), `O`\>; \<`M`, `O`\>(`model`, `options?`): [`HarnessForOptions`](#harnessforoptions)\<[`PiHarness`](#piharness), `O`\>; \} = `piHarness`

###### Call Signature

> \<`O`\>(`model`, `options?`): [`HarnessForOptions`](#harnessforoptions)\<[`PiOpenaiCompatibleHarness`](#piopenaicompatibleharness), `O`\>

Build a Pi harness around a model source. `compat` applies only to an
OpenAI-compatible source; each hint omitted from it defaults to `false`.
Without `tools` or `mcpServers` the harness also works with `askAgent`. An
MCP server Pi cannot run throws here, when the workflow module loads.

###### Type Parameters

###### O

`O` *extends* [`PiHarnessOptions`](#piharnessoptions) = `Record`\<`never`, `never`\>

###### Parameters

###### model

[`OpenaiCompatibleSource`](#openaicompatiblesource)

###### options?

`O`

###### Returns

[`HarnessForOptions`](#harnessforoptions)\<[`PiOpenaiCompatibleHarness`](#piopenaicompatibleharness), `O`\>

###### Call Signature

> \<`O`\>(`model`, `options?`): [`HarnessForOptions`](#harnessforoptions)\<[`PiOtherHarness`](#piotherharness), `O`\>

Build a Pi harness around a model source. `compat` applies only to an
OpenAI-compatible source; each hint omitted from it defaults to `false`.
Without `tools` or `mcpServers` the harness also works with `askAgent`. An
MCP server Pi cannot run throws here, when the workflow module loads.

###### Type Parameters

###### O

`O` *extends* `Omit`\<[`PiHarnessOptions`](#piharnessoptions), `"compat"`\> = `Record`\<`never`, `never`\>

###### Parameters

###### model

[`OpenrouterSource`](#openroutersource) | [`OpenaiCodexSource`](#openaicodexsource)

###### options?

`O`

###### Returns

[`HarnessForOptions`](#harnessforoptions)\<[`PiOtherHarness`](#piotherharness), `O`\>

###### Call Signature

> \<`M`, `O`\>(`model`, `options?`): [`HarnessForOptions`](#harnessforoptions)\<[`PiHarness`](#piharness), `O`\>

Build a Pi harness around a model source. `compat` applies only to an
OpenAI-compatible source; each hint omitted from it defaults to `false`.
Without `tools` or `mcpServers` the harness also works with `askAgent`. An
MCP server Pi cannot run throws here, when the workflow module loads.

###### Type Parameters

###### M

`M` *extends* [`ModelSource`](#modelsource)

###### O

`O` *extends* `Omit`\<[`PiHarnessOptions`](#piharnessoptions), `"compat"`\> & `object` = `Record`\<`never`, `never`\>

###### Parameters

###### model

`M`

###### options?

`O`

###### Returns

[`HarnessForOptions`](#harnessforoptions)\<[`PiHarness`](#piharness), `O`\>

***

### harnessKinds

> `const` **harnessKinds**: \[`"claude"` \| `"codex"` \| `"pi"`, ...("claude" \| "codex" \| "pi")\[\]\]

Every harness kind this release of jigs can build, taken from the keys of
`harnesses`. Use it for a workflow input that names a harness, so a new kind
appears without editing the input.

#### Example

```ts
import { harnessKinds } from "@jigs-ai/jigs";
import { z } from "zod";

const inputs = z.object({ harness: z.enum(harnessKinds) });
```

***

### models

> `const` **models**: `object`

Constructors for model-source descriptors.

#### Type Declaration

##### openaiCodex()

> `readonly` **openaiCodex**(`model`): [`OpenaiCodexSource`](#openaicodexsource)

Build a source that runs through the Codex subscription Pi is logged in
to. Only `harnesses.pi` accepts it.

###### Parameters

###### model

`string`

###### Returns

[`OpenaiCodexSource`](#openaicodexsource)

##### openaiCompatible()

> `readonly` **openaiCompatible**(`options`): [`OpenaiCompatibleSource`](#openaicompatiblesource)

Build a source for an OpenAI-compatible server.

###### Parameters

###### options

###### apiKeyEnv?

`string`

###### baseUrl

`string`

###### model

`string`

###### name

`string`

###### Returns

[`OpenaiCompatibleSource`](#openaicompatiblesource)

##### openrouter()

> `readonly` **openrouter**(`model`, `options`): [`OpenrouterSource`](#openroutersource)

Build an OpenRouter source. Its key is read from `OPENROUTER_API_KEY`
unless `apiKeyEnv` names another variable.

###### Parameters

###### model

`string`

###### options

###### apiKeyEnv?

`string`

###### Returns

[`OpenrouterSource`](#openroutersource)

***

### githubMcp()

#### Call Signature

> **githubMcp**(): [`McpStdioServerConfig`](#mcpstdioserverconfig)

An MCP server that gives an agent GitHub's own tools, acting as the factory's GitHub App.

##### Returns

[`McpStdioServerConfig`](#mcpstdioserverconfig)

##### Remarks

It runs `github-mcp-server`, which must be installed on the machine, with the token of an
agent whose harness sets `github`; a harness without `github` cannot use it. Tools that need a
user, such as `get_me`, are left out, since an App's token cannot answer them. Pi needs the
list of tools the model may call.

##### Example

```ts
import { githubMcp, harnesses } from "@jigs-ai/jigs";

const builder = harnesses.claude({
  model: "opus",
  github: { installationName: "github-acme" },
  mcpServers: { github: githubMcp() },
});
```

#### Call Signature

> **githubMcp**(`options`): [`PiMcpStdioServerConfig`](#pimcpstdioserverconfig)

An MCP server that gives an agent GitHub's own tools, acting as the factory's GitHub App.

##### Parameters

###### options

[`GithubMcpOptions`](#githubmcpoptions)

##### Returns

[`PiMcpStdioServerConfig`](#pimcpstdioserverconfig)

##### Remarks

It runs `github-mcp-server`, which must be installed on the machine, with the token of an
agent whose harness sets `github`; a harness without `github` cannot use it. Tools that need a
user, such as `get_me`, are left out, since an App's token cannot answer them. Pi needs the
list of tools the model may call.

##### Example

```ts
import { githubMcp, harnesses } from "@jigs-ai/jigs";

const builder = harnesses.claude({
  model: "opus",
  github: { installationName: "github-acme" },
  mcpServers: { github: githubMcp() },
});
```

***

### linearMcp()

#### Call Signature

> **linearMcp**(): [`McpHttpServerConfig`](#mcphttpserverconfig)

An MCP server that gives an agent Linear's own tools, acting as the factory on Linear.

##### Returns

[`McpHttpServerConfig`](#mcphttpserverconfig)

##### Remarks

It reaches Linear's hosted server at `https://mcp.linear.app/mcp` with the token of an agent
whose harness sets `linear`; a harness without `linear` cannot use it. In app mode the agent
acts as the factory's Linear app, in key mode as the API key's user. Pi needs the list of
tools the model may call. The result is plain data, so spread it to change a field, such as
`url` to `https://mcp.linear.app/mcp/readonly` for read tools only.

##### Example

```ts
import { harnesses, linearMcp } from "@jigs-ai/jigs";

const triager = harnesses.claude({
  model: "opus",
  linear: { installationName: "linear-acme" },
  mcpServers: { linear: linearMcp() },
});
```

#### Call Signature

> **linearMcp**(`options`): [`PiMcpHttpServerConfig`](#pimcphttpserverconfig)

An MCP server that gives an agent Linear's own tools, acting as the factory on Linear.

##### Parameters

###### options

[`LinearMcpOptions`](#linearmcpoptions)

##### Returns

[`PiMcpHttpServerConfig`](#pimcphttpserverconfig)

##### Remarks

It reaches Linear's hosted server at `https://mcp.linear.app/mcp` with the token of an agent
whose harness sets `linear`; a harness without `linear` cannot use it. In app mode the agent
acts as the factory's Linear app, in key mode as the API key's user. Pi needs the list of
tools the model may call. The result is plain data, so spread it to change a field, such as
`url` to `https://mcp.linear.app/mcp/readonly` for read tools only.

##### Example

```ts
import { harnesses, linearMcp } from "@jigs-ai/jigs";

const triager = harnesses.claude({
  model: "opus",
  linear: { installationName: "linear-acme" },
  mcpServers: { linear: linearMcp() },
});
```

***

### pagerdutyMcp()

#### Call Signature

> **pagerdutyMcp**(): [`McpHttpServerConfig`](#mcphttpserverconfig)

An MCP server that gives an agent PagerDuty's own tools, acting as the factory's PagerDuty app.

##### Returns

[`McpHttpServerConfig`](#mcphttpserverconfig)

##### Remarks

It reaches PagerDuty's hosted server with the token of an agent whose harness sets
`pagerduty`; a harness without `pagerduty` cannot use it. The token carries the scopes jigs
itself uses, so the agent can read and update incidents and read users; other tools fail for
lack of a scope. The token belongs to an app, not a user, so `get_user_data` is disabled and
`list_incidents` cannot filter by the `assigned` or `teams` request scope. Pi needs the list of
tools the model may call; leave `get_user_data` out of it. The result is plain data: for an
account in the EU service region, spread it with `url: "https://mcp.eu.pagerduty.com/mcp"`.

##### Example

```ts
import { harnesses, pagerdutyMcp } from "@jigs-ai/jigs";

const triager = harnesses.claude({
  model: "opus",
  pagerduty: { installationName: "pagerduty-acme" },
  mcpServers: { pagerduty: pagerdutyMcp() },
});
```

#### Call Signature

> **pagerdutyMcp**(`options`): [`PiMcpHttpServerConfig`](#pimcphttpserverconfig)

An MCP server that gives an agent PagerDuty's own tools, acting as the factory's PagerDuty app.

##### Parameters

###### options

[`PagerdutyMcpOptions`](#pagerdutymcpoptions)

##### Returns

[`PiMcpHttpServerConfig`](#pimcphttpserverconfig)

##### Remarks

It reaches PagerDuty's hosted server with the token of an agent whose harness sets
`pagerduty`; a harness without `pagerduty` cannot use it. The token carries the scopes jigs
itself uses, so the agent can read and update incidents and read users; other tools fail for
lack of a scope. The token belongs to an app, not a user, so `get_user_data` is disabled and
`list_incidents` cannot filter by the `assigned` or `teams` request scope. Pi needs the list of
tools the model may call; leave `get_user_data` out of it. The result is plain data: for an
account in the EU service region, spread it with `url: "https://mcp.eu.pagerduty.com/mcp"`.

##### Example

```ts
import { harnesses, pagerdutyMcp } from "@jigs-ai/jigs";

const triager = harnesses.claude({
  model: "opus",
  pagerduty: { installationName: "pagerduty-acme" },
  mcpServers: { pagerduty: pagerdutyMcp() },
});
```

## Agent and model requests/results

### AgentResult

> **AgentResult**\<`T`\> = [`ModelResult`](#modelresult)\<`T`\> & `object`

A model result with the session reference an agent harness returned, when it returned one.

#### Type Declaration

##### session?

> `optional` **session**: [`AgentSessionRef`](#agentsessionref)

#### Type Parameters

##### T

`T` = `unknown`

***

### AgentSessionRef

> **AgentSessionRef** = `object`

A session reference: the small piece of data that lets a later `runAgent` call resume the same
harness session. Pass it back as `resume`.

#### Properties

##### descriptor

> **descriptor**: `string`

The harness descriptor the session was recorded on, as [describeHarness](#describeharness) renders it.

##### harness

> **harness**: [`Harness`](#harness-3)\[`"kind"`\]

##### id

> **id**: `string`

***

### AskAgentOptions

> **AskAgentOptions**\<`T`\> = `object`

Options for one harness turn without tools or a worktree.

#### Type Parameters

##### T

`T` = `undefined`

#### Properties

##### harness

> **harness**: [`AskableHarness`](#askableharness)

##### output?

> `optional` **output**: `z.ZodType`\<`T`\>

##### prompt

> **prompt**: `string`

##### system?

> `optional` **system**: `string`

***

### AskModelOptions

> **AskModelOptions**\<`T`\> = `object`

Options for one API model call.

#### Type Parameters

##### T

`T` = `undefined`

#### Properties

##### model

> **model**: [`AskableModelSource`](#askablemodelsource)

##### output?

> `optional` **output**: `z.ZodType`\<`T`\>

##### prompt

> **prompt**: `string`

##### system?

> `optional` **system**: `string`

***

### ModelResult

> **ModelResult**\<`T`\> = `object`

Text and structured output returned by a model call.

#### Type Parameters

##### T

`T` = `unknown`

#### Properties

##### output

> **output**: `T`

##### text

> **text**: `string`

***

### OutputJsonSchema

> **OutputJsonSchema** = `Record`\<`string`, `unknown`\>

The serializable JSON Schema sent across the workflow-step boundary.

***

### RunAgentOptions

> **RunAgentOptions**\<`T`\> = `object`

Options for an agent that works inside a directory.

#### Type Parameters

##### T

`T` = `undefined`

#### Properties

##### cwd

> **cwd**: `string`

##### harness

> **harness**: [`Harness`](#harness-3)

##### output?

> `optional` **output**: `z.ZodType`\<`T`\>

##### prompt

> **prompt**: `string`

##### resume?

> `optional` **resume**: [`AgentSessionRef`](#agentsessionref)

The session reference of an earlier run to continue.

***

### describeHarness()

> **describeHarness**(`harness`): `string`

A harness descriptor as a string that ignores field order: two descriptors that list the same
settings in another order render the same.

#### Parameters

##### harness

[`Harness`](#harness-3)

#### Returns

`string`

***

### unwrapAgentStep()

> **unwrapAgentStep**(`result`): [`AgentResult`](#agentresult)

Convert returned execution failure markers into errors the workflow throws.

#### Parameters

##### result

[`AgentResult`](#agentresult) | \{ `jitFailure`: `object` & `object`[]; \} | \{ `resumeFailed`: `string`; \}

#### Returns

[`AgentResult`](#agentresult)

## Decision models

### AskJevOptions

> **AskJevOptions**\<`QUESTIONS`\> = `object`

A decision request in workflow and durable wire form.

#### Type Parameters

##### QUESTIONS

`QUESTIONS` *extends* [`JevQuestions`](#jevquestions)

#### Properties

##### model

> **model**: [`OpenrouterSource`](#openroutersource)

##### questions

> **questions**: `QUESTIONS`

##### state

> **state**: [`JevState`](#jevstate)

***

### ChoiceQuestion

> **ChoiceQuestion**\<`OPTIONS`\> = `object`

A question answered with one named option.

#### Type Parameters

##### OPTIONS

`OPTIONS` *extends* `Record`\<`string`, `string`\> = `Record`\<`string`, `string`\>

#### Properties

##### instructions

> **instructions**: `string`

##### options

> **options**: `OPTIONS`

##### type

> **type**: `"choice"`

***

### JevAnswer

> **JevAnswer**\<`QUESTION`\> = `QUESTION` *extends* [`ChoiceQuestion`](#choicequestion)\<infer OPTIONS\> ? `object` : `QUESTION` *extends* [`ScoreQuestion`](#scorequestion) ? `object` : `object`

The calibrated answer shape selected by one question descriptor.

#### Type Parameters

##### QUESTION

`QUESTION` *extends* [`JevQuestion`](#jevquestion)

***

### JevAnswers

> **JevAnswers**\<`QUESTIONS`\> = `{ [KEY in keyof QUESTIONS]: JevAnswer<QUESTIONS[KEY]> }`

Answers narrowed independently for every named question.

#### Type Parameters

##### QUESTIONS

`QUESTIONS` *extends* [`JevQuestions`](#jevquestions)

***

### JevQuestion

> **JevQuestion** = [`YesNoQuestion`](#yesnoquestion) \| [`ChoiceQuestion`](#choicequestion) \| [`ScoreQuestion`](#scorequestion)

Any question accepted by `askJev`.

***

### JevQuestions

> **JevQuestions** = `Record`\<`string`, [`JevQuestion`](#jevquestion)\>

Named decision questions evaluated against one shared state.

***

### JevResult

> **JevResult**\<`QUESTIONS`\> = `object`

A typed decision result.

#### Type Parameters

##### QUESTIONS

`QUESTIONS` *extends* [`JevQuestions`](#jevquestions)

#### Properties

##### answers

> **answers**: [`JevAnswers`](#jevanswers)\<`QUESTIONS`\>

***

### JevState

> **JevState** = `string` \| `JevJsonObject` \| `JevJsonValue`[]

JSON-compatible evidence evaluated by a decision model.

***

### ScoreQuestion

> **ScoreQuestion** = `object`

A question scored over ordered levels, from lowest to highest.

#### Properties

##### instructions

> **instructions**: `string`

##### levels

> **levels**: `string`[]

##### type

> **type**: `"score"`

***

### YesNoQuestion

> **YesNoQuestion** = `object`

A calibrated yes-or-no question.

#### Properties

##### instructions

> **instructions**: `string`

##### type

> **type**: `"yes-no"`

***

### choice()

> **choice**\<`OPTIONS`\>(`instructions`, `options`): [`ChoiceQuestion`](#choicequestion)\<`OPTIONS`\>

Build a question answered with one named option. It throws unless every option has a
description.

#### Type Parameters

##### OPTIONS

`OPTIONS` *extends* `Record`\<`string`, `string`\>

#### Parameters

##### instructions

`string`

##### options

`OPTIONS`

#### Returns

[`ChoiceQuestion`](#choicequestion)\<`OPTIONS`\>

***

### score()

> **score**(`instructions`, `levels`): [`ScoreQuestion`](#scorequestion)

Build a question scored over ordered levels, from lowest to highest. It throws unless there
are at least two levels, each described.

#### Parameters

##### instructions

`string`

##### levels

`string`[]

#### Returns

[`ScoreQuestion`](#scorequestion)

***

### yesNo()

> **yesNo**(`instructions`): [`YesNoQuestion`](#yesnoquestion)

Build a calibrated yes-or-no question.

#### Parameters

##### instructions

`string`

#### Returns

[`YesNoQuestion`](#yesnoquestion)

## Human input

### HumanReply

What people answered in the run's Linear agent session.

#### Remarks

Every message sent since the run last read the session counts, including any sent before the
question. `body` holds every message oldest first, each after its author's name; `author` and
`createdAt` are the newest message's.

#### Properties

##### author

> **author**: `object`

###### id

> **id**: `string`

###### name

> **name**: `string`

##### body

> **body**: `string`

##### createdAt

> **createdAt**: `string`

***

### Halt

> **Halt** = `object`

What the question says, in the words a stranger to the repo reads.
`headline` is one plain sentence naming what paused and why, `where`
names the routine it paused in so the footer can say so, `about` restates the
ticket itself, `notes` are plain bullet lines, and `onReply` decides what
the question asks the human to do: choose between the questions ("continue")
or repair something and let the step run again ("retry"). `mention` adds
people, by Linear email, to the operator (or the creator) and the assignee
the question already mentions; an email no Linear user has is skipped.

#### Properties

##### about?

> `optional` **about**: `string`

##### headline

> **headline**: `string`

##### mention?

> `optional` **mention**: `string`[]

##### notes?

> `optional` **notes**: `string`[]

##### onReply

> **onReply**: `"continue"` \| `"retry"`

##### questions?

> `optional` **questions**: [`HaltQuestion`](#haltquestion)[]

##### where

> **where**: `string`

***

### HaltOption

> **HaltOption** = `z.infer`\<*typeof* [`haltOptionSchema`](#haltoptionschema)\>

One answer choice for a question shown to a human.

***

### HaltQuestion

> **HaltQuestion** = `z.infer`\<*typeof* [`haltQuestionSchema`](#haltquestionschema)\>

A question shown to a human while a run waits for their reply.

***

### JsonValue

> **JsonValue** = `string` \| `number` \| `boolean` \| `null` \| [`JsonValue`](#jsonvalue)[] \| \{\[`key`: `string`\]: [`JsonValue`](#jsonvalue); \}

A value that can be serialized as JSON and embedded in a prompt or comment.

***

### haltOptionSchema

> `const` **haltOptionSchema**: `ZodObject`\<\{ `label`: `ZodString`; `recommended`: `ZodOptional`\<`ZodBoolean`\>; \}, `$strict`\>

Validates an answer choice with a nonempty label and an optional recommendation marker.

***

### haltQuestionSchema

> `const` **haltQuestionSchema**: `ZodObject`\<\{ `context`: `ZodOptional`\<`ZodString`\>; `options`: `ZodOptional`\<`ZodArray`\<`ZodObject`\<\{ `label`: `ZodString`; `recommended`: `ZodOptional`\<`ZodBoolean`\>; \}, `$strict`\>\>\>; `question`: `ZodString`; \}, `$strict`\>

Validates a question with nonempty text, optional context and optional suggested answers.

## Linear tickets

### TicketClaim

A ticket held exclusively by the current workflow run, with the Linear agent session the run
talks to people in.

#### Properties

##### consumedPromptIds

> **consumedPromptIds**: `string`[]

The messages in the session this run has already read. A later question skips them.

##### identifier

> **identifier**: `string`

##### installationName

> **installationName**: `string`

The Linear installation, as named on the hub, the ticket is reached through.

##### issueId

> **issueId**: `string`

##### sessionId

> **sessionId**: `string`

The Linear agent session this run asks its questions and posts its notes in.

##### token

> **token**: `string`

***

### TicketComment

> **TicketComment** = `object`

A Linear ticket comment captured in a workflow snapshot.

#### Properties

##### author

> **author**: `string` \| `null`

##### body

> **body**: `string`

##### createdAt

> **createdAt**: `string`

##### id

> **id**: `string`

***

### TicketLink

> **TicketLink** = `object`

A named external link attached to a Linear ticket.

#### Properties

##### title

> **title**: `string`

##### url

> **url**: `string`

***

### TicketNote

> **TicketNote** = `object`

A note a ticket run posts in its Linear agent session that asks for nothing
and suspends nothing. It carries its own words, the way a halt does, so the
renderer owns the layout and every caller owns what it says.

#### Remarks

Linear marks a session stale after about 30 minutes with no activity, and a
stale session hides its Stop button. Before a long quiet wait on people, such
as a pull request waiting for review, post a note with `run: "waiting"`.

#### Properties

##### closing

> **closing**: `string`

What the reader should do with it.

##### headline

> **headline**: `string`

One plain sentence naming what jigs is about to do, or has stopped doing.

##### mention?

> `optional` **mention**: `string`[]

More people to mention, by Linear email, beyond the operator (or the
creator) and the assignee. Each person is named once; an email no Linear
user has is skipped with a warning.

##### notes

> **notes**: `string`[]

The bullet lines under it.

##### run?

> `optional` **run**: `"waiting"` \| `"ended"`

What the run does after this note; omitted, it keeps working.

###### Remarks

`"ended"` is the run's final message, success or not; Linear shows the
session as finished. Set it on every way out of the run. `"waiting"` shows the session as awaiting input, which never goes
stale but shows no Stop button. The run does not read replies to a waiting
note, so say in it where people act and how to stop the run.

***

### TicketRef

> **TicketRef** = `object`

A compact reference to a related Linear ticket.

#### Properties

##### id

> **id**: `string`

##### identifier

> **identifier**: `string`

##### title

> **title**: `string`

***

### TicketReviewPrompt()

> **TicketReviewPrompt** = (`input`) => `string`

Renders instructions for an agent to turn a ticket into an actionable handoff.

#### Parameters

##### input

[`TicketReviewPromptInput`](#ticketreviewpromptinput)

#### Returns

`string`

***

### TicketReviewPromptInput

> **TicketReviewPromptInput** = `object`

The rendered ticket supplied to a ticket-review prompt.

#### Properties

##### ticket

> **ticket**: `string`

***

### TicketSnapshot

> **TicketSnapshot** = `object`

The fixed ticket state shared by every step in one workflow activation.

#### Properties

##### blockedBy

> **blockedBy**: [`TicketRef`](#ticketref)[]

##### blocks

> **blocks**: [`TicketRef`](#ticketref)[]

##### branchName

> **branchName**: `string`

##### comments

> **comments**: [`TicketComment`](#ticketcomment)[]

##### description

> **description**: `string`

##### fetchedAt

> **fetchedAt**: `string`

##### id

> **id**: `string`

##### identifier

> **identifier**: `string`

##### labels

> **labels**: `string`[]

##### links

> **links**: [`TicketLink`](#ticketlink)[]

##### state

> **state**: `string`

##### subIssues

> **subIssues**: [`TicketRef`](#ticketref)[]

##### title

> **title**: `string`

##### url

> **url**: `string`

***

### ticketReviewPrompt

> `const` **ticketReviewPrompt**: [`TicketReviewPrompt`](#ticketreviewprompt)

The default prompt for reviewing a Linear ticket before implementation begins.

***

### ticketReviewVerdictSchema

> `const` **ticketReviewVerdictSchema**: `ZodObject`\<\{ `about`: `ZodString`; `assumptions`: `ZodArray`\<`ZodString`\>; `brief`: `ZodString`; `questions`: `ZodArray`\<`ZodObject`\<\{ `context`: `ZodOptional`\<`ZodString`\>; `options`: `ZodOptional`\<`ZodArray`\<`ZodObject`\<\{ `label`: `ZodString`; `recommended`: `ZodOptional`\<`ZodBoolean`\>; \}, `$strict`\>\>\>; `question`: `ZodString`; \}, `$strict`\>\>; `verdict`: `ZodEnum`\<\{ `needs-human`: `"needs-human"`; `proceed`: `"proceed"`; \}\>; \}, `$strict`\>

Structured verdict returned by the agent that reviews a ticket before work starts.

***

### renderTicketSnapshot()

> **renderTicketSnapshot**(`snapshot`): `string`

Render a ticket snapshot as Markdown for an agent prompt.

#### Parameters

##### snapshot

[`TicketSnapshot`](#ticketsnapshot)

#### Returns

`string`

## PagerDuty incidents

### IncidentRef

> **IncidentRef** = `object`

A PagerDuty object an incident points at, such as its service or an assignee.

#### Properties

##### id

> **id**: `string`

##### name

> **name**: `string`

##### url

> **url**: `string` \| `null`

***

### IncidentSnapshot

> **IncidentSnapshot** = `object`

The incident as one workflow activation read it.

#### Properties

##### assignees

> **assignees**: [`IncidentRef`](#incidentref)[]

##### createdAt

> **createdAt**: `string`

##### escalationPolicy

> **escalationPolicy**: [`IncidentRef`](#incidentref)

##### fetchedAt

> **fetchedAt**: `string`

##### id

> **id**: `string`

##### number

> **number**: `number`

##### service

> **service**: [`IncidentRef`](#incidentref)

##### status

> **status**: `"triggered"` \| `"acknowledged"` \| `"resolved"`

##### title

> **title**: `string`

##### urgency

> **urgency**: `"high"` \| `"low"`

##### url

> **url**: `string`

## Pull requests

### CheckRun

A check or commit status reported on a pull request head.

#### Properties

##### conclusion

> **conclusion**: `string` \| `null`

##### name

> **name**: `string`

##### url

> **url**: `string`

***

### MergeOptions

How workflow code asks for a pull request to be merged.

#### Extends

- [`PullRequestReadOptions`](#pullrequestreadoptions)

#### Properties

##### approvalCovers?

> `optional` **approvalCovers**: [`ApprovalCoverage`](#approvalcoverage)

Which commits an approving review covers. Default `"latest-commit"`.

###### Inherited from

[`PullRequestReadOptions`](#pullrequestreadoptions).[`approvalCovers`](#approvalcovers-2)

##### consent?

> `optional` **consent**: [`MergeConsent`](#mergeconsent)

Whose consent the merge needs. Default `"operator"`.

***

### PullRequestComment

A comment on the pull request conversation, which hangs off no thread.

#### Properties

##### body

> **body**: `string`

##### createdAt

> **createdAt**: `string`

##### id

> **id**: `number`

##### updatedAt

> **updatedAt**: `string`

##### user

> **user**: `string`

##### userType

> **userType**: `string`

***

### PullRequestMarker

Hidden progress metadata stored in a pull request comment.

#### Properties

##### kind

> **kind**: `MarkerKind`

`reply` answers the thing named by `source`, and `status` is a note about a
commit, such as a stand-down
after a refused merge, a CI failure jigs could not repair, or a merge
refused for a state that will pass.

##### reason?

> `optional` **reason**: [`StatusReason`](#statusreason)

Required on a `status` marker, meaningless on any other.

##### run

> **run**: `string`

The run that wrote it. Provenance for a reader; never matched on.

##### scope

> **scope**: `string`

Names this workflow's work on the pull request. Keep it stable across
replacement runs to recognize earlier notes and replies.

##### source?

> `optional` **source**: `string`

What this answers: a comment as `id@updatedAt`, or a commit sha.

***

### PullRequestReadOptions

How workflow code asks for a pull request's approval to be read.

#### Extended by

- [`MergeOptions`](#mergeoptions)

#### Properties

##### approvalCovers?

> `optional` **approvalCovers**: [`ApprovalCoverage`](#approvalcoverage)

Which commits an approving review covers. Default `"latest-commit"`.

***

### PullRequestReview

A submitted GitHub review of a pull request.

#### Properties

##### body

> **body**: `string`

##### commitSha?

> `optional` **commitSha**: `string`

##### id

> **id**: `number`

##### state

> **state**: `string`

##### submittedAt

> **submittedAt**: `string`

##### user

> **user**: `string`

***

### PullRequestSnapshot

GitHub facts about a pull request, without a judgment about outstanding work.

#### Properties

##### appBot

> **appBot**: `string`

The login of the factory's GitHub App, `<slug>[bot]`: the account jigs posts as, and so do
agents whose harness sets `github`.

##### approval

> **approval**: [`ApprovalState`](#approvalstate)

The operator's consent: how the people's approving reviews read on this head.

##### ci

> **ci**: `"none"` \| `"pending"` \| `"red"` \| `"green"`

`none`: no check or status has reported on this head yet. It is never green.

##### conversationComments

> **conversationComments**: [`PullRequestComment`](#pullrequestcomment)[]

##### draft

> **draft**: `boolean`

##### failingChecks

> **failingChecks**: [`CheckRun`](#checkrun)[]

##### headSha

> **headSha**: `string`

##### labels

> **labels**: `string`[]

Label names on the pull request.

##### mergeCommitSha

> **mergeCommitSha**: `string` \| `null`

The merge commit, once GitHub has made one.

##### merged

> **merged**: `boolean`

##### mergeState

> **mergeState**: `string`

GitHub's own verdict on whether the pull request can merge right now,
folding in conflicts, required checks and required reviews. `"clean"` is
the only value that permits a merge; `"unknown"` means GitHub has not
finished computing it, so the answer is "not yet, ask again".

##### reviews

> **reviews**: [`PullRequestReview`](#pullrequestreview)[]

##### reviewThreads

> **reviewThreads**: [`ReviewThread`](#reviewthread)[]

##### state

> **state**: `"open"` \| `"closed"`

***

### ReviewComment

A comment anchored to a file in a pull request review.

#### Properties

##### body

> **body**: `string`

##### createdAt

> **createdAt**: `string`

##### id

> **id**: `number`

##### line

> **line**: `number` \| `null`

##### path

> **path**: `string`

##### rootId

> **rootId**: `number`

##### updatedAt

> **updatedAt**: `string`

##### user

> **user**: `string`

***

### ReviewThread

A pull request review conversation, with its optional file location.

#### Properties

##### comments

> **comments**: [`ReviewComment`](#reviewcomment)[]

##### line

> **line**: `number` \| `null`

##### origin?

> `optional` **origin**: `"conversation"`

##### path

> **path**: `string`

##### rootId

> **rootId**: `number`

***

### ApprovalState

> **ApprovalState** = `"approved"` \| `"changes-requested"` \| `"stale"` \| `"none"`

How the operator's consent reads right now. `stale` is an approval that
named an earlier commit. This differs from a pull
request nobody has approved.

***

### PullRequestRef

> **PullRequestRef** = [`RepositoryRef`](#repositoryref) & `object`

Identifies a pull request by its repository, the installation jigs reaches it through, and its number.

#### Type Declaration

##### number

> **number**: `number`

The repository-local pull request number.

***

### RepositoryRef

> **RepositoryRef** = `object`

Identifies a repository, and the GitHub installation jigs reaches it through.

#### Properties

##### installationName

> **installationName**: `string`

The name of the GitHub App installation, as named on the hub, that jigs acts through.

##### owner

> **owner**: `string`

The GitHub organization or account that owns the repository.

##### repo

> **repo**: `string`

The repository name.

***

### StatusReason

> **StatusReason** = `"merge"` \| `"ci"` \| `"merge-retry"`

Label a status note as a merge refusal, CI failure or temporary merge refusal.
Distinct reasons keep notes for the same commit independent. They do not
change merge readiness or schedule more work.

***

### blockedMergeNote()

> **blockedMergeNote**(`snapshot`): `string` \| `null`

The note to leave on a pull request that is approved and green but that GitHub
blocks from merging, or `null` when that is not why it waits.

#### Parameters

##### snapshot

[`PullRequestSnapshot`](#pullrequestsnapshot)

#### Returns

`string` \| `null`

#### Remarks

GitHub does not say which branch rule blocks the merge, so without a note
jigs would wait in silence.

***

### defaultPullRequestScope()

> **defaultPullRequestScope**(`subject`): `string`

The scope a caller gets when it names none: this workflow's function name
and the subject it was given: a ticket key or the pull request itself.
Pass an explicit scope to continue another workflow's work, or to review a
pull request independently of the run delivering it.

#### Parameters

##### subject

`string`

#### Returns

`string`

***

### isPullRequestMergeReady()

> **isPullRequestMergeReady**(`snapshot`): `boolean`

Whether current GitHub facts satisfy the configured approval and merge requirements.

#### Parameters

##### snapshot

[`PullRequestSnapshot`](#pullrequestsnapshot)

#### Returns

`boolean`

***

### parseMarkers()

> **parseMarkers**(`body`): [`PullRequestMarker`](#pullrequestmarker)[]

Every marker in one comment body, in the order they appear.

#### Parameters

##### body

`string`

#### Returns

[`PullRequestMarker`](#pullrequestmarker)[]

***

### pullRequestSnapshotKey()

> **pullRequestSnapshotKey**(`snapshot`): `string`

A comparison key for the facts in a pull request snapshot.

#### Parameters

##### snapshot

[`PullRequestSnapshot`](#pullrequestsnapshot)

#### Returns

`string`

#### Remarks

Collection ordering and incidental fields do not change the key. Compare keys for equality;
the key format is opaque and is not a durable identifier.

***

### renderChecks()

> **renderChecks**(`failing`): `string`

Render failed checks as a Markdown list for a pull request note.

#### Parameters

##### failing

[`CheckRun`](#checkrun)[]

#### Returns

`string`

## Pull request delivery

### BuildAndReviewOptions

What `buildAndReview` needs besides the delivery.

#### Properties

##### rounds

> **rounds**: `number`

One round is one build plus one review of what it committed.

***

### BuildApproved

A change the reviewer approved.

#### Properties

##### ledger

> **ledger**: [`ReviewRound`](#reviewround)[]

##### notes

> **notes**: `string`[]

The non-blocking findings of the approving round, for a person to read.

##### outcome

> **outcome**: `"approved"`

##### reviewedCommit

> **reviewedCommit**: `string`

The commit the reviewer approved. Publish exactly this one.

***

### BuildFacts

What a fresh build prompt is given: the open findings and the diff so far.

#### Type Parameters

##### W

`W`

#### Properties

##### diff

> **diff**: `string`

Empty before the first commit.

##### findings

> **findings**: `object`[]

###### blocking

> **blocking**: `boolean`

###### summary

> **summary**: `string`

##### work

> **work**: `W`

##### worktree

> **worktree**: [`Worktree`](#worktree-3)

***

### BuildStopped

Why `buildAndReview` stopped without an approved change. Nothing is pushed: committed work stays
in the worktree for the workflow to push or leave.

#### Remarks

`rounds-exhausted` carries the blocking findings still open. `uncommitted` and `no-commits` mean
the builder left uncommitted changes, or committed nothing new, so there was nothing to review.

#### Properties

##### findings

> **findings**: `string`[]

##### outcome

> **outcome**: `"stopped"`

##### reason

> **reason**: `"rounds-exhausted"` \| `"uncommitted"` \| `"no-commits"`

##### round

> **round**: `number`

The round it stopped in; for `rounds-exhausted`, the last round.

***

### Delivery

One piece of work taken to a pull request: what to build, where, and the agents that build,
review and describe it.

#### Remarks

`work` is yours: only your prompts read it. Give each delivery its own agent session objects: a
session holds its agent's conversation, and its name only labels log lines. `writer` describes
the pull request and defaults to `builder`. Each routine reads only some of these fields, so a
full delivery can be passed to all of them.

#### Type Parameters

##### W

`W`

#### Properties

##### builder

> **builder**: `AgentSession`

##### key

> **key**: `string`

One key per pull request: it scopes the hidden markers on that pull request's notes.

##### prompts

> **prompts**: [`DeliveryPrompts`](#deliveryprompts-1)\<`W`\>

##### reviewer

> **reviewer**: `AgentSession`

##### work

> **work**: `W`

##### worktree

> **worktree**: [`Worktree`](#worktree-3)

##### writer?

> `optional` **writer**: `AgentSession`

***

### DeliveryPrompts

The prompts a delivery sends, written by the workflow. jigs adds only the line that tells each
agent the shape of its answer.

#### Remarks

A turn with two forms goes to an agent session: `resume` is sent to an agent that holds the
earlier turns, so it says only what is new, and `fresh` to one starting from nothing, so it
says everything. `describe` is sent either way.

#### Type Parameters

##### W

`W`

#### Properties

##### build

> **build**: `object`

###### fresh()

> **fresh**: (`facts`) => `string`

###### Parameters

###### facts

[`BuildFacts`](#buildfacts)\<`W`\>

###### Returns

`string`

###### resume()

> **resume**: (`facts`) => `string`

###### Parameters

###### facts

###### findings

`object`[]

###### Returns

`string`

##### describe()

> **describe**: (`facts`) => `string`

###### Parameters

###### facts

###### diff

`string`

###### work

`W`

###### worktree

[`Worktree`](#worktree-3)

###### Returns

`string`

##### maintain

> **maintain**: `object`

###### fresh()

> **fresh**: (`facts`) => `string`

###### Parameters

###### facts

[`MaintainFacts`](#maintainfacts) & `object`

###### Returns

`string`

###### resume()

> **resume**: (`facts`) => `string`

###### Parameters

###### facts

[`MaintainFacts`](#maintainfacts)

###### Returns

`string`

##### review

> **review**: `object`

###### fresh()

> **fresh**: (`facts`) => `string`

###### Parameters

###### facts

[`ReviewFacts`](#reviewfacts)\<`W`\>

###### Returns

`string`

###### resume()

> **resume**: (`facts`) => `string`

###### Parameters

###### facts

###### diff

`string`

###### headSha

`string`

###### responses

`object`[]

###### Returns

`string`

***

### Described

A pull request title and body.

#### Properties

##### body

> **body**: `string`

##### title

> **title**: `string`

***

### DescribeOptions

What `describePullRequest` needs besides the delivery.

#### Properties

##### check()?

> `optional` **check**: (`described`) => `string`[]

The problems with a title and body, such as a title that breaks your naming convention; none
means they are fine. The writer is sent back once with the problems, and problems in its
second answer throw.

###### Parameters

###### described

[`Described`](#described)

###### Returns

`string`[]

***

### FollowOptions

What `followPullRequestToOutcome` needs besides the delivery and the pull request.

#### Properties

##### approvalCovers

> **approvalCovers**: [`ApprovalCoverage`](#approvalcoverage)

Which commits a person's approving review covers.

##### attemptsPerUpdate

> **attemptsPerUpdate**: `number`

Builder turns allowed for each change to the pull request, including recovery.

##### mergeWhen()

> **mergeWhen**: (`snapshot`) => `boolean`

Whether you consent to merging this snapshot now. jigs still merges only when GitHub reports
the pull request approved, green and clean, so this can only make merging stricter. Return
`false` to leave every merge to a person, or check the snapshot, such as for a label.

###### Parameters

###### snapshot

[`PullRequestSnapshot`](#pullrequestsnapshot)

###### Returns

`boolean`

##### onNeedsHuman()

> **onNeedsHuman**: (`facts`) => `Promise`\<`void`\>

Tell a person the pull request needs them. Watching goes on: the next change to the pull
request picks the work back up. The same facts are never sent twice in a row.

###### Parameters

###### facts

[`NeedsHuman`](#needshuman)

###### Returns

`Promise`\<`void`\>

##### wake()

> **wake**: (`snapshot`, `scope`) => `string`[]

The facts in a snapshot that wake the builder, one string each; it is woken for one it has
not been shown. `scope` is the delivery's marker scope. Pass `builderWakeFacts` for the
default rules, or your own function, for example to ignore another bot's comments.

###### Parameters

###### snapshot

[`PullRequestSnapshot`](#pullrequestsnapshot)

###### scope

`string`

###### Returns

`string`[]

***

### MaintainFacts

What a maintenance prompt is given: the pull request as GitHub reports it, and any local work
the builder has to recover first.

#### Properties

##### news

> **news**: `string`[]

The wake facts in `snapshot` the builder has not been shown, as the wake rule wrote them.
Empty when the turn only recovers local work.

##### pr

> **pr**: [`PullRequestRef`](#pullrequestref)

##### recovery?

> `optional` **recovery**: [`UnpublishedWork`](#unpublishedwork)

##### snapshot

> **snapshot**: [`PullRequestSnapshot`](#pullrequestsnapshot)

***

### PublishOptions

What `publishPullRequest` needs besides the delivery.

#### Properties

##### body

> **body**: `string`

##### commit

> **commit**: `string`

The commit to publish. It must be the worktree's HEAD, with nothing uncommitted.

##### draft?

> `optional` **draft**: `boolean`

##### title

> **title**: `string`

***

### ReviewFacts

What a fresh review prompt is given: the commit under review and every earlier round.

#### Type Parameters

##### W

`W`

#### Properties

##### diff

> **diff**: `string`

##### headSha

> **headSha**: `string`

##### ledger

> **ledger**: [`ReviewRound`](#reviewround)[]

##### work

> **work**: `W`

##### worktree

> **worktree**: [`Worktree`](#worktree-3)

***

### ReviewRound

One build and the review of what it committed.

#### Properties

##### findings

> **findings**: `object`[]

###### blocking

> **blocking**: `boolean`

###### summary

> **summary**: `string`

##### responses

> **responses**: `object`[]

The builder's answers to the previous round's findings; empty on the first round.

###### changed

> **changed**: `boolean`

###### detail

> **detail**: `string`

###### finding

> **finding**: `string`

##### round

> **round**: `number`

##### verdict

> **verdict**: `"approved"` \| `"changes-requested"`

`changes-requested` when any finding is blocking.

***

### UnpublishedWork

Local work the pull request has never had: uncommitted changes, or a local commit that was not
pushed. It holds back a merge until it is published.

#### Properties

##### dirty

> **dirty**: `boolean`

##### localHead

> **localHead**: `string`

##### pullRequestHead

> **pullRequestHead**: `string`

***

### BuildDelivery

> **BuildDelivery**\<`W`\> = `Pick`\<[`Delivery`](#delivery)\<`W`\>, `"work"` \| `"worktree"` \| `"builder"` \| `"reviewer"`\> & `object`

The parts of a delivery `buildAndReview` reads.

#### Type Declaration

##### prompts

> **prompts**: `Pick`\<[`DeliveryPrompts`](#deliveryprompts-1)\<`W`\>, `"build"` \| `"review"`\>

#### Type Parameters

##### W

`W`

***

### BuildResult

> **BuildResult** = [`BuildApproved`](#buildapproved) \| [`BuildStopped`](#buildstopped)

What `buildAndReview` returns: an approved change, or a stop.

***

### DescribeDelivery

> **DescribeDelivery**\<`W`\> = `Pick`\<[`Delivery`](#delivery)\<`W`\>, `"work"` \| `"worktree"` \| `"builder"` \| `"writer"`\> & `object`

The parts of a delivery `describePullRequest` reads.

#### Type Declaration

##### prompts

> **prompts**: `Pick`\<[`DeliveryPrompts`](#deliveryprompts-1)\<`W`\>, `"describe"`\>

#### Type Parameters

##### W

`W`

***

### FindingResponse

> **FindingResponse** = `z.output`\<*typeof* `findingResponse`\>

The builder's answer to one finding: what it changed, or why it changed nothing.

***

### FollowDelivery

> **FollowDelivery**\<`W`\> = `Pick`\<[`Delivery`](#delivery)\<`W`\>, `"work"` \| `"key"` \| `"worktree"` \| `"builder"`\> & `object`

The parts of a delivery `followPullRequestToOutcome` reads.

#### Type Declaration

##### prompts

> **prompts**: `Pick`\<[`DeliveryPrompts`](#deliveryprompts-1)\<`W`\>, `"maintain"`\>

#### Type Parameters

##### W

`W`

***

### FollowResult

> **FollowResult** = \{ `outcome`: `"merged"`; \} \| \{ `outcome`: `"closed"`; \}

How `followPullRequestToOutcome` ended: the pull request merged, or closed unmerged.

***

### NeedsHuman

> **NeedsHuman** = \{ `detail`: `string`; `reason`: `"builder-asked"` \| `"attempts-exhausted"`; `unpublished?`: [`UnpublishedWork`](#unpublishedwork); \} \| \{ `detail`: `string`; `reason`: `"merge-refused"`; `tries`: `number`; \} \| \{ `detail`: `string`; `headSha`: `string`; `reason`: `"merge-blocked"`; \}

Why a pull request needs a person, as facts for the workflow to word and send.

#### Remarks

- `builder-asked`: the builder said it needs a person; `detail` is its summary.
- `attempts-exhausted`: the builder's attempts for one pull request update ran out with local
  work still unpublished; `detail` is its last summary.
- `merge-refused`: GitHub refused the merge; `detail` is the last refusal and `tries` how
  often jigs tried. A transient refusal is retried up to ten times before it is reported.
- `merge-blocked`: GitHub blocks an approved, green pull request from merging, usually because
  of a branch rule; `detail` says so in a sentence. Sent once per head. Mark a note posted
  about it with `headSha` and the delivery's scope, so it does not wake the builder and a later
  run does not post it again.

`unpublished` is set when local work the pull request has never had holds back the merge.
The local worktree path never appears in `detail`.

***

### PublishDelivery

> **PublishDelivery** = `Pick`\<[`Delivery`](#delivery)\<`unknown`\>, `"worktree"`\>

The parts of a delivery `publishPullRequest` reads.

***

### ReviewFinding

> **ReviewFinding** = `z.output`\<*typeof* `reviewFinding`\>

One finding from a review of the change.

***

### builderWakeFacts()

> **builderWakeFacts**(`snapshot`, `scope`): `string`[]

The default wake rule for `followPullRequestToOutcome`: the facts in a snapshot a builder can
act on, one string each.

#### Parameters

##### snapshot

[`PullRequestSnapshot`](#pullrequestsnapshot)

##### scope

`string`

#### Returns

`string`[]

#### Remarks

A review with a body or one requesting changes, a new comment or a person's edit of one, a
check failing on the current head, and a conflict with the base each wake the builder. Checks
that queue, run or pass, a bare approval, label changes, a bot editing its own comment, the App
bot's unmarked comments (the builder's own replies) and notes marked with the delivery's
`scope` wake nothing. To change the rules, wrap it or pass your own function as `wake`.

#### Example

```ts
import { builderWakeFacts, type PullRequestSnapshot } from "@jigs-ai/jigs";

// Also ignore a coverage bot's comments.
const wake = (snapshot: PullRequestSnapshot, scope: string) =>
  builderWakeFacts(
    {
      ...snapshot,
      conversationComments: snapshot.conversationComments.filter(
        (comment) => comment.user !== "codecov[bot]",
      ),
    },
    scope,
  );
```

## Slack messages

### SlackAuthor

Someone who posted in Slack.

#### Remarks

`id` is the Slack user ID, or the bot ID for an integration that posts
without a user. `email` is missing for bots. `isOwnBot` marks the factory's
own bot, which is what posts every message jigs sends.

#### Properties

##### bot

> **bot**: `boolean`

##### email?

> `optional` **email**: `string`

##### id

> **id**: `string`

##### isOwnBot

> **isOwnBot**: `boolean`

##### name

> **name**: `string`

***

### SlackPost

One Slack message: its timestamp, which is also its ID in the channel, its
`mrkdwn` text and who wrote it.

#### Properties

##### author

> **author**: [`SlackAuthor`](#slackauthor)

##### text

> **text**: `string`

##### ts

> **ts**: `string`

***

### SlackQuestion

The thread a wait reads, named by the ts of its top-level message (never a
reply's). `lastRead` is the ts of the newest post the workflow has read,
never its own question; only human replies after it count. `until`, an
ISO 8601 timestamp, is when to stop waiting.

#### Properties

##### channel

> **channel**: `string`

##### installationName

> **installationName**: `string`

The Slack installation, as named on the hub, the thread is read through; only its events wake the wait.

##### lastRead

> **lastRead**: `string`

##### threadTs

> **threadTs**: `string`

##### until?

> `optional` **until**: `string`

***

### SlackMessageSnapshot

> **SlackMessageSnapshot** = \{ `channel`: `string`; `gone`: `true`; `ts`: `string`; \} \| [`SlackPost`](#slackpost) & `object`

A Slack message and its thread, as `fetchSlackMessage` read them, or `gone`
when the message was deleted.

#### Remarks

`replies` are the thread's replies, oldest first, without the message
itself.

***

### SlackReplyResult

> **SlackReplyResult** = \{ `outcome`: `"replied"`; `replies`: [`SlackPost`](#slackpost)[]; \} \| \{ `outcome`: `"timed-out"`; \} \| \{ `outcome`: `"gone"`; \}

How `waitForSlackReply` ended: `replied` with the new human replies (oldest first, never
empty), `timed-out` at `until`, or `gone` when the thread's top-level message was deleted.

## Git/change data

### ChangePatch

Patches for selected paths between two resolved commits.

#### Properties

##### patches

> **patches**: `object`[]

Patch text for each selected path, in first-requested order.

###### path

> **path**: `string`

The literal path that was selected.

###### text

> **text**: `string`

The Git patch for this path, which may be empty or truncated.

##### truncated

> **truncated**: `boolean`

Whether the shared text limit cut off any patch text.

***

### ChangeSummary

A bounded description of the committed changes between two Git refs.

#### Properties

##### base

> **base**: `string`

The resolved base commit.

##### commits

> **commits**: `object`[]

Commits reachable from head but not base, newest first.

###### authorName

> **authorName**: `string`

The author name recorded by Git, without mailmap rewriting.

###### sha

> **sha**: `string`

The full commit SHA.

###### subject

> **subject**: `string`

The first line of the commit message.

##### files

> **files**: [`FileChange`](#filechange)[]

Files that differ directly between the base and head trees.

##### head

> **head**: `string`

The resolved head commit.

##### truncated

> **truncated**: `boolean`

Whether file or commit limits caused results to be omitted.

***

### FileChange

One file changed between the base and head trees.

#### Properties

##### additions

> **additions**: `number`

The number of added lines, or zero for a binary file.

##### deletions

> **deletions**: `number`

The number of deleted lines, or zero for a binary file.

##### path

> **path**: `string`

The changed path. Renames use the path in the head tree.

##### status

> **status**: [`ChangeStatus`](#changestatus)

How the path differs between the two trees.

***

### ChangeStatus

> **ChangeStatus** = `"added"` \| `"modified"` \| `"deleted"` \| `"renamed"` \| `"other"`

How a file differs between the base and head trees.

***

### renderChangeSummary()

> **renderChangeSummary**(`summary`): `string`

Render a Markdown review summary with commits, totals and up to 60 changed-file rows.

#### Parameters

##### summary

[`ChangeSummary`](#changesummary)

#### Returns

`string`

## Runtime and resources

### PullRequestWorktree

A worktree checked out at a pull request's head commit, with no branch of its own.

#### Remarks

It is for checking the pull request as it stands, so it cannot be pushed. Pass `headSha` to
`mergePullRequest` to merge exactly the commit that was checked. Commits made in it are not
kept when the run's resources are released.

#### Properties

##### binding

> **binding**: `string`

The named repository binding in the factory configuration.

##### headSha

> **headSha**: `string`

The pull request's head commit, which the worktree is checked out at.

##### installationName

> **installationName**: `string`

The binding's GitHub installation, as named on the hub, that reaches its repository.

##### path

> **path**: `string`

***

### ReleaseReport

The result of applying a release policy to one run's resources.

#### Properties

##### policy

> **policy**: `object`

The policy applied by this release attempt.

###### onFailure

> **onFailure**: `"release"` \| `"keep"` = `releaseAction`

What to do with eligible resources after a failed or cancelled run.

###### onSuccess

> **onSuccess**: `"release"` \| `"keep"` = `releaseAction`

What to do with eligible resources after a completed run.

##### resources

> **resources**: [`ResourceRecord`](#resourcerecord)[]

Every resource the run recorded, with its state and reason after this attempt.

***

### ResourceRecord

One recorded resource and what has happened to it. Records stay after release as history.

#### Extends

- [`RunResource`](#runresource)

#### Properties

##### identity

> **identity**: `string`

The stable name that distinguishes this resource from others of the same kind.

###### Inherited from

[`RunResource`](#runresource).[`identity`](#identity-1)

##### kind

> **kind**: `string`

The resource category, such as `worktree` or `run-directory`.

###### Inherited from

[`RunResource`](#runresource).[`kind`](#kind-2)

##### reason

> **reason**: `string` \| `null`

Why the resource is in its state, or null while it is live and untouched.

##### runId

> **runId**: `string`

The run that owns the resource.

##### state

> **state**: [`ResourceState`](#resourcestate)

##### updatedAt

> **updatedAt**: `string`

When the state last changed, as an ISO timestamp.

##### url

> **url**: `string`

An absolute URL where a human can inspect the resource.

###### Inherited from

[`RunResource`](#runresource).[`url`](#url-2)

***

### RunResource

A durable thing that a run created or otherwise owns a reference to.

#### Extended by

- [`ResourceRecord`](#resourcerecord)

#### Properties

##### identity

> **identity**: `string`

The stable name that distinguishes this resource from others of the same kind.

##### kind

> **kind**: `string`

The resource category, such as `worktree` or `run-directory`.

##### url

> **url**: `string`

An absolute URL where a human can inspect the resource.

***

### Worktree

A provisioned repository worktree and the commit it was cut from.

#### Properties

##### baseSha

> **baseSha**: `string`

##### binding

> **binding**: `string`

The named repository binding in the factory configuration.

##### branch

> **branch**: `string`

##### defaultBranch

> **defaultBranch**: `string`

##### installationName

> **installationName**: `string`

The binding's GitHub installation, as named on the hub, that reaches its repository.

##### path

> **path**: `string`

***

### ReleasePolicy

> **ReleasePolicy** = `z.input`\<*typeof* `releaseSchema`\>

Selects whether eligible run resources are released for each terminal outcome.

***

### ResourceState

> **ResourceState** = `"live"` \| `"kept"` \| `"released"` \| `"failed"`

Where a recorded resource stands: `live` until release decides, then `kept` by policy or a
safety check, `released`, or `failed` when the release attempt errored and will be retried.

## Errors and utilities

### ClaimConflictError

A ticket-claim failure that identifies the run already holding the ticket.

#### Extends

- `Error`

#### Constructors

##### Constructor

> **new ClaimConflictError**(`resource`, `owningRunId`): [`ClaimConflictError`](#claimconflicterror)

###### Parameters

###### resource

`string`

###### owningRunId

`string`

###### Returns

[`ClaimConflictError`](#claimconflicterror)

###### Overrides

`Error.constructor`

#### Properties

##### owningRunId

> `readonly` **owningRunId**: `string`

##### resource

> `readonly` **resource**: `string`

***

### JigsError

An operator-readable failure that is safe to construct inside a workflow.

#### Extends

- `Error`

#### Constructors

##### Constructor

> **new JigsError**(`message`, `hint?`): [`JigsError`](#jigserror)

###### Parameters

###### message

`string`

###### hint?

`string`

###### Returns

[`JigsError`](#jigserror)

###### Overrides

`Error.constructor`

#### Properties

##### hint?

> `readonly` `optional` **hint**: `string`

What the reader can do about it. Quote each command to run in backticks, as in
``stop the service first: `pnpm exec jigs service stop` ``: the CLI prints it on its own line.

***

### JitCheckError

A failed just-in-time tool check, with repair details for each failure.

#### Extends

- `Error`

#### Constructors

##### Constructor

> **new JitCheckError**(`failures`): [`JitCheckError`](#jitcheckerror)

###### Parameters

###### failures

`object` & `object`[]

###### Returns

[`JitCheckError`](#jitcheckerror)

###### Overrides

`Error.constructor`

#### Properties

##### failures

> `readonly` **failures**: `object` & `object`[]

***

### interpolate()

> **interpolate**(`template`, `values`): `string`

Replace named `{{ placeholders }}` once, leaving unknown names unchanged.

#### Parameters

##### template

`string`

##### values

`Record`\<`string`, `string`\>

#### Returns

`string`

***

### unreachable()

> **unreachable**(`value`): `never`

Fail an exhaustive branch if an unexpected value reaches it at runtime.

#### Parameters

##### value

`never`

#### Returns

`never`

## Factory plumbing

### AgentRequest

> **AgentRequest** = `Omit`\<[`RunAgentOptions`](#runagentoptions), `"output"`\> & `object` \| `Omit`\<[`AskAgentOptions`](#askagentoptions), `"output"`\> & `object`

Serializable agent request passed to a durable step.

***

### ModelRequest

> **ModelRequest** = `Omit`\<[`AskModelOptions`](#askmodeloptions), `"output"`\> & `object`

Serializable API model request passed to a durable step.

#### Type Declaration

##### outputSchema?

> `optional` **outputSchema**: [`OutputJsonSchema`](#outputjsonschema)

## Linear agent sessions

### LinearAgentConversationOptions

How a Linear agent conversation runs: the Claude harness and the worktree it works in.

#### Remarks

`instructions` lead the first message Claude reads, which carries Linear's context for the
session when Linear sends one. The conversation ends once no one has replied for `idleFor`, a duration such
as `"30m"` or milliseconds; four hours by default.

#### Properties

##### cwd

> **cwd**: `string`

##### harness

> **harness**: [`Harness`](#harness-3)

##### idleFor?

> `optional` **idleFor**: `number` \| `` `${number}s` `` \| `` `${number}d` `` \| `` `${number}h` `` \| `` `${number}m` ``

##### instructions?

> `optional` **instructions**: `string`

***

### LinearAgentConversationResult

> **LinearAgentConversationResult** = \{ `outcome`: `"idle"` \| `"stopped"`; `turns`: `number`; \} \| \{ `error`: `string`; `outcome`: `"failed"`; `turns`: `number`; \}

How a Linear agent conversation ended, and how many turns it ran.

## Type Aliases

### ApprovalCoverage

> **ApprovalCoverage** = `"latest-commit"` \| `"any-commit"`

Which commits an approving review covers, chosen in workflow code.

#### Remarks

`latest-commit`, the default, counts an approval only on the commit it names, so a push
withdraws it. `any-commit` keeps a person's approval counting through later pushes until a
later review requests changes or the approval is dismissed; approvals by a bot, such as an
agent acting as the factory's GitHub App, never count.

***

### MergeConsent

> **MergeConsent** = `"operator"` \| `"workflow"`

Whose consent a merge needs, chosen in workflow code for each merge.

#### Remarks

`operator`, the default, needs a person's approving review. `workflow` lets the
workflow's own checks stand in for it, for a workflow that judges a pull request itself, such as
one that tests a dependency update before merging it. Every other merge requirement still holds,
and a review requesting changes still stops the merge.
