@unifedev/thread-pages 0.3.2
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/ARCHITECTURE.md +230 -0
- package/PLUGIN_OVERVIEW.md +83 -0
- package/README.md +153 -0
- package/authoring.ts +368 -0
- package/bridge.ts +1721 -0
- package/dist/server.js +12830 -0
- package/dist/server.meta.json +11 -0
- package/docs/MODEL.md +211 -0
- package/docs/ROADMAP.md +96 -0
- package/home.ts +419 -0
- package/package.json +66 -0
- package/page.ts +782 -0
- package/server.ts +2179 -0
- package/theme.ts +676 -0
- package/tsconfig.json +15 -0
package/ARCHITECTURE.md
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
# Architecture
|
|
2
|
+
|
|
3
|
+
Version 0.3.0 · September 2026
|
|
4
|
+
|
|
5
|
+
This is the design and its reasoning. [docs/MODEL.md](./docs/MODEL.md) is the
|
|
6
|
+
operator's view — where things are stored and how to reach them.
|
|
7
|
+
[docs/ROADMAP.md](./docs/ROADMAP.md) is what is left.
|
|
8
|
+
|
|
9
|
+
## Intent
|
|
10
|
+
|
|
11
|
+
A Thread Page is a small application an agent writes for one task, for one
|
|
12
|
+
person to read and answer from.
|
|
13
|
+
|
|
14
|
+
Chat is a poor medium for the moments that matter: a comparison, a diagram, a set
|
|
15
|
+
of choices, a thing only the user can decide. Those want a page. But a *fixed*
|
|
16
|
+
page — a dashboard with slots — is worse than chat, because the shape of what
|
|
17
|
+
needs saying changes with every task.
|
|
18
|
+
|
|
19
|
+
So the plugin supplies no design. It supplies a secure host for a document the
|
|
20
|
+
agent writes freshly each time, and a way for that document to talk back.
|
|
21
|
+
|
|
22
|
+
Three properties follow, and everything else is downstream of them:
|
|
23
|
+
|
|
24
|
+
1. **The page is a file the agent edits directly.** Not a template it fills, not
|
|
25
|
+
an API it posts to. Saving is publishing.
|
|
26
|
+
2. **The agent's contract stays small.** One command, a short instruction, and
|
|
27
|
+
an optional guide it fetches only when the page needs more than prose.
|
|
28
|
+
3. **Page code is untrusted.** It is generated, so it is sandboxed and given
|
|
29
|
+
narrow named capabilities rather than credentials.
|
|
30
|
+
|
|
31
|
+
## The shape
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
~/.bb/thread-storage/<threadId>/thread-page.html the page
|
|
35
|
+
/thread-page-assets/ what it shows
|
|
36
|
+
/thread-page-uploads/ what the user sent
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
An agent runs `bb thread-page init`, gets that path, and edits the file. The
|
|
40
|
+
plugin serves it at a stable URL on the bb origin the user is already
|
|
41
|
+
authenticated to — so the same link works on a laptop and a phone with no extra
|
|
42
|
+
port, tunnel, or password.
|
|
43
|
+
|
|
44
|
+
Nothing else is stored. Two small values live in bb's existing key-value table: a
|
|
45
|
+
signing key, so open browser sessions survive a plugin reload, and a best-effort
|
|
46
|
+
last-good copy per page, so a page still opens read-only when its machine is
|
|
47
|
+
offline. There is no plugin database and no background service.
|
|
48
|
+
|
|
49
|
+
## Trust boundary
|
|
50
|
+
|
|
51
|
+
The page is generated code, so it is treated as hostile.
|
|
52
|
+
|
|
53
|
+
**Inside the iframe** — `sandbox="allow-scripts allow-forms"`, opaque origin.
|
|
54
|
+
Arbitrary HTML, CSS and JavaScript are allowed *because* the frame has no bb
|
|
55
|
+
cookie, no mutation token, no parent DOM, no `localStorage`, no raw bb API, no
|
|
56
|
+
CLI, and no filesystem access. CSP blocks ordinary `fetch` and subresources.
|
|
57
|
+
Page-authored code can therefore be as creative as the task needs without that
|
|
58
|
+
creativity being a security question.
|
|
59
|
+
|
|
60
|
+
**Outside the iframe** — plugin-authored code on the bb origin. It holds the
|
|
61
|
+
action token, makes the same-origin calls, owns navigation, and renders
|
|
62
|
+
confirmations. The document URL carries render authority only, so page code never
|
|
63
|
+
sees a credential that can change anything.
|
|
64
|
+
|
|
65
|
+
**Between them** — one `MessagePort` and a fixed capability list. Each capability
|
|
66
|
+
has its own validator, size and depth limits, effect class, and output
|
|
67
|
+
projection. There is no generic "call bb" method, no path parameter, and no
|
|
68
|
+
provider passthrough.
|
|
69
|
+
|
|
70
|
+
### Confirmed effects
|
|
71
|
+
|
|
72
|
+
Anything that reaches outside the current thread requires a confirmation the page
|
|
73
|
+
cannot fake or word:
|
|
74
|
+
|
|
75
|
+
1. The page invokes the method.
|
|
76
|
+
2. The server refuses once, returning a signed challenge that carries **its own**
|
|
77
|
+
summary, derived from validated parameters.
|
|
78
|
+
3. The trusted shell shows that summary in a dialog the sandbox cannot draw over.
|
|
79
|
+
4. The server verifies the signature before acting.
|
|
80
|
+
|
|
81
|
+
The challenge is bound to one request id, method, parameter fingerprint, page
|
|
82
|
+
revision and thread, and expires in two minutes. So it cannot be forged, replayed,
|
|
83
|
+
or reused to approve different parameters — a page cannot get "message thread A"
|
|
84
|
+
approved and then quietly reuse it for thread B.
|
|
85
|
+
|
|
86
|
+
### The honest limitation
|
|
87
|
+
|
|
88
|
+
Page JavaScript can navigate its own frame and encode data in the destination
|
|
89
|
+
URL. Browser sandbox flags do not close that channel, and CSP resource directives
|
|
90
|
+
do not either. A page therefore has access to data already inside its own frame.
|
|
91
|
+
|
|
92
|
+
It grants no bb authority. Closing it entirely would mean forbidding authored
|
|
93
|
+
JavaScript and shipping a declarative renderer instead, which would cost the
|
|
94
|
+
open-page model that is the point of the product. This is a stated trade, not an
|
|
95
|
+
oversight.
|
|
96
|
+
|
|
97
|
+
## Capabilities
|
|
98
|
+
|
|
99
|
+
| Method | Effect | Confirmed |
|
|
100
|
+
| --- | --- | --- |
|
|
101
|
+
| `context.get` | read | |
|
|
102
|
+
| `thread.activity` | read | |
|
|
103
|
+
| `threads.snapshot` | read | |
|
|
104
|
+
| `projects.list` | read | |
|
|
105
|
+
| `providers.list` | read | |
|
|
106
|
+
| `storage.get` | read | |
|
|
107
|
+
| `thread.reply` | current-thread write | |
|
|
108
|
+
| `storage.set` | current-thread write | |
|
|
109
|
+
| `threads.openPage` | navigation | |
|
|
110
|
+
| `threads.openBb` | navigation | |
|
|
111
|
+
| `threads.continue` | cross-thread write | yes |
|
|
112
|
+
| `threads.spawn` | cross-thread write | yes |
|
|
113
|
+
| `projects.create` | cross-thread write | yes |
|
|
114
|
+
| `threads.archive` | destructive | yes |
|
|
115
|
+
| `threads.stop` | destructive | yes |
|
|
116
|
+
| `navigation.openExternal` | navigation | yes |
|
|
117
|
+
| `projects.browse` | device | yes |
|
|
118
|
+
| `voice.captureAndTranscribe` | device | contract only |
|
|
119
|
+
|
|
120
|
+
Adding a capability extends this list. It never requires a new page component,
|
|
121
|
+
because no page component is built in.
|
|
122
|
+
|
|
123
|
+
Two deliberate narrowings. `projects.browse` opens the host's native folder
|
|
124
|
+
picker and returns an **opaque single-use token** plus a display string — never a
|
|
125
|
+
filesystem path the page could reuse or leak; `projects.create` redeems it.
|
|
126
|
+
`storage.*` is namespaced per thread, so pages cannot read each other's state
|
|
127
|
+
despite sharing one table.
|
|
128
|
+
|
|
129
|
+
## What the plugin renders, and what it does not
|
|
130
|
+
|
|
131
|
+
The plugin owns exactly three pieces of UI, all of them chrome outside the
|
|
132
|
+
sandbox:
|
|
133
|
+
|
|
134
|
+
- the page title bar;
|
|
135
|
+
- a **Sessions** link back to the home page;
|
|
136
|
+
- a working indicator while the thread is mid-turn.
|
|
137
|
+
|
|
138
|
+
The last two are worth explaining, because both could have been pushed onto
|
|
139
|
+
agents and deliberately were not.
|
|
140
|
+
|
|
141
|
+
**The Sessions link** is chrome so that no agent spends instruction budget on it
|
|
142
|
+
and no page can forget it. The home page it points to is not special: any
|
|
143
|
+
thread's page can be designated home with `bb thread-page home`, and it is an
|
|
144
|
+
ordinary Thread Page afterwards.
|
|
145
|
+
|
|
146
|
+
**The working indicator** answers "is it still writing?". Its state rides on the
|
|
147
|
+
`x-thread-page-activity` header of the revision poll the shell already makes
|
|
148
|
+
every ten seconds — so it costs no extra request, nothing in any page's HTML, and
|
|
149
|
+
nothing in any agent's instructions. Its wording is a setting; blank hides it.
|
|
150
|
+
|
|
151
|
+
Everything else is the page's.
|
|
152
|
+
|
|
153
|
+
## The home page
|
|
154
|
+
|
|
155
|
+
`bb thread-page home` designates a thread and, if that thread has no page yet,
|
|
156
|
+
writes a session hub. The default groups sessions by project and gives each group
|
|
157
|
+
its own look.
|
|
158
|
+
|
|
159
|
+
The design point is that **a group is not a project**. A group is a label, a
|
|
160
|
+
look, and a *set* of project ids, kept in the page's own scoped storage. One
|
|
161
|
+
group per project is only the default; a project may appear in several groups,
|
|
162
|
+
and regrouping is an edit to the page rather than a schema change.
|
|
163
|
+
|
|
164
|
+
Per-group looks need no second document. The stylesheet's `data-world` attribute
|
|
165
|
+
re-resolves every design token for a subtree, so a group can carry a different
|
|
166
|
+
palette, typeface, shape language and button style inside one page. Separate
|
|
167
|
+
linked pages remain possible through `threads.openPage`; they were not necessary.
|
|
168
|
+
|
|
169
|
+
## The design system
|
|
170
|
+
|
|
171
|
+
Five worlds — `paper`, `terminal`, `atrium`, `volume`, `bloom` — each declaring
|
|
172
|
+
both light and dark palettes at once, with one resolver publishing the live half
|
|
173
|
+
onto the tokens the rest of the sheet uses. A page picks one with `data-theme` on
|
|
174
|
+
`<html>`, plus `data-mode` and `data-atmos`.
|
|
175
|
+
|
|
176
|
+
It needs no class names: every rule keys off semantic structure, so plain HTML is
|
|
177
|
+
already styled. Three class names exist for things structure cannot express —
|
|
178
|
+
`.card`, `.needs-you`, `.label`.
|
|
179
|
+
|
|
180
|
+
**The stylesheet travels inside each page** rather than being injected at render
|
|
181
|
+
time. That means an agent can change any rule for one page, and a plugin update
|
|
182
|
+
can never restyle a page the user has already read. The cost is that improvements
|
|
183
|
+
to the design system only reach pages created afterwards; that trade favours the
|
|
184
|
+
reader.
|
|
185
|
+
|
|
186
|
+
A page may add one more `<style>` with two rules: everything inside
|
|
187
|
+
`@scope (main)`, and colour and shape from `var(--token)` only. The second is
|
|
188
|
+
what keeps a bespoke chart correct in all five worlds and in dark mode.
|
|
189
|
+
|
|
190
|
+
## Instructions
|
|
191
|
+
|
|
192
|
+
Three, and only the first is loaded per session.
|
|
193
|
+
|
|
194
|
+
1. **The contract** — why the page matters, how to ask well, what belongs on a
|
|
195
|
+
page. Injected into eligible root threads. It holds only what changes
|
|
196
|
+
behaviour; every mechanical convention is absorbed by the runtime or the seed.
|
|
197
|
+
2. **The seed comment** — the class names, the theme attributes, the escape-hatch
|
|
198
|
+
rule. Free, because the agent is already reading the file.
|
|
199
|
+
3. **The guide** — `bb thread-page guide`. Unbounded, and paid for only by the
|
|
200
|
+
sessions that open it.
|
|
201
|
+
|
|
202
|
+
There is no skill and no agent tool. Both would put the plugin in every session's
|
|
203
|
+
context whether or not the task needs it.
|
|
204
|
+
|
|
205
|
+
## Eligibility
|
|
206
|
+
|
|
207
|
+
Only threads a user started get a page. Children, forks and hidden workers get
|
|
208
|
+
`SKIP` and answer in chat, because they are not the ones being talked to. `init`
|
|
209
|
+
rechecks this at call time rather than trusting the injected instruction.
|
|
210
|
+
|
|
211
|
+
## Testing
|
|
212
|
+
|
|
213
|
+
93 tests over three suites, none needing a browser:
|
|
214
|
+
|
|
215
|
+
- `bridge.test.ts` — the capability contract in isolation: validators, limits,
|
|
216
|
+
effect classes, confirmation binding. No SDK, DOM, or filesystem.
|
|
217
|
+
- `page.test.ts` — HTML parsing against malformed and adversarial documents,
|
|
218
|
+
kernel ordering, sandbox invariants, form and label derivation.
|
|
219
|
+
- `server.test.ts` — routes, tokens, capabilities, uploads, assets, home, and the
|
|
220
|
+
working state, against a fake host.
|
|
221
|
+
|
|
222
|
+
Browser verification is done by hand for the things tests cannot see. Several
|
|
223
|
+
real defects were found only that way — an invalid CSP source that silently
|
|
224
|
+
blocked every relative asset, an auth rule that rejected raw upload bodies, a
|
|
225
|
+
`<select>`'s options leaking into an answer label, and a snapshot flag that
|
|
226
|
+
selected archived threads instead of adding them. Each has a test now.
|
|
227
|
+
|
|
228
|
+
The gap worth naming: there is no hostile-page corpus yet. The confirmation flow
|
|
229
|
+
is tested against forgery, replay and parameter-swapping, but no test plays an
|
|
230
|
+
attacker trying to reach the parent frame or steal a cookie.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Thread Pages
|
|
2
|
+
|
|
3
|
+
Give every bb thread its own web page — written by the agent, for that one task.
|
|
4
|
+
|
|
5
|
+
## What it does
|
|
6
|
+
|
|
7
|
+
An agent working on a task usually has more to tell you than chat can carry: a
|
|
8
|
+
comparison, a diagram, a set of choices, a thing only you can decide. Thread
|
|
9
|
+
Pages gives it a real page to say it on.
|
|
10
|
+
|
|
11
|
+
The agent runs one command, gets an HTML file, and edits it directly. Saving the
|
|
12
|
+
file publishes it. You open one stable link — in bb, in a browser, on your
|
|
13
|
+
phone — read the page, and answer from inside it. Your answer arrives as the
|
|
14
|
+
agent's next message.
|
|
15
|
+
|
|
16
|
+
The page is a complete HTML document the agent writes for the task at hand. Not
|
|
17
|
+
a template with slots. If the task needs a chart, it writes a chart. If it needs
|
|
18
|
+
an eight-screen wizard, a diagram you click, or three separate forms, it writes
|
|
19
|
+
that. The plugin supplies the secure host, never the design.
|
|
20
|
+
|
|
21
|
+
## Why it is built this way
|
|
22
|
+
|
|
23
|
+
**Nothing to learn, nothing to load.** There is no skill in the agent's context,
|
|
24
|
+
no page tool, no publish protocol, no runtime copied into your files. The
|
|
25
|
+
standing instruction is two sentences. Deeper guidance is one optional command
|
|
26
|
+
away, so a simple task never pays for it.
|
|
27
|
+
|
|
28
|
+
**The page is a file.** It lives in the thread's own storage as ordinary HTML.
|
|
29
|
+
The agent reads and writes it with the tools it already has. You can open it,
|
|
30
|
+
diff it, or keep it.
|
|
31
|
+
|
|
32
|
+
**Your bb, your page.** Pages are served through the bb origin you are already
|
|
33
|
+
authenticated to, so they work over bb Connect and on mobile without exposing a
|
|
34
|
+
second port or a public URL.
|
|
35
|
+
|
|
36
|
+
**Safe by construction.** Page code runs in an opaque-origin sandbox with no bb
|
|
37
|
+
cookie, no mutation token, no parent DOM, no raw API, and no general network
|
|
38
|
+
access. Anything the page can ask bb to do goes through one narrow, validated
|
|
39
|
+
capability at a time.
|
|
40
|
+
|
|
41
|
+
## In the page
|
|
42
|
+
|
|
43
|
+
- Any HTML, CSS, and JavaScript the task needs, including Web Components, SVG,
|
|
44
|
+
canvas, and multi-screen state.
|
|
45
|
+
- Forms that reply to the thread with no code at all — blank answers included,
|
|
46
|
+
several forms at once, each with its own state.
|
|
47
|
+
- File attachments, stored beside the thread and handed to the agent by path.
|
|
48
|
+
- Images, stylesheets, fonts, and data from a confined per-thread asset folder.
|
|
49
|
+
- Live thread activity, and a working indicator while the agent is mid-turn.
|
|
50
|
+
- Listing, messaging, starting, stopping and archiving sessions from a page.
|
|
51
|
+
- Update protection, so a page reload never eats what you were typing.
|
|
52
|
+
- A read-only cached copy when the source machine goes offline.
|
|
53
|
+
|
|
54
|
+
## Getting started
|
|
55
|
+
|
|
56
|
+
Install the plugin, then turn on **Agent initialization hint** in its settings
|
|
57
|
+
to have new sessions use their page automatically. Or leave it off and ask any
|
|
58
|
+
agent to run `bb thread-page init`.
|
|
59
|
+
|
|
60
|
+
The page seed and the instruction text are both settings, so you can change what
|
|
61
|
+
every future page starts from without touching any existing page.
|
|
62
|
+
|
|
63
|
+
## The home page
|
|
64
|
+
|
|
65
|
+
`bb thread-page home` writes a session hub grouped by project, each group with
|
|
66
|
+
its own look, and every other page then shows a **← Sessions** link back to it.
|
|
67
|
+
|
|
68
|
+
Home is an ordinary page afterwards — ask the agent that owns it to regroup or
|
|
69
|
+
restyle it. Groups are not tied to projects: a group is a label, a look, and a
|
|
70
|
+
set of projects, so "Work" and "Side projects" are as valid as one-per-project,
|
|
71
|
+
and a project can appear in both.
|
|
72
|
+
|
|
73
|
+
## Current state
|
|
74
|
+
|
|
75
|
+
Everything needed for daily use is implemented and verified in a browser: page
|
|
76
|
+
authoring, forms, attachments, confined assets, live activity, the session hub,
|
|
77
|
+
and the full capability set with trusted confirmations. Voice dictation has a
|
|
78
|
+
defined contract but no handler yet.
|
|
79
|
+
|
|
80
|
+
One limitation worth stating plainly: page JavaScript can navigate its own frame
|
|
81
|
+
and put data in that URL. Browsers cannot prevent this while still allowing page
|
|
82
|
+
scripts. It grants no bb authority, but a page you did not write is still code
|
|
83
|
+
you are choosing to run.
|
package/README.md
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# Thread Pages
|
|
2
|
+
|
|
3
|
+
`@unifedev/thread-pages` — part of [Unife](https://github.com/unifedev), a
|
|
4
|
+
unified interface for everything. Thread Pages is the unified interface for
|
|
5
|
+
working with AI agents; this plugin implements it for [bb](https://getbb.app).
|
|
6
|
+
|
|
7
|
+
**Every agent session gets one web page, written for that task, that you can read
|
|
8
|
+
and answer from on any device.**
|
|
9
|
+
|
|
10
|
+
An agent usually has more to tell you than chat can carry: a comparison, a
|
|
11
|
+
diagram, a set of choices, a thing only you can decide. Thread Pages gives it a
|
|
12
|
+
page to say it on — and gives you a form to answer from, which arrives as the
|
|
13
|
+
agent's next message.
|
|
14
|
+
|
|
15
|
+
The page is a complete HTML document the agent writes for the task at hand. If it
|
|
16
|
+
needs a chart, it writes a chart. If it needs a multi-screen flow, a diagram you
|
|
17
|
+
click, or three separate forms, it writes that. The plugin supplies the secure
|
|
18
|
+
host, never the design.
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
bb plugin install git:https://github.com/unifedev/bb-thread-pages.git
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Then turn on **Agent initialization hint** in the plugin's settings, so new
|
|
27
|
+
sessions use their page automatically:
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
bb plugin config thread-pages set agentInstructions true
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
That is the whole setup. If this bb is paired with `bb connect`, every page is
|
|
34
|
+
reachable from your phone immediately — there is no port to expose and nothing
|
|
35
|
+
per-page to configure.
|
|
36
|
+
|
|
37
|
+
## Using it
|
|
38
|
+
|
|
39
|
+
The agent's whole workflow is one command:
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
bb thread-page init # create or locate this thread's page; prints the link
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Two others exist:
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
bb thread-page guide # authoring reference, only when a page needs more
|
|
49
|
+
bb thread-page home # make this thread's page the home page
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
`bb thread-page home` writes a session hub grouped by project, with a filter,
|
|
53
|
+
live status, and per-row open, prompt, stop and archive. Every other page then
|
|
54
|
+
shows a **← Sessions** link back to it. Home is an ordinary page afterwards: ask
|
|
55
|
+
the agent that owns it to regroup or restyle it.
|
|
56
|
+
|
|
57
|
+
## Documentation
|
|
58
|
+
|
|
59
|
+
- [docs/MODEL.md](./docs/MODEL.md) — **start here**: instructions, storage,
|
|
60
|
+
templates, and remote access
|
|
61
|
+
- [ARCHITECTURE.md](./ARCHITECTURE.md) — the design and its reasoning
|
|
62
|
+
- [docs/ROADMAP.md](./docs/ROADMAP.md) — what is left
|
|
63
|
+
- [PLUGIN_OVERVIEW.md](./PLUGIN_OVERVIEW.md) — marketplace description
|
|
64
|
+
|
|
65
|
+
## What a page can do
|
|
66
|
+
|
|
67
|
+
Authored freely inside the sandbox:
|
|
68
|
+
|
|
69
|
+
- any HTML, CSS and JavaScript, including Web Components, SVG, canvas, and
|
|
70
|
+
multi-screen state;
|
|
71
|
+
- forms that reply to the thread with no code at all — blank answers included,
|
|
72
|
+
several forms at once, each with its own state;
|
|
73
|
+
- file attachments, stored beside the thread and handed to the agent by path;
|
|
74
|
+
- images, stylesheets, fonts and data from a confined per-thread asset folder;
|
|
75
|
+
- live thread activity, so a page can show what the agent is doing now;
|
|
76
|
+
- small state that survives a reload.
|
|
77
|
+
|
|
78
|
+
Through named capabilities, with confirmation where it matters:
|
|
79
|
+
|
|
80
|
+
- list sessions, projects and providers;
|
|
81
|
+
- message, start, stop or archive a session;
|
|
82
|
+
- create a project through the host's native folder picker;
|
|
83
|
+
- open another page, a bb thread, or an external link.
|
|
84
|
+
|
|
85
|
+
The plugin also supplies three pieces of chrome outside the page: the title bar,
|
|
86
|
+
the Sessions link, and a working indicator while the thread is mid-turn. Its
|
|
87
|
+
wording is a setting; blank hides it.
|
|
88
|
+
|
|
89
|
+
## Where things live
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
~/.bb/thread-storage/<threadId>/
|
|
93
|
+
thread-page.html the page
|
|
94
|
+
thread-page-assets/ what it shows you
|
|
95
|
+
thread-page-uploads/ what you attached
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
The page is a normal file — read it, diff it, keep it. There is no database of
|
|
99
|
+
pages and no separate publish step. Settings hold the instruction text and the
|
|
100
|
+
new-page seed, so you can change what future pages start from without touching
|
|
101
|
+
one that exists.
|
|
102
|
+
|
|
103
|
+
## Access
|
|
104
|
+
|
|
105
|
+
Thread Pages needs no port share. Its routes are part of the bb server, so the
|
|
106
|
+
origin that reaches bb reaches your pages, behind the same owner login:
|
|
107
|
+
|
|
108
|
+
```text
|
|
109
|
+
https://<handle>.getbb.app/api/v1/plugins/thread-pages/http/page?threadId=<id>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
`bb thread-page init` prints that absolute URL whenever this bb is connected, and
|
|
113
|
+
a relative path when it is local-only. For private access instead, point
|
|
114
|
+
Tailscale Serve at the whole bb loopback origin — never Funnel it, and never
|
|
115
|
+
wildcard-bind bb.
|
|
116
|
+
|
|
117
|
+
## Security
|
|
118
|
+
|
|
119
|
+
The page is generated code, so it is treated as untrusted. It runs in an
|
|
120
|
+
opaque-origin sandbox with no bb cookie, no mutation token, no parent DOM, no
|
|
121
|
+
`localStorage`, no raw bb API, no CLI, no filesystem access, and no ordinary
|
|
122
|
+
network access. Everything it can ask bb to do goes through one validated,
|
|
123
|
+
named capability at a time.
|
|
124
|
+
|
|
125
|
+
Anything reaching outside the current thread requires a confirmation the page
|
|
126
|
+
cannot fake: the server answers once with a signed challenge carrying **its own**
|
|
127
|
+
summary, the trusted shell shows that summary, and the server re-verifies the
|
|
128
|
+
signature before acting. The challenge is bound to one request, method, parameter
|
|
129
|
+
fingerprint, page revision and thread, and expires in two minutes.
|
|
130
|
+
|
|
131
|
+
One limitation stated plainly: page JavaScript can navigate its own frame and put
|
|
132
|
+
data in that URL. Browsers cannot prevent this while still allowing page scripts.
|
|
133
|
+
It grants no bb authority, but a page is code you are choosing to run.
|
|
134
|
+
|
|
135
|
+
## Development
|
|
136
|
+
|
|
137
|
+
```sh
|
|
138
|
+
npm ci
|
|
139
|
+
bb plugin types --check .
|
|
140
|
+
npm test
|
|
141
|
+
npm run typecheck
|
|
142
|
+
npm run build
|
|
143
|
+
bb plugin reload thread-pages
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
93 tests cover the capability contract, token scope and tampering, HTML parsing
|
|
147
|
+
against adversarial documents, sandbox and CSP invariants, forms, uploads,
|
|
148
|
+
confined assets, the home page, and the confirmation flow against forgery,
|
|
149
|
+
replay and parameter-swapping.
|
|
150
|
+
|
|
151
|
+
## Licence
|
|
152
|
+
|
|
153
|
+
MIT
|