@opencode/plugin 0.0.0-dev-57 → 0.0.0-dev-64
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/dist/gui/context.d.ts +49 -1
- package/dist/gui/host-apis.d.ts +820 -4
- package/dist/gui/registries.d.ts +15 -2
- package/package.json +8 -8
package/dist/gui/context.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Accessor } from "solid-js";
|
|
2
2
|
import type { BaseContext, App, Cleanup, Contract, DeclaredStores, Ipc, IpcClient, IpcSpec, Live, Persisted, StoreDeclaration, Token, TokenValue } from "./core.js";
|
|
3
|
-
import type { Appearance, Desktop, Dialogs, Embeds, Keybinds, Layout, Links, Locale, Router, Screen, Servers, SessionRef, Sessions, Storage, System, Workspaces } from "./host-apis.js";
|
|
3
|
+
import type { Appearance, Attention, Commands, Desktop, Dialogs, Embeds, Keybinds, Layout, Links, Locale, Router, Screen, Servers, SessionRef, Sessions, Storage, System, Tabs, Toasts, Ui, Workspaces } from "./host-apis.js";
|
|
4
4
|
/**
|
|
5
5
|
* What every window entry gets. Contracts are provided and read at runtime: `ctx.provide` for your own, `ctx.use` for
|
|
6
6
|
* other plugins', `ctx.main` for your main process. The APIs the host always provides are properties, each created
|
|
@@ -120,6 +120,44 @@ export interface Context extends BaseContext {
|
|
|
120
120
|
* ```
|
|
121
121
|
*/
|
|
122
122
|
readonly dialogs: Dialogs;
|
|
123
|
+
/**
|
|
124
|
+
* Short messages in a corner of the window. A plugin's toasts close when it goes away.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```ts
|
|
128
|
+
* const saving = ctx.toast.show({ title: ctx.t("saving"), variant: "loading", persistent: true })
|
|
129
|
+
* await save()
|
|
130
|
+
* saving.dismiss()
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
readonly toast: Toasts;
|
|
134
|
+
/**
|
|
135
|
+
* The shell's tab strip: open, show, move and close session tabs.
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```ts
|
|
139
|
+
* const first = (key: string) => ctx.tabs.move(key, 0)
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
readonly tabs: Tabs;
|
|
143
|
+
/**
|
|
144
|
+
* System notifications and sounds that follow the user's notification settings, for when they look elsewhere.
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```ts
|
|
148
|
+
* void ctx.attention.notify({ title: ctx.t("tests.done"), session: { server: session.server.id, id: session.id } })
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
readonly attention: Attention;
|
|
152
|
+
/**
|
|
153
|
+
* Runs published plugin commands and the app's own, as the command palette does.
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```ts
|
|
157
|
+
* if (!ctx.commands.run("terminal.toggle")) ctx.toast.show({ title: ctx.t("terminal.unavailable") })
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
readonly commands: Commands;
|
|
123
161
|
/**
|
|
124
162
|
* Routes local links to the plugins that handle them.
|
|
125
163
|
*
|
|
@@ -138,6 +176,16 @@ export interface Context extends BaseContext {
|
|
|
138
176
|
* ```
|
|
139
177
|
*/
|
|
140
178
|
readonly embeds: Embeds;
|
|
179
|
+
/**
|
|
180
|
+
* The app's own components: icons, buttons, tooltips, menus, the loading indicator, the dialog frame, switches,
|
|
181
|
+
* text fields, keybind chips, Markdown and highlighted code.
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```tsx
|
|
185
|
+
* <ctx.ui.Button icon="check" onClick={apply}>{ctx.t("apply")}</ctx.ui.Button>
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
readonly ui: Ui;
|
|
141
189
|
/**
|
|
142
190
|
* The running app: its version, release channel and platform, as `ctx.app` in server and TUI plugins.
|
|
143
191
|
*
|
package/dist/gui/host-apis.d.ts
CHANGED
|
@@ -491,10 +491,77 @@ export interface ComposerQuote {
|
|
|
491
491
|
readonly subject: string;
|
|
492
492
|
};
|
|
493
493
|
}
|
|
494
|
-
/**
|
|
494
|
+
/** A model the composer sends a prompt with, as the model picker names it. */
|
|
495
|
+
export interface ComposerModel {
|
|
496
|
+
/** The provider's id, e.g. `anthropic`. */
|
|
497
|
+
providerID: string;
|
|
498
|
+
/** The model's id within its provider, e.g. `claude-sonnet-4-5`. */
|
|
499
|
+
modelID: string;
|
|
500
|
+
/** The model's variant, e.g. `high`. Undefined for the model's default. */
|
|
501
|
+
variant?: string;
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* The session screen's composer: the routed session's next prompt, with its text, its attached parts and the model it
|
|
505
|
+
* is sent with. Nothing here sends the prompt; the user does. A write to the draft (`insert`, `setText`, `attach`,
|
|
506
|
+
* `update`, `detach`) made before the session's stored draft loads waits for it, then applies to the session routed
|
|
507
|
+
* when it was made, in call order with the other draft writes; the stored draft is never replaced.
|
|
508
|
+
*/
|
|
495
509
|
export interface Composer {
|
|
496
510
|
/**
|
|
497
|
-
*
|
|
511
|
+
* The prompt's text, as plain text: a mention reads as its `@` text, and attachments and attached parts are left
|
|
512
|
+
* out. In shell mode, the shell command. Empty until the session's draft loads, and in a subagent's session, which
|
|
513
|
+
* has no composer. Reactive.
|
|
514
|
+
*
|
|
515
|
+
* @example
|
|
516
|
+
* const empty = () => screen.composer.text().trim() === ""
|
|
517
|
+
*/
|
|
518
|
+
text(): string;
|
|
519
|
+
/**
|
|
520
|
+
* Inserts plain text into the prompt as typing would, at the cursor the user last left in it, else at the end, and
|
|
521
|
+
* moves the cursor after it. Selected text is not replaced. The text is not parsed: `@path` stays text rather than a
|
|
522
|
+
* mention, and line breaks stay line breaks. Focus stays where it is; call `focus` to move it. Before the session's
|
|
523
|
+
* draft loads, it waits and applies in call order. Does nothing in a subagent's session, which has no composer, or
|
|
524
|
+
* for empty text.
|
|
525
|
+
*
|
|
526
|
+
* @param text - The text to insert.
|
|
527
|
+
*
|
|
528
|
+
* @example
|
|
529
|
+
* screen.composer.insert(`Explain ${path}`)
|
|
530
|
+
*/
|
|
531
|
+
insert(text: string): void;
|
|
532
|
+
/**
|
|
533
|
+
* Replaces the prompt's text, mentions included, and moves the cursor to the end. Attachments and attached parts
|
|
534
|
+
* stay. Before the session's draft loads, it waits and applies in call order. Does nothing in a subagent's session,
|
|
535
|
+
* which has no composer.
|
|
536
|
+
*
|
|
537
|
+
* @param text - The new text. Empty clears the text.
|
|
538
|
+
*/
|
|
539
|
+
setText(text: string): void;
|
|
540
|
+
/**
|
|
541
|
+
* The model the next prompt is sent with: the user's choice for the routed session, else the session's agent
|
|
542
|
+
* default, else the app's default. Undefined while the model catalog loads, when no connected provider offers the
|
|
543
|
+
* choice, and in a subagent's session, which has no composer. Reactive.
|
|
544
|
+
*/
|
|
545
|
+
model(): ComposerModel | undefined;
|
|
546
|
+
/**
|
|
547
|
+
* Selects the model for the routed session's next prompts, as picking it in the model picker does: it becomes the
|
|
548
|
+
* session's choice and the first recent model. Without `variant`, the model keeps the variant the picker would show
|
|
549
|
+
* for it. Returns false, and changes nothing, while the model catalog loads, when no connected provider offers the
|
|
550
|
+
* model, when the model has no such variant, and in a subagent's session.
|
|
551
|
+
*
|
|
552
|
+
* @param model - The model, and optionally its variant.
|
|
553
|
+
*/
|
|
554
|
+
setModel(model: ComposerModel): boolean;
|
|
555
|
+
/**
|
|
556
|
+
* Selects a variant of the current model, as the composer's variant control does. Returns false, and changes
|
|
557
|
+
* nothing, when there is no current model, when the model has no such variant, and in a subagent's session.
|
|
558
|
+
*
|
|
559
|
+
* @param variant - The variant. Undefined selects the model's default.
|
|
560
|
+
*/
|
|
561
|
+
setVariant(variant: string | undefined): boolean;
|
|
562
|
+
/**
|
|
563
|
+
* Attaches a file, a note or a quote to the next prompt. Focus stays where it is; call `focus` to move it. Before
|
|
564
|
+
* the session's draft loads, it waits and applies in call order.
|
|
498
565
|
*
|
|
499
566
|
* @param part - The part to attach.
|
|
500
567
|
*/
|
|
@@ -516,7 +583,8 @@ export interface Composer {
|
|
|
516
583
|
*/
|
|
517
584
|
focus(commentID?: string): void;
|
|
518
585
|
/**
|
|
519
|
-
* Changes an attached part. Files, notes and quotes alike; a note or a quote takes only `comment`.
|
|
586
|
+
* Changes an attached part. Files, notes and quotes alike; a note or a quote takes only `comment`. Before the
|
|
587
|
+
* session's draft loads, it waits and applies in call order.
|
|
520
588
|
*
|
|
521
589
|
* @param id - The part's `commentID`.
|
|
522
590
|
* @param patch - The fields to change.
|
|
@@ -528,11 +596,18 @@ export interface Composer {
|
|
|
528
596
|
readonly preview?: string;
|
|
529
597
|
}): void;
|
|
530
598
|
/**
|
|
531
|
-
* Removes an attached part.
|
|
599
|
+
* Removes an attached part. Before the session's draft loads, it waits and applies in call order.
|
|
532
600
|
*
|
|
533
601
|
* @param id - The part's `commentID`.
|
|
534
602
|
*/
|
|
535
603
|
detach(id: string): void;
|
|
604
|
+
/**
|
|
605
|
+
* Whether keyboard focus is in the prompt now. Not reactive: read it where you act, such as in `Command.run`.
|
|
606
|
+
*
|
|
607
|
+
* @example
|
|
608
|
+
* run: () => (screen.composer.focused() ? send() : false)
|
|
609
|
+
*/
|
|
610
|
+
focused(): boolean;
|
|
536
611
|
}
|
|
537
612
|
/** Work the session moved to the background. */
|
|
538
613
|
export interface BackgroundTask {
|
|
@@ -929,6 +1004,31 @@ export interface Desktop {
|
|
|
929
1004
|
* @param app - The app's name.
|
|
930
1005
|
*/
|
|
931
1006
|
installed(app: string): Promise<boolean>;
|
|
1007
|
+
/**
|
|
1008
|
+
* Asks the user for files or folders with the system's open dialog. Desktop only: a browser never tells the page
|
|
1009
|
+
* where a picked file is.
|
|
1010
|
+
*
|
|
1011
|
+
* @param options - What to pick.
|
|
1012
|
+
* @returns The absolute paths the user picked, in the order the dialog reports them; empty when the user cancelled.
|
|
1013
|
+
* Rejects when the dialog cannot open.
|
|
1014
|
+
*
|
|
1015
|
+
* @example
|
|
1016
|
+
* ```ts
|
|
1017
|
+
* const [folder] = (await ctx.desktop?.pick({ directory: true, title: ctx.t("pick.folder") })) ?? []
|
|
1018
|
+
* ```
|
|
1019
|
+
*/
|
|
1020
|
+
pick(options?: PickOptions): Promise<readonly string[]>;
|
|
1021
|
+
}
|
|
1022
|
+
/** What `Desktop.pick` asks for. */
|
|
1023
|
+
export interface PickOptions {
|
|
1024
|
+
/** Picks folders instead of files. Defaults to false. */
|
|
1025
|
+
readonly directory?: boolean;
|
|
1026
|
+
/** Lets the user pick more than one. Defaults to false. */
|
|
1027
|
+
readonly multiple?: boolean;
|
|
1028
|
+
/** The dialog's title; the system's default title when omitted. Not every system shows it. */
|
|
1029
|
+
readonly title?: string;
|
|
1030
|
+
/** File extensions to offer, without the dot (e.g. `["json"]`); every file when omitted. Ignored for folders. */
|
|
1031
|
+
readonly extensions?: readonly string[];
|
|
932
1032
|
}
|
|
933
1033
|
/** The interface language and its writing direction. */
|
|
934
1034
|
export interface Locale {
|
|
@@ -949,6 +1049,18 @@ export interface Appearance {
|
|
|
949
1049
|
* @param kind - `mono`, the terminal font.
|
|
950
1050
|
*/
|
|
951
1051
|
font(kind: "mono"): string;
|
|
1052
|
+
/**
|
|
1053
|
+
* The color scheme the interface shows: the user's choice in Settings › Appearance, with "System" resolved to the
|
|
1054
|
+
* system's current scheme. Before the app interface mounts, the system's scheme. Reactive.
|
|
1055
|
+
* - `light`: dark text on light backgrounds.
|
|
1056
|
+
* - `dark`: light text on dark backgrounds.
|
|
1057
|
+
*
|
|
1058
|
+
* @example
|
|
1059
|
+
* ```ts
|
|
1060
|
+
* const background = () => (ctx.appearance.mode() === "dark" ? "#000" : "#fff")
|
|
1061
|
+
* ```
|
|
1062
|
+
*/
|
|
1063
|
+
mode(): "light" | "dark";
|
|
952
1064
|
}
|
|
953
1065
|
/** The app's route. */
|
|
954
1066
|
export interface Router {
|
|
@@ -1067,6 +1179,301 @@ export interface Dialogs {
|
|
|
1067
1179
|
}): DialogHandle;
|
|
1068
1180
|
/** Some dialog is open. Reactive. */
|
|
1069
1181
|
active(): boolean;
|
|
1182
|
+
/**
|
|
1183
|
+
* Asks the user to confirm an action, in the app's own confirmation dialog. Opens as `open` does, with the same
|
|
1184
|
+
* lifetime: it waits for the app interface, and closes with the owner that asked, else with the plugin.
|
|
1185
|
+
*
|
|
1186
|
+
* @param options - The question and its buttons.
|
|
1187
|
+
* @returns True only when the user chose the confirm button. False when they chose cancel, pressed Escape or clicked
|
|
1188
|
+
* outside, when another dialog replaced it, and when it closed or never opened because its owner or plugin went
|
|
1189
|
+
* away.
|
|
1190
|
+
*
|
|
1191
|
+
* @example
|
|
1192
|
+
* ```ts
|
|
1193
|
+
* if (await ctx.dialogs.confirm({ title: ctx.t("end.title"), confirm: ctx.t("end"), danger: true })) end()
|
|
1194
|
+
* ```
|
|
1195
|
+
*/
|
|
1196
|
+
confirm(options: ConfirmOptions): Promise<boolean>;
|
|
1197
|
+
/**
|
|
1198
|
+
* Tells the user something they must acknowledge, in a dialog with one button. Opens and closes as `confirm` does.
|
|
1199
|
+
*
|
|
1200
|
+
* @param options - What the dialog says.
|
|
1201
|
+
* @returns Resolves once the dialog closes, however it closes.
|
|
1202
|
+
*
|
|
1203
|
+
* @example
|
|
1204
|
+
* ```ts
|
|
1205
|
+
* await ctx.dialogs.alert({ title: ctx.t("export.done"), description: path })
|
|
1206
|
+
* ```
|
|
1207
|
+
*/
|
|
1208
|
+
alert(options: AlertOptions): Promise<void>;
|
|
1209
|
+
/**
|
|
1210
|
+
* Asks the user for a line of text, in the app's own dialog. Enter submits. Opens and closes as `confirm` does.
|
|
1211
|
+
*
|
|
1212
|
+
* @param options - The question, the field and its button.
|
|
1213
|
+
* @returns The text the user submits, which is never empty: the submit button and Enter do nothing while the field
|
|
1214
|
+
* is empty. Undefined when the user cancels, dismisses the dialog, or it closes with its owner.
|
|
1215
|
+
*
|
|
1216
|
+
* @example
|
|
1217
|
+
* ```ts
|
|
1218
|
+
* const invite = await ctx.dialogs.prompt({ title: ctx.t("join.title"), placeholder: "https://…" })
|
|
1219
|
+
* ```
|
|
1220
|
+
*/
|
|
1221
|
+
prompt(options: PromptOptions): Promise<string | undefined>;
|
|
1222
|
+
/**
|
|
1223
|
+
* Asks the user to pick one option from a searchable list, in the app's own dialog, as the command palette lists
|
|
1224
|
+
* commands. Opens and closes as `confirm` does.
|
|
1225
|
+
*
|
|
1226
|
+
* @param options - The title, the search field and the options.
|
|
1227
|
+
* @returns The picked option's `value`; undefined when the user dismisses the dialog or it closes with its owner.
|
|
1228
|
+
*
|
|
1229
|
+
* @example
|
|
1230
|
+
* ```ts
|
|
1231
|
+
* const url = await ctx.dialogs.select({ title: ctx.t("links"), options: links.map((url) => ({ title: url, value: url })) })
|
|
1232
|
+
* ```
|
|
1233
|
+
*/
|
|
1234
|
+
select<T>(options: SelectOptions<T>): Promise<T | undefined>;
|
|
1235
|
+
}
|
|
1236
|
+
/** What `Dialogs.confirm` asks. */
|
|
1237
|
+
export interface ConfirmOptions {
|
|
1238
|
+
/** The question, as the dialog's title. */
|
|
1239
|
+
readonly title: string;
|
|
1240
|
+
/** More detail under the title, such as what the action cannot undo. Omit it for none. */
|
|
1241
|
+
readonly description?: string;
|
|
1242
|
+
/** The confirm button's label. Defaults to the app's "Confirm". */
|
|
1243
|
+
readonly confirm?: string;
|
|
1244
|
+
/** The cancel button's label. Defaults to the app's "Cancel". */
|
|
1245
|
+
readonly cancel?: string;
|
|
1246
|
+
/**
|
|
1247
|
+
* Styles the confirm button as destructive, for an action that deletes or ends something, and starts focus on
|
|
1248
|
+
* Cancel. Defaults to false.
|
|
1249
|
+
*/
|
|
1250
|
+
readonly danger?: boolean;
|
|
1251
|
+
}
|
|
1252
|
+
/** What `Dialogs.alert` says. */
|
|
1253
|
+
export interface AlertOptions {
|
|
1254
|
+
/** The headline, as the dialog's title. */
|
|
1255
|
+
readonly title: string;
|
|
1256
|
+
/** More detail under the title. Omit it for none. */
|
|
1257
|
+
readonly description?: string;
|
|
1258
|
+
/** The button's label. Defaults to the app's "OK". */
|
|
1259
|
+
readonly ok?: string;
|
|
1260
|
+
}
|
|
1261
|
+
/** What `Dialogs.prompt` asks. */
|
|
1262
|
+
export interface PromptOptions {
|
|
1263
|
+
/** The question, as the dialog's title. */
|
|
1264
|
+
readonly title: string;
|
|
1265
|
+
/** More detail under the title. Omit it for none. */
|
|
1266
|
+
readonly description?: string;
|
|
1267
|
+
/** The field's placeholder. Omit it for none. */
|
|
1268
|
+
readonly placeholder?: string;
|
|
1269
|
+
/** The field's initial text, selected so typing replaces it. Defaults to "". */
|
|
1270
|
+
readonly value?: string;
|
|
1271
|
+
/**
|
|
1272
|
+
* Hides what the user types, for a password or a token. The host neither stores nor logs the value. Defaults to
|
|
1273
|
+
* false.
|
|
1274
|
+
*/
|
|
1275
|
+
readonly secret?: boolean;
|
|
1276
|
+
/** The submit button's label. Defaults to the app's "Submit". */
|
|
1277
|
+
readonly submit?: string;
|
|
1278
|
+
}
|
|
1279
|
+
/** One option of `Dialogs.select`. */
|
|
1280
|
+
export interface SelectOption<T> {
|
|
1281
|
+
/** The option's label; search matches it. */
|
|
1282
|
+
readonly title: string;
|
|
1283
|
+
/** What `select` resolves with when the user picks this option. */
|
|
1284
|
+
readonly value: T;
|
|
1285
|
+
/** A muted second line; search matches it too. Omit it for none. */
|
|
1286
|
+
readonly description?: string;
|
|
1287
|
+
/** The heading the option lists under. Options of one group list together, in the order first seen. */
|
|
1288
|
+
readonly group?: string;
|
|
1289
|
+
}
|
|
1290
|
+
/** What `Dialogs.select` asks. */
|
|
1291
|
+
export interface SelectOptions<T> {
|
|
1292
|
+
/** The dialog's title. */
|
|
1293
|
+
readonly title: string;
|
|
1294
|
+
/** The search field's placeholder. Defaults to the app's "Search". */
|
|
1295
|
+
readonly placeholder?: string;
|
|
1296
|
+
/** The options, in display order. */
|
|
1297
|
+
readonly options: readonly SelectOption<T>[];
|
|
1298
|
+
/** The value of the option to highlight first, compared with `===`. Defaults to the first option. */
|
|
1299
|
+
readonly current?: T;
|
|
1300
|
+
}
|
|
1301
|
+
/** A button on a toast. */
|
|
1302
|
+
export interface ToastAction {
|
|
1303
|
+
/** The button's label. */
|
|
1304
|
+
readonly label: string;
|
|
1305
|
+
/** Runs when the user clicks it; the toast then closes. A throw is logged to the console and the toast still closes. */
|
|
1306
|
+
run(): void;
|
|
1307
|
+
}
|
|
1308
|
+
/** What `Toasts.show` shows. */
|
|
1309
|
+
export interface ToastOptions {
|
|
1310
|
+
/** The headline. */
|
|
1311
|
+
readonly title: string;
|
|
1312
|
+
/** More detail under the title. Omit it for none. */
|
|
1313
|
+
readonly description?: string;
|
|
1314
|
+
/**
|
|
1315
|
+
* The toast's tone. Defaults to `default`.
|
|
1316
|
+
* - `default`: neutral information.
|
|
1317
|
+
* - `success`: something finished; shows a check icon unless `icon` is set.
|
|
1318
|
+
* - `error`: something failed.
|
|
1319
|
+
* - `loading`: something is in progress. Pair it with `persistent` and dismiss it when the work ends.
|
|
1320
|
+
*/
|
|
1321
|
+
readonly variant?: "default" | "success" | "error" | "loading";
|
|
1322
|
+
/** An icon before the title. Omit it for none, or the variant's own. */
|
|
1323
|
+
readonly icon?: IconName;
|
|
1324
|
+
/** Milliseconds before the toast closes itself. Ignored when `persistent` is true. Defaults to the app's 5 seconds. */
|
|
1325
|
+
readonly duration?: number;
|
|
1326
|
+
/** Stays until the user or `dismiss` closes it, instead of closing after `duration`. Defaults to false. */
|
|
1327
|
+
readonly persistent?: boolean;
|
|
1328
|
+
/** Buttons on the toast, in order. Omit it for none. */
|
|
1329
|
+
readonly actions?: readonly ToastAction[];
|
|
1330
|
+
}
|
|
1331
|
+
/** One toast `Toasts.show` showed. */
|
|
1332
|
+
export interface ToastHandle {
|
|
1333
|
+
/** Closes the toast. Does nothing once it closed. */
|
|
1334
|
+
dismiss(): void;
|
|
1335
|
+
}
|
|
1336
|
+
/**
|
|
1337
|
+
* The app's toasts: short messages in a corner of the window that do not take focus. Every toast of a plugin that is
|
|
1338
|
+
* still showing closes when the plugin goes away (disabled, reloaded or removed), so no button outlives the code it
|
|
1339
|
+
* runs; a toast does not close with the component or `createKeyed` run that showed it.
|
|
1340
|
+
*/
|
|
1341
|
+
export interface Toasts {
|
|
1342
|
+
/**
|
|
1343
|
+
* Shows a toast at once, also before the app interface mounts: it appears as soon as the window shows its toasts.
|
|
1344
|
+
* Showing a toast equal to one still showing (same title, description, variant, duration, persistence and action
|
|
1345
|
+
* labels) replaces that one instead of stacking a copy.
|
|
1346
|
+
*
|
|
1347
|
+
* @param options - What the toast shows.
|
|
1348
|
+
* @returns The toast's handle.
|
|
1349
|
+
*/
|
|
1350
|
+
show(options: ToastOptions): ToastHandle;
|
|
1351
|
+
}
|
|
1352
|
+
/** What `Attention.notify` sends. */
|
|
1353
|
+
export interface NotifyOptions {
|
|
1354
|
+
/** The notification's headline. */
|
|
1355
|
+
readonly title: string;
|
|
1356
|
+
/** The notification's body. Omit it for none. */
|
|
1357
|
+
readonly message?: string;
|
|
1358
|
+
/**
|
|
1359
|
+
* Which of the user's notification settings it follows, both the system notification and the sound. Defaults to
|
|
1360
|
+
* `default`.
|
|
1361
|
+
* - `default`: Settings › Notifications › Agent ("complete or needs attention") and its sound.
|
|
1362
|
+
* - `error`: Settings › Notifications › Errors and its sound.
|
|
1363
|
+
*/
|
|
1364
|
+
readonly variant?: "default" | "error";
|
|
1365
|
+
/** The session the notification is about: clicking the notification opens and shows it, as `Tabs.open` does. */
|
|
1366
|
+
readonly session?: {
|
|
1367
|
+
/** The server's `ServerRef.id`. */
|
|
1368
|
+
readonly server: string;
|
|
1369
|
+
/** The session's id on that server. */
|
|
1370
|
+
readonly id: string;
|
|
1371
|
+
};
|
|
1372
|
+
/** Plays the sound the user chose for `variant`, when its sound is on. False never plays one. Defaults to true. */
|
|
1373
|
+
readonly sound?: boolean;
|
|
1374
|
+
/**
|
|
1375
|
+
* Shows the notification and plays its sound at most once across the app's windows, each of which runs its own
|
|
1376
|
+
* instance of the plugin: the first window to send an id wins, and later sends with that id do nothing. Use an id
|
|
1377
|
+
* of the event, such as a run's id. Omit it to always notify.
|
|
1378
|
+
*/
|
|
1379
|
+
readonly id?: string;
|
|
1380
|
+
}
|
|
1381
|
+
/** What `Attention.notify` did. */
|
|
1382
|
+
export interface NotifyResult {
|
|
1383
|
+
/**
|
|
1384
|
+
* The app asked the system to show the notification. False when the user turned it off for `variant`, when one of
|
|
1385
|
+
* the app's windows has focus, or when another window already sent `id`. The system may still hide one it was
|
|
1386
|
+
* asked to show, for example when the user denied a browser's permission.
|
|
1387
|
+
*/
|
|
1388
|
+
readonly notification: boolean;
|
|
1389
|
+
/** The sound started. False when `sound` is false, the user turned it off for `variant`, or `id` was sent before. */
|
|
1390
|
+
readonly sound: boolean;
|
|
1391
|
+
}
|
|
1392
|
+
/** Gets the user's attention while they look elsewhere, with the same rules as the app's own notifications. */
|
|
1393
|
+
export interface Attention {
|
|
1394
|
+
/**
|
|
1395
|
+
* Sends a system notification while no window of the app has focus, and plays a sound, each only when the user's
|
|
1396
|
+
* notification settings for `variant` allow it. Clicking the notification brings the window forward and opens
|
|
1397
|
+
* `session`, when given. Before the app interface mounts, it waits for it.
|
|
1398
|
+
*
|
|
1399
|
+
* @param options - What to send.
|
|
1400
|
+
* @returns What it did; never rejects.
|
|
1401
|
+
*/
|
|
1402
|
+
notify(options: NotifyOptions): Promise<NotifyResult>;
|
|
1403
|
+
}
|
|
1404
|
+
/** The commands the app runs from its command palette, keybinds and slash menu. */
|
|
1405
|
+
export interface Commands {
|
|
1406
|
+
/**
|
|
1407
|
+
* Runs a command as choosing it in the command palette does: a published plugin command (`${plugin}.${id}`, any
|
|
1408
|
+
* plugin's) or one of the app's own. The app's command ids are not a stable API and may change between releases.
|
|
1409
|
+
* A command that is listed but disabled does not run. A command that runs async work is not awaited.
|
|
1410
|
+
*
|
|
1411
|
+
* @param id - The command's id.
|
|
1412
|
+
* @returns False when no enabled command has the id, and before the app interface mounts, when the app has
|
|
1413
|
+
* registered no commands yet.
|
|
1414
|
+
*/
|
|
1415
|
+
run(id: string): boolean;
|
|
1416
|
+
}
|
|
1417
|
+
/** One tab of the shell's tab strip. */
|
|
1418
|
+
export interface ShellTab {
|
|
1419
|
+
/** The tab's key, `SessionRef.tab` for a session's tab. Stays the same while the tab is open. */
|
|
1420
|
+
readonly key: string;
|
|
1421
|
+
/** The session the tab shows; undefined for a draft. */
|
|
1422
|
+
readonly session: SessionRef | undefined;
|
|
1423
|
+
/** The tab is the one on screen. */
|
|
1424
|
+
readonly active: boolean;
|
|
1425
|
+
}
|
|
1426
|
+
/**
|
|
1427
|
+
* The shell's tab strip: the sessions and drafts open as tabs. Nothing throws before the app interface mounts:
|
|
1428
|
+
* `list` is empty, and writes wait and apply in call order once it mounts.
|
|
1429
|
+
*/
|
|
1430
|
+
export interface Tabs {
|
|
1431
|
+
/** The open tabs, in strip order. Reactive. */
|
|
1432
|
+
list(): readonly ShellTab[];
|
|
1433
|
+
/**
|
|
1434
|
+
* Opens a session as a tab at the end of the strip, or keeps its open tab where it is. A tab that shows the session
|
|
1435
|
+
* already, such as a subagent opened from its parent's tab, is its tab. Does nothing when the app does not list the
|
|
1436
|
+
* server. A session id the server does not know still opens a tab, which shows the app's "session not found" page.
|
|
1437
|
+
*
|
|
1438
|
+
* @param session - The session's server and id.
|
|
1439
|
+
* @param options - Whether to show the tab.
|
|
1440
|
+
*
|
|
1441
|
+
* @example
|
|
1442
|
+
* ```ts
|
|
1443
|
+
* ctx.tabs.open({ server: session.server.id, id: session.id }, { focus: true })
|
|
1444
|
+
* ```
|
|
1445
|
+
*/
|
|
1446
|
+
open(session: {
|
|
1447
|
+
/** The server's `ServerRef.id`. */
|
|
1448
|
+
readonly server: string;
|
|
1449
|
+
/** The session's id on that server. */
|
|
1450
|
+
readonly id: string;
|
|
1451
|
+
}, options?: {
|
|
1452
|
+
/**
|
|
1453
|
+
* Also shows the tab and the session in it, as clicking the session in the session list does. Defaults to
|
|
1454
|
+
* false: the tab opens in the background.
|
|
1455
|
+
*/
|
|
1456
|
+
readonly focus?: boolean;
|
|
1457
|
+
}): void;
|
|
1458
|
+
/**
|
|
1459
|
+
* Shows an open tab, as a click on it does. Does nothing when no open tab has the key.
|
|
1460
|
+
*
|
|
1461
|
+
* @param key - The tab's `ShellTab.key`.
|
|
1462
|
+
*/
|
|
1463
|
+
focus(key: string): void;
|
|
1464
|
+
/**
|
|
1465
|
+
* Moves an open tab to a place in the strip. Does nothing when no open tab has the key.
|
|
1466
|
+
*
|
|
1467
|
+
* @param key - The tab's `ShellTab.key`.
|
|
1468
|
+
* @param index - The tab's new place, from 0; clamped to the strip.
|
|
1469
|
+
*/
|
|
1470
|
+
move(key: string, index: number): void;
|
|
1471
|
+
/**
|
|
1472
|
+
* Closes an open tab, as the user does: it lists under recently closed tabs. Does nothing when no open tab has the key.
|
|
1473
|
+
*
|
|
1474
|
+
* @param key - The tab's `ShellTab.key`.
|
|
1475
|
+
*/
|
|
1476
|
+
close(key: string): void;
|
|
1070
1477
|
}
|
|
1071
1478
|
/** Props of `Embeds.View`. */
|
|
1072
1479
|
export interface EmbedProps {
|
|
@@ -1107,3 +1514,412 @@ export interface Embeds {
|
|
|
1107
1514
|
*/
|
|
1108
1515
|
capture(id: string): Promise<Uint8Array | undefined>;
|
|
1109
1516
|
}
|
|
1517
|
+
/** Props of `Ui.Icon`. */
|
|
1518
|
+
export interface UiIconProps {
|
|
1519
|
+
/** The artwork, by its name in the app's icon catalog. */
|
|
1520
|
+
readonly name: IconName;
|
|
1521
|
+
/**
|
|
1522
|
+
* The icon's size. Defaults to `normal`.
|
|
1523
|
+
* - `small`: 14px.
|
|
1524
|
+
* - `normal`: 16px.
|
|
1525
|
+
* - `large`: 20px.
|
|
1526
|
+
*/
|
|
1527
|
+
readonly size?: "small" | "normal" | "large";
|
|
1528
|
+
/** Classes of the `svg`, for layout and color: the icon draws in `currentColor`. */
|
|
1529
|
+
readonly class?: string;
|
|
1530
|
+
}
|
|
1531
|
+
/** Props of `Ui.Button`. */
|
|
1532
|
+
export interface UiButtonProps {
|
|
1533
|
+
/** The button's text. */
|
|
1534
|
+
readonly children: JSX.Element;
|
|
1535
|
+
/** Runs when the user clicks the button, or presses Enter or Space on it. Not called while it is disabled or busy. */
|
|
1536
|
+
readonly onClick?: (event: MouseEvent) => void;
|
|
1537
|
+
/**
|
|
1538
|
+
* How the button looks. Defaults to `neutral`.
|
|
1539
|
+
* - `neutral`: a bordered button for most actions.
|
|
1540
|
+
* - `contrast`: the main action of a dialog or form.
|
|
1541
|
+
* - `ghost`: no border or background until hovered, for toolbars.
|
|
1542
|
+
* - `ghost-muted`: like `ghost`, with muted text, for secondary toolbar actions.
|
|
1543
|
+
* - `danger`: an action that deletes or discards.
|
|
1544
|
+
*/
|
|
1545
|
+
readonly variant?: "neutral" | "contrast" | "ghost" | "ghost-muted" | "danger";
|
|
1546
|
+
/**
|
|
1547
|
+
* The button's height. Defaults to `normal`.
|
|
1548
|
+
* - `small`: for dense rows.
|
|
1549
|
+
* - `normal`: for most places.
|
|
1550
|
+
* - `large`: for toolbars that use large icon buttons.
|
|
1551
|
+
*/
|
|
1552
|
+
readonly size?: "small" | "normal" | "large";
|
|
1553
|
+
/** An icon before the text. Omit it for none. */
|
|
1554
|
+
readonly icon?: IconName;
|
|
1555
|
+
/** The button cannot be clicked. Defaults to false. */
|
|
1556
|
+
readonly disabled?: boolean;
|
|
1557
|
+
/**
|
|
1558
|
+
* The action is running: a loading indicator replaces the icon, and the button cannot be clicked until it is false
|
|
1559
|
+
* again. Defaults to false.
|
|
1560
|
+
*/
|
|
1561
|
+
readonly busy?: boolean;
|
|
1562
|
+
/** `submit` submits the form the button is in. Defaults to `button`. */
|
|
1563
|
+
readonly type?: "button" | "submit";
|
|
1564
|
+
/** Takes focus when its dialog opens, as the app's own dialogs focus their main button. Defaults to false. */
|
|
1565
|
+
readonly autofocus?: boolean;
|
|
1566
|
+
/** Classes of the button, for layout. The app's styles give it its look. */
|
|
1567
|
+
readonly class?: string;
|
|
1568
|
+
}
|
|
1569
|
+
/** Props of `Ui.IconButton`. */
|
|
1570
|
+
export interface UiIconButtonProps {
|
|
1571
|
+
/** The button's icon. */
|
|
1572
|
+
readonly icon: IconName;
|
|
1573
|
+
/** The button's accessible name, which screen readers announce. Pass translated copy; it is not shown. */
|
|
1574
|
+
readonly label: string;
|
|
1575
|
+
/** Runs when the user clicks the button, or presses Enter or Space on it. Not called while it is disabled or busy. */
|
|
1576
|
+
readonly onClick?: (event: MouseEvent) => void;
|
|
1577
|
+
/**
|
|
1578
|
+
* How the button looks. Defaults to `ghost-muted`.
|
|
1579
|
+
* - `neutral`: a bordered button.
|
|
1580
|
+
* - `ghost`: no border or background until hovered.
|
|
1581
|
+
* - `ghost-muted`: like `ghost`, with a muted icon, for toolbars.
|
|
1582
|
+
*/
|
|
1583
|
+
readonly variant?: "neutral" | "ghost" | "ghost-muted";
|
|
1584
|
+
/**
|
|
1585
|
+
* The button's size. Defaults to `normal`.
|
|
1586
|
+
* - `small`: for dense rows.
|
|
1587
|
+
* - `normal`: for most places.
|
|
1588
|
+
* - `large`: for panel toolbars.
|
|
1589
|
+
*/
|
|
1590
|
+
readonly size?: "small" | "normal" | "large";
|
|
1591
|
+
/** The button cannot be clicked. Defaults to false. */
|
|
1592
|
+
readonly disabled?: boolean;
|
|
1593
|
+
/** The button is a toggle that is on: it shows pressed and reports `aria-pressed`. Omit it for a plain button. */
|
|
1594
|
+
readonly pressed?: boolean;
|
|
1595
|
+
/**
|
|
1596
|
+
* The action is running: a loading indicator replaces the icon, and the button cannot be clicked until it is false
|
|
1597
|
+
* again. Defaults to false.
|
|
1598
|
+
*/
|
|
1599
|
+
readonly busy?: boolean;
|
|
1600
|
+
/** Classes of the button, for layout. The app's styles give it its look. */
|
|
1601
|
+
readonly class?: string;
|
|
1602
|
+
}
|
|
1603
|
+
/** Props of `Ui.Tooltip`. */
|
|
1604
|
+
export interface UiTooltipProps {
|
|
1605
|
+
/** What the tooltip shows: usually translated text. */
|
|
1606
|
+
readonly value: JSX.Element;
|
|
1607
|
+
/** Keys shown after `value`, such as `ctx.keybinds.keybind(command)`. Omit it, or pass an empty list, for none. */
|
|
1608
|
+
readonly keys?: readonly string[];
|
|
1609
|
+
/** Where the tooltip opens from the element. Defaults to `top`; it flips when there is no room. */
|
|
1610
|
+
readonly placement?: "top" | "bottom" | "left" | "right";
|
|
1611
|
+
/** The element that shows the tooltip while the pointer rests on it or it has keyboard focus. */
|
|
1612
|
+
readonly children: JSX.Element;
|
|
1613
|
+
}
|
|
1614
|
+
/** An action in `UiMenuProps.items`. */
|
|
1615
|
+
export interface UiMenuItem {
|
|
1616
|
+
/** Marks the entry as an action. Optional: an entry without `type` is an action. */
|
|
1617
|
+
readonly type?: "item";
|
|
1618
|
+
/** The action's text. */
|
|
1619
|
+
readonly label: string;
|
|
1620
|
+
/** An icon before the text. Omit it for none. */
|
|
1621
|
+
readonly icon?: IconName;
|
|
1622
|
+
/** Keys shown at the end of the row, such as `ctx.keybinds.keybind(command)`. Omit it for none. */
|
|
1623
|
+
readonly keys?: readonly string[];
|
|
1624
|
+
/** The action cannot be chosen. Defaults to false. */
|
|
1625
|
+
readonly disabled?: boolean;
|
|
1626
|
+
/** Runs when the user chooses the action; the menu then closes. */
|
|
1627
|
+
onSelect(): void;
|
|
1628
|
+
}
|
|
1629
|
+
/** A line between entries in `UiMenuProps.items`. */
|
|
1630
|
+
export interface UiMenuSeparator {
|
|
1631
|
+
/** Marks the entry as a separator. */
|
|
1632
|
+
readonly type: "separator";
|
|
1633
|
+
}
|
|
1634
|
+
/** Actions under a heading in `UiMenuProps.items`. */
|
|
1635
|
+
export interface UiMenuGroup {
|
|
1636
|
+
/** Marks the entry as a group. */
|
|
1637
|
+
readonly type: "group";
|
|
1638
|
+
/** The group's heading. */
|
|
1639
|
+
readonly label: string;
|
|
1640
|
+
/** The group's actions, in order. */
|
|
1641
|
+
readonly items: readonly UiMenuItem[];
|
|
1642
|
+
}
|
|
1643
|
+
/** One entry of `UiMenuProps.items`: an action, a separator, or a group of actions under a heading. */
|
|
1644
|
+
export type UiMenuEntry = UiMenuItem | UiMenuSeparator | UiMenuGroup;
|
|
1645
|
+
/** Props of `Ui.Menu`. */
|
|
1646
|
+
export interface UiMenuProps {
|
|
1647
|
+
/** The trigger's accessible name, and its text when `trigger` is `button`. Pass translated copy. */
|
|
1648
|
+
readonly label: string;
|
|
1649
|
+
/** The menu's entries, in order. */
|
|
1650
|
+
readonly items: readonly UiMenuEntry[];
|
|
1651
|
+
/**
|
|
1652
|
+
* The button that opens the menu. Defaults to `icon`.
|
|
1653
|
+
* - `icon`: an icon button, as `Ui.IconButton` with the `ghost-muted` look.
|
|
1654
|
+
* - `button`: a button that shows `label`, as `Ui.Button`.
|
|
1655
|
+
*/
|
|
1656
|
+
readonly trigger?: "icon" | "button";
|
|
1657
|
+
/** The trigger's icon. Defaults to the "more" dots for an `icon` trigger, and to no icon for a `button` trigger. */
|
|
1658
|
+
readonly icon?: IconName;
|
|
1659
|
+
/** Where the menu opens from the trigger. Defaults to `bottom-end`; it flips when there is no room. */
|
|
1660
|
+
readonly placement?: "bottom-start" | "bottom-end" | "top-start" | "top-end";
|
|
1661
|
+
/** The trigger cannot open the menu. Defaults to false. */
|
|
1662
|
+
readonly disabled?: boolean;
|
|
1663
|
+
}
|
|
1664
|
+
/** Props of `Ui.Loader`. */
|
|
1665
|
+
export interface UiLoaderProps {
|
|
1666
|
+
/**
|
|
1667
|
+
* The indicator's size. Defaults to `normal`.
|
|
1668
|
+
* - `small`: 14px, for buttons and dense rows.
|
|
1669
|
+
* - `normal`: 16px.
|
|
1670
|
+
* - `large`: 20px, for a pane that loads.
|
|
1671
|
+
*/
|
|
1672
|
+
readonly size?: "small" | "normal" | "large";
|
|
1673
|
+
/** Classes of the indicator, for layout and color. */
|
|
1674
|
+
readonly class?: string;
|
|
1675
|
+
}
|
|
1676
|
+
/** Props of `Ui.Dialog`. */
|
|
1677
|
+
export interface UiDialogProps {
|
|
1678
|
+
/** The dialog's title, which also names it for screen readers. */
|
|
1679
|
+
readonly title: string;
|
|
1680
|
+
/** Text under the title. Omit it for none. */
|
|
1681
|
+
readonly description?: string;
|
|
1682
|
+
/** The dialog's content, with the app's dialog padding. It scrolls when it is taller than the dialog. */
|
|
1683
|
+
readonly children?: JSX.Element;
|
|
1684
|
+
/** The dialog's buttons, aligned to the end of its last row. Omit it for none. */
|
|
1685
|
+
readonly footer?: JSX.Element;
|
|
1686
|
+
/**
|
|
1687
|
+
* The dialog's size. Defaults to `fit`.
|
|
1688
|
+
* - `fit`: 480px wide and as tall as its content.
|
|
1689
|
+
* - `normal`: 480 by 368px.
|
|
1690
|
+
* - `large`: 640 by 480px.
|
|
1691
|
+
* - `x-large`: up to 980 by 600px, smaller in a small window.
|
|
1692
|
+
*/
|
|
1693
|
+
readonly size?: "fit" | "normal" | "large" | "x-large";
|
|
1694
|
+
/**
|
|
1695
|
+
* Shows the close button in the header, labelled with the app's "Close". Escape and a click outside close the dialog
|
|
1696
|
+
* either way. Defaults to true.
|
|
1697
|
+
*/
|
|
1698
|
+
readonly closable?: boolean;
|
|
1699
|
+
}
|
|
1700
|
+
/** Props of `Ui.Switch`. */
|
|
1701
|
+
export interface UiSwitchProps {
|
|
1702
|
+
/** The switch is on. */
|
|
1703
|
+
readonly checked: boolean;
|
|
1704
|
+
/** Runs with the new state when the user flips the switch. Pass it on to `checked` to keep the switch in step. */
|
|
1705
|
+
readonly onChange: (checked: boolean) => void;
|
|
1706
|
+
/** The switch's label, which also names it for screen readers. Pass translated copy. */
|
|
1707
|
+
readonly label: string;
|
|
1708
|
+
/** Hides the label from view and keeps it for screen readers, for a row that shows its own text. Defaults to false. */
|
|
1709
|
+
readonly hideLabel?: boolean;
|
|
1710
|
+
/** Text under the label. Omit it for none. */
|
|
1711
|
+
readonly description?: string;
|
|
1712
|
+
/** The switch cannot be flipped. Defaults to false. */
|
|
1713
|
+
readonly disabled?: boolean;
|
|
1714
|
+
}
|
|
1715
|
+
/** Props of `Ui.TextInput`. */
|
|
1716
|
+
export interface UiTextInputProps {
|
|
1717
|
+
/** The field's text. */
|
|
1718
|
+
readonly value: string;
|
|
1719
|
+
/** Runs with the field's text on every edit. Pass it on to `value` to keep the field in step. */
|
|
1720
|
+
readonly onInput: (value: string) => void;
|
|
1721
|
+
/** The field's accessible name, which screen readers announce. Pass translated copy; it is not shown. */
|
|
1722
|
+
readonly label: string;
|
|
1723
|
+
/** Text the empty field shows. Omit it for none. */
|
|
1724
|
+
readonly placeholder?: string;
|
|
1725
|
+
/** Runs with the field's text when the user presses Enter, except while an input method composes text. */
|
|
1726
|
+
readonly onSubmit?: (value: string) => void;
|
|
1727
|
+
/**
|
|
1728
|
+
* What the field holds. Defaults to `text`.
|
|
1729
|
+
* - `text`: plain text.
|
|
1730
|
+
* - `password`: hidden text.
|
|
1731
|
+
* - `search`: a search query.
|
|
1732
|
+
* - `url`: a web address.
|
|
1733
|
+
*/
|
|
1734
|
+
readonly type?: "text" | "password" | "search" | "url";
|
|
1735
|
+
/**
|
|
1736
|
+
* The field's height. Defaults to `normal`.
|
|
1737
|
+
* - `normal`: 28px.
|
|
1738
|
+
* - `large`: 32px, as in dialogs.
|
|
1739
|
+
*/
|
|
1740
|
+
readonly size?: "normal" | "large";
|
|
1741
|
+
/** The field cannot be edited. Defaults to false. */
|
|
1742
|
+
readonly disabled?: boolean;
|
|
1743
|
+
/** Shows the field as invalid and reports `aria-invalid`. Defaults to false. */
|
|
1744
|
+
readonly invalid?: boolean;
|
|
1745
|
+
/** Takes focus when its dialog opens. Defaults to false. */
|
|
1746
|
+
readonly autofocus?: boolean;
|
|
1747
|
+
/** Classes of the field, for layout. The app's styles give it its look. */
|
|
1748
|
+
readonly class?: string;
|
|
1749
|
+
}
|
|
1750
|
+
/** Props of `Ui.Keybind`. */
|
|
1751
|
+
export interface UiKeybindProps {
|
|
1752
|
+
/** The keys, one chip each, as `Keybinds.keybind` and `Keybinds.keys` return them. Empty shows nothing. */
|
|
1753
|
+
readonly keys: readonly string[];
|
|
1754
|
+
/** Classes of the chips' row, for layout. */
|
|
1755
|
+
readonly class?: string;
|
|
1756
|
+
}
|
|
1757
|
+
/** Props of `Ui.Markdown`. */
|
|
1758
|
+
export interface UiMarkdownProps {
|
|
1759
|
+
/** The Markdown source. */
|
|
1760
|
+
readonly text: string;
|
|
1761
|
+
/** Classes of the rendered block, such as a text size. */
|
|
1762
|
+
readonly class?: string;
|
|
1763
|
+
}
|
|
1764
|
+
/** Props of `Ui.Code`. */
|
|
1765
|
+
export interface UiCodeProps {
|
|
1766
|
+
/** The code, shown as it is. */
|
|
1767
|
+
readonly content: string;
|
|
1768
|
+
/**
|
|
1769
|
+
* The language to highlight, by a highlighter id or a common alias (`ts`, `tsx`, `py`, `json`, `bash`). A language
|
|
1770
|
+
* the app cannot highlight shows plain text; `mermaid` draws the diagram, as the timeline does. Defaults to plain
|
|
1771
|
+
* text.
|
|
1772
|
+
*/
|
|
1773
|
+
readonly language?: string;
|
|
1774
|
+
/** Classes of the code block, for layout. */
|
|
1775
|
+
readonly class?: string;
|
|
1776
|
+
}
|
|
1777
|
+
/**
|
|
1778
|
+
* The app's own components, so a plugin's UI looks and behaves like the app's: the same buttons, menus, dialogs and
|
|
1779
|
+
* fields, in the user's theme, fonts and language. Each takes a small set of props the SDK keeps stable. A component
|
|
1780
|
+
* renders with the context of the plugin that renders it, and works in any of its contributions and dialogs.
|
|
1781
|
+
*/
|
|
1782
|
+
export interface Ui {
|
|
1783
|
+
/**
|
|
1784
|
+
* An icon from the app's catalog, the artwork every `icon` field of the SDK names.
|
|
1785
|
+
*
|
|
1786
|
+
* @param props - The icon and its size.
|
|
1787
|
+
*
|
|
1788
|
+
* @example
|
|
1789
|
+
* ```tsx
|
|
1790
|
+
* <ctx.ui.Icon name="branch" size="small" />
|
|
1791
|
+
* ```
|
|
1792
|
+
*/
|
|
1793
|
+
Icon(props: UiIconProps): JSX.Element;
|
|
1794
|
+
/**
|
|
1795
|
+
* A button with text.
|
|
1796
|
+
*
|
|
1797
|
+
* @param props - Its text, look and action.
|
|
1798
|
+
*
|
|
1799
|
+
* @example
|
|
1800
|
+
* ```tsx
|
|
1801
|
+
* <ctx.ui.Button variant="contrast" busy={saving()} onClick={save}>{ctx.t("save")}</ctx.ui.Button>
|
|
1802
|
+
* ```
|
|
1803
|
+
*/
|
|
1804
|
+
Button(props: UiButtonProps): JSX.Element;
|
|
1805
|
+
/**
|
|
1806
|
+
* A button that shows only an icon. Wrap it in `Tooltip` to show its label on hover.
|
|
1807
|
+
*
|
|
1808
|
+
* @param props - Its icon, accessible name and action.
|
|
1809
|
+
*
|
|
1810
|
+
* @example
|
|
1811
|
+
* ```tsx
|
|
1812
|
+
* <ctx.ui.IconButton icon="outline-rotate-clockwise" label={ctx.t("reload")} onClick={reload} />
|
|
1813
|
+
* ```
|
|
1814
|
+
*/
|
|
1815
|
+
IconButton(props: UiIconButtonProps): JSX.Element;
|
|
1816
|
+
/**
|
|
1817
|
+
* A tooltip on an element.
|
|
1818
|
+
*
|
|
1819
|
+
* @param props - What it shows, and the element.
|
|
1820
|
+
*
|
|
1821
|
+
* @example
|
|
1822
|
+
* ```tsx
|
|
1823
|
+
* <ctx.ui.Tooltip value={ctx.t("toggle")} keys={ctx.keybinds.keybind(`${ctx.id}.toggle`)}>
|
|
1824
|
+
* <ctx.ui.IconButton icon="sidebar" label={ctx.t("toggle")} onClick={toggle} />
|
|
1825
|
+
* </ctx.ui.Tooltip>
|
|
1826
|
+
* ```
|
|
1827
|
+
*/
|
|
1828
|
+
Tooltip(props: UiTooltipProps): JSX.Element;
|
|
1829
|
+
/**
|
|
1830
|
+
* A button that opens a menu of actions.
|
|
1831
|
+
*
|
|
1832
|
+
* @param props - The trigger and the entries.
|
|
1833
|
+
*
|
|
1834
|
+
* @example
|
|
1835
|
+
* ```tsx
|
|
1836
|
+
* <ctx.ui.Menu label={ctx.t("more")} items={[{ label: ctx.t("delete"), icon: "trash", onSelect: remove }]} />
|
|
1837
|
+
* ```
|
|
1838
|
+
*/
|
|
1839
|
+
Menu(props: UiMenuProps): JSX.Element;
|
|
1840
|
+
/**
|
|
1841
|
+
* The app's loading indicator, for anything that loads, connects or runs that is not the AI working.
|
|
1842
|
+
*
|
|
1843
|
+
* @param props - Its size.
|
|
1844
|
+
*
|
|
1845
|
+
* @example
|
|
1846
|
+
* ```tsx
|
|
1847
|
+
* <Show when={!loading()} fallback={<ctx.ui.Loader />}>{content()}</Show>
|
|
1848
|
+
* ```
|
|
1849
|
+
*/
|
|
1850
|
+
Loader(props: UiLoaderProps): JSX.Element;
|
|
1851
|
+
/**
|
|
1852
|
+
* The app's dialog frame: title, content and buttons. Render it from `ctx.dialogs.open`; it renders nothing useful
|
|
1853
|
+
* elsewhere.
|
|
1854
|
+
*
|
|
1855
|
+
* @param props - The title, content and buttons.
|
|
1856
|
+
*
|
|
1857
|
+
* @example
|
|
1858
|
+
* ```tsx
|
|
1859
|
+
* ctx.dialogs.open((dialog) => (
|
|
1860
|
+
* <ctx.ui.Dialog title={ctx.t("about")} footer={<ctx.ui.Button onClick={dialog.close}>{ctx.t("done")}</ctx.ui.Button>}>
|
|
1861
|
+
* {ctx.t("about.body")}
|
|
1862
|
+
* </ctx.ui.Dialog>
|
|
1863
|
+
* ))
|
|
1864
|
+
* ```
|
|
1865
|
+
*/
|
|
1866
|
+
Dialog(props: UiDialogProps): JSX.Element;
|
|
1867
|
+
/**
|
|
1868
|
+
* An on/off switch with a label.
|
|
1869
|
+
*
|
|
1870
|
+
* @param props - Its state, label and handler.
|
|
1871
|
+
*
|
|
1872
|
+
* @example
|
|
1873
|
+
* ```tsx
|
|
1874
|
+
* <ctx.ui.Switch label={ctx.t("wrap")} checked={wrap()} onChange={setWrap} />
|
|
1875
|
+
* ```
|
|
1876
|
+
*/
|
|
1877
|
+
Switch(props: UiSwitchProps): JSX.Element;
|
|
1878
|
+
/**
|
|
1879
|
+
* A one-line text field.
|
|
1880
|
+
*
|
|
1881
|
+
* @param props - Its text, accessible name and handlers.
|
|
1882
|
+
*
|
|
1883
|
+
* @example
|
|
1884
|
+
* ```tsx
|
|
1885
|
+
* <ctx.ui.TextInput label={ctx.t("name")} value={name()} onInput={setName} onSubmit={save} />
|
|
1886
|
+
* ```
|
|
1887
|
+
*/
|
|
1888
|
+
TextInput(props: UiTextInputProps): JSX.Element;
|
|
1889
|
+
/**
|
|
1890
|
+
* Keys shown as chips, as menus and tooltips show shortcuts.
|
|
1891
|
+
*
|
|
1892
|
+
* @param props - The keys.
|
|
1893
|
+
*
|
|
1894
|
+
* @example
|
|
1895
|
+
* ```tsx
|
|
1896
|
+
* <ctx.ui.Keybind keys={ctx.keybinds.keybind(`${ctx.id}.toggle`)} />
|
|
1897
|
+
* ```
|
|
1898
|
+
*/
|
|
1899
|
+
Keybind(props: UiKeybindProps): JSX.Element;
|
|
1900
|
+
/**
|
|
1901
|
+
* Markdown rendered as the timeline renders a message: headings, lists, tables, links, math and highlighted code
|
|
1902
|
+
* blocks with a copy button. On the session screen, links to local files open through the LinkHandler
|
|
1903
|
+
* contributions, as the timeline's do. Rendering is asynchronous: the block fills in shortly after it mounts.
|
|
1904
|
+
*
|
|
1905
|
+
* @param props - The Markdown source.
|
|
1906
|
+
*
|
|
1907
|
+
* @example
|
|
1908
|
+
* ```tsx
|
|
1909
|
+
* <ctx.ui.Markdown text={summary()} />
|
|
1910
|
+
* ```
|
|
1911
|
+
*/
|
|
1912
|
+
Markdown(props: UiMarkdownProps): JSX.Element;
|
|
1913
|
+
/**
|
|
1914
|
+
* A read-only code block, highlighted as the timeline highlights code, with a copy button. Highlighting is
|
|
1915
|
+
* asynchronous: the block fills in shortly after it mounts.
|
|
1916
|
+
*
|
|
1917
|
+
* @param props - The code and its language.
|
|
1918
|
+
*
|
|
1919
|
+
* @example
|
|
1920
|
+
* ```tsx
|
|
1921
|
+
* <ctx.ui.Code content={JSON.stringify(config, null, 2)} language="json" />
|
|
1922
|
+
* ```
|
|
1923
|
+
*/
|
|
1924
|
+
Code(props: UiCodeProps): JSX.Element;
|
|
1925
|
+
}
|
package/dist/gui/registries.d.ts
CHANGED
|
@@ -56,11 +56,19 @@ export interface Command {
|
|
|
56
56
|
*/
|
|
57
57
|
readonly editable?: true;
|
|
58
58
|
/**
|
|
59
|
-
* Runs the command from the palette, the keybind or the slash command.
|
|
59
|
+
* Runs the command from the palette, the keybind or the slash command. From the keybind, return `false`
|
|
60
|
+
* synchronously to decline the key: the event goes on to its target, as if the command had no keybind, e.g. Enter
|
|
61
|
+
* reaches the prompt. `false` from the palette or a slash command does nothing more.
|
|
60
62
|
*
|
|
61
63
|
* @param input - The slash command's arguments, when `slash.arguments` is set.
|
|
64
|
+
* @returns `false` to decline the key; anything else handles it.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* run: () => (ctx.screen.current()?.composer.focused() ? keepGoing() : false)
|
|
69
|
+
* ```
|
|
62
70
|
*/
|
|
63
|
-
run(input?: string): void | Promise<void>;
|
|
71
|
+
run(input?: string): void | false | Promise<void>;
|
|
64
72
|
}
|
|
65
73
|
/** The fields every `MenuItem` has, whichever menu it is in. */
|
|
66
74
|
interface MenuItemBase {
|
|
@@ -367,6 +375,11 @@ export interface SettingsPage {
|
|
|
367
375
|
* section.
|
|
368
376
|
*/
|
|
369
377
|
readonly section?: "general";
|
|
378
|
+
/**
|
|
379
|
+
* The nav group of a page. Omit it to list the page after the app's own pages, such as Shortcuts.
|
|
380
|
+
* - `about`: below About, in its group, for pages about the app itself such as release notes.
|
|
381
|
+
*/
|
|
382
|
+
readonly group?: "about";
|
|
370
383
|
/** Nav label of a page; search shows it as the section of every entry, except rows placed in a host `section`. */
|
|
371
384
|
readonly title: string;
|
|
372
385
|
/** The page's nav icon. */
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@opencode/plugin",
|
|
4
|
-
"version": "0.0.0-dev-
|
|
4
|
+
"version": "0.0.0-dev-64",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"scripts": {
|
|
@@ -78,15 +78,15 @@
|
|
|
78
78
|
],
|
|
79
79
|
"dependencies": {
|
|
80
80
|
"@ai-sdk/provider": "3.0.8",
|
|
81
|
-
"@opencode/ai": "0.0.0-dev-
|
|
82
|
-
"@opencode/client": "0.0.0-dev-
|
|
83
|
-
"@opencode/protocol": "0.0.0-dev-
|
|
84
|
-
"@opencode/schema": "0.0.0-dev-
|
|
85
|
-
"@opencode/util": "0.0.0-dev-
|
|
81
|
+
"@opencode/ai": "0.0.0-dev-64",
|
|
82
|
+
"@opencode/client": "0.0.0-dev-64",
|
|
83
|
+
"@opencode/protocol": "0.0.0-dev-64",
|
|
84
|
+
"@opencode/schema": "0.0.0-dev-64",
|
|
85
|
+
"@opencode/util": "0.0.0-dev-64",
|
|
86
86
|
"effect": "4.0.1"
|
|
87
87
|
},
|
|
88
88
|
"peerDependencies": {
|
|
89
|
-
"@opencode/theme": "0.0.0-dev-
|
|
89
|
+
"@opencode/theme": "0.0.0-dev-64",
|
|
90
90
|
"@opentui/core": "0.7.0",
|
|
91
91
|
"@opentui/solid": "0.7.0",
|
|
92
92
|
"electron": "*",
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
}
|
|
119
119
|
},
|
|
120
120
|
"devDependencies": {
|
|
121
|
-
"@opencode/theme": "0.0.0-dev-
|
|
121
|
+
"@opencode/theme": "0.0.0-dev-64",
|
|
122
122
|
"@opentui/core": "0.7.0",
|
|
123
123
|
"@opentui/solid": "0.7.0",
|
|
124
124
|
"@tsconfig/bun": "1.0.9",
|