@enhance-eng/enhance 0.1.33 → 0.1.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { $t as createOrganisationOutputSchema, At as PartialBatchError, Ct as canvasEditsSchema, Dt as fromCanvasReference, Et as canvasReferenceRenderTarget, Ft as createScreenOutputSchema, Gn as getCanvasDocumentOutputSchema, It as appendRecordingChunkOutputSchema, Kn as saveCanvasDocumentOutputSchema, Lt as completeRecordingOutputSchema, Mn as beginCanvasActivityOutputSchema, Nn as canvasAgentActivityPhaseSchema, Nt as appErrorSchema, Ot as hasCanvasReferenceScope, Pt as completeScreenOutputSchema, _ as PROCEDURE_DESCRIPTIONS, a as toFailurePayload, ar as canvasReadableSceneDocumentSchema, cr as canvasAuthoredStyleDeclarations, d as ProcessExitError, dr as canvasLayoutPriorityDeclarations, er as canvasWorldBoundsSchema, et as canvasRenderScopedInputSchema, f as createCapabilityCatalogAdapter, g as OPTION_DESCRIPTIONS, gt as canvasFindInputSchema, i as toExitCode, it as canvasRemoveCapabilityInputSchema, jt as CliError, k as operationStatusInputSchema, kt as parseCanvasReference, l as toSharedCapabilities, lr as canvasAxisStyleProperties, lt as canvasUpdateHtmlCapabilityInputSchema, m as createCapabilityPolicyAdapter, n as withCommandName, nn as withFixtureScreen, p as createRouterShapeAdapter, qn as canvasOperationSchema, r as toCanvasAuthoringResult, sr as canvasAuthoredLayoutValueOf, st as canvasReadInputSchema, t as withCommandInFailure, tn as emptyFixtureDocument, u as createMcpCapabilityDiscoveryAdapter, ur as canvasLayoutMainAxisOf, wn as canvasTextRunsOf, wt as assertCanvasReferenceNodes, yr as canvasSchema, zt as startRecordingOutputSchema } from "./cli-output-identity.lib-CWNAXho4.mjs";
3
- import { S as createAuthUseCase, _ as assertCanvasReferenceOperations, b as createCanvasActivityComposite, d as createRenderFileAdapter, f as readCanvasReferenceScene, g as createEditCanvasComposite, h as fromCapabilityReference, n as createHttpRemoteAdapter, o as createOauthLoopbackAdapter, p as createWriteHtmlCanvasComposite, r as readCliEnvironment, s as createCapabilityInvocationAdapter, t as createMutationKeyAdapter, v as sceneAtVersion, x as createRenderCanvasComposite, y as createApplyCanvasComposite } from "./mutation-key.adapter-A1d27TVY.mjs";
2
+ import { $t as createOrganisationOutputSchema, An as canvasAgentActivityPhaseSchema, At as PartialBatchError, Ct as canvasEditsSchema, Dt as fromCanvasReference, Et as canvasReferenceRenderTarget, Ft as createScreenOutputSchema, Gn as getCanvasDocumentOutputSchema, It as appendRecordingChunkOutputSchema, Kn as saveCanvasDocumentOutputSchema, Lt as completeRecordingOutputSchema, Nt as appErrorSchema, Ot as hasCanvasReferenceScope, Pt as completeScreenOutputSchema, _ as PROCEDURE_DESCRIPTIONS, a as toFailurePayload, ar as canvasReadableSceneDocumentSchema, cr as canvasAuthoredStyleDeclarations, d as ProcessExitError, dr as canvasLayoutPriorityDeclarations, er as canvasWorldBoundsSchema, et as canvasRenderScopedInputSchema, f as createCapabilityCatalogAdapter, g as OPTION_DESCRIPTIONS, gt as canvasFindInputSchema, i as toExitCode, it as canvasRemoveCapabilityInputSchema, jt as CliError, k as operationStatusInputSchema, kn as beginCanvasActivityOutputSchema, kt as parseCanvasReference, l as toSharedCapabilities, lr as canvasAxisStyleProperties, lt as canvasUpdateHtmlCapabilityInputSchema, m as createCapabilityPolicyAdapter, n as withCommandName, nn as withFixtureScreen, p as createRouterShapeAdapter, qn as canvasOperationSchema, r as toCanvasAuthoringResult, sr as canvasAuthoredLayoutValueOf, st as canvasReadInputSchema, t as withCommandInFailure, tn as emptyFixtureDocument, u as createMcpCapabilityDiscoveryAdapter, ur as canvasLayoutMainAxisOf, wn as canvasTextRunsOf, wt as assertCanvasReferenceNodes, yr as canvasSchema, zt as startRecordingOutputSchema } from "./cli-output-identity.lib-i4KnVAYs.mjs";
3
+ import { S as createAuthUseCase, _ as assertCanvasReferenceOperations, b as createCanvasActivityComposite, d as createRenderFileAdapter, f as readCanvasReferenceScene, g as createEditCanvasComposite, h as fromCapabilityReference, n as createHttpRemoteAdapter, o as createOauthLoopbackAdapter, p as createWriteHtmlCanvasComposite, r as readCliEnvironment, s as createCapabilityInvocationAdapter, t as createMutationKeyAdapter, v as sceneAtVersion, x as createRenderCanvasComposite, y as createApplyCanvasComposite } from "./mutation-key.adapter-Ck8nOqke.mjs";
4
4
  import { t as toCapabilityInventory } from "./capability-inventory.mapper-DyYXyVBJ.mjs";
5
5
  import { t as createFileCredentialAdapter } from "./file-credential.adapter-C78gc9OK.mjs";
6
6
  import process from "node:process";
@@ -35,6 +35,173 @@ const canvasColorCss = (color, opacity = 1) => {
35
35
  return `color(${color.space} ${channels} / ${String(alpha)})`;
36
36
  };
37
37
 
38
+ //#endregion
39
+ //#region ../../packages/contract/src/canvas/canvas-gradient-field.lib.ts
40
+ const UNIT_BOUNDS = {
41
+ x: 0,
42
+ y: 0,
43
+ width: 1,
44
+ height: 1
45
+ };
46
+ const fieldPoint = (paint, point) => {
47
+ const [a, b, c, d, e, f] = paint.transform;
48
+ const determinant = a * d - b * c;
49
+ const x = point.x - e, y = point.y - f;
50
+ return {
51
+ x: (d * x - c * y) / determinant,
52
+ y: (a * y - b * x) / determinant
53
+ };
54
+ };
55
+ const canvasGradientFieldCoordinates = (paint, bounds = UNIT_BOUNDS) => [
56
+ {
57
+ x: bounds.x,
58
+ y: bounds.y
59
+ },
60
+ {
61
+ x: bounds.x + bounds.width,
62
+ y: bounds.y
63
+ },
64
+ {
65
+ x: bounds.x,
66
+ y: bounds.y + bounds.height
67
+ },
68
+ {
69
+ x: bounds.x + bounds.width,
70
+ y: bounds.y + bounds.height
71
+ }
72
+ ].flatMap((point) => {
73
+ const local = fieldPoint(paint, point);
74
+ return [local.x, local.y];
75
+ });
76
+
77
+ //#endregion
78
+ //#region ../../packages/contract/src/canvas/canvas-angular-gradient.lib.ts
79
+ const HALF$1 = .5;
80
+ const FULL_TURN = 360;
81
+ const PERCENT$4 = 100;
82
+ const FIELD_UNIT = 1024;
83
+ const LINEAR_COEFFICIENTS = 4;
84
+ const gradient = (paint, center, isAlpha) => {
85
+ const stops = paint.stops.map((stop) => {
86
+ return `${isAlpha ? `rgb(255 255 255 / ${String(stop.color.alpha * paint.opacity)})` : canvasColorCss({
87
+ ...stop.color,
88
+ alpha: 1
89
+ })} ${String(stop.position * FULL_TURN)}deg`;
90
+ });
91
+ return `conic-gradient(from 90deg at ${String(center)}% ${String(center)}% in srgb, ${stops.join(", ")})`;
92
+ };
93
+ /** Separate alpha from color so translucent stops interpolate straight sRGB, as copied by Figma. */
94
+ const canvasAngularGradientField = (paint, bounds) => {
95
+ const coordinates = canvasGradientFieldCoordinates(paint, bounds);
96
+ const low = Math.min(0, ...coordinates);
97
+ const span = Math.max(1, ...coordinates) - low;
98
+ const center = (HALF$1 - low) / span * PERCENT$4;
99
+ const matrix = paint.transform.map((value, index) => index < LINEAR_COEFFICIENTS ? value / FIELD_UNIT : value);
100
+ const style = `width:100%;height:100%;background-image:${gradient(paint, center, false)};mask-image:${gradient(paint, center, true)};`;
101
+ return `<g transform="matrix(${matrix.map(String).join(" ")})"><foreignObject x="${String(low * FIELD_UNIT)}" y="${String(low * FIELD_UNIT)}" width="${String(span * FIELD_UNIT)}" height="${String(span * FIELD_UNIT)}" overflow="visible"><div xmlns="http://www.w3.org/1999/xhtml" style="${style}"></div></foreignObject></g>`;
102
+ };
103
+ const canvasAngularGradientSvg = (paint) => `<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 1 1" preserveAspectRatio="none">${canvasAngularGradientField(paint)}</svg>`;
104
+
105
+ //#endregion
106
+ //#region ../../packages/contract/src/canvas/canvas-diamond-gradient.lib.ts
107
+ const HALF = .5;
108
+ const QUARTER = .25;
109
+ /** Each quadrant is a linear field with slope 2*(abs(x-.5)+abs(y-.5)). */
110
+ const canvasDiamondGradientField = (paint, id = "field", bounds) => {
111
+ const coordinates = canvasGradientFieldCoordinates(paint, bounds);
112
+ const extent = Math.max(HALF, ...coordinates.map((value) => Math.abs(value - HALF))) + 1;
113
+ const low = HALF - extent, high = HALF + extent;
114
+ const quadrants = [
115
+ {
116
+ x: .75,
117
+ y: .75,
118
+ points: `.5,.5 ${String(high)},.5 ${String(high)},${String(high)} .5,${String(high)}`
119
+ },
120
+ {
121
+ x: QUARTER,
122
+ y: .75,
123
+ points: `.5,.5 .5,${String(high)} ${String(low)},${String(high)} ${String(low)},.5`
124
+ },
125
+ {
126
+ x: QUARTER,
127
+ y: QUARTER,
128
+ points: `.5,.5 ${String(low)},.5 ${String(low)},${String(low)} .5,${String(low)}`
129
+ },
130
+ {
131
+ x: .75,
132
+ y: QUARTER,
133
+ points: `.5,.5 .5,${String(low)} ${String(high)},${String(low)} ${String(high)},.5`
134
+ }
135
+ ];
136
+ const stops = paint.stops.map((stop) => `<stop offset="${String(stop.position)}" stop-color="${canvasColorCss({
137
+ ...stop.color,
138
+ alpha: 1
139
+ })}" stop-opacity="${String(stop.color.alpha * paint.opacity)}" />`).join("");
140
+ const definitions = quadrants.map((quadrant, index) => `<linearGradient id="${id}-${String(index)}" gradientUnits="userSpaceOnUse" x1=".5" y1=".5" x2="${String(quadrant.x)}" y2="${String(quadrant.y)}" color-interpolation="sRGB">${stops}</linearGradient>`).join("");
141
+ const fields = quadrants.map((quadrant, index) => `<polygon points="${quadrant.points}" fill="url(#${id}-${String(index)})" shape-rendering="crispEdges" />`).join("");
142
+ return `<defs>${definitions}</defs><g transform="matrix(${paint.transform.map(String).join(" ")})">${fields}</g>`;
143
+ };
144
+ const canvasDiamondGradientSvg = (paint) => `<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 1 1" preserveAspectRatio="none">${canvasDiamondGradientField(paint)}</svg>`;
145
+
146
+ //#endregion
147
+ //#region ../../packages/contract/src/canvas/canvas-filter.lib.ts
148
+ const PERCENT$3 = 100;
149
+ /** Radius/2 preserves the existing Gaussian approximation, not native sampling parity. */
150
+ const canvasBlurStandardDeviation = (filter) => filter.parameter === "radius" ? filter.value / 2 : filter.value;
151
+ const filterCss = (filter) => {
152
+ switch (filter.kind) {
153
+ case "blur": return `blur(${String(canvasBlurStandardDeviation(filter))}px)`;
154
+ case "brightness":
155
+ case "contrast":
156
+ case "saturate": return `${filter.kind}(${String(filter.value)})`;
157
+ case "grayscale":
158
+ case "invert":
159
+ case "sepia": return `${filter.kind}(${String(filter.value * PERCENT$3)}%)`;
160
+ case "hue-rotate": return `hue-rotate(${String(filter.value)}deg)`;
161
+ }
162
+ };
163
+ const canvasFilterListCss = (filters) => filters.filter((filter) => filter.visible).map((filter) => filterCss(filter)).join(" ");
164
+
165
+ //#endregion
166
+ //#region ../../packages/contract/src/canvas/canvas-font-family.lib.ts
167
+ const GENERIC_FAMILIES = /* @__PURE__ */ new Set([
168
+ "cursive",
169
+ "emoji",
170
+ "fantasy",
171
+ "fangsong",
172
+ "math",
173
+ "monospace",
174
+ "sans-serif",
175
+ "serif",
176
+ "system-ui",
177
+ "ui-monospace",
178
+ "ui-rounded",
179
+ "ui-sans-serif",
180
+ "ui-serif"
181
+ ]);
182
+ const CSS_IDENTIFIER = /^-?[_a-z][-\w]*$/iu;
183
+ const CSS_VARIABLE = /^var\(--[-\w]+\)$/iu;
184
+ const MAX_UNICODE = 1114111;
185
+ const SURROGATE_START = 55296;
186
+ const SURROGATE_END = 57343;
187
+ const REPLACEMENT_CHARACTER = 65533;
188
+ const isCanvasGenericFontFamily = (family) => GENERIC_FAMILIES.has(family.toLowerCase());
189
+ const decodedCss = (value) => value.replaceAll(/\\(?:([\da-f]{1,6})(?:\r\n|[\t\n\f\r ])?|(\r\n|[\n\r\f])|([^\da-f]))/giu, (_match, hex, newline, literal) => {
190
+ if (newline !== void 0) return "";
191
+ if (hex === void 0) return literal ?? "";
192
+ const point = Number.parseInt(hex, 16);
193
+ return String.fromCodePoint(point === 0 || point > MAX_UNICODE || point >= SURROGATE_START && point <= SURROGATE_END ? REPLACEMENT_CHARACTER : point);
194
+ });
195
+ const canvasFontFamilyName = (token) => {
196
+ const value = token.trim();
197
+ const isQuoted = value.startsWith("\"") && value.endsWith("\"") || value.startsWith("'") && value.endsWith("'");
198
+ return decodedCss(isQuoted ? value.slice(1, -1) : value);
199
+ };
200
+ const canvasFontFamilyCss = (family) => {
201
+ if (family.startsWith("\"") && isCanvasGenericFontFamily(canvasFontFamilyName(family))) return JSON.stringify(canvasFontFamilyName(family));
202
+ return CSS_IDENTIFIER.test(family) || CSS_VARIABLE.test(family) ? family : JSON.stringify(family);
203
+ };
204
+
38
205
  //#endregion
39
206
  //#region ../../packages/contract/src/canvas/canvas-typography-css.lib.ts
40
207
  const PERCENT$2 = 100;
@@ -43,15 +210,12 @@ const canvasTextDirectionDeclarations = (direction) => direction === void 0 ? {}
43
210
  ...direction !== "auto" && { direction },
44
211
  "unicode-bidi": direction === "auto" ? "plaintext" : "isolate"
45
212
  };
46
- const CSS_IDENTIFIER = /^-?[_a-z][-\w]*$/iu;
47
- const CSS_VARIABLE = /^var\(--[-\w]+\)$/iu;
48
- const fontFamilyName = (family) => CSS_IDENTIFIER.test(family) || CSS_VARIABLE.test(family) ? family : JSON.stringify(family);
49
213
  const canvasTypographyFontFamily = (typography) => [.../* @__PURE__ */ new Set([
50
214
  typography.family,
51
215
  ...typography.family === "Inter" ? ["Inter Variable"] : [],
52
216
  ...typography.family === "JetBrains Mono" ? ["JetBrains Mono Variable"] : [],
53
217
  ...typography.fallbackFamilies
54
- ])].map((family) => fontFamilyName(family)).join(", ");
218
+ ])].map((family) => canvasFontFamilyCss(family)).join(", ");
55
219
  /** Weight is the sole wght owner; the remaining axes never shadow the visible weight field. */
56
220
  const canvasFontVariationSettings = (typography) => Object.entries({
57
221
  ...typography.variations,
@@ -86,10 +250,45 @@ const canvasTextDecorationDeclarations = (decoration) => ({
86
250
  "text-decoration-skip-ink": decoration.skipInk ?? "auto"
87
251
  });
88
252
 
253
+ //#endregion
254
+ //#region ../../packages/contract/src/canvas/canvas-linear-gradient.lib.ts
255
+ const canvasLinearGradientDefinition = (paint, id, units = "userSpaceOnUse") => {
256
+ const stops = paint.stops.map((stop) => `<stop offset="${String(stop.position)}" stop-color="${canvasColorCss({
257
+ ...stop.color,
258
+ alpha: 1
259
+ })}" stop-opacity="${String(stop.color.alpha * paint.opacity)}" />`).join("");
260
+ return `<linearGradient id="${id}" gradientUnits="${units}" x1="0" y1=".5" x2="1" y2=".5" gradientTransform="matrix(${paint.transform.map(String).join(" ")})" color-interpolation="sRGB">${stops}</linearGradient>`;
261
+ };
262
+ const canvasLinearGradientSvg = (paint) => {
263
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 1 1" preserveAspectRatio="none"><defs>${canvasLinearGradientDefinition(paint, "field")}</defs><path d="M0 0H1V1H0Z" fill="url(#field)" /></svg>`;
264
+ };
265
+
266
+ //#endregion
267
+ //#region ../../packages/contract/src/canvas/canvas-radial-gradient.lib.ts
268
+ const DIAMETER = 2;
269
+ const transformFor = (paint) => paint.transform ?? [
270
+ paint.radius.x * DIAMETER,
271
+ 0,
272
+ 0,
273
+ paint.radius.y * DIAMETER,
274
+ paint.center.x - paint.radius.x,
275
+ paint.center.y - paint.radius.y
276
+ ];
277
+ const canvasRadialGradientDefinition = (paint, id, units = "userSpaceOnUse") => {
278
+ const stops = paint.stops.map((stop) => `<stop offset="${String(stop.position)}" stop-color="${canvasColorCss({
279
+ ...stop.color,
280
+ alpha: 1
281
+ })}" stop-opacity="${String(stop.color.alpha * paint.opacity)}" />`).join("");
282
+ return `<radialGradient id="${id}" gradientUnits="${units}" cx=".5" cy=".5" r=".5" gradientTransform="matrix(${transformFor(paint).map(String).join(" ")})" color-interpolation="sRGB">${stops}</radialGradient>`;
283
+ };
284
+ const canvasRadialGradientSvg = (paint) => {
285
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 1 1" preserveAspectRatio="none"><defs>${canvasRadialGradientDefinition(paint, "field")}</defs><path d="M0 0H1V1H0Z" fill="url(#field)" /></svg>`;
286
+ };
287
+
89
288
  //#endregion
90
289
  //#region ../../packages/contract/src/recording/event-stream.lib.ts
91
290
  /**
92
- * @justified docs/comments.md#intent
291
+ * @justified intent
93
292
  * The recording wire format, in one place, because the recorder, the seed and the player all
94
293
  * speak it.
95
294
  *
@@ -98,7 +297,7 @@ const canvasTextDecorationDeclarations = (decoration) => ({
98
297
  *
99
298
  * It has to work that way. rrweb emits the full snapshot as a *single event*, and with fonts and
100
299
  * images inlined that runs to megabytes; whole-event chunks would put that event's size under
101
- * the request ceiling, making the ceiling one on fidelity. docs/features/recorder.md#dom.
300
+ * the request ceiling, making the ceiling one on fidelity.
102
301
  *
103
302
  * A raw newline only ever separates records: `JSON.stringify` writes one inside a string as the
104
303
  * two characters `\` and `n`.
@@ -106,7 +305,7 @@ const canvasTextDecorationDeclarations = (decoration) => ({
106
305
  /** One event's line, terminator included. Every line ends in one, including the last. */
107
306
  const lineFor = (event) => `${JSON.stringify(event)}\n`;
108
307
  /**
109
- * @justified docs/comments.md#clarification
308
+ * @justified clarification
110
309
  * A recording being written, cut into ranges of at most `limit` units as it goes.
111
310
  *
112
311
  * A range comes out the moment it is full, because the point of streaming is that stopping is a
@@ -837,20 +1036,21 @@ const cssPaint = (paint) => {
837
1036
  if (!paint.visible) return null;
838
1037
  if (paint.kind === "solid") return cssColour(paint.color);
839
1038
  if (paint.kind === "image") return `url(${JSON.stringify(paint.assetId)})`;
1039
+ if (paint.kind === "angular-gradient" || paint.kind === "diamond-gradient") {
1040
+ const svg = paint.kind === "angular-gradient" ? canvasAngularGradientSvg(paint) : canvasDiamondGradientSvg(paint);
1041
+ return `url("data:image/svg+xml,${encodeURIComponent(svg)}") 0 0 / 100% 100% no-repeat`;
1042
+ }
840
1043
  const stops = paint.stops.map((stop) => `${cssColour(stop.color)} ${String(stop.position * PERCENT)}%`).join(", ");
841
- if (paint.kind === "linear-gradient") return `linear-gradient(${String(paint.angle)}deg, ${stops})`;
1044
+ if (paint.kind === "linear-gradient") {
1045
+ if (paint.transform !== void 0) return `url("data:image/svg+xml,${encodeURIComponent(canvasLinearGradientSvg({
1046
+ ...paint,
1047
+ transform: paint.transform
1048
+ }))}") 0 0 / 100% 100% no-repeat`;
1049
+ return `linear-gradient(${String(paint.angle)}deg, ${stops})`;
1050
+ }
1051
+ if (paint.transform !== void 0) return `url("data:image/svg+xml,${encodeURIComponent(canvasRadialGradientSvg(paint))}") 0 0 / 100% 100% no-repeat`;
842
1052
  return `radial-gradient(at ${String(paint.center.x * PERCENT)}% ${String(paint.center.y * PERCENT)}%, ${stops})`;
843
1053
  };
844
- const cssFilter = (filter) => {
845
- if (filter.kind === "blur") return `blur(${String(filter.value)}px)`;
846
- if (filter.kind === "hue-rotate") return `hue-rotate(${String(filter.value)}deg)`;
847
- const value = [
848
- "grayscale",
849
- "invert",
850
- "sepia"
851
- ].includes(filter.kind) ? `${String(filter.value * PERCENT)}%` : String(filter.value);
852
- return `${filter.kind}(${value})`;
853
- };
854
1054
  const visiblePaints = (paints) => paints?.flatMap((paint) => {
855
1055
  const value = cssPaint(paint);
856
1056
  return value === null ? [] : [value];
@@ -881,12 +1081,12 @@ const outlineCss = (outline) => {
881
1081
  };
882
1082
  const effectCss = (appearance) => {
883
1083
  const shadows = appearance.shadows?.filter((shadow) => shadow.visible).map((shadow) => `${shadow.kind === "inner" ? "inset " : ""}${String(shadow.offsetX)}px ${String(shadow.offsetY)}px ${String(shadow.blur)}px ${String(shadow.spread)}px ${cssColour(shadow.color)}`);
884
- const filters = appearance.filters?.filter((filter) => filter.visible).map(cssFilter);
885
- const backdrop = appearance.backdropFilters?.filter((filter) => filter.visible).map(cssFilter);
1084
+ const filters = canvasFilterListCss(appearance.filters ?? []);
1085
+ const backdrop = canvasFilterListCss(appearance.backdropFilters ?? []);
886
1086
  return {
887
1087
  ...shadows !== void 0 && shadows.length > 0 && { "box-shadow": shadows.join(", ") },
888
- ...filters !== void 0 && filters.length > 0 && { filter: filters.join(" ") },
889
- ...backdrop !== void 0 && backdrop.length > 0 && { "backdrop-filter": backdrop.join(" ") }
1088
+ ...filters !== "" && { filter: filters },
1089
+ ...backdrop !== "" && { "backdrop-filter": backdrop }
890
1090
  };
891
1091
  };
892
1092
  const appearanceCss = (appearance) => {
@@ -1594,7 +1794,7 @@ const registerCanvasProgram = (program, input) => {
1594
1794
  };
1595
1795
 
1596
1796
  //#endregion
1597
- //#region ../../packages/sdk/dist/capture-files.lib-DmLQGNWF.mjs
1797
+ //#region ../../packages/sdk/dist/capture-files.lib-Gy817Cvp.mjs
1598
1798
  const CAPTURE_KEY_LENGTH = 160;
1599
1799
  const CAPTURE_METADATA_LENGTH = 200;
1600
1800
  const CAPTURE_ISSUE_LENGTH = 500;
@@ -1614,6 +1814,30 @@ const captureBlobSchema = z.strictObject({
1614
1814
  bytes: z.number().int().positive(),
1615
1815
  mediaType: z.string().min(1).max(CAPTURE_METADATA_LENGTH)
1616
1816
  });
1817
+ const captureDestinationSchema = z.strictObject({ organisationId: z.uuid().optional() });
1818
+ const captureContextSchema = z.strictObject({
1819
+ key: z.string().min(1),
1820
+ label: z.string().min(1),
1821
+ url: z.url().optional(),
1822
+ sequence: z.number().int().nonnegative(),
1823
+ attempt: z.number().int().nonnegative().default(0)
1824
+ });
1825
+ const captureBaselineSelectionSchema = z.union([z.strictObject({ runId: z.uuid() }), z.strictObject({
1826
+ reference: z.string().min(1),
1827
+ revision: z.string().min(1).optional()
1828
+ })]);
1829
+ const captureReviewMetadataSchema = z.strictObject({
1830
+ destination: captureDestinationSchema,
1831
+ context: captureContextSchema.optional(),
1832
+ revision: z.string().min(1).optional(),
1833
+ baselineRunId: z.uuid().nullable(),
1834
+ compareTo: captureBaselineSelectionSchema.optional()
1835
+ });
1836
+ const captureVerdictSchema = z.enum([
1837
+ "awaiting-review",
1838
+ "approved",
1839
+ "changes-requested"
1840
+ ]);
1617
1841
  const captureArtifactSchema = z.strictObject({
1618
1842
  format: z.literal("enhance-capture"),
1619
1843
  version: z.literal(1),
@@ -1621,6 +1845,7 @@ const captureArtifactSchema = z.strictObject({
1621
1845
  label: key,
1622
1846
  journeyLabel: key,
1623
1847
  order: z.number().int().nonnegative(),
1848
+ page: z.string().min(1).optional(),
1624
1849
  viewport: z.strictObject({
1625
1850
  width: dimension,
1626
1851
  height: dimension,
@@ -1693,7 +1918,8 @@ const captureRunDescriptorSchema = z.strictObject({
1693
1918
  generation: z.number().int().nonnegative(),
1694
1919
  participants: z.array(key).min(1),
1695
1920
  expiresAt: z.iso.datetime(),
1696
- formatVersion: z.literal(1)
1921
+ formatVersion: z.literal(1),
1922
+ review: captureReviewMetadataSchema.optional()
1697
1923
  });
1698
1924
  const captureAttemptSchema = z.strictObject({
1699
1925
  participant: key,
@@ -1741,11 +1967,25 @@ const captureReceiptSchema = z.strictObject({
1741
1967
  }))
1742
1968
  });
1743
1969
  const beginCaptureRunInputSchema = z.strictObject({
1744
- canvasId: z.uuid(),
1970
+ canvasId: z.uuid().optional(),
1971
+ destination: captureDestinationSchema.optional(),
1972
+ title: z.string().trim().min(1).optional(),
1973
+ context: captureContextSchema.optional(),
1974
+ revision: z.string().min(1).optional(),
1975
+ compareTo: captureBaselineSelectionSchema.optional(),
1745
1976
  source: key.default("default"),
1746
1977
  runKey: key,
1747
1978
  participants: z.array(key).min(1).default(["local"]),
1748
1979
  formatVersion: z.literal(1).default(1)
1980
+ }).superRefine((input, ctx) => {
1981
+ if (input.canvasId === void 0 === (input.destination === void 0)) ctx.addIssue({
1982
+ code: "custom",
1983
+ message: "Choose either a canvas or a destination for this run."
1984
+ });
1985
+ if (input.canvasId !== void 0 && (input.context !== void 0 || input.compareTo !== void 0)) ctx.addIssue({
1986
+ code: "custom",
1987
+ message: "Run review requires a destination."
1988
+ });
1749
1989
  });
1750
1990
  const beginCaptureRunOutputSchema = z.strictObject({ run: captureRunDescriptorSchema });
1751
1991
  z.strictObject({ runId: z.uuid() });
@@ -1761,6 +2001,7 @@ const getCaptureRunOutputSchema = z.strictObject({
1761
2001
  run: captureRunDescriptorSchema,
1762
2002
  state: captureRunStateSchema,
1763
2003
  receipt: captureReceiptSchema.nullable(),
2004
+ verdict: captureVerdictSchema.optional(),
1764
2005
  failure: z.strictObject({
1765
2006
  code: key,
1766
2007
  message: z.string().max(CAPTURE_FAILURE_LENGTH)
@@ -1902,6 +2143,7 @@ const finalAttempts = (manifest) => {
1902
2143
  const uniqueCaptures = (source, artifacts) => {
1903
2144
  const keys = /* @__PURE__ */ new Set();
1904
2145
  const orders = /* @__PURE__ */ new Set();
2146
+ const pages = /* @__PURE__ */ new Map();
1905
2147
  for (const artifact of artifacts) {
1906
2148
  if (artifact.key.source !== source) return "Capture source differs from its reserved run.";
1907
2149
  const identity = captureKeyString(artifact.key);
@@ -1912,6 +2154,9 @@ const uniqueCaptures = (source, artifacts) => {
1912
2154
  artifact.order
1913
2155
  ]);
1914
2156
  if (orders.has(order)) return `Duplicate step order in journey ${artifact.key.journey}.`;
2157
+ const journey = JSON.stringify([artifact.key.journey, artifact.key.variant]);
2158
+ if (pages.has(journey) && pages.get(journey) !== artifact.page) return `Every step in journey ${artifact.key.journey} must use the same page.`;
2159
+ pages.set(journey, artifact.page);
1915
2160
  keys.add(identity);
1916
2161
  orders.add(order);
1917
2162
  }
@@ -1941,6 +2186,71 @@ const captureManifestContent = (manifest) => {
1941
2186
  const serialized = canonicalCaptureJson(manifest);
1942
2187
  return serialized === null ? null : `enhance-capture-run:v1\0${serialized}`;
1943
2188
  };
2189
+ const mergeCaptureManifests = (parts) => {
2190
+ const first = parts[0];
2191
+ if (first === void 0) return "At least one participant manifest is required.";
2192
+ const descriptor = canonicalCaptureJson(first.run);
2193
+ const participants = /* @__PURE__ */ new Map();
2194
+ const attempts = [];
2195
+ for (const part of parts) {
2196
+ if (canonicalCaptureJson(part.run) !== descriptor || part.ordering !== first.ordering) return "Participant manifests must belong to the same reserved run and ordering.";
2197
+ for (const participant of part.participants) {
2198
+ if (participants.has(participant.id)) return "A participant manifest was supplied more than once.";
2199
+ participants.set(participant.id, participant);
2200
+ }
2201
+ if (part.attempts.some((attempt) => part.participants.every((participant) => participant.id !== attempt.participant))) return "A participant manifest contains another participant’s attempt.";
2202
+ attempts.push(...part.attempts);
2203
+ }
2204
+ const manifest = {
2205
+ ...first,
2206
+ participants: Array.from(participants, ([, participant]) => participant).toSorted((a, b) => compare(a.id, b.id)),
2207
+ attempts: attempts.toSorted((a, b) => {
2208
+ const participant = compare(a.participant, b.participant);
2209
+ if (participant !== 0) return participant;
2210
+ const project = compare(a.project, b.project);
2211
+ if (project !== 0) return project;
2212
+ const test = compare(a.testId, b.testId);
2213
+ return test === 0 ? a.retry - b.retry : test;
2214
+ })
2215
+ };
2216
+ const selected = selectedCaptures(manifest);
2217
+ return typeof selected === "string" ? selected : manifest;
2218
+ };
2219
+ z.strictObject({ canvasId: z.uuid() }).extend({ verdict: captureVerdictSchema });
2220
+ const captureReferenceInputSchema = z.strictObject({
2221
+ canvasId: z.uuid(),
2222
+ name: z.string().min(1)
2223
+ });
2224
+ const captureReferenceSchema = z.strictObject({
2225
+ runId: z.uuid(),
2226
+ revision: z.string(),
2227
+ version: z.number().int().positive()
2228
+ });
2229
+ const updateCaptureReferenceInputSchema = captureReferenceInputSchema.extend({
2230
+ expectedVersion: z.number().int().nonnegative(),
2231
+ revision: z.string().min(1)
2232
+ });
2233
+ const captureReviewSchema = z.strictObject({
2234
+ current: getCaptureRunOutputSchema,
2235
+ latest: captureRunDescriptorSchema,
2236
+ related: z.array(z.strictObject({
2237
+ run: captureRunDescriptorSchema,
2238
+ verdict: captureVerdictSchema
2239
+ })),
2240
+ changes: z.array(z.strictObject({
2241
+ key: captureKeySchema,
2242
+ frameId: z.string(),
2243
+ label: z.string(),
2244
+ journeyLabel: z.string(),
2245
+ page: z.string().optional(),
2246
+ change: z.enum([
2247
+ "new",
2248
+ "changed",
2249
+ "unchanged",
2250
+ "uncompared"
2251
+ ])
2252
+ }))
2253
+ });
1944
2254
  const captureError = (code, message, runId) => Object.assign(new Error(message), {
1945
2255
  code,
1946
2256
  ...runId !== void 0 && { runId }
@@ -2001,14 +2311,20 @@ const readCaptureManifest = async (path) => {
2001
2311
  };
2002
2312
 
2003
2313
  //#endregion
2004
- //#region ../../packages/sdk/dist/capture-client.client-D7YPcnYK.mjs
2314
+ //#region ../../packages/sdk/dist/capture-client.client-wrAGDHxW.mjs
2005
2315
  const UPLOAD_BATCH_SIZE = 400;
2006
2316
  const POLL_INTERVAL_MS = 250;
2317
+ const readFromDirectories = async (directories, blob) => {
2318
+ for (const directory of directories) try {
2319
+ return await readCaptureBlob(directory, blob);
2320
+ } catch {}
2321
+ throw captureError("artifact", `Capture blob is unavailable: ${blob.sha256}.`);
2322
+ };
2007
2323
  const uploadBlob = async (input) => {
2008
2324
  if (input.held === void 0) throw captureError("transport", "Enhance omitted a requested blob reservation.", input.runId);
2009
2325
  const upload = input.held.upload;
2010
2326
  if (upload === null) return;
2011
- const bytes = await readCaptureBlob(input.directory, input.blob);
2327
+ const bytes = await readFromDirectories(input.directories, input.blob);
2012
2328
  try {
2013
2329
  if (!(await fetch(upload.url, {
2014
2330
  method: "PUT",
@@ -2021,11 +2337,11 @@ const uploadBlob = async (input) => {
2021
2337
  throw captureError("transport", "Capture upload was not confirmed. Resume the same manifest.", input.runId);
2022
2338
  }
2023
2339
  };
2024
- const uploadBlobs = async (transport, manifest, directory, blobs) => {
2340
+ const uploadBlobs = async (transport, manifest, directories, blobs) => {
2025
2341
  let unavailable = 0;
2026
2342
  const available = [];
2027
2343
  for (const blob of blobs) try {
2028
- await readCaptureBlob(directory, blob);
2344
+ await readFromDirectories(directories, blob);
2029
2345
  available.push(blob);
2030
2346
  } catch {
2031
2347
  unavailable++;
@@ -2041,7 +2357,7 @@ const uploadBlobs = async (transport, manifest, directory, blobs) => {
2041
2357
  await uploadBlob({
2042
2358
  transport,
2043
2359
  runId: manifest.run.id,
2044
- directory,
2360
+ directories,
2045
2361
  blob,
2046
2362
  held: uploads.get(blob.sha256)
2047
2363
  });
@@ -2072,7 +2388,7 @@ const checkedReceipt = (receipt, manifest) => {
2072
2388
  if (receipt.runId !== manifest.run.id || receipt.canvasId !== manifest.run.canvasId || receipt.manifestDigest !== captureManifestDigest(manifest)) throw captureError("conflict", "This run committed a different manifest.", manifest.run.id);
2073
2389
  return receipt;
2074
2390
  };
2075
- const publishManifest = async (transport, manifest, directory) => {
2391
+ const publishManifest = async (transport, manifest, directory, blobDirectories = [directory]) => {
2076
2392
  const artifacts = selectedCaptures(manifest);
2077
2393
  if (typeof artifacts === "string") throw captureError("artifact", artifacts);
2078
2394
  const blobs = captureBlobs(artifacts);
@@ -2083,15 +2399,15 @@ const publishManifest = async (transport, manifest, directory) => {
2083
2399
  await writeCaptureJson(path.join(directory, "receipt.json"), receipt);
2084
2400
  return receipt;
2085
2401
  }
2086
- if (current.state === "collecting") await uploadBlobs(transport, manifest, directory, blobs);
2402
+ if (current.state === "collecting") await uploadBlobs(transport, manifest, blobDirectories, blobs);
2087
2403
  await transport.request("captureRun.seal", { manifest }, getCaptureRunOutputSchema);
2088
2404
  const receipt = checkedReceipt(await committedRun(transport, manifest.run.id), manifest);
2089
2405
  await writeCaptureJson(path.join(directory, "receipt.json"), receipt);
2090
2406
  return receipt;
2091
2407
  };
2092
- const publishCaptureManifest = async (transport, manifest, directory) => {
2408
+ const publishCaptureManifest = async (transport, manifest, directory, blobDirectories = [directory]) => {
2093
2409
  try {
2094
- return await publishManifest(transport, manifest, directory);
2410
+ return await publishManifest(transport, manifest, directory, blobDirectories);
2095
2411
  } catch (error) {
2096
2412
  if (error instanceof Error) throw Object.assign(error, { runId: manifest.run.id });
2097
2413
  throw captureError("transport", "Capture publication was not confirmed. Resume the same manifest.", manifest.run.id);
@@ -2232,24 +2548,49 @@ const createRun = (transport, input, directory) => {
2232
2548
  }
2233
2549
  };
2234
2550
  };
2551
+ const beginCaptureRun = async (transport, input) => {
2552
+ const request = beginCaptureRunInputSchema.parse({
2553
+ canvasId: input.canvas,
2554
+ destination: input.destination,
2555
+ title: input.title,
2556
+ context: input.context,
2557
+ revision: input.revision,
2558
+ compareTo: input.compareTo,
2559
+ source: input.source,
2560
+ runKey: input.runKey,
2561
+ participants: input.participants
2562
+ });
2563
+ const { run } = await transport.request("captureRun.begin", request, beginCaptureRunOutputSchema);
2564
+ const directory = input.directory ?? path.join(".enhance", "captures", run.id);
2565
+ await mkdir(directory, { recursive: true });
2566
+ await writeCaptureJson(path.join(directory, "run.json"), run);
2567
+ return createRun(transport, run, directory);
2568
+ };
2235
2569
  const createEnhance = (options) => {
2236
2570
  const transport = captureTransport(options);
2237
2571
  const get = async (runId) => transport.request("captureRun.get", { runId }, getCaptureRunOutputSchema, true);
2238
2572
  return { captures: {
2239
- begin: async (input) => {
2240
- const request = beginCaptureRunInputSchema.parse({
2241
- canvasId: input.canvas,
2242
- source: input.source,
2243
- runKey: input.runKey,
2244
- participants: input.participants
2245
- });
2246
- const { run } = await transport.request("captureRun.begin", request, beginCaptureRunOutputSchema);
2247
- const directory = input.directory ?? path.join(".enhance", "captures", run.id);
2248
- await mkdir(directory, { recursive: true });
2249
- await writeCaptureJson(path.join(directory, "run.json"), run);
2250
- return createRun(transport, run, directory);
2573
+ review: async (canvasId) => transport.request("captureRun.review", { canvasId }, captureReviewSchema.nullable(), true),
2574
+ decide: async (canvasId, verdict) => {
2575
+ await transport.request("captureRun.decide", {
2576
+ canvasId,
2577
+ verdict
2578
+ }, z.object({ accepted: z.literal(true) }));
2579
+ },
2580
+ reference: async (canvasId, name) => transport.request("captureRun.reference", {
2581
+ canvasId,
2582
+ name
2583
+ }, captureReferenceSchema.nullable(), true),
2584
+ promote: async (input) => transport.request("captureRun.promote", updateCaptureReferenceInputSchema.parse(input), captureReferenceSchema),
2585
+ publishManifests: async (paths) => {
2586
+ const manifest = mergeCaptureManifests(await Promise.all(paths.map(async (path) => readCaptureManifest(path))));
2587
+ if (typeof manifest === "string") throw captureError("artifact", manifest);
2588
+ const directory = path.dirname(paths[0] ?? ".");
2589
+ await writeCaptureJson(path.join(directory, "merged-manifest.json"), manifest);
2590
+ return publishCaptureManifest(transport, manifest, directory, paths.map((path$1) => path.dirname(path$1)));
2251
2591
  },
2252
- publishManifest: async (path$1) => publishCaptureManifest(transport, await readCaptureManifest(path$1), path.dirname(path$1)),
2592
+ begin: async (input) => beginCaptureRun(transport, input),
2593
+ publishManifest: async (path$2) => publishCaptureManifest(transport, await readCaptureManifest(path$2), path.dirname(path$2)),
2253
2594
  get
2254
2595
  } };
2255
2596
  };
@@ -2279,6 +2620,7 @@ const registerCapturesProgram = (program, dependencies) => {
2279
2620
  //#endregion
2280
2621
  //#region src/infrastructure/command-summaries.consts.ts
2281
2622
  const COMMAND_SUMMARIES = {
2623
+ "captureRun.review": "Read product review for a run canvas.",
2282
2624
  "canvas chats": "Chat history.",
2283
2625
  "canvas.createEditableFrame": "Make a screen editable.",
2284
2626
  "canvas.create": "Create a canvas.",
@@ -3135,7 +3477,7 @@ const main = async () => {
3135
3477
  const remote = createHttpRemoteAdapter(config.apiUrl, credentials, mutationKey);
3136
3478
  const cli = createCliProgram({
3137
3479
  apiUrl: config.apiUrl,
3138
- version: "0.1.33",
3480
+ version: "0.1.37",
3139
3481
  credentials,
3140
3482
  remote,
3141
3483
  mutationKey,