@enhance-eng/enhance 0.1.174 → 0.1.177

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.
@@ -489,6 +489,10 @@ const paginationSchema = z.object({
489
489
  cursor: z.string().nullable().default(null),
490
490
  limit: z.number().int().min(1).max(MAX_PAGE_SIZE$1).default(DEFAULT_PAGE_SIZE$1)
491
491
  });
492
+ const pageSchema = (item) => z.object({
493
+ items: z.array(item),
494
+ nextCursor: z.string().nullable()
495
+ });
492
496
  /**
493
497
  * A collection bounded by human behaviour rather than by a cursor: every row up to a
494
498
  * ceiling, and a flag saying the ceiling was hit.
@@ -634,6 +638,14 @@ const collectionSchema = z.union([
634
638
  z.literal("everything"),
635
639
  z.uuid()
636
640
  ]);
641
+ /** Cards in one page of the canvas list; the dashboard asks for fewer. */
642
+ const MAX_CANVAS_PAGE = 200;
643
+ const MAX_CANVAS_CURSOR_LENGTH = 4096;
644
+ const canvasListSortSchema = z.enum([
645
+ "opened",
646
+ "created",
647
+ "name"
648
+ ]);
637
649
  const listCanvasesInputSchema = z.object({
638
650
  collection: collectionSchema.default("own"),
639
651
  title: z.string().trim().min(1).optional().describe("Title text to match before returning canvas ids."),
@@ -645,7 +657,13 @@ const listCanvasesInputSchema = z.object({
645
657
  "mine",
646
658
  "shared"
647
659
  ]).default("all"),
648
- hasUnresolved: z.boolean().default(false)
660
+ hasUnresolved: z.boolean().default(false),
661
+ /** A page of at most this many cards. Without it the whole collection comes back. */
662
+ limit: z.number().int().min(1).max(MAX_CANVAS_PAGE).optional(),
663
+ /** The dashboard's orders. Without it, latest activity first, the order agents read. */
664
+ sort: canvasListSortSchema.optional().describe("Order as the dashboard does: opened (yours first), created (newest first) or name. Omit for latest activity first."),
665
+ /** The `nextCursor` of the page before, in the same order. */
666
+ cursor: z.string().min(1).max(MAX_CANVAS_CURSOR_LENGTH).optional()
649
667
  });
650
668
  const canvasCardBaseSchema = linkedCanvasSchema.extend({
651
669
  screenCount: z.number().int().min(0),
@@ -657,7 +675,8 @@ const canvasCardSchema = z.union([canvasCardBaseSchema.extend({ thumbnail: canva
657
675
  thumbnail: z.null(),
658
676
  thumbnailFallbackReason: thumbnailFallbackReasonSchema
659
677
  })]);
660
- const listCanvasesOutputSchema = cappedSchema(canvasCardSchema);
678
+ /** A page of cards: `nextCursor` is where the next starts, `null` on the last page. */
679
+ const listCanvasesOutputSchema = pageSchema(canvasCardSchema).extend({ truncated: z.boolean() });
661
680
  const renameCanvasInputSchema = z.object({
662
681
  canvasId: z.uuid(),
663
682
  title: z.string().trim().min(1)
@@ -1031,6 +1050,12 @@ const canvasFlowOffsetSchema = z.object({
1031
1050
  x: canvasNumberSchema,
1032
1051
  y: canvasNumberSchema
1033
1052
  });
1053
+ /**
1054
+ * What an alignment does when its content overflows the box it aligns in: `safe` falls back to the
1055
+ * start, `unsafe` keeps the alignment and lets the content overflow both sides, as CSS's overflow
1056
+ * position keywords do. Without one an alignment keeps CSS's default for that property.
1057
+ */
1058
+ const canvasOverflowPositionSchema = z.enum(["safe", "unsafe"]);
1034
1059
  const canvasFlexLayoutSchema = z.object({
1035
1060
  direction: z.enum(["row", "column"]),
1036
1061
  alignItems: z.enum([
@@ -1063,7 +1088,13 @@ const canvasFlexLayoutSchema = z.object({
1063
1088
  wrap: z.enum(["nowrap", "wrap"]).optional(),
1064
1089
  gridColumns: z.number().int().positive().optional(),
1065
1090
  gridAutoRepeat: canvasGridAutoRepeatSchema.optional(),
1066
- padding: canvasFlexPaddingSchema
1091
+ padding: canvasFlexPaddingSchema,
1092
+ /** The overflow position of each alignment that names one, by the alignment it qualifies. */
1093
+ overflowPositions: z.object({
1094
+ justifyContent: canvasOverflowPositionSchema.optional(),
1095
+ alignItems: canvasOverflowPositionSchema.optional(),
1096
+ alignContent: canvasOverflowPositionSchema.optional()
1097
+ }).strict().optional()
1067
1098
  }).strict();
1068
1099
  /**
1069
1100
  * What conversion recorded about the source box of an inline-level frame that the frame itself
@@ -1125,6 +1156,8 @@ const canvasNodeLayoutSchema = z.object({
1125
1156
  "end",
1126
1157
  "stretch"
1127
1158
  ]).optional(),
1159
+ /** The overflow position `alignSelf` names, when it names one. */
1160
+ alignSelfOverflowPosition: canvasOverflowPositionSchema.optional(),
1128
1161
  flexGrow: nonNegativeCanvasNumberSchema.optional(),
1129
1162
  flexShrink: nonNegativeCanvasNumberSchema.optional(),
1130
1163
  flexBasis: z.union([
@@ -3354,6 +3387,24 @@ const editCanvasOutputSchema = z.discriminatedUnion("outcome", [applyCanvasOpera
3354
3387
  version: z.number().int().positive()
3355
3388
  })]);
3356
3389
 
3390
+ //#endregion
3391
+ //#region ../../packages/contract/src/canvas/canvas-frozen-through.lib.ts
3392
+ /**
3393
+ * Frozen through, so every reader of one value can share it and none can change it for another.
3394
+ * Walked with a stack, not by recursion: rich text can nest deeper than the call stack.
3395
+ */
3396
+ const frozenThrough = (value) => {
3397
+ const pending = [value];
3398
+ while (pending.length > 0) {
3399
+ const next = pending.pop();
3400
+ if (next !== null && typeof next === "object" && !Object.isFrozen(next)) {
3401
+ Object.freeze(next);
3402
+ for (const child of Object.values(next)) pending.push(child);
3403
+ }
3404
+ }
3405
+ return value;
3406
+ };
3407
+
3357
3408
  //#endregion
3358
3409
  //#region ../../packages/contract/src/canvas/canvas-text-links.lib.ts
3359
3410
  const FORBIDDEN_DOMAIN_CHARACTERS = /* @__PURE__ */ new Set([
@@ -3497,6 +3548,8 @@ const characterFormattingSchema = canvasTextParagraphSchema.pick({
3497
3548
  decorationBlendMode: canvasTypographySchema.shape.decoration.shape.blendMode,
3498
3549
  backgroundBlendMode: canvasBlendModeSchema.optional()
3499
3550
  }).strip();
3551
+ const optionalParagraphSchema = canvasTextParagraphSchema.optional();
3552
+ const optionalTextStyleSchema = canvasTextStyleBindingSchema.optional();
3500
3553
  const safeHref = (value) => typeof value === "string" && isCanvasRichTextHref(value) ? value : void 0;
3501
3554
  const richStylesOf = (value) => {
3502
3555
  if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
@@ -3588,9 +3641,9 @@ const richNodeOf = (value, children) => {
3588
3641
  const values = Reflect.get(value, "children");
3589
3642
  const styles = richStylesOf(Reflect.get(value, "styles"));
3590
3643
  const fills = fillsSchema.safeParse(Reflect.get(value, "fills"));
3591
- const paragraph = canvasTextParagraphSchema.optional().safeParse(Reflect.get(value, "paragraph"));
3644
+ const paragraph = optionalParagraphSchema.safeParse(Reflect.get(value, "paragraph"));
3592
3645
  const formatting = characterFormattingSchema.safeParse(value);
3593
- const textStyle = canvasTextStyleBindingSchema.optional().safeParse(Reflect.get(value, "textStyle"));
3646
+ const textStyle = optionalTextStyleSchema.safeParse(Reflect.get(value, "textStyle"));
3594
3647
  if (styles === null || !fills.success || !paragraph.success || !formatting.success || !textStyle.success || !Array.isArray(values)) return null;
3595
3648
  const href = safeHref(Reflect.get(value, "href"));
3596
3649
  return {
@@ -3617,14 +3670,16 @@ const canvasRichTextValueOf = (nodes) => {
3617
3670
  }
3618
3671
  return text.join("");
3619
3672
  };
3620
- const canvasRichTextOf = (node) => {
3621
- const props = node.props;
3622
- if (props === void 0 || !Array.isArray(props["richText"])) return [];
3623
- const rich = richChildrenOf(props["richText"]);
3624
- if (rich === null) return [];
3625
- const text = props["text"];
3626
- return canvasRichTextValueOf(rich) === text ? rich : [];
3673
+ const NO_RICH_TEXT = Object.freeze([]);
3674
+ /** Readings of frozen props, which an edit replaces: a record that can still change is read afresh. */
3675
+ const richTextRead = /* @__PURE__ */ new WeakMap();
3676
+ const richTextIn = (props) => {
3677
+ const rich = Array.isArray(props["richText"]) ? richChildrenOf(props["richText"]) : null;
3678
+ const read = rich !== null && canvasRichTextValueOf(rich) === props["text"] ? frozenThrough(rich) : NO_RICH_TEXT;
3679
+ if (Object.isFrozen(props)) richTextRead.set(props, read);
3680
+ return read;
3627
3681
  };
3682
+ const canvasRichTextOf = ({ props }) => props === void 0 ? NO_RICH_TEXT : richTextRead.get(props) ?? richTextIn(props);
3628
3683
  const hasCanvasRichTextPaints = (node) => {
3629
3684
  const pending = [...canvasRichTextOf(node)];
3630
3685
  while (pending.length > 0) {
@@ -9593,6 +9648,33 @@ const deleteRecordingOutputSchema = z.object({
9593
9648
  detachedScreenCount: z.number().int().min(0)
9594
9649
  });
9595
9650
 
9651
+ //#endregion
9652
+ //#region ../../packages/contract/src/recording/secret-field.lib.ts
9653
+ /**
9654
+ * Which form fields a capture never stores as they appear: a card or sign-in secret, decided by
9655
+ * what the page declares the field is for, as browsers decide what to autofill, and every field
9656
+ * of a frame from another site that its page lets take payments.
9657
+ */
9658
+ /** The `autocomplete` purposes of a card or a sign-in secret. */
9659
+ const SECRET_PURPOSES = /* @__PURE__ */ new Set([
9660
+ "cc-number",
9661
+ "cc-csc",
9662
+ "cc-exp",
9663
+ "cc-exp-month",
9664
+ "cc-exp-year",
9665
+ "cc-name",
9666
+ "cc-given-name",
9667
+ "cc-additional-name",
9668
+ "cc-family-name",
9669
+ "one-time-code",
9670
+ "current-password",
9671
+ "new-password"
9672
+ ]);
9673
+ /** The fields a picture paints over: those a page declares secret, which a selector can name. */
9674
+ const SECRET_FIELD_SELECTOR = ["input[type=\"password\" i]", ...[...SECRET_PURPOSES].map((purpose) => `[autocomplete~="${purpose}" i]`)].join(", ");
9675
+ /** The selects a capture blocks: those a page declares a card or sign-in secret. */
9676
+ const SECRET_SELECT_SELECTOR = [...SECRET_PURPOSES].map((purpose) => `select[autocomplete~="${purpose}" i]`).join(", ");
9677
+
9596
9678
  //#endregion
9597
9679
  //#region ../../packages/contract/src/screen/screen.schema.ts
9598
9680
  const createScreenInputSchema = z.object({
@@ -9983,6 +10065,10 @@ const clientRenderFailureDetailsSchema = z.strictObject({
9983
10065
  "export-image-unreachable",
9984
10066
  "export-image-not-an-image",
9985
10067
  "export-font-unread",
10068
+ "export-drawn-by-server",
10069
+ "export-picture-refused",
10070
+ "export-picture-blank",
10071
+ "export-text-unaligned",
9986
10072
  "clipboard-unavailable",
9987
10073
  "clipboard-image-pending",
9988
10074
  "clipboard-image-unavailable",
@@ -10032,6 +10118,23 @@ const clientRenderFailureDetailsSchema = z.strictObject({
10032
10118
  resourceCount: count$1.optional(),
10033
10119
  /** The status a refused export read answered with. */
10034
10120
  httpStatus: z.number().int().min(HTTP_STATUS_LOWEST).max(HTTP_STATUS_HIGHEST).optional(),
10121
+ /** The browser engine that drew, or could not draw, an image export. */
10122
+ browser: z.strictObject({
10123
+ engine: z.enum([
10124
+ "chromium",
10125
+ "firefox",
10126
+ "webkit",
10127
+ "unknown"
10128
+ ]),
10129
+ version: z.number().int().min(0).max(MAX_COUNT)
10130
+ }).optional(),
10131
+ /** Why the browser gave no picture back for `export-picture-refused`. */
10132
+ refusal: z.enum([
10133
+ "read-back",
10134
+ "load",
10135
+ "memory",
10136
+ "encode"
10137
+ ]).optional(),
10035
10138
  deliveryGap: z.strictObject({
10036
10139
  refused: count$1,
10037
10140
  expired: count$1,
@@ -10102,7 +10205,8 @@ const CANVAS_SYNC_REPORTS = [
10102
10205
  "retrying",
10103
10206
  "recovery",
10104
10207
  "trace",
10105
- "update-required"
10208
+ "update-required",
10209
+ "parts-mismatch"
10106
10210
  ];
10107
10211
  /** How a failed document read was answered, on the report of one worth a look. */
10108
10212
  const CANVAS_SYNC_READ_OUTCOMES = [
@@ -10314,8 +10418,14 @@ const clientSaveIncidentInputSchema = z.strictObject({
10314
10418
  readOutcome: z.enum(CANVAS_SYNC_READ_OUTCOMES).optional(),
10315
10419
  status: z.enum(CANVAS_SYNC_REPORT_STATUSES).optional(),
10316
10420
  episode: z.enum(CANVAS_SYNC_EPISODES).optional(),
10421
+ /** On a `parts-mismatch` report: the parts its head names and the parts found, counts only. */
10422
+ partsNamed: z.number().int().nonnegative().optional(),
10423
+ partsFound: z.number().int().nonnegative().optional(),
10317
10424
  trace: canvasSaveTraceSchema.optional()
10318
10425
  });
10426
+
10427
+ //#endregion
10428
+ //#region ../../packages/contract/src/shared/client-save-output.schema.ts
10319
10429
  /** Whether the API's analytics destination took the record. Older clients ignore it. */
10320
10430
  const CANVAS_SAVE_ANALYTICS_STATES = [
10321
10431
  "delivered",
@@ -10954,7 +11064,9 @@ const SKILLS = {
10954
11064
  description: "Put the screens a thread is changing onto an Enhance canvas as editable frames and return the link. Use when asked to capture, share or review screens, or to put work on a canvas. Also applies whenever a thread has changed how a screen looks: when that work is done, offer once, in one line, to put the changed screens on an Enhance canvas for review, and capture only on a yes.",
10955
11065
  body: ({ call, two, command, line }) => `# Capture screens to Enhance
10956
11066
 
10957
- Put each screen this thread is changing onto one Enhance canvas as an editable frame, and return the canvas link.
11067
+ Put each screen this thread is changing onto one Enhance canvas as an editable frame, and return the canvas link. The person should see their first screen within a couple of minutes and the whole set within five.
11068
+
11069
+ A capture is cheap and can be redone, so capture each page as soon as it is in the state you want, as it is, at whatever size it has. When a state needs data, such as an account or a finished step, make it yourself where the app runs, with its seed script or its own API, rather than asking the person. Place each page as soon as you capture it, and give the person the link with the first one. For a whole flow, walk it once and capture as you go.
10958
11070
 
10959
11071
  ${two({
10960
11072
  cli: `## Commands
@@ -12672,7 +12784,7 @@ const canvasPrototypeOutputSchema = z.strictObject({
12672
12784
  //#region src/application/capture-page.schema.ts
12673
12785
  const canvasCapturePageCapabilityInputSchema = z.strictObject({
12674
12786
  ...canvasRenderRequestSchema.pick({ canvasRef: true }).shape,
12675
- waitMs: canvasRenderRequestSchema.shape.waitMs.describe("How long this call waits for the page to become editable, in milliseconds: at most 120000. Call again with the same captureId to keep waiting."),
12787
+ waitMs: canvasRenderRequestSchema.shape.waitMs.describe("How long this call waits for the page to become editable, in milliseconds: at most 120000. With 0 it answers as soon as the picture is on the canvas. Call again with the same input and client token to keep waiting."),
12676
12788
  captureId: z.uuid().optional().describe("The captureId the snippet answered with. Omit it to get a snippet to run in the page."),
12677
12789
  title: z.string().optional().describe("Optional: a name for the frame. Without it, or when it is blank, the frame takes the captured page's own title."),
12678
12790
  extent: z.enum(["full-page", "viewport"]).default("full-page").describe("What the snippet captures: the whole page, or only the visible window."),
@@ -12684,7 +12796,7 @@ const canvasCapturePageCapabilityInputSchema = z.strictObject({
12684
12796
  width: z.number().positive(),
12685
12797
  height: z.number().positive()
12686
12798
  }).optional().describe("Optional: the width and height the snippet answered, for the picture shown while the page converts. Without it that picture is 1280 by 800. The frame always takes the captured page's own size."),
12687
- baseVersion: z.number().int().positive().optional().describe("The canvas version you read; the frame is saved as one change at it.")
12799
+ baseVersion: z.number().int().positive().optional().describe("Optional: the canvas version you planned against. A placement planned before the canvas was restored is refused. A placement never needs the version of another.")
12688
12800
  });
12689
12801
  const canvasCapturePageInputSchema = canvasCapturePageCapabilityInputSchema.extend({ clientToken: retryClientTokenSchema });
12690
12802
  const canvasCapturePageOutputSchema = z.strictObject({
@@ -12710,7 +12822,7 @@ const canvasCapturePageOutputSchema = z.strictObject({
12710
12822
  width: z.number(),
12711
12823
  height: z.number()
12712
12824
  }).nullable()
12713
- }).nullable().describe("The editable frame, once placed; version is the canvas version for your next write, and box is where the canvas stores the frame, which tells you where to put the next capture."),
12825
+ }).nullable().describe("The editable frame, once placed; version is the canvas version that saved it, and box is where the canvas stores the frame, which tells you where to put the next capture."),
12714
12826
  url: z.url().nullable().describe("The full web address of the canvas, as the API answered it, once the page is placed. Give the person this link; never build one from the id."),
12715
12827
  failure: canvasRenderFailureSchema.nullable(),
12716
12828
  warningCount: z.number().int().nonnegative(),
@@ -12767,6 +12879,7 @@ const canvasWriteHtmlCapabilityInputSchema = z.object({
12767
12879
  selectionNodeIds: z.array(z.string().min(1)).optional().describe("Selected node IDs from the canvas URL; restrict the destination to this selection."),
12768
12880
  targetNodeId: z.string().min(1).describe("Stable container id for insert-children, or subtree root id for replace."),
12769
12881
  mode: z.enum(["insert-children", "replace"]).describe("Insert the compiled group inside the target, or replace the target subtree."),
12882
+ placement: canvasInsertHtmlInputSchema.shape.placement,
12770
12883
  html: z.string().min(1).describe("Exactly one safe top-level HTML/CSS visual group to compile into editable nodes."),
12771
12884
  idPrefix: z.string().min(1).optional().describe("Optional namespace for generated IDs. Choose a fresh prefix for each new import or replacement; reuse only for an identical retry."),
12772
12885
  baseVersion: z.number().int().positive(),
@@ -14684,9 +14797,9 @@ const CANVAS_CAPABILITY_SPECS = [
14684
14797
  //#region src/infrastructure/canvas-conversion-capability.consts.ts
14685
14798
  /** The page capture's calls, in order. Help and the hosted assistants' tool both print them. */
14686
14799
  const CAPTURE_PAGE_CALLS = [
14687
- "Call {canvas.capturePage} with canvasRef alone: the answer has a snippet, which is a script, and a 15-minute pass. The snippet holds the pass: hand it to your browser from a file or a variable, and keep it out of what you print.",
14800
+ "Call {canvas.capturePage} with canvasRef alone: the answer has a snippet, which is a script, and a 24-hour pass. The snippet holds the pass: hand it to your browser from a file or a variable, and keep it out of what you print.",
14688
14801
  "Open the page yourself and run the snippet in it, with Playwright's page.evaluate or your browser's JavaScript tool; it answers with captureId, title, width, height and issues (the page itself never passes through you). The same snippet works on any number of pages while the pass lives. With no browser to drive, install Playwright in a folder of your own outside the project: npm install playwright, then npx playwright install chromium.",
14689
- "Call {canvas.capturePage} again with captureId, size: { width, height } from the snippet's answer, at: { x, y } (the frame's top-left corner, anywhere on the canvas) and the baseVersion you read. Every placement moves the canvas on: its answer's frame.version is the next placement's baseVersion."
14802
+ "Call {canvas.capturePage} again with captureId, size: { width, height } from the snippet's answer and at: { x, y } (the frame's top-left corner, anywhere on the canvas). Place each page as soon as you capture it, with waitMs: 0: its picture lands at once and becomes editable meanwhile, and placements never wait on one another, so give the person the canvas link from the first answer. Once every page is placed, repeat each placement with the same input and client token and a longer waitMs to read its editable frame; the repeats may run at the same time."
14690
14803
  ];
14691
14804
  const CANVAS_CONVERSION_CAPABILITY_SPECS = [
14692
14805
  {
@@ -14768,8 +14881,7 @@ const CANVAS_CONVERSION_CAPABILITY_SPECS = [
14768
14881
  x: 5e3,
14769
14882
  y: 4e3
14770
14883
  },
14771
- baseVersion: 1,
14772
- waitMs: 1500
14884
+ waitMs: 0
14773
14885
  },
14774
14886
  earlierAnswers: CAPTURE_PAGE_CALLS,
14775
14887
  outputExample: {
@@ -16085,7 +16197,8 @@ const createCanvasRouter = (handlers, webOrigin) => trpcRouter({
16085
16197
  }));
16086
16198
  return {
16087
16199
  items: page.items.map((view) => toCanvasCardContract(view, webOrigin)),
16088
- truncated: page.truncated
16200
+ truncated: page.truncated,
16201
+ nextCursor: page.nextCursor
16089
16202
  };
16090
16203
  }),
16091
16204
  rename: canvasOwnerProcedure.input(renameCanvasInputSchema).output(canvasSchema).mutation(async ({ input, ctx }) => {
@@ -17788,9 +17901,9 @@ const createCanvasWalkthroughRouter = (handlers) => trpcRouter({ copyWalkthrough
17788
17901
 
17789
17902
  //#endregion
17790
17903
  //#region ../api/src/shared/auth/capture-pass.lib.ts
17791
- const CAPTURE_PASS_MINUTES = 15;
17792
- const MINUTE_MS = 6e4;
17793
- const CAPTURE_PASS_LIFETIME_MS = CAPTURE_PASS_MINUTES * MINUTE_MS;
17904
+ const CAPTURE_PASS_HOURS = 24;
17905
+ const HOUR_MS = 36e5;
17906
+ const CAPTURE_PASS_LIFETIME_MS = CAPTURE_PASS_HOURS * HOUR_MS;
17794
17907
  /** A pass's claims, read back only from a pass the API sealed. */
17795
17908
  const capturePassClaimsSchema = z.strictObject({
17796
17909
  personId: z.uuid(),
@@ -17807,7 +17920,7 @@ const capturePassClaimsSchema = z.strictObject({
17807
17920
  * Issues the capture pass an agent hands to a page. Only an agent that may edit the canvas gets
17808
17921
  * one, and the pass names that agent, so revoking the agent ends it.
17809
17922
  */
17810
- const capturePassRouter = (options) => trpcRouter({ create: agentCanvasEditorProcedure.meta({ description: "Issue a 15-minute pass that lets the capture script store captures of pages for this canvas, and nothing else." }).input(createCapturePassInputSchema).output(createCapturePassOutputSchema).mutation(({ input, ctx }) => {
17923
+ const capturePassRouter = (options) => trpcRouter({ create: agentCanvasEditorProcedure.meta({ description: "Issue a 24-hour pass that lets the capture script store captures of pages for this canvas, and nothing else." }).input(createCapturePassInputSchema).output(createCapturePassOutputSchema).mutation(({ input, ctx }) => {
17811
17924
  if (ctx.viewer.kind !== "agent") throw toTrpcError(appError("UNAUTHORIZED", "this call needs an agent token"));
17812
17925
  const settings = options.capturePass;
17813
17926
  if (settings === void 0) throw toTrpcError(appError("INTERNAL", "this API issues no capture passes"));
package/dist/main.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
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-BgqE7RXo.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-25kXQXyA.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-DXXUW_-R.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-C5xbjvAa.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";
@@ -120,6 +120,24 @@ const canvasTextDecorationDeclarations = (decoration) => ({
120
120
  "text-decoration-skip-ink": decoration.skipInk ?? "auto"
121
121
  });
122
122
 
123
+ //#endregion
124
+ //#region ../../packages/contract/src/canvas/canvas-overflow-position.lib.ts
125
+ /** CSS takes an overflow position only on an alignment that places content at a position. */
126
+ const POSITIONAL_ALIGNMENTS = /* @__PURE__ */ new Set([
127
+ "start",
128
+ "end",
129
+ "center",
130
+ "flex-start",
131
+ "flex-end",
132
+ "self-start",
133
+ "self-end"
134
+ ]);
135
+ /**
136
+ * An alignment's CSS value with the overflow position its layout names, such as `safe center`. A
137
+ * distribution, `stretch` or a baseline takes none, so it keeps its value.
138
+ */
139
+ const canvasAlignmentCss = (value, position) => position !== void 0 && POSITIONAL_ALIGNMENTS.has(value) ? `${position} ${value}` : value;
140
+
123
141
  //#endregion
124
142
  //#region ../../packages/contract/src/recording/event-stream.lib.ts
125
143
  /**
@@ -1030,9 +1048,9 @@ const containerCss = (node) => {
1030
1048
  ...columns !== void 0 && { "grid-template-columns": columns },
1031
1049
  ...container.direction !== void 0 && { "flex-direction": container.direction },
1032
1050
  ...container.wrap !== void 0 && { "flex-wrap": container.wrap },
1033
- ...container.alignItems !== void 0 && { "align-items": aligned(container.alignItems) },
1034
- ...container.alignContent !== void 0 && { "align-content": aligned(container.alignContent) },
1035
- ...container.justifyContent !== void 0 && { "justify-content": aligned(container.justifyContent) },
1051
+ ...container.alignItems !== void 0 && { "align-items": canvasAlignmentCss(aligned(container.alignItems), container.overflowPositions?.alignItems) },
1052
+ ...container.alignContent !== void 0 && { "align-content": canvasAlignmentCss(aligned(container.alignContent), container.overflowPositions?.alignContent) },
1053
+ ...container.justifyContent !== void 0 && { "justify-content": canvasAlignmentCss(aligned(container.justifyContent), container.overflowPositions?.justifyContent) },
1036
1054
  ...rowGap !== void 0 && { "row-gap": rowGap },
1037
1055
  ...columnGap !== void 0 && { "column-gap": columnGap },
1038
1056
  ...Object.fromEntries(Object.entries(container.padding ?? {}).map(([side, value]) => [`padding-${side}`, value]))
@@ -1085,7 +1103,7 @@ const placementCss = (node, document) => {
1085
1103
  ...sizeCss("width", layout.horizontal, isFlow && (main === "horizontal" || alignment === "stretch")),
1086
1104
  ...sizeCss("height", layout.vertical, isFlow && (main === "vertical" || alignment === "stretch")),
1087
1105
  ...isFlow && main !== void 0 && flowCss(node, primary),
1088
- ...isFlow && alignment !== void 0 && { "align-self": alignment },
1106
+ ...isFlow && alignment !== void 0 && { "align-self": canvasAlignmentCss(alignment, layout.alignSelfOverflowPosition) },
1089
1107
  ...isFlow && fillMinimumCss(node, main),
1090
1108
  ...alignment === "stretch" && cross?.mode === "hug" && main !== void 0 && { [main === "horizontal" ? "height" : "width"]: "auto" },
1091
1109
  ...layout.aspectRatio !== void 0 && { "aspect-ratio": layout.aspectRatio },
@@ -1891,7 +1909,7 @@ const registerCanvasProgram = (program, input) => {
1891
1909
  };
1892
1910
 
1893
1911
  //#endregion
1894
- //#region ../../packages/sdk/dist/stall-watch.lib-Dk5eJmyQ.mjs
1912
+ //#region ../../packages/sdk/dist/stall-watch.lib-CjZG1Ibk.mjs
1895
1913
  const CAPTURE_METADATA_LENGTH = 200;
1896
1914
  const CAPTURE_FAILURE_LENGTH = 1e3;
1897
1915
  const CAPTURE_UPLOAD_BATCH_SIZE = 400;
@@ -3092,6 +3110,10 @@ const paginationSchema = z.object({
3092
3110
  cursor: z.string().nullable().default(null),
3093
3111
  limit: z.number().int().min(1).max(100).default(20)
3094
3112
  });
3113
+ const pageSchema = (item) => z.object({
3114
+ items: z.array(item),
3115
+ nextCursor: z.string().nullable()
3116
+ });
3095
3117
  /**
3096
3118
  * A collection bounded by human behaviour rather than by a cursor: every row up to a
3097
3119
  * ceiling, and a flag saying the ceiling was hit.
@@ -3213,6 +3235,14 @@ const collectionSchema = z.union([
3213
3235
  z.literal("everything"),
3214
3236
  z.uuid()
3215
3237
  ]);
3238
+ /** Cards in one page of the canvas list; the dashboard asks for fewer. */
3239
+ const MAX_CANVAS_PAGE = 200;
3240
+ const MAX_CANVAS_CURSOR_LENGTH = 4096;
3241
+ const canvasListSortSchema = z.enum([
3242
+ "opened",
3243
+ "created",
3244
+ "name"
3245
+ ]);
3216
3246
  z.object({
3217
3247
  collection: collectionSchema.default("own"),
3218
3248
  title: z.string().trim().min(1).optional().describe("Title text to match before returning canvas ids."),
@@ -3224,7 +3254,13 @@ z.object({
3224
3254
  "mine",
3225
3255
  "shared"
3226
3256
  ]).default("all"),
3227
- hasUnresolved: z.boolean().default(false)
3257
+ hasUnresolved: z.boolean().default(false),
3258
+ /** A page of at most this many cards. Without it the whole collection comes back. */
3259
+ limit: z.number().int().min(1).max(MAX_CANVAS_PAGE).optional(),
3260
+ /** The dashboard's orders. Without it, latest activity first, the order agents read. */
3261
+ sort: canvasListSortSchema.optional().describe("Order as the dashboard does: opened (yours first), created (newest first) or name. Omit for latest activity first."),
3262
+ /** The `nextCursor` of the page before, in the same order. */
3263
+ cursor: z.string().min(1).max(MAX_CANVAS_CURSOR_LENGTH).optional()
3228
3264
  });
3229
3265
  const canvasCardBaseSchema = linkedCanvasSchema.extend({
3230
3266
  screenCount: z.number().int().min(0),
@@ -3232,10 +3268,10 @@ const canvasCardBaseSchema = linkedCanvasSchema.extend({
3232
3268
  /** When the person listing last opened it in the web app; `null` if they never have. */
3233
3269
  lastViewedAt: z.iso.datetime().nullable()
3234
3270
  });
3235
- cappedSchema(z.union([canvasCardBaseSchema.extend({ thumbnail: canvasThumbnailPreviewSchema }), canvasCardBaseSchema.extend({
3271
+ pageSchema(z.union([canvasCardBaseSchema.extend({ thumbnail: canvasThumbnailPreviewSchema }), canvasCardBaseSchema.extend({
3236
3272
  thumbnail: z.null(),
3237
3273
  thumbnailFallbackReason: thumbnailFallbackReasonSchema
3238
- })]));
3274
+ })])).extend({ truncated: z.boolean() });
3239
3275
  z.object({
3240
3276
  canvasId: z.uuid(),
3241
3277
  title: z.string().trim().min(1)
@@ -3572,6 +3608,12 @@ const canvasFlowOffsetSchema = z.object({
3572
3608
  x: canvasNumberSchema,
3573
3609
  y: canvasNumberSchema
3574
3610
  });
3611
+ /**
3612
+ * What an alignment does when its content overflows the box it aligns in: `safe` falls back to the
3613
+ * start, `unsafe` keeps the alignment and lets the content overflow both sides, as CSS's overflow
3614
+ * position keywords do. Without one an alignment keeps CSS's default for that property.
3615
+ */
3616
+ const canvasOverflowPositionSchema = z.enum(["safe", "unsafe"]);
3575
3617
  const canvasFlexLayoutSchema = z.object({
3576
3618
  direction: z.enum(["row", "column"]),
3577
3619
  alignItems: z.enum([
@@ -3604,7 +3646,13 @@ const canvasFlexLayoutSchema = z.object({
3604
3646
  wrap: z.enum(["nowrap", "wrap"]).optional(),
3605
3647
  gridColumns: z.number().int().positive().optional(),
3606
3648
  gridAutoRepeat: canvasGridAutoRepeatSchema.optional(),
3607
- padding: canvasFlexPaddingSchema
3649
+ padding: canvasFlexPaddingSchema,
3650
+ /** The overflow position of each alignment that names one, by the alignment it qualifies. */
3651
+ overflowPositions: z.object({
3652
+ justifyContent: canvasOverflowPositionSchema.optional(),
3653
+ alignItems: canvasOverflowPositionSchema.optional(),
3654
+ alignContent: canvasOverflowPositionSchema.optional()
3655
+ }).strict().optional()
3608
3656
  }).strict();
3609
3657
  /**
3610
3658
  * What conversion recorded about the source box of an inline-level frame that the frame itself
@@ -3666,6 +3714,8 @@ const canvasNodeLayoutSchema = z.object({
3666
3714
  "end",
3667
3715
  "stretch"
3668
3716
  ]).optional(),
3717
+ /** The overflow position `alignSelf` names, when it names one. */
3718
+ alignSelfOverflowPosition: canvasOverflowPositionSchema.optional(),
3669
3719
  flexGrow: nonNegativeCanvasNumberSchema.optional(),
3670
3720
  flexShrink: nonNegativeCanvasNumberSchema.optional(),
3671
3721
  flexBasis: z.union([
@@ -5322,7 +5372,7 @@ const canvasTextStyleSchema = z.object({
5322
5372
  message: "A published revision belongs to a source style and canvas.",
5323
5373
  path: ["sourceRevision"]
5324
5374
  });
5325
- z.object({
5375
+ const canvasTextStyleBindingSchema = z.object({
5326
5376
  id: canvasTextStyleSchema.shape.id,
5327
5377
  position: z.enum([
5328
5378
  "normal",
@@ -5791,6 +5841,9 @@ canvasTextParagraphSchema.pick({
5791
5841
  decorationBlendMode: canvasTypographySchema.shape.decoration.shape.blendMode,
5792
5842
  backgroundBlendMode: canvasBlendModeSchema.optional()
5793
5843
  }).strip();
5844
+ canvasTextParagraphSchema.optional();
5845
+ canvasTextStyleBindingSchema.optional();
5846
+ Object.freeze([]);
5794
5847
  const CANVAS_FONT_CONTENT_TYPES = [
5795
5848
  "font/ttf",
5796
5849
  "font/otf",
@@ -9544,6 +9597,29 @@ z.object({
9544
9597
  /** Screens survive with their provenance nulled. That is what makes iteration safe. */
9545
9598
  detachedScreenCount: z.number().int().min(0)
9546
9599
  });
9600
+ /**
9601
+ * Which form fields a capture never stores as they appear: a card or sign-in secret, decided by
9602
+ * what the page declares the field is for, as browsers decide what to autofill, and every field
9603
+ * of a frame from another site that its page lets take payments.
9604
+ */
9605
+ /** The `autocomplete` purposes of a card or a sign-in secret. */
9606
+ const SECRET_PURPOSES = /* @__PURE__ */ new Set([
9607
+ "cc-number",
9608
+ "cc-csc",
9609
+ "cc-exp",
9610
+ "cc-exp-month",
9611
+ "cc-exp-year",
9612
+ "cc-name",
9613
+ "cc-given-name",
9614
+ "cc-additional-name",
9615
+ "cc-family-name",
9616
+ "one-time-code",
9617
+ "current-password",
9618
+ "new-password"
9619
+ ]);
9620
+ /** The fields a picture paints over: those a page declares secret, which a selector can name. */
9621
+ const SECRET_FIELD_SELECTOR = ["input[type=\"password\" i]", ...[...SECRET_PURPOSES].map((purpose) => `[autocomplete~="${purpose}" i]`)].join(", ");
9622
+ [...SECRET_PURPOSES].map((purpose) => `select[autocomplete~="${purpose}" i]`).join(", ");
9547
9623
  z.object({
9548
9624
  /**
9549
9625
  * Client-minted, once per capture attempt. A retry is the same screen; a re-capture at the
@@ -9905,6 +9981,10 @@ const clientRenderFailureDetailsSchema = z.strictObject({
9905
9981
  "export-image-unreachable",
9906
9982
  "export-image-not-an-image",
9907
9983
  "export-font-unread",
9984
+ "export-drawn-by-server",
9985
+ "export-picture-refused",
9986
+ "export-picture-blank",
9987
+ "export-text-unaligned",
9908
9988
  "clipboard-unavailable",
9909
9989
  "clipboard-image-pending",
9910
9990
  "clipboard-image-unavailable",
@@ -9954,6 +10034,23 @@ const clientRenderFailureDetailsSchema = z.strictObject({
9954
10034
  resourceCount: count$1.optional(),
9955
10035
  /** The status a refused export read answered with. */
9956
10036
  httpStatus: z.number().int().min(HTTP_STATUS_LOWEST).max(HTTP_STATUS_HIGHEST).optional(),
10037
+ /** The browser engine that drew, or could not draw, an image export. */
10038
+ browser: z.strictObject({
10039
+ engine: z.enum([
10040
+ "chromium",
10041
+ "firefox",
10042
+ "webkit",
10043
+ "unknown"
10044
+ ]),
10045
+ version: z.number().int().min(0).max(MAX_COUNT)
10046
+ }).optional(),
10047
+ /** Why the browser gave no picture back for `export-picture-refused`. */
10048
+ refusal: z.enum([
10049
+ "read-back",
10050
+ "load",
10051
+ "memory",
10052
+ "encode"
10053
+ ]).optional(),
9957
10054
  deliveryGap: z.strictObject({
9958
10055
  refused: count$1,
9959
10056
  expired: count$1,
@@ -10018,7 +10115,8 @@ const CANVAS_SYNC_REPORTS = [
10018
10115
  "retrying",
10019
10116
  "recovery",
10020
10117
  "trace",
10021
- "update-required"
10118
+ "update-required",
10119
+ "parts-mismatch"
10022
10120
  ];
10023
10121
  /** How a failed document read was answered, on the report of one worth a look. */
10024
10122
  const CANVAS_SYNC_READ_OUTCOMES = [
@@ -10230,6 +10328,9 @@ z.strictObject({
10230
10328
  readOutcome: z.enum(CANVAS_SYNC_READ_OUTCOMES).optional(),
10231
10329
  status: z.enum(CANVAS_SYNC_REPORT_STATUSES).optional(),
10232
10330
  episode: z.enum(CANVAS_SYNC_EPISODES).optional(),
10331
+ /** On a `parts-mismatch` report: the parts its head names and the parts found, counts only. */
10332
+ partsNamed: z.number().int().nonnegative().optional(),
10333
+ partsFound: z.number().int().nonnegative().optional(),
10233
10334
  trace: canvasSaveTraceSchema.optional()
10234
10335
  });
10235
10336
  z.object({
@@ -10747,7 +10848,7 @@ const startStallWatch = (caller, idleMs = STALL_MS) => {
10747
10848
  };
10748
10849
 
10749
10850
  //#endregion
10750
- //#region ../../packages/sdk/dist/capture-client.client-DuFVZYes.mjs
10851
+ //#region ../../packages/sdk/dist/capture-client.client-XD3yn5Xr.mjs
10751
10852
  const line = (text) => `Enhance: ${text}\n`;
10752
10853
  /** A left-out capture by its journey and step, or by its test when it could not be read at all. */
10753
10854
  const leftOutName = (leftOut, attempts) => {
@@ -12975,7 +13076,7 @@ const main = async () => {
12975
13076
  const remote = createHttpRemoteAdapter(config.apiUrl, credentials, mutationKey);
12976
13077
  const cli = createCliProgram({
12977
13078
  apiUrl: config.apiUrl,
12978
- version: "0.1.174",
13079
+ version: "0.1.177",
12979
13080
  credentials,
12980
13081
  remote,
12981
13082
  mutationKey,
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import { $ as canvasWriteReceiptSchema, $n as listCommentsOutputSchema, B as canvasPrototypeOutputSchema, Bt as encodeCanvasExchangeToken, F as canvasCapturePageInputSchema, Gn as commentCanvasContextSchema, H as operationStatusImageSchema, I as canvasCapturePageOutputSchema, It as parseCanvasReference, Jn as commentThreadSchema, K as canvasCaptureInputSchema, Kn as commentMessageSchema, Kt as canvasUpdateHtmlInputSchema, Lt as canvasExchangeDigest, Q as canvasPreparationOutputSchema, Qn as listCommentsInputSchema, R as canvasPrototypeInputSchema, St as canvasMakeEditableInputSchema, U as operationStatusInputSchema, Ut as canvasReadInputSchema, V as canvasConversionStatusSchema, W as operationStatusOutputSchema, Wn as commentAuthorSchema, Wt as canvasReadOutputSchema, Xn as elementAnchorSchema, Y as canvasArrangeInputSchema, Yn as domLocatorSchema, Z as canvasDuplicateInputSchema, Zn as getCommentOutputSchema, _n as CliError, _t as createdCanvasAnswerSchema, ar as screenTextCommentTargetSchema, bt as canvasInsertHtmlInputSchema, dn as pointOfUseText, dt as canvasRemoveInputSchema, er as replyCommentInputSchema, ft as canvasCreateToolInputSchema, g as toMcpFailurePayload, gt as canvasFindOutputSchema, ht as canvasFindInputSchema, ir as screenElementsCommentTargetSchema, nr as screenAreaCommentTargetSchema, nt as canvasAssetImportOutputSchema, o as CAPTURE_PAGE_CALLS, or as startCommentInputSchema, pt as canvasCreateToolOutputSchema, q as canvasCaptureOutputSchema, qn as commentResolverSchema, rr as screenElementCommentTargetSchema, sn as MCP_TOOL_BY_CAPABILITY, st as canvasRenderScopedToolInputSchema, tr as replyCommentOutputSchema, tt as canvasAssetImportInputSchema, w as PROTOTYPE_UPDATE_GUIDANCE, zt as decodeCanvasExchangeToken } from "./cli-output-identity.lib-BgqE7RXo.mjs";
3
- import { T as createAuthUseCase, c as createOauthLoopbackAdapter, f as createCapabilityInvocationAdapter, n as createMutationKeyAdapter, r as createHttpRemoteAdapter, u as withCapabilityNames, y as boundedResultPage } from "./zod-messages.lib-25kXQXyA.mjs";
4
- import { a as createMcpCanvasToolsAdapter, c as toolClientToken, d as createCapabilityCatalogAdapter, i as createMcpClientInvocationAdapter, l as withClientTokenNamed, o as mcpDispatchedResultSchema, r as workflowsFor, s as createMcpResultAdapter, u as createMcpClientContextAdapter } from "./mcp-server.adapter-VC6efIcJ.mjs";
2
+ import { $ as canvasWriteReceiptSchema, $n as listCommentsOutputSchema, B as canvasPrototypeOutputSchema, Bt as encodeCanvasExchangeToken, F as canvasCapturePageInputSchema, Gn as commentCanvasContextSchema, H as operationStatusImageSchema, I as canvasCapturePageOutputSchema, It as parseCanvasReference, Jn as commentThreadSchema, K as canvasCaptureInputSchema, Kn as commentMessageSchema, Kt as canvasUpdateHtmlInputSchema, Lt as canvasExchangeDigest, Q as canvasPreparationOutputSchema, Qn as listCommentsInputSchema, R as canvasPrototypeInputSchema, St as canvasMakeEditableInputSchema, U as operationStatusInputSchema, Ut as canvasReadInputSchema, V as canvasConversionStatusSchema, W as operationStatusOutputSchema, Wn as commentAuthorSchema, Wt as canvasReadOutputSchema, Xn as elementAnchorSchema, Y as canvasArrangeInputSchema, Yn as domLocatorSchema, Z as canvasDuplicateInputSchema, Zn as getCommentOutputSchema, _n as CliError, _t as createdCanvasAnswerSchema, ar as screenTextCommentTargetSchema, bt as canvasInsertHtmlInputSchema, dn as pointOfUseText, dt as canvasRemoveInputSchema, er as replyCommentInputSchema, ft as canvasCreateToolInputSchema, g as toMcpFailurePayload, gt as canvasFindOutputSchema, ht as canvasFindInputSchema, ir as screenElementsCommentTargetSchema, nr as screenAreaCommentTargetSchema, nt as canvasAssetImportOutputSchema, o as CAPTURE_PAGE_CALLS, or as startCommentInputSchema, pt as canvasCreateToolOutputSchema, q as canvasCaptureOutputSchema, qn as commentResolverSchema, rr as screenElementCommentTargetSchema, sn as MCP_TOOL_BY_CAPABILITY, st as canvasRenderScopedToolInputSchema, tr as replyCommentOutputSchema, tt as canvasAssetImportInputSchema, w as PROTOTYPE_UPDATE_GUIDANCE, zt as decodeCanvasExchangeToken } from "./cli-output-identity.lib-DXXUW_-R.mjs";
3
+ import { T as createAuthUseCase, c as createOauthLoopbackAdapter, f as createCapabilityInvocationAdapter, n as createMutationKeyAdapter, r as createHttpRemoteAdapter, u as withCapabilityNames, y as boundedResultPage } from "./zod-messages.lib-C5xbjvAa.mjs";
4
+ import { a as createMcpCanvasToolsAdapter, c as toolClientToken, d as createCapabilityCatalogAdapter, i as createMcpClientInvocationAdapter, l as withClientTokenNamed, o as mcpDispatchedResultSchema, r as workflowsFor, s as createMcpResultAdapter, u as createMcpClientContextAdapter } from "./mcp-server.adapter-DGFgu7Ea.mjs";
5
5
  import { z } from "zod";
6
6
  import { McpServer } from "@modelcontextprotocol/server";
7
7
 
package/dist/mcp-main.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
- import { s as toCapabilityDefinition } from "./cli-output-identity.lib-BgqE7RXo.mjs";
3
- import { a as readLocalMcpEnvironment, t as installZodMessages } from "./zod-messages.lib-25kXQXyA.mjs";
2
+ import { s as toCapabilityDefinition } from "./cli-output-identity.lib-DXXUW_-R.mjs";
3
+ import { a as readLocalMcpEnvironment, t as installZodMessages } from "./zod-messages.lib-C5xbjvAa.mjs";
4
4
  import { t as createFileCredentialAdapter } from "./file-credential.adapter-CShGZcd5.mjs";
5
- import { d as createCapabilityCatalogAdapter, t as createMcpServerAdapter, u as createMcpClientContextAdapter } from "./mcp-server.adapter-VC6efIcJ.mjs";
6
- import { n as createMcpCanvasProfileAdapter, t as createMcpInvocationAdapter } from "./mcp-invocation.adapter-Cq2xp41d.mjs";
5
+ import { d as createCapabilityCatalogAdapter, t as createMcpServerAdapter, u as createMcpClientContextAdapter } from "./mcp-server.adapter-DGFgu7Ea.mjs";
6
+ import { n as createMcpCanvasProfileAdapter, t as createMcpInvocationAdapter } from "./mcp-invocation.adapter-C2xE1Qqx.mjs";
7
7
  import process from "node:process";
8
8
  import { z } from "zod";
9
9
  import { serveStdio } from "@modelcontextprotocol/server/stdio";
@@ -171,19 +171,19 @@ const clientContext = createMcpClientContextAdapter();
171
171
  const main = () => {
172
172
  const config = readLocalMcpEnvironment();
173
173
  const credentials = createFileCredentialAdapter(config.configDirectory, config.earlierConfigDirectory);
174
- const invocation = createMcpInvocationAdapter(config.apiUrl, credentials, config.configDirectory, { version: "0.1.174" });
174
+ const invocation = createMcpInvocationAdapter(config.apiUrl, credentials, config.configDirectory, { version: "0.1.177" });
175
175
  const catalog = [...createCapabilityCatalogAdapter(), ...createMcpTransportCapabilityAdapter()];
176
176
  const client = clientContext.createStdio();
177
177
  serveStdio(() => config.profile === "canvas" ? createMcpCanvasProfileAdapter({
178
178
  readOnly: config.isReadOnly,
179
179
  ...config.workflowsDirectory !== void 0 && { workflows: config.workflowsDirectory },
180
180
  name: config.mcpServiceName,
181
- version: "0.1.174",
181
+ version: "0.1.177",
182
182
  invocation,
183
183
  clientMetadata: client.metadata,
184
184
  catalog
185
185
  }) : createMcpServerAdapter({
186
- version: "0.1.174",
186
+ version: "0.1.177",
187
187
  name: config.mcpServiceName,
188
188
  commandName: config.commandName,
189
189
  invocation,
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { Ct as canvasEditCapabilityInputSchema, Et as inputProblemFields, Ft as hasCanvasReferenceScope, It as parseCanvasReference, Nt as canvasReferenceRenderTarget, Tr as agentClientMetadata, Zt as readStoredCanvasScene, _n as CliError, d as toPresentedCapabilities, dn as pointOfUseText, fn as startUpListFor, g as toMcpFailurePayload, gn as skillTextsFor, hi as canvasRenderTargetSchema, hn as jobOf, i as createLazyCapabilityCatalogAdapter, it as canvasRenderBatchResultSchema, k as canvasWriteHtmlCapabilityInputSchema, l as GUIDE_TOPICS, lt as canvasRenderFileSchema, mn as SKILL_NAMES, n as withCommandName, on as onSurface, p as createMcpCapabilityDiscoveryAdapter, pi as canvasRenderSourceStateSchema, pn as DESIGN_RULES, qt as retryClientTokenSchema, r as toCanvasAuthoringResult, sn as MCP_TOOL_BY_CAPABILITY, t as withCommandInFailure, u as GUIDE_TOPIC_NAMES, zr as wholeCanvasDocumentOutputSchema } from "./cli-output-identity.lib-BgqE7RXo.mjs";
2
+ import { Ct as canvasEditCapabilityInputSchema, Et as inputProblemFields, Ft as hasCanvasReferenceScope, It as parseCanvasReference, Nt as canvasReferenceRenderTarget, Tr as agentClientMetadata, Zt as readStoredCanvasScene, _n as CliError, d as toPresentedCapabilities, dn as pointOfUseText, fn as startUpListFor, g as toMcpFailurePayload, gn as skillTextsFor, hi as canvasRenderTargetSchema, hn as jobOf, i as createLazyCapabilityCatalogAdapter, it as canvasRenderBatchResultSchema, k as canvasWriteHtmlCapabilityInputSchema, l as GUIDE_TOPICS, lt as canvasRenderFileSchema, mn as SKILL_NAMES, n as withCommandName, on as onSurface, p as createMcpCapabilityDiscoveryAdapter, pi as canvasRenderSourceStateSchema, pn as DESIGN_RULES, qt as retryClientTokenSchema, r as toCanvasAuthoringResult, sn as MCP_TOOL_BY_CAPABILITY, t as withCommandInFailure, u as GUIDE_TOPIC_NAMES, zr as wholeCanvasDocumentOutputSchema } from "./cli-output-identity.lib-DXXUW_-R.mjs";
3
3
  import { z } from "zod";
4
4
  import { AsyncLocalStorage } from "node:async_hooks";
5
5
  import { readFile, rm } from "node:fs/promises";
@@ -547,6 +547,7 @@ const writeSchema = canvasWriteHtmlCapabilityInputSchema.pick({
547
547
  }).extend({
548
548
  canvas: z.string().min(1).describe("Canvas UUID or complete canvas/page/selection URL. Preserve every supplied page and selection."),
549
549
  mode: z.enum(["insert-children", "replace"]).default("insert-children"),
550
+ placement: canvasWriteHtmlCapabilityInputSchema.shape.placement.describe("Where a new top-level screen (targetNodeId root) goes: auto finds free space, near puts it beside or below a screen, explicit sets page coordinates. Omit to keep the authored position."),
550
551
  clientToken: clientTokenSchema
551
552
  });
552
553
  const editSchema = canvasEditCapabilityInputSchema.extend({ clientToken: clientTokenSchema });
package/dist/mcp.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { f as toSharedCapabilities } from "./cli-output-identity.lib-BgqE7RXo.mjs";
2
+ import { f as toSharedCapabilities } from "./cli-output-identity.lib-DXXUW_-R.mjs";
3
3
  import { t as toCapabilityInventory } from "./capability-inventory.mapper-DyYXyVBJ.mjs";
4
- import { d as createCapabilityCatalogAdapter, t as createMcpServerAdapter } from "./mcp-server.adapter-VC6efIcJ.mjs";
4
+ import { d as createCapabilityCatalogAdapter, t as createMcpServerAdapter } from "./mcp-server.adapter-DGFgu7Ea.mjs";
5
5
 
6
6
  export { createCapabilityCatalogAdapter, createMcpServerAdapter as createEnhanceMcpServer, toCapabilityInventory, toSharedCapabilities };
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { An as foldPrototypeArtifactPath, B as canvasPrototypeOutputSchema, In as getMeOutputSchema, Ln as MCP_AUTH_SCOPE, Pn as prototypeArtifactPathSchema, Ti as signedDownloadSchema, _n as CliError, dn as pointOfUseText, nt as canvasAssetImportOutputSchema, tt as canvasAssetImportInputSchema, w as PROTOTYPE_UPDATE_GUIDANCE, z as canvasPrototypeIntentSchema } from "./cli-output-identity.lib-BgqE7RXo.mjs";
3
- import { h as createImportCanvasAssetComposite, m as createPublishCanvasPrototypeComposite, n as createMutationKeyAdapter, o as readRemoteMcpEnvironment, p as createPrototypeArtifactAdapter, r as createHttpRemoteAdapter, t as installZodMessages } from "./zod-messages.lib-25kXQXyA.mjs";
4
- import { c as toolClientToken, d as createCapabilityCatalogAdapter, l as withClientTokenNamed, n as createServedSkills, s as createMcpResultAdapter, t as createMcpServerAdapter, u as createMcpClientContextAdapter } from "./mcp-server.adapter-VC6efIcJ.mjs";
5
- import { n as createMcpCanvasProfileAdapter, t as createMcpInvocationAdapter } from "./mcp-invocation.adapter-Cq2xp41d.mjs";
2
+ import { An as foldPrototypeArtifactPath, B as canvasPrototypeOutputSchema, In as getMeOutputSchema, Ln as MCP_AUTH_SCOPE, Pn as prototypeArtifactPathSchema, Ti as signedDownloadSchema, _n as CliError, dn as pointOfUseText, nt as canvasAssetImportOutputSchema, tt as canvasAssetImportInputSchema, w as PROTOTYPE_UPDATE_GUIDANCE, z as canvasPrototypeIntentSchema } from "./cli-output-identity.lib-DXXUW_-R.mjs";
3
+ import { h as createImportCanvasAssetComposite, m as createPublishCanvasPrototypeComposite, n as createMutationKeyAdapter, o as readRemoteMcpEnvironment, p as createPrototypeArtifactAdapter, r as createHttpRemoteAdapter, t as installZodMessages } from "./zod-messages.lib-C5xbjvAa.mjs";
4
+ import { c as toolClientToken, d as createCapabilityCatalogAdapter, l as withClientTokenNamed, n as createServedSkills, s as createMcpResultAdapter, t as createMcpServerAdapter, u as createMcpClientContextAdapter } from "./mcp-server.adapter-DGFgu7Ea.mjs";
5
+ import { n as createMcpCanvasProfileAdapter, t as createMcpInvocationAdapter } from "./mcp-invocation.adapter-C2xE1Qqx.mjs";
6
6
  import process from "node:process";
7
7
  import { z } from "zod";
8
8
  import { mkdir, mkdtemp, readFile, rm } from "node:fs/promises";
@@ -847,7 +847,7 @@ const server = await createRemoteMcpHttpAdapter({
847
847
  ...config.MCP_STAGED_UPLOAD_ORIGIN !== void 0 && { stagedUploadOrigin: config.MCP_STAGED_UPLOAD_ORIGIN },
848
848
  allowedHosts: config.MCP_ALLOWED_HOSTS.split(",").map((value) => value.trim()),
849
849
  allowedOrigins: config.MCP_ALLOWED_ORIGINS.split(",").map((value) => value.trim()),
850
- version: "0.1.174",
850
+ version: "0.1.177",
851
851
  ...config.MCP_UI_URL !== void 0 && { uiUrl: config.MCP_UI_URL },
852
852
  onerror: (error) => process.stderr.write(`${error.message}\n`)
853
853
  });
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { $r as reserveCanvasAssetOutputSchema, $t as callingSurface, A as commentAttentionCapabilityInputSchema, Ai as endCanvasActivityOutputSchema, An as foldPrototypeArtifactPath, Ar as IMAGE_KIND, Br as canvasBoxSourceOf, Bt as encodeCanvasExchangeToken, Ct as canvasEditCapabilityInputSchema, D as canvasReadCapabilityInputSchema, Di as CANVAS_BLEND_MODES, Dn as PROTOTYPE_ARTIFACT_MANIFEST_PATH, Dr as getCanvasPreparationOutputSchema, Dt as inputProblemSummary, E as canvasApplyCapabilityInputSchema, Ei as canvasAdditionalStyleSchema, Er as createCanvasPreparationOutputSchema, Et as inputProblemFields, Fn as submitPrototypeArtifactOutputSchema, Fr as canvasLayoutWithoutCssProperties, Ft as hasCanvasReferenceScope, G as canvasCaptureCapabilityInputSchema, Gr as canvasCssPixelValue, Gt as canvasUpdateHtmlCapabilityInputSchema, Ht as canvasOutlineCursorSchema, In as getMeOutputSchema, Ir as textOf, It as parseCanvasReference, J as canvasArrangeCapabilityInputSchema, Jt as canvasTranscriptCursorSchema, Kt as canvasUpdateHtmlInputSchema, L as canvasPrototypeCapabilityInputSchema, Lr as mapCanvasFontSources, Lt as canvasExchangeDigest, M as recordingSnapshotCapabilityInputSchema, Mn as getPrototypePublishStatusOutputSchema, Mr as RECTANGLE_KIND, Mt as canvasReferenceNodeIds, N as transcriptReadCapabilityInputSchema, Nn as prototypeArtifactManifestSchema, Nr as SCREEN_KIND, O as canvasRenderCapabilityInputSchema, Oi as canvasBlendModeSchema, On as attachPrototypeArtifactOutputSchema, Or as FRAME_KIND, P as canvasCapturePageCapabilityInputSchema, Pn as prototypeArtifactPathSchema, Pr as TEXT_KIND, Qr as reserveCanvasAssetInputSchema, Qt as callOf, Rn as cliAuthConfigurationSchema, Rt as canvasSnapshotToken, Si as canvasSceneDocumentSchema, Sr as beginCanvasActivityOutputSchema, Tn as getRecordingOutputSchema, U as operationStatusInputSchema, Ur as canvasAuthoredStyleDeclarations, Ut as canvasReadInputSchema, Vn as listOrganisationsOutputSchema, Vr as canvasRecordedBoxNoteFor, Vt as resolveCanvasSnapshot, Wr as canvasAxisStyleProperties, X as canvasDuplicateCapabilityInputSchema, Xr as canvasCssValue, Xt as tallyCanvasWork, Yr as canvasCssTokens, Yt as canvasResourcesCursorSchema, Zr as canvasAssetUploadOutputSchema, Zt as readStoredCanvasScene, _i as createCanvasRenderOutputSchema, _n as CliError, _r as canvasRecordingPropsSchema, ai as editCanvasOutputSchema, an as inputName, at as canvasRenderPendingSchema, bi as getCanvasRenderOutputSchema, br as canvasReferencePageOf, ci as getCanvasMutationOutputSchema, cn as CANVAS_EDIT_WORDS, cr as applyCanvasTypographyPatch, ct as canvasRenderRequestSchema, di as createCanvasConversionOutputSchema, dr as canvasTextPropsWithContent, ei as canvasFontAssetIdentityFromPath, en as cliPathOf, et as canvasAssetImportCapabilityInputSchema, fi as getCanvasConversionOutputSchema, gr as canvasPrototypePropsSchema, hr as canvasConversionMetadataSchema, ht as canvasFindInputSchema, ii as CANVAS_RICH_TEXT_STYLE_PROPERTIES, in as inSurfaceWords, j as prototypePublishCapabilityInputSchema, jn as getPrototypeArtifactCapabilitiesOutputSchema, jr as PAGE_KIND, jt as assertCanvasReferenceNodes, k as canvasWriteHtmlCapabilityInputSchema, ki as canvasPaintSchema, kn as createPrototypeArtifactOutputSchema, kr as GROUP_KIND, ln as PartialBatchError, lr as canvasCssTypographyOwners, lt as canvasRenderFileSchema, mi as canvasRenderStateSchema, mr as canvasCaptureSchema, mt as canvasFindCursorSchema, ni as canvasRichTextValueOf, nn as currentNodeIdStep, nt as canvasAssetImportOutputSchema, oi as applyCanvasOperationsInputSchema, pr as CAPTURE_LANDING_CONVERTING, qr as canvasLayoutPositionOf, ri as hasCanvasRichTextPaints, rn as diagnosisStep, rt as canvasRenderBatchRequestSchema, si as applyCanvasOperationsOutputSchema, sr as createCapturePassOutputSchema, ti as canvasRichTextOf, tn as commandName, ui as canvasNodeStylePatchSchema, ur as canvasTextChangeBetween, ut as canvasRemoveCapabilityInputSchema, v as toRemoteError, vi as createRecordingSnapshotOutputSchema, vn as isFormatRefusalError, vr as captureLandingSchema, vt as listedCanvasesAnswerSchema, wi as canvasImageAssetIdentityFromPath, wr as AGENT_CLIENT_HEADER, xi as canvasReadableSceneDocumentSchema, xr as resolveCanvasReference, xt as canvasMakeEditableCapabilityInputSchema, yi as downloadCanvasRenderOutputSchema, yn as transcriptOutputSchema, yr as DEFAULT_CANVAS_REFERENCE_PAGE_ID, yt as canvasInsertHtmlCapabilityInputSchema, zn as createAgentTokenOutputSchema, zr as wholeCanvasDocumentOutputSchema, zt as decodeCanvasExchangeToken } from "./cli-output-identity.lib-BgqE7RXo.mjs";
2
+ import { $r as reserveCanvasAssetOutputSchema, $t as callingSurface, A as commentAttentionCapabilityInputSchema, Ai as endCanvasActivityOutputSchema, An as foldPrototypeArtifactPath, Ar as IMAGE_KIND, Br as canvasBoxSourceOf, Bt as encodeCanvasExchangeToken, Ct as canvasEditCapabilityInputSchema, D as canvasReadCapabilityInputSchema, Di as CANVAS_BLEND_MODES, Dn as PROTOTYPE_ARTIFACT_MANIFEST_PATH, Dr as getCanvasPreparationOutputSchema, Dt as inputProblemSummary, E as canvasApplyCapabilityInputSchema, Ei as canvasAdditionalStyleSchema, Er as createCanvasPreparationOutputSchema, Et as inputProblemFields, Fn as submitPrototypeArtifactOutputSchema, Fr as canvasLayoutWithoutCssProperties, Ft as hasCanvasReferenceScope, G as canvasCaptureCapabilityInputSchema, Gr as canvasCssPixelValue, Gt as canvasUpdateHtmlCapabilityInputSchema, Hr as canvasAuthoredLayoutValueOf, Ht as canvasOutlineCursorSchema, In as getMeOutputSchema, Ir as textOf, It as parseCanvasReference, J as canvasArrangeCapabilityInputSchema, Jt as canvasTranscriptCursorSchema, Kt as canvasUpdateHtmlInputSchema, L as canvasPrototypeCapabilityInputSchema, Lr as mapCanvasFontSources, Lt as canvasExchangeDigest, M as recordingSnapshotCapabilityInputSchema, Mn as getPrototypePublishStatusOutputSchema, Mr as RECTANGLE_KIND, Mt as canvasReferenceNodeIds, N as transcriptReadCapabilityInputSchema, Nn as prototypeArtifactManifestSchema, Nr as SCREEN_KIND, O as canvasRenderCapabilityInputSchema, Oi as canvasBlendModeSchema, On as attachPrototypeArtifactOutputSchema, Or as FRAME_KIND, P as canvasCapturePageCapabilityInputSchema, Pn as prototypeArtifactPathSchema, Pr as TEXT_KIND, Qr as reserveCanvasAssetInputSchema, Qt as callOf, Rn as cliAuthConfigurationSchema, Rt as canvasSnapshotToken, Si as canvasSceneDocumentSchema, Sr as beginCanvasActivityOutputSchema, Tn as getRecordingOutputSchema, U as operationStatusInputSchema, Ur as canvasAuthoredStyleDeclarations, Ut as canvasReadInputSchema, Vn as listOrganisationsOutputSchema, Vr as canvasRecordedBoxNoteFor, Vt as resolveCanvasSnapshot, Wr as canvasAxisStyleProperties, X as canvasDuplicateCapabilityInputSchema, Xr as canvasCssValue, Xt as tallyCanvasWork, Yr as canvasCssTokens, Yt as canvasResourcesCursorSchema, Zr as canvasAssetUploadOutputSchema, Zt as readStoredCanvasScene, _i as createCanvasRenderOutputSchema, _n as CliError, _r as canvasRecordingPropsSchema, ai as editCanvasOutputSchema, an as inputName, at as canvasRenderPendingSchema, bi as getCanvasRenderOutputSchema, br as canvasReferencePageOf, ci as getCanvasMutationOutputSchema, cn as CANVAS_EDIT_WORDS, cr as applyCanvasTypographyPatch, ct as canvasRenderRequestSchema, di as createCanvasConversionOutputSchema, dr as canvasTextPropsWithContent, ei as canvasFontAssetIdentityFromPath, en as cliPathOf, et as canvasAssetImportCapabilityInputSchema, fi as getCanvasConversionOutputSchema, gr as canvasPrototypePropsSchema, hr as canvasConversionMetadataSchema, ht as canvasFindInputSchema, ii as CANVAS_RICH_TEXT_STYLE_PROPERTIES, in as inSurfaceWords, j as prototypePublishCapabilityInputSchema, jn as getPrototypeArtifactCapabilitiesOutputSchema, jr as PAGE_KIND, jt as assertCanvasReferenceNodes, k as canvasWriteHtmlCapabilityInputSchema, ki as canvasPaintSchema, kn as createPrototypeArtifactOutputSchema, kr as GROUP_KIND, ln as PartialBatchError, lr as canvasCssTypographyOwners, lt as canvasRenderFileSchema, mi as canvasRenderStateSchema, mr as canvasCaptureSchema, mt as canvasFindCursorSchema, ni as canvasRichTextValueOf, nn as currentNodeIdStep, nt as canvasAssetImportOutputSchema, oi as applyCanvasOperationsInputSchema, pr as CAPTURE_LANDING_CONVERTING, qr as canvasLayoutPositionOf, ri as hasCanvasRichTextPaints, rn as diagnosisStep, rt as canvasRenderBatchRequestSchema, si as applyCanvasOperationsOutputSchema, sr as createCapturePassOutputSchema, ti as canvasRichTextOf, tn as commandName, ui as canvasNodeStylePatchSchema, ur as canvasTextChangeBetween, ut as canvasRemoveCapabilityInputSchema, v as toRemoteError, vi as createRecordingSnapshotOutputSchema, vn as isFormatRefusalError, vr as captureLandingSchema, vt as listedCanvasesAnswerSchema, wi as canvasImageAssetIdentityFromPath, wr as AGENT_CLIENT_HEADER, xi as canvasReadableSceneDocumentSchema, xr as resolveCanvasReference, xt as canvasMakeEditableCapabilityInputSchema, yi as downloadCanvasRenderOutputSchema, yn as transcriptOutputSchema, yr as DEFAULT_CANVAS_REFERENCE_PAGE_ID, yt as canvasInsertHtmlCapabilityInputSchema, zn as createAgentTokenOutputSchema, zr as wholeCanvasDocumentOutputSchema, zt as decodeCanvasExchangeToken } from "./cli-output-identity.lib-DXXUW_-R.mjs";
3
3
  import process from "node:process";
4
4
  import { z } from "zod";
5
5
  import { generateKeyBetween, generateNKeysBetween } from "fractional-indexing";
@@ -1838,6 +1838,26 @@ const canvasAppearanceOwnedBy = (node, properties) => {
1838
1838
  return [...owned].filter((setting) => node.appearance?.[setting] !== void 0);
1839
1839
  };
1840
1840
 
1841
+ //#endregion
1842
+ //#region ../../packages/canvas-document/src/canvas-inline-first-line.lib.ts
1843
+ const recordOf$1 = (value) => typeof value === "object" && value !== null ? Object.fromEntries(Object.entries(value)) : null;
1844
+ /**
1845
+ * Where a layer drawn as an inline over more than one line starts its first line, from its box, as
1846
+ * conversion recorded it. The browser resolves an absolute child's `left` and `top` from that first
1847
+ * line, and the child's box is stored from the layer's box. A layer with a content clip draws as an
1848
+ * inline-flex box, which starts at its box, so it has none.
1849
+ */
1850
+ const canvasInlineFirstLineOf = (node) => {
1851
+ if (node === void 0 || node.layout?.clipContent !== void 0 || canvasAuthoredLayoutValueOf(node, "display") !== "inline") return void 0;
1852
+ const line = recordOf$1(recordOf$1(node.props?.["source"])?.["captureInlineFirstLine"]);
1853
+ const x = line?.["x"];
1854
+ const y = line?.["y"];
1855
+ return typeof x === "number" && typeof y === "number" && Number.isFinite(x) && Number.isFinite(y) ? {
1856
+ x,
1857
+ y
1858
+ } : void 0;
1859
+ };
1860
+
1841
1861
  //#endregion
1842
1862
  //#region ../../packages/canvas-document/src/canvas-style-position.lib.ts
1843
1863
  const POSITION_AXES = {
@@ -1872,7 +1892,8 @@ const isInsetWrite = ([property, value]) => value !== null && INSET_PROPERTIES.h
1872
1892
  /**
1873
1893
  * Whether the canvas draws the layer somewhere other than its box although nothing on the layer
1874
1894
  * says so: a far-edge or scaled constraint under a Hug or Fill parent, a parent that keeps a
1875
- * scrollbar gutter, or a captured parent-relative position. Such a layer keeps its style.
1895
+ * scrollbar gutter, a parent drawn as an inline from its first line, or a captured parent-relative
1896
+ * position. Such a layer keeps its style.
1876
1897
  */
1877
1898
  const isDrawnAwayFromBox = (document, node, axis) => {
1878
1899
  const parentId = document.relationships[node.id]?.parentId;
@@ -1880,7 +1901,7 @@ const isDrawnAwayFromBox = (document, node, axis) => {
1880
1901
  const constraint = node.constraints?.[axis];
1881
1902
  const parentSize = parent?.layout?.[POSITION_AXES[axis].size];
1882
1903
  const source = node.props?.["source"];
1883
- return constraint !== void 0 && constraint !== "start" && parentSize !== void 0 && parentSize.mode !== "fixed" || parent?.layout?.scrollbarGutter !== void 0 || typeof source === "object" && source !== null && "captureRelativePosition" in source;
1904
+ return constraint !== void 0 && constraint !== "start" && parentSize !== void 0 && parentSize.mode !== "fixed" || parent?.layout?.scrollbarGutter !== void 0 || canvasInlineFirstLineOf(parent) !== void 0 || typeof source === "object" && source !== null && "captureRelativePosition" in source;
1884
1905
  };
1885
1906
  const isBoxPlaced = (document, node, axis) => {
1886
1907
  if (node.box === void 0 || canvasLayoutPositionOf(node) !== "absolute") return false;
@@ -2551,7 +2572,7 @@ const canvasWriteReceipt = (commit, fingerprint) => {
2551
2572
  const namedAsGiven = (version, given) => {
2552
2573
  const stated = String(version);
2553
2574
  if (given === "flag") return `${inputName("baseVersion")} ${stated}`;
2554
- if (given === "input" || given === "placed") return inSurfaceWords({
2575
+ if (given === "input") return inSurfaceWords({
2555
2576
  cli: `the baseVersion ${stated} given in --input`,
2556
2577
  mcp: `baseVersion ${stated}`
2557
2578
  });
@@ -2561,22 +2582,31 @@ const readAgain = (current, given) => given === "snapshot" ? `Read the layer aga
2561
2582
  cli: "Inspect the intended scope with 'enhance canvas tree --canvas <the original canvas or selection link>'",
2562
2583
  mcp: `Read the intended scope again with ${commandName("canvas.read")}`
2563
2584
  })} and reconcile against version ${String(current)} before submitting a new edit.`;
2564
- const nextStepAt = (current, given) => given === "placed" ? `Nothing was placed. Place again with baseVersion ${String(current)}. Every placement moves the canvas on: its answer's frame.version is the next placement's baseVersion.` : `An earlier identical request may already have committed. Do not repeat it with a new client token. ${readAgain(current, given)}`;
2585
+ const nextStepAt = (current, given) => `An earlier identical request may already have committed. Do not repeat it with a new client token. ${readAgain(current, given)}`;
2565
2586
  /** The refusal of a write planned for a version the canvas has moved past. */
2566
2587
  const staleVersionError = (current, expectedVersion, given) => new CliError("CONFLICT", `Canvas version ${String(current)} no longer matches ${namedAsGiven(expectedVersion, given)}.`, nextStepAt(current, given));
2567
2588
  /**
2568
- * The canvas at a version, with the web address the API answered for it: null from an API older
2569
- * than the field.
2589
+ * The canvas as it is now, with its version and the web address the API answered for it: null
2590
+ * from an API older than the field.
2570
2591
  */
2571
- const canvasAtVersion = async (input, canvasId, expectedVersion, given) => {
2592
+ const canvasNow = async (input, canvasId) => {
2572
2593
  const held = wholeCanvasDocumentOutputSchema.safeParse(await input.remote.query("canvas.document.get", { canvasId }));
2573
2594
  if (!held.success) throw new CliError("INTERNAL", "The API returned an invalid canvas document.", diagnosisStep("Run `enhance doctor` and report incompatible API and CLI versions."));
2574
- if (held.data.version !== expectedVersion) throw staleVersionError(held.data.version, expectedVersion, given);
2575
2595
  return {
2576
2596
  scene: readStoredCanvasScene(held.data.document),
2597
+ version: held.data.version,
2577
2598
  url: held.data.url ?? null
2578
2599
  };
2579
2600
  };
2601
+ /** The canvas at a version, with its web address; another version is a refusal. */
2602
+ const canvasAtVersion = async (input, canvasId, expectedVersion, given) => {
2603
+ const { scene, version, url } = await canvasNow(input, canvasId);
2604
+ if (version !== expectedVersion) throw staleVersionError(version, expectedVersion, given);
2605
+ return {
2606
+ scene,
2607
+ url
2608
+ };
2609
+ };
2580
2610
  const sceneAtVersion = async (input, canvasId, expectedVersion, given) => {
2581
2611
  const { scene } = await canvasAtVersion(input, canvasId, expectedVersion, given);
2582
2612
  return scene;
@@ -5860,10 +5890,27 @@ const waitForPreparation = async (remote, initial, waitMs) => {
5860
5890
  const runCanvasPreparation = async (remote, input, waitMs) => {
5861
5891
  const made = createCanvasPreparationOutputSchema.parse(await remote.mutate("canvas.render.preparation.create", input));
5862
5892
  const job = await waitForPreparation(remote, made.job, waitMs);
5863
- if (job.canvasId !== input.canvasId || job.requestedVersion !== input.expectedVersion || !isDeepStrictEqual(job.scope, input.scope) || !isDeepStrictEqual(job.request, input.request)) throw new CliError("CONFLICT", "The native preparation does not match this request.", "Read the canvas and prepare a new intent; do not apply this plan.");
5864
- if (job.state === "succeeded" && job.result.loadedVersion !== input.expectedVersion) throw new CliError("CONFLICT", "The native preparation measured a different revision.", "Read the canvas and prepare a new intent.");
5893
+ const isAtVersion = (version) => input.request.kind === "compile-screens" ? version >= input.expectedVersion : version === input.expectedVersion;
5894
+ if (job.canvasId !== input.canvasId || !isAtVersion(job.requestedVersion) || !isDeepStrictEqual(job.scope, input.scope) || !isDeepStrictEqual(job.request, input.request)) throw new CliError("CONFLICT", "The native preparation does not match this request.", "Read the canvas and prepare a new intent; do not apply this plan.");
5895
+ if (job.state === "succeeded" && !isAtVersion(job.result.loadedVersion)) throw new CliError("CONFLICT", "The native preparation measured a different revision.", "Read the canvas and prepare a new intent.");
5865
5896
  return job;
5866
5897
  };
5898
+ /** How long to wait before asking again for a preparation the API had no room for. */
5899
+ const BUSY_RETRY_MS = 1e3;
5900
+ /**
5901
+ * The preparation, started as soon as the API has room for it within the wait, or null when the
5902
+ * wait ends first.
5903
+ */
5904
+ const runCanvasPreparationWhenFree = async (remote, input, waitMs) => {
5905
+ const deadline = Date.now() + waitMs;
5906
+ for (;;) try {
5907
+ return await runCanvasPreparation(remote, input, Math.max(0, deadline - Date.now()));
5908
+ } catch (error) {
5909
+ if (!(error instanceof CliError) || error.code !== "RATE_LIMITED") throw error;
5910
+ if (Date.now() + BUSY_RETRY_MS > deadline) return null;
5911
+ await setTimeout$1(BUSY_RETRY_MS);
5912
+ }
5913
+ };
5867
5914
 
5868
5915
  //#endregion
5869
5916
  //#region src/application/captured-frame.use-case.ts
@@ -6270,19 +6317,14 @@ const committedSave = async (remote, save) => {
6270
6317
  }));
6271
6318
  return recovered.state === "committed" ? recovered.result : null;
6272
6319
  };
6273
- /** A sort key after every layer on the canvas, so the picture lands in front. */
6274
- const frontSortKey = (scene) => {
6320
+ /**
6321
+ * A sort key after every layer on the canvas, so the picture lands in front. It ends with the
6322
+ * picture's own id, so pictures placed at the same time never share a key.
6323
+ */
6324
+ const frontSortKey = (scene, pictureId) => {
6275
6325
  let last = "a0";
6276
6326
  for (const relation of Object.values(scene.relationships)) if (relation.parentId === "root" && relation.sortKey > last) last = relation.sortKey;
6277
- return `${last}~capture`;
6278
- };
6279
- /** The canvas at the agent's version; a stale version is a refusal, and nothing was written. */
6280
- const canvasAt = async (remote, placement) => {
6281
- try {
6282
- return await canvasAtVersion({ remote }, placement.canvasId, placement.baseVersion, "placed");
6283
- } catch (error) {
6284
- throw refusalOf(error) ?? error;
6285
- }
6327
+ return `${last}~${pictureId}`;
6286
6328
  };
6287
6329
  /** Placing is not moving: a capture that is already a frame stays where it is stored. */
6288
6330
  const refuseAnotherPosition = (placement, stored) => {
@@ -6295,36 +6337,36 @@ const refuseAnotherPosition = (placement, stored) => {
6295
6337
  * canvas at once, marked as becoming editable, as every capture lands.
6296
6338
  */
6297
6339
  const landPicture = async (remote, placement) => {
6298
- const save = saveOf(placement, "picture", placement.baseVersion);
6299
- const prior = await committedSave(remote, save);
6340
+ const prior = await committedSave(remote, saveOf(placement, "picture", 0));
6300
6341
  if (prior !== null) return {
6301
6342
  kind: "picture",
6302
6343
  version: prior.version,
6303
6344
  url: prior.url ?? null
6304
6345
  };
6305
- const { scene, url } = await canvasAt(remote, placement);
6306
- const landed = scene.nodes[pictureIdOf(placement.captureId)];
6346
+ const { scene, version: current, url } = await canvasNow({ remote }, placement.canvasId);
6347
+ const pictureId = pictureIdOf(placement.captureId);
6348
+ const landed = scene.nodes[pictureId];
6307
6349
  if (landed !== void 0 && landed.component !== "screen") {
6308
6350
  if (landed.box !== void 0) refuseAnotherPosition(placement, landed.box);
6309
6351
  return {
6310
6352
  kind: "frame",
6311
- version: placement.baseVersion,
6353
+ version: current,
6312
6354
  box: landed.box ?? null,
6313
6355
  url
6314
6356
  };
6315
6357
  }
6316
6358
  if (landed !== void 0) return {
6317
6359
  kind: "picture",
6318
- version: isFailed(landed) ? await markPicture(remote, placement, CAPTURE_LANDING_CONVERTING, "retry") ?? placement.baseVersion : placement.baseVersion,
6360
+ version: isFailed(landed) ? await markPicture(remote, placement, CAPTURE_LANDING_CONVERTING, "retry") ?? current : current,
6319
6361
  url
6320
6362
  };
6321
6363
  const size = placement.size ?? PICTURE_SIZE;
6322
6364
  return {
6323
6365
  kind: "picture",
6324
- version: (await saveFrame(remote, save, {
6366
+ version: (await saveFrame(remote, saveOf(placement, "picture", placement.baseVersion ?? current), {
6325
6367
  op: "insertNode",
6326
6368
  node: {
6327
- id: pictureIdOf(placement.captureId),
6369
+ id: pictureId,
6328
6370
  label: placement.title ?? CAPTURED_PAGE_LABEL,
6329
6371
  component: SCREEN_KIND,
6330
6372
  styles: {},
@@ -6344,9 +6386,9 @@ const landPicture = async (remote, placement) => {
6344
6386
  },
6345
6387
  parentage: {
6346
6388
  parentId: "root",
6347
- sortKey: frontSortKey(scene)
6389
+ sortKey: frontSortKey(scene, pictureId)
6348
6390
  }
6349
- })).version,
6391
+ }, "rebase")).version,
6350
6392
  url
6351
6393
  };
6352
6394
  };
@@ -6476,7 +6518,7 @@ const askForSnippet = async (remote, canvasId, extent) => {
6476
6518
  warning: `Run snippet in the page you opened (Playwright's page.evaluate or your browser's JavaScript tool). It answers with captureId; ${inSurfaceWords({
6477
6519
  cli: "run",
6478
6520
  mcp: "call"
6479
- })} ${commandName("canvas.capturePage")} again with ${placementInputs("that captureId, at and baseVersion")}. The pass lasts 15 minutes for any number of pages, and the snippet holds it: keep the snippet out of what you print. To send this machine's installed fonts, first grant the page local-fonts: in Playwright, await context.grantPermissions(['local-fonts']).`
6521
+ })} ${commandName("canvas.capturePage")} again with ${placementInputs("that captureId and at")}. The pass lasts 24 hours for any number of pages, and the snippet holds it: keep the snippet out of what you print. To send this machine's installed fonts, first grant the page local-fonts: in Playwright, await context.grantPermissions(['local-fonts']).`
6480
6522
  });
6481
6523
  };
6482
6524
  /**
@@ -6514,7 +6556,7 @@ const placed$1 = (save, on, further = []) => receipt("placed", {
6514
6556
  operation: mutationOf(save),
6515
6557
  ...on,
6516
6558
  further,
6517
- warning: "The picture has become an editable frame in place. Render the frame at its version to inspect it. For the next capture, frame.version is the baseVersion and frame.box says where this one sits."
6559
+ warning: "The picture has become an editable frame in place. Render the frame at its version to inspect it. frame.box says where this one sits, for placing the next capture."
6518
6560
  });
6519
6561
  /** The frame as the API stored it: a receipt's boxes are the stored ones, the request's are not. */
6520
6562
  const storedFrame = (nodeId, saved) => ({
@@ -6554,7 +6596,7 @@ const place$1 = async (remote, placement) => {
6554
6596
  url: landed.url
6555
6597
  }, sizeWarnings(placement.size, frame));
6556
6598
  }
6557
- const job = await runCanvasPreparation(remote, {
6599
+ const job = await runCanvasPreparationWhenFree(remote, {
6558
6600
  canvasId: placement.canvasId,
6559
6601
  expectedVersion: landed.version,
6560
6602
  request: {
@@ -6568,6 +6610,11 @@ const place$1 = async (remote, placement) => {
6568
6610
  },
6569
6611
  scope: { nodeIds: [] }
6570
6612
  }, placement.waitMs);
6613
+ if (job === null) return receipt("converting", {
6614
+ picture,
6615
+ url: landed.url,
6616
+ warning: `The picture is on the canvas. Enhance is already making as many pages editable as it takes at once, so this one has not started. Repeat ${commandName("canvas.capturePage")} with the same input and ${inputName("clientToken")} to start it, or leave it: it becomes editable when the canvas is opened.`
6617
+ });
6571
6618
  if (job.state !== "succeeded") return notYetEditable(remote, placement, {
6572
6619
  picture,
6573
6620
  save,
@@ -6591,10 +6638,10 @@ const captureCanvasPage = async (remote, offered, clientToken) => {
6591
6638
  const input = canvasCapturePageCapabilityInputSchema.parse(offered);
6592
6639
  const reference = parseCanvasReference(input.canvasRef);
6593
6640
  if (input.captureId === void 0) return askForSnippet(remote, reference.canvasId, input.extent);
6594
- if (input.at === void 0 || input.baseVersion === void 0) throw new CliError("BAD_REQUEST", "A placement needs a position, x and y in at, and the baseVersion you read.", `${inSurfaceWords({
6641
+ if (input.at === void 0) throw new CliError("BAD_REQUEST", "A placement needs a position, x and y in at.", `${inSurfaceWords({
6595
6642
  cli: "Run",
6596
6643
  mcp: "Call"
6597
- })} ${commandName("canvas.capturePage")} again with ${placementInputs("captureId, at: { x, y } and baseVersion")}.`);
6644
+ })} ${commandName("canvas.capturePage")} again with ${placementInputs("captureId and at: { x, y }")}.`);
6598
6645
  return place$1(remote, {
6599
6646
  canvasId: reference.canvasId,
6600
6647
  clientToken,
@@ -10348,6 +10395,12 @@ const remoteMcpConfigSchema = z.object({
10348
10395
  MCP_STAGED_UPLOAD_ORIGIN: z.url().optional(),
10349
10396
  MCP_UI_URL: z.url().optional(),
10350
10397
  MCP_ALLOWED_ORIGINS: z.string().min(1).default("claude.ai,claude.com")
10398
+ }).superRefine((config, context) => {
10399
+ if (config.ENHANCE_MCP_READ_ONLY && config.ENHANCE_MCP_PROFILE !== "canvas") context.addIssue({
10400
+ code: "custom",
10401
+ path: ["ENHANCE_MCP_READ_ONLY"],
10402
+ message: "ENHANCE_MCP_READ_ONLY requires the canvas profile."
10403
+ });
10351
10404
  });
10352
10405
  const readRemoteMcpConfig = (variables) => remoteMcpConfigSchema.parse(variables);
10353
10406
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enhance-eng/enhance",
3
- "version": "0.1.174",
3
+ "version": "0.1.177",
4
4
  "private": false,
5
5
  "description": "Agent-first command-line interface for Enhance.",
6
6
  "keywords": [