@machinen/runtime 0.1.0
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/API.md +7052 -0
- package/LICENSE +110 -0
- package/README.md +119 -0
- package/dist/chunk-6SP6T537.js +163 -0
- package/dist/chunk-6SP6T537.js.map +1 -0
- package/dist/index.d.ts +2227 -0
- package/dist/index.js +7205 -0
- package/dist/index.js.map +1 -0
- package/dist/mount-server-bin.d.ts +2 -0
- package/dist/mount-server-bin.js +1341 -0
- package/dist/mount-server-bin.js.map +1 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Functional Source License, Version 1.1, MIT Future License
|
|
2
|
+
|
|
3
|
+
## Abbreviation
|
|
4
|
+
|
|
5
|
+
FSL-1.1-MIT
|
|
6
|
+
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2026 RedwoodJS Inc
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or
|
|
34
|
+
service that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software
|
|
39
|
+
that exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee
|
|
52
|
+
using the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to
|
|
59
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
+
remove any copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
79
|
+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the MIT license that is effective on the second anniversary of the date we make
|
|
91
|
+
the Software available. On or after that date, you may use the Software under
|
|
92
|
+
the MIT license, in which case the following will apply:
|
|
93
|
+
|
|
94
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
95
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
96
|
+
the Software without restriction, including without limitation the rights to
|
|
97
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
98
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
99
|
+
so, subject to the following conditions:
|
|
100
|
+
|
|
101
|
+
The above copyright notice and this permission notice shall be included in all
|
|
102
|
+
copies or substantial portions of the Software.
|
|
103
|
+
|
|
104
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
105
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
106
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
107
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
108
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
109
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
110
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# @machinen/runtime
|
|
2
|
+
|
|
3
|
+
The TypeScript API behind machinen. Reach for this when you want to
|
|
4
|
+
drive microVMs from your own Node.js code instead of through the CLI.
|
|
5
|
+
|
|
6
|
+
## What you can build with it
|
|
7
|
+
|
|
8
|
+
- **Run a Linux workload in a VM** with first-class control: stream
|
|
9
|
+
stdout/stderr, exec commands inside, write files in, await exit.
|
|
10
|
+
- **Snapshot a running process to disk and resume it later** —
|
|
11
|
+
possibly on a different machine. Heap, sockets, and open file
|
|
12
|
+
descriptors come back intact.
|
|
13
|
+
- **Clone a running VM into a sibling.** Both copies run independently
|
|
14
|
+
from the same instant, diverging from a shared heap. Useful for
|
|
15
|
+
branching warmed-up state into N parallel runs.
|
|
16
|
+
- **Bake reusable images.** `provision()` runs your apt/curl/copy
|
|
17
|
+
steps inside a real VM and archives the result as a tarball you can
|
|
18
|
+
boot over and over.
|
|
19
|
+
- **Multiplex many VMs from one host process** with per-sandbox stdio
|
|
20
|
+
routing.
|
|
21
|
+
|
|
22
|
+
If you want a CLI rather than a library, see
|
|
23
|
+
[`@machinen/cli`](../cli/README.md).
|
|
24
|
+
|
|
25
|
+
## Install
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm i @machinen/runtime
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
You also need a VMM binary. The matching one for your host
|
|
32
|
+
(`@machinen/vmm-arm64-darwin` for Apple Silicon Macs,
|
|
33
|
+
`@machinen/vmm-arm64-linux` for arm64 Linux) is pulled in
|
|
34
|
+
automatically as an optional dependency. If you'd rather install it
|
|
35
|
+
explicitly:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm i @machinen/vmm-arm64-darwin # or @machinen/vmm-arm64-linux
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
First boot fetches the kernel + base rootfs from a private GitHub
|
|
42
|
+
release, so make sure you've authenticated [GitHub
|
|
43
|
+
CLI](https://cli.github.com/) (`gh auth login`).
|
|
44
|
+
|
|
45
|
+
## A taste
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { boot } from "@machinen/runtime";
|
|
49
|
+
|
|
50
|
+
const vm = await boot({
|
|
51
|
+
image: "./rootfs-debian-arm64.tar.gz",
|
|
52
|
+
cmd: ["/bin/sh"],
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
await vm.exec("echo hello from inside");
|
|
56
|
+
|
|
57
|
+
const { code } = await vm.wait();
|
|
58
|
+
process.exit(code ?? 0);
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
For a longer walkthrough — provision an image, boot it, snapshot, hand
|
|
62
|
+
off — see the [Quickstart](../../docs/quickstart.md) and the
|
|
63
|
+
[guides](../../docs/) for end-to-end recipes (mounts, networking, fork
|
|
64
|
+
patterns, lifecycle).
|
|
65
|
+
|
|
66
|
+
## Reference
|
|
67
|
+
|
|
68
|
+
The full API surface — every function, every option, every error
|
|
69
|
+
class, with line-linked source pointers — is generated by typedoc and
|
|
70
|
+
lives in [API.md](./API.md). It's regenerated on release; treat it as
|
|
71
|
+
the source of truth for shapes and types.
|
|
72
|
+
|
|
73
|
+
A flyover of what's there:
|
|
74
|
+
|
|
75
|
+
- `provision`, `boot`, `restore`, `attach` — the four lifecycle
|
|
76
|
+
functions.
|
|
77
|
+
- `VmHandle` — what `boot`/`restore`/`attach` return: `exec`,
|
|
78
|
+
`execRaw`, `execPty`, `writeFile`, `snapshot`, `fork`, `wait`,
|
|
79
|
+
`kill`, `detach`.
|
|
80
|
+
- `MachinenError` and the typed-error tree (`BootError`, `ExecError`,
|
|
81
|
+
`SnapshotError`, …) plus `isMachinenError` / `formatMachinenError`.
|
|
82
|
+
- `list`, `runGc`, `validatePid`, `RegistryEntry` — registry and
|
|
83
|
+
lifecycle helpers.
|
|
84
|
+
- `bootPty` / `PtyVmHandle` — boot straight into a PTY for
|
|
85
|
+
terminal-aware workloads.
|
|
86
|
+
- `VsockExec`, `VsockFiles`, `VsockSecrets`, `VsockWinsize` — the
|
|
87
|
+
vsock protocol clients underneath the higher-level API.
|
|
88
|
+
- `Sandboxes`, `Supervisor` — multi-VM hosts.
|
|
89
|
+
- `LogEvent`, `OnLog` — the streaming-log event shape.
|
|
90
|
+
|
|
91
|
+
## Debugging
|
|
92
|
+
|
|
93
|
+
Set `DEBUG=machinen:*` to stream internal diagnostics to stderr. Uses
|
|
94
|
+
the [`debug`](https://github.com/debug-js/debug) package, so it's
|
|
95
|
+
zero-overhead when unset and supports the usual comma-separated
|
|
96
|
+
namespace patterns.
|
|
97
|
+
|
|
98
|
+
| Namespace | Covers |
|
|
99
|
+
| ---------------------- | --------------------------------------------------------------- |
|
|
100
|
+
| `machinen:boot` | `boot()` lifecycle — VMM spawn, vsock bridge, registry |
|
|
101
|
+
| `machinen:provision` | `provision()` steps — install hook, tar-to-disk, repack |
|
|
102
|
+
| `machinen:exec` | vsock exec — connect retries, frames, exit codes |
|
|
103
|
+
| `machinen:snapshot` | CRIU dump trigger, wait, console-log inspection |
|
|
104
|
+
| `machinen:attach` | attach lookup, VM resolution |
|
|
105
|
+
| `machinen:registry` | `~/.machinen/vms/` reads, writes, stale-entry pruning |
|
|
106
|
+
| `machinen:gvproxy` | sidecar spawn, port-forward setup |
|
|
107
|
+
| `machinen:mkinitramfs` | rootfs/bundle pack steps |
|
|
108
|
+
| `machinen:cli` | `@machinen/cli` argv parsing and command dispatch |
|
|
109
|
+
| `machinen:vmm` | tee VMM stderr to host stderr (replaces `MACHINEN_BUILD_DEBUG`) |
|
|
110
|
+
|
|
111
|
+
```sh
|
|
112
|
+
DEBUG=machinen:* npx machinen boot ./rootfs.tar.gz -- /bin/sh
|
|
113
|
+
DEBUG=machinen:exec,machinen:registry node script.js
|
|
114
|
+
DEBUG=machinen:gvproxy* pnpm smoke-tests
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## License
|
|
118
|
+
|
|
119
|
+
[FSL-1.1-MIT](../../LICENSE) — converts to MIT two years after each release.
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
// src/errors.ts
|
|
2
|
+
var ErrorCode = {
|
|
3
|
+
// boot — VM lifecycle, binary lookup, config validation
|
|
4
|
+
BOOT_VMM_MISSING: "BOOT_VMM_MISSING",
|
|
5
|
+
BOOT_VMM_PACKAGE_BROKEN: "BOOT_VMM_PACKAGE_BROKEN",
|
|
6
|
+
BOOT_IMAGE_NOT_FOUND: "BOOT_IMAGE_NOT_FOUND",
|
|
7
|
+
BOOT_SNAPSHOT_NOT_FOUND: "BOOT_SNAPSHOT_NOT_FOUND",
|
|
8
|
+
BOOT_KERNEL_NOT_FOUND: "BOOT_KERNEL_NOT_FOUND",
|
|
9
|
+
BOOT_DTB_NOT_FOUND: "BOOT_DTB_NOT_FOUND",
|
|
10
|
+
BOOT_CMD_WITHOUT_IMAGE: "BOOT_CMD_WITHOUT_IMAGE",
|
|
11
|
+
BOOT_CMD_MISSING: "BOOT_CMD_MISSING",
|
|
12
|
+
BOOT_CWD_INVALID: "BOOT_CWD_INVALID",
|
|
13
|
+
BOOT_MOUNT_INVALID: "BOOT_MOUNT_INVALID",
|
|
14
|
+
BOOT_MOUNT_HOST_NOT_FOUND: "BOOT_MOUNT_HOST_NOT_FOUND",
|
|
15
|
+
BOOT_LIVE_MOUNT_OVERRIDE_UNKNOWN: "BOOT_LIVE_MOUNT_OVERRIDE_UNKNOWN",
|
|
16
|
+
BOOT_PORT_FORWARD_INVALID: "BOOT_PORT_FORWARD_INVALID",
|
|
17
|
+
BOOT_PORT_FORWARD_CONFLICT: "BOOT_PORT_FORWARD_CONFLICT",
|
|
18
|
+
BOOT_PORT_FORWARD_NO_GVPROXY: "BOOT_PORT_FORWARD_NO_GVPROXY",
|
|
19
|
+
BOOT_PORT_FORWARD_IN_USE: "BOOT_PORT_FORWARD_IN_USE",
|
|
20
|
+
BOOT_PACK_FAILED: "BOOT_PACK_FAILED",
|
|
21
|
+
BOOT_TIMEOUT: "BOOT_TIMEOUT",
|
|
22
|
+
BOOT_DETACHED_READINESS_FAILED: "BOOT_DETACHED_READINESS_FAILED",
|
|
23
|
+
BOOT_MEMORY_INVALID: "BOOT_MEMORY_INVALID",
|
|
24
|
+
FORK_MEMORY_BACKPRESSURE: "FORK_MEMORY_BACKPRESSURE",
|
|
25
|
+
// mountdisk — `--mount` squashfs+ext4 overlay (#272)
|
|
26
|
+
BOOT_MOUNTDISK_TOOL_MISSING: "BOOT_MOUNTDISK_TOOL_MISSING",
|
|
27
|
+
// exec — vsock command execution
|
|
28
|
+
EXEC_VSOCK_UNAVAILABLE: "EXEC_VSOCK_UNAVAILABLE",
|
|
29
|
+
EXEC_AGENT_UNAVAILABLE: "EXEC_AGENT_UNAVAILABLE",
|
|
30
|
+
EXEC_AGENT_TIMEOUT: "EXEC_AGENT_TIMEOUT",
|
|
31
|
+
EXEC_NONZERO_EXIT: "EXEC_NONZERO_EXIT",
|
|
32
|
+
EXEC_PROTOCOL: "EXEC_PROTOCOL",
|
|
33
|
+
// snapshot — CRIU-based VM snapshotting
|
|
34
|
+
SNAPSHOT_NO_DISK: "SNAPSHOT_NO_DISK",
|
|
35
|
+
SNAPSHOT_DUMP_FAILED: "SNAPSHOT_DUMP_FAILED",
|
|
36
|
+
SNAPSHOT_TIMEOUT: "SNAPSHOT_TIMEOUT",
|
|
37
|
+
// provision — image builder
|
|
38
|
+
PROVISION_BASE_NOT_FOUND: "PROVISION_BASE_NOT_FOUND",
|
|
39
|
+
PROVISION_KERNEL_NOT_FOUND: "PROVISION_KERNEL_NOT_FOUND",
|
|
40
|
+
PROVISION_DTB_NOT_FOUND: "PROVISION_DTB_NOT_FOUND",
|
|
41
|
+
PROVISION_ASSETS_DIR_INVALID: "PROVISION_ASSETS_DIR_INVALID",
|
|
42
|
+
PROVISION_INSTALL_HOOK_FAILED: "PROVISION_INSTALL_HOOK_FAILED",
|
|
43
|
+
PROVISION_DISK_TOO_SMALL: "PROVISION_DISK_TOO_SMALL",
|
|
44
|
+
// rootfs-img — tar→ext4 materializer (#114, #120)
|
|
45
|
+
ROOTFS_IMG_TOOL_MISSING: "ROOTFS_IMG_TOOL_MISSING",
|
|
46
|
+
// registry / attach
|
|
47
|
+
REGISTRY_VM_NOT_FOUND: "REGISTRY_VM_NOT_FOUND",
|
|
48
|
+
REGISTRY_NAME_IN_USE: "REGISTRY_NAME_IN_USE",
|
|
49
|
+
// files — vsock push/pull
|
|
50
|
+
FILES_HOST_DIR_NOT_FOUND: "FILES_HOST_DIR_NOT_FOUND",
|
|
51
|
+
FILES_AGENT_UNAVAILABLE: "FILES_AGENT_UNAVAILABLE",
|
|
52
|
+
// mount — live-share (--mount-live, #78). Path containment is the
|
|
53
|
+
// load-bearing piece: any resolver failure means the guest tried to
|
|
54
|
+
// reach outside the mounted directory.
|
|
55
|
+
MOUNT_PATH_INVALID: "MOUNT_PATH_INVALID",
|
|
56
|
+
MOUNT_PATH_ESCAPE: "MOUNT_PATH_ESCAPE",
|
|
57
|
+
// mount-server-detached spawn (#150 phase 3): the standalone helper
|
|
58
|
+
// bin couldn't be located (no dist build, no source, no override) or
|
|
59
|
+
// failed to start.
|
|
60
|
+
MOUNT_SERVER_BIN_MISSING: "MOUNT_SERVER_BIN_MISSING",
|
|
61
|
+
MOUNT_SERVER_SPAWN_FAILED: "MOUNT_SERVER_SPAWN_FAILED",
|
|
62
|
+
// secrets — vsock KEY=VALUE injection
|
|
63
|
+
SECRETS_VALUE_INVALID: "SECRETS_VALUE_INVALID",
|
|
64
|
+
SECRETS_AGENT_UNAVAILABLE: "SECRETS_AGENT_UNAVAILABLE",
|
|
65
|
+
// winsize — vsock resize forwarder
|
|
66
|
+
WINSIZE_AGENT_UNAVAILABLE: "WINSIZE_AGENT_UNAVAILABLE",
|
|
67
|
+
// multiplex — sandbox registry
|
|
68
|
+
SANDBOX_ID_DUPLICATE: "SANDBOX_ID_DUPLICATE",
|
|
69
|
+
SANDBOX_ID_UNKNOWN: "SANDBOX_ID_UNKNOWN",
|
|
70
|
+
// cache — host-side artifact mirror
|
|
71
|
+
CACHE_BIND_FAILED: "CACHE_BIND_FAILED",
|
|
72
|
+
// gvproxy — user-mode network bridge
|
|
73
|
+
GVPROXY_NOT_FOUND: "GVPROXY_NOT_FOUND",
|
|
74
|
+
GVPROXY_EXPOSE_FAILED: "GVPROXY_EXPOSE_FAILED",
|
|
75
|
+
GVPROXY_PORT_IN_USE: "GVPROXY_PORT_IN_USE",
|
|
76
|
+
GVPROXY_INSTALL_FAILED: "GVPROXY_INSTALL_FAILED",
|
|
77
|
+
GVPROXY_SPAWN_FAILED: "GVPROXY_SPAWN_FAILED",
|
|
78
|
+
// mkinitramfs — initramfs packer
|
|
79
|
+
MKINITRAMFS_BUNDLE_INVALID: "MKINITRAMFS_BUNDLE_INVALID",
|
|
80
|
+
MKINITRAMFS_WORKSPACE_INVALID: "MKINITRAMFS_WORKSPACE_INVALID",
|
|
81
|
+
MKINITRAMFS_WORKSPACE_TOO_LARGE: "MKINITRAMFS_WORKSPACE_TOO_LARGE",
|
|
82
|
+
MKINITRAMFS_BASE_EXTRACT_FAILED: "MKINITRAMFS_BASE_EXTRACT_FAILED",
|
|
83
|
+
MKINITRAMFS_INIT_MISSING: "MKINITRAMFS_INIT_MISSING",
|
|
84
|
+
// parse — CLI arg parser
|
|
85
|
+
PARSE_FLAG_UNKNOWN: "PARSE_FLAG_UNKNOWN",
|
|
86
|
+
PARSE_FLAG_MISSING_VALUE: "PARSE_FLAG_MISSING_VALUE",
|
|
87
|
+
PARSE_FLAG_DUPLICATE: "PARSE_FLAG_DUPLICATE",
|
|
88
|
+
PARSE_FLAG_MALFORMED: "PARSE_FLAG_MALFORMED",
|
|
89
|
+
PARSE_PORT_INVALID: "PARSE_PORT_INVALID"
|
|
90
|
+
};
|
|
91
|
+
var MachinenError = class extends Error {
|
|
92
|
+
code;
|
|
93
|
+
retryable;
|
|
94
|
+
constructor(code, message, opts = {}) {
|
|
95
|
+
super(message, { cause: opts.cause });
|
|
96
|
+
this.code = code;
|
|
97
|
+
this.retryable = opts.retryable ?? false;
|
|
98
|
+
this.name = new.target.name;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
var BootError = class extends MachinenError {
|
|
102
|
+
};
|
|
103
|
+
var ExecError = class extends MachinenError {
|
|
104
|
+
};
|
|
105
|
+
var SnapshotError = class extends MachinenError {
|
|
106
|
+
};
|
|
107
|
+
var ProvisionError = class extends MachinenError {
|
|
108
|
+
};
|
|
109
|
+
var RegistryError = class extends MachinenError {
|
|
110
|
+
};
|
|
111
|
+
var FilesError = class extends MachinenError {
|
|
112
|
+
};
|
|
113
|
+
var MountError = class extends MachinenError {
|
|
114
|
+
};
|
|
115
|
+
var SecretsError = class extends MachinenError {
|
|
116
|
+
};
|
|
117
|
+
var WinsizeError = class extends MachinenError {
|
|
118
|
+
};
|
|
119
|
+
var SandboxError = class extends MachinenError {
|
|
120
|
+
};
|
|
121
|
+
var CacheError = class extends MachinenError {
|
|
122
|
+
};
|
|
123
|
+
var GvproxyError = class extends MachinenError {
|
|
124
|
+
};
|
|
125
|
+
var MkinitramfsError = class extends MachinenError {
|
|
126
|
+
};
|
|
127
|
+
var ParseError = class extends MachinenError {
|
|
128
|
+
};
|
|
129
|
+
function isMachinenError(err, code) {
|
|
130
|
+
return err instanceof MachinenError && (code === void 0 || err.code === code);
|
|
131
|
+
}
|
|
132
|
+
function formatMachinenError(err) {
|
|
133
|
+
const lines = [`(${err.code}): ${err.message}`];
|
|
134
|
+
let cur = err.cause;
|
|
135
|
+
while (cur !== void 0 && cur !== null) {
|
|
136
|
+
const msg = cur instanceof Error ? cur.message : String(cur);
|
|
137
|
+
lines.push(` caused by: ${msg}`);
|
|
138
|
+
cur = cur instanceof Error ? cur.cause : void 0;
|
|
139
|
+
}
|
|
140
|
+
return lines.join("\n");
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export {
|
|
144
|
+
ErrorCode,
|
|
145
|
+
MachinenError,
|
|
146
|
+
BootError,
|
|
147
|
+
ExecError,
|
|
148
|
+
SnapshotError,
|
|
149
|
+
ProvisionError,
|
|
150
|
+
RegistryError,
|
|
151
|
+
FilesError,
|
|
152
|
+
MountError,
|
|
153
|
+
SecretsError,
|
|
154
|
+
WinsizeError,
|
|
155
|
+
SandboxError,
|
|
156
|
+
CacheError,
|
|
157
|
+
GvproxyError,
|
|
158
|
+
MkinitramfsError,
|
|
159
|
+
ParseError,
|
|
160
|
+
isMachinenError,
|
|
161
|
+
formatMachinenError
|
|
162
|
+
};
|
|
163
|
+
//# sourceMappingURL=chunk-6SP6T537.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts"],"mappings":";AAsBO,IAAM,YAAY;AAAA;AAAA,EAEvB,kBAAkB;AAAA,EAClB,yBAAyB;AAAA,EACzB,sBAAsB;AAAA,EACtB,yBAAyB;AAAA,EACzB,uBAAuB;AAAA,EACvB,oBAAoB;AAAA,EACpB,wBAAwB;AAAA,EACxB,kBAAkB;AAAA,EAClB,kBAAkB;AAAA,EAClB,oBAAoB;AAAA,EACpB,2BAA2B;AAAA,EAC3B,kCAAkC;AAAA,EAClC,2BAA2B;AAAA,EAC3B,4BAA4B;AAAA,EAC5B,8BAA8B;AAAA,EAC9B,0BAA0B;AAAA,EAC1B,kBAAkB;AAAA,EAClB,cAAc;AAAA,EACd,gCAAgC;AAAA,EAChC,qBAAqB;AAAA,EACrB,0BAA0B;AAAA;AAAA,EAE1B,6BAA6B;AAAA;AAAA,EAG7B,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,EACxB,oBAAoB;AAAA,EACpB,mBAAmB;AAAA,EACnB,eAAe;AAAA;AAAA,EAGf,kBAAkB;AAAA,EAClB,sBAAsB;AAAA,EACtB,kBAAkB;AAAA;AAAA,EAGlB,0BAA0B;AAAA,EAC1B,4BAA4B;AAAA,EAC5B,yBAAyB;AAAA,EACzB,8BAA8B;AAAA,EAC9B,+BAA+B;AAAA,EAC/B,0BAA0B;AAAA;AA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