visualproof 0.4.3 → 0.5.0

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.
Files changed (82) hide show
  1. package/README.md +16 -7
  2. package/dist/assets/latex/visualproof.sty +19 -9
  3. package/dist/assets/tips/tour-agent.webp +0 -0
  4. package/dist/assets/tips/tour-arrange.webp +0 -0
  5. package/dist/assets/tips/tour-artwork.webp +0 -0
  6. package/dist/assets/tips/tour-checks.webp +0 -0
  7. package/dist/assets/tips/tour-keys.webp +0 -0
  8. package/dist/assets/tips/tour-library.webp +0 -0
  9. package/dist/assets/tips/tour-project.webp +0 -0
  10. package/dist/assets/tips/tour-review.webp +0 -0
  11. package/dist/assets/tips/tour-share.webp +0 -0
  12. package/dist/assets/tips/tour-source.webp +0 -0
  13. package/dist/assets/tips/tour-target.webp +0 -0
  14. package/dist/assets/tips/tour-view.webp +0 -0
  15. package/dist/assets/tips/tour.json +117 -112
  16. package/dist/assets/tips/tour.webp +0 -0
  17. package/dist/mcp/visualproof-mcp.mjs +7 -3
  18. package/dist/server/access.js +37 -1
  19. package/dist/server/accesspage.js +130 -0
  20. package/dist/server/agent.js +11 -5
  21. package/dist/server/agentlibrary.js +1 -1
  22. package/dist/server/agentviews.js +1 -1
  23. package/dist/server/artcmd.js +1 -1
  24. package/dist/server/askfollow.js +1 -4
  25. package/dist/server/buildwatch.js +133 -0
  26. package/dist/server/deploy.js +844 -0
  27. package/dist/server/doctor.js +15 -3
  28. package/dist/server/events.js +20 -5
  29. package/dist/server/export.js +17 -4
  30. package/dist/server/fetchurl.js +30 -13
  31. package/dist/server/film.js +1 -1
  32. package/dist/server/history.js +3 -1
  33. package/dist/server/historyapi.js +100 -50
  34. package/dist/server/historythread.js +206 -0
  35. package/dist/server/hover.js +8 -0
  36. package/dist/server/identity.js +25 -1
  37. package/dist/server/library.js +10 -3
  38. package/dist/server/live.js +206 -28
  39. package/dist/server/lostfound.js +3 -2
  40. package/dist/server/main.js +361 -50
  41. package/dist/server/poppler.js +48 -10
  42. package/dist/server/renames.js +10 -5
  43. package/dist/server/review.js +32 -2
  44. package/dist/server/reviewapi.js +1 -1
  45. package/dist/server/status.js +144 -50
  46. package/dist/server/talk.js +7 -2
  47. package/dist/server/usage.js +51 -0
  48. package/dist/server/views.js +21 -7
  49. package/dist/shared/board.js +2 -1
  50. package/dist/shared/collab.js +14 -8
  51. package/dist/shared/deploy.js +35 -0
  52. package/dist/shared/doc/latex.js +5 -3
  53. package/dist/shared/doc/outline.js +6 -3
  54. package/dist/shared/layout.js +297 -70
  55. package/dist/shared/libm.js +366 -0
  56. package/dist/shared/library.js +11 -6
  57. package/dist/shared/palette.js +1 -1
  58. package/dist/shared/review.js +7 -5
  59. package/dist/shared/search.js +7 -3
  60. package/dist/shared/separate.js +556 -32
  61. package/dist/shared/views.js +8 -1
  62. package/dist/web/bundle/app.js +3595 -1520
  63. package/dist/web/bundle/edges.js +44 -16
  64. package/dist/web/bundle/layout.js +1026 -80
  65. package/dist/web/index.html +2 -2
  66. package/dist/web/src/artwork.js +25 -4
  67. package/dist/web/src/axiomring.js +42 -0
  68. package/dist/web/src/bundles.js +52 -16
  69. package/dist/web/src/canvas.js +109 -54
  70. package/dist/web/src/overview.js +4 -1
  71. package/dist/web/src/past.js +28 -0
  72. package/dist/web/src/scene.js +13 -12
  73. package/dist/web/src/selection.js +47 -4
  74. package/dist/web/src/status.js +32 -2
  75. package/dist/web/src/theme.js +108 -0
  76. package/dist/web/style.css +181 -45
  77. package/docs/agent-api/following.md +1 -1
  78. package/docs/agent-api/history.md +3 -0
  79. package/docs/agent-api/library.md +1 -1
  80. package/docs/agent-api/requests.md +4 -1
  81. package/docs/agent-api/views.md +1 -1
  82. package/package.json +1 -1
package/README.md CHANGED
@@ -19,7 +19,12 @@ https://github.com/user-attachments/assets/98e435d6-f493-437d-b342-1833819c0b77
19
19
 
20
20
  ## Try it
21
21
 
22
- Set up in your Lean codebase with agent prompt:
22
+ Set it up for your team with an agent prompt, following your project's GitHub repository:
23
+ ```text
24
+ Deploy VisualProof (https://github.com/LucianoXu/VisualProof) for my Lean project's GitHub repository, following its main branch, and give me the address to open.
25
+ ```
26
+
27
+ Or on your own machine, for the code you are editing:
23
28
  ```text
24
29
  Set up VisualProof (https://github.com/LucianoXu/VisualProof) for my Lean project, and give me the address to open.
25
30
  ```
@@ -33,13 +38,16 @@ What the agent does, step by step: [A poster from the command line](docs/MANUAL.
33
38
  Set up manually:
34
39
  ```bash
35
40
  npm install --global visualproof
36
- cd my-lean-project && lake build
37
- visualproof serve .
41
+ visualproof serve https://github.com/<owner>/<repo>
38
42
  ```
43
+ It follows the repository's default branch and builds each new commit itself ([Following a
44
+ branch](docs/MANUAL.md#following-a-branch)). Or, for the code you are editing:
45
+ `cd my-lean-project && lake build && visualproof serve .`
39
46
 
40
- It needs Node, elan and Poppler ([Requirements](#requirements)). On the first visit the page offers
41
- a short tour of your own project; `?` holds the tips — a film of a review on Sphere-Packing-Lean in
42
- thirteen scenes, with captions, and a row for each thing it does not show — and every key.
47
+ It needs Node, elan and Poppler, and git to follow a branch ([Requirements](#requirements)). On the
48
+ first visit the page offers a short tour of your own project; `?` holds the tips — a film of a
49
+ review on Sphere-Packing-Lean in thirteen scenes, with captions, and a row for each thing it does not
50
+ show — and every key.
43
51
 
44
52
  ## See what a Lean theorem actually rests on
45
53
 
@@ -91,7 +99,8 @@ project's edge.
91
99
  - Optionally XeLaTeX, for the printed document.
92
100
 
93
101
  The project must have been built with `lake build`: VisualProof only reads what the build left,
94
- and never builds it.
102
+ and never builds it. A branch of a git repository it follows (`serve <git URL>`) it builds itself,
103
+ in a clone of its own, and needs git.
95
104
 
96
105
  ## Where it keeps things
97
106
 
@@ -208,31 +208,39 @@
208
208
  % what follows: a section of one declaration takes no page of its own. Its heading: the number and
209
209
  % the title, sans-serif and bold, smaller at each level; the cluster's key beneath, small and mono.
210
210
  % A top section names the running head, as LaTeX's own classes do.
211
+ % Headings that follow one another (a section, then its first subsection) ask for that room once,
212
+ % the first of them: until the first line after the last, nothing asks again (\vp@need) nor lets
213
+ % the page break (\vp@keep), as a subsection's own \needspace under its section's heading would
214
+ % break the page there and leave that heading alone at its foot.
215
+ \newif\ifvp@afterhead
216
+ \newcommand\vp@need[1]{\ifvp@afterhead\else\needspace{#1}\fi}
217
+ \newcommand\vp@keep{\ifvp@afterhead\nopagebreak\fi}
218
+ \newcommand\vp@headdone{\global\vp@afterheadtrue\everypar{\global\vp@afterheadfalse\everypar{}}}
211
219
  \newcommand\vp@sectionbreak[1]{\par\addvspace{\ifcase#1\or 22pt plus 8pt minus 4pt\or 16pt plus 6pt minus 3pt\or
212
- 12pt plus 4pt minus 2pt\else 10pt plus 3pt minus 2pt\fi}\needspace{\ifnum#1<3 14\else 10\fi\baselineskip}}
220
+ 12pt plus 4pt minus 2pt\else 10pt plus 3pt minus 2pt\fi}\vp@need{\ifnum#1<3 14\else 10\fi\baselineskip}}
213
221
  \newcommand\vpSection[7]{%
214
222
  \vp@sectionbreak{#2}%
215
- \phantomsection\hypertarget{#1}{}\label{#1}\bookmark[dest=#1,level=#6]{#7}%
223
+ \phantomsection\hypertarget{#1}{}\label{#1}\bookmark[dest=#1,level=#6]{#7}\vp@keep
216
224
  {\raggedright\sffamily\bfseries\ifcase#2\or\LARGE\or\Large\or\large\else\normalsize\fi
217
225
  \ifstrempty{#3}{}{#3\quad}#4\par}\nopagebreak
218
226
  \vspace{1pt}{\footnotesize\color{vpMuted}\vpName{#5}\par}\nopagebreak
219
227
  \ifnum#2=1 \markright{\ifstrempty{#3}{}{#3\enspace}#4}\fi
220
- \vspace{\ifnum#2<3 4pt\else 2pt\fi}}
228
+ \vspace{\ifnum#2<3 4pt\else 2pt\fi}\vp@headdone}
221
229
  % a section's own declarations and notes again after one of its sections, as the board's order may
222
230
  % have them: its title at the level of its sections, unnumbered, "continued" after it
223
231
  \newcommand\vpSectionResume[2]{%
224
232
  \vp@sectionbreak{#1}%
225
233
  {\raggedright\sffamily\bfseries\ifcase#1\or\LARGE\or\Large\or\large\else\normalsize\fi
226
234
  #2\hskip 0.5em{\mdseries\small\color{vpMuted}continued}\par}\nopagebreak
227
- \vspace{\ifnum#1<3 4pt\else 2pt\fi}}
235
+ \vspace{\ifnum#1<3 4pt\else 2pt\fi}\vp@headdone}
228
236
 
229
237
  % ------------------------------------------------------------------------------ a declaration
230
238
 
231
239
  % {id}{short}{kind}: the short name, the kind on the right
232
240
  \newenvironment{vpDecl}[3]{%
233
- \par\needspace{8\baselineskip}%
241
+ \par\vp@need{8\baselineskip}%
234
242
  \vspace{10pt plus 4pt}%
235
- \phantomsection\hypertarget{#1}{}\label{#1}%
243
+ \phantomsection\hypertarget{#1}{}\label{#1}\vp@keep
236
244
  \noindent{\sffamily\bfseries #2}%
237
245
  \hfill\vpKind{#3}\par\nopagebreak\vspace{1pt}}{\par}
238
246
  \newcommand\vpFullName[1]{\noindent{\footnotesize\vpName{#1}}}
@@ -261,14 +269,16 @@
261
269
  % by its number
262
270
  \newenvironment{vpReferences}{\par\addvspace{22pt plus 8pt minus 4pt}\needspace{6\baselineskip}%
263
271
  \phantomsection\hypertarget{vp-references}{}\label{vp-references}\bookmark[dest=vp-references,level=0]{References}%
264
- {\raggedright\sffamily\bfseries\Large References\par}\nopagebreak\vspace{6pt}\small\setlength\parskip{4pt}}{\par}
272
+ {\raggedright\sffamily\bfseries\Large References\par}\nopagebreak\vspace{6pt}\small\setlength\parskip{4pt}%
273
+ % ragged: a title, an upload name and a hash break nowhere, and justified they spread the rest
274
+ \raggedright}{\par}
265
275
  \newcommand\vpReference[5]{\par\noindent\hangindent=2em\hangafter=1
266
276
  \makebox[2em][l]{(#1)}\textit{#2}. #4; #3.\hskip 0.5em{\footnotesize\color{vpMuted}SHA-256 \vpMono{#5}…}\par}
267
277
 
268
278
  % ------------------------------------------------------------------------------ notes and figures
269
279
 
270
280
  % a note of the view, as the document's prose: body text, with room around it
271
- \newenvironment{vpNote}[1]{\par\addvspace{6pt plus 2pt}\phantomsection\hypertarget{#1}{}}{\par\addvspace{6pt plus 2pt}}
281
+ \newenvironment{vpNote}[1]{\par\addvspace{6pt plus 2pt}\phantomsection\hypertarget{#1}{}\vp@keep}{\par\addvspace{6pt plus 2pt}}
272
282
  % a declaration a note names, linked to where the document prints it, with its page
273
283
  \newcommand\vpMention[2]{\hyperlink{#1}{\vpInlineCode{#2}}\nobreak\hskip 0.2em{\footnotesize\color{vpMuted}(p.~\pageref*{#1})}}
274
284
  % an image or a clip a note carries, where the note is (no float): an image at its own size, a clip at
@@ -278,7 +288,7 @@
278
288
  \newsavebox\vp@figbox
279
289
  \newlength\vp@figw
280
290
  \newcommand\vpFigure[5]{%
281
- \par\needspace{8\baselineskip}\vspace{4pt}\noindent
291
+ \par\vp@need{8\baselineskip}\vspace{4pt}\vp@keep\noindent
282
292
  \begin{minipage}{\linewidth}\centering
283
293
  \ifstrempty{#2}{\sbox\vp@figbox{\includegraphics{#1}}\setlength\vp@figw{\wd\vp@figbox}}{\setlength\vp@figw{#2}}%
284
294
  \ifdim\vp@figw>\linewidth \setlength\vp@figw{\linewidth}\fi
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,288 +1,293 @@
1
1
  {
2
2
  "film": {
3
- "file": "tour-9d4241345aaf.mp4",
4
- "sha256": "9d4241345aaf68755b689fd0ba6b3139a2b077a68996361445b8098398079620",
5
- "size": 53706647,
3
+ "file": "tour-5d6d75f7fa38.mp4",
4
+ "sha256": "5d6d75f7fa38eb34d3e0f071d105825618f95a6d5e50b53fca939924d1261b63",
5
+ "size": 48300562,
6
6
  "width": 2560,
7
7
  "height": 1600,
8
- "duration": 238.96666666666667
8
+ "duration": 205.5
9
9
  },
10
10
  "chapters": [
11
11
  {
12
12
  "id": "target",
13
13
  "start": 0,
14
- "end": 19.466666666666665
14
+ "end": 16.733333333333334
15
15
  },
16
16
  {
17
17
  "id": "view",
18
- "start": 19.466666666666665,
19
- "end": 31.833333333333332
18
+ "start": 16.733333333333334,
19
+ "end": 28.233333333333334
20
20
  },
21
21
  {
22
22
  "id": "arrange",
23
- "start": 31.833333333333332,
24
- "end": 53.666666666666664
23
+ "start": 28.233333333333334,
24
+ "end": 45.63333333333333
25
25
  },
26
26
  {
27
27
  "id": "source",
28
- "start": 53.666666666666664,
29
- "end": 66.06666666666666
28
+ "start": 45.63333333333333,
29
+ "end": 55.9
30
30
  },
31
31
  {
32
32
  "id": "keys",
33
- "start": 66.06666666666666,
34
- "end": 92.8
33
+ "start": 55.9,
34
+ "end": 76.2
35
35
  },
36
36
  {
37
37
  "id": "checks",
38
- "start": 92.8,
39
- "end": 111.3
38
+ "start": 76.2,
39
+ "end": 93.9
40
40
  },
41
41
  {
42
42
  "id": "review",
43
- "start": 111.3,
44
- "end": 129.73333333333332
43
+ "start": 93.9,
44
+ "end": 106.96666666666667
45
45
  },
46
46
  {
47
47
  "id": "project",
48
- "start": 129.73333333333332,
49
- "end": 138.66666666666666
48
+ "start": 106.96666666666667,
49
+ "end": 113.7
50
50
  },
51
51
  {
52
52
  "id": "share",
53
- "start": 138.66666666666666,
54
- "end": 152
53
+ "start": 113.7,
54
+ "end": 125.6
55
55
  },
56
56
  {
57
57
  "id": "agent",
58
- "start": 152,
59
- "end": 171.33333333333334
58
+ "start": 125.6,
59
+ "end": 141.83333333333334
60
60
  },
61
61
  {
62
62
  "id": "library",
63
- "start": 171.33333333333334,
64
- "end": 199.73333333333332
63
+ "start": 141.83333333333334,
64
+ "end": 169.93333333333334
65
65
  },
66
66
  {
67
67
  "id": "export",
68
- "start": 199.73333333333332,
69
- "end": 219.23333333333332
68
+ "start": 169.93333333333334,
69
+ "end": 188.26666666666668
70
70
  },
71
71
  {
72
72
  "id": "artwork",
73
- "start": 219.23333333333332,
74
- "end": 238.96666666666667
73
+ "start": 188.26666666666668,
74
+ "end": 205.5
75
75
  }
76
76
  ],
77
77
  "captions": [
78
78
  {
79
79
  "start": 4.1,
80
- "end": 7.9,
80
+ "end": 6.633333333333334,
81
81
  "text": "Search the theorem to review: press /."
82
82
  },
83
83
  {
84
- "start": 7.9,
85
- "end": 11.9,
84
+ "start": 6.633333333333334,
85
+ "end": 9.966666666666667,
86
86
  "text": "There are two MainTheorems: take the one in Dim24."
87
87
  },
88
88
  {
89
- "start": 11.9,
90
- "end": 15.866666666666667,
89
+ "start": 9.966666666666667,
90
+ "end": 13.133333333333333,
91
91
  "text": "Mark it as the target of the review."
92
92
  },
93
93
  {
94
- "start": 15.866666666666667,
95
- "end": 19.466666666666665,
94
+ "start": 13.133333333333333,
95
+ "end": 16.733333333333334,
96
96
  "text": "The side panel lists the targets, with their progress."
97
97
  },
98
98
  {
99
- "start": 19.466666666666665,
100
- "end": 25.333333333333332,
99
+ "start": 16.733333333333334,
100
+ "end": 21.9,
101
101
  "text": "Rests on · Uses: everything the theorem uses."
102
102
  },
103
103
  {
104
- "start": 25.333333333333332,
105
- "end": 28.833333333333332,
104
+ "start": 21.9,
105
+ "end": 25.233333333333334,
106
106
  "text": "Zoom in: a view of just that, in a tab of its own."
107
107
  },
108
108
  {
109
- "start": 28.833333333333332,
110
- "end": 31.833333333333332,
109
+ "start": 25.233333333333334,
110
+ "end": 28.233333333333334,
111
111
  "text": "The view is laid out for what it holds alone."
112
112
  },
113
113
  {
114
- "start": 34.13333333333333,
115
- "end": 39.5,
114
+ "start": 30.133333333333333,
115
+ "end": 34.666666666666664,
116
116
  "text": "Drag a cluster with Ctrl held: it stays there, for everyone."
117
117
  },
118
118
  {
119
- "start": 39.5,
120
- "end": 46.53333333333333,
119
+ "start": 34.666666666666664,
120
+ "end": 39.8,
121
121
  "text": "Or let the lock go with l, and drag without Ctrl."
122
122
  },
123
123
  {
124
- "start": 46.53333333333333,
125
- "end": 53.666666666666664,
124
+ "start": 39.8,
125
+ "end": 45.63333333333333,
126
126
  "text": "Double-click a circle to fold it to a point; again to open."
127
127
  },
128
128
  {
129
- "start": 53.666666666666664,
130
- "end": 58.7,
129
+ "start": 45.63333333333333,
130
+ "end": 49.666666666666664,
131
131
  "text": "Space opens the source of what is selected."
132
132
  },
133
133
  {
134
- "start": 58.7,
135
- "end": 62.5,
134
+ "start": 49.666666666666664,
135
+ "end": 52.96666666666667,
136
136
  "text": "Rest on a name: Lean says what it is."
137
137
  },
138
138
  {
139
- "start": 62.5,
140
- "end": 66.06666666666666,
139
+ "start": 52.96666666666667,
140
+ "end": 55.9,
141
141
  "text": "Click it to go there: its source, its panel."
142
142
  },
143
143
  {
144
- "start": 66.06666666666666,
145
- "end": 69.13333333333334,
144
+ "start": 55.9,
145
+ "end": 58.96666666666667,
146
146
  "text": "Keys: the definitions that carry what it says."
147
147
  },
148
148
  {
149
- "start": 69.13333333333334,
150
- "end": 84.53333333333333,
149
+ "start": 58.96666666666667,
150
+ "end": 69.56666666666666,
151
151
  "text": "Mark each as a key with the mouse, in its panel."
152
152
  },
153
153
  {
154
- "start": 84.53333333333333,
155
- "end": 92.8,
154
+ "start": 69.56666666666666,
155
+ "end": 76.2,
156
156
  "text": "Rests on · Keys lights them, joined to the target."
157
157
  },
158
158
  {
159
- "start": 93.4,
160
- "end": 96.1,
159
+ "start": 76.6,
160
+ "end": 78.9,
161
161
  "text": "Selection: the statement alone."
162
162
  },
163
163
  {
164
- "start": 96.1,
165
- "end": 98.9,
164
+ "start": 78.9,
165
+ "end": 81.7,
166
166
  "text": "Least effort — you trust every name in it."
167
167
  },
168
168
  {
169
- "start": 98.9,
170
- "end": 101.36666666666666,
169
+ "start": 81.7,
170
+ "end": 84.16666666666667,
171
171
  "text": "Keys: the few that carry the meaning."
172
172
  },
173
173
  {
174
- "start": 101.36666666666666,
175
- "end": 103.43333333333334,
174
+ "start": 84.16666666666667,
175
+ "end": 86.23333333333333,
176
176
  "text": "Little effort, good confidence."
177
177
  },
178
178
  {
179
- "start": 103.43333333333334,
180
- "end": 105.63333333333334,
179
+ "start": 86.23333333333333,
180
+ "end": 88.23333333333333,
181
181
  "text": "TCB: everything it rests on."
182
182
  },
183
183
  {
184
- "start": 105.63333333333334,
185
- "end": 107.63333333333334,
184
+ "start": 88.23333333333333,
185
+ "end": 90.23333333333333,
186
186
  "text": "Most effort, most confidence."
187
187
  },
188
188
  {
189
- "start": 107.63333333333334,
190
- "end": 111.3,
189
+ "start": 90.23333333333333,
190
+ "end": 93.9,
191
191
  "text": "Choose how far to read: the counts say what each costs."
192
192
  },
193
193
  {
194
- "start": 111.3,
195
- "end": 116.6,
194
+ "start": 93.9,
195
+ "end": 97.46666666666667,
196
196
  "text": "Read a definition, then say what you think of it."
197
197
  },
198
198
  {
199
- "start": 116.6,
200
- "end": 125.96666666666667,
199
+ "start": 97.46666666666667,
200
+ "end": 103.8,
201
201
  "text": "Approve it, with why: the comment stays with it."
202
202
  },
203
203
  {
204
- "start": 125.96666666666667,
205
- "end": 129.73333333333332,
204
+ "start": 103.8,
205
+ "end": 106.96666666666667,
206
206
  "text": "The target's progress counts your approval."
207
207
  },
208
208
  {
209
- "start": 129.73333333333332,
210
- "end": 135.03333333333333,
209
+ "start": 106.96666666666667,
210
+ "end": 111.06666666666666,
211
211
  "text": "The Project tab: the whole codebase."
212
212
  },
213
213
  {
214
- "start": 135.03333333333333,
215
- "end": 138.66666666666666,
214
+ "start": 111.06666666666666,
215
+ "end": 113.7,
216
216
  "text": "Every board shows the same review."
217
217
  },
218
218
  {
219
- "start": 138.66666666666666,
220
- "end": 145.56666666666666,
219
+ "start": 113.7,
220
+ "end": 119.4,
221
221
  "text": "Share → AI agent: a token, and a prompt for it."
222
222
  },
223
223
  {
224
- "start": 145.56666666666666,
225
- "end": 148.76666666666668,
224
+ "start": 119.4,
225
+ "end": 122.6,
226
226
  "text": "Paste the prompt into your agent: it joins here."
227
227
  },
228
228
  {
229
- "start": 148.76666666666668,
230
- "end": 152,
229
+ "start": 122.6,
230
+ "end": 125.6,
231
231
  "text": "The token is the agent's own: revoke it here."
232
232
  },
233
233
  {
234
- "start": 152.7,
235
- "end": 160.13333333333333,
234
+ "start": 126.1,
235
+ "end": 132.33333333333334,
236
236
  "text": "Click the agent to follow it, and ask."
237
237
  },
238
238
  {
239
- "start": 160.13333333333333,
240
- "end": 165.83333333333334,
239
+ "start": 132.33333333333334,
240
+ "end": 136.83333333333334,
241
241
  "text": "It reads the code, and takes your view along."
242
242
  },
243
243
  {
244
- "start": 165.83333333333334,
245
- "end": 171.33333333333334,
244
+ "start": 136.83333333333334,
245
+ "end": 141.83333333333334,
246
246
  "text": "Its answer names what it explains."
247
247
  },
248
248
  {
249
- "start": 172.13333333333333,
250
- "end": 178.23333333333332,
249
+ "start": 142.63333333333333,
250
+ "end": 148.03333333333333,
251
251
  "text": "Library: add a paper about the code."
252
252
  },
253
253
  {
254
- "start": 178.23333333333332,
255
- "end": 191.53333333333333,
254
+ "start": 148.03333333333333,
255
+ "end": 159.2,
256
256
  "text": "Link it to the theorem, at its page."
257
257
  },
258
258
  {
259
- "start": 191.53333333333333,
260
- "end": 199.73333333333332,
259
+ "start": 159.2,
260
+ "end": 163.6,
261
+ "text": "Space: its source, and the paper beside it at its page."
262
+ },
263
+ {
264
+ "start": 163.6,
265
+ "end": 169.93333333333334,
261
266
  "text": "Pin a note on the target: where to start."
262
267
  },
263
268
  {
264
- "start": 199.73333333333332,
265
- "end": 207.66666666666666,
269
+ "start": 169.93333333333334,
270
+ "end": 177.36666666666667,
266
271
  "text": "Export prints a view: here, the target's TCB."
267
272
  },
268
273
  {
269
- "start": 207.66666666666666,
270
- "end": 212.26666666666668,
274
+ "start": 177.36666666666667,
275
+ "end": 181.33333333333334,
271
276
  "text": "Drag a section to change the document's order."
272
277
  },
273
278
  {
274
- "start": 212.26666666666668,
275
- "end": 219.23333333333332,
279
+ "start": 181.33333333333334,
280
+ "end": 188.26666666666668,
276
281
  "text": "Typeset: the PDF follows the order you set."
277
282
  },
278
283
  {
279
- "start": 219.23333333333332,
280
- "end": 224,
284
+ "start": 188.26666666666668,
285
+ "end": 192.33333333333334,
281
286
  "text": "Artwork: the board as a picture to keep."
282
287
  },
283
288
  {
284
- "start": 224,
285
- "end": 235.36666666666667,
289
+ "start": 192.33333333333334,
290
+ "end": 202.3,
286
291
  "text": "Frame it, then save it as PNG or SVG."
287
292
  }
288
293
  ]
Binary file
@@ -124,7 +124,10 @@ function fetchOffer() {
124
124
  const r = await fetch(`${URL_}/api/agent/mcp/tools`, { headers: auth(), signal: AbortSignal.timeout(15_000) });
125
125
  const body = await r.json().catch(() => null);
126
126
  if (!r.ok || !body || !Array.isArray(body.tools)) {
127
- offerError = `${URL_} answered ${r.status}: ${body?.error ?? "no tools"}${body?.hint ? ` — ${body.hint}` : ""}`;
127
+ // a server that lets in only those given its link answers a token it does not know as it
128
+ // answers anyone: 404, saying nothing more
129
+ const unknown = r.status === 404 && !body?.hint ? " — a server that lets in only those given its link answers so to a token it does not know: check that VISUALPROOF_TOKEN is the whole token from Share (vpa_…), and VISUALPROOF_URL the server it came with" : "";
130
+ offerError = `${URL_} answered ${r.status}: ${body?.error ?? "no tools"}${body?.hint ? ` — ${body.hint}` : ""}${unknown}`;
128
131
  return;
129
132
  }
130
133
  offer = body;
@@ -461,14 +464,15 @@ function received(line) {
461
464
  }
462
465
 
463
466
  /** The client went: what is under way ends, and VisualProof is told the agent left (offline at
464
- * once), within a second and a half. */
467
+ * once), within a second and a half — by this session, so that a session a newer one replaced
468
+ * (its wait answered `replaced`) leaves the newer one listening. */
465
469
  let leaving = false;
466
470
  async function leave() {
467
471
  if (leaving) return;
468
472
  leaving = true;
469
473
  for (const ctl of running.values()) ctl.abort();
470
474
  if (URL_ && TOKEN && !stopped)
471
- await fetch(`${URL_}/api/agent/view`, { method: "POST", headers: { ...auth(), "content-type": "application/json" }, body: '{"leave":true}', signal: AbortSignal.timeout(1500) }).catch(() => {});
475
+ await fetch(`${URL_}/api/agent/view`, { method: "POST", headers: { ...auth(), "content-type": "application/json", "x-visualproof-session": SESSION }, body: '{"leave":true}', signal: AbortSignal.timeout(1500) }).catch(() => {});
472
476
  process.exit(0);
473
477
  }
474
478
 
@@ -3,7 +3,9 @@
3
3
  // sends it on to the page, so that the key does not stay in the address (the history, a
4
4
  // screenshot, a link copied from the bar). Every other request — the page, its data, the event
5
5
  // stream, the agents' API — needs that cookie, or the key itself as `Authorization: Bearer <key>`
6
- // (an agent), and is answered 404 without it, as if there were nothing here.
6
+ // (an agent), and is answered 404 without it, as if there were nothing here; but a browser asking
7
+ // for a page, which is shown one that says the site is private, and nothing of it (CollabSpec
8
+ // decision 7, the owner's decision of 2026-10-18: server/accesspage.ts).
7
9
  //
8
10
  // One key for everyone: who has the link is in, and taking someone out means a new key for all.
9
11
  // Over plain HTTP the key and the cookie cross the network in the clear: this keeps out who has
@@ -12,8 +14,15 @@
12
14
  // Cookies are not kept per port: every server on one host shares a browser's cookie jar. So the
13
15
  // cookie is named per instance, by a digest of its key, and two servers on one host do not put
14
16
  // each other's readers out; its value is made from the key too, never the key itself.
17
+ //
18
+ // Without a key, whoever reaches the port is in — and a web page any browser on this machine opens
19
+ // can reach it too, by DNS rebinding: its name made to resolve to this machine, the page's scripts
20
+ // then ask this server as their own origin, and read the answers. So a server without a key answers
21
+ // only the names it is reached at (CollabSpec decision 12, the owner's decision of 2026-10-18):
22
+ // hostAllowed, below.
15
23
  import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
16
24
  import { existsSync, readFileSync, writeFileSync } from "node:fs";
25
+ import { isIPv4, isIPv6 } from "node:net";
17
26
  /** where the link points: `/k/<key>` */
18
27
  export const KEY_PATH = "/k/";
19
28
  /** what every cookie's name starts with; before 2026-10-08 it was the whole name, for every server,
@@ -93,3 +102,30 @@ function cookieOf(req, name) {
93
102
  }
94
103
  return null;
95
104
  }
105
+ /** A name as Host headers and the options give it, compared: lowercase, without the dot of a name
106
+ * written fully qualified (`example.org.`). */
107
+ const hostKey = (name) => name.toLowerCase().replace(/\.$/, "");
108
+ /** Whether a server without an access key answers a request for `host`, its Host header
109
+ * (CollabSpec decision 12, the owner's decision of 2026-10-18): an IP address (IPv6 in brackets),
110
+ * which a page's scripts reach only as that address, never as a name they made resolve to it;
111
+ * `localhost` and the names under it, which browsers resolve to this machine themselves; and the
112
+ * names in `names` — `--public-url`'s host and every `--allowed-host`. Any port; any case. A
113
+ * request without a Host is not answered, nor is a Host that is no name. */
114
+ export function hostAllowed(host, names) {
115
+ const m = /^(?:\[([0-9A-Fa-f:.]+)\]|([A-Za-z0-9._-]+))(?::\d{1,5})?$/.exec(host ?? "");
116
+ if (!m)
117
+ return false;
118
+ if (m[1] !== undefined)
119
+ return isIPv6(m[1]);
120
+ const name = hostKey(m[2]);
121
+ if (!name)
122
+ return false;
123
+ if (isIPv4(name) || name === "localhost" || name.endsWith(".localhost"))
124
+ return true;
125
+ return names.some((n) => hostKey(n) === name);
126
+ }
127
+ /** The name `--public-url` gives, as hostAllowed compares it (its port is not part of it). */
128
+ export function urlHost(url) {
129
+ const h = new URL(url).hostname;
130
+ return h.startsWith("[") ? h.slice(1, -1) : h;
131
+ }