@codeworksh/harness 0.0.1-dev.20260824145955 → 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,16 @@ 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
+
90
100
  Local execution is the default. To create a session in a new Daytona sandbox, set `DAYTONA_API_KEY` and select the Daytona driver:
91
101
 
92
102
  ```sh
package/cli/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
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-m-xcehZ7.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";
@@ -55,30 +55,35 @@ const run = Command.make("run", {
55
55
  cwd: Flag.string("cwd").pipe(Flag.withAlias("C"), Flag.withDescription("Working directory for a new session"), Flag.optional),
56
56
  sandbox: Flag.choice("sandbox", sandboxDrivers).pipe(Flag.withDescription("Sandbox for a new session (default: local)"), Flag.optional),
57
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 for a new session"), Flag.optional),
59
- model: Flag.string("model").pipe(Flag.withDescription("Model ID for a new session"), Flag.optional),
60
- thinking: Flag.choice("thinking", thinkingLevels).pipe(Flag.withDescription("Thinking level for a new session"), 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
61
  }, Effect.fn("CLI.run")(function* ({ prompt, session, cwd, sandbox, sandboxProviderId, provider, model, thinking }) {
62
62
  const shared = yield* root;
63
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" });
64
64
  if (Option.isSome(provider) !== Option.isSome(model)) return yield* new InvalidInputError({ message: "--provider and --model must be provided together" });
65
- 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" });
66
65
  if (Option.isSome(sandboxProviderId) && (Option.isNone(sandbox) || sandbox.value === "local")) return yield* new InvalidInputError({ message: "--sandbox-provider-id requires a remote --sandbox" });
67
66
  return yield* Effect.gen(function* () {
67
+ const runtime = {
68
+ ...Option.isNone(provider) || Option.isNone(model) ? {} : { model: {
69
+ provider: provider.value,
70
+ id: model.value
71
+ } },
72
+ ...Option.isNone(thinking) ? {} : { thinkingLevel: thinking.value }
73
+ };
68
74
  let handle;
69
- if (Option.isSome(session)) handle = yield* attach({ sessionId: ID.make(session.value) });
75
+ if (Option.isSome(session)) handle = yield* attach({
76
+ sessionId: ID.make(session.value),
77
+ ...runtime
78
+ });
70
79
  else {
71
80
  const selectedSandbox = Option.getOrElse(sandbox, () => "local");
72
81
  const selected = yield* selectSandbox(selectedSandbox, Option.getOrUndefined(sandboxProviderId));
73
82
  handle = yield* create$1({
74
83
  title: "CLI",
84
+ ...runtime,
75
85
  ...selected === void 0 ? {} : { sandbox: selected },
76
- ...Option.isNone(cwd) ? {} : { directory: cwd.value },
77
- ...Option.isNone(provider) || Option.isNone(model) ? {} : { model: {
78
- provider: provider.value,
79
- id: model.value
80
- } },
81
- ...Option.isNone(thinking) ? {} : { thinkingLevel: thinking.value }
86
+ ...Option.isNone(cwd) ? {} : { directory: cwd.value }
82
87
  });
83
88
  }
84
89
  const ended = yield* Queue.unbounded();
@@ -112,8 +117,8 @@ const run = Command.make("run", {
112
117
  description: "Use an existing remote sandbox"
113
118
  },
114
119
  {
115
- command: "codework run --session <id> \"Now fix them\"",
116
- description: "Continue a session"
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"
117
122
  }
118
123
  ]));
119
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":["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(\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, 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(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\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\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) });\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...(selected === undefined ? {} : { sandbox: selected }),\n\t\t\t\t\t...(Option.isNone(cwd) ? {} : { directory: cwd.value }),\n\t\t\t\t\t...(Option.isNone(provider) || Option.isNone(model)\n\t\t\t\t\t\t? {}\n\t\t\t\t\t\t: { model: { provider: provider.value, id: model.value } }),\n\t\t\t\t\t...(Option.isNone(thinking) ? {} : { thinkingLevel: thinking.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{ 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;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,kBAA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,aAAa;CACpB;EAAE,SAAS;EAA4C,aAAa;CAAmB;CACvF;EACC,SAAS;EACT,aAAa;CACd;CACA;EACC,SAAS;EACT,aAAa;CACd;CACA;EACC,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,CAA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,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"}
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,5 +1,5 @@
1
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-m-xcehZ7.mjs";
2
+ import { c as harness_exports, r as session_exports, s as sandbox_exports, u as tool_exports } from "./session-CF1B0VEr.mjs";
3
3
  //#region src/effect/tools.ts
4
4
  var tools_exports = /* @__PURE__ */ __exportAll({
5
5
  Tools: () => tools_exports,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeworksh/harness",
3
- "version": "0.0.1-dev.20260824145955",
3
+ "version": "0.0.1-dev.20260824173147",
4
4
  "description": "AI agent harness — agent loop, tools, and code execution sandbox.",
5
5
  "keywords": [
6
6
  "agent",
@@ -7161,6 +7161,18 @@ const runtimeBindings = (input) => ({
7161
7161
  ...input.systemPrompt?.append === void 0 ? {} : { promptSystemAppend: input.systemPrompt.append },
7162
7162
  ...input.systemPrompt?.override === void 0 ? {} : { promptSystemOverride: input.systemPrompt.override }
7163
7163
  });
7164
+ const publishConfig = Effect.fn("Session.publishConfig")(function* (events, sessionId, input) {
7165
+ if (input.model === void 0 && input.thinkingLevel === void 0) return;
7166
+ yield* events.publish(ConfigChanged, {
7167
+ timestamp: yield* DateTime.now,
7168
+ sessionId,
7169
+ ...input.model === void 0 ? {} : { model: {
7170
+ providerId: input.model.provider,
7171
+ modelId: input.model.id
7172
+ } },
7173
+ ...input.thinkingLevel === void 0 ? {} : { thinkingLevel: input.thinkingLevel }
7174
+ });
7175
+ });
7164
7176
  const promptInput = (input) => {
7165
7177
  const value = typeof input === "string" ? { text: input } : input;
7166
7178
  return {
@@ -7234,15 +7246,7 @@ const create$1 = Effect.fn("Session.create")(function* (input = {}) {
7234
7246
  directory: AbsolutePath$1.make(directory),
7235
7247
  sandboxInstanceId: sandboxId
7236
7248
  });
7237
- if (input.model !== void 0 || input.thinkingLevel !== void 0) yield* events.publish(ConfigChanged, {
7238
- timestamp: yield* DateTime.now,
7239
- sessionId: id,
7240
- ...input.model === void 0 ? {} : { model: {
7241
- providerId: input.model.provider,
7242
- modelId: input.model.id
7243
- } },
7244
- ...input.thinkingLevel === void 0 ? {} : { thinkingLevel: input.thinkingLevel }
7245
- });
7249
+ yield* publishConfig(events, id, input);
7246
7250
  yield* runtime.set(id, runtimeBindings(input));
7247
7251
  return yield* makeHandle(id);
7248
7252
  });
@@ -7254,10 +7258,13 @@ const get = Effect.fn("Session.get")(function* (sessionId) {
7254
7258
  const attach = Effect.fn("Session.attach")(function* (input) {
7255
7259
  const found = yield* get(input.sessionId);
7256
7260
  if (Option.isNone(found)) return yield* new SessionNotFoundError({ sessionId: input.sessionId });
7257
- yield* (yield* Service$1).set(input.sessionId, runtimeBindings(input));
7261
+ const runtime = yield* Service$1;
7262
+ const events = yield* Service$13;
7263
+ yield* publishConfig(events, input.sessionId, input);
7264
+ yield* runtime.set(input.sessionId, runtimeBindings(input));
7258
7265
  return found.value;
7259
7266
  });
7260
7267
  //#endregion
7261
7268
  export { create$2 as a, harness_exports as c, ID$4 as d, Drivers as i, layer as l, create$1 as n, register as o, session_exports as r, sandbox_exports as s, attach as t, tool_exports as u };
7262
7269
 
7263
- //# sourceMappingURL=session-m-xcehZ7.mjs.map
7270
+ //# sourceMappingURL=session-CF1B0VEr.mjs.map