@codeworksh/plugin 0.0.1-dev.20260925150557 → 0.1.0-canary.1.1.gc0ff5572

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.md +13 -5
  2. package/{event-BnLveFBB.d.mts → event-6sTQ_4bq.d.mts} +53 -49
  3. package/event.d.mts +1 -1
  4. package/filesystem-CuGE9poU.d.mts +268 -0
  5. package/filesystem-omtKo08x.mjs +381 -0
  6. package/filesystem-omtKo08x.mjs.map +1 -0
  7. package/ids.mjs +1 -1
  8. package/ids.mjs.map +1 -1
  9. package/index.d.mts +4 -3
  10. package/index.mjs +3 -2
  11. package/io-Dgh8U41k.mjs +188 -0
  12. package/io-Dgh8U41k.mjs.map +1 -0
  13. package/{io-BYs7hbiY.d.mts → io-nhvNKC33.d.mts} +51 -8
  14. package/{location-D4hAfuXF.d.mts → location-Q39els63.d.mts} +9 -14
  15. package/location.d.mts +2 -2
  16. package/location.mjs +2 -5
  17. package/location.mjs.map +1 -1
  18. package/package.json +8 -3
  19. package/plugin/prompt.d.mts +1 -1
  20. package/plugin/prompt.mjs.map +1 -1
  21. package/plugin/section.d.mts +27 -0
  22. package/plugin/section.mjs +65 -0
  23. package/plugin/section.mjs.map +1 -0
  24. package/plugin/tool.d.mts +1 -1
  25. package/{plugin-B1M3SjEb.d.mts → plugin-Deb2QWIP.d.mts} +27 -9
  26. package/{plugin-lorpq7Oi.mjs → plugin-XaYYRsX-.mjs} +3 -1
  27. package/{plugin-lorpq7Oi.mjs.map → plugin-XaYYRsX-.mjs.map} +1 -1
  28. package/plugin.d.mts +5 -4
  29. package/plugin.mjs +3 -2
  30. package/prompt-DWaA5ZXj.d.mts +21 -0
  31. package/sandbox/driver.d.mts +1 -1
  32. package/sandbox/driver.mjs +7 -3
  33. package/sandbox/driver.mjs.map +1 -1
  34. package/sandbox/errors.d.mts +1 -1
  35. package/sandbox/filesystem.d.mts +2 -2
  36. package/sandbox/filesystem.mjs +2 -142
  37. package/sandbox/instance.d.mts +1 -1
  38. package/sandbox/io.d.mts +2 -2
  39. package/sandbox/io.mjs +3 -127
  40. package/sandbox.d.mts +3 -3
  41. package/sandbox.mjs +8 -5
  42. package/sandbox.mjs.map +1 -1
  43. package/schema.d.mts +3 -1
  44. package/schema.mjs +4 -2
  45. package/schema.mjs.map +1 -1
  46. package/settings-47Mzxhl0.d.mts +587 -0
  47. package/settings.d.mts +2 -2
  48. package/settings.mjs +56 -5
  49. package/settings.mjs.map +1 -1
  50. package/tool/progress.d.mts +1 -1
  51. package/{tool-BoVqkYvL.d.mts → tool-D4_I_rzy.d.mts} +2 -2
  52. package/{tool-DuYBgiJf.d.mts → tool-_ajVYIY5.d.mts} +20 -1
  53. package/tool.d.mts +1 -1
  54. package/tool.mjs +2 -1
  55. package/tool.mjs.map +1 -1
  56. package/filesystem-Cp-KapCE.d.mts +0 -142
  57. package/prompt-BcpagjGh.d.mts +0 -10
  58. package/sandbox/filesystem.mjs.map +0 -1
  59. package/sandbox/io.mjs.map +0 -1
  60. package/settings-bbJi7FiQ.d.mts +0 -207
@@ -0,0 +1,188 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
+ import { ID } from "./sandbox/instance.mjs";
3
+ import { posix } from "./posix.mjs";
4
+ import { d as withCwd, o as isNotFoundError, r as Service$1 } from "./filesystem-omtKo08x.mjs";
5
+ import { Shell as Shell$1, withCwd as withCwd$1 } from "./sandbox/shell.mjs";
6
+ import { Context, Deferred, Effect, Layer } from "effect";
7
+ //#region src/sandbox/mutation.ts
8
+ var Service = class extends Context.Service()("@codeworksh/plugin/sandbox/mutation/Service") {};
9
+ const locks = /* @__PURE__ */ new Map();
10
+ /** Hand the file to the next waiter, or free it. Ownership moves directly, so no newcomer can barge in. */
11
+ const release = (key, lock) => {
12
+ const next = lock.waiters.shift();
13
+ if (next === void 0) locks.delete(key);
14
+ else Deferred.doneUnsafe(next, Effect.void);
15
+ };
16
+ /** Take the file, waiting interruptibly; must run uninterruptibly so taking and releasing pair up. */
17
+ const acquire = (key, restore) => Effect.suspend(() => {
18
+ const lock = locks.get(key);
19
+ if (lock === void 0) {
20
+ locks.set(key, { waiters: [] });
21
+ return Effect.void;
22
+ }
23
+ const turn = Deferred.makeUnsafe();
24
+ lock.waiters.push(turn);
25
+ return restore(Deferred.await(turn)).pipe(Effect.onInterrupt(() => Effect.sync(() => {
26
+ const index = lock.waiters.indexOf(turn);
27
+ if (index !== -1) lock.waiters.splice(index, 1);
28
+ else release(key, lock);
29
+ })));
30
+ });
31
+ /**
32
+ * The canonical path. A file that does not exist yet takes its canonical
33
+ * parent joined with its name, walking up as far as needed, so a write that
34
+ * creates a file (and its directories) shares a key with later mutations of it.
35
+ */
36
+ const canonical = (fs, path) => fs.realpath(path).pipe(Effect.catchIf((error) => isNotFoundError(error.cause), (error) => {
37
+ const parent = posix.dirname(path);
38
+ if (parent === path) return Effect.fail(error);
39
+ return Effect.map(canonical(fs, parent), (resolved) => posix.join(resolved, posix.basename(path)));
40
+ }));
41
+ const make = (instance, cwd, fs) => ({ withFile: (path, effect) => Effect.flatMap(canonical(fs, posix.resolve(cwd, path)), (resolved) => {
42
+ const key = `${instance}\0${resolved}`;
43
+ return Effect.uninterruptibleMask((restore) => Effect.andThen(acquire(key, restore), restore(effect).pipe(Effect.ensuring(Effect.sync(() => {
44
+ const lock = locks.get(key);
45
+ if (lock !== void 0) release(key, lock);
46
+ })))));
47
+ }) });
48
+ //#endregion
49
+ //#region src/sandbox/io.ts
50
+ var io_exports = /* @__PURE__ */ __exportAll({
51
+ Current: () => Current,
52
+ DEFAULT_SPILL_PATH: () => DEFAULT_SPILL_PATH,
53
+ FileSystem: () => FileSystem,
54
+ Mutation: () => Mutation,
55
+ SandboxIO: () => io_exports,
56
+ Shell: () => Shell,
57
+ host: () => host,
58
+ hostLayer: () => hostLayer,
59
+ identityLayer: () => identityLayer,
60
+ mount: () => mount,
61
+ remote: () => remote,
62
+ resolveMountCwd: () => resolveMountCwd,
63
+ virtual: () => virtual,
64
+ withMutation: () => withMutation
65
+ });
66
+ /**
67
+ * `SandboxIO` is a **mount**: a filesystem, a shell, and the identity and
68
+ * working directory they act on.
69
+ *
70
+ * It is the whole vocabulary a consumer needs. Project, Git, Copy, Location, and
71
+ * every tool ask for `SandboxIO.FileSystem`, `SandboxIO.Shell`, and
72
+ * `SandboxIO.Current` — never for a driver, an address, or a provider SDK — so
73
+ * a host directory, an in-memory VFS, and a remote microVM are interchangeable
74
+ * behind one contract.
75
+ *
76
+ * The mount neither creates nor destroys infrastructure. `SandboxInstance` is
77
+ * the durable namespace it acts on — a device, which exists whether or not
78
+ * anything has it mounted — and `Sandbox.Controller` is the only path that
79
+ * creates, stops, or destroys one.
80
+ */
81
+ /**
82
+ * The filesystem tag. Re-exported here so consumers import one namespace —
83
+ * Project, Git, Copy, and the runner ask for `SandboxIO.FileSystem`, never for
84
+ * the module that happens to define it. Code *inside* `sandbox/` keeps importing
85
+ * the tag directly, since `io.ts` is built on top of it.
86
+ */
87
+ const FileSystem = Service$1;
88
+ /** The shell tag. Re-exported here so consumers import one namespace. */
89
+ const Shell = Shell$1;
90
+ /** Per-file mutation ordering for this mount's instance. Re-exported here so consumers import one namespace. */
91
+ const Mutation = Service;
92
+ /** Spill directory for a driver that configures none. */
93
+ const DEFAULT_SPILL_PATH = "/tmp";
94
+ /** Identity and working directory of the current mount. */
95
+ var Current = class extends Context.Service()("@codeworksh/plugin/sandbox/io/Current") {};
96
+ /**
97
+ * Resolve a mount's cwd without consulting ambient process state.
98
+ *
99
+ * The default is supplied by the namespace adapter:
100
+ * provider metadata remotely, `/` for a virtual filesystem, and `process.cwd()` for the host adapter.
101
+ * An explicit absolute cwd replaces it; a relative cwd is resolved inside it. The
102
+ * result is therefore always the one concrete absolute path `Current` requires.
103
+ *
104
+ * A non-absolute default throws rather than failing typed. It is the one
105
+ * defect-level guard in this module, and deliberately so:
106
+ * Adapters reading a value from a provider call this inside their own error channel,
107
+ * where the throw becomes their typed failure (see `EnvDaytona.mountCwd`).
108
+ */
109
+ const resolveMountCwd = (defaultCwd, cwd) => {
110
+ if (!posix.isAbsolute(defaultCwd)) throw new TypeError(`Sandbox default cwd must be absolute: ${defaultCwd}`);
111
+ if (cwd === void 0) return posix.resolve(defaultCwd);
112
+ return posix.isAbsolute(cwd) ? posix.resolve(cwd) : posix.resolve(defaultCwd, cwd);
113
+ };
114
+ /**
115
+ * Complete a mount with its {@link Mutation} queue, derived from the mount's own
116
+ * identity and filesystem. Every layer that provides a mount goes through here,
117
+ * so mounts of one instance always meet in the same queue.
118
+ */
119
+ const withMutation = (layer) => Layer.provideMerge(Layer.effect(Mutation, Effect.gen(function* () {
120
+ const current = yield* Current;
121
+ return make(current.id, current.cwd, yield* Service$1);
122
+ })), layer);
123
+ /**
124
+ * Bind a cwd-neutral transport to one mount.
125
+ *
126
+ * The transport underneath is shared between
127
+ * mounts and stays rooted at the namespace root, and everything directory-shaped
128
+ * happens here, once per mount. Two mounts of one namespace at different working
129
+ * directories therefore coexist without seeing or moving each other's.
130
+ *
131
+ * It consumes the same two tags it provides — the transport is supplied by the
132
+ * layer this is composed over, not by itself.
133
+ */
134
+ const mount = (identity) => Layer.mergeAll(Layer.succeed(Current, identity), Layer.effect(Service$1, Effect.map(Service$1, (fs) => withCwd(fs, identity.cwd))), Layer.effect(Shell$1, Effect.map(Shell$1, (shell) => withCwd$1(shell, identity.cwd)))).pipe(withMutation);
135
+ /**
136
+ * Just the identity tag, with no filesystem or shell beneath it. For consumers
137
+ * assembled from stubs — a test that runs `Project` over a fake filesystem still
138
+ * needs to know which namespace it is in.
139
+ */
140
+ const identityLayer = (identity) => Layer.succeed(Current, identity);
141
+ /** The host identity alone. See {@link identityLayer}. */
142
+ const hostLayer = (cwd) => identityLayer(host(cwd));
143
+ /**
144
+ * The host, rooted at `cwd`. Always `SandboxInstance.ID.local`: the working
145
+ * directory selects where relative paths resolve, it does not make a second host
146
+ * namespace — two mounts rooted at different directories still agree on absolute
147
+ * paths.
148
+ *
149
+ * The host coordinate is explicit so a caller cannot accidentally substitute ambient process
150
+ * state for the application or session directory it owns.
151
+ */
152
+ const host = (cwd) => ({
153
+ id: ID.local,
154
+ driver: "local",
155
+ kind: "local",
156
+ cwd: resolveMountCwd(cwd),
157
+ spillPath: DEFAULT_SPILL_PATH
158
+ });
159
+ /**
160
+ * A VFS-backed namespace. The id is minted per call unless one is named, because
161
+ * building one of these builds a fresh VFS: N unnamed calls are N distinct
162
+ * namespaces, none of which outlives the process. A file-backed store is the
163
+ * exception — its file is the state, so whoever knows the file supplies the id
164
+ * it was registered under.
165
+ */
166
+ const virtual = (input) => ({
167
+ id: input.id ?? ID.create(),
168
+ driver: input.driver,
169
+ kind: "virtual",
170
+ cwd: resolveMountCwd(input.defaultCwd ?? "/", input.cwd),
171
+ spillPath: input.spillPath ?? "/tmp"
172
+ });
173
+ /**
174
+ * A provider-hosted namespace. The id is always supplied: a remote resource's
175
+ * durable identity is minted and recorded by whoever provisioned it, never
176
+ * derived here from the provider's own locator.
177
+ */
178
+ const remote = (input) => ({
179
+ id: input.id,
180
+ driver: input.driver,
181
+ kind: "remote",
182
+ cwd: resolveMountCwd(input.defaultCwd, input.cwd),
183
+ spillPath: input.spillPath ?? "/tmp"
184
+ });
185
+ //#endregion
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 };
187
+
188
+ //# sourceMappingURL=io-Dgh8U41k.mjs.map
@@ -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":"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"}
@@ -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
@@ -2,6 +2,12 @@ import { i as project_d_exports, n as Info$1 } from "./project-CLGsIFD-.mjs";
2
2
  import { a as space_d_exports, n as Info$2 } from "./space-CR-9UxdT.mjs";
3
3
  import { Context, Schema } from "effect";
4
4
  //#region src/location.d.ts
5
+ declare const Info_base: Schema.Class<Info, Schema.Struct<{
6
+ /** The absolute cwd tools run in; `space.location` is the root it lives under. */
7
+ readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
8
+ readonly space: typeof Info$2;
9
+ readonly project: typeof Info$1;
10
+ }>, {}>;
5
11
  /**
6
12
  * Where work happens: a directory inside a space.
7
13
  *
@@ -12,7 +18,7 @@ import { Context, Schema } from "effect";
12
18
  * equal to or beneath that root. Sessions sharing a space share the project;
13
19
  * worktree relationships stay a Project concern beneath it.
14
20
  *
15
- * **Both halves come from the mount, so `Ref` is overrides and nothing else.**
21
+ * **Both halves come from the mount, and nothing overrides them.**
16
22
  * A Location is a directory *within* a mounted namespace — the mount has to be
17
23
  * resolved first, the way a volume is mounted before any path on it means
18
24
  * anything — and once it is, the namespace and the working directory are already
@@ -24,17 +30,6 @@ import { Context, Schema } from "effect";
24
30
  * which belong to the harness; a plugin receives a resolved `Info` on its context and asks for
25
31
  * {@link Service} when it needs the live one.
26
32
  */
27
- declare const Ref: Schema.Struct<{
28
- /** Defaults to the mount's cwd. Set it to work in a subdirectory of the mount. */
29
- readonly directory: Schema.optional<Schema.brand<Schema.String, "AbsolutePath">>;
30
- }>;
31
- type Ref = typeof Ref.Type;
32
- declare const Info_base: Schema.Class<Info, Schema.Struct<{
33
- /** The absolute cwd tools run in; `space.location` is the root it lives under. */
34
- readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
35
- readonly space: typeof Info$2;
36
- readonly project: typeof Info$1;
37
- }>, {}>;
38
33
  declare class Info extends Info_base {}
39
34
  interface Interface extends Info {}
40
35
  declare const Service_base: Context.ServiceClass<Service, "@codeworksh/plugin/location/Service", Interface>;
@@ -57,5 +52,5 @@ declare const NotDirectoryError_base: Schema.Class<NotDirectoryError, Schema.Tag
57
52
  declare class NotDirectoryError extends NotDirectoryError_base {}
58
53
  type Error = DirectoryNotFoundError | NotDirectoryError;
59
54
  //#endregion
60
- export { NotDirectoryError as a, Interface as i, Error as n, Ref as o, Info as r, Service as s, DirectoryNotFoundError as t };
61
- //# sourceMappingURL=location-D4hAfuXF.d.mts.map
55
+ export { NotDirectoryError as a, Interface as i, Error as n, Service as o, Info as r, DirectoryNotFoundError as t };
56
+ //# sourceMappingURL=location-Q39els63.d.mts.map
package/location.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as NotDirectoryError, i as Interface, n as Error, o as Ref, r as Info, s as Service, t as DirectoryNotFoundError } from "./location-D4hAfuXF.mjs";
2
- export { DirectoryNotFoundError, Error, Info, Interface, NotDirectoryError, Ref, Service };
1
+ import { a as NotDirectoryError, i as Interface, n as Error, o as Service, r as Info, t as DirectoryNotFoundError } from "./location-Q39els63.mjs";
2
+ export { DirectoryNotFoundError, Error, Info, Interface, NotDirectoryError, Service };
package/location.mjs CHANGED
@@ -14,7 +14,7 @@ import { Context, Schema } from "effect";
14
14
  * equal to or beneath that root. Sessions sharing a space share the project;
15
15
  * worktree relationships stay a Project concern beneath it.
16
16
  *
17
- * **Both halves come from the mount, so `Ref` is overrides and nothing else.**
17
+ * **Both halves come from the mount, and nothing overrides them.**
18
18
  * A Location is a directory *within* a mounted namespace — the mount has to be
19
19
  * resolved first, the way a volume is mounted before any path on it means
20
20
  * anything — and once it is, the namespace and the working directory are already
@@ -26,9 +26,6 @@ import { Context, Schema } from "effect";
26
26
  * which belong to the harness; a plugin receives a resolved `Info` on its context and asks for
27
27
  * {@link Service} when it needs the live one.
28
28
  */
29
- const Ref = Schema.Struct({
30
- /** Defaults to the mount's cwd. Set it to work in a subdirectory of the mount. */
31
- directory: Schema.optional(AbsolutePath) }).annotate({ identifier: "Location.Ref" });
32
29
  var Info = class extends Schema.Class("Location.Info")({
33
30
  /** The absolute cwd tools run in; `space.location` is the root it lives under. */
34
31
  directory: AbsolutePath,
@@ -43,6 +40,6 @@ const Fields = {
43
40
  var DirectoryNotFoundError = class extends Schema.TaggedError()("Location.DirectoryNotFoundError", Fields) {};
44
41
  var NotDirectoryError = class extends Schema.TaggedError()("Location.NotDirectoryError", Fields) {};
45
42
  //#endregion
46
- export { DirectoryNotFoundError, Info, NotDirectoryError, Ref, Service };
43
+ export { DirectoryNotFoundError, Info, NotDirectoryError, Service };
47
44
 
48
45
  //# sourceMappingURL=location.mjs.map
package/location.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"location.mjs","names":["SpaceSchema.Info","ProjectSchema.Info","SandboxInstance.ID"],"sources":["../../src/location.ts"],"sourcesContent":["import { Context, Schema } from \"effect\";\nimport { ProjectSchema } from \"./project.ts\";\nimport { AbsolutePath } from \"./schema.ts\";\nimport { SandboxInstance } from \"./sandbox/instance.ts\";\nimport { SpaceSchema } from \"./space.ts\";\n\n/**\n * Where work happens: a directory inside a space.\n *\n * The pair (space, directory) is the key. A path alone does not name a place —\n * `/app/repo` on the host and `/app/repo` inside a remote sandbox are different\n * trees wearing the same spelling — so the space carries the env and the\n * root it lives under (`space.location`), and `directory` is the absolute cwd\n * equal to or beneath that root. Sessions sharing a space share the project;\n * worktree relationships stay a Project concern beneath it.\n *\n * **Both halves come from the mount, so `Ref` is overrides and nothing else.**\n * A Location is a directory *within* a mounted namespace — the mount has to be\n * resolved first, the way a volume is mounted before any path on it means\n * anything — and once it is, the namespace and the working directory are already\n * in scope. Re-declaring them would be two spellings of one value, free to drift;\n * a Location pointing somewhere its own shell is not becomes unrepresentable\n * rather than merely avoided by discipline.\n *\n * Only the shape and the service tag live here. Building one needs Project, Space, Repo and Git,\n * which belong to the harness; a plugin receives a resolved `Info` on its context and asks for\n * {@link Service} when it needs the live one.\n */\nexport const Ref = Schema.Struct({\n\t/** Defaults to the mount's cwd. Set it to work in a subdirectory of the mount. */\n\tdirectory: Schema.optional(AbsolutePath),\n}).annotate({ identifier: \"Location.Ref\" });\nexport type Ref = typeof Ref.Type;\n\nexport class Info extends Schema.Class<Info>(\"Location.Info\")({\n\t/** The absolute cwd tools run in; `space.location` is the root it lives under. */\n\tdirectory: AbsolutePath,\n\tspace: SpaceSchema.Info,\n\tproject: ProjectSchema.Info,\n}) {}\n\nexport interface Interface extends Info {}\n\nexport class Service extends Context.Service<Service, Interface>()(\"@codeworksh/plugin/location/Service\") {}\n\nconst Fields = {\n\tdirectory: AbsolutePath,\n\tsandboxInstanceId: SandboxInstance.ID,\n};\n\nexport class DirectoryNotFoundError extends Schema.TaggedError<DirectoryNotFoundError>()(\n\t\"Location.DirectoryNotFoundError\",\n\tFields,\n) {}\n\nexport class NotDirectoryError extends Schema.TaggedError<NotDirectoryError>()(\"Location.NotDirectoryError\", Fields) {}\n\nexport type Error = DirectoryNotFoundError | NotDirectoryError;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAa,MAAM,OAAO,OAAO;;AAEhC,WAAW,OAAO,SAAS,YAAY,EACxC,CAAC,CAAC,CAAC,SAAS,EAAE,YAAY,eAAe,CAAC;AAG1C,IAAa,OAAb,cAA0B,OAAO,MAAY,eAAe,CAAC,CAAC;;CAE7D,WAAW;CACX,OAAOA;CACP,SAASC;AACV,CAAC,CAAC,CAAC,CAAC;AAIJ,IAAa,UAAb,cAA6B,QAAQ,QAA4B,CAAC,CAAC,qCAAqC,CAAC,CAAC,CAAC;AAE3G,MAAM,SAAS;CACd,WAAW;CACX,mBAAmBC;AACpB;AAEA,IAAa,yBAAb,cAA4C,OAAO,YAAoC,CAAC,CACvF,mCACA,MACD,CAAC,CAAC,CAAC;AAEH,IAAa,oBAAb,cAAuC,OAAO,YAA+B,CAAC,CAAC,8BAA8B,MAAM,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"location.mjs","names":["SpaceSchema.Info","ProjectSchema.Info","SandboxInstance.ID"],"sources":["../../src/location.ts"],"sourcesContent":["import { Context, Schema } from \"effect\";\nimport { ProjectSchema } from \"./project.ts\";\nimport { AbsolutePath } from \"./schema.ts\";\nimport { SandboxInstance } from \"./sandbox/instance.ts\";\nimport { SpaceSchema } from \"./space.ts\";\n\n/**\n * Where work happens: a directory inside a space.\n *\n * The pair (space, directory) is the key. A path alone does not name a place —\n * `/app/repo` on the host and `/app/repo` inside a remote sandbox are different\n * trees wearing the same spelling — so the space carries the env and the\n * root it lives under (`space.location`), and `directory` is the absolute cwd\n * equal to or beneath that root. Sessions sharing a space share the project;\n * worktree relationships stay a Project concern beneath it.\n *\n * **Both halves come from the mount, and nothing overrides them.**\n * A Location is a directory *within* a mounted namespace — the mount has to be\n * resolved first, the way a volume is mounted before any path on it means\n * anything — and once it is, the namespace and the working directory are already\n * in scope. Re-declaring them would be two spellings of one value, free to drift;\n * a Location pointing somewhere its own shell is not becomes unrepresentable\n * rather than merely avoided by discipline.\n *\n * Only the shape and the service tag live here. Building one needs Project, Space, Repo and Git,\n * which belong to the harness; a plugin receives a resolved `Info` on its context and asks for\n * {@link Service} when it needs the live one.\n */\nexport class Info extends Schema.Class<Info>(\"Location.Info\")({\n\t/** The absolute cwd tools run in; `space.location` is the root it lives under. */\n\tdirectory: AbsolutePath,\n\tspace: SpaceSchema.Info,\n\tproject: ProjectSchema.Info,\n}) {}\n\nexport interface Interface extends Info {}\n\nexport class Service extends Context.Service<Service, Interface>()(\"@codeworksh/plugin/location/Service\") {}\n\nconst Fields = {\n\tdirectory: AbsolutePath,\n\tsandboxInstanceId: SandboxInstance.ID,\n};\n\nexport class DirectoryNotFoundError extends Schema.TaggedError<DirectoryNotFoundError>()(\n\t\"Location.DirectoryNotFoundError\",\n\tFields,\n) {}\n\nexport class NotDirectoryError extends Schema.TaggedError<NotDirectoryError>()(\"Location.NotDirectoryError\", Fields) {}\n\nexport type Error = DirectoryNotFoundError | NotDirectoryError;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,IAAa,OAAb,cAA0B,OAAO,MAAY,eAAe,CAAC,CAAC;;CAE7D,WAAW;CACX,OAAOA;CACP,SAASC;AACV,CAAC,CAAC,CAAC,CAAC;AAIJ,IAAa,UAAb,cAA6B,QAAQ,QAA4B,CAAC,CAAC,qCAAqC,CAAC,CAAC,CAAC;AAE3G,MAAM,SAAS;CACd,WAAW;CACX,mBAAmBC;AACpB;AAEA,IAAa,yBAAb,cAA4C,OAAO,YAAoC,CAAC,CACvF,mCACA,MACD,CAAC,CAAC,CAAC;AAEH,IAAa,oBAAb,cAAuC,OAAO,YAA+B,CAAC,CAAC,8BAA8B,MAAM,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeworksh/plugin",
3
- "version": "0.0.1-dev.20260925150557",
3
+ "version": "0.1.0-canary.1.1.gc0ff5572",
4
4
  "description": "SDK for building CodeWork plugins — the plugin, tool, and sandbox contracts shared with @codeworksh/harness.",
5
5
  "keywords": [
6
6
  "agent",
@@ -45,6 +45,11 @@
45
45
  "import": "./plugin/prompt.mjs",
46
46
  "default": "./plugin/prompt.mjs"
47
47
  },
48
+ "./plugin/section": {
49
+ "types": "./plugin/section.d.mts",
50
+ "import": "./plugin/section.mjs",
51
+ "default": "./plugin/section.mjs"
52
+ },
48
53
  "./sandbox": {
49
54
  "types": "./sandbox.d.mts",
50
55
  "import": "./sandbox.mjs",
@@ -163,7 +168,7 @@
163
168
  "uuidv7": "^1.2.1"
164
169
  },
165
170
  "peerDependencies": {
166
- "@codeworksh/aikit": "^0.9.2",
167
- "effect": "4.0.0-rc.115"
171
+ "@codeworksh/aikit": "0.10.0-canary.1.1.gc0ff5572",
172
+ "effect": "4.0.1"
168
173
  }
169
174
  }
@@ -1,2 +1,2 @@
1
- import { t as PromptRegistry } from "../prompt-BcpagjGh.mjs";
1
+ import { t as PromptRegistry } from "../prompt-DWaA5ZXj.mjs";
2
2
  export { PromptRegistry };
@@ -1 +1 @@
1
- {"version":3,"file":"prompt.mjs","names":[],"sources":["../../../src/plugin/prompt.ts"],"sourcesContent":["export interface PromptRegistry {\n\treadonly set: (systemPrompt: string) => void;\n\treadonly get: () => string | undefined;\n}\n"],"mappings":""}
1
+ {"version":3,"file":"prompt.mjs","names":[],"sources":["../../../src/plugin/prompt.ts"],"sourcesContent":["import type { Section } from \"./section.ts\";\n\nexport interface PromptRegistry {\n\t/** The untagged head of the system prompt; the last `set` wins. */\n\treadonly foundation: {\n\t\treadonly set: (text: string) => void;\n\t\treadonly get: () => string | undefined;\n\t};\n\treadonly sections: {\n\t\treadonly append: (section: Section, entry: string) => void;\n\t\treadonly set: (section: Section, entries: ReadonlyArray<string>) => void;\n\t\t/** Writing a removed section again opens a new one, last in order. */\n\t\treadonly remove: (section: Section) => void;\n\t\treadonly get: (section: Section) => ReadonlyArray<string> | undefined;\n\t};\n}\n"],"mappings":""}
@@ -0,0 +1,27 @@
1
+ declare namespace section_d_exports {
2
+ export { Addendum, Format, ProjectContext, Rules, Section, Skills, builtins, define, invalid, isFormat, reserved };
3
+ }
4
+ /** `text`: entries verbatim, blank-line separated. `list`: deduplicated `- ` bullets. */
5
+ export type Format = "text" | "list";
6
+ export interface Section<Name extends string = string> {
7
+ readonly name: Name;
8
+ readonly format: Format;
9
+ }
10
+ export declare const Rules: Section<"rules">;
11
+ export declare const Addendum: Section<"addendum">;
12
+ export declare const ProjectContext: Section<"project_context">;
13
+ export declare const Skills: Section<"skills">;
14
+ /** Rendered in this order, before custom sections. */
15
+ export declare const builtins: ReadonlyArray<Section>;
16
+ /** Rendered by the harness, never by a plugin. */
17
+ export declare const reserved: ReadonlySet<string>;
18
+ /** Runtime check: a JavaScript plugin can pass anything. */
19
+ export declare const isFormat: (format: unknown) => format is Format;
20
+ export declare const invalid: (name: unknown) => string | undefined;
21
+ /** A custom section. Throws on a name that is malformed, reserved, or built in. */
22
+ export declare const define: <const Name extends string>(name: Name, options?: {
23
+ readonly format?: Format;
24
+ }) => Section<Name>;
25
+ //#endregion
26
+ export { section_d_exports as t };
27
+ //# sourceMappingURL=section.d.mts.map
@@ -0,0 +1,65 @@
1
+ import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
2
+ //#region src/plugin/section.ts
3
+ var section_exports = /* @__PURE__ */ __exportAll({
4
+ Addendum: () => Addendum,
5
+ ProjectContext: () => ProjectContext,
6
+ Rules: () => Rules,
7
+ Skills: () => Skills,
8
+ builtins: () => builtins,
9
+ define: () => define,
10
+ invalid: () => invalid,
11
+ isFormat: () => isFormat,
12
+ reserved: () => reserved
13
+ });
14
+ const Rules = Object.freeze({
15
+ name: "rules",
16
+ format: "list"
17
+ });
18
+ const Addendum = Object.freeze({
19
+ name: "addendum",
20
+ format: "text"
21
+ });
22
+ const ProjectContext = Object.freeze({
23
+ name: "project_context",
24
+ format: "text"
25
+ });
26
+ const Skills = Object.freeze({
27
+ name: "skills",
28
+ format: "text"
29
+ });
30
+ /** Rendered in this order, before custom sections. */
31
+ const builtins = Object.freeze([
32
+ Rules,
33
+ Addendum,
34
+ ProjectContext,
35
+ Skills
36
+ ]);
37
+ /** Rendered by the harness, never by a plugin. */
38
+ const reserved = /* @__PURE__ */ new Set([
39
+ "tools",
40
+ "cwd",
41
+ "foundation"
42
+ ]);
43
+ const pattern = /^[a-z][a-z0-9_-]*$/;
44
+ const formats = /* @__PURE__ */ new Set(["text", "list"]);
45
+ /** Runtime check: a JavaScript plugin can pass anything. */
46
+ const isFormat = (format) => formats.has(format);
47
+ const invalid = (name) => {
48
+ if (typeof name !== "string" || !pattern.test(name)) return `prompt section name must be lowercase letters, digits, "_" or "-": ${JSON.stringify(name)}`;
49
+ if (reserved.has(name)) return `prompt section name is reserved: ${name}`;
50
+ };
51
+ /** A custom section. Throws on a name that is malformed, reserved, or built in. */
52
+ const define = (name, options) => {
53
+ const reason = invalid(name) ?? (builtins.some((section) => section.name === name) ? `prompt section name is built in: ${name}` : void 0);
54
+ if (reason !== void 0) throw new Error(reason);
55
+ const format = options?.format ?? "text";
56
+ if (!isFormat(format)) throw new Error(`prompt section format must be "text" or "list": ${JSON.stringify(format)}`);
57
+ return Object.freeze({
58
+ name,
59
+ format
60
+ });
61
+ };
62
+ //#endregion
63
+ export { Addendum, ProjectContext, Rules, Skills, builtins, define, invalid, isFormat, reserved, section_exports as t };
64
+
65
+ //# sourceMappingURL=section.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"section.mjs","names":[],"sources":["../../../src/plugin/section.ts"],"sourcesContent":["// Sections are passed by value, never by name string, so a typo fails to compile instead of\n// quietly opening a new section.\n\n/** `text`: entries verbatim, blank-line separated. `list`: deduplicated `- ` bullets. */\nexport type Format = \"text\" | \"list\";\n\nexport interface Section<Name extends string = string> {\n\treadonly name: Name;\n\treadonly format: Format;\n}\n\nexport const Rules: Section<\"rules\"> = Object.freeze({ name: \"rules\", format: \"list\" });\nexport const Addendum: Section<\"addendum\"> = Object.freeze({ name: \"addendum\", format: \"text\" });\nexport const ProjectContext: Section<\"project_context\"> = Object.freeze({ name: \"project_context\", format: \"text\" });\nexport const Skills: Section<\"skills\"> = Object.freeze({ name: \"skills\", format: \"text\" });\n\n/** Rendered in this order, before custom sections. */\nexport const builtins: ReadonlyArray<Section> = Object.freeze([Rules, Addendum, ProjectContext, Skills]);\n\n/** Rendered by the harness, never by a plugin. */\nexport const reserved: ReadonlySet<string> = new Set([\"tools\", \"cwd\", \"foundation\"]);\n\nconst pattern = /^[a-z][a-z0-9_-]*$/;\n\nconst formats: ReadonlySet<unknown> = new Set<Format>([\"text\", \"list\"]);\n\n/** Runtime check: a JavaScript plugin can pass anything. */\nexport const isFormat = (format: unknown): format is Format => formats.has(format);\n\nexport const invalid = (name: unknown): string | undefined => {\n\tif (typeof name !== \"string\" || !pattern.test(name))\n\t\treturn `prompt section name must be lowercase letters, digits, \"_\" or \"-\": ${JSON.stringify(name)}`;\n\tif (reserved.has(name)) return `prompt section name is reserved: ${name}`;\n\treturn undefined;\n};\n\n/** A custom section. Throws on a name that is malformed, reserved, or built in. */\nexport const define = <const Name extends string>(\n\tname: Name,\n\toptions?: { readonly format?: Format },\n): Section<Name> => {\n\tconst reason =\n\t\tinvalid(name) ??\n\t\t(builtins.some((section) => section.name === name) ? `prompt section name is built in: ${name}` : undefined);\n\tif (reason !== undefined) throw new Error(reason);\n\tconst format = options?.format ?? \"text\";\n\tif (!isFormat(format)) throw new Error(`prompt section format must be \"text\" or \"list\": ${JSON.stringify(format)}`);\n\treturn Object.freeze({ name, format });\n};\n"],"mappings":";;;;;;;;;;;;;AAWA,MAAa,QAA0B,OAAO,OAAO;CAAE,MAAM;CAAS,QAAQ;AAAO,CAAC;AACtF,MAAa,WAAgC,OAAO,OAAO;CAAE,MAAM;CAAY,QAAQ;AAAO,CAAC;AAC/F,MAAa,iBAA6C,OAAO,OAAO;CAAE,MAAM;CAAmB,QAAQ;AAAO,CAAC;AACnH,MAAa,SAA4B,OAAO,OAAO;CAAE,MAAM;CAAU,QAAQ;AAAO,CAAC;;AAGzF,MAAa,WAAmC,OAAO,OAAO;CAAC;CAAO;CAAU;CAAgB;AAAM,CAAC;;AAGvG,MAAa,2BAAgC,IAAI,IAAI;CAAC;CAAS;CAAO;AAAY,CAAC;AAEnF,MAAM,UAAU;AAEhB,MAAM,0BAAgC,IAAI,IAAY,CAAC,QAAQ,MAAM,CAAC;;AAGtE,MAAa,YAAY,WAAsC,QAAQ,IAAI,MAAM;AAEjF,MAAa,WAAW,SAAsC;CAC7D,IAAI,OAAO,SAAS,YAAY,CAAC,QAAQ,KAAK,IAAI,GACjD,OAAO,sEAAsE,KAAK,UAAU,IAAI;CACjG,IAAI,SAAS,IAAI,IAAI,GAAG,OAAO,oCAAoC;AAEpE;;AAGA,MAAa,UACZ,MACA,YACmB;CACnB,MAAM,SACL,QAAQ,IAAI,MACX,SAAS,MAAM,YAAY,QAAQ,SAAS,IAAI,IAAI,oCAAoC,SAAS,KAAA;CACnG,IAAI,WAAW,KAAA,GAAW,MAAM,IAAI,MAAM,MAAM;CAChD,MAAM,SAAS,SAAS,UAAU;CAClC,IAAI,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,MAAM,mDAAmD,KAAK,UAAU,MAAM,GAAG;CAClH,OAAO,OAAO,OAAO;EAAE;EAAM;CAAO,CAAC;AACtC"}
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 };