@clickless/react 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.
Files changed (59) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1095 -2
  3. package/dist/actions/actionCalls.d.ts +50 -0
  4. package/dist/actions/actionRegistry.d.ts +78 -0
  5. package/dist/components/Adaptive.d.ts +116 -0
  6. package/dist/components/AdaptiveAction.d.ts +4 -0
  7. package/dist/components/AdaptiveProvider.d.ts +38 -0
  8. package/dist/components/AdaptiveRegion.d.ts +60 -0
  9. package/dist/components/ClicklessUiErrorBoundary.d.ts +24 -0
  10. package/dist/components/OriginalToolbar.d.ts +21 -0
  11. package/dist/components/PromptBar.d.ts +21 -0
  12. package/dist/components/PromptPanel.d.ts +103 -0
  13. package/dist/components/WorkingDots.d.ts +4 -0
  14. package/dist/components/focusAfterPromptAction.d.ts +15 -0
  15. package/dist/components/hostColorScheme.d.ts +35 -0
  16. package/dist/components/promptPanelStyles.d.ts +14 -0
  17. package/dist/core/applyOperations.d.ts +21 -0
  18. package/dist/core/colorContrast.d.ts +22 -0
  19. package/dist/core/defaultLayout.d.ts +12 -0
  20. package/dist/core/index.d.ts +8 -0
  21. package/dist/core/ownProperties.d.ts +11 -0
  22. package/dist/core/propValues.d.ts +8 -0
  23. package/dist/core/reconcileLayout.d.ts +59 -0
  24. package/dist/core/schemas.gen.d.ts +427 -0
  25. package/dist/core/validateActionCalls.d.ts +28 -0
  26. package/dist/core/validateManifest.d.ts +11 -0
  27. package/dist/core/validateOperations.d.ts +15 -0
  28. package/dist/engine/engineClient.d.ts +231 -0
  29. package/dist/engine/engineErrorMessages.d.ts +13 -0
  30. package/dist/engine/engineResponses.d.ts +201 -0
  31. package/dist/engine/plainReplies.d.ts +2 -0
  32. package/dist/hooks/useActionRunHistory.d.ts +12 -0
  33. package/dist/hooks/useAdaptiveAction.d.ts +11 -0
  34. package/dist/hooks/useAdaptiveRegion.d.ts +34 -0
  35. package/dist/hooks/useChangeHistory.d.ts +32 -0
  36. package/dist/hooks/useDictation.d.ts +50 -0
  37. package/dist/hooks/useEngineReachable.d.ts +5 -0
  38. package/dist/hooks/usePromptBar.d.ts +163 -0
  39. package/dist/hooks/useRegionGroup.d.ts +15 -0
  40. package/dist/index.d.ts +21 -0
  41. package/dist/index.js +6600 -0
  42. package/dist/presets/mergePresets.d.ts +20 -0
  43. package/dist/presets/propPresets.d.ts +305 -0
  44. package/dist/region/changedComponentIds.d.ts +13 -0
  45. package/dist/region/firstPaintOrder.d.ts +19 -0
  46. package/dist/region/previewRequests.d.ts +21 -0
  47. package/dist/region/regionContext.d.ts +96 -0
  48. package/dist/region/regionGroup.d.ts +189 -0
  49. package/dist/region/regionSnapshot.d.ts +52 -0
  50. package/dist/region/regionStore.d.ts +361 -0
  51. package/dist/region/responsiveColumns.d.ts +35 -0
  52. package/dist/region/retrier.d.ts +22 -0
  53. package/dist/region/savedLayoutParsing.d.ts +7 -0
  54. package/dist/region/settleIntoSavedLayout.d.ts +14 -0
  55. package/dist/region/textDirection.d.ts +12 -0
  56. package/dist/region/unsavedChangeSaver.d.ts +45 -0
  57. package/dist/region/unsavedChanges.d.ts +78 -0
  58. package/dist/region/userFacingTitle.d.ts +7 -0
  59. package/package.json +59 -3
@@ -0,0 +1,231 @@
1
+ import type { Action, Manifest, Operation, OperationError } from "../core/index.js";
2
+ /**
3
+ * How a previewed change from a prompt ended without being kept: the user
4
+ * chose not to keep it, or it left the screen before they chose.
5
+ */
6
+ export type PreviewNotKeptOutcome = "discarded" | "abandoned";
7
+ /** Which way a page's text, and so its rows, run. */
8
+ export type TextDirection = "ltr" | "rtl";
9
+ /** An earlier request on the screen and the reply it got, with what came of it. */
10
+ export interface ConversationTurn {
11
+ request: string;
12
+ reply: string;
13
+ }
14
+ import { type ActionRunRecorded, type ActionRunsPage, type LayoutResponse, type PlanAcrossRegionsResponse, type PlanResponse, type RegionLayoutsResponse, type UndoAcrossRegionsResponse, type UndoLayoutResponse, type DiscardResponse, type FeaturesResponse, type TranscriptionResponse, type HistoryPage } from "./engineResponses.js";
15
+ export interface EngineOptions {
16
+ /**
17
+ * Base URL of the ClickLess engine, without a trailing slash. It must start
18
+ * with `https://`, or `http://` for this machine only (`localhost`,
19
+ * `127.0.0.1`, `[::1]` or a `.localhost` name): at any other address nothing
20
+ * is sent.
21
+ */
22
+ url: string;
23
+ /**
24
+ * Returns the token your backend signed for the current user. Called before
25
+ * every request, so it can refresh an expired token.
26
+ */
27
+ getToken: () => string | Promise<string>;
28
+ fetch?: typeof fetch;
29
+ }
30
+ /**
31
+ * A change the user is looking at and has not kept, sent with a prompt typed
32
+ * meanwhile, which is then planned from it.
33
+ */
34
+ export interface PreviewToPlanFrom {
35
+ /** Applied, in order, to the saved layout the preview was made on. */
36
+ operations: readonly Operation[];
37
+ /** The revision the preview was made on. If the saved layout has changed since, nothing is planned. */
38
+ baseRevision: number;
39
+ }
40
+ /** A region as the screen last saw it, so the engine can tell when it has changed since. */
41
+ export interface RegionAsLastSeen {
42
+ regionId: string;
43
+ baseRevision: number;
44
+ }
45
+ export declare class EngineError extends Error {
46
+ readonly status: number;
47
+ readonly code: string;
48
+ readonly errors?: OperationError[] | undefined;
49
+ /** For a change across several regions: the ones that had changed elsewhere. */
50
+ readonly regionIds?: readonly string[];
51
+ constructor(message: string, status: number, code: string, errors?: OperationError[] | undefined, errorOptions?: ErrorOptions & {
52
+ regionIds?: readonly string[];
53
+ });
54
+ }
55
+ /**
56
+ * True when the error says the engine could not be reached or could not answer
57
+ * properly: no connection, an address it may not be called at, no answer in
58
+ * time, no token from the host, a reply that is not the engine's, or a fault on
59
+ * the engine's side.
60
+ */
61
+ export declare function isEngineUnavailable(error: unknown): boolean;
62
+ /**
63
+ * True when the same request may well succeed later: the engine was
64
+ * unavailable or busy, the user's sign-in was refused (a fresh token may be
65
+ * accepted), or it asked for a pause. A 403 is not among them: the sign-in was
66
+ * accepted but the user has no permission, which asking again will not change.
67
+ * Anything that is not an `EngineError` is counted too,
68
+ * so nothing unexpected throws away a change for good.
69
+ */
70
+ export declare function isWorthRetrying(error: unknown): boolean;
71
+ /** The error for an engine that could not be reached at all. */
72
+ export declare function engineUnreachableError(cause?: unknown): EngineError;
73
+ /** The engine, for something that cannot be done without one. */
74
+ export declare function requireEngine(engine: EngineClient | null, actionDescription: string): EngineClient;
75
+ export declare class EngineClient {
76
+ private readonly engineOptions;
77
+ private readonly userId?;
78
+ private engineReachable;
79
+ private reachabilityListeners;
80
+ private tokenForAnotherUserReported;
81
+ private insecureUrlReported;
82
+ private tenantId;
83
+ /**
84
+ * `userId` is the user every request is made for. A token the host gives for
85
+ * anyone else, or for them in a tenant other than the first token's, is
86
+ * never sent: `getToken` gives the token of whoever is signed in when it
87
+ * answers, which, for a request made just before another user signed in,
88
+ * is not the user it was made for.
89
+ */
90
+ constructor(engineOptions: EngineOptions, userId?: string | undefined);
91
+ /**
92
+ * False from the moment a request finds the engine unavailable until one
93
+ * gets an answer from it again. True until anything has been asked.
94
+ */
95
+ get isReachable(): boolean;
96
+ subscribeToReachability: (reachabilityListener: () => void) => (() => void);
97
+ private setReachable;
98
+ readLayout(regionId: string): Promise<LayoutResponse>;
99
+ applyOperations(regionId: string, revisionRequest: {
100
+ manifest: Manifest;
101
+ operations: readonly Operation[];
102
+ prompt?: string;
103
+ message?: string;
104
+ baseRevision: number;
105
+ viaVoice?: boolean;
106
+ }): Promise<LayoutResponse>;
107
+ restoreRevision(regionId: string, revision: number, baseRevision: number): Promise<LayoutResponse>;
108
+ readHistory(regionId: string, pageOptions: {
109
+ limit: number;
110
+ before?: number;
111
+ promptedOnly?: boolean;
112
+ }): Promise<HistoryPage>;
113
+ undoLastChange(regionId: string, baseRevision: number): Promise<UndoLayoutResponse>;
114
+ /** Tells the engine a change it planned for a prompt was previewed and not kept. */
115
+ reportDiscardedPreview(regionId: string, discardReport: {
116
+ manifestVersion: string;
117
+ prompt: string;
118
+ message: string;
119
+ operations: readonly Operation[];
120
+ viaVoice?: boolean;
121
+ /** "abandoned" when the preview left the screen before the user chose. Defaults to "discarded". */
122
+ outcome?: PreviewNotKeptOutcome;
123
+ }): Promise<DiscardResponse>;
124
+ planFromPrompt(regionId: string, planRequest: {
125
+ manifest: Manifest;
126
+ prompt: string;
127
+ viaVoice?: boolean;
128
+ /** Which way the page reads, so "left" and "right" mean what the user sees. Defaults to "ltr". */
129
+ textDirection?: TextDirection;
130
+ /** The columns this screen draws the layout in, when fewer than the manifest's. */
131
+ drawnColumns?: number;
132
+ /** The preview on the screen, if any: the answer is what the prompt changes from it. */
133
+ preview?: PreviewToPlanFrom;
134
+ }): Promise<PlanResponse>;
135
+ /** `planFromPrompt` for several regions of one screen, planned together in one request. */
136
+ planAcrossRegions(planRequest: {
137
+ regions: {
138
+ manifest: Manifest;
139
+ /** The columns this screen draws the region in, when fewer than its manifest's. */
140
+ drawnColumns?: number;
141
+ /** This region's part of the preview on the screen, if any. */
142
+ preview?: PreviewToPlanFrom;
143
+ }[];
144
+ prompt: string;
145
+ viaVoice?: boolean;
146
+ /** What the screen offers to do for the user. There may then be no regions. */
147
+ actions?: readonly Action[];
148
+ /** Earlier requests on the screen and their replies, oldest first. */
149
+ conversation?: readonly ConversationTurn[];
150
+ /** Files the user attached: their names and types only. */
151
+ attachedFiles?: readonly {
152
+ name: string;
153
+ type: string;
154
+ }[];
155
+ /** What a missed request is recorded under when no region is on the screen. */
156
+ screenId?: string;
157
+ /** Which way the page reads, so "left" and "right" mean what the user sees. Defaults to "ltr". */
158
+ textDirection?: TextDirection;
159
+ }): Promise<PlanAcrossRegionsResponse>;
160
+ /** Saves one change to several regions: every region's part is stored, or none is. */
161
+ saveChangeAcrossRegions(changeRequest: {
162
+ regions: {
163
+ manifest: Manifest;
164
+ operations: readonly Operation[];
165
+ baseRevision: number;
166
+ }[];
167
+ prompt?: string;
168
+ message?: string;
169
+ viaVoice?: boolean;
170
+ }): Promise<RegionLayoutsResponse>;
171
+ /** Undoes the latest change among these regions, in each of them it reached. */
172
+ undoAcrossRegions(regions: RegionAsLastSeen[]): Promise<UndoAcrossRegionsResponse>;
173
+ /** Returns these regions to how they were after the change `changeId`; 0 is before any. */
174
+ restoreAcrossRegions(changeId: number, regions: RegionAsLastSeen[]): Promise<RegionLayoutsResponse>;
175
+ /** The history of several regions as one list. Each entry's `revision` is its change's number. */
176
+ readChanges(regionIds: readonly string[], pageOptions: {
177
+ limit: number;
178
+ before?: number;
179
+ promptedOnly?: boolean;
180
+ }): Promise<HistoryPage>;
181
+ /** `reportDiscardedPreview` for a preview that changed several regions. */
182
+ reportDiscardedAcrossRegions(discardReport: {
183
+ prompt: string;
184
+ message: string;
185
+ regions: {
186
+ regionId: string;
187
+ manifestVersion: string;
188
+ operations: readonly Operation[];
189
+ }[];
190
+ viaVoice?: boolean;
191
+ outcome?: PreviewNotKeptOutcome;
192
+ }): Promise<DiscardResponse>;
193
+ /**
194
+ * Notes that the user ran an action, or turned it down, and how it ended.
195
+ * Only the names of the fields it was given are sent, never their values.
196
+ */
197
+ recordActionRun(actionRunReport: {
198
+ screenId: string;
199
+ actionName: string;
200
+ actionTitle: string;
201
+ /** Whether it changed something, or only what was shown. */
202
+ mode: "read" | "write";
203
+ parameterNames: readonly string[];
204
+ outcome: "done" | "failed" | "cancelled";
205
+ viaVoice?: boolean;
206
+ }): Promise<ActionRunRecorded>;
207
+ /** The signed-in user's own action runs on one screen, newest first. */
208
+ readActionRuns(screenId: string, pageOptions: {
209
+ limit: number;
210
+ }): Promise<ActionRunsPage>;
211
+ /** What the engine is set up to do, so only what will work is offered. */
212
+ readFeatures(): Promise<FeaturesResponse>;
213
+ /**
214
+ * Turns a recording of a spoken prompt into text. `vocabularyHints` are names
215
+ * likely to be spoken, such as the titles on the screen.
216
+ */
217
+ transcribeRecording(recording: Blob, vocabularyHints?: readonly string[]): Promise<TranscriptionResponse>;
218
+ private sendRegionRequest;
219
+ private sendJsonRequest;
220
+ private sendRequest;
221
+ /**
222
+ * One request, given up on once `timeoutMs` has passed since it began,
223
+ * whatever it is waiting on then: the host's token, the answer, or the
224
+ * reading of its body. Nothing waits on the engine for longer.
225
+ */
226
+ private sendRequestOnce;
227
+ /** The request itself, from asking for the token to reading the answer, stopped by `timeoutSignal`. */
228
+ private sendRequestWithin;
229
+ private refuseTokenForAnotherAccount;
230
+ private throwEngineError;
231
+ }
@@ -0,0 +1,13 @@
1
+ /** Said to the user when a change they previewed can no longer be made. */
2
+ export declare const PREVIEW_NO_LONGER_FITS_MESSAGE = "That change no longer fits this screen. Please try again.";
3
+ /** Said when a change would leave a part of the screen with nothing on it. */
4
+ export declare const WOULD_EMPTY_PAGE_MESSAGE = "That would leave this page empty, so nothing was changed.";
5
+ /** Said when the engine cannot be reached, or cannot answer, so nothing can be personalised for now. */
6
+ export declare const ENGINE_UNAVAILABLE_MESSAGE = "Personalising isn't available right now. Please try again in a little while.";
7
+ /** Said when a recording held no speech that could be made out. */
8
+ export declare const NOTHING_HEARD_MESSAGE = "We couldn't hear anything. Please try again.";
9
+ /**
10
+ * A sentence for the person using the application. The engine's own error text
11
+ * is written for developers, so none of it is passed through.
12
+ */
13
+ export declare function describeError(error: unknown): string;
@@ -0,0 +1,201 @@
1
+ import { ActionCall, Operation, type Layout, type OperationError } from "../core/index.js";
2
+ export interface LayoutResponse {
3
+ revision: number;
4
+ /** null means the default layout. */
5
+ layout: Layout | null;
6
+ /** Whether the latest saved change can be undone. Absent from engines that do not say. */
7
+ canUndo?: boolean;
8
+ /**
9
+ * The number of the change that made this revision, counted across all of the
10
+ * user's regions. 0 when the region was never changed. Absent from engines
11
+ * that cannot change several regions at once.
12
+ */
13
+ changeId?: number;
14
+ }
15
+ /** A region's layout in an answer that carries several. */
16
+ export interface RegionLayoutResponse extends LayoutResponse {
17
+ regionId: string;
18
+ }
19
+ export interface RegionLayoutsResponse {
20
+ regions: RegionLayoutResponse[];
21
+ }
22
+ /** The change an undo took back. */
23
+ export interface UndoneChange {
24
+ /** `restore` went back to an earlier version of the screen. */
25
+ kind: "apply" | "restore";
26
+ /** What the user asked for. Null for a change made with the application's own controls. */
27
+ prompt: string | null;
28
+ /** From several regions, every region's, one region after another. */
29
+ operations: Operation[];
30
+ }
31
+ /**
32
+ * What an undo answers. `notUndoneIn` names the regions the undone change also
33
+ * reached that keep their part of it, because they changed again since.
34
+ * `undone` is the change taken back, null when the engine cannot tell which.
35
+ * Both are absent from engines that do not say. The undo has happened whatever
36
+ * `undone` holds, so it is read with care rather than checked with the rest.
37
+ */
38
+ export interface UndoLayoutResponse extends LayoutResponse {
39
+ notUndoneIn?: string[];
40
+ undone?: UndoneChange | null;
41
+ }
42
+ /** `UndoLayoutResponse` for an undo across several regions. */
43
+ export interface UndoAcrossRegionsResponse extends RegionLayoutsResponse {
44
+ notUndoneIn?: string[];
45
+ undone?: UndoneChange | null;
46
+ }
47
+ /** What the planner proposes for a prompt sent for several regions. */
48
+ export interface PlanAcrossRegionsResponse {
49
+ /** Only the regions that change. */
50
+ changes: {
51
+ regionId: string;
52
+ operations: Operation[];
53
+ }[];
54
+ /** The actions to run, in order. Absent from engines that offer none. */
55
+ actionCalls?: ActionCall[];
56
+ message: string;
57
+ }
58
+ export interface PlanResponse {
59
+ operations: Operation[];
60
+ message: string;
61
+ }
62
+ export interface DiscardResponse {
63
+ /** False when the engine is set to keep no such records. */
64
+ recorded: boolean;
65
+ }
66
+ export interface FeaturesResponse {
67
+ /** Whether the engine can turn a spoken prompt into text. */
68
+ dictation: boolean;
69
+ }
70
+ export interface TranscriptionResponse {
71
+ /** What was said. Empty when nothing could be made out, or when it seemed to hold a secret. */
72
+ text: string;
73
+ /**
74
+ * Given only when what was said is not given back, such as when it seems to
75
+ * hold a password or card number: what to tell the user instead.
76
+ */
77
+ message?: string;
78
+ }
79
+ export interface HistoryEntry {
80
+ /**
81
+ * Which point in the history this is: pass it to `restoreRevision`. From one
82
+ * region's history it is that region's revision. From a history of several
83
+ * regions it is the change's own number, the same as `changeId`.
84
+ */
85
+ revision: number;
86
+ /**
87
+ * Only in a history of several regions: the number of the change, counted
88
+ * across all of the user's regions. Its presence says that `revision` holds
89
+ * this number and not a region's revision.
90
+ */
91
+ changeId?: number;
92
+ /** `apply` is a change; `undo` and `restore` returned to an earlier layout. */
93
+ kind: "apply" | "undo" | "restore";
94
+ /** What the user asked for. Null for changes made with the application's own controls. */
95
+ prompt: string | null;
96
+ /** What the planner replied. */
97
+ message: string | null;
98
+ operations: Operation[];
99
+ createdAt: string;
100
+ /**
101
+ * From a history of several regions: what the change did in each region it
102
+ * reached. `revision` is then the number of the change as a whole, and
103
+ * `operations` holds every region's, one region after another.
104
+ */
105
+ regions?: {
106
+ regionId: string;
107
+ revision: number;
108
+ operations: Operation[];
109
+ }[];
110
+ }
111
+ export interface HistoryPage {
112
+ /** Newest first. */
113
+ revisions: HistoryEntry[];
114
+ hasMore: boolean;
115
+ }
116
+ export declare function isLayoutResponse(responseBody: unknown): responseBody is LayoutResponse;
117
+ export declare function isPlanResponse(responseBody: unknown): responseBody is PlanResponse;
118
+ export declare function isPlanAcrossRegionsResponse(responseBody: unknown): responseBody is PlanAcrossRegionsResponse;
119
+ export declare function isRegionLayoutsResponse(responseBody: unknown): responseBody is RegionLayoutsResponse;
120
+ export declare function isUndoLayoutResponse(responseBody: unknown): responseBody is UndoLayoutResponse;
121
+ export declare function isUndoAcrossRegionsResponse(responseBody: unknown): responseBody is UndoAcrossRegionsResponse;
122
+ export declare function isDiscardResponse(responseBody: unknown): responseBody is DiscardResponse;
123
+ export declare function isFeaturesResponse(responseBody: unknown): responseBody is FeaturesResponse;
124
+ export declare function isTranscriptionResponse(responseBody: unknown): responseBody is TranscriptionResponse;
125
+ /** A history entry as the engine sends it, before what it says is made safe to show. */
126
+ interface EngineHistoryEntry {
127
+ revision: number;
128
+ createdAt: string;
129
+ kind?: unknown;
130
+ prompt?: unknown;
131
+ message?: unknown;
132
+ operations: unknown[];
133
+ }
134
+ /** One region's history as the engine sends it. */
135
+ export interface EngineHistoryPage {
136
+ /** Newest first. */
137
+ revisions: EngineHistoryEntry[];
138
+ hasMore: boolean;
139
+ }
140
+ export declare function isEngineHistoryPage(responseBody: unknown): responseBody is EngineHistoryPage;
141
+ /** One region's history with what is shown made safe to show. */
142
+ export declare function historyPageFromEngine(enginePage: EngineHistoryPage): HistoryPage;
143
+ /** The engine's history of several regions, as it sends it. */
144
+ export interface ChangesPage {
145
+ /** Newest first. */
146
+ changes: {
147
+ changeId: number;
148
+ kind?: unknown;
149
+ prompt?: unknown;
150
+ message?: unknown;
151
+ createdAt: string;
152
+ regions: {
153
+ regionId: string;
154
+ revision: number;
155
+ operations: unknown[];
156
+ }[];
157
+ }[];
158
+ hasMore: boolean;
159
+ }
160
+ export declare function isChangesPage(responseBody: unknown): responseBody is ChangesPage;
161
+ /** A history of several regions in the same shape as one region's, one entry per change, made safe to show. */
162
+ export declare function historyPageFromChanges(changesPage: ChangesPage): HistoryPage;
163
+ /** What the engine said went wrong: the `detail` of an error reply. */
164
+ export interface ErrorDetail {
165
+ code?: string;
166
+ message?: string;
167
+ errors?: OperationError[];
168
+ /** For a request that named several regions: the ones that had changed elsewhere. */
169
+ regionIds?: string[];
170
+ }
171
+ /**
172
+ * The `detail` of an error reply, keeping only the fields of the kind the engine
173
+ * sends: a reply that is not the engine's can hold anything. Empty when `detail`
174
+ * is not an object, as for the plain sentence the engine sends for a missing or
175
+ * rejected token.
176
+ */
177
+ export declare function readErrorDetail(responseBody: unknown): ErrorDetail;
178
+ /** An action the user ran or turned down, as the engine keeps it: never the values it was given. */
179
+ export interface ActionRunEntry {
180
+ id: number;
181
+ actionName: string;
182
+ actionTitle: string;
183
+ /** `read` only changed what was shown, such as opening a page. */
184
+ actionMode: "read" | "write";
185
+ /** The names of the fields it was given. */
186
+ parameterNames: string[];
187
+ outcome: "done" | "failed" | "cancelled";
188
+ createdAt: string;
189
+ }
190
+ export interface ActionRunsPage {
191
+ /** Newest first. */
192
+ runs: ActionRunEntry[];
193
+ hasMore: boolean;
194
+ }
195
+ export interface ActionRunRecorded {
196
+ recorded: boolean;
197
+ id?: number;
198
+ }
199
+ export declare function isActionRunsPage(responseBody: unknown): responseBody is ActionRunsPage;
200
+ export declare function isActionRunRecorded(responseBody: unknown): responseBody is ActionRunRecorded;
201
+ export {};
@@ -0,0 +1,2 @@
1
+ /** Said when a prompt came back with nothing to change, nothing to do and nothing said. As the engine says it. */
2
+ export declare const NOTHING_UNDERSTOOD_MESSAGE = "I couldn't work out what to change. Could you say it another way?";
@@ -0,0 +1,12 @@
1
+ import type { ActionRunEntry } from "../engine/engineResponses.js";
2
+ /**
3
+ * For the prompt panel: the signed-in user's latest action runs on a screen, newest first, read from
4
+ * the engine: what they did, never with what values. Read again whenever
5
+ * `refreshKey` changes, such as after a run is recorded. Empty without an
6
+ * engine, or when it cannot be read: a past list is never worth an error.
7
+ */
8
+ export declare function useActionRunHistory(screenId: string, { enabled, limit, refreshKey }?: {
9
+ enabled?: boolean;
10
+ limit?: number;
11
+ refreshKey?: number;
12
+ }): readonly ActionRunEntry[];
@@ -0,0 +1,11 @@
1
+ import { type ActionDefinition } from "../actions/actionRegistry.js";
2
+ /**
3
+ * Offers an action while the calling component is mounted: something the
4
+ * application can do for its user when they ask, such as changing their name
5
+ * or opening a customer's record. The prompt panel then asks the planner for it
6
+ * when a request calls for it, asks the user to confirm a `write`, and calls
7
+ * `run`, which makes the request with the user's own sign-in.
8
+ *
9
+ * `run` and `confirm` may be new functions on every render: the latest are used.
10
+ */
11
+ export declare function useAdaptiveAction(definition: ActionDefinition): void;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Reads a region's manifest and layout and returns the functions that change it.
3
+ * Works anywhere inside `AdaptiveProvider`, including outside the region itself.
4
+ * Outside the provider it reads the region it sits in, or, outside that
5
+ * region too, an empty one of its own whose changes reach nothing on screen.
6
+ */
7
+ export declare function useAdaptiveRegion(regionId: string): {
8
+ manifest: import("../core/index.js").Manifest | null;
9
+ layout: import("../core/index.js").Layout | null;
10
+ preview: import("../core/index.js").Layout | null;
11
+ original: import("../core/index.js").Layout | null;
12
+ differsFromOriginal: boolean;
13
+ changedComponentIds: ReadonlySet<string>;
14
+ savedLayoutAdjustments: readonly import("../core/index.js").LayoutChange[];
15
+ loading: boolean;
16
+ loadFailed: boolean;
17
+ canUndo: boolean;
18
+ revision: number;
19
+ hasHistory: boolean;
20
+ hasUnsavedChanges: boolean;
21
+ applyOperations: (operations: readonly import("../core/index.js").Operation[], prompt?: string, message?: string, viaVoice?: boolean) => Promise<import("../core/index.js").ApplyOperationsOutcome>;
22
+ previewOperations: (operations: readonly import("../core/index.js").Operation[], prompt?: string, message?: string, viaVoice?: boolean) => import("../core/index.js").ApplyOperationsOutcome;
23
+ commitPreview: () => Promise<import("../core/index.js").ApplyOperationsOutcome | null>;
24
+ cancelPreview: () => void;
25
+ discardPreview: () => void;
26
+ undoLastChange: () => Promise<import("../index.js").UndoResult>;
27
+ planFromPrompt: (prompt: string, viaVoice?: boolean) => Promise<import("../engine/engineResponses.js").PlanResponse>;
28
+ restoreRevision: (revision: number) => Promise<number>;
29
+ readHistory: (options: {
30
+ limit: number;
31
+ before?: number;
32
+ promptedOnly?: boolean;
33
+ }) => Promise<import("../engine/engineResponses.js").HistoryPage>;
34
+ };
@@ -0,0 +1,32 @@
1
+ import type { Manifest } from "../core/index.js";
2
+ import type { HistoryEntry } from "../engine/engineResponses.js";
3
+ export interface ChangeHistoryOptions {
4
+ /** How many entries to hold at first, and to load each time. Default 5. */
5
+ pageSize?: number;
6
+ /**
7
+ * `prompts` (the default) lists only changes the user asked for in words,
8
+ * which reads as a conversation. `all` also lists changes made with the
9
+ * application's own controls, undos and restores.
10
+ */
11
+ include?: "prompts" | "all";
12
+ }
13
+ /**
14
+ * A user's saved changes to a region, oldest first so they read like a
15
+ * conversation. Holds the latest page and loads earlier ones on request.
16
+ *
17
+ * Given several region ids, it is the history of them all as one list. A
18
+ * change that reached more than one region is one entry, whose `revision` is
19
+ * the number of the change as a whole and whose `regions` says what it did in each.
20
+ */
21
+ export declare function useChangeHistory(regionId: string | readonly string[], historyOptions?: ChangeHistoryOptions): {
22
+ entries: HistoryEntry[];
23
+ loading: boolean;
24
+ error: string | null;
25
+ hasEarlier: boolean;
26
+ loadEarlier: () => void;
27
+ };
28
+ /**
29
+ * A short description of a change made without a prompt, for a history that
30
+ * includes them. An entry in a form it does not know is described in general terms.
31
+ */
32
+ export declare function describeHistoryEntry(entry: Pick<HistoryEntry, "kind" | "operations">, manifest: Manifest | null): string;
@@ -0,0 +1,50 @@
1
+ /**
2
+ * `starting` is the wait for the browser to hand over the microphone, which
3
+ * the first time includes asking the user for permission.
4
+ */
5
+ export type DictationStatus = "idle" | "starting" | "recording" | "transcribing";
6
+ export interface DictationOptions {
7
+ /**
8
+ * Called with everything made out of the current recording so far. `isFinal`
9
+ * is true on the last call for a recording. Today there is one call per
10
+ * recording; a caller that replaces what the previous call gave it will keep
11
+ * working when text arrives while the user is still speaking.
12
+ */
13
+ onTranscript: (transcript: string, isFinal: boolean) => void;
14
+ /** Names likely to be spoken, such as the titles on the screen. */
15
+ vocabularyHints?: readonly string[];
16
+ /** A recording is ended for the user after this long. Default 60. */
17
+ maxSeconds?: number;
18
+ /** False puts off asking the engine whether it offers dictation. Default true. */
19
+ enabled?: boolean;
20
+ }
21
+ /** The name of the custom property that carries how loud the user is, from 0 to 1. */
22
+ export declare const SOUND_LEVEL_PROPERTY = "--clickless-dictation-level";
23
+ /**
24
+ * Records a spoken prompt and has the engine turn it into text, which it does
25
+ * by passing the recording to OpenAI's speech-to-text service. Use it to build
26
+ * your own microphone button, or render `PromptPanel` with `dictation`.
27
+ *
28
+ * Nothing is recorded until `start` is called, and the microphone is let go as
29
+ * soon as the recording ends. Must be rendered inside `AdaptiveProvider`.
30
+ */
31
+ export declare function useDictation(dictationOptions: DictationOptions): {
32
+ /** True when the engine offers dictation and this browser can record. False until both are known. */
33
+ available: boolean;
34
+ status: DictationStatus;
35
+ /** Whole seconds recorded so far. */
36
+ elapsedSeconds: number;
37
+ /** A sentence for the user about why the last recording gave no text, or null. */
38
+ error: string | null;
39
+ /** Puts the error away, as when the user starts typing instead. */
40
+ clearError: () => void;
41
+ start: () => Promise<void>;
42
+ stop: () => void;
43
+ cancel: () => void;
44
+ /**
45
+ * Give this to the element that shows the sound level, or one around it. While recording, its
46
+ * `--clickless-dictation-level` custom property is set to a number from 0
47
+ * (silence) to 1 (loud) several times a second.
48
+ */
49
+ soundLevelRef: (element: HTMLElement | null) => void;
50
+ };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * False while the engine cannot be reached, from the first request that finds
3
+ * it so until one gets an answer again. True with no engine, and on the server.
4
+ */
5
+ export declare function useEngineReachable(): boolean;