@enhance-eng/enhance 0.1.167 → 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-DbOpumEM.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-Cs57z-_f.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
  };
@@ -1348,34 +1356,6 @@ const canvasComputedStyleRecords = (document, nodeIds) => nodeIds.map((nodeId) =
1348
1356
 
1349
1357
  //#endregion
1350
1358
  //#region src/infrastructure/canvas-authoring-source.program.ts
1351
- const GUIDE = {
1352
- topic: "canvas-agent-authoring",
1353
- workflow: [
1354
- "Keep the complete selection link as --canvas; only selected nodes and descendants are in scope.",
1355
- "Unknown state: canvas inspect. When nodeCount=0, use target root and its version to create a populated screen using write-html --review none. No blank pre-render or empty shell.",
1356
- "Multiple screens: publish each populated screen before authoring the next so users see progress. Prepare only what that screen needs; do not prepare the whole set before the first write.",
1357
- "Existing content: read only missing subtree structure or ids. Reuse useful context and product styles.",
1358
- "Batch related text, style, rename, duplicate and move changes with canvas edit --edits. Existing focused commands also work.",
1359
- "Use the version from the latest successful read or write as --base-version. After a conflict, reread and recompute the requested edit.",
1360
- "Render the affected screen when ready for review and inspect the PNG. Repeat after changes or a concrete discrepancy."
1361
- ],
1362
- html: {
1363
- modes: ["insert-children", "replace"],
1364
- rules: [
1365
- "Use inline concrete CSS; flex, padding and gap. Avoid margin, grid, tables and inline layout.",
1366
- "Give screen rows, cards and buttons explicit dimensions; avoid relying on implicit stretch. Use block frames for colored badges.",
1367
- "Name meaningful groups with layer-name; include content and structure together.",
1368
- "Styled text controls become frames with editable text children.",
1369
- "Scripts, event handlers, embedded documents, executable URLs and CSS imports are rejected."
1370
- ]
1371
- },
1372
- completion: [
1373
- "Natural hierarchy with the fewest useful editable primitives.",
1374
- "The committed version and affected ids match the request.",
1375
- "Inspect the final PNG for hierarchy, alignment, clipping and overflow.",
1376
- "Keep text, layout and appearance editable in the ordinary inspector."
1377
- ]
1378
- };
1379
1359
  const canvasScene = async (input, canvasId) => {
1380
1360
  const held = wholeCanvasDocumentOutputSchema.parse(await input.remote.query("canvas.document.get", { canvasId }));
1381
1361
  return {
@@ -1384,9 +1364,6 @@ const canvasScene = async (input, canvasId) => {
1384
1364
  };
1385
1365
  };
1386
1366
  const configureCanvasAuthoringSource = (canvas, input) => {
1387
- canvas.command("guide").description("Agent design workflow.").action(() => {
1388
- input.output.result(GUIDE);
1389
- });
1390
1367
  canvas.command("get-jsx").description("Read concise subtree JSX.").requiredOption("--canvas <url-or-id>", "Canvas URL or UUID to inspect.").requiredOption("--node-id <id>", "Stable subtree root id.").option("--depth <integer>", "Maximum descendant depth from 0 to 20.", "8").action(async (options) => {
1391
1368
  const reference = parseCanvasReference(options.canvas);
1392
1369
  const canvasId = reference.canvasId;
@@ -1836,7 +1813,7 @@ const recordingIdFrom = (nodeId) => {
1836
1813
  };
1837
1814
  const selectClientToken = (input, value) => {
1838
1815
  const clientToken = z.uuid().nullable().safeParse(value ?? null);
1839
- 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.");
1840
1817
  input.mutationKey.select(clientToken.data, false);
1841
1818
  return input.mutationKey.current("canvas.render.create", {});
1842
1819
  };
@@ -1910,7 +1887,7 @@ const registerCanvasProgram = (program, input) => {
1910
1887
  };
1911
1888
 
1912
1889
  //#endregion
1913
- //#region ../../packages/sdk/dist/stall-watch.lib-0UnfNs7X.mjs
1890
+ //#region ../../packages/sdk/dist/stall-watch.lib-DGygK3yF.mjs
1914
1891
  const CAPTURE_METADATA_LENGTH = 200;
1915
1892
  const CAPTURE_FAILURE_LENGTH = 1e3;
1916
1893
  const CAPTURE_UPLOAD_BATCH_SIZE = 400;
@@ -3080,14 +3057,14 @@ z.object({
3080
3057
  message: z.string().min(1).max(MAX_PICTURE_FAILURE_LENGTH)
3081
3058
  })).max(20)
3082
3059
  });
3083
- const coordinate$1 = z.number();
3084
- const extent = z.number().nonnegative();
3060
+ const coordinate$2 = z.number();
3061
+ const extent$1 = z.number().nonnegative();
3085
3062
  /** A box in page coordinates. */
3086
3063
  const canvasOutlineBoxSchema = z.strictObject({
3087
- x: coordinate$1,
3088
- y: coordinate$1,
3089
- width: extent,
3090
- height: extent
3064
+ x: coordinate$2,
3065
+ y: coordinate$2,
3066
+ width: extent$1,
3067
+ height: extent$1
3091
3068
  });
3092
3069
  /** What a browser measured of one top layer: its own box, and how far its descendants paint. */
3093
3070
  const canvasOutlineMeasurementSchema = z.strictObject({
@@ -4018,225 +3995,15 @@ const canvasAdditionalStylePatchSchema = z.object({
4018
3995
  order: identifiers.optional(),
4019
3996
  empty: z.enum(["keep", "remove"]).optional()
4020
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");
4021
- const MAX_DESCRIPTION$1 = 2e3;
4022
- const MAX_OVERRIDE_VALUE = 1e3;
4023
- const canvasTextStyleTypographySchema = canvasTypographySchema.pick({
4024
- family: true,
4025
- fallbackFamilies: true,
4026
- size: true,
4027
- weight: true,
4028
- style: true,
4029
- variations: true,
4030
- opticalSize: true,
4031
- features: true,
4032
- lineHeight: true,
4033
- letterSpacing: true,
4034
- transform: true,
4035
- decoration: true,
4036
- paragraphSpacing: true,
4037
- paragraphIndent: true,
4038
- listSpacing: true,
4039
- hangingList: true,
4040
- hangingPunctuation: true,
4041
- verticalTrim: true,
4042
- wrapStyle: true
4043
- }).extend({ decoration: canvasTypographySchema.shape.decoration.omit({ blendMode: true }) }).strict();
4044
- const CANVAS_TEXT_STYLE_PROPERTIES = canvasTextStyleTypographySchema.keyof().options;
4045
- const canvasTextStyleSchema = z.object({
4046
- id: z.string().min(1),
4047
- name: z.string().trim().min(1),
4048
- description: z.string().max(MAX_DESCRIPTION$1),
4049
- sortKey: z.string().min(1).optional(),
4050
- sourceStyleId: z.string().min(1).optional(),
4051
- sourceCanvasId: z.uuid().optional(),
4052
- sourceRevision: z.number().int().positive().optional(),
4053
- typography: canvasTextStyleTypographySchema.extend({ listStyle: canvasTypographySchema.shape.listStyle }).transform((typography) => {
4054
- Reflect.deleteProperty(typography, "listStyle");
4055
- return typography;
4056
- })
4057
- }).strict().refine((style) => style.sourceCanvasId === void 0 || style.sourceStyleId !== void 0, {
4058
- message: "A source canvas belongs to a reference snapshot.",
4059
- path: ["sourceCanvasId"]
4060
- }).refine((style) => style.sourceRevision === void 0 || style.sourceCanvasId !== void 0 && style.sourceStyleId !== void 0, {
4061
- message: "A published revision belongs to a source style and canvas.",
4062
- path: ["sourceRevision"]
4063
- });
4064
- z.object({
4065
- id: canvasTextStyleSchema.shape.id,
4066
- position: z.enum([
4067
- "normal",
4068
- "subscript",
4069
- "superscript"
4070
- ]).optional(),
4071
- overrides: z.partialRecord(z.enum([
4072
- "fontWeight",
4073
- "fontStyle",
4074
- "fontVariationSettings",
4075
- "fontOpticalSizing",
4076
- "textDecorationLine",
4077
- "textDecorationStyle",
4078
- "textDecorationColor",
4079
- "textDecorationThickness",
4080
- "textUnderlineOffset",
4081
- "textDecorationSkipInk"
4082
- ]), z.union([z.string().max(MAX_OVERRIDE_VALUE), z.number()])).optional()
4083
- }).strict();
4084
- const fillsSchema = canvasPaintSchema.array().optional();
4085
- z.object({ fills: fillsSchema });
4086
- canvasTextParagraphSchema.pick({
4087
- paragraphSpacing: true,
4088
- paragraphIndent: true,
4089
- listSpacing: true,
4090
- wrapStyle: true
4091
- }).extend({
4092
- hangingPunctuation: canvasTypographySchema.shape.hangingPunctuation,
4093
- verticalTrim: canvasTypographySchema.shape.verticalTrim,
4094
- stroke: canvasTypographySchema.shape.stroke.nullable(),
4095
- decorationBlendMode: canvasTypographySchema.shape.decoration.shape.blendMode,
4096
- backgroundBlendMode: canvasBlendModeSchema.optional()
4097
- }).strip();
4098
- /**
4099
- * The two-phase upload, seen from the client. The bytes never pass through the API: it hands
4100
- * back a URL S3 will accept, and the client PUTs to it directly.
4101
- */
4102
- const signedUploadSchema = z.object({
4103
- url: z.url(),
4104
- expiresAt: z.iso.datetime(),
4105
- /** Signed into the URL, so a client that omits one gets a 403 from S3, not from us. */
4106
- headers: z.record(z.string(), z.string())
4107
- });
4108
- const signedDownloadSchema = z.object({
4109
- url: z.url(),
4110
- expiresAt: z.iso.datetime(),
4111
- bytes: z.number().int().min(0)
4112
- });
4113
- const CANVAS_ASSET_PATH_PREFIX = "/v1/canvas-assets/";
4114
- const CANVAS_IMAGE_CONTENT_TYPES = [
4115
- "image/avif",
4116
- "image/gif",
4117
- "image/jpeg",
4118
- "image/png",
4119
- "image/webp"
4120
- ];
4121
- /**
4122
- * An image the canvas image store may hold. Files people upload keep to the closed list above; an
4123
- * image a layer held inline is stored under whatever `image/*` type it has.
4124
- */
4125
- const canvasStoredImageContentTypeSchema = z.string().regex(/^image\/[a-z0-9.+-]+$/u);
4126
- z.object({
4127
- canvasId: z.uuid(),
4128
- contentType: z.enum(CANVAS_IMAGE_CONTENT_TYPES),
4129
- bytes: z.number().int().positive()
4130
- });
4131
- z.object({
4132
- assetId: z.uuid(),
4133
- path: z.string().startsWith("/v1/canvas-assets/"),
4134
- upload: signedUploadSchema
4135
- });
4136
- const canvasImageAssetPath = (canvasId, assetId) => `${CANVAS_ASSET_PATH_PREFIX}${encodeURIComponent(canvasId)}/${encodeURIComponent(assetId)}`;
4137
- const canvasImageIdentitySchema = z.tuple([z.uuid(), z.uuid()]);
4138
- const canvasImageAssetIdentityFromPath = (path) => {
4139
- if (!path.startsWith("/v1/canvas-assets/")) return null;
4140
- const identity = canvasImageIdentitySchema.safeParse(path.slice(18).split("/")).data;
4141
- return identity === void 0 ? null : {
4142
- canvasId: identity[0],
4143
- assetId: identity[1]
4144
- };
4145
- };
4146
- const CANVAS_FONT_CONTENT_TYPES = [
4147
- "font/ttf",
4148
- "font/otf",
4149
- "font/woff",
4150
- "font/woff2",
4151
- "font/collection"
4152
- ];
4153
- const canvasFontAssetIdentitySchema = z.object({
4154
- canvasId: z.uuid(),
4155
- sha256: z.string().regex(/^[a-f0-9]{64}$/u)
4156
- });
4157
- canvasFontAssetIdentitySchema.extend({ bytes: z.number().int().positive() }).extend({ contentType: z.enum(CANVAS_FONT_CONTENT_TYPES) });
4158
- z.object({ path: z.string().startsWith("/v1/canvas-assets/") }).extend({ upload: signedUploadSchema });
4159
- const canvasFontAssetPath = (canvasId, sha256) => `${CANVAS_ASSET_PATH_PREFIX}${encodeURIComponent(canvasId)}/fonts/${encodeURIComponent(sha256)}`;
4160
- z.object({
4161
- canvasId: z.uuid(),
4162
- sources: z.array(canvasFontAssetIdentitySchema).min(1)
4163
- });
4164
- z.object({ resources: z.array(z.object({
4165
- source: canvasFontAssetIdentitySchema,
4166
- path: z.string()
4167
- })) });
4168
- const MAX_FONT_WEIGHT = 1e3;
4169
- const FONT_CONTENT_TYPES = new Set(CANVAS_FONT_CONTENT_TYPES);
4170
- const isStoredContentType = (kind, contentType) => kind === "image" ? canvasStoredImageContentTypeSchema.safeParse(contentType).success : FONT_CONTENT_TYPES.has(contentType);
4171
- const canvasAssetUploadIdentitySchema = z.strictObject({
4172
- canvasId: z.uuid(),
4173
- clientToken: z.uuid()
4174
- });
4175
- z.discriminatedUnion("kind", [canvasAssetUploadIdentitySchema.extend({
4176
- kind: z.literal("image"),
4177
- contentType: z.enum(CANVAS_IMAGE_CONTENT_TYPES),
4178
- bytes: z.number().int().positive(),
4179
- sha256: z.string().regex(/^[a-f0-9]{64}$/u)
4180
- }), canvasAssetUploadIdentitySchema.extend({
4181
- kind: z.literal("font"),
4182
- contentType: z.enum(CANVAS_FONT_CONTENT_TYPES),
4183
- bytes: z.number().int().positive(),
4184
- sha256: z.string().regex(/^[a-f0-9]{64}$/u)
4185
- })]);
4186
- const canvasAssetMetadataSchema = z.discriminatedUnion("kind", [z.strictObject({
4187
- kind: z.literal("image"),
4188
- width: z.number().int().positive(),
4189
- height: z.number().int().positive()
4190
- }), z.strictObject({
4191
- kind: z.literal("font"),
4192
- family: z.string().min(1),
4193
- subfamily: z.string(),
4194
- style: z.enum([
4195
- "normal",
4196
- "italic",
4197
- "oblique"
4198
- ]),
4199
- minimumWeight: z.number().min(1).max(MAX_FONT_WEIGHT),
4200
- maximumWeight: z.number().min(1).max(MAX_FONT_WEIGHT)
4201
- }).refine((font) => font.minimumWeight <= font.maximumWeight, "Font weight bounds must be ordered.")]);
4202
- z.strictObject({
4203
- canvasId: z.uuid(),
4204
- clientToken: z.uuid(),
4205
- assetId: z.uuid(),
4206
- kind: z.enum(["image", "font"]),
4207
- contentType: z.string(),
4208
- bytes: z.number().int().positive(),
4209
- sha256: z.string().regex(/^[a-f0-9]{64}$/u),
4210
- path: z.string().startsWith("/v1/canvas-assets/"),
4211
- state: z.enum(["awaiting_upload", "ready"]),
4212
- metadata: canvasAssetMetadataSchema.nullable()
4213
- }).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.");
4214
- const SIDES$1 = [
4215
- "top",
4216
- "right",
4217
- "bottom",
4218
- "left"
4219
- ];
4220
- SIDES$1.map((side) => `padding-${side}`), SIDES$1.map((side) => `margin-${side}`);
4221
- const format = z.enum(["png", "jpeg"]);
4222
- const scale = z.number().positive();
4223
- const canvasExportSettingsSchema = z.strictObject({
4224
- format: format.optional(),
4225
- scale: scale.optional()
4226
- });
4227
- const canvasExportSettingsPatchSchema = z.strictObject({
4228
- format: format.nullable().optional(),
4229
- scale: scale.nullable().optional()
4230
- }).refine((patch) => patch.format !== void 0 || patch.scale !== void 0);
4231
- const coordinate = z.number();
4232
- const dimension = coordinate.nonnegative();
3998
+ const coordinate$1 = z.number();
3999
+ const dimension = coordinate$1.nonnegative();
4233
4000
  const MAX_ID_LENGTH = 200;
4234
4001
  const MIN_POLYGON_POINTS = 3;
4235
4002
  const identity$1 = z.string().min(1).max(MAX_ID_LENGTH);
4236
4003
  const path$1 = z.string().regex(/^[MmLlHhVvCcSsQqTtAaZzEe\d\s.,+-]*$/u);
4237
4004
  const canvasGeometryBoundsSchema = z.strictObject({
4238
- x: coordinate,
4239
- y: coordinate,
4005
+ x: coordinate$1,
4006
+ y: coordinate$1,
4240
4007
  width: dimension,
4241
4008
  height: dimension
4242
4009
  });
@@ -4289,32 +4056,111 @@ const canvasGeometrySchema = z.discriminatedUnion("kind", [
4289
4056
  }),
4290
4057
  canvasBooleanGeometrySchema
4291
4058
  ]);
4292
- const CANVAS_COMPOSITING_RETIRED = "Update Enhance: compositing is no longer supported. Use the isolation style or a mask group.";
4293
- 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.";
4294
- const CANVAS_FORMAT_SERVER_UPDATING = "Enhance is being updated. Try again in a minute.";
4295
- /** Marks an issue whose message was written for whoever sent the request, so the API keeps it. */
4296
- const FOR_CALLER = { forCaller: true };
4297
- /**
4298
- * The format a writer was built for, as a plain whole number so tool schemas can describe it. Which
4299
- * writes that format may make is `refuseUnsafeWriterFormat`'s call.
4300
- */
4301
- const canvasDocumentFormatSchema = z.number({ error: CANVAS_FORMAT_UPDATE_REQUIRED }).int({ error: CANVAS_FORMAT_UPDATE_REQUIRED }).positive({ error: CANVAS_FORMAT_UPDATE_REQUIRED }).meta({
4302
- description: `The document format this client writes. The current format is ${String(15)}.`,
4303
- examples: [15]
4304
- });
4305
- /**
4306
- * Refuses a write its client's format could get wrong. A client whose format differs from the
4307
- * current one only in its number may still name changes, but a whole value it sends may lack
4308
- * fields added since, so that needs the current format.
4309
- */
4310
- const refuseUnsafeWriterFormat = (documentFormatVersion, writes, context) => {
4311
- const writer = canvasWriterFormat(documentFormatVersion);
4312
- if (writer === "current" || writer === "number-only" && writes === "names") return;
4313
- context.addIssue({
4314
- code: "custom",
4315
- path: ["documentFormatVersion"],
4316
- message: writer === "ahead" ? CANVAS_FORMAT_SERVER_UPDATING : CANVAS_FORMAT_UPDATE_REQUIRED,
4317
- params: FOR_CALLER,
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,
4318
4164
  input: documentFormatVersion
4319
4165
  });
4320
4166
  };
@@ -4402,6 +4248,109 @@ canvasSceneDocumentSchema.extend({
4402
4248
  nodes: z.record(z.string(), z.unknown()),
4403
4249
  relationships: z.record(z.string(), z.unknown())
4404
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
+ });
4405
4354
  const temporaryIdSchema = z.string().min(1);
4406
4355
  const canvasConversionIssueSchema = z.object({
4407
4356
  code: z.enum([
@@ -4411,7 +4360,8 @@ const canvasConversionIssueSchema = z.object({
4411
4360
  "nodes-truncated",
4412
4361
  "responsive-behavior-not-editable",
4413
4362
  "style-degraded",
4414
- "unsupported-surface"
4363
+ "unsupported-surface",
4364
+ "vertical-writing-unsupported"
4415
4365
  ]),
4416
4366
  message: z.string().min(1),
4417
4367
  temporaryId: temporaryIdSchema.optional()
@@ -4471,7 +4421,10 @@ const canvasSubtreeDraftSchema = z.object({
4471
4421
  relationships: z.array(canvasSubtreeDraftRelationshipSchema),
4472
4422
  report: canvasConversionReportSchema.catch({
4473
4423
  nodeCount: 0,
4474
- issues: []
4424
+ issues: [{
4425
+ code: "content-omitted",
4426
+ message: "The converter's report could not be read, so what it left out of this insert is unknown."
4427
+ }]
4475
4428
  })
4476
4429
  }).transform((draft) => ({
4477
4430
  ...draft,
@@ -4495,7 +4448,11 @@ const editableFrameInputBase = {
4495
4448
  };
4496
4449
  z.union([z.strictObject({
4497
4450
  ...editableFrameInputBase,
4498
- 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.")
4499
4456
  }), z.strictObject({
4500
4457
  ...editableFrameInputBase,
4501
4458
  capture: editableFrameCaptureSchema.describe("The stored page a new capture lands from, and the page its frame goes on.")
@@ -4512,7 +4469,9 @@ const createEditableFrameResultSchema = z.object({
4512
4469
  insertedNodeIds: z.array(z.string().min(1)),
4513
4470
  removedNodeIds: z.array(z.string().min(1)),
4514
4471
  boxes: z.record(z.string().min(1), canvasSceneBoxSchema),
4515
- affectedBounds: canvasSceneBoxSchema
4472
+ affectedBounds: canvasSceneBoxSchema,
4473
+ /** Where requested placement saved the root; absent when the request asked for none. */
4474
+ placement: canvasPlacementResultSchema.optional()
4516
4475
  });
4517
4476
  const RENDER_PHASES = [
4518
4477
  "queued",
@@ -4565,7 +4524,7 @@ const RENDER_WARNING_CODES = [
4565
4524
  "LAYOUT_FALLBACK",
4566
4525
  "DRAWN_APPROXIMATELY"
4567
4526
  ];
4568
- const MAX_RENDER_MESSAGE_LENGTH$1 = 500;
4527
+ const MAX_RENDER_MESSAGE_LENGTH = 500;
4569
4528
  const canvasRenderPixelLimitSchema = z.number().int().positive();
4570
4529
  const canvasWorldBoundsSchema = z.object({
4571
4530
  x: z.number(),
@@ -4637,13 +4596,13 @@ const canvasRenderFailureReasonSchema = z.enum(RENDER_FAILURE_REASONS);
4637
4596
  const canvasRenderWarningCodeSchema = z.enum(RENDER_WARNING_CODES);
4638
4597
  const canvasRenderWarningSchema = z.object({
4639
4598
  code: canvasRenderWarningCodeSchema,
4640
- message: z.string().min(1).max(MAX_RENDER_MESSAGE_LENGTH$1),
4599
+ message: z.string().min(1).max(MAX_RENDER_MESSAGE_LENGTH),
4641
4600
  sourceId: z.string().min(1).nullable()
4642
4601
  });
4643
4602
  const canvasRenderFailureSchema = z.object({
4644
4603
  reason: canvasRenderFailureReasonSchema,
4645
4604
  phase: canvasRenderPhaseSchema,
4646
- message: z.string().min(1).max(MAX_RENDER_MESSAGE_LENGTH$1),
4605
+ message: z.string().min(1).max(MAX_RENDER_MESSAGE_LENGTH),
4647
4606
  retryable: z.boolean(),
4648
4607
  sourceId: z.string().min(1).nullable()
4649
4608
  });
@@ -4792,11 +4751,20 @@ z.object({
4792
4751
  });
4793
4752
  const canvasWriteScopeSchema = z.object({ rootIds: z.array(z.string().min(1)) });
4794
4753
  const canvasConversionDestinationSchema = z.discriminatedUnion("kind", [
4795
- 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
+ }),
4796
4762
  z.object({
4797
4763
  kind: z.literal("insert-children"),
4798
4764
  pageId: z.string().min(1).optional(),
4799
- 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()
4800
4768
  }),
4801
4769
  z.object({
4802
4770
  kind: z.literal("replace"),
@@ -4911,7 +4879,9 @@ z.discriminatedUnion("state", [
4911
4879
  state: z.literal("ready"),
4912
4880
  jobId: z.uuid(),
4913
4881
  loadedVersion: z.number().int().positive(),
4914
- draft: canvasSubtreeDraftSchema
4882
+ draft: canvasSubtreeDraftSchema,
4883
+ /** Where measured placement put the draft's root, when the request asked for it. */
4884
+ placement: canvasSceneBoxSchema.optional()
4915
4885
  }),
4916
4886
  z.object({
4917
4887
  state: z.literal("failed"),
@@ -5283,6 +5253,69 @@ const canvasEditTextOperationSchema = z.object({
5283
5253
  history: canvasTextHistoryTargetSchema.optional(),
5284
5254
  source: canvasTextSourceSchema.optional()
5285
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();
5286
5319
  const MAX_DESCRIPTION = 2e3;
5287
5320
  const MAX_TITLE = 200;
5288
5321
  const MAX_PAGE = 50;
@@ -5544,6 +5577,269 @@ createEditableFrameResultSchema.extend({
5544
5577
  operation: insertConvertedSubtreeOperationSchema,
5545
5578
  next: z.array(z.string().min(1))
5546
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}`);
5547
5843
  /** Reads retain unsupported documents; the write boundary validates the current scene format. */
5548
5844
  const canvasDocumentBlobSchema = z.record(z.string(), z.unknown());
5549
5845
  z.object({
@@ -5742,176 +6038,6 @@ z.object({
5742
6038
  text: z.string(),
5743
6039
  links: z.array(textLinkSchema).optional()
5744
6040
  });
5745
- const canvasPropertySectionSchema = z.enum([
5746
- "position",
5747
- "layout",
5748
- "clip",
5749
- "cornerRadius",
5750
- "blending",
5751
- "typography",
5752
- "nativeControl",
5753
- "textDecoration",
5754
- "fill",
5755
- "outline",
5756
- "textStroke",
5757
- "border",
5758
- "outerShadow",
5759
- "innerShadow",
5760
- "filters",
5761
- "additionalStyles",
5762
- "vector",
5763
- "export",
5764
- "source"
5765
- ]);
5766
- const MAX_RENDER_MESSAGE_LENGTH = 500;
5767
- const MAX_RENDER_KIND_LENGTH = 100;
5768
- /**
5769
- * What a layer's box is: `placed` where the canvas draws the layer, `placed-before-transform` where
5770
- * it draws the layer before the layer's own transform, `recorded` a size kept from when the layer
5771
- * was made, for a layer the browser lays out.
5772
- */
5773
- const canvasBoxSourceSchema = z.enum([
5774
- "placed",
5775
- "placed-before-transform",
5776
- "recorded"
5777
- ]);
5778
- /** Present only on a read that holds a `recorded` box. */
5779
- const boxNoteSchema = z.string().min(1).optional();
5780
- const canvasInspectNodeSummarySchema = z.object({
5781
- id: z.string().min(1),
5782
- label: z.string().max(MAX_RENDER_MESSAGE_LENGTH),
5783
- kind: z.string().min(1).max(MAX_RENDER_KIND_LENGTH),
5784
- parentId: z.string().min(1).nullable(),
5785
- childCount: z.number().int().min(0),
5786
- box: canvasSceneBoxSchema.nullable(),
5787
- boxSource: canvasBoxSourceSchema.optional(),
5788
- propertySections: z.array(canvasPropertySectionSchema)
5789
- });
5790
- z.object({ canvasId: z.uuid() });
5791
- z.object({
5792
- canvasId: z.uuid(),
5793
- openUrl: z.url(),
5794
- title: z.string().min(1),
5795
- version: z.number().int().positive(),
5796
- nodeCount: z.number().int().min(0),
5797
- rootChildCount: z.number().int().min(0),
5798
- bounds: canvasSceneBoxSchema.nullable(),
5799
- kinds: z.record(z.string(), z.number().int().min(0)),
5800
- boxNote: boxNoteSchema,
5801
- next: z.array(z.string().min(1))
5802
- });
5803
- z.object({ canvasId: z.uuid() });
5804
- z.object({
5805
- canvasId: z.uuid(),
5806
- version: z.number().int().positive(),
5807
- nodes: z.array(canvasInspectNodeSummarySchema),
5808
- boxNote: boxNoteSchema
5809
- });
5810
- z.object({
5811
- canvasId: z.uuid(),
5812
- nodeId: z.string().min(1)
5813
- });
5814
- z.object({
5815
- canvasId: z.uuid(),
5816
- version: z.number().int().positive(),
5817
- node: canvasInspectNodeSummarySchema.extend({
5818
- styles: z.record(z.string(), z.union([z.string(), z.number()])),
5819
- layout: canvasNodeLayoutSchema.optional(),
5820
- appearance: canvasAppearanceValuesSchema.optional(),
5821
- geometry: canvasGeometrySchema.optional(),
5822
- typography: canvasAuthoredTypographySchema.optional(),
5823
- additionalStyles: canvasAdditionalStylesSchema.optional(),
5824
- props: z.record(z.string(), z.unknown()),
5825
- children: z.array(z.string().min(1))
5826
- }),
5827
- boxNote: boxNoteSchema,
5828
- next: z.array(z.string().min(1))
5829
- });
5830
- /**
5831
- * What each operation writes. `names` sets one plain value, places, removes, or merges a patch, so
5832
- * values its client never knew stay as stored. `whole` brings a whole layer or replaces a whole
5833
- * group of values, which a client that read the canvas in an older format may have stripped.
5834
- */
5835
- const CANVAS_OPERATION_WRITES = {
5836
- insertConvertedSubtree: "whole",
5837
- insertNode: "whole",
5838
- insertText: "names",
5839
- insertPrototype: "names",
5840
- setPrototypeDeployment: "names",
5841
- editText: "names",
5842
- setText: "names",
5843
- setBox: "names",
5844
- setLabel: "names",
5845
- setContainerKind: "names",
5846
- setVisibility: "names",
5847
- setLocked: "names",
5848
- setConstraints: "names",
5849
- setStyles: "names",
5850
- patchExportSettings: "names",
5851
- setAppearance: "names",
5852
- setLayout: "whole",
5853
- patchTypography: "names",
5854
- setTypography: "whole",
5855
- patchAdditionalStyles: "names",
5856
- setAdditionalStyles: "whole",
5857
- setArtworkColor: "whole",
5858
- setTextStyleLibrary: "whole",
5859
- patchFontLibrary: "names",
5860
- setTextStyle: "whole",
5861
- setGeometry: "whole",
5862
- setProps: "whole",
5863
- setParentage: "names",
5864
- move: "names",
5865
- remove: "names"
5866
- };
5867
- const nodeIdSchema$2 = canvasSceneNodeSchema.shape.id;
5868
- const writableBoxSchema = canvasSceneBoxSchema.extend({
5869
- width: z.number().positive(),
5870
- height: z.number().positive()
5871
- });
5872
- const copiedNodeIdsSchema = z.record(nodeIdSchema$2, nodeIdSchema$2);
5873
- /** A receipt stored before boxes said what they are holds none, so the source stays optional. */
5874
- const canvasReceiptBoxSchema = canvasSceneBoxSchema.extend({ boxSource: canvasBoxSourceSchema.optional() });
5875
- const canvasMutationRequestContextSchema = z.strictObject({
5876
- fingerprint: z.string().regex(/^[a-f0-9]{64}$/u),
5877
- revisionPolicy: z.enum(["strict", "rebase"]),
5878
- copiedNodeIds: copiedNodeIdsSchema.optional()
5879
- });
5880
- z.object({
5881
- canvasId: z.uuid(),
5882
- mutationId: z.uuid(),
5883
- documentFormatVersion: canvasDocumentFormatSchema,
5884
- baseVersion: z.number().int().positive(),
5885
- operations: z.array(canvasOperationSchema).min(1),
5886
- requestContext: canvasMutationRequestContextSchema.optional(),
5887
- writeScope: canvasWriteScopeSchema.optional()
5888
- }).superRefine((input, context) => {
5889
- refuseUnsafeWriterFormat(input.documentFormatVersion, input.operations.every((operation) => CANVAS_OPERATION_WRITES[operation.op] === "names") ? "names" : "whole", context);
5890
- });
5891
- const applyCanvasOperationsOutputSchema = z.object({
5892
- canvasId: z.uuid(),
5893
- mutationId: z.uuid(),
5894
- previousVersion: z.number().int().positive(),
5895
- version: z.number().int().positive(),
5896
- operations: z.array(canvasOperationSchema),
5897
- insertedNodeIds: z.array(nodeIdSchema$2),
5898
- changedNodeIds: z.array(nodeIdSchema$2),
5899
- removedNodeIds: z.array(nodeIdSchema$2),
5900
- boxes: z.record(nodeIdSchema$2, canvasReceiptBoxSchema),
5901
- affectedBounds: writableBoxSchema.nullable(),
5902
- copiedNodeIds: copiedNodeIdsSchema.optional(),
5903
- next: z.array(z.string().min(1))
5904
- });
5905
- z.strictObject({
5906
- canvasId: z.uuid(),
5907
- mutationId: z.uuid(),
5908
- fingerprint: canvasMutationRequestContextSchema.shape.fingerprint
5909
- });
5910
- z.discriminatedUnion("state", [z.strictObject({ state: z.literal("not-found") }), z.strictObject({
5911
- state: z.literal("committed"),
5912
- /** `url` is the canvas's web address. An API older than the field answers without it. */
5913
- result: applyCanvasOperationsOutputSchema.extend({ url: z.url().optional() })
5914
- })]);
5915
6041
  const LIMITS = {
5916
6042
  nodes: 1e3,
5917
6043
  fields: 20,
@@ -6299,7 +6425,9 @@ const canvasDuplicatePreparationSchema = z.strictObject({
6299
6425
  destination: z.discriminatedUnion("kind", [z.strictObject({ kind: z.literal("native") }), z.strictObject({
6300
6426
  kind: z.literal("inside"),
6301
6427
  parentId: nodeId$2
6302
- })])
6428
+ })]),
6429
+ /** World placement for a set of top-level copies. Absent, the native copy offset stands. */
6430
+ placement: canvasPlacementIntentSchema.optional()
6303
6431
  });
6304
6432
  const canvasPreparationRequestSchema = z.discriminatedUnion("kind", [
6305
6433
  z.strictObject({
@@ -6862,6 +6990,10 @@ z.discriminatedUnion("purpose", [
6862
6990
  outputPrefix: z.string().min(1).max(MAX_STORAGE_KEY_LENGTH)
6863
6991
  })
6864
6992
  ]);
6993
+ const snapshotPlacementSchema = z.object({
6994
+ x: z.number(),
6995
+ y: z.number()
6996
+ });
6865
6997
  z.object({
6866
6998
  jobId: z.uuid(),
6867
6999
  loadedVersion: z.number().int().positive(),
@@ -6882,14 +7014,18 @@ z.object({
6882
7014
  viewport: z.object({
6883
7015
  width: z.number().int().positive(),
6884
7016
  height: z.number().int().positive()
6885
- })
7017
+ }),
7018
+ /** Where the page's search put the captured screen, at `loadedVersion`. */
7019
+ placement: snapshotPlacementSchema.optional()
6886
7020
  }).optional()
6887
7021
  });
6888
7022
  z.object({ accepted: z.literal(true) });
6889
7023
  z.object({
6890
7024
  jobId: z.uuid(),
6891
7025
  loadedVersion: z.number().int().positive(),
6892
- 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()
6893
7029
  });
6894
7030
  z.object({ accepted: z.literal(true) });
6895
7031
  z.object({
@@ -6902,7 +7038,9 @@ z.object({
6902
7038
  viewport: z.object({
6903
7039
  width: z.number().int().positive(),
6904
7040
  height: z.number().int().positive()
6905
- })
7041
+ }),
7042
+ /** Where the editor's search for a capture below this recording puts the screen. */
7043
+ placement: snapshotPlacementSchema.optional()
6906
7044
  });
6907
7045
  z.object({
6908
7046
  jobId: z.uuid(),
@@ -7794,7 +7932,11 @@ const desktopRequestSchema = z.object({
7794
7932
  const desktopMutationIntentSchema = z.object({
7795
7933
  mutationId: id$2,
7796
7934
  canvasId: id$2,
7797
- procedure: z.enum(["canvas.applyOperations", "canvas.render.importSource"]),
7935
+ procedure: z.enum([
7936
+ "canvas.applyOperations",
7937
+ "canvas.render.importSource",
7938
+ "canvas.applyEdits"
7939
+ ]),
7798
7940
  input: z.record(z.string(), z.unknown()),
7799
7941
  state: z.enum([
7800
7942
  "recorded",
@@ -8352,7 +8494,9 @@ z.object({
8352
8494
  z.object({});
8353
8495
  z.object({
8354
8496
  items: z.array(agentTokenSchema),
8355
- 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()
8356
8500
  });
8357
8501
  z.object({ tokenId: z.uuid() });
8358
8502
  z.object({
@@ -8365,6 +8509,44 @@ z.discriminatedUnion("method", [z.object({ method: z.literal("token") }), z.obje
8365
8509
  clientId: z.string().min(1),
8366
8510
  scope: z.literal("openid")
8367
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) });
8368
8550
  const personSchema = z.object({
8369
8551
  id: z.uuid(),
8370
8552
  preparedCanvasId: z.uuid(),
@@ -10532,7 +10714,7 @@ const startStallWatch = (caller, idleMs = STALL_MS) => {
10532
10714
  };
10533
10715
 
10534
10716
  //#endregion
10535
- //#region ../../packages/sdk/dist/capture-client.client-MxFryzJG.mjs
10717
+ //#region ../../packages/sdk/dist/capture-client.client-BkUyb4Kt.mjs
10536
10718
  const line = (text) => `Enhance: ${text}\n`;
10537
10719
  /** A left-out capture by its journey and step, or by its test when it could not be read at all. */
10538
10720
  const leftOutName = (leftOut, attempts) => {
@@ -11446,7 +11628,7 @@ const prepareMutation = (command, commandPath, procedurePath, input) => {
11446
11628
  command.hook("preAction", (actionCommand) => {
11447
11629
  const candidate = actionCommand.getOptionValue("clientToken");
11448
11630
  const parsed = z.uuid().nullable().safeParse(candidate ?? null);
11449
- 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.");
11450
11632
  input.mutationKey.select(parsed.data, commandPath[0] === "fixture");
11451
11633
  });
11452
11634
  };
@@ -11837,6 +12019,19 @@ const registerFixtureProgram = (program, composites, output) => {
11837
12019
  registerWorldFixture(fixture, composites.world, output);
11838
12020
  };
11839
12021
 
12022
+ //#endregion
12023
+ //#region src/infrastructure/guide.program.ts
12024
+ /** `canvas guide`: the design skill of the one source, for an agent `setup` gave no skills. */
12025
+ const registerCanvasGuideProgram = (program, input) => {
12026
+ const canvas = program.commands.find((command) => command.name() === "canvas");
12027
+ if (canvas === void 0) throw new TypeError("The canvas commands are registered first.");
12028
+ canvas.command("guide").description("How to design on a canvas: the design-on-canvas skill.").action(() => {
12029
+ const design = input.skills().find(({ skill }) => skill === "design-on-canvas");
12030
+ if (design === void 0) throw new TypeError("The skills hold no design-on-canvas.");
12031
+ input.write(design.body);
12032
+ });
12033
+ };
12034
+
11840
12035
  //#endregion
11841
12036
  //#region src/infrastructure/input-help.program.ts
11842
12037
  /** The longest help a command made from an API procedure may print, and any other command. */
@@ -12148,7 +12343,7 @@ const registerRecordingProgram = (program, input) => {
12148
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) => {
12149
12344
  const token = z.uuid().nullable().safeParse(options.clientToken ?? null);
12150
12345
  const recordingId = z.uuid().safeParse(options.recordingId);
12151
- 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.");
12152
12347
  input.output.result(await input.invocation.invoke({
12153
12348
  capability: input.catalog.one("recording.snapshot"),
12154
12349
  arguments: {
@@ -12373,6 +12568,12 @@ const registerUtilityPrograms = (program, input, catalog) => {
12373
12568
  catalog,
12374
12569
  output: input.output
12375
12570
  });
12571
+ registerCanvasGuideProgram(program, {
12572
+ skills: () => toolSkillTextsOf(input.commandName, input.machine),
12573
+ write: (text) => {
12574
+ process.stdout.write(text);
12575
+ }
12576
+ });
12376
12577
  };
12377
12578
  /**
12378
12579
  * Whether the command that ran answered with nothing. trpc-cli prints no line for such an answer
@@ -12600,7 +12801,8 @@ const failureSchema = appErrorSchema$1.omit({ fields: true }).extend({
12600
12801
  fields: z.array(z.object({
12601
12802
  path: z.string(),
12602
12803
  message: z.string()
12603
- })).optional()
12804
+ })).optional(),
12805
+ cause: z.string().optional()
12604
12806
  });
12605
12807
  const parsedFailure = (value) => {
12606
12808
  try {
@@ -12611,7 +12813,8 @@ const parsedFailure = (value) => {
12611
12813
  code: result.data.code,
12612
12814
  message: result.data.message,
12613
12815
  remediation: result.data.remediation,
12614
- ...result.data.fields !== void 0 && { fields: result.data.fields }
12816
+ ...result.data.fields !== void 0 && { fields: result.data.fields },
12817
+ ...result.data.cause !== void 0 && { cause: result.data.cause }
12615
12818
  };
12616
12819
  } catch {
12617
12820
  return null;
@@ -12694,7 +12897,7 @@ const main = async () => {
12694
12897
  const remote = createHttpRemoteAdapter(config.apiUrl, credentials, mutationKey);
12695
12898
  const cli = createCliProgram({
12696
12899
  apiUrl: config.apiUrl,
12697
- version: "0.1.167",
12900
+ version: "0.1.170",
12698
12901
  credentials,
12699
12902
  remote,
12700
12903
  mutationKey,