@vibechain/os 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/AGENTS.md +52 -11
  2. package/README.md +115 -20
  3. package/SECURITY.md +6 -4
  4. package/dist/app-client.js +20 -4
  5. package/dist/app-host.d.ts +74 -5
  6. package/dist/app-host.js +94 -6
  7. package/dist/app-protocol.d.ts +21 -0
  8. package/dist/app-protocol.js +9 -0
  9. package/dist/app-wire.d.ts +186 -6
  10. package/dist/app-wire.js +213 -7
  11. package/dist/audio.d.ts +65 -0
  12. package/dist/audio.js +162 -0
  13. package/dist/browser.d.ts +2 -1
  14. package/dist/browser.js +2 -1
  15. package/dist/bundle.d.ts +2 -0
  16. package/dist/bundle.js +5 -3
  17. package/dist/check.js +11 -4
  18. package/dist/cli.js +3 -1
  19. package/dist/commands.d.ts +6 -0
  20. package/dist/commands.js +17 -0
  21. package/dist/fake-services.d.ts +88 -0
  22. package/dist/fake-services.js +132 -0
  23. package/dist/index.d.ts +3 -3
  24. package/dist/index.js +1 -1
  25. package/dist/links.d.ts +13 -0
  26. package/dist/links.js +17 -1
  27. package/dist/listing.d.ts +12 -0
  28. package/dist/listing.js +49 -1
  29. package/dist/manifest.d.ts +76 -1
  30. package/dist/manifest.js +170 -5
  31. package/dist/os.d.ts +83 -5
  32. package/dist/os.js +179 -15
  33. package/dist/preview-parent.d.ts +21 -2
  34. package/dist/preview-parent.js +101 -8
  35. package/dist/preview-surfaces.d.ts +36 -0
  36. package/dist/preview-surfaces.js +84 -0
  37. package/dist/preview-ui.js +1 -1
  38. package/dist/preview.js +4 -2
  39. package/dist/templates/plain/game.js +3 -1
  40. package/dist/testing.d.ts +50 -7
  41. package/dist/testing.js +137 -13
  42. package/dist/transport.d.ts +4 -1
  43. package/dist/transport.js +2 -2
  44. package/dist/vibemarket-os.js +1 -1
  45. package/examples/paw-beat/README.md +38 -10
  46. package/examples/paw-beat/cat.ts +13 -0
  47. package/examples/paw-beat/game.ts +290 -123
  48. package/examples/paw-beat/index.html +20 -4
  49. package/examples/paw-beat/main.ts +156 -48
  50. package/examples/paw-beat/music.ts +72 -337
  51. package/examples/paw-beat/stage.ts +23 -9
  52. package/examples/paw-beat/store/screenshot-1.webp +0 -0
  53. package/examples/paw-beat/store/screenshot-2.webp +0 -0
  54. package/examples/paw-beat/synth.ts +477 -0
  55. package/examples/paw-beat/tracks.ts +286 -0
  56. package/examples/paw-beat/vibemarket.json +15 -8
  57. package/examples/vibexp-app/plain/game.ts +6 -2
  58. package/package.json +7 -1
  59. package/skill.md +471 -0
package/AGENTS.md CHANGED
@@ -1,9 +1,10 @@
1
- # VibeStore app author contract — @vibechain/os 0.5.1
1
+ # VibeStore app author contract — @vibechain/os 0.6.0
2
2
 
3
3
  This is the contract for people and agents building apps for VibeStore, the app
4
4
  store inside VibeMarket OS. Read it with [README.md](README.md) (API, helpers and
5
5
  the listing table) and [SECURITY.md](SECURITY.md) (sandbox and limits). The public
6
- guide is https://vibechain.com/os/docs.
6
+ guide is https://vibechain.com/os/docs. Coding agents: start from the agent skill,
7
+ https://vibechain.com/os/skill.md, generated from this package for its version.
7
8
 
8
9
  ## What you build
9
10
 
@@ -18,7 +19,7 @@ declares in `network` (below).
18
19
  ## Start
19
20
 
20
21
  ```sh
21
- npx --yes @vibechain/os@0.5.1 init my-app # TypeScript + canvas; or --template three, or --template plain
22
+ npx --yes @vibechain/os@0.6.0 init my-app # TypeScript + canvas; or --template three, or --template plain
22
23
  cd my-app
23
24
  npm install
24
25
  npm run build
@@ -44,14 +45,17 @@ os.onPause(() => { void os.save(state); }); // pause, resume and resize
44
45
  await os.ready(); // remove the host's loading state (or os.progress(0.5) while loading)
45
46
  const cards = await os.cards(); // if the manifest declares cards
46
47
  const me = await os.player(); // { guest: false, handle, username?, name, picture } or { guest: true }; plus token with network
47
- await os.finish({ score: 42 });
48
+ await os.finish({ score: 42 }); // also posts to the board "score" (or { score, board })
49
+ await os.unlock("first-win"); // an achievement the manifest declares; vmOS shows the toast
50
+ const receipt = await os.buy("gold-frame"); // from a click: vmOS's own spend dialog, Printer Cash burned
48
51
  ```
49
52
 
50
53
  Every rejection is an `OsError` with a stable `code` (`unsupported`,
51
54
  `not-permitted`, `invalid`, `too-large`, `rate-limited`, `needs-click`,
52
- `unavailable`, `timeout`, `closed`); refusals keep the app running. `game.finish`
55
+ `unavailable`, `timeout`, `closed`, and since 0.6 `cancelled`, `insufficient`,
56
+ `limit`, `guest`); refusals keep the app running. `game.finish`
53
57
  takes one integer score from 0 to 1,000,000,000, once per open window; the host
54
- owns the results screen and the score grants nothing. Saves are coalesced (one
58
+ owns the results screen. The score is display data: it never sets a reward. A finished round of an approved app may earn the player a small amount of Printer Cash, decided and paid by VibeMarket OS within per-player daily caps. The app cannot grant, see or influence the amount, and nothing an app sends is trusted for it. Saves are coalesced (one
55
59
  write per 10 seconds) and kept on the server, except a guest's, which last only
56
60
  while the window is open. `os.pack(slug)`, `os.showPack(slug)`,
57
61
  `os.showCard(slug, cardId)` and `os.open(link)` (app links `vmos://pack/<slug>`,
@@ -63,20 +67,48 @@ gamepads, audio, WebAssembly and `blob:` workers (`spawnWorker`) work; threads
63
67
  and `SharedArrayBuffer` do not. `os.fullscreen()` asks the host after a click.
64
68
  The optional `os.onCapture?.(() => canvasOrDataUrl)` customises the picture the desktop camera takes of your app (by default the SDK sends the largest visible canvas, so canvas and WebGL games need nothing; apps built with an older SDK show a placeholder in desktop photos). Optional helpers: `@vibechain/os/loop`, `@vibechain/os/canvas` and
65
69
  `@vibechain/os/testing` (`createFakeOs`, an in-memory host for unit tests).
70
+
71
+ **Leaderboards, achievements, friends, invites, sharing and spending (0.6).**
72
+ `os.leaderboard()` reads a board and `os.showLeaderboard()` opens vmOS's panel;
73
+ `os.unlock(id)` and `os.achievements()` (achievements pay nothing);
74
+ `os.friends()` (only friends who have the app); `os.invite()` and `os.share()`
75
+ open vmOS's sheets, and `os.launch.invite` or `os.onInvite` carries a friend's
76
+ invite and its `data`; `os.products()`, `os.buy(id)`, `os.purchases()`,
77
+ `os.consume(id)` and `os.receiptToken(id)` (network apps) sell the products the
78
+ manifest declares for Printer Cash, which is burned, never paid to the
79
+ developer. Buying, sharing and inviting need the app in front, a click (for
80
+ `buy` within the last second) and the player's confirmation in a surface vmOS
81
+ draws itself; guests get `guest`. Scores are the app's claims, accepted only in
82
+ a server-timed round. Spending and invite limits exist; their values are not
83
+ published. On an older host each of these answers `unsupported`: hide the
84
+ feature. Product rules: a product delivers what its name and description say,
85
+ inside the app; it is never, and never stands for, money, Nuggets, Steam items,
86
+ cards, packs or anything usable outside the app; a chance-based product shows
87
+ its odds before the dialog can open; nothing the screenshots show may need a
88
+ purchase; prices change only in a new reviewed version.
89
+
90
+ **Sound belongs to the desktop.** Follow `os.sound` (`{ muted, volume }`) and
91
+ `os.onSound`: silent while muted, scaled by the volume, live. A sandboxed frame
92
+ cannot be muted from outside, so review checks that the app follows it. Use
93
+ `createAudio(os)` from `@vibechain/os/audio` and connect everything you play to
94
+ `audio.master`; a game's own sound button is `audio.muted`, an extra mute that
95
+ never overrides the desktop's, and the game never says "sound on" while the
96
+ desktop is muted.
66
97
  `connectVibeMarketApp()` (0.4) still works and is deprecated.
67
98
 
68
99
  ## What an app cannot do
69
100
 
70
101
  An app learns who is playing (their public handle, @name, display name and
71
102
  picture, the same in every app; there is no anonymous id) but has no access to
72
- the player's account, session, Steam ID or balance; no wallets, purchases,
73
- trades, Cash, Nuggets, XP or rewards;
103
+ the player's account, session, Steam ID or balance; no wallets, trades, Cash,
104
+ Nuggets, XP or rewards, and no purchases but its own declared products bought
105
+ through `os.buy`;
74
106
  no vibechain.com APIs; no undeclared servers; no Classic `/market` holdings; and
75
107
  no access to the desktop page, other apps, Steam commands or native IPC. Card
76
108
  holdings are visible only as the manifest declares (`cards`), and the signed
77
109
  player token only with `network`; whatever the app sends its servers is tied to
78
110
  the player's public identity. A network app may not embed third-party advertising
79
- or analytics SDKs, take payments, or ask players to sign in; what its server
111
+ or analytics SDKs, take payments (other than `os.buy`), or ask players to sign in; what its server
80
112
  sends after review is still bound by the listing rules. Never ask players to type
81
113
  secrets into your app.
82
114
 
@@ -104,6 +136,15 @@ version 3 (and version 2 unchanged), with unknown fields refused at every level:
104
136
  only after its creator approves.
105
137
  - `cards` (optional): `none`, `linked` (needs `packs`) or `all` (every vmOS
106
138
  pack the player holds).
139
+ - `leaderboards` (optional, 0.6): up to 5 `{ id, name, order?, format? }`;
140
+ `order` `high` or `low`, `format` `number` or `time` (milliseconds). The
141
+ board `score` exists anyway. `achievements` (optional): up to 50
142
+ `{ id, name, description, icon?, secret? }`, icons 128 x 128 PNG or WebP of
143
+ at most 64 KiB. `products` (optional): up to 50
144
+ `{ id, name, description, price, kind }`, whole Printer Cash within the
145
+ store's maximum, `kind` `consumable` or `permanent`. Ids are a lowercase
146
+ letter then up to 31 lowercase letters, digits or hyphens, unique and never
147
+ given a new meaning; names at most 40 and descriptions 120 characters.
107
148
  - `network` (optional): up to 8 exact `https://` or `wss://` origins with a
108
149
  public DNS name; no IP addresses, local or wildcard-DNS names, paths or `*`.
109
150
  Your servers must send `Access-Control-Allow-Origin: *`.
@@ -147,8 +188,8 @@ npm run pack # os pack dist app.zip
147
188
  Submit only what you are willing to publish permanently. Staff choose which
148
189
  approved version is live.
149
190
 
150
- Apps open in the browser version of VibeMarket OS. The Steam client shows a
151
- notice with a link instead of opening them, and the mobile apps do not run them.
191
+ Apps open in VibeMarket OS in the browser and in the VibeMarket Steam client;
192
+ the mobile apps do not run them.
152
193
 
153
194
  ## Market-game API (not for VibeStore apps)
154
195
 
package/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # @vibechain/os
2
2
 
3
- Build games, tools and desktop apps for VibeMarket OS. One `connect()` gives your app readiness, a save that follows the player, who is playing, their vmOS cards and packs, a signed statement of the player for your own server, and a score. Use TypeScript with a bundler, or two `<script>` tags and nothing to install.
3
+ Build games, tools and desktop apps for VibeMarket OS. Coding agents: read the agent skill, https://vibechain.com/os/skill.md. One `connect()` gives your app readiness, a save that follows the player, who is playing, their vmOS cards and packs, a signed statement of the player for your own server, a score with leaderboards, achievements, friends and invites, sharing, and products the player buys with Printer Cash. Use TypeScript with a bundler, or two `<script>` tags and nothing to install.
4
4
 
5
5
  ## Quickstart
6
6
 
7
7
  ```sh
8
- npx --yes @vibechain/os@0.5.1 init my-app # TypeScript, esbuild and a 2D canvas (the default)
9
- npx --yes @vibechain/os@0.5.1 init my-app --template three # TypeScript, esbuild and Three.js: a spinning vmOS card
10
- npx --yes @vibechain/os@0.5.1 init my-app --template plain # index.html + game.js, nothing to install
8
+ npx --yes @vibechain/os@0.6.0 init my-app # TypeScript, esbuild and a 2D canvas (the default)
9
+ npx --yes @vibechain/os@0.6.0 init my-app --template three # TypeScript, esbuild and Three.js: a spinning vmOS card
10
+ npx --yes @vibechain/os@0.6.0 init my-app --template plain # index.html + game.js, nothing to install
11
11
  ```
12
12
 
13
13
  For `canvas` and `three`: `cd my-app`, `npm install`, `npm run build`, `npm run dev`, and open the printed `http://127.0.0.1:PORT` address. `npm run check` (`os check`) lists every problem with the manifest and the build at once, and `npm run pack` writes `app.zip`. For `plain`: `npx @vibechain/os preview my-app`; the folder is already the app, so zip it to submit. Every template's `vibemarket.json` is a complete schema version 3 listing with placeholder text and pictures you must replace first (an unchanged starter is rejected at review).
@@ -15,7 +15,7 @@ For `canvas` and `three`: `cd my-app`, `npm install`, `npm run build`, `npm run
15
15
  To install from a downloaded SDK archive, supply its absolute path to npm and the initializer:
16
16
 
17
17
  ```sh
18
- npm exec --yes --package=/absolute/path/vibechain-os-0.5.1.tgz -- os init my-app /absolute/path/vibechain-os-0.5.1.tgz
18
+ npm exec --yes --package=/absolute/path/vibechain-os-0.6.0.tgz -- os init my-app /absolute/path/vibechain-os-0.6.0.tgz
19
19
  ```
20
20
 
21
21
  That keeps a `file:` archive dependency; retain the archive for later reinstalls. Use a supported Node.js release: `^22.23.4`, `^24.22.1` or `^26.12.1`. The library is ESM-only (`import`, or dynamic `import()` from CommonJS); browsers without a bundler use `vibemarket-os.js` (below).
@@ -41,16 +41,33 @@ await os.showCard("born-to-vibe", "b1"); // ...or one card on its pack's page
41
41
  await os.open("vmos://pack/born-to-vibe"); // ...or an app link (packLink, cardLink, parseVmosLink)
42
42
 
43
43
  const me = await os.player(); // { guest: false, handle, username?, name, picture, token?, expiresAt? } or { guest: true }
44
- await os.finish({ score: 42 }); // one integer score, 0 to 1,000,000,000
44
+ await os.finish({ score: 42 }); // one integer score, 0 to 1,000,000,000, posted to the board "score"
45
+ await os.finish({ score: 61250, board: "time-trial" }); // ...or to a board you declared (0.6)
46
+
47
+ // 0.6: leaderboards, achievements, friends, invites, sharing and spending
48
+ const board = await os.leaderboard({ board: "score", scope: "friends", period: "week", limit: 10 });
49
+ await os.showLeaderboard("score"); // vmOS's own panel over the app; needs a click
50
+ await os.unlock("first-win"); // { unlocked: true } the first time; vmOS shows the toast
51
+ const achievements = await os.achievements();
52
+ const friends = await os.friends(); // friends who have this app, with presence
53
+ await os.invite({ text: "Race me!", data: "room-42" }); // vmOS's invite sheet; needs a click
54
+ os.launch.invite; // { from, data } when a friend's invite opened the app, else null
55
+ os.onInvite(invite => {}); // an invite while the app is open
56
+ await os.share({ score: 42 }); // vmOS's share sheet; needs a click
57
+ const products = await os.products(); // the manifest's products, with owned
58
+ const receipt = await os.buy("midnight-coat"); // vmOS's spend dialog; needs a click in the last second
59
+ for (const waiting of await os.purchases()) { grant(waiting.product); await os.consume(waiting.id); }
60
+ const token = await os.receiptToken(receipt.id); // network apps: verify on your server
45
61
 
46
62
  os.onPause(() => {}); os.onResume(() => {});
47
63
  os.onResize(({ width, height }) => {});
48
- os.size; os.active; os.guest; // current values
64
+ os.onSound(({ muted, volume }) => {}); // the desktop's speaker and volume changed
65
+ os.size; os.active; os.guest; os.sound; // current values; os.sound is { muted, volume } (0 to 1)
49
66
  await os.maximize(); await os.fullscreen();
50
67
  os.close(); // release the port
51
68
  ```
52
69
 
53
- **Errors.** Every rejection is an `OsError` whose `code` is one of nine and never changes; the `message` is a plain sentence that may. A refusal keeps the app running; only protocol violations (malformed messages, replayed requests, the hard rate limits) end the session.
70
+ **Errors.** Every rejection is an `OsError` whose `code` is one of thirteen and never changes; the `message` is a plain sentence that may. A refusal keeps the app running; only protocol violations (malformed messages, replayed requests, the hard rate limits) end the session.
54
71
 
55
72
  | Code | Means |
56
73
  |---|---|
@@ -59,10 +76,14 @@ os.close(); // release the port
59
76
  | `invalid` | A bad argument: not JSON, a bad pack slug, a number out of range. |
60
77
  | `too-large` | A save over 1 MiB, or over the player's 8 MiB across all apps. |
61
78
  | `rate-limited` | Too often; try later. |
62
- | `needs-click` | `showPack`, `showCard`, `open` or `fullscreen` without a fresh click in the app. |
79
+ | `needs-click` | `showPack`, `showCard`, `open`, `fullscreen`, `showLeaderboard`, `share` or `invite` without a fresh click in the app, or `buy` without one in the last second. |
63
80
  | `unavailable` | The host or server could not answer now; retry. |
64
81
  | `timeout` | No answer in 10 seconds. |
65
82
  | `closed` | The session ended: the window closed, the app was revoked, or a limit. |
83
+ | `cancelled` | 0.6: the player closed the spend dialog without spending. |
84
+ | `insufficient` | 0.6: the player does not have enough Printer Cash (you never learn how much they have). |
85
+ | `limit` | 0.6: a cap was reached: a daily spending limit, too many unconsumed purchases, or the day's invites. |
86
+ | `guest` | 0.6: guests cannot buy, share or invite; the player has to sign in. |
66
87
 
67
88
  **Saves.** `os.save(value)` stores one JSON value per player per app on VibeMarket's servers: at most 1 MiB as UTF-8 JSON, nested at most 64 deep, finite numbers only. It survives closing the window, other devices and reinstalling; a save not written for 365 days is deleted, and the player can delete it from the app's VibeStore page. Calls made sooner than the host accepts (one write in flight, at most one every 10 seconds) replace the pending value, and every caller's promise resolves with the write that carries it, so call it as often as you like. Saves are accepted while the window is behind another one: `os.onPause(() => os.save(state))` is the place to save. Two devices playing at once overwrite each other (last write wins). A guest's save lives only while the window is open (`os.guest`).
68
89
 
@@ -70,13 +91,25 @@ os.close(); // release the port
70
91
 
71
92
  **Showing any pack, and app links (0.5.1).** Any app can show and advertise any public vmOS pack, linked or not, with nothing in the manifest. `os.pack(slug)` returns its public face, what the pack's public page shows: name, creator, cover art and every card with its name, rarity and art (art URLs work as described above), never what the player holds. `os.showPack(slug)` opens the pack in VibeMarket inside vmOS, and `os.showCard(slug, cardId)` opens one card on its pack's page. An app link is one string you can put in your own content or get from your server: `vmos://pack/<slug>`, `vmos://card/<slug>/<cardId>`, or a pack's public page `https://vibechain.com/os/pack/<slug>` (or `www.`); `os.open(link)` opens it. `packLink(slug)` and `cardLink(slug, cardId)` write links and `parseVmosLink(text)` reads one (`{ kind: "pack", pack }`, `{ kind: "card", pack, card }` or `null`); the grammar is exact (lowercase scheme and host, no query, fragment, port or percent-encoding, at most 200 characters), and anything else answers `invalid` without reaching the host. `open` never navigates your frame: the SDK sends the host only the parsed pack or card. All three need the app ready and in front (`not-permitted`) and a fresh click in it (`needs-click`), share one budget of one per 10 seconds (`rate-limited`), and answer `invalid` for a pack that does not exist or was taken down or a card not in it. Buying and opening happen only in VibeMarket's own window, and your app learns nothing about what the player does there; it sees new holdings only through `os.cards()` and `onCards`, as the manifest permits. On a 0.5.0 host `showCard` and card links answer `unsupported`. The [docs](https://vibechain.com/os/docs#sdk-05-link-out) have the full rules and examples.
72
93
 
73
- **Network and the player.** A manifest may declare up to 8 servers in `network`: exact `https://` or `wss://` origins (a DNS name, no path, no IP addresses, no local or wildcard-DNS names). The app may then `fetch`, `WebSocket` and `EventSource` them, and load images, audio, video and fonts from the `https://` ones; never scripts, styles or workers. Your servers must answer the frame's `Origin: null` with `Access-Control-Allow-Origin: *` (or `null`) for `fetch` and for images used as textures. Version remote URLs and send a long `Cache-Control`: the app has no IndexedDB, Cache Storage or service worker. Every server you declare sees the player's IP address; the listing says "Connects to" and "Loads content from" your hosts, and what your server sends after review is still bound by the listing rules (no third-party advertising or analytics, no payments, no sign-in prompts).
94
+ **Network and the player.** A manifest may declare up to 8 servers in `network`: exact `https://` or `wss://` origins (a DNS name, no path, no IP addresses, no local or wildcard-DNS names). The app may then `fetch`, `WebSocket` and `EventSource` them, and load images, audio, video and fonts from the `https://` ones; never scripts, styles or workers. Your servers must answer the frame's `Origin: null` with `Access-Control-Allow-Origin: *` (or `null`) for `fetch` and for images used as textures. Version remote URLs and send a long `Cache-Control`: the app has no IndexedDB, Cache Storage or service worker. Every server you declare sees the player's IP address; the listing says "Connects to" and "Loads content from" your hosts, and what your server sends after review is still bound by the listing rules (no third-party advertising or analytics, no payments other than `os.buy`, no sign-in prompts).
74
95
 
75
96
  **Who is playing, and what your app and your servers learn.** `os.player()` tells every schema 3 app who is playing, with no permission and no prompt: the player's public vmOS identity, exactly what their public profile shows anyone. That is `{ guest: false, handle, username?, name, picture }`: `handle` is the character's fixed id and never changes (key your data on it), `username` the @name they show when it differs, `name` the display name, and `picture` the avatar as a URL under your app's own address (CORS-clean, like card art), or null. A guest is `{ guest: true }` and nothing else. There is no anonymous or per-app id: the same player has the same handle in every app, so two apps can recognize the same player, and anything your app sends to your servers (handle, name, holdings, save, gameplay) arrives tied to that public identity. Your app never receives the player's Steam ID, account id, session, balance, Nuggets, level or wallet. With `network`, the answer also carries `token` and `expiresAt`: a 5-minute Ed25519 JWT stating the same identity (`sub` is the handle, plus `username`, `name`, `aud` = your app id) for your own server, which must verify it rather than trust a handle the client sends: the [verification sample in the docs](https://vibechain.com/os/docs#sdk-05-verify) is the whole check, in Node with no dependencies, and compares `aud` with your app id. The token is not a credential for any vibechain.com route; the SDK reuses it while more than a minute remains; guests get none. Every server you declare also sees the player's IP address.
76
97
 
77
98
  **Loading, window and input.** `ready()` within 15 seconds, or call `progress(fraction)` at least every 15 seconds and `ready()` within 120 (the SDK sends at most one progress a second). `maximize()` maximizes or restores the window. `fullscreen()` asks the host to put your app's window, with a slim host strip (your app's name, Report, Exit), into the browser's full screen; it needs a fresh click and Escape always leaves. Pointer lock, gamepads and audio work in every app (sound starts on the first input). Workers run from `blob:` URLs: `spawnWorker("worker.js")` fetches a bundled worker script and starts it (bundle it into one file). WebAssembly works; threads and `SharedArrayBuffer` do not, so use single-threaded engine exports.
78
99
 
79
- **Older hosts.** On a host older than 0.5, `ready`, `finish`, the lifecycle, `load` and `save` work (saves use the window-only 32 KiB checkpoint, and a larger one answers `too-large`); the rest answers `unsupported` and `progress` does nothing.
100
+ **Leaderboards, achievements, friends, invites and sharing (0.6).** Every app has the board `score` ("High scores", bigger is better); a manifest may declare up to 5 boards of its own, each bigger-is-better or smaller-is-better, as a number or a time in milliseconds. `os.finish({ score, board })` ends the round as before and also posts the score to the board (`score` when you name none). vmOS keeps each player's best per board, all time and per week (from Monday 00:00 UTC), and accepts one score per round, only inside a round it timed itself (from `ready()` to the first `finish()`), at a limited rate; a refused score never affects the round, and `finish` resolves either way. Scores are reported by your app, so they are not proof of skill: players can report rows from vmOS's panel and staff remove them; a game that needs trusted rankings keeps its own board on its own server. `os.leaderboard({ board, scope, period, limit })` reads up to 50 rows (default 10) of `everyone` or `friends`, `all` or `week`, with each row's rank, handle, name, picture and score, and `you`, the player's own place even when it is outside the rows. `os.showLeaderboard(board)` opens vmOS's own panel over your app (needs a click) and resolves when it closes. `os.unlock(id)` records an achievement your manifest declares, once (`{ unlocked: true }` only the first time), and vmOS shows its own toast; achievements pay nothing. `os.achievements()` lists every declared achievement with `unlocked` and `at`; a secret one reads "Secret achievement", with no description or icon, until it is unlocked. `os.friends()` lists the player's friends who installed your app (at most 100), with `presence` `playing` (your app is open on their desk), `online` or `offline`, and only the public fields of a player; you never see the whole friends list. `os.invite({ to, text, data })` opens vmOS's invite sheet (needs a click): the player picks friends and confirms; they get a chat message with your app's card, and `{ sent }` says how many (0 when the player closes the sheet). `text` is a line of at most 80 characters and `data` up to 256 characters of your own (a room code, a seed). The friend who opens it starts your app with `os.launch.invite` (`{ from, data }`, read it once at start), or, if it is already open, `os.onInvite` hears it. `os.share({ text, score, board })` opens vmOS's share sheet with a card vmOS composes (your app's name and icon, the player's name, the score in the board's format and their rank); the player chooses a friend in chat or their VibeSpace status, may edit the caption (at most 140 characters) and confirms; `{ shared }` is false when they close it. `vmos://app/<appId>` and `https://vibechain.com/os/app/<appId>` are app links (`appLink(id)` writes one) that open an app's page in MiniVibe; `os.open` takes them, with a click. Guests can play, but their scores and achievements are not recorded and `share`, `invite` and `buy` answer `guest`. Invites, shares and spend dialogs are rate limited per app; the limits exist and may change.
101
+
102
+ **Spending Printer Cash (0.6).** An app may sell things inside itself for Printer Cash, and only products its manifest declares, with a price, reviewed with the version. `os.buy(productId)`, called from a click (within the last second), makes vmOS draw its own dialog over your app, outside your frame: your app's name and icon, the product's name and description as approved, the price and the player's Printer Cash now and after, with Cancel as the default. Your app is paused and learns nothing until it closes; then `buy` resolves with a `Receipt` (`{ id, product, kind, price, at, consumed }`) or rejects `cancelled`, `insufficient` (you never learn the balance), `limit` or `guest`. The price and product come from the approved manifest, never from your call. The Printer Cash is removed from play: nothing is paid to you. A `permanent` product is owned from then on, on every device (`products()` says `owned`, and buying it again returns the same receipt and spends nothing). A `consumable`'s receipt stays in `os.purchases()` until you grant the item and call `os.consume(receipt.id)`, so a crash between paying and granting loses nothing: read `purchases()` at every start and grant what is waiting. A player holds a limited number of unconsumed purchases per app, and spending per player per day is limited; the limits exist and their values are not published. A `network` app verifies a purchase on its server with `os.receiptToken(id)`: an Ed25519 JWT signed with the same key as the player token (same `kid`, same public keys), valid for 5 minutes, with the claims `sub` (handle), `app`, `rid`, `product`, `kind`, `price` and `at`. There is no refund call; staff can reverse a receipt.
103
+
104
+ Products are reviewed with the version, by these rules:
105
+
106
+ - A product delivers what its name and description say, inside the app.
107
+ - No product is, or stands for, money, Nuggets, Steam items, cards, packs or anything usable or tradable outside the app.
108
+ - A product whose result depends on chance shows its odds in the app before the dialog can open.
109
+ - Nothing the listing's screenshots show may need a purchase.
110
+ - Prices and products change only through a new reviewed version. An id keeps its meaning: a later version may add products, change names, descriptions and prices or drop one, but never change a product's `kind` (or a board's `order` or `format`).
111
+
112
+ **Older hosts.** On a host older than 0.6 every 0.6 call answers `unsupported`, `os.launch.invite` is null and `finish({ score, board })` ends the round without a board; nothing throws at import or connect, so hide the buttons and carry on. On a host older than 0.5, `ready`, `finish`, the lifecycle, `load` and `save` work (saves use the window-only 32 KiB checkpoint, and a larger one answers `too-large`); the rest answers `unsupported` and `progress` does nothing.
80
113
 
81
114
  **Desktop photos.** The desktop camera cannot see inside a sandboxed app window, so it asks the app for its current frame (`app.capture`). `connect()` and `connectVibeMarketApp()` answer by default with the largest visible `<canvas>` on the page, taken on the next animation frame, scaled to at most 1280 pixels on its longest side and encoded as WebP (JPEG if WebP is unavailable) under 1,000,000 characters; a WebGL game needs no changes. An app that draws with the DOM, or wants a custom picture, registers `const off = os.onCapture?.(() => canvasOrDataUrl)` (optional; the 0.4 client has `sdk.onCapture` too): return an `HTMLCanvasElement`, a PNG/JPEG/WebP data URL, `null`, or a promise of one; the latest handler wins and the host waits about 1.2 seconds. Failures are silent. An app built with an older SDK shows a placeholder in desktop photos until it is rebuilt against this SDK.
82
115
 
@@ -84,7 +117,7 @@ os.close(); // release the port
84
117
 
85
118
  ## Apps without a bundler
86
119
 
87
- `vibemarket-os.js` (in `dist/` of the package, copied by `os init --template plain`) defines one global, `VibemarketOS`, with `connect`, `OsError` and the link helpers `packLink`, `cardLink` and `parseVmosLink`. **Load it and your game from files: inline `<script>` code does not run**, because the runtime's policy allows scripts only from your app's own files.
120
+ `vibemarket-os.js` (in `dist/` of the package, copied by `os init --template plain`) defines one global, `VibemarketOS`, with `connect`, `OsError`, `createAudio` and the link helpers `packLink`, `cardLink`, `appLink` and `parseVmosLink`. **Load it and your game from files: inline `<script>` code does not run**, because the runtime's policy allows scripts only from your app's own files.
88
121
 
89
122
  ```html
90
123
  <script src="vibemarket-os.js"></script>
@@ -101,7 +134,7 @@ VibemarketOS.connect().then(async os => {
101
134
 
102
135
  ## Game helpers
103
136
 
104
- `@vibechain/os/loop` and `@vibechain/os/canvas` take the result of `connect()` (or of the legacy `connectVibeMarketApp()`) and follow its lifecycle, so a game stops drawing when its window is not active.
137
+ `@vibechain/os/loop`, `@vibechain/os/canvas` and `@vibechain/os/audio` take the result of `connect()` (or of the legacy `connectVibeMarketApp()`) and follow its lifecycle, so a game stops drawing when its window is not active.
105
138
 
106
139
  ```ts
107
140
  import { connect } from "@vibechain/os";
@@ -116,6 +149,21 @@ os.ready();
116
149
  window.addEventListener("pagehide", () => { loop.stop(); os.close(); }, { once: true });
117
150
  ```
118
151
 
152
+ ### Sound
153
+
154
+ The desktop owns sound: its taskbar speaker and its game volume (on the website's desk, master volume × the Games fader) reach the app as `os.sound` and `os.onSound` (0.5.2; on an older host `os.sound` is `{ muted: false, volume: 1 }` and never changes). A sandboxed frame cannot be muted from outside in a browser, so this is cooperative: the app must follow it, and VibeStore review checks that it does. `@vibechain/os/audio` makes that the default:
155
+
156
+ ```ts
157
+ import { createAudio } from "@vibechain/os/audio";
158
+
159
+ const audio = createAudio(os); // ideally inside the first click; also takes connectVibeMarketApp()'s object
160
+ music.connect(audio.master); // connect everything you play to the master
161
+ audio.muted = !soundButtonOn; // optional: your own extra mute, which never overrides the desktop's
162
+ audio.onChange(() => { /* redraw a sound label; on a new audio.context, rebuild your nodes */ });
163
+ ```
164
+
165
+ The master is silent while the desktop is muted, follows its volume and ramps over 50 ms on every change (no clicks). The context is suspended after the ramp while the window is behind another one or minimized, and resumed when it comes back. A context the browser stopped (`suspended`, or WebKit's `interrupted` after an audio interruption, sleep or an output change) is resumed on every click, tap or key in the frame; one the browser closed, or one still stopped after 3 gestures, is replaced (at most 3 times), and `audio.context` and `audio.master` then name the new ones. `audio.paused = true` holds it suspended for your own pause (a menu, a lost GPU). `createLoop`'s pause and the helper's follow the same lifecycle and never fight. Show the real state: never "sound on" while `os.sound.muted` is true.
166
+
119
167
  `createLoop` runs a fixed-timestep simulation (default 60 steps per second, at most 5 catch-up steps per frame) and renders once per animation frame. It pauses while the app is inactive and discards that time instead of simulating it on return. `fitCanvas` sizes the canvas backing store from the host surface with the device pixel ratio capped (default 2, and at most 3840 x 2160 pixels), resizes only when the size changes, and keeps a lost WebGL context restorable through `onContextLost` and `onContextRestored`.
120
168
 
121
169
  ### Testing your game
@@ -133,11 +181,29 @@ host.click(); await game.openShop(); // showPack, showCard, open and f
133
181
  expect(host.save).toEqual({ best: 7 }); expect(host.finished).toEqual({ score: 7 });
134
182
  ```
135
183
 
184
+ 0.6 adds fakes for every new call, with the rules of the real services:
185
+
186
+ ```ts
187
+ const host = createFakeOs({
188
+ leaderboards: [{ id: "laps", name: "Fastest lap", order: "low", format: "time" }], // as in vibemarket.json
189
+ achievements: [{ id: "first-win", name: "First win", description: "Win a race." }],
190
+ products: [{ id: "nitro", name: "Nitro", description: "One boost for the next race.", price: 5, kind: "consumable" }],
191
+ scores: [{ board: "laps", handle: "rival", name: "Rival", score: 61_000, friend: true }],
192
+ friends: [{ handle: "rival", name: "Rival", picture: null, presence: "online" }],
193
+ printerCash: 20,
194
+ });
195
+ host.click(); await host.os.buy("nitro"); // confirmed; host.setChoice("cancel") makes the player say no
196
+ expect(host.services.receipts).toHaveLength(1); expect(host.services.printerCash).toBe(15);
197
+ host.receiveInvite({ from: "rival", data: "room-42" }); // onInvite listeners hear it
198
+ ```
199
+
200
+ `host.services` records the scores posted, achievements unlocked, shares, invites, receipts and the Printer Cash left; `shownLeaderboards` and `shownApps` what the game opened. `host: "0.5"` behaves like a host from before 0.6 (every new call `unsupported`). The same fakes answer the new calls in `os preview`, which draws plain stand-ins marked "Preview" for vmOS's dialog, sheets, panel and toast; the real ones look different and are drawn by vmOS.
201
+
136
202
  It applies the real save limits, slug checks, card access levels, single-shot score, click rule, link grammar and error codes, and `protocol: 1` behaves like an older host. `packs` lists every public pack it knows (any of them works with `pack`, `showPack`, `showCard` and `open`), and `shownPacks` and `shownCards` record what the game asked to show. It has no time limits, rate limits or save coalescing, so still run the preview before you ship. `createFakeApp` is the same for the legacy `connectVibeMarketApp()` API.
137
203
 
138
204
  ### Complete examples
139
205
 
140
- `examples/paw-beat` is a small 3D rhythm game with Three.js (built on the legacy API, unchanged). The `os init` templates live in `examples/vibexp-app` (canvas), `examples/vibexp-app/plain` (the smallest app) and `examples/vibexp-app/three`.
206
+ `examples/paw-beat` is a small 3D rhythm game with Three.js on `connect()`: a save, a leaderboard, three achievements, a share button and one cosmetic product, each degrading silently on an older host. The `os init` templates live in `examples/vibexp-app` (canvas), `examples/vibexp-app/plain` (the smallest app) and `examples/vibexp-app/three`.
141
207
 
142
208
  ## Intro, loading and results
143
209
 
@@ -151,7 +217,7 @@ await app.game.finish({ score: 42 });
151
217
 
152
218
  `score` must be an integer from 0 through 1,000,000,000, with no other input fields. It is a reported game score. The host owns the final screen and Play again control. Completion is single-shot for that open controller, including suspended generations: retrying the same score acknowledges the accepted result; changing the score is rejected. The host posts acknowledgement before showing results. If the frame closes before it receives that acknowledgement, inspect the host result rather than assuming the completion failed.
153
219
 
154
- Completion does not grant Cash, XP, inventory or a wallet action. The local preview and collection host report score only. An approved host may show an existing Cash award only after its own registered game policy and server reward flow confirm it; the frame cannot select a reward amount or supply proof of payment. Older hosts may not understand this additive method; use a matching 0.2.x host/preview.
220
+ The score is display data: it never sets a reward. A finished round of an approved app may earn the player a small amount of Printer Cash, decided and paid by VibeMarket OS within per-player daily caps. The app cannot grant, see or influence the amount, and nothing an app sends is trusted for it. See [Rewards](https://vibechain.com/os/docs#rewards). Completion never grants XP, inventory or a wallet action, and the local preview and collection host report the score only. Older hosts may not understand this additive method; use a matching 0.2.x host/preview.
155
221
 
156
222
  ## Listing in VibeStore
157
223
 
@@ -166,7 +232,10 @@ VibeStore is the app store inside VibeMarket OS. You submit from its **Submit**
166
232
  "description": "At least forty characters of plain text about the app.", "category": "game",
167
233
  "rating": { "violence": "none", "language": "none", "mature": false }, "support": "https://example.com/help"
168
234
  },
169
- "packs": ["rooftop-rats"], "cards": "linked", "network": ["wss://play.example.com"]
235
+ "packs": ["rooftop-rats"], "cards": "linked", "network": ["wss://play.example.com"],
236
+ "leaderboards": [{ "id": "score", "name": "High scores" }],
237
+ "achievements": [{ "id": "first-win", "name": "First win", "description": "Win your first match." }],
238
+ "products": [{ "id": "gold-frame", "name": "Gold frame", "description": "A gold frame for your deck.", "price": 20, "kind": "permanent" }]
170
239
  }
171
240
  ```
172
241
 
@@ -185,15 +254,19 @@ VibeStore is the app store inside VibeMarket OS. You submit from its **Submit**
185
254
  | `store.support` | An `https://` URL without a user name or password, or an email address, at most 200 characters. Players and reviewers see it. |
186
255
  | `packs` | Optional. Up to 3 pack slugs, no repeats, in the order the listing shows them. |
187
256
  | `cards` | Optional. `none` (the default), `linked` (needs a pack in `packs`) or `all`. |
257
+ | `leaderboards` | Optional (0.6). Up to 5 of `{ id, name, order?, format? }`: `order` `high` (default, bigger is better) or `low`, `format` `number` (default) or `time` (milliseconds, shown m:ss.cc). The board `score` exists anyway unless you declare that id. |
258
+ | `achievements` | Optional (0.6). Up to 50 of `{ id, name, description, icon?, secret? }`. `icon` is a `.png` or `.webp` in the bundle, exactly 128 x 128 pixels, at most 64 KiB. `secret` hides the name and description until unlocked. |
259
+ | `products` | Optional (0.6). Up to 50 of `{ id, name, description, price, kind }`: `price` in whole Printer Cash, at least 1 and within the store's maximum price; `kind` `consumable` or `permanent`. Reviewed by the product rules above. |
260
+ | ids and names | An id is a lowercase letter followed by up to 31 lowercase letters, digits and hyphens, unique in its list, and keeps its meaning in every later version. A name is at most 40 characters and a description at most 120, one line each. |
188
261
  | `network` | Optional. Up to 8 `https://` or `wss://` origins: `scheme://host` or `scheme://host:port` exactly (no path, not even `/`; no port 443), a public DNS name with internationalized names in punycode; never an IP address, `localhost` or a `.local`, `.internal`, `.lan`, `.home.arpa`, `.test`, `.example`, `.invalid`, `.onion` or `.arpa` name, a wildcard-DNS service (`nip.io`, `sslip.io`, `xip.io`, `localtest.me`, `lvh.me`, `traefik.me`), a vibechain.com, vibe.market or eattherich.gg address, or a `*`. Stored lowercase and sorted. |
189
262
 
190
- Unknown fields are refused at every level, and version 3 refuses the four constant fields of version 2 (`sdkVersion`, `category`, `permissions`, `collectionId`). Schema version 2 manifests are still accepted unchanged. A bundle may not contain SVG files anywhere, because SVG is a document format that can carry script; use PNG or WebP. The submitted ZIP is at most 50 MiB (128 MiB expanded, 32 MiB per file, 2,000 files and folders; see [SECURITY.md](SECURITY.md)); a game may stream more art, audio and data from its declared servers. `os assets` copies a `public/` folder of your project whole into `dist/`, so assets need no manual copying.
263
+ The `vibemarket.json` file is at most 64 KiB. Unknown fields are refused at every level, and version 3 refuses the four constant fields of version 2 (`sdkVersion`, `category`, `permissions`, `collectionId`). Schema version 2 manifests are still accepted unchanged. A bundle may not contain SVG files anywhere, because SVG is a document format that can carry script; use PNG or WebP. The submitted ZIP is at most 50 MiB (128 MiB expanded, 32 MiB per file, 2,000 files and folders; see [SECURITY.md](SECURITY.md)); a game may stream more art, audio and data from its declared servers. `os assets` copies a `public/` folder of your project whole into `dist/`, so assets need no manual copying.
191
264
 
192
- `os check [dir]` prints every problem with the manifest and the built folder at once, one per line with the field and how to fix it (`store.icon: icon.png is 512 x 512; it must be exactly 256 x 256 pixels`), and exits 1 if there is any: the same manifest, origin, listing image, file type and size checks as the server. `os pack` and `os preview` run them too. To validate in your own tools, `@vibechain/os/manifest` exports `parseManifest`, `checkManifest` (every problem as `{ path, message }`), `networkOrigin` and the bounds (`APP_BUNDLE_LIMITS`, `APP_MANIFEST_LIMITS`, `APP_STORE_CATEGORIES`), `@vibechain/os/listing` exports `checkListing`, `pngSize` and `imageKind`, and `@vibechain/os/policy` exports `appRuntimeCsp`, the runtime's exact Content-Security-Policy, which the preview and vibechain.com share.
265
+ `os check [dir]` prints every problem with the manifest and the built folder at once, one per line with the field and how to fix it (`store.icon: icon.png is 512 x 512; it must be exactly 256 x 256 pixels`), and exits 1 if there is any: the same manifest, origin, listing image, file type and size checks as the server. `os pack` and `os preview` run them too. To validate in your own tools, `@vibechain/os/manifest` exports `parseManifest`, `checkManifest` (every problem as `{ path, message }`), `networkOrigin` and the bounds (`APP_BUNDLE_LIMITS`, `APP_MANIFEST_LIMITS`, `APP_STORE_CATEGORIES`), `@vibechain/os/listing` exports `checkListing`, `pngSize`, `webpSize`, `imageKind` and `achievementIconProblem`, and `@vibechain/os/policy` exports `appRuntimeCsp`, the runtime's exact Content-Security-Policy, which the preview and vibechain.com share.
193
266
 
194
267
  ## Publishing status
195
268
 
196
- Publish by submitting your packed ZIP from the VibeStore **Submit** tab in VibeMarket OS, or with `os submit` from your terminal; see [Publish](https://vibechain.com/os/docs#publish) and [Review](https://vibechain.com/os/docs#review). Installing the SDK does not list your app. An approved version is archived to public IPFS, so approval is publication: removing an app from VibeStore later does not recall that copy. Third-party apps open in the browser version of VibeMarket OS; the Steam client does not run them yet. The app API grants no native, payment, wallet or reward access, and card reads only as the manifest declares them. Existing Market games continue to use their separate permissioned API.
269
+ Publish by submitting your packed ZIP from the VibeStore **Submit** tab in VibeMarket OS, or with `os submit` from your terminal; see [Publish](https://vibechain.com/os/docs#publish) and [Review](https://vibechain.com/os/docs#review). Installing the SDK does not list your app. An approved version is archived to public IPFS, so approval is publication: removing an app from VibeStore later does not recall that copy. Third-party apps open in VibeMarket OS in the browser and in the VibeMarket Steam client. The app API grants no native or wallet access, no payment but a declared product bought in vmOS's own dialog, and cannot grant, see or influence a reward, and card reads only as the manifest declares them. Existing Market games continue to use their separate permissioned API.
197
270
 
198
271
  See the [SDK docs](https://vibechain.com/os/docs) for the app API and [SECURITY.md](SECURITY.md) for the sandbox and resource limits.
199
272
 
@@ -219,16 +292,38 @@ npx os logout # revokes this computer's sign-in, then deletes it
219
292
 
220
293
  ## Maintainer workflow
221
294
 
295
+ The agent skill for app developers, **https://vibechain.com/os/skill.md**, is generated from this package: `tools/skill.ts` fills `tools/skill-template.md` with the version, the `Os` methods, the error and submission codes, the limits, the link grammar, the commands, the smallest app and the token check, and writes `skill.md`, which the website serves. `tests/skill.test.ts` (and the website's own test of the route) re-render it and fail on any difference, so an SDK change that alters one of those facts needs `pnpm skill` and the regenerated file in the same commit. A release bumps `package.json` and `OS_SDK_VERSION` together (a test binds them), then runs `pnpm skill`.
296
+
222
297
  ```sh
223
298
  pnpm install --frozen-lockfile
299
+ pnpm skill # regenerate skill.md from the SDK; pnpm review fails while it is stale
224
300
  pnpm review
225
301
  pnpm build
226
302
  pnpm check:package
227
- pnpm release:preview --version 0.5.1
303
+ pnpm release:preview --version 0.6.0
228
304
  ```
229
305
 
230
306
  `pnpm build` emits JavaScript/declarations, the bundled preview host UI, `dist/vibemarket-os.js` (the no-bundler IIFE) and `dist/templates/plain/game.js` (built from `examples/vibexp-app/plain/game.ts`, so the repository holds no authored JavaScript). Only `examples/paw-beat` and `examples/vibexp-app` (with its `plain` and `three` templates) are published; `examples/card-game` and `examples/verify-player.ts` are type-checked and tested here and shown on the docs site. The store images of both examples are generated by scripts in `tools/` (not published), which drive headless, muted Chromium through Playwright. Read [SECURITY.md](SECURITY.md) before integrating any untrusted app.
231
307
 
308
+ ## Changes in 0.6.0 (since 0.5.2)
309
+
310
+ - **New: leaderboards.** The manifest's optional `leaderboards`; `os.finish({ score, board })` posts to a board (the default board `score` without one); `os.leaderboard()` and `os.showLeaderboard()`.
311
+ - **New: achievements.** The manifest's optional `achievements` (with optional 128 x 128 icons, checked by `os check`); `os.unlock()` and `os.achievements()`.
312
+ - **New: friends, invites and sharing.** `os.friends()`, `os.invite()`, `os.launch`, `os.onInvite()` and `os.share()`; app links `vmos://app/<appId>` and `https://vibechain.com/os/app/<appId>` for `os.open`, written by the new `appLink()` (also on the `VibemarketOS` global).
313
+ - **New: spending Printer Cash.** The manifest's optional `products`; `os.products()`, `os.buy()`, `os.purchases()`, `os.consume()` and `os.receiptToken()`, with the product review rules above.
314
+ - **New error codes:** `cancelled`, `insufficient`, `limit` and `guest` (thirteen in all).
315
+ - **Compatible both ways.** Still protocol 2: each new call is a new message a host lists in its hello features, so every 0.5 app works on a 0.6 host unchanged, and a 0.6 app on an older host gets `unsupported` from the new calls (nothing throws at import or connect; `finish` with a board ends the round without it). The `Os` interface gained the new members, so a hand-written object implementing `Os` needs them (use `createFakeOs`).
316
+ - **Manifest file:** `vibemarket.json` may be up to 64 KiB (was 16 KiB). Older manifests parse exactly as before.
317
+ - **Testing and preview.** `createFakeOs` fakes every new call (`setChoice`, `receiveInvite`, `services`, `host: "0.5"`); `os preview` answers them with the same fakes and draws marked stand-ins for vmOS's surfaces.
318
+ - **Host side** (for VibeMarket OS itself): `AppHostServices` gained an optional handler per call and `clicked`; the controller enforces the window state, arguments, guests, the click and the per-call rates before a handler runs.
319
+ - **Paw Beat 1.3.0** moves to `connect()` and schema version 3: its save follows the player, and it has a Top dancers board, three achievements, a share button, a Leaderboard button and a midnight coat for Biscuit.
320
+
321
+ ## Changes in 0.5.2 (since 0.5.1)
322
+
323
+ - **New: the desktop's sound.** The host sends `app.sound` (`{ muted, volume }`) with the port, before any answer, and on every change; `Os.sound` and `Os.onSound` are new, and the 0.4 object gains `sound.current()` and `sound.onChanged()`. `@vibechain/os/audio` (`createAudio`, also on the `VibemarketOS` global) gives an AudioContext and a master that follow it, the window and the browser's gesture rule, and recover a stopped or closed context. Nothing existing changed: older apps ignore the event, and on an older host the sound reads audible at full volume. The fake hosts (`setSound`) and the preview (a speaker and volume in its header) let you test it.
324
+ - **Paw Beat 1.2.0.** The bundled example has six original tracks; a random one plays each round, with a best score per track.
325
+
326
+
232
327
  ## Changes in 0.5.1 (since 0.5.0)
233
328
 
234
329
  - **New, optional: desktop photos.** The host may send `app.capture` and the SDK answers with a new `app.frame` request carrying the app's picture (by default its largest visible canvas). `Os.onCapture` and `VibeMarketAppSdk.onCapture` are new optional hooks to supply your own picture. Nothing existing was renamed or removed, and no app needs a code change: an app built with an older SDK, or one that sends nothing, is shown as its icon and name in desktop photos.
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 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.
3
+ These are bounded browser host controls, not a certification that arbitrary web code is safe. They grant no economy or wallet access, no payment other than a declared product the player confirms in vmOS's own spend dialog (SDK 0.6), 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
 
@@ -32,8 +32,8 @@ The flag is a claim made by the client's page-level marker, not a credential. On
32
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.
33
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.
34
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.
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.
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. Since 0.6 it can also receive: other players' public profile fields and scores on its own boards; the player's friends who installed the same app (public fields and a coarse presence, never the whole friends list); that an invite came from a named friend, with the `data` the sending app attached; its own achievements; and the player's receipts for its own products (never the Printer Cash balance: only that a purchase failed for lack of it). Spending, sharing and inviting need the app in front, a recent click in it and the player's confirmation in a dialog or sheet vmOS draws outside the frame, which the app cannot imitate, cover or click; the host checks the front state, the click, guests, the arguments and a per-call rate before the desk's handler runs. The host re-checks every card, pack, player, board, achievement, friend, invite, product and receipt 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.
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. The score is display data: it never sets a reward. A finished round of an approved app may earn the player a small amount of Printer Cash, decided and paid by VibeMarket OS within per-player daily caps. The app cannot grant, see or influence the amount, and nothing an app sends is trusted for it.
37
37
 
38
38
  ## Enforced accepted-work limits
39
39
 
@@ -65,13 +65,15 @@ The browser allocates structured-clone data before host validation. Message byte
65
65
 
66
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
67
 
68
+ **Sound (0.5.2).** The desktop's speaker and volume reach an app only as the `app.sound` event (`{ muted, volume }`, validated exactly by both ends): sent with the port before any answer, and on every change. It is cooperative, not enforcement: a browser cannot mute a sandboxed cross-origin frame from outside, so an app that ignores it, or a client older than 0.5.2, keeps sounding until its window goes behind another (then the lifecycle and, after the grace, teardown stop it) or the app is closed. Following the desktop's sound is a review rule, and `@vibechain/os/audio` follows it by default. The event tells the app nothing about the player beyond the desktop's own sound setting.
69
+
68
70
  **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
71
 
70
72
  **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
73
 
72
74
  **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
75
 
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.
76
+ 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. Leaderboard scores (0.6) are the app's own claims too: they are accepted only inside a server-timed round and at a bounded rate, and are not proof of skill. Rewards, inventory grants and spending require separate server-authoritative, replay-safe, idempotent and capped verification: the server takes a product's price from the approved manifest, never from the call, and spends in one ledger transaction keyed by the dialog's operation; this package implements none of that, only the messages.
75
77
 
76
78
  ## CLI sign-in and tokens
77
79
 
@@ -1,4 +1,4 @@
1
- import { APP_FRAGMENT, APP_LIMITS, appNonce, checkpointValue, lifecycleValue, FRAME_MESSAGE_BYTES } from "./app-protocol.js";
1
+ import { APP_FRAGMENT, APP_LIMITS, AUDIBLE, appNonce, checkpointValue, lifecycleValue, soundValue, FRAME_MESSAGE_BYTES } from "./app-protocol.js";
2
2
  import { connectHostPort, createRpcTransport } from "./transport.js";
3
3
  import { createCapturer } from "./capture.js";
4
4
  import { gameFinishInput } from "./completion.js";
@@ -20,8 +20,8 @@ export async function connectVibeMarketApp(signal) {
20
20
  export function createAppPortSdk(port, session) {
21
21
  if (!appNonce(session))
22
22
  throw Error("Invalid app session.");
23
- let state = Object.freeze({ active: true, width: 0, height: 0 });
24
- const listeners = new Set();
23
+ let state = Object.freeze({ active: true, width: 0, height: 0 }), sound = AUDIBLE;
24
+ const listeners = new Set(), sounds = new Set();
25
25
  const transport = createRpcTransport(port, {
26
26
  session, timeoutMs: APP_LIMITS.requestTimeoutMs, maxPending: APP_LIMITS.inFlight, jsonBytes: APP_LIMITS.responseBytes, outBytes: FRAME_MESSAGE_BYTES,
27
27
  onEvent(value) {
@@ -29,6 +29,21 @@ export function createAppPortSdk(port, session) {
29
29
  capturer.event(value.id);
30
30
  return;
31
31
  }
32
+ if (value.event === "app.sound") {
33
+ let next;
34
+ try {
35
+ next = soundValue(value.state);
36
+ }
37
+ catch {
38
+ return;
39
+ }
40
+ if (next.muted === sound.muted && next.volume === sound.volume)
41
+ return;
42
+ sound = next;
43
+ for (const listener of [...sounds])
44
+ listener(sound);
45
+ return;
46
+ }
32
47
  if (value.event !== "app.lifecycle")
33
48
  return;
34
49
  try {
@@ -54,7 +69,8 @@ export function createAppPortSdk(port, session) {
54
69
  async write(value) { complete(await transport.request({ method: "app.checkpoint.set", value: checkpointValue(value) })); },
55
70
  }),
56
71
  lifecycle: Object.freeze({ current: () => state, onChanged(listener) { listeners.add(listener); return () => { listeners.delete(listener); }; } }),
72
+ sound: Object.freeze({ current: () => sound, onChanged(listener) { sounds.add(listener); return () => { sounds.delete(listener); }; } }),
57
73
  onCapture(handler) { return capturer.on(handler); },
58
- destroy() { destroyed = true; capturer.clear(); listeners.clear(); transport.destroy(); },
74
+ destroy() { destroyed = true; capturer.clear(); listeners.clear(); sounds.clear(); transport.destroy(); },
59
75
  });
60
76
  }