@enhance-eng/enhance 0.1.25 → 0.1.33
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/{cli-output-identity.lib-DpON8As5.mjs → cli-output-identity.lib-CWNAXho4.mjs} +2402 -1306
- package/dist/main.mjs +719 -58
- package/dist/{mcp-invocation.adapter-FuxI6KsE.mjs → mcp-invocation.adapter-DHdF8-MP.mjs} +115 -69
- package/dist/mcp-main.mjs +12 -7
- package/dist/{mcp-server.adapter-D7XwVD-o.mjs → mcp-server.adapter-B0Kn0e7m.mjs} +109 -35
- package/dist/mcp.mjs +2 -2
- package/dist/{mutation-key.adapter-CXQ08HQY.mjs → mutation-key.adapter-A1d27TVY.mjs} +333 -176
- package/dist/remote-mcp-main.mjs +28 -45
- package/package.json +4 -3
package/dist/remote-mcp-main.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import { a as readRemoteMcpEnvironment, c as createPrototypeArtifactAdapter, l as createPublishCanvasPrototypeComposite, n as createHttpRemoteAdapter, t as createMutationKeyAdapter, u as createImportCanvasAssetComposite } from "./mutation-key.adapter-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { M as canvasAssetImportInputSchema, N as canvasAssetImportOutputSchema, Ut as foldPrototypeArtifactPath, Xt as MCP_AUTH_SCOPE, Yt as getMeOutputSchema, b as canvasPrototypeIntentSchema, f as createCapabilityCatalogAdapter, jt as CliError, qt as prototypeArtifactPathSchema, x as canvasPrototypeOutputSchema } from "./cli-output-identity.lib-CWNAXho4.mjs";
|
|
3
|
+
import { a as readRemoteMcpEnvironment, c as createPrototypeArtifactAdapter, l as createPublishCanvasPrototypeComposite, n as createHttpRemoteAdapter, t as createMutationKeyAdapter, u as createImportCanvasAssetComposite } from "./mutation-key.adapter-A1d27TVY.mjs";
|
|
4
|
+
import { n as createMcpCanvasProfileAdapter, t as createMcpInvocationAdapter } from "./mcp-invocation.adapter-DHdF8-MP.mjs";
|
|
5
|
+
import { a as createMcpResultAdapter, o as createMcpClientContextAdapter, t as createMcpServerAdapter } from "./mcp-server.adapter-B0Kn0e7m.mjs";
|
|
6
6
|
import process from "node:process";
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
import os, { tmpdir } from "node:os";
|
|
@@ -24,7 +24,6 @@ import { open as open$1 } from "yauzl";
|
|
|
24
24
|
|
|
25
25
|
//#region src/infrastructure/mcp-canvas-ui.adapter.ts
|
|
26
26
|
const HTTP_OK$1 = 200;
|
|
27
|
-
const MAX_HTML_BYTES = 1e6;
|
|
28
27
|
const UI_TIMEOUT_MS = 15e3;
|
|
29
28
|
const MIME_TYPE = "text/html;profile=mcp-app";
|
|
30
29
|
const readHtml = async (url) => {
|
|
@@ -47,14 +46,9 @@ const readHtml = async (url) => {
|
|
|
47
46
|
throw new Error("The Enhance canvas panel is unavailable. Continue through the canvas tools.");
|
|
48
47
|
}
|
|
49
48
|
const chunks = [];
|
|
50
|
-
let bytes = 0;
|
|
51
49
|
await pipeline(response, new Writable({ write: (chunk, _encoding, callback) => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
else {
|
|
55
|
-
chunks.push(chunk);
|
|
56
|
-
callback();
|
|
57
|
-
}
|
|
50
|
+
chunks.push(chunk);
|
|
51
|
+
callback();
|
|
58
52
|
} }), { signal });
|
|
59
53
|
const html = Buffer.concat(chunks).toString("utf8");
|
|
60
54
|
if (!html.includes("<head>")) throw new Error("The Enhance canvas panel is not valid HTML.");
|
|
@@ -237,7 +231,7 @@ const createMcpFileDownloadAdapter = (allowedOrigins) => {
|
|
|
237
231
|
if (url.hostname.includes("*") || url.protocol !== "https:" || url.origin !== origin || url.username !== "" || url.password !== "") throw new Error("Hosted file origins must be exact HTTPS origins.");
|
|
238
232
|
return origin;
|
|
239
233
|
}));
|
|
240
|
-
return { download: async (file, maxBytes) => {
|
|
234
|
+
return { download: async (file, maxBytes = Infinity) => {
|
|
241
235
|
const url = new URL(file.download_url);
|
|
242
236
|
if (isIP(url.hostname.replaceAll(/^\[|\]$/gu, "")) !== 0 || url.protocol !== "https:" || !origins.has(url.origin) || url.username !== "" || url.password !== "" || url.hash !== "") throw unavailable();
|
|
243
237
|
const directory = await mkdtemp(path.join(tmpdir(), "enhance-host-file-"));
|
|
@@ -337,7 +331,7 @@ const contentTypeOf = (body) => {
|
|
|
337
331
|
throw new CliError("BAD_REQUEST", "The selected host file is not a supported image or font.", "Select PNG, JPEG, GIF, WebP, AVIF, TTF, OTF, WOFF or WOFF2. No resource was reserved.");
|
|
338
332
|
};
|
|
339
333
|
const createMcpAssetFileAdapter = (files, file) => ({ read: async () => {
|
|
340
|
-
const acquired = await files.download(file
|
|
334
|
+
const acquired = await files.download(file);
|
|
341
335
|
try {
|
|
342
336
|
const body = await readFile(acquired.path);
|
|
343
337
|
const contentType = contentTypeOf(body);
|
|
@@ -409,7 +403,6 @@ const filesOf = async (zip, limits) => new Promise((resolve, reject) => {
|
|
|
409
403
|
const entries = [];
|
|
410
404
|
const paths = /* @__PURE__ */ new Set();
|
|
411
405
|
const prefixes = /* @__PURE__ */ new Map();
|
|
412
|
-
let count = 0;
|
|
413
406
|
let bytes = 0;
|
|
414
407
|
zip.on("error", reject);
|
|
415
408
|
zip.on("end", () => {
|
|
@@ -420,10 +413,9 @@ const filesOf = async (zip, limits) => new Promise((resolve, reject) => {
|
|
|
420
413
|
const name = isDirectory ? entry.fileName.slice(0, -1) : entry.fileName;
|
|
421
414
|
const unixType = entry.externalFileAttributes >>> ATTRIBUTE_BITS & TYPE_MASK;
|
|
422
415
|
const expectedType = isDirectory ? DIRECTORY_TYPE : FILE_TYPE;
|
|
423
|
-
count += 1;
|
|
424
416
|
bytes += entry.uncompressedSize;
|
|
425
417
|
const folded = foldPrototypeArtifactPath(name);
|
|
426
|
-
if (
|
|
418
|
+
if (!isDirectory && limits.fileCount !== void 0 && entries.length >= limits.fileCount || !prototypeArtifactPathSchema.safeParse(name).success || Buffer.byteLength(name) > limits.pathBytes || paths.has(folded) || hasAmbiguousParentPath(prefixes, name) || (entry.generalPurposeBitFlag & 1) !== 0 || ![0, DEFLATE].includes(entry.compressionMethod) || unixType !== 0 && unixType !== expectedType && entry.versionMadeBy >>> BYTE_BITS === UNIX_HOST || isDirectory && entry.uncompressedSize !== 0 || entry.uncompressedSize > limits.fileBytes || limits.expandedBytes !== void 0 && bytes > limits.expandedBytes) {
|
|
427
419
|
reject(invalidArchive());
|
|
428
420
|
return;
|
|
429
421
|
}
|
|
@@ -464,20 +456,9 @@ const createHostedPrototypeZipAdapter = () => ({ extract });
|
|
|
464
456
|
|
|
465
457
|
//#endregion
|
|
466
458
|
//#region src/infrastructure/mcp-prototype-artifact.adapter.ts
|
|
467
|
-
const MAX_ZIP_BYTES = 104857600;
|
|
468
|
-
const MAX_EXPANDED_BYTES = 536870912;
|
|
469
|
-
const MAX_FILE_BYTES = 67108864;
|
|
470
|
-
const MAX_FILES = 1e4;
|
|
471
|
-
const bounded = (limits) => ({
|
|
472
|
-
...limits,
|
|
473
|
-
artifactBytes: Math.min(limits.artifactBytes, MAX_ZIP_BYTES),
|
|
474
|
-
expandedBytes: Math.min(limits.expandedBytes, MAX_EXPANDED_BYTES),
|
|
475
|
-
fileBytes: Math.min(limits.fileBytes, MAX_FILE_BYTES),
|
|
476
|
-
fileCount: Math.min(limits.fileCount, MAX_FILES)
|
|
477
|
-
});
|
|
478
459
|
const createMcpPrototypeArtifactAdapter = (files, file) => ({ package: async (input) => {
|
|
479
460
|
if (file === void 0) throw new CliError("BAD_REQUEST", "A build file is required.", "Select the ZIP to publish.");
|
|
480
|
-
const limits =
|
|
461
|
+
const limits = input.limits;
|
|
481
462
|
const acquired = await files.download(file, limits.artifactBytes);
|
|
482
463
|
let directory = null;
|
|
483
464
|
try {
|
|
@@ -502,26 +483,21 @@ const createMcpPrototypeArtifactAdapter = (files, file) => ({ package: async (in
|
|
|
502
483
|
|
|
503
484
|
//#endregion
|
|
504
485
|
//#region src/infrastructure/mcp-hosted-files.adapter.ts
|
|
486
|
+
const clientContext$1 = createMcpClientContextAdapter();
|
|
505
487
|
const assetInputSchema = canvasAssetImportInputSchema.omit({ source: true }).extend({ file: mcpFileSchema });
|
|
506
488
|
const prototypeInputSchema = canvasPrototypeIntentSchema.extend({ file: mcpFileSchema.optional() });
|
|
507
|
-
const capacity = { active: 0 };
|
|
508
|
-
const MAX_TRANSFERS = 2;
|
|
509
489
|
const transfer = async (action) => {
|
|
510
490
|
const result = createMcpResultAdapter("Select the same host file with a fresh download URL and reuse the original clientToken after uncertainty.");
|
|
511
|
-
if (capacity.active >= MAX_TRANSFERS) return result.failure(new CliError("CONFLICT", "Hosted file transfer is at capacity.", "Retry the identical intent and clientToken after an active transfer finishes."));
|
|
512
|
-
capacity.active += 1;
|
|
513
491
|
try {
|
|
514
492
|
return await action();
|
|
515
493
|
} catch (error) {
|
|
516
494
|
return result.failure(error);
|
|
517
|
-
} finally {
|
|
518
|
-
capacity.active -= 1;
|
|
519
495
|
}
|
|
520
496
|
};
|
|
521
497
|
const registerAsset = (server, input) => {
|
|
522
498
|
server.registerTool("asset_import", {
|
|
523
499
|
title: "Import a canvas asset",
|
|
524
|
-
description: "Import one file explicitly uploaded or selected in this host. Supply its authorized file reference, never a local path or an arbitrary URL. Accepts PNG, JPEG, GIF, WebP, AVIF, TTF, OTF, WOFF or WOFF2
|
|
500
|
+
description: "Import one file explicitly uploaded or selected in this host. Supply its authorized file reference, never a local path or an arbitrary URL. Accepts PNG, JPEG, GIF, WebP, AVIF, TTF, OTF, WOFF or WOFF2; verifies actual bytes and native metadata. Returns a durable resource without placing it or changing the canvas version. Retry with the same bytes and clientToken; a refreshed download URL is allowed.",
|
|
525
501
|
inputSchema: assetInputSchema,
|
|
526
502
|
outputSchema: canvasAssetImportOutputSchema,
|
|
527
503
|
annotations: {
|
|
@@ -531,15 +507,15 @@ const registerAsset = (server, input) => {
|
|
|
531
507
|
openWorldHint: false
|
|
532
508
|
},
|
|
533
509
|
_meta: { "openai/fileParams": ["file"] }
|
|
534
|
-
}, async (args) => transfer(async () => {
|
|
510
|
+
}, async (args, context) => clientContext$1.run(context, async () => transfer(async () => {
|
|
535
511
|
const result = canvasAssetImportOutputSchema.parse(await createImportCanvasAssetComposite(input.remoteFor(args.clientToken), createMcpAssetFileAdapter(input.files, args.file)).execute(args));
|
|
536
512
|
return createMcpResultAdapter("Reconnect Enhance and retry the same intent.").structured(result);
|
|
537
|
-
}));
|
|
513
|
+
})));
|
|
538
514
|
};
|
|
539
515
|
const registerPrototype = (server, input) => {
|
|
540
516
|
server.registerTool("prototype_publish", {
|
|
541
517
|
title: "Publish a prototype to the canvas",
|
|
542
|
-
description: "Publish an uploaded static build ZIP or resume an existing deployment. For source.kind=build supply file and build metadata; use a ZIP with the chosen HTML entry at its stated path.
|
|
518
|
+
description: "Publish an uploaded static build ZIP or resume an existing deployment. For source.kind=build supply file and build metadata; use a ZIP with the chosen HTML entry at its stated path. Runnable builds can execute scripts and contact external services when opened. Preserve the complete canvas reference and baseVersion. Reports ingestion separately from attachment. Retry identical build bytes and clientToken; a fresh download URL is allowed. After attachment conflict, reuse the ready deployment with a new token and deliberate revised baseVersion. Status reads never attach.",
|
|
543
519
|
inputSchema: prototypeInputSchema,
|
|
544
520
|
outputSchema: canvasPrototypeOutputSchema,
|
|
545
521
|
annotations: {
|
|
@@ -549,11 +525,11 @@ const registerPrototype = (server, input) => {
|
|
|
549
525
|
openWorldHint: true
|
|
550
526
|
},
|
|
551
527
|
_meta: { "openai/fileParams": ["file"] }
|
|
552
|
-
}, async ({ file, ...args }) => transfer(async () => {
|
|
528
|
+
}, async ({ file, ...args }, context) => clientContext$1.run(context, async () => transfer(async () => {
|
|
553
529
|
if (args.source.kind === "build" !== (file !== void 0)) throw new CliError("BAD_REQUEST", "Supply a file only when publishing a new build.", "For a new build select its ZIP. To resume an existing deployment, omit file.");
|
|
554
530
|
const result = canvasPrototypeOutputSchema.parse(await createPublishCanvasPrototypeComposite(input.remoteFor(args.clientToken), createMcpPrototypeArtifactAdapter(input.files, file)).execute(args));
|
|
555
531
|
return createMcpResultAdapter("Reconnect Enhance and retry the same intent.").structured(result);
|
|
556
|
-
}));
|
|
532
|
+
})));
|
|
557
533
|
};
|
|
558
534
|
const createMcpHostedFilesAdapter = (input) => ({ register: (server) => {
|
|
559
535
|
registerAsset(server, input);
|
|
@@ -562,13 +538,17 @@ const createMcpHostedFilesAdapter = (input) => ({ register: (server) => {
|
|
|
562
538
|
|
|
563
539
|
//#endregion
|
|
564
540
|
//#region src/infrastructure/mcp-http-profile.adapter.ts
|
|
541
|
+
const clientContext = createMcpClientContextAdapter();
|
|
565
542
|
const createMcpHttpProfileAdapter = (config, catalog, credentialFor, profile) => {
|
|
566
543
|
const files = config.fileOrigins !== void 0 && config.fileOrigins.length > 0 ? createMcpFileDownloadAdapter(config.fileOrigins) : void 0;
|
|
567
544
|
const ui = config.uiUrl === void 0 ? void 0 : createMcpCanvasUiAdapter(config.uiUrl);
|
|
568
545
|
return createMcpHandler(({ authInfo }) => {
|
|
569
546
|
if (authInfo === void 0) throw new Error("authenticated MCP request held no identity");
|
|
570
547
|
const credentials = credentialFor(authInfo.token);
|
|
571
|
-
const hosted = createMcpHostedCapabilitiesAdapter(catalog, createMcpInvocationAdapter(config.apiUrl, credentials, config.configDirectory, {
|
|
548
|
+
const hosted = createMcpHostedCapabilitiesAdapter(catalog, createMcpInvocationAdapter(config.apiUrl, credentials, config.configDirectory, {
|
|
549
|
+
version: config.version,
|
|
550
|
+
connectionPath: "hosted_mcp"
|
|
551
|
+
}));
|
|
572
552
|
return profile.kind === "canvas" ? createMcpCanvasProfileAdapter({
|
|
573
553
|
version: config.version,
|
|
574
554
|
...hosted,
|
|
@@ -580,7 +560,10 @@ const createMcpHttpProfileAdapter = (config, catalog, credentialFor, profile) =>
|
|
|
580
560
|
remoteFor: (clientToken) => {
|
|
581
561
|
const mutationKey = createMutationKeyAdapter();
|
|
582
562
|
mutationKey.select(clientToken, true);
|
|
583
|
-
return createHttpRemoteAdapter(config.apiUrl, credentials, mutationKey
|
|
563
|
+
return createHttpRemoteAdapter(config.apiUrl, credentials, mutationKey, {
|
|
564
|
+
...clientContext.current(),
|
|
565
|
+
path: "hosted_mcp"
|
|
566
|
+
});
|
|
584
567
|
}
|
|
585
568
|
}) },
|
|
586
569
|
readOnly: profile.readOnly
|
|
@@ -614,7 +597,7 @@ const metadataFrom = async (config) => {
|
|
|
614
597
|
};
|
|
615
598
|
const authVerifier = (config) => ({ verifyAccessToken: async (token) => {
|
|
616
599
|
try {
|
|
617
|
-
const remote = createHttpRemoteAdapter(config.apiUrl, credentialFor(token, config.configDirectory), createMutationKeyAdapter());
|
|
600
|
+
const remote = createHttpRemoteAdapter(config.apiUrl, credentialFor(token, config.configDirectory), createMutationKeyAdapter(), { path: "hosted_mcp" });
|
|
618
601
|
const me = getMeOutputSchema.parse(await remote.queryWithToken("person.me", {}, token));
|
|
619
602
|
if (me.authentication.kind !== "oauth-agent" || me.authentication.resource !== config.resourceUrl) throw new OAuthError(OAuthErrorCode.InvalidToken, "token is not valid for Enhance MCP");
|
|
620
603
|
return {
|
|
@@ -746,7 +729,7 @@ const server = await createRemoteMcpHttpAdapter({
|
|
|
746
729
|
fileOrigins: config.MCP_FILE_ORIGINS.split(",").map((value) => value.trim()).filter(Boolean),
|
|
747
730
|
allowedHosts: config.MCP_ALLOWED_HOSTS.split(",").map((value) => value.trim()),
|
|
748
731
|
allowedOrigins: config.MCP_ALLOWED_ORIGINS.split(",").map((value) => value.trim()),
|
|
749
|
-
version: "0.1.
|
|
732
|
+
version: "0.1.33",
|
|
750
733
|
...config.MCP_UI_URL !== void 0 && { uiUrl: config.MCP_UI_URL },
|
|
751
734
|
onerror: (error) => process.stderr.write(`${error.message}\n`)
|
|
752
735
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enhance-eng/enhance",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.33",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Agent-first command-line interface for Enhance.",
|
|
6
6
|
"keywords": [
|
|
@@ -31,14 +31,14 @@
|
|
|
31
31
|
"!dist/*.map"
|
|
32
32
|
],
|
|
33
33
|
"scripts": {
|
|
34
|
-
"build": "tsdown",
|
|
34
|
+
"build": "pnpm --filter @enhance-eng/sdk build && tsdown",
|
|
35
35
|
"build:desktop": "ENHANCE3_DESKTOP_RUNTIME=1 tsdown",
|
|
36
36
|
"prepack": "pnpm run build",
|
|
37
37
|
"test": "pnpm run test:unit && pnpm run test:e2e",
|
|
38
38
|
"test:e2e": "pnpm run build && node e2e/e2e-runner.ts",
|
|
39
39
|
"test:e2e:browser": "pnpm run build && playwright test",
|
|
40
40
|
"test:unit": "vitest run --config vitest.config.ts",
|
|
41
|
-
"typecheck": "tsc --noEmit"
|
|
41
|
+
"typecheck": "pnpm --filter @enhance-eng/sdk build && tsc --noEmit"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@modelcontextprotocol/core": "2.0.0",
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@bcoe/v8-coverage": "1.0.2",
|
|
60
|
+
"@enhance-eng/sdk": "workspace:*",
|
|
60
61
|
"@enhance3/api": "workspace:*",
|
|
61
62
|
"@enhance3/contract": "workspace:*",
|
|
62
63
|
"@enhance3/tsconfig": "workspace:*",
|