@lensmcp/protocol-types 1.26.26 → 1.26.28
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/index.d.ts +1 -0
- package/index.js +1 -1
- package/lib/canvas-chat.d.ts +132 -0
- package/lib/canvas-chat.js +2 -0
- package/lib/canvas.d.ts +52 -0
- package/lib/canvas.js +1 -1
- package/lib/goal-design.d.ts +24 -0
- package/package.json +1 -1
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";export*from"./lib/schema-version.js";export*from"./lib/source-location.js";export*from"./lib/context.js";export*from"./lib/event.js";export*from"./lib/node.js";export*from"./lib/edge.js";export*from"./lib/attributes.js";export*from"./lib/producer-health.js";export*from"./lib/resources.js";export*from"./lib/tokens.js";export*from"./lib/capture-demand.js";export*from"./lib/bounded-clone.js";export*from"./lib/bounded-map.js";export*from"./lib/flood-guard.js";export*from"./lib/dashboard.js";export*from"./lib/dashboard-path.js";export*from"./lib/lens-hosts.js";export*from"./lib/dashboard-lint.js";export*from"./lib/dashboard-typecheck.js";export*from"./lib/lint-coverage.js";export*from"./lib/lint-ignores.js";export*from"./lib/static-checks.js";export*from"./lib/log-query.js";export*from"./lib/error-dismissal.js";export*from"./lib/expected-failure.js";export*from"./lib/error-verdict.js";export*from"./lib/finding-proof.js";export*from"./lib/error-cause.js";export*from"./lib/metrics-reset.js";export*from"./lib/ai-content.js";export*from"./lib/http-exchange.js";export*from"./lib/ai-call.js";export*from"./lib/ai-call-row.js";export*from"./lib/ai-call-groups.js";export*from"./lib/ai-context.js";export*from"./lib/ai-cache-facts.js";export*from"./lib/ai-cache.js";export*from"./lib/ai-cache-verdict.js";export*from"./lib/ai-together.js";export*from"./lib/ai-origins.js";export*from"./lib/ai-playground.js";export*from"./lib/ai-compare.js";export*from"./lib/pod-memory.js";export*from"./lib/perf-rules.js";export*from"./lib/sources.js";export*from"./lib/page-visit.js";export*from"./lib/replay.js";export*from"./lib/event-loop.js";export*from"./lib/workspace-actions.js";export*from"./lib/docker-jobs.js";export*from"./lib/docker-report.js";export*from"./lib/docker-runs.js";export*from"./lib/docker-errors.js";export*from"./lib/peers.js";export*from"./lib/hosts.js";export*from"./lib/cluster-hosts.js";export*from"./lib/dashboard-updates.js";export*from"./lib/accounts.js";export*from"./lib/host-agents.js";export*from"./lib/remote-instances.js";export*from"./lib/team.js";export*from"./lib/sessions.js";export*from"./lib/conversations.js";export*from"./lib/backlog.js";export*from"./lib/team-review-changes.js";export*from"./lib/goal-outcome.js";export*from"./lib/role-fidelity.js";export*from"./lib/goal-retro.js";export*from"./lib/follow-ups.js";export*from"./lib/changes.js";export*from"./lib/main-mirror.js";export*from"./lib/team-design.js";export*from"./lib/team-library.js";export*from"./lib/team-skills.js";export*from"./lib/system-report.js";export*from"./lib/overseer-findings.js";export*from"./lib/overseer-rounds.js";export*from"./lib/goal-design.js";export*from"./lib/overseer-messages.js";export*from"./lib/team-roadmap.js";export*from"./lib/team-prompts.js";export{PROOF_ACTIONS,NOT_RUN_KINDS}from"./lib/team-delivery.js";export*from"./lib/canvas.js";export*from"./lib/canvas-catalog.js";export*from"./lib/canvas-frame-policy.js";export*from"./lib/canvas-attachments.js";export*from"./lib/canvas-editing.js";export*from"./lib/canvas-hub.js";
|
|
1
|
+
"use strict";export*from"./lib/schema-version.js";export*from"./lib/source-location.js";export*from"./lib/context.js";export*from"./lib/event.js";export*from"./lib/node.js";export*from"./lib/edge.js";export*from"./lib/attributes.js";export*from"./lib/producer-health.js";export*from"./lib/resources.js";export*from"./lib/tokens.js";export*from"./lib/capture-demand.js";export*from"./lib/bounded-clone.js";export*from"./lib/bounded-map.js";export*from"./lib/flood-guard.js";export*from"./lib/dashboard.js";export*from"./lib/dashboard-path.js";export*from"./lib/lens-hosts.js";export*from"./lib/dashboard-lint.js";export*from"./lib/dashboard-typecheck.js";export*from"./lib/lint-coverage.js";export*from"./lib/lint-ignores.js";export*from"./lib/static-checks.js";export*from"./lib/log-query.js";export*from"./lib/error-dismissal.js";export*from"./lib/expected-failure.js";export*from"./lib/error-verdict.js";export*from"./lib/finding-proof.js";export*from"./lib/error-cause.js";export*from"./lib/metrics-reset.js";export*from"./lib/ai-content.js";export*from"./lib/http-exchange.js";export*from"./lib/ai-call.js";export*from"./lib/ai-call-row.js";export*from"./lib/ai-call-groups.js";export*from"./lib/ai-context.js";export*from"./lib/ai-cache-facts.js";export*from"./lib/ai-cache.js";export*from"./lib/ai-cache-verdict.js";export*from"./lib/ai-together.js";export*from"./lib/ai-origins.js";export*from"./lib/ai-playground.js";export*from"./lib/ai-compare.js";export*from"./lib/pod-memory.js";export*from"./lib/perf-rules.js";export*from"./lib/sources.js";export*from"./lib/page-visit.js";export*from"./lib/replay.js";export*from"./lib/event-loop.js";export*from"./lib/workspace-actions.js";export*from"./lib/docker-jobs.js";export*from"./lib/docker-report.js";export*from"./lib/docker-runs.js";export*from"./lib/docker-errors.js";export*from"./lib/peers.js";export*from"./lib/hosts.js";export*from"./lib/cluster-hosts.js";export*from"./lib/dashboard-updates.js";export*from"./lib/accounts.js";export*from"./lib/host-agents.js";export*from"./lib/remote-instances.js";export*from"./lib/team.js";export*from"./lib/sessions.js";export*from"./lib/conversations.js";export*from"./lib/backlog.js";export*from"./lib/team-review-changes.js";export*from"./lib/goal-outcome.js";export*from"./lib/role-fidelity.js";export*from"./lib/goal-retro.js";export*from"./lib/follow-ups.js";export*from"./lib/changes.js";export*from"./lib/main-mirror.js";export*from"./lib/team-design.js";export*from"./lib/team-library.js";export*from"./lib/team-skills.js";export*from"./lib/system-report.js";export*from"./lib/overseer-findings.js";export*from"./lib/overseer-rounds.js";export*from"./lib/goal-design.js";export*from"./lib/overseer-messages.js";export*from"./lib/team-roadmap.js";export*from"./lib/team-prompts.js";export{PROOF_ACTIONS,NOT_RUN_KINDS}from"./lib/team-delivery.js";export*from"./lib/canvas.js";export*from"./lib/canvas-catalog.js";export*from"./lib/canvas-frame-policy.js";export*from"./lib/canvas-attachments.js";export*from"./lib/canvas-editing.js";export*from"./lib/canvas-chat.js";export*from"./lib/canvas-hub.js";
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type { CanvasActor, CanvasHealthState } from './canvas.js';
|
|
2
|
+
/**
|
|
3
|
+
* Canvas chat (planning/canvas/02-canvas-chat.md): the person makes and changes a canvas by talking to it, in the
|
|
4
|
+
* dashboard. A chat (`ch-<id>`) belongs to one canvas once it exists — a chat started from *New canvas* is bound to
|
|
5
|
+
* the canvas its first version makes. Its engine is the person's pick, per chat (C1): a MODEL called with a key from
|
|
6
|
+
* Settings › AI, or an AGENT launched headless on the person's accounts.
|
|
7
|
+
*
|
|
8
|
+
* POST /api/canvases/chats DashCanvasChatStart → DashCanvasChatAnswer
|
|
9
|
+
* GET /api/canvases/chats?canvas=<id> DashCanvasChatList
|
|
10
|
+
* GET /api/canvases/chats/<ch> DashCanvasChatAnswer (`rows` whole)
|
|
11
|
+
* POST /api/canvases/chats/<ch>/messages DashCanvasChatSay → DashCanvasChatAnswer
|
|
12
|
+
* POST /api/canvases/chats/<ch>/engine DashCanvasChatEngineInput → DashCanvasChatAnswer
|
|
13
|
+
* POST /api/canvases/chats/<ch>/stop → DashCanvasChatAnswer
|
|
14
|
+
* GET /api/canvases/chats/<ch>/stream text/event-stream of DashCanvasChatEvent
|
|
15
|
+
*/
|
|
16
|
+
export declare const CANVAS_CHAT_ENGINES: readonly ["model", "agent"];
|
|
17
|
+
export type CanvasChatEngine = (typeof CANVAS_CHAT_ENGINES)[number];
|
|
18
|
+
export declare const CANVAS_CHAT_STATES: readonly ["idle", "working", "stopped", "failed"];
|
|
19
|
+
export type CanvasChatState = (typeof CANVAS_CHAT_STATES)[number];
|
|
20
|
+
/**
|
|
21
|
+
* What a row is: the person's message; the engine's words (`reply`); a tool call or a launch's progress line, shown
|
|
22
|
+
* small (`step`); a version written by the engine (`version`); a version the person saved from MDX/Data (`edit`); a
|
|
23
|
+
* failure (`error`); the engine switched (`engine`).
|
|
24
|
+
*/
|
|
25
|
+
export declare const CANVAS_CHAT_ROW_KINDS: readonly ["person", "reply", "step", "version", "edit", "error", "engine"];
|
|
26
|
+
export type CanvasChatRowKind = (typeof CANVAS_CHAT_ROW_KINDS)[number];
|
|
27
|
+
/** How a chat's engine runs: the model's provider and model id, or the agent's client and the account it uses. */
|
|
28
|
+
export interface CanvasChatSettings {
|
|
29
|
+
/** model: `anthropic` | `openai`. */
|
|
30
|
+
provider?: string;
|
|
31
|
+
/** model: the model id (default: the provider's default in Settings › AI). */
|
|
32
|
+
model?: string;
|
|
33
|
+
/** agent: `claude` | `codex` (default: the machine's launch default). */
|
|
34
|
+
client?: string;
|
|
35
|
+
/** agent: the account id (`ac-…`) it launches on (default: the drain plan's next). */
|
|
36
|
+
account?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface CanvasChat {
|
|
39
|
+
id: string;
|
|
40
|
+
project: string;
|
|
41
|
+
/** The canvas it changes; absent until a new canvas's first version is written. */
|
|
42
|
+
canvas?: string;
|
|
43
|
+
engine: CanvasChatEngine;
|
|
44
|
+
settings: CanvasChatSettings;
|
|
45
|
+
title: string;
|
|
46
|
+
state: CanvasChatState;
|
|
47
|
+
/** What runs now: a model turn's id, or the agent's launch id. */
|
|
48
|
+
working?: string;
|
|
49
|
+
createdAt: number;
|
|
50
|
+
updatedAt: number;
|
|
51
|
+
by: CanvasActor;
|
|
52
|
+
/** The newest row's seq. */
|
|
53
|
+
seq: number;
|
|
54
|
+
}
|
|
55
|
+
export interface CanvasChatRow {
|
|
56
|
+
chat: string;
|
|
57
|
+
seq: number;
|
|
58
|
+
at: number;
|
|
59
|
+
kind: CanvasChatRowKind;
|
|
60
|
+
/** What is said: the person's or the engine's words, a step's line, a version's note, an error's message. */
|
|
61
|
+
text: string;
|
|
62
|
+
/** `version` and `edit`: the version's number. */
|
|
63
|
+
version?: number;
|
|
64
|
+
/** `version` and `edit`: its health once checked. */
|
|
65
|
+
health?: CanvasHealthState;
|
|
66
|
+
/** Who: the person, the model (`model:<provider>`), the agent (its client and session). */
|
|
67
|
+
by?: CanvasActor;
|
|
68
|
+
/** `engine`: the engine and settings switched to. `error`: a code the page can act on (`no-key`, `launch-off`, `quota`…). */
|
|
69
|
+
meta?: Record<string, unknown>;
|
|
70
|
+
}
|
|
71
|
+
/** The longest message the person sends, and the most rows one answer carries (the newest). */
|
|
72
|
+
export declare const CANVAS_CHAT_LIMITS: {
|
|
73
|
+
readonly textChars: 8000;
|
|
74
|
+
readonly rows: 500;
|
|
75
|
+
readonly title: 120;
|
|
76
|
+
};
|
|
77
|
+
export interface DashCanvasChatStart {
|
|
78
|
+
engine: CanvasChatEngine;
|
|
79
|
+
settings?: CanvasChatSettings;
|
|
80
|
+
/** The first message. */
|
|
81
|
+
text: string;
|
|
82
|
+
/** A chat about an existing canvas; absent, a new canvas. */
|
|
83
|
+
canvas?: string;
|
|
84
|
+
requestId?: string;
|
|
85
|
+
}
|
|
86
|
+
export interface DashCanvasChatSay {
|
|
87
|
+
text: string;
|
|
88
|
+
requestId?: string;
|
|
89
|
+
}
|
|
90
|
+
export interface DashCanvasChatEngineInput {
|
|
91
|
+
engine: CanvasChatEngine;
|
|
92
|
+
settings?: CanvasChatSettings;
|
|
93
|
+
}
|
|
94
|
+
export interface DashCanvasChatAnswer {
|
|
95
|
+
chat: CanvasChat;
|
|
96
|
+
rows: CanvasChatRow[];
|
|
97
|
+
}
|
|
98
|
+
export interface DashCanvasChatList {
|
|
99
|
+
chats: CanvasChat[];
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* The stream's events: a row as it is written; a reply's text as it streams (`live`, replaced by its `row` when whole —
|
|
103
|
+
* `text` is the whole reply so far, not a piece); the chat's own state.
|
|
104
|
+
*/
|
|
105
|
+
export type DashCanvasChatEvent = {
|
|
106
|
+
kind: 'row';
|
|
107
|
+
row: CanvasChatRow;
|
|
108
|
+
} | {
|
|
109
|
+
kind: 'live';
|
|
110
|
+
text: string;
|
|
111
|
+
} | {
|
|
112
|
+
kind: 'chat';
|
|
113
|
+
chat: CanvasChat;
|
|
114
|
+
};
|
|
115
|
+
/** The role a chat's launch carries on the launch registry and Team › Launches. */
|
|
116
|
+
export declare const CANVAS_AUTHOR_ROLE = "canvas-author";
|
|
117
|
+
/** How long a canvas author waits for the next message before it ends: the person's next message starts it again. */
|
|
118
|
+
export declare const CANVAS_AUTHOR_IDLE_MINUTES = 15;
|
|
119
|
+
/**
|
|
120
|
+
* The canvas author's whole guide: given to the launched client where a compaction cannot reach it (Claude Code's system
|
|
121
|
+
* prompt, Codex's developer instructions — storage launches.ts `roleText`), so it holds for the whole session. Its first
|
|
122
|
+
* paragraph is the plan's, with the chat's ids in it. Every tool it names is a canvas tool (apps/canvas tools.spec.ts).
|
|
123
|
+
*/
|
|
124
|
+
export declare function canvasAuthorText(p: {
|
|
125
|
+
chat: string;
|
|
126
|
+
canvas?: string;
|
|
127
|
+
}): string;
|
|
128
|
+
/** What a canvas author is told first (its stdin): read the chat and answer it. Its rules are {@link canvasAuthorText}. */
|
|
129
|
+
export declare function canvasAuthorStart(p: {
|
|
130
|
+
chat: string;
|
|
131
|
+
launchId: string;
|
|
132
|
+
}): string;
|
|
@@ -0,0 +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");
|
package/lib/canvas.d.ts
CHANGED
|
@@ -35,6 +35,37 @@ export declare const CANVAS_PROJECT_ID_PATTERN: RegExp;
|
|
|
35
35
|
/** A question id, option id or checklist item id: what the person's answers are keyed by. */
|
|
36
36
|
export declare const CANVAS_QID_PATTERN: RegExp;
|
|
37
37
|
export declare const isCanvasId: (id: unknown) => id is string;
|
|
38
|
+
/**
|
|
39
|
+
* A canvas's labels: short words the person and its authors put on it, to find and sort canvases by (`design`, `qa`,
|
|
40
|
+
* `weekly`…). Lower case, digits and `-`; at most {@link CANVAS_TAG_LIMITS}. `design` is LensMCP's own: the canvas a
|
|
41
|
+
* goal's design is drawn as (planning/team/20), shown on the Canvases page under Designs, and hidden there once its
|
|
42
|
+
* goal ended.
|
|
43
|
+
*/
|
|
44
|
+
export declare const CANVAS_TAG_PATTERN: RegExp;
|
|
45
|
+
export declare const CANVAS_TAG_LIMITS: {
|
|
46
|
+
readonly count: 8;
|
|
47
|
+
readonly chars: 32;
|
|
48
|
+
};
|
|
49
|
+
/** The label LensMCP puts on a goal's design canvas. */
|
|
50
|
+
export declare const CANVAS_DESIGN_TAG = "design";
|
|
51
|
+
/**
|
|
52
|
+
* Labels as written made labels: trimmed, lower case, spaces and `_` as `-`, a leading `#` dropped, each once, in the
|
|
53
|
+
* order given. Undefined, with why, when one still is not a label or there are more than {@link CANVAS_TAG_LIMITS}.
|
|
54
|
+
*/
|
|
55
|
+
export declare function canvasTags(input: unknown): {
|
|
56
|
+
tags: string[];
|
|
57
|
+
} | {
|
|
58
|
+
why: string;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* The labels a person or an agent writes on a canvas that has `before`: {@link CANVAS_DESIGN_TAG} is LensMCP's — kept
|
|
62
|
+
* where it was (first), never put on by hand, so the Canvases page's Designs are the goals' designs and only those.
|
|
63
|
+
*/
|
|
64
|
+
export declare function authoredCanvasTags(asked: unknown, before?: readonly string[]): {
|
|
65
|
+
tags: string[];
|
|
66
|
+
} | {
|
|
67
|
+
why: string;
|
|
68
|
+
};
|
|
38
69
|
/** Each cap is refused with its reason, never cut silently (§3.6). */
|
|
39
70
|
export declare const CANVAS_LIMITS: {
|
|
40
71
|
/** MDX of one version. */
|
|
@@ -310,6 +341,8 @@ export interface CanvasRecord {
|
|
|
310
341
|
title: string;
|
|
311
342
|
kind: CanvasKind;
|
|
312
343
|
links: CanvasLink[];
|
|
344
|
+
/** Its labels ({@link canvasTags}); absent: none — and on a record an older LensMCP or hub wrote. */
|
|
345
|
+
tags?: string[];
|
|
313
346
|
author: CanvasActor;
|
|
314
347
|
share: CanvasShare;
|
|
315
348
|
archived: boolean;
|
|
@@ -827,6 +860,14 @@ export interface DashCanvasRow {
|
|
|
827
860
|
kind: CanvasKind;
|
|
828
861
|
project: CanvasProjectRef;
|
|
829
862
|
links: CanvasLink[];
|
|
863
|
+
/** Its labels, when it has any. */
|
|
864
|
+
tags?: string[];
|
|
865
|
+
/**
|
|
866
|
+
* A design canvas (labelled {@link CANVAS_DESIGN_TAG}): whether its goal ended — completed or cancelled. The Canvases
|
|
867
|
+
* page shows an ended goal's design only when asked (Designs › Show finished). Absent: not a design, or its goal is
|
|
868
|
+
* not on this board.
|
|
869
|
+
*/
|
|
870
|
+
goalEnded?: boolean;
|
|
830
871
|
author: CanvasActor;
|
|
831
872
|
current: number;
|
|
832
873
|
latest: number;
|
|
@@ -893,13 +934,24 @@ export interface DashCanvasList {
|
|
|
893
934
|
projects: CanvasProjectRef[];
|
|
894
935
|
/** The project the dashboard serves. */
|
|
895
936
|
here?: CanvasProjectRef;
|
|
937
|
+
/**
|
|
938
|
+
* `all`: the canvases the page lists unfiltered — every one but the designs; `designs`: the design canvases whose goal
|
|
939
|
+
* has not ended; `finished`: those whose goal ended (Designs › Show finished).
|
|
940
|
+
*/
|
|
896
941
|
counts: {
|
|
897
942
|
all: number;
|
|
898
943
|
open: number;
|
|
899
944
|
broken: number;
|
|
900
945
|
archived: number;
|
|
901
946
|
shared: number;
|
|
947
|
+
designs?: number;
|
|
948
|
+
finished?: number;
|
|
902
949
|
};
|
|
950
|
+
/** The labels on this project's canvases, and on how many each — the page's label filter. */
|
|
951
|
+
tags?: Array<{
|
|
952
|
+
tag: string;
|
|
953
|
+
count: number;
|
|
954
|
+
}>;
|
|
903
955
|
/** The store's head across canvases: the page refetches when it moves. */
|
|
904
956
|
stamp: string;
|
|
905
957
|
}
|
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 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");
|
package/lib/goal-design.d.ts
CHANGED
|
@@ -42,9 +42,14 @@ export interface DashDesignQuestion {
|
|
|
42
42
|
question: string;
|
|
43
43
|
/** What the overseer found that the answer turns on. */
|
|
44
44
|
context?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Each option: its label, the line after it (`detail`), and its write-up — the Markdown indented under it (`body`): what
|
|
47
|
+
* the person gets, what it costs, its risk, a diagram when it changes how it works. Absent on a version before format 2.
|
|
48
|
+
*/
|
|
45
49
|
options: Array<{
|
|
46
50
|
label: string;
|
|
47
51
|
detail?: string;
|
|
52
|
+
body?: string;
|
|
48
53
|
}>;
|
|
49
54
|
/** The number (1…) of the recommended option. */
|
|
50
55
|
recommended: number;
|
|
@@ -118,6 +123,11 @@ export interface DashDesignVersion {
|
|
|
118
123
|
format?: 'mdx';
|
|
119
124
|
/** The canvas this version is drawn as (its questions are the canvas's decisions). Absent: not drawn as one yet. */
|
|
120
125
|
canvas?: DashDesignCanvasRef;
|
|
126
|
+
/**
|
|
127
|
+
* The design format it was checked against: 2 — «How it works» with a diagram, each option written up (owner,
|
|
128
|
+
* 2026-11-24). Absent: handed in before; LensMCP sends a waiting one back to be written again ({@link DashGoalDesign.rewrite}).
|
|
129
|
+
*/
|
|
130
|
+
form?: number;
|
|
121
131
|
}
|
|
122
132
|
/**
|
|
123
133
|
* One version of a design as a canvas: the canvas (`cv-…`, one per design, linked to its goal) and its version. Its
|
|
@@ -127,6 +137,8 @@ export interface DashDesignVersion {
|
|
|
127
137
|
export interface DashDesignCanvasRef {
|
|
128
138
|
id: string;
|
|
129
139
|
version: number;
|
|
140
|
+
/** How the version was laid out as a canvas: 2 — the reading order, its evidence folded. Absent: the first layout. */
|
|
141
|
+
layout?: number;
|
|
130
142
|
}
|
|
131
143
|
/** The canvas decision a design question is: its `qid` is the question's id (`q1`); an option `o<n>` is option n. */
|
|
132
144
|
export declare const designOptionId: (n: number) => string;
|
|
@@ -198,6 +210,16 @@ export interface DashGoalDesign {
|
|
|
198
210
|
file?: string;
|
|
199
211
|
/** The canvas its versions are drawn as (`cv-…`): one per design, a canvas version per design version. */
|
|
200
212
|
canvas?: string;
|
|
213
|
+
/**
|
|
214
|
+
* LensMCP sent this version back to the overseer to be written again in the format designs are held to now (a diagram
|
|
215
|
+
* of how it works, each option written up) — not the person's word: nothing they answered was sent, and the version
|
|
216
|
+
* stays readable. Once per version; the overseer's next version is in the new format.
|
|
217
|
+
*/
|
|
218
|
+
rewrite?: {
|
|
219
|
+
version: number;
|
|
220
|
+
at: number;
|
|
221
|
+
why: string;
|
|
222
|
+
};
|
|
201
223
|
}
|
|
202
224
|
/** A design on the Inbox › Designs list. */
|
|
203
225
|
export interface DashDesignBrief {
|
|
@@ -220,6 +242,8 @@ export interface DashDesignBrief {
|
|
|
220
242
|
decision?: DashDesignDecision;
|
|
221
243
|
/** The newest version as a canvas: the canvas's own pages (Canvases, a canvas opened anywhere) answer it too. */
|
|
222
244
|
canvas?: DashDesignCanvasRef;
|
|
245
|
+
/** LensMCP sent the newest version back to be written again in the new format ({@link DashGoalDesign.rewrite}). */
|
|
246
|
+
rewrite?: boolean;
|
|
223
247
|
}
|
|
224
248
|
export interface DashDesignsAnswer {
|
|
225
249
|
designs: DashDesignBrief[];
|