@codeworksh/plugin 0.1.0-dev.20261007133154 → 0.2.0-canary.8.1.g763b062a

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"io-Dgh8U41k.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":";;;;;;;AA4BA,IAAa,UAAb,cAA6B,QAAQ,QAA4B,CAAC,CAAC,6CAA6C,CAAC,CAAC,CAAC;AAQnH,MAAM,wBAAQ,IAAI,IAAkB;;AAGpC,MAAM,WAAW,KAAa,SAAqB;CAClD,MAAM,OAAO,KAAK,QAAQ,MAAM;CAChC,IAAI,SAAS,KAAA,GAAW,MAAM,OAAO,GAAG;MACnC,SAAS,WAAW,MAAM,OAAO,IAAI;AAC3C;;AAGA,MAAM,WAAW,KAAa,YAC7B,OAAO,cAAc;CACpB,MAAM,OAAO,MAAM,IAAI,GAAG;CAC1B,IAAI,SAAS,KAAA,GAAW;EACvB,MAAM,IAAI,KAAK,EAAE,SAAS,CAAC,EAAE,CAAC;EAC9B,OAAO,OAAO;CACf;CACA,MAAM,OAAO,SAAS,WAAiB;CACvC,KAAK,QAAQ,KAAK,IAAI;CACtB,OAAO,QAAQ,SAAS,MAAM,IAAI,CAAC,CAAC,CAAC,KACpC,OAAO,kBACN,OAAO,WAAW;EACjB,MAAM,QAAQ,KAAK,QAAQ,QAAQ,IAAI;EAEvC,IAAI,UAAU,IAAI,KAAK,QAAQ,OAAO,OAAO,CAAC;OACzC,QAAQ,KAAK,IAAI;CACvB,CAAC,CACF,CACD;AACD,CAAC;;;;;;AAOF,MAAM,aAAa,IAAgB,SAClC,GAAG,SAAS,IAAI,CAAC,CAAC,KACjB,OAAO,SACL,UAAU,gBAAgB,MAAM,KAAK,IACrC,UAAU;CACV,MAAM,SAAS,MAAM,QAAQ,IAAI;CACjC,IAAI,WAAW,MAAM,OAAO,OAAO,KAAK,KAAK;CAC7C,OAAO,OAAO,IAAI,UAAU,IAAI,MAAM,IAAI,aAAa,MAAM,KAAK,UAAU,MAAM,SAAS,IAAI,CAAC,CAAC;AAClG,CACD,CACD;AAED,MAAa,QAAQ,UAA8B,KAAa,QAA+B,EAC9F,WAAW,MAAM,WAChB,OAAO,QAAQ,UAAU,IAAI,MAAM,QAAQ,KAAK,IAAI,CAAC,IAAI,aAAa;CACrE,MAAM,MAAM,GAAG,SAAS,IAAI;CAG5B,OAAO,OAAO,qBAAqB,YAClC,OAAO,QACN,QAAQ,KAAK,OAAO,GACpB,QAAQ,MAAM,CAAC,CAAC,KACf,OAAO,SACN,OAAO,WAAW;EACjB,MAAM,OAAO,MAAM,IAAI,GAAG;EAC1B,IAAI,SAAS,KAAA,GAAW,QAAQ,KAAK,IAAI;CAC1C,CAAC,CACF,CACD,CACD,CACD;AACD,CAAC,EACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC1EA,MAAa,aAAaA;;AAI1B,MAAa,QAAQC;;AAIrB,MAAa,WAAWC;;AAwBxB,MAAa,qBAAqB;;AAGlC,IAAa,UAAb,cAA6B,QAAQ,QAA2B,CAAC,CAAC,uCAAuC,CAAC,CAAC,CAAC;;;;;;;;;;;;;;AAqB5G,MAAa,mBAAmB,YAAoB,QAAyB;CAC5E,IAAI,CAAC,MAAM,WAAW,UAAU,GAC/B,MAAM,IAAI,UAAU,yCAAyC,YAAY;CAQ1E,IAAI,QAAQ,KAAA,GAAW,OAAO,MAAM,QAAQ,UAAU;CACtD,OAAO,MAAM,WAAW,GAAG,IAAI,MAAM,QAAQ,GAAG,IAAI,MAAM,QAAQ,YAAY,GAAG;AAClF;;;;;;AAOA,MAAa,gBACZ,UAEAC,MAAY,aACXA,MAAY,OACX,UACA,OAAO,IAAI,aAAa;CACvB,MAAM,UAAU,OAAO;CACvB,OAAOC,KAAqB,QAAQ,IAAI,QAAQ,KAAK,OAAOJ,SAAyB;AACtF,CAAC,CACF,GACA,KACD;;;;;;;;;;;;AAaD,MAAa,SAAS,aACrBG,MAAY,SACXA,MAAY,QAAQ,SAAS,QAAQ,GACrCA,MAAY,OACXH,WACA,OAAO,IAAIA,YAA4B,OAAOK,QAA0B,IAAI,SAAS,GAAG,CAAC,CAC1F,GACAF,MAAY,OACXF,SACA,OAAO,IAAIA,UAAW,UAAuBK,UAAa,OAAO,SAAS,GAAG,CAAC,CAC/E,CACD,CAAC,CAAC,KAAK,YAAY;;;;;;AAOpB,MAAa,iBAAiB,aAAuBH,MAAY,QAAQ,SAAS,QAAQ;;AAG1F,MAAa,aAAa,QAAgB,cAAc,KAAK,GAAG,CAAC;;;;;;;;;;AAWjE,MAAa,QAAQ,SAA2B;CAC/C,IAAA,GAAuB;CACvB,QAAQ;CACR,MAAM;CACN,KAAK,gBAAgB,GAAG;CACxB,WAAW;AACZ;;;;;;;;AASA,MAAa,WAAW,WAMP;CAChB,IAAI,MAAM,MAAA,GAAyB,OAAO;CAC1C,QAAQ,MAAM;CACd,MAAM;CACN,KAAK,gBAAgB,MAAM,cAAc,KAAK,MAAM,GAAG;CACvD,WAAW,MAAM,aAAA;AAClB;;;;;;AAOA,MAAa,UAAU,WAQN;CAChB,IAAI,MAAM;CACV,QAAQ,MAAM;CACd,MAAM;CACN,KAAK,gBAAgB,MAAM,YAAY,MAAM,GAAG;CAChD,WAAW,MAAM,aAAA;AAClB"}
@@ -1,4 +1,4 @@
1
- import { c as filesystem_d_exports, s as Service } from "./filesystem-Cp-KapCE.mjs";
1
+ import { c as filesystem_d_exports, n as FileSystemError, r as Interface$1, s as Service$1 } from "./filesystem-CuGE9poU.mjs";
2
2
  import { i as Shell$1 } from "./shell-CZ6Y4lNU.mjs";
3
3
  import { Context, Effect, Layer, Option, Schema } from "effect";
4
4
  declare namespace instance_d_exports {
@@ -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 {
@@ -370,8 +372,33 @@ declare const defineModule: <Options>(value: ModuleDefinition<Options>) => Modul
370
372
  declare const driver: <CreateConfig, RuntimeConfig extends RuntimeConfigBase>(value: Driver<CreateConfig, RuntimeConfig>) => Driver<CreateConfig, RuntimeConfig> & Registration;
371
373
  /** Attach trusted origin metadata without changing the driver implementation. */
372
374
  declare const withSource: (registration: Registration, source: Source) => Registration;
375
+ declare namespace mutation_d_exports {
376
+ export { Interface, mutation_d_exports as SandboxMutation, Service, make };
377
+ }
378
+ /**
379
+ * Serializes mutations of one file.
380
+ *
381
+ * Tool calls may run in parallel, and a file-mutating tool does read → modify →
382
+ * write. Two of those on one file interleave and the first write is lost, so a
383
+ * tool holds the file for its whole read-modify-write.
384
+ *
385
+ * A file is its sandbox instance plus its canonical path: two mounts of one
386
+ * instance share files, and a symlinked spelling of a path is the same file.
387
+ * Other files never wait. This orders the harness's own tools within this
388
+ * process only; it is not a lock against `bash` or other processes.
389
+ */
390
+ interface Interface {
391
+ /**
392
+ * Run `effect` as the only mutation of `path` in flight. Calls queue in the
393
+ * order their paths resolve, which for one spelling is the order they were made.
394
+ */
395
+ readonly withFile: <A, E, R>(path: string, effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E | FileSystemError, R>;
396
+ }
397
+ declare const Service_base: Context.ServiceClass<Service, "@codeworksh/plugin/sandbox/mutation/Service", Interface>;
398
+ declare class Service extends Service_base {}
399
+ declare const make: (instance: ID, cwd: string, fs: Interface$1) => Interface;
373
400
  declare namespace io_d_exports {
374
- export { Current, FileSystem, Identity, Layer$1 as Layer, Provides, io_d_exports as SandboxIO, Shell, host, hostLayer, identityLayer, mount, remote, resolveMountCwd, virtual };
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 };
375
402
  }
376
403
  /**
377
404
  * `SandboxIO` is a **mount**: a filesystem, a shell, and the identity and
@@ -394,11 +421,14 @@ declare namespace io_d_exports {
394
421
  * the module that happens to define it. Code *inside* `sandbox/` keeps importing
395
422
  * the tag directly, since `io.ts` is built on top of it.
396
423
  */
397
- declare const FileSystem: typeof Service;
398
- type FileSystem = Service;
424
+ declare const FileSystem: typeof Service$1;
425
+ type FileSystem = Service$1;
399
426
  /** The shell tag. Re-exported here so consumers import one namespace. */
400
427
  declare const Shell: typeof Shell$1;
401
428
  type Shell = Shell$1;
429
+ /** Per-file mutation ordering for this mount's instance. Re-exported here so consumers import one namespace. */
430
+ declare const Mutation: typeof Service;
431
+ type Mutation = Service;
402
432
  /**
403
433
  * What a mount sees: immutable identity, plus the working directory resolved for
404
434
  * *this* mount.
@@ -415,12 +445,16 @@ interface Identity {
415
445
  readonly kind: Kind;
416
446
  /** Absolute, and always a path in *this* namespace. */
417
447
  readonly cwd: string;
448
+ /** Directory, in this namespace, that oversized tool output is written to. */
449
+ readonly spillPath: string;
418
450
  }
451
+ /** Spill directory for a driver that configures none. */
452
+ declare const DEFAULT_SPILL_PATH = "/tmp";
419
453
  declare const Current_base: Context.ServiceClass<Current, "@codeworksh/plugin/sandbox/io/Current", Identity>;
420
454
  /** Identity and working directory of the current mount. */
421
455
  declare class Current extends Current_base {}
422
456
  /** Everything a mount provides. */
423
- type Provides = Current | Service | Shell$1;
457
+ type Provides = Current | Service$1 | Shell$1 | Service;
424
458
  /** A built mount. */
425
459
  type Layer$1<E = never, RIn = never> = Layer.Layer<Provides, E, RIn>;
426
460
  /**
@@ -437,6 +471,12 @@ type Layer$1<E = never, RIn = never> = Layer.Layer<Provides, E, RIn>;
437
471
  * where the throw becomes their typed failure (see `EnvDaytona.mountCwd`).
438
472
  */
439
473
  declare const resolveMountCwd: (defaultCwd: string, cwd?: string) => string;
474
+ /**
475
+ * Complete a mount with its {@link Mutation} queue, derived from the mount's own
476
+ * identity and filesystem. Every layer that provides a mount goes through here,
477
+ * so mounts of one instance always meet in the same queue.
478
+ */
479
+ declare const withMutation: <E, R>(layer: Layer.Layer<Current | Service$1 | Shell$1, E, R>) => Layer.Layer<Provides, E, R>;
440
480
  /**
441
481
  * Bind a cwd-neutral transport to one mount.
442
482
  *
@@ -448,7 +488,7 @@ declare const resolveMountCwd: (defaultCwd: string, cwd?: string) => string;
448
488
  * It consumes the same two tags it provides — the transport is supplied by the
449
489
  * layer this is composed over, not by itself.
450
490
  */
451
- declare const mount: (identity: Identity) => Layer.Layer<Provides, never, Service | Shell$1>;
491
+ declare const mount: (identity: Identity) => Layer.Layer<Provides, never, Service$1 | Shell$1>;
452
492
  /**
453
493
  * Just the identity tag, with no filesystem or shell beneath it. For consumers
454
494
  * assembled from stubs — a test that runs `Project` over a fake filesystem still
@@ -479,6 +519,7 @@ declare const virtual: (input: {
479
519
  readonly id?: ID;
480
520
  readonly defaultCwd?: string;
481
521
  readonly cwd?: string;
522
+ readonly spillPath?: string;
482
523
  }) => Identity;
483
524
  /**
484
525
  * A provider-hosted namespace. The id is always supplied: a remote resource's
@@ -491,7 +532,9 @@ declare const remote: (input: {
491
532
  /** Namespace-intrinsic default supplied or discovered by the driver. */
492
533
  readonly defaultCwd: string;
493
534
  readonly cwd?: string;
535
+ /** Namespace-intrinsic spill directory configured by the driver. */
536
+ readonly spillPath?: string;
494
537
  }) => Identity;
495
538
  //#endregion
496
- export { SandboxTransitionConflictError as $, apiVersion as A, SandboxDriverLoadError as B, Observed as C, RuntimeConfigBase as D, Registration as E, withSource as F, SandboxMustBeStoppedError as G, SandboxDriverNotRegisteredError as H, Redactor as I, SandboxReadError as J, SandboxNotFoundError as K, SandboxBusyError as L, driver as M, driver_d_exports as N, RuntimeInput as O, erase as P, SandboxStopError as Q, SandboxCreateError as R, Name as S, toField as St, Registered as T, SandboxDriverRegistrationError as U, SandboxDriverLoadPhase as V, SandboxMountError as W, SandboxRegisterError as X, SandboxRefreshError as Y, SandboxRemovedError as Z, Capabilities as _, fromField as _t, Provides as a, providerError as at, Module as b, mountable as bt, hostLayer as c, sanitizeError as ct, mount as d, Kind as dt, SandboxUnavailError as et, remote as f, Ownership as ft, ApiVersion as g, fromColumn as gt, AbsolutePath as h, Usage as ht, Layer$1 as i, makeRedactor as it, defineModule as j, Source as k, identityLayer as l, ID as lt, virtual as m, Status as mt, FileSystem as n, SandboxWakeError as nt, Shell as o, providerErrorCause as ot, resolveMountCwd as p, PersistedError as pt, SandboxProviderError as q, Identity as r, errors_d_exports as rt, host as s, providerErrorIsNotFound as st, Current as t, SandboxUnsupportedError as tt, io_d_exports as u, Info as ut, Definition as v, instance_d_exports as vt, Provisioned as w, ModuleDefinition as x, toColumn as xt, Driver as y, isMountable as yt, SandboxDestroyError as z };
497
- //# sourceMappingURL=io-BYs7hbiY.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-nhvNKC33.d.mts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeworksh/plugin",
3
- "version": "0.1.0-dev.20261007133154",
3
+ "version": "0.2.0-canary.8.1.g763b062a",
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-dev.20261007132549",
171
+ "@codeworksh/aikit": "0.11.0-canary.8.1.g763b062a",
172
172
  "effect": "4.0.1"
173
173
  }
174
174
  }
package/plugin/tool.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as ToolAfterResult, c as ToolBeforeResult, d as ToolRegistry, f as ToolResultContent, i as ToolAfterFn, l as ToolDefPatch, n as ToolAddOptions, o as ToolBefore, r as ToolAfter, s as ToolBeforeFn, t as HookReturn, u as ToolRegistration } from "../tool-BoVqkYvL.mjs";
1
+ import { a as ToolAfterResult, c as ToolBeforeResult, d as ToolRegistry, f as ToolResultContent, i as ToolAfterFn, l as ToolDefPatch, n as ToolAddOptions, o as ToolBefore, r as ToolAfter, s as ToolBeforeFn, t as HookReturn, u as ToolRegistration } from "../tool-D4_I_rzy.mjs";
2
2
  export { HookReturn, ToolAddOptions, ToolAfter, ToolAfterFn, ToolAfterResult, ToolBefore, ToolBeforeFn, ToolBeforeResult, ToolDefPatch, ToolRegistration, ToolRegistry, ToolResultContent };
@@ -1,11 +1,11 @@
1
- import { i as Definition, o as Payload, r as Data, s as PublishOptions } from "./event-BnLveFBB.mjs";
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 { a as Provides, r as Identity, u as io_d_exports } from "./io-BYs7hbiY.mjs";
5
- import { i as Info$1 } from "./settings-B6-grSTA.mjs";
4
+ import { f as io_d_exports, i as Identity, s as Provides } from "./io-nhvNKC33.mjs";
5
+ import { i as Info$1 } from "./settings-47Mzxhl0.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";
8
- import { d as ToolRegistry, p as tool_d_exports } from "./tool-BoVqkYvL.mjs";
8
+ import { d as ToolRegistry, p as tool_d_exports } from "./tool-D4_I_rzy.mjs";
9
9
  import { Model } from "@codeworksh/aikit";
10
10
  import { Effect } from "effect";
11
11
  //#region src/plugin/registry.d.ts
@@ -37,10 +37,22 @@ interface Config {
37
37
  interface Events {
38
38
  readonly publish: <D extends Definition>(definition: D, data: Data<D>, options?: PublishOptions) => Effect.Effect<Payload<D>>;
39
39
  }
40
+ /**
41
+ * The harness's own directories on the host, all under its home (`--home`, `~/.codework` by
42
+ * default). App-level: the same for every session, and never a session's project or its sandbox.
43
+ */
44
+ interface Paths {
45
+ readonly home: string;
46
+ readonly bin: string;
47
+ readonly cache: string;
48
+ readonly data: string;
49
+ readonly log: string;
50
+ }
40
51
  /** One object, shared by every plugin in one exchange. */
41
52
  interface SharedPluginContext {
42
53
  readonly sessionId: SessionID;
43
54
  readonly sandbox: Identity;
55
+ readonly paths: Paths;
44
56
  readonly location: Info;
45
57
  readonly settings: Info$1;
46
58
  readonly model: Model.Info;
@@ -124,6 +136,11 @@ interface Plugin {
124
136
  * `plugin.<id>.*`.
125
137
  */
126
138
  readonly events?: ReadonlyArray<Definition>;
139
+ /**
140
+ * Off until a user asks for it. An `optIn` plugin is selected like any other but runs only
141
+ * when a settings entry turns it on: `{ "plugin": "<id>", "enabled": true }`.
142
+ */
143
+ readonly optIn?: boolean;
127
144
  /**
128
145
  * `options` is this plugin's own configuration block, `{}` when its entry carried none.
129
146
  * Unvalidated: the harness never looks inside it, so a plugin checks whatever shape it
@@ -134,8 +151,8 @@ interface Plugin {
134
151
  }
135
152
  declare const define: (plugin: Plugin) => Plugin;
136
153
  declare namespace plugin_d_exports {
137
- export { Config, Events, Mount, Plugin, PluginKind, PluginOptions, PluginPatch, PluginRef, PluginRegistry, PluginSpec, prompt_d_exports as Prompt, PromptResolver, section_d_exports as Section, SharedPluginContext, tool_d_exports as Tool, define, domains, rank };
154
+ export { Config, Events, Mount, Paths, Plugin, PluginKind, PluginOptions, PluginPatch, PluginRef, PluginRegistry, PluginSpec, prompt_d_exports as Prompt, PromptResolver, section_d_exports as Section, SharedPluginContext, tool_d_exports as Tool, define, domains, rank };
138
155
  }
139
156
  //#endregion
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-CLuLZhKa.d.mts.map
157
+ export { PluginRegistry as _, define as a, PluginOptions as c, PluginSpec as d, Config as f, SharedPluginContext as g, PromptResolver as h, PluginKind as i, PluginPatch as l, Paths 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 };
158
+ //# sourceMappingURL=plugin-Deb2QWIP.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-XaYYRsX-.mjs","names":[],"sources":["../../src/plugin/plugin.ts","../../src/plugin.ts"],"sourcesContent":["import type { Effect } from \"effect\";\nimport type { Definition } from \"../event.ts\";\nimport type { Service as LocationService } from \"../location.ts\";\nimport type { SandboxIO } from \"../sandbox/io.ts\";\nimport type { PluginOptions } from \"./ref.ts\";\nimport type { SharedPluginContext } from \"./context.ts\";\n\n/**\n * The domains a plugin can extend, and the order the harness runs them in.\n *\n * Order is declared, not positional. A plugin's place used to come from where its entry sat in\n * the `plugins` array, which is unknowable when the entry is written: a user's settings file and\n * a project's are edited by different people at different times, and neither can see the other's\n * order. Since a prompt plugin indexes the tools registered before it, that made a tool added\n * from settings invisible in the system prompt, with no way to fix it from a settings file.\n *\n * A plugin instead says which domain it extends, and the harness runs the domains in this order.\n * Entries within one domain keep the order they were written in, because that is where\n * composition actually happens -- a plugin patching another's tool, or appending to the prompt a\n * previous one rendered, is written next to it and deliberately after it.\n *\n * Kept as data so a later release can add a domain, or make the order configurable, without\n * touching the loader: `{ tool: 1, skill: 2, prompt: 3 }` needs no code change here.\n */\nexport const domains = { tool: 1, prompt: 2 } as const;\n\nexport type PluginKind = keyof typeof domains;\n\n/** Sort key for a plugin: its domain first, then where it was written. */\nexport const rank = (kind: PluginKind) => domains[kind];\n\nexport type Mount = SandboxIO.Provides | LocationService;\nexport interface Plugin {\n\treadonly id: string;\n\t/**\n\t * The domain this plugin extends, which decides when it runs: every `tool` plugin is set up\n\t * before any `prompt` plugin, whichever settings layer each came from, so a prompt plugin\n\t * always sees the complete tool set. Plugins within one domain run in the order they were\n\t * written.\n\t */\n\treadonly kind: PluginKind;\n\t/**\n\t * Event definitions this plugin publishes. Declared rather than registered at\n\t * runtime so they are known before the event system builds, and so a bad type\n\t * fails the boot instead of the first publish. Types must be namespaced\n\t * `plugin.<id>.*`.\n\t */\n\treadonly events?: ReadonlyArray<Definition>;\n\t/**\n\t * `options` is this plugin's own configuration block, `{}` when its entry carried none.\n\t * Unvalidated: the harness never looks inside it, so a plugin checks whatever shape it\n\t * documents. It is a second argument rather than a context field so `ctx` stays one object\n\t * shared by every plugin in the exchange.\n\t */\n\treadonly setup: (\n\t\tctx: SharedPluginContext,\n\t\toptions: PluginOptions,\n\t) => void | Promise<void> | Effect.Effect<void, unknown, Mount>;\n}\n\nexport const define = (plugin: Plugin): Plugin => plugin;\n","/**\n * The plugin authoring surface.\n *\n * Everything a third-party plugin needs to describe itself and to write into the harness during\n * `setup`, and nothing about how the harness finds, installs or runs it. Loading, the store and\n * the `.npmrc` anchoring stay in `@codeworksh/harness`, which imports this same module — so a\n * plugin and its host agree on one set of types rather than two that happen to match.\n */\nexport type { Config, Events, PromptResolver, SharedPluginContext } from \"./plugin/context.ts\";\nexport { define, domains, type Mount, type Plugin, type PluginKind, rank } from \"./plugin/plugin.ts\";\nexport * as Prompt from \"./plugin/prompt.ts\";\nexport * as Section from \"./plugin/section.ts\";\nexport type { PluginOptions, PluginPatch, PluginRef, PluginSpec } from \"./plugin/ref.ts\";\nexport type { PluginRegistry } from \"./plugin/registry.ts\";\nexport * as Tool from \"./plugin/tool.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAa,UAAU;CAAE,MAAM;CAAG,QAAQ;AAAE;;AAK5C,MAAa,QAAQ,SAAqB,QAAQ;AA+BlD,MAAa,UAAU,WAA2B"}
1
+ {"version":3,"file":"plugin-XaYYRsX-.mjs","names":[],"sources":["../../src/plugin/plugin.ts","../../src/plugin.ts"],"sourcesContent":["import type { Effect } from \"effect\";\nimport type { Definition } from \"../event.ts\";\nimport type { Service as LocationService } from \"../location.ts\";\nimport type { SandboxIO } from \"../sandbox/io.ts\";\nimport type { SharedPluginContext } from \"./context.ts\";\nimport type { PluginOptions } from \"./ref.ts\";\n\n/**\n * The domains a plugin can extend, and the order the harness runs them in.\n *\n * Order is declared, not positional. A plugin's place used to come from where its entry sat in\n * the `plugins` array, which is unknowable when the entry is written: a user's settings file and\n * a project's are edited by different people at different times, and neither can see the other's\n * order. Since a prompt plugin indexes the tools registered before it, that made a tool added\n * from settings invisible in the system prompt, with no way to fix it from a settings file.\n *\n * A plugin instead says which domain it extends, and the harness runs the domains in this order.\n * Entries within one domain keep the order they were written in, because that is where\n * composition actually happens -- a plugin patching another's tool, or appending to the prompt a\n * previous one rendered, is written next to it and deliberately after it.\n *\n * Kept as data so a later release can add a domain, or make the order configurable, without\n * touching the loader: `{ tool: 1, skill: 2, prompt: 3 }` needs no code change here.\n */\nexport const domains = { tool: 1, prompt: 2 } as const;\n\nexport type PluginKind = keyof typeof domains;\n\n/** Sort key for a plugin: its domain first, then where it was written. */\nexport const rank = (kind: PluginKind) => domains[kind];\n\nexport type Mount = SandboxIO.Provides | LocationService;\nexport interface Plugin {\n\treadonly id: string;\n\t/**\n\t * The domain this plugin extends, which decides when it runs: every `tool` plugin is set up\n\t * before any `prompt` plugin, whichever settings layer each came from, so a prompt plugin\n\t * always sees the complete tool set. Plugins within one domain run in the order they were\n\t * written.\n\t */\n\treadonly kind: PluginKind;\n\t/**\n\t * Event definitions this plugin publishes. Declared rather than registered at\n\t * runtime so they are known before the event system builds, and so a bad type\n\t * fails the boot instead of the first publish. Types must be namespaced\n\t * `plugin.<id>.*`.\n\t */\n\treadonly events?: ReadonlyArray<Definition>;\n\t/**\n\t * Off until a user asks for it. An `optIn` plugin is selected like any other but runs only\n\t * when a settings entry turns it on: `{ \"plugin\": \"<id>\", \"enabled\": true }`.\n\t */\n\treadonly optIn?: boolean;\n\t/**\n\t * `options` is this plugin's own configuration block, `{}` when its entry carried none.\n\t * Unvalidated: the harness never looks inside it, so a plugin checks whatever shape it\n\t * documents. It is a second argument rather than a context field so `ctx` stays one object\n\t * shared by every plugin in the exchange.\n\t */\n\treadonly setup: (\n\t\tctx: SharedPluginContext,\n\t\toptions: PluginOptions,\n\t) => void | Promise<void> | Effect.Effect<void, unknown, Mount>;\n}\n\nexport const define = (plugin: Plugin): Plugin => plugin;\n","/**\n * The plugin authoring surface.\n *\n * Everything a third-party plugin needs to describe itself and to write into the harness during\n * `setup`, and nothing about how the harness finds, installs or runs it. Loading, the store and\n * the `.npmrc` anchoring stay in `@codeworksh/harness`, which imports this same module — so a\n * plugin and its host agree on one set of types rather than two that happen to match.\n */\nexport type { Config, Events, Paths, PromptResolver, SharedPluginContext } from \"./plugin/context.ts\";\nexport { define, domains, type Mount, type Plugin, type PluginKind, rank } from \"./plugin/plugin.ts\";\nexport * as Prompt from \"./plugin/prompt.ts\";\nexport * as Section from \"./plugin/section.ts\";\nexport type { PluginOptions, PluginPatch, PluginRef, PluginSpec } from \"./plugin/ref.ts\";\nexport type { PluginRegistry } from \"./plugin/registry.ts\";\nexport * as Tool from \"./plugin/tool.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAa,UAAU;CAAE,MAAM;CAAG,QAAQ;AAAE;;AAK5C,MAAa,QAAQ,SAAqB,QAAQ;AAoClD,MAAa,UAAU,WAA2B"}
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
- 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-CLuLZhKa.mjs";
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 };
3
+ import { p as tool_d_exports } from "./tool-D4_I_rzy.mjs";
4
+ import { _ as PluginRegistry, a as define, c as PluginOptions, d as PluginSpec, f as Config, g as SharedPluginContext, h as PromptResolver, i as PluginKind, l as PluginPatch, m as Paths, n as Mount, o as domains, p as Events, r as Plugin, s as rank, u as PluginRef } from "./plugin-Deb2QWIP.mjs";
5
+ export { type Config, type Events, type Mount, type Paths, 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 apiVersion, C as Observed, D as RuntimeConfigBase, E as Registration, F as withSource, M as driver, N as driver_d_exports, O as RuntimeInput, P as erase, S as Name, T as Registered, _ as Capabilities, b as Module, g as ApiVersion, h as AbsolutePath, j as defineModule, k as Source, v as Definition, w as Provisioned, x as ModuleDefinition, y as Driver } from "../io-BYs7hbiY.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-nhvNKC33.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.mjs";
3
+ import "../io-Dgh8U41k.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 SandboxTransitionConflictError, B as SandboxDriverLoadError, G as SandboxMustBeStoppedError, H as SandboxDriverNotRegisteredError, I as Redactor, J as SandboxReadError, K as SandboxNotFoundError, L as SandboxBusyError, Q as SandboxStopError, R as SandboxCreateError, U as SandboxDriverRegistrationError, V as SandboxDriverLoadPhase, W as SandboxMountError, X as SandboxRegisterError, Y as SandboxRefreshError, Z as SandboxRemovedError, at as providerError, ct as sanitizeError, et as SandboxUnavailError, it as makeRedactor, nt as SandboxWakeError, ot as providerErrorCause, q as SandboxProviderError, rt as errors_d_exports, st as providerErrorIsNotFound, tt as SandboxUnsupportedError, z as SandboxDestroyError } from "../io-BYs7hbiY.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-nhvNKC33.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 { a as Provider, c as filesystem_d_exports, d as realpathScripts, f as validateRmOptions, i as OperationUnsupportedError, l as fromProvider, n as FileSystemError, o as RmOptions, p as withCwd, r as Interface, s as Service, t as FileStat, u as isNotFoundError } from "../filesystem-Cp-KapCE.mjs";
2
- export { FileStat, FileSystemError, Interface, OperationUnsupportedError, Provider, RmOptions, filesystem_d_exports as SandboxFileSystem, Service, fromProvider, isNotFoundError, realpathScripts, validateRmOptions, withCwd };
1
+ import { _ as LineScanOptions, a as Provider, c as filesystem_d_exports, d as readBytesScript, f as readBytesViaShell, g as LineScan, h as withCwd, i as OperationUnsupportedError, l as fromProvider, m as validateRmOptions, n as FileSystemError, o as RmOptions, p as realpathScripts, r as Interface, s as Service, t as FileStat, u as isNotFoundError, v as scan_d_exports } from "../filesystem-CuGE9poU.mjs";
2
+ export { FileStat, FileSystemError, Interface, type LineScan, type LineScanOptions, OperationUnsupportedError, Provider, RmOptions, filesystem_d_exports as SandboxFileSystem, scan_d_exports as Scan, Service, fromProvider, isNotFoundError, readBytesScript, readBytesViaShell, realpathScripts, validateRmOptions, withCwd };
@@ -1,142 +1,2 @@
1
- import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
- import { posix } from "../posix.mjs";
3
- import { Context, Effect, Schema } from "effect";
4
- //#region src/sandbox/filesystem.ts
5
- var filesystem_exports = /* @__PURE__ */ __exportAll({
6
- FileSystemError: () => FileSystemError,
7
- OperationUnsupportedError: () => OperationUnsupportedError,
8
- SandboxFileSystem: () => filesystem_exports,
9
- Service: () => Service,
10
- fromProvider: () => fromProvider,
11
- isNotFoundError: () => isNotFoundError,
12
- realpathScripts: () => realpathScripts,
13
- validateRmOptions: () => validateRmOptions,
14
- withCwd: () => withCwd
15
- });
16
- /**
17
- * The runtime filesystem contract, independent of any backend.
18
- *
19
- * Two surfaces, deliberately:
20
- * - {@link Provider} is what a backend implements — plain promises that reject,
21
- * matching every SDK we wrap.
22
- * - {@link Interface} is what the harness consumes — Effect with a typed error
23
- * channel and tracing spans. {@link fromProvider} bridges the two exactly
24
- * once, so no consumer ever writes `Effect.tryPromise` against a filesystem.
25
- *
26
- * Implementations:
27
- * - Local:
28
- * implement it over a VFS (`./local`);
29
- * local filesystem use OS primitives; hence have broader filesytem capabilities.
30
- *
31
- * - Remote:
32
- * implement it over a provider (`./remote`).
33
- * remote filesytems depends on the interface provided by the remote provider; hence can have limited filesytem capabilities.
34
- *
35
- * `isFile`/`isDirectory` are required booleans; size, mtime, and isSymbolicLink are omitted when the
36
- * backend cannot report them — never fabricated.
37
- *
38
- * **Paths are POSIX, and the harness is Unix-only (for now!).** Every path uses `/`
39
- * separators on both the host and inside a sandbox — Windows is not supported,
40
- * so no translation layer exists. Consumers must use the shared Effect POSIX
41
- * path implementation, never the platform default, or a host running the harness would
42
- * impose its own flavour on a remote sandbox's paths. Relative paths resolve
43
- * against the backend's configured `cwd`.
44
- */
45
- var OperationUnsupportedError = class extends Schema.TaggedError()("OperationUnsupportedError", {
46
- operation: Schema.String,
47
- message: Schema.String
48
- }) {};
49
- /** A backend operation failed. `cause` carries the provider's own rejection. */
50
- var FileSystemError = class extends Schema.TaggedError()("SandboxFileSystemError", {
51
- method: Schema.String,
52
- path: Schema.String,
53
- cause: Schema.optional(Schema.Defect())
54
- }) {};
55
- /** Whether a provider failure means the path itself is definitively absent. */
56
- const isNotFoundError = (cause) => {
57
- const code = cause?.code;
58
- return code === "ENOENT" || code === "ENOTDIR";
59
- };
60
- /**
61
- * Shell forms of `realpath` for backends that only expose a process API.
62
- * `pwd -P` is the portable primitive: directories resolve directly, anything
63
- * else resolves its parent and keeps the final name as given. Run as
64
- * `sh -c <script> _ <path>`; try the first, fall back to the second.
65
- */
66
- const realpathScripts = ["cd -- \"$1\" && pwd -P", "cd -- \"$(dirname -- \"$1\")\" && printf '%s/%s' \"$(pwd -P)\" \"$(basename -- \"$1\")\""];
67
- /** The runtime filesystem service — the live {@link Interface} for the active sandbox. */
68
- var Service = class extends Context.Service()("@codeworksh/plugin/sandbox/filesystem/Service") {};
69
- /**
70
- * Reject `rm` options a provider does not implement, before any mutation. Only
71
- * `recursive` and `force` are part of the contract; anything else is refused
72
- * loudly rather than silently ignored.
73
- */
74
- const validateRmOptions = (options, operation = "rm") => Effect.suspend(() => {
75
- for (const option of Object.keys(options ?? {})) {
76
- if (option === "recursive" || option === "force") continue;
77
- return Effect.fail(new OperationUnsupportedError({
78
- operation,
79
- message: `Unsupported rm option: ${option}`
80
- }));
81
- }
82
- return Effect.void;
83
- });
84
- /**
85
- * Lift a {@link Provider} into the runtime {@link Interface}: one place that
86
- * converts rejections into {@link FileSystemError}, validates `rm` options,
87
- * creates missing parents on write, and names a tracing span per operation.
88
- */
89
- const fromProvider = (provider) => {
90
- const attempt = (method, path, run) => Effect.tryPromise({
91
- try: run,
92
- catch: (cause) => new FileSystemError({
93
- method,
94
- path,
95
- cause
96
- })
97
- });
98
- const writeCreatingParents = (path, content) => {
99
- const write = attempt("writeFile", path, () => provider.writeFile(path, content));
100
- const parent = posix.dirname(path);
101
- return write.pipe(Effect.catch(() => attempt("mkdir", parent, () => provider.mkdir(parent, { recursive: true })).pipe(Effect.ignore, Effect.andThen(write))));
102
- };
103
- return {
104
- readFile: Effect.fn("SandboxFileSystem.readFile")((path) => attempt("readFile", path, () => provider.readFile(path))),
105
- readFileBuffer: Effect.fn("SandboxFileSystem.readFileBuffer")((path) => attempt("readFileBuffer", path, () => provider.readFileBuffer(path))),
106
- writeFile: Effect.fn("SandboxFileSystem.writeFile")(writeCreatingParents),
107
- stat: Effect.fn("SandboxFileSystem.stat")((path) => attempt("stat", path, () => provider.stat(path))),
108
- ...provider.lstat === void 0 ? {} : { lstat: Effect.fn("SandboxFileSystem.lstat")((path) => attempt("lstat", path, () => provider.lstat(path))) },
109
- readdir: Effect.fn("SandboxFileSystem.readdir")((path) => attempt("readdir", path, () => provider.readdir(path))),
110
- exists: Effect.fn("SandboxFileSystem.exists")((path) => attempt("exists", path, () => provider.exists(path))),
111
- mkdir: Effect.fn("SandboxFileSystem.mkdir")((path, options) => attempt("mkdir", path, () => provider.mkdir(path, options))),
112
- rm: Effect.fn("SandboxFileSystem.rm")((path, options) => validateRmOptions(options).pipe(Effect.andThen(attempt("rm", path, () => provider.rm(path, options))))),
113
- realpath: Effect.fn("SandboxFileSystem.realpath")((path) => attempt("realpath", path, () => provider.realpath(path)))
114
- };
115
- };
116
- /**
117
- * Bind a cwd-neutral filesystem to one mount's working directory.
118
- *
119
- * The counterpart of `Shell.withCwd`, and the reason relative paths mean the
120
- * same thing to both: a shared transport stays rooted at the namespace root, so
121
- * resolution happens here, per mount, rather than inside a VFS whose `chdir` is
122
- * global state two mounts would fight over.
123
- */
124
- const withCwd = (fs, cwd) => {
125
- const at = (path) => posix.resolve(cwd, path);
126
- return {
127
- readFile: (path) => fs.readFile(at(path)),
128
- readFileBuffer: (path) => fs.readFileBuffer(at(path)),
129
- writeFile: (path, content) => fs.writeFile(at(path), content),
130
- stat: (path) => fs.stat(at(path)),
131
- readdir: (path) => fs.readdir(at(path)),
132
- exists: (path) => fs.exists(at(path)),
133
- mkdir: (path, options) => fs.mkdir(at(path), options),
134
- rm: (path, options) => fs.rm(at(path), options),
135
- realpath: (path) => fs.realpath(at(path)),
136
- ...fs.lstat === void 0 ? {} : { lstat: (path) => fs.lstat(at(path)) }
137
- };
138
- };
139
- //#endregion
140
- export { FileSystemError, OperationUnsupportedError, filesystem_exports as SandboxFileSystem, Service, fromProvider, isNotFoundError, realpathScripts, validateRmOptions, withCwd };
141
-
142
- //# sourceMappingURL=filesystem.mjs.map
1
+ import { a as fromProvider, c as readBytesViaShell, d as withCwd, f as scan_exports, i as filesystem_exports, l as realpathScripts, n as OperationUnsupportedError, o as isNotFoundError, r as Service, s as readBytesScript, t as FileSystemError, u as validateRmOptions } from "../filesystem-omtKo08x.mjs";
2
+ export { FileSystemError, OperationUnsupportedError, filesystem_exports as SandboxFileSystem, scan_exports as Scan, Service, fromProvider, isNotFoundError, readBytesScript, readBytesViaShell, realpathScripts, validateRmOptions, withCwd };
@@ -1,2 +1,2 @@
1
- import { St as toField, _t as fromField, bt as mountable, dt as Kind, ft as Ownership, gt as fromColumn, ht as Usage, lt as ID, mt as Status, pt as PersistedError, ut as Info, vt as instance_d_exports, xt as toColumn, yt as isMountable } from "../io-BYs7hbiY.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-nhvNKC33.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 Provides, c as hostLayer, d as mount, f as remote, i as Layer, l as identityLayer, m as virtual, n as FileSystem, o as Shell, p as resolveMountCwd, r as Identity, s as host, t as Current, u as io_d_exports } from "../io-BYs7hbiY.mjs";
2
- export { Current, FileSystem, Identity, Layer, Provides, io_d_exports as SandboxIO, Shell, host, hostLayer, identityLayer, mount, remote, resolveMountCwd, virtual };
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-nhvNKC33.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 };