@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.
Files changed (125) hide show
  1. package/README.md +43 -43
  2. package/dist/agent-os.d.ts +313 -226
  3. package/dist/agent-os.js +1418 -1545
  4. package/dist/agentos-package.d.ts +31 -0
  5. package/dist/agentos-package.js +91 -0
  6. package/dist/base-filesystem.d.ts +2 -15
  7. package/dist/base-filesystem.js +23 -171
  8. package/dist/{host-tools-zod.d.ts → bindings-zod.d.ts} +1 -1
  9. package/dist/{host-tools-zod.js → bindings-zod.js} +52 -25
  10. package/dist/bindings.d.ts +43 -0
  11. package/dist/bindings.js +34 -0
  12. package/dist/cron/cron-manager.js +43 -10
  13. package/dist/cron/index.d.ts +1 -1
  14. package/dist/cron/types.d.ts +26 -10
  15. package/dist/default-software.d.ts +8 -0
  16. package/dist/default-software.js +10 -0
  17. package/dist/filesystem-snapshot.d.ts +1 -2
  18. package/dist/filesystem-snapshot.js +0 -43
  19. package/dist/generated/AcpLimitsConfig.d.ts +20 -0
  20. package/dist/generated/AcpLimitsConfig.js +2 -0
  21. package/dist/generated/BindingLimitsConfig.d.ts +10 -0
  22. package/dist/generated/BindingLimitsConfig.js +2 -0
  23. package/dist/generated/CreateVmConfig.d.ts +28 -0
  24. package/dist/generated/FsPermissionRule.d.ts +6 -0
  25. package/dist/generated/FsPermissionRule.js +1 -0
  26. package/dist/generated/FsPermissionRuleSet.d.ts +6 -0
  27. package/dist/generated/FsPermissionRuleSet.js +1 -0
  28. package/dist/generated/FsPermissionScope.d.ts +3 -0
  29. package/dist/generated/FsPermissionScope.js +1 -0
  30. package/dist/generated/HttpLimitsConfig.d.ts +3 -0
  31. package/dist/generated/HttpLimitsConfig.js +2 -0
  32. package/dist/generated/JsModuleResolution.d.ts +1 -0
  33. package/dist/generated/JsModuleResolution.js +2 -0
  34. package/dist/generated/JsRuntimeConfig.d.ts +31 -0
  35. package/dist/generated/JsRuntimeConfig.js +1 -0
  36. package/dist/generated/JsRuntimeLimitsConfig.d.ts +11 -0
  37. package/dist/generated/JsRuntimeLimitsConfig.js +2 -0
  38. package/dist/generated/JsRuntimePlatform.d.ts +1 -0
  39. package/dist/generated/JsRuntimePlatform.js +2 -0
  40. package/dist/generated/MountPluginDescriptor.d.ts +4 -0
  41. package/dist/generated/MountPluginDescriptor.js +2 -0
  42. package/dist/generated/NativeRootFilesystemConfig.d.ts +5 -0
  43. package/dist/generated/NativeRootFilesystemConfig.js +1 -0
  44. package/dist/generated/PatternPermissionRule.d.ts +6 -0
  45. package/dist/generated/PatternPermissionRule.js +1 -0
  46. package/dist/generated/PatternPermissionRuleSet.d.ts +6 -0
  47. package/dist/generated/PatternPermissionRuleSet.js +1 -0
  48. package/dist/generated/PatternPermissionScope.d.ts +3 -0
  49. package/dist/generated/PatternPermissionScope.js +1 -0
  50. package/dist/generated/PermissionMode.d.ts +1 -0
  51. package/dist/generated/PermissionMode.js +2 -0
  52. package/dist/generated/PermissionsPolicy.d.ts +10 -0
  53. package/dist/generated/PermissionsPolicy.js +1 -0
  54. package/dist/generated/PluginLimitsConfig.d.ts +4 -0
  55. package/dist/generated/PluginLimitsConfig.js +2 -0
  56. package/dist/generated/ProcessLimitsConfig.d.ts +7 -0
  57. package/dist/generated/ProcessLimitsConfig.js +2 -0
  58. package/dist/generated/PythonLimitsConfig.d.ts +6 -0
  59. package/dist/generated/PythonLimitsConfig.js +2 -0
  60. package/dist/generated/ResourceLimitsConfig.d.ts +24 -0
  61. package/dist/generated/ResourceLimitsConfig.js +2 -0
  62. package/dist/generated/RootFilesystemConfig.d.ts +9 -0
  63. package/dist/generated/RootFilesystemConfig.js +1 -0
  64. package/dist/generated/RootFilesystemEntry.d.ts +13 -0
  65. package/dist/generated/RootFilesystemEntry.js +1 -0
  66. package/dist/generated/RootFilesystemEntryEncoding.d.ts +1 -0
  67. package/dist/generated/RootFilesystemEntryEncoding.js +2 -0
  68. package/dist/generated/RootFilesystemEntryKind.d.ts +1 -0
  69. package/dist/generated/RootFilesystemEntryKind.js +2 -0
  70. package/dist/generated/RootFilesystemLowerDescriptor.d.ts +7 -0
  71. package/dist/generated/RootFilesystemLowerDescriptor.js +1 -0
  72. package/dist/generated/RootFilesystemMode.d.ts +1 -0
  73. package/dist/generated/RootFilesystemMode.js +2 -0
  74. package/dist/generated/VmDnsConfig.d.ts +6 -0
  75. package/dist/generated/VmDnsConfig.js +2 -0
  76. package/dist/generated/VmGroupConfig.d.ts +5 -0
  77. package/dist/generated/VmGroupConfig.js +2 -0
  78. package/dist/generated/VmLimitsConfig.d.ts +20 -0
  79. package/dist/generated/VmLimitsConfig.js +1 -0
  80. package/dist/generated/VmListenPolicyConfig.d.ts +5 -0
  81. package/dist/generated/VmListenPolicyConfig.js +2 -0
  82. package/dist/generated/VmUserAccountConfig.d.ts +9 -0
  83. package/dist/generated/VmUserAccountConfig.js +2 -0
  84. package/dist/generated/VmUserConfig.d.ts +19 -0
  85. package/dist/generated/VmUserConfig.js +1 -0
  86. package/dist/generated/WasmLimitsConfig.d.ts +8 -0
  87. package/dist/generated/WasmLimitsConfig.js +2 -0
  88. package/dist/host-dir-mount.d.ts +1 -1
  89. package/dist/index.d.ts +6 -5
  90. package/dist/index.js +5 -5
  91. package/dist/layers.d.ts +7 -4
  92. package/dist/layers.js +0 -176
  93. package/dist/options-schema.d.ts +556 -0
  94. package/dist/options-schema.js +386 -0
  95. package/dist/packages.d.ts +17 -116
  96. package/dist/packages.js +35 -322
  97. package/dist/runtime-compat.d.ts +33 -46
  98. package/dist/runtime-compat.js +197 -511
  99. package/dist/runtime.d.ts +42 -8
  100. package/dist/sandbox.d.ts +112 -0
  101. package/dist/sandbox.js +264 -0
  102. package/dist/session-api.d.ts +180 -0
  103. package/dist/session-api.js +1 -0
  104. package/dist/sidecar/agentos-protocol.d.ts +509 -20
  105. package/dist/sidecar/agentos-protocol.js +808 -81
  106. package/dist/sidecar/native-process-client.d.ts +6 -2
  107. package/dist/sidecar/native-process-client.js +8 -1
  108. package/dist/sidecar/permissions.d.ts +1 -1
  109. package/dist/sidecar/permissions.js +4 -4
  110. package/dist/sidecar/rpc-client.d.ts +100 -9
  111. package/dist/sidecar/rpc-client.js +445 -110
  112. package/dist/test/runtime.d.ts +2 -1
  113. package/dist/test/runtime.js +2 -1
  114. package/dist/test/terminal-harness.js +0 -3
  115. package/dist/types.d.ts +13 -7
  116. package/package.json +46 -35
  117. package/dist/agent-session-types.d.ts +0 -67
  118. package/dist/agents.d.ts +0 -63
  119. package/dist/agents.js +0 -42
  120. package/dist/host-tools.d.ts +0 -45
  121. package/dist/host-tools.js +0 -26
  122. package/dist/overlay-filesystem.d.ts +0 -19
  123. package/dist/overlay-filesystem.js +0 -645
  124. package/fixtures/AGENTOS_SYSTEM_PROMPT.md +0 -21
  125. /package/dist/{agent-session-types.js → generated/CreateVmConfig.js} +0 -0
@@ -0,0 +1 @@
1
+ export type RootFilesystemMode = "ephemeral" | "read-only";
@@ -0,0 +1,2 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ export {};
@@ -0,0 +1,6 @@
1
+ export type VmDnsConfig = {
2
+ nameServers: Array<string>;
3
+ overrides: {
4
+ [key in string]?: Array<string>;
5
+ };
6
+ };
@@ -0,0 +1,2 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ export {};
@@ -0,0 +1,5 @@
1
+ export type VmGroupConfig = {
2
+ gid: number;
3
+ name: string;
4
+ members: Array<string>;
5
+ };
@@ -0,0 +1,2 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ export {};
@@ -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,5 @@
1
+ export type VmListenPolicyConfig = {
2
+ portMin?: number;
3
+ portMax?: number;
4
+ allowPrivileged?: boolean;
5
+ };
@@ -0,0 +1,2 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ export {};
@@ -0,0 +1,9 @@
1
+ export type VmUserAccountConfig = {
2
+ uid: number;
3
+ gid: number;
4
+ username: string;
5
+ homedir: string;
6
+ shell: string;
7
+ gecos?: string;
8
+ supplementaryGids: Array<number>;
9
+ };
@@ -0,0 +1,2 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ 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 {};
@@ -0,0 +1,8 @@
1
+ export type WasmLimitsConfig = {
2
+ maxModuleFileBytes?: number;
3
+ capturedOutputLimitBytes?: number;
4
+ syncReadLimitBytes?: number;
5
+ prewarmTimeoutMs?: number;
6
+ runnerHeapLimitMb?: number;
7
+ runnerCpuTimeLimitMs?: number;
8
+ };
@@ -0,0 +1,2 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ export {};
@@ -1,4 +1,4 @@
1
- import type { MountConfigJsonObject, NativeMountPluginDescriptor } from "@secure-exec/core/descriptors";
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 { hostTool, MAX_TOOL_DESCRIPTION_LENGTH, toolKit, validateToolkits, } from "./host-tools.js";
6
- export { createInMemoryLayerStore, createSnapshotExport, } from "./layers.js";
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 { isAcpTimeoutErrorData, isUnknownSessionErrorData, } from "./json-rpc.js";
9
- export { createInMemoryFileSystem, KernelError } from "./runtime-compat.js";
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 { hostTool, MAX_TOOL_DESCRIPTION_LENGTH, toolKit, validateToolkits, } from "./host-tools.js";
7
- export { createInMemoryLayerStore, createSnapshotExport, } from "./layers.js";
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 { isAcpTimeoutErrorData, isUnknownSessionErrorData, } from "./json-rpc.js";
10
- export { createInMemoryFileSystem, KernelError } from "./runtime-compat.js";
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 { type BaseFilesystemSnapshot } from "./base-filesystem.js";
2
- import { type FilesystemEntry } from "./filesystem-snapshot.js";
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
- }