@vibechain/os 0.4.1 → 0.5.1

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 (84) hide show
  1. package/AGENTS.md +80 -48
  2. package/README.md +143 -55
  3. package/SECURITY.md +47 -20
  4. package/dist/app-client.d.ts +4 -1
  5. package/dist/app-client.js +15 -4
  6. package/dist/app-host.d.ts +124 -9
  7. package/dist/app-host.js +395 -57
  8. package/dist/app-protocol.d.ts +17 -1
  9. package/dist/app-protocol.js +12 -0
  10. package/dist/app-runtime.d.ts +18 -2
  11. package/dist/app-runtime.js +75 -11
  12. package/dist/app-wire.d.ts +215 -0
  13. package/dist/app-wire.js +268 -0
  14. package/dist/browser.d.ts +3 -0
  15. package/dist/browser.js +3 -0
  16. package/dist/bundle.js +6 -6
  17. package/dist/canvas.d.ts +2 -2
  18. package/dist/canvas.js +3 -1
  19. package/dist/capture.d.ts +22 -0
  20. package/dist/capture.js +99 -0
  21. package/dist/check.d.ts +12 -0
  22. package/dist/check.js +167 -0
  23. package/dist/cli-publish.d.ts +24 -0
  24. package/dist/cli-publish.js +288 -0
  25. package/dist/cli-session.d.ts +108 -0
  26. package/dist/cli-session.js +245 -0
  27. package/dist/cli.d.ts +10 -0
  28. package/dist/cli.js +46 -10
  29. package/dist/index.d.ts +8 -0
  30. package/dist/index.js +4 -0
  31. package/dist/links.d.ts +15 -0
  32. package/dist/links.js +41 -0
  33. package/dist/listing.d.ts +3 -3
  34. package/dist/listing.js +1 -1
  35. package/dist/loop.d.ts +18 -2
  36. package/dist/loop.js +13 -1
  37. package/dist/manifest.d.ts +90 -4
  38. package/dist/manifest.js +340 -5
  39. package/dist/os.d.ts +63 -0
  40. package/dist/os.js +383 -0
  41. package/dist/preview-parent.d.ts +42 -0
  42. package/dist/preview-parent.js +134 -11
  43. package/dist/preview-ui.js +1 -1
  44. package/dist/preview.js +25 -7
  45. package/dist/redact.d.ts +6 -0
  46. package/dist/redact.js +16 -0
  47. package/dist/runtime-policy.d.ts +20 -0
  48. package/dist/runtime-policy.js +45 -0
  49. package/dist/scaffold.d.ts +13 -2
  50. package/dist/scaffold.js +95 -31
  51. package/dist/submit-notice.d.ts +26 -0
  52. package/dist/submit-notice.js +34 -0
  53. package/dist/templates/plain/game.js +18 -0
  54. package/dist/testing.d.ts +68 -0
  55. package/dist/testing.js +181 -1
  56. package/dist/transport.d.ts +22 -0
  57. package/dist/transport.js +71 -19
  58. package/dist/vibemarket-os.js +1 -0
  59. package/dist/worker.d.ts +18 -0
  60. package/dist/worker.js +34 -0
  61. package/examples/paw-beat/README.md +20 -8
  62. package/examples/paw-beat/cat.ts +665 -89
  63. package/examples/paw-beat/game.ts +162 -28
  64. package/examples/paw-beat/index.html +114 -40
  65. package/examples/paw-beat/main.ts +264 -149
  66. package/examples/paw-beat/music.ts +314 -65
  67. package/examples/paw-beat/stage.ts +560 -0
  68. package/examples/paw-beat/store/icon.png +0 -0
  69. package/examples/paw-beat/store/screenshot-1.webp +0 -0
  70. package/examples/paw-beat/store/screenshot-2.webp +0 -0
  71. package/examples/paw-beat/vibemarket.json +2 -2
  72. package/examples/vibexp-app/README.md +7 -7
  73. package/examples/vibexp-app/index.html +3 -2
  74. package/examples/vibexp-app/plain/game.ts +20 -0
  75. package/examples/vibexp-app/plain/index.html +6 -0
  76. package/examples/vibexp-app/plain/vibemarket.json +17 -0
  77. package/examples/vibexp-app/src/main.ts +46 -31
  78. package/examples/vibexp-app/store/icon.png +0 -0
  79. package/examples/vibexp-app/three/README.md +21 -0
  80. package/examples/vibexp-app/three/index.html +4 -0
  81. package/examples/vibexp-app/three/src/main.ts +45 -0
  82. package/examples/vibexp-app/three/vibemarket.json +19 -0
  83. package/examples/vibexp-app/vibemarket.json +17 -11
  84. package/package.json +6 -2
package/SECURITY.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # VibeMarket OS app security and resource contract
2
2
 
3
- These are bounded browser host controls, not a certification that arbitrary web code is safe. They grant no host identity or economy access. Native shells are refused. Store submission and review are checked by the VibeStore service, not by this package, and are not described here as open.
3
+ These are bounded browser host controls, not a certification that arbitrary web code is safe. They grant no economy, wallet or payment access and no credential for any vibechain.com route. What an app can receive is listed under Boundary: its own save, the card holdings its manifest declares, the player's public identity (handle, @name, display name, picture), and, for apps that declare servers, a short-lived signed statement of that identity for those servers. Native shells are refused, with one narrow exception for the VibeMarket Steam client described under Host admission. Store submission and review are checked by the VibeStore service, not by this package, and are not described here as open.
4
4
 
5
5
  ## Host admission
6
6
 
@@ -13,10 +13,16 @@ These are bounded browser host controls, not a certification that arbitrary web
13
13
 
14
14
  Every other origin is refused, including other `https` hosts and subdomains, plain `http` to the production names and any explicit port on them. A framed host is refused. Known native bridge markers (`__VM_STEAM__`, `__TAURI_INTERNALS__`, `__TAURI__`, `vibeNative`, `ReactNativeWebView`) and embedded user agents (Tauri, Electron, VibeSteam, VibeMarketDesktop, Android `wv`) are refused on every host. Admission is a refusal policy: the absence of a marker does not certify an unknown webview.
15
15
 
16
+ **Steam client claim.** On the VibeMarket OS website only (`https://vibechain.com` or `https://www.vibechain.com`, default port, top-level window), a window whose own data property `__VM_STEAM__` holds a plain object (prototype `Object.prototype` or `null`, frozen or not) whose own data property `appFrames` is exactly the number `1` is not refused for the two markers that client always carries, `__VM_STEAM__` and `__TAURI_INTERNALS__`. The flag is read once, from its property descriptor, so no getter runs. An accessor, an inherited property, any other value (`0`, `"1"`, `true`, absent) or a marker that is not a plain object counts as no flag and is refused with the same native-shell message as before. With the flag present every other marker (`__TAURI__`, `vibeNative`, `ReactNativeWebView`) and every embedded user agent is still refused, and the flag changes nothing on the local preview, on any other origin or in a framed host, which keep their own messages. The Steam client sets no custom user agent, so it presents its platform webview's default (WKWebView, WebView2 or WebKitGTK), which matches none of the refused agent patterns.
17
+
18
+ The flag is a claim made by the client's page-level marker, not a credential. Only Steam client builds that carry the client's app-frame guard set it, and only on a platform where that build passed a manual hostile-app test. This package cannot verify any of that: the claim is not authenticated, a webview that copies the marker makes the same claim, and the check proves nothing about the client's IPC scope, its navigation and window policy or whether its bridge is reachable from a sandboxed frame. It shows only that the page is the top-level website on its production origin and that the shell asserts the guard. Inside an admitted Steam client, app isolation still rests on the frame's sandbox and opaque origin (`mountAppFrame` still accepts its bootstrap only from origin `null`), on the website's runtime headers and on the client's own guard.
19
+
20
+ **Shipped Steam clients, by platform.** Steam client builds already in players' hands carry no version, no custom user agent and no `appFrames` key, so the website holds a second admission path for them: `SHIPPED_CLIENT_FRAMES` in `app-runtime.ts`, one entry per platform (`windows`, `macos`, `linux`), all `1` since 2026-11-23 (the owner's decision on the automated frame harness's results on all three platforms, recorded in `vibemarket-desktop/docs/frame-probe-results/ci-2026-11-23.md`; no person has run the probe inside the shipped client). On the production website, top-level, a window whose `__VM_STEAM__` is the same own plain-object marker is not refused for the client's two markers when the platform named by its webview's default user agent has entry `1`. The platform is read conservatively from the whole agent string: WebView2's Edge agent on `Windows NT` for Windows, WKWebView's agent on `Macintosh` with no `Version/` or `Safari/` tokens for macOS, WebKitGTK's agent on `X11; Linux` for Linux; any other agent, or one with an extra token, is no platform and refuses. A `1` means the owner admitted that platform on the evidence recorded beside the entry: either a person ran the frame probe (`vibechain/components/os-apps/frame-probe`, opened from the desk) inside the shipped client on that platform and every native command it tries came back unreachable from the sandboxed frame, or the automated frame harness (`vibemarket-desktop/docs/FRAME-HARNESS.md`) ran the shipped build's own configuration and pinned framework on that platform's webview and its native-side log showed no command body run because of a frame. The harness is not the players' binary and not their own webview runtime. Either way it is evidence about what was tested, not about future builds, and the user agent cannot tell a WebView2 page from the Edge browser or one client build from another; the marker, the production origin and the other refusals still apply. The table and its pinned test change only in a reviewed commit.
21
+
16
22
  ## Runtime origins
17
23
 
18
24
  - **Local preview.** `os preview` serves the parent page from `127.0.0.1` and the app from a different host, `localhost`, on the same port.
19
- - **vibechain.com.** Apps are served by the website on the same origin as the desktop, under `/os/runtime/external/<appId>/<versionKey>/<file>`, where `versionKey` names one immutable version. There is no separate app domain. On the same origin exactly one thing keeps an app's HTML from running as `vibechain.com` with the player's session: the sandbox, which gives the document an opaque origin. The website's runtime route is therefore required to send `Content-Security-Policy: sandbox allow-scripts` on every response under that path, to serve HTML only to frame requests, to answer errors as plain text, to use fixed content types with `nosniff`, and to ignore and never set cookies. Those controls live in the website, not in this package, and this package cannot enforce them. What remains after them: browsers may run an app in the same process as the desktop, and the protection depends on those headers being right on every response. A separate registrable domain would be stronger; moving to one later is a routing change.
25
+ - **vibechain.com.** Apps are served by the website on the same origin as the desktop, under `/os/runtime/external/<appId>/<versionKey>/<file>`, where `versionKey` names one immutable version. There is no separate app domain. On the same origin exactly one thing keeps an app's HTML from running as `vibechain.com` with the player's session: the sandbox, which gives the document an opaque origin. The website's runtime route is therefore required to send `Content-Security-Policy: sandbox allow-scripts allow-pointer-lock` (from `appRuntimeCsp` in this package, the one generator both the website and the preview use) on every response under that path, to serve HTML only to frame requests, to answer errors as plain text, to use fixed content types with `nosniff`, and to ignore and never set cookies. Those controls live in the website, not in this package, and this package cannot enforce them. What remains after them: browsers may run an app in the same process as the desktop, and the protection depends on those headers being right on every response. A separate registrable domain would be stronger; moving to one later is a routing change.
20
26
 
21
27
  `mountAppFrame` accepts the bootstrap only from its own frame's window with origin `null`, on both hosts. If a response ever arrived without the sandbox, the app would not be able to connect to the host, but its code would already have run with the site's origin; the connection check is not a substitute for the header.
22
28
 
@@ -25,31 +31,52 @@ Every other origin is refused, including other `https` hosts and subdomains, pla
25
31
  - App code executes in an iframe with `sandbox="allow-scripts"`, without `allow-same-origin`, top navigation, popups, forms or downloads. Runtime HTTP CSP also carries `sandbox allow-scripts`, including direct visits. The host checks its browser/native policy before creating a frame. Never inject third-party JavaScript into the desktop React realm or a privileged native webview.
26
32
  - Admission binds the exact iframe WindowProxy, opaque origin `null`, one unpredictable 128-bit URL challenge, then a private MessagePort with a fresh 128-bit session. `null` is not an identity by itself. Bootstrap is ≤256-byte JSON and ≤32 messages from that child; unrelated windows receive no port. The global listener is removed after connection.
27
33
  - The additive app codec uses bounded JSON on the existing channel/envelope/port transport. Legacy Market messages stay unchanged. Wrong session, replayed IDs, unknown methods, invalid schemas, malformed/oversized messages and quota exhaustion close the port. No implicit Market permissions are inherited.
28
- - Close, navigation, minimize, app focus loss, hidden document, identity or package change revoke the active generation. Minimize/focus loss preserves only the same app's host-accepted bounded checkpoint. Restore creates a fresh iframe, challenge and session. Host focus uses desktop policy, not the browser `blur` event caused by focusing the child itself.
29
- - The app receives no host authentication, wallet address, profile, inventory, Steam ticket, native handle, money or arbitrary HTTP relay. Checkpoint contains only its own supplied JSON; it is parsed, never merged into host objects. An app must not ask people to enter secrets inside its UI.
34
+ - Close, navigation, minimize, hidden document, identity or package change revoke the active generation, and so does losing the front to another desktop window once a 60 second grace has run out. Within the grace the website's desk keeps the backgrounded frame and its session: the app is sent `active: false`, the frame is `display: none` and inert (never painted, hit or focused; the keyboard goes back to the desk), and its `game.finish` and `app.checkpoint.set` requests are withheld, neither applied nor answered, as they would be lost for a suspended app; reads are answered, saves (`app.save.set`, protocol 2) are accepted because that is when a game saves, `pack.show` and the display methods answer `not-permitted`, and every request still counts against the limits below. Returning in front within the grace re-activates the same frame, controller and session. The grace timer is the host's, starts when the window leaves the front, and nothing the app sends extends it; at most one app frame lives on the page, and opening another app tears the backgrounded one down at once. This is a cooperative pause, not a sandbox: until the host's frame-time watchdog exists (it does not yet), a hostile backgrounded app can keep its timers, workers and audio running for up to 60 seconds (Chromium stops a hidden frame's animation frames; WebKit does not), bounded only by the one-frame cap, the grace and the immediate teardown on a hidden page. Revocation preserves only the same app's host-accepted bounded checkpoint. Restore after revocation creates a fresh iframe, challenge and session. Host focus uses desktop policy, not the browser `blur` event caused by focusing the child itself.
35
+ - The app receives no session, Steam ID, account id, balance, wallet address, Steam ticket, native handle, money, arbitrary HTTP relay or credential for any vibechain.com route. What it can receive (protocol 2, after `host.hello`): its own save (JSON it wrote, at most 1 MiB, parsed and validated, never merged into host objects); the card holdings its manifest declares (`cards: "linked"` for its effective linked packs, `cards: "all"` for every vmOS pack the player holds, with no prompt; card id, pack slug, name, rarity, count and an art path under the app's own prefix, never an internal pack id, pull id, Nugget or Printer Cash amount or foil); public pack card lists; and who is playing (owner decision 2026-11-23, "just tell the app who the user is"): for every schema 3 app, without a permission, the player's public vmOS identity, exactly what their public profile shows anyone (the fixed `handle`, the @`username` when it differs, the display `name` and the profile `picture` as a path under the app's own prefix), or `{ guest: true }` for a guest; and, only for apps whose manifest declares `network`, a 5-minute Ed25519 token stating that identity, whose audience is the app id and which no vibechain.com route accepts. The host re-checks every card, pack and player value against strict shapes before it reaches the app, so an extra field cannot ride along. There is no anonymous or per-app id: the same player is the same handle in every app, so apps can recognize and correlate a player, and everything an app sends to its declared servers (identity, holdings, save, gameplay) reaches them tied to the player's public profile, together with the player's IP address. The listing says what an app can see and where it connects. Checkpoints (legacy) contain only the app's own JSON. An app must not ask people to enter secrets inside its UI.
30
36
  - `game.finish` accepts only an integer score from 0 through 1,000,000,000. It cannot carry Cash, XP, receipts or grant instructions. The first score is retained across suspension; same-score retries acknowledge without a second host callback, and changed scores are refused. The host posts its acknowledgement before notifying its results UI. Callback throws or acknowledgement failure never authorize another award. Stale generations cannot notify the host. A reported score is not reward proof; only a separately registered host/server policy can confirm an existing Cash award.
31
37
 
32
38
  ## Enforced accepted-work limits
33
39
 
34
- | Boundary | Limit |
35
- |---|---:|
36
- | App checkpoint | 32KiB UTF-8; depth8; 2,048nodes; 64keys/object; 256items/array; 8KiB/string |
37
- | Request / response | 34KiB UTF-8 JSON each, cheap character cap before encoding/parsing |
38
- | In-flight requests | 4 per active generation |
39
- | Request rate | 10 per fixed one-second host interval; exhaustion terminates |
40
- | Cumulative requests / IDs | 5,000 per open app controller, including suspended generations |
41
- | Absolute controller lifetime / readiness | 15minutes across suspension and remounts /15seconds |
42
- | App-side request wait | 10seconds |
43
- | Built bundle | Existing256 total entries, 16MiB/file, 64MiB expanded; ZIP20MiB |
44
- | Schema version 2 bundle | No SVG files; store icon a 256 x 256 PNG ≤256KiB; 1–4 screenshots ≤1MiB each, signature matching the extension |
45
- | First Desk adapter | One open third-party app controller and at most one untrusted iframe |
46
-
47
- The local preview snapshots admitted files once using bounded no-follow file-handle reads, then serves only that immutable in-memory map and exact fixed host assets. It has no URL proxy, arbitrary filesystem route, write route or credential. Local filesystem authoring is not the public upload trust boundary; the existing ZIP validator remains responsible for untrusted uploads. The preview requires `127.0.0.1` for the parent and a different `localhost` runtime host, validates Host headers, never auto-opens a browser, and closes owned connections on shutdown.
40
+ A host that supplies protocol 2 services (an apps3 host: the desk with its `apps3` flag on, and the local preview) applies the right-hand column to every session, protocol 1 clients included. A host without services is exactly the 0.4 host (left column).
41
+
42
+ | Boundary | 0.4 host | apps3 host |
43
+ |---|---:|---:|
44
+ | App checkpoint (legacy) | 32KiB UTF-8; depth8; 2,048nodes; 64keys/object; 256items/array; 8KiB/string | same |
45
+ | Save (`os.save`) | none | 1 MiB UTF-8 JSON, depth 64, finite numbers; one write in flight, one per 10 s (soft, `rate-limited`); the backend also bounds 8 MiB per account and 16 MiB written per hour |
46
+ | Request / response | 34KiB UTF-8 JSON each, cheap character cap before encoding/parsing | 34 KiB before `host.hello` and for protocol 1 methods; after it, per method (`APP_METHODS_2`): 64 B to 256 B for most requests, 1,100,000 B for a save; responses up to 256 KiB for a page of 500 cards and 1,100,000 B for a save read |
47
+ | In-flight requests | 4 per active generation | 4 before hello, 8 after |
48
+ | Request rate | 10 per fixed one-second host interval; exhaustion terminates | 10 per one-second interval and 120 per rolling minute; exhaustion terminates. Per-method soft rates answer `rate-limited` and keep the session |
49
+ | Request ids | each unique per session | strictly increasing decimal integers per session (every shipped client sends 1, 2, 3, ...) |
50
+ | Cumulative requests | 5,000 per open app controller, including suspended generations | 30,000 (unreachable inside 4 hours at 120 a minute; the minute bound decides) |
51
+ | Controller lifetime / readiness | 15minutes absolute across suspension and remounts / `ready()` within 15seconds | idle prompt after 15 minutes with no user activation and no request, teardown if unanswered (the host's UI); 4 hours absolute / `ready()` within 15 s, or `progress()` at least every 15 s and `ready()` within 120 s |
52
+ | App-side request wait | 10seconds | 10 seconds; the client also paces itself below the host's limits |
53
+ | Built bundle | 2,000 entries, 32 MiB per file, 128 MiB expanded; ZIP 50 MiB (`APP_BUNDLE_LIMITS`; Market games keep `GAME_LIMITS`: 256, 16 MiB, 64 MiB, 20 MiB) | same |
54
+ | Schema version 2 and 3 bundle | No SVG files; store icon a 256 x 256 PNG ≤256KiB; 1–4 screenshots ≤1MiB each, signature matching the extension | same |
55
+ | Schema version 3 manifest | | at most 3 linked packs, 8 declared origins |
56
+ | First Desk adapter | One open third-party app controller and at most one untrusted iframe | same |
57
+
58
+ Policy outcomes (a missing permission, the app loading or behind another window, a soft rate, a missing click, a quota, an unavailable server) are answered with one of nine stable codes and keep the session. Protocol violations (malformed or unknown messages, schema errors, a second hello, a lower or repeated id, a request over its method's bound, the hard limits above) end it. `pack.show`, `card.show` and entering `display.fullscreen` act only while the app is ready and in front; the host additionally checks fresh user activation on its own page and answers `needs-click`. Leaving fullscreen is always allowed.
59
+
60
+ The local preview snapshots admitted files once using bounded no-follow file-handle reads, then serves only that immutable in-memory map, exact fixed host assets and stand-in card art (the bundle's own listing icon, under the version prefix). It is an apps3 host with stand-in services: six fake cards per linked pack, a save in the parent page's own browser storage, and an unsigned placeholder player token for apps that declare `network`; its runtime responses carry the production policy from `appRuntimeCsp`, with the preview's asset prefix and parent. It has no URL proxy, arbitrary filesystem route, write route or credential. Local filesystem authoring is not the public upload trust boundary; the existing ZIP validator remains responsible for untrusted uploads. The preview requires `127.0.0.1` for the parent and a different `localhost` runtime host, validates Host headers, never auto-opens a browser, and closes owned connections on shutdown.
48
61
 
49
62
  ## What these controls cannot promise
50
63
 
51
64
  The browser allocates structured-clone data before host validation. Message byte limits bound accepted host processing, not that prior allocation. An iframe has no portable hard CPU, memory, GPU, event-queue or network quota. A hostile app can still stall or exhaust a browser before removal. Cooperative lifecycle events do not enforce resource fairness; physical iframe removal limits continued execution after suspension but is not an OS process kill certificate.
52
65
 
53
- CSP restricts fetches, assets, workers and embedding, but does not universally prevent a sandboxed app navigating its own frame to an external URL. Navigation revokes the session after load; a request may already have occurred. Do not describe this as a network firewall or supply secrets that require one. Known native bridge markers and embedded user agents are denied; their absence does not certify unknown webviews. Actual native IPC provenance tests are required before native admission.
66
+ The runtime policy (`appRuntimeCsp`, `@vibechain/os/policy`) limits scripts, styles and workers' first scripts to the version's own files, and every fetch, image, media and font to those files plus, for a version whose manifest declares `network`, its declared origins: every origin in `connect-src`, the `https://` ones also in `img-src`, `media-src` and `font-src`, and never in `script-src`, `style-src`, `worker-src`, `child-src`, `frame-src` or `object-src`. Declared origins are re-validated (`networkOrigin`: https or wss, a public DNS name, no IP address in any form, no local, reserved or wildcard-DNS name, no Vibechain domain) and a list that is not normalized throws rather than produce a partial policy. What it cannot stop: text fetched from a declared server run in a `blob:` worker (`worker-src blob:` stays, for engines and decoders), `WebAssembly.instantiate` on fetched bytes, fetched CSS put into a `<style>` element, an interpreter in the bundle running server-sent programs, and server data driving behaviour. So "the reviewed code is the code that runs" holds for the files VibeStore hosts and is listing policy for everything else: an app whose behaviour changes after review because its server says so breaches the listing rules and is removed by revocation; it is not confined. A declared name can also resolve to a private address; Chromium's Private Network Access narrows that in one engine only. Every declared server sees the player's IP address. Network apps may not embed third-party advertising or analytics SDKs (review rule, owner decision 2026-11-23). WebRTC is not governed by CSP: an app can open peer connections in every measured engine, so the listing allows WebRTC only for play between players signalled through declared servers. A sandboxed app can also navigate its own frame to an external URL; navigation revokes the session after load, but a request may already have occurred. Do not describe any of this as a network firewall or supply secrets that require one. Known native bridge markers and embedded user agents are denied, except the Steam client's own two markers when it claims app frames (see Host admission); their absence does not certify unknown webviews, and that claim does not certify the client. Native IPC provenance tests on each platform remain the client's gate before a build sets the flag.
67
+
68
+ **Showing packs and cards (0.5.1).** Any app may show any public pack (one that exists and is not taken down), linked or not: `cards.pack` answers the pack's public face, exactly what its public page shows (name, creator, cover, card names, rarities and art under the app's own prefix) and never holdings, which come only from `cards.list` as the manifest declares. `pack.show` and `card.show` ask the host to open the pack or one card in VibeMarket's market window. `os.open(link)` accepts only the exact app-link grammar (`vmos://pack/<slug>`, `vmos://card/<slug>/<cardId>`, `https://vibechain.com/os/pack/<slug>` or `www.`, at most 200 characters, no percent-encoding, query, fragment, port, user or other host), parses it in the SDK and sends only the parsed slug and card id; neither the SDK nor the host navigates to the string. The host acts only while the app is ready and in front and on fresh user activation on its own page (`needs-click`), at most once per 10 seconds across both methods (`rate-limited`), and answers `invalid` for an unknown or taken-down pack or a card not in it. The market window's Buy and Open controls are the host's own and ignore clicks for 500 ms after it opens, and the app is never told whether anything was bought or opened, so showing a pack tells it nothing new about the player and grants it nothing.
69
+
70
+ **Player identity.** An app learns the player's public identity and nothing private: the handle, @name, display name and picture their public profile already shows. The token is a 5-minute Ed25519 JWT (`sub` = the handle, plus `username`, `name`, `guest: false`, `aud` = the app id) signed by the backend only, for apps that declare `network`, so their servers can trust who is playing instead of a handle the client claims; guests get none; public keys are at `https://vibechain.com/.well-known/vmos-app-keys.json`. It is a statement for the app's own server, not a credential: no vibechain.com route accepts it. A server that does not check `aud` would accept another app's tokens; the verification sample in the docs (https://vibechain.com/os/docs#sdk-05-verify) checks it. Within its 5 minutes a token can be replayed; servers that need one-time use keep `jti`.
71
+
72
+ **Owner decisions applied (2026-11-23).** An app is told who is playing (its public identity; no anonymous ids), and `cards: "all"` reads every vmOS pack the player holds with no consent prompt: the listing discloses both. Fullscreen goes through the host: the app's window, with a host-drawn strip naming the app and offering Report and Exit, enters the browser's full screen; the frame never gets the Fullscreen API (`fullscreen=()` stays in the runtime's Permissions-Policy) and Escape always leaves. Saves are kept on uninstall and revocation, deleted after 365 days without a write, on the player's request and with the account. Network apps carry no third-party advertising or analytics SDKs (a review rule).
73
+
74
+ Listing third-party apps relies on controls outside this package: publisher authentication, employee review of every version, immutable version digests, revocation, network and abuse budgets, install scope and adversarial tests. The listing checks in this package (`parseManifest`, `checkListing`, the SVG refusal) validate a bundle's shape; they do not review its behaviour. Scores, saves, checkpoints and any deck a game sends its server are untrusted client claims: the player token carries no holdings, so a server cannot ask whether a player really holds a card. Rewards, inventory grants and payments require separate server-authoritative, replay-safe, idempotent and capped verification; they are not implemented by this app API.
75
+
76
+ ## CLI sign-in and tokens
77
+
78
+ `os login` is a browser device grant. The CLI receives a 256-bit device code it alone holds (its poll credential) and an 8-letter user code it shows the person; it never handles a Steam password, a Steam cookie or the website's session. The person approves on `https://vibechain.com/os/cli` with an explicit POST after signing in with Steam there. The resulting token (`vmos_cli_` + 256 random bits) is shown to the CLI once, kept server-side only as a SHA-256 hash, expires 30 days after issue without extension, and is accepted only by the four CLI routes: create a submission, read the account's submissions, read its own identity, revoke itself. Every other route refuses it. A disabled account's tokens stop working.
79
+
80
+ On disk the token lives in the per-user config directory (`0700`) in `credentials.json` (`0600`), written with `O_CREAT | O_EXCL | O_NOFOLLOW` to a new name and renamed into place. On POSIX the CLI refuses a file or directory that is a link, owned by another user, or readable by group or others. Windows has no such mode bits; the file relies on the per-user ACL of `%APPDATA%`. `VIBEMARKET_OS_TOKEN` overrides the file and is never written. The token is never printed, put in a URL or a process argument, or written to the project; errors and `--verbose` output are redacted. Requests go only to `https://vibechain.com` (or a loudly announced loopback development origin), the saved token only to the origin that issued it, and redirects are never followed, so the Authorization header cannot reach another host. The browser opener is called with a fixed argument list and a URL the CLI builds itself.
54
81
 
55
- Listing third-party apps relies on controls outside this package: publisher authentication, employee review of every version, immutable version digests, revocation, network and abuse budgets, install scope and adversarial tests. The listing checks in this package (`parseManifest`, `checkListing`, the SVG refusal) validate a bundle's shape; they do not review its behaviour. Scores/checkpoints are untrusted client claims. Rewards, inventory grants and payments require separate server-authoritative, replay-safe, idempotent and capped verification; they are not implemented by this app API.
82
+ What this cannot promise: anyone who persuades you to approve their code gets a token for your account (submit and read submissions only), so approve only a code your own terminal shows and revoke unknown sign-ins at `/os/cli`. Malware running as your user can read the file, as it could read a browser profile; revoke the sign-in if a machine is compromised.
@@ -1,4 +1,7 @@
1
1
  import { type VibeMarketAppSdk } from "./app-protocol.ts";
2
- /** No profile, inventory, wallet, native, economy or arbitrary storage methods. */
2
+ /**
3
+ * The 0.4 app API: readiness, lifecycle, the window-only checkpoint and one score.
4
+ * @deprecated Use `connect()` from `@vibechain/os`, which works on every host.
5
+ */
3
6
  export declare function connectVibeMarketApp(signal?: AbortSignal): Promise<VibeMarketAppSdk>;
4
7
  export declare function createAppPortSdk(port: MessagePort, session: string): VibeMarketAppSdk;
@@ -1,7 +1,11 @@
1
- import { APP_FRAGMENT, APP_LIMITS, appNonce, checkpointValue, lifecycleValue } from "./app-protocol.js";
1
+ import { APP_FRAGMENT, APP_LIMITS, appNonce, checkpointValue, lifecycleValue, FRAME_MESSAGE_BYTES } from "./app-protocol.js";
2
2
  import { connectHostPort, createRpcTransport } from "./transport.js";
3
+ import { createCapturer } from "./capture.js";
3
4
  import { gameFinishInput } from "./completion.js";
4
- /** No profile, inventory, wallet, native, economy or arbitrary storage methods. */
5
+ /**
6
+ * The 0.4 app API: readiness, lifecycle, the window-only checkpoint and one score.
7
+ * @deprecated Use `connect()` from `@vibechain/os`, which works on every host.
8
+ */
5
9
  export async function connectVibeMarketApp(signal) {
6
10
  const challenge = new URLSearchParams(window.location.hash.slice(1)).get(APP_FRAGMENT);
7
11
  if (!appNonce(challenge))
@@ -19,8 +23,12 @@ export function createAppPortSdk(port, session) {
19
23
  let state = Object.freeze({ active: true, width: 0, height: 0 });
20
24
  const listeners = new Set();
21
25
  const transport = createRpcTransport(port, {
22
- session, timeoutMs: APP_LIMITS.requestTimeoutMs, maxPending: APP_LIMITS.inFlight, jsonBytes: APP_LIMITS.responseBytes,
26
+ session, timeoutMs: APP_LIMITS.requestTimeoutMs, maxPending: APP_LIMITS.inFlight, jsonBytes: APP_LIMITS.responseBytes, outBytes: FRAME_MESSAGE_BYTES,
23
27
  onEvent(value) {
28
+ if (value.event === "app.capture") {
29
+ capturer.event(value.id);
30
+ return;
31
+ }
24
32
  if (value.event !== "app.lifecycle")
25
33
  return;
26
34
  try {
@@ -33,6 +41,8 @@ export function createAppPortSdk(port, session) {
33
41
  listener(state);
34
42
  },
35
43
  });
44
+ const capturer = createCapturer((id, image) => { transport.request({ method: "app.frame", id, image }).catch(() => { }); }, () => destroyed);
45
+ let destroyed = false;
36
46
  const complete = (result) => { if (!("completed" in result) || result.completed !== true)
37
47
  throw Error("Invalid app acknowledgement."); };
38
48
  return Object.freeze({
@@ -44,6 +54,7 @@ export function createAppPortSdk(port, session) {
44
54
  async write(value) { complete(await transport.request({ method: "app.checkpoint.set", value: checkpointValue(value) })); },
45
55
  }),
46
56
  lifecycle: Object.freeze({ current: () => state, onChanged(listener) { listeners.add(listener); return () => { listeners.delete(listener); }; } }),
47
- destroy() { listeners.clear(); transport.destroy(); },
57
+ onCapture(handler) { return capturer.on(handler); },
58
+ destroy() { destroyed = true; capturer.clear(); listeners.clear(); transport.destroy(); },
48
59
  });
49
60
  }
@@ -1,31 +1,146 @@
1
1
  import type { GameFinishInput } from "./completion.ts";
2
2
  import { type AppLifecycle } from "./app-protocol.ts";
3
+ import { type Player, type WireCard, type WirePack, type WirePackSummary } from "./app-wire.ts";
3
4
  export interface AppSession {
4
5
  lifecycle(value: AppLifecycle): void;
5
6
  close(): void;
7
+ /**
8
+ * Ask a protocol 2 app for its current frame (`app.capture` / `app.frame`): a PNG, JPEG or WebP data URL, or null when
9
+ * there is none (protocol 1, no hello yet, the app has no picture, the timeout, the session ended, a newer capture took
10
+ * over). One capture is pending at a time. Never rejects.
11
+ */
12
+ capture(timeoutMs?: number): Promise<string | null>;
13
+ }
14
+ /**
15
+ * `current`: this generation is the live one (its frame is mounted for this app and the page is shown). `foreground`: its
16
+ * window is in front. A generation that is current but not in the foreground is backgrounded: the host keeps its frame
17
+ * for a grace period and has told it `active: false`. While backgrounded, reads are answered (`ui.ready`,
18
+ * `app.checkpoint.get`), but writes (`game.finish`, `app.checkpoint.set`) are withheld: not applied and not answered, as
19
+ * for a suspended app whose session is gone (the app's own request times out). They still count against every request
20
+ * limit. Without `foreground` a generation is always in the foreground, as before. `progress`: a protocol 2 app reported
21
+ * loading progress (0 to 1) before it was ready.
22
+ */
23
+ export interface AppAttachOptions {
24
+ current: () => boolean;
25
+ foreground?: () => boolean;
26
+ ready: () => void;
27
+ finish?: (result: Readonly<GameFinishInput>) => void;
28
+ fault: (message: string) => void;
29
+ progress?: (fraction: number) => void;
30
+ }
31
+ /**
32
+ * The I/O an apps3 host (the desk, the preview, a test) supplies for protocol 2, one object per open app. The controller
33
+ * owns the protocol (shapes, sizes, rates, window states, paging, coalescing rules, card diffs); these functions own
34
+ * permission and storage. Throw an AppHostError to answer a code (`not-permitted` for `cards: "none"`, `needs-click`
35
+ * without a fresh activation, `too-large` for the account's 8 MiB, `rate-limited`); any other throw answers `unavailable`.
36
+ * Every value they return is re-checked against the strict wire shapes before it reaches the app.
37
+ */
38
+ export interface AppHostServices {
39
+ /** whether the player is a guest (their save lives only while the window is open) */
40
+ readonly guest: boolean;
41
+ /** the manifest's entry, so art paths resolve against the version prefix */
42
+ readonly entry: string;
43
+ /** the stored save as JSON text, or nulls; prefetched on open */
44
+ saveGet(): Promise<{
45
+ value: string | null;
46
+ savedAt: string | null;
47
+ }>;
48
+ /** store JSON text (already checked: at most 1 MiB, depth 64) */
49
+ saveSet(text: string): Promise<{
50
+ savedAt: string;
51
+ }>;
52
+ /** the permitted holdings, whole, with the revision of the answer; throw `not-permitted` for `cards: "none"` */
53
+ cards(): Promise<{
54
+ cards: WireCard[];
55
+ revision: string;
56
+ }>;
57
+ /** the permitted packs with what the player holds of each */
58
+ packs(): Promise<WirePackSummary[]>;
59
+ /** the public face of any public pack (exists, not taken down): never holdings; throw `invalid` for an unknown or taken-down pack */
60
+ pack(slug: string): Promise<WirePack>;
61
+ /** open the market window on any public pack; throw `needs-click` without a fresh activation, `invalid` for an unknown or taken-down pack */
62
+ showPack(slug: string): Promise<void>;
63
+ /**
64
+ * open that card in its pack's page (0.5.1); the same rules as `showPack`, and `invalid` for a card not in the pack. Without it
65
+ * the host does not offer `card.show`, and a 0.5.1 client answers `os.showCard` with `unsupported` itself.
66
+ */
67
+ showCard?(slug: string, card: string): Promise<void>;
68
+ /** the player's public identity (`picture` as a path after the version prefix), or `{ guest: true }`; `token` and `expiresAt` only for an app that declares `network` */
69
+ player(): Promise<Player>;
70
+ maximize(on: boolean): Promise<void>;
71
+ fullscreen(on: boolean): Promise<void>;
72
+ }
73
+ export interface AppControllerOptions {
74
+ /** protocol 2 and the apps3 lifetime (15 minutes idle, 4 hours absolute); without it the controller is exactly protocol 1 */
75
+ services?: AppHostServices;
76
+ /** no activity for 15 minutes: show "Still playing?" and call `activity()` on an answer, or tear down */
77
+ idle?: () => void;
6
78
  }
7
79
  export interface AppController {
8
- attach(port: MessagePort, session: string, options: {
9
- current: () => boolean;
10
- ready: () => void;
11
- finish?: (result: Readonly<GameFinishInput>) => void;
12
- fault: (message: string) => void;
13
- }): AppSession;
80
+ attach(port: MessagePort, session: string, options: AppAttachOptions): AppSession;
14
81
  suspend(): void;
15
82
  dispose(): void;
83
+ /** 2 when the host offers protocol 2 (it has services), else 1 */
84
+ readonly protocol?: 1 | 2;
85
+ /** the host saw user activation in the app's window (sampled while it is in front); resets the idle timer */
86
+ activity?(): void;
87
+ /** holdings may have changed (a pull, gift, trade, or the window returned to the front): diff and tell a watching app */
88
+ cardsChanged?(): Promise<void>;
16
89
  }
17
90
  /** A single installation/window owns only the JSON this same app host-accepted. */
18
- export declare function createAppController(clock?: () => number): AppController;
91
+ export declare function createAppController(clock?: () => number, options?: AppControllerOptions): AppController;
19
92
  export interface AppFrameOptions {
20
93
  controller: AppController;
21
94
  challenge: string;
22
95
  current: () => boolean;
23
96
  ready: () => void;
24
97
  fault: (message: string) => void;
98
+ /** whether the app's window is in front (AppAttachOptions); `setActive` tells the app the same */
99
+ foreground?: () => boolean;
25
100
  finish?: (result: Readonly<GameFinishInput>) => void;
101
+ /** protocol 2: the app's loading progress, 0 to 1, for the host's loading bar */
102
+ progress?: (fraction: number) => void;
26
103
  }
27
- /** Caller supplies the already-validated immutable URL, including this generation's fragment. */
28
- export declare function mountAppFrame(frame: HTMLIFrameElement, options: AppFrameOptions): {
104
+ /** One mounted frame. `setActive` sends the app its lifecycle's `active` flag; `resize` keeps it. */
105
+ export interface MountedAppFrame {
29
106
  resize(width: number, height: number): void;
107
+ setActive(active: boolean): void;
30
108
  dispose(): void;
109
+ /** the app's current frame as a data URL (see `AppSession.capture`), or null; also null when there is no session or it ended */
110
+ capture(timeoutMs?: number): Promise<string | null>;
111
+ }
112
+ /**
113
+ * Caller supplies the already-validated immutable URL, including this generation's fragment. With a protocol 2
114
+ * controller the transfer advertises `protocol: 2`, and readiness is `ready()` within 15 s, or `progress()` at least
115
+ * every 15 s and `ready()` within 120 s.
116
+ */
117
+ export declare function mountAppFrame(frame: HTMLIFrameElement, options: AppFrameOptions): MountedAppFrame;
118
+ /** The art and pack fields of the backend's card read (`AppCardsReply` in vibemarket/steam/os-apps.ts), structurally. */
119
+ export interface AppCardsReplyShape {
120
+ packs: readonly {
121
+ slug: string;
122
+ name: string;
123
+ creator: string | null;
124
+ total: number;
125
+ held: number;
126
+ cover: boolean;
127
+ }[];
128
+ cards: readonly {
129
+ pack: string;
130
+ card: string;
131
+ name: string;
132
+ rarity: number;
133
+ count: number;
134
+ art: boolean;
135
+ }[];
136
+ revision: string;
137
+ }
138
+ /**
139
+ * The backend's card read as an app sees it, for an apps3 host's services: rarity numbers named, ids joined, and art as the
140
+ * path after the version prefix only where the backend has servable art and the card id can be a path segment.
141
+ */
142
+ export declare function appCardsView(reply: AppCardsReplyShape): {
143
+ packs: WirePackSummary[];
144
+ cards: WireCard[];
145
+ revision: string;
31
146
  };