# zidane-ui/channels/headless

Import: `import { … } from 'zidane-ui/channels/headless'`. Source: [ui/src/channels/headless/index.ts](https://github.com/Tahul/zidane/blob/main/ui/src/channels/headless/index.ts).

## Functions

### `createChannelsHost`

Function.

Creates a [`ChannelsHostState`](https://zidane.si/docs/reference/ui-channels-headless.md#ChannelsHostState) over a backend. A member whose method the backend does not offer is left out.

```ts
function createChannelsHost(backend: ChannelsBackend): ChannelsHostState
```

**Parameters**

- `backend` (`ChannelsBackend`): The host's channels methods.

**Returns** `ChannelsHostState`

Source: [ui/src/channels/headless/state.ts:321](https://github.com/Tahul/zidane/blob/main/ui/src/channels/headless/state.ts#L321)

## Classes

### `ChannelsActionError`

Class.

An error a [`ChannelsHost`](https://zidane.si/docs/reference/ui-channels-headless.md#ChannelsHost) action rejects with: its [`ChannelsError`](https://zidane.si/docs/reference/ui-channels-headless.md#ChannelsError) in `error`.

```ts
class ChannelsActionError extends Error
```

**Constructor**

```ts
new ChannelsActionError(error: ChannelsError)
```

**Parameters**

- `error` (`ChannelsError`): What failed.

**Returns** `ChannelsActionError`

**Properties**

- `error` (`ChannelsError`, readonly): What failed, for the labels.

Source: [ui/src/channels/headless/host.ts:140](https://github.com/Tahul/zidane/blob/main/ui/src/channels/headless/host.ts#L140)

## Constants

### `CHANNELS_METHODS`

Constant.

Every [`ChannelsMethod`](https://zidane.si/docs/reference/ui-channels-headless.md#ChannelsMethod), for a transport that lists what it forwards.

```ts
const CHANNELS_METHODS: readonly ('projects.readiness' | 'channels.bindings.testAs' | 'channels.connections.list' | 'channels.connections.get' | 'channels.connections.create' | 'channels.connections.update' | 'channels.connections.remove' | 'channels.connections.status' | 'channels.connections.slackManifest' | 'channels.connections.slackCredentials' | 'channels.connections.slackInstall' | 'channels.connections.githubManifest' | 'channels.bindings.list' | 'channels.runsOn' | 'channels.bindings.put' | 'channels.bindings.remove' | 'channels.bindings.enable' | 'channels.conversations' | 'channels.defaultProject' | 'channels.held.list' | 'channels.held.release' | 'channels.alerts.list' | 'channels.agent.get' | 'channels.agent.set')[]
```

Source: [ui/src/channels/headless/host.ts:77](https://github.com/Tahul/zidane/blob/main/ui/src/channels/headless/host.ts#L77)

## Interfaces

### `AccessPolicy`

Interface.

A level with some of its rules changed.

```ts
interface AccessPolicy
```

**Properties**

- `agent?` (`string`): Agent profile id the session runs (overrides the binding's).
- `approvals?` (`'off' | 'ask' | 'decide'`): How tool calls are approved: 'ask' (the channel's owners answer), 'decide' (a model decides), 'off' (never asked). Absent: the host's approval mode.
- `approvalTimeout?` (`number | 'never'`): Minutes a pending approval waits before it is denied; 'never' waits until answered.
- `budget?` (`{ minutes?: number; usd?: number }`): Per-run ceilings: cost in US dollars, wall time in minutes.
- `extends?` (`AccessLevel`): The level this policy starts from. Absent: the level the outer layers gave (an owner with none starts from 'full'; a member must have one).
- `readDeny?` (`false | 'host-secrets'`): 'host-secrets': read tools refuse the host's secret paths. `false` lifts it.
- `toolset?` (`'host' | 'profile-only'`): 'profile-only': the agent gets only its profile's tools and MCP servers, none the host or the folder adds (session policy `toolset`). 'host' lifts it. Absent: what the outer layers gave; no level sets it.

Source: [dist/pure-ET4-8JZg.d.ts:17845](https://github.com/Tahul/zidane/blob/main/dist/pure-ET4-8JZg.d.ts#L17845)

### `ChannelAlert`

Interface.

One open incident a person is told about once (docs/CHANNELS.md § Alerts): an app notification and a Slack DM.

```ts
interface ChannelAlert
```

**Properties**

- `at` (`number`): When it opened, Unix ms.
- `connectionId?` (`string`): The connection, for a connection's incident.
- `detail?` (`string`): More, when the title isn't enough.
- `fix?` (`ReadinessFix`): The readiness fix.
- `id` (`string`): The incident's key: the same incident is told once, and clears on recovery.
- `kind` (`ChannelAlertKind`): What it is about.
- `projectId?` (`string`): The project, for a project's incident.
- `title` (`string`): One short line.

Source: [dist/pure-ET4-8JZg.d.ts:9098](https://github.com/Tahul/zidane/blob/main/dist/pure-ET4-8JZg.d.ts#L9098)

### `ChannelBinding`

Interface.

A maintainer's binding: one project's conversations through one connection.

```ts
interface ChannelBinding
```

**Properties**

- `access` (`BindingAccessRules`): What members and guests get.
- `accessToSet?` (`boolean`): `true`: imported from a config file whose access was a function, so it came in off. It stays off until a
  maintainer sets its `access` (a put with `access` clears it).
- `connectionId` (`string | null`): The connection it runs through. `null`: a draft that still needs one (a published project's).
- `createdAt` (`number`): Creation time, Unix ms.
- `createdBy` (`string`): The user id that made it.
- `draft` (`boolean`): A published project's binding that waits for a maintainer to map it to a connection. Never runs.
- `enabled` (`boolean`): `false`: kept, but off.
- `environment?` (`ChannelBindingEnvironment`): Where its sessions run (see [`ChannelBindingEnvironment`](https://zidane.si/docs/reference/ui-channels-headless.md#ChannelBindingEnvironment)). Absent: `worktree`.
- `handoff?` (`boolean`): `false`: the org's Agent may not start threads here (docs/CHANNELS.md § The Agent). Absent: it may (a channel binding).
- `id` (`string`): `bind_` + 12 hex.
- `identity?` (`BindingIdentity`): Name and icon overrides.
- `inherit?` (`boolean`): `true`: its sessions take the project's own inherit rules. Absent: they run project-only for every kind
  (`lockedForChannel`), the default.
- `limits?` (`Limits`): Throttles over the defaults (`concurrentRuns`, `runsPerMemberPerHour`).
- `match` (`ChannelBindingMatch`): The conversations it takes. One binding per Slack channel or repository per connection.
- `profileId?` (`string`): A profile of the project (`projects.content`, kind `profile`) its sessions run. Absent: the project's own agent.
- `projectId` (`string`): The project its sessions belong to (and are owned by).
- `publishedFrom?` (`{ bindingId: string; hostId: string }`): A draft's origin: the publishing host and its binding there, which turns off once this one runs (docs/CHANNELS.md § Published projects).
- `updatedAt` (`number`): Last change, Unix ms.
- `version` (`number`): Grows by one with each change: a write that names an older one is refused.

Source: [dist/pure-ET4-8JZg.d.ts:18022](https://github.com/Tahul/zidane/blob/main/dist/pure-ET4-8JZg.d.ts#L18022)

### `ChannelConnection`

Interface.

An admin's connection, as a list answers it. Never carries a secret's value: `secrets` names those it holds.

```ts
interface ChannelConnection
```

**Properties**

- `createdAt` (`number`): Creation time, Unix ms.
- `createdBy` (`string`): The user id that made it.
- `enabled` (`boolean`): `false`: kept, but off.
- `github?` (`GithubConnectionInfo`): GitHub facts.
- `id` (`string`): `conn_` + 12 hex: stable, never reused.
- `localUsers?` (`string[]`): A laptop's own provider accounts (Slack user ids, GitHub logins): the laptop has one person, and these are theirs.
  A server ignores it: there a person links their account (docs/IDENTITY.md, Linked accounts).
- `name` (`string`): Its name: letters, digits, `-` and `_`, unique on the host. It names the webhook routes (`/channels/<name>/…`).
- `provider` (`ChannelConnectionProvider`): Which provider it talks to.
- `replaces?` (`string`): The connection it replaces once it is ready (`ChannelConnectionInput.replaces`). Cleared when the replacement is done.
- `secrets` (`('botToken' | 'appToken' | 'signingSecret' | 'clientSecret' | 'privateKey' | 'webhookSecret')[]`): The secrets it holds, by key. Their values never leave the host.
- `shared` (`ChannelConnectionShare`): The projects it serves. Default `all`.
- `slack?` (`SlackConnectionInfo`): Slack facts.
- `status` (`ChannelConnectionStatus`): Its setup (computed from what it holds, and `enabled`).
- `transport` (`ChannelConnectionTransport`): How it hears its provider. GitHub is always `http`.
- `updatedAt` (`number`): Last change, Unix ms.
- `version` (`number`): Grows by one with each change: a write that names an older one is refused.

Source: [dist/pure-ET4-8JZg.d.ts:17916](https://github.com/Tahul/zidane/blob/main/dist/pure-ET4-8JZg.d.ts#L17916)

### `ChannelIpcMethods`

Interface.

The `channels.*` methods of `import('./protocol').IpcMethods` (docs/CHANNELS.md § Methods), with the host's
`projects.readiness` (`ProjectIpcMethods`), which the channels compute: a channels client reaches all it needs here.

```ts
interface ChannelIpcMethods extends Pick<ProjectIpcMethods, 'projects.readiness'>
```

**Properties**

- `channels.agent.get` (`{ params: Record<string, never>; result: ChannelAgent | null }`): The org's Agent, or `null` when there is none yet. Anyone. Additive.
- `channels.agent.set` (`{ params: { enabled: boolean }; result: ChannelAgent }`): Turns the org's Agent on or off. Admins. Additive.
- `channels.alerts.list` (`{ params: Record<string, never>; result: ChannelAlert[] }`): The caller's open channel alerts (docs/CHANNELS.md § Alerts). Additive.
- `channels.bindings.enable` (`{ params: { bindingId: string; enabled: boolean; id: string }; result: ChannelBinding }`): Turns a binding on or off. Maintainers. Additive.
- `channels.bindings.list` (`{ params: { id: string }; result: ChannelBindingsView }`): A project's bindings and the connections shared with it. A project's members. Additive.
- `channels.bindings.put` (`{ params: { binding: ChannelBindingInput; id: string }; result: ChannelBinding }`): Makes or changes a binding of the project `id`. Maintainers. Additive.
- `channels.bindings.remove` (`{ params: { bindingId: string; id: string }; result: void }`): Removes a binding. Maintainers. Additive.
- `channels.bindings.testAs` (`{ params: { as: TestAsKind; bindingId: string }; result: { sessionId: string } }`): Opens a private session for the caller that runs with the binding's exact rules for a member or a guest
  (docs/CHANNELS.md § Test as). Marked `metadata.test = { bindingId, as }`; no budget source. Maintainers. Additive.
- `channels.connections.create` (`{ params: ChannelConnectionInput; result: ChannelConnection }`): Makes a connection (pending until it holds its credentials). Admins. Additive.
- `channels.connections.get` (`{ params: { id: string }; result: ChannelConnection | null }`): One connection, or `null`. Admins. Additive.
- `channels.connections.githubManifest` (`{ params: { id: string; organization?: string }; result: GithubManifestResult }`): Starts GitHub's App Manifest flow for a GitHub connection: GitHub comes back to this server, which stores the App's id, key and webhook secret. Admins. Additive.
- `channels.connections.list` (`{ params: Record<string, never>; result: ChannelConnection[] }`): Every connection, without secrets. Admins (on a laptop, its user). Additive.
- `channels.connections.remove` (`{ params: { force?: boolean; id: string }; result: void }`): Removes a connection and its secrets. Refused while bindings run through it, unless `force` (they become drafts). Admins. Additive.
- `channels.connections.slackCredentials` (`{ params: { appId: string; appToken?: string; botToken?: string; clientId: string; clientSecret: string; id: string; signingSecret?: string }; result: ChannelConnection }`): Saves a Slack app's credentials once (they go to the secret store, never back). With `botToken` (the app
  installed from Slack's own page) the connection is ready at once; otherwise `slackInstall` follows. Admins. Additive.
- `channels.connections.slackInstall` (`{ params: { id: string }; result: { url: string } }`): The "Add to Slack" URL of a connection with credentials: Slack comes back to this server, which stores the bot token. Admins. Additive.
- `channels.connections.slackManifest` (`{ params: { connectionId?: string; iconUrl?: string; name: string; transport: ChannelConnectionTransport }; result: SlackManifestResult }`): A Slack app manifest for Socket Mode or HTTP (with this server's URLs for `connectionId`), and Slack's create link. Admins. Additive.
- `channels.connections.status` (`{ params: Record<string, never>; result: ChannelConnectionState[] }`): Each connection's live state, with why a pending one does not start. Admins. Additive.
- `channels.connections.update` (`{ params: { id: string; patch: ChannelConnectionPatch }; result: ChannelConnection }`): Changes a connection: name, transport, sharing, on or off. A changed transport or token restarts it. Admins. Additive.
- `channels.conversations` (`{ params: { connectionId: string; id: string }; result: ChannelConversation[] }`): The Slack channels a connection's app is in, for the binding picker. A project's maintainers. Additive.
- `channels.defaultProject` (`{ params: { connectionId: string; projectId: string | null }; result: void }`): Sets (`null`: clears) the caller's default project for a connection's DMs and unbound mentions. Additive.
- `channels.held.list` (`{ params: { id: string }; result: HeldPost[] }`): The project's posts held for review (docs/CHANNELS.md § Outbound filter), oldest first. Maintainers. Additive.
- `channels.held.release` (`{ params: { as: HeldRelease; heldId: string; id: string }; result: void }`): Sends a held post as it was, sends it with its credential-like parts redacted, or drops it. Audited. Maintainers. Additive.
- `channels.linkPrompts` (`{ params: { bindingId: string; id: string }; result: { sent: number } }`): The bot DMs each person in the binding's Slack channel with no linked zidane account a link to link it. Maintainers. Additive.
- `channels.retention` (`{ params: { keepLeavers?: boolean }; result: { keepLeavers: boolean } }`): Reads, and with `keepLeavers` sets, the organization's retention flag: keep the DM sessions of people who left. Admins. Additive.
- `channels.runsOn` (`{ params: { id: string }; result: ChannelRunsOn }`): Where the project's channel sessions can run, and what Automatic picks now. A project's members. Additive.
- `projects.readiness` (`{ params: { id: string }; result: ReadinessItem[] }`, from `Pick`): The project's readiness checklist (docs/CHANNELS.md § Readiness checks): what its channels compute; none without channels. A member reads it. Additive.

Source: [dist/pure-ET4-8JZg.d.ts:18191](https://github.com/Tahul/zidane/blob/main/dist/pure-ET4-8JZg.d.ts#L18191)

### `ChannelRunsOn`

Interface.

Where a project's channel sessions can run on this host (`channels.runsOn`), for the binding's picker.

```ts
interface ChannelRunsOn
```

**Properties**

- `automatic` (`{ environment: string } | { reason: string }`): What Automatic picks now (an environment kind), or why nothing can run.
- `machines` (`{ name: string; status: 'online' | 'offline'; worktrees: boolean }[]`): The host's machines.
- `server` (`string`): The host's name.
- `serverRuns` (`boolean`): The host runs sessions in its own folders (a laptop; a server with `selfMachine` on).
- `serverWorktrees` (`boolean`): The host makes worktrees in its own folders.

Source: [dist/pure-ET4-8JZg.d.ts:17960](https://github.com/Tahul/zidane/blob/main/dist/pure-ET4-8JZg.d.ts#L17960)

### `ChannelsAgent`

Interface.

The org's Agent (docs/CHANNELS.md § The Agent): read with `channels.agent.get`, read again on `channels:changed`
without a project. Anyone reads it; admins turn it on or off.

```ts
interface ChannelsAgent
```

**Properties**

- `ensure` (`() => void`): Reads it once, the first time something shows it. Never rejects.
- `error` (`Readable<ChannelsError | null>`): Why the last read failed, or `null`.
- `refresh` (`() => Promise<void>`): Reads it again. Rejects with a [`ChannelsActionError`](https://zidane.si/docs/reference/ui-channels-headless.md#ChannelsActionError).
- `set?` (`(enabled: boolean) => Promise<ChannelAgent>`): Turns it on or off. Absent: no switch.
- `view` (`Readable<ChannelAgent | null | undefined>`): The Agent, `null` when there is none yet (no Slack app is ready), `undefined` until read.

Source: [ui/src/channels/headless/host.ts:272](https://github.com/Tahul/zidane/blob/main/ui/src/channels/headless/host.ts#L272)

### `ChannelsAlerts`

Interface.

The caller's open channel alerts (docs/CHANNELS.md § Alerts): read with `channels.alerts.list`, then kept live by
`channels:alert` (an opened alert is added, a cleared one removed). The host sends a person only their own.

```ts
interface ChannelsAlerts
```

**Properties**

- `ensure` (`() => void`): Reads them once, the first time something shows them. Never rejects.
- `error` (`Readable<ChannelsError | null>`): Why the last read failed, or `null`.
- `list` (`Readable<readonly ChannelAlert[] | null>`): The open alerts, oldest first: `null` until read.
- `refresh` (`() => Promise<void>`): Reads them again. Rejects with a [`ChannelsActionError`](https://zidane.si/docs/reference/ui-channels-headless.md#ChannelsActionError).
- `runFix?` (`(fix: { kind: 'method'; label: string; method: string; params: Record<string, unknown> }) => Promise<void>`): Runs an alert's method fix, then reads the alerts again. Absent: method fixes show without a button.

Source: [ui/src/channels/headless/host.ts:255](https://github.com/Tahul/zidane/blob/main/ui/src/channels/headless/host.ts#L255)

### `ChannelsBackend`

Interface.

The transport under a channels host: one call per protocol method, and which ones the host offers. Each app
implements it once (zidane-server's client, the desktop app's IPC, a fixture).

```ts
interface ChannelsBackend
```

**Properties**

- `call` (`<M extends 'projects.readiness' | 'channels.bindings.testAs' | 'channels.connections.list' | 'channels.connections.get' | 'channels.connections.create' | 'channels.connections.update' | 'channels.connections.remove' | 'channels.connections.status' | 'channels.connections.slackManifest' | 'channels.connections.slackCredentials' | 'channels.connections.slackInstall' | 'channels.connections.githubManifest' | 'channels.bindings.list' | 'channels.runsOn' | 'channels.bindings.put' | 'channels.bindings.remove' | 'channels.bindings.enable' | 'channels.conversations' | 'channels.defaultProject' | 'channels.held.list' | 'channels.held.release' | 'channels.alerts.list' | 'channels.agent.get' | 'channels.agent.set'>(method: M, params: ChannelsParams<M>) => Promise<ChannelsResult<M>>`): Calls a method. Rejects with the host's error (the adapter's own type; `classify` words it).
- `can` (`(method: 'projects.readiness' | 'channels.bindings.testAs' | 'channels.connections.list' | 'channels.connections.get' | 'channels.connections.create' | 'channels.connections.update' | 'channels.connections.remove' | 'channels.connections.status' | 'channels.connections.slackManifest' | 'channels.connections.slackCredentials' | 'channels.connections.slackInstall' | 'channels.connections.githubManifest' | 'channels.bindings.list' | 'channels.runsOn' | 'channels.bindings.put' | 'channels.bindings.remove' | 'channels.bindings.enable' | 'channels.conversations' | 'channels.defaultProject' | 'channels.held.list' | 'channels.held.release' | 'channels.alerts.list' | 'channels.agent.get' | 'channels.agent.set') => boolean`): Whether the host offers a method. A method it does not offer hides what needs it.
- `classify?` (`(err: unknown) => ChannelsError`): Words a rejection. Default: `failed` with its message.
- `publicUrl?` (`boolean`): The host serves https webhooks at a public URL, so a Slack app can use HTTP instead of Socket Mode. Default false.
- `runFix?` (`(method: string, params: Record<string, unknown>) => Promise<unknown>`): Calls the method a readiness fix names (`fix.kind === 'method'`): any method of the host, checked there like any
  other call. Absent: method fixes are not offered.

Source: [ui/src/channels/headless/host.ts:157](https://github.com/Tahul/zidane/blob/main/ui/src/channels/headless/host.ts#L157)

### `ChannelsBindings`

Interface.

Project settings › Channels: a project's bindings. Members read; maintainers change.

```ts
interface ChannelsBindings
```

**Properties**

- `conversations?` (`(projectId: string, connectionId: string) => Promise<ChannelConversation[]>`): The Slack channels a connection's app is in. Absent: the channel is typed by hand.
- `enable?` (`(projectId: string, bindingId: string, enabled: boolean) => Promise<ChannelBinding>`): Turns a binding on or off. Absent: no switch.
- `ensure` (`(projectId: string) => void`): Reads a project's bindings once, the first time something shows them. Never rejects.
- `error` (`(projectId: string) => Readable<ChannelsError | null>`): Why the last read of a project failed, or `null`.
- `put?` (`(projectId: string, binding: ChannelBindingInput) => Promise<ChannelBinding>`): Makes or changes a binding. Absent: read-only.
- `refresh` (`(projectId: string) => Promise<void>`): Reads them again. Rejects with a [`ChannelsActionError`](https://zidane.si/docs/reference/ui-channels-headless.md#ChannelsActionError).
- `remove?` (`(projectId: string, bindingId: string) => Promise<void>`): Removes a binding. Absent: no Remove.
- `runsOn?` (`(projectId: string) => Promise<ChannelRunsOn>`): Where the project's channel sessions can run on the host, and what Automatic picks now: the binding's picker.
- `view` (`(projectId: string) => Readable<ChannelBindingsView | null>`): A project's bindings and the connections shared with it: `null` until read. One store per project.

Source: [ui/src/channels/headless/host.ts:216](https://github.com/Tahul/zidane/blob/main/ui/src/channels/headless/host.ts#L216)

### `ChannelsConnections`

Interface.

Settings › Channels: the host's connections, admins only (on a laptop, its user).

```ts
interface ChannelsConnections
```

**Properties**

- `create?` (`(input: ChannelConnectionInput) => Promise<ChannelConnection>`): Makes a connection (pending until it holds its credentials). Absent: no Add.
- `ensure` (`() => void`): Reads the list and the states once, the first time something shows them. Never rejects.
- `error` (`Readable<ChannelsError | null>`): Why the last read failed, or `null`.
- `githubManifest?` (`(id: string, organization?: string) => Promise<GithubManifestResult>`): The page that starts GitHub's App Manifest flow. Absent: no Create GitHub App.
- `list` (`Readable<readonly ChannelConnection[] | null>`): Every connection, without secrets: `null` until read.
- `refresh` (`() => Promise<void>`): Reads the list and the states again. Rejects with a [`ChannelsActionError`](https://zidane.si/docs/reference/ui-channels-headless.md#ChannelsActionError).
- `remove?` (`(id: string, force?: boolean) => Promise<void>`): Removes a connection; `force` turns its bindings into drafts. Absent: no Remove.
- `slackCredentials?` (`(params: { appId: string; appToken?: string; botToken?: string; clientId: string; clientSecret: string; id: string; signingSecret?: string }) => Promise<ChannelConnection>`): Saves a Slack app's credentials once. Absent: no credentials form.
- `slackInstall?` (`(id: string) => Promise<string>`): The "Add to Slack" URL. Absent: no Install.
- `slackManifest?` (`(params: { connectionId?: string; iconUrl?: string; name: string; transport: ChannelConnectionTransport }) => Promise<SlackManifestResult>`): A Slack app manifest and Slack's create link. Absent: no Create Slack app.
- `status` (`Readable<Readonly<Record<string, ConnectionLiveState>>>`): Each connection's live state, by connection id (`channels.connections.status`, then `channels:status`).
- `transports` (`readonly ('http' | 'socket')[]`): The transports a new Slack app may use: `socket` always, `http` when the host has a public URL.
- `update?` (`(id: string, patch: ChannelConnectionPatch) => Promise<ChannelConnection>`): Changes a connection's name, transport, sharing, on or off. Absent: read-only.

Source: [ui/src/channels/headless/host.ts:174](https://github.com/Tahul/zidane/blob/main/ui/src/channels/headless/host.ts#L174)

### `ChannelsError`

Interface.

Why an action or a read failed, as the UI words it: `refused` (the caller's place does not allow it),
`unavailable` (this host runs no channels: on the desktop, the background service is off), `failed` (anything
else). `detail` is what the host said.

```ts
interface ChannelsError
```

**Properties**

- `detail` (`string`): The host's own words.
- `kind` (`'failed' | 'unavailable' | 'refused'`): What kind of failure.

Source: [ui/src/channels/headless/host.ts:132](https://github.com/Tahul/zidane/blob/main/ui/src/channels/headless/host.ts#L132)

### `ChannelsHeld`

Interface.

A project's held replies (docs/CHANNELS.md § Outbound filter): posts not sent because they look like they carry a
credential, each with a masked preview. Its owners and maintainers send one as it was, redacted, or drop it.

```ts
interface ChannelsHeld
```

**Properties**

- `list` (`(projectId: string) => Promise<HeldPost[]>`): The project's held replies, oldest first.
- `release` (`(projectId: string, heldId: string, as: HeldRelease) => Promise<void>`): Sends a held reply as it was or redacted, or drops it.

Source: [ui/src/channels/headless/host.ts:110](https://github.com/Tahul/zidane/blob/main/ui/src/channels/headless/host.ts#L110)

### `ChannelsHost`

Interface.

Everything the channels components read.

```ts
interface ChannelsHost
```

**Properties**

- `agent?` (`ChannelsAgent`): The org's Agent. Absent: no Agent card and no Agent row.
- `alerts?` (`ChannelsAlerts`): The caller's open channel alerts. Absent: no alerts list.
- `bindings?` (`ChannelsBindings`): A project's bindings (Project settings › Channels). Absent: no Channels section.
- `connections?` (`ChannelsConnections`): The host's connections (Settings › Channels). Absent: no Channels page.
- `defaultProjects` (`Readable<Readonly<Record<string, string | null>>>`): The defaults set from this window, by connection id (`null`: cleared). The host has no read of them.
- `held?` (`ChannelsHeld`): A project's replies the outbound filter held, and their release. Absent: no Held replies list.
- `openProject?` (`(projectId: string) => void`): Opens a project of the host (its home): the Agent card's Open project. Absent: no Open project.
- `openSession?` (`(sessionId: string) => void`): Opens a session of the host (a test session). Absent: Test as opens it in the background.
- `openTarget?` (`(target: ReadinessOpenTarget, projectId?: string) => void`): Opens a screen of the app a readiness fix names (Settings › Channels, Linked accounts). The project's own screens
  open its settings in the kit. Absent: those fixes show without a button. `projectId`: the project the fix is
  about (absent for an alert about no project).
- `readiness?` (`ChannelsReadiness`): A project's readiness checklist. Absent: no checklist.
- `setDefaultProject?` (`(connectionId: string, projectId: string | null) => Promise<void>`): Sets (`null`: clears) the caller's default project for a connection's DMs and unbound mentions. Absent: no
  default project rows.
- `testAs?` (`(projectId: string, bindingId: string, as: TestAsKind, identity: { iconUrl?: string; name: string }) => Promise<TestSession>`): Opens a private session with a binding's exact rules for a member or a guest. Absent: no Test as.
  `identity`: how its replies post, kept for the session's Test badge.
- `testSessions` (`Readable<Readonly<Record<string, TestSession>>>`): The test sessions opened in this window, by session id.

Source: [ui/src/channels/headless/host.ts:300](https://github.com/Tahul/zidane/blob/main/ui/src/channels/headless/host.ts#L300)

### `ChannelsHostState`

Interface.

A [`ChannelsHost`](https://zidane.si/docs/reference/ui-channels-headless.md#ChannelsHost) with what its adapter feeds it.

```ts
interface ChannelsHostState extends ChannelsHost
```

**Properties**

- `agent?` (`ChannelsAgent`, from `ChannelsHost`): The org's Agent. Absent: no Agent card and no Agent row.
- `alerts?` (`ChannelsAlerts`, from `ChannelsHost`): The caller's open channel alerts. Absent: no alerts list.
- `apply` (`(signal: { kind: string }) => void`): A signal of the host: reads again what it touches. Other kinds are ignored.
- `bindings?` (`ChannelsBindings`, from `ChannelsHost`): A project's bindings (Project settings › Channels). Absent: no Channels section.
- `connections?` (`ChannelsConnections`, from `ChannelsHost`): The host's connections (Settings › Channels). Absent: no Channels page.
- `defaultProjects` (`Readable<Readonly<Record<string, string | null>>>`, from `ChannelsHost`): The defaults set from this window, by connection id (`null`: cleared). The host has no read of them.
- `held?` (`ChannelsHeld`, from `ChannelsHost`): A project's replies the outbound filter held, and their release. Absent: no Held replies list.
- `openProject?` (`(projectId: string) => void`, from `ChannelsHost`): Opens a project of the host (its home): the Agent card's Open project. Absent: no Open project.
- `openSession?` (`(sessionId: string) => void`, from `ChannelsHost`): Opens a session of the host (a test session). Absent: Test as opens it in the background.
- `openTarget?` (`(target: ReadinessOpenTarget, projectId?: string) => void`, from `ChannelsHost`): Opens a screen of the app a readiness fix names (Settings › Channels, Linked accounts). The project's own screens
  open its settings in the kit. Absent: those fixes show without a button. `projectId`: the project the fix is
  about (absent for an alert about no project).
- `readiness?` (`ChannelsReadiness`, from `ChannelsHost`): A project's readiness checklist. Absent: no checklist.
- `setDefaultProject?` (`(connectionId: string, projectId: string | null) => Promise<void>`, from `ChannelsHost`): Sets (`null`: clears) the caller's default project for a connection's DMs and unbound mentions. Absent: no
  default project rows.
- `testAs?` (`(projectId: string, bindingId: string, as: TestAsKind, identity: { iconUrl?: string; name: string }) => Promise<TestSession>`, from `ChannelsHost`): Opens a private session with a binding's exact rules for a member or a guest. Absent: no Test as.
  `identity`: how its replies post, kept for the session's Test badge.
- `testSessions` (`Readable<Readonly<Record<string, TestSession>>>`, from `ChannelsHost`): The test sessions opened in this window, by session id.
- `wake` (`() => void`): Reads again everything read so far (a new connection).

Source: [ui/src/channels/headless/state.ts:33](https://github.com/Tahul/zidane/blob/main/ui/src/channels/headless/state.ts#L33)

### `ChannelsReadiness`

Interface.

A project's readiness checklist. Members read; each fix is checked by the host like any call.

```ts
interface ChannelsReadiness
```

**Properties**

- `ensure` (`(projectId: string) => void`): Reads a project's items once, the first time something shows them. Never rejects.
- `error` (`(projectId: string) => Readable<ChannelsError | null>`): Why the last read failed, or `null`.
- `items` (`(projectId: string) => Readable<readonly ReadinessItem[] | null>`): A project's items: `null` until read. One store per project, read again on `projects:readiness`.
- `refresh` (`(projectId: string) => Promise<void>`): Reads them again. Rejects with a [`ChannelsActionError`](https://zidane.si/docs/reference/ui-channels-headless.md#ChannelsActionError).
- `runFix?` (`(projectId: string, fix: { kind: 'method'; label: string; method: string; params: Record<string, unknown> }) => Promise<void>`): Runs a method fix, then reads the project's items again. Absent: method fixes show without a button.

Source: [ui/src/channels/headless/host.ts:238](https://github.com/Tahul/zidane/blob/main/ui/src/channels/headless/host.ts#L238)

### `ConnectionLiveState`

Interface.

A connection's live state: `state` with why, since when.

```ts
interface ConnectionLiveState
```

**Properties**

- `connectionId` (`string`): The connection.
- `detail?` (`string`): Why (a pending setup's missing piece, the provider's error).
- `since` (`number`): Since when, Unix ms.
- `state` (`'starting' | 'failed' | 'stopped' | 'connected' | 'degraded'`): How it is now.

Source: [ui/src/channels/headless/host.ts:204](https://github.com/Tahul/zidane/blob/main/ui/src/channels/headless/host.ts#L204)

### `Limits`

Interface.

Throttles per channel. Owners are never throttled.

```ts
interface Limits
```

**Properties**

- `concurrentRuns?` (`number`): Runs of this channel's sessions at once. Default 2.
- `runsPerMemberPerHour?` (`number`): Runs one member may start per hour. Default 10.

Source: [dist/pure-ET4-8JZg.d.ts:17865](https://github.com/Tahul/zidane/blob/main/dist/pure-ET4-8JZg.d.ts#L17865)

### `TestSession`

Interface.

A session "Test as" opened: the binding's rules for a member or a guest, as its replies would post.

```ts
interface TestSession
```

**Properties**

- `as` (`TestAsKind`): Who it runs as.
- `bindingId` (`string`): The binding it tests.
- `identity` (`{ iconUrl?: string; name: string }`): The name and icon its replies post with (the binding's, else the project's name).
- `projectId` (`string`): The project of the binding.
- `sessionId` (`string`): The session.

Source: [ui/src/channels/headless/host.ts:286](https://github.com/Tahul/zidane/blob/main/ui/src/channels/headless/host.ts#L286)

## Types

### `ChannelAgent`

Type.

The org's Agent (docs/CHANNELS.md § The Agent): its project, its name, on or off.

```ts
type ChannelAgent = NonNullable<ChannelsResult<'channels.agent.get'>>
```

Source: [ui/src/channels/headless/host.ts:86](https://github.com/Tahul/zidane/blob/main/ui/src/channels/headless/host.ts#L86)

### `ChannelBindingEnvironment`

Type.

Where a binding's sessions run: a worktree each, the project's folder, or the host's default environment kind.

```ts
type ChannelBindingEnvironment = NonNullable<ChannelsParams<'channels.bindings.put'>['binding']['environment']>
```

Source: [ui/src/channels/headless/host.ts:89](https://github.com/Tahul/zidane/blob/main/ui/src/channels/headless/host.ts#L89)

### `ChannelsMethod`

Type.

A method the channels area calls: the `channels.*` methods of connections, bindings, test sessions, held replies, alerts and the org's Agent, and `projects.readiness`.

```ts
type ChannelsMethod = keyof typeof CHANNELS_METHOD_TABLE
```

Source: [ui/src/channels/headless/host.ts:74](https://github.com/Tahul/zidane/blob/main/ui/src/channels/headless/host.ts#L74)

### `ChannelsParams`

Type.

A method's params.

```ts
type ChannelsParams<M extends ChannelsMethod> = ChannelIpcMethods[M]['params']
```

**Type parameters**

- `M` (`extends ChannelsMethod`)

Source: [ui/src/channels/headless/host.ts:80](https://github.com/Tahul/zidane/blob/main/ui/src/channels/headless/host.ts#L80)

### `ChannelsResult`

Type.

A method's result.

```ts
type ChannelsResult<M extends ChannelsMethod> = ChannelIpcMethods[M]['result']
```

**Type parameters**

- `M` (`extends ChannelsMethod`)

Source: [ui/src/channels/headless/host.ts:83](https://github.com/Tahul/zidane/blob/main/ui/src/channels/headless/host.ts#L83)

### `ChannelsSignal`

Type.

The signals that move the channels stores.

```ts
type ChannelsSignal =
  | { kind: 'channels:changed'; projectId?: string }
  | { connectionId: string; detail?: string; kind: 'channels:status'; since: number; state: 'starting' | 'connected' | 'degraded' | 'failed' | 'stopped' }
  | { kind: 'projects:readiness'; projectId: string }
  | { alert: ChannelAlert; cleared?: boolean; forUser: string; kind: 'channels:alert' }
```

Source: [ui/src/channels/headless/host.ts:121](https://github.com/Tahul/zidane/blob/main/ui/src/channels/headless/host.ts#L121)

### `ReadinessFix`

Type.

A readiness item's one-click fix.

```ts
type ReadinessFix = NonNullable<ReadinessItem['fix']>
```

Source: [ui/src/channels/headless/host.ts:95](https://github.com/Tahul/zidane/blob/main/ui/src/channels/headless/host.ts#L95)

### `ReadinessItem`

Type.

One line of a project's readiness checklist (`projects.readiness`).

```ts
type ReadinessItem = ChannelsResult<'projects.readiness'>[number]
```

Source: [ui/src/channels/headless/host.ts:92](https://github.com/Tahul/zidane/blob/main/ui/src/channels/headless/host.ts#L92)

### `ReadinessMethodFix`

Type.

A readiness fix that calls a method of the host.

```ts
type ReadinessMethodFix = Extract<ReadinessFix, { kind: 'method' }>
```

Source: [ui/src/channels/headless/host.ts:98](https://github.com/Tahul/zidane/blob/main/ui/src/channels/headless/host.ts#L98)

### `ReadinessOpenTarget`

Type.

A screen a readiness fix opens.

```ts
type ReadinessOpenTarget = Extract<ReadinessFix, { kind: 'open' }>['target']
```

Source: [ui/src/channels/headless/host.ts:101](https://github.com/Tahul/zidane/blob/main/ui/src/channels/headless/host.ts#L101)

### `TestAsKind`

Type.

Who a test session runs as.

```ts
type TestAsKind = ChannelsParams<'channels.bindings.testAs'>['as']
```

Source: [ui/src/channels/headless/host.ts:118](https://github.com/Tahul/zidane/blob/main/ui/src/channels/headless/host.ts#L118)
