OverviewFilesCommitsIssuesDocsReleasesPeers

pgh-runtime commits / 0c3ea13

Add README
Usage example, fetcher/store contracts, transport-agnostic note. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
0c3ea13e570bebff30a4b6fcd4845339aab7b932
by plankatron <fleeky@gmail.com> · 2026-05-02T21:04:02.000Z

Changed files (1) +59 -0

README.md +59 -0
……@@ -0,0 +1,59 @@
1# pgh-runtime
2
3Per-app OTA updater for `pgh`-installed apps. Embedded in each app;
4polls a release source, materializes new tree closures into the local
5TreeStore, emits events. The app decides when to apply (typically on
6next restart, via a supervisor signal).
7
8Mirrors `pear-runtime-updater`'s shape but uses `hyper-overlay`
9content-addressing instead of Hyperdrive.
10
11## Usage
12
13```js
14import { PghRuntime } from 'pgh-runtime'
15
16const runtime = new PghRuntime({
17 name: 'my-app',
18 currentTreeHash: process.env.PGH_CURRENT_TREE_HASH,
19 fetcher, // { getLatestRelease, getTree, getContent }
20 store, // TreeStore-compatible
21 interval: 60 * 60 * 1000 // 1h; 0 = no polling
22})
23
24runtime.on('updating', () => console.log('downloading...'))
25runtime.on('updated', (i) => console.log('ready:', i.newTreeHash))
26runtime.on('error', (e) => console.error(e))
27
28await runtime.start()
29```
30
31## Required interfaces
32
33```
34fetcher:
35 async getLatestRelease(name) -> { treeHash, version, ... } | null
36 async getTree(hash) -> { entries: [...], size }
37 async getContent(hash) -> Buffer
38
39store (TreeStore-compatible):
40 init()
41 hasTree(hash) -> boolean
42 materialize(hash, entries, { fetchContent, fetchTree, source? })
43```
44
45Transport-agnostic — any fetcher conforming to the shape above works.
46`pgh`'s `NetworkFetcher` provides the Hyperswarm implementation,
47talking to `pgh-sidecar`'s release-registry advertiser + DeployServer.
48
49## Tests
50
51```bash
52npm test
53```
54
55## Related
56
57- `pgh-sidecar` — release-registry source / DeployServer.
58- `pgh` — the CLI / supervisor that wires this runtime into apps.
59- `hyper-overlay` — the underlying content-addressed tree format.