Human
Humans: ask a person, get an approval, send a notice, request a connection.
class HumanA 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.
ownerstatic
static owner(options?: { client?: NoClick }): HumanYour 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");The client to send with; defaults to the module client built from NOCLICK_API_KEY.
The owner, to message, ask, put in an agent's tools= or answer_with.
answerWith
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 threadThis person.
answering
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.
The noclick.Agent, or None.
reach
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}`);The noclick.OwnerReach.
setTimezone
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);claimEmailAddress
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");The noclick.OwnerEmailAddress, or None.
renameEmailAddress
renameEmailAddress(name: string): Promise<OwnerEmailAddress>Renames the address the owner emails their assistant at to name (the part before the
The noclick.OwnerEmailAddress at its new name.
addEmail
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);confirmEmail
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");The confirmed email.
only
only(...tools: HumanTool[]): HumanOperationsSome 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")] });A ref to just those tools of this person, to list in tools=.
/** The tools a person gives an agent: `notify`, `ask` and `hand_off`. */
type HumanTool = "notify" | "ask" | "hand_off";ask
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.
The answers they choose from (up to 20); left out, they answer in their own words.
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.
They may choose several of the options, or of a pick's choices.
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.
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.
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).
/**
* 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[];approve
approve(
message: string,
options?: { details?: unknown; via?: Via; expiresInS?: number },
): Promise<HumanRequest<boolean>>Ask for a yes/no; wait() resolves to true when approved.
The request, already sent. wait() gives True if they approve
and False if they decline.
/** `"auto"` or the channels to use, e.g. `["email", "web"]`. */
type Via = "auto" | string | string[];notify
notify(message: string, options?: { via?: Via }): Promise<HumanRequest<null>>Send a notice (the operation succeeds once it's sent).
The request, already sent and its operation already succeeded, so
wait() returns None at once. undelivered names any channel that failed.
/** `"auto"` or the channels to use, e.g. `["email", "web"]`. */
type Via = "auto" | string | string[];connect
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.
The link, already emailed: its url and when it expires_at.
wait() gives the connected Connection.
HumanRequest
class HumanRequest extends OperationA request to a person; also the operation that finishes when they answer.
- Inherits from Operation.
| requestId | string | null | The request's own id (the operation's is |
| requestStatus | HumanRequestStatus | null |
|
| request | JsonObject | The request as created: |
| url | string | null | The page where the person answers ( |
| deliveredVia | string[] | |
| undelivered | JsonObject[] | Channels that failed, each with a |
| 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). |
type HumanRequestStatus = "pending" | "answered" | "delivered" | "expired" | "canceled";
type JsonObject = { [key: string]: unknown };liststatic
static list(
options?: HumanRequestFilters & { limit?: number },
): Promise<HumanRequest<unknown>[]>Requests your code and agents sent, newest first (or the first limit).
"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).
Return at most this many.
Which users the read covers (user_id query), instead of acting as one (user).
undefined = the ambient user (asUser), null = the account itself.
The client to send with; defaults to the module client built from NOCLICK_API_KEY.
Every matching request, fetched page by page. Each is also the
operation you can wait() on; request_status is the request's own status.
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;listPagestatic
static listPage(
options?: HumanRequestFilters & PageOptions,
): Promise<Page<HumanRequest<unknown>>>One page of requests; pass nextCursor back as cursor.
The next_cursor of the page before; omit it for the first page.
Return at most this many.
"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).
Which users the read covers (user_id query), instead of acting as one (user).
undefined = the ambient user (asUser), null = the account itself.
The client to send with; defaults to the module client built from NOCLICK_API_KEY.
A page whose data holds the requests and whose next_cursor is None on the last page.
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;retrievestatic
static retrieve(
requestId: string,
options?: { client?: NoClick; user?: UserOption },
): Promise<HumanRequest<unknown>>One request by its own id (a HumanRequest.requestId, the /h/ 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" });Who the call acts for. Defaults to the user set by noclick.as_user (none: the account itself).
The client to send with; defaults to the module client built from NOCLICK_API_KEY.
The request.
/** `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>;
}summarystatic
static summary(options?: KindScopedFilters): Promise<OperationSummary>How many human-request operations (ask, approve, notify) match, by operation status.
undefined = the ambient user (asUser), null = the account itself.
Statuses, or "live" for every non-terminal one.
An Agent or agent id.
Rows changed since (for polling).
The failed ones of one cause (an OperationFailure's cause, from Operation.failures()).
The requesting key: its id or its prefix (nk_live_ab12).
Which users the read covers (user_id query), instead of acting as one (user).
The number that match in total, and per operation status in by_status.
/** `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;answer
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.
This request, answered: request_status is answered.
/**
* 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;
}approve
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).
This request, answered: request_status is answered and note is yours.
decline
decline(options?: { note?: string }): Promise<this>Decline it: a held call never runs, and the agent gets a turn saying so, with your note.
This request, answered: request_status is answered and note is yours.
HumanOperations
class HumanOperationsSome of a person's tools for an agent (human.only(...)), for tools.
| human | Human | |
| tools | HumanTool[] |
/** The tools a person gives an agent: `notify`, `ask` and `hand_off`. */
type HumanTool = "notify" | "ask" | "hand_off";Answer
interface AnswerWhat 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).
| 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 |
| secret | string | null | A |
HumanFileAsk
interface HumanFileAskA 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.
| 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
interface OwnerEmailAn email confirmed for the owner (Human.confirmEmail).
| string | ||
| status | string |
|
| merged | boolean | An account that already had the email took this one in. |
OwnerLine
interface OwnerLineOne of NoClick's own numbers the owner texts it on (Human.reach): app is whatsapp or imessage.
| app | string | |
| number | string |
OwnerReach
interface OwnerReachWhere the owner texts NoClick (Human.reach).
| 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. |
| OwnerEmailAddress | null | The address the owner emails their assistant at; null before it has one. |
HumanRequestLink
class HumanRequestLinkA human request's page (/h/), 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" });| id | string | |
| key | string | null |
read
read(): Promise<HumanRequestPage>The request as its page shows it.
The HumanRequestPage.
answer
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).
The request as it stands once answered.
type JsonObject = { [key: string]: unknown };connect
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.
The sign-in link to open.
reply
reply(text: string): Promise<JsonObject>Reply in the conversation an agent handed this link's person.
The request as it stands.
type JsonObject = { [key: string]: unknown };handBack
handBack(): Promise<JsonObject>Give the handed-over conversation back to the agent, which answers from the next message.
The request as it stands.
type JsonObject = { [key: string]: unknown };HumanRequestPage
interface HumanRequestPageA human request as its page shows it (HumanRequestLink.read).
| id | string | |
| kind | string |
|
| status | string |
|
| 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. |
type JsonObject = { [key: string]: unknown };OwnerEmailAddress
interface OwnerEmailAddressThe address the owner emails their assistant at.
| 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. |