@lensmcp/protocol-types 1.26.28 → 1.26.29

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.
@@ -34,7 +34,23 @@ export interface CanvasChatSettings {
34
34
  client?: string;
35
35
  /** agent: the account id (`ac-…`) it launches on (default: the drain plan's next). */
36
36
  account?: string;
37
+ /**
38
+ * How hard it thinks: a model's effort (Claude's `output_config.effort`, a GPT's `reasoning.effort`), an agent's
39
+ * (Claude Code `--effort`, Codex `model_reasoning_effort`). Absent: the model's or the client's own default.
40
+ */
41
+ effort?: CanvasChatEffort;
37
42
  }
43
+ /** The efforts a chat may ask for, lowest first. */
44
+ export declare const CANVAS_CHAT_EFFORTS: readonly ["low", "medium", "high", "xhigh", "max"];
45
+ export type CanvasChatEffort = (typeof CANVAS_CHAT_EFFORTS)[number];
46
+ export declare const isCanvasChatEffort: (v: unknown) => v is CanvasChatEffort;
47
+ /**
48
+ * The efforts an engine takes: a Claude model and Claude Code all five; a GPT model low to high (`reasoning.effort`
49
+ * has no more); Codex low to xhigh (`model_reasoning_effort`).
50
+ */
51
+ export declare function canvasChatEfforts(engine: CanvasChatEngine, settings: CanvasChatSettings | undefined): readonly CanvasChatEffort[];
52
+ /** The effort asked for, as the engine takes it: one it has no such level for gets its highest (a GPT's `max` is `high`). */
53
+ export declare function canvasChatEffortFor(engine: CanvasChatEngine, settings: CanvasChatSettings | undefined): CanvasChatEffort | undefined;
38
54
  export interface CanvasChat {
39
55
  id: string;
40
56
  project: string;
@@ -1,2 +1,2 @@
1
- "use strict";var n=Object.defineProperty;var t=(e,a)=>n(e,"name",{value:a,configurable:!0});var i=Object.defineProperty,s=t((e,a)=>i(e,"name",{value:a,configurable:!0}),"a");export const CANVAS_CHAT_ENGINES=["model","agent"],CANVAS_CHAT_STATES=["idle","working","stopped","failed"],CANVAS_CHAT_ROW_KINDS=["person","reply","step","version","edit","error","engine"],CANVAS_CHAT_LIMITS={textChars:8e3,rows:500,title:120},CANVAS_AUTHOR_ROLE="canvas-author",CANVAS_AUTHOR_IDLE_MINUTES=15;export function canvasAuthorText(e){const a=JSON.stringify(e.chat);return["# Your role: canvas author (LensMCP)","",`You write a canvas with a person, in a chat (${e.chat}). Read it with \`canvas_chat { chat: ${a} }\`, change the canvas with \`canvas_write\` (\`chat: ${a}\` on the first, which makes it), say what you did with \`canvas_chat { chat: ${a}, say }\` \u2014 short \u2014 and wait for the next message with \`canvas_wait { on: ["chat"], chat: ${a}, since }\`. Do not change the repository. Stop after ${CANVAS_AUTHOR_IDLE_MINUTES} idle minutes; the person's next message starts you again with the chat so far.`,"",e.canvas?`- The canvas is ${e.canvas}: read it first (\`canvas_get { id: ${JSON.stringify(e.canvas)}, include: ["mdx", "data", "shape"] }\`), then write \`canvas_write { id: ${JSON.stringify(e.canvas)}, chat: ${a}, ifVersion, note }\`.`:`- There is no canvas yet: your first \`canvas_write { chat: ${a}, mdx, data, note }\` makes it and binds it to the chat; write the next versions with its \`id\`.`,"- Read skill://lensmcp-canvas/SKILL.md before you write: the components, the data and its shape, and what the checker refuses.","- What to do is in the person's messages (`kind: \"person\"`). An `edit` row is a version the person saved themselves: read it before you write, and build on it, never over it. Other rows are the chat's record.","- Read the repository and the lens as the canvas needs; change nothing in the repository \u2014 no edits, no commits, no branches. What you make is the canvas.",`- One message, one answer: the version(s) it asks for, one short \`say\`, then \`canvas_wait\` with the \`seq\` you read. Back with nothing new: wait again \u2014 once ${CANVAS_AUTHOR_IDLE_MINUTES} minutes passed with nothing, end.`].join(`
2
- `)}t(canvasAuthorText,"canvasAuthorText"),s(canvasAuthorText,"canvasAuthorText");export function canvasAuthorStart(e){return`The person wrote to you in the canvas chat ${e.chat}: read it with canvas_chat { chat: ${JSON.stringify(e.chat)} } and answer its newest messages, as your role says. (LensMCP launch ${e.launchId}.)`}t(canvasAuthorStart,"canvasAuthorStart"),s(canvasAuthorStart,"canvasAuthorStart");
1
+ "use strict";var r=Object.defineProperty;var a=(t,e)=>r(t,"name",{value:e,configurable:!0});var o=Object.defineProperty,n=a((t,e)=>o(t,"name",{value:e,configurable:!0}),"a");export const CANVAS_CHAT_ENGINES=["model","agent"],CANVAS_CHAT_STATES=["idle","working","stopped","failed"],CANVAS_CHAT_ROW_KINDS=["person","reply","step","version","edit","error","engine"],CANVAS_CHAT_EFFORTS=["low","medium","high","xhigh","max"],isCanvasChatEffort=n(t=>typeof t=="string"&&CANVAS_CHAT_EFFORTS.includes(t),"isCanvasChatEffort");export function canvasChatEfforts(t,e){return t==="model"?e?.provider==="openai"?CANVAS_CHAT_EFFORTS.slice(0,3):CANVAS_CHAT_EFFORTS:e?.client==="codex"?CANVAS_CHAT_EFFORTS.slice(0,4):CANVAS_CHAT_EFFORTS}a(canvasChatEfforts,"canvasChatEfforts"),n(canvasChatEfforts,"canvasChatEfforts");export function canvasChatEffortFor(t,e){const s=e?.effort;if(!isCanvasChatEffort(s))return;const i=canvasChatEfforts(t,e);return i.includes(s)?s:i[i.length-1]}a(canvasChatEffortFor,"canvasChatEffortFor"),n(canvasChatEffortFor,"canvasChatEffortFor");export const CANVAS_CHAT_LIMITS={textChars:8e3,rows:500,title:120},CANVAS_AUTHOR_ROLE="canvas-author",CANVAS_AUTHOR_IDLE_MINUTES=15;export function canvasAuthorText(t){const e=JSON.stringify(t.chat);return["# Your role: canvas author (LensMCP)","",`You write a canvas with a person, in a chat (${t.chat}). Read it with \`canvas_chat { chat: ${e} }\`, change the canvas with \`canvas_write\` (\`chat: ${e}\` on the first, which makes it), say what you did with \`canvas_chat { chat: ${e}, say }\` \u2014 short \u2014 and wait for the next message with \`canvas_wait { on: ["chat"], chat: ${e}, since }\`. Do not change the repository. Stop after ${CANVAS_AUTHOR_IDLE_MINUTES} idle minutes; the person's next message starts you again with the chat so far.`,"",t.canvas?`- The canvas is ${t.canvas}: read it first (\`canvas_get { id: ${JSON.stringify(t.canvas)}, include: ["mdx", "data", "shape"] }\`), then write \`canvas_write { id: ${JSON.stringify(t.canvas)}, chat: ${e}, ifVersion, note }\`.`:`- There is no canvas yet: your first \`canvas_write { chat: ${e}, mdx, data, note }\` makes it and binds it to the chat; write the next versions with its \`id\`.`,"- Read skill://lensmcp-canvas/SKILL.md before you write: the components, the data and its shape, and what the checker refuses.","- What to do is in the person's messages (`kind: \"person\"`). An `edit` row is a version the person saved themselves: read it before you write, and build on it, never over it. Other rows are the chat's record.","- Read the repository and the lens as the canvas needs; change nothing in the repository \u2014 no edits, no commits, no branches. What you make is the canvas.",`- One message, one answer: the version(s) it asks for, one short \`say\`, then \`canvas_wait\` with the \`seq\` you read. Back with nothing new: wait again \u2014 once ${CANVAS_AUTHOR_IDLE_MINUTES} minutes passed with nothing, end.`].join(`
2
+ `)}a(canvasAuthorText,"canvasAuthorText"),n(canvasAuthorText,"canvasAuthorText");export function canvasAuthorStart(t){return`The person wrote to you in the canvas chat ${t.chat}: read it with canvas_chat { chat: ${JSON.stringify(t.chat)} } and answer its newest messages, as your role says. (LensMCP launch ${t.launchId}.)`}a(canvasAuthorStart,"canvasAuthorStart"),n(canvasAuthorStart,"canvasAuthorStart");
package/lib/canvas.d.ts CHANGED
@@ -90,6 +90,12 @@ export declare const CANVAS_LIMITS: {
90
90
  readonly commentChars: 8000;
91
91
  /** A frame → parent message (zod-checked, rate-limited). */
92
92
  readonly frameMessageBytes: number;
93
+ /**
94
+ * The document as drawn, handed to the page to print (`canvas/snapshot`): in parts of at most this many characters —
95
+ * each well under `frameMessageBytes` as JSON — and at most this many parts.
96
+ */
97
+ readonly snapshotPartChars: number;
98
+ readonly snapshotParts: 96;
93
99
  /** JSON nesting the parse and the data accept. */
94
100
  readonly depth: 64;
95
101
  /** Ops in one data patch or migration. */
@@ -625,7 +631,7 @@ export type CanvasSafeBlock = {
625
631
  /** Which tier the person sees (§4.3). */
626
632
  export type CanvasTier = 1 | 2 | 3;
627
633
  /** Every method the port carries; anything else is method-not-found. Names follow MCP Apps (SEP-1865). */
628
- export declare const CANVAS_BROKER_METHODS: readonly ["ui/initialize", "ui/notifications/size-changed", "ui/open-link", "canvas/heartbeat", "canvas/slots", "canvas/focus", "canvas/get", "canvas/rendered", "canvas/problem", "canvas/health", "canvas/data-changed", "canvas/answers-changed", "canvas/selection", "canvas/copy", "canvas/download", "canvas/open-ref", "canvas/slot-sizes", "canvas/theme", "canvas/escape"];
634
+ export declare const CANVAS_BROKER_METHODS: readonly ["ui/initialize", "ui/notifications/size-changed", "ui/open-link", "canvas/heartbeat", "canvas/slots", "canvas/focus", "canvas/get", "canvas/rendered", "canvas/problem", "canvas/health", "canvas/data-changed", "canvas/answers-changed", "canvas/selection", "canvas/copy", "canvas/download", "canvas/open-ref", "canvas/slot-sizes", "canvas/theme", "canvas/escape", "canvas/snapshot-asked", "canvas/snapshot", "canvas/print"];
629
635
  export type CanvasBrokerMethod = (typeof CANVAS_BROKER_METHODS)[number];
630
636
  /** A JSON-RPC 2.0 message on the port: a request has an `id`, a notification none. */
631
637
  export interface CanvasRpc<P = unknown> {
@@ -835,6 +841,24 @@ export declare const CANVAS_FRAME_PARAMS: {
835
841
  }, z.core.$strip>;
836
842
  /** Escape pressed in the document: the page around it acts on it as its own (issues/closed/canvas-20). */
837
843
  readonly 'canvas/escape': z.ZodObject<{}, z.core.$strip>;
844
+ /**
845
+ * The document as drawn, asked for by `canvas/snapshot-asked { n }` (issues/closed/canvas-24): `#root`'s HTML in
846
+ * parts, put together by the page and printed apart from the frame — untrusted markup the page sanitises and prints
847
+ * where no script runs.
848
+ */
849
+ readonly 'canvas/snapshot': z.ZodObject<{
850
+ n: z.ZodNumber;
851
+ part: z.ZodNumber;
852
+ parts: z.ZodNumber;
853
+ html: z.ZodString;
854
+ dir: z.ZodOptional<z.ZodEnum<{
855
+ auto: "auto";
856
+ ltr: "ltr";
857
+ rtl: "rtl";
858
+ }>>;
859
+ }, z.core.$strip>;
860
+ /** Cmd/Ctrl+P pressed in the document: the page prints the canvas (as the menu's Print does), not itself. */
861
+ readonly 'canvas/print': z.ZodObject<{}, z.core.$strip>;
838
862
  };
839
863
  /**
840
864
  * The height a question's slot starts at, before the parent measured its control (`canvas/slot-sizes` then tells the
package/lib/canvas.js CHANGED
@@ -1 +1 @@
1
- "use strict";var m=Object.defineProperty;var r=(e,t)=>m(e,"name",{value:t,configurable:!0});var A=Object.defineProperty,o=r((e,t)=>A(e,"name",{value:t,configurable:!0}),"o");import{z as a}from"zod";import{TASK_ARTIFACT_MAX_BYTES as d,TASK_ARTIFACTS_MAX as p,TASK_ARTIFACTS_MAX_BYTES as v}from"./canvas-attachments.js";export const CANVAS_FORMAT=1,CANVAS_FRAME_PROTOCOL=1,CANVAS_FRAME_RUNTIME="frame-v1",CANVAS_FRAME_PATH="/v1",CANVAS_FRAME_HOST="lensmcp.canvas.localhost",CANVAS_ID_PATTERN=/^cv-[0-9a-f]{16}$/,CANVAS_PROJECT_ID_PATTERN=/^pr-[0-9a-f]{16}$/,CANVAS_QID_PATTERN=/^[a-z][a-z0-9_-]{0,63}$/i,isCanvasId=o(e=>typeof e=="string"&&CANVAS_ID_PATTERN.test(e),"isCanvasId"),CANVAS_TAG_PATTERN=/^[a-z0-9][a-z0-9-]{0,31}$/,CANVAS_TAG_LIMITS={count:8,chars:32},CANVAS_DESIGN_TAG="design";export function canvasTags(e){if(!Array.isArray(e))return{why:"`tags` is a list of short labels"};const t=[];for(const s of e){if(typeof s!="string")return{why:"`tags` is a list of short labels"};const n=s.trim().replace(/^#+/,"").toLowerCase().replace(/[\s_]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"");if(n){if(!CANVAS_TAG_PATTERN.test(n))return{why:`\xAB${s.slice(0,40)}\xBB is not a label: lower-case letters, digits and -, at most ${CANVAS_TAG_LIMITS.chars} characters`};t.includes(n)||t.push(n)}}return t.length>CANVAS_TAG_LIMITS.count?{why:`a canvas has at most ${CANVAS_TAG_LIMITS.count} labels; got ${t.length}`}:{tags:t}}r(canvasTags,"canvasTags"),o(canvasTags,"canvasTags");export function authoredCanvasTags(e,t=[]){const s=canvasTags(e);if("why"in s)return s;const n=t.includes(CANVAS_DESIGN_TAG);if(!n&&s.tags.includes(CANVAS_DESIGN_TAG))return{why:`\xAB${CANVAS_DESIGN_TAG}\xBB is LensMCP's own label \u2014 the canvas a goal's design is drawn as; pick another`};const i=n&&!s.tags.includes(CANVAS_DESIGN_TAG)?[CANVAS_DESIGN_TAG,...s.tags]:s.tags;return i.length>CANVAS_TAG_LIMITS.count?{why:`a canvas has at most ${CANVAS_TAG_LIMITS.count} labels; got ${i.length}`}:{tags:i}}r(authoredCanvasTags,"authoredCanvasTags"),o(authoredCanvasTags,"authoredCanvasTags");export const CANVAS_LIMITS={mdxBytes:256*1024,mdxWholeBytes:64*1024,dataBytes:2*1024*1024,answerBytes:16*1024,questions:500,assets:p,assetBytes:v,assetFileBytes:d,canvasBytes:256*1024*1024,projectBytes:2*1024*1024*1024,titleChars:200,noteChars:2e3,commentChars:8e3,frameMessageBytes:256*1024,depth:64,ops:1e3,checkpointEvery:50,checkpointsKept:20,waitDefaultMs:45e3,waitMaxMs:9e5},CANVAS_KINDS=["doc","decision","plan","review","report","dashboard","qa","template"],CANVAS_TEMPLATE_NAMES=["decision-record","plan-review","weekly-report","goal-dashboard","qa-report"],CANVAS_QUESTION_KINDS=["choice","multi","text","number","confirm","approve"],CANVAS_FIELD_KINDS=["text","number","date","file","image"],CANVAS_INTERACTIVE=["Question","Checklist","Field","Options"];export function canvasAnswerKeys(e){return e.kind==="checklist"?(e.items??[]).map(t=>`${e.qid}/${t.id}`):e.kind==="multi"?(e.options??[]).map(t=>`${e.qid}/${t.id}`):[e.qid]}r(canvasAnswerKeys,"canvasAnswerKeys"),o(canvasAnswerKeys,"canvasAnswerKeys");export const canvasQidOf=o(e=>e.split("/")[0]??e,"canvasQidOf"),CANVAS_SHAPE_KEYS=["type","properties","required","items","enum","minimum","maximum","minItems","maxItems","format","additionalProperties","description","derived","$schema","title"],CANVAS_DATA_OPS=["set","remove","move","copy","append"],CANVAS_HEALTH_STATES=["checked","good","broken","unverified"],CANVAS_ANSWER_VIAS=["document","rail","inbox","cli","api","host"],CANVAS_LEDGER_PARTS=["version","data","answer","got","grant","share","archive","delete","comment","health","meta","asset"],CANVAS_OUTSIDE={timeoutMs:1e4,maxBytes:2*1024*1024,redirects:5,perCanvasPerMinute:30,perOriginPerMinute:60,keptPerCanvas:20,keptBytesPerCanvas:8*1024*1024};export function canvasGrantWords(e){return`This canvas could send what it reads to ${e}, or anywhere.`}r(canvasGrantWords,"canvasGrantWords"),o(canvasGrantWords,"canvasGrantWords");export function canvasGrantPrompt(e){return{title:`Let this canvas read ${e}?`,lines:[canvasGrantWords(e),"A site a canvas may read is also a way out: the addresses its versions ask for can carry what its author knows, each read tells the site you opened the canvas, and the site can pass any of it on.","The dashboard fetches it, never the canvas: only the exact URLs a version declares, public addresses only, GET, no cookies, 10 s and 2 MB at most. Revoke it here at any time; the ledger records both."],act:`Approve ${e}`}}r(canvasGrantPrompt,"canvasGrantPrompt"),o(canvasGrantPrompt,"canvasGrantPrompt");export const CANVAS_BROKER_METHODS=["ui/initialize","ui/notifications/size-changed","ui/open-link","canvas/heartbeat","canvas/slots","canvas/focus","canvas/get","canvas/rendered","canvas/problem","canvas/health","canvas/data-changed","canvas/answers-changed","canvas/selection","canvas/copy","canvas/download","canvas/open-ref","canvas/slot-sizes","canvas/theme","canvas/escape"],CANVAS_APP_MIME="text/html;profile=mcp-app",CANVAS_APP_URI_TEMPLATE="ui://canvas/{id}",canvasAppUri=o(e=>`ui://canvas/${e}`,"canvasAppUri"),CANVAS_APP_VIEW_URI="ui://canvas/view",CANVAS_ANSWER_TOOL="canvas_answer",CANVAS_APP_PROTOCOL=1;export function canvasConfirmedAnswers(e){const t=new Map;for(const n of e){if(!n.confirmed)continue;const i=t.get(n.key);(!i||n.seq>i.seq)&&t.set(n.key,n)}const s={};for(const[n,i]of t)i.state==="current"&&(s[n]=i.value);return s}r(canvasConfirmedAnswers,"canvasConfirmedAnswers"),o(canvasConfirmedAnswers,"canvasConfirmedAnswers");export function canvasFrameInit(e){const t=e.detail;return{protocol:CANVAS_FRAME_PROTOCOL,theme:e.theme,tokens:e.tokens,canvas:t.canvas.id,version:t.shown,code:e.code,compiler:e.compiler,contract:t.version.contract,bindings:t.version.bindings,data:t.data,marks:t.marks,answers:canvasConfirmedAnswers(t.answers),got:{},...e.anchor?{anchor:e.anchor}:{},fallback:e.fallback,dir:"auto"}}r(canvasFrameInit,"canvasFrameInit"),o(canvasFrameInit,"canvasFrameInit");const c=a.number(),u=a.object({qid:a.string().max(64),x:c,y:c,width:c.min(0).max(1e4),height:c.min(0).max(1e4),visible:a.boolean()}),l=a.object({message:a.string().max(4e3),block:a.string().max(200).optional(),line:a.number().int().min(0).max(1e6).optional(),column:a.number().int().min(0).max(1e5).optional(),component:a.string().max(100).optional()});export const CANVAS_FRAME_PARAMS={"ui/initialize":a.looseObject({protocol:a.number().int()}),"ui/notifications/size-changed":a.object({height:c.min(0).max(1e6),width:c.min(0).max(1e5).optional()}),"ui/open-link":a.object({url:a.string().max(4e3)}),"canvas/heartbeat":a.object({t:c}),"canvas/slots":a.object({slots:a.array(u).max(CANVAS_LIMITS.questions)}),"canvas/focus":a.object({qid:a.string().max(64)}),"canvas/get":a.object({uri:a.string().max(2e3)}),"canvas/rendered":a.object({ms:c.min(0),blocks:a.number().int().min(0),errors:a.number().int().min(0)}),"canvas/problem":a.object({errors:a.array(l).max(200)}),"canvas/health":a.object({ok:a.boolean(),errors:a.array(l).max(200)}),"canvas/selection":a.object({text:a.string().max(8e3),block:a.string().max(200).optional(),lines:a.tuple([a.number().int(),a.number().int()]).optional()}),"canvas/copy":a.object({text:a.string().max(1024*1024)}),"canvas/download":a.object({name:a.string().max(200),type:a.enum(["csv","json","png","txt","md"]),text:a.string().max(4*1024*1024)}),"canvas/open-ref":a.object({kind:a.enum(["task","goal","file","canvas"]),id:a.string().max(2e3),line:a.number().int().optional()}),"canvas/escape":a.object({})};export function canvasSlotHeight(e){const t=40+(e.detail?20:0),s=44;switch(e.kind){case"choice":case"multi":return t+36*Math.max(1,e.options?.length??0)+s;case"checklist":return t+32*Math.max(1,e.items?.length??0);case"confirm":return t+s;case"approve":return t+72+s;case"text":return t+84+s;default:return t+40+s}}r(canvasSlotHeight,"canvasSlotHeight"),o(canvasSlotHeight,"canvasSlotHeight");
1
+ "use strict";var l=Object.defineProperty;var r=(e,t)=>l(e,"name",{value:t,configurable:!0});var A=Object.defineProperty,o=r((e,t)=>A(e,"name",{value:t,configurable:!0}),"o");import{z as a}from"zod";import{TASK_ARTIFACT_MAX_BYTES as p,TASK_ARTIFACTS_MAX as d,TASK_ARTIFACTS_MAX_BYTES as h}from"./canvas-attachments.js";export const CANVAS_FORMAT=1,CANVAS_FRAME_PROTOCOL=1,CANVAS_FRAME_RUNTIME="frame-v1",CANVAS_FRAME_PATH="/v1",CANVAS_FRAME_HOST="lensmcp.canvas.localhost",CANVAS_ID_PATTERN=/^cv-[0-9a-f]{16}$/,CANVAS_PROJECT_ID_PATTERN=/^pr-[0-9a-f]{16}$/,CANVAS_QID_PATTERN=/^[a-z][a-z0-9_-]{0,63}$/i,isCanvasId=o(e=>typeof e=="string"&&CANVAS_ID_PATTERN.test(e),"isCanvasId"),CANVAS_TAG_PATTERN=/^[a-z0-9][a-z0-9-]{0,31}$/,CANVAS_TAG_LIMITS={count:8,chars:32},CANVAS_DESIGN_TAG="design";export function canvasTags(e){if(!Array.isArray(e))return{why:"`tags` is a list of short labels"};const t=[];for(const s of e){if(typeof s!="string")return{why:"`tags` is a list of short labels"};const n=s.trim().replace(/^#+/,"").toLowerCase().replace(/[\s_]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"");if(n){if(!CANVAS_TAG_PATTERN.test(n))return{why:`\xAB${s.slice(0,40)}\xBB is not a label: lower-case letters, digits and -, at most ${CANVAS_TAG_LIMITS.chars} characters`};t.includes(n)||t.push(n)}}return t.length>CANVAS_TAG_LIMITS.count?{why:`a canvas has at most ${CANVAS_TAG_LIMITS.count} labels; got ${t.length}`}:{tags:t}}r(canvasTags,"canvasTags"),o(canvasTags,"canvasTags");export function authoredCanvasTags(e,t=[]){const s=canvasTags(e);if("why"in s)return s;const n=t.includes(CANVAS_DESIGN_TAG);if(!n&&s.tags.includes(CANVAS_DESIGN_TAG))return{why:`\xAB${CANVAS_DESIGN_TAG}\xBB is LensMCP's own label \u2014 the canvas a goal's design is drawn as; pick another`};const i=n&&!s.tags.includes(CANVAS_DESIGN_TAG)?[CANVAS_DESIGN_TAG,...s.tags]:s.tags;return i.length>CANVAS_TAG_LIMITS.count?{why:`a canvas has at most ${CANVAS_TAG_LIMITS.count} labels; got ${i.length}`}:{tags:i}}r(authoredCanvasTags,"authoredCanvasTags"),o(authoredCanvasTags,"authoredCanvasTags");export const CANVAS_LIMITS={mdxBytes:256*1024,mdxWholeBytes:64*1024,dataBytes:2*1024*1024,answerBytes:16*1024,questions:500,assets:d,assetBytes:h,assetFileBytes:p,canvasBytes:256*1024*1024,projectBytes:2*1024*1024*1024,titleChars:200,noteChars:2e3,commentChars:8e3,frameMessageBytes:256*1024,snapshotPartChars:96*1024,snapshotParts:96,depth:64,ops:1e3,checkpointEvery:50,checkpointsKept:20,waitDefaultMs:45e3,waitMaxMs:9e5},CANVAS_KINDS=["doc","decision","plan","review","report","dashboard","qa","template"],CANVAS_TEMPLATE_NAMES=["decision-record","plan-review","weekly-report","goal-dashboard","qa-report"],CANVAS_QUESTION_KINDS=["choice","multi","text","number","confirm","approve"],CANVAS_FIELD_KINDS=["text","number","date","file","image"],CANVAS_INTERACTIVE=["Question","Checklist","Field","Options"];export function canvasAnswerKeys(e){return e.kind==="checklist"?(e.items??[]).map(t=>`${e.qid}/${t.id}`):e.kind==="multi"?(e.options??[]).map(t=>`${e.qid}/${t.id}`):[e.qid]}r(canvasAnswerKeys,"canvasAnswerKeys"),o(canvasAnswerKeys,"canvasAnswerKeys");export const canvasQidOf=o(e=>e.split("/")[0]??e,"canvasQidOf"),CANVAS_SHAPE_KEYS=["type","properties","required","items","enum","minimum","maximum","minItems","maxItems","format","additionalProperties","description","derived","$schema","title"],CANVAS_DATA_OPS=["set","remove","move","copy","append"],CANVAS_HEALTH_STATES=["checked","good","broken","unverified"],CANVAS_ANSWER_VIAS=["document","rail","inbox","cli","api","host"],CANVAS_LEDGER_PARTS=["version","data","answer","got","grant","share","archive","delete","comment","health","meta","asset"],CANVAS_OUTSIDE={timeoutMs:1e4,maxBytes:2*1024*1024,redirects:5,perCanvasPerMinute:30,perOriginPerMinute:60,keptPerCanvas:20,keptBytesPerCanvas:8*1024*1024};export function canvasGrantWords(e){return`This canvas could send what it reads to ${e}, or anywhere.`}r(canvasGrantWords,"canvasGrantWords"),o(canvasGrantWords,"canvasGrantWords");export function canvasGrantPrompt(e){return{title:`Let this canvas read ${e}?`,lines:[canvasGrantWords(e),"A site a canvas may read is also a way out: the addresses its versions ask for can carry what its author knows, each read tells the site you opened the canvas, and the site can pass any of it on.","The dashboard fetches it, never the canvas: only the exact URLs a version declares, public addresses only, GET, no cookies, 10 s and 2 MB at most. Revoke it here at any time; the ledger records both."],act:`Approve ${e}`}}r(canvasGrantPrompt,"canvasGrantPrompt"),o(canvasGrantPrompt,"canvasGrantPrompt");export const CANVAS_BROKER_METHODS=["ui/initialize","ui/notifications/size-changed","ui/open-link","canvas/heartbeat","canvas/slots","canvas/focus","canvas/get","canvas/rendered","canvas/problem","canvas/health","canvas/data-changed","canvas/answers-changed","canvas/selection","canvas/copy","canvas/download","canvas/open-ref","canvas/slot-sizes","canvas/theme","canvas/escape","canvas/snapshot-asked","canvas/snapshot","canvas/print"],CANVAS_APP_MIME="text/html;profile=mcp-app",CANVAS_APP_URI_TEMPLATE="ui://canvas/{id}",canvasAppUri=o(e=>`ui://canvas/${e}`,"canvasAppUri"),CANVAS_APP_VIEW_URI="ui://canvas/view",CANVAS_ANSWER_TOOL="canvas_answer",CANVAS_APP_PROTOCOL=1;export function canvasConfirmedAnswers(e){const t=new Map;for(const n of e){if(!n.confirmed)continue;const i=t.get(n.key);(!i||n.seq>i.seq)&&t.set(n.key,n)}const s={};for(const[n,i]of t)i.state==="current"&&(s[n]=i.value);return s}r(canvasConfirmedAnswers,"canvasConfirmedAnswers"),o(canvasConfirmedAnswers,"canvasConfirmedAnswers");export function canvasFrameInit(e){const t=e.detail;return{protocol:CANVAS_FRAME_PROTOCOL,theme:e.theme,tokens:e.tokens,canvas:t.canvas.id,version:t.shown,code:e.code,compiler:e.compiler,contract:t.version.contract,bindings:t.version.bindings,data:t.data,marks:t.marks,answers:canvasConfirmedAnswers(t.answers),got:{},...e.anchor?{anchor:e.anchor}:{},fallback:e.fallback,dir:"auto"}}r(canvasFrameInit,"canvasFrameInit"),o(canvasFrameInit,"canvasFrameInit");const c=a.number(),v=a.object({qid:a.string().max(64),x:c,y:c,width:c.min(0).max(1e4),height:c.min(0).max(1e4),visible:a.boolean()}),m=a.object({message:a.string().max(4e3),block:a.string().max(200).optional(),line:a.number().int().min(0).max(1e6).optional(),column:a.number().int().min(0).max(1e5).optional(),component:a.string().max(100).optional()});export const CANVAS_FRAME_PARAMS={"ui/initialize":a.looseObject({protocol:a.number().int()}),"ui/notifications/size-changed":a.object({height:c.min(0).max(1e6),width:c.min(0).max(1e5).optional()}),"ui/open-link":a.object({url:a.string().max(4e3)}),"canvas/heartbeat":a.object({t:c}),"canvas/slots":a.object({slots:a.array(v).max(CANVAS_LIMITS.questions)}),"canvas/focus":a.object({qid:a.string().max(64)}),"canvas/get":a.object({uri:a.string().max(2e3)}),"canvas/rendered":a.object({ms:c.min(0),blocks:a.number().int().min(0),errors:a.number().int().min(0)}),"canvas/problem":a.object({errors:a.array(m).max(200)}),"canvas/health":a.object({ok:a.boolean(),errors:a.array(m).max(200)}),"canvas/selection":a.object({text:a.string().max(8e3),block:a.string().max(200).optional(),lines:a.tuple([a.number().int(),a.number().int()]).optional()}),"canvas/copy":a.object({text:a.string().max(1024*1024)}),"canvas/download":a.object({name:a.string().max(200),type:a.enum(["csv","json","png","txt","md"]),text:a.string().max(4*1024*1024)}),"canvas/open-ref":a.object({kind:a.enum(["task","goal","file","canvas"]),id:a.string().max(2e3),line:a.number().int().optional()}),"canvas/escape":a.object({}),"canvas/snapshot":a.object({n:a.number().int().min(0),part:a.number().int().min(0).max(CANVAS_LIMITS.snapshotParts-1),parts:a.number().int().min(1).max(CANVAS_LIMITS.snapshotParts),html:a.string().max(CANVAS_LIMITS.snapshotPartChars),dir:a.enum(["ltr","rtl","auto"]).optional()}),"canvas/print":a.object({})};export function canvasSlotHeight(e){const t=40+(e.detail?20:0),s=44;switch(e.kind){case"choice":case"multi":return t+36*Math.max(1,e.options?.length??0)+s;case"checklist":return t+32*Math.max(1,e.items?.length??0);case"confirm":return t+s;case"approve":return t+72+s;case"text":return t+84+s;default:return t+40+s}}r(canvasSlotHeight,"canvasSlotHeight"),o(canvasSlotHeight,"canvasSlotHeight");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lensmcp/protocol-types",
3
- "version": "1.26.28",
3
+ "version": "1.26.29",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "module": "./index.js",