@ai-ecoverse/slicc-bios 2.9.1 → 2.9.3

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 (2) hide show
  1. package/README.md +2 -2
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -552,14 +552,14 @@ Programs ask seven's page for what only a page can do through the kernel's `/dev
552
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 as `webhook.event` with that `webhookId` and the headers `x-slicc-preview-conn` and `x-slicc-preview-token`. Seven takes one only when the connection is a live tab of that preview token, seven still holds that preview, and the `webhookId` is that preview's; any other is dropped (one from a connection seven doesn't hold with `serve: dropped an emit for <webhook> from a connection seven doesn't hold`), and so is any `serve-<16 hex>` webhook after the preview ends or of a preview it never held. It records the emit and delivers it as a webhook lick with 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
553
  - **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
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 a leader reconnect, 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
- - **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. 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`.
555
+ - **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
556
  - **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
557
  - **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
558
  - **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
559
  - **`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
560
  - **Refusals:** no tray hub (a seven off `*.sliccy.ai` without `slicc-os.tray-hub`) is `ENOTSUP`, `seven publishes previews only through its tray 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 tray not connected yet, 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.
561
561
  - **Tests:** `test/integration/previews.test.mjs` publishes `httptest` on a fake tray hub from a raw `/dev/embedder` request, checks the mint, the chip, `serve.list`, a visit, a 404 from the server, a path outside the served root (403) and a root nobody serves (404), then ends a preview every way (the program killed, the chip's Stop, the hub's revoke, `serve.stop`, the switch, a reload) and checks each one is revoked 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 429 comes back as the reply's `error` line, while an orphan on the tray is revoked at boot and a persistent preview isn't. `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 in seven chunks, ranges (a window, a suffix, an unsatisfiable one), a 404, a 25 MiB+1 file refused with 413 and an 8 MiB window of it. `test/integration/previews-snapshot.test.mjs` sends `serve.snapshot` bodies from the terminal to a fake tray hub: three files (a 70 000-byte binary among them) uploaded with the upload token and their types and finalized, the reply, `serve.list` before and after a reload whose boot sweep revokes 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 mint refused with `PREVIEW_LIMIT`, 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 nothing.
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, webhook or live connection, one from a lingering tab whose preview is gone, an emit name with control characters, a `serve-<16 hex>` webhook seven holds no preview for, 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. 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.
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, webhook or live connection, one from a lingering tab whose preview is gone, an emit name with control characters, a `serve-<16 hex>` webhook seven holds no preview for, 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.
563
563
  - **Bridge tests:** `test/integration/serve-bridge.test.mjs` publishes a `serve --local` server with the bridge on a fake tray hub that serves the preview with SLICC 6's own bootstrap (`@ai-ecoverse/cherry`'s `preview-bridge.js`, a devDependency) and relays the `bridge.*` messages 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
564
  - Kinds seven doesn't list (`open.file`, `open.download`, `open.reveal`, `clipboard.read`) are `ENOTSUP` before the page sees them.
565
565
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/slicc-bios",
3
- "version": "2.9.1",
3
+ "version": "2.9.3",
4
4
  "description": "Slim loader that boots SLICC into OPFS and serves the UI from there",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",