@rivet-dev/agentos-core 0.0.0-integrate-dylib-into-main.815fcda → 0.0.0-main.29b0797
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -43
- package/dist/agent-os.d.ts +313 -226
- package/dist/agent-os.js +1418 -1545
- package/dist/agentos-package.d.ts +31 -0
- package/dist/agentos-package.js +91 -0
- package/dist/base-filesystem.d.ts +2 -15
- package/dist/base-filesystem.js +23 -171
- package/dist/{host-tools-zod.d.ts → bindings-zod.d.ts} +1 -1
- package/dist/{host-tools-zod.js → bindings-zod.js} +52 -25
- package/dist/bindings.d.ts +43 -0
- package/dist/bindings.js +34 -0
- package/dist/cron/cron-manager.js +43 -10
- package/dist/cron/index.d.ts +1 -1
- package/dist/cron/types.d.ts +26 -10
- package/dist/default-software.d.ts +8 -0
- package/dist/default-software.js +10 -0
- package/dist/filesystem-snapshot.d.ts +1 -2
- package/dist/filesystem-snapshot.js +0 -43
- package/dist/generated/AcpLimitsConfig.d.ts +20 -0
- package/dist/generated/AcpLimitsConfig.js +2 -0
- package/dist/generated/BindingLimitsConfig.d.ts +10 -0
- package/dist/generated/BindingLimitsConfig.js +2 -0
- package/dist/generated/CreateVmConfig.d.ts +28 -0
- package/dist/generated/FsPermissionRule.d.ts +6 -0
- package/dist/generated/FsPermissionRule.js +1 -0
- package/dist/generated/FsPermissionRuleSet.d.ts +6 -0
- package/dist/generated/FsPermissionRuleSet.js +1 -0
- package/dist/generated/FsPermissionScope.d.ts +3 -0
- package/dist/generated/FsPermissionScope.js +1 -0
- package/dist/generated/HttpLimitsConfig.d.ts +3 -0
- package/dist/generated/HttpLimitsConfig.js +2 -0
- package/dist/generated/JsModuleResolution.d.ts +1 -0
- package/dist/generated/JsModuleResolution.js +2 -0
- package/dist/generated/JsRuntimeConfig.d.ts +31 -0
- package/dist/generated/JsRuntimeConfig.js +1 -0
- package/dist/generated/JsRuntimeLimitsConfig.d.ts +11 -0
- package/dist/generated/JsRuntimeLimitsConfig.js +2 -0
- package/dist/generated/JsRuntimePlatform.d.ts +1 -0
- package/dist/generated/JsRuntimePlatform.js +2 -0
- package/dist/generated/MountPluginDescriptor.d.ts +4 -0
- package/dist/generated/MountPluginDescriptor.js +2 -0
- package/dist/generated/NativeRootFilesystemConfig.d.ts +5 -0
- package/dist/generated/NativeRootFilesystemConfig.js +1 -0
- package/dist/generated/PatternPermissionRule.d.ts +6 -0
- package/dist/generated/PatternPermissionRule.js +1 -0
- package/dist/generated/PatternPermissionRuleSet.d.ts +6 -0
- package/dist/generated/PatternPermissionRuleSet.js +1 -0
- package/dist/generated/PatternPermissionScope.d.ts +3 -0
- package/dist/generated/PatternPermissionScope.js +1 -0
- package/dist/generated/PermissionMode.d.ts +1 -0
- package/dist/generated/PermissionMode.js +2 -0
- package/dist/generated/PermissionsPolicy.d.ts +10 -0
- package/dist/generated/PermissionsPolicy.js +1 -0
- package/dist/generated/PluginLimitsConfig.d.ts +4 -0
- package/dist/generated/PluginLimitsConfig.js +2 -0
- package/dist/generated/ProcessLimitsConfig.d.ts +7 -0
- package/dist/generated/ProcessLimitsConfig.js +2 -0
- package/dist/generated/PythonLimitsConfig.d.ts +6 -0
- package/dist/generated/PythonLimitsConfig.js +2 -0
- package/dist/generated/ResourceLimitsConfig.d.ts +24 -0
- package/dist/generated/ResourceLimitsConfig.js +2 -0
- package/dist/generated/RootFilesystemConfig.d.ts +9 -0
- package/dist/generated/RootFilesystemConfig.js +1 -0
- package/dist/generated/RootFilesystemEntry.d.ts +13 -0
- package/dist/generated/RootFilesystemEntry.js +1 -0
- package/dist/generated/RootFilesystemEntryEncoding.d.ts +1 -0
- package/dist/generated/RootFilesystemEntryEncoding.js +2 -0
- package/dist/generated/RootFilesystemEntryKind.d.ts +1 -0
- package/dist/generated/RootFilesystemEntryKind.js +2 -0
- package/dist/generated/RootFilesystemLowerDescriptor.d.ts +7 -0
- package/dist/generated/RootFilesystemLowerDescriptor.js +1 -0
- package/dist/generated/RootFilesystemMode.d.ts +1 -0
- package/dist/generated/RootFilesystemMode.js +2 -0
- package/dist/generated/VmDnsConfig.d.ts +6 -0
- package/dist/generated/VmDnsConfig.js +2 -0
- package/dist/generated/VmGroupConfig.d.ts +5 -0
- package/dist/generated/VmGroupConfig.js +2 -0
- package/dist/generated/VmLimitsConfig.d.ts +20 -0
- package/dist/generated/VmLimitsConfig.js +1 -0
- package/dist/generated/VmListenPolicyConfig.d.ts +5 -0
- package/dist/generated/VmListenPolicyConfig.js +2 -0
- package/dist/generated/VmUserAccountConfig.d.ts +9 -0
- package/dist/generated/VmUserAccountConfig.js +2 -0
- package/dist/generated/VmUserConfig.d.ts +19 -0
- package/dist/generated/VmUserConfig.js +1 -0
- package/dist/generated/WasmLimitsConfig.d.ts +8 -0
- package/dist/generated/WasmLimitsConfig.js +2 -0
- package/dist/host-dir-mount.d.ts +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.js +5 -5
- package/dist/layers.d.ts +7 -4
- package/dist/layers.js +0 -176
- package/dist/options-schema.d.ts +556 -0
- package/dist/options-schema.js +386 -0
- package/dist/packages.d.ts +17 -116
- package/dist/packages.js +35 -322
- package/dist/runtime-compat.d.ts +33 -46
- package/dist/runtime-compat.js +197 -511
- package/dist/runtime.d.ts +42 -8
- package/dist/sandbox.d.ts +112 -0
- package/dist/sandbox.js +264 -0
- package/dist/session-api.d.ts +180 -0
- package/dist/session-api.js +1 -0
- package/dist/sidecar/agentos-protocol.d.ts +509 -20
- package/dist/sidecar/agentos-protocol.js +808 -81
- package/dist/sidecar/native-process-client.d.ts +6 -2
- package/dist/sidecar/native-process-client.js +8 -1
- package/dist/sidecar/permissions.d.ts +1 -1
- package/dist/sidecar/permissions.js +4 -4
- package/dist/sidecar/rpc-client.d.ts +100 -9
- package/dist/sidecar/rpc-client.js +445 -110
- package/dist/test/runtime.d.ts +2 -1
- package/dist/test/runtime.js +2 -1
- package/dist/test/terminal-harness.js +0 -3
- package/dist/types.d.ts +13 -7
- package/package.json +46 -35
- package/dist/agent-session-types.d.ts +0 -67
- package/dist/agents.d.ts +0 -63
- package/dist/agents.js +0 -42
- package/dist/host-tools.d.ts +0 -45
- package/dist/host-tools.js +0 -26
- package/dist/overlay-filesystem.d.ts +0 -19
- package/dist/overlay-filesystem.js +0 -645
- package/fixtures/AGENTOS_SYSTEM_PROMPT.md +0 -21
- /package/dist/{agent-session-types.js → generated/CreateVmConfig.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type RootFilesystemMode = "ephemeral" | "read-only";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AcpLimitsConfig } from "./AcpLimitsConfig.js";
|
|
2
|
+
import type { BindingLimitsConfig } from "./BindingLimitsConfig.js";
|
|
3
|
+
import type { HttpLimitsConfig } from "./HttpLimitsConfig.js";
|
|
4
|
+
import type { JsRuntimeLimitsConfig } from "./JsRuntimeLimitsConfig.js";
|
|
5
|
+
import type { PluginLimitsConfig } from "./PluginLimitsConfig.js";
|
|
6
|
+
import type { ProcessLimitsConfig } from "./ProcessLimitsConfig.js";
|
|
7
|
+
import type { PythonLimitsConfig } from "./PythonLimitsConfig.js";
|
|
8
|
+
import type { ResourceLimitsConfig } from "./ResourceLimitsConfig.js";
|
|
9
|
+
import type { WasmLimitsConfig } from "./WasmLimitsConfig.js";
|
|
10
|
+
export type VmLimitsConfig = {
|
|
11
|
+
resources?: ResourceLimitsConfig;
|
|
12
|
+
http?: HttpLimitsConfig;
|
|
13
|
+
bindings?: BindingLimitsConfig;
|
|
14
|
+
plugins?: PluginLimitsConfig;
|
|
15
|
+
acp?: AcpLimitsConfig;
|
|
16
|
+
jsRuntime?: JsRuntimeLimitsConfig;
|
|
17
|
+
python?: PythonLimitsConfig;
|
|
18
|
+
wasm?: WasmLimitsConfig;
|
|
19
|
+
process?: ProcessLimitsConfig;
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { VmGroupConfig } from "./VmGroupConfig.js";
|
|
2
|
+
import type { VmUserAccountConfig } from "./VmUserAccountConfig.js";
|
|
3
|
+
/**
|
|
4
|
+
* Initial Linux-style credentials and account record for processes in a VM.
|
|
5
|
+
*/
|
|
6
|
+
export type VmUserConfig = {
|
|
7
|
+
uid?: number;
|
|
8
|
+
gid?: number;
|
|
9
|
+
euid?: number;
|
|
10
|
+
egid?: number;
|
|
11
|
+
username?: string;
|
|
12
|
+
homedir?: string;
|
|
13
|
+
shell?: string;
|
|
14
|
+
gecos?: string;
|
|
15
|
+
groupName?: string;
|
|
16
|
+
supplementaryGids?: Array<number>;
|
|
17
|
+
accounts?: Array<VmUserAccountConfig>;
|
|
18
|
+
groups?: Array<VmGroupConfig>;
|
|
19
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/host-dir-mount.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MountConfigJsonObject, NativeMountPluginDescriptor } from "@
|
|
1
|
+
import type { MountConfigJsonObject, NativeMountPluginDescriptor } from "@rivet-dev/agentos-runtime-core/descriptors";
|
|
2
2
|
export interface HostDirBackendOptions {
|
|
3
3
|
/** Absolute path to the host directory to project into the VM. */
|
|
4
4
|
hostPath: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export { AgentOs, AgentOsSidecar } from "./agent-os.js";
|
|
2
|
-
export { AGENT_CONFIGS } from "./agents.js";
|
|
3
2
|
export { CronManager, InvalidScheduleError, PastScheduleError, TimerScheduleDriver, } from "./cron/index.js";
|
|
4
3
|
export { createHostDirBackend, nodeModulesMount } from "./host-dir-mount.js";
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
4
|
+
export { binding, MAX_BINDING_DESCRIPTION_LENGTH, bindings, validateBindings, } from "./bindings.js";
|
|
5
|
+
export { agentOsLimitsSchema, agentOsOptionFieldSchemas, agentOsOptionsSchema, bindingSchema, mountConfigSchema, nativeMountConfigSchema, parseAgentOsOptions, permissionsSchema, rootFilesystemConfigSchema, sharedSidecarConfigSchema, sidecarConfigSchema, bindingsSchema, } from "./options-schema.js";
|
|
6
|
+
export { createSnapshotExport, } from "./layers.js";
|
|
7
7
|
export { defineSoftware } from "./packages.js";
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
8
|
+
export { isPackageDescriptor, OPT_AGENTOS_BIN, OPT_AGENTOS_ROOT, tryReadAgentosPackageManifest, } from "./agentos-package.js";
|
|
9
|
+
export { KernelError } from "./runtime-compat.js";
|
|
10
|
+
export type { ExecOptions, ExecResult, ManagedProcess, ProcessInfo, ShellHandle, VirtualDirEntry, VirtualStat, } from "./runtime.js";
|
|
10
11
|
export type * from "./types.js";
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// @rivet-dev/agentos
|
|
2
2
|
export { AgentOs, AgentOsSidecar } from "./agent-os.js";
|
|
3
|
-
export { AGENT_CONFIGS } from "./agents.js";
|
|
4
3
|
export { CronManager, InvalidScheduleError, PastScheduleError, TimerScheduleDriver, } from "./cron/index.js";
|
|
5
4
|
export { createHostDirBackend, nodeModulesMount } from "./host-dir-mount.js";
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
5
|
+
export { binding, MAX_BINDING_DESCRIPTION_LENGTH, bindings, validateBindings, } from "./bindings.js";
|
|
6
|
+
export { agentOsLimitsSchema, agentOsOptionFieldSchemas, agentOsOptionsSchema, bindingSchema, mountConfigSchema, nativeMountConfigSchema, parseAgentOsOptions, permissionsSchema, rootFilesystemConfigSchema, sharedSidecarConfigSchema, sidecarConfigSchema, bindingsSchema, } from "./options-schema.js";
|
|
7
|
+
export { createSnapshotExport, } from "./layers.js";
|
|
8
8
|
export { defineSoftware } from "./packages.js";
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
9
|
+
export { isPackageDescriptor, OPT_AGENTOS_BIN, OPT_AGENTOS_ROOT, tryReadAgentosPackageManifest, } from "./agentos-package.js";
|
|
10
|
+
export { KernelError } from "./runtime-compat.js";
|
package/dist/layers.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { BaseFilesystemSnapshot } from "./base-filesystem.js";
|
|
2
|
+
import type { FilesystemEntry } from "./filesystem-snapshot.js";
|
|
3
3
|
import type { VirtualFileSystem } from "./runtime-compat.js";
|
|
4
4
|
export type OverlayFilesystemMode = "ephemeral" | "read-only";
|
|
5
5
|
export interface FilesystemSnapshotExport {
|
|
@@ -31,6 +31,10 @@ export type SnapshotImportSource = {
|
|
|
31
31
|
kind: "snapshot-export";
|
|
32
32
|
source: FilesystemSnapshotExport | unknown;
|
|
33
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* Caller-provided durable layer store. AgentOS forwards these explicit handles
|
|
36
|
+
* but does not provide a second client-side filesystem or overlay engine.
|
|
37
|
+
*/
|
|
34
38
|
export interface LayerStore {
|
|
35
39
|
readonly storeId: string;
|
|
36
40
|
createWritableLayer(): Promise<WritableLayerHandle>;
|
|
@@ -45,7 +49,6 @@ export interface LayerStore {
|
|
|
45
49
|
mode: "read-only";
|
|
46
50
|
lowers: SnapshotLayerHandle[];
|
|
47
51
|
}): VirtualFileSystem;
|
|
52
|
+
dispose(): void;
|
|
48
53
|
}
|
|
49
54
|
export declare function createSnapshotExport(entries: FilesystemEntry[]): RootSnapshotExport;
|
|
50
|
-
export declare function createInMemoryLayerStore(): LayerStore;
|
|
51
|
-
export declare function createDefaultRootLowerInput(): SnapshotImportSource;
|
package/dist/layers.js
CHANGED
|
@@ -1,53 +1,3 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { getBaseFilesystemSnapshot, } from "./base-filesystem.js";
|
|
3
|
-
import { createFilesystemFromEntries, snapshotVirtualFilesystem, } from "./filesystem-snapshot.js";
|
|
4
|
-
import { createOverlayBackend } from "./overlay-filesystem.js";
|
|
5
|
-
function cloneSnapshotHandle(storeId, layerId) {
|
|
6
|
-
return { kind: "snapshot", storeId, layerId };
|
|
7
|
-
}
|
|
8
|
-
function cloneWritableHandle(storeId, layerId, leaseId) {
|
|
9
|
-
return { kind: "writable", storeId, layerId, leaseId };
|
|
10
|
-
}
|
|
11
|
-
function isBaseFilesystemSnapshot(value) {
|
|
12
|
-
if (!value || typeof value !== "object") {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
const filesystem = value.filesystem;
|
|
16
|
-
if (!filesystem || typeof filesystem !== "object") {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
return Array.isArray(filesystem.entries);
|
|
20
|
-
}
|
|
21
|
-
function isFilesystemSnapshotExport(value) {
|
|
22
|
-
if (!value || typeof value !== "object") {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
if (value.format !== "agentos-filesystem-snapshot-v1") {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
const filesystem = value.filesystem;
|
|
29
|
-
if (!filesystem || typeof filesystem !== "object") {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
return Array.isArray(filesystem.entries);
|
|
33
|
-
}
|
|
34
|
-
function normalizeSnapshotExport(source) {
|
|
35
|
-
if (source.kind === "base-filesystem-artifact") {
|
|
36
|
-
if (!isBaseFilesystemSnapshot(source.source)) {
|
|
37
|
-
throw new Error("Invalid base filesystem artifact");
|
|
38
|
-
}
|
|
39
|
-
return {
|
|
40
|
-
format: "agentos-filesystem-snapshot-v1",
|
|
41
|
-
filesystem: {
|
|
42
|
-
entries: source.source.filesystem.entries,
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
if (!isFilesystemSnapshotExport(source.source)) {
|
|
47
|
-
throw new Error("Invalid snapshot export");
|
|
48
|
-
}
|
|
49
|
-
return source.source;
|
|
50
|
-
}
|
|
51
1
|
export function createSnapshotExport(entries) {
|
|
52
2
|
return {
|
|
53
3
|
kind: "snapshot-export",
|
|
@@ -57,129 +7,3 @@ export function createSnapshotExport(entries) {
|
|
|
57
7
|
},
|
|
58
8
|
};
|
|
59
9
|
}
|
|
60
|
-
export function createInMemoryLayerStore() {
|
|
61
|
-
const storeId = `memory-layer-store:${randomUUID()}`;
|
|
62
|
-
const layers = new Map();
|
|
63
|
-
function getLayerState(handle) {
|
|
64
|
-
if (handle.storeId !== storeId) {
|
|
65
|
-
throw new Error(`Layer ${handle.layerId} belongs to store ${handle.storeId}, not ${storeId}`);
|
|
66
|
-
}
|
|
67
|
-
const state = layers.get(handle.layerId);
|
|
68
|
-
if (!state) {
|
|
69
|
-
throw new Error(`Unknown layer: ${handle.layerId}`);
|
|
70
|
-
}
|
|
71
|
-
if (state.kind !== handle.kind) {
|
|
72
|
-
throw new Error(`Layer kind mismatch for ${handle.layerId}`);
|
|
73
|
-
}
|
|
74
|
-
return state;
|
|
75
|
-
}
|
|
76
|
-
return {
|
|
77
|
-
storeId,
|
|
78
|
-
async createWritableLayer() {
|
|
79
|
-
const layerId = randomUUID();
|
|
80
|
-
const leaseId = randomUUID();
|
|
81
|
-
layers.set(layerId, {
|
|
82
|
-
kind: "writable",
|
|
83
|
-
fs: await createFilesystemFromEntries([
|
|
84
|
-
{
|
|
85
|
-
path: "/",
|
|
86
|
-
type: "directory",
|
|
87
|
-
mode: "0755",
|
|
88
|
-
uid: 0,
|
|
89
|
-
gid: 0,
|
|
90
|
-
},
|
|
91
|
-
]),
|
|
92
|
-
leaseId,
|
|
93
|
-
valid: true,
|
|
94
|
-
activeOverlay: null,
|
|
95
|
-
});
|
|
96
|
-
return cloneWritableHandle(storeId, layerId, leaseId);
|
|
97
|
-
},
|
|
98
|
-
async importSnapshot(source) {
|
|
99
|
-
const snapshot = normalizeSnapshotExport(source);
|
|
100
|
-
const layerId = randomUUID();
|
|
101
|
-
layers.set(layerId, {
|
|
102
|
-
kind: "snapshot",
|
|
103
|
-
snapshot,
|
|
104
|
-
fs: await createFilesystemFromEntries(snapshot.filesystem.entries),
|
|
105
|
-
});
|
|
106
|
-
return cloneSnapshotHandle(storeId, layerId);
|
|
107
|
-
},
|
|
108
|
-
async openSnapshotLayer(layerId) {
|
|
109
|
-
const state = layers.get(layerId);
|
|
110
|
-
if (!state || state.kind !== "snapshot") {
|
|
111
|
-
throw new Error(`Unknown snapshot layer: ${layerId}`);
|
|
112
|
-
}
|
|
113
|
-
return cloneSnapshotHandle(storeId, layerId);
|
|
114
|
-
},
|
|
115
|
-
async sealLayer(layer) {
|
|
116
|
-
const state = getLayerState(layer);
|
|
117
|
-
if (state.kind !== "writable") {
|
|
118
|
-
throw new Error(`Layer ${layer.layerId} is not writable`);
|
|
119
|
-
}
|
|
120
|
-
if (!state.valid || state.leaseId !== layer.leaseId) {
|
|
121
|
-
throw new Error(`Writable layer ${layer.layerId} is no longer valid`);
|
|
122
|
-
}
|
|
123
|
-
const entries = await snapshotVirtualFilesystem(state.activeOverlay ?? state.fs);
|
|
124
|
-
const snapshot = createSnapshotExport(entries).source;
|
|
125
|
-
const layerId = randomUUID();
|
|
126
|
-
layers.set(layerId, {
|
|
127
|
-
kind: "snapshot",
|
|
128
|
-
snapshot,
|
|
129
|
-
fs: await createFilesystemFromEntries(snapshot.filesystem.entries),
|
|
130
|
-
});
|
|
131
|
-
state.valid = false;
|
|
132
|
-
state.activeOverlay = null;
|
|
133
|
-
return cloneSnapshotHandle(storeId, layerId);
|
|
134
|
-
},
|
|
135
|
-
createOverlayFilesystem(options) {
|
|
136
|
-
const lowers = options.lowers.map((lower) => {
|
|
137
|
-
const state = getLayerState(lower);
|
|
138
|
-
if (state.kind !== "snapshot") {
|
|
139
|
-
throw new Error(`Layer ${lower.layerId} is not a snapshot`);
|
|
140
|
-
}
|
|
141
|
-
return lower;
|
|
142
|
-
});
|
|
143
|
-
if (options.mode === "read-only") {
|
|
144
|
-
return createOverlayBackend({
|
|
145
|
-
mode: "read-only",
|
|
146
|
-
lowers: lowers.map((lower) => {
|
|
147
|
-
const state = getLayerState(lower);
|
|
148
|
-
if (state.kind !== "snapshot") {
|
|
149
|
-
throw new Error(`Layer ${lower.layerId} is not a snapshot`);
|
|
150
|
-
}
|
|
151
|
-
return state.fs;
|
|
152
|
-
}),
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
const upperState = getLayerState(options.upper);
|
|
156
|
-
if (upperState.kind !== "writable") {
|
|
157
|
-
throw new Error(`Layer ${options.upper.layerId} is not writable`);
|
|
158
|
-
}
|
|
159
|
-
if (!upperState.valid || upperState.leaseId !== options.upper.leaseId) {
|
|
160
|
-
throw new Error(`Writable layer ${options.upper.layerId} is no longer valid`);
|
|
161
|
-
}
|
|
162
|
-
if (upperState.activeOverlay) {
|
|
163
|
-
throw new Error(`Writable layer ${options.upper.layerId} is already attached to an overlay`);
|
|
164
|
-
}
|
|
165
|
-
const overlay = createOverlayBackend({
|
|
166
|
-
upper: upperState.fs,
|
|
167
|
-
lowers: lowers.map((lower) => {
|
|
168
|
-
const state = getLayerState(lower);
|
|
169
|
-
if (state.kind !== "snapshot") {
|
|
170
|
-
throw new Error(`Layer ${lower.layerId} is not a snapshot`);
|
|
171
|
-
}
|
|
172
|
-
return state.fs;
|
|
173
|
-
}),
|
|
174
|
-
});
|
|
175
|
-
upperState.activeOverlay = overlay;
|
|
176
|
-
return overlay;
|
|
177
|
-
},
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
export function createDefaultRootLowerInput() {
|
|
181
|
-
return {
|
|
182
|
-
kind: "base-filesystem-artifact",
|
|
183
|
-
source: getBaseFilesystemSnapshot(),
|
|
184
|
-
};
|
|
185
|
-
}
|