@lensmcp/protocol-types 1.26.29 → 1.26.30
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/lib/canvas.d.ts +13 -1
- package/lib/canvas.js +1 -1
- package/package.json +1 -1
package/lib/canvas.d.ts
CHANGED
|
@@ -865,6 +865,11 @@ export declare const CANVAS_FRAME_PARAMS: {
|
|
|
865
865
|
* frame the real heights). One formula on both sides, so the first layout already leaves the control its room.
|
|
866
866
|
*/
|
|
867
867
|
export declare function canvasSlotHeight(ask: CanvasAsk): number;
|
|
868
|
+
/**
|
|
869
|
+
* An option's label as it is shown: without the colon its author ended it with — `**Free it by hand now:** what it
|
|
870
|
+
* means` reads its bold part as the label, and the label read «Free it by hand now:» everywhere it stood alone.
|
|
871
|
+
*/
|
|
872
|
+
export declare function canvasOptionLabel(label: string): string;
|
|
868
873
|
/** Parent → frame notifications. */
|
|
869
874
|
export interface CanvasSlotSizes {
|
|
870
875
|
/** The height the parent's control for each qid needs. */
|
|
@@ -954,8 +959,13 @@ export interface DashCanvasInbox {
|
|
|
954
959
|
}
|
|
955
960
|
export interface DashCanvasList {
|
|
956
961
|
canvases: DashCanvasRow[];
|
|
957
|
-
/**
|
|
962
|
+
/**
|
|
963
|
+
* The projects worth naming here, for filters and sharing: this one, each that owns or is named by a canvas this
|
|
964
|
+
* project reads, and each other whose folder is still on this machine — not one of a folder long gone.
|
|
965
|
+
*/
|
|
958
966
|
projects: CanvasProjectRef[];
|
|
967
|
+
/** The titles of the tasks and goals the listed canvases link to, by id — what a link is called on the page. */
|
|
968
|
+
linkTitles?: Record<string, string>;
|
|
959
969
|
/** The project the dashboard serves. */
|
|
960
970
|
here?: CanvasProjectRef;
|
|
961
971
|
/**
|
|
@@ -982,6 +992,8 @@ export interface DashCanvasList {
|
|
|
982
992
|
export interface DashCanvasDetail {
|
|
983
993
|
canvas: CanvasRecord;
|
|
984
994
|
project: CanvasProjectRef;
|
|
995
|
+
/** The titles of the tasks and goals it links to, by id, as this dashboard's board knows them. */
|
|
996
|
+
linkTitles?: Record<string, string>;
|
|
985
997
|
/** The version drawn: `current`, or `lastGood` under tier 2. */
|
|
986
998
|
shown: number;
|
|
987
999
|
tier: CanvasTier;
|
package/lib/canvas.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var m=Object.defineProperty;var r=(e,t)=>m(e,"name",{value:t,configurable:!0});var p=Object.defineProperty,o=r((e,t)=>p(e,"name",{value:t,configurable:!0}),"o");import{z as a}from"zod";import{TASK_ARTIFACT_MAX_BYTES as A,TASK_ARTIFACTS_MAX as h,TASK_ARTIFACTS_MAX_BYTES as d}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 n of e){if(typeof n!="string")return{why:"`tags` is a list of short labels"};const s=n.trim().replace(/^#+/,"").toLowerCase().replace(/[\s_]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"");if(s){if(!CANVAS_TAG_PATTERN.test(s))return{why:`\xAB${n.slice(0,40)}\xBB is not a label: lower-case letters, digits and -, at most ${CANVAS_TAG_LIMITS.chars} characters`};t.includes(s)||t.push(s)}}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 n=canvasTags(e);if("why"in n)return n;const s=t.includes(CANVAS_DESIGN_TAG);if(!s&&n.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=s&&!n.tags.includes(CANVAS_DESIGN_TAG)?[CANVAS_DESIGN_TAG,...n.tags]:n.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:h,assetBytes:d,assetFileBytes:A,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 s of e){if(!s.confirmed)continue;const i=t.get(s.key);(!i||s.seq>i.seq)&&t.set(s.key,s)}const n={};for(const[s,i]of t)i.state==="current"&&(n[s]=i.value);return n}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()}),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(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(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({}),"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){if(e.component==="Options"&&e.kind==="choice")return 26+40*Math.ceil(Math.max(1,e.options?.length??0)/2);const t=40+(e.detail?20:0),n=44;switch(e.kind){case"choice":case"multi":return t+36*Math.max(1,e.options?.length??0)+n;case"checklist":return t+32*Math.max(1,e.items?.length??0);case"confirm":return t+n;case"approve":return t+72+n;case"text":return t+84+n;default:return t+40+n}}r(canvasSlotHeight,"canvasSlotHeight"),o(canvasSlotHeight,"canvasSlotHeight");export function canvasOptionLabel(e){return e.replace(/\s*[::]+\s*$/u,"")||e}r(canvasOptionLabel,"canvasOptionLabel"),o(canvasOptionLabel,"canvasOptionLabel");
|