@enhance-eng/enhance 0.1.175 → 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)
@@ -3368,6 +3387,24 @@ const editCanvasOutputSchema = z.discriminatedUnion("outcome", [applyCanvasOpera
3368
3387
  version: z.number().int().positive()
3369
3388
  })]);
3370
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
+
3371
3408
  //#endregion
3372
3409
  //#region ../../packages/contract/src/canvas/canvas-text-links.lib.ts
3373
3410
  const FORBIDDEN_DOMAIN_CHARACTERS = /* @__PURE__ */ new Set([
@@ -3511,6 +3548,8 @@ const characterFormattingSchema = canvasTextParagraphSchema.pick({
3511
3548
  decorationBlendMode: canvasTypographySchema.shape.decoration.shape.blendMode,
3512
3549
  backgroundBlendMode: canvasBlendModeSchema.optional()
3513
3550
  }).strip();
3551
+ const optionalParagraphSchema = canvasTextParagraphSchema.optional();
3552
+ const optionalTextStyleSchema = canvasTextStyleBindingSchema.optional();
3514
3553
  const safeHref = (value) => typeof value === "string" && isCanvasRichTextHref(value) ? value : void 0;
3515
3554
  const richStylesOf = (value) => {
3516
3555
  if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
@@ -3602,9 +3641,9 @@ const richNodeOf = (value, children) => {
3602
3641
  const values = Reflect.get(value, "children");
3603
3642
  const styles = richStylesOf(Reflect.get(value, "styles"));
3604
3643
  const fills = fillsSchema.safeParse(Reflect.get(value, "fills"));
3605
- const paragraph = canvasTextParagraphSchema.optional().safeParse(Reflect.get(value, "paragraph"));
3644
+ const paragraph = optionalParagraphSchema.safeParse(Reflect.get(value, "paragraph"));
3606
3645
  const formatting = characterFormattingSchema.safeParse(value);
3607
- const textStyle = canvasTextStyleBindingSchema.optional().safeParse(Reflect.get(value, "textStyle"));
3646
+ const textStyle = optionalTextStyleSchema.safeParse(Reflect.get(value, "textStyle"));
3608
3647
  if (styles === null || !fills.success || !paragraph.success || !formatting.success || !textStyle.success || !Array.isArray(values)) return null;
3609
3648
  const href = safeHref(Reflect.get(value, "href"));
3610
3649
  return {
@@ -3631,14 +3670,16 @@ const canvasRichTextValueOf = (nodes) => {
3631
3670
  }
3632
3671
  return text.join("");
3633
3672
  };
3634
- const canvasRichTextOf = (node) => {
3635
- const props = node.props;
3636
- if (props === void 0 || !Array.isArray(props["richText"])) return [];
3637
- const rich = richChildrenOf(props["richText"]);
3638
- if (rich === null) return [];
3639
- const text = props["text"];
3640
- 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;
3641
3681
  };
3682
+ const canvasRichTextOf = ({ props }) => props === void 0 ? NO_RICH_TEXT : richTextRead.get(props) ?? richTextIn(props);
3642
3683
  const hasCanvasRichTextPaints = (node) => {
3643
3684
  const pending = [...canvasRichTextOf(node)];
3644
3685
  while (pending.length > 0) {
@@ -9607,6 +9648,33 @@ const deleteRecordingOutputSchema = z.object({
9607
9648
  detachedScreenCount: z.number().int().min(0)
9608
9649
  });
9609
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
+
9610
9678
  //#endregion
9611
9679
  //#region ../../packages/contract/src/screen/screen.schema.ts
9612
9680
  const createScreenInputSchema = z.object({
@@ -10137,7 +10205,8 @@ const CANVAS_SYNC_REPORTS = [
10137
10205
  "retrying",
10138
10206
  "recovery",
10139
10207
  "trace",
10140
- "update-required"
10208
+ "update-required",
10209
+ "parts-mismatch"
10141
10210
  ];
10142
10211
  /** How a failed document read was answered, on the report of one worth a look. */
10143
10212
  const CANVAS_SYNC_READ_OUTCOMES = [
@@ -10349,8 +10418,14 @@ const clientSaveIncidentInputSchema = z.strictObject({
10349
10418
  readOutcome: z.enum(CANVAS_SYNC_READ_OUTCOMES).optional(),
10350
10419
  status: z.enum(CANVAS_SYNC_REPORT_STATUSES).optional(),
10351
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(),
10352
10424
  trace: canvasSaveTraceSchema.optional()
10353
10425
  });
10426
+
10427
+ //#endregion
10428
+ //#region ../../packages/contract/src/shared/client-save-output.schema.ts
10354
10429
  /** Whether the API's analytics destination took the record. Older clients ignore it. */
10355
10430
  const CANVAS_SAVE_ANALYTICS_STATES = [
10356
10431
  "delivered",
@@ -10989,7 +11064,9 @@ const SKILLS = {
10989
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.",
10990
11065
  body: ({ call, two, command, line }) => `# Capture screens to Enhance
10991
11066
 
10992
- 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.
10993
11070
 
10994
11071
  ${two({
10995
11072
  cli: `## Commands
@@ -12707,7 +12784,7 @@ const canvasPrototypeOutputSchema = z.strictObject({
12707
12784
  //#region src/application/capture-page.schema.ts
12708
12785
  const canvasCapturePageCapabilityInputSchema = z.strictObject({
12709
12786
  ...canvasRenderRequestSchema.pick({ canvasRef: true }).shape,
12710
- 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."),
12711
12788
  captureId: z.uuid().optional().describe("The captureId the snippet answered with. Omit it to get a snippet to run in the page."),
12712
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."),
12713
12790
  extent: z.enum(["full-page", "viewport"]).default("full-page").describe("What the snippet captures: the whole page, or only the visible window."),
@@ -12719,7 +12796,7 @@ const canvasCapturePageCapabilityInputSchema = z.strictObject({
12719
12796
  width: z.number().positive(),
12720
12797
  height: z.number().positive()
12721
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."),
12722
- 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.")
12723
12800
  });
12724
12801
  const canvasCapturePageInputSchema = canvasCapturePageCapabilityInputSchema.extend({ clientToken: retryClientTokenSchema });
12725
12802
  const canvasCapturePageOutputSchema = z.strictObject({
@@ -12745,7 +12822,7 @@ const canvasCapturePageOutputSchema = z.strictObject({
12745
12822
  width: z.number(),
12746
12823
  height: z.number()
12747
12824
  }).nullable()
12748
- }).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."),
12749
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."),
12750
12827
  failure: canvasRenderFailureSchema.nullable(),
12751
12828
  warningCount: z.number().int().nonnegative(),
@@ -14720,9 +14797,9 @@ const CANVAS_CAPABILITY_SPECS = [
14720
14797
  //#region src/infrastructure/canvas-conversion-capability.consts.ts
14721
14798
  /** The page capture's calls, in order. Help and the hosted assistants' tool both print them. */
14722
14799
  const CAPTURE_PAGE_CALLS = [
14723
- "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.",
14724
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.",
14725
- "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."
14726
14803
  ];
14727
14804
  const CANVAS_CONVERSION_CAPABILITY_SPECS = [
14728
14805
  {
@@ -14804,8 +14881,7 @@ const CANVAS_CONVERSION_CAPABILITY_SPECS = [
14804
14881
  x: 5e3,
14805
14882
  y: 4e3
14806
14883
  },
14807
- baseVersion: 1,
14808
- waitMs: 1500
14884
+ waitMs: 0
14809
14885
  },
14810
14886
  earlierAnswers: CAPTURE_PAGE_CALLS,
14811
14887
  outputExample: {
@@ -16121,7 +16197,8 @@ const createCanvasRouter = (handlers, webOrigin) => trpcRouter({
16121
16197
  }));
16122
16198
  return {
16123
16199
  items: page.items.map((view) => toCanvasCardContract(view, webOrigin)),
16124
- truncated: page.truncated
16200
+ truncated: page.truncated,
16201
+ nextCursor: page.nextCursor
16125
16202
  };
16126
16203
  }),
16127
16204
  rename: canvasOwnerProcedure.input(renameCanvasInputSchema).output(canvasSchema).mutation(async ({ input, ctx }) => {
@@ -17824,9 +17901,9 @@ const createCanvasWalkthroughRouter = (handlers) => trpcRouter({ copyWalkthrough
17824
17901
 
17825
17902
  //#endregion
17826
17903
  //#region ../api/src/shared/auth/capture-pass.lib.ts
17827
- const CAPTURE_PASS_MINUTES = 15;
17828
- const MINUTE_MS = 6e4;
17829
- 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;
17830
17907
  /** A pass's claims, read back only from a pass the API sealed. */
17831
17908
  const capturePassClaimsSchema = z.strictObject({
17832
17909
  personId: z.uuid(),
@@ -17843,7 +17920,7 @@ const capturePassClaimsSchema = z.strictObject({
17843
17920
  * Issues the capture pass an agent hands to a page. Only an agent that may edit the canvas gets
17844
17921
  * one, and the pass names that agent, so revoking the agent ends it.
17845
17922
  */
17846
- 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 }) => {
17847
17924
  if (ctx.viewer.kind !== "agent") throw toTrpcError(appError("UNAUTHORIZED", "this call needs an agent token"));
17848
17925
  const settings = options.capturePass;
17849
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-G_YH4nyt.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-B3YsMYh-.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";
@@ -1909,7 +1909,7 @@ const registerCanvasProgram = (program, input) => {
1909
1909
  };
1910
1910
 
1911
1911
  //#endregion
1912
- //#region ../../packages/sdk/dist/stall-watch.lib-BuEofb7k.mjs
1912
+ //#region ../../packages/sdk/dist/stall-watch.lib-CjZG1Ibk.mjs
1913
1913
  const CAPTURE_METADATA_LENGTH = 200;
1914
1914
  const CAPTURE_FAILURE_LENGTH = 1e3;
1915
1915
  const CAPTURE_UPLOAD_BATCH_SIZE = 400;
@@ -3110,6 +3110,10 @@ const paginationSchema = z.object({
3110
3110
  cursor: z.string().nullable().default(null),
3111
3111
  limit: z.number().int().min(1).max(100).default(20)
3112
3112
  });
3113
+ const pageSchema = (item) => z.object({
3114
+ items: z.array(item),
3115
+ nextCursor: z.string().nullable()
3116
+ });
3113
3117
  /**
3114
3118
  * A collection bounded by human behaviour rather than by a cursor: every row up to a
3115
3119
  * ceiling, and a flag saying the ceiling was hit.
@@ -3231,6 +3235,14 @@ const collectionSchema = z.union([
3231
3235
  z.literal("everything"),
3232
3236
  z.uuid()
3233
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
+ ]);
3234
3246
  z.object({
3235
3247
  collection: collectionSchema.default("own"),
3236
3248
  title: z.string().trim().min(1).optional().describe("Title text to match before returning canvas ids."),
@@ -3242,7 +3254,13 @@ z.object({
3242
3254
  "mine",
3243
3255
  "shared"
3244
3256
  ]).default("all"),
3245
- 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()
3246
3264
  });
3247
3265
  const canvasCardBaseSchema = linkedCanvasSchema.extend({
3248
3266
  screenCount: z.number().int().min(0),
@@ -3250,10 +3268,10 @@ const canvasCardBaseSchema = linkedCanvasSchema.extend({
3250
3268
  /** When the person listing last opened it in the web app; `null` if they never have. */
3251
3269
  lastViewedAt: z.iso.datetime().nullable()
3252
3270
  });
3253
- cappedSchema(z.union([canvasCardBaseSchema.extend({ thumbnail: canvasThumbnailPreviewSchema }), canvasCardBaseSchema.extend({
3271
+ pageSchema(z.union([canvasCardBaseSchema.extend({ thumbnail: canvasThumbnailPreviewSchema }), canvasCardBaseSchema.extend({
3254
3272
  thumbnail: z.null(),
3255
3273
  thumbnailFallbackReason: thumbnailFallbackReasonSchema
3256
- })]));
3274
+ })])).extend({ truncated: z.boolean() });
3257
3275
  z.object({
3258
3276
  canvasId: z.uuid(),
3259
3277
  title: z.string().trim().min(1)
@@ -5354,7 +5372,7 @@ const canvasTextStyleSchema = z.object({
5354
5372
  message: "A published revision belongs to a source style and canvas.",
5355
5373
  path: ["sourceRevision"]
5356
5374
  });
5357
- z.object({
5375
+ const canvasTextStyleBindingSchema = z.object({
5358
5376
  id: canvasTextStyleSchema.shape.id,
5359
5377
  position: z.enum([
5360
5378
  "normal",
@@ -5823,6 +5841,9 @@ canvasTextParagraphSchema.pick({
5823
5841
  decorationBlendMode: canvasTypographySchema.shape.decoration.shape.blendMode,
5824
5842
  backgroundBlendMode: canvasBlendModeSchema.optional()
5825
5843
  }).strip();
5844
+ canvasTextParagraphSchema.optional();
5845
+ canvasTextStyleBindingSchema.optional();
5846
+ Object.freeze([]);
5826
5847
  const CANVAS_FONT_CONTENT_TYPES = [
5827
5848
  "font/ttf",
5828
5849
  "font/otf",
@@ -9576,6 +9597,29 @@ z.object({
9576
9597
  /** Screens survive with their provenance nulled. That is what makes iteration safe. */
9577
9598
  detachedScreenCount: z.number().int().min(0)
9578
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(", ");
9579
9623
  z.object({
9580
9624
  /**
9581
9625
  * Client-minted, once per capture attempt. A retry is the same screen; a re-capture at the
@@ -10071,7 +10115,8 @@ const CANVAS_SYNC_REPORTS = [
10071
10115
  "retrying",
10072
10116
  "recovery",
10073
10117
  "trace",
10074
- "update-required"
10118
+ "update-required",
10119
+ "parts-mismatch"
10075
10120
  ];
10076
10121
  /** How a failed document read was answered, on the report of one worth a look. */
10077
10122
  const CANVAS_SYNC_READ_OUTCOMES = [
@@ -10283,6 +10328,9 @@ z.strictObject({
10283
10328
  readOutcome: z.enum(CANVAS_SYNC_READ_OUTCOMES).optional(),
10284
10329
  status: z.enum(CANVAS_SYNC_REPORT_STATUSES).optional(),
10285
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(),
10286
10334
  trace: canvasSaveTraceSchema.optional()
10287
10335
  });
10288
10336
  z.object({
@@ -10800,7 +10848,7 @@ const startStallWatch = (caller, idleMs = STALL_MS) => {
10800
10848
  };
10801
10849
 
10802
10850
  //#endregion
10803
- //#region ../../packages/sdk/dist/capture-client.client-D5I-J6jl.mjs
10851
+ //#region ../../packages/sdk/dist/capture-client.client-XD3yn5Xr.mjs
10804
10852
  const line = (text) => `Enhance: ${text}\n`;
10805
10853
  /** A left-out capture by its journey and step, or by its test when it could not be read at all. */
10806
10854
  const leftOutName = (leftOut, attempts) => {
@@ -13028,7 +13076,7 @@ const main = async () => {
13028
13076
  const remote = createHttpRemoteAdapter(config.apiUrl, credentials, mutationKey);
13029
13077
  const cli = createCliProgram({
13030
13078
  apiUrl: config.apiUrl,
13031
- version: "0.1.175",
13079
+ version: "0.1.177",
13032
13080
  credentials,
13033
13081
  remote,
13034
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-G_YH4nyt.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-B3YsMYh-.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-Du3nYNyJ.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-G_YH4nyt.mjs";
3
- import { a as readLocalMcpEnvironment, t as installZodMessages } from "./zod-messages.lib-B3YsMYh-.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-Du3nYNyJ.mjs";
6
- import { n as createMcpCanvasProfileAdapter, t as createMcpInvocationAdapter } from "./mcp-invocation.adapter-COoROuob.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.175" });
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.175",
181
+ version: "0.1.177",
182
182
  invocation,
183
183
  clientMetadata: client.metadata,
184
184
  catalog
185
185
  }) : createMcpServerAdapter({
186
- version: "0.1.175",
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-G_YH4nyt.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";
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-G_YH4nyt.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-Du3nYNyJ.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-G_YH4nyt.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-B3YsMYh-.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-Du3nYNyJ.mjs";
5
- import { n as createMcpCanvasProfileAdapter, t as createMcpInvocationAdapter } from "./mcp-invocation.adapter-COoROuob.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.175",
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-G_YH4nyt.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.175",
3
+ "version": "0.1.177",
4
4
  "private": false,
5
5
  "description": "Agent-first command-line interface for Enhance.",
6
6
  "keywords": [