@rivet-dev/agentos-core 0.0.0-codex-agentos-native-platform-e2e.78ef941 → 0.0.0-codex-actor-plugin-contract-coverage.115ca8a

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 (101) hide show
  1. package/README.md +4 -7
  2. package/dist/agent-os.d.ts +150 -45
  3. package/dist/agent-os.js +769 -541
  4. package/dist/agentos-package.d.ts +29 -0
  5. package/dist/agentos-package.js +88 -0
  6. package/dist/base-filesystem.d.ts +2 -15
  7. package/dist/base-filesystem.js +23 -171
  8. package/dist/cron/types.d.ts +1 -1
  9. package/dist/default-software.d.ts +8 -0
  10. package/dist/default-software.js +10 -0
  11. package/dist/generated/AcpLimitsConfig.d.ts +4 -0
  12. package/dist/generated/AcpLimitsConfig.js +2 -0
  13. package/dist/generated/CreateVmConfig.d.ts +26 -0
  14. package/dist/generated/CreateVmConfig.js +1 -0
  15. package/dist/generated/FsPermissionRule.d.ts +6 -0
  16. package/dist/generated/FsPermissionRule.js +1 -0
  17. package/dist/generated/FsPermissionRuleSet.d.ts +6 -0
  18. package/dist/generated/FsPermissionRuleSet.js +1 -0
  19. package/dist/generated/FsPermissionScope.d.ts +3 -0
  20. package/dist/generated/FsPermissionScope.js +1 -0
  21. package/dist/generated/HttpLimitsConfig.d.ts +3 -0
  22. package/dist/generated/HttpLimitsConfig.js +2 -0
  23. package/dist/generated/JsModuleResolution.d.ts +1 -0
  24. package/dist/generated/JsModuleResolution.js +2 -0
  25. package/dist/generated/JsRuntimeConfig.d.ts +31 -0
  26. package/dist/generated/JsRuntimeConfig.js +1 -0
  27. package/dist/generated/JsRuntimeLimitsConfig.d.ts +11 -0
  28. package/dist/generated/JsRuntimeLimitsConfig.js +2 -0
  29. package/dist/generated/JsRuntimePlatform.d.ts +1 -0
  30. package/dist/generated/JsRuntimePlatform.js +2 -0
  31. package/dist/generated/MountPluginDescriptor.d.ts +4 -0
  32. package/dist/generated/MountPluginDescriptor.js +2 -0
  33. package/dist/generated/NativeRootFilesystemConfig.d.ts +5 -0
  34. package/dist/generated/NativeRootFilesystemConfig.js +1 -0
  35. package/dist/generated/PatternPermissionRule.d.ts +6 -0
  36. package/dist/generated/PatternPermissionRule.js +1 -0
  37. package/dist/generated/PatternPermissionRuleSet.d.ts +6 -0
  38. package/dist/generated/PatternPermissionRuleSet.js +1 -0
  39. package/dist/generated/PatternPermissionScope.d.ts +3 -0
  40. package/dist/generated/PatternPermissionScope.js +1 -0
  41. package/dist/generated/PermissionMode.d.ts +1 -0
  42. package/dist/generated/PermissionMode.js +2 -0
  43. package/dist/generated/PermissionsPolicy.d.ts +10 -0
  44. package/dist/generated/PermissionsPolicy.js +1 -0
  45. package/dist/generated/PluginLimitsConfig.d.ts +4 -0
  46. package/dist/generated/PluginLimitsConfig.js +2 -0
  47. package/dist/generated/PythonLimitsConfig.d.ts +6 -0
  48. package/dist/generated/PythonLimitsConfig.js +2 -0
  49. package/dist/generated/ResourceLimitsConfig.d.ts +24 -0
  50. package/dist/generated/ResourceLimitsConfig.js +2 -0
  51. package/dist/generated/RootFilesystemConfig.d.ts +9 -0
  52. package/dist/generated/RootFilesystemConfig.js +1 -0
  53. package/dist/generated/RootFilesystemEntry.d.ts +13 -0
  54. package/dist/generated/RootFilesystemEntry.js +1 -0
  55. package/dist/generated/RootFilesystemEntryEncoding.d.ts +1 -0
  56. package/dist/generated/RootFilesystemEntryEncoding.js +2 -0
  57. package/dist/generated/RootFilesystemEntryKind.d.ts +1 -0
  58. package/dist/generated/RootFilesystemEntryKind.js +2 -0
  59. package/dist/generated/RootFilesystemLowerDescriptor.d.ts +7 -0
  60. package/dist/generated/RootFilesystemLowerDescriptor.js +1 -0
  61. package/dist/generated/RootFilesystemMode.d.ts +1 -0
  62. package/dist/generated/RootFilesystemMode.js +2 -0
  63. package/dist/generated/ToolLimitsConfig.d.ts +10 -0
  64. package/dist/generated/ToolLimitsConfig.js +2 -0
  65. package/dist/generated/VmDnsConfig.d.ts +6 -0
  66. package/dist/generated/VmDnsConfig.js +2 -0
  67. package/dist/generated/VmLimitsConfig.d.ts +18 -0
  68. package/dist/generated/VmLimitsConfig.js +1 -0
  69. package/dist/generated/VmListenPolicyConfig.d.ts +5 -0
  70. package/dist/generated/VmListenPolicyConfig.js +2 -0
  71. package/dist/generated/WasmLimitsConfig.d.ts +7 -0
  72. package/dist/generated/WasmLimitsConfig.js +2 -0
  73. package/dist/host-dir-mount.d.ts +1 -1
  74. package/dist/host-tools-zod.js +27 -7
  75. package/dist/host-tools.js +9 -0
  76. package/dist/index.d.ts +3 -1
  77. package/dist/index.js +2 -1
  78. package/dist/layers.d.ts +2 -2
  79. package/dist/layers.js +19 -10
  80. package/dist/options-schema.d.ts +453 -0
  81. package/dist/options-schema.js +268 -0
  82. package/dist/packages.d.ts +17 -116
  83. package/dist/packages.js +35 -322
  84. package/dist/runtime-compat.d.ts +22 -9
  85. package/dist/runtime-compat.js +126 -141
  86. package/dist/runtime.d.ts +32 -5
  87. package/dist/sandbox.d.ts +112 -0
  88. package/dist/sandbox.js +264 -0
  89. package/dist/sidecar/agentos-protocol.d.ts +88 -1
  90. package/dist/sidecar/agentos-protocol.js +134 -18
  91. package/dist/sidecar/native-process-client.d.ts +6 -3
  92. package/dist/sidecar/native-process-client.js +5 -3
  93. package/dist/sidecar/permissions.d.ts +1 -1
  94. package/dist/sidecar/permissions.js +3 -3
  95. package/dist/sidecar/rpc-client.d.ts +62 -4
  96. package/dist/sidecar/rpc-client.js +339 -85
  97. package/dist/types.d.ts +10 -3
  98. package/package.json +40 -34
  99. package/dist/agents.d.ts +0 -63
  100. package/dist/agents.js +0 -42
  101. package/fixtures/AGENTOS_SYSTEM_PROMPT.md +0 -21
@@ -0,0 +1,9 @@
1
+ import type { RootFilesystemEntry } from "./RootFilesystemEntry.js";
2
+ import type { RootFilesystemLowerDescriptor } from "./RootFilesystemLowerDescriptor.js";
3
+ import type { RootFilesystemMode } from "./RootFilesystemMode.js";
4
+ export type RootFilesystemConfig = {
5
+ mode: RootFilesystemMode;
6
+ disableDefaultBaseLayer: boolean;
7
+ lowers: Array<RootFilesystemLowerDescriptor>;
8
+ bootstrapEntries: Array<RootFilesystemEntry>;
9
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ import type { RootFilesystemEntryEncoding } from "./RootFilesystemEntryEncoding.js";
2
+ import type { RootFilesystemEntryKind } from "./RootFilesystemEntryKind.js";
3
+ export type RootFilesystemEntry = {
4
+ path: string;
5
+ kind: RootFilesystemEntryKind;
6
+ mode?: number;
7
+ uid?: number;
8
+ gid?: number;
9
+ content?: string;
10
+ encoding?: RootFilesystemEntryEncoding;
11
+ target?: string;
12
+ executable: boolean;
13
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export type RootFilesystemEntryEncoding = "utf8" | "base64";
@@ -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 @@
1
+ export type RootFilesystemEntryKind = "file" | "directory" | "symlink";
@@ -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,7 @@
1
+ import type { RootFilesystemEntry } from "./RootFilesystemEntry.js";
2
+ export type RootFilesystemLowerDescriptor = {
3
+ "kind": "snapshot";
4
+ entries: Array<RootFilesystemEntry>;
5
+ } | {
6
+ "kind": "bundledBaseFilesystem";
7
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -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,10 @@
1
+ export type ToolLimitsConfig = {
2
+ defaultToolTimeoutMs?: number;
3
+ maxToolTimeoutMs?: number;
4
+ maxRegisteredToolkits?: number;
5
+ maxRegisteredToolsPerVm?: number;
6
+ maxToolsPerToolkit?: number;
7
+ maxToolSchemaBytes?: number;
8
+ maxToolExamplesPerTool?: number;
9
+ maxToolExampleInputBytes?: number;
10
+ };
@@ -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,18 @@
1
+ import type { AcpLimitsConfig } from "./AcpLimitsConfig.js";
2
+ import type { HttpLimitsConfig } from "./HttpLimitsConfig.js";
3
+ import type { JsRuntimeLimitsConfig } from "./JsRuntimeLimitsConfig.js";
4
+ import type { PluginLimitsConfig } from "./PluginLimitsConfig.js";
5
+ import type { PythonLimitsConfig } from "./PythonLimitsConfig.js";
6
+ import type { ResourceLimitsConfig } from "./ResourceLimitsConfig.js";
7
+ import type { ToolLimitsConfig } from "./ToolLimitsConfig.js";
8
+ import type { WasmLimitsConfig } from "./WasmLimitsConfig.js";
9
+ export type VmLimitsConfig = {
10
+ resources?: ResourceLimitsConfig;
11
+ http?: HttpLimitsConfig;
12
+ tools?: ToolLimitsConfig;
13
+ plugins?: PluginLimitsConfig;
14
+ acp?: AcpLimitsConfig;
15
+ jsRuntime?: JsRuntimeLimitsConfig;
16
+ python?: PythonLimitsConfig;
17
+ wasm?: WasmLimitsConfig;
18
+ };
@@ -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,7 @@
1
+ export type WasmLimitsConfig = {
2
+ maxModuleFileBytes?: number;
3
+ capturedOutputLimitBytes?: number;
4
+ syncReadLimitBytes?: number;
5
+ prewarmTimeoutMs?: number;
6
+ runnerHeapLimitMb?: number;
7
+ };
@@ -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;
@@ -1,3 +1,4 @@
1
+ import { zodToJsonSchema as zodV3ToJsonSchema } from "zod-to-json-schema";
1
2
  const OPTIONAL_WRAPPER_TYPES = new Set(["default", "optional"]);
2
3
  const TRANSPARENT_WRAPPER_TYPES = new Set([
3
4
  ...OPTIONAL_WRAPPER_TYPES,
@@ -30,6 +31,9 @@ export class HostToolSchemaConversionError extends Error {
30
31
  }
31
32
  }
32
33
  function getSchemaDef(schema) {
34
+ if (!schema || typeof schema !== "object") {
35
+ return {};
36
+ }
33
37
  return (schema._def ??
34
38
  schema.def ??
35
39
  {});
@@ -131,7 +135,8 @@ function validateSchema(schema, path) {
131
135
  return;
132
136
  }
133
137
  if (typeName === "array") {
134
- const itemSchema = getSchemaDef(schema).element;
138
+ const def = getSchemaDef(schema);
139
+ const itemSchema = (def.element ?? def.type);
135
140
  if (!itemSchema) {
136
141
  throw new HostToolSchemaConversionError(path, displayTypeName(typeName), "array schema is missing its item schema");
137
142
  }
@@ -163,8 +168,12 @@ function validateSchema(schema, path) {
163
168
  return;
164
169
  }
165
170
  if (typeName === "literal") {
166
- const values = getSchemaDef(schema).values;
167
- const literalValues = Array.isArray(values) ? values : [];
171
+ const def = getSchemaDef(schema);
172
+ const literalValues = Array.isArray(def.values)
173
+ ? def.values
174
+ : "value" in def
175
+ ? [def.value]
176
+ : [];
168
177
  const [literalValue] = literalValues;
169
178
  if (literalValues.length !== 1 ||
170
179
  !("string number boolean".split(" ").includes(typeof literalValue) || literalValue === null)) {
@@ -225,12 +234,23 @@ function findUnsupportedGeneratedKeyword(value, path) {
225
234
  }
226
235
  return null;
227
236
  }
237
+ function generateJsonSchema(schema) {
238
+ const nativeJsonSchema = schema.toJSONSchema?.();
239
+ if (nativeJsonSchema) {
240
+ return nativeJsonSchema;
241
+ }
242
+ const generated = zodV3ToJsonSchema(schema, {
243
+ $refStrategy: "none",
244
+ target: "jsonSchema7",
245
+ });
246
+ if (!generated || (typeof generated === "object" && Object.keys(generated).length === 0)) {
247
+ throw new HostToolSchemaConversionError("$", displayTypeName(normalizeTypeName(schema)), "schema cannot be converted to JSON Schema");
248
+ }
249
+ return generated;
250
+ }
228
251
  export function zodToJsonSchema(schema) {
229
252
  validateSchema(schema, "$");
230
- const jsonSchema = schema.toJSONSchema?.();
231
- if (!jsonSchema) {
232
- throw new HostToolSchemaConversionError("$", displayTypeName(normalizeTypeName(schema)), "schema does not expose toJSONSchema()");
233
- }
253
+ const jsonSchema = generateJsonSchema(schema);
234
254
  const unsupportedKeyword = findUnsupportedGeneratedKeyword(jsonSchema, "$");
235
255
  if (unsupportedKeyword) {
236
256
  throw new HostToolSchemaConversionError("$", displayTypeName(normalizeTypeName(schema)), `${unsupportedKeyword.keyword} emitted at ${unsupportedKeyword.path} is not supported`);
@@ -8,16 +8,25 @@ export function hostTool(def) {
8
8
  export function toolKit(def) {
9
9
  return def;
10
10
  }
11
+ const TOOLKIT_COMMAND_NAME_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
12
+ function validateToolCommandName(kind, name) {
13
+ if (TOOLKIT_COMMAND_NAME_RE.test(name)) {
14
+ return;
15
+ }
16
+ throw new Error(`${kind} name "${name}" must be lowercase alphanumeric with optional single hyphen separators`);
17
+ }
11
18
  /**
12
19
  * Validate all description lengths in the given toolkits.
13
20
  * Throws if any toolkit or tool description exceeds MAX_TOOL_DESCRIPTION_LENGTH.
14
21
  */
15
22
  export function validateToolkits(toolKits) {
16
23
  for (const tk of toolKits) {
24
+ validateToolCommandName("Toolkit", tk.name);
17
25
  if (tk.description.length > MAX_TOOL_DESCRIPTION_LENGTH) {
18
26
  throw new Error(`Toolkit "${tk.name}" description is ${tk.description.length} characters, max is ${MAX_TOOL_DESCRIPTION_LENGTH}`);
19
27
  }
20
28
  for (const [toolName, tool] of Object.entries(tk.tools)) {
29
+ validateToolCommandName("Tool", toolName);
21
30
  if (tool.description.length > MAX_TOOL_DESCRIPTION_LENGTH) {
22
31
  throw new Error(`Tool "${tk.name}/${toolName}" description is ${tool.description.length} characters, max is ${MAX_TOOL_DESCRIPTION_LENGTH}`);
23
32
  }
package/dist/index.d.ts CHANGED
@@ -1,10 +1,12 @@
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
4
  export { hostTool, MAX_TOOL_DESCRIPTION_LENGTH, toolKit, validateToolkits, } from "./host-tools.js";
5
+ export { agentOsLimitsSchema, agentOsOptionFieldSchemas, agentOsOptionsSchema, hostToolSchema, mountConfigSchema, nativeMountConfigSchema, parseAgentOsOptions, permissionsSchema, rootFilesystemConfigSchema, sharedSidecarConfigSchema, sidecarConfigSchema, toolKitSchema, } from "./options-schema.js";
6
6
  export { createInMemoryLayerStore, createSnapshotExport, } from "./layers.js";
7
7
  export { defineSoftware } from "./packages.js";
8
+ export { isPackageDescriptor, OPT_AGENTOS_BIN, OPT_AGENTOS_ROOT, tryReadAgentosPackageManifest, } from "./agentos-package.js";
8
9
  export { isAcpTimeoutErrorData, isUnknownSessionErrorData, } from "./json-rpc.js";
9
10
  export { createInMemoryFileSystem, KernelError } from "./runtime-compat.js";
11
+ export type { ExecOptions, ExecResult, ManagedProcess, ProcessInfo, ShellHandle, VirtualDirEntry, VirtualStat, } from "./runtime.js";
10
12
  export type * from "./types.js";
package/dist/index.js CHANGED
@@ -1,10 +1,11 @@
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
5
  export { hostTool, MAX_TOOL_DESCRIPTION_LENGTH, toolKit, validateToolkits, } from "./host-tools.js";
6
+ export { agentOsLimitsSchema, agentOsOptionFieldSchemas, agentOsOptionsSchema, hostToolSchema, mountConfigSchema, nativeMountConfigSchema, parseAgentOsOptions, permissionsSchema, rootFilesystemConfigSchema, sharedSidecarConfigSchema, sidecarConfigSchema, toolKitSchema, } from "./options-schema.js";
7
7
  export { createInMemoryLayerStore, createSnapshotExport, } from "./layers.js";
8
8
  export { defineSoftware } from "./packages.js";
9
+ export { isPackageDescriptor, OPT_AGENTOS_BIN, OPT_AGENTOS_ROOT, tryReadAgentosPackageManifest, } from "./agentos-package.js";
9
10
  export { isAcpTimeoutErrorData, isUnknownSessionErrorData, } from "./json-rpc.js";
10
11
  export { createInMemoryFileSystem, KernelError } from "./runtime-compat.js";
package/dist/layers.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type BaseFilesystemSnapshot } from "./base-filesystem.js";
1
+ import type { BaseFilesystemSnapshot } from "./base-filesystem.js";
2
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";
@@ -45,7 +45,7 @@ export interface LayerStore {
45
45
  mode: "read-only";
46
46
  lowers: SnapshotLayerHandle[];
47
47
  }): VirtualFileSystem;
48
+ dispose(): void;
48
49
  }
49
50
  export declare function createSnapshotExport(entries: FilesystemEntry[]): RootSnapshotExport;
50
51
  export declare function createInMemoryLayerStore(): LayerStore;
51
- export declare function createDefaultRootLowerInput(): SnapshotImportSource;
package/dist/layers.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import { randomUUID } from "node:crypto";
2
- import { getBaseFilesystemSnapshot, } from "./base-filesystem.js";
3
2
  import { createFilesystemFromEntries, snapshotVirtualFilesystem, } from "./filesystem-snapshot.js";
4
3
  import { createOverlayBackend } from "./overlay-filesystem.js";
5
4
  function cloneSnapshotHandle(storeId, layerId) {
@@ -73,8 +72,11 @@ export function createInMemoryLayerStore() {
73
72
  }
74
73
  return state;
75
74
  }
76
- return {
75
+ const store = {
77
76
  storeId,
77
+ get retainedLayerCount() {
78
+ return layers.size;
79
+ },
78
80
  async createWritableLayer() {
79
81
  const layerId = randomUUID();
80
82
  const leaseId = randomUUID();
@@ -117,10 +119,11 @@ export function createInMemoryLayerStore() {
117
119
  if (state.kind !== "writable") {
118
120
  throw new Error(`Layer ${layer.layerId} is not writable`);
119
121
  }
120
- if (!state.valid || state.leaseId !== layer.leaseId) {
122
+ const baseFs = state.activeOverlay ?? state.fs;
123
+ if (!state.valid || state.leaseId !== layer.leaseId || !baseFs) {
121
124
  throw new Error(`Writable layer ${layer.layerId} is no longer valid`);
122
125
  }
123
- const entries = await snapshotVirtualFilesystem(state.activeOverlay ?? state.fs);
126
+ const entries = await snapshotVirtualFilesystem(baseFs);
124
127
  const snapshot = createSnapshotExport(entries).source;
125
128
  const layerId = randomUUID();
126
129
  layers.set(layerId, {
@@ -128,8 +131,11 @@ export function createInMemoryLayerStore() {
128
131
  snapshot,
129
132
  fs: await createFilesystemFromEntries(snapshot.filesystem.entries),
130
133
  });
134
+ // Release the writable layer's filesystem payload now that it is sealed;
135
+ // the invalid tombstone is retained so stale handles still report cleanly.
131
136
  state.valid = false;
132
137
  state.activeOverlay = null;
138
+ state.fs = null;
133
139
  return cloneSnapshotHandle(storeId, layerId);
134
140
  },
135
141
  createOverlayFilesystem(options) {
@@ -162,6 +168,9 @@ export function createInMemoryLayerStore() {
162
168
  if (upperState.activeOverlay) {
163
169
  throw new Error(`Writable layer ${options.upper.layerId} is already attached to an overlay`);
164
170
  }
171
+ if (!upperState.fs) {
172
+ throw new Error(`Writable layer ${options.upper.layerId} is no longer valid`);
173
+ }
165
174
  const overlay = createOverlayBackend({
166
175
  upper: upperState.fs,
167
176
  lowers: lowers.map((lower) => {
@@ -175,11 +184,11 @@ export function createInMemoryLayerStore() {
175
184
  upperState.activeOverlay = overlay;
176
185
  return overlay;
177
186
  },
187
+ dispose() {
188
+ // Release every retained layer's filesystem payload so the store does
189
+ // not accumulate snapshots/writable layers for the process lifetime.
190
+ layers.clear();
191
+ },
178
192
  };
179
- }
180
- export function createDefaultRootLowerInput() {
181
- return {
182
- kind: "base-filesystem-artifact",
183
- source: getBaseFilesystemSnapshot(),
184
- };
193
+ return store;
185
194
  }