# Human

> Humans: ask a person, get an approval, send a notice, request a connection.

## Human

```typescript
class Human
```

A person to reach. `user.human` (or `new Human()`, meaning the user
current at each call, or the one a session or user-pinned key acts for)
is the user; `Human.owner()` is your account's owner; `new Human({ email })` is anyone else.
Every method returns an operation: `await req.wait()` for the outcome.

`via` says where a message goes: `"auto"` (the default), or a list of `"web"` (only the page: you
pass `request.url` on), `"email"`, and for the owner `"whatsapp"` and `"imessage"`, sent from
NoClick's own numbers to the number they text NoClick from. `"auto"` is the app the owner last
texted NoClick on, else email. `"sms"` and `"call"` throw `NotAvailable` for now. What couldn't be
sent is listed in `undelivered`, never implied.

### Human.owner

```typescript
static owner(options?: { client?: NoClick }): Human
```

Your account's owner: the person behind the account, reached by email and on the app they text
NoClick from. Only your account reaches them: it always acts as your account, inside `asUser` too,
and a user's session or a key pinned to a user throws `PermissionDenied`.

    await Human.owner().notify("The site is live: https://morrowbakery.com");

Parameters:

- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: The owner, to message, ask, put in an agent's `tools=` or `answer_with`.

### Human.answerWith

```typescript
answerWith(
  agent: Agent | string | null,
  options?: { conversation?: string },
): Promise<this>
```

Send what this person texts or says to NoClick's own numbers (its WhatsApp and iMessage numbers and
its voice number) to `agent` (one of your account's). A text's reply goes back on the app they texted
on once the agent's turn ends, and texts sent while it's busy go in its next turn, in order; on a call,
each thing they say is a turn whose reply is read aloud as it's written. `null` hands them back to
NoClick's assistant. Only `Human.owner()` reaches NoClick's numbers: your users reach an agent on a
number of your own (`PhoneNumber.answerWith`). `conversation` is the agent's conversation each text or
call lands in, a template over `{channel}` (`whatsapp`, `imessage` or `call`); omitted, `"owner"`.
Give an inbox and a number the same key and the person's email, calls and texts are one conversation.

    const assistant = Agent.fromName("assistant");
    await Human.owner().answerWith(assistant);
    await assistant.message("What's on today?", { conversation: "owner" }); // the same thread

Parameters:

- `agent` (`Agent | string | null`, required)
- `options.conversation` (`string`)

Returns: This person.

### Human.answering

```typescript
answering(): Promise<Agent | null>
```

The agent this person's texts to NoClick's own numbers go to (`answerWith`), or `null` when NoClick's assistant answers them.

Returns: The `noclick.Agent`, or `None`.

### Human.reach

```typescript
reach(): Promise<OwnerReach>
```

NoClick's own numbers the owner texts it on, whether a phone of theirs is linked (never which), and the
address they email their assistant at (`email`, null before it has one). Show a number only once a phone is
linked: a text from a phone the account hasn't linked starts an account of its own, and linking one is the
owner's, signed in to NoClick. Your account's own key reads it, never a user's.

    const { lines, phoneLinked } = await Human.owner().reach();
    if (phoneLinked) for (const line of lines) console.log(`${line.app}: ${line.number}`);

Returns: The `noclick.OwnerReach`.

### Human.setTimezone

```typescript
setTimezone(timezone: string): Promise<void>
```

Where the signed-in owner is, from their browser (an IANA zone such as `"Europe/London"`): the clock of the
account's assistant, and of each of its own agents NoClick placed, moves there; a zone chosen through the API
stays. The signed-in owner's alone: a key rejects with `PermissionDenied`.

    await Human.owner().setTimezone(Intl.DateTimeFormat().resolvedOptions().timeZone);

Parameters:

- `timezone` (`string`, required)

### Human.claimEmailAddress

```typescript
claimEmailAddress(): Promise<OwnerEmailAddress | null>
```

The address the owner emails their assistant at (`reach().email`), claiming a readable one, from their own
address, the first time it's wanted; null where NoClick takes no mail. The signed-in owner's alone: a key rejects
with `PermissionDenied`.

    const mail = await Human.owner().claimEmailAddress();
    console.log(mail ? `Email your assistant at ${mail.address}` : "No email here");

Returns: The `noclick.OwnerEmailAddress`, or `None`.

### Human.renameEmailAddress

```typescript
renameEmailAddress(name: string): Promise<OwnerEmailAddress>
```

Renames the address the owner emails their assistant at to `name` (the part before the

Parameters:

- `name` (`string`, required)

Returns: The `noclick.OwnerEmailAddress` at its new name.

### Human.addEmail

```typescript
addEmail(email: string): Promise<void>
```

Send a code to `email` for the owner of an account made by texting NoClick (which has none);
`confirmEmail` with the code makes it theirs. Throws `Conflict` when the account already has an
email, `RateLimited` after too many codes.

    const owner = Human.owner();
    await owner.addEmail("maya@morrowbakery.com");
    await owner.confirmEmail(code);

Parameters:

- `email` (`string`, required)

### Human.confirmEmail

```typescript
confirmEmail(code: string): Promise<OwnerEmail>
```

The code `addEmail` sent: on a match the email is the owner's to sign in with, or, when an account
already has it, that account takes this one in (`merged`). Whether an account has the email is said
only once the code matches. `status` is `added`, or `verified` when an agent's turn confirmed it
(it's added once that turn ends).

    const confirmed = await Human.owner().confirmEmail("482913");

Parameters:

- `code` (`string`, required)

Returns: The confirmed email.

### Human.only

```typescript
only(...tools: HumanTool[]): HumanOperations
```

Some of the tools this person gives an agent, for `tools`. In an
agent's tools a `Human` gives it three, each addressed only to this person: `notify`, `ask`
(the turn waits, `awaiting_human`, and the answer arrives as the next turn) and `hand_off`
(the conversation goes to this person, with a page and an email carrying the transcript and a
reply box; their replies post as `person` messages and the agent stays quiet until
`agent.handBack(conversation)`; on a call it's transferred to the person's `phone`). Policy
names them `human.notify`, `human.ask` and `human.hand_off`.

    const manager = new Human({ email: "ops@acme.com" });
    await Agent.create("support", { instructions: "...", tools: ["search", manager.only("notify", "ask")] });

Parameters:

- `tools` (`HumanTool[]`, required)

Returns: A ref to just those tools of this person, to list in `tools=`.

Types:

```typescript
/** The tools a person gives an agent: `notify`, `ask` and `hand_off`. */
type HumanTool = "notify" | "ask" | "hand_off";
```

### Human.ask

```typescript
ask(message: string, options?: HumanAskOptions): Promise<HumanRequest<Answer>>
```

Ask a question; `wait()` resolves to an `Answer`. `pick` asks, in place of `options`, for
something in one of their connected accounts, and `multiple` lets them choose several.

Parameters:

- `message` (`string`, required)
- `options.options` (`string[]`): The answers they choose from (up to 20); left out, they answer in their own words.
- `options.pick` (`HumanPick`): In place of `options`: something in a connected account. The choices are read from it, and an account that holds just one answers at once with it.
- `options.multiple` (`boolean`): They may choose several of the options, or of a pick's choices.
- `options.connect` (`HumanConnectAsk`): Asked of the owner: which of the account's connections a workflow step uses. NoClick sets the one they choose as them, and an account holding just one that fits answers at once with it. Needs the `workflows` scope.
- `options.secret` (`HumanSecretAsk`): A secret's values, typed on NoClick's page (its link carries a key: the request's id alone opens nothing), never shown to you or a model. Needs the `secrets` scope.
- `options.via` (`Via`)
- `options.expiresInS` (`number`)

Returns: The request, already sent. `wait()` blocks until the person answers
and gives what they picked (`choice`, a pick's `value` beside it; each of
several in `choices` and `values`) and wrote (`text`).

Types:

```typescript
/**
 * Something to pick in a connected account (`Human.ask`'s `pick`): the connection (a `Connection`, or
 * its id or name) and the field its lookup lists (`connection.lookup` names them: `repository`,
 * `team_id`, `channel`), with the values that field depends on (a spreadsheet's id for its sheets).
 */
interface HumanPick {
  connection: string | Connection;
  field: string;
  arguments?: JsonObject;
}

type JsonObject = { [key: string]: unknown };

/**
 * Which of the account's connections a workflow step uses (`Human.ask`'s `connect`, asked of the owner): the app or
 * model provider (`integration`) or the one kind of credential (`credentialType`), and the step; `slot` narrows it
 * to one kind the step keys connections by.
 */
interface HumanConnectAsk {
  integration?: string;
  credentialType?: string;
  step: HumanStepRef & { slot?: string };
}

/** A workflow step a question fills in: its workflow (a `Workflow` or its id) and its id in the graph. */
interface HumanStepRef {
  workflow: string | Workflow;
  stepId: string;
}

/**
 * A secret's values (`Human.ask`'s `secret`): typed on NoClick's page and kept as the account's secret `name`, its
 * `keys` each a value; with `step`, an agent step's shell gets it too (the owner's only).
 */
interface HumanSecretAsk {
  name: string;
  keys: string[];
  step?: HumanStepRef;
}

/** `"auto"` or the channels to use, e.g. `["email", "web"]`. */
type Via = "auto" | string | string[];
```

### Human.approve

```typescript
approve(
  message: string,
  options?: { details?: unknown; via?: Via; expiresInS?: number },
): Promise<HumanRequest<boolean>>
```

Ask for a yes/no; `wait()` resolves to `true` when approved.

Parameters:

- `message` (`string`, required)
- `options.details` (`unknown`)
- `options.via` (`Via`)
- `options.expiresInS` (`number`)

Returns: The request, already sent. `wait()` gives `True` if they approve
and `False` if they decline.

Types:

```typescript
/** `"auto"` or the channels to use, e.g. `["email", "web"]`. */
type Via = "auto" | string | string[];
```

### Human.notify

```typescript
notify(message: string, options?: { via?: Via }): Promise<HumanRequest<null>>
```

Send a notice (the operation succeeds once it's sent).

Parameters:

- `message` (`string`, required)
- `options.via` (`Via`)

Returns: The request, already sent and its operation already succeeded, so
`wait()` returns `None` at once. `undelivered` names any channel that failed.

Types:

```typescript
/** `"auto"` or the channels to use, e.g. `["email", "web"]`. */
type Via = "auto" | string | string[];
```

### Human.connect

```typescript
connect(
  connection: string | Connection,
  options?: { reason?: string; redirectUrl?: string },
): Promise<ConnectLink>
```

Ask this person to connect `connection` (a `Connection` or its name, in
this person's user); `wait()` resolves to the connected `Connection`.

Parameters:

- `connection` (`string | Connection`, required)
- `options.reason` (`string`)
- `options.redirectUrl` (`string`)

Returns: The link, already emailed: its `url` and when it `expires_at`.
`wait()` gives the connected `Connection`.

## HumanRequest

```typescript
class HumanRequest extends Operation
```

A request to a person; also the operation that finishes when they answer.

| Attribute | Type | Description |
| --- | --- | --- |
| `requestId` | `string | null` | The request's own id (the operation's is `id`). |
| `requestStatus` | `HumanRequestStatus | null` | `pending`, `answered`, `delivered`, `expired` or `canceled`. |
| `request` | `JsonObject` | The request as created: `url`, `delivered_via`, `undelivered`, ... |
| `url` | `string | null` | The page where the person answers (`/h/{id}`); embed or send it yourself. |
| `deliveredVia` | `string[]` |  |
| `undelivered` | `JsonObject[]` | Channels that failed, each with a `reason`. |
| `file` | `HumanFileAsk | null` | A file question's file where the agent works (null for any other request). |
| `note` | `string | null` | What the approver wrote with their answer (null until answered, or if they wrote nothing). |

Types:

```typescript
type HumanRequestStatus = "pending" | "answered" | "delivered" | "expired" | "canceled";

type JsonObject = { [key: string]: unknown };
```

### HumanRequest.list

```typescript
static list(
  options?: HumanRequestFilters & { limit?: number },
): Promise<HumanRequest<unknown>[]>
```

Requests your code and agents sent, newest first (or the first `limit`).

Parameters:

- `options.status` (`OneOrMany<HumanRequestStatus>`)
- `options.statusNot` (`OneOrMany<HumanRequestStatus>`)
- `options.kind` (`OneOrMany<"ask" | "approve" | "notify">`)
- `options.answerable` (`"owner" | "code"`): `"owner"`: only requests the signed-in account owner may answer; `"code"`: only those your code
may answer with `approve` or `decline`. A call NoClick holds for the account's owner (a purchase or a
deletion, whose `request.owner_only` is true) is listed only for a key that names the `approvals:answer`
scope, and never one made with that key or one whose terms a person accepts (see `Approval`).
- `options.limit` (`number`): Return at most this many.
- `options.userFilter` (`UserFilter`): Which users the read covers (`user_id` query), instead of acting as one (`user`).
- `options.user` (`UserOption`, default: the current user): `undefined` = the ambient user (`asUser`), `null` = the account itself.
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: Every matching request, fetched page by page. Each is also the
operation you can `wait()` on; `request_status` is the request's own status.

Types:

```typescript
type HumanRequestStatus = "pending" | "answered" | "delivered" | "expired" | "canceled";

/**
 * Which users a read covers: `ALL_USERS`, `NO_USER`, a `User` or your id for one. Sent as the
 * `user_id` query parameter, never as the `NoClick-User` header, so it filters without acting as the user.
 */
type UserFilter = typeof ALL_USERS | typeof NO_USER | UserRef;

/** A `User` or your own id for the user. */
type UserRef = string | UserLike;

/** Anything that can name a user lazily (a `User`). */
interface UserLike {
  _userId(): Promise<string>;
}

/** `undefined` = the ambient user (from `asUser`), `null` = the account itself. */
type UserOption = UserRef | null | undefined;
```

### HumanRequest.listPage

```typescript
static listPage(
  options?: HumanRequestFilters & PageOptions,
): Promise<Page<HumanRequest<unknown>>>
```

One page of requests; pass `nextCursor` back as `cursor`.

Parameters:

- `options.cursor` (`string | null`): The `next_cursor` of the page before; omit it for the first page.
- `options.limit` (`number`): Return at most this many.
- `options.status` (`OneOrMany<HumanRequestStatus>`)
- `options.statusNot` (`OneOrMany<HumanRequestStatus>`)
- `options.kind` (`OneOrMany<"ask" | "approve" | "notify">`)
- `options.answerable` (`"owner" | "code"`): `"owner"`: only requests the signed-in account owner may answer; `"code"`: only those your code
may answer with `approve` or `decline`. A call NoClick holds for the account's owner (a purchase or a
deletion, whose `request.owner_only` is true) is listed only for a key that names the `approvals:answer`
scope, and never one made with that key or one whose terms a person accepts (see `Approval`).
- `options.userFilter` (`UserFilter`): Which users the read covers (`user_id` query), instead of acting as one (`user`).
- `options.user` (`UserOption`, default: the current user): `undefined` = the ambient user (`asUser`), `null` = the account itself.
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: A page whose `data` holds the requests and whose `next_cursor` is `None` on the last page.

Types:

```typescript
type HumanRequestStatus = "pending" | "answered" | "delivered" | "expired" | "canceled";

/**
 * Which users a read covers: `ALL_USERS`, `NO_USER`, a `User` or your id for one. Sent as the
 * `user_id` query parameter, never as the `NoClick-User` header, so it filters without acting as the user.
 */
type UserFilter = typeof ALL_USERS | typeof NO_USER | UserRef;

/** A `User` or your own id for the user. */
type UserRef = string | UserLike;

/** Anything that can name a user lazily (a `User`). */
interface UserLike {
  _userId(): Promise<string>;
}

/** `undefined` = the ambient user (from `asUser`), `null` = the account itself. */
type UserOption = UserRef | null | undefined;
```

### HumanRequest.retrieve

```typescript
static retrieve(
  requestId: string,
  options?: { client?: NoClick; user?: UserOption },
): Promise<HumanRequest<unknown>>
```

One request by its own id (a `HumanRequest.requestId`, the `/h/{id}` page's): what it asks, how it stands
(`requestStatus`) and, once answered, the answer. A user reads only their own; throws `NotFound` for any other.
Answer it with `answer`, `approve` or `decline`.

    const request = await HumanRequest.retrieve("hr_3f2a1c9e");
    if (request.requestStatus === "pending") await request.approve({ note: "Go ahead" });

Parameters:

- `requestId` (`string`, required)
- `options.user` (`UserOption`, default: the current user): Who the call acts for. Defaults to the user set by `noclick.as_user` (none: the account itself).
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: The request.

Types:

```typescript
/** `undefined` = the ambient user (from `asUser`), `null` = the account itself. */
type UserOption = UserRef | null | undefined;

/** A `User` or your own id for the user. */
type UserRef = string | UserLike;

/** Anything that can name a user lazily (a `User`). */
interface UserLike {
  _userId(): Promise<string>;
}
```

### HumanRequest.summary

```typescript
static summary(options?: KindScopedFilters): Promise<OperationSummary>
```

How many human-request operations (ask, approve, notify) match, by operation status.

Parameters:

- `options.client` (`NoClick`)
- `options.user` (`UserOption`): `undefined` = the ambient user (`asUser`), `null` = the account itself.
- `options.status` (`OperationStatus | "live" | readonly (OperationStatus | "live")[]`): Statuses, or `"live"` for every non-terminal one.
- `options.agent` (`string | ApiObject`): An `Agent` or agent id.
- `options.statusNot` (`OperationStatus | readonly OperationStatus[]`)
- `options.updatedAfter` (`Date | string`): Rows changed since (for polling).
- `options.cause` (`string`): The failed ones of one cause (an `OperationFailure`'s `cause`, from `Operation.failures()`).
- `options.key` (`string`): The requesting key: its id or its prefix (`nk_live_ab12`).
- `options.createdAfter` (`Date | string`)
- `options.createdBefore` (`Date | string`)
- `options.userFilter` (`UserFilter`): Which users the read covers (`user_id` query), instead of acting as one (`user`).

Returns: The number that match in `total`, and per operation status in `by_status`.

Types:

```typescript
/** `undefined` = the ambient user (from `asUser`), `null` = the account itself. */
type UserOption = UserRef | null | undefined;

/** A `User` or your own id for the user. */
type UserRef = string | UserLike;

/** Anything that can name a user lazily (a `User`). */
interface UserLike {
  _userId(): Promise<string>;
}

type OperationStatus =
  | "queued" | "running" | "awaiting_human"
  | "succeeded" | "failed" | "canceled" | "expired";

/**
 * Which users a read covers: `ALL_USERS`, `NO_USER`, a `User` or your id for one. Sent as the
 * `user_id` query parameter, never as the `NoClick-User` header, so it filters without acting as the user.
 */
type UserFilter = typeof ALL_USERS | typeof NO_USER | UserRef;
```

### HumanRequest.answer

```typescript
answer(fields: HumanAnswerFields): Promise<this>
```

Answer a question from your own code, as the person it waits on (who may: as `approve` says): a `choice` (or
`choices`) and/or `text`; a connect question's `connection` (one of the account's that fits), which NoClick sets
on the step as your key, so it needs the `workflows` scope and a key acting for your whole account, never a
user's or an agent's own tools; a secret question's `secretValues`, kept in the secret and never with the
answer, which needs the `secrets` scope. A file question (`file`) is the account's owner's alone, signed in:
`secretValues` for its keys, else `fileContent`, the whole file, written into the asking agent's sandbox or
machine while it runs.

Parameters:

- `fields` (`HumanAnswerFields`, required)

Returns: This request, answered: `request_status` is `answered`.

Types:

```typescript
/**
 * What `HumanRequest.answer` takes: a question's choice(s) and/or text, a connect question's connection, or a secret
 * or file question's values (or the file itself).
 */
interface HumanAnswerFields {
  choice?: string;
  choices?: string[];
  text?: string;
  /** One of the account's connections that fits (a `Connection`, or its ref or name). */
  connection?: string | Connection;
  /** A value for each of the secret's keys, or of a file question's: kept in the secret or the file, never with the answer. */
  secretValues?: Record<string, string>;
  /** A file question's that names no keys: the file as it's written (text, up to 1 MB), kept in the file and never with the answer. */
  fileContent?: string;
}
```

### HumanRequest.approve

```typescript
approve(options?: { note?: string }): Promise<this>
```

Approve it from your own code, as the person it waits on: with a key acting for your account,
an approval routed to your account; with a user's session or inside `asUser`, one addressed to
that user; a call NoClick holds for the account's owner, only with a key that names the
`approvals:answer` scope, as `Approval.approve` answers it (anyone else gets `PermissionDenied`).
A held operation call then runs exactly as it
was held (a held shell command or other tool, the agent makes again itself), and the agent gets
a turn in the same conversation with its result, its reply going out where the conversation
lives: on an email thread, the same thread (the inbox agent's `reply` tool is bound to the
thread's latest message).

Parameters:

- `options.note` (`string`)

Returns: This request, answered: `request_status` is `answered` and `note` is yours.

### HumanRequest.decline

```typescript
decline(options?: { note?: string }): Promise<this>
```

Decline it: a held call never runs, and the agent gets a turn saying so, with your `note`.

Parameters:

- `options.note` (`string`)

Returns: This request, answered: `request_status` is `answered` and `note` is yours.

## HumanOperations

```typescript
class HumanOperations
```

Some of a person's tools for an agent (`human.only(...)`), for `tools`.

| Attribute | Type | Description |
| --- | --- | --- |
| `human` | `Human` |  |
| `tools` | `HumanTool[]` |  |

Types:

```typescript
/** The tools a person gives an agent: `notify`, `ask` and `hand_off`. */
type HumanTool = "notify" | "ask" | "hand_off";
```

## Answer

```typescript
interface Answer
```

What the person chose (`choice`) and/or wrote (`text`). A `pick`'s answer names the choice in the
account too (`value`: a repository's `owner/name`, a channel's id); a question asked with
`multiple` names each one they chose (`choices`, and a pick's `values`).

| Attribute | Type | Description |
| --- | --- | --- |
| `choice` | `string | null` |  |
| `text` | `string | null` |  |
| `raw` | `unknown` | The response JSON exactly as the API sent it. |
| `value` | `string | null` |  |
| `choices` | `string[]` |  |
| `values` | `string[]` |  |
| `connection` | `string | null` | A `connect` question's: the connection set on the step, by its ref (also its `value`; `choice` is its name). |
| `secret` | `string | null` | A `secret` question's: the secret its values went into, never the values. |

## HumanFileAsk

```typescript
interface HumanFileAsk
```

A file in the asking agent's sandbox or machine its owner fills in (`HumanRequest.file`): a local `.env`, a key
file. Only an agent's own `ask` tool asks one, and only the account's owner answers it: with `keys`, a value for
each (set in the file as `KEY=value` lines, the rest of it kept); without, the whole file. NoClick writes it there
as a file holding secrets, never keeping it anywhere else.

| Attribute | Type | Description |
| --- | --- | --- |
| `path` | `string` | The file's absolute path where the agent works. |
| `keys` | `string[] | null` | The keys they fill in; null when they write the whole file. |
| `agentId` | `string` |  |
| `agentName` | `string | null` |  |

## OwnerEmail

```typescript
interface OwnerEmail
```

An email confirmed for the owner (`Human.confirmEmail`).

| Attribute | Type | Description |
| --- | --- | --- |
| `email` | `string` |  |
| `status` | `string` | `added`, or `verified` when an agent's turn confirmed it: it's added once that turn ends. |
| `merged` | `boolean` | An account that already had the email took this one in. |

## OwnerLine

```typescript
interface OwnerLine
```

One of NoClick's own numbers the owner texts it on (`Human.reach`): `app` is `whatsapp` or `imessage`.

| Attribute | Type | Description |
| --- | --- | --- |
| `app` | `string` |  |
| `number` | `string` |  |

## OwnerReach

```typescript
interface OwnerReach
```

Where the owner texts NoClick (`Human.reach`).

| Attribute | Type | Description |
| --- | --- | --- |
| `lines` | `OwnerLine[]` | NoClick's own numbers, one for each app it answers on. |
| `phoneLinked` | `boolean` | Whether a phone of the owner's is linked to the account; which one is never said. |
| `email` | `OwnerEmailAddress | null` | The address the owner emails their assistant at; null before it has one. |

## HumanRequestLink

```typescript
class HumanRequestLink
```

A human request's page (`/h/{id}`), as the person its link reached reads and answers it. The id is the capability;
the link NoClick sends its person carries a key beside it (`?k=`), which a request asked of the account's owner, one
only its person answers and a held call's approval need: pass it as `key`. Who may answer is NoClick's to judge, as
on its own page: a request the link can't open rejects with `NotFound`, and an answer it doesn't take with its
reason.

    const link = new HumanRequestLink(requestId, { key: new URL(location.href).searchParams.get("k") });
    const page = await link.read();
    if (page.kind === "approve") await link.answer({ decision: "approve" });

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `string` |  |
| `key` | `string | null` |  |

### HumanRequestLink.read

```typescript
read(): Promise<HumanRequestPage>
```

The request as its page shows it.

Returns: The `HumanRequestPage`.

### HumanRequestLink.answer

```typescript
answer(body: JsonObject): Promise<JsonObject>
```

Answer it, once: a question's `choice` (or `choices`) and `text`, an approval's `decision` (`approve` or `deny`);
a held call's `approved`, `note` and each of its terms accepted; a step question's `connection` or `values`; a
file question's `secret_values` (one for each of its keys) or `file_content` (the whole file).
Rejects with the reason an answer isn't taken (already answered, expired, not this link's to give).

Parameters:

- `body` (`JsonObject`, required)

Returns: The request as it stands once answered.

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```

### HumanRequestLink.connect

```typescript
connect(options?: { credentialType?: string }): Promise<{ url: string }>
```

A connect question's other account: the provider's sign-in link (`url`), which comes back to the request's page
and whose account answers the question. `credentialType`: which of its ways to sign in.

Parameters:

- `options.credentialType` (`string`)

Returns: The sign-in link to open.

### HumanRequestLink.reply

```typescript
reply(text: string): Promise<JsonObject>
```

Reply in the conversation an agent handed this link's person.

Parameters:

- `text` (`string`, required)

Returns: The request as it stands.

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```

### HumanRequestLink.handBack

```typescript
handBack(): Promise<JsonObject>
```

Give the handed-over conversation back to the agent, which answers from the next message.

Returns: The request as it stands.

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```

## HumanRequestPage

```typescript
interface HumanRequestPage
```

A human request as its page shows it (`HumanRequestLink.read`).

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `string` |  |
| `kind` | `string` | `ask`, `approve`, `notify`, `hand_off`, `setup`, ... |
| `status` | `string` | `pending` until it's answered, then `answered`, `expired`, `canceled`, ... |
| `message` | `string | null` |  |
| `expiresAt` | `Date | null` |  |
| `raw` | `JsonObject` | Everything the page shows: its options, its brand, a held call's approval, a step question, a hand-off. |

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```

## OwnerEmailAddress

```typescript
interface OwnerEmailAddress
```

The address the owner emails their assistant at.

| Attribute | Type | Description |
| --- | --- | --- |
| `address` | `string` |  |
| `paused` | `boolean` | The owner turned its mail off: the address stays theirs, and mail to it is ignored. |
| `fromAnyone` | `boolean` | Anyone's mail to it reaches the assistant, not only the owner's. |
