@enhance-eng/enhance 0.1.25 → 0.1.37
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-i4KnVAYs.mjs} +3264 -1639
- package/dist/main.mjs +1083 -80
- package/dist/{mcp-invocation.adapter-FuxI6KsE.mjs → mcp-invocation.adapter-CBnzmPZl.mjs} +120 -70
- package/dist/mcp-main.mjs +12 -7
- package/dist/{mcp-server.adapter-D7XwVD-o.mjs → mcp-server.adapter-DC9gAePw.mjs} +110 -35
- package/dist/mcp.mjs +2 -2
- package/dist/{mutation-key.adapter-CXQ08HQY.mjs → mutation-key.adapter-Ck8nOqke.mjs} +385 -193
- package/dist/remote-mcp-main.mjs +28 -45
- package/package.json +6 -9
|
@@ -1,11 +1,62 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { A as operationStatusOutputSchema,
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { A as operationStatusOutputSchema, D as canvasConversionStatusSchema, F as canvasArrangeInputSchema, H as canvasCaptureOutputSchema, L as canvasDuplicateInputSchema, M as canvasAssetImportInputSchema, N as canvasAssetImportOutputSchema, O as operationStatusImageSchema, R as canvasPreparationOutputSchema, S as canvasExchangeDigest, T as encodeCanvasExchangeToken, V as canvasCaptureInputSchema, _n as screenElementsCommentTargetSchema, _t as canvasFindOutputSchema, an as commentMessageSchema, at as canvasRemoveInputSchema, br as createCanvasOutputSchema, cn as domLocatorSchema, ct as canvasReadOutputSchema, dn as listCommentsInputSchema, f as createCapabilityCatalogAdapter, fn as listCommentsOutputSchema, gn as screenElementCommentTargetSchema, gt as canvasFindInputSchema, hn as screenAreaCommentTargetSchema, in as commentCanvasContextSchema, jt as CliError, k as operationStatusInputSchema, kt as parseCanvasReference, ln as elementAnchorSchema, mn as replyCommentOutputSchema, mt as canvasCreateToolOutputSchema, o as toMcpFailurePayload, on as commentResolverSchema, pn as replyCommentInputSchema, pt as canvasCreateToolInputSchema, rn as commentAuthorSchema, sn as commentThreadSchema, st as canvasReadInputSchema, tt as canvasRenderScopedToolInputSchema, un as getCommentOutputSchema, ut as canvasUpdateHtmlInputSchema, vn as screenTextCommentTargetSchema, w as decodeCanvasExchangeToken, x as canvasPrototypeOutputSchema, xt as canvasMakeEditableInputSchema, y as canvasPrototypeInputSchema, yn as startCommentInputSchema, yt as canvasInsertHtmlInputSchema, z as canvasWriteReceiptSchema } from "./cli-output-identity.lib-i4KnVAYs.mjs";
|
|
3
|
+
import { S as createAuthUseCase, h as fromCapabilityReference, m as boundedResultPage, n as createHttpRemoteAdapter, o as createOauthLoopbackAdapter, s as createCapabilityInvocationAdapter, t as createMutationKeyAdapter } from "./mutation-key.adapter-Ck8nOqke.mjs";
|
|
4
|
+
import { a as createMcpResultAdapter, i as mcpDispatchedResultSchema, n as createMcpWorkflowsAdapter, o as createMcpClientContextAdapter, r as createMcpClientInvocationAdapter } from "./mcp-server.adapter-DC9gAePw.mjs";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import { McpServer } from "@modelcontextprotocol/server";
|
|
7
7
|
|
|
8
|
+
//#region src/application/canvas-html-reference.consts.ts
|
|
9
|
+
const CANVAS_HTML_EXAMPLES = {
|
|
10
|
+
retained: "<div data-enhance-id=\"frame\" data-enhance-name=\"Settings\" style=\"width:360px\"><span data-enhance-id=\"title\" data-enhance-name=\"Title\" style=\"font-size:24px\">Account settings</span><div data-enhance-id=\"reference\" data-enhance-name=\"Reference\" data-enhance-opaque=\"true\"></div></div>",
|
|
11
|
+
mixed: "<div data-enhance-id=\"frame\" data-enhance-name=\"Settings\" style=\"width:360px\"><span data-enhance-id=\"title\" data-enhance-name=\"Title\" style=\"font-size:24px\">Your account</span><div style=\"width:320px;height:64px;padding:16px;background:#f4f4f5\"><span style=\"font-size:16px\">Your changes are saved.</span></div><div data-enhance-id=\"reference\" data-enhance-name=\"Reference\" data-enhance-opaque=\"true\"></div></div>"
|
|
12
|
+
};
|
|
13
|
+
const CANVAS_HTML_REFERENCE_URI = "enhance://canvas/html/1";
|
|
14
|
+
const CANVAS_HTML_REFERENCE = `# Canvas HTML exchange, version 1
|
|
15
|
+
|
|
16
|
+
This reference describes the canvas MCP HTML exchange. It is generated from the runtime's checked source and is also available as the MCP resource ${CANVAS_HTML_REFERENCE_URI}. Tool schemas remain authoritative for arguments and returned outcomes. The broader CLI has its own command help.
|
|
17
|
+
|
|
18
|
+
## Read and retain identity
|
|
19
|
+
|
|
20
|
+
Preserve the complete canvas, page or selection reference. Use canvas_read with its editable view and an explicit existing root. An editable read is complete or fails with a narrower-scope remedy; an outline is a different, paginated view. The returned snapshot token binds the scope and observed revision. Submit that exact token and reference with the complete edited root.
|
|
21
|
+
|
|
22
|
+
Retained containers use div; retained text uses span containing plain text. Each retained element keeps data-enhance-id and data-enhance-name. These IDs identify existing objects; never invent, duplicate or copy them into a new object. You may edit the name. Preserve the original root identity. Existing rich-text formatting is reconciled by the text owner; do not add nested markup to retained text.
|
|
23
|
+
|
|
24
|
+
Locked and unsupported objects appear as empty opaque placeholders with data-enhance-opaque="true". Keep them unchanged, including their identity and name. Their hidden descendants are not missing content. The native structural tools remain responsible for moves, duplication and removal, including lock and scope checks.
|
|
25
|
+
|
|
26
|
+
Example returned root (illustrative IDs; use the actual returned IDs):
|
|
27
|
+
|
|
28
|
+
\`\`\`html
|
|
29
|
+
${CANVAS_HTML_EXAMPLES.retained}
|
|
30
|
+
\`\`\`
|
|
31
|
+
|
|
32
|
+
## Edit existing content and add new content
|
|
33
|
+
|
|
34
|
+
Retained elements accept only data-enhance-id, data-enhance-name, data-enhance-opaque and style. Use ordinary inline CSS declarations, with no duplicate property, !important or at-rule. Keep unrelated authored styles. The native style owner validates changes and preserves properties not represented by this projection.
|
|
35
|
+
|
|
36
|
+
Add a populated new subtree without retained identity or opaque markers. New content goes through the same safe HTML compiler as canvas_insert_html, receives fresh identities. Prefer concrete inline CSS and explicit dimensions for each meaningful group. Do not include scripts, event handlers, embedded executable documents or executable URLs. Available content becomes editable even when fidelity is incomplete. Available assets are retained; unavailable assets do not prevent insertion. Importing an asset does not place it.
|
|
37
|
+
|
|
38
|
+
Example complete update changing the title and adding a notice:
|
|
39
|
+
|
|
40
|
+
\`\`\`html
|
|
41
|
+
${CANVAS_HTML_EXAMPLES.mixed}
|
|
42
|
+
\`\`\`
|
|
43
|
+
|
|
44
|
+
A new subtree cannot contain retained IDs or opaque placeholders in version 1. Insert a container and use canvas_arrange to move retained objects into it. New fragments are compiled independently; do not rely on inherited parent measurements or styles. Use explicit child dimensions and styles, then inspect the committed rendering. For a separate screen, prefer canvas_insert_html at an explicit parent and observed baseVersion.
|
|
45
|
+
|
|
46
|
+
## Deletion, commitment and recovery
|
|
47
|
+
|
|
48
|
+
Omission is not implicit deletion. Declare intentional omitted subtrees in removeNodeIds, or call canvas_remove with explicit roots. Locked content prevents the whole invalid edit. A no-op creates no revision. A pending preparation is not a commit: follow operation_status and its continuation until the outcome states whether the canvas changed.
|
|
49
|
+
|
|
50
|
+
Reuse identical arguments and the same clientToken after an uncertain response. A conflict requires a fresh scoped read and deliberate replan. Do not issue a fresh token merely to bypass the conflict or an unknown outcome. Keep the returned revision and identity mappings. Render the affected root at that revision and inspect its pixels; successful compilation alone is not visual verification.
|
|
51
|
+
|
|
52
|
+
## Completeness
|
|
53
|
+
|
|
54
|
+
Submit the complete intended edit. There is no node, source-length or operation-count ceiling. Unsupported optional visual features use the compiler's available representation. Identity, scope, lock and revision checks still govern retained objects and canonical writes.
|
|
55
|
+
`;
|
|
56
|
+
|
|
57
|
+
//#endregion
|
|
8
58
|
//#region src/infrastructure/mcp-canvas-content.adapter.ts
|
|
59
|
+
const clientContext$9 = createMcpClientContextAdapter();
|
|
9
60
|
const READ_ANNOTATIONS = {
|
|
10
61
|
readOnlyHint: true,
|
|
11
62
|
destructiveHint: false,
|
|
@@ -31,7 +82,7 @@ const registerRemoval = (server, invoke) => {
|
|
|
31
82
|
readOnlyHint: false,
|
|
32
83
|
destructiveHint: true
|
|
33
84
|
}
|
|
34
|
-
}, async ({ clientToken, ...args }) => delivered$1(canvasWriteReceiptSchema, async () => invoke("canvas.remove", args, clientToken)));
|
|
85
|
+
}, async ({ clientToken, ...args }, context) => clientContext$9.run(context, async () => delivered$1(canvasWriteReceiptSchema, async () => invoke("canvas.remove", args, clientToken))));
|
|
35
86
|
};
|
|
36
87
|
const registerExchange = (server, invoke, isReadOnly) => {
|
|
37
88
|
server.registerTool("canvas_read", {
|
|
@@ -40,7 +91,7 @@ const registerExchange = (server, invoke, isReadOnly) => {
|
|
|
40
91
|
inputSchema: canvasReadInputSchema,
|
|
41
92
|
outputSchema: canvasReadOutputSchema,
|
|
42
93
|
annotations: READ_ANNOTATIONS
|
|
43
|
-
}, async (args) => delivered$1(canvasReadOutputSchema, async () => invoke("canvas.read", args)));
|
|
94
|
+
}, async (args, context) => clientContext$9.run(context, async () => delivered$1(canvasReadOutputSchema, async () => invoke("canvas.read", args))));
|
|
44
95
|
if (isReadOnly) return;
|
|
45
96
|
server.registerTool("canvas_update_html", {
|
|
46
97
|
title: "Update editable canvas content",
|
|
@@ -52,7 +103,7 @@ const registerExchange = (server, invoke, isReadOnly) => {
|
|
|
52
103
|
readOnlyHint: false,
|
|
53
104
|
destructiveHint: true
|
|
54
105
|
}
|
|
55
|
-
}, async ({ clientToken, ...args }) => delivered$1(canvasPreparationOutputSchema, async () => invoke("canvas.updateHtml", args, clientToken)));
|
|
106
|
+
}, async ({ clientToken, ...args }, context) => clientContext$9.run(context, async () => delivered$1(canvasPreparationOutputSchema, async () => invoke("canvas.updateHtml", args, clientToken))));
|
|
56
107
|
};
|
|
57
108
|
const registerInsertion = (server, invoke) => {
|
|
58
109
|
server.registerTool("canvas_insert_html", {
|
|
@@ -64,7 +115,7 @@ const registerInsertion = (server, invoke) => {
|
|
|
64
115
|
...READ_ANNOTATIONS,
|
|
65
116
|
readOnlyHint: false
|
|
66
117
|
}
|
|
67
|
-
}, async ({ clientToken, ...args }) => delivered$1(canvasConversionStatusSchema, async () => invoke("canvas.insertHtml", args, clientToken)));
|
|
118
|
+
}, async ({ clientToken, ...args }, context) => clientContext$9.run(context, async () => delivered$1(canvasConversionStatusSchema, async () => invoke("canvas.insertHtml", args, clientToken))));
|
|
68
119
|
};
|
|
69
120
|
const registerConversion = (server, invoke) => {
|
|
70
121
|
server.registerTool("canvas_capture", {
|
|
@@ -76,7 +127,7 @@ const registerConversion = (server, invoke) => {
|
|
|
76
127
|
...READ_ANNOTATIONS,
|
|
77
128
|
readOnlyHint: false
|
|
78
129
|
}
|
|
79
|
-
}, async ({ clientToken, ...args }) => delivered$1(canvasCaptureOutputSchema, async () => invoke("canvas.capture", args, clientToken)));
|
|
130
|
+
}, async ({ clientToken, ...args }, context) => clientContext$9.run(context, async () => delivered$1(canvasCaptureOutputSchema, async () => invoke("canvas.capture", args, clientToken))));
|
|
80
131
|
server.registerTool("canvas_make_editable", {
|
|
81
132
|
title: "Make a captured screen editable",
|
|
82
133
|
description: "Convert one supported, root-level captured screen into a new editable subtree beside its source. Preserve the complete page/selection reference. The original screen is retained. This does not reconstruct raster images, crawl prototypes or capture arbitrary websites. Read the bounded loss report, follow operation_status for pending work or remaining mappings, then render the original and result for comparison. Retry uncertainty with identical arguments and clientToken.",
|
|
@@ -86,7 +137,7 @@ const registerConversion = (server, invoke) => {
|
|
|
86
137
|
...READ_ANNOTATIONS,
|
|
87
138
|
readOnlyHint: false
|
|
88
139
|
}
|
|
89
|
-
}, async ({ clientToken, ...args }) => delivered$1(canvasConversionStatusSchema, async () => invoke("canvas.makeEditable", args, clientToken)));
|
|
140
|
+
}, async ({ clientToken, ...args }, context) => clientContext$9.run(context, async () => delivered$1(canvasConversionStatusSchema, async () => invoke("canvas.makeEditable", args, clientToken))));
|
|
90
141
|
};
|
|
91
142
|
const createMcpCanvasContentAdapter = (invoke, isReadOnly) => ({ register: (server) => {
|
|
92
143
|
server.registerResource("canvas-html-v1", CANVAS_HTML_REFERENCE_URI, {
|
|
@@ -107,6 +158,7 @@ const createMcpCanvasContentAdapter = (invoke, isReadOnly) => ({ register: (serv
|
|
|
107
158
|
|
|
108
159
|
//#endregion
|
|
109
160
|
//#region src/infrastructure/mcp-canvas-discovery.adapter.ts
|
|
161
|
+
const clientContext$8 = createMcpClientContextAdapter();
|
|
110
162
|
const annotations$1 = {
|
|
111
163
|
readOnlyHint: true,
|
|
112
164
|
destructiveHint: false,
|
|
@@ -121,14 +173,14 @@ const registerFind = (server, invoke) => {
|
|
|
121
173
|
inputSchema: canvasFindInputSchema,
|
|
122
174
|
outputSchema: canvasFindOutputSchema,
|
|
123
175
|
annotations: annotations$1
|
|
124
|
-
}, async (request) => {
|
|
176
|
+
}, async (request, context) => clientContext$8.run(context, async () => {
|
|
125
177
|
try {
|
|
126
178
|
const result = canvasFindOutputSchema.parse(await invoke("canvas.find", request));
|
|
127
179
|
return createMcpResultAdapter("Reconnect Enhance and retry the same intent.").structured(result);
|
|
128
180
|
} catch (error) {
|
|
129
181
|
return failed(error);
|
|
130
182
|
}
|
|
131
|
-
});
|
|
183
|
+
}));
|
|
132
184
|
};
|
|
133
185
|
const registerCreate = (server, invoke) => {
|
|
134
186
|
server.registerTool("canvas_create", {
|
|
@@ -140,7 +192,7 @@ const registerCreate = (server, invoke) => {
|
|
|
140
192
|
...annotations$1,
|
|
141
193
|
readOnlyHint: false
|
|
142
194
|
}
|
|
143
|
-
}, async ({ destination, title, clientToken }) => {
|
|
195
|
+
}, async ({ destination, title, clientToken }, context) => clientContext$8.run(context, async () => {
|
|
144
196
|
try {
|
|
145
197
|
const created = createCanvasOutputSchema.parse(await invoke("canvas.create", {
|
|
146
198
|
title,
|
|
@@ -162,7 +214,7 @@ const registerCreate = (server, invoke) => {
|
|
|
162
214
|
} catch (error) {
|
|
163
215
|
return failed(error);
|
|
164
216
|
}
|
|
165
|
-
});
|
|
217
|
+
}));
|
|
166
218
|
};
|
|
167
219
|
const createMcpCanvasDiscoveryAdapter = (input) => {
|
|
168
220
|
const invoke = async (id, args, clientToken) => input.invocation.invoke({
|
|
@@ -178,6 +230,7 @@ const createMcpCanvasDiscoveryAdapter = (input) => {
|
|
|
178
230
|
|
|
179
231
|
//#endregion
|
|
180
232
|
//#region src/infrastructure/mcp-canvas-preparation.adapter.ts
|
|
233
|
+
const clientContext$7 = createMcpClientContextAdapter();
|
|
181
234
|
const deliverPreparation = async (action) => {
|
|
182
235
|
try {
|
|
183
236
|
const result = canvasPreparationOutputSchema.parse(await action());
|
|
@@ -211,14 +264,15 @@ const createMcpCanvasPreparationAdapter = (invoke) => ({ register: (server) => {
|
|
|
211
264
|
idempotentHint: true,
|
|
212
265
|
openWorldHint: false
|
|
213
266
|
}
|
|
214
|
-
}, async (offered) => {
|
|
267
|
+
}, async (offered, context) => clientContext$7.run(context, async () => {
|
|
215
268
|
const { clientToken, ...args } = definition.inputSchema.parse(offered);
|
|
216
269
|
return deliverPreparation(async () => invoke(definition.capability, args, clientToken));
|
|
217
|
-
});
|
|
270
|
+
}));
|
|
218
271
|
} });
|
|
219
272
|
|
|
220
273
|
//#endregion
|
|
221
274
|
//#region src/infrastructure/mcp-canvas-render.adapter.ts
|
|
275
|
+
const clientContext$6 = createMcpClientContextAdapter();
|
|
222
276
|
const createMcpCanvasRenderAdapter = (input) => ({ register: (server) => {
|
|
223
277
|
server.registerTool("canvas_render", {
|
|
224
278
|
title: "Inspect canvas pixels",
|
|
@@ -232,7 +286,7 @@ const createMcpCanvasRenderAdapter = (input) => ({ register: (server) => {
|
|
|
232
286
|
idempotentHint: true,
|
|
233
287
|
openWorldHint: false
|
|
234
288
|
}
|
|
235
|
-
}, async ({ clientToken, ...request }) => {
|
|
289
|
+
}, async ({ clientToken, ...request }, context) => clientContext$6.run(context, async () => {
|
|
236
290
|
const results = createMcpResultAdapter("Reconnect Enhance and retry this same render intent.");
|
|
237
291
|
try {
|
|
238
292
|
return {
|
|
@@ -246,11 +300,12 @@ const createMcpCanvasRenderAdapter = (input) => ({ register: (server) => {
|
|
|
246
300
|
} catch (error) {
|
|
247
301
|
return results.failure(error);
|
|
248
302
|
}
|
|
249
|
-
});
|
|
303
|
+
}));
|
|
250
304
|
} });
|
|
251
305
|
|
|
252
306
|
//#endregion
|
|
253
307
|
//#region src/infrastructure/mcp-connection-tools.adapter.ts
|
|
308
|
+
const clientContext$5 = createMcpClientContextAdapter();
|
|
254
309
|
const TOOLS = [{
|
|
255
310
|
name: "connection_status",
|
|
256
311
|
capability: "auth.status",
|
|
@@ -280,7 +335,7 @@ const register = (server, input, config) => {
|
|
|
280
335
|
idempotentHint: config.isReadOnly,
|
|
281
336
|
openWorldHint: !config.isReadOnly
|
|
282
337
|
}
|
|
283
|
-
}, async () => {
|
|
338
|
+
}, async (_args, context) => clientContext$5.run(context, async () => {
|
|
284
339
|
try {
|
|
285
340
|
const result = capability.outputSchema.parse(await input.invocation.invoke({
|
|
286
341
|
capability,
|
|
@@ -291,7 +346,7 @@ const register = (server, input, config) => {
|
|
|
291
346
|
} catch (error) {
|
|
292
347
|
return createMcpResultAdapter("Use connection_connect, complete the returned sign-in URL, then check connection_status.").failure(error);
|
|
293
348
|
}
|
|
294
|
-
});
|
|
349
|
+
}));
|
|
295
350
|
};
|
|
296
351
|
const createMcpConnectionToolsAdapter = (input) => ({ register: (server) => {
|
|
297
352
|
for (const config of TOOLS) if (input.readOnly !== true || config.isReadOnly) register(server, input, config);
|
|
@@ -596,7 +651,8 @@ const packFeedbackMessages = (items, cursor, maxBytes) => {
|
|
|
596
651
|
for (const message of items.slice(offset)) {
|
|
597
652
|
if (bodyOffset >= message.body.length || !message.body.slice(bodyOffset).isWellFormed()) throw invalid$1();
|
|
598
653
|
const full = projectFeedbackMessage(message, bodyOffset, message.body.length);
|
|
599
|
-
|
|
654
|
+
let end = bytes$2(full) <= budget ? message.body.length : fitMessageEnd(message, bodyOffset, budget);
|
|
655
|
+
if (end === bodyOffset && messages.length === 0) end = message.body.length;
|
|
600
656
|
if (end === bodyOffset) break;
|
|
601
657
|
const entry = projectFeedbackMessage(message, bodyOffset, end);
|
|
602
658
|
messages.push(entry);
|
|
@@ -615,19 +671,12 @@ const packFeedbackMessages = (items, cursor, maxBytes) => {
|
|
|
615
671
|
};
|
|
616
672
|
};
|
|
617
673
|
const packFeedbackThreads = (threads, offset, maxBytes) => {
|
|
618
|
-
const items =
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
messagesIncluded: 0
|
|
625
|
-
};
|
|
626
|
-
if (bytes$2(item) > budget) break;
|
|
627
|
-
items.push(item);
|
|
628
|
-
budget -= bytes$2(item);
|
|
629
|
-
}
|
|
630
|
-
return items;
|
|
674
|
+
const items = threads.slice(offset).map((thread) => ({
|
|
675
|
+
thread: projectFeedbackThread(thread),
|
|
676
|
+
openingPreview: feedbackPreview(thread.messages[0]?.body ?? ""),
|
|
677
|
+
messagesIncluded: 0
|
|
678
|
+
}));
|
|
679
|
+
return boundedResultPage(items, 0, items.length, maxBytes).entries;
|
|
631
680
|
};
|
|
632
681
|
|
|
633
682
|
//#endregion
|
|
@@ -702,17 +751,6 @@ const anchorEntries = (anchor) => {
|
|
|
702
751
|
return entries;
|
|
703
752
|
};
|
|
704
753
|
const bytes$1 = (value) => Buffer.byteLength(JSON.stringify(value));
|
|
705
|
-
const bounded = (items, offset, limit, maxBytes) => {
|
|
706
|
-
const entries = [];
|
|
707
|
-
let budget = maxBytes;
|
|
708
|
-
const page = items.slice(offset, offset + limit);
|
|
709
|
-
for (const entry of page) {
|
|
710
|
-
if (bytes$1(entry) > budget) break;
|
|
711
|
-
entries.push(entry);
|
|
712
|
-
budget -= bytes$1(entry);
|
|
713
|
-
}
|
|
714
|
-
return entries;
|
|
715
|
-
};
|
|
716
754
|
const readAnchorThread = async (remote, input, cursor) => {
|
|
717
755
|
if (cursor.nativeCursor !== null || cursor.bodyOffset !== 0) throw new CliError("BAD_REQUEST", "The anchor cursor has an invalid position.", "Repeat the anchor read using its complete cursor.");
|
|
718
756
|
const context = {
|
|
@@ -747,7 +785,7 @@ const readFeedbackAnchor = async (remote, input, cursor) => {
|
|
|
747
785
|
thread,
|
|
748
786
|
omittedMetadata
|
|
749
787
|
}) - FEEDBACK_CURSOR_RESERVE_BYTES;
|
|
750
|
-
const entries =
|
|
788
|
+
const entries = boundedResultPage(items, cursor.offset, input.limit, budget).entries;
|
|
751
789
|
const offset = cursor.offset + entries.length;
|
|
752
790
|
const nextCursor = offset >= items.length ? null : encodeCanvasExchangeToken({
|
|
753
791
|
...cursor,
|
|
@@ -891,8 +929,7 @@ const readFeedback = async (remote, input) => {
|
|
|
891
929
|
} : decodeCanvasExchangeToken(token, feedbackCursorSchema);
|
|
892
930
|
if (cursor.queryDigest !== queryDigest) throw invalid();
|
|
893
931
|
const result = feedbackReadOutputSchema.parse(await (input.view === "threads" ? readThreads(remote, input, cursor) : input.view === "anchor" ? readFeedbackAnchor(remote, input, cursor) : readMessages(remote, input, cursor)));
|
|
894
|
-
|
|
895
|
-
if (bytes(result) > 48e3 || entries.length === 0 && result.nextCursor !== null) throw new CliError("INTERNAL", "Feedback cannot fit within the response budget.", "Read a single thread or reduce the page size. No message was marked as read or resolved.");
|
|
932
|
+
if ((result.view === "threads" ? result.items : result.view === "anchor" ? result.entries : result.messages).length === 0 && result.nextCursor !== null) throw new CliError("INTERNAL", "Feedback pagination did not advance.", "Restart the read. No message was marked as read or resolved.");
|
|
896
933
|
return result;
|
|
897
934
|
};
|
|
898
935
|
|
|
@@ -957,6 +994,7 @@ const resolveFeedback = async (remote, input) => {
|
|
|
957
994
|
|
|
958
995
|
//#endregion
|
|
959
996
|
//#region src/infrastructure/mcp-feedback.adapter.ts
|
|
997
|
+
const clientContext$4 = createMcpClientContextAdapter();
|
|
960
998
|
const annotations = {
|
|
961
999
|
readOnlyHint: false,
|
|
962
1000
|
destructiveHint: false,
|
|
@@ -981,7 +1019,7 @@ const writer = (server, invoke, spec) => {
|
|
|
981
1019
|
...annotations,
|
|
982
1020
|
destructiveHint: spec.destructive
|
|
983
1021
|
}
|
|
984
|
-
}, async (args) => delivered(async () => spec.execute({ mutate: async (id, input) => invoke(id, input, args.clientToken) }, args)));
|
|
1022
|
+
}, async (args, context) => clientContext$4.run(context, async () => delivered(async () => spec.execute({ mutate: async (id, input) => invoke(id, input, args.clientToken) }, args))));
|
|
985
1023
|
};
|
|
986
1024
|
const createMcpFeedbackAdapter = (invoke, isReadOnly = false) => ({ register: (server) => {
|
|
987
1025
|
server.registerTool("feedback_read", {
|
|
@@ -993,7 +1031,7 @@ const createMcpFeedbackAdapter = (invoke, isReadOnly = false) => ({ register: (s
|
|
|
993
1031
|
...annotations,
|
|
994
1032
|
readOnlyHint: true
|
|
995
1033
|
}
|
|
996
|
-
}, async (args) => delivered(async () => readFeedback({ query: async (id, input) => invoke(id, input) }, args)));
|
|
1034
|
+
}, async (args, context) => clientContext$4.run(context, async () => delivered(async () => readFeedback({ query: async (id, input) => invoke(id, input) }, args))));
|
|
997
1035
|
if (isReadOnly) return;
|
|
998
1036
|
writer(server, invoke, {
|
|
999
1037
|
name: "feedback_create",
|
|
@@ -1023,9 +1061,14 @@ const createMcpFeedbackAdapter = (invoke, isReadOnly = false) => ({ register: (s
|
|
|
1023
1061
|
|
|
1024
1062
|
//#endregion
|
|
1025
1063
|
//#region src/infrastructure/mcp-operation-status.adapter.ts
|
|
1064
|
+
const clientContext$3 = createMcpClientContextAdapter();
|
|
1026
1065
|
const deliverStatus = async (server, offered) => {
|
|
1027
1066
|
const image = operationStatusImageSchema.safeParse(offered);
|
|
1028
|
-
const
|
|
1067
|
+
const status = operationStatusOutputSchema.parse(image.success ? image.data.status : offered);
|
|
1068
|
+
const result = image.success && status.kind === "canvas-render" ? {
|
|
1069
|
+
...status,
|
|
1070
|
+
...image.data.localImage.source !== void 0 && { source: image.data.localImage.source }
|
|
1071
|
+
} : status;
|
|
1029
1072
|
const images = (image.success ? await createMcpResultAdapter("Reconnect Enhance.").success(server, image.data.localImage, "embedded") : null)?.content.filter((entry) => entry.type === "image") ?? [];
|
|
1030
1073
|
const response = createMcpResultAdapter("Reconnect Enhance.").structured(result.kind === "canvas-render" && images.length > 0 ? {
|
|
1031
1074
|
...result,
|
|
@@ -1041,7 +1084,7 @@ const deliverStatus = async (server, offered) => {
|
|
|
1041
1084
|
const createMcpOperationStatusAdapter = (input) => ({ register: (server) => {
|
|
1042
1085
|
server.registerTool("operation_status", {
|
|
1043
1086
|
title: "Inspect an existing operation",
|
|
1044
|
-
description: "Read an existing canvas mutation, preparation, render, conversion or prototype deployment. This never starts, resumes or attaches work. Use includeImage true to collect an existing completed render as a native PNG. Page through affected identities, durable copy mappings and conversion issues. A missing mutation receipt means the outcome is unknown; publication readiness does not prove canvas attachment.",
|
|
1087
|
+
description: "Read an existing canvas mutation, preparation, render, conversion or prototype deployment. This never starts, resumes or attaches work. Use includeImage true to collect an existing completed render as a native PNG. A render still queued with attempt above 0 is waiting to retry a failed attempt; repeat the original canvas_render with its clientToken to run it. Page through affected identities, durable copy mappings and conversion issues. A missing mutation receipt means the outcome is unknown; publication readiness does not prove canvas attachment.",
|
|
1045
1088
|
inputSchema: operationStatusInputSchema,
|
|
1046
1089
|
outputSchema: operationStatusOutputSchema,
|
|
1047
1090
|
annotations: {
|
|
@@ -1050,7 +1093,7 @@ const createMcpOperationStatusAdapter = (input) => ({ register: (server) => {
|
|
|
1050
1093
|
idempotentHint: true,
|
|
1051
1094
|
openWorldHint: false
|
|
1052
1095
|
}
|
|
1053
|
-
}, async (request) => {
|
|
1096
|
+
}, async (request, context) => clientContext$3.run(context, async () => {
|
|
1054
1097
|
try {
|
|
1055
1098
|
const offered = await input.invocation.invoke({
|
|
1056
1099
|
capability: fromCapabilityReference(input.catalog, "operation.status"),
|
|
@@ -1061,7 +1104,7 @@ const createMcpOperationStatusAdapter = (input) => ({ register: (server) => {
|
|
|
1061
1104
|
} catch (error) {
|
|
1062
1105
|
return createMcpResultAdapter("Reconnect Enhance and retry this same operation reference.").failure(error);
|
|
1063
1106
|
}
|
|
1064
|
-
});
|
|
1107
|
+
}));
|
|
1065
1108
|
} });
|
|
1066
1109
|
|
|
1067
1110
|
//#endregion
|
|
@@ -1077,10 +1120,11 @@ const createMcpProfileInvocationAdapter = (input) => ({ invoke: async (request)
|
|
|
1077
1120
|
|
|
1078
1121
|
//#endregion
|
|
1079
1122
|
//#region src/infrastructure/mcp-prototype-publish.adapter.ts
|
|
1123
|
+
const clientContext$2 = createMcpClientContextAdapter();
|
|
1080
1124
|
const createMcpPrototypePublishAdapter = (invoke) => ({ register: (server) => {
|
|
1081
1125
|
server.registerTool("prototype_publish", {
|
|
1082
1126
|
title: "Publish a prototype to the canvas",
|
|
1083
|
-
description: "Publish a selected, unpacked static build directory through the native artifact pipeline, or resume its deployment. Runnable builds may execute scripts and contact external services when opened. Preserve the complete canvas/page/selection link and baseVersion. Deployment readiness and canvas attachment are reported separately. Poll operation_status for ingestion; call this tool again to attach. Retry uncertainty with identical arguments and clientToken. After
|
|
1127
|
+
description: "Publish a selected, unpacked static build directory through the native artifact pipeline, or resume its deployment. Runnable builds may execute scripts and contact external services when opened. Preserve the complete canvas/page/selection link and baseVersion. Deployment readiness and canvas attachment are reported separately. Poll operation_status for ingestion; call this tool again to attach. Retry uncertainty with identical arguments and clientToken. After an unrelated canvas edit, reuse the ready deployment and clientToken with a deliberate revised baseVersion; do not re-upload. A changed destination or scope requires a new attachment intent. This does not build source code or verify the resulting UI.",
|
|
1084
1128
|
inputSchema: canvasPrototypeInputSchema,
|
|
1085
1129
|
outputSchema: canvasPrototypeOutputSchema,
|
|
1086
1130
|
annotations: {
|
|
@@ -1089,22 +1133,23 @@ const createMcpPrototypePublishAdapter = (invoke) => ({ register: (server) => {
|
|
|
1089
1133
|
idempotentHint: true,
|
|
1090
1134
|
openWorldHint: true
|
|
1091
1135
|
}
|
|
1092
|
-
}, async ({ clientToken, ...args }) => {
|
|
1136
|
+
}, async ({ clientToken, ...args }, context) => clientContext$2.run(context, async () => {
|
|
1093
1137
|
try {
|
|
1094
1138
|
const result = canvasPrototypeOutputSchema.parse(await invoke("prototype.publishCanvas", args, clientToken));
|
|
1095
1139
|
return createMcpResultAdapter("Reconnect Enhance and retry the same intent.").structured(result);
|
|
1096
1140
|
} catch (error) {
|
|
1097
1141
|
return createMcpResultAdapter("Retry the original publishing request and clientToken after reconnecting; do not infer that a lost response means no changes.").failure(error);
|
|
1098
1142
|
}
|
|
1099
|
-
});
|
|
1143
|
+
}));
|
|
1100
1144
|
} });
|
|
1101
1145
|
|
|
1102
1146
|
//#endregion
|
|
1103
1147
|
//#region src/infrastructure/mcp-asset-import.adapter.ts
|
|
1148
|
+
const clientContext$1 = createMcpClientContextAdapter();
|
|
1104
1149
|
const createMcpAssetImportAdapter = (invoke) => ({ register: (server) => {
|
|
1105
1150
|
server.registerTool("asset_import", {
|
|
1106
1151
|
title: "Import a canvas asset",
|
|
1107
|
-
description: "Import one explicitly selected local image or font
|
|
1152
|
+
description: "Import one explicitly selected local image or font. Verifies actual bytes and format. Returns a durable native resource and metadata without placing content or changing the canvas version. Use the resource in a subsequent explicit authoring action. Retry the same file and clientToken after uncertainty, or inspect the returned operation reference.",
|
|
1108
1153
|
inputSchema: canvasAssetImportInputSchema,
|
|
1109
1154
|
outputSchema: canvasAssetImportOutputSchema,
|
|
1110
1155
|
annotations: {
|
|
@@ -1113,7 +1158,7 @@ const createMcpAssetImportAdapter = (invoke) => ({ register: (server) => {
|
|
|
1113
1158
|
idempotentHint: true,
|
|
1114
1159
|
openWorldHint: false
|
|
1115
1160
|
}
|
|
1116
|
-
}, async (offered) => {
|
|
1161
|
+
}, async (offered, context) => clientContext$1.run(context, async () => {
|
|
1117
1162
|
try {
|
|
1118
1163
|
const { clientToken, ...input } = canvasAssetImportInputSchema.parse(offered);
|
|
1119
1164
|
const result = canvasAssetImportOutputSchema.parse(await invoke("canvas.importAsset", input, clientToken));
|
|
@@ -1121,7 +1166,7 @@ const createMcpAssetImportAdapter = (invoke) => ({ register: (server) => {
|
|
|
1121
1166
|
} catch (error) {
|
|
1122
1167
|
return createMcpResultAdapter("Retry the same selected file and clientToken.").failure(error);
|
|
1123
1168
|
}
|
|
1124
|
-
});
|
|
1169
|
+
}));
|
|
1125
1170
|
} });
|
|
1126
1171
|
|
|
1127
1172
|
//#endregion
|
|
@@ -1146,6 +1191,7 @@ const createMcpCanvasProfileAdapter = (input) => {
|
|
|
1146
1191
|
const authentication = input.authentication ?? "local";
|
|
1147
1192
|
const invocation = createMcpProfileInvocationAdapter({
|
|
1148
1193
|
...input,
|
|
1194
|
+
invocation: createMcpClientInvocationAdapter(input.invocation, input.clientMetadata),
|
|
1149
1195
|
catalog,
|
|
1150
1196
|
readOnly: isReadOnly,
|
|
1151
1197
|
authentication
|
|
@@ -1225,15 +1271,16 @@ const createMcpAuthAdapter = (credentials, remote) => {
|
|
|
1225
1271
|
let active = null;
|
|
1226
1272
|
let state = null;
|
|
1227
1273
|
return {
|
|
1228
|
-
login: async (offered) => {
|
|
1274
|
+
login: async (offered, requestRemote = remote) => {
|
|
1229
1275
|
if (active !== null) return active.ready;
|
|
1230
1276
|
const input = loginInputSchema.parse(offered);
|
|
1231
1277
|
const controller = new AbortController();
|
|
1232
1278
|
const ready = Promise.withResolvers();
|
|
1279
|
+
const requestAuth = createAuthUseCase(credentials, requestRemote, createOauthLoopbackAdapter(requestRemote));
|
|
1233
1280
|
state = null;
|
|
1234
1281
|
const complete = async () => {
|
|
1235
1282
|
try {
|
|
1236
|
-
await
|
|
1283
|
+
await requestAuth.loginWithBrowser({
|
|
1237
1284
|
label: "Agent plugin",
|
|
1238
1285
|
openBrowser: input.openBrowser,
|
|
1239
1286
|
signal: controller.signal,
|
|
@@ -1266,10 +1313,10 @@ const createMcpAuthAdapter = (credentials, remote) => {
|
|
|
1266
1313
|
};
|
|
1267
1314
|
return ready.promise;
|
|
1268
1315
|
},
|
|
1269
|
-
status: async () => {
|
|
1316
|
+
status: async (requestRemote = remote) => {
|
|
1270
1317
|
if (state !== null) return state;
|
|
1271
1318
|
if (await credentials.read() === null) return { authenticated: false };
|
|
1272
|
-
return auth.status();
|
|
1319
|
+
return auth.status(requestRemote);
|
|
1273
1320
|
},
|
|
1274
1321
|
logout: async () => {
|
|
1275
1322
|
active?.controller.abort();
|
|
@@ -1282,6 +1329,7 @@ const createMcpAuthAdapter = (credentials, remote) => {
|
|
|
1282
1329
|
|
|
1283
1330
|
//#endregion
|
|
1284
1331
|
//#region src/infrastructure/mcp-invocation.adapter.ts
|
|
1332
|
+
const clientContext = createMcpClientContextAdapter();
|
|
1285
1333
|
const TRANSPORT_CAPABILITIES = /* @__PURE__ */ new Set([
|
|
1286
1334
|
"auth.login",
|
|
1287
1335
|
"auth.logout",
|
|
@@ -1290,9 +1338,9 @@ const TRANSPORT_CAPABILITIES = /* @__PURE__ */ new Set([
|
|
|
1290
1338
|
]);
|
|
1291
1339
|
const invokeTransport = async (input) => {
|
|
1292
1340
|
switch (input.capability) {
|
|
1293
|
-
case "auth.login": return input.auth.login(input.arguments);
|
|
1341
|
+
case "auth.login": return input.auth.login(input.arguments, input.remote);
|
|
1294
1342
|
case "auth.logout": return input.auth.logout();
|
|
1295
|
-
case "auth.status": return input.auth.status();
|
|
1343
|
+
case "auth.status": return input.auth.status(input.remote);
|
|
1296
1344
|
case "doctor": {
|
|
1297
1345
|
const [api, credential] = await Promise.all([input.remote.health(), input.credentials.read()]);
|
|
1298
1346
|
return {
|
|
@@ -1311,19 +1359,21 @@ const invokeTransport = async (input) => {
|
|
|
1311
1359
|
};
|
|
1312
1360
|
const createMcpInvocationAdapter = (apiUrl, credentials, configDirectory, options) => {
|
|
1313
1361
|
const { version, desktop } = options;
|
|
1314
|
-
const
|
|
1315
|
-
const auth = createMcpAuthAdapter(credentials, transportRemote);
|
|
1362
|
+
const auth = createMcpAuthAdapter(credentials, createHttpRemoteAdapter(apiUrl, credentials, createMutationKeyAdapter()));
|
|
1316
1363
|
return { invoke: async (request) => {
|
|
1364
|
+
const mutationKey = createMutationKeyAdapter();
|
|
1365
|
+
const remote = createHttpRemoteAdapter(apiUrl, credentials, mutationKey, {
|
|
1366
|
+
...request.clientMetadata ?? clientContext.current(),
|
|
1367
|
+
path: options.connectionPath ?? "local_mcp"
|
|
1368
|
+
});
|
|
1317
1369
|
if (TRANSPORT_CAPABILITIES.has(request.capability.id)) return invokeTransport({
|
|
1318
1370
|
capability: request.capability.id,
|
|
1319
1371
|
arguments: request.arguments,
|
|
1320
1372
|
credentials,
|
|
1321
|
-
remote
|
|
1373
|
+
remote,
|
|
1322
1374
|
version,
|
|
1323
1375
|
auth
|
|
1324
1376
|
});
|
|
1325
|
-
const mutationKey = createMutationKeyAdapter();
|
|
1326
|
-
const remote = createHttpRemoteAdapter(apiUrl, credentials, mutationKey);
|
|
1327
1377
|
return createCapabilityInvocationAdapter({
|
|
1328
1378
|
remote: desktop === void 0 ? remote : createDesktopScopedRemoteAdapter(remote, desktop.scope, desktop.observer, mutationKey),
|
|
1329
1379
|
mutationKey,
|
package/dist/mcp-main.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { f as createCapabilityCatalogAdapter, h as toCapabilityDefinition } from "./cli-output-identity.lib-
|
|
3
|
-
import { i as readLocalMcpEnvironment } from "./mutation-key.adapter-
|
|
2
|
+
import { f as createCapabilityCatalogAdapter, h as toCapabilityDefinition } from "./cli-output-identity.lib-i4KnVAYs.mjs";
|
|
3
|
+
import { i as readLocalMcpEnvironment } from "./mutation-key.adapter-Ck8nOqke.mjs";
|
|
4
4
|
import { t as createFileCredentialAdapter } from "./file-credential.adapter-C78gc9OK.mjs";
|
|
5
|
-
import { t as
|
|
6
|
-
import {
|
|
5
|
+
import { n as createMcpCanvasProfileAdapter, t as createMcpInvocationAdapter } from "./mcp-invocation.adapter-CBnzmPZl.mjs";
|
|
6
|
+
import { o as createMcpClientContextAdapter, t as createMcpServerAdapter } from "./mcp-server.adapter-DC9gAePw.mjs";
|
|
7
7
|
import process from "node:process";
|
|
8
8
|
import { z } from "zod";
|
|
9
9
|
import { serveStdio } from "@modelcontextprotocol/server/stdio";
|
|
@@ -166,28 +166,33 @@ const createMcpTransportCapabilityAdapter = () => capabilities;
|
|
|
166
166
|
|
|
167
167
|
//#endregion
|
|
168
168
|
//#region src/mcp-main.ts
|
|
169
|
+
const clientContext = createMcpClientContextAdapter();
|
|
169
170
|
const main = () => {
|
|
170
171
|
const config = readLocalMcpEnvironment();
|
|
171
172
|
const credentials = createFileCredentialAdapter(config.configDirectory);
|
|
172
|
-
const invocation = createMcpInvocationAdapter(config.apiUrl, credentials, config.configDirectory, { version: "0.1.
|
|
173
|
+
const invocation = createMcpInvocationAdapter(config.apiUrl, credentials, config.configDirectory, { version: "0.1.37" });
|
|
173
174
|
const catalog = [...createCapabilityCatalogAdapter(), ...createMcpTransportCapabilityAdapter()];
|
|
175
|
+
const client = clientContext.createStdio();
|
|
174
176
|
serveStdio(() => config.profile === "canvas" ? createMcpCanvasProfileAdapter({
|
|
175
177
|
readOnly: config.isReadOnly,
|
|
176
178
|
...config.workflowsDirectory !== void 0 && { workflowsDirectory: config.workflowsDirectory },
|
|
177
179
|
name: config.mcpServiceName,
|
|
178
|
-
version: "0.1.
|
|
180
|
+
version: "0.1.37",
|
|
179
181
|
invocation,
|
|
182
|
+
clientMetadata: client.metadata,
|
|
180
183
|
catalog
|
|
181
184
|
}) : createMcpServerAdapter({
|
|
182
|
-
version: "0.1.
|
|
185
|
+
version: "0.1.37",
|
|
183
186
|
name: config.mcpServiceName,
|
|
184
187
|
commandName: config.commandName,
|
|
185
188
|
invocation,
|
|
189
|
+
clientMetadata: client.metadata,
|
|
186
190
|
catalog,
|
|
187
191
|
exposures: ["shared", "mcp-transport"],
|
|
188
192
|
...config.workflowsDirectory !== void 0 && { workflowsDirectory: config.workflowsDirectory }
|
|
189
193
|
}), {
|
|
190
194
|
legacy: "serve",
|
|
195
|
+
transport: client.transport,
|
|
191
196
|
onerror: () => process.stderr.write(`${config.mcpServiceName} transport failure\n`)
|
|
192
197
|
});
|
|
193
198
|
};
|