@evref-bl/plexus 0.15.1 → 0.16.0
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 +8 -12
- package/dist/cli.js +8 -183
- package/dist/cli.js.map +1 -1
- package/dist/commandLine.d.ts +13 -0
- package/dist/commandLine.d.ts.map +1 -0
- package/dist/commandLine.js +247 -0
- package/dist/commandLine.js.map +1 -0
- package/dist/config/pharoMcpVersion.d.ts +6 -7
- package/dist/config/pharoMcpVersion.d.ts.map +1 -1
- package/dist/config/pharoMcpVersion.js +6 -7
- package/dist/config/pharoMcpVersion.js.map +1 -1
- package/dist/errors.d.ts +11 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +17 -0
- package/dist/errors.js.map +1 -0
- package/dist/forward/endpointHandoffFormat.d.ts +23 -0
- package/dist/forward/endpointHandoffFormat.d.ts.map +1 -0
- package/dist/forward/endpointHandoffFormat.js.map +1 -0
- package/dist/forward/index.d.ts +20 -0
- package/dist/forward/index.d.ts.map +1 -0
- package/dist/forward/index.js +77 -0
- package/dist/forward/index.js.map +1 -0
- package/dist/forward/jsonRpc.d.ts +20 -0
- package/dist/forward/jsonRpc.d.ts.map +1 -0
- package/dist/forward/jsonRpc.js +141 -0
- package/dist/forward/jsonRpc.js.map +1 -0
- package/dist/home.d.ts +15 -0
- package/dist/home.d.ts.map +1 -0
- package/dist/home.js +30 -0
- package/dist/home.js.map +1 -0
- package/dist/images/bases.d.ts +40 -0
- package/dist/images/bases.d.ts.map +1 -0
- package/dist/images/bases.js +190 -0
- package/dist/images/bases.js.map +1 -0
- package/dist/images/claims.d.ts +34 -0
- package/dist/images/claims.d.ts.map +1 -0
- package/dist/images/claims.js +119 -0
- package/dist/images/claims.js.map +1 -0
- package/dist/images/context.d.ts +22 -0
- package/dist/images/context.d.ts.map +1 -0
- package/dist/images/context.js +26 -0
- package/dist/images/context.js.map +1 -0
- package/dist/images/create.d.ts +19 -0
- package/dist/images/create.d.ts.map +1 -0
- package/dist/images/create.js +121 -0
- package/dist/images/create.js.map +1 -0
- package/dist/images/delete.d.ts +10 -0
- package/dist/images/delete.d.ts.map +1 -0
- package/dist/images/delete.js +31 -0
- package/dist/images/delete.js.map +1 -0
- package/dist/images/endpoint.d.ts +17 -0
- package/dist/images/endpoint.d.ts.map +1 -0
- package/dist/images/endpoint.js +58 -0
- package/dist/images/endpoint.js.map +1 -0
- package/dist/images/index.d.ts +28 -0
- package/dist/images/index.d.ts.map +1 -0
- package/dist/images/index.js +51 -0
- package/dist/images/index.js.map +1 -0
- package/dist/images/leftovers.d.ts +9 -0
- package/dist/images/leftovers.d.ts.map +1 -0
- package/dist/images/leftovers.js +38 -0
- package/dist/images/leftovers.js.map +1 -0
- package/dist/images/list.d.ts +12 -0
- package/dist/images/list.d.ts.map +1 -0
- package/dist/images/list.js +74 -0
- package/dist/images/list.js.map +1 -0
- package/dist/images/names.d.ts +15 -0
- package/dist/images/names.d.ts.map +1 -0
- package/dist/images/names.js +53 -0
- package/dist/images/names.js.map +1 -0
- package/dist/images/prepare.d.ts +18 -0
- package/dist/images/prepare.d.ts.map +1 -0
- package/dist/images/prepare.js +58 -0
- package/dist/images/prepare.js.map +1 -0
- package/dist/images/processes.d.ts +21 -0
- package/dist/images/processes.d.ts.map +1 -0
- package/dist/images/processes.js +83 -0
- package/dist/images/processes.js.map +1 -0
- package/dist/images/scripts.d.ts +39 -0
- package/dist/images/scripts.d.ts.map +1 -0
- package/dist/images/scripts.js +127 -0
- package/dist/images/scripts.js.map +1 -0
- package/dist/images/start.d.ts +23 -0
- package/dist/images/start.d.ts.map +1 -0
- package/dist/images/start.js +173 -0
- package/dist/images/start.js.map +1 -0
- package/dist/images/stop.d.ts +11 -0
- package/dist/images/stop.d.ts.map +1 -0
- package/dist/images/stop.js +42 -0
- package/dist/images/stop.js.map +1 -0
- package/dist/images/store.d.ts +62 -0
- package/dist/images/store.d.ts.map +1 -0
- package/dist/images/store.js +180 -0
- package/dist/images/store.js.map +1 -0
- package/dist/images/templates.d.ts +14 -0
- package/dist/images/templates.d.ts.map +1 -0
- package/dist/images/templates.js +84 -0
- package/dist/images/templates.js.map +1 -0
- package/dist/index.d.ts +12 -22
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -22
- package/dist/index.js.map +1 -1
- package/dist/launcher/pharoLauncherMcpClient.d.ts +22 -59
- package/dist/launcher/pharoLauncherMcpClient.d.ts.map +1 -1
- package/dist/launcher/pharoLauncherMcpClient.js +128 -87
- package/dist/launcher/pharoLauncherMcpClient.js.map +1 -1
- package/dist/launcher/pharoLauncherProfile.d.ts +7 -29
- package/dist/launcher/pharoLauncherProfile.d.ts.map +1 -1
- package/dist/launcher/pharoLauncherProfile.js +19 -111
- package/dist/launcher/pharoLauncherProfile.js.map +1 -1
- package/dist/launcher/vmRenewal.d.ts +30 -0
- package/dist/launcher/vmRenewal.d.ts.map +1 -0
- package/dist/launcher/vmRenewal.js +58 -0
- package/dist/launcher/vmRenewal.js.map +1 -0
- package/dist/mcp/server.d.ts +18 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +206 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/types.d.ts +68 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +5 -0
- package/dist/version.js.map +1 -0
- package/package.json +3 -12
- package/dist/config/config.d.ts +0 -15
- package/dist/config/config.d.ts.map +0 -1
- package/dist/config/config.js +0 -74
- package/dist/config/config.js.map +0 -1
- package/dist/config/plexusHome.d.ts +0 -17
- package/dist/config/plexusHome.d.ts.map +0 -1
- package/dist/config/plexusHome.js +0 -30
- package/dist/config/plexusHome.js.map +0 -1
- package/dist/config/projectConfig.d.ts +0 -141
- package/dist/config/projectConfig.d.ts.map +0 -1
- package/dist/config/projectConfig.js +0 -722
- package/dist/config/projectConfig.js.map +0 -1
- package/dist/config/projectConfigAuthoring.d.ts +0 -53
- package/dist/config/projectConfigAuthoring.d.ts.map +0 -1
- package/dist/config/projectConfigAuthoring.js +0 -159
- package/dist/config/projectConfigAuthoring.js.map +0 -1
- package/dist/gateway/projectImageMcpEndpoint.d.ts +0 -23
- package/dist/gateway/projectImageMcpEndpoint.d.ts.map +0 -1
- package/dist/gateway/projectImageMcpEndpoint.js +0 -40
- package/dist/gateway/projectImageMcpEndpoint.js.map +0 -1
- package/dist/gateway/server/index.d.ts +0 -8
- package/dist/gateway/server/index.d.ts.map +0 -1
- package/dist/gateway/server/index.js +0 -34
- package/dist/gateway/server/index.js.map +0 -1
- package/dist/gateway/server/mcp/server.d.ts +0 -66
- package/dist/gateway/server/mcp/server.d.ts.map +0 -1
- package/dist/gateway/server/mcp/server.js +0 -458
- package/dist/gateway/server/mcp/server.js.map +0 -1
- package/dist/gateway/server/routing/endpointHandoffFormat.d.ts +0 -26
- package/dist/gateway/server/routing/endpointHandoffFormat.d.ts.map +0 -1
- package/dist/gateway/server/routing/endpointHandoffFormat.js.map +0 -1
- package/dist/gateway/server/routing/gateway.d.ts +0 -167
- package/dist/gateway/server/routing/gateway.d.ts.map +0 -1
- package/dist/gateway/server/routing/gateway.js +0 -863
- package/dist/gateway/server/routing/gateway.js.map +0 -1
- package/dist/gateway/server/routing/imageMcpRouter.d.ts +0 -59
- package/dist/gateway/server/routing/imageMcpRouter.d.ts.map +0 -1
- package/dist/gateway/server/routing/imageMcpRouter.js +0 -253
- package/dist/gateway/server/routing/imageMcpRouter.js.map +0 -1
- package/dist/gateway/server/routing/pharoFacade.d.ts +0 -12
- package/dist/gateway/server/routing/pharoFacade.d.ts.map +0 -1
- package/dist/gateway/server/routing/pharoFacade.js +0 -67
- package/dist/gateway/server/routing/pharoFacade.js.map +0 -1
- package/dist/gateway/server/routing/routeDiscovery.d.ts +0 -26
- package/dist/gateway/server/routing/routeDiscovery.d.ts.map +0 -1
- package/dist/gateway/server/routing/routeDiscovery.js +0 -46
- package/dist/gateway/server/routing/routeDiscovery.js.map +0 -1
- package/dist/gateway/server/routing/routingTable.d.ts +0 -120
- package/dist/gateway/server/routing/routingTable.d.ts.map +0 -1
- package/dist/gateway/server/routing/routingTable.js +0 -215
- package/dist/gateway/server/routing/routingTable.js.map +0 -1
- package/dist/gateway/server/support/processLiveness.d.ts +0 -10
- package/dist/gateway/server/support/processLiveness.d.ts.map +0 -1
- package/dist/gateway/server/support/processLiveness.js +0 -25
- package/dist/gateway/server/support/processLiveness.js.map +0 -1
- package/dist/gateway/server/support/sourceBuildPreflight.d.ts +0 -15
- package/dist/gateway/server/support/sourceBuildPreflight.d.ts.map +0 -1
- package/dist/gateway/server/support/sourceBuildPreflight.js +0 -88
- package/dist/gateway/server/support/sourceBuildPreflight.js.map +0 -1
- package/dist/gateway/server/support/toolResultFormatting.d.ts +0 -8
- package/dist/gateway/server/support/toolResultFormatting.d.ts.map +0 -1
- package/dist/gateway/server/support/toolResultFormatting.js +0 -74
- package/dist/gateway/server/support/toolResultFormatting.js.map +0 -1
- package/dist/images/homeImageCache.d.ts +0 -302
- package/dist/images/homeImageCache.d.ts.map +0 -1
- package/dist/images/homeImageCache.js +0 -1024
- package/dist/images/homeImageCache.js.map +0 -1
- package/dist/images/imageRescue.d.ts +0 -151
- package/dist/images/imageRescue.d.ts.map +0 -1
- package/dist/images/imageRescue.js +0 -748
- package/dist/images/imageRescue.js.map +0 -1
- package/dist/images/imageRuntime.d.ts +0 -60
- package/dist/images/imageRuntime.d.ts.map +0 -1
- package/dist/images/imageRuntime.js +0 -90
- package/dist/images/imageRuntime.js.map +0 -1
- package/dist/images/preparedImageCache.d.ts +0 -86
- package/dist/images/preparedImageCache.d.ts.map +0 -1
- package/dist/images/preparedImageCache.js +0 -229
- package/dist/images/preparedImageCache.js.map +0 -1
- package/dist/images/scopedTemplateCatalog.d.ts +0 -33
- package/dist/images/scopedTemplateCatalog.d.ts.map +0 -1
- package/dist/images/scopedTemplateCatalog.js +0 -363
- package/dist/images/scopedTemplateCatalog.js.map +0 -1
- package/dist/internal.d.ts +0 -20
- package/dist/internal.d.ts.map +0 -1
- package/dist/internal.js +0 -20
- package/dist/internal.js.map +0 -1
- package/dist/launcher/scopedPharoLauncherServer.d.ts +0 -349
- package/dist/launcher/scopedPharoLauncherServer.d.ts.map +0 -1
- package/dist/launcher/scopedPharoLauncherServer.js +0 -1307
- package/dist/launcher/scopedPharoLauncherServer.js.map +0 -1
- package/dist/lifecycle/startProjectImage.d.ts +0 -94
- package/dist/lifecycle/startProjectImage.d.ts.map +0 -1
- package/dist/lifecycle/startProjectImage.js +0 -1008
- package/dist/lifecycle/startProjectImage.js.map +0 -1
- package/dist/lifecycle/stopProjectImage.d.ts +0 -31
- package/dist/lifecycle/stopProjectImage.d.ts.map +0 -1
- package/dist/lifecycle/stopProjectImage.js +0 -201
- package/dist/lifecycle/stopProjectImage.js.map +0 -1
- package/dist/mcp/agentServer.d.ts +0 -15
- package/dist/mcp/agentServer.d.ts.map +0 -1
- package/dist/mcp/agentServer.js +0 -67
- package/dist/mcp/agentServer.js.map +0 -1
- package/dist/mcp/imageOperations.d.ts +0 -54
- package/dist/mcp/imageOperations.d.ts.map +0 -1
- package/dist/mcp/imageOperations.js +0 -223
- package/dist/mcp/imageOperations.js.map +0 -1
- package/dist/mcp/pharoMcpHealth.d.ts +0 -26
- package/dist/mcp/pharoMcpHealth.d.ts.map +0 -1
- package/dist/mcp/pharoMcpHealth.js +0 -97
- package/dist/mcp/pharoMcpHealth.js.map +0 -1
- package/dist/support/pathStyle.d.ts +0 -11
- package/dist/support/pathStyle.d.ts.map +0 -1
- package/dist/support/pathStyle.js +0 -61
- package/dist/support/pathStyle.js.map +0 -1
- package/dist/support/toolResultFormatting.d.ts +0 -8
- package/dist/support/toolResultFormatting.d.ts.map +0 -1
- package/dist/support/toolResultFormatting.js +0 -74
- package/dist/support/toolResultFormatting.js.map +0 -1
- package/dist/workspace/projectStartupScript.d.ts +0 -73
- package/dist/workspace/projectStartupScript.d.ts.map +0 -1
- package/dist/workspace/projectStartupScript.js +0 -607
- package/dist/workspace/projectStartupScript.js.map +0 -1
- package/dist/workspace/projectState.d.ts +0 -216
- package/dist/workspace/projectState.d.ts.map +0 -1
- package/dist/workspace/projectState.js +0 -172
- package/dist/workspace/projectState.js.map +0 -1
- /package/dist/{gateway/server/routing → forward}/endpointHandoffFormat.js +0 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { LauncherProcess } from "../launcher/pharoLauncherMcpClient.js";
|
|
2
|
+
import type { ImageInfo } from "../types.js";
|
|
3
|
+
import type { ImagesContext } from "./context.js";
|
|
4
|
+
import { type ImageFiles } from "./store.js";
|
|
5
|
+
/**
|
|
6
|
+
* The images in scope, or the one named, with what runs them now: one look
|
|
7
|
+
* at the store and one at the host's processes. It pings nothing and writes
|
|
8
|
+
* nothing.
|
|
9
|
+
*/
|
|
10
|
+
export declare function list(context: ImagesContext, name?: string): Promise<ImageInfo[]>;
|
|
11
|
+
export declare function describe(files: ImageFiles, processes: readonly LauncherProcess[]): ImageInfo;
|
|
12
|
+
//# sourceMappingURL=list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/images/list.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAIlD,OAAO,EAOL,KAAK,UAAU,EAChB,MAAM,YAAY,CAAC;AAEpB;;;;GAIG;AACH,wBAAsB,IAAI,CAAC,OAAO,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAQtF;AAmBD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,eAAe,EAAE,GAAG,SAAS,CAwB5F"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { storeRoot } from "../home.js";
|
|
4
|
+
import { observeEndpoint } from "./endpoint.js";
|
|
5
|
+
import { nameOfDisk } from "./names.js";
|
|
6
|
+
import { displayOf, hostProcesses, vmsOn } from "./processes.js";
|
|
7
|
+
import { existingImage, filesOfDirectory, isImage, mcpSourceOf, readFirstLine, readProperties, } from "./store.js";
|
|
8
|
+
/**
|
|
9
|
+
* The images in scope, or the one named, with what runs them now: one look
|
|
10
|
+
* at the store and one at the host's processes. It pings nothing and writes
|
|
11
|
+
* nothing.
|
|
12
|
+
*/
|
|
13
|
+
export async function list(context, name) {
|
|
14
|
+
const images = name === undefined ? imagesInScope(context) : [existingImage(context, name)];
|
|
15
|
+
if (images.length === 0) {
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
const processes = await hostProcesses(context);
|
|
19
|
+
return images.map((files) => describe(files, processes));
|
|
20
|
+
}
|
|
21
|
+
function imagesInScope(context) {
|
|
22
|
+
const store = storeRoot(context.home);
|
|
23
|
+
let entries;
|
|
24
|
+
try {
|
|
25
|
+
entries = fs.readdirSync(store, { withFileTypes: true });
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
return entries
|
|
31
|
+
.filter((entry) => entry.isDirectory())
|
|
32
|
+
.map((entry) => ({ entry, name: nameOfDisk(entry.name, context.scope) }))
|
|
33
|
+
.filter((item) => item.name !== undefined)
|
|
34
|
+
.map(({ entry, name }) => filesOfDirectory(path.join(store, entry.name), name))
|
|
35
|
+
.filter(isImage)
|
|
36
|
+
.sort((left, right) => left.name.localeCompare(right.name));
|
|
37
|
+
}
|
|
38
|
+
export function describe(files, processes) {
|
|
39
|
+
const vms = vmsOn(files.imagePath, processes);
|
|
40
|
+
const created = readProperties(files.created);
|
|
41
|
+
const template = originTemplate(files.dir) ?? created?.template;
|
|
42
|
+
const pharoVersion = readFirstLine(path.join(files.dir, "pharo.version"));
|
|
43
|
+
const mcp = mcpSourceOf(created?.mcp);
|
|
44
|
+
const everyStart = readFirstLine(files.onStart);
|
|
45
|
+
const observed = vms.length > 0 ? observeEndpoint(files, vms) : undefined;
|
|
46
|
+
return {
|
|
47
|
+
name: files.name,
|
|
48
|
+
diskName: files.diskName,
|
|
49
|
+
path: files.imagePath,
|
|
50
|
+
running: vms.length > 0,
|
|
51
|
+
pids: vms.map((vm) => vm.pid),
|
|
52
|
+
...(vms.length > 0 ? { display: displayOf(vms[0]) } : {}),
|
|
53
|
+
...(observed && "endpoint" in observed ? { endpoint: observed.endpoint } : {}),
|
|
54
|
+
...(observed && "problem" in observed ? { endpointProblem: observed.problem } : {}),
|
|
55
|
+
...(fs.existsSync(files.building) ? { building: true } : {}),
|
|
56
|
+
...(template === undefined ? {} : { template }),
|
|
57
|
+
...(pharoVersion === undefined ? {} : { pharoVersion }),
|
|
58
|
+
...(mcp === undefined ? {} : { mcp }),
|
|
59
|
+
...(everyStart === undefined ? {} : { everyStart }),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
// The launcher records the template an image came from in its metadata.
|
|
63
|
+
function originTemplate(dir) {
|
|
64
|
+
let metadata;
|
|
65
|
+
try {
|
|
66
|
+
metadata = fs.readFileSync(path.join(dir, "meta-inf.ston"), "utf8");
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
const name = /#originTemplate\s*:\s*\w+\s*\{[\s\S]*?#name\s*:\s*'((?:''|[^'])*)'/.exec(metadata)?.[1];
|
|
72
|
+
return name?.replaceAll("''", "'");
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/images/list.ts"],"names":[],"mappings":"AAAA,O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AE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC;QACrC,GAAG,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC;KACpD,CAAC;AACJ,CAAC;AAED,wEAAwE;AACxE,SAAS,cAAc,CAAC,GAAW;IACjC,IAAI,QAAgB,CAAC;IACrB,IAAI,CAAC;QACH,QAAQ,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,EAAE,MAAM,CAAC,CAAC;IACtE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,IAAI,GAAG,oEAAoE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACtG,OAAO,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** The disk names of bases being built, which share the store with images. */
|
|
2
|
+
export declare const buildPrefix = "plexus-build-";
|
|
3
|
+
/**
|
|
4
|
+
* The scope a caller gave, or nothing for none. An empty scope is refused
|
|
5
|
+
* rather than read as none, since none reaches every image in the store.
|
|
6
|
+
*/
|
|
7
|
+
export declare function checkScope(scope: unknown): string | undefined;
|
|
8
|
+
/** The directory and file base name of an image in the store. */
|
|
9
|
+
export declare function diskName(name: unknown, scope: string | undefined): string;
|
|
10
|
+
/**
|
|
11
|
+
* The name a directory of the store answers to in this scope, or nothing
|
|
12
|
+
* when it is out of scope or is not an image's.
|
|
13
|
+
*/
|
|
14
|
+
export declare function nameOfDisk(disk: string, scope: string | undefined): string | undefined;
|
|
15
|
+
//# sourceMappingURL=names.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"names.d.ts","sourceRoot":"","sources":["../../src/images/names.ts"],"names":[],"mappings":"AASA,8EAA8E;AAC9E,eAAO,MAAM,WAAW,kBAAkB,CAAC;AAY3C;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAW7D;AAED,iEAAiE;AACjE,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAUzE;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAWtF"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { PlexusError } from "../errors.js";
|
|
2
|
+
const namePattern = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
3
|
+
// The first dash of a disk name ends its scope. A scope that could hold one
|
|
4
|
+
// would make `shop-api-dev` both image `api-dev` of `shop` and image `dev` of
|
|
5
|
+
// `shop-api`, and each scope would list, stop and delete the other's.
|
|
6
|
+
const scopePattern = /^[A-Za-z0-9][A-Za-z0-9._]{0,63}$/;
|
|
7
|
+
/** The disk names of bases being built, which share the store with images. */
|
|
8
|
+
export const buildPrefix = "plexus-build-";
|
|
9
|
+
function check(value, what) {
|
|
10
|
+
if (typeof value !== "string" || !namePattern.test(value)) {
|
|
11
|
+
throw new PlexusError("invalid-name", `${what} ${JSON.stringify(value)} is not valid: use 1 to 64 letters, digits, dots, dashes or underscores, starting with a letter or a digit.`);
|
|
12
|
+
}
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The scope a caller gave, or nothing for none. An empty scope is refused
|
|
17
|
+
* rather than read as none, since none reaches every image in the store.
|
|
18
|
+
*/
|
|
19
|
+
export function checkScope(scope) {
|
|
20
|
+
if (scope === undefined) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
if (typeof scope !== "string" || !scopePattern.test(scope)) {
|
|
24
|
+
throw new PlexusError("invalid-name", `Scope ${JSON.stringify(scope)} is not valid: use 1 to 64 letters, digits, dots or underscores, starting with a letter or a digit. A dash separates the scope from the image name, so a scope holds none.`);
|
|
25
|
+
}
|
|
26
|
+
return scope;
|
|
27
|
+
}
|
|
28
|
+
/** The directory and file base name of an image in the store. */
|
|
29
|
+
export function diskName(name, scope) {
|
|
30
|
+
const checked = check(name, "Image name");
|
|
31
|
+
const disk = scope === undefined ? checked : `${scope}-${checked}`;
|
|
32
|
+
if (disk.startsWith(buildPrefix)) {
|
|
33
|
+
throw new PlexusError("invalid-name", `Image name ${JSON.stringify(checked)} is not valid: ${buildPrefix} names the bases PLexus builds.`);
|
|
34
|
+
}
|
|
35
|
+
return disk;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The name a directory of the store answers to in this scope, or nothing
|
|
39
|
+
* when it is out of scope or is not an image's.
|
|
40
|
+
*/
|
|
41
|
+
export function nameOfDisk(disk, scope) {
|
|
42
|
+
if (disk.startsWith(buildPrefix)) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
if (scope === undefined) {
|
|
46
|
+
return disk;
|
|
47
|
+
}
|
|
48
|
+
const prefix = `${scope}-`;
|
|
49
|
+
return disk.startsWith(prefix) && disk.length > prefix.length
|
|
50
|
+
? disk.slice(prefix.length)
|
|
51
|
+
: undefined;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=names.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"names.js","sourceRoot":"","sources":["../../src/images/names.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,WAAW,GAAG,mCAAmC,CAAC;AAExD,4EAA4E;AAC5E,8EAA8E;AAC9E,sEAAsE;AACtE,MAAM,YAAY,GAAG,kCAAkC,CAAC;AAExD,8EAA8E;AAC9E,MAAM,CAAC,MAAM,WAAW,GAAG,eAAe,CAAC;AAE3C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C,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QACjC,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,MAAM,GAAG,GAAG,KAAK,GAAG,CAAC;IAC3B,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM;QAC3D,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;QAC3B,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ImagesContext } from "./context.js";
|
|
2
|
+
import { type PrepareSource } from "./scripts.js";
|
|
3
|
+
import { type ImageFiles } from "./store.js";
|
|
4
|
+
/**
|
|
5
|
+
* Make an image from a template in the store, under the name the launcher
|
|
6
|
+
* knows it by. What failed, when it did.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createFromTemplate(context: ImagesContext, files: ImageFiles, template: {
|
|
9
|
+
name: string;
|
|
10
|
+
category: string;
|
|
11
|
+
}): Promise<string | undefined>;
|
|
12
|
+
/**
|
|
13
|
+
* Run the preparation in the image, which loads MCP, saves and quits. What
|
|
14
|
+
* failed, when it did: the image's own report first, since it names the
|
|
15
|
+
* Smalltalk error, then the launcher's.
|
|
16
|
+
*/
|
|
17
|
+
export declare function prepare(context: ImagesContext, files: ImageFiles, source: PrepareSource): Promise<string | undefined>;
|
|
18
|
+
//# sourceMappingURL=prepare.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepare.d.ts","sourceRoot":"","sources":["../../src/images/prepare.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAiB,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAkB,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7D;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,aAAa,EACtB,KAAK,EAAE,UAAU,EACjB,QAAQ,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAC3C,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAQ7B;AAED;;;;GAIG;AACH,wBAAsB,OAAO,CAC3B,OAAO,EAAE,aAAa,EACtB,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAoC7B"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { launcherFailureMessage, launchLogPaths, launchOutputTail, } from "../launcher/pharoLauncherMcpClient.js";
|
|
3
|
+
import { prepareScript } from "./scripts.js";
|
|
4
|
+
import { readProperties } from "./store.js";
|
|
5
|
+
/**
|
|
6
|
+
* Make an image from a template in the store, under the name the launcher
|
|
7
|
+
* knows it by. What failed, when it did.
|
|
8
|
+
*/
|
|
9
|
+
export async function createFromTemplate(context, files, template) {
|
|
10
|
+
const result = await context.launcher().createImage({
|
|
11
|
+
templateName: template.name,
|
|
12
|
+
templateCategory: template.category,
|
|
13
|
+
newImageName: files.diskName,
|
|
14
|
+
noLaunch: true,
|
|
15
|
+
});
|
|
16
|
+
return result.ok ? undefined : launcherFailureMessage("createImage", result);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Run the preparation in the image, which loads MCP, saves and quits. What
|
|
20
|
+
* failed, when it did: the image's own report first, since it names the
|
|
21
|
+
* Smalltalk error, then the launcher's.
|
|
22
|
+
*/
|
|
23
|
+
export async function prepare(context, files, source) {
|
|
24
|
+
fs.mkdirSync(files.plexusDir, { recursive: true });
|
|
25
|
+
fs.rmSync(files.prepareStatus, { force: true });
|
|
26
|
+
fs.writeFileSync(files.prepareScript, prepareScript(source), "utf8");
|
|
27
|
+
const result = await context.launcher().startImage({
|
|
28
|
+
imageName: files.diskName,
|
|
29
|
+
script: files.prepareScript,
|
|
30
|
+
detached: false,
|
|
31
|
+
displayMode: "headless",
|
|
32
|
+
// The VM's output and the launcher's report of which VM it ran: a VM that
|
|
33
|
+
// cannot run an image says there how to renew it.
|
|
34
|
+
includeRaw: true,
|
|
35
|
+
});
|
|
36
|
+
const status = readProperties(files.prepareStatus);
|
|
37
|
+
if (result.ok && status?.status === "ok") {
|
|
38
|
+
fs.rmSync(files.prepareScript, { force: true });
|
|
39
|
+
fs.rmSync(files.prepareStatus, { force: true });
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
const reasons = [
|
|
43
|
+
status?.status === "failed"
|
|
44
|
+
? `Loading MCP failed: ${status.message || "the image gave no message"}`
|
|
45
|
+
: undefined,
|
|
46
|
+
result.ok ? undefined : launcherFailureMessage("startImage", result),
|
|
47
|
+
].filter((reason) => reason !== undefined);
|
|
48
|
+
const logs = launchLogPaths(result);
|
|
49
|
+
return [
|
|
50
|
+
// A launch that failed says how in its own message. One that ended well
|
|
51
|
+
// without a status leaves only what the VM printed to say why.
|
|
52
|
+
...(reasons.length > 0
|
|
53
|
+
? reasons
|
|
54
|
+
: ["The preparation ended without saying whether MCP loaded.", ...launchOutputTail(result)]),
|
|
55
|
+
...(logs.length > 0 ? [`Launcher logs: ${logs.join(", ")}`] : []),
|
|
56
|
+
].join("\n");
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=prepare.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepare.js","sourceRoot":"","sources":["../../src/images/prepare.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EACL,sBAAsB,EACtB,cAAc,EACd,gBAAgB,GACjB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAsB,MAAM,cAAc,CAA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IAAI,MAAM,CAAC,EAAE,IAAI,MAAM,EAAE,MAAM,KAAK,IAAI,EAAE,CAAC;QACzC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAChD,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAChD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,OAAO,GAAG;QACd,MAAM,EAAE,MAAM,KAAK,QAAQ;YACzB,CAAC,CAAC,uBAAuB,MAAM,CAAC,OAAO,IAAI,2BAA2B,EAAE;YACxE,CAAC,CAAC,SAAS;QACb,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,sBAAsB,CAAC,YAAY,EAAE,MAAM,CAAC;KACrE,CAAC,MAAM,CAAC,CAAC,MAAM,EAAoB,EAAE,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC;IAC7D,MAAM,IAAI,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IACpC,OAAO;QACL,wEAAwE;QACxE,+DAA+D;QAC/D,GAAG,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;YACpB,CAAC,CAAC,OAAO;YACT,CAAC,CAAC,CAAC,0DAA0D,EAAE,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;QAC9F,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,kBAAkB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KAClE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type LauncherProcess } from "../launcher/pharoLauncherMcpClient.js";
|
|
2
|
+
import type { Display } from "../types.js";
|
|
3
|
+
import type { ImagesContext } from "./context.js";
|
|
4
|
+
export declare function hostProcesses(context: ImagesContext): Promise<LauncherProcess[]>;
|
|
5
|
+
/**
|
|
6
|
+
* The VMs running this image file. Matched on the real path, never on a
|
|
7
|
+
* basename or a substring: those took `plugin-mcp-eval` for `mcp-eval`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function vmsOn(imagePath: string, processes: readonly LauncherProcess[]): LauncherProcess[];
|
|
10
|
+
export declare function displayOf(process: LauncherProcess): Display;
|
|
11
|
+
export interface KillFailure {
|
|
12
|
+
pid: number;
|
|
13
|
+
reason: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Kill each VM, and say which kills failed and why. A kill that fails on a VM
|
|
17
|
+
* that is gone meanwhile did what it was asked.
|
|
18
|
+
*/
|
|
19
|
+
export declare function killVms(context: ImagesContext, pids: readonly number[]): Promise<KillFailure[]>;
|
|
20
|
+
export declare function killFailureLines(failures: readonly KillFailure[]): string[];
|
|
21
|
+
//# sourceMappingURL=processes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processes.d.ts","sourceRoot":"","sources":["../../src/images/processes.ts"],"names":[],"mappings":"AAOA,OAAO,EAEL,KAAK,eAAe,EACrB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGlD,wBAAsB,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAStF;AAED;;;GAGG;AACH,wBAAgB,KAAK,CACnB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,SAAS,eAAe,EAAE,GACpC,eAAe,EAAE,CAMnB;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAI3D;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAsB,OAAO,CAC3B,OAAO,EAAE,aAAa,EACtB,IAAI,EAAE,SAAS,MAAM,EAAE,GACtB,OAAO,CAAC,WAAW,EAAE,CAAC,CAexB;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,SAAS,WAAW,EAAE,GAAG,MAAM,EAAE,CAE3E"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A running image is a process whose command line names its image file. The
|
|
3
|
+
* host's process list, asked once per call, is the only source.
|
|
4
|
+
*/
|
|
5
|
+
import fs from "node:fs";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { PlexusError } from "../errors.js";
|
|
8
|
+
import { launcherFailureMessage, } from "../launcher/pharoLauncherMcpClient.js";
|
|
9
|
+
import { isPidAlive } from "./store.js";
|
|
10
|
+
export async function hostProcesses(context) {
|
|
11
|
+
const result = await context.launcher().listProcesses();
|
|
12
|
+
if (!result.ok) {
|
|
13
|
+
throw new PlexusError("launcher-failed", launcherFailureMessage("listProcesses", result));
|
|
14
|
+
}
|
|
15
|
+
return result.data ?? [];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The VMs running this image file. Matched on the real path, never on a
|
|
19
|
+
* basename or a substring: those took `plugin-mcp-eval` for `mcp-eval`.
|
|
20
|
+
*/
|
|
21
|
+
export function vmsOn(imagePath, processes) {
|
|
22
|
+
const image = realPath(imagePath);
|
|
23
|
+
return processes.filter((process) => {
|
|
24
|
+
const candidate = imagePathOf(process);
|
|
25
|
+
return candidate !== undefined && samePath(realPath(candidate), image);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
export function displayOf(process) {
|
|
29
|
+
return /(^|\s|")--headless(\s|"|$)/.test(process.commandLine)
|
|
30
|
+
? "headless"
|
|
31
|
+
: "interactive";
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Kill each VM, and say which kills failed and why. A kill that fails on a VM
|
|
35
|
+
* that is gone meanwhile did what it was asked.
|
|
36
|
+
*/
|
|
37
|
+
export async function killVms(context, pids) {
|
|
38
|
+
const failures = [];
|
|
39
|
+
for (const pid of pids) {
|
|
40
|
+
let reason;
|
|
41
|
+
try {
|
|
42
|
+
const result = await context.launcher().killProcess({ pid });
|
|
43
|
+
reason = result.ok ? undefined : launcherFailureMessage("killProcess", result);
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
reason = error instanceof Error ? error.message : String(error);
|
|
47
|
+
}
|
|
48
|
+
if (reason !== undefined && isPidAlive(pid)) {
|
|
49
|
+
failures.push({ pid, reason });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return failures;
|
|
53
|
+
}
|
|
54
|
+
export function killFailureLines(failures) {
|
|
55
|
+
return failures.map(({ pid, reason }) => `Killing pid ${pid} failed: ${reason}`);
|
|
56
|
+
}
|
|
57
|
+
// A relative path names a file only from the VM's working directory, which
|
|
58
|
+
// the process list does not say.
|
|
59
|
+
function imagePathOf(process) {
|
|
60
|
+
const candidate = process.imagePath ?? imageArgument(process.commandLine);
|
|
61
|
+
return candidate !== undefined && path.isAbsolute(candidate) ? candidate : undefined;
|
|
62
|
+
}
|
|
63
|
+
function imageArgument(commandLine) {
|
|
64
|
+
const quoted = [...commandLine.matchAll(/"([^"]+)"|'([^']+)'/g)]
|
|
65
|
+
.map((match) => match[1] ?? match[2])
|
|
66
|
+
.find((value) => value.toLowerCase().endsWith(".image"));
|
|
67
|
+
return (quoted ??
|
|
68
|
+
commandLine.split(/\s+/).find((token) => token.toLowerCase().endsWith(".image")));
|
|
69
|
+
}
|
|
70
|
+
function realPath(file) {
|
|
71
|
+
try {
|
|
72
|
+
return fs.realpathSync.native(file);
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
return path.resolve(file);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function samePath(left, right) {
|
|
79
|
+
return process.platform === "win32"
|
|
80
|
+
? left.toLowerCase() === right.toLowerCase()
|
|
81
|
+
: left === right;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=processes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processes.js","sourceRoot":"","sources":["../../src/images/processes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EACL,sBAAsB,GAEvB,MAAM,uCAAuC,CAAC;AAG/C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAAsB;IACxD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,QAAQ,EAAE,CAAC,aAAa,EAAE,CAAC;IACxD,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;QACf,MAAM,IAAI,WAAW,CACnB,iBAAiB,EACjB,sBAAsB,CAAC,eAAe,EAAE,MAAM,CAAC,CAChD,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;AAC3B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,KAAK,CACnB,SAAiB,EACjB,SAAqC;IAErC,MAAM,KAAK,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;IAClC,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE;QAClC,MAAM,SAAS,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;QACvC,OAAO,SAAS,KAAK,SAAS,IAAI,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,CAAC;IACzE,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,OAAwB;IAChD,OAAO,4BAA4B,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,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+
*/
|
|
5
|
+
/** Where the pinned MCP comes from: the release's tag of Evref-BL/MCP. */
|
|
6
|
+
export declare function pharoMcpRepository(version: string): {
|
|
7
|
+
readonly githubUser: "Evref-BL";
|
|
8
|
+
readonly project: "MCP";
|
|
9
|
+
readonly commitish: `v${string}`;
|
|
10
|
+
readonly path: "src";
|
|
11
|
+
readonly baseline: "MCP";
|
|
12
|
+
};
|
|
13
|
+
export type PrepareSource = {
|
|
14
|
+
kind: "pin";
|
|
15
|
+
version: string;
|
|
16
|
+
} | {
|
|
17
|
+
kind: "script";
|
|
18
|
+
script: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Get MCP into a fresh image, save it and quit. The pinned release is loaded
|
|
22
|
+
* with the Metacello expression PLexus has always used; a script is filed in
|
|
23
|
+
* instead.
|
|
24
|
+
*
|
|
25
|
+
* A pinned load forgets the Iceberg repositories it registered: their
|
|
26
|
+
* locations name the build directory, which a base is renamed away from. A
|
|
27
|
+
* script's are kept, since its image is built where it stays.
|
|
28
|
+
*/
|
|
29
|
+
export declare function prepareScript(source: PrepareSource): string;
|
|
30
|
+
/**
|
|
31
|
+
* Start this image's MCP server and say where it listens. The same text for
|
|
32
|
+
* every image: everything it needs it finds from the image's own directory.
|
|
33
|
+
*
|
|
34
|
+
* Port 0 asks the system for a free port; the file names the port bound and
|
|
35
|
+
* the pid that bound it, written under another name and renamed so that a
|
|
36
|
+
* reader never sees half of it. It never saves the image.
|
|
37
|
+
*/
|
|
38
|
+
export declare const startScript: string;
|
|
39
|
+
//# sourceMappingURL=scripts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scripts.d.ts","sourceRoot":"","sources":["../../src/images/scripts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,0EAA0E;AAC1E,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM;;;;;;EAQjD;AAED,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAChC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAuBvC;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CA0C3D;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,QAsCvB,CAAC"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The two Smalltalk scripts PLexus runs in an image. Both must run on Pharo
|
|
3
|
+
* 10 to 15.
|
|
4
|
+
*/
|
|
5
|
+
/** Where the pinned MCP comes from: the release's tag of Evref-BL/MCP. */
|
|
6
|
+
export function pharoMcpRepository(version) {
|
|
7
|
+
return {
|
|
8
|
+
githubUser: "Evref-BL",
|
|
9
|
+
project: "MCP",
|
|
10
|
+
commitish: `v${version}`,
|
|
11
|
+
path: "src",
|
|
12
|
+
baseline: "MCP",
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function smalltalkString(value) {
|
|
16
|
+
return `'${value.replaceAll("'", "''")}'`;
|
|
17
|
+
}
|
|
18
|
+
function smalltalkPath(value) {
|
|
19
|
+
return smalltalkString(value.replace(/\\/g, "/"));
|
|
20
|
+
}
|
|
21
|
+
// A properties value is one line.
|
|
22
|
+
const errorText = "((error description copyReplaceAll: String cr with: ' ') copyReplaceAll: String lf with: ' ')";
|
|
23
|
+
function failureWriter(file, indent) {
|
|
24
|
+
return [
|
|
25
|
+
`${indent}${file} ensureDelete.`,
|
|
26
|
+
`${indent}${file} writeStreamDo: [ :stream |`,
|
|
27
|
+
`${indent} stream nextPutAll: 'status=failed'; cr;`,
|
|
28
|
+
`${indent} nextPutAll: 'message='; nextPutAll: ${errorText}; cr ].`,
|
|
29
|
+
].join("\n");
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Get MCP into a fresh image, save it and quit. The pinned release is loaded
|
|
33
|
+
* with the Metacello expression PLexus has always used; a script is filed in
|
|
34
|
+
* instead.
|
|
35
|
+
*
|
|
36
|
+
* A pinned load forgets the Iceberg repositories it registered: their
|
|
37
|
+
* locations name the build directory, which a base is renamed away from. A
|
|
38
|
+
* script's are kept, since its image is built where it stays.
|
|
39
|
+
*/
|
|
40
|
+
export function prepareScript(source) {
|
|
41
|
+
const load = source.kind === "pin"
|
|
42
|
+
? (() => {
|
|
43
|
+
const repository = pharoMcpRepository(source.version);
|
|
44
|
+
return [
|
|
45
|
+
` Metacello new`,
|
|
46
|
+
` githubUser: ${smalltalkString(repository.githubUser)} project: ${smalltalkString(repository.project)} commitish: ${smalltalkString(repository.commitish)} path: ${smalltalkString(repository.path)};`,
|
|
47
|
+
` baseline: ${smalltalkString(repository.baseline)};`,
|
|
48
|
+
` load.`,
|
|
49
|
+
].join("\n");
|
|
50
|
+
})()
|
|
51
|
+
: ` ${smalltalkPath(source.script)} asFileReference fileIn.`;
|
|
52
|
+
const forget = source.kind === "pin"
|
|
53
|
+
? [
|
|
54
|
+
` (Smalltalk globals at: #IceRepository ifAbsent: [ nil ]) ifNotNil: [ :class |`,
|
|
55
|
+
` (class registry reject: [ :each | repositoriesBefore includes: each ])`,
|
|
56
|
+
` do: [ :each | class registry remove: each ifAbsent: [ ] ] ].`,
|
|
57
|
+
].join("\n")
|
|
58
|
+
: "";
|
|
59
|
+
return `"Written by PLexus to prepare this image. Do not edit."
|
|
60
|
+
| dir status repositoriesBefore |
|
|
61
|
+
dir := FileLocator imageDirectory asFileReference / 'plexus'.
|
|
62
|
+
dir ensureCreateDirectory.
|
|
63
|
+
status := dir / 'prepare-status.properties'.
|
|
64
|
+
[
|
|
65
|
+
repositoriesBefore := (Smalltalk globals at: #IceRepository ifAbsent: [ nil ])
|
|
66
|
+
ifNil: [ #() ] ifNotNil: [ :class | class registry copy ].
|
|
67
|
+
${load}
|
|
68
|
+
(Smalltalk globals includesKey: #MCP)
|
|
69
|
+
ifFalse: [ Error signal: 'MCP is not in the image after loading.' ].
|
|
70
|
+
${forget}
|
|
71
|
+
status ensureDelete.
|
|
72
|
+
status writeStreamDo: [ :stream | stream nextPutAll: 'status=ok'; cr ].
|
|
73
|
+
Smalltalk snapshot: true andQuit: true ]
|
|
74
|
+
on: Error
|
|
75
|
+
do: [ :error |
|
|
76
|
+
${failureWriter("status", " ")}
|
|
77
|
+
Smalltalk exitFailure ]
|
|
78
|
+
`;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Start this image's MCP server and say where it listens. The same text for
|
|
82
|
+
* every image: everything it needs it finds from the image's own directory.
|
|
83
|
+
*
|
|
84
|
+
* Port 0 asks the system for a free port; the file names the port bound and
|
|
85
|
+
* the pid that bound it, written under another name and renamed so that a
|
|
86
|
+
* reader never sees half of it. It never saves the image.
|
|
87
|
+
*/
|
|
88
|
+
export const startScript = `"Written by PLexus to start this image's MCP server. Do not edit."
|
|
89
|
+
| dir status mcp port pid endpoint temporary |
|
|
90
|
+
dir := FileLocator imageDirectory asFileReference / 'plexus'.
|
|
91
|
+
status := dir / 'start-status.properties'.
|
|
92
|
+
[
|
|
93
|
+
(dir / 'on-start') exists ifTrue: [
|
|
94
|
+
(dir / 'on-start') contents lines
|
|
95
|
+
detect: [ :line | line trimBoth notEmpty ]
|
|
96
|
+
ifFound: [ :line | line trimBoth asFileReference fileIn ] ].
|
|
97
|
+
(Smalltalk globals includesKey: #MCP)
|
|
98
|
+
ifFalse: [ Error signal: 'MCP is not in the image.' ].
|
|
99
|
+
(Smalltalk globals at: #PLexusMCPServer ifAbsent: [ nil ])
|
|
100
|
+
ifNotNil: [ :previous | [ previous stop ] on: Error do: [ :error | nil ] ].
|
|
101
|
+
pid := [ (Smalltalk globals at: #LibC) uniqueInstance getpid ]
|
|
102
|
+
on: Error do: [ :error | nil ].
|
|
103
|
+
mcp := (Smalltalk globals at: #MCP) new.
|
|
104
|
+
mcp port: 0.
|
|
105
|
+
mcp start.
|
|
106
|
+
port := mcp port.
|
|
107
|
+
(port isInteger and: [ port > 0 ])
|
|
108
|
+
ifFalse: [ Error signal: 'MCP did not report a bound port after starting.' ].
|
|
109
|
+
Smalltalk globals at: #PLexusMCPServer put: mcp.
|
|
110
|
+
endpoint := dir / 'endpoint.properties'.
|
|
111
|
+
temporary := dir / 'endpoint.properties.tmp'.
|
|
112
|
+
temporary ensureDelete.
|
|
113
|
+
temporary writeStreamDo: [ :stream |
|
|
114
|
+
stream nextPutAll: 'transport=http'; cr.
|
|
115
|
+
stream nextPutAll: 'host=127.0.0.1'; cr.
|
|
116
|
+
stream nextPutAll: 'port='; nextPutAll: port asString; cr.
|
|
117
|
+
stream nextPutAll: 'path=/'; cr.
|
|
118
|
+
pid ifNotNil: [ :value | stream nextPutAll: 'pid='; nextPutAll: value asString; cr ] ].
|
|
119
|
+
endpoint ensureDelete.
|
|
120
|
+
temporary renameTo: endpoint basename ]
|
|
121
|
+
on: Error
|
|
122
|
+
do: [ :error |
|
|
123
|
+
${failureWriter("status", " ")}
|
|
124
|
+
Smalltalk exitFailure ].
|
|
125
|
+
Semaphore new wait.
|
|
126
|
+
`;
|
|
127
|
+
//# sourceMappingURL=scripts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scripts.js","sourceRoot":"","sources":["../../src/images/scripts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,0EAA0E;AAC1E,MAAM,UAAU,kBAAkB,CAAC,OAAe;IAChD,OAAO;QACL,UAAU,EAAE,UAAU;QACtB,OAAO,EAAE,KAAK;QACd,SAAS,EAAE,IAAI,OAAO,EAAE;QACxB,IAAI,EAAE,KAAK;QACX,QAAQ,EAAE,KAAK;KACP,CAAC;AACb,CAAC;AAMD,SAAS,eAAe,CAAC,KAAa;IACpC,OAAO,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC;AAC5C,CAAC;AAED,SAAS,aAAa,CAAC,KAAa;IAClC,OAAO,eAAe,CAAC,KAAK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;;EAMN,aAAa,CAAC,QAAQ,EAAE,QAAQ,CAAC;;CAElC,CAAC;AACF,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmCzB,aAAa,CAAC,QAAQ,EAAE,QAAQ,CAAC;;;CAGlC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { PlexusError } from "../errors.js";
|
|
2
|
+
import type { Display, Endpoint, StartOptions } from "../types.js";
|
|
3
|
+
import { type ClaimHolder, type ClaimState } from "./claims.js";
|
|
4
|
+
import type { ImagesContext } from "./context.js";
|
|
5
|
+
import { type ImageFiles } from "./store.js";
|
|
6
|
+
export declare const defaultStartTimeoutMs = 300000;
|
|
7
|
+
export interface StartResult {
|
|
8
|
+
name: string;
|
|
9
|
+
pids: number[];
|
|
10
|
+
endpoint: Endpoint;
|
|
11
|
+
display: Display;
|
|
12
|
+
seconds: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Launch the image with the start script and wait until its MCP server
|
|
16
|
+
* answers, or fail as soon as the VM reports a failure or exits. Nothing is
|
|
17
|
+
* recorded: the next look at the host is what says it runs.
|
|
18
|
+
*/
|
|
19
|
+
export declare function start(context: ImagesContext, name: string, options?: StartOptions): Promise<StartResult>;
|
|
20
|
+
/** Whether a start holds this image's launch lock now. */
|
|
21
|
+
export declare function launchLockState(context: ImagesContext, files: ImageFiles): ClaimState;
|
|
22
|
+
export declare function beingStarted(files: ImageFiles, holder: ClaimHolder | undefined): PlexusError;
|
|
23
|
+
//# sourceMappingURL=start.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/images/start.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAQ3C,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAwB,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AACtF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAKlD,OAAO,EAML,KAAK,UAAU,EAChB,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,qBAAqB,SAAU,CAAC;AAE7C,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAsB,KAAK,CACzB,OAAO,EAAE,aAAa,EACtB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC,WAAW,CAAC,CAgFtB;AAsGD,0DAA0D;AAC1D,wBAAgB,eAAe,CAAC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,GAAG,UAAU,CAErF;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,WAAW,CAM5F"}
|