@molecule/app-ide-panel-logic 1.3.1 → 1.4.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/README.md +285 -3
- package/dist/chatTimelineOrdering.d.ts +175 -1
- package/dist/chatTimelineOrdering.d.ts.map +1 -1
- package/dist/chatTimelineOrdering.js +192 -1
- package/dist/chatTimelineOrdering.js.map +1 -1
- package/dist/components/chat-card-event-utilities.d.ts +320 -0
- package/dist/components/chat-card-event-utilities.d.ts.map +1 -0
- package/dist/components/chat-card-event-utilities.js +198 -0
- package/dist/components/chat-card-event-utilities.js.map +1 -0
- package/dist/components/chat-card-style.d.ts +7 -1
- package/dist/components/chat-card-style.d.ts.map +1 -1
- package/dist/components/chat-card-style.js +8 -2
- package/dist/components/chat-card-style.js.map +1 -1
- package/dist/components/chat-composer-utilities.d.ts +472 -0
- package/dist/components/chat-composer-utilities.d.ts.map +1 -0
- package/dist/components/chat-composer-utilities.js +519 -0
- package/dist/components/chat-composer-utilities.js.map +1 -0
- package/dist/components/chat-dictation-controller.d.ts +376 -0
- package/dist/components/chat-dictation-controller.d.ts.map +1 -0
- package/dist/components/chat-dictation-controller.js +559 -0
- package/dist/components/chat-dictation-controller.js.map +1 -0
- package/dist/components/chat-effort-utilities.d.ts +24 -0
- package/dist/components/chat-effort-utilities.d.ts.map +1 -1
- package/dist/components/chat-effort-utilities.js +41 -0
- package/dist/components/chat-effort-utilities.js.map +1 -1
- package/dist/components/chat-format-utilities.d.ts +71 -0
- package/dist/components/chat-format-utilities.d.ts.map +1 -0
- package/dist/components/chat-format-utilities.js +192 -0
- package/dist/components/chat-format-utilities.js.map +1 -0
- package/dist/components/chat-models-utilities.d.ts +168 -0
- package/dist/components/chat-models-utilities.d.ts.map +1 -1
- package/dist/components/chat-models-utilities.js +253 -0
- package/dist/components/chat-models-utilities.js.map +1 -1
- package/dist/components/chat-settings-utilities.d.ts +153 -1
- package/dist/components/chat-settings-utilities.d.ts.map +1 -1
- package/dist/components/chat-settings-utilities.js +204 -1
- package/dist/components/chat-settings-utilities.js.map +1 -1
- package/dist/components/chat-stream-utilities.d.ts +165 -1
- package/dist/components/chat-stream-utilities.d.ts.map +1 -1
- package/dist/components/chat-stream-utilities.js +155 -1
- package/dist/components/chat-stream-utilities.js.map +1 -1
- package/dist/components/chat-tests-controller.d.ts +249 -0
- package/dist/components/chat-tests-controller.d.ts.map +1 -0
- package/dist/components/chat-tests-controller.js +504 -0
- package/dist/components/chat-tests-controller.js.map +1 -0
- package/dist/components/chat-timeline-utilities.d.ts +90 -0
- package/dist/components/chat-timeline-utilities.d.ts.map +1 -0
- package/dist/components/chat-timeline-utilities.js +71 -0
- package/dist/components/chat-timeline-utilities.js.map +1 -0
- package/dist/components/chat-ui-constants.d.ts +98 -0
- package/dist/components/chat-ui-constants.d.ts.map +1 -0
- package/dist/components/chat-ui-constants.js +146 -0
- package/dist/components/chat-ui-constants.js.map +1 -0
- package/dist/components/chat-undo-utilities.d.ts +47 -0
- package/dist/components/chat-undo-utilities.d.ts.map +1 -0
- package/dist/components/chat-undo-utilities.js +73 -0
- package/dist/components/chat-undo-utilities.js.map +1 -0
- package/dist/components/context-usage-utilities.d.ts +25 -3
- package/dist/components/context-usage-utilities.d.ts.map +1 -1
- package/dist/components/context-usage-utilities.js +42 -2
- package/dist/components/context-usage-utilities.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/panels.d.ts +6 -0
- package/dist/panels.d.ts.map +1 -1
- package/dist/panels.js +6 -0
- package/dist/panels.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Framework-neutral helpers of the IDE chat composer: the slash-command menu
|
|
3
|
+
* filter, the read-only viewer gate, the keyboard index wrap, the @-mention
|
|
4
|
+
* ranking and the `<file …>` block a mention inserts, the two persistence keys
|
|
5
|
+
* (unsent draft, active conversation), the `/explain` and `/lint` prompt
|
|
6
|
+
* builders with the limit-refusal parse the submit path reads, the pure
|
|
7
|
+
* classifier that fixes the order of `handleSubmit`'s checks, and the pure
|
|
8
|
+
* reducer behind the composer textarea's keydown handler (popup navigation,
|
|
9
|
+
* picks, Escape and the IME guard). Shared verbatim by every framework's chat
|
|
10
|
+
* panel, so the menu, the viewer rules, the mention picker, the typed commands
|
|
11
|
+
* and the keyboard behave the same in each.
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
import type { AppModelDefinition } from '@molecule/app-ai-models';
|
|
16
|
+
import type { CommandDef } from '../command-metadata.js';
|
|
17
|
+
import type { CommandMenu, EffortPicker, FileEntry, FilePicker, ModelPicker } from './chat-card-event-utilities.js';
|
|
18
|
+
import type { EffortCommand, EffortLevel, EffortMode, EffortOption } from './chat-effort-utilities.js';
|
|
19
|
+
import type { ModelMode, ServerModeDefaults } from './chat-model-mode-utilities.js';
|
|
20
|
+
import type { SoundEventType } from './chat-settings-utilities.js';
|
|
21
|
+
import type { ShareCommand } from './chat-share-utilities.js';
|
|
22
|
+
import type { TimestampsCommand } from './chat-timestamps-utilities.js';
|
|
23
|
+
/**
|
|
24
|
+
* The `sessionStorage` key the composer persists an unsent draft under, per
|
|
25
|
+
* project.
|
|
26
|
+
* @param projectId - The project the chat panel belongs to.
|
|
27
|
+
* @returns The draft storage key (`mol-chat-draft:<projectId>`).
|
|
28
|
+
*/
|
|
29
|
+
export declare function chatDraftStorageKey(projectId: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* The `localStorage` key the outer panel remembers the active conversation
|
|
32
|
+
* under, per project.
|
|
33
|
+
* @param projectId - The project the chat panel belongs to.
|
|
34
|
+
* @returns The conversation storage key (`mol-chat-conv:<projectId>`).
|
|
35
|
+
*/
|
|
36
|
+
export declare function chatConversationStorageKey(projectId: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Whether a read-only project VIEWER may run `command` — true only for a
|
|
39
|
+
* command flagged {@link CommandDef.viewerSafe} (a read, a view-only surface or
|
|
40
|
+
* a per-user preference). Everything else is default-DENIED: an unflagged or
|
|
41
|
+
* missing command is unavailable to viewers. Host side-channel commands are
|
|
42
|
+
* gated separately by `matchesSideChannelCommand`, which the callers OR in
|
|
43
|
+
* where a viewer may also message the team.
|
|
44
|
+
* @param command - The command definition, or `undefined` when the text named
|
|
45
|
+
* no registered command.
|
|
46
|
+
* @returns `true` when the command is viewer-safe, `false` otherwise.
|
|
47
|
+
*/
|
|
48
|
+
export declare function viewerCommandAllowed(command: CommandDef | undefined): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* The commands an open command menu lists: every command for a `showAll` menu
|
|
51
|
+
* (the slash-button toggle over existing text) or the ones whose label starts
|
|
52
|
+
* with the typed text; viewers see only the commands they can run (viewer-safe
|
|
53
|
+
* reads plus the team side channel); `/share` is listed only when the host
|
|
54
|
+
* allows sharing.
|
|
55
|
+
* @param commands - The command registry unioned with any host-provided commands.
|
|
56
|
+
* @param menu - The open command menu, or `null` when it is closed.
|
|
57
|
+
* @param canEdit - Whether the member may edit the project (`false` for a
|
|
58
|
+
* read-only viewer; `undefined` counts as an editor).
|
|
59
|
+
* @param shareAllowed - Whether the host allows managing share links.
|
|
60
|
+
* @returns The commands the menu shows, in registry order (`[]` when closed).
|
|
61
|
+
*/
|
|
62
|
+
export declare function filterCommandMenu(commands: readonly CommandDef[], menu: CommandMenu | null, canEdit: boolean | undefined, shareAllowed: boolean): CommandDef[];
|
|
63
|
+
/**
|
|
64
|
+
* Wrap-around index: Down from -1 → 0, Up from -1 → last, wraps at both ends.
|
|
65
|
+
* @param cur - The current index (-1 means no selection).
|
|
66
|
+
* @param delta - The direction to move (+1 down, -1 up).
|
|
67
|
+
* @param len - The total number of items.
|
|
68
|
+
* @returns The new wrapped index.
|
|
69
|
+
*/
|
|
70
|
+
export declare function wrapIdx(cur: number, delta: number, len: number): number;
|
|
71
|
+
/**
|
|
72
|
+
* Rank the @-mention picker's entries by the composer query: entries whose name
|
|
73
|
+
* contains the query (case-insensitive), with the active file first, then open
|
|
74
|
+
* tabs, then prefix matches, then the rest alphabetically — capped at the first
|
|
75
|
+
* fifteen rows.
|
|
76
|
+
* @param entries - The picker's file entries.
|
|
77
|
+
* @param query - The text typed after the `@`.
|
|
78
|
+
* @param activeFile - The editor's active file, if any (`null` when none).
|
|
79
|
+
* @param openTabs - The editor's open tab paths, if any.
|
|
80
|
+
* @returns The ranked, capped entries to show.
|
|
81
|
+
*/
|
|
82
|
+
export declare function rankFileMentionEntries(entries: readonly FileEntry[], query: string, activeFile: string | null | undefined, openTabs: readonly string[] | undefined): FileEntry[];
|
|
83
|
+
/**
|
|
84
|
+
* Build the `<file …>` block a chosen @-mention inserts into the outgoing
|
|
85
|
+
* message: the file's content in a language-tagged fence, or a placeholder when
|
|
86
|
+
* the sandbox could not read it. The caller joins it to any text already in the
|
|
87
|
+
* message with a blank line.
|
|
88
|
+
* @param displayPath - The path to annotate the block with (no leading `/`).
|
|
89
|
+
* @param extension - The file's extension, used as the fence language tag.
|
|
90
|
+
* @param content - The file's text, or `null` when it could not be read.
|
|
91
|
+
* @returns The message block.
|
|
92
|
+
*/
|
|
93
|
+
export declare function buildFileMentionBlock(displayPath: string, extension: string, content: string | null): string;
|
|
94
|
+
/**
|
|
95
|
+
* The prompt a `/explain` submit sends: the named target, or a default that
|
|
96
|
+
* asks about what the user just shared.
|
|
97
|
+
* @param target - The text after `/explain`, when any.
|
|
98
|
+
* @param hasAttachments - Whether @-mentioned files ride along with the send.
|
|
99
|
+
* @returns The message text to send.
|
|
100
|
+
*/
|
|
101
|
+
export declare function buildExplainPrompt(target: string | undefined, hasAttachments: boolean): string;
|
|
102
|
+
/**
|
|
103
|
+
* The prompt a `/lint` submit sends: lint the named path with `npm run lint --
|
|
104
|
+
* <args>`, or the whole project.
|
|
105
|
+
* @param args - The text after `/lint`, when any.
|
|
106
|
+
* @returns The message text to send.
|
|
107
|
+
*/
|
|
108
|
+
export declare function buildLintPrompt(args: string | undefined): string;
|
|
109
|
+
/** The backend's description of a usage-limit refusal, as a failed request carries it. */
|
|
110
|
+
export interface LimitRefusal {
|
|
111
|
+
/** The backend's human-readable refusal message, when it sent one. */
|
|
112
|
+
error?: string;
|
|
113
|
+
/** Which limit fired (`max_tool_loops`, `daily`, …). */
|
|
114
|
+
limitType: string;
|
|
115
|
+
/** True when the refusal is really "sign up" (e.g. an anonymous visitor). */
|
|
116
|
+
requiresSignup?: boolean;
|
|
117
|
+
/** The remedy the backend resolved (e.g. a billing action). */
|
|
118
|
+
billingAction?: string;
|
|
119
|
+
/** The higher plan that lifts the limit, or `null` when none does. */
|
|
120
|
+
upgradeTier?: string | null;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Parse a failed request's usage-limit refusal out of its response body. The
|
|
124
|
+
* backend describes a refusal as `{ error, limitType, requiresSignup?,
|
|
125
|
+
* billingAction?, upgradeTier? }`; anything else (a network failure, a plain
|
|
126
|
+
* message error) is not a limit refusal.
|
|
127
|
+
* @param error - The caught error value.
|
|
128
|
+
* @returns The refusal, or `null` when the error carries none.
|
|
129
|
+
*/
|
|
130
|
+
export declare function limitRefusalFromError(error: unknown): LimitRefusal | null;
|
|
131
|
+
/** What `handleSubmit` knows before it decides which path a submit takes. */
|
|
132
|
+
export interface ComposerSubmitState {
|
|
133
|
+
/** True when the member may only read the transcript (no edit, no team chat). */
|
|
134
|
+
transcriptOnly: boolean;
|
|
135
|
+
/** How many files are attached in the composer right now. */
|
|
136
|
+
attachedCount: number;
|
|
137
|
+
/** Whether the member may edit the project (`undefined` takes the viewer path). */
|
|
138
|
+
canEdit: boolean | undefined;
|
|
139
|
+
/** Whether team side-channel messages are allowed in this workspace. */
|
|
140
|
+
canSendTeamMessages: boolean;
|
|
141
|
+
/** The command registry unioned with host commands, as the menu sees it. */
|
|
142
|
+
allCommands: readonly CommandDef[];
|
|
143
|
+
/** The host's extra commands (the team-message gate reads them with the registry). */
|
|
144
|
+
extraCommands: readonly CommandDef[] | undefined;
|
|
145
|
+
/**
|
|
146
|
+
* Reads whether the tests status bar is currently visible — the `/test
|
|
147
|
+
* on|off` base. Called only when the submit is the tests-bar command, so a
|
|
148
|
+
* plain submit never touches the preference storage.
|
|
149
|
+
*/
|
|
150
|
+
readTestsBarVisible: () => boolean;
|
|
151
|
+
}
|
|
152
|
+
/** The path a composer submit takes, as `routeComposerSubmit` classifies it. */
|
|
153
|
+
export type ComposerSubmitRoute =
|
|
154
|
+
/** The submit is ignored: a transcript-only member, or nothing to send. */
|
|
155
|
+
{
|
|
156
|
+
kind: 'ignored';
|
|
157
|
+
}
|
|
158
|
+
/** A team side-channel message while team messaging is unavailable. */
|
|
159
|
+
| {
|
|
160
|
+
kind: 'team-blocked';
|
|
161
|
+
}
|
|
162
|
+
/** A read-only viewer tried to run the assistant or a mutating command. */
|
|
163
|
+
| {
|
|
164
|
+
kind: 'viewer-blocked';
|
|
165
|
+
}
|
|
166
|
+
/** `/autofix` — toggles auto-fix through the command dispatcher. */
|
|
167
|
+
| {
|
|
168
|
+
kind: 'autofix';
|
|
169
|
+
}
|
|
170
|
+
/** `/autoapprove` — toggles auto-approve through the command dispatcher. */
|
|
171
|
+
| {
|
|
172
|
+
kind: 'autoapprove';
|
|
173
|
+
}
|
|
174
|
+
/** `/sounds` — opens the sounds picker. */
|
|
175
|
+
| {
|
|
176
|
+
kind: 'sounds';
|
|
177
|
+
}
|
|
178
|
+
/** `/test on|off|toggle` — sets the tests bar visibility. */
|
|
179
|
+
| {
|
|
180
|
+
kind: 'tests-bar';
|
|
181
|
+
visible: boolean;
|
|
182
|
+
}
|
|
183
|
+
/** `/timestamps` — a per-device timestamp display preference. */
|
|
184
|
+
| {
|
|
185
|
+
kind: 'timestamps';
|
|
186
|
+
command: TimestampsCommand;
|
|
187
|
+
}
|
|
188
|
+
/** `/settings` — opens the settings view through the command dispatcher. */
|
|
189
|
+
| {
|
|
190
|
+
kind: 'settings';
|
|
191
|
+
}
|
|
192
|
+
/** `/skills [query]` — opens the skills overlay, seeded with the query. */
|
|
193
|
+
| {
|
|
194
|
+
kind: 'skills';
|
|
195
|
+
query: string;
|
|
196
|
+
}
|
|
197
|
+
/** `/scripts [query]` — opens the scripts overlay, seeded with the query. */
|
|
198
|
+
| {
|
|
199
|
+
kind: 'scripts';
|
|
200
|
+
query: string;
|
|
201
|
+
}
|
|
202
|
+
/** `/test [query | all]` — opens the tests browser, or runs everything. */
|
|
203
|
+
| {
|
|
204
|
+
kind: 'tests';
|
|
205
|
+
query: string;
|
|
206
|
+
runAll: boolean;
|
|
207
|
+
}
|
|
208
|
+
/** `/run <name>` — runs a saved script (an empty name means usage). */
|
|
209
|
+
| {
|
|
210
|
+
kind: 'run-script';
|
|
211
|
+
name: string;
|
|
212
|
+
params: Record<string, string>;
|
|
213
|
+
}
|
|
214
|
+
/** `/report [title]` and `/bug [title]` — opens the bug-report modal. */
|
|
215
|
+
| {
|
|
216
|
+
kind: 'report';
|
|
217
|
+
title: string;
|
|
218
|
+
}
|
|
219
|
+
/** `/share [role]` — opens the share-link modal at the requested role. */
|
|
220
|
+
| {
|
|
221
|
+
kind: 'share';
|
|
222
|
+
command: ShareCommand;
|
|
223
|
+
}
|
|
224
|
+
/** `/autocommit <seconds>` — arms or cancels the auto-commit countdown. */
|
|
225
|
+
| {
|
|
226
|
+
kind: 'autocommit';
|
|
227
|
+
seconds: number | null;
|
|
228
|
+
}
|
|
229
|
+
/** `/model --plan|--execute|--commit|--compact` — opens the scoped picker. */
|
|
230
|
+
| {
|
|
231
|
+
kind: 'model-mode';
|
|
232
|
+
mode: ModelMode;
|
|
233
|
+
}
|
|
234
|
+
/** `/mic` and `/dictate` — opens the dictation engine picker. */
|
|
235
|
+
| {
|
|
236
|
+
kind: 'mic';
|
|
237
|
+
}
|
|
238
|
+
/** `/model [name]` — opens the picker, or resolves and selects a model. */
|
|
239
|
+
| {
|
|
240
|
+
kind: 'model';
|
|
241
|
+
query: string | undefined;
|
|
242
|
+
}
|
|
243
|
+
/** `/effort …` — opens the level picker, shows status, or sets a level. */
|
|
244
|
+
| {
|
|
245
|
+
kind: 'effort';
|
|
246
|
+
command: EffortCommand;
|
|
247
|
+
}
|
|
248
|
+
/** `/maxloops <N>` — persists the max tool iterations setting. */
|
|
249
|
+
| {
|
|
250
|
+
kind: 'max-loops';
|
|
251
|
+
loops: number;
|
|
252
|
+
}
|
|
253
|
+
/** `/explain` with no attachments — sends the built explain prompt. */
|
|
254
|
+
| {
|
|
255
|
+
kind: 'explain';
|
|
256
|
+
prompt: string;
|
|
257
|
+
}
|
|
258
|
+
/** `/lint` — sends the built lint prompt. */
|
|
259
|
+
| {
|
|
260
|
+
kind: 'lint';
|
|
261
|
+
prompt: string;
|
|
262
|
+
}
|
|
263
|
+
/** A host side-channel command — sends the raw text without a user bubble. */
|
|
264
|
+
| {
|
|
265
|
+
kind: 'side-channel';
|
|
266
|
+
message: string;
|
|
267
|
+
}
|
|
268
|
+
/** A plain message (an `/explain` with attachments is rewritten into one). */
|
|
269
|
+
| {
|
|
270
|
+
kind: 'send';
|
|
271
|
+
message: string;
|
|
272
|
+
};
|
|
273
|
+
/**
|
|
274
|
+
* Classify a composer submit into the one path it takes, fixing the order of
|
|
275
|
+
* `handleSubmit`'s checks: transcript-only and empty submits, the team-message
|
|
276
|
+
* gate, the read-only viewer gate, every locally-handled slash command, the
|
|
277
|
+
* side-channel send, and finally a plain message. Deterministic and
|
|
278
|
+
* side-effect free — the caller performs every side effect (`setInputValue`,
|
|
279
|
+
* `addSystemCard`, `sendMessage`, …) for the returned route — so the check
|
|
280
|
+
* order is identical in every framework's chat panel.
|
|
281
|
+
* @param input - The composer's raw text.
|
|
282
|
+
* @param state - The props and derived values the checks read.
|
|
283
|
+
* @returns The {@link ComposerSubmitRoute} the submit takes.
|
|
284
|
+
*/
|
|
285
|
+
export declare function routeComposerSubmit(input: string, state: ComposerSubmitState): ComposerSubmitRoute;
|
|
286
|
+
/**
|
|
287
|
+
* One keydown event's fields, as the composer's native keydown handler reads
|
|
288
|
+
* them — a structural subset of the DOM `KeyboardEvent`, so a test can pass a
|
|
289
|
+
* plain object.
|
|
290
|
+
*/
|
|
291
|
+
export interface ComposerKeyEvent {
|
|
292
|
+
/** The named key (`'Enter'`, `'Escape'`, `'ArrowDown'`, …). */
|
|
293
|
+
key: string;
|
|
294
|
+
/** True when Shift is held — Shift+Enter inserts a newline instead of submitting. */
|
|
295
|
+
shiftKey: boolean;
|
|
296
|
+
/** True while an IME composition is in progress. */
|
|
297
|
+
isComposing?: boolean;
|
|
298
|
+
/** The legacy key code — `229` marks an IME composition on some engines. */
|
|
299
|
+
keyCode?: number;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Everything the composer's keydown reducer reads: the open popups with the
|
|
303
|
+
* row lists they navigate, and the panel values the Enter branches decide with.
|
|
304
|
+
*/
|
|
305
|
+
export interface ComposerKeyState {
|
|
306
|
+
/** The composer textarea's current text (the effort Enter fallback parses it). */
|
|
307
|
+
input: string;
|
|
308
|
+
/** The open sounds picker, or `null`. */
|
|
309
|
+
soundsPicker: {
|
|
310
|
+
selectedIdx: number;
|
|
311
|
+
} | null;
|
|
312
|
+
/** Whether the dictation-engine picker is open. */
|
|
313
|
+
micOpen: boolean;
|
|
314
|
+
/** The open effort picker, or `null`. */
|
|
315
|
+
effortPicker: EffortPicker | null;
|
|
316
|
+
/** The effort picker's rows after the typed filter, in display order. */
|
|
317
|
+
effortPickerVisible: readonly EffortOption[];
|
|
318
|
+
/** The open model picker, or `null`. */
|
|
319
|
+
modelPicker: ModelPicker | null;
|
|
320
|
+
/** The model rows the picker lists, in display order. */
|
|
321
|
+
visibleModels: readonly AppModelDefinition[];
|
|
322
|
+
/** Whether the host offers the model picker's "manage your own models" row. */
|
|
323
|
+
hasManageCustomModels: boolean;
|
|
324
|
+
/** The live conversation mode (`'plan'` or `'execute'`). */
|
|
325
|
+
liveMode: EffortMode;
|
|
326
|
+
/** Whether a panel overlay (`/skills`, `/scripts`, `/settings`, `/tests`) is open. */
|
|
327
|
+
overlayOpen: boolean;
|
|
328
|
+
/** The open `@`-file picker, or `null`. */
|
|
329
|
+
filePicker: FilePicker | null;
|
|
330
|
+
/** The file picker's entries after the query filter, in display order. */
|
|
331
|
+
filteredEntries: readonly FileEntry[];
|
|
332
|
+
/** The open slash-command menu, or `null`. */
|
|
333
|
+
commandMenu: CommandMenu | null;
|
|
334
|
+
/** The command menu's entries after its filter, in display order. */
|
|
335
|
+
filteredCmds: readonly CommandDef[];
|
|
336
|
+
/** Whether a reply is streaming right now (Escape aborts it). */
|
|
337
|
+
abortable: boolean;
|
|
338
|
+
/** Whether the member is on the free tier (the model Enter lock reads it). */
|
|
339
|
+
isFreeTier: boolean;
|
|
340
|
+
/** The free-tier model's id, or `''` when the catalog did not name one. */
|
|
341
|
+
freeTierModelId: string;
|
|
342
|
+
/** The project's model catalog, custom (bring-your-own AI) models included. */
|
|
343
|
+
models: readonly AppModelDefinition[];
|
|
344
|
+
/** The server's per-mode default models, when it sent them. */
|
|
345
|
+
serverModelDefaults: ServerModeDefaults;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* The effect the composer's keydown handler performs for one key. The reducer
|
|
349
|
+
* returns it and the caller applies it, so the reducer itself touches no state.
|
|
350
|
+
*/
|
|
351
|
+
export type ComposerKeyEffect =
|
|
352
|
+
/** Nothing to do (a pick with no row, or a locked model). */
|
|
353
|
+
{
|
|
354
|
+
kind: 'none';
|
|
355
|
+
}
|
|
356
|
+
/** Escape: close the sounds picker. */
|
|
357
|
+
| {
|
|
358
|
+
kind: 'close-sounds';
|
|
359
|
+
}
|
|
360
|
+
/** Escape: close the dictation-engine picker. */
|
|
361
|
+
| {
|
|
362
|
+
kind: 'close-mic';
|
|
363
|
+
}
|
|
364
|
+
/** Escape: close the effort picker. */
|
|
365
|
+
| {
|
|
366
|
+
kind: 'close-effort';
|
|
367
|
+
}
|
|
368
|
+
/** Escape: close the model picker. */
|
|
369
|
+
| {
|
|
370
|
+
kind: 'close-model';
|
|
371
|
+
}
|
|
372
|
+
/** Escape: close the panel overlay. */
|
|
373
|
+
| {
|
|
374
|
+
kind: 'close-overlay';
|
|
375
|
+
}
|
|
376
|
+
/** Escape: close the `@`-file picker. */
|
|
377
|
+
| {
|
|
378
|
+
kind: 'close-file';
|
|
379
|
+
}
|
|
380
|
+
/** Escape: close the slash-command menu. */
|
|
381
|
+
| {
|
|
382
|
+
kind: 'close-command';
|
|
383
|
+
}
|
|
384
|
+
/** Escape: abort the streaming reply (same path as the Stop button). */
|
|
385
|
+
| {
|
|
386
|
+
kind: 'abort';
|
|
387
|
+
}
|
|
388
|
+
/** Move the sounds picker's highlight by one row (the caller wraps it). */
|
|
389
|
+
| {
|
|
390
|
+
kind: 'sounds-move';
|
|
391
|
+
delta: 1 | -1;
|
|
392
|
+
}
|
|
393
|
+
/** Apply the sounds picker's highlighted mode to one event (or all of them). */
|
|
394
|
+
| {
|
|
395
|
+
kind: 'sounds-pick';
|
|
396
|
+
event: SoundEventType | 'all';
|
|
397
|
+
}
|
|
398
|
+
/** Move the effort picker's highlight by one row (the caller wraps it). */
|
|
399
|
+
| {
|
|
400
|
+
kind: 'effort-move';
|
|
401
|
+
delta: 1 | -1;
|
|
402
|
+
}
|
|
403
|
+
/** Set the effort level for the picker's mode. */
|
|
404
|
+
| {
|
|
405
|
+
kind: 'effort-pick';
|
|
406
|
+
mode: EffortMode;
|
|
407
|
+
level: EffortLevel;
|
|
408
|
+
}
|
|
409
|
+
/** Move the model picker's highlight by one row (the caller wraps it). */
|
|
410
|
+
| {
|
|
411
|
+
kind: 'model-move';
|
|
412
|
+
delta: 1 | -1;
|
|
413
|
+
}
|
|
414
|
+
/** Open the host's custom-model manager for the picker's mode. */
|
|
415
|
+
| {
|
|
416
|
+
kind: 'model-manage';
|
|
417
|
+
mode: EffortMode;
|
|
418
|
+
}
|
|
419
|
+
/** Select the model row; `locked` means the free-tier clamp refuses it. */
|
|
420
|
+
| {
|
|
421
|
+
kind: 'model-pick';
|
|
422
|
+
model: AppModelDefinition;
|
|
423
|
+
mode?: ModelMode;
|
|
424
|
+
locked: boolean;
|
|
425
|
+
}
|
|
426
|
+
/** Move the `@`-file picker's highlight by one row (the caller wraps it). */
|
|
427
|
+
| {
|
|
428
|
+
kind: 'file-move';
|
|
429
|
+
delta: 1 | -1;
|
|
430
|
+
}
|
|
431
|
+
/** Attach the highlighted file entry. */
|
|
432
|
+
| {
|
|
433
|
+
kind: 'file-pick';
|
|
434
|
+
entry: FileEntry;
|
|
435
|
+
}
|
|
436
|
+
/** Move the command menu's highlight by one row (the caller wraps it). */
|
|
437
|
+
| {
|
|
438
|
+
kind: 'command-move';
|
|
439
|
+
delta: 1 | -1;
|
|
440
|
+
}
|
|
441
|
+
/** Close the command menu and submit the composer text as typed. */
|
|
442
|
+
| {
|
|
443
|
+
kind: 'command-dismiss-submit';
|
|
444
|
+
}
|
|
445
|
+
/** Run the command with this id. */
|
|
446
|
+
| {
|
|
447
|
+
kind: 'command-run';
|
|
448
|
+
id: string;
|
|
449
|
+
}
|
|
450
|
+
/** Submit the composer (a bare Enter). */
|
|
451
|
+
| {
|
|
452
|
+
kind: 'submit';
|
|
453
|
+
};
|
|
454
|
+
/** What `composerKeyAction` decides for one keydown. */
|
|
455
|
+
export interface ComposerKeyAction {
|
|
456
|
+
/** Whether the handler calls `event.preventDefault()` before applying the effect. */
|
|
457
|
+
preventDefault: boolean;
|
|
458
|
+
/** The effect the caller applies. */
|
|
459
|
+
effect: ComposerKeyEffect;
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Decide what the composer's keydown handler does for one key: the IME guard,
|
|
463
|
+
* Escape's close order (sounds, mic, effort, model, overlay, file, command,
|
|
464
|
+
* abort), the open picker's arrow/Enter/Tab navigation, and the bare Enter that
|
|
465
|
+
* submits. Pure and side-effect free — the caller performs every effect — so
|
|
466
|
+
* the key behavior is identical in every framework's chat panel.
|
|
467
|
+
* @param event - The keydown event's fields.
|
|
468
|
+
* @param state - The open popups and the panel values the decisions read.
|
|
469
|
+
* @returns The {@link ComposerKeyAction} to apply.
|
|
470
|
+
*/
|
|
471
|
+
export declare function composerKeyAction(event: ComposerKeyEvent, state: ComposerKeyState): ComposerKeyAction;
|
|
472
|
+
//# sourceMappingURL=chat-composer-utilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-composer-utilities.d.ts","sourceRoot":"","sources":["../../src/components/chat-composer-utilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAEjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAGxD,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,SAAS,EACT,UAAU,EACV,WAAW,EACZ,MAAM,gCAAgC,CAAA;AACvC,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EACX,UAAU,EACV,YAAY,EACb,MAAM,4BAA4B,CAAA;AAEnC,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AAInF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAElE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAE7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAKvE;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEpE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAE7E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EA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