@codeworksh/harness 0.0.1-dev.20260824142157 → 0.0.1-dev.20260824173147

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
@@ -78,7 +78,7 @@ pnpm dlx @codeworksh/harness@dev \
78
78
 
79
79
  `modelgen [path]` uses Aikit's model generator and writes `./models.gen.json` by default. Set `CODEWORK_MODELS_FILE` or pass a path when you keep the catalog elsewhere.
80
80
 
81
- The CLI prints the session ID to stderr. Provider, model, and thinking settings are stored with a new session, so use the same home directory and session ID to continue it:
81
+ The CLI prints the session ID to stderr. Provider, model, and thinking settings are stored with the session, so use the same home directory and session ID to continue it:
82
82
 
83
83
  ```sh
84
84
  pnpm dlx @codeworksh/harness@dev \
@@ -87,6 +87,40 @@ pnpm dlx @codeworksh/harness@dev \
87
87
  "Continue with the implementation"
88
88
  ```
89
89
 
90
+ Persisted settings are the fallback. A new CLI process can explicitly re-bind or change them while attaching; supplied values are recorded as the session's latest configuration:
91
+
92
+ ```sh
93
+ pnpm dlx @codeworksh/harness@dev \
94
+ --home .codework-beta \
95
+ run --session <session-id> \
96
+ --provider openai --model gpt-5.6-luna --thinking high \
97
+ "Continue with this model"
98
+ ```
99
+
100
+ Local execution is the default. To create a session in a new Daytona sandbox, set `DAYTONA_API_KEY` and select the Daytona driver:
101
+
102
+ ```sh
103
+ export DAYTONA_API_KEY="..."
104
+
105
+ pnpm dlx @codeworksh/harness@dev \
106
+ --home .codework-beta \
107
+ run --sandbox daytona --provider openai --model gpt-5.5 \
108
+ "Inspect this repository"
109
+ ```
110
+
111
+ Pass the provider's sandbox ID to connect a new Harness session to an existing Daytona sandbox:
112
+
113
+ ```sh
114
+ pnpm dlx @codeworksh/harness@dev \
115
+ --home .codework-beta \
116
+ run --sandbox daytona --sandbox-provider-id <daytona-sandbox-id> \
117
+ "Continue work in this sandbox"
118
+ ```
119
+
120
+ `--cwd` overrides the selected sandbox's default working directory. When continuing with `--session`, omit the sandbox flags: the durable session already references its sandbox.
121
+
122
+ The same flags work with Vercel Sandbox by using `--sandbox vercel`; `--sandbox-provider-id` then accepts the existing Vercel sandbox name.
123
+
90
124
  Use `codework --help` or `pnpm dlx @codeworksh/harness@dev --help` for all options.
91
125
 
92
126
  ## Effect SDK
package/cli/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { _ as ID, a as layer, g as posix, n as create, t as attach } from "../session-jgwp2MT6.mjs";
2
+ import { a as create, d as ID, i as Drivers, l as layer, n as create$1, o as register, t as attach } from "../session-CF1B0VEr.mjs";
3
3
  import { Effect, Fiber, Option, Queue, Schema, Stream } from "effect";
4
4
  import { generateModels } from "@codeworksh/aikit/modelgen";
5
5
  import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
@@ -15,6 +15,11 @@ const thinkingLevels = [
15
15
  "xhigh",
16
16
  "max"
17
17
  ];
18
+ const sandboxDrivers = [
19
+ "local",
20
+ "daytona",
21
+ "vercel"
22
+ ];
18
23
  const writeOut = (value) => Effect.sync(() => void process.stdout.write(value));
19
24
  const writeError = (value) => Effect.sync(() => void process.stderr.write(value));
20
25
  var InvalidInputError = class extends Schema.TaggedError()("CLI.InvalidInputError", { message: Schema.String }) {};
@@ -29,6 +34,17 @@ const render = (ended) => Effect.fn("CLI.render")(function* (event) {
29
34
  const awaitMessage = Effect.fn("CLI.awaitMessage")(function* (ended, messageId) {
30
35
  while ((yield* Queue.take(ended)) !== messageId);
31
36
  });
37
+ const selectSandbox = Effect.fn("CLI.selectSandbox")(function* (driver, providerResourceId) {
38
+ if (driver === "local") return void 0;
39
+ if (driver === "daytona") return providerResourceId === void 0 ? yield* create({ driver }) : yield* register({
40
+ driver,
41
+ providerResourceId
42
+ });
43
+ return providerResourceId === void 0 ? yield* create({ driver }) : yield* register({
44
+ driver,
45
+ providerResourceId
46
+ });
47
+ });
32
48
  const root = Command.make("codework").pipe(Command.withSharedFlags({
33
49
  home: Flag.string("home").pipe(Flag.withDescription("Harness data directory"), Flag.optional),
34
50
  database: Flag.string("database").pipe(Flag.withDescription("SQLite path or :memory:"), Flag.optional)
@@ -36,25 +52,40 @@ const root = Command.make("codework").pipe(Command.withSharedFlags({
36
52
  const run = Command.make("run", {
37
53
  prompt: Argument.string("prompt").pipe(Argument.withDescription("Prompt for the agent")),
38
54
  session: Flag.string("session").pipe(Flag.withAlias("s"), Flag.withDescription("Continue an existing session ID"), Flag.optional),
39
- cwd: Flag.string("cwd").pipe(Flag.withAlias("C"), Flag.withDescription("Working directory for a new local session"), Flag.optional),
40
- provider: Flag.string("provider").pipe(Flag.withDescription("Model catalog provider ID for a new session"), Flag.optional),
41
- model: Flag.string("model").pipe(Flag.withDescription("Model ID for a new session"), Flag.optional),
42
- thinking: Flag.choice("thinking", thinkingLevels).pipe(Flag.withDescription("Thinking level for a new session"), Flag.optional)
43
- }, Effect.fn("CLI.run")(function* ({ prompt, session, cwd, provider, model, thinking }) {
55
+ cwd: Flag.string("cwd").pipe(Flag.withAlias("C"), Flag.withDescription("Working directory for a new session"), Flag.optional),
56
+ sandbox: Flag.choice("sandbox", sandboxDrivers).pipe(Flag.withDescription("Sandbox for a new session (default: local)"), Flag.optional),
57
+ sandboxProviderId: Flag.string("sandbox-provider-id").pipe(Flag.withDescription("Provider ID of an existing sandbox"), Flag.optional),
58
+ provider: Flag.string("provider").pipe(Flag.withDescription("Model catalog provider ID"), Flag.optional),
59
+ model: Flag.string("model").pipe(Flag.withDescription("Model ID"), Flag.optional),
60
+ thinking: Flag.choice("thinking", thinkingLevels).pipe(Flag.withDescription("Thinking level"), Flag.optional)
61
+ }, Effect.fn("CLI.run")(function* ({ prompt, session, cwd, sandbox, sandboxProviderId, provider, model, thinking }) {
44
62
  const shared = yield* root;
45
- if (Option.isSome(session) && Option.isSome(cwd)) return yield* new InvalidInputError({ message: "--cwd can only be used when creating a new session" });
63
+ if (Option.isSome(session) && (Option.isSome(cwd) || Option.isSome(sandbox) || Option.isSome(sandboxProviderId))) return yield* new InvalidInputError({ message: "--cwd, --sandbox, and --sandbox-provider-id can only be used when creating a new session" });
46
64
  if (Option.isSome(provider) !== Option.isSome(model)) return yield* new InvalidInputError({ message: "--provider and --model must be provided together" });
47
- if (Option.isSome(session) && (Option.isSome(provider) || Option.isSome(thinking))) return yield* new InvalidInputError({ message: "--provider, --model, and --thinking can only be used when creating a new session" });
65
+ if (Option.isSome(sandboxProviderId) && (Option.isNone(sandbox) || sandbox.value === "local")) return yield* new InvalidInputError({ message: "--sandbox-provider-id requires a remote --sandbox" });
48
66
  return yield* Effect.gen(function* () {
49
- const handle = Option.isSome(session) ? yield* attach({ sessionId: ID.make(session.value) }) : yield* create({
50
- title: "CLI",
51
- ...Option.isNone(cwd) ? {} : { directory: posix.resolve(cwd.value) },
67
+ const runtime = {
52
68
  ...Option.isNone(provider) || Option.isNone(model) ? {} : { model: {
53
69
  provider: provider.value,
54
70
  id: model.value
55
71
  } },
56
72
  ...Option.isNone(thinking) ? {} : { thinkingLevel: thinking.value }
73
+ };
74
+ let handle;
75
+ if (Option.isSome(session)) handle = yield* attach({
76
+ sessionId: ID.make(session.value),
77
+ ...runtime
57
78
  });
79
+ else {
80
+ const selectedSandbox = Option.getOrElse(sandbox, () => "local");
81
+ const selected = yield* selectSandbox(selectedSandbox, Option.getOrUndefined(sandboxProviderId));
82
+ handle = yield* create$1({
83
+ title: "CLI",
84
+ ...runtime,
85
+ ...selected === void 0 ? {} : { sandbox: selected },
86
+ ...Option.isNone(cwd) ? {} : { directory: cwd.value }
87
+ });
88
+ }
58
89
  const ended = yield* Queue.unbounded();
59
90
  const printer = yield* handle.events().pipe(Stream.runForEach(render(ended)), Effect.forkScoped({ startImmediately: true }));
60
91
  yield* writeError(`session ${handle.id}\n`);
@@ -65,9 +96,10 @@ const run = Command.make("run", {
65
96
  yield* writeOut("\n");
66
97
  }).pipe(Effect.provide(layer({
67
98
  ...Option.isNone(shared.home) ? {} : { home: shared.home.value },
68
- ...Option.isNone(shared.database) ? {} : { database: shared.database.value }
99
+ ...Option.isNone(shared.database) ? {} : { database: shared.database.value },
100
+ sandboxes: [Drivers.daytona(), Drivers.vercel()]
69
101
  })), Effect.scoped);
70
- })).pipe(Command.withDescription("Start or continue a local agent session"), Command.withExamples([
102
+ })).pipe(Command.withDescription("Start or continue an agent session"), Command.withExamples([
71
103
  {
72
104
  command: "codework run \"Inspect the failing tests\"",
73
105
  description: "Create a session"
@@ -77,8 +109,16 @@ const run = Command.make("run", {
77
109
  description: "Create a session with an explicit model"
78
110
  },
79
111
  {
80
- command: "codework run --session <id> \"Now fix them\"",
81
- description: "Continue a session"
112
+ command: "codework run --sandbox daytona \"Inspect the repository\"",
113
+ description: "Create a Daytona sandbox and session"
114
+ },
115
+ {
116
+ command: "codework run --sandbox daytona --sandbox-provider-id <id> \"Inspect the repository\"",
117
+ description: "Use an existing remote sandbox"
118
+ },
119
+ {
120
+ command: "codework run --session <id> --provider openai --model gpt-5.6-luna \"Now fix them\"",
121
+ description: "Continue a session with explicit model bindings"
82
122
  }
83
123
  ]));
84
124
  const modelgen = Command.make("modelgen", { path: Argument.string("path").pipe(Argument.withDescription("Output path; defaults to CODEWORK_MODELS_FILE or ./models.gen.json"), Argument.optional) }, Effect.fn("CLI.modelgen")(function* ({ path }) {
package/cli/index.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["Session.attach","Session.create","Harness.layer"],"sources":["../../../src/cli/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { generateModels } from \"@codeworksh/aikit/modelgen\";\nimport * as NodeRuntime from \"@effect/platform-node/NodeRuntime\";\nimport * as NodeServices from \"@effect/platform-node/NodeServices\";\nimport { Effect, Fiber, Option, Queue, Schema, Stream } from \"effect\";\nimport { Argument, CliError, Command, Flag } from \"effect/unstable/cli\";\nimport { Harness } from \"../effect/harness.ts\";\nimport { Session } from \"../effect/session.ts\";\nimport type { EventSchema } from \"../event/schema.ts\";\nimport { posix } from \"../posix.ts\";\n\nconst thinkingLevels = [\"off\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\", \"max\"] as const;\n\nconst writeOut = (value: string) => Effect.sync(() => void process.stdout.write(value));\nconst writeError = (value: string) => Effect.sync(() => void process.stderr.write(value));\n\nclass InvalidInputError extends Schema.TaggedError<InvalidInputError>()(\"CLI.InvalidInputError\", {\n\tmessage: Schema.String,\n}) {}\n\nclass ModelgenError extends Schema.TaggedError<ModelgenError>()(\"CLI.ModelgenError\", {\n\tcause: Schema.Defect(),\n}) {}\n\nconst render = (ended: Queue.Queue<string>) =>\n\tEffect.fn(\"CLI.render\")(function* (event: EventSchema.Payload) {\n\t\tif (event.type === \"session.llm.text.delta\") {\n\t\t\tyield* writeOut((event.data as { readonly delta: string }).delta);\n\t\t\treturn;\n\t\t}\n\t\tif (event.type === \"session.turn.ended\") {\n\t\t\tyield* Queue.offer(ended, (event.data as { readonly messageId: string }).messageId);\n\t\t}\n\t});\n\nconst awaitMessage = Effect.fn(\"CLI.awaitMessage\")(function* (ended: Queue.Queue<string>, messageId: string) {\n\twhile ((yield* Queue.take(ended)) !== messageId) {\n\t\t// Earlier turns in the same drain are expected when a tool call continues.\n\t}\n});\n\nconst root = Command.make(\"codework\").pipe(\n\tCommand.withSharedFlags({\n\t\thome: Flag.string(\"home\").pipe(Flag.withDescription(\"Harness data directory\"), Flag.optional),\n\t\tdatabase: Flag.string(\"database\").pipe(Flag.withDescription(\"SQLite path or :memory:\"), Flag.optional),\n\t}),\n\tCommand.withDescription(\"Run Codework agent sessions\"),\n);\n\nconst run = Command.make(\n\t\"run\",\n\t{\n\t\tprompt: Argument.string(\"prompt\").pipe(Argument.withDescription(\"Prompt for the agent\")),\n\t\tsession: Flag.string(\"session\").pipe(\n\t\t\tFlag.withAlias(\"s\"),\n\t\t\tFlag.withDescription(\"Continue an existing session ID\"),\n\t\t\tFlag.optional,\n\t\t),\n\t\tcwd: Flag.string(\"cwd\").pipe(\n\t\t\tFlag.withAlias(\"C\"),\n\t\t\tFlag.withDescription(\"Working directory for a new local session\"),\n\t\t\tFlag.optional,\n\t\t),\n\t\tprovider: Flag.string(\"provider\").pipe(\n\t\t\tFlag.withDescription(\"Model catalog provider ID for a new session\"),\n\t\t\tFlag.optional,\n\t\t),\n\t\tmodel: Flag.string(\"model\").pipe(Flag.withDescription(\"Model ID for a new session\"), Flag.optional),\n\t\tthinking: Flag.choice(\"thinking\", thinkingLevels).pipe(\n\t\t\tFlag.withDescription(\"Thinking level for a new session\"),\n\t\t\tFlag.optional,\n\t\t),\n\t},\n\tEffect.fn(\"CLI.run\")(function* ({ prompt, session, cwd, provider, model, thinking }) {\n\t\tconst shared = yield* root;\n\t\tif (Option.isSome(session) && Option.isSome(cwd)) {\n\t\t\treturn yield* new InvalidInputError({ message: \"--cwd can only be used when creating a new session\" });\n\t\t}\n\t\tif (Option.isSome(provider) !== Option.isSome(model)) {\n\t\t\treturn yield* new InvalidInputError({ message: \"--provider and --model must be provided together\" });\n\t\t}\n\t\tif (Option.isSome(session) && (Option.isSome(provider) || Option.isSome(thinking))) {\n\t\t\treturn yield* new InvalidInputError({\n\t\t\t\tmessage: \"--provider, --model, and --thinking can only be used when creating a new session\",\n\t\t\t});\n\t\t}\n\t\tconst program = Effect.gen(function* () {\n\t\t\tconst handle = Option.isSome(session)\n\t\t\t\t? yield* Session.attach({ sessionId: Session.SessionSchema.ID.make(session.value) })\n\t\t\t\t: yield* Session.create({\n\t\t\t\t\t\ttitle: \"CLI\",\n\t\t\t\t\t\t...(Option.isNone(cwd) ? {} : { directory: posix.resolve(cwd.value) }),\n\t\t\t\t\t\t...(Option.isNone(provider) || Option.isNone(model)\n\t\t\t\t\t\t\t? {}\n\t\t\t\t\t\t\t: { model: { provider: provider.value, id: model.value } }),\n\t\t\t\t\t\t...(Option.isNone(thinking) ? {} : { thinkingLevel: thinking.value }),\n\t\t\t\t\t});\n\t\t\tconst ended = yield* Queue.unbounded<string>();\n\t\t\tconst printer = yield* handle\n\t\t\t\t.events()\n\t\t\t\t.pipe(Stream.runForEach(render(ended)), Effect.forkScoped({ startImmediately: true }));\n\n\t\t\tyield* writeError(`session ${handle.id}\\n`);\n\t\t\tyield* handle.run(prompt);\n\t\t\tconst path = yield* handle.path();\n\t\t\tconst leaf = path.at(-1);\n\t\t\tif (leaf !== undefined) yield* awaitMessage(ended, leaf.entry.id);\n\t\t\tyield* Fiber.interrupt(printer);\n\t\t\tyield* writeOut(\"\\n\");\n\t\t});\n\n\t\treturn yield* program.pipe(\n\t\t\tEffect.provide(\n\t\t\t\tHarness.layer({\n\t\t\t\t\t...(Option.isNone(shared.home) ? {} : { home: shared.home.value }),\n\t\t\t\t\t...(Option.isNone(shared.database) ? {} : { database: shared.database.value }),\n\t\t\t\t}),\n\t\t\t),\n\t\t\tEffect.scoped,\n\t\t);\n\t}),\n).pipe(\n\tCommand.withDescription(\"Start or continue a local agent session\"),\n\tCommand.withExamples([\n\t\t{ command: 'codework run \"Inspect the failing tests\"', description: \"Create a session\" },\n\t\t{\n\t\t\tcommand: 'codework run --provider openai --model gpt-5.5 --thinking high \"Inspect the failing tests\"',\n\t\t\tdescription: \"Create a session with an explicit model\",\n\t\t},\n\t\t{ command: 'codework run --session <id> \"Now fix them\"', description: \"Continue a session\" },\n\t]),\n);\n\nconst modelgen = Command.make(\n\t\"modelgen\",\n\t{\n\t\tpath: Argument.string(\"path\").pipe(\n\t\t\tArgument.withDescription(\"Output path; defaults to CODEWORK_MODELS_FILE or ./models.gen.json\"),\n\t\t\tArgument.optional,\n\t\t),\n\t},\n\tEffect.fn(\"CLI.modelgen\")(function* ({ path }) {\n\t\tconst generated = yield* Effect.tryPromise({\n\t\t\ttry: () => generateModels(Option.isNone(path) ? {} : { path: path.value }),\n\t\t\tcatch: (cause) => new ModelgenError({ cause }),\n\t\t});\n\t\tyield* writeOut(`Generated model catalog at ${generated}\\n`);\n\t}),\n).pipe(\n\tCommand.withDescription(\"Generate the Aikit model catalog\"),\n\tCommand.withExamples([{ command: \"codework modelgen\", description: \"Generate models.gen.json\" }]),\n);\n\nexport const command = root.pipe(Command.withSubcommands([run, modelgen]));\n\nexport const main: Effect.Effect<void, Command.Error<typeof command> | CliError.CliError> = Command.run(command, {\n\tversion: \"0.0.1\",\n}).pipe(Effect.provide(NodeServices.layer));\n\nNodeRuntime.runMain(main);\n"],"mappings":";;;;;;;;AAYA,MAAM,iBAAiB;CAAC;CAAO;CAAW;CAAO;CAAU;CAAQ;CAAS;AAAK;AAEjF,MAAM,YAAY,UAAkB,OAAO,WAAW,KAAK,QAAQ,OAAO,MAAM,KAAK,CAAC;AACtF,MAAM,cAAc,UAAkB,OAAO,WAAW,KAAK,QAAQ,OAAO,MAAM,KAAK,CAAC;AAExF,IAAM,oBAAN,cAAgC,OAAO,YAA+B,CAAC,CAAC,yBAAyB,EAChG,SAAS,OAAO,OACjB,CAAC,CAAC,CAAC,CAAC;AAEJ,IAAM,gBAAN,cAA4B,OAAO,YAA2B,CAAC,CAAC,qBAAqB,EACpF,OAAO,OAAO,OAAO,EACtB,CAAC,CAAC,CAAC,CAAC;AAEJ,MAAM,UAAU,UACf,OAAO,GAAG,YAAY,CAAC,CAAC,WAAW,OAA4B;CAC9D,IAAI,MAAM,SAAS,0BAA0B;EAC5C,OAAO,SAAU,MAAM,KAAoC,KAAK;EAChE;CACD;CACA,IAAI,MAAM,SAAS,sBAClB,OAAO,MAAM,MAAM,OAAQ,MAAM,KAAwC,SAAS;AAEpF,CAAC;AAEF,MAAM,eAAe,OAAO,GAAG,kBAAkB,CAAC,CAAC,WAAW,OAA4B,WAAmB;CAC5G,QAAQ,OAAO,MAAM,KAAK,KAAK,OAAO;AAGvC,CAAC;AAED,MAAM,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,KACrC,QAAQ,gBAAgB;CACvB,MAAM,KAAK,OAAO,MAAM,CAAC,CAAC,KAAK,KAAK,gBAAgB,wBAAwB,GAAG,KAAK,QAAQ;CAC5F,UAAU,KAAK,OAAO,UAAU,CAAC,CAAC,KAAK,KA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,SAAS;EACT,aAAa;CACd;CACA;EAAE,SAAS;EAA8C,aAAa;CAAqB;AAC5F,CAAC,CACF;AAEA,MAAM,WAAW,QAAQ,KACxB,YACA,EACC,MAAM,SAAS,OAAO,MAAM,CAAC,CAAC,KAC7B,SAAS,gBAAgB,oEAAoE,GAC7F,SAAS,QACV,EACD,GACA,OAAO,GAAG,cAAc,CAAC,CAAC,WAAW,EAAE,QAAQ;CAC9C,MAAM,YAAY,OAAO,OAAO,WAAW;EAC1C,WAAW,eAAe,OAAO,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;EACzE,QAAQ,UAAU,IAAI,cAAc,EAAE,MAAM,CAAC;CAC9C,CAAC;CACD,OAAO,SAAS,8BAA8B,UAAU,GAAG;AAC5D,CAAC,CACF,CAAC,CAAC,KACD,QAAQ,gBAAgB,kCAAkC,GAC1D,QAAQ,aAAa,CAAC;CAAE,SAAS;CAAqB,aAAa;AAA2B,CAAC,CAAC,CACjG;AAEA,MAAa,UAAU,KAAK,KAAK,QAAQ,gBAAgB,CAAC,KAAK,QAAQ,CAAC,CAAC;AAEzE,MAAa,OAA+E,QAAQ,IAAI,SAAS,EAChH,SAAS,QACV,CAAC,CAAC,CAAC,KAAK,OAAO,QAAQ,aAAa,KAAK,CAAC;AAE1C,YAAY,QAAQ,IAAI"}
1
+ {"version":3,"file":"index.mjs","names":["Sandbox.create","Sandbox.register","Session.attach","Session.create","Harness.layer"],"sources":["../../../src/cli/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { generateModels } from \"@codeworksh/aikit/modelgen\";\nimport * as NodeRuntime from \"@effect/platform-node/NodeRuntime\";\nimport * as NodeServices from \"@effect/platform-node/NodeServices\";\nimport { Effect, Fiber, Option, Queue, Schema, Stream } from \"effect\";\nimport { Argument, CliError, Command, Flag } from \"effect/unstable/cli\";\nimport { Harness } from \"../effect/harness.ts\";\nimport { Sandbox } from \"../effect/sandbox.ts\";\nimport { Session } from \"../effect/session.ts\";\nimport type { EventSchema } from \"../event/schema.ts\";\n\nconst thinkingLevels = [\"off\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\", \"max\"] as const;\nconst sandboxDrivers = [\"local\", \"daytona\", \"vercel\"] as const;\n\nconst writeOut = (value: string) => Effect.sync(() => void process.stdout.write(value));\nconst writeError = (value: string) => Effect.sync(() => void process.stderr.write(value));\n\nclass InvalidInputError extends Schema.TaggedError<InvalidInputError>()(\"CLI.InvalidInputError\", {\n\tmessage: Schema.String,\n}) {}\n\nclass ModelgenError extends Schema.TaggedError<ModelgenError>()(\"CLI.ModelgenError\", {\n\tcause: Schema.Defect(),\n}) {}\n\nconst render = (ended: Queue.Queue<string>) =>\n\tEffect.fn(\"CLI.render\")(function* (event: EventSchema.Payload) {\n\t\tif (event.type === \"session.llm.text.delta\") {\n\t\t\tyield* writeOut((event.data as { readonly delta: string }).delta);\n\t\t\treturn;\n\t\t}\n\t\tif (event.type === \"session.turn.ended\") {\n\t\t\tyield* Queue.offer(ended, (event.data as { readonly messageId: string }).messageId);\n\t\t}\n\t});\n\nconst awaitMessage = Effect.fn(\"CLI.awaitMessage\")(function* (ended: Queue.Queue<string>, messageId: string) {\n\twhile ((yield* Queue.take(ended)) !== messageId) {\n\t\t// Earlier turns in the same drain are expected when a tool call continues.\n\t}\n});\n\nconst selectSandbox = Effect.fn(\"CLI.selectSandbox\")(function* (\n\tdriver: (typeof sandboxDrivers)[number],\n\tproviderResourceId?: string,\n) {\n\tif (driver === \"local\") return undefined;\n\tif (driver === \"daytona\") {\n\t\treturn providerResourceId === undefined\n\t\t\t? yield* Sandbox.create({ driver })\n\t\t\t: yield* Sandbox.register({ driver, providerResourceId });\n\t}\n\treturn providerResourceId === undefined\n\t\t? yield* Sandbox.create({ driver })\n\t\t: yield* Sandbox.register({ driver, providerResourceId });\n});\n\nconst root = Command.make(\"codework\").pipe(\n\tCommand.withSharedFlags({\n\t\thome: Flag.string(\"home\").pipe(Flag.withDescription(\"Harness data directory\"), Flag.optional),\n\t\tdatabase: Flag.string(\"database\").pipe(Flag.withDescription(\"SQLite path or :memory:\"), Flag.optional),\n\t}),\n\tCommand.withDescription(\"Run Codework agent sessions\"),\n);\n\nconst run = Command.make(\n\t\"run\",\n\t{\n\t\tprompt: Argument.string(\"prompt\").pipe(Argument.withDescription(\"Prompt for the agent\")),\n\t\tsession: Flag.string(\"session\").pipe(\n\t\t\tFlag.withAlias(\"s\"),\n\t\t\tFlag.withDescription(\"Continue an existing session ID\"),\n\t\t\tFlag.optional,\n\t\t),\n\t\tcwd: Flag.string(\"cwd\").pipe(\n\t\t\tFlag.withAlias(\"C\"),\n\t\t\tFlag.withDescription(\"Working directory for a new session\"),\n\t\t\tFlag.optional,\n\t\t),\n\t\tsandbox: Flag.choice(\"sandbox\", sandboxDrivers).pipe(\n\t\t\tFlag.withDescription(\"Sandbox for a new session (default: local)\"),\n\t\t\tFlag.optional,\n\t\t),\n\t\tsandboxProviderId: Flag.string(\"sandbox-provider-id\").pipe(\n\t\t\tFlag.withDescription(\"Provider ID of an existing sandbox\"),\n\t\t\tFlag.optional,\n\t\t),\n\t\tprovider: Flag.string(\"provider\").pipe(Flag.withDescription(\"Model catalog provider ID\"), Flag.optional),\n\t\tmodel: Flag.string(\"model\").pipe(Flag.withDescription(\"Model ID\"), Flag.optional),\n\t\tthinking: Flag.choice(\"thinking\", thinkingLevels).pipe(Flag.withDescription(\"Thinking level\"), Flag.optional),\n\t},\n\tEffect.fn(\"CLI.run\")(function* ({ prompt, session, cwd, sandbox, sandboxProviderId, provider, model, thinking }) {\n\t\tconst shared = yield* root;\n\t\tif (\n\t\t\tOption.isSome(session) &&\n\t\t\t(Option.isSome(cwd) || Option.isSome(sandbox) || Option.isSome(sandboxProviderId))\n\t\t) {\n\t\t\treturn yield* new InvalidInputError({\n\t\t\t\tmessage: \"--cwd, --sandbox, and --sandbox-provider-id can only be used when creating a new session\",\n\t\t\t});\n\t\t}\n\t\tif (Option.isSome(provider) !== Option.isSome(model)) {\n\t\t\treturn yield* new InvalidInputError({ message: \"--provider and --model must be provided together\" });\n\t\t}\n\t\tif (Option.isSome(sandboxProviderId) && (Option.isNone(sandbox) || sandbox.value === \"local\")) {\n\t\t\treturn yield* new InvalidInputError({ message: \"--sandbox-provider-id requires a remote --sandbox\" });\n\t\t}\n\t\tconst program = Effect.gen(function* () {\n\t\t\tconst runtime = {\n\t\t\t\t...(Option.isNone(provider) || Option.isNone(model)\n\t\t\t\t\t? {}\n\t\t\t\t\t: { model: { provider: provider.value, id: model.value } }),\n\t\t\t\t...(Option.isNone(thinking) ? {} : { thinkingLevel: thinking.value }),\n\t\t\t};\n\t\t\tlet handle: Session.Handle;\n\t\t\tif (Option.isSome(session)) {\n\t\t\t\thandle = yield* Session.attach({ sessionId: Session.SessionSchema.ID.make(session.value), ...runtime });\n\t\t\t} else {\n\t\t\t\tconst selectedSandbox = Option.getOrElse(sandbox, () => \"local\" as const);\n\t\t\t\tconst selected = yield* selectSandbox(selectedSandbox, Option.getOrUndefined(sandboxProviderId));\n\t\t\t\thandle = yield* Session.create({\n\t\t\t\t\ttitle: \"CLI\",\n\t\t\t\t\t...runtime,\n\t\t\t\t\t...(selected === undefined ? {} : { sandbox: selected }),\n\t\t\t\t\t...(Option.isNone(cwd) ? {} : { directory: cwd.value }),\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst ended = yield* Queue.unbounded<string>();\n\t\t\tconst printer = yield* handle\n\t\t\t\t.events()\n\t\t\t\t.pipe(Stream.runForEach(render(ended)), Effect.forkScoped({ startImmediately: true }));\n\n\t\t\tyield* writeError(`session ${handle.id}\\n`);\n\t\t\tyield* handle.run(prompt);\n\t\t\tconst path = yield* handle.path();\n\t\t\tconst leaf = path.at(-1);\n\t\t\tif (leaf !== undefined) yield* awaitMessage(ended, leaf.entry.id);\n\t\t\tyield* Fiber.interrupt(printer);\n\t\t\tyield* writeOut(\"\\n\");\n\t\t});\n\n\t\treturn yield* program.pipe(\n\t\t\tEffect.provide(\n\t\t\t\tHarness.layer({\n\t\t\t\t\t...(Option.isNone(shared.home) ? {} : { home: shared.home.value }),\n\t\t\t\t\t...(Option.isNone(shared.database) ? {} : { database: shared.database.value }),\n\t\t\t\t\tsandboxes: [Sandbox.Drivers.daytona(), Sandbox.Drivers.vercel()],\n\t\t\t\t}),\n\t\t\t),\n\t\t\tEffect.scoped,\n\t\t);\n\t}),\n).pipe(\n\tCommand.withDescription(\"Start or continue an agent session\"),\n\tCommand.withExamples([\n\t\t{ command: 'codework run \"Inspect the failing tests\"', description: \"Create a session\" },\n\t\t{\n\t\t\tcommand: 'codework run --provider openai --model gpt-5.5 --thinking high \"Inspect the failing tests\"',\n\t\t\tdescription: \"Create a session with an explicit model\",\n\t\t},\n\t\t{\n\t\t\tcommand: 'codework run --sandbox daytona \"Inspect the repository\"',\n\t\t\tdescription: \"Create a Daytona sandbox and session\",\n\t\t},\n\t\t{\n\t\t\tcommand: 'codework run --sandbox daytona --sandbox-provider-id <id> \"Inspect the repository\"',\n\t\t\tdescription: \"Use an existing remote sandbox\",\n\t\t},\n\t\t{\n\t\t\tcommand: 'codework run --session <id> --provider openai --model gpt-5.6-luna \"Now fix them\"',\n\t\t\tdescription: \"Continue a session with explicit model bindings\",\n\t\t},\n\t]),\n);\n\nconst modelgen = Command.make(\n\t\"modelgen\",\n\t{\n\t\tpath: Argument.string(\"path\").pipe(\n\t\t\tArgument.withDescription(\"Output path; defaults to CODEWORK_MODELS_FILE or ./models.gen.json\"),\n\t\t\tArgument.optional,\n\t\t),\n\t},\n\tEffect.fn(\"CLI.modelgen\")(function* ({ path }) {\n\t\tconst generated = yield* Effect.tryPromise({\n\t\t\ttry: () => generateModels(Option.isNone(path) ? {} : { path: path.value }),\n\t\t\tcatch: (cause) => new ModelgenError({ cause }),\n\t\t});\n\t\tyield* writeOut(`Generated model catalog at ${generated}\\n`);\n\t}),\n).pipe(\n\tCommand.withDescription(\"Generate the Aikit model catalog\"),\n\tCommand.withExamples([{ command: \"codework modelgen\", description: \"Generate models.gen.json\" }]),\n);\n\nexport const command = root.pipe(Command.withSubcommands([run, modelgen]));\n\nexport const main: Effect.Effect<void, Command.Error<typeof command> | CliError.CliError> = Command.run(command, {\n\tversion: \"0.0.1\",\n}).pipe(Effect.provide(NodeServices.layer));\n\nNodeRuntime.runMain(main);\n"],"mappings":";;;;;;;;AAYA,MAAM,iBAAiB;CAAC;CAAO;CAAW;CAAO;CAAU;CAAQ;CAAS;AAAK;AACjF,MAAM,iBAAiB;CAAC;CAAS;CAAW;AAAQ;AAEpD,MAAM,YAAY,UAAkB,OAAO,WAAW,KAAK,QAAQ,OAAO,MAAM,KAAK,CAAC;AACtF,MAAM,cAAc,UAAkB,OAAO,WAAW,KAAK,QAAQ,OAAO,MAAM,KAAK,CAAC;AAExF,IAAM,oBAAN,cAAgC,OAAO,YAA+B,CAAC,CAAC,yBAAyB,EAChG,SAAS,OAAO,OACjB,CAAC,CAAC,CAAC,CAAC;AAEJ,IAAM,gBAAN,cAA4B,OAAO,YAA2B,CAAC,CAAC,qBAAqB,EACpF,OAAO,OAAO,OAAO,EACtB,CAAC,CAAC,CAAC,CAAC;AAEJ,MAAM,UAAU,UACf,OAAO,GAAG,YAAY,CAAC,CAAC,WAAW,OAA4B;CAC9D,IAAI,MAAM,SAAS,0BAA0B;EAC5C,OAAO,SAAU,MAAM,KAAoC,KAAK;EAChE;CACD;CACA,IAAI,MAAM,SAAS,sBAClB,OAAO,MAAM,MAAM,OAAQ,MAAM,KAAwC,SAAS;AAEpF,CAAC;AAEF,MAAM,eAAe,OAAO,GAAG,kBAAkB,CAAC,CAAC,WAAW,OAA4B,WAAmB;CAC5G,QAAQ,OAAO,MAAM,KAAK,KAAK,OAAO;AAGvC,CAAC;AAED,MAAM,gBAAgB,OAAO,GAAG,mBAAmB,CAAC,CAAC,WACpD,QACA,oBACC;CACD,IAAI,WAAW,SAAS,OAAO,KAAA;CAC/B,IAAI,WAAW,WACd,OAAO,uBAAuB,KAAA,IAC3B,OAAOA,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AAC,CAAC,WAAW,EAAE,QAAQ;CAC9C,MAAM,YAAY,OAAO,OAAO,WAAW;EAC1C,WAAW,eAAe,OAAO,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;EACzE,QAAQ,UAAU,IAAI,cAAc,EAAE,MAAM,CAAC;CAC9C,CAAC;CACD,OAAO,SAAS,8BAA8B,UAAU,GAAG;AAC5D,CAAC,CACF,CAAC,CAAC,KACD,QAAQ,gBAAgB,kCAAkC,GAC1D,QAAQ,aAAa,CAAC;CAAE,SAAS;CAAqB,aAAa;AAA2B,CAAC,CAAC,CACjG;AAEA,MAAa,UAAU,KAAK,KAAK,QAAQ,gBAAgB,CAAC,KAAK,QAAQ,CAAC,CAAC;AAEzE,MAAa,OAA+E,QAAQ,IAAI,SAAS,EAChH,SAAS,QACV,CAAC,CAAC,CAAC,KAAK,OAAO,QAAQ,aAAa,KAAK,CAAC;AAE1C,YAAY,QAAQ,IAAI"}
package/effect.d.mts CHANGED
@@ -105,7 +105,7 @@ interface CreateInput extends RuntimeInput {
105
105
  readonly sandbox?: Info$1;
106
106
  readonly directory?: string;
107
107
  }
108
- interface AttachInput extends Pick<RuntimeInput, "tools" | "systemPrompt"> {
108
+ interface AttachInput extends RuntimeInput {
109
109
  readonly sessionId: ID;
110
110
  }
111
111
  type PromptInput = string | {
package/effect.mjs CHANGED
@@ -1,93 +1,5 @@
1
- import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
- import { c as make$3, d as Controller, f as AbsolutePath, h as instance_exports, i as harness_exports, l as make$1, m as Registry, o as tool_exports, p as Name, r as session_exports, s as make$2, u as make } from "./session-jgwp2MT6.mjs";
3
- import { Effect } from "effect";
4
- //#region src/effect/sandbox.ts
5
- var sandbox_exports = /* @__PURE__ */ __exportAll({
6
- Drivers: () => Drivers,
7
- Sandbox: () => sandbox_exports,
8
- SandboxInstance: () => instance_exports,
9
- create: () => create,
10
- destroy: () => destroy,
11
- get: () => get,
12
- list: () => list,
13
- refresh: () => refresh,
14
- register: () => register,
15
- stop: () => stop,
16
- wake: () => wake
17
- });
18
- const registered = Effect.fn("Sandbox.registered")(function* (name) {
19
- return yield* (yield* Registry).get(Name.make(name));
20
- });
21
- const create = Effect.fn("Sandbox.create")(function* (input) {
22
- const controller = yield* Controller;
23
- const driver = yield* registered(input.driver);
24
- if (input.driver === "memory") {
25
- const cwd = AbsolutePath.make(input.cwd ?? "/");
26
- return yield* controller.create({
27
- driver,
28
- config: {
29
- defaultCwd: cwd,
30
- initializeCwd: cwd
31
- }
32
- });
33
- }
34
- if (input.driver === "sqldb") {
35
- const cwd = AbsolutePath.make(input.cwd ?? "/");
36
- return yield* controller.create({
37
- driver,
38
- config: {
39
- defaultCwd: cwd,
40
- initializeCwd: cwd,
41
- ...input.location === void 0 ? {} : { location: input.location }
42
- }
43
- });
44
- }
45
- const { driver: _, ...config } = input;
46
- return yield* controller.create({
47
- driver,
48
- config
49
- });
50
- });
51
- const register = Effect.fn("Sandbox.register")(function* (input) {
52
- const controller = yield* Controller;
53
- const driver = yield* registered(input.driver);
54
- return yield* controller.register({
55
- driver,
56
- providerResourceId: input.providerResourceId
57
- });
58
- });
59
- const get = Effect.fn("Sandbox.get")(function* (id) {
60
- return yield* (yield* Controller).get(id);
61
- });
62
- const list = Effect.fn("Sandbox.list")(function* (input) {
63
- return yield* (yield* Controller).list({
64
- ...input?.driver === void 0 ? {} : { driver: Name.make(input.driver) },
65
- ...input?.status === void 0 ? {} : { status: input.status }
66
- });
67
- });
68
- const refresh = Effect.fn("Sandbox.refresh")(function* (id) {
69
- return yield* (yield* Controller).refresh(id);
70
- });
71
- const wake = Effect.fn("Sandbox.wake")(function* (id) {
72
- return yield* (yield* Controller).wake(id);
73
- });
74
- const stop = Effect.fn("Sandbox.stop")(function* (id) {
75
- return yield* (yield* Controller).stop(id);
76
- });
77
- const destroy = Effect.fn("Sandbox.destroy")(function* (id) {
78
- yield* (yield* Controller).destroy(id);
79
- });
80
- const Drivers = {
81
- get memory() {
82
- return make().driver;
83
- },
84
- get sqldb() {
85
- return make$1().driver;
86
- },
87
- vercel: (options = {}) => make$2(options),
88
- daytona: (options = {}) => make$3(options)
89
- };
90
- //#endregion
1
+ import { n as __exportAll } from "./rolldown-runtime-B4iAMlE-.mjs";
2
+ import { c as harness_exports, r as session_exports, s as sandbox_exports, u as tool_exports } from "./session-CF1B0VEr.mjs";
91
3
  //#region src/effect/tools.ts
92
4
  var tools_exports = /* @__PURE__ */ __exportAll({
93
5
  Tools: () => tools_exports,
package/effect.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"effect.mjs","names":["SandboxDriver.Registry","SandboxController.Controller","MemorySandboxDriver.make","SqldbSandboxDriver.make","VercelSandboxDriver.make","DaytonaSandboxDriver.make"],"sources":["../../src/effect/sandbox.ts","../../src/effect/tools.ts"],"sourcesContent":["import { Effect } from \"effect\";\nimport { SandboxController } from \"../sandbox/control.ts\";\nimport { SandboxDriver } from \"../sandbox/driver.ts\";\nimport { DaytonaSandboxDriver } from \"../sandbox/drivers/daytona.ts\";\nimport { MemorySandboxDriver } from \"../sandbox/drivers/memory.ts\";\nimport { SqldbSandboxDriver } from \"../sandbox/drivers/sqldb.ts\";\nimport { VercelSandboxDriver } from \"../sandbox/drivers/vercel.ts\";\nimport { SandboxInstance } from \"../sandbox/instance.ts\";\n\nexport type Info = SandboxInstance.Info;\nexport type Driver = SandboxDriver.Registration;\n\nexport type CreateInput =\n\t| { readonly driver: \"memory\"; readonly cwd?: string }\n\t| { readonly driver: \"sqldb\"; readonly cwd?: string; readonly location?: string }\n\t| ({ readonly driver: \"vercel\" } & VercelSandboxDriver.CreateConfig)\n\t| ({ readonly driver: \"daytona\" } & DaytonaSandboxDriver.CreateConfig);\n\nexport type RegisterInput = {\n\treadonly driver: \"vercel\" | \"daytona\";\n\treadonly providerResourceId: string;\n};\n\nconst registered = Effect.fn(\"Sandbox.registered\")(function* (name: string) {\n\tconst registry = yield* SandboxDriver.Registry;\n\treturn yield* registry.get(SandboxDriver.Name.make(name));\n});\n\nexport const create = Effect.fn(\"Sandbox.create\")(function* (input: CreateInput) {\n\tconst controller = yield* SandboxController.Controller;\n\tconst driver = yield* registered(input.driver);\n\tif (input.driver === \"memory\") {\n\t\tconst cwd = SandboxDriver.AbsolutePath.make(input.cwd ?? \"/\");\n\t\treturn yield* controller.create({ driver, config: { defaultCwd: cwd, initializeCwd: cwd } });\n\t}\n\tif (input.driver === \"sqldb\") {\n\t\tconst cwd = SandboxDriver.AbsolutePath.make(input.cwd ?? \"/\");\n\t\treturn yield* controller.create({\n\t\t\tdriver,\n\t\t\tconfig: {\n\t\t\t\tdefaultCwd: cwd,\n\t\t\t\tinitializeCwd: cwd,\n\t\t\t\t...(input.location === undefined ? {} : { location: input.location }),\n\t\t\t},\n\t\t});\n\t}\n\tconst { driver: _, ...config } = input;\n\treturn yield* controller.create({ driver, config });\n});\n\nexport const register = Effect.fn(\"Sandbox.register\")(function* (input: RegisterInput) {\n\tconst controller = yield* SandboxController.Controller;\n\tconst driver = yield* registered(input.driver);\n\treturn yield* controller.register({ driver, providerResourceId: input.providerResourceId });\n});\n\nexport const get = Effect.fn(\"Sandbox.get\")(function* (id: SandboxInstance.ID) {\n\tconst controller = yield* SandboxController.Controller;\n\treturn yield* controller.get(id);\n});\n\nexport const list = Effect.fn(\"Sandbox.list\")(function* (input?: {\n\treadonly driver?: string;\n\treadonly status?: SandboxInstance.Status;\n}) {\n\tconst controller = yield* SandboxController.Controller;\n\treturn yield* controller.list({\n\t\t...(input?.driver === undefined ? {} : { driver: SandboxDriver.Name.make(input.driver) }),\n\t\t...(input?.status === undefined ? {} : { status: input.status }),\n\t});\n});\n\nexport const refresh = Effect.fn(\"Sandbox.refresh\")(function* (id: SandboxInstance.ID) {\n\tconst controller = yield* SandboxController.Controller;\n\treturn yield* controller.refresh(id);\n});\n\nexport const wake = Effect.fn(\"Sandbox.wake\")(function* (id: SandboxInstance.ID) {\n\tconst controller = yield* SandboxController.Controller;\n\treturn yield* controller.wake(id);\n});\n\nexport const stop = Effect.fn(\"Sandbox.stop\")(function* (id: SandboxInstance.ID) {\n\tconst controller = yield* SandboxController.Controller;\n\treturn yield* controller.stop(id);\n});\n\nexport const destroy = Effect.fn(\"Sandbox.destroy\")(function* (id: SandboxInstance.ID) {\n\tconst controller = yield* SandboxController.Controller;\n\tyield* controller.destroy(id);\n});\n\nexport const Drivers = {\n\tget memory(): Driver {\n\t\treturn MemorySandboxDriver.make().driver;\n\t},\n\tget sqldb(): Driver {\n\t\treturn SqldbSandboxDriver.make().driver;\n\t},\n\tvercel: (options: VercelSandboxDriver.ClientOptions = {}): Driver => VercelSandboxDriver.make(options),\n\tdaytona: (options: DaytonaSandboxDriver.ClientOptions = {}): Driver => DaytonaSandboxDriver.make(options),\n} as const;\n\nexport { SandboxInstance };\n\nexport * as Sandbox from \"./sandbox.ts\";\n","export const bash = \"bash\" as const;\n\nexport * as Tools from \"./tools.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;AAuBA,MAAM,aAAa,OAAO,GAAG,oBAAoB,CAAC,CAAC,WAAW,MAAc;CAE3E,OAAO,QAAO,OADUA,SAAAA,CACD,IAAA,KAAuB,KAAK,IAAI,CAAC;AACzD,CAAC;AAED,MAAa,SAAS,OAAO,GAAG,gBAAgB,CAAC,CAAC,WAAW,OAAoB;CAChF,MAAM,aAAa,OAAOC;CAC1B,MAAM,SAAS,OAAO,WAAW,MAAM,MAAM;CAC7C,IAAI,MAAM,WAAW,UAAU;EAC9B,MAAM,MAAA,aAAiC,KAAK,MAAM,OAAO,GAAG;EAC5D,OAAO,OAAO,WAAW,OAAO;GAAE;GAAQ,QAAQ;IAAE,YAAY;IAAK,eAAe;GAAI;EAAE,CAAC;CAC5F;CACA,IAAI,MAAM,WAAW,SAAS;EAC7B,MAAM,MAAA,aAAiC,KAAK,MAAM,OAAO,GAAG;EAC5D,OAAO,OAAO,WAAW,OAAO;GAC/B;GACA,QAAQ;IACP,YAAY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AAO,GAAG,iBAAiB,CAAC,CAAC,WAAW,IAAwB;CAEtF,QAAO,OADmBA,WAAAA,CACR,QAAQ,EAAE;AAC7B,CAAC;AAED,MAAa,UAAU;CACtB,IAAI,SAAiB;EACpB,OAAOC,KAAyB,CAAC,CAAC;CACnC;CACA,IAAI,QAAgB;EACnB,OAAOC,OAAwB,CAAC,CAAC;CAClC;CACA,SAAS,UAA6C,CAAC,MAAcC,OAAyB,OAAO;CACrG,UAAU,UAA8C,CAAC,MAAcC,OAA0B,OAAO;AACzG;;;;;;;ACrGA,MAAa,OAAO"}
1
+ {"version":3,"file":"effect.mjs","names":[],"sources":["../../src/effect/tools.ts"],"sourcesContent":["export const bash = \"bash\" as const;\n\nexport * as Tools from \"./tools.ts\";\n"],"mappings":";;;;;;;AAAA,MAAa,OAAO"}