@enhance-eng/enhance 0.1.14 → 0.1.16
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-bX6NwZjd.mjs → cli-output-identity.lib-F9-nlguI.mjs} +504 -84
- package/dist/main.mjs +133 -512
- package/dist/{mcp-invocation.adapter-BdZ-LpPW.mjs → mcp-invocation.adapter-fYfIiCYu.mjs} +2 -2
- package/dist/mcp-main.mjs +7 -7
- package/dist/{mcp-server.adapter-DBlOw4BM.mjs → mcp-server.adapter-C8plL5bs.mjs} +317 -147
- package/dist/mcp.mjs +2 -2
- package/dist/{mutation-key.adapter-p1odGHfg.mjs → mutation-key.adapter-Bc4p5ff4.mjs} +720 -24
- package/dist/remote-mcp-main.mjs +5 -5
- package/package.json +2 -1
|
@@ -4,6 +4,7 @@ import { z } from "zod";
|
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
5
5
|
import { TRPCError, initTRPC } from "@trpc/server";
|
|
6
6
|
import { middlewareMarker } from "@trpc/server/unstable-core-do-not-import";
|
|
7
|
+
import { Buffer as Buffer$1 } from "node:buffer";
|
|
7
8
|
import { TRPCClientError } from "@trpc/client";
|
|
8
9
|
|
|
9
10
|
//#region \0rolldown/runtime.js
|
|
@@ -1168,7 +1169,7 @@ const RENDER_MAX_OUTPUT_BYTES = RENDER_MAX_OUTPUT_MIB * BYTES_PER_MIB$2;
|
|
|
1168
1169
|
const RENDER_MAX_SNAPSHOT_BYTES = RENDER_MAX_SNAPSHOT_MIB * BYTES_PER_MIB$2;
|
|
1169
1170
|
const RENDER_MAX_WORLD_EDGE = 1e5;
|
|
1170
1171
|
const RENDER_MIN_SCALE = .1;
|
|
1171
|
-
const MAX_NODE_ID_LENGTH$
|
|
1172
|
+
const MAX_NODE_ID_LENGTH$6 = 200;
|
|
1172
1173
|
const MAX_RENDER_MESSAGE_LENGTH$1 = 500;
|
|
1173
1174
|
const canvasWorldBoundsSchema = z.object({
|
|
1174
1175
|
x: z.number(),
|
|
@@ -1180,7 +1181,7 @@ const canvasRenderTargetSchema = z.discriminatedUnion("kind", [
|
|
|
1180
1181
|
z.object({ kind: z.literal("content") }),
|
|
1181
1182
|
z.object({
|
|
1182
1183
|
kind: z.literal("node"),
|
|
1183
|
-
nodeId: z.string().min(1).max(MAX_NODE_ID_LENGTH$
|
|
1184
|
+
nodeId: z.string().min(1).max(MAX_NODE_ID_LENGTH$6)
|
|
1184
1185
|
}),
|
|
1185
1186
|
z.object({
|
|
1186
1187
|
kind: z.literal("bounds"),
|
|
@@ -1202,7 +1203,7 @@ const canvasRenderSnapshotResultSchema = z.object({
|
|
|
1202
1203
|
recordingId: z.uuid(),
|
|
1203
1204
|
atMs: z.number().int().nonnegative(),
|
|
1204
1205
|
screenId: z.uuid(),
|
|
1205
|
-
screenNodeId: z.string().min(1).max(MAX_NODE_ID_LENGTH$
|
|
1206
|
+
screenNodeId: z.string().min(1).max(MAX_NODE_ID_LENGTH$6),
|
|
1206
1207
|
viewport: z.object({
|
|
1207
1208
|
width: z.number().int().positive(),
|
|
1208
1209
|
height: z.number().int().positive()
|
|
@@ -1229,20 +1230,20 @@ const canvasRenderWarningCodeSchema = z.enum(RENDER_WARNING_CODES);
|
|
|
1229
1230
|
const canvasRenderWarningSchema = z.object({
|
|
1230
1231
|
code: canvasRenderWarningCodeSchema,
|
|
1231
1232
|
message: z.string().min(1).max(MAX_RENDER_MESSAGE_LENGTH$1),
|
|
1232
|
-
sourceId: z.string().min(1).max(MAX_NODE_ID_LENGTH$
|
|
1233
|
+
sourceId: z.string().min(1).max(MAX_NODE_ID_LENGTH$6).nullable()
|
|
1233
1234
|
});
|
|
1234
1235
|
const canvasRenderFailureSchema = z.object({
|
|
1235
1236
|
reason: canvasRenderFailureReasonSchema,
|
|
1236
1237
|
phase: canvasRenderPhaseSchema,
|
|
1237
1238
|
message: z.string().min(1).max(MAX_RENDER_MESSAGE_LENGTH$1),
|
|
1238
1239
|
retryable: z.boolean(),
|
|
1239
|
-
sourceId: z.string().min(1).max(MAX_NODE_ID_LENGTH$
|
|
1240
|
+
sourceId: z.string().min(1).max(MAX_NODE_ID_LENGTH$6).nullable()
|
|
1240
1241
|
});
|
|
1241
1242
|
const canvasRenderTimingSchema = z.object({
|
|
1242
1243
|
phase: canvasRenderPhaseSchema,
|
|
1243
1244
|
durationMs: z.number().int().min(0)
|
|
1244
1245
|
});
|
|
1245
|
-
const canvasRenderResultSchema = z.object({
|
|
1246
|
+
const canvasRenderResultSchema$1 = z.object({
|
|
1246
1247
|
canvasId: z.uuid(),
|
|
1247
1248
|
requestedVersion: z.number().int().positive(),
|
|
1248
1249
|
loadedVersion: z.number().int().positive(),
|
|
@@ -1294,7 +1295,7 @@ const canvasRenderJobSchema = z.discriminatedUnion("state", [
|
|
|
1294
1295
|
canvasRenderJobBaseSchema.extend({
|
|
1295
1296
|
state: z.literal("succeeded"),
|
|
1296
1297
|
phase: z.literal("complete"),
|
|
1297
|
-
result: canvasRenderResultSchema,
|
|
1298
|
+
result: canvasRenderResultSchema$1,
|
|
1298
1299
|
failure: z.null()
|
|
1299
1300
|
}),
|
|
1300
1301
|
canvasRenderJobBaseSchema.extend({
|
|
@@ -1566,14 +1567,14 @@ const canvasPropertySectionSchema = z.enum(CANVAS_PROPERTY_SECTIONS);
|
|
|
1566
1567
|
|
|
1567
1568
|
//#endregion
|
|
1568
1569
|
//#region ../../packages/contract/src/canvas/canvas-inspection.schema.ts
|
|
1569
|
-
const MAX_NODE_ID_LENGTH$
|
|
1570
|
+
const MAX_NODE_ID_LENGTH$5 = 200;
|
|
1570
1571
|
const MAX_RENDER_MESSAGE_LENGTH = 500;
|
|
1571
1572
|
const MAX_RENDER_KIND_LENGTH = 100;
|
|
1572
1573
|
const canvasInspectNodeSummarySchema = z.object({
|
|
1573
|
-
id: z.string().min(1).max(MAX_NODE_ID_LENGTH$
|
|
1574
|
+
id: z.string().min(1).max(MAX_NODE_ID_LENGTH$5),
|
|
1574
1575
|
label: z.string().max(MAX_RENDER_MESSAGE_LENGTH),
|
|
1575
1576
|
kind: z.string().min(1).max(MAX_RENDER_KIND_LENGTH),
|
|
1576
|
-
parentId: z.string().min(1).max(MAX_NODE_ID_LENGTH$
|
|
1577
|
+
parentId: z.string().min(1).max(MAX_NODE_ID_LENGTH$5).nullable(),
|
|
1577
1578
|
childCount: z.number().int().min(0),
|
|
1578
1579
|
box: canvasWorldBoundsSchema.nullable(),
|
|
1579
1580
|
propertySections: z.array(canvasPropertySectionSchema)
|
|
@@ -1598,7 +1599,7 @@ const inspectCanvasTreeOutputSchema = z.object({
|
|
|
1598
1599
|
});
|
|
1599
1600
|
const inspectCanvasNodeInputSchema = z.object({
|
|
1600
1601
|
canvasId: z.uuid(),
|
|
1601
|
-
nodeId: z.string().min(1).max(MAX_NODE_ID_LENGTH$
|
|
1602
|
+
nodeId: z.string().min(1).max(MAX_NODE_ID_LENGTH$5)
|
|
1602
1603
|
});
|
|
1603
1604
|
const inspectCanvasNodeOutputSchema = z.object({
|
|
1604
1605
|
canvasId: z.uuid(),
|
|
@@ -1610,7 +1611,7 @@ const inspectCanvasNodeOutputSchema = z.object({
|
|
|
1610
1611
|
typography: canvasTypographySchema.optional(),
|
|
1611
1612
|
additionalStyles: canvasAdditionalStylesSchema.optional(),
|
|
1612
1613
|
props: z.record(z.string(), z.unknown()),
|
|
1613
|
-
children: z.array(z.string().min(1).max(MAX_NODE_ID_LENGTH$
|
|
1614
|
+
children: z.array(z.string().min(1).max(MAX_NODE_ID_LENGTH$5))
|
|
1614
1615
|
}),
|
|
1615
1616
|
next: z.array(z.string().min(1))
|
|
1616
1617
|
});
|
|
@@ -2166,12 +2167,12 @@ const insertConvertedSubtreeOperationSchema = z.object({
|
|
|
2166
2167
|
nodes: z.record(z.string().min(1).max(200), canvasSceneNodeSchema).refine((nodes) => Object.keys(nodes).length <= MAX_CANVAS_CONVERSION_NODES),
|
|
2167
2168
|
relationships: z.record(z.string().min(1).max(200), convertedSubtreeRelationshipSchema).refine((relationships) => Object.keys(relationships).length < MAX_CANVAS_CONVERSION_NODES)
|
|
2168
2169
|
});
|
|
2169
|
-
const MAX_NODE_ID_LENGTH$
|
|
2170
|
-
const MAX_LABEL_LENGTH = 500;
|
|
2171
|
-
const MAX_TEXT_LENGTH = 1e5;
|
|
2170
|
+
const MAX_NODE_ID_LENGTH$4 = 200;
|
|
2171
|
+
const MAX_LABEL_LENGTH$1 = 500;
|
|
2172
|
+
const MAX_TEXT_LENGTH$1 = 1e5;
|
|
2172
2173
|
const MAX_CANVAS_OPERATIONS = 1e3;
|
|
2173
|
-
const nodeIdSchema$1 = z.string().min(1).max(MAX_NODE_ID_LENGTH$
|
|
2174
|
-
const sortKeySchema = z.string().min(1).max(MAX_LABEL_LENGTH);
|
|
2174
|
+
const nodeIdSchema$1 = z.string().min(1).max(MAX_NODE_ID_LENGTH$4);
|
|
2175
|
+
const sortKeySchema = z.string().min(1).max(MAX_LABEL_LENGTH$1);
|
|
2175
2176
|
const writableBoxSchema = canvasSceneBoxSchema.extend({
|
|
2176
2177
|
width: z.number().positive(),
|
|
2177
2178
|
height: z.number().positive()
|
|
@@ -2200,15 +2201,15 @@ const canvasOperationSchema = z.discriminatedUnion("op", [
|
|
|
2200
2201
|
placementSchema.extend({
|
|
2201
2202
|
op: z.literal("insertText"),
|
|
2202
2203
|
nodeId: nodeIdSchema$1,
|
|
2203
|
-
label: z.string().max(MAX_LABEL_LENGTH).default("Text"),
|
|
2204
|
-
text: z.string().max(MAX_TEXT_LENGTH),
|
|
2204
|
+
label: z.string().max(MAX_LABEL_LENGTH$1).default("Text"),
|
|
2205
|
+
text: z.string().max(MAX_TEXT_LENGTH$1),
|
|
2205
2206
|
box: writableBoxSchema,
|
|
2206
2207
|
styles: canvasTextStylesSchema.default({})
|
|
2207
2208
|
}),
|
|
2208
2209
|
placementSchema.extend({
|
|
2209
2210
|
op: z.literal("insertPrototype"),
|
|
2210
2211
|
nodeId: nodeIdSchema$1,
|
|
2211
|
-
label: z.string().max(MAX_LABEL_LENGTH).default("Prototype"),
|
|
2212
|
+
label: z.string().max(MAX_LABEL_LENGTH$1).default("Prototype"),
|
|
2212
2213
|
prototypeId: z.uuid(),
|
|
2213
2214
|
deploymentId: z.uuid(),
|
|
2214
2215
|
box: writableBoxSchema,
|
|
@@ -2223,7 +2224,7 @@ const canvasOperationSchema = z.discriminatedUnion("op", [
|
|
|
2223
2224
|
z.object({
|
|
2224
2225
|
op: z.literal("setText"),
|
|
2225
2226
|
nodeId: nodeIdSchema$1,
|
|
2226
|
-
text: z.string().max(MAX_TEXT_LENGTH)
|
|
2227
|
+
text: z.string().max(MAX_TEXT_LENGTH$1)
|
|
2227
2228
|
}),
|
|
2228
2229
|
z.object({
|
|
2229
2230
|
op: z.literal("setBox"),
|
|
@@ -2233,7 +2234,7 @@ const canvasOperationSchema = z.discriminatedUnion("op", [
|
|
|
2233
2234
|
z.object({
|
|
2234
2235
|
op: z.literal("setLabel"),
|
|
2235
2236
|
nodeId: nodeIdSchema$1,
|
|
2236
|
-
label: z.string().trim().min(1).max(MAX_LABEL_LENGTH),
|
|
2237
|
+
label: z.string().trim().min(1).max(MAX_LABEL_LENGTH$1),
|
|
2237
2238
|
labelOrigin: canvasNodeLabelOriginSchema.nullable().optional()
|
|
2238
2239
|
}),
|
|
2239
2240
|
z.object({
|
|
@@ -2325,7 +2326,7 @@ const createEditableFrameOutputSchema = createEditableFrameResultSchema.extend({
|
|
|
2325
2326
|
const CANVAS_REALTIME_PROTOCOL = "enhance3.canvas.v1";
|
|
2326
2327
|
const MAX_DISPLAY_NAME_LENGTH = 100;
|
|
2327
2328
|
const MAX_INITIALS_LENGTH = 8;
|
|
2328
|
-
const MAX_NODE_ID_LENGTH$
|
|
2329
|
+
const MAX_NODE_ID_LENGTH$3 = 200;
|
|
2329
2330
|
const MAX_SELECTION_SIZE = 100;
|
|
2330
2331
|
const MAX_ACTIVITY_TARGETS = 100;
|
|
2331
2332
|
const MAX_REALTIME_TICKET_LENGTH = 4096;
|
|
@@ -2377,7 +2378,7 @@ const visibleWorldBoxSchema = canvasSceneBoxSchema.extend({
|
|
|
2377
2378
|
const gesturePreviewSchema = z.object({
|
|
2378
2379
|
kind: z.enum(["drag", "resize"]),
|
|
2379
2380
|
baseVersion: z.number().int().positive(),
|
|
2380
|
-
boxes: z.record(z.string().min(1).max(MAX_NODE_ID_LENGTH$
|
|
2381
|
+
boxes: z.record(z.string().min(1).max(MAX_NODE_ID_LENGTH$3), visibleWorldBoxSchema)
|
|
2381
2382
|
});
|
|
2382
2383
|
const canvasPresencePatchSchema = z.object({
|
|
2383
2384
|
cursor: cursorSchema.nullable().optional(),
|
|
@@ -2387,7 +2388,7 @@ const canvasPresencePatchSchema = z.object({
|
|
|
2387
2388
|
"keyboard"
|
|
2388
2389
|
]).optional(),
|
|
2389
2390
|
focused: z.boolean().optional(),
|
|
2390
|
-
selectedNodeIds: z.array(z.string().min(1).max(MAX_NODE_ID_LENGTH$
|
|
2391
|
+
selectedNodeIds: z.array(z.string().min(1).max(MAX_NODE_ID_LENGTH$3)).max(MAX_SELECTION_SIZE).optional(),
|
|
2391
2392
|
visibleWorldBox: visibleWorldBoxSchema.optional(),
|
|
2392
2393
|
gesture: gesturePreviewSchema.nullable().optional(),
|
|
2393
2394
|
cursorChat: z.string().max(140).nullable().optional()
|
|
@@ -2402,7 +2403,7 @@ const canvasPresenceSchema = z.object({
|
|
|
2402
2403
|
"keyboard"
|
|
2403
2404
|
]),
|
|
2404
2405
|
focused: z.boolean(),
|
|
2405
|
-
selectedNodeIds: z.array(z.string().min(1).max(MAX_NODE_ID_LENGTH$
|
|
2406
|
+
selectedNodeIds: z.array(z.string().min(1).max(MAX_NODE_ID_LENGTH$3)).max(MAX_SELECTION_SIZE),
|
|
2406
2407
|
visibleWorldBox: visibleWorldBoxSchema.nullable(),
|
|
2407
2408
|
gesture: gesturePreviewSchema.nullable(),
|
|
2408
2409
|
cursorChat: z.string().max(140).nullable().default(null),
|
|
@@ -2420,7 +2421,7 @@ const canvasAgentActivitySchema = z.object({
|
|
|
2420
2421
|
canvasId: z.uuid(),
|
|
2421
2422
|
actor: agentMutationActorSchema,
|
|
2422
2423
|
phase: canvasAgentActivityPhaseSchema,
|
|
2423
|
-
nodeIds: z.array(z.string().min(1).max(MAX_NODE_ID_LENGTH$
|
|
2424
|
+
nodeIds: z.array(z.string().min(1).max(MAX_NODE_ID_LENGTH$3)).max(MAX_ACTIVITY_TARGETS),
|
|
2424
2425
|
bounds: visibleWorldBoxSchema.nullable(),
|
|
2425
2426
|
expiresAt: z.iso.datetime()
|
|
2426
2427
|
});
|
|
@@ -2437,7 +2438,7 @@ const canvasRealtimeTicketOutputSchema = z.object({
|
|
|
2437
2438
|
const beginCanvasActivityInputSchema = z.object({
|
|
2438
2439
|
canvasId: z.uuid(),
|
|
2439
2440
|
phase: canvasAgentActivityPhaseSchema,
|
|
2440
|
-
nodeIds: z.array(z.string().min(1).max(MAX_NODE_ID_LENGTH$
|
|
2441
|
+
nodeIds: z.array(z.string().min(1).max(MAX_NODE_ID_LENGTH$3)).max(MAX_ACTIVITY_TARGETS).default([]),
|
|
2441
2442
|
bounds: visibleWorldBoxSchema.nullable().default(null)
|
|
2442
2443
|
});
|
|
2443
2444
|
const beginCanvasActivityOutputSchema = z.object({
|
|
@@ -2546,7 +2547,7 @@ const canvasRealtimeServerEnvelopeSchema = z.discriminatedUnion("type", [
|
|
|
2546
2547
|
|
|
2547
2548
|
//#endregion
|
|
2548
2549
|
//#region ../../packages/contract/src/canvas/canvas-render-exposure.schema.ts
|
|
2549
|
-
const MAX_NODE_ID_LENGTH$
|
|
2550
|
+
const MAX_NODE_ID_LENGTH$2 = 200;
|
|
2550
2551
|
/** The only job metadata exposed to the browser carrying a one-job render grant. */
|
|
2551
2552
|
const exposeCanvasRenderInputSchema = z.object({ jobId: z.uuid() });
|
|
2552
2553
|
const exposeCanvasRenderBaseSchema = z.object({
|
|
@@ -2568,7 +2569,7 @@ const exposeCanvasRenderOutputSchema = z.discriminatedUnion("purpose", [exposeCa
|
|
|
2568
2569
|
purpose: z.literal("conversion"),
|
|
2569
2570
|
target: z.object({
|
|
2570
2571
|
kind: z.literal("node"),
|
|
2571
|
-
nodeId: z.string().min(1).max(MAX_NODE_ID_LENGTH$
|
|
2572
|
+
nodeId: z.string().min(1).max(MAX_NODE_ID_LENGTH$2)
|
|
2572
2573
|
}),
|
|
2573
2574
|
sourceState: z.undefined().optional(),
|
|
2574
2575
|
conversion: canvasConversionRequestSchema,
|
|
@@ -4634,6 +4635,189 @@ var PartialBatchError = class extends CliError {
|
|
|
4634
4635
|
}
|
|
4635
4636
|
};
|
|
4636
4637
|
|
|
4638
|
+
//#endregion
|
|
4639
|
+
//#region src/application/canvas-reference.use-case.ts
|
|
4640
|
+
const canvasIdSchema = z.uuid();
|
|
4641
|
+
const selectedIdsSchema = z.array(z.string().min(1).max(200)).min(1);
|
|
4642
|
+
const CANVAS_PATH = /^\/c\/([^/]+)\/?$/u;
|
|
4643
|
+
const urlFrom = (candidate) => {
|
|
4644
|
+
try {
|
|
4645
|
+
return new URL(candidate);
|
|
4646
|
+
} catch {
|
|
4647
|
+
return null;
|
|
4648
|
+
}
|
|
4649
|
+
};
|
|
4650
|
+
const parseCanvasReference = (reference) => {
|
|
4651
|
+
const candidate = reference.trim();
|
|
4652
|
+
const direct = canvasIdSchema.safeParse(candidate);
|
|
4653
|
+
if (direct.success) return {
|
|
4654
|
+
canvasId: direct.data,
|
|
4655
|
+
nodeIds: []
|
|
4656
|
+
};
|
|
4657
|
+
const url = urlFrom(candidate);
|
|
4658
|
+
if (url !== null && (url.protocol === "http:" || url.protocol === "https:")) {
|
|
4659
|
+
const id = canvasIdSchema.safeParse(CANVAS_PATH.exec(url.pathname.toLowerCase())?.[1]);
|
|
4660
|
+
if (id.success) {
|
|
4661
|
+
const selection = new URLSearchParams(url.hash.slice(1)).getAll("selection");
|
|
4662
|
+
if (selection.length === 0) return {
|
|
4663
|
+
canvasId: id.data,
|
|
4664
|
+
nodeIds: []
|
|
4665
|
+
};
|
|
4666
|
+
const parsed = selectedIdsSchema.safeParse(selection);
|
|
4667
|
+
if (!parsed.success) throw new CliError("BAD_REQUEST", "The link contains an invalid selection.", "Copy the selection link again from the canvas.");
|
|
4668
|
+
return {
|
|
4669
|
+
canvasId: id.data,
|
|
4670
|
+
nodeIds: [...new Set(parsed.data)]
|
|
4671
|
+
};
|
|
4672
|
+
}
|
|
4673
|
+
}
|
|
4674
|
+
throw new CliError("BAD_REQUEST", "The canvas reference is neither a canvas URL nor a UUID.", "Paste an HTTP(S) URL shaped https://app.example/c/<UUID>, or pass the bare canvas UUID.");
|
|
4675
|
+
};
|
|
4676
|
+
const fromCanvasReference = (reference) => {
|
|
4677
|
+
const parsed = parseCanvasReference(reference);
|
|
4678
|
+
if (parsed.nodeIds.length > 0) throw new CliError("BAD_REQUEST", `This command cannot discard the link selection: ${parsed.nodeIds.join(", ")}.`, "Inspect the selection with canvas tree and use a targeted edit. Use a canvas URL without a selection only when the request covers the whole canvas.");
|
|
4679
|
+
return parsed.canvasId;
|
|
4680
|
+
};
|
|
4681
|
+
const canvasReferenceNodeIds = (reference, document) => {
|
|
4682
|
+
const missing = reference.nodeIds.filter((id) => document.nodes[id] === void 0);
|
|
4683
|
+
if (missing.length > 0) throw new CliError("NOT_FOUND", `The link selection no longer exists: ${missing.join(", ")}.`, "Copy a current selection link; do not substitute other canvas content.");
|
|
4684
|
+
const selected = new Set(reference.nodeIds);
|
|
4685
|
+
const descendants = (parentId) => {
|
|
4686
|
+
for (const [id, relationship] of Object.entries(document.relationships)) {
|
|
4687
|
+
if (relationship.parentId !== parentId || selected.has(id)) continue;
|
|
4688
|
+
selected.add(id);
|
|
4689
|
+
descendants(id);
|
|
4690
|
+
}
|
|
4691
|
+
};
|
|
4692
|
+
for (const id of reference.nodeIds) descendants(id);
|
|
4693
|
+
return selected;
|
|
4694
|
+
};
|
|
4695
|
+
const assertCanvasReferenceNodes = (reference, document, nodeIds) => {
|
|
4696
|
+
if (reference.nodeIds.length === 0) return;
|
|
4697
|
+
const scope = canvasReferenceNodeIds(reference, document);
|
|
4698
|
+
assertNodesInScope(scope, nodeIds);
|
|
4699
|
+
};
|
|
4700
|
+
const assertNodesInScope = (scope, nodeIds) => {
|
|
4701
|
+
const outside = nodeIds.filter((id) => !scope.has(id));
|
|
4702
|
+
if (outside.length > 0) throw new CliError("BAD_REQUEST", `These nodes are outside the link selection: ${outside.join(", ")}.`, "Limit the edit to the selected nodes and their descendants. Request a wider selection only when the person wants a wider change.");
|
|
4703
|
+
};
|
|
4704
|
+
const conversionScope = (operation) => {
|
|
4705
|
+
if (operation.destination.kind === "adjacent") throw new CliError("BAD_REQUEST", "Adjacent conversion would insert outside the link selection.", "Use insert-children or replace with a selected target.");
|
|
4706
|
+
return {
|
|
4707
|
+
required: [operation.destination.targetNodeId],
|
|
4708
|
+
inserted: Object.keys(operation.nodes)
|
|
4709
|
+
};
|
|
4710
|
+
};
|
|
4711
|
+
const operationScope = (operation, document) => {
|
|
4712
|
+
switch (operation.op) {
|
|
4713
|
+
case "insertNode": return {
|
|
4714
|
+
required: [operation.parentage.parentId],
|
|
4715
|
+
inserted: [operation.node.id]
|
|
4716
|
+
};
|
|
4717
|
+
case "insertText":
|
|
4718
|
+
case "insertPrototype": return {
|
|
4719
|
+
required: [operation.parentId, ...operation.afterId === void 0 ? [] : [operation.afterId]],
|
|
4720
|
+
inserted: [operation.nodeId]
|
|
4721
|
+
};
|
|
4722
|
+
case "insertConvertedSubtree": return conversionScope(operation);
|
|
4723
|
+
case "move":
|
|
4724
|
+
case "setParentage": {
|
|
4725
|
+
const parentId = operation.op === "move" ? operation.parentId : operation.parentage.parentId;
|
|
4726
|
+
return {
|
|
4727
|
+
required: [operation.nodeId, ...parentId === document.relationships[operation.nodeId]?.parentId ? [] : [parentId]],
|
|
4728
|
+
inserted: []
|
|
4729
|
+
};
|
|
4730
|
+
}
|
|
4731
|
+
case "setPrototypeDeployment":
|
|
4732
|
+
case "setText":
|
|
4733
|
+
case "setBox":
|
|
4734
|
+
case "setLabel":
|
|
4735
|
+
case "setContainerKind":
|
|
4736
|
+
case "setVisibility":
|
|
4737
|
+
case "setLocked":
|
|
4738
|
+
case "setConstraints":
|
|
4739
|
+
case "setStyles":
|
|
4740
|
+
case "setAppearance":
|
|
4741
|
+
case "setLayout":
|
|
4742
|
+
case "setTypography":
|
|
4743
|
+
case "setAdditionalStyles":
|
|
4744
|
+
case "setProps":
|
|
4745
|
+
case "remove": return {
|
|
4746
|
+
required: [operation.nodeId],
|
|
4747
|
+
inserted: []
|
|
4748
|
+
};
|
|
4749
|
+
}
|
|
4750
|
+
};
|
|
4751
|
+
const assertCanvasReferenceOperations = (reference, document, operations) => {
|
|
4752
|
+
if (reference.nodeIds.length === 0) return;
|
|
4753
|
+
const scope = new Set(canvasReferenceNodeIds(reference, document));
|
|
4754
|
+
for (const operation of operations) {
|
|
4755
|
+
const { required, inserted } = operationScope(operation, document);
|
|
4756
|
+
assertNodesInScope(scope, [...required, ...inserted.filter((id) => document.nodes[id] !== void 0)]);
|
|
4757
|
+
for (const id of inserted) scope.add(id);
|
|
4758
|
+
}
|
|
4759
|
+
};
|
|
4760
|
+
|
|
4761
|
+
//#endregion
|
|
4762
|
+
//#region src/infrastructure/canvas-edit-input.schema.ts
|
|
4763
|
+
const MAX_NODE_ID_LENGTH$1 = 200;
|
|
4764
|
+
const MAX_NODE_IDS = 1e3;
|
|
4765
|
+
const MAX_TEXT_LENGTH = 1e5;
|
|
4766
|
+
const MAX_LABEL_LENGTH = 500;
|
|
4767
|
+
const MAX_EDITS = 100;
|
|
4768
|
+
const nodeId = z.string().min(1).max(MAX_NODE_ID_LENGTH$1);
|
|
4769
|
+
const nodeIds = z.array(nodeId).min(1).max(MAX_NODE_IDS);
|
|
4770
|
+
const canvasEditsSchema = z.array(z.discriminatedUnion("kind", [
|
|
4771
|
+
z.object({
|
|
4772
|
+
kind: z.literal("set_text"),
|
|
4773
|
+
nodeId,
|
|
4774
|
+
text: z.string().max(MAX_TEXT_LENGTH)
|
|
4775
|
+
}),
|
|
4776
|
+
z.object({
|
|
4777
|
+
kind: z.literal("set_styles"),
|
|
4778
|
+
nodeIds,
|
|
4779
|
+
styles: z.record(z.string(), z.union([
|
|
4780
|
+
z.string(),
|
|
4781
|
+
z.number(),
|
|
4782
|
+
z.null()
|
|
4783
|
+
]))
|
|
4784
|
+
}),
|
|
4785
|
+
z.object({
|
|
4786
|
+
kind: z.literal("rename"),
|
|
4787
|
+
nodeId,
|
|
4788
|
+
name: z.string().trim().min(1).max(MAX_LABEL_LENGTH)
|
|
4789
|
+
}),
|
|
4790
|
+
z.object({
|
|
4791
|
+
kind: z.literal("duplicate"),
|
|
4792
|
+
nodeIds,
|
|
4793
|
+
parentId: nodeId.optional()
|
|
4794
|
+
}),
|
|
4795
|
+
z.object({
|
|
4796
|
+
kind: z.literal("move"),
|
|
4797
|
+
nodeId,
|
|
4798
|
+
destination: z.discriminatedUnion("kind", [
|
|
4799
|
+
z.object({
|
|
4800
|
+
kind: z.literal("before"),
|
|
4801
|
+
nodeId
|
|
4802
|
+
}),
|
|
4803
|
+
z.object({
|
|
4804
|
+
kind: z.literal("after"),
|
|
4805
|
+
nodeId
|
|
4806
|
+
}),
|
|
4807
|
+
z.object({
|
|
4808
|
+
kind: z.literal("parent"),
|
|
4809
|
+
parentId: nodeId,
|
|
4810
|
+
index: z.number().int().nonnegative().optional()
|
|
4811
|
+
})
|
|
4812
|
+
])
|
|
4813
|
+
})
|
|
4814
|
+
])).min(1).max(MAX_EDITS);
|
|
4815
|
+
const canvasEditCapabilityInputSchema = z.object({
|
|
4816
|
+
canvas: z.string().min(1).describe("Canvas UUID or full canvas/selection URL; selection limits the entire edit batch."),
|
|
4817
|
+
baseVersion: z.number().int().positive().describe("Exact version to edit, including the version returned by a previous successful write."),
|
|
4818
|
+
edits: canvasEditsSchema.describe("One to 100 sequential text, style, rename, duplicate or move edits, committed atomically. Target existing node IDs.")
|
|
4819
|
+
});
|
|
4820
|
+
|
|
4637
4821
|
//#endregion
|
|
4638
4822
|
//#region src/application/capability-example.consts.ts
|
|
4639
4823
|
const CAPABILITY_UUID_EXAMPLE = "00000000-0000-4000-8000-000000000010";
|
|
@@ -4661,11 +4845,13 @@ const canvasRenderCapabilityInputSchema = z.object({
|
|
|
4661
4845
|
});
|
|
4662
4846
|
const canvasWriteHtmlCapabilityInputSchema = z.object({
|
|
4663
4847
|
canvasId: z.uuid(),
|
|
4848
|
+
selectionNodeIds: z.array(z.string().min(1).max(MAX_NODE_ID_LENGTH)).optional().describe("Selected node IDs from the canvas URL; restrict the destination to this selection."),
|
|
4664
4849
|
targetNodeId: z.string().min(1).max(MAX_NODE_ID_LENGTH).describe("Stable container id for insert-children, or subtree root id for replace."),
|
|
4665
4850
|
mode: z.enum(["insert-children", "replace"]).describe("Insert the compiled group inside the target, or replace the target subtree."),
|
|
4666
4851
|
html: z.string().min(1).max(MAX_HTML_LENGTH).describe("Exactly one safe top-level HTML/CSS visual group to compile into editable nodes."),
|
|
4667
|
-
idPrefix: z.string().min(1).max(MAX_ID_PREFIX_LENGTH).optional().describe("Optional
|
|
4852
|
+
idPrefix: z.string().min(1).max(MAX_ID_PREFIX_LENGTH).optional().describe("Optional namespace for generated IDs. Choose a fresh prefix for each new import or replacement; reuse only for an identical retry."),
|
|
4668
4853
|
baseVersion: z.number().int().positive(),
|
|
4854
|
+
review: z.enum(["none", "render"]).optional().describe("Use none to return the committed edit without rendering; omission preserves combined review."),
|
|
4669
4855
|
renderOutputPath: z.string().min(1).nullable().describe("Local review PNG path, or null for a protected temporary artifact."),
|
|
4670
4856
|
overwriteRender: z.boolean().describe("Whether an existing renderOutputPath may be replaced."),
|
|
4671
4857
|
renderScale: z.number().min(MIN_RENDER_SCALE).max(MAX_RENDER_SCALE).describe("Review PNG pixels per canvas unit, from 0.1 through 4."),
|
|
@@ -4701,6 +4887,44 @@ const transcriptReadCapabilityInputSchema = z.object({
|
|
|
4701
4887
|
//#endregion
|
|
4702
4888
|
//#region src/infrastructure/canvas-capability.consts.ts
|
|
4703
4889
|
const CANVAS_CAPABILITY_SPECS = [
|
|
4890
|
+
{
|
|
4891
|
+
id: "canvas.edit",
|
|
4892
|
+
cliPath: "canvas edit",
|
|
4893
|
+
operation: "mutation",
|
|
4894
|
+
effect: "write",
|
|
4895
|
+
idempotency: "single",
|
|
4896
|
+
inputSchema: canvasEditCapabilityInputSchema,
|
|
4897
|
+
outputSchema: applyCanvasOperationsOutputSchema,
|
|
4898
|
+
summary: "Change selected text, styles, names, duplicates, or positions in one atomic design edit.",
|
|
4899
|
+
procedures: [
|
|
4900
|
+
"canvas.document.get",
|
|
4901
|
+
"canvas.realtime.activity.begin",
|
|
4902
|
+
"canvas.realtime.activity.renew",
|
|
4903
|
+
"canvas.realtime.activity.end",
|
|
4904
|
+
"canvas.applyOperations"
|
|
4905
|
+
],
|
|
4906
|
+
inputExample: {
|
|
4907
|
+
canvas: CAPABILITY_UUID_EXAMPLE,
|
|
4908
|
+
baseVersion: 1,
|
|
4909
|
+
edits: [{
|
|
4910
|
+
kind: "set_text",
|
|
4911
|
+
nodeId: "text_title",
|
|
4912
|
+
text: "Today"
|
|
4913
|
+
}]
|
|
4914
|
+
},
|
|
4915
|
+
outputExample: {
|
|
4916
|
+
canvasId: CAPABILITY_UUID_EXAMPLE,
|
|
4917
|
+
mutationId: CAPABILITY_UUID_EXAMPLE,
|
|
4918
|
+
previousVersion: 1,
|
|
4919
|
+
version: 2,
|
|
4920
|
+
insertedNodeIds: [],
|
|
4921
|
+
changedNodeIds: ["text_title"],
|
|
4922
|
+
removedNodeIds: [],
|
|
4923
|
+
boxes: {},
|
|
4924
|
+
affectedBounds: null,
|
|
4925
|
+
next: []
|
|
4926
|
+
}
|
|
4927
|
+
},
|
|
4704
4928
|
{
|
|
4705
4929
|
id: "canvas.apply",
|
|
4706
4930
|
cliPath: "canvas apply",
|
|
@@ -4789,20 +5013,39 @@ const CANVAS_CAPABILITY_SPECS = [
|
|
|
4789
5013
|
effect: "write",
|
|
4790
5014
|
idempotency: "composite",
|
|
4791
5015
|
inputSchema: canvasWriteHtmlCapabilityInputSchema,
|
|
4792
|
-
outputSchema: z.looseObject({
|
|
5016
|
+
outputSchema: z.union([z.looseObject({
|
|
4793
5017
|
canvasId: z.uuid(),
|
|
4794
5018
|
mutationCommitted: z.literal(true),
|
|
4795
5019
|
previousVersion: z.number().int().positive(),
|
|
4796
5020
|
version: z.number().int().positive(),
|
|
5021
|
+
rootNodeId: z.string().optional(),
|
|
5022
|
+
jobId: z.uuid().optional(),
|
|
5023
|
+
affected: z.object({
|
|
5024
|
+
inserted: z.number(),
|
|
5025
|
+
changed: z.number(),
|
|
5026
|
+
removed: z.number()
|
|
5027
|
+
}).optional(),
|
|
4797
5028
|
createdNodes: z.array(z.object({
|
|
4798
5029
|
id: z.string(),
|
|
4799
5030
|
name: z.string(),
|
|
4800
5031
|
component: z.string()
|
|
4801
|
-
})),
|
|
5032
|
+
})).optional(),
|
|
4802
5033
|
removedNodeIds: z.array(z.string()),
|
|
4803
|
-
next: z.array(z.string())
|
|
4804
|
-
}),
|
|
4805
|
-
|
|
5034
|
+
next: z.array(z.string()).optional()
|
|
5035
|
+
}), z.object({
|
|
5036
|
+
state: z.literal("pending"),
|
|
5037
|
+
canvasId: z.uuid(),
|
|
5038
|
+
jobId: z.uuid(),
|
|
5039
|
+
phase: z.string(),
|
|
5040
|
+
status: z.object({
|
|
5041
|
+
tool: z.literal("capability_query"),
|
|
5042
|
+
arguments: z.object({
|
|
5043
|
+
capability: z.literal("canvas.render.getImport"),
|
|
5044
|
+
input: z.object({ jobId: z.uuid() })
|
|
5045
|
+
})
|
|
5046
|
+
})
|
|
5047
|
+
})]),
|
|
5048
|
+
summary: "Design an editable screen or visual group from HTML and CSS. Use review none for a fast commit, then render after the intended edits.",
|
|
4806
5049
|
procedures: [
|
|
4807
5050
|
"canvas.realtime.activity.begin",
|
|
4808
5051
|
"canvas.realtime.activity.renew",
|
|
@@ -4818,7 +5061,8 @@ const CANVAS_CAPABILITY_SPECS = [
|
|
|
4818
5061
|
canvasId: CAPABILITY_UUID_EXAMPLE,
|
|
4819
5062
|
targetNodeId: "root",
|
|
4820
5063
|
mode: "insert-children",
|
|
4821
|
-
html: "<div layer-name=\"Ready\" style=\"display:flex;width:
|
|
5064
|
+
html: "<div layer-name=\"Ready\" style=\"display:flex;flex-direction:column;gap:16px;padding:24px;width:360px;background:#fff\"><h1 style=\"font-size:24px\">Today</h1><p>Three tasks ready to start</p><div style=\"padding:16px;background:#eef2ff\">Review the design</div></div>",
|
|
5065
|
+
review: "none",
|
|
4822
5066
|
idPrefix: "example",
|
|
4823
5067
|
baseVersion: 1,
|
|
4824
5068
|
renderOutputPath: null,
|
|
@@ -4831,13 +5075,26 @@ const CANVAS_CAPABILITY_SPECS = [
|
|
|
4831
5075
|
mutationCommitted: true,
|
|
4832
5076
|
previousVersion: 1,
|
|
4833
5077
|
version: 2,
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
5078
|
+
rootNodeId: "example_ready_0001",
|
|
5079
|
+
jobId: CAPABILITY_UUID_EXAMPLE,
|
|
5080
|
+
affected: {
|
|
5081
|
+
inserted: 4,
|
|
5082
|
+
changed: 0,
|
|
5083
|
+
removed: 0
|
|
5084
|
+
},
|
|
5085
|
+
insertedNodeIds: [
|
|
5086
|
+
"example_ready_0001",
|
|
5087
|
+
"example_text_0002",
|
|
5088
|
+
"example_text_0003",
|
|
5089
|
+
"example_text_0004"
|
|
5090
|
+
],
|
|
5091
|
+
affectedBounds: {
|
|
5092
|
+
x: 0,
|
|
5093
|
+
y: 0,
|
|
5094
|
+
width: 360,
|
|
5095
|
+
height: 180
|
|
5096
|
+
},
|
|
5097
|
+
removedNodeIds: []
|
|
4841
5098
|
}
|
|
4842
5099
|
}
|
|
4843
5100
|
];
|
|
@@ -4845,7 +5102,7 @@ const CANVAS_CAPABILITY_SPECS = [
|
|
|
4845
5102
|
//#endregion
|
|
4846
5103
|
//#region src/infrastructure/capability-example.mapper.ts
|
|
4847
5104
|
const jsonRecordSchema$2 = z.record(z.string(), z.unknown());
|
|
4848
|
-
const recordFrom$
|
|
5105
|
+
const recordFrom$3 = (value) => {
|
|
4849
5106
|
const parsed = jsonRecordSchema$2.safeParse(value);
|
|
4850
5107
|
return parsed.success ? parsed.data : null;
|
|
4851
5108
|
};
|
|
@@ -4865,7 +5122,7 @@ const alternativeExample = (schema) => {
|
|
|
4865
5122
|
return alternatives === null ? void 0 : toCapabilityExample(alternatives[0]);
|
|
4866
5123
|
};
|
|
4867
5124
|
const objectExample = (schema) => {
|
|
4868
|
-
const properties = recordFrom$
|
|
5125
|
+
const properties = recordFrom$3(schema["properties"]) ?? {};
|
|
4869
5126
|
const required = Array.isArray(schema["required"]) ? schema["required"] : [];
|
|
4870
5127
|
const entries = [];
|
|
4871
5128
|
for (const name of required) if (typeof name === "string") entries.push([name, toCapabilityExample(properties[name])]);
|
|
@@ -4877,7 +5134,7 @@ const numberExample = (schema) => {
|
|
|
4877
5134
|
return 0;
|
|
4878
5135
|
};
|
|
4879
5136
|
const toCapabilityExample = (schemaValue) => {
|
|
4880
|
-
const schema = recordFrom$
|
|
5137
|
+
const schema = recordFrom$3(schemaValue);
|
|
4881
5138
|
if (schema === null) return {};
|
|
4882
5139
|
if ("default" in schema) return schema["default"];
|
|
4883
5140
|
if ("const" in schema) return schema["const"];
|
|
@@ -5115,25 +5372,25 @@ const OPTION_DESCRIPTIONS = {
|
|
|
5115
5372
|
//#endregion
|
|
5116
5373
|
//#region src/infrastructure/capability-definition.mapper.ts
|
|
5117
5374
|
const jsonRecordSchema$1 = z.record(z.string(), z.unknown());
|
|
5118
|
-
const recordFrom$
|
|
5375
|
+
const recordFrom$2 = (value) => {
|
|
5119
5376
|
const parsed = jsonRecordSchema$1.safeParse(value);
|
|
5120
5377
|
return parsed.success ? parsed.data : null;
|
|
5121
5378
|
};
|
|
5122
5379
|
const ordered = (value) => {
|
|
5123
5380
|
if (Array.isArray(value)) return value.map((entry) => ordered(entry));
|
|
5124
|
-
const record = recordFrom$
|
|
5381
|
+
const record = recordFrom$2(value);
|
|
5125
5382
|
if (record === null) return value;
|
|
5126
5383
|
return Object.fromEntries(Object.entries(record).toSorted(([left], [right]) => left.localeCompare(right)).map(([key, held]) => [key, ordered(held)]));
|
|
5127
5384
|
};
|
|
5128
5385
|
const digest = (value) => createHash("sha256").update(JSON.stringify(ordered(value))).digest("hex");
|
|
5129
5386
|
const kebab = (value) => value.replaceAll(/[A-Z]/gu, (letter) => `-${letter.toLowerCase()}`);
|
|
5130
5387
|
const fieldsFrom = (schemaValue, procedure, direction) => {
|
|
5131
|
-
const schema = recordFrom$
|
|
5132
|
-
const properties = recordFrom$
|
|
5388
|
+
const schema = recordFrom$2(schemaValue);
|
|
5389
|
+
const properties = recordFrom$2(schema?.["properties"]);
|
|
5133
5390
|
if (properties === null) return [];
|
|
5134
5391
|
const required = new Set(Array.isArray(schema?.["required"]) ? schema["required"] : []);
|
|
5135
5392
|
return Object.entries(properties).map(([name, property]) => {
|
|
5136
|
-
const detail = recordFrom$
|
|
5393
|
+
const detail = recordFrom$2(property);
|
|
5137
5394
|
const option = `--${kebab(name)}`;
|
|
5138
5395
|
const meaning = direction === "input" ? OPTION_DESCRIPTIONS[`${procedure} ${option}`] ?? OPTION_DESCRIPTIONS[option] : void 0;
|
|
5139
5396
|
return {
|
|
@@ -5144,18 +5401,24 @@ const fieldsFrom = (schemaValue, procedure, direction) => {
|
|
|
5144
5401
|
});
|
|
5145
5402
|
};
|
|
5146
5403
|
const summaryFor = (id, meta) => {
|
|
5147
|
-
const description = recordFrom$
|
|
5404
|
+
const description = recordFrom$2(meta)?.["description"];
|
|
5148
5405
|
return PROCEDURE_DESCRIPTIONS[id] ?? (typeof description === "string" && description !== "" ? description : `Run the ${id} product operation.`);
|
|
5149
5406
|
};
|
|
5150
5407
|
const nextFor = (id, operation) => {
|
|
5151
5408
|
const namespace = id.split(".", 1)[0] ?? id;
|
|
5152
5409
|
if (id.endsWith(".list")) return [`Choose an id from the result before another ${namespace} operation.`];
|
|
5410
|
+
if ([
|
|
5411
|
+
"canvas.apply",
|
|
5412
|
+
"canvas.edit",
|
|
5413
|
+
"canvas.writeHtml"
|
|
5414
|
+
].includes(id)) return ["Reuse the committed version for the next edit. Render the affected screen when the requested visual change is ready to review."];
|
|
5415
|
+
if (id === "canvas.render") return ["Inspect the returned image; read more structure only if the pixels reveal a discrepancy."];
|
|
5153
5416
|
if (operation === "mutation") return [`Read the affected ${namespace} resource to confirm the result.`];
|
|
5154
5417
|
return [`Use the returned identifiers and version in the next ${namespace} operation.`];
|
|
5155
5418
|
};
|
|
5156
5419
|
const guideFor = (input) => ({
|
|
5157
5420
|
summary: summaryFor(input.id, input.meta),
|
|
5158
|
-
useWhen: input.operation === "query" ? `Use when current ${input.id.split(".", 1)[0] ?? "product"} state is
|
|
5421
|
+
useWhen: input.operation === "query" ? `Use when current ${input.id.split(".", 1)[0] ?? "product"} state is missing from the task context.` : `Use when the requested change exactly matches ${input.id}; read the current state first when a version or identifier may have changed.`,
|
|
5159
5422
|
preconditions: [
|
|
5160
5423
|
"Authenticate as the accountable Enhance person.",
|
|
5161
5424
|
"Use only resource identifiers returned by an earlier capability result or supplied by the person.",
|
|
@@ -5167,7 +5430,7 @@ const guideFor = (input) => ({
|
|
|
5167
5430
|
recovery: [
|
|
5168
5431
|
"BAD_REQUEST: correct the named fields and call again.",
|
|
5169
5432
|
"UNAUTHORIZED: restore Enhance authentication, then retry once.",
|
|
5170
|
-
"FORBIDDEN or NOT_FOUND:
|
|
5433
|
+
"FORBIDDEN or NOT_FOUND: check the supplied resource and selection; do not substitute unrelated content. Ask for corrected access or scope if needed.",
|
|
5171
5434
|
"CONFLICT: read the current resource, merge the intended change, and retry with its version.",
|
|
5172
5435
|
"INTERNAL: run Enhance diagnostics, report the failure, and stop repeating the call."
|
|
5173
5436
|
],
|
|
@@ -5405,6 +5668,11 @@ const PROCEDURE_CAPABILITY_POLICIES = {
|
|
|
5405
5668
|
}
|
|
5406
5669
|
};
|
|
5407
5670
|
const UTILITY_CAPABILITY_POLICIES = {
|
|
5671
|
+
"canvas.edit": {
|
|
5672
|
+
exposure: "shared",
|
|
5673
|
+
reason: "Small scoped design edits share one atomic authoring path.",
|
|
5674
|
+
owner: "product"
|
|
5675
|
+
},
|
|
5408
5676
|
"canvas.apply": {
|
|
5409
5677
|
exposure: "shared",
|
|
5410
5678
|
reason: "Bounded canvas operation batches are a product authoring capability.",
|
|
@@ -9286,7 +9554,7 @@ const IMPORT_SOURCE_EXAMPLE = {
|
|
|
9286
9554
|
targetNodeId: "root"
|
|
9287
9555
|
}
|
|
9288
9556
|
};
|
|
9289
|
-
const recordFrom = (value, label) => {
|
|
9557
|
+
const recordFrom$1 = (value, label) => {
|
|
9290
9558
|
const parsed = jsonRecordSchema.safeParse(value);
|
|
9291
9559
|
if (!parsed.success) throw new TypeError(`${label} is not an object`);
|
|
9292
9560
|
return parsed.data;
|
|
@@ -9315,8 +9583,8 @@ const procedureSchemas = (definitions, id) => {
|
|
|
9315
9583
|
};
|
|
9316
9584
|
const createCapabilityCatalogAdapter = () => {
|
|
9317
9585
|
const router = createRouterShapeAdapter();
|
|
9318
|
-
const routerInternals = recordFrom(Reflect.get(router, "_def"), "router internals");
|
|
9319
|
-
const definitions = recordFrom(routerInternals["procedures"], "router procedures");
|
|
9586
|
+
const routerInternals = recordFrom$1(Reflect.get(router, "_def"), "router internals");
|
|
9587
|
+
const definitions = recordFrom$1(routerInternals["procedures"], "router procedures");
|
|
9320
9588
|
const parsedProcedures = parseRouter({ router });
|
|
9321
9589
|
const policy = createCapabilityPolicyAdapter();
|
|
9322
9590
|
policy.assertProcedureInventory(parsedProcedures.map(([id]) => id));
|
|
@@ -9385,33 +9653,53 @@ var ProcessExitError = class extends FailedToExitError {
|
|
|
9385
9653
|
|
|
9386
9654
|
//#endregion
|
|
9387
9655
|
//#region src/infrastructure/mcp-capability-discovery.adapter.ts
|
|
9388
|
-
const EXACT_ID_SCORE = 1e4;
|
|
9389
|
-
const ID_PREFIX_SCORE = 1e3;
|
|
9390
|
-
const ID_SEGMENT_SCORE = 100;
|
|
9391
|
-
const ID_SUBSTRING_SCORE = 40;
|
|
9392
|
-
const GUIDE_MATCH_SCORE = 10;
|
|
9393
9656
|
const NO_MATCH_SCORE = 0;
|
|
9394
|
-
const
|
|
9657
|
+
const EXACT_ID_SCORE = 1e5;
|
|
9658
|
+
const EXACT_ALIAS_SCORE = 9e4;
|
|
9659
|
+
const ALIAS_TERM_SCORE = 1100;
|
|
9660
|
+
const ID_TERM_SCORE = 1050;
|
|
9661
|
+
const PURPOSE_TERM_SCORE = 1e3;
|
|
9662
|
+
const CONTRACT_BUDGET_BYTES = 2e4;
|
|
9663
|
+
const STOP_WORDS = new Set("a an and are as at be before by can do for from how i in into is it me my of on or our the then this to use with".split(" "));
|
|
9664
|
+
const INTENT_ALIASES = {
|
|
9665
|
+
"canvas.writeHtml": [
|
|
9666
|
+
"design editable screen",
|
|
9667
|
+
"create screen",
|
|
9668
|
+
"new screen",
|
|
9669
|
+
"mockup",
|
|
9670
|
+
"html css",
|
|
9671
|
+
"build layout"
|
|
9672
|
+
],
|
|
9673
|
+
"canvas.edit": [
|
|
9674
|
+
"change selected text",
|
|
9675
|
+
"edit text",
|
|
9676
|
+
"change styles",
|
|
9677
|
+
"duplicate card",
|
|
9678
|
+
"move node",
|
|
9679
|
+
"rename layer",
|
|
9680
|
+
"update selected design"
|
|
9681
|
+
],
|
|
9682
|
+
"canvas.render": [
|
|
9683
|
+
"render canvas",
|
|
9684
|
+
"preview design",
|
|
9685
|
+
"inspect pixels",
|
|
9686
|
+
"screenshot design"
|
|
9687
|
+
]
|
|
9688
|
+
};
|
|
9689
|
+
const normalized = (value) => value.replaceAll(/([a-z])([A-Z])/gu, "$1 $2").toLocaleLowerCase("en-AU").replaceAll(/[^a-z0-9]+/gu, " ").trim();
|
|
9690
|
+
const termsFor = (value) => [...new Set(normalized(value).split(" ").filter((term) => term !== "" && !STOP_WORDS.has(term)))];
|
|
9395
9691
|
const scoreFor = (capability, offered) => {
|
|
9396
9692
|
const query = normalized(offered);
|
|
9397
|
-
|
|
9398
|
-
|
|
9399
|
-
|
|
9400
|
-
const
|
|
9401
|
-
|
|
9402
|
-
|
|
9403
|
-
|
|
9404
|
-
|
|
9405
|
-
|
|
9406
|
-
|
|
9407
|
-
].join(" "));
|
|
9408
|
-
const terms = query.split(" ").filter((term) => term !== "");
|
|
9409
|
-
let score = id.startsWith(query) ? ID_PREFIX_SCORE : NO_MATCH_SCORE;
|
|
9410
|
-
for (const term of terms) {
|
|
9411
|
-
if (idSegments.has(term)) score += ID_SEGMENT_SCORE;
|
|
9412
|
-
else if (id.includes(term)) score += ID_SUBSTRING_SCORE;
|
|
9413
|
-
if (guide.includes(term)) score += GUIDE_MATCH_SCORE;
|
|
9414
|
-
}
|
|
9693
|
+
if (query === normalized(capability.id)) return EXACT_ID_SCORE;
|
|
9694
|
+
const aliases = INTENT_ALIASES[capability.id] ?? [];
|
|
9695
|
+
if (aliases.some((alias) => normalized(alias) === query)) return EXACT_ALIAS_SCORE;
|
|
9696
|
+
const aliasTerms = new Set(aliases.flatMap((alias) => termsFor(alias)));
|
|
9697
|
+
const idTerms = new Set(termsFor(capability.id));
|
|
9698
|
+
const purposeTerms = new Set(termsFor(capability.guide.summary));
|
|
9699
|
+
let score = NO_MATCH_SCORE;
|
|
9700
|
+
for (const term of termsFor(offered)) if (aliasTerms.has(term)) score += ALIAS_TERM_SCORE;
|
|
9701
|
+
else if (idTerms.has(term)) score += ID_TERM_SCORE;
|
|
9702
|
+
else if (purposeTerms.has(term)) score += PURPOSE_TERM_SCORE;
|
|
9415
9703
|
return score;
|
|
9416
9704
|
};
|
|
9417
9705
|
const exampleFor = (capability) => {
|
|
@@ -9453,11 +9741,24 @@ const createMcpCapabilityDiscoveryAdapter = (catalog) => ({
|
|
|
9453
9741
|
const scoreDifference = right.score - left.score;
|
|
9454
9742
|
return scoreDifference === NO_MATCH_SCORE ? left.capability.id.localeCompare(right.capability.id) : scoreDifference;
|
|
9455
9743
|
});
|
|
9456
|
-
|
|
9744
|
+
const summary = {
|
|
9457
9745
|
matches: ranked.slice(0, input.limit).map(({ capability }) => toBrief(capability)),
|
|
9458
9746
|
totalMatches: ranked.length,
|
|
9459
9747
|
truncated: ranked.length > input.limit
|
|
9460
9748
|
};
|
|
9749
|
+
const best = ranked[0];
|
|
9750
|
+
if (best === void 0) return summary;
|
|
9751
|
+
const withContract = {
|
|
9752
|
+
...summary,
|
|
9753
|
+
bestContract: toContract(best.capability)
|
|
9754
|
+
};
|
|
9755
|
+
return Buffer$1.byteLength(JSON.stringify({
|
|
9756
|
+
ok: true,
|
|
9757
|
+
result: withContract
|
|
9758
|
+
}), "utf8") <= CONTRACT_BUDGET_BYTES ? withContract : {
|
|
9759
|
+
...summary,
|
|
9760
|
+
detailRequired: { capability: best.capability.id }
|
|
9761
|
+
};
|
|
9461
9762
|
},
|
|
9462
9763
|
describe: (id) => {
|
|
9463
9764
|
const capability = catalog.find((candidate) => candidate.id === id);
|
|
@@ -9543,6 +9844,125 @@ const toExitCode = (failure, isMalformed, error) => {
|
|
|
9543
9844
|
return 1;
|
|
9544
9845
|
};
|
|
9545
9846
|
|
|
9847
|
+
//#endregion
|
|
9848
|
+
//#region src/infrastructure/canvas-authoring-result.mapper.ts
|
|
9849
|
+
const MAX_RECEIPT_BYTES = 4096;
|
|
9850
|
+
const DETAIL_REFERENCE_ALLOWANCE = 512;
|
|
9851
|
+
const MAX_CONTINUATION_IDS = 20;
|
|
9852
|
+
const receiptSchema = z.object({
|
|
9853
|
+
canvasId: z.uuid(),
|
|
9854
|
+
mutationCommitted: z.literal(true),
|
|
9855
|
+
previousVersion: z.number().int().positive(),
|
|
9856
|
+
version: z.number().int().positive(),
|
|
9857
|
+
rootNodeId: z.string().max(200).optional(),
|
|
9858
|
+
mutationId: z.uuid().optional(),
|
|
9859
|
+
jobId: z.uuid().optional(),
|
|
9860
|
+
affected: z.object({
|
|
9861
|
+
inserted: z.number(),
|
|
9862
|
+
changed: z.number(),
|
|
9863
|
+
removed: z.number()
|
|
9864
|
+
}),
|
|
9865
|
+
affectedBounds: canvasSceneBoxSchema.nullable()
|
|
9866
|
+
});
|
|
9867
|
+
const canvasRenderResultSchema = z.object({
|
|
9868
|
+
jobId: z.uuid(),
|
|
9869
|
+
canvasId: z.uuid(),
|
|
9870
|
+
requestedVersion: z.number().nullable(),
|
|
9871
|
+
loadedVersion: z.number(),
|
|
9872
|
+
target: canvasRenderTargetSchema,
|
|
9873
|
+
sourceState: canvasRenderSourceStateEvidenceSchema.nullable(),
|
|
9874
|
+
bounds: canvasSceneBoxSchema,
|
|
9875
|
+
width: z.number(),
|
|
9876
|
+
height: z.number(),
|
|
9877
|
+
scale: z.number(),
|
|
9878
|
+
contentType: z.literal("image/png"),
|
|
9879
|
+
bytes: z.number(),
|
|
9880
|
+
warnings: z.array(canvasRenderWarningSchema),
|
|
9881
|
+
path: z.string().min(1),
|
|
9882
|
+
sensitive: z.literal(true),
|
|
9883
|
+
cleanup: z.enum(["unlink-after-use", "caller-owned"]),
|
|
9884
|
+
deleteAfter: z.string().optional()
|
|
9885
|
+
});
|
|
9886
|
+
const recordFrom = (value) => typeof value === "object" && value !== null && !Array.isArray(value) ? Object.fromEntries(Object.entries(value)) : null;
|
|
9887
|
+
const receiptFrom = (value) => {
|
|
9888
|
+
const receipt = receiptSchema.safeParse(value);
|
|
9889
|
+
if (receipt.success) return receipt.data;
|
|
9890
|
+
const applied = applyCanvasOperationsOutputSchema.safeParse(value);
|
|
9891
|
+
if (!applied.success) return null;
|
|
9892
|
+
return {
|
|
9893
|
+
canvasId: applied.data.canvasId,
|
|
9894
|
+
mutationCommitted: true,
|
|
9895
|
+
mutationId: applied.data.mutationId,
|
|
9896
|
+
previousVersion: applied.data.previousVersion,
|
|
9897
|
+
version: applied.data.version,
|
|
9898
|
+
affected: {
|
|
9899
|
+
inserted: applied.data.insertedNodeIds.length,
|
|
9900
|
+
changed: applied.data.changedNodeIds.length,
|
|
9901
|
+
removed: applied.data.removedNodeIds.length
|
|
9902
|
+
},
|
|
9903
|
+
affectedBounds: applied.data.affectedBounds
|
|
9904
|
+
};
|
|
9905
|
+
};
|
|
9906
|
+
const canFitReceipt = (value) => Buffer.byteLength(JSON.stringify(value)) <= MAX_RECEIPT_BYTES - DETAIL_REFERENCE_ALLOWANCE;
|
|
9907
|
+
const boundedEntries = (compact, key, entries) => {
|
|
9908
|
+
const kept = [];
|
|
9909
|
+
for (const entry of entries.slice(0, MAX_CONTINUATION_IDS)) {
|
|
9910
|
+
if (!canFitReceipt({
|
|
9911
|
+
...compact,
|
|
9912
|
+
[key]: [...kept, entry]
|
|
9913
|
+
})) break;
|
|
9914
|
+
kept.push(entry);
|
|
9915
|
+
}
|
|
9916
|
+
return kept;
|
|
9917
|
+
};
|
|
9918
|
+
const toCanvasAuthoringResult = (value) => {
|
|
9919
|
+
const original = recordFrom(value);
|
|
9920
|
+
if (original === null) return null;
|
|
9921
|
+
const receipt = receiptFrom(value);
|
|
9922
|
+
if (receipt === null) return null;
|
|
9923
|
+
const complete = {
|
|
9924
|
+
...original,
|
|
9925
|
+
...receipt
|
|
9926
|
+
};
|
|
9927
|
+
if (canFitReceipt(complete)) return {
|
|
9928
|
+
value: complete,
|
|
9929
|
+
detail: null
|
|
9930
|
+
};
|
|
9931
|
+
const compact = {
|
|
9932
|
+
...receipt,
|
|
9933
|
+
detailTruncated: true
|
|
9934
|
+
};
|
|
9935
|
+
for (const key of [
|
|
9936
|
+
"mode",
|
|
9937
|
+
"targetNodeId",
|
|
9938
|
+
"review"
|
|
9939
|
+
]) {
|
|
9940
|
+
const entry = original[key];
|
|
9941
|
+
if (entry !== void 0 && canFitReceipt({
|
|
9942
|
+
...compact,
|
|
9943
|
+
[key]: entry
|
|
9944
|
+
})) compact[key] = entry;
|
|
9945
|
+
}
|
|
9946
|
+
for (const key of [
|
|
9947
|
+
"insertedNodeIds",
|
|
9948
|
+
"changedNodeIds",
|
|
9949
|
+
"removedNodeIds",
|
|
9950
|
+
"createdNodes",
|
|
9951
|
+
"duplicatedNodes",
|
|
9952
|
+
"moves",
|
|
9953
|
+
"affectedParents"
|
|
9954
|
+
]) {
|
|
9955
|
+
const entries = original[key];
|
|
9956
|
+
if (!Array.isArray(entries)) continue;
|
|
9957
|
+
const kept = boundedEntries(compact, key, entries);
|
|
9958
|
+
if (kept.length > 0) compact[key] = kept;
|
|
9959
|
+
}
|
|
9960
|
+
return {
|
|
9961
|
+
value: compact,
|
|
9962
|
+
detail: complete
|
|
9963
|
+
};
|
|
9964
|
+
};
|
|
9965
|
+
|
|
9546
9966
|
//#endregion
|
|
9547
9967
|
//#region src/infrastructure/cli-output-identity.lib.ts
|
|
9548
9968
|
const commandReferencePattern = /(?<![-\w@])enhance(?=(?:-mcp)?(?:[^-\w]|$))/gu;
|
|
@@ -9570,4 +9990,4 @@ const withCommandInFailure = (value, commandName) => ({
|
|
|
9570
9990
|
});
|
|
9571
9991
|
|
|
9572
9992
|
//#endregion
|
|
9573
|
-
export {
|
|
9993
|
+
export { createOrganisationOutputSchema as $, parseCanvasReference as A, canvasSchema as At, PROTOTYPE_ARTIFACT_MANIFEST_PATH as B, transcriptReadCapabilityInputSchema as C, canvasAdditionalStyleSchema as Ct, assertCanvasReferenceOperations as D, canvasAxisStyleProperties as Dt, assertCanvasReferenceNodes as E, canvasAuthoredStyleDeclarations as Et, completeScreenOutputSchema as F, getPrototypePublishStatusOutputSchema as G, createPrototypeArtifactOutputSchema as H, createScreenOutputSchema as I, submitPrototypeArtifactOutputSchema as J, prototypeArtifactManifestSchema as K, appendRecordingChunkOutputSchema as L, CliError as M, transcriptOutputSchema as N, canvasReferenceNodeIds as O, canvasLayoutMainAxisOf as Ot, appErrorSchema as P, createAgentTokenOutputSchema as Q, completeRecordingOutputSchema as R, recordingSnapshotCapabilityInputSchema as S, canvasReadableSceneDocumentSchema as St, canvasEditsSchema as T, canvasAuthoredLayoutValueOf as Tt, foldPrototypeArtifactPath as U, attachPrototypeArtifactOutputSchema as V, getPrototypeArtifactCapabilitiesOutputSchema as W, MCP_AUTH_SCOPE as X, getMeOutputSchema as Y, cliAuthConfigurationSchema as Z, canvasApplyCapabilityInputSchema as _, canvasWorldBoundsSchema as _t, toExitCode as a, applyCanvasOperationsInputSchema as at, commentAttentionCapabilityInputSchema as b, downloadCanvasRenderOutputSchema as bt, toSharedCapabilities as c, canvasNodeStylePatchSchema as ct, createCapabilityCatalogAdapter as d, saveCanvasDocumentOutputSchema as dt, emptyFixtureDocument as et, createRouterShapeAdapter as f, createCanvasConversionOutputSchema as ft, PROCEDURE_DESCRIPTIONS as g, canvasRenderTargetSchema as gt, OPTION_DESCRIPTIONS as h, canvasRenderSourceStateSchema as ht, toCanvasAuthoringResult as i, MAX_CANVAS_OPERATIONS as it, PartialBatchError as j, fromCanvasReference as k, canvasLayoutPriorityDeclarations as kt, createMcpCapabilityDiscoveryAdapter as l, canvasLayoutWithoutCssProperties as lt, toCapabilityDefinition as m, RENDER_MIN_SCALE as mt, withCommandName as n, beginCanvasActivityOutputSchema as nt, toFailurePayload as o, applyCanvasOperationsOutputSchema as ot, createCapabilityPolicyAdapter as p, getCanvasConversionOutputSchema as pt, prototypeArtifactPathSchema as q, canvasRenderResultSchema as r, canvasAgentActivityPhaseSchema as rt, toPresentedCapabilities as s, canvasOperationSchema as st, withCommandInFailure as t, withFixtureScreen as tt, ProcessExitError as u, getCanvasDocumentOutputSchema as ut, canvasRenderCapabilityInputSchema as v, createCanvasRenderOutputSchema as vt, canvasEditCapabilityInputSchema as w, canvasTypographySchema as wt, prototypePublishCapabilityInputSchema as x, getCanvasRenderOutputSchema as xt, canvasWriteHtmlCapabilityInputSchema as y, createRecordingSnapshotOutputSchema as yt, startRecordingOutputSchema as z };
|