# @jigs-ai/jigs v0.110.4

Low-level Linear operations for factory-owned steps. `#jigs/steps` wraps the ones
jigs routines and recipes use, such as `postTicketNote`; call the rest, such as
`createComment`, from your own `"use step"` function. Higher-level waiting such as
`haltForHuman` comes from `#jigs/routines`.

See [Waiting and external events](https://salimhamed.github.io/jigs/guide/waiting-and-events).

## Resolve and read

### LinearIssueMatch

A matching Linear ticket returned by a project title search.

#### Properties

##### description

> **description**: `string`

##### id

> **id**: `string`

##### identifier

> **identifier**: `string`

##### state

> **state**: `string`

##### title

> **title**: `string`

##### url

> **url**: `string`

***

### FindIssueInput

> **FindIssueInput** = [`IssuePlace`](#issueplace) & `object`

A search for the newest ticket whose title starts with `titlePrefix`.

#### Type Declaration

##### titlePrefix

> **titlePrefix**: `string`

***

### fetchTicketSnapshot()

> **fetchTicketSnapshot**(`__namedParameters`): `Promise`\<`TicketSnapshot`\>

Read the ticket’s current details and discussion.

#### Parameters

##### \_\_namedParameters

###### installationName

`string`

###### issueId

`string`

#### Returns

`Promise`\<`TicketSnapshot`\>

***

### findIssue()

> **findIssue**(`__namedParameters`): `Promise`\<[`LinearIssueMatch`](#linearissuematch) \| `null`\>

Find the newest ticket in a team or project whose title starts with the given text.

#### Parameters

##### \_\_namedParameters

[`FindIssueInput`](#findissueinput) & `object`

#### Returns

`Promise`\<[`LinearIssueMatch`](#linearissuematch) \| `null`\>

***

### resolveLinearIssue()

> **resolveLinearIssue**(`__namedParameters`): `Promise`\<`LinearIssueRef`\>

Resolve a Linear identifier or issue ID before claiming or reading the ticket.

#### Parameters

##### \_\_namedParameters

###### installationName

`string`

###### reference

`string`

#### Returns

`Promise`\<`LinearIssueRef`\>

## Create and update

### TicketStatusResult

The before-and-after state names from a ticket status update.

#### Properties

##### changed

> **changed**: `boolean`

##### from

> **from**: `string`

##### to

> **to**: `string`

***

### CreateIssueInput

> **CreateIssueInput** = [`IssuePlace`](#issueplace) & `object`

A new Linear ticket. `status` is a workflow status name such as `Triage`; without one, Linear
picks the team's default. `labels` are names from the team or the whole workspace.

#### Type Declaration

##### description

> **description**: `string`

##### labels?

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

##### status?

> `optional` **status**: `string`

##### title

> **title**: `string`

***

### IssuePlace

> **IssuePlace** = \{ `project?`: `string`; `team`: `string`; \} \| \{ `project`: `string`; `team?`: `string`; \}

Where a Linear ticket lives: a team (key such as `ENG`, name or id), a project (id or the slug
its URL ends in), or both. Without a team, the project's first team.

***

### createComment()

> **createComment**(`__namedParameters`): `Promise`\<\{ `createdAt`: `string`; `id`: `string`; \}\>

Post a comment on a ticket. An `id` (UUID v4) names the comment in advance, so a caller can
find it again after a lost response instead of posting twice.

#### Parameters

##### \_\_namedParameters

###### body

`string`

###### id?

`string`

###### installationName

`string`

###### issueId

`string`

#### Returns

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

***

### createIssue()

> **createIssue**(`__namedParameters`): `Promise`\<\{ `id`: `string`; `identifier`: `string`; `url`: `string`; \}\>

Create a ticket in a team, a project or both, optionally with a status and labels.

#### Parameters

##### \_\_namedParameters

[`CreateIssueInput`](#createissueinput) & `object`

#### Returns

`Promise`\<\{ `id`: `string`; `identifier`: `string`; `url`: `string`; \}\>

#### Example

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

export async function fileFinding(title: string, description: string) {
  "use step";
  return createIssue({ installationName: "linear-acme", team: "ENG", status: "Triage", title, description });
}
```

***

### setTicketStatus()

> **setTicketStatus**(`__namedParameters`): `Promise`\<[`TicketStatusResult`](#ticketstatusresult)\>

Set a ticket to one of its team's named states.

#### Parameters

##### \_\_namedParameters

###### installationName

`string`

###### issueId

`string`

###### stateName

`string`

#### Returns

`Promise`\<[`TicketStatusResult`](#ticketstatusresult)\>

## Human interaction primitives

### postTicketHumanInputRequest()

> **postTicketHumanInputRequest**(`__namedParameters`, `metadata`, `render`): `Promise`\<`void`\>

Ask in the run's Linear agent session for a person to help the run continue.

#### Parameters

##### \_\_namedParameters

###### halt

`Halt`

###### installationName

`string`

###### issueId

`string`

###### sessionId

`string`

##### metadata

`StepRunMetadata`

##### render

[`RenderHumanInputRequest`](#renderhumaninputrequest) = `renderHumanInputRequest`

#### Returns

`Promise`\<`void`\>

#### Remarks

Posts the halt as an elicitation, which shows the session as waiting for input. Mentions the
factory's `linear.operator`, or the ticket's creator when it is not set, then the assignee and
the halt's `mention` emails, each person once. A person Linear cannot find is skipped with a
warning; the question always posts. A changed operator takes effect when the service restarts,
which `jigs up` does.

***

### postTicketNote()

> **postTicketNote**(`__namedParameters`, `metadata`, `render`): `Promise`\<`void`\>

Tell ticket participants something in the run's Linear agent session, without waiting for a
reply.

#### Parameters

##### \_\_namedParameters

###### installationName

`string`

###### issueId

`string`

###### note

`TicketNote`

###### sessionId

`string`

##### metadata

`StepRunMetadata`

##### render

[`RenderTicketNote`](#renderticketnote) = `renderTicketNote`

#### Returns

`Promise`\<`void`\>

#### Remarks

A note that ends the run is the session's final response, even for a failure: Linear offers
Retry on a session that ends in an error, and a run that has ended cannot take it. A note
that waits on people is an elicitation, which shows the session as awaiting input. Any other
note is a response followed by a short thought, which keeps the session working so Stop still
ends the run. Mentions in each of them notify. Mentions the same people as
[postTicketHumanInputRequest](#posttickethumaninputrequest), with the note's `mention` emails as the extras.

## Rendering/customization

### HumanInputContext

> **HumanInputContext** = `object`

What the question's footer says about the run that asked it. The factory's
step wrapper builds it from the Workflow SDK's metadata, which the workflow
cannot see. Where the run paused belongs to the halt, not the context: only
the routine that raised it knows.

#### Properties

##### runId

> **runId**: `string`

##### workflow?

> `optional` **workflow**: `string`

***

### RenderHumanInputRequest()

> **RenderHumanInputRequest** = (`halt`, `context`, `participants`) => `string`

Renders the question that asks a person to unblock a run.

#### Parameters

##### halt

`Halt`

##### context

[`HumanInputContext`](#humaninputcontext)

##### participants

[`TicketParticipants`](#ticketparticipants)

#### Returns

`string`

***

### RenderTicketNote()

> **RenderTicketNote** = (`note`, `participants`) => `string`

Renders a note for ticket participants that asks for nothing.

#### Parameters

##### note

`TicketNote`

##### participants

[`TicketParticipants`](#ticketparticipants)

#### Returns

`string`

***

### TicketParticipants

> **TicketParticipants** = `object`

Who the message is for. `mentions` is the final list the message greets, in
order and each person once: the operator (or, without one, the ticket's
creator), the assignee, then any extra people the step was asked to mention.
A custom renderer greets `mentions` rather than working it out again; the
other fields are there for context and may be null.

#### Properties

##### assignee

> **assignee**: `LinearProfile` \| `null`

##### creator

> **creator**: `LinearProfile` \| `null`

##### mentions

> **mentions**: `LinearProfile`[]

##### operator

> **operator**: `LinearProfile` \| `null`

The configured operator, or null when none is set or Linear could not find them.

***

### renderHumanInputRequest

> `const` **renderHumanInputRequest**: [`RenderHumanInputRequest`](#renderhumaninputrequest)

Render the default question as Linear Markdown.

***

### renderTicketNote

> `const` **renderTicketNote**: [`RenderTicketNote`](#renderticketnote)

Render the default ticket note as Linear Markdown.

## Linear agent sessions

### LinearAgentActivityContent

> **LinearAgentActivityContent** = \{ `body`: `string`; `type`: `"thought"`; \} \| \{ `action`: `string`; `parameter`: `string`; `result?`: `string`; `type`: `"action"`; \} \| \{ `body`: `string`; `type`: `"elicitation"`; \} \| \{ `body`: `string`; `type`: `"response"`; \} \| \{ `body`: `string`; `type`: `"error"`; \}

What the factory's app posts into a Linear agent session. A `thought` or an `action` shows
progress; an `elicitation` asks the person for input; a `response` or an `error` ends the
app's turn, and Linear waits for the person.

***

### LinearAgentPrompt

> **LinearAgentPrompt** = `object`

One message a person sent into a Linear agent session, oldest first when listed.

#### Remarks

`signal` is null for a plain reply and `"stop"` when the person pressed stop; Linear also names
`continue`, `auth` and `select`. `sourceCommentId` is the comment the reply was written as, and
is null for a stop.

#### Properties

##### author

> **author**: `object`

###### id

> **id**: `string`

###### name

> **name**: `string`

##### body

> **body**: `string`

##### createdAt

> **createdAt**: `string`

##### id

> **id**: `string`

##### signal

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

##### sourceCommentId

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

***

### executeLinearAgentTurn()

> **executeLinearAgentTurn**(`request`, `metadata`, `deps`): `Promise`\<`TurnStepResult`\>

Run one turn of a conversation in a Linear agent session.

#### Parameters

##### request

[`LinearAgentTurnRequest`](#linearagentturnrequest)

##### metadata

`StepRunMetadata`

##### deps

`LinearAgentTurnDeps` = `defaultDeps`

#### Returns

`Promise`\<`TurnStepResult`\>

#### Remarks

The turn takes the opening mention, if given, and every reply in the session not in
`consumed`, so a retry takes the replies that arrived while the turn ran. A stop among them
ends the turn `stopped` before it starts. While the turn runs, a status line is posted as an
ephemeral thought, at most every five seconds, and each answer is posted as a response once
written.

***

### listLinearAgentSessionPrompts()

> **listLinearAgentSessionPrompts**(`__namedParameters`): `Promise`\<[`LinearAgentPrompt`](#linearagentprompt)[]\>

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

#### Parameters

##### \_\_namedParameters

###### installationName

`string`

###### sessionId

`string`

#### Returns

`Promise`\<[`LinearAgentPrompt`](#linearagentprompt)[]\>

#### Remarks

The mention that opened the session is not one of them. A message whose `signal` is `"stop"` is
the person pressing stop.

***

### openLinearAgentSession()

> **openLinearAgentSession**(`__namedParameters`, `metadata`): `Promise`\<\{ `sessionId`: `string`; \}\>

Open a Linear agent session on an issue as the factory's app, showing the run's dashboard when
the service hosts one, and return its id.

#### Parameters

##### \_\_namedParameters

###### installationName

`string`

###### issueId

`string`

##### metadata

`RunMetadata`

#### Returns

`Promise`\<\{ `sessionId`: `string`; \}\>

#### Remarks

Linear starts the session at once. Its create call takes no id of its own, so a retry after a
lost response may open a second session.

***

### postLinearAgentActivity()

> **postLinearAgentActivity**(`__namedParameters`, `metadata`): `Promise`\<\{ `createdAt`: `string`; `id`: `string`; \}\>

Post an activity into a Linear agent session as the factory's app.

#### Parameters

##### \_\_namedParameters

###### content

[`LinearAgentActivityContent`](#linearagentactivitycontent)

###### ephemeral?

`boolean`

###### installationName

`string`

###### once?

`string`

###### sessionId

`string`

##### metadata

`Pick`\<`StepRunMetadata`, `"workflowRunId"` \| `"stepId"`\>

#### Returns

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

#### Remarks

Only a `thought` or an `action` may be `ephemeral`; Linear replaces an ephemeral activity with
the next one. Every retry of one step posts the same activity, so a lost response never posts
it twice. With `once`, the activity is posted at most once per key in the session, from any
step.

***

### setLinearAgentSessionUrls()

> **setLinearAgentSessionUrls**(`__namedParameters`, `metadata`): `Promise`\<`void`\>

Replace the links a Linear agent session shows, such as a pull request. The run's dashboard
comes first when the service hosts one.

#### Parameters

##### \_\_namedParameters

###### installationName

`string`

###### sessionId

`string`

###### urls

`object`[]

##### metadata

`RunMetadata`

#### Returns

`Promise`\<`void`\>

## Type Aliases

### LinearAgentTurnRequest

> **LinearAgentTurnRequest** = `object`

One turn of a conversation in a Linear agent session: the harness and worktree it runs in, the
mention that opened the session until a turn takes it, and `consumed`, the ids of the messages
earlier turns took. The turn takes every newer reply in the session.

#### Properties

##### consumed

> **consumed**: `string`[]

##### cwd

> **cwd**: `string`

##### harness

> **harness**: `Harness`

##### installationName

> **installationName**: `string`

##### instructions?

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

##### opening?

> `optional` **opening**: `ConversationMessage`

##### sessionId

> **sessionId**: `string`
