@dudko.dev/agent-web-ui 0.0.0 → 0.0.1
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 +21 -0
- package/README.md +251 -5
- package/dist/canvas.cjs +266 -0
- package/dist/canvas.cjs.map +1 -0
- package/dist/canvas.d.cts +105 -0
- package/dist/canvas.d.ts +105 -0
- package/dist/canvas.js +200 -0
- package/dist/canvas.js.map +1 -0
- package/dist/chunk-4EHUITGU.js +342 -0
- package/dist/chunk-4EHUITGU.js.map +1 -0
- package/dist/chunk-7O64ZI6Z.js +125 -0
- package/dist/chunk-7O64ZI6Z.js.map +1 -0
- package/dist/chunk-A55Q377T.js +342 -0
- package/dist/chunk-A55Q377T.js.map +1 -0
- package/dist/chunk-EL2YCROY.js +127 -0
- package/dist/chunk-EL2YCROY.js.map +1 -0
- package/dist/chunk-GB7RZJMG.js +98 -0
- package/dist/chunk-GB7RZJMG.js.map +1 -0
- package/dist/chunk-KZQB35LS.js +22 -0
- package/dist/chunk-KZQB35LS.js.map +1 -0
- package/dist/chunk-P2F2P3JC.js +400 -0
- package/dist/chunk-P2F2P3JC.js.map +1 -0
- package/dist/chunk-TPK25QGK.js +342 -0
- package/dist/chunk-TPK25QGK.js.map +1 -0
- package/dist/en-CcNUz2tN.d.cts +342 -0
- package/dist/en-CcNUz2tN.d.ts +342 -0
- package/dist/index.cjs +4143 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +919 -0
- package/dist/index.d.ts +919 -0
- package/dist/index.js +3771 -0
- package/dist/index.js.map +1 -0
- package/dist/labels-B5xpIGf_.d.cts +25 -0
- package/dist/labels-B5xpIGf_.d.ts +25 -0
- package/dist/labels-D5BrHct4.d.cts +1208 -0
- package/dist/labels-UuWI7wPo.d.ts +1208 -0
- package/dist/locales/be.cjs +794 -0
- package/dist/locales/be.cjs.map +1 -0
- package/dist/locales/be.d.cts +14 -0
- package/dist/locales/be.d.ts +14 -0
- package/dist/locales/be.js +374 -0
- package/dist/locales/be.js.map +1 -0
- package/dist/locales/bg.cjs +747 -0
- package/dist/locales/bg.cjs.map +1 -0
- package/dist/locales/bg.d.cts +14 -0
- package/dist/locales/bg.d.ts +14 -0
- package/dist/locales/bg.js +327 -0
- package/dist/locales/bg.js.map +1 -0
- package/dist/locales/ca.cjs +773 -0
- package/dist/locales/ca.cjs.map +1 -0
- package/dist/locales/ca.d.cts +14 -0
- package/dist/locales/ca.d.ts +14 -0
- package/dist/locales/ca.js +353 -0
- package/dist/locales/ca.js.map +1 -0
- package/dist/locales/cs.cjs +794 -0
- package/dist/locales/cs.cjs.map +1 -0
- package/dist/locales/cs.d.cts +14 -0
- package/dist/locales/cs.d.ts +14 -0
- package/dist/locales/cs.js +374 -0
- package/dist/locales/cs.js.map +1 -0
- package/dist/locales/da.cjs +747 -0
- package/dist/locales/da.cjs.map +1 -0
- package/dist/locales/da.d.cts +14 -0
- package/dist/locales/da.d.ts +14 -0
- package/dist/locales/da.js +327 -0
- package/dist/locales/da.js.map +1 -0
- package/dist/locales/de.cjs +756 -0
- package/dist/locales/de.cjs.map +1 -0
- package/dist/locales/de.d.cts +14 -0
- package/dist/locales/de.d.ts +14 -0
- package/dist/locales/de.js +336 -0
- package/dist/locales/de.js.map +1 -0
- package/dist/locales/el.cjs +756 -0
- package/dist/locales/el.cjs.map +1 -0
- package/dist/locales/el.d.cts +14 -0
- package/dist/locales/el.d.ts +14 -0
- package/dist/locales/el.js +336 -0
- package/dist/locales/el.js.map +1 -0
- package/dist/locales/en.cjs +753 -0
- package/dist/locales/en.cjs.map +1 -0
- package/dist/locales/en.d.cts +10 -0
- package/dist/locales/en.d.ts +10 -0
- package/dist/locales/en.js +333 -0
- package/dist/locales/en.js.map +1 -0
- package/dist/locales/es-419.cjs +778 -0
- package/dist/locales/es-419.cjs.map +1 -0
- package/dist/locales/es-419.d.cts +16 -0
- package/dist/locales/es-419.d.ts +16 -0
- package/dist/locales/es-419.js +23 -0
- package/dist/locales/es-419.js.map +1 -0
- package/dist/locales/es.cjs +769 -0
- package/dist/locales/es.cjs.map +1 -0
- package/dist/locales/es.d.cts +14 -0
- package/dist/locales/es.d.ts +14 -0
- package/dist/locales/es.js +14 -0
- package/dist/locales/es.js.map +1 -0
- package/dist/locales/fi.cjs +753 -0
- package/dist/locales/fi.cjs.map +1 -0
- package/dist/locales/fi.d.cts +14 -0
- package/dist/locales/fi.d.ts +14 -0
- package/dist/locales/fi.js +333 -0
- package/dist/locales/fi.js.map +1 -0
- package/dist/locales/fr-CA.cjs +777 -0
- package/dist/locales/fr-CA.cjs.map +1 -0
- package/dist/locales/fr-CA.d.cts +17 -0
- package/dist/locales/fr-CA.d.ts +17 -0
- package/dist/locales/fr-CA.js +22 -0
- package/dist/locales/fr-CA.js.map +1 -0
- package/dist/locales/fr.cjs +769 -0
- package/dist/locales/fr.cjs.map +1 -0
- package/dist/locales/fr.d.cts +14 -0
- package/dist/locales/fr.d.ts +14 -0
- package/dist/locales/fr.js +14 -0
- package/dist/locales/fr.js.map +1 -0
- package/dist/locales/gn.cjs +750 -0
- package/dist/locales/gn.cjs.map +1 -0
- package/dist/locales/gn.d.cts +16 -0
- package/dist/locales/gn.d.ts +16 -0
- package/dist/locales/gn.js +330 -0
- package/dist/locales/gn.js.map +1 -0
- package/dist/locales/hr.cjs +769 -0
- package/dist/locales/hr.cjs.map +1 -0
- package/dist/locales/hr.d.cts +14 -0
- package/dist/locales/hr.d.ts +14 -0
- package/dist/locales/hr.js +349 -0
- package/dist/locales/hr.js.map +1 -0
- package/dist/locales/ht.cjs +750 -0
- package/dist/locales/ht.cjs.map +1 -0
- package/dist/locales/ht.d.cts +16 -0
- package/dist/locales/ht.d.ts +16 -0
- package/dist/locales/ht.js +330 -0
- package/dist/locales/ht.js.map +1 -0
- package/dist/locales/hu.cjs +753 -0
- package/dist/locales/hu.cjs.map +1 -0
- package/dist/locales/hu.d.cts +14 -0
- package/dist/locales/hu.d.ts +14 -0
- package/dist/locales/hu.js +333 -0
- package/dist/locales/hu.js.map +1 -0
- package/dist/locales/index.cjs +537 -0
- package/dist/locales/index.cjs.map +1 -0
- package/dist/locales/index.d.cts +38 -0
- package/dist/locales/index.d.ts +38 -0
- package/dist/locales/index.js +105 -0
- package/dist/locales/index.js.map +1 -0
- package/dist/locales/it.cjs +777 -0
- package/dist/locales/it.cjs.map +1 -0
- package/dist/locales/it.d.cts +14 -0
- package/dist/locales/it.d.ts +14 -0
- package/dist/locales/it.js +357 -0
- package/dist/locales/it.js.map +1 -0
- package/dist/locales/nb.cjs +747 -0
- package/dist/locales/nb.cjs.map +1 -0
- package/dist/locales/nb.d.cts +14 -0
- package/dist/locales/nb.d.ts +14 -0
- package/dist/locales/nb.js +327 -0
- package/dist/locales/nb.js.map +1 -0
- package/dist/locales/nl.cjs +753 -0
- package/dist/locales/nl.cjs.map +1 -0
- package/dist/locales/nl.d.cts +14 -0
- package/dist/locales/nl.d.ts +14 -0
- package/dist/locales/nl.js +333 -0
- package/dist/locales/nl.js.map +1 -0
- package/dist/locales/pl.cjs +794 -0
- package/dist/locales/pl.cjs.map +1 -0
- package/dist/locales/pl.d.cts +14 -0
- package/dist/locales/pl.d.ts +14 -0
- package/dist/locales/pl.js +374 -0
- package/dist/locales/pl.js.map +1 -0
- package/dist/locales/pt-BR.cjs +773 -0
- package/dist/locales/pt-BR.cjs.map +1 -0
- package/dist/locales/pt-BR.d.cts +14 -0
- package/dist/locales/pt-BR.d.ts +14 -0
- package/dist/locales/pt-BR.js +353 -0
- package/dist/locales/pt-BR.js.map +1 -0
- package/dist/locales/pt.cjs +777 -0
- package/dist/locales/pt.cjs.map +1 -0
- package/dist/locales/pt.d.cts +14 -0
- package/dist/locales/pt.d.ts +14 -0
- package/dist/locales/pt.js +357 -0
- package/dist/locales/pt.js.map +1 -0
- package/dist/locales/qu.cjs +756 -0
- package/dist/locales/qu.cjs.map +1 -0
- package/dist/locales/qu.d.cts +16 -0
- package/dist/locales/qu.d.ts +16 -0
- package/dist/locales/qu.js +336 -0
- package/dist/locales/qu.js.map +1 -0
- package/dist/locales/ro.cjs +769 -0
- package/dist/locales/ro.cjs.map +1 -0
- package/dist/locales/ro.d.cts +14 -0
- package/dist/locales/ro.d.ts +14 -0
- package/dist/locales/ro.js +349 -0
- package/dist/locales/ro.js.map +1 -0
- package/dist/locales/ru.cjs +789 -0
- package/dist/locales/ru.cjs.map +1 -0
- package/dist/locales/ru.d.cts +14 -0
- package/dist/locales/ru.d.ts +14 -0
- package/dist/locales/ru.js +369 -0
- package/dist/locales/ru.js.map +1 -0
- package/dist/locales/sk.cjs +794 -0
- package/dist/locales/sk.cjs.map +1 -0
- package/dist/locales/sk.d.cts +14 -0
- package/dist/locales/sk.d.ts +14 -0
- package/dist/locales/sk.js +374 -0
- package/dist/locales/sk.js.map +1 -0
- package/dist/locales/sq.cjs +753 -0
- package/dist/locales/sq.cjs.map +1 -0
- package/dist/locales/sq.d.cts +14 -0
- package/dist/locales/sq.d.ts +14 -0
- package/dist/locales/sq.js +333 -0
- package/dist/locales/sq.js.map +1 -0
- package/dist/locales/sr-Latn.cjs +841 -0
- package/dist/locales/sr-Latn.cjs.map +1 -0
- package/dist/locales/sr-Latn.d.cts +17 -0
- package/dist/locales/sr-Latn.d.ts +17 -0
- package/dist/locales/sr-Latn.js +86 -0
- package/dist/locales/sr-Latn.js.map +1 -0
- package/dist/locales/sr.cjs +769 -0
- package/dist/locales/sr.cjs.map +1 -0
- package/dist/locales/sr.d.cts +14 -0
- package/dist/locales/sr.d.ts +14 -0
- package/dist/locales/sr.js +14 -0
- package/dist/locales/sr.js.map +1 -0
- package/dist/locales/sv.cjs +753 -0
- package/dist/locales/sv.cjs.map +1 -0
- package/dist/locales/sv.d.cts +14 -0
- package/dist/locales/sv.d.ts +14 -0
- package/dist/locales/sv.js +333 -0
- package/dist/locales/sv.js.map +1 -0
- package/dist/locales/tr.cjs +750 -0
- package/dist/locales/tr.cjs.map +1 -0
- package/dist/locales/tr.d.cts +14 -0
- package/dist/locales/tr.d.ts +14 -0
- package/dist/locales/tr.js +330 -0
- package/dist/locales/tr.js.map +1 -0
- package/dist/locales/uk.cjs +794 -0
- package/dist/locales/uk.cjs.map +1 -0
- package/dist/locales/uk.d.cts +14 -0
- package/dist/locales/uk.d.ts +14 -0
- package/dist/locales/uk.js +374 -0
- package/dist/locales/uk.js.map +1 -0
- package/dist/markdown.cjs +620 -0
- package/dist/markdown.cjs.map +1 -0
- package/dist/markdown.d.cts +153 -0
- package/dist/markdown.d.ts +153 -0
- package/dist/markdown.js +573 -0
- package/dist/markdown.js.map +1 -0
- package/dist/mcp-app-entry-BA-Ca39z.d.ts +1480 -0
- package/dist/mcp-app-entry-tybABaHg.d.cts +1480 -0
- package/dist/mcp-app-policy-DXKQ2jjM.d.cts +73 -0
- package/dist/mcp-app-policy-DXKQ2jjM.d.ts +73 -0
- package/dist/mcp-app-sandbox.cjs +323 -0
- package/dist/mcp-app-sandbox.cjs.map +1 -0
- package/dist/mcp-app-sandbox.d.cts +70 -0
- package/dist/mcp-app-sandbox.d.ts +70 -0
- package/dist/mcp-app-sandbox.js +209 -0
- package/dist/mcp-app-sandbox.js.map +1 -0
- package/dist/mcp-app.cjs +980 -0
- package/dist/mcp-app.cjs.map +1 -0
- package/dist/mcp-app.d.cts +3 -0
- package/dist/mcp-app.d.ts +3 -0
- package/dist/mcp-app.js +816 -0
- package/dist/mcp-app.js.map +1 -0
- package/dist/pipeline.cjs +845 -0
- package/dist/pipeline.cjs.map +1 -0
- package/dist/pipeline.css +1407 -0
- package/dist/pipeline.d.cts +348 -0
- package/dist/pipeline.d.ts +348 -0
- package/dist/pipeline.js +778 -0
- package/dist/pipeline.js.map +1 -0
- package/dist/styles.css +4109 -0
- package/dist/types-BmvgYUzF.d.cts +19 -0
- package/dist/types-Cr5gmUts.d.ts +19 -0
- package/package.json +155 -8
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,919 @@
|
|
|
1
|
+
import { AgentEvent, IUsage, Skill, ToolApprovalRequest, ToolApprovalContext, ToolApprovalDecision } from '@dudko.dev/agent-web';
|
|
2
|
+
import { A as AgentUiState, C as ChatAttachment, R as RemoteRunView, L as LessonView, h as ChatMessage, i as ApprovalView, S as SubagentView, j as SubagentNode } from './mcp-app-entry-BA-Ca39z.js';
|
|
3
|
+
export { f as AgentStatus, k as AppView, B as BrowserOAuthProvider, l as BrowserOAuthProviderOptions, m as BudgetView, n as CompactionView, o as ConnectedMcp, D as DecisionView, E as ElicitationView, F as FetchView, p as McpAppsConnectionLike, q as McpCatalogEntry, M as McpElicitationFieldSchema, a as McpElicitationHandler, d as McpElicitationOptions, b as McpElicitationRequest, c as McpElicitationResult, e as McpElicitationSchema, r as McpHttpServerConfig, s as McpModule, t as McpOAuthCallback, u as McpOAuthRegistration, v as McpOAuthRegistrationKind, w as McpProtocolMode, x as McpServerInstructions, y as McpServerProtocol, z as McpServerResult, G as MediaView, H as ModelLoadState, Q as QuestionView, I as QueuedMessageView, J as ReplanState, K as SkillConsentView, N as StepEscalationView, O as StepView, T as ToolCallView, P as TranscriptView, U as UserNoteView, W as WrittenFileView } from './mcp-app-entry-BA-Ca39z.js';
|
|
4
|
+
export { a as ASK_USER_TOOL_NAME, b as ATTACHMENT_BOUNDS, c as AgentLabels, A as AgentLabelsOverride, d as AttachmentBounds, e as AttachmentFiles, f as AttachmentOverLimit, g as AttachmentTextOptions, h as AttachmentTransform, C as ComposerAttachment, i as ComposerNotice, E as ELICITATION_MAX_OPTIONS, j as ELICITATION_TIMEOUT_MS, k as ELICITATION_VALUE_MAX_CHARS, l as ElicitationControl, m as ElicitationDraft, n as ElicitationDraftValue, o as ElicitationField, p as ElicitationFormOutcome, q as ElicitationIssue, r as ElicitationIssueKind, s as ElicitationLink, t as ElicitationOption, u as ElicitationOutcomeReason, v as ElicitationQueue, w as ElicitationQueueOptions, F as FileKind, I as INPUT_COUNTER_FROM, M as MenuSection, N as NoticeTexts, P as PendingElicitation, x as PendingQuestion, Q as QUESTION_TIMEOUT_MS, y as QuestionOutcomeReason, z as QuestionQueue, B as QuestionQueueOptions, S as SavedAttachments, D as SlashCommand, G as SteerIntent, T as TextExcerpt, H as askUserOutputKept, J as askUserWith, K as attachmentFileName, L as attachmentKindOf, O as attachmentLabel, R as attachmentOverLimit, U as attachmentRefusal, V as attachmentTransformOf, W as boxLength, X as createElicitationQueue, Y as createQuestionQueue, Z as dataUrlParts, _ as defaultLabels, $ as defaultNoticeTexts, a0 as elicitationConnectOptions, a1 as elicitationFields, a2 as elicitationFormAnswer, a3 as elicitationInitialDraft, a4 as elicitationLink, a5 as elicitationSettings, a6 as elicitationTimeoutOf, a7 as excerptNote, a8 as fileKindOf, a9 as fileNameOf, aa as filterCommands, ab as formatClock, ac as formatCountdown, ad as formatElapsed, ae as freeAttachmentPath, af as inputCounterShown, ag as insertionFits, ah as isOneCharacter, ai as lineCountOf, aj as longTextName, ak as longTextRoute, al as menuKeyTarget, am as menuSections, an as mergeLabels, ao as messageOverLimit, ap as micProblemText, aq as noticesOf, ar as overflowOf, as as parseSlash, at as questionChoiceOf, au as questionOtherOf, av as questionTimeoutOf, aw as saveAttachments, ax as steerIntent, ay as textExcerpt, az as voiceMessageName, aA as withAttachments, aB as withoutOwnWords } from './labels-UuWI7wPo.js';
|
|
5
|
+
import './mcp-app-policy-DXKQ2jjM.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The reducer that turns the agent's `AgentEvent` stream into a renderable
|
|
9
|
+
* {@link AgentUiState}. It is a pure function of (state, action) with no React,
|
|
10
|
+
* no clock and no randomness (ids come from a monotonic `seq`; times come in on
|
|
11
|
+
* the action as `at`), so it can be unit-tested in isolation and reused to
|
|
12
|
+
* build a fully custom UI.
|
|
13
|
+
*/
|
|
14
|
+
type AgentAction =
|
|
15
|
+
/** Clear the whole conversation (transcript + current run), keeping status. */
|
|
16
|
+
{
|
|
17
|
+
type: 'reset';
|
|
18
|
+
}
|
|
19
|
+
/** Set the lifecycle status (owned by the hook). */
|
|
20
|
+
| {
|
|
21
|
+
type: 'status';
|
|
22
|
+
status: AgentUiState['status'];
|
|
23
|
+
error?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Fold one streamed agent event into the view. `at` (ms epoch, from the
|
|
27
|
+
* hook) times runs and tool calls; `attachments` decorate the user turn a
|
|
28
|
+
* `run.start` opens.
|
|
29
|
+
*/
|
|
30
|
+
| {
|
|
31
|
+
type: 'event';
|
|
32
|
+
event: AgentEvent;
|
|
33
|
+
maxEvents?: number;
|
|
34
|
+
at?: number;
|
|
35
|
+
attachments?: ChatAttachment[];
|
|
36
|
+
/** The event is another tab's run of this conversation (`watchSession`), relayed here. */
|
|
37
|
+
remote?: boolean;
|
|
38
|
+
/** With `session.busy`: the goal that waits (shown as queued until the run starts). */
|
|
39
|
+
goal?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Another tab's run of this conversation, as `watchSession` reports it (or `undefined`: none
|
|
43
|
+
* in view). Ended `gone` - that tab closed before it said so - finishes the answer it left.
|
|
44
|
+
*/
|
|
45
|
+
| {
|
|
46
|
+
type: 'remote';
|
|
47
|
+
remote: RemoteRunView | undefined;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The agent's notebook as it is now (the hook sends it when the agent is built: lessons a
|
|
51
|
+
* persistent store brought back). Later `skill.learned` / `skill.forgotten` events keep it current.
|
|
52
|
+
*/
|
|
53
|
+
| {
|
|
54
|
+
type: 'notebook';
|
|
55
|
+
lessons: LessonView[];
|
|
56
|
+
}
|
|
57
|
+
/** Replace the transcript with a saved conversation (chat history). */
|
|
58
|
+
| {
|
|
59
|
+
type: 'load';
|
|
60
|
+
messages: ChatMessage[];
|
|
61
|
+
totalUsage?: IUsage;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The run is over and these messages never reached the model (`RunResult.undelivered`,
|
|
65
|
+
* or what was still queued when it was stopped). Clears the queue. An empty list
|
|
66
|
+
* clears `undelivered` too (the follow-up was sent, or the user discarded them).
|
|
67
|
+
*/
|
|
68
|
+
| {
|
|
69
|
+
type: 'undelivered';
|
|
70
|
+
texts: string[];
|
|
71
|
+
keepQueued?: boolean;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* `sendRemote`: the text went to the conversation's run in another tab, which has not answered
|
|
75
|
+
* yet - shown in `queued`, marked `sentTo: 'another-tab'`, until `remote-answer` with this `id`
|
|
76
|
+
* (or that run's own `message.queued` for it, which takes its place).
|
|
77
|
+
*/
|
|
78
|
+
| {
|
|
79
|
+
type: 'remote-send';
|
|
80
|
+
id: string;
|
|
81
|
+
text: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* That tab's answer to `remote-send` `id`: `taken` (its run has it), `refused` (refused, or its
|
|
85
|
+
* run ended without taking it - the text comes back in `undelivered`, to send again or drop), or
|
|
86
|
+
* `unknown` (the watch that sent it was closed - another conversation is in view: nothing is
|
|
87
|
+
* offered, as that tab may still take it). Either way the waiting entry goes.
|
|
88
|
+
*/
|
|
89
|
+
| {
|
|
90
|
+
type: 'remote-answer';
|
|
91
|
+
id: string;
|
|
92
|
+
text: string;
|
|
93
|
+
answer: 'taken' | 'refused' | 'unknown';
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* The user sent a goal and this tab's run is getting going: its turn is shown at once (a
|
|
97
|
+
* user message and a pending answer), until the run's `run.start` takes its place.
|
|
98
|
+
*/
|
|
99
|
+
| {
|
|
100
|
+
type: 'submitted';
|
|
101
|
+
goal: string;
|
|
102
|
+
attachments?: ChatAttachment[];
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* The notebook view of the agent's own skills (`agent.listLearnedSkills()`): what the core stored
|
|
106
|
+
* about each lesson, in the shape the UI keeps current from `skill.learned` events.
|
|
107
|
+
*/
|
|
108
|
+
declare const lessonsOf: (skills: Skill[]) => LessonView[];
|
|
109
|
+
/** A fresh, empty view. */
|
|
110
|
+
declare const createInitialAgentState: () => AgentUiState;
|
|
111
|
+
/**
|
|
112
|
+
* The flat `subagents` list as a tree: each node with the subagents it started, in the order
|
|
113
|
+
* they started. A node whose parent is not in the list (its start was never seen) is a root.
|
|
114
|
+
*/
|
|
115
|
+
declare const subagentTree: (subagents: SubagentView[]) => SubagentNode[];
|
|
116
|
+
/**
|
|
117
|
+
* The consent requests THIS tab can answer: pending, and not asked in another tab (a run of the
|
|
118
|
+
* conversation going on there - those are shown, and answered only there). What `useAgent`
|
|
119
|
+
* returns as `pendingApprovals`.
|
|
120
|
+
*/
|
|
121
|
+
declare const pendingApprovalsOf: (state: Pick<AgentUiState, "approvals">) => ApprovalView[];
|
|
122
|
+
/**
|
|
123
|
+
* The status to show: `running` while another tab runs this conversation (`remote`) and this
|
|
124
|
+
* tab is otherwise ready or idle - never over `initializing` or `error`, which the host must see.
|
|
125
|
+
*/
|
|
126
|
+
declare const agentStatusOf: (state: Pick<AgentUiState, "status" | "remote">) => AgentUiState["status"];
|
|
127
|
+
declare const agentStateReducer: (state: AgentUiState, action: AgentAction) => AgentUiState;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* The workspace files an answer NAMES in its text (`<MessageList showNamedFiles>`): pure, no
|
|
131
|
+
* React, no DOM, no import. What it reads as a path, exactly:
|
|
132
|
+
*
|
|
133
|
+
* - an inline code span whose whole content is an absolute path - `` `/attachments/a.png` ``
|
|
134
|
+
* (one or more backticks, CommonMark's rule: closed by a run of the same length; the one space
|
|
135
|
+
* inside each end is dropped);
|
|
136
|
+
* - the destination of a Markdown link or image - `[a](/media/a.jpg)`, ``,
|
|
137
|
+
* `[a](</notes/my notes.md>)` - percent-decoded.
|
|
138
|
+
*
|
|
139
|
+
* Nothing else: a path in plain words (`see /notes.md`), in a fenced code block (``` or ~~~ - a
|
|
140
|
+
* listing, a command, an example: not something the answer hands over), in an indented block or
|
|
141
|
+
* in a URL (`https://…`, `//host/…`) is not read. A path is absolute, one line, at most 512
|
|
142
|
+
* characters, with no empty, `.` or `..` segment, no backslash or control character and no
|
|
143
|
+
* trailing slash (a folder) - it is never normalised into another path: what is looked up is what
|
|
144
|
+
* the answer wrote. Then {@link namedFilesOf} keeps only the paths that EXIST in the workspace's
|
|
145
|
+
* listing - the one check that matters: a path that is not a file of the workspace is nothing.
|
|
146
|
+
*
|
|
147
|
+
* The scan is linear in the text, whatever the text holds (it runs while a message is drawn,
|
|
148
|
+
* and the text is the model's - which a fetched page can steer): code spans by one pass over the
|
|
149
|
+
* runs of backticks, links by a pattern that cannot backtrack across brackets, and no more than
|
|
150
|
+
* {@link NAMED_FILES_TEXT_MAX} characters of it.
|
|
151
|
+
*/
|
|
152
|
+
/** The most files an answer is shown with (see {@link namedFilesOf}). */
|
|
153
|
+
declare const NAMED_FILES_MAX = 12;
|
|
154
|
+
/** The most distinct paths kept from one text (a bound on what is looked up, not on the scan). */
|
|
155
|
+
declare const NAMED_FILES_SCAN_MAX = 200;
|
|
156
|
+
/**
|
|
157
|
+
* The most of a text that is scanned: the first 100,000 characters. That is about 25,000 tokens -
|
|
158
|
+
* more than an answer that hands files over is (above most models' default output limit for one
|
|
159
|
+
* answer); past it, the text is a dump (a file pasted back, a runaway answer), whose paths are a
|
|
160
|
+
* listing, not files handed over. It bounds the scan's (linear) work to a few milliseconds.
|
|
161
|
+
*/
|
|
162
|
+
declare const NAMED_FILES_TEXT_MAX = 100000;
|
|
163
|
+
/** `raw` as a workspace path, or `undefined` when it is not one (see the module's rules). */
|
|
164
|
+
declare const workspacePathOf: (raw: string) => string | undefined;
|
|
165
|
+
/**
|
|
166
|
+
* The workspace paths a text names, in the order they appear, each once, at most
|
|
167
|
+
* {@link NAMED_FILES_SCAN_MAX}. Whether they exist is {@link namedFilesOf}'s question.
|
|
168
|
+
*/
|
|
169
|
+
declare const pathsNamedIn: (text: string) => string[];
|
|
170
|
+
interface NamedFilesOptions {
|
|
171
|
+
/** Paths left out - the files the answer wrote, the media it made: they have chips already. */
|
|
172
|
+
exclude?: Iterable<string>;
|
|
173
|
+
/** At most this many (default {@link NAMED_FILES_MAX}). */
|
|
174
|
+
max?: number;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* The paths of `named` (from {@link pathsNamedIn}) that are files of the workspace - `exists`
|
|
178
|
+
* answers from its listing, never by reading or fetching anything -, without `exclude`, in order,
|
|
179
|
+
* at most `max` (default 12: each chip of a picture reads its bytes for the thumbnail, and an
|
|
180
|
+
* answer that lists a folder of two hundred files would otherwise read them all - the chips are
|
|
181
|
+
* for the files the answer hands over, not a second file browser; the Files panel has them all).
|
|
182
|
+
*/
|
|
183
|
+
declare const namedFilesOf: (named: readonly string[], exists: (path: string) => boolean, { exclude, max }?: NamedFilesOptions) => string[];
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* The transcript's scroll position while content arrives - the rule, as a pure function (no DOM),
|
|
187
|
+
* and the numbers it stands on. `useFollowScroll` (hooks/use-follow-scroll.ts) applies it.
|
|
188
|
+
*
|
|
189
|
+
* Two states. FOLLOWING: the view is at the end and stays there, whatever grows or shrinks.
|
|
190
|
+
* READING: the person moved up, and the view is theirs - nothing that arrives moves what they
|
|
191
|
+
* read; going back down to the end follows again.
|
|
192
|
+
*/
|
|
193
|
+
/** A scroller's measures (CSS pixels). */
|
|
194
|
+
interface ScrollMeasure {
|
|
195
|
+
scrollTop: number;
|
|
196
|
+
scrollHeight: number;
|
|
197
|
+
clientHeight: number;
|
|
198
|
+
}
|
|
199
|
+
/** How far from the end still counts as "back at the end" when moving down. */
|
|
200
|
+
declare const FOLLOW_REJOIN_PX = 80;
|
|
201
|
+
/**
|
|
202
|
+
* How far above the end a move up must leave the view to count as the person's. Under it, a
|
|
203
|
+
* move up is the browser's own: the bounce at the end of a touch scroll (the position comes
|
|
204
|
+
* back from beyond the end), or a sub-pixel rounding. Small on purpose: a slow drag moves a
|
|
205
|
+
* few pixels between two pieces of an answer, and must not be pulled back.
|
|
206
|
+
*/
|
|
207
|
+
declare const FOLLOW_LEAVE_PX = 2;
|
|
208
|
+
declare const endGap: (m: ScrollMeasure) => number;
|
|
209
|
+
/**
|
|
210
|
+
* Whether the view follows after a scroll event: `before` is what the scroller measured when it
|
|
211
|
+
* was last looked at, `now` what it measures in the event.
|
|
212
|
+
*
|
|
213
|
+
* - The content or the box changed size since: the move is the layout's (the browser keeps the
|
|
214
|
+
* position inside a shorter transcript, a keyboard opens), not the person's - nothing changes.
|
|
215
|
+
* - A move up that leaves the end: the person reads - stop following.
|
|
216
|
+
* - A move down that ends near the end: follow again.
|
|
217
|
+
*/
|
|
218
|
+
declare const followsAfterScroll: (following: boolean, before: ScrollMeasure, now: ScrollMeasure) => boolean;
|
|
219
|
+
/**
|
|
220
|
+
* Whether the view still follows when the transcript changed size: a piece of the answer often
|
|
221
|
+
* lands between a move of the person's and its scroll event, and must not undo the move. With
|
|
222
|
+
* the box as it was and the transcript no shorter, nothing but the person moves the view up
|
|
223
|
+
* (the hook turns the browser's own scroll anchoring off: `useFollowScroll`).
|
|
224
|
+
*/
|
|
225
|
+
declare const followsAfterResize: (following: boolean, before: ScrollMeasure, now: ScrollMeasure) => boolean;
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Downscale an image in the browser before it goes to a model. Providers bill
|
|
229
|
+
* images by their pixel size and resize anything over ~1.15 MP / 1568 px on
|
|
230
|
+
* the long edge themselves — sending more only costs upload time and, for
|
|
231
|
+
* some providers, tokens. GIF and SVG are left as they are.
|
|
232
|
+
*/
|
|
233
|
+
interface DownscaleOptions {
|
|
234
|
+
/** Longest edge in pixels (default 1568). */
|
|
235
|
+
maxDimension?: number;
|
|
236
|
+
/** Total pixels (default 1 150 000). */
|
|
237
|
+
maxPixels?: number;
|
|
238
|
+
/** JPEG/WebP quality 0..1 (default 0.9). */
|
|
239
|
+
quality?: number;
|
|
240
|
+
}
|
|
241
|
+
/** A picture's size in pixels, as its file declares it. */
|
|
242
|
+
interface ImageSize {
|
|
243
|
+
width: number;
|
|
244
|
+
height: number;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* A picture's size in pixels read from its file's header - a few small reads, nothing decoded -
|
|
248
|
+
* for PNG, JPEG and WebP (by their bytes, whatever the file's type says). undefined for any
|
|
249
|
+
* other format, a header that does not add up, or a file that cannot be read: the caller then
|
|
250
|
+
* goes by the bytes alone. Never throws.
|
|
251
|
+
*/
|
|
252
|
+
declare const imageSizeOf: (file: Blob) => Promise<ImageSize | undefined>;
|
|
253
|
+
/** The image, smaller when it is larger than the limits; the original otherwise. */
|
|
254
|
+
declare const downscaleImage: (file: Blob, opts?: DownscaleOptions) => Promise<Blob>;
|
|
255
|
+
|
|
256
|
+
/** Compact one-line preview of a tool input/output value, truncated. */
|
|
257
|
+
declare const previewValue: (value: unknown, max?: number) => string;
|
|
258
|
+
/** 1234 → "1.2k", 12345 → "12k". */
|
|
259
|
+
declare const formatTokens: (n: number) => string;
|
|
260
|
+
/** 340 → "340 ms", 4200 → "4.2 s", 125_000 → "2m 5s". */
|
|
261
|
+
declare const formatDuration: (ms: number) => string;
|
|
262
|
+
/**
|
|
263
|
+
* Images inside a tool result, as data URLs: MCP image parts
|
|
264
|
+
* (`{ type: 'image', data, mimeType }`), data-URL strings, and objects that
|
|
265
|
+
* carry one (`{ dataUrl }` / `{ url: 'data:…' }`). Looks two levels deep.
|
|
266
|
+
*/
|
|
267
|
+
declare const imagesInOutput: (output: unknown, depth?: number) => string[];
|
|
268
|
+
/** One result of the core's `web_search` tool, as far as a UI shows it. */
|
|
269
|
+
interface WebSearchResultView {
|
|
270
|
+
title: string;
|
|
271
|
+
/** An http(s) address - anything else is left out. */
|
|
272
|
+
url: string;
|
|
273
|
+
/** The host of `url`, for the line under the title. */
|
|
274
|
+
host: string;
|
|
275
|
+
snippet: string;
|
|
276
|
+
date?: string;
|
|
277
|
+
}
|
|
278
|
+
interface WebSearchView {
|
|
279
|
+
query: string;
|
|
280
|
+
results: WebSearchResultView[];
|
|
281
|
+
/** Results the egress policy left out. */
|
|
282
|
+
filtered: number;
|
|
283
|
+
truncated: boolean;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* The result of the core's `web_search` tool (`{ query, results: [{ title, url, snippet, date? }],
|
|
287
|
+
* filtered?, truncated?, untrusted: true }`), or undefined when `output` is not one. Titles and
|
|
288
|
+
* snippets are third-party text: they come back as plain strings, to be rendered as text. A
|
|
289
|
+
* result whose `url` is not http(s) is dropped, so a link can never be a `javascript:` one.
|
|
290
|
+
*/
|
|
291
|
+
declare const webSearchOf: (output: unknown) => WebSearchView | undefined;
|
|
292
|
+
/** 0.934 → "0.93", 0.8 → "0.8", 1 → "1". */
|
|
293
|
+
declare const formatProbability: (p: number) => string;
|
|
294
|
+
|
|
295
|
+
/** The consent requests waiting for a person, by request id. */
|
|
296
|
+
interface ApprovalQueue {
|
|
297
|
+
/**
|
|
298
|
+
* The core's `toolApproval.onRequest`: resolves when `approve` / `deny` is called. A request
|
|
299
|
+
* the core stops waiting for (`ctx.signal`: its `timeoutMs` ran out, the run stopped) leaves
|
|
300
|
+
* the queue at once, so no stale answer is kept for it.
|
|
301
|
+
*/
|
|
302
|
+
handler: (req: ToolApprovalRequest, ctx?: ToolApprovalContext) => Promise<ToolApprovalDecision>;
|
|
303
|
+
/** Allow one. False when no such request is waiting (answered, expired, settled). */
|
|
304
|
+
approve: (id: string, options?: {
|
|
305
|
+
remember?: boolean;
|
|
306
|
+
}) => boolean;
|
|
307
|
+
/** Deny one. False when no such request is waiting. */
|
|
308
|
+
deny: (id: string, reason?: string) => boolean;
|
|
309
|
+
/** Answer every waiting request with `decision` (the run ended, the view closed). */
|
|
310
|
+
settleAll: (decision: ToolApprovalDecision) => void;
|
|
311
|
+
/** The ids of the requests waiting, oldest first. */
|
|
312
|
+
pending: () => string[];
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* The queue behind `useAgent`'s `approve` / `deny`: `request.id → resolver`. A request leaves it
|
|
316
|
+
* exactly once - answered, settled by `settleAll`, or dropped when the core no longer wants the
|
|
317
|
+
* answer (its signal aborted; the core has already denied the call and said so in its event).
|
|
318
|
+
*/
|
|
319
|
+
declare const createApprovalQueue: () => ApprovalQueue;
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Input protection for the buttons that SAY YES to an MCP App (its tool call's "Allow once" /
|
|
323
|
+
* "Always allow", a link's "Open", a file's "Save", sampling's "Allow"): the way a browser's own
|
|
324
|
+
* permission prompts guard theirs. A prompt an app causes appears when the APP chooses - while
|
|
325
|
+
* the person types, holds a key or double-clicks something in the app - and where its layout
|
|
326
|
+
* puts it, so an input aimed at something else must not land on "yes".
|
|
327
|
+
*
|
|
328
|
+
* A button is ARMED only once it has been on screen, in one place, for `PROMPT_ARM_MS`; it is
|
|
329
|
+
* disarmed again the moment it moves, is covered, leaves the screen or the page is hidden. A
|
|
330
|
+
* click counts only when it is armed now AND began while it was armed: its pointerdown (a
|
|
331
|
+
* pointer's click) or its Enter / Space keydown (a key's) came after the arming. A key repeat
|
|
332
|
+
* never counts, and a keydown that does not count is swallowed. A click with no key and no
|
|
333
|
+
* pointer behind it (assistive technology activating the button) counts when it is armed.
|
|
334
|
+
*
|
|
335
|
+
* Pure: the clock and the button's place are passed in (`ArmedButton` reads them from the DOM).
|
|
336
|
+
*/
|
|
337
|
+
/** How long a button must have been shown, still, before it takes a click. */
|
|
338
|
+
declare const PROMPT_ARM_MS = 500;
|
|
339
|
+
interface PromptArming {
|
|
340
|
+
/** Armed now. */
|
|
341
|
+
readonly armed: boolean;
|
|
342
|
+
/**
|
|
343
|
+
* One look at the button: where it is on screen (any string that changes when it moves), or
|
|
344
|
+
* `undefined` when it is not shown (off screen, covered, the page hidden). Returns `armed`.
|
|
345
|
+
*/
|
|
346
|
+
sample: (where: string | undefined, now: number) => boolean;
|
|
347
|
+
/** A pointer went down on the button. */
|
|
348
|
+
pointerDown: (at: number) => void;
|
|
349
|
+
/** A key went down on the button. False: swallow it (`preventDefault`) - it must not act. */
|
|
350
|
+
keyDown: (key: {
|
|
351
|
+
key: string;
|
|
352
|
+
repeat: boolean;
|
|
353
|
+
}, at: number) => boolean;
|
|
354
|
+
/** A click reached the button (`detail` > 0 for a pointer's). True: it may act. */
|
|
355
|
+
click: (detail: number, now: number) => boolean;
|
|
356
|
+
}
|
|
357
|
+
declare const createPromptArming: (delayMs?: number) => PromptArming;
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Saved conversations — the transcript a chat UI shows (messages with their
|
|
361
|
+
* tool calls, usage and image attachments), one record per conversation. The
|
|
362
|
+
* agent's own memory (what the MODEL sees) lives in the core's ContextStore
|
|
363
|
+
* under the same id; keep both and a reloaded chat continues where it was.
|
|
364
|
+
*/
|
|
365
|
+
interface ChatRecord {
|
|
366
|
+
/** Also the agent's memory session id. */
|
|
367
|
+
id: string;
|
|
368
|
+
title: string;
|
|
369
|
+
createdAt: number;
|
|
370
|
+
updatedAt: number;
|
|
371
|
+
messages: ChatMessage[];
|
|
372
|
+
totalUsage?: IUsage;
|
|
373
|
+
}
|
|
374
|
+
/** A list entry (no messages). */
|
|
375
|
+
type ChatSummary = Omit<ChatRecord, 'messages'> & {
|
|
376
|
+
messageCount: number;
|
|
377
|
+
};
|
|
378
|
+
interface ChatHistoryStoreOptions {
|
|
379
|
+
/** IndexedDB database (default 'agent-web-react'). */
|
|
380
|
+
dbName?: string;
|
|
381
|
+
/** Object store (default 'chats'). */
|
|
382
|
+
storeName?: string;
|
|
383
|
+
/** Keep chats in memory only (tests, private mode; also the fallback without IndexedDB). */
|
|
384
|
+
memory?: boolean;
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* IndexedDB-backed chat history (raw IndexedDB — no extra dependency). Every tab of the origin
|
|
388
|
+
* shares it: once a write has committed the other tabs hear which chat changed (a `chats`
|
|
389
|
+
* notice from the core's `postStorageChange` - the id, never a message), and `useChatHistory`
|
|
390
|
+
* there refreshes.
|
|
391
|
+
*/
|
|
392
|
+
declare class ChatHistoryStore {
|
|
393
|
+
/** The IndexedDB database (undefined in memory): the name its `chats` notices go out under. */
|
|
394
|
+
readonly dbName: string | undefined;
|
|
395
|
+
private readonly name;
|
|
396
|
+
private readonly storeName;
|
|
397
|
+
private readonly memory?;
|
|
398
|
+
private db?;
|
|
399
|
+
constructor(opts?: ChatHistoryStoreOptions);
|
|
400
|
+
/**
|
|
401
|
+
* The store's connection, opened on first use. Never in another tab's way: when another
|
|
402
|
+
* connection asks to delete or upgrade the database (`versionchange` - another tab's
|
|
403
|
+
* `indexedDB.deleteDatabase`, a newer copy of this package), it is closed at once, so that
|
|
404
|
+
* request goes ahead instead of waiting for this tab to close; one the browser closed by itself
|
|
405
|
+
* (site data cleared) is let go too. The next use opens the database again - after a deletion a
|
|
406
|
+
* new, empty one (no chats: `list()` is empty, a save starts it again); after an upgrade by a
|
|
407
|
+
* newer copy, the open fails until the page is reloaded with that copy.
|
|
408
|
+
*/
|
|
409
|
+
private open;
|
|
410
|
+
private tx;
|
|
411
|
+
/** One write in its own transaction, resolved once it committed - then the notice. */
|
|
412
|
+
private write;
|
|
413
|
+
private announce;
|
|
414
|
+
/**
|
|
415
|
+
* Read the stored record and write what `merge` makes of it in ONE readwrite transaction: no
|
|
416
|
+
* other tab's save can land between the read and the write. `merge` is synchronous (a
|
|
417
|
+
* transaction does not survive an await). Resolves with what was written, once committed.
|
|
418
|
+
*/
|
|
419
|
+
putMerged(id: string, merge: (stored: ChatRecord | undefined) => ChatRecord): Promise<ChatRecord>;
|
|
420
|
+
list(): Promise<ChatSummary[]>;
|
|
421
|
+
get(id: string): Promise<ChatRecord | undefined>;
|
|
422
|
+
put(record: ChatRecord): Promise<void>;
|
|
423
|
+
delete(id: string): Promise<void>;
|
|
424
|
+
clear(): Promise<void>;
|
|
425
|
+
}
|
|
426
|
+
/** The words a chat's title and a message of attachments only are said with (`AgentLabels`'). */
|
|
427
|
+
interface AttachmentTexts {
|
|
428
|
+
/** A recording - audio attachments only (default "Voice message"). */
|
|
429
|
+
voiceMessage?: string;
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* A message of attachments only, in words - where a text is needed (a chat's title, the name a
|
|
433
|
+
* screen reader gives the message): `voiceMessage` when every attachment is audio (a voice
|
|
434
|
+
* message), else the files' names.
|
|
435
|
+
*/
|
|
436
|
+
declare const attachmentsText: (attachments: readonly ChatAttachment[], texts?: AttachmentTexts) => string;
|
|
437
|
+
/**
|
|
438
|
+
* A chat's title: its first user message, trimmed. A first message of attachments only is named
|
|
439
|
+
* by what was said in it once the run has transcribed it (the next answer's transcript of an
|
|
440
|
+
* attachment), else by `attachmentsText` - "Voice message", or the files' names.
|
|
441
|
+
*/
|
|
442
|
+
declare const chatTitle: (messages: ChatMessage[], texts?: AttachmentTexts) => string;
|
|
443
|
+
/** A fresh, sortable conversation id (also a valid memory session id). */
|
|
444
|
+
declare const newChatId: () => string;
|
|
445
|
+
/** What this tab last read or wrote of a chat: the very message objects, and when. */
|
|
446
|
+
interface ChatBase {
|
|
447
|
+
/** The messages as read or written (by identity: an edit, a reset or a trim is not "known"). */
|
|
448
|
+
known: ReadonlySet<ChatMessage>;
|
|
449
|
+
updatedAt: number;
|
|
450
|
+
}
|
|
451
|
+
/** This tab's view holds a message of its own (not another tab's, relayed) it never read or wrote. */
|
|
452
|
+
declare const ownUnsaved: (messages: ChatMessage[], base: ChatBase | undefined) => boolean;
|
|
453
|
+
/** This tab's view says nothing new (every message is one it read or wrote). */
|
|
454
|
+
declare const unchangedSince: (messages: ChatMessage[], base: ChatBase | undefined) => boolean;
|
|
455
|
+
/**
|
|
456
|
+
* The record to save. A turn this tab only followed from another tab (`remote`) is never saved
|
|
457
|
+
* from here - that tab saves its own, unclipped copy. When another tab saved the chat after this
|
|
458
|
+
* tab last read or wrote it (or saved a chat this tab never read), THAT record is the truth for
|
|
459
|
+
* everything that is not this tab's own: this tab's own new messages - by identity, not by count,
|
|
460
|
+
* so a reset or a trim here drops nothing there - go after it, each before a stored turn that
|
|
461
|
+
* began after its own (`ChatMessage.startedAt`: this tab saved its turn late, after another tab
|
|
462
|
+
* ran the next one and saved first). Without times, after it all.
|
|
463
|
+
*/
|
|
464
|
+
declare const mergeChatRecord: (view: ChatRecord, stored: ChatRecord | undefined, base: ChatBase | undefined,
|
|
465
|
+
/** The words of a title of attachments only (`chatTitle`). */
|
|
466
|
+
texts?: AttachmentTexts) => {
|
|
467
|
+
record: ChatRecord;
|
|
468
|
+
merged: boolean;
|
|
469
|
+
};
|
|
470
|
+
/**
|
|
471
|
+
* What `useChatHistory` does to save the open chat: the stored record is read and the merged one
|
|
472
|
+
* written in ONE readwrite transaction (`ChatHistoryStore.putMerged`), so another tab's save
|
|
473
|
+
* cannot land between the two.
|
|
474
|
+
*/
|
|
475
|
+
declare const saveChat: (store: ChatHistoryStore, view: ChatRecord, base: ChatBase | undefined, texts?: AttachmentTexts) => Promise<{
|
|
476
|
+
record: ChatRecord;
|
|
477
|
+
merged: boolean;
|
|
478
|
+
}>;
|
|
479
|
+
|
|
480
|
+
/** Normalize any thrown value into a message string. */
|
|
481
|
+
declare const errMessage: (err: unknown) => string;
|
|
482
|
+
/**
|
|
483
|
+
* Calls `fn` once, `ms` after the LAST of a burst of calls (trailing): another tab writing a file
|
|
484
|
+
* per tool call, or a chat per settled run, refreshes a view once, not once per notice. `cancel`
|
|
485
|
+
* drops a pending call (on unmount).
|
|
486
|
+
*/
|
|
487
|
+
declare const coalesce: (fn: () => void, ms?: number) => {
|
|
488
|
+
call: () => void;
|
|
489
|
+
cancel: () => void;
|
|
490
|
+
};
|
|
491
|
+
/**
|
|
492
|
+
* The core's `onStorageChange`, or a no-op where the core predates it (the hooks then work as
|
|
493
|
+
* before: this tab's own changes only). One place for the guard every hook needs.
|
|
494
|
+
*/
|
|
495
|
+
declare const listenToOtherTabs: (core: {
|
|
496
|
+
onStorageChange?: unknown;
|
|
497
|
+
}, dbName: string | undefined, listener: (change: {
|
|
498
|
+
kind: string;
|
|
499
|
+
op: string;
|
|
500
|
+
key?: string;
|
|
501
|
+
namespace?: string;
|
|
502
|
+
}) => void) => (() => void);
|
|
503
|
+
/**
|
|
504
|
+
* Follow another tab's writes to one database: `accept` sees every notice (and says whether it
|
|
505
|
+
* matters here), `settle` runs once, ~`ms` after the last accepted one of a burst. What every hook
|
|
506
|
+
* that follows other tabs uses. The returned function unsubscribes and drops a pending settle.
|
|
507
|
+
*/
|
|
508
|
+
declare const followOtherTabs: (core: {
|
|
509
|
+
onStorageChange?: unknown;
|
|
510
|
+
}, dbName: string | undefined, accept: (change: {
|
|
511
|
+
kind: string;
|
|
512
|
+
op: string;
|
|
513
|
+
key?: string;
|
|
514
|
+
namespace?: string;
|
|
515
|
+
}) => boolean, settle: () => void, ms?: number) => (() => void);
|
|
516
|
+
/**
|
|
517
|
+
* What `sendRemote` makes of `watchSession().send`'s answer: `true` - that tab took it; `false`
|
|
518
|
+
* while this view still watches that conversation - refused, or that run ended without it (the text
|
|
519
|
+
* is offered again); `false` after the watch was closed (another conversation, the view gone) -
|
|
520
|
+
* unknown: that tab may still take it, so nothing is offered.
|
|
521
|
+
*/
|
|
522
|
+
declare const remoteAnswerOf: (ok: boolean, stillWatching: boolean) => "taken" | "refused" | "unknown";
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* The sandboxed frame's security core: what untrusted HTML (a file the agent wrote, later an
|
|
526
|
+
* MCP App) is wrapped in before it reaches an `<iframe>`. Pure strings - no React, no DOM - so
|
|
527
|
+
* every guard is unit-tested here and proved in a real browser by `e2e/files.spec.ts`.
|
|
528
|
+
*
|
|
529
|
+
* The boundary, in three layers:
|
|
530
|
+
* 1. `sandbox` WITHOUT `allow-same-origin`: the document gets an opaque origin - no access to
|
|
531
|
+
* the page's DOM, storage, IndexedDB (the key vault), cookies. No `allow-top-navigation`,
|
|
532
|
+
* `allow-popups`, `allow-forms`, `allow-modals`, `allow-downloads` either.
|
|
533
|
+
* 2. A Content-Security-Policy with no network source at all, given twice: as the first element
|
|
534
|
+
* of the document itself, and by inheritance from the shell (3) - a `srcdoc` document takes
|
|
535
|
+
* its parent's policy, which nothing inside the document can pre-empt.
|
|
536
|
+
* 3. A shell document of ours between the page and the untrusted one. A frame may always
|
|
537
|
+
* navigate ITSELF (`location = …`, a link, `<meta http-equiv=refresh>`): neither the sandbox
|
|
538
|
+
* nor a document's own CSP stops that, and a navigation is a network request. The only thing
|
|
539
|
+
* that does is the `frame-src` of the document that EMBEDS the frame - so we embed it in one
|
|
540
|
+
* we wrote, whose policy says `frame-src 'none'`.
|
|
541
|
+
*/
|
|
542
|
+
interface SandboxedDocumentOptions {
|
|
543
|
+
/** Let the document's own inline scripts run (default false). */
|
|
544
|
+
scripts?: boolean;
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* The policy of the framed document: nothing is fetched from anywhere. Inline styles, and
|
|
548
|
+
* images / fonts / media the document carries inside itself (`data:`, `blob:`), are all it gets;
|
|
549
|
+
* inline scripts only when asked for. `frame-src 'none'` is what stops the frame from navigating.
|
|
550
|
+
*/
|
|
551
|
+
declare const sandboxedCsp: (scripts?: boolean) => string;
|
|
552
|
+
/**
|
|
553
|
+
* The `sandbox` attribute: empty (everything off) or `allow-scripts`. Never
|
|
554
|
+
* `allow-same-origin`, never a navigation, popup, form, modal or download token.
|
|
555
|
+
*/
|
|
556
|
+
declare const sandboxTokens: (scripts?: boolean) => string;
|
|
557
|
+
/** A string as the value of a double-quoted HTML attribute. */
|
|
558
|
+
declare const escapeAttribute: (value: string) => string;
|
|
559
|
+
/** A `<meta>` that carries a Content-Security-Policy. */
|
|
560
|
+
declare const cspMetaTag: (policy: string) => string;
|
|
561
|
+
/**
|
|
562
|
+
* The document with our policy as its FIRST element: right after a leading DOCTYPE (so the
|
|
563
|
+
* page stays in standards mode), otherwise before everything. Nothing the document says can
|
|
564
|
+
* come earlier - not its own `<meta>`, not a `<base>`, not a script before `<html>` - and a
|
|
565
|
+
* later policy of its own can only narrow ours.
|
|
566
|
+
*/
|
|
567
|
+
declare const withCspFirst: (html: string, scripts?: boolean) => string;
|
|
568
|
+
/** `withCspFirst` with a policy of the caller's (an MCP App's, built by `mcpAppCsp`). */
|
|
569
|
+
declare const withPolicyFirst: (html: string, policy: string) => string;
|
|
570
|
+
/**
|
|
571
|
+
* What goes into the outer frame's `srcdoc`: the shell (ours: the policy, and one inner frame
|
|
572
|
+
* that fills it) carrying the untrusted document, escaped, as the inner frame's `srcdoc`.
|
|
573
|
+
* Give the OUTER `<iframe>` the same `sandboxTokens(scripts)`.
|
|
574
|
+
*/
|
|
575
|
+
declare const buildSandboxedDocument: (html: string, { scripts }?: SandboxedDocumentOptions) => string;
|
|
576
|
+
/** HTML above this many characters is not framed at all - it is shown as source. */
|
|
577
|
+
declare const HTML_PREVIEW_MAX_CHARS = 1000000;
|
|
578
|
+
/**
|
|
579
|
+
* The files a document links to by a relative path (`style.css`, `./app.js`, `img/a.png`): the
|
|
580
|
+
* preview does not load them, and says so. A hint for the user, not a guard - the policy is
|
|
581
|
+
* what keeps them from loading.
|
|
582
|
+
*/
|
|
583
|
+
declare const linkedFilesOf: (html: string, max?: number) => string[];
|
|
584
|
+
/** A piece of HTML source, by what it is (for colouring the Source view). */
|
|
585
|
+
interface SourceToken {
|
|
586
|
+
kind: 'text' | 'tag' | 'attr' | 'string' | 'comment';
|
|
587
|
+
text: string;
|
|
588
|
+
}
|
|
589
|
+
/**
|
|
590
|
+
* Split HTML source into coloured pieces. Lossless: the pieces joined are the input. It only
|
|
591
|
+
* decides colours - the result is rendered as text nodes, never as markup.
|
|
592
|
+
*/
|
|
593
|
+
declare const tokenizeHtml: (source: string) => SourceToken[];
|
|
594
|
+
/** The frame's height is the host's: a number of pixels between these, never the content's wish. */
|
|
595
|
+
declare const FRAME_MIN_HEIGHT = 120;
|
|
596
|
+
declare const FRAME_MAX_HEIGHT = 800;
|
|
597
|
+
declare const clampFrameHeight: (height: number) => number;
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* Recording from the microphone, for dictation through a model and for voice messages. No React:
|
|
601
|
+
* a hook and the composer are built on it. The browser's `getUserMedia` and `MediaRecorder` can
|
|
602
|
+
* be handed in (`RecordingDeps`), which is how the tests drive it.
|
|
603
|
+
*
|
|
604
|
+
* The rules it keeps:
|
|
605
|
+
* - the permission is asked only by `startRecording` - call it from the person's tap;
|
|
606
|
+
* - every track of the stream is stopped when the recording ends: stopped, cancelled, cut at its
|
|
607
|
+
* longest, or failed - the browser's "recording" indicator goes away;
|
|
608
|
+
* - nothing is kept here: the audio is handed to the caller once, as a `Blob`.
|
|
609
|
+
*/
|
|
610
|
+
/** Why the microphone could not be used, as the composer says it (`micProblemLabel`). */
|
|
611
|
+
type MicProblem =
|
|
612
|
+
/** The person (or the browser, for this site) refused the permission. */
|
|
613
|
+
'not-allowed'
|
|
614
|
+
/** No microphone on the device (or none that fits). */
|
|
615
|
+
| 'audio-capture'
|
|
616
|
+
/** The microphone is held by another app (or the system refused to start it). */
|
|
617
|
+
| 'busy'
|
|
618
|
+
/** No recording here at all: no `mediaDevices` (an insecure page) or no `MediaRecorder`. */
|
|
619
|
+
| 'unsupported' | 'failed';
|
|
620
|
+
/** An error of the microphone, with its `MicProblem`. */
|
|
621
|
+
declare class MicError extends Error {
|
|
622
|
+
readonly code: MicProblem;
|
|
623
|
+
constructor(code: MicProblem, message?: string);
|
|
624
|
+
}
|
|
625
|
+
/** What a recording gave: the bytes, their media type (no codec parameters) and how long it ran. */
|
|
626
|
+
interface RecordedAudio {
|
|
627
|
+
blob: Blob;
|
|
628
|
+
/** `audio/webm`, `audio/mp4` (Safari, iOS), `audio/ogg`... - the container, without `;codecs=`. */
|
|
629
|
+
mediaType: string;
|
|
630
|
+
durationMs: number;
|
|
631
|
+
}
|
|
632
|
+
/** The slice of `MediaRecorder` this module drives. */
|
|
633
|
+
interface MediaRecorderLike {
|
|
634
|
+
readonly mimeType: string;
|
|
635
|
+
readonly state: 'inactive' | 'recording' | 'paused';
|
|
636
|
+
start(timeslice?: number): void;
|
|
637
|
+
stop(): void;
|
|
638
|
+
ondataavailable: ((event: {
|
|
639
|
+
data: Blob;
|
|
640
|
+
}) => void) | null;
|
|
641
|
+
onstop: (() => void) | null;
|
|
642
|
+
onerror: ((event: unknown) => void) | null;
|
|
643
|
+
}
|
|
644
|
+
interface MediaRecorderConstructorLike {
|
|
645
|
+
new (stream: MediaStream, options?: {
|
|
646
|
+
mimeType?: string;
|
|
647
|
+
}): MediaRecorderLike;
|
|
648
|
+
isTypeSupported?(type: string): boolean;
|
|
649
|
+
}
|
|
650
|
+
interface RecordingDeps {
|
|
651
|
+
/** Default: `navigator.mediaDevices.getUserMedia`. */
|
|
652
|
+
getUserMedia?: (constraints: MediaStreamConstraints) => Promise<MediaStream>;
|
|
653
|
+
/** Default: the page's `MediaRecorder`. */
|
|
654
|
+
MediaRecorder?: MediaRecorderConstructorLike;
|
|
655
|
+
/** Default: `Date.now`. */
|
|
656
|
+
now?: () => number;
|
|
657
|
+
}
|
|
658
|
+
/** The longest recording unless the caller says otherwise: five minutes. */
|
|
659
|
+
declare const RECORDING_DEFAULT_MAX_MS: number;
|
|
660
|
+
/**
|
|
661
|
+
* The containers asked for, in order: Opus in WebM (Chrome, Edge, Firefox), AAC in MP4 (Safari -
|
|
662
|
+
* iOS records nothing else), Opus in Ogg. Every one is a type the core transcribes and plays.
|
|
663
|
+
*/
|
|
664
|
+
declare const RECORDING_TYPES: readonly ["audio/webm;codecs=opus", "audio/webm", "audio/mp4", "audio/ogg;codecs=opus", "audio/ogg"];
|
|
665
|
+
/** The first type the recorder takes, or undefined (the browser then picks its own). */
|
|
666
|
+
declare const pickRecordingType: (isTypeSupported: ((type: string) => boolean) | undefined) => string | undefined;
|
|
667
|
+
/**
|
|
668
|
+
* A recorder's media type as a file's: the container without parameters, and the names browsers
|
|
669
|
+
* use for the same thing brought to one (`audio/x-m4a`, `audio/m4a`, `video/mp4` from Safari →
|
|
670
|
+
* `audio/mp4`; `video/webm` → `audio/webm`). Unknown or empty: `audio/webm`.
|
|
671
|
+
*/
|
|
672
|
+
declare const audioTypeOf: (type: string | undefined) => string;
|
|
673
|
+
/** The file extension of an audio type (`audioTypeOf`'s): `webm`, `m4a`, `ogg`, `wav`, `mp3`, `aac`. */
|
|
674
|
+
declare const audioExtensionOf: (type: string) => string;
|
|
675
|
+
/** What a failed `getUserMedia` (or recorder) means, by the DOMException's name. */
|
|
676
|
+
declare const micProblemOf: (err: unknown) => MicProblem;
|
|
677
|
+
/** Whether this browser can record at all (it does not ask for anything). */
|
|
678
|
+
declare const recordingSupported: (deps?: RecordingDeps) => boolean;
|
|
679
|
+
/** Stop every track of a stream: the microphone is let go. */
|
|
680
|
+
declare const stopTracks: (stream: MediaStream | undefined) => void;
|
|
681
|
+
/** A recording under way. */
|
|
682
|
+
interface Recording {
|
|
683
|
+
/** When it started (the clock of `RecordingDeps.now`). */
|
|
684
|
+
readonly startedAt: number;
|
|
685
|
+
/** Stop it and get the audio. The microphone is let go first. */
|
|
686
|
+
stop(): Promise<RecordedAudio>;
|
|
687
|
+
/** Throw it away. The microphone is let go; `stop` then rejects. */
|
|
688
|
+
cancel(): void;
|
|
689
|
+
/** Settles when the recording has ended, whichever way (the tracks are stopped by then). */
|
|
690
|
+
readonly ended: Promise<void>;
|
|
691
|
+
}
|
|
692
|
+
interface StartRecordingOptions extends RecordingDeps {
|
|
693
|
+
/** Cut it here (default `RECORDING_DEFAULT_MAX_MS`); `onLimit` is told, `stop` still gives the audio. */
|
|
694
|
+
maxMs?: number;
|
|
695
|
+
onLimit?: () => void;
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* Ask for the microphone and start recording. Rejects with a `MicError` when the microphone
|
|
699
|
+
* cannot be had (the permission refused, no device, held elsewhere, no recorder) - and then no
|
|
700
|
+
* track is left running.
|
|
701
|
+
*/
|
|
702
|
+
declare const startRecording: (options?: StartRecordingOptions) => Promise<Recording>;
|
|
703
|
+
|
|
704
|
+
/** The slice of the Web Speech API recognizer `useSpeechToText` (and any other front end) drives. */
|
|
705
|
+
interface SpeechRecognizerLike {
|
|
706
|
+
lang: string;
|
|
707
|
+
continuous: boolean;
|
|
708
|
+
interimResults: boolean;
|
|
709
|
+
start(): void;
|
|
710
|
+
stop(): void;
|
|
711
|
+
abort?(): void;
|
|
712
|
+
onresult: ((ev: SpeechResultEventLike) => void) | null;
|
|
713
|
+
/**
|
|
714
|
+
* `error` is the Web Speech API's code (`not-allowed`, `audio-capture`, `network`, ...) or a
|
|
715
|
+
* recognizer's own; `message`, when given, is what to say - in the host's words.
|
|
716
|
+
*/
|
|
717
|
+
onerror: ((ev: {
|
|
718
|
+
error?: string;
|
|
719
|
+
message?: string;
|
|
720
|
+
}) => void) | null;
|
|
721
|
+
onend: (() => void) | null;
|
|
722
|
+
}
|
|
723
|
+
interface SpeechResultEventLike {
|
|
724
|
+
resultIndex: number;
|
|
725
|
+
results: ArrayLike<{
|
|
726
|
+
isFinal: boolean;
|
|
727
|
+
0: {
|
|
728
|
+
transcript: string;
|
|
729
|
+
};
|
|
730
|
+
}>;
|
|
731
|
+
}
|
|
732
|
+
/** Turn a recording into text: the host's call to a speech-to-text model. */
|
|
733
|
+
type TranscribeAudio = (audio: RecordedAudio, context: {
|
|
734
|
+
/** The recognizer's language (BCP-47), a hint for the model. */
|
|
735
|
+
lang: string;
|
|
736
|
+
/** Aborted when the person cancels (or the composer goes away). */
|
|
737
|
+
signal: AbortSignal;
|
|
738
|
+
}) => Promise<string>;
|
|
739
|
+
interface RecordingRecognizerOptions extends RecordingDeps {
|
|
740
|
+
/** The speech-to-text call - a provider's transcription model, an on-device engine. */
|
|
741
|
+
transcribe: TranscribeAudio;
|
|
742
|
+
/** The longest dictation (default: the recorder's five minutes). */
|
|
743
|
+
maxMs?: number;
|
|
744
|
+
}
|
|
745
|
+
/**
|
|
746
|
+
* A recognizer for `useSpeechToText` / the composer's mic (`speech.createRecognizer`) that
|
|
747
|
+
* RECORDS and then hands the audio to `transcribe`: tap to start (the microphone is asked for
|
|
748
|
+
* then), tap again to stop - the words arrive once, as one final result, after the model has
|
|
749
|
+
* answered (`useSpeechToText().finishing` meanwhile). The microphone is let go as soon as the
|
|
750
|
+
* recording stops; the audio is given to `transcribe` and kept nowhere.
|
|
751
|
+
*
|
|
752
|
+
* Errors come as the Web Speech API's codes where there is one (`not-allowed`, `audio-capture`),
|
|
753
|
+
* the recorder's otherwise (`busy`, `unsupported`), and `transcription` with the thrown error's
|
|
754
|
+
* `message` - say it in the host's words: the composer shows the message as given.
|
|
755
|
+
*/
|
|
756
|
+
declare const createRecordingRecognizer: (options: RecordingRecognizerOptions) => (() => SpeechRecognizerLike);
|
|
757
|
+
|
|
758
|
+
/**
|
|
759
|
+
* Reading answers aloud: the text an answer is read as (`speakableText`), and two engines behind
|
|
760
|
+
* one shape (`SpeakText`) - the browser's own `speechSynthesis` (on the device, free, offline
|
|
761
|
+
* where the voice is local) and any engine that makes audio (`createAudioSpeaker`: a provider's
|
|
762
|
+
* text-to-speech model, played from a `blob:` URL). No React; `useReadAloud` and the message
|
|
763
|
+
* list's Listen button are built on it.
|
|
764
|
+
*/
|
|
765
|
+
/** Where a reading is: making its audio, playing, paused. */
|
|
766
|
+
type ReadAloudState = 'loading' | 'playing' | 'paused';
|
|
767
|
+
/** A reading under way. */
|
|
768
|
+
interface SpeechPlayback {
|
|
769
|
+
pause(): void;
|
|
770
|
+
resume(): void;
|
|
771
|
+
/** End it now; `done` then resolves. */
|
|
772
|
+
stop(): void;
|
|
773
|
+
/** Resolves when the reading ends - read to the end, or stopped; rejects when it failed. */
|
|
774
|
+
readonly done: Promise<void>;
|
|
775
|
+
}
|
|
776
|
+
/** Start reading a text. `onState` hears every change of state until `done` settles. */
|
|
777
|
+
type SpeakText = (text: string, options: {
|
|
778
|
+
lang?: string;
|
|
779
|
+
onState: (state: ReadAloudState) => void;
|
|
780
|
+
}) => SpeechPlayback;
|
|
781
|
+
/**
|
|
782
|
+
* A reading that failed in the engine itself (the browser's voice, the audio element) - a code,
|
|
783
|
+
* not words for the person: the Listen button says its own label. An error a host's
|
|
784
|
+
* `synthesize` throws is shown with its message.
|
|
785
|
+
*/
|
|
786
|
+
declare class SpeechOutputError extends Error {
|
|
787
|
+
readonly code: string;
|
|
788
|
+
constructor(code: string);
|
|
789
|
+
}
|
|
790
|
+
interface SpeakableOptions {
|
|
791
|
+
/** Said in place of a code block (default: nothing - the block is skipped). */
|
|
792
|
+
code?: string;
|
|
793
|
+
}
|
|
794
|
+
/**
|
|
795
|
+
* An answer's Markdown as the words to say: no markers (`#`, `*`, `_`, backticks, `>`, list
|
|
796
|
+
* bullets, table rules), a link as its text, a picture as its alt text, a bare URL as its host, a
|
|
797
|
+
* code block NOT read symbol by symbol (left out, or said as `options.code`), inline code as its
|
|
798
|
+
* text, a table's cells one after another. Blocks end in a stop so the voice pauses between them.
|
|
799
|
+
*/
|
|
800
|
+
declare const speakableText: (markdown: string, options?: SpeakableOptions) => string;
|
|
801
|
+
/**
|
|
802
|
+
* A text in pieces of at most `max` characters, cut after a sentence where one ends in time,
|
|
803
|
+
* else after a word: engines read long text badly in one go (Chrome's voices stop after some
|
|
804
|
+
* seconds; a provider takes a few thousand characters per call).
|
|
805
|
+
*/
|
|
806
|
+
declare const splitForSpeech: (text: string, max?: number) => string[];
|
|
807
|
+
/** A writing system, as far as a voice needs to know: the letters it can read. */
|
|
808
|
+
type SpeechScript = 'latin' | 'cyrillic' | 'greek' | 'arabic' | 'hebrew' | 'han' | 'kana' | 'hangul' | 'devanagari' | 'thai' | 'georgian' | 'armenian';
|
|
809
|
+
/** The script a language (BCP-47) is written in: `sr-Latn` is Latin, `zh-*` Han, `ja` kana. */
|
|
810
|
+
declare const scriptOfLanguage: (lang: string) => SpeechScript;
|
|
811
|
+
/**
|
|
812
|
+
* The script most of a text's letters are written in (digits, signs and spaces do not count);
|
|
813
|
+
* a text with any kana is Japanese (it is mostly Han letters too). Undefined: no letters.
|
|
814
|
+
*/
|
|
815
|
+
declare const scriptOfText: (text: string) => SpeechScript | undefined;
|
|
816
|
+
/**
|
|
817
|
+
* The language to read a text in: the first of `preferred` (the UI's language, then the
|
|
818
|
+
* browser's, `navigator.languages`) written in the text's script - so a Russian answer in an
|
|
819
|
+
* English interface is read in Russian, not spelled by an English voice -, else the script's
|
|
820
|
+
* usual language. A text without letters: the first preferred. Which of the languages of ONE
|
|
821
|
+
* script (English or French) cannot be told from the letters: the person's order decides.
|
|
822
|
+
*/
|
|
823
|
+
declare const languageOfText: (text: string, preferred?: readonly (string | undefined)[]) => string | undefined;
|
|
824
|
+
/** The slice of a `SpeechSynthesisVoice` used here. */
|
|
825
|
+
interface SpeechVoiceLike {
|
|
826
|
+
voiceURI: string;
|
|
827
|
+
name: string;
|
|
828
|
+
lang: string;
|
|
829
|
+
localService?: boolean;
|
|
830
|
+
default?: boolean;
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* The voice to read a language with: the person's (by `voiceURI`) while the browser has it and it
|
|
834
|
+
* reads that language's script; else
|
|
835
|
+
* one of exactly that language (`pt-BR`), then of its base (`pt`) - a voice on the device before a
|
|
836
|
+
* network one, the browser's default of the language first. Undefined: none for the language (the
|
|
837
|
+
* browser then reads with its own default).
|
|
838
|
+
*/
|
|
839
|
+
declare const voiceFor: <V extends SpeechVoiceLike>(voices: readonly V[], lang: string | undefined, preferred?: string) => V | undefined;
|
|
840
|
+
/** The voices of a language (`voiceFor`'s matching), for a picker. */
|
|
841
|
+
declare const voicesOf: <V extends SpeechVoiceLike>(voices: readonly V[], lang: string | undefined) => V[];
|
|
842
|
+
/** The slice of `speechSynthesis` this module drives. */
|
|
843
|
+
interface SpeechSynthesisLike {
|
|
844
|
+
speak(utterance: SpeechUtteranceLike): void;
|
|
845
|
+
cancel(): void;
|
|
846
|
+
pause(): void;
|
|
847
|
+
resume(): void;
|
|
848
|
+
getVoices(): SpeechVoiceLike[];
|
|
849
|
+
readonly speaking?: boolean;
|
|
850
|
+
}
|
|
851
|
+
interface SpeechUtteranceLike {
|
|
852
|
+
text: string;
|
|
853
|
+
lang: string;
|
|
854
|
+
voice: SpeechVoiceLike | null;
|
|
855
|
+
rate: number;
|
|
856
|
+
onstart: (() => void) | null;
|
|
857
|
+
onend: (() => void) | null;
|
|
858
|
+
onerror: ((event: {
|
|
859
|
+
error?: string;
|
|
860
|
+
}) => void) | null;
|
|
861
|
+
}
|
|
862
|
+
/** Whether the browser can read aloud (it has `speechSynthesis`). */
|
|
863
|
+
declare const speechSynthesisSupported: () => boolean;
|
|
864
|
+
interface BrowserSpeakerOptions {
|
|
865
|
+
/** The person's voice (`voiceURI`); else one of the text's language (`voiceFor`). */
|
|
866
|
+
voice?: string;
|
|
867
|
+
/** 0.1-10, default 1. */
|
|
868
|
+
rate?: number;
|
|
869
|
+
/** Default: the page's `speechSynthesis` and `SpeechSynthesisUtterance` (tests hand in their own). */
|
|
870
|
+
synth?: SpeechSynthesisLike;
|
|
871
|
+
createUtterance?: (text: string) => SpeechUtteranceLike;
|
|
872
|
+
}
|
|
873
|
+
/**
|
|
874
|
+
* Read with the browser's `speechSynthesis`: on the device (a local voice works offline), free.
|
|
875
|
+
* The text goes in pieces (`splitForSpeech`); one reading at a time in the whole page - starting
|
|
876
|
+
* one cancels any other.
|
|
877
|
+
*/
|
|
878
|
+
declare const createBrowserSpeaker: (options?: BrowserSpeakerOptions) => SpeakText;
|
|
879
|
+
/** Make the audio of a text: the host's call to a text-to-speech model. */
|
|
880
|
+
type SynthesizeSpeech = (text: string, context: {
|
|
881
|
+
lang?: string;
|
|
882
|
+
signal: AbortSignal;
|
|
883
|
+
}) => Promise<Blob>;
|
|
884
|
+
/** The slice of an `HTMLAudioElement` this module drives. */
|
|
885
|
+
interface AudioLike {
|
|
886
|
+
src: string;
|
|
887
|
+
paused: boolean;
|
|
888
|
+
play(): Promise<void>;
|
|
889
|
+
pause(): void;
|
|
890
|
+
onended: (() => void) | null;
|
|
891
|
+
onerror: (() => void) | null;
|
|
892
|
+
}
|
|
893
|
+
interface AudioSpeakerOptions {
|
|
894
|
+
synthesize: SynthesizeSpeech;
|
|
895
|
+
/** Characters per call (default 2000): a long answer is several calls, the next made while one plays. */
|
|
896
|
+
maxChars?: number;
|
|
897
|
+
/** Default: `new Audio()`. */
|
|
898
|
+
createAudio?: () => AudioLike;
|
|
899
|
+
/** Default: `URL.createObjectURL` / `URL.revokeObjectURL`. */
|
|
900
|
+
objectUrl?: {
|
|
901
|
+
create: (blob: Blob) => string;
|
|
902
|
+
revoke: (url: string) => void;
|
|
903
|
+
};
|
|
904
|
+
/**
|
|
905
|
+
* Play a moment of silence on the element at once, inside the person's tap (default true): iOS
|
|
906
|
+
* Safari plays an element later - after the audio was made - only if it was played inside the
|
|
907
|
+
* gesture. Call `speak` from the click handler for it to count.
|
|
908
|
+
*/
|
|
909
|
+
unlock?: boolean;
|
|
910
|
+
}
|
|
911
|
+
/**
|
|
912
|
+
* Read with an engine that makes audio - a provider's text-to-speech model: each piece of the text
|
|
913
|
+
* (`maxChars`) is made by `synthesize` and played from a `blob:` URL, revoked when it has played
|
|
914
|
+
* or the reading stops. Stopping aborts a call in flight (`signal`). Nothing is stored.
|
|
915
|
+
*/
|
|
916
|
+
declare const createAudioSpeaker: (options: AudioSpeakerOptions) => SpeakText;
|
|
917
|
+
|
|
918
|
+
export { AgentUiState, ApprovalView, ChatAttachment, ChatHistoryStore, ChatMessage, FOLLOW_LEAVE_PX, FOLLOW_REJOIN_PX, FRAME_MAX_HEIGHT, FRAME_MIN_HEIGHT, HTML_PREVIEW_MAX_CHARS, LessonView, MicError, NAMED_FILES_MAX, NAMED_FILES_SCAN_MAX, NAMED_FILES_TEXT_MAX, PROMPT_ARM_MS, RECORDING_DEFAULT_MAX_MS, RECORDING_TYPES, RemoteRunView, SpeechOutputError, SubagentNode, SubagentView, agentStateReducer, agentStatusOf, attachmentsText, audioExtensionOf, audioTypeOf, buildSandboxedDocument, chatTitle, clampFrameHeight, coalesce, createApprovalQueue, createAudioSpeaker, createBrowserSpeaker, createInitialAgentState, createPromptArming, createRecordingRecognizer, cspMetaTag, downscaleImage, endGap, errMessage, escapeAttribute, followOtherTabs, followsAfterResize, followsAfterScroll, formatDuration, formatProbability, formatTokens, imageSizeOf, imagesInOutput, languageOfText, lessonsOf, linkedFilesOf, listenToOtherTabs, mergeChatRecord, micProblemOf, namedFilesOf, newChatId, ownUnsaved, pathsNamedIn, pendingApprovalsOf, pickRecordingType, previewValue, recordingSupported, remoteAnswerOf, sandboxTokens, sandboxedCsp, saveChat, scriptOfLanguage, scriptOfText, speakableText, speechSynthesisSupported, splitForSpeech, startRecording, stopTracks, subagentTree, tokenizeHtml, unchangedSince, voiceFor, voicesOf, webSearchOf, withCspFirst, withPolicyFirst, workspacePathOf };
|
|
919
|
+
export type { AgentAction, ApprovalQueue, AttachmentTexts, AudioLike, AudioSpeakerOptions, BrowserSpeakerOptions, ChatBase, ChatHistoryStoreOptions, ChatRecord, ChatSummary, DownscaleOptions, ImageSize, MediaRecorderConstructorLike, MediaRecorderLike, MicProblem, NamedFilesOptions, PromptArming, ReadAloudState, RecordedAudio, Recording, RecordingDeps, RecordingRecognizerOptions, SandboxedDocumentOptions, ScrollMeasure, SourceToken, SpeakText, SpeakableOptions, SpeechPlayback, SpeechRecognizerLike, SpeechScript, SpeechSynthesisLike, SpeechUtteranceLike, SpeechVoiceLike, StartRecordingOptions, SynthesizeSpeech, TranscribeAudio, WebSearchResultView, WebSearchView };
|