@ai-ecoverse/slicc-bios 2.9.4 → 2.10.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.
- package/README.md +31 -23
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -89,7 +89,7 @@ Seven can share its origin with another app: on `www.sliccy.ai` the BIOS is `/7/
|
|
|
89
89
|
- **Pages find the BIOS** through `os/site.js`: the folder of the service worker that controls them (`navigator.serviceWorker.controller.scriptURL`), or the origin's root when none does. The deployed lockfiles (`packages/…`), `certs.json`, the installer worker and every Reload that goes through the BIOS use it. `home()` is the BIOS without its trailing slash, and the base of follow (`#follow=`) and guest seat (`#seat=`) links.
|
|
90
90
|
- **The other app's routes stay its own.** A request for a path with no OPFS file goes to the network, so six's page, its scripts and its relay at `/auth/callback`, which isn't aliased there, still load. An OPFS file is still served sandboxed, and a script request for one still gets a 403. The UI links `manifest.json`, which the service worker redirects to the BIOS's folder, so six's `/manifest.json` stays six's.
|
|
91
91
|
- **Production:** `www.sliccy.ai` is production like `seven.sliccy.ai` (`PRODUCTION_HOSTS` in `os/site.js`), for kernel users and the vault.
|
|
92
|
-
- **Sign-in** goes through six's relay page itself (see Adobe sign-in),
|
|
92
|
+
- **Sign-in** goes through six's relay page itself (see Adobe sign-in), **the tray hub** through the BIOS's folder (see Remote devices), and so does **the serve hub** (`/7/api/serve/*`, see Public previews).
|
|
93
93
|
|
|
94
94
|
#### Moving SLICC 6 into seven
|
|
95
95
|
|
|
@@ -531,36 +531,48 @@ Programs ask seven's page for what only a page can do through the kernel's `/dev
|
|
|
531
531
|
- **No click:** `midi.request` gets no seven prompt and no click item: its prompt in `plugged()` answers `null`, since Chrome's MIDI permission prompt needs no user activation, so the module sends `waiting for the browser's MIDI permission prompt in seven's tab` and calls `navigator.requestMIDIAccess` (`{ sysex: true }` with `--sysex`) at once, for a typed command and an agent's alike. A blocked or dismissed prompt refuses with `MIDI access was refused in the browser` (`EACCES`). No other `midi.*` kind asks.
|
|
532
532
|
- **The indicator:** while a port is open, the live list shows "MIDI port open", the handle with its name (`midi2 (IAC Driver Bus 1)`) and who opened it, with **Close**, which closes the port in seven and ends a `midi receive` on it. The chip goes when the port closes, however it closes: `midi close`, Close, the switch, unplugging, or the end of a `midi receive` that opened it (^C or `--count`).
|
|
533
533
|
- **The switch:** "MIDI devices" sits after Bluetooth devices, on by default and kept in the same `slicc-os.switches`. Off refuses every `midi.*` kind with `MIDI devices are off in seven's settings` (`EACCES`), and turning it off closes every open port, clears what a timed `midi send` scheduled and hasn't played (`MIDIOutput.clear()`), ends every `midi receive` with that error and refuses a request still waiting on the browser's prompt or an open still in flight.
|
|
534
|
-
- **Public previews** (`serve` and `scserve` from the catalog's [`@ai-ecoverse/slicc-serve`](https://github.com/ai-ecoverse/slicc-serve), [slicc-serve#6](https://github.com/ai-ecoverse/slicc-serve/issues/6); `src/seed/serve.js`): `serve` runs its static server on the kernel's loopback, or names a kernel server with `--port`, and asks the page to publish that port at a public capability URL through
|
|
535
|
-
- **`serve.publish`** (`{"kind":"serve.publish","port":8400,"root":"~/site","entry":"docs/a.html"
|
|
536
|
-
- **A refusal the hub answered:** a mint whose status isn't 2xx
|
|
534
|
+
- **Public previews** (`serve` and `scserve` from the catalog's [`@ai-ecoverse/slicc-serve`](https://github.com/ai-ecoverse/slicc-serve), [slicc-serve#6](https://github.com/ai-ecoverse/slicc-serve/issues/6); `src/seed/serve.js`, `src/seed/serve-hub.js` and `src/seed/serve-http.js`): `serve` runs its static server on the kernel's loopback, or names a kernel server with `--port`, and asks the page to publish that port at a public capability URL on `*.sliccy.now` through sliccy-ai's serve hub ([the hub's spec](https://github.com/ai-ecoverse/sliccy-ai#previews-on-sliccynow-the-serve-hub), [sliccy-ai#167](https://github.com/ai-ecoverse/sliccy-ai/issues/167)). Serving needs no tray. The page then answers every visitor request the hub relays by speaking HTTP to the port (see The serve hub below). Nothing is uploaded: visitors get the files while the program that asked keeps its request open.
|
|
535
|
+
- **`serve.publish`** (`{"kind":"serve.publish","port":8400,"root":"~/site","entry":"docs/a.html"}`, no body): `port` is the kernel port (1 to 65535), `root` only names it in the prompt and the chip, and `entry` is a path inside it (no leading `/`, no empty, `.` or `..` segment; `\` counts as `/`; a query is kept). An `allowLive` that older `serve` builds still send is accepted and ignored. slicc-serve's README has [the contract](https://github.com/ai-ecoverse/slicc-serve#the-embedder-contract). The reply's first line is `{"url","previewToken"}`, with the hub's `url` as it is, and the reply stays open. When the program closes it, or a signal or its exit does, seven stops the preview on the hub and writes nothing more. When seven ends it, it writes one more line, `{"stopped": <reason>}`, then ends the reply: `stopped in seven` (the chip's Stop), `stopped with serve --stop`, `revoked by the serve hub` (its `preview.revoked`), `public previews were switched off` (the switch below) or `seven lost its serve host` (the hub deleted the host, or another tab of the same browser took over its socket).
|
|
536
|
+
- **A refusal the hub answered:** a mint whose status isn't 2xx is the reply, not an errno, so `serve` can tell sign-in (exit 3) and limits (exit 4) from other failures should the hub ever gate publishing: one line `{"error", "status", "code"?, "retryAfter"?, "signIn"?}` and the end. `error` and `code` are the hub's (`error` is `the serve hub answered <status>` without one); `retryAfter` is its `Retry-After`; `signIn` is the hub's `signIn`, else a `Link` with `rel="login"`. A hub seven can't reach at all is `EIO` with the reason.
|
|
537
537
|
- **The prompt:** the same gesture check as `open.url`: a request typed in a terminal of an active tab goes ahead; any other, the agent's always, waits for "Publish ~/site at a public URL?" (or "the server on port 5173" without a root; "<asker> asks seven to publish ~/site at a public URL. Anyone with the link can open it while it is served.", **Publish** and Cancel). The dismissed texts are `the request to publish was dismissed` and `nobody answered the request to publish within 60 s`.
|
|
538
538
|
- **The switch:** "Public previews" in Settings, on by default and kept in `slicc-os.switches` like the capture switches. Off refuses `serve.publish` with `EACCES`, `public previews are off in seven's settings`, before the prompt and again after it, and turning it off revokes every live preview this seven serves.
|
|
539
539
|
- **The chip:** while a preview is live, every tab shows "Serving publicly", the root (or `port <n>`) and who asked, with **Stop**, which revokes it.
|
|
540
|
-
- **Minting:** the page posts `{
|
|
540
|
+
- **Minting:** the page posts `{ entry: "/<entry>", tag: "/srv/serve/<32 hex>" }` (`entry` is `/` without one) to the hub's `POST …/previews` (below). The tag is only a name the hub lists back: a fresh one per publish, never a path in seven's file system.
|
|
541
541
|
- **`serve.snapshot`** (`serve --ttl`, [slicc-serve#4](https://github.com/ai-ecoverse/slicc-serve/issues/4), `src/seed/snapshot.js`): a snapshot that stays up without seven, uploaded through the page. The header is `{"kind":"serve.snapshot","root","entry"?,"ttlMs","files","bytes"}` (`ttlMs` 60 000 to 30 days, at most 1,000 files and 50 MiB), and the body is each file as a JSON line `{"path","type","size"}` (at most 4 KiB) followed by exactly `size` bytes, at most 25 MiB each. Paths follow the hub's rules (no leading `/`, no empty, `.` or `..` segment, no segment starting with `.` but `.well-known`, no `\`, `:` or NUL); `type` is a plain media type.
|
|
542
542
|
- **Before the body:** the same switch, the same refusals and the same gesture check as `serve.publish`, with "Publish a snapshot of /home/site (2 files, 1.8 KiB) at a public URL for 7 days?" (dismissed texts `the request to publish the snapshot was dismissed`, `nobody answered the request to publish the snapshot within 60 s`).
|
|
543
|
-
- **Upload:** the page mints `{
|
|
544
|
-
- **The reply:** one line `{"url","previewToken","
|
|
543
|
+
- **Upload:** the page mints `{ entry, tag, ttlMs }` like a live preview, reads the body file by file and `PUT`s each to `…/previews/<token>/files/<path>` (each segment percent-encoded) with the host's bearer and its `Content-Type`, four at a time, reporting `uploaded 12 of 40 files` through `request.progress`, then `POST`s `…/finalize`. The hub needs the entry's file (`index.html` without an entry) and keeps the snapshot for `ttlMs` from the finalize.
|
|
544
|
+
- **The reply:** one line `{"url","previewToken","expiresAt","files","bytes"}` (`expiresAt` is the finalize time plus `ttlMs`, in ms since the epoch).
|
|
545
545
|
- **Failures** answer at once, without reading the rest of the body, and stop whatever was minted on the hub. A body that breaks the rules, or whose files and bytes don't add up to exactly `files` and `bytes`, is `EIO`, `bad snapshot body: <what>`. A refusal the hub answered is the reply line of `serve.publish` with `"during": "mint"`, `"upload"` (and its `"path"`) or `"finalize"`. A hub that can't be reached is `EIO`. A program that goes away before the page has written its reply aborts the request, and the snapshot is stopped on the hub, even when its finalize was in flight and succeeds (#1801); once the reply is written, the snapshot stays, since `serve` may have read it.
|
|
546
|
-
- **Kept:** a finalized snapshot outlives the page, so seven keeps `{previewToken, url, root?, entry?, since, expiresAt, uid,
|
|
546
|
+
- **Kept:** a finalized snapshot outlives the page, so seven keeps `{previewToken, url, root?, entry?, since, expiresAt, uid, files, bytes}` in `localStorage` (`slicc-os.snapshots`, out of every program's reach) until it expires or is stopped, and the sweep leaves snapshots alone.
|
|
547
|
+
- **The serve hub:** the page is a publisher of sliccy-ai's serve hub with a host of its own.
|
|
548
|
+
- **Where:** on `*.sliccy.ai` the hub is the page's own origin, `<BIOS folder>/api/serve/…` (`/7/api/serve/…` on `www.sliccy.ai`), so no CORS is involved; elsewhere (`localhost`, tests) it is the origin `localStorage['slicc-os.serve-hub']` names, and without one there is none.
|
|
549
|
+
- **The host:** the first call creates one (`POST …/api/serve/host`, 201 `{hostId, secret}`), which seven keeps in `localStorage` (`slicc-os.serve-host`, out of every program's reach). Every other call carries `Authorization: Bearer <secret>`. A `404 HOST_NOT_FOUND` or `410 HOST_GONE` makes a new host and tries again once.
|
|
550
|
+
- **Calls:** `POST …/previews` mints, `GET …/previews` lists, `DELETE …/previews/<token>` stops, and snapshots `PUT …/files/<path>` and `POST …/finalize` (above).
|
|
551
|
+
- **The socket:** `serve.publish` opens `…/api/serve/host/<hostId>/ws` with the subprotocols `slicc-serve.v1` and `bearer.<secret>` and mints once the hub's `hello` arrives. It pings every 30 s and reconnects after 1, 2, 5, 10, then every 30 s. A socket that closes before `hello` while `serve.publish` waits for it makes the page list its previews, so a host the hub forgot is replaced and the hub's refusal reaches the request. Close 4000 (another socket took the host, which only another tab of the same browser does) ends every live preview with `seven lost its serve host` and stops reconnecting until the next `serve.publish`; 4001 (the host was deleted) ends them the same way and forgets the host. After each `hello`, a live preview minted on another host ends the same way.
|
|
552
|
+
- **Leftovers:** a live preview stays minted while the page is away (its visitors get 502), so at boot in the tab that runs the kernel (when it has a host), and after each `hello`, the page lists the host's previews and stops each live one whose `tag` is under `/srv/serve/` and that it doesn't serve (neither its token nor its tag is one of seven's, a mint still in flight included). Snapshots stay.
|
|
553
|
+
- **Visitor requests:** `http.request {id, previewToken, method, url, path, headers, body}` that is malformed (a method that isn't a token, a path that doesn't start with `/` or holds a space or control character, headers that aren't `[name, value]` pairs, a `Content-Length` that isn't a number) is `400`; `CONNECT` and `TRACE` are `405`; one for a preview seven doesn't serve (never minted, or ended) is `404` `this preview is no longer served`; and one past 16 open streams of that preview, or 64 in all, is `503` with `Retry-After: 1`. None of these dials anything. Otherwise the page dials the preview's own port with `kernel.dial` (nothing in the message chooses the port or the host) and speaks HTTP/1.1 itself: `kernel.loopbackFetch` builds a browser `Request` and `Response`, which drop `Cookie` and `Set-Cookie`. It sends the method and `path` as they came, `Host: 127.0.0.1:<port>`, the visitor's headers but the hop-by-hop ones, `host`, `expect`, `content-length` and `x-forwarded-*`, then `X-Forwarded-Host` with the host of the URL the hub minted (never the visitor's), `X-Forwarded-Proto: https` and `Connection: close`. A body goes as its binary frames arrive: with the visitor's `Content-Length` exactly that many bytes and nothing after them (so no second request reaches the port on that connection), and chunked without one. Each frame is acknowledged with `http.ack` once the port has taken it.
|
|
554
|
+
- **The answer:** `http.response {id, status, headers, body}` with the port's status and headers as it sent them (repeats kept, `Set-Cookie` included) but the hop-by-hop ones (and `Content-Length` next to a chunked body); a `Location` on the port (`http://127.0.0.1:<port>`, `http://localhost:<port>` or `http://<port>.kernel.localhost`) becomes its path, query and fragment, so a redirect stays on the preview. `1xx` answers are skipped. The body (none for `HEAD`, `204` and `304`; chunked, counted, or until the port closes) follows in binary frames of a 4-byte big-endian id and at most 64 KiB, at most 1 MiB unacknowledged, then `http.response.end`. So `Range`, conditional requests, streams and bodies of any size are the port's own. Nothing answering on the port is `502` `nothing answers on kernel port <port>: …`; a port that fails before its head is `502` with the reason, and after it `http.cancel` with the reason. An `http.cancel` from the hub, the socket closing, or the preview ending closes the connection to the port.
|
|
555
|
+
- **Bounds** (`LIMITS` in `os/serve-http.js`): the port's head must come within 25 s, else `504` `kernel port <port> didn't answer within 25 s`. After it, a stream is cancelled when for 25 s neither the port sends anything nor the hub acknowledges anything (`kernel port <port> sent nothing for 25 s`), which closes the connection to the port. A stream that keeps moving has no size or duration limit: a large download or a server-sent event stream runs as long as the visitor reads it, while seven holds at most the 1 MiB ack window of it at a time; an idle event stream ends after 25 s and `EventSource` reconnects. The stream caps above bound how many there are.
|
|
556
|
+
- **The bridge** goes over the same socket: `bridge.connected`, `bridge.disconnected`, `bridge.cdp.response`, `bridge.emit` and `preview.state` from the hub; `bridge.cdp.request`, `bridge.close` and `preview.state.update` to it.
|
|
547
557
|
- **Whose:** each preview keeps the uid of the process that published it.
|
|
548
558
|
- **`serve.list`:** one JSON line per preview of the caller's uid (every one for root): a live one as `{previewToken, url, root?, port, entry?, since}`, a snapshot as `{previewToken, url, root?, entry?, since, mode: "persistent", expiresAt}` (times in ms since the epoch), and an empty reply when there are none.
|
|
549
|
-
- **`serve.stop`** (`{"kind":"serve.stop","previewToken":"…"}`, an empty reply): ends a live preview's `serve.publish` reply with `stopped with serve --stop`, or forgets a kept snapshot once the hub has
|
|
550
|
-
- **The bridge** (`serve --bridge`, [slicc-serve#5](https://github.com/ai-ecoverse/slicc-serve/issues/5), `src/seed/bridge.js` and `src/seed/bridge-cdp.js`; slicc-serve's README has [the contract](https://github.com/ai-ecoverse/slicc-serve#the-bridge-in-seven)): `serve.publish` with `"bridge": true`, `maxTabs` (an integer from 1 to 100, default 20, else `EIO` `invalid maxTabs`) and `quiet` makes every tab a visitor opens on the preview a CDP target of seven, `preview:<token>:<connId>`, and hands the page's `window.slicc.emit(name, detail)` to the agent. The hub does the rest as
|
|
551
|
-
- **The mint** adds `bridge: true`, `maxTabs
|
|
552
|
-
- **The webhook:** slicc-agent delivers a webhook only to a name it has an entry for, so seven writes `/root/.slicc/webhooks/serve-<16 hex>.json` (`{"target":"cone","message":"An event from a visitor's tab on the bridged preview <url> (serve --bridge)"}`) through the kernel when it mints, removes it when the preview ends, and, each time it writes one, removes every other `serve-<16 hex>.json` there that it holds no preview for (left over from before a reload). Emits arrive
|
|
559
|
+
- **`serve.stop`** (`{"kind":"serve.stop","previewToken":"…"}`, an empty reply): ends a live preview's `serve.publish` reply with `stopped with serve --stop`, or forgets a kept snapshot once the hub has stopped it (a stop that fails keeps it, so it can be stopped again), and stops it on the hub (`DELETE …/previews/<token>`). A token seven doesn't hold is stopped on the hub all the same. One the hub doesn't know either (`404`), and a held preview of another uid for a caller who isn't root, is `ENOENT`, `the serve hub has no such preview`. A kept snapshot minted on the tray hub before seven moved to the serve hub (its entry has a `trayId`) is unknown to the serve hub, so its stop is `EIO`, `the snapshot <token> lives on the tray hub, which seven no longer publishes through, so it ends only at its expiry`, and seven keeps listing it until then.
|
|
560
|
+
- **The bridge** (`serve --bridge`, [slicc-serve#5](https://github.com/ai-ecoverse/slicc-serve/issues/5), `src/seed/bridge.js` and `src/seed/bridge-cdp.js`; slicc-serve's README has [the contract](https://github.com/ai-ecoverse/slicc-serve#the-bridge-in-seven)): `serve.publish` with `"bridge": true`, `maxTabs` (an integer from 1 to 100, default 20, else `EIO` `invalid maxTabs`) and `quiet` makes every tab a visitor opens on the preview a CDP target of seven, `preview:<token>:<connId>`, and hands the page's `window.slicc.emit(name, detail)` to the agent. The hub does the rest as SLICC 6's did: it injects its bootstrap into the preview's HTML, holds one `/__slicc/bridge` socket per visitor tab (at most `maxTabs`), and relays between those sockets and the page's socket to the hub.
|
|
561
|
+
- **The mint** adds `bridge: true`, `maxTabs` and `quiet`. Seven names the agent's webhook for the preview itself, `serve-<16 hex>`, a fresh name per preview, and the reply's first line adds `"webhook"`. The prompt says so: "Publish ~/app at a public URL, and let the agent drive the tabs of whoever opens it?".
|
|
562
|
+
- **The webhook:** slicc-agent delivers a webhook only to a name it has an entry for, so seven writes `/root/.slicc/webhooks/serve-<16 hex>.json` (`{"target":"cone","message":"An event from a visitor's tab on the bridged preview <url> (serve --bridge)"}`) through the kernel when it mints, removes it when the preview ends, and, each time it writes one, removes every other `serve-<16 hex>.json` there that it holds no preview for (left over from before a reload). Emits arrive on the hub socket as `bridge.emit {previewToken, connId, name, detail, at}`. Seven takes one only when `connId` is a live tab of that preview token and seven still holds that preview; any other is dropped with `serve: dropped an emit from a connection seven doesn't hold`, a beacon's (`connId` `null`, an emit has to come from a live tab) included. A `serve-<16 hex>` `webhook.event` that comes through the tray is dropped too: those names take only the bridge's emits. It records the emit and delivers it to the preview's webhook as a webhook lick, with the headers `x-slicc-preview-conn` and `x-slicc-preview-token` and the body `{"name","detail"}`: `name` without control characters (C0, DEL, C1, as spaces) and cut to 200 characters, and a `detail` over 16 KiB as JSON (the hub's own emit limit) or one that can't be written as JSON replaced by at most 4,096 characters of its JSON (or `null`) with `"truncated": true`. The first tab of a preview that isn't `quiet` is delivered the same way, with `x-slicc-preview-lifecycle: connected` and the body `{"origin","userAgent","connectedAt"}` (normalised as below), and seven sends `preview.state.update {previewToken, announced: true}`; the hub's `preview.state` restores `quiet` and `announced`. A delivery the agent turns down (it has no entry for the name) is logged as `serve: the agent has no webhook <name>, so it dropped the delivery`, one it can't take (no agent running) as `serve: the webhook <name>: <why>`. Webhook payloads come from strangers' browsers, and the agent treats a webhook lick as data.
|
|
553
563
|
- **Targets:** for each `bridge.connected` of a preview it holds (one for an unknown preview token opens nothing), seven adds a `page` target `preview:<token>:<connId>` in the browser context `preview`, with the URL and origin seven minted: the preview's URL, and its origin as the frame's `securityOrigin` and the main context's origin. Then it asks the tab for its `location.href` and `document.title` (one `Runtime.evaluate`) and takes the URL only when it is at most 2,048 characters on the preview's own origin, and the title with control characters (C0, DEL, C1) replaced by spaces and cut to 200 characters (`Target.targetInfoChanged`).
|
|
554
|
-
- **Visitor-claimed data:** what a visitor's tab or the hub's `bridge.connected` reports (the page's URL and title, the connection's `origin` and `userAgent`, `connectedAt`, emits, every CDP answer) comes from a stranger's browser. Seven bounds it where it enters: the claimed `origin` becomes a parseable `http:`/`https:` origin or `about:invalid`, `userAgent` loses its control characters and is cut to 512 characters, `connectedAt` to 64. None of it is an input to a protected-origin decision about seven's real targets: a visitor target never gets seven's, the vault's or a privileged scheme's origin or URL, so a claim can't lower the protection of anything, and at most the guard cuts that visitor's own session. Agents and programs must treat `preview:` targets (browser context `preview`) as untrusted pages of strangers. `bridge.disconnected`, the preview's end and, 3 s after
|
|
564
|
+
- **Visitor-claimed data:** what a visitor's tab or the hub's `bridge.connected` reports (the page's URL and title, the connection's `origin` and `userAgent`, `connectedAt`, emits, every CDP answer) comes from a stranger's browser. Seven bounds it where it enters: the claimed `origin` becomes a parseable `http:`/`https:` origin or `about:invalid`, `userAgent` loses its control characters and is cut to 512 characters, `connectedAt` to 64. None of it is an input to a protected-origin decision about seven's real targets: a visitor target never gets seven's, the vault's or a privileged scheme's origin or URL, so a claim can't lower the protection of anything, and at most the guard cuts that visitor's own session. Agents and programs must treat `preview:` targets (browser context `preview`) as untrusted pages of strangers. `bridge.disconnected`, the preview's end and, 3 s after the page's socket to the hub reconnects, a tab the hub didn't replay (`bridge.connected` with `replay: true`, which restores a tab without a record or an announcement) drop it.
|
|
555
565
|
- **The CDP side** is slicc-serve's host relay (`crates/serve-hub/src/bridge.rs` and `remote.rs`, [slicc-serve#32](https://github.com/ai-ecoverse/slicc-serve/pull/32)): the `Target` domain with flat sessions (`getTargets`, `setDiscoverTargets`, `setAutoAttach`, `attachToTarget`, `detachFromTarget`, `closeTarget` as `bridge.close`, `getTargetInfo`; `createTarget`, `createBrowserContext` and `Browser.close` are `-32000`, `a preview bridge can't open or close the visitor's browser`), the same synthetic session methods (`Page.getFrameTree`, `Page.createIsolatedWorld` and `Runtime.enable`'s main context from the tab, `{}` for `Input.dispatchMouseEvent`, `Input.dispatchKeyEvent` and `Input.insertText` so that playwright-cli's in-page fallback acts exactly once), and every `Runtime.evaluate`, `Runtime.callFunctionOn`, `Runtime.getProperties`, `DOM.describeNode` and `DOM.resolveNode` sent to the tab as one `Runtime.evaluate` against a registry the page keeps (`globalThis[Symbol.for('seven.bridge')]`), so an object handle names the object itself and never runs its expression again. A `callFunctionOn` function is compiled with indirect `eval`, so it runs at the page's global scope and sees none of the bridge's own names; `Runtime.getProperties` lists a handle's own string-keyed properties from their descriptors (getters and setters as functions, never run; `accessorPropertiesOnly` honoured); a `DOM.resolveNode` handle joins its `objectGroup` like an evaluated one. Handles are `7.<context>.<n>`, the shape of Chrome's object ids, so the guard knows their context; a navigation drops them. `Page.navigate` answers with the frame and sends `Page.frameNavigated`, a new context and `Page.loadEventFired`. Everything else goes to the tab as `bridge.cdp.request`; an answer for a connection seven doesn't know is dropped, a tab that doesn't answer within 30 s is `-32000`, `the visitor's tab didn't answer within 30 s`, a tab that goes is `-32000`, `the visitor's tab is gone`, and an answer over 25 MiB as JSON is `-32000`, `the visitor's answer is over 25 MiB, so seven refused it`. An answer is taken only from the connection the request went to. For the guard, seven also answers `Page.getNavigationHistory` (the tab's one entry) and `DOM.disable`.
|
|
556
566
|
- **The `preview` route:** the guard's route `preview` has the DevTools port's semantics on purpose. The extension route's special cases (synthetic auto-attach, the private frame list, tab targets) and the link route's (URLs cut by the link guard, its `stockSetup`) describe a real Chrome behind seven, and a visitor tab is neither: it is a page in a stranger's browser that answers only what the bootstrap answers, so the guard applies its general rules. It refuses before the visitor sees them `Target.sendMessageToTarget`, an attach without `flatten`, init scripts with code, `Emulation` and `Network` overrides, interception, a navigation to a protected URL and the `Debugger` domains (no debugger floor for the route), answers cookies with none, and `Browser.getVersion` says `slicc: { route: "preview" }`.
|
|
557
567
|
- **Through the guard:** the kernel's CDP hook (`browserHook` in `os/cdp.js`) gives every connection without `--runtime`, while seven holds a bridged preview, the bridge's targets in a guard of their own (`guardProtected` with the route `preview`, which the guard treats like the DevTools port: neither the extension's nor a link's), joined to the guarded browser it would have picked (`joined` in `os/bridge.js`: `Target.getTargets` lists both, `setDiscoverTargets` and `setAutoAttach` go to both, a `preview:` target or a session the bridge attached goes to the bridge, everything else to the browser). With no browser to drive, the connection has the bridge's targets alone; a browser that fails for another reason (an extension that needs an update, a DevTools port that closed) is logged as `cdp: only the bridged preview's tabs, no browser: <why>`. So kernel `playwright-cli` sees visitor tabs next to the browser's, a connection seven wouldn't hand a browser (a linked device without Browser control) doesn't get them either, and nothing reaches a visitor tab past the guard. Visitor tabs belong to strangers' browsers: they are never in the Browser panel's tabs, and seven never moves one anywhere.
|
|
558
568
|
- **Lifecycle records:** the last 500, in memory, of the previews seven published with the bridge: `{at, event: "connected"|"disconnected"|"emit", previewToken, connId, announced, origin?, userAgent?, connectedAt?, reason?, name?, detail?}`, with `name` cut to 200 characters and `detail` as JSON cut to 1,000. Each is also a further line of that preview's held `serve.publish` reply, which a `--foreground` `serve` prints. A stopped preview's records stay until truncated.
|
|
559
569
|
- **`serve.logs`** (`{"kind":"serve.logs","previewToken"?}`): one JSON line per record, oldest first, of that preview or of every one the caller may see (its own uid's; root sees all). A token seven never bridged, or another uid's for a caller who isn't root, is `ENOENT`, `seven holds no preview <token>`. **`serve.truncate`** (same options) clears them, re-arms the first-visit announcement of each matching preview still held (`preview.state.update {announced: false}`) and answers `{"cleared","rearmed"}`.
|
|
560
|
-
- **Refusals:** no
|
|
561
|
-
- **Tests:** `test/integration/previews.test.mjs` publishes `httptest` on
|
|
562
|
-
- **Bridge trust tests:** `test/integration/bridge-trust.test.mjs` (node only) has one row per check that a visitor or the hub's messages can't pass: an unknown token on `bridge.connected`, an emit without the right token
|
|
563
|
-
- **
|
|
570
|
+
- **Refusals:** no serve hub (a seven off `*.sliccy.ai` without `slicc-os.serve-hub`) is `ENOTSUP`, `seven publishes previews only through the serve hub, and it has none here`; a tab that doesn't run the kernel (another seven tab of the same browser) is `ENOTSUP`, `seven publishes only from the tab that runs its kernel; run serve in that tab's terminal`; a socket to the hub that isn't up within 15 s (`seven isn’t connected to the serve hub yet; try again in a moment`), a hub that can't be reached and a bad `port`, `entry`, `maxTabs` or `previewToken` (`invalid port`, `invalid entry`, `invalid maxTabs`, `invalid previewToken`) are `EIO` with the reason. The kinds' policies are `{}`: the kernel admits a process of the session's own uid, so a cone's agent publishes in its own session, and `sudo -u cone` in root's terminal is refused before the page sees it. A remote follower's shell has no page hook, so `serve` there is `ENOTSUP` before the page sees it.
|
|
571
|
+
- **Tests:** `test/integration/fake-serve-hub.mjs` is a serve hub with the hub's API, its socket protocol (flow control included), its labels as `<label>.localhost:<port>` and the bridge's injection and visitor sockets. `test/integration/previews.test.mjs` publishes `httptest` on it from a raw `/dev/embedder` request, checks the boot sweep (an orphan stopped, a snapshot and a preview of another tag kept), the mint, the chip, `serve.list`, a visit, a 404 from the server, a 300 000-byte POST echoed whole, a chunked event stream and a preview seven doesn't serve (404), then ends a preview every way (the program killed, the chip's Stop, the hub's revoke, `serve.stop`, a deleted host, which also gets the page a new one, the switch, a reload) and checks each one is stopped with its `stopped` line, that a cone's session lists none of root's previews and can't stop one, and that a hub's refusal comes back as the reply's `error` line; a seven without a hub refuses with `ENOTSUP`. `test/integration/previews-serve.test.mjs` installs `serve` from the catalog, runs `serve --local` and publishes its port: text, a 300 000-byte binary file, the server's own ranges (a window, a suffix, an unsatisfiable one), a 404 and a 25 MiB+1 file that comes through whole. `test/integration/previews-snapshot.test.mjs` sends `serve.snapshot` bodies from the terminal: three files (a 70 000-byte binary among them) uploaded with the host's bearer and their types and finalized, the reply, `serve.list` before and after a reload whose boot sweep stops an orphan and not the snapshot, an upload the hub refuses (`during: "upload"` with its path, then stopped), a body that announces fewer bytes than it carries (`EIO`, stopped), a refused mint, a program killed while the hub holds its finalize (the finalize is released once the program is gone from `ps`; the snapshot is stopped and not kept), the switch off, a `serve.stop` the hub fails (non-zero, and `serve.list` still shows the snapshot), and a second `serve.stop`, after which the hub no longer serves it and `localStorage` keeps no snapshot.
|
|
572
|
+
- **Bridge trust tests:** `test/integration/bridge-trust.test.mjs` (node only) has one row per check that a visitor or the hub's messages can't pass: an unknown token on `bridge.connected`, an emit without the right token or a live connection (a beacon's included), one from a lingering tab whose preview is gone, an emit name with control characters, a `serve-<16 hex>` `webhook.event` through the tray, an oversize or deeply nested emit, an answer from another visitor's connection, an answer over 25 MiB, another visitor's object handle, a forged `preview:<token>:<conn>`, `Target.createTarget`, a duplicate `bridge.connected`, a replay, a tab the hub didn't replay after a relink, a replay under another token, a claimed URL, origin, user agent or title, a getter run by `Runtime.getProperties` (and only accessors listed with `accessorPropertiesOnly`), a resolved node's handle that its group's release keeps (or another group's drops), and a called function that sees the bridge's own names. A mutant whose text isn't in the source fails its run instead of passing it. Each row runs again against a mutant of the code with its check removed (applied at import by a module hook), and that run must fail. Two more run the bridge through the guard on the `preview` route: what it refuses before the visitor sees it, and a visitor claiming a protected origin and URL next to a real browser (the fixture of the guard tests), whose real targets keep their decisions.
|
|
573
|
+
- **Relay tests:** `test/integration/previews-relay.test.mjs` publishes `relay-fixture` (`test/integration/fixtures/relay-fixture/`, a kernel JS server that echoes what it gets and answers silently, stalls, drips, redirects and sends large bodies on cue) on the fake serve hub and checks through visits and the hub's socket: the visitor's `Cookie`, both `Set-Cookie` lines, the method, query and body, `Host`, `X-Forwarded-Host` from the minted host even when the request names another, a redirect on the port made a path and one elsewhere kept; `400` for a malformed request, `405` for `CONNECT` and `TRACE` and `404` for a preview seven doesn't serve, none of them dialing; a body cut at its `Content-Length` with nothing after it reaching the port; sixteen silent streams answered `504` after 25 s and their connections closed, a seventeenth refused with `503` without a dial, a stream idle for 25 s cut and its connection closed, one that sends for 35 s kept whole; a 70 MiB answer to a visitor that pauses reading, with at most 1 MiB unacknowledged; and a preview's stream ended when the preview ends.
|
|
574
|
+
- **Relay trust tests:** `test/integration/serve-trust.test.mjs` (node only) has one row per bound of the relay, each run again against a mutant without its check, which must fail: a message's own `port` or `host` never reaches the dial, a token seven doesn't hold dials nothing, a head that doesn't come is `504` with the connection closed, a stalled body is cancelled while one that keeps sending past 120 s stays and arrives whole, the stream caps answer `503` without a dial, an answer of 65 MiB streams through with at most the 1 MiB window in flight, a body longer than its `Content-Length` goes on only up to it, `CONNECT` and `TRACE` are `405`, `X-Forwarded-Host` is the minted host, and unpublishing closes the preview's streams.
|
|
575
|
+
- **Bridge tests:** `test/integration/serve-bridge.test.mjs` publishes a `serve --local` server with the bridge on the fake serve hub, which serves the preview with SLICC 6's own bootstrap (`@ai-ecoverse/cherry`'s `preview-bridge.js`, a devDependency) and relays the `bridge.*` messages and emits like the real hub. A visitor tab in the same Chrome opens it; seven's terminal checks the mint, the webhook entry, the `connected` and `emit` lines of the held reply, the `preview.state.update`s and the first-visit delivery, and kernel `playwright-cli` lists the target, evaluates, snapshots, clicks the button exactly once (no `Input.*` reaches the tab), takes a screenshot and sees the tab go when it closes; then `serve.logs`, `serve.truncate`, `serve.stop` (the webhook entry goes, the records stay) and `ENOENT` for an unknown token. A second test drives a quiet preview's tab next to a browser through the fake extension: `tab-list` shows the real tab and the visitor target, and `tab-select` and `eval` go over the bridge.
|
|
564
576
|
- Kinds seven doesn't list (`open.file`, `open.download`, `open.reveal`, `clipboard.read`) are `ENOTSUP` before the page sees them.
|
|
565
577
|
|
|
566
578
|
### Composer recording
|
|
@@ -815,11 +827,7 @@ seven can also join a tailnet, with a patched build of Tailscale's wasm client (
|
|
|
815
827
|
- **Revoking:** the hub's `biscotto.revoked` (sent for a revoke from anywhere) and this page's own `revoke(id)` close every link of the seat at once; the agent ends the seat's Chord links and leaves nothing behind, and the hub refuses its token from then on (`INVALID_JOIN_CAPABILITY`). Seven doesn't rely on the hub for that: both also put the seat's id in a local deny list (`localStorage['slicc-os.revoked-seats']`, id → until), kept until the seat's own expiry, or 7 days when seven doesn't know it, and a join on a denied seat is refused with `UNTRUSTED` ("this guest seat was revoked") even if the hub let it through. When the hub's stop fails, `revoke` rejects with "Seven refuses this guest from now on, but the tray hub didn’t revoke the link: …", and the tab shows a warning notice (`guest-seat-stop:<id>`) with **Try again**, which retries the stop and goes once the hub takes it. The deny list stays either way.
|
|
816
828
|
- **The guest's page:** opening the seat link boots the BIOS as usual (the base set and `/opt/agent` go into that browser's OPFS), then the BIOS goes straight to `os/join.html` for a `#seat` (and `os/start.js` sends one there too), a page that opts into the cross-document view transition inline, like `index.html`. That page is `<slicc-chat>` alone inside `.swc-theme` and `<sp-theme system="spectrum-two">`, with spectrum's stylesheet (`@ai-ecoverse/slicc-spectrum/swc.css`, spectrum ≥ 1.86.0: the pinned `@adobe/spectrum-wc` stylesheet with its tokens inlined), following the system's light or dark. It takes the seat URL from the fragment, removes it from the address bar and keeps it in `sessionStorage` (`slicc-os.seat`) for reloads of that tab only, installs `/opt/agent` like a follower, and dials the hub as `slicc-seven/1` with a fresh certificate each time, so a guest is never a device. It opens `pi`, calls slicc-agent's `connectGuest`, and shows `createAgentModel(guest)`, whose `seat` puts the chat in guest mode (with the assistant messages' `model` left out, since a guest gets no model list and the chat would show the raw id): the host's messages read "From the host", and the guest's messages wait for the seat's review. A dropped link reconnects. A revoked or expired seat, a refused port (`EACCES`) or another agent version (`EVERSION`) ends it: the page drops the chat, forgets the seat and says why ("This guest link isn’t valid any more.").
|
|
817
829
|
- **Tests:** `test/integration/follow-guests.test.mjs` invites a guest from a real owner's Network panel against the fake hub, joins from a second browser, delivers an approved guest message, checks that a guest can't stop, abort, steer or reconfigure the cone (its message lands as a follow-up after the owner's run, never in it), can't reach sudo decisions, `connectAgent` or any other stream kind, that a follower sees the seat, and that Revoke closes the link at once and the link is refused after.
|
|
818
|
-
- **Public previews**
|
|
819
|
-
- **Each request:** `{ reqId, servedRoot, vfsPath, asText, range? }`. A `vfsPath` outside `servedRoot` (six's `isPathWithinServedRoot`: not absolute, a `.` or `..` segment, `%2e` in any case, or a served root of `/`) is `403`. A served root this seven doesn't serve is `404` `this preview is no longer served`. Otherwise the page sends `GET <path>` with the visitor's `Range` and `accept-encoding: identity` to the port through `kernel.loopbackFetch`; `<path>` is `vfsPath` without the served root, and `/` for the default entry. Same-origin redirects (to `<port>.kernel.localhost`, `127.0.0.1:<port>` or `localhost:<port>`) are followed up to 5 times, and the whole answer has 25 s.
|
|
820
|
-
- **The answer:** `preview.response` chunks of 64 KiB (`reqId`, `ok`, `mime`, `chunkIndex`, `totalChunks`, `content`, `encoding`, `status`, `size`, `range`), with the server's `Content-Type` (by the file name when it sends none). A `200` is UTF-8 when the hub asked for text and the bytes are UTF-8, base64 otherwise, and is refused with `413` `preview file exceeds 25 MiB limit` once it declares or sends more than 25 MiB. A `206` is always base64, carries `size` and `range` from its `Content-Range`, and is cut to 8 MiB, which the visitor's next range continues; an empty one is `416` with the size. A `416` keeps the size from `Content-Range: bytes */<size>`. Any other status is `ok: false` with the first 4 KiB of the body as `reason`, a port that doesn't answer `502` `nothing answers on kernel port <port>: …`, and one that hangs `504`.
|
|
821
|
-
- **Revoked and replayed:** `preview.revoked` ends that preview's `serve.publish` request (`revoked by the tray hub`), and `preview.state` (which the hub replays on every connect) is kept with the preview. A preview is live only while its request is, and a reload ends every kernel process, so at every `leader.connected`, at boot and after a reconnect, the page lists the tray's previews (`GET /api/tray/<trayId>/previews`) and revokes each live one under `/srv/serve/` that it doesn't serve, as slicc-serve's relay does after each connect. Persistent (`--ttl`) previews stay.
|
|
822
|
-
- **Routes:** mint, stop and list go to the hub with the controller token, and a snapshot's uploads and finalize with its upload token, through the sliccy-ai worker's same-origin proxy on `*.sliccy.ai` like the other tray routes.
|
|
830
|
+
- **Public previews** don't go through the tray: the page publishes on sliccy-ai's serve hub with a host of its own (see [Public previews](#requests-from-programs-devembedder)). A `serve-<16 hex>` `webhook.event` that comes through the tray is dropped.
|
|
823
831
|
- **The tray:** its capabilities are kept in `localStorage` (`slicc-os.tray`), so the join URL survives reloads. A hub that forgot the tray gets a new one. The leader socket pings every 30 s and reconnects with backoff. Elsewhere (`localhost`, tests) the tray starts only when `localStorage['slicc-os.tray-hub']` names a hub.
|
|
824
832
|
- **Kernel side:** the kernel gets one uplink and one route table, the union of what the active exits offer, pushed with `kernel.setRoutes`.
|
|
825
833
|
- **Choosing an exit:** for each destination, an exit that claims it (a tailnet address or MagicDNS name) wins. Otherwise the default exit takes it: the one that offers a default route, for example Tailscale with an exit node. Otherwise HTTP stays on the picked transport, and raw connections are `ENETUNREACH`.
|
|
@@ -861,7 +869,7 @@ A server running inside the kernel (vite, `python -m http.server`, impeccable `l
|
|
|
861
869
|
- The headers take longer than 30 s: `504` `sw: no answer from kernel port <port> for <path> in 30 s`.
|
|
862
870
|
- After the headers, the 30 s applies to each chunk, not to the whole response. A stream that stays silent for 30 s is ended and its socket closed. `EventSource` reconnects by itself, so a server should send a comment line as a heartbeat. Chrome may also stop the service worker during a long stream, and `EventSource` reconnects then too.
|
|
863
871
|
|
|
864
|
-
- **Publishing one.** `serve DIR` and `serve --port <n>` publish a kernel server at a public URL (see [Public previews](#requests-from-programs-devembedder)). The
|
|
872
|
+
- **Publishing one.** `serve DIR` and `serve --port <n>` publish a kernel server at a public URL (see [Public previews](#requests-from-programs-devembedder)). The serve hub's relay reaches it over `kernel.dial` with every method, the query string and the request's headers and body.
|
|
865
873
|
|
|
866
874
|
What doesn't work through the service worker:
|
|
867
875
|
|