@codeworksh/plugin 0.1.0-canary.20.1.gf5454e1e → 0.1.0-canary.22.1.g06862c3f

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/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
1
  import { t as section_d_exports } from "./plugin/section.mjs";
2
2
  import { g as tool_d_exports } from "./tool-DuYBgiJf.mjs";
3
- import { t as plugin_d_exports } from "./plugin-C5HDBWGL.mjs";
3
+ import { t as plugin_d_exports } from "./plugin-Bb1gRtNX.mjs";
4
4
  export { plugin_d_exports as Plugin, section_d_exports as Section, tool_d_exports as Tool };
@@ -277,6 +277,8 @@ declare const AbsolutePath: Schema.brand<Schema.String, "SandboxDriver.AbsoluteP
277
277
  type AbsolutePath = typeof AbsolutePath.Type;
278
278
  declare const RuntimeConfigBase: Schema.Struct<{
279
279
  readonly defaultCwd: Schema.brand<Schema.String, "SandboxDriver.AbsolutePath">;
280
+ /** Where oversized tool output is written inside the sandbox; `SandboxIO.DEFAULT_SPILL_PATH` when absent. */
281
+ readonly spillPath: Schema.optional<Schema.brand<Schema.String, "SandboxDriver.AbsolutePath">>;
280
282
  }>;
281
283
  interface RuntimeConfigBase extends Schema.Schema.Type<typeof RuntimeConfigBase> {}
282
284
  interface Capabilities {
@@ -396,7 +398,7 @@ declare const Service_base: Context.ServiceClass<Service, "@codeworksh/plugin/sa
396
398
  declare class Service extends Service_base {}
397
399
  declare const make: (instance: ID, cwd: string, fs: Interface$1) => Interface;
398
400
  declare namespace io_d_exports {
399
- export { Current, FileSystem, Identity, Layer$1 as Layer, Mutation, Provides, io_d_exports as SandboxIO, Shell, host, hostLayer, identityLayer, mount, remote, resolveMountCwd, virtual, withMutation };
401
+ export { Current, DEFAULT_SPILL_PATH, FileSystem, Identity, Layer$1 as Layer, Mutation, Provides, io_d_exports as SandboxIO, Shell, host, hostLayer, identityLayer, mount, remote, resolveMountCwd, virtual, withMutation };
400
402
  }
401
403
  /**
402
404
  * `SandboxIO` is a **mount**: a filesystem, a shell, and the identity and
@@ -443,7 +445,11 @@ interface Identity {
443
445
  readonly kind: Kind;
444
446
  /** Absolute, and always a path in *this* namespace. */
445
447
  readonly cwd: string;
448
+ /** Directory, in this namespace, that oversized tool output is written to. */
449
+ readonly spillPath: string;
446
450
  }
451
+ /** Spill directory for a driver that configures none. */
452
+ declare const DEFAULT_SPILL_PATH = "/tmp";
447
453
  declare const Current_base: Context.ServiceClass<Current, "@codeworksh/plugin/sandbox/io/Current", Identity>;
448
454
  /** Identity and working directory of the current mount. */
449
455
  declare class Current extends Current_base {}
@@ -513,6 +519,7 @@ declare const virtual: (input: {
513
519
  readonly id?: ID;
514
520
  readonly defaultCwd?: string;
515
521
  readonly cwd?: string;
522
+ readonly spillPath?: string;
516
523
  }) => Identity;
517
524
  /**
518
525
  * A provider-hosted namespace. The id is always supplied: a remote resource's
@@ -525,7 +532,9 @@ declare const remote: (input: {
525
532
  /** Namespace-intrinsic default supplied or discovered by the driver. */
526
533
  readonly defaultCwd: string;
527
534
  readonly cwd?: string;
535
+ /** Namespace-intrinsic spill directory configured by the driver. */
536
+ readonly spillPath?: string;
528
537
  }) => Identity;
529
538
  //#endregion
530
- export { SandboxRemovedError as $, RuntimeInput as A, SandboxCreateError as B, ModuleDefinition as C, toColumn as Ct, Registered as D, Provisioned as E, driver_d_exports as F, SandboxDriverRegistrationError as G, SandboxDriverLoadError as H, erase as I, SandboxNotFoundError as J, SandboxMountError as K, withSource as L, apiVersion as M, defineModule as N, Registration as O, driver as P, SandboxRegisterError as Q, Redactor as R, Module as S, mountable as St, Observed as T, SandboxDriverLoadPhase as U, SandboxDestroyError as V, SandboxDriverNotRegisteredError as W, SandboxReadError as X, SandboxProviderError as Y, SandboxRefreshError as Z, AbsolutePath as _, Usage as _t, Mutation as a, errors_d_exports as at, Definition as b, instance_d_exports as bt, host as c, providerErrorCause as ct, io_d_exports as d, ID as dt, SandboxStopError as et, mount as f, Info as ft, withMutation as g, Status as gt, virtual as h, PersistedError as ht, Layer$1 as i, SandboxWakeError as it, Source as j, RuntimeConfigBase as k, hostLayer as l, providerErrorIsNotFound as lt, resolveMountCwd as m, Ownership as mt, FileSystem as n, SandboxUnavailError as nt, Provides as o, makeRedactor as ot, remote as p, Kind as pt, SandboxMustBeStoppedError as q, Identity as r, SandboxUnsupportedError as rt, Shell as s, providerError as st, Current as t, SandboxTransitionConflictError as tt, identityLayer as u, sanitizeError as ut, ApiVersion as v, fromColumn as vt, Name as w, toField as wt, Driver as x, isMountable as xt, Capabilities as y, fromField as yt, SandboxBusyError as z };
531
- //# sourceMappingURL=io-BarV4hvG.d.mts.map
539
+ export { SandboxRegisterError as $, RuntimeConfigBase as A, SandboxBusyError as B, Module as C, mountable as Ct, Provisioned as D, Observed as E, driver as F, SandboxDriverNotRegisteredError as G, SandboxDestroyError as H, driver_d_exports as I, SandboxMustBeStoppedError as J, SandboxDriverRegistrationError as K, erase as L, Source as M, apiVersion as N, Registered as O, defineModule as P, SandboxRefreshError as Q, withSource as R, Driver as S, isMountable as St, Name as T, toField as Tt, SandboxDriverLoadError as U, SandboxCreateError as V, SandboxDriverLoadPhase as W, SandboxProviderError as X, SandboxNotFoundError as Y, SandboxReadError as Z, withMutation as _, Status as _t, Layer$1 as a, SandboxWakeError as at, Capabilities as b, fromField as bt, Shell as c, providerError as ct, identityLayer as d, sanitizeError as dt, SandboxRemovedError as et, io_d_exports as f, ID as ft, virtual as g, PersistedError as gt, resolveMountCwd as h, Ownership as ht, Identity as i, SandboxUnsupportedError as it, RuntimeInput as j, Registration as k, host as l, providerErrorCause as lt, remote as m, Kind as mt, DEFAULT_SPILL_PATH as n, SandboxTransitionConflictError as nt, Mutation as o, errors_d_exports as ot, mount as p, Info as pt, SandboxMountError as q, FileSystem as r, SandboxUnavailError as rt, Provides as s, makeRedactor as st, Current as t, SandboxStopError as tt, hostLayer as u, providerErrorIsNotFound as ut, AbsolutePath as v, Usage as vt, ModuleDefinition as w, toColumn as wt, Definition as x, instance_d_exports as xt, ApiVersion as y, fromColumn as yt, Redactor as z };
540
+ //# sourceMappingURL=io-CXi2Sjg9.d.mts.map
@@ -49,6 +49,7 @@ const make = (instance, cwd, fs) => ({ withFile: (path, effect) => Effect.flatMa
49
49
  //#region src/sandbox/io.ts
50
50
  var io_exports = /* @__PURE__ */ __exportAll({
51
51
  Current: () => Current,
52
+ DEFAULT_SPILL_PATH: () => DEFAULT_SPILL_PATH,
52
53
  FileSystem: () => FileSystem,
53
54
  Mutation: () => Mutation,
54
55
  SandboxIO: () => io_exports,
@@ -88,6 +89,8 @@ const FileSystem = Service$1;
88
89
  const Shell = Shell$1;
89
90
  /** Per-file mutation ordering for this mount's instance. Re-exported here so consumers import one namespace. */
90
91
  const Mutation = Service;
92
+ /** Spill directory for a driver that configures none. */
93
+ const DEFAULT_SPILL_PATH = "/tmp";
91
94
  /** Identity and working directory of the current mount. */
92
95
  var Current = class extends Context.Service()("@codeworksh/plugin/sandbox/io/Current") {};
93
96
  /**
@@ -150,7 +153,8 @@ const host = (cwd) => ({
150
153
  id: ID.local,
151
154
  driver: "local",
152
155
  kind: "local",
153
- cwd: resolveMountCwd(cwd)
156
+ cwd: resolveMountCwd(cwd),
157
+ spillPath: DEFAULT_SPILL_PATH
154
158
  });
155
159
  /**
156
160
  * A VFS-backed namespace. The id is minted per call unless one is named, because
@@ -163,7 +167,8 @@ const virtual = (input) => ({
163
167
  id: input.id ?? ID.create(),
164
168
  driver: input.driver,
165
169
  kind: "virtual",
166
- cwd: resolveMountCwd(input.defaultCwd ?? "/", input.cwd)
170
+ cwd: resolveMountCwd(input.defaultCwd ?? "/", input.cwd),
171
+ spillPath: input.spillPath ?? "/tmp"
167
172
  });
168
173
  /**
169
174
  * A provider-hosted namespace. The id is always supplied: a remote resource's
@@ -174,9 +179,10 @@ const remote = (input) => ({
174
179
  id: input.id,
175
180
  driver: input.driver,
176
181
  kind: "remote",
177
- cwd: resolveMountCwd(input.defaultCwd, input.cwd)
182
+ cwd: resolveMountCwd(input.defaultCwd, input.cwd),
183
+ spillPath: input.spillPath ?? "/tmp"
178
184
  });
179
185
  //#endregion
180
- export { host as a, io_exports as c, resolveMountCwd as d, virtual as f, Shell as i, mount as l, FileSystem as n, hostLayer as o, withMutation as p, Mutation as r, identityLayer as s, Current as t, remote as u };
186
+ export { Shell as a, identityLayer as c, remote as d, resolveMountCwd as f, Mutation as i, io_exports as l, withMutation as m, DEFAULT_SPILL_PATH as n, host as o, virtual as p, FileSystem as r, hostLayer as s, Current as t, mount as u };
181
187
 
182
- //# sourceMappingURL=io-CFWrEV0O.mjs.map
188
+ //# sourceMappingURL=io-RvZvG-4N.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"io-RvZvG-4N.mjs","names":["SandboxFileSystem.Service","ShellTag","SandboxMutation.Service","EffectLayer","SandboxMutation.make","SandboxFileSystem.withCwd","shellWithCwd"],"sources":["../../src/sandbox/mutation.ts","../../src/sandbox/io.ts"],"sourcesContent":["import { Context, Deferred, Effect } from \"effect\";\nimport { posix } from \"../posix.ts\";\nimport { type FileSystemError, type Interface as FileSystem, isNotFoundError } from \"./filesystem.ts\";\nimport type { SandboxInstance } from \"./instance.ts\";\n\n/**\n * Serializes mutations of one file.\n *\n * Tool calls may run in parallel, and a file-mutating tool does read → modify →\n * write. Two of those on one file interleave and the first write is lost, so a\n * tool holds the file for its whole read-modify-write.\n *\n * A file is its sandbox instance plus its canonical path: two mounts of one\n * instance share files, and a symlinked spelling of a path is the same file.\n * Other files never wait. This orders the harness's own tools within this\n * process only; it is not a lock against `bash` or other processes.\n */\nexport interface Interface {\n\t/**\n\t * Run `effect` as the only mutation of `path` in flight. Calls queue in the\n\t * order their paths resolve, which for one spelling is the order they were made.\n\t */\n\treadonly withFile: <A, E, R>(\n\t\tpath: string,\n\t\teffect: Effect.Effect<A, E, R>,\n\t) => Effect.Effect<A, E | FileSystemError, R>;\n}\n\nexport class Service extends Context.Service<Service, Interface>()(\"@codeworksh/plugin/sandbox/mutation/Service\") {}\n\ninterface Lock {\n\treadonly waiters: Array<Deferred.Deferred<void>>;\n}\n\n// Process-wide on purpose: every mount of one instance must meet in the same\n// queue, whichever layer built it. A key is present exactly while its file is held.\nconst locks = new Map<string, Lock>();\n\n/** Hand the file to the next waiter, or free it. Ownership moves directly, so no newcomer can barge in. */\nconst release = (key: string, lock: Lock): void => {\n\tconst next = lock.waiters.shift();\n\tif (next === undefined) locks.delete(key);\n\telse Deferred.doneUnsafe(next, Effect.void);\n};\n\n/** Take the file, waiting interruptibly; must run uninterruptibly so taking and releasing pair up. */\nconst acquire = (key: string, restore: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>) =>\n\tEffect.suspend(() => {\n\t\tconst lock = locks.get(key);\n\t\tif (lock === undefined) {\n\t\t\tlocks.set(key, { waiters: [] });\n\t\t\treturn Effect.void;\n\t\t}\n\t\tconst turn = Deferred.makeUnsafe<void>();\n\t\tlock.waiters.push(turn);\n\t\treturn restore(Deferred.await(turn)).pipe(\n\t\t\tEffect.onInterrupt(() =>\n\t\t\t\tEffect.sync(() => {\n\t\t\t\t\tconst index = lock.waiters.indexOf(turn);\n\t\t\t\t\t// Still queued: leave. Already handed the file: pass it on.\n\t\t\t\t\tif (index !== -1) lock.waiters.splice(index, 1);\n\t\t\t\t\telse release(key, lock);\n\t\t\t\t}),\n\t\t\t),\n\t\t);\n\t});\n\n/**\n * The canonical path. A file that does not exist yet takes its canonical\n * parent joined with its name, walking up as far as needed, so a write that\n * creates a file (and its directories) shares a key with later mutations of it.\n */\nconst canonical = (fs: FileSystem, path: string): Effect.Effect<string, FileSystemError> =>\n\tfs.realpath(path).pipe(\n\t\tEffect.catchIf(\n\t\t\t(error) => isNotFoundError(error.cause),\n\t\t\t(error) => {\n\t\t\t\tconst parent = posix.dirname(path);\n\t\t\t\tif (parent === path) return Effect.fail(error);\n\t\t\t\treturn Effect.map(canonical(fs, parent), (resolved) => posix.join(resolved, posix.basename(path)));\n\t\t\t},\n\t\t),\n\t);\n\nexport const make = (instance: SandboxInstance.ID, cwd: string, fs: FileSystem): Interface => ({\n\twithFile: (path, effect) =>\n\t\tEffect.flatMap(canonical(fs, posix.resolve(cwd, path)), (resolved) => {\n\t\t\tconst key = `${instance}\\0${resolved}`;\n\t\t\t// Held from the moment `acquire` returns: nothing can interrupt between\n\t\t\t// taking the file and installing its release.\n\t\t\treturn Effect.uninterruptibleMask((restore) =>\n\t\t\t\tEffect.andThen(\n\t\t\t\t\tacquire(key, restore),\n\t\t\t\t\trestore(effect).pipe(\n\t\t\t\t\t\tEffect.ensuring(\n\t\t\t\t\t\t\tEffect.sync(() => {\n\t\t\t\t\t\t\t\tconst lock = locks.get(key);\n\t\t\t\t\t\t\t\tif (lock !== undefined) release(key, lock);\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t);\n\t\t}),\n});\n\nexport * as SandboxMutation from \"./mutation.ts\";\n","import { Context, Effect, Layer as EffectLayer } from \"effect\";\nimport { posix } from \"../posix.ts\";\nimport type { SandboxDriver } from \"./driver.ts\";\nimport { SandboxFileSystem } from \"./filesystem.ts\";\nimport { SandboxInstance } from \"./instance.ts\";\nimport { SandboxMutation } from \"./mutation.ts\";\nimport { type ISandboxExe, Shell as ShellTag, withCwd as shellWithCwd } from \"./shell.ts\";\n\n/**\n * `SandboxIO` is a **mount**: a filesystem, a shell, and the identity and\n * working directory they act on.\n *\n * It is the whole vocabulary a consumer needs. Project, Git, Copy, Location, and\n * every tool ask for `SandboxIO.FileSystem`, `SandboxIO.Shell`, and\n * `SandboxIO.Current` — never for a driver, an address, or a provider SDK — so\n * a host directory, an in-memory VFS, and a remote microVM are interchangeable\n * behind one contract.\n *\n * The mount neither creates nor destroys infrastructure. `SandboxInstance` is\n * the durable namespace it acts on — a device, which exists whether or not\n * anything has it mounted — and `Sandbox.Controller` is the only path that\n * creates, stops, or destroys one.\n */\n\n/**\n * The filesystem tag. Re-exported here so consumers import one namespace —\n * Project, Git, Copy, and the runner ask for `SandboxIO.FileSystem`, never for\n * the module that happens to define it. Code *inside* `sandbox/` keeps importing\n * the tag directly, since `io.ts` is built on top of it.\n */\nexport const FileSystem = SandboxFileSystem.Service;\nexport type FileSystem = SandboxFileSystem.Service;\n\n/** The shell tag. Re-exported here so consumers import one namespace. */\nexport const Shell = ShellTag;\nexport type Shell = ShellTag;\n\n/** Per-file mutation ordering for this mount's instance. Re-exported here so consumers import one namespace. */\nexport const Mutation = SandboxMutation.Service;\nexport type Mutation = SandboxMutation.Service;\n\n/**\n * What a mount sees: immutable identity, plus the working directory resolved for\n * *this* mount.\n *\n * Nothing mutable belongs here. `status`, `usage`, and reference counts all\n * change while a mount is open, so a mount-time snapshot of them would be wrong\n * by construction — runtime code that needs live management state asks the\n * control plane. The driver's own resource locator is likewise absent: consumers\n * never parse a Vercel name or a Daytona id.\n */\nexport interface Identity {\n\treadonly id: SandboxInstance.ID;\n\treadonly driver: SandboxDriver.Name;\n\treadonly kind: SandboxInstance.Kind;\n\t/** Absolute, and always a path in *this* namespace. */\n\treadonly cwd: string;\n\t/** Directory, in this namespace, that oversized tool output is written to. */\n\treadonly spillPath: string;\n}\n\n/** Spill directory for a driver that configures none. */\nexport const DEFAULT_SPILL_PATH = \"/tmp\";\n\n/** Identity and working directory of the current mount. */\nexport class Current extends Context.Service<Current, Identity>()(\"@codeworksh/plugin/sandbox/io/Current\") {}\n\n/** Everything a mount provides. */\nexport type Provides = Current | SandboxFileSystem.Service | ShellTag | SandboxMutation.Service;\n\n/** A built mount. */\nexport type Layer<E = never, RIn = never> = EffectLayer.Layer<Provides, E, RIn>;\n\n/**\n * Resolve a mount's cwd without consulting ambient process state.\n *\n * The default is supplied by the namespace adapter:\n * provider metadata remotely, `/` for a virtual filesystem, and `process.cwd()` for the host adapter.\n * An explicit absolute cwd replaces it; a relative cwd is resolved inside it. The\n * result is therefore always the one concrete absolute path `Current` requires.\n *\n * A non-absolute default throws rather than failing typed. It is the one\n * defect-level guard in this module, and deliberately so:\n * Adapters reading a value from a provider call this inside their own error channel,\n * where the throw becomes their typed failure (see `EnvDaytona.mountCwd`).\n */\nexport const resolveMountCwd = (defaultCwd: string, cwd?: string): string => {\n\tif (!posix.isAbsolute(defaultCwd)) {\n\t\tthrow new TypeError(`Sandbox default cwd must be absolute: ${defaultCwd}`);\n\t}\n\t// `resolve`, not `normalize`: normalize keeps a trailing slash, and `cwd` is\n\t// persisted — `space.location` and its id hash would read\n\t// `/workspace/` and `/workspace` as two directories and keep a row for each.\n\t//\n\t// A provider-reported default (`getWorkDir()`) or a config value is free to\n\t// carry one, so it is stripped here rather than at every reader.\n\tif (cwd === undefined) return posix.resolve(defaultCwd);\n\treturn posix.isAbsolute(cwd) ? posix.resolve(cwd) : posix.resolve(defaultCwd, cwd);\n};\n\n/**\n * Complete a mount with its {@link Mutation} queue, derived from the mount's own\n * identity and filesystem. Every layer that provides a mount goes through here,\n * so mounts of one instance always meet in the same queue.\n */\nexport const withMutation = <E, R>(\n\tlayer: EffectLayer.Layer<Current | SandboxFileSystem.Service | ShellTag, E, R>,\n): EffectLayer.Layer<Provides, E, R> =>\n\tEffectLayer.provideMerge(\n\t\tEffectLayer.effect(\n\t\t\tMutation,\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst current = yield* Current;\n\t\t\t\treturn SandboxMutation.make(current.id, current.cwd, yield* SandboxFileSystem.Service);\n\t\t\t}),\n\t\t),\n\t\tlayer,\n\t);\n\n/**\n * Bind a cwd-neutral transport to one mount.\n *\n * The transport underneath is shared between\n * mounts and stays rooted at the namespace root, and everything directory-shaped\n * happens here, once per mount. Two mounts of one namespace at different working\n * directories therefore coexist without seeing or moving each other's.\n *\n * It consumes the same two tags it provides — the transport is supplied by the\n * layer this is composed over, not by itself.\n */\nexport const mount = (identity: Identity): EffectLayer.Layer<Provides, never, SandboxFileSystem.Service | ShellTag> =>\n\tEffectLayer.mergeAll(\n\t\tEffectLayer.succeed(Current, identity),\n\t\tEffectLayer.effect(\n\t\t\tSandboxFileSystem.Service,\n\t\t\tEffect.map(SandboxFileSystem.Service, (fs) => SandboxFileSystem.withCwd(fs, identity.cwd)),\n\t\t),\n\t\tEffectLayer.effect(\n\t\t\tShellTag,\n\t\t\tEffect.map(ShellTag, (shell: ISandboxExe) => shellWithCwd(shell, identity.cwd)),\n\t\t),\n\t).pipe(withMutation);\n\n/**\n * Just the identity tag, with no filesystem or shell beneath it. For consumers\n * assembled from stubs — a test that runs `Project` over a fake filesystem still\n * needs to know which namespace it is in.\n */\nexport const identityLayer = (identity: Identity) => EffectLayer.succeed(Current, identity);\n\n/** The host identity alone. See {@link identityLayer}. */\nexport const hostLayer = (cwd: string) => identityLayer(host(cwd));\n\n/**\n * The host, rooted at `cwd`. Always `SandboxInstance.ID.local`: the working\n * directory selects where relative paths resolve, it does not make a second host\n * namespace — two mounts rooted at different directories still agree on absolute\n * paths.\n *\n * The host coordinate is explicit so a caller cannot accidentally substitute ambient process\n * state for the application or session directory it owns.\n */\nexport const host = (cwd: string): Identity => ({\n\tid: SandboxInstance.ID.local,\n\tdriver: \"local\" as SandboxDriver.Name,\n\tkind: \"local\",\n\tcwd: resolveMountCwd(cwd),\n\tspillPath: DEFAULT_SPILL_PATH,\n});\n\n/**\n * A VFS-backed namespace. The id is minted per call unless one is named, because\n * building one of these builds a fresh VFS: N unnamed calls are N distinct\n * namespaces, none of which outlives the process. A file-backed store is the\n * exception — its file is the state, so whoever knows the file supplies the id\n * it was registered under.\n */\nexport const virtual = (input: {\n\treadonly driver: string;\n\treadonly id?: SandboxInstance.ID;\n\treadonly defaultCwd?: string;\n\treadonly cwd?: string;\n\treadonly spillPath?: string;\n}): Identity => ({\n\tid: input.id ?? SandboxInstance.ID.create(),\n\tdriver: input.driver as SandboxDriver.Name,\n\tkind: \"virtual\",\n\tcwd: resolveMountCwd(input.defaultCwd ?? \"/\", input.cwd),\n\tspillPath: input.spillPath ?? DEFAULT_SPILL_PATH,\n});\n\n/**\n * A provider-hosted namespace. The id is always supplied: a remote resource's\n * durable identity is minted and recorded by whoever provisioned it, never\n * derived here from the provider's own locator.\n */\nexport const remote = (input: {\n\treadonly driver: string;\n\treadonly id: SandboxInstance.ID;\n\t/** Namespace-intrinsic default supplied or discovered by the driver. */\n\treadonly defaultCwd: string;\n\treadonly cwd?: string;\n\t/** Namespace-intrinsic spill directory configured by the driver. */\n\treadonly spillPath?: string;\n}): Identity => ({\n\tid: input.id,\n\tdriver: input.driver as SandboxDriver.Name,\n\tkind: \"remote\",\n\tcwd: resolveMountCwd(input.defaultCwd, input.cwd),\n\tspillPath: input.spillPath ?? DEFAULT_SPILL_PATH,\n});\n\nexport * as SandboxIO from \"./io.ts\";\n"],"mappings":"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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeworksh/plugin",
3
- "version": "0.1.0-canary.20.1.gf5454e1e",
3
+ "version": "0.1.0-canary.22.1.g06862c3f",
4
4
  "description": "SDK for building CodeWork plugins — the plugin, tool, and sandbox contracts shared with @codeworksh/harness.",
5
5
  "keywords": [
6
6
  "agent",
@@ -168,7 +168,7 @@
168
168
  "uuidv7": "^1.2.1"
169
169
  },
170
170
  "peerDependencies": {
171
- "@codeworksh/aikit": "0.10.0-canary.20.1.gf5454e1e",
171
+ "@codeworksh/aikit": "0.10.0-canary.22.1.g06862c3f",
172
172
  "effect": "4.0.1"
173
173
  }
174
174
  }
@@ -1,7 +1,7 @@
1
1
  import { i as Definition, o as Payload, r as Data, s as PublishOptions } from "./event-6sTQ_4bq.mjs";
2
2
  import { n as SessionID } from "./ids-CHjmAdTc.mjs";
3
3
  import { o as Service, r as Info } from "./location-Q39els63.mjs";
4
- import { d as io_d_exports, o as Provides, r as Identity } from "./io-BarV4hvG.mjs";
4
+ import { f as io_d_exports, i as Identity, s as Provides } from "./io-CXi2Sjg9.mjs";
5
5
  import { i as Info$1 } from "./settings-B6-grSTA.mjs";
6
6
  import { t as section_d_exports } from "./plugin/section.mjs";
7
7
  import { n as prompt_d_exports, t as PromptRegistry } from "./prompt-DWaA5ZXj.mjs";
@@ -138,4 +138,4 @@ declare namespace plugin_d_exports {
138
138
  }
139
139
  //#endregion
140
140
  export { define as a, PluginOptions as c, PluginSpec as d, Config as f, PluginRegistry as g, SharedPluginContext as h, PluginKind as i, PluginPatch as l, PromptResolver as m, Mount as n, domains as o, Events as p, Plugin as r, rank as s, plugin_d_exports as t, PluginRef as u };
141
- //# sourceMappingURL=plugin-C5HDBWGL.d.mts.map
141
+ //# sourceMappingURL=plugin-Bb1gRtNX.d.mts.map
package/plugin.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as section_d_exports } from "./plugin/section.mjs";
2
2
  import { n as prompt_d_exports } from "./prompt-DWaA5ZXj.mjs";
3
3
  import { p as tool_d_exports } from "./tool-BoVqkYvL.mjs";
4
- import { a as define, c as PluginOptions, d as PluginSpec, f as Config, g as PluginRegistry, h as SharedPluginContext, i as PluginKind, l as PluginPatch, m as PromptResolver, n as Mount, o as domains, p as Events, r as Plugin, s as rank, u as PluginRef } from "./plugin-C5HDBWGL.mjs";
4
+ import { a as define, c as PluginOptions, d as PluginSpec, f as Config, g as PluginRegistry, h as SharedPluginContext, i as PluginKind, l as PluginPatch, m as PromptResolver, n as Mount, o as domains, p as Events, r as Plugin, s as rank, u as PluginRef } from "./plugin-Bb1gRtNX.mjs";
5
5
  export { type Config, type Events, type Mount, type Plugin, type PluginKind, type PluginOptions, type PluginPatch, type PluginRef, type PluginRegistry, type PluginSpec, prompt_d_exports as Prompt, type PromptResolver, section_d_exports as Section, type SharedPluginContext, tool_d_exports as Tool, define, domains, rank };
@@ -1,2 +1,2 @@
1
- import { A as RuntimeInput, C as ModuleDefinition, D as Registered, E as Provisioned, F as driver_d_exports, I as erase, L as withSource, M as apiVersion, N as defineModule, O as Registration, P as driver, S as Module, T as Observed, _ as AbsolutePath, b as Definition, j as Source, k as RuntimeConfigBase, v as ApiVersion, w as Name, x as Driver, y as Capabilities } from "../io-BarV4hvG.mjs";
1
+ import { A as RuntimeConfigBase, C as Module, D as Provisioned, E as Observed, F as driver, I as driver_d_exports, L as erase, M as Source, N as apiVersion, O as Registered, P as defineModule, R as withSource, S as Driver, T as Name, b as Capabilities, j as RuntimeInput, k as Registration, v as AbsolutePath, w as ModuleDefinition, x as Definition, y as ApiVersion } from "../io-CXi2Sjg9.mjs";
2
2
  export { AbsolutePath, ApiVersion, Capabilities, Definition, Driver, Module, ModuleDefinition, Name, Observed, Provisioned, Registered, Registration, RuntimeConfigBase, RuntimeInput, driver_d_exports as SandboxDriver, Source, apiVersion, driver, erase, defineModule as module, withSource };
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
2
  import "./instance.mjs";
3
- import "../io-CFWrEV0O.mjs";
3
+ import "../io-RvZvG-4N.mjs";
4
4
  import { Schema } from "effect";
5
5
  //#region src/sandbox/driver.ts
6
6
  var driver_exports = /* @__PURE__ */ __exportAll({
@@ -20,7 +20,11 @@ const apiVersion = 1;
20
20
  const Name = Schema.String.check(Schema.isNonEmpty()).pipe(Schema.brand("SandboxDriver.Name"));
21
21
  /** A path whose coordinate system is the mounted namespace. */
22
22
  const AbsolutePath = Schema.String.check(Schema.isStartingWith("/")).pipe(Schema.brand("SandboxDriver.AbsolutePath"));
23
- const RuntimeConfigBase = Schema.Struct({ defaultCwd: AbsolutePath });
23
+ const RuntimeConfigBase = Schema.Struct({
24
+ defaultCwd: AbsolutePath,
25
+ /** Where oversized tool output is written inside the sandbox; `SandboxIO.DEFAULT_SPILL_PATH` when absent. */
26
+ spillPath: Schema.optional(AbsolutePath)
27
+ });
24
28
  const erase = (value) => ({
25
29
  name: value.name,
26
30
  kind: value.kind,
@@ -1 +1 @@
1
- {"version":3,"file":"driver.mjs","names":[],"sources":["../../../src/sandbox/driver.ts"],"sourcesContent":["import { type Effect, type Layer, Option, Schema } from \"effect\";\nimport type { SandboxProviderError } from \"./errors.ts\";\nimport { SandboxInstance } from \"./instance.ts\";\nimport { SandboxIO } from \"./io.ts\";\n\n/** Version of the loadable sandbox-driver module ABI. */\nexport const apiVersion = 1 as const;\nexport type ApiVersion = typeof apiVersion;\n\n/** Open driver identity. Adding a driver never extends a union in core. */\nexport const Name = Schema.String.check(Schema.isNonEmpty()).pipe(Schema.brand(\"SandboxDriver.Name\"));\nexport type Name = typeof Name.Type;\n\n/** A path whose coordinate system is the mounted namespace. */\nexport const AbsolutePath = Schema.String.check(Schema.isStartingWith(\"/\")).pipe(\n\tSchema.brand(\"SandboxDriver.AbsolutePath\"),\n);\nexport type AbsolutePath = typeof AbsolutePath.Type;\n\nexport const RuntimeConfigBase = Schema.Struct({ defaultCwd: AbsolutePath });\nexport interface RuntimeConfigBase extends Schema.Schema.Type<typeof RuntimeConfigBase> {}\n\nexport interface Capabilities {\n\treadonly inspect: boolean;\n\treadonly reattach: boolean;\n\treadonly wake: boolean;\n\treadonly stop: boolean;\n\treadonly destroy: boolean;\n\treadonly cancels: boolean;\n}\n\nexport interface Observed {\n\treadonly status: SandboxInstance.Status;\n\treadonly providerStatus?: string | undefined;\n\treadonly metadata?: Readonly<Record<string, string>> | undefined;\n}\n\nexport interface Provisioned<RuntimeConfig extends RuntimeConfigBase> {\n\treadonly providerResourceId?: string | undefined;\n\treadonly providerStatus?: string | undefined;\n\treadonly runtimeConfig: RuntimeConfig;\n\treadonly metadata?: Readonly<Record<string, string>> | undefined;\n}\n\nexport interface RuntimeInput<RuntimeConfig extends RuntimeConfigBase> {\n\treadonly id: SandboxInstance.ID;\n\treadonly providerResourceId: Option.Option<string>;\n\treadonly runtimeConfig: RuntimeConfig;\n}\n\nexport interface Driver<CreateConfig, RuntimeConfig extends RuntimeConfigBase> {\n\treadonly name: Name;\n\treadonly kind: Exclude<SandboxInstance.Kind, \"local\">;\n\treadonly capabilities: Capabilities;\n\treadonly createConfigCodec: Schema.Codec<CreateConfig, unknown>;\n\treadonly runtimeConfigCodec: Schema.Codec<RuntimeConfig, unknown>;\n\treadonly create: (input: {\n\t\treadonly instanceId: SandboxInstance.ID;\n\t\treadonly config: CreateConfig;\n\t}) => Effect.Effect<Provisioned<RuntimeConfig>, SandboxProviderError>;\n\treadonly runtimeConfigFor?:\n\t\t| ((input: {\n\t\t\t\treadonly providerResourceId: string;\n\t\t\t\treadonly overrides?: Partial<RuntimeConfig> | undefined;\n\t\t }) => Effect.Effect<RuntimeConfig, SandboxProviderError>)\n\t\t| undefined;\n\treadonly attach: (\n\t\tinput: RuntimeInput<RuntimeConfig>,\n\t) => Layer.Layer<SandboxIO.FileSystem | SandboxIO.Shell, SandboxProviderError>;\n\treadonly inspect?: (input: RuntimeInput<RuntimeConfig>) => Effect.Effect<Observed, SandboxProviderError>;\n\treadonly wake?: (input: RuntimeInput<RuntimeConfig>) => Effect.Effect<Observed, SandboxProviderError>;\n\treadonly stop?: (input: RuntimeInput<RuntimeConfig>) => Effect.Effect<Observed, SandboxProviderError>;\n\treadonly destroy?: (input: RuntimeInput<RuntimeConfig>) => Effect.Effect<void, SandboxProviderError>;\n}\n\nexport type Definition<CreateConfig, RuntimeConfig extends RuntimeConfigBase> = Pick<\n\tDriver<CreateConfig, RuntimeConfig>,\n\t\"name\" | \"createConfigCodec\" | \"runtimeConfigCodec\"\n>;\n\n/** Registry-only erased shape. Driver authors construct it via {@link driver}. */\nexport interface Registered {\n\treadonly name: Name;\n\treadonly kind: Exclude<SandboxInstance.Kind, \"local\">;\n\treadonly capabilities: Capabilities;\n\treadonly createConfigCodec: Schema.Codec<unknown, unknown>;\n\treadonly runtimeConfigCodec: Schema.Codec<RuntimeConfigBase, unknown>;\n\treadonly create: (input: {\n\t\treadonly instanceId: SandboxInstance.ID;\n\t\treadonly config: unknown;\n\t}) => Effect.Effect<Provisioned<RuntimeConfigBase>, SandboxProviderError>;\n\treadonly runtimeConfigFor?:\n\t\t| ((input: {\n\t\t\t\treadonly providerResourceId: string;\n\t\t\t\treadonly overrides?: Readonly<Record<string, unknown>> | undefined;\n\t\t }) => Effect.Effect<RuntimeConfigBase, SandboxProviderError>)\n\t\t| undefined;\n\treadonly attach: (\n\t\tinput: RuntimeInput<RuntimeConfigBase>,\n\t) => Layer.Layer<SandboxIO.FileSystem | SandboxIO.Shell, SandboxProviderError>;\n\treadonly inspect?: (input: RuntimeInput<RuntimeConfigBase>) => Effect.Effect<Observed, SandboxProviderError>;\n\treadonly wake?: (input: RuntimeInput<RuntimeConfigBase>) => Effect.Effect<Observed, SandboxProviderError>;\n\treadonly stop?: (input: RuntimeInput<RuntimeConfigBase>) => Effect.Effect<Observed, SandboxProviderError>;\n\treadonly destroy?: (input: RuntimeInput<RuntimeConfigBase>) => Effect.Effect<void, SandboxProviderError>;\n}\n\nexport const erase = <CreateConfig, RuntimeConfig extends RuntimeConfigBase>(\n\tvalue: Driver<CreateConfig, RuntimeConfig>,\n): Registered => ({\n\tname: value.name,\n\tkind: value.kind,\n\tcapabilities: value.capabilities,\n\tcreateConfigCodec: value.createConfigCodec as Schema.Codec<unknown, unknown>,\n\truntimeConfigCodec: value.runtimeConfigCodec as Schema.Codec<RuntimeConfigBase, unknown>,\n\tcreate: (input) => value.create({ instanceId: input.instanceId, config: input.config as CreateConfig }),\n\t...(value.runtimeConfigFor === undefined\n\t\t? {}\n\t\t: {\n\t\t\t\truntimeConfigFor: (input: {\n\t\t\t\t\treadonly providerResourceId: string;\n\t\t\t\t\treadonly overrides?: Readonly<Record<string, unknown>> | undefined;\n\t\t\t\t}) =>\n\t\t\t\t\tvalue.runtimeConfigFor!({\n\t\t\t\t\t\tproviderResourceId: input.providerResourceId,\n\t\t\t\t\t\t...(input.overrides === undefined ? {} : { overrides: input.overrides as Partial<RuntimeConfig> }),\n\t\t\t\t\t}),\n\t\t\t}),\n\tattach: (input) => value.attach(input as RuntimeInput<RuntimeConfig>),\n\t...(value.inspect === undefined\n\t\t? {}\n\t\t: { inspect: (input: RuntimeInput<RuntimeConfigBase>) => value.inspect!(input as RuntimeInput<RuntimeConfig>) }),\n\t...(value.wake === undefined\n\t\t? {}\n\t\t: { wake: (input: RuntimeInput<RuntimeConfigBase>) => value.wake!(input as RuntimeInput<RuntimeConfig>) }),\n\t...(value.stop === undefined\n\t\t? {}\n\t\t: { stop: (input: RuntimeInput<RuntimeConfigBase>) => value.stop!(input as RuntimeInput<RuntimeConfig>) }),\n\t...(value.destroy === undefined\n\t\t? {}\n\t\t: { destroy: (input: RuntimeInput<RuntimeConfigBase>) => value.destroy!(input as RuntimeInput<RuntimeConfig>) }),\n});\n\nexport type Source = \"core\" | \"builtin\" | \"package\" | \"file\";\n\nexport interface Registration {\n\treadonly registered: Registered;\n\treadonly apiVersion: ApiVersion;\n\treadonly source: Source;\n}\n\nexport interface Module<Options> {\n\treadonly apiVersion: ApiVersion;\n\treadonly name: Name;\n\treadonly options: Schema.Codec<Options, unknown>;\n\treadonly make: (options: Options) => Registration;\n}\n\nexport interface ModuleDefinition<Options> {\n\treadonly apiVersion: ApiVersion;\n\treadonly name: string | Name;\n\treadonly options: Schema.Codec<Options, unknown>;\n\treadonly make: (options: Options) => Registration;\n}\n\n/** Define the default export of a loadable sandbox package. */\nconst defineModule = <Options>(value: ModuleDefinition<Options>): Module<Options> => ({\n\t...value,\n\tname: Name.make(value.name),\n});\nexport { defineModule as module };\n\n/** Construct a driver and its registry contribution. */\nexport const driver = <CreateConfig, RuntimeConfig extends RuntimeConfigBase>(\n\tvalue: Driver<CreateConfig, RuntimeConfig>,\n): Driver<CreateConfig, RuntimeConfig> & Registration =>\n\tObject.assign(value, {\n\t\tregistered: erase(value),\n\t\tapiVersion,\n\t\tsource: \"builtin\" as const,\n\t});\n\n/** Attach trusted origin metadata without changing the driver implementation. */\nexport const withSource = (registration: Registration, source: Source): Registration => ({\n\t...registration,\n\tsource,\n});\n\nexport * as SandboxDriver from \"./driver.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;AAMA,MAAa,aAAa;;AAI1B,MAAa,OAAO,OAAO,OAAO,MAAM,OAAO,WAAW,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,oBAAoB,CAAC;;AAIpG,MAAa,eAAe,OAAO,OAAO,MAAM,OAAO,eAAe,GAAG,CAAC,CAAC,CAAC,KAC3E,OAAO,MAAM,4BAA4B,CAC1C;AAGA,MAAa,oBAAoB,OAAO,OAAO,EAAE,YAAY,aAAa,CAAC;AAuF3E,MAAa,SACZ,WACiB;CACjB,MAAM,MAAM;CACZ,MAAM,MAAM;CACZ,cAAc,MAAM;CACpB,mBAAmB,MAAM;CACzB,oBAAoB,MAAM;CAC1B,SAAS,UAAU,MAAM,OAAO;EAAE,YAAY,MAAM;EAAY,QAAQ,MAAM;CAAuB,CAAC;CACtG,GAAI,MAAM,qBAAqB,KAAA,IAC5B,CAAC,IACD,EACA,mBAAmB,UAIlB,MAAM,iBAAkB;EACvB,oBAAoB,MAAM;EAC1B,GAAI,MAAM,cAAc,KAAA,IAAY,CAAC,IAAI,EAAE,WAAW,MAAM,UAAoC;CACjG,CAAC,EACH;CACF,SAAS,UAAU,MAAM,OAAO,KAAoC;CACpE,GAAI,MAAM,YAAY,KAAA,IACnB,CAAC,IACD,EAAE,UAAU,UAA2C,MAAM,QAAS,KAAoC,EAAE;CAC/G,GAAI,MAAM,SAAS,KAAA,IAChB,CAAC,IACD,EAAE,OAAO,UAA2C,MAAM,KAAM,KAAoC,EAAE;CACzG,GAAI,MAAM,SAAS,KAAA,IAChB,CAAC,IACD,EAAE,OAAO,UAA2C,MAAM,KAAM,KAAoC,EAAE;CACzG,GAAI,MAAM,YAAY,KAAA,IACnB,CAAC,IACD,EAAE,UAAU,UAA2C,MAAM,QAAS,KAAoC,EAAE;AAChH;;AAyBA,MAAM,gBAAyB,WAAuD;CACrF,GAAG;CACH,MAAM,KAAK,KAAK,MAAM,IAAI;AAC3B;;AAIA,MAAa,UACZ,UAEA,OAAO,OAAO,OAAO;CACpB,YAAY,MAAM,KAAK;CACvB,YAAA;CACA,QAAQ;AACT,CAAC;;AAGF,MAAa,cAAc,cAA4B,YAAkC;CACxF,GAAG;CACH;AACD"}
1
+ {"version":3,"file":"driver.mjs","names":[],"sources":["../../../src/sandbox/driver.ts"],"sourcesContent":["import { type Effect, type Layer, Option, Schema } from \"effect\";\nimport type { SandboxProviderError } from \"./errors.ts\";\nimport { SandboxInstance } from \"./instance.ts\";\nimport { SandboxIO } from \"./io.ts\";\n\n/** Version of the loadable sandbox-driver module ABI. */\nexport const apiVersion = 1 as const;\nexport type ApiVersion = typeof apiVersion;\n\n/** Open driver identity. Adding a driver never extends a union in core. */\nexport const Name = Schema.String.check(Schema.isNonEmpty()).pipe(Schema.brand(\"SandboxDriver.Name\"));\nexport type Name = typeof Name.Type;\n\n/** A path whose coordinate system is the mounted namespace. */\nexport const AbsolutePath = Schema.String.check(Schema.isStartingWith(\"/\")).pipe(\n\tSchema.brand(\"SandboxDriver.AbsolutePath\"),\n);\nexport type AbsolutePath = typeof AbsolutePath.Type;\n\nexport const RuntimeConfigBase = Schema.Struct({\n\tdefaultCwd: AbsolutePath,\n\t/** Where oversized tool output is written inside the sandbox; `SandboxIO.DEFAULT_SPILL_PATH` when absent. */\n\tspillPath: Schema.optional(AbsolutePath),\n});\nexport interface RuntimeConfigBase extends Schema.Schema.Type<typeof RuntimeConfigBase> {}\n\nexport interface Capabilities {\n\treadonly inspect: boolean;\n\treadonly reattach: boolean;\n\treadonly wake: boolean;\n\treadonly stop: boolean;\n\treadonly destroy: boolean;\n\treadonly cancels: boolean;\n}\n\nexport interface Observed {\n\treadonly status: SandboxInstance.Status;\n\treadonly providerStatus?: string | undefined;\n\treadonly metadata?: Readonly<Record<string, string>> | undefined;\n}\n\nexport interface Provisioned<RuntimeConfig extends RuntimeConfigBase> {\n\treadonly providerResourceId?: string | undefined;\n\treadonly providerStatus?: string | undefined;\n\treadonly runtimeConfig: RuntimeConfig;\n\treadonly metadata?: Readonly<Record<string, string>> | undefined;\n}\n\nexport interface RuntimeInput<RuntimeConfig extends RuntimeConfigBase> {\n\treadonly id: SandboxInstance.ID;\n\treadonly providerResourceId: Option.Option<string>;\n\treadonly runtimeConfig: RuntimeConfig;\n}\n\nexport interface Driver<CreateConfig, RuntimeConfig extends RuntimeConfigBase> {\n\treadonly name: Name;\n\treadonly kind: Exclude<SandboxInstance.Kind, \"local\">;\n\treadonly capabilities: Capabilities;\n\treadonly createConfigCodec: Schema.Codec<CreateConfig, unknown>;\n\treadonly runtimeConfigCodec: Schema.Codec<RuntimeConfig, unknown>;\n\treadonly create: (input: {\n\t\treadonly instanceId: SandboxInstance.ID;\n\t\treadonly config: CreateConfig;\n\t}) => Effect.Effect<Provisioned<RuntimeConfig>, SandboxProviderError>;\n\treadonly runtimeConfigFor?:\n\t\t| ((input: {\n\t\t\t\treadonly providerResourceId: string;\n\t\t\t\treadonly overrides?: Partial<RuntimeConfig> | undefined;\n\t\t }) => Effect.Effect<RuntimeConfig, SandboxProviderError>)\n\t\t| undefined;\n\treadonly attach: (\n\t\tinput: RuntimeInput<RuntimeConfig>,\n\t) => Layer.Layer<SandboxIO.FileSystem | SandboxIO.Shell, SandboxProviderError>;\n\treadonly inspect?: (input: RuntimeInput<RuntimeConfig>) => Effect.Effect<Observed, SandboxProviderError>;\n\treadonly wake?: (input: RuntimeInput<RuntimeConfig>) => Effect.Effect<Observed, SandboxProviderError>;\n\treadonly stop?: (input: RuntimeInput<RuntimeConfig>) => Effect.Effect<Observed, SandboxProviderError>;\n\treadonly destroy?: (input: RuntimeInput<RuntimeConfig>) => Effect.Effect<void, SandboxProviderError>;\n}\n\nexport type Definition<CreateConfig, RuntimeConfig extends RuntimeConfigBase> = Pick<\n\tDriver<CreateConfig, RuntimeConfig>,\n\t\"name\" | \"createConfigCodec\" | \"runtimeConfigCodec\"\n>;\n\n/** Registry-only erased shape. Driver authors construct it via {@link driver}. */\nexport interface Registered {\n\treadonly name: Name;\n\treadonly kind: Exclude<SandboxInstance.Kind, \"local\">;\n\treadonly capabilities: Capabilities;\n\treadonly createConfigCodec: Schema.Codec<unknown, unknown>;\n\treadonly runtimeConfigCodec: Schema.Codec<RuntimeConfigBase, unknown>;\n\treadonly create: (input: {\n\t\treadonly instanceId: SandboxInstance.ID;\n\t\treadonly config: unknown;\n\t}) => Effect.Effect<Provisioned<RuntimeConfigBase>, SandboxProviderError>;\n\treadonly runtimeConfigFor?:\n\t\t| ((input: {\n\t\t\t\treadonly providerResourceId: string;\n\t\t\t\treadonly overrides?: Readonly<Record<string, unknown>> | undefined;\n\t\t }) => Effect.Effect<RuntimeConfigBase, SandboxProviderError>)\n\t\t| undefined;\n\treadonly attach: (\n\t\tinput: RuntimeInput<RuntimeConfigBase>,\n\t) => Layer.Layer<SandboxIO.FileSystem | SandboxIO.Shell, SandboxProviderError>;\n\treadonly inspect?: (input: RuntimeInput<RuntimeConfigBase>) => Effect.Effect<Observed, SandboxProviderError>;\n\treadonly wake?: (input: RuntimeInput<RuntimeConfigBase>) => Effect.Effect<Observed, SandboxProviderError>;\n\treadonly stop?: (input: RuntimeInput<RuntimeConfigBase>) => Effect.Effect<Observed, SandboxProviderError>;\n\treadonly destroy?: (input: RuntimeInput<RuntimeConfigBase>) => Effect.Effect<void, SandboxProviderError>;\n}\n\nexport const erase = <CreateConfig, RuntimeConfig extends RuntimeConfigBase>(\n\tvalue: Driver<CreateConfig, RuntimeConfig>,\n): Registered => ({\n\tname: value.name,\n\tkind: value.kind,\n\tcapabilities: value.capabilities,\n\tcreateConfigCodec: value.createConfigCodec as Schema.Codec<unknown, unknown>,\n\truntimeConfigCodec: value.runtimeConfigCodec as Schema.Codec<RuntimeConfigBase, unknown>,\n\tcreate: (input) => value.create({ instanceId: input.instanceId, config: input.config as CreateConfig }),\n\t...(value.runtimeConfigFor === undefined\n\t\t? {}\n\t\t: {\n\t\t\t\truntimeConfigFor: (input: {\n\t\t\t\t\treadonly providerResourceId: string;\n\t\t\t\t\treadonly overrides?: Readonly<Record<string, unknown>> | undefined;\n\t\t\t\t}) =>\n\t\t\t\t\tvalue.runtimeConfigFor!({\n\t\t\t\t\t\tproviderResourceId: input.providerResourceId,\n\t\t\t\t\t\t...(input.overrides === undefined ? {} : { overrides: input.overrides as Partial<RuntimeConfig> }),\n\t\t\t\t\t}),\n\t\t\t}),\n\tattach: (input) => value.attach(input as RuntimeInput<RuntimeConfig>),\n\t...(value.inspect === undefined\n\t\t? {}\n\t\t: { inspect: (input: RuntimeInput<RuntimeConfigBase>) => value.inspect!(input as RuntimeInput<RuntimeConfig>) }),\n\t...(value.wake === undefined\n\t\t? {}\n\t\t: { wake: (input: RuntimeInput<RuntimeConfigBase>) => value.wake!(input as RuntimeInput<RuntimeConfig>) }),\n\t...(value.stop === undefined\n\t\t? {}\n\t\t: { stop: (input: RuntimeInput<RuntimeConfigBase>) => value.stop!(input as RuntimeInput<RuntimeConfig>) }),\n\t...(value.destroy === undefined\n\t\t? {}\n\t\t: { destroy: (input: RuntimeInput<RuntimeConfigBase>) => value.destroy!(input as RuntimeInput<RuntimeConfig>) }),\n});\n\nexport type Source = \"core\" | \"builtin\" | \"package\" | \"file\";\n\nexport interface Registration {\n\treadonly registered: Registered;\n\treadonly apiVersion: ApiVersion;\n\treadonly source: Source;\n}\n\nexport interface Module<Options> {\n\treadonly apiVersion: ApiVersion;\n\treadonly name: Name;\n\treadonly options: Schema.Codec<Options, unknown>;\n\treadonly make: (options: Options) => Registration;\n}\n\nexport interface ModuleDefinition<Options> {\n\treadonly apiVersion: ApiVersion;\n\treadonly name: string | Name;\n\treadonly options: Schema.Codec<Options, unknown>;\n\treadonly make: (options: Options) => Registration;\n}\n\n/** Define the default export of a loadable sandbox package. */\nconst defineModule = <Options>(value: ModuleDefinition<Options>): Module<Options> => ({\n\t...value,\n\tname: Name.make(value.name),\n});\nexport { defineModule as module };\n\n/** Construct a driver and its registry contribution. */\nexport const driver = <CreateConfig, RuntimeConfig extends RuntimeConfigBase>(\n\tvalue: Driver<CreateConfig, RuntimeConfig>,\n): Driver<CreateConfig, RuntimeConfig> & Registration =>\n\tObject.assign(value, {\n\t\tregistered: erase(value),\n\t\tapiVersion,\n\t\tsource: \"builtin\" as const,\n\t});\n\n/** Attach trusted origin metadata without changing the driver implementation. */\nexport const withSource = (registration: Registration, source: Source): Registration => ({\n\t...registration,\n\tsource,\n});\n\nexport * as SandboxDriver from \"./driver.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;AAMA,MAAa,aAAa;;AAI1B,MAAa,OAAO,OAAO,OAAO,MAAM,OAAO,WAAW,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,oBAAoB,CAAC;;AAIpG,MAAa,eAAe,OAAO,OAAO,MAAM,OAAO,eAAe,GAAG,CAAC,CAAC,CAAC,KAC3E,OAAO,MAAM,4BAA4B,CAC1C;AAGA,MAAa,oBAAoB,OAAO,OAAO;CAC9C,YAAY;;CAEZ,WAAW,OAAO,SAAS,YAAY;AACxC,CAAC;AAuFD,MAAa,SACZ,WACiB;CACjB,MAAM,MAAM;CACZ,MAAM,MAAM;CACZ,cAAc,MAAM;CACpB,mBAAmB,MAAM;CACzB,oBAAoB,MAAM;CAC1B,SAAS,UAAU,MAAM,OAAO;EAAE,YAAY,MAAM;EAAY,QAAQ,MAAM;CAAuB,CAAC;CACtG,GAAI,MAAM,qBAAqB,KAAA,IAC5B,CAAC,IACD,EACA,mBAAmB,UAIlB,MAAM,iBAAkB;EACvB,oBAAoB,MAAM;EAC1B,GAAI,MAAM,cAAc,KAAA,IAAY,CAAC,IAAI,EAAE,WAAW,MAAM,UAAoC;CACjG,CAAC,EACH;CACF,SAAS,UAAU,MAAM,OAAO,KAAoC;CACpE,GAAI,MAAM,YAAY,KAAA,IACnB,CAAC,IACD,EAAE,UAAU,UAA2C,MAAM,QAAS,KAAoC,EAAE;CAC/G,GAAI,MAAM,SAAS,KAAA,IAChB,CAAC,IACD,EAAE,OAAO,UAA2C,MAAM,KAAM,KAAoC,EAAE;CACzG,GAAI,MAAM,SAAS,KAAA,IAChB,CAAC,IACD,EAAE,OAAO,UAA2C,MAAM,KAAM,KAAoC,EAAE;CACzG,GAAI,MAAM,YAAY,KAAA,IACnB,CAAC,IACD,EAAE,UAAU,UAA2C,MAAM,QAAS,KAAoC,EAAE;AAChH;;AAyBA,MAAM,gBAAyB,WAAuD;CACrF,GAAG;CACH,MAAM,KAAK,KAAK,MAAM,IAAI;AAC3B;;AAIA,MAAa,UACZ,UAEA,OAAO,OAAO,OAAO;CACpB,YAAY,MAAM,KAAK;CACvB,YAAA;CACA,QAAQ;AACT,CAAC;;AAGF,MAAa,cAAc,cAA4B,YAAkC;CACxF,GAAG;CACH;AACD"}
@@ -1,2 +1,2 @@
1
- import { $ as SandboxRemovedError, B as SandboxCreateError, G as SandboxDriverRegistrationError, H as SandboxDriverLoadError, J as SandboxNotFoundError, K as SandboxMountError, Q as SandboxRegisterError, R as Redactor, U as SandboxDriverLoadPhase, V as SandboxDestroyError, W as SandboxDriverNotRegisteredError, X as SandboxReadError, Y as SandboxProviderError, Z as SandboxRefreshError, at as errors_d_exports, ct as providerErrorCause, et as SandboxStopError, it as SandboxWakeError, lt as providerErrorIsNotFound, nt as SandboxUnavailError, ot as makeRedactor, q as SandboxMustBeStoppedError, rt as SandboxUnsupportedError, st as providerError, tt as SandboxTransitionConflictError, ut as sanitizeError, z as SandboxBusyError } from "../io-BarV4hvG.mjs";
1
+ import { $ as SandboxRegisterError, B as SandboxBusyError, G as SandboxDriverNotRegisteredError, H as SandboxDestroyError, J as SandboxMustBeStoppedError, K as SandboxDriverRegistrationError, Q as SandboxRefreshError, U as SandboxDriverLoadError, V as SandboxCreateError, W as SandboxDriverLoadPhase, X as SandboxProviderError, Y as SandboxNotFoundError, Z as SandboxReadError, at as SandboxWakeError, ct as providerError, dt as sanitizeError, et as SandboxRemovedError, it as SandboxUnsupportedError, lt as providerErrorCause, nt as SandboxTransitionConflictError, ot as errors_d_exports, q as SandboxMountError, rt as SandboxUnavailError, st as makeRedactor, tt as SandboxStopError, ut as providerErrorIsNotFound, z as Redactor } from "../io-CXi2Sjg9.mjs";
2
2
  export { Redactor, SandboxBusyError, SandboxCreateError, SandboxDestroyError, SandboxDriverLoadError, SandboxDriverLoadPhase, SandboxDriverNotRegisteredError, SandboxDriverRegistrationError, errors_d_exports as SandboxError, SandboxMountError, SandboxMustBeStoppedError, SandboxNotFoundError, SandboxProviderError, SandboxReadError, SandboxRefreshError, SandboxRegisterError, SandboxRemovedError, SandboxStopError, SandboxTransitionConflictError, SandboxUnavailError, SandboxUnsupportedError, SandboxWakeError, makeRedactor, providerError, providerErrorCause, providerErrorIsNotFound, sanitizeError };
@@ -1,2 +1,2 @@
1
- import { Ct as toColumn, St as mountable, _t as Usage, bt as instance_d_exports, dt as ID, ft as Info, gt as Status, ht as PersistedError, mt as Ownership, pt as Kind, vt as fromColumn, wt as toField, xt as isMountable, yt as fromField } from "../io-BarV4hvG.mjs";
1
+ import { Ct as mountable, St as isMountable, Tt as toField, _t as Status, bt as fromField, ft as ID, gt as PersistedError, ht as Ownership, mt as Kind, pt as Info, vt as Usage, wt as toColumn, xt as instance_d_exports, yt as fromColumn } from "../io-CXi2Sjg9.mjs";
2
2
  export { ID, Info, Kind, Ownership, PersistedError, instance_d_exports as SandboxInstance, Status, Usage, fromColumn, fromField, isMountable, mountable, toColumn, toField };
package/sandbox/io.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as Mutation, c as host, d as io_d_exports, f as mount, g as withMutation, h as virtual, i as Layer, l as hostLayer, m as resolveMountCwd, n as FileSystem, o as Provides, p as remote, r as Identity, s as Shell, t as Current, u as identityLayer } from "../io-BarV4hvG.mjs";
2
- export { Current, FileSystem, Identity, Layer, Mutation, Provides, io_d_exports as SandboxIO, Shell, host, hostLayer, identityLayer, mount, remote, resolveMountCwd, virtual, withMutation };
1
+ import { _ as withMutation, a as Layer, c as Shell, d as identityLayer, f as io_d_exports, g as virtual, h as resolveMountCwd, i as Identity, l as host, m as remote, n as DEFAULT_SPILL_PATH, o as Mutation, p as mount, r as FileSystem, s as Provides, t as Current, u as hostLayer } from "../io-CXi2Sjg9.mjs";
2
+ export { Current, DEFAULT_SPILL_PATH, FileSystem, Identity, Layer, Mutation, Provides, io_d_exports as SandboxIO, Shell, host, hostLayer, identityLayer, mount, remote, resolveMountCwd, virtual, withMutation };
package/sandbox/io.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
  import "./instance.mjs";
2
- import { a as host, c as io_exports, d as resolveMountCwd, f as virtual, i as Shell, l as mount, n as FileSystem, o as hostLayer, p as withMutation, r as Mutation, s as identityLayer, t as Current, u as remote } from "../io-CFWrEV0O.mjs";
3
- export { Current, FileSystem, Mutation, io_exports as SandboxIO, Shell, host, hostLayer, identityLayer, mount, remote, resolveMountCwd, virtual, withMutation };
2
+ import { a as Shell, c as identityLayer, d as remote, f as resolveMountCwd, i as Mutation, l as io_exports, m as withMutation, n as DEFAULT_SPILL_PATH, o as host, p as virtual, r as FileSystem, s as hostLayer, t as Current, u as mount } from "../io-RvZvG-4N.mjs";
3
+ export { Current, DEFAULT_SPILL_PATH, FileSystem, Mutation, io_exports as SandboxIO, Shell, host, hostLayer, identityLayer, mount, remote, resolveMountCwd, virtual, withMutation };
package/sandbox.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as RuntimeInput, C as ModuleDefinition, E as Provisioned, M as apiVersion, N as defineModule, O as Registration, P as driver, R as Redactor, S as Module, T as Observed, Y as SandboxProviderError, _ as AbsolutePath, a as Mutation, b as Definition, bt as instance_d_exports, ct as providerErrorCause, g as withMutation, i as Layer, k as RuntimeConfigBase, lt as providerErrorIsNotFound, n as FileSystem, o as Provides, ot as makeRedactor, r as Identity, s as Shell, st as providerError, t as Current, ut as sanitizeError, v as ApiVersion, w as Name, x as Driver, y as Capabilities } from "./io-BarV4hvG.mjs";
1
+ import { A as RuntimeConfigBase, C as Module, D as Provisioned, E as Observed, F as driver, N as apiVersion, P as defineModule, S as Driver, T as Name, X as SandboxProviderError, _ as withMutation, a as Layer, b as Capabilities, c as Shell, ct as providerError, dt as sanitizeError, i as Identity, j as RuntimeInput, k as Registration, lt as providerErrorCause, n as DEFAULT_SPILL_PATH, o as Mutation, r as FileSystem, s as Provides, st as makeRedactor, t as Current, ut as providerErrorIsNotFound, v as AbsolutePath, w as ModuleDefinition, x as Definition, xt as instance_d_exports, y as ApiVersion, z as Redactor } from "./io-CXi2Sjg9.mjs";
2
2
  import { c as filesystem_d_exports } from "./filesystem-BYaEdL14.mjs";
3
3
  import { a as ShellError, i as Shell$1, l as quote, n as ExecResult, o as ShellOptions, r as ISandboxExe, s as fromExec, t as ExecChunk, u as quoteArgv } from "./shell-CZ6Y4lNU.mjs";
4
4
  import { SandboxResource as resource_d_exports } from "./sandbox/resource.mjs";
@@ -6,7 +6,7 @@ declare namespace driver_d_exports {
6
6
  export { AbsolutePath, ApiVersion, Capabilities, Definition, Driver, Module, ModuleDefinition, Name, Observed, Provisioned, Registration, RuntimeConfigBase as RuntimeConfig, RuntimeConfigBase, RuntimeInput, driver_d_exports as SandboxDriver, apiVersion, driver, defineModule as module };
7
7
  }
8
8
  declare namespace io_d_exports {
9
- export { Current, FileSystem, Identity, Layer, Mutation, Provides, io_d_exports as SandboxIO, Shell, withMutation };
9
+ export { Current, DEFAULT_SPILL_PATH, FileSystem, Identity, Layer, Mutation, Provides, io_d_exports as SandboxIO, Shell, withMutation };
10
10
  }
11
11
  declare namespace provider_d_exports {
12
12
  export { Redactor, SandboxProviderError, makeRedactor, providerError, providerErrorCause, providerErrorIsNotFound, sanitizeError };
package/sandbox.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { SandboxInstance as instance_exports } from "./sandbox/instance.mjs";
3
3
  import { i as filesystem_exports } from "./filesystem-BFCKzgND.mjs";
4
- import { i as Shell, n as FileSystem, p as withMutation, r as Mutation, t as Current } from "./io-CFWrEV0O.mjs";
4
+ import { a as Shell, i as Mutation, m as withMutation, n as DEFAULT_SPILL_PATH, r as FileSystem, t as Current } from "./io-RvZvG-4N.mjs";
5
5
  import { Shell as Shell$1, ShellError, fromExec, quote, quoteArgv } from "./sandbox/shell.mjs";
6
6
  import { AbsolutePath, Name, RuntimeConfigBase, driver, module as defineModule } from "./sandbox/driver.mjs";
7
7
  import { SandboxProviderError, makeRedactor, providerError, providerErrorCause, providerErrorIsNotFound, sanitizeError } from "./sandbox/errors.mjs";
@@ -20,6 +20,7 @@ var driver_exports = /* @__PURE__ */ __exportAll({
20
20
  //#region src/sandbox/public/io.ts
21
21
  var io_exports = /* @__PURE__ */ __exportAll({
22
22
  Current: () => Current,
23
+ DEFAULT_SPILL_PATH: () => DEFAULT_SPILL_PATH,
23
24
  FileSystem: () => FileSystem,
24
25
  Mutation: () => Mutation,
25
26
  SandboxIO: () => io_exports,
package/sandbox.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"sandbox.mjs","names":[],"sources":["../../src/sandbox/public/driver.ts","../../src/sandbox/public/io.ts","../../src/sandbox/provider.ts","../../src/sandbox/public/shell.ts"],"sourcesContent":["export { AbsolutePath, apiVersion, driver, module, Name, RuntimeConfigBase } from \"../driver.ts\";\nexport type {\n\tApiVersion,\n\tCapabilities,\n\tDefinition,\n\tDriver,\n\tModule,\n\tModuleDefinition,\n\tObserved,\n\tProvisioned,\n\tRegistration,\n\tRuntimeConfigBase as RuntimeConfig,\n\tRuntimeInput,\n} from \"../driver.ts\";\n\nexport * as SandboxDriver from \"./driver.ts\";\n","export { Current, FileSystem, Mutation, Shell, withMutation } from \"../io.ts\";\nexport type { Identity, Layer, Provides } from \"../io.ts\";\n\nexport * as SandboxIO from \"./io.ts\";\n","export {\n\tmakeRedactor,\n\tproviderError,\n\tproviderErrorCause,\n\tproviderErrorIsNotFound,\n\tSandboxProviderError,\n\tsanitizeError,\n} from \"./errors.ts\";\nexport type { Redactor } from \"./errors.ts\";\n","export { fromExec, quote, quoteArgv, Shell, ShellError } from \"../shell.ts\";\nexport type { ExecChunk, ExecResult, ISandboxExe, ShellOptions } from \"../shell.ts\";\n"],"mappings":""}
1
+ {"version":3,"file":"sandbox.mjs","names":[],"sources":["../../src/sandbox/public/driver.ts","../../src/sandbox/public/io.ts","../../src/sandbox/provider.ts","../../src/sandbox/public/shell.ts"],"sourcesContent":["export { AbsolutePath, apiVersion, driver, module, Name, RuntimeConfigBase } from \"../driver.ts\";\nexport type {\n\tApiVersion,\n\tCapabilities,\n\tDefinition,\n\tDriver,\n\tModule,\n\tModuleDefinition,\n\tObserved,\n\tProvisioned,\n\tRegistration,\n\tRuntimeConfigBase as RuntimeConfig,\n\tRuntimeInput,\n} from \"../driver.ts\";\n\nexport * as SandboxDriver from \"./driver.ts\";\n","export { Current, DEFAULT_SPILL_PATH, FileSystem, Mutation, Shell, withMutation } from \"../io.ts\";\nexport type { Identity, Layer, Provides } from \"../io.ts\";\n\nexport * as SandboxIO from \"./io.ts\";\n","export {\n\tmakeRedactor,\n\tproviderError,\n\tproviderErrorCause,\n\tproviderErrorIsNotFound,\n\tSandboxProviderError,\n\tsanitizeError,\n} from \"./errors.ts\";\nexport type { Redactor } from \"./errors.ts\";\n","export { fromExec, quote, quoteArgv, Shell, ShellError } from \"../shell.ts\";\nexport type { ExecChunk, ExecResult, ISandboxExe, ShellOptions } from \"../shell.ts\";\n"],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"io-CFWrEV0O.mjs","names":["SandboxFileSystem.Service","ShellTag","SandboxMutation.Service","EffectLayer","SandboxMutation.make","SandboxFileSystem.withCwd","shellWithCwd"],"sources":["../../src/sandbox/mutation.ts","../../src/sandbox/io.ts"],"sourcesContent":["import { Context, Deferred, Effect } from \"effect\";\nimport { posix } from \"../posix.ts\";\nimport { type FileSystemError, type Interface as FileSystem, isNotFoundError } from \"./filesystem.ts\";\nimport type { SandboxInstance } from \"./instance.ts\";\n\n/**\n * Serializes mutations of one file.\n *\n * Tool calls may run in parallel, and a file-mutating tool does read → modify →\n * write. Two of those on one file interleave and the first write is lost, so a\n * tool holds the file for its whole read-modify-write.\n *\n * A file is its sandbox instance plus its canonical path: two mounts of one\n * instance share files, and a symlinked spelling of a path is the same file.\n * Other files never wait. This orders the harness's own tools within this\n * process only; it is not a lock against `bash` or other processes.\n */\nexport interface Interface {\n\t/**\n\t * Run `effect` as the only mutation of `path` in flight. Calls queue in the\n\t * order their paths resolve, which for one spelling is the order they were made.\n\t */\n\treadonly withFile: <A, E, R>(\n\t\tpath: string,\n\t\teffect: Effect.Effect<A, E, R>,\n\t) => Effect.Effect<A, E | FileSystemError, R>;\n}\n\nexport class Service extends Context.Service<Service, Interface>()(\"@codeworksh/plugin/sandbox/mutation/Service\") {}\n\ninterface Lock {\n\treadonly waiters: Array<Deferred.Deferred<void>>;\n}\n\n// Process-wide on purpose: every mount of one instance must meet in the same\n// queue, whichever layer built it. A key is present exactly while its file is held.\nconst locks = new Map<string, Lock>();\n\n/** Hand the file to the next waiter, or free it. Ownership moves directly, so no newcomer can barge in. */\nconst release = (key: string, lock: Lock): void => {\n\tconst next = lock.waiters.shift();\n\tif (next === undefined) locks.delete(key);\n\telse Deferred.doneUnsafe(next, Effect.void);\n};\n\n/** Take the file, waiting interruptibly; must run uninterruptibly so taking and releasing pair up. */\nconst acquire = (key: string, restore: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>) =>\n\tEffect.suspend(() => {\n\t\tconst lock = locks.get(key);\n\t\tif (lock === undefined) {\n\t\t\tlocks.set(key, { waiters: [] });\n\t\t\treturn Effect.void;\n\t\t}\n\t\tconst turn = Deferred.makeUnsafe<void>();\n\t\tlock.waiters.push(turn);\n\t\treturn restore(Deferred.await(turn)).pipe(\n\t\t\tEffect.onInterrupt(() =>\n\t\t\t\tEffect.sync(() => {\n\t\t\t\t\tconst index = lock.waiters.indexOf(turn);\n\t\t\t\t\t// Still queued: leave. Already handed the file: pass it on.\n\t\t\t\t\tif (index !== -1) lock.waiters.splice(index, 1);\n\t\t\t\t\telse release(key, lock);\n\t\t\t\t}),\n\t\t\t),\n\t\t);\n\t});\n\n/**\n * The canonical path. A file that does not exist yet takes its canonical\n * parent joined with its name, walking up as far as needed, so a write that\n * creates a file (and its directories) shares a key with later mutations of it.\n */\nconst canonical = (fs: FileSystem, path: string): Effect.Effect<string, FileSystemError> =>\n\tfs.realpath(path).pipe(\n\t\tEffect.catchIf(\n\t\t\t(error) => isNotFoundError(error.cause),\n\t\t\t(error) => {\n\t\t\t\tconst parent = posix.dirname(path);\n\t\t\t\tif (parent === path) return Effect.fail(error);\n\t\t\t\treturn Effect.map(canonical(fs, parent), (resolved) => posix.join(resolved, posix.basename(path)));\n\t\t\t},\n\t\t),\n\t);\n\nexport const make = (instance: SandboxInstance.ID, cwd: string, fs: FileSystem): Interface => ({\n\twithFile: (path, effect) =>\n\t\tEffect.flatMap(canonical(fs, posix.resolve(cwd, path)), (resolved) => {\n\t\t\tconst key = `${instance}\\0${resolved}`;\n\t\t\t// Held from the moment `acquire` returns: nothing can interrupt between\n\t\t\t// taking the file and installing its release.\n\t\t\treturn Effect.uninterruptibleMask((restore) =>\n\t\t\t\tEffect.andThen(\n\t\t\t\t\tacquire(key, restore),\n\t\t\t\t\trestore(effect).pipe(\n\t\t\t\t\t\tEffect.ensuring(\n\t\t\t\t\t\t\tEffect.sync(() => {\n\t\t\t\t\t\t\t\tconst lock = locks.get(key);\n\t\t\t\t\t\t\t\tif (lock !== undefined) release(key, lock);\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t);\n\t\t}),\n});\n\nexport * as SandboxMutation from \"./mutation.ts\";\n","import { Context, Effect, Layer as EffectLayer } from \"effect\";\nimport { posix } from \"../posix.ts\";\nimport type { SandboxDriver } from \"./driver.ts\";\nimport { SandboxFileSystem } from \"./filesystem.ts\";\nimport { SandboxInstance } from \"./instance.ts\";\nimport { SandboxMutation } from \"./mutation.ts\";\nimport { type ISandboxExe, Shell as ShellTag, withCwd as shellWithCwd } from \"./shell.ts\";\n\n/**\n * `SandboxIO` is a **mount**: a filesystem, a shell, and the identity and\n * working directory they act on.\n *\n * It is the whole vocabulary a consumer needs. Project, Git, Copy, Location, and\n * every tool ask for `SandboxIO.FileSystem`, `SandboxIO.Shell`, and\n * `SandboxIO.Current` — never for a driver, an address, or a provider SDK — so\n * a host directory, an in-memory VFS, and a remote microVM are interchangeable\n * behind one contract.\n *\n * The mount neither creates nor destroys infrastructure. `SandboxInstance` is\n * the durable namespace it acts on — a device, which exists whether or not\n * anything has it mounted — and `Sandbox.Controller` is the only path that\n * creates, stops, or destroys one.\n */\n\n/**\n * The filesystem tag. Re-exported here so consumers import one namespace —\n * Project, Git, Copy, and the runner ask for `SandboxIO.FileSystem`, never for\n * the module that happens to define it. Code *inside* `sandbox/` keeps importing\n * the tag directly, since `io.ts` is built on top of it.\n */\nexport const FileSystem = SandboxFileSystem.Service;\nexport type FileSystem = SandboxFileSystem.Service;\n\n/** The shell tag. Re-exported here so consumers import one namespace. */\nexport const Shell = ShellTag;\nexport type Shell = ShellTag;\n\n/** Per-file mutation ordering for this mount's instance. Re-exported here so consumers import one namespace. */\nexport const Mutation = SandboxMutation.Service;\nexport type Mutation = SandboxMutation.Service;\n\n/**\n * What a mount sees: immutable identity, plus the working directory resolved for\n * *this* mount.\n *\n * Nothing mutable belongs here. `status`, `usage`, and reference counts all\n * change while a mount is open, so a mount-time snapshot of them would be wrong\n * by construction — runtime code that needs live management state asks the\n * control plane. The driver's own resource locator is likewise absent: consumers\n * never parse a Vercel name or a Daytona id.\n */\nexport interface Identity {\n\treadonly id: SandboxInstance.ID;\n\treadonly driver: SandboxDriver.Name;\n\treadonly kind: SandboxInstance.Kind;\n\t/** Absolute, and always a path in *this* namespace. */\n\treadonly cwd: string;\n}\n\n/** Identity and working directory of the current mount. */\nexport class Current extends Context.Service<Current, Identity>()(\"@codeworksh/plugin/sandbox/io/Current\") {}\n\n/** Everything a mount provides. */\nexport type Provides = Current | SandboxFileSystem.Service | ShellTag | SandboxMutation.Service;\n\n/** A built mount. */\nexport type Layer<E = never, RIn = never> = EffectLayer.Layer<Provides, E, RIn>;\n\n/**\n * Resolve a mount's cwd without consulting ambient process state.\n *\n * The default is supplied by the namespace adapter:\n * provider metadata remotely, `/` for a virtual filesystem, and `process.cwd()` for the host adapter.\n * An explicit absolute cwd replaces it; a relative cwd is resolved inside it. The\n * result is therefore always the one concrete absolute path `Current` requires.\n *\n * A non-absolute default throws rather than failing typed. It is the one\n * defect-level guard in this module, and deliberately so:\n * Adapters reading a value from a provider call this inside their own error channel,\n * where the throw becomes their typed failure (see `EnvDaytona.mountCwd`).\n */\nexport const resolveMountCwd = (defaultCwd: string, cwd?: string): string => {\n\tif (!posix.isAbsolute(defaultCwd)) {\n\t\tthrow new TypeError(`Sandbox default cwd must be absolute: ${defaultCwd}`);\n\t}\n\t// `resolve`, not `normalize`: normalize keeps a trailing slash, and `cwd` is\n\t// persisted — `space.location` and its id hash would read\n\t// `/workspace/` and `/workspace` as two directories and keep a row for each.\n\t//\n\t// A provider-reported default (`getWorkDir()`) or a config value is free to\n\t// carry one, so it is stripped here rather than at every reader.\n\tif (cwd === undefined) return posix.resolve(defaultCwd);\n\treturn posix.isAbsolute(cwd) ? posix.resolve(cwd) : posix.resolve(defaultCwd, cwd);\n};\n\n/**\n * Complete a mount with its {@link Mutation} queue, derived from the mount's own\n * identity and filesystem. Every layer that provides a mount goes through here,\n * so mounts of one instance always meet in the same queue.\n */\nexport const withMutation = <E, R>(\n\tlayer: EffectLayer.Layer<Current | SandboxFileSystem.Service | ShellTag, E, R>,\n): EffectLayer.Layer<Provides, E, R> =>\n\tEffectLayer.provideMerge(\n\t\tEffectLayer.effect(\n\t\t\tMutation,\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst current = yield* Current;\n\t\t\t\treturn SandboxMutation.make(current.id, current.cwd, yield* SandboxFileSystem.Service);\n\t\t\t}),\n\t\t),\n\t\tlayer,\n\t);\n\n/**\n * Bind a cwd-neutral transport to one mount.\n *\n * The transport underneath is shared between\n * mounts and stays rooted at the namespace root, and everything directory-shaped\n * happens here, once per mount. Two mounts of one namespace at different working\n * directories therefore coexist without seeing or moving each other's.\n *\n * It consumes the same two tags it provides — the transport is supplied by the\n * layer this is composed over, not by itself.\n */\nexport const mount = (identity: Identity): EffectLayer.Layer<Provides, never, SandboxFileSystem.Service | ShellTag> =>\n\tEffectLayer.mergeAll(\n\t\tEffectLayer.succeed(Current, identity),\n\t\tEffectLayer.effect(\n\t\t\tSandboxFileSystem.Service,\n\t\t\tEffect.map(SandboxFileSystem.Service, (fs) => SandboxFileSystem.withCwd(fs, identity.cwd)),\n\t\t),\n\t\tEffectLayer.effect(\n\t\t\tShellTag,\n\t\t\tEffect.map(ShellTag, (shell: ISandboxExe) => shellWithCwd(shell, identity.cwd)),\n\t\t),\n\t).pipe(withMutation);\n\n/**\n * Just the identity tag, with no filesystem or shell beneath it. For consumers\n * assembled from stubs — a test that runs `Project` over a fake filesystem still\n * needs to know which namespace it is in.\n */\nexport const identityLayer = (identity: Identity) => EffectLayer.succeed(Current, identity);\n\n/** The host identity alone. See {@link identityLayer}. */\nexport const hostLayer = (cwd: string) => identityLayer(host(cwd));\n\n/**\n * The host, rooted at `cwd`. Always `SandboxInstance.ID.local`: the working\n * directory selects where relative paths resolve, it does not make a second host\n * namespace — two mounts rooted at different directories still agree on absolute\n * paths.\n *\n * The host coordinate is explicit so a caller cannot accidentally substitute ambient process\n * state for the application or session directory it owns.\n */\nexport const host = (cwd: string): Identity => ({\n\tid: SandboxInstance.ID.local,\n\tdriver: \"local\" as SandboxDriver.Name,\n\tkind: \"local\",\n\tcwd: resolveMountCwd(cwd),\n});\n\n/**\n * A VFS-backed namespace. The id is minted per call unless one is named, because\n * building one of these builds a fresh VFS: N unnamed calls are N distinct\n * namespaces, none of which outlives the process. A file-backed store is the\n * exception — its file is the state, so whoever knows the file supplies the id\n * it was registered under.\n */\nexport const virtual = (input: {\n\treadonly driver: string;\n\treadonly id?: SandboxInstance.ID;\n\treadonly defaultCwd?: string;\n\treadonly cwd?: string;\n}): Identity => ({\n\tid: input.id ?? SandboxInstance.ID.create(),\n\tdriver: input.driver as SandboxDriver.Name,\n\tkind: \"virtual\",\n\tcwd: resolveMountCwd(input.defaultCwd ?? \"/\", input.cwd),\n});\n\n/**\n * A provider-hosted namespace. The id is always supplied: a remote resource's\n * durable identity is minted and recorded by whoever provisioned it, never\n * derived here from the provider's own locator.\n */\nexport const remote = (input: {\n\treadonly driver: string;\n\treadonly id: SandboxInstance.ID;\n\t/** Namespace-intrinsic default supplied or discovered by the driver. */\n\treadonly defaultCwd: string;\n\treadonly cwd?: string;\n}): Identity => ({\n\tid: input.id,\n\tdriver: input.driver as SandboxDriver.Name,\n\tkind: \"remote\",\n\tcwd: resolveMountCwd(input.defaultCwd, input.cwd),\n});\n\nexport * as SandboxIO from \"./io.ts\";\n"],"mappings":"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"}