@lensmcp/protocol-types 1.26.23 → 1.26.24
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 +5 -0
- package/index.js +1 -1
- package/lib/ai-cache-verdict.d.ts +1 -1
- package/lib/ai-cache-verdict.js +1 -1
- package/lib/ai-call-row.d.ts +11 -0
- package/lib/ai-call-row.js +2 -2
- package/lib/ai-call.js +9 -9
- package/lib/canvas-attachments.d.ts +80 -0
- package/lib/canvas-attachments.js +1 -0
- package/lib/canvas-catalog.js +3 -2
- package/lib/canvas-editing.d.ts +107 -0
- package/lib/canvas-editing.js +4 -0
- package/lib/canvas-frame-policy.d.ts +20 -0
- package/lib/canvas-frame-policy.js +1 -0
- package/lib/canvas-hub.d.ts +231 -0
- package/lib/canvas-hub.js +1 -0
- package/lib/canvas.d.ts +149 -8
- package/lib/canvas.js +1 -1
- package/lib/docker-jobs.d.ts +9 -2
- package/lib/docker-report.d.ts +2 -1
- package/lib/docker-report.js +1 -1
- package/lib/http-exchange.d.ts +10 -0
- package/lib/lens-hosts.d.ts +40 -0
- package/lib/lens-hosts.js +1 -0
- package/lib/lint-coverage.d.ts +8 -0
- package/lib/lint-ignores.d.ts +20 -0
- package/lib/lint-ignores.js +2 -2
- package/lib/overseer-findings.d.ts +21 -4
- package/lib/overseer-findings.js +1 -1
- package/lib/peers.d.ts +123 -1
- package/lib/peers.js +1 -1
- package/lib/static-checks.d.ts +14 -0
- package/lib/static-checks.js +1 -1
- package/lib/team.d.ts +35 -0
- package/package.json +1 -1
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { CanvasBinding, CanvasContract, CanvasDataMarks, CanvasGetDecl, CanvasHealthState, CanvasProblem, CanvasRecord, CanvasRenderError, CanvasShape } from './canvas.js';
|
|
2
|
+
/**
|
|
3
|
+
* The person editing a canvas in the dashboard (planning/canvas §10 «Editing», issues canvas-12): the detail page edits
|
|
4
|
+
* the MDX, the data and the shape; each pause in typing is checked by the dashboard's server — the checker's refusals
|
|
5
|
+
* with their line, column and hint, the shape and the data the same way an agent's write is — and the candidate is
|
|
6
|
+
* compiled and drawn in the frame as a preview. Saving makes a version authored by the person, through the same write
|
|
7
|
+
* as an agent's (`writeCanvas`), with the same promotion check and fallback; only the person (their browser, signed in)
|
|
8
|
+
* saves, and only on a canvas this project may write.
|
|
9
|
+
*
|
|
10
|
+
* GET /api/canvases/<id>/edit DashCanvasEditBase — what the editor opens with
|
|
11
|
+
* POST /api/canvases/<id>/check DashCanvasCheckInput → DashCanvasCheck
|
|
12
|
+
* POST /api/canvases/<id>/edit DashCanvasEditInput → DashCanvasEditResult
|
|
13
|
+
*/
|
|
14
|
+
/** The three parts the person edits; a problem names the one it is in. */
|
|
15
|
+
export type CanvasEditPart = 'mdx' | 'data' | 'shape';
|
|
16
|
+
/** What the editor opens with: the version a write builds on (the newest written), its MDX, data and shape. */
|
|
17
|
+
export interface DashCanvasEditBase {
|
|
18
|
+
/** The version the editor edits (`latest`): a save is refused when another was written since. */
|
|
19
|
+
version: number;
|
|
20
|
+
current: number;
|
|
21
|
+
mdx: string;
|
|
22
|
+
/** The data a save without data keeps, as JSON text (two-space indent). */
|
|
23
|
+
data: string;
|
|
24
|
+
/** Its shape, as JSON text — without `derived`. */
|
|
25
|
+
shape: string;
|
|
26
|
+
/** The shape was derived from the components and the data: it stays derived unless the person edits it. */
|
|
27
|
+
shapeDerived: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A candidate, as typed: each part sent only when the person changed it (left out, the base's is kept). Data and shape
|
|
31
|
+
* are JSON TEXT, so a syntax error is named by its line and column.
|
|
32
|
+
*/
|
|
33
|
+
export interface DashCanvasCheckInput {
|
|
34
|
+
mdx?: string;
|
|
35
|
+
data?: string;
|
|
36
|
+
shape?: string;
|
|
37
|
+
/** The version the editor started from. */
|
|
38
|
+
ifVersion: number;
|
|
39
|
+
}
|
|
40
|
+
export interface DashCanvasEditInput extends DashCanvasCheckInput {
|
|
41
|
+
/** Why — optional for the person. */
|
|
42
|
+
note?: string;
|
|
43
|
+
requestId?: string;
|
|
44
|
+
}
|
|
45
|
+
/** A refusal or a warning where the person typed it: its part, line and column, and how to fix it. */
|
|
46
|
+
export type CanvasEditProblem = CanvasProblem & {
|
|
47
|
+
part?: CanvasEditPart;
|
|
48
|
+
};
|
|
49
|
+
/** The candidate as it would be written — what the preview draws. */
|
|
50
|
+
export interface DashCanvasCandidate {
|
|
51
|
+
/** The number it would get. */
|
|
52
|
+
version: number;
|
|
53
|
+
source: string;
|
|
54
|
+
contract: CanvasContract;
|
|
55
|
+
bindings: CanvasBinding[];
|
|
56
|
+
gets: CanvasGetDecl[];
|
|
57
|
+
shape: CanvasShape;
|
|
58
|
+
shapeDerived: boolean;
|
|
59
|
+
data: unknown;
|
|
60
|
+
marks: CanvasDataMarks;
|
|
61
|
+
/** Compiled by the dashboard, as a saved version is. */
|
|
62
|
+
code: string;
|
|
63
|
+
compiler: string;
|
|
64
|
+
format: number;
|
|
65
|
+
/** Answer keys this version would make stale (a question reworded) or orphaned (a question gone). */
|
|
66
|
+
stale: string[];
|
|
67
|
+
orphaned: string[];
|
|
68
|
+
}
|
|
69
|
+
export interface DashCanvasCheck {
|
|
70
|
+
/** Nothing refuses it: saving would write it. */
|
|
71
|
+
ok: boolean;
|
|
72
|
+
problems: CanvasEditProblem[];
|
|
73
|
+
candidate?: DashCanvasCandidate;
|
|
74
|
+
/** Another version was written since the editor opened (an agent's, or another tab's): the newest now. */
|
|
75
|
+
conflict?: {
|
|
76
|
+
latest: number;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export interface DashCanvasEditResult {
|
|
80
|
+
canvas: CanvasRecord;
|
|
81
|
+
/** The version written. */
|
|
82
|
+
version: number;
|
|
83
|
+
/** It is the one shown now: it rendered `good`, or no render could judge it (`unverified`, the first view decides). */
|
|
84
|
+
promoted: boolean;
|
|
85
|
+
health: CanvasHealthState;
|
|
86
|
+
/** The promotion check (§4.1): a render, as for an agent's write. */
|
|
87
|
+
check?: {
|
|
88
|
+
ran: boolean;
|
|
89
|
+
health?: 'good' | 'broken';
|
|
90
|
+
errors?: CanvasRenderError[];
|
|
91
|
+
why?: string;
|
|
92
|
+
};
|
|
93
|
+
stale: string[];
|
|
94
|
+
/** Already written by the same request: this is the first answer. */
|
|
95
|
+
replayed: boolean;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* A JSON text read for the editor: its value, or where it stops being JSON (`line 4, column 9`). V8 names the position
|
|
99
|
+
* (`… at position 42`, and in newer releases the line and column too); the line and column are counted from it.
|
|
100
|
+
*/
|
|
101
|
+
export declare function parseCanvasJsonText(text: string, part: CanvasEditPart): {
|
|
102
|
+
ok: true;
|
|
103
|
+
value: unknown;
|
|
104
|
+
} | {
|
|
105
|
+
ok: false;
|
|
106
|
+
problem: CanvasEditProblem;
|
|
107
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"use strict";var d=Object.defineProperty;var l=(e,n)=>d(e,"name",{value:n,configurable:!0});var u=Object.defineProperty,p=l((e,n)=>u(e,"name",{value:n,configurable:!0}),"c");export function parseCanvasJsonText(e,n){try{return{ok:!0,value:JSON.parse(e)}}catch(r){const a=r instanceof Error?r.message:String(r),i=/\(line (\d+) column (\d+)\)/.exec(a),c=/position (\d+)/.exec(a);let s,o;if(i)s=Number(i[1]),o=Number(i[2]);else if(c){const t=e.slice(0,Number(c[1]));s=t.split(`
|
|
2
|
+
`).length,o=t.length-t.lastIndexOf(`
|
|
3
|
+
`)}else if(/end of JSON input/i.test(a)){const t=e.split(`
|
|
4
|
+
`);s=t.length,o=(t[t.length-1]?.length??0)+1}const m=a.replace(/^SyntaxError:\s*/,"").replace(/\s*\(line \d+ column \d+\)/,"").replace(/,? ?"[^"]{40,}"? is not valid JSON/," is not valid JSON");return{ok:!1,problem:{code:"json",severity:"error",part:n,message:`The ${n} is not JSON: ${m}`,hint:n==="data"?"Data is one JSON value: quote keys and strings, no trailing commas, no comments.":"A shape is a JSON object: quote keys and strings, no trailing commas, no comments.",...s!==void 0?{line:s}:{},...o!==void 0?{column:o}:{}}}}}l(parseCanvasJsonText,"parseCanvasJsonText"),p(parseCanvasJsonText,"parseCanvasJsonText");
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the canvas frame host serves, and under which policy (planning/canvas §2.2) — one rule for its two servers:
|
|
3
|
+
* a dashboard answering `http://lensmcp.canvas.localhost:<its port>` by its `Host` header (servers/lensmcp-mcp
|
|
4
|
+
* `dashboard/canvas-frame-host.ts`), and the gateway answering `https://lensmcp.canvas.localhost` on its front door
|
|
5
|
+
* (`@lensmcp/cluster` `runtime/frame-host.ts`, a copy its spec holds equal — the published gateway does not depend on
|
|
6
|
+
* this package at runtime).
|
|
7
|
+
*/
|
|
8
|
+
/** A file of the frame: at its top, or one level down (`media/` fonts, `chunks/`) — never `..`, never a hidden file. */
|
|
9
|
+
export declare const CANVAS_FRAME_FILE: RegExp;
|
|
10
|
+
export declare const CANVAS_FRAME_TYPES: Readonly<Record<string, string>>;
|
|
11
|
+
/**
|
|
12
|
+
* The dashboards a frame may sit in (`frame-ancestors`): this machine's names, and the gateway's on any front-door port —
|
|
13
|
+
* `lensmcp.localhost` and its subdomains, and `lensmcp.local` through the host move's compatibility window.
|
|
14
|
+
*/
|
|
15
|
+
export declare const CANVAS_FRAME_ANCESTORS = "http://localhost:* http://127.0.0.1:* https://lensmcp.localhost:* https://*.lensmcp.localhost:* https://lensmcp.local:*";
|
|
16
|
+
/**
|
|
17
|
+
* The policy of `host.html` — and so of the inner frame, which inherits it (§2.2). Host-sources stay explicit (Firefox bug
|
|
18
|
+
* 1819006). `ancestors`: a canvas hub's frame domain names the teammates' dashboards it may sit in (§6 «Teammates»).
|
|
19
|
+
*/
|
|
20
|
+
export declare function canvasFrameCsp(origin: string, ancestors?: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=Object.defineProperty;var n=(s,t)=>e(s,"name",{value:t,configurable:!0});var a=Object.defineProperty,o=n((s,t)=>a(s,"name",{value:t,configurable:!0}),"n");export const CANVAS_FRAME_FILE=/^(?:(?:media|chunks)\/)?[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)*\.(html|js|css|woff2|woff|map|svg)$/,CANVAS_FRAME_TYPES={html:"text/html; charset=utf-8",js:"application/javascript; charset=utf-8",css:"text/css; charset=utf-8",woff2:"font/woff2",woff:"font/woff",map:"application/json",svg:"image/svg+xml"},CANVAS_FRAME_ANCESTORS="http://localhost:* http://127.0.0.1:* https://lensmcp.localhost:* https://*.lensmcp.localhost:* https://lensmcp.local:*";export function canvasFrameCsp(s,t=CANVAS_FRAME_ANCESTORS){return["default-src 'none'",`script-src ${s} 'unsafe-eval'`,`style-src ${s} 'unsafe-inline'`,`font-src ${s}`,"img-src data: blob:","connect-src 'none'","frame-src 'none'","form-action 'none'","base-uri 'none'","object-src 'none'","worker-src 'none'","manifest-src 'none'",`frame-ancestors ${t}`].join("; ")}n(canvasFrameCsp,"canvasFrameCsp"),o(canvasFrameCsp,"canvasFrameCsp");
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import type { CanvasActor, CanvasAnswer, CanvasComment, CanvasDataOp, CanvasGrant, CanvasHealth, CanvasKept, CanvasLedgerRow, CanvasRecord, CanvasVersion } from './canvas.js';
|
|
2
|
+
import type { CanvasAsset } from './canvas-attachments.js';
|
|
3
|
+
/**
|
|
4
|
+
* THE CANVAS HUB — canvases shared by teammates on different machines (planning/canvas/00-plan.md § 6 «Teammates»,
|
|
5
|
+
* phase 16; issues canvas-14). A self-hosted server (`lensmcp hub serve`) keeps the canvases a team shares in a canvas
|
|
6
|
+
* store of its own, and is their HOME: the one writer, the one that assigns `seq` (§6: one writer per canvas). Each
|
|
7
|
+
* teammate's LensMCP keeps a READ CACHE of them in its own `canvases.db` and FORWARDS every write — a version, a data
|
|
8
|
+
* patch, an answer, a comment — to the hub, signed in as the person (OAuth, an identity provider the hub names).
|
|
9
|
+
*
|
|
10
|
+
* - Projects match by normalised remote (`normaliseRemote`): `github.com/acme/shop` is one hub project, whatever each
|
|
11
|
+
* teammate's checkout is called or wherever it is.
|
|
12
|
+
* - People have OAuth identities, recorded in `by.person`; per-project ROLES say who reads, answers, writes, administers.
|
|
13
|
+
* - The hub serves canvas frames from its own user-content origin (`frameOrigin`), never `*.localhost`.
|
|
14
|
+
*
|
|
15
|
+
* This file is the wire contract between a LensMCP (its dashboard, its MCP server, its CLI) and a hub.
|
|
16
|
+
*/
|
|
17
|
+
/** Where every hub route lives: `<hub>/hub/v1/…`. */
|
|
18
|
+
export declare const CANVAS_HUB_API = "/hub/v1";
|
|
19
|
+
/** A person's roles on a hub project, lowest first: each holds the ones before it. */
|
|
20
|
+
export declare const CANVAS_HUB_ROLES: readonly ["read", "answer", "write", "admin"];
|
|
21
|
+
export type CanvasHubRole = (typeof CANVAS_HUB_ROLES)[number];
|
|
22
|
+
/** Whether `have` includes `need` (read < answer < write < admin). */
|
|
23
|
+
export declare function canvasHubRoleAtLeast(have: CanvasHubRole | undefined, need: CanvasHubRole): boolean;
|
|
24
|
+
export declare const isCanvasHubRole: (value: unknown) => value is CanvasHubRole;
|
|
25
|
+
/** `GET /hub/v1/info` — public: what a LensMCP needs to sign a person in and to frame the hub's canvases. */
|
|
26
|
+
export interface CanvasHubInfo {
|
|
27
|
+
/** The hub's name, as teammates read it («Acme canvases»). */
|
|
28
|
+
name: string;
|
|
29
|
+
/** Its public URL — what every link and every forwarded write names. */
|
|
30
|
+
url: string;
|
|
31
|
+
/** The LensMCP that serves it. */
|
|
32
|
+
version: string;
|
|
33
|
+
/** The identity provider people sign in with: authorization code + PKCE, a loopback redirect (RFC 8252). */
|
|
34
|
+
auth: {
|
|
35
|
+
issuer: string;
|
|
36
|
+
authorizationEndpoint: string;
|
|
37
|
+
tokenEndpoint: string;
|
|
38
|
+
/** A public client registered at the identity provider for LensMCP (no secret: a native app). */
|
|
39
|
+
clientId: string;
|
|
40
|
+
scopes: string[];
|
|
41
|
+
/** The audience the hub's tokens must carry (`aud`), asked for as `audience` and as `resource` (RFC 8707). */
|
|
42
|
+
audience: string;
|
|
43
|
+
};
|
|
44
|
+
/** The hub's own user-content origin, where its canvases' frames are served (planning/canvas § 2.2, § 6). */
|
|
45
|
+
frameOrigin: string;
|
|
46
|
+
/** The hub's session rules. */
|
|
47
|
+
rules: {
|
|
48
|
+
/** An answer counts as the person's own (confirmed) only within this long of their sign-in (`auth_time`). */
|
|
49
|
+
confirmMaxAgeSec: number;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/** A hub project: one normalised remote. */
|
|
53
|
+
export interface CanvasHubProject {
|
|
54
|
+
id: string;
|
|
55
|
+
remote: string;
|
|
56
|
+
name: string;
|
|
57
|
+
}
|
|
58
|
+
export interface CanvasHubProjectRole extends CanvasHubProject {
|
|
59
|
+
role: CanvasHubRole;
|
|
60
|
+
}
|
|
61
|
+
/** `GET /hub/v1/me` — who the token is, and their roles. */
|
|
62
|
+
export interface CanvasHubMe {
|
|
63
|
+
/** The identity the hub records in `by.person` (the email, else the subject). */
|
|
64
|
+
person: string;
|
|
65
|
+
name?: string;
|
|
66
|
+
email?: string;
|
|
67
|
+
/** A hub administrator (the hub's config): may make projects and give any role. */
|
|
68
|
+
admin: boolean;
|
|
69
|
+
projects: CanvasHubProjectRole[];
|
|
70
|
+
}
|
|
71
|
+
/** A canvas of a hub project, as listed for a cache to compare: its ledger head. */
|
|
72
|
+
export interface CanvasHubHead {
|
|
73
|
+
id: string;
|
|
74
|
+
title: string;
|
|
75
|
+
seq: number;
|
|
76
|
+
updatedAt: number;
|
|
77
|
+
deleted?: boolean;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* What a forwarded write says made it, besides the person its token names: an agent's session and client, or the
|
|
81
|
+
* person's own browser (`kind: person` — a confirmed answer still needs the hub's session rules, {@link CanvasHubInfo}).
|
|
82
|
+
*/
|
|
83
|
+
export interface CanvasHubOn {
|
|
84
|
+
kind: 'person' | 'agent';
|
|
85
|
+
client?: string;
|
|
86
|
+
session?: string;
|
|
87
|
+
name?: string;
|
|
88
|
+
machine: string;
|
|
89
|
+
}
|
|
90
|
+
/** A version as a home keeps it, with what a candidate's promotion needs. */
|
|
91
|
+
export interface CanvasHubVersion extends CanvasVersion {
|
|
92
|
+
intent: {
|
|
93
|
+
mode: 'keep' | 'whole';
|
|
94
|
+
} | {
|
|
95
|
+
mode: 'migrate';
|
|
96
|
+
ops: CanvasDataOp[];
|
|
97
|
+
};
|
|
98
|
+
shown: boolean;
|
|
99
|
+
questions: number;
|
|
100
|
+
}
|
|
101
|
+
export interface CanvasHubRevision {
|
|
102
|
+
rev: number;
|
|
103
|
+
version: number;
|
|
104
|
+
kind: string;
|
|
105
|
+
ops?: CanvasDataOp[];
|
|
106
|
+
merge?: unknown;
|
|
107
|
+
by: CanvasActor;
|
|
108
|
+
note?: string;
|
|
109
|
+
at: number;
|
|
110
|
+
compacted: boolean;
|
|
111
|
+
}
|
|
112
|
+
export interface CanvasHubCheckpoint {
|
|
113
|
+
rev: number;
|
|
114
|
+
version: number;
|
|
115
|
+
data?: unknown;
|
|
116
|
+
versionRef?: number;
|
|
117
|
+
at: number;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* One canvas, as its home hands it on: whole (`since: 0, have: 0, rev: 0` — what «Share with the team» sends the hub)
|
|
121
|
+
* or what changed after what a cache has — ledger rows after `since`, versions after `have` (a version never changes
|
|
122
|
+
* but its health), revisions and checkpoints after `rev`. The mutable rest — the record, every version's health, the
|
|
123
|
+
* working data, answers, comments, grants — always whole.
|
|
124
|
+
*/
|
|
125
|
+
export interface CanvasHubSnapshot {
|
|
126
|
+
format: 1;
|
|
127
|
+
canvas: CanvasRecord;
|
|
128
|
+
/** Bytes its versions take (the record's caps). */
|
|
129
|
+
bytes: number;
|
|
130
|
+
versions: CanvasHubVersion[];
|
|
131
|
+
health: Array<{
|
|
132
|
+
n: number;
|
|
133
|
+
health: CanvasHealth;
|
|
134
|
+
shown: boolean;
|
|
135
|
+
dataRev: number;
|
|
136
|
+
}>;
|
|
137
|
+
working: {
|
|
138
|
+
data: unknown;
|
|
139
|
+
dataRev: number;
|
|
140
|
+
version: number;
|
|
141
|
+
at: number;
|
|
142
|
+
};
|
|
143
|
+
answers: CanvasAnswer[];
|
|
144
|
+
comments: CanvasComment[];
|
|
145
|
+
grants: CanvasGrant[];
|
|
146
|
+
ledger: CanvasLedgerRow[];
|
|
147
|
+
revisions: CanvasHubRevision[];
|
|
148
|
+
checkpoints: CanvasHubCheckpoint[];
|
|
149
|
+
/**
|
|
150
|
+
* The files attached to its answers (canvas-11), every row whole — their bytes travel on their own
|
|
151
|
+
* (`GET|POST /hub/v1/canvases/:id/assets/:asset`). `stored`: the side that made the snapshot has the file.
|
|
152
|
+
*/
|
|
153
|
+
assets?: CanvasHubAsset[];
|
|
154
|
+
/**
|
|
155
|
+
* Kept snapshots of outside sites (§2.5), in a SHARE: the sharer's own — they read them, so they stay theirs at the
|
|
156
|
+
* hub. A hub's snapshot for a teammate carries `outside` instead.
|
|
157
|
+
*/
|
|
158
|
+
got?: CanvasKept[];
|
|
159
|
+
/**
|
|
160
|
+
* The asking teammate's OWN approvals of outside sites and the snapshots their dashboard kept (§2.5: each person
|
|
161
|
+
* approves for themselves; a kept snapshot belongs to the one who read it) — present when they differ from the
|
|
162
|
+
* `outside` mark the request named. A cache keeps these as its `grants` and `got`, and never another's.
|
|
163
|
+
*/
|
|
164
|
+
outside?: CanvasHubOutside;
|
|
165
|
+
/** What it was made after. */
|
|
166
|
+
since: number;
|
|
167
|
+
have: number;
|
|
168
|
+
rev: number;
|
|
169
|
+
}
|
|
170
|
+
/** An attachment as a snapshot carries it: its row, and whether the side that made the snapshot holds its bytes. */
|
|
171
|
+
export type CanvasHubAsset = CanvasAsset & {
|
|
172
|
+
stored: boolean;
|
|
173
|
+
};
|
|
174
|
+
/** One person's approvals of outside sites for one hub canvas, and the snapshots their dashboard kept of them. */
|
|
175
|
+
export interface CanvasHubOutside {
|
|
176
|
+
grants: CanvasGrant[];
|
|
177
|
+
got: CanvasKept[];
|
|
178
|
+
/** What both sides compare (`canvasOutsideMark`): the same mark, nothing to send. */
|
|
179
|
+
mark: string;
|
|
180
|
+
}
|
|
181
|
+
/** Where a canvas's home is, as a LensMCP store keeps a canvas it caches from a hub. */
|
|
182
|
+
export interface CanvasHubHome {
|
|
183
|
+
canvas: string;
|
|
184
|
+
/** The hub's URL. */
|
|
185
|
+
hub: string;
|
|
186
|
+
/** The hub's project id. */
|
|
187
|
+
hubProject: string;
|
|
188
|
+
/** The normalised remote both sides match by. */
|
|
189
|
+
remote: string;
|
|
190
|
+
/** The hub's ledger head this cache holds. */
|
|
191
|
+
seq: number;
|
|
192
|
+
syncedAt: number;
|
|
193
|
+
movedAt: number;
|
|
194
|
+
}
|
|
195
|
+
/** A refusal from the hub: `{ error, code }` with its HTTP status. */
|
|
196
|
+
export interface CanvasHubError {
|
|
197
|
+
error: string;
|
|
198
|
+
code: string;
|
|
199
|
+
}
|
|
200
|
+
/** The dashboard's view of the team hub for the project it serves (`GET /api/canvases/hub`). */
|
|
201
|
+
export interface DashCanvasHub {
|
|
202
|
+
/** A hub is set for this machine or this project (`lensmcp hub add <url>`). */
|
|
203
|
+
configured: boolean;
|
|
204
|
+
url?: string;
|
|
205
|
+
name?: string;
|
|
206
|
+
/** The person is signed in to it on this machine. */
|
|
207
|
+
signedIn: boolean;
|
|
208
|
+
person?: string;
|
|
209
|
+
personName?: string;
|
|
210
|
+
/** A sign-in started here and not finished yet: its authorize URL. */
|
|
211
|
+
signingIn?: string;
|
|
212
|
+
/** This project's normalised remote: what the hub matches it by. None: it has no git remote. */
|
|
213
|
+
remote?: string;
|
|
214
|
+
/** The hub's project for it, and the person's role there. */
|
|
215
|
+
project?: CanvasHubProjectRole;
|
|
216
|
+
frameOrigin?: string;
|
|
217
|
+
/** When this machine last read the hub. */
|
|
218
|
+
syncedAt?: number;
|
|
219
|
+
/** Why the hub could not be read (offline, signed out, no role). */
|
|
220
|
+
error?: string;
|
|
221
|
+
}
|
|
222
|
+
/** A hub canvas on a list or a detail: where it lives, and what the person may do there. */
|
|
223
|
+
export interface DashCanvasHubOf {
|
|
224
|
+
url: string;
|
|
225
|
+
name: string;
|
|
226
|
+
role?: CanvasHubRole;
|
|
227
|
+
signedIn: boolean;
|
|
228
|
+
person?: string;
|
|
229
|
+
syncedAt: number;
|
|
230
|
+
error?: string;
|
|
231
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var r=Object.defineProperty;var a=(e,t)=>r(e,"name",{value:t,configurable:!0});var s=Object.defineProperty,n=a((e,t)=>s(e,"name",{value:t,configurable:!0}),"t");export const CANVAS_HUB_API="/hub/v1",CANVAS_HUB_ROLES=["read","answer","write","admin"];export function canvasHubRoleAtLeast(e,t){return e?CANVAS_HUB_ROLES.indexOf(e)>=CANVAS_HUB_ROLES.indexOf(t):!1}a(canvasHubRoleAtLeast,"canvasHubRoleAtLeast"),n(canvasHubRoleAtLeast,"canvasHubRoleAtLeast");export const isCanvasHubRole=n(e=>typeof e=="string"&&CANVAS_HUB_ROLES.includes(e),"isCanvasHubRole");
|
package/lib/canvas.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { type CanvasAsset } from './canvas-attachments.js';
|
|
3
|
+
import type { DashCanvasHubOf } from './canvas-hub.js';
|
|
2
4
|
/**
|
|
3
5
|
* Canvases (planning/canvas/00-plan.md): what any agent — Claude Code, Codex, a team agent — shows the person, and what
|
|
4
6
|
* the person answers, kept by LensMCP rather than by one client's artifacts.
|
|
@@ -44,6 +46,7 @@ export declare const CANVAS_LIMITS: {
|
|
|
44
46
|
/** One answer's value and note. */
|
|
45
47
|
readonly answerBytes: number;
|
|
46
48
|
readonly questions: 500;
|
|
49
|
+
/** Attachments (canvas-11): TaskArtifact's caps — 50 files, 100 MB together, 10 MB each. */
|
|
47
50
|
readonly assets: 50;
|
|
48
51
|
readonly assetBytes: number;
|
|
49
52
|
readonly assetFileBytes: number;
|
|
@@ -81,8 +84,14 @@ export interface CanvasActor {
|
|
|
81
84
|
kind: 'agent' | 'person' | 'system';
|
|
82
85
|
/** `claude`, `codex`, `mcp`, `dashboard`, `cli`, `host:<name>`. */
|
|
83
86
|
client?: string;
|
|
84
|
-
/** The MCP session, the coordination session, or the dashboard's per-sign-in session id. */
|
|
87
|
+
/** The MCP session, the coordination session, or the dashboard's per-sign-in session id (`sid-<id>`, D8). */
|
|
85
88
|
session?: string;
|
|
89
|
+
/**
|
|
90
|
+
* A person on the dashboard: how the request was signed in (D8). `session` — a per-sign-in cookie, the only one a
|
|
91
|
+
* confirmed answer is given with; `machine` — the machine-wide cookie from before it (`session` is then `ck-<digest>`):
|
|
92
|
+
* signed in, but its answers are reported until the browser signs in again; `none` — a Bearer, a token, no cookie.
|
|
93
|
+
*/
|
|
94
|
+
signIn?: 'session' | 'machine' | 'none';
|
|
86
95
|
/** A team agent's role or name, as the person reads it. */
|
|
87
96
|
name?: string;
|
|
88
97
|
/** An `ac-…` account. */
|
|
@@ -127,9 +136,9 @@ export interface CanvasAsk {
|
|
|
127
136
|
items?: CanvasOption[];
|
|
128
137
|
/** An option id. */
|
|
129
138
|
recommended?: string;
|
|
130
|
-
/**
|
|
139
|
+
/** Holds the linked task — no one claims it until it is answered (`waitingOn`) — and lands in the Inbox (§7). */
|
|
131
140
|
blocking?: boolean;
|
|
132
|
-
/** Lands in Team › Inbox (§7). */
|
|
141
|
+
/** Lands in Team › Inbox, routed to the goal's manager first, then the person (§7). */
|
|
133
142
|
inbox?: boolean;
|
|
134
143
|
required?: boolean;
|
|
135
144
|
min?: number;
|
|
@@ -381,7 +390,7 @@ export interface CanvasAnswer {
|
|
|
381
390
|
/** For stale: the version that changed the question. */
|
|
382
391
|
changedIn?: number;
|
|
383
392
|
}
|
|
384
|
-
export declare const CANVAS_LEDGER_PARTS: readonly ["version", "data", "answer", "got", "grant", "share", "archive", "delete", "comment", "health", "meta"];
|
|
393
|
+
export declare const CANVAS_LEDGER_PARTS: readonly ["version", "data", "answer", "got", "grant", "share", "archive", "delete", "comment", "health", "meta", "asset"];
|
|
385
394
|
export type CanvasLedgerPart = (typeof CANVAS_LEDGER_PARTS)[number];
|
|
386
395
|
/** One row per change (§3.4). `seq` is assigned by the home store only. */
|
|
387
396
|
export interface CanvasLedgerRow {
|
|
@@ -440,6 +449,10 @@ export interface CanvasComment {
|
|
|
440
449
|
note?: string;
|
|
441
450
|
};
|
|
442
451
|
}
|
|
452
|
+
/**
|
|
453
|
+
* The person's approval of one outside origin for one canvas (§2.5): exact (`https://api.github.com`), revocable, made
|
|
454
|
+
* only from the person's own browser — never by an agent, never by a reported answer.
|
|
455
|
+
*/
|
|
443
456
|
export interface CanvasGrant {
|
|
444
457
|
canvas: string;
|
|
445
458
|
origin: string;
|
|
@@ -450,6 +463,43 @@ export interface CanvasGrant {
|
|
|
450
463
|
by: CanvasActor;
|
|
451
464
|
};
|
|
452
465
|
}
|
|
466
|
+
/**
|
|
467
|
+
* An `https:` get's result kept as a snapshot in the canvas's own `got` part (§2.5) — never in the agent's data. What
|
|
468
|
+
* the person's view read from the site, so a render and a health re-check draw what the person saw, never live.
|
|
469
|
+
*/
|
|
470
|
+
export interface CanvasKept {
|
|
471
|
+
canvas: string;
|
|
472
|
+
uri: string;
|
|
473
|
+
origin: string;
|
|
474
|
+
value: unknown;
|
|
475
|
+
/** When the dashboard last read this value from the site. */
|
|
476
|
+
at: number;
|
|
477
|
+
/** When it was first kept as it is: an answer that changed is a new snapshot, and a ledger row. */
|
|
478
|
+
since: number;
|
|
479
|
+
bytes: number;
|
|
480
|
+
}
|
|
481
|
+
/** What the dashboard's own fetch of an outside site holds to (§2.5). */
|
|
482
|
+
export declare const CANVAS_OUTSIDE: {
|
|
483
|
+
/** The whole fetch, every redirect hop included. */
|
|
484
|
+
readonly timeoutMs: 10000;
|
|
485
|
+
/** The answer, after decompression. */
|
|
486
|
+
readonly maxBytes: number;
|
|
487
|
+
readonly redirects: 5;
|
|
488
|
+
/** Fetches in a minute, per canvas and per origin (across canvases). */
|
|
489
|
+
readonly perCanvasPerMinute: 30;
|
|
490
|
+
readonly perOriginPerMinute: 60;
|
|
491
|
+
/** Snapshots kept per canvas, and their bytes in all. */
|
|
492
|
+
readonly keptPerCanvas: 20;
|
|
493
|
+
readonly keptBytesPerCanvas: number;
|
|
494
|
+
};
|
|
495
|
+
/** The approval prompt's first line (§2.5): a granted origin is also a way out, so it says so. */
|
|
496
|
+
export declare function canvasGrantWords(origin: string): string;
|
|
497
|
+
/** The whole approval prompt the rail shows for `origin`. */
|
|
498
|
+
export declare function canvasGrantPrompt(origin: string): {
|
|
499
|
+
title: string;
|
|
500
|
+
lines: string[];
|
|
501
|
+
act: string;
|
|
502
|
+
};
|
|
453
503
|
export interface CanvasDataChange {
|
|
454
504
|
path: string;
|
|
455
505
|
change: 'added' | 'removed' | 'changed';
|
|
@@ -542,7 +592,7 @@ export type CanvasSafeBlock = {
|
|
|
542
592
|
/** Which tier the person sees (§4.3). */
|
|
543
593
|
export type CanvasTier = 1 | 2 | 3;
|
|
544
594
|
/** Every method the port carries; anything else is method-not-found. Names follow MCP Apps (SEP-1865). */
|
|
545
|
-
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"];
|
|
595
|
+
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"];
|
|
546
596
|
export type CanvasBrokerMethod = (typeof CANVAS_BROKER_METHODS)[number];
|
|
547
597
|
/** A JSON-RPC 2.0 message on the port: a request has an `id`, a notification none. */
|
|
548
598
|
export interface CanvasRpc<P = unknown> {
|
|
@@ -585,6 +635,7 @@ export interface CanvasFrameInit {
|
|
|
585
635
|
fallback?: boolean;
|
|
586
636
|
dir?: 'ltr' | 'rtl' | 'auto';
|
|
587
637
|
}
|
|
638
|
+
/** A get's result. `kept`: read from the canvas's kept snapshot (a render's only `https:` source), `at` when it was read from the site. */
|
|
588
639
|
export type CanvasGotResult = {
|
|
589
640
|
ok: true;
|
|
590
641
|
value: unknown;
|
|
@@ -594,6 +645,46 @@ export type CanvasGotResult = {
|
|
|
594
645
|
ok: false;
|
|
595
646
|
reason: string;
|
|
596
647
|
};
|
|
648
|
+
/** The MIME type of an MCP Apps UI resource (SEP-1865): an HTML page a host renders in its sandbox. */
|
|
649
|
+
export declare const CANVAS_APP_MIME = "text/html;profile=mcp-app";
|
|
650
|
+
/** One canvas as an MCP Apps page: the runtime with the canvas written in. */
|
|
651
|
+
export declare const CANVAS_APP_URI_TEMPLATE = "ui://canvas/{id}";
|
|
652
|
+
export declare const canvasAppUri: (id: string) => string;
|
|
653
|
+
/**
|
|
654
|
+
* The page `canvas_get` and `canvas_write` name as their UI (`_meta.ui.resourceUri`): the same runtime with no canvas
|
|
655
|
+
* in it — a host renders it beside the call, and it reads the canvas the call answered about (`ui://canvas/<id>`).
|
|
656
|
+
*/
|
|
657
|
+
export declare const CANVAS_APP_VIEW_URI = "ui://canvas/view";
|
|
658
|
+
/** The tool a hosted page answers through: app-only (`_meta.ui.visibility: ["app"]`), recorded REPORTED. */
|
|
659
|
+
export declare const CANVAS_ANSWER_TOOL = "canvas_answer";
|
|
660
|
+
/** The page's own protocol, in its payload. */
|
|
661
|
+
export declare const CANVAS_APP_PROTOCOL = 1;
|
|
662
|
+
/**
|
|
663
|
+
* What an MCP Apps page carries (`<script type="application/json" id="lensmcp-canvas">`): the frame init, as the
|
|
664
|
+
* dashboard builds it (confirmed answers only), and what the page shows around it. The host has no dashboard session,
|
|
665
|
+
* so an answer given in the page is REPORTED (`via: host:<name>`) until the person confirms it in the dashboard.
|
|
666
|
+
*/
|
|
667
|
+
export interface CanvasAppPayload {
|
|
668
|
+
app: number;
|
|
669
|
+
canvas: {
|
|
670
|
+
id: string;
|
|
671
|
+
title: string;
|
|
672
|
+
version: number;
|
|
673
|
+
project: string;
|
|
674
|
+
url?: string;
|
|
675
|
+
};
|
|
676
|
+
init: CanvasFrameInit;
|
|
677
|
+
/** Reported answers newer than the key's confirmed one: shown under their question, never acted on. */
|
|
678
|
+
reported: Array<{
|
|
679
|
+
key: string;
|
|
680
|
+
value: unknown;
|
|
681
|
+
via: string;
|
|
682
|
+
at: number;
|
|
683
|
+
}>;
|
|
684
|
+
/** Whether the page has mermaid written in (`<script id="lensmcp-mermaid">`): only a canvas with a diagram does. */
|
|
685
|
+
mermaid: boolean;
|
|
686
|
+
answerTool: string;
|
|
687
|
+
}
|
|
597
688
|
/**
|
|
598
689
|
* The confirmed answers that stand (state `current`), the newest per key — what the frame's `props.answers` is, what
|
|
599
690
|
* `When` reads, and the only answers agents act on (§2.4).
|
|
@@ -691,11 +782,11 @@ export declare const CANVAS_FRAME_PARAMS: {
|
|
|
691
782
|
readonly 'canvas/download': z.ZodObject<{
|
|
692
783
|
name: z.ZodString;
|
|
693
784
|
type: z.ZodEnum<{
|
|
694
|
-
csv: "csv";
|
|
695
|
-
json: "json";
|
|
696
785
|
png: "png";
|
|
786
|
+
json: "json";
|
|
697
787
|
txt: "txt";
|
|
698
788
|
md: "md";
|
|
789
|
+
csv: "csv";
|
|
699
790
|
}>;
|
|
700
791
|
text: z.ZodString;
|
|
701
792
|
}, z.core.$strip>;
|
|
@@ -709,6 +800,8 @@ export declare const CANVAS_FRAME_PARAMS: {
|
|
|
709
800
|
id: z.ZodString;
|
|
710
801
|
line: z.ZodOptional<z.ZodNumber>;
|
|
711
802
|
}, z.core.$strip>;
|
|
803
|
+
/** Escape pressed in the document: the page around it acts on it as its own (issues/closed/canvas-20). */
|
|
804
|
+
readonly 'canvas/escape': z.ZodObject<{}, z.core.$strip>;
|
|
712
805
|
};
|
|
713
806
|
/**
|
|
714
807
|
* The height a question's slot starts at, before the parent measured its control (`canvas/slot-sizes` then tells the
|
|
@@ -744,6 +837,8 @@ export interface DashCanvasRow {
|
|
|
744
837
|
shared: boolean;
|
|
745
838
|
/** Homed by another project, shared to this one. */
|
|
746
839
|
foreign: boolean;
|
|
840
|
+
/** Its home is a team hub (§6 teammates): this list shows the read cache. */
|
|
841
|
+
hub?: DashCanvasHubOf;
|
|
747
842
|
updatedAt: number;
|
|
748
843
|
createdAt: number;
|
|
749
844
|
}
|
|
@@ -765,6 +860,26 @@ export interface DashCanvasInboxQuestion {
|
|
|
765
860
|
askedAt: number;
|
|
766
861
|
/** Homed by another project, shared to this one. */
|
|
767
862
|
foreign: boolean;
|
|
863
|
+
/** Where it is in the team (§7): with its goal's manager first, or with the person. */
|
|
864
|
+
route?: CanvasQuestionRoute;
|
|
865
|
+
}
|
|
866
|
+
/**
|
|
867
|
+
* Where a canvas question asked with `inbox` or `blocking` is in the team (§7, planning/team/09): the coordination store
|
|
868
|
+
* derives a team question from it and routes it as an agent's — its goal's manager first, the person when no manager
|
|
869
|
+
* takes it or the manager's session ends or 30 minutes pass. `task-done`: every task it links ended — the Inbox row is
|
|
870
|
+
* withdrawn, and the question stays open on the canvas, «its task is done».
|
|
871
|
+
*/
|
|
872
|
+
export interface CanvasQuestionRoute {
|
|
873
|
+
qid: string;
|
|
874
|
+
/** The derived team question (`q-…`). */
|
|
875
|
+
question?: string;
|
|
876
|
+
state: 'manager' | 'person' | 'task-done';
|
|
877
|
+
/** The manager it is with. */
|
|
878
|
+
toName?: string;
|
|
879
|
+
/** Why it is the person's: no manager on the team, escalated by its manager, its manager's session ended, … */
|
|
880
|
+
why?: string;
|
|
881
|
+
/** While with a manager: when it goes to the person by itself (Q-D4). */
|
|
882
|
+
escalatesAt?: number;
|
|
768
883
|
}
|
|
769
884
|
export interface DashCanvasInbox {
|
|
770
885
|
questions: DashCanvasInboxQuestion[];
|
|
@@ -810,14 +925,30 @@ export interface DashCanvasDetail {
|
|
|
810
925
|
frameOrigin: string;
|
|
811
926
|
/** May the person answer here (a worker Mac's read-only board: «answer on the organizer»). */
|
|
812
927
|
canAnswer: boolean;
|
|
813
|
-
/**
|
|
928
|
+
/** May the person edit it here (canvas-12): this view may answer, and this project may write the canvas (its home or share.write). */
|
|
929
|
+
canEdit?: boolean;
|
|
930
|
+
/** Gets the version uses, and what each resolves to now. An `https:` one names its origin and its kept snapshot. */
|
|
814
931
|
gets: Array<CanvasGetDecl & {
|
|
815
932
|
allowed: boolean;
|
|
816
933
|
why?: string;
|
|
934
|
+
origin?: string;
|
|
935
|
+
kept?: {
|
|
936
|
+
at: number;
|
|
937
|
+
since: number;
|
|
938
|
+
bytes: number;
|
|
939
|
+
};
|
|
817
940
|
}>;
|
|
941
|
+
/** The person's approvals of outside origins (§2.5), standing and revoked. */
|
|
942
|
+
grants: CanvasGrant[];
|
|
818
943
|
comments: CanvasComment[];
|
|
819
944
|
/** The ledger's head. */
|
|
820
945
|
seq: number;
|
|
946
|
+
/** Where its open questions asked with `inbox` or `blocking` are in the team (§7) — «its task is done» among them. */
|
|
947
|
+
routes?: CanvasQuestionRoute[];
|
|
948
|
+
/** The files the person attached to answers (canvas-11): what a file or image answer's `asset` names. */
|
|
949
|
+
assets?: CanvasAsset[];
|
|
950
|
+
/** Its home is a team hub (§6 teammates): writes go there, this is the read cache. */
|
|
951
|
+
hub?: DashCanvasHubOf;
|
|
821
952
|
}
|
|
822
953
|
export interface DashCanvasCompiled {
|
|
823
954
|
canvas: string;
|
|
@@ -843,6 +974,16 @@ export interface DashCanvasAnswerResult {
|
|
|
843
974
|
answer?: CanvasAnswer;
|
|
844
975
|
answers: CanvasAnswer[];
|
|
845
976
|
seq: number;
|
|
977
|
+
/** The person's own browser answered, and it was recorded reported: why, in words to show them (D8: sign in again). */
|
|
978
|
+
reported?: string;
|
|
979
|
+
}
|
|
980
|
+
/** `POST /api/canvases/<id>/grants`: approve (the person's browser only) or revoke one outside origin (§2.5). */
|
|
981
|
+
export interface DashCanvasGrantInput {
|
|
982
|
+
origin: string;
|
|
983
|
+
grant: boolean;
|
|
984
|
+
}
|
|
985
|
+
export interface DashCanvasGrantResult {
|
|
986
|
+
grants: CanvasGrant[];
|
|
846
987
|
}
|
|
847
988
|
export interface DashCanvasHealthInput {
|
|
848
989
|
version: number;
|