@enhance-eng/enhance 0.1.167 → 0.1.170
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-DbOpumEM.mjs → cli-output-identity.lib-CKns8qEG.mjs} +2211 -1719
- package/dist/main.mjs +678 -475
- package/dist/{mcp-invocation.adapter-CUyCBfrk.mjs → mcp-invocation.adapter-BfWB3PFL.mjs} +63 -38
- package/dist/mcp-main.mjs +9 -9
- package/dist/{mcp-server.adapter-KDg3Ektd.mjs → mcp-server.adapter-UiOcYGPZ.mjs} +109 -84
- package/dist/mcp.mjs +2 -2
- package/dist/remote-mcp-main.mjs +47 -15
- package/dist/{zod-messages.lib-Cs57z-_f.mjs → zod-messages.lib-G2BtVFRk.mjs} +3658 -3175
- package/package.json +2 -1
package/dist/remote-mcp-main.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { $ as canvasAssetImportInputSchema,
|
|
3
|
-
import { h as createImportCanvasAssetComposite, m as createPublishCanvasPrototypeComposite, n as createMutationKeyAdapter, o as readRemoteMcpEnvironment, p as createPrototypeArtifactAdapter, r as createHttpRemoteAdapter, t as installZodMessages } from "./zod-messages.lib-
|
|
4
|
-
import {
|
|
5
|
-
import { n as createMcpCanvasProfileAdapter, t as createMcpInvocationAdapter } from "./mcp-invocation.adapter-
|
|
2
|
+
import { $ as canvasAssetImportInputSchema, An as getMeOutputSchema, L as canvasPrototypeIntentSchema, On as prototypeArtifactPathSchema, R as canvasPrototypeOutputSchema, S as PROTOTYPE_UPDATE_GUIDANCE, an as MCP_TOOL_BY_CAPABILITY, dn as CliError, et as canvasAssetImportOutputSchema, jn as MCP_AUTH_SCOPE, ln as skillTextsFor, wn as foldPrototypeArtifactPath, yi as signedDownloadSchema } from "./cli-output-identity.lib-CKns8qEG.mjs";
|
|
3
|
+
import { h as createImportCanvasAssetComposite, m as createPublishCanvasPrototypeComposite, n as createMutationKeyAdapter, o as readRemoteMcpEnvironment, p as createPrototypeArtifactAdapter, r as createHttpRemoteAdapter, t as installZodMessages } from "./zod-messages.lib-G2BtVFRk.mjs";
|
|
4
|
+
import { c as withClientTokenNamed, l as createMcpClientContextAdapter, o as createMcpResultAdapter, s as toolClientToken, t as createMcpServerAdapter, u as createCapabilityCatalogAdapter } from "./mcp-server.adapter-UiOcYGPZ.mjs";
|
|
5
|
+
import { n as createMcpCanvasProfileAdapter, t as createMcpInvocationAdapter } from "./mcp-invocation.adapter-BfWB3PFL.mjs";
|
|
6
6
|
import process from "node:process";
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
import { mkdir, mkdtemp, readFile, rm } from "node:fs/promises";
|
|
@@ -21,6 +21,18 @@ import { lookup } from "node:dns/promises";
|
|
|
21
21
|
import { BlockList, isIP } from "node:net";
|
|
22
22
|
import { open as open$1 } from "yauzl";
|
|
23
23
|
|
|
24
|
+
//#region src/infrastructure/api-refusal.lib.ts
|
|
25
|
+
const refusedByApiSchema = z.object({ data: z.looseObject({ code: z.literal("UNAUTHORIZED") }) });
|
|
26
|
+
/**
|
|
27
|
+
* Whether the API itself refused the credential. Only that says the credential is bad: a check
|
|
28
|
+
* that could not be made says nothing about it, and answering "invalid" for one sends a signed-in
|
|
29
|
+
* person to sign in again.
|
|
30
|
+
*/
|
|
31
|
+
const isApiRefusal = (error) => error instanceof CliError ? error.code === "UNAUTHORIZED" : refusedByApiSchema.safeParse(error).success;
|
|
32
|
+
/** What to log when the check could not be made: the reason, which names no token. */
|
|
33
|
+
const uncheckedTokenError = (error) => /* @__PURE__ */ new Error(`token verification could not be made: ${error instanceof Error ? error.message : "unknown failure"}`);
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
24
36
|
//#region src/infrastructure/mcp-canvas-ui.adapter.ts
|
|
25
37
|
const HTTP_OK$1 = 200;
|
|
26
38
|
const UI_TIMEOUT_MS = 15e3;
|
|
@@ -537,12 +549,14 @@ const selectedFile = async (remote, source) => {
|
|
|
537
549
|
if (source.file !== void 0 && source.stagedUploadId !== void 0) throw new CliError("BAD_REQUEST", "Supply either a file or a staged upload, not both.", "Select one file and retry with the same clientToken.");
|
|
538
550
|
return source.stagedUploadId === void 0 ? source.file : stagedFile(remote, source.stagedUploadId);
|
|
539
551
|
};
|
|
540
|
-
|
|
552
|
+
/** A transfer's answer, which names the retry token it used: the agent's, or one the tool made. */
|
|
553
|
+
const transfer = async (given, action) => {
|
|
554
|
+
const clientToken = toolClientToken(given);
|
|
541
555
|
const result = createMcpResultAdapter("Select the same host file with a fresh download URL and reuse the original clientToken after uncertainty.");
|
|
542
556
|
try {
|
|
543
|
-
return await action();
|
|
557
|
+
return withClientTokenNamed(await action(clientToken), clientToken);
|
|
544
558
|
} catch (error) {
|
|
545
|
-
return result.failure(error);
|
|
559
|
+
return withClientTokenNamed(result.failure(error), clientToken);
|
|
546
560
|
}
|
|
547
561
|
};
|
|
548
562
|
const registerAsset = (server, input) => {
|
|
@@ -558,11 +572,14 @@ const registerAsset = (server, input) => {
|
|
|
558
572
|
openWorldHint: false
|
|
559
573
|
},
|
|
560
574
|
_meta: { "openai/fileParams": ["file"] }
|
|
561
|
-
}, async (args, context) => clientContext$1.run(context, async () => transfer(async () => {
|
|
562
|
-
const remote = input.remoteFor(
|
|
575
|
+
}, async (args, context) => clientContext$1.run(context, async () => transfer(args.clientToken, async (clientToken) => {
|
|
576
|
+
const remote = input.remoteFor(clientToken);
|
|
563
577
|
const file = await selectedFile(remote, args);
|
|
564
578
|
if (file === void 0) throw new CliError("BAD_REQUEST", "No file was selected.", "Select the file to import and retry with the same clientToken.");
|
|
565
|
-
const result = canvasAssetImportOutputSchema.parse(await createImportCanvasAssetComposite(remote, createMcpAssetFileAdapter(input.files, file)).execute(
|
|
579
|
+
const result = canvasAssetImportOutputSchema.parse(await createImportCanvasAssetComposite(remote, createMcpAssetFileAdapter(input.files, file)).execute({
|
|
580
|
+
...args,
|
|
581
|
+
clientToken
|
|
582
|
+
}));
|
|
566
583
|
return createMcpResultAdapter("Reconnect Enhance and retry the same intent.").structured(result);
|
|
567
584
|
})));
|
|
568
585
|
};
|
|
@@ -579,14 +596,17 @@ const registerPrototype = (server, input) => {
|
|
|
579
596
|
openWorldHint: true
|
|
580
597
|
},
|
|
581
598
|
_meta: { "openai/fileParams": ["file"] }
|
|
582
|
-
}, async ({ file: selected, stagedUploadId, ...args }, context) => clientContext$1.run(context, async () => transfer(async () => {
|
|
583
|
-
const remote = input.remoteFor(
|
|
599
|
+
}, async ({ file: selected, stagedUploadId, ...args }, context) => clientContext$1.run(context, async () => transfer(args.clientToken, async (clientToken) => {
|
|
600
|
+
const remote = input.remoteFor(clientToken);
|
|
584
601
|
const file = await selectedFile(remote, {
|
|
585
602
|
file: selected,
|
|
586
603
|
stagedUploadId
|
|
587
604
|
});
|
|
588
605
|
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.");
|
|
589
|
-
const result = canvasPrototypeOutputSchema.parse(await createPublishCanvasPrototypeComposite(remote, createMcpPrototypeArtifactAdapter(input.files, file)).execute(
|
|
606
|
+
const result = canvasPrototypeOutputSchema.parse(await createPublishCanvasPrototypeComposite(remote, createMcpPrototypeArtifactAdapter(input.files, file)).execute({
|
|
607
|
+
...args,
|
|
608
|
+
clientToken
|
|
609
|
+
}));
|
|
590
610
|
return createMcpResultAdapter("Reconnect Enhance and retry the same intent.").structured(result);
|
|
591
611
|
})));
|
|
592
612
|
};
|
|
@@ -598,6 +618,14 @@ const createMcpHostedFilesAdapter = (input) => ({ register: (server) => {
|
|
|
598
618
|
//#endregion
|
|
599
619
|
//#region src/infrastructure/mcp-http-profile.adapter.ts
|
|
600
620
|
const clientContext = createMcpClientContextAdapter();
|
|
621
|
+
/**
|
|
622
|
+
* What `workflow_guide` answers with on a hosted connection: the skills of the one source, worded
|
|
623
|
+
* for tools, where the plugin's own server reads the folder its build wrote from that source.
|
|
624
|
+
*/
|
|
625
|
+
const workflows = skillTextsFor({
|
|
626
|
+
surface: "mcp",
|
|
627
|
+
nameOf: (capability) => MCP_TOOL_BY_CAPABILITY[capability]
|
|
628
|
+
});
|
|
601
629
|
/** The tools that import a file, fetching only from the origins `files` allows. */
|
|
602
630
|
const hostedFilesFor = (files, apiUrl, credentials) => createMcpHostedFilesAdapter({
|
|
603
631
|
files,
|
|
@@ -624,6 +652,7 @@ const createMcpHttpProfileAdapter = (config, catalog, credentialFor, profile) =>
|
|
|
624
652
|
}));
|
|
625
653
|
return profile.kind === "canvas" ? createMcpCanvasProfileAdapter({
|
|
626
654
|
version: config.version,
|
|
655
|
+
workflows,
|
|
627
656
|
...hosted,
|
|
628
657
|
delivery: "embedded",
|
|
629
658
|
authentication: "oauth",
|
|
@@ -632,6 +661,7 @@ const createMcpHttpProfileAdapter = (config, catalog, credentialFor, profile) =>
|
|
|
632
661
|
readOnly: profile.readOnly
|
|
633
662
|
}) : createMcpServerAdapter({
|
|
634
663
|
version: config.version,
|
|
664
|
+
workflows,
|
|
635
665
|
...hosted,
|
|
636
666
|
delivery: "embedded"
|
|
637
667
|
});
|
|
@@ -700,7 +730,9 @@ const authVerifier = (config) => ({ verifyAccessToken: async (token) => {
|
|
|
700
730
|
};
|
|
701
731
|
} catch (error) {
|
|
702
732
|
if (OAuthError.isInstance(error)) throw error;
|
|
703
|
-
|
|
733
|
+
const code = isApiRefusal(error) ? OAuthErrorCode.InvalidToken : OAuthErrorCode.ServerError;
|
|
734
|
+
if (code === OAuthErrorCode.ServerError) config.onerror(uncheckedTokenError(error));
|
|
735
|
+
throw new OAuthError(code, "token verification failed");
|
|
704
736
|
}
|
|
705
737
|
} });
|
|
706
738
|
const healthResponse = () => Response.json({
|
|
@@ -818,7 +850,7 @@ const server = await createRemoteMcpHttpAdapter({
|
|
|
818
850
|
...config.MCP_STAGED_UPLOAD_ORIGIN !== void 0 && { stagedUploadOrigin: config.MCP_STAGED_UPLOAD_ORIGIN },
|
|
819
851
|
allowedHosts: config.MCP_ALLOWED_HOSTS.split(",").map((value) => value.trim()),
|
|
820
852
|
allowedOrigins: config.MCP_ALLOWED_ORIGINS.split(",").map((value) => value.trim()),
|
|
821
|
-
version: "0.1.
|
|
853
|
+
version: "0.1.170",
|
|
822
854
|
...config.MCP_UI_URL !== void 0 && { uiUrl: config.MCP_UI_URL },
|
|
823
855
|
onerror: (error) => process.stderr.write(`${error.message}\n`)
|
|
824
856
|
});
|