@codeworksh/harness 0.0.1-dev.20260824182323 → 0.0.1-dev.20260825090614
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 +15 -0
- package/cli/index.d.mts +1 -2
- package/cli/index.mjs +150 -9
- package/cli/index.mjs.map +1 -1
- package/effect.d.mts +2101 -26
- package/effect.mjs +2 -2
- package/package.json +2 -2
- package/{session-CF1B0VEr.mjs → session-BpTL_HoS.mjs} +247 -99
- package/session-BpTL_HoS.mjs.map +1 -0
- package/control-DyVTL25_.d.mts +0 -1947
- package/session-CF1B0VEr.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -76,6 +76,21 @@ pnpm dlx @codeworksh/harness@dev \
|
|
|
76
76
|
"Inspect this repository"
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
+
The streamed response remains clean on stdout for piping. Session context and the per-run model usage summary are written to stderr:
|
|
80
|
+
|
|
81
|
+
```text
|
|
82
|
+
session ses_...
|
|
83
|
+
sandbox local · /workspace/project
|
|
84
|
+
|
|
85
|
+
── response ─────────────────────────────────────────────────────────────
|
|
86
|
+
The response streams here.
|
|
87
|
+
── usage ────────────────────────────────────────────────────────────────
|
|
88
|
+
model openai/gpt-5.5
|
|
89
|
+
tokens 12,400 input · 820 output · 13,220 total
|
|
90
|
+
cache 9,600 read · 0 write
|
|
91
|
+
cost $0.014200 · 1 turn
|
|
92
|
+
```
|
|
93
|
+
|
|
79
94
|
`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
95
|
|
|
81
96
|
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:
|
package/cli/index.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { $ as SandboxUnavailError, G as SandboxDriverRegistrationError, J as SandboxProviderError, T as SessionNotFoundError, W as SandboxDriverNotRegisteredError, Z as SandboxRemovedError, c as LLMStreamError, f as SandboxDirectoryNotFoundError, g as SnapshotError, l as ModelNotFoundError, n as PromptConflictError, nt as ContextDecodeError, p as TurnError, q as SandboxNotFoundError, rt as ContextEncodeError, tt as FileSystemError, u as ProviderTurnError } from "../control-DyVTL25_.mjs";
|
|
2
1
|
import { Effect, Option, Schema } from "effect";
|
|
3
2
|
import { CliError, Command } from "effect/unstable/cli";
|
|
4
3
|
//#region src/cli/index.d.ts
|
|
@@ -16,7 +15,7 @@ declare const command: Command.Command<"codework", {
|
|
|
16
15
|
}, {
|
|
17
16
|
readonly home: Option.Option<string>;
|
|
18
17
|
readonly database: Option.Option<string>;
|
|
19
|
-
},
|
|
18
|
+
}, InvalidInputError | ModelgenError, never>;
|
|
20
19
|
declare const main: Effect.Effect<void, Command.Error<typeof command> | CliError.CliError>;
|
|
21
20
|
//#endregion
|
|
22
21
|
export { command, main };
|
package/cli/index.mjs
CHANGED
|
@@ -1,10 +1,118 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as create, d as
|
|
3
|
-
import { Effect, Fiber, Option, Queue, Schema, Stream } from "effect";
|
|
2
|
+
import { _ as LLMTextDelta, a as create, d as LLMStreamError, f as ModelCatalogError, g as LLMEnded, i as Drivers, l as layer, m as ProviderError, n as create$1, o as register, p as ModelNotFoundError, t as attach, v as TurnEnded, y as ID } from "../session-BpTL_HoS.mjs";
|
|
3
|
+
import { Duration, Effect, Fiber, Option, Queue, Ref, Schema, Stream } from "effect";
|
|
4
4
|
import { generateModels } from "@codeworksh/aikit/modelgen";
|
|
5
5
|
import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
|
|
6
6
|
import * as NodeServices from "@effect/platform-node/NodeServices";
|
|
7
7
|
import { Argument, Command, Flag } from "effect/unstable/cli";
|
|
8
|
+
//#region src/cli/error.ts
|
|
9
|
+
const isProviderError = Schema.is(ProviderError);
|
|
10
|
+
const isModelCatalogError = Schema.is(ModelCatalogError);
|
|
11
|
+
const isModelNotFoundError = Schema.is(ModelNotFoundError);
|
|
12
|
+
const isLLMStreamError = Schema.is(LLMStreamError);
|
|
13
|
+
const providerCategory = (reason) => {
|
|
14
|
+
switch (reason._tag) {
|
|
15
|
+
case "Runner.ProviderAuthenticationError": return "authentication";
|
|
16
|
+
case "Runner.ProviderConfigurationError": return "configuration";
|
|
17
|
+
case "Runner.ProviderAuthorizationError": return "authorization";
|
|
18
|
+
case "Runner.ProviderModelUnavailableError": return "model_unavailable";
|
|
19
|
+
case "Runner.ProviderRateLimitError": return "rate_limited";
|
|
20
|
+
case "Runner.ProviderQuotaError": return "quota";
|
|
21
|
+
case "Runner.ProviderInvalidRequestError": return "invalid_request";
|
|
22
|
+
case "Runner.ProviderContentPolicyError": return "content_policy";
|
|
23
|
+
case "Runner.ProviderTimeoutError": return "timeout";
|
|
24
|
+
case "Runner.ProviderTransportError": return "transport";
|
|
25
|
+
case "Runner.ProviderUnavailableError": return "provider_unavailable";
|
|
26
|
+
case "Runner.ProviderInvalidResponseError": return "invalid_response";
|
|
27
|
+
case "Runner.ProviderUnknownError": return "provider";
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const credentialHint = (provider) => {
|
|
31
|
+
switch (provider) {
|
|
32
|
+
case "openrouter": return "set OPENROUTER_API_KEY and retry";
|
|
33
|
+
case "openai": return "set OPENAI_API_KEY and retry";
|
|
34
|
+
case "anthropic": return "set ANTHROPIC_API_KEY and retry";
|
|
35
|
+
case "google": return "set GOOGLE_GENERATIVE_AI_API_KEY and retry";
|
|
36
|
+
case "xai": return "set XAI_API_KEY and retry";
|
|
37
|
+
default: return `configure credentials for provider "${provider}" and retry`;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const providerHint = (error) => {
|
|
41
|
+
switch (error.reason._tag) {
|
|
42
|
+
case "Runner.ProviderAuthenticationError": return error.reason.authentication === "missing" ? credentialHint(error.provider) : `check the credentials configured for provider "${error.provider}"`;
|
|
43
|
+
case "Runner.ProviderAuthorizationError": return "check that the credential can access this model and endpoint";
|
|
44
|
+
case "Runner.ProviderModelUnavailableError": return "check the provider model ID and whether your account can access it";
|
|
45
|
+
case "Runner.ProviderRateLimitError": return error.reason.retryAfter === void 0 ? "retry after the provider rate-limit window resets" : `retry in about ${Math.ceil(Duration.toMillis(error.reason.retryAfter) / 1e3)} seconds`;
|
|
46
|
+
case "Runner.ProviderQuotaError": return "check the provider account quota or billing balance";
|
|
47
|
+
case "Runner.ProviderTimeoutError":
|
|
48
|
+
case "Runner.ProviderTransportError":
|
|
49
|
+
case "Runner.ProviderUnavailableError": return error.isRetryable ? "this failure is retryable" : void 0;
|
|
50
|
+
default: return;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const unknownMessage = (error) => {
|
|
54
|
+
if (error instanceof Error && error.message.trim().length > 0) return error.message;
|
|
55
|
+
if (typeof error === "string" && error.trim().length > 0) return error;
|
|
56
|
+
if (typeof error === "object" && error !== null && "_tag" in error) return String(error._tag);
|
|
57
|
+
return "the command failed for an unknown reason";
|
|
58
|
+
};
|
|
59
|
+
/** Render typed SDK errors for humans without exposing Effect causes or provider payloads. */
|
|
60
|
+
const renderError = (error) => {
|
|
61
|
+
if (isProviderError(error)) {
|
|
62
|
+
const hint = providerHint(error);
|
|
63
|
+
return [
|
|
64
|
+
`error[${providerCategory(error.reason)}]: ${error.message}`,
|
|
65
|
+
`provider: ${error.provider}`,
|
|
66
|
+
`model: ${error.model}`,
|
|
67
|
+
...error.reason.requestId === void 0 ? [] : [`request: ${error.reason.requestId}`],
|
|
68
|
+
...hint === void 0 ? [] : [`hint: ${hint}`]
|
|
69
|
+
].join("\n") + "\n";
|
|
70
|
+
}
|
|
71
|
+
if (isModelCatalogError(error)) return [`error[model_catalog]: ${error.message}`, "hint: run `codework modelgen` or set CODEWORK_MODELS_FILE to a generated catalog"].join("\n") + "\n";
|
|
72
|
+
if (isModelNotFoundError(error)) return [`error[model_not_found]: ${error.message}`, "hint: check the provider/model IDs in models.gen.json or regenerate the catalog"].join("\n") + "\n";
|
|
73
|
+
if (isLLMStreamError(error)) return `error[stream_protocol]: ${error.message}\n`;
|
|
74
|
+
return `error: ${unknownMessage(error)}\n`;
|
|
75
|
+
};
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/cli/output.ts
|
|
78
|
+
const emptyUsage = {
|
|
79
|
+
turns: 0,
|
|
80
|
+
input: 0,
|
|
81
|
+
output: 0,
|
|
82
|
+
reasoning: 0,
|
|
83
|
+
cacheRead: 0,
|
|
84
|
+
cacheWrite: 0,
|
|
85
|
+
totalTokens: 0,
|
|
86
|
+
cost: 0
|
|
87
|
+
};
|
|
88
|
+
const addUsage = (summary, message) => ({
|
|
89
|
+
turns: summary.turns + 1,
|
|
90
|
+
provider: message.provider.id,
|
|
91
|
+
model: message.responseModel ?? message.model,
|
|
92
|
+
input: summary.input + message.usage.input,
|
|
93
|
+
output: summary.output + message.usage.output,
|
|
94
|
+
reasoning: summary.reasoning + (message.usage.reasoning ?? 0),
|
|
95
|
+
cacheRead: summary.cacheRead + message.usage.cacheRead,
|
|
96
|
+
cacheWrite: summary.cacheWrite + message.usage.cacheWrite,
|
|
97
|
+
totalTokens: summary.totalTokens + message.usage.totalTokens,
|
|
98
|
+
cost: summary.cost + message.usage.cost.total
|
|
99
|
+
});
|
|
100
|
+
const number = new Intl.NumberFormat("en-US");
|
|
101
|
+
const row = (label, value) => `${label.padEnd(9)}${value}\n`;
|
|
102
|
+
const formatCost = (cost) => `$${cost.toFixed(cost > 0 && cost < .01 ? 6 : 4)}`;
|
|
103
|
+
const divider = (label, columns = 72) => {
|
|
104
|
+
const width = Math.min(100, Math.max(32, columns));
|
|
105
|
+
const start = `── ${label} `;
|
|
106
|
+
return `${start}${"─".repeat(Math.max(2, width - start.length))}\n`;
|
|
107
|
+
};
|
|
108
|
+
const header = (input) => `${row("session", input.sessionId)}${row("sandbox", `${input.sandbox} · ${input.directory}`)}\n${divider("response", input.columns)}`;
|
|
109
|
+
const usage = (summary, columns) => {
|
|
110
|
+
const turns = `${summary.turns} ${summary.turns === 1 ? "turn" : "turns"}`;
|
|
111
|
+
const model = summary.provider === void 0 || summary.model === void 0 ? "unknown" : `${summary.provider}/${summary.model}`;
|
|
112
|
+
const reasoning = summary.reasoning === 0 ? "" : ` · ${number.format(summary.reasoning)} reasoning`;
|
|
113
|
+
return `${divider("usage", columns)}${row("model", model)}${row("tokens", `${number.format(summary.input)} input · ${number.format(summary.output)} output${reasoning} · ${number.format(summary.totalTokens)} total`)}${row("cache", `${number.format(summary.cacheRead)} read · ${number.format(summary.cacheWrite)} write`)}${row("cost", `${formatCost(summary.cost)} · ${turns}`)}`;
|
|
114
|
+
};
|
|
115
|
+
//#endregion
|
|
8
116
|
//#region src/cli/index.ts
|
|
9
117
|
const thinkingLevels = [
|
|
10
118
|
"off",
|
|
@@ -22,14 +130,35 @@ const sandboxDrivers = [
|
|
|
22
130
|
];
|
|
23
131
|
const writeOut = (value) => Effect.sync(() => void process.stdout.write(value));
|
|
24
132
|
const writeError = (value) => Effect.sync(() => void process.stderr.write(value));
|
|
133
|
+
const terminalColumns = () => process.stderr.isTTY ? process.stderr.columns ?? 72 : 72;
|
|
25
134
|
var InvalidInputError = class extends Schema.TaggedError()("CLI.InvalidInputError", { message: Schema.String }) {};
|
|
26
135
|
var ModelgenError = class extends Schema.TaggedError()("CLI.ModelgenError", { cause: Schema.Defect() }) {};
|
|
27
|
-
const
|
|
28
|
-
|
|
136
|
+
const initialRenderState = {
|
|
137
|
+
usage: emptyUsage,
|
|
138
|
+
textSeen: false,
|
|
139
|
+
textEndsWithNewline: false
|
|
140
|
+
};
|
|
141
|
+
const isTextDelta = Schema.is(LLMTextDelta);
|
|
142
|
+
const isLLMEnded = Schema.is(LLMEnded);
|
|
143
|
+
const isTurnEnded = Schema.is(TurnEnded);
|
|
144
|
+
const render = (ended, state) => Effect.fn("CLI.render")(function* (event) {
|
|
145
|
+
if (isTextDelta(event)) {
|
|
29
146
|
yield* writeOut(event.data.delta);
|
|
147
|
+
if (event.data.delta.length > 0) yield* Ref.update(state, (current) => ({
|
|
148
|
+
...current,
|
|
149
|
+
textSeen: true,
|
|
150
|
+
textEndsWithNewline: event.data.delta.endsWith("\n")
|
|
151
|
+
}));
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (isLLMEnded(event)) {
|
|
155
|
+
yield* Ref.update(state, (current) => ({
|
|
156
|
+
...current,
|
|
157
|
+
usage: addUsage(current.usage, event.data.message)
|
|
158
|
+
}));
|
|
30
159
|
return;
|
|
31
160
|
}
|
|
32
|
-
if (event
|
|
161
|
+
if (isTurnEnded(event)) yield* Queue.offer(ended, event.data.messageId);
|
|
33
162
|
});
|
|
34
163
|
const awaitMessage = Effect.fn("CLI.awaitMessage")(function* (ended, messageId) {
|
|
35
164
|
while ((yield* Queue.take(ended)) !== messageId);
|
|
@@ -87,18 +216,30 @@ const run = Command.make("run", {
|
|
|
87
216
|
});
|
|
88
217
|
}
|
|
89
218
|
const ended = yield* Queue.unbounded();
|
|
90
|
-
const
|
|
91
|
-
yield*
|
|
219
|
+
const renderState = yield* Ref.make(initialRenderState);
|
|
220
|
+
const printer = yield* handle.events().pipe(Stream.runForEach(render(ended, renderState)), Effect.forkScoped({ startImmediately: true }));
|
|
221
|
+
const info = yield* handle.info;
|
|
222
|
+
const columns = terminalColumns();
|
|
223
|
+
yield* writeError(header({
|
|
224
|
+
sessionId: handle.id,
|
|
225
|
+
sandbox: info.sandbox?.driver ?? "local",
|
|
226
|
+
directory: info.directory,
|
|
227
|
+
columns
|
|
228
|
+
}));
|
|
92
229
|
yield* handle.run(prompt);
|
|
93
230
|
const leaf = (yield* handle.path()).at(-1);
|
|
94
231
|
if (leaf !== void 0) yield* awaitMessage(ended, leaf.entry.id);
|
|
95
232
|
yield* Fiber.interrupt(printer);
|
|
96
|
-
yield*
|
|
233
|
+
const rendered = yield* Ref.get(renderState);
|
|
234
|
+
if (rendered.textSeen && !rendered.textEndsWithNewline) yield* writeOut("\n");
|
|
235
|
+
yield* writeError(usage(rendered.usage, columns));
|
|
97
236
|
}).pipe(Effect.provide(layer({
|
|
98
237
|
...Option.isNone(shared.home) ? {} : { home: shared.home.value },
|
|
99
238
|
...Option.isNone(shared.database) ? {} : { database: shared.database.value },
|
|
100
239
|
sandboxes: [Drivers.daytona(), Drivers.vercel()]
|
|
101
|
-
})), Effect.scoped)
|
|
240
|
+
})), Effect.scoped, Effect.catch((error) => writeError(renderError(error)).pipe(Effect.andThen(Effect.sync(() => {
|
|
241
|
+
process.exitCode = 1;
|
|
242
|
+
})))));
|
|
102
243
|
})).pipe(Command.withDescription("Start or continue an agent session"), Command.withExamples([
|
|
103
244
|
{
|
|
104
245
|
command: "codework run \"Inspect the failing tests\"",
|
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(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;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AQ,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":["Runner.ProviderError","Runner.ModelCatalogError","Runner.ModelNotFoundError","Runner.LLMStreamError","EventList.LLMTextDelta","EventList.LLMEnded","EventList.TurnEnded","Sandbox.create","Sandbox.register","Session.attach","Session.create","Harness.layer"],"sources":["../../../src/cli/error.ts","../../../src/cli/output.ts","../../../src/cli/index.ts"],"sourcesContent":["import { Duration, Schema } from \"effect\";\nimport { Runner } from \"../runner/run.ts\";\n\nconst isProviderError = Schema.is(Runner.ProviderError);\nconst isModelCatalogError = Schema.is(Runner.ModelCatalogError);\nconst isModelNotFoundError = Schema.is(Runner.ModelNotFoundError);\nconst isLLMStreamError = Schema.is(Runner.LLMStreamError);\n\nconst providerCategory = (reason: Runner.ProviderFailureReason): string => {\n\tswitch (reason._tag) {\n\t\tcase \"Runner.ProviderAuthenticationError\":\n\t\t\treturn \"authentication\";\n\t\tcase \"Runner.ProviderConfigurationError\":\n\t\t\treturn \"configuration\";\n\t\tcase \"Runner.ProviderAuthorizationError\":\n\t\t\treturn \"authorization\";\n\t\tcase \"Runner.ProviderModelUnavailableError\":\n\t\t\treturn \"model_unavailable\";\n\t\tcase \"Runner.ProviderRateLimitError\":\n\t\t\treturn \"rate_limited\";\n\t\tcase \"Runner.ProviderQuotaError\":\n\t\t\treturn \"quota\";\n\t\tcase \"Runner.ProviderInvalidRequestError\":\n\t\t\treturn \"invalid_request\";\n\t\tcase \"Runner.ProviderContentPolicyError\":\n\t\t\treturn \"content_policy\";\n\t\tcase \"Runner.ProviderTimeoutError\":\n\t\t\treturn \"timeout\";\n\t\tcase \"Runner.ProviderTransportError\":\n\t\t\treturn \"transport\";\n\t\tcase \"Runner.ProviderUnavailableError\":\n\t\t\treturn \"provider_unavailable\";\n\t\tcase \"Runner.ProviderInvalidResponseError\":\n\t\t\treturn \"invalid_response\";\n\t\tcase \"Runner.ProviderUnknownError\":\n\t\t\treturn \"provider\";\n\t}\n};\n\nconst credentialHint = (provider: string): string => {\n\tswitch (provider) {\n\t\tcase \"openrouter\":\n\t\t\treturn \"set OPENROUTER_API_KEY and retry\";\n\t\tcase \"openai\":\n\t\t\treturn \"set OPENAI_API_KEY and retry\";\n\t\tcase \"anthropic\":\n\t\t\treturn \"set ANTHROPIC_API_KEY and retry\";\n\t\tcase \"google\":\n\t\t\treturn \"set GOOGLE_GENERATIVE_AI_API_KEY and retry\";\n\t\tcase \"xai\":\n\t\t\treturn \"set XAI_API_KEY and retry\";\n\t\tdefault:\n\t\t\treturn `configure credentials for provider \"${provider}\" and retry`;\n\t}\n};\n\nconst providerHint = (error: Runner.ProviderError): string | undefined => {\n\tswitch (error.reason._tag) {\n\t\tcase \"Runner.ProviderAuthenticationError\":\n\t\t\treturn error.reason.authentication === \"missing\"\n\t\t\t\t? credentialHint(error.provider)\n\t\t\t\t: `check the credentials configured for provider \"${error.provider}\"`;\n\t\tcase \"Runner.ProviderAuthorizationError\":\n\t\t\treturn \"check that the credential can access this model and endpoint\";\n\t\tcase \"Runner.ProviderModelUnavailableError\":\n\t\t\treturn \"check the provider model ID and whether your account can access it\";\n\t\tcase \"Runner.ProviderRateLimitError\":\n\t\t\treturn error.reason.retryAfter === undefined\n\t\t\t\t? \"retry after the provider rate-limit window resets\"\n\t\t\t\t: `retry in about ${Math.ceil(Duration.toMillis(error.reason.retryAfter) / 1_000)} seconds`;\n\t\tcase \"Runner.ProviderQuotaError\":\n\t\t\treturn \"check the provider account quota or billing balance\";\n\t\tcase \"Runner.ProviderTimeoutError\":\n\t\tcase \"Runner.ProviderTransportError\":\n\t\tcase \"Runner.ProviderUnavailableError\":\n\t\t\treturn error.isRetryable ? \"this failure is retryable\" : undefined;\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n};\n\nconst unknownMessage = (error: unknown): string => {\n\tif (error instanceof Error && error.message.trim().length > 0) return error.message;\n\tif (typeof error === \"string\" && error.trim().length > 0) return error;\n\tif (typeof error === \"object\" && error !== null && \"_tag\" in error) return String(error._tag);\n\treturn \"the command failed for an unknown reason\";\n};\n\n/** Render typed SDK errors for humans without exposing Effect causes or provider payloads. */\nexport const renderError = (error: unknown): string => {\n\tif (isProviderError(error)) {\n\t\tconst hint = providerHint(error);\n\t\treturn (\n\t\t\t[\n\t\t\t\t`error[${providerCategory(error.reason)}]: ${error.message}`,\n\t\t\t\t`provider: ${error.provider}`,\n\t\t\t\t`model: ${error.model}`,\n\t\t\t\t...(error.reason.requestId === undefined ? [] : [`request: ${error.reason.requestId}`]),\n\t\t\t\t...(hint === undefined ? [] : [`hint: ${hint}`]),\n\t\t\t].join(\"\\n\") + \"\\n\"\n\t\t);\n\t}\n\tif (isModelCatalogError(error)) {\n\t\treturn (\n\t\t\t[\n\t\t\t\t`error[model_catalog]: ${error.message}`,\n\t\t\t\t\"hint: run `codework modelgen` or set CODEWORK_MODELS_FILE to a generated catalog\",\n\t\t\t].join(\"\\n\") + \"\\n\"\n\t\t);\n\t}\n\tif (isModelNotFoundError(error)) {\n\t\treturn (\n\t\t\t[\n\t\t\t\t`error[model_not_found]: ${error.message}`,\n\t\t\t\t\"hint: check the provider/model IDs in models.gen.json or regenerate the catalog\",\n\t\t\t].join(\"\\n\") + \"\\n\"\n\t\t);\n\t}\n\tif (isLLMStreamError(error)) {\n\t\treturn `error[stream_protocol]: ${error.message}\\n`;\n\t}\n\treturn `error: ${unknownMessage(error)}\\n`;\n};\n","import type { Message } from \"@codeworksh/aikit\";\n\nexport interface UsageSummary {\n\treadonly turns: number;\n\treadonly provider?: string;\n\treadonly model?: string;\n\treadonly input: number;\n\treadonly output: number;\n\treadonly reasoning: number;\n\treadonly cacheRead: number;\n\treadonly cacheWrite: number;\n\treadonly totalTokens: number;\n\treadonly cost: number;\n}\n\nexport const emptyUsage: UsageSummary = {\n\tturns: 0,\n\tinput: 0,\n\toutput: 0,\n\treasoning: 0,\n\tcacheRead: 0,\n\tcacheWrite: 0,\n\ttotalTokens: 0,\n\tcost: 0,\n};\n\nexport const addUsage = (summary: UsageSummary, message: Message.AssistantMessage): UsageSummary => ({\n\tturns: summary.turns + 1,\n\tprovider: message.provider.id,\n\tmodel: message.responseModel ?? message.model,\n\tinput: summary.input + message.usage.input,\n\toutput: summary.output + message.usage.output,\n\treasoning: summary.reasoning + (message.usage.reasoning ?? 0),\n\tcacheRead: summary.cacheRead + message.usage.cacheRead,\n\tcacheWrite: summary.cacheWrite + message.usage.cacheWrite,\n\ttotalTokens: summary.totalTokens + message.usage.totalTokens,\n\tcost: summary.cost + message.usage.cost.total,\n});\n\nconst number = new Intl.NumberFormat(\"en-US\");\nconst row = (label: string, value: string) => `${label.padEnd(9)}${value}\\n`;\n\nconst formatCost = (cost: number): string => `$${cost.toFixed(cost > 0 && cost < 0.01 ? 6 : 4)}`;\n\nexport const divider = (label: string, columns = 72): string => {\n\tconst width = Math.min(100, Math.max(32, columns));\n\tconst start = `── ${label} `;\n\treturn `${start}${\"─\".repeat(Math.max(2, width - start.length))}\\n`;\n};\n\nexport const header = (input: {\n\treadonly sessionId: string;\n\treadonly sandbox: string;\n\treadonly directory: string;\n\treadonly columns?: number;\n}): string =>\n\t`${row(\"session\", input.sessionId)}${row(\"sandbox\", `${input.sandbox} · ${input.directory}`)}\\n${divider(\n\t\t\"response\",\n\t\tinput.columns,\n\t)}`;\n\nexport const usage = (summary: UsageSummary, columns?: number): string => {\n\tconst turns = `${summary.turns} ${summary.turns === 1 ? \"turn\" : \"turns\"}`;\n\tconst model =\n\t\tsummary.provider === undefined || summary.model === undefined\n\t\t\t? \"unknown\"\n\t\t\t: `${summary.provider}/${summary.model}`;\n\tconst reasoning = summary.reasoning === 0 ? \"\" : ` · ${number.format(summary.reasoning)} reasoning`;\n\treturn `${divider(\"usage\", columns)}${row(\"model\", model)}${row(\n\t\t\"tokens\",\n\t\t`${number.format(summary.input)} input · ${number.format(summary.output)} output${reasoning} · ${number.format(\n\t\t\tsummary.totalTokens,\n\t\t)} total`,\n\t)}${row(\"cache\", `${number.format(summary.cacheRead)} read · ${number.format(summary.cacheWrite)} write`)}${row(\n\t\t\"cost\",\n\t\t`${formatCost(summary.cost)} · ${turns}`,\n\t)}`;\n};\n","#!/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, Ref, 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 { EventList } from \"../event/list.ts\";\nimport type { EventSchema } from \"../event/schema.ts\";\nimport { renderError } from \"./error.ts\";\nimport { addUsage, emptyUsage, header, usage, type UsageSummary } from \"./output.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));\nconst terminalColumns = () => (process.stderr.isTTY ? (process.stderr.columns ?? 72) : 72);\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\ninterface RenderState {\n\treadonly usage: UsageSummary;\n\treadonly textSeen: boolean;\n\treadonly textEndsWithNewline: boolean;\n}\n\nconst initialRenderState: RenderState = {\n\tusage: emptyUsage,\n\ttextSeen: false,\n\ttextEndsWithNewline: false,\n};\n\nconst isTextDelta = Schema.is(EventList.LLMTextDelta);\nconst isLLMEnded = Schema.is(EventList.LLMEnded);\nconst isTurnEnded = Schema.is(EventList.TurnEnded);\n\nconst render = (ended: Queue.Queue<string>, state: Ref.Ref<RenderState>) =>\n\tEffect.fn(\"CLI.render\")(function* (event: EventSchema.Payload) {\n\t\tif (isTextDelta(event)) {\n\t\t\tyield* writeOut(event.data.delta);\n\t\t\tif (event.data.delta.length > 0) {\n\t\t\t\tyield* Ref.update(state, (current) => ({\n\t\t\t\t\t...current,\n\t\t\t\t\ttextSeen: true,\n\t\t\t\t\ttextEndsWithNewline: event.data.delta.endsWith(\"\\n\"),\n\t\t\t\t}));\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (isLLMEnded(event)) {\n\t\t\tyield* Ref.update(state, (current) => ({ ...current, usage: addUsage(current.usage, event.data.message) }));\n\t\t\treturn;\n\t\t}\n\t\tif (isTurnEnded(event)) {\n\t\t\tyield* Queue.offer(ended, event.data.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 renderState = yield* Ref.make(initialRenderState);\n\t\t\tconst printer = yield* handle\n\t\t\t\t.events()\n\t\t\t\t.pipe(Stream.runForEach(render(ended, renderState)), Effect.forkScoped({ startImmediately: true }));\n\n\t\t\tconst info = yield* handle.info;\n\t\t\tconst columns = terminalColumns();\n\t\t\tyield* writeError(\n\t\t\t\theader({\n\t\t\t\t\tsessionId: handle.id,\n\t\t\t\t\tsandbox: info.sandbox?.driver ?? \"local\",\n\t\t\t\t\tdirectory: info.directory,\n\t\t\t\t\tcolumns,\n\t\t\t\t}),\n\t\t\t);\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\tconst rendered = yield* Ref.get(renderState);\n\t\t\tif (rendered.textSeen && !rendered.textEndsWithNewline) yield* writeOut(\"\\n\");\n\t\t\tyield* writeError(usage(rendered.usage, columns));\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\tEffect.catch((error) =>\n\t\t\t\twriteError(renderError(error)).pipe(\n\t\t\t\t\tEffect.andThen(\n\t\t\t\t\t\tEffect.sync(() => {\n\t\t\t\t\t\t\tprocess.exitCode = 1;\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t),\n\t\t);\n\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":";;;;;;;;AAGA,MAAM,kBAAkB,OAAO,GAAGA,aAAoB;AACtD,MAAM,sBAAsB,OAAO,GAAGC,iBAAwB;AAC9D,MAAM,uBAAuB,OAAO,GAAGC,kBAAyB;AAChE,MAAM,mBAAmB,OAAO,GAAGC,cAAqB;AAExD,MAAM,oBAAoB,WAAiD;CAC1E,QAAQ,OAAO,MAAf;EACC,KAAK,sCACJ,OAAO;EACR,KAAK,qCACJ,OAAO;EACR,KAAK,qCACJ,OAAO;EACR,KAAK,wCACJ,OAAO;EACR,KAAK,iCACJ,OAAO;EACR,KAAK,6BACJ,OAAO;EACR,KAAK,sCACJ,OAAO;EACR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