@enhance-eng/enhance 0.1.160 → 0.1.165

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.
@@ -1,10 +1,18 @@
1
1
  #!/usr/bin/env node
2
- import { A as operationStatusImageSchema, B as canvasPreparationOutputSchema, C as canvasPrototypeOutputSchema, Ct as canvasMakeEditableInputSchema, D as encodeCanvasExchangeToken, E as decodeCanvasExchangeToken, F as canvasAssetImportOutputSchema, Fr as createCanvasOutputSchema, L as canvasArrangeInputSchema, M as operationStatusOutputSchema, Nt as CliError, P as canvasAssetImportInputSchema, U as canvasCaptureInputSchema, V as canvasWriteReceiptSchema, W as canvasCaptureOutputSchema, _n as screenAreaCommentTargetSchema, an as commentAuthorSchema, bn as screenTextCommentTargetSchema, cn as commentResolverSchema, dn as elementAnchorSchema, fn as getCommentOutputSchema, ft as canvasUpdateHtmlInputSchema, gn as replyCommentOutputSchema, gt as canvasCreateToolOutputSchema, hn as replyCommentInputSchema, ht as canvasCreateToolInputSchema, j as operationStatusInputSchema, jt as parseCanvasReference, k as canvasConversionStatusSchema, l as toMcpFailurePayload, ln as commentThreadSchema, lt as canvasReadInputSchema, mn as listCommentsOutputSchema, on as commentCanvasContextSchema, p as createCapabilityCatalogAdapter, pn as listCommentsInputSchema, rt as canvasRenderScopedToolInputSchema, sn as commentMessageSchema, st as canvasRemoveInputSchema, un as domLocatorSchema, ut as canvasReadOutputSchema, v as PROTOTYPE_UPDATE_GUIDANCE, vn as screenElementCommentTargetSchema, vt as canvasFindInputSchema, w as canvasExchangeDigest, x as canvasPrototypeInputSchema, xn as startCommentInputSchema, xt as canvasInsertHtmlInputSchema, yn as screenElementsCommentTargetSchema, yt as canvasFindOutputSchema, z as canvasDuplicateInputSchema } from "./cli-output-identity.lib-DrfKWcGw.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-DFjvJyX6.mjs";
4
- import { a as createMcpResultAdapter, i as mcpDispatchedResultSchema, n as createMcpWorkflowsAdapter, o as createMcpClientContextAdapter, r as createMcpClientInvocationAdapter } from "./mcp-server.adapter-YQLl2Wec.mjs";
2
+ import { $ as canvasAssetImportInputSchema, B as operationStatusImageSchema, Bn as listCommentsInputSchema, Fn as commentResolverSchema, Ft as canvasReadInputSchema, G as canvasCaptureOutputSchema, Gn as screenElementCommentTargetSchema, H as operationStatusOutputSchema, Hn as replyCommentInputSchema, I as canvasPrototypeInputSchema, In as commentThreadSchema, It as canvasReadOutputSchema, Jn as startCommentInputSchema, Kn as screenElementsCommentTargetSchema, Kt as parseCanvasReference, Ln as domLocatorSchema, Mn as commentAuthorSchema, Mt as encodeCanvasExchangeToken, N as canvasCapturePageInputSchema, Nn as commentCanvasContextSchema, P as canvasCapturePageOutputSchema, Pn as commentMessageSchema, R as canvasPrototypeOutputSchema, Rn as elementAnchorSchema, Rt as canvasUpdateHtmlInputSchema, S as PROTOTYPE_UPDATE_GUIDANCE, Un as replyCommentOutputSchema, V as operationStatusInputSchema, Vn as listCommentsOutputSchema, W as canvasCaptureInputSchema, Wn as screenAreaCommentTargetSchema, X as canvasPreparationOutputSchema, Y as canvasDuplicateInputSchema, Z as canvasWriteReceiptSchema, an as CliError, at as canvasRenderScopedToolInputSchema, bt as canvasMakeEditableInputSchema, dt as canvasCreateToolOutputSchema, et as canvasAssetImportOutputSchema, ht as createdCanvasAnswerSchema, jt as decodeCanvasExchangeToken, kt as canvasExchangeDigest, lt as canvasRemoveInputSchema, m as toMcpFailurePayload, mt as canvasFindOutputSchema, o as CAPTURE_PAGE_CALLS, pt as canvasFindInputSchema, q as canvasArrangeInputSchema, qn as screenTextCommentTargetSchema, rn as MCP_TOOL_BY_CAPABILITY, ut as canvasCreateToolInputSchema, vt as canvasInsertHtmlInputSchema, z as canvasConversionStatusSchema, zn as getCommentOutputSchema } from "./cli-output-identity.lib-Z9ISwnoo.mjs";
3
+ import { T as createAuthUseCase, c as createOauthLoopbackAdapter, f as createCapabilityInvocationAdapter, n as createMutationKeyAdapter, r as createHttpRemoteAdapter, u as withCapabilityNames, y as boundedResultPage } from "./zod-messages.lib-BrqCGdLn.mjs";
4
+ import { a as createMcpResultAdapter, i as mcpDispatchedResultSchema, n as createMcpWorkflowsAdapter, o as createMcpClientContextAdapter, r as createMcpClientInvocationAdapter, s as createCapabilityCatalogAdapter } from "./mcp-server.adapter-DJ2BZrIw.mjs";
5
5
  import { z } from "zod";
6
6
  import { McpServer } from "@modelcontextprotocol/server";
7
7
 
8
+ //#region src/infrastructure/capability-reference.mapper.ts
9
+ const fromCapabilityReference = (catalog, id) => {
10
+ const capability = catalog.find((candidate) => candidate.id === id);
11
+ if (capability === void 0) throw new TypeError(`${id} is missing from the capability catalogue`);
12
+ return capability;
13
+ };
14
+
15
+ //#endregion
8
16
  //#region src/application/canvas-html-reference.consts.ts
9
17
  const CANVAS_HTML_EXAMPLES = {
10
18
  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>",
@@ -47,6 +55,10 @@ ${CANVAS_HTML_EXAMPLES.mixed}
47
55
 
48
56
  A new subtree cannot contain retained IDs or opaque placeholders. 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.
49
57
 
58
+ ## Fonts
59
+
60
+ Inter and JetBrains Mono are built into every canvas: write font-family: Inter or font-family: 'JetBrains Mono' and the text renders and measures in those faces without an import. The CSS generic families (sans-serif, serif, monospace, system-ui and the others) need no import either. Any other family must be imported with asset_import before text uses it; use the family the ready resource names. Text in a family that has no face on the canvas renders in a fallback and shows as a missing font.
61
+
50
62
  ## Deletion, commitment and recovery
51
63
 
52
64
  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.
@@ -61,6 +73,7 @@ Submit the complete intended edit. There is no node, source-length or operation-
61
73
  //#endregion
62
74
  //#region src/infrastructure/mcp-canvas-content.adapter.ts
63
75
  const clientContext$9 = createMcpClientContextAdapter();
76
+ const CAPTURE_PAGE_CALLS_FOR_TOOLS = CAPTURE_PAGE_CALLS.map((call, index) => `${String(index + 1)}) ${withCapabilityNames(call, (id) => MCP_TOOL_BY_CAPABILITY[id] ?? id)}`).join(" ");
64
77
  const READ_ANNOTATIONS = {
65
78
  readOnlyHint: true,
66
79
  destructiveHint: false,
@@ -124,7 +137,7 @@ const registerInsertion = (server, invoke) => {
124
137
  const registerConversion = (server, invoke) => {
125
138
  server.registerTool("canvas_capture", {
126
139
  title: "Capture a recording moment",
127
- description: "Persist an exact recording moment after inspecting its canvas_render preview. Supply that preview job, the observed canvas version and the full page/selection reference. The native placement owner inserts a durable screen below the root-level recording on the same page. A concurrent canvas edit prevents attachment. This supports recordings already on this canvas, not arbitrary URLs or prototype crawling. Reuse identical arguments and clientToken after uncertainty. Pending or failed work does not prove whether a durable screen exists; follow operation_status.",
140
+ description: "Land an exact recording moment as an editable frame after inspecting its canvas_render preview. Supply that preview job, the canvas version that preview rendered (baseVersion) and the full page/selection reference. The page is stored, compiled into editable layers and saved as one frame below the root-level recording on the same page, in one change at baseVersion. When attachment is committed, frame.nodeId is the editable frame (edit its layers) and frame.version is the canvas version to use as your next baseVersion; canvas_make_editable is not needed. A concurrent canvas edit prevents the save: render a new preview and capture with a new clientToken. When attachment is pending, repeat with identical arguments and the same clientToken, or follow its operation with operation_status; a new token could save a second frame. When attachment is not_confirmed with a failure, nothing was added: capture again with a new clientToken. This supports recordings already on this canvas, not arbitrary URLs or prototype crawling.",
128
141
  inputSchema: canvasCaptureInputSchema,
129
142
  outputSchema: canvasCaptureOutputSchema,
130
143
  annotations: {
@@ -132,6 +145,16 @@ const registerConversion = (server, invoke) => {
132
145
  readOnlyHint: false
133
146
  }
134
147
  }, async ({ clientToken, ...args }, context) => clientContext$9.run(context, async () => delivered$1(canvasCaptureOutputSchema, async () => invoke("canvas.capture", args, clientToken))));
148
+ server.registerTool("canvas_capture_page", {
149
+ title: "Capture a page you opened",
150
+ description: `Put any page you can open on a canvas as an editable frame: a page on localhost, behind a sign-in, or anywhere else your browser can reach. Enhance never visits the address itself. ${CAPTURE_PAGE_CALLS_FOR_TOOLS} A picture of the page lands at once at that place, and becomes the editable frame in place, keeping its id. When step is placed, frame.nodeId is the editable frame, frame.version is your next baseVersion and frame.box tells you where to put the next capture. When step is converting, the picture is on the canvas: repeat with identical arguments and clientToken. If a page's Content Security Policy blocks the snippet, run it from Playwright in a context created with bypassCSP: true.`,
151
+ inputSchema: canvasCapturePageInputSchema,
152
+ outputSchema: canvasCapturePageOutputSchema,
153
+ annotations: {
154
+ ...READ_ANNOTATIONS,
155
+ readOnlyHint: false
156
+ }
157
+ }, async ({ clientToken, ...args }, context) => clientContext$9.run(context, async () => delivered$1(canvasCapturePageOutputSchema, async () => invoke("canvas.capturePage", args, clientToken))));
135
158
  server.registerTool("canvas_make_editable", {
136
159
  title: "Make a captured screen editable",
137
160
  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.",
@@ -198,7 +221,7 @@ const registerCreate = (server, invoke) => {
198
221
  }
199
222
  }, async ({ destination, title, clientToken }, context) => clientContext$8.run(context, async () => {
200
223
  try {
201
- const created = createCanvasOutputSchema.parse(await invoke("canvas.create", {
224
+ const created = createdCanvasAnswerSchema.parse(await invoke("canvas.create", {
202
225
  title,
203
226
  organisationId: destination.kind === "personal" ? null : destination.organisationId,
204
227
  sourceUrl: null
@@ -212,7 +235,8 @@ const registerCreate = (server, invoke) => {
212
235
  organisationId: created.organisationId
213
236
  },
214
237
  accessState: created.accessState,
215
- openPath: `/c/${created.id}`
238
+ openPath: `/c/${created.id}`,
239
+ url: created.url ?? null
216
240
  });
217
241
  return createMcpResultAdapter("Reconnect Enhance and retry the same intent.").structured(result);
218
242
  } catch (error) {
package/dist/mcp-main.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
- import { g as toCapabilityDefinition, p as createCapabilityCatalogAdapter } from "./cli-output-identity.lib-DrfKWcGw.mjs";
3
- import { i as readLocalMcpEnvironment } from "./mutation-key.adapter-DFjvJyX6.mjs";
4
- import { t as createFileCredentialAdapter } from "./file-credential.adapter-C78gc9OK.mjs";
5
- import { n as createMcpCanvasProfileAdapter, t as createMcpInvocationAdapter } from "./mcp-invocation.adapter-DrEm-z3C.mjs";
6
- import { o as createMcpClientContextAdapter, t as createMcpServerAdapter } from "./mcp-server.adapter-YQLl2Wec.mjs";
2
+ import { s as toCapabilityDefinition } from "./cli-output-identity.lib-Z9ISwnoo.mjs";
3
+ import { a as readLocalMcpEnvironment, t as installZodMessages } from "./zod-messages.lib-BrqCGdLn.mjs";
4
+ import { t as createFileCredentialAdapter } from "./file-credential.adapter-CShGZcd5.mjs";
5
+ import { o as createMcpClientContextAdapter, s as createCapabilityCatalogAdapter, t as createMcpServerAdapter } from "./mcp-server.adapter-DJ2BZrIw.mjs";
6
+ import { n as createMcpCanvasProfileAdapter, t as createMcpInvocationAdapter } from "./mcp-invocation.adapter-Cn7Cr0UH.mjs";
7
7
  import process from "node:process";
8
8
  import { z } from "zod";
9
9
  import { serveStdio } from "@modelcontextprotocol/server/stdio";
@@ -166,23 +166,24 @@ const createMcpTransportCapabilityAdapter = () => capabilities;
166
166
 
167
167
  //#endregion
168
168
  //#region src/mcp-main.ts
169
+ installZodMessages();
169
170
  const clientContext = createMcpClientContextAdapter();
170
171
  const main = () => {
171
172
  const config = readLocalMcpEnvironment();
172
- const credentials = createFileCredentialAdapter(config.configDirectory);
173
- const invocation = createMcpInvocationAdapter(config.apiUrl, credentials, config.configDirectory, { version: "0.1.160" });
173
+ const credentials = createFileCredentialAdapter(config.configDirectory, config.earlierConfigDirectory);
174
+ const invocation = createMcpInvocationAdapter(config.apiUrl, credentials, config.configDirectory, { version: "0.1.165" });
174
175
  const catalog = [...createCapabilityCatalogAdapter(), ...createMcpTransportCapabilityAdapter()];
175
176
  const client = clientContext.createStdio();
176
177
  serveStdio(() => config.profile === "canvas" ? createMcpCanvasProfileAdapter({
177
178
  readOnly: config.isReadOnly,
178
179
  ...config.workflowsDirectory !== void 0 && { workflowsDirectory: config.workflowsDirectory },
179
180
  name: config.mcpServiceName,
180
- version: "0.1.160",
181
+ version: "0.1.165",
181
182
  invocation,
182
183
  clientMetadata: client.metadata,
183
184
  catalog
184
185
  }) : createMcpServerAdapter({
185
- version: "0.1.160",
186
+ version: "0.1.165",
186
187
  name: config.mcpServiceName,
187
188
  commandName: config.commandName,
188
189
  invocation,
@@ -1,14 +1,19 @@
1
1
  #!/usr/bin/env node
2
- import { $n as wholeCanvasDocumentOutputSchema, At as hasCanvasReferenceScope, J as canvasWriteHtmlCapabilityInputSchema, Ln as agentClientMetadata, Nt as CliError, Ot as canvasReferenceRenderTarget, at as canvasRenderFileSchema, et as canvasRenderBatchResultSchema, fr as canvasReadableSceneDocumentSchema, i as toPresentedCapabilities, ir as canvasRenderSourceStateSchema, jt as parseCanvasReference, l as toMcpFailurePayload, n as withCommandName, o as createMcpCapabilityDiscoveryAdapter, or as canvasRenderTargetSchema, p as createCapabilityCatalogAdapter, r as toCanvasAuthoringResult, t as withCommandInFailure, wt as canvasEditCapabilityInputSchema } from "./cli-output-identity.lib-DrfKWcGw.mjs";
2
+ import { Ar as wholeCanvasDocumentOutputSchema, D as canvasWriteHtmlCapabilityInputSchema, Fr as canvasRenderSourceStateSchema, Gt as hasCanvasReferenceScope, Kt as parseCanvasReference, Lr as canvasRenderTargetSchema, Ut as canvasReferenceRenderTarget, an as CliError, d as createMcpCapabilityDiscoveryAdapter, i as createLazyCapabilityCatalogAdapter, l as toPresentedCapabilities, m as toMcpFailurePayload, n as withCommandName, nn as onSurface, nt as canvasRenderBatchResultSchema, pr as agentClientMetadata, qt as readStoredCanvasScene, r as toCanvasAuthoringResult, st as canvasRenderFileSchema, t as withCommandInFailure, wt as inputProblemFields, xt as canvasEditCapabilityInputSchema } from "./cli-output-identity.lib-Z9ISwnoo.mjs";
3
3
  import { z } from "zod";
4
- import { readFileSync } from "node:fs";
4
+ import { readFile, rm } from "node:fs/promises";
5
5
  import path from "node:path";
6
+ import { AsyncLocalStorage } from "node:async_hooks";
6
7
  import { createHash, randomUUID } from "node:crypto";
7
- import { readFile, rm } from "node:fs/promises";
8
+ import { readFileSync } from "node:fs";
8
9
  import { StdioServerTransport } from "@modelcontextprotocol/server/stdio";
9
10
  import { CLIENT_INFO_META_KEY, McpServer } from "@modelcontextprotocol/server";
10
- import { AsyncLocalStorage } from "node:async_hooks";
11
11
 
12
+ //#region src/infrastructure/capability-catalog.adapter.ts
13
+ /** The description of every command, for a caller that lists or serves them all. */
14
+ const createCapabilityCatalogAdapter = () => createLazyCapabilityCatalogAdapter().all();
15
+
16
+ //#endregion
12
17
  //#region src/infrastructure/mcp-client-context.adapter.ts
13
18
  const requests = new AsyncLocalStorage();
14
19
  const initializeSchema = z.object({
@@ -33,7 +38,7 @@ const withMcpClientContext = (context, action) => {
33
38
  version: client.version
34
39
  }
35
40
  });
36
- return requests.run(metadata, action);
41
+ return requests.run(metadata, () => onSurface("mcp", action));
37
42
  };
38
43
  const createMcpStdioClientAdapter = (offered) => {
39
44
  const native = offered ?? new StdioServerTransport();
@@ -94,6 +99,7 @@ const createMcpRenderAttachmentAdapter = async (server, result, delivery) => {
94
99
  }] }));
95
100
  return {
96
101
  metadata: canvasRenderFileSchema.omit({
102
+ picture: true,
97
103
  path: true,
98
104
  sensitive: true,
99
105
  cleanup: true,
@@ -242,7 +248,7 @@ const artifactResult = (server, serialized, delivery) => {
242
248
  structuredContent
243
249
  };
244
250
  };
245
- const validationError = (error) => new CliError("BAD_REQUEST", "Input validation error.", "Correct the rejected fields using this tool’s schema, then retry. Describe the exact capability only if its contract is unknown.", Object.fromEntries(error.issues.map((issue) => [issue.path.length === 0 ? "input" : issue.path.join("."), issue.message])));
251
+ const validationError = (error) => new CliError("BAD_REQUEST", "Input validation error.", "Correct the rejected fields using this tool’s schema, then retry. Describe the exact capability only if its contract is unknown.", inputProblemFields(error));
246
252
  const prepareCanvasResult = async (server, presented, delivery) => {
247
253
  const batch = await createMcpRenderBatchResultAdapter(server, presented, delivery);
248
254
  if (batch !== null) return batch;
@@ -580,7 +586,7 @@ const renderTarget = async (input, args) => {
580
586
  if (held.version !== args.expectedVersion) throw new CliError("CONFLICT", "The canvas changed before rendering.", "Read the selected subtree and render its current version.");
581
587
  return {
582
588
  canvasId: reference.canvasId,
583
- target: canvasReferenceRenderTarget(reference, canvasReadableSceneDocumentSchema.parse(held.document), args.target)
589
+ target: canvasReferenceRenderTarget(reference, readStoredCanvasScene(held.document), args.target)
584
590
  };
585
591
  };
586
592
  const deliver = async (server, input, action) => {
@@ -880,4 +886,4 @@ const createMcpServerAdapter = (input) => {
880
886
  };
881
887
 
882
888
  //#endregion
883
- export { createMcpResultAdapter as a, mcpDispatchedResultSchema as i, createMcpWorkflowsAdapter as n, createMcpClientContextAdapter as o, createMcpClientInvocationAdapter as r, createMcpServerAdapter as t };
889
+ export { createMcpResultAdapter as a, mcpDispatchedResultSchema as i, createMcpWorkflowsAdapter as n, createMcpClientContextAdapter as o, createMcpClientInvocationAdapter as r, createCapabilityCatalogAdapter as s, createMcpServerAdapter as t };
package/dist/mcp.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { a as toSharedCapabilities, p as createCapabilityCatalogAdapter } from "./cli-output-identity.lib-DrfKWcGw.mjs";
2
+ import { u as toSharedCapabilities } from "./cli-output-identity.lib-Z9ISwnoo.mjs";
3
3
  import { t as toCapabilityInventory } from "./capability-inventory.mapper-DyYXyVBJ.mjs";
4
- import { t as createMcpServerAdapter } from "./mcp-server.adapter-YQLl2Wec.mjs";
4
+ import { s as createCapabilityCatalogAdapter, t as createMcpServerAdapter } from "./mcp-server.adapter-DJ2BZrIw.mjs";
5
5
 
6
6
  export { createCapabilityCatalogAdapter, createMcpServerAdapter as createEnhanceMcpServer, toCapabilityInventory, toSharedCapabilities };