@enhance-eng/enhance 0.1.39 → 0.1.158
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-DgHRuXTI.mjs → cli-output-identity.lib-DBMayAFH.mjs} +713 -306
- package/dist/main.mjs +8151 -362
- package/dist/{mcp-invocation.adapter-CjZnnMCd.mjs → mcp-invocation.adapter-HEKcQv-G.mjs} +4 -4
- package/dist/mcp-main.mjs +7 -7
- package/dist/{mcp-server.adapter-DOHJxL6l.mjs → mcp-server.adapter-D1D-6M_L.mjs} +2 -2
- package/dist/mcp.mjs +2 -2
- package/dist/{mutation-key.adapter-BWkNj5jp.mjs → mutation-key.adapter-DKwaV7lk.mjs} +43 -21
- package/dist/remote-mcp-main.mjs +6 -6
- package/package.json +1 -1
|
@@ -7,22 +7,12 @@ import { TRPCError, initTRPC } from "@trpc/server";
|
|
|
7
7
|
import { middlewareMarker } from "@trpc/server/unstable-core-do-not-import";
|
|
8
8
|
import { setTimeout } from "node:timers/promises";
|
|
9
9
|
import assert from "node:assert/strict";
|
|
10
|
-
import { Buffer as Buffer$1 } from "node:buffer";
|
|
11
10
|
import { TRPCClientError } from "@trpc/client";
|
|
11
|
+
import { Buffer as Buffer$1 } from "node:buffer";
|
|
12
12
|
|
|
13
13
|
//#region \0rolldown/runtime.js
|
|
14
14
|
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
15
15
|
|
|
16
|
-
//#endregion
|
|
17
|
-
//#region ../../packages/canvas-format/src/canvas-edit-support.lib.ts
|
|
18
|
-
/** Why the API refused an operation, as a fixed value. Never the words of the refusal. */
|
|
19
|
-
const CANVAS_REFUSAL_CODES = [
|
|
20
|
-
"appearance-unsupported-component",
|
|
21
|
-
"styles-unsupported-component",
|
|
22
|
-
"text-shadow-blend-unsupported",
|
|
23
|
-
"recording-aspect-not-preserved"
|
|
24
|
-
];
|
|
25
|
-
|
|
26
16
|
//#endregion
|
|
27
17
|
//#region ../../packages/canvas-format/src/canvas-format.consts.ts
|
|
28
18
|
/** Historical formats stay pinned; an ordinary writer always uses CANVAS_SCENE_VERSION. */
|
|
@@ -39,7 +29,8 @@ const LEGACY_CANVAS_FORMATS = {
|
|
|
39
29
|
v9: 9,
|
|
40
30
|
v10: 10,
|
|
41
31
|
v11: 11,
|
|
42
|
-
v12: 12
|
|
32
|
+
v12: 12,
|
|
33
|
+
v13: 13
|
|
43
34
|
};
|
|
44
35
|
const LEGACY_CANVAS_ADAPTATIONS = {
|
|
45
36
|
[LEGACY_CANVAS_FORMATS.v1]: "layout",
|
|
@@ -53,9 +44,20 @@ const LEGACY_CANVAS_ADAPTATIONS = {
|
|
|
53
44
|
[LEGACY_CANVAS_FORMATS.v9]: "geometry",
|
|
54
45
|
[LEGACY_CANVAS_FORMATS.v10]: "geometry",
|
|
55
46
|
[LEGACY_CANVAS_FORMATS.v11]: "css",
|
|
56
|
-
[LEGACY_CANVAS_FORMATS.v12]: "text-shadow-blend"
|
|
47
|
+
[LEGACY_CANVAS_FORMATS.v12]: "text-shadow-blend",
|
|
48
|
+
[LEGACY_CANVAS_FORMATS.v13]: "format-number"
|
|
57
49
|
};
|
|
58
50
|
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region ../../packages/canvas-format/src/canvas-edit-support.lib.ts
|
|
53
|
+
/** Why the API refused an operation, as a fixed value. Never the words of the refusal. */
|
|
54
|
+
const CANVAS_REFUSAL_CODES = [
|
|
55
|
+
"appearance-unsupported-component",
|
|
56
|
+
"styles-unsupported-component",
|
|
57
|
+
"text-shadow-blend-unsupported",
|
|
58
|
+
"recording-aspect-not-preserved"
|
|
59
|
+
];
|
|
60
|
+
|
|
59
61
|
//#endregion
|
|
60
62
|
//#region ../../packages/canvas-format/src/canvas-css-adaptation.lib.ts
|
|
61
63
|
const isRecord$3 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -305,10 +307,11 @@ const withoutTextShadowBlends = (document) => {
|
|
|
305
307
|
|
|
306
308
|
//#endregion
|
|
307
309
|
//#region ../../packages/canvas-format/src/canvas-format.lib.ts
|
|
308
|
-
const READABLE_FORMATS = /* @__PURE__ */ new Set([...Object.values(LEGACY_CANVAS_FORMATS),
|
|
310
|
+
const READABLE_FORMATS = /* @__PURE__ */ new Set([...Object.values(LEGACY_CANVAS_FORMATS), 14]);
|
|
309
311
|
const isReadableCanvasFormat = (version) => READABLE_FORMATS.has(version);
|
|
310
312
|
/** Formats whose adaptation rewrites the stored document in place, keeping its geometry. */
|
|
311
313
|
const ADAPTED_IN_PLACE = /* @__PURE__ */ new Set([
|
|
314
|
+
"format-number",
|
|
312
315
|
"text-shadow-blend",
|
|
313
316
|
"css",
|
|
314
317
|
"geometry"
|
|
@@ -328,20 +331,20 @@ const legacyLayout = (layout) => {
|
|
|
328
331
|
const adaptLegacyFormat = (document) => {
|
|
329
332
|
const version = document["version"];
|
|
330
333
|
if (!isReadableCanvasFormat(version)) return null;
|
|
331
|
-
if (version ===
|
|
334
|
+
if (version === 14 || !isRecord$1(document["nodes"])) return document;
|
|
332
335
|
const adaptation = Object.entries(LEGACY_CANVAS_ADAPTATIONS).find(([format]) => Number(format) === version)?.[1];
|
|
333
336
|
if (ADAPTED_IN_PLACE.has(adaptation)) return {
|
|
334
337
|
...document,
|
|
335
|
-
version:
|
|
338
|
+
version: 14
|
|
336
339
|
};
|
|
337
340
|
if (Object.values(document["nodes"]).some((node) => isRecord$1(node) && node["geometry"] !== void 0)) return null;
|
|
338
341
|
if (adaptation === "typography") return {
|
|
339
342
|
...document,
|
|
340
|
-
version:
|
|
343
|
+
version: 14
|
|
341
344
|
};
|
|
342
345
|
return {
|
|
343
346
|
...document,
|
|
344
|
-
version:
|
|
347
|
+
version: 14,
|
|
345
348
|
nodes: Object.fromEntries(Object.entries(document["nodes"]).map(([id, node]) => [id, isRecord$1(node) && node["layout"] !== void 0 ? {
|
|
346
349
|
...node,
|
|
347
350
|
layout: legacyLayout(node["layout"])
|
|
@@ -350,12 +353,14 @@ const adaptLegacyFormat = (document) => {
|
|
|
350
353
|
};
|
|
351
354
|
/**
|
|
352
355
|
* Adapt known formats in memory, retaining malformed content for each boundary's validator. Format
|
|
353
|
-
*
|
|
354
|
-
*
|
|
356
|
+
* 13 differs from the current format only in that its layers cannot hold a box baseline source, so
|
|
357
|
+
* it takes only the new format number. Format 12 already has the CSS model, so it takes only the
|
|
358
|
+
* text shadow step that every older format takes after the CSS adaptation.
|
|
355
359
|
*/
|
|
356
360
|
const adaptCanvasDocumentFormat = (document) => {
|
|
357
361
|
const adapted = adaptLegacyFormat(document);
|
|
358
362
|
if (adapted === null || adapted === document) return adapted;
|
|
363
|
+
if (document["version"] === LEGACY_CANVAS_FORMATS.v13) return adapted;
|
|
359
364
|
return withoutTextShadowBlends(document["version"] === LEGACY_CANVAS_FORMATS.v12 ? adapted : adaptCanvasCss(adapted));
|
|
360
365
|
};
|
|
361
366
|
|
|
@@ -481,7 +486,8 @@ const viewerCapabilitySchema = z.object({
|
|
|
481
486
|
})).default([]),
|
|
482
487
|
grantableAccessLevels: z.array(grantableAccessLevelSchema).default([]),
|
|
483
488
|
share: z.boolean(),
|
|
484
|
-
manage: z.boolean()
|
|
489
|
+
manage: z.boolean(),
|
|
490
|
+
readHistory: z.boolean().default(false)
|
|
485
491
|
});
|
|
486
492
|
const canvasSchema = z.object({
|
|
487
493
|
id: z.uuid(),
|
|
@@ -557,6 +563,25 @@ const duplicateCanvasInputSchema = z.object({
|
|
|
557
563
|
title: z.string().trim().min(1).optional()
|
|
558
564
|
});
|
|
559
565
|
const duplicateCanvasOutputSchema = z.object({ canvas: canvasSchema });
|
|
566
|
+
/**
|
|
567
|
+
* A new canvas made from work the person holds, such as unsaved changes. The
|
|
568
|
+
* copy's id is chosen by the caller and is its idempotency token: a repeat by the same person
|
|
569
|
+
* returns the canvas that already has it. `sourceCanvasId` names the original; it lends its
|
|
570
|
+
* mounted prototypes and walkthroughs only to the owner of a live original.
|
|
571
|
+
*/
|
|
572
|
+
const copyCanvasFromWorkInputSchema = z.object({
|
|
573
|
+
canvasId: z.uuid(),
|
|
574
|
+
sourceCanvasId: z.uuid().optional(),
|
|
575
|
+
organisationId: z.union([z.uuid(), z.literal("personal")]),
|
|
576
|
+
title: z.string().trim().min(1),
|
|
577
|
+
document: z.record(z.string(), z.unknown()),
|
|
578
|
+
screenIds: z.array(z.uuid())
|
|
579
|
+
});
|
|
580
|
+
/** The document is the one the API wrote, with fonts and walkthroughs mapped to the copy. */
|
|
581
|
+
const copyCanvasFromWorkOutputSchema = z.object({
|
|
582
|
+
canvas: canvasSchema,
|
|
583
|
+
document: z.record(z.string(), z.unknown())
|
|
584
|
+
});
|
|
560
585
|
const permanentlyDeleteCanvasInputSchema = z.object({
|
|
561
586
|
canvasId: z.uuid(),
|
|
562
587
|
confirmation: z.string().min(1)
|
|
@@ -781,14 +806,22 @@ const canvasPaintCoreSchema = z.discriminatedUnion("kind", [
|
|
|
781
806
|
path: ["transform"]
|
|
782
807
|
})
|
|
783
808
|
]);
|
|
784
|
-
const canvasPaintSchema = z.intersection(canvasPaintCoreSchema, z.object({
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
809
|
+
const canvasPaintSchema = z.intersection(canvasPaintCoreSchema, z.object({
|
|
810
|
+
alternatives: z.partialRecord(z.enum([
|
|
811
|
+
"solid",
|
|
812
|
+
"linear-gradient",
|
|
813
|
+
"radial-gradient",
|
|
814
|
+
"angular-gradient",
|
|
815
|
+
"diamond-gradient",
|
|
816
|
+
"image"
|
|
817
|
+
]), canvasPaintCoreSchema).optional(),
|
|
818
|
+
recentGradient: z.enum([
|
|
819
|
+
"linear-gradient",
|
|
820
|
+
"radial-gradient",
|
|
821
|
+
"angular-gradient",
|
|
822
|
+
"diamond-gradient"
|
|
823
|
+
]).optional()
|
|
824
|
+
}));
|
|
792
825
|
const canvasColorDefinitionSchema = z.object({
|
|
793
826
|
id: itemId$1,
|
|
794
827
|
name: z.string().trim().min(1),
|
|
@@ -887,6 +920,17 @@ const canvasFlexLayoutSchema = z.object({
|
|
|
887
920
|
gridAutoRepeat: canvasGridAutoRepeatSchema.optional(),
|
|
888
921
|
padding: canvasFlexPaddingSchema
|
|
889
922
|
}).strict();
|
|
923
|
+
/**
|
|
924
|
+
* What conversion recorded about the source box of an inline-level frame that the frame itself
|
|
925
|
+
* cannot hold: whether it was a button, whether its only clipping overflow was `clip`, and, when
|
|
926
|
+
* conversion took all its content out of its line, how far that line sat above its border-box
|
|
927
|
+
* bottom. The editor works the box baseline rule out from these facts on every draw.
|
|
928
|
+
*/
|
|
929
|
+
const canvasBaselineSourceSchema = z.object({
|
|
930
|
+
button: z.literal(true).optional(),
|
|
931
|
+
overflowClip: z.literal(true).optional(),
|
|
932
|
+
lineAboveBorderBottom: canvasNumberSchema.optional()
|
|
933
|
+
}).strict();
|
|
890
934
|
const canvasNodeLayoutSchema = z.object({
|
|
891
935
|
rotation: canvasNumberSchema.optional(),
|
|
892
936
|
flipHorizontal: z.boolean().optional(),
|
|
@@ -926,6 +970,7 @@ const canvasNodeLayoutSchema = z.object({
|
|
|
926
970
|
order: canvasNumberSchema.int().optional(),
|
|
927
971
|
margin: canvasFlexMarginSchema.partial().optional(),
|
|
928
972
|
clipContent: z.boolean().optional(),
|
|
973
|
+
baselineSource: canvasBaselineSourceSchema.optional(),
|
|
929
974
|
container: canvasFlexLayoutSchema.partial().extend({ padding: canvasFlexPaddingSchema.partial().optional() }).optional()
|
|
930
975
|
}).strict();
|
|
931
976
|
|
|
@@ -1357,6 +1402,7 @@ const CANVAS_RICH_TEXT_STYLE_PROPERTIES = /* @__PURE__ */ new Set([
|
|
|
1357
1402
|
"marginRight",
|
|
1358
1403
|
"marginTop",
|
|
1359
1404
|
"opacity",
|
|
1405
|
+
"overflowWrap",
|
|
1360
1406
|
"paddingBottom",
|
|
1361
1407
|
"paddingLeft",
|
|
1362
1408
|
"paddingRight",
|
|
@@ -1367,11 +1413,16 @@ const CANVAS_RICH_TEXT_STYLE_PROPERTIES = /* @__PURE__ */ new Set([
|
|
|
1367
1413
|
"textDecorationSkipInk",
|
|
1368
1414
|
"textDecorationStyle",
|
|
1369
1415
|
"textDecorationThickness",
|
|
1416
|
+
"textRendering",
|
|
1370
1417
|
"textShadow",
|
|
1371
1418
|
"textTransform",
|
|
1372
1419
|
"textUnderlineOffset",
|
|
1373
1420
|
"verticalAlign",
|
|
1374
1421
|
"whiteSpace",
|
|
1422
|
+
"wordBreak",
|
|
1423
|
+
"wordSpacing",
|
|
1424
|
+
"WebkitFontSmoothing",
|
|
1425
|
+
"WebkitTextFillColor",
|
|
1375
1426
|
"WebkitTextStrokeColor",
|
|
1376
1427
|
"WebkitTextStrokeWidth",
|
|
1377
1428
|
"--canvas-text-stroke-alignment"
|
|
@@ -1646,6 +1697,11 @@ const CANVAS_IMAGE_CONTENT_TYPES = [
|
|
|
1646
1697
|
"image/png",
|
|
1647
1698
|
"image/webp"
|
|
1648
1699
|
];
|
|
1700
|
+
/**
|
|
1701
|
+
* An image the canvas image store may hold. Files people upload keep to the closed list above; an
|
|
1702
|
+
* image a layer held inline is stored under whatever `image/*` type it has.
|
|
1703
|
+
*/
|
|
1704
|
+
const canvasStoredImageContentTypeSchema = z.string().regex(/^image\/[a-z0-9.+-]+$/u);
|
|
1649
1705
|
const reserveCanvasImageInputSchema = z.object({
|
|
1650
1706
|
canvasId: z.uuid(),
|
|
1651
1707
|
contentType: z.enum(CANVAS_IMAGE_CONTENT_TYPES),
|
|
@@ -1674,7 +1730,8 @@ const CANVAS_FONT_CONTENT_TYPES = [
|
|
|
1674
1730
|
"font/ttf",
|
|
1675
1731
|
"font/otf",
|
|
1676
1732
|
"font/woff",
|
|
1677
|
-
"font/woff2"
|
|
1733
|
+
"font/woff2",
|
|
1734
|
+
"font/collection"
|
|
1678
1735
|
];
|
|
1679
1736
|
const canvasFontAssetIdentitySchema = z.object({
|
|
1680
1737
|
canvasId: z.uuid(),
|
|
@@ -1706,10 +1763,8 @@ const canvasFontAssetIdentityFromPath = (path) => {
|
|
|
1706
1763
|
//#endregion
|
|
1707
1764
|
//#region ../../packages/contract/src/canvas/canvas-asset-upload.schema.ts
|
|
1708
1765
|
const MAX_FONT_WEIGHT = 1e3;
|
|
1709
|
-
const
|
|
1710
|
-
|
|
1711
|
-
font: CANVAS_FONT_CONTENT_TYPES
|
|
1712
|
-
};
|
|
1766
|
+
const FONT_CONTENT_TYPES = new Set(CANVAS_FONT_CONTENT_TYPES);
|
|
1767
|
+
const isStoredContentType = (kind, contentType) => kind === "image" ? canvasStoredImageContentTypeSchema.safeParse(contentType).success : FONT_CONTENT_TYPES.has(contentType);
|
|
1713
1768
|
const canvasAssetUploadIdentitySchema = z.strictObject({
|
|
1714
1769
|
canvasId: z.uuid(),
|
|
1715
1770
|
clientToken: z.uuid()
|
|
@@ -1752,7 +1807,7 @@ const canvasAssetUploadOutputSchema = z.strictObject({
|
|
|
1752
1807
|
path: z.string().startsWith("/v1/canvas-assets/"),
|
|
1753
1808
|
state: z.enum(["awaiting_upload", "ready"]),
|
|
1754
1809
|
metadata: canvasAssetMetadataSchema.nullable()
|
|
1755
|
-
}).refine((asset) => asset.state === "ready" === (asset.metadata !== null), "Readiness must match verified metadata.").refine((asset) => asset.metadata === null || asset.metadata.kind === asset.kind, "Metadata must describe the reserved asset kind.").refine((asset) =>
|
|
1810
|
+
}).refine((asset) => asset.state === "ready" === (asset.metadata !== null), "Readiness must match verified metadata.").refine((asset) => asset.metadata === null || asset.metadata.kind === asset.kind, "Metadata must describe the reserved asset kind.").refine((asset) => isStoredContentType(asset.kind, asset.contentType), "Content type must match the asset kind.").refine((asset) => asset.path === (asset.kind === "image" ? canvasImageAssetPath(asset.canvasId, asset.assetId) : canvasFontAssetPath(asset.canvasId, asset.sha256)), "The resource path must match its native identity.");
|
|
1756
1811
|
const reserveCanvasAssetOutputSchema = canvasAssetUploadOutputSchema.safeExtend({ upload: signedUploadSchema.nullable() }).refine((asset) => asset.state === "awaiting_upload" === (asset.upload !== null), "Only pending uploads receive upload access.");
|
|
1757
1812
|
|
|
1758
1813
|
//#endregion
|
|
@@ -1978,8 +2033,7 @@ const cssValue = (value, shouldPreserveCase) => {
|
|
|
1978
2033
|
const source = String(value).replace(/\s*!important\s*$/iu, "").trim();
|
|
1979
2034
|
return shouldPreserveCase || source.includes("(") ? source : source.toLowerCase();
|
|
1980
2035
|
};
|
|
1981
|
-
|
|
1982
|
-
const canvasAuthoredLayoutValueOf = (node, property) => {
|
|
2036
|
+
const authoredLayoutValue = (node, property) => {
|
|
1983
2037
|
let result = null;
|
|
1984
2038
|
let isImportant = false;
|
|
1985
2039
|
const declarations = Object.entries(canvasAuthoredStyleDeclarations(node));
|
|
@@ -1995,6 +2049,24 @@ const canvasAuthoredLayoutValueOf = (node, property) => {
|
|
|
1995
2049
|
}
|
|
1996
2050
|
return result ?? void 0;
|
|
1997
2051
|
};
|
|
2052
|
+
/**
|
|
2053
|
+
* Edits replace a node's style objects rather than changing them, so their identity keys the values
|
|
2054
|
+
* already read. Rendering a large document reads each property of each node many times.
|
|
2055
|
+
*/
|
|
2056
|
+
const readAuthoredValues = /* @__PURE__ */ new WeakMap();
|
|
2057
|
+
/** Read supported authored longhands without measuring or rewriting unresolved CSS expressions. */
|
|
2058
|
+
const canvasAuthoredLayoutValueOf = (node, property) => {
|
|
2059
|
+
const known = readAuthoredValues.get(node.styles);
|
|
2060
|
+
const read = known !== void 0 && known.additionalStyles === node.additionalStyles ? known : {
|
|
2061
|
+
additionalStyles: node.additionalStyles,
|
|
2062
|
+
values: /* @__PURE__ */ new Map()
|
|
2063
|
+
};
|
|
2064
|
+
if (read !== known) readAuthoredValues.set(node.styles, read);
|
|
2065
|
+
if (read.values.has(property)) return read.values.get(property);
|
|
2066
|
+
const value = authoredLayoutValue(node, property);
|
|
2067
|
+
read.values.set(property, value);
|
|
2068
|
+
return value;
|
|
2069
|
+
};
|
|
1998
2070
|
/** Named controls override only their own longhand, even beside an important shorthand. */
|
|
1999
2071
|
const canvasLayoutPriorityDeclarations = (node, declarations) => {
|
|
2000
2072
|
const important = new Set(Object.entries(canvasAuthoredStyleDeclarations(node)).filter(([, value]) => hasCanvasCssPriority(value)).flatMap(([property]) => canvasCssPropertyScope(property)));
|
|
@@ -2123,10 +2195,11 @@ const canvasGeometrySchema = z.discriminatedUnion("kind", [
|
|
|
2123
2195
|
//#endregion
|
|
2124
2196
|
//#region ../../packages/contract/src/canvas/canvas-scene.schema.ts
|
|
2125
2197
|
const CANVAS_COMPOSITING_RETIRED = "Update Enhance: compositing is no longer supported. Use the isolation style or a mask group.";
|
|
2126
|
-
const canvasDocumentFormatSchema = z.literal(
|
|
2198
|
+
const canvasDocumentFormatSchema = z.literal(14, { error: "This editor uses an unsupported document format. Update the editor before changing this canvas." });
|
|
2127
2199
|
const canvasPreservedFontAppearanceSchema = z.object({
|
|
2128
2200
|
signature: z.string().regex(/^[a-f0-9]{16}$/u),
|
|
2129
|
-
image
|
|
2201
|
+
/** The captured picture of the page's text, inline as written or as its canvas image store path. */
|
|
2202
|
+
image: z.string().refine((image) => image.startsWith("data:image/jpeg;base64,") || canvasImageAssetIdentityFromPath(image) !== null),
|
|
2130
2203
|
families: z.array(z.string().min(1)).min(1)
|
|
2131
2204
|
});
|
|
2132
2205
|
const canvasSceneBoxSchema = z.object({
|
|
@@ -2173,7 +2246,7 @@ const canvasSceneNodeSchema = z.looseObject({
|
|
|
2173
2246
|
box: canvasSceneBoxSchema.optional()
|
|
2174
2247
|
});
|
|
2175
2248
|
const canvasSceneDocumentSchema = z.object({
|
|
2176
|
-
version: z.literal(
|
|
2249
|
+
version: z.literal(14),
|
|
2177
2250
|
nodes: z.record(z.string(), canvasSceneNodeSchema),
|
|
2178
2251
|
relationships: z.record(z.string(), z.object({
|
|
2179
2252
|
parentId: z.string().min(1),
|
|
@@ -2190,7 +2263,7 @@ const canvasReadableSceneDocumentSchema = z.preprocess((value) => {
|
|
|
2190
2263
|
return adaptCanvasDocumentFormat(blob);
|
|
2191
2264
|
}, canvasSceneDocumentSchema);
|
|
2192
2265
|
const emptyCanvasSceneDocument = () => ({
|
|
2193
|
-
version:
|
|
2266
|
+
version: 14,
|
|
2194
2267
|
nodes: { root: {
|
|
2195
2268
|
id: "root",
|
|
2196
2269
|
label: "Canvas",
|
|
@@ -2355,7 +2428,8 @@ const RENDER_WARNING_CODES = [
|
|
|
2355
2428
|
"FONT_FALLBACK",
|
|
2356
2429
|
"LOCAL_FONT_FALLBACK",
|
|
2357
2430
|
"SOURCE_FALLBACK",
|
|
2358
|
-
"SCALE_REDUCED"
|
|
2431
|
+
"SCALE_REDUCED",
|
|
2432
|
+
"LAYOUT_FALLBACK"
|
|
2359
2433
|
];
|
|
2360
2434
|
|
|
2361
2435
|
//#endregion
|
|
@@ -2519,6 +2593,9 @@ const createCanvasRenderOutputSchema = z.object({
|
|
|
2519
2593
|
alreadyExists: z.boolean()
|
|
2520
2594
|
});
|
|
2521
2595
|
const getCanvasRenderInputSchema = z.object({ jobId: z.uuid() });
|
|
2596
|
+
/** The longest an export read waits on the server for the job to settle. */
|
|
2597
|
+
const CANVAS_EXPORT_LONGEST_WAIT_MS = 1e4;
|
|
2598
|
+
const getCanvasExportInputSchema = getCanvasRenderInputSchema.extend({ waitMs: z.number().int().min(0).max(CANVAS_EXPORT_LONGEST_WAIT_MS).optional() });
|
|
2522
2599
|
const getCanvasRenderOutputSchema = z.object({ job: canvasRenderJobSchema });
|
|
2523
2600
|
const cancelCanvasRenderInputSchema = z.object({ jobId: z.uuid() });
|
|
2524
2601
|
const cancelCanvasRenderOutputSchema = z.object({ job: canvasRenderJobSchema });
|
|
@@ -3133,7 +3210,6 @@ const insertConvertedSubtreeOperationSchema = z.object({
|
|
|
3133
3210
|
relationships: z.record(z.string().min(1), convertedSubtreeRelationshipSchema)
|
|
3134
3211
|
});
|
|
3135
3212
|
const nodeIdSchema$3 = z.string().min(1);
|
|
3136
|
-
const sortKeySchema = z.string().min(1);
|
|
3137
3213
|
const writableBoxSchema$1 = canvasSceneBoxSchema.extend({
|
|
3138
3214
|
width: z.number().positive(),
|
|
3139
3215
|
height: z.number().positive()
|
|
@@ -3142,10 +3218,7 @@ const placementSchema = z.object({
|
|
|
3142
3218
|
parentId: nodeIdSchema$3,
|
|
3143
3219
|
afterId: nodeIdSchema$3.optional()
|
|
3144
3220
|
});
|
|
3145
|
-
const parentageSchema =
|
|
3146
|
-
parentId: nodeIdSchema$3,
|
|
3147
|
-
sortKey: sortKeySchema
|
|
3148
|
-
});
|
|
3221
|
+
const parentageSchema = convertedSubtreeRelationshipSchema;
|
|
3149
3222
|
const canvasSetStylesOperationSchema = z.object({
|
|
3150
3223
|
op: z.literal("setStyles"),
|
|
3151
3224
|
nodeId: nodeIdSchema$3,
|
|
@@ -3164,6 +3237,11 @@ const currentCanvasOperationSchema = z.discriminatedUnion("op", [
|
|
|
3164
3237
|
documentVersion: z.number().int().nonnegative(),
|
|
3165
3238
|
versionEntryId: z.uuid().optional()
|
|
3166
3239
|
}).optional(),
|
|
3240
|
+
/**
|
|
3241
|
+
* The canvas a pasted screen layer was copied from, which the API checks the screen against
|
|
3242
|
+
* when the writer does not own it and this canvas never showed it.
|
|
3243
|
+
*/
|
|
3244
|
+
screenSource: z.object({ canvasId: z.uuid() }).optional(),
|
|
3167
3245
|
/** A page copy's base name; the API gives the copy the first free name from it. */
|
|
3168
3246
|
pageCopyBase: z.string().refine((base) => base.trim() !== "").optional()
|
|
3169
3247
|
}),
|
|
@@ -3381,10 +3459,17 @@ const getCanvasDocumentOutputSchema = z.object({
|
|
|
3381
3459
|
* has not seen the restore, and the log never reaches back past it.
|
|
3382
3460
|
*/
|
|
3383
3461
|
restoreFenceVersion: z.number().int().positive().optional(),
|
|
3384
|
-
|
|
3462
|
+
/**
|
|
3463
|
+
* Absent only on a catch-up: a read with `afterVersion` whose batches reach the current revision
|
|
3464
|
+
* without a whole-document save or a restore between them. A read without `afterVersion`, or one
|
|
3465
|
+
* across a gap, always carries the document.
|
|
3466
|
+
*/
|
|
3467
|
+
document: canvasDocumentBlobSchema.optional(),
|
|
3385
3468
|
/** The manifest, resolved and signed. This is what makes a cold open one round trip. */
|
|
3386
3469
|
screens: z.array(documentScreenSchema)
|
|
3387
3470
|
});
|
|
3471
|
+
/** The answer to a document read without `afterVersion`, which always carries the document. */
|
|
3472
|
+
const wholeCanvasDocumentOutputSchema = getCanvasDocumentOutputSchema.extend({ document: canvasDocumentBlobSchema });
|
|
3388
3473
|
const saveCanvasDocumentInputSchema = z.object({
|
|
3389
3474
|
canvasId: z.uuid(),
|
|
3390
3475
|
baseVersion: z.number().int().min(1),
|
|
@@ -4138,7 +4223,9 @@ const canvasPreparationPlanSchema = z.strictObject({
|
|
|
4138
4223
|
});
|
|
4139
4224
|
const canvasPreparationWorkPlanSchema = canvasPreparationPlanSchema.extend({ compilations: z.array(z.strictObject({
|
|
4140
4225
|
id: nodeId$5,
|
|
4141
|
-
draft: canvasSubtreeDraftSchema
|
|
4226
|
+
draft: canvasSubtreeDraftSchema,
|
|
4227
|
+
/** Where a screen compile fell back on the try that returned it, as an export says it. */
|
|
4228
|
+
warnings: z.array(canvasRenderWarningSchema).optional()
|
|
4142
4229
|
})).optional() });
|
|
4143
4230
|
const preparationRouteStateSchema = z.discriminatedUnion("state", [
|
|
4144
4231
|
z.object({
|
|
@@ -4154,7 +4241,10 @@ const preparationRouteStateSchema = z.discriminatedUnion("state", [
|
|
|
4154
4241
|
z.object({
|
|
4155
4242
|
state: z.literal("failed"),
|
|
4156
4243
|
jobId: z.uuid(),
|
|
4157
|
-
message: z.string().min(1)
|
|
4244
|
+
message: z.string().min(1),
|
|
4245
|
+
/** A screen compile names an outage or a deadline, which its worker tries again. */
|
|
4246
|
+
reason: z.enum(["SOURCE_FAILED", "PREPARATION_FAILED"]).optional(),
|
|
4247
|
+
retryable: z.boolean().optional()
|
|
4158
4248
|
})
|
|
4159
4249
|
]);
|
|
4160
4250
|
const job = z.object({
|
|
@@ -4731,6 +4821,13 @@ const exposeCanvasRenderOutputSchema = z.discriminatedUnion("purpose", [
|
|
|
4731
4821
|
purpose: z.literal("preparation"),
|
|
4732
4822
|
preparation: canvasRenderPreparationSchema,
|
|
4733
4823
|
screens: z.array(documentScreenSchema).optional(),
|
|
4824
|
+
/** The tries this job has used, less those a storage outage ended, and how many it has. */
|
|
4825
|
+
attempts: z.strictObject({
|
|
4826
|
+
counted: z.number().int().nonnegative(),
|
|
4827
|
+
limit: z.number().int().positive()
|
|
4828
|
+
}).optional(),
|
|
4829
|
+
/** When this try's lease ends; a screen compile prepares its layout until then. */
|
|
4830
|
+
deadlineAt: z.iso.datetime().optional(),
|
|
4734
4831
|
sourceState: z.undefined().optional(),
|
|
4735
4832
|
scale: z.literal(1),
|
|
4736
4833
|
format: z.literal("json")
|
|
@@ -4924,7 +5021,8 @@ const renderRouteStateSchema = z.discriminatedUnion("state", [
|
|
|
4924
5021
|
failure: z.object({
|
|
4925
5022
|
reason: canvasRenderFailureReasonSchema,
|
|
4926
5023
|
message: z.string().min(1).max(MAX_FAILURE_MESSAGE_LENGTH),
|
|
4927
|
-
sourceId: z.string().min(1).max(MAX_SOURCE_ID_LENGTH).nullable()
|
|
5024
|
+
sourceId: z.string().min(1).max(MAX_SOURCE_ID_LENGTH).nullable(),
|
|
5025
|
+
overtaken: z.boolean().optional()
|
|
4928
5026
|
}),
|
|
4929
5027
|
capture: z.null()
|
|
4930
5028
|
})
|
|
@@ -5460,19 +5558,20 @@ const lastRunWith = (nodes, text) => {
|
|
|
5460
5558
|
};
|
|
5461
5559
|
/**
|
|
5462
5560
|
* The one-character runs whose formatting typed text takes. Typing at a link's edge stays
|
|
5463
|
-
* outside the link
|
|
5464
|
-
* stands in.
|
|
5561
|
+
* outside the link, unless the typing continues a replacement of that link; empty text and an
|
|
5562
|
+
* empty last paragraph have no character, so the last run stands in.
|
|
5465
5563
|
*/
|
|
5466
|
-
const canvasTextTypedFormatting = (runs, range) => {
|
|
5564
|
+
const canvasTextTypedFormatting = (runs, range, shouldContinueLink = false) => {
|
|
5467
5565
|
const index = typedCharacterOf(canvasRichTextValueOf(runs), range);
|
|
5468
5566
|
const character = sliceRuns(runs, index, index + 1);
|
|
5469
5567
|
const formatting = character.length > 0 ? character : lastRunWith(runs, " ");
|
|
5470
|
-
|
|
5568
|
+
const linkBefore = canvasRichTextLinkOf(sliceRuns(runs, range.start - 1, range.start));
|
|
5569
|
+
return range.start === range.end && linkBefore !== canvasRichTextLinkOf(sliceRuns(runs, range.start, range.start + 1)) && (!shouldContinueLink || linkBefore === null) ? formattedRuns(formatting, {
|
|
5471
5570
|
type: "link",
|
|
5472
5571
|
href: null
|
|
5473
5572
|
}) : formatting;
|
|
5474
5573
|
};
|
|
5475
|
-
const insertedRuns = (nodes, range, text, shouldKeepEmpty = false) => text === "" && !shouldKeepEmpty ? [] : withText(canvasTextTypedFormatting(nodes, range), text);
|
|
5574
|
+
const insertedRuns = (nodes, range, text, { shouldKeepEmpty = false, shouldContinueLink = false } = {}) => text === "" && !shouldKeepEmpty ? [] : withText(canvasTextTypedFormatting(nodes, range, shouldContinueLink), text);
|
|
5476
5575
|
const canvasTextReplacementRange = (before, text, range) => {
|
|
5477
5576
|
const replacementEnd = text.length - before.length + (range?.end ?? 0);
|
|
5478
5577
|
if (range !== void 0 && isValidTextRange(before, range) && isValidTextRange(text, {
|
|
@@ -5577,7 +5676,7 @@ const paragraphProps = (node, range, command) => {
|
|
|
5577
5676
|
Reflect.deleteProperty(props, "links");
|
|
5578
5677
|
return props;
|
|
5579
5678
|
};
|
|
5580
|
-
const replacementRuns = (runs, range, command) => {
|
|
5679
|
+
const replacementRuns = (runs, range, command, shouldContinueLink) => {
|
|
5581
5680
|
if (command.richText !== void 0) {
|
|
5582
5681
|
const rich = canvasRichTextOf({ props: {
|
|
5583
5682
|
text: command.text,
|
|
@@ -5586,7 +5685,10 @@ const replacementRuns = (runs, range, command) => {
|
|
|
5586
5685
|
if (rich.length > 0) return rich;
|
|
5587
5686
|
}
|
|
5588
5687
|
const shouldKeepEmpty = range.start === 0 && range.end === canvasRichTextValueOf(runs).length;
|
|
5589
|
-
let next = insertedRuns(runs, range, command.text,
|
|
5688
|
+
let next = insertedRuns(runs, range, command.text, {
|
|
5689
|
+
shouldKeepEmpty,
|
|
5690
|
+
shouldContinueLink
|
|
5691
|
+
});
|
|
5590
5692
|
if (command.text === "") return next;
|
|
5591
5693
|
if (Object.keys(command.styles ?? {}).length > 0 || Object.keys(textRunFormattingOf(command)).length > 0) next = formattedRuns(next, {
|
|
5592
5694
|
type: "format",
|
|
@@ -5604,14 +5706,14 @@ const replacementRuns = (runs, range, command) => {
|
|
|
5604
5706
|
return next;
|
|
5605
5707
|
};
|
|
5606
5708
|
/** Commands write the existing text/run pair atomically and retain unrelated source metadata. */
|
|
5607
|
-
const canvasTextPropsWithCommand = (node, range, command) => {
|
|
5709
|
+
const canvasTextPropsWithCommand = (node, range, command, shouldContinueLink) => {
|
|
5608
5710
|
const text = textOf(node) ?? "";
|
|
5609
5711
|
if (!(command.type === "paint" ? isValidTextCharacterRange(text, range) : isValidTextRange(text, range))) return node.props ?? {};
|
|
5610
5712
|
if (command.type === "paragraph" || command.type === "list-indent") return paragraphProps(node, range, command);
|
|
5611
5713
|
if (command.type !== "replace" && range.start === range.end && (text !== "" || command.type !== "text-style" && command.type !== "format")) return node.props ?? {};
|
|
5612
5714
|
if (command.type === "link" && command.href !== null && !isCanvasRichTextHref(command.href)) return node.props ?? {};
|
|
5613
5715
|
const runs = canvasTextRunsOf(node);
|
|
5614
|
-
const middle = command.type === "replace" ? replacementRuns(runs, range, command) : formattedRuns(text === "" ? runs : sliceRuns(runs, range.start, range.end), command);
|
|
5716
|
+
const middle = command.type === "replace" ? replacementRuns(runs, range, command, shouldContinueLink) : formattedRuns(text === "" ? runs : sliceRuns(runs, range.start, range.end), command);
|
|
5615
5717
|
const next = canvasTextParagraphRunsAfterEdit(runs, joinRuns([
|
|
5616
5718
|
...sliceRuns(runs, 0, range.start),
|
|
5617
5719
|
...middle,
|
|
@@ -5633,14 +5735,14 @@ const canvasTextPropsWithCommand = (node, range, command) => {
|
|
|
5633
5735
|
const canvasTextPropsWithContent = (node, text, styles, formatting) => {
|
|
5634
5736
|
const before = textOf(node) ?? "";
|
|
5635
5737
|
if (before === text) return node.props ?? {};
|
|
5636
|
-
const { range, ...marks } = formatting ?? {};
|
|
5738
|
+
const { range, shouldContinueLink, ...marks } = formatting ?? {};
|
|
5637
5739
|
const replacement = canvasTextReplacementRange(before, text, range);
|
|
5638
5740
|
return canvasTextPropsWithCommand(node, replacement, {
|
|
5639
5741
|
type: "replace",
|
|
5640
5742
|
styles,
|
|
5641
5743
|
...marks,
|
|
5642
5744
|
text: text.slice(replacement.start, text.length - before.length + replacement.end)
|
|
5643
|
-
});
|
|
5745
|
+
}, shouldContinueLink);
|
|
5644
5746
|
};
|
|
5645
5747
|
|
|
5646
5748
|
//#endregion
|
|
@@ -6001,6 +6103,20 @@ const duplicateCanvasVersionOutputSchema = z.object({
|
|
|
6001
6103
|
version: z.literal(1)
|
|
6002
6104
|
});
|
|
6003
6105
|
|
|
6106
|
+
//#endregion
|
|
6107
|
+
//#region ../../packages/contract/src/canvas/canvas-walkthrough-copy.schema.ts
|
|
6108
|
+
/** Walkthroughs on `sourceCanvasId` that a paste into `canvasId` carries. */
|
|
6109
|
+
const copyCanvasWalkthroughsInputSchema = z.object({
|
|
6110
|
+
canvasId: z.uuid(),
|
|
6111
|
+
sourceCanvasId: z.uuid(),
|
|
6112
|
+
recordingIds: z.array(z.uuid()).min(1)
|
|
6113
|
+
});
|
|
6114
|
+
/** One pair for each walkthrough the API copied; one it could not copy has no pair. */
|
|
6115
|
+
const copyCanvasWalkthroughsOutputSchema = z.object({ copies: z.array(z.object({
|
|
6116
|
+
sourceRecordingId: z.uuid(),
|
|
6117
|
+
recordingId: z.uuid()
|
|
6118
|
+
})) });
|
|
6119
|
+
|
|
6004
6120
|
//#endregion
|
|
6005
6121
|
//#region ../../packages/contract/src/canvas/font-catalog.schema.ts
|
|
6006
6122
|
const MAX_WEIGHT = 1e3;
|
|
@@ -6189,6 +6305,7 @@ const setReviewStateOutputSchema = z.object({ reviewState: setReviewStateInputSc
|
|
|
6189
6305
|
/** The longest journey, step, variant or label a capture may carry. */
|
|
6190
6306
|
const CAPTURE_KEY_LENGTH = 160;
|
|
6191
6307
|
const CAPTURE_METADATA_LENGTH = 200;
|
|
6308
|
+
/** The longest capture issue message a capture or a receipt carries. */
|
|
6192
6309
|
const CAPTURE_ISSUE_LENGTH = 500;
|
|
6193
6310
|
const CAPTURE_FAILURE_LENGTH = 1e3;
|
|
6194
6311
|
const CAPTURE_UPLOAD_BATCH_SIZE = 400;
|
|
@@ -6271,7 +6388,7 @@ const captureArtifactSchema = z.strictObject({
|
|
|
6271
6388
|
}),
|
|
6272
6389
|
issues: z.array(z.strictObject({
|
|
6273
6390
|
code: key,
|
|
6274
|
-
message: z.string().min(1).max(
|
|
6391
|
+
message: z.string().min(1).max(500)
|
|
6275
6392
|
}))
|
|
6276
6393
|
}).superRefine((artifact, ctx) => {
|
|
6277
6394
|
if (artifact.preview.width / artifact.preview.pixelRatio !== artifact.viewport.width || artifact.preview.height / artifact.preview.pixelRatio !== artifact.viewport.height) ctx.addIssue({
|
|
@@ -6314,10 +6431,8 @@ const captureRunDescriptorSchema = z.strictObject({
|
|
|
6314
6431
|
formatVersion: z.literal(1),
|
|
6315
6432
|
review: captureReviewMetadataSchema.optional()
|
|
6316
6433
|
});
|
|
6317
|
-
const
|
|
6434
|
+
const attemptFields = {
|
|
6318
6435
|
participant: key,
|
|
6319
|
-
testId: key,
|
|
6320
|
-
project: key,
|
|
6321
6436
|
retry: z.number().int().nonnegative(),
|
|
6322
6437
|
status: z.enum([
|
|
6323
6438
|
"passed",
|
|
@@ -6332,6 +6447,27 @@ const captureAttemptSchema = z.strictObject({
|
|
|
6332
6447
|
line: z.number().int()
|
|
6333
6448
|
}).optional(),
|
|
6334
6449
|
captures: z.array(captureArtifactSchema)
|
|
6450
|
+
};
|
|
6451
|
+
/**
|
|
6452
|
+
* A Playwright test's attempt, or a script's, which has no test. A Playwright attempt leaves out
|
|
6453
|
+
* `runner`, as every SDK before scripts had their own wrote it, so its manifest digest is unchanged.
|
|
6454
|
+
*/
|
|
6455
|
+
const playwrightCaptureAttemptSchema = z.strictObject({
|
|
6456
|
+
runner: z.literal("playwright").optional(),
|
|
6457
|
+
testId: key,
|
|
6458
|
+
project: key,
|
|
6459
|
+
...attemptFields
|
|
6460
|
+
});
|
|
6461
|
+
const scriptCaptureAttemptSchema = z.strictObject({
|
|
6462
|
+
runner: z.literal("script"),
|
|
6463
|
+
...attemptFields
|
|
6464
|
+
});
|
|
6465
|
+
const captureAttemptSchema = z.union([playwrightCaptureAttemptSchema, scriptCaptureAttemptSchema]);
|
|
6466
|
+
/** A capture the SDK or the selection left out; `message` is one of `CAPTURE_LEFT_OUT_REASONS`. */
|
|
6467
|
+
const captureLeftOutSchema = z.strictObject({
|
|
6468
|
+
key: captureKeySchema.optional(),
|
|
6469
|
+
testId: key.optional(),
|
|
6470
|
+
message: z.string().min(1).max(500)
|
|
6335
6471
|
});
|
|
6336
6472
|
const captureManifestSchema = z.strictObject({
|
|
6337
6473
|
format: z.literal("enhance-capture-run"),
|
|
@@ -6346,7 +6482,8 @@ const captureManifestSchema = z.strictObject({
|
|
|
6346
6482
|
])
|
|
6347
6483
|
})).min(1),
|
|
6348
6484
|
attempts: z.array(captureAttemptSchema),
|
|
6349
|
-
ordering: z.enum(["partial", "complete"])
|
|
6485
|
+
ordering: z.enum(["partial", "complete"]),
|
|
6486
|
+
leftOut: z.array(captureLeftOutSchema).optional()
|
|
6350
6487
|
});
|
|
6351
6488
|
const captureReceiptSchema = z.strictObject({
|
|
6352
6489
|
runId: z.uuid(),
|
|
@@ -6361,7 +6498,7 @@ const captureReceiptSchema = z.strictObject({
|
|
|
6361
6498
|
})),
|
|
6362
6499
|
issues: z.array(z.strictObject({
|
|
6363
6500
|
code: key,
|
|
6364
|
-
message: z.string().max(
|
|
6501
|
+
message: z.string().max(500)
|
|
6365
6502
|
}))
|
|
6366
6503
|
});
|
|
6367
6504
|
const beginCaptureRunInputSchema = z.strictObject({
|
|
@@ -6418,6 +6555,38 @@ const reserveCaptureBlobsOutputSchema = z.strictObject({ uploads: z.array(z.stri
|
|
|
6418
6555
|
}).nullable()
|
|
6419
6556
|
})).max(CAPTURE_UPLOAD_BATCH_SIZE) });
|
|
6420
6557
|
|
|
6558
|
+
//#endregion
|
|
6559
|
+
//#region ../../packages/contract/src/recording/frozen-screen.schema.ts
|
|
6560
|
+
const MAX_ISSUE_CODE_LENGTH = 160;
|
|
6561
|
+
const MAX_ISSUE_MESSAGE_LENGTH = 500;
|
|
6562
|
+
const MAX_ISSUE_KINDS = 32;
|
|
6563
|
+
const frozenScreenIssuesSchema = z$1.array(z$1.object({
|
|
6564
|
+
code: z$1.string().check(z$1.minLength(1), z$1.maxLength(MAX_ISSUE_CODE_LENGTH)),
|
|
6565
|
+
message: z$1.string().check(z$1.minLength(1), z$1.maxLength(MAX_ISSUE_MESSAGE_LENGTH))
|
|
6566
|
+
})).check(z$1.maxLength(MAX_ISSUE_KINDS));
|
|
6567
|
+
/** Missing issues are historical or unreported; an empty array explicitly reports no omissions. */
|
|
6568
|
+
const frozenScreenCaptureSchema = z$1.object({
|
|
6569
|
+
issues: z$1.optional(frozenScreenIssuesSchema),
|
|
6570
|
+
prototype: z$1.optional(z$1.object({
|
|
6571
|
+
prototypeId: z$1.uuid(),
|
|
6572
|
+
deploymentId: z$1.uuid()
|
|
6573
|
+
}))
|
|
6574
|
+
});
|
|
6575
|
+
|
|
6576
|
+
//#endregion
|
|
6577
|
+
//#region ../../packages/contract/src/capture/capture-issue.lib.ts
|
|
6578
|
+
/** Why a capture was left out, in words about the capture; a check's own text goes to a log. */
|
|
6579
|
+
const CAPTURE_LEFT_OUT_REASONS = {
|
|
6580
|
+
unreadable: "its saved capture could not be read",
|
|
6581
|
+
notACapture: "it is not an Enhance capture",
|
|
6582
|
+
pictureMismatch: "its picture does not match the size of its page",
|
|
6583
|
+
nothingArrived: "none of its files arrived",
|
|
6584
|
+
notSaved: "it could not be saved on this machine",
|
|
6585
|
+
noPicture: "it could not be compiled and has no picture",
|
|
6586
|
+
anotherSource: "it was captured for another source",
|
|
6587
|
+
outsideShards: "its test ran outside this run's shards"
|
|
6588
|
+
};
|
|
6589
|
+
|
|
6421
6590
|
//#endregion
|
|
6422
6591
|
//#region ../../packages/contract/src/capture/capture-name.lib.ts
|
|
6423
6592
|
const CODE_LENGTH = 8;
|
|
@@ -7329,7 +7498,7 @@ const ROOT_FIXTURE_NODE_ID = "root";
|
|
|
7329
7498
|
const SORT_KEY_DIGITS = 4;
|
|
7330
7499
|
const sortKeyAt = (seat) => `a${String(seat).padStart(SORT_KEY_DIGITS, "0")}`;
|
|
7331
7500
|
const emptyFixtureDocument = () => ({
|
|
7332
|
-
version:
|
|
7501
|
+
version: 14,
|
|
7333
7502
|
nodes: { [ROOT_FIXTURE_NODE_ID]: {
|
|
7334
7503
|
id: ROOT_FIXTURE_NODE_ID,
|
|
7335
7504
|
label: "Canvas",
|
|
@@ -7952,24 +8121,6 @@ const requestPrototypeRuntimeTicketOutputSchema = z.object({
|
|
|
7952
8121
|
expiresAt: z.iso.datetime()
|
|
7953
8122
|
});
|
|
7954
8123
|
|
|
7955
|
-
//#endregion
|
|
7956
|
-
//#region ../../packages/contract/src/recording/frozen-screen.schema.ts
|
|
7957
|
-
const MAX_ISSUE_CODE_LENGTH = 160;
|
|
7958
|
-
const MAX_ISSUE_MESSAGE_LENGTH = 500;
|
|
7959
|
-
const MAX_ISSUE_KINDS = 32;
|
|
7960
|
-
const frozenScreenIssuesSchema = z$1.array(z$1.object({
|
|
7961
|
-
code: z$1.string().check(z$1.minLength(1), z$1.maxLength(MAX_ISSUE_CODE_LENGTH)),
|
|
7962
|
-
message: z$1.string().check(z$1.minLength(1), z$1.maxLength(MAX_ISSUE_MESSAGE_LENGTH))
|
|
7963
|
-
})).check(z$1.maxLength(MAX_ISSUE_KINDS));
|
|
7964
|
-
/** Missing issues are historical or unreported; an empty array explicitly reports no omissions. */
|
|
7965
|
-
const frozenScreenCaptureSchema = z$1.object({
|
|
7966
|
-
issues: z$1.optional(frozenScreenIssuesSchema),
|
|
7967
|
-
prototype: z$1.optional(z$1.object({
|
|
7968
|
-
prototypeId: z$1.uuid(),
|
|
7969
|
-
deploymentId: z$1.uuid()
|
|
7970
|
-
}))
|
|
7971
|
-
});
|
|
7972
|
-
|
|
7973
8124
|
//#endregion
|
|
7974
8125
|
//#region ../../packages/contract/src/prototype/prototype-bridge.schema.ts
|
|
7975
8126
|
const PROTOTYPE_BRIDGE_PROTOCOL = 1;
|
|
@@ -8008,7 +8159,9 @@ const prototypeBridgeCaptureRequestSchema = z$1.object({
|
|
|
8008
8159
|
type: z$1.literal("enhance.prototype.capture"),
|
|
8009
8160
|
requestId: z$1.uuid(),
|
|
8010
8161
|
connectionId: z$1.optional(z$1.uuid()),
|
|
8011
|
-
documentId: z$1.optional(z$1.uuid())
|
|
8162
|
+
documentId: z$1.optional(z$1.uuid()),
|
|
8163
|
+
/** Absent for Capture; `menu-svg` asks for a menu picture, which adds no layer. */
|
|
8164
|
+
format: z$1.optional(z$1.literal("menu-svg"))
|
|
8012
8165
|
});
|
|
8013
8166
|
const prototypeBridgeConnectRequestSchema = z$1.object({
|
|
8014
8167
|
protocol: z$1.literal(1),
|
|
@@ -8083,7 +8236,19 @@ const capturedPrototypeScreenSchema = z$1.object({
|
|
|
8083
8236
|
width: z$1.number().check(z$1.positive()),
|
|
8084
8237
|
height: z$1.number().check(z$1.positive())
|
|
8085
8238
|
}),
|
|
8086
|
-
title: z$1.string()
|
|
8239
|
+
title: z$1.string(),
|
|
8240
|
+
/**
|
|
8241
|
+
* The files the screen names, fetched inside the prototype's frame, which can read them. Their
|
|
8242
|
+
* bytes are transferred with the message, and the host keeps them as files of the screen.
|
|
8243
|
+
*/
|
|
8244
|
+
files: z$1.optional(z$1.object({
|
|
8245
|
+
named: z$1.array(z$1.string()),
|
|
8246
|
+
fetched: z$1.array(z$1.object({
|
|
8247
|
+
url: z$1.string(),
|
|
8248
|
+
contentType: z$1.string(),
|
|
8249
|
+
bytes: z$1.custom((value) => Object.prototype.toString.call(value) === "[object ArrayBuffer]")
|
|
8250
|
+
}))
|
|
8251
|
+
}))
|
|
8087
8252
|
});
|
|
8088
8253
|
const prototypeBridgeCaptureResponseBaseSchema = z$1.object({
|
|
8089
8254
|
protocol: z$1.literal(1),
|
|
@@ -8092,15 +8257,22 @@ const prototypeBridgeCaptureResponseBaseSchema = z$1.object({
|
|
|
8092
8257
|
connectionId: z$1.optional(z$1.uuid()),
|
|
8093
8258
|
documentId: z$1.optional(z$1.uuid())
|
|
8094
8259
|
});
|
|
8095
|
-
const prototypeBridgeCaptureResponseSchema = z$1.discriminatedUnion("outcome", [
|
|
8096
|
-
|
|
8097
|
-
|
|
8098
|
-
|
|
8099
|
-
|
|
8100
|
-
|
|
8101
|
-
|
|
8102
|
-
|
|
8103
|
-
|
|
8260
|
+
const prototypeBridgeCaptureResponseSchema = z$1.discriminatedUnion("outcome", [
|
|
8261
|
+
z$1.extend(prototypeBridgeCaptureResponseBaseSchema, {
|
|
8262
|
+
outcome: z$1.literal("captured"),
|
|
8263
|
+
screen: capturedPrototypeScreenSchema,
|
|
8264
|
+
issues: z$1.optional(frozenScreenIssuesSchema)
|
|
8265
|
+
}),
|
|
8266
|
+
z$1.extend(prototypeBridgeCaptureResponseBaseSchema, {
|
|
8267
|
+
outcome: z$1.literal("menu-svg"),
|
|
8268
|
+
markup: z$1.string().check(z$1.startsWith("data:image/svg+xml"))
|
|
8269
|
+
}),
|
|
8270
|
+
z$1.extend(prototypeBridgeCaptureResponseBaseSchema, {
|
|
8271
|
+
outcome: z$1.literal("failed"),
|
|
8272
|
+
error: z$1.string().check(z$1.minLength(1)),
|
|
8273
|
+
code: z$1.optional(z$1.enum(["capture-failed", "capture-busy"]))
|
|
8274
|
+
})
|
|
8275
|
+
]);
|
|
8104
8276
|
|
|
8105
8277
|
//#endregion
|
|
8106
8278
|
//#region ../../packages/contract/src/prototype/prototype-input.schema.ts
|
|
@@ -8440,7 +8612,9 @@ const recordingSummarySchema = z.object({
|
|
|
8440
8612
|
viewport: viewportSchema,
|
|
8441
8613
|
interrupted: z.boolean(),
|
|
8442
8614
|
chunkCount: z.number().int().min(0),
|
|
8443
|
-
startedAt: z.iso.datetime()
|
|
8615
|
+
startedAt: z.iso.datetime(),
|
|
8616
|
+
/** A walkthrough copy: its player arrives with the paste or duplicate, never placed by itself. */
|
|
8617
|
+
isCopy: z.boolean()
|
|
8444
8618
|
});
|
|
8445
8619
|
/**
|
|
8446
8620
|
* @justified intent
|
|
@@ -8454,26 +8628,40 @@ const recordingSummarySchema = z.object({
|
|
|
8454
8628
|
* Batched: a page asks for tens of files, and a per-file round trip would cost more than the
|
|
8455
8629
|
* bytes do.
|
|
8456
8630
|
*/
|
|
8457
|
-
const
|
|
8631
|
+
const reservedAssetsSchema = z.array(z.object({
|
|
8632
|
+
url: z.url(),
|
|
8633
|
+
contentType: z.string().min(1).max(200),
|
|
8634
|
+
byteSize: z.number().int().min(1),
|
|
8635
|
+
/** The hex SHA-256 of the file's bytes, which a checksum-signed upload is held to. */
|
|
8636
|
+
sha256: z.string().regex(/^[a-f0-9]{64}$/u).optional()
|
|
8637
|
+
})).max(MAX_ASSETS_PER_CALL);
|
|
8638
|
+
/**
|
|
8639
|
+
* Files go into a walkthrough's bundle, or, for a screen with no walkthrough such as a prototype
|
|
8640
|
+
* capture, into that screen's own bundle, which the screen's owner reserves them into by its id.
|
|
8641
|
+
*/
|
|
8642
|
+
const reserveAssetsInputSchema = z.union([z.object({
|
|
8458
8643
|
recordingId: z.uuid(),
|
|
8459
|
-
assets:
|
|
8460
|
-
|
|
8461
|
-
|
|
8462
|
-
|
|
8463
|
-
|
|
8464
|
-
});
|
|
8644
|
+
assets: reservedAssetsSchema
|
|
8645
|
+
}), z.object({
|
|
8646
|
+
screenId: z.uuid(),
|
|
8647
|
+
assets: reservedAssetsSchema
|
|
8648
|
+
})]);
|
|
8465
8649
|
const reserveAssetsOutputSchema = z.object({ reserved: z.array(z.object({
|
|
8466
8650
|
url: z.string(),
|
|
8467
8651
|
upload: signedUploadSchema
|
|
8468
8652
|
})) });
|
|
8469
|
-
const
|
|
8653
|
+
const arrivedAssetsSchema = z.array(z.object({
|
|
8654
|
+
url: z.url(),
|
|
8655
|
+
etag: z.string().min(1).max(200),
|
|
8656
|
+
byteSize: z.number().int().min(1)
|
|
8657
|
+
})).max(MAX_ASSETS_PER_CALL);
|
|
8658
|
+
const confirmAssetsInputSchema = z.union([z.object({
|
|
8470
8659
|
recordingId: z.uuid(),
|
|
8471
|
-
arrived:
|
|
8472
|
-
|
|
8473
|
-
|
|
8474
|
-
|
|
8475
|
-
|
|
8476
|
-
});
|
|
8660
|
+
arrived: arrivedAssetsSchema
|
|
8661
|
+
}), z.object({
|
|
8662
|
+
screenId: z.uuid(),
|
|
8663
|
+
arrived: arrivedAssetsSchema
|
|
8664
|
+
})]);
|
|
8477
8665
|
const confirmAssetsOutputSchema = z.object({
|
|
8478
8666
|
/** Reserved and never delivered. Reported rather than left for the replay to discover. */
|
|
8479
8667
|
missingAssetCount: z.number().int().min(0) });
|
|
@@ -8597,7 +8785,9 @@ const createScreenInputSchema = z.object({
|
|
|
8597
8785
|
width: z.number().int().positive(),
|
|
8598
8786
|
height: z.number().int().positive()
|
|
8599
8787
|
}),
|
|
8600
|
-
bytes: z.number().int().min(1).max(Number.MAX_SAFE_INTEGER)
|
|
8788
|
+
bytes: z.number().int().min(1).max(Number.MAX_SAFE_INTEGER),
|
|
8789
|
+
/** The hex SHA-256 of the screen file; when given, the upload address takes only those bytes. */
|
|
8790
|
+
sha256: z.string().regex(/^[a-f0-9]{64}$/u).optional()
|
|
8601
8791
|
});
|
|
8602
8792
|
const createScreenOutputSchema = z.object({
|
|
8603
8793
|
screenId: z.uuid(),
|
|
@@ -8693,7 +8883,7 @@ const clientConversionOutputSchema = z.object({ accepted: z.literal(true) });
|
|
|
8693
8883
|
//#region ../../packages/contract/src/shared/client-performance.schema.ts
|
|
8694
8884
|
const MAX_CAPABILITY_VERSION$1 = 16;
|
|
8695
8885
|
const MAX_DURATION_MS$1 = 18e5;
|
|
8696
|
-
const MAX_COUNT = 1e6;
|
|
8886
|
+
const MAX_COUNT$1 = 1e6;
|
|
8697
8887
|
const MAX_BYTES = 1073741824;
|
|
8698
8888
|
const MAX_PROTOTYPE_OPEN_ATTEMPTS = 16;
|
|
8699
8889
|
/** How the read of a canvas's unsaved browser copy ended when the canvas opened. */
|
|
@@ -8703,7 +8893,7 @@ const browserCopyCheckSchema = z.enum([
|
|
|
8703
8893
|
"none"
|
|
8704
8894
|
]);
|
|
8705
8895
|
const durationSchema$1 = z.number().int().min(0).max(MAX_DURATION_MS$1);
|
|
8706
|
-
const countSchema = z.number().int().min(0).max(MAX_COUNT);
|
|
8896
|
+
const countSchema = z.number().int().min(0).max(MAX_COUNT$1);
|
|
8707
8897
|
const base$1 = {
|
|
8708
8898
|
canvasId: z.uuid(),
|
|
8709
8899
|
clientViewId: z.uuid(),
|
|
@@ -8818,7 +9008,12 @@ const clientPerformanceInputSchema = z.discriminatedUnion("name", [
|
|
|
8818
9008
|
"denied",
|
|
8819
9009
|
"expired-or-used",
|
|
8820
9010
|
"temporary-error",
|
|
8821
|
-
"deadline"
|
|
9011
|
+
"deadline",
|
|
9012
|
+
"ticket-held",
|
|
9013
|
+
"gate-silent",
|
|
9014
|
+
"exchange-held",
|
|
9015
|
+
"document-held",
|
|
9016
|
+
"document-unconfirmed"
|
|
8822
9017
|
]),
|
|
8823
9018
|
attempts: z.number().int().min(1).max(MAX_PROTOTYPE_OPEN_ATTEMPTS),
|
|
8824
9019
|
durationMs: durationSchema$1,
|
|
@@ -8863,7 +9058,10 @@ const clientPerformanceOutputSchema = z.object({ accepted: z.literal(true) });
|
|
|
8863
9058
|
const MAX_ASSET_LENGTH = 128;
|
|
8864
9059
|
const MAX_FRAME_COORDINATE = 1e7;
|
|
8865
9060
|
const MAX_FRAMES = 8;
|
|
8866
|
-
const
|
|
9061
|
+
const MAX_COUNT = 1e3;
|
|
9062
|
+
const HTTP_STATUS_LOWEST = 100;
|
|
9063
|
+
const HTTP_STATUS_HIGHEST = 599;
|
|
9064
|
+
const count$1 = z.number().int().min(0).max(MAX_COUNT);
|
|
8867
9065
|
const clientRenderFailureDetailsSchema = z.strictObject({
|
|
8868
9066
|
version: z.literal(1),
|
|
8869
9067
|
severity: z.enum([
|
|
@@ -8894,6 +9092,10 @@ const clientRenderFailureDetailsSchema = z.strictObject({
|
|
|
8894
9092
|
"application-empty",
|
|
8895
9093
|
"startup-stalled",
|
|
8896
9094
|
"export-incomplete",
|
|
9095
|
+
"export-image-refused",
|
|
9096
|
+
"export-image-unreachable",
|
|
9097
|
+
"export-image-not-an-image",
|
|
9098
|
+
"export-font-unread",
|
|
8897
9099
|
"clipboard-unavailable",
|
|
8898
9100
|
"clipboard-image-pending",
|
|
8899
9101
|
"clipboard-image-unavailable",
|
|
@@ -8930,8 +9132,16 @@ const clientRenderFailureDetailsSchema = z.strictObject({
|
|
|
8930
9132
|
"no-asset-list",
|
|
8931
9133
|
"kept-local"
|
|
8932
9134
|
]).optional(),
|
|
8933
|
-
subsystem: z.enum([
|
|
9135
|
+
subsystem: z.enum([
|
|
9136
|
+
"menu",
|
|
9137
|
+
"menu-picture",
|
|
9138
|
+
"unknown"
|
|
9139
|
+
]).optional(),
|
|
8934
9140
|
repeats: count$1.optional(),
|
|
9141
|
+
/** How many images or fonts an export could not read, for the `export-…-unread` codes. */
|
|
9142
|
+
resourceCount: count$1.optional(),
|
|
9143
|
+
/** The status a refused export read answered with. */
|
|
9144
|
+
httpStatus: z.number().int().min(HTTP_STATUS_LOWEST).max(HTTP_STATUS_HIGHEST).optional(),
|
|
8935
9145
|
deliveryGap: z.strictObject({
|
|
8936
9146
|
refused: count$1,
|
|
8937
9147
|
expired: count$1,
|
|
@@ -9071,8 +9281,15 @@ const CANVAS_SAVE_NOTICE_CAUSES = [
|
|
|
9071
9281
|
"offline",
|
|
9072
9282
|
"retrying",
|
|
9073
9283
|
"upload",
|
|
9284
|
+
"missing-image",
|
|
9285
|
+
"missing-capture",
|
|
9074
9286
|
"review",
|
|
9075
9287
|
"view-only",
|
|
9288
|
+
"not-backed-up",
|
|
9289
|
+
"gone",
|
|
9290
|
+
"refused",
|
|
9291
|
+
"copy-refused",
|
|
9292
|
+
"copy-preview",
|
|
9076
9293
|
"unknown"
|
|
9077
9294
|
];
|
|
9078
9295
|
const CANVAS_SAVE_SEVERITIES = [
|
|
@@ -9088,7 +9305,15 @@ const CANVAS_SAVE_DEVICE_PROTECTIONS = [
|
|
|
9088
9305
|
const CANVAS_SAVE_ACTIONS = [
|
|
9089
9306
|
"try-again",
|
|
9090
9307
|
"sync",
|
|
9091
|
-
"overwrite"
|
|
9308
|
+
"overwrite",
|
|
9309
|
+
"review",
|
|
9310
|
+
"save-copy",
|
|
9311
|
+
"save-separate-copy",
|
|
9312
|
+
"send-feedback",
|
|
9313
|
+
"retry-upload",
|
|
9314
|
+
"choose-file",
|
|
9315
|
+
"remove-screen",
|
|
9316
|
+
"go-to-canvases"
|
|
9092
9317
|
];
|
|
9093
9318
|
const CANVAS_SAVE_OUTCOMES = [
|
|
9094
9319
|
"saved",
|
|
@@ -9425,6 +9650,11 @@ const RETRY_LATER = "later";
|
|
|
9425
9650
|
const MUTATION_ID_REUSED = "mutation-id-reused";
|
|
9426
9651
|
/** The message for input the api's schema refused; `fields` names each field and why. */
|
|
9427
9652
|
const REQUEST_REJECTED = "that request will not do";
|
|
9653
|
+
/**
|
|
9654
|
+
* `fields.reason` on the NOT_FOUND of a deleted canvas, told only to a person who could read it
|
|
9655
|
+
* before the delete. Lost access, and a canvas the person never had, answer plain NOT_FOUND.
|
|
9656
|
+
*/
|
|
9657
|
+
const CANVAS_DELETED = "canvas-deleted";
|
|
9428
9658
|
/** `fields.reason` on a 413, whether the server's envelope or a proxy's bare status says so. */
|
|
9429
9659
|
const REQUEST_TOO_LARGE = "request-too-large";
|
|
9430
9660
|
const HTTP_UNAUTHORIZED = 401;
|
|
@@ -9639,20 +9869,40 @@ const fitCaptureNames = (raw) => {
|
|
|
9639
9869
|
}
|
|
9640
9870
|
return capture;
|
|
9641
9871
|
};
|
|
9872
|
+
/** The format check's one rule about the picture: its size must be the page's. */
|
|
9873
|
+
const isPictureMismatch = (issues) => issues.length > 0 && issues.every((issue) => issue.path.length === 1 && issue.path[0] === "preview");
|
|
9874
|
+
/** A capture that fails its format check, named in words about the capture, never the check's text. */
|
|
9875
|
+
const leftOutCapture = (capture, testId, issues) => {
|
|
9876
|
+
const key = typeof capture === "object" && capture !== null ? captureKeySchema.safeParse(Reflect.get(capture, "key")) : null;
|
|
9877
|
+
return {
|
|
9878
|
+
...key?.success === true && { key: key.data },
|
|
9879
|
+
...testId !== void 0 && { testId },
|
|
9880
|
+
message: isPictureMismatch(issues) ? CAPTURE_LEFT_OUT_REASONS.pictureMismatch : CAPTURE_LEFT_OUT_REASONS.notACapture
|
|
9881
|
+
};
|
|
9882
|
+
};
|
|
9883
|
+
const lenientCaptures = { captures: z.array(z.unknown()) };
|
|
9642
9884
|
/**
|
|
9643
9885
|
* A manifest checked in outline, then capture by capture: one capture that fails its own checks
|
|
9644
|
-
* is left out
|
|
9886
|
+
* is left out and named in the manifest's `leftOut`, and the rest of the run still publishes.
|
|
9645
9887
|
*/
|
|
9646
|
-
const lenientCaptureManifestSchema = captureManifestSchema.extend({ attempts: z.array(
|
|
9647
|
-
...manifest
|
|
9648
|
-
attempts
|
|
9888
|
+
const lenientCaptureManifestSchema = captureManifestSchema.extend({ attempts: z.array(z.union([playwrightCaptureAttemptSchema.extend(lenientCaptures), scriptCaptureAttemptSchema.extend(lenientCaptures)])) }).transform((manifest) => {
|
|
9889
|
+
const leftOut = [...manifest.leftOut ?? []];
|
|
9890
|
+
const attempts = manifest.attempts.map((attempt) => ({
|
|
9649
9891
|
...attempt,
|
|
9650
|
-
captures: attempt.captures.flatMap((
|
|
9651
|
-
const
|
|
9652
|
-
|
|
9892
|
+
captures: attempt.captures.flatMap((raw) => {
|
|
9893
|
+
const capture = fitCaptureNames(raw);
|
|
9894
|
+
const parsed = captureArtifactSchema.safeParse(capture);
|
|
9895
|
+
if (parsed.success) return [parsed.data];
|
|
9896
|
+
leftOut.push(leftOutCapture(capture, "testId" in attempt ? attempt.testId : void 0, parsed.error.issues));
|
|
9897
|
+
return [];
|
|
9653
9898
|
})
|
|
9654
|
-
}))
|
|
9655
|
-
|
|
9899
|
+
}));
|
|
9900
|
+
return {
|
|
9901
|
+
...manifest,
|
|
9902
|
+
attempts,
|
|
9903
|
+
...leftOut.length > 0 && { leftOut }
|
|
9904
|
+
};
|
|
9905
|
+
});
|
|
9656
9906
|
const sealCaptureRunInputSchema = z.strictObject({ manifest: lenientCaptureManifestSchema });
|
|
9657
9907
|
|
|
9658
9908
|
//#endregion
|
|
@@ -11578,6 +11828,7 @@ const PROCEDURE_DESCRIPTIONS = {
|
|
|
11578
11828
|
"canvas.delete": "Move a canvas to its recoverable bin; retention is currently indefinite.",
|
|
11579
11829
|
"canvas.move": "Move a canvas between the personal shelf and a team shelf.",
|
|
11580
11830
|
"canvas.duplicate": "Copy a canvas and its document into the selected shelf.",
|
|
11831
|
+
"canvas.copyWalkthroughs": "Copy walkthroughs from a readable canvas into this one before saving players that name the copies.",
|
|
11581
11832
|
"canvas.deletePermanently": "Permanently delete a canvas already in the recoverable bin.",
|
|
11582
11833
|
"canvas.restore": "Restore a canvas from the recoverable bin.",
|
|
11583
11834
|
"canvas.list": "Find canvas ids by collection, title, access, review state, or deletion state.",
|
|
@@ -11637,8 +11888,8 @@ const PROCEDURE_DESCRIPTIONS = {
|
|
|
11637
11888
|
"recording.delete": "Soft-delete a completed recording while preserving screens and clearing their provenance.",
|
|
11638
11889
|
"recording.refreshUpload": "Replace an expired signed upload for a recording chunk.",
|
|
11639
11890
|
"recording.confirmUpload": "Confirm that a repaired recording chunk reached storage.",
|
|
11640
|
-
"recordingAsset.reserve": "Reserve signed uploads for external assets used by a recording.",
|
|
11641
|
-
"recordingAsset.confirm": "Confirm which reserved recording assets reached storage.",
|
|
11891
|
+
"recordingAsset.reserve": "Reserve signed uploads for external assets used by a recording or by a screen with no walkthrough.",
|
|
11892
|
+
"recordingAsset.confirm": "Confirm which reserved recording or screen assets reached storage.",
|
|
11642
11893
|
"screen.create": "Reserve a signed upload for a captured page and return its screen id.",
|
|
11643
11894
|
"screen.complete": "Confirm a captured page after its bytes have been uploaded.",
|
|
11644
11895
|
"screen.delete": "Delete an unattached captured page owned by this person."
|
|
@@ -11646,6 +11897,10 @@ const PROCEDURE_DESCRIPTIONS = {
|
|
|
11646
11897
|
|
|
11647
11898
|
//#endregion
|
|
11648
11899
|
//#region src/infrastructure/procedure-options.consts.ts
|
|
11900
|
+
const PROTOTYPE_UPDATE_GUIDANCE = "To update a prototype, publish to its owner node: pass source.prototypeId and that node's id as source.nodeId. Any other node that shows it forks into its own prototype and keeps its label. An update keeps the title the node shows; you must still pass a title of 200 characters or fewer, which only names a new node.";
|
|
11901
|
+
const PROTOTYPE_TITLE_OPTION = "Label above a new prototype frame, up to 200 characters. An update or a fork ignores it and keeps the title the node shows.";
|
|
11902
|
+
const PROTOTYPE_ID_OPTION = "Existing prototype to update. Without --node-id it goes to the owner node, and is refused if that node is gone.";
|
|
11903
|
+
const PROTOTYPE_NODE_OPTION = "The prototype's owner node to update it. Pass it with --prototype-id; any other node that shows the prototype forks into its own prototype.";
|
|
11649
11904
|
const OPTION_DESCRIPTIONS = {
|
|
11650
11905
|
...CANVAS_VERSION_OPTION_DESCRIPTIONS,
|
|
11651
11906
|
"--canvas-ref": "Complete canvas, page or selection URL, or canvas UUID. Preserve the supplied scope.",
|
|
@@ -11665,7 +11920,7 @@ const OPTION_DESCRIPTIONS = {
|
|
|
11665
11920
|
"operation.status --operation": "Exact durable operation reference returned by a prior call, including its kind and identity fields.",
|
|
11666
11921
|
"operation.status --include-image": "Include available render image evidence when true; this does not start another render.",
|
|
11667
11922
|
"operation.status --offset": "Zero-based entry offset; continue using nextOffset until the result reports complete.",
|
|
11668
|
-
"prototype.publishCanvas --source":
|
|
11923
|
+
"prototype.publishCanvas --source": `Selected local build directory and attachment metadata, or an existing ready deployment to attach after replanning. ${PROTOTYPE_UPDATE_GUIDANCE}`,
|
|
11669
11924
|
"--canvas-id": "Canvas id, from `enhance canvas list`.",
|
|
11670
11925
|
"--mutation-id": "Client-minted UUID identifying this atomic canvas mutation.",
|
|
11671
11926
|
"--organisation-id": "Team id, from `enhance organisation list`.",
|
|
@@ -11708,6 +11963,14 @@ const OPTION_DESCRIPTIONS = {
|
|
|
11708
11963
|
"--route": "Original page route retained with the captured screen.",
|
|
11709
11964
|
"--page-title": "Page title retained with the capture or used for a new canvas.",
|
|
11710
11965
|
"--title": "Human-readable title used to name or find the resource.",
|
|
11966
|
+
"prototype publish --title": PROTOTYPE_TITLE_OPTION,
|
|
11967
|
+
"prototype.publish --title": PROTOTYPE_TITLE_OPTION,
|
|
11968
|
+
"prototype publish --prototype-id": PROTOTYPE_ID_OPTION,
|
|
11969
|
+
"prototype.publish --prototype-id": PROTOTYPE_ID_OPTION,
|
|
11970
|
+
"canvas.node --node-id": "Stable node id returned by `enhance canvas tree`. Required unless --canvas is a single-node selection link.",
|
|
11971
|
+
"prototype publish --node-id": PROTOTYPE_NODE_OPTION,
|
|
11972
|
+
"prototype.publish --node-id": PROTOTYPE_NODE_OPTION,
|
|
11973
|
+
"canvas publish-prototype --input": `Publish request JSON. ${PROTOTYPE_UPDATE_GUIDANCE}`,
|
|
11711
11974
|
"--email": "Email address of the person to invite or add.",
|
|
11712
11975
|
"--body": "Comment text; use the JSON input for content that is difficult to quote.",
|
|
11713
11976
|
"--source-url": "Original page URL associated with the capture or recording.",
|
|
@@ -11751,6 +12014,9 @@ const OPTION_DESCRIPTIONS = {
|
|
|
11751
12014
|
"auth login --token": "Existing agent token for CI or headless fallback; omit it to authenticate in a browser.",
|
|
11752
12015
|
"canvas.create --organisation-id": "Team UUID from `enhance organisation list`; omit it to create on the personal shelf.",
|
|
11753
12016
|
"canvas.move --organisation-id": "Destination team UUID from `enhance organisation list`, or the literal `personal`.",
|
|
12017
|
+
"canvas.copyWalkthroughs --canvas-id": "Destination canvas id, from `enhance canvas list`; you need edit access to it.",
|
|
12018
|
+
"canvas.copyWalkthroughs --source-canvas-id": "Canvas id the walkthroughs are on, from `enhance canvas list`; you need read access to it.",
|
|
12019
|
+
"canvas.copyWalkthroughs --recording-ids": "Walkthrough ids on the source canvas, from `enhance recording list`; each gets one copy.",
|
|
11754
12020
|
"canvas.duplicate --organisation-id": "Destination team UUID from `enhance organisation list`, or the literal `personal`.",
|
|
11755
12021
|
"canvas.deletePermanently --confirmation": "Exact canvas title returned by `enhance canvas list --deleted true`.",
|
|
11756
12022
|
"canvas.textStyleLibrary.list --search": "Match published library titles in your teams and files shared with you.",
|
|
@@ -11787,13 +12053,16 @@ const OPTION_DESCRIPTIONS = {
|
|
|
11787
12053
|
"recording.start --page-title": "Required captured page title, or the literal null.",
|
|
11788
12054
|
"recording.appendChunk --etag": "ETag from the already-uploaded chunk at --index; omit only when abandoning that range.",
|
|
11789
12055
|
"recording.appendAudioChunk --etag": "ETag from the already-uploaded audio chunk at --index; omit only when abandoning it.",
|
|
11790
|
-
"recordingAsset.reserve --assets": "One or more JSON objects shaped `{\"url\":\"https://…\",\"contentType\":\"image/png\",\"byteSize\":123}
|
|
12056
|
+
"recordingAsset.reserve --assets": "One or more JSON objects shaped `{\"url\":\"https://…\",\"contentType\":\"image/png\",\"byteSize\":123}`, with an optional hex `\"sha256\"` that the upload is then held to.",
|
|
12057
|
+
"recordingAsset.reserve --screen-id": "Screen id from `enhance screen create` for a capture with no walkthrough; use instead of --recording-id.",
|
|
12058
|
+
"recordingAsset.confirm --screen-id": "Screen id the files were reserved against; use instead of --recording-id.",
|
|
11791
12059
|
"recordingAsset.confirm --arrived": "One or more JSON objects shaped `{\"url\":\"https://…\",\"etag\":\"…\",\"byteSize\":123}`.",
|
|
11792
12060
|
"screen.create --client-token": "Client-minted capture UUID; reuse it when retrying the same screen reservation.",
|
|
11793
12061
|
"screen.create --is-recording-mark": "Defaults to true for recording marks. Use false for an explicit canvas capture that retains recording provenance without adding a recording mark.",
|
|
11794
12062
|
"screen.create --provenance": "Required origin JSON `{\"sourceRecordingId\":\"UUID\",\"atMs\":0}`, or the literal null.",
|
|
11795
12063
|
"screen.create --route": "Required original page route, or the literal null.",
|
|
11796
12064
|
"screen.create --page-title": "Required captured page title, or the literal null.",
|
|
12065
|
+
"screen.create --sha256": "Optional hex SHA-256 of the screen file; the upload address then accepts only those bytes.",
|
|
11797
12066
|
"fixture recording --source-url": "Required original page URL represented by this recording."
|
|
11798
12067
|
};
|
|
11799
12068
|
|
|
@@ -11812,7 +12081,7 @@ const ordered = (value) => {
|
|
|
11812
12081
|
return Object.fromEntries(Object.entries(record).toSorted(([left], [right]) => left.localeCompare(right)).map(([key, held]) => [key, ordered(held)]));
|
|
11813
12082
|
};
|
|
11814
12083
|
const digest = (value) => createHash("sha256").update(JSON.stringify(ordered(value))).digest("hex");
|
|
11815
|
-
const
|
|
12084
|
+
const toKebabCase = (value) => value.replaceAll(/[A-Z]/gu, (letter) => `-${letter.toLowerCase()}`);
|
|
11816
12085
|
const fieldsFrom = (schemaValue, procedure, direction) => {
|
|
11817
12086
|
const schema = recordFrom$2(schemaValue);
|
|
11818
12087
|
const properties = recordFrom$2(schema?.["properties"]);
|
|
@@ -11820,7 +12089,7 @@ const fieldsFrom = (schemaValue, procedure, direction) => {
|
|
|
11820
12089
|
const required = new Set(Array.isArray(schema?.["required"]) ? schema["required"] : []);
|
|
11821
12090
|
return Object.entries(properties).map(([name, property]) => {
|
|
11822
12091
|
const detail = recordFrom$2(property);
|
|
11823
|
-
const option = `--${
|
|
12092
|
+
const option = `--${toKebabCase(name)}`;
|
|
11824
12093
|
const meaning = direction === "input" ? OPTION_DESCRIPTIONS[`${procedure} ${option}`] ?? OPTION_DESCRIPTIONS[option] : void 0;
|
|
11825
12094
|
return {
|
|
11826
12095
|
name,
|
|
@@ -11967,6 +12236,15 @@ const CANVAS_RECOVERY_POLICIES = {
|
|
|
11967
12236
|
"canvas.chats.delete": CHAT_HISTORY_POLICY
|
|
11968
12237
|
};
|
|
11969
12238
|
|
|
12239
|
+
//#endregion
|
|
12240
|
+
//#region src/infrastructure/recovery-copy-capability.consts.ts
|
|
12241
|
+
/** Save a copy runs in the browser; an agent copies with canvas.duplicate. */
|
|
12242
|
+
const RECOVERY_COPY_POLICY = {
|
|
12243
|
+
exposure: "internal",
|
|
12244
|
+
reason: "Browser recovery copies of unsaved work; agents copy a canvas with canvas.duplicate.",
|
|
12245
|
+
owner: "product"
|
|
12246
|
+
};
|
|
12247
|
+
|
|
11970
12248
|
//#endregion
|
|
11971
12249
|
//#region src/infrastructure/capability-policy.consts.ts
|
|
11972
12250
|
const FONT_ASSET_POLICY = {
|
|
@@ -12065,6 +12343,7 @@ const PROCEDURE_CAPABILITY_POLICIES = {
|
|
|
12065
12343
|
},
|
|
12066
12344
|
...CANVAS_RECOVERY_POLICIES,
|
|
12067
12345
|
"canvas.chats.publish": CHAT_HISTORY_POLICY,
|
|
12346
|
+
"canvas.copyFromWork": RECOVERY_COPY_POLICY,
|
|
12068
12347
|
"canvas.applyOperations": {
|
|
12069
12348
|
exposure: "internal",
|
|
12070
12349
|
reason: "Wrapped by bounded, intention-revealing authoring capabilities.",
|
|
@@ -12217,6 +12496,7 @@ const PROCEDURE_CAPABILITY_POLICIES = {
|
|
|
12217
12496
|
//#endregion
|
|
12218
12497
|
//#region src/infrastructure/shared-capability-procedure.consts.ts
|
|
12219
12498
|
const SHARED_CAPABILITY_PROCEDURES = /* @__PURE__ */ new Set([
|
|
12499
|
+
"canvas.copyWalkthroughs",
|
|
12220
12500
|
"canvas.create",
|
|
12221
12501
|
"canvas.createEditableFrame",
|
|
12222
12502
|
"canvas.delete",
|
|
@@ -12757,7 +13037,8 @@ const PROCEDURES_WITHOUT_GENERIC_RECEIPTS = /* @__PURE__ */ new Set([
|
|
|
12757
13037
|
"canvas.render.create",
|
|
12758
13038
|
"canvas.render.importSource",
|
|
12759
13039
|
"canvas.render.preparation.create",
|
|
12760
|
-
"screen.create"
|
|
13040
|
+
"screen.create",
|
|
13041
|
+
"canvas.copyFromWork"
|
|
12761
13042
|
]);
|
|
12762
13043
|
const outcomeFrom = (result) => {
|
|
12763
13044
|
if (result.ok) return {
|
|
@@ -12858,7 +13139,8 @@ const timed = trpcMiddleware(async ({ ctx, path, type, next }) => {
|
|
|
12858
13139
|
outcome: await next(),
|
|
12859
13140
|
statements: span.statements,
|
|
12860
13141
|
blobAttempts: span.blobAttempts,
|
|
12861
|
-
degraded: span.degraded
|
|
13142
|
+
degraded: span.degraded,
|
|
13143
|
+
layerRows: span.layerRows
|
|
12862
13144
|
}));
|
|
12863
13145
|
const failure = call.outcome.ok ? null : failureOf(call.outcome.error);
|
|
12864
13146
|
const line = {
|
|
@@ -12868,6 +13150,8 @@ const timed = trpcMiddleware(async ({ ctx, path, type, next }) => {
|
|
|
12868
13150
|
kind: type,
|
|
12869
13151
|
durationMs: Math.round(performance.now() - startedAt),
|
|
12870
13152
|
queryCount: call.statements.length,
|
|
13153
|
+
layerRowsRead: call.layerRows.read,
|
|
13154
|
+
layerRowsWritten: call.layerRows.written,
|
|
12871
13155
|
blobCallCount: call.blobAttempts.length,
|
|
12872
13156
|
blobRetryCount: call.blobAttempts.reduce((total, made) => total + made.attempts - 1, 0),
|
|
12873
13157
|
degraded: call.degraded.toSorted((a, b) => a.localeCompare(b)).join(","),
|
|
@@ -12891,7 +13175,8 @@ const RENDER_GRANT_PROCEDURES = /* @__PURE__ */ new Set([
|
|
|
12891
13175
|
"canvas.render.exposure",
|
|
12892
13176
|
"prototype.requestRuntimeTicket",
|
|
12893
13177
|
"recording.get",
|
|
12894
|
-
"recording.list"
|
|
13178
|
+
"recording.list",
|
|
13179
|
+
"telemetry.renderFailure"
|
|
12895
13180
|
]);
|
|
12896
13181
|
const renderGrantScope = trpcMiddleware(async ({ ctx, path, next }) => {
|
|
12897
13182
|
if (ctx.viewer.kind === "render" && !RENDER_GRANT_PROCEDURES.has(path)) throw toTrpcError(appError$1("FORBIDDEN", "the render grant cannot call that procedure"));
|
|
@@ -12959,7 +13244,7 @@ const withAccess = trpcMiddleware(async ({ ctx, getRawInput, next }) => {
|
|
|
12959
13244
|
})).match((snapshot) => snapshot, (error) => {
|
|
12960
13245
|
throw toTrpcError(error);
|
|
12961
13246
|
});
|
|
12962
|
-
if (!access.canRead) throw toTrpcError(appError$1("NOT_FOUND", "no such canvas"));
|
|
13247
|
+
if (!access.canRead) throw toTrpcError(access.isDeletedForReader === true ? appError$1("NOT_FOUND", "no such canvas", { reason: CANVAS_DELETED }) : appError$1("NOT_FOUND", "no such canvas"));
|
|
12963
13248
|
ctx.tag("canvasId", scope.data.canvasId);
|
|
12964
13249
|
return next({ ctx: {
|
|
12965
13250
|
...ctx,
|
|
@@ -13053,22 +13338,21 @@ const toCanvasActorColour = (identity) => {
|
|
|
13053
13338
|
for (const character of identity) hash = hash * HASH_RADIX + (character.codePointAt(0) ?? 0) >>> 0;
|
|
13054
13339
|
return COLOURS[hash % COLOURS.length] ?? "blue";
|
|
13055
13340
|
};
|
|
13056
|
-
const
|
|
13057
|
-
|
|
13058
|
-
|
|
13059
|
-
|
|
13060
|
-
|
|
13061
|
-
|
|
13062
|
-
|
|
13063
|
-
|
|
13064
|
-
|
|
13065
|
-
|
|
13066
|
-
|
|
13067
|
-
|
|
13068
|
-
|
|
13069
|
-
|
|
13070
|
-
|
|
13071
|
-
};
|
|
13341
|
+
const toAgentCanvasActor = (input) => ({
|
|
13342
|
+
personId: input.personId,
|
|
13343
|
+
displayName: input.displayName,
|
|
13344
|
+
initials: input.initials,
|
|
13345
|
+
colour: toCanvasActorColour(input.tokenId),
|
|
13346
|
+
kind: "agent",
|
|
13347
|
+
tokenLabel: input.tokenLabel,
|
|
13348
|
+
...input.agentAttribution !== void 0 && { agentAttribution: input.agentAttribution }
|
|
13349
|
+
});
|
|
13350
|
+
const toCanvasMutationActor = (viewer) => viewer.kind === "agent" ? toAgentCanvasActor(viewer) : {
|
|
13351
|
+
personId: viewer.personId,
|
|
13352
|
+
displayName: viewer.displayName,
|
|
13353
|
+
initials: viewer.initials,
|
|
13354
|
+
colour: toCanvasActorColour(viewer.personId),
|
|
13355
|
+
kind: "person"
|
|
13072
13356
|
};
|
|
13073
13357
|
const toAgentCanvasRequestActor = (viewer) => viewer.kind === "agent" ? {
|
|
13074
13358
|
personId: viewer.personId,
|
|
@@ -13107,7 +13391,8 @@ const toCanvasContract = (view) => ({
|
|
|
13107
13391
|
grants: [...view.reach.grants],
|
|
13108
13392
|
grantableAccessLevels: [...view.reach.grantableAccessLevels],
|
|
13109
13393
|
share: view.reach.canShare,
|
|
13110
|
-
manage: view.reach.canManage
|
|
13394
|
+
manage: view.reach.canManage,
|
|
13395
|
+
readHistory: view.reach.canSeeRoutes
|
|
13111
13396
|
},
|
|
13112
13397
|
createdAt: view.canvas.createdAt.toISOString(),
|
|
13113
13398
|
lastActivityAt: view.canvas.lastActivityAt.toISOString()
|
|
@@ -13880,12 +14165,20 @@ const createCanvasChatRouter = (handlers) => trpcRouter({
|
|
|
13880
14165
|
* always the creator, so tightening it breaks re-recording onto somebody else's canvas —
|
|
13881
14166
|
* while widening it lets a `can-view` reviewer rearrange one.
|
|
13882
14167
|
*/
|
|
14168
|
+
/** The line for a catch-up that met an unreadable batch record and answered the document. */
|
|
14169
|
+
const unreadableBatchLine = (canvasId, unreadable) => ({
|
|
14170
|
+
event: "CanvasCatchUpUnreadableBatch",
|
|
14171
|
+
canvasId,
|
|
14172
|
+
mutationId: unreadable.mutationId,
|
|
14173
|
+
version: unreadable.version
|
|
14174
|
+
});
|
|
13883
14175
|
const getDocument = (handlers) => canvasReaderProcedure.input(getCanvasDocumentInputSchema).output(getCanvasDocumentOutputSchema).query(async ({ input, ctx }) => {
|
|
13884
14176
|
const result = orThrow(await handlers.getDocument.execute({
|
|
13885
14177
|
canvasId: input.canvasId,
|
|
13886
14178
|
afterVersion: input.afterVersion,
|
|
13887
14179
|
withRoutes: ctx.canvasAccess.canSeeRoutes
|
|
13888
14180
|
}));
|
|
14181
|
+
if (result.unreadable !== void 0) ctx.logger.error(unreadableBatchLine(input.canvasId, result.unreadable), "event");
|
|
13889
14182
|
return {
|
|
13890
14183
|
...result.mutations !== void 0 && { mutations: result.mutations.map((commit) => ({
|
|
13891
14184
|
mutationId: commit.mutationId,
|
|
@@ -13893,9 +14186,9 @@ const getDocument = (handlers) => canvasReaderProcedure.input(getCanvasDocumentI
|
|
|
13893
14186
|
version: commit.version,
|
|
13894
14187
|
operations: commit.operations.map((operation) => canvasOperationSchema.parse(operation))
|
|
13895
14188
|
})) },
|
|
13896
|
-
version: result.
|
|
13897
|
-
...
|
|
13898
|
-
document: result.document
|
|
14189
|
+
version: result.version,
|
|
14190
|
+
...result.restoreFenceVersion > 0 && { restoreFenceVersion: result.restoreFenceVersion },
|
|
14191
|
+
...result.document !== void 0 && { document: result.document },
|
|
13899
14192
|
screens: result.screens.map((screen) => ({
|
|
13900
14193
|
screenId: screen.screenId,
|
|
13901
14194
|
clientToken: screen.clientToken,
|
|
@@ -14282,6 +14575,18 @@ const remove$1 = (handlers) => personProcedure.input(deleteCanvasInputSchema).ou
|
|
|
14282
14575
|
deletedAt: result.deletedAt.toISOString()
|
|
14283
14576
|
};
|
|
14284
14577
|
});
|
|
14578
|
+
const copyFromWork = (handlers) => personProcedure.input(copyCanvasFromWorkInputSchema).output(copyCanvasFromWorkOutputSchema).mutation(async ({ input, ctx }) => {
|
|
14579
|
+
const copy = orThrow(await handlers.copyFromWork.execute({
|
|
14580
|
+
...input,
|
|
14581
|
+
sourceCanvasId: input.sourceCanvasId ?? null,
|
|
14582
|
+
organisationId: input.organisationId === "personal" ? null : input.organisationId,
|
|
14583
|
+
personId: ctx.viewer.personId
|
|
14584
|
+
}));
|
|
14585
|
+
return {
|
|
14586
|
+
canvas: toCanvasContract(copy.view),
|
|
14587
|
+
document: copy.document
|
|
14588
|
+
};
|
|
14589
|
+
});
|
|
14285
14590
|
const createCanvasLifecycleRouter = (handlers) => trpcRouter({
|
|
14286
14591
|
delete: remove$1(handlers),
|
|
14287
14592
|
move: canvasOwnerProcedure.input(moveCanvasInputSchema).output(moveCanvasOutputSchema).mutation(async ({ input, ctx }) => ({ canvas: toCanvasContract(orThrow(await handlers.move.execute({
|
|
@@ -14294,6 +14599,7 @@ const createCanvasLifecycleRouter = (handlers) => trpcRouter({
|
|
|
14294
14599
|
organisationId: input.organisationId === "personal" ? null : input.organisationId,
|
|
14295
14600
|
personId: ctx.viewer.personId
|
|
14296
14601
|
}))) })),
|
|
14602
|
+
copyFromWork: copyFromWork(handlers),
|
|
14297
14603
|
deletePermanently: personProcedure.input(permanentlyDeleteCanvasInputSchema).output(permanentlyDeleteCanvasOutputSchema).mutation(async ({ input, ctx }) => orThrow(await handlers.removePermanently.execute({
|
|
14298
14604
|
...input,
|
|
14299
14605
|
personId: ctx.viewer.personId
|
|
@@ -14645,18 +14951,22 @@ const createCanvasSelectionRoute = (selection, readCanvas) => agentCanvasReaderP
|
|
|
14645
14951
|
|
|
14646
14952
|
//#endregion
|
|
14647
14953
|
//#region ../api/src/canvas/infrastructure/canvas-thumbnail.router.ts
|
|
14648
|
-
const
|
|
14954
|
+
const createCanvasThumbnailRouter = (handlers) => trpcRouter({ reportUnavailable: canvasReaderProcedure.input(reportCanvasThumbnailUnavailableInputSchema).output(reportCanvasThumbnailUnavailableOutputSchema).mutation(async ({ input, ctx }) => {
|
|
14955
|
+
const found = orThrow(await handlers.thumbnailReports.reportUnavailable({
|
|
14956
|
+
canvasId: input.canvasId,
|
|
14957
|
+
thumbnailId: input.thumbnailId
|
|
14958
|
+
}));
|
|
14649
14959
|
ctx.logger.warn({
|
|
14650
14960
|
event: "ThumbnailBlobUnavailable",
|
|
14651
14961
|
canvasId: input.canvasId,
|
|
14652
14962
|
blobId: input.thumbnailId,
|
|
14653
14963
|
clientReleaseIdentity: input.clientReleaseIdentity,
|
|
14654
14964
|
attemptedOperation: input.attemptedOperation,
|
|
14655
|
-
recoveryOutcome: input.recoveryOutcome
|
|
14965
|
+
recoveryOutcome: input.recoveryOutcome,
|
|
14966
|
+
storageOutcome: found
|
|
14656
14967
|
}, "event");
|
|
14657
14968
|
return { recorded: true };
|
|
14658
|
-
});
|
|
14659
|
-
const createCanvasThumbnailRouter = () => trpcRouter({ reportUnavailable });
|
|
14969
|
+
}) });
|
|
14660
14970
|
|
|
14661
14971
|
//#endregion
|
|
14662
14972
|
//#region ../api/src/canvas/infrastructure/canvas-version-contract.mapper.ts
|
|
@@ -14803,6 +15113,16 @@ const createCanvasVersionRouter = (handlers) => trpcRouter({
|
|
|
14803
15113
|
duplicate: duplicate(handlers)
|
|
14804
15114
|
});
|
|
14805
15115
|
|
|
15116
|
+
//#endregion
|
|
15117
|
+
//#region ../api/src/canvas/infrastructure/canvas-walkthrough.router.ts
|
|
15118
|
+
const createCanvasWalkthroughRouter = (handlers) => trpcRouter({ copyWalkthroughs: canvasEditorProcedure.meta({ description: "Copy walkthroughs from a canvas you can read into this canvas before saving players that name the copies. Each pair names a walkthrough and its copy; one that is deleted, unfinished or unreadable has no pair." }).input(copyCanvasWalkthroughsInputSchema).output(copyCanvasWalkthroughsOutputSchema).mutation(async ({ input, ctx }) => {
|
|
15119
|
+
const { copies } = orThrow(await handlers.copyWalkthroughs.execute({
|
|
15120
|
+
...input,
|
|
15121
|
+
viewer: ctx.viewer
|
|
15122
|
+
}));
|
|
15123
|
+
return { copies: [...copies] };
|
|
15124
|
+
}) });
|
|
15125
|
+
|
|
14806
15126
|
//#endregion
|
|
14807
15127
|
//#region ../api/src/canvas/infrastructure/capture-run.router.ts
|
|
14808
15128
|
const actorOf$1 = (viewer) => {
|
|
@@ -14889,6 +15209,28 @@ const createFontCatalogRouter = ({ fontCatalog }) => trpcRouter({
|
|
|
14889
15209
|
})
|
|
14890
15210
|
});
|
|
14891
15211
|
|
|
15212
|
+
//#endregion
|
|
15213
|
+
//#region ../api/src/canvas/domain/render-job-limits.policy.ts
|
|
15214
|
+
const MILLISECONDS_PER_MINUTE = 6e4;
|
|
15215
|
+
const MAX_AGE_MINUTES = 10;
|
|
15216
|
+
const OUTPUT_TTL_MINUTES = 15;
|
|
15217
|
+
const RENDER_JOB_MAX_AGE_MS = MAX_AGE_MINUTES * MILLISECONDS_PER_MINUTE;
|
|
15218
|
+
const RENDER_JOB_OUTPUT_TTL_MS = OUTPUT_TTL_MINUTES * MILLISECONDS_PER_MINUTE;
|
|
15219
|
+
const EXPORT_MAX_AGE_MINUTES = 60;
|
|
15220
|
+
const EXPORT_ATTEMPT_DEADLINE_MINUTES = 30;
|
|
15221
|
+
/** A person's export of a tall or wide layer is banded, so it may run longer than other renders. */
|
|
15222
|
+
const RENDER_EXPORT_MAX_AGE_MS = EXPORT_MAX_AGE_MINUTES * MILLISECONDS_PER_MINUTE;
|
|
15223
|
+
const RENDER_EXPORT_ATTEMPT_DEADLINE_MS = EXPORT_ATTEMPT_DEADLINE_MINUTES * MILLISECONDS_PER_MINUTE;
|
|
15224
|
+
const CAPTURE_COMPILE_ATTEMPT_DEADLINE_MINUTES = 2;
|
|
15225
|
+
/**
|
|
15226
|
+
* A screen compile of a capture run has two minutes of work. A page not editable by then lands as
|
|
15227
|
+
* its picture, so a run never waits on one slow page (Haziq, 7 November 2026).
|
|
15228
|
+
*/
|
|
15229
|
+
const RENDER_CAPTURE_COMPILE_ATTEMPT_DEADLINE_MS = CAPTURE_COMPILE_ATTEMPT_DEADLINE_MINUTES * MILLISECONDS_PER_MINUTE;
|
|
15230
|
+
const OUTAGE_RETRY_LIMIT_MS = 15 * MILLISECONDS_PER_MINUTE;
|
|
15231
|
+
/** Tries that a storage outage ended do not count against a job's tries. */
|
|
15232
|
+
const countedRenderJobAttempts = (job) => job.attempt - (job.outageAttempts ?? 0);
|
|
15233
|
+
|
|
14892
15234
|
//#endregion
|
|
14893
15235
|
//#region ../api/src/canvas/domain/render-result.value-object.ts
|
|
14894
15236
|
const isRenderConversionResult = (result) => "rootNodeId" in result;
|
|
@@ -14896,6 +15238,18 @@ const isRenderOutputResult = (result) => "storageKey" in result;
|
|
|
14896
15238
|
|
|
14897
15239
|
//#endregion
|
|
14898
15240
|
//#region ../api/src/canvas/infrastructure/render-job.presenter.ts
|
|
15241
|
+
/**
|
|
15242
|
+
* The screens a preparation compiles, the tries a worker counts, and when this try ends, so a
|
|
15243
|
+
* screen compile can use all of it.
|
|
15244
|
+
*/
|
|
15245
|
+
const toPreparationWorkExposure = (job) => ({
|
|
15246
|
+
screens: job.screens?.map((screen) => toCanvasVersionContractScreen(screen)),
|
|
15247
|
+
attempts: {
|
|
15248
|
+
counted: countedRenderJobAttempts(job),
|
|
15249
|
+
limit: 3
|
|
15250
|
+
},
|
|
15251
|
+
...job.leaseExpiresAt !== null && { deadlineAt: job.leaseExpiresAt.toISOString() }
|
|
15252
|
+
});
|
|
14899
15253
|
const wireResult = (job, result) => ({
|
|
14900
15254
|
canvasId: job.canvasId,
|
|
14901
15255
|
requestedVersion: job.requestedVersion,
|
|
@@ -15237,10 +15591,13 @@ const createExport = (handlers) => canvasPersonReaderProcedure.meta({ descriptio
|
|
|
15237
15591
|
};
|
|
15238
15592
|
});
|
|
15239
15593
|
const requireExport = (job) => job.purpose === "export" ? job : orThrow((0, import_index_cjs.err)(appError("NOT_FOUND", "no such export")));
|
|
15240
|
-
|
|
15241
|
-
|
|
15594
|
+
/** Waits up to `waitMs` for the export to settle, so the editor learns of it as soon as it does. */
|
|
15595
|
+
const getExport = (handlers) => personProcedure.input(getCanvasExportInputSchema).output(getCanvasRenderOutputSchema).query(async ({ input, ctx, signal }) => {
|
|
15596
|
+
const job = orThrow(await handlers.awaitSettled.execute({
|
|
15242
15597
|
jobId: input.jobId,
|
|
15243
|
-
actor: personActorOf(ctx.viewer)
|
|
15598
|
+
actor: personActorOf(ctx.viewer),
|
|
15599
|
+
waitMs: input.waitMs ?? 0,
|
|
15600
|
+
signal
|
|
15244
15601
|
}));
|
|
15245
15602
|
return { job: presentRender(requireExport(job)) };
|
|
15246
15603
|
});
|
|
@@ -15291,7 +15648,7 @@ const createRenderExposureRouter = (handlers) => trpcRouter({ exposure: renderPr
|
|
|
15291
15648
|
...base,
|
|
15292
15649
|
purpose: job.purpose,
|
|
15293
15650
|
preparation: job.preparationRequest,
|
|
15294
|
-
|
|
15651
|
+
...toPreparationWorkExposure(job),
|
|
15295
15652
|
scale: 1,
|
|
15296
15653
|
format: "json"
|
|
15297
15654
|
});
|
|
@@ -16002,20 +16359,13 @@ const toAgentPrototypePublisher = (viewer) => {
|
|
|
16002
16359
|
displayName: viewer.displayName,
|
|
16003
16360
|
initials: viewer.initials,
|
|
16004
16361
|
tokenId: viewer.tokenId,
|
|
16005
|
-
tokenLabel: viewer.tokenLabel
|
|
16362
|
+
tokenLabel: viewer.tokenLabel,
|
|
16363
|
+
...viewer.agentAttribution !== void 0 && { agentAttribution: viewer.agentAttribution }
|
|
16006
16364
|
}
|
|
16007
16365
|
};
|
|
16008
16366
|
};
|
|
16009
16367
|
const toPrototypePublisher = (viewer) => {
|
|
16010
|
-
return {
|
|
16011
|
-
personId: viewer.personId,
|
|
16012
|
-
...viewer.kind === "agent" && { publisher: {
|
|
16013
|
-
displayName: viewer.displayName,
|
|
16014
|
-
initials: viewer.initials,
|
|
16015
|
-
tokenId: viewer.tokenId,
|
|
16016
|
-
tokenLabel: viewer.tokenLabel
|
|
16017
|
-
} }
|
|
16018
|
-
};
|
|
16368
|
+
return viewer.kind === "agent" ? toAgentPrototypePublisher(viewer) : { personId: viewer.personId };
|
|
16019
16369
|
};
|
|
16020
16370
|
|
|
16021
16371
|
//#endregion
|
|
@@ -16364,7 +16714,8 @@ const createRecordingRouter = (handlers) => trpcRouter({
|
|
|
16364
16714
|
viewport: recording.viewport,
|
|
16365
16715
|
interrupted: recording.interrupted,
|
|
16366
16716
|
chunkCount: recording.chunkCount,
|
|
16367
|
-
startedAt: recording.startedAt.toISOString()
|
|
16717
|
+
startedAt: recording.startedAt.toISOString(),
|
|
16718
|
+
isCopy: recording.isCopy
|
|
16368
16719
|
})),
|
|
16369
16720
|
truncated: false,
|
|
16370
16721
|
unreadableCount
|
|
@@ -16384,6 +16735,18 @@ const onWire$1 = (upload) => ({
|
|
|
16384
16735
|
expiresAt: upload.expiresAt.toISOString(),
|
|
16385
16736
|
headers: upload.headers
|
|
16386
16737
|
});
|
|
16738
|
+
/** A batch names a walkthrough or a screen; the log line carries whichever it named. */
|
|
16739
|
+
const targetOf = (input) => "recordingId" in input ? {
|
|
16740
|
+
recordingId: input.recordingId,
|
|
16741
|
+
screenId: null
|
|
16742
|
+
} : {
|
|
16743
|
+
recordingId: null,
|
|
16744
|
+
screenId: input.screenId
|
|
16745
|
+
};
|
|
16746
|
+
const tagTarget = (ctx, input) => {
|
|
16747
|
+
if ("recordingId" in input) ctx.tag("recordingId", input.recordingId);
|
|
16748
|
+
else ctx.tag("screenId", input.screenId);
|
|
16749
|
+
};
|
|
16387
16750
|
/**
|
|
16388
16751
|
* Somewhere to put the files the recorded page loaded — its fonts, its images, the stylesheets
|
|
16389
16752
|
* rrweb could not read. The extension fetches them, because it holds the user's cookies and its
|
|
@@ -16394,9 +16757,9 @@ const reserveAssets = (handlers) => personProcedure.input(reserveAssetsInputSche
|
|
|
16394
16757
|
...input,
|
|
16395
16758
|
ownerPersonId: ctx.viewer.personId
|
|
16396
16759
|
}));
|
|
16397
|
-
ctx
|
|
16760
|
+
tagTarget(ctx, input);
|
|
16398
16761
|
ctx.telemetry.emit("RecordingAssetsReserved", {
|
|
16399
|
-
|
|
16762
|
+
...targetOf(input),
|
|
16400
16763
|
assetCount: input.assets.length
|
|
16401
16764
|
});
|
|
16402
16765
|
return { reserved: result.reserved.map((entry) => ({
|
|
@@ -16410,9 +16773,9 @@ const confirmAssets = (handlers) => personProcedure.input(confirmAssetsInputSche
|
|
|
16410
16773
|
...input,
|
|
16411
16774
|
ownerPersonId: ctx.viewer.personId
|
|
16412
16775
|
}));
|
|
16413
|
-
ctx
|
|
16776
|
+
tagTarget(ctx, input);
|
|
16414
16777
|
ctx.telemetry.emit("RecordingAssetsConfirmed", {
|
|
16415
|
-
|
|
16778
|
+
...targetOf(input),
|
|
16416
16779
|
assetCount: input.arrived.length,
|
|
16417
16780
|
missingAssetCount: result.missingAssetCount
|
|
16418
16781
|
});
|
|
@@ -16560,6 +16923,11 @@ const clientPerformanceTelemetryRoute = () => baseProcedure.input(clientPerforma
|
|
|
16560
16923
|
//#endregion
|
|
16561
16924
|
//#region ../api/src/shared/observability/client-render-failure.router.ts
|
|
16562
16925
|
const FINGERPRINT_LENGTH = 24;
|
|
16926
|
+
/** A render page has its own event: the crash alarm counts the editor's, and a thumbnail is not one. */
|
|
16927
|
+
const incidentEvent = (viewerKind, outcome) => {
|
|
16928
|
+
if (viewerKind === "render") return "RenderPageIncident";
|
|
16929
|
+
return outcome === "failed" ? "EditorRenderFailed" : "EditorRecoveryReported";
|
|
16930
|
+
};
|
|
16563
16931
|
const clientRenderFailureRoute = () => baseProcedure.input(clientRenderFailureInputSchema).output(clientRenderFailureOutputSchema).mutation(({ input, ctx }) => {
|
|
16564
16932
|
const { details, ...identity } = input;
|
|
16565
16933
|
const { frames, deliveryGap, ...classification } = details ?? {
|
|
@@ -16578,7 +16946,7 @@ const clientRenderFailureRoute = () => baseProcedure.input(clientRenderFailureIn
|
|
|
16578
16946
|
classification.controlId,
|
|
16579
16947
|
frames[0] ?? null
|
|
16580
16948
|
])).digest("hex").slice(0, FINGERPRINT_LENGTH);
|
|
16581
|
-
const event = classification.outcome
|
|
16949
|
+
const event = incidentEvent(ctx.viewer.kind, classification.outcome);
|
|
16582
16950
|
const fields = {
|
|
16583
16951
|
...identity,
|
|
16584
16952
|
...Object.fromEntries(Object.entries(classification).filter(([key]) => key !== "version")),
|
|
@@ -16594,15 +16962,16 @@ const clientRenderFailureRoute = () => baseProcedure.input(clientRenderFailureIn
|
|
|
16594
16962
|
},
|
|
16595
16963
|
...ctx.testRun !== null && { testRun: ctx.testRun }
|
|
16596
16964
|
};
|
|
16597
|
-
if (
|
|
16965
|
+
if (ctx.viewer.kind === "render") ctx.logger.warn(fields, "event");
|
|
16966
|
+
else if (classification.outcome !== "failed" || classification.severity === "recovered") ctx.logger.info(fields, "event");
|
|
16598
16967
|
else ctx.logger.error(fields, "event");
|
|
16599
16968
|
return { accepted: true };
|
|
16600
16969
|
});
|
|
16601
16970
|
|
|
16602
16971
|
//#endregion
|
|
16603
16972
|
//#region ../api/src/shared/observability/client-save-telemetry.router.ts
|
|
16604
|
-
/** A
|
|
16605
|
-
const isExactBuild = (build) => /^[0-9a-f]{12}$/u.test(build);
|
|
16973
|
+
/** A release names itself by its commit, short or full; `dev` or an instance label is not that. */
|
|
16974
|
+
const isExactBuild = (build) => /^(?:[0-9a-f]{12}|[0-9a-f]{40})$/u.test(build);
|
|
16606
16975
|
const eventPropertiesOf = (input, trace, apiBuild, environment) => ({
|
|
16607
16976
|
schema_version: trace.schema,
|
|
16608
16977
|
event_id: trace.eventId,
|
|
@@ -16798,6 +17167,7 @@ const canvasRouter = (handlers, options) => trpcRouter({
|
|
|
16798
17167
|
...createCanvasRouter(handlers.canvas)._def.record,
|
|
16799
17168
|
...createCanvasImageRouter(handlers.canvas)._def.record,
|
|
16800
17169
|
...createCanvasFontRouter(handlers.canvas)._def.record,
|
|
17170
|
+
...createCanvasWalkthroughRouter(handlers.canvas)._def.record,
|
|
16801
17171
|
fontCatalog: createFontCatalogRouter(handlers.canvas),
|
|
16802
17172
|
textStyleLibrary: createTextStyleLibraryRouter(handlers.canvas),
|
|
16803
17173
|
...createCanvasLifecycleRouter(handlers.canvas)._def.record,
|
|
@@ -16812,7 +17182,7 @@ const canvasRouter = (handlers, options) => trpcRouter({
|
|
|
16812
17182
|
...createRenderExposureRouter(handlers.render)._def.record,
|
|
16813
17183
|
...createRenderExportRouter(handlers.render)._def.record
|
|
16814
17184
|
}),
|
|
16815
|
-
thumbnail: createCanvasThumbnailRouter(),
|
|
17185
|
+
thumbnail: createCanvasThumbnailRouter(handlers.canvas),
|
|
16816
17186
|
participants: createCanvasParticipantRouter(handlers.canvas),
|
|
16817
17187
|
invites: createCanvasInviteRouter(handlers.canvas, options.shouldExposeInviteTokens)
|
|
16818
17188
|
});
|
|
@@ -16896,6 +17266,7 @@ const handlers = {
|
|
|
16896
17266
|
undo: unavailable.execute,
|
|
16897
17267
|
receipt: unavailable.execute
|
|
16898
17268
|
},
|
|
17269
|
+
thumbnailReports: { reportUnavailable: unavailable.execute },
|
|
16899
17270
|
chats: {
|
|
16900
17271
|
publish: unavailable.execute,
|
|
16901
17272
|
list: unavailable.execute,
|
|
@@ -16914,6 +17285,8 @@ const handlers = {
|
|
|
16914
17285
|
remove: unavailable,
|
|
16915
17286
|
move: unavailable,
|
|
16916
17287
|
duplicate: unavailable,
|
|
17288
|
+
copyFromWork: unavailable,
|
|
17289
|
+
copyWalkthroughs: unavailable,
|
|
16917
17290
|
removePermanently: unavailable,
|
|
16918
17291
|
markViewed: unavailable,
|
|
16919
17292
|
firstAgentWork: unavailable,
|
|
@@ -17040,6 +17413,7 @@ const handlers = {
|
|
|
17040
17413
|
render: {
|
|
17041
17414
|
create: unavailable,
|
|
17042
17415
|
get: unavailable,
|
|
17416
|
+
awaitSettled: unavailable,
|
|
17043
17417
|
cancel: unavailable,
|
|
17044
17418
|
download: unavailable,
|
|
17045
17419
|
expose: unavailable,
|
|
@@ -17215,7 +17589,7 @@ const createCapabilityCatalogAdapter = () => {
|
|
|
17215
17589
|
outputSchema: schemas.output,
|
|
17216
17590
|
meta: parsed.meta,
|
|
17217
17591
|
policy: procedurePolicy,
|
|
17218
|
-
cliPath: procedurePolicy.exposure === "shared" ? id.
|
|
17592
|
+
cliPath: procedurePolicy.exposure === "shared" ? id.split(".").map((part) => toKebabCase(part)).join(" ") : null,
|
|
17219
17593
|
...ROUTER_INPUT_EXAMPLES[id] !== void 0 && { inputExample: ROUTER_INPUT_EXAMPLES[id] }
|
|
17220
17594
|
});
|
|
17221
17595
|
});
|
|
@@ -17254,6 +17628,156 @@ var ProcessExitError = class extends FailedToExitError {
|
|
|
17254
17628
|
}
|
|
17255
17629
|
};
|
|
17256
17630
|
|
|
17631
|
+
//#endregion
|
|
17632
|
+
//#region src/infrastructure/failure-exit.consts.ts
|
|
17633
|
+
const BAD_REQUEST_EXIT = 3;
|
|
17634
|
+
const UNAUTHORIZED_EXIT = 4;
|
|
17635
|
+
const REFUSED_EXIT = 5;
|
|
17636
|
+
const OTHER_EXIT = 1;
|
|
17637
|
+
const EXIT_CODE_OF_FAILURE = {
|
|
17638
|
+
BAD_REQUEST: 3,
|
|
17639
|
+
UNAUTHORIZED: 4,
|
|
17640
|
+
FORBIDDEN: 5,
|
|
17641
|
+
NOT_FOUND: 5,
|
|
17642
|
+
CONFLICT: 5,
|
|
17643
|
+
RATE_LIMITED: 5,
|
|
17644
|
+
INTERNAL: 1
|
|
17645
|
+
};
|
|
17646
|
+
|
|
17647
|
+
//#endregion
|
|
17648
|
+
//#region src/infrastructure/failure.mapper.ts
|
|
17649
|
+
const remediationFor = (code) => {
|
|
17650
|
+
switch (code) {
|
|
17651
|
+
case "BAD_REQUEST": return "Run the command with '--help', then rewrite every rejected argument.";
|
|
17652
|
+
case "UNAUTHORIZED": return "Run 'enhance auth login' and complete authentication in the browser.";
|
|
17653
|
+
case "FORBIDDEN": return "Run 'enhance canvas list --scope mine' and choose a target you can change.";
|
|
17654
|
+
case "NOT_FOUND": return "List the resource again and retry with an identifier from that result.";
|
|
17655
|
+
case "CONFLICT": return "Read the resource again before retrying the change.";
|
|
17656
|
+
case "RATE_LIMITED": return "Wait for the server retry window, then retry once.";
|
|
17657
|
+
case "INTERNAL": return "Run 'enhance doctor', report the result, and stop.";
|
|
17658
|
+
}
|
|
17659
|
+
};
|
|
17660
|
+
const SESSION_EXPIRED_REMEDIATION = `Your Enhance session expired. ${remediationFor("UNAUTHORIZED")}`;
|
|
17661
|
+
/** What the shared classifier can say beyond the code, for the answers that carry more. */
|
|
17662
|
+
const remediationOf = (error, status) => {
|
|
17663
|
+
if (status === void 0) return remediationFor(error.code);
|
|
17664
|
+
const outcome = requestOutcomeOf({
|
|
17665
|
+
kind: "response",
|
|
17666
|
+
status,
|
|
17667
|
+
appError: error,
|
|
17668
|
+
retryAfterMs: null
|
|
17669
|
+
});
|
|
17670
|
+
if (outcome.kind === "sign-in" && outcome.reason === "session-expired") return SESSION_EXPIRED_REMEDIATION;
|
|
17671
|
+
if (error.code === "CONFLICT" && outcome.kind === "transient") return "Wait a few seconds, then retry the same command with the same clientToken.";
|
|
17672
|
+
if (outcome.kind === "fault" && outcome.detail === "mutation-id-reused") return "Do not reuse a clientToken with different arguments. Send this change with a new clientToken.";
|
|
17673
|
+
return remediationFor(error.code);
|
|
17674
|
+
};
|
|
17675
|
+
const trpcErrorSchema = z.object({ data: z.looseObject({
|
|
17676
|
+
appError: z.unknown(),
|
|
17677
|
+
httpStatus: z.number().optional()
|
|
17678
|
+
}) });
|
|
17679
|
+
const appErrorFrom = (error) => {
|
|
17680
|
+
const parsed = trpcErrorSchema.safeParse(error);
|
|
17681
|
+
const appError = appErrorSchema.safeParse(parsed.success ? parsed.data.data.appError : null);
|
|
17682
|
+
if (!appError.success) return null;
|
|
17683
|
+
return {
|
|
17684
|
+
appError: appError.data,
|
|
17685
|
+
remediation: remediationOf(appError.data, parsed.data?.data.httpStatus)
|
|
17686
|
+
};
|
|
17687
|
+
};
|
|
17688
|
+
const toRemoteError = (error) => {
|
|
17689
|
+
if (!(error instanceof TRPCClientError)) return error;
|
|
17690
|
+
if (error.cause instanceof CliError) return error.cause;
|
|
17691
|
+
const parsed = appErrorFrom(error);
|
|
17692
|
+
if (parsed === null) return error;
|
|
17693
|
+
return new CliError(parsed.appError.code, parsed.appError.message, parsed.remediation, parsed.appError.fields);
|
|
17694
|
+
};
|
|
17695
|
+
const failureFields = (fields) => fields === void 0 ? {} : { fields: Object.entries(fields).toSorted(([left], [right]) => left.localeCompare(right)).map(([path, message]) => ({
|
|
17696
|
+
path,
|
|
17697
|
+
message
|
|
17698
|
+
})) };
|
|
17699
|
+
const toFailurePayload = (error, parserMessage) => {
|
|
17700
|
+
if (error instanceof CliError) return {
|
|
17701
|
+
code: error.code,
|
|
17702
|
+
message: error.message,
|
|
17703
|
+
remediation: error.remediation,
|
|
17704
|
+
...failureFields(error.fields)
|
|
17705
|
+
};
|
|
17706
|
+
if (error instanceof TRPCClientError) {
|
|
17707
|
+
if (error.cause instanceof CliError) return toFailurePayload(error.cause, parserMessage);
|
|
17708
|
+
const parsed = appErrorFrom(error);
|
|
17709
|
+
if (parsed !== null) return {
|
|
17710
|
+
code: parsed.appError.code,
|
|
17711
|
+
message: parsed.appError.message,
|
|
17712
|
+
remediation: parsed.remediation,
|
|
17713
|
+
...failureFields(parsed.appError.fields)
|
|
17714
|
+
};
|
|
17715
|
+
}
|
|
17716
|
+
if (error instanceof ProcessExitError) {
|
|
17717
|
+
const message = parserMessage?.trim();
|
|
17718
|
+
return {
|
|
17719
|
+
code: "BAD_REQUEST",
|
|
17720
|
+
message: message === void 0 || message === "" ? "The command line is malformed." : message,
|
|
17721
|
+
remediation: "Run 'enhance --help' and use one of the complete command paths shown there."
|
|
17722
|
+
};
|
|
17723
|
+
}
|
|
17724
|
+
return {
|
|
17725
|
+
code: "INTERNAL",
|
|
17726
|
+
message: "The request failed before it received a usable result.",
|
|
17727
|
+
remediation: "Run 'enhance doctor', report the result, and stop."
|
|
17728
|
+
};
|
|
17729
|
+
};
|
|
17730
|
+
const toMcpFailurePayload = (error) => {
|
|
17731
|
+
const failure = toFailurePayload(error, null);
|
|
17732
|
+
if (failure.remediation !== remediationFor(failure.code) && failure.remediation !== SESSION_EXPIRED_REMEDIATION) return failure;
|
|
17733
|
+
const remediation = {
|
|
17734
|
+
BAD_REQUEST: "Review this tool’s input schema and correct the reported argument errors.",
|
|
17735
|
+
UNAUTHORIZED: "Reconnect Enhance through this host’s connection flow, then repeat the request.",
|
|
17736
|
+
FORBIDDEN: "Choose a canvas you can access. Do not repeat this write against the denied canvas.",
|
|
17737
|
+
INTERNAL: "A write may have an unknown outcome. Inspect a returned operation reference before retrying. Otherwise retry only identical arguments with the original clientToken; never create a new intent to recover a failed request. If the failure repeats, stop and report this error."
|
|
17738
|
+
};
|
|
17739
|
+
return {
|
|
17740
|
+
...failure,
|
|
17741
|
+
remediation: remediation[failure.code] ?? failure.remediation
|
|
17742
|
+
};
|
|
17743
|
+
};
|
|
17744
|
+
const toExitCode = (failure, isMalformed, error) => {
|
|
17745
|
+
if (isMalformed) return 2;
|
|
17746
|
+
if (error instanceof PartialBatchError) return 6;
|
|
17747
|
+
return EXIT_CODE_OF_FAILURE[failure.code];
|
|
17748
|
+
};
|
|
17749
|
+
const failureCodesExiting = (exitCode) => Object.entries(EXIT_CODE_OF_FAILURE).filter(([, code]) => code === exitCode).map(([name]) => `\`${name}\``).join(", ");
|
|
17750
|
+
const toPublishedExitTable = () => [
|
|
17751
|
+
{
|
|
17752
|
+
code: 0,
|
|
17753
|
+
meaning: "The command succeeded."
|
|
17754
|
+
},
|
|
17755
|
+
{
|
|
17756
|
+
code: 1,
|
|
17757
|
+
meaning: `The command failed for another reason (${failureCodesExiting(1)}). A write may have an unknown outcome.`
|
|
17758
|
+
},
|
|
17759
|
+
{
|
|
17760
|
+
code: 2,
|
|
17761
|
+
meaning: "The command line was malformed. Nothing ran."
|
|
17762
|
+
},
|
|
17763
|
+
{
|
|
17764
|
+
code: 3,
|
|
17765
|
+
meaning: `The API refused the input (${failureCodesExiting(3)}).`
|
|
17766
|
+
},
|
|
17767
|
+
{
|
|
17768
|
+
code: 4,
|
|
17769
|
+
meaning: `The credential is missing or expired (${failureCodesExiting(4)}).`
|
|
17770
|
+
},
|
|
17771
|
+
{
|
|
17772
|
+
code: 5,
|
|
17773
|
+
meaning: `The API refused the request (${failureCodesExiting(5)}).`
|
|
17774
|
+
},
|
|
17775
|
+
{
|
|
17776
|
+
code: 6,
|
|
17777
|
+
meaning: "A batch finished only in part. Retry with the same `--client-token`."
|
|
17778
|
+
}
|
|
17779
|
+
];
|
|
17780
|
+
|
|
17257
17781
|
//#endregion
|
|
17258
17782
|
//#region src/infrastructure/mcp-capability-discovery.adapter.ts
|
|
17259
17783
|
const NO_MATCH_SCORE = 0;
|
|
@@ -17384,123 +17908,6 @@ const createMcpCapabilityDiscoveryAdapter = (catalog) => ({
|
|
|
17384
17908
|
const toPresentedCapabilities = (catalog, exposures) => catalog.filter((capability) => exposures.includes(capability.policy.exposure));
|
|
17385
17909
|
const toSharedCapabilities = (catalog) => toPresentedCapabilities(catalog, ["shared"]);
|
|
17386
17910
|
|
|
17387
|
-
//#endregion
|
|
17388
|
-
//#region src/infrastructure/failure.mapper.ts
|
|
17389
|
-
const MALFORMED_EXIT = 2;
|
|
17390
|
-
const BAD_REQUEST_EXIT = 3;
|
|
17391
|
-
const UNAUTHORIZED_EXIT = 4;
|
|
17392
|
-
const REFUSED_EXIT = 5;
|
|
17393
|
-
const PARTIAL_EXIT = 6;
|
|
17394
|
-
const REFUSALS = /* @__PURE__ */ new Set([
|
|
17395
|
-
"FORBIDDEN",
|
|
17396
|
-
"NOT_FOUND",
|
|
17397
|
-
"CONFLICT",
|
|
17398
|
-
"RATE_LIMITED"
|
|
17399
|
-
]);
|
|
17400
|
-
const remediationFor = (code) => {
|
|
17401
|
-
switch (code) {
|
|
17402
|
-
case "BAD_REQUEST": return "Run the command with '--help', then rewrite every rejected argument.";
|
|
17403
|
-
case "UNAUTHORIZED": return "Run 'enhance auth login' and complete authentication in the browser.";
|
|
17404
|
-
case "FORBIDDEN": return "Run 'enhance canvas list --scope mine' and choose a target you can change.";
|
|
17405
|
-
case "NOT_FOUND": return "List the resource again and retry with an identifier from that result.";
|
|
17406
|
-
case "CONFLICT": return "Read the resource again before retrying the change.";
|
|
17407
|
-
case "RATE_LIMITED": return "Wait for the server retry window, then retry once.";
|
|
17408
|
-
case "INTERNAL": return "Run 'enhance doctor', report the result, and stop.";
|
|
17409
|
-
}
|
|
17410
|
-
};
|
|
17411
|
-
const SESSION_EXPIRED_REMEDIATION = `Your Enhance session expired. ${remediationFor("UNAUTHORIZED")}`;
|
|
17412
|
-
/** What the shared classifier can say beyond the code, for the answers that carry more. */
|
|
17413
|
-
const remediationOf = (error, status) => {
|
|
17414
|
-
if (status === void 0) return remediationFor(error.code);
|
|
17415
|
-
const outcome = requestOutcomeOf({
|
|
17416
|
-
kind: "response",
|
|
17417
|
-
status,
|
|
17418
|
-
appError: error,
|
|
17419
|
-
retryAfterMs: null
|
|
17420
|
-
});
|
|
17421
|
-
if (outcome.kind === "sign-in" && outcome.reason === "session-expired") return SESSION_EXPIRED_REMEDIATION;
|
|
17422
|
-
if (error.code === "CONFLICT" && outcome.kind === "transient") return "Wait a few seconds, then retry the same command with the same clientToken.";
|
|
17423
|
-
if (outcome.kind === "fault" && outcome.detail === "mutation-id-reused") return "Do not reuse a clientToken with different arguments. Send this change with a new clientToken.";
|
|
17424
|
-
return remediationFor(error.code);
|
|
17425
|
-
};
|
|
17426
|
-
const trpcErrorSchema = z.object({ data: z.looseObject({
|
|
17427
|
-
appError: z.unknown(),
|
|
17428
|
-
httpStatus: z.number().optional()
|
|
17429
|
-
}) });
|
|
17430
|
-
const appErrorFrom = (error) => {
|
|
17431
|
-
const parsed = trpcErrorSchema.safeParse(error);
|
|
17432
|
-
const appError = appErrorSchema.safeParse(parsed.success ? parsed.data.data.appError : null);
|
|
17433
|
-
if (!appError.success) return null;
|
|
17434
|
-
return {
|
|
17435
|
-
appError: appError.data,
|
|
17436
|
-
remediation: remediationOf(appError.data, parsed.data?.data.httpStatus)
|
|
17437
|
-
};
|
|
17438
|
-
};
|
|
17439
|
-
const toRemoteError = (error) => {
|
|
17440
|
-
if (!(error instanceof TRPCClientError)) return error;
|
|
17441
|
-
if (error.cause instanceof CliError) return error.cause;
|
|
17442
|
-
const parsed = appErrorFrom(error);
|
|
17443
|
-
if (parsed === null) return error;
|
|
17444
|
-
return new CliError(parsed.appError.code, parsed.appError.message, parsed.remediation, parsed.appError.fields);
|
|
17445
|
-
};
|
|
17446
|
-
const failureFields = (fields) => fields === void 0 ? {} : { fields: Object.entries(fields).toSorted(([left], [right]) => left.localeCompare(right)).map(([path, message]) => ({
|
|
17447
|
-
path,
|
|
17448
|
-
message
|
|
17449
|
-
})) };
|
|
17450
|
-
const toFailurePayload = (error, parserMessage) => {
|
|
17451
|
-
if (error instanceof CliError) return {
|
|
17452
|
-
code: error.code,
|
|
17453
|
-
message: error.message,
|
|
17454
|
-
remediation: error.remediation,
|
|
17455
|
-
...failureFields(error.fields)
|
|
17456
|
-
};
|
|
17457
|
-
if (error instanceof TRPCClientError) {
|
|
17458
|
-
if (error.cause instanceof CliError) return toFailurePayload(error.cause, parserMessage);
|
|
17459
|
-
const parsed = appErrorFrom(error);
|
|
17460
|
-
if (parsed !== null) return {
|
|
17461
|
-
code: parsed.appError.code,
|
|
17462
|
-
message: parsed.appError.message,
|
|
17463
|
-
remediation: parsed.remediation,
|
|
17464
|
-
...failureFields(parsed.appError.fields)
|
|
17465
|
-
};
|
|
17466
|
-
}
|
|
17467
|
-
if (error instanceof ProcessExitError) {
|
|
17468
|
-
const message = parserMessage?.trim();
|
|
17469
|
-
return {
|
|
17470
|
-
code: "BAD_REQUEST",
|
|
17471
|
-
message: message === void 0 || message === "" ? "The command line is malformed." : message,
|
|
17472
|
-
remediation: "Run 'enhance --help' and use one of the complete command paths shown there."
|
|
17473
|
-
};
|
|
17474
|
-
}
|
|
17475
|
-
return {
|
|
17476
|
-
code: "INTERNAL",
|
|
17477
|
-
message: "The request failed before it received a usable result.",
|
|
17478
|
-
remediation: "Run 'enhance doctor', report the result, and stop."
|
|
17479
|
-
};
|
|
17480
|
-
};
|
|
17481
|
-
const toMcpFailurePayload = (error) => {
|
|
17482
|
-
const failure = toFailurePayload(error, null);
|
|
17483
|
-
if (failure.remediation !== remediationFor(failure.code) && failure.remediation !== SESSION_EXPIRED_REMEDIATION) return failure;
|
|
17484
|
-
const remediation = {
|
|
17485
|
-
BAD_REQUEST: "Review this tool’s input schema and correct the reported argument errors.",
|
|
17486
|
-
UNAUTHORIZED: "Reconnect Enhance through this host’s connection flow, then repeat the request.",
|
|
17487
|
-
FORBIDDEN: "Choose a canvas you can access. Do not repeat this write against the denied canvas.",
|
|
17488
|
-
INTERNAL: "A write may have an unknown outcome. Inspect a returned operation reference before retrying. Otherwise retry only identical arguments with the original clientToken; never create a new intent to recover a failed request. If the failure repeats, stop and report this error."
|
|
17489
|
-
};
|
|
17490
|
-
return {
|
|
17491
|
-
...failure,
|
|
17492
|
-
remediation: remediation[failure.code] ?? failure.remediation
|
|
17493
|
-
};
|
|
17494
|
-
};
|
|
17495
|
-
const toExitCode = (failure, isMalformed, error) => {
|
|
17496
|
-
if (isMalformed) return MALFORMED_EXIT;
|
|
17497
|
-
if (error instanceof PartialBatchError) return PARTIAL_EXIT;
|
|
17498
|
-
if (failure.code === "BAD_REQUEST") return BAD_REQUEST_EXIT;
|
|
17499
|
-
if (failure.code === "UNAUTHORIZED") return UNAUTHORIZED_EXIT;
|
|
17500
|
-
if (REFUSALS.has(failure.code)) return REFUSED_EXIT;
|
|
17501
|
-
return 1;
|
|
17502
|
-
};
|
|
17503
|
-
|
|
17504
17911
|
//#endregion
|
|
17505
17912
|
//#region src/infrastructure/canvas-authoring-result.mapper.ts
|
|
17506
17913
|
const MAX_RECEIPT_BYTES = 4096;
|
|
@@ -17628,4 +18035,4 @@ const withCommandInFailure = (value, commandName) => ({
|
|
|
17628
18035
|
});
|
|
17629
18036
|
|
|
17630
18037
|
//#endregion
|
|
17631
|
-
export {
|
|
18038
|
+
export { canvasRenderBatchRequestSchema as $, wholeCanvasDocumentOutputSchema as $n, cliAuthConfigurationSchema as $t, operationStatusImageSchema as A, canvasRecordingPropsSchema as An, canvasAdditionalStyleSchema as Ar, hasCanvasReferenceScope as At, canvasPreparationOutputSchema as B, FRAME_KIND as Bn, getRecordingOutputSchema as Bt, canvasPrototypeOutputSchema as C, canvasCssTypographyOwners as Cn, reserveCanvasAssetOutputSchema as Cr, canvasMakeEditableInputSchema as Ct, encodeCanvasExchangeToken as D, canvasCaptureSchema as Dn, canvasRichTextValueOf as Dr, canvasReferenceNodeIds as Dt, decodeCanvasExchangeToken as E, canvasTextRunsOf as En, canvasRichTextOf as Er, assertCanvasReferenceNodes as Et, canvasAssetImportOutputSchema as F, canvasAgentActivityPhaseSchema as Fn, createCanvasOutputSchema as Fr, appErrorSchema as Ft, canvasApplyCapabilityInputSchema as G, TEXT_KIND as Gn, foldPrototypeArtifactPath as Gt, canvasCaptureCapabilityInputSchema as H, IMAGE_KIND as Hn, PROTOTYPE_ARTIFACT_MANIFEST_PATH as Ht, canvasArrangeCapabilityInputSchema as I, AGENT_CLIENT_HEADER as In, listCanvasesOutputSchema as Ir, completeScreenOutputSchema as It, canvasWriteHtmlCapabilityInputSchema as J, getCanvasMutationOutputSchema as Jn, prototypeArtifactManifestSchema as Jt, canvasReadCapabilityInputSchema as K, applyCanvasOperationsInputSchema as Kn, getPrototypeArtifactCapabilitiesOutputSchema as Kt, canvasArrangeInputSchema as L, agentClientMetadata as Ln, createScreenOutputSchema as Lt, operationStatusOutputSchema as M, canvasReferencePageOf as Mn, canvasBlendModeSchema as Mr, PartialBatchError as Mt, canvasAssetImportCapabilityInputSchema as N, resolveCanvasReference as Nn, canvasPaintSchema as Nr, CliError as Nt, resolveCanvasSnapshot as O, canvasConversionMetadataSchema as On, hasCanvasRichTextPaints as Or, canvasReferenceRenderTarget as Ot, canvasAssetImportInputSchema as P, beginCanvasActivityOutputSchema as Pn, canvasSchema as Pr, transcriptOutputSchema as Pt, transcriptReadCapabilityInputSchema as Q, saveCanvasDocumentOutputSchema as Qn, MCP_AUTH_SCOPE as Qt, canvasDuplicateCapabilityInputSchema as R, createCanvasPreparationOutputSchema as Rn, appendRecordingChunkOutputSchema as Rt, canvasPrototypeIntentSchema as S, applyCanvasTypographyPatch as Sn, reserveCanvasAssetInputSchema as Sr, canvasMakeEditableCapabilityInputSchema as St, canvasSnapshotToken as T, canvasTextPropsWithContent as Tn, canvasImageAssetIdentityFromPath as Tr, canvasEditsSchema as Tt, canvasCaptureInputSchema as U, PAGE_KIND as Un, attachPrototypeArtifactOutputSchema as Ut, canvasWriteReceiptSchema as V, GROUP_KIND as Vn, startRecordingOutputSchema as Vt, canvasCaptureOutputSchema as W, RECTANGLE_KIND as Wn, createPrototypeArtifactOutputSchema as Wt, prototypePublishCapabilityInputSchema as X, textOf as Xn, submitPrototypeArtifactOutputSchema as Xt, commentAttentionCapabilityInputSchema as Y, canvasLayoutWithoutCssProperties as Yn, prototypeArtifactPathSchema as Yt, recordingSnapshotCapabilityInputSchema as Z, mapCanvasFontSources as Zn, getMeOutputSchema as Zt, OPTION_DESCRIPTIONS as _, screenAreaCommentTargetSchema as _n, canvasLayoutMainAxisOf as _r, canvasFindCursorSchema as _t, toSharedCapabilities as a, commentAuthorSchema as an, canvasRenderStateSchema as ar, canvasRenderFileSchema as at, canvasPrototypeCapabilityInputSchema as b, screenTextCommentTargetSchema as bn, canvasCssValue as br, canvasInsertHtmlCapabilityInputSchema as bt, toFailurePayload as c, commentResolverSchema as cn, createCanvasRenderOutputSchema as cr, canvasOutlineCursorSchema as ct, toRemoteError as d, elementAnchorSchema as dn, getCanvasRenderOutputSchema as dr, canvasUpdateHtmlCapabilityInputSchema as dt, createAgentTokenOutputSchema as en, canvasOperationSchema as er, canvasRenderBatchResultSchema as et, ProcessExitError as f, getCommentOutputSchema as fn, canvasReadableSceneDocumentSchema as fr, canvasUpdateHtmlInputSchema as ft, toCapabilityDefinition as g, replyCommentOutputSchema as gn, canvasAxisStyleProperties as gr, canvasCreateToolOutputSchema as gt, createCapabilityPolicyAdapter as h, replyCommentInputSchema as hn, canvasAuthoredStyleDeclarations as hr, canvasCreateToolInputSchema as ht, toPresentedCapabilities as i, withFixtureScreen as in, canvasRenderSourceStateSchema as ir, canvasRenderRequestSchema as it, operationStatusInputSchema as j, DEFAULT_CANVAS_REFERENCE_PAGE_ID as jn, CANVAS_BLEND_MODES as jr, parseCanvasReference as jt, canvasConversionStatusSchema as k, canvasPrototypePropsSchema as kn, CANVAS_RICH_TEXT_STYLE_PROPERTIES as kr, fromCanvasReference as kt, toMcpFailurePayload as l, commentThreadSchema as ln, createRecordingSnapshotOutputSchema as lr, canvasReadInputSchema as lt, createRouterShapeAdapter as m, listCommentsOutputSchema as mn, canvasAuthoredLayoutValueOf as mr, canvasResourcesCursorSchema as mt, withCommandName as n, listOrganisationsOutputSchema as nn, createCanvasConversionOutputSchema as nr, canvasRenderScopedInputSchema as nt, createMcpCapabilityDiscoveryAdapter as o, commentCanvasContextSchema as on, canvasRenderTargetSchema as or, canvasRemoveCapabilityInputSchema as ot, createCapabilityCatalogAdapter as p, listCommentsInputSchema as pn, canvasSceneDocumentSchema as pr, canvasTranscriptCursorSchema as pt, canvasRenderCapabilityInputSchema as q, applyCanvasOperationsOutputSchema as qn, getPrototypePublishStatusOutputSchema as qt, toCanvasAuthoringResult as r, emptyFixtureDocument as rn, getCanvasConversionOutputSchema as rr, canvasRenderScopedToolInputSchema as rt, toExitCode as s, commentMessageSchema as sn, canvasWorldBoundsSchema as sr, canvasRemoveInputSchema as st, withCommandInFailure as t, createOrganisationOutputSchema as tn, canvasNodeStylePatchSchema as tr, canvasRenderPendingSchema as tt, toPublishedExitTable as u, domLocatorSchema as un, downloadCanvasRenderOutputSchema as ur, canvasReadOutputSchema as ut, PROTOTYPE_UPDATE_GUIDANCE as v, screenElementCommentTargetSchema as vn, canvasLayoutPriorityDeclarations as vr, canvasFindInputSchema as vt, canvasExchangeDigest as w, canvasTextChangeBetween as wn, canvasFontAssetIdentityFromPath as wr, canvasEditCapabilityInputSchema as wt, canvasPrototypeInputSchema as x, startCommentInputSchema as xn, canvasAssetUploadOutputSchema as xr, canvasInsertHtmlInputSchema as xt, PROCEDURE_DESCRIPTIONS as y, screenElementsCommentTargetSchema as yn, canvasCssTokens as yr, canvasFindOutputSchema as yt, canvasDuplicateInputSchema as z, getCanvasPreparationOutputSchema as zn, completeRecordingOutputSchema as zt };
|