@evref-bl/plexus 0.15.2 → 0.17.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/answers/index.d.ts +97 -0
- package/dist/answers/index.d.ts.map +1 -0
- package/dist/answers/index.js +352 -0
- package/dist/answers/index.js.map +1 -0
- package/dist/answers/texts.d.ts +83 -0
- package/dist/answers/texts.d.ts.map +1 -0
- package/dist/answers/texts.js +216 -0
- package/dist/answers/texts.js.map +1 -0
- package/dist/cli.js +21 -182
- 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 +259 -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 +61 -0
- package/dist/forward/index.d.ts.map +1 -0
- package/dist/forward/index.js +133 -0
- package/dist/forward/index.js.map +1 -0
- package/dist/forward/jsonRpc.d.ts +58 -0
- package/dist/forward/jsonRpc.d.ts.map +1 -0
- package/dist/forward/jsonRpc.js +259 -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 +41 -0
- package/dist/images/bases.d.ts.map +1 -0
- package/dist/images/bases.js +194 -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 +37 -0
- package/dist/images/context.d.ts.map +1 -0
- package/dist/images/context.js +40 -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 +122 -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 +32 -0
- package/dist/images/delete.js.map +1 -0
- package/dist/images/endpoint.d.ts +29 -0
- package/dist/images/endpoint.d.ts.map +1 -0
- package/dist/images/endpoint.js +86 -0
- package/dist/images/endpoint.js.map +1 -0
- package/dist/images/index.d.ts +32 -0
- package/dist/images/index.d.ts.map +1 -0
- package/dist/images/index.js +56 -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 +48 -0
- package/dist/images/scripts.d.ts.map +1 -0
- package/dist/images/scripts.js +149 -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 +179 -0
- package/dist/images/start.js.map +1 -0
- package/dist/images/stop.d.ts +17 -0
- package/dist/images/stop.d.ts.map +1 -0
- package/dist/images/stop.js +171 -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 +181 -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 +85 -0
- package/dist/images/templates.js.map +1 -0
- package/dist/index.d.ts +16 -22
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -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 +121 -98
- package/dist/launcher/pharoLauncherMcpClient.js.map +1 -1
- package/dist/launcher/pharoLauncherProfile.d.ts +5 -32
- package/dist/launcher/pharoLauncherProfile.d.ts.map +1 -1
- package/dist/launcher/pharoLauncherProfile.js +17 -115
- package/dist/launcher/pharoLauncherProfile.js.map +1 -1
- package/dist/mcp/server.d.ts +27 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +269 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/telemetry/reachability.d.ts +59 -0
- package/dist/telemetry/reachability.d.ts.map +1 -0
- package/dist/telemetry/reachability.js +183 -0
- package/dist/telemetry/reachability.js.map +1 -0
- package/dist/telemetry/sdk.d.ts +54 -0
- package/dist/telemetry/sdk.d.ts.map +1 -0
- package/dist/telemetry/sdk.js +167 -0
- package/dist/telemetry/sdk.js.map +1 -0
- package/dist/telemetry/settings.d.ts +16 -0
- package/dist/telemetry/settings.d.ts.map +1 -0
- package/dist/telemetry/settings.js +67 -0
- package/dist/telemetry/settings.js.map +1 -0
- package/dist/telemetry/trace.d.ts +32 -0
- package/dist/telemetry/trace.d.ts.map +1 -0
- package/dist/telemetry/trace.js +79 -0
- package/dist/telemetry/trace.js.map +1 -0
- package/dist/types.d.ts +82 -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 +15 -15
- 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 -1031
- 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 -1054
- 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
|
@@ -1,125 +1,148 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* How PLexus reaches the launcher
|
|
3
|
-
*
|
|
4
|
-
* It used to spawn `pharo-launcher-mcp` and send tool names over stdio. The
|
|
5
|
-
* package answers those names as functions now, so the call is a call: no
|
|
6
|
-
* process, no handshake, and no object stringified into a text block for the
|
|
7
|
-
* other side to parse back. Asking the host what it is running went from
|
|
8
|
-
* 175ms to the 46ms the question itself costs.
|
|
9
|
-
*
|
|
10
|
-
* The names stay because PLexus uses them: an operation that needs approval is
|
|
11
|
-
* described before it is performed, and what it names is a tool.
|
|
2
|
+
* How PLexus reaches the launcher: pharo-launcher-mcp's functions, called in
|
|
3
|
+
* this process on PLexus's one profile.
|
|
12
4
|
*/
|
|
5
|
+
import fs from "node:fs";
|
|
13
6
|
import { openPharoLauncher, } from "@evref-bl/pharo-launcher-mcp/launcher";
|
|
7
|
+
import { homeProfileEnvironment } from "./pharoLauncherProfile.js";
|
|
14
8
|
import { vmRenewalHint } from "./vmRenewal.js";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
9
|
+
// The launcher gives a command 30 s. Downloading a template, or a launch that
|
|
10
|
+
// waits while an image loads MCP and saves, takes minutes.
|
|
11
|
+
export const longCommandTimeoutMs = 60 * 60_000;
|
|
12
|
+
export function openLauncherPort(home) {
|
|
13
|
+
const env = homeProfileEnvironment(home);
|
|
14
|
+
let quick;
|
|
15
|
+
let long;
|
|
16
|
+
const quickLauncher = () => (quick ??= openPharoLauncher({ env }));
|
|
17
|
+
const longLauncher = () => (long ??= openPharoLauncher({ env, timeoutMs: longCommandTimeoutMs }));
|
|
18
|
+
return {
|
|
19
|
+
createImage: (input) => longLauncher().createImage(input),
|
|
20
|
+
startImage: (input) => (input.detached ? quickLauncher() : longLauncher()).startImage(input),
|
|
21
|
+
listProcesses: (input) => quickLauncher().listProcesses(input),
|
|
22
|
+
killProcess: (input) => quickLauncher().killProcess(input),
|
|
23
|
+
listTemplateCategories: (input) => quickLauncher().listTemplateCategories(input),
|
|
24
|
+
listTemplates: (input) => quickLauncher().listTemplates(input),
|
|
25
|
+
updateTemplates: (input) => quickLauncher().updateTemplates(input),
|
|
26
|
+
};
|
|
24
27
|
}
|
|
25
|
-
const
|
|
26
|
-
function
|
|
27
|
-
if (!payload
|
|
28
|
+
const failureDetailLength = 500;
|
|
29
|
+
function detailField(payload, key) {
|
|
30
|
+
if (!isRecord(payload)) {
|
|
28
31
|
return undefined;
|
|
29
32
|
}
|
|
30
33
|
const value = payload[key];
|
|
31
|
-
if (typeof value !== "string") {
|
|
34
|
+
if (typeof value !== "string" || !value.trim()) {
|
|
32
35
|
return undefined;
|
|
33
36
|
}
|
|
34
37
|
const detail = value.trim();
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
return detail.length > launcherFailureDetailLength
|
|
39
|
-
? `${detail.slice(0, launcherFailureDetailLength)}…`
|
|
38
|
+
return detail.length > failureDetailLength
|
|
39
|
+
? `${detail.slice(0, failureDetailLength)}…`
|
|
40
40
|
: detail;
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
failureDetailField(payload, "action"),
|
|
51
|
-
]
|
|
42
|
+
/**
|
|
43
|
+
* What the launcher said went wrong, trimmed: a diagnostic built from
|
|
44
|
+
* launcher output can run to pages. A launch whose VM stopped with its own
|
|
45
|
+
* fatal-error report also says how to renew that VM.
|
|
46
|
+
*/
|
|
47
|
+
export function launcherFailureMessage(operation, payload) {
|
|
48
|
+
const detail = detailField(payload, "message") ??
|
|
49
|
+
[detailField(payload, "diagnostic"), detailField(payload, "action")]
|
|
52
50
|
.filter(Boolean)
|
|
53
51
|
.join(" ");
|
|
54
52
|
const message = detail
|
|
55
|
-
? `
|
|
56
|
-
: `
|
|
57
|
-
const renewal =
|
|
53
|
+
? `Pharo Launcher ${operation} failed: ${detail}`
|
|
54
|
+
: `Pharo Launcher ${operation} failed`;
|
|
55
|
+
const renewal = operation === "startImage" ? waitedLaunchRenewalHint(payload) : undefined;
|
|
58
56
|
return renewal ? `${message}\n${renewal}` : message;
|
|
59
57
|
}
|
|
60
|
-
// A launch that waited for its VM has the VM's output in the
|
|
61
|
-
//
|
|
62
|
-
function
|
|
63
|
-
if (
|
|
64
|
-
return undefined;
|
|
65
|
-
}
|
|
66
|
-
const raw = payload.raw;
|
|
67
|
-
if (!raw || typeof raw !== "object") {
|
|
58
|
+
// A launch that waited for its VM has the VM's output in the raw result,
|
|
59
|
+
// after the launcher's own report of which VM it ran.
|
|
60
|
+
function waitedLaunchRenewalHint(payload) {
|
|
61
|
+
if (!isRecord(payload) || !isRecord(payload.raw)) {
|
|
68
62
|
return undefined;
|
|
69
63
|
}
|
|
70
|
-
const { stdout, stderr } = raw;
|
|
64
|
+
const { stdout, stderr } = payload.raw;
|
|
71
65
|
const report = typeof stdout === "string" ? stdout : "";
|
|
72
|
-
|
|
73
|
-
|
|
66
|
+
return vmRenewalHint(`${report}\n${typeof stderr === "string" ? stderr : ""}`, report);
|
|
67
|
+
}
|
|
68
|
+
/** The launcher's report of a launch: which VM, which pid, which logs. */
|
|
69
|
+
export function launchReport(result) {
|
|
70
|
+
if (!isRecord(result)) {
|
|
71
|
+
return "";
|
|
72
|
+
}
|
|
73
|
+
if (isRecord(result.raw) && typeof result.raw.stdout === "string") {
|
|
74
|
+
return result.raw.stdout;
|
|
75
|
+
}
|
|
76
|
+
return isRecord(result.data) && typeof result.data.message === "string"
|
|
77
|
+
? result.data.message
|
|
78
|
+
: "";
|
|
79
|
+
}
|
|
80
|
+
/** The VM a detached launch started, as the launcher reports its pid. */
|
|
81
|
+
export function launchedPid(result) {
|
|
82
|
+
const pid = /^Detached profile-scoped Pharo image pid (\d+)\./m.exec(launchReport(result))?.[1];
|
|
83
|
+
return pid === undefined ? undefined : Number(pid);
|
|
74
84
|
}
|
|
75
85
|
/**
|
|
76
|
-
* The
|
|
77
|
-
*
|
|
78
|
-
* The launcher's own test keeps its thirteen tools and thirteen functions
|
|
79
|
-
* level with each other. This table is the third list, and it is here rather
|
|
80
|
-
* than there because the names are PLexus's vocabulary: they appear in the
|
|
81
|
-
* plans it shows for approval and in what it reports when one fails.
|
|
86
|
+
* The end of what a waited launch's VM wrote, where it says why it stopped:
|
|
87
|
+
* its errors first, then its output, each trimmed like a diagnostic.
|
|
82
88
|
*/
|
|
83
|
-
export
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
typeof result === "object" &&
|
|
102
|
-
result.ok === false);
|
|
89
|
+
export function launchOutputTail(result) {
|
|
90
|
+
if (!isRecord(result) || !isRecord(result.raw)) {
|
|
91
|
+
return [];
|
|
92
|
+
}
|
|
93
|
+
const streams = [
|
|
94
|
+
["Its error output ends with:", result.raw.stderr],
|
|
95
|
+
["Its output ends with:", result.raw.stdout],
|
|
96
|
+
];
|
|
97
|
+
return streams.flatMap(([label, text]) => {
|
|
98
|
+
const trimmed = typeof text === "string" ? text.trim() : "";
|
|
99
|
+
if (!trimmed) {
|
|
100
|
+
return [];
|
|
101
|
+
}
|
|
102
|
+
const tail = trimmed.length > failureDetailLength
|
|
103
|
+
? `…${trimmed.slice(-failureDetailLength)}`
|
|
104
|
+
: trimmed;
|
|
105
|
+
return [`${label}\n${tail}`];
|
|
106
|
+
});
|
|
103
107
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
108
|
+
/** The log files a detached launch writes the VM's output to. */
|
|
109
|
+
export function launchLogPaths(result) {
|
|
110
|
+
const paths = launchReport(result)
|
|
111
|
+
.split(/\r?\n/)
|
|
112
|
+
.map((line) => /^(?:stdout|stderr):\s*(\S.*)$/.exec(line.trim())?.[1])
|
|
113
|
+
.filter((value) => value !== undefined);
|
|
114
|
+
return [...new Set(paths)];
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* What a detached launch's logs say about a VM that stopped: the renewal hint
|
|
118
|
+
* when it stopped with its own fatal-error report, or nothing.
|
|
119
|
+
*/
|
|
120
|
+
export function exitedLaunchHint(result, logPaths) {
|
|
121
|
+
const report = launchReport(result);
|
|
122
|
+
return report ? vmRenewalHint(logPaths.map(logTail).join("\n"), report) : undefined;
|
|
123
|
+
}
|
|
124
|
+
// The end of a log, where a VM that stopped wrote why. A log that is gone says
|
|
125
|
+
// nothing.
|
|
126
|
+
function logTail(logPath) {
|
|
127
|
+
const tailLength = 64 * 1024;
|
|
128
|
+
try {
|
|
129
|
+
const size = fs.statSync(logPath).size;
|
|
130
|
+
const descriptor = fs.openSync(logPath, "r");
|
|
131
|
+
try {
|
|
132
|
+
const length = Math.min(size, tailLength);
|
|
133
|
+
const buffer = Buffer.alloc(length);
|
|
134
|
+
fs.readSync(descriptor, buffer, 0, length, size - length);
|
|
135
|
+
return buffer.toString("utf8");
|
|
136
|
+
}
|
|
137
|
+
finally {
|
|
138
|
+
fs.closeSync(descriptor);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
return "";
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function isRecord(value) {
|
|
146
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
124
147
|
}
|
|
125
148
|
//# sourceMappingURL=pharoLauncherMcpClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pharoLauncherMcpClient.js","sourceRoot":"","sources":["../../src/launcher/pharoLauncherMcpClient.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"pharoLauncherMcpClient.js","sourceRoot":"","sources":["../../src/launcher/pharoLauncherMcpClient.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EACL,iBAAiB,GAElB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MA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IACZ,CAAC;AACH,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -1,35 +1,8 @@
|
|
|
1
|
-
import { type ProjectConfig } from "../config/projectConfig.js";
|
|
2
|
-
export type PharoLauncherMcpProfileOwnership = "plexus-owned" | "external" | "unknown";
|
|
3
|
-
export interface PharoLauncherMcpProfilePaths {
|
|
4
|
-
profileName?: string;
|
|
5
|
-
stateRoot?: string;
|
|
6
|
-
launcherImage?: string;
|
|
7
|
-
imagesDir?: string;
|
|
8
|
-
vmsDir?: string;
|
|
9
|
-
templateSourcesDir?: string;
|
|
10
|
-
initScriptsDir?: string;
|
|
11
|
-
logsDir?: string;
|
|
12
|
-
launcherConfiguration?: string;
|
|
13
|
-
}
|
|
14
|
-
export interface PharoLauncherMcpProfileDiagnostic extends PharoLauncherMcpProfilePaths {
|
|
15
|
-
ownership: PharoLauncherMcpProfileOwnership;
|
|
16
|
-
mode: "project-owned" | "external";
|
|
17
|
-
profileScope: "project" | "explicit-override" | "external" | "unknown";
|
|
18
|
-
environmentKeys: string[];
|
|
19
|
-
reason: string;
|
|
20
|
-
}
|
|
21
|
-
export interface ResolvePharoLauncherMcpProfileOptions {
|
|
22
|
-
projectRoot: string;
|
|
23
|
-
config: ProjectConfig;
|
|
24
|
-
workspaceId: string;
|
|
25
|
-
stateRoot?: string;
|
|
26
|
-
env?: NodeJS.ProcessEnv;
|
|
27
|
-
}
|
|
28
1
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
2
|
+
* PLexus's one launcher profile, as the launcher's own variables.
|
|
3
|
+
*
|
|
4
|
+
* One profile, so the launcher image, the VMs and the templates, which are
|
|
5
|
+
* large and the same for every image, exist once per home.
|
|
31
6
|
*/
|
|
32
|
-
export declare function
|
|
33
|
-
export declare function pharoLauncherMcpProfileEnvironment(options: ResolvePharoLauncherMcpProfileOptions): Record<string, string> | undefined;
|
|
34
|
-
export declare function describePharoLauncherMcpProfile(options: ResolvePharoLauncherMcpProfileOptions): PharoLauncherMcpProfileDiagnostic;
|
|
7
|
+
export declare function homeProfileEnvironment(home: string): Record<string, string>;
|
|
35
8
|
//# sourceMappingURL=pharoLauncherProfile.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pharoLauncherProfile.d.ts","sourceRoot":"","sources":["../../src/launcher/pharoLauncherProfile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pharoLauncherProfile.d.ts","sourceRoot":"","sources":["../../src/launcher/pharoLauncherProfile.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAiB3E"}
|
|
@@ -1,121 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { resolvePlexusHomePath } from "../config/plexusHome.js";
|
|
4
|
-
import { sanitizeRuntimeId } from "../workspace/projectState.js";
|
|
5
|
-
const launcherProfileEnvironmentKeys = [
|
|
6
|
-
"PHARO_LAUNCHER_MCP_PROFILE",
|
|
7
|
-
"PHARO_LAUNCHER_MCP_STATE_ROOT",
|
|
8
|
-
"PHARO_LAUNCHER_MCP_LAUNCHER_IMAGE",
|
|
9
|
-
"PHARO_LAUNCHER_MCP_IMAGES_DIR",
|
|
10
|
-
"PHARO_LAUNCHER_MCP_VMS_DIR",
|
|
11
|
-
"PHARO_LAUNCHER_MCP_TEMPLATE_SOURCES_DIR",
|
|
12
|
-
"PHARO_LAUNCHER_MCP_INIT_SCRIPTS_DIR",
|
|
13
|
-
"PHARO_LAUNCHER_MCP_LOGS_DIR",
|
|
14
|
-
"PHARO_LAUNCHER_MCP_LAUNCHER_CONFIGURATION",
|
|
15
|
-
];
|
|
16
|
-
function profileName(config) {
|
|
17
|
-
return ["plexus", sanitizeRuntimeId(projectConfigId(config))].join("-");
|
|
18
|
-
}
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { profileRoot } from "../home.js";
|
|
19
3
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
4
|
+
* PLexus's one launcher profile, as the launcher's own variables.
|
|
5
|
+
*
|
|
6
|
+
* One profile, so the launcher image, the VMs and the templates, which are
|
|
7
|
+
* large and the same for every image, exist once per home.
|
|
22
8
|
*/
|
|
23
|
-
export function
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
function defaultProfileRoot(config, env) {
|
|
27
|
-
return homeProfilesRoot(resolvePlexusHomePath({ config, env }));
|
|
28
|
-
}
|
|
29
|
-
function projectOwnedPaths(options) {
|
|
30
|
-
const runtime = resolveProjectRuntimePolicy(options.config);
|
|
31
|
-
const policy = runtime.launcherProfile;
|
|
32
|
-
const stateRoot = policy.root
|
|
33
|
-
? resolvePathLike(policy.root)
|
|
34
|
-
: defaultProfileRoot(options.config, options.env);
|
|
35
|
-
return {
|
|
36
|
-
profileName: policy.name ?? profileName(options.config),
|
|
37
|
-
stateRoot,
|
|
38
|
-
launcherImage: joinPathLike(stateRoot, "launcher", "PharoLauncher.image"),
|
|
39
|
-
imagesDir: joinPathLike(stateRoot, "images"),
|
|
40
|
-
vmsDir: joinPathLike(stateRoot, "vms"),
|
|
41
|
-
templateSourcesDir: joinPathLike(stateRoot, "templates"),
|
|
42
|
-
initScriptsDir: joinPathLike(stateRoot, "init-scripts"),
|
|
43
|
-
logsDir: joinPathLike(stateRoot, "logs"),
|
|
44
|
-
launcherConfiguration: joinPathLike(stateRoot, "launcher", "pharo-launcher-cli-config.ston"),
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
function environmentFromPaths(paths) {
|
|
48
|
-
return {
|
|
49
|
-
PHARO_LAUNCHER_MCP_PROFILE: paths.profileName,
|
|
50
|
-
PHARO_LAUNCHER_MCP_STATE_ROOT: paths.stateRoot,
|
|
51
|
-
PHARO_LAUNCHER_MCP_LAUNCHER_IMAGE: paths.launcherImage,
|
|
52
|
-
PHARO_LAUNCHER_MCP_IMAGES_DIR: paths.imagesDir,
|
|
53
|
-
PHARO_LAUNCHER_MCP_VMS_DIR: paths.vmsDir,
|
|
54
|
-
PHARO_LAUNCHER_MCP_TEMPLATE_SOURCES_DIR: paths.templateSourcesDir,
|
|
55
|
-
PHARO_LAUNCHER_MCP_INIT_SCRIPTS_DIR: paths.initScriptsDir,
|
|
56
|
-
PHARO_LAUNCHER_MCP_LOGS_DIR: paths.logsDir,
|
|
57
|
-
PHARO_LAUNCHER_MCP_LAUNCHER_CONFIGURATION: paths.launcherConfiguration,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
function externallySuppliedPaths(env) {
|
|
61
|
-
return {
|
|
62
|
-
profileName: env.PHARO_LAUNCHER_MCP_PROFILE,
|
|
63
|
-
stateRoot: env.PHARO_LAUNCHER_MCP_STATE_ROOT,
|
|
64
|
-
launcherImage: env.PHARO_LAUNCHER_MCP_LAUNCHER_IMAGE,
|
|
65
|
-
imagesDir: env.PHARO_LAUNCHER_MCP_IMAGES_DIR,
|
|
66
|
-
vmsDir: env.PHARO_LAUNCHER_MCP_VMS_DIR,
|
|
67
|
-
templateSourcesDir: env.PHARO_LAUNCHER_MCP_TEMPLATE_SOURCES_DIR,
|
|
68
|
-
initScriptsDir: env.PHARO_LAUNCHER_MCP_INIT_SCRIPTS_DIR,
|
|
69
|
-
logsDir: env.PHARO_LAUNCHER_MCP_LOGS_DIR,
|
|
70
|
-
launcherConfiguration: env.PHARO_LAUNCHER_MCP_LAUNCHER_CONFIGURATION,
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
function presentEnvironmentKeys(env) {
|
|
74
|
-
return launcherProfileEnvironmentKeys.filter((key) => env[key] !== undefined);
|
|
75
|
-
}
|
|
76
|
-
export function pharoLauncherMcpProfileEnvironment(options) {
|
|
77
|
-
const runtime = resolveProjectRuntimePolicy(options.config);
|
|
78
|
-
if (runtime.launcherProfile.mode !== "project-owned") {
|
|
79
|
-
return undefined;
|
|
80
|
-
}
|
|
81
|
-
return environmentFromPaths(projectOwnedPaths(options));
|
|
82
|
-
}
|
|
83
|
-
export function describePharoLauncherMcpProfile(options) {
|
|
84
|
-
const runtime = resolveProjectRuntimePolicy(options.config);
|
|
85
|
-
if (runtime.launcherProfile.mode === "project-owned") {
|
|
86
|
-
const paths = projectOwnedPaths(options);
|
|
87
|
-
const profileScope = runtime.launcherProfile.name || runtime.launcherProfile.root
|
|
88
|
-
? "explicit-override"
|
|
89
|
-
: "project";
|
|
90
|
-
return {
|
|
91
|
-
ownership: "plexus-owned",
|
|
92
|
-
mode: "project-owned",
|
|
93
|
-
profileScope,
|
|
94
|
-
...paths,
|
|
95
|
-
environmentKeys: Object.keys(environmentFromPaths(paths)).sort((left, right) => left.localeCompare(right)),
|
|
96
|
-
reason: profileScope === "project"
|
|
97
|
-
? "PLexus derives and passes a project-scoped pharo-launcher-mcp profile."
|
|
98
|
-
: "PLexus passes an explicitly configured project-owned pharo-launcher-mcp profile override.",
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
const env = options.env ?? process.env;
|
|
102
|
-
const environmentKeys = presentEnvironmentKeys(env).sort((left, right) => left.localeCompare(right));
|
|
103
|
-
if (environmentKeys.length === 0) {
|
|
104
|
-
return {
|
|
105
|
-
ownership: "unknown",
|
|
106
|
-
mode: "external",
|
|
107
|
-
profileScope: "unknown",
|
|
108
|
-
environmentKeys,
|
|
109
|
-
reason: "runtime.launcherProfile.mode is external, but no pharo-launcher-mcp profile environment is visible.",
|
|
110
|
-
};
|
|
111
|
-
}
|
|
9
|
+
export function homeProfileEnvironment(home) {
|
|
10
|
+
const root = profileRoot(home);
|
|
112
11
|
return {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
12
|
+
PHARO_LAUNCHER_MCP_PROFILE: "plexus",
|
|
13
|
+
PHARO_LAUNCHER_MCP_STATE_ROOT: root,
|
|
14
|
+
PHARO_LAUNCHER_MCP_LAUNCHER_IMAGE: path.join(root, "launcher", "PharoLauncher.image"),
|
|
15
|
+
PHARO_LAUNCHER_MCP_IMAGES_DIR: path.join(root, "images"),
|
|
16
|
+
PHARO_LAUNCHER_MCP_VMS_DIR: path.join(root, "vms"),
|
|
17
|
+
PHARO_LAUNCHER_MCP_TEMPLATE_SOURCES_DIR: path.join(root, "templates"),
|
|
18
|
+
PHARO_LAUNCHER_MCP_INIT_SCRIPTS_DIR: path.join(root, "init-scripts"),
|
|
19
|
+
PHARO_LAUNCHER_MCP_LOGS_DIR: path.join(root, "logs"),
|
|
20
|
+
PHARO_LAUNCHER_MCP_LAUNCHER_CONFIGURATION: path.join(root, "launcher", "pharo-launcher-cli-config.ston"),
|
|
119
21
|
};
|
|
120
22
|
}
|
|
121
23
|
//# sourceMappingURL=pharoLauncherProfile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pharoLauncherProfile.js","sourceRoot":"","sources":["../../src/launcher/pharoLauncherProfile.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"pharoLauncherProfile.js","sourceRoot":"","sources":["../../src/launcher/pharoLauncherProfile.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAY;IACjD,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IAC/B,OAAO;QACL,0BAA0B,EAAE,QAAQ;QACpC,6BAA6B,EAAE,IAAI;QACnC,iCAAiC,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,qBAAqB,CAAC;QACrF,6BAA6B,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC;QACxD,0BAA0B,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC;QAClD,uCAAuC,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC;QACrE,mCAAmC,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC;QACpE,2BAA2B,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC;QACpD,yCAAyC,EAAE,IAAI,CAAC,IAAI,CAClD,IAAI,EACJ,UAAU,EACV,gCAAgC,CACjC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `plexus mcp`: the image tools, and the tools of the images running in
|
|
3
|
+
* scope, each forwarded to the image it names. A request's work runs in the
|
|
4
|
+
* trace context its `_meta` carries, so what it forwards continues the host's
|
|
5
|
+
* trace.
|
|
6
|
+
*/
|
|
7
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
8
|
+
import { type CallToolResult, type Tool } from "@modelcontextprotocol/sdk/types.js";
|
|
9
|
+
import type { Images } from "../images/index.js";
|
|
10
|
+
import type { Endpoint } from "../types.js";
|
|
11
|
+
export type ImagesApi = Pick<Images, "templates" | "list" | "create" | "start" | "stop" | "delete">;
|
|
12
|
+
/** What a forwarded call carries beside its arguments. */
|
|
13
|
+
export interface ForwardOptions {
|
|
14
|
+
/** The schema the image listed for the tool, which sets how long the call waits. */
|
|
15
|
+
inputSchema?: Tool["inputSchema"];
|
|
16
|
+
/** Aborted when the host cancels the call. */
|
|
17
|
+
signal?: AbortSignal;
|
|
18
|
+
}
|
|
19
|
+
export interface PlexusMcpServerOptions {
|
|
20
|
+
images: ImagesApi;
|
|
21
|
+
listTools?: (endpoint: Endpoint) => Promise<Tool[]>;
|
|
22
|
+
callTool?: (endpoint: Endpoint, name: string, args: Record<string, unknown>, options: ForwardOptions) => Promise<CallToolResult>;
|
|
23
|
+
}
|
|
24
|
+
export declare const imageTools: Tool[];
|
|
25
|
+
export declare function createPlexusMcpServer(options: PlexusMcpServerOptions): Server;
|
|
26
|
+
export declare function runPlexusMcpServer(options: PlexusMcpServerOptions): Promise<void>;
|
|
27
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAEnE,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,IAAI,EACV,MAAM,oCAAoC,CAAC;AAM5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,KAAK,EAAW,QAAQ,EAAa,MAAM,aAAa,CAAC;AAGhE,MAAM,MAAM,SAAS,GAAG,IAAI,CAC1B,MAAM,EACN,WAAW,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAC9D,CAAC;AAEF,0DAA0D;AAC1D,MAAM,WAAW,cAAc;IAC7B,oFAAoF;IACpF,WAAW,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IAClC,8CAA8C;IAC9C,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,SAAS,CAAC;IAClB,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IACpD,QAAQ,CAAC,EAAE,CACT,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,EAAE,cAAc,KACpB,OAAO,CAAC,cAAc,CAAC,CAAC;CAC9B;AAWD,eAAO,MAAM,UA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