apps 0.0.1-beta.144 → 0.0.1-beta.148

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +14 -0
  2. package/framework-reference.json +1 -1
  3. package/js/{chunk-IWLFLMIL.js → chunk-4XXHO5UG.js} +3966 -1760
  4. package/js/{chunk-6OWHQINS.js → chunk-63BS5GBH.js} +2 -2
  5. package/js/{chunk-6NRWFVK2.js → chunk-ALZDZ3ZT.js} +3 -3
  6. package/js/{chunk-T4MICYGT.js → chunk-CQCY3OZS.js} +2 -2
  7. package/js/{chunk-QDF7PQAD.js → chunk-CWAPV2TN.js} +2 -2
  8. package/js/{chunk-5MEOL2SG.js → chunk-DX5DD6Z2.js} +6 -6
  9. package/js/{chunk-455CCO6Q.js → chunk-E2PVLAGK.js} +1 -1
  10. package/js/{chunk-AFEMXP3F.js → chunk-FWK2WTJB.js} +2 -2
  11. package/js/{chunk-2OGVSUNI.js → chunk-GWFQCQB5.js} +2 -2
  12. package/js/chunk-HEFJFDU4.js +87 -0
  13. package/js/{chunk-B2PSDMZP.js → chunk-I7MYW7IK.js} +2 -2
  14. package/js/{chunk-B4JN2A6F.js → chunk-MXFPSMNM.js} +1 -1
  15. package/js/{chunk-INQON4A2.js → chunk-OA4UYCJ4.js} +2 -2
  16. package/js/{chunk-OFSXKKD6.js → chunk-PUMGAWHB.js} +7 -7
  17. package/js/{chunk-W6V5OIHB.js → chunk-SEJXUMGT.js} +267 -1
  18. package/js/{chunk-BU3UOD2T.js → chunk-SXYFFXHM.js} +1 -1
  19. package/js/{chunk-BHSWVS3Q.js → chunk-UT2CBMW3.js} +4 -1
  20. package/js/{chunk-TMYRAFMC.js → chunk-ZWFMEH2Y.js} +18 -1
  21. package/js/client.js +30 -8
  22. package/js/contracts.js +1 -2
  23. package/js/effect.js +10 -11
  24. package/js/graphql.js +12 -13
  25. package/js/host.js +10 -11
  26. package/js/index.js +6 -7
  27. package/js/mcp/effect.js +11 -12
  28. package/js/mcp.js +13 -14
  29. package/js/openapi.js +8 -9
  30. package/js/react.js +122 -3
  31. package/js/skills/effect.js +1 -2
  32. package/js/skills.js +7 -8
  33. package/js/ui/auth/contracts.js +5 -1
  34. package/js/ui/auth.js +7 -4
  35. package/js/ui/contracts.js +52 -5
  36. package/js/ui/serving.js +55 -17
  37. package/package.json +1 -1
  38. package/runtime.json +1 -1
  39. package/types/apps/src/client.d.ts +3 -0
  40. package/types/apps/src/contracts/desktop-errors.d.ts +46 -0
  41. package/types/apps/src/contracts/desktop.d.ts +228 -0
  42. package/types/apps/src/contracts/ui-auth.d.ts +4 -1
  43. package/types/apps/src/contracts/ui.d.ts +43 -1
  44. package/types/apps/src/implementation/desktop.d.ts +85 -0
  45. package/types/apps/src/implementation/ui-serving.d.ts +13 -1
  46. package/types/apps/src/react.d.ts +29 -0
  47. package/types/apps/src/ui-serving.d.ts +1 -1
  48. package/js/chunk-QLUWYCOT.js +0 -2325
@@ -3,3 +3,6 @@ export { queryReference, mutationReference, liveQueryAtom } from "./implementati
3
3
  export { AppQueryFailed, type OperationReference, type QueryDescriptor, type QueryTransport, } from "./contracts/live.js";
4
4
  export { createAppClient } from "./implementation/ui-client.js";
5
5
  export type { AppMutation, OptimisticLocalStore, OptimisticUpdate, } from "./contracts/optimistic.js";
6
+ export { desktop } from "./implementation/desktop.js";
7
+ export { DesktopUnavailable, DesktopPermissionDenied, ShortcutTaken, DesktopInvalidInput, SystemAudioBlocked, type DesktopError, } from "./contracts/desktop-errors.js";
8
+ export { desktopBadgeMaximum, desktopMaximumWindows, desktopMenuBarTitleMaxLength, desktopPermissions, desktopWindowSize, type DesktopPermission, type DesktopPermissionState, type DesktopWindowOptions, } from "./contracts/desktop.js";
@@ -0,0 +1,46 @@
1
+ /** Failures of `desktop` from `apps/client`, which authors check with `instanceof`. */
2
+ import { Schema } from "effect";
3
+ import type { DesktopBridgeFailure } from "./desktop.js";
4
+ declare const DesktopUnavailable_base: Schema.Class<DesktopUnavailable, Schema.TaggedStruct<"DesktopUnavailable", {}>, import("effect/Cause").YieldableError>;
5
+ /** The page is not in an installed Executor desktop window, or the desktop closed the bridge. */
6
+ export declare class DesktopUnavailable extends DesktopUnavailable_base {
7
+ }
8
+ declare const DesktopPermissionDenied_base: Schema.Class<DesktopPermissionDenied, Schema.TaggedStruct<"DesktopPermissionDenied", {
9
+ permission: Schema.Literals<readonly ["menuBar", "shortcuts", "floating", "startAtLogin", "microphone", "camera", "systemAudio", "clipboardRead", "notifications"]>;
10
+ }>, import("effect/Cause").YieldableError>;
11
+ /** The person did not allow this capability for the app. */
12
+ export declare class DesktopPermissionDenied extends DesktopPermissionDenied_base {
13
+ }
14
+ declare const ShortcutTaken_base: Schema.Class<ShortcutTaken, Schema.TaggedStruct<"ShortcutTaken", {
15
+ accelerator: Schema.String;
16
+ }>, import("effect/Cause").YieldableError>;
17
+ /** Another app or program already holds this global shortcut. */
18
+ export declare class ShortcutTaken extends ShortcutTaken_base {
19
+ }
20
+ declare const DesktopInvalidInput_base: Schema.Class<DesktopInvalidInput, Schema.TaggedStruct<"DesktopInvalidInput", {
21
+ message: Schema.String;
22
+ }>, import("effect/Cause").YieldableError>;
23
+ /** The call's input is not one the desktop accepts, such as a title that is too long. */
24
+ export declare class DesktopInvalidInput extends DesktopInvalidInput_base {
25
+ }
26
+ declare const SystemAudioBlocked_base: Schema.Class<SystemAudioBlocked, Schema.TaggedStruct<"SystemAudioBlocked", {}>, import("effect/Cause").YieldableError>;
27
+ /**
28
+ * The app may hear system audio, but macOS has not allowed Executor to record the screen and
29
+ * system audio. The desktop has already offered to open System Settings; try again afterwards.
30
+ */
31
+ export declare class SystemAudioBlocked extends SystemAudioBlocked_base {
32
+ }
33
+ /** Any failure a `desktop` call rejects with. */
34
+ export type DesktopError = DesktopUnavailable | DesktopPermissionDenied | ShortcutTaken | DesktopInvalidInput | SystemAudioBlocked;
35
+ /** The plain tagged objects a bridge rejects with, as they cross the desktop's preload. */
36
+ export declare const DesktopBridgeRejection: Schema.Union<readonly [Schema.TaggedStruct<"DesktopUnavailable", {}>, Schema.TaggedStruct<"DesktopPermissionDenied", {
37
+ permission: Schema.Literals<readonly ["menuBar", "shortcuts", "floating", "startAtLogin", "microphone", "camera", "systemAudio", "clipboardRead", "notifications"]>;
38
+ }>, Schema.TaggedStruct<"ShortcutTaken", {
39
+ accelerator: Schema.String;
40
+ }>, Schema.TaggedStruct<"DesktopInvalidInput", {
41
+ message: Schema.String;
42
+ }>, Schema.TaggedStruct<"SystemAudioBlocked", {}>]>;
43
+ type Same<A, B> = [A] extends [B] ? ([B] extends [A] ? true : false) : false;
44
+ /** Fails to compile when the decoder and the bridge contract's `DesktopBridgeFailure` differ. */
45
+ export declare const desktopBridgeRejectionMatchesContract: Same<typeof DesktopBridgeRejection.Type, DesktopBridgeFailure>;
46
+ export {};
@@ -0,0 +1,228 @@
1
+ /**
2
+ * Protocols between the Executor desktop app and the pages it shows. The desktop's preload exposes
3
+ * each bridge as one frozen global, only in windows it owns, and checks the page's exact origin on
4
+ * every call. Neither bridge carries credentials, file access or account choice.
5
+ */
6
+ /**
7
+ * A capability an installed app asks the person for, once, and keeps until they revoke it.
8
+ * `microphone` and `camera` gate `navigator.mediaDevices.getUserMedia`, `clipboardRead` gates
9
+ * `navigator.clipboard.readText()`, `systemAudio` gates `desktop.audio.system()`, and
10
+ * `startAtLogin` opens the app hidden when the person signs in to their computer.
11
+ */
12
+ export type DesktopPermission = "menuBar" | "shortcuts" | "floating" | "startAtLogin" | "microphone" | "camera" | "systemAudio" | "clipboardRead" | "notifications";
13
+ /** Every `DesktopPermission`, in the order the desktop lists them. */
14
+ export declare const desktopPermissions: readonly DesktopPermission[];
15
+ /**
16
+ * `prompt` asks on first use. `unavailable` means the page is not in an installed desktop window,
17
+ * or this platform has no such capability: `systemAudio` needs macOS 13 or Windows, and
18
+ * `startAtLogin` needs macOS, Windows or a Linux desktop that reads `~/.config/autostart`.
19
+ */
20
+ export type DesktopPermissionState = "granted" | "denied" | "prompt" | "unavailable";
21
+ /** Failures a bridge call rejects with, as plain tagged objects that cross the preload boundary. */
22
+ export type DesktopBridgeFailure = {
23
+ readonly _tag: "DesktopUnavailable";
24
+ } | {
25
+ readonly _tag: "DesktopPermissionDenied";
26
+ readonly permission: DesktopPermission;
27
+ } | {
28
+ readonly _tag: "ShortcutTaken";
29
+ readonly accelerator: string;
30
+ } | {
31
+ readonly _tag: "DesktopInvalidInput";
32
+ readonly message: string;
33
+ } | {
34
+ readonly _tag: "SystemAudioBlocked";
35
+ };
36
+ /** Longest menu-bar title, in characters. */
37
+ export declare const desktopMenuBarTitleMaxLength = 24;
38
+ /** Largest count `setBadge` shows. */
39
+ export declare const desktopBadgeMaximum = 99999;
40
+ /** Most extra windows one installed app holds open at once, besides its main window. */
41
+ export declare const desktopMaximumWindows = 8;
42
+ /** Smallest and largest size, in pixels, of a window `openWindow` opens. */
43
+ export declare const desktopWindowSize: {
44
+ readonly minimum: 200;
45
+ readonly maximum: 4096;
46
+ };
47
+ /** What a window `openWindow` opens looks like. Width and height default to 800 by 600. */
48
+ export interface DesktopWindowOptions {
49
+ readonly width?: number;
50
+ readonly height?: number;
51
+ /** Keep the window above other windows. Needs the `floating` permission. */
52
+ readonly floating?: boolean;
53
+ }
54
+ /** What happened to the window a page is in, as the `type` of a `desktopWindowEvent`. */
55
+ export type DesktopWindowEventType = "focus" | "blur";
56
+ /**
57
+ * The bridge in an installed app window or menu-bar popover, at `window[desktopAppBridgeGlobal]`.
58
+ * Authors use `desktop` from `apps/client`, which wraps it; they never read the global.
59
+ * Notifications use the standard `Notification` API; the desktop asks for the `notifications`
60
+ * permission in front of it.
61
+ */
62
+ export interface DesktopAppBridge {
63
+ readonly version: typeof desktopBridgeVersion;
64
+ readonly permission: (name: DesktopPermission) => Promise<DesktopPermissionState>;
65
+ /** Ask the person for a permission now if they have not answered, and resolve their choice. */
66
+ readonly requestPermission: (name: DesktopPermission) => Promise<DesktopPermissionState>;
67
+ /** Plain text up to `desktopMenuBarTitleMaxLength`; `null` restores the app's name. */
68
+ readonly setMenuBarTitle: (text: string | null) => Promise<void>;
69
+ /**
70
+ * Register a global shortcut in Electron accelerator syntax. When pressed, the page receives a
71
+ * `desktopShortcutEvent` `CustomEvent` on `window` whose `detail` is `{ id }`.
72
+ */
73
+ readonly registerShortcut: (accelerator: string) => Promise<{
74
+ readonly id: string;
75
+ }>;
76
+ readonly unregisterShortcut: (id: string) => Promise<void>;
77
+ readonly setFloating: (on: boolean) => Promise<void>;
78
+ /**
79
+ * The window the calling page is in: `show` makes it visible, `hide` hides it, `focus` shows it
80
+ * and brings it in front of every other app's windows, and `toggle` hides it when it is visible
81
+ * and focused and focuses it otherwise.
82
+ */
83
+ readonly windowAction: (action: "show" | "hide" | "focus" | "toggle") => Promise<void>;
84
+ /**
85
+ * Open another window of this app at a path on the app's own origin, or focus the window that
86
+ * already shows it. The window has this bridge too and closes with the app.
87
+ */
88
+ readonly openWindow: (path: string, options: DesktopWindowOptions) => Promise<void>;
89
+ /** A count from 1 to `desktopBadgeMaximum` on the app's icon; `null` or 0 removes it. */
90
+ readonly setBadge: (count: number | null) => Promise<void>;
91
+ /**
92
+ * Ask for the `systemAudio` permission and check the computer lets Executor record what it
93
+ * plays. Resolves when `getDisplayMedia` in this page will capture system audio.
94
+ */
95
+ readonly systemAudio: () => Promise<void>;
96
+ }
97
+ export declare const desktopAppBridgeGlobal = "__executorDesktop";
98
+ export declare const desktopShortcutEvent = "executor:desktop-shortcut";
99
+ /** Dispatched on `window` with `detail` `{ type: DesktopWindowEventType }`. */
100
+ export declare const desktopWindowEvent = "executor:desktop-window";
101
+ export declare const desktopBridgeVersion = 1;
102
+ /**
103
+ * `executor://app/<server>/<app>` opens an installed app; a path and query after the app's ID,
104
+ * such as `executor://app/<server>/<app>/notes/42?tab=edit`, open it at that path on its origin.
105
+ * A notification an app shows with `new Notification(title, { data: { path } })` opens that path
106
+ * the same way when the person clicks it.
107
+ */
108
+ export declare const desktopNotificationPathKey = "path";
109
+ /**
110
+ * An app on one account the desktop holds. `server` is the account's `id` (`DesktopAccount`): the
111
+ * server's ID from `/.well-known/executor` for this computer, `<server ID>.<organization ID>` for a
112
+ * team on a hosted server. App links use it as their `<server>` segment.
113
+ */
114
+ export interface DesktopAppRef {
115
+ readonly server: string;
116
+ readonly app: string;
117
+ }
118
+ export interface DesktopInstalledApp extends DesktopAppRef {
119
+ readonly name: string;
120
+ readonly installedAt: string;
121
+ }
122
+ /**
123
+ * The account a desktop dashboard window belongs to: this computer's own Executor, or one team on
124
+ * a hosted server. `id` is the server's ID for this computer and `<server ID>.<organization ID>` for
125
+ * a team, so several teams on one server are separate accounts.
126
+ */
127
+ export interface DesktopAccount {
128
+ readonly id: string;
129
+ readonly kind: "local" | "self-host" | "cloud";
130
+ readonly team: string;
131
+ readonly host: string;
132
+ /**
133
+ * `sign-in-again`: its sign-in ended and its apps stay closed until it signs in again.
134
+ * `unreachable`: its server did not answer the last time the desktop asked.
135
+ */
136
+ readonly state: "signed-in" | "sign-in-again" | "unreachable";
137
+ }
138
+ /**
139
+ * Where the dashboard's account button is, in CSS pixels of the page's viewport, so the desktop
140
+ * shows its own account menu above it. `settings` adds Account settings to the menu.
141
+ */
142
+ export interface DesktopAccountMenuOptions {
143
+ readonly anchor: {
144
+ readonly x: number;
145
+ readonly y: number;
146
+ readonly width: number;
147
+ readonly height: number;
148
+ };
149
+ readonly settings: boolean;
150
+ }
151
+ /**
152
+ * The bridge in the desktop's dashboard windows, at `window[desktopHostBridgeGlobal]`. The shared
153
+ * dashboard shows Install as app and the Desktop section only when it is present. `install` shows
154
+ * the desktop's own confirmation dialog and resolves `null` when the person cancels.
155
+ */
156
+ export interface DesktopHostBridge {
157
+ readonly version: typeof desktopBridgeVersion;
158
+ /** The account this dashboard window belongs to: a `DesktopAccount`'s `id`. */
159
+ readonly server: string;
160
+ readonly installed: (app: string) => Promise<DesktopInstalledApp | null>;
161
+ readonly install: (app: string) => Promise<DesktopInstalledApp | null>;
162
+ readonly uninstall: (app: string) => Promise<void>;
163
+ readonly open: (app: string) => Promise<void>;
164
+ readonly permissions: (app: string) => Promise<Record<DesktopPermission, DesktopPermissionState>>;
165
+ /**
166
+ * `denied` and `prompt` apply at once. `granted` shows the desktop's own permission prompt
167
+ * first, so a page can't grant an app anything the person did not allow there. Resolves the
168
+ * state the permission has afterwards.
169
+ */
170
+ readonly setPermission: (app: string, name: DesktopPermission, state: "granted" | "denied" | "prompt") => Promise<DesktopPermissionState>;
171
+ /** This window's own account. Desktops before accounts lack the three account members. */
172
+ readonly account?: () => Promise<DesktopAccount>;
173
+ /** Calls `listener` with this window's account whenever it changes, until the returned function runs. */
174
+ readonly watchAccount?: (listener: (account: DesktopAccount) => void) => () => void;
175
+ /**
176
+ * Calls `listener` with an app's ID whenever it is installed or removed on this desktop, however
177
+ * that happened, until the returned function runs.
178
+ */
179
+ readonly watchInstalled?: (listener: (app: string) => void) => () => void;
180
+ /**
181
+ * Show the desktop's own account menu, which lists every account on this computer and switches,
182
+ * adds, signs out of and removes them; the page never sees the other accounts. Resolves when the
183
+ * menu closes: `settings` when the person chose Account settings, which the page then opens.
184
+ */
185
+ readonly openAccountMenu?: (options: DesktopAccountMenuOptions) => Promise<"settings" | null>;
186
+ }
187
+ export declare const desktopHostBridgeGlobal = "__executorDesktopHost";
188
+ /**
189
+ * What `GET /.well-known/executor` answers on every Executor server, so a desktop can key it.
190
+ * `origins` names where each role is served: the dashboard with sign-in and session links, the
191
+ * API with its protected resource, and the OAuth issuer. One origin serves all three on local
192
+ * and self-host; Cloud splits them across hosts.
193
+ */
194
+ export interface ExecutorServerIdentity {
195
+ readonly serverId: string;
196
+ readonly kind: "local" | "self-host" | "cloud";
197
+ readonly origins: {
198
+ readonly dashboard: string;
199
+ readonly api: string;
200
+ readonly auth: string;
201
+ };
202
+ }
203
+ export declare const executorServerIdentityPath = "/.well-known/executor";
204
+ /**
205
+ * A browser dashboard's request that the desktop install one of its apps:
206
+ * `executor://install?server=<dashboard origin>&app=<app ID>`, with `&org=<organization ID>` for a
207
+ * hosted server. Any website can open such a link, so it carries no credential and grants
208
+ * nothing: the desktop confirms the server's identity at `server` and shows its own install
209
+ * dialog, and adding an unknown server shows the server form with that host first.
210
+ */
211
+ export interface DesktopInstallLink {
212
+ /** The dashboard's origin: `https://`, or `http://` on `localhost`, `127.0.0.1` or `[::1]`. */
213
+ readonly server: string;
214
+ readonly app: string;
215
+ readonly organization?: string;
216
+ /**
217
+ * The app's and its team's names as the dashboard showed them, so a desktop that cannot read
218
+ * them yet can say what the link asks. Any page can write them, so they only label a prompt.
219
+ */
220
+ readonly name?: string;
221
+ readonly team?: string;
222
+ }
223
+ export declare const desktopLinkProtocol = "executor";
224
+ export declare const loopbackHostname: (hostname: string) => boolean;
225
+ /** Build an install link, or `undefined` when its parts would not parse back. */
226
+ export declare const desktopInstallLink: (link: DesktopInstallLink) => string | undefined;
227
+ /** Read an install link strictly: any other part, repeated or unknown parameter is refused. */
228
+ export declare const parseDesktopInstallLink: (value: string) => DesktopInstallLink | undefined;
@@ -5,7 +5,10 @@ export declare const AppSignInId: Schema.brand<Schema.String, "AppSignInId">;
5
5
  export type AppSignInId = typeof AppSignInId.Type;
6
6
  /** Authentication proofs are redacted at the HTTP boundary. */
7
7
  export declare const AppSignInCode: Schema.RedactedFromValue<Schema.String>;
8
- /** A path on the current app origin, including its query and fragment; never a redirect to another host or host-owned route. */
8
+ /**
9
+ * A path on the current app origin, including its query and fragment; never a redirect to another
10
+ * host or host-owned route, except the menu-bar page, which renders the app like its main page.
11
+ */
9
12
  export declare const AppReturnPath: Schema.brand<Schema.String, "AppReturnPath">;
10
13
  export type AppReturnPath = typeof AppReturnPath.Type;
11
14
  /** Callback query on the app origin. The code is single-use and works only with its attempt's cookie. */
@@ -24,6 +24,48 @@ export interface UiAccountNotice {
24
24
  /** The app's accounts in the dashboard. */
25
25
  readonly fix: string;
26
26
  }
27
+ /**
28
+ * The pages a host can open for an app: the source file that defines each, and where the build
29
+ * retains it. `main` is the app's page in a browser tab or an installed window; `menuBar` is the
30
+ * desktop menu-bar popover. Retained pages outside `index.html` sit under the host-owned
31
+ * `_executor/` prefix, which neither compiled output nor public files can use.
32
+ */
33
+ export declare const appUiDocuments: {
34
+ readonly main: {
35
+ readonly source: "ui/index.html";
36
+ readonly asset: "index.html";
37
+ };
38
+ readonly menuBar: {
39
+ readonly source: "ui/menubar.html";
40
+ readonly asset: "_executor/menubar.html";
41
+ };
42
+ };
43
+ export type AppUiDocument = keyof typeof appUiDocuments;
44
+ /** The app's icon, for desktop launchers, windows and the menu bar. */
45
+ export declare const appUiIcon: {
46
+ readonly source: "ui/icon.svg";
47
+ readonly asset: "_executor/icon.svg";
48
+ };
49
+ /**
50
+ * Which optional pages a build retained, written beside them so a host learns this from one read.
51
+ * Builds from before it have only the main page.
52
+ */
53
+ export declare const appUiPagesAsset = "_executor/pages.json";
54
+ export declare const AppUiPagesManifest: Schema.Struct<{
55
+ readonly menuBar: Schema.Boolean;
56
+ readonly icon: Schema.Boolean;
57
+ }>;
58
+ /** What a version's retained UI has: its main page, menu-bar page and icon. */
59
+ export interface AppUiPages {
60
+ readonly main: boolean;
61
+ readonly menuBar: boolean;
62
+ readonly icon: boolean;
63
+ }
64
+ /** Where an app's origin serves its menu-bar page and its icon. */
65
+ export declare const appMenuBarRoute = "/_executor/menubar";
66
+ export declare const appIconRoute = "/_executor/icon.svg";
67
+ /** Bytes an icon may contain. */
68
+ export declare const appUiIconMaxBytes: number;
27
69
  /** Retained browser bytes. Hosts authorize access before reading or rendering them. */
28
70
  export interface AppUiFile {
29
71
  readonly body: Uint8Array;
@@ -127,4 +169,4 @@ export declare const AppUiApi: HttpApi.HttpApi<"app-ui", HttpApiGroup.HttpApiGro
127
169
  } | {
128
170
  readonly type: "heartbeat";
129
171
  }>, Schema.toCodecJson<typeof UiUnauthorized | typeof UiForbidden | typeof UiVersionChanged | typeof UiFailed>, never, never>, false>>;
130
- export {};
172
+ export * from "./desktop.js";
@@ -0,0 +1,85 @@
1
+ import { type DesktopPermission, type DesktopPermissionState, type DesktopWindowOptions } from "../contracts/desktop.js";
2
+ /**
3
+ * Capabilities of the Executor desktop app, for a page shown in an installed app window or its
4
+ * menu-bar popover. In any other page `available` is false, `permission` resolves `"unavailable"`
5
+ * and every other call rejects with `DesktopUnavailable`. Calls that need a permission ask the
6
+ * person the first time and reject with `DesktopPermissionDenied` when they decline.
7
+ */
8
+ export declare const desktop: {
9
+ /** Whether this page is in an installed Executor desktop window. */
10
+ readonly available: boolean;
11
+ /** The person's choice for one capability, without asking them. */
12
+ permission: (name: DesktopPermission) => Promise<DesktopPermissionState>;
13
+ /**
14
+ * Ask the person for one capability now, if they have not answered yet, and resolve their
15
+ * choice; a refusal resolves `"denied"` rather than rejecting. Use it for `startAtLogin`, which
16
+ * no other call asks for, or to ask for the microphone before a recording starts.
17
+ */
18
+ requestPermission: (name: DesktopPermission) => Promise<DesktopPermissionState>;
19
+ menuBar: {
20
+ /**
21
+ * Show plain text for the app in the menu bar, at most `desktopMenuBarTitleMaxLength`
22
+ * characters. `null` restores the app's name. Needs the `menuBar` permission.
23
+ */
24
+ setTitle: (text: string | null) => Promise<void>;
25
+ };
26
+ shortcuts: {
27
+ /**
28
+ * Call `handler` whenever the person presses `accelerator` anywhere on their computer, in
29
+ * Electron accelerator syntax such as `"CommandOrControl+Shift+K"`. Resolves a function that
30
+ * removes the shortcut through the desktop window that registered it. The shortcut stays held,
31
+ * and `handler` keeps running, until that function resolves; when it rejects, call it again.
32
+ * Needs the `shortcuts` permission; rejects with `ShortcutTaken` when another program holds
33
+ * the keys.
34
+ */
35
+ register: (accelerator: string, handler: () => void) => Promise<() => Promise<void>>;
36
+ };
37
+ window: {
38
+ /** Keep the app's window above other windows, or stop. Needs the `floating` permission. */
39
+ setFloating: (on: boolean) => Promise<void>;
40
+ /** Make the window this page is in visible. */
41
+ show: () => Promise<void>;
42
+ /** Hide the window this page is in. The app keeps running, and its page keeps running. */
43
+ hide: () => Promise<void>;
44
+ /**
45
+ * Show the window this page is in and bring it in front of every other app's windows, such as
46
+ * from a global shortcut's handler.
47
+ */
48
+ focus: () => Promise<void>;
49
+ /** Hide the window when it is visible and focused; otherwise show and focus it. */
50
+ toggle: () => Promise<void>;
51
+ /**
52
+ * Open another window of this app at `path`, such as `"/compose?to=ada"`, on the app's own
53
+ * origin, or focus the window that already shows that path. The window has `desktop` too, with
54
+ * the same permissions, and closes when the app quits. At most `desktopMaximumWindows` are
55
+ * open at once; `floating` needs the `floating` permission.
56
+ */
57
+ open: (path: string, options?: DesktopWindowOptions) => Promise<void>;
58
+ /**
59
+ * Call `handler` whenever the window this page is in loses focus, such as to hide a window a
60
+ * shortcut summoned. Returns a function that stops listening. Does nothing outside an
61
+ * installed Executor desktop window.
62
+ */
63
+ onBlur: (handler: () => void) => (() => void);
64
+ /** Call `handler` whenever the window this page is in gains focus. */
65
+ onFocus: (handler: () => void) => (() => void);
66
+ };
67
+ badge: {
68
+ /**
69
+ * Show a count on the app's icon: on Windows, on the app's own taskbar button; on macOS and
70
+ * Linux, installed apps share Executor's Dock or launcher icon, which shows the sum of their
71
+ * counts. `null` or 0 removes the app's count. Needs no permission.
72
+ */
73
+ set: (count: number | null) => Promise<void>;
74
+ };
75
+ audio: {
76
+ /**
77
+ * Everything playing on this computer, such as the other people in a call, as an audio-only
78
+ * `MediaStream`. Asks for the `systemAudio` permission the first time. Rejects with
79
+ * `SystemAudioBlocked` when macOS has not allowed Executor to record the screen and system
80
+ * audio, after offering to open System Settings, and with `DesktopUnavailable` where the
81
+ * computer cannot capture system audio (Linux, macOS before 13). Stop its tracks when done.
82
+ */
83
+ system: () => Promise<MediaStream>;
84
+ };
85
+ };
@@ -1,6 +1,6 @@
1
1
  import { Effect, Option, Stream } from "effect";
2
2
  import { HttpServerRequest, HttpServerResponse } from "effect/http";
3
- import { UiFailed, UiForbidden, type AppUiAsset, type AppUiRange, type AppUiStoredFile, type UiAccountNotice } from "../contracts/ui.js";
3
+ import { type AppUiPages, UiFailed, type AppUiDocument, UiForbidden, type AppUiAsset, type AppUiRange, type AppUiStoredFile, type UiAccountNotice } from "../contracts/ui.js";
4
4
  /**
5
5
  * The version's public file a page path names, or a 404 for a missing file. `None` means the path
6
6
  * is the page itself. Hosts answer files before the page's account and usage work, which a file
@@ -17,6 +17,8 @@ export declare const appFile: <E, R>(options: {
17
17
  */
18
18
  export declare const appDocument: <E, R>(options: {
19
19
  readonly version: string;
20
+ /** Which of the app's pages to render; the main page when absent. */
21
+ readonly document?: AppUiDocument | undefined;
20
22
  /** The account IDs the page runs with, by requirement. */
21
23
  readonly accountIds?: Readonly<Record<string, readonly string[]>> | undefined;
22
24
  readonly accounts?: UiAccountNotice | undefined;
@@ -33,6 +35,16 @@ export declare const storedAppFile: <E1, E2>(stored: {
33
35
  }, read: (range: AppUiRange | undefined) => Effect.Effect<Option.Option<{
34
36
  readonly body: Stream.Stream<Uint8Array, E1>;
35
37
  }>, E2>) => AppUiStoredFile;
38
+ /**
39
+ * The app's icon. The response forbids scripts and outside loads, so opening the URL shows only
40
+ * the drawing; desktops render it as an image, which runs nothing either.
41
+ */
42
+ export declare const appIcon: (asset: AppUiAsset | undefined, build: string) => Effect.Effect<HttpServerResponse.HttpServerResponse, UiFailed, HttpServerRequest.HttpServerRequest>;
43
+ /**
44
+ * What a version's retained UI has, from its pages manifest, or from its main page for a build
45
+ * that predates the manifest.
46
+ */
47
+ export declare const appUiPages: <E, R>(asset: (path: string) => Effect.Effect<AppUiAsset | undefined, E, R>) => Effect.Effect<AppUiPages, E | UiFailed, R>;
36
48
  /** The file a URL path names: each segment percent-decoded, or none when one does not decode. */
37
49
  export declare const assetPath: (path: string) => Option.Option<string>;
38
50
  /** Serve an asset only after the host has checked current access and file existence.
@@ -1,7 +1,36 @@
1
1
  import { AsyncResult, type Atom } from "effect/reactivity";
2
+ import type { DesktopPermission, DesktopPermissionState } from "./contracts/desktop.js";
2
3
  /** Subscribe for the component lifetime. Each mount owns and disposes its registry, including StrictMode remounts. */
3
4
  export declare const useAppQuery: <A, E>(atom: Atom.Atom<AsyncResult.AsyncResult<A, E>>) => {
4
5
  data: A | undefined;
5
6
  pending: boolean;
6
7
  error: string | undefined;
7
8
  };
9
+ /**
10
+ * Hold a global desktop shortcut while the component is mounted, calling the latest `handler` on
11
+ * each press. Does nothing outside an installed Executor desktop window. Registering and removing
12
+ * one accelerator happen in order, so a remount or a changed accelerator never races its earlier
13
+ * registration; a removal the desktop refused is tried again before the next registration. Returns
14
+ * why the latest registration failed, such as `ShortcutTaken` or `DesktopPermissionDenied` from
15
+ * `apps/client`, or `undefined`.
16
+ */
17
+ export declare const useDesktopShortcut: (accelerator: string, handler: () => void) => unknown;
18
+ /**
19
+ * The person's choice for one desktop permission, read when the component mounts and again each
20
+ * time its window gains focus, since they can change it in the app's menu or the dashboard.
21
+ * `undefined` until the first read; `"unavailable"` outside an installed Executor desktop window.
22
+ */
23
+ export declare const useDesktopPermission: (name: DesktopPermission) => DesktopPermissionState | undefined;
24
+ /**
25
+ * Show `count` on the app's icon while the component is mounted (see `desktop.badge.set`), and
26
+ * remove it on unmount. Does nothing outside an installed Executor desktop window. Returns why the
27
+ * latest change failed, such as `DesktopInvalidInput` from `apps/client`, or `undefined`.
28
+ */
29
+ export declare const useDesktopBadge: (count: number | null) => unknown;
30
+ /**
31
+ * Call the latest `handler` whenever this page's desktop window loses focus (`"blur"`) or gains
32
+ * it (`"focus"`), while the component is mounted. Does nothing outside an installed Executor
33
+ * desktop window. Hide a summoned window on blur with
34
+ * `useDesktopWindowEvent("blur", () => void desktop.window.hide())`.
35
+ */
36
+ export declare const useDesktopWindowEvent: (type: "focus" | "blur", handler: () => void) => void;
@@ -1,2 +1,2 @@
1
1
  /** Host-only rendering utilities; the host supplies authorized retained assets. */
2
- export { appDocument, appAsset, appFile, assetPath, storedAppFile, } from "./implementation/ui-serving.js";
2
+ export { appDocument, appAsset, appIcon, appUiPages, appFile, assetPath, storedAppFile, } from "./implementation/ui-serving.js";