@acryldev/launcher-desktop 0.1.8 → 0.1.10

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.
@@ -15,6 +15,8 @@ export interface LauncherApi {
15
15
  start(id: string): Promise<StateResponse>;
16
16
  /** Bring the newer release of the app's Blend into it, keeping the person's changes. */
17
17
  update(id: string): Promise<StateResponse>;
18
+ /** Update this app itself to its Blend's newer release. */
19
+ updateSelf(): Promise<StateResponse>;
18
20
  stop(id: string): Promise<StateResponse>;
19
21
  /** ACRYL ADE in a window (`desktop`) or the browser (`web`); made the first time (about a minute). */
20
22
  openAde(surface: 'web' | 'desktop'): Promise<StateResponse>;
@@ -1,5 +1,5 @@
1
1
  /** What the screen shows, worked out from the Host's list: pure functions, no DOM (Clean Code: the view only draws these). */
2
- import type { AppView, Surface } from '../contract.ts';
2
+ import type { AppView, BlendView, Surface } from '../contract.ts';
3
3
  export type SurfaceFilter = 'all' | Surface;
4
4
  export interface Tiles {
5
5
  readonly apps: number;
@@ -21,4 +21,20 @@ export declare const initial: (name: string) => string;
21
21
  /** The line a person types to start the app in a terminal: shown on the card's panel as "Runs". */
22
22
  export declare const runsLine: (app: AppView) => string;
23
23
  /** A name for an app made from a registry id: its last part (`acrylblends.notes-desktop` gives `notes-desktop`), the same rule as the terminal's. */
24
+ /**
25
+ * The folder (and id) a name makes: any name a person types ("ACRYL ADE (EB)") becomes lower case letters, digits and dashes, starting with a
26
+ * letter ("acryl-ade-eb"), the form `acryl new` and npm accept. Empty when the name has no letter or digit to keep.
27
+ */
28
+ export declare const folderName: (text: string) => string;
24
29
  export declare const blendAppName: (id: string) => string;
30
+ export interface StoreSubcategory {
31
+ readonly name: string;
32
+ readonly count: number;
33
+ }
34
+ export interface StoreCategory {
35
+ readonly name: string;
36
+ readonly count: number;
37
+ readonly subs: readonly StoreSubcategory[];
38
+ }
39
+ /** The store's categories that hold at least one of `blends`, in the store's own order, each with its subcategories (by name) and counts. */
40
+ export declare function storeCategories(blends: readonly BlendView[]): readonly StoreCategory[];
@@ -9,6 +9,8 @@ export declare const LAUNCHER_NEW_PATH = "/api/acryl-launcher/new";
9
9
  export declare const LAUNCHER_START_PATH = "/api/acryl-launcher/start";
10
10
  export declare const LAUNCHER_STOP_PATH = "/api/acryl-launcher/stop";
11
11
  export declare const LAUNCHER_UPDATE_PATH = "/api/acryl-launcher/update";
12
+ /** Update the Control Center itself (the Blend copy it runs from) to its Blend's newer release. */
13
+ export declare const LAUNCHER_UPDATE_SELF_PATH = "/api/acryl-launcher/update-self";
12
14
  /** Open ACRYL ADE (the Blend `acryl.ade` in `<home>/ade`, the folder `acryl ade` uses), made on first use, in a window or the browser. */
13
15
  export declare const LAUNCHER_ADE_PATH = "/api/acryl-launcher/ade";
14
16
  export declare const LAUNCHER_BLENDS_PATH = "/api/acryl-launcher/blends";
@@ -54,6 +56,15 @@ export interface AppView {
54
56
  }
55
57
  /** WebBoxes.ai's New WebBox form, opened with the app's repository filled in (the person signs in and presses Create there). */
56
58
  export declare function webboxesDeployUrl(github: string, name: string): string;
59
+ /**
60
+ * WebBoxes.ai's New WebBox form for a store Blend: with `?blend=<id>` the form opens on that registry Blend (the person signs in and presses
61
+ * Create there). A community Blend that lives on GitHub rather than in the registry (`source` is `github:owner/repo#tag`) deploys from its
62
+ * repository, as a shared app does.
63
+ */
64
+ export declare function webboxesDeployBlendUrl(blend: {
65
+ readonly id: string;
66
+ readonly source?: string | undefined;
67
+ }): string;
57
68
  export interface StarterView {
58
69
  readonly value: string;
59
70
  readonly label: string;
@@ -81,6 +92,20 @@ export interface StateResponse {
81
92
  readonly appsFolder: string;
82
93
  readonly starters: readonly StarterView[];
83
94
  readonly job: JobView | null;
95
+ /** This app itself, when it runs from a Blend copy it can update and there is something to say: a newer release, an update running, done or failed. */
96
+ readonly self?: SelfView;
97
+ }
98
+ export interface SelfView {
99
+ /** The name a person reads: "ACRYL Control Center". */
100
+ readonly name: string;
101
+ /** The release the copy has now. */
102
+ readonly version: string;
103
+ /** The newer release (`available`), or the one being or just brought in. */
104
+ readonly update: string;
105
+ readonly status: 'available' | 'updating' | 'done' | 'failed';
106
+ readonly since?: number;
107
+ /** The update's last lines of output (`updating`, `failed`). */
108
+ readonly output?: string;
84
109
  }
85
110
  export interface HealthView {
86
111
  /** `undefined` when the command was not found on this machine. */
@@ -104,6 +129,17 @@ export interface BlendView {
104
129
  readonly source?: string;
105
130
  /** A community Blend's GitHub owner, shown as "by @owner". */
106
131
  readonly publisher?: string;
132
+ /** Where the store files it (the registry's placement.json): its category and subcategory; `order` is the category's place in the store's list. */
133
+ readonly place?: BlendPlace;
134
+ /** Its page on the store (https), when the registry names one. */
135
+ readonly page?: string;
136
+ /** A picture of its first page (https), when the Blend has one. */
137
+ readonly screenshot?: string;
138
+ }
139
+ export interface BlendPlace {
140
+ readonly category: string;
141
+ readonly subcategory: string;
142
+ readonly order: number;
107
143
  }
108
144
  export interface BlendsResponse {
109
145
  readonly blends: readonly BlendView[];
@@ -3,6 +3,8 @@ import { type BlendView } from './contract.ts';
3
3
  export declare const REGISTRY_INDEX = "https://acrylblends.github.io/registry/index.json";
4
4
  /** Blends released by people outside the ACRYL project and found on GitHub by the registry's hourly sync (origin `community`, each with its `source`). */
5
5
  export declare const REGISTRY_DISCOVERED = "https://acrylblends.github.io/registry/discovered.json";
6
+ /** Where the store files each Blend (category, subcategory, its page, its screenshot) and the store's categories in order; the website writes it. */
7
+ export declare const REGISTRY_PLACEMENT = "https://acrylblends.github.io/registry/placement.json";
6
8
  export declare class RegistryUnavailable extends Error {
7
9
  }
8
10
  type Fetch = (input: string, init?: {
@@ -16,5 +18,5 @@ type Fetch = (input: string, init?: {
16
18
  * The Blends an ACRYL app can be made from (registry entries whose runtime is `acrylblends`), by name: the public registry's, and the community ones
17
19
  * the registry found on GitHub (made from their `source`). The community list is optional: when it cannot be read, the store still lists the rest.
18
20
  */
19
- export declare function readBlends(fetchImpl?: Fetch, url?: string, discovered?: string | undefined): Promise<readonly BlendView[]>;
21
+ export declare function readBlends(fetchImpl?: Fetch, url?: string, discovered?: string | undefined, placement?: string | undefined): Promise<readonly BlendView[]>;
20
22
  export {};
@@ -0,0 +1,43 @@
1
+ import type { SelfView } from './contract.ts';
2
+ /** The command that updates an app from its Blend's newer release (as the service's `update`). */
3
+ export declare const SELF_UPDATE_SPEC = "acrylblends@latest";
4
+ export interface SelfFiles {
5
+ readonly read: (path: string) => string | undefined;
6
+ readonly write: (path: string, text: string) => void;
7
+ readonly remove: (path: string) => void;
8
+ /** When a file was last written (ms since epoch), or undefined when it is not there. */
9
+ readonly modified: (path: string) => number | undefined;
10
+ }
11
+ /** The copy this app runs from: its folder, the name a person reads, and the Blend and version it was made from. */
12
+ export interface SelfCopy {
13
+ readonly folder: string;
14
+ readonly name: string;
15
+ readonly blend: string;
16
+ readonly version: string;
17
+ }
18
+ /** The Blend and version a copy was made from: package.json's `acryl.from` (`acryl.control-center#0.2.14`), which create-acrylblends writes. */
19
+ export declare function originOf(packageText: string | undefined): {
20
+ blend: string;
21
+ version: string;
22
+ } | undefined;
23
+ /**
24
+ * Where the copy stands: up to date (`undefined` when there is nothing to say), a newer release out, an update running, done (until this app is opened
25
+ * again: `startedAt` is when this process began), or failed. `version` is what the copy has now (blend.yaml's `metadata.version`, which the merge moves).
26
+ */
27
+ export declare function selfView(copy: SelfCopy, latest: string | undefined, files: SelfFiles, home: string, startedAt: number, newer: (a: string, b: string) => boolean): SelfView | undefined;
28
+ /**
29
+ * The command that updates the copy, detached (its output goes to a file, so it outlives the service and this app's reload): node runs
30
+ * `npm exec acrylblends@latest -- update` in the copy and writes its exit code to the end file. Records the start first.
31
+ */
32
+ export declare function selfUpdateCommand(copy: SelfCopy, to: string, files: SelfFiles & {
33
+ makeFolder: (path: string) => void;
34
+ }, home: string, now: number): {
35
+ program: string;
36
+ args: string[];
37
+ cwd: string;
38
+ log: string;
39
+ };
40
+ /** The record's files on this machine's disk. */
41
+ export declare const nodeSelfFiles: SelfFiles & {
42
+ makeFolder: (path: string) => void;
43
+ };
@@ -1,6 +1,7 @@
1
1
  import type { GithubPollView, GithubStartView, GithubView, AppSharePlanRequest, AppSharePlanView, AppShareRequest, AppShareResponse, AppView, BlendView, HealthView, NewAppRequest, PluginPullResponse, PluginView, PublishPlanRequest, PublishPlanView, PublishRequest, PublishResponse, StateResponse, Surface } from './contract.ts';
2
2
  import { type Door } from './door.ts';
3
3
  import { type Runner } from './runner.ts';
4
+ import { type SelfFiles } from './self-update.ts';
4
5
  /** A request the service cannot honour, in a sentence a person can act on. The route answers it as 409. */
5
6
  export declare class LauncherRefusal extends Error {
6
7
  }
@@ -23,6 +24,16 @@ export interface LauncherPorts {
23
24
  * computer's own tools are used as they are (tests, and a launcher run from a terminal).
24
25
  */
25
26
  readonly prepareTools?: () => Promise<readonly string[]>;
27
+ /**
28
+ * This app's own copy, when it runs from one it can update (`acryl --gui` keeps the Blend in `~/.acryl/control-center`): its folder and name, how to
29
+ * read and write the update's record, and when this process began (an update finished before it is the release that runs now).
30
+ */
31
+ readonly self?: {
32
+ readonly folder: string;
33
+ readonly name: string;
34
+ readonly files: SelfFiles;
35
+ readonly startedAt: number;
36
+ };
26
37
  }
27
38
  export declare class LauncherService {
28
39
  #private;
@@ -48,6 +59,11 @@ export declare class LauncherService {
48
59
  * install). A running app is stopped first and started again after.
49
60
  */
50
61
  update(id: string): void;
62
+ /**
63
+ * Update this app itself to its Blend's newer release: `acrylblends update` in its own folder, detached, so it finishes even when this plugin is reloaded
64
+ * by the change it brings. The new release runs once the app is opened again.
65
+ */
66
+ updateSelf(): void;
51
67
  /**
52
68
  * When this app quits (or the plugin unloads): stop everything it started, except a Desktop app whose window is open. That window is the person's
53
69
  * own, and closing it stops the app; a Web app has no window, so it would run on unseen. Returns the names of the apps left open.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acryldev/launcher-desktop",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "The ACRYL screen of the desktop app (spec 050): every app made with ACRYL on this machine, the surface of each (Web, Desktop, CLI/TUI), and New app, Add a folder, Start and Stop. The Host half serves the list and runs the commands; the Client half draws the Control Center design as the first screen",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -48,8 +48,8 @@
48
48
  "node": "^22.19.0 || >=24.0.0"
49
49
  },
50
50
  "dependencies": {
51
- "@acryldev/blends": "^1.7.17",
52
- "@acryldev/control": "0.3.0",
51
+ "@acryldev/blends": "^1.7.30",
52
+ "@acryldev/control": "0.3.1",
53
53
  "@acryldev/launcher": "0.1.4",
54
54
  "@acryldev/loopback-http": "0.2.1"
55
55
  },
@@ -59,7 +59,7 @@
59
59
  "react": "18.3.1"
60
60
  },
61
61
  "devDependencies": {
62
- "@acryldev/blends": "^1.7.17",
62
+ "@acryldev/blends": "^1.7.30",
63
63
  "@acryldev/ui": "0.4.0",
64
64
  "@deepseek-ai/cordis": "4.0.4",
65
65
  "@deepseek-ai/dsh-client-modules": "0.2.0-rc.2",
@@ -1 +0,0 @@
1
- {"version":3,"file":"node-gnGasVKs.js","names":["TIMEOUT_MS","#ports","#started","#failures","#installing","#tools","#blends","#view","#job","#toolsReady","#installThenStart","#environment","#appLog","#watch","#door","#entry","#checkPublish","#options","#shareCommand","#signIn","#note","#finish","#install"],"sources":["../src/contract.ts","../src/door.ts","../src/registry.ts","../src/runner.ts","../src/service.ts","../src/node.ts"],"sourcesContent":["/** The wire contract of the ACRYL screen's routes (the desktop face of the launcher, spec 050 T012). The screen is the client of these routes. */\n\n/** Every launcher route lives under this prefix, the one the Host's Web adapter mounts for this plugin. */\nexport const LAUNCHER_API_PREFIX = '/api/acryl-launcher'\nexport const LAUNCHER_STATE_PATH = `${LAUNCHER_API_PREFIX}/state`\nexport const LAUNCHER_HEALTH_PATH = `${LAUNCHER_API_PREFIX}/health`\nexport const LAUNCHER_ADD_PATH = `${LAUNCHER_API_PREFIX}/add`\nexport const LAUNCHER_REMOVE_PATH = `${LAUNCHER_API_PREFIX}/remove`\nexport const LAUNCHER_NEW_PATH = `${LAUNCHER_API_PREFIX}/new`\nexport const LAUNCHER_START_PATH = `${LAUNCHER_API_PREFIX}/start`\nexport const LAUNCHER_STOP_PATH = `${LAUNCHER_API_PREFIX}/stop`\nexport const LAUNCHER_UPDATE_PATH = `${LAUNCHER_API_PREFIX}/update`\n/** Open ACRYL ADE (the Blend `acryl.ade` in `<home>/ade`, the folder `acryl ade` uses), made on first use, in a window or the browser. */\nexport const LAUNCHER_ADE_PATH = `${LAUNCHER_API_PREFIX}/ade`\nexport const LAUNCHER_BLENDS_PATH = `${LAUNCHER_API_PREFIX}/blends`\nexport const LAUNCHER_ASSISTANT_FOLDER_PATH = `${LAUNCHER_API_PREFIX}/assistant-folder`\nexport const LAUNCHER_PLUGINS_PATH = `${LAUNCHER_API_PREFIX}/plugins`\nexport const LAUNCHER_PLUGIN_PULL_PATH = `${LAUNCHER_API_PREFIX}/plugin-pull`\nexport const LAUNCHER_PUBLISH_PLAN_PATH = `${LAUNCHER_API_PREFIX}/publish-plan`\nexport const LAUNCHER_PUBLISH_PATH = `${LAUNCHER_API_PREFIX}/publish`\nexport const LAUNCHER_SHARE_PLAN_PATH = `${LAUNCHER_API_PREFIX}/share-plan`\nexport const LAUNCHER_SHARE_PATH = `${LAUNCHER_API_PREFIX}/share`\nexport const LAUNCHER_GITHUB_PATH = `${LAUNCHER_API_PREFIX}/github`\nexport const LAUNCHER_GITHUB_START_PATH = `${LAUNCHER_API_PREFIX}/github-start`\nexport const LAUNCHER_GITHUB_POLL_PATH = `${LAUNCHER_API_PREFIX}/github-poll`\nexport const LAUNCHER_GITHUB_DISCONNECT_PATH = `${LAUNCHER_API_PREFIX}/github-disconnect`\n\n/** The three kinds of app (spec 050 D10): a web app, a desktop window, and the lightest, a terminal app, which is listed but not yet made. */\nexport type Surface = 'web' | 'desktop' | 'tui'\nexport const SURFACES: readonly Surface[] = ['web', 'desktop', 'tui']\n/** Surfaces a person can choose for a new app today. */\nexport const MAKEABLE_SURFACES: readonly Surface[] = ['web', 'desktop']\n\n/** `starting` is a started app that has not printed its address yet; `missing` is a listed app whose folder is gone. */\nexport type AppRunState = 'running' | 'starting' | 'stopped' | 'missing'\n\nexport interface AppView {\n readonly id: string\n /** The folder's name: what a person calls the app. */\n readonly name: string\n readonly path: string\n readonly blend: string\n readonly madeBy: 'person' | 'agent'\n readonly surface: Surface\n readonly state: AppRunState\n /** Where a running web app answers, with the token it printed. */\n readonly address?: string\n /** While the app is starting: the last lines it printed, live. */\n readonly output?: string\n /** Why the app stopped on its own, when it did (the last lines it printed). */\n readonly failure?: string\n /** The version of the Blend it was made from (its blend.yaml), when it records one. */\n readonly version?: string\n /** A newer release of that Blend in the registry: `acrylblends update` brings it in, keeping the person's changes. */\n readonly update?: string\n /** Where the app was shared to (`https://github.com/<owner>/<repo>`), from its origin remote; what WebBoxes.ai deploys from. */\n readonly github?: string\n}\n\n/** WebBoxes.ai's New WebBox form, opened with the app's repository filled in (the person signs in and presses Create there). */\nexport function webboxesDeployUrl(github: string, name: string): string {\n const url = new URL(WEBBOXES_NEW_BOX)\n url.searchParams.set('github', github)\n url.searchParams.set('name', name.toLowerCase().replace(/[^a-z0-9-]+/gu, '-').replace(/^-+|-+$/gu, '').slice(0, 40))\n return url.href\n}\n\nexport interface StarterView {\n readonly value: string\n readonly label: string\n readonly description: string\n}\n\n/** The one app the screen is making right now (making an app installs it, about a minute). */\nexport interface JobView {\n readonly name: string\n /** Making a new app, or updating one from its Blend's newer release. */\n readonly kind: 'make' | 'update'\n /** The line a person types to do the same. */\n readonly line: string\n readonly status: 'running' | 'done' | 'failed'\n /** Which step it is on and what comes next, e.g. \"Step 2 of 3: installing its dependencies (npm install). Next: starting it.\" */\n readonly step: string\n /** When the job began (ms since epoch), so the screen can show how long it has run. */\n readonly since: number\n /** The last lines the current step printed, live. */\n readonly output: string\n readonly message?: string\n}\n\nexport interface StateResponse {\n readonly apps: readonly AppView[]\n /** Where \"+ New app\" suggests putting a new app (a visible folder next to ACRYL's hidden home). */\n readonly appsFolder: string\n readonly starters: readonly StarterView[]\n readonly job: JobView | null\n}\n\nexport interface HealthView {\n /** `undefined` when the command was not found on this machine. */\n readonly node?: string\n readonly npm?: string\n /** The model key is saved once for every app (`acryl model`). */\n readonly modelKey: boolean\n readonly home: string\n}\n\n/** A Blend in the public registry (acrylblends.github.io/registry/index.json) that `acryl new --from <id>` can make an app from. */\nexport interface BlendView {\n /** `acrylblends.notes`: what `--from` takes. */\n readonly id: string\n readonly name: string\n readonly version: string\n readonly category: string\n readonly description: string\n /** Who released it: the ACRYL project (`official`) or anyone else (`community`, not reviewed); the registry's `origin`. */\n readonly origin: 'official' | 'community'\n /** A community Blend's release on GitHub (`github:owner/repo#tag`), what `--from` takes for a Blend outside the public registry; absent: `--from <id>`. */\n readonly source?: string\n /** A community Blend's GitHub owner, shown as \"by @owner\". */\n readonly publisher?: string\n}\n\nexport interface BlendsResponse {\n readonly blends: readonly BlendView[]\n}\n\n/** A Blend id as `acryl new --from` takes it: it starts with a letter or digit, so it can never read as an option. */\n/** WebBoxes.ai's WebBoxes page: with `github` (a public https://github.com/owner/repo) and `name` it opens the New WebBox form filled in. */\nexport const WEBBOXES_NEW_BOX = 'https://webboxes.ai/dashboard/webboxes'\n\nexport const BLEND_ID = /^[a-z0-9][a-z0-9._-]{0,127}$/u\n\n/** A Blend released on GitHub, as `--from` takes it (create-acrylblends `github:owner/repo#ref`): what a community Blend is made from. */\nexport const BLEND_SOURCE = /^github:[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})\\/[A-Za-z0-9._-]{1,100}(?:#[A-Za-z0-9._/-]{1,100})?$/u\n\n/** The app to make: from a starter (`acryl new <name> <starter>`) or from a registry Blend (`acryl new <name> --from <id>`), never both. */\nexport interface NewAppRequest {\n readonly where: string\n readonly name: string\n readonly starter?: string\n readonly blend?: string\n readonly surface: Surface\n}\n\n/** A plugin of a running app, as the app's door lists it: one the app's own people made, or one pulled from a registry (`pulledFrom`). */\nexport interface PluginView {\n readonly name: string\n readonly version: string\n readonly state: string\n /** `github:owner/repo@version` when it was pulled; absent for a plugin made in the app (the ones that can be shared). */\n readonly pulledFrom?: string\n readonly author?: string\n}\n\nexport interface PluginsResponse {\n readonly plugins: readonly PluginView[]\n}\n\n/** What pulling a plugin did, in the door's words. */\nexport interface PluginPullResponse {\n readonly text: string\n readonly plugins: readonly PluginView[]\n}\n\n/** What publishing a plugin would send, read without sending anything: the person reads this before saying yes. */\nexport interface PublishPlanView {\n readonly owner: string\n readonly repo: string\n readonly version: string\n readonly visibility: string\n readonly license: string\n readonly createsRepository: boolean\n readonly files: readonly string[]\n readonly integrity: string\n readonly digest: string\n /** The line a friend pulls it with. */\n readonly pullLine: string\n}\n\nexport interface PublishPlanRequest {\n readonly id: string\n readonly plugin: string\n /** The account that owns the repository; absent means the signed-in one. */\n readonly owner?: string\n readonly license?: string\n}\n\n/** The person's yes: the plan they read, sent back as it was. */\nexport interface PublishRequest extends PublishPlanRequest {\n readonly plan: PublishPlanView\n}\n\nexport interface PublishResponse {\n readonly releaseUrl: string\n readonly pullLine: string\n}\n\n/** What sharing a whole app would send, in the app's own words (`npm run share -- --json`): the person reads this before saying yes. */\nexport interface AppSharePlanView {\n /** `owner/name` for a repository the share creates, or the address of the remote the app already has. */\n readonly repository: string\n readonly create: boolean\n readonly visibility: 'private' | 'public'\n /** Files changed since the app's last save; the share saves them first. */\n readonly changes: number\n}\n\nexport interface AppSharePlanRequest {\n readonly id: string\n /** The account that owns a new repository; absent means the signed-in one. */\n readonly owner?: string\n /** Who may see it: written to the app's blend.yaml (metadata.visibility, the one place it is kept) before the plan is read; absent keeps it. */\n readonly visibility?: 'private' | 'public'\n}\n\n/** The GitHub connection Control Center hands its apps (as GH_TOKEN): who is signed in, never the token. */\nexport interface GithubView {\n /** False when this build has no GitHub app to sign in with. */\n readonly available: boolean\n readonly login: string | null\n}\n\n/** A sign-in under way: the code the person types at GitHub. The device code stays in the service. */\nexport interface GithubStartView {\n readonly userCode: string\n readonly verificationUri: string\n /** Seconds between polls. */\n readonly interval: number\n}\n\nexport type GithubPollView =\n | { readonly state: 'pending', readonly interval?: number }\n | { readonly state: 'connected', readonly login: string }\n | { readonly state: 'failed', readonly reason: string }\n\n/** The person's yes: the plan they read, sent back as it was. */\nexport interface AppShareRequest extends AppSharePlanRequest {\n readonly plan: AppSharePlanView\n}\n\nexport interface AppShareResponse {\n /** The remote the app now pushes to. */\n readonly remote: string\n readonly created: boolean\n}\n\n/** A plugin name, a GitHub account and a license id as the door takes them: nothing that could read as an option or a path. */\nexport const PLUGIN_NAME = /^[a-z0-9][a-z0-9._-]{0,127}$/u\nexport const ACCOUNT_NAME = /^[A-Za-z0-9][A-Za-z0-9-]{0,38}$/u\nexport const LICENSE_ID = /^[A-Za-z0-9][A-Za-z0-9.+-]{0,39}$/u\n\n/** The folder the assistant's agent works in: the apps folder, made if it was not there yet. */\nexport interface AssistantFolderResponse {\n readonly folder: string\n}\n","/**\n * The running app's door, reached the way the app's own `acryl` command reaches it: `<app>/.acryl/door.json` names the loopback address and the secret of the\n * app that is running now. The screen is a person's surface, so it may do what the terminal's prompt does: send a publish the person confirmed. Only\n * loopback addresses are used, and a missing or stale file means the app is not running.\n */\nimport { readFileSync } from 'node:fs'\nimport { join } from 'node:path'\n\nexport class DoorUnavailable extends Error {}\n\n/** One door answer: `ok` with a `value` (and the door's own `text`), or a refusal with its `code` and `message`. */\nexport interface DoorAnswer {\n readonly ok: boolean\n readonly value?: unknown\n readonly text?: string\n readonly code?: string\n readonly message?: string\n}\n\nexport interface Door {\n /** A verb of the app's door (`plugin-list`, `plugin-pull`, `plugin-publish` for the plan, ...). */\n call(folder: string, verb: string, args: Readonly<Record<string, unknown>>): Promise<DoorAnswer>\n /** The person's yes to a publish plan; the app sends it only when the plan still matches. */\n confirmPublish(folder: string, body: Readonly<Record<string, unknown>>): Promise<DoorAnswer>\n}\n\ntype Fetch = (input: string, init?: { method?: string, headers?: Record<string, string>, body?: string, signal?: AbortSignal }) => Promise<{ json: () => Promise<unknown> }>\n\nconst TIMEOUT_MS = 60_000\nconst LOOPBACK = new Set(['127.0.0.1', 'localhost', '[::1]'])\nconst NOT_RUNNING = 'the app is not running: start it from this screen, then try again'\n\ninterface DoorFile { readonly url: string, readonly secret: string }\n\nfunction readDoorFile(folder: string, read: (path: string) => string): DoorFile {\n let parsed: unknown\n try {\n parsed = JSON.parse(read(join(folder, '.acryl', 'door.json')))\n } catch {\n throw new DoorUnavailable(NOT_RUNNING)\n }\n const file = parsed as Partial<DoorFile> | null\n if (typeof file?.url !== 'string' || typeof file.secret !== 'string') throw new DoorUnavailable(NOT_RUNNING)\n let url: URL\n try { url = new URL(file.url) } catch { throw new DoorUnavailable(NOT_RUNNING) }\n if (url.protocol !== 'http:' || !LOOPBACK.has(url.hostname)) throw new DoorUnavailable(NOT_RUNNING)\n return { url: url.origin, secret: file.secret }\n}\n\nexport function fileDoor(fetchImpl: Fetch = (input, init) => fetch(input, init), read: (path: string) => string = path => readFileSync(path, 'utf8')): Door {\n const post = async (folder: string, path: string, body: unknown): Promise<DoorAnswer> => {\n const file = readDoorFile(folder, read)\n try {\n const response = await fetchImpl(`${file.url}${path}`, {\n method: 'POST', headers: { authorization: `Bearer ${file.secret}`, 'content-type': 'application/json' }, body: JSON.stringify(body), signal: AbortSignal.timeout(TIMEOUT_MS),\n })\n const answer = await response.json() as DoorAnswer | null\n if (answer === null || typeof answer !== 'object') throw new DoorUnavailable('the app answered with nothing readable')\n return answer\n } catch (cause) {\n if (cause instanceof DoorUnavailable) throw cause\n throw new DoorUnavailable(NOT_RUNNING)\n }\n }\n return {\n call: (folder, verb, args) => post(folder, '/api/acryl-door/call', { verb, args }),\n confirmPublish: (folder, body) => post(folder, '/api/acryl-door/publish-confirmed', body),\n }\n}\n","/** The public Blend registry as the screen's store lists it: only reads (the same index `acryl new --from` and the terminal's \"Install a Blend\" use). */\nimport { BLEND_SOURCE, type BlendView } from './contract.ts'\n\nexport const REGISTRY_INDEX = 'https://acrylblends.github.io/registry/index.json'\n/** Blends released by people outside the ACRYL project and found on GitHub by the registry's hourly sync (origin `community`, each with its `source`). */\nexport const REGISTRY_DISCOVERED = 'https://acrylblends.github.io/registry/discovered.json'\nconst TIMEOUT_MS = 10_000\n\nexport class RegistryUnavailable extends Error {}\n\ntype Fetch = (input: string, init?: { signal?: AbortSignal }) => Promise<{ ok: boolean, status: number, json: () => Promise<unknown> }>\n\nconst record = (value: unknown): Record<string, unknown> | undefined => value !== null && typeof value === 'object' && !Array.isArray(value) ? value as Record<string, unknown> : undefined\nconst text = (value: unknown): string => typeof value === 'string' ? value : ''\n\n/** The `entries` of one registry list; `RegistryUnavailable` in words a person can act on. */\nasync function entriesOf(fetchImpl: Fetch, url: string): Promise<readonly unknown[]> {\n let body: unknown\n try {\n const response = await fetchImpl(url, { signal: AbortSignal.timeout(TIMEOUT_MS) })\n if (!response.ok) throw new RegistryUnavailable(`The registry answered HTTP ${String(response.status)}.`)\n body = await response.json()\n } catch (cause) {\n if (cause instanceof RegistryUnavailable) throw cause\n throw new RegistryUnavailable('The registry could not be read. Check the network and try again.')\n }\n const entries = record(body)?.entries\n if (!Array.isArray(entries)) throw new RegistryUnavailable('The registry answered, but its list could not be read.')\n return entries\n}\n\n/**\n * The Blends an ACRYL app can be made from (registry entries whose runtime is `acrylblends`), by name: the public registry's, and the community ones\n * the registry found on GitHub (made from their `source`). The community list is optional: when it cannot be read, the store still lists the rest.\n */\nexport async function readBlends(fetchImpl: Fetch = (input, init) => fetch(input, init), url: string = REGISTRY_INDEX, discovered: string | undefined = REGISTRY_DISCOVERED): Promise<readonly BlendView[]> {\n const blends: BlendView[] = []\n const ids = new Set<string>()\n for (const raw of await entriesOf(fetchImpl, url)) {\n const entry = record(raw)\n if (entry === undefined || entry.runtime !== 'acrylblends' || typeof entry.id !== 'string' || entry.id === '') continue\n ids.add(entry.id)\n blends.push({ id: entry.id, name: text(entry.name) || entry.id, version: text(entry.version), category: text(entry.category), description: text(entry.description), origin: entry.origin === 'official' ? 'official' : 'community' })\n }\n const community = discovered === undefined ? [] : await entriesOf(fetchImpl, discovered).catch(() => [])\n for (const raw of community) {\n const entry = record(raw)\n // A community Blend is made from its GitHub release; one without a usable source, or with an id the public registry has, is not offered.\n if (entry === undefined || entry.runtime !== 'acrylblends' || typeof entry.id !== 'string' || entry.id === '' || ids.has(entry.id)) continue\n const source = text(entry.source)\n if (!BLEND_SOURCE.test(source)) continue\n ids.add(entry.id)\n // Its place in the store's categories (the sync reads it from the Blend's own package.json keywords), else the word its blend.yaml carries.\n const placement = record(entry.placement)\n const category = text(placement?.category) === '' ? text(entry.category) : [text(placement?.category), text(placement?.subcategory)].filter(Boolean).join(' › ')\n const publisher = text(entry.publisher)\n blends.push({ id: entry.id, name: text(entry.name) || entry.id, version: text(entry.version), category, description: text(entry.description), origin: 'community', source, ...(publisher === '' ? {} : { publisher }) })\n }\n return blends.sort((a, b) => a.name.localeCompare(b.name))\n}\n","/**\n * The one place this plugin starts processes. A `Runner` hands back a `Run` the service watches; the real one spawns the command through the\n * machine's own Node and npm (the desktop app carries no Node of its own yet, spec 050 T005) and stops a whole tree, not only its first process\n * (`npm run dev` starts a server below npm).\n */\nimport { spawn, spawnSync } from 'node:child_process'\nimport { closeSync, existsSync, openSync, readSync } from 'node:fs'\nimport { StringDecoder } from 'node:string_decoder'\n\nexport interface Run {\n /** Output so far is delivered in chunks, stdout and stderr together. */\n onOutput(listener: (text: string) => void): void\n /** The end, once: the exit code, or the reason the command could not start (`notFound` when the program is not on this machine). */\n onEnd(listener: (end: { code: number | null, notFound: boolean, error?: string }) => void): void\n stop(): void\n}\n\nexport interface Command {\n readonly program: string\n readonly args: readonly string[]\n readonly cwd: string\n readonly env: Readonly<Record<string, string | undefined>>\n /** A file for the command's output instead of a pipe into this process: a command that may outlive this process (a Desktop app's window) needs it,\n * since a write into a pipe whose reader has gone kills the writer (EPIPE). Its output still reaches `onOutput`, read from the file as it grows. */\n readonly log?: string\n}\n\nexport type Runner = (command: Command) => Run\n\n/** Keys the desktop app set for itself; a started app must choose its own (a shared one would put the new app in this app's home and port). */\nconst OWN_KEYS = /^(ACRYL_|ACRYLBLENDS_|DSH_|ELECTRON_|npm_|PORT$|WATCH_REPORT_DEPENDENCIES$)/u\n\n/** The environment a started app gets: this process's, without the keys above, plus the places Node usually lives (a Dock launch has a short PATH). */\nexport function appEnvironment(base: Readonly<Record<string, string | undefined>>, platform: NodeJS.Platform = process.platform): Record<string, string | undefined> {\n const env: Record<string, string | undefined> = {}\n for (const [key, value] of Object.entries(base)) if (!OWN_KEYS.test(key)) env[key] = value\n if (platform !== 'win32') {\n const extra = ['/opt/homebrew/bin', '/usr/local/bin']\n const have = (env.PATH ?? '').split(':')\n env.PATH = [...have, ...extra.filter(dir => !have.includes(dir))].filter(dir => dir !== '').join(':')\n }\n return env\n}\n\n/**\n * What a child of the Electron main process inherits. On Linux Chromium opens its DevTools port (`--remote-debugging-port`), its sockets and its files without\n * close-on-exec and Node's spawn passes every one on, so an app started from here kept the port bound after this app quit. macOS closes all but the standard streams\n * when it starts a process, and Windows does not inherit a socket, so only Linux needs it. bash's `exec 12>&-` closes a descriptor of any number (dash takes one\n * digit); the command then replaces bash, so the process id and group stay the child's. The same text is in plugins/desktop-shell/inherited.ts; keep them equal.\n */\n// biome-ignore lint/suspicious/noTemplateCurlyInString: shell parameter expansion, not a JavaScript template\nconst CLOSE_AND_RUN = 'for f in /proc/self/fd/*; do n=${f##*/}; if [ \"$n\" -gt 2 ]; then eval \"exec $n>&-\"; fi; done; exec \"$@\"'\nconst BASH = '/bin/bash'\n\n/** The program and arguments to spawn so the child holds no descriptor above 2: the command itself where that is already so, or where bash is not there. */\nexport function withoutInheritedDescriptors(program: string, args: readonly string[], platform: NodeJS.Platform = process.platform, hasBash: boolean = existsSync(BASH)): { readonly program: string, readonly args: readonly string[] } {\n if (platform !== 'linux' || !hasBash) return { program, args }\n return { program: BASH, args: ['-c', CLOSE_AND_RUN, 'acryl-spawn', program, ...args] }\n}\n\n/** Stop a command and everything it started: a process group on Unix, `taskkill /t` on Windows. */\nfunction stopTree(pid: number, platform: NodeJS.Platform): void {\n try {\n if (platform === 'win32') spawnSync('taskkill', ['/pid', String(pid), '/t', '/f'], { windowsHide: true })\n else process.kill(-pid, 'SIGTERM')\n } catch { /* already gone */ }\n}\n\n/** Read a file as it grows, until the returned function is called (it reads what is left first). */\nfunction follow(file: string, emit: (text: string) => void): () => void {\n const fd = openSync(file, 'r')\n const decoder = new StringDecoder('utf8')\n const buffer = Buffer.alloc(64 * 1024)\n let at = 0\n const read = (): void => {\n for (let n = readSync(fd, buffer, 0, buffer.length, at); n > 0; n = readSync(fd, buffer, 0, buffer.length, at)) {\n at += n\n emit(decoder.write(buffer.subarray(0, n)))\n }\n }\n const timer = setInterval(read, 250)\n timer.unref()\n return () => { clearInterval(timer); read(); closeSync(fd) }\n}\n\nexport const spawnRunner: Runner = (command) => {\n const win = process.platform === 'win32'\n // `npm` and `npx` are .cmd files on Windows, which only a shell starts.\n const start = win ? { program: command.program, args: command.args } : withoutInheritedDescriptors(command.program, command.args)\n const log = command.log === undefined ? undefined : openSync(command.log, 'w')\n const output = log ?? 'pipe'\n const child = spawn(start.program, [...start.args], { cwd: command.cwd, env: command.env as NodeJS.ProcessEnv, shell: win, detached: !win, windowsHide: true, stdio: ['ignore', output, output] })\n if (log !== undefined) closeSync(log)\n const outputs: Array<(text: string) => void> = []\n const emit = (text: string): void => { for (const listener of outputs) listener(text) }\n const unfollow = command.log === undefined ? () => {} : follow(command.log, emit)\n const ends: Array<(end: { code: number | null, notFound: boolean, error?: string }) => void> = []\n let ended = false\n const finish = (end: { code: number | null, notFound: boolean, error?: string }): void => {\n if (ended) return\n ended = true\n unfollow()\n for (const listener of ends) listener(end)\n }\n for (const stream of [child.stdout, child.stderr]) stream?.on('data', (chunk: Buffer) => { emit(chunk.toString('utf8')) })\n child.on('error', (cause: NodeJS.ErrnoException) => { finish({ code: null, notFound: cause.code === 'ENOENT', error: cause.message }) })\n // 127 is \"not found\" from a shell (Unix), 1 with this text is cmd.exe's.\n child.on('close', (code) => { finish({ code, notFound: code === 127 }) })\n return {\n onOutput: (listener) => { outputs.push(listener) },\n onEnd: (listener) => { ends.push(listener) },\n stop: () => { if (!ended && child.pid !== undefined) stopTree(child.pid, process.platform) },\n }\n}\n","/**\n * What the ACRYL screen does, as one service with ports (Clean Architecture: the routes and the Cordis plugin are the edge; this holds the rules).\n * The list is the registry `<home>/apps.json` (`acryl-launcher`, the same file `acryl apps` and the terminal read); what runs is held here, in\n * memory, because the launcher records no port: an app is \"running\" when this service started it and it has not ended.\n */\nimport { basename, join } from 'node:path'\nimport {\n addApp, APP_NAME, appNameProblem, APP_MARKER, blendOf, blendVersionOf, clearGithub, githubOf, githubClientId, githubEnv, inspectApp, maskKey, modelEnv, pollGithubSignIn,\n readApps, readGithub, readModelKey, removeApp, setBlendVisibility, startGithubSignIn, STARTERS, toolsEnv, whereProblem,\n type AppEntry,\n} from '@acryldev/launcher'\nimport type {\n GithubPollView, GithubStartView, GithubView,\n AppSharePlanRequest, AppSharePlanView, AppShareRequest, AppShareResponse, AppRunState, AppView, BlendView, HealthView, JobView, NewAppRequest, PluginPullResponse, PluginView, PublishPlanRequest, PublishPlanView, PublishRequest, PublishResponse, StateResponse, Surface,\n} from './contract.ts'\nimport { ACCOUNT_NAME, BLEND_ID, BLEND_SOURCE, LICENSE_ID, MAKEABLE_SURFACES, PLUGIN_NAME } from './contract.ts'\nimport { DoorUnavailable, type Door, type DoorAnswer } from './door.ts'\nimport { appEnvironment, type Run, type Runner } from './runner.ts'\n\n/** A request the service cannot honour, in a sentence a person can act on. The route answers it as 409. */\nexport class LauncherRefusal extends Error {}\n\nexport interface LauncherPorts {\n /** ACRYL's home (`appInstance.home`): where `apps.json` and `model.json` are. */\n readonly home: string\n /** The folder \"+ New app\" suggests. */\n readonly appsFolder: string\n readonly runner: Runner\n /** The environment started apps inherit (before the desktop app's own keys are removed). */\n readonly environment: () => Readonly<Record<string, string | undefined>>\n readonly exists: (path: string) => boolean\n readonly makeFolder: (path: string) => void\n /** The Blends in the public registry; rejects (`RegistryUnavailable`) when it cannot be read. */\n readonly blends: () => Promise<readonly BlendView[]>\n /** The running apps' doors: what lists, pulls and publishes their plugins. */\n readonly door: Door\n /**\n * Fetch whatever of Node.js (with npm) and gh this computer lacks into `<home>/tools` (`prepareTools` of @acryldev/launcher); absent, the\n * computer's own tools are used as they are (tests, and a launcher run from a terminal).\n */\n readonly prepareTools?: () => Promise<readonly string[]>\n}\n\n/** The address an app prints, with the token it needs: `http://127.0.0.1:3999/?token=...`. */\nconst ADDRESS = /https?:\\/\\/(?:127\\.0\\.0\\.1|localhost|\\[::1\\]):\\d+[^\\s'\")\\]]*/u\nconst TAIL_LINES = 12\nconst BLENDS_FRESH_MS = 60_000\n/** The package `acryl new` runs (`distribution/acryl-npm-launcher/forward.js` CREATE_SPEC). */\nconst CREATE_SPEC = 'create-acrylblends@latest'\n/** The command that updates an app from its Blend's newer release (`acrylblends update`, in the acrylblends package). */\nconst UPDATE_SPEC = 'acrylblends@latest'\n/** The app's own share command, from its folder (the `save` plugin of acrylblends). */\nconst SHARE_COMMAND = join('plugins', 'save', 'share-cli.ts')\n/** ACRYL ADE: the Blend and the folder in the home that `acryl ade` makes and opens (`distribution/acryl-npm-launcher/managed.js` MANAGED.ade). */\nconst ADE_BLEND = 'acryl.ade'\nconst ADE_FOLDER = 'ade'\nconst ANSI = /\\u001b\\[[0-9;?]*[ -/]*[@-~]/gu\n\n// A finished last line keeps its newline, so the next chunk starts a line of its own instead of running on (\"...needsnpm http fetch\").\nconst tail = (text: string): string => {\n const lines = text.replace(ANSI, '').split(/\\r?\\n/u).map(line => line.trim()).filter(line => line !== '').slice(-TAIL_LINES).join('\\n')\n return lines !== '' && /\\n\\s*$/u.test(text) ? `${lines}\\n` : lines\n}\n\n/** The job as this service changes it; `JobView` is what the screen is told. */\ninterface Job {\n readonly name: string\n readonly kind: JobView['kind']\n readonly line: string\n status: JobView['status']\n step: string\n readonly since: number\n output: string\n message?: string\n /** The process the job is on now: the command that makes the app, then, for an app that arrives without its dependencies, `npm install`. */\n run: Run\n}\n\ninterface Started {\n readonly run: Run\n /** Started with `npm run desktop`: once it serves, its own window is open, and it stays when this app quits. */\n readonly desktop: boolean\n address: string | undefined\n output: string\n}\n\nexport class LauncherService {\n readonly #ports: LauncherPorts\n readonly #started = new Map<string, Started>()\n /** Why an app last ended without being stopped, until it is started again. */\n readonly #failures = new Map<string, string>()\n #job: Job | undefined\n #blends: { at: number, list: readonly BlendView[] } | undefined\n\n #signIn: { readonly clientId: string, readonly deviceCode: string, readonly until: number } | undefined\n /** Apps just made whose `npm install` is running (`#install`), by id. */\n readonly #installing = new Map<string, Job>()\n /** The tools apps need: being fetched (the first start on a computer without them), ready, or not had (apps then try the computer's own). */\n #tools: { readonly state: 'preparing' } | { readonly state: 'ready' } | { readonly state: 'failed', readonly reason: string } = { state: 'ready' }\n constructor(ports: LauncherPorts) { this.#ports = ports }\n\n /** Start fetching what this computer lacks of Node.js and gh; apps wait for it (`#toolsReady`). Called once, when the launcher starts. */\n prepareTools(): Promise<void> {\n const prepare = this.#ports.prepareTools\n if (prepare === undefined) return Promise.resolve()\n this.#tools = { state: 'preparing' }\n return prepare().then(\n () => { this.#tools = { state: 'ready' } },\n (cause: unknown) => { this.#tools = { state: 'failed', reason: cause instanceof Error ? cause.message : String(cause) } },\n )\n }\n\n /** Refuse, in words, to start anything while the tools are still being fetched; a failed fetch lets apps try the computer's own tools. */\n #toolsReady(): void {\n if (this.#tools.state === 'preparing') {\n throw new LauncherRefusal('Getting Node.js and GitHub\\'s tool ready for your apps (only on the first start on this computer, about a minute). Try again in a moment.')\n }\n }\n\n state(): StateResponse {\n // The registry's versions mark the apps with a newer Blend release; a stale list is read again in the background for the next state.\n if (this.#blends === undefined || Date.now() - this.#blends.at >= BLENDS_FRESH_MS) void this.blends().catch(() => undefined)\n const apps = readApps(this.#ports.home).map(entry => this.#view(entry))\n const at = this.#job\n const job = at === undefined ? null : { name: at.name, kind: at.kind, line: at.line, status: at.status, step: at.step, since: at.since, output: at.output.trimEnd(), ...at.message === undefined ? {} : { message: at.message } }\n return { apps, appsFolder: this.#ports.appsFolder, starters: STARTERS, job }\n }\n\n #view(entry: AppEntry): AppView {\n const started = this.#started.get(entry.id)\n const missing = inspectApp(entry).state === 'missing'\n const installing = this.#installing.get(entry.id)\n const state: AppRunState = missing ? 'missing' : started === undefined ? (installing !== undefined ? 'starting' : 'stopped') : started.address === undefined ? 'starting' : 'running'\n const failure = this.#failures.get(entry.id)\n const blend = entry.blend === '' ? blendOf(entry.path) : entry.blend\n const version = missing ? '' : blendVersionOf(entry.path)\n const latest = this.#blends?.list.find(listed => listed.id === blend)?.version\n const github = missing ? undefined : githubOf(entry.path)\n return {\n id: entry.id, name: basename(entry.path), path: entry.path, blend, madeBy: entry.madeBy, surface: entry.surface, state,\n ...version === '' ? {} : { version },\n ...version !== '' && latest !== undefined && newerVersion(latest, version) ? { update: latest } : {},\n ...started?.address === undefined ? {} : { address: started.address },\n ...started === undefined || started.address !== undefined || started.output === '' ? {} : { output: started.output.trimEnd() },\n ...started === undefined && installing !== undefined && installing.output !== '' ? { output: installing.output.trimEnd() } : {},\n ...failure === undefined || state !== 'stopped' ? {} : { failure },\n ...github === undefined ? {} : { github },\n }\n }\n\n add(path: string): AppView {\n try {\n return this.#view(addApp(this.#ports.home, { path }).entry)\n } catch (cause) {\n throw new LauncherRefusal(cause instanceof Error ? cause.message : String(cause))\n }\n }\n\n remove(id: string): void {\n this.stop(id)\n if (!removeApp(this.#ports.home, id)) throw new LauncherRefusal(`there is no app \"${id}\" in the list`)\n }\n\n /**\n * Start an app the way the terminal's \"Open an app\" does, with the saved model key: a Web app with `npm run dev` in its folder (its address opens in the\n * browser), a Desktop app with `npm run desktop`, which starts the same app and opens it in its own window (Electron is fetched the first time).\n */\n start(id: string, surface?: Surface): void {\n this.#toolsReady()\n const entry = readApps(this.#ports.home).find(app => app.id === id)\n if (entry === undefined) throw new LauncherRefusal(`there is no app \"${id}\" in the list`)\n if (inspectApp(entry).state === 'missing') throw new LauncherRefusal(`the folder ${entry.path} is gone: remove it from the list, or put it back`)\n if (this.#started.has(id)) return\n this.#failures.delete(id)\n // An app whose dependencies are not installed (one pulled from the registry in a terminal, or copied) cannot run: install them first, shown as \"starting\".\n if (!this.#ports.exists(join(entry.path, 'node_modules'))) { this.#installThenStart(id, entry.path, surface); return }\n const desktop = (surface ?? entry.surface) === 'desktop'\n const run = this.#ports.runner({ program: 'npm', args: ['run', desktop ? 'desktop' : 'dev'], cwd: entry.path, env: this.#environment(), ...(desktop ? { log: this.#appLog(id) } : {}) })\n this.#watch(id, run, undefined, desktop)\n }\n\n #installThenStart(id: string, folder: string, surface: Surface | undefined): void {\n const run = this.#ports.runner({ program: 'npm', args: ['install', '--loglevel', 'http'], cwd: folder, env: this.#environment() })\n const started: Started = { run, desktop: false, address: undefined, output: '' }\n this.#started.set(id, started)\n run.onOutput((text) => { started.output = tail(`${started.output}${text}`) })\n run.onEnd((end) => {\n if (this.#started.get(id) !== started) return\n this.#started.delete(id)\n if (end.notFound) this.#failures.set(id, 'Node.js and npm were not found on this machine. Install Node.js 22.19 or later from nodejs.org, then try again.')\n else if (end.code === 0) { try { this.start(id, surface) } catch (cause) { this.#failures.set(id, cause instanceof Error ? cause.message : String(cause)) } }\n else if (end.code !== null) this.#failures.set(id, started.output === '' ? (end.error ?? 'npm install ended before the app could run.') : started.output.trimEnd())\n })\n }\n\n /**\n * ACRYL ADE, the way `acryl ade` (`--gui`) opens it: the Blend `acryl.ade` in `<home>/ade`, made from the registry the first time (listed, installed and\n * started as any app made here is), then started in a window or the browser. Already running, it is left as it is.\n */\n openAde(surface: 'web' | 'desktop'): void {\n const folder = join(this.#ports.home, ADE_FOLDER)\n if (!this.#ports.exists(join(folder, APP_MARKER))) { this.create({ name: ADE_FOLDER, where: this.#ports.home, blend: ADE_BLEND, surface }); return }\n this.start(addApp(this.#ports.home, { path: folder, surface }).entry.id, surface)\n }\n\n stop(id: string): void {\n this.#started.get(id)?.run.stop()\n }\n\n /**\n * Bring the newer registry release of the app's Blend into it: `acrylblends update` in its folder (a git merge that keeps the person's changes, then npm\n * install). A running app is stopped first and started again after.\n */\n update(id: string): void {\n this.#toolsReady()\n if (this.#job?.status === 'running') throw new LauncherRefusal(`${this.#job.name} is still being worked on: wait for it to finish`)\n const entry = readApps(this.#ports.home).find(app => app.id === id)\n if (entry === undefined) throw new LauncherRefusal(`there is no app \"${id}\" in the list`)\n const view = this.#view(entry)\n if (view.update === undefined) throw new LauncherRefusal(`${view.name} is on the latest release of ${view.blend}`)\n const restart = this.#started.has(id)\n this.stop(id)\n const run = this.#ports.runner({ program: 'npm', args: ['exec', '--yes', UPDATE_SPEC, '--', 'update'], cwd: entry.path, env: this.#environment() })\n const job: Job = {\n name: view.name, kind: 'update', line: `cd ${entry.path} && npx ${UPDATE_SPEC} update`, status: 'running', run, since: Date.now(), output: '',\n step: `Updating ${view.name} from ${view.blend} ${view.version ?? ''} to ${view.update}: getting the release and merging it in, your changes are kept, then npm install. Next: ${restart ? 'starting it again' : 'done'}.`,\n }\n this.#job = job\n let output = ''\n run.onOutput((text) => { output = tail(`${output}${text}`); job.output = output })\n run.onEnd((end) => {\n if (job.run !== run) return\n if (end.notFound) { job.status = 'failed'; job.message = 'Node.js and npm were not found on this machine. Install Node.js 22.19 or later from nodejs.org, then try again.'; return }\n if (end.code !== 0) { job.status = 'failed'; job.message = output === '' ? (end.error ?? 'The update ended before it was done; the app is unchanged.') : output.trimEnd(); return }\n job.status = 'done'\n job.step = `Updated ${view.name} to ${view.blend} ${view.update}.${restart ? ' Starting it again: its progress shows on its card below.' : ''}`\n job.output = ''\n if (restart) try { this.start(id) } catch (cause) { this.#failures.set(id, cause instanceof Error ? cause.message : String(cause)) }\n })\n }\n\n /**\n * When this app quits (or the plugin unloads): stop everything it started, except a Desktop app whose window is open. That window is the person's\n * own, and closing it stops the app; a Web app has no window, so it would run on unseen. Returns the names of the apps left open.\n */\n stopAll(): string[] {\n const kept: string[] = []\n for (const [id, started] of this.#started) {\n if (started.desktop && started.address !== undefined) kept.push(id)\n else started.run.stop()\n }\n this.#job?.run.stop()\n for (const job of this.#installing.values()) job.run.stop()\n return kept\n }\n\n /** Where a Desktop app's output goes (`<home>/logs/apps/<id>.log`): a file, so the app does not depend on this process to write it. */\n #appLog(id: string): string {\n const folder = join(this.#ports.home, 'logs', 'apps')\n this.#ports.makeFolder(folder)\n return join(folder, `${id}.log`)\n }\n\n /**\n * Make an app: the same `acryl new <name> <starter>` the terminal runs, in the folder the person chose. `acryl new` goes on to install and start the app,\n * so the process it began is the app's running process: when its blend.yaml appears the app is listed and that process is adopted as the app's.\n */\n create(request: NewAppRequest): void {\n this.#toolsReady()\n if (this.#job?.status === 'running') throw new LauncherRefusal(`${this.#job.name} is still being made: wait for it to finish`)\n const problem = whereProblem(request.where) ?? (APP_NAME.test(request.name) ? undefined : appNameProblem(request.name, this.#ports))\n if (problem !== undefined) throw new LauncherRefusal(problem)\n if ((request.starter === undefined) === (request.blend === undefined)) throw new LauncherRefusal('choose a starter or a Blend, not both')\n if (request.starter !== undefined && !STARTERS.some(starter => starter.value === request.starter)) throw new LauncherRefusal(`there is no starter \"${request.starter}\"`)\n if (request.blend !== undefined && !BLEND_ID.test(request.blend) && !BLEND_SOURCE.test(request.blend)) throw new LauncherRefusal(`\"${request.blend}\" is not a Blend id (for example acrylblends.notes) or a Blend on GitHub (github:owner/repo#tag)`)\n if (!MAKEABLE_SURFACES.includes(request.surface)) throw new LauncherRefusal('CLI (TUI) apps are coming: choose Web or Desktop')\n const folder = join(request.where, request.name)\n if (this.#ports.exists(folder)) throw new LauncherRefusal(`there is already a folder named ${request.name} in ${request.where}`)\n this.#ports.makeFolder(request.where)\n // What `acryl new` forwards to (the selector's `npm exec --yes create-acrylblends@latest -- <args>`), run directly so this screen does not depend on which\n // `acryl` release is installed; the line shown is the one a person types.\n const source = request.blend === undefined ? [request.starter ?? ''] : ['--from', request.blend]\n const args = ['exec', '--yes', CREATE_SPEC, '--', request.name, ...source]\n const line = `cd ${request.where} && acryl new ${request.name} ${source.join(' ')}`\n // npm_config_loglevel reaches the install a starter runs inside create-acrylblends too, so its minute shows each download instead of one still line.\n const run = this.#ports.runner({ program: 'npm', args, cwd: request.where, env: { ...this.#environment(), npm_config_loglevel: 'http' } })\n const step = request.blend === undefined\n ? `Step 1 of 2: getting ${request.name} and installing its dependencies (${CREATE_SPEC}, about a minute). Next: starting it.`\n : `Step 1 of 3: getting ${request.name} (${CREATE_SPEC}). Next: installing its dependencies, then starting it.`\n const job: Job = { name: request.name, kind: 'make', line, status: 'running', run, step, since: Date.now(), output: '' }\n this.#job = job\n this.#watch(undefined, run, { folder, surface: request.surface, job })\n }\n\n /** The registry's Blends, read again at most once a minute: the store is opened and closed often, and the registry is a public file. */\n async blends(): Promise<readonly BlendView[]> {\n if (this.#blends !== undefined && Date.now() - this.#blends.at < BLENDS_FRESH_MS) return this.#blends.list\n const list = await this.#ports.blends()\n this.#blends = { at: Date.now(), list }\n return list\n }\n\n /** The apps folder, made when it is not there yet: the assistant's agent works in it, and a folder that does not exist cannot be worked in. */\n assistantFolder(): string {\n this.#ports.makeFolder(this.#ports.appsFolder)\n return this.#ports.appsFolder\n }\n\n #entry(id: string): AppEntry {\n const entry = readApps(this.#ports.home).find(app => app.id === id)\n if (entry === undefined) throw new LauncherRefusal(`there is no app \"${id}\" in the list`)\n return entry\n }\n\n /** A door call, with \"the app is not running\" and a refusal as the sentence a person can act on. */\n async #door(id: string, run: (door: Door, folder: string) => Promise<DoorAnswer>): Promise<DoorAnswer> {\n const entry = this.#entry(id)\n let answer: DoorAnswer\n try {\n answer = await run(this.#ports.door, entry.path)\n } catch (cause) {\n if (cause instanceof DoorUnavailable) throw new LauncherRefusal(cause.message)\n throw cause\n }\n if (!answer.ok) throw new LauncherRefusal(answer.message ?? 'the app refused')\n return answer\n }\n\n /** The plugins of a running app: the ones its people made (shareable) and the ones pulled from a registry. */\n async plugins(id: string): Promise<readonly PluginView[]> {\n let answer: DoorAnswer\n try {\n answer = await this.#door(id, (door, folder) => door.call(folder, 'plugin-list', {}))\n } catch (cause) {\n // An app from an older Blueprint has neither plugin-share nor extensions: its door says so in words meant for an agent. Say it for a person.\n if (cause instanceof LauncherRefusal && /no extensions plugin to drive/u.test(cause.message)) {\n throw new LauncherRefusal('This app keeps its plugins in its own page: open it, then Settings > Plugins. Pulling a plugin from here needs an app made with a newer Blueprint.')\n }\n throw cause\n }\n const list = Array.isArray(answer.value) ? answer.value as Array<Record<string, unknown>> : []\n return list.filter(plugin => typeof plugin.name === 'string').map(plugin => ({\n name: String(plugin.name), version: typeof plugin.version === 'string' ? plugin.version : '', state: typeof plugin.state === 'string' ? plugin.state : '',\n ...typeof plugin.pulledFrom === 'string' ? { pulledFrom: plugin.pulledFrom } : {},\n ...typeof plugin.author === 'string' ? { author: plugin.author } : {},\n }))\n }\n\n /** Pull a plugin into a running app from a registry source (`github:owner/repo@version`), the way `acryl plugin pull` does. */\n async pullPlugin(id: string, source: string): Promise<PluginPullResponse> {\n if (source.trim() === '' || source.startsWith('-') || source.length > 1024) throw new LauncherRefusal('say where the plugin is, for example github:someone/pomodoro@0.1.0')\n const answer = await this.#door(id, (door, folder) => door.call(folder, 'plugin-pull', { source: source.trim() }))\n return { text: answer.text ?? 'Pulled.', plugins: await this.plugins(id) }\n }\n\n #checkPublish(request: PublishPlanRequest): void {\n if (!PLUGIN_NAME.test(request.plugin)) throw new LauncherRefusal(`\"${request.plugin}\" is not a plugin name`)\n if (request.owner !== undefined && !ACCOUNT_NAME.test(request.owner)) throw new LauncherRefusal(`\"${request.owner}\" is not a GitHub account name`)\n if (request.license !== undefined && !LICENSE_ID.test(request.license)) throw new LauncherRefusal(`\"${request.license}\" is not a license id`)\n }\n\n #options(request: PublishPlanRequest): Record<string, unknown> {\n return { ...request.owner === undefined ? {} : { owner: request.owner }, ...request.license === undefined ? {} : { license: request.license } }\n }\n\n /** What publishing a plugin would send (the account, repository, version, license and files). Sends nothing. */\n async publishPlan(request: PublishPlanRequest): Promise<PublishPlanView> {\n this.#checkPublish(request)\n const answer = await this.#door(request.id, (door, folder) => door.call(folder, 'plugin-publish', { name: request.plugin, ...this.#options(request) }))\n const plan = answer.value as Partial<PublishPlanView> | null\n if (plan === null || typeof plan !== 'object' || typeof plan.owner !== 'string' || typeof plan.repo !== 'string' || typeof plan.version !== 'string') {\n throw new LauncherRefusal('the app did not give a publish plan')\n }\n return {\n owner: plan.owner, repo: plan.repo, version: plan.version, visibility: String(plan.visibility ?? ''), license: String(plan.license ?? ''),\n createsRepository: plan.createsRepository === true, files: Array.isArray(plan.files) ? plan.files.map(String) : [],\n integrity: String(plan.integrity ?? ''), digest: String(plan.digest ?? ''), pullLine: String(plan.pullLine ?? ''),\n }\n }\n\n /** The person's yes: publish exactly the plan they read. The app sends it only if the plugin still matches that plan. */\n async publish(request: PublishRequest): Promise<PublishResponse> {\n this.#checkPublish(request)\n const answer = await this.#door(request.id, (door, folder) => door.confirmPublish(folder, { name: request.plugin, ...this.#options(request), confirm: request.plan }))\n const result = answer.value as { ok?: boolean, releaseUrl?: string, pullLine?: string, reason?: string, next?: string } | null\n if (result?.ok !== true) throw new LauncherRefusal(`Not published: ${result?.reason ?? 'the app did not answer'}${result?.next === undefined ? '' : `. ${result.next}`}`)\n return { releaseUrl: result.releaseUrl ?? '', pullLine: result.pullLine ?? '' }\n }\n\n /**\n * The app's own share command (`plugins/save/share-cli.ts`, acrylblends 1.5.5), run in its folder: it prints one JSON line, the plan or the result.\n * The app need not be running. An app made before that command has none, and is told how to get it.\n */\n async #shareCommand(request: AppSharePlanRequest, confirm: AppSharePlanView | undefined): Promise<Record<string, unknown>> {\n this.#toolsReady()\n const entry = this.#entry(request.id)\n if (request.owner !== undefined && !ACCOUNT_NAME.test(request.owner)) throw new LauncherRefusal(`\"${request.owner}\" is not a GitHub account name`)\n if (!this.#ports.exists(join(entry.path, SHARE_COMMAND))) {\n throw new LauncherRefusal(`This app was made before apps could share themselves. In ${entry.path} run \"npx acrylblends@latest upgrade\", then try again.`)\n }\n // The person's choice is kept where the app's own share reads it, so the plan, the share and every later save agree.\n if (request.visibility !== undefined && confirm === undefined) {\n try { setBlendVisibility(entry.path, request.visibility) } catch (cause) { throw new LauncherRefusal(`Could not set who may see it: ${cause instanceof Error ? cause.message : String(cause)}`) }\n }\n // The plan goes back base64url-encoded: on Windows the command starts through a shell, which would take JSON's quotes.\n const args = [SHARE_COMMAND, '--json', ...request.owner === undefined ? [] : ['--owner', request.owner], ...confirm === undefined ? [] : ['--confirm', Buffer.from(JSON.stringify(confirm), 'utf8').toString('base64url')]]\n const run = this.#ports.runner({ program: 'node', args, cwd: entry.path, env: this.#environment() })\n let output = ''\n run.onOutput((text) => { output += text })\n const end = await new Promise<{ code: number | null, notFound: boolean, error?: string }>((resolve) => { run.onEnd(resolve) })\n if (end.notFound) throw new LauncherRefusal('Node.js was not found on this machine. Install Node.js 22.19 or later from nodejs.org, then try again.')\n const line = output.split(/\\r?\\n/u).map(text => text.trim()).findLast(text => text.startsWith('{'))\n let answer: unknown\n try { answer = line === undefined ? undefined : JSON.parse(line) } catch { answer = undefined }\n if (answer === null || typeof answer !== 'object') throw new LauncherRefusal(tail(output) === '' ? 'the app did not answer' : tail(output))\n const value = answer as Record<string, unknown>\n if (value.ok === false) throw new LauncherRefusal(`Not shared: ${typeof value.reason === 'string' ? value.reason : 'the app refused'}`)\n return value\n }\n\n /** What sharing the app would send: the repository (a new one, or the remote it has), its visibility and how many changed files are saved first. Sends nothing. */\n async sharePlan(request: AppSharePlanRequest): Promise<AppSharePlanView> {\n const plan = await this.#shareCommand(request, undefined)\n if (typeof plan.repository !== 'string' || typeof plan.create !== 'boolean' || (plan.visibility !== 'private' && plan.visibility !== 'public') || typeof plan.changes !== 'number') {\n throw new LauncherRefusal('the app did not give a share plan')\n }\n return { repository: plan.repository, create: plan.create, visibility: plan.visibility, changes: plan.changes }\n }\n\n /** The person's yes: share exactly the plan they read. The app sends it only if it still matches that plan. */\n async share(request: AppShareRequest): Promise<AppShareResponse> {\n const result = await this.#shareCommand(request, request.plan)\n if (result.ok !== true || typeof result.remote !== 'string') throw new LauncherRefusal('Not shared: the app did not answer')\n return { remote: result.remote, created: result.created === true }\n }\n\n async health(probe: Runner = this.#ports.runner): Promise<HealthView> {\n const version = (program: string): Promise<string | undefined> => new Promise((resolve) => {\n const run = probe({ program, args: ['--version'], cwd: this.#ports.home, env: this.#environment() })\n let text = ''\n run.onOutput((chunk) => { text += chunk })\n run.onEnd(end => { resolve(end.code === 0 && !end.notFound ? text.trim().split(/\\s+/u)[0]?.replace(/^v/u, '') : undefined) })\n })\n const [node, npm] = await Promise.all([version('node'), version('npm')])\n return { ...node === undefined ? {} : { node }, ...npm === undefined ? {} : { npm }, modelKey: readModelKey(this.#ports.home) !== undefined, home: this.#ports.home }\n }\n\n /** The saved key, masked, for the screen's Settings and Health; never the key itself. */\n maskedModelKey(): string | undefined {\n const key = readModelKey(this.#ports.home)\n return key === undefined ? undefined : maskKey(key)\n }\n\n #environment(): Record<string, string | undefined> {\n const inherited = this.#ports.environment()\n // `modelEnv` and `githubEnv` return only what to add (the saved key or GitHub token, unless the environment already names one).\n // The fetched tools come first on PATH, so an app runs on the Node.js the launcher made sure of.\n return appEnvironment(toolsEnv(this.#ports.home, { ...inherited, ...modelEnv(this.#ports.home, inherited), ...githubEnv(this.#ports.home, inherited) }))\n }\n\n /** Who is signed in to GitHub here (the token apps get as GH_TOKEN), never the token. */\n github(): GithubView {\n return { available: githubClientId(this.#ports.environment()) !== undefined, login: readGithub(this.#ports.home)?.login ?? null }\n }\n\n /** Start GitHub's device sign-in: the code for the person; the device code stays here until it is approved, refused or expires. */\n async githubStart(): Promise<GithubStartView> {\n const clientId = githubClientId(this.#ports.environment())\n if (clientId === undefined) throw new LauncherRefusal('this build of Control Center has no GitHub app to sign in with')\n try {\n const started = await startGithubSignIn(clientId)\n this.#signIn = { clientId, deviceCode: started.deviceCode, until: Date.now() + started.expiresIn * 1000 }\n return { userCode: started.userCode, verificationUri: started.verificationUri, interval: started.interval }\n } catch (cause) {\n throw new LauncherRefusal(`GitHub sign-in could not start: ${cause instanceof Error ? cause.message : String(cause)}. Check the network and try again.`)\n }\n }\n\n /** One poll of the sign-in under way: pending, connected (the token is saved and every app started from now on gets it), or failed. */\n async githubPoll(): Promise<GithubPollView> {\n const signIn = this.#signIn\n if (signIn === undefined) return { state: 'failed', reason: 'no GitHub sign-in is under way: start it again' }\n if (Date.now() > signIn.until) { this.#signIn = undefined; return { state: 'failed', reason: 'the code expired: start the sign-in again' } }\n try {\n const answer = await pollGithubSignIn(this.#ports.home, signIn.clientId, signIn.deviceCode)\n if (answer.state !== 'pending') this.#signIn = undefined\n return answer\n } catch {\n // A network blip between polls: keep waiting; the code's own expiry ends a sign-in that never comes back.\n return { state: 'pending' }\n }\n }\n\n /** Forget the GitHub connection on this machine. Apps started from now on no longer get the token. */\n githubDisconnect(): GithubView {\n this.#signIn = undefined\n clearGithub(this.#ports.home)\n return this.github()\n }\n\n /**\n * Follow one process. For an app being started, `id` is known; for one being made it is not until the folder has its blend.yaml, which is when the app\n * is listed and the process becomes that app's.\n */\n #watch(id: string | undefined, run: Run, making: { folder: string, surface: Surface, job: Job } | undefined, desktop = false): void {\n const started: Started = { run, desktop, address: undefined, output: '' }\n let appId = id\n if (appId !== undefined) this.#started.set(appId, started)\n run.onOutput((text) => {\n started.output = tail(`${started.output}${text}`)\n if (making !== undefined && making.job.run === run) making.job.output = started.output\n started.address ??= ADDRESS.exec(text)?.[0]\n if (making !== undefined && appId === undefined && this.#ports.exists(join(making.folder, APP_MARKER))) {\n const listed = addApp(this.#ports.home, { path: making.folder, surface: making.surface }).entry\n appId = listed.id\n this.#started.set(appId, started)\n }\n if (making !== undefined && started.address !== undefined && making.job.status === 'running') making.job.status = 'done'\n })\n run.onEnd((end) => {\n if (appId !== undefined && this.#started.get(appId) === started) {\n this.#started.delete(appId)\n // An app that ends after being stopped on purpose is not a failure; one that ends on its own with a non-zero code is. A Desktop app that was up\n // ends when its window is closed, the normal way to stop it: that is not a failure either (it showed \"It stopped on its own\" with its start log).\n const closed = started.address !== undefined && readApps(this.#ports.home).find(entry => entry.id === appId)?.surface === 'desktop'\n if (end.code !== 0 && end.code !== null && !end.notFound && !closed) this.#failures.set(appId, started.output.trimEnd())\n }\n if (end.notFound) this.#note(making, 'failed', 'Node.js and npm were not found on this machine. Install Node.js 22.19 or later from nodejs.org, then try again.', id)\n else if (making !== undefined && making.job.status === 'running') {\n // `create-acrylblends` installs the app and ends cleanly without starting it: a clean end with the app listed is \"made\", and the app is started\n // the way the walk of the terminal ends (\"makes an app and runs it\").\n if (end.code === 0 && appId !== undefined) {\n // An app made from a registry Blend arrives without its dependencies (`acryl new --from` prints \"npm install\" as the next step; a starter installs\n // itself): install them here, so what is started can run.\n if (this.#ports.exists(join(making.folder, 'node_modules'))) this.#finish(appId, making.job)\n else this.#install(appId, making.folder, making.job)\n } else making.job.status = 'failed'\n }\n if (making !== undefined && making.job.status === 'failed' && making.job.message === undefined) making.job.message = started.output === '' ? (end.error ?? 'The command ended before the app was made.') : started.output.trimEnd()\n })\n }\n\n /** The job's last step: the app is made, so it is started (a Desktop app opens its window). */\n #finish(appId: string, job: Job): void {\n job.status = 'done'\n job.step = `Made. Starting ${job.name} now: its progress shows on its card below.`\n job.output = ''\n delete job.message\n try { this.start(appId) } catch (cause) { this.#failures.set(appId, cause instanceof Error ? cause.message : String(cause)) }\n }\n\n /** `npm install` in the new app's folder, as the job's second step; the job is still running while it does, and says so. */\n #install(appId: string, folder: string, job: Job): void {\n // The app is listed already; until its install ends its card shows it starting, with the install's lines, not as stopped.\n this.#installing.set(appId, job)\n job.step = 'Step 2 of 3: installing its dependencies (npm install, about a minute). Next: starting it.'\n job.output = ''\n // `--loglevel http` makes npm print each download, so the screen shows it working instead of a silent minute.\n const run = this.#ports.runner({ program: 'npm', args: ['install', '--loglevel', 'http'], cwd: folder, env: this.#environment() })\n job.run = run\n let output = ''\n run.onOutput((text) => { output = tail(`${output}${text}`); job.output = output })\n run.onEnd((end) => {\n this.#installing.delete(appId)\n if (job.run !== run) return\n if (end.notFound) { job.status = 'failed'; job.message = 'Node.js and npm were not found on this machine. Install Node.js 22.19 or later from nodejs.org, then try again.' } else if (end.code === 0) this.#finish(appId, job)\n else { job.status = 'failed'; job.message = output === '' ? (end.error ?? 'npm install ended before the app could run.') : output.trimEnd() }\n })\n }\n\n #note(making: { job: Job } | undefined, status: 'failed', message: string, id: string | undefined): void {\n if (making !== undefined) {\n making.job.status = status\n making.job.message = message\n } else if (id !== undefined) this.#failures.set(id, message)\n }\n}\n\n/** `0.2.0` is newer than `0.1.9`; anything that is not three numbers is never newer. */\nfunction newerVersion(candidate: string, current: string): boolean {\n const parse = (text: string): number[] | undefined => /^(\\d+)\\.(\\d+)\\.(\\d+)$/u.exec(text)?.slice(1).map(Number)\n const a = parse(candidate)\n const b = parse(current)\n if (a === undefined || b === undefined) return false\n for (let index = 0; index < 3; index += 1) if (a[index] !== b[index]) return (a[index] ?? 0) > (b[index] ?? 0)\n return false\n}\n","/**\n * The Control Center's service wired to this machine: real processes, the running apps' doors, the public registry, and the tools fetch. One wiring for\n * every face that runs the Control Center in a Node process: the Cordis Host plugin (index.ts) and the terminal Control Center (`acryl`, bundled from\n * apps/acryl-launcher-tui), so the window, the browser and the terminal do the same thing with the same code.\n */\nimport { existsSync, mkdirSync } from 'node:fs'\nimport { dirname, join } from 'node:path'\nimport { prepareTools } from '@acryldev/launcher'\nimport { fileDoor } from './door.ts'\nimport { readBlends } from './registry.ts'\nimport { spawnRunner } from './runner.ts'\nimport { LauncherService } from './service.ts'\n\n/** `home` is ACRYL's home (`~/.acryl`); new apps are suggested in the visible folder beside it (`~/ACRYL`): the home's parent, never a looked-up user folder. */\nexport function createNodeLauncher(home: string, environment: () => Readonly<Record<string, string | undefined>> = () => process.env): LauncherService {\n return new LauncherService({\n home,\n appsFolder: join(dirname(home), 'ACRYL'),\n runner: spawnRunner,\n environment,\n exists: path => existsSync(path),\n makeFolder: (path) => { mkdirSync(path, { recursive: true }) },\n blends: () => readBlends(),\n door: fileDoor(),\n // A computer without Node.js 22.19+ or gh gets them once, from their makers, into the home's tools folder.\n prepareTools: () => prepareTools(home, process.env),\n })\n}\n\nexport { LauncherRefusal, LauncherService } from './service.ts'\nexport { readBlends, RegistryUnavailable } from './registry.ts'\nexport { webboxesDeployUrl } from './contract.ts'\nexport type { AppView, BlendView, GithubPollView, GithubStartView, JobView, PluginView, StateResponse, Surface } from './contract.ts'\n"],"mappings":";;;;;;;;AAGA,MAAa,sBAAsB;AACnC,MAAa,sBAAsB,GAAG,oBAAoB;AAC1D,MAAa,uBAAuB,GAAG,oBAAoB;AAC3D,MAAa,oBAAoB,GAAG,oBAAoB;AACxD,MAAa,uBAAuB,GAAG,oBAAoB;AAC3D,MAAa,oBAAoB,GAAG,oBAAoB;AACxD,MAAa,sBAAsB,GAAG,oBAAoB;AAC1D,MAAa,qBAAqB,GAAG,oBAAoB;AACzD,MAAa,uBAAuB,GAAG,oBAAoB;;AAE3D,MAAa,oBAAoB,GAAG,oBAAoB;AACxD,MAAa,uBAAuB,GAAG,oBAAoB;AAC3D,MAAa,iCAAiC,GAAG,oBAAoB;AACrE,MAAa,wBAAwB,GAAG,oBAAoB;AAC5D,MAAa,4BAA4B,GAAG,oBAAoB;AAChE,MAAa,6BAA6B,GAAG,oBAAoB;AACjE,MAAa,wBAAwB,GAAG,oBAAoB;AAC5D,MAAa,2BAA2B,GAAG,oBAAoB;AAC/D,MAAa,sBAAsB,GAAG,oBAAoB;AAC1D,MAAa,uBAAuB,GAAG,oBAAoB;AAC3D,MAAa,6BAA6B,GAAG,oBAAoB;AACjE,MAAa,4BAA4B,GAAG,oBAAoB;AAChE,MAAa,kCAAkC,GAAG,oBAAoB;AAItE,MAAa,WAA+B;CAAC;CAAO;CAAW;AAAK;;AAEpE,MAAa,oBAAw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