@openlegion/platform 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +1189 -2
- package/dist/body.d.ts +9 -0
- package/dist/body.js +28 -0
- package/dist/chat-history.d.ts +53 -0
- package/dist/chat-history.js +11 -0
- package/dist/client.d.ts +217 -0
- package/dist/client.js +367 -0
- package/dist/core.d.ts +47 -0
- package/dist/core.js +1 -0
- package/dist/crypto.d.ts +25 -0
- package/dist/crypto.js +81 -0
- package/dist/errors.d.ts +111 -0
- package/dist/errors.js +134 -0
- package/dist/events.d.ts +131 -0
- package/dist/events.js +5 -0
- package/dist/generated/api.d.ts +5505 -0
- package/dist/generated/api.js +446 -0
- package/dist/handler.d.ts +201 -0
- package/dist/handler.js +682 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +12 -0
- package/dist/kit-agents.d.ts +95 -0
- package/dist/kit-agents.js +280 -0
- package/dist/kit-codes.d.ts +279 -0
- package/dist/kit-codes.js +44 -0
- package/dist/kit-connections.d.ts +21 -0
- package/dist/kit-connections.js +189 -0
- package/dist/kit-files.d.ts +8 -0
- package/dist/kit-files.js +117 -0
- package/dist/kit-model-keys.d.ts +8 -0
- package/dist/kit-model-keys.js +86 -0
- package/dist/kit-threads.d.ts +3 -0
- package/dist/kit-threads.js +92 -0
- package/dist/kit-tools.d.ts +21 -0
- package/dist/kit-tools.js +47 -0
- package/dist/kit.d.ts +130 -0
- package/dist/kit.js +155 -0
- package/dist/mcp-server.d.ts +27 -0
- package/dist/mcp-server.js +166 -0
- package/dist/next.d.ts +24 -0
- package/dist/next.js +6 -0
- package/dist/ol-signed.d.ts +82 -0
- package/dist/ol-signed.js +115 -0
- package/dist/react/add-server.d.ts +90 -0
- package/dist/react/add-server.js +183 -0
- package/dist/react/agent-chat.d.ts +925 -0
- package/dist/react/agent-chat.js +1917 -0
- package/dist/react/agent-editor.d.ts +133 -0
- package/dist/react/agent-editor.js +222 -0
- package/dist/react/agent-kit.d.ts +160 -0
- package/dist/react/agent-kit.js +279 -0
- package/dist/react/agent-list.d.ts +247 -0
- package/dist/react/agent-list.js +248 -0
- package/dist/react/approval-card.d.ts +272 -0
- package/dist/react/approval-card.js +372 -0
- package/dist/react/artifact-card.d.ts +38 -0
- package/dist/react/artifact-card.js +39 -0
- package/dist/react/avatar.d.ts +21 -0
- package/dist/react/avatar.js +33 -0
- package/dist/react/card-ledger.d.ts +30 -0
- package/dist/react/card-ledger.js +49 -0
- package/dist/react/chat-timing.d.ts +121 -0
- package/dist/react/chat-timing.js +229 -0
- package/dist/react/computer-view.d.ts +309 -0
- package/dist/react/computer-view.js +543 -0
- package/dist/react/computer-viewer.d.ts +175 -0
- package/dist/react/computer-viewer.js +555 -0
- package/dist/react/computer-wire.d.ts +178 -0
- package/dist/react/computer-wire.js +244 -0
- package/dist/react/connect-button.d.ts +145 -0
- package/dist/react/connect-button.js +212 -0
- package/dist/react/connection-request.d.ts +16 -0
- package/dist/react/connection-request.js +18 -0
- package/dist/react/connections-list.d.ts +90 -0
- package/dist/react/connections-list.js +76 -0
- package/dist/react/errors.d.ts +250 -0
- package/dist/react/errors.js +146 -0
- package/dist/react/files.d.ts +41 -0
- package/dist/react/files.js +78 -0
- package/dist/react/index.d.ts +35 -0
- package/dist/react/index.js +26 -0
- package/dist/react/limit-words.d.ts +80 -0
- package/dist/react/limit-words.js +53 -0
- package/dist/react/markdown.d.ts +42 -0
- package/dist/react/markdown.js +56 -0
- package/dist/react/md-parse.d.ts +106 -0
- package/dist/react/md-parse.js +638 -0
- package/dist/react/model-keys-card.d.ts +94 -0
- package/dist/react/model-keys-card.js +123 -0
- package/dist/react/reload.d.ts +211 -0
- package/dist/react/reload.js +339 -0
- package/dist/react/reveal.d.ts +17 -0
- package/dist/react/reveal.js +22 -0
- package/dist/react/schedule-editor.d.ts +107 -0
- package/dist/react/schedule-editor.js +172 -0
- package/dist/react/schedule-time.d.ts +66 -0
- package/dist/react/schedule-time.js +90 -0
- package/dist/react/styles.css +1274 -0
- package/dist/react/transport.d.ts +49 -0
- package/dist/react/transport.js +380 -0
- package/dist/react/use-connections.d.ts +155 -0
- package/dist/react/use-connections.js +231 -0
- package/dist/react/use-model-keys.d.ts +47 -0
- package/dist/react/use-model-keys.js +57 -0
- package/dist/react/use-threads.d.ts +63 -0
- package/dist/react/use-threads.js +73 -0
- package/dist/react/vault-form.d.ts +92 -0
- package/dist/react/vault-form.js +151 -0
- package/dist/schema.d.ts +47 -0
- package/dist/schema.js +16 -0
- package/dist/secrets.d.ts +15 -0
- package/dist/secrets.js +18 -0
- package/dist/stream.d.ts +129 -0
- package/dist/stream.js +192 -0
- package/dist/testing.d.ts +33 -0
- package/dist/testing.js +40 -0
- package/dist/webhooks.d.ts +31 -0
- package/dist/webhooks.js +72 -0
- package/package.json +85 -3
|
@@ -0,0 +1,925 @@
|
|
|
1
|
+
import { type UIMessage } from "ai";
|
|
2
|
+
import { type ReactNode, type Ref } from "react";
|
|
3
|
+
import { type ApprovalRunRefused } from "./approval-card.tsx";
|
|
4
|
+
import { type AgentChatLabels } from "./errors.ts";
|
|
5
|
+
import type { AgentChatMessage } from "../chat-history.ts";
|
|
6
|
+
import type { QueuedReason } from "../stream.ts";
|
|
7
|
+
import { type RunOutcome, type SentMessage } from "./reload.ts";
|
|
8
|
+
import { type VaultFormLabels, type VaultRequest } from "./vault-form.tsx";
|
|
9
|
+
import { type ConnectButtonLabels } from "./connect-button.tsx";
|
|
10
|
+
import { type AgentChatComputer } from "./computer-view.tsx";
|
|
11
|
+
import { type AvatarFor } from "./avatar.tsx";
|
|
12
|
+
import { type KitArtifact, type KitFile } from "./files.ts";
|
|
13
|
+
import { type StopState } from "./chat-timing.ts";
|
|
14
|
+
export { decisionWatch, followUpWaits, lookAfterDecision, noticeLooks, stopStateAfter, type DecisionWatch, type StopState } from "./chat-timing.ts";
|
|
15
|
+
/** What `renderText` is told about the message its text belongs to. */
|
|
16
|
+
export interface RenderTextInfo {
|
|
17
|
+
/**
|
|
18
|
+
* Untrusted content reached the run that wrote this. The kit's renderer still draws its links, each with its host
|
|
19
|
+
* shown; yours may choose otherwise (`<MarkdownText tainted taintedLinks="text">`). Never load a remote image.
|
|
20
|
+
*/
|
|
21
|
+
tainted: boolean;
|
|
22
|
+
role: UIMessage["role"];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Did untrusted content reach the run that wrote `m`? The stream's closing `message-metadata {tainted}`
|
|
26
|
+
* first, then the API's `tainted` (a thread's history, passed as `initialMessages`). An assistant message
|
|
27
|
+
* neither has said anything about yet — a reply still streaming — counts as tainted; a user or system
|
|
28
|
+
* message counts only when it says so.
|
|
29
|
+
*/
|
|
30
|
+
export declare function isMessageTainted(m: UIMessage): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Did a person stop the run that wrote `m`? The API's `stopped` on a reply (a thread's history, passed as
|
|
33
|
+
* `initialMessages`). Only a reply says so: a reply stopped while you watch has no `stopped` yet, and
|
|
34
|
+
* `useAgentChat().stopState` says it.
|
|
35
|
+
*/
|
|
36
|
+
export declare function isMessageStopped(m: UIMessage): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Did reply `m` end in failure? It carries the platform's refusal (`data-refusal`: the run failed, and says why),
|
|
39
|
+
* other than a stop-early one (a limit reached, `run_budget_exhausted` or `run_step_limit`: it stopped, as a reply
|
|
40
|
+
* a person stops does). A reply still being written, one that finished, and one that stopped did not, whatever its
|
|
41
|
+
* steps met on the way: a step refused or failed in it is a quiet line (`data-ol-tool-recovered`), and only a failed
|
|
42
|
+
* reply's steps are drawn as failures (`data-ol-reply-failed` on its row).
|
|
43
|
+
*/
|
|
44
|
+
export declare function replyFailed(m: UIMessage): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* ONE SENTENCE WHEN A REPLY STOPS EARLY. Whether the refusal at `parts[i]`, a stop-early one, is said already by the
|
|
47
|
+
* reply's own words right before it: the engine writes why it stopped as the reply (a budget or step limit), so the
|
|
48
|
+
* platform's sentence for the same stop ("This reply stopped before it finished. …") is not drawn under it. A reply
|
|
49
|
+
* with no words keeps it (it is all the person reads), as does one whose words have a step after them; your own
|
|
50
|
+
* sentence for the code (`labels.refusals`) is always drawn. Step markers, reasoning and `agent.finish` between are
|
|
51
|
+
* nothing.
|
|
52
|
+
*/
|
|
53
|
+
export declare function stopAlreadySaid(parts: readonly UIMessage["parts"][number][], i: number, labels: Pick<AgentChatLabels, "refusals">): boolean;
|
|
54
|
+
/** What `onFinish` is told when a reply ends. */
|
|
55
|
+
export interface AgentChatFinish {
|
|
56
|
+
message: UIMessage;
|
|
57
|
+
status: "finished" | "stopped" | "failed";
|
|
58
|
+
}
|
|
59
|
+
/** How a reply ended, for `onFinish`: stopped by a person, failed (an error, or the platform's refusal), else finished. */
|
|
60
|
+
export declare function finishStatus(message: UIMessage, isAbort: boolean, isError: boolean): AgentChatFinish["status"];
|
|
61
|
+
export interface UseAgentChatOptions {
|
|
62
|
+
/** thr_…, found or created on the server. One per hook for its life: see `useAgentChat`. */
|
|
63
|
+
threadId: string;
|
|
64
|
+
/**
|
|
65
|
+
* The thread's history, oldest first: `toAgentChatMessages(page.data)` of `GET /threads/{id}/messages`. A message
|
|
66
|
+
* built by hand needs its `tainted`, and a person's message its `run`, or a reload can't say how its run ended.
|
|
67
|
+
*/
|
|
68
|
+
initialMessages?: readonly (UIMessage | AgentChatMessage)[];
|
|
69
|
+
/** The kit's chat route. Default "/api/openlegion/chat". */
|
|
70
|
+
api?: string;
|
|
71
|
+
/** Pick a running answer back up on load. Default true. */
|
|
72
|
+
resume?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* AN OPEN CONVERSATION NOTICES WHAT ARRIVES BY ITSELF: a schedule's reply, a hand-off, a decision made
|
|
75
|
+
* elsewhere. While the tab is visible and the chat idle, it looks every this many ms, and once when the tab is
|
|
76
|
+
* shown or focused: one request to the kit's route (`GET {base}/chat/{thr}/stream`, one platform read of the
|
|
77
|
+
* thread). A run in progress is followed and drawn live; none, and the thread changed since the last look, the
|
|
78
|
+
* history is read once and what is new is drawn. Not while hidden, or while a reply is written, sent or awaited;
|
|
79
|
+
* the person typing does not stop it. Default 30000; 0 turns it off.
|
|
80
|
+
*/
|
|
81
|
+
lookEveryMs?: number;
|
|
82
|
+
/** Every error, in full, for YOUR logs. The page shows only `agentChatErrorText`. */
|
|
83
|
+
onError?: (err: Error) => void;
|
|
84
|
+
/**
|
|
85
|
+
* When a reply ends, once the chat has drawn it as the thread holds it (the one read when a reply ends): the
|
|
86
|
+
* reply, and how it ended. "finished": it answered (or stopped at its limit and says so); "stopped": a person
|
|
87
|
+
* stopped it; "failed": it did not go through (the chat says why). For your page around the chat, e.g. to read
|
|
88
|
+
* your menu again after a first file: do it on "finished", as a refresh after a failed send with no network
|
|
89
|
+
* would replace the page.
|
|
90
|
+
*/
|
|
91
|
+
onFinish?: (end: AgentChatFinish) => void;
|
|
92
|
+
/**
|
|
93
|
+
* The `fetch` every call of the chat goes through (else the page's own). It may be written inline: the chat reads
|
|
94
|
+
* the one it was last given at each call, and keeps its one transport (a reply's Stop, the messages sent while it
|
|
95
|
+
* runs) whatever the parent re-renders.
|
|
96
|
+
*/
|
|
97
|
+
fetch?: typeof fetch;
|
|
98
|
+
/** The kit's vault route, for `<VaultSecretForm>`. Default: `api` with `/chat` replaced by `/vault`. */
|
|
99
|
+
vaultApi?: string;
|
|
100
|
+
/**
|
|
101
|
+
* Read the conversation's delivered files into `artifacts`, on load and after each reply, and (on
|
|
102
|
+
* `<AgentChat>`) list them under the transcript. Default false: no such request is made, and each file is a
|
|
103
|
+
* card in the reply that delivered it, its one place.
|
|
104
|
+
*/
|
|
105
|
+
showFiles?: boolean;
|
|
106
|
+
}
|
|
107
|
+
/** What `onSeen` is told: the newest drawn message's id, and when the person saw it (RFC 3339 UTC). */
|
|
108
|
+
export interface SeenMessage {
|
|
109
|
+
message: string;
|
|
110
|
+
at: string;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* THE PERSON SAW THE NEWEST MESSAGE: told once per message id, when it is the newest drawn, in view, the page
|
|
114
|
+
* visible and focused, and not still being written; a newer one is told when it is in view in turn. For your Inbox
|
|
115
|
+
* and notifications, in place of watching the chat's markup.
|
|
116
|
+
*/
|
|
117
|
+
export declare function seenWatch(report: (seen: SeenMessage) => void, now?: () => Date): {
|
|
118
|
+
update(o: {
|
|
119
|
+
newest: string | null;
|
|
120
|
+
inView: boolean;
|
|
121
|
+
visible: boolean;
|
|
122
|
+
focused: boolean;
|
|
123
|
+
writing: boolean;
|
|
124
|
+
}): void;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* SEEN, RECORDED FOR THE PERSON: which id the chat marks seen when `onSeen` fires. A stored message
|
|
128
|
+
* (`msg_…`) by its id, at once. A reply drawn live carries the chat's own id: it is marked with the thread's id for it
|
|
129
|
+
* (`known`, from the read when the reply ends), and if it was seen before that read, then. Only the newest seen is
|
|
130
|
+
* owed: a newer message seen first covers it. The person's own messages are never known here and never marked: the
|
|
131
|
+
* platform counts what they sent as seen.
|
|
132
|
+
*/
|
|
133
|
+
export declare function seenMarks(post: (message: string) => void): {
|
|
134
|
+
seen(id: string): void;
|
|
135
|
+
known(liveId: string, stored: string): void;
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* The request behind `seenMarks`: `markSeen` (so every `<AgentList>` on the page takes the new count). A route with no
|
|
139
|
+
* person behind it (`subject_required`) has nothing to record: the chat stops asking, quietly. Any other failure goes
|
|
140
|
+
* to `onError` for the partner's logs; the person sees nothing, and the next mark is tried.
|
|
141
|
+
*/
|
|
142
|
+
export declare function seenPoster(o: {
|
|
143
|
+
thread: string;
|
|
144
|
+
base: string;
|
|
145
|
+
fetch: typeof fetch;
|
|
146
|
+
onError: () => ((err: Error) => void) | undefined;
|
|
147
|
+
}): (message: string) => Promise<void>;
|
|
148
|
+
/**
|
|
149
|
+
* Did the thread change since the chat last heard? `was`: the stamp of the last 204 (undefined before the
|
|
150
|
+
* first, null from a route that does not say it); `now`: this one's. Only a change between two stamps reads the history.
|
|
151
|
+
*/
|
|
152
|
+
export declare function stampMoved(was: string | null | undefined, now: string | null): boolean;
|
|
153
|
+
/**
|
|
154
|
+
* WHAT THE CHAT HAS HEARD OF THE THREAD: the stamp it last read the conversation at. Its first 204 is the
|
|
155
|
+
* load's read; after that, a look of its own (`noticing`) whose stamp moved reads it. The stamp is heard (`heard`) only
|
|
156
|
+
* once a read is applied: a read that failed, or was skipped while the chat was busy, is tried again at the next
|
|
157
|
+
* look. Another look's 204 (a decision's, a waiting message's) neither reads nor takes the stamp.
|
|
158
|
+
*/
|
|
159
|
+
export declare function stampLedger(): {
|
|
160
|
+
wants(now: string | null, noticing: boolean): boolean;
|
|
161
|
+
heard(now: string | null): void;
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* After an error: the person's last message, if the error says it never reached the agent (a refused or failed send,
|
|
165
|
+
* with no run behind it), else null. A cut reply (`stream_interrupted`) or a run's own error was sent.
|
|
166
|
+
*/
|
|
167
|
+
export declare function unsentAfterError(messages: readonly UIMessage[], err: unknown): string | null;
|
|
168
|
+
/**
|
|
169
|
+
* Why a message was not sent, as the note's `data-ol-unsent-why` says it: `limit` (a spending limit refused it),
|
|
170
|
+
* `refused` (any other refusal: a plan, credits, a paused agent) or `failed` (it did not go: offline, a 5xx,
|
|
171
|
+
* anything else). A page keeps a failure's look for `failed` only.
|
|
172
|
+
*/
|
|
173
|
+
export type UnsentReason = "limit" | "refused" | "failed";
|
|
174
|
+
/** The reason a send's error gives (`UnsentReason`). */
|
|
175
|
+
export declare function unsentReason(err: unknown): UnsentReason;
|
|
176
|
+
/** A message's words and files, to send again as they were. */
|
|
177
|
+
export declare function resendOf(m: UIMessage): {
|
|
178
|
+
text: string;
|
|
179
|
+
files: KitFile[];
|
|
180
|
+
};
|
|
181
|
+
/**
|
|
182
|
+
* Whether a send that failed may have reached the platform all the same: no answer (the connection
|
|
183
|
+
* dropped after the POST went), a 5xx (the route's, or a host's in front of it), or the first send under that id still
|
|
184
|
+
* being stored (409 `idempotency_in_flight`). A refusal or another 4xx was answered, and the platform stored nothing.
|
|
185
|
+
*/
|
|
186
|
+
export declare function mayHaveArrived(err: unknown): boolean;
|
|
187
|
+
/**
|
|
188
|
+
* What Send again sends for a not-sent message, after the failure that marked it (`err`): its words and files as they
|
|
189
|
+
* were, under the SAME id when that failure may have reached the platform (`mayHaveArrived`). The kit route keys a
|
|
190
|
+
* send by the message's id and the platform stores only a completed answer under a key, so the same id is the first
|
|
191
|
+
* send replayed (its run followed) or a fresh try, never a second run. Else `id` is null: a new message, as before.
|
|
192
|
+
*/
|
|
193
|
+
export declare function againOf(m: UIMessage, err: unknown): {
|
|
194
|
+
id: string | null;
|
|
195
|
+
text: string;
|
|
196
|
+
files: KitFile[];
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* The chat's one `fetch`: the partner's latest (`ref.current`), else the page's own, read at each
|
|
200
|
+
* call. The transport is made once with it, so a parent that re-renders with a new inline `fetch` neither replaces the
|
|
201
|
+
* transport (which holds the run a reply follows, for Stop; the runs of messages sent while a reply runs; the replay
|
|
202
|
+
* guard) nor keeps calling the first one.
|
|
203
|
+
*/
|
|
204
|
+
export declare function latestFetch(ref: {
|
|
205
|
+
readonly current: typeof fetch | undefined;
|
|
206
|
+
}): typeof fetch;
|
|
207
|
+
/**
|
|
208
|
+
* The transcript, then the messages that wait behind the current reply, each once. When a reply ends the waiting
|
|
209
|
+
* messages take their place in the transcript and leave the waiting list in two updates, and a render may fall
|
|
210
|
+
* between them: a message already in the transcript is not listed again, and no longer waits.
|
|
211
|
+
*/
|
|
212
|
+
export declare function withWaiting(messages: UIMessage[], waiting: readonly UIMessage[]): {
|
|
213
|
+
messages: UIMessage[];
|
|
214
|
+
waiting: ReadonlySet<string>;
|
|
215
|
+
};
|
|
216
|
+
/**
|
|
217
|
+
* Where the waiting messages go when the reply ends. `answered`: the ones that reply also answered (one run read
|
|
218
|
+
* them all) go before it, so the reply is drawn once, after the last message it answered, as history holds it.
|
|
219
|
+
* `later`: the ones a later run answers go after it. With no reply drawn, both simply follow.
|
|
220
|
+
*/
|
|
221
|
+
export declare function placeAnswered(messages: UIMessage[], answered: readonly UIMessage[], later: readonly UIMessage[]): UIMessage[];
|
|
222
|
+
/** When a reply ends before the thread holds its message, how long before the one more look. */
|
|
223
|
+
export declare const SETTLE_RETRY_MS = 1500;
|
|
224
|
+
/** The reply being written when the view first saw a Stop asked: its id (null if none had begun) and how many parts it had. */
|
|
225
|
+
type StopMark = {
|
|
226
|
+
id: string | null;
|
|
227
|
+
parts: number;
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
230
|
+
* Whether the transcript is still at its end after a scroll event. Near the end (within 48 px), it is; moved up
|
|
231
|
+
* by the person, it is not; otherwise it is as it was. A scroll event is delivered a frame after the scroll, so the
|
|
232
|
+
* chat's own move to the end can arrive after more content grew under it: that is not the person leaving, and the
|
|
233
|
+
* growth is still followed. `before` is the position at the previous event.
|
|
234
|
+
*
|
|
235
|
+
* A real input of the person's just before a move up lets go of the end (`person`: `isScrollInput`), even in a frame
|
|
236
|
+
* where the content changed size. Any other move up is taken here for the layout's: when the content gets shorter the
|
|
237
|
+
* browser moves the position up with it, and says so a frame later; a card drawn in the same frame makes the content
|
|
238
|
+
* taller all the same (d9e3069e: -125 and +148 px in one frame, the position up 123 px). Whether such a move was the
|
|
239
|
+
* layout's after all is `scrollJudge`'s to say. Back within reach of the end, it follows again, whoever moved it.
|
|
240
|
+
*/
|
|
241
|
+
export declare function atEndAfterScroll(was: boolean, before: number, el: {
|
|
242
|
+
scrollTop: number;
|
|
243
|
+
scrollHeight: number;
|
|
244
|
+
clientHeight: number;
|
|
245
|
+
}, seen?: {
|
|
246
|
+
person?: boolean;
|
|
247
|
+
}): boolean;
|
|
248
|
+
/** How many frames after a quiet move up the judge looks again for a size change (`scrollJudge`). */
|
|
249
|
+
export declare const QUIET_FRAMES = 3;
|
|
250
|
+
/**
|
|
251
|
+
* WHAT A SCROLL EVENT MEANS FOR FOLLOWING THE END. A move up is the layout's, and the end is
|
|
252
|
+
* taken back, only when the content changed size around it; with no size change it is the person's, whatever moved
|
|
253
|
+
* it: Shift+Tab to an older control, find-in-page, a screen reader or magnifier, a page's own `scrollIntoView`.
|
|
254
|
+
*
|
|
255
|
+
* A size change is RECORDED WHERE IT HAPPENS (`resized`: every row's ResizeObserver and the list's MutationObserver;
|
|
256
|
+
* not the transcript's own box, whose change never leaves the position short of the end),
|
|
257
|
+
* not read from heights at scroll events: a row above that shrinks while one below grows by as much leaves
|
|
258
|
+
* `scrollHeight` as it was, yet the browser's scroll anchoring moves the position up. A layout moves the position in
|
|
259
|
+
* its own frame and the event reports it in the next, but the observer of that layout can run after the event (a
|
|
260
|
+
* layout made in a task, its observers at the end of the next frame). So a change counts as RECENT for `QUIET_FRAMES`
|
|
261
|
+
* frames after it is seen (`later`); an event with none recent is QUIET; a quiet move up away from the end is held
|
|
262
|
+
* (`then: { confirm }`, the end not taken back yet) and judged by `quiet(mark)` `QUIET_FRAMES` frames on: still no
|
|
263
|
+
* size change since, it was the person's (let go); one came, it was the layout's (take the end back). A change seen
|
|
264
|
+
* long before a move cannot have made it, and does not count against it. The chat taking the end on purpose while a
|
|
265
|
+
* move is held (`took`: a decision made here) voids that move's let-go too.
|
|
266
|
+
*/
|
|
267
|
+
export declare function scrollJudge(later?: (frames: number, fn: () => void) => void): {
|
|
268
|
+
resized(): void;
|
|
269
|
+
took(): void;
|
|
270
|
+
scrolled(atEnd: boolean, el: {
|
|
271
|
+
scrollTop: number;
|
|
272
|
+
scrollHeight: number;
|
|
273
|
+
clientHeight: number;
|
|
274
|
+
}, person: boolean): {
|
|
275
|
+
atEnd: boolean;
|
|
276
|
+
then: "none" | "back" | {
|
|
277
|
+
confirm: number;
|
|
278
|
+
};
|
|
279
|
+
};
|
|
280
|
+
quiet(mark: number): boolean;
|
|
281
|
+
};
|
|
282
|
+
/**
|
|
283
|
+
* Still at the end after a scroll event, but left short of it by a move that was not the person's (the browser's
|
|
284
|
+
* scroll anchoring, a shrink and a growth in one frame): back to the end at once, not at the next change of height.
|
|
285
|
+
*/
|
|
286
|
+
export declare function takesEndBack(atEnd: boolean, el: {
|
|
287
|
+
scrollTop: number;
|
|
288
|
+
scrollHeight: number;
|
|
289
|
+
clientHeight: number;
|
|
290
|
+
}): boolean;
|
|
291
|
+
/**
|
|
292
|
+
* Is this event on the transcript the person moving it? A wheel; a touch that moves (a touch
|
|
293
|
+
* that only lands is a tap: Approve); a key that scrolls or Tab, not in a box of text (Space only on the transcript
|
|
294
|
+
* itself, where it is not a button's press); focus moved by the keyboard to something in it (`:focus-visible`; a
|
|
295
|
+
* click's or a tap's focus is not); a press on the transcript's own scrollbar (past its content box). Nothing else.
|
|
296
|
+
*/
|
|
297
|
+
export declare function isScrollInput(e: {
|
|
298
|
+
type: string;
|
|
299
|
+
key?: string;
|
|
300
|
+
target: unknown;
|
|
301
|
+
offsetX?: number;
|
|
302
|
+
offsetY?: number;
|
|
303
|
+
}, el: {
|
|
304
|
+
clientWidth: number;
|
|
305
|
+
clientHeight: number;
|
|
306
|
+
}): boolean;
|
|
307
|
+
/**
|
|
308
|
+
* How many approval cards the bar says wait for the person: each waiting card's buttons, where they are on
|
|
309
|
+
* screen, and the part of the screen the transcript shows. 0 (no bar) when none waits or one has its buttons wholly
|
|
310
|
+
* in view; else how many wait.
|
|
311
|
+
*/
|
|
312
|
+
export declare function approvalBarCount(all: ReadonlyArray<{
|
|
313
|
+
top: number;
|
|
314
|
+
bottom: number;
|
|
315
|
+
deciding?: boolean;
|
|
316
|
+
}>, view: {
|
|
317
|
+
top: number;
|
|
318
|
+
bottom: number;
|
|
319
|
+
}): number;
|
|
320
|
+
/**
|
|
321
|
+
* OLDER MESSAGES (one ongoing conversation per agent): "more" to read, "loading" while a page is read, "failed" when
|
|
322
|
+
* it was not, "end" at the start of the conversation.
|
|
323
|
+
*/
|
|
324
|
+
export type EarlierState = "more" | "loading" | "failed" | "end";
|
|
325
|
+
/** How near the top (px) the person's scroll reads the next older page: it is there by the time they arrive. */
|
|
326
|
+
export declare const EARLIER_REACH_PX = 200;
|
|
327
|
+
/**
|
|
328
|
+
* Where an older page is read from: the oldest message drawn, when it is a stored one (`msg_…`) of a conversation with
|
|
329
|
+
* an id. Null otherwise: a conversation that began in this visit has nothing older, and one with no id none to read.
|
|
330
|
+
*/
|
|
331
|
+
export declare function earlierFrom(messages: readonly UIMessage[], threadId: string | undefined): string | null;
|
|
332
|
+
/**
|
|
333
|
+
* Whether the view reads the next older page now: only with more to read, in a transcript that scrolls in its own box
|
|
334
|
+
* (without one a "Show earlier messages" button does it), and either the person has left the end and is within
|
|
335
|
+
* `EARLIER_REACH_PX` of the top, or the messages do not fill the box yet. Never on open: the chat opens at its end,
|
|
336
|
+
* and the box's first position (0, before it is taken to the end) is not the person at the top.
|
|
337
|
+
*/
|
|
338
|
+
export declare function wantsEarlier(at: {
|
|
339
|
+
earlier: EarlierState | undefined;
|
|
340
|
+
scrollBox: boolean;
|
|
341
|
+
overflowing: boolean;
|
|
342
|
+
atEnd: boolean;
|
|
343
|
+
top: number;
|
|
344
|
+
}): boolean;
|
|
345
|
+
/**
|
|
346
|
+
* The messages drawn above `first` (the oldest drawn before): an older page the person scrolled back to. Its cards
|
|
347
|
+
* were there before the chat opened, so they are not announced as ones that just turned up (`approvalsToAnnounce`).
|
|
348
|
+
*/
|
|
349
|
+
export declare function rowsAbove(messages: readonly UIMessage[], first: string | null): string[];
|
|
350
|
+
/**
|
|
351
|
+
* THE PERSON'S PLACE IS KEPT (no jump): after older rows went in above, or the line at the top changed, the row they
|
|
352
|
+
* were reading goes back to where it was. A browser that already kept it (scroll anchoring) leaves nothing to move.
|
|
353
|
+
*/
|
|
354
|
+
export declare function keepReadingPlace(el: HTMLElement, place: {
|
|
355
|
+
id: string;
|
|
356
|
+
offset: number;
|
|
357
|
+
}): void;
|
|
358
|
+
/** What `<AgentChat ref>` and `<AgentChatView ref>` hold. */
|
|
359
|
+
export interface AgentChatHandle {
|
|
360
|
+
/**
|
|
361
|
+
* Brings a message (its id) or an approval's card (`apr_…`) into view, as the person's own move would: the
|
|
362
|
+
* transcript stops following its end, and follows again once they return to it. False when it is not drawn (yet),
|
|
363
|
+
* or is not in what the chat has loaded (`onOpenAtMissing` says that for `openAt`).
|
|
364
|
+
*/
|
|
365
|
+
bringIntoView(id: string): boolean;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* THE APP SAYS WHERE THE CHAT GOES: a message by its id, or an approval's card by its `apr_…`. A card: the whole
|
|
369
|
+
* card when it fits the transcript, else its buttons; a message: the whole message when it fits, else from its start.
|
|
370
|
+
* The end is let go of first (`letGo`), so the scroll this makes is not taken back (`takesEndBack`). False, and
|
|
371
|
+
* nothing moved, when it is not drawn.
|
|
372
|
+
*/
|
|
373
|
+
export declare function goToTarget(el: HTMLElement, id: string, letGo: () => void): boolean;
|
|
374
|
+
/**
|
|
375
|
+
* Whether `id` is in what the chat has loaded: a message by its id; an approval (`apr_…`) by a part that asks for it
|
|
376
|
+
* (`approvalOfPart`) or a run's call (`outcomes`). Read from the data, not the page: a card still reading itself counts.
|
|
377
|
+
*/
|
|
378
|
+
export declare function openTargetLoaded(messages: readonly UIMessage[], outcomes: Readonly<Record<string, RunOutcome>> | undefined, id: string): boolean;
|
|
379
|
+
/**
|
|
380
|
+
* OPENAT'S TARGET IS NOT IN THE CHAT: once the history is in (`historyLoaded`), an
|
|
381
|
+
* `openAt` that is not in it is said once per id (`onOpenAtMissing`), so the app can show it on its own. Null: nothing
|
|
382
|
+
* to say (no target, still loading, found, or said before).
|
|
383
|
+
*/
|
|
384
|
+
export declare function openAtMissing(at: {
|
|
385
|
+
openAt: string | undefined;
|
|
386
|
+
historyLoaded: boolean | undefined;
|
|
387
|
+
messages: readonly UIMessage[];
|
|
388
|
+
outcomes: Readonly<Record<string, RunOutcome>> | undefined;
|
|
389
|
+
fired: ReadonlySet<string>;
|
|
390
|
+
}): string | null;
|
|
391
|
+
/** The chat's handle: `goToTarget` on its transcript, once it is drawn. */
|
|
392
|
+
export declare function chatHandle(transcript: () => HTMLElement | null, letGo: () => void): AgentChatHandle;
|
|
393
|
+
/**
|
|
394
|
+
* A DECISION IS THE PERSON ACTING IN THE CHAT: once the platform took an Approve or a Reject here (`decided`
|
|
395
|
+
* gained an approval), the transcript takes its end again, wherever the card was reached from (Review, `openAt`,
|
|
396
|
+
* their own scrolling), so the reply the decision starts is drawn in view. Else `was`.
|
|
397
|
+
*/
|
|
398
|
+
export declare function decisionTakesEnd(was: boolean, before: ReadonlyMap<string, string>, now: ReadonlyMap<string, string>): boolean;
|
|
399
|
+
/**
|
|
400
|
+
* WHICH WAITING CARDS ARE SAID: a card waiting for the person that turned up after the chat opened (its
|
|
401
|
+
* message not in the history it opened with, `initial`), and not said already (`said`). The transcript is `aria-busy`
|
|
402
|
+
* while a reply streams, so a status line outside it says them.
|
|
403
|
+
*/
|
|
404
|
+
export declare function approvalsToAnnounce(cards: ReadonlyArray<{
|
|
405
|
+
id: string;
|
|
406
|
+
title: string;
|
|
407
|
+
message: string | null;
|
|
408
|
+
}>, said: ReadonlySet<string>, initial: ReadonlySet<string>): Array<{
|
|
409
|
+
id: string;
|
|
410
|
+
title: string;
|
|
411
|
+
}>;
|
|
412
|
+
export declare function ApprovalBar(props: {
|
|
413
|
+
count: number;
|
|
414
|
+
labels: AgentChatLabels;
|
|
415
|
+
onReview: () => void;
|
|
416
|
+
}): import("react").JSX.Element;
|
|
417
|
+
/**
|
|
418
|
+
* NO NEW STEP AFTER STOP. The engine starts no new work once Stop is asked, but the model's next call can
|
|
419
|
+
* still stream in ("Writing a file…" 0.7 s after the tap, for a call that never ran). True for a tool part of the
|
|
420
|
+
* reply being written that was not there when the stop was seen (`at`): the view does not draw it. Words are still
|
|
421
|
+
* drawn, and a call there at the tap is drawn as it goes on. No stop asked (`at` null): false.
|
|
422
|
+
*/
|
|
423
|
+
export declare function stepAfterStop(at: StopMark | null, m: UIMessage, i: number): boolean;
|
|
424
|
+
/**
|
|
425
|
+
* `useChat` with the kit's transport, the queued state, Stop and Reconnect: for a builder who draws their own UI.
|
|
426
|
+
* It serves one thread for its life: to show another, mount the component that calls it again, with
|
|
427
|
+
* `key={threadId}` (`<AgentChat>` does this itself).
|
|
428
|
+
*/
|
|
429
|
+
export declare function useAgentChat(opts: UseAgentChatOptions): {
|
|
430
|
+
/** The transcript: `useChat`'s messages, then the person's messages that wait behind the current reply. */
|
|
431
|
+
messages: UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>[];
|
|
432
|
+
/** `useChat`'s error, else why a message sent while a reply was on its way did not go. */
|
|
433
|
+
error: Error | undefined;
|
|
434
|
+
/** The person's messages (by id) that wait behind the current reply: sent, and answered after it. */
|
|
435
|
+
waiting: ReadonlySet<string>;
|
|
436
|
+
/**
|
|
437
|
+
* Stop the reply: cancels the run (not only the watching). `stopState` says where it stands; `stopped`
|
|
438
|
+
* once the run's stream says so.
|
|
439
|
+
*/
|
|
440
|
+
stop: () => Promise<void>;
|
|
441
|
+
/** Where a Stop stands (`stopping`, `stopped`, `failed`), else null. Cleared by the next send. */
|
|
442
|
+
stopState: StopState | null;
|
|
443
|
+
/**
|
|
444
|
+
* After Approve or Reject, until the reply the decision starts has ended (or 30 s with none found): the chat is
|
|
445
|
+
* working, though no request of its own is out yet. `agentChatViewProps` draws it as `busy`.
|
|
446
|
+
*/
|
|
447
|
+
awaitingReply: boolean;
|
|
448
|
+
/**
|
|
449
|
+
* Approve or Reject was tapped (`<AgentChatView onApprovalDeciding>`): working from now, and once the platform
|
|
450
|
+
* took the decision (`taken` true), follow the run it starts (`followUp`).
|
|
451
|
+
*/
|
|
452
|
+
afterDecision: (taken: Promise<boolean>) => void;
|
|
453
|
+
/** `awaitingReply`, and the reply it waits for has no words yet: "Thinking…" shows (`<AgentChatView awaitingWords>`). */
|
|
454
|
+
awaitingWords: boolean;
|
|
455
|
+
/** How many times the chat has looked for what arrived: `<AgentChatView approvalLook>`. */
|
|
456
|
+
looks: number;
|
|
457
|
+
/** The history is in (the load's re-read tried, its runs' outcomes read): `<AgentChatView historyLoaded>`. */
|
|
458
|
+
historyLoaded: boolean;
|
|
459
|
+
/**
|
|
460
|
+
* Older messages: "more", "loading", "failed" or "end"; undefined when there is nothing older to read (a
|
|
461
|
+
* conversation that began in this visit). `<AgentChatView earlier>`.
|
|
462
|
+
*/
|
|
463
|
+
earlier: EarlierState | undefined;
|
|
464
|
+
/** Read the page before the oldest message shown and put it above (`<AgentChatView onLoadEarlier>`). One at a time. */
|
|
465
|
+
loadEarlier: () => void;
|
|
466
|
+
/**
|
|
467
|
+
* The person saw this message (`<AgentChatView onSeen>`): recorded for them, `POST {base}/threads/{thread}/seen`,
|
|
468
|
+
* with the thread's id for a reply drawn live (once the read when it ended gives it). Their own messages are not
|
|
469
|
+
* sent: the platform counts them as seen. `agentChatViewProps` calls it before your `onSeen`.
|
|
470
|
+
*/
|
|
471
|
+
seen: (s: SeenMessage) => void;
|
|
472
|
+
/** Under a person's message (by id) whose run left no answer: how it ended. */
|
|
473
|
+
runOutcomes: Readonly<Record<string, RunOutcome>>;
|
|
474
|
+
/** The vault asks (`<message id>:<part index>`) already saved: their form is not drawn again. */
|
|
475
|
+
savedAsks: ReadonlySet<string>;
|
|
476
|
+
/** The person's messages (by id) that were refused or did not go: shown as not sent, with Send again. */
|
|
477
|
+
unsent: ReadonlySet<string>;
|
|
478
|
+
/** Why each of `unsent` was not sent (`UnsentReason`), by message id. */
|
|
479
|
+
unsentReasons: ReadonlyMap<string, UnsentReason>;
|
|
480
|
+
/**
|
|
481
|
+
* Send a not-sent message again, as it was: it moves to the end, and is no longer marked. After a failure that may
|
|
482
|
+
* have reached the platform (no answer, a 5xx) it goes under the same id, so it never starts a second run.
|
|
483
|
+
*/
|
|
484
|
+
sendAgain: (id: string) => void;
|
|
485
|
+
/** The message's place in the queue while it waits, else null. */
|
|
486
|
+
queued: number | null;
|
|
487
|
+
/** Why the message waits (`thread_busy`, `agent_busy`, `agent_paused`, `workspace_busy`), else null. */
|
|
488
|
+
queuedReason: QueuedReason | null;
|
|
489
|
+
/** The files the agent delivered in this conversation, newest first. Read only with `showFiles`; empty without it. */
|
|
490
|
+
artifacts: readonly KitArtifact[];
|
|
491
|
+
/** The link that downloads one of `artifacts`, or the file of a `data-artifact` part. */
|
|
492
|
+
artifactHref: (id: string) => string;
|
|
493
|
+
/** A delivered Markdown or plain-text file's words, for its preview (at most 256 KB); null when they can't be read. */
|
|
494
|
+
artifactText: (id: string) => Promise<string | null>;
|
|
495
|
+
/** Upload one file the person picked, for the next message. Its id goes with `send`. */
|
|
496
|
+
attach: (file: Blob & {
|
|
497
|
+
name: string;
|
|
498
|
+
}) => Promise<KitFile>;
|
|
499
|
+
/**
|
|
500
|
+
* Send a message, with the files `attach` uploaded (at most 5). While a reply is on its way it is sent at
|
|
501
|
+
* once all the same, shown as waiting (`waiting`), and answered after that reply.
|
|
502
|
+
*/
|
|
503
|
+
send: (text: string, files?: readonly KitFile[]) => Promise<void>;
|
|
504
|
+
/**
|
|
505
|
+
* After an interrupted reply: follow that run again from its start, in place of the half-shown reply. If the
|
|
506
|
+
* Reconnect fails before the replay brings anything, the half-shown reply comes back and Reconnect is offered again.
|
|
507
|
+
*/
|
|
508
|
+
reconnect: () => Promise<void>;
|
|
509
|
+
id: string;
|
|
510
|
+
setMessages: (messages: UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>[] | ((messages: UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>[]) => UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>[])) => void;
|
|
511
|
+
status: import("ai").ChatStatus;
|
|
512
|
+
sendMessage: (message?: (Omit<UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>, "id" | "role"> & {
|
|
513
|
+
id?: string | undefined;
|
|
514
|
+
role?: "user" | "system" | "assistant" | undefined;
|
|
515
|
+
} & {
|
|
516
|
+
text?: never;
|
|
517
|
+
files?: never;
|
|
518
|
+
messageId?: string;
|
|
519
|
+
}) | {
|
|
520
|
+
text: string;
|
|
521
|
+
files?: FileList | import("ai").FileUIPart[];
|
|
522
|
+
metadata?: unknown;
|
|
523
|
+
parts?: never;
|
|
524
|
+
messageId?: string;
|
|
525
|
+
} | {
|
|
526
|
+
files: FileList | import("ai").FileUIPart[];
|
|
527
|
+
metadata?: unknown;
|
|
528
|
+
parts?: never;
|
|
529
|
+
messageId?: string;
|
|
530
|
+
} | undefined, options?: import("ai").ChatRequestOptions) => Promise<void>;
|
|
531
|
+
regenerate: ({ messageId, ...options }?: {
|
|
532
|
+
messageId?: string;
|
|
533
|
+
} & import("ai").ChatRequestOptions) => Promise<void>;
|
|
534
|
+
resumeStream: (options?: import("ai").ChatRequestOptions) => Promise<void>;
|
|
535
|
+
addToolResult: import("ai").ChatAddToolOutputFunction<UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>>;
|
|
536
|
+
addToolOutput: import("ai").ChatAddToolOutputFunction<UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>>;
|
|
537
|
+
addToolApprovalResponse: import("ai").ChatAddToolApproveResponseFunction;
|
|
538
|
+
clearError: () => void;
|
|
539
|
+
};
|
|
540
|
+
export interface AgentChatProps extends UseAgentChatOptions {
|
|
541
|
+
/** Every visible string: for your language, and your product's voice. */
|
|
542
|
+
labels?: Partial<AgentChatLabels>;
|
|
543
|
+
/**
|
|
544
|
+
* Your renderer for message text, in place of the kit's. Default: the agent's Markdown drawn by the kit's safe
|
|
545
|
+
* subset (`<MarkdownText>`), a person's words as they are with line breaks kept. `info.tainted` says untrusted
|
|
546
|
+
* content reached the run: load no remote image, and choose how its links are drawn (README "Rendering replies
|
|
547
|
+
* safely").
|
|
548
|
+
*/
|
|
549
|
+
renderText?: (text: string, info: RenderTextInfo) => ReactNode;
|
|
550
|
+
/** Show each tool call's name and state (never its input or output). Default true. */
|
|
551
|
+
showToolCalls?: boolean;
|
|
552
|
+
/**
|
|
553
|
+
* "fold" (default): while the agent works, the step it is on; once the reply is done, one line ("2 steps") that
|
|
554
|
+
* opens to the list. "list": every step on its own line, always.
|
|
555
|
+
*/
|
|
556
|
+
steps?: "fold" | "list";
|
|
557
|
+
/** "fold" (default): an approval card shows its first two facts, the rest behind "Details". "all": every fact. */
|
|
558
|
+
approvalFields?: "fold" | "all";
|
|
559
|
+
className?: string;
|
|
560
|
+
vaultLabels?: Partial<VaultFormLabels>;
|
|
561
|
+
/** The Connect button's words, where an agent asks your user to connect an app (`labels.done` is the carry-on). */
|
|
562
|
+
connectLabels?: Partial<ConnectButtonLabels>;
|
|
563
|
+
/** First messages to offer while the conversation is empty, as chips: tapping one sends it. */
|
|
564
|
+
suggestions?: readonly string[];
|
|
565
|
+
/** Where the suggestions are: "start" (default), above the transcript, or "end", right under the message box. */
|
|
566
|
+
suggestionsAt?: "start" | "end";
|
|
567
|
+
/** Put the cursor in the message box when the chat appears. Default false. */
|
|
568
|
+
autoFocus?: boolean;
|
|
569
|
+
/**
|
|
570
|
+
* The bar right above the message box while an approval card the person can decide is out of sight: "Waiting for
|
|
571
|
+
* your OK" and "Review", which brings the card into view (`data-ol-approval-bar`). Default true; false turns it off.
|
|
572
|
+
*/
|
|
573
|
+
approvalBar?: boolean;
|
|
574
|
+
/**
|
|
575
|
+
* The person saw the newest message: called once per message, when the newest drawn message is in view while
|
|
576
|
+
* the page is visible and focused (a reply being written, once it has ended); again for a newer one. Nothing while
|
|
577
|
+
* the tab is hidden or the message is out of view. `message` is its id (a message sent in this visit carries the
|
|
578
|
+
* chat's own id until the page is loaded again); `at`, when it was seen. The chat also records it for the person
|
|
579
|
+
* (`<AgentList>`'s badge), with or without this.
|
|
580
|
+
*/
|
|
581
|
+
onSeen?: (seen: SeenMessage) => void;
|
|
582
|
+
/**
|
|
583
|
+
* One quiet line above a reply a schedule started, `labels.fromSchedule` ("From your schedule"), hook
|
|
584
|
+
* `data-ol-from-schedule`: read from the history's `trigger` (`toAgentChatMessages`). Default true; false turns it off.
|
|
585
|
+
*/
|
|
586
|
+
fromSchedule?: boolean;
|
|
587
|
+
/**
|
|
588
|
+
* The agent's name: each of its messages is signed with it, after its avatar, in place of `labels.agent`. Absent:
|
|
589
|
+
* `labels.agent` ("Agent") and no avatar, as before.
|
|
590
|
+
*/
|
|
591
|
+
agentName?: string;
|
|
592
|
+
/**
|
|
593
|
+
* With `agentName`: the picture before it, yours (`(agent) => <img src={…} alt="" />`), in a fixed box (nothing
|
|
594
|
+
* moves when it loads or fails). Absent: the name's first letter in a circle. Null: none. The art is yours.
|
|
595
|
+
*/
|
|
596
|
+
avatar?: AvatarFor<{
|
|
597
|
+
name: string;
|
|
598
|
+
}>;
|
|
599
|
+
/**
|
|
600
|
+
* Where the chat opens: a message's id, or an approval's (`apr_…`) for its card. Brought into view once it is
|
|
601
|
+
* drawn (a card, once it has read itself), as the person's own move: the chat no longer follows its end until they
|
|
602
|
+
* return to it. Not once the person has scrolled by hand meanwhile. A new value goes there again.
|
|
603
|
+
*/
|
|
604
|
+
openAt?: string;
|
|
605
|
+
/**
|
|
606
|
+
* `openAt`'s target is not in what the chat has loaded (the newest messages): called once per id, once the history
|
|
607
|
+
* is in. Show that approval on its own, or say it could not be found. The chat does not page
|
|
608
|
+
* back for it.
|
|
609
|
+
*/
|
|
610
|
+
onOpenAtMissing?: (id: string) => void;
|
|
611
|
+
/** The chat's handle: `bringIntoView(id)`, the same move later (`AgentChatHandle`). */
|
|
612
|
+
ref?: Ref<AgentChatHandle>;
|
|
613
|
+
/** Yours, drawn right above the message box (after the chat's status lines): a spending meter, a note. */
|
|
614
|
+
beforeComposer?: ReactNode;
|
|
615
|
+
/** Yours, drawn under the message box (after the suggestions, when they are at the "end"). */
|
|
616
|
+
afterComposer?: ReactNode;
|
|
617
|
+
/**
|
|
618
|
+
* The person may read this chat and not send in it (a plan they don't have): your sentence, and your link, where the
|
|
619
|
+
* message box was, in its footprint (`ComposerOff`). The history, its cards and their buttons stay usable; nothing
|
|
620
|
+
* the kit sends itself goes. Your server's refusal is still the gate. Absent: the box, as before.
|
|
621
|
+
*/
|
|
622
|
+
composerOff?: ComposerOff | undefined;
|
|
623
|
+
/**
|
|
624
|
+
* The agent's browser: each `data-computer` part is a one-line row (what the agent is doing, the
|
|
625
|
+
* site), and with `fetchViewer` a Watch button that opens `<ComputerView>` in place, to watch, take over and give
|
|
626
|
+
* back. `fetchViewer` asks YOUR server for a viewer grant (`readViewerGrant` reads its answer); only the person
|
|
627
|
+
* the conversation belongs to may watch or take over, and your server is where that is decided. Absent: the row
|
|
628
|
+
* alone, with no Watch.
|
|
629
|
+
*/
|
|
630
|
+
computer?: AgentChatComputer | undefined;
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
633
|
+
* `<AgentChat composerOff>`: the message box is off, and your sentence is where it was.
|
|
634
|
+
*
|
|
635
|
+
* <AgentChat composerOff={{ now: !hasPlan, text: "Choose a plan to send messages.", link: { href: "/plans", text: "See plans" }, code: "plan_required" }} />
|
|
636
|
+
*/
|
|
637
|
+
export interface ComposerOff {
|
|
638
|
+
/** Your sentence in the box's place, said politely when it appears (`data-ol-composer-note`, role status). */
|
|
639
|
+
text: string;
|
|
640
|
+
/** A link after the sentence (`data-ol-composer-link`): your plans page. */
|
|
641
|
+
link?: {
|
|
642
|
+
href: string;
|
|
643
|
+
text: string;
|
|
644
|
+
} | undefined;
|
|
645
|
+
/** Off now. Default true. False: the box is on, and turns off only when a send is refused with `code`. */
|
|
646
|
+
now?: boolean | undefined;
|
|
647
|
+
/**
|
|
648
|
+
* Your server's refusal code for the same reason (the `error.code` of its 402). A send refused with it turns the
|
|
649
|
+
* box off with your sentence, in place of the failure line, until `now` changes or the chat opens again.
|
|
650
|
+
*/
|
|
651
|
+
code?: string | undefined;
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* Whether the box is off: off now, or a send refused with the host's code (`refused`: one was, since `now` last
|
|
655
|
+
* changed).
|
|
656
|
+
*/
|
|
657
|
+
export declare function composerIsOff(spec: ComposerOff | undefined, error: unknown, refused: boolean): boolean;
|
|
658
|
+
/** What `useAgentChat` returns. */
|
|
659
|
+
export type AgentChatState = ReturnType<typeof useAgentChat>;
|
|
660
|
+
/**
|
|
661
|
+
* `<AgentChatView>`'s whole prop set, from `useAgentChat`'s result and `<AgentChat>`'s own props: what
|
|
662
|
+
* `<AgentChat>` passes, so a chat of yours with one more thing never lacks what it wires.
|
|
663
|
+
*
|
|
664
|
+
* const chat = useAgentChat(props);
|
|
665
|
+
* return (
|
|
666
|
+
* <>
|
|
667
|
+
* <AgentChatView {...agentChatViewProps(chat, props)} />
|
|
668
|
+
* <button onClick={() => void chat.send("Plan my week")}>Plan my week</button>
|
|
669
|
+
* </>
|
|
670
|
+
* );
|
|
671
|
+
*/
|
|
672
|
+
export declare function agentChatViewProps(chat: AgentChatState, props: AgentChatProps): AgentChatViewProps;
|
|
673
|
+
/**
|
|
674
|
+
* Keyed by thread: a new `threadId` is a new chat, so sends, uploads, the files list and
|
|
675
|
+
* the history reads all go to the thread shown. Your own `key={threadId}` is harmless.
|
|
676
|
+
*/
|
|
677
|
+
export declare function AgentChat(props: AgentChatProps): import("react").JSX.Element;
|
|
678
|
+
export interface AgentChatViewProps {
|
|
679
|
+
messages: UIMessage[];
|
|
680
|
+
/** The conversation (`thr_…`): a vault form in a reply names it, with its message, as the ask it answers. */
|
|
681
|
+
threadId?: string | undefined;
|
|
682
|
+
busy: boolean;
|
|
683
|
+
error: Error | undefined;
|
|
684
|
+
queued: number | null;
|
|
685
|
+
/** Why the message waits, when the server says (`data-queued.reason`): picks the line `queuedText` shows. */
|
|
686
|
+
queuedReason?: QueuedReason | null | undefined;
|
|
687
|
+
labels?: Partial<AgentChatLabels> | undefined;
|
|
688
|
+
renderText?: ((text: string, info: RenderTextInfo) => ReactNode) | undefined;
|
|
689
|
+
showToolCalls?: boolean | undefined;
|
|
690
|
+
/** "fold" (default) or "list": see `<AgentChat steps>`. */
|
|
691
|
+
steps?: "fold" | "list" | undefined;
|
|
692
|
+
/** "fold" (default) or "all": see `<AgentChat approvalFields>`. */
|
|
693
|
+
approvalFields?: "fold" | "all" | undefined;
|
|
694
|
+
className?: string | undefined;
|
|
695
|
+
/** First messages to offer while the conversation is empty, as chips: tapping one calls `onSend` with it. */
|
|
696
|
+
suggestions?: readonly string[] | undefined;
|
|
697
|
+
/** "start" (default) or "end": see `<AgentChat suggestionsAt>`. */
|
|
698
|
+
suggestionsAt?: "start" | "end" | undefined;
|
|
699
|
+
/** Put the cursor in the message box when the chat appears. */
|
|
700
|
+
autoFocus?: boolean | undefined;
|
|
701
|
+
/** The bar while a waiting approval card is out of sight: see `<AgentChat approvalBar>`. Default true. */
|
|
702
|
+
approvalBar?: boolean | undefined;
|
|
703
|
+
/** The line above a reply a schedule started: see `<AgentChat fromSchedule>`. Default true. */
|
|
704
|
+
fromSchedule?: boolean | undefined;
|
|
705
|
+
/** The agent's name and its avatar: see `<AgentChat agentName avatar>`. */
|
|
706
|
+
agentName?: string | undefined;
|
|
707
|
+
avatar?: AvatarFor<{
|
|
708
|
+
name: string;
|
|
709
|
+
}>;
|
|
710
|
+
/** Yours, right above the message box: see `<AgentChat beforeComposer>`. */
|
|
711
|
+
beforeComposer?: ReactNode;
|
|
712
|
+
/** Yours, under the message box: see `<AgentChat afterComposer>`. */
|
|
713
|
+
afterComposer?: ReactNode;
|
|
714
|
+
/** The box off, your sentence in its place: see `<AgentChat composerOff>`. */
|
|
715
|
+
composerOff?: ComposerOff | undefined;
|
|
716
|
+
/** The agent's browser, its row and Watch: see `<AgentChat computer>`. */
|
|
717
|
+
computer?: AgentChatComputer | undefined;
|
|
718
|
+
/**
|
|
719
|
+
* `files`: what the person attached, uploaded by `onAttach`. Called while `busy` too: the box is never locked
|
|
720
|
+
* by a reply (`useAgentChat().send` sends such a message to wait its turn).
|
|
721
|
+
*/
|
|
722
|
+
onSend: (text: string, files?: readonly KitFile[]) => void;
|
|
723
|
+
/** The person's messages (by id) that wait behind the current reply (`useAgentChat().waiting`): marked, with the sentence that says so. */
|
|
724
|
+
waiting?: ReadonlySet<string> | undefined;
|
|
725
|
+
/** Stop the reply (`useAgentChat().stop`). Absent, there is no Stop button: Send stays in its place. */
|
|
726
|
+
onStop?: (() => void) | undefined;
|
|
727
|
+
/** Where a Stop stands (`useAgentChat().stopState`). */
|
|
728
|
+
stopState?: StopState | null | undefined;
|
|
729
|
+
onReconnect: () => void;
|
|
730
|
+
/** Upload a picked file (`useAgentChat().attach`). Absent, there is no attach button. */
|
|
731
|
+
onAttach?: ((file: File) => Promise<KitFile>) | undefined;
|
|
732
|
+
/** The files the agent delivered in this conversation (`useAgentChat().artifacts`), each linked by `artifactHref`. */
|
|
733
|
+
/** Also list `artifacts` under the transcript. Default false: a delivered file is its card in the reply. */
|
|
734
|
+
showFiles?: boolean | undefined;
|
|
735
|
+
artifacts?: readonly KitArtifact[] | undefined;
|
|
736
|
+
artifactHref?: ((id: string) => string) | undefined;
|
|
737
|
+
/** Reads a delivered text file's words for its card's preview (`useAgentChat().artifactText`). Absent, a text file's card has no preview. */
|
|
738
|
+
artifactText?: ((id: string) => Promise<string | null>) | undefined;
|
|
739
|
+
/** Where `<VaultSecretForm>` posts; absent, the form posts to "/api/openlegion/vault". */
|
|
740
|
+
vaultApi?: string | undefined;
|
|
741
|
+
vaultLabels?: Partial<VaultFormLabels> | undefined;
|
|
742
|
+
/** After a save: the handle, and the request it answered (its label, kind and whether it was tainted). */
|
|
743
|
+
onVaultSaved?: ((handle: string, request?: VaultRequest) => void) | undefined;
|
|
744
|
+
onVaultError?: ((err: Error) => void) | undefined;
|
|
745
|
+
/** Where an agent asks your user to connect an app: the Connect button's route, words and carry-on. */
|
|
746
|
+
connect?: ConnectProps | undefined;
|
|
747
|
+
/** Under a person's message (by id) whose run left no answer: how it ended (`useAgentChat().runOutcomes`). */
|
|
748
|
+
runOutcomes?: Readonly<Record<string, RunOutcome>> | undefined;
|
|
749
|
+
/** Vault asks (`<message id>:<part index>`) already saved: drawn as their tool line only (`useAgentChat().savedAsks`). */
|
|
750
|
+
savedAsks?: ReadonlySet<string> | undefined;
|
|
751
|
+
/** The person's messages (by id) that were refused or did not go (`useAgentChat().unsent`): marked, with Send again. */
|
|
752
|
+
unsent?: ReadonlySet<string> | undefined;
|
|
753
|
+
/**
|
|
754
|
+
* Why each not-sent message was not sent (`useAgentChat().unsentReasons`), drawn as the note's `data-ol-unsent-why`:
|
|
755
|
+
* `limit`, `refused` or `failed`. Without it, the reason is read from `error`, else `failed`.
|
|
756
|
+
*/
|
|
757
|
+
unsentReasons?: ReadonlyMap<string, UnsentReason> | undefined;
|
|
758
|
+
/** Send a not-sent message again (`useAgentChat().sendAgain`). */
|
|
759
|
+
onSendAgain?: ((id: string) => void) | undefined;
|
|
760
|
+
/** The kit's base path, for the approval card's routes. Default "/api/openlegion". */
|
|
761
|
+
approvalBase?: string | undefined;
|
|
762
|
+
/**
|
|
763
|
+
* Changes each time the chat looks for what arrived (`<AgentChat>` passes the hook's `looks`): every pending
|
|
764
|
+
* approval card reads its approval again, so one decided elsewhere or expired stops offering its buttons. A pending
|
|
765
|
+
* card also reads again when the tab comes back. Without it, only the tab coming back.
|
|
766
|
+
*/
|
|
767
|
+
approvalLook?: number | undefined;
|
|
768
|
+
/** The person saw the newest message: see `<AgentChat onSeen>`. */
|
|
769
|
+
onSeen?: ((seen: SeenMessage) => void) | undefined;
|
|
770
|
+
/** Where the chat opens: see `<AgentChat openAt>`. */
|
|
771
|
+
openAt?: string | undefined;
|
|
772
|
+
/** See `<AgentChat onOpenAtMissing>`. Called only once `historyLoaded` is true. */
|
|
773
|
+
onOpenAtMissing?: ((id: string) => void) | undefined;
|
|
774
|
+
/** The history is in (`<AgentChat>` passes the hook's): until then, `openAt`'s target is not said to be missing. */
|
|
775
|
+
historyLoaded?: boolean | undefined;
|
|
776
|
+
/**
|
|
777
|
+
* Older messages (`useAgentChat().earlier`): "more", "loading", "failed" or "end". Undefined: nothing older to read,
|
|
778
|
+
* and no line at the top.
|
|
779
|
+
*/
|
|
780
|
+
earlier?: EarlierState | undefined;
|
|
781
|
+
/** Read the page before the oldest message shown (`useAgentChat().loadEarlier`): when the person nears the top. */
|
|
782
|
+
onLoadEarlier?: (() => void) | undefined;
|
|
783
|
+
/** The chat's handle: see `<AgentChat ref>`. */
|
|
784
|
+
ref?: Ref<AgentChatHandle> | undefined;
|
|
785
|
+
/**
|
|
786
|
+
* Approve or Reject was tapped on an approval card, before the platform answers; `taken` resolves true once it
|
|
787
|
+
* took the decision with a run to follow. `agentChatViewProps` passes `useAgentChat().afterDecision`: working from
|
|
788
|
+
* then, and never for a decision with no run to follow.
|
|
789
|
+
*/
|
|
790
|
+
onApprovalDeciding?: ((decision: "approve" | "reject", taken: Promise<boolean>) => void) | undefined;
|
|
791
|
+
/**
|
|
792
|
+
* After Approve or Reject, before the reply it starts has words (`useAgentChat().awaitingWords`): "Thinking…" shows
|
|
793
|
+
* though the last row already has words (the reply that asked).
|
|
794
|
+
*/
|
|
795
|
+
awaitingWords?: boolean | undefined;
|
|
796
|
+
/** The `fetch` the chat's Approve and Reject, Connect button and vault form go through (else the page's own). */
|
|
797
|
+
fetch?: typeof fetch | undefined;
|
|
798
|
+
}
|
|
799
|
+
interface ConnectProps {
|
|
800
|
+
api?: string | undefined;
|
|
801
|
+
labels?: Partial<ConnectButtonLabels> | undefined;
|
|
802
|
+
onConnected?: ((app: string, appName: string) => void) | undefined;
|
|
803
|
+
onError?: ((err: Error) => void) | undefined;
|
|
804
|
+
}
|
|
805
|
+
type ApprovalProps = Pick<AgentChatViewProps, "approvalBase" | "onApprovalDeciding" | "fetch" | "approvalFields" | "approvalLook"> & {
|
|
806
|
+
/** Decided in this chat: its card stays where it was, and keeps this chat's words if mounted again. */
|
|
807
|
+
decidedHere?: (approval: string) => boolean;
|
|
808
|
+
/** The platform took a decision on this card, in the row it is drawn in; `refused`: an Approve with no run to follow (`refusalAfterDecision`). */
|
|
809
|
+
tookHere?: (approval: string, refused: ApprovalRunRefused | null) => void;
|
|
810
|
+
/** The carry-on after this chat's decision on it is over: it says "Approved.". */
|
|
811
|
+
settled?: (approval: string) => boolean;
|
|
812
|
+
/** Approved here with no run to follow: the refused send's note, under the card. */
|
|
813
|
+
refused?: (approval: string) => ApprovalRunRefused | undefined;
|
|
814
|
+
};
|
|
815
|
+
/**
|
|
816
|
+
* REJECT-THINKING: what is drawn under a card the platform took with no run to follow (`run_refused`). After Approve,
|
|
817
|
+
* the note a send refused now gets (the platform's sentence, or the limit and when it resets); after Reject nothing:
|
|
818
|
+
* the agent was not going to do it anyway.
|
|
819
|
+
*/
|
|
820
|
+
export declare function refusalAfterDecision(decision: "approve" | "reject", runRefused: ApprovalRunRefused | null): ApprovalRunRefused | null;
|
|
821
|
+
/**
|
|
822
|
+
* The approval a tool part names, decided or not: its `apr_…`, else null. The stream names it while the call waits
|
|
823
|
+
* (`output.approval`); history names it on every call that needed one, after the decision too (on its output, or on
|
|
824
|
+
* the part itself for a call that ended in an error, as a rejected one does).
|
|
825
|
+
*/
|
|
826
|
+
/**
|
|
827
|
+
* "CARRIES ON" ENDS WHEN THE CARRY-ON ENDS. A card decided in this chat (`decided`) while the chat works
|
|
828
|
+
* after the decision (`busy`: the decision's look and its reply) is carrying on; once the chat stops working (that
|
|
829
|
+
* reply ended, or 30 s with none found), it is `settled` and says "Approved.", as a reload does. A card decided with
|
|
830
|
+
* the chat never working (a view with no hook) keeps its words. Unchanged: the same object, so nothing draws again.
|
|
831
|
+
*/
|
|
832
|
+
export interface CarryOn {
|
|
833
|
+
readonly working: ReadonlySet<string>;
|
|
834
|
+
readonly settled: ReadonlySet<string>;
|
|
835
|
+
}
|
|
836
|
+
export declare function carriedOn(was: CarryOn | undefined, now: {
|
|
837
|
+
busy: boolean;
|
|
838
|
+
decided: Iterable<string>;
|
|
839
|
+
}): CarryOn;
|
|
840
|
+
/** One bubble of a reply: a run of its parts (`reply`: the last, the reply itself), or a message it sent as it went. */
|
|
841
|
+
export type ChatBubble = {
|
|
842
|
+
kind: "parts";
|
|
843
|
+
parts: number[];
|
|
844
|
+
reply: boolean;
|
|
845
|
+
} | {
|
|
846
|
+
kind: "message";
|
|
847
|
+
part: number;
|
|
848
|
+
message: SentMessage;
|
|
849
|
+
};
|
|
850
|
+
/**
|
|
851
|
+
* MESSAGES A RUN SENDS AS IT GOES: a reply's bubbles. Each message it sent (`data-message`) is its own bubble
|
|
852
|
+
* where it fell: the parts before it close as one bubble, and later parts start a new one, so the last bubble is the
|
|
853
|
+
* reply. A run of parts that says nothing (`says`: words, a card, a file; a wait's step line does not) is not a bubble
|
|
854
|
+
* of its own between two messages: its parts go on to the next bubble, so twelve numbers are twelve bubbles. The
|
|
855
|
+
* parts after the last message are the reply when any of them shows (`shows`), or when `tail` asks for it (a Stopped
|
|
856
|
+
* line to put under it). A message already drawn (`drawn`: a row of its own, from a reload or the thread's read) or
|
|
857
|
+
* carried twice is drawn once. A reply with no message is one bubble, as before.
|
|
858
|
+
*/
|
|
859
|
+
export declare function chatBubbles(parts: UIMessage["parts"], o: {
|
|
860
|
+
drawn: ReadonlySet<string>;
|
|
861
|
+
says: (i: number) => boolean;
|
|
862
|
+
shows: (i: number) => boolean;
|
|
863
|
+
tail: boolean;
|
|
864
|
+
}): ChatBubble[];
|
|
865
|
+
export declare function partKeys(parts: UIMessage["parts"], cardOf: (i: number) => string | null): string[];
|
|
866
|
+
export declare function approvalOfPart(part: Record<string, unknown>): string | null;
|
|
867
|
+
/**
|
|
868
|
+
* ONE CARD PER APPROVAL, WHERE IT WAS LAST ASKED FOR. Each approval's card is drawn at the newest call that asked
|
|
869
|
+
* for it: a tool part that is its action's first (in transcript order), or one held for approval again (the
|
|
870
|
+
* engine reuses the waiting action when the model repeats the same call), or a reloaded run's call. The agent
|
|
871
|
+
* asking again for the same thing (a new call or the same one, the same approval) moves the card down to that
|
|
872
|
+
* reply, so it is never a screen above the words that point to it; the calls above it say so (`below`,
|
|
873
|
+
* labels.toolApprovalBelow). A reply that reuses the call with its result (the one after a decision) is a step
|
|
874
|
+
* after the card and moves nothing, so a decided card stays where it was decided. Keys: `<message id>:<part index>` for parts, `<message id>:<apr>`
|
|
875
|
+
* for a run's calls.
|
|
876
|
+
*/
|
|
877
|
+
export declare function approvalPlaces(messages: readonly UIMessage[], outcomes: Readonly<Record<string, RunOutcome>> | undefined, decidedIn?: ReadonlyMap<string, string>): {
|
|
878
|
+
cards: ReadonlySet<string>;
|
|
879
|
+
below: ReadonlySet<string>;
|
|
880
|
+
spent: ReadonlySet<string>;
|
|
881
|
+
};
|
|
882
|
+
/**
|
|
883
|
+
* The chat's Go on for an open browser view: the go-on message through the chat's own send, as if the person typed it.
|
|
884
|
+
* Null while a reply runs or the box is off, so the view draws no Go on then. Pure.
|
|
885
|
+
*/
|
|
886
|
+
export declare function chatGoOn(opts: {
|
|
887
|
+
busy: boolean;
|
|
888
|
+
off: boolean;
|
|
889
|
+
message: string;
|
|
890
|
+
onSend: (text: string) => void;
|
|
891
|
+
}): (() => void) | null;
|
|
892
|
+
/**
|
|
893
|
+
* An approval's card in the chat, wired to the kit's routes and the chat's decision state (in a reply, or under a run's
|
|
894
|
+
* outcome). Approved here with no run to follow: the refused send's note under it, and the card says "Approved.".
|
|
895
|
+
*/
|
|
896
|
+
export declare function ChatApprovalCard({ id, approval, labels, fallbackTitle, loadingTitle }: {
|
|
897
|
+
id: string;
|
|
898
|
+
approval: ApprovalProps;
|
|
899
|
+
labels: AgentChatLabels;
|
|
900
|
+
fallbackTitle: string;
|
|
901
|
+
loadingTitle?: string | undefined;
|
|
902
|
+
}): import("react").JSX.Element;
|
|
903
|
+
/**
|
|
904
|
+
* What Enter or Send does with the message being written: "send" it; "hold" it while a file still uploads (it goes
|
|
905
|
+
* when the upload ends: `heldSendNext`); or "none" when there are no words. Never whether a reply is on its way.
|
|
906
|
+
*/
|
|
907
|
+
export declare function submitAction(text: string, uploading: number): "send" | "hold" | "none";
|
|
908
|
+
/** A held send, as the uploads change: it waits while one uploads, goes when none does, and is let go if one failed. */
|
|
909
|
+
export declare function heldSendNext(s: {
|
|
910
|
+
uploading: number;
|
|
911
|
+
failed: boolean;
|
|
912
|
+
}): "send" | "cancel" | "wait";
|
|
913
|
+
/**
|
|
914
|
+
* What the one button beside the message box is: Stop while the agent works and the box has no words, else Send.
|
|
915
|
+
* Words typed during a reply bring Send back (the message then waits its turn); clearing them brings Stop back.
|
|
916
|
+
* Once Stop is asked (`stopAsked`: stopping, or stopped while the reply ends) it is Send at once, words or none.
|
|
917
|
+
*/
|
|
918
|
+
export declare function composerAction(s: {
|
|
919
|
+
busy: boolean;
|
|
920
|
+
canStop: boolean;
|
|
921
|
+
text: string;
|
|
922
|
+
stopAsked?: boolean;
|
|
923
|
+
}): "stop" | "send";
|
|
924
|
+
/** The chat's markup alone, from its state (what `<AgentChat>` draws). */
|
|
925
|
+
export declare function AgentChatView(props: AgentChatViewProps): import("react").JSX.Element;
|