@enhance-eng/enhance 0.1.168 → 0.1.170

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 { $r as canvasAxisStyleProperties, C as PROCEDURE_DESCRIPTIONS, Ct as ROOT_FIELD, Dt as objectFieldNames, Et as isInputRecord, Ft as canvasReadInputSchema, Gt as hasCanvasReferenceScope, Jr as emptyCanvasSceneDocument$1, Kt as parseCanvasReference, Lt as canvasUpdateHtmlCapabilityInputSchema, Mr as saveCanvasDocumentOutputSchema, Nn as emptyFixtureDocument, Nr as wholeCanvasDocumentOutputSchema, Ot as quotedValue, Pn as withFixtureScreen, Pr as canvasOperationSchema$1, Qr as canvasAuthoredStyleDeclarations, St as canvasEditsSchema, Tt as inputProblemSummary, Ut as canvasReferenceRenderTarget, V as operationStatusInputSchema, Vr as canvasWorldBoundsSchema$1, Vt as assertCanvasReferenceNodes, Wt as fromCanvasReference, Yt as cliPathOf, Zr as canvasAuthoredLayoutValueOf, Zt as currentNodeIdStep, _ as CANVAS_UPDATE_HTML_INPUT_EXAMPLE, _n as startRecordingOutputSchema, a as createRouterShapeAdapter, b as ProcessExitError, bi as canvasSchema$1, c as toKebabCase, cn as CliError, ct as canvasRemoveCapabilityInputSchema, d as createMcpCapabilityDiscoveryAdapter, dn as appErrorSchema$1, f as toExitCode, fn as completeScreenOutputSchema, h as toPublishedExitTable, hn as completeRecordingOutputSchema, i as createLazyCapabilityCatalogAdapter, it as canvasRenderScopedInputSchema, jn as createOrganisationOutputSchema, mn as appendRecordingChunkOutputSchema, mr as canvasAgentActivityPhaseSchema$1, n as withCommandName, on as skillTextsFor, p as toFailurePayload, pn as createScreenOutputSchema, pr as beginCanvasActivityOutputSchema, pt as canvasFindInputSchema, qt as readStoredCanvasScene, r as toCanvasAuthoringResult, ri as canvasLayoutPriorityDeclarations, rr as canvasTextRunsOf, sn as PartialBatchError, t as withCommandInFailure, ti as canvasLayoutMainAxisOf, u as toSharedCapabilities, v as CAPABILITY_UUID_EXAMPLE, wt as inputProblemFields, x as OPTION_DESCRIPTIONS, y as createCapabilityPolicyAdapter } from "./cli-output-identity.lib-DMHqCPUz.mjs";
3
- import { A as canvasAngularGradientSvg, C as assertCanvasReferenceOperations, D as canvasLinearGradientSvg, E as canvasRadialGradientSvg, M as compareCanvasSortKeys, O as canvasFilterListCss, S as createCanvasActivityComposite, T as createAuthUseCase, _ as readCanvasReferenceScene, b as createEditCanvasComposite, c as createOauthLoopbackAdapter, d as isJsonValued, f as createCapabilityInvocationAdapter, g as createRenderFileAdapter, i as readCliEnvironment, j as canvasColorCss, k as canvasDiamondGradientSvg, l as toInputHelp, n as createMutationKeyAdapter, r as createHttpRemoteAdapter, s as readToolMachine, t as installZodMessages, u as withCapabilityNames, v as createWriteHtmlCanvasComposite, w as createRenderCanvasComposite, x as sceneAtVersion } from "./zod-messages.lib-T23QiUQO.mjs";
2
+ import { Br as canvasLayoutMainAxisOf, C as PROCEDURE_DESCRIPTIONS, Ct as ROOT_FIELD, Dt as objectFieldNames, Et as isInputRecord, Hr as canvasLayoutPriorityDeclarations, In as emptyFixtureDocument, Ir as canvasAuthoredLayoutValueOf, Ln as withFixtureScreen, Lr as canvasAuthoredStyleDeclarations, Mr as saveCanvasDocumentOutputSchema, Mt as fromCanvasReference, Nr as wholeCanvasDocumentOutputSchema, Nt as hasCanvasReferenceScope, Ot as quotedValue, Pn as createOrganisationOutputSchema, Pt as parseCanvasReference, Qt as cliPathOf, Rr as canvasAxisStyleProperties, St as canvasEditsSchema, Tt as inputProblemSummary, Ut as canvasUpdateHtmlCapabilityInputSchema, V as operationStatusInputSchema, Vt as canvasReadInputSchema, Yt as readStoredCanvasScene, _ as CANVAS_UPDATE_HTML_INPUT_EXAMPLE, _i as emptyCanvasSceneDocument$1, _n as appendRecordingChunkOutputSchema, _r as canvasAgentActivityPhaseSchema$1, a as createRouterShapeAdapter, b as ProcessExitError, bn as startRecordingOutputSchema, c as toKebabCase, ct as canvasRemoveCapabilityInputSchema, d as createMcpCapabilityDiscoveryAdapter, dn as CliError, en as currentNodeIdStep, f as toExitCode, gn as createScreenOutputSchema, gr as beginCanvasActivityOutputSchema, h as toPublishedExitTable, hn as completeScreenOutputSchema, i as createLazyCapabilityCatalogAdapter, it as canvasRenderScopedInputSchema, jt as canvasReferenceRenderTarget, kt as assertCanvasReferenceNodes, ln as skillTextsFor, mn as appErrorSchema$1, n as withCommandName, or as canvasTextRunsOf, p as toFailurePayload, pt as canvasFindInputSchema, r as toCanvasAuthoringResult, ri as canvasOperationSchema$1, t as withCommandInFailure, u as toSharedCapabilities, ui as canvasWorldBoundsSchema$1, un as PartialBatchError, v as CAPABILITY_UUID_EXAMPLE, vn as completeRecordingOutputSchema, wi as canvasSchema$1, wt as inputProblemFields, x as OPTION_DESCRIPTIONS, y as createCapabilityPolicyAdapter } from "./cli-output-identity.lib-CKns8qEG.mjs";
3
+ import { A as canvasAngularGradientSvg, C as sceneAtVersion, D as canvasLinearGradientSvg, E as canvasRadialGradientSvg, O as canvasFilterListCss, S as createCanvasActivityComposite, T as createAuthUseCase, _ as readCanvasReferenceScene, b as createEditCanvasComposite, c as createOauthLoopbackAdapter, d as isJsonValued, f as createCapabilityInvocationAdapter, g as createRenderFileAdapter, i as readCliEnvironment, j as canvasColorCss, k as canvasDiamondGradientSvg, l as toInputHelp, n as createMutationKeyAdapter, r as createHttpRemoteAdapter, s as readToolMachine, t as installZodMessages, u as withCapabilityNames, v as createWriteHtmlCanvasComposite, w as createRenderCanvasComposite, x as assertCanvasReferenceOperations } from "./zod-messages.lib-G2BtVFRk.mjs";
4
4
  import { t as toCapabilityInventory } from "./capability-inventory.mapper-DyYXyVBJ.mjs";
5
5
  import { t as createFileCredentialAdapter } from "./file-credential.adapter-CShGZcd5.mjs";
6
6
  import process from "node:process";
@@ -19,6 +19,14 @@ import { channel } from "node:diagnostics_channel";
19
19
  import { execFile } from "node:child_process";
20
20
  import { proxify } from "trpc-cli/dist/proxify.js";
21
21
 
22
+ //#region ../../packages/canvas-format/src/canvas-sort-key.lib.ts
23
+ /**
24
+ * Sibling order by sort key. Fractional keys compare by code unit, so "Zz" comes before "a0";
25
+ * locale collation would put them the other way round.
26
+ */
27
+ const compareCanvasSortKeys = (left, right) => left < right ? -1 : left > right ? 1 : 0;
28
+
29
+ //#endregion
22
30
  //#region ../../packages/contract/src/canvas/canvas-font-family.lib.ts
23
31
  const GENERIC_FAMILIES = /* @__PURE__ */ new Set([
24
32
  "-apple-system",
@@ -627,7 +635,7 @@ const authoringNumberFrom = (schema, value, option) => {
627
635
  const authoringBaseVersion = (value) => authoringNumberFrom(positiveIntegerSchema, value, "--base-version");
628
636
  const selectAuthoringToken = (input, value, isComposite) => {
629
637
  const parsed = uuidNullableSchema.safeParse(value ?? null);
630
- if (!parsed.success) throw new CliError("BAD_REQUEST", "--client-token must be a UUID.", "Mint one UUID and reuse it only when retrying the exact same command.");
638
+ if (!parsed.success) throw new CliError("BAD_REQUEST", "--client-token must be a UUID.", "Leave --client-token out: the tool makes one and prints it. Pass that one back only when retrying the exact same command.");
631
639
  input.mutationKey.select(parsed.data, isComposite);
632
640
  };
633
641
  const authoringMutationId = (input, purpose) => input.mutationKey.current("canvas.applyOperations", { purpose });
@@ -751,7 +759,7 @@ const baseVersionFrom = (value) => {
751
759
  };
752
760
  const selectMutationToken = (input, value) => {
753
761
  const parsed = z.uuid().nullable().safeParse(value ?? null);
754
- if (!parsed.success) throw new CliError("BAD_REQUEST", "--client-token must be a UUID.", "Mint one UUID and reuse it only when retrying this exact operation batch.");
762
+ if (!parsed.success) throw new CliError("BAD_REQUEST", "--client-token must be a UUID.", "Leave --client-token out: the tool makes one and prints it. Pass that one back only when retrying this exact operation batch.");
755
763
  input.mutationKey.select(parsed.data, false);
756
764
  return input.mutationKey.current("canvas.applyOperations", {});
757
765
  };
@@ -1805,7 +1813,7 @@ const recordingIdFrom = (nodeId) => {
1805
1813
  };
1806
1814
  const selectClientToken = (input, value) => {
1807
1815
  const clientToken = z.uuid().nullable().safeParse(value ?? null);
1808
- if (!clientToken.success) throw new CliError("BAD_REQUEST", "--client-token must be a UUID.", "Mint one UUID and reuse it only when retrying this exact render.");
1816
+ if (!clientToken.success) throw new CliError("BAD_REQUEST", "--client-token must be a UUID.", "Leave --client-token out: the tool makes one and prints it. Pass that one back only when retrying this exact render.");
1809
1817
  input.mutationKey.select(clientToken.data, false);
1810
1818
  return input.mutationKey.current("canvas.render.create", {});
1811
1819
  };
@@ -1879,7 +1887,7 @@ const registerCanvasProgram = (program, input) => {
1879
1887
  };
1880
1888
 
1881
1889
  //#endregion
1882
- //#region ../../packages/sdk/dist/stall-watch.lib-DPwEELHr.mjs
1890
+ //#region ../../packages/sdk/dist/stall-watch.lib-DGygK3yF.mjs
1883
1891
  const CAPTURE_METADATA_LENGTH = 200;
1884
1892
  const CAPTURE_FAILURE_LENGTH = 1e3;
1885
1893
  const CAPTURE_UPLOAD_BATCH_SIZE = 400;
@@ -3049,14 +3057,14 @@ z.object({
3049
3057
  message: z.string().min(1).max(MAX_PICTURE_FAILURE_LENGTH)
3050
3058
  })).max(20)
3051
3059
  });
3052
- const coordinate$1 = z.number();
3053
- const extent = z.number().nonnegative();
3060
+ const coordinate$2 = z.number();
3061
+ const extent$1 = z.number().nonnegative();
3054
3062
  /** A box in page coordinates. */
3055
3063
  const canvasOutlineBoxSchema = z.strictObject({
3056
- x: coordinate$1,
3057
- y: coordinate$1,
3058
- width: extent,
3059
- height: extent
3064
+ x: coordinate$2,
3065
+ y: coordinate$2,
3066
+ width: extent$1,
3067
+ height: extent$1
3060
3068
  });
3061
3069
  /** What a browser measured of one top layer: its own box, and how far its descendants paint. */
3062
3070
  const canvasOutlineMeasurementSchema = z.strictObject({
@@ -3987,225 +3995,15 @@ const canvasAdditionalStylePatchSchema = z.object({
3987
3995
  order: identifiers.optional(),
3988
3996
  empty: z.enum(["keep", "remove"]).optional()
3989
3997
  }).strict().refine((patch) => patch.set?.every((item) => patch.clear?.includes(item.id) !== true) ?? true, "a declaration cannot be set and cleared in the same patch");
3990
- const MAX_DESCRIPTION$1 = 2e3;
3991
- const MAX_OVERRIDE_VALUE = 1e3;
3992
- const canvasTextStyleTypographySchema = canvasTypographySchema.pick({
3993
- family: true,
3994
- fallbackFamilies: true,
3995
- size: true,
3996
- weight: true,
3997
- style: true,
3998
- variations: true,
3999
- opticalSize: true,
4000
- features: true,
4001
- lineHeight: true,
4002
- letterSpacing: true,
4003
- transform: true,
4004
- decoration: true,
4005
- paragraphSpacing: true,
4006
- paragraphIndent: true,
4007
- listSpacing: true,
4008
- hangingList: true,
4009
- hangingPunctuation: true,
4010
- verticalTrim: true,
4011
- wrapStyle: true
4012
- }).extend({ decoration: canvasTypographySchema.shape.decoration.omit({ blendMode: true }) }).strict();
4013
- const CANVAS_TEXT_STYLE_PROPERTIES = canvasTextStyleTypographySchema.keyof().options;
4014
- const canvasTextStyleSchema = z.object({
4015
- id: z.string().min(1),
4016
- name: z.string().trim().min(1),
4017
- description: z.string().max(MAX_DESCRIPTION$1),
4018
- sortKey: z.string().min(1).optional(),
4019
- sourceStyleId: z.string().min(1).optional(),
4020
- sourceCanvasId: z.uuid().optional(),
4021
- sourceRevision: z.number().int().positive().optional(),
4022
- typography: canvasTextStyleTypographySchema.extend({ listStyle: canvasTypographySchema.shape.listStyle }).transform((typography) => {
4023
- Reflect.deleteProperty(typography, "listStyle");
4024
- return typography;
4025
- })
4026
- }).strict().refine((style) => style.sourceCanvasId === void 0 || style.sourceStyleId !== void 0, {
4027
- message: "A source canvas belongs to a reference snapshot.",
4028
- path: ["sourceCanvasId"]
4029
- }).refine((style) => style.sourceRevision === void 0 || style.sourceCanvasId !== void 0 && style.sourceStyleId !== void 0, {
4030
- message: "A published revision belongs to a source style and canvas.",
4031
- path: ["sourceRevision"]
4032
- });
4033
- z.object({
4034
- id: canvasTextStyleSchema.shape.id,
4035
- position: z.enum([
4036
- "normal",
4037
- "subscript",
4038
- "superscript"
4039
- ]).optional(),
4040
- overrides: z.partialRecord(z.enum([
4041
- "fontWeight",
4042
- "fontStyle",
4043
- "fontVariationSettings",
4044
- "fontOpticalSizing",
4045
- "textDecorationLine",
4046
- "textDecorationStyle",
4047
- "textDecorationColor",
4048
- "textDecorationThickness",
4049
- "textUnderlineOffset",
4050
- "textDecorationSkipInk"
4051
- ]), z.union([z.string().max(MAX_OVERRIDE_VALUE), z.number()])).optional()
4052
- }).strict();
4053
- const fillsSchema = canvasPaintSchema.array().optional();
4054
- z.object({ fills: fillsSchema });
4055
- canvasTextParagraphSchema.pick({
4056
- paragraphSpacing: true,
4057
- paragraphIndent: true,
4058
- listSpacing: true,
4059
- wrapStyle: true
4060
- }).extend({
4061
- hangingPunctuation: canvasTypographySchema.shape.hangingPunctuation,
4062
- verticalTrim: canvasTypographySchema.shape.verticalTrim,
4063
- stroke: canvasTypographySchema.shape.stroke.nullable(),
4064
- decorationBlendMode: canvasTypographySchema.shape.decoration.shape.blendMode,
4065
- backgroundBlendMode: canvasBlendModeSchema.optional()
4066
- }).strip();
4067
- /**
4068
- * The two-phase upload, seen from the client. The bytes never pass through the API: it hands
4069
- * back a URL S3 will accept, and the client PUTs to it directly.
4070
- */
4071
- const signedUploadSchema = z.object({
4072
- url: z.url(),
4073
- expiresAt: z.iso.datetime(),
4074
- /** Signed into the URL, so a client that omits one gets a 403 from S3, not from us. */
4075
- headers: z.record(z.string(), z.string())
4076
- });
4077
- const signedDownloadSchema = z.object({
4078
- url: z.url(),
4079
- expiresAt: z.iso.datetime(),
4080
- bytes: z.number().int().min(0)
4081
- });
4082
- const CANVAS_ASSET_PATH_PREFIX = "/v1/canvas-assets/";
4083
- const CANVAS_IMAGE_CONTENT_TYPES = [
4084
- "image/avif",
4085
- "image/gif",
4086
- "image/jpeg",
4087
- "image/png",
4088
- "image/webp"
4089
- ];
4090
- /**
4091
- * An image the canvas image store may hold. Files people upload keep to the closed list above; an
4092
- * image a layer held inline is stored under whatever `image/*` type it has.
4093
- */
4094
- const canvasStoredImageContentTypeSchema = z.string().regex(/^image\/[a-z0-9.+-]+$/u);
4095
- z.object({
4096
- canvasId: z.uuid(),
4097
- contentType: z.enum(CANVAS_IMAGE_CONTENT_TYPES),
4098
- bytes: z.number().int().positive()
4099
- });
4100
- z.object({
4101
- assetId: z.uuid(),
4102
- path: z.string().startsWith("/v1/canvas-assets/"),
4103
- upload: signedUploadSchema
4104
- });
4105
- const canvasImageAssetPath = (canvasId, assetId) => `${CANVAS_ASSET_PATH_PREFIX}${encodeURIComponent(canvasId)}/${encodeURIComponent(assetId)}`;
4106
- const canvasImageIdentitySchema = z.tuple([z.uuid(), z.uuid()]);
4107
- const canvasImageAssetIdentityFromPath = (path) => {
4108
- if (!path.startsWith("/v1/canvas-assets/")) return null;
4109
- const identity = canvasImageIdentitySchema.safeParse(path.slice(18).split("/")).data;
4110
- return identity === void 0 ? null : {
4111
- canvasId: identity[0],
4112
- assetId: identity[1]
4113
- };
4114
- };
4115
- const CANVAS_FONT_CONTENT_TYPES = [
4116
- "font/ttf",
4117
- "font/otf",
4118
- "font/woff",
4119
- "font/woff2",
4120
- "font/collection"
4121
- ];
4122
- const canvasFontAssetIdentitySchema = z.object({
4123
- canvasId: z.uuid(),
4124
- sha256: z.string().regex(/^[a-f0-9]{64}$/u)
4125
- });
4126
- canvasFontAssetIdentitySchema.extend({ bytes: z.number().int().positive() }).extend({ contentType: z.enum(CANVAS_FONT_CONTENT_TYPES) });
4127
- z.object({ path: z.string().startsWith("/v1/canvas-assets/") }).extend({ upload: signedUploadSchema });
4128
- const canvasFontAssetPath = (canvasId, sha256) => `${CANVAS_ASSET_PATH_PREFIX}${encodeURIComponent(canvasId)}/fonts/${encodeURIComponent(sha256)}`;
4129
- z.object({
4130
- canvasId: z.uuid(),
4131
- sources: z.array(canvasFontAssetIdentitySchema).min(1)
4132
- });
4133
- z.object({ resources: z.array(z.object({
4134
- source: canvasFontAssetIdentitySchema,
4135
- path: z.string()
4136
- })) });
4137
- const MAX_FONT_WEIGHT = 1e3;
4138
- const FONT_CONTENT_TYPES = new Set(CANVAS_FONT_CONTENT_TYPES);
4139
- const isStoredContentType = (kind, contentType) => kind === "image" ? canvasStoredImageContentTypeSchema.safeParse(contentType).success : FONT_CONTENT_TYPES.has(contentType);
4140
- const canvasAssetUploadIdentitySchema = z.strictObject({
4141
- canvasId: z.uuid(),
4142
- clientToken: z.uuid()
4143
- });
4144
- z.discriminatedUnion("kind", [canvasAssetUploadIdentitySchema.extend({
4145
- kind: z.literal("image"),
4146
- contentType: z.enum(CANVAS_IMAGE_CONTENT_TYPES),
4147
- bytes: z.number().int().positive(),
4148
- sha256: z.string().regex(/^[a-f0-9]{64}$/u)
4149
- }), canvasAssetUploadIdentitySchema.extend({
4150
- kind: z.literal("font"),
4151
- contentType: z.enum(CANVAS_FONT_CONTENT_TYPES),
4152
- bytes: z.number().int().positive(),
4153
- sha256: z.string().regex(/^[a-f0-9]{64}$/u)
4154
- })]);
4155
- const canvasAssetMetadataSchema = z.discriminatedUnion("kind", [z.strictObject({
4156
- kind: z.literal("image"),
4157
- width: z.number().int().positive(),
4158
- height: z.number().int().positive()
4159
- }), z.strictObject({
4160
- kind: z.literal("font"),
4161
- family: z.string().min(1),
4162
- subfamily: z.string(),
4163
- style: z.enum([
4164
- "normal",
4165
- "italic",
4166
- "oblique"
4167
- ]),
4168
- minimumWeight: z.number().min(1).max(MAX_FONT_WEIGHT),
4169
- maximumWeight: z.number().min(1).max(MAX_FONT_WEIGHT)
4170
- }).refine((font) => font.minimumWeight <= font.maximumWeight, "Font weight bounds must be ordered.")]);
4171
- z.strictObject({
4172
- canvasId: z.uuid(),
4173
- clientToken: z.uuid(),
4174
- assetId: z.uuid(),
4175
- kind: z.enum(["image", "font"]),
4176
- contentType: z.string(),
4177
- bytes: z.number().int().positive(),
4178
- sha256: z.string().regex(/^[a-f0-9]{64}$/u),
4179
- path: z.string().startsWith("/v1/canvas-assets/"),
4180
- state: z.enum(["awaiting_upload", "ready"]),
4181
- metadata: canvasAssetMetadataSchema.nullable()
4182
- }).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.").safeExtend({ upload: signedUploadSchema.nullable() }).refine((asset) => asset.state === "awaiting_upload" === (asset.upload !== null), "Only pending uploads receive upload access.");
4183
- const SIDES$1 = [
4184
- "top",
4185
- "right",
4186
- "bottom",
4187
- "left"
4188
- ];
4189
- SIDES$1.map((side) => `padding-${side}`), SIDES$1.map((side) => `margin-${side}`);
4190
- const format = z.enum(["png", "jpeg"]);
4191
- const scale = z.number().positive();
4192
- const canvasExportSettingsSchema = z.strictObject({
4193
- format: format.optional(),
4194
- scale: scale.optional()
4195
- });
4196
- const canvasExportSettingsPatchSchema = z.strictObject({
4197
- format: format.nullable().optional(),
4198
- scale: scale.nullable().optional()
4199
- }).refine((patch) => patch.format !== void 0 || patch.scale !== void 0);
4200
- const coordinate = z.number();
4201
- const dimension = coordinate.nonnegative();
3998
+ const coordinate$1 = z.number();
3999
+ const dimension = coordinate$1.nonnegative();
4202
4000
  const MAX_ID_LENGTH = 200;
4203
4001
  const MIN_POLYGON_POINTS = 3;
4204
4002
  const identity$1 = z.string().min(1).max(MAX_ID_LENGTH);
4205
4003
  const path$1 = z.string().regex(/^[MmLlHhVvCcSsQqTtAaZzEe\d\s.,+-]*$/u);
4206
4004
  const canvasGeometryBoundsSchema = z.strictObject({
4207
- x: coordinate,
4208
- y: coordinate,
4005
+ x: coordinate$1,
4006
+ y: coordinate$1,
4209
4007
  width: dimension,
4210
4008
  height: dimension
4211
4009
  });
@@ -4258,37 +4056,116 @@ const canvasGeometrySchema = z.discriminatedUnion("kind", [
4258
4056
  }),
4259
4057
  canvasBooleanGeometrySchema
4260
4058
  ]);
4261
- const CANVAS_COMPOSITING_RETIRED = "Update Enhance: compositing is no longer supported. Use the isolation style or a mask group.";
4262
- const CANVAS_FORMAT_UPDATE_REQUIRED = "This change needs a newer version of Enhance. Refresh the editor, or update the Enhance plugin or command-line tool, then try again.";
4263
- const CANVAS_FORMAT_SERVER_UPDATING = "Enhance is being updated. Try again in a minute.";
4264
- /** Marks an issue whose message was written for whoever sent the request, so the API keeps it. */
4265
- const FOR_CALLER = { forCaller: true };
4266
- /**
4267
- * The format a writer was built for, as a plain whole number so tool schemas can describe it. Which
4268
- * writes that format may make is `refuseUnsafeWriterFormat`'s call.
4269
- */
4270
- const canvasDocumentFormatSchema = z.number({ error: CANVAS_FORMAT_UPDATE_REQUIRED }).int({ error: CANVAS_FORMAT_UPDATE_REQUIRED }).positive({ error: CANVAS_FORMAT_UPDATE_REQUIRED }).meta({
4271
- description: `The document format this client writes. The current format is ${String(15)}.`,
4272
- examples: [15]
4273
- });
4274
- /**
4275
- * Refuses a write its client's format could get wrong. A client whose format differs from the
4276
- * current one only in its number may still name changes, but a whole value it sends may lack
4277
- * fields added since, so that needs the current format.
4278
- */
4279
- const refuseUnsafeWriterFormat = (documentFormatVersion, writes, context) => {
4280
- const writer = canvasWriterFormat(documentFormatVersion);
4281
- if (writer === "current" || writer === "number-only" && writes === "names") return;
4282
- context.addIssue({
4283
- code: "custom",
4284
- path: ["documentFormatVersion"],
4285
- message: writer === "ahead" ? CANVAS_FORMAT_SERVER_UPDATING : CANVAS_FORMAT_UPDATE_REQUIRED,
4286
- params: FOR_CALLER,
4287
- input: documentFormatVersion
4288
- });
4289
- };
4290
- z.object({
4291
- signature: z.string().regex(/^[a-f0-9]{16}$/u),
4059
+ const canvasPropertySectionSchema = z.enum([
4060
+ "position",
4061
+ "layout",
4062
+ "clip",
4063
+ "cornerRadius",
4064
+ "blending",
4065
+ "typography",
4066
+ "nativeControl",
4067
+ "textDecoration",
4068
+ "fill",
4069
+ "outline",
4070
+ "textStroke",
4071
+ "border",
4072
+ "outerShadow",
4073
+ "innerShadow",
4074
+ "filters",
4075
+ "additionalStyles",
4076
+ "vector",
4077
+ "export",
4078
+ "source"
4079
+ ]);
4080
+ const format = z.enum(["png", "jpeg"]);
4081
+ const scale = z.number().positive();
4082
+ const canvasExportSettingsSchema = z.strictObject({
4083
+ format: format.optional(),
4084
+ scale: scale.optional()
4085
+ });
4086
+ const canvasExportSettingsPatchSchema = z.strictObject({
4087
+ format: format.nullable().optional(),
4088
+ scale: scale.nullable().optional()
4089
+ }).refine((patch) => patch.format !== void 0 || patch.scale !== void 0);
4090
+ /**
4091
+ * The two-phase upload, seen from the client. The bytes never pass through the API: it hands
4092
+ * back a URL S3 will accept, and the client PUTs to it directly.
4093
+ */
4094
+ const signedUploadSchema = z.object({
4095
+ url: z.url(),
4096
+ expiresAt: z.iso.datetime(),
4097
+ /** Signed into the URL, so a client that omits one gets a 403 from S3, not from us. */
4098
+ headers: z.record(z.string(), z.string())
4099
+ });
4100
+ const signedDownloadSchema = z.object({
4101
+ url: z.url(),
4102
+ expiresAt: z.iso.datetime(),
4103
+ bytes: z.number().int().min(0)
4104
+ });
4105
+ const CANVAS_ASSET_PATH_PREFIX = "/v1/canvas-assets/";
4106
+ const CANVAS_IMAGE_CONTENT_TYPES = [
4107
+ "image/avif",
4108
+ "image/gif",
4109
+ "image/jpeg",
4110
+ "image/png",
4111
+ "image/webp"
4112
+ ];
4113
+ /**
4114
+ * An image the canvas image store may hold. Files people upload keep to the closed list above; an
4115
+ * image a layer held inline is stored under whatever `image/*` type it has.
4116
+ */
4117
+ const canvasStoredImageContentTypeSchema = z.string().regex(/^image\/[a-z0-9.+-]+$/u);
4118
+ z.object({
4119
+ canvasId: z.uuid(),
4120
+ contentType: z.enum(CANVAS_IMAGE_CONTENT_TYPES),
4121
+ bytes: z.number().int().positive()
4122
+ });
4123
+ z.object({
4124
+ assetId: z.uuid(),
4125
+ path: z.string().startsWith("/v1/canvas-assets/"),
4126
+ upload: signedUploadSchema
4127
+ });
4128
+ const canvasImageAssetPath = (canvasId, assetId) => `${CANVAS_ASSET_PATH_PREFIX}${encodeURIComponent(canvasId)}/${encodeURIComponent(assetId)}`;
4129
+ const canvasImageIdentitySchema = z.tuple([z.uuid(), z.uuid()]);
4130
+ const canvasImageAssetIdentityFromPath = (path) => {
4131
+ if (!path.startsWith("/v1/canvas-assets/")) return null;
4132
+ const identity = canvasImageIdentitySchema.safeParse(path.slice(18).split("/")).data;
4133
+ return identity === void 0 ? null : {
4134
+ canvasId: identity[0],
4135
+ assetId: identity[1]
4136
+ };
4137
+ };
4138
+ const CANVAS_COMPOSITING_RETIRED = "Update Enhance: compositing is no longer supported. Use the isolation style or a mask group.";
4139
+ const CANVAS_FORMAT_UPDATE_REQUIRED = "This change needs a newer version of Enhance. Refresh the editor, or update the Enhance plugin or command-line tool, then try again.";
4140
+ const CANVAS_FORMAT_SERVER_UPDATING = "Enhance is being updated. Try again in a minute.";
4141
+ /** Marks an issue whose message was written for whoever sent the request, so the API keeps it. */
4142
+ const FOR_CALLER = { forCaller: true };
4143
+ /**
4144
+ * The format a writer was built for, as a plain whole number so tool schemas can describe it. Which
4145
+ * writes that format may make is `refuseUnsafeWriterFormat`'s call.
4146
+ */
4147
+ const canvasDocumentFormatSchema = z.number({ error: CANVAS_FORMAT_UPDATE_REQUIRED }).int({ error: CANVAS_FORMAT_UPDATE_REQUIRED }).positive({ error: CANVAS_FORMAT_UPDATE_REQUIRED }).meta({
4148
+ description: `The document format this client writes. The current format is ${String(15)}.`,
4149
+ examples: [15]
4150
+ });
4151
+ /**
4152
+ * Refuses a write its client's format could get wrong. A client whose format differs from the
4153
+ * current one only in its number may still name changes, but a whole value it sends may lack
4154
+ * fields added since, so that needs the current format.
4155
+ */
4156
+ const refuseUnsafeWriterFormat = (documentFormatVersion, writes, context) => {
4157
+ const writer = canvasWriterFormat(documentFormatVersion);
4158
+ if (writer === "current" || writer === "number-only" && writes === "names") return;
4159
+ context.addIssue({
4160
+ code: "custom",
4161
+ path: ["documentFormatVersion"],
4162
+ message: writer === "ahead" ? CANVAS_FORMAT_SERVER_UPDATING : CANVAS_FORMAT_UPDATE_REQUIRED,
4163
+ params: FOR_CALLER,
4164
+ input: documentFormatVersion
4165
+ });
4166
+ };
4167
+ z.object({
4168
+ signature: z.string().regex(/^[a-f0-9]{16}$/u),
4292
4169
  /** The captured picture of the page's text, inline as written or as its canvas image store path. */
4293
4170
  image: z.string().refine((image) => image.startsWith("data:image/jpeg;base64,") || canvasImageAssetIdentityFromPath(image) !== null),
4294
4171
  families: z.array(z.string().min(1)).min(1)
@@ -4371,6 +4248,109 @@ canvasSceneDocumentSchema.extend({
4371
4248
  nodes: z.record(z.string(), z.unknown()),
4372
4249
  relationships: z.record(z.string(), z.unknown())
4373
4250
  });
4251
+ const MAX_RENDER_MESSAGE_LENGTH$1 = 500;
4252
+ const MAX_RENDER_KIND_LENGTH = 100;
4253
+ /**
4254
+ * What a layer's box is: `placed` where the canvas draws the layer, `placed-before-transform` where
4255
+ * it draws the layer before the layer's own transform, `recorded` a size kept from when the layer
4256
+ * was made, for a layer the browser lays out.
4257
+ */
4258
+ const canvasBoxSourceSchema = z.enum([
4259
+ "placed",
4260
+ "placed-before-transform",
4261
+ "recorded"
4262
+ ]);
4263
+ /** Present only on a read that holds a `recorded` box. */
4264
+ const boxNoteSchema = z.string().min(1).optional();
4265
+ const canvasInspectNodeSummarySchema = z.object({
4266
+ id: z.string().min(1),
4267
+ label: z.string().max(MAX_RENDER_MESSAGE_LENGTH$1),
4268
+ kind: z.string().min(1).max(MAX_RENDER_KIND_LENGTH),
4269
+ parentId: z.string().min(1).nullable(),
4270
+ childCount: z.number().int().min(0),
4271
+ box: canvasSceneBoxSchema.nullable(),
4272
+ boxSource: canvasBoxSourceSchema.optional(),
4273
+ propertySections: z.array(canvasPropertySectionSchema)
4274
+ });
4275
+ z.object({ canvasId: z.uuid() });
4276
+ z.object({
4277
+ canvasId: z.uuid(),
4278
+ openUrl: z.url(),
4279
+ title: z.string().min(1),
4280
+ version: z.number().int().positive(),
4281
+ nodeCount: z.number().int().min(0),
4282
+ rootChildCount: z.number().int().min(0),
4283
+ bounds: canvasSceneBoxSchema.nullable(),
4284
+ kinds: z.record(z.string(), z.number().int().min(0)),
4285
+ boxNote: boxNoteSchema,
4286
+ next: z.array(z.string().min(1))
4287
+ });
4288
+ z.object({ canvasId: z.uuid() });
4289
+ z.object({
4290
+ canvasId: z.uuid(),
4291
+ version: z.number().int().positive(),
4292
+ nodes: z.array(canvasInspectNodeSummarySchema),
4293
+ boxNote: boxNoteSchema
4294
+ });
4295
+ z.object({
4296
+ canvasId: z.uuid(),
4297
+ nodeId: z.string().min(1)
4298
+ });
4299
+ z.object({
4300
+ canvasId: z.uuid(),
4301
+ version: z.number().int().positive(),
4302
+ node: canvasInspectNodeSummarySchema.extend({
4303
+ styles: z.record(z.string(), z.union([z.string(), z.number()])),
4304
+ layout: canvasNodeLayoutSchema.optional(),
4305
+ appearance: canvasAppearanceValuesSchema.optional(),
4306
+ geometry: canvasGeometrySchema.optional(),
4307
+ typography: canvasAuthoredTypographySchema.optional(),
4308
+ additionalStyles: canvasAdditionalStylesSchema.optional(),
4309
+ props: z.record(z.string(), z.unknown()),
4310
+ children: z.array(z.string().min(1))
4311
+ }),
4312
+ boxNote: boxNoteSchema,
4313
+ next: z.array(z.string().min(1))
4314
+ });
4315
+ const coordinate = z.number();
4316
+ const extent = z.number().positive();
4317
+ const placedBox = z.strictObject({
4318
+ x: coordinate,
4319
+ y: coordinate,
4320
+ width: extent,
4321
+ height: extent
4322
+ });
4323
+ /** Where the person who started the request was looking; a preference, never a camera command. */
4324
+ const canvasInitiatingViewHintSchema = z.strictObject({
4325
+ pageId: z.string().min(1),
4326
+ bounds: placedBox
4327
+ });
4328
+ /** How a new top-level screen or copied set is placed on its page. Omitted, positions stay as authored. */
4329
+ const canvasPlacementIntentSchema = z.discriminatedUnion("kind", [
4330
+ z.strictObject({
4331
+ kind: z.literal("auto"),
4332
+ view: canvasInitiatingViewHintSchema.optional()
4333
+ }),
4334
+ z.strictObject({
4335
+ kind: z.literal("near"),
4336
+ anchorNodeId: z.string().min(1),
4337
+ side: z.enum(["right", "below"])
4338
+ }),
4339
+ z.strictObject({
4340
+ kind: z.literal("explicit"),
4341
+ x: coordinate,
4342
+ y: coordinate
4343
+ })
4344
+ ]);
4345
+ /** Where a committed change put its roots, as saved at its own revision. */
4346
+ const canvasPlacementResultSchema = z.strictObject({
4347
+ pageId: z.string().min(1),
4348
+ bounds: placedBox,
4349
+ roots: z.array(z.strictObject({
4350
+ nodeId: z.string().min(1),
4351
+ box: placedBox
4352
+ })).min(1)
4353
+ });
4374
4354
  const temporaryIdSchema = z.string().min(1);
4375
4355
  const canvasConversionIssueSchema = z.object({
4376
4356
  code: z.enum([
@@ -4468,7 +4448,11 @@ const editableFrameInputBase = {
4468
4448
  };
4469
4449
  z.union([z.strictObject({
4470
4450
  ...editableFrameInputBase,
4471
- screenNodeId: z.string().min(1).describe("The screen layer to convert beside itself.")
4451
+ screenNodeId: z.string().min(1).describe("The screen layer to convert beside itself."),
4452
+ position: z.strictObject({
4453
+ x: z.number(),
4454
+ y: z.number()
4455
+ }).optional().describe("Where the editor measured room for the frame below its screen.")
4472
4456
  }), z.strictObject({
4473
4457
  ...editableFrameInputBase,
4474
4458
  capture: editableFrameCaptureSchema.describe("The stored page a new capture lands from, and the page its frame goes on.")
@@ -4485,7 +4469,9 @@ const createEditableFrameResultSchema = z.object({
4485
4469
  insertedNodeIds: z.array(z.string().min(1)),
4486
4470
  removedNodeIds: z.array(z.string().min(1)),
4487
4471
  boxes: z.record(z.string().min(1), canvasSceneBoxSchema),
4488
- affectedBounds: canvasSceneBoxSchema
4472
+ affectedBounds: canvasSceneBoxSchema,
4473
+ /** Where requested placement saved the root; absent when the request asked for none. */
4474
+ placement: canvasPlacementResultSchema.optional()
4489
4475
  });
4490
4476
  const RENDER_PHASES = [
4491
4477
  "queued",
@@ -4538,7 +4524,7 @@ const RENDER_WARNING_CODES = [
4538
4524
  "LAYOUT_FALLBACK",
4539
4525
  "DRAWN_APPROXIMATELY"
4540
4526
  ];
4541
- const MAX_RENDER_MESSAGE_LENGTH$1 = 500;
4527
+ const MAX_RENDER_MESSAGE_LENGTH = 500;
4542
4528
  const canvasRenderPixelLimitSchema = z.number().int().positive();
4543
4529
  const canvasWorldBoundsSchema = z.object({
4544
4530
  x: z.number(),
@@ -4610,13 +4596,13 @@ const canvasRenderFailureReasonSchema = z.enum(RENDER_FAILURE_REASONS);
4610
4596
  const canvasRenderWarningCodeSchema = z.enum(RENDER_WARNING_CODES);
4611
4597
  const canvasRenderWarningSchema = z.object({
4612
4598
  code: canvasRenderWarningCodeSchema,
4613
- message: z.string().min(1).max(MAX_RENDER_MESSAGE_LENGTH$1),
4599
+ message: z.string().min(1).max(MAX_RENDER_MESSAGE_LENGTH),
4614
4600
  sourceId: z.string().min(1).nullable()
4615
4601
  });
4616
4602
  const canvasRenderFailureSchema = z.object({
4617
4603
  reason: canvasRenderFailureReasonSchema,
4618
4604
  phase: canvasRenderPhaseSchema,
4619
- message: z.string().min(1).max(MAX_RENDER_MESSAGE_LENGTH$1),
4605
+ message: z.string().min(1).max(MAX_RENDER_MESSAGE_LENGTH),
4620
4606
  retryable: z.boolean(),
4621
4607
  sourceId: z.string().min(1).nullable()
4622
4608
  });
@@ -4765,11 +4751,20 @@ z.object({
4765
4751
  });
4766
4752
  const canvasWriteScopeSchema = z.object({ rootIds: z.array(z.string().min(1)) });
4767
4753
  const canvasConversionDestinationSchema = z.discriminatedUnion("kind", [
4768
- z.object({ kind: z.literal("adjacent") }),
4754
+ z.object({
4755
+ kind: z.literal("adjacent"),
4756
+ /** Where the page was measured to have room for the frame. Absent, stored boxes are searched. */
4757
+ position: z.strictObject({
4758
+ x: z.number(),
4759
+ y: z.number()
4760
+ }).optional()
4761
+ }),
4769
4762
  z.object({
4770
4763
  kind: z.literal("insert-children"),
4771
4764
  pageId: z.string().min(1).optional(),
4772
- targetNodeId: z.string().min(1)
4765
+ targetNodeId: z.string().min(1),
4766
+ /** World placement for a new top-level screen. Absent, the authored position stands. */
4767
+ placement: canvasPlacementIntentSchema.optional()
4773
4768
  }),
4774
4769
  z.object({
4775
4770
  kind: z.literal("replace"),
@@ -4884,7 +4879,9 @@ z.discriminatedUnion("state", [
4884
4879
  state: z.literal("ready"),
4885
4880
  jobId: z.uuid(),
4886
4881
  loadedVersion: z.number().int().positive(),
4887
- draft: canvasSubtreeDraftSchema
4882
+ draft: canvasSubtreeDraftSchema,
4883
+ /** Where measured placement put the draft's root, when the request asked for it. */
4884
+ placement: canvasSceneBoxSchema.optional()
4888
4885
  }),
4889
4886
  z.object({
4890
4887
  state: z.literal("failed"),
@@ -5256,6 +5253,69 @@ const canvasEditTextOperationSchema = z.object({
5256
5253
  history: canvasTextHistoryTargetSchema.optional(),
5257
5254
  source: canvasTextSourceSchema.optional()
5258
5255
  });
5256
+ const MAX_DESCRIPTION$1 = 2e3;
5257
+ const MAX_OVERRIDE_VALUE = 1e3;
5258
+ const canvasTextStyleTypographySchema = canvasTypographySchema.pick({
5259
+ family: true,
5260
+ fallbackFamilies: true,
5261
+ size: true,
5262
+ weight: true,
5263
+ style: true,
5264
+ variations: true,
5265
+ opticalSize: true,
5266
+ features: true,
5267
+ lineHeight: true,
5268
+ letterSpacing: true,
5269
+ transform: true,
5270
+ decoration: true,
5271
+ paragraphSpacing: true,
5272
+ paragraphIndent: true,
5273
+ listSpacing: true,
5274
+ hangingList: true,
5275
+ hangingPunctuation: true,
5276
+ verticalTrim: true,
5277
+ wrapStyle: true
5278
+ }).extend({ decoration: canvasTypographySchema.shape.decoration.omit({ blendMode: true }) }).strict();
5279
+ const CANVAS_TEXT_STYLE_PROPERTIES = canvasTextStyleTypographySchema.keyof().options;
5280
+ const canvasTextStyleSchema = z.object({
5281
+ id: z.string().min(1),
5282
+ name: z.string().trim().min(1),
5283
+ description: z.string().max(MAX_DESCRIPTION$1),
5284
+ sortKey: z.string().min(1).optional(),
5285
+ sourceStyleId: z.string().min(1).optional(),
5286
+ sourceCanvasId: z.uuid().optional(),
5287
+ sourceRevision: z.number().int().positive().optional(),
5288
+ typography: canvasTextStyleTypographySchema.extend({ listStyle: canvasTypographySchema.shape.listStyle }).transform((typography) => {
5289
+ Reflect.deleteProperty(typography, "listStyle");
5290
+ return typography;
5291
+ })
5292
+ }).strict().refine((style) => style.sourceCanvasId === void 0 || style.sourceStyleId !== void 0, {
5293
+ message: "A source canvas belongs to a reference snapshot.",
5294
+ path: ["sourceCanvasId"]
5295
+ }).refine((style) => style.sourceRevision === void 0 || style.sourceCanvasId !== void 0 && style.sourceStyleId !== void 0, {
5296
+ message: "A published revision belongs to a source style and canvas.",
5297
+ path: ["sourceRevision"]
5298
+ });
5299
+ z.object({
5300
+ id: canvasTextStyleSchema.shape.id,
5301
+ position: z.enum([
5302
+ "normal",
5303
+ "subscript",
5304
+ "superscript"
5305
+ ]).optional(),
5306
+ overrides: z.partialRecord(z.enum([
5307
+ "fontWeight",
5308
+ "fontStyle",
5309
+ "fontVariationSettings",
5310
+ "fontOpticalSizing",
5311
+ "textDecorationLine",
5312
+ "textDecorationStyle",
5313
+ "textDecorationColor",
5314
+ "textDecorationThickness",
5315
+ "textUnderlineOffset",
5316
+ "textDecorationSkipInk"
5317
+ ]), z.union([z.string().max(MAX_OVERRIDE_VALUE), z.number()])).optional()
5318
+ }).strict();
5259
5319
  const MAX_DESCRIPTION = 2e3;
5260
5320
  const MAX_TITLE = 200;
5261
5321
  const MAX_PAGE = 50;
@@ -5517,6 +5577,269 @@ createEditableFrameResultSchema.extend({
5517
5577
  operation: insertConvertedSubtreeOperationSchema,
5518
5578
  next: z.array(z.string().min(1))
5519
5579
  });
5580
+ /**
5581
+ * What each operation writes. `names` sets one plain value, places, removes, or merges a patch, so
5582
+ * values its client never knew stay as stored. `whole` brings a whole layer or replaces a whole
5583
+ * group of values, which a client that read the canvas in an older format may have stripped.
5584
+ */
5585
+ const CANVAS_OPERATION_WRITES = {
5586
+ insertConvertedSubtree: "whole",
5587
+ insertNode: "whole",
5588
+ insertText: "names",
5589
+ insertPrototype: "names",
5590
+ setPrototypeDeployment: "names",
5591
+ editText: "names",
5592
+ setText: "names",
5593
+ setBox: "names",
5594
+ setLabel: "names",
5595
+ setContainerKind: "names",
5596
+ setVisibility: "names",
5597
+ setLocked: "names",
5598
+ setConstraints: "names",
5599
+ setStyles: "names",
5600
+ patchExportSettings: "names",
5601
+ setAppearance: "names",
5602
+ setLayout: "whole",
5603
+ patchTypography: "names",
5604
+ setTypography: "whole",
5605
+ patchAdditionalStyles: "names",
5606
+ setAdditionalStyles: "whole",
5607
+ setArtworkColor: "whole",
5608
+ setTextStyleLibrary: "whole",
5609
+ patchFontLibrary: "names",
5610
+ setTextStyle: "whole",
5611
+ setGeometry: "whole",
5612
+ setProps: "whole",
5613
+ setParentage: "names",
5614
+ move: "names",
5615
+ remove: "names"
5616
+ };
5617
+ const nodeIdSchema$2 = canvasSceneNodeSchema.shape.id;
5618
+ const writableBoxSchema = canvasSceneBoxSchema.extend({
5619
+ width: z.number().positive(),
5620
+ height: z.number().positive()
5621
+ });
5622
+ const copiedNodeIdsSchema = z.record(nodeIdSchema$2, nodeIdSchema$2);
5623
+ /** A receipt stored before boxes said what they are holds none, so the source stays optional. */
5624
+ const canvasReceiptBoxSchema = canvasSceneBoxSchema.extend({ boxSource: canvasBoxSourceSchema.optional() });
5625
+ const canvasMutationRequestContextSchema = z.strictObject({
5626
+ fingerprint: z.string().regex(/^[a-f0-9]{64}$/u),
5627
+ revisionPolicy: z.enum(["strict", "rebase"]),
5628
+ copiedNodeIds: copiedNodeIdsSchema.optional()
5629
+ });
5630
+ z.object({
5631
+ canvasId: z.uuid(),
5632
+ mutationId: z.uuid(),
5633
+ documentFormatVersion: canvasDocumentFormatSchema,
5634
+ baseVersion: z.number().int().positive(),
5635
+ operations: z.array(canvasOperationSchema).min(1),
5636
+ requestContext: canvasMutationRequestContextSchema.optional(),
5637
+ writeScope: canvasWriteScopeSchema.optional()
5638
+ }).superRefine((input, context) => {
5639
+ refuseUnsafeWriterFormat(input.documentFormatVersion, input.operations.every((operation) => CANVAS_OPERATION_WRITES[operation.op] === "names") ? "names" : "whole", context);
5640
+ });
5641
+ const applyCanvasOperationsOutputSchema = z.object({
5642
+ canvasId: z.uuid(),
5643
+ mutationId: z.uuid(),
5644
+ previousVersion: z.number().int().positive(),
5645
+ version: z.number().int().positive(),
5646
+ operations: z.array(canvasOperationSchema),
5647
+ insertedNodeIds: z.array(nodeIdSchema$2),
5648
+ changedNodeIds: z.array(nodeIdSchema$2),
5649
+ removedNodeIds: z.array(nodeIdSchema$2),
5650
+ boxes: z.record(nodeIdSchema$2, canvasReceiptBoxSchema),
5651
+ affectedBounds: writableBoxSchema.nullable(),
5652
+ copiedNodeIds: copiedNodeIdsSchema.optional(),
5653
+ next: z.array(z.string().min(1))
5654
+ });
5655
+ z.strictObject({
5656
+ canvasId: z.uuid(),
5657
+ mutationId: z.uuid(),
5658
+ fingerprint: canvasMutationRequestContextSchema.shape.fingerprint
5659
+ });
5660
+ z.discriminatedUnion("state", [z.strictObject({ state: z.literal("not-found") }), z.strictObject({
5661
+ state: z.literal("committed"),
5662
+ /** `url` is the canvas's web address. An API older than the field answers without it. */
5663
+ result: applyCanvasOperationsOutputSchema.extend({ url: z.url().optional() })
5664
+ })]);
5665
+ const nodeId$3 = z.string().min(1);
5666
+ const nodeIds$1 = z.array(nodeId$3).min(1);
5667
+ /** An agent's small edits, in the order the API plans them. */
5668
+ const canvasAgentEditsSchema = z.array(z.discriminatedUnion("kind", [
5669
+ z.object({
5670
+ kind: z.literal("set_text"),
5671
+ nodeId: nodeId$3,
5672
+ text: z.string()
5673
+ }),
5674
+ z.object({
5675
+ kind: z.literal("set_styles"),
5676
+ nodeIds: nodeIds$1,
5677
+ styles: z.record(z.string(), z.union([
5678
+ z.string(),
5679
+ z.number(),
5680
+ z.null()
5681
+ ]))
5682
+ }),
5683
+ z.object({
5684
+ kind: z.literal("rename"),
5685
+ nodeId: nodeId$3,
5686
+ name: z.string().trim().min(1)
5687
+ }),
5688
+ z.object({
5689
+ kind: z.literal("duplicate"),
5690
+ nodeIds: nodeIds$1,
5691
+ parentId: nodeId$3.optional()
5692
+ }),
5693
+ z.object({
5694
+ kind: z.literal("move"),
5695
+ nodeId: nodeId$3,
5696
+ destination: z.discriminatedUnion("kind", [
5697
+ z.object({
5698
+ kind: z.literal("before"),
5699
+ nodeId: nodeId$3
5700
+ }),
5701
+ z.object({
5702
+ kind: z.literal("after"),
5703
+ nodeId: nodeId$3
5704
+ }),
5705
+ z.object({
5706
+ kind: z.literal("parent"),
5707
+ parentId: nodeId$3,
5708
+ index: z.number().int().nonnegative().optional()
5709
+ })
5710
+ ])
5711
+ })
5712
+ ])).min(1);
5713
+ z.strictObject({
5714
+ canvasId: z.uuid(),
5715
+ mutationId: z.uuid(),
5716
+ baseVersion: z.number().int().positive(),
5717
+ edits: canvasAgentEditsSchema,
5718
+ /** The prefix of copies' ids; the API makes one from the mutation id when it is left out. */
5719
+ idPrefix: z.string().min(1).optional(),
5720
+ /** A selection link's layers: the batch may change nothing outside them. */
5721
+ scopeNodeIds: z.array(nodeId$3).optional(),
5722
+ /** A selection link's page: the batch may name no layer on another page. */
5723
+ scopePageId: z.string().min(1).optional(),
5724
+ /** Whose words a refusal's next step is written in. */
5725
+ surface: z.enum(["cli", "mcp"]).optional(),
5726
+ fingerprint: canvasMutationRequestContextSchema.shape.fingerprint
5727
+ });
5728
+ const plannedNodeSchema = z.object({
5729
+ sourceId: z.string(),
5730
+ newId: z.string(),
5731
+ name: z.string(),
5732
+ component: z.string(),
5733
+ descendantIdMap: z.record(z.string(), z.string())
5734
+ });
5735
+ z.discriminatedUnion("outcome", [applyCanvasOperationsOutputSchema.extend({
5736
+ outcome: z.literal("committed"),
5737
+ /** True when the answer is the commit of an earlier identical request. */
5738
+ recovered: z.boolean(),
5739
+ duplicatedNodes: z.array(plannedNodeSchema).optional(),
5740
+ moves: z.array(z.object({
5741
+ nodeId: z.string(),
5742
+ parentId: z.string(),
5743
+ index: z.number().int()
5744
+ })).optional(),
5745
+ affectedParents: z.array(z.object({
5746
+ parentId: z.string(),
5747
+ children: z.array(z.string())
5748
+ })).optional()
5749
+ }), z.object({
5750
+ outcome: z.literal("no_op"),
5751
+ canvasId: z.uuid(),
5752
+ version: z.number().int().positive()
5753
+ })]);
5754
+ const fillsSchema = canvasPaintSchema.array().optional();
5755
+ z.object({ fills: fillsSchema });
5756
+ canvasTextParagraphSchema.pick({
5757
+ paragraphSpacing: true,
5758
+ paragraphIndent: true,
5759
+ listSpacing: true,
5760
+ wrapStyle: true
5761
+ }).extend({
5762
+ hangingPunctuation: canvasTypographySchema.shape.hangingPunctuation,
5763
+ verticalTrim: canvasTypographySchema.shape.verticalTrim,
5764
+ stroke: canvasTypographySchema.shape.stroke.nullable(),
5765
+ decorationBlendMode: canvasTypographySchema.shape.decoration.shape.blendMode,
5766
+ backgroundBlendMode: canvasBlendModeSchema.optional()
5767
+ }).strip();
5768
+ const CANVAS_FONT_CONTENT_TYPES = [
5769
+ "font/ttf",
5770
+ "font/otf",
5771
+ "font/woff",
5772
+ "font/woff2",
5773
+ "font/collection"
5774
+ ];
5775
+ const canvasFontAssetIdentitySchema = z.object({
5776
+ canvasId: z.uuid(),
5777
+ sha256: z.string().regex(/^[a-f0-9]{64}$/u)
5778
+ });
5779
+ canvasFontAssetIdentitySchema.extend({ bytes: z.number().int().positive() }).extend({ contentType: z.enum(CANVAS_FONT_CONTENT_TYPES) });
5780
+ z.object({ path: z.string().startsWith("/v1/canvas-assets/") }).extend({ upload: signedUploadSchema });
5781
+ const canvasFontAssetPath = (canvasId, sha256) => `${CANVAS_ASSET_PATH_PREFIX}${encodeURIComponent(canvasId)}/fonts/${encodeURIComponent(sha256)}`;
5782
+ z.object({
5783
+ canvasId: z.uuid(),
5784
+ sources: z.array(canvasFontAssetIdentitySchema).min(1)
5785
+ });
5786
+ z.object({ resources: z.array(z.object({
5787
+ source: canvasFontAssetIdentitySchema,
5788
+ path: z.string()
5789
+ })) });
5790
+ const MAX_FONT_WEIGHT = 1e3;
5791
+ const FONT_CONTENT_TYPES = new Set(CANVAS_FONT_CONTENT_TYPES);
5792
+ const isStoredContentType = (kind, contentType) => kind === "image" ? canvasStoredImageContentTypeSchema.safeParse(contentType).success : FONT_CONTENT_TYPES.has(contentType);
5793
+ const canvasAssetUploadIdentitySchema = z.strictObject({
5794
+ canvasId: z.uuid(),
5795
+ clientToken: z.uuid()
5796
+ });
5797
+ z.discriminatedUnion("kind", [canvasAssetUploadIdentitySchema.extend({
5798
+ kind: z.literal("image"),
5799
+ contentType: z.enum(CANVAS_IMAGE_CONTENT_TYPES),
5800
+ bytes: z.number().int().positive(),
5801
+ sha256: z.string().regex(/^[a-f0-9]{64}$/u)
5802
+ }), canvasAssetUploadIdentitySchema.extend({
5803
+ kind: z.literal("font"),
5804
+ contentType: z.enum(CANVAS_FONT_CONTENT_TYPES),
5805
+ bytes: z.number().int().positive(),
5806
+ sha256: z.string().regex(/^[a-f0-9]{64}$/u)
5807
+ })]);
5808
+ const canvasAssetMetadataSchema = z.discriminatedUnion("kind", [z.strictObject({
5809
+ kind: z.literal("image"),
5810
+ width: z.number().int().positive(),
5811
+ height: z.number().int().positive()
5812
+ }), z.strictObject({
5813
+ kind: z.literal("font"),
5814
+ family: z.string().min(1),
5815
+ subfamily: z.string(),
5816
+ style: z.enum([
5817
+ "normal",
5818
+ "italic",
5819
+ "oblique"
5820
+ ]),
5821
+ minimumWeight: z.number().min(1).max(MAX_FONT_WEIGHT),
5822
+ maximumWeight: z.number().min(1).max(MAX_FONT_WEIGHT)
5823
+ }).refine((font) => font.minimumWeight <= font.maximumWeight, "Font weight bounds must be ordered.")]);
5824
+ z.strictObject({
5825
+ canvasId: z.uuid(),
5826
+ clientToken: z.uuid(),
5827
+ assetId: z.uuid(),
5828
+ kind: z.enum(["image", "font"]),
5829
+ contentType: z.string(),
5830
+ bytes: z.number().int().positive(),
5831
+ sha256: z.string().regex(/^[a-f0-9]{64}$/u),
5832
+ path: z.string().startsWith("/v1/canvas-assets/"),
5833
+ state: z.enum(["awaiting_upload", "ready"]),
5834
+ metadata: canvasAssetMetadataSchema.nullable()
5835
+ }).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.").safeExtend({ upload: signedUploadSchema.nullable() }).refine((asset) => asset.state === "awaiting_upload" === (asset.upload !== null), "Only pending uploads receive upload access.");
5836
+ const SIDES$1 = [
5837
+ "top",
5838
+ "right",
5839
+ "bottom",
5840
+ "left"
5841
+ ];
5842
+ SIDES$1.map((side) => `padding-${side}`), SIDES$1.map((side) => `margin-${side}`);
5520
5843
  /** Reads retain unsupported documents; the write boundary validates the current scene format. */
5521
5844
  const canvasDocumentBlobSchema = z.record(z.string(), z.unknown());
5522
5845
  z.object({
@@ -5715,176 +6038,6 @@ z.object({
5715
6038
  text: z.string(),
5716
6039
  links: z.array(textLinkSchema).optional()
5717
6040
  });
5718
- const canvasPropertySectionSchema = z.enum([
5719
- "position",
5720
- "layout",
5721
- "clip",
5722
- "cornerRadius",
5723
- "blending",
5724
- "typography",
5725
- "nativeControl",
5726
- "textDecoration",
5727
- "fill",
5728
- "outline",
5729
- "textStroke",
5730
- "border",
5731
- "outerShadow",
5732
- "innerShadow",
5733
- "filters",
5734
- "additionalStyles",
5735
- "vector",
5736
- "export",
5737
- "source"
5738
- ]);
5739
- const MAX_RENDER_MESSAGE_LENGTH = 500;
5740
- const MAX_RENDER_KIND_LENGTH = 100;
5741
- /**
5742
- * What a layer's box is: `placed` where the canvas draws the layer, `placed-before-transform` where
5743
- * it draws the layer before the layer's own transform, `recorded` a size kept from when the layer
5744
- * was made, for a layer the browser lays out.
5745
- */
5746
- const canvasBoxSourceSchema = z.enum([
5747
- "placed",
5748
- "placed-before-transform",
5749
- "recorded"
5750
- ]);
5751
- /** Present only on a read that holds a `recorded` box. */
5752
- const boxNoteSchema = z.string().min(1).optional();
5753
- const canvasInspectNodeSummarySchema = z.object({
5754
- id: z.string().min(1),
5755
- label: z.string().max(MAX_RENDER_MESSAGE_LENGTH),
5756
- kind: z.string().min(1).max(MAX_RENDER_KIND_LENGTH),
5757
- parentId: z.string().min(1).nullable(),
5758
- childCount: z.number().int().min(0),
5759
- box: canvasSceneBoxSchema.nullable(),
5760
- boxSource: canvasBoxSourceSchema.optional(),
5761
- propertySections: z.array(canvasPropertySectionSchema)
5762
- });
5763
- z.object({ canvasId: z.uuid() });
5764
- z.object({
5765
- canvasId: z.uuid(),
5766
- openUrl: z.url(),
5767
- title: z.string().min(1),
5768
- version: z.number().int().positive(),
5769
- nodeCount: z.number().int().min(0),
5770
- rootChildCount: z.number().int().min(0),
5771
- bounds: canvasSceneBoxSchema.nullable(),
5772
- kinds: z.record(z.string(), z.number().int().min(0)),
5773
- boxNote: boxNoteSchema,
5774
- next: z.array(z.string().min(1))
5775
- });
5776
- z.object({ canvasId: z.uuid() });
5777
- z.object({
5778
- canvasId: z.uuid(),
5779
- version: z.number().int().positive(),
5780
- nodes: z.array(canvasInspectNodeSummarySchema),
5781
- boxNote: boxNoteSchema
5782
- });
5783
- z.object({
5784
- canvasId: z.uuid(),
5785
- nodeId: z.string().min(1)
5786
- });
5787
- z.object({
5788
- canvasId: z.uuid(),
5789
- version: z.number().int().positive(),
5790
- node: canvasInspectNodeSummarySchema.extend({
5791
- styles: z.record(z.string(), z.union([z.string(), z.number()])),
5792
- layout: canvasNodeLayoutSchema.optional(),
5793
- appearance: canvasAppearanceValuesSchema.optional(),
5794
- geometry: canvasGeometrySchema.optional(),
5795
- typography: canvasAuthoredTypographySchema.optional(),
5796
- additionalStyles: canvasAdditionalStylesSchema.optional(),
5797
- props: z.record(z.string(), z.unknown()),
5798
- children: z.array(z.string().min(1))
5799
- }),
5800
- boxNote: boxNoteSchema,
5801
- next: z.array(z.string().min(1))
5802
- });
5803
- /**
5804
- * What each operation writes. `names` sets one plain value, places, removes, or merges a patch, so
5805
- * values its client never knew stay as stored. `whole` brings a whole layer or replaces a whole
5806
- * group of values, which a client that read the canvas in an older format may have stripped.
5807
- */
5808
- const CANVAS_OPERATION_WRITES = {
5809
- insertConvertedSubtree: "whole",
5810
- insertNode: "whole",
5811
- insertText: "names",
5812
- insertPrototype: "names",
5813
- setPrototypeDeployment: "names",
5814
- editText: "names",
5815
- setText: "names",
5816
- setBox: "names",
5817
- setLabel: "names",
5818
- setContainerKind: "names",
5819
- setVisibility: "names",
5820
- setLocked: "names",
5821
- setConstraints: "names",
5822
- setStyles: "names",
5823
- patchExportSettings: "names",
5824
- setAppearance: "names",
5825
- setLayout: "whole",
5826
- patchTypography: "names",
5827
- setTypography: "whole",
5828
- patchAdditionalStyles: "names",
5829
- setAdditionalStyles: "whole",
5830
- setArtworkColor: "whole",
5831
- setTextStyleLibrary: "whole",
5832
- patchFontLibrary: "names",
5833
- setTextStyle: "whole",
5834
- setGeometry: "whole",
5835
- setProps: "whole",
5836
- setParentage: "names",
5837
- move: "names",
5838
- remove: "names"
5839
- };
5840
- const nodeIdSchema$2 = canvasSceneNodeSchema.shape.id;
5841
- const writableBoxSchema = canvasSceneBoxSchema.extend({
5842
- width: z.number().positive(),
5843
- height: z.number().positive()
5844
- });
5845
- const copiedNodeIdsSchema = z.record(nodeIdSchema$2, nodeIdSchema$2);
5846
- /** A receipt stored before boxes said what they are holds none, so the source stays optional. */
5847
- const canvasReceiptBoxSchema = canvasSceneBoxSchema.extend({ boxSource: canvasBoxSourceSchema.optional() });
5848
- const canvasMutationRequestContextSchema = z.strictObject({
5849
- fingerprint: z.string().regex(/^[a-f0-9]{64}$/u),
5850
- revisionPolicy: z.enum(["strict", "rebase"]),
5851
- copiedNodeIds: copiedNodeIdsSchema.optional()
5852
- });
5853
- z.object({
5854
- canvasId: z.uuid(),
5855
- mutationId: z.uuid(),
5856
- documentFormatVersion: canvasDocumentFormatSchema,
5857
- baseVersion: z.number().int().positive(),
5858
- operations: z.array(canvasOperationSchema).min(1),
5859
- requestContext: canvasMutationRequestContextSchema.optional(),
5860
- writeScope: canvasWriteScopeSchema.optional()
5861
- }).superRefine((input, context) => {
5862
- refuseUnsafeWriterFormat(input.documentFormatVersion, input.operations.every((operation) => CANVAS_OPERATION_WRITES[operation.op] === "names") ? "names" : "whole", context);
5863
- });
5864
- const applyCanvasOperationsOutputSchema = z.object({
5865
- canvasId: z.uuid(),
5866
- mutationId: z.uuid(),
5867
- previousVersion: z.number().int().positive(),
5868
- version: z.number().int().positive(),
5869
- operations: z.array(canvasOperationSchema),
5870
- insertedNodeIds: z.array(nodeIdSchema$2),
5871
- changedNodeIds: z.array(nodeIdSchema$2),
5872
- removedNodeIds: z.array(nodeIdSchema$2),
5873
- boxes: z.record(nodeIdSchema$2, canvasReceiptBoxSchema),
5874
- affectedBounds: writableBoxSchema.nullable(),
5875
- copiedNodeIds: copiedNodeIdsSchema.optional(),
5876
- next: z.array(z.string().min(1))
5877
- });
5878
- z.strictObject({
5879
- canvasId: z.uuid(),
5880
- mutationId: z.uuid(),
5881
- fingerprint: canvasMutationRequestContextSchema.shape.fingerprint
5882
- });
5883
- z.discriminatedUnion("state", [z.strictObject({ state: z.literal("not-found") }), z.strictObject({
5884
- state: z.literal("committed"),
5885
- /** `url` is the canvas's web address. An API older than the field answers without it. */
5886
- result: applyCanvasOperationsOutputSchema.extend({ url: z.url().optional() })
5887
- })]);
5888
6041
  const LIMITS = {
5889
6042
  nodes: 1e3,
5890
6043
  fields: 20,
@@ -6272,7 +6425,9 @@ const canvasDuplicatePreparationSchema = z.strictObject({
6272
6425
  destination: z.discriminatedUnion("kind", [z.strictObject({ kind: z.literal("native") }), z.strictObject({
6273
6426
  kind: z.literal("inside"),
6274
6427
  parentId: nodeId$2
6275
- })])
6428
+ })]),
6429
+ /** World placement for a set of top-level copies. Absent, the native copy offset stands. */
6430
+ placement: canvasPlacementIntentSchema.optional()
6276
6431
  });
6277
6432
  const canvasPreparationRequestSchema = z.discriminatedUnion("kind", [
6278
6433
  z.strictObject({
@@ -6835,6 +6990,10 @@ z.discriminatedUnion("purpose", [
6835
6990
  outputPrefix: z.string().min(1).max(MAX_STORAGE_KEY_LENGTH)
6836
6991
  })
6837
6992
  ]);
6993
+ const snapshotPlacementSchema = z.object({
6994
+ x: z.number(),
6995
+ y: z.number()
6996
+ });
6838
6997
  z.object({
6839
6998
  jobId: z.uuid(),
6840
6999
  loadedVersion: z.number().int().positive(),
@@ -6855,14 +7014,18 @@ z.object({
6855
7014
  viewport: z.object({
6856
7015
  width: z.number().int().positive(),
6857
7016
  height: z.number().int().positive()
6858
- })
7017
+ }),
7018
+ /** Where the page's search put the captured screen, at `loadedVersion`. */
7019
+ placement: snapshotPlacementSchema.optional()
6859
7020
  }).optional()
6860
7021
  });
6861
7022
  z.object({ accepted: z.literal(true) });
6862
7023
  z.object({
6863
7024
  jobId: z.uuid(),
6864
7025
  loadedVersion: z.number().int().positive(),
6865
- draft: canvasSubtreeDraftSchema
7026
+ draft: canvasSubtreeDraftSchema,
7027
+ /** The root's measured place at `loadedVersion`, for a request that asked to be placed. */
7028
+ placement: canvasSceneBoxSchema.optional()
6866
7029
  });
6867
7030
  z.object({ accepted: z.literal(true) });
6868
7031
  z.object({
@@ -6875,7 +7038,9 @@ z.object({
6875
7038
  viewport: z.object({
6876
7039
  width: z.number().int().positive(),
6877
7040
  height: z.number().int().positive()
6878
- })
7041
+ }),
7042
+ /** Where the editor's search for a capture below this recording puts the screen. */
7043
+ placement: snapshotPlacementSchema.optional()
6879
7044
  });
6880
7045
  z.object({
6881
7046
  jobId: z.uuid(),
@@ -7767,7 +7932,11 @@ const desktopRequestSchema = z.object({
7767
7932
  const desktopMutationIntentSchema = z.object({
7768
7933
  mutationId: id$2,
7769
7934
  canvasId: id$2,
7770
- procedure: z.enum(["canvas.applyOperations", "canvas.render.importSource"]),
7935
+ procedure: z.enum([
7936
+ "canvas.applyOperations",
7937
+ "canvas.render.importSource",
7938
+ "canvas.applyEdits"
7939
+ ]),
7771
7940
  input: z.record(z.string(), z.unknown()),
7772
7941
  state: z.enum([
7773
7942
  "recorded",
@@ -8325,7 +8494,9 @@ z.object({
8325
8494
  z.object({});
8326
8495
  z.object({
8327
8496
  items: z.array(agentTokenSchema),
8328
- isConnected: z.boolean()
8497
+ isConnected: z.boolean(),
8498
+ /** True once any agent credential of this person was ever used, even if all are now revoked. */
8499
+ hasEverConnected: z.boolean()
8329
8500
  });
8330
8501
  z.object({ tokenId: z.uuid() });
8331
8502
  z.object({
@@ -8338,6 +8509,44 @@ z.discriminatedUnion("method", [z.object({ method: z.literal("token") }), z.obje
8338
8509
  clientId: z.string().min(1),
8339
8510
  scope: z.literal("openid")
8340
8511
  })]);
8512
+ const onboardingStepIdSchema = z.enum([
8513
+ "connect_agent",
8514
+ "first_agent_work",
8515
+ "comment",
8516
+ "share_comments"
8517
+ ]);
8518
+ /** One person's preferences for one hint. `isSnoozed` is worked out with the API's clock. */
8519
+ const onboardingStepStateSchema = z.object({
8520
+ isAcknowledged: z.boolean(),
8521
+ maybeLaterCount: z.number().int().min(0),
8522
+ snoozedUntil: z.iso.datetime().nullable(),
8523
+ isSnoozed: z.boolean(),
8524
+ isStopped: z.boolean(),
8525
+ automaticShowCount: z.number().int().min(0),
8526
+ lastPresentationId: z.uuid().nullable()
8527
+ });
8528
+ z.strictObject({});
8529
+ z.object({
8530
+ hasCommented: z.boolean(),
8531
+ hasCopiedCanvasLink: z.boolean(),
8532
+ steps: z.object({
8533
+ connect_agent: onboardingStepStateSchema,
8534
+ first_agent_work: onboardingStepStateSchema,
8535
+ comment: onboardingStepStateSchema,
8536
+ share_comments: onboardingStepStateSchema
8537
+ })
8538
+ });
8539
+ z.strictObject({
8540
+ stepId: onboardingStepIdSchema,
8541
+ choice: z.enum(["got_it", "maybe_later"])
8542
+ });
8543
+ z.strictObject({
8544
+ stepId: onboardingStepIdSchema,
8545
+ presentationId: z.uuid()
8546
+ });
8547
+ z.object({ automaticShowNumber: z.number().int().min(1) });
8548
+ z.strictObject({});
8549
+ z.object({ hasCopiedCanvasLink: z.literal(true) });
8341
8550
  const personSchema = z.object({
8342
8551
  id: z.uuid(),
8343
8552
  preparedCanvasId: z.uuid(),
@@ -10505,7 +10714,7 @@ const startStallWatch = (caller, idleMs = STALL_MS) => {
10505
10714
  };
10506
10715
 
10507
10716
  //#endregion
10508
- //#region ../../packages/sdk/dist/capture-client.client-BSIO1VRh.mjs
10717
+ //#region ../../packages/sdk/dist/capture-client.client-BkUyb4Kt.mjs
10509
10718
  const line = (text) => `Enhance: ${text}\n`;
10510
10719
  /** A left-out capture by its journey and step, or by its test when it could not be read at all. */
10511
10720
  const leftOutName = (leftOut, attempts) => {
@@ -11419,7 +11628,7 @@ const prepareMutation = (command, commandPath, procedurePath, input) => {
11419
11628
  command.hook("preAction", (actionCommand) => {
11420
11629
  const candidate = actionCommand.getOptionValue("clientToken");
11421
11630
  const parsed = z.uuid().nullable().safeParse(candidate ?? null);
11422
- if (!parsed.success) throw new CliError("BAD_REQUEST", "--client-token must be a UUID.", "Mint one UUID and reuse it only when retrying this exact command.");
11631
+ if (!parsed.success) throw new CliError("BAD_REQUEST", "--client-token must be a UUID.", "Leave --client-token out: the tool makes one and prints it. Pass that one back only when retrying this exact command.");
11423
11632
  input.mutationKey.select(parsed.data, commandPath[0] === "fixture");
11424
11633
  });
11425
11634
  };
@@ -12134,7 +12343,7 @@ const registerRecordingProgram = (program, input) => {
12134
12343
  recording.command("snapshot").description("Persist one visually accepted recording moment as an ordinary screen and frame.").requiredOption("--canvas <url-or-id>", "Canvas URL or UUID containing the recording.").requiredOption("--recording-id <uuid>", "Recording UUID returned by recording list.").requiredOption("--at-ms <integer>", "Accepted recording timestamp in milliseconds.").option("--timeout-ms <integer>", "Local polling deadline in milliseconds.", "120000").option("--client-token <uuid>", "Stable UUID to reuse only when retrying this exact snapshot.").addHelpText("after", "\nPreview first: canvas render --node-id rec_<recording-uuid> --at-ms <integer>, then inspect its PNG. This command persists the accepted moment.\n").action(async (options) => {
12135
12344
  const token = z.uuid().nullable().safeParse(options.clientToken ?? null);
12136
12345
  const recordingId = z.uuid().safeParse(options.recordingId);
12137
- if (!token.success || !recordingId.success) throw new CliError("BAD_REQUEST", "The recording id or client token is not a UUID.", "Use the recording id from `recording list`; mint one client token per accepted moment.");
12346
+ if (!token.success || !recordingId.success) throw new CliError("BAD_REQUEST", "The recording id or client token is not a UUID.", "Use the recording id from `recording list`, and leave --client-token out for each accepted moment: the tool makes one.");
12138
12347
  input.output.result(await input.invocation.invoke({
12139
12348
  capability: input.catalog.one("recording.snapshot"),
12140
12349
  arguments: {
@@ -12688,7 +12897,7 @@ const main = async () => {
12688
12897
  const remote = createHttpRemoteAdapter(config.apiUrl, credentials, mutationKey);
12689
12898
  const cli = createCliProgram({
12690
12899
  apiUrl: config.apiUrl,
12691
- version: "0.1.168",
12900
+ version: "0.1.170",
12692
12901
  credentials,
12693
12902
  remote,
12694
12903
  mutationKey,