@amalgm/apps 0.1.3-preview.37556900944 → 0.1.3-preview.44182717274
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 +24 -12
- package/README.md +39 -32
- package/dist/apps.d.ts +9 -7
- package/dist/apps.js +54 -45
- package/dist/apps.js.map +1 -1
- package/dist/command-surface.d.ts +3 -7
- package/dist/command-surface.js +9 -29
- package/dist/command-surface.js.map +1 -1
- package/dist/construct-surface.js +45 -17
- package/dist/construct-surface.js.map +1 -1
- package/dist/construct.d.ts +0 -5
- package/dist/construct.js +0 -22
- package/dist/construct.js.map +1 -1
- package/dist/folders.d.ts +40 -0
- package/dist/folders.js +94 -0
- package/dist/folders.js.map +1 -0
- package/dist/identity.d.ts +1 -2
- package/dist/identity.js +1 -13
- package/dist/identity.js.map +1 -1
- package/dist/index.d.ts +1 -6
- package/dist/index.js +1 -5
- package/dist/index.js.map +1 -1
- package/dist/layout.d.ts +20 -0
- package/dist/layout.js +27 -0
- package/dist/layout.js.map +1 -0
- package/dist/logs.js +2 -0
- package/dist/logs.js.map +1 -1
- package/dist/mcp-server.d.ts +1 -1
- package/dist/mcp-server.js +3 -33
- package/dist/mcp-server.js.map +1 -1
- package/dist/ownership.d.ts +1 -1
- package/dist/ownership.js +5 -4
- package/dist/ownership.js.map +1 -1
- package/dist/package.js +10 -2
- package/dist/package.js.map +1 -1
- package/dist/presentation.d.ts +1 -3
- package/dist/presentation.js +1 -12
- package/dist/presentation.js.map +1 -1
- package/dist/releases.d.ts +4 -6
- package/dist/releases.js +15 -24
- package/dist/releases.js.map +1 -1
- package/dist/runtime.js +4 -4
- package/dist/runtime.js.map +1 -1
- package/dist/schema.js +2 -13
- package/dist/schema.js.map +1 -1
- package/dist/store.d.ts +9 -3
- package/dist/store.js +20 -14
- package/dist/store.js.map +1 -1
- package/dist/supervisor.d.ts +2 -2
- package/dist/supervisor.js +11 -11
- package/dist/supervisor.js.map +1 -1
- package/dist/types.d.ts +14 -11
- package/docs/SHELL_INTEGRATION.md +23 -5
- package/docs/STATUS.md +31 -28
- package/docs/SUPERVISION.md +14 -15
- package/package.json +7 -18
- package/skills/apps/SKILL.md +56 -73
- package/dist/bin/apps.d.ts +0 -2
- package/dist/bin/apps.js +0 -6
- package/dist/bin/apps.js.map +0 -1
- package/dist/bin/mcp.d.ts +0 -2
- package/dist/bin/mcp.js +0 -15
- package/dist/bin/mcp.js.map +0 -1
- package/dist/cli.d.ts +0 -15
- package/dist/cli.js +0 -116
- package/dist/cli.js.map +0 -1
- package/dist/http.d.ts +0 -30
- package/dist/http.js +0 -77
- package/dist/http.js.map +0 -1
package/dist/command-surface.js
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The one Apps command surface. Every adapter (
|
|
2
|
+
* The one Apps command surface. Every adapter (MCP, and any later API)
|
|
3
3
|
* consumes this list: the same names, the same inputs, the same annotations,
|
|
4
4
|
* and the same SDK calls. Nothing here spawns, stores, or supervises.
|
|
5
5
|
*/
|
|
6
6
|
import { boolean, integer, jsonSchema, parseInput, string } from './command-input.js';
|
|
7
7
|
const appId = { app_id: string('Stable app id', true) };
|
|
8
|
-
const cwd = { cwd: string('
|
|
8
|
+
const cwd = { cwd: string('Absolute path of the directory containing amalgm.app.json', true) };
|
|
9
9
|
const definitions = [
|
|
10
10
|
define({
|
|
11
11
|
name: 'create',
|
|
12
12
|
title: 'Create app',
|
|
13
|
-
description: 'Create an app from a directory containing amalgm.app.json: validate, build an immutable release, and start it.',
|
|
13
|
+
description: 'Create an app from a directory containing amalgm.app.json: validate, build an immutable release, and start it. The app gets its own folder in the apps root; a project outside that root stays where it is and gains no files.',
|
|
14
14
|
shape: {
|
|
15
15
|
...cwd,
|
|
16
16
|
port: integer('Pin a local port instead of allocating one'),
|
|
17
17
|
connect_dns: boolean('Publish the app on the public route table (default true)'),
|
|
18
|
-
autostart: boolean('Start the app whenever the
|
|
18
|
+
autostart: boolean('Start the app whenever the Amalgm runtime starts (default true)'),
|
|
19
19
|
keep_alive: boolean('Restart the app after crashes (default true)'),
|
|
20
20
|
},
|
|
21
|
-
positional: ['cwd'],
|
|
22
21
|
annotations: write(false),
|
|
23
22
|
run: (apps, input) => apps.register({
|
|
24
23
|
cwd: input.cwd,
|
|
@@ -33,7 +32,6 @@ const definitions = [
|
|
|
33
32
|
title: 'List apps',
|
|
34
33
|
description: 'List registered apps with their active releases, status, and health.',
|
|
35
34
|
shape: {},
|
|
36
|
-
positional: [],
|
|
37
35
|
annotations: read(),
|
|
38
36
|
run: async (apps) => apps.list(),
|
|
39
37
|
}),
|
|
@@ -42,32 +40,29 @@ const definitions = [
|
|
|
42
40
|
title: 'Get app',
|
|
43
41
|
description: 'Get one registered app in full.',
|
|
44
42
|
shape: appId,
|
|
45
|
-
positional: ['app_id'],
|
|
46
43
|
annotations: read(),
|
|
47
44
|
run: async (apps, input) => found(apps, input.app_id),
|
|
48
45
|
}),
|
|
49
46
|
define({
|
|
50
47
|
name: 'update',
|
|
51
48
|
title: 'Update app settings',
|
|
52
|
-
description: 'Change app settings without touching its id, route,
|
|
49
|
+
description: 'Change app settings without touching its id, route, or releases: name, description, autostart, keep-alive, and route publication. A new name renames the app\'s folder, and a running app restarts from it.',
|
|
53
50
|
shape: {
|
|
54
51
|
...appId,
|
|
55
52
|
name: string('New display name'),
|
|
56
53
|
description: string('New description'),
|
|
57
|
-
autostart: boolean('Start the app whenever the
|
|
54
|
+
autostart: boolean('Start the app whenever the Amalgm runtime starts'),
|
|
58
55
|
keep_alive: boolean('Restart the app after crashes'),
|
|
59
56
|
dns_connected: boolean('Publish the app on the public route table'),
|
|
60
57
|
},
|
|
61
|
-
positional: ['app_id'],
|
|
62
58
|
annotations: write(true),
|
|
63
59
|
run: (apps, input) => apps.update(input.app_id, settings(input)),
|
|
64
60
|
}),
|
|
65
61
|
define({
|
|
66
62
|
name: 'delete',
|
|
67
63
|
title: 'Delete app',
|
|
68
|
-
description: 'Stop and delete an app
|
|
64
|
+
description: 'Stop and delete an app: its folder goes, and its releases, logs, and data are parked on this computer. A project the app was made from is never touched.',
|
|
69
65
|
shape: appId,
|
|
70
|
-
positional: ['app_id'],
|
|
71
66
|
annotations: destructive(),
|
|
72
67
|
run: (apps, input) => apps.delete(input.app_id),
|
|
73
68
|
}),
|
|
@@ -76,7 +71,6 @@ const definitions = [
|
|
|
76
71
|
title: 'Start app',
|
|
77
72
|
description: 'Start the active deployment and keep it running.',
|
|
78
73
|
shape: appId,
|
|
79
|
-
positional: ['app_id'],
|
|
80
74
|
annotations: write(true),
|
|
81
75
|
run: (apps, input) => apps.start(input.app_id),
|
|
82
76
|
}),
|
|
@@ -85,7 +79,6 @@ const definitions = [
|
|
|
85
79
|
title: 'Stop app',
|
|
86
80
|
description: 'Stop an app and preserve its releases.',
|
|
87
81
|
shape: appId,
|
|
88
|
-
positional: ['app_id'],
|
|
89
82
|
annotations: write(true),
|
|
90
83
|
run: (apps, input) => apps.stop(input.app_id),
|
|
91
84
|
}),
|
|
@@ -93,8 +86,7 @@ const definitions = [
|
|
|
93
86
|
name: 'deploy',
|
|
94
87
|
title: 'Deploy app',
|
|
95
88
|
description: 'Build an immutable release from the source directory and activate it. The current process stays up through the build.',
|
|
96
|
-
shape: { ...appId, cwd: string('
|
|
97
|
-
positional: ['app_id', 'cwd'],
|
|
89
|
+
shape: { ...appId, cwd: string('Absolute path to build from instead of the app\'s source; it becomes the source') },
|
|
98
90
|
annotations: write(false),
|
|
99
91
|
run: (apps, input) => apps.deploy(input.app_id, { cwd: input.cwd }),
|
|
100
92
|
}),
|
|
@@ -103,7 +95,6 @@ const definitions = [
|
|
|
103
95
|
title: 'Roll back app',
|
|
104
96
|
description: 'Activate an earlier immutable release as a new deployment. Without release_id the previous deployment is restored.',
|
|
105
97
|
shape: { ...appId, release_id: string('Release to activate') },
|
|
106
|
-
positional: ['app_id', 'release_id'],
|
|
107
98
|
annotations: write(false),
|
|
108
99
|
run: (apps, input) => apps.rollback(input.app_id, { releaseId: input.release_id }),
|
|
109
100
|
}),
|
|
@@ -112,7 +103,6 @@ const definitions = [
|
|
|
112
103
|
title: 'List releases',
|
|
113
104
|
description: 'List the immutable releases of an app.',
|
|
114
105
|
shape: appId,
|
|
115
|
-
positional: ['app_id'],
|
|
116
106
|
annotations: read(),
|
|
117
107
|
run: async (apps, input) => apps.versions(input.app_id),
|
|
118
108
|
}),
|
|
@@ -121,7 +111,6 @@ const definitions = [
|
|
|
121
111
|
title: 'List deployments',
|
|
122
112
|
description: 'List the append-only deployment history of an app.',
|
|
123
113
|
shape: appId,
|
|
124
|
-
positional: ['app_id'],
|
|
125
114
|
annotations: read(),
|
|
126
115
|
run: async (apps, input) => apps.deployments(input.app_id),
|
|
127
116
|
}),
|
|
@@ -130,7 +119,6 @@ const definitions = [
|
|
|
130
119
|
title: 'Read app logs',
|
|
131
120
|
description: 'Read the last lines of the app process log.',
|
|
132
121
|
shape: { ...appId, lines: integer('How many trailing lines to return (default 200)') },
|
|
133
|
-
positional: ['app_id', 'lines'],
|
|
134
122
|
annotations: read(),
|
|
135
123
|
run: async (apps, input) => apps.logs(input.app_id, input.lines),
|
|
136
124
|
}),
|
|
@@ -139,7 +127,6 @@ const definitions = [
|
|
|
139
127
|
title: 'Validate app package',
|
|
140
128
|
description: 'Inspect a directory as an app package without changing state: manifest, digest, and packaged files.',
|
|
141
129
|
shape: cwd,
|
|
142
|
-
positional: ['cwd'],
|
|
143
130
|
annotations: read(),
|
|
144
131
|
run: async (apps, input) => apps.validate(input.cwd),
|
|
145
132
|
}),
|
|
@@ -148,7 +135,6 @@ const definitions = [
|
|
|
148
135
|
title: 'List routes',
|
|
149
136
|
description: 'List the routes of running, healthy apps that are published on the route table.',
|
|
150
137
|
shape: {},
|
|
151
|
-
positional: [],
|
|
152
138
|
annotations: read(),
|
|
153
139
|
run: async (apps) => apps.routes(),
|
|
154
140
|
}),
|
|
@@ -183,17 +169,11 @@ function settings(input) {
|
|
|
183
169
|
};
|
|
184
170
|
}
|
|
185
171
|
function define(input) {
|
|
186
|
-
for (const field of input.positional) {
|
|
187
|
-
if (!(field in input.shape))
|
|
188
|
-
throw new Error(`${input.name}: positional field ${field} is not an input`);
|
|
189
|
-
}
|
|
190
172
|
return Object.freeze({
|
|
191
173
|
name: input.name,
|
|
192
174
|
mcpName: `amalgm_apps_${input.name}`,
|
|
193
175
|
title: input.title,
|
|
194
176
|
description: input.description,
|
|
195
|
-
inputShape: input.shape,
|
|
196
|
-
positional: input.positional,
|
|
197
177
|
annotations: input.annotations,
|
|
198
178
|
inputSchema: () => jsonSchema(input.shape),
|
|
199
179
|
invoke: (apps, value) => input.run(apps, parseInput(input.shape, value)),
|
|
@@ -208,5 +188,5 @@ function write(idempotentHint) {
|
|
|
208
188
|
function destructive() {
|
|
209
189
|
return Object.freeze({ readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false });
|
|
210
190
|
}
|
|
211
|
-
export {
|
|
191
|
+
export { appCommandDefinitions, createAppCommands };
|
|
212
192
|
//# sourceMappingURL=command-surface.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-surface.js","sourceRoot":"","sources":["../src/command-surface.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"command-surface.js","sourceRoot":"","sources":["../src/command-surface.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AA8BtF,MAAM,KAAK,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,eAAe,EAAE,IAAI,CAAC,EAAE,CAAC;AACxD,MAAM,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,2DAA2D,EAAE,IAAI,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,KAAK,CAAC,KAAK,CAAC;QAC1C,MAAM,EAAE,CAAC,IAAU,EAAE,KAAc,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;KACxF,CAAC,CAAC;AACL,CAAC;AAED,SAAS,IAAI;IACX,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC;AACnH,CAAC;AAED,SAAS,KAAK,CAAC,cAAuB;IACpC,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC;AAC9G,CAAC;AAED,SAAS,WAAW;IAClB,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC;AACpH,CAAC;AAED,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -6,8 +6,11 @@
|
|
|
6
6
|
* rails decide when to ask, never how an app is built or run.
|
|
7
7
|
*/
|
|
8
8
|
import fs from 'node:fs';
|
|
9
|
+
import path from 'node:path';
|
|
10
|
+
import { makeFolder, renameApp } from './folders.js';
|
|
11
|
+
import { appLayout } from './layout.js';
|
|
9
12
|
import { packPackage, unpackPackage } from './package.js';
|
|
10
|
-
import {
|
|
13
|
+
import { constructIdentity, decodeConstructPayload, dependencyUuids, encodeConstructPayload, } from './construct.js';
|
|
11
14
|
export function appConstructSurface(service) {
|
|
12
15
|
return Object.freeze({
|
|
13
16
|
resolve: async (ref) => resolve(service, ref),
|
|
@@ -41,22 +44,33 @@ function dependencies(service, appId) {
|
|
|
41
44
|
return release ? dependencyUuids(release.manifest) : [];
|
|
42
45
|
}
|
|
43
46
|
/**
|
|
44
|
-
* The app again under a fresh UUID, recorded here as a new app of its own
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* themselves, so today there is
|
|
47
|
+
* The app again under a fresh UUID, recorded here as a new app of its own,
|
|
48
|
+
* with its source in a new folder of its own. A copy exists to be sent, not
|
|
49
|
+
* to run twice on this computer, so it is left stopped and off the route
|
|
50
|
+
* table. Its closure is the tool constructs its manifest names, and a tool
|
|
51
|
+
* carries a slug until tools are constructs themselves, so today there is
|
|
52
|
+
* nothing below the head to re-mint.
|
|
49
53
|
*/
|
|
50
54
|
async function copy(service, appId) {
|
|
51
55
|
const app = service.store.getApp(appId);
|
|
52
56
|
if (!app)
|
|
53
57
|
throw new Error(`App not found: ${appId}`);
|
|
54
|
-
const
|
|
55
|
-
unpackPackage(packPackage(app.sourceDir), directory);
|
|
56
|
-
const copied = await service.create({ cwd: directory, autostart: false, connectDns: false }, { intentional: true });
|
|
58
|
+
const copied = await createInNewFolder(service, app.name, packPackage(app.sourceDir), (directory) => (service.create({ cwd: directory, autostart: false, connectDns: false }, { intentional: true })));
|
|
57
59
|
await service.stop(copied.id);
|
|
58
60
|
return constructIdentity(copied);
|
|
59
61
|
}
|
|
62
|
+
/** Unpack a source Amalgm owns into a new app folder and create the app there; a failure leaves no folder. */
|
|
63
|
+
async function createInNewFolder(service, name, source, create) {
|
|
64
|
+
const directory = appLayout(service.root, makeFolder(service, name)).dir;
|
|
65
|
+
try {
|
|
66
|
+
unpackPackage(source, directory);
|
|
67
|
+
return await create(directory);
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
fs.rmSync(directory, { recursive: true, force: true });
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
60
74
|
/** What this computer runs for one construct: the only Apply truth. */
|
|
61
75
|
function holding(service, entityId) {
|
|
62
76
|
const app = service.store.getApp(entityId);
|
|
@@ -74,18 +88,28 @@ function payloadDependencies(payloadFile) {
|
|
|
74
88
|
async function switchTo(service, input) {
|
|
75
89
|
const received = decodeConstructPayload(fs.readFileSync(input.payloadFile));
|
|
76
90
|
const existing = service.store.getApp(input.entityId);
|
|
77
|
-
const directory = existing && isImportedSource(service.stateDir, existing.sourceDir)
|
|
78
|
-
? existing.sourceDir
|
|
79
|
-
: allocateImportDir(service.stateDir, received.manifest.name);
|
|
80
|
-
unpackPackage(received, directory);
|
|
81
91
|
const origin = { received: input.version };
|
|
82
92
|
// Nothing is answered here: what this computer now runs is a question for
|
|
83
93
|
// the product, and the host asks it again when it verifies the switch.
|
|
84
94
|
if (!existing) {
|
|
85
|
-
await service.create({ id: input.entityId, cwd: directory }, origin);
|
|
95
|
+
await createInNewFolder(service, received.manifest.name, received, (directory) => (service.create({ id: input.entityId, cwd: directory }, origin)));
|
|
86
96
|
return;
|
|
87
97
|
}
|
|
88
|
-
|
|
98
|
+
// A source Amalgm owns takes the version in place. A person's own project
|
|
99
|
+
// is never rewritten: the version is built from a copy that leaves after.
|
|
100
|
+
const layout = appLayout(service.root, existing.folder);
|
|
101
|
+
const owned = existing.sourceDir === layout.dir;
|
|
102
|
+
if (!owned)
|
|
103
|
+
fs.mkdirSync(layout.build, { recursive: true });
|
|
104
|
+
const directory = owned ? layout.dir : fs.mkdtempSync(path.join(layout.build, 'received-'));
|
|
105
|
+
try {
|
|
106
|
+
unpackPackage(received, directory);
|
|
107
|
+
await service.operations.run(input.entityId, 'deploy', () => (service.deployFrom(input.entityId, directory, origin)));
|
|
108
|
+
}
|
|
109
|
+
finally {
|
|
110
|
+
if (!owned)
|
|
111
|
+
fs.rmSync(directory, { recursive: true, force: true });
|
|
112
|
+
}
|
|
89
113
|
}
|
|
90
114
|
/** A received change where only the named fields moved. */
|
|
91
115
|
async function applyStructure(service, input) {
|
|
@@ -95,11 +119,15 @@ async function applyStructure(service, input) {
|
|
|
95
119
|
if (!app)
|
|
96
120
|
return;
|
|
97
121
|
if (input.status === 'deleted') {
|
|
98
|
-
|
|
122
|
+
// Deleted on another computer: this one forgets the app and parks its
|
|
123
|
+
// `.private/`, and leaves the folder itself to the person.
|
|
124
|
+
await service.operations.run(input.entityId, 'delete', () => service.forget(input.entityId));
|
|
99
125
|
return;
|
|
100
126
|
}
|
|
101
127
|
if (app.name !== input.name) {
|
|
102
|
-
service.
|
|
128
|
+
await service.operations.run(input.entityId, 'rename', async () => {
|
|
129
|
+
service.changed(await renameApp(service, service.store.getApp(input.entityId), input.name));
|
|
130
|
+
});
|
|
103
131
|
}
|
|
104
132
|
}
|
|
105
133
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"construct-surface.js","sourceRoot":"","sources":["../src/construct-surface.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"construct-surface.js","sourceRoot":"","sources":["../src/construct-surface.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,eAAe,EACf,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AAuBxB,MAAM,UAAU,mBAAmB,CAAC,OAAa;IAC/C,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,OAAO,EAAE,KAAK,EAAE,GAAW,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;QACrD,YAAY,EAAE,KAAK,EAAE,KAAa,EAAE,EAAE,CAAC,YAAY,CAA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AG,CAAC,CAAC,CAAC;IACzD,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9D,MAAM,eAAe,CAAC,OAAO,EAAE;QAC7B,QAAQ,EAAE,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO;KACjE,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,UAAU,CAAC,OAAa,EAAE,KAAa,EAAE,OAAe;IAC/D,OAAO,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,EAAE,EAAE,gBAAgB,EAAE,OAAO,EAAE,CAAE,CAAC;AACxE,CAAC;AAED,6EAA6E;AAC7E,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,OAAa,EAAE,MAAuB;IAC1E,MAAM,OAAO,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC,MAAM,CAAC,CAAC;AAClD,CAAC"}
|
package/dist/construct.d.ts
CHANGED
|
@@ -83,8 +83,3 @@ export declare function encodeConstructPayload(packed: PackedPackage): Construct
|
|
|
83
83
|
export declare function decodeConstructPayload(bytes: Uint8Array | string): ConstructPackage;
|
|
84
84
|
/** The UUIDs this app depends on: the tool constructs its manifest names. */
|
|
85
85
|
export declare function dependencyUuids(manifest: AppManifest): string[];
|
|
86
|
-
/** Where a received app's files live. A created app's source is the user's own. */
|
|
87
|
-
export declare function importsRoot(stateDir: string): string;
|
|
88
|
-
/** An imported source leaves with its app; the user's own directory never does. */
|
|
89
|
-
export declare function isImportedSource(stateDir: string, sourceDir: string): boolean;
|
|
90
|
-
export declare function allocateImportDir(stateDir: string, name: unknown): string;
|
package/dist/construct.js
CHANGED
|
@@ -9,8 +9,6 @@
|
|
|
9
9
|
* address the bytes by content. The rails never open the payload; Apps does.
|
|
10
10
|
*/
|
|
11
11
|
import crypto from 'node:crypto';
|
|
12
|
-
import fs from 'node:fs';
|
|
13
|
-
import path from 'node:path';
|
|
14
12
|
const PAYLOAD_SCHEMA = 1;
|
|
15
13
|
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
16
14
|
/** Name one app the way the access commands do. */
|
|
@@ -52,24 +50,4 @@ export function decodeConstructPayload(bytes) {
|
|
|
52
50
|
export function dependencyUuids(manifest) {
|
|
53
51
|
return manifest.toolIds.filter((id) => UUID.test(id));
|
|
54
52
|
}
|
|
55
|
-
/** Where a received app's files live. A created app's source is the user's own. */
|
|
56
|
-
export function importsRoot(stateDir) {
|
|
57
|
-
return path.join(stateDir, 'imports');
|
|
58
|
-
}
|
|
59
|
-
/** An imported source leaves with its app; the user's own directory never does. */
|
|
60
|
-
export function isImportedSource(stateDir, sourceDir) {
|
|
61
|
-
return path.dirname(path.resolve(sourceDir)) === importsRoot(stateDir);
|
|
62
|
-
}
|
|
63
|
-
export function allocateImportDir(stateDir, name) {
|
|
64
|
-
const root = importsRoot(stateDir);
|
|
65
|
-
fs.mkdirSync(root, { recursive: true });
|
|
66
|
-
const base = String(name || 'app').toLowerCase().replace(/[^a-z0-9._-]+/g, '-')
|
|
67
|
-
.replace(/^-+|-+$/g, '').slice(0, 60) || 'app';
|
|
68
|
-
for (let index = 0; index < 1000; index += 1) {
|
|
69
|
-
const candidate = path.join(root, index ? `${base}-${index + 1}` : base);
|
|
70
|
-
if (!fs.existsSync(candidate))
|
|
71
|
-
return candidate;
|
|
72
|
-
}
|
|
73
|
-
throw new Error(`Could not allocate an install directory for app: ${String(name)}`);
|
|
74
|
-
}
|
|
75
53
|
//# sourceMappingURL=construct.js.map
|
package/dist/construct.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"construct.js","sourceRoot":"","sources":["../src/construct.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,MAAM,MAAM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,IAAI,CAAC,KAAK,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IACnG,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,cAAc,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,mCAAmC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;IAC/E,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACjE,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9D,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;AAC5D,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,eAAe,CAAC,QAAqB;IACnD,OAAO,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every app is one folder in the user's apps root, named after the app. The
|
|
3
|
+
* source sits in that folder when Amalgm owns it (made there by an agent,
|
|
4
|
+
* received, or copied); an app made from a person's own project leaves the
|
|
5
|
+
* project where it is, and the folder's identity file points at it. Only the
|
|
6
|
+
* app's folder is ever deleted, never a person's project.
|
|
7
|
+
*/
|
|
8
|
+
import type { Apps } from './apps.js';
|
|
9
|
+
import type { AppRecord } from './types.js';
|
|
10
|
+
/** The folder a create took, and the paths it made there. */
|
|
11
|
+
interface FolderClaim {
|
|
12
|
+
folder: string;
|
|
13
|
+
/** The person's own project, or null when the folder holds the source. */
|
|
14
|
+
sourceDir: string | null;
|
|
15
|
+
made: string[];
|
|
16
|
+
}
|
|
17
|
+
/** Make a new, empty folder for an app called `name`. */
|
|
18
|
+
declare function makeFolder(service: Apps, name: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* The folder a new app takes. A source already in the apps root is the
|
|
21
|
+
* app's folder; any other source is the person's own project, which stays
|
|
22
|
+
* where it is while a new folder names it.
|
|
23
|
+
*/
|
|
24
|
+
declare function claimFolder(service: Apps, cwd: string, name: string): FolderClaim;
|
|
25
|
+
/** Undo a failed create: only what it made goes, never a source it found. */
|
|
26
|
+
declare function releaseClaim(claim: FolderClaim): void;
|
|
27
|
+
/** The identity file: the app's permanent id and name, and the person's own project when that is its source. */
|
|
28
|
+
declare function writeIdentity(service: Apps, app: AppRecord): void;
|
|
29
|
+
/** A deliberate deploy from another directory makes it the app's source. */
|
|
30
|
+
declare function repointSource(service: Apps, app: AppRecord, cwd: string): void;
|
|
31
|
+
/**
|
|
32
|
+
* Rename an app and its folder. A running app runs from inside its folder
|
|
33
|
+
* and was handed paths there, so it is stopped for the move and started again.
|
|
34
|
+
* The caller holds the app's operation.
|
|
35
|
+
*/
|
|
36
|
+
declare function renameApp(service: Apps, app: AppRecord, name: string): Promise<AppRecord>;
|
|
37
|
+
/** Keep a removed app's `.private/` in the parked folder. Nothing parked is ever deleted. */
|
|
38
|
+
declare function parkPrivate(service: Apps, app: AppRecord): void;
|
|
39
|
+
export { claimFolder, makeFolder, parkPrivate, releaseClaim, renameApp, repointSource, writeIdentity };
|
|
40
|
+
export type { FolderClaim };
|
package/dist/folders.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every app is one folder in the user's apps root, named after the app. The
|
|
3
|
+
* source sits in that folder when Amalgm owns it (made there by an agent,
|
|
4
|
+
* received, or copied); an app made from a person's own project leaves the
|
|
5
|
+
* project where it is, and the folder's identity file points at it. Only the
|
|
6
|
+
* app's folder is ever deleted, never a person's project.
|
|
7
|
+
*/
|
|
8
|
+
import fs from 'node:fs';
|
|
9
|
+
import path from 'node:path';
|
|
10
|
+
import { entityFolderName, parkedDir } from '@amalgm/core/identity';
|
|
11
|
+
import { appLayout } from './layout.js';
|
|
12
|
+
/** Folder names in use in the apps root, on disk or in the catalog. */
|
|
13
|
+
function takenFolders(service, except = '') {
|
|
14
|
+
const onDisk = fs.existsSync(service.root) ? fs.readdirSync(service.root) : [];
|
|
15
|
+
return [...onDisk, ...service.store.listApps().map((app) => app.folder)]
|
|
16
|
+
.filter((folder) => folder.toLowerCase() !== except.toLowerCase());
|
|
17
|
+
}
|
|
18
|
+
/** Make a new, empty folder for an app called `name`. */
|
|
19
|
+
function makeFolder(service, name) {
|
|
20
|
+
const folder = entityFolderName(name, takenFolders(service));
|
|
21
|
+
fs.mkdirSync(service.root, { recursive: true });
|
|
22
|
+
fs.mkdirSync(appLayout(service.root, folder).dir);
|
|
23
|
+
return folder;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The folder a new app takes. A source already in the apps root is the
|
|
27
|
+
* app's folder; any other source is the person's own project, which stays
|
|
28
|
+
* where it is while a new folder names it.
|
|
29
|
+
*/
|
|
30
|
+
function claimFolder(service, cwd, name) {
|
|
31
|
+
if (path.dirname(cwd) !== service.root) {
|
|
32
|
+
const folder = makeFolder(service, name);
|
|
33
|
+
return { folder, sourceDir: cwd, made: [appLayout(service.root, folder).dir] };
|
|
34
|
+
}
|
|
35
|
+
const folder = path.basename(cwd);
|
|
36
|
+
if (service.store.listApps().some((app) => app.folder.toLowerCase() === folder.toLowerCase())) {
|
|
37
|
+
throw new Error(`Another app already uses this folder: ${cwd}`);
|
|
38
|
+
}
|
|
39
|
+
const layout = appLayout(service.root, folder);
|
|
40
|
+
return { folder, sourceDir: null, made: [layout.private, layout.identity].filter((file) => !fs.existsSync(file)) };
|
|
41
|
+
}
|
|
42
|
+
/** Undo a failed create: only what it made goes, never a source it found. */
|
|
43
|
+
function releaseClaim(claim) {
|
|
44
|
+
for (const made of claim.made)
|
|
45
|
+
fs.rmSync(made, { recursive: true, force: true });
|
|
46
|
+
}
|
|
47
|
+
/** The identity file: the app's permanent id and name, and the person's own project when that is its source. */
|
|
48
|
+
function writeIdentity(service, app) {
|
|
49
|
+
const layout = appLayout(service.root, app.folder);
|
|
50
|
+
const source = app.sourceDir === layout.dir ? {} : { source: app.sourceDir };
|
|
51
|
+
fs.writeFileSync(layout.identity, `${JSON.stringify({ id: app.id, name: app.name, ...source }, null, 2)}\n`);
|
|
52
|
+
}
|
|
53
|
+
/** A deliberate deploy from another directory makes it the app's source. */
|
|
54
|
+
function repointSource(service, app, cwd) {
|
|
55
|
+
if (cwd === app.sourceDir)
|
|
56
|
+
return;
|
|
57
|
+
const own = appLayout(service.root, app.folder).dir;
|
|
58
|
+
writeIdentity(service, service.store.updateApp(app.id, { sourceDir: cwd === own ? null : cwd }));
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Rename an app and its folder. A running app runs from inside its folder
|
|
62
|
+
* and was handed paths there, so it is stopped for the move and started again.
|
|
63
|
+
* The caller holds the app's operation.
|
|
64
|
+
*/
|
|
65
|
+
async function renameApp(service, app, name) {
|
|
66
|
+
const folder = entityFolderName(name, takenFolders(service, app.folder));
|
|
67
|
+
const moves = folder !== app.folder;
|
|
68
|
+
const running = moves && Boolean(app.pid);
|
|
69
|
+
if (running) {
|
|
70
|
+
await service.supervisor.stop(app.id, { preserveDesiredState: true });
|
|
71
|
+
service.health.forget(app.id);
|
|
72
|
+
}
|
|
73
|
+
if (moves)
|
|
74
|
+
fs.renameSync(appLayout(service.root, app.folder).dir, appLayout(service.root, folder).dir);
|
|
75
|
+
let renamed = service.store.updateApp(app.id, { name, folder });
|
|
76
|
+
writeIdentity(service, renamed);
|
|
77
|
+
if (running)
|
|
78
|
+
renamed = await service.supervisor.start(app.id);
|
|
79
|
+
return renamed;
|
|
80
|
+
}
|
|
81
|
+
/** Keep a removed app's `.private/` in the parked folder. Nothing parked is ever deleted. */
|
|
82
|
+
function parkPrivate(service, app) {
|
|
83
|
+
const from = appLayout(service.root, app.folder).private;
|
|
84
|
+
if (!fs.existsSync(from))
|
|
85
|
+
return;
|
|
86
|
+
const base = parkedDir(service.parked, 'app', app.id);
|
|
87
|
+
let target = base;
|
|
88
|
+
for (let n = 2; fs.existsSync(target); n += 1)
|
|
89
|
+
target = `${base}-${n}`;
|
|
90
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
91
|
+
fs.renameSync(from, target);
|
|
92
|
+
}
|
|
93
|
+
export { claimFolder, makeFolder, parkPrivate, releaseClaim, renameApp, repointSource, writeIdentity };
|
|
94
|
+
//# sourceMappingURL=folders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"folders.js","sourceRoot":"","sources":["../src/folders.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAYxC,uEAAuE;AACvE,SAAS,YAAY,CAAC,OAAa,EAAE,MAAM,GAAG,EAAE;IAC9C,MAAM,MAAM,GAAG,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC/E,OAAO,CAAC,GAAG,MAAM,EAAE,GAAG,OAAO,C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EAAE,CAAE,CAAC;IACjE,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAChC,IAAI,OAAO;QAAE,OAAO,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC9D,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,6FAA6F;AAC7F,SAAS,WAAW,CAAC,OAAa,EAAE,GAAc;IAChD,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;IACzD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO;IACjC,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;IACtD,IAAI,MAAM,GAAG,IAAI,CAAC;IAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC;QAAE,MAAM,GAAG,GAAG,IAAI,IAAI,CAAC,EAAE,CAAC;IACvE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACxD,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC9B,CAAC;AAED,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC"}
|
package/dist/identity.d.ts
CHANGED
|
@@ -3,8 +3,7 @@ import type { AppRecord } from './types.js';
|
|
|
3
3
|
interface AppReader {
|
|
4
4
|
listApps(): AppRecord[];
|
|
5
5
|
}
|
|
6
|
-
declare function defaultStateDir(env?: NodeJS.ProcessEnv, scope?: unknown): string;
|
|
7
6
|
declare function allocatePort(store: AppReader, preferred: number | undefined, minimum: number, maximum: number): Promise<number>;
|
|
8
7
|
declare function allocateRef(store: AppReader): string;
|
|
9
8
|
declare function assertAppRef(value: unknown): string;
|
|
10
|
-
export { APP_REF_PATTERN, allocatePort, allocateRef, assertAppRef,
|
|
9
|
+
export { APP_REF_PATTERN, allocatePort, allocateRef, assertAppRef, };
|
package/dist/identity.js
CHANGED
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
import crypto from 'node:crypto';
|
|
2
2
|
import net from 'node:net';
|
|
3
|
-
import os from 'node:os';
|
|
4
|
-
import path from 'node:path';
|
|
5
|
-
import { resolveProductStateDir } from '@amalgm/core/identity';
|
|
6
3
|
import { APP_REF_PATTERN } from '@amalgm/core/transport';
|
|
7
4
|
const REF_ALPHABET = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
|
8
|
-
function defaultStateDir(env = process.env, scope) {
|
|
9
|
-
return resolveProductStateDir({
|
|
10
|
-
product: 'apps',
|
|
11
|
-
primitive: 'apps',
|
|
12
|
-
env,
|
|
13
|
-
homedir: path.join(os.homedir(), '.amalgm'),
|
|
14
|
-
scope,
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
5
|
// The store knows only the apps it registered, so every candidate is proven
|
|
18
6
|
// on the host: a port is free when nothing answers on loopback. A bind probe
|
|
19
7
|
// is not enough, since `::` binds beside an IPv4 wildcard holder on macOS.
|
|
@@ -71,5 +59,5 @@ function assertAppRef(value) {
|
|
|
71
59
|
}
|
|
72
60
|
return String(value);
|
|
73
61
|
}
|
|
74
|
-
export { APP_REF_PATTERN, allocatePort, allocateRef, assertAppRef,
|
|
62
|
+
export { APP_REF_PATTERN, allocatePort, allocateRef, assertAppRef, };
|
|
75
63
|
//# sourceMappingURL=identity.js.map
|
package/dist/identity.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,M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,IAAI,YAAY,CAAC,IAAI,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;gBACtD,IAAI,SAAS,CAAC,MAAM,KAAK,EAAE;oBAAE,MAAM;YACrC,CAAC;QACH,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC;YAAE,OAAO,SAAS,CAAC;IAC7C,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;AACnD,CAAC;AAED,SAAS,YAAY,CAAC,KAAc;IAClC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC3E,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AAED,OAAO,EACL,eAAe,EACf,YAAY,EACZ,WAAW,EACX,YAAY,GACb,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
export { Apps } from './apps.js';
|
|
2
|
-
export {
|
|
3
|
-
export { appCommandDefinition, appCommandDefinitions, createAppCommands } from './command-surface.js';
|
|
2
|
+
export { appCommandDefinitions, createAppCommands } from './command-surface.js';
|
|
4
3
|
export type { AppCommandAnnotations, AppCommandDefinition, AppCommandName, AppCommands } from './command-surface.js';
|
|
5
4
|
export { appConstructSurface } from './construct-surface.js';
|
|
6
5
|
export type { AppConstructSurface } from './construct-surface.js';
|
|
7
6
|
export { decodeConstructPayload, encodeConstructPayload } from './construct.js';
|
|
8
7
|
export type { ConstructChange, ConstructHolding, ConstructIdentity, ConstructPayload, ConstructSwitch, RecordConstruct, SwitchedStructure, } from './construct.js';
|
|
9
|
-
export { linkedToolEnvironment } from './presentation.js';
|
|
10
8
|
export * from './lease.js';
|
|
11
9
|
export { createMcpTools } from './mcp.js';
|
|
12
10
|
export { createMcpServer } from './mcp-server.js';
|
|
13
|
-
export { createAppsHttpServer } from './http.js';
|
|
14
|
-
export type { AppsHttpServer, CatalogApp, LegacyArtifact } from './http.js';
|
|
15
|
-
export { unpackPackage } from './package.js';
|
|
16
11
|
export type * from './types.js';
|