@enhance-eng/enhance 0.1.168 → 0.1.171

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 { At as quotedValue, Bn as createOrganisationOutputSchema, C as OPTION_DESCRIPTIONS, Ci as emptyCanvasSceneDocument$1, Cn as appendRecordingChunkOutputSchema, Cr as canvasAgentActivityPhaseSchema$1, Dt as inputProblemSummary, En as startRecordingOutputSchema, Et as inputProblemFields, Ft as hasCanvasReferenceScope, Gt as canvasUpdateHtmlCapabilityInputSchema, Hn as emptyFixtureDocument, Hr as canvasAuthoredLayoutValueOf, It as parseCanvasReference, Jr as canvasLayoutPriorityDeclarations, Kr as canvasLayoutMainAxisOf, Nt as canvasReferenceRenderTarget, Ot as isInputRecord, Pt as fromCanvasReference, Rr as saveCanvasDocumentOutputSchema, S as ProcessExitError, Sn as createScreenOutputSchema, Sr as beginCanvasActivityOutputSchema, T as PROCEDURE_DESCRIPTIONS, Tt as ROOT_FIELD, U as operationStatusInputSchema, Un as withFixtureScreen, Ur as canvasAuthoredStyleDeclarations, Ut as canvasReadInputSchema, Wr as canvasAxisStyleProperties, Zt as readStoredCanvasScene, _ as toPublishedExitTable, _n as CliError, a as createRouterShapeAdapter, b as CAPABILITY_UUID_EXAMPLE, bn as appErrorSchema$1, c as toKebabCase, dn as pointOfUseText, en as cliPathOf, f as toSharedCapabilities, fr as canvasTextRunsOf, gi as canvasWorldBoundsSchema$1, gn as skillTextsFor, h as toFailurePayload, ht as canvasFindInputSchema, i as createLazyCapabilityCatalogAdapter, ji as canvasSchema$1, jt as assertCanvasReferenceNodes, kt as objectFieldNames, l as GUIDE_TOPICS, li as canvasOperationSchema$1, ln as PartialBatchError, m as toExitCode, n as withCommandName, nn as currentNodeIdStep, ot as canvasRenderScopedInputSchema, p as createMcpCapabilityDiscoveryAdapter, r as toCanvasAuthoringResult, t as withCommandInFailure, u as GUIDE_TOPIC_NAMES, un as loadGuideLineFor, ut as canvasRemoveCapabilityInputSchema, wn as completeRecordingOutputSchema, wt as canvasEditsSchema, x as createCapabilityPolicyAdapter, xn as completeScreenOutputSchema, y as CANVAS_UPDATE_HTML_INPUT_EXAMPLE, zr as wholeCanvasDocumentOutputSchema } from "./cli-output-identity.lib-BsDqFLVA.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-B8yowT7b.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
  };
@@ -825,11 +833,15 @@ const configureUpdate = (work, input) => {
825
833
  });
826
834
  };
827
835
  const configureFinish = (canvas, input) => {
828
- canvas.command("finish-working-on-nodes").description("End visible agent activity.").requiredOption("--canvas <url-or-id>", "Canvas URL or UUID.").requiredOption("--activity-id <uuid>", "Lease id returned by canvas work begin.").action(async (options) => {
829
- if (!await createCanvasActivityComposite(input.remote).finish(fromCanvasReference(options.canvas), authoringUuidSchema.parse(options.activityId))) throw new CliError("NOT_FOUND", "The activity could not be finished.", "It may already have expired; run canvas work begin for new work.");
836
+ canvas.command("finish-working-on-nodes").description("Say you have finished: end your mark on the canvas, or narrow it.").requiredOption("--canvas <url-or-id>", "Canvas URL or UUID.").option("--node-ids <ids>", "Comma-separated screens you finished; leave out when you have finished on this canvas.").option("--activity-id <uuid>", "A lease id from canvas work begin; leave out for your own.").action(async (options) => {
837
+ const ended = await createCanvasActivityComposite(input.remote).finish({
838
+ canvasId: fromCanvasReference(options.canvas),
839
+ activityId: options.activityId === void 0 ? void 0 : authoringUuidSchema.parse(options.activityId),
840
+ nodeIds: nodeIdsFrom(options.nodeIds)
841
+ });
830
842
  input.output.result({
831
- ended: true,
832
- activityId: options.activityId
843
+ ...ended,
844
+ ...ended.outcome === "nothing-live" && { note: "Nothing was live on this canvas." }
833
845
  });
834
846
  });
835
847
  };
@@ -1805,7 +1817,7 @@ const recordingIdFrom = (nodeId) => {
1805
1817
  };
1806
1818
  const selectClientToken = (input, value) => {
1807
1819
  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.");
1820
+ 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
1821
  input.mutationKey.select(clientToken.data, false);
1810
1822
  return input.mutationKey.current("canvas.render.create", {});
1811
1823
  };
@@ -1879,7 +1891,7 @@ const registerCanvasProgram = (program, input) => {
1879
1891
  };
1880
1892
 
1881
1893
  //#endregion
1882
- //#region ../../packages/sdk/dist/stall-watch.lib-DPwEELHr.mjs
1894
+ //#region ../../packages/sdk/dist/stall-watch.lib-DwUtOrzm.mjs
1883
1895
  const CAPTURE_METADATA_LENGTH = 200;
1884
1896
  const CAPTURE_FAILURE_LENGTH = 1e3;
1885
1897
  const CAPTURE_UPLOAD_BATCH_SIZE = 400;
@@ -3049,14 +3061,14 @@ z.object({
3049
3061
  message: z.string().min(1).max(MAX_PICTURE_FAILURE_LENGTH)
3050
3062
  })).max(20)
3051
3063
  });
3052
- const coordinate$1 = z.number();
3053
- const extent = z.number().nonnegative();
3064
+ const coordinate$2 = z.number();
3065
+ const extent$1 = z.number().nonnegative();
3054
3066
  /** A box in page coordinates. */
3055
3067
  const canvasOutlineBoxSchema = z.strictObject({
3056
- x: coordinate$1,
3057
- y: coordinate$1,
3058
- width: extent,
3059
- height: extent
3068
+ x: coordinate$2,
3069
+ y: coordinate$2,
3070
+ width: extent$1,
3071
+ height: extent$1
3060
3072
  });
3061
3073
  /** What a browser measured of one top layer: its own box, and how far its descendants paint. */
3062
3074
  const canvasOutlineMeasurementSchema = z.strictObject({
@@ -3274,6 +3286,23 @@ z.object({ canvasId: z.uuid() });
3274
3286
  z.object({ lastViewedAt: z.iso.datetime().nullable() });
3275
3287
  z.object({ canvasId: z.uuid() });
3276
3288
  z.object({ canvasId: z.uuid() });
3289
+ z.object({
3290
+ canvasId: z.uuid(),
3291
+ activityId: z.uuid().optional(),
3292
+ nodeIds: z.array(z.string().min(1)).max(100).default([])
3293
+ });
3294
+ z.discriminatedUnion("outcome", [
3295
+ z.object({
3296
+ outcome: z.literal("ended"),
3297
+ activityId: z.uuid()
3298
+ }),
3299
+ z.object({
3300
+ outcome: z.literal("narrowed"),
3301
+ activityId: z.uuid(),
3302
+ remainingNodeIds: z.array(z.string().min(1)).min(1)
3303
+ }),
3304
+ z.object({ outcome: z.literal("nothing-live") })
3305
+ ]);
3277
3306
  const unsafeStyleValue = /javascript|vbscript|data\s*:\s*text\/html|expression\s*\(|@import/iu;
3278
3307
  const canvasCssValueSchema = z.string().refine((value) => !unsafeStyleValue.test(value), "unsafe CSS value");
3279
3308
  const canvasNumberSchema = z.number();
@@ -3987,225 +4016,15 @@ const canvasAdditionalStylePatchSchema = z.object({
3987
4016
  order: identifiers.optional(),
3988
4017
  empty: z.enum(["keep", "remove"]).optional()
3989
4018
  }).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();
4019
+ const coordinate$1 = z.number();
4020
+ const dimension = coordinate$1.nonnegative();
4202
4021
  const MAX_ID_LENGTH = 200;
4203
4022
  const MIN_POLYGON_POINTS = 3;
4204
4023
  const identity$1 = z.string().min(1).max(MAX_ID_LENGTH);
4205
4024
  const path$1 = z.string().regex(/^[MmLlHhVvCcSsQqTtAaZzEe\d\s.,+-]*$/u);
4206
4025
  const canvasGeometryBoundsSchema = z.strictObject({
4207
- x: coordinate,
4208
- y: coordinate,
4026
+ x: coordinate$1,
4027
+ y: coordinate$1,
4209
4028
  width: dimension,
4210
4029
  height: dimension
4211
4030
  });
@@ -4258,26 +4077,105 @@ const canvasGeometrySchema = z.discriminatedUnion("kind", [
4258
4077
  }),
4259
4078
  canvasBooleanGeometrySchema
4260
4079
  ]);
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);
4080
+ const canvasPropertySectionSchema = z.enum([
4081
+ "position",
4082
+ "layout",
4083
+ "clip",
4084
+ "cornerRadius",
4085
+ "blending",
4086
+ "typography",
4087
+ "nativeControl",
4088
+ "textDecoration",
4089
+ "fill",
4090
+ "outline",
4091
+ "textStroke",
4092
+ "border",
4093
+ "outerShadow",
4094
+ "innerShadow",
4095
+ "filters",
4096
+ "additionalStyles",
4097
+ "vector",
4098
+ "export",
4099
+ "source"
4100
+ ]);
4101
+ const format = z.enum(["png", "jpeg"]);
4102
+ const scale = z.number().positive();
4103
+ const canvasExportSettingsSchema = z.strictObject({
4104
+ format: format.optional(),
4105
+ scale: scale.optional()
4106
+ });
4107
+ const canvasExportSettingsPatchSchema = z.strictObject({
4108
+ format: format.nullable().optional(),
4109
+ scale: scale.nullable().optional()
4110
+ }).refine((patch) => patch.format !== void 0 || patch.scale !== void 0);
4111
+ /**
4112
+ * The two-phase upload, seen from the client. The bytes never pass through the API: it hands
4113
+ * back a URL S3 will accept, and the client PUTs to it directly.
4114
+ */
4115
+ const signedUploadSchema = z.object({
4116
+ url: z.url(),
4117
+ expiresAt: z.iso.datetime(),
4118
+ /** Signed into the URL, so a client that omits one gets a 403 from S3, not from us. */
4119
+ headers: z.record(z.string(), z.string())
4120
+ });
4121
+ const signedDownloadSchema = z.object({
4122
+ url: z.url(),
4123
+ expiresAt: z.iso.datetime(),
4124
+ bytes: z.number().int().min(0)
4125
+ });
4126
+ const CANVAS_ASSET_PATH_PREFIX = "/v1/canvas-assets/";
4127
+ const CANVAS_IMAGE_CONTENT_TYPES = [
4128
+ "image/avif",
4129
+ "image/gif",
4130
+ "image/jpeg",
4131
+ "image/png",
4132
+ "image/webp"
4133
+ ];
4134
+ /**
4135
+ * An image the canvas image store may hold. Files people upload keep to the closed list above; an
4136
+ * image a layer held inline is stored under whatever `image/*` type it has.
4137
+ */
4138
+ const canvasStoredImageContentTypeSchema = z.string().regex(/^image\/[a-z0-9.+-]+$/u);
4139
+ z.object({
4140
+ canvasId: z.uuid(),
4141
+ contentType: z.enum(CANVAS_IMAGE_CONTENT_TYPES),
4142
+ bytes: z.number().int().positive()
4143
+ });
4144
+ z.object({
4145
+ assetId: z.uuid(),
4146
+ path: z.string().startsWith("/v1/canvas-assets/"),
4147
+ upload: signedUploadSchema
4148
+ });
4149
+ const canvasImageAssetPath = (canvasId, assetId) => `${CANVAS_ASSET_PATH_PREFIX}${encodeURIComponent(canvasId)}/${encodeURIComponent(assetId)}`;
4150
+ const canvasImageIdentitySchema = z.tuple([z.uuid(), z.uuid()]);
4151
+ const canvasImageAssetIdentityFromPath = (path) => {
4152
+ if (!path.startsWith("/v1/canvas-assets/")) return null;
4153
+ const identity = canvasImageIdentitySchema.safeParse(path.slice(18).split("/")).data;
4154
+ return identity === void 0 ? null : {
4155
+ canvasId: identity[0],
4156
+ assetId: identity[1]
4157
+ };
4158
+ };
4159
+ const CANVAS_COMPOSITING_RETIRED = "Update Enhance: compositing is no longer supported. Use the isolation style or a mask group.";
4160
+ 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.";
4161
+ const CANVAS_FORMAT_SERVER_UPDATING = "Enhance is being updated. Try again in a minute.";
4162
+ /** Marks an issue whose message was written for whoever sent the request, so the API keeps it. */
4163
+ const FOR_CALLER = { forCaller: true };
4164
+ /**
4165
+ * The format a writer was built for, as a plain whole number so tool schemas can describe it. Which
4166
+ * writes that format may make is `refuseUnsafeWriterFormat`'s call.
4167
+ */
4168
+ const canvasDocumentFormatSchema = z.number({ error: CANVAS_FORMAT_UPDATE_REQUIRED }).int({ error: CANVAS_FORMAT_UPDATE_REQUIRED }).positive({ error: CANVAS_FORMAT_UPDATE_REQUIRED }).meta({
4169
+ description: `The document format this client writes. The current format is ${String(15)}.`,
4170
+ examples: [15]
4171
+ });
4172
+ /**
4173
+ * Refuses a write its client's format could get wrong. A client whose format differs from the
4174
+ * current one only in its number may still name changes, but a whole value it sends may lack
4175
+ * fields added since, so that needs the current format.
4176
+ */
4177
+ const refuseUnsafeWriterFormat = (documentFormatVersion, writes, context) => {
4178
+ const writer = canvasWriterFormat(documentFormatVersion);
4281
4179
  if (writer === "current" || writer === "number-only" && writes === "names") return;
4282
4180
  context.addIssue({
4283
4181
  code: "custom",
@@ -4371,6 +4269,109 @@ canvasSceneDocumentSchema.extend({
4371
4269
  nodes: z.record(z.string(), z.unknown()),
4372
4270
  relationships: z.record(z.string(), z.unknown())
4373
4271
  });
4272
+ const MAX_RENDER_MESSAGE_LENGTH$1 = 500;
4273
+ const MAX_RENDER_KIND_LENGTH = 100;
4274
+ /**
4275
+ * What a layer's box is: `placed` where the canvas draws the layer, `placed-before-transform` where
4276
+ * it draws the layer before the layer's own transform, `recorded` a size kept from when the layer
4277
+ * was made, for a layer the browser lays out.
4278
+ */
4279
+ const canvasBoxSourceSchema = z.enum([
4280
+ "placed",
4281
+ "placed-before-transform",
4282
+ "recorded"
4283
+ ]);
4284
+ /** Present only on a read that holds a `recorded` box. */
4285
+ const boxNoteSchema = z.string().min(1).optional();
4286
+ const canvasInspectNodeSummarySchema = z.object({
4287
+ id: z.string().min(1),
4288
+ label: z.string().max(MAX_RENDER_MESSAGE_LENGTH$1),
4289
+ kind: z.string().min(1).max(MAX_RENDER_KIND_LENGTH),
4290
+ parentId: z.string().min(1).nullable(),
4291
+ childCount: z.number().int().min(0),
4292
+ box: canvasSceneBoxSchema.nullable(),
4293
+ boxSource: canvasBoxSourceSchema.optional(),
4294
+ propertySections: z.array(canvasPropertySectionSchema)
4295
+ });
4296
+ z.object({ canvasId: z.uuid() });
4297
+ z.object({
4298
+ canvasId: z.uuid(),
4299
+ openUrl: z.url(),
4300
+ title: z.string().min(1),
4301
+ version: z.number().int().positive(),
4302
+ nodeCount: z.number().int().min(0),
4303
+ rootChildCount: z.number().int().min(0),
4304
+ bounds: canvasSceneBoxSchema.nullable(),
4305
+ kinds: z.record(z.string(), z.number().int().min(0)),
4306
+ boxNote: boxNoteSchema,
4307
+ next: z.array(z.string().min(1))
4308
+ });
4309
+ z.object({ canvasId: z.uuid() });
4310
+ z.object({
4311
+ canvasId: z.uuid(),
4312
+ version: z.number().int().positive(),
4313
+ nodes: z.array(canvasInspectNodeSummarySchema),
4314
+ boxNote: boxNoteSchema
4315
+ });
4316
+ z.object({
4317
+ canvasId: z.uuid(),
4318
+ nodeId: z.string().min(1)
4319
+ });
4320
+ z.object({
4321
+ canvasId: z.uuid(),
4322
+ version: z.number().int().positive(),
4323
+ node: canvasInspectNodeSummarySchema.extend({
4324
+ styles: z.record(z.string(), z.union([z.string(), z.number()])),
4325
+ layout: canvasNodeLayoutSchema.optional(),
4326
+ appearance: canvasAppearanceValuesSchema.optional(),
4327
+ geometry: canvasGeometrySchema.optional(),
4328
+ typography: canvasAuthoredTypographySchema.optional(),
4329
+ additionalStyles: canvasAdditionalStylesSchema.optional(),
4330
+ props: z.record(z.string(), z.unknown()),
4331
+ children: z.array(z.string().min(1))
4332
+ }),
4333
+ boxNote: boxNoteSchema,
4334
+ next: z.array(z.string().min(1))
4335
+ });
4336
+ const coordinate = z.number();
4337
+ const extent = z.number().positive();
4338
+ const placedBox = z.strictObject({
4339
+ x: coordinate,
4340
+ y: coordinate,
4341
+ width: extent,
4342
+ height: extent
4343
+ });
4344
+ /** Where the person who started the request was looking; a preference, never a camera command. */
4345
+ const canvasInitiatingViewHintSchema = z.strictObject({
4346
+ pageId: z.string().min(1),
4347
+ bounds: placedBox
4348
+ });
4349
+ /** How a new top-level screen or copied set is placed on its page. Omitted, positions stay as authored. */
4350
+ const canvasPlacementIntentSchema = z.discriminatedUnion("kind", [
4351
+ z.strictObject({
4352
+ kind: z.literal("auto"),
4353
+ view: canvasInitiatingViewHintSchema.optional()
4354
+ }),
4355
+ z.strictObject({
4356
+ kind: z.literal("near"),
4357
+ anchorNodeId: z.string().min(1),
4358
+ side: z.enum(["right", "below"])
4359
+ }),
4360
+ z.strictObject({
4361
+ kind: z.literal("explicit"),
4362
+ x: coordinate,
4363
+ y: coordinate
4364
+ })
4365
+ ]);
4366
+ /** Where a committed change put its roots, as saved at its own revision. */
4367
+ const canvasPlacementResultSchema = z.strictObject({
4368
+ pageId: z.string().min(1),
4369
+ bounds: placedBox,
4370
+ roots: z.array(z.strictObject({
4371
+ nodeId: z.string().min(1),
4372
+ box: placedBox
4373
+ })).min(1)
4374
+ });
4374
4375
  const temporaryIdSchema = z.string().min(1);
4375
4376
  const canvasConversionIssueSchema = z.object({
4376
4377
  code: z.enum([
@@ -4468,7 +4469,11 @@ const editableFrameInputBase = {
4468
4469
  };
4469
4470
  z.union([z.strictObject({
4470
4471
  ...editableFrameInputBase,
4471
- screenNodeId: z.string().min(1).describe("The screen layer to convert beside itself.")
4472
+ screenNodeId: z.string().min(1).describe("The screen layer to convert beside itself."),
4473
+ position: z.strictObject({
4474
+ x: z.number(),
4475
+ y: z.number()
4476
+ }).optional().describe("Where the editor measured room for the frame below its screen.")
4472
4477
  }), z.strictObject({
4473
4478
  ...editableFrameInputBase,
4474
4479
  capture: editableFrameCaptureSchema.describe("The stored page a new capture lands from, and the page its frame goes on.")
@@ -4485,7 +4490,9 @@ const createEditableFrameResultSchema = z.object({
4485
4490
  insertedNodeIds: z.array(z.string().min(1)),
4486
4491
  removedNodeIds: z.array(z.string().min(1)),
4487
4492
  boxes: z.record(z.string().min(1), canvasSceneBoxSchema),
4488
- affectedBounds: canvasSceneBoxSchema
4493
+ affectedBounds: canvasSceneBoxSchema,
4494
+ /** Where requested placement saved the root; absent when the request asked for none. */
4495
+ placement: canvasPlacementResultSchema.optional()
4489
4496
  });
4490
4497
  const RENDER_PHASES = [
4491
4498
  "queued",
@@ -4538,7 +4545,7 @@ const RENDER_WARNING_CODES = [
4538
4545
  "LAYOUT_FALLBACK",
4539
4546
  "DRAWN_APPROXIMATELY"
4540
4547
  ];
4541
- const MAX_RENDER_MESSAGE_LENGTH$1 = 500;
4548
+ const MAX_RENDER_MESSAGE_LENGTH = 500;
4542
4549
  const canvasRenderPixelLimitSchema = z.number().int().positive();
4543
4550
  const canvasWorldBoundsSchema = z.object({
4544
4551
  x: z.number(),
@@ -4610,13 +4617,13 @@ const canvasRenderFailureReasonSchema = z.enum(RENDER_FAILURE_REASONS);
4610
4617
  const canvasRenderWarningCodeSchema = z.enum(RENDER_WARNING_CODES);
4611
4618
  const canvasRenderWarningSchema = z.object({
4612
4619
  code: canvasRenderWarningCodeSchema,
4613
- message: z.string().min(1).max(MAX_RENDER_MESSAGE_LENGTH$1),
4620
+ message: z.string().min(1).max(MAX_RENDER_MESSAGE_LENGTH),
4614
4621
  sourceId: z.string().min(1).nullable()
4615
4622
  });
4616
4623
  const canvasRenderFailureSchema = z.object({
4617
4624
  reason: canvasRenderFailureReasonSchema,
4618
4625
  phase: canvasRenderPhaseSchema,
4619
- message: z.string().min(1).max(MAX_RENDER_MESSAGE_LENGTH$1),
4626
+ message: z.string().min(1).max(MAX_RENDER_MESSAGE_LENGTH),
4620
4627
  retryable: z.boolean(),
4621
4628
  sourceId: z.string().min(1).nullable()
4622
4629
  });
@@ -4765,11 +4772,20 @@ z.object({
4765
4772
  });
4766
4773
  const canvasWriteScopeSchema = z.object({ rootIds: z.array(z.string().min(1)) });
4767
4774
  const canvasConversionDestinationSchema = z.discriminatedUnion("kind", [
4768
- z.object({ kind: z.literal("adjacent") }),
4775
+ z.object({
4776
+ kind: z.literal("adjacent"),
4777
+ /** Where the page was measured to have room for the frame. Absent, stored boxes are searched. */
4778
+ position: z.strictObject({
4779
+ x: z.number(),
4780
+ y: z.number()
4781
+ }).optional()
4782
+ }),
4769
4783
  z.object({
4770
4784
  kind: z.literal("insert-children"),
4771
4785
  pageId: z.string().min(1).optional(),
4772
- targetNodeId: z.string().min(1)
4786
+ targetNodeId: z.string().min(1),
4787
+ /** World placement for a new top-level screen. Absent, the authored position stands. */
4788
+ placement: canvasPlacementIntentSchema.optional()
4773
4789
  }),
4774
4790
  z.object({
4775
4791
  kind: z.literal("replace"),
@@ -4884,7 +4900,9 @@ z.discriminatedUnion("state", [
4884
4900
  state: z.literal("ready"),
4885
4901
  jobId: z.uuid(),
4886
4902
  loadedVersion: z.number().int().positive(),
4887
- draft: canvasSubtreeDraftSchema
4903
+ draft: canvasSubtreeDraftSchema,
4904
+ /** Where measured placement put the draft's root, when the request asked for it. */
4905
+ placement: canvasSceneBoxSchema.optional()
4888
4906
  }),
4889
4907
  z.object({
4890
4908
  state: z.literal("failed"),
@@ -5256,6 +5274,69 @@ const canvasEditTextOperationSchema = z.object({
5256
5274
  history: canvasTextHistoryTargetSchema.optional(),
5257
5275
  source: canvasTextSourceSchema.optional()
5258
5276
  });
5277
+ const MAX_DESCRIPTION$1 = 2e3;
5278
+ const MAX_OVERRIDE_VALUE = 1e3;
5279
+ const canvasTextStyleTypographySchema = canvasTypographySchema.pick({
5280
+ family: true,
5281
+ fallbackFamilies: true,
5282
+ size: true,
5283
+ weight: true,
5284
+ style: true,
5285
+ variations: true,
5286
+ opticalSize: true,
5287
+ features: true,
5288
+ lineHeight: true,
5289
+ letterSpacing: true,
5290
+ transform: true,
5291
+ decoration: true,
5292
+ paragraphSpacing: true,
5293
+ paragraphIndent: true,
5294
+ listSpacing: true,
5295
+ hangingList: true,
5296
+ hangingPunctuation: true,
5297
+ verticalTrim: true,
5298
+ wrapStyle: true
5299
+ }).extend({ decoration: canvasTypographySchema.shape.decoration.omit({ blendMode: true }) }).strict();
5300
+ const CANVAS_TEXT_STYLE_PROPERTIES = canvasTextStyleTypographySchema.keyof().options;
5301
+ const canvasTextStyleSchema = z.object({
5302
+ id: z.string().min(1),
5303
+ name: z.string().trim().min(1),
5304
+ description: z.string().max(MAX_DESCRIPTION$1),
5305
+ sortKey: z.string().min(1).optional(),
5306
+ sourceStyleId: z.string().min(1).optional(),
5307
+ sourceCanvasId: z.uuid().optional(),
5308
+ sourceRevision: z.number().int().positive().optional(),
5309
+ typography: canvasTextStyleTypographySchema.extend({ listStyle: canvasTypographySchema.shape.listStyle }).transform((typography) => {
5310
+ Reflect.deleteProperty(typography, "listStyle");
5311
+ return typography;
5312
+ })
5313
+ }).strict().refine((style) => style.sourceCanvasId === void 0 || style.sourceStyleId !== void 0, {
5314
+ message: "A source canvas belongs to a reference snapshot.",
5315
+ path: ["sourceCanvasId"]
5316
+ }).refine((style) => style.sourceRevision === void 0 || style.sourceCanvasId !== void 0 && style.sourceStyleId !== void 0, {
5317
+ message: "A published revision belongs to a source style and canvas.",
5318
+ path: ["sourceRevision"]
5319
+ });
5320
+ z.object({
5321
+ id: canvasTextStyleSchema.shape.id,
5322
+ position: z.enum([
5323
+ "normal",
5324
+ "subscript",
5325
+ "superscript"
5326
+ ]).optional(),
5327
+ overrides: z.partialRecord(z.enum([
5328
+ "fontWeight",
5329
+ "fontStyle",
5330
+ "fontVariationSettings",
5331
+ "fontOpticalSizing",
5332
+ "textDecorationLine",
5333
+ "textDecorationStyle",
5334
+ "textDecorationColor",
5335
+ "textDecorationThickness",
5336
+ "textUnderlineOffset",
5337
+ "textDecorationSkipInk"
5338
+ ]), z.union([z.string().max(MAX_OVERRIDE_VALUE), z.number()])).optional()
5339
+ }).strict();
5259
5340
  const MAX_DESCRIPTION = 2e3;
5260
5341
  const MAX_TITLE = 200;
5261
5342
  const MAX_PAGE = 50;
@@ -5517,6 +5598,269 @@ createEditableFrameResultSchema.extend({
5517
5598
  operation: insertConvertedSubtreeOperationSchema,
5518
5599
  next: z.array(z.string().min(1))
5519
5600
  });
5601
+ /**
5602
+ * What each operation writes. `names` sets one plain value, places, removes, or merges a patch, so
5603
+ * values its client never knew stay as stored. `whole` brings a whole layer or replaces a whole
5604
+ * group of values, which a client that read the canvas in an older format may have stripped.
5605
+ */
5606
+ const CANVAS_OPERATION_WRITES = {
5607
+ insertConvertedSubtree: "whole",
5608
+ insertNode: "whole",
5609
+ insertText: "names",
5610
+ insertPrototype: "names",
5611
+ setPrototypeDeployment: "names",
5612
+ editText: "names",
5613
+ setText: "names",
5614
+ setBox: "names",
5615
+ setLabel: "names",
5616
+ setContainerKind: "names",
5617
+ setVisibility: "names",
5618
+ setLocked: "names",
5619
+ setConstraints: "names",
5620
+ setStyles: "names",
5621
+ patchExportSettings: "names",
5622
+ setAppearance: "names",
5623
+ setLayout: "whole",
5624
+ patchTypography: "names",
5625
+ setTypography: "whole",
5626
+ patchAdditionalStyles: "names",
5627
+ setAdditionalStyles: "whole",
5628
+ setArtworkColor: "whole",
5629
+ setTextStyleLibrary: "whole",
5630
+ patchFontLibrary: "names",
5631
+ setTextStyle: "whole",
5632
+ setGeometry: "whole",
5633
+ setProps: "whole",
5634
+ setParentage: "names",
5635
+ move: "names",
5636
+ remove: "names"
5637
+ };
5638
+ const nodeIdSchema$2 = canvasSceneNodeSchema.shape.id;
5639
+ const writableBoxSchema = canvasSceneBoxSchema.extend({
5640
+ width: z.number().positive(),
5641
+ height: z.number().positive()
5642
+ });
5643
+ const copiedNodeIdsSchema = z.record(nodeIdSchema$2, nodeIdSchema$2);
5644
+ /** A receipt stored before boxes said what they are holds none, so the source stays optional. */
5645
+ const canvasReceiptBoxSchema = canvasSceneBoxSchema.extend({ boxSource: canvasBoxSourceSchema.optional() });
5646
+ const canvasMutationRequestContextSchema = z.strictObject({
5647
+ fingerprint: z.string().regex(/^[a-f0-9]{64}$/u),
5648
+ revisionPolicy: z.enum(["strict", "rebase"]),
5649
+ copiedNodeIds: copiedNodeIdsSchema.optional()
5650
+ });
5651
+ z.object({
5652
+ canvasId: z.uuid(),
5653
+ mutationId: z.uuid(),
5654
+ documentFormatVersion: canvasDocumentFormatSchema,
5655
+ baseVersion: z.number().int().positive(),
5656
+ operations: z.array(canvasOperationSchema).min(1),
5657
+ requestContext: canvasMutationRequestContextSchema.optional(),
5658
+ writeScope: canvasWriteScopeSchema.optional()
5659
+ }).superRefine((input, context) => {
5660
+ refuseUnsafeWriterFormat(input.documentFormatVersion, input.operations.every((operation) => CANVAS_OPERATION_WRITES[operation.op] === "names") ? "names" : "whole", context);
5661
+ });
5662
+ const applyCanvasOperationsOutputSchema = z.object({
5663
+ canvasId: z.uuid(),
5664
+ mutationId: z.uuid(),
5665
+ previousVersion: z.number().int().positive(),
5666
+ version: z.number().int().positive(),
5667
+ operations: z.array(canvasOperationSchema),
5668
+ insertedNodeIds: z.array(nodeIdSchema$2),
5669
+ changedNodeIds: z.array(nodeIdSchema$2),
5670
+ removedNodeIds: z.array(nodeIdSchema$2),
5671
+ boxes: z.record(nodeIdSchema$2, canvasReceiptBoxSchema),
5672
+ affectedBounds: writableBoxSchema.nullable(),
5673
+ copiedNodeIds: copiedNodeIdsSchema.optional(),
5674
+ next: z.array(z.string().min(1))
5675
+ });
5676
+ z.strictObject({
5677
+ canvasId: z.uuid(),
5678
+ mutationId: z.uuid(),
5679
+ fingerprint: canvasMutationRequestContextSchema.shape.fingerprint
5680
+ });
5681
+ z.discriminatedUnion("state", [z.strictObject({ state: z.literal("not-found") }), z.strictObject({
5682
+ state: z.literal("committed"),
5683
+ /** `url` is the canvas's web address. An API older than the field answers without it. */
5684
+ result: applyCanvasOperationsOutputSchema.extend({ url: z.url().optional() })
5685
+ })]);
5686
+ const nodeId$3 = z.string().min(1);
5687
+ const nodeIds$1 = z.array(nodeId$3).min(1);
5688
+ /** An agent's small edits, in the order the API plans them. */
5689
+ const canvasAgentEditsSchema = z.array(z.discriminatedUnion("kind", [
5690
+ z.object({
5691
+ kind: z.literal("set_text"),
5692
+ nodeId: nodeId$3,
5693
+ text: z.string()
5694
+ }),
5695
+ z.object({
5696
+ kind: z.literal("set_styles"),
5697
+ nodeIds: nodeIds$1,
5698
+ styles: z.record(z.string(), z.union([
5699
+ z.string(),
5700
+ z.number(),
5701
+ z.null()
5702
+ ]))
5703
+ }),
5704
+ z.object({
5705
+ kind: z.literal("rename"),
5706
+ nodeId: nodeId$3,
5707
+ name: z.string().trim().min(1)
5708
+ }),
5709
+ z.object({
5710
+ kind: z.literal("duplicate"),
5711
+ nodeIds: nodeIds$1,
5712
+ parentId: nodeId$3.optional()
5713
+ }),
5714
+ z.object({
5715
+ kind: z.literal("move"),
5716
+ nodeId: nodeId$3,
5717
+ destination: z.discriminatedUnion("kind", [
5718
+ z.object({
5719
+ kind: z.literal("before"),
5720
+ nodeId: nodeId$3
5721
+ }),
5722
+ z.object({
5723
+ kind: z.literal("after"),
5724
+ nodeId: nodeId$3
5725
+ }),
5726
+ z.object({
5727
+ kind: z.literal("parent"),
5728
+ parentId: nodeId$3,
5729
+ index: z.number().int().nonnegative().optional()
5730
+ })
5731
+ ])
5732
+ })
5733
+ ])).min(1);
5734
+ z.strictObject({
5735
+ canvasId: z.uuid(),
5736
+ mutationId: z.uuid(),
5737
+ baseVersion: z.number().int().positive(),
5738
+ edits: canvasAgentEditsSchema,
5739
+ /** The prefix of copies' ids; the API makes one from the mutation id when it is left out. */
5740
+ idPrefix: z.string().min(1).optional(),
5741
+ /** A selection link's layers: the batch may change nothing outside them. */
5742
+ scopeNodeIds: z.array(nodeId$3).optional(),
5743
+ /** A selection link's page: the batch may name no layer on another page. */
5744
+ scopePageId: z.string().min(1).optional(),
5745
+ /** Whose words a refusal's next step is written in. */
5746
+ surface: z.enum(["cli", "mcp"]).optional(),
5747
+ fingerprint: canvasMutationRequestContextSchema.shape.fingerprint
5748
+ });
5749
+ const plannedNodeSchema = z.object({
5750
+ sourceId: z.string(),
5751
+ newId: z.string(),
5752
+ name: z.string(),
5753
+ component: z.string(),
5754
+ descendantIdMap: z.record(z.string(), z.string())
5755
+ });
5756
+ z.discriminatedUnion("outcome", [applyCanvasOperationsOutputSchema.extend({
5757
+ outcome: z.literal("committed"),
5758
+ /** True when the answer is the commit of an earlier identical request. */
5759
+ recovered: z.boolean(),
5760
+ duplicatedNodes: z.array(plannedNodeSchema).optional(),
5761
+ moves: z.array(z.object({
5762
+ nodeId: z.string(),
5763
+ parentId: z.string(),
5764
+ index: z.number().int()
5765
+ })).optional(),
5766
+ affectedParents: z.array(z.object({
5767
+ parentId: z.string(),
5768
+ children: z.array(z.string())
5769
+ })).optional()
5770
+ }), z.object({
5771
+ outcome: z.literal("no_op"),
5772
+ canvasId: z.uuid(),
5773
+ version: z.number().int().positive()
5774
+ })]);
5775
+ const fillsSchema = canvasPaintSchema.array().optional();
5776
+ z.object({ fills: fillsSchema });
5777
+ canvasTextParagraphSchema.pick({
5778
+ paragraphSpacing: true,
5779
+ paragraphIndent: true,
5780
+ listSpacing: true,
5781
+ wrapStyle: true
5782
+ }).extend({
5783
+ hangingPunctuation: canvasTypographySchema.shape.hangingPunctuation,
5784
+ verticalTrim: canvasTypographySchema.shape.verticalTrim,
5785
+ stroke: canvasTypographySchema.shape.stroke.nullable(),
5786
+ decorationBlendMode: canvasTypographySchema.shape.decoration.shape.blendMode,
5787
+ backgroundBlendMode: canvasBlendModeSchema.optional()
5788
+ }).strip();
5789
+ const CANVAS_FONT_CONTENT_TYPES = [
5790
+ "font/ttf",
5791
+ "font/otf",
5792
+ "font/woff",
5793
+ "font/woff2",
5794
+ "font/collection"
5795
+ ];
5796
+ const canvasFontAssetIdentitySchema = z.object({
5797
+ canvasId: z.uuid(),
5798
+ sha256: z.string().regex(/^[a-f0-9]{64}$/u)
5799
+ });
5800
+ canvasFontAssetIdentitySchema.extend({ bytes: z.number().int().positive() }).extend({ contentType: z.enum(CANVAS_FONT_CONTENT_TYPES) });
5801
+ z.object({ path: z.string().startsWith("/v1/canvas-assets/") }).extend({ upload: signedUploadSchema });
5802
+ const canvasFontAssetPath = (canvasId, sha256) => `${CANVAS_ASSET_PATH_PREFIX}${encodeURIComponent(canvasId)}/fonts/${encodeURIComponent(sha256)}`;
5803
+ z.object({
5804
+ canvasId: z.uuid(),
5805
+ sources: z.array(canvasFontAssetIdentitySchema).min(1)
5806
+ });
5807
+ z.object({ resources: z.array(z.object({
5808
+ source: canvasFontAssetIdentitySchema,
5809
+ path: z.string()
5810
+ })) });
5811
+ const MAX_FONT_WEIGHT = 1e3;
5812
+ const FONT_CONTENT_TYPES = new Set(CANVAS_FONT_CONTENT_TYPES);
5813
+ const isStoredContentType = (kind, contentType) => kind === "image" ? canvasStoredImageContentTypeSchema.safeParse(contentType).success : FONT_CONTENT_TYPES.has(contentType);
5814
+ const canvasAssetUploadIdentitySchema = z.strictObject({
5815
+ canvasId: z.uuid(),
5816
+ clientToken: z.uuid()
5817
+ });
5818
+ z.discriminatedUnion("kind", [canvasAssetUploadIdentitySchema.extend({
5819
+ kind: z.literal("image"),
5820
+ contentType: z.enum(CANVAS_IMAGE_CONTENT_TYPES),
5821
+ bytes: z.number().int().positive(),
5822
+ sha256: z.string().regex(/^[a-f0-9]{64}$/u)
5823
+ }), canvasAssetUploadIdentitySchema.extend({
5824
+ kind: z.literal("font"),
5825
+ contentType: z.enum(CANVAS_FONT_CONTENT_TYPES),
5826
+ bytes: z.number().int().positive(),
5827
+ sha256: z.string().regex(/^[a-f0-9]{64}$/u)
5828
+ })]);
5829
+ const canvasAssetMetadataSchema = z.discriminatedUnion("kind", [z.strictObject({
5830
+ kind: z.literal("image"),
5831
+ width: z.number().int().positive(),
5832
+ height: z.number().int().positive()
5833
+ }), z.strictObject({
5834
+ kind: z.literal("font"),
5835
+ family: z.string().min(1),
5836
+ subfamily: z.string(),
5837
+ style: z.enum([
5838
+ "normal",
5839
+ "italic",
5840
+ "oblique"
5841
+ ]),
5842
+ minimumWeight: z.number().min(1).max(MAX_FONT_WEIGHT),
5843
+ maximumWeight: z.number().min(1).max(MAX_FONT_WEIGHT)
5844
+ }).refine((font) => font.minimumWeight <= font.maximumWeight, "Font weight bounds must be ordered.")]);
5845
+ z.strictObject({
5846
+ canvasId: z.uuid(),
5847
+ clientToken: z.uuid(),
5848
+ assetId: z.uuid(),
5849
+ kind: z.enum(["image", "font"]),
5850
+ contentType: z.string(),
5851
+ bytes: z.number().int().positive(),
5852
+ sha256: z.string().regex(/^[a-f0-9]{64}$/u),
5853
+ path: z.string().startsWith("/v1/canvas-assets/"),
5854
+ state: z.enum(["awaiting_upload", "ready"]),
5855
+ metadata: canvasAssetMetadataSchema.nullable()
5856
+ }).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.");
5857
+ const SIDES$1 = [
5858
+ "top",
5859
+ "right",
5860
+ "bottom",
5861
+ "left"
5862
+ ];
5863
+ SIDES$1.map((side) => `padding-${side}`), SIDES$1.map((side) => `margin-${side}`);
5520
5864
  /** Reads retain unsupported documents; the write boundary validates the current scene format. */
5521
5865
  const canvasDocumentBlobSchema = z.record(z.string(), z.unknown());
5522
5866
  z.object({
@@ -5715,176 +6059,6 @@ z.object({
5715
6059
  text: z.string(),
5716
6060
  links: z.array(textLinkSchema).optional()
5717
6061
  });
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
6062
  const LIMITS = {
5889
6063
  nodes: 1e3,
5890
6064
  fields: 20,
@@ -6272,7 +6446,9 @@ const canvasDuplicatePreparationSchema = z.strictObject({
6272
6446
  destination: z.discriminatedUnion("kind", [z.strictObject({ kind: z.literal("native") }), z.strictObject({
6273
6447
  kind: z.literal("inside"),
6274
6448
  parentId: nodeId$2
6275
- })])
6449
+ })]),
6450
+ /** World placement for a set of top-level copies. Absent, the native copy offset stands. */
6451
+ placement: canvasPlacementIntentSchema.optional()
6276
6452
  });
6277
6453
  const canvasPreparationRequestSchema = z.discriminatedUnion("kind", [
6278
6454
  z.strictObject({
@@ -6573,14 +6749,11 @@ const beginCanvasActivityInputSchema = z.object({
6573
6749
  z.object({
6574
6750
  activityId: z.uuid(),
6575
6751
  expiresAt: z.iso.datetime(),
6576
- renewAfterMs: z.number().int().positive()
6752
+ renewAfterMs: z.number().int().positive(),
6753
+ /** The layers the mark names after this call: a start keeps the ones a live mark had. */
6754
+ nodeIds: z.array(z.string().min(1)).max(MAX_ACTIVITY_TARGETS).optional()
6577
6755
  });
6578
6756
  beginCanvasActivityInputSchema.extend({ activityId: z.uuid() });
6579
- z.object({
6580
- canvasId: z.uuid(),
6581
- activityId: z.uuid()
6582
- });
6583
- z.object({ ended: z.literal(true) });
6584
6757
  const serverEnvelopeBase = {
6585
6758
  v: z.literal(1),
6586
6759
  seq: z.number().int().nonnegative()
@@ -6835,6 +7008,10 @@ z.discriminatedUnion("purpose", [
6835
7008
  outputPrefix: z.string().min(1).max(MAX_STORAGE_KEY_LENGTH)
6836
7009
  })
6837
7010
  ]);
7011
+ const snapshotPlacementSchema = z.object({
7012
+ x: z.number(),
7013
+ y: z.number()
7014
+ });
6838
7015
  z.object({
6839
7016
  jobId: z.uuid(),
6840
7017
  loadedVersion: z.number().int().positive(),
@@ -6855,14 +7032,18 @@ z.object({
6855
7032
  viewport: z.object({
6856
7033
  width: z.number().int().positive(),
6857
7034
  height: z.number().int().positive()
6858
- })
7035
+ }),
7036
+ /** Where the page's search put the captured screen, at `loadedVersion`. */
7037
+ placement: snapshotPlacementSchema.optional()
6859
7038
  }).optional()
6860
7039
  });
6861
7040
  z.object({ accepted: z.literal(true) });
6862
7041
  z.object({
6863
7042
  jobId: z.uuid(),
6864
7043
  loadedVersion: z.number().int().positive(),
6865
- draft: canvasSubtreeDraftSchema
7044
+ draft: canvasSubtreeDraftSchema,
7045
+ /** The root's measured place at `loadedVersion`, for a request that asked to be placed. */
7046
+ placement: canvasSceneBoxSchema.optional()
6866
7047
  });
6867
7048
  z.object({ accepted: z.literal(true) });
6868
7049
  z.object({
@@ -6875,7 +7056,9 @@ z.object({
6875
7056
  viewport: z.object({
6876
7057
  width: z.number().int().positive(),
6877
7058
  height: z.number().int().positive()
6878
- })
7059
+ }),
7060
+ /** Where the editor's search for a capture below this recording puts the screen. */
7061
+ placement: snapshotPlacementSchema.optional()
6879
7062
  });
6880
7063
  z.object({
6881
7064
  jobId: z.uuid(),
@@ -7767,7 +7950,11 @@ const desktopRequestSchema = z.object({
7767
7950
  const desktopMutationIntentSchema = z.object({
7768
7951
  mutationId: id$2,
7769
7952
  canvasId: id$2,
7770
- procedure: z.enum(["canvas.applyOperations", "canvas.render.importSource"]),
7953
+ procedure: z.enum([
7954
+ "canvas.applyOperations",
7955
+ "canvas.render.importSource",
7956
+ "canvas.applyEdits"
7957
+ ]),
7771
7958
  input: z.record(z.string(), z.unknown()),
7772
7959
  state: z.enum([
7773
7960
  "recorded",
@@ -8325,7 +8512,9 @@ z.object({
8325
8512
  z.object({});
8326
8513
  z.object({
8327
8514
  items: z.array(agentTokenSchema),
8328
- isConnected: z.boolean()
8515
+ isConnected: z.boolean(),
8516
+ /** True once any agent credential of this person was ever used, even if all are now revoked. */
8517
+ hasEverConnected: z.boolean()
8329
8518
  });
8330
8519
  z.object({ tokenId: z.uuid() });
8331
8520
  z.object({
@@ -8338,6 +8527,44 @@ z.discriminatedUnion("method", [z.object({ method: z.literal("token") }), z.obje
8338
8527
  clientId: z.string().min(1),
8339
8528
  scope: z.literal("openid")
8340
8529
  })]);
8530
+ const onboardingStepIdSchema = z.enum([
8531
+ "connect_agent",
8532
+ "first_agent_work",
8533
+ "comment",
8534
+ "share_comments"
8535
+ ]);
8536
+ /** One person's preferences for one hint. `isSnoozed` is worked out with the API's clock. */
8537
+ const onboardingStepStateSchema = z.object({
8538
+ isAcknowledged: z.boolean(),
8539
+ maybeLaterCount: z.number().int().min(0),
8540
+ snoozedUntil: z.iso.datetime().nullable(),
8541
+ isSnoozed: z.boolean(),
8542
+ isStopped: z.boolean(),
8543
+ automaticShowCount: z.number().int().min(0),
8544
+ lastPresentationId: z.uuid().nullable()
8545
+ });
8546
+ z.strictObject({});
8547
+ z.object({
8548
+ hasCommented: z.boolean(),
8549
+ hasCopiedCanvasLink: z.boolean(),
8550
+ steps: z.object({
8551
+ connect_agent: onboardingStepStateSchema,
8552
+ first_agent_work: onboardingStepStateSchema,
8553
+ comment: onboardingStepStateSchema,
8554
+ share_comments: onboardingStepStateSchema
8555
+ })
8556
+ });
8557
+ z.strictObject({
8558
+ stepId: onboardingStepIdSchema,
8559
+ choice: z.enum(["got_it", "maybe_later"])
8560
+ });
8561
+ z.strictObject({
8562
+ stepId: onboardingStepIdSchema,
8563
+ presentationId: z.uuid()
8564
+ });
8565
+ z.object({ automaticShowNumber: z.number().int().min(1) });
8566
+ z.strictObject({});
8567
+ z.object({ hasCopiedCanvasLink: z.literal(true) });
8341
8568
  const personSchema = z.object({
8342
8569
  id: z.uuid(),
8343
8570
  preparedCanvasId: z.uuid(),
@@ -10505,7 +10732,7 @@ const startStallWatch = (caller, idleMs = STALL_MS) => {
10505
10732
  };
10506
10733
 
10507
10734
  //#endregion
10508
- //#region ../../packages/sdk/dist/capture-client.client-BSIO1VRh.mjs
10735
+ //#region ../../packages/sdk/dist/capture-client.client-DgqxTJkF.mjs
10509
10736
  const line = (text) => `Enhance: ${text}\n`;
10510
10737
  /** A left-out capture by its journey and step, or by its test when it could not be read at all. */
10511
10738
  const leftOutName = (leftOut, attempts) => {
@@ -11419,7 +11646,7 @@ const prepareMutation = (command, commandPath, procedurePath, input) => {
11419
11646
  command.hook("preAction", (actionCommand) => {
11420
11647
  const candidate = actionCommand.getOptionValue("clientToken");
11421
11648
  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.");
11649
+ 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
11650
  input.mutationKey.select(parsed.data, commandPath[0] === "fixture");
11424
11651
  });
11425
11652
  };
@@ -11812,16 +12039,53 @@ const registerFixtureProgram = (program, composites, output) => {
11812
12039
 
11813
12040
  //#endregion
11814
12041
  //#region src/infrastructure/guide.program.ts
11815
- /** `canvas guide`: the design skill of the one source, for an agent `setup` gave no skills. */
12042
+ /** The commands where an agent writes, looks or finishes, each with the rules it repeats. */
12043
+ const POINT_OF_USE_COMMANDS = {
12044
+ create: "create",
12045
+ "insert-html": "write",
12046
+ "write-html": "write",
12047
+ "update-html": "update",
12048
+ edit: "edit",
12049
+ render: "render",
12050
+ "finish-working-on-nodes": "finish",
12051
+ "import-asset": "import"
12052
+ };
12053
+ const GUIDE_NAMES = ["design-on-canvas", ...GUIDE_TOPIC_NAMES];
12054
+ const isTopic = (name) => GUIDE_TOPIC_NAMES.includes(name);
12055
+ /**
12056
+ * `canvas guide [topic]`: the design skill of the one source, or one of its topics, for an agent
12057
+ * `setup` gave no skills. It also tells `canvas --help` to load the guide first, and puts each
12058
+ * command's design rules in that command's help.
12059
+ */
11816
12060
  const registerCanvasGuideProgram = (program, input) => {
11817
12061
  const canvas = program.commands.find((command) => command.name() === "canvas");
11818
12062
  if (canvas === void 0) throw new TypeError("The canvas commands are registered first.");
11819
- canvas.command("guide").description("How to design on a canvas: the design-on-canvas skill.").action(() => {
12063
+ for (const command of canvas.commands) {
12064
+ const use = POINT_OF_USE_COMMANDS[command.name()];
12065
+ if (use !== void 0) command.addHelpText("after", `\nDesign: ${pointOfUseText(use)}\n`);
12066
+ }
12067
+ canvas.command("guide").description(`How to design on a canvas: the design-on-canvas skill, or a topic (${GUIDE_TOPIC_NAMES.join(", ")}).`).argument("[topic]", `One of ${GUIDE_NAMES.join(", ")}.`, "design-on-canvas").action((topic) => {
12068
+ if (isTopic(topic)) {
12069
+ input.write(GUIDE_TOPICS[topic].body);
12070
+ return;
12071
+ }
12072
+ if (topic !== "design-on-canvas") throw new CliError("BAD_REQUEST", `The guide has no topic ${topic}.`, `Ask for one of: ${GUIDE_NAMES.join(", ")}.`);
11820
12073
  const design = input.skills().find(({ skill }) => skill === "design-on-canvas");
11821
12074
  if (design === void 0) throw new TypeError("The skills hold no design-on-canvas.");
11822
12075
  input.write(design.body);
11823
12076
  });
11824
12077
  };
12078
+ /**
12079
+ * Tells `canvas --help` to load the guide first, after the sentence about the group. The group's
12080
+ * help is bounded, so it carries only this first line of the start-up list; the guide holds every
12081
+ * rule, and each command's help repeats its own. Run after the group's description is set.
12082
+ */
12083
+ const tellCanvasHelpToLoadTheGuide = (program, loadGuide) => {
12084
+ const canvas = program.commands.find((command) => command.name() === "canvas");
12085
+ if (canvas === void 0) throw new TypeError("The canvas commands are registered first.");
12086
+ if (canvas.summary() === "") canvas.summary(canvas.description());
12087
+ canvas.description(`${canvas.description()} ${loadGuide}`);
12088
+ };
11825
12089
 
11826
12090
  //#endregion
11827
12091
  //#region src/infrastructure/input-help.program.ts
@@ -12134,7 +12398,7 @@ const registerRecordingProgram = (program, input) => {
12134
12398
  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
12399
  const token = z.uuid().nullable().safeParse(options.clientToken ?? null);
12136
12400
  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.");
12401
+ 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
12402
  input.output.result(await input.invocation.invoke({
12139
12403
  capability: input.catalog.one("recording.snapshot"),
12140
12404
  arguments: {
@@ -12299,6 +12563,13 @@ const toolSkillTextsOf = (commandName, machine) => skillTextsFor({
12299
12563
  command: skillCommandOf(commandName, machine),
12300
12564
  nameOf: cliPathOf
12301
12565
  });
12566
+ /** The line in `canvas --help` that says to load the guide, naming its command as the skills do. */
12567
+ const toolLoadGuideOf = (commandName, machine) => loadGuideLineFor({
12568
+ surface: "cli",
12569
+ commandName,
12570
+ command: skillCommandOf(commandName, machine),
12571
+ nameOf: cliPathOf
12572
+ });
12302
12573
  /** Signing in, and the setup that signs in and gives each coding agent the skills. */
12303
12574
  const registerSignInPrograms = (program, input) => {
12304
12575
  const auth = createAuthUseCase(input.credentials, input.remote, createOauthLoopbackAdapter(input.remote));
@@ -12400,6 +12671,7 @@ const createCliProgram = (input) => {
12400
12671
  output: input.output
12401
12672
  });
12402
12673
  built.description("Operate Enhance as the authenticated person.");
12674
+ tellCanvasHelpToLoadTheGuide(built, toolLoadGuideOf(input.commandName, input.machine));
12403
12675
  attachInputHelp(built, catalog);
12404
12676
  const failureState = input.state;
12405
12677
  return {
@@ -12688,7 +12960,7 @@ const main = async () => {
12688
12960
  const remote = createHttpRemoteAdapter(config.apiUrl, credentials, mutationKey);
12689
12961
  const cli = createCliProgram({
12690
12962
  apiUrl: config.apiUrl,
12691
- version: "0.1.168",
12963
+ version: "0.1.171",
12692
12964
  credentials,
12693
12965
  remote,
12694
12966
  mutationKey,