@evref-bl/plexus 0.15.2 → 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 +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 +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 -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,722 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import { joinPathLike } from "../support/pathStyle.js";
|
|
3
|
-
export const plexusProjectConfigFileName = "plexus.json";
|
|
4
|
-
export const defaultPharoMcpMetadataKey = "io.github.evref-bl/pharo";
|
|
5
|
-
export const defaultPharoMcpSupportedMajorVersions = [12, 13, 14, 15];
|
|
6
|
-
export class ProjectConfigError extends Error {
|
|
7
|
-
issues;
|
|
8
|
-
constructor(message, issues) {
|
|
9
|
-
super(message);
|
|
10
|
-
this.issues = issues;
|
|
11
|
-
this.name = "ProjectConfigError";
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
function isObject(value) {
|
|
15
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
16
|
-
}
|
|
17
|
-
export function defaultProjectRuntimePolicy() {
|
|
18
|
-
return {
|
|
19
|
-
launcherProfile: {
|
|
20
|
-
mode: "project-owned",
|
|
21
|
-
},
|
|
22
|
-
pharoMcp: {
|
|
23
|
-
metadataKey: defaultPharoMcpMetadataKey,
|
|
24
|
-
supportedMajorVersions: [...defaultPharoMcpSupportedMajorVersions],
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
export function resolveProjectRuntimePolicy(config) {
|
|
29
|
-
return config.runtime ?? defaultProjectRuntimePolicy();
|
|
30
|
-
}
|
|
31
|
-
export function projectConfigId(config) {
|
|
32
|
-
return config.id;
|
|
33
|
-
}
|
|
34
|
-
export function projectMcpStartupMode(mcp) {
|
|
35
|
-
return mcp.startupMode ?? "required";
|
|
36
|
-
}
|
|
37
|
-
export function projectMcpLoadPolicy(mcp) {
|
|
38
|
-
return mcp.loadPolicy ?? "ifMissing";
|
|
39
|
-
}
|
|
40
|
-
export function projectImageDisplayMode(image) {
|
|
41
|
-
return image.displayMode ?? "headless";
|
|
42
|
-
}
|
|
43
|
-
export function projectImageCreateCleanupPolicy(create) {
|
|
44
|
-
return create.cleanupPolicy ?? "workspace_cleanup_only";
|
|
45
|
-
}
|
|
46
|
-
function stringField(object, key, issues, pathPrefix) {
|
|
47
|
-
const value = object[key];
|
|
48
|
-
if (typeof value === "string" && value.trim().length > 0) {
|
|
49
|
-
return value;
|
|
50
|
-
}
|
|
51
|
-
issues.push(`${pathPrefix}.${key} must be a non-empty string`);
|
|
52
|
-
return "";
|
|
53
|
-
}
|
|
54
|
-
function stringFieldAllowingEmpty(object, key, issues, pathPrefix) {
|
|
55
|
-
const value = object[key];
|
|
56
|
-
if (typeof value === "string") {
|
|
57
|
-
return value;
|
|
58
|
-
}
|
|
59
|
-
issues.push(`${pathPrefix}.${key} must be a string`);
|
|
60
|
-
return "";
|
|
61
|
-
}
|
|
62
|
-
function booleanField(object, key, issues, pathPrefix) {
|
|
63
|
-
const value = object[key];
|
|
64
|
-
if (typeof value === "boolean") {
|
|
65
|
-
return value;
|
|
66
|
-
}
|
|
67
|
-
issues.push(`${pathPrefix}.${key} must be a boolean`);
|
|
68
|
-
return false;
|
|
69
|
-
}
|
|
70
|
-
function booleanFieldWithDefault(object, key, issues, pathPrefix, defaultValue) {
|
|
71
|
-
const value = object[key];
|
|
72
|
-
if (value === undefined) {
|
|
73
|
-
return defaultValue;
|
|
74
|
-
}
|
|
75
|
-
if (typeof value === "boolean") {
|
|
76
|
-
return value;
|
|
77
|
-
}
|
|
78
|
-
issues.push(`${pathPrefix}.${key} must be a boolean`);
|
|
79
|
-
return defaultValue;
|
|
80
|
-
}
|
|
81
|
-
function optionalPortField(object, key, issues, pathPrefix) {
|
|
82
|
-
const value = object[key];
|
|
83
|
-
if (value === undefined) {
|
|
84
|
-
return undefined;
|
|
85
|
-
}
|
|
86
|
-
if (typeof value === "number" &&
|
|
87
|
-
Number.isInteger(value) &&
|
|
88
|
-
value >= 1 &&
|
|
89
|
-
value <= 65_535) {
|
|
90
|
-
return value;
|
|
91
|
-
}
|
|
92
|
-
issues.push(`${pathPrefix}.${key} must be an integer between 1 and 65535`);
|
|
93
|
-
return undefined;
|
|
94
|
-
}
|
|
95
|
-
function optionalPharoMcpStartupModeField(object, key, issues, pathPrefix) {
|
|
96
|
-
const value = object[key];
|
|
97
|
-
if (value === undefined) {
|
|
98
|
-
return undefined;
|
|
99
|
-
}
|
|
100
|
-
if (value === "required" || value === "optional" || value === "disabled") {
|
|
101
|
-
return value;
|
|
102
|
-
}
|
|
103
|
-
issues.push(`${pathPrefix}.${key} must be one of required, optional, disabled`);
|
|
104
|
-
return undefined;
|
|
105
|
-
}
|
|
106
|
-
function optionalPharoMcpLoadPolicyField(object, key, issues, pathPrefix) {
|
|
107
|
-
const value = object[key];
|
|
108
|
-
if (value === undefined) {
|
|
109
|
-
return undefined;
|
|
110
|
-
}
|
|
111
|
-
if (value === "ifMissing" || value === "always" || value === "never") {
|
|
112
|
-
return value;
|
|
113
|
-
}
|
|
114
|
-
issues.push(`${pathPrefix}.${key} must be one of ifMissing, always, never`);
|
|
115
|
-
return undefined;
|
|
116
|
-
}
|
|
117
|
-
function imageMcpLoadScriptField(object, key, issues, pathPrefix, loadPolicy) {
|
|
118
|
-
if (loadPolicy === "never" && object[key] === undefined) {
|
|
119
|
-
return "";
|
|
120
|
-
}
|
|
121
|
-
return stringField(object, key, issues, pathPrefix);
|
|
122
|
-
}
|
|
123
|
-
function optionalImageDisplayModeField(object, key, issues, pathPrefix) {
|
|
124
|
-
const value = object[key];
|
|
125
|
-
if (value === undefined) {
|
|
126
|
-
return undefined;
|
|
127
|
-
}
|
|
128
|
-
if (value === "headless" || value === "interactive") {
|
|
129
|
-
return value;
|
|
130
|
-
}
|
|
131
|
-
issues.push(`${pathPrefix}.${key} must be one of headless, interactive`);
|
|
132
|
-
return undefined;
|
|
133
|
-
}
|
|
134
|
-
function optionalImageCreateCleanupPolicyField(object, key, issues, pathPrefix) {
|
|
135
|
-
const value = object[key];
|
|
136
|
-
if (value === undefined) {
|
|
137
|
-
return undefined;
|
|
138
|
-
}
|
|
139
|
-
if (value === "workspace_cleanup_only") {
|
|
140
|
-
return value;
|
|
141
|
-
}
|
|
142
|
-
issues.push(`${pathPrefix}.${key} must be workspace_cleanup_only`);
|
|
143
|
-
return undefined;
|
|
144
|
-
}
|
|
145
|
-
function optionalPositiveIntegerField(object, key, issues, pathPrefix) {
|
|
146
|
-
const value = object[key];
|
|
147
|
-
if (value === undefined) {
|
|
148
|
-
return undefined;
|
|
149
|
-
}
|
|
150
|
-
if (typeof value === "number" && Number.isInteger(value) && value > 0) {
|
|
151
|
-
return value;
|
|
152
|
-
}
|
|
153
|
-
issues.push(`${pathPrefix}.${key} must be a positive integer`);
|
|
154
|
-
return undefined;
|
|
155
|
-
}
|
|
156
|
-
function optionalStringField(object, key, issues, pathPrefix) {
|
|
157
|
-
const value = object[key];
|
|
158
|
-
if (value === undefined) {
|
|
159
|
-
return undefined;
|
|
160
|
-
}
|
|
161
|
-
if (typeof value === "string" && value.trim().length > 0) {
|
|
162
|
-
return value;
|
|
163
|
-
}
|
|
164
|
-
issues.push(`${pathPrefix}.${key} must be a non-empty string`);
|
|
165
|
-
return undefined;
|
|
166
|
-
}
|
|
167
|
-
function stringFieldWithDefault(object, key, issues, pathPrefix, defaultValue) {
|
|
168
|
-
return optionalStringField(object, key, issues, pathPrefix) ?? defaultValue;
|
|
169
|
-
}
|
|
170
|
-
function urlField(object, key, issues, pathPrefix) {
|
|
171
|
-
const value = object[key];
|
|
172
|
-
if (typeof value === "string" && value.trim().length > 0) {
|
|
173
|
-
try {
|
|
174
|
-
new URL(value);
|
|
175
|
-
return value;
|
|
176
|
-
}
|
|
177
|
-
catch {
|
|
178
|
-
issues.push(`${pathPrefix}.${key} must be a valid URL`);
|
|
179
|
-
return "";
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
issues.push(`${pathPrefix}.${key} must be a valid URL`);
|
|
183
|
-
return "";
|
|
184
|
-
}
|
|
185
|
-
function optionalUrlField(object, key, issues, pathPrefix) {
|
|
186
|
-
const value = object[key];
|
|
187
|
-
if (value === undefined) {
|
|
188
|
-
return undefined;
|
|
189
|
-
}
|
|
190
|
-
if (typeof value === "string" && value.trim().length > 0) {
|
|
191
|
-
try {
|
|
192
|
-
new URL(value);
|
|
193
|
-
return value;
|
|
194
|
-
}
|
|
195
|
-
catch {
|
|
196
|
-
issues.push(`${pathPrefix}.${key} must be a valid URL`);
|
|
197
|
-
return undefined;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
issues.push(`${pathPrefix}.${key} must be a valid URL`);
|
|
201
|
-
return undefined;
|
|
202
|
-
}
|
|
203
|
-
function pathFieldWithDefault(object, key, issues, pathPrefix, defaultValue) {
|
|
204
|
-
const value = stringFieldWithDefault(object, key, issues, pathPrefix, defaultValue);
|
|
205
|
-
if (!value.startsWith("/")) {
|
|
206
|
-
issues.push(`${pathPrefix}.${key} must start with /`);
|
|
207
|
-
return defaultValue;
|
|
208
|
-
}
|
|
209
|
-
return value;
|
|
210
|
-
}
|
|
211
|
-
function parsePositiveIntegerArray(value, issues, pathPrefix, fallback) {
|
|
212
|
-
if (value === undefined) {
|
|
213
|
-
return [...fallback];
|
|
214
|
-
}
|
|
215
|
-
if (!Array.isArray(value) ||
|
|
216
|
-
value.length === 0 ||
|
|
217
|
-
!value.every((item) => Number.isInteger(item) && item > 0)) {
|
|
218
|
-
issues.push(`${pathPrefix} must be a non-empty array of positive integers`);
|
|
219
|
-
return [...fallback];
|
|
220
|
-
}
|
|
221
|
-
return [...new Set(value)];
|
|
222
|
-
}
|
|
223
|
-
function parseHomeImageCache(value, issues) {
|
|
224
|
-
const fallback = {
|
|
225
|
-
enabled: true,
|
|
226
|
-
networkPolicy: "online",
|
|
227
|
-
};
|
|
228
|
-
if (value === undefined) {
|
|
229
|
-
return fallback;
|
|
230
|
-
}
|
|
231
|
-
if (!isObject(value)) {
|
|
232
|
-
issues.push("home.imageCache must be an object");
|
|
233
|
-
return fallback;
|
|
234
|
-
}
|
|
235
|
-
const networkPolicy = value.networkPolicy ?? "online";
|
|
236
|
-
if (networkPolicy !== "online" && networkPolicy !== "local-only") {
|
|
237
|
-
issues.push("home.imageCache.networkPolicy must be one of online, local-only");
|
|
238
|
-
}
|
|
239
|
-
return {
|
|
240
|
-
enabled: booleanFieldWithDefault(value, "enabled", issues, "home.imageCache", true),
|
|
241
|
-
networkPolicy: networkPolicy === "local-only" ? "local-only" : "online",
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
function parseHomeDependencyRepositories(value, issues) {
|
|
245
|
-
const fallback = {
|
|
246
|
-
networkPolicy: "online",
|
|
247
|
-
};
|
|
248
|
-
if (value === undefined) {
|
|
249
|
-
return fallback;
|
|
250
|
-
}
|
|
251
|
-
if (!isObject(value)) {
|
|
252
|
-
issues.push("home.dependencyRepositories must be an object");
|
|
253
|
-
return fallback;
|
|
254
|
-
}
|
|
255
|
-
const networkPolicy = value.networkPolicy ?? "online";
|
|
256
|
-
if (networkPolicy !== "online" && networkPolicy !== "local-only") {
|
|
257
|
-
issues.push("home.dependencyRepositories.networkPolicy must be one of online, local-only");
|
|
258
|
-
}
|
|
259
|
-
return {
|
|
260
|
-
networkPolicy: networkPolicy === "local-only" ? "local-only" : "online",
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
function parseHome(value, issues) {
|
|
264
|
-
if (value === undefined) {
|
|
265
|
-
return undefined;
|
|
266
|
-
}
|
|
267
|
-
if (!isObject(value)) {
|
|
268
|
-
issues.push("home must be an object");
|
|
269
|
-
return undefined;
|
|
270
|
-
}
|
|
271
|
-
const imageCache = parseHomeImageCache(value.imageCache, issues);
|
|
272
|
-
const dependencyRepositories = parseHomeDependencyRepositories(value.dependencyRepositories, issues);
|
|
273
|
-
const path = optionalStringField(value, "path", issues, "home");
|
|
274
|
-
return {
|
|
275
|
-
...(path ? { path } : {}),
|
|
276
|
-
imageCache,
|
|
277
|
-
dependencyRepositories,
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
function parseProjectIdentity(value, issues) {
|
|
281
|
-
if (typeof value.id === "string" && value.id.trim().length > 0) {
|
|
282
|
-
return value.id;
|
|
283
|
-
}
|
|
284
|
-
issues.push("config.id must be a non-empty string");
|
|
285
|
-
return "";
|
|
286
|
-
}
|
|
287
|
-
function parseImageMcp(value, issues, pathPrefix) {
|
|
288
|
-
if (!isObject(value)) {
|
|
289
|
-
issues.push(`${pathPrefix}.mcp must be an object`);
|
|
290
|
-
return { loadScript: "" };
|
|
291
|
-
}
|
|
292
|
-
const loadPolicy = optionalPharoMcpLoadPolicyField(value, "loadPolicy", issues, `${pathPrefix}.mcp`);
|
|
293
|
-
return {
|
|
294
|
-
port: optionalPortField(value, "port", issues, `${pathPrefix}.mcp`),
|
|
295
|
-
loadScript: imageMcpLoadScriptField(value, "loadScript", issues, `${pathPrefix}.mcp`, loadPolicy),
|
|
296
|
-
startupMode: optionalPharoMcpStartupModeField(value, "startupMode", issues, `${pathPrefix}.mcp`),
|
|
297
|
-
loadPolicy,
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
|
-
function parsePharoMcpRepository(value, issues, pathPrefix) {
|
|
301
|
-
if (value === undefined) {
|
|
302
|
-
return undefined;
|
|
303
|
-
}
|
|
304
|
-
if (!isObject(value)) {
|
|
305
|
-
issues.push(`${pathPrefix}.repository must be an object`);
|
|
306
|
-
return undefined;
|
|
307
|
-
}
|
|
308
|
-
return {
|
|
309
|
-
githubUser: stringField(value, "githubUser", issues, `${pathPrefix}.repository`),
|
|
310
|
-
project: stringField(value, "project", issues, `${pathPrefix}.repository`),
|
|
311
|
-
commitish: stringField(value, "commitish", issues, `${pathPrefix}.repository`),
|
|
312
|
-
path: stringFieldAllowingEmpty(value, "path", issues, `${pathPrefix}.repository`),
|
|
313
|
-
baseline: stringField(value, "baseline", issues, `${pathPrefix}.repository`),
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
function parsePreparedImageMcp(value, issues, pathPrefix) {
|
|
317
|
-
if (!isObject(value)) {
|
|
318
|
-
issues.push(`${pathPrefix}.mcp must be an object`);
|
|
319
|
-
return { loadScript: "" };
|
|
320
|
-
}
|
|
321
|
-
return {
|
|
322
|
-
loadScript: stringField(value, "loadScript", issues, `${pathPrefix}.mcp`),
|
|
323
|
-
repository: parsePharoMcpRepository(value.repository, issues, `${pathPrefix}.mcp`),
|
|
324
|
-
startupMode: optionalPharoMcpStartupModeField(value, "startupMode", issues, `${pathPrefix}.mcp`),
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
function parseImageSshConfig(value, issues, pathPrefix) {
|
|
328
|
-
if (value === undefined) {
|
|
329
|
-
return undefined;
|
|
330
|
-
}
|
|
331
|
-
if (!isObject(value)) {
|
|
332
|
-
issues.push(`${pathPrefix}.ssh must be an object`);
|
|
333
|
-
return undefined;
|
|
334
|
-
}
|
|
335
|
-
const username = optionalStringField(value, "username", issues, `${pathPrefix}.ssh`);
|
|
336
|
-
const host = optionalStringField(value, "host", issues, `${pathPrefix}.ssh`);
|
|
337
|
-
const port = optionalPortField(value, "port", issues, `${pathPrefix}.ssh`);
|
|
338
|
-
if (port !== undefined && host === undefined) {
|
|
339
|
-
issues.push(`${pathPrefix}.ssh.host must be set when ${pathPrefix}.ssh.port is set`);
|
|
340
|
-
}
|
|
341
|
-
const hasPublicKey = value.publicKey !== undefined;
|
|
342
|
-
const hasPrivateKey = value.privateKey !== undefined;
|
|
343
|
-
const hasCustomKeys = hasPublicKey || hasPrivateKey;
|
|
344
|
-
const publicKey = hasCustomKeys
|
|
345
|
-
? stringField(value, "publicKey", issues, `${pathPrefix}.ssh`)
|
|
346
|
-
: undefined;
|
|
347
|
-
const privateKey = hasCustomKeys
|
|
348
|
-
? stringField(value, "privateKey", issues, `${pathPrefix}.ssh`)
|
|
349
|
-
: undefined;
|
|
350
|
-
return {
|
|
351
|
-
...(username ? { username } : {}),
|
|
352
|
-
...(host ? { host } : {}),
|
|
353
|
-
...(port ? { port } : {}),
|
|
354
|
-
...(publicKey !== undefined ? { publicKey } : {}),
|
|
355
|
-
...(privateKey !== undefined ? { privateKey } : {}),
|
|
356
|
-
};
|
|
357
|
-
}
|
|
358
|
-
function parseImagePlainCredentialsConfig(value, issues, pathPrefix) {
|
|
359
|
-
if (value === undefined) {
|
|
360
|
-
return undefined;
|
|
361
|
-
}
|
|
362
|
-
if (!isObject(value)) {
|
|
363
|
-
issues.push(`${pathPrefix}.plainCredentials must be an object`);
|
|
364
|
-
return undefined;
|
|
365
|
-
}
|
|
366
|
-
return {
|
|
367
|
-
username: stringField(value, "username", issues, `${pathPrefix}.plainCredentials`),
|
|
368
|
-
password: stringField(value, "password", issues, `${pathPrefix}.plainCredentials`),
|
|
369
|
-
};
|
|
370
|
-
}
|
|
371
|
-
function parseImageGit(value, issues, pathPrefix) {
|
|
372
|
-
if (value === undefined) {
|
|
373
|
-
return undefined;
|
|
374
|
-
}
|
|
375
|
-
if (!isObject(value)) {
|
|
376
|
-
issues.push(`${pathPrefix}.git must be an object`);
|
|
377
|
-
return undefined;
|
|
378
|
-
}
|
|
379
|
-
const transportValue = value.transport ?? "ssh";
|
|
380
|
-
const transport = transportValue === "ssh" ||
|
|
381
|
-
transportValue === "https" ||
|
|
382
|
-
transportValue === "http"
|
|
383
|
-
? transportValue
|
|
384
|
-
: "ssh";
|
|
385
|
-
if (transport !== transportValue) {
|
|
386
|
-
issues.push(`${pathPrefix}.git.transport must be one of ssh, https, http`);
|
|
387
|
-
}
|
|
388
|
-
const ssh = parseImageSshConfig(value.ssh, issues, `${pathPrefix}.git`);
|
|
389
|
-
const plainCredentials = parseImagePlainCredentialsConfig(value.plainCredentials, issues, `${pathPrefix}.git`);
|
|
390
|
-
if (transport === "ssh" && plainCredentials) {
|
|
391
|
-
issues.push(`${pathPrefix}.git.plainCredentials can only be used with https or http`);
|
|
392
|
-
}
|
|
393
|
-
if (transport !== "ssh" && ssh) {
|
|
394
|
-
issues.push(`${pathPrefix}.git.ssh can only be used with ssh`);
|
|
395
|
-
}
|
|
396
|
-
return {
|
|
397
|
-
transport,
|
|
398
|
-
...(ssh ? { ssh } : {}),
|
|
399
|
-
...(plainCredentials ? { plainCredentials } : {}),
|
|
400
|
-
};
|
|
401
|
-
}
|
|
402
|
-
function parseImageCreate(value, issues, pathPrefix) {
|
|
403
|
-
if (value === undefined) {
|
|
404
|
-
return undefined;
|
|
405
|
-
}
|
|
406
|
-
const createPath = `${pathPrefix}.create`;
|
|
407
|
-
if (!isObject(value)) {
|
|
408
|
-
issues.push(`${createPath} must be an object`);
|
|
409
|
-
return undefined;
|
|
410
|
-
}
|
|
411
|
-
const kindValue = value.kind ?? "template";
|
|
412
|
-
const kind = kindValue === "template" ? kindValue : "template";
|
|
413
|
-
if (kind !== kindValue) {
|
|
414
|
-
issues.push(`${createPath}.kind must be template`);
|
|
415
|
-
}
|
|
416
|
-
const profileId = optionalStringField(value, "profileId", issues, createPath);
|
|
417
|
-
const templateName = stringField(value, "templateName", issues, createPath);
|
|
418
|
-
const templateCategory = optionalStringField(value, "templateCategory", issues, createPath);
|
|
419
|
-
const role = optionalStringField(value, "role", issues, createPath);
|
|
420
|
-
const cleanupPolicy = optionalImageCreateCleanupPolicyField(value, "cleanupPolicy", issues, createPath);
|
|
421
|
-
return {
|
|
422
|
-
kind,
|
|
423
|
-
...(profileId ? { profileId } : {}),
|
|
424
|
-
templateName,
|
|
425
|
-
...(templateCategory ? { templateCategory } : {}),
|
|
426
|
-
...(role ? { role } : {}),
|
|
427
|
-
...(cleanupPolicy ? { cleanupPolicy } : {}),
|
|
428
|
-
};
|
|
429
|
-
}
|
|
430
|
-
function parseImagePreparedImage(value, issues, pathPrefix) {
|
|
431
|
-
if (value === undefined) {
|
|
432
|
-
return undefined;
|
|
433
|
-
}
|
|
434
|
-
const preparedPath = `${pathPrefix}.preparedImage`;
|
|
435
|
-
if (!isObject(value)) {
|
|
436
|
-
issues.push(`${preparedPath} must be an object`);
|
|
437
|
-
return undefined;
|
|
438
|
-
}
|
|
439
|
-
const copyModeValue = value.copyMode ?? "copy-on-open";
|
|
440
|
-
const copyMode = copyModeValue === "copy-on-open" ? copyModeValue : "copy-on-open";
|
|
441
|
-
if (copyMode !== copyModeValue) {
|
|
442
|
-
issues.push(`${preparedPath}.copyMode must be copy-on-open`);
|
|
443
|
-
}
|
|
444
|
-
return {
|
|
445
|
-
cacheId: stringField(value, "cacheId", issues, preparedPath),
|
|
446
|
-
copyMode,
|
|
447
|
-
};
|
|
448
|
-
}
|
|
449
|
-
function parseImages(value, issues) {
|
|
450
|
-
if (!Array.isArray(value)) {
|
|
451
|
-
issues.push("images must be an array");
|
|
452
|
-
return [];
|
|
453
|
-
}
|
|
454
|
-
return value.map((image, index) => {
|
|
455
|
-
const pathPrefix = `images[${index}]`;
|
|
456
|
-
if (!isObject(image)) {
|
|
457
|
-
issues.push(`${pathPrefix} must be an object`);
|
|
458
|
-
return {
|
|
459
|
-
id: "",
|
|
460
|
-
imageName: "",
|
|
461
|
-
mcp: { loadScript: "" },
|
|
462
|
-
};
|
|
463
|
-
}
|
|
464
|
-
return {
|
|
465
|
-
id: stringField(image, "id", issues, pathPrefix),
|
|
466
|
-
imageName: stringField(image, "imageName", issues, pathPrefix),
|
|
467
|
-
displayMode: optionalImageDisplayModeField(image, "displayMode", issues, pathPrefix),
|
|
468
|
-
mcp: parseImageMcp(image.mcp, issues, pathPrefix),
|
|
469
|
-
create: parseImageCreate(image.create, issues, pathPrefix),
|
|
470
|
-
preparedImage: parseImagePreparedImage(image.preparedImage, issues, pathPrefix),
|
|
471
|
-
git: parseImageGit(image.git, issues, pathPrefix),
|
|
472
|
-
};
|
|
473
|
-
});
|
|
474
|
-
}
|
|
475
|
-
function parsePreparedImageSource(value, issues, pathPrefix) {
|
|
476
|
-
if (!isObject(value)) {
|
|
477
|
-
issues.push(`${pathPrefix}.source must be an object`);
|
|
478
|
-
return {
|
|
479
|
-
kind: "template",
|
|
480
|
-
templateName: "",
|
|
481
|
-
};
|
|
482
|
-
}
|
|
483
|
-
const kindValue = value.kind ?? "template";
|
|
484
|
-
const kind = kindValue === "template" ? kindValue : "template";
|
|
485
|
-
if (kind !== kindValue) {
|
|
486
|
-
issues.push(`${pathPrefix}.source.kind must be template`);
|
|
487
|
-
}
|
|
488
|
-
return {
|
|
489
|
-
kind,
|
|
490
|
-
profileId: optionalStringField(value, "profileId", issues, `${pathPrefix}.source`),
|
|
491
|
-
templateName: stringField(value, "templateName", issues, `${pathPrefix}.source`),
|
|
492
|
-
templateCategory: optionalStringField(value, "templateCategory", issues, `${pathPrefix}.source`),
|
|
493
|
-
};
|
|
494
|
-
}
|
|
495
|
-
function parsePreparedImages(value, issues) {
|
|
496
|
-
if (value === undefined) {
|
|
497
|
-
return undefined;
|
|
498
|
-
}
|
|
499
|
-
if (!Array.isArray(value)) {
|
|
500
|
-
issues.push("preparedImages must be an array");
|
|
501
|
-
return undefined;
|
|
502
|
-
}
|
|
503
|
-
return value.map((preparedImage, index) => {
|
|
504
|
-
const pathPrefix = `preparedImages[${index}]`;
|
|
505
|
-
if (!isObject(preparedImage)) {
|
|
506
|
-
issues.push(`${pathPrefix} must be an object`);
|
|
507
|
-
return {
|
|
508
|
-
id: "",
|
|
509
|
-
imageName: "",
|
|
510
|
-
source: {
|
|
511
|
-
kind: "template",
|
|
512
|
-
templateName: "",
|
|
513
|
-
},
|
|
514
|
-
mcp: {
|
|
515
|
-
loadScript: "",
|
|
516
|
-
},
|
|
517
|
-
};
|
|
518
|
-
}
|
|
519
|
-
return {
|
|
520
|
-
id: stringField(preparedImage, "id", issues, pathPrefix),
|
|
521
|
-
imageName: stringField(preparedImage, "imageName", issues, pathPrefix),
|
|
522
|
-
source: parsePreparedImageSource(preparedImage.source, issues, pathPrefix),
|
|
523
|
-
mcp: parsePreparedImageMcp(preparedImage.mcp, issues, pathPrefix),
|
|
524
|
-
};
|
|
525
|
-
});
|
|
526
|
-
}
|
|
527
|
-
function parseLauncherProfilePolicy(value, issues) {
|
|
528
|
-
if (value === undefined) {
|
|
529
|
-
return { ...defaultProjectRuntimePolicy().launcherProfile };
|
|
530
|
-
}
|
|
531
|
-
if (!isObject(value)) {
|
|
532
|
-
issues.push("runtime.launcherProfile must be an object");
|
|
533
|
-
return { ...defaultProjectRuntimePolicy().launcherProfile };
|
|
534
|
-
}
|
|
535
|
-
const modeValue = value.mode ?? "project-owned";
|
|
536
|
-
const mode = modeValue === "project-owned" || modeValue === "external"
|
|
537
|
-
? modeValue
|
|
538
|
-
: "project-owned";
|
|
539
|
-
if (mode !== modeValue) {
|
|
540
|
-
issues.push("runtime.launcherProfile.mode must be one of project-owned, external");
|
|
541
|
-
}
|
|
542
|
-
const name = optionalStringField(value, "name", issues, "runtime.launcherProfile");
|
|
543
|
-
const root = optionalStringField(value, "root", issues, "runtime.launcherProfile");
|
|
544
|
-
const templateCatalog = parseLauncherTemplateCatalogPolicy(value.templateCatalog, issues);
|
|
545
|
-
return {
|
|
546
|
-
mode,
|
|
547
|
-
...(name ? { name } : {}),
|
|
548
|
-
...(root ? { root } : {}),
|
|
549
|
-
...(templateCatalog
|
|
550
|
-
? {
|
|
551
|
-
templateCatalog,
|
|
552
|
-
}
|
|
553
|
-
: {}),
|
|
554
|
-
};
|
|
555
|
-
}
|
|
556
|
-
function parseLauncherTemplateCatalogPolicy(value, issues) {
|
|
557
|
-
if (value === undefined) {
|
|
558
|
-
return undefined;
|
|
559
|
-
}
|
|
560
|
-
const pathPrefix = "runtime.launcherProfile.templateCatalog";
|
|
561
|
-
if (!isObject(value)) {
|
|
562
|
-
issues.push(`${pathPrefix} must be an object`);
|
|
563
|
-
return undefined;
|
|
564
|
-
}
|
|
565
|
-
const pathValue = optionalStringField(value, "path", issues, pathPrefix);
|
|
566
|
-
const sourceValue = value.source ?? (pathValue ? "path" : "user-or-server");
|
|
567
|
-
const source = sourceValue === "user-or-server" ||
|
|
568
|
-
sourceValue === "user" ||
|
|
569
|
-
sourceValue === "server" ||
|
|
570
|
-
sourceValue === "path" ||
|
|
571
|
-
sourceValue === "none"
|
|
572
|
-
? sourceValue
|
|
573
|
-
: "user-or-server";
|
|
574
|
-
if (source !== sourceValue) {
|
|
575
|
-
issues.push(`${pathPrefix}.source must be one of user-or-server, user, server, path, none`);
|
|
576
|
-
}
|
|
577
|
-
if (source === "path" && !pathValue) {
|
|
578
|
-
issues.push(`${pathPrefix}.path must be set when source is path`);
|
|
579
|
-
}
|
|
580
|
-
const serverSourcesUrl = optionalUrlField(value, "serverSourcesUrl", issues, pathPrefix);
|
|
581
|
-
return {
|
|
582
|
-
source,
|
|
583
|
-
...(pathValue ? { path: pathValue } : {}),
|
|
584
|
-
...(serverSourcesUrl ? { serverSourcesUrl } : {}),
|
|
585
|
-
};
|
|
586
|
-
}
|
|
587
|
-
function parsePharoMcpPolicy(value, issues) {
|
|
588
|
-
const defaults = defaultProjectRuntimePolicy().pharoMcp;
|
|
589
|
-
if (value === undefined) {
|
|
590
|
-
return {
|
|
591
|
-
metadataKey: defaults.metadataKey,
|
|
592
|
-
supportedMajorVersions: [...defaults.supportedMajorVersions],
|
|
593
|
-
};
|
|
594
|
-
}
|
|
595
|
-
if (!isObject(value)) {
|
|
596
|
-
issues.push("runtime.pharoMcp must be an object");
|
|
597
|
-
return {
|
|
598
|
-
metadataKey: defaults.metadataKey,
|
|
599
|
-
supportedMajorVersions: [...defaults.supportedMajorVersions],
|
|
600
|
-
};
|
|
601
|
-
}
|
|
602
|
-
return {
|
|
603
|
-
metadataKey: stringFieldWithDefault(value, "metadataKey", issues, "runtime.pharoMcp", defaults.metadataKey),
|
|
604
|
-
supportedMajorVersions: parsePositiveIntegerArray(value.supportedMajorVersions, issues, "runtime.pharoMcp.supportedMajorVersions", defaults.supportedMajorVersions),
|
|
605
|
-
};
|
|
606
|
-
}
|
|
607
|
-
function parseWorkspaceImagePolicy(value, issues) {
|
|
608
|
-
if (value === undefined) {
|
|
609
|
-
return undefined;
|
|
610
|
-
}
|
|
611
|
-
const pathPrefix = "runtime.workspaceImages";
|
|
612
|
-
if (!isObject(value)) {
|
|
613
|
-
issues.push(`${pathPrefix} must be an object`);
|
|
614
|
-
return undefined;
|
|
615
|
-
}
|
|
616
|
-
const maxCount = optionalPositiveIntegerField(value, "maxCount", issues, pathPrefix);
|
|
617
|
-
return {
|
|
618
|
-
...(maxCount !== undefined ? { maxCount } : {}),
|
|
619
|
-
};
|
|
620
|
-
}
|
|
621
|
-
function parseRuntimePolicy(value, issues) {
|
|
622
|
-
if (value === undefined) {
|
|
623
|
-
return defaultProjectRuntimePolicy();
|
|
624
|
-
}
|
|
625
|
-
if (!isObject(value)) {
|
|
626
|
-
issues.push("runtime must be an object");
|
|
627
|
-
return defaultProjectRuntimePolicy();
|
|
628
|
-
}
|
|
629
|
-
const scopeValue = value.scope ?? "project";
|
|
630
|
-
if (scopeValue !== "project") {
|
|
631
|
-
issues.push("runtime.scope must be \"project\"");
|
|
632
|
-
}
|
|
633
|
-
const workspaceImages = parseWorkspaceImagePolicy(value.workspaceImages, issues);
|
|
634
|
-
const nodeId = optionalStringField(value, "nodeId", issues, "runtime");
|
|
635
|
-
if (value.stateRoot !== undefined) {
|
|
636
|
-
issues.push("runtime.stateRoot is no longer read: a workspace keeps its state in its own .plexus directory");
|
|
637
|
-
}
|
|
638
|
-
return {
|
|
639
|
-
...(nodeId ? { nodeId } : {}),
|
|
640
|
-
...(workspaceImages ? { workspaceImages } : {}),
|
|
641
|
-
launcherProfile: parseLauncherProfilePolicy(value.launcherProfile, issues),
|
|
642
|
-
pharoMcp: parsePharoMcpPolicy(value.pharoMcp, issues),
|
|
643
|
-
};
|
|
644
|
-
}
|
|
645
|
-
function collectDuplicates(values, label, issues) {
|
|
646
|
-
const seen = new Set();
|
|
647
|
-
for (const value of values) {
|
|
648
|
-
if (!value) {
|
|
649
|
-
continue;
|
|
650
|
-
}
|
|
651
|
-
if (seen.has(value)) {
|
|
652
|
-
issues.push(`${label} must be unique: ${value}`);
|
|
653
|
-
}
|
|
654
|
-
else {
|
|
655
|
-
seen.add(value);
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
function collectDuplicatePorts(images, issues) {
|
|
660
|
-
const seen = new Set();
|
|
661
|
-
for (const image of images) {
|
|
662
|
-
if (projectMcpStartupMode(image.mcp) === "disabled") {
|
|
663
|
-
continue;
|
|
664
|
-
}
|
|
665
|
-
const port = image.mcp.port;
|
|
666
|
-
if (!port) {
|
|
667
|
-
continue;
|
|
668
|
-
}
|
|
669
|
-
if (seen.has(port)) {
|
|
670
|
-
issues.push(`image MCP ports must be unique: ${port}`);
|
|
671
|
-
}
|
|
672
|
-
else {
|
|
673
|
-
seen.add(port);
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
function validatePreparedImageReferences(config, issues) {
|
|
678
|
-
const preparedImageIds = new Set(config.preparedImages?.map((preparedImage) => preparedImage.id) ?? []);
|
|
679
|
-
config.images.forEach((image, index) => {
|
|
680
|
-
const cacheId = image.preparedImage?.cacheId;
|
|
681
|
-
if (cacheId && !preparedImageIds.has(cacheId)) {
|
|
682
|
-
issues.push(`images[${index}].preparedImage.cacheId must reference a preparedImages id: ${cacheId}`);
|
|
683
|
-
}
|
|
684
|
-
});
|
|
685
|
-
}
|
|
686
|
-
export function parseProjectConfig(value) {
|
|
687
|
-
const issues = [];
|
|
688
|
-
if (!isObject(value)) {
|
|
689
|
-
throw new ProjectConfigError("Invalid Plexus project config", [
|
|
690
|
-
"config must be an object",
|
|
691
|
-
]);
|
|
692
|
-
}
|
|
693
|
-
const home = parseHome(value.home, issues);
|
|
694
|
-
const preparedImages = parsePreparedImages(value.preparedImages, issues);
|
|
695
|
-
const config = {
|
|
696
|
-
id: parseProjectIdentity(value, issues),
|
|
697
|
-
name: stringField(value, "name", issues, "config"),
|
|
698
|
-
...(home ? { home } : {}),
|
|
699
|
-
runtime: parseRuntimePolicy(value.runtime, issues),
|
|
700
|
-
...(preparedImages ? { preparedImages } : {}),
|
|
701
|
-
images: parseImages(value.images, issues),
|
|
702
|
-
};
|
|
703
|
-
collectDuplicates(config.images.map((image) => image.id), "image ids", issues);
|
|
704
|
-
collectDuplicates(config.images.map((image) => image.imageName), "image names", issues);
|
|
705
|
-
collectDuplicates(config.preparedImages?.map((preparedImage) => preparedImage.id) ?? [], "prepared image ids", issues);
|
|
706
|
-
collectDuplicates(config.preparedImages?.map((preparedImage) => preparedImage.imageName) ?? [], "prepared image names", issues);
|
|
707
|
-
collectDuplicatePorts(config.images, issues);
|
|
708
|
-
validatePreparedImageReferences(config, issues);
|
|
709
|
-
if (issues.length > 0) {
|
|
710
|
-
throw new ProjectConfigError("Invalid Plexus project config", issues);
|
|
711
|
-
}
|
|
712
|
-
return config;
|
|
713
|
-
}
|
|
714
|
-
export function projectConfigPath(projectRoot) {
|
|
715
|
-
return joinPathLike(projectRoot, plexusProjectConfigFileName);
|
|
716
|
-
}
|
|
717
|
-
export function loadProjectConfig(projectRoot) {
|
|
718
|
-
const filePath = projectConfigPath(projectRoot);
|
|
719
|
-
const raw = fs.readFileSync(filePath, "utf8");
|
|
720
|
-
return parseProjectConfig(JSON.parse(raw));
|
|
721
|
-
}
|
|
722
|
-
//# sourceMappingURL=projectConfig.js.map
|