@bridgebrew/shell 0.0.0-stage → 0.0.2

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.
@@ -0,0 +1,924 @@
1
+ // The shell's contract (E8), declared once for Bridge's own plugins: the `shell` service this plugin
2
+ // provides and the rail and the sidebar inject, the slots it declares, and the boot kernel's
3
+ // `workspaceEntries`, `hostStatus` and `screenRequests` that it injects and `sidebarMarks` and `sidebarItems` that
4
+ // the sidebar injects. Included by the
5
+ // browser type-check (tsconfig.pages.json); no plugin imports it (AD-8).
6
+ import type {} from 'cordis';
7
+ import type {} from '@bridge/ui-slots';
8
+ import type { ReactNode } from 'react';
9
+ import type { StatusStreamEvent, WorkspaceLook } from '@bridge/kernel/status';
10
+
11
+ /** `look`: its look as it shows for this user (research-018 slice 8, research-028): the workspace's proposal with the
12
+ * user's Mine for it laid over (appearance slice 3), when either sets anything. */
13
+ interface ShellWorkspace {
14
+ slug: string;
15
+ title: string;
16
+ /** A stage's workspace (research-083). */
17
+ parent?: string;
18
+ look?: WorkspaceLook;
19
+ state: string;
20
+ }
21
+ /** A screen's window rule, as its plugin's manifest declares it (research-018 W4, W6): the windows showing the items
22
+ * `item` matches (`null`: no item; `*`: any; `<path>/*`: those below `<path>`; else that one; absent: all) are of
23
+ * `kind` among the screen's windows (absent: the screen's own), and hold their size beside others when `keepSize`, at
24
+ * `width` px once windows come beside them (slice 6e; absent: the width they have then); may go in picture in picture
25
+ * when `pip` (slice 10). */
26
+ export interface ShellWindowRule {
27
+ item?: string | null;
28
+ kind?: string;
29
+ keepSize?: boolean;
30
+ width?: number;
31
+ pip?: boolean;
32
+ }
33
+ /** A screen; its children are screens of the same plugin. `windows`: how its windows sit, first rule matching wins.
34
+ * `mobile`: it has a phone variant (its plugin's `mobileScreen` entry), else a phone shows its desktop view. */
35
+ interface ShellNode {
36
+ id: string;
37
+ title: string;
38
+ icon?: string;
39
+ windows?: ShellWindowRule[];
40
+ mobile?: true;
41
+ /** A root screen saying `view: false`: shown only on the nodes that choose it (`chosenBlocks`). */
42
+ view?: false;
43
+ children?: ShellNode[];
44
+ }
45
+ /** An item a workspace plugin lists under its screens (`ctx.sidebar.items`); a child's id starts with its parent's id
46
+ * and `/`, at most three levels deep. */
47
+ interface ShellSidebarItem {
48
+ id: string;
49
+ title: string;
50
+ icon?: string;
51
+ count?: number;
52
+ badge?: string;
53
+ children?: ShellSidebarItem[];
54
+ }
55
+ /** One root screen's tree: `plugin` is its plugin's key (a plugin with several root screens has a block each, in order);
56
+ * its root id starts the screens' URLs. */
57
+ interface ShellBlock {
58
+ plugin: string;
59
+ screen: ShellNode;
60
+ /** Its plugin's screens are not views (`view: false` in its manifest): they open from a menu (Settings, Plugins). */
61
+ view?: false;
62
+ }
63
+ /** From `/_bridge/workspaces/<slug>/screens`: the blocks without a section, then the sections. */
64
+ interface ShellScreens {
65
+ root: ShellBlock[];
66
+ sections: { id: string; title: string; blocks: ShellBlock[] }[];
67
+ /** Every block's id (`<plugin>/<root screen id>`) as the host listed them, once root's sections arranged the lists:
68
+ * the plugins' order other nodes fall back on (`screenBlocks` of `@bridge/kernel/node-layout`). */
69
+ order?: string[];
70
+ }
71
+
72
+ /** A way around a workspace (research-035): the sidebar, the Start menu, a phone's menu. */
73
+ export interface ShellNavigator {
74
+ /** Its plugin key. */
75
+ id: string;
76
+ label: string;
77
+ }
78
+
79
+ /** A node of the current workspace's tree (AD-23), as `/_bridge/workspaces/<slug>/nodes` gives it. */
80
+ interface ShellTreeNode {
81
+ id: string;
82
+ parent: string | null;
83
+ title: string;
84
+ archived: boolean;
85
+ active: string[];
86
+ settings: Record<string, unknown>;
87
+ views?: string[];
88
+ home?: string;
89
+ /** Its blocks' order (research-067): `<plugin>/<root screen id>`, as the user placed them. */
90
+ layout?: string[];
91
+ /** Blocks of the plugins it shows that it does not (research-067). */
92
+ hidden?: string[];
93
+ /** `root` only (research-067): its sections, each with the blocks it holds, in order. */
94
+ sections?: { id: string; title: string; blocks: string[] }[];
95
+ }
96
+
97
+ /** `/_bridge/status/events` as the shell reads it, through the kernel's `hostStatus`: a snapshot first. */
98
+ export type HostStatusEvent = StatusStreamEvent;
99
+
100
+ /** What one window shows (research-018): a node, the screen chosen there and its item, or a utility screen over it. The
101
+ * shell's current view (`ShellState`'s `node`, `screen`, `item`, `utility`) is the focused window's. */
102
+ export interface ShellView {
103
+ node: string;
104
+ screen?: { plugin: string; id: string } | undefined;
105
+ item?: string | undefined;
106
+ utility?: { plugin: string; node: string; title: string } | undefined;
107
+ /** Research-090: the screen's own state in this window (a tab, a filter), a small flat map of strings the screen sets
108
+ * (`setScreenState`) and reads back when it mounts; saved with the window by its manager, in the URL's query for the
109
+ * focused window. Not part of a view's identity (P8). */
110
+ screenState?: Record<string, string> | undefined;
111
+ }
112
+
113
+ /** A window manager (research-018 WM3): a `_host` plugin fills `stage` and provides this. The shell calls it for every
114
+ * view it shows (its current view, the focused window's), after enforcing P8 itself: a view a window already shows is
115
+ * `focus`ed, never opened twice among the windows `list` gives (a manager with desks lists the desk shown: P8 holds per
116
+ * desk, owner, 11 October 2026). A manager that misses a function or throws is set aside for the page: the shell shows
117
+ * its own one window (C6). Its windows' ids are its own. */
118
+ /** Research-069: a view's state as the shell knows it (`viewState`). */
119
+ export type ViewState = 'editing' | 'reloading' | 'failed' | 'idle';
120
+ /** A window's view scope (`viewScope`), one view generation's. */
121
+ export interface ShellViewScope {
122
+ register(): { set(dirty: boolean): void; remove(): void };
123
+ show(state: 'idle' | 'reloading' | 'failed'): void;
124
+ /** The slot's fallback shown in place of the screen's entry (`failed`: failed or missing; `reloading`: not loaded yet),
125
+ * `undefined` once it is gone; over `show`'s. */
126
+ fallback(state: 'reloading' | 'failed' | undefined): void;
127
+ state(): ViewState;
128
+ subscribe(listener: () => void): () => void;
129
+ attach(): () => void;
130
+ }
131
+ export interface WindowManager {
132
+ /** Shows `view`: in the focused window, or (`beside`) in a new window beside it, focused; `desk: 'new'` (an ⌥-click in
133
+ * the sidebar, W8): in a new window on a new desk, shown (a manager without desks: beside, as `beside` says). A
134
+ * plugin's request (`ctx.screen.open` with hints, research-018 slice 6) leaves the shell's current view as it is: with
135
+ * `beside` and `from` (the window asking), the new window goes beside `from`, which keeps the focus (W7); `into`:
136
+ * `view` replaces window `into`'s, the focus where it is. With `into` and `beside`, an existing destination is
137
+ * restored from the dock or detached from its tabs so it is visible beside the conversation. */
138
+ open(
139
+ view: ShellView,
140
+ hints: {
141
+ beside?: boolean;
142
+ desk?: 'new';
143
+ from?: string;
144
+ into?: string;
145
+ /** A new window, floating (⌘K's ⇧↵, research-034); a manager that cannot: beside. */
146
+ float?: boolean;
147
+ /** A new window, maximized (⌘K's ⇧⌘↵); a manager that cannot: beside. */
148
+ max?: boolean;
149
+ },
150
+ ): void;
151
+ /** Focuses window `id` (the shell asks it for P8); the manager tells the shell nothing back. */
152
+ focus(id: string): void;
153
+ /** Closes window `id` (the shell asks it for W8's toggle: a ⌘-click on what another window of the desk shows), its
154
+ * way out animated at will; a manager that refuses (its last window) keeps it. Optional for the shell: without it,
155
+ * that ⌘-click focuses the window, as P8. */
156
+ close(id: string): void;
157
+ /** The windows P8 looks at: the current workspace's (the shell's `current`); with desks, the desk shown's only.
158
+ * `hidden` (research-069): one the user does not see now (minimized, a tab behind another, under a maximized one); a
159
+ * manager that does not say is taken to show every window. */
160
+ list(): readonly { id: string; view: ShellView; hidden?: true | undefined }[];
161
+ focused(): string | undefined;
162
+ /** A plugin's `reuse` (`ctx.screen.open(item, { reuse: true })`, research-018 slice 6c): the window of those `list`
163
+ * gives, but `from` (the one asking), that shows `view` instead of its own view: of `view`'s screen, node and kind (the
164
+ * kinds its screen's `windows` rules give: a contact's card among the cards, not the list), the one focused last;
165
+ * none: `view` opens beside `from`. Optional: without it, the shell takes the first window of that screen on that node. */
166
+ reusable?(
167
+ view: ShellView,
168
+ from: string | undefined,
169
+ /** Research-069: only a window it says yes to (an agent's page: one shown and idle), the manager's ranking kept. */
170
+ eligible?: (id: string) => boolean,
171
+ ): string | undefined;
172
+ /** Research-069, an agent's page (`shell.present`): `view` in a new tiled window beside window `from`, the focus where
173
+ * it was, and its id; or `undefined` with nothing changed: no room for it tiled, a locked window in the way, the stage
174
+ * not measured, the user's new windows floating, a maximized window. Never a float, a desk, a reveal, a close.
175
+ * Optional: without it, an agent's page opens nothing. */
176
+ tryOpen?(view: ShellView, from: string): string | undefined;
177
+ }
178
+
179
+ /** One window's parts, as the shell draws them for its manager (owner, 11 October 2026: the shell defines the spaces, the
180
+ * window manager the windows and their design): `renderWindow` hands them to `WindowOptions.frame`, which draws the
181
+ * window around them in the manager's design (its border, corners, shadow, focus ring, its bar's look and controls).
182
+ * The anatomy is the shell's, so that plugins, tools and tests find a window under any manager: `window` goes on the
183
+ * frame's outer element (`data-slot="shell-window"`, `data-window` its id, `data-focused` when the manager said so,
184
+ * `data-active` on the window the user works in (`WindowOptions.active`; the shell's flat one always),
185
+ * `role="region"` named by its title: the item's, the screen's, the node's), `bar` on the bar's element
186
+ * (`shell-window-bar`), which holds `crumbs` (the node's path below the workspace, then the screen's path, then the
187
+ * item as its plugin titles it, each ancestor choosable; nothing at the workspace without a choice: the bar keeps its
188
+ * height by itself) then the manager's controls; `body` is the rest, an element that fills the frame's column and
189
+ * scrolls alone (`shell-window-body`): the archived node's banner, then the screen (its `screen` slot entry), an empty
190
+ * window's choices, or a notice (not installed, failed, not active on this node).
191
+ * These attributes are also how a kit rendering (`@bridge/ui`'s `registerRendering`, a pack such as a Windows 98 look)
192
+ * draws windows, with a manager or without one: its stylesheet, under `<html data-kit>` and outside cascade layers,
193
+ * styles the frame (`shell-window`, `data-focused`, `data-active`), the bar (`shell-window-bar`: the kit's Buttons in
194
+ * it are the manager's controls, a `role="tablist"` of `role="tab"` its tabs, which a rendering may move under the
195
+ * title) and the body (`shell-window-body`). So a manager (and the shell's flat frame) draws its frame with utility
196
+ * classes or in a cascade layer (`@layer`), never unlayered: the rendering wins without a specificity contest; what
197
+ * it leaves out stays the manager's design. ./anatomy.test.tsx pins these names. */
198
+ export interface WindowParts {
199
+ window: {
200
+ 'data-slot': 'shell-window';
201
+ 'data-window': string;
202
+ 'data-focused'?: true;
203
+ 'data-active'?: true;
204
+ role: 'region';
205
+ 'aria-label': string;
206
+ };
207
+ bar: { 'data-slot': 'shell-window-bar' };
208
+ crumbs: ReactNode;
209
+ body: ReactNode;
210
+ }
211
+
212
+ /** `renderWindow`'s options: `focused` marks the window focused among several (`data-focused`, where the manager draws
213
+ * its ring); `active`: it is the window the user works in (the focused one, ring or not: alone, it has none), its
214
+ * screen gets `focused: true`, the others `false`; absent (a manager that does not say), the screen's `focused` is
215
+ * absent too. `choices`: an empty window (a node alone) offers the node's views as buttons under "Choose a view in the
216
+ * sidebar". `others` (research-018 slice 6c): the other windows of its desk (shown or minimized) showing its screen on
217
+ * its node, each with its item and the kind its screen's `windows` rules give, passed on to its screen as `others`.
218
+ * `frame`: draws the window around its parts (`WindowParts`); absent, the shell's flat frame, as without a manager. */
219
+ export interface WindowOptions {
220
+ focused: boolean;
221
+ active?: boolean;
222
+ choices?: boolean;
223
+ others?: readonly { item?: string; kind?: string }[];
224
+ frame?: (parts: WindowParts) => ReactNode;
225
+ }
226
+
227
+ /** A window shortcut (research-018 C5): `keys`, one or several, each modifiers then a `KeyboardEvent.code` (or a single
228
+ * character, matched on `KeyboardEvent.key`) joined by `+`, as `Alt+Shift+ArrowLeft`; `Alt` is ⌥ in the browser, ⌥ or ⌘
229
+ * in the Electron app (on W, M, \, ⇧\, 1-9 and ⇧1-9 only). `run` gets the key pressed, as registered. None runs while typing in a
230
+ * field (but ⌥W and ⌥M, ⌘W and ⌘M in the app), nor while a modal dialog is open; a held key repeats it only with `repeat`. */
231
+ /** A workspace plugin's action in the navigators' node menus (bridge#126): shown first, on the workspace and on each
232
+ * live node where `plugin` is active, in workspace `workspace` only; `run` gets the node acted on (`root`: the
233
+ * workspace) and opens its plugin's own dialog. */
234
+ export interface ShellNodeAction {
235
+ /** Unique in its workspace (its plugin key, say). */
236
+ id: string;
237
+ /** The plugin it belongs to: shown where that plugin is active. */
238
+ plugin: string;
239
+ workspace: string;
240
+ /** Its menu item's words ("New project…"). */
241
+ label: string;
242
+ /** When it makes something new: its words under the menus' New ("Project…"), where it goes instead. */
243
+ newLabel?: string;
244
+ run(node: string): void;
245
+ }
246
+
247
+ export interface ShellShortcut {
248
+ keys: string | readonly string[];
249
+ /** Short: the ⌘K palette names the command with it. */
250
+ label: string;
251
+ /** What more there is to say (another way to do it, a limit): beside the label, quieter, in the help and ⌘K. */
252
+ description?: string | undefined;
253
+ run(keys: string): void;
254
+ repeat?: boolean;
255
+ }
256
+
257
+ /** A pointer gesture (declared for the help and conflicts; its owner listens to the pointer itself): `modifiers` held,
258
+ * written as a shortcut's without the key (`Alt+Shift`, `''` for none), then `action`: a primary click, a primary drag,
259
+ * or a right drag. */
260
+ export interface ShellGesture {
261
+ modifiers: string;
262
+ action: 'click' | 'drag' | 'right-drag';
263
+ label: string;
264
+ }
265
+
266
+ interface ShellState {
267
+ /** User workspaces from `/_bridge/workspaces` (`_host` excluded), by slug. */
268
+ workspaces: ShellWorkspace[];
269
+ /** The URL's `/<slug>/` when it names a workspace, else the one chosen, else the first. */
270
+ current: ShellWorkspace | undefined;
271
+ /** From `/_bridge/status`: `warning` when a workspace or plugin failed, stopped, or is unresolved, or a
272
+ * plugin shows a reload or browser error;
273
+ * `safe` in safe mode or with a workspace in it; `undefined` before the first answer. */
274
+ status: 'ok' | 'warning' | 'safe' | undefined;
275
+ /** Each workspace's plugins with their states (`_host`'s too), as one text, from `/_bridge/status`: changes when one is
276
+ * installed, removed, enabled or disabled (the page asks for its pack themes again, research-038). */
277
+ compositions?: Record<string, string>;
278
+ /** The current workspace's screens, from its plugins' manifests; `undefined` until they load, `null`
279
+ * when loading them failed with none shown. */
280
+ screens: ShellScreens | null | undefined;
281
+ /** The screen chosen (in the sidebar, or by `setScreen` from anywhere); reset when the current workspace
282
+ * changes or the loaded tree does not have it. A new object on every `setScreen`, even for the same screen. */
283
+ screen: { plugin: string; id: string } | undefined;
284
+ /** The chosen screen's item (`setScreen`, its plugin's `ctx.screen.open`): the URL's segments past the screen's
285
+ * path, decoded and joined by `/`; `undefined` for none, and with no screen. */
286
+ item: string | undefined;
287
+ /** The chosen screen and its ancestors, its block's root first; empty with none chosen. */
288
+ path: ShellNode[];
289
+ /** True once the current workspace's browser entries settled (loaded, failed, or past the deadline). */
290
+ loaded: boolean;
291
+ /** While the chosen screen is missing from the tree because its plugin failed or is unresolved (status says
292
+ * so): that plugin's key and id, and its error with the way out; `waiting` (unresolved): the services it waits
293
+ * for, and their failed providers with the way out. The screen, its path and its URL are kept until it comes
294
+ * back. */
295
+ failed: { key: string; plugin: string; message: string; waiting?: true } | undefined;
296
+ /** The node shown (AD-6): the URL's `/<slug>/<node>/`, `root` by default and for a node the tree lacks. */
297
+ node: string;
298
+ /** The current workspace's node tree, refetched on its `nodes` status events; `undefined` until it loads.
299
+ * `resolved`: per node, the plugin keys active there (AD-25) and the views it shows (AD-11: its own, plugins active
300
+ * there with a screen) and its home view (`home`: the user's choice, else a manifest's), as the host resolved them. */
301
+ nodes:
302
+ | {
303
+ revision: number;
304
+ nodes: ShellTreeNode[];
305
+ resolved: Record<string, { active: string[]; views: string[]; home?: string }>;
306
+ /** The nodes of projects (bridge#126): node id → project key chain; absent from an older host. */
307
+ projects?: Record<string, string>;
308
+ }
309
+ | undefined;
310
+ /** A utility screen shown in `main` over the chosen view (`setUtility`): plugin `plugin`'s entry in `screen` (its
311
+ * screen id is the plugin key) for node `node`, titled `title` in the breadcrumb. Not a view: listed under no node,
312
+ * not in the URL. Closed by choosing a view or a node, by Back or Forward, and by a workspace change. */
313
+ utility: { plugin: string; node: string; title: string } | undefined;
314
+ /** The window manager the shell set aside for this page (it missed a function, threw, or its `stage` entry crashed):
315
+ * its plugin key (none for a `stage` entry without a registrant) and why; the shell shows its own one window (C6). */
316
+ managerFailed: { plugin?: string | undefined; message: string } | undefined;
317
+ /** `null` while a window manager is set aside for this page (not stored: the shell's one window); else `undefined`:
318
+ * the current workspace's look decides (`windowManager`, the user's Mine over the proposal, research-028), else
319
+ * Bridge's default (the highest-priority `stage` entry). */
320
+ managerChoice: null | undefined;
321
+ /** Research-090: the current view's screen state (the focused window's), as the URL's query names it; `undefined` for
322
+ * none. Kept while the view keeps its node and screen (another item too), dropped by another; a screen opened
323
+ * (`setScreen`, a link) starts on the state its view names. */
324
+ screenState: Record<string, string> | undefined;
325
+ /** The sidebar column hidden (`setSidebarHidden`, ⌥B): kept per browser, all workspaces alike. */
326
+ sidebarHidden: boolean;
327
+ /** A plugin fills the `sidebar` slot and, when that plugin is a navigator, the workspace's look shows it. Not (the
328
+ * sidebar plugin disabled, the Start menu chosen alone): no column, whatever `sidebarHidden` says, and nothing offers
329
+ * to show or hide it. */
330
+ sidebarFilled: boolean;
331
+ /** The navigators this Bridge has (research-035), as they registered (`registerNavigator`): the sidebar, the Start
332
+ * menu, any other; the look's `navigation` chooses among them. */
333
+ navigators: readonly ShellNavigator[];
334
+ }
335
+
336
+ /** A workspace of a Bridge the desktop app joined, as that Bridge's `/_bridge/workspaces` lists it. */
337
+ export interface DesktopWorkspace {
338
+ slug: string;
339
+ title: string;
340
+ look?: WorkspaceLook;
341
+ state: string;
342
+ }
343
+ /** A Bridge the desktop app joined (SPEC multi-instance CAP-12): never its key. `state` (CAP-5): whether it can be used
344
+ * now, `since` when (ISO), `reason` why not, in words; its workspaces are the last it listed. */
345
+ export interface DesktopInstance {
346
+ id: string;
347
+ label: string;
348
+ origin: string;
349
+ workspaces: DesktopWorkspace[];
350
+ state: 'ok' | 'unreachable' | 'incompatible' | 'expired' | 'revoked';
351
+ reason?: string;
352
+ since: string;
353
+ }
354
+ /** A command as a page publishes it to the app (plain data): what the palette shows, run back in that page by id path. */
355
+ export interface RemoteCommand {
356
+ id: string;
357
+ label: string;
358
+ keys?: string;
359
+ group?: string;
360
+ disabled?: boolean;
361
+ icon?: string;
362
+ description?: string;
363
+ navigation?: boolean;
364
+ children?: RemoteCommand[];
365
+ }
366
+ /** A joined Bridge's page's commands: what its focused screen acts on, and every command its palette would list. */
367
+ export interface RemoteCommands {
368
+ subject?: string;
369
+ commands: RemoteCommand[];
370
+ }
371
+ /** The joined Bridges, and the remote workspace the window shows (`null`: this home page). */
372
+ export interface DesktopState {
373
+ instances: DesktopInstance[];
374
+ shown: { instance: string; slug: string } | null;
375
+ /** A popup of the home page covers the window (`overlay(true)`): the home page draws its own toasts meanwhile. */
376
+ overlay: boolean;
377
+ /** The remote page shown's commands, as it last published them (research-034 slice 3); `null` with none shown. */
378
+ commands: RemoteCommands | null;
379
+ /** The rail's tiles in the user's order, by key (`home:<slug>`, `<instanceId>:<slug>`; CAP-4): a key not there yet is
380
+ * a new workspace, shown last; `removed`: the tiles taken off the rail. */
381
+ order: string[];
382
+ removed: string[];
383
+ }
384
+ /** A home toast as the app's toast view draws it (the kit's `ToastShown`): its action a label, run back in the home page. */
385
+ export interface DesktopToast {
386
+ id: string;
387
+ title: string;
388
+ description?: string;
389
+ variant?: 'success' | 'error' | 'warning' | 'info';
390
+ duration?: number;
391
+ action?: { label: string };
392
+ /** The toast it replaced in place keeps its state there (its description unfolded). */
393
+ key?: string;
394
+ }
395
+ /** A server-sent event of a joined workspace's stream (`id`: the last event id the stream gave), or its end. */
396
+ export type DesktopStreamEvent = { event: string; data: string; id?: string } | { error: string };
397
+ type DesktopResult<T = {}> = ({ ok: true } & T) | { ok: false; error: string };
398
+ /** The desktop app's API on its home page (apps/desktop/src/preload.cjs): absent in a browser, and in a remote page
399
+ * (which knows it is embedded by its user agent's `BridgeEmbedded`). */
400
+ export interface BridgeDesktop {
401
+ state(): Promise<DesktopState>;
402
+ onState(listener: (state: DesktopState) => void): () => void;
403
+ /** Joins the Bridge of an invite link (`<origin>/pair#token=<code>`); `error`: why not, nothing joined. `expectId`:
404
+ * the joined Bridge the invite must be of (joining an expired or revoked one again: its key replaced in place). */
405
+ join(link: string, expectId?: string): Promise<DesktopResult<{ instance: DesktopInstance }>>;
406
+ /** Reads joined Bridge `instance`'s state now (a click on the tile standing for one that could not be used). */
407
+ retry(instance: string): Promise<DesktopResult>;
408
+ /** Shows workspace `slug` of joined Bridge `instance` over the window, or (`null`) this page again. */
409
+ select(instance: string | null, slug: string): Promise<DesktopResult>;
410
+ /** Sets the rail's order: `keys` first, the keys the app knew and `keys` lacks after them. */
411
+ setOrder(keys: readonly string[]): Promise<DesktopResult>;
412
+ /** Appends to the order the keys not in it yet (new workspaces, last). */
413
+ append(keys: readonly string[]): Promise<DesktopResult>;
414
+ /** Takes a tile off the rail, or puts it back at its end. */
415
+ remove(key: string): Promise<DesktopResult>;
416
+ restore(key: string): Promise<DesktopResult>;
417
+ /** Forgets joined Bridge `instance` in this app (CAP-6): its link, key, cached workspaces and its pages' data; the
418
+ * Bridge is not contacted (not a revocation: its Admin still lists this app). */
419
+ unlink(instance: string): Promise<DesktopResult>;
420
+ createWorkspace(
421
+ instance: string,
422
+ workspace: { slug: string; title: string },
423
+ ): Promise<DesktopResult<{ slug: string }>>;
424
+ /** Joined workspaces' APIs (CAP-12), for home plugins: the app makes the request with the link's key, which never
425
+ * reaches this page (alpha limit: a home plugin acts with the owner's rights on every joined workspace). Only a path
426
+ * of the workspace's API (`/<workspace>/api/…`), of a Bridge that can be used now; GET, POST, PUT, PATCH, DELETE;
427
+ * bodies up to 1 MiB, answers up to 4 MiB. */
428
+ instances: {
429
+ /** One request: its status, content type and body as text. `ok: true` means the call was made and answered, whatever
430
+ * its HTTP status (a 404, a 500, a 3xx too: read `status`); `ok: false`, `error`: why it was not made or got no
431
+ * answer. `headers` is a plain object of strings and `body` a string (else the promise rejects); no body on GET. */
432
+ call(
433
+ instance: string,
434
+ workspace: string,
435
+ path: string,
436
+ init?: { method?: string; headers?: Record<string, string>; body?: string },
437
+ ): Promise<
438
+ DesktopResult<{ status: number; headers: { 'content-type'?: string }; body: string }>
439
+ >;
440
+ /** Each server-sent event of the path, then a last `{ error }` when it stops: its end, a refusal, its Bridge
441
+ * unlinked, the window closing. It never reconnects by itself: to resume, open it again with the last event's `id`
442
+ * as `lastEventId` (sent as `Last-Event-ID`). Returns the unsubscribe; every stream also closes when this page
443
+ * loads another. */
444
+ stream(
445
+ instance: string,
446
+ workspace: string,
447
+ path: string,
448
+ onEvent: (event: DesktopStreamEvent) => void,
449
+ lastEventId?: string,
450
+ ): () => void;
451
+ };
452
+ /** The app's recovery screen (the home Bridge did not start): try it again, in safe mode, or quit. */
453
+ recover(action: 'retry' | 'safe' | 'quit'): Promise<DesktopResult>;
454
+ /** A popup of this page opens (`true`) or closes: over a remote page, the page covers the window meanwhile. */
455
+ overlay(open: boolean): Promise<unknown>;
456
+ /** Home page (research-034 slice 3): the app took ⌘K in a view; returns the unsubscribe. */
457
+ onPalette(listener: () => void): () => void;
458
+ /** Home page: its palette opened or closed; the home view covers the window meanwhile. */
459
+ palette(open: boolean): Promise<unknown>;
460
+ /** Home page: runs the remote page shown's command at `path`. */
461
+ runRemote(path: readonly string[]): Promise<unknown>;
462
+ /** This page is the app's toast view (window-layout.md): small, opaque, over a remote page, it draws the home page's
463
+ * toasts and nothing else. The calls below are each for one of the two pages. */
464
+ toastView: boolean;
465
+ /** Home page, while a remote page shows: its toasts, for the toast view to draw; `[]`: none. */
466
+ showToasts(toasts: DesktopToast[]): Promise<unknown>;
467
+ /** Home page: a toast's action or dismissal used in the toast view; returns the unsubscribe. */
468
+ onToastUsed(listener: (id: string, used: 'action' | 'dismiss') => void): () => void;
469
+ /** Toast view: the toasts to draw now, then on each change. */
470
+ toasts(): Promise<DesktopResult<{ toasts: DesktopToast[] }>>;
471
+ onToasts(listener: (toasts: DesktopToast[]) => void): () => void;
472
+ /** Toast view: the size of its stack, which the view takes, at the window's bottom right (0 hides it), and its
473
+ * opaque background (`#rrggbb`), the view's own. */
474
+ toastSize(size: { width: number; height: number; background?: string }): Promise<unknown>;
475
+ /** Toast view: a toast's action or dismissal used, for the home page to run. */
476
+ toastUsed(id: string, used: 'action' | 'dismiss'): Promise<unknown>;
477
+ }
478
+ declare global {
479
+ interface Window {
480
+ bridgeDesktop?: BridgeDesktop;
481
+ }
482
+ }
483
+
484
+ declare module 'cordis' {
485
+ interface Context {
486
+ shell: {
487
+ get(): ShellState;
488
+ setCurrent(slug: string): void;
489
+ /** Opens the shell's one approval modal (research-031) on request `id` (or, with none, the first pending), even
490
+ * one the user dismissed with Later. Projects' Review button calls it, so the decision is taken in one place
491
+ * wherever the user is. */
492
+ reviewRequest(id?: string): void;
493
+ /** Opens the Errors modal (`./errors.tsx`): what is failing in this Bridge now, in full, from
494
+ * `/_bridge/status`; `key`: the item to scroll to and outline briefly (a cause key, `pluginKey(slug, id)`,
495
+ * or a workspace slug, as a failure toast's `details` gives it), none: the top. */
496
+ showErrors(key?: string): void;
497
+ /** Opens the keyboard shortcuts' help (as `?` does): a plugin's button in the `controls` zone asks for it. */
498
+ showShortcuts(): void;
499
+ /** Opens plugin `plugin`'s settings (its id) in workspace `slug` on field `setting`: a fix's Open the setting, the
500
+ * toasts' and Health's (research-047); `event`, the click's, followed by Bridge's rule (`follow`, research-048). */
501
+ openSetting(
502
+ slug: string,
503
+ plugin: string,
504
+ setting: string,
505
+ event?: {
506
+ type?: string;
507
+ button?: number;
508
+ metaKey: boolean;
509
+ ctrlKey: boolean;
510
+ altKey: boolean;
511
+ shiftKey: boolean;
512
+ },
513
+ ): void;
514
+ /** Opens Admin › System › Logs (bridge#222), a navigation entry: `settings` its rotation and retention settings,
515
+ * else `<workspace>[/<plugin>[/<subject>]]` (each part URI-encoded) its filters; none, every log. */
516
+ openBridgeLogs(
517
+ item?: string,
518
+ event?: {
519
+ type?: string;
520
+ button?: number;
521
+ metaKey: boolean;
522
+ ctrlKey: boolean;
523
+ altKey: boolean;
524
+ shiftKey: boolean;
525
+ },
526
+ ): void;
527
+ /** Opens plugin `plugin`'s Logs tab (its id) in workspace `slug`'s Plugins screen, a navigation entry: the records
528
+ * up to `until` (an ISO time: Health's Logs, research-047), else its live log. */
529
+ openLogs(
530
+ slug: string,
531
+ plugin: string,
532
+ until?: string,
533
+ event?: {
534
+ type?: string;
535
+ button?: number;
536
+ metaKey: boolean;
537
+ ctrlKey: boolean;
538
+ altKey: boolean;
539
+ shiftKey: boolean;
540
+ },
541
+ ): void;
542
+ /** Runs plugin `plugin`'s settings action in workspace `slug` (a Health row's fix), its `confirm` asked first. */
543
+ runAction(
544
+ slug: string,
545
+ plugin: string,
546
+ fix: { action: string; label: string; confirm?: string },
547
+ ): void;
548
+ /** Opens Admin's Health screen (research-047) on its open problems. */
549
+ showHealth(event?: {
550
+ type?: string;
551
+ button?: number;
552
+ metaKey: boolean;
553
+ ctrlKey: boolean;
554
+ altKey: boolean;
555
+ shiftKey: boolean;
556
+ }): void;
557
+ /** What the status indicator leads to: with a warning, Health (every failure has its episode there); without one,
558
+ * Admin's Status. The rail's dot and the Bridge status command. */
559
+ showStatus(): Promise<void>;
560
+ /** `node`: the screen chosen under that node, which becomes the node shown; `item`: its item (none by default). */
561
+ setScreen(
562
+ screen: { plugin: string; id: string },
563
+ node?: string,
564
+ item?: string,
565
+ screenState?: Record<string, string>,
566
+ ): void;
567
+ /** Research-090: window `window`'s screen state set to `next` (`undefined`: none; not a small flat map of strings:
568
+ * none), by its screen: the focused window's in the URL's query, in place unless `push` (a history entry); any
569
+ * window's saved with it by its manager. */
570
+ setScreenState(
571
+ window: string,
572
+ next: Record<string, string> | undefined,
573
+ options?: { push?: boolean },
574
+ ): void;
575
+ /** A workspace plugin's `ctx.screen.open(item?, hints?)`: its screen shown with `item`, unless none of its screens
576
+ * is shown (or a utility screen is over it); throws a `TypeError` for an item starting with a child screen's id.
577
+ * `beside`, `reuse`: in another window, the focused one (the one asking) keeping the focus, as `workspace.d.ts`
578
+ * says (`reuse`: the window the manager's `reusable` names, focused last of the kind asked); without a window
579
+ * manager, as without hints. `beside` from a plugin none of whose screens is shown (its tab in another plugin's
580
+ * screen): its first root screen in a new window beside (the window showing it already: focused); nothing
581
+ * without a window manager. */
582
+ openItem(
583
+ plugin: string,
584
+ item: string | undefined,
585
+ hints?: { beside?: true; desk?: true; reuse?: true; show?: true },
586
+ ): void;
587
+ /** Follows a link to `view` as `event` asks (research-048): a plain click here, a new history entry; ⌘ (Ctrl) or a
588
+ * middle click in a new window beside (⌘ again on what another window shows: that window closes, W8); ⌥ in a new
589
+ * window on a new desk; ⇧ or another button, nothing. Without a window manager, a modified click does nothing. */
590
+ follow(
591
+ view: ShellView,
592
+ event: {
593
+ type?: string;
594
+ button?: number;
595
+ metaKey: boolean;
596
+ ctrlKey: boolean;
597
+ altKey: boolean;
598
+ shiftKey: boolean;
599
+ },
600
+ ): void;
601
+ /** Follows an item link of the window `from` (its id) shows, `view` its view with the item (research-048): plain
602
+ * there (`reuse`: another window of its screen when there is one), ⌘ or middle beside it, ⌥ on a new desk; a
603
+ * modified click without a window manager, nothing. */
604
+ followItem(
605
+ view: ShellView,
606
+ event: {
607
+ type?: string;
608
+ button?: number;
609
+ metaKey: boolean;
610
+ ctrlKey: boolean;
611
+ altKey: boolean;
612
+ shiftKey: boolean;
613
+ },
614
+ options?: { from?: string; reuse?: boolean },
615
+ ): void;
616
+ /** Follows a link to `view` of workspace `slug` (research-048): the current one as `follow`; another entered
617
+ * first, `view` shown there on a plain click, opened beside (⌥: on a new desk) once routed on a modified one;
618
+ * without a window manager a modified click does nothing. */
619
+ openIn(
620
+ slug: string,
621
+ view: ShellView,
622
+ event: {
623
+ type?: string;
624
+ button?: number;
625
+ metaKey: boolean;
626
+ ctrlKey: boolean;
627
+ altKey: boolean;
628
+ shiftKey: boolean;
629
+ },
630
+ ): void;
631
+ /** Whether a window manager is active: a modified click has somewhere to go. */
632
+ managed(): boolean;
633
+ /** The URL of `view` in the current workspace (a link's `href`); none while the screen tree loads. */
634
+ hrefOf(view: ShellView): string | undefined;
635
+ /** Shows node `id`: its home view (also from another view of the node shown), else the chosen view kept when it
636
+ * is shown there, else the node's first view, else none. */
637
+ setNode(id: string): void;
638
+ /** Hides or shows the sidebar column (`ShellState.sidebarHidden`), kept per browser. */
639
+ setSidebarHidden(hidden: boolean): void;
640
+ /** A navigator joins the choice (research-035): `id` its plugin key (the shell matches it to what fills
641
+ * `sidebar`); returns its removal. */
642
+ registerNavigator(navigator: ShellNavigator): () => void;
643
+ /** Whether navigator `id` shows in the current workspace: the look's `navigation` (the user's Mine over the
644
+ * workspace's proposal) names it, or names none this Bridge has (every one shows then: never none). */
645
+ navigatorShown(id: string): boolean;
646
+ /** Shows a utility screen (`ShellState.utility`), or closes it (`undefined`). */
647
+ setUtility(utility: { plugin: string; node: string; title: string } | undefined): void;
648
+ /** Closes the utility screen as the browser's Back would: back to the node it was opened from, if another. */
649
+ closeUtility(): void;
650
+ /** Creates a node under `parent` in the current workspace; resolves once its tree is shown; rejects with the
651
+ * host's message, or with `code: 'not-shown'` when made but its tree could not be fetched. */
652
+ createNode(parent: string, title: string): Promise<{ id: string; revision: number }>;
653
+ /** Renames, moves (`dryRun`: `lost` only, nothing changed), places among its siblings (`before`: the sibling it
654
+ * goes before, `null` last), archives, unarchives, shows or hides a view on
655
+ * (`view`, AD-11), sets the home view of (`home`, `null`: automatic) a node of the current workspace, places one
656
+ * of its views (`place`: its order, its section on root, `from` another node) or changes root's sections
657
+ * (`section`, research-067: a new one answers its `id`); resolves
658
+ * once its tree is shown; rejects as `createNode`. */
659
+ changeNode(
660
+ id: string,
661
+ change:
662
+ | { title: string }
663
+ | { parent: string; dryRun?: boolean }
664
+ | { before: string | null }
665
+ | { archived: boolean }
666
+ | { view: { plugin: string; shown: boolean; block?: string } }
667
+ | { home: string | null }
668
+ | {
669
+ place: {
670
+ block: string;
671
+ before?: string | null;
672
+ section?: string | null;
673
+ from?: string;
674
+ };
675
+ }
676
+ | {
677
+ section:
678
+ | { title: string }
679
+ | { id: string; title: string }
680
+ | { id: string; before: string | null }
681
+ | { id: string; removed: true };
682
+ },
683
+ ): Promise<{ revision: number; lost?: string[]; id?: string }>;
684
+ /** A window manager's focus change: `view` (the focused window's) becomes the current view, its URL in place
685
+ * (no history entry). */
686
+ show(view: ShellView): void;
687
+ subscribe(listener: () => void): () => void;
688
+ /** Sets the user's window manager for the current workspace (its Mine's `windowManager`: a plugin key, `null` for
689
+ * none, `undefined` for the workspace's own choice again); the one now active gets the current view. */
690
+ chooseManager(choice: string | null | undefined): void;
691
+ /** The view a page path names in the current workspace, by the URL's rules; none for another workspace or a
692
+ * screen its tree lacks. */
693
+ viewAt(pathname: string): ShellView | undefined;
694
+ /** ⌘K's ↵ with a modifier (research-034): the view change made next, in this task, opens in a new window beside,
695
+ * on a new desk, floating, or maximized; without a window manager, here. */
696
+ placeNext(where: 'beside' | 'desk' | 'float' | 'max'): void;
697
+ /** Research-069: the state of window `id`'s view (its `data-state`): `editing` while one of its editors holds unsaved
698
+ * changes (`useEditing` of `@bridge/ui`), `reloading` while its plugin starts again, `failed` while a notice stands
699
+ * in its place, else `idle`; `undefined` while it is not mounted (not known: never replaced). */
700
+ viewState(id: string): ViewState | undefined;
701
+ /** The shell's own window body: window `id`'s view scope for one view generation (a node change starts another),
702
+ * the editors' registrations (`ViewScopeProvider`'s value), the state the shell shows (`show`), followed by
703
+ * `subscribe`; the window's while mounted (`attach` returns its removal). */
704
+ viewScope(id: string): ShellViewScope;
705
+ /** Research-069, an agent's page (`bridge_link`'s `show`) from the session window `from`: never a change the user
706
+ * cannot see to a view they know. In order: no window manager, or `from` not shown, nothing; a window shown
707
+ * showing `view` already, nothing changes (`visible`); a shown, idle window of its kind on its node (`reusable`), not
708
+ * the one the user has focused, replaced (`replaced`); else a new tiled window beside `from` (`tryOpen`, `opened`), or nothing. Never a close, a
709
+ * move, a reveal from the dock or tabs, a new desk; the typing focus kept while the view mounts. One window per
710
+ * `turn` (the agent's, kept for the page across a reload): the next `present` of that turn replaces that window,
711
+ * and nothing opens once it is closed or editing. */
712
+ present(
713
+ view: ShellView,
714
+ from: string,
715
+ turn?: string,
716
+ ):
717
+ | { shown: 'visible' | 'replaced' | 'opened'; window: string }
718
+ | {
719
+ shown: false;
720
+ reason: 'no-manager' | 'not-shown' | 'hidden' | 'turn-used' | 'no-room';
721
+ };
722
+ /** The window shortcuts (research-018 C5): `register` refuses (and logs) a key Bridge reserves (Escape, Space, Tab but ⌥Tab,
723
+ * ⌘K, ⌘L, ⌘R, ⌘T, ⌘C, ⌘V, ⌘X, ⌘A, ⌘Z, `?`) or one registered already, and returns the removal; the shell runs
724
+ * a shortcut on `keydown` (a key without a modifier not while typing in a field); `list` feeds the help. */
725
+ /** Workspace plugins' node actions (`ShellNodeAction`, bridge#126): `register` returns the removal; the
726
+ * navigators read `list` and follow `subscribe`. */
727
+ nodeActions: {
728
+ register(action: ShellNodeAction): () => void;
729
+ list(): readonly ShellNodeAction[];
730
+ subscribe(listener: () => void): () => void;
731
+ };
732
+ shortcuts: {
733
+ register(shortcut: ShellShortcut, by?: string): () => void;
734
+ /** Each registered shortcut: its keys, its label, and its run (as its first key would; the ⌘K palette's). */
735
+ list(): readonly {
736
+ keys: readonly string[];
737
+ label: string;
738
+ description?: string | undefined;
739
+ run(): void;
740
+ }[];
741
+ /** Declares a pointer gesture its owner (`by`) handles itself, for the help; refused (and logged, naming both
742
+ * owners) when the same modifiers and action are declared already, or for Bridge's ⌘-click / Ctrl-click. */
743
+ gesture(gesture: ShellGesture, by?: string): () => void;
744
+ gestures(): readonly (ShellGesture & { by?: string })[];
745
+ /** Declares keys its owner (`by`) handles itself (a screen's, acting only while its window is `focused`), for the
746
+ * help and for clashes; refused (and logged, naming the holder) for a key registered or declared already. Bridge's
747
+ * own keys (Escape, ⌘Z…) may be declared. Returns the removal. */
748
+ declare(
749
+ shortcut: { keys: string | readonly string[]; label: string },
750
+ by?: string,
751
+ ): () => void;
752
+ declared(): readonly { keys: readonly string[]; label: string; by?: string }[];
753
+ subscribe(listener: () => void): () => void;
754
+ };
755
+ };
756
+ /** The active window manager's (research-018 WM3), when a `_host` plugin provides it; the shell reads it with
757
+ * `ctx.get('windowManager')` (never injected: none is the one-window shell). */
758
+ windowManager: WindowManager;
759
+ /** The boot kernel's: aborts the previous workspace's requests and streams, disposes its plugins,
760
+ * then loads `slug`'s browser entries (none for `undefined`); resolves once they settled or another
761
+ * `open` took over. */
762
+ workspaceEntries: {
763
+ open(slug: string | undefined): Promise<void>;
764
+ /** Workspace `slug`'s node tree, at `revision` or newer when given: the page's fetches, shared with its plugins'
765
+ * `nodes` service (`@bridge/kernel/node-trees`). Absent in an older boot kernel. */
766
+ tree?(slug: string, revision?: number): Promise<unknown>;
767
+ };
768
+ /** The boot kernel's: the host's status events (`/_bridge/status/events`), a snapshot first (the last one
769
+ * again to a late subscriber, a new one on each reconnection), after the kernel disposed the browser
770
+ * half of each plugin they show failed, unresolved, disabled, or removed. Returns the unsubscribe. */
771
+ hostStatus: {
772
+ subscribe(listener: (event: HostStatusEvent) => void): () => void;
773
+ /** Calls `listener` once this page is older than Bridge (its shared modules changed): the shell toasts it, the
774
+ * boot kernel's own banner then stays away. Absent in an older boot kernel. */
775
+ pageUpdated?(listener: () => void): () => void;
776
+ };
777
+ /** The boot kernel's: the marks workspace plugins set on their own sidebar nodes (`ctx.sidebar.set(id,
778
+ * { count?, working? })`), by plugin key then screen id; a new map on every change. */
779
+ sidebarMarks: {
780
+ get(): ReadonlyMap<
781
+ string,
782
+ ReadonlyMap<string, { count?: number; working?: boolean; alert?: 'error' | 'warning' }>
783
+ >;
784
+ subscribe(listener: () => void): () => void;
785
+ };
786
+ /** The boot kernel's: the items workspace plugins list under their own screens (`ctx.sidebar.items(id, items)`),
787
+ * by plugin key then screen id; a new map on every change. */
788
+ sidebarItems: {
789
+ navigation: {
790
+ get(): ReadonlyMap<
791
+ string,
792
+ ReadonlyMap<
793
+ string,
794
+ {
795
+ screen: string;
796
+ node: string;
797
+ items: readonly ShellSidebarItem[];
798
+ }
799
+ >
800
+ >;
801
+ subscribe(listener: () => void): () => void;
802
+ };
803
+ get(): ReadonlyMap<string, ReadonlyMap<string, readonly ShellSidebarItem[]>>;
804
+ subscribe(listener: () => void): () => void;
805
+ };
806
+ /** The boot kernel's: a workspace plugin's `ctx.screen.open(item?, hints?)`, its key, the item and the hints (only
807
+ * those `true`), for the shell to show (`subscribe` returns the unsubscribe); `isItemSegment`, the kernel's rule for
808
+ * an item path's part, for reading a URL (the shell imports nothing from the kernel: it builds as a plugin). */
809
+ screenRequests: {
810
+ subscribe(
811
+ listener: (
812
+ plugin: string,
813
+ item: string | undefined,
814
+ hints: { beside?: true; desk?: true; reuse?: true; show?: true },
815
+ ) => void,
816
+ ): () => void;
817
+ /** The titles plugins give their items (`ctx.screen.title`), by plugin key then item; a new map on every change. */
818
+ titles: {
819
+ get(): ReadonlyMap<string, ReadonlyMap<string, { title: string; context?: string }>>;
820
+ subscribe(listener: () => void): () => void;
821
+ };
822
+ isItemSegment(segment: string): boolean;
823
+ };
824
+ }
825
+ }
826
+
827
+ declare module '@bridge/ui-slots' {
828
+ interface SlotMap {
829
+ /** While the sidebar column is hidden, the shell hands the rail what that column's footer held: `controls` (the
830
+ * shortcuts' help, the light/dark toggle) for its bottom, above its status and Admin, and `sidebarToggle` (the
831
+ * button showing the column again) for its very end; both absent while the column shows. */
832
+ rail: {
833
+ kind: 'single';
834
+ scope: 'root';
835
+ owner: { controls?: ReactNode; sidebarToggle?: ReactNode };
836
+ };
837
+ /** Declared by `rail` (CAP-4, research-024 C12): a home plugin's icon (an Inbox, an agenda) at the top of
838
+ * the rail, above the workspaces, or at its bottom, above Admin; each entry its own `id`, about 40px square. */
839
+ 'rail-top': { kind: 'list'; scope: 'root' };
840
+ 'rail-bottom': { kind: 'list'; scope: 'root' };
841
+ sidebar: { kind: 'single'; scope: 'root' };
842
+ /** Declared by `windows`' `stage` entry: at the left of its dock, before the desks (a Start button); each entry its
843
+ * own `id`, 28px high. Not drawn while another manager, or none, lays out the windows. */
844
+ 'dock-start': { kind: 'list'; scope: 'root' };
845
+ main: { kind: 'single'; scope: 'root' };
846
+ /** Over the whole frame, after it: `_host` plugins add floating layers (each its own `id`), fixed-positioned. */
847
+ overlay: { kind: 'list'; scope: 'root' };
848
+ /** Declared by `shell`: with its theme controls, wherever they stand (under the sidebar, under the rail while it is
849
+ * hidden, in the narrow column of the desktop app's pages), first; each entry its own `id`, a 28px button (the
850
+ * Start menu's when no dock shows). */
851
+ controls: { kind: 'list'; scope: 'root' };
852
+ /** Declared by `shell`'s `main` entry: a workspace plugin fills its own key (its plugin key; the kernel
853
+ * sets it) with its screens, and gets the chosen screen's id and the node shown, `readOnly` when that node or
854
+ * an ancestor is archived, and its `item` when one is chosen; never on a node where that plugin is not active
855
+ * (AD-25): the shell shows a notice instead. The entry remounts when the node changes (not the item). The same
856
+ * screen may show in several windows (other items, other desks): `focused` says whether its window is the one the
857
+ * user works in (its keys act only then); absent, a window manager that does not say: take it as focused. `others`
858
+ * (research-018 slice 6c): the other windows of its desk (shown or minimized) showing the same screen on the same
859
+ * node, each with its item and the kind its screen's `windows` rules give it: a list may leave its own card pane
860
+ * while card windows are open, and send a click to them (`reuse`); absent, a manager (or a Bridge) that does not say.
861
+ * `screenState`, `setScreenState` (research-090): its window's own state and its setter, as `workspace.d.ts`'s
862
+ * `screen` says; absent from an older Bridge. */
863
+ screen: {
864
+ kind: 'keyed';
865
+ scope: 'root';
866
+ owner: {
867
+ screen: string;
868
+ node: string;
869
+ readOnly: boolean;
870
+ item?: string;
871
+ focused?: boolean;
872
+ others?: readonly { item?: string; kind?: string }[];
873
+ screenState?: Record<string, string>;
874
+ setScreenState?: (
875
+ next: Record<string, string> | undefined,
876
+ options?: { push?: boolean },
877
+ ) => void;
878
+ };
879
+ };
880
+ /** Declared by `shell`'s `main` entry (research-020 C): a screen's phone variant, filled under its plugin key as
881
+ * `screen` is, with the same owner; on a phone the shell renders it in the place of `screen`, and `screen` (the
882
+ * desktop view, D4) when the plugin has none. */
883
+ mobileScreen: {
884
+ kind: 'keyed';
885
+ scope: 'root';
886
+ /** `setActions` (research-020, iOS 26's layout): the buttons the screen wants the shell to draw, in glass:
887
+ * `top`, the capsule at the top right; `primary`, the round button at the bottom right beside the bar of
888
+ * screens. Call it from an effect, and with `[]` when the screen unmounts. Absent: an older shell. */
889
+ owner: SlotMap['screen']['owner'] & {
890
+ setActions?: (
891
+ actions: readonly {
892
+ id: string;
893
+ label: string;
894
+ icon: string;
895
+ placement?: 'top' | 'primary';
896
+ onSelect: () => void;
897
+ disabled?: boolean;
898
+ }[],
899
+ ) => void;
900
+ /** `{ bar: false }`: no bottom bar while the screen shows a form of its own (a new contact over its list),
901
+ * whose buttons the bar would cover; `{}` gives it back (call it so when the screen unmounts). */
902
+ setChrome?: (chrome: { bar?: boolean }) => void;
903
+ };
904
+ };
905
+ /** Declared by `shell`'s `main` entry (research-018 WM2): a window manager (a `_host` plugin) lays its windows out
906
+ * here, in the space the shell leaves it (on the canvas beside the sidebar, nothing drawn: the margin around the
907
+ * windows is the manager's), each window from `renderWindow(id, view, options)`: its parts (`WindowParts`: its
908
+ * breadcrumb, its screen) in the frame the manager draws (`options.frame`). `view` is the current view (the
909
+ * focused window's), `workspace` the current workspace's slug. Empty, or its entry crashed: the shell shows the
910
+ * current view flat in the stage, under a top bar with its breadcrumb (C6). */
911
+ /** Declared by `shell`'s `main` entry (research-034): a workspace plugin's dialogs over any view (Contacts' quick
912
+ * create from ⌘K), each entry its own `id`; each draws its own modal (portalled), nothing in the stage. */
913
+ dialogs: { kind: 'list'; scope: 'root' };
914
+ stage: {
915
+ kind: 'single';
916
+ scope: 'root';
917
+ owner: {
918
+ renderWindow: (id: string, view: ShellView, options: WindowOptions) => ReactNode;
919
+ view: ShellView;
920
+ workspace: string | undefined;
921
+ };
922
+ };
923
+ }
924
+ }