@acryldev/launcher-desktop 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/lib/client.js +66 -38
- package/lib/client.js.map +1 -1
- package/lib/index.js +5 -996
- package/lib/index.js.map +1 -1
- package/lib/node-DxDbk2F0.js +1062 -0
- package/lib/node-DxDbk2F0.js.map +1 -0
- package/lib/node.js +2 -0
- package/lib/page.js +9 -9
- package/lib/types/contract.d.ts +9 -0
- package/lib/types/index.d.ts +5 -0
- package/lib/types/node.d.ts +7 -0
- package/lib/types/runner.d.ts +3 -0
- package/lib/types/service.d.ts +5 -1
- package/package.json +7 -3
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["TIMEOUT_MS","record","text","text","#ports","#started","#failures","#installing","#tools","#blends","#view","#job","#toolsReady","#installThenStart","#environment","#watch","#door","#entry","#checkPublish","#options","#shareCommand","#signIn","#note","#finish","#install"],"sources":["../src/contract.ts","../src/door.ts","../src/registry.ts","../src/tools.ts","../src/runner.ts","../src/service.ts","../src/route.ts","../src/index.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 launcher as tools an agent can call (spec 050 D11, T013): the same operations the screen offers, through the same `LauncherService`, so what an agent\n * does and what a person clicks cannot drift apart. They go into ACRYL's tool registry (`acrylTools`): the DSH chat has them, and agents ACRYL does not run\n * (Claude Code, Codex) reach them through `@acryldev/agent-control`'s loopback gateway, where their names are on the default allowlist. Nothing outward happens\n * here: a publish only produces the plan the person reads, and the person's click on the screen is the yes.\n */\nimport type { Context } from '@deepseek-ai/cordis'\nimport { defineAcrylTool, type AcrylToolDefinition } from '@acryldev/control'\nimport type { AppView } from './contract.ts'\nimport type { LauncherService } from './service.ts'\n\nexport const LAUNCHER_TOOLS = [\n 'acryl_launcher_help',\n 'acryl_launcher_apps',\n 'acryl_launcher_blends',\n 'acryl_launcher_new_app',\n 'acryl_launcher_start_app',\n 'acryl_launcher_stop_app',\n 'acryl_launcher_plugins',\n 'acryl_launcher_pull_plugin',\n 'acryl_launcher_publish_plan',\n] as const\n\nexport const LAUNCHER_HELP = `The ACRYL launcher is the first screen of ACRYL (Web and Desktop). Where things are:\n- My apps (left nav): every app made with ACRYL on this machine, as cards with a state (running, stopped), a surface (Web = served at an address, Desktop = a window of its own) and a Blend name. Select a card for its panel: Start or Stop, Open, Remove from list, its folder, and, while it runs, its Plugins.\n- + New app (top): asks where, a name, a starter (Blank, Node.js, Notes, Chat, To-do, Agent) and a surface; it runs \"acryl new <name> <starter>\" and installs the app (about a minute), then starts it.\n- Blends store (left nav): the public registry of ready-made apps (acrylblends.github.io/blends); \"Make an app\" on a card runs \"acryl new <name> --from <id>\".\n- Add a folder (top): puts an app you already have in the list (\"acryl apps add <folder>\").\n- Plugins of a running app (its card's panel): \"Pull a plugin\" takes github:owner/repo@version; \"Share plugin\" shows exactly what would be published and sends nothing until the person clicks \"Yes, publish\". An agent never publishes: it can only prepare the plan.\n- Running, Made by agents, Updates (not built yet), WebBoxes.ai (deploy is coming), Health (Node, npm and the model key), Settings (the look: ACRYL ADE or acryl.dev).\n- Assistant (left nav): this panel. ACRYL ADE (the agentic development environment) opens from its card on My apps.\nTools: acryl_launcher_apps lists the apps; acryl_launcher_new_app, _start_app and _stop_app change them; acryl_launcher_blends searches the registry; acryl_launcher_plugins and _pull_plugin work on a running app; acryl_launcher_publish_plan prepares a publish for the person to confirm.`\n\n/** An app as an agent reads it: the address without its launch token (the token is a secret of the person's session). */\nconst describeApp = (app: AppView): Record<string, unknown> => ({\n id: app.id, name: app.name, folder: app.path, blend: app.blend, surface: app.surface, state: app.state, madeBy: app.madeBy,\n ...app.address === undefined ? {} : { address: app.address.replace(/\\?.*$/u, '') },\n ...app.failure === undefined ? {} : { failure: app.failure },\n})\n\nconst text = (value: string) => [{ type: 'text' as const, text: value }]\n/** Every tool's value is the text an agent reads (JSON where it is data): a typed object output would need a schema per tool and gains nothing here. */\nconst asText = (value: unknown): string => JSON.stringify(value, null, 2)\nconst STRING = { type: 'string' } as const\n\n/** The tool definitions over one service; separate from registering them so a test can call each. */\nexport function launcherTools(service: LauncherService): readonly AcrylToolDefinition[] {\n return [\n defineAcrylTool({\n name: 'acryl_launcher_help',\n description: 'How to use the ACRYL launcher and where to find what: its screens, buttons and the other launcher tools. Call it first when asked about the launcher.',\n parameters: {},\n output: { schema: STRING, render: (_args, value: string) => text(value) },\n execute: () => LAUNCHER_HELP,\n }),\n defineAcrylTool({\n name: 'acryl_launcher_apps',\n description: 'The apps in the launcher\\'s list: id, folder, Blend, surface (web or desktop), state (running, starting, stopped, missing) and address when running; and the app being made, if any.',\n parameters: {},\n output: { schema: STRING, render: (_args, value: string) => text(value) },\n execute: () => {\n const state = service.state()\n return asText({ apps: state.apps.map(describeApp), making: state.job, newAppsGoIn: state.appsFolder })\n },\n }),\n defineAcrylTool({\n name: 'acryl_launcher_blends',\n description: 'Blends in the public registry that an app can be made from (id, name, category, description). Give a query to narrow it; at most 25 are returned.',\n parameters: { query: { type: 'string', description: 'words to look for in the name, id, category or description' } },\n output: { schema: STRING, render: (_args, value: string) => text(value) },\n execute: async (args) => {\n const needle = (args.query ?? '').trim().toLowerCase()\n const all = await service.blends()\n const found = all.filter(blend => needle === '' || `${blend.name} ${blend.id} ${blend.category} ${blend.description}`.toLowerCase().includes(needle))\n return asText({ total: found.length, blends: found.slice(0, 25).map(blend => ({ id: blend.id, name: blend.name, category: blend.category, description: blend.description })) })\n },\n }),\n defineAcrylTool({\n name: 'acryl_launcher_new_app',\n description: 'Make a new app, as the launcher\\'s + New app does: from a starter (blank, nodejs, notes, chat, todo, agent) or from a registry Blend id (acrylblends_launcher_blends), as a web or desktop app. It installs the app (about a minute) and starts it; watch with acryl_launcher_apps.',\n parameters: {\n name: { type: 'string', required: true, description: 'lower case letters, digits and dashes' },\n starter: { type: 'string', description: 'a starter; default blank. Not with blend.' },\n blend: { type: 'string', description: 'a registry Blend id such as acrylblends.csv-explorer. Not with starter.' },\n surface: { type: 'string', description: 'web (default) or desktop' },\n where: { type: 'string', description: 'the folder to make it in; default the launcher\\'s apps folder' },\n },\n output: { schema: STRING, render: (_args, value: string) => text(value) },\n execute: (args) => {\n const surface = args.surface === 'desktop' ? 'desktop' : args.surface === undefined || args.surface === 'web' ? 'web' : undefined\n if (surface === undefined) throw new Error('surface must be web or desktop')\n const where = args.where ?? service.state().appsFolder\n service.create({ where, name: args.name, surface, ...args.blend === undefined ? { starter: args.starter ?? 'blank' } : { blend: args.blend, ...args.starter === undefined ? {} : { starter: args.starter } } })\n return asText({ making: args.name, where, note: 'It is being made and installed (about a minute), then started. Call acryl_launcher_apps to watch.' })\n },\n }),\n defineAcrylTool({\n name: 'acryl_launcher_start_app',\n description: 'Start an app from the launcher\\'s list (a desktop app opens its own window); installs its dependencies first if it has none.',\n parameters: { app: { type: 'string', required: true, description: 'the app\\'s id from acryl_launcher_apps' } },\n output: { schema: STRING, render: (_args, value: string) => text(value) },\n execute: (args) => { service.start(args.app); return asText({ starting: args.app }) },\n }),\n defineAcrylTool({\n name: 'acryl_launcher_stop_app',\n description: 'Stop an app the launcher started.',\n parameters: { app: { type: 'string', required: true, description: 'the app\\'s id from acryl_launcher_apps' } },\n output: { schema: STRING, render: (_args, value: string) => text(value) },\n execute: (args) => { service.stop(args.app); return asText({ stopped: args.app }) },\n }),\n defineAcrylTool({\n name: 'acryl_launcher_plugins',\n description: 'The plugins of a RUNNING app: the ones made in it (shareable) and the ones pulled from a registry, with their source.',\n parameters: { app: { type: 'string', required: true, description: 'the app\\'s id' } },\n output: { schema: STRING, render: (_args, value: string) => text(value) },\n execute: async (args) => asText({ plugins: await service.plugins(args.app) }),\n }),\n defineAcrylTool({\n name: 'acryl_launcher_pull_plugin',\n description: 'Pull a plugin from a registry source into a RUNNING app, as the launcher\\'s Pull a plugin does. The source is github:owner/repo@version.',\n parameters: {\n app: { type: 'string', required: true, description: 'the app\\'s id' },\n source: { type: 'string', required: true, description: 'github:owner/repo@version' },\n },\n output: { schema: STRING, render: (_args, value: string) => text(value) },\n execute: async (args) => asText(await service.pullPlugin(args.app, args.source)),\n }),\n defineAcrylTool({\n name: 'acryl_launcher_publish_plan',\n description: 'Prepare publishing a plugin made in a RUNNING app: what would be sent (account, repository, version, license, files) and the line a friend pulls it with. Sends NOTHING: the person presses Share plugin on the app\\'s card in the launcher and says yes.',\n parameters: {\n app: { type: 'string', required: true, description: 'the app\\'s id' },\n plugin: { type: 'string', required: true, description: 'a plugin made in the app' },\n owner: { type: 'string', description: 'the GitHub account that would own the repository; default the signed-in one' },\n },\n output: { schema: STRING, render: (_args, value: string) => text(value) },\n execute: async (args) => asText({ plan: await service.publishPlan({ id: args.app, plugin: args.plugin, ...args.owner === undefined ? {} : { owner: args.owner } }), nextStep: 'Nothing was sent. Tell the person to press Share plugin on the app\\'s card and confirm.' }),\n }),\n ]\n}\n\n/** Register the tools in the registry; the disposer removes them. @returns disposer. */\nexport function registerLauncherTools(ctx: Context, service: LauncherService): () => void {\n const disposers = launcherTools(service).map(definition => ctx.acrylTools.register(definition))\n return () => { for (const dispose of disposers.reverse()) dispose() }\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 { existsSync } from 'node:fs'\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}\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\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 child = spawn(start.program, [...start.args], { cwd: command.cwd, env: command.env as NodeJS.ProcessEnv, shell: win, detached: !win, windowsHide: true, stdio: ['ignore', 'pipe', 'pipe'] })\n const outputs: Array<(text: string) => void> = []\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 for (const listener of ends) listener(end)\n }\n for (const stream of [child.stdout, child.stderr]) stream.on('data', (chunk: Buffer) => { for (const listener of outputs) listener(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 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 run = this.#ports.runner({ program: 'npm', args: ['run', (surface ?? entry.surface) === 'desktop' ? 'desktop' : 'dev'], cwd: entry.path, env: this.#environment() })\n this.#watch(id, run, undefined)\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, 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 stopAll(): void {\n for (const started of this.#started.values()) started.run.stop()\n this.#job?.run.stop()\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): void {\n const started: Started = { run, 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","/** Strict same-origin loopback routes for the ACRYL screen. Reads need the app's own page; a change needs the exact `Origin` and a small JSON body. */\nimport { Acryl } from '@acryldev/blends'\nimport { error } from '@acryldev/loopback-http'\nimport { INVALID_JSON, jsonBody, jsonContent, ownPage, privateApi, readJson, type ReportError } from '@acryldev/loopback-http/router'\nimport {\n LAUNCHER_ADD_PATH, LAUNCHER_ADE_PATH, LAUNCHER_ASSISTANT_FOLDER_PATH, LAUNCHER_BLENDS_PATH, LAUNCHER_PLUGIN_PULL_PATH, LAUNCHER_PLUGINS_PATH, LAUNCHER_PUBLISH_PATH, LAUNCHER_PUBLISH_PLAN_PATH, LAUNCHER_SHARE_PATH, LAUNCHER_GITHUB_PATH, LAUNCHER_GITHUB_START_PATH, LAUNCHER_GITHUB_POLL_PATH, LAUNCHER_GITHUB_DISCONNECT_PATH, LAUNCHER_SHARE_PLAN_PATH, LAUNCHER_API_PREFIX, LAUNCHER_HEALTH_PATH, LAUNCHER_NEW_PATH, LAUNCHER_REMOVE_PATH, LAUNCHER_START_PATH, LAUNCHER_STATE_PATH, LAUNCHER_STOP_PATH, LAUNCHER_UPDATE_PATH,\n SURFACES, type AppSharePlanRequest, type AppSharePlanView, type AppShareRequest, type NewAppRequest, type PublishPlanRequest, type PublishPlanView, type PublishRequest, type Surface,\n} from './contract.ts'\nimport { RegistryUnavailable } from './registry.ts'\nimport { LauncherRefusal, type LauncherService } from './service.ts'\n\nconst MAX_FIELD = 1024\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 | undefined => typeof value === 'string' && value.trim() !== '' && value.length <= MAX_FIELD ? value.trim() : undefined\nconst onlyKeys = (value: Record<string, unknown>, allowed: readonly string[]): boolean => Object.keys(value).every(key => allowed.includes(key))\n\nfunction parseOne(field: string) {\n return (value: unknown): string | undefined => {\n const body = record(value)\n return body === undefined || !onlyKeys(body, [field]) ? undefined : text(body[field])\n }\n}\n\nfunction parseNew(value: unknown): NewAppRequest | undefined {\n const body = record(value)\n if (body === undefined || !onlyKeys(body, ['where', 'name', 'starter', 'blend', 'surface'])) return undefined\n const where = text(body.where)\n const name = text(body.name)\n const starter = text(body.starter)\n const blend = text(body.blend)\n const surface = SURFACES.find((known): known is Surface => known === body.surface)\n if (where === undefined || name === undefined || surface === undefined || (starter === undefined) === (blend === undefined)) return undefined\n return { where, name, surface, ...starter === undefined ? {} : { starter }, ...blend === undefined ? {} : { blend } }\n}\n\nconst optional = (value: unknown): string | undefined | null => value === undefined ? undefined : text(value) ?? null\n\nfunction parsePublishPlan(value: unknown): PublishPlanRequest | undefined {\n const body = record(value)\n if (body === undefined || !onlyKeys(body, ['id', 'plugin', 'owner', 'license'])) return undefined\n const id = text(body.id)\n const plugin = text(body.plugin)\n const owner = optional(body.owner)\n const license = optional(body.license)\n if (id === undefined || plugin === undefined || owner === null || license === null) return undefined\n return { id, plugin, ...owner === undefined ? {} : { owner }, ...license === undefined ? {} : { license } }\n}\n\nfunction parsePlan(value: unknown): PublishPlanView | undefined {\n const plan = record(value)\n if (plan === undefined || !Array.isArray(plan.files) || !plan.files.every(file => typeof file === 'string')) return undefined\n const fields = ['owner', 'repo', 'version', 'visibility', 'license', 'integrity', 'digest', 'pullLine'] as const\n if (!fields.every(field => typeof plan[field] === 'string') || typeof plan.createsRepository !== 'boolean') return undefined\n return plan as unknown as PublishPlanView\n}\n\nfunction parsePublish(value: unknown): PublishRequest | undefined {\n const body = record(value)\n if (body === undefined) return undefined\n const { plan, ...rest } = body\n const request = parsePublishPlan(rest)\n const confirmed = parsePlan(plan)\n return request === undefined || confirmed === undefined ? undefined : { ...request, plan: confirmed }\n}\n\nfunction parseSharePlan(value: unknown): AppSharePlanRequest | undefined {\n const body = record(value)\n if (body === undefined || !onlyKeys(body, ['id', 'owner', 'visibility'])) return undefined\n const id = text(body.id)\n const owner = optional(body.owner)\n if (body.visibility !== undefined && body.visibility !== 'private' && body.visibility !== 'public') return undefined\n const visibility = body.visibility as 'private' | 'public' | undefined\n return id === undefined || owner === null ? undefined : { id, ...owner === undefined ? {} : { owner }, ...visibility === undefined ? {} : { visibility } }\n}\n\nconst nothing = (value: unknown): {} | undefined => (record(value) !== undefined && Object.keys(value as object).length === 0 ? {} : undefined)\n\nfunction parseShare(value: unknown): AppShareRequest | undefined {\n const body = record(value)\n if (body === undefined) return undefined\n const { plan, ...rest } = body\n const request = parseSharePlan(rest)\n const read = record(plan)\n if (request === undefined || read === undefined || !onlyKeys(read, ['repository', 'create', 'visibility', 'changes'])) return undefined\n const repository = text(read.repository)\n if (repository === undefined || typeof read.create !== 'boolean' || (read.visibility !== 'private' && read.visibility !== 'public')) return undefined\n if (typeof read.changes !== 'number' || !Number.isSafeInteger(read.changes) || read.changes < 0) return undefined\n const confirmed: AppSharePlanView = { repository, create: read.create, visibility: read.visibility, changes: read.changes }\n return { ...request, plan: confirmed }\n}\n\nexport function launcherRoutes(service: LauncherService, report: ReportError = () => {}): Acryl {\n const app = new Acryl()\n app.get(LAUNCHER_STATE_PATH, ownPage, (c) => c.json(service.state()))\n app.get(LAUNCHER_HEALTH_PATH, ownPage, async (c) => {\n try {\n return c.json({ ...await service.health(), keyMask: service.maskedModelKey() ?? null })\n } catch (cause) {\n report('check this machine', cause)\n return c.json(error('the launcher is unavailable'), 500)\n }\n })\n\n app.get(LAUNCHER_BLENDS_PATH, ownPage, async (c) => {\n try {\n return c.json({ blends: await service.blends() })\n } catch (cause) {\n if (cause instanceof RegistryUnavailable) return c.json(error(cause.message), 502)\n report('read the registry', cause)\n return c.json(error('the launcher is unavailable'), 500)\n }\n })\n\n /** A question or an action on a running app's door: same-origin JSON in, the answer out. A refusal is 409 with its reason. */\n const ask = <T>(path: string, parse: (value: unknown) => T | undefined, run: (request: T) => Promise<unknown>, operation: string): void => {\n app.post(path, ownPage, jsonContent, jsonBody(), async (c) => {\n const value = await readJson(c)\n if (value === INVALID_JSON) return c.json(error('invalid JSON request'), 400)\n const request = parse(value)\n if (request === undefined) return c.json(error(`invalid ${operation} request`), 400)\n try {\n return c.json(await run(request))\n } catch (cause) {\n if (cause instanceof LauncherRefusal) return c.json(error(cause.message), 409)\n report(operation, cause)\n return c.json(error('the launcher is unavailable'), 500)\n }\n })\n }\n ask(LAUNCHER_ASSISTANT_FOLDER_PATH, (value) => (record(value) !== undefined && Object.keys(value as object).length === 0 ? {} : undefined), () => Promise.resolve({ folder: service.assistantFolder() }), 'prepare the assistant\\'s folder')\n ask(LAUNCHER_PLUGINS_PATH, parseOne('id'), async id => ({ plugins: await service.plugins(id) }), 'list plugins')\n ask(LAUNCHER_PLUGIN_PULL_PATH, (value) => {\n const body = record(value)\n const id = body === undefined || !onlyKeys(body, ['id', 'source']) ? undefined : text(body.id)\n const source = body === undefined ? undefined : text(body.source)\n return id === undefined || source === undefined ? undefined : { id, source }\n }, request => service.pullPlugin(request.id, request.source), 'pull a plugin')\n ask(LAUNCHER_PUBLISH_PLAN_PATH, parsePublishPlan, request => service.publishPlan(request), 'plan a publish')\n ask(LAUNCHER_PUBLISH_PATH, parsePublish, request => service.publish(request), 'publish a plugin')\n ask(LAUNCHER_SHARE_PLAN_PATH, parseSharePlan, request => service.sharePlan(request), 'plan a share')\n ask(LAUNCHER_SHARE_PATH, parseShare, request => service.share(request), 'share an app')\n ask(LAUNCHER_GITHUB_PATH, nothing, () => Promise.resolve(service.github()), 'read the GitHub connection')\n ask(LAUNCHER_GITHUB_START_PATH, nothing, () => service.githubStart(), 'start the GitHub sign-in')\n ask(LAUNCHER_GITHUB_POLL_PATH, nothing, () => service.githubPoll(), 'check the GitHub sign-in')\n ask(LAUNCHER_GITHUB_DISCONNECT_PATH, nothing, () => Promise.resolve(service.githubDisconnect()), 'disconnect GitHub')\n\n /** A change: same-origin JSON in, the new state out. A refusal is 409 with its reason; anything else is reported and 500. */\n const change = <T>(path: string, parse: (value: unknown) => T | undefined, run: (request: T) => void, operation: string): void => {\n app.post(path, ownPage, jsonContent, jsonBody(), async (c) => {\n const value = await readJson(c)\n if (value === INVALID_JSON) return c.json(error('invalid JSON request'), 400)\n const request = parse(value)\n if (request === undefined) return c.json(error(`invalid ${operation} request`), 400)\n try {\n run(request)\n return c.json(service.state())\n } catch (cause) {\n if (cause instanceof LauncherRefusal) return c.json(error(cause.message), 409)\n report(operation, cause)\n return c.json(error('the launcher is unavailable'), 500)\n }\n })\n }\n change(LAUNCHER_ADD_PATH, parseOne('path'), path => { service.add(path) }, 'add an app')\n change(LAUNCHER_REMOVE_PATH, parseOne('id'), id => { service.remove(id) }, 'remove an app')\n change(LAUNCHER_NEW_PATH, parseNew, request => { service.create(request) }, 'make an app')\n change(LAUNCHER_START_PATH, parseOne('id'), id => { service.start(id) }, 'start an app')\n change(LAUNCHER_STOP_PATH, parseOne('id'), id => { service.stop(id) }, 'stop an app')\n change(LAUNCHER_UPDATE_PATH, parseOne('id'), id => { service.update(id) }, 'update an app')\n change(LAUNCHER_ADE_PATH, (value) => { const surface = parseOne('surface')(value); return surface === 'web' || surface === 'desktop' ? surface : undefined }, surface => { service.openAde(surface) }, 'open ACRYL ADE')\n return privateApi(LAUNCHER_API_PREFIX, app)\n}\n","/**\n * Cordis Host plugin: the routes behind the ACRYL screen, the first screen of the desktop app (spec 050 T012). It lists the apps in the ACRYL home's\n * `apps.json`, adds, removes, makes, starts and stops them, and stops everything it started when it unloads.\n * Capability boundary: the list and what runs on this machine (one service, `LauncherService`); the drawing is the Client half.\n */\nimport { existsSync, mkdirSync } from 'node:fs'\nimport { dirname, join } from 'node:path'\nimport { prepareTools } from '@acryldev/launcher'\nimport type { Context } from '@deepseek-ai/cordis'\nimport type {} from '@acryldev/blends/cordis/router'\nimport type {} from '@acryldev/blends/cordis/router-http'\nimport { LAUNCHER_API_PREFIX } from './contract.ts'\nimport { fileDoor } from './door.ts'\nimport { readBlends } from './registry.ts'\nimport { registerLauncherTools } from './tools.ts'\nimport { launcherRoutes } from './route.ts'\nimport { spawnRunner } from './runner.ts'\nimport { LauncherService } from './service.ts'\n\nexport const name = 'acryl-launcher-desktop'\n\n/** The part of the runtime's `appInstance` service ACRYL plugins read (every plugin declares exactly this shape, so the augmentations agree). */\ninterface AppInstanceService {\n readonly home: string\n readonly dshHome: string\n}\n\ndeclare module '@deepseek-ai/cordis' {\n interface Context {\n appInstance: AppInstanceService\n }\n}\n\nexport const inject = ['router', 'routerHttp', 'appInstance']\n\nexport function apply(ctx: Context): void {\n const home = ctx.appInstance.home\n const service = new LauncherService({\n home,\n // The visible folder next to ACRYL's hidden home (`~/.acryl` and `~/ACRYL`): the home's parent, never a looked-up user folder.\n appsFolder: join(dirname(home), 'ACRYL'),\n runner: spawnRunner,\n environment: () => process.env,\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 void service.prepareTools()\n const report = (operation: string, cause: unknown): void => {\n ctx.logger.error(`@acryldev/launcher-desktop: failed to ${operation}: ${cause instanceof Error ? cause.message : String(cause)}`)\n }\n // Every process this plugin started goes with it, whether it unloads or the app quits.\n ctx.effect(() => () => { service.stopAll() }, '@acryldev/launcher-desktop: apps it started')\n // The launcher as tools, for the DSH chat and, through @acryldev/agent-control's gateway, for Claude Code and Codex. Optional: with no tool registry nothing is lost.\n ctx.inject(['acrylTools'], (child) => {\n child.effect(() => registerLauncherTools(child, service), '@acryldev/launcher-desktop: launcher tools')\n })\n ctx.router.route('/', launcherRoutes(service, report))\n ctx.routerHttp.mount(LAUNCHER_API_PREFIX)\n}\n\nexport { LauncherRefusal, LauncherService } from './service.ts'\nexport * 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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AAQ,QAAQ;CAAE,GAAG,6CAA6C;CAE3F,IAAI,OAAO,CAAC,YAAY,IAAI,UAAU;EACpC,MAAM,aAAa,sBAAsB,OAAO,OAAO,GAAG,4CAA4C;CACxG,CAAC;CACD,IAAI,OAAO,MAAM,KAAK,eAAe,SAAS,MAAM,CAAC;CACrD,IAAI,WAAW,MAAM,mBAAmB;AAC1C"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["text"],"sources":["../src/tools.ts","../src/route.ts","../src/index.ts"],"sourcesContent":["/**\n * The launcher as tools an agent can call (spec 050 D11, T013): the same operations the screen offers, through the same `LauncherService`, so what an agent\n * does and what a person clicks cannot drift apart. They go into ACRYL's tool registry (`acrylTools`): the DSH chat has them, and agents ACRYL does not run\n * (Claude Code, Codex) reach them through `@acryldev/agent-control`'s loopback gateway, where their names are on the default allowlist. Nothing outward happens\n * here: a publish only produces the plan the person reads, and the person's click on the screen is the yes.\n */\nimport type { Context } from '@deepseek-ai/cordis'\nimport { defineAcrylTool, type AcrylToolDefinition } from '@acryldev/control'\nimport type { AppView } from './contract.ts'\nimport type { LauncherService } from './service.ts'\n\nexport const LAUNCHER_TOOLS = [\n 'acryl_launcher_help',\n 'acryl_launcher_apps',\n 'acryl_launcher_blends',\n 'acryl_launcher_new_app',\n 'acryl_launcher_start_app',\n 'acryl_launcher_stop_app',\n 'acryl_launcher_plugins',\n 'acryl_launcher_pull_plugin',\n 'acryl_launcher_publish_plan',\n] as const\n\nexport const LAUNCHER_HELP = `The ACRYL launcher is the first screen of ACRYL (Web and Desktop). Where things are:\n- My apps (left nav): every app made with ACRYL on this machine, as cards with a state (running, stopped), a surface (Web = served at an address, Desktop = a window of its own) and a Blend name. Select a card for its panel: Start or Stop, Open, Remove from list, its folder, and, while it runs, its Plugins.\n- + New app (top): asks where, a name, a starter (Blank, Node.js, Notes, Chat, To-do, Agent) and a surface; it runs \"acryl new <name> <starter>\" and installs the app (about a minute), then starts it.\n- Blends store (left nav): the public registry of ready-made apps (acrylblends.github.io/blends); \"Make an app\" on a card runs \"acryl new <name> --from <id>\".\n- Add a folder (top): puts an app you already have in the list (\"acryl apps add <folder>\").\n- Plugins of a running app (its card's panel): \"Pull a plugin\" takes github:owner/repo@version; \"Share plugin\" shows exactly what would be published and sends nothing until the person clicks \"Yes, publish\". An agent never publishes: it can only prepare the plan.\n- Running, Made by agents, Updates (not built yet), WebBoxes.ai (deploy is coming), Health (Node, npm and the model key), Settings (the look: ACRYL ADE or acryl.dev).\n- Assistant (left nav): this panel. ACRYL ADE (the agentic development environment) opens from its card on My apps.\nTools: acryl_launcher_apps lists the apps; acryl_launcher_new_app, _start_app and _stop_app change them; acryl_launcher_blends searches the registry; acryl_launcher_plugins and _pull_plugin work on a running app; acryl_launcher_publish_plan prepares a publish for the person to confirm.`\n\n/** An app as an agent reads it: the address without its launch token (the token is a secret of the person's session). */\nconst describeApp = (app: AppView): Record<string, unknown> => ({\n id: app.id, name: app.name, folder: app.path, blend: app.blend, surface: app.surface, state: app.state, madeBy: app.madeBy,\n ...app.address === undefined ? {} : { address: app.address.replace(/\\?.*$/u, '') },\n ...app.failure === undefined ? {} : { failure: app.failure },\n})\n\nconst text = (value: string) => [{ type: 'text' as const, text: value }]\n/** Every tool's value is the text an agent reads (JSON where it is data): a typed object output would need a schema per tool and gains nothing here. */\nconst asText = (value: unknown): string => JSON.stringify(value, null, 2)\nconst STRING = { type: 'string' } as const\n\n/** The tool definitions over one service; separate from registering them so a test can call each. */\nexport function launcherTools(service: LauncherService): readonly AcrylToolDefinition[] {\n return [\n defineAcrylTool({\n name: 'acryl_launcher_help',\n description: 'How to use the ACRYL launcher and where to find what: its screens, buttons and the other launcher tools. Call it first when asked about the launcher.',\n parameters: {},\n output: { schema: STRING, render: (_args, value: string) => text(value) },\n execute: () => LAUNCHER_HELP,\n }),\n defineAcrylTool({\n name: 'acryl_launcher_apps',\n description: 'The apps in the launcher\\'s list: id, folder, Blend, surface (web or desktop), state (running, starting, stopped, missing) and address when running; and the app being made, if any.',\n parameters: {},\n output: { schema: STRING, render: (_args, value: string) => text(value) },\n execute: () => {\n const state = service.state()\n return asText({ apps: state.apps.map(describeApp), making: state.job, newAppsGoIn: state.appsFolder })\n },\n }),\n defineAcrylTool({\n name: 'acryl_launcher_blends',\n description: 'Blends in the public registry that an app can be made from (id, name, category, description). Give a query to narrow it; at most 25 are returned.',\n parameters: { query: { type: 'string', description: 'words to look for in the name, id, category or description' } },\n output: { schema: STRING, render: (_args, value: string) => text(value) },\n execute: async (args) => {\n const needle = (args.query ?? '').trim().toLowerCase()\n const all = await service.blends()\n const found = all.filter(blend => needle === '' || `${blend.name} ${blend.id} ${blend.category} ${blend.description}`.toLowerCase().includes(needle))\n return asText({ total: found.length, blends: found.slice(0, 25).map(blend => ({ id: blend.id, name: blend.name, category: blend.category, description: blend.description })) })\n },\n }),\n defineAcrylTool({\n name: 'acryl_launcher_new_app',\n description: 'Make a new app, as the launcher\\'s + New app does: from a starter (blank, nodejs, notes, chat, todo, agent) or from a registry Blend id (acrylblends_launcher_blends), as a web or desktop app. It installs the app (about a minute) and starts it; watch with acryl_launcher_apps.',\n parameters: {\n name: { type: 'string', required: true, description: 'lower case letters, digits and dashes' },\n starter: { type: 'string', description: 'a starter; default blank. Not with blend.' },\n blend: { type: 'string', description: 'a registry Blend id such as acrylblends.csv-explorer. Not with starter.' },\n surface: { type: 'string', description: 'web (default) or desktop' },\n where: { type: 'string', description: 'the folder to make it in; default the launcher\\'s apps folder' },\n },\n output: { schema: STRING, render: (_args, value: string) => text(value) },\n execute: (args) => {\n const surface = args.surface === 'desktop' ? 'desktop' : args.surface === undefined || args.surface === 'web' ? 'web' : undefined\n if (surface === undefined) throw new Error('surface must be web or desktop')\n const where = args.where ?? service.state().appsFolder\n service.create({ where, name: args.name, surface, ...args.blend === undefined ? { starter: args.starter ?? 'blank' } : { blend: args.blend, ...args.starter === undefined ? {} : { starter: args.starter } } })\n return asText({ making: args.name, where, note: 'It is being made and installed (about a minute), then started. Call acryl_launcher_apps to watch.' })\n },\n }),\n defineAcrylTool({\n name: 'acryl_launcher_start_app',\n description: 'Start an app from the launcher\\'s list (a desktop app opens its own window); installs its dependencies first if it has none.',\n parameters: { app: { type: 'string', required: true, description: 'the app\\'s id from acryl_launcher_apps' } },\n output: { schema: STRING, render: (_args, value: string) => text(value) },\n execute: (args) => { service.start(args.app); return asText({ starting: args.app }) },\n }),\n defineAcrylTool({\n name: 'acryl_launcher_stop_app',\n description: 'Stop an app the launcher started.',\n parameters: { app: { type: 'string', required: true, description: 'the app\\'s id from acryl_launcher_apps' } },\n output: { schema: STRING, render: (_args, value: string) => text(value) },\n execute: (args) => { service.stop(args.app); return asText({ stopped: args.app }) },\n }),\n defineAcrylTool({\n name: 'acryl_launcher_plugins',\n description: 'The plugins of a RUNNING app: the ones made in it (shareable) and the ones pulled from a registry, with their source.',\n parameters: { app: { type: 'string', required: true, description: 'the app\\'s id' } },\n output: { schema: STRING, render: (_args, value: string) => text(value) },\n execute: async (args) => asText({ plugins: await service.plugins(args.app) }),\n }),\n defineAcrylTool({\n name: 'acryl_launcher_pull_plugin',\n description: 'Pull a plugin from a registry source into a RUNNING app, as the launcher\\'s Pull a plugin does. The source is github:owner/repo@version.',\n parameters: {\n app: { type: 'string', required: true, description: 'the app\\'s id' },\n source: { type: 'string', required: true, description: 'github:owner/repo@version' },\n },\n output: { schema: STRING, render: (_args, value: string) => text(value) },\n execute: async (args) => asText(await service.pullPlugin(args.app, args.source)),\n }),\n defineAcrylTool({\n name: 'acryl_launcher_publish_plan',\n description: 'Prepare publishing a plugin made in a RUNNING app: what would be sent (account, repository, version, license, files) and the line a friend pulls it with. Sends NOTHING: the person presses Share plugin on the app\\'s card in the launcher and says yes.',\n parameters: {\n app: { type: 'string', required: true, description: 'the app\\'s id' },\n plugin: { type: 'string', required: true, description: 'a plugin made in the app' },\n owner: { type: 'string', description: 'the GitHub account that would own the repository; default the signed-in one' },\n },\n output: { schema: STRING, render: (_args, value: string) => text(value) },\n execute: async (args) => asText({ plan: await service.publishPlan({ id: args.app, plugin: args.plugin, ...args.owner === undefined ? {} : { owner: args.owner } }), nextStep: 'Nothing was sent. Tell the person to press Share plugin on the app\\'s card and confirm.' }),\n }),\n ]\n}\n\n/** Register the tools in the registry; the disposer removes them. @returns disposer. */\nexport function registerLauncherTools(ctx: Context, service: LauncherService): () => void {\n const disposers = launcherTools(service).map(definition => ctx.acrylTools.register(definition))\n return () => { for (const dispose of disposers.reverse()) dispose() }\n}\n","/** Strict same-origin loopback routes for the ACRYL screen. Reads need the app's own page; a change needs the exact `Origin` and a small JSON body. */\nimport { Acryl } from '@acryldev/blends'\nimport { error } from '@acryldev/loopback-http'\nimport { INVALID_JSON, jsonBody, jsonContent, ownPage, privateApi, readJson, type ReportError } from '@acryldev/loopback-http/router'\nimport {\n LAUNCHER_ADD_PATH, LAUNCHER_ADE_PATH, LAUNCHER_ASSISTANT_FOLDER_PATH, LAUNCHER_BLENDS_PATH, LAUNCHER_PLUGIN_PULL_PATH, LAUNCHER_PLUGINS_PATH, LAUNCHER_PUBLISH_PATH, LAUNCHER_PUBLISH_PLAN_PATH, LAUNCHER_SHARE_PATH, LAUNCHER_GITHUB_PATH, LAUNCHER_GITHUB_START_PATH, LAUNCHER_GITHUB_POLL_PATH, LAUNCHER_GITHUB_DISCONNECT_PATH, LAUNCHER_SHARE_PLAN_PATH, LAUNCHER_API_PREFIX, LAUNCHER_HEALTH_PATH, LAUNCHER_NEW_PATH, LAUNCHER_REMOVE_PATH, LAUNCHER_START_PATH, LAUNCHER_STATE_PATH, LAUNCHER_STOP_PATH, LAUNCHER_UPDATE_PATH,\n SURFACES, type AppSharePlanRequest, type AppSharePlanView, type AppShareRequest, type NewAppRequest, type PublishPlanRequest, type PublishPlanView, type PublishRequest, type Surface,\n} from './contract.ts'\nimport { RegistryUnavailable } from './registry.ts'\nimport { LauncherRefusal, type LauncherService } from './service.ts'\n\nconst MAX_FIELD = 1024\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 | undefined => typeof value === 'string' && value.trim() !== '' && value.length <= MAX_FIELD ? value.trim() : undefined\nconst onlyKeys = (value: Record<string, unknown>, allowed: readonly string[]): boolean => Object.keys(value).every(key => allowed.includes(key))\n\nfunction parseOne(field: string) {\n return (value: unknown): string | undefined => {\n const body = record(value)\n return body === undefined || !onlyKeys(body, [field]) ? undefined : text(body[field])\n }\n}\n\nfunction parseNew(value: unknown): NewAppRequest | undefined {\n const body = record(value)\n if (body === undefined || !onlyKeys(body, ['where', 'name', 'starter', 'blend', 'surface'])) return undefined\n const where = text(body.where)\n const name = text(body.name)\n const starter = text(body.starter)\n const blend = text(body.blend)\n const surface = SURFACES.find((known): known is Surface => known === body.surface)\n if (where === undefined || name === undefined || surface === undefined || (starter === undefined) === (blend === undefined)) return undefined\n return { where, name, surface, ...starter === undefined ? {} : { starter }, ...blend === undefined ? {} : { blend } }\n}\n\nconst optional = (value: unknown): string | undefined | null => value === undefined ? undefined : text(value) ?? null\n\nfunction parsePublishPlan(value: unknown): PublishPlanRequest | undefined {\n const body = record(value)\n if (body === undefined || !onlyKeys(body, ['id', 'plugin', 'owner', 'license'])) return undefined\n const id = text(body.id)\n const plugin = text(body.plugin)\n const owner = optional(body.owner)\n const license = optional(body.license)\n if (id === undefined || plugin === undefined || owner === null || license === null) return undefined\n return { id, plugin, ...owner === undefined ? {} : { owner }, ...license === undefined ? {} : { license } }\n}\n\nfunction parsePlan(value: unknown): PublishPlanView | undefined {\n const plan = record(value)\n if (plan === undefined || !Array.isArray(plan.files) || !plan.files.every(file => typeof file === 'string')) return undefined\n const fields = ['owner', 'repo', 'version', 'visibility', 'license', 'integrity', 'digest', 'pullLine'] as const\n if (!fields.every(field => typeof plan[field] === 'string') || typeof plan.createsRepository !== 'boolean') return undefined\n return plan as unknown as PublishPlanView\n}\n\nfunction parsePublish(value: unknown): PublishRequest | undefined {\n const body = record(value)\n if (body === undefined) return undefined\n const { plan, ...rest } = body\n const request = parsePublishPlan(rest)\n const confirmed = parsePlan(plan)\n return request === undefined || confirmed === undefined ? undefined : { ...request, plan: confirmed }\n}\n\nfunction parseSharePlan(value: unknown): AppSharePlanRequest | undefined {\n const body = record(value)\n if (body === undefined || !onlyKeys(body, ['id', 'owner', 'visibility'])) return undefined\n const id = text(body.id)\n const owner = optional(body.owner)\n if (body.visibility !== undefined && body.visibility !== 'private' && body.visibility !== 'public') return undefined\n const visibility = body.visibility as 'private' | 'public' | undefined\n return id === undefined || owner === null ? undefined : { id, ...owner === undefined ? {} : { owner }, ...visibility === undefined ? {} : { visibility } }\n}\n\nconst nothing = (value: unknown): {} | undefined => (record(value) !== undefined && Object.keys(value as object).length === 0 ? {} : undefined)\n\nfunction parseShare(value: unknown): AppShareRequest | undefined {\n const body = record(value)\n if (body === undefined) return undefined\n const { plan, ...rest } = body\n const request = parseSharePlan(rest)\n const read = record(plan)\n if (request === undefined || read === undefined || !onlyKeys(read, ['repository', 'create', 'visibility', 'changes'])) return undefined\n const repository = text(read.repository)\n if (repository === undefined || typeof read.create !== 'boolean' || (read.visibility !== 'private' && read.visibility !== 'public')) return undefined\n if (typeof read.changes !== 'number' || !Number.isSafeInteger(read.changes) || read.changes < 0) return undefined\n const confirmed: AppSharePlanView = { repository, create: read.create, visibility: read.visibility, changes: read.changes }\n return { ...request, plan: confirmed }\n}\n\nexport function launcherRoutes(service: LauncherService, report: ReportError = () => {}): Acryl {\n const app = new Acryl()\n app.get(LAUNCHER_STATE_PATH, ownPage, (c) => c.json(service.state()))\n app.get(LAUNCHER_HEALTH_PATH, ownPage, async (c) => {\n try {\n return c.json({ ...await service.health(), keyMask: service.maskedModelKey() ?? null })\n } catch (cause) {\n report('check this machine', cause)\n return c.json(error('the launcher is unavailable'), 500)\n }\n })\n\n app.get(LAUNCHER_BLENDS_PATH, ownPage, async (c) => {\n try {\n return c.json({ blends: await service.blends() })\n } catch (cause) {\n if (cause instanceof RegistryUnavailable) return c.json(error(cause.message), 502)\n report('read the registry', cause)\n return c.json(error('the launcher is unavailable'), 500)\n }\n })\n\n /** A question or an action on a running app's door: same-origin JSON in, the answer out. A refusal is 409 with its reason. */\n const ask = <T>(path: string, parse: (value: unknown) => T | undefined, run: (request: T) => Promise<unknown>, operation: string): void => {\n app.post(path, ownPage, jsonContent, jsonBody(), async (c) => {\n const value = await readJson(c)\n if (value === INVALID_JSON) return c.json(error('invalid JSON request'), 400)\n const request = parse(value)\n if (request === undefined) return c.json(error(`invalid ${operation} request`), 400)\n try {\n return c.json(await run(request))\n } catch (cause) {\n if (cause instanceof LauncherRefusal) return c.json(error(cause.message), 409)\n report(operation, cause)\n return c.json(error('the launcher is unavailable'), 500)\n }\n })\n }\n ask(LAUNCHER_ASSISTANT_FOLDER_PATH, (value) => (record(value) !== undefined && Object.keys(value as object).length === 0 ? {} : undefined), () => Promise.resolve({ folder: service.assistantFolder() }), 'prepare the assistant\\'s folder')\n ask(LAUNCHER_PLUGINS_PATH, parseOne('id'), async id => ({ plugins: await service.plugins(id) }), 'list plugins')\n ask(LAUNCHER_PLUGIN_PULL_PATH, (value) => {\n const body = record(value)\n const id = body === undefined || !onlyKeys(body, ['id', 'source']) ? undefined : text(body.id)\n const source = body === undefined ? undefined : text(body.source)\n return id === undefined || source === undefined ? undefined : { id, source }\n }, request => service.pullPlugin(request.id, request.source), 'pull a plugin')\n ask(LAUNCHER_PUBLISH_PLAN_PATH, parsePublishPlan, request => service.publishPlan(request), 'plan a publish')\n ask(LAUNCHER_PUBLISH_PATH, parsePublish, request => service.publish(request), 'publish a plugin')\n ask(LAUNCHER_SHARE_PLAN_PATH, parseSharePlan, request => service.sharePlan(request), 'plan a share')\n ask(LAUNCHER_SHARE_PATH, parseShare, request => service.share(request), 'share an app')\n ask(LAUNCHER_GITHUB_PATH, nothing, () => Promise.resolve(service.github()), 'read the GitHub connection')\n ask(LAUNCHER_GITHUB_START_PATH, nothing, () => service.githubStart(), 'start the GitHub sign-in')\n ask(LAUNCHER_GITHUB_POLL_PATH, nothing, () => service.githubPoll(), 'check the GitHub sign-in')\n ask(LAUNCHER_GITHUB_DISCONNECT_PATH, nothing, () => Promise.resolve(service.githubDisconnect()), 'disconnect GitHub')\n\n /** A change: same-origin JSON in, the new state out. A refusal is 409 with its reason; anything else is reported and 500. */\n const change = <T>(path: string, parse: (value: unknown) => T | undefined, run: (request: T) => void, operation: string): void => {\n app.post(path, ownPage, jsonContent, jsonBody(), async (c) => {\n const value = await readJson(c)\n if (value === INVALID_JSON) return c.json(error('invalid JSON request'), 400)\n const request = parse(value)\n if (request === undefined) return c.json(error(`invalid ${operation} request`), 400)\n try {\n run(request)\n return c.json(service.state())\n } catch (cause) {\n if (cause instanceof LauncherRefusal) return c.json(error(cause.message), 409)\n report(operation, cause)\n return c.json(error('the launcher is unavailable'), 500)\n }\n })\n }\n change(LAUNCHER_ADD_PATH, parseOne('path'), path => { service.add(path) }, 'add an app')\n change(LAUNCHER_REMOVE_PATH, parseOne('id'), id => { service.remove(id) }, 'remove an app')\n change(LAUNCHER_NEW_PATH, parseNew, request => { service.create(request) }, 'make an app')\n change(LAUNCHER_START_PATH, parseOne('id'), id => { service.start(id) }, 'start an app')\n change(LAUNCHER_STOP_PATH, parseOne('id'), id => { service.stop(id) }, 'stop an app')\n change(LAUNCHER_UPDATE_PATH, parseOne('id'), id => { service.update(id) }, 'update an app')\n change(LAUNCHER_ADE_PATH, (value) => { const surface = parseOne('surface')(value); return surface === 'web' || surface === 'desktop' ? surface : undefined }, surface => { service.openAde(surface) }, 'open ACRYL ADE')\n return privateApi(LAUNCHER_API_PREFIX, app)\n}\n","/**\n * Cordis Host plugin: the routes behind the ACRYL screen, the first screen of the desktop app (spec 050 T012). It lists the apps in the ACRYL home's\n * `apps.json`, adds, removes, makes, starts and stops them, and stops everything it started when it unloads.\n * Capability boundary: the list and what runs on this machine (one service, `LauncherService`); the drawing is the Client half.\n */\nimport type { Context } from '@deepseek-ai/cordis'\nimport type {} from '@acryldev/blends/cordis/router'\nimport type {} from '@acryldev/blends/cordis/router-http'\nimport { LAUNCHER_API_PREFIX } from './contract.ts'\nimport { createNodeLauncher } from './node.ts'\nimport { registerLauncherTools } from './tools.ts'\nimport { launcherRoutes } from './route.ts'\n\nexport const name = 'acryl-launcher-desktop'\n\n/** The part of the runtime's `appInstance` service ACRYL plugins read (every plugin declares exactly this shape, so the augmentations agree). */\ninterface AppInstanceService {\n readonly home: string\n readonly dshHome: string\n}\n\ndeclare module '@deepseek-ai/cordis' {\n interface Context {\n appInstance: AppInstanceService\n }\n}\n\nexport const inject = ['router', 'routerHttp', 'appInstance']\n\nexport function apply(ctx: Context): void {\n const service = createNodeLauncher(ctx.appInstance.home)\n void service.prepareTools()\n const report = (operation: string, cause: unknown): void => {\n ctx.logger.error(`@acryldev/launcher-desktop: failed to ${operation}: ${cause instanceof Error ? cause.message : String(cause)}`)\n }\n // Every process this plugin started goes with it, whether it unloads or the app quits.\n ctx.effect(() => () => {\n const kept = service.stopAll()\n if (kept.length > 0) ctx.logger.info(`left open (a Desktop app with its window up; closing the window stops it): ${kept.join(', ')}`)\n }, '@acryldev/launcher-desktop: apps it started')\n // The launcher as tools, for the DSH chat and, through @acryldev/agent-control's gateway, for Claude Code and Codex. Optional: with no tool registry nothing is lost.\n ctx.inject(['acrylTools'], (child) => {\n child.effect(() => registerLauncherTools(child, service), '@acryldev/launcher-desktop: launcher tools')\n })\n ctx.router.route('/', launcherRoutes(service, report))\n ctx.routerHttp.mount(LAUNCHER_API_PREFIX)\n}\n\nexport { LauncherRefusal, LauncherService } from './service.ts'\nexport * from './contract.ts'\n"],"mappings":";;;;;;AAuBA,MAAa,gBAAgB;;;;;;;;;;AAW7B,MAAM,eAAe,SAA2C;CAC9D,IAAI,IAAI;CAAI,MAAM,IAAI;CAAM,QAAQ,IAAI;CAAM,OAAO,IAAI;CAAO,SAAS,IAAI;CAAS,OAAO,IAAI;CAAO,QAAQ,IAAI;CACpH,GAAG,IAAI,YAAY,KAA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