@codeworksh/harness 0.0.1-dev.20260907170816 → 0.0.1-dev.20260922135939

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -15,6 +15,147 @@ The initial public surface is the Effect SDK at `@codeworksh/harness/effect`.
15
15
  - **Model Flexibility:** select any provider and model available in Aikit's generated catalog, including its supported thinking levels.
16
16
  - **Pluggable Sandboxes:** run the same workflow against the host machine, a virtual filesystem, or a remote sandbox.
17
17
 
18
+ ## Plugins
19
+
20
+ Third-party plugins build against [`@codeworksh/plugin`](../plugin/README.md), the published SDK
21
+ that owns the plugin, tool and sandbox contract this package consumes — a plugin package depends
22
+ on it rather than on the whole harness. The same types are re-exported here as `Plugin` and `Tool`
23
+ for embedders who already hold the harness.
24
+
25
+ Pass a plugin list when constructing the harness. Each plugin declares an ID and the domain it extends — `tool` or `prompt` — and contributes during setup. Setup runs once per exchange, after model resolution; its tools, hooks, and prompt remain pinned through tool continuations.
26
+
27
+ ```ts
28
+ import { Effect, Schema } from "effect";
29
+ import { Harness, Plugin, Tool } from "@codeworksh/harness/effect";
30
+
31
+ const echo = Plugin.define({
32
+ id: "acme.tool.echo",
33
+ kind: "tool",
34
+ setup(ctx) {
35
+ ctx.plugin.tools.add(
36
+ Tool.register(
37
+ Tool.make({
38
+ name: "echo",
39
+ description: "Echo a message",
40
+ parameters: Schema.Struct({ text: Schema.String }),
41
+ success: Schema.String,
42
+ handler: ({ text }) => Effect.succeed(text),
43
+ }),
44
+ ),
45
+ {
46
+ beforeToolCall(call) {
47
+ // Arguments have already been decoded. Return { block: true, reason: "..." }
48
+ // to skip this handler and its after hook.
49
+ },
50
+ afterToolCall({ terminal }) {
51
+ // Completed/error results can be patched through content, details, isError.
52
+ // Aborted results are observation-only; keep cancellation cleanup short.
53
+ },
54
+ },
55
+ );
56
+ },
57
+ });
58
+
59
+ // A prompt plugin renders the system prompt, and indexes every tool registered before it.
60
+ const prompt = Plugin.define({
61
+ id: "acme.prompt.main",
62
+ kind: "prompt",
63
+ setup(ctx) {
64
+ ctx.plugin.prompt.set(
65
+ `You have: ${ctx.plugin.tools
66
+ .list()
67
+ .map((tool) => tool.name)
68
+ .join(", ")}`,
69
+ );
70
+ },
71
+ });
72
+
73
+ // Omit `plugins` for the built-ins plus whatever settings add; passing it owns the whole
74
+ // selection, which is why this one supplies its own prompt plugin.
75
+ const runtime = Harness.layer({ plugins: [echo, prompt] });
76
+ ```
77
+
78
+ Hooks belong to the tool registration. Sequential or parallel scheduling, selected with `Session.create({ tools: { execution: "parallel" } })`, covers the entire hook/handler pipeline. After runs for a started, interrupted tool if it has not already started, with a one-second cooperative cleanup grace period. The kernel owns result settlement.
79
+
80
+ `ctx.plugin.tools.update(name, patch)` rewrites a registration's model-facing prose without replacing the tool or its hooks. A read sees only earlier contributions, so a plugin patching `promptSnippet` or `promptGuidelines` must run _before_ the tool it patches is indexed. Declaring `kind: "tool"` puts it ahead of every prompt plugin already; what it still has to get right is its position among the other tool plugins, which is the order their entries are written in.
81
+
82
+ Prompt plugins use `ctx.plugin.prompt.get()` and `set(string)`. Each `set` replaces the entire prompt, including with an empty string. Place a prompt plugin after the tools or prompt contributors it needs. Contributions close after setup; plugins receive event publication but no subscription or background lifecycle.
83
+
84
+ Omitting `plugins` selects Bash then the default prompt, followed by the host settings' `plugins` block. An explicit array replaces all of that, and an empty one runs nothing — which is not a usable harness: `freeze` requires a system prompt, so a selection without a prompt plugin fails every exchange with `SnapshotError("no prompt plugin set a system prompt")`. Every working selection ends with a prompt plugin, whether `codework.prompt.default` or your own.
85
+
86
+ An entry is a **module** or a **configuration object**.
87
+
88
+ A module is a definition object, a local path, a `file:` URL, or a package spec. It is loaded if it is not already, and it takes the position it is written at — naming a module again moves it:
89
+
90
+ ```ts
91
+ plugins: [echo, "./plugins/local.ts", "file:///opt/plugin.mjs", "@acme/codework-tool-proc@1.2.0"];
92
+ ```
93
+
94
+ A configuration object addresses a plugin **something else already selected**, and names it one of two ways:
95
+
96
+ ```jsonc
97
+ { "plugin": "acme.tool.proc", "options": { "limit": 40 } } // by ID, when you know it
98
+ { "package": "@acme/codework-tool-proc", "options": { "limit": 40 } } // by the package it came from
99
+ { "plugin": "codework.tool.bash", "enabled": false } // drop a built-in
100
+ ```
101
+
102
+ Exactly one of `plugin` and `package` per entry. `plugin` is a plugin's ID; `package` is any name the module answers to — the package name, the exact spec, the path it was loaded from, or the name a local package's own manifest declares.
103
+
104
+ An **ID is a key**. The last module to claim one owns it, and the configuration written against it stays with the key rather than with whichever module is currently behind it. Two modules exporting one ID is the author's conflict to resolve — the replacement is logged at debug, not arbitrated here.
105
+
106
+ A configuration object **never loads, installs or reorders anything**. If its name matches nothing in the selection — a typo, a package you have not added, a plugin this build does not ship — the entry is **ignored**: one debug line, no failure, and nothing fetched. So adding a package and configuring it is two entries, in that order:
107
+
108
+ ```jsonc
109
+ { "plugins": ["@acme/codework-tool-proc@1.2.0", { "package": "@acme/codework-tool-proc", "options": { "limit": 40 } }] }
110
+ ```
111
+
112
+ Repeated configuration replaces rather than merges — the block is opaque, so the last entry owns it whole. `options` reaches that plugin as the second argument to `setup`, `{}` when nothing configured it. The harness never looks inside it, including the `null`s it strips everywhere else in a settings file, since inside an opaque block a `null` is a value its plugin may need:
113
+
114
+ ```ts
115
+ Plugin.define({
116
+ id: "acme.tool.proc",
117
+ setup(ctx, options) {
118
+ const limit = typeof options.limit === "number" ? options.limit : 10;
119
+ },
120
+ });
121
+ ```
122
+
123
+ Source modules must default-export one plugin object.
124
+
125
+ Settings entries take the same two forms, and they extend the built-in selection instead of standing in for it, so naming one plugin cannot silently drop Bash or the prompt:
126
+
127
+ ```jsonc
128
+ // <project>/.codework/settings.jsonc, ~/.codework/settings.jsonc, or a --user-config-dir
129
+ {
130
+ "plugins": [
131
+ "@acme/codework-prompt-life",
132
+ "@acme/codework-tool-proc@1.2.0",
133
+ "./plugins/local.ts",
134
+ { "package": "@acme/codework-tool-proc", "options": { "limit": 20 } },
135
+ { "plugin": "codework.tool.bash", "enabled": false },
136
+ ],
137
+ }
138
+ ```
139
+
140
+ Settings files are JSONC: comments and a trailing comma are part of the format, and a syntax error names what the parser expected and where (`PropertyNameExpected at 2:38`). Entries accumulate across settings layers, lowest priority first: a project's list extends the user's rather than standing in for it, the way every other key in the document merges. A project drops an inherited plugin the same way it drops a built-in, with `{ "plugin": "<id>", "enabled": false }`. A leading `~` expands to the home directory. A `./` or `../` path resolves against the directory of the file that declared it — inside `<project>/.codework/`, or beside `~/.codework/settings.jsonc` — so one entry means one file in every project; a `package` naming a relative path is anchored the same way. `file:` URLs, absolute paths and package specs are taken as written.
141
+
142
+ Setup order comes from the **domain a plugin declares**, not from where its entry sits. Every `kind: "tool"` plugin is set up before any `kind: "prompt"` plugin, so a prompt plugin always sees the complete tool set — including tools added from a settings file, which land after the built-ins in the array. Within one domain, entries keep the order they were written in, which is where composition actually happens: a plugin patching another's tool, or appending to the prompt a previous one rendered, is written after it on purpose.
143
+
144
+ That is the reason `kind` is part of the definition rather than something the harness guesses. A user's settings file and a project's are edited by different people at different times, and neither can see the other's ordering; what each plugin _is_ remains knowable in both.
145
+
146
+ A plugin package declares `@codeworksh/harness` and `effect` as **exact peer dependencies**, never as dependencies:
147
+
148
+ ```jsonc
149
+ "peerDependencies": { "@codeworksh/harness": "0.0.1", "effect": "4.0.0-rc.115" },
150
+ "devDependencies": { "effect": "4.0.0-rc.115" }
151
+ ```
152
+
153
+ A plugin is installed into its own directory, so its Effect is a separate module instance from the harness's. Two instances of the _same_ version interoperate completely — service tags resolve by their string id, and schemas, generators and handlers all cross the boundary. Two different _versions_ do not: a tool's schema then encodes a result the harness cannot commit. Declaring the peer moves that from a runtime failure to a line during `npm install`, and `test/plugin.foreign.test.ts` holds the interop itself in place.
154
+
155
+ Package sources install with pnpm, with lifecycle scripts disabled, under the harness home cache. The installer inherits stderr, so a first install prints pnpm's own progress and errors to the terminal — and a `plugins` entry in a settings file means that can happen during `Harness.layer` construction, before any session exists. An omitted version means `latest` on the first installation; subsequent constructions reuse that completed installation. The selection is read once per `Harness.layer`, so an edited `plugins` block applies at the next construction; hot reload and daemon lifecycles are not implemented.
156
+
157
+ Failures are attributed: a bad reference, unreadable module, or malformed plugin fails `Harness.layer` construction with `PluginPreparationError`, which carries the failing phase (`source`, `install`, `import`, or `definition`) and the index of the offending reference. A failing package install reports `PluginInstallError`; a plugin's `setup` failure becomes `Plugin.SetupError` with the plugin id, surfacing as a `SnapshotError` for that exchange. Plugins are trusted in-process code — local paths and `file:` references import whatever they point at, so only load sources you trust.
158
+
18
159
  ## Pluggable Sandboxes
19
160
 
20
161
  Harness uses a driver-based sandbox architecture. Drivers share a common lifecycle and I/O surface, keeping provider details out of session and agent-loop code.
@@ -130,7 +271,7 @@ export DAYTONA_API_KEY="..."
130
271
 
131
272
  pnpm dlx @codeworksh/harness@dev \
132
273
  --home .codework-beta \
133
- run --sandbox daytona --provider openai --model gpt-5.5 \
274
+ run --sandbox-driver daytona --provider openai --model gpt-5.5 \
134
275
  "Inspect this repository"
135
276
  ```
136
277
 
@@ -139,13 +280,13 @@ Pass the provider's sandbox ID to connect a new Harness session to an existing D
139
280
  ```sh
140
281
  pnpm dlx @codeworksh/harness@dev \
141
282
  --home .codework-beta \
142
- run --sandbox daytona --sandbox-provider-id <daytona-sandbox-id> \
283
+ run --sandbox-driver daytona --sandbox-provider-id <daytona-sandbox-id> \
143
284
  "Continue work in this sandbox"
144
285
  ```
145
286
 
146
287
  `--cwd` overrides the selected sandbox's default working directory. When continuing with `--session`, omit the sandbox flags: the durable session already references its sandbox.
147
288
 
148
- The same flags work with Vercel Sandbox by using `--sandbox vercel`; `--sandbox-provider-id` then accepts the existing Vercel sandbox name.
289
+ The same flags work with Vercel Sandbox by using `--sandbox-driver vercel`; `--sandbox-provider-id` then accepts the existing Vercel sandbox name.
149
290
 
150
291
  Use `codework --help` or `pnpm dlx @codeworksh/harness@dev --help` for all options.
151
292
 
@@ -1,4 +1,5 @@
1
- import { C as Name, E as driver, L as quote, M as resolveMountCwd, N as Shell, P as ShellError, R as quoteArgv, S as AbsolutePath, T as defineModule, U as fromProvider, V as Service, Y as PersistedError, n as Service$1, nt as posix, v as makeRedactor, y as providerError, z as resolveCwd } from "./sandbox-QCmZ3UhD.mjs";
1
+ import { a as io_exports, n as shell_exports, o as instance_exports, r as filesystem_exports, s as posix, t as resource_exports } from "./resource-DFZh0e-s.mjs";
2
+ import { SandboxDriver, SandboxProvider } from "./sandbox.mjs";
2
3
  import { Context, DateTime, Effect, Layer, Option, Schema } from "effect";
3
4
  import { Buffer } from "node:buffer";
4
5
  //#region src/sandboxes/daytona/fs.ts
@@ -19,7 +20,8 @@ const make$1 = (provider, options) => {
19
20
  readdir: (path) => provider.readdir(resolve(path)),
20
21
  exists: (path) => provider.exists(resolve(path)),
21
22
  mkdir: (path, mkdirOptions) => provider.mkdir(resolve(path), mkdirOptions),
22
- rm: (path, rmOptions) => provider.rm(resolve(path), rmOptions)
23
+ rm: (path, rmOptions) => provider.rm(resolve(path), rmOptions),
24
+ realpath: (path) => provider.realpath(resolve(path))
23
25
  };
24
26
  };
25
27
  //#endregion
@@ -40,9 +42,9 @@ const DEFAULT_CWD = "/home/daytona";
40
42
  */
41
43
  const mountCwd = async (cwd, getWorkDir) => {
42
44
  const defaultCwd = posix.isAbsolute(cwd ?? "") ? DEFAULT_CWD : await getWorkDir() ?? "/home/daytona";
43
- return resolveMountCwd(defaultCwd, cwd);
45
+ return io_exports.SandboxIO.resolveMountCwd(defaultCwd, cwd);
44
46
  };
45
- Schema.TaggedError()("DaytonaError", { sanitized: PersistedError });
47
+ Schema.TaggedError()("DaytonaError", { sanitized: instance_exports.SandboxInstance.PersistedError });
46
48
  var Remote = class extends Context.Service()("@codeworksh/harness/sandboxes/daytona/provider/Remote") {};
47
49
  const assertCommandSucceeded = (command, result) => {
48
50
  if (result.exitCode !== 0) throw new Error(result.result || `command failed (${result.exitCode}): ${command}`);
@@ -69,7 +71,7 @@ const providerFrom = (sandbox, options) => {
69
71
  writeFile: (path, content) => sandbox.fs.uploadFile(typeof content === "string" ? Buffer.from(content, "utf8") : Buffer.from(content), path),
70
72
  stat: async (path) => statsFrom(await sandbox.fs.getFileDetails(path)),
71
73
  lstat: async (path) => {
72
- const command = `test -L ${quote(path)}`;
74
+ const command = `test -L ${(0, shell_exports.quote)(path)}`;
73
75
  const result = await sandbox.process.executeCommand(command, options.cwd, void 0, options.execTimeout);
74
76
  if (result.exitCode === 0) return {
75
77
  isFile: false,
@@ -96,7 +98,7 @@ const providerFrom = (sandbox, options) => {
96
98
  await sandbox.fs.createFolder(path, "755");
97
99
  return;
98
100
  }
99
- const command = `mkdir -p ${quote(path)}`;
101
+ const command = `mkdir -p ${(0, shell_exports.quote)(path)}`;
100
102
  const result = await sandbox.process.executeCommand(command, options.cwd, void 0, options.execTimeout);
101
103
  assertCommandSucceeded(command, result);
102
104
  },
@@ -108,13 +110,33 @@ const providerFrom = (sandbox, options) => {
108
110
  if (rmOptions?.force && !await filesystem.exists(path)) return;
109
111
  throw cause;
110
112
  }
113
+ },
114
+ realpath: async (path) => {
115
+ const run = async (script) => {
116
+ const command = (0, shell_exports.quoteArgv)([
117
+ "sh",
118
+ "-c",
119
+ script,
120
+ "_",
121
+ path
122
+ ]);
123
+ return {
124
+ command,
125
+ result: await sandbox.process.executeCommand(command, options.cwd, void 0, options.execTimeout)
126
+ };
127
+ };
128
+ const asDirectory = await run(filesystem_exports.SandboxFileSystem.realpathScripts[0]);
129
+ if (asDirectory.result.exitCode === 0) return (asDirectory.result.result ?? "").trimEnd();
130
+ const asFile = await run(filesystem_exports.SandboxFileSystem.realpathScripts[1]);
131
+ assertCommandSucceeded(asFile.command, asFile.result);
132
+ return (asFile.result.result ?? "").trimEnd();
111
133
  }
112
134
  };
113
135
  return filesystem;
114
136
  };
115
137
  const runCommand = (sandbox, options, command, opts) => Effect.tryPromise({
116
- try: () => sandbox.process.executeCommand(command, resolveCwd(options.cwd, opts?.cwd), opts?.env, options.execTimeout),
117
- catch: (cause) => new ShellError({
138
+ try: () => sandbox.process.executeCommand(command, (0, shell_exports.resolveCwd)(options.cwd, opts?.cwd), opts?.env, options.execTimeout),
139
+ catch: (cause) => new shell_exports.ShellError({
118
140
  command,
119
141
  cause
120
142
  })
@@ -124,7 +146,7 @@ const runCommand = (sandbox, options, command, opts) => Effect.tryPromise({
124
146
  exitCode: response.exitCode
125
147
  })));
126
148
  const exec = (sandbox, options) => (command, opts) => runCommand(sandbox, options, command, opts);
127
- const execArgv = (sandbox, options) => (argv, opts) => runCommand(sandbox, options, quoteArgv(argv), opts);
149
+ const execArgv = (sandbox, options) => (argv, opts) => runCommand(sandbox, options, (0, shell_exports.quoteArgv)(argv), opts);
128
150
  /**
129
151
  * Cwd-neutral IO attachment for a lifecycle driver.
130
152
  *
@@ -133,11 +155,11 @@ const execArgv = (sandbox, options) => (argv, opts) => runCommand(sandbox, optio
133
155
  * itself keeps no mutable working-directory state and owns no resource
134
156
  * finalizer.
135
157
  */
136
- const transport = (sandbox, options = {}) => Layer.merge(Layer.succeed(Service, fromProvider(make$1(providerFrom(sandbox, options)))), Layer.succeed(Shell, Shell.of({
158
+ const transport = (sandbox, options = {}) => Layer.merge(Layer.succeed(filesystem_exports.SandboxFileSystem.Service, filesystem_exports.SandboxFileSystem.fromProvider(make$1(providerFrom(sandbox, options)))), Layer.succeed(shell_exports.Shell, shell_exports.Shell.of({
137
159
  exec: exec(sandbox, options),
138
160
  execArgv: execArgv(sandbox, options)
139
161
  })));
140
- Layer.effect(Service$1, Effect.map(Remote, ({ sandbox }) => ({ providerResourceId: sandbox.id })));
162
+ Layer.effect(resource_exports.SandboxResource.Service, Effect.map(Remote, ({ sandbox }) => ({ providerResourceId: sandbox.id })));
141
163
  //#endregion
142
164
  //#region src/sandboxes/daytona/index.ts
143
165
  const Options = Schema.Struct({
@@ -164,11 +186,11 @@ const CreateConfig = Schema.Struct({
164
186
  execTimeout: Schema.optional(Schema.Finite)
165
187
  });
166
188
  const RuntimeConfig = Schema.Struct({
167
- defaultCwd: AbsolutePath,
189
+ defaultCwd: SandboxDriver.AbsolutePath,
168
190
  user: Schema.optional(Schema.String),
169
191
  execTimeout: Schema.optional(Schema.Finite)
170
192
  });
171
- const name = Name.make("daytona");
193
+ const name = SandboxDriver.Name.make("daytona");
172
194
  const statusFrom = (state) => {
173
195
  return {
174
196
  status: state === "stopped" || state === "archived" ? "offline" : state === "stopping" || state === "archiving" || state === "snapshotting" || state === "destroying" ? "suspending" : state === "destroyed" ? "unavail" : state === "error" || state === "build_failed" || state === "unknown" ? "faulted" : "online",
@@ -177,7 +199,7 @@ const statusFrom = (state) => {
177
199
  };
178
200
  const shouldWake = (sandbox) => sandbox.state === "stopped" || sandbox.state === "archived";
179
201
  const make = (client = {}) => {
180
- const redact = makeRedactor([client.apiKey ?? ""]);
202
+ const redact = SandboxProvider.makeRedactor([client.apiKey ?? ""]);
181
203
  const daytona = (sdk) => new sdk.Daytona({
182
204
  ...client.apiKey === void 0 ? {} : { apiKey: client.apiKey },
183
205
  ...client.apiUrl === void 0 ? {} : { apiUrl: client.apiUrl },
@@ -190,7 +212,7 @@ const make = (client = {}) => {
190
212
  sdk = loaded;
191
213
  return run(loaded);
192
214
  }),
193
- catch: (cause) => providerError({
215
+ catch: (cause) => SandboxProvider.providerError({
194
216
  driver: name,
195
217
  operation,
196
218
  cause,
@@ -207,11 +229,11 @@ const make = (client = {}) => {
207
229
  });
208
230
  const wake = (sandbox, operation) => shouldWake(sandbox) ? attempt(operation, () => sandbox.start()).pipe(Effect.map(() => sandbox)) : Effect.succeed(sandbox);
209
231
  const runtime = (defaultCwd, input) => ({
210
- defaultCwd: AbsolutePath.make(defaultCwd),
232
+ defaultCwd: SandboxDriver.AbsolutePath.make(defaultCwd),
211
233
  ...input.user === void 0 ? {} : { user: input.user },
212
234
  ...input.execTimeout === void 0 ? {} : { execTimeout: input.execTimeout }
213
235
  });
214
- return driver({
236
+ return SandboxDriver.driver({
215
237
  name,
216
238
  kind: "remote",
217
239
  capabilities: {
@@ -259,7 +281,7 @@ const make = (client = {}) => {
259
281
  runtimeConfigFor: ({ providerResourceId, overrides }) => Effect.gen(function* () {
260
282
  const sandbox = yield* get(providerResourceId, "runtimeConfigFor");
261
283
  return {
262
- defaultCwd: overrides?.defaultCwd ?? AbsolutePath.make(yield* attempt("runtimeConfigFor.cwd", () => mountCwd(void 0, () => sandbox.getWorkDir()))),
284
+ defaultCwd: overrides?.defaultCwd ?? SandboxDriver.AbsolutePath.make(yield* attempt("runtimeConfigFor.cwd", () => mountCwd(void 0, () => sandbox.getWorkDir()))),
263
285
  ...overrides?.user === void 0 ? { user: sandbox.user } : { user: overrides.user },
264
286
  ...overrides?.execTimeout === void 0 ? {} : { execTimeout: overrides.execTimeout }
265
287
  };
@@ -275,8 +297,8 @@ const make = (client = {}) => {
275
297
  destroy: (input) => Effect.flatMap(get(Option.getOrElse(input.providerResourceId, () => input.id), "destroy"), (sandbox) => attempt("destroy", () => sandbox.delete()))
276
298
  });
277
299
  };
278
- const sandbox = defineModule({
279
- apiVersion: 1,
300
+ const sandbox = SandboxDriver.module({
301
+ apiVersion: SandboxDriver.apiVersion,
280
302
  name,
281
303
  options: Options,
282
304
  make
@@ -288,4 +310,4 @@ const config = (value) => ({
288
310
  //#endregion
289
311
  export { RuntimeConfig as a, sandbox as c, ResourcesConfig as i, CreateConfig as n, config as o, Options as r, make as s, ClientOptions as t };
290
312
 
291
- //# sourceMappingURL=daytona-C6wWlJ4z.mjs.map
313
+ //# sourceMappingURL=daytona-BAurx6Gp.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"daytona-BAurx6Gp.mjs","names":["make","SandboxIO","SandboxInstance","quote","quoteArgv","SandboxFileSystem","resolveCwd","ShellError","RemoteFileSystem.make","Shell","SandboxResource","EnvDaytona.mountCwd","EnvDaytona.transport"],"sources":["../../src/sandboxes/daytona/fs.ts","../../src/sandboxes/daytona/provider.ts","../../src/sandboxes/daytona/index.ts"],"sourcesContent":["import { posix } from \"../../util/posix.ts\";\nimport { SandboxFileSystem } from \"../../sandbox/fs/filesystem.ts\";\n\nexport type FileStat = SandboxFileSystem.FileStat;\n\nexport interface Interface extends SandboxFileSystem.Provider {\n\treadonly lstat?: (path: string) => Promise<FileStat>;\n}\n\nexport interface Options {\n\treadonly cwd?: string;\n}\n\nconst resolvePath = (path: string, options?: Options) => {\n\tconst normalized = posix.normalize(path);\n\tif (options?.cwd === undefined || posix.isAbsolute(normalized)) return normalized;\n\treturn posix.normalize(posix.join(options.cwd, normalized));\n};\n\n/** Resolve provider paths without adding policy or mutable working-directory state. */\nexport const make = (provider: Interface, options?: Options): SandboxFileSystem.Provider => {\n\tconst resolve = (path: string) => resolvePath(path, options);\n\n\treturn {\n\t\treadFile: (path) => provider.readFile(resolve(path)),\n\t\treadFileBuffer: (path) => provider.readFileBuffer(resolve(path)),\n\t\twriteFile: (path, content) => provider.writeFile(resolve(path), content),\n\t\tstat: (path) => provider.stat(resolve(path)),\n\t\t...(provider.lstat === undefined ? {} : { lstat: (path: string) => provider.lstat!(resolve(path)) }),\n\t\treaddir: (path) => provider.readdir(resolve(path)),\n\t\texists: (path) => provider.exists(resolve(path)),\n\t\tmkdir: (path, mkdirOptions) => provider.mkdir(resolve(path), mkdirOptions),\n\t\trm: (path, rmOptions) => provider.rm(resolve(path), rmOptions),\n\t\trealpath: (path) => provider.realpath(resolve(path)),\n\t};\n};\n\nexport const withProvider = make;\n","/* oxlint-disable effecttsgo/async-function -- Daytona's SDK boundary is Promise-based. */\nimport { Context, DateTime, Effect, Layer, Option, Schema } from \"effect\";\nimport { Buffer } from \"node:buffer\";\nimport { posix } from \"../../util/posix.ts\";\nimport { sanitizeError } from \"../../sandbox/errors.ts\";\nimport { SandboxFileSystem } from \"../../sandbox/fs/filesystem.ts\";\nimport { SandboxInstance } from \"../../sandbox/instance.ts\";\nimport { SandboxIO } from \"../../sandbox/io.ts\";\nimport { SandboxResource } from \"../../sandbox/resource.ts\";\nimport { type ISandboxExe, quote, quoteArgv, resolveCwd, Shell, ShellError } from \"../../sandbox/shell/shell.ts\";\nimport * as RemoteFileSystem from \"./fs.ts\";\n\ntype CodeLanguage = import(\"@daytona/sdk\").CodeLanguage;\ntype Daytona = import(\"@daytona/sdk\").Daytona;\ntype FileInfo = import(\"@daytona/sdk\").FileInfo;\ntype Image = import(\"@daytona/sdk\").Image;\ntype RemoteSandbox = import(\"@daytona/sdk\").Sandbox;\ntype Resources = import(\"@daytona/sdk\").Resources;\n\n/** Fallback when Daytona cannot report a snapshot/image-specific work directory. */\nexport const DEFAULT_CWD = \"/home/daytona\";\n\n/**\n * The mount cwd for a Daytona namespace.\n *\n * An absolute override replaces the namespace default outright, so the\n * `getWorkDir()` round-trip is skipped: it would discover a value we then throw\n * away. Otherwise the sandbox's own work directory is the default, and\n * {@link DEFAULT_CWD} covers a snapshot or image that reports none.\n *\n * Taken as a thunk rather than read off the sandbox so all three branches are\n * testable without provisioning one — this decides where every Daytona mount\n * roots, and §8.1 makes a wrong answer here resolve silently rather than fail.\n */\nexport const mountCwd = async (\n\tcwd: string | undefined,\n\tgetWorkDir: () => Promise<string | undefined>,\n): Promise<string> => {\n\tconst defaultCwd = posix.isAbsolute(cwd ?? \"\") ? DEFAULT_CWD : ((await getWorkDir()) ?? DEFAULT_CWD);\n\treturn SandboxIO.resolveMountCwd(defaultCwd, cwd);\n};\n\nexport class DaytonaError extends Schema.TaggedError<DaytonaError>()(\"DaytonaError\", {\n\tsanitized: SandboxInstance.PersistedError,\n}) {}\n\nexport interface Options {\n\t/** API key. Falls back to the `DAYTONA_API_KEY` env var when omitted. */\n\treadonly apiKey?: string | undefined;\n\t/** API URL. Falls back to `DAYTONA_API_URL` / the SDK default. */\n\treadonly apiUrl?: string | undefined;\n\t/** Target region. Falls back to `DAYTONA_TARGET` / the SDK default. */\n\treadonly target?: string | undefined;\n\t/** Reuse an existing sandbox by id or name instead of creating one. */\n\treadonly sandboxId?: string | undefined;\n\t/** Durable instance identity for this namespace. Supplied by the Controller. */\n\treadonly instanceId?: SandboxInstance.ID | undefined;\n\t/** Snapshot to create the sandbox from. */\n\treadonly snapshot?: string | undefined;\n\t/** Image (registry reference or declarative `Image`) to create the sandbox from. */\n\treadonly image?: string | Image | undefined;\n\t/** Runtime used for code execution. Defaults to `\"typescript\"`. */\n\treadonly language?: CodeLanguage | string | undefined;\n\t/** Environment variables baked into the sandbox. */\n\treadonly envVars?: Record<string, string> | undefined;\n\t/** Resource allocation (cpu / memory / disk). */\n\treadonly resources?: Resources | undefined;\n\t/** OS user to run as inside the sandbox. */\n\treadonly user?: string | undefined;\n\t/**\n\t * Mount working directory. Relative values resolve against `getWorkDir()`;\n\t * omitted values use it, with `/home/daytona` as the provider fallback.\n\t */\n\treadonly cwd?: string | undefined;\n\t/** Idle minutes before the sandbox auto-stops. */\n\treadonly autoStopInterval?: number | undefined;\n\t/** Per-command timeout in seconds. 0 means no timeout. */\n\treadonly execTimeout?: number | undefined;\n}\n\ninterface RemoteState {\n\treadonly sandbox: RemoteSandbox;\n\treadonly cwd: string;\n}\n\nclass Remote extends Context.Service<Remote, RemoteState>()(\"@codeworksh/harness/sandboxes/daytona/provider/Remote\") {}\n\nconst assertCommandSucceeded = (command: string, result: { exitCode: number; result?: string }) => {\n\tif (result.exitCode !== 0) throw new Error(result.result || `command failed (${result.exitCode}): ${command}`);\n};\n\nconst dateFrom = (value: string | undefined) => {\n\tif (value === undefined) return undefined;\n\treturn Option.getOrUndefined(DateTime.make(value).pipe(Option.map(DateTime.toDateUtc)));\n};\n\nexport const createSandbox = (daytona: Daytona, options: Options) => {\n\tconst base = {\n\t\tlanguage: options.language ?? \"typescript\",\n\t\t...(options.envVars === undefined ? {} : { envVars: options.envVars }),\n\t\t...(options.user === undefined ? {} : { user: options.user }),\n\t\t...(options.autoStopInterval === undefined ? {} : { autoStopInterval: options.autoStopInterval }),\n\t\tautoDeleteInterval: -1,\n\t};\n\treturn options.image !== undefined\n\t\t? daytona.create({\n\t\t\t\t...base,\n\t\t\t\timage: options.image,\n\t\t\t\t...(options.resources === undefined ? {} : { resources: options.resources }),\n\t\t\t})\n\t\t: daytona.create({ ...base, ...(options.snapshot === undefined ? {} : { snapshot: options.snapshot }) });\n};\n\nconst remote = (options: Options) =>\n\tLayer.effect(\n\t\tRemote,\n\t\tEffect.tryPromise({\n\t\t\ttry: async (): Promise<RemoteState> => {\n\t\t\t\tconst { Daytona } = await import(\"@daytona/sdk\");\n\t\t\t\tconst daytona = new Daytona({\n\t\t\t\t\t...(options.apiKey === undefined ? {} : { apiKey: options.apiKey }),\n\t\t\t\t\t...(options.apiUrl === undefined ? {} : { apiUrl: options.apiUrl }),\n\t\t\t\t\t...(options.target === undefined ? {} : { target: options.target }),\n\t\t\t\t});\n\t\t\t\tconst sandbox = options.sandboxId\n\t\t\t\t\t? await daytona.get(options.sandboxId)\n\t\t\t\t\t: await createSandbox(daytona, options);\n\t\t\t\treturn {\n\t\t\t\t\tsandbox,\n\t\t\t\t\tcwd: await mountCwd(options.cwd, () => sandbox.getWorkDir()),\n\t\t\t\t};\n\t\t\t},\n\t\t\tcatch: (cause) => new DaytonaError({ sanitized: sanitizeError(cause) }),\n\t\t}),\n\t);\n\nexport const statsFrom = (info: FileInfo): RemoteFileSystem.FileStat => {\n\tconst symlink = info.mode === undefined ? undefined : info.mode.startsWith(\"l\");\n\tconst mtime = dateFrom(info.modifiedAt ?? info.modTime);\n\n\t// omit size/mtime/isSymbolicLink the toolbox did not report — never fabricate\n\treturn {\n\t\tisFile: !info.isDir && symlink !== true,\n\t\tisDirectory: info.isDir,\n\t\t...(symlink === undefined ? {} : { isSymbolicLink: symlink }),\n\t\t...(info.size === undefined ? {} : { size: info.size }),\n\t\t...(mtime === undefined ? {} : { mtime }),\n\t};\n};\n\ntype RemoteFilesystemProvider = Pick<\n\tRemoteFileSystem.Interface,\n\t\"readFile\" | \"readFileBuffer\" | \"writeFile\" | \"stat\" | \"lstat\" | \"readdir\" | \"exists\" | \"mkdir\" | \"rm\" | \"realpath\"\n>;\n\nconst providerFrom = (sandbox: RemoteSandbox, options: Options) => {\n\tconst filesystem: RemoteFilesystemProvider = {\n\t\treadFile: async (path: string) => (await sandbox.fs.downloadFile(path)).toString(\"utf8\"),\n\t\treadFileBuffer: async (path: string) => new Uint8Array(await sandbox.fs.downloadFile(path)),\n\t\twriteFile: (path: string, content: string | Uint8Array) =>\n\t\t\tsandbox.fs.uploadFile(typeof content === \"string\" ? Buffer.from(content, \"utf8\") : Buffer.from(content), path),\n\t\tstat: async (path: string) => statsFrom(await sandbox.fs.getFileDetails(path)),\n\t\t// The toolbox file-details endpoint follows symlinks. Detect the entry\n\t\t// with the sandbox shell first so lstat never reports target metadata as\n\t\t// if it described the link itself.\n\t\tlstat: async (path: string) => {\n\t\t\tconst command = `test -L ${quote(path)}`;\n\t\t\tconst result = await sandbox.process.executeCommand(command, options.cwd, undefined, options.execTimeout);\n\t\t\tif (result.exitCode === 0) {\n\t\t\t\treturn { isFile: false, isDirectory: false, isSymbolicLink: true };\n\t\t\t}\n\t\t\tif (result.exitCode === 1) return statsFrom(await sandbox.fs.getFileDetails(path));\n\t\t\tassertCommandSucceeded(command, result);\n\t\t\tthrow new Error(`unreachable lstat result for ${path}`);\n\t\t},\n\t\treaddir: async (path: string) => (await sandbox.fs.listFiles(path)).map((entry) => entry.name),\n\t\t// Only a genuine 404 means \"absent\". Auth, rate-limit, and transport\n\t\t// failures propagate: a caller that deletes records on absence must not\n\t\t// be told a path is gone because the API was briefly unreachable.\n\t\texists: async (path: string) => {\n\t\t\ttry {\n\t\t\t\tawait sandbox.fs.getFileDetails(path);\n\t\t\t\treturn true;\n\t\t\t} catch (cause) {\n\t\t\t\tconst { DaytonaNotFoundError } = await import(\"@daytona/sdk\");\n\t\t\t\tif (cause instanceof DaytonaNotFoundError) return false;\n\t\t\t\tthrow cause;\n\t\t\t}\n\t\t},\n\t\tmkdir: async (path: string, mkdirOptions?: { recursive?: boolean }) => {\n\t\t\tif (!mkdirOptions?.recursive) {\n\t\t\t\tawait sandbox.fs.createFolder(path, \"755\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst command = `mkdir -p ${quote(path)}`;\n\t\t\tconst result = await sandbox.process.executeCommand(command, options.cwd, undefined, options.execTimeout);\n\t\t\tassertCommandSucceeded(command, result);\n\t\t},\n\t\trm: async (path: string, rmOptions?: { recursive?: boolean; force?: boolean }) => {\n\t\t\tif (rmOptions?.force && !(await filesystem.exists(path))) return;\n\t\t\ttry {\n\t\t\t\tawait sandbox.fs.deleteFile(path, rmOptions?.recursive);\n\t\t\t} catch (cause) {\n\t\t\t\tif (rmOptions?.force && !(await filesystem.exists(path))) return;\n\t\t\t\tthrow cause;\n\t\t\t}\n\t\t},\n\t\trealpath: async (path: string) => {\n\t\t\tconst run = async (script: string) => {\n\t\t\t\tconst command = quoteArgv([\"sh\", \"-c\", script, \"_\", path]);\n\t\t\t\tconst result = await sandbox.process.executeCommand(command, options.cwd, undefined, options.execTimeout);\n\t\t\t\treturn { command, result };\n\t\t\t};\n\t\t\tconst asDirectory = await run(SandboxFileSystem.realpathScripts[0]);\n\t\t\tif (asDirectory.result.exitCode === 0) return (asDirectory.result.result ?? \"\").trimEnd();\n\t\t\tconst asFile = await run(SandboxFileSystem.realpathScripts[1]);\n\t\t\tassertCommandSucceeded(asFile.command, asFile.result);\n\t\t\treturn (asFile.result.result ?? \"\").trimEnd();\n\t\t},\n\t};\n\n\treturn filesystem;\n};\n\n// Daytona's execute API folds stderr into `result` and reports a single exit\n// code, so the shell surfaces the combined output as stdout and leaves stderr\n// empty rather than inventing a split.\nconst runCommand = (\n\tsandbox: RemoteSandbox,\n\toptions: Options,\n\tcommand: string,\n\topts?: { env?: Record<string, string>; cwd?: string },\n) =>\n\tEffect.tryPromise({\n\t\ttry: () =>\n\t\t\tsandbox.process.executeCommand(command, resolveCwd(options.cwd, opts?.cwd), opts?.env, options.execTimeout),\n\t\tcatch: (cause) => new ShellError({ command, cause }),\n\t}).pipe(Effect.map((response) => ({ stdout: response.result ?? \"\", stderr: \"\", exitCode: response.exitCode })));\n\nconst exec =\n\t(sandbox: RemoteSandbox, options: Options): ISandboxExe[\"exec\"] =>\n\t(command, opts) =>\n\t\trunCommand(sandbox, options, command, opts);\n\n// `executeCommand` takes a single string, so the vector is quoted here rather\n// than spawned; the per-call cwd rides the toolbox's own cwd argument instead\n// of a `cd` prefix.\nconst execArgv =\n\t(sandbox: RemoteSandbox, options: Options): ISandboxExe[\"execArgv\"] =>\n\t(argv, opts) =>\n\t\trunCommand(sandbox, options, quoteArgv(argv), opts);\n\nconst filesystemLayer = (options: Options) =>\n\tLayer.effect(\n\t\tSandboxFileSystem.Service,\n\t\tEffect.map(Remote, ({ sandbox, cwd }) => {\n\t\t\tconst mounted = { ...options, cwd };\n\t\t\treturn SandboxFileSystem.fromProvider(RemoteFileSystem.make(providerFrom(sandbox, mounted), { cwd }));\n\t\t}),\n\t);\n\nconst shellLayer = (options: Options) =>\n\tLayer.effect(\n\t\tShell,\n\t\tEffect.map(Remote, ({ sandbox, cwd }) => {\n\t\t\tconst mounted = { ...options, cwd };\n\t\t\treturn Shell.of({ exec: exec(sandbox, mounted), execArgv: execArgv(sandbox, mounted) });\n\t\t}),\n\t);\n\n/**\n * Cwd-neutral IO attachment for a lifecycle driver.\n *\n * Mount wrappers supply an absolute cwd to every public operation. Internal\n * filesystem helper commands already receive absolute paths, so the transport\n * itself keeps no mutable working-directory state and owns no resource\n * finalizer.\n */\nexport const transport = (\n\tsandbox: RemoteSandbox,\n\toptions: Pick<Options, \"execTimeout\"> = {},\n): Layer.Layer<SandboxFileSystem.Service | Shell> =>\n\tLayer.merge(\n\t\tLayer.succeed(\n\t\t\tSandboxFileSystem.Service,\n\t\t\tSandboxFileSystem.fromProvider(RemoteFileSystem.make(providerFrom(sandbox, options))),\n\t\t),\n\t\tLayer.succeed(\n\t\t\tShell,\n\t\t\tShell.of({\n\t\t\t\texec: exec(sandbox, options),\n\t\t\t\texecArgv: execArgv(sandbox, options),\n\t\t\t}),\n\t\t),\n\t);\n\n// Daytona's locator is the sandbox id. See `SandboxResource` for why this is a\n// shared tag rather than a Daytona-specific one.\nconst resourceLayer = Layer.effect(\n\tSandboxResource.Service,\n\tEffect.map(Remote, ({ sandbox }) => ({ providerResourceId: sandbox.id })),\n);\n\n// Identity is per remote sandbox, not per provider: two sandboxes both rooted at\n// the same directory must not share persisted directory records.\n//\n// The id is minted here only when the caller names none. A durable id is the\n// control plane's to mint and record — deriving one from the provider's own\n// locator is what §6.1 forbids — so a caller that needs the namespace to survive\n// a restart passes `instanceId` rather than relying on this.\nconst identityLayer = (options: Options) =>\n\tLayer.effect(\n\t\tSandboxIO.Current,\n\t\tEffect.map(Remote, ({ cwd }) =>\n\t\t\tSandboxIO.remote({\n\t\t\t\tdriver: \"daytona\",\n\t\t\t\tid: options.instanceId ?? SandboxInstance.ID.create(),\n\t\t\t\tdefaultCwd: cwd,\n\t\t\t}),\n\t\t),\n\t);\n\n/**\n * A Daytona sandbox provides the runtime filesystem service directly plus\n * the sandbox's native remote shell. It intentionally does not provide VFS:\n * remote filesystems have no synchronous filesystem surface.\n */\nexport const layer = (options: Options = {}): Layer.Layer<SandboxIO.Provides | SandboxResource.Service, DaytonaError> =>\n\tLayer.mergeAll(filesystemLayer(options), shellLayer(options), identityLayer(options), resourceLayer).pipe(\n\t\tLayer.provide(remote(options)),\n\t);\n\nexport const services = layer;\n","import { Effect, Layer, Option, Schema } from \"effect\";\nimport { SandboxDriver, SandboxInstance, SandboxProvider } from \"../../sandbox.ts\";\nimport * as EnvDaytona from \"./provider.ts\";\n\nexport const Options = Schema.Struct({\n\tapiKey: Schema.optional(Schema.String),\n\tapiUrl: Schema.optional(Schema.String),\n\ttarget: Schema.optional(Schema.String),\n});\nexport type Options = typeof Options.Type;\nexport const ClientOptions = Options;\nexport type ClientOptions = Options;\n\nexport const ResourcesConfig = Schema.Struct({\n\tcpu: Schema.optional(Schema.Finite),\n\tgpu: Schema.optional(Schema.Finite),\n\tmemory: Schema.optional(Schema.Finite),\n\tdisk: Schema.optional(Schema.Finite),\n});\nexport type ResourcesConfig = typeof ResourcesConfig.Type;\n\nexport const CreateConfig = Schema.Struct({\n\tsnapshot: Schema.optional(Schema.String),\n\timage: Schema.optional(Schema.String),\n\tlanguage: Schema.optional(Schema.String),\n\tenvVars: Schema.optional(Schema.Record(Schema.String, Schema.String)),\n\tresources: Schema.optional(ResourcesConfig),\n\tuser: Schema.optional(Schema.String),\n\tcwd: Schema.optional(Schema.String),\n\tautoStopInterval: Schema.optional(Schema.Finite),\n\texecTimeout: Schema.optional(Schema.Finite),\n});\nexport type CreateConfig = typeof CreateConfig.Type;\n\nexport const RuntimeConfig = Schema.Struct({\n\tdefaultCwd: SandboxDriver.AbsolutePath,\n\tuser: Schema.optional(Schema.String),\n\texecTimeout: Schema.optional(Schema.Finite),\n});\nexport type RuntimeConfig = typeof RuntimeConfig.Type;\n\nconst name = SandboxDriver.Name.make(\"daytona\");\ntype DaytonaSdk = typeof import(\"@daytona/sdk\");\ntype RemoteSandbox = import(\"@daytona/sdk\").Sandbox;\ntype Resources = import(\"@daytona/sdk\").Resources;\n\nconst statusFrom = (\n\tstate: RemoteSandbox[\"state\"],\n): {\n\treadonly status: SandboxInstance.Status;\n\treadonly providerStatus: string;\n} => {\n\tconst providerStatus = state ?? \"unknown\";\n\treturn {\n\t\tstatus:\n\t\t\tstate === \"stopped\" || state === \"archived\"\n\t\t\t\t? \"offline\"\n\t\t\t\t: state === \"stopping\" || state === \"archiving\" || state === \"snapshotting\" || state === \"destroying\"\n\t\t\t\t\t? \"suspending\"\n\t\t\t\t\t: state === \"destroyed\"\n\t\t\t\t\t\t? \"unavail\"\n\t\t\t\t\t\t: state === \"error\" || state === \"build_failed\" || state === \"unknown\"\n\t\t\t\t\t\t\t? \"faulted\"\n\t\t\t\t\t\t\t: \"online\",\n\t\tproviderStatus,\n\t};\n};\n\nconst shouldWake = (sandbox: RemoteSandbox): boolean => sandbox.state === \"stopped\" || sandbox.state === \"archived\";\n\nexport const make = (\n\tclient: ClientOptions = {},\n): SandboxDriver.Driver<CreateConfig, RuntimeConfig> & SandboxDriver.Registration => {\n\tconst redact = SandboxProvider.makeRedactor([client.apiKey ?? \"\"]);\n\tconst daytona = (sdk: DaytonaSdk) =>\n\t\tnew sdk.Daytona({\n\t\t\t...(client.apiKey === undefined ? {} : { apiKey: client.apiKey }),\n\t\t\t...(client.apiUrl === undefined ? {} : { apiUrl: client.apiUrl }),\n\t\t\t...(client.target === undefined ? {} : { target: client.target }),\n\t\t});\n\n\tconst attempt = <A>(\n\t\toperation: string,\n\t\trun: (sdk: DaytonaSdk) => Promise<A>,\n\t): Effect.Effect<A, SandboxProvider.SandboxProviderError> =>\n\t\tEffect.suspend(() => {\n\t\t\tlet sdk: DaytonaSdk | undefined;\n\t\t\treturn Effect.tryPromise({\n\t\t\t\ttry: () =>\n\t\t\t\t\timport(\"@daytona/sdk\").then((loaded) => {\n\t\t\t\t\t\tsdk = loaded;\n\t\t\t\t\t\treturn run(loaded);\n\t\t\t\t\t}),\n\t\t\t\tcatch: (cause) =>\n\t\t\t\t\tSandboxProvider.providerError({\n\t\t\t\t\t\tdriver: name,\n\t\t\t\t\t\toperation,\n\t\t\t\t\t\tcause,\n\t\t\t\t\t\tredact,\n\t\t\t\t\t\tnotFound: sdk !== undefined && cause instanceof sdk.DaytonaNotFoundError,\n\t\t\t\t\t}),\n\t\t\t});\n\t\t});\n\n\tconst get = (providerResourceId: string, operation: string) =>\n\t\tattempt(operation, (sdk) => daytona(sdk).get(providerResourceId));\n\n\tconst refresh = (sandbox: RemoteSandbox, operation: string) =>\n\t\tattempt(operation, () => sandbox.refreshData()).pipe(Effect.as(sandbox));\n\n\tconst observed = (sandbox: RemoteSandbox): SandboxDriver.Observed => ({\n\t\t...statusFrom(sandbox.state),\n\t\tmetadata: {\n\t\t\ttarget: sandbox.target,\n\t\t},\n\t});\n\n\tconst wake = (sandbox: RemoteSandbox, operation: string) =>\n\t\tshouldWake(sandbox)\n\t\t\t? attempt(operation, () => sandbox.start()).pipe(Effect.map(() => sandbox))\n\t\t\t: Effect.succeed(sandbox);\n\n\tconst runtime = (\n\t\tdefaultCwd: string,\n\t\tinput: { readonly user?: string | undefined; readonly execTimeout?: number | undefined },\n\t) => ({\n\t\tdefaultCwd: SandboxDriver.AbsolutePath.make(defaultCwd),\n\t\t...(input.user === undefined ? {} : { user: input.user }),\n\t\t...(input.execTimeout === undefined ? {} : { execTimeout: input.execTimeout }),\n\t});\n\n\treturn SandboxDriver.driver({\n\t\tname,\n\t\tkind: \"remote\",\n\t\tcapabilities: {\n\t\t\tinspect: true,\n\t\t\treattach: true,\n\t\t\twake: true,\n\t\t\tstop: true,\n\t\t\tdestroy: true,\n\t\t\t// Installed SDK 0.187.0 has no cancellation signal on\n\t\t\t// executeCommand; session execution cannot carry cwd/env safely.\n\t\t\tcancels: false,\n\t\t},\n\t\tcreateConfigCodec: CreateConfig,\n\t\truntimeConfigCodec: RuntimeConfig,\n\t\tcreate: ({ instanceId, config }) =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst base = {\n\t\t\t\t\tlanguage: config.language ?? \"typescript\",\n\t\t\t\t\t...(config.envVars === undefined ? {} : { envVars: config.envVars }),\n\t\t\t\t\t...(config.user === undefined ? {} : { user: config.user }),\n\t\t\t\t\t...(config.autoStopInterval === undefined ? {} : { autoStopInterval: config.autoStopInterval }),\n\t\t\t\t\tautoDeleteInterval: -1,\n\t\t\t\t\tlabels: {\n\t\t\t\t\t\t\"codework-instance\": instanceId,\n\t\t\t\t\t\t\"codework-managed\": \"true\",\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\tconst sandbox = yield* attempt(\"create\", (loaded) => {\n\t\t\t\t\tconst sdk = daytona(loaded);\n\t\t\t\t\treturn config.image === undefined\n\t\t\t\t\t\t? sdk.create({ ...base, ...(config.snapshot === undefined ? {} : { snapshot: config.snapshot }) })\n\t\t\t\t\t\t: sdk.create({\n\t\t\t\t\t\t\t\t...base,\n\t\t\t\t\t\t\t\timage: config.image,\n\t\t\t\t\t\t\t\t...(config.resources === undefined ? {} : { resources: config.resources as Resources }),\n\t\t\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t\tconst defaultCwd = yield* attempt(\"create.cwd\", () =>\n\t\t\t\t\tEnvDaytona.mountCwd(config.cwd, () => sandbox.getWorkDir()),\n\t\t\t\t);\n\t\t\t\tconst state = statusFrom(sandbox.state);\n\t\t\t\treturn {\n\t\t\t\t\tproviderResourceId: sandbox.id,\n\t\t\t\t\tproviderStatus: state.providerStatus,\n\t\t\t\t\truntimeConfig: runtime(defaultCwd, config),\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\ttarget: sandbox.target,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}),\n\t\truntimeConfigFor: ({ providerResourceId, overrides }) =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst sandbox = yield* get(providerResourceId, \"runtimeConfigFor\");\n\t\t\t\tconst defaultCwd =\n\t\t\t\t\toverrides?.defaultCwd ??\n\t\t\t\t\tSandboxDriver.AbsolutePath.make(\n\t\t\t\t\t\tyield* attempt(\"runtimeConfigFor.cwd\", () =>\n\t\t\t\t\t\t\tEnvDaytona.mountCwd(undefined, () => sandbox.getWorkDir()),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\treturn {\n\t\t\t\t\tdefaultCwd,\n\t\t\t\t\t...(overrides?.user === undefined ? { user: sandbox.user } : { user: overrides.user }),\n\t\t\t\t\t...(overrides?.execTimeout === undefined ? {} : { execTimeout: overrides.execTimeout }),\n\t\t\t\t};\n\t\t\t}),\n\t\tattach: (input) =>\n\t\t\tLayer.unwrap(\n\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\tconst sandbox = yield* get(\n\t\t\t\t\t\tOption.getOrElse(input.providerResourceId, () => input.id),\n\t\t\t\t\t\t\"attach\",\n\t\t\t\t\t);\n\t\t\t\t\tyield* wake(sandbox, \"attach.wake\");\n\t\t\t\t\treturn EnvDaytona.transport(\n\t\t\t\t\t\tsandbox,\n\t\t\t\t\t\tinput.runtimeConfig.execTimeout === undefined\n\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t: { execTimeout: input.runtimeConfig.execTimeout },\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t\t),\n\t\tinspect: (input) =>\n\t\t\tEffect.flatMap(\n\t\t\t\tget(\n\t\t\t\t\tOption.getOrElse(input.providerResourceId, () => input.id),\n\t\t\t\t\t\"inspect\",\n\t\t\t\t),\n\t\t\t\t(sandbox) => Effect.map(refresh(sandbox, \"inspect.refresh\"), observed),\n\t\t\t),\n\t\twake: (input) =>\n\t\t\tEffect.flatMap(\n\t\t\t\tget(\n\t\t\t\t\tOption.getOrElse(input.providerResourceId, () => input.id),\n\t\t\t\t\t\"wake\",\n\t\t\t\t),\n\t\t\t\t(sandbox) => Effect.map(wake(sandbox, \"wake.start\"), observed),\n\t\t\t),\n\t\tstop: (input) =>\n\t\t\tEffect.flatMap(\n\t\t\t\tget(\n\t\t\t\t\tOption.getOrElse(input.providerResourceId, () => input.id),\n\t\t\t\t\t\"stop\",\n\t\t\t\t),\n\t\t\t\t(sandbox) => attempt(\"stop\", () => sandbox.stop()).pipe(Effect.map(() => observed(sandbox))),\n\t\t\t),\n\t\tdestroy: (input) =>\n\t\t\tEffect.flatMap(\n\t\t\t\tget(\n\t\t\t\t\tOption.getOrElse(input.providerResourceId, () => input.id),\n\t\t\t\t\t\"destroy\",\n\t\t\t\t),\n\t\t\t\t(sandbox) => attempt(\"destroy\", () => sandbox.delete()),\n\t\t\t),\n\t});\n};\n\nconst sandbox = SandboxDriver.module({\n\tapiVersion: SandboxDriver.apiVersion,\n\tname,\n\toptions: Options,\n\tmake,\n});\n\nexport const config = (value: CreateConfig) => ({ driver: \"daytona\" as const, config: value });\n\nexport default sandbox;\n"],"mappings":";;;;;AAaA,MAAM,eAAe,MAAc,YAAsB;CACxD,MAAM,aAAa,MA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