@enhance-eng/enhance 0.1.170 → 0.1.172
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{cli-output-identity.lib-CKns8qEG.mjs → cli-output-identity.lib-BsDqFLVA.mjs} +233 -60
- package/dist/main.mjs +80 -17
- package/dist/{mcp-invocation.adapter-BfWB3PFL.mjs → mcp-invocation.adapter-DGgt79VT.mjs} +10 -10
- package/dist/mcp-main.mjs +7 -7
- package/dist/{mcp-server.adapter-UiOcYGPZ.mjs → mcp-server.adapter-CbObvH7Y.mjs} +79 -25
- package/dist/mcp.mjs +2 -2
- package/dist/remote-mcp-main.mjs +6 -6
- package/dist/{zod-messages.lib-G2BtVFRk.mjs → zod-messages.lib-B8yowT7b.mjs} +74 -17
- package/package.json +1 -1
|
@@ -720,6 +720,36 @@ const markCanvasViewedOutputSchema = z.object({ lastViewedAt: z.iso.datetime().n
|
|
|
720
720
|
const restoreCanvasInputSchema = z.object({ canvasId: z.uuid() });
|
|
721
721
|
const restoreCanvasOutputSchema = z.object({ canvasId: z.uuid() });
|
|
722
722
|
|
|
723
|
+
//#endregion
|
|
724
|
+
//#region ../../packages/contract/src/canvas/canvas-activity-end.schema.ts
|
|
725
|
+
/** The most layers one agent activity names, as its start allows. */
|
|
726
|
+
const MAX_ACTIVITY_TARGETS$1 = 100;
|
|
727
|
+
/**
|
|
728
|
+
* Without an id, the call ends the calling token's activity on the canvas. With layer ids, it
|
|
729
|
+
* takes those layers out of the mark, and ends the activity when none remain.
|
|
730
|
+
*/
|
|
731
|
+
const endCanvasActivityInputSchema = z.object({
|
|
732
|
+
canvasId: z.uuid(),
|
|
733
|
+
activityId: z.uuid().optional(),
|
|
734
|
+
nodeIds: z.array(z.string().min(1)).max(MAX_ACTIVITY_TARGETS$1).default([])
|
|
735
|
+
});
|
|
736
|
+
/**
|
|
737
|
+
* What finishing did: ended the mark, took the named layers out of it, or found nothing live,
|
|
738
|
+
* which is a success: the agent has finished either way.
|
|
739
|
+
*/
|
|
740
|
+
const endCanvasActivityOutputSchema = z.discriminatedUnion("outcome", [
|
|
741
|
+
z.object({
|
|
742
|
+
outcome: z.literal("ended"),
|
|
743
|
+
activityId: z.uuid()
|
|
744
|
+
}),
|
|
745
|
+
z.object({
|
|
746
|
+
outcome: z.literal("narrowed"),
|
|
747
|
+
activityId: z.uuid(),
|
|
748
|
+
remainingNodeIds: z.array(z.string().min(1)).min(1)
|
|
749
|
+
}),
|
|
750
|
+
z.object({ outcome: z.literal("nothing-live") })
|
|
751
|
+
]);
|
|
752
|
+
|
|
723
753
|
//#endregion
|
|
724
754
|
//#region ../../packages/contract/src/canvas/canvas-css-value.schema.ts
|
|
725
755
|
const unsafeStyleValue = /javascript|vbscript|data\s*:\s*text\/html|expression\s*\(|@import/iu;
|
|
@@ -5156,14 +5186,11 @@ const beginCanvasActivityInputSchema = z.object({
|
|
|
5156
5186
|
const beginCanvasActivityOutputSchema = z.object({
|
|
5157
5187
|
activityId: z.uuid(),
|
|
5158
5188
|
expiresAt: z.iso.datetime(),
|
|
5159
|
-
renewAfterMs: z.number().int().positive()
|
|
5189
|
+
renewAfterMs: z.number().int().positive(),
|
|
5190
|
+
/** The layers the mark names after this call: a start keeps the ones a live mark had. */
|
|
5191
|
+
nodeIds: z.array(z.string().min(1)).max(MAX_ACTIVITY_TARGETS).optional()
|
|
5160
5192
|
});
|
|
5161
5193
|
const renewCanvasActivityInputSchema = beginCanvasActivityInputSchema.extend({ activityId: z.uuid() });
|
|
5162
|
-
const endCanvasActivityInputSchema = z.object({
|
|
5163
|
-
canvasId: z.uuid(),
|
|
5164
|
-
activityId: z.uuid()
|
|
5165
|
-
});
|
|
5166
|
-
const endCanvasActivityOutputSchema = z.object({ ended: z.literal(true) });
|
|
5167
5194
|
const serverEnvelopeBase = {
|
|
5168
5195
|
v: z.literal(1),
|
|
5169
5196
|
seq: z.number().int().nonnegative()
|
|
@@ -10738,15 +10765,6 @@ var CliError = class extends Error {
|
|
|
10738
10765
|
*/
|
|
10739
10766
|
const isFormatRefusalError = (error) => error instanceof CliError && error.fields?.["documentFormatVersion"] !== void 0;
|
|
10740
10767
|
|
|
10741
|
-
//#endregion
|
|
10742
|
-
//#region src/application/partial-batch.error.ts
|
|
10743
|
-
var PartialBatchError = class extends CliError {
|
|
10744
|
-
constructor(message, remediation, details) {
|
|
10745
|
-
super(details?.code ?? "INTERNAL", message, remediation, details?.fields);
|
|
10746
|
-
this.name = "PartialBatchError";
|
|
10747
|
-
}
|
|
10748
|
-
};
|
|
10749
|
-
|
|
10750
10768
|
//#endregion
|
|
10751
10769
|
//#region src/application/skill-texts.use-case.ts
|
|
10752
10770
|
/** The skills, by the short name each has before a surface names it. */
|
|
@@ -10779,17 +10797,100 @@ const wordsOf = (skill, wording) => {
|
|
|
10779
10797
|
command: isTool ? wording.command : ""
|
|
10780
10798
|
};
|
|
10781
10799
|
};
|
|
10800
|
+
/**
|
|
10801
|
+
* Each design rule that a tool repeats where it applies, one sentence each. The guide, the
|
|
10802
|
+
* start-up list and the tools hold the same sentence, so the surfaces cannot drift apart; no
|
|
10803
|
+
* sentence names a command or a tool, so it reads the same on every surface.
|
|
10804
|
+
*/
|
|
10805
|
+
const DESIGN_RULES = {
|
|
10806
|
+
look: "Read the canvas outline first: its screens, their widths, and what the person has selected.",
|
|
10807
|
+
brief: "Before the first write, tell the person your design brief in a few lines: the moods you considered and the one you chose, five or six colours with their roles, the type, and the direction in one line.",
|
|
10808
|
+
fonts: "Use the canvas's fonts or import one; put an @font-face whose src is the path the import returned in each write that uses it, since the family name alone draws a fallback. If you cannot, use the closest, say so, and go on.",
|
|
10809
|
+
units: "Set font sizes and line heights in px, and letter spacing in em.",
|
|
10810
|
+
sizes: "Start a new screen at 1440 by 900 for desktop, 768 by 1024 for tablet or 390 by 844 for mobile, unless the brief or the product says otherwise; the height is only a starting point.",
|
|
10811
|
+
group: "Write one visual group per call, about 15 lines of HTML, so the screen grows in view.",
|
|
10812
|
+
html: "Write inline styles with flex, padding and gap, and a layer-name attribute on each element, since other name attributes are dropped; set the font family on each group, since a group does not take it from the layer it goes into. No margins, grids or tables.",
|
|
10813
|
+
rows: "In repeated rows, give icons, values and trailing actions a fixed width, and keep the slot when a row has nothing in it.",
|
|
10814
|
+
review: "After each section, get a picture of the screen, check it against the review list, and tell the person one line that starts with \"Review:\".",
|
|
10815
|
+
scale: "Use scale 1 for layout; use 2 only to read small text.",
|
|
10816
|
+
fit: "When a frame cuts its content off, set its height to fit its content with the style \"height\": \"hug\"; never guess a new fixed height.",
|
|
10817
|
+
fix: "Fix what a picture shows with small edits, not by rebuilding the screen: starting again throws away work the person has watched, and content that overflows is never a reason to delete a frame.",
|
|
10818
|
+
ids: "Never show layer ids to the person; name screens and layers by what they are.",
|
|
10819
|
+
finish: "When you have finished, call finish, naming the screens or none; if refused, go on.",
|
|
10820
|
+
code: "For code, read exact values from the design, never from a picture."
|
|
10821
|
+
};
|
|
10782
10822
|
/** The heading over a skill's list: the tool has commands, and the plugin has tools. */
|
|
10783
10823
|
const listHeading = ({ two }) => two({
|
|
10784
10824
|
cli: "## Commands",
|
|
10785
10825
|
mcp: "## Tools"
|
|
10786
10826
|
});
|
|
10787
10827
|
/**
|
|
10828
|
+
* The design skill's rules, after its list of commands or tools: how to look first, the brief,
|
|
10829
|
+
* the look of a screen with no product to follow, how to write, review and finish.
|
|
10830
|
+
*/
|
|
10831
|
+
const designSections = (words) => `## Start by looking
|
|
10832
|
+
|
|
10833
|
+
${DESIGN_RULES.look}
|
|
10834
|
+
|
|
10835
|
+
A change to an existing screen keeps that screen's look. A new screen on a canvas that holds a product's screens follows those screens first: their fonts, sizes, colours, spacing and corner radii. The rules for the look below are for a screen with no product to follow.
|
|
10836
|
+
|
|
10837
|
+
## Tell the person your brief
|
|
10838
|
+
|
|
10839
|
+
${DESIGN_RULES.brief} Skip it only when the brief or the product already fixes the design.
|
|
10840
|
+
|
|
10841
|
+
- Moods: name three or four mood words, and choose one that is not the first that came to mind. Say in a few words why it fits better.
|
|
10842
|
+
- Colours: picture a scene for that mood, and take each colour from an object in it. Pure white is the usual ground, and one strong colour carries the screen.
|
|
10843
|
+
- Type: a display face and a text face, with their sizes.
|
|
10844
|
+
- Direction: one line on the layout idea.
|
|
10845
|
+
|
|
10846
|
+
## Decide the look
|
|
10847
|
+
|
|
10848
|
+
- Few elements, each doing work. Make the thing that matters most much bigger than the rest; a page of equal cards has no first read.
|
|
10849
|
+
- Pair heavy display type with light, small labels, as an editorial page does. Use three type sizes, far apart.
|
|
10850
|
+
- Vary the spacing: tight inside a group, generous between groups. Prefer an asymmetric layout to a centred one when the content allows.
|
|
10851
|
+
- Put content straight on the page. Add a card, border or shadow only to show grouping or something clickable, and leave out dated gradients and heavy shadows.
|
|
10852
|
+
- Light mode unless asked. No text under 13px, and text under 16px at 4.5:1 contrast or more.
|
|
10853
|
+
- A product screen should be clear at a glance. Brand and marketing work should impress, and can be playful. When the brief is vague, aim to impress.
|
|
10854
|
+
- Real words and numbers of realistic length. SVG for icons, not emoji.
|
|
10855
|
+
- Asked for several directions, change the layout or the idea, not only the colours, and keep the content the same.
|
|
10856
|
+
|
|
10857
|
+
## Fonts, units and sizes
|
|
10858
|
+
|
|
10859
|
+
- ${DESIGN_RULES.fonts} ${DESIGN_RULES.units}
|
|
10860
|
+
- ${DESIGN_RULES.sizes}
|
|
10861
|
+
- A mobile screen starts with the status bar of the guide's \`mobile-status-bar\` topic, pasted as its first child; never draw one by hand.
|
|
10862
|
+
|
|
10863
|
+
## Write a group at a time
|
|
10864
|
+
|
|
10865
|
+
- ${DESIGN_RULES.group}
|
|
10866
|
+
- ${DESIGN_RULES.html}
|
|
10867
|
+
- For repeated rows, write the container together with its first row, then copy that row with ${words.call("canvas.edit")} and change its text, rather than write the same HTML again. Read the copy's layers for their ids; never guess an id.
|
|
10868
|
+
- ${DESIGN_RULES.rows} After three similar rows, look at a picture and check that the slots line up down the page.
|
|
10869
|
+
- To restructure, move layers with ${words.call("canvas.edit")}; never delete a layer and write it again.
|
|
10870
|
+
|
|
10871
|
+
## Look at what you made
|
|
10872
|
+
|
|
10873
|
+
${DESIGN_RULES.review} ${DESIGN_RULES.scale} For more detail, get a picture of a smaller layer. The review list, in order:
|
|
10874
|
+
|
|
10875
|
+
1. Spacing: is it even where it should be even, tight in groups and generous between them?
|
|
10876
|
+
2. Type: are there few sizes, far apart, and none under 13px?
|
|
10877
|
+
3. Contrast: can all text be read against its ground, at 4.5:1 or more under 16px?
|
|
10878
|
+
4. Alignment: do edges and repeated rows line up down the page?
|
|
10879
|
+
5. Fit: is anything cut off or overflowing its frame?
|
|
10880
|
+
6. Repetition: do repeated items match one another, with no stray one?
|
|
10881
|
+
7. Is everything that was asked for there?
|
|
10882
|
+
|
|
10883
|
+
${DESIGN_RULES.fix} ${DESIGN_RULES.fit} Then look again.
|
|
10884
|
+
|
|
10885
|
+
## When you have finished
|
|
10886
|
+
|
|
10887
|
+
${DESIGN_RULES.finish} Then give the canvas link. ${DESIGN_RULES.ids}
|
|
10888
|
+
`;
|
|
10889
|
+
/**
|
|
10788
10890
|
* Each skill states its goal and names what the surface offers for it; the commands' own help
|
|
10789
10891
|
* and the tools' own descriptions teach the rest. A line is added only when measured runs are
|
|
10790
|
-
* worse without it; `skill-evaluation` holds the cases and what the last runs found
|
|
10791
|
-
*
|
|
10792
|
-
* and the record marks each as not measured.
|
|
10892
|
+
* worse without it; `skill-evaluation` holds the cases and what the last runs found, line group
|
|
10893
|
+
* by line group, for the design skill's rules too.
|
|
10793
10894
|
*/
|
|
10794
10895
|
const SKILLS = {
|
|
10795
10896
|
capture: {
|
|
@@ -10835,31 +10936,9 @@ ${listHeading(words)}
|
|
|
10835
10936
|
- ${learn("canvas.updateHtml", "rebuild the inside of a layer")} Use it only when the structure itself changes.
|
|
10836
10937
|
- ${learn("canvas.importAsset", "bring in an image or a font")}
|
|
10837
10938
|
- ${learn("canvas.render", "get a picture of a screen")}
|
|
10939
|
+
- ${learn("canvas.finishWorkingOnNodes", "say that you have finished, so your mark leaves the canvas")}
|
|
10838
10940
|
|
|
10839
|
-
|
|
10840
|
-
|
|
10841
|
-
A change to an existing screen keeps that screen's look. A new screen on a canvas that holds a product's screens takes their fonts, sizes, colours, spacing and corner radii. With no product to follow:
|
|
10842
|
-
|
|
10843
|
-
- White background, near-black text and one accent colour, used for the main action and little else, unless the brief asks otherwise.
|
|
10844
|
-
- Three type sizes, far apart: one large, one body, one small. No text under 13px, and body text at 4.5:1 contrast or more.
|
|
10845
|
-
- Make the thing that matters most much bigger than the rest. A page of equal cards has no first read.
|
|
10846
|
-
- Put content straight on the page and separate it with space: tight inside a group, generous between groups. Add a card, border or shadow only to show grouping or something clickable.
|
|
10847
|
-
- Real words and numbers of realistic length. SVG for icons, not emoji.
|
|
10848
|
-
- In repeated rows, give icons, values and trailing actions a fixed width, and keep the slot when a row has nothing in it.
|
|
10849
|
-
- Asked for several directions, change the layout or the idea, not only the accent colour, and keep the content the same.
|
|
10850
|
-
|
|
10851
|
-
## Look at what you made
|
|
10852
|
-
|
|
10853
|
-
After each screen, and after any change a person would notice, get a picture and check, in this order:
|
|
10854
|
-
|
|
10855
|
-
1. Is everything that was asked for there, and readable?
|
|
10856
|
-
2. Is anything cut off or overflowing its frame? Fix the frame's size or the content's wrapping; do not shrink the text.
|
|
10857
|
-
3. Do repeated rows line up down the page?
|
|
10858
|
-
4. Is the first thing you notice the thing that matters most?
|
|
10859
|
-
5. Is spacing even where it should be even?
|
|
10860
|
-
|
|
10861
|
-
Fix what you see with ${call("canvas.edit")}, not by rebuilding the screen, then look again.
|
|
10862
|
-
`;
|
|
10941
|
+
${designSections(words)}`;
|
|
10863
10942
|
}
|
|
10864
10943
|
},
|
|
10865
10944
|
"publish-prototype": {
|
|
@@ -10899,19 +10978,16 @@ ${listHeading(words)}
|
|
|
10899
10978
|
"apply-canvas-design": {
|
|
10900
10979
|
job: "applying a canvas design",
|
|
10901
10980
|
description: "Implement an approved or edited Enhance canvas design in the owning product source, republish it, and verify source-to-design fidelity. Use for canvas-to-code or canvas-to-prototype handoff.",
|
|
10902
|
-
body: (words) =>
|
|
10903
|
-
const { learn } = words;
|
|
10904
|
-
return `# Apply a canvas design
|
|
10981
|
+
body: (words) => `# Apply a canvas design
|
|
10905
10982
|
|
|
10906
10983
|
Make the product's source match an approved design on an Enhance canvas, then update the prototype on that canvas from the new build.
|
|
10907
10984
|
|
|
10908
10985
|
${listHeading(words)}
|
|
10909
10986
|
|
|
10910
|
-
- ${learn("canvas.read", "read the design: the canvas's outline, or one screen as HTML")}
|
|
10911
|
-
- ${learn("canvas.render", "get a picture of a screen")}
|
|
10912
|
-
- ${learn("prototype.publish", "update the prototype that is already on the canvas")} Read it before publishing.
|
|
10913
|
-
|
|
10914
|
-
}
|
|
10987
|
+
- ${words.learn("canvas.read", "read the design: the canvas's outline, or one screen as HTML")} ${DESIGN_RULES.code}
|
|
10988
|
+
- ${words.learn("canvas.render", "get a picture of a screen")}
|
|
10989
|
+
- ${words.learn("prototype.publish", "update the prototype that is already on the canvas")} Read it before publishing.
|
|
10990
|
+
`
|
|
10915
10991
|
}
|
|
10916
10992
|
};
|
|
10917
10993
|
/**
|
|
@@ -10919,20 +10995,88 @@ ${listHeading(words)}
|
|
|
10919
10995
|
* and development tools never overwrite one another's; the plugin's host names them itself.
|
|
10920
10996
|
*/
|
|
10921
10997
|
const skillTextsFor = (wording) => SKILL_NAMES.map((skill) => {
|
|
10922
|
-
const
|
|
10998
|
+
const { body: write, description } = SKILLS[skill];
|
|
10923
10999
|
const name = wording.surface === "cli" ? `${wording.commandName}-${skill}` : skill;
|
|
10924
|
-
const body =
|
|
11000
|
+
const body = write(wordsOf(skill, wording));
|
|
10925
11001
|
return {
|
|
10926
11002
|
skill,
|
|
10927
11003
|
name,
|
|
10928
|
-
description
|
|
11004
|
+
description,
|
|
10929
11005
|
body,
|
|
10930
|
-
text: `---\nname: ${name}\ndescription: ${
|
|
11006
|
+
text: `---\nname: ${name}\ndescription: ${description}\n---\n\n${body}`
|
|
10931
11007
|
};
|
|
10932
11008
|
});
|
|
10933
11009
|
/** The job each skill is for, in the order of the skills, for a sentence that lists them. */
|
|
10934
11010
|
const SKILL_JOBS = SKILL_NAMES.map((skill) => SKILLS[skill].job);
|
|
10935
11011
|
|
|
11012
|
+
//#endregion
|
|
11013
|
+
//#region src/application/design-guidance.use-case.ts
|
|
11014
|
+
/**
|
|
11015
|
+
* Where an agent meets the design rules besides the guide: the start-up list when it connects,
|
|
11016
|
+
* and the rules each tool and command repeats where it applies. Every sentence is one of the
|
|
11017
|
+
* guide's own, so no surface can teach a rule in other words.
|
|
11018
|
+
*/
|
|
11019
|
+
/** The places an agent writes, looks or finishes, each with the rules that apply there. */
|
|
11020
|
+
const POINTS_OF_USE = {
|
|
11021
|
+
create: ["brief"],
|
|
11022
|
+
write: [
|
|
11023
|
+
"brief",
|
|
11024
|
+
"sizes",
|
|
11025
|
+
"group",
|
|
11026
|
+
"html",
|
|
11027
|
+
"rows",
|
|
11028
|
+
"ids"
|
|
11029
|
+
],
|
|
11030
|
+
import: ["fonts"],
|
|
11031
|
+
update: ["html", "fix"],
|
|
11032
|
+
edit: [
|
|
11033
|
+
"fit",
|
|
11034
|
+
"fix",
|
|
11035
|
+
"ids"
|
|
11036
|
+
],
|
|
11037
|
+
render: ["review", "scale"],
|
|
11038
|
+
finish: ["finish"]
|
|
11039
|
+
};
|
|
11040
|
+
/** The rules for one point of use, as one paragraph for a tool's description or a command's help. */
|
|
11041
|
+
const pointOfUseText = (use) => POINTS_OF_USE[use].map((rule) => DESIGN_RULES[rule]).join(" ");
|
|
11042
|
+
/** The rules of the start-up list, in order, after the line that says to load the guide. */
|
|
11043
|
+
const START_UP_RULES = [
|
|
11044
|
+
"look",
|
|
11045
|
+
"brief",
|
|
11046
|
+
"fonts",
|
|
11047
|
+
"units",
|
|
11048
|
+
"group",
|
|
11049
|
+
"review",
|
|
11050
|
+
"fit",
|
|
11051
|
+
"rows",
|
|
11052
|
+
"ids",
|
|
11053
|
+
"finish",
|
|
11054
|
+
"code"
|
|
11055
|
+
];
|
|
11056
|
+
/**
|
|
11057
|
+
* The short list an agent meets when it connects: on an MCP server, its instructions; on the
|
|
11058
|
+
* command line, the top of `canvas --help`. Its first line says how this surface loads the guide.
|
|
11059
|
+
*/
|
|
11060
|
+
const startUpListFor = (wording) => [
|
|
11061
|
+
"Designing on an Enhance canvas:",
|
|
11062
|
+
`- ${loadGuideLineFor(wording)}`,
|
|
11063
|
+
...START_UP_RULES.map((rule) => `- ${DESIGN_RULES[rule]}`)
|
|
11064
|
+
].join("\n");
|
|
11065
|
+
/**
|
|
11066
|
+
* The start-up list's first line: how this surface loads the guide. The command line's canvas
|
|
11067
|
+
* help has room for this line alone; the guide holds every rule.
|
|
11068
|
+
*/
|
|
11069
|
+
const loadGuideLineFor = (wording) => wording.surface === "cli" ? `Load the design guide first: run \`${wording.command} canvas guide\` once in each session, before other commands, and again when a long thread may have lost it.` : "Load the design guide first: call workflow_guide with design-on-canvas once in each session, before other calls, and again when a long thread may have lost it.";
|
|
11070
|
+
|
|
11071
|
+
//#endregion
|
|
11072
|
+
//#region src/application/partial-batch.error.ts
|
|
11073
|
+
var PartialBatchError = class extends CliError {
|
|
11074
|
+
constructor(message, remediation, details) {
|
|
11075
|
+
super(details?.code ?? "INTERNAL", message, remediation, details?.fields);
|
|
11076
|
+
this.name = "PartialBatchError";
|
|
11077
|
+
}
|
|
11078
|
+
};
|
|
11079
|
+
|
|
10936
11080
|
//#endregion
|
|
10937
11081
|
//#region ../../packages/canvas-document/src/canvas-edit-words.consts.ts
|
|
10938
11082
|
/**
|
|
@@ -10967,6 +11111,7 @@ const MCP_TOOL_BY_CAPABILITY = {
|
|
|
10967
11111
|
"canvas.duplicateNodes": "canvas_duplicate",
|
|
10968
11112
|
"canvas.edit": "canvas_edit",
|
|
10969
11113
|
"canvas.find": "canvas_find",
|
|
11114
|
+
"canvas.finishWorkingOnNodes": "canvas_finish_working",
|
|
10970
11115
|
"canvas.importAsset": "asset_import",
|
|
10971
11116
|
"canvas.insertHtml": "canvas_insert_html",
|
|
10972
11117
|
"canvas.makeEditable": "canvas_make_editable",
|
|
@@ -12011,7 +12156,7 @@ const canvasRenderRequestSchema = z.strictObject({
|
|
|
12011
12156
|
canvasRenderTargetSchema.options[3].strict().extend({ bounds: canvasRenderTargetSchema.options[3].shape.bounds.strict() })
|
|
12012
12157
|
]),
|
|
12013
12158
|
sourceState: canvasRenderSourceStateSchema.strict().nullable().default(null),
|
|
12014
|
-
scale: z.number().positive().default(1),
|
|
12159
|
+
scale: z.number().positive().default(1).describe(DESIGN_RULES.scale),
|
|
12015
12160
|
waitMs: z.number().int().min(0).max(MAX_WAIT_MS).default(DEFAULT_WAIT_MS).describe("Additional local polling after the server returns an active job; render creation retains its existing bounded HTTP deadline.")
|
|
12016
12161
|
});
|
|
12017
12162
|
|
|
@@ -14036,6 +14181,29 @@ const createMcpCapabilityDiscoveryAdapter = (catalog) => ({
|
|
|
14036
14181
|
const toPresentedCapabilities = (catalog, exposures) => catalog.filter((capability) => exposures.includes(capability.policy.exposure));
|
|
14037
14182
|
const toSharedCapabilities = (catalog) => toPresentedCapabilities(catalog, ["shared"]);
|
|
14038
14183
|
|
|
14184
|
+
//#endregion
|
|
14185
|
+
//#region src/application/guide-topics.consts.ts
|
|
14186
|
+
/** Texts the design guide answers with by name, beside the skills. */
|
|
14187
|
+
const GUIDE_TOPIC_NAMES = ["mobile-status-bar"];
|
|
14188
|
+
/** A topic names no command and no tool, so every surface hands out the same text. */
|
|
14189
|
+
const GUIDE_TOPICS = { "mobile-status-bar": {
|
|
14190
|
+
description: "Paste-ready markup for the status bar at the top of a 390 px mobile screen: the time, signal and battery.",
|
|
14191
|
+
body: `# Mobile status bar
|
|
14192
|
+
|
|
14193
|
+
A mobile screen starts with a status bar. Paste this as the first child of a 390 px screen, and never draw one by hand. On a dark screen, change each \`#000000\` to \`#ffffff\`.
|
|
14194
|
+
|
|
14195
|
+
\`\`\`html
|
|
14196
|
+
<div layer-name="Status bar" style="display:flex;align-items:center;justify-content:space-between;width:390px;height:47px;padding:0 26px 0 32px;box-sizing:border-box;flex-shrink:0">
|
|
14197
|
+
<span layer-name="Time" style="font-family:Inter;font-size:16px;line-height:20px;font-weight:600;color:#000000">9:41</span>
|
|
14198
|
+
<div layer-name="Indicators" style="display:flex;align-items:center;gap:6px">
|
|
14199
|
+
<svg layer-name="Signal" width="18" height="12" viewBox="0 0 18 12"><rect x="0" y="9" width="3" height="3" rx="1" fill="#000000"/><rect x="5" y="6" width="3" height="6" rx="1" fill="#000000"/><rect x="10" y="3" width="3" height="9" rx="1" fill="#000000"/><rect x="15" y="0" width="3" height="12" rx="1" fill="#000000"/></svg>
|
|
14200
|
+
<svg layer-name="Battery" width="26" height="12" viewBox="0 0 26 12"><rect x="0.5" y="0.5" width="22" height="11" rx="3" fill="none" stroke="#000000" stroke-opacity="0.4"/><rect x="2" y="2" width="19" height="8" rx="2" fill="#000000"/><rect x="24" y="4" width="2" height="4" rx="1" fill="#000000" fill-opacity="0.4"/></svg>
|
|
14201
|
+
</div>
|
|
14202
|
+
</div>
|
|
14203
|
+
\`\`\`
|
|
14204
|
+
`
|
|
14205
|
+
} };
|
|
14206
|
+
|
|
14039
14207
|
//#endregion
|
|
14040
14208
|
//#region src/infrastructure/capability-example.mapper.ts
|
|
14041
14209
|
const jsonRecordSchema$2 = z.record(z.string(), z.unknown());
|
|
@@ -17295,7 +17463,8 @@ const createCanvasActivityRouter = (activity) => trpcRouter({
|
|
|
17295
17463
|
return {
|
|
17296
17464
|
activityId: started.activityId,
|
|
17297
17465
|
expiresAt: started.expiresAt.toISOString(),
|
|
17298
|
-
renewAfterMs: CANVAS_ACTIVITY_RENEW_AFTER_MS
|
|
17466
|
+
renewAfterMs: CANVAS_ACTIVITY_RENEW_AFTER_MS,
|
|
17467
|
+
nodeIds: [...started.nodeIds]
|
|
17299
17468
|
};
|
|
17300
17469
|
}),
|
|
17301
17470
|
renew: agentCanvasReaderProcedure.input(renewCanvasActivityInputSchema).output(beginCanvasActivityOutputSchema).mutation(async ({ input, ctx }) => {
|
|
@@ -17308,16 +17477,20 @@ const createCanvasActivityRouter = (activity) => trpcRouter({
|
|
|
17308
17477
|
return {
|
|
17309
17478
|
activityId: renewed.activityId,
|
|
17310
17479
|
expiresAt: renewed.expiresAt.toISOString(),
|
|
17311
|
-
renewAfterMs: CANVAS_ACTIVITY_RENEW_AFTER_MS
|
|
17480
|
+
renewAfterMs: CANVAS_ACTIVITY_RENEW_AFTER_MS,
|
|
17481
|
+
nodeIds: [...renewed.nodeIds]
|
|
17312
17482
|
};
|
|
17313
17483
|
}),
|
|
17314
17484
|
end: agentCanvasReaderProcedure.input(endCanvasActivityInputSchema).output(endCanvasActivityOutputSchema).mutation(async ({ input, ctx }) => {
|
|
17315
17485
|
if (ctx.viewer.kind !== "agent") throw new TypeError("agent identity was not narrowed");
|
|
17316
|
-
orThrow(await activity.end({
|
|
17486
|
+
const ended = orThrow(await activity.end({
|
|
17317
17487
|
...input,
|
|
17318
17488
|
tokenId: ctx.viewer.tokenId
|
|
17319
17489
|
}));
|
|
17320
|
-
return
|
|
17490
|
+
return ended.outcome === "narrowed" ? {
|
|
17491
|
+
...ended,
|
|
17492
|
+
remainingNodeIds: [...ended.remainingNodeIds]
|
|
17493
|
+
} : ended;
|
|
17321
17494
|
})
|
|
17322
17495
|
});
|
|
17323
17496
|
const createCanvasRealtimeRouter = (handlers, endpoint) => trpcRouter({
|
|
@@ -20463,4 +20636,4 @@ const withCommandInFailure = (value, commandName) => ({
|
|
|
20463
20636
|
});
|
|
20464
20637
|
|
|
20465
20638
|
//#endregion
|
|
20466
|
-
export {
|
|
20639
|
+
export { canvasWriteReceiptSchema as $, listCommentsOutputSchema as $n, reserveCanvasAssetOutputSchema as $r, callingSurface as $t, commentAttentionCapabilityInputSchema as A, endCanvasActivityOutputSchema as Ai, foldPrototypeArtifactPath as An, IMAGE_KIND as Ar, quotedValue as At, canvasPrototypeOutputSchema as B, createOrganisationOutputSchema as Bn, canvasBoxSourceOf as Br, encodeCanvasExchangeToken as Bt, OPTION_DESCRIPTIONS as C, emptyCanvasSceneDocument as Ci, appendRecordingChunkOutputSchema as Cn, canvasAgentActivityPhaseSchema as Cr, canvasEditCapabilityInputSchema as Ct, canvasReadCapabilityInputSchema as D, CANVAS_BLEND_MODES as Di, PROTOTYPE_ARTIFACT_MANIFEST_PATH as Dn, getCanvasPreparationOutputSchema as Dr, inputProblemSummary as Dt, canvasApplyCapabilityInputSchema as E, canvasAdditionalStyleSchema as Ei, startRecordingOutputSchema as En, createCanvasPreparationOutputSchema as Er, inputProblemFields as Et, canvasCapturePageInputSchema as F, submitPrototypeArtifactOutputSchema as Fn, canvasLayoutWithoutCssProperties as Fr, hasCanvasReferenceScope as Ft, canvasCaptureCapabilityInputSchema as G, commentCanvasContextSchema as Gn, canvasCssPixelValue as Gr, canvasUpdateHtmlCapabilityInputSchema as Gt, operationStatusImageSchema as H, emptyFixtureDocument as Hn, canvasAuthoredLayoutValueOf as Hr, canvasOutlineCursorSchema as Ht, canvasCapturePageOutputSchema as I, getMeOutputSchema as In, textOf as Ir, parseCanvasReference as It, canvasArrangeCapabilityInputSchema as J, commentThreadSchema as Jn, canvasLayoutPriorityDeclarations as Jr, canvasTranscriptCursorSchema as Jt, canvasCaptureInputSchema as K, commentMessageSchema as Kn, canvasLayoutMainAxisOf as Kr, canvasUpdateHtmlInputSchema as Kt, canvasPrototypeCapabilityInputSchema as L, MCP_AUTH_SCOPE as Ln, mapCanvasFontSources as Lr, canvasExchangeDigest as Lt, recordingSnapshotCapabilityInputSchema as M, getPrototypePublishStatusOutputSchema as Mn, RECTANGLE_KIND as Mr, canvasReferenceNodeIds as Mt, transcriptReadCapabilityInputSchema as N, prototypeArtifactManifestSchema as Nn, SCREEN_KIND as Nr, canvasReferenceRenderTarget as Nt, canvasRenderCapabilityInputSchema as O, canvasBlendModeSchema as Oi, attachPrototypeArtifactOutputSchema as On, FRAME_KIND as Or, isInputRecord as Ot, canvasCapturePageCapabilityInputSchema as P, prototypeArtifactPathSchema as Pn, TEXT_KIND as Pr, fromCanvasReference as Pt, canvasPreparationOutputSchema as Q, listCommentsInputSchema as Qn, reserveCanvasAssetInputSchema as Qr, callOf as Qt, canvasPrototypeInputSchema as R, cliAuthConfigurationSchema as Rn, saveCanvasDocumentOutputSchema as Rr, canvasSnapshotToken as Rt, ProcessExitError as S, canvasSceneDocumentSchema as Si, createScreenOutputSchema as Sn, beginCanvasActivityOutputSchema as Sr, canvasMakeEditableInputSchema as St, PROCEDURE_DESCRIPTIONS as T, signedDownloadSchema as Ti, getRecordingOutputSchema as Tn, agentClientMetadata as Tr, ROOT_FIELD as Tt, operationStatusInputSchema as U, withFixtureScreen as Un, canvasAuthoredStyleDeclarations as Ur, canvasReadInputSchema as Ut, canvasConversionStatusSchema as V, listOrganisationsOutputSchema as Vn, canvasRecordedBoxNoteFor as Vr, resolveCanvasSnapshot as Vt, operationStatusOutputSchema as W, commentAuthorSchema as Wn, canvasAxisStyleProperties as Wr, canvasReadOutputSchema as Wt, canvasDuplicateCapabilityInputSchema as X, elementAnchorSchema as Xn, canvasCssValue as Xr, tallyCanvasWork as Xt, canvasArrangeInputSchema as Y, domLocatorSchema as Yn, canvasCssTokens as Yr, canvasResourcesCursorSchema as Yt, canvasDuplicateInputSchema as Z, getCommentOutputSchema as Zn, canvasAssetUploadOutputSchema as Zr, readStoredCanvasScene as Zt, toPublishedExitTable as _, createCanvasRenderOutputSchema as _i, CliError as _n, canvasRecordingPropsSchema as _r, createdCanvasAnswerSchema as _t, createRouterShapeAdapter as a, editCanvasOutputSchema as ai, inputName as an, screenTextCommentTargetSchema as ar, canvasRenderPendingSchema as at, CAPABILITY_UUID_EXAMPLE as b, getCanvasRenderOutputSchema as bi, appErrorSchema as bn, canvasReferencePageOf as br, canvasInsertHtmlInputSchema as bt, toKebabCase as c, getCanvasMutationOutputSchema as ci, CANVAS_EDIT_WORDS as cn, applyCanvasTypographyPatch as cr, canvasRenderRequestSchema as ct, toPresentedCapabilities as d, createCanvasConversionOutputSchema as di, pointOfUseText as dn, canvasTextPropsWithContent as dr, canvasRemoveInputSchema as dt, canvasFontAssetIdentityFromPath as ei, cliPathOf as en, replyCommentInputSchema as er, canvasAssetImportCapabilityInputSchema as et, toSharedCapabilities as f, getCanvasConversionOutputSchema as fi, startUpListFor as fn, canvasTextRunsOf as fr, canvasCreateToolInputSchema as ft, toMcpFailurePayload as g, canvasWorldBoundsSchema as gi, skillTextsFor as gn, canvasPrototypePropsSchema as gr, canvasFindOutputSchema as gt, toFailurePayload as h, canvasRenderTargetSchema as hi, SKILL_NAMES as hn, canvasConversionMetadataSchema as hr, canvasFindInputSchema as ht, createLazyCapabilityCatalogAdapter as i, CANVAS_RICH_TEXT_STYLE_PROPERTIES as ii, inSurfaceWords as in, screenElementsCommentTargetSchema as ir, canvasRenderBatchResultSchema as it, prototypePublishCapabilityInputSchema as j, canvasSchema as ji, getPrototypeArtifactCapabilitiesOutputSchema as jn, PAGE_KIND as jr, assertCanvasReferenceNodes as jt, canvasWriteHtmlCapabilityInputSchema as k, canvasPaintSchema as ki, createPrototypeArtifactOutputSchema as kn, GROUP_KIND as kr, objectFieldNames as kt, GUIDE_TOPICS as l, canvasOperationSchema as li, PartialBatchError as ln, canvasCssTypographyOwners as lr, canvasRenderFileSchema as lt, toExitCode as m, canvasRenderStateSchema as mi, SKILL_JOBS as mn, canvasCaptureSchema as mr, canvasFindCursorSchema as mt, withCommandName as n, canvasRichTextValueOf as ni, currentNodeIdStep as nn, screenAreaCommentTargetSchema as nr, canvasAssetImportOutputSchema as nt, CAPTURE_PAGE_CALLS as o, applyCanvasOperationsInputSchema as oi, onSurface as on, startCommentInputSchema as or, canvasRenderScopedInputSchema as ot, createMcpCapabilityDiscoveryAdapter as p, canvasRenderSourceStateSchema as pi, DESIGN_RULES as pn, CAPTURE_LANDING_CONVERTING as pr, canvasCreateToolOutputSchema as pt, canvasCaptureOutputSchema as q, commentResolverSchema as qn, canvasLayoutPositionOf as qr, retryClientTokenSchema as qt, toCanvasAuthoringResult as r, hasCanvasRichTextPaints as ri, diagnosisStep as rn, screenElementCommentTargetSchema as rr, canvasRenderBatchRequestSchema as rt, toCapabilityDefinition as s, applyCanvasOperationsOutputSchema as si, MCP_TOOL_BY_CAPABILITY as sn, createCapturePassOutputSchema as sr, canvasRenderScopedToolInputSchema as st, withCommandInFailure as t, canvasRichTextOf as ti, commandName as tn, replyCommentOutputSchema as tr, canvasAssetImportInputSchema as tt, GUIDE_TOPIC_NAMES as u, canvasNodeStylePatchSchema as ui, loadGuideLineFor as un, canvasTextChangeBetween as ur, canvasRemoveCapabilityInputSchema as ut, toRemoteError as v, createRecordingSnapshotOutputSchema as vi, isFormatRefusalError as vn, captureLandingSchema as vr, listedCanvasesAnswerSchema as vt, PROTOTYPE_UPDATE_GUIDANCE as w, canvasImageAssetIdentityFromPath as wi, completeRecordingOutputSchema as wn, AGENT_CLIENT_HEADER as wr, canvasEditsSchema as wt, createCapabilityPolicyAdapter as x, canvasReadableSceneDocumentSchema as xi, completeScreenOutputSchema as xn, resolveCanvasReference as xr, canvasMakeEditableCapabilityInputSchema as xt, CANVAS_UPDATE_HTML_INPUT_EXAMPLE as y, downloadCanvasRenderOutputSchema as yi, transcriptOutputSchema as yn, DEFAULT_CANVAS_REFERENCE_PAGE_ID as yr, canvasInsertHtmlCapabilityInputSchema as yt, canvasPrototypeIntentSchema as z, createAgentTokenOutputSchema as zn, wholeCanvasDocumentOutputSchema as zr, decodeCanvasExchangeToken as zt };
|
package/dist/main.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
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-
|
|
2
|
+
import { At as quotedValue, Bn as createOrganisationOutputSchema, C as OPTION_DESCRIPTIONS, Ci as emptyCanvasSceneDocument$1, Cn as appendRecordingChunkOutputSchema, Cr as canvasAgentActivityPhaseSchema$1, Dt as inputProblemSummary, En as startRecordingOutputSchema, Et as inputProblemFields, Ft as hasCanvasReferenceScope, Gt as canvasUpdateHtmlCapabilityInputSchema, Hn as emptyFixtureDocument, Hr as canvasAuthoredLayoutValueOf, It as parseCanvasReference, Jr as canvasLayoutPriorityDeclarations, Kr as canvasLayoutMainAxisOf, Nt as canvasReferenceRenderTarget, Ot as isInputRecord, Pt as fromCanvasReference, Rr as saveCanvasDocumentOutputSchema, S as ProcessExitError, Sn as createScreenOutputSchema, Sr as beginCanvasActivityOutputSchema, T as PROCEDURE_DESCRIPTIONS, Tt as ROOT_FIELD, U as operationStatusInputSchema, Un as withFixtureScreen, Ur as canvasAuthoredStyleDeclarations, Ut as canvasReadInputSchema, Wr as canvasAxisStyleProperties, Zt as readStoredCanvasScene, _ as toPublishedExitTable, _n as CliError, a as createRouterShapeAdapter, b as CAPABILITY_UUID_EXAMPLE, bn as appErrorSchema$1, c as toKebabCase, dn as pointOfUseText, en as cliPathOf, f as toSharedCapabilities, fr as canvasTextRunsOf, gi as canvasWorldBoundsSchema$1, gn as skillTextsFor, h as toFailurePayload, ht as canvasFindInputSchema, i as createLazyCapabilityCatalogAdapter, ji as canvasSchema$1, jt as assertCanvasReferenceNodes, kt as objectFieldNames, l as GUIDE_TOPICS, li as canvasOperationSchema$1, ln as PartialBatchError, m as toExitCode, n as withCommandName, nn as currentNodeIdStep, ot as canvasRenderScopedInputSchema, p as createMcpCapabilityDiscoveryAdapter, r as toCanvasAuthoringResult, t as withCommandInFailure, u as GUIDE_TOPIC_NAMES, un as loadGuideLineFor, ut as canvasRemoveCapabilityInputSchema, wn as completeRecordingOutputSchema, wt as canvasEditsSchema, x as createCapabilityPolicyAdapter, xn as completeScreenOutputSchema, y as CANVAS_UPDATE_HTML_INPUT_EXAMPLE, zr as wholeCanvasDocumentOutputSchema } from "./cli-output-identity.lib-BsDqFLVA.mjs";
|
|
3
|
+
import { A as canvasAngularGradientSvg, C as sceneAtVersion, D as canvasLinearGradientSvg, E as canvasRadialGradientSvg, O as canvasFilterListCss, S as createCanvasActivityComposite, T as createAuthUseCase, _ as readCanvasReferenceScene, b as createEditCanvasComposite, c as createOauthLoopbackAdapter, d as isJsonValued, f as createCapabilityInvocationAdapter, g as createRenderFileAdapter, i as readCliEnvironment, j as canvasColorCss, k as canvasDiamondGradientSvg, l as toInputHelp, n as createMutationKeyAdapter, r as createHttpRemoteAdapter, s as readToolMachine, t as installZodMessages, u as withCapabilityNames, v as createWriteHtmlCanvasComposite, w as createRenderCanvasComposite, x as assertCanvasReferenceOperations } from "./zod-messages.lib-B8yowT7b.mjs";
|
|
4
4
|
import { t as toCapabilityInventory } from "./capability-inventory.mapper-DyYXyVBJ.mjs";
|
|
5
5
|
import { t as createFileCredentialAdapter } from "./file-credential.adapter-CShGZcd5.mjs";
|
|
6
6
|
import process from "node:process";
|
|
@@ -833,11 +833,15 @@ const configureUpdate = (work, input) => {
|
|
|
833
833
|
});
|
|
834
834
|
};
|
|
835
835
|
const configureFinish = (canvas, input) => {
|
|
836
|
-
canvas.command("finish-working-on-nodes").description("
|
|
837
|
-
|
|
836
|
+
canvas.command("finish-working-on-nodes").description("Say you have finished: end your mark on the canvas, or narrow it.").requiredOption("--canvas <url-or-id>", "Canvas URL or UUID.").option("--node-ids <ids>", "Comma-separated screens you finished; leave out when you have finished on this canvas.").option("--activity-id <uuid>", "A lease id from canvas work begin; leave out for your own.").action(async (options) => {
|
|
837
|
+
const ended = await createCanvasActivityComposite(input.remote).finish({
|
|
838
|
+
canvasId: fromCanvasReference(options.canvas),
|
|
839
|
+
activityId: options.activityId === void 0 ? void 0 : authoringUuidSchema.parse(options.activityId),
|
|
840
|
+
nodeIds: nodeIdsFrom(options.nodeIds)
|
|
841
|
+
});
|
|
838
842
|
input.output.result({
|
|
839
|
-
ended
|
|
840
|
-
|
|
843
|
+
...ended,
|
|
844
|
+
...ended.outcome === "nothing-live" && { note: "Nothing was live on this canvas." }
|
|
841
845
|
});
|
|
842
846
|
});
|
|
843
847
|
};
|
|
@@ -1887,7 +1891,7 @@ const registerCanvasProgram = (program, input) => {
|
|
|
1887
1891
|
};
|
|
1888
1892
|
|
|
1889
1893
|
//#endregion
|
|
1890
|
-
//#region ../../packages/sdk/dist/stall-watch.lib-
|
|
1894
|
+
//#region ../../packages/sdk/dist/stall-watch.lib-DwUtOrzm.mjs
|
|
1891
1895
|
const CAPTURE_METADATA_LENGTH = 200;
|
|
1892
1896
|
const CAPTURE_FAILURE_LENGTH = 1e3;
|
|
1893
1897
|
const CAPTURE_UPLOAD_BATCH_SIZE = 400;
|
|
@@ -3282,6 +3286,23 @@ z.object({ canvasId: z.uuid() });
|
|
|
3282
3286
|
z.object({ lastViewedAt: z.iso.datetime().nullable() });
|
|
3283
3287
|
z.object({ canvasId: z.uuid() });
|
|
3284
3288
|
z.object({ canvasId: z.uuid() });
|
|
3289
|
+
z.object({
|
|
3290
|
+
canvasId: z.uuid(),
|
|
3291
|
+
activityId: z.uuid().optional(),
|
|
3292
|
+
nodeIds: z.array(z.string().min(1)).max(100).default([])
|
|
3293
|
+
});
|
|
3294
|
+
z.discriminatedUnion("outcome", [
|
|
3295
|
+
z.object({
|
|
3296
|
+
outcome: z.literal("ended"),
|
|
3297
|
+
activityId: z.uuid()
|
|
3298
|
+
}),
|
|
3299
|
+
z.object({
|
|
3300
|
+
outcome: z.literal("narrowed"),
|
|
3301
|
+
activityId: z.uuid(),
|
|
3302
|
+
remainingNodeIds: z.array(z.string().min(1)).min(1)
|
|
3303
|
+
}),
|
|
3304
|
+
z.object({ outcome: z.literal("nothing-live") })
|
|
3305
|
+
]);
|
|
3285
3306
|
const unsafeStyleValue = /javascript|vbscript|data\s*:\s*text\/html|expression\s*\(|@import/iu;
|
|
3286
3307
|
const canvasCssValueSchema = z.string().refine((value) => !unsafeStyleValue.test(value), "unsafe CSS value");
|
|
3287
3308
|
const canvasNumberSchema = z.number();
|
|
@@ -6728,14 +6749,11 @@ const beginCanvasActivityInputSchema = z.object({
|
|
|
6728
6749
|
z.object({
|
|
6729
6750
|
activityId: z.uuid(),
|
|
6730
6751
|
expiresAt: z.iso.datetime(),
|
|
6731
|
-
renewAfterMs: z.number().int().positive()
|
|
6752
|
+
renewAfterMs: z.number().int().positive(),
|
|
6753
|
+
/** The layers the mark names after this call: a start keeps the ones a live mark had. */
|
|
6754
|
+
nodeIds: z.array(z.string().min(1)).max(MAX_ACTIVITY_TARGETS).optional()
|
|
6732
6755
|
});
|
|
6733
6756
|
beginCanvasActivityInputSchema.extend({ activityId: z.uuid() });
|
|
6734
|
-
z.object({
|
|
6735
|
-
canvasId: z.uuid(),
|
|
6736
|
-
activityId: z.uuid()
|
|
6737
|
-
});
|
|
6738
|
-
z.object({ ended: z.literal(true) });
|
|
6739
6757
|
const serverEnvelopeBase = {
|
|
6740
6758
|
v: z.literal(1),
|
|
6741
6759
|
seq: z.number().int().nonnegative()
|
|
@@ -10714,7 +10732,7 @@ const startStallWatch = (caller, idleMs = STALL_MS) => {
|
|
|
10714
10732
|
};
|
|
10715
10733
|
|
|
10716
10734
|
//#endregion
|
|
10717
|
-
//#region ../../packages/sdk/dist/capture-client.client-
|
|
10735
|
+
//#region ../../packages/sdk/dist/capture-client.client-DgqxTJkF.mjs
|
|
10718
10736
|
const line = (text) => `Enhance: ${text}\n`;
|
|
10719
10737
|
/** A left-out capture by its journey and step, or by its test when it could not be read at all. */
|
|
10720
10738
|
const leftOutName = (leftOut, attempts) => {
|
|
@@ -12021,16 +12039,53 @@ const registerFixtureProgram = (program, composites, output) => {
|
|
|
12021
12039
|
|
|
12022
12040
|
//#endregion
|
|
12023
12041
|
//#region src/infrastructure/guide.program.ts
|
|
12024
|
-
/**
|
|
12042
|
+
/** The commands where an agent writes, looks or finishes, each with the rules it repeats. */
|
|
12043
|
+
const POINT_OF_USE_COMMANDS = {
|
|
12044
|
+
create: "create",
|
|
12045
|
+
"insert-html": "write",
|
|
12046
|
+
"write-html": "write",
|
|
12047
|
+
"update-html": "update",
|
|
12048
|
+
edit: "edit",
|
|
12049
|
+
render: "render",
|
|
12050
|
+
"finish-working-on-nodes": "finish",
|
|
12051
|
+
"import-asset": "import"
|
|
12052
|
+
};
|
|
12053
|
+
const GUIDE_NAMES = ["design-on-canvas", ...GUIDE_TOPIC_NAMES];
|
|
12054
|
+
const isTopic = (name) => GUIDE_TOPIC_NAMES.includes(name);
|
|
12055
|
+
/**
|
|
12056
|
+
* `canvas guide [topic]`: the design skill of the one source, or one of its topics, for an agent
|
|
12057
|
+
* `setup` gave no skills. It also tells `canvas --help` to load the guide first, and puts each
|
|
12058
|
+
* command's design rules in that command's help.
|
|
12059
|
+
*/
|
|
12025
12060
|
const registerCanvasGuideProgram = (program, input) => {
|
|
12026
12061
|
const canvas = program.commands.find((command) => command.name() === "canvas");
|
|
12027
12062
|
if (canvas === void 0) throw new TypeError("The canvas commands are registered first.");
|
|
12028
|
-
|
|
12063
|
+
for (const command of canvas.commands) {
|
|
12064
|
+
const use = POINT_OF_USE_COMMANDS[command.name()];
|
|
12065
|
+
if (use !== void 0) command.addHelpText("after", `\nDesign: ${pointOfUseText(use)}\n`);
|
|
12066
|
+
}
|
|
12067
|
+
canvas.command("guide").description(`How to design on a canvas: the design-on-canvas skill, or a topic (${GUIDE_TOPIC_NAMES.join(", ")}).`).argument("[topic]", `One of ${GUIDE_NAMES.join(", ")}.`, "design-on-canvas").action((topic) => {
|
|
12068
|
+
if (isTopic(topic)) {
|
|
12069
|
+
input.write(GUIDE_TOPICS[topic].body);
|
|
12070
|
+
return;
|
|
12071
|
+
}
|
|
12072
|
+
if (topic !== "design-on-canvas") throw new CliError("BAD_REQUEST", `The guide has no topic ${topic}.`, `Ask for one of: ${GUIDE_NAMES.join(", ")}.`);
|
|
12029
12073
|
const design = input.skills().find(({ skill }) => skill === "design-on-canvas");
|
|
12030
12074
|
if (design === void 0) throw new TypeError("The skills hold no design-on-canvas.");
|
|
12031
12075
|
input.write(design.body);
|
|
12032
12076
|
});
|
|
12033
12077
|
};
|
|
12078
|
+
/**
|
|
12079
|
+
* Tells `canvas --help` to load the guide first, after the sentence about the group. The group's
|
|
12080
|
+
* help is bounded, so it carries only this first line of the start-up list; the guide holds every
|
|
12081
|
+
* rule, and each command's help repeats its own. Run after the group's description is set.
|
|
12082
|
+
*/
|
|
12083
|
+
const tellCanvasHelpToLoadTheGuide = (program, loadGuide) => {
|
|
12084
|
+
const canvas = program.commands.find((command) => command.name() === "canvas");
|
|
12085
|
+
if (canvas === void 0) throw new TypeError("The canvas commands are registered first.");
|
|
12086
|
+
if (canvas.summary() === "") canvas.summary(canvas.description());
|
|
12087
|
+
canvas.description(`${canvas.description()} ${loadGuide}`);
|
|
12088
|
+
};
|
|
12034
12089
|
|
|
12035
12090
|
//#endregion
|
|
12036
12091
|
//#region src/infrastructure/input-help.program.ts
|
|
@@ -12508,6 +12563,13 @@ const toolSkillTextsOf = (commandName, machine) => skillTextsFor({
|
|
|
12508
12563
|
command: skillCommandOf(commandName, machine),
|
|
12509
12564
|
nameOf: cliPathOf
|
|
12510
12565
|
});
|
|
12566
|
+
/** The line in `canvas --help` that says to load the guide, naming its command as the skills do. */
|
|
12567
|
+
const toolLoadGuideOf = (commandName, machine) => loadGuideLineFor({
|
|
12568
|
+
surface: "cli",
|
|
12569
|
+
commandName,
|
|
12570
|
+
command: skillCommandOf(commandName, machine),
|
|
12571
|
+
nameOf: cliPathOf
|
|
12572
|
+
});
|
|
12511
12573
|
/** Signing in, and the setup that signs in and gives each coding agent the skills. */
|
|
12512
12574
|
const registerSignInPrograms = (program, input) => {
|
|
12513
12575
|
const auth = createAuthUseCase(input.credentials, input.remote, createOauthLoopbackAdapter(input.remote));
|
|
@@ -12609,6 +12671,7 @@ const createCliProgram = (input) => {
|
|
|
12609
12671
|
output: input.output
|
|
12610
12672
|
});
|
|
12611
12673
|
built.description("Operate Enhance as the authenticated person.");
|
|
12674
|
+
tellCanvasHelpToLoadTheGuide(built, toolLoadGuideOf(input.commandName, input.machine));
|
|
12612
12675
|
attachInputHelp(built, catalog);
|
|
12613
12676
|
const failureState = input.state;
|
|
12614
12677
|
return {
|
|
@@ -12897,7 +12960,7 @@ const main = async () => {
|
|
|
12897
12960
|
const remote = createHttpRemoteAdapter(config.apiUrl, credentials, mutationKey);
|
|
12898
12961
|
const cli = createCliProgram({
|
|
12899
12962
|
apiUrl: config.apiUrl,
|
|
12900
|
-
version: "0.1.
|
|
12963
|
+
version: "0.1.172",
|
|
12901
12964
|
credentials,
|
|
12902
12965
|
remote,
|
|
12903
12966
|
mutationKey,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { $ as
|
|
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-
|
|
4
|
-
import { a as mcpDispatchedResultSchema, c as withClientTokenNamed, i as createMcpCanvasToolsAdapter, l as createMcpClientContextAdapter, n as createMcpWorkflowsAdapter, o as createMcpResultAdapter, r as createMcpClientInvocationAdapter, s as toolClientToken, u as createCapabilityCatalogAdapter } from "./mcp-server.adapter-
|
|
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-BsDqFLVA.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-B8yowT7b.mjs";
|
|
4
|
+
import { a as mcpDispatchedResultSchema, c as withClientTokenNamed, i as createMcpCanvasToolsAdapter, l as createMcpClientContextAdapter, n as createMcpWorkflowsAdapter, o as createMcpResultAdapter, r as createMcpClientInvocationAdapter, s as toolClientToken, u as createCapabilityCatalogAdapter } from "./mcp-server.adapter-CbObvH7Y.mjs";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import { McpServer } from "@modelcontextprotocol/server";
|
|
7
7
|
|
|
@@ -117,7 +117,7 @@ const registerExchange = (server, invoke, isReadOnly) => {
|
|
|
117
117
|
if (isReadOnly) return;
|
|
118
118
|
server.registerTool("canvas_update_html", {
|
|
119
119
|
title: "Update editable canvas content",
|
|
120
|
-
description:
|
|
120
|
+
description: `Submit the complete HTML from canvas_read with its original snapshotToken and canvasRef. Preserve retained IDs and opaque placeholders. Add populated new subtrees without identity markers and with explicit dimensions/styles. Retained elements allow only identity, name, opaque, locked and style attributes (svg also viewBox). Writing CSS that a native setting paints replaces that setting; writing a mask group's mask CSS removes the mask. Keep opaque and locked elements unchanged. New wrappers cannot contain retained IDs; use canvas_arrange. Reference: enhance://canvas/html/2. Declare deliberate omitted subtrees in removeNodeIds. A no-op creates no revision. The call normally answers with the committed result; one that outlasts the wait answers as pending and has not committed, so repeat it with identical arguments and clientToken. Retry an uncertain result with identical arguments and clientToken; a changed canvas requires a new read and deliberate replan. ${pointOfUseText("update")}`,
|
|
121
121
|
inputSchema: canvasUpdateHtmlInputSchema,
|
|
122
122
|
outputSchema: canvasPreparationOutputSchema,
|
|
123
123
|
annotations: {
|
|
@@ -130,7 +130,7 @@ const registerExchange = (server, invoke, isReadOnly) => {
|
|
|
130
130
|
const registerInsertion = (server, invoke) => {
|
|
131
131
|
server.registerTool("canvas_insert_html", {
|
|
132
132
|
title: "Insert editable HTML content",
|
|
133
|
-
description:
|
|
133
|
+
description: `Compile one populated HTML subtree into fresh editable nodes at an explicit parent. Preserve the full canvas/page/selection reference. The canonical compiler commits atomically at baseVersion; a concurrent edit rejects the insertion. The call normally answers with the committed version and root node; operation_status is for a compile that outlasts the wait, and for additional identity mappings. Reuse identical arguments and clientToken after an uncertain response. ${pointOfUseText("write")}`,
|
|
134
134
|
inputSchema: canvasInsertHtmlInputSchema,
|
|
135
135
|
outputSchema: canvasConversionStatusSchema,
|
|
136
136
|
annotations: {
|
|
@@ -217,7 +217,7 @@ const registerFind = (server, invoke) => {
|
|
|
217
217
|
const registerCreate = (server, invoke) => {
|
|
218
218
|
server.registerTool("canvas_create", {
|
|
219
219
|
title: "Create a canvas",
|
|
220
|
-
description:
|
|
220
|
+
description: `Create an invite-only canvas in an explicit existing personal or team destination from canvas_find. Use only when the person wants a new canvas. Reuse the same clientToken and arguments after an uncertain response. Returns the committed initial document revision. This creates no team, prototype or public share. ${pointOfUseText("create")}`,
|
|
221
221
|
inputSchema: canvasCreateToolInputSchema,
|
|
222
222
|
outputSchema: canvasCreateToolOutputSchema,
|
|
223
223
|
annotations: {
|
|
@@ -310,7 +310,7 @@ const clientContext$6 = createMcpClientContextAdapter();
|
|
|
310
310
|
const createMcpCanvasRenderAdapter = (input) => ({ register: (server) => {
|
|
311
311
|
server.registerTool("canvas_render", {
|
|
312
312
|
title: "Inspect canvas pixels",
|
|
313
|
-
description:
|
|
313
|
+
description: `Render one explicit target or up to four named targets at the returned canvas revision. A batch shares 16,000,000 pixels equally unless per-target budgets are supplied; the total is checked before rendering. Each outcome identifies its target and actual image content index; partial completion is explicit. Preserve the complete page or selection URL. The call normally answers with the PNG. A render that outlasts the wait answers with a durable operation reference: collect its pixels with operation_status and includeImage true. Reuse identical arguments and clientToken after an uncertain outcome. Rendering creates a temporary job but no canvas edit. Inspect the delivered image before claiming visual verification. ${pointOfUseText("render")}`,
|
|
314
314
|
inputSchema: canvasRenderScopedToolInputSchema,
|
|
315
315
|
outputSchema: mcpDispatchedResultSchema,
|
|
316
316
|
...input.ui !== void 0 && { _meta: input.ui.toolMeta },
|
|
@@ -1186,7 +1186,7 @@ const clientContext$1 = createMcpClientContextAdapter();
|
|
|
1186
1186
|
const createMcpAssetImportAdapter = (invoke) => ({ register: (server) => {
|
|
1187
1187
|
server.registerTool("asset_import", {
|
|
1188
1188
|
title: "Import a canvas asset",
|
|
1189
|
-
description:
|
|
1189
|
+
description: `Import one explicitly selected local image or font. Verifies actual bytes and format. Returns a durable native resource and metadata without placing content or changing the canvas version. Use the resource in a subsequent explicit authoring action. Retry the same file and clientToken after uncertainty, or inspect the returned operation reference. ${pointOfUseText("import")}`,
|
|
1190
1190
|
inputSchema: canvasAssetImportInputSchema,
|
|
1191
1191
|
outputSchema: canvasAssetImportOutputSchema,
|
|
1192
1192
|
annotations: {
|
|
@@ -1210,10 +1210,10 @@ const createMcpAssetImportAdapter = (invoke) => ({ register: (server) => {
|
|
|
1210
1210
|
|
|
1211
1211
|
//#endregion
|
|
1212
1212
|
//#region src/infrastructure/mcp-canvas-profile.adapter.ts
|
|
1213
|
-
const profileInstructions = (input, workflows) => [workflows, input.authentication === "oauth" ? "Use the host’s OAuth connection flow to connect Enhance." : input.readOnly === true ? "Use connection_status to check account authentication. This profile cannot start sign-in or write; use the existing host connection flow if needed." : "Use connection_connect for browser sign-in, then connection_status to verify authentication."].filter(Boolean).join("
|
|
1213
|
+
const profileInstructions = (input, workflows) => [workflows, input.authentication === "oauth" ? "Use the host’s OAuth connection flow to connect Enhance." : input.readOnly === true ? "Use connection_status to check account authentication. This profile cannot start sign-in or write; use the existing host connection flow if needed." : "Use connection_connect for browser sign-in, then connection_status to verify authentication."].filter(Boolean).join("\n\n");
|
|
1214
1214
|
/** The small-edit tool the CLI and the desktop assistant have, and no second insert or render. */
|
|
1215
1215
|
const editToolsFor = (input, catalog, invocation) => createMcpCanvasToolsAdapter({
|
|
1216
|
-
tools: ["edit"],
|
|
1216
|
+
tools: ["edit", "finish"],
|
|
1217
1217
|
catalog,
|
|
1218
1218
|
invocation,
|
|
1219
1219
|
results: createMcpResultAdapter(input.authentication === "oauth" ? "Reconnect Enhance through this host’s connection flow, then repeat the request." : "Reconnect Enhance and retry the same intent."),
|
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-
|
|
3
|
-
import { a as readLocalMcpEnvironment, t as installZodMessages } from "./zod-messages.lib-
|
|
2
|
+
import { s as toCapabilityDefinition } from "./cli-output-identity.lib-BsDqFLVA.mjs";
|
|
3
|
+
import { a as readLocalMcpEnvironment, t as installZodMessages } from "./zod-messages.lib-B8yowT7b.mjs";
|
|
4
4
|
import { t as createFileCredentialAdapter } from "./file-credential.adapter-CShGZcd5.mjs";
|
|
5
|
-
import { l as createMcpClientContextAdapter, t as createMcpServerAdapter, u as createCapabilityCatalogAdapter } from "./mcp-server.adapter-
|
|
6
|
-
import { n as createMcpCanvasProfileAdapter, t as createMcpInvocationAdapter } from "./mcp-invocation.adapter-
|
|
5
|
+
import { l as createMcpClientContextAdapter, t as createMcpServerAdapter, u as createCapabilityCatalogAdapter } from "./mcp-server.adapter-CbObvH7Y.mjs";
|
|
6
|
+
import { n as createMcpCanvasProfileAdapter, t as createMcpInvocationAdapter } from "./mcp-invocation.adapter-DGgt79VT.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
|
+
const invocation = createMcpInvocationAdapter(config.apiUrl, credentials, config.configDirectory, { version: "0.1.172" });
|
|
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.
|
|
181
|
+
version: "0.1.172",
|
|
182
182
|
invocation,
|
|
183
183
|
clientMetadata: client.metadata,
|
|
184
184
|
catalog
|
|
185
185
|
}) : createMcpServerAdapter({
|
|
186
|
-
version: "0.1.
|
|
186
|
+
version: "0.1.172",
|
|
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 {
|
|
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, hi as canvasRenderTargetSchema, hn as SKILL_NAMES, i as createLazyCapabilityCatalogAdapter, it as canvasRenderBatchResultSchema, k as canvasWriteHtmlCapabilityInputSchema, l as GUIDE_TOPICS, lt as canvasRenderFileSchema, mn as SKILL_JOBS, 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-BsDqFLVA.mjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
5
5
|
import { readFile, rm } from "node:fs/promises";
|
|
@@ -494,6 +494,47 @@ const mcpMutationInputSchema = z.object({
|
|
|
494
494
|
clientToken: z.uuid().optional().describe("Stable UUID reused only when retrying this exact mutation input.")
|
|
495
495
|
});
|
|
496
496
|
|
|
497
|
+
//#endregion
|
|
498
|
+
//#region src/infrastructure/mcp-canvas-finish.adapter.ts
|
|
499
|
+
const clientContext$3 = createMcpClientContextAdapter();
|
|
500
|
+
/** The procedure that ends an agent's activity, which the catalogue offers as a capability. */
|
|
501
|
+
const FINISH_CAPABILITY = "canvas.realtime.activity.end";
|
|
502
|
+
const finishSchema = z.strictObject({
|
|
503
|
+
canvas: z.string().min(1).describe("Canvas UUID or complete canvas URL."),
|
|
504
|
+
nodeIds: z.array(z.string().min(1)).max(100).default([]).describe("The screens you finished. Leave empty when you have finished on this canvas.")
|
|
505
|
+
});
|
|
506
|
+
/** `canvas_finish_working`: the agent says it has finished, so its mark leaves the canvas. */
|
|
507
|
+
const createMcpCanvasFinishAdapter = (input) => ({ register: (server) => {
|
|
508
|
+
const capability = input.catalog.find((candidate) => candidate.id === FINISH_CAPABILITY);
|
|
509
|
+
if (capability === void 0) return;
|
|
510
|
+
server.registerTool("canvas_finish_working", {
|
|
511
|
+
title: "Say you have finished",
|
|
512
|
+
description: `End your mark on the canvas, or take finished screens out of it. ${pointOfUseText("finish")} With nothing live, the call succeeds and says so; a mark nobody finishes leaves 45 seconds after the last call.`,
|
|
513
|
+
inputSchema: finishSchema,
|
|
514
|
+
outputSchema: mcpDispatchedResultSchema,
|
|
515
|
+
annotations: {
|
|
516
|
+
readOnlyHint: false,
|
|
517
|
+
destructiveHint: false,
|
|
518
|
+
idempotentHint: true,
|
|
519
|
+
openWorldHint: false
|
|
520
|
+
}
|
|
521
|
+
}, async ({ canvas, nodeIds }, context) => clientContext$3.run(context, async () => {
|
|
522
|
+
try {
|
|
523
|
+
const ended = await input.invocation.invoke({
|
|
524
|
+
capability,
|
|
525
|
+
arguments: {
|
|
526
|
+
canvasId: parseCanvasReference(canvas).canvasId,
|
|
527
|
+
nodeIds
|
|
528
|
+
},
|
|
529
|
+
clientToken: null
|
|
530
|
+
});
|
|
531
|
+
return await input.results.success(server, ended, input.delivery);
|
|
532
|
+
} catch (error) {
|
|
533
|
+
return input.results.failure(error);
|
|
534
|
+
}
|
|
535
|
+
}));
|
|
536
|
+
} });
|
|
537
|
+
|
|
497
538
|
//#endregion
|
|
498
539
|
//#region src/infrastructure/mcp-canvas-tools.adapter.ts
|
|
499
540
|
const clientContext$2 = createMcpClientContextAdapter();
|
|
@@ -515,8 +556,15 @@ const renderSchema = z.object({
|
|
|
515
556
|
expectedVersion: z.number().int().positive().describe("Version returned by the latest successful read or write."),
|
|
516
557
|
target: canvasRenderTargetSchema.default({ kind: "content" }),
|
|
517
558
|
sourceState: canvasRenderSourceStateSchema.nullable().default(null),
|
|
518
|
-
scale: z.number().positive().default(1)
|
|
559
|
+
scale: z.number().positive().default(1).describe(DESIGN_RULES.scale)
|
|
519
560
|
});
|
|
561
|
+
/** A write or an edit: it changes the canvas, and a repeat makes a second change. */
|
|
562
|
+
const CHANGING_ANNOTATIONS = {
|
|
563
|
+
readOnlyHint: false,
|
|
564
|
+
destructiveHint: true,
|
|
565
|
+
idempotentHint: false,
|
|
566
|
+
openWorldHint: false
|
|
567
|
+
};
|
|
520
568
|
const invoke = async (input, id, args, token = null) => {
|
|
521
569
|
const capability = input.catalog.find((candidate) => candidate.id === id);
|
|
522
570
|
if (capability === void 0) throw new TypeError(`Missing canvas capability ${id}`);
|
|
@@ -553,15 +601,10 @@ const deliver = async (server, input, given, action) => {
|
|
|
553
601
|
const registerWrite = (server, input) => {
|
|
554
602
|
if (input.catalog.some((capability) => capability.id === "canvas.writeHtml")) server.registerTool("canvas_write_html", {
|
|
555
603
|
title: "Design editable canvas content",
|
|
556
|
-
description: `Create a
|
|
604
|
+
description: `Create a screen, or add a visual group to one, from safe HTML/CSS. Returns the committed version and root node without an extra read or render. ${input.readTool === "canvas_read" ? "Read canonical IDs and the current version with canvas_read. Keep all writes inside the frozen selection." : "If starting state is unknown, call capability_query with {\"capability\":\"canvas.read\",\"input\":{\"canvasId\":\"<UUID from canvas URL>\"}}. When nodeCount is 0, use targetNodeId \"root\" and the returned version."} ${pointOfUseText("write")} Give important rows, cards and buttons explicit dimensions; avoid implicit stretch and inline badge backgrounds. Include real content, not an empty shell. Reuse a returned version for subsequent edits; read a targeted subtree only when its ids or structure are unknown. Use canvas_edit for small changes. The schema here is executable; no search or describe is required.`,
|
|
557
605
|
inputSchema: writeSchema,
|
|
558
606
|
outputSchema: mcpDispatchedResultSchema,
|
|
559
|
-
annotations:
|
|
560
|
-
readOnlyHint: false,
|
|
561
|
-
destructiveHint: true,
|
|
562
|
-
idempotentHint: false,
|
|
563
|
-
openWorldHint: false
|
|
564
|
-
}
|
|
607
|
+
annotations: CHANGING_ANNOTATIONS
|
|
565
608
|
}, async ({ canvas, clientToken: token, ...args }, context) => clientContext$2.run(context, async () => deliver(server, input, token, async (clientToken) => {
|
|
566
609
|
const reference = parseCanvasReference(canvas);
|
|
567
610
|
return invoke(input, "canvas.writeHtml", {
|
|
@@ -580,21 +623,16 @@ const registerWrite = (server, input) => {
|
|
|
580
623
|
const registerEdit = (server, input) => {
|
|
581
624
|
if (input.catalog.some((capability) => capability.id === "canvas.edit")) server.registerTool("canvas_edit", {
|
|
582
625
|
title: "Edit existing canvas content",
|
|
583
|
-
description:
|
|
626
|
+
description: `Apply text, styles, rename, duplicate or move edits together in one atomic mutation. Use ids from the input version and the latest successful read or write version; no intermediate read is required just to advance a version. Keep the complete selection URL. Read only the missing subtree when ids are unknown. Returns a compact committed receipt; render after the requested changes are complete. ${pointOfUseText("edit")}`,
|
|
584
627
|
inputSchema: editSchema,
|
|
585
628
|
outputSchema: mcpDispatchedResultSchema,
|
|
586
|
-
annotations:
|
|
587
|
-
readOnlyHint: false,
|
|
588
|
-
destructiveHint: true,
|
|
589
|
-
idempotentHint: false,
|
|
590
|
-
openWorldHint: false
|
|
591
|
-
}
|
|
629
|
+
annotations: CHANGING_ANNOTATIONS
|
|
592
630
|
}, async ({ clientToken: token, ...args }, context) => clientContext$2.run(context, async () => deliver(server, input, token, async (clientToken) => invoke(input, "canvas.edit", args, clientToken))));
|
|
593
631
|
};
|
|
594
632
|
const registerRender = (server, input) => {
|
|
595
633
|
if (input.catalog.some((capability) => capability.id === "canvas.render")) server.registerTool("canvas_render", {
|
|
596
634
|
title: "Review canvas pixels",
|
|
597
|
-
description:
|
|
635
|
+
description: `Render the version returned by a successful read or write and inspect its native PNG. Target the affected screen/node; a blank canvas does not need a pre-render. For a selection link use one node inside the selection. ${pointOfUseText("render")}`,
|
|
598
636
|
inputSchema: renderSchema,
|
|
599
637
|
outputSchema: mcpDispatchedResultSchema,
|
|
600
638
|
annotations: {
|
|
@@ -617,11 +655,13 @@ const createMcpCanvasToolsAdapter = (input) => ({ register: (server) => {
|
|
|
617
655
|
const selected = input.tools ?? [
|
|
618
656
|
"write",
|
|
619
657
|
"edit",
|
|
620
|
-
"render"
|
|
658
|
+
"render",
|
|
659
|
+
"finish"
|
|
621
660
|
];
|
|
622
661
|
if (selected.includes("write")) registerWrite(server, input);
|
|
623
662
|
if (selected.includes("edit")) registerEdit(server, input);
|
|
624
663
|
if (selected.includes("render")) registerRender(server, input);
|
|
664
|
+
if (selected.includes("finish")) createMcpCanvasFinishAdapter(input).register(server);
|
|
625
665
|
} });
|
|
626
666
|
|
|
627
667
|
//#endregion
|
|
@@ -636,14 +676,21 @@ const createMcpClientInvocationAdapter = (invocation, legacyClient) => ({ invoke
|
|
|
636
676
|
|
|
637
677
|
//#endregion
|
|
638
678
|
//#region src/infrastructure/mcp-workflows.adapter.ts
|
|
639
|
-
/** The guide offers exactly the skills of the one source, by their short names. */
|
|
679
|
+
/** The guide offers exactly the skills and the topics of the one source, by their short names. */
|
|
640
680
|
const workflowNameSchema = z.enum(SKILL_NAMES);
|
|
681
|
+
const guideNameSchema = z.enum([...SKILL_NAMES, ...GUIDE_TOPIC_NAMES]);
|
|
641
682
|
const workflowSchema = z.object({
|
|
642
683
|
name: workflowNameSchema,
|
|
643
684
|
description: z.string().min(1),
|
|
644
685
|
body: z.string().min(1)
|
|
645
686
|
});
|
|
646
|
-
const
|
|
687
|
+
const jobs = `Before ${SKILL_JOBS.slice(0, -1).join(", ")} or ${SKILL_JOBS.at(-1) ?? ""}, call workflow_guide with the matching workflow and follow its guidance.`;
|
|
688
|
+
const topics = `Topics: ${GUIDE_TOPIC_NAMES.map((name) => `${name} (${GUIDE_TOPICS[name].description})`).join("; ")}.`;
|
|
689
|
+
/** The start-up list names tools, which every MCP server words the same. */
|
|
690
|
+
const startUp = startUpListFor({
|
|
691
|
+
surface: "mcp",
|
|
692
|
+
nameOf: (capability) => MCP_TOOL_BY_CAPABILITY[capability]
|
|
693
|
+
});
|
|
647
694
|
/** A skill's file, or a failure that names the skill the folder lacks. */
|
|
648
695
|
const skillFileOf = (directory, name) => {
|
|
649
696
|
try {
|
|
@@ -666,13 +713,20 @@ const workflowIn = (directory, name) => {
|
|
|
666
713
|
};
|
|
667
714
|
/** The guide tool over a folder of skills, or over skills already written for tools. */
|
|
668
715
|
const createMcpWorkflowsAdapter = (skills, authenticationInstructions) => {
|
|
669
|
-
const workflows = typeof skills === "string" ? workflowNameSchema.options.map((name) => workflowIn(skills, name)) : skills.map(({ skill, description, body }) => ({
|
|
716
|
+
const workflows = [...typeof skills === "string" ? workflowNameSchema.options.map((name) => workflowIn(skills, name)) : skills.map(({ skill, description, body }) => ({
|
|
670
717
|
name: skill,
|
|
671
718
|
description,
|
|
672
719
|
body
|
|
673
|
-
}))
|
|
720
|
+
})), ...GUIDE_TOPIC_NAMES.map((name) => ({
|
|
721
|
+
name,
|
|
722
|
+
...GUIDE_TOPICS[name]
|
|
723
|
+
}))];
|
|
674
724
|
return {
|
|
675
|
-
instructions: [
|
|
725
|
+
instructions: [
|
|
726
|
+
startUp,
|
|
727
|
+
jobs,
|
|
728
|
+
authenticationInstructions
|
|
729
|
+
].filter(Boolean).join("\n\n"),
|
|
676
730
|
register: (server) => {
|
|
677
731
|
for (const workflow of workflows) server.registerPrompt(workflow.name, { description: workflow.description }, () => ({ messages: [{
|
|
678
732
|
role: "user",
|
|
@@ -683,8 +737,8 @@ const createMcpWorkflowsAdapter = (skills, authenticationInstructions) => {
|
|
|
683
737
|
}] }));
|
|
684
738
|
server.registerTool("workflow_guide", {
|
|
685
739
|
title: "Load an Enhance workflow",
|
|
686
|
-
description:
|
|
687
|
-
inputSchema: z.strictObject({ workflow:
|
|
740
|
+
description: `${jobs} ${topics}`,
|
|
741
|
+
inputSchema: z.strictObject({ workflow: guideNameSchema }),
|
|
688
742
|
annotations: {
|
|
689
743
|
readOnlyHint: true,
|
|
690
744
|
destructiveHint: false,
|
package/dist/mcp.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { f as toSharedCapabilities } from "./cli-output-identity.lib-BsDqFLVA.mjs";
|
|
3
3
|
import { t as toCapabilityInventory } from "./capability-inventory.mapper-DyYXyVBJ.mjs";
|
|
4
|
-
import { t as createMcpServerAdapter, u as createCapabilityCatalogAdapter } from "./mcp-server.adapter-
|
|
4
|
+
import { t as createMcpServerAdapter, u as createCapabilityCatalogAdapter } from "./mcp-server.adapter-CbObvH7Y.mjs";
|
|
5
5
|
|
|
6
6
|
export { createCapabilityCatalogAdapter, createMcpServerAdapter as createEnhanceMcpServer, toCapabilityInventory, toSharedCapabilities };
|
package/dist/remote-mcp-main.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
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-
|
|
4
|
-
import { c as withClientTokenNamed, l as createMcpClientContextAdapter, o as createMcpResultAdapter, s as toolClientToken, t as createMcpServerAdapter, u as createCapabilityCatalogAdapter } from "./mcp-server.adapter-
|
|
5
|
-
import { n as createMcpCanvasProfileAdapter, t as createMcpInvocationAdapter } from "./mcp-invocation.adapter-
|
|
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, gn as skillTextsFor, nt as canvasAssetImportOutputSchema, sn as MCP_TOOL_BY_CAPABILITY, tt as canvasAssetImportInputSchema, w as PROTOTYPE_UPDATE_GUIDANCE, z as canvasPrototypeIntentSchema } from "./cli-output-identity.lib-BsDqFLVA.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-B8yowT7b.mjs";
|
|
4
|
+
import { c as withClientTokenNamed, l as createMcpClientContextAdapter, o as createMcpResultAdapter, s as toolClientToken, t as createMcpServerAdapter, u as createCapabilityCatalogAdapter } from "./mcp-server.adapter-CbObvH7Y.mjs";
|
|
5
|
+
import { n as createMcpCanvasProfileAdapter, t as createMcpInvocationAdapter } from "./mcp-invocation.adapter-DGgt79VT.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";
|
|
@@ -562,7 +562,7 @@ const transfer = async (given, action) => {
|
|
|
562
562
|
const registerAsset = (server, input) => {
|
|
563
563
|
server.registerTool("asset_import", {
|
|
564
564
|
title: "Import a canvas asset",
|
|
565
|
-
description:
|
|
565
|
+
description: `Import one file explicitly uploaded or selected in this host. Supply its authorized file reference, never a local path or an arbitrary URL. Accepts PNG, JPEG, GIF, WebP, AVIF, TTF, OTF, WOFF or WOFF2; verifies actual bytes and native metadata. Returns a durable resource without placing it or changing the canvas version. Retry with the same bytes and clientToken; a refreshed download URL is allowed. ${pointOfUseText("import")}`,
|
|
566
566
|
inputSchema: assetInputSchema,
|
|
567
567
|
outputSchema: canvasAssetImportOutputSchema,
|
|
568
568
|
annotations: {
|
|
@@ -850,7 +850,7 @@ const server = await createRemoteMcpHttpAdapter({
|
|
|
850
850
|
...config.MCP_STAGED_UPLOAD_ORIGIN !== void 0 && { stagedUploadOrigin: config.MCP_STAGED_UPLOAD_ORIGIN },
|
|
851
851
|
allowedHosts: config.MCP_ALLOWED_HOSTS.split(",").map((value) => value.trim()),
|
|
852
852
|
allowedOrigins: config.MCP_ALLOWED_ORIGINS.split(",").map((value) => value.trim()),
|
|
853
|
-
version: "0.1.
|
|
853
|
+
version: "0.1.172",
|
|
854
854
|
...config.MCP_UI_URL !== void 0 && { uiUrl: config.MCP_UI_URL },
|
|
855
855
|
onerror: (error) => process.stderr.write(`${error.message}\n`)
|
|
856
856
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { $r as
|
|
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-BsDqFLVA.mjs";
|
|
3
3
|
import process from "node:process";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { generateKeyBetween, generateNKeysBetween } from "fractional-indexing";
|
|
@@ -19,7 +19,7 @@ import { ZipFile } from "yazl";
|
|
|
19
19
|
import { spawn } from "node:child_process";
|
|
20
20
|
import { createTRPCUntypedClient, httpLink } from "@trpc/client";
|
|
21
21
|
import { createServer } from "node:http";
|
|
22
|
-
import { Agent } from "undici";
|
|
22
|
+
import { Agent, RetryAgent } from "undici";
|
|
23
23
|
|
|
24
24
|
//#region ../../packages/canvas-format/src/canvas-slice.lib.ts
|
|
25
25
|
/** A run on a slice reached past what was loaded; the caller runs it again on the whole canvas. */
|
|
@@ -2244,12 +2244,27 @@ const pngDimensions = (body) => {
|
|
|
2244
2244
|
height: view.getUint32(PNG_HEIGHT_OFFSET)
|
|
2245
2245
|
};
|
|
2246
2246
|
};
|
|
2247
|
+
/**
|
|
2248
|
+
* The finished render's picture. A picture storage cannot be reached for is the named outcome: the
|
|
2249
|
+
* render succeeded, and the same job's picture can be fetched again without drawing it twice.
|
|
2250
|
+
*/
|
|
2251
|
+
const pictureOf = async (remote, url, jobId) => {
|
|
2252
|
+
try {
|
|
2253
|
+
return await remote.download(url);
|
|
2254
|
+
} catch (error) {
|
|
2255
|
+
if (error instanceof CliError && error.fields?.["reason"] !== "PICTURE_UNREACHABLE") throw error;
|
|
2256
|
+
throw new CliError("INTERNAL", "The render finished, but its picture could not be downloaded.", `Read ${commandName("operation.status")} with ${inputName("includeImage", "input")} true for render job ${jobId} to download it again. Do not create another render.`, {
|
|
2257
|
+
renderState: "succeeded",
|
|
2258
|
+
reason: "PICTURE_UNREACHABLE"
|
|
2259
|
+
});
|
|
2260
|
+
}
|
|
2261
|
+
};
|
|
2247
2262
|
const downloadVerifiedRenderPng = async (remote, job) => {
|
|
2248
2263
|
if (job.result.canvasId !== job.canvasId || job.result.requestedVersion !== job.requestedVersion || job.result.loadedVersion !== job.requestedVersion || JSON.stringify(job.result.target) !== JSON.stringify(job.target)) throw new CliError("INTERNAL", "The completed render evidence does not match its requested canvas, revision or target.", `Do not use the image. Report render job ${job.id}.`);
|
|
2249
2264
|
if (job.maxOutputPixels !== void 0 && job.result.width * job.result.height > job.maxOutputPixels) throw new CliError("INTERNAL", "The completed render exceeds its authorised output pixel limit.", `Do not use the image. Report render job ${job.id}.`, { reason: "RENDER_BUDGET_UNSUPPORTED" });
|
|
2250
2265
|
const signed = downloadCanvasRenderOutputSchema.safeParse(await remote.query("canvas.render.download", { jobId: job.id }));
|
|
2251
2266
|
if (!signed.success || signed.data.jobId !== job.id || signed.data.download.bytes !== job.result.bytes) throw new CliError("INTERNAL", "The API returned an invalid render download response.", diagnosisStep("Run `enhance doctor`; report the API and CLI versions if they differ."));
|
|
2252
|
-
const body = await remote
|
|
2267
|
+
const body = await pictureOf(remote, signed.data.download.url, job.id);
|
|
2253
2268
|
const dimensions = pngDimensions(body);
|
|
2254
2269
|
if (dimensions === null || body.byteLength !== job.result.bytes || dimensions.width !== job.result.width || dimensions.height !== job.result.height) throw new CliError("INTERNAL", "The downloaded render did not match its completed job metadata.", `Do not use the image. Report render job ${job.id}.`);
|
|
2255
2270
|
return {
|
|
@@ -4857,6 +4872,8 @@ const ignoreFailure = async (operation) => {
|
|
|
4857
4872
|
return false;
|
|
4858
4873
|
}
|
|
4859
4874
|
};
|
|
4875
|
+
/** The most layers one mark names, as the contract allows. */
|
|
4876
|
+
const MAX_ACTIVITY_NODE_IDS$1 = 100;
|
|
4860
4877
|
const liveHandle = (remote, initial, activityId, renewAfterMs) => {
|
|
4861
4878
|
let target = initial;
|
|
4862
4879
|
let isFinished = false;
|
|
@@ -4882,6 +4899,19 @@ const liveHandle = (remote, initial, activityId, renewAfterMs) => {
|
|
|
4882
4899
|
};
|
|
4883
4900
|
await renew();
|
|
4884
4901
|
},
|
|
4902
|
+
include: async (next) => {
|
|
4903
|
+
if (isFinished) return;
|
|
4904
|
+
target = {
|
|
4905
|
+
...target,
|
|
4906
|
+
...next,
|
|
4907
|
+
nodeIds: [.../* @__PURE__ */ new Set([...next.nodeIds, ...target.nodeIds])].slice(0, MAX_ACTIVITY_NODE_IDS$1)
|
|
4908
|
+
};
|
|
4909
|
+
await renew();
|
|
4910
|
+
},
|
|
4911
|
+
release: () => {
|
|
4912
|
+
isFinished = true;
|
|
4913
|
+
clearInterval(timer);
|
|
4914
|
+
},
|
|
4885
4915
|
finish: async () => {
|
|
4886
4916
|
if (isFinished) return;
|
|
4887
4917
|
isFinished = true;
|
|
@@ -4900,21 +4930,25 @@ const createCanvasActivityComposite = (remote) => ({
|
|
|
4900
4930
|
...target,
|
|
4901
4931
|
nodeIds: [...target.nodeIds]
|
|
4902
4932
|
}));
|
|
4903
|
-
return parsed.success ? liveHandle(remote,
|
|
4933
|
+
return parsed.success ? liveHandle(remote, {
|
|
4934
|
+
...target,
|
|
4935
|
+
nodeIds: parsed.data.nodeIds ?? target.nodeIds
|
|
4936
|
+
}, parsed.data.activityId, parsed.data.renewAfterMs) : null;
|
|
4904
4937
|
} catch {
|
|
4905
4938
|
return null;
|
|
4906
4939
|
}
|
|
4907
4940
|
},
|
|
4908
|
-
finish: async (
|
|
4909
|
-
canvasId,
|
|
4910
|
-
activityId
|
|
4941
|
+
finish: async (request) => endCanvasActivityOutputSchema.parse(await remote.mutate(PROCEDURES$1.end, {
|
|
4942
|
+
canvasId: request.canvasId,
|
|
4943
|
+
...request.activityId !== void 0 && { activityId: request.activityId },
|
|
4944
|
+
nodeIds: [...request.nodeIds]
|
|
4911
4945
|
}))
|
|
4912
4946
|
});
|
|
4913
4947
|
|
|
4914
4948
|
//#endregion
|
|
4915
4949
|
//#region src/application/apply-canvas.composite.ts
|
|
4916
4950
|
const APPLY_PROCEDURE = "canvas.applyOperations";
|
|
4917
|
-
const MAX_ACTIVITY_NODE_IDS
|
|
4951
|
+
const MAX_ACTIVITY_NODE_IDS = 100;
|
|
4918
4952
|
const BOX_OPERATION_TYPES = /* @__PURE__ */ new Set([
|
|
4919
4953
|
"insertPrototype",
|
|
4920
4954
|
"insertText",
|
|
@@ -4931,7 +4965,7 @@ const operationNodeIds = (operation) => {
|
|
|
4931
4965
|
if (operation.op === "insertNode") return [operation.node.id];
|
|
4932
4966
|
return [operation.nodeId];
|
|
4933
4967
|
};
|
|
4934
|
-
const activityNodeIds = (input) => [...new Set(input.operations.flatMap((operation) => operationNodeIds(operation)))].slice(0, MAX_ACTIVITY_NODE_IDS
|
|
4968
|
+
const activityNodeIds = (input) => [...new Set(input.operations.flatMap((operation) => operationNodeIds(operation)))].slice(0, MAX_ACTIVITY_NODE_IDS);
|
|
4935
4969
|
const operationBox = (operation) => {
|
|
4936
4970
|
if (operation.op === "insertConvertedSubtree") return operation.nodes[operation.rootNodeId]?.box ?? null;
|
|
4937
4971
|
if (operation.op === "insertNode") return operation.node.box ?? null;
|
|
@@ -4981,7 +5015,7 @@ const createApplyCanvasComposite = (remote) => ({ execute: async (input, options
|
|
|
4981
5015
|
try {
|
|
4982
5016
|
return await apply(remote, input);
|
|
4983
5017
|
} finally {
|
|
4984
|
-
|
|
5018
|
+
activity?.release();
|
|
4985
5019
|
}
|
|
4986
5020
|
} });
|
|
4987
5021
|
|
|
@@ -5526,7 +5560,6 @@ const makeCanvasEditable = async (remote, offered) => {
|
|
|
5526
5560
|
//#endregion
|
|
5527
5561
|
//#region src/application/write-html-canvas.composite.ts
|
|
5528
5562
|
const READ_IMPORT_PROCEDURE = "canvas.render.getImport";
|
|
5529
|
-
const MAX_ACTIVITY_NODE_IDS = 100;
|
|
5530
5563
|
const MAX_RECEIPT_ENTRIES = 40;
|
|
5531
5564
|
/** Problems that mean part of the HTML is not on the canvas, not only drawn less faithfully. */
|
|
5532
5565
|
const LOST_CONTENT_CODES = /* @__PURE__ */ new Set([
|
|
@@ -5671,20 +5704,27 @@ const createWriteHtmlCanvasComposite = (remote, render) => ({ execute: async (in
|
|
|
5671
5704
|
const activity = await createCanvasActivityComposite(remote).begin({
|
|
5672
5705
|
canvasId: input.canvasId,
|
|
5673
5706
|
phase: "creating",
|
|
5674
|
-
nodeIds: [input.targetNodeId],
|
|
5707
|
+
nodeIds: input.targetNodeId === "root" ? [] : [input.targetNodeId],
|
|
5675
5708
|
bounds: null
|
|
5676
5709
|
});
|
|
5677
5710
|
try {
|
|
5678
5711
|
const imported = await runCanvasConversion(remote, conversionInput(input));
|
|
5712
|
+
const screen = imported.state === "succeeded" && input.targetNodeId === "root" ? imported.result.rootNodeId : input.targetNodeId;
|
|
5713
|
+
const isReviewed = input.review !== "none" && input.responseMode !== "bounded";
|
|
5714
|
+
if (!isReviewed && imported.state === "succeeded") await activity?.include({
|
|
5715
|
+
phase: "writing",
|
|
5716
|
+
nodeIds: [screen],
|
|
5717
|
+
bounds: null
|
|
5718
|
+
});
|
|
5679
5719
|
if (input.responseMode === "bounded") return canvasConversionStatus(imported, {
|
|
5680
5720
|
offset: 0,
|
|
5681
5721
|
limit: MAX_RECEIPT_ENTRIES
|
|
5682
5722
|
});
|
|
5683
5723
|
if (imported.state !== "succeeded") return pendingResponse(imported);
|
|
5684
|
-
if (
|
|
5685
|
-
await activity?.
|
|
5724
|
+
if (!isReviewed) return committedResponse(input, imported);
|
|
5725
|
+
await activity?.include({
|
|
5686
5726
|
phase: "rendering",
|
|
5687
|
-
nodeIds:
|
|
5727
|
+
nodeIds: [screen],
|
|
5688
5728
|
bounds: imported.result.affectedBounds
|
|
5689
5729
|
});
|
|
5690
5730
|
const review = await renderReview(render, input, imported);
|
|
@@ -5706,7 +5746,7 @@ const createWriteHtmlCanvasComposite = (remote, render) => ({ execute: async (in
|
|
|
5706
5746
|
};
|
|
5707
5747
|
}
|
|
5708
5748
|
} finally {
|
|
5709
|
-
|
|
5749
|
+
activity?.release();
|
|
5710
5750
|
}
|
|
5711
5751
|
} });
|
|
5712
5752
|
|
|
@@ -10393,8 +10433,25 @@ const remoteRequest = async (action) => {
|
|
|
10393
10433
|
throw toRemoteError(error);
|
|
10394
10434
|
}
|
|
10395
10435
|
};
|
|
10436
|
+
/**
|
|
10437
|
+
* A picture's download: a connection that fails to open or drops before an answer is tried again on
|
|
10438
|
+
* a new one, three times, so a patchy network does not lose a finished render. Any answer is final.
|
|
10439
|
+
*/
|
|
10440
|
+
const PICTURE_CONNECTIONS = new RetryAgent(new Agent(), {
|
|
10441
|
+
maxRetries: 3,
|
|
10442
|
+
statusCodes: []
|
|
10443
|
+
});
|
|
10444
|
+
const fetchPicture = async (url) => {
|
|
10445
|
+
const init = {};
|
|
10446
|
+
Reflect.set(init, "dispatcher", PICTURE_CONNECTIONS);
|
|
10447
|
+
try {
|
|
10448
|
+
return await fetch(url, init);
|
|
10449
|
+
} catch (error) {
|
|
10450
|
+
throw new CliError("INTERNAL", `Could not reach ${originOf(url)}: ${networkReason(error)}.`, NETWORK_REMEDIATION, { reason: "PICTURE_UNREACHABLE" });
|
|
10451
|
+
}
|
|
10452
|
+
};
|
|
10396
10453
|
const download = async (url) => {
|
|
10397
|
-
const response = await
|
|
10454
|
+
const response = await fetchPicture(url);
|
|
10398
10455
|
if (!response.ok) throw new CliError(response.status === NOT_FOUND_STATUS || response.status === FORBIDDEN_STATUS ? "NOT_FOUND" : "INTERNAL", `Render download answered HTTP ${String(response.status)}.`, "The result may have expired. Request a new render.");
|
|
10399
10456
|
return new Uint8Array(await response.arrayBuffer());
|
|
10400
10457
|
};
|