@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.
Files changed (67) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +18 -0
  3. package/README.md +27 -2
  4. package/THIRD_PARTY_NOTICES.txt +52056 -0
  5. package/dist/arguments.d.ts +162 -0
  6. package/dist/arguments.js +1 -0
  7. package/dist/bin.d.ts +2 -0
  8. package/dist/bin.js +2 -0
  9. package/dist/contracts.d.ts +98 -0
  10. package/dist/contracts.js +0 -0
  11. package/dist/environment.d.ts +4 -0
  12. package/dist/environment.js +1 -0
  13. package/dist/failure.d.ts +5 -0
  14. package/dist/failure.js +1 -0
  15. package/dist/index.d.ts +2 -0
  16. package/dist/index.js +1 -0
  17. package/dist/project-files.d.ts +2 -0
  18. package/dist/project-files.js +1 -0
  19. package/dist/project-lock.d.ts +13 -0
  20. package/dist/project-lock.js +4 -0
  21. package/dist/report.d.ts +3 -0
  22. package/dist/report.js +1 -0
  23. package/dist/run.d.ts +17 -0
  24. package/dist/run.js +36 -0
  25. package/dist/snapshot-commands.d.ts +7 -0
  26. package/dist/snapshot-commands.js +3 -0
  27. package/dist/snapshot-errors.d.ts +4 -0
  28. package/dist/snapshot-errors.js +2 -0
  29. package/dist/snapshot-help.d.ts +3 -0
  30. package/dist/snapshot-help.js +14 -0
  31. package/dist/snapshot-templates.d.ts +16 -0
  32. package/dist/snapshot-templates.js +58 -0
  33. package/dist/start-application.d.ts +2 -0
  34. package/dist/start-application.js +3 -0
  35. package/dist/starter-inputs.d.ts +13 -0
  36. package/dist/starter-inputs.js +1 -0
  37. package/dist/starter-release.d.ts +29 -0
  38. package/dist/starter-release.js +1 -0
  39. package/dist/starter-template.d.ts +9 -0
  40. package/dist/starter-template.js +2 -0
  41. package/dist/starter.generated.d.ts +1 -0
  42. package/dist/starter.generated.js +1 -0
  43. package/dist/starter.json +1 -0
  44. package/dist/template-files.d.ts +2 -0
  45. package/dist/template-files.js +1 -0
  46. package/dist/templates.d.ts +27 -0
  47. package/dist/templates.js +115 -0
  48. package/dist/validation.d.ts +5 -0
  49. package/dist/validation.js +1 -0
  50. package/dist/wasm-commands.d.ts +7 -0
  51. package/dist/wasm-commands.js +1 -0
  52. package/dist/wasm-errors.d.ts +2 -0
  53. package/dist/wasm-errors.js +1 -0
  54. package/dist/wasm-help.d.ts +3 -0
  55. package/dist/wasm-help.js +37 -0
  56. package/dist/wasm-release.d.ts +15 -0
  57. package/dist/wasm-release.js +8 -0
  58. package/dist/wasm-template-files.d.ts +50 -0
  59. package/dist/wasm-template-files.js +350 -0
  60. package/dist/wasm-template-network.d.ts +15 -0
  61. package/dist/wasm-template-network.js +91 -0
  62. package/dist/wasm-templates.d.ts +16 -0
  63. package/dist/wasm-templates.js +91 -0
  64. package/dist/wasm-text.d.ts +23 -0
  65. package/dist/wasm-text.js +40 -0
  66. package/package.json +56 -3
  67. package/sbom.cdx.json +8537 -0
@@ -0,0 +1,2 @@
1
+ export declare function newDirectory(directory: string): Promise<void>;
2
+ export declare function file(directory: string, path: string, content: string | Uint8Array): Promise<void>;
@@ -0,0 +1 @@
1
+ var a=Object.defineProperty;var e=(r,i)=>a(r,"name",{value:i,configurable:!0});import{mkdir as o,writeFile as n}from"node:fs/promises";import{dirname as f,join as c}from"node:path";import{VMError as s}from"@oxvm/sdk";async function u(r){await o(f(r),{recursive:!0});try{await o(r)}catch{throw new s("INVALID_ARGUMENT","Choose a new directory; scaffolding preserves existing files")}}e(u,"newDirectory");async function x(r,i,t){await n(c(r,i),t,{flag:"wx"})}e(x,"file");export{x as file,u as newDirectory};
@@ -0,0 +1,27 @@
1
+ import type { ImageRef, RuntimeMode, TrustedImageKey } from "@oxvm/sdk";
2
+ export declare function registryConfig(): Promise<string | undefined>;
3
+ export declare function initializeImage(directory: string, mode: RuntimeMode): Promise<{
4
+ readonly directory: string;
5
+ readonly recipePath: string;
6
+ readonly mode: RuntimeMode;
7
+ }>;
8
+ interface ApplicationInputs {
9
+ readonly engineDir?: string;
10
+ readonly engineComplianceDir?: string;
11
+ readonly materialsUrl?: string;
12
+ readonly productionImage?: ImageRef<"userspace">;
13
+ readonly image?: {
14
+ readonly bundle: string;
15
+ readonly trust: TrustedImageKey;
16
+ };
17
+ readonly archives?: {
18
+ readonly sdk: string;
19
+ readonly cli: string;
20
+ };
21
+ }
22
+ export declare function initializeApplication(directory: string, mode: RuntimeMode, skipAssets: boolean, signal: AbortSignal, inputs?: ApplicationInputs): Promise<{
23
+ readonly directory: string;
24
+ readonly mode: RuntimeMode;
25
+ readonly assets: "installed" | "skipped";
26
+ }>;
27
+ export {};
@@ -0,0 +1,115 @@
1
+ var S=Object.defineProperty;var d=(e,n)=>S(e,"name",{value:n,configurable:!0});import{mkdir as C,readFile as h}from"node:fs/promises";import{join as w}from"node:path";import{VMError as b}from"@oxvm/sdk";import{createProjectLock as O,getSDKRelease as L,installProjectAssets as D,loadImageReference as R,pinnedEngineCompliance as N}from"@oxvm/sdk/image-builder";import{newDirectory as k,file as t}from"./template-files.js";import{object as y,text as $}from"./validation.js";import{archiveDependencies as T,writeStarter as M}from"./starter-template.js";const A="alpine:3.23.3@sha256:25109184c71bdad752c8312a8623239686a9a2071e8825f20acb8f2198c3f659";async function j(){const e=JSON.parse(await h(new URL("../package.json",import.meta.url),"utf8")),n=y(e,"CLI manifest");if(n.publishConfig===void 0)return;const r=$(y(n.publishConfig,"publish configuration").registry),s=new URL(r);if(s.href!=="https://registry.npmjs.org/"){if(s.protocol!=="https:"&&s.protocol!=="http:"||s.username!==""||s.password!==""||s.search!==""||s.hash!=="")throw new b("INVALID_ARGUMENT","package registry must be HTTP(S) without credentials");return`@oxvm:registry=${s.href}
2
+ `}}d(j,"registryConfig");async function z(e,n){await k(e);const r="custom-linux",s={id:r,version:"1.0.0",sourceDateEpoch:0,smokeTest:{command:"/bin/sh",args:["-c","printf oxidevm-ready"],expectedExitCode:0,stdoutIncludes:"oxidevm-ready"}},i=n==="system"?{...s,mode:n,source:{kind:"boot-files",kernel:{path:"kernel.bzImage",sha256:"0".repeat(64)},disk:{path:"disk.img",sha256:"0".repeat(64)},commandLine:"console=hvc0 root=/dev/vda rw"}}:{...s,mode:n,source:{kind:"dockerfile",context:".",file:"Dockerfile"}};return n==="userspace"&&(await t(e,"Dockerfile",`FROM ${A}
3
+ RUN mkdir -p /workspace
4
+ WORKDIR /workspace
5
+ `),await t(e,".dockerignore",`*.pem
6
+ *.public.json
7
+ dist/
8
+ node_modules/
9
+ .git/
10
+ `)),await t(e,"oxvm.image.ts",`import type { ImageRecipe } from "@oxvm/sdk/image-builder";
11
+
12
+ export default ${JSON.stringify(i,null,2)} satisfies ImageRecipe;
13
+ `),await t(e,"image.lock.json",`${JSON.stringify({schemaVersion:2,kind:"build-inputs",mode:n,id:r,version:"1.0.0",sourceDateEpoch:0},null,2)}
14
+ `),await t(e,".gitignore",`*.pem
15
+ *.key
16
+ kernel.bzImage
17
+ disk.img
18
+ dist/
19
+ node_modules/
20
+ `),await t(e,"README.md",`# Custom Linux image
21
+
22
+ ${n==="system"?"Supply your own kernel.bzImage and disk.img. Replace the placeholder SHA-256 values with their actual checksums and set the correct boot command line. Build a disk with the compatible guest-agent integration for workspace/process APIs. This release supplies no managed kernel bootstrap. Keep guest binaries outside Git.":"Edit the Dockerfile and typed recipe. Keep the base pinned to its immutable digest."}
23
+
24
+ Create a signing key once with \`oxvm image keygen --out author.pem\`. Build with \`oxvm image build oxvm.image.ts --signing-key author.pem\`, then run \`oxvm image test dist --trust author.public.json\`. Development builds report missing redistribution evidence. Add reviewed SBOM, notices, corresponding sources and license policy before requesting \`--distribution\`.
25
+ `),{directory:e,recipePath:w(e,"oxvm.image.ts"),mode:n}}d(z,"initializeImage");async function F(e,n,r,s,i={}){const a=i.image===void 0?void 0:await R(i.image.bundle,i.image.trust);if(a!==void 0&&a.mode!==n)throw new b("INVALID_ARGUMENT","image bundle must match the application mode");const o=a===void 0?i.productionImage:{mode:n,manifestUrl:`/oxvm/images/${a.manifestSHA256}/manifest.json`,manifestSHA256:a.manifestSHA256,trust:a.trust},l={mode:n,publicDir:n==="userspace"?".oxvm/assets":"public",assetBaseUrl:"/oxvm/",...o===void 0?{}:{image:o}},I=O(l),u=i.engineDir!==void 0,p=!r&&(u||i.image!==void 0),g=await j(),c=await T(i.archives);await k(e),await C(w(e,"src")),await t(e,"LICENSE",await h(new URL("../LICENSE",import.meta.url),"utf8")),await t(e,"NOTICE",await h(new URL("../NOTICE",import.meta.url),"utf8"));const f=N(),v=i.materialsUrl;await t(e,"LICENSES.md",`# Licenses and deployment
26
+
27
+ The SDK, CLI, and generated application code use Apache-2.0. Keep LICENSE
28
+ and NOTICE with redistributed code. Dependencies retain their own licenses.
29
+ Both installed packages include THIRD_PARTY_NOTICES.txt and sbom.cdx.json.
30
+ Fonts retain their OFL license files in public/fonts.
31
+ ${n==="userspace"?`
32
+ Python syntax highlighting uses highlight.js under BSD-3-Clause. Its license is in public/licenses/highlight.js.txt.
33
+ `:""}
34
+ The OXVM engine is proprietary and distributed separately. Local
35
+ development also permits work on commercial projects. Commercial production
36
+ requires a Spacia agreement. Non-commercial hosted deployments use the
37
+ registered public-license process. Licensed self-hosting is explicit.
38
+ ${f===null?"":`
39
+ [Engine terms](${new URL("RUNTIME-LICENSE.txt",f.url).href})
40
+ accompany the immutable compliance revision ${f.sha256}.
41
+ The runtime retains verified terms, notices, and the artifact SBOM.
42
+ `}
43
+ Development and production use the hosted runtime by default. It does not copy engine
44
+ binaries into your deployment. The existing hosted service describes its
45
+ [boot telemetry](https://run.oxvm.dev/telemetry). Its service terms and privacy
46
+ notices also apply.
47
+
48
+ The Python + pandas image is a collection of separately licensed programs. Engine
49
+ restrictions do not restrict rights granted by guest or dependency licenses.
50
+ Keep corresponding sources, notices, license texts, and checksums with
51
+ redistributed image binaries. You may modify and sign your own guest images.
52
+ ${v===void 0?`
53
+ The supplied image bundle contains its license and source materials.
54
+ `:`
55
+ [Image source and license materials](${v}) accompany the signed image.
56
+ `}`),await t(e,"src/runtime.ts",`import type { RuntimeOptions } from "@oxvm/sdk";
57
+
58
+ const runtime: RuntimeOptions = ${u?'import.meta.env.DEV ? { hosting: "self-hosted", baseUrl: "/oxvm/runtime/" } : { hosting: "frame" }':'{ hosting: "frame" }'};
59
+ export default runtime;
60
+ `);const x=L().sdkVersion;if(await t(e,"package.json",`${JSON.stringify({name:"oxvm-starter",version:"0.0.0",private:!0,license:"Apache-2.0",type:"module",scripts:{dev:"vite",build:n==="userspace"?"tsc --noEmit && tsc -p tsconfig.node.json && vite build":"tsc --noEmit && vite build",preview:"vite preview",assets:"oxvm assets install",doctor:"oxvm doctor"},dependencies:{"@oxvm/sdk":c?.sdk??x,...n==="userspace"?{"highlight.js":"11.12.0","@xterm/xterm":"6.0.0","@xterm/addon-fit":"0.11.0"}:{}},devDependencies:{"@oxvm/cli":c?.cli??x,vite:"7.3.6",typescript:"6.0.3","@types/node":"24.13.3"},...c===void 0?{}:{overrides:{"@oxvm/sdk":c.sdk}}},null,2)}
61
+ `),c!==void 0&&await t(e,"pnpm-workspace.yaml",`overrides:
62
+ '@oxvm/sdk': ${JSON.stringify(c.sdk)}
63
+ `),g!==void 0&&await t(e,".npmrc",g),await t(e,"oxvm.config.ts",`import type { ProjectConfig } from "@oxvm/sdk/image-builder";
64
+ export default ${JSON.stringify(l,null,2)} satisfies ProjectConfig;
65
+ `),await t(e,"oxvm.lock.json",`${JSON.stringify(I,null,2)}
66
+ `),await t(e,"tsconfig.json",`${JSON.stringify({compilerOptions:{target:"ES2024",module:"ESNext",moduleResolution:"Bundler",lib:["ES2024","DOM","DOM.Iterable"],types:["vite/client"],strict:!0,noUncheckedIndexedAccess:!0,exactOptionalPropertyTypes:!0,noImplicitOverride:!0,useUnknownInCatchVariables:!0,skipLibCheck:!1,noEmit:!0,verbatimModuleSyntax:!0,allowImportingTsExtensions:!0,noUnusedLocals:!0,noUnusedParameters:!0,noFallthroughCasesInSwitch:!0,noImplicitReturns:!0,noPropertyAccessFromIndexSignature:!0,noUncheckedSideEffectImports:!0},include:["src/**/*.ts"]},null,2)}
67
+ `),n==="userspace"){await M(e),await t(e,"src/image.ts",`// Generated by OXVM assets install.
68
+ ${o===void 0?`import type { ImageRef } from "@oxvm/sdk";
69
+ const image: ImageRef<"userspace"> | undefined = undefined;
70
+ export default image;`:`import { defineImage } from "@oxvm/sdk";
71
+ export default defineImage(${JSON.stringify(o)});`}
72
+ `);const m=i.productionImage??o;await t(e,"src/production-image.ts",`// Generated by OXVM assets install.
73
+ ${m===void 0?`import type { ImageRef } from "@oxvm/sdk";
74
+ const image: ImageRef<"userspace"> | undefined = undefined;
75
+ export default image;`:`import { defineImage } from "@oxvm/sdk";
76
+ export default defineImage(${JSON.stringify(m)});`}
77
+ `)}else{await t(e,"vite.config.ts",`import { defineConfig } from "vite";
78
+ const headers = { "Cross-Origin-Opener-Policy": "same-origin", "Cross-Origin-Embedder-Policy": "require-corp" };
79
+ export default defineConfig({ server: { headers }, preview: { headers }, worker: { format: "es" }, optimizeDeps: { exclude: ["@oxvm/sdk"] } });
80
+ `),await t(e,"index.html",`<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="oxvm-assets" content="/oxvm/"><title>OXVM</title></head><body><h1>Linux in your browser</h1><button id="run">Run Linux command</button><button id="cancel">Cancel startup</button><pre id="output" aria-live="polite"></pre><script type="module" src="/src/main.ts"><\/script></body></html>
81
+ `);const m=o===void 0?"":", defineImage",E=o===void 0?"":`image: defineImage(${JSON.stringify(o)}), `;await t(e,"src/main.ts",`import { createVM, VMError${m} } from "@oxvm/sdk";
82
+ import runtime from "./runtime.ts";
83
+
84
+ const run = document.querySelector("#run");
85
+ const output = document.querySelector("#output");
86
+ const cancel = document.querySelector("#cancel");
87
+ if (!(run instanceof HTMLButtonElement) || !(output instanceof HTMLElement) || !(cancel instanceof HTMLButtonElement)) throw new Error("Missing controls");
88
+ let controller: AbortController | undefined;
89
+ cancel.addEventListener("click", () => controller?.abort());
90
+ run.addEventListener("click", () => {
91
+ if (controller !== undefined) return;
92
+ const current = new AbortController(); controller = current; run.disabled = true;
93
+ void (async () => {
94
+ const vm = await createVM({ mode: ${JSON.stringify(n)}, runtime, ${E}signal: current.signal, onProgress: progress => { output.textContent = "Opening Linux: " + progress.phase; } });
95
+ try {
96
+ const result = await vm.exec({ command: "/bin/sh", args: ["-c", "printf 'Hello from Linux\\n'"], signal: current.signal });
97
+ output.textContent = new TextDecoder().decode(result.stdout) + new TextDecoder().decode(result.stderr) + "\\n" + JSON.stringify(result.exit);
98
+ } finally { await vm.dispose(); }
99
+ })().catch((error: unknown) => { output.textContent = error instanceof VMError ? error.code + ": " + error.message : "Linux could not complete"; }).finally(() => { controller = undefined; run.disabled = false; });
100
+ });
101
+ `)}return await t(e,".gitignore",`node_modules/
102
+ dist/
103
+ .oxvm/
104
+ public/oxvm/
105
+ *.pem
106
+ *.key
107
+ `),n==="system"&&await t(e,"README.md",`# Linux browser application
108
+
109
+ Selected mode: ${n}.
110
+
111
+ ${g===void 0?"Install the SDK and CLI release archives with the documented pnpm override. ":"Keep the generated .npmrc so the @oxvm scope uses this build's configured registry. "}Run \`pnpm install\` and \`pnpm dev\`. Open the printed localhost URL and choose Run Linux command. Use \`pnpm exec oxvm doctor\` against that URL to check the deployment. \`pnpm build\` produces static assets. Configure COOP and COEP on the production host as in vite.config.ts.
112
+
113
+ ${p?`Pinned assets are installed; dependencies have not been installed.
114
+ `:`The application selects the hosted runtime. Supply an explicit System image before starting the app.
115
+ `}`),p&&await D(e,l,{signal:s,hosting:u?"self-hosted":"frame",...i.engineDir===void 0?{}:{engineDir:i.engineDir},...i.engineComplianceDir===void 0?{}:{engineComplianceDir:i.engineComplianceDir},...i.image===void 0?{}:{imageDir:i.image.bundle,trust:i.image.trust}}),{directory:e,mode:n,assets:p?"installed":"skipped"}}d(F,"initializeApplication");export{F as initializeApplication,z as initializeImage,j as registryConfig};
@@ -0,0 +1,5 @@
1
+ export declare function object(value: unknown, label: string): Record<string, unknown>;
2
+ export declare function fields(input: Record<string, unknown>, required: readonly string[], optional?: readonly string[]): void;
3
+ export declare function text(value: unknown): string;
4
+ export declare function number(value: unknown, minimum?: number): number;
5
+ export declare function choice<T extends string>(value: unknown, choices: readonly T[]): T;
@@ -0,0 +1 @@
1
+ var O=Object.defineProperty;var e=(r,t)=>O(r,"name",{value:t,configurable:!0});import{VMError as o}from"@oxvm/sdk";function s(r,t){if(typeof r!="object"||r===null||Array.isArray(r))throw new o("PROTOCOL_ERROR",`${t} must be an object`);return Object.fromEntries(Object.entries(r))}e(s,"object");function R(r,t,n=[]){if(t.some(i=>!Object.hasOwn(r,i))||Object.keys(r).some(i=>!t.includes(i)&&!n.includes(i)))throw new o("PROTOCOL_ERROR","unexpected or missing report fields")}e(R,"fields");function m(r){if(typeof r!="string"||r.length===0||r.length>8192||Array.from(r).some(t=>t.charCodeAt(0)<32&&![9,10,13].includes(t.charCodeAt(0))))throw new o("PROTOCOL_ERROR","invalid report string");return r}e(m,"text");function p(r,t=0){if(typeof r!="number"||!Number.isSafeInteger(r)||r<t)throw new o("PROTOCOL_ERROR","invalid report integer");return r}e(p,"number");function b(r,t){for(const n of t)if(n===r)return n;throw new o("PROTOCOL_ERROR","invalid report choice")}e(b,"choice");export{b as choice,R as fields,p as number,s as object,m as text};
@@ -0,0 +1,7 @@
1
+ import type { CLIInvocation } from "./arguments.js";
2
+ import type { CliReport } from "./contracts.js";
3
+ import type { CLIEnvironment } from "./run.js";
4
+ export type WasmCLIInvocation = Extract<CLIInvocation, {
5
+ command: "wasm add" | "wasm stage" | "wasm doctor" | "wasm inspect" | "wasm build" | "wasm release" | "wasm init" | "wasm test";
6
+ }>;
7
+ export declare function runWasmCommand(invocation: WasmCLIInvocation, io: CLIEnvironment): Promise<CliReport>;
@@ -0,0 +1 @@
1
+ var w=Object.defineProperty;var l=(e,r)=>w(e,"name",{value:r,configurable:!0});import{relative as g,resolve as u,sep as h}from"node:path";import{readFile as y}from"node:fs/promises";import{VMError as m}from"@oxvm/sdk";import{BlobCache as k,buildModule as b,commitAdd as j,defaultModuleCacheDir as M,doctorModules as V,githubToken as D,inspectWasm as A,previewAdd as F,readImageTrust as I,stageProject as T,testModule as x}from"@oxvm/sdk/image-builder";import{releasePlan as N}from"./wasm-release.js";import{consentText as R}from"./wasm-text.js";import{initializeModule as $}from"./wasm-templates.js";import{pinnedStarterRelease as C}from"./starter-release.js";function E(e,r){const s=g(e,r);return s===""||s===".."||s.startsWith(`..${h}`)?r:s}l(E,"shown");async function c(e,r,s){const t=await b(u(r.directory,e.project),{check:s,signal:r.signal,...e.out===void 0?{}:{out:e.out},...e.module===void 0?{}:{module:e.module}});return t.directory===null?t:{...t,directory:E(r.directory,t.directory)}}l(c,"buildFor");async function p(e,r,s){return{projectDir:e,cache:new k(M(s.environment)),token:await D(s.environment),offline:r.offline===!0,signal:s.signal}}l(p,"context");async function L(e,r,s){if(!r.consent.required)return r.consent.otherwise;if(e.yes)return"approved";if(s.confirm===void 0)throw new m("INVALID_ARGUMENT",`${r.card.id} needs your consent (${r.consent.reasons.join(", ")}). Run this command in a terminal to see what the module declares and confirm, or read the module.json of the release first and pass --yes.`,{reason:"wasm-consent-required"});if(s.stderr(R(r)),!await s.confirm("Install this module? [y/N] "))throw new m("ABORTED","the module was not installed");return"approved"}l(L,"consentFor");async function O(e,r){const s=e.command;switch(s){case"wasm inspect":{const t=u(r.directory,e.file),a=await A(new Uint8Array(await y(t)));return{schemaVersion:3,kind:"result",command:s,result:{file:e.file,...a}}}case"wasm build":return{schemaVersion:3,kind:"result",command:s,result:await c(e,r,e.check)};case"wasm release":{const t=await c(e,r,!1);return{schemaVersion:3,kind:"result",command:s,result:{build:t,...N(t,{directory:t.directory??"dist",...e.repo===void 0?{}:{repo:e.repo}})}}}case"wasm init":return{schemaVersion:3,kind:"result",command:s,result:await $(u(r.directory,e.directory),{kind:e.moduleKind,network:e.network,...e.id===void 0?{}:{id:e.id},...e.from===void 0?{}:{from:u(r.directory,e.from)}})};case"wasm test":{const t=u(r.directory,e.project),a=u(t,e.module??"dist"),n=e.image===void 0?C()?.image:{bundle:u(r.directory,e.image.bundle),trust:await I(u(r.directory,e.image.trust))};if(n===void 0)throw new m("INVALID_ARGUMENT","this CLI pins no public starter image; pass --image <bundle> --image-trust <A.public.json>",{reason:"wasm-test-image"});const o=await x(a,{image:n,args:e.args,options:e.options,browser:e.browser,signal:r.signal,...e.engineDir===void 0?{}:{engineDir:u(r.directory,e.engineDir)},...e.timeoutMs===void 0?{}:{commandMs:e.timeoutMs}});return{schemaVersion:3,kind:"result",command:s,result:o}}case"wasm doctor":return{schemaVersion:3,kind:"result",command:s,result:await V(u(r.directory,e.project),{signal:r.signal})};case"wasm stage":{const t=u(r.directory,e.project),a=await T(t,await p(t,e,r));return{schemaVersion:3,kind:"result",command:s,result:{modules:a.staged.map(n=>({id:n.id,release:n.release,rebuilt:n.rebuilt})),vendored:a.vendored,removed:a.removed,generatedFile:e.project==="."?a.generatedFile.replace(`${t}/`,""):a.generatedFile}}}case"wasm add":{const t=u(r.directory,e.project),a=await p(t,e,r),n=await F(t,e.source,a),o=await L(e,n,r),i=await j(t,n,a),{card:d}=n;return{schemaVersion:3,kind:"result",command:s,result:{id:d.id,version:d.version,source:d.source,release:d.release,status:i.status,consent:o,license:{spdx:d.license.spdx,copyleft:d.license.copyleft},capabilities:d.capabilities,...d.commands.length===0?{}:{commands:d.commands.map(f=>f.name)},...d.network.reach==="none"?{}:{network:{reach:d.network.reach,hosts:d.network.hosts,...d.network.purpose===void 0?{}:{purpose:d.network.purpose}}},added:n.added,removed:n.removed,generatedFile:i.stage.generatedFile.replace(`${t}/`,"")}}}}}l(O,"runWasmCommand");export{O as runWasmCommand};
@@ -0,0 +1,2 @@
1
+ /** The stable reason of a module failure (`wasm-…`), the only detail that is safe and useful to print. */
2
+ export declare function wasmFailureDetail(error: unknown): Readonly<Record<string, unknown>> | undefined;
@@ -0,0 +1 @@
1
+ var r=Object.defineProperty;var t=(n,e)=>r(n,"name",{value:e,configurable:!0});import{VMError as i}from"@oxvm/sdk";function s(n){if(!(n instanceof i))return;const e=n.detail?.reason;return typeof e=="string"&&/^wasm-[a-z0-9-]{1,64}$/u.test(e)?{reason:e}:void 0}t(s,"wasmFailureDetail");export{s as wasmFailureDetail};
@@ -0,0 +1,3 @@
1
+ import type { CliCommand } from "./contracts.js";
2
+ export declare const wasmHelp = "\n wasm add <github:owner/repo@tag | file:directory> [--project <directory>] [--yes] [--offline]\n Resolves a module release, shows what it declares and asks before installing it. Writes oxvm.modules.json,\n oxvm.modules.lock.json, modules/<id>/module.json and the staged files, and generates src/oxvm.modules.generated.ts.\n A source whose owner is listed under \"trusted\" is installed without a question the first time; a release that asks for\n more authority than the installed one always asks again. --yes accepts after you have reviewed the module.\n wasm stage [--project <directory>] [--offline]\n Rebuilds the staged files and generated handles from the lock (use it after cloning a project).\n wasm doctor [--project <directory>]\n Checks that declaration, lock, committed module.json files, staged files and generated handles agree, and what the SDK\n and browser must provide.\n wasm inspect <file.wasm>\n Reports a WebAssembly binary's imports, exports and the ABI it appears to use.\n wasm init <directory> [--kind command|service] [--id <id>] [--from <file.wasm>] [--network none|vm|internet]\n Creates a module project: module.ts (manifest and adapter), unit tests, strict TypeScript and ESLint settings, CI and\n release workflows, and an example that wraps a tiny WebAssembly function. --from starts from your own .wasm file.\n A command module declares its id in commands, so programs in a VM can run it from a shell once an application turns\n it on; an id that starts with oxidevm is reserved and gets none. --network declares the module's reach (default none):\n vm adds net.vm, internet adds net.internet and a disclosure stub; both add src/net.ts and test/net.test.ts.\n wasm build [--project <directory>] [--out <directory>] [--module <file>] [--check]\n Reads the manifest from module.ts without running it, bundles the adapter into one file, pins every artifact and\n writes module.json, adapter.mjs, the artifacts and SHA256SUMS to dist/. --check verifies and writes nothing. Exits 3\n when it finds errors.\n wasm test [--project <directory>] [--module <dist>] [--image <bundle> --image-trust <A.public.json>] [--arg <value>]...\n [--option <name=value>]... [--browser chromium|firefox|webkit] [--engine-dir <release>] [--timeout-ms <ms>]\n Runs the runner-contract properties against the built module (dist/ by default) in a real browser: integrity, exit\n status, readiness, endpoints, duplicate start, snapshots, stop on end of input, restart, recovery after a kill,\n declared capabilities, and the network standard (no direct browser network, nothing beyond the reach, offline). Uses\n the public starter image unless --image names another. Exits 3 when a property fails, and 4 when the browser or image\n refuses the module (no isolated module workers, or a missing prerequisite), so no property ran.\n wasm release [--project <directory>] [--out <directory>] [--module <file>] [--repo <owner/name>]\n Builds, then prints the steps that publish the build as a GitHub release: tag, draft, verify, publish. It runs none of them.\n\nModules run in Userspace JS processes, in the VM's module frame, with a self-hosted runtime or the hosted runtime frame.\nEvery wasm command accepts --json.\n";
3
+ export declare function wasmCommandHelp(command: CliCommand): string;
@@ -0,0 +1,37 @@
1
+ var r=Object.defineProperty;var t=(e,s)=>r(e,"name",{value:s,configurable:!0});const a=`
2
+ wasm add <github:owner/repo@tag | file:directory> [--project <directory>] [--yes] [--offline]
3
+ Resolves a module release, shows what it declares and asks before installing it. Writes oxvm.modules.json,
4
+ oxvm.modules.lock.json, modules/<id>/module.json and the staged files, and generates src/oxvm.modules.generated.ts.
5
+ A source whose owner is listed under "trusted" is installed without a question the first time; a release that asks for
6
+ more authority than the installed one always asks again. --yes accepts after you have reviewed the module.
7
+ wasm stage [--project <directory>] [--offline]
8
+ Rebuilds the staged files and generated handles from the lock (use it after cloning a project).
9
+ wasm doctor [--project <directory>]
10
+ Checks that declaration, lock, committed module.json files, staged files and generated handles agree, and what the SDK
11
+ and browser must provide.
12
+ wasm inspect <file.wasm>
13
+ Reports a WebAssembly binary's imports, exports and the ABI it appears to use.
14
+ wasm init <directory> [--kind command|service] [--id <id>] [--from <file.wasm>] [--network none|vm|internet]
15
+ Creates a module project: module.ts (manifest and adapter), unit tests, strict TypeScript and ESLint settings, CI and
16
+ release workflows, and an example that wraps a tiny WebAssembly function. --from starts from your own .wasm file.
17
+ A command module declares its id in commands, so programs in a VM can run it from a shell once an application turns
18
+ it on; an id that starts with oxidevm is reserved and gets none. --network declares the module's reach (default none):
19
+ vm adds net.vm, internet adds net.internet and a disclosure stub; both add src/net.ts and test/net.test.ts.
20
+ wasm build [--project <directory>] [--out <directory>] [--module <file>] [--check]
21
+ Reads the manifest from module.ts without running it, bundles the adapter into one file, pins every artifact and
22
+ writes module.json, adapter.mjs, the artifacts and SHA256SUMS to dist/. --check verifies and writes nothing. Exits 3
23
+ when it finds errors.
24
+ wasm test [--project <directory>] [--module <dist>] [--image <bundle> --image-trust <A.public.json>] [--arg <value>]...
25
+ [--option <name=value>]... [--browser chromium|firefox|webkit] [--engine-dir <release>] [--timeout-ms <ms>]
26
+ Runs the runner-contract properties against the built module (dist/ by default) in a real browser: integrity, exit
27
+ status, readiness, endpoints, duplicate start, snapshots, stop on end of input, restart, recovery after a kill,
28
+ declared capabilities, and the network standard (no direct browser network, nothing beyond the reach, offline). Uses
29
+ the public starter image unless --image names another. Exits 3 when a property fails, and 4 when the browser or image
30
+ refuses the module (no isolated module workers, or a missing prerequisite), so no property ran.
31
+ wasm release [--project <directory>] [--out <directory>] [--module <file>] [--repo <owner/name>]
32
+ Builds, then prints the steps that publish the build as a GitHub release: tag, draft, verify, publish. It runs none of them.
33
+
34
+ Modules run in Userspace JS processes, in the VM's module frame, with a self-hosted runtime or the hosted runtime frame.
35
+ Every wasm command accepts --json.
36
+ `;function n(e){return`oxvm ${e}
37
+ ${a}`}t(n,"wasmCommandHelp");export{n as wasmCommandHelp,a as wasmHelp};
@@ -0,0 +1,15 @@
1
+ import type { WasmBuildResult } from "@oxvm/sdk/image-builder";
2
+ /** A word for a shell command line: left alone when it is plainly safe, single-quoted otherwise. */
3
+ export declare function shellWord(value: string): string;
4
+ /**
5
+ * The commands that publish a finished build: tag, draft with every file, download and check the draft against its own
6
+ * SHA256SUMS, publish, and the line that installs it. Publishing changes what other people can install, so these are
7
+ * printed for the author to run (or for the release workflow to run), never executed here.
8
+ */
9
+ export declare function releasePlan(build: WasmBuildResult, options: {
10
+ readonly repo?: string;
11
+ readonly directory: string;
12
+ }): {
13
+ readonly tag: string | null;
14
+ readonly steps: readonly string[];
15
+ };
@@ -0,0 +1,8 @@
1
+ var o=Object.defineProperty;var s=(e,n)=>o(e,"name",{value:n,configurable:!0});function r(e){return/^[A-Za-z0-9._/@:+=-]+$/u.test(e)?e:`'${e.replaceAll("'","'\\''")}'`}s(r,"shellWord");function $(e,n){if(e.result==="failed"||e.version===null||e.release===null)return{tag:null,steps:[]};const t=`v${e.version}`,i=n.repo??"OWNER/REPO",a=n.repo===void 0?"":` --repo ${r(n.repo)}`,l=`${r(n.directory)}/*`;return{tag:t,steps:[`1. Commit your changes, then tag the release:
2
+ git tag ${r(t)} && git push origin ${r(t)}`,`2. Draft the release with every file of the build:
3
+ gh release create ${r(t)} ${l} --draft --verify-tag --title ${r(t)} --generate-notes${a}`,`3. Download the draft and check it against its own SHA256SUMS:
4
+ mkdir verify && gh release download ${r(t)} --dir verify${a}
5
+ (cd verify && sha256sum --check SHA256SUMS && sha256sum SHA256SUMS)
6
+ The last digest must be the release id, ${e.release}.`,`4. Publish it:
7
+ gh release edit ${r(t)} --draft=false${a}`,`5. Anyone can now install it:
8
+ oxvm wasm add github:${i}@${t}`]}}s($,"releasePlan");export{$ as releasePlan,r as shellWord};
@@ -0,0 +1,50 @@
1
+ /** The text of the files of a generated module project. */
2
+ import { type TemplateReach } from "./wasm-template-network.js";
3
+ /** Command names that start with this are reserved; the SDK's manifest decoder refuses them in `commands`. */
4
+ export declare const RESERVED_COMMAND_PREFIX = "oxidevm";
5
+ /** The command a generated command module declares: its id, which is always a valid command name unless the prefix is reserved. */
6
+ export declare function commandFor(id: string): string | undefined;
7
+ /** The name `oxvm wasm stage` exports a module's handle under: `my-tool` becomes `myTool`. */
8
+ export declare function handleName(id: string): string;
9
+ /**
10
+ * What a generated project is: a service, or a command module with the name its manifest declares in `commands`
11
+ * (`undefined` when the id starts with the reserved prefix) that is either the add example or a `--from` skeleton.
12
+ */
13
+ export type TemplateShape = {
14
+ readonly kind: "service";
15
+ } | {
16
+ readonly kind: "command";
17
+ readonly command: string | undefined;
18
+ readonly skeleton: boolean;
19
+ };
20
+ /** A hand-assembled WebAssembly module exporting `add(i32, i32) -> i32`, so the example needs no binary in source control. */
21
+ export declare const ADD_WASM: Uint8Array<ArrayBuffer>;
22
+ export declare const OPERANDS_SOURCE = "/** Reads exactly two 32-bit signed integers from text; `undefined` when there are not exactly two valid ones. */\nexport function parseOperands(args: readonly string[]): readonly [number, number] | undefined {\n const [left, right, ...rest] = args;\n if (left === undefined || right === undefined || rest.length > 0) return undefined;\n const first = parseInteger(left), second = parseInteger(right);\n return first === undefined || second === undefined ? undefined : [first, second];\n}\n\nfunction parseInteger(text: string): number | undefined {\n if (!/^-?\\d{1,10}$/u.test(text)) return undefined;\n const value = Number(text);\n return value >= -2147483648 && value <= 2147483647 ? value : undefined;\n}\n";
23
+ export declare const OPERANDS_TEST = "import { describe, expect, it } from \"vitest\";\nimport { parseOperands } from \"../src/operands.ts\";\n\ndescribe(\"parseOperands\", () => {\n it(\"reads two 32-bit integers\", () => {\n expect(parseOperands([\"2\", \"-3\"])).toEqual([2, -3]);\n expect(parseOperands([\"2147483647\", \"-2147483648\"])).toEqual([2147483647, -2147483648]);\n });\n\n it(\"refuses anything else\", () => {\n for (const args of [[], [\"1\"], [\"1\", \"2\", \"3\"], [\"1\", \"x\"], [\"1.5\", \"2\"], [\"2147483648\", \"1\"], [\"\", \"1\"], [\"1e3\", \"1\"]]) {\n expect(parseOperands(args)).toBeUndefined();\n }\n });\n});\n";
24
+ /**
25
+ * `src/command.ts` of the add example: the command's behavior, apart from the WebAssembly, against only the host members it
26
+ * uses. `command` is the name module.ts declares, or undefined when the id is reserved and the module declares none.
27
+ */
28
+ export declare function addCommandSource(id: string, command: string | undefined): string;
29
+ /**
30
+ * `test/command.test.ts` of the add example: runs the whole module, its WebAssembly included, through the SDK's real runner
31
+ * with \`testHost\`, for each way the module can start.
32
+ */
33
+ export declare function addCommandTest(id: string, command: string | undefined): string;
34
+ export declare const TSCONFIG = "{\n \"compilerOptions\": {\n \"allowImportingTsExtensions\": true,\n \"exactOptionalPropertyTypes\": true,\n \"forceConsistentCasingInFileNames\": true,\n \"isolatedModules\": true,\n \"lib\": [\"ES2024\", \"DOM\"],\n \"module\": \"ESNext\",\n \"moduleResolution\": \"Bundler\",\n \"noEmit\": true,\n \"noFallthroughCasesInSwitch\": true,\n \"noImplicitOverride\": true,\n \"noImplicitReturns\": true,\n \"noPropertyAccessFromIndexSignature\": true,\n \"noUncheckedIndexedAccess\": true,\n \"noUncheckedSideEffectImports\": true,\n \"noUnusedLocals\": true,\n \"noUnusedParameters\": true,\n \"skipLibCheck\": false,\n \"strict\": true,\n \"target\": \"ES2024\",\n \"types\": [],\n \"useUnknownInCatchVariables\": true,\n \"verbatimModuleSyntax\": true\n },\n \"include\": [\"module.ts\", \"src\"]\n}\n";
35
+ /** Tests run in Node, so they alone see Node's types; the module and its helpers are checked without them, as they run in a worker. */
36
+ export declare const TEST_TSCONFIG = "{\n \"extends\": \"../tsconfig.json\",\n \"compilerOptions\": { \"types\": [\"node\"] },\n \"include\": [\"./**/*.ts\", \"../module.ts\", \"../src/**/*.ts\"]\n}\n";
37
+ export declare function moduleTest(id: string, shape: TemplateShape, reach: TemplateReach): string;
38
+ export declare const ESLINT_CONFIG = "import eslint from \"@eslint/js\";\nimport { defineConfig } from \"eslint/config\";\nimport tseslint from \"typescript-eslint\";\n\nexport default defineConfig(\n { ignores: [\"dist/**\", \"node_modules/**\", \"eslint.config.js\"] },\n eslint.configs.recommended,\n ...tseslint.configs.strictTypeChecked,\n {\n languageOptions: { parserOptions: { projectService: true, tsconfigRootDir: import.meta.dirname } },\n rules: {\n \"@typescript-eslint/ban-ts-comment\": \"error\",\n \"@typescript-eslint/consistent-type-imports\": \"error\",\n \"@typescript-eslint/no-explicit-any\": \"error\",\n \"@typescript-eslint/no-floating-promises\": \"error\",\n \"@typescript-eslint/no-non-null-assertion\": \"error\",\n \"@typescript-eslint/no-unsafe-type-assertion\": \"error\",\n \"@typescript-eslint/strict-boolean-expressions\": \"error\",\n \"@typescript-eslint/switch-exhaustiveness-check\": \"error\",\n },\n },\n);\n";
39
+ export declare const GITIGNORE = "node_modules/\ndist/\n*.log\n";
40
+ /**
41
+ * The Playwright version \`oxvm wasm test\` drives, which is the SDK's own dependency. The template declares the same
42
+ * version so \`pnpm exec playwright install\` fetches the browser build that version expects; a test keeps them equal.
43
+ */
44
+ export declare const TEMPLATE_PLAYWRIGHT = "1.64.0";
45
+ export declare function ciWorkflow(manual: boolean): string;
46
+ export declare function releaseWorkflow(manual: boolean): string;
47
+ /** A stub for the module's own notice. The CLI's NOTICE describes the CLI (esbuild, a Go runtime, fonts), not a module project. */
48
+ export declare function noticeFile(id: string): string;
49
+ export declare function agentsFile(id: string, shape: TemplateShape): string;
50
+ export declare function readmeFile(id: string, shape: TemplateShape, reach: TemplateReach): string;