@evref-bl/plexus 0.16.0 → 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/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 +16 -2
- package/dist/cli.js.map +1 -1
- package/dist/commandLine.d.ts.map +1 -1
- package/dist/commandLine.js +21 -9
- package/dist/commandLine.js.map +1 -1
- package/dist/config/pharoMcpVersion.d.ts +1 -1
- package/dist/config/pharoMcpVersion.js +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/forward/index.d.ts +43 -2
- package/dist/forward/index.d.ts.map +1 -1
- package/dist/forward/index.js +59 -3
- package/dist/forward/index.js.map +1 -1
- package/dist/forward/jsonRpc.d.ts +40 -2
- package/dist/forward/jsonRpc.d.ts.map +1 -1
- package/dist/forward/jsonRpc.js +143 -25
- package/dist/forward/jsonRpc.js.map +1 -1
- package/dist/images/bases.d.ts +3 -2
- package/dist/images/bases.d.ts.map +1 -1
- package/dist/images/bases.js +12 -8
- package/dist/images/bases.js.map +1 -1
- package/dist/images/context.d.ts +17 -2
- package/dist/images/context.d.ts.map +1 -1
- package/dist/images/context.js +15 -1
- package/dist/images/context.js.map +1 -1
- package/dist/images/create.d.ts.map +1 -1
- package/dist/images/create.js +3 -2
- package/dist/images/create.js.map +1 -1
- package/dist/images/delete.d.ts.map +1 -1
- package/dist/images/delete.js +2 -1
- package/dist/images/delete.js.map +1 -1
- package/dist/images/endpoint.d.ts +13 -1
- package/dist/images/endpoint.d.ts.map +1 -1
- package/dist/images/endpoint.js +29 -1
- package/dist/images/endpoint.js.map +1 -1
- package/dist/images/index.d.ts +9 -5
- package/dist/images/index.d.ts.map +1 -1
- package/dist/images/index.js +19 -14
- package/dist/images/index.js.map +1 -1
- package/dist/images/scripts.d.ts +13 -4
- package/dist/images/scripts.d.ts.map +1 -1
- package/dist/images/scripts.js +28 -6
- package/dist/images/scripts.js.map +1 -1
- package/dist/images/start.d.ts.map +1 -1
- package/dist/images/start.js +11 -5
- package/dist/images/start.js.map +1 -1
- package/dist/images/stop.d.ts +13 -7
- package/dist/images/stop.d.ts.map +1 -1
- package/dist/images/stop.js +138 -9
- package/dist/images/stop.js.map +1 -1
- package/dist/images/store.d.ts.map +1 -1
- package/dist/images/store.js +2 -1
- package/dist/images/store.js.map +1 -1
- package/dist/images/templates.d.ts.map +1 -1
- package/dist/images/templates.js +2 -1
- package/dist/images/templates.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.d.ts +11 -2
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +135 -72
- package/dist/mcp/server.js.map +1 -1
- 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 +14 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +13 -4
|
@@ -2,19 +2,57 @@ export interface Session {
|
|
|
2
2
|
protocolVersion?: string;
|
|
3
3
|
sessionId?: string;
|
|
4
4
|
}
|
|
5
|
+
/**
|
|
6
|
+
* How a forwarded request failed, beside its message: whether the image
|
|
7
|
+
* answered, never got the call, or got it and gave no answer.
|
|
8
|
+
*
|
|
9
|
+
* - `answered`: the image answered a JSON-RPC error, with its code;
|
|
10
|
+
* - `no-handshake`: the handshake timed out, so the call was not sent;
|
|
11
|
+
* - `timeout`: the call was sent and not answered in time;
|
|
12
|
+
* - `refused`: the connection was refused, so nothing was sent;
|
|
13
|
+
* - `closed`: the connection closed after the call was sent;
|
|
14
|
+
* - `cancelled`: the caller's signal aborted the request;
|
|
15
|
+
* - `other`: an HTTP status, with `httpStatus`, invalid JSON, or a response
|
|
16
|
+
* with no result.
|
|
17
|
+
*/
|
|
18
|
+
export type ForwardError = Error & ForwardErrorKind;
|
|
19
|
+
type ForwardErrorKind = {
|
|
20
|
+
kind: "answered";
|
|
21
|
+
rpcCode?: number;
|
|
22
|
+
} | {
|
|
23
|
+
kind: "no-handshake" | "timeout";
|
|
24
|
+
waitedMs: number;
|
|
25
|
+
} | {
|
|
26
|
+
kind: "refused" | "closed" | "cancelled";
|
|
27
|
+
} | {
|
|
28
|
+
kind: "other";
|
|
29
|
+
httpStatus?: number;
|
|
30
|
+
};
|
|
5
31
|
/**
|
|
6
32
|
* One request, answered by its JSON-RPC response object. A JSON-RPC error is
|
|
7
33
|
* thrown with the server's `error.data` in the message.
|
|
34
|
+
*
|
|
35
|
+
* The request is a CLIENT span, `<method>` or `tools/call <tool>`, and
|
|
36
|
+
* carries the active trace context in its `params._meta`: see
|
|
37
|
+
* `requestAttributes` for what the span records.
|
|
8
38
|
*/
|
|
9
39
|
export declare function request(url: string, method: string, params: Record<string, unknown> | undefined, options: {
|
|
10
40
|
timeoutMs: number;
|
|
11
41
|
session?: Session;
|
|
42
|
+
signal?: AbortSignal;
|
|
12
43
|
}): Promise<Record<string, unknown>>;
|
|
13
44
|
/**
|
|
14
45
|
* The handshake a stateful MCP server needs before a call. A server that does
|
|
15
46
|
* not take it still answers calls, so a failed handshake leaves the call to
|
|
16
|
-
* go without a session rather than failing it
|
|
47
|
+
* go without a session rather than failing it, except when it was cancelled,
|
|
48
|
+
* or timed out and `failOnTimeout` asks: a server that does not answer the
|
|
49
|
+
* handshake will not answer the call either, and failing here says the call
|
|
50
|
+
* was never sent.
|
|
17
51
|
*/
|
|
18
|
-
export declare function initialize(url: string, timeoutMs: number
|
|
52
|
+
export declare function initialize(url: string, timeoutMs: number, options?: {
|
|
53
|
+
failOnTimeout?: boolean;
|
|
54
|
+
signal?: AbortSignal;
|
|
55
|
+
}): Promise<Session>;
|
|
19
56
|
export declare function jsonRpcErrorText(value: unknown): string;
|
|
57
|
+
export {};
|
|
20
58
|
//# sourceMappingURL=jsonRpc.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonRpc.d.ts","sourceRoot":"","sources":["../../src/forward/jsonRpc.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"jsonRpc.d.ts","sourceRoot":"","sources":["../../src/forward/jsonRpc.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,OAAO;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,gBAAgB,CAAC;AAEpD,KAAK,gBAAgB,GACjB;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GACtC;IAAE,IAAI,EAAE,cAAc,GAAG,SAAS,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACtD;IAAE,IAAI,EAAE,SAAS,GAAG,QAAQ,GAAG,WAAW,CAAA;CAAE,GAC5C;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAO3C;;;;;;;GAOG;AACH,wBAAsB,OAAO,CAC3B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAC3C,OAAO,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,WAAW,CAAA;CAAE,GACtE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA0ClC;AA4DD;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAC9B,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE;IAAE,aAAa,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,WAAW,CAAA;CAAO,GAC9D,OAAO,CAAC,OAAO,CAAC,CAoDlB;AAMD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAOvD"}
|
package/dist/forward/jsonRpc.js
CHANGED
|
@@ -1,35 +1,107 @@
|
|
|
1
1
|
import http from "node:http";
|
|
2
|
+
import { SpanKind } from "@opentelemetry/api";
|
|
3
|
+
import { errorType, failed, identifierOrOther, inSpan, withTraceContext } from "../telemetry/trace.js";
|
|
2
4
|
import { plexusVersion } from "../version.js";
|
|
3
5
|
const protocolVersion = "2025-06-18";
|
|
4
6
|
/**
|
|
5
7
|
* One request, answered by its JSON-RPC response object. A JSON-RPC error is
|
|
6
8
|
* thrown with the server's `error.data` in the message.
|
|
9
|
+
*
|
|
10
|
+
* The request is a CLIENT span, `<method>` or `tools/call <tool>`, and
|
|
11
|
+
* carries the active trace context in its `params._meta`: see
|
|
12
|
+
* `requestAttributes` for what the span records.
|
|
7
13
|
*/
|
|
8
14
|
export async function request(url, method, params, options) {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const id = `plexus-${method}-${Date.now()}`;
|
|
16
|
+
const tool = method === "tools/call" && typeof params?.name === "string" ? identifierOrOther(params.name) : undefined;
|
|
17
|
+
return inSpan(tool === undefined ? method : `${method} ${tool}`, SpanKind.CLIENT, requestAttributes(url, method, id, tool, options.session), async (span) => {
|
|
18
|
+
const sent = withTraceContext(params);
|
|
19
|
+
const answer = await post(url, {
|
|
20
|
+
jsonrpc: "2.0",
|
|
21
|
+
id,
|
|
22
|
+
method,
|
|
23
|
+
...(sent === undefined ? {} : { params: sent }),
|
|
24
|
+
}, options.timeoutMs, options.session, options.signal);
|
|
25
|
+
const payload = answer.payload;
|
|
26
|
+
if (!isRecord(payload)) {
|
|
27
|
+
throw forwardError(new Error("MCP response was not a JSON object"), { kind: "other" });
|
|
28
|
+
}
|
|
29
|
+
if ("error" in payload) {
|
|
30
|
+
const code = isRecord(payload.error) ? payload.error.code : undefined;
|
|
31
|
+
throw forwardError(new Error(`MCP error ${jsonRpcErrorText(payload.error)}`), {
|
|
32
|
+
kind: "answered",
|
|
33
|
+
...(typeof code === "number" ? { rpcCode: code } : {}),
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
if (!("result" in payload)) {
|
|
37
|
+
throw forwardError(new Error(`MCP ${method} response did not include a result`), { kind: "other" });
|
|
38
|
+
}
|
|
39
|
+
if (tool !== undefined && isRecord(payload.result) && payload.result.isError === true) {
|
|
40
|
+
failed(span, "tool_error");
|
|
41
|
+
}
|
|
42
|
+
return payload;
|
|
43
|
+
}, requestErrorType);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* What a forwarded request's span records, after the OpenTelemetry MCP
|
|
47
|
+
* conventions: the method, the tool and its operation, the session where the
|
|
48
|
+
* handshake opened one, the request's id, and the image's local address.
|
|
49
|
+
*/
|
|
50
|
+
function requestAttributes(url, method, id, tool, session = {}) {
|
|
51
|
+
let address = {};
|
|
52
|
+
try {
|
|
53
|
+
const target = new URL(url);
|
|
54
|
+
address = {
|
|
55
|
+
"server.address": target.hostname.replace(/^\[(.*)\]$/, "$1"),
|
|
56
|
+
...(target.port === "" ? {} : { "server.port": Number(target.port) }),
|
|
57
|
+
};
|
|
18
58
|
}
|
|
19
|
-
|
|
20
|
-
|
|
59
|
+
catch {
|
|
60
|
+
// The request refuses the URL itself.
|
|
21
61
|
}
|
|
22
|
-
|
|
23
|
-
|
|
62
|
+
return {
|
|
63
|
+
"mcp.method.name": method,
|
|
64
|
+
...(tool === undefined ? {} : { "gen_ai.tool.name": tool, "gen_ai.operation.name": "execute_tool" }),
|
|
65
|
+
...(session.protocolVersion === undefined ? {} : { "mcp.protocol.version": session.protocolVersion }),
|
|
66
|
+
...(session.sessionId === undefined ? {} : { "mcp.session.id": session.sessionId }),
|
|
67
|
+
"network.transport": "tcp",
|
|
68
|
+
"network.protocol.name": "http",
|
|
69
|
+
"jsonrpc.request.id": id,
|
|
70
|
+
...address,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A failed request's `error.type`: the JSON-RPC code an image answered, the
|
|
75
|
+
* HTTP status it answered, `timeout`, how the connection failed, or the
|
|
76
|
+
* error's class.
|
|
77
|
+
*/
|
|
78
|
+
function requestErrorType(error) {
|
|
79
|
+
const failure = error;
|
|
80
|
+
switch (failure?.kind) {
|
|
81
|
+
case "answered":
|
|
82
|
+
return failure.rpcCode === undefined ? "_OTHER" : String(failure.rpcCode);
|
|
83
|
+
case "timeout":
|
|
84
|
+
case "no-handshake":
|
|
85
|
+
return "timeout";
|
|
86
|
+
case "refused":
|
|
87
|
+
case "closed":
|
|
88
|
+
case "cancelled":
|
|
89
|
+
return failure.kind;
|
|
90
|
+
case "other":
|
|
91
|
+
return failure.httpStatus === undefined ? errorType(error) : String(failure.httpStatus);
|
|
92
|
+
default:
|
|
93
|
+
return errorType(error);
|
|
24
94
|
}
|
|
25
|
-
return payload;
|
|
26
95
|
}
|
|
27
96
|
/**
|
|
28
97
|
* The handshake a stateful MCP server needs before a call. A server that does
|
|
29
98
|
* not take it still answers calls, so a failed handshake leaves the call to
|
|
30
|
-
* go without a session rather than failing it
|
|
99
|
+
* go without a session rather than failing it, except when it was cancelled,
|
|
100
|
+
* or timed out and `failOnTimeout` asks: a server that does not answer the
|
|
101
|
+
* handshake will not answer the call either, and failing here says the call
|
|
102
|
+
* was never sent.
|
|
31
103
|
*/
|
|
32
|
-
export async function initialize(url, timeoutMs) {
|
|
104
|
+
export async function initialize(url, timeoutMs, options = {}) {
|
|
33
105
|
let answer;
|
|
34
106
|
try {
|
|
35
107
|
answer = await post(url, {
|
|
@@ -41,9 +113,19 @@ export async function initialize(url, timeoutMs) {
|
|
|
41
113
|
capabilities: {},
|
|
42
114
|
clientInfo: { name: "plexus", version: plexusVersion },
|
|
43
115
|
},
|
|
44
|
-
}, timeoutMs);
|
|
116
|
+
}, timeoutMs, {}, options.signal);
|
|
45
117
|
}
|
|
46
|
-
catch {
|
|
118
|
+
catch (error) {
|
|
119
|
+
const kind = error.kind;
|
|
120
|
+
if (kind === "cancelled") {
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
if (kind === "timeout" && options.failOnTimeout) {
|
|
124
|
+
throw forwardError(new Error(`MCP initialize timed out after ${timeoutMs}ms`), {
|
|
125
|
+
kind: "no-handshake",
|
|
126
|
+
waitedMs: timeoutMs,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
47
129
|
return {};
|
|
48
130
|
}
|
|
49
131
|
const result = isRecord(answer.payload) ? answer.payload.result : undefined;
|
|
@@ -57,7 +139,7 @@ export async function initialize(url, timeoutMs) {
|
|
|
57
139
|
...(answer.sessionId ? { sessionId: answer.sessionId } : {}),
|
|
58
140
|
};
|
|
59
141
|
// A stateless server does not implement the notification.
|
|
60
|
-
await post(url, { jsonrpc: "2.0", method: "notifications/initialized" }, timeoutMs, session).catch(() => undefined);
|
|
142
|
+
await post(url, { jsonrpc: "2.0", method: "notifications/initialized" }, timeoutMs, session, options.signal).catch(() => undefined);
|
|
61
143
|
return session;
|
|
62
144
|
}
|
|
63
145
|
// MCP Pharo names each argument that broke a tool's schema in the error's
|
|
@@ -72,13 +154,43 @@ export function jsonRpcErrorText(value) {
|
|
|
72
154
|
const data = value.data === undefined ? "" : ` ${JSON.stringify(value.data)}`;
|
|
73
155
|
return `${code}${value.message}${data}`;
|
|
74
156
|
}
|
|
75
|
-
|
|
157
|
+
/** The error with its kind, its message kept. */
|
|
158
|
+
function forwardError(error, kind) {
|
|
159
|
+
return Object.assign(error, kind);
|
|
160
|
+
}
|
|
161
|
+
function cancelled() {
|
|
162
|
+
return forwardError(new Error("MCP request cancelled"), { kind: "cancelled" });
|
|
163
|
+
}
|
|
164
|
+
// What the socket said, by whether the request could have reached the server:
|
|
165
|
+
// a refused connection sent nothing, a reset one had the request written.
|
|
166
|
+
function socketError(error, signal) {
|
|
167
|
+
if (signal?.aborted) {
|
|
168
|
+
return cancelled();
|
|
169
|
+
}
|
|
170
|
+
const failure = error instanceof Error ? error : new Error(String(error));
|
|
171
|
+
if ("kind" in failure) {
|
|
172
|
+
return failure;
|
|
173
|
+
}
|
|
174
|
+
const code = failure.code;
|
|
175
|
+
return forwardError(failure, {
|
|
176
|
+
kind: code === "ECONNREFUSED" ? "refused" : code === "ECONNRESET" || code === "EPIPE" ? "closed" : "other",
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* One POST, waiting at most `timeoutMs` for the server to say anything, and
|
|
181
|
+
* no longer than `signal` lets it: an abort destroys the request in flight.
|
|
182
|
+
*/
|
|
183
|
+
function post(url, payload, timeoutMs, session = {}, signal) {
|
|
76
184
|
const target = new URL(url);
|
|
77
185
|
if (target.protocol !== "http:") {
|
|
78
|
-
return Promise.reject(new Error(`Unsupported MCP endpoint: ${url}`));
|
|
186
|
+
return Promise.reject(forwardError(new Error(`Unsupported MCP endpoint: ${url}`), { kind: "other" }));
|
|
187
|
+
}
|
|
188
|
+
if (signal?.aborted) {
|
|
189
|
+
return Promise.reject(cancelled());
|
|
79
190
|
}
|
|
80
191
|
const body = JSON.stringify(payload);
|
|
81
192
|
return new Promise((resolve, reject) => {
|
|
193
|
+
const fail = (error) => reject(socketError(error, signal));
|
|
82
194
|
const outgoing = http.request({
|
|
83
195
|
// URL keeps an IPv6 host in brackets; the socket wants it bare.
|
|
84
196
|
hostname: target.hostname.replace(/^\[(.*)\]$/, "$1"),
|
|
@@ -96,7 +208,10 @@ function post(url, payload, timeoutMs, session = {}) {
|
|
|
96
208
|
...(session.sessionId ? { "Mcp-Session-Id": session.sessionId } : {}),
|
|
97
209
|
},
|
|
98
210
|
timeout: timeoutMs,
|
|
211
|
+
...(signal === undefined ? {} : { signal }),
|
|
99
212
|
}, (response) => {
|
|
213
|
+
// A connection that closes in the middle of the body ends nothing.
|
|
214
|
+
response.on("error", fail);
|
|
100
215
|
const chunks = [];
|
|
101
216
|
response.on("data", (chunk) => {
|
|
102
217
|
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
@@ -104,7 +219,7 @@ function post(url, payload, timeoutMs, session = {}) {
|
|
|
104
219
|
response.on("end", () => {
|
|
105
220
|
const status = response.statusCode;
|
|
106
221
|
if (status === undefined || status < 200 || status >= 300) {
|
|
107
|
-
reject(new Error(`HTTP ${status ?? "unknown"} ${response.statusMessage ?? ""}`.trim()));
|
|
222
|
+
reject(forwardError(new Error(`HTTP ${status ?? "unknown"} ${response.statusMessage ?? ""}`.trim()), { kind: "other", ...(status === undefined ? {} : { httpStatus: status }) }));
|
|
108
223
|
return;
|
|
109
224
|
}
|
|
110
225
|
const text = Buffer.concat(chunks).toString("utf8");
|
|
@@ -118,7 +233,7 @@ function post(url, payload, timeoutMs, session = {}) {
|
|
|
118
233
|
data = JSON.parse(text);
|
|
119
234
|
}
|
|
120
235
|
catch (error) {
|
|
121
|
-
reject(new Error(`MCP response was not valid JSON: ${error instanceof Error ? error.message : String(error)}`));
|
|
236
|
+
reject(forwardError(new Error(`MCP response was not valid JSON: ${error instanceof Error ? error.message : String(error)}`), { kind: "other" }));
|
|
122
237
|
return;
|
|
123
238
|
}
|
|
124
239
|
const sessionId = response.headers["mcp-session-id"];
|
|
@@ -129,9 +244,12 @@ function post(url, payload, timeoutMs, session = {}) {
|
|
|
129
244
|
});
|
|
130
245
|
});
|
|
131
246
|
outgoing.on("timeout", () => {
|
|
132
|
-
outgoing.destroy(new Error(`MCP request timed out after ${timeoutMs}ms`)
|
|
247
|
+
outgoing.destroy(forwardError(new Error(`MCP request timed out after ${timeoutMs}ms`), {
|
|
248
|
+
kind: "timeout",
|
|
249
|
+
waitedMs: timeoutMs,
|
|
250
|
+
}));
|
|
133
251
|
});
|
|
134
|
-
outgoing.on("error",
|
|
252
|
+
outgoing.on("error", fail);
|
|
135
253
|
outgoing.end(body);
|
|
136
254
|
});
|
|
137
255
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonRpc.js","sourceRoot":"","sources":["../../src/forward/jsonRpc.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,MAAM,eAAe,GAAG,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"jsonRpc.js","sourceRoot":"","sources":["../../src/forward/jsonRpc.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAmB,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACvG,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,MAAM,eAAe,GAAG,YAAY,CAAC;AAiCrC;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO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AAC,CAAC;AAC9E,CAAC"}
|
package/dist/images/bases.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ImagesContext } from "./context.js";
|
|
2
2
|
import { type ImageFiles } from "./store.js";
|
|
3
|
-
export declare function baseKey(template: string, category: string, pin: string): string;
|
|
3
|
+
export declare function baseKey(template: string, category: string, pin: string, telemetry?: boolean): string;
|
|
4
4
|
/**
|
|
5
5
|
* Where an image is made from a template before it is what it is for: in the
|
|
6
6
|
* store, where the launcher makes images, under a name no image can have and
|
|
@@ -9,7 +9,8 @@ export declare function baseKey(template: string, category: string, pin: string)
|
|
|
9
9
|
export declare function newBuild(context: ImagesContext, name: string): ImageFiles;
|
|
10
10
|
/**
|
|
11
11
|
* The base for this template, built first when there is none. `built` says
|
|
12
|
-
* whether this call built the one it answers.
|
|
12
|
+
* whether this call built the one it answers. With telemetry it is the base
|
|
13
|
+
* that holds MCP's `Telemetry` group, a base of its own.
|
|
13
14
|
*/
|
|
14
15
|
export declare function ensureBase(context: ImagesContext, template: {
|
|
15
16
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bases.d.ts","sourceRoot":"","sources":["../../src/images/bases.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bases.d.ts","sourceRoot":"","sources":["../../src/images/bases.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGlD,OAAO,EAKL,KAAK,UAAU,EAChB,MAAM,YAAY,CAAC;AAIpB,wBAAgB,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,UAAQ,GAAG,MAAM,CAclG;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,CAEzE;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAC9B,OAAO,EAAE,aAAa,EACtB,QAAQ,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,EAC5C,GAAG,EAAE,MAAM,GACV,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC,CAkC1C;AAED,wEAAwE;AACxE,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAY9D;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CACtB,OAAO,EAAE,aAAa,EACtB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,CAAC,SAAS,EAAE,UAAU,KAAK,IAAI,GACtC,IAAI,CAYN;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI,CAUlE;AAmBD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAO5E;AAID;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAqChE"}
|
package/dist/images/bases.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A base is a template with the pinned MCP loaded and saved, so that a create
|
|
3
3
|
* copies it in seconds instead of loading MCP for minutes. It is a directory
|
|
4
|
-
* of `<home>/bases` named after its template, category
|
|
5
|
-
*
|
|
4
|
+
* of `<home>/bases` named after its template, category, pin and whether it
|
|
5
|
+
* holds MCP's `Telemetry` group, built under a temporary name and renamed when
|
|
6
|
+
* complete: its existence is its record.
|
|
6
7
|
*/
|
|
7
8
|
import crypto from "node:crypto";
|
|
8
9
|
import fs from "node:fs";
|
|
9
10
|
import path from "node:path";
|
|
11
|
+
import * as texts from "../answers/texts.js";
|
|
10
12
|
import { PlexusError } from "../errors.js";
|
|
11
13
|
import { basesRoot, storeRoot, tmpRoot } from "../home.js";
|
|
12
14
|
import { buildPrefix } from "./names.js";
|
|
13
15
|
import { createFromTemplate, prepare } from "./prepare.js";
|
|
14
16
|
import { filesOfDirectory, isFile, ownedName, removeDirectory, } from "./store.js";
|
|
15
17
|
const baseFileName = "base";
|
|
16
|
-
export function baseKey(template, category, pin) {
|
|
18
|
+
export function baseKey(template, category, pin, telemetry = false) {
|
|
17
19
|
const slug = template
|
|
18
20
|
.toLowerCase()
|
|
19
21
|
.replace(/[^a-z0-9]+/g, "-")
|
|
@@ -25,7 +27,8 @@ export function baseKey(template, category, pin) {
|
|
|
25
27
|
.update(`${category}\n${template}`)
|
|
26
28
|
.digest("hex")
|
|
27
29
|
.slice(0, 8);
|
|
28
|
-
|
|
30
|
+
// Before the pin, which ends every key: see evictOtherPins.
|
|
31
|
+
return `${slug}-${hash}${telemetry ? "-telemetry" : ""}-mcp-${pin}`;
|
|
29
32
|
}
|
|
30
33
|
/**
|
|
31
34
|
* Where an image is made from a template before it is what it is for: in the
|
|
@@ -37,10 +40,11 @@ export function newBuild(context, name) {
|
|
|
37
40
|
}
|
|
38
41
|
/**
|
|
39
42
|
* The base for this template, built first when there is none. `built` says
|
|
40
|
-
* whether this call built the one it answers.
|
|
43
|
+
* whether this call built the one it answers. With telemetry it is the base
|
|
44
|
+
* that holds MCP's `Telemetry` group, a base of its own.
|
|
41
45
|
*/
|
|
42
46
|
export async function ensureBase(context, template, pin) {
|
|
43
|
-
const key = baseKey(template.name, template.category, pin);
|
|
47
|
+
const key = baseKey(template.name, template.category, pin, context.telemetry);
|
|
44
48
|
const dir = path.join(basesRoot(context.home), key);
|
|
45
49
|
const isBase = () => isFile(path.join(dir, `${baseFileName}.image`));
|
|
46
50
|
if (isBase()) {
|
|
@@ -49,7 +53,7 @@ export async function ensureBase(context, template, pin) {
|
|
|
49
53
|
const build = newBuild(context, key);
|
|
50
54
|
try {
|
|
51
55
|
const failure = (await createFromTemplate(context, build, template)) ??
|
|
52
|
-
(await prepare(context, build, { kind: "pin", version: pin }));
|
|
56
|
+
(await prepare(context, build, { kind: "pin", version: pin, telemetry: context.telemetry }));
|
|
53
57
|
if (failure !== undefined) {
|
|
54
58
|
throw new PlexusError("create-failed", `Building the base for ${template.name} failed.\n${failure}`);
|
|
55
59
|
}
|
|
@@ -115,7 +119,7 @@ export function moveIntoStore(dir, files) {
|
|
|
115
119
|
}
|
|
116
120
|
catch (error) {
|
|
117
121
|
if (fs.existsSync(files.dir)) {
|
|
118
|
-
throw new PlexusError("image-exists",
|
|
122
|
+
throw new PlexusError("image-exists", texts.imageExists(files.name));
|
|
119
123
|
}
|
|
120
124
|
throw error;
|
|
121
125
|
}
|
package/dist/images/bases.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bases.js","sourceRoot":"","sources":["../../src/images/bases.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"bases.js","sourceRoot":"","sources":["../../src/images/bases.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EACL,gBAAgB,EAChB,MAAM,EACN,SAAS,EACT,eAAe,GAEhB,MAAM,YAAY,CAAC;AAEpB,MAAM,YAAY,GAAG,MAAM,CAAC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AAuC,EAAE,mCAAmC,CAAC;YAC/F,CAAC,CAAC,OAAO,CAAC;IACd,CAAC,CAAC;SACD,OAAO,CAAC,YAAY,EAAE,CAAC,KAAK,EAAE,KAAa,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3F,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;QACxB,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC3C,CAAC;AACH,CAAC"}
|
package/dist/images/context.d.ts
CHANGED
|
@@ -1,14 +1,25 @@
|
|
|
1
|
+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
+
import { type CallToolOptions } from "../forward/index.js";
|
|
1
3
|
import { type LauncherPort } from "../launcher/pharoLauncherMcpClient.js";
|
|
2
4
|
import type { Endpoint, ImagesOptions } from "../types.js";
|
|
3
5
|
/**
|
|
4
|
-
* What every operation works with. The clock
|
|
5
|
-
* test can run a start
|
|
6
|
+
* What every operation works with. The clock, the ping and the calls a stop
|
|
7
|
+
* makes to save an image are here so that a test can run a start or a stop
|
|
8
|
+
* without an image.
|
|
6
9
|
*/
|
|
7
10
|
export interface ImagesContext {
|
|
8
11
|
home: string;
|
|
9
12
|
scope?: string;
|
|
13
|
+
/** Whether the images made and started are enrolled in OpenTelemetry. */
|
|
14
|
+
telemetry: boolean;
|
|
10
15
|
launcher(): LauncherPort;
|
|
11
16
|
ping(endpoint: Endpoint): Promise<boolean>;
|
|
17
|
+
/** The tools an image lists, for the one a stop that saves evaluates with. */
|
|
18
|
+
listTools(endpoint: Endpoint): Promise<ReadonlyArray<{
|
|
19
|
+
name: string;
|
|
20
|
+
}>>;
|
|
21
|
+
/** One call to an image's tool, as forwarding makes it. */
|
|
22
|
+
callTool(endpoint: Endpoint, name: string, args: Record<string, unknown>, options: CallToolOptions): Promise<CallToolResult>;
|
|
12
23
|
sleep(ms: number): Promise<void>;
|
|
13
24
|
now(): number;
|
|
14
25
|
/** How often a start or a stop asks the host again. */
|
|
@@ -17,6 +28,10 @@ export interface ImagesContext {
|
|
|
17
28
|
vmAppearMs: number;
|
|
18
29
|
/** How long a stop waits for the VMs it killed to go. */
|
|
19
30
|
stopWaitMs: number;
|
|
31
|
+
/** How long a stop that saves waits for the image to take the save, and for its VM to quit. */
|
|
32
|
+
saveWaitMs: number;
|
|
20
33
|
}
|
|
34
|
+
/** Whether `PLEXUS_TELEMETRY` asks for telemetry: `1` or `true`, in any case. */
|
|
35
|
+
export declare function plexusTelemetry(env?: NodeJS.ProcessEnv): boolean;
|
|
21
36
|
export declare function imagesContext(options?: ImagesOptions): ImagesContext;
|
|
22
37
|
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/images/context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/images/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAA6B,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtF,OAAO,EAEL,KAAK,YAAY,EAClB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG3D;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yEAAyE;IACzE,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,IAAI,YAAY,CAAC;IACzB,IAAI,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3C,8EAA8E;IAC9E,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,aAAa,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IACxE,2DAA2D;IAC3D,QAAQ,CACN,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,cAAc,CAAC,CAAC;IAC3B,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,GAAG,IAAI,MAAM,CAAC;IACd,uDAAuD;IACvD,MAAM,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,UAAU,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,UAAU,EAAE,MAAM,CAAC;IACnB,+FAA+F;IAC/F,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,iFAAiF;AACjF,wBAAgB,eAAe,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,OAAO,CAE7E;AASD,wBAAgB,aAAa,CAAC,OAAO,GAAE,aAAkB,GAAG,aAAa,CAuBxE"}
|
package/dist/images/context.js
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { ping } from "../forward/index.js";
|
|
2
|
+
import { callTool, listTools, ping } from "../forward/index.js";
|
|
3
3
|
import { plexusHome } from "../home.js";
|
|
4
4
|
import { openLauncherPort, } from "../launcher/pharoLauncherMcpClient.js";
|
|
5
5
|
import { checkScope } from "./names.js";
|
|
6
|
+
/** Whether `PLEXUS_TELEMETRY` asks for telemetry: `1` or `true`, in any case. */
|
|
7
|
+
export function plexusTelemetry(env = process.env) {
|
|
8
|
+
return /^(1|true)$/i.test(env.PLEXUS_TELEMETRY?.trim() ?? "");
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* How long a stop that saves waits on each request of the image's tool
|
|
12
|
+
* listing: an image that cannot list its tools in that time will not take
|
|
13
|
+
* the save either.
|
|
14
|
+
*/
|
|
15
|
+
const listingWaitMs = 10_000;
|
|
6
16
|
export function imagesContext(options = {}) {
|
|
7
17
|
// The launcher is handed these paths, and a VM's command line is compared
|
|
8
18
|
// with them, so they are absolute whatever the caller's directory.
|
|
@@ -12,15 +22,19 @@ export function imagesContext(options = {}) {
|
|
|
12
22
|
return {
|
|
13
23
|
home,
|
|
14
24
|
...(scope === undefined ? {} : { scope }),
|
|
25
|
+
telemetry: options.telemetry ?? plexusTelemetry(),
|
|
15
26
|
// Opening resolves the launcher installation, which an operation that
|
|
16
27
|
// never reaches the launcher has no reason to pay for.
|
|
17
28
|
launcher: () => (launcher ??= openLauncherPort(home)),
|
|
18
29
|
ping: (endpoint) => ping(endpoint),
|
|
30
|
+
listTools: (endpoint) => listTools(endpoint, { timeoutMs: listingWaitMs }),
|
|
31
|
+
callTool: (endpoint, name, args, callOptions) => callTool(endpoint, name, args, callOptions),
|
|
19
32
|
sleep: (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
|
|
20
33
|
now: () => Date.now(),
|
|
21
34
|
pollMs: 250,
|
|
22
35
|
vmAppearMs: 30_000,
|
|
23
36
|
stopWaitMs: 10_000,
|
|
37
|
+
saveWaitMs: 60_000,
|
|
24
38
|
};
|
|
25
39
|
}
|
|
26
40
|
//# sourceMappingURL=context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/images/context.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/images/context.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAwB,MAAM,qBAAqB,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,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E,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC;QAC5F,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAChE,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;QACrB,MAAM,EAAE,GAAG;QACX,UAAU,EAAE,MAAM;QAClB,UAAU,EAAE,MAAM;QAClB,UAAU,EAAE,MAAM;KACnB,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/images/create.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/images/create.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAU5D,OAAO,EAA2B,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AACzF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAKlD,OAAO,EAML,KAAK,UAAU,EAEhB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAO9E;;;;GAIG;AACH,wBAAsB,MAAM,CAC1B,OAAO,EAAE,aAAa,EACtB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,YAAY,CAAC,CAgCvB;AAED,6EAA6E;AAC7E,wBAAgB,aAAa,CAAC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,GAAG,UAAU,CAEnF;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,WAAW,CAM7F"}
|
package/dist/images/create.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import * as texts from "../answers/texts.js";
|
|
3
4
|
import { defaultPharoMcpVersion } from "../config/pharoMcpVersion.js";
|
|
4
5
|
import { PlexusError } from "../errors.js";
|
|
5
6
|
import { longCommandTimeoutMs } from "../launcher/pharoLauncherMcpClient.js";
|
|
@@ -24,7 +25,7 @@ export async function create(context, name, options) {
|
|
|
24
25
|
const startedAt = context.now();
|
|
25
26
|
const files = imageFiles(context, name);
|
|
26
27
|
if (exists(files.dir)) {
|
|
27
|
-
throw new PlexusError("image-exists",
|
|
28
|
+
throw new PlexusError("image-exists", texts.imageExists(name));
|
|
28
29
|
}
|
|
29
30
|
const script = checkedScript(options);
|
|
30
31
|
if (typeof options.template !== "string" || options.template.trim() === "") {
|
|
@@ -55,7 +56,7 @@ export function buildingState(context, files) {
|
|
|
55
56
|
return readClaim(context, files.building, createMaxMs);
|
|
56
57
|
}
|
|
57
58
|
export function stillBuilding(files, holder) {
|
|
58
|
-
return new PlexusError("building",
|
|
59
|
+
return new PlexusError("building", texts.stillBuilding(files.name, holder?.pid), holder ? { pid: holder.pid } : undefined);
|
|
59
60
|
}
|
|
60
61
|
function checkedScript(options) {
|
|
61
62
|
if (options.script === undefined) {
|