@amalgm/apps 0.1.0 → 0.1.1
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/PURPOSE.md +4 -0
- package/README.md +15 -0
- package/dist/http.d.ts +31 -0
- package/dist/http.js +78 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +5 -1
package/PURPOSE.md
CHANGED
|
@@ -16,6 +16,10 @@ product beside independently supervised Events, Realtime, and other products;
|
|
|
16
16
|
it supplies identity, transport, and UI composition but does not absorb their
|
|
17
17
|
domain supervisors or maintain a second app lifecycle implementation.
|
|
18
18
|
|
|
19
|
+
Runtime hosts may mount the Apps HTTP catalog, including its legacy Artifacts
|
|
20
|
+
projection, without becoming lifecycle authorities. Catalog reads come from
|
|
21
|
+
the same Apps store as the SDK, CLI, and MCP surfaces.
|
|
22
|
+
|
|
19
23
|
## Primitives
|
|
20
24
|
|
|
21
25
|
- An **app** is a stable local identity with a user-controlled name, route,
|
package/README.md
CHANGED
|
@@ -42,6 +42,21 @@ await apps.deploy(app.id);
|
|
|
42
42
|
await apps.rollback(app.id);
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
+
The same persisted catalog has an HTTP adapter for runtime hosts:
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { Apps } from '@amalgm/apps';
|
|
49
|
+
import { createAppsHttpServer } from '@amalgm/apps/http';
|
|
50
|
+
|
|
51
|
+
const apps = new Apps({ stateDir: '/var/lib/amalgm/apps' });
|
|
52
|
+
const http = createAppsHttpServer(apps);
|
|
53
|
+
await http.listen();
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
It serves modern `/apps` and engine-compatible `/apps/list` catalogs plus
|
|
57
|
+
their `/artifacts` legacy projection. Lifecycle choices remain on the SDK,
|
|
58
|
+
CLI, and MCP surfaces; this HTTP increment is read-only.
|
|
59
|
+
|
|
45
60
|
The SDK, supervisor, CLI, MCP server, lease, and tests are authored in
|
|
46
61
|
TypeScript. `npm run build` emits the CommonJS runtime and declarations into
|
|
47
62
|
`dist/`; generated output is not a second source tree.
|
package/dist/http.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apps catalog HTTP adapter. Route and projection laws come from engine
|
|
3
|
+
* `runtime/scripts/amalgm-mcp/server/routes/apps.js` and
|
|
4
|
+
* `runtime/scripts/amalgm-mcp/apps/rest.js`.
|
|
5
|
+
*
|
|
6
|
+
* Lifecycle mutations are deliberately absent here: the owning Apps service
|
|
7
|
+
* already exposes them through SDK, CLI, and MCP, and the shell campaign must
|
|
8
|
+
* not choose how the production runtime starts or supervises apps.
|
|
9
|
+
*/
|
|
10
|
+
import type { AddressInfo } from 'node:net';
|
|
11
|
+
import type { Apps } from './apps.js';
|
|
12
|
+
import type { AppView } from './types.js';
|
|
13
|
+
type CatalogApp = AppView & {
|
|
14
|
+
kind: 'app';
|
|
15
|
+
cwd: string;
|
|
16
|
+
app_ref: string;
|
|
17
|
+
appUrl: string;
|
|
18
|
+
};
|
|
19
|
+
type LegacyArtifact = Omit<CatalogApp, 'kind'> & {
|
|
20
|
+
kind: 'artifact';
|
|
21
|
+
artifactRef: string;
|
|
22
|
+
artifact_ref: string;
|
|
23
|
+
artifactUrl: string;
|
|
24
|
+
};
|
|
25
|
+
interface AppsHttpServer {
|
|
26
|
+
listen(port?: number, host?: string): Promise<AddressInfo>;
|
|
27
|
+
close(): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
declare function createAppsHttpServer(apps: Apps): AppsHttpServer;
|
|
30
|
+
export { createAppsHttpServer };
|
|
31
|
+
export type { AppsHttpServer, CatalogApp, LegacyArtifact };
|
package/dist/http.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apps catalog HTTP adapter. Route and projection laws come from engine
|
|
3
|
+
* `runtime/scripts/amalgm-mcp/server/routes/apps.js` and
|
|
4
|
+
* `runtime/scripts/amalgm-mcp/apps/rest.js`.
|
|
5
|
+
*
|
|
6
|
+
* Lifecycle mutations are deliberately absent here: the owning Apps service
|
|
7
|
+
* already exposes them through SDK, CLI, and MCP, and the shell campaign must
|
|
8
|
+
* not choose how the production runtime starts or supervises apps.
|
|
9
|
+
*/
|
|
10
|
+
import http from 'node:http';
|
|
11
|
+
function catalogApp(app) {
|
|
12
|
+
return {
|
|
13
|
+
...app,
|
|
14
|
+
kind: 'app',
|
|
15
|
+
cwd: app.sourceDir,
|
|
16
|
+
app_ref: app.appRef,
|
|
17
|
+
appUrl: app.publicUrl,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function legacyArtifact(app) {
|
|
21
|
+
const catalog = catalogApp(app);
|
|
22
|
+
return {
|
|
23
|
+
...catalog,
|
|
24
|
+
kind: 'artifact',
|
|
25
|
+
artifactRef: catalog.appRef,
|
|
26
|
+
artifact_ref: catalog.appRef,
|
|
27
|
+
artifactUrl: catalog.appUrl || catalog.publicUrl,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function legacyRoutes(routes) {
|
|
31
|
+
return routes.map((route) => ({
|
|
32
|
+
artifact_ref: route.app_ref,
|
|
33
|
+
port: route.port,
|
|
34
|
+
name: route.name,
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
function createAppsHttpServer(apps) {
|
|
38
|
+
const server = http.createServer((request, response) => {
|
|
39
|
+
const url = new URL(request.url || '/', 'http://127.0.0.1');
|
|
40
|
+
if (request.method !== 'GET')
|
|
41
|
+
return json(response, 405, { error: 'Method not allowed' });
|
|
42
|
+
if (url.pathname === '/apps' || url.pathname === '/apps/list') {
|
|
43
|
+
return json(response, 200, { version: 1, apps: apps.list().map(catalogApp) });
|
|
44
|
+
}
|
|
45
|
+
if (url.pathname === '/apps/routes') {
|
|
46
|
+
return json(response, 200, { routes: apps.routes() });
|
|
47
|
+
}
|
|
48
|
+
if (url.pathname === '/artifacts' || url.pathname === '/artifacts/list') {
|
|
49
|
+
return json(response, 200, { version: 1, artifacts: apps.list().map(legacyArtifact) });
|
|
50
|
+
}
|
|
51
|
+
if (url.pathname === '/artifacts/routes') {
|
|
52
|
+
return json(response, 200, { routes: legacyRoutes(apps.routes()) });
|
|
53
|
+
}
|
|
54
|
+
return json(response, 404, { error: 'Not found' });
|
|
55
|
+
});
|
|
56
|
+
return {
|
|
57
|
+
listen(port = 0, host = '127.0.0.1') {
|
|
58
|
+
return new Promise((resolve, reject) => {
|
|
59
|
+
server.once('error', reject);
|
|
60
|
+
server.listen(port, host, () => {
|
|
61
|
+
server.off('error', reject);
|
|
62
|
+
resolve(server.address());
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
},
|
|
66
|
+
close() {
|
|
67
|
+
return new Promise((resolve, reject) => {
|
|
68
|
+
server.close((error) => error ? reject(error) : resolve());
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function json(response, status, body) {
|
|
74
|
+
response.writeHead(status, { 'content-type': 'application/json' });
|
|
75
|
+
response.end(JSON.stringify(body));
|
|
76
|
+
}
|
|
77
|
+
export { createAppsHttpServer };
|
|
78
|
+
//# sourceMappingURL=http.js.map
|
package/dist/http.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;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,G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AAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;YAC7D,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC;AAED,SAAS,IAAI,CAAC,QAA6B,EAAE,MAAc,EAAE,IAAa;IACxE,QAAQ,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC,CAAC;IACnE,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;AACrC,CAAC;AAED,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,5 +4,7 @@ export * from './lease.js';
|
|
|
4
4
|
export { normalizeManifest, readManifest } from './manifest.js';
|
|
5
5
|
export { createMcpTools } from './mcp.js';
|
|
6
6
|
export { createMcpServer } from './mcp-server.js';
|
|
7
|
+
export { createAppsHttpServer } from './http.js';
|
|
8
|
+
export type { AppsHttpServer, CatalogApp, LegacyArtifact } from './http.js';
|
|
7
9
|
export { inspectPackage, materialize, packPackage, unpackPackage, validatePackageFiles, } from './package.js';
|
|
8
10
|
export type * from './types.js';
|
package/dist/index.js
CHANGED
|
@@ -4,5 +4,6 @@ export * from './lease.js';
|
|
|
4
4
|
export { normalizeManifest, readManifest } from './manifest.js';
|
|
5
5
|
export { createMcpTools } from './mcp.js';
|
|
6
6
|
export { createMcpServer } from './mcp-server.js';
|
|
7
|
+
export { createAppsHttpServer } from './http.js';
|
|
7
8
|
export { inspectPackage, materialize, packPackage, unpackPackage, validatePackageFiles, } from './package.js';
|
|
8
9
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EACL,cAAc,EACd,WAAW,EACX,WAAW,EACX,aAAa,EACb,oBAAoB,GACrB,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAEjD,OAAO,EACL,cAAc,EACd,WAAW,EACX,WAAW,EACX,aAAa,EACb,oBAAoB,GACrB,MAAM,cAAc,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amalgm/apps",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Local-first, versioned application deployment for Amalgm.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"private": false,
|
|
@@ -23,6 +23,10 @@
|
|
|
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"
|
|
26
30
|
}
|
|
27
31
|
},
|
|
28
32
|
"bin": {
|