@acryldev/launcher-desktop 0.1.8 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/client.js +474 -107
- package/lib/client.js.map +1 -1
- package/lib/index.js +8 -2
- package/lib/index.js.map +1 -1
- package/lib/{node-gnGasVKs.js → node-C_SuDIqi.js} +220 -6
- package/lib/node-C_SuDIqi.js.map +1 -0
- package/lib/node.js +1 -1
- package/lib/page.js +27 -13
- package/lib/types/client/api.d.ts +2 -0
- package/lib/types/client/model.d.ts +17 -1
- package/lib/types/contract.d.ts +36 -0
- package/lib/types/registry.d.ts +3 -1
- package/lib/types/self-update.d.ts +43 -0
- package/lib/types/service.d.ts +16 -0
- package/package.json +4 -4
- package/lib/node-gnGasVKs.js.map +0 -1
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as LAUNCHER_UPDATE_PATH, C as LAUNCHER_PUBLISH_PLAN_PATH, D as LAUNCHER_START_PATH, E as LAUNCHER_SHARE_PLAN_PATH, F as
|
|
1
|
+
import { A as LAUNCHER_UPDATE_PATH, C as LAUNCHER_PUBLISH_PLAN_PATH, D as LAUNCHER_START_PATH, E as LAUNCHER_SHARE_PLAN_PATH, F as SURFACES, I as WEBBOXES_NEW_BOX, L as webboxesDeployBlendUrl, M as LICENSE_ID, N as MAKEABLE_SURFACES, O as LAUNCHER_STATE_PATH, P as PLUGIN_NAME, R as webboxesDeployUrl, S as LAUNCHER_PUBLISH_PATH, T as LAUNCHER_SHARE_PATH, _ as LAUNCHER_GITHUB_START_PATH, b as LAUNCHER_PLUGINS_PATH, c as BLEND_SOURCE, d as LAUNCHER_API_PREFIX, f as LAUNCHER_ASSISTANT_FOLDER_PATH, g as LAUNCHER_GITHUB_POLL_PATH, h as LAUNCHER_GITHUB_PATH, i as RegistryUnavailable, j as LAUNCHER_UPDATE_SELF_PATH, k as LAUNCHER_STOP_PATH, l as LAUNCHER_ADD_PATH, m as LAUNCHER_GITHUB_DISCONNECT_PATH, n as LauncherRefusal, o as ACCOUNT_NAME, p as LAUNCHER_BLENDS_PATH, r as LauncherService, s as BLEND_ID, t as createNodeLauncher, u as LAUNCHER_ADE_PATH, v as LAUNCHER_HEALTH_PATH, w as LAUNCHER_REMOVE_PATH, x as LAUNCHER_PLUGIN_PULL_PATH, y as LAUNCHER_NEW_PATH } from "./node-C_SuDIqi.js";
|
|
2
2
|
import { defineAcrylTool } from "@acryldev/control";
|
|
3
3
|
import { Acryl } from "@acryldev/blends";
|
|
4
4
|
import { error } from "@acryldev/loopback-http";
|
|
@@ -467,6 +467,12 @@ function launcherRoutes(service, report = () => {}) {
|
|
|
467
467
|
change(LAUNCHER_UPDATE_PATH, parseOne("id"), (id) => {
|
|
468
468
|
service.update(id);
|
|
469
469
|
}, "update an app");
|
|
470
|
+
change(LAUNCHER_UPDATE_SELF_PATH, (value) => {
|
|
471
|
+
const body = record(value);
|
|
472
|
+
return body !== void 0 && onlyKeys(body, []) ? true : void 0;
|
|
473
|
+
}, () => {
|
|
474
|
+
service.updateSelf();
|
|
475
|
+
}, "update this app");
|
|
470
476
|
change(LAUNCHER_ADE_PATH, (value) => {
|
|
471
477
|
const surface = parseOne("surface")(value);
|
|
472
478
|
return surface === "web" || surface === "desktop" ? surface : void 0;
|
|
@@ -500,6 +506,6 @@ function apply(ctx) {
|
|
|
500
506
|
ctx.routerHttp.mount(LAUNCHER_API_PREFIX);
|
|
501
507
|
}
|
|
502
508
|
//#endregion
|
|
503
|
-
export { ACCOUNT_NAME, BLEND_ID, BLEND_SOURCE, LAUNCHER_ADD_PATH, LAUNCHER_ADE_PATH, LAUNCHER_API_PREFIX, LAUNCHER_ASSISTANT_FOLDER_PATH, LAUNCHER_BLENDS_PATH, LAUNCHER_GITHUB_DISCONNECT_PATH, LAUNCHER_GITHUB_PATH, LAUNCHER_GITHUB_POLL_PATH, LAUNCHER_GITHUB_START_PATH, LAUNCHER_HEALTH_PATH, LAUNCHER_NEW_PATH, LAUNCHER_PLUGINS_PATH, LAUNCHER_PLUGIN_PULL_PATH, LAUNCHER_PUBLISH_PATH, LAUNCHER_PUBLISH_PLAN_PATH, LAUNCHER_REMOVE_PATH, LAUNCHER_SHARE_PATH, LAUNCHER_SHARE_PLAN_PATH, LAUNCHER_START_PATH, LAUNCHER_STATE_PATH, LAUNCHER_STOP_PATH, LAUNCHER_UPDATE_PATH, LICENSE_ID, LauncherRefusal, LauncherService, MAKEABLE_SURFACES, PLUGIN_NAME, SURFACES, WEBBOXES_NEW_BOX, apply, inject, name, webboxesDeployUrl };
|
|
509
|
+
export { ACCOUNT_NAME, BLEND_ID, BLEND_SOURCE, LAUNCHER_ADD_PATH, LAUNCHER_ADE_PATH, LAUNCHER_API_PREFIX, LAUNCHER_ASSISTANT_FOLDER_PATH, LAUNCHER_BLENDS_PATH, LAUNCHER_GITHUB_DISCONNECT_PATH, LAUNCHER_GITHUB_PATH, LAUNCHER_GITHUB_POLL_PATH, LAUNCHER_GITHUB_START_PATH, LAUNCHER_HEALTH_PATH, LAUNCHER_NEW_PATH, LAUNCHER_PLUGINS_PATH, LAUNCHER_PLUGIN_PULL_PATH, LAUNCHER_PUBLISH_PATH, LAUNCHER_PUBLISH_PLAN_PATH, LAUNCHER_REMOVE_PATH, LAUNCHER_SHARE_PATH, LAUNCHER_SHARE_PLAN_PATH, LAUNCHER_START_PATH, LAUNCHER_STATE_PATH, LAUNCHER_STOP_PATH, LAUNCHER_UPDATE_PATH, LAUNCHER_UPDATE_SELF_PATH, LICENSE_ID, LauncherRefusal, LauncherService, MAKEABLE_SURFACES, PLUGIN_NAME, SURFACES, WEBBOXES_NEW_BOX, apply, inject, name, webboxesDeployBlendUrl, webboxesDeployUrl };
|
|
504
510
|
|
|
505
511
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,KAAA,IAAY,CAAC,IAAI,EAAE,SAAS,IAAI,QAAQ,QAAQ,UAAU,EAAE,EAAE;CACjF,GAAG,IAAI,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,SAAS,IAAI,QAAQ;AAC7D;AAEA,MAAMA,UAAQ,UAAkB,CAAC;CAAE,MAAM;CAAiB,MAAM;AAAM,CAAC;;AAEvE,MAAM,UAAU,UAA2B,KAAK,UAAU,OAAO,MAAM,CAAC;AACxE,MAAM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../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, LAUNCHER_UPDATE_SELF_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_UPDATE_SELF_PATH, (value) => { const body = record(value); return body !== undefined && onlyKeys(body, []) ? true : undefined }, () => { service.updateSelf() }, 'update this 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,KAAA,IAAY,CAAC,IAAI,EAAE,SAAS,IAAI,QAAQ,QAAQ,UAAU,EAAE,EAAE;CACjF,GAAG,IAAI,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,SAAS,IAAI,QAAQ;AAC7D;AAEA,MAAMA,UAAQ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,IAAI,GAAG;CACtI,GAAG,6CAA6C;CAEhD,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"}
|
|
@@ -15,6 +15,8 @@ const LAUNCHER_NEW_PATH = `${LAUNCHER_API_PREFIX}/new`;
|
|
|
15
15
|
const LAUNCHER_START_PATH = `${LAUNCHER_API_PREFIX}/start`;
|
|
16
16
|
const LAUNCHER_STOP_PATH = `${LAUNCHER_API_PREFIX}/stop`;
|
|
17
17
|
const LAUNCHER_UPDATE_PATH = `${LAUNCHER_API_PREFIX}/update`;
|
|
18
|
+
/** Update the Control Center itself (the Blend copy it runs from) to its Blend's newer release. */
|
|
19
|
+
const LAUNCHER_UPDATE_SELF_PATH = `${LAUNCHER_API_PREFIX}/update-self`;
|
|
18
20
|
/** 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. */
|
|
19
21
|
const LAUNCHER_ADE_PATH = `${LAUNCHER_API_PREFIX}/ade`;
|
|
20
22
|
const LAUNCHER_BLENDS_PATH = `${LAUNCHER_API_PREFIX}/blends`;
|
|
@@ -43,6 +45,20 @@ function webboxesDeployUrl(github, name) {
|
|
|
43
45
|
url.searchParams.set("name", name.toLowerCase().replace(/[^a-z0-9-]+/gu, "-").replace(/^-+|-+$/gu, "").slice(0, 40));
|
|
44
46
|
return url.href;
|
|
45
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* WebBoxes.ai's New WebBox form for a store Blend: with `?blend=<id>` the form opens on that registry Blend (the person signs in and presses
|
|
50
|
+
* Create there). A community Blend that lives on GitHub rather than in the registry (`source` is `github:owner/repo#tag`) deploys from its
|
|
51
|
+
* repository, as a shared app does.
|
|
52
|
+
*/
|
|
53
|
+
function webboxesDeployBlendUrl(blend) {
|
|
54
|
+
const name = (blend.id.split(".").pop() ?? blend.id).toLowerCase().replace(/[^a-z0-9-]+/gu, "-").replace(/^-+|-+$/gu, "").slice(0, 40);
|
|
55
|
+
const repository = /^github:([A-Za-z0-9][A-Za-z0-9-]*\/[A-Za-z0-9_.-]+)(?:#.*)?$/u.exec(blend.source ?? "");
|
|
56
|
+
if (repository?.[1] !== void 0) return webboxesDeployUrl(`https://github.com/${repository[1]}`, name);
|
|
57
|
+
const url = new URL(WEBBOXES_NEW_BOX);
|
|
58
|
+
url.searchParams.set("blend", blend.id);
|
|
59
|
+
url.searchParams.set("name", name);
|
|
60
|
+
return url.href;
|
|
61
|
+
}
|
|
46
62
|
/** A Blend id as `acryl new --from` takes it: it starts with a letter or digit, so it can never read as an option. */
|
|
47
63
|
/** WebBoxes.ai's WebBoxes page: with `github` (a public https://github.com/owner/repo) and `name` it opens the New WebBox form filled in. */
|
|
48
64
|
const WEBBOXES_NEW_BOX = "https://webboxes.ai/dashboard/webboxes";
|
|
@@ -123,6 +139,8 @@ function fileDoor(fetchImpl = (input, init) => fetch(input, init), read = (path)
|
|
|
123
139
|
const REGISTRY_INDEX = "https://acrylblends.github.io/registry/index.json";
|
|
124
140
|
/** Blends released by people outside the ACRYL project and found on GitHub by the registry's hourly sync (origin `community`, each with its `source`). */
|
|
125
141
|
const REGISTRY_DISCOVERED = "https://acrylblends.github.io/registry/discovered.json";
|
|
142
|
+
/** Where the store files each Blend (category, subcategory, its page, its screenshot) and the store's categories in order; the website writes it. */
|
|
143
|
+
const REGISTRY_PLACEMENT = "https://acrylblends.github.io/registry/placement.json";
|
|
126
144
|
const TIMEOUT_MS = 1e4;
|
|
127
145
|
var RegistryUnavailable = class extends Error {};
|
|
128
146
|
const record = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
@@ -142,11 +160,51 @@ async function entriesOf(fetchImpl, url) {
|
|
|
142
160
|
if (!Array.isArray(entries)) throw new RegistryUnavailable("The registry answered, but its list could not be read.");
|
|
143
161
|
return entries;
|
|
144
162
|
}
|
|
163
|
+
const httpsUrl = (value) => typeof value === "string" && /^https:\/\/\S+$/u.test(value) ? value : void 0;
|
|
164
|
+
/**
|
|
165
|
+
* Each Blend's place in the store, by id, from the registry's placement.json. Optional: when it cannot be read, the store lists the Blends without
|
|
166
|
+
* categories (the list itself comes from the index).
|
|
167
|
+
*/
|
|
168
|
+
async function placementsOf(fetchImpl, url) {
|
|
169
|
+
const placed = /* @__PURE__ */ new Map();
|
|
170
|
+
let body;
|
|
171
|
+
try {
|
|
172
|
+
const response = await fetchImpl(url, { signal: AbortSignal.timeout(TIMEOUT_MS) });
|
|
173
|
+
if (!response.ok) return placed;
|
|
174
|
+
body = await response.json();
|
|
175
|
+
} catch {
|
|
176
|
+
return placed;
|
|
177
|
+
}
|
|
178
|
+
const order = /* @__PURE__ */ new Map();
|
|
179
|
+
const taxonomy = record(body)?.taxonomy;
|
|
180
|
+
if (Array.isArray(taxonomy)) taxonomy.forEach((raw, at) => {
|
|
181
|
+
const name = text(record(raw)?.name);
|
|
182
|
+
if (name !== "") order.set(name, at);
|
|
183
|
+
});
|
|
184
|
+
const entries = record(record(body)?.entries);
|
|
185
|
+
for (const [id, raw] of Object.entries(entries ?? {})) {
|
|
186
|
+
const entry = record(raw);
|
|
187
|
+
const category = text(entry?.category);
|
|
188
|
+
if (entry === void 0 || category === "") continue;
|
|
189
|
+
const page = httpsUrl(entry.page);
|
|
190
|
+
const screenshot = httpsUrl(entry.screenshot);
|
|
191
|
+
placed.set(id, {
|
|
192
|
+
place: {
|
|
193
|
+
category,
|
|
194
|
+
subcategory: text(entry.subcategory),
|
|
195
|
+
order: order.get(category) ?? Number.MAX_SAFE_INTEGER
|
|
196
|
+
},
|
|
197
|
+
...page === void 0 ? {} : { page },
|
|
198
|
+
...screenshot === void 0 ? {} : { screenshot }
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
return placed;
|
|
202
|
+
}
|
|
145
203
|
/**
|
|
146
204
|
* 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
|
|
147
205
|
* 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.
|
|
148
206
|
*/
|
|
149
|
-
async function readBlends(fetchImpl = (input, init) => fetch(input, init), url = REGISTRY_INDEX, discovered = REGISTRY_DISCOVERED) {
|
|
207
|
+
async function readBlends(fetchImpl = (input, init) => fetch(input, init), url = REGISTRY_INDEX, discovered = REGISTRY_DISCOVERED, placement = REGISTRY_PLACEMENT) {
|
|
150
208
|
const blends = [];
|
|
151
209
|
const ids = /* @__PURE__ */ new Set();
|
|
152
210
|
for (const raw of await entriesOf(fetchImpl, url)) {
|
|
@@ -183,7 +241,15 @@ async function readBlends(fetchImpl = (input, init) => fetch(input, init), url =
|
|
|
183
241
|
...publisher === "" ? {} : { publisher }
|
|
184
242
|
});
|
|
185
243
|
}
|
|
186
|
-
|
|
244
|
+
const placed = placement === void 0 ? /* @__PURE__ */ new Map() : await placementsOf(fetchImpl, placement);
|
|
245
|
+
return blends.map((blend) => {
|
|
246
|
+
const where = placed.get(blend.id);
|
|
247
|
+
return where === void 0 ? blend : {
|
|
248
|
+
...blend,
|
|
249
|
+
...where,
|
|
250
|
+
category: [where.place.category, where.place.subcategory].filter(Boolean).join(" › ")
|
|
251
|
+
};
|
|
252
|
+
}).sort((a, b) => a.name.localeCompare(b.name));
|
|
187
253
|
}
|
|
188
254
|
//#endregion
|
|
189
255
|
//#region src/runner.ts
|
|
@@ -325,6 +391,112 @@ const spawnRunner = (command) => {
|
|
|
325
391
|
};
|
|
326
392
|
};
|
|
327
393
|
//#endregion
|
|
394
|
+
//#region src/self-update.ts
|
|
395
|
+
/** The command that updates an app from its Blend's newer release (as the service's `update`). */
|
|
396
|
+
const SELF_UPDATE_SPEC = "acrylblends@latest";
|
|
397
|
+
const paths = (home) => {
|
|
398
|
+
const folder = join(home, "logs");
|
|
399
|
+
return {
|
|
400
|
+
folder,
|
|
401
|
+
start: join(folder, "control-center-update.json"),
|
|
402
|
+
end: join(folder, "control-center-update.end"),
|
|
403
|
+
log: join(folder, "control-center-update.log")
|
|
404
|
+
};
|
|
405
|
+
};
|
|
406
|
+
/** The Blend and version a copy was made from: package.json's `acryl.from` (`acryl.control-center#0.2.14`), which create-acrylblends writes. */
|
|
407
|
+
function originOf(packageText) {
|
|
408
|
+
if (packageText === void 0) return void 0;
|
|
409
|
+
try {
|
|
410
|
+
const from = JSON.parse(packageText).acryl?.from;
|
|
411
|
+
const match = typeof from === "string" ? /^([a-z0-9][a-z0-9._-]*)#(\d+\.\d+\.\d+\S*)$/u.exec(from) : null;
|
|
412
|
+
return match === null ? void 0 : {
|
|
413
|
+
blend: match[1],
|
|
414
|
+
version: match[2]
|
|
415
|
+
};
|
|
416
|
+
} catch {
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
/** The last lines of a log, the way the screen shows a job's output. */
|
|
421
|
+
const lastLines = (text, count = 12) => (text ?? "").replaceAll(/\u001b\[[0-9;?]*[ -/]*[@-~]/gu, "").trimEnd().split(/\r?\n/u).slice(-count).join("\n");
|
|
422
|
+
/**
|
|
423
|
+
* Where the copy stands: up to date (`undefined` when there is nothing to say), a newer release out, an update running, done (until this app is opened
|
|
424
|
+
* again: `startedAt` is when this process began), or failed. `version` is what the copy has now (blend.yaml's `metadata.version`, which the merge moves).
|
|
425
|
+
*/
|
|
426
|
+
function selfView(copy, latest, files, home, startedAt, newer) {
|
|
427
|
+
const at = paths(home);
|
|
428
|
+
const started = files.read(at.start);
|
|
429
|
+
if (started !== void 0) {
|
|
430
|
+
let record = {};
|
|
431
|
+
try {
|
|
432
|
+
record = JSON.parse(started);
|
|
433
|
+
} catch {}
|
|
434
|
+
const to = typeof record.to === "string" ? record.to : "?";
|
|
435
|
+
const since = typeof record.since === "number" ? record.since : 0;
|
|
436
|
+
const ended = files.read(at.end);
|
|
437
|
+
if (ended === void 0) return {
|
|
438
|
+
name: copy.name,
|
|
439
|
+
version: copy.version,
|
|
440
|
+
update: to,
|
|
441
|
+
status: "updating",
|
|
442
|
+
since,
|
|
443
|
+
output: lastLines(files.read(at.log))
|
|
444
|
+
};
|
|
445
|
+
if (ended.trim() === "0" && (files.modified(at.end) ?? 0) < startedAt) for (const file of [at.start, at.end]) files.remove(file);
|
|
446
|
+
else if (ended.trim() === "0") return {
|
|
447
|
+
name: copy.name,
|
|
448
|
+
version: copy.version,
|
|
449
|
+
update: to,
|
|
450
|
+
status: "done",
|
|
451
|
+
since
|
|
452
|
+
};
|
|
453
|
+
else return {
|
|
454
|
+
name: copy.name,
|
|
455
|
+
version: copy.version,
|
|
456
|
+
update: to,
|
|
457
|
+
status: "failed",
|
|
458
|
+
since,
|
|
459
|
+
output: lastLines(files.read(at.log))
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
return latest !== void 0 && newer(latest, copy.version) ? {
|
|
463
|
+
name: copy.name,
|
|
464
|
+
version: copy.version,
|
|
465
|
+
update: latest,
|
|
466
|
+
status: "available"
|
|
467
|
+
} : void 0;
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* The command that updates the copy, detached (its output goes to a file, so it outlives the service and this app's reload): node runs
|
|
471
|
+
* `npm exec acrylblends@latest -- update` in the copy and writes its exit code to the end file. Records the start first.
|
|
472
|
+
*/
|
|
473
|
+
function selfUpdateCommand(copy, to, files, home, now) {
|
|
474
|
+
const at = paths(home);
|
|
475
|
+
files.makeFolder(at.folder);
|
|
476
|
+
files.remove(at.end);
|
|
477
|
+
files.write(at.start, `${JSON.stringify({
|
|
478
|
+
from: copy.version,
|
|
479
|
+
to,
|
|
480
|
+
since: now
|
|
481
|
+
})}\n`);
|
|
482
|
+
return {
|
|
483
|
+
program: "node",
|
|
484
|
+
args: [
|
|
485
|
+
"-e",
|
|
486
|
+
[
|
|
487
|
+
"const { spawnSync } = require('node:child_process')",
|
|
488
|
+
"const { writeFileSync } = require('node:fs')",
|
|
489
|
+
"const win = process.platform === 'win32'",
|
|
490
|
+
`const run = spawnSync(win ? 'npm.cmd' : 'npm', ['exec', '--yes', '${SELF_UPDATE_SPEC}', '--', 'update'], { stdio: 'inherit', shell: win })`,
|
|
491
|
+
"writeFileSync(process.argv[1], String(run.status ?? 1))"
|
|
492
|
+
].join("; "),
|
|
493
|
+
at.end
|
|
494
|
+
],
|
|
495
|
+
cwd: copy.folder,
|
|
496
|
+
log: at.log
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
//#endregion
|
|
328
500
|
//#region src/service.ts
|
|
329
501
|
/**
|
|
330
502
|
* 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).
|
|
@@ -397,11 +569,13 @@ var LauncherService = class {
|
|
|
397
569
|
output: at.output.trimEnd(),
|
|
398
570
|
...at.message === void 0 ? {} : { message: at.message }
|
|
399
571
|
};
|
|
572
|
+
const self = this.#self();
|
|
400
573
|
return {
|
|
401
574
|
apps,
|
|
402
575
|
appsFolder: this.#ports.appsFolder,
|
|
403
576
|
starters: STARTERS,
|
|
404
|
-
job
|
|
577
|
+
job,
|
|
578
|
+
...self === void 0 ? {} : { self }
|
|
405
579
|
};
|
|
406
580
|
}
|
|
407
581
|
#view(entry) {
|
|
@@ -586,6 +760,46 @@ var LauncherService = class {
|
|
|
586
760
|
}
|
|
587
761
|
});
|
|
588
762
|
}
|
|
763
|
+
/** This app's own copy: the Blend and version it was made from (package.json's `acryl.from`), the version it has now, and its name. */
|
|
764
|
+
#selfCopy() {
|
|
765
|
+
const self = this.#ports.self;
|
|
766
|
+
if (self === void 0) return void 0;
|
|
767
|
+
const origin = originOf(self.files.read(join(self.folder, "package.json")));
|
|
768
|
+
if (origin === void 0) return void 0;
|
|
769
|
+
return {
|
|
770
|
+
folder: self.folder,
|
|
771
|
+
name: self.name,
|
|
772
|
+
blend: origin.blend,
|
|
773
|
+
version: blendVersionOf(self.folder) || origin.version
|
|
774
|
+
};
|
|
775
|
+
}
|
|
776
|
+
#self() {
|
|
777
|
+
const self = this.#ports.self;
|
|
778
|
+
const copy = this.#selfCopy();
|
|
779
|
+
if (self === void 0 || copy === void 0) return void 0;
|
|
780
|
+
const latest = this.#blends?.list.find((listed) => listed.id === copy.blend)?.version;
|
|
781
|
+
return selfView(copy, latest, self.files, this.#ports.home, self.startedAt, newerVersion);
|
|
782
|
+
}
|
|
783
|
+
/**
|
|
784
|
+
* Update this app itself to its Blend's newer release: `acrylblends update` in its own folder, detached, so it finishes even when this plugin is reloaded
|
|
785
|
+
* by the change it brings. The new release runs once the app is opened again.
|
|
786
|
+
*/
|
|
787
|
+
updateSelf() {
|
|
788
|
+
this.#toolsReady();
|
|
789
|
+
const self = this.#ports.self;
|
|
790
|
+
const copy = this.#selfCopy();
|
|
791
|
+
const view = this.#self();
|
|
792
|
+
if (self === void 0 || copy === void 0) throw new LauncherRefusal("This app was not made from a Blend copy it can update: download the newest release instead.");
|
|
793
|
+
if (view === void 0 || view.status !== "available" && view.status !== "failed") throw new LauncherRefusal(view?.status === "updating" ? `${copy.name} is already being updated` : `${copy.name} is on the latest release`);
|
|
794
|
+
const command = selfUpdateCommand(copy, view.update, {
|
|
795
|
+
...self.files,
|
|
796
|
+
makeFolder: this.#ports.makeFolder
|
|
797
|
+
}, this.#ports.home, Date.now());
|
|
798
|
+
this.#ports.runner({
|
|
799
|
+
...command,
|
|
800
|
+
env: this.#environment()
|
|
801
|
+
});
|
|
802
|
+
}
|
|
589
803
|
/**
|
|
590
804
|
* When this app quits (or the plugin unloads): stop everything it started, except a Desktop app whose window is open. That window is the person's
|
|
591
805
|
* own, and closing it stops the app; a Web app has no window, so it would run on unseen. Returns the names of the apps left open.
|
|
@@ -1024,7 +1238,7 @@ function newerVersion(candidate, current) {
|
|
|
1024
1238
|
/**
|
|
1025
1239
|
* The Control Center's service wired to this machine: real processes, the running apps' doors, the public registry, and the tools fetch. One wiring for
|
|
1026
1240
|
* every face that runs the Control Center in a Node process: the Cordis Host plugin (index.ts) and the terminal Control Center (`acryl`, bundled from
|
|
1027
|
-
*
|
|
1241
|
+
* distribution/acryl-npm-launcher/tui), so the window, the browser and the terminal do the same thing with the same code.
|
|
1028
1242
|
*/
|
|
1029
1243
|
/** `home` is ACRYL's home (`~/.acryl`); new apps are suggested in the visible folder beside it (`~/ACRYL`): the home's parent, never a looked-up user folder. */
|
|
1030
1244
|
function createNodeLauncher(home, environment = () => process.env) {
|
|
@@ -1043,6 +1257,6 @@ function createNodeLauncher(home, environment = () => process.env) {
|
|
|
1043
1257
|
});
|
|
1044
1258
|
}
|
|
1045
1259
|
//#endregion
|
|
1046
|
-
export { LAUNCHER_UPDATE_PATH as A, LAUNCHER_PUBLISH_PLAN_PATH as C, LAUNCHER_START_PATH as D, LAUNCHER_SHARE_PLAN_PATH as E,
|
|
1260
|
+
export { LAUNCHER_UPDATE_PATH as A, LAUNCHER_PUBLISH_PLAN_PATH as C, LAUNCHER_START_PATH as D, LAUNCHER_SHARE_PLAN_PATH as E, SURFACES as F, WEBBOXES_NEW_BOX as I, webboxesDeployBlendUrl as L, LICENSE_ID as M, MAKEABLE_SURFACES as N, LAUNCHER_STATE_PATH as O, PLUGIN_NAME as P, webboxesDeployUrl as R, LAUNCHER_PUBLISH_PATH as S, LAUNCHER_SHARE_PATH as T, LAUNCHER_GITHUB_START_PATH as _, readBlends as a, LAUNCHER_PLUGINS_PATH as b, BLEND_SOURCE as c, LAUNCHER_API_PREFIX as d, LAUNCHER_ASSISTANT_FOLDER_PATH as f, LAUNCHER_GITHUB_POLL_PATH as g, LAUNCHER_GITHUB_PATH as h, RegistryUnavailable as i, LAUNCHER_UPDATE_SELF_PATH as j, LAUNCHER_STOP_PATH as k, LAUNCHER_ADD_PATH as l, LAUNCHER_GITHUB_DISCONNECT_PATH as m, LauncherRefusal as n, ACCOUNT_NAME as o, LAUNCHER_BLENDS_PATH as p, LauncherService as r, BLEND_ID as s, createNodeLauncher as t, LAUNCHER_ADE_PATH as u, LAUNCHER_HEALTH_PATH as v, LAUNCHER_REMOVE_PATH as w, LAUNCHER_PLUGIN_PULL_PATH as x, LAUNCHER_NEW_PATH as y };
|
|
1047
1261
|
|
|
1048
|
-
//# sourceMappingURL=node-
|
|
1262
|
+
//# sourceMappingURL=node-C_SuDIqi.js.map
|