@daugasauron/dolly 0.1.4-rc.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -10,7 +10,7 @@ an agent in place of a web frontend (`docs/agent-frontend.md` in the repository)
10
10
  | `@daugasauron/dolly` | The runtime: `boot()`, the kernel, the process runtime, and the host modules that are its own machinery (`runtime`, `http`, `threads`, `dso`, `stack`, `nena`, `snapshot`, `packages`). Building images stays with Dolly's site |
11
11
  | `@daugasauron/dolly-host-NAME` | One device host module each: `display` (Ghostty's terminal and programs' frames), `input`, `gpu`, `audio`, `microphone`, `touch`, `download` (as `dolly-host-save`: npm takes no new name with the word), `upload`, `sockets`, `pty` |
12
12
  | `@daugasauron/dolly-image-default` | The `default` image alone: a shell, its text tools, the terminal, curl, `amy`, `nena`, `ps`. `amy` lists what is installed and has nothing more to install |
13
- | `@daugasauron/dolly-image-pi-agent` | The `pi-agent` image alone: the Pi coding agent with JavaScript (Janis), shell tools, ripgrep and fd. The README's "Pi with npm" serves it with a policy |
13
+ | `@daugasauron/dolly-image-pi-minimal` | The `pi-minimal` image alone: the Pi coding agent with JavaScript (Janis), a shell, POSIX tools, curl, ripgrep and fd, on `display`, `input` and `download` alone. The README's "Pi with npm" serves it with a policy |
14
14
 
15
15
  ```sh
16
16
  npm install @daugasauron/dolly @daugasauron/dolly-image-default \
@@ -51,6 +51,7 @@ shows its own failure in the element.
51
51
  | `modules` | URLs of the `module.json` of each host module the page has. The registry loads these and no other; an image's `REQUIRES HOST` must be among them |
52
52
  | `site` | Optional: the URL of a site that serves Dolly's own pages (`session/`, `sessions/`, `docs/`), as Dolly's site does. Given, a saved session names itself in the tab's URL and modules link to those pages |
53
53
  | `http` | Optional `{ policy, relays }` for the HTTP broker, the page's one network edge (docs/http.md). Without a policy a program may fetch any HTTPS URL |
54
+ | `files` | Optional `{ "/absolute/path": text or Uint8Array }`, written over the image before its program starts: Pi's instructions and skills (`docs/agent-frontend.md`), a start script. Programs can read them; they are not for secrets |
54
55
 
55
56
  The page, not the image, chooses the modules and the policy, before anything of
56
57
  the image runs. A program reaches nothing of the browser but through them.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.4-rc.2",
2
+ "version": "0.1.4",
3
3
  "type": "module",
4
4
  "name": "@daugasauron/dolly",
5
5
  "license": "MIT",
package/src/browser.mjs CHANGED
@@ -35,15 +35,17 @@ function element(tag, properties, attributes = {}) {
35
35
  // directory `images` (images.mjs). The embedding, trusted page code, names the
36
36
  // host modules the page has (`modules`, the URLs of their manifests) and sets
37
37
  // the HTTP broker's policy (`http`: { policy, relays }), both before anything
38
- // of the guest runs. `site`, given, is the root of the routes a module may link
39
- // to (session/, sessions/, docs/). It resolves to the page's API (window.__dolly
40
- // on the site) once the image's ENTRY runs.
41
- export function boot(mount, { images, image, modules, site, http = {} } = {}) {
38
+ // of the guest runs. `files` ({ "/absolute/path": string or Uint8Array }) are
39
+ // written over the restored image before its ENTRY starts. `site`, given, is the
40
+ // root of the routes a module may link to (session/, sessions/, docs/). It
41
+ // resolves to the page's API (window.__dolly on the site) once the image's ENTRY runs.
42
+ export function boot(mount, { images, image, modules, site, http = {}, files = {} } = {}) {
42
43
  return run(mount, { images, modules, site, http }, async () => {
43
44
  const definition = DOLLY_IMAGES.find(candidate => candidate.image === image);
44
- if (!definition) throw new Error("invalid Dolly boot options");
45
+ if (!definition || typeof files !== "object" || files === null) throw new Error("invalid Dolly boot options");
45
46
  if (definition.entry === null) throw new Error(`${image} has no ENTRY; it only builds`);
46
- return { image, label: "PRECOMPILED SYSTEM", required: definition.hostRequirements ?? [] };
47
+ return { image, label: "PRECOMPILED SYSTEM", required: definition.hostRequirements ?? [],
48
+ start: () => ({ message: { files }, transfers: [] }) };
47
49
  });
48
50
  }
49
51
 
@@ -5,7 +5,7 @@ import { loadPackagedSnapshotMetadata, streamPackagedSystemSnapshot } from "./pa
5
5
  import { siteReference, hex } from "./static-asset.mjs";
6
6
  import { checkedMemoryRange, runImage } from "./worker-image.mjs";
7
7
 
8
- await runImage(async ({ image, mode }, host) => {
8
+ await runImage(async ({ image, mode, files: given = {} }, host) => {
9
9
  const definition = DOLLY_IMAGES.find(candidate => candidate.image === image);
10
10
  if (!definition || mode !== "snapshot") throw new Error("invalid Dolly image selection");
11
11
  const metadata = await loadPackagedSnapshotMetadata(image);
@@ -19,7 +19,7 @@ await runImage(async ({ image, mode }, host) => {
19
19
  // The kernel restores a snapshot against the list of its paths.
20
20
  files.write("/etc/dolly/image.manifest", `${metadata.manifest.join("\n")}\n`);
21
21
  },
22
- async restore({ kernel, memory, stage }) {
22
+ async restore({ kernel, memory, files, stage }) {
23
23
  stage("loading precompiled userspace snapshot...");
24
24
  const capacity = 1024 * 1024;
25
25
  const address = kernel.dolly_snapshot_restore_address(BigInt(capacity));
@@ -49,7 +49,10 @@ await runImage(async ({ image, mode }, host) => {
49
49
  throw new Error("Dolly rejected an incomplete snapshot part");
50
50
  return hex(staging().subarray(0, 32));
51
51
  });
52
- return { status: kernel.dolly_bootstrap_snapshot_end() };
52
+ const status = kernel.dolly_bootstrap_snapshot_end();
53
+ // The embedding's files (boot's `files`) lie over the image's.
54
+ if (status === 0) for (const [path, contents] of Object.entries(given)) files.write(path, contents);
55
+ return { status };
53
56
  },
54
57
  };
55
58
  });