@oxvm/cli 0.0.0-stage → 0.0.29
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/LICENSE +202 -0
- package/NOTICE +18 -0
- package/README.md +27 -2
- package/THIRD_PARTY_NOTICES.txt +52056 -0
- package/dist/arguments.d.ts +162 -0
- package/dist/arguments.js +1 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +2 -0
- package/dist/contracts.d.ts +98 -0
- package/dist/contracts.js +0 -0
- package/dist/environment.d.ts +4 -0
- package/dist/environment.js +1 -0
- package/dist/failure.d.ts +5 -0
- package/dist/failure.js +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/project-files.d.ts +2 -0
- package/dist/project-files.js +1 -0
- package/dist/project-lock.d.ts +13 -0
- package/dist/project-lock.js +4 -0
- package/dist/report.d.ts +3 -0
- package/dist/report.js +1 -0
- package/dist/run.d.ts +17 -0
- package/dist/run.js +36 -0
- package/dist/snapshot-commands.d.ts +7 -0
- package/dist/snapshot-commands.js +3 -0
- package/dist/snapshot-errors.d.ts +4 -0
- package/dist/snapshot-errors.js +2 -0
- package/dist/snapshot-help.d.ts +3 -0
- package/dist/snapshot-help.js +14 -0
- package/dist/snapshot-templates.d.ts +16 -0
- package/dist/snapshot-templates.js +58 -0
- package/dist/start-application.d.ts +2 -0
- package/dist/start-application.js +3 -0
- package/dist/starter-inputs.d.ts +13 -0
- package/dist/starter-inputs.js +1 -0
- package/dist/starter-release.d.ts +29 -0
- package/dist/starter-release.js +1 -0
- package/dist/starter-template.d.ts +9 -0
- package/dist/starter-template.js +2 -0
- package/dist/starter.generated.d.ts +1 -0
- package/dist/starter.generated.js +1 -0
- package/dist/starter.json +1 -0
- package/dist/template-files.d.ts +2 -0
- package/dist/template-files.js +1 -0
- package/dist/templates.d.ts +27 -0
- package/dist/templates.js +115 -0
- package/dist/validation.d.ts +5 -0
- package/dist/validation.js +1 -0
- package/dist/wasm-commands.d.ts +7 -0
- package/dist/wasm-commands.js +1 -0
- package/dist/wasm-errors.d.ts +2 -0
- package/dist/wasm-errors.js +1 -0
- package/dist/wasm-help.d.ts +3 -0
- package/dist/wasm-help.js +37 -0
- package/dist/wasm-release.d.ts +15 -0
- package/dist/wasm-release.js +8 -0
- package/dist/wasm-template-files.d.ts +50 -0
- package/dist/wasm-template-files.js +350 -0
- package/dist/wasm-template-network.d.ts +15 -0
- package/dist/wasm-template-network.js +91 -0
- package/dist/wasm-templates.d.ts +16 -0
- package/dist/wasm-templates.js +91 -0
- package/dist/wasm-text.d.ts +23 -0
- package/dist/wasm-text.js +40 -0
- package/package.json +56 -3
- package/sbom.cdx.json +8537 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import type { RuntimeMode } from "@oxvm/sdk";
|
|
2
|
+
import type { CliCommand } from "./contracts.js";
|
|
3
|
+
interface Common {
|
|
4
|
+
readonly kind: "command";
|
|
5
|
+
readonly json: boolean;
|
|
6
|
+
}
|
|
7
|
+
interface SnapshotOptions {
|
|
8
|
+
readonly browser?: "chromium" | "firefox" | "webkit";
|
|
9
|
+
readonly timeoutMs?: number;
|
|
10
|
+
readonly engineDir?: string;
|
|
11
|
+
}
|
|
12
|
+
interface SnapshotPublicationOptions extends SnapshotOptions {
|
|
13
|
+
readonly recipe?: string;
|
|
14
|
+
readonly signingKey: string;
|
|
15
|
+
readonly imageTrust?: string;
|
|
16
|
+
readonly out?: string;
|
|
17
|
+
readonly baseUrl?: string;
|
|
18
|
+
}
|
|
19
|
+
export type CLIInvocation = Common & ({
|
|
20
|
+
readonly command: "snapshot init";
|
|
21
|
+
readonly directory: string;
|
|
22
|
+
readonly name: string;
|
|
23
|
+
readonly mode?: RuntimeMode;
|
|
24
|
+
readonly image?: string;
|
|
25
|
+
readonly imageTrust?: string;
|
|
26
|
+
} | ({
|
|
27
|
+
readonly command: "snapshot build";
|
|
28
|
+
} & SnapshotPublicationOptions) | ({
|
|
29
|
+
readonly command: "snapshot pack";
|
|
30
|
+
readonly backup: string;
|
|
31
|
+
} & SnapshotPublicationOptions) | ({
|
|
32
|
+
readonly command: "snapshot test";
|
|
33
|
+
readonly bundle: string;
|
|
34
|
+
readonly trust: string;
|
|
35
|
+
readonly verify?: string;
|
|
36
|
+
} & SnapshotOptions) | {
|
|
37
|
+
readonly command: "snapshot inspect";
|
|
38
|
+
readonly artifact: string;
|
|
39
|
+
readonly trust?: string;
|
|
40
|
+
} | {
|
|
41
|
+
readonly command: "wasm add";
|
|
42
|
+
readonly source: string;
|
|
43
|
+
readonly project: string;
|
|
44
|
+
readonly yes: boolean;
|
|
45
|
+
readonly offline: boolean;
|
|
46
|
+
} | {
|
|
47
|
+
readonly command: "wasm stage";
|
|
48
|
+
readonly project: string;
|
|
49
|
+
readonly offline: boolean;
|
|
50
|
+
} | {
|
|
51
|
+
readonly command: "wasm doctor";
|
|
52
|
+
readonly project: string;
|
|
53
|
+
} | {
|
|
54
|
+
readonly command: "wasm inspect";
|
|
55
|
+
readonly file: string;
|
|
56
|
+
} | {
|
|
57
|
+
readonly command: "wasm build";
|
|
58
|
+
readonly project: string;
|
|
59
|
+
readonly check: boolean;
|
|
60
|
+
readonly out?: string;
|
|
61
|
+
readonly module?: string;
|
|
62
|
+
} | {
|
|
63
|
+
readonly command: "wasm release";
|
|
64
|
+
readonly project: string;
|
|
65
|
+
readonly out?: string;
|
|
66
|
+
readonly module?: string;
|
|
67
|
+
readonly repo?: string;
|
|
68
|
+
} | {
|
|
69
|
+
readonly command: "wasm init";
|
|
70
|
+
readonly directory: string;
|
|
71
|
+
readonly moduleKind: "command" | "service";
|
|
72
|
+
readonly id?: string;
|
|
73
|
+
readonly from?: string;
|
|
74
|
+
readonly network: "none" | "vm" | "internet";
|
|
75
|
+
} | {
|
|
76
|
+
readonly command: "wasm test";
|
|
77
|
+
readonly project: string;
|
|
78
|
+
readonly module?: string;
|
|
79
|
+
readonly image?: {
|
|
80
|
+
readonly bundle: string;
|
|
81
|
+
readonly trust: string;
|
|
82
|
+
};
|
|
83
|
+
readonly args: readonly string[];
|
|
84
|
+
readonly options: Readonly<Record<string, unknown>>;
|
|
85
|
+
readonly browser: "chromium" | "firefox" | "webkit";
|
|
86
|
+
readonly engineDir?: string;
|
|
87
|
+
readonly timeoutMs?: number;
|
|
88
|
+
} | {
|
|
89
|
+
readonly command: "init";
|
|
90
|
+
readonly directory: string;
|
|
91
|
+
readonly mode: RuntimeMode;
|
|
92
|
+
readonly skipAssets: boolean;
|
|
93
|
+
readonly start: boolean;
|
|
94
|
+
readonly packageManager: "npm" | "bun";
|
|
95
|
+
readonly archives?: {
|
|
96
|
+
readonly sdk: string;
|
|
97
|
+
readonly cli: string;
|
|
98
|
+
};
|
|
99
|
+
readonly engineDir?: string;
|
|
100
|
+
readonly image?: {
|
|
101
|
+
readonly bundle: string;
|
|
102
|
+
readonly trust: string;
|
|
103
|
+
};
|
|
104
|
+
} | {
|
|
105
|
+
readonly command: "assets install";
|
|
106
|
+
readonly config?: string;
|
|
107
|
+
readonly image?: string;
|
|
108
|
+
readonly snapshot?: string;
|
|
109
|
+
readonly trust?: string;
|
|
110
|
+
readonly reference?: string;
|
|
111
|
+
readonly engineDir?: string;
|
|
112
|
+
readonly updateLock: boolean;
|
|
113
|
+
} | {
|
|
114
|
+
readonly command: "doctor";
|
|
115
|
+
readonly url: string;
|
|
116
|
+
readonly browser: "chromium" | "firefox" | "webkit";
|
|
117
|
+
readonly hosting?: "frame" | "self-hosted";
|
|
118
|
+
readonly frameOrigin?: string;
|
|
119
|
+
readonly previewOrigin?: string;
|
|
120
|
+
readonly config?: string;
|
|
121
|
+
} | {
|
|
122
|
+
readonly command: "image init";
|
|
123
|
+
readonly directory: string;
|
|
124
|
+
readonly mode: RuntimeMode;
|
|
125
|
+
} | {
|
|
126
|
+
readonly command: "image keygen";
|
|
127
|
+
readonly out: string;
|
|
128
|
+
} | {
|
|
129
|
+
readonly command: "image build";
|
|
130
|
+
readonly recipe: string;
|
|
131
|
+
readonly signingKey: string;
|
|
132
|
+
readonly out?: string;
|
|
133
|
+
readonly baseUrl?: string;
|
|
134
|
+
readonly distribution: boolean;
|
|
135
|
+
readonly secrets: readonly {
|
|
136
|
+
readonly id: string;
|
|
137
|
+
readonly file: string;
|
|
138
|
+
}[];
|
|
139
|
+
} | {
|
|
140
|
+
readonly command: "image test";
|
|
141
|
+
readonly bundle: string;
|
|
142
|
+
readonly trust: string;
|
|
143
|
+
readonly browser: "chromium" | "firefox" | "webkit";
|
|
144
|
+
readonly distribution: boolean;
|
|
145
|
+
readonly engineDir?: string;
|
|
146
|
+
} | {
|
|
147
|
+
readonly command: "image inspect";
|
|
148
|
+
readonly bundle: string;
|
|
149
|
+
readonly trust?: string;
|
|
150
|
+
} | {
|
|
151
|
+
readonly command: "image pack";
|
|
152
|
+
readonly bundle: string;
|
|
153
|
+
readonly trust: string;
|
|
154
|
+
});
|
|
155
|
+
export type ParsedArguments = CLIInvocation | {
|
|
156
|
+
readonly kind: "help" | "version";
|
|
157
|
+
readonly json: boolean;
|
|
158
|
+
readonly command?: CliCommand;
|
|
159
|
+
};
|
|
160
|
+
/** Node parses the fixed CLI grammar; validate correlations before acquiring any resource. */
|
|
161
|
+
export declare function parseArguments(arguments_: readonly string[], environment: Readonly<Record<string, string | undefined>>): ParsedArguments;
|
|
162
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var x=Object.defineProperty;var m=(u,o)=>x(u,"name",{value:o,configurable:!0});import{parseArgs as $}from"node:util";import{VMError as L}from"@oxvm/sdk";import{setting as y}from"./environment.js";function r(u){throw new L("INVALID_ARGUMENT",u)}m(r,"invalid");function G(u){const o={};for(const e of u){const c=e.indexOf("="),l=e.slice(0,c),w=e.slice(c+1);if(c<1||!/^[A-Za-z][A-Za-z0-9_-]{0,63}$/u.test(l)||w.length>8192)return r("--option must be name=value");if(Object.hasOwn(o,l))return r(`--option ${l} was given twice`);let k=w;try{const h=JSON.parse(w);(typeof h=="number"||typeof h=="boolean"||Array.isArray(h))&&(k=h)}catch{}o[l]=k}return o}m(G,"moduleOptions");function U(u){return u===void 0||u==="frame"||u==="self-hosted"?u:r("--hosting must be frame or self-hosted")}m(U,"doctorHosting");function s(u,o){return typeof u!="string"||u.length===0||u.length>8192||u.includes("\0")?r(`${o} is required and must be bounded text`):u}m(s,"nonempty");const A={init:["mode","skip-assets","engine-dir","image","image-trust","start","use-bun","sdk-archive","cli-archive"],"assets install":["config","image","snapshot","trust","reference","engine-dir","update-lock"],doctor:["browser","hosting","frame-origin","preview-origin","config"],"image init":["mode"],"image keygen":["out"],"image build":["signing-key","out","base-url","distribution","secret"],"image test":["trust","browser","distribution","engine-dir"],"image inspect":["trust"],"image pack":["trust"],"snapshot pack":["recipe","signing-key","image-trust","out","base-url","browser","timeout-ms","engine-dir"],"snapshot test":["trust","verify","browser","timeout-ms","engine-dir"],"snapshot inspect":["trust"],"snapshot init":["name","mode","image","image-trust"],"snapshot build":["signing-key","image-trust","out","base-url","browser","timeout-ms","engine-dir"],"wasm add":["project","yes","offline"],"wasm stage":["project","offline"],"wasm doctor":["project"],"wasm inspect":[],"wasm build":["project","out","module","check"],"wasm release":["project","out","module","repo"],"wasm init":["kind","id","from","network"],"wasm test":["project","module","image","image-trust","arg","option","browser","engine-dir","timeout-ms"]};function R(u,o){let e;try{e=$({args:[...u],allowPositionals:!0,strict:!0,tokens:!0,options:{json:{type:"boolean"},help:{type:"boolean"},version:{type:"boolean"},mode:{type:"string"},"skip-assets":{type:"boolean"},config:{type:"string"},image:{type:"string"},reference:{type:"string"},browser:{type:"string"},hosting:{type:"string"},"frame-origin":{type:"string"},"preview-origin":{type:"string"},out:{type:"string"},"signing-key":{type:"string"},"base-url":{type:"string"},distribution:{type:"boolean"},trust:{type:"string"},secret:{type:"string",multiple:!0},"engine-dir":{type:"string"},recipe:{type:"string"},"image-trust":{type:"string"},verify:{type:"string"},"timeout-ms":{type:"string"},name:{type:"string"},snapshot:{type:"string"},project:{type:"string"},yes:{type:"boolean"},offline:{type:"boolean"},module:{type:"string"},check:{type:"boolean"},arg:{type:"string",multiple:!0},option:{type:"string",multiple:!0},kind:{type:"string"},id:{type:"string"},from:{type:"string"},repo:{type:"string"},network:{type:"string"},start:{type:"boolean"},"use-bun":{type:"boolean"},"sdk-archive":{type:"string"},"cli-archive":{type:"string"},"update-lock":{type:"boolean"}}})}catch{return r("unknown flag or missing flag value; use --help")}const c=e.values.json===!0;if(e.values.help===!0||e.values.version===!0){if(e.values.help===!0&&e.values.version===!0)return r("--help and --version cannot be combined");if(c)return r("Use help or version without --json");const t=e.positionals.slice(0,2).join(" ");return e.values.help===!0&&(t.startsWith("snapshot ")||t.startsWith("wasm "))&&N(t)?{kind:"help",json:c,command:t}:{kind:e.values.help===!0?"help":"version",json:c}}const[l,w]=e.positionals,k=l==="image"||l==="assets"||l==="snapshot"||l==="wasm",h=k?`${l} ${w??""}`:l;let n;for(const t of Object.keys(A))t===h&&N(t)&&(n=t);if(n===void 0)return r("unknown or missing command; use --help");const S=new Set;for(const t of e.tokens)if(t.kind==="option"){if(t.name!=="json"&&!A[n].includes(t.name))return r(`--${t.name} is not supported by ${n}`);if(S.has(t.name)&&!["secret","arg","option"].includes(t.name))return r(`--${t.name} was repeated`);S.add(t.name)}const b=e.positionals.slice(k?2:1),O=n==="assets install"||n==="image keygen"||n==="wasm stage"||n==="wasm doctor"||n==="wasm build"||n==="wasm release"||n==="wasm test"?0:1;if(b.length>O||n!=="doctor"&&n!=="snapshot init"&&n!=="snapshot build"&&b.length!==O)return r("unexpected or missing positional arguments");const d=m(()=>s(b[0],"command path"),"argument"),I=m(()=>e.values.mode==="system"?"system":e.values.mode==="userspace"?"userspace":r("--mode must be system or userspace"),"mode"),_=m(()=>{const t=e.values.browser??"chromium";return t==="chromium"||t==="firefox"||t==="webkit"?t:r("--browser must be chromium, firefox or webkit")},"browser"),i={kind:"command",json:c},j=e.values["engine-dir"]===void 0?{}:{engineDir:s(e.values["engine-dir"],"--engine-dir")};let f;if(e.values["timeout-ms"]!==void 0){const t=e.values["timeout-ms"];if(!/^[1-9][0-9]*$/u.test(t))return r("--timeout-ms must be an integer");if(f=Number(t),!Number.isSafeInteger(f)||f>2147483647)return r("--timeout-ms exceeds the timer bound")}const T={...j,...e.values.browser===void 0?{}:{browser:_()},...f===void 0?{}:{timeoutMs:f}};switch(n){case"snapshot init":return{...i,command:n,directory:b[0]??"snapshots/ready",name:s(e.values.name??"ready","snapshot name"),...e.values.mode===void 0?{}:{mode:I()},...e.values.image===void 0?{}:{image:s(e.values.image,"--image")},...e.values["image-trust"]===void 0?{}:{imageTrust:s(e.values["image-trust"],"--image-trust")}};case"wasm add":return{...i,command:n,source:d(),project:e.values.project??".",yes:e.values.yes===!0,offline:e.values.offline===!0};case"wasm stage":return{...i,command:n,project:e.values.project??".",offline:e.values.offline===!0};case"wasm doctor":return{...i,command:n,project:e.values.project??"."};case"wasm inspect":return{...i,command:n,file:d()};case"wasm build":return{...i,command:n,project:e.values.project??".",check:e.values.check===!0,...e.values.out===void 0?{}:{out:s(e.values.out,"--out")},...e.values.module===void 0?{}:{module:s(e.values.module,"--module")}};case"wasm release":{const t=e.values.repo;return t!==void 0&&!/^[A-Za-z0-9][A-Za-z0-9-]{0,38}\/[A-Za-z0-9._-]{1,100}$/u.test(t)?r("--repo must be owner/name"):{...i,command:n,project:e.values.project??".",...e.values.out===void 0?{}:{out:s(e.values.out,"--out")},...e.values.module===void 0?{}:{module:s(e.values.module,"--module")},...t===void 0?{}:{repo:t}}}case"wasm test":{const t=e.values.image,a=e.values["image-trust"];if(t===void 0!=(a===void 0))return r("--image and --image-trust must be supplied together");const v=G(e.values.option??[]),g=(e.values.arg??[]).map(p=>p.length>8192||p.includes("\0")?r("--arg must be bounded text"):p);return{...i,command:n,project:e.values.project??".",...e.values.module===void 0?{}:{module:s(e.values.module,"--module")},...t===void 0?{}:{image:{bundle:s(t,"--image"),trust:s(a,"--image-trust")}},args:g,options:v,browser:_(),...j,...f===void 0?{}:{timeoutMs:f}}}case"wasm init":{const t=e.values.kind??"command";if(t!=="command"&&t!=="service")return r("--kind must be command or service");const a=e.values.network??"none";return a!=="none"&&a!=="vm"&&a!=="internet"?r("--network must be none, vm or internet"):{...i,command:n,directory:d(),moduleKind:t,network:a,...e.values.id===void 0?{}:{id:s(e.values.id,"--id")},...e.values.from===void 0?{}:{from:s(e.values.from,"--from")}}}case"snapshot build":case"snapshot pack":{const t=n==="snapshot build"?b[0]:e.values.recipe,a={...i,...t===void 0?{}:{recipe:t},signingKey:s(e.values["signing-key"]??y(o,"SIGNING_KEY_FILE"),"snapshot signing key"),...e.values["image-trust"]===void 0?{}:{imageTrust:s(e.values["image-trust"],"--image-trust")},...e.values.out===void 0?{}:{out:s(e.values.out,"--out")},...e.values["base-url"]===void 0?{}:{baseUrl:s(e.values["base-url"],"--base-url")},...T};return n==="snapshot build"?{...a,command:n}:{...a,command:n,backup:d()}}case"snapshot test":return{...i,command:n,bundle:d(),trust:s(e.values.trust??y(o,"SNAPSHOT_TRUST_FILE"),"snapshot author trust"),...e.values.verify===void 0?{}:{verify:s(e.values.verify,"--verify")},...T};case"snapshot inspect":{const t=e.values.trust??y(o,"SNAPSHOT_TRUST_FILE");return{...i,command:n,artifact:d(),...t===void 0?{}:{trust:s(t,"snapshot author trust")}}}case"init":{if(e.values.start===!0&&(e.values["skip-assets"]===!0||c))return r("--start requires installed assets and cannot be combined with --json");const t=e.values["sdk-archive"],a=e.values["cli-archive"];if(t===void 0!=(a===void 0))return r("--sdk-archive and --cli-archive must be supplied together");const v=t===void 0?{}:{archives:{sdk:s(t,"--sdk-archive"),cli:s(a,"--cli-archive")}};if(e.values["skip-assets"]===!0&&e.values["engine-dir"]!==void 0)return r("--engine-dir installs assets and cannot be combined with --skip-assets");const g=e.values.image,p=e.values["image-trust"];if(g===void 0!=(p===void 0))return r("--image and --image-trust must be supplied together");const E=g===void 0?void 0:{bundle:s(g,"--image"),trust:s(p,"--image-trust")};return{...i,command:n,directory:d(),mode:e.values.mode===void 0?"userspace":I(),skipAssets:e.values["skip-assets"]===!0,start:e.values.start===!0,packageManager:e.values["use-bun"]===!0?"bun":"npm",...v,...j,...E===void 0?{}:{image:E}}}case"assets install":{if(e.values.snapshot!==void 0&&e.values.image!==void 0)return r("--snapshot and --image are exclusive");if(e.values.reference!==void 0&&e.values.image===void 0&&e.values.snapshot===void 0)return r("--reference requires --image or --snapshot");if(e.values.trust!==void 0&&e.values.snapshot===void 0&&e.values.image===void 0)return r("--trust requires --snapshot or --image");const t=e.values.snapshot===void 0?{}:{snapshot:s(e.values.snapshot,"--snapshot"),trust:s(e.values.trust??y(o,"SNAPSHOT_TRUST_FILE"),"snapshot author trust")};return{...i,command:n,...e.values.config===void 0?{}:{config:s(e.values.config,"--config")},...e.values.image===void 0?{}:{image:s(e.values.image,"--image")},...e.values.trust===void 0?{}:{trust:s(e.values.trust,"--trust")},...t,...e.values.reference===void 0?{}:{reference:s(e.values.reference,"--reference")},...j,updateLock:e.values["update-lock"]===!0}}case"doctor":{const t=U(e.values.hosting);return t==="self-hosted"&&e.values["frame-origin"]!==void 0?r("--frame-origin applies only to --hosting frame"):{...i,command:n,url:b[0]??"http://localhost:5173/",browser:_(),...t===void 0?{}:{hosting:t},...e.values["frame-origin"]===void 0?{}:{frameOrigin:s(e.values["frame-origin"],"--frame-origin")},...e.values["preview-origin"]===void 0?{}:{previewOrigin:s(e.values["preview-origin"],"--preview-origin")},...e.values.config===void 0?{}:{config:s(e.values.config,"--config")}}}case"image init":return{...i,command:n,directory:d(),mode:I()};case"image keygen":return{...i,command:n,out:s(e.values.out,"--out")};case"image build":{const t=(e.values.secret??[]).map(a=>{const v=a.indexOf("="),g=a.slice(0,v),p=a.slice(v+1);return v<1||!/^[A-Za-z0-9_-]{1,64}$/u.test(g)||p.length===0?r("--secret must be id=path"):{id:g,file:p}});return new Set(t.map(a=>a.id)).size!==t.length?r("duplicate BuildKit secret id"):{...i,command:n,recipe:d(),signingKey:s(e.values["signing-key"]??y(o,"SIGNING_KEY_FILE"),"--signing-key or OXVM_SIGNING_KEY_FILE"),distribution:e.values.distribution===!0,secrets:t,...e.values.out===void 0?{}:{out:s(e.values.out,"--out")},...e.values["base-url"]===void 0?{}:{baseUrl:s(e.values["base-url"],"--base-url")}}}case"image test":return{...i,command:n,bundle:d(),trust:s(e.values.trust??y(o,"IMAGE_TRUST_FILE"),"--trust or OXVM_IMAGE_TRUST_FILE"),browser:_(),distribution:e.values.distribution===!0,...j};case"image inspect":return{...i,command:n,bundle:d(),...e.values.trust===void 0?{}:{trust:s(e.values.trust,"--trust")}};case"image pack":return{...i,command:n,bundle:d(),trust:s(e.values.trust,"--trust")}}}m(R,"parseArguments");function N(u){return Object.hasOwn(A,u)}m(N,"isCommand");export{R as parseArguments};
|
package/dist/bin.d.ts
ADDED
package/dist/bin.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var c=Object.defineProperty;var r=(s,t)=>c(s,"name",{value:t,configurable:!0});import{createInterface as a}from"node:readline/promises";import{runCLI as l}from"./run.js";async function p(s,t){const o=a({input:process.stdin,output:process.stderr});try{return/^y(?:es)?$/iu.test((await o.question(s,{signal:t})).trim())}catch{return!1}finally{o.close()}}r(p,"ask");const e=new AbortController,n=r(()=>{e.abort({kind:"signal",signal:"SIGINT"})},"interrupt"),i=r(()=>{e.abort({kind:"signal",signal:"SIGTERM"})},"terminate");process.on("SIGINT",n),process.on("SIGTERM",i);try{process.exitCode=await l(process.argv.slice(2),{directory:process.cwd(),environment:process.env,signal:e.signal,stdout:r(s=>{process.stdout.write(s)},"stdout"),stderr:r(s=>{process.stderr.write(s)},"stderr"),...process.stdin.isTTY&&process.stderr.isTTY?{confirm:r(s=>p(s,e.signal),"confirm")}:{}})}finally{process.off("SIGINT",n),process.off("SIGTERM",i)}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { RuntimeMode, SHA256, VMErrorCode } from "@oxvm/sdk";
|
|
2
|
+
import type { DoctorReport, ImageDistribution, ImageInspection, ImagePackReport, ImageTestReport, ProjectLockChange, SnapshotBuildResult, SnapshotTestReport, SnapshotInspectResult, WasmAddResult, WasmBuildResult, WasmDoctorReport, WasmInspectResult, WasmStageResult, WasmTestReport } from "@oxvm/sdk/image-builder";
|
|
3
|
+
/** The deployment doctor's report is the SDK's (`decodeDoctorReport` owns its decoding). */
|
|
4
|
+
export type { DoctorCheck, DoctorHosting, DoctorReport } from "@oxvm/sdk/image-builder";
|
|
5
|
+
export interface WasmInitResult {
|
|
6
|
+
readonly directory: string;
|
|
7
|
+
readonly id: string;
|
|
8
|
+
readonly kind: "command" | "service";
|
|
9
|
+
readonly abi: string;
|
|
10
|
+
/** The network reach module.ts declares (engine ADR 0029): `wasm init --network`. */
|
|
11
|
+
readonly network: "none" | "vm" | "internet";
|
|
12
|
+
/** Every file created, relative to the directory and sorted. */
|
|
13
|
+
readonly files: readonly string[];
|
|
14
|
+
/**
|
|
15
|
+
* A command module's `commands` as module.ts declares them: its id, or none when the id starts with the reserved prefix
|
|
16
|
+
* `oxidevm`. A service has no such key.
|
|
17
|
+
*/
|
|
18
|
+
readonly commands?: readonly string[];
|
|
19
|
+
}
|
|
20
|
+
/** A finished build plus the commands that publish it. Nothing here has been run. */
|
|
21
|
+
export interface WasmReleaseResult {
|
|
22
|
+
readonly build: WasmBuildResult;
|
|
23
|
+
/** The git tag the release must carry, `v` plus the version; null when the build failed. */
|
|
24
|
+
readonly tag: string | null;
|
|
25
|
+
readonly steps: readonly string[];
|
|
26
|
+
}
|
|
27
|
+
export interface CliResultMap {
|
|
28
|
+
readonly "wasm add": WasmAddResult;
|
|
29
|
+
readonly "wasm stage": WasmStageResult;
|
|
30
|
+
readonly "wasm doctor": WasmDoctorReport;
|
|
31
|
+
readonly "wasm inspect": WasmInspectResult;
|
|
32
|
+
readonly "wasm build": WasmBuildResult;
|
|
33
|
+
readonly "wasm release": WasmReleaseResult;
|
|
34
|
+
readonly "wasm init": WasmInitResult;
|
|
35
|
+
readonly "wasm test": WasmTestReport;
|
|
36
|
+
readonly "snapshot init": {
|
|
37
|
+
readonly directory: string;
|
|
38
|
+
readonly recipePath: string;
|
|
39
|
+
readonly mode: RuntimeMode;
|
|
40
|
+
readonly name: string;
|
|
41
|
+
readonly files: readonly string[];
|
|
42
|
+
};
|
|
43
|
+
readonly "snapshot build": SnapshotBuildResult;
|
|
44
|
+
readonly "snapshot pack": SnapshotBuildResult;
|
|
45
|
+
readonly "snapshot test": SnapshotTestReport;
|
|
46
|
+
readonly "snapshot inspect": SnapshotInspectResult;
|
|
47
|
+
readonly init: {
|
|
48
|
+
readonly directory: string;
|
|
49
|
+
readonly mode: RuntimeMode;
|
|
50
|
+
readonly assets: "installed" | "skipped";
|
|
51
|
+
};
|
|
52
|
+
readonly "assets install": {
|
|
53
|
+
readonly publicDir: string;
|
|
54
|
+
readonly files: number;
|
|
55
|
+
readonly referencePath: string | null;
|
|
56
|
+
readonly lock: ProjectLockChange;
|
|
57
|
+
};
|
|
58
|
+
readonly doctor: DoctorReport;
|
|
59
|
+
readonly "image init": {
|
|
60
|
+
readonly directory: string;
|
|
61
|
+
readonly recipePath: string;
|
|
62
|
+
readonly mode: RuntimeMode;
|
|
63
|
+
};
|
|
64
|
+
readonly "image keygen": {
|
|
65
|
+
readonly privateKeyPath: string;
|
|
66
|
+
readonly publicKeyPath: string;
|
|
67
|
+
readonly keyId: string;
|
|
68
|
+
};
|
|
69
|
+
readonly "image build": {
|
|
70
|
+
readonly mode: RuntimeMode;
|
|
71
|
+
readonly manifestSHA256: SHA256;
|
|
72
|
+
readonly bundleDir: string;
|
|
73
|
+
readonly referencePath: string;
|
|
74
|
+
readonly lockPath: string;
|
|
75
|
+
readonly distribution: ImageDistribution;
|
|
76
|
+
};
|
|
77
|
+
readonly "image test": ImageTestReport;
|
|
78
|
+
readonly "image inspect": ImageInspection;
|
|
79
|
+
readonly "image pack": ImagePackReport;
|
|
80
|
+
}
|
|
81
|
+
export type CliCommand = keyof CliResultMap;
|
|
82
|
+
export type CliReport = {
|
|
83
|
+
readonly [K in CliCommand]: {
|
|
84
|
+
readonly schemaVersion: 3;
|
|
85
|
+
readonly kind: "result";
|
|
86
|
+
readonly command: K;
|
|
87
|
+
readonly result: CliResultMap[K];
|
|
88
|
+
};
|
|
89
|
+
}[CliCommand] | {
|
|
90
|
+
readonly schemaVersion: 3;
|
|
91
|
+
readonly kind: "error";
|
|
92
|
+
readonly command: CliCommand | null;
|
|
93
|
+
readonly error: {
|
|
94
|
+
readonly code: VMErrorCode;
|
|
95
|
+
readonly message: string;
|
|
96
|
+
readonly detail?: Readonly<Record<string, unknown>>;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
type Setting = "SIGNING_KEY_FILE" | "IMAGE_TRUST_FILE" | "SNAPSHOT_TRUST_FILE";
|
|
2
|
+
/** Flags override this fallback; conflicting environment aliases never select a key silently. */
|
|
3
|
+
export declare function setting(environment: Readonly<Record<string, string | undefined>>, name: Setting): string | undefined;
|
|
4
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var f=Object.defineProperty;var c=(e,r)=>f(e,"name",{value:r,configurable:!0});import{VMError as u}from"@oxvm/sdk";function a(e,r){const o=`OXVM_${r}`,i=`OXIDEVM_${r}`,n=e[o],t=e[i];if(n!==void 0&&t!==void 0&&n!==t)throw new u("INVALID_ARGUMENT",`${o} and ${i} differ; set one value or use the explicit flag`);return n??t}c(a,"setting");export{a as setting};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The text for a failed command. Raw filesystem and tool errors can include author paths or secrets, so an
|
|
3
|
+
* error that is not an SDK error contributes only its errno name (for example ENOSPC), never its message.
|
|
4
|
+
*/
|
|
5
|
+
export declare function failureMessage(error: unknown): string;
|
package/dist/failure.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var i=Object.defineProperty;var t=(e,n)=>i(e,"name",{value:n,configurable:!0});import{VMError as s}from"@oxvm/sdk";const l="operation failed; check the selected files and installed tools";function a(e){return e instanceof s?e.message:typeof e=="object"&&e!==null&&"code"in e&&typeof e.code=="string"&&/^E[A-Z0-9]{1,15}$/u.test(e.code)?`operation failed (${e.code}); check the selected files and installed tools`:l}t(a,"failureMessage");export{a as failureMessage};
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{decodeCliReport as r}from"./report.js";export{r as decodeCliReport};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var c=Object.defineProperty;var r=(t,o)=>c(t,"name",{value:o,configurable:!0});import{lstat as u}from"node:fs/promises";import{resolve as d}from"node:path";import{VMError as a}from"@oxvm/sdk";async function f(t,o){const n=d(t,o);try{return await u(n),n}catch(e){if(typeof e=="object"&&e!==null&&"code"in e&&e.code==="ENOENT")return;throw e}}r(f,"find");async function s(t,o,n){const[e,i]=await Promise.all([f(t,o),f(t,n)]);if(e!==void 0&&i!==void 0)throw new a("INVALID_ARGUMENT",`Both ${o} and ${n} exist; select the intended file explicitly`,{reason:"project-file-conflict"});return e??i}r(s,"discover");function x(t){return s(t,"oxvm.config.ts","oxidevm.config.ts")}r(x,"defaultProjectConfig");function v(t){return s(t,"oxvm.snapshot.ts","oxidevm.snapshot.ts")}r(v,"defaultSnapshotRecipe");export{x as defaultProjectConfig,v as defaultSnapshotRecipe};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ProjectLockChange } from "@oxvm/sdk/image-builder";
|
|
2
|
+
/** The versions `--update-lock` binds: this CLI, the SDK it runs and the SDK the project resolves (null when none). */
|
|
3
|
+
export interface LockVersions {
|
|
4
|
+
readonly cli: string;
|
|
5
|
+
readonly runtime: string;
|
|
6
|
+
readonly project: string | null;
|
|
7
|
+
}
|
|
8
|
+
/** Why `--update-lock` cannot write one release into the lock, or undefined when all three versions agree. */
|
|
9
|
+
export declare function versionRefusal({ cli, runtime, project }: LockVersions): string | undefined;
|
|
10
|
+
/** A lock written by this CLI is true only when the project builds with the same SDK release. */
|
|
11
|
+
export declare function requireOneRelease(projectDirectory: string): Promise<void>;
|
|
12
|
+
/** What `assets install` did to the project lock, old → new, for stderr; nothing when it neither wrote nor was asked to. */
|
|
13
|
+
export declare function lockChangeText(change: ProjectLockChange, requested: boolean): string;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var p=Object.defineProperty;var s=(t,e)=>p(t,"name",{value:e,configurable:!0});import{open as g}from"node:fs/promises";import{dirname as f,join as m,resolve as h}from"node:path";import{VMError as r}from"@oxvm/sdk";import{getSDKRelease as k}from"@oxvm/sdk/image-builder";import{object as w}from"./validation.js";const v=64*1024,R=/^[0-9A-Za-z][0-9A-Za-z.+-]{0,63}$/u;function x({cli:t,runtime:e,project:n}){if(n===t&&e===t)return;const o=n===null?"no @oxvm/sdk installed beside":`@oxvm/sdk ${n} and`,i=e===t?"":`, which runs @oxvm/sdk ${e}`;return`--update-lock writes the lock for one release, but this project has ${o} @oxvm/cli ${t}${i}; install both at the same version, then run \`npx oxvm assets install --update-lock\` again`}s(x,"versionRefusal");function O(t,e){let n;try{n=JSON.parse(t.toString("utf8"))}catch{throw new r("PROTOCOL_ERROR",`${e} package manifest is not JSON`)}const o=w(n,`${e} package manifest`),i=o.version;if(o.name!==e)throw new r("INVALID_ARGUMENT",`${e} resolves to a different package; install a matching @oxvm/sdk and @oxvm/cli pair before updating its lock`);if(typeof i!="string"||!R.test(i))throw new r("PROTOCOL_ERROR",`${e} package manifest has an invalid version`);return i}s(O,"manifestVersion");async function d(t,e){let n;try{n=await g(t,"r")}catch(o){if(typeof o=="object"&&o!==null&&"code"in o&&(o.code==="ENOENT"||o.code==="ENOTDIR"))return null;throw o}try{if((await n.stat()).size>v)throw new r("PROTOCOL_ERROR",`${e} package manifest exceeds its limit`);return O(await n.readFile(),e)}finally{await n.close()}}s(d,"packageVersion");async function $(t){for(let e=h(t);;e=f(e)){const n=await d(m(e,"node_modules","@oxvm","sdk","package.json"),"@oxvm/sdk");if(await d(m(e,"node_modules","@oxidevm","sdk","package.json"),"@oxidevm/sdk")!==null)throw new r("INVALID_ARGUMENT","This project still installs @oxidevm/sdk; install a matching @oxvm/sdk and @oxvm/cli pair before updating its lock");if(n!==null||f(e)===e)return n}}s($,"projectSDKVersion");async function j(t){const e=await d(new URL("../package.json",import.meta.url),"@oxvm/cli");if(e===null)throw new r("PROTOCOL_ERROR","the @oxvm/cli package manifest is missing");const n=x({cli:e,runtime:k().sdkVersion,project:await $(t)});if(n!==void 0)throw new r("INVALID_ARGUMENT",n)}s(j,"requireOneRelease");function A(t,e){const n=s(a=>({SDK:a.sdkVersion,engine:a.engineRelease,image:`sha256:${a.manifestSHA256}`}),"release"),o=n(t.to);if(!t.updated)return e?`The project lock already matches this SDK release (SDK ${o.SDK}, engine ${o.engine}, image ${o.image}); nothing to rewrite
|
|
2
|
+
`:"";const i=t.from===void 0?void 0:n(t.from),u=["SDK","engine","image"].map(a=>{const c=o[a],l=i?.[a];return` ${a.padEnd(8)}${l===void 0?c:l===c?`${c} (unchanged)`:`${l} \u2192 ${c}`}
|
|
3
|
+
`});return`${i===void 0?"Wrote":"Updated"} the project lock for this SDK release:
|
|
4
|
+
${u.join("")}`}s(A,"lockChangeText");export{A as lockChangeText,j as requireOneRelease,x as versionRefusal};
|
package/dist/report.d.ts
ADDED
package/dist/report.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var R=Object.defineProperty;var m=(d,r)=>R(d,"name",{value:r,configurable:!0});import{VMError as o}from"@oxvm/sdk";import{decodeBuilderError as g,decodeDoctorReport as w,decodeImageDigest as h,decodeImageDistribution as P,decodeImageInspection as O,decodeImageTestReport as b,decodeSnapshotBuildResult as V,decodeSnapshotTestReport as A,decodeSnapshotInspectResult as C,decodeWasmAddResult as I,decodeWasmBuildResult as f,decodeWasmDoctorReport as S,decodeWasmInspectResult as L,decodeWasmStageResult as T,decodeWasmTestReport as D}from"@oxvm/sdk/image-builder";import{choice as i,fields as n,number as u,object as p,text as t}from"./validation.js";const k=["init","assets install","doctor","image init","image keygen","image build","image test","image inspect","image pack","snapshot init","snapshot build","snapshot pack","snapshot test","snapshot inspect","wasm add","wasm stage","wasm doctor","wasm inspect","wasm build","wasm release","wasm init","wasm test"];function y(d){const r=p(d,"project lock release");n(r,["sdkVersion","engineRelease","manifestSHA256"]);const s=t(r.sdkVersion),e=t(r.engineRelease);if(!/^[0-9A-Za-z][0-9A-Za-z.+-]{0,63}$/u.test(s)||!/^sha256:[0-9a-f]{64}$/u.test(e))throw new o("PROTOCOL_ERROR","invalid project lock release");return{sdkVersion:s,engineRelease:e,manifestSHA256:h(r.manifestSHA256,"image digest")}}m(y,"lockIdentity");function E(d){const r=p(d,"project lock change");n(r,["updated","to"],["from"]);const s=r.updated;if(typeof s!="boolean"||r.from!==void 0&&!s)throw new o("PROTOCOL_ERROR","a project lock names its previous release only when it was updated");return{updated:s,...r.from===void 0?{}:{from:y(r.from)},to:y(r.to)}}m(E,"lockChange");function K(d){const r=p(d,"CLI report");if(r.schemaVersion!==3)throw new o("PROTOCOL_ERROR","unsupported CLI report schema");if(r.kind==="error")return n(r,["schemaVersion","kind","command","error"]),{schemaVersion:3,kind:"error",command:r.command===null?null:i(r.command,k),error:g(r.error)};if(n(r,["schemaVersion","kind","command","result"]),r.kind!=="result")throw new o("PROTOCOL_ERROR","invalid CLI envelope");const s=i(r.command,k),e=p(r.result,"CLI result");switch(s){case"snapshot init":{if(n(e,["directory","recipePath","mode","name","files"]),!Array.isArray(e.files)||e.files.length!==6||new Set(e.files).size!==6)throw new o("PROTOCOL_ERROR","Snapshot scaffold must contain six files");return{schemaVersion:3,kind:"result",command:s,result:{directory:t(e.directory),recipePath:t(e.recipePath),mode:i(e.mode,["system","userspace"]),name:t(e.name),files:Array.from(e.files).map(t)}}}case"snapshot build":case"snapshot pack":return{schemaVersion:3,kind:"result",command:s,result:V(e)};case"snapshot test":return{schemaVersion:3,kind:"result",command:s,result:A(e)};case"snapshot inspect":return{schemaVersion:3,kind:"result",command:s,result:C(e)};case"wasm add":return{schemaVersion:3,kind:"result",command:s,result:I(e)};case"wasm stage":return{schemaVersion:3,kind:"result",command:s,result:T(e)};case"wasm doctor":return{schemaVersion:3,kind:"result",command:s,result:S(e)};case"wasm inspect":return{schemaVersion:3,kind:"result",command:s,result:L(e)};case"wasm build":return{schemaVersion:3,kind:"result",command:s,result:f(e)};case"wasm release":{n(e,["build","tag","steps"]);const c=f(e.build),a=e.tag===null?null:t(e.tag);if(!Array.isArray(e.steps)||e.steps.length>32||c.result==="failed"!=(a===null)||a===null!=(e.steps.length===0))throw new o("PROTOCOL_ERROR","a release plan has a tag and steps exactly when the build succeeded");return{schemaVersion:3,kind:"result",command:s,result:{build:c,tag:a,steps:Array.from(e.steps).map(l=>t(l))}}}case"wasm test":return{schemaVersion:3,kind:"result",command:s,result:D(e)};case"wasm init":{if(n(e,["directory","id","kind","abi","network","files"],["commands"]),!Array.isArray(e.files)||e.files.length===0||e.files.length>64)throw new o("PROTOCOL_ERROR","a module scaffold lists its files");const c=i(e.kind,["command","service"]),a=e.commands;if(a!==void 0&&(c!=="command"||!Array.isArray(a)||a.length>16))throw new o("PROTOCOL_ERROR","only a command module's scaffold lists commands, at most sixteen");return{schemaVersion:3,kind:"result",command:s,result:{directory:t(e.directory),id:t(e.id),kind:c,abi:t(e.abi),network:i(e.network,["none","vm","internet"]),files:Array.from(e.files).map(l=>t(l)),...a===void 0?{}:{commands:Array.from(a).map(l=>t(l))}}}}case"init":return n(e,["directory","mode","assets"]),{schemaVersion:3,kind:"result",command:s,result:{directory:t(e.directory),mode:i(e.mode,["system","userspace"]),assets:i(e.assets,["installed","skipped"])}};case"assets install":return n(e,["publicDir","files","referencePath","lock"]),{schemaVersion:3,kind:"result",command:s,result:{publicDir:t(e.publicDir),files:u(e.files,1),referencePath:e.referencePath===null?null:t(e.referencePath),lock:E(e.lock)}};case"doctor":return{schemaVersion:3,kind:"result",command:s,result:w(e)};case"image init":return n(e,["directory","recipePath","mode"]),{schemaVersion:3,kind:"result",command:s,result:{directory:t(e.directory),recipePath:t(e.recipePath),mode:i(e.mode,["system","userspace"])}};case"image keygen":return n(e,["privateKeyPath","publicKeyPath","keyId"]),{schemaVersion:3,kind:"result",command:s,result:{privateKeyPath:t(e.privateKeyPath),publicKeyPath:t(e.publicKeyPath),keyId:t(e.keyId)}};case"image build":return n(e,["mode","manifestSHA256","bundleDir","referencePath","lockPath","distribution"]),{schemaVersion:3,kind:"result",command:s,result:{mode:i(e.mode,["system","userspace"]),manifestSHA256:h(e.manifestSHA256,"manifest digest"),bundleDir:t(e.bundleDir),referencePath:t(e.referencePath),lockPath:t(e.lockPath),distribution:P(e.distribution)}};case"image test":return{schemaVersion:3,kind:"result",command:s,result:b(e)};case"image inspect":return{schemaVersion:3,kind:"result",command:s,result:O(e)};case"image pack":return n(e,["manifestSHA256","transportPath","packCount","encodedBytes","decodedBytes"]),{schemaVersion:3,kind:"result",command:s,result:{manifestSHA256:h(e.manifestSHA256,"manifest digest"),transportPath:t(e.transportPath),packCount:u(e.packCount,0),encodedBytes:u(e.encodedBytes,0),decodedBytes:u(e.decodedBytes,0)}}}}m(K,"decodeCliReport");export{K as decodeCliReport};
|
package/dist/run.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CliReport } from "./contracts.js";
|
|
2
|
+
export interface CLIEnvironment {
|
|
3
|
+
readonly directory: string;
|
|
4
|
+
readonly environment: Readonly<Record<string, string | undefined>>;
|
|
5
|
+
readonly signal: AbortSignal;
|
|
6
|
+
stdout(text: string): void;
|
|
7
|
+
stderr(text: string): void;
|
|
8
|
+
/** Asks a yes-or-no question of a person at a terminal; absent when nobody can answer. */
|
|
9
|
+
confirm?(question: string): Promise<boolean>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The exit status of a command that produced a result: 3 when a check it ran failed, 4 when `wasm test` was refused (the
|
|
13
|
+
* browser or image cannot run the module, so no property ran; distinct from a failure), otherwise 0.
|
|
14
|
+
*/
|
|
15
|
+
export declare function reportExitCode(report: CliReport): 0 | 3 | 4;
|
|
16
|
+
/** One boundary normalizes output and exit codes; resource-owning SDK operations perform cleanup. */
|
|
17
|
+
export declare function runCLI(arguments_: readonly string[], io: CLIEnvironment): Promise<number>;
|
package/dist/run.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
var y=Object.defineProperty;var m=(e,r)=>y(e,"name",{value:r,configurable:!0});import{dirname as D,resolve as x}from"node:path";import{VMError as g}from"@oxvm/sdk";import{buildImage as I,downloadImageBundle as A,getSDKRelease as h,inspectImage as E,installProjectAssets as $,loadImageRecipe as P,loadImageReference as R,loadProjectConfig as T,generateImageKey as O,readImageTrust as o,testImage as V,doctorProject as j,packImage as C}from"@oxvm/sdk/image-builder";import{parseArguments as S}from"./arguments.js";import{decodeCliReport as p}from"./report.js";import{initializeApplication as L,initializeImage as N}from"./templates.js";import{startApplication as _}from"./start-application.js";import{readStarterInputs as K}from"./starter-inputs.js";import{pinnedStarterRelease as U}from"./starter-release.js";import{runSnapshotCommand as B}from"./snapshot-commands.js";import{snapshotHelp as F,snapshotCommandHelp as M}from"./snapshot-help.js";import{snapshotFailureDetail as H,snapshotFailureText as G,cancellationExit as W}from"./snapshot-errors.js";import{runWasmCommand as z}from"./wasm-commands.js";import{wasmCommandHelp as J,wasmHelp as X}from"./wasm-help.js";import{addText as q,buildText as Q,doctorText as Y,initText as Z,inspectText as v,printable as w,releaseText as ee,stageText as se,testText as te}from"./wasm-text.js";import{wasmFailureDetail as ne}from"./wasm-errors.js";import{failureMessage as re}from"./failure.js";import{lockChangeText as ae,requireOneRelease as ie}from"./project-lock.js";import{defaultProjectConfig as b}from"./project-files.js";const de=`oxvm \u2014 Linux in your browser
|
|
2
|
+
|
|
3
|
+
Commands:
|
|
4
|
+
init <directory> [--start] [--use-bun]
|
|
5
|
+
Creates the Python + pandas starter using the hosted runtime and signed image.
|
|
6
|
+
Advanced: [--mode system|userspace] [--image <bundle> --image-trust <file>]
|
|
7
|
+
[--skip-assets | --engine-dir <release>] [--sdk-archive <sdk.tgz> --cli-archive <cli.tgz>]
|
|
8
|
+
assets install [--config oxvm.config.ts] [--image <bundle> --trust <file>] [--reference <file>] [--engine-dir <release>] [--update-lock]
|
|
9
|
+
After an SDK upgrade, --update-lock stages this release's assets, then rewrites oxvm.lock.json for it.
|
|
10
|
+
doctor [url] [--browser chromium|firefox|webkit] [--hosting frame|self-hosted] [--frame-origin <origin>] [--preview-origin <origin>] [--config oxvm.config.ts]
|
|
11
|
+
Checks a running application in a real browser (default http://localhost:5173/); start it first.
|
|
12
|
+
It checks the hosted runtime frame unless the application serves its own runtime assets; --hosting chooses.
|
|
13
|
+
Its lock check compares the project's oxvm.lock.json with the installed SDK.
|
|
14
|
+
image init <directory> --mode system|userspace
|
|
15
|
+
image keygen --out <author.pem>
|
|
16
|
+
image build <recipe.ts> --signing-key <author.pem> [--distribution]
|
|
17
|
+
image test <bundle> --trust <author.public.json> [--browser chromium|firefox|webkit] [--engine-dir <release>]
|
|
18
|
+
image inspect <bundle> [--trust <author.public.json>]
|
|
19
|
+
image pack <bundle> --trust <author.public.json>
|
|
20
|
+
|
|
21
|
+
Every command accepts --json; --start runs interactively and cannot use --json. Paths resolve from the current directory.
|
|
22
|
+
Normal init installs no local engine files. Development and production use run.oxvm.dev.
|
|
23
|
+
Self-hosting is an explicit commercial option: --engine-dir selects a local pinned release.
|
|
24
|
+
Explicit assets/image test commands can use OXVM_ENGINE_DIR (legacy OXIDEVM_ENGINE_DIR) or the verified engine cache.
|
|
25
|
+
Example: oxvm init app --start
|
|
26
|
+
`;async function ue(e,r){const n=m(s=>x(r.directory,s),"path"),i=e.command;switch(i){case"snapshot init":case"snapshot build":case"snapshot pack":case"snapshot test":case"snapshot inspect":return B(e,r);case"wasm add":case"wasm stage":case"wasm doctor":case"wasm inspect":case"wasm build":case"wasm release":case"wasm init":case"wasm test":return z(e,r);case"init":{const s=e.mode==="userspace"&&e.image===void 0?await K(r.directory,h().sdkVersion):void 0,t=e.mode==="userspace"&&e.image===void 0?U():void 0;if(e.mode==="userspace"&&e.image===void 0&&s===void 0&&t===void 0)throw new g("FEATURE_NOT_AVAILABLE","Run this private preview from its prepared launcher directory. Its prebuilt image and runtime are supplied automatically; no image build is needed.");const a=e.image===void 0?s?.image:{bundle:n(e.image.bundle),trust:n(e.image.trust)},d=e.engineDir===void 0?s?.engineDir:n(e.engineDir),c=a===void 0?d===void 0||t===void 0?void 0:{bundle:await A(t.archive,t.image,{signal:r.signal}),trust:t.image.trust}:{bundle:a.bundle,trust:await o(a.trust)},l=e.archives===void 0?s?.archives:{sdk:n(e.archives.sdk),cli:n(e.archives.cli)},u=t?.image,f=s?.engineComplianceDir;return{schemaVersion:3,kind:"result",command:i,result:await L(n(e.directory),e.mode,e.skipAssets,r.signal,{...l===void 0?{}:{archives:l},...d===void 0?{}:{engineDir:d},...c===void 0?{}:{image:c},...u===void 0?{}:{productionImage:u},...t===void 0?{}:{materialsUrl:t.materialsUrl},...f===void 0?{}:{engineComplianceDir:f}})}}case"assets install":{const s=e.config===void 0?await b(r.directory)??n("oxvm.config.ts"):n(e.config),t=await T(s);e.updateLock&&await ie(t.directory);const a=await $(t.directory,t.config,{signal:r.signal,...e.updateLock?{updateLock:!0}:{},...e.image===void 0?{}:{imageDir:n(e.image)},...e.snapshot===void 0?{}:{snapshotDir:n(e.snapshot)},...e.trust===void 0?{}:{trust:await o(n(e.trust))},...e.reference===void 0?{}:{referencePath:n(e.reference)},...e.engineDir===void 0?{}:{engineDir:n(e.engineDir)}}),d=ae(a.lock,e.updateLock);return d!==""&&r.stderr(d),{schemaVersion:3,kind:"result",command:i,result:a}}case"doctor":{const s=e.config===void 0?await b(r.directory):n(e.config);return{schemaVersion:3,kind:"result",command:i,result:await j(e.url,{browser:e.browser,signal:r.signal,...e.hosting===void 0?{}:{hosting:e.hosting},...e.frameOrigin===void 0?{}:{frameOrigin:e.frameOrigin},...e.previewOrigin===void 0?{}:{previewOrigin:e.previewOrigin},...s===void 0?{}:{project:s}})}}case"image init":return{schemaVersion:3,kind:"result",command:i,result:await N(n(e.directory),e.mode)};case"image keygen":{const s=await O(n(e.out));return{schemaVersion:3,kind:"result",command:i,result:{privateKeyPath:s.privateKeyPath,publicKeyPath:s.publicKeyPath,keyId:s.trust.keyId}}}case"image build":{const s=await P(n(e.recipe)),t=await I(s,{recipeDir:D(n(e.recipe)),signingKeyFile:n(e.signingKey),signal:r.signal,purpose:e.distribution?"distribution":"development",secrets:e.secrets.map(a=>({id:a.id,file:n(a.file)})),...e.out===void 0?{}:{outDir:n(e.out)},...e.baseUrl===void 0?{}:{publicBaseUrl:e.baseUrl},onProgress:m(a=>{r.stderr(`${a.phase}
|
|
27
|
+
`)},"onProgress")});return{schemaVersion:3,kind:"result",command:i,result:{mode:t.mode,manifestSHA256:t.image.manifestSHA256,bundleDir:t.bundleDir,referencePath:t.referencePath,lockPath:t.lockPath,distribution:t.distribution}}}case"image test":{const s=await o(n(e.trust)),t=await R(n(e.bundle),s);return{schemaVersion:3,kind:"result",command:i,result:await V(n(e.bundle),{image:t,browser:e.browser,purpose:e.distribution?"distribution":"development",signal:r.signal,...e.engineDir===void 0?{}:{engineDir:n(e.engineDir)}})}}case"image inspect":return{schemaVersion:3,kind:"result",command:i,result:await E(n(e.bundle),{signal:r.signal,...e.trust===void 0?{}:{trust:await o(n(e.trust))}})};case"image pack":return{schemaVersion:3,kind:"result",command:i,result:await C(n(e.bundle),{signal:r.signal,trust:await o(n(e.trust))})}}}m(ue,"execute");function me(e){return e.kind!=="result"?0:e.command==="wasm test"&&e.result.result==="refused"?4:(e.command==="doctor"||e.command==="image test"||e.command==="snapshot test"||e.command==="wasm doctor"||e.command==="wasm build"||e.command==="wasm test")&&e.result.result==="failed"||e.command==="wasm release"&&e.result.build.result==="failed"?3:0}m(me,"reportExitCode");async function Oe(e,r){const n=e.includes("--json");let i=null;try{const s=S(e,r.environment);if(s.kind!=="command"){if(n)throw new g("INVALID_ARGUMENT","use --help or --version without --json");const a=h();return r.stdout(s.kind==="help"?s.command===void 0?de+F+X:s.command.startsWith("wasm ")?J(s.command):M(s.command):`@oxvm/cli ${a.sdkVersion}; @oxvm/sdk ${a.sdkVersion}; engine ${a.engineRelease}
|
|
28
|
+
`),0}if(i=s.command,r.signal.aborted)throw new g("ABORTED","command interrupted");const t=p(await ue(s,r));return r.stdout(n?`${JSON.stringify(t)}
|
|
29
|
+
`:i.startsWith("wasm ")?w(k(t)):k(t)),s.command==="init"&&s.start&&t.command==="init"&&t.kind==="result"&&await _(t.result.directory,s.packageManager,r),me(t)}catch(s){const t=r.signal.aborted,a=t?"ABORTED":s instanceof g?s.code:"STORAGE_ERROR",d=i?.startsWith("snapshot ")===!0,c=i?.startsWith("wasm ")===!0,l=t?"command interrupted; owned resources have been cleaned up":d?"Snapshot command failed; check its phase and reason":re(s),u=d?H(s):c?ne(s):void 0,f=p({schemaVersion:3,kind:"error",command:i,error:{code:a,message:l,...u===void 0?{}:{detail:u}}});return r.stdout(n?`${JSON.stringify(f)}
|
|
30
|
+
`:d&&!t?G(a,u):`${a}: ${c?w(l):l}
|
|
31
|
+
`),t?W(r.signal):u?.reason==="snapshot-verify-failed"?3:a==="INVALID_ARGUMENT"||a==="FEATURE_NOT_AVAILABLE"||d&&a==="CORE_LOAD_FAILED"?2:1}}m(Oe,"runCLI");function k(e){if(e.kind==="result"){if(e.command==="snapshot build"||e.command==="snapshot pack")return`Snapshot ${e.result.name} verified in ${e.result.verification.browser}. Bundle: ${e.result.bundlePath}. SDK options: ${e.result.referencePath}
|
|
32
|
+
`;if(e.command==="snapshot init")return`Created ${e.result.directory}. Edit prepare.ts, then run oxvm snapshot build ${e.result.recipePath}.
|
|
33
|
+
`;if(e.command==="snapshot test")return`Snapshot ${e.result.name} restoration ${e.result.result} (${e.result.browser.name} ${e.result.browser.version}).
|
|
34
|
+
`;if(e.command==="snapshot inspect")return`${e.result.kind==="bundle"?e.result.name:"Personal backup"}: ${e.result.snapshot.mode}, integrity verified; authentication ${e.result.authentication.kind}; runtime restoration not run.
|
|
35
|
+
`}if(e.kind==="result"){if(e.command==="wasm add")return q(e.result);if(e.command==="wasm stage")return se(e.result);if(e.command==="wasm doctor")return Y(e.result);if(e.command==="wasm inspect")return v(e.result);if(e.command==="wasm build")return Q(e.result);if(e.command==="wasm release")return ee(e.result);if(e.command==="wasm init")return Z(e.result);if(e.command==="wasm test")return te(e.result)}return`${JSON.stringify(e,null,2)}
|
|
36
|
+
`}m(k,"successText");export{me as reportExitCode,Oe as runCLI};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CLIInvocation } from "./arguments.js";
|
|
2
|
+
import type { CLIEnvironment } from "./run.js";
|
|
3
|
+
import type { CliReport } from "./contracts.js";
|
|
4
|
+
export type SnapshotCLIInvocation = Extract<CLIInvocation, {
|
|
5
|
+
command: "snapshot init" | "snapshot build" | "snapshot pack" | "snapshot test" | "snapshot inspect";
|
|
6
|
+
}>;
|
|
7
|
+
export declare function runSnapshotCommand(invocation: SnapshotCLIInvocation, io: CLIEnvironment): Promise<CliReport>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var w=Object.defineProperty;var a=(e,r)=>w(e,"name",{value:r,configurable:!0});import{dirname as g,resolve as l}from"node:path";import{buildSnapshot as b,packSnapshot as T,testSnapshot as S,inspectSnapshot as y,loadSnapshotRecipe as D,readImageTrust as m}from"@oxvm/sdk/image-builder";import{initializeSnapshot as M}from"./snapshot-templates.js";import{setting as f}from"./environment.js";import{defaultSnapshotRecipe as k}from"./project-files.js";async function F(e,r){const s=a(t=>l(r.directory,t),"path"),u=e.command,n=a(t=>{r.stderr(e.json?`${JSON.stringify(t)}
|
|
2
|
+
`:`${t.phase}
|
|
3
|
+
`)},"onProgress");switch(u){case"snapshot init":{const t=e.imageTrust??f(r.environment,"IMAGE_TRUST_FILE");return{schemaVersion:3,kind:"result",command:u,result:await M(s(e.directory),{name:e.name,signal:r.signal,...e.mode===void 0?{}:{mode:e.mode},...e.image===void 0?{}:{imageDir:s(e.image)},...t===void 0?{}:{imageTrust:await m(s(t))}})}}case"snapshot inspect":return{schemaVersion:3,kind:"result",command:u,result:await y(s(e.artifact),{signal:r.signal,...e.trust===void 0?{}:{trust:await m(s(e.trust))}})};case"snapshot test":return{schemaVersion:3,kind:"result",command:u,result:await S(s(e.bundle),{trust:await m(s(e.trust)),signal:r.signal,onProgress:n,...e.verify===void 0?{}:{verifyModule:s(e.verify)},...e.browser===void 0?{}:{browser:e.browser},...e.timeoutMs===void 0?{}:{timeoutMs:e.timeoutMs},...e.engineDir===void 0?{}:{engineDir:s(e.engineDir)}})};case"snapshot build":case"snapshot pack":{const t=e.recipe===void 0?await k(r.directory)??s("oxvm.snapshot.ts"):s(e.recipe),d=await D(t),i=e.imageTrust===void 0?d.imageTrust===void 0?f(r.environment,"IMAGE_TRUST_FILE"):l(g(t),d.imageTrust):s(e.imageTrust),p={recipeDir:g(t),signingKeyFile:s(e.signingKey),signal:r.signal,onProgress:n,...i===void 0?{}:{imageTrust:await m(s(i))},...e.out===void 0?{}:{outDir:s(e.out)},...e.baseUrl===void 0?{}:{publicBaseUrl:e.baseUrl},...e.browser===void 0?{}:{browser:e.browser},...e.timeoutMs===void 0?{}:{timeoutMs:e.timeoutMs},...e.engineDir===void 0?{}:{engineDir:s(e.engineDir)}},h=e.command==="snapshot build"?await b(d,p):await T(s(e.backup),d,p);return{schemaVersion:3,kind:"result",command:u,result:h}}}}a(F,"runSnapshotCommand");export{F as runSnapshotCommand};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function snapshotFailureDetail(error: unknown): Readonly<Record<string, unknown>> | undefined;
|
|
2
|
+
/** Text output: the fixed summary, the safe context, then the browser's SDK message. */
|
|
3
|
+
export declare function snapshotFailureText(code: string, detail: Readonly<Record<string, unknown>> | undefined): string;
|
|
4
|
+
export declare function cancellationExit(signal: AbortSignal): 130 | 143;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var u=Object.defineProperty;var c=(e,t)=>u(e,"name",{value:t,configurable:!0});import{VMError as d}from"@oxvm/sdk";import{isSnapshotProcessName as f}from"@oxvm/sdk/image-builder";const l=["validate","compile","start","stage","prepare","ready","capture","export","package","verify","publish","done"],g=["bundle-signature","image-integrity","snapshot-integrity","browser-features","shipped-resume","authoring-receipt","original-processes","custom-verification"],m=["snapshot-recipe-invalid","snapshot-input-unsafe","snapshot-process-exited","snapshot-command-failed","snapshot-readiness-timeout","snapshot-command-exit","snapshot-command-timeout","snapshot-ready-timeout","snapshot-capture-timeout","snapshot-build-timeout","snapshot-verify-failed","snapshot-unexpected-cold-boot","snapshot-browser-unavailable","snapshot-preparation-failed","snapshot-publication-incomplete","snapshot-initial-conflict"];function x(e){if(!(e instanceof d)||e.detail===void 0)return;const t=e.detail.phase,s=e.detail.reason,o=e.detail.cause,n=e.detail.process,a=e.detail.check,i=e.detail.browserMessage;return{...typeof t=="string"&&l.includes(t)?{phase:t}:{},...typeof s=="string"&&m.includes(s)?{reason:s}:{},...typeof a=="string"&&g.includes(a)?{check:a}:{},...typeof o=="string"&&["ENOSPC","EDQUOT","EIO","EACCES"].includes(o)?{cause:o}:{},...f(n)?{process:n}:{},...h(e.detail.checkpoint)?{checkpoint:e.detail.checkpoint}:{},...typeof i=="string"&&/^[\x20-\x7e…]{1,500}$/u.test(i)?{browserMessage:i}:{}}}c(x,"snapshotFailureDetail");function h(e){if(typeof e!="object"||e===null)return!1;const t=Object.keys(e),s=/^[a-z][a-z-]{0,31}$/u,o=/^[A-Za-z0-9][A-Za-z0-9-]{0,47}$/u,n=Reflect.get(e,"phase"),a=Reflect.get(e,"domain"),i=Reflect.get(e,"owner"),r=Reflect.get(e,"causes");return t.every(p=>["phase","domain","owner","causes"].includes(p))&&typeof n=="string"&&s.test(n)&&typeof a=="string"&&s.test(a)&&(i===void 0||typeof i=="string"&&s.test(i))&&Array.isArray(r)&&r.length<=9&&r.every(p=>typeof p=="string"&&o.test(p))}c(h,"safeCheckpoint");function y(e){return h(e)?[`checkpoint ${e.phase} ${e.domain}${e.owner===void 0?"":`/${e.owner}`}${e.causes.length===0?"":` ${e.causes.join("/")}`}`]:[]}c(y,"checkpointText");function w(e,t){const s=[...["phase","reason","check","process","cause"].flatMap(n=>typeof t?.[n]=="string"?[`${n} ${t[n]}`]:[]),...y(t?.checkpoint)],o=t?.browserMessage;return`${e}: Snapshot command failed${s.length===0?"":` (${s.join(", ")})`}${typeof o=="string"?`: ${o}`:""}
|
|
2
|
+
`}c(w,"snapshotFailureText");function E(e){const t=e.reason;return typeof t=="object"&&t!==null&&"kind"in t&&t.kind==="signal"&&"signal"in t&&t.signal==="SIGTERM"?143:130}c(E,"cancellationExit");export{E as cancellationExit,x as snapshotFailureDetail,w as snapshotFailureText};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { CliCommand } from "./contracts.js";
|
|
2
|
+
export declare const snapshotHelp = "\n snapshot init [directory] [--name ready] [--mode userspace|system] [--image <bundle>] [--image-trust <A.public.json>]\n snapshot build [recipe] [--signing-key <B.pem>] [--image-trust <A.public.json>] [--out <directory>] [--base-url <url>]\n snapshot pack <backup.oxvm> [--recipe <recipe>] [--signing-key <B.pem>] [--image-trust <A.public.json>] [--out <directory>] [--base-url <url>]\n snapshot test <bundle> [--trust <B.public.json>] [--verify <module>]\n snapshot inspect <bundle-or-backup> [--trust <B.public.json>]\n\nBuild, pack and test accept --browser chromium|firefox|webkit, --timeout-ms <milliseconds>, --engine-dir <release> and --json.\nInit and inspect accept --json. Signing uses OXVM_SIGNING_KEY_FILE; image trust uses OXVM_IMAGE_TRUST_FILE;\nsnapshot trust uses OXVM_SNAPSHOT_TRUST_FILE. Legacy OXIDEVM_* names remain accepted; conflicting values are refused. A recipe's imageTrust takes precedence over that environment default.\nThe default init directory is snapshots/ready; build and pack use oxvm.snapshot.ts (or legacy oxidevm.snapshot.ts) by default.\nSigning does not grant guest redistribution rights; snapshot bundles are development-only.\n";
|
|
3
|
+
export declare function snapshotCommandHelp(command: CliCommand): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
var n=Object.defineProperty;var s=(e,t)=>n(e,"name",{value:t,configurable:!0});const i=`
|
|
2
|
+
snapshot init [directory] [--name ready] [--mode userspace|system] [--image <bundle>] [--image-trust <A.public.json>]
|
|
3
|
+
snapshot build [recipe] [--signing-key <B.pem>] [--image-trust <A.public.json>] [--out <directory>] [--base-url <url>]
|
|
4
|
+
snapshot pack <backup.oxvm> [--recipe <recipe>] [--signing-key <B.pem>] [--image-trust <A.public.json>] [--out <directory>] [--base-url <url>]
|
|
5
|
+
snapshot test <bundle> [--trust <B.public.json>] [--verify <module>]
|
|
6
|
+
snapshot inspect <bundle-or-backup> [--trust <B.public.json>]
|
|
7
|
+
|
|
8
|
+
Build, pack and test accept --browser chromium|firefox|webkit, --timeout-ms <milliseconds>, --engine-dir <release> and --json.
|
|
9
|
+
Init and inspect accept --json. Signing uses OXVM_SIGNING_KEY_FILE; image trust uses OXVM_IMAGE_TRUST_FILE;
|
|
10
|
+
snapshot trust uses OXVM_SNAPSHOT_TRUST_FILE. Legacy OXIDEVM_* names remain accepted; conflicting values are refused. A recipe's imageTrust takes precedence over that environment default.
|
|
11
|
+
The default init directory is snapshots/ready; build and pack use oxvm.snapshot.ts (or legacy oxidevm.snapshot.ts) by default.
|
|
12
|
+
Signing does not grant guest redistribution rights; snapshot bundles are development-only.
|
|
13
|
+
`;function o(e){return`oxvm ${e}
|
|
14
|
+
${i}`}s(o,"snapshotCommandHelp");export{o as snapshotCommandHelp,i as snapshotHelp};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type RuntimeMode, type TrustedImageKey } from "@oxvm/sdk";
|
|
2
|
+
export declare function preparationSource(mode: RuntimeMode): string;
|
|
3
|
+
export declare function verificationSource(): string;
|
|
4
|
+
export declare function initializeSnapshot(directory: string, options: {
|
|
5
|
+
name: string;
|
|
6
|
+
mode?: RuntimeMode;
|
|
7
|
+
imageDir?: string;
|
|
8
|
+
imageTrust?: TrustedImageKey;
|
|
9
|
+
signal: AbortSignal;
|
|
10
|
+
}): Promise<{
|
|
11
|
+
directory: string;
|
|
12
|
+
recipePath: string;
|
|
13
|
+
name: string;
|
|
14
|
+
mode: RuntimeMode;
|
|
15
|
+
files: readonly string[];
|
|
16
|
+
}>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
var m=Object.defineProperty;var n=(t,e)=>m(t,"name",{value:e,configurable:!0});import{join as d,relative as c,resolve as h}from"node:path";import{VMError as i}from"@oxvm/sdk";import{inspectImage as f,loadImageReference as g}from"@oxvm/sdk/image-builder";import{newDirectory as w,file as a}from"./template-files.js";const o=`async function send(process: SnapshotProcess, input: string): Promise<void> {
|
|
2
|
+
const writer = process.stdin.getWriter();
|
|
3
|
+
try { await writer.write(new TextEncoder().encode(input)); }
|
|
4
|
+
finally { writer.releaseLock(); }
|
|
5
|
+
}
|
|
6
|
+
`;function v(t){return`import type { PrepareSnapshot, SnapshotProcess } from "@oxvm/sdk";
|
|
7
|
+
${o}
|
|
8
|
+
const prepare: PrepareSnapshot = async ({ vm, start }) => {
|
|
9
|
+
await vm.workspace.writeText("/welcome.txt", "Prepared workspace\\n");
|
|
10
|
+
const token = crypto.randomUUID();
|
|
11
|
+
const shell = await start("shell", { command: "/bin/sh", args: ["-i"],
|
|
12
|
+
cwd: ${JSON.stringify(t==="system"?"/":"/workspace")}, terminal: { columns: 80, rows: 24 } });
|
|
13
|
+
await send(shell, "KEEP='" + token + "'; printf 'prepared:%s:%s\\\\n' \\"$KEEP\\" \\"$$\\"\\n");
|
|
14
|
+
await shell.waitForOutput("prepared:" + token + ":" + String(shell.pid));
|
|
15
|
+
return { token, pid: shell.pid };
|
|
16
|
+
};
|
|
17
|
+
export default prepare;
|
|
18
|
+
`}n(v,"preparationSource");function k(){return`import type { VerifySnapshot, SnapshotProcess } from "@oxvm/sdk";
|
|
19
|
+
${o}
|
|
20
|
+
function proof(value: unknown): { token: string; pid: number } {
|
|
21
|
+
if (typeof value !== "object" || value === null || Object.keys(value).length !== 2
|
|
22
|
+
|| !("token" in value) || typeof value.token !== "string"
|
|
23
|
+
|| !("pid" in value) || typeof value.pid !== "number"
|
|
24
|
+
|| !Number.isSafeInteger(value.pid) || value.pid <= 0) throw new Error("Invalid captured proof");
|
|
25
|
+
return { token: value.token, pid: value.pid };
|
|
26
|
+
}
|
|
27
|
+
const verify: VerifySnapshot = async ({ vm, data, attach }) => {
|
|
28
|
+
const expected = proof(data);
|
|
29
|
+
if (await vm.workspace.readText("/welcome.txt") !== "Prepared workspace\\n") throw new Error("Prepared file was not restored");
|
|
30
|
+
const shell = await attach("shell");
|
|
31
|
+
if (shell.pid !== expected.pid) throw new Error("Original shell PID changed");
|
|
32
|
+
await send(shell, "printf 'restored:%s:%s\\\\n' \\"$KEEP\\" \\"$$\\"\\n");
|
|
33
|
+
await shell.waitForOutput("restored:" + expected.token + ":" + String(expected.pid));
|
|
34
|
+
};
|
|
35
|
+
export default verify;
|
|
36
|
+
`}n(k,"verificationSource");async function D(t,e){if(!/^[a-z][a-z0-9-]{0,63}$/u.test(e.name))throw new i("INVALID_ARGUMENT","Snapshot name is invalid");if(e.signal.aborted)throw new i("ABORTED","Scaffolding was cancelled");let r=e.mode??"userspace";if(e.imageDir!==void 0){if(e.imageTrust===void 0)throw new i("INVALID_ARGUMENT","Custom snapshot images require external image trust");const s=await g(e.imageDir,e.imageTrust);if(await f(e.imageDir,{trust:e.imageTrust,signal:e.signal}),e.mode!==void 0&&e.mode!==s.mode)throw new i("INVALID_ARGUMENT","Explicit mode conflicts with the supplied image");r=s.mode}await w(t);const p=["oxvm.snapshot.ts","prepare.ts","verify.ts","tsconfig.snapshot.json","README.md",".gitignore"],l=e.imageDir===void 0?"default":c(t,h(e.imageDir)),u=`import type { SnapshotRecipe } from "@oxvm/sdk/image-builder";
|
|
37
|
+
export default {
|
|
38
|
+
name: ${JSON.stringify(e.name)}, mode: ${JSON.stringify(r)}, image: ${JSON.stringify(l)},
|
|
39
|
+
workload: { module: "./prepare.ts" }, verify: { module: "./verify.ts" },
|
|
40
|
+
} satisfies SnapshotRecipe;
|
|
41
|
+
`;return await a(t,"oxvm.snapshot.ts",u),await a(t,"prepare.ts",v(r)),await a(t,"verify.ts",k()),await a(t,"tsconfig.snapshot.json",JSON.stringify({compilerOptions:{target:"ES2024",module:"ESNext",moduleResolution:"Bundler",lib:["ES2024","DOM","DOM.Iterable"],types:[],strict:!0,noUncheckedIndexedAccess:!0,exactOptionalPropertyTypes:!0,verbatimModuleSyntax:!0,noEmit:!0,skipLibCheck:!1},include:["prepare.ts","verify.ts"]},null,2)+`
|
|
42
|
+
`),await a(t,".gitignore",`dist/
|
|
43
|
+
*.pem
|
|
44
|
+
*.oxvm
|
|
45
|
+
*.owners/
|
|
46
|
+
*.building-*/
|
|
47
|
+
*.previous-*/
|
|
48
|
+
*.publication.json*
|
|
49
|
+
`),await a(t,"README.md",`# Prepared ${e.name}
|
|
50
|
+
|
|
51
|
+
The Node recipe selects inputs. Preparation and verification run in the browser and import only the public SDK; Node globals are unavailable. Workspace API paths are relative to /workspace.
|
|
52
|
+
|
|
53
|
+
Create a separate snapshot key: \`oxvm image keygen --out snapshot-author.pem\` (public companion: snapshot-author.public.json).
|
|
54
|
+
Run \`oxvm snapshot build oxvm.snapshot.ts --signing-key snapshot-author.pem${e.imageDir===void 0?"":" --image-trust <image-author.public.json>"}\`.
|
|
55
|
+
Run \`oxvm snapshot test dist --trust snapshot-author.public.json\`. Type-check browser scripts with \`tsc -p tsconfig.snapshot.json\`; check the recipe in your project's strict Node configuration.
|
|
56
|
+
|
|
57
|
+
The verifier reattaches the original shell and proves its in-memory token and PID. It never initializes that token again. Keep image key A separate from snapshot key B. Signed bundles are development-only; signing does not grant guest or engine redistribution rights.
|
|
58
|
+
`),{directory:t,recipePath:d(t,"oxvm.snapshot.ts"),name:e.name,mode:r,files:p}}n(D,"initializeSnapshot");export{D as initializeSnapshot,v as preparationSource,k as verificationSource};
|