@parcha/pi-durable-disk 0.0.0-stage → 0.1.0-beta.13

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 (50) hide show
  1. package/CHANGELOG.md +329 -0
  2. package/LICENSE +202 -0
  3. package/NOTICE +2 -0
  4. package/README.md +695 -2
  5. package/bin/archil-scoped +165 -0
  6. package/dist/app.d.ts +40 -0
  7. package/dist/app.js +47 -0
  8. package/dist/claim.d.ts +222 -0
  9. package/dist/claim.js +722 -0
  10. package/dist/cli.d.ts +64 -0
  11. package/dist/cli.js +664 -0
  12. package/dist/commands.d.ts +67 -0
  13. package/dist/commands.js +299 -0
  14. package/dist/confine.d.ts +91 -0
  15. package/dist/confine.js +341 -0
  16. package/dist/env.d.ts +129 -0
  17. package/dist/env.js +608 -0
  18. package/dist/errors.d.ts +47 -0
  19. package/dist/errors.js +55 -0
  20. package/dist/fork.d.ts +41 -0
  21. package/dist/fork.js +181 -0
  22. package/dist/hosts/daytona-launch.d.ts +52 -0
  23. package/dist/hosts/daytona-launch.js +270 -0
  24. package/dist/hosts/daytona.d.ts +147 -0
  25. package/dist/hosts/daytona.js +368 -0
  26. package/dist/hosts/docker.d.ts +103 -0
  27. package/dist/hosts/docker.js +362 -0
  28. package/dist/hosts/local-host.d.ts +71 -0
  29. package/dist/hosts/local-host.js +356 -0
  30. package/dist/index.d.ts +16 -0
  31. package/dist/index.js +17 -0
  32. package/dist/lease.d.ts +7 -0
  33. package/dist/lease.js +6 -0
  34. package/dist/local-run.d.ts +10 -0
  35. package/dist/local-run.js +63 -0
  36. package/dist/park.d.ts +92 -0
  37. package/dist/park.js +229 -0
  38. package/dist/run.d.ts +290 -0
  39. package/dist/run.js +785 -0
  40. package/dist/serve.d.ts +101 -0
  41. package/dist/serve.js +393 -0
  42. package/dist/status.d.ts +123 -0
  43. package/dist/status.js +264 -0
  44. package/dist/store.d.ts +103 -0
  45. package/dist/store.js +217 -0
  46. package/dist/supervise.d.ts +340 -0
  47. package/dist/supervise.js +528 -0
  48. package/dist/watchdog.d.ts +39 -0
  49. package/dist/watchdog.js +137 -0
  50. package/package.json +87 -4
package/dist/cli.d.ts ADDED
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env node
2
+ import { type Parking } from "./park.js";
3
+ import { type RunServer } from "./serve.js";
4
+ import { type DurableRun } from "./run.js";
5
+ /** "30s", "500ms", "2m", "1h", or plain milliseconds. */
6
+ /**
7
+ * Whether the lease watchdog may kill every other process in the instance's cgroup: only inside its own systemd unit,
8
+ * whose cgroup holds nothing but the instance and its commands. Elsewhere the cgroup may be shared (a login session, an
9
+ * agent host's service), so the watchdog kills only the instance's own command groups.
10
+ *
11
+ * The holder handle only claims a unit (`mode: "systemd"`, `unit`), and it arrives in an environment variable that any
12
+ * child inherits, so /proc decides: this process's cgroup v2 path must end in `/<unit>.service`, and its parent's cgroup
13
+ * must be another (a process that merely inherited the handle shares its parent's cgroup). When the handle claims a
14
+ * unit that /proc does not confirm, `warning` says why, for one log line.
15
+ */
16
+ export declare function watchdogOwnsCgroup(holder: Record<string, unknown>, options?: {
17
+ proc?: string;
18
+ ppid?: number;
19
+ }): {
20
+ owns: boolean;
21
+ warning?: string;
22
+ };
23
+ export declare function parseDuration(text: string): number;
24
+ /** `--run-as NAME|UID[:GID]`: the user the agent's commands run as, with its group and home from /etc/passwd when listed. */
25
+ export declare function runUser(spec: string, passwd?: string): {
26
+ uid: number;
27
+ gid: number;
28
+ home: string;
29
+ name: string;
30
+ };
31
+ /** What the instance does besides the app between its open and its exit. */
32
+ export interface InstanceLife {
33
+ /** How long a drain waits for running work before the release; 0 (default) releases at once. */
34
+ readonly drainMs?: number;
35
+ /** Park the run when its work allows (`watchParking`); absent, the instance stays up through every wait. */
36
+ readonly park?: {
37
+ readonly thresholdMs: number;
38
+ readonly idleMs?: number;
39
+ };
40
+ /** The serve front: its open requests keep the instance up, and a park or a drain stops its submissions. */
41
+ readonly server?: RunServer;
42
+ /** The app's wake hook; default run.json `sleeping` with `wakeAt`. */
43
+ readonly wake?: (run: DurableRun, at: number | null) => Promise<void>;
44
+ /** Handed the parking watch once it runs. */
45
+ readonly onParking?: (parking: Parking) => void;
46
+ }
47
+ /**
48
+ * The instance's life after the run opened: the app's `onOpen` runs; the run parks when `life.park` allows (the wake
49
+ * written, the run released, exit 0); SIGTERM or SIGINT drains and releases, and the drain's outcome is the exit code.
50
+ * A drain stops new submissions and waits up to `life.drainMs` for running work; with `resume` it then writes the run
51
+ * sleeping with its wake (the deadline its work waits for, null when idle and idle parking is on, otherwise now), so
52
+ * the supervisor starts it again and a deploy never strands it; a wake hook that refuses falls back to a due wake.
53
+ * `pause` seals it paused. A rejection of `onOpen` is the app failing (exit 1), except once a drain or a park's release
54
+ * began: closing the Harness under the app makes its work reject ("Session is closed"), and ending the process there
55
+ * would cut the release before its unmount (a container's FUSE daemon dies with the process, leaving the delegation
56
+ * orphaned).
57
+ */
58
+ export declare function serveUntilDone(run: Pick<DurableRun, "setStatus" | "release" | "record">, onOpen: ((run: DurableRun) => void | Promise<void>) | undefined, onSigterm: string | undefined, log: (event: string, extra?: Record<string, unknown>) => void, signals?: Pick<NodeJS.EventEmitter, "once">, life?: InstanceLife): Promise<number>;
59
+ /**
60
+ * The flags every instance this supervisor starts gets after `run`: `--app MODULE` (made absolute, since the unit's working
61
+ * directory is not the supervisor's) and any `--run-arg`, in that order.
62
+ */
63
+ export declare function instanceRunArgs(values: Record<string, unknown>): string[];
64
+ export declare function main(argv: string[]): Promise<number>;