@amalgm/apps 0.1.3-preview.37556579173 → 0.1.3-preview.39017162709

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/PURPOSE.md +24 -12
  2. package/README.md +39 -32
  3. package/dist/apps.d.ts +9 -7
  4. package/dist/apps.js +54 -45
  5. package/dist/apps.js.map +1 -1
  6. package/dist/command-surface.d.ts +3 -7
  7. package/dist/command-surface.js +9 -29
  8. package/dist/command-surface.js.map +1 -1
  9. package/dist/construct-surface.js +45 -17
  10. package/dist/construct-surface.js.map +1 -1
  11. package/dist/construct.d.ts +0 -5
  12. package/dist/construct.js +0 -22
  13. package/dist/construct.js.map +1 -1
  14. package/dist/folders.d.ts +40 -0
  15. package/dist/folders.js +94 -0
  16. package/dist/folders.js.map +1 -0
  17. package/dist/identity.d.ts +1 -2
  18. package/dist/identity.js +1 -13
  19. package/dist/identity.js.map +1 -1
  20. package/dist/index.d.ts +1 -6
  21. package/dist/index.js +1 -5
  22. package/dist/index.js.map +1 -1
  23. package/dist/layout.d.ts +20 -0
  24. package/dist/layout.js +27 -0
  25. package/dist/layout.js.map +1 -0
  26. package/dist/logs.js +2 -0
  27. package/dist/logs.js.map +1 -1
  28. package/dist/mcp-server.d.ts +1 -1
  29. package/dist/mcp-server.js +3 -33
  30. package/dist/mcp-server.js.map +1 -1
  31. package/dist/ownership.d.ts +1 -1
  32. package/dist/ownership.js +5 -4
  33. package/dist/ownership.js.map +1 -1
  34. package/dist/package.js +10 -2
  35. package/dist/package.js.map +1 -1
  36. package/dist/presentation.d.ts +1 -3
  37. package/dist/presentation.js +1 -12
  38. package/dist/presentation.js.map +1 -1
  39. package/dist/releases.d.ts +4 -6
  40. package/dist/releases.js +15 -24
  41. package/dist/releases.js.map +1 -1
  42. package/dist/runtime.js +4 -4
  43. package/dist/runtime.js.map +1 -1
  44. package/dist/schema.js +2 -13
  45. package/dist/schema.js.map +1 -1
  46. package/dist/store.d.ts +9 -3
  47. package/dist/store.js +20 -14
  48. package/dist/store.js.map +1 -1
  49. package/dist/supervisor.d.ts +2 -2
  50. package/dist/supervisor.js +11 -11
  51. package/dist/supervisor.js.map +1 -1
  52. package/dist/types.d.ts +14 -11
  53. package/docs/SHELL_INTEGRATION.md +23 -5
  54. package/docs/STATUS.md +31 -28
  55. package/docs/SUPERVISION.md +14 -15
  56. package/package.json +7 -18
  57. package/skills/apps/SKILL.md +56 -73
  58. package/dist/bin/apps.d.ts +0 -2
  59. package/dist/bin/apps.js +0 -6
  60. package/dist/bin/apps.js.map +0 -1
  61. package/dist/bin/mcp.d.ts +0 -2
  62. package/dist/bin/mcp.js +0 -15
  63. package/dist/bin/mcp.js.map +0 -1
  64. package/dist/cli.d.ts +0 -15
  65. package/dist/cli.js +0 -116
  66. package/dist/cli.js.map +0 -1
  67. package/dist/http.d.ts +0 -30
  68. package/dist/http.js +0 -77
  69. package/dist/http.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amalgm/apps",
3
- "version": "0.1.3-preview.37556579173",
3
+ "version": "0.1.3-preview.39017162709",
4
4
  "description": "Local-first, versioned application deployment for Amalgm.",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,
@@ -23,16 +23,8 @@
23
23
  "./lease": {
24
24
  "types": "./dist/lease.d.ts",
25
25
  "default": "./dist/lease.js"
26
- },
27
- "./http": {
28
- "types": "./dist/http.d.ts",
29
- "default": "./dist/http.js"
30
26
  }
31
27
  },
32
- "bin": {
33
- "amalgm-apps": "./dist/bin/apps.js",
34
- "amalgm-apps-mcp": "./dist/bin/mcp.js"
35
- },
36
28
  "files": [
37
29
  "docs",
38
30
  "dist",
@@ -41,7 +33,7 @@
41
33
  "README.md"
42
34
  ],
43
35
  "scripts": {
44
- "build": "tsc -p tsconfig.build.json && tsx scripts/mark-executables.ts",
36
+ "build": "tsc -p tsconfig.build.json",
45
37
  "check": "tsx scripts/check-tree.ts && tsc -p tsconfig.json && tsc -p tsconfig.test.json",
46
38
  "test": "tsx --test --test-concurrency=1 --test-timeout=30000 test/*.test.ts",
47
39
  "verify": "npm run check && npm run build && npm test",
@@ -57,7 +49,7 @@
57
49
  "node": ">=24"
58
50
  },
59
51
  "dependencies": {
60
- "@amalgm/core": "0.5.1-preview.35541371724",
52
+ "@amalgm/core": "0.5.1-preview.39017016854",
61
53
  "@types/better-sqlite3": "^7.6.13",
62
54
  "@types/node": "^20.19.43",
63
55
  "better-sqlite3": "^12.6.2",
@@ -73,10 +65,7 @@
73
65
  "jobs": [
74
66
  "verify"
75
67
  ],
76
- "verify": "verify",
77
- "cli": [
78
- "amalgm-apps"
79
- ]
68
+ "verify": "verify"
80
69
  },
81
70
  "allowScripts": {
82
71
  "better-sqlite3@12.11.1": true,
@@ -89,11 +78,11 @@
89
78
  "@amalgm/core"
90
79
  ]
91
80
  },
92
- "gitHead": "15455bf9daec2417d37d897550fcf60fd0556b34",
81
+ "gitHead": "251bf5626644764972b5f0380de6ddfc48ec7e0a",
93
82
  "amalgmSource": {
94
83
  "repository": "amalgm-inc/amalgm-apps",
95
84
  "branch": "preview",
96
- "commit": "15455bf9daec2417d37d897550fcf60fd0556b34",
97
- "occurrence": "37556579173"
85
+ "commit": "251bf5626644764972b5f0380de6ddfc48ec7e0a",
86
+ "occurrence": "39017162709"
98
87
  }
99
88
  }
@@ -1,11 +1,11 @@
1
1
  ---
2
2
  name: apps
3
- description: Turn any runnable project into a locally owned, versioned application that Amalgm keeps alive — declare an amalgm.app.json, register it, and get immutable releases, one-command deploys and rollbacks, crash restarts, health monitoring, and a stable public URL without a remote hosting platform. Use when building, deploying, or operating an Amalgm app, writing an app manifest, wiring the ready/heartbeat health lease, driving the apps CLI or MCP tools, or embedding the Apps SDK in your own service.
3
+ description: Turn any runnable project into a locally owned, versioned application that Amalgm keeps alive — declare an amalgm.app.json, register it, and get immutable releases, one-command deploys and rollbacks, crash restarts, health monitoring, and a stable public URL without a remote hosting platform. Use when building, deploying, or operating an Amalgm app, writing an app manifest, wiring the ready/heartbeat health lease, driving the `amalgm apps` command or the Apps MCP tools, or embedding the Apps SDK in your own service.
4
4
  ---
5
5
 
6
6
  # Amalgm Apps
7
7
 
8
- Apps turns any runnable project — any language, any framework — into a versioned application that Amalgm keeps alive on your machine. You describe the app once in an `amalgm.app.json` manifest and register it; from then on every deploy produces an immutable, content-addressed release, rollback is a one-command return to bytes that already exist, crashes are restarted automatically with backoff, and your app gets a stable identity: an id, an app ref, a port, and a public URL that all survive deploys, rollbacks, and renames. There is no remote build farm and no hosting account — state lives on disk under your Amalgm home directory, and the same SDK powers the CLI, the MCP tools, and the HTTP catalog.
8
+ Apps turns any runnable project — any language, any framework — into a versioned application that Amalgm keeps alive on your machine. You describe the app once in an `amalgm.app.json` manifest and register it; from then on every deploy produces an immutable, content-addressed release, rollback is a one-command return to bytes that already exist, crashes are restarted automatically with backoff, and your app gets a stable identity: an id, an app ref, a port, and a public URL that all survive deploys, rollbacks, and renames. There is no remote build farm and no hosting account — each app is one folder in your apps root, and the same SDK powers the `amalgm apps` command and the MCP tools.
9
9
 
10
10
  ## Installation
11
11
 
@@ -15,14 +15,13 @@ Everything ships in one npm package:
15
15
  npm install @amalgm/apps
16
16
  ```
17
17
 
18
- The package exposes four entry points, so you only import what your integration needs:
18
+ The package exposes three entry points, so you only import what your integration needs:
19
19
 
20
- - `@amalgm/apps` — the full SDK: the `Apps` service class, the command surface (`createAppCommands`, `appCommandDefinitions`), `runCli`, `unpackPackage`, and MCP factories (`createMcpTools`, `createMcpServer`).
20
+ - `@amalgm/apps` — the full SDK: the `Apps` service class, the command surface (`createAppCommands`, `appCommandDefinitions`), the rails seam (`appConstructSurface`), and MCP factories (`createMcpTools`, `createMcpServer`).
21
21
  - `@amalgm/apps/lease` — the tiny client your *hosted app* imports to announce health: `connect`, `ready`, `heartbeat`, `grants`, `isManaged`. Zero configuration; inert outside Amalgm.
22
- - `@amalgm/apps/http` — `createAppsHttpServer`, a read-only HTTP catalog of your apps for dashboards and embedders.
23
22
  - `@amalgm/apps/mcp` — the MCP tool definitions alone, for hosts that assemble their own MCP server.
24
23
 
25
- Installing the package also gives you two binaries: `amalgm-apps` (the CLI) and `amalgm-apps-mcp` (a stdio MCP server), both runnable with `npx`.
24
+ The package has no command of its own. Inside Amalgm, the runtime owns the one `Apps` instance and serves its MCP tools at `/mcp/apps`; the `amalgm apps` command and agents both call those tools.
26
25
 
27
26
  Node.js 24 or newer is required.
28
27
 
@@ -54,23 +53,23 @@ Add an `amalgm.app.json` next to it:
54
53
  Register it:
55
54
 
56
55
  ```bash
57
- npx --yes --package @amalgm/apps amalgm-apps create ./hello
56
+ amalgm apps create --input '{"cwd": "/Users/me/hello"}'
58
57
  ```
59
58
 
60
- That single command validates the manifest, packages the included files into a release, deploys it, starts the process on an assigned port, and prints the app as JSON — including its `id`, `appRef`, `port`, and `publicUrl`. Ship a new version any time with `npx --yes --package @amalgm/apps amalgm-apps deploy <app-id>`, and step back with `npx --yes --package @amalgm/apps amalgm-apps rollback <app-id>`.
59
+ `cwd` is an absolute path: the runtime reads it, not your shell. That single command validates the manifest, packages the included files into a release, deploys it, starts the process on an assigned port, and prints the app as JSON — including its `id`, `appRef`, `port`, `publicUrl`, and `folder`. An agent calls the `amalgm_apps_create` tool with the same `{ "cwd": "/Users/me/hello" }`. Ship a new version any time with `amalgm apps deploy --input '{"app_id": "<app-id>"}'`, and step back with `amalgm apps rollback --input '{"app_id": "<app-id>"}'`.
61
60
 
62
- The same flow from TypeScript:
61
+ The same flow from TypeScript, with the three folders the runtime would hand Apps:
63
62
 
64
63
  ```ts
65
64
  import { Apps } from '@amalgm/apps';
66
65
 
67
- const apps = new Apps();
66
+ const apps = new Apps({ root: '/srv/me/apps', dir: '/srv/me/computer/apps', parked: '/srv/me/computer/parked' });
68
67
  const app = await apps.register({ cwd: './hello' });
69
- console.log(app.publicUrl, app.port);
68
+ console.log(app.publicUrl, app.port, app.folder);
70
69
  await apps.close();
71
70
  ```
72
71
 
73
- Continuous crash recovery and health monitoring require a long-lived Apps owner: Shell, the Apps MCP server, or an embedding service that calls `apps.boot()`. The CLI performs one operation and then releases its Apps owner. Use one owner for each state directory.
72
+ Continuous crash recovery and health monitoring require a long-lived Apps owner: the Amalgm runtime, or an embedding service that calls `apps.boot()`. Use one owner for each catalog folder.
74
73
 
75
74
  ## The app manifest
76
75
 
@@ -96,12 +95,12 @@ Rules worth knowing before your first deploy:
96
95
  - Unknown fields are rejected, not ignored — a typo like `"startCmd"` fails validation with a message naming the field.
97
96
  - `package.include` and `package.exclude` are glob patterns; `include` must match at least one file. Only included files become part of a release, so build outputs your `startCommand` needs must be covered.
98
97
  - `buildCommand: null` means "no build step". When set, it runs once per new release, before the release is activated.
99
- - `startCommand` runs with the deployment directory as its working directory. Write `{port}` anywhere in it to interpolate the assigned port, or just read the `PORT` environment variable.
98
+ - `startCommand` runs with the deployment directory (a copy of the release in the app's `.private/current/`) as its working directory. Write `{port}` anywhere in it to interpolate the assigned port, or just read the `PORT` environment variable.
100
99
 
101
100
  Check a project without deploying it:
102
101
 
103
102
  ```bash
104
- npx --yes --package @amalgm/apps amalgm-apps validate ./hello
103
+ amalgm apps validate --input '{"cwd": "/Users/me/hello"}'
105
104
  ```
106
105
 
107
106
  This prints the parsed manifest, the release digest, the exact files that would be packaged, and anything excluded — the fastest way to debug an `include` pattern.
@@ -118,12 +117,12 @@ Three nouns cover everything you will observe:
118
117
  const app = await apps.register({ cwd: './hello' }); // returns an AppView
119
118
  await apps.deploy(app.id); // package sourceDir again -> new release if bytes changed
120
119
  await apps.rollback(app.id); // previous release; or apps.rollback(id, { releaseId })
121
- await apps.update(app.id, { name: 'Hello v2' });
120
+ await apps.update(app.id, { name: 'Hello v2' }); // renames the app's folder too
122
121
  apps.versions(app.id); // Release[]
123
122
  apps.deployments(app.id); // Deployment[]
124
123
  await apps.start(app.id); // start the current deployment, no rebuild
125
124
  await apps.stop(app.id);
126
- await apps.delete(app.id); // stops the process, removes all state and files
125
+ await apps.delete(app.id); // stops it, parks .private/, removes the app's folder
127
126
  ```
128
127
 
129
128
  ### Safe deploys
@@ -161,7 +160,7 @@ Every hosted process receives:
161
160
  | `AMALGM_APP_ID` | The app's stable id |
162
161
  | `AMALGM_APP_REF` | The app's stable ref (the subdomain) |
163
162
  | `AMALGM_APP_URL` | The app's public URL |
164
- | `AMALGM_APP_DATA_DIR` | The only directory where persistent data belongs |
163
+ | `AMALGM_APP_DATA_DIR` | The only directory where persistent data belongs: the app's `.private/data` |
165
164
 
166
165
  Write durable data **only** to `AMALGM_APP_DATA_DIR`. It survives deploys and rollbacks; anything written inside a deployment directory does not, and never becomes part of a later release.
167
166
 
@@ -197,69 +196,51 @@ if (isManaged()) {
197
196
  }
198
197
  ```
199
198
 
200
- ## CLI
201
-
202
- `amalgm-apps` takes a command plus arguments, prints the result as JSON, and exits non-zero on failure. The CLI, the MCP tools, and the SDK expose one command surface, so every verb below is also an MCP tool with the same input fields:
203
-
204
- ```bash
205
- amalgm-apps create <dir> # validate, release, deploy, and start in one step
206
- amalgm-apps validate <dir> # dry-run: manifest, digest, packaged files
207
- amalgm-apps list # all apps with status and health
208
- amalgm-apps get <app-id> # one app in full detail
209
- amalgm-apps update <app-id> --name "New name" [--[no-]autostart] [--[no-]keep-alive] [--[no-]dns-connected]
210
- amalgm-apps deploy <app-id> [dir] # new release from the source dir (or a new dir)
211
- amalgm-apps rollback <app-id> [release-id]
212
- amalgm-apps versions <app-id> # release history
213
- amalgm-apps deployments <app-id> # deployment history with statuses
214
- amalgm-apps logs <app-id> [lines] # trailing process log lines
215
- amalgm-apps start <app-id>
216
- amalgm-apps stop <app-id>
217
- amalgm-apps export <app-id> # portable package: manifest, packed files, tool ids
218
- amalgm-apps install --file portable.json # {"app": <export result>, "autostart"?: bool}
219
- amalgm-apps routes # published routes of running healthy apps
220
- amalgm-apps delete <app-id> # stop and remove everything
199
+ ## The `amalgm apps` command and MCP tools
200
+
201
+ The command and the MCP tools are one command surface over the SDK. Each command is an MCP tool named `amalgm_apps_<command>` that takes the same JSON object; `amalgm apps <command>` takes it as `--input '<json>'` (or `--file <path>`, or `--stdin`), prints the result as JSON, and exits non-zero on failure:
202
+
203
+ ```text
204
+ create { cwd, port?, connect_dns?, autostart?, keep_alive? } validate, release, deploy, and start
205
+ validate { cwd } dry-run: manifest, digest, packaged files
206
+ list {} all apps with status and health
207
+ get { app_id } one app in full detail
208
+ update { app_id, name?, description?, autostart?, keep_alive?, dns_connected? }
209
+ deploy { app_id, cwd? } new release from the source (a new cwd becomes the source)
210
+ rollback { app_id, release_id? } an earlier release, as a new deployment
211
+ versions { app_id } release history
212
+ deployments { app_id } deployment history with statuses
213
+ logs { app_id, lines? } trailing process log lines
214
+ start { app_id }
215
+ stop { app_id }
216
+ routes {} published routes of running healthy apps
217
+ delete { app_id } stop the app and remove its folder
221
218
  ```
222
219
 
223
- Bare arguments fill each command's positional fields in order; every field can also be passed as `--field value` (or `--field` / `--no-field` for booleans), and `--input '<json>'` or `--file <path>` supplies the whole input as one object, exactly as an MCP call would. `create` accepts `--port <n>` to pin a specific port, `--no-autostart` to register without launching on boot, `--no-keep-alive` to disable crash restarts, and `--no-connect-dns` to keep the app off the public route table. Every command also accepts a global `--state-dir <dir>` to operate on a non-default state directory. Run `amalgm-apps help` for the generated reference.
224
-
225
- ## MCP tools
220
+ `create` takes `port` to pin a specific port, `autostart: false` to register without launching when the runtime starts, `keep_alive: false` to disable crash restarts, and `connect_dns: false` to keep the app off the public route table. Each tool carries the command's input schema and MCP annotations (read-only, destructive, idempotent). `appCommandDefinitions` from `@amalgm/apps` is that list, for hosts that build their own adapter; `createMcpServer({ apps })` serves it over the one `Apps` instance a host owns. This is how an agent connected to Amalgm ships and operates apps on your behalf.
226
221
 
227
- Run `npx --yes --package @amalgm/apps amalgm-apps-mcp` for a stdio MCP server, or embed the tools in your own host:
222
+ ## Where files live
228
223
 
229
- ```ts
230
- import { Apps, createMcpTools, createMcpServer } from '@amalgm/apps';
224
+ Apps reads and writes only the three folders its host hands it, and keeps every file it makes for an app inside that app's `.private/`:
231
225
 
232
- const tools = createMcpTools(new Apps()); // name, description, inputSchema, handler
233
- const server = createMcpServer(); // or a full JSON-RPC server: server.start()
234
226
  ```
235
-
236
- The tools are the CLI commands one-for-one, named `amalgm_apps_<command>`: `amalgm_apps_create`, `amalgm_apps_list`, `amalgm_apps_get`, `amalgm_apps_update`, `amalgm_apps_delete`, `amalgm_apps_start`, `amalgm_apps_stop`, `amalgm_apps_deploy`, `amalgm_apps_rollback`, `amalgm_apps_versions`, `amalgm_apps_deployments`, `amalgm_apps_logs`, `amalgm_apps_validate`, `amalgm_apps_routes`, `amalgm_apps_export`, and `amalgm_apps_install`. Each carries the command's input schema and MCP annotations (read-only, destructive, idempotent). `appCommandDefinitions` from `@amalgm/apps` is that list, for hosts that build their own adapter. This is how an agent connected to Amalgm ships and operates apps on your behalf.
237
-
238
- For read-only visibility — a dashboard, a status page — mount the HTTP catalog:
239
-
240
- ```ts
241
- import { Apps, createAppsHttpServer } from '@amalgm/apps';
242
-
243
- const server = createAppsHttpServer(new Apps());
227
+ <root>/<Folder>/ one folder per app, named after it ("Hello", "Hello-2")
228
+ .amalgm-app.json the app's permanent id and name; "source" names your
229
+ own project when the app was made from one
230
+ amalgm.app.json, ... the source itself, when Amalgm owns it
231
+ .private/ never synced, never leaves this computer
232
+ build/ releases being built
233
+ releases/<release-id>/ immutable release contents
234
+ current/<deployment-id>/ the copy your process actually runs from
235
+ data/ your app's AMALGM_APP_DATA_DIR — survives every deploy
236
+ logs/app.log captured stdout/stderr, capped into app.log.1
237
+ <dir>/apps.db this computer's catalog: apps, releases, deployments, history
238
+ <parked>/app/<app-id>/ a deleted app's .private/, kept and never deleted
244
239
  ```
245
240
 
246
- It serves `GET /apps` (and `/apps/list`) plus `/apps/routes`. It is strictly a catalog: all lifecycle changes go through the SDK, CLI, or MCP tools.
247
-
248
- ## Where state lives
249
-
250
- Apps keeps everything under one state directory. The standalone main binding defaults to `~/.amalgm/users/<scope>/apps`; preview and local bindings use separate namespaces under `~/.amalgm/environments/`. A composed host supplies its installation root through `AMALGM_ROOT`. Point it elsewhere with the `AMALGM_APPS_DIR` environment variable (used verbatim), `AMALGM_DIR` (state goes in an `apps/` folder under it), or the `stateDir` option / `--state-dir` flag.
251
-
252
- Inside you will find, per app:
253
-
254
- ```
255
- apps.db # the SQLite catalog: apps, releases, deployments, history
256
- releases/<app-id>/ # immutable release contents, one directory per release
257
- deployments/<app-id>/# the working copies your process actually runs from
258
- data/<app-id>/ # your app's AMALGM_APP_DATA_DIR — survives every deploy
259
- logs/<app-id>.log # captured stdout/stderr, rotated once at <app-id>.log.1
260
- ```
241
+ An app made from your own project leaves the project where it is: nothing Amalgm makes lands in it, and deleting the app never touches it. An app whose folder already sits in the apps root, or that arrived from another computer, keeps its source in the folder. Renaming an app renames the folder (made safe for every platform), and a running app restarts from its new place. Deleting an app parks its `.private/` and removes the folder; a delete made on another computer only forgets the app here and parks `.private/`.
261
242
 
262
- Treat these directories as read-only observability: inspect the logs, browse a release, back up `data/` — but let the CLI, SDK, and MCP tools make the changes. `delete` removes an app's releases, deployments, data, and logs in one step.
243
+ Treat these folders as read-only observability: inspect the logs, browse a release, back up `data/` — but let the `amalgm apps` command, the MCP tools, or the SDK make the changes.
263
244
 
264
245
  ## Embedding the SDK
265
246
 
@@ -269,7 +250,9 @@ If you are building a long-lived service that hosts apps itself, construct one `
269
250
  import { Apps } from '@amalgm/apps';
270
251
 
271
252
  const apps = new Apps({
272
- stateDir: '/var/lib/amalgm/apps',
253
+ root: '/srv/me/apps', // one folder per app
254
+ dir: '/srv/me/computer/apps', // apps.db
255
+ parked: '/srv/me/computer/parked', // deleted apps' .private/
273
256
  publishRoutes: (routes, reason) => gateway.update(routes), // eligible routes changed
274
257
  onChange: (app) => events.emit('app', app), // app updated, or { id, deleted: true }
275
258
  onError: (error) => log.warn(error),
@@ -282,4 +265,4 @@ await apps.close({ stopProcesses: true }); // stop hosted apps on the way down
282
265
 
283
266
  `boot()` adopts apps that should be running and resumes health monitoring; `close()` without `stopProcesses: true` detaches and leaves processes running for the next owner. Your callbacks are fault boundaries — an exception inside them is reported through `onError` and contained, never allowed to take the daemon down. `apps.routes()` returns the currently eligible `{ app_ref, port, name }` routes; routes fail closed, so an app that is stopped, degraded, or disconnected from DNS simply disappears from the table.
284
267
 
285
- Only one live Apps service may manage a given state directory at a time; a second instance pointed at the same directory will refuse to take ownership rather than corrupt it.
268
+ Only one live Apps service may manage a given catalog folder at a time; a second instance pointed at the same `dir` will refuse to take ownership rather than corrupt it.
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
package/dist/bin/apps.js DELETED
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env node
2
- import { runCli } from '../cli.js';
3
- runCli(process.argv.slice(2)).then((code) => {
4
- process.exitCode = code;
5
- });
6
- //# sourceMappingURL=apps.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"apps.js","sourceRoot":"","sources":["../../src/bin/apps.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;IAC1C,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;AAC1B,CAAC,CAAC,CAAC"}
package/dist/bin/mcp.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
package/dist/bin/mcp.js DELETED
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env node
2
- import { errorMessage } from '../boundaries.js';
3
- import { createMcpServer } from '../mcp-server.js';
4
- const server = createMcpServer();
5
- server.start().catch((error) => {
6
- console.error(errorMessage(error));
7
- process.exitCode = 1;
8
- });
9
- async function shutdown() {
10
- await server.apps.close();
11
- process.exit();
12
- }
13
- process.once('SIGINT', shutdown);
14
- process.once('SIGTERM', shutdown);
15
- //# sourceMappingURL=mcp.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../src/bin/mcp.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,MAAM,GAAG,eAAe,EAAE,CAAC;AACjC,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IAC7B,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;IACnC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC;AAEH,KAAK,UAAU,QAAQ;IACrB,MAAM,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;IAC1B,OAAO,CAAC,IAAI,EAAE,CAAC;AACjB,CAAC;AAED,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACjC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC"}
package/dist/cli.d.ts DELETED
@@ -1,15 +0,0 @@
1
- /**
2
- * CLI adapter over the Apps command surface. It only turns argv into the
3
- * command's input object; the command list, validation, and SDK calls are
4
- * shared with MCP.
5
- */
6
- import type { Writable } from 'node:stream';
7
- import type { AppCommands } from './command-surface.js';
8
- interface CliIo {
9
- stdout?: Writable;
10
- stderr?: Writable;
11
- /** The bound command surface to run against; the default opens local Apps state. */
12
- commands?: AppCommands;
13
- }
14
- declare function runCli(argv: string[], io?: CliIo): Promise<number>;
15
- export { runCli };
package/dist/cli.js DELETED
@@ -1,116 +0,0 @@
1
- /**
2
- * CLI adapter over the Apps command surface. It only turns argv into the
3
- * command's input object; the command list, validation, and SDK calls are
4
- * shared with MCP.
5
- */
6
- import fs from 'node:fs';
7
- import { Apps } from './apps.js';
8
- import { appCommandDefinition, appCommandDefinitions, createAppCommands } from './command-surface.js';
9
- const HELP = `Usage: amalgm-apps [--state-dir DIR] <command> [arguments] [--field value | --no-field]
10
- amalgm-apps <command> --input JSON | --file PATH
11
-
12
- Commands (identical to the Apps MCP tools):
13
- ${appCommandDefinitions.map(usage).join('\n')}
14
-
15
- Bare arguments fill the fields listed in order. Any field can be given as
16
- --field value (--app-id, --release-id, ...) or, for booleans, --field and
17
- --no-field. --input takes the whole input as one JSON object; --file reads it
18
- from a JSON file. Output is the command result as JSON; failures print the
19
- error message and exit 1.`;
20
- function usage(definition) {
21
- const positional = definition.positional.map((field) => (definition.inputShape[field].required ? `<${flag(field)}>` : `[${flag(field)}]`));
22
- const flags = Object.entries(definition.inputShape)
23
- .filter(([field]) => !definition.positional.includes(field))
24
- .map(([field, shape]) => (shape.type === 'boolean' ? `[--[no-]${flag(field)}]` : `[--${flag(field)} ${shape.type}]`));
25
- return ` ${[definition.name, ...positional, ...flags].join(' ')}\n ${definition.description}`;
26
- }
27
- function flag(field) {
28
- return field.replace(/_/g, '-');
29
- }
30
- function field(flagName) {
31
- return flagName.replace(/-/g, '_');
32
- }
33
- function coerce(definition, name, raw) {
34
- const shape = definition.inputShape[name];
35
- if (!shape)
36
- throw new Error(`Unknown option for ${definition.name}: --${flag(name)}`);
37
- if (shape.type === 'integer') {
38
- const value = Number(raw);
39
- if (!Number.isInteger(value))
40
- throw new Error(`--${flag(name)} must be an integer`);
41
- return value;
42
- }
43
- return raw;
44
- }
45
- function parse(argv) {
46
- const args = [...argv];
47
- let stateDir;
48
- const stateIndex = args.indexOf('--state-dir');
49
- if (stateIndex >= 0)
50
- [, stateDir] = args.splice(stateIndex, 2);
51
- const command = args.shift();
52
- if (!command || ['help', '--help', '-h'].includes(command))
53
- return { command: undefined, stateDir, input: {} };
54
- const definition = appCommandDefinition(command);
55
- const input = {};
56
- const bare = [];
57
- for (let index = 0; index < args.length; index += 1) {
58
- const value = args[index];
59
- if (!value.startsWith('--')) {
60
- bare.push(value);
61
- }
62
- else if (value === '--input') {
63
- Object.assign(input, JSON.parse(args[++index] ?? ''));
64
- }
65
- else if (value === '--file') {
66
- Object.assign(input, JSON.parse(fs.readFileSync(args[++index] ?? '', 'utf8')));
67
- }
68
- else if (value.startsWith('--no-') && definition.inputShape[field(value.slice(5))]?.type === 'boolean') {
69
- input[field(value.slice(5))] = false;
70
- }
71
- else if (definition.inputShape[field(value.slice(2))]?.type === 'boolean') {
72
- input[field(value.slice(2))] = true;
73
- }
74
- else {
75
- const name = field(value.slice(2));
76
- const raw = args[++index];
77
- if (raw === undefined)
78
- throw new Error(`--${flag(name)} needs a value`);
79
- input[name] = coerce(definition, name, raw);
80
- }
81
- }
82
- if (bare.length > definition.positional.length) {
83
- throw new Error(`Unexpected argument for ${command}: ${bare[definition.positional.length]}`);
84
- }
85
- bare.forEach((value, index) => {
86
- const name = definition.positional[index];
87
- input[name] = coerce(definition, name, value);
88
- });
89
- return { command, stateDir, input };
90
- }
91
- async function runCli(argv, io = {}) {
92
- const stdout = io.stdout || process.stdout;
93
- const stderr = io.stderr || process.stderr;
94
- let apps;
95
- try {
96
- const parsed = parse(argv);
97
- if (!parsed.command) {
98
- stdout.write(`${HELP}\n`);
99
- return 0;
100
- }
101
- const commands = io.commands || createAppCommands(apps = new Apps({ stateDir: parsed.stateDir }));
102
- const result = await commands.execute(parsed.command, parsed.input);
103
- stdout.write(`${JSON.stringify(result, null, 2)}\n`);
104
- return 0;
105
- }
106
- catch (error) {
107
- stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
108
- return 1;
109
- }
110
- finally {
111
- if (apps)
112
- await apps.close();
113
- }
114
- }
115
- export { runCli };
116
- //# sourceMappingURL=cli.js.map
package/dist/cli.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,OAAO,EAAE,IAAI,EAAE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AAM,CAAC;IAC3C,IAAI,IAAsB,CAAC;IAC3B,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;QAC3B,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC;YAC1B,OAAO,CAAC,CAAC;QACX,CAAC;QACD,MAAM,QAAQ,GAAG,EAAE,CAAC,QAAQ,IAAI,iBAAiB,CAAC,IAAI,GAAG,IAAI,IAAI,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;QAClG,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,OAAuC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;QACpG,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;QACrD,OAAO,CAAC,CAAC;IACX,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC5E,OAAO,CAAC,CAAC;IACX,CAAC;YAAS,CAAC;QACT,IAAI,IAAI;YAAE,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;IAC/B,CAAC;AACH,CAAC;AAED,OAAO,EAAE,MAAM,EAAE,CAAC"}
package/dist/http.d.ts DELETED
@@ -1,30 +0,0 @@
1
- /**
2
- * Apps catalog HTTP adapter. It serves `/apps` and the legacy `/artifacts`
3
- * projection that the UI still reads.
4
- *
5
- * Lifecycle mutations are deliberately absent here: the owning Apps service
6
- * already exposes them through SDK, CLI, and MCP, and the shell campaign must
7
- * not choose how the production runtime starts or supervises apps.
8
- */
9
- import type { AddressInfo } from 'node:net';
10
- import type { Apps } from './apps.js';
11
- import type { AppView } from './types.js';
12
- type CatalogApp = AppView & {
13
- kind: 'app';
14
- cwd: string;
15
- app_ref: string;
16
- appUrl: string;
17
- };
18
- type LegacyArtifact = Omit<CatalogApp, 'kind'> & {
19
- kind: 'artifact';
20
- artifactRef: string;
21
- artifact_ref: string;
22
- artifactUrl: string;
23
- };
24
- interface AppsHttpServer {
25
- listen(port?: number, host?: string): Promise<AddressInfo>;
26
- close(): Promise<void>;
27
- }
28
- declare function createAppsHttpServer(apps: Apps): AppsHttpServer;
29
- export { createAppsHttpServer };
30
- export type { AppsHttpServer, CatalogApp, LegacyArtifact };
package/dist/http.js DELETED
@@ -1,77 +0,0 @@
1
- /**
2
- * Apps catalog HTTP adapter. It serves `/apps` and the legacy `/artifacts`
3
- * projection that the UI still reads.
4
- *
5
- * Lifecycle mutations are deliberately absent here: the owning Apps service
6
- * already exposes them through SDK, CLI, and MCP, and the shell campaign must
7
- * not choose how the production runtime starts or supervises apps.
8
- */
9
- import http from 'node:http';
10
- function catalogApp(app) {
11
- return {
12
- ...app,
13
- kind: 'app',
14
- cwd: app.sourceDir,
15
- app_ref: app.appRef,
16
- appUrl: app.publicUrl,
17
- };
18
- }
19
- function legacyArtifact(app) {
20
- const catalog = catalogApp(app);
21
- return {
22
- ...catalog,
23
- kind: 'artifact',
24
- artifactRef: catalog.appRef,
25
- artifact_ref: catalog.appRef,
26
- artifactUrl: catalog.appUrl || catalog.publicUrl,
27
- };
28
- }
29
- function legacyRoutes(routes) {
30
- return routes.map((route) => ({
31
- artifact_ref: route.app_ref,
32
- port: route.port,
33
- name: route.name,
34
- }));
35
- }
36
- function createAppsHttpServer(apps) {
37
- const server = http.createServer((request, response) => {
38
- const url = new URL(request.url || '/', 'http://127.0.0.1');
39
- if (request.method !== 'GET')
40
- return json(response, 405, { error: 'Method not allowed' });
41
- if (url.pathname === '/apps' || url.pathname === '/apps/list') {
42
- return json(response, 200, { version: 1, apps: apps.list().map(catalogApp) });
43
- }
44
- if (url.pathname === '/apps/routes') {
45
- return json(response, 200, { routes: apps.routes() });
46
- }
47
- if (url.pathname === '/artifacts' || url.pathname === '/artifacts/list') {
48
- return json(response, 200, { version: 1, artifacts: apps.list().map(legacyArtifact) });
49
- }
50
- if (url.pathname === '/artifacts/routes') {
51
- return json(response, 200, { routes: legacyRoutes(apps.routes()) });
52
- }
53
- return json(response, 404, { error: 'Not found' });
54
- });
55
- return {
56
- listen(port = 0, host = '127.0.0.1') {
57
- return new Promise((resolve, reject) => {
58
- server.once('error', reject);
59
- server.listen(port, host, () => {
60
- server.off('error', reject);
61
- resolve(server.address());
62
- });
63
- });
64
- },
65
- close() {
66
- return new Promise((resolve, reject) => {
67
- server.close((error) => error ? reject(error) : resolve());
68
- });
69
- },
70
- };
71
- }
72
- function json(response, status, body) {
73
- response.writeHead(status, { 'content-type': 'application/json' });
74
- response.end(JSON.stringify(body));
75
- }
76
- export { createAppsHttpServer };
77
- //# sourceMappingURL=http.js.map
package/dist/http.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAwB7B,SAAS,UAAU,CAAC,GAAY;IAC9B,OAAO;QACL,GAAG,GAAG;QACN,IAAI,EAAE,KAAK;QACX,GAAG,EAAE,GAAG,CAAC,SAAS;QAClB,OAAO,EAAE,GAAG,CAAC,MAAM;QACnB,MAAM,EAAE,GAAG,CAAC,SAAS;KACtB,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,GAAY;IAClC,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;IAChC,OAAO;QACL,GAAG,OAAO;QACV,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE,OAAO,CAAC,MAAM;QAC3B,YAAY,EAAE,OAAO,CAAC,MAAM;QAC5B,W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