@codeworksh/cli 0.8.0 → 0.9.0-canary.158.1.gdff28d0d
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/{acp-DodCRypZ.mjs → acp-D1X6PAQd.mjs} +16 -11
- package/acp-D1X6PAQd.mjs.map +1 -0
- package/{add-Dgy0iTEQ.mjs → add-BO0TXkKX.mjs} +8 -7
- package/add-BO0TXkKX.mjs.map +1 -0
- package/{add-31QB-o0_.mjs → add-BwC5Yb3Z.mjs} +5 -5
- package/add-BwC5Yb3Z.mjs.map +1 -0
- package/{catalog-XfqtqMDz.mjs → catalog-BhnZFkoq.mjs} +2 -2
- package/{catalog-XfqtqMDz.mjs.map → catalog-BhnZFkoq.mjs.map} +1 -1
- package/{check-BoANDJxT.mjs → check-n2oLWYrZ.mjs} +4 -4
- package/check-n2oLWYrZ.mjs.map +1 -0
- package/connect-CO-oR-Br.mjs +35 -0
- package/connect-CO-oR-Br.mjs.map +1 -0
- package/{control-CQxWGS4k.mjs → control-Clr9Xyw9.mjs} +10 -9
- package/control-Clr9Xyw9.mjs.map +1 -0
- package/devices-aPlpoGGA.mjs +29 -0
- package/devices-aPlpoGGA.mjs.map +1 -0
- package/disconnect-B7HoGP0E.mjs +21 -0
- package/disconnect-B7HoGP0E.mjs.map +1 -0
- package/disconnect-gKR8hsnU.mjs +2 -0
- package/{service-CjOS-xCw.mjs → discovery-D07MPnKd.mjs} +13 -37
- package/discovery-D07MPnKd.mjs.map +1 -0
- package/{entries-DpL4xhu0.mjs → entries-BzfySpSJ.mjs} +3 -3
- package/{entries-DpL4xhu0.mjs.map → entries-BzfySpSJ.mjs.map} +1 -1
- package/{error-CPyvkO4x.mjs → error-ippxl2z7.mjs} +775 -31
- package/error-ippxl2z7.mjs.map +1 -0
- package/{fork-CjZteIbk.mjs → fork-lbhh_6QP.mjs} +8 -7
- package/fork-lbhh_6QP.mjs.map +1 -0
- package/identity-DbK4fABs.mjs +26 -0
- package/identity-DbK4fABs.mjs.map +1 -0
- package/{thread-I6vNdC0y.mjs → ids-cNIRx0-c.mjs} +11 -5
- package/ids-cNIRx0-c.mjs.map +1 -0
- package/index.mjs +39 -34
- package/index.mjs.map +1 -1
- package/{install-BUfEBtrj.mjs → install-dfD5hzCS.mjs} +4 -4
- package/install-dfD5hzCS.mjs.map +1 -0
- package/jsonc-CWL4-4yz.mjs +33 -0
- package/jsonc-CWL4-4yz.mjs.map +1 -0
- package/{link-ZuzWj9qt.mjs → link-D1cicwAl.mjs} +8 -6
- package/link-D1cicwAl.mjs.map +1 -0
- package/{list-DDuzyNv0.mjs → list-BKJgNMJm.mjs} +10 -12
- package/list-BKJgNMJm.mjs.map +1 -0
- package/{list-6QTwXTKO.mjs → list-C3McEC0O.mjs} +4 -4
- package/list-C3McEC0O.mjs.map +1 -0
- package/{list-DPbF2uMB.mjs → list-CGT6jT-r.mjs} +4 -4
- package/list-CGT6jT-r.mjs.map +1 -0
- package/{list-BnIIcMI3.mjs → list-DZK016LF.mjs} +4 -4
- package/list-DZK016LF.mjs.map +1 -0
- package/{login-BtuROCPJ.mjs → login-DuFDeGH-.mjs} +4 -4
- package/login-DuFDeGH-.mjs.map +1 -0
- package/{login-CGXU21AK.mjs → login-XhIIF5Yu.mjs} +4 -4
- package/login-XhIIF5Yu.mjs.map +1 -0
- package/{logout-DUn8KSjX.mjs → logout-CA1No9_2.mjs} +4 -4
- package/logout-CA1No9_2.mjs.map +1 -0
- package/{logout-Bnk2hxfZ.mjs → logout-Dpqw8tQZ.mjs} +4 -4
- package/logout-Dpqw8tQZ.mjs.map +1 -0
- package/package-DgfSc9nY.mjs +6 -0
- package/package-DgfSc9nY.mjs.map +1 -0
- package/package.json +3 -3
- package/pair-BC8a_KYX.mjs +15 -0
- package/pair-BC8a_KYX.mjs.map +1 -0
- package/{providers-GEdlDJHp.mjs → providers--giKGohM.mjs} +4 -4
- package/providers--giKGohM.mjs.map +1 -0
- package/reconnect-I9-Do_DK.mjs +2 -0
- package/{refresh-DGJW3rSp.mjs → refresh-BIH3qn5A.mjs} +4 -4
- package/refresh-BIH3qn5A.mjs.map +1 -0
- package/{refresh-93t2pSpb.mjs → refresh-Dg8WvRcq.mjs} +4 -4
- package/refresh-Dg8WvRcq.mjs.map +1 -0
- package/{identity-LhURGrcS.mjs → registration-C6yiv31r.mjs} +27 -25
- package/registration-C6yiv31r.mjs.map +1 -0
- package/relay-CLPWErNw.mjs +319 -0
- package/relay-CLPWErNw.mjs.map +1 -0
- package/{relink-Djy5t7D2.mjs → relink-D8Koos_q.mjs} +9 -7
- package/relink-D8Koos_q.mjs.map +1 -0
- package/{reload-Dm464rPC.mjs → reload-C5-B0s9x.mjs} +6 -5
- package/{reload-Dm464rPC.mjs.map → reload-C5-B0s9x.mjs.map} +1 -1
- package/{remove-DBT19X2j.mjs → remove-6m5n17il.mjs} +4 -4
- package/remove-6m5n17il.mjs.map +1 -0
- package/{remove-f7C_vEOD.mjs → remove-VZO51J2m.mjs} +5 -5
- package/remove-VZO51J2m.mjs.map +1 -0
- package/{restart-DXMDjblc.mjs → restart-4NoPj76N.mjs} +5 -4
- package/restart-4NoPj76N.mjs.map +1 -0
- package/revoke-Gu5N3Vzy.mjs +13 -0
- package/revoke-Gu5N3Vzy.mjs.map +1 -0
- package/{run-CTFksYXE.mjs → run-RHrJN2Pv.mjs} +12 -14
- package/run-RHrJN2Pv.mjs.map +1 -0
- package/{runtime-CK2CunDw.mjs → runtime-CtLWuLd-.mjs} +48 -12
- package/runtime-CtLWuLd-.mjs.map +1 -0
- package/{serve-BntJRQed.mjs → serve-BZ5FAU3h.mjs} +586 -64
- package/serve-BZ5FAU3h.mjs.map +1 -0
- package/service-CRnqz89w.mjs +79 -0
- package/service-CRnqz89w.mjs.map +1 -0
- package/{settings-DasbTMFs.mjs → settings-DU140UBM.mjs} +3 -3
- package/settings-DU140UBM.mjs.map +1 -0
- package/{shared-CDyNsYBy.mjs → shared-CC4WukJX.mjs} +4 -4
- package/shared-CC4WukJX.mjs.map +1 -0
- package/{shared-CiSbTY59.mjs → shared-Dzwbs5Lk.mjs} +7 -9
- package/shared-Dzwbs5Lk.mjs.map +1 -0
- package/{start-CTYwK1Z4.mjs → start-COhahq2E.mjs} +5 -4
- package/start-COhahq2E.mjs.map +1 -0
- package/{status-CPKssQFk.mjs → status-Cau7bzuQ.mjs} +5 -4
- package/status-Cau7bzuQ.mjs.map +1 -0
- package/{status-CHcJyF_7.mjs → status-DJJOuCzL.mjs} +4 -4
- package/status-DJJOuCzL.mjs.map +1 -0
- package/{stop-CpQr3fUv.mjs → stop-CC--mxXp.mjs} +5 -4
- package/stop-CC--mxXp.mjs.map +1 -0
- package/{update-C3llbIB0.mjs → update-DMQLgDm3.mjs} +4 -4
- package/update-DMQLgDm3.mjs.map +1 -0
- package/acp-DodCRypZ.mjs.map +0 -1
- package/add-31QB-o0_.mjs.map +0 -1
- package/add-Dgy0iTEQ.mjs.map +0 -1
- package/check-BoANDJxT.mjs.map +0 -1
- package/control-CQxWGS4k.mjs.map +0 -1
- package/disconnect-BiLuV4JZ.mjs +0 -2
- package/error-CPyvkO4x.mjs.map +0 -1
- package/fork-CjZteIbk.mjs.map +0 -1
- package/identity-LhURGrcS.mjs.map +0 -1
- package/install-BUfEBtrj.mjs.map +0 -1
- package/jsonc-Ca0uQLm-.mjs +0 -58
- package/jsonc-Ca0uQLm-.mjs.map +0 -1
- package/link-ZuzWj9qt.mjs.map +0 -1
- package/list-6QTwXTKO.mjs.map +0 -1
- package/list-BnIIcMI3.mjs.map +0 -1
- package/list-DDuzyNv0.mjs.map +0 -1
- package/list-DPbF2uMB.mjs.map +0 -1
- package/login-BtuROCPJ.mjs.map +0 -1
- package/login-CGXU21AK.mjs.map +0 -1
- package/logout-Bnk2hxfZ.mjs.map +0 -1
- package/logout-DUn8KSjX.mjs.map +0 -1
- package/package-C5s94xPy.mjs +0 -6
- package/package-C5s94xPy.mjs.map +0 -1
- package/providers-GEdlDJHp.mjs.map +0 -1
- package/reconnect-ChE5ETwx.mjs +0 -2
- package/refresh-93t2pSpb.mjs.map +0 -1
- package/refresh-DGJW3rSp.mjs.map +0 -1
- package/relink-Djy5t7D2.mjs.map +0 -1
- package/remove-DBT19X2j.mjs.map +0 -1
- package/remove-f7C_vEOD.mjs.map +0 -1
- package/restart-DXMDjblc.mjs.map +0 -1
- package/run-CTFksYXE.mjs.map +0 -1
- package/runtime-CK2CunDw.mjs.map +0 -1
- package/serve-BntJRQed.mjs.map +0 -1
- package/service-CjOS-xCw.mjs.map +0 -1
- package/settings-DasbTMFs.mjs.map +0 -1
- package/shared-CDyNsYBy.mjs.map +0 -1
- package/shared-CiSbTY59.mjs.map +0 -1
- package/start-CTYwK1Z4.mjs.map +0 -1
- package/status-CHcJyF_7.mjs.map +0 -1
- package/status-CPKssQFk.mjs.map +0 -1
- package/stop-CpQr3fUv.mjs.map +0 -1
- package/thread-I6vNdC0y.mjs.map +0 -1
- package/update-C3llbIB0.mjs.map +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { a as reportFailure, m as writeOut } from "./error-ippxl2z7.mjs";
|
|
2
|
+
import { i as Cmd, t as handler } from "./runtime-CtLWuLd-.mjs";
|
|
3
|
+
import { r as options } from "./service-CRnqz89w.mjs";
|
|
4
|
+
import { n as ensure, r as stop } from "./discovery-D07MPnKd.mjs";
|
|
4
5
|
import { Effect } from "effect";
|
|
5
6
|
//#region src/cli/cmd/handlers/service/restart.ts
|
|
6
7
|
var restart_default = handler(Cmd.commands.service.commands.restart, Effect.fn("CLI.service.restart")(function* ({ host, port }) {
|
|
@@ -18,4 +19,4 @@ var restart_default = handler(Cmd.commands.service.commands.restart, Effect.fn("
|
|
|
18
19
|
//#endregion
|
|
19
20
|
export { restart_default as default };
|
|
20
21
|
|
|
21
|
-
//# sourceMappingURL=restart-
|
|
22
|
+
//# sourceMappingURL=restart-4NoPj76N.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"restart-4NoPj76N.mjs","names":["Runtime.handler","options","Service.options","Discovery.stop","Discovery.ensure"],"sources":["../../src/cli/cmd/handlers/service/restart.ts"],"sourcesContent":["import { Effect } from \"effect\";\nimport * as Runtime from \"../../../../framework/runtime.ts\";\nimport * as Discovery from \"../../../../server/discovery.ts\";\nimport { reportFailure } from \"../../../error.ts\";\nimport { writeOut } from \"../../../output.ts\";\nimport * as Service from \"../../../service.ts\";\nimport { Cmd } from \"../../cmd.ts\";\n\nexport default Runtime.handler(\n\tCmd.commands.service.commands.restart,\n\tEffect.fn(\"CLI.service.restart\")(function* ({ host, port }) {\n\t\tconst options = yield* Service.options(yield* Cmd.spec, { host, port });\n\t\tyield* Discovery.stop(options.home);\n\t\tconst server = yield* Discovery.ensure({ ...options, replace: true });\n\t\tyield* writeOut(`${server.url}\\n`);\n\t}, Effect.catch(reportFailure)),\n);\n"],"mappings":";;;;;;AAQA,IAAA,kBAAeA,QACd,IAAI,SAAS,QAAQ,SAAS,SAC9B,OAAO,GAAG,qBAAqB,CAAC,CAAC,WAAW,EAAE,MAAM,QAAQ;CAC3D,MAAMC,YAAU,OAAOC,QAAgB,OAAO,IAAI,MAAM;EAAE;EAAM;CAAK,CAAC;CACtE,OAAOC,KAAeF,UAAQ,IAAI;CAClC,MAAM,SAAS,OAAOG,OAAiB;EAAE,GAAGH;EAAS,SAAS;CAAK,CAAC;CACpE,OAAO,SAAS,GAAG,OAAO,IAAI,GAAG;AAClC,GAAG,OAAO,MAAM,aAAa,CAAC,CAC/B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { a as reportFailure, g as make, t as InvalidInputError } from "./error-ippxl2z7.mjs";
|
|
2
|
+
import { i as Cmd, t as handler } from "./runtime-CtLWuLd-.mjs";
|
|
3
|
+
import { t as connect } from "./service-CRnqz89w.mjs";
|
|
4
|
+
import { Effect } from "effect";
|
|
5
|
+
//#region src/cli/cmd/handlers/service/revoke.ts
|
|
6
|
+
var revoke_default = handler(Cmd.commands.service.commands.revoke, Effect.fn("CLI.service.revoke")(function* ({ id }) {
|
|
7
|
+
const { applied } = yield* Effect.flatMap(make, (rpc) => rpc["device.revoke"]({ id })).pipe(connect());
|
|
8
|
+
if (!applied) return yield* new InvalidInputError({ message: `no paired device ${id}` });
|
|
9
|
+
}, Effect.catch(reportFailure)));
|
|
10
|
+
//#endregion
|
|
11
|
+
export { revoke_default as default };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=revoke-Gu5N3Vzy.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revoke-Gu5N3Vzy.mjs","names":["Runtime.handler","Client.make","Service.connect"],"sources":["../../src/cli/cmd/handlers/service/revoke.ts"],"sourcesContent":["import { Effect } from \"effect\";\nimport * as Runtime from \"../../../../framework/runtime.ts\";\nimport * as Client from \"../../../../server/client.ts\";\nimport { InvalidInputError, reportFailure } from \"../../../error.ts\";\nimport * as Service from \"../../../service.ts\";\nimport { Cmd } from \"../../cmd.ts\";\n\nexport default Runtime.handler(\n\tCmd.commands.service.commands.revoke,\n\tEffect.fn(\"CLI.service.revoke\")(function* ({ id }) {\n\t\tconst { applied } = yield* Effect.flatMap(Client.make, (rpc) => rpc[\"device.revoke\"]({ id })).pipe(\n\t\t\tService.connect(),\n\t\t);\n\t\tif (!applied) return yield* new InvalidInputError({ message: `no paired device ${id}` });\n\t}, Effect.catch(reportFailure)),\n);\n"],"mappings":";;;;;AAOA,IAAA,iBAAeA,QACd,IAAI,SAAS,QAAQ,SAAS,QAC9B,OAAO,GAAG,oBAAoB,CAAC,CAAC,WAAW,EAAE,MAAM;CAClD,MAAM,EAAE,YAAY,OAAO,OAAO,QAAQC,OAAc,QAAQ,IAAI,gBAAgB,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,KAC7FC,QAAgB,CACjB;CACA,IAAI,CAAC,SAAS,OAAO,OAAO,IAAI,kBAAkB,EAAE,SAAS,oBAAoB,KAAK,CAAC;AACxF,GAAG,OAAO,MAAM,aAAa,CAAC,CAC/B"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { i as
|
|
2
|
-
import {
|
|
1
|
+
import { _ as run, c as header, d as usage, f as writeError, g as make, i as renderError, m as writeOut, o as addUsage, s as emptyUsage, t as InvalidInputError, u as terminalColumns } from "./error-ippxl2z7.mjs";
|
|
2
|
+
import { i as Cmd, t as handler } from "./runtime-CtLWuLd-.mjs";
|
|
3
3
|
import { t as harnessOptions } from "./harness-6d8TlAVk.mjs";
|
|
4
|
-
import { t as
|
|
4
|
+
import { t as connect } from "./service-CRnqz89w.mjs";
|
|
5
|
+
import { n as threadFlag, t as sessionId } from "./ids-cNIRx0-c.mjs";
|
|
5
6
|
import { Effect, Exit, Fiber, Logger, Option, Queue, Ref, Schema, Stream } from "effect";
|
|
6
7
|
import { EventList, Harness, Sandbox, Session } from "@codeworksh/harness/effect";
|
|
7
8
|
//#region src/cli/cmd/handlers/run.ts
|
|
@@ -60,13 +61,10 @@ var run_default = handler(Cmd.commands.run, Effect.fn("CLI.run", { level: "Info"
|
|
|
60
61
|
if (Option.isSome(session) && (Option.isSome(cwd) || Option.isSome(sandboxDriver) || Option.isSome(sandboxProviderId) || Option.isSome(sandboxId))) return yield* new InvalidInputError({ message: "--cwd, --sandbox-driver, --sandbox-id, and --sandbox-provider-id can only be used when creating a new session" });
|
|
61
62
|
if (Option.isSome(thread) && Option.isNone(session)) return yield* new InvalidInputError({ message: "--thread continues a thread of --session" });
|
|
62
63
|
const threadId = yield* threadFlag(thread);
|
|
64
|
+
const id = Option.isSome(session) ? yield* sessionId(session.value) : void 0;
|
|
63
65
|
if (Option.isSome(provider) !== Option.isSome(model)) return yield* new InvalidInputError({ message: "--provider and --model must be provided together" });
|
|
64
66
|
if (Option.isSome(sandboxProviderId) && Option.isNone(sandboxDriver)) return yield* new InvalidInputError({ message: "--sandbox-provider-id requires a remote --sandbox-driver" });
|
|
65
|
-
if (Option.isSome(server) && [
|
|
66
|
-
shared.home,
|
|
67
|
-
shared.database,
|
|
68
|
-
shared.userConfigDir
|
|
69
|
-
].some(Option.isSome)) return yield* new InvalidInputError({ message: "--home, --database, and --user-config-dir belong on codework serve when using --server" });
|
|
67
|
+
if (Option.isSome(server) && [shared.database, shared.userConfigDir].some(Option.isSome)) return yield* new InvalidInputError({ message: "--database and --user-config-dir belong on codework serve when using --server" });
|
|
70
68
|
if (Option.isSome(sandboxId) && (Option.isSome(sandboxDriver) || Option.isSome(sandboxProviderId))) return yield* new InvalidInputError({ message: "--sandbox-id cannot be combined with --sandbox-driver or --sandbox-provider-id" });
|
|
71
69
|
const selection = Option.isSome(sandboxId) ? { id: Sandbox.SandboxInstance.ID.make(sandboxId.value) } : {
|
|
72
70
|
driver: Option.getOrElse(sandboxDriver, () => "local"),
|
|
@@ -82,8 +80,8 @@ var run_default = handler(Cmd.commands.run, Effect.fn("CLI.run", { level: "Info"
|
|
|
82
80
|
};
|
|
83
81
|
const remote = Effect.gen(function* () {
|
|
84
82
|
const rpc = yield* make;
|
|
85
|
-
const info =
|
|
86
|
-
sessionId:
|
|
83
|
+
const info = id !== void 0 ? yield* rpc["thread.configure"]({
|
|
84
|
+
sessionId: id,
|
|
87
85
|
...threadId === void 0 ? {} : { threadId },
|
|
88
86
|
runtime
|
|
89
87
|
}) : yield* rpc["session.create"]({
|
|
@@ -113,8 +111,8 @@ var run_default = handler(Cmd.commands.run, Effect.fn("CLI.run", { level: "Info"
|
|
|
113
111
|
});
|
|
114
112
|
const program = Effect.gen(function* () {
|
|
115
113
|
let handle;
|
|
116
|
-
if (
|
|
117
|
-
sessionId:
|
|
114
|
+
if (id !== void 0) handle = yield* Session.attach({
|
|
115
|
+
sessionId: id,
|
|
118
116
|
...threadId === void 0 ? {} : { threadId },
|
|
119
117
|
...runtime
|
|
120
118
|
});
|
|
@@ -150,7 +148,7 @@ var run_default = handler(Cmd.commands.run, Effect.fn("CLI.run", { level: "Info"
|
|
|
150
148
|
yield* finish(renderState, columns);
|
|
151
149
|
});
|
|
152
150
|
return yield* Effect.gen(function* () {
|
|
153
|
-
if (Option.isSome(server)) return yield* remote.pipe(
|
|
151
|
+
if (Option.isSome(server)) return yield* remote.pipe(connect(server.value));
|
|
154
152
|
return yield* program.pipe(Effect.scoped, Effect.provide(Harness.layer(harnessOptions(shared))), Effect.provideService(Logger.LogToStderr, true));
|
|
155
153
|
}).pipe(Effect.catch((error) => writeError(renderError(error)).pipe(Effect.andThen(Effect.sync(() => {
|
|
156
154
|
process.exitCode = 1;
|
|
@@ -159,4 +157,4 @@ var run_default = handler(Cmd.commands.run, Effect.fn("CLI.run", { level: "Info"
|
|
|
159
157
|
//#endregion
|
|
160
158
|
export { run_default as default };
|
|
161
159
|
|
|
162
|
-
//# sourceMappingURL=run-
|
|
160
|
+
//# sourceMappingURL=run-RHrJN2Pv.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-RHrJN2Pv.mjs","names":["Runtime.handler","Client.make","Client.run","Service.connect"],"sources":["../../src/cli/cmd/handlers/run.ts"],"sourcesContent":["import { EventList, type EventSchema, Harness, Sandbox, Session } from \"@codeworksh/harness/effect\";\nimport { Effect, Exit, Fiber, Logger, Option, Queue, Ref, Schema, Stream } from \"effect\";\nimport * as Runtime from \"../../../framework/runtime.ts\";\nimport * as Client from \"../../../server/client.ts\";\nimport * as Service from \"../../service.ts\";\nimport { InvalidInputError, renderError } from \"../../error.ts\";\nimport { harnessOptions } from \"../../harness.ts\";\nimport {\n\taddUsage,\n\temptyUsage,\n\theader,\n\tterminalColumns,\n\tusage,\n\ttype UsageSummary,\n\twriteError,\n\twriteOut,\n} from \"../../output.ts\";\nimport { sessionId, threadFlag } from \"../../ids.ts\";\nimport { Cmd } from \"../cmd.ts\";\n\ninterface RenderState {\n\treadonly usage: UsageSummary;\n\treadonly textSeen: boolean;\n\treadonly textEndsWithNewline: boolean;\n\treadonly reason?: EventList.LLMEnded[\"data\"][\"reason\"];\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 = (state: Ref.Ref<RenderState>, ended?: Queue.Queue<string>) =>\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) => ({\n\t\t\t\t...current,\n\t\t\t\tusage: addUsage(current.usage, event.data.message),\n\t\t\t\treason: event.data.reason,\n\t\t\t}));\n\t\t\treturn;\n\t\t}\n\t\tif (ended !== undefined && isTurnEnded(event)) {\n\t\t\tyield* Queue.offer(ended, event.data.messageId);\n\t\t}\n\t});\n\nconst finish = Effect.fn(\"CLI.finish\")(function* (state: Ref.Ref<RenderState>, columns: number) {\n\tconst rendered = yield* Ref.get(state);\n\tif (rendered.textSeen && !rendered.textEndsWithNewline) yield* writeOut(\"\\n\");\n\tyield* writeError(usage(rendered.usage, columns));\n\tif (rendered.reason === \"length\") {\n\t\tyield* writeError(\"Response was truncated: the model reached its output token limit.\\n\");\n\t\tyield* Effect.sync(() => {\n\t\t\tprocess.exitCode = 1;\n\t\t});\n\t}\n});\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\", { level: \"Info\" })(function* (input: Sandbox.Selection) {\n\tconst selection = yield* Sandbox.resolve(input);\n\tif (selection.created && selection.info !== undefined) {\n\t\tconst id = selection.info.id;\n\t\tyield* Effect.addFinalizer(() => Effect.ignore(Sandbox.stop(id)));\n\t}\n\treturn selection.info;\n});\n\nexport default Runtime.handler(\n\tCmd.commands.run,\n\tEffect.fn(\"CLI.run\", { level: \"Info\" })(function* ({\n\t\tprompt,\n\t\tsession,\n\t\tthread,\n\t\tcwd,\n\t\tsandboxDriver,\n\t\tsandboxProviderId,\n\t\tsandboxId,\n\t\tprovider,\n\t\tmodel,\n\t\tthinking,\n\t\tserver,\n\t}) {\n\t\tconst shared = yield* Cmd.spec;\n\t\tif (\n\t\t\tOption.isSome(session) &&\n\t\t\t(Option.isSome(cwd) ||\n\t\t\t\tOption.isSome(sandboxDriver) ||\n\t\t\t\tOption.isSome(sandboxProviderId) ||\n\t\t\t\tOption.isSome(sandboxId))\n\t\t) {\n\t\t\treturn yield* new InvalidInputError({\n\t\t\t\tmessage:\n\t\t\t\t\t\"--cwd, --sandbox-driver, --sandbox-id, 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(thread) && Option.isNone(session)) {\n\t\t\treturn yield* new InvalidInputError({ message: \"--thread continues a thread of --session\" });\n\t\t}\n\t\tconst threadId = yield* threadFlag(thread);\n\t\tconst id = Option.isSome(session) ? yield* sessionId(session.value) : undefined;\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(sandboxDriver)) {\n\t\t\treturn yield* new InvalidInputError({\n\t\t\t\tmessage: \"--sandbox-provider-id requires a remote --sandbox-driver\",\n\t\t\t});\n\t\t}\n\t\t// --home stays: it names the home whose token reaches the server.\n\t\tif (Option.isSome(server) && [shared.database, shared.userConfigDir].some(Option.isSome)) {\n\t\t\treturn yield* new InvalidInputError({\n\t\t\t\tmessage: \"--database and --user-config-dir belong on codework serve when using --server\",\n\t\t\t});\n\t\t}\n\n\t\tif (Option.isSome(sandboxId) && (Option.isSome(sandboxDriver) || Option.isSome(sandboxProviderId))) {\n\t\t\treturn yield* new InvalidInputError({\n\t\t\t\tmessage: \"--sandbox-id cannot be combined with --sandbox-driver or --sandbox-provider-id\",\n\t\t\t});\n\t\t}\n\t\tconst selection: Sandbox.Selection = Option.isSome(sandboxId)\n\t\t\t? { id: Sandbox.SandboxInstance.ID.make(sandboxId.value) }\n\t\t\t: {\n\t\t\t\t\tdriver: Option.getOrElse(sandboxDriver, () => \"local\"),\n\t\t\t\t\t...(Option.isNone(sandboxProviderId) ? {} : { providerResourceId: sandboxProviderId.value }),\n\t\t\t\t};\n\n\t\t// The session's host directory, with no flag to set it: a person running a command is always\n\t\t// somewhere, and that somewhere is what they mean by \"this project\". `--cwd` is a different\n\t\t// thing entirely -- where the work runs inside the session's space, which may be a sandbox\n\t\t// on another machine.\n\t\tconst hostDir = Session.AbsolutePath.make(process.cwd());\n\n\t\tconst runtime = {\n\t\t\t...(Option.isNone(provider) || Option.isNone(model)\n\t\t\t\t? {}\n\t\t\t\t: { model: { provider: provider.value, id: model.value } }),\n\t\t\t...(Option.isNone(thinking) ? {} : { thinkingLevel: thinking.value }),\n\t\t};\n\t\tconst remote = Effect.gen(function* () {\n\t\t\tconst rpc = yield* Client.make;\n\t\t\tconst info =\n\t\t\t\tid !== undefined\n\t\t\t\t\t? yield* rpc[\"thread.configure\"]({\n\t\t\t\t\t\t\tsessionId: id,\n\t\t\t\t\t\t\t...(threadId === undefined ? {} : { threadId }),\n\t\t\t\t\t\t\truntime,\n\t\t\t\t\t\t})\n\t\t\t\t\t: yield* rpc[\"session.create\"]({\n\t\t\t\t\t\t\truntime,\n\t\t\t\t\t\t\t...(Option.isNone(cwd) ? {} : { directory: cwd.value }),\n\t\t\t\t\t\t\thostDir,\n\t\t\t\t\t\t\tsandbox: selection,\n\t\t\t\t\t\t});\n\t\t\tconst state = yield* Ref.make(initialRenderState);\n\t\t\tconst columns = terminalColumns();\n\t\t\tyield* writeError(\n\t\t\t\theader({\n\t\t\t\t\tsessionId: info.session.id,\n\t\t\t\t\tsandbox: info.session.sandbox?.driver ?? \"local\",\n\t\t\t\t\tdirectory: info.placement?.directory ?? info.session.directory,\n\t\t\t\t\tcolumns,\n\t\t\t\t}),\n\t\t\t);\n\t\t\tif (info.session.sandbox !== undefined) yield* writeError(`sandbox-id: ${info.session.sandbox.id}\\n`);\n\t\t\tyield* Client.run(rpc, { sessionId: info.session.id, threadId: info.id, text: prompt }, render(state)).pipe(\n\t\t\t\tEffect.onInterrupt(() =>\n\t\t\t\t\trpc[\"thread.interrupt\"]({ sessionId: info.session.id, threadId: info.id }).pipe(\n\t\t\t\t\t\tEffect.timeout(\"5 seconds\"),\n\t\t\t\t\t\tEffect.ignore,\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t);\n\t\t\tyield* finish(state, columns);\n\t\t});\n\t\tconst program = Effect.gen(function* () {\n\t\t\tlet handle: Session.ThreadHandle;\n\t\t\tif (id !== undefined) {\n\t\t\t\thandle = yield* Session.attach({\n\t\t\t\t\tsessionId: id,\n\t\t\t\t\t...(threadId === undefined ? {} : { threadId }),\n\t\t\t\t\t...runtime,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tconst selected = yield* selectSandbox(selection);\n\t\t\t\tconst created = yield* Session.create({\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\thostDir,\n\t\t\t\t});\n\t\t\t\thandle = created.main;\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(renderState, ended)), 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.sessionId,\n\t\t\t\t\tsandbox: info.session.sandbox?.driver ?? \"local\",\n\t\t\t\t\tdirectory: info.placement?.directory ?? info.session.directory,\n\t\t\t\t\tcolumns,\n\t\t\t\t}),\n\t\t\t);\n\t\t\t// The local command joins execution to retain typed error details. Ctrl+C is the user stopping\n\t\t\t// the run, as on the remote path: named so, the next server start does not resume it.\n\t\t\tconst execution = yield* handle.prompt({ text: prompt, delivery: \"followUp\" }).pipe(\n\t\t\t\tEffect.andThen(handle.resume()),\n\t\t\t\tEffect.onInterrupt(() => handle.interrupt().pipe(Effect.timeout(\"5 seconds\"), Effect.ignore)),\n\t\t\t\tEffect.exit,\n\t\t\t);\n\t\t\tyield* handle.wait();\n\t\t\tif (Exit.isFailure(execution)) return yield* Effect.failCause(execution.cause);\n\t\t\tconst leaf = (yield* handle.history()).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* finish(renderState, columns);\n\t\t});\n\n\t\t// Scope inside the provided layer, so the run's finalizers (stopping a created sandbox) close\n\t\t// while the harness and its database are still open.\n\t\tconst execute = Effect.gen(function* () {\n\t\t\tif (Option.isSome(server)) return yield* remote.pipe(Service.connect(server.value));\n\t\t\t// Stdout carries only the response; harness logs go with the rest of the diagnostics.\n\t\t\treturn yield* program.pipe(\n\t\t\t\tEffect.scoped,\n\t\t\t\tEffect.provide(Harness.layer(harnessOptions(shared))),\n\t\t\t\tEffect.provideService(Logger.LogToStderr, true),\n\t\t\t);\n\t\t});\n\t\treturn yield* execute.pipe(\n\t\t\tEffect.catch((error) =>\n\t\t\t\twriteError(renderError(error)).pipe(\n\t\t\t\t\tEff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W;CACpB,CAAC,CACF,CACD,CACD,CACD;AACD,CAAC,CACF"}
|
|
@@ -41,7 +41,7 @@ const ServerAddress = {
|
|
|
41
41
|
}))), Flag.withDescription("Port the background server listens on"), Flag.withDefault(7433))
|
|
42
42
|
};
|
|
43
43
|
/** For commands that only talk to a server that is already running. */
|
|
44
|
-
const RunningServer = Flag.String("server").pipe(Flag.withDescription("RPC server URL (
|
|
44
|
+
const RunningServer = Flag.String("server").pipe(Flag.withDescription("RPC server URL (defaults to this home's server)"), Flag.optional);
|
|
45
45
|
/** A thread's MCP server in a running server: every thread sharing its instance is affected. */
|
|
46
46
|
const McpControlParams = {
|
|
47
47
|
name: Argument.String("name").pipe(Argument.withDescription("Server name in mcp.json")),
|
|
@@ -271,6 +271,28 @@ const Cmd = make("codework", {
|
|
|
271
271
|
}
|
|
272
272
|
]
|
|
273
273
|
}),
|
|
274
|
+
make("connect", {
|
|
275
|
+
description: "Connect this machine to a workspace",
|
|
276
|
+
params: {
|
|
277
|
+
workspace: Flag.String("workspace").pipe(Flag.withDescription("Workspace to connect to; otherwise the approver picks it"), Flag.optional),
|
|
278
|
+
machineId: Flag.String("machine-id").pipe(Flag.withDescription("Set this home's machine id instead of generating one, e.g. build-box-1"), Flag.optional)
|
|
279
|
+
},
|
|
280
|
+
examples: [{
|
|
281
|
+
command: "codework connect",
|
|
282
|
+
description: "Show a code to approve in the CodeWork app"
|
|
283
|
+
}, {
|
|
284
|
+
command: "codework connect --machine-id build-box-1",
|
|
285
|
+
description: "Connect with a fixed id, replacing a rebuilt machine's old link"
|
|
286
|
+
}]
|
|
287
|
+
}),
|
|
288
|
+
make("disconnect", {
|
|
289
|
+
description: "Disconnect this machine from a workspace",
|
|
290
|
+
params: { workspace: Flag.String("workspace").pipe(Flag.withDescription("Workspace to leave; optional when only one is connected"), Flag.optional) },
|
|
291
|
+
examples: [{
|
|
292
|
+
command: "codework disconnect",
|
|
293
|
+
description: "Leave the only connected workspace"
|
|
294
|
+
}]
|
|
295
|
+
}),
|
|
274
296
|
make("serve", {
|
|
275
297
|
description: "Start the CodeWork RPC server",
|
|
276
298
|
params: {
|
|
@@ -279,15 +301,23 @@ const Cmd = make("codework", {
|
|
|
279
301
|
minimum: 0,
|
|
280
302
|
maximum: 65535
|
|
281
303
|
}))), Flag.withDescription("Port to listen on (0 for an ephemeral port)"), Flag.withDefault(7433)),
|
|
282
|
-
service: Flag.Boolean("service").pipe(Flag.withDescription("Run as the background server `codework service` manages, logging to <home>/log/server.log"), Flag.withDefault(false))
|
|
304
|
+
service: Flag.Boolean("service").pipe(Flag.withDescription("Run as the background server `codework service` manages, logging to <home>/log/server.log"), Flag.withDefault(false)),
|
|
305
|
+
trustedProxy: Flag.String("trusted-proxy").pipe(Flag.withDescription("Address or CIDR range of a TLS proxy in front of the server, repeatable or comma-separated (default: CODEWORK_TRUSTED_PROXY, then server.trustedProxy in user settings)"), Flag.atLeast(0))
|
|
283
306
|
},
|
|
284
|
-
examples: [
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
307
|
+
examples: [
|
|
308
|
+
{
|
|
309
|
+
command: "codework serve",
|
|
310
|
+
description: "Start the RPC server on 127.0.0.1:7433"
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
command: "codework serve --port 0",
|
|
314
|
+
description: "Choose an available local port"
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
command: "codework serve --host 0.0.0.0 --trusted-proxy 10.0.0.0/8",
|
|
318
|
+
description: "Believe X-Forwarded-Proto from a proxy in 10.0.0.0/8"
|
|
319
|
+
}
|
|
320
|
+
]
|
|
291
321
|
}),
|
|
292
322
|
make("service", {
|
|
293
323
|
description: "Manage the background server",
|
|
@@ -301,7 +331,13 @@ const Cmd = make("codework", {
|
|
|
301
331
|
params: ServerAddress
|
|
302
332
|
}),
|
|
303
333
|
make("status", { description: "Show background server status" }),
|
|
304
|
-
make("stop", { description: "Stop the background server" })
|
|
334
|
+
make("stop", { description: "Stop the background server" }),
|
|
335
|
+
make("pair", { description: "Print a one-time code another computer pairs with, valid 10 minutes" }),
|
|
336
|
+
make("devices", { description: "List paired devices" }),
|
|
337
|
+
make("revoke", {
|
|
338
|
+
description: "Unpair a device and end its connections",
|
|
339
|
+
params: { id: Argument.String("device-id").pipe(Argument.withDescription("The device to unpair")) }
|
|
340
|
+
})
|
|
305
341
|
]
|
|
306
342
|
}),
|
|
307
343
|
make("session", {
|
|
@@ -598,7 +634,7 @@ function run(root, handlers, options) {
|
|
|
598
634
|
function provide(node, handlers, context) {
|
|
599
635
|
const found = handlers.find((entry) => entry.spec === node.spec);
|
|
600
636
|
const command = context.path.length === 0 ? node.name : context.path.join(" ");
|
|
601
|
-
const spec = found ? node.spec.pipe(Command.withHandler((input) => Effect.promise(found.load).pipe(Effect.flatMap((module) => module.default(input)), Effect.provide(layer({
|
|
637
|
+
const spec = found ? node.spec.pipe(Command.withHandler((input) => Effect.promise(found.load).pipe(Effect.flatMap((module) => module.default(input)), Effect.catch((error) => Effect.promise(() => import("./error-ippxl2z7.mjs").then((n) => n.r)).pipe(Effect.flatMap((module) => module.reportFailure(error)))), Effect.provide(layer({
|
|
602
638
|
version: context.version,
|
|
603
639
|
command
|
|
604
640
|
}))))) : node.spec;
|
|
@@ -612,4 +648,4 @@ function provide(node, handlers, context) {
|
|
|
612
648
|
//#endregion
|
|
613
649
|
export { Cmd as i, handlers as n, run as r, handler as t };
|
|
614
650
|
|
|
615
|
-
//# sourceMappingURL=runtime-
|
|
651
|
+
//# sourceMappingURL=runtime-CtLWuLd-.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-CtLWuLd-.mjs","names":["Spec.make","Otel.layer"],"sources":["../../src/framework/spec.ts","../../src/cli/cmd/cmd.ts","../../src/framework/otel.ts","../../src/framework/runtime.ts"],"sourcesContent":["import { Command } from \"effect/cli\";\n\n/**\n * A declarative command tree. Specs carry only the shape of a command -- its\n * name, parameters, description, and children -- so the whole CLI surface can\n * be read in one file. Handlers are attached separately by {@link Runtime}, which\n * keeps their imports (and the harness they pull in) off the startup path.\n */\n\nexport interface Example {\n\treadonly command: string;\n\treadonly description: string;\n}\n\ninterface Options<\n\tConfig extends Command.Command.Config,\n\tShared extends Command.Command.FlagConfig,\n\tCommands extends ReadonlyArray<Any>,\n> {\n\treadonly description?: string;\n\treadonly params?: Config;\n\t/** Flags declared here are also parsed by every descendant command. */\n\treadonly shared?: Shared;\n\treadonly examples?: ReadonlyArray<Example>;\n\treadonly commands?: Commands;\n}\n\nexport interface Node<\n\tName extends string,\n\t// The tree is heterogeneous, so a node has to accept any command shape here.\n\t// Concrete types are recovered per-command through `Runtime.Input`.\n\t// biome-ignore lint/suspicious/noExplicitAny: heterogeneous command tree\n\tSpec extends Command.Command<Name, any, any, any, any>,\n\tCommands extends Children,\n> {\n\treadonly name: Name;\n\treadonly spec: Spec;\n\treadonly commands: Commands;\n}\n\n// The command name is invariant on `Command`, so the erased node type has to\n// admit any name for concrete nodes to be assignable to it.\n// biome-ignore lint/suspicious/noExplicitAny: heterogeneous command tree\nexport type Any = Node<string, Command.Command<any, any, any, any, any>, Children>;\nexport type Children = Readonly<Record<string, Any>>;\n\ntype ChildrenOf<Commands extends ReadonlyArray<Any>> = {\n\treadonly [Node in Commands[number] as Node[\"name\"]]: Node;\n};\n\nexport function make<\n\tconst Name extends string,\n\tconst Config extends Command.Command.Config = {},\n\tconst Shared extends Command.Command.FlagConfig = {},\n\tconst Commands extends ReadonlyArray<Any> = [],\n>(name: Name, options: Options<Config, Shared, Commands> = {}) {\n\tlet spec = Command.make(name, options.params ?? ({} as Config)).pipe(\n\t\tCommand.withSharedFlags(options.shared ?? ({} as Shared)),\n\t);\n\tif (options.description !== undefined) spec = spec.pipe(Command.withDescription(options.description));\n\tif (options.examples !== undefined) spec = spec.pipe(Command.withExamples(options.examples));\n\treturn {\n\t\tname,\n\t\tspec,\n\t\tcommands: Object.fromEntries(\n\t\t\t(options.commands ?? []).map((command) => [command.name, command]),\n\t\t) as ChildrenOf<Commands>,\n\t};\n}\n","import { Model } from \"@codeworksh/aikit\";\nimport { Schema } from \"effect\";\nimport { Argument, Flag } from \"effect/cli\";\nimport * as Spec from \"../../framework/spec.ts\";\n\n/**\n * The full command surface of the `codework` CLI. Declarations only -- each\n * command's behaviour lives in `./handlers`, wired up in `src/index.ts`.\n */\n\nconst thinkingLevels = Object.values(Model.ThinkingLevelEnum);\n\n/**\n * Every `auth` subcommand answers the same three questions: which provider,\n * whose credentials, and where they live. Only `login` needs anything more.\n */\nconst AuthParams = {\n\topenaiCodex: Flag.Boolean(\"openai-codex\").pipe(\n\t\tFlag.withDescription(\"Use OpenAI Codex OAuth\"),\n\t\tFlag.withDefault(false),\n\t),\n\tgithubCopilot: Flag.Boolean(\"github-copilot\").pipe(\n\t\tFlag.withDescription(\"Use GitHub Copilot OAuth (device flow)\"),\n\t\tFlag.withDefault(false),\n\t),\n\tserver: Flag.String(\"server\").pipe(Flag.withDescription(\"RPC server URL (ws://host:port/rpc/v1)\"), Flag.optional),\n\tauthFile: Flag.String(\"auth-file\").pipe(\n\t\tFlag.withDescription(\"Credential file (defaults to <home>/aikit/auth.json)\"),\n\t\tFlag.optional,\n\t),\n};\n\n/** Where the background server binds when `service` has to start one. */\nconst ServerAddress = {\n\thost: Flag.String(\"host\").pipe(\n\t\tFlag.withDescription(\"Host interface the background server binds\"),\n\t\tFlag.withDefault(\"127.0.0.1\"),\n\t),\n\tport: Flag.Int(\"port\").pipe(\n\t\tFlag.withSchema(Schema.Int.check(Schema.isBetween({ minimum: 0, maximum: 65535 }))),\n\t\tFlag.withDescription(\"Port the background server listens on\"),\n\t\tFlag.withDefault(7433),\n\t),\n};\n\n/** For commands that only talk to a server that is already running. */\nconst RunningServer = Flag.String(\"server\").pipe(\n\tFlag.withDescription(\"RPC server URL (defaults to this home's server)\"),\n\tFlag.optional,\n);\n\n/** A thread's MCP server in a running server: every thread sharing its instance is affected. */\nconst McpControlParams = {\n\tname: Argument.String(\"name\").pipe(Argument.withDescription(\"Server name in mcp.json\")),\n\tsession: Flag.String(\"session\").pipe(Flag.withAlias(\"s\"), Flag.withDescription(\"The session\")),\n\tthread: Flag.String(\"thread\").pipe(\n\t\tFlag.withDescription(\"Thread of --session whose server it is: a thread ID, or main (default)\"),\n\t\tFlag.optional,\n\t),\n\tserver: RunningServer,\n};\n\nconst JsonFlag = Flag.Boolean(\"json\").pipe(\n\tFlag.withDescription(\"Print machine-readable output\"),\n\tFlag.withDefault(false),\n);\n\nexport const Cmd = Spec.make(\"codework\", {\n\tdescription: \"CodeWork Command Line Interface\",\n\tshared: {\n\t\tuserConfigDir: Flag.String(\"user-config-dir\").pipe(\n\t\t\tFlag.withDescription(\"Directory whose settings.jsonc replaces the user settings in --home\"),\n\t\t\tFlag.optional,\n\t\t),\n\t\thome: Flag.String(\"home\").pipe(\n\t\t\tFlag.withDescription(\"CodeWork home: user settings, credentials, cache and data (default: ~/.codework)\"),\n\t\t\tFlag.optional,\n\t\t),\n\t\tdatabase: Flag.String(\"database\").pipe(Flag.withDescription(\"SQLite database path or :memory:\"), Flag.optional),\n\t},\n\tcommands: [\n\t\tSpec.make(\"auth\", {\n\t\t\tdescription: \"Manage OAuth credentials\",\n\t\t\tcommands: [\n\t\t\t\tSpec.make(\"login\", {\n\t\t\t\t\tdescription: \"Sign in to a provider\",\n\t\t\t\t\tparams: {\n\t\t\t\t\t\t...AuthParams,\n\t\t\t\t\t\tbrowser: Flag.Boolean(\"browser\").pipe(\n\t\t\t\t\t\t\tFlag.withDescription(\"Open the authorization URL in the default browser\"),\n\t\t\t\t\t\t\tFlag.withDefault(true),\n\t\t\t\t\t\t),\n\t\t\t\t\t\tdevice: Flag.Boolean(\"device\").pipe(\n\t\t\t\t\t\t\tFlag.withDescription(\"Use the device-code flow instead of a localhost browser callback\"),\n\t\t\t\t\t\t\tFlag.withDefault(false),\n\t\t\t\t\t\t),\n\t\t\t\t\t\tenterprise: Flag.String(\"enterprise\").pipe(\n\t\t\t\t\t\t\tFlag.withDescription(\"GitHub Enterprise domain for GitHub Copilot login\"),\n\t\t\t\t\t\t\tFlag.optional,\n\t\t\t\t\t\t),\n\t\t\t\t\t\tenableModels: Flag.Boolean(\"enable-models\").pipe(\n\t\t\t\t\t\t\tFlag.withDescription(\"Enable unconfigured Copilot catalog models after login\"),\n\t\t\t\t\t\t\tFlag.withDefault(false),\n\t\t\t\t\t\t),\n\t\t\t\t\t\tjson: JsonFlag,\n\t\t\t\t\t},\n\t\t\t\t\texamples: [\n\t\t\t\t\t\t{ command: \"codework auth login --openai-codex\", description: \"Sign in with ChatGPT\" },\n\t\t\t\t\t\t{ command: \"codework auth login --github-copilot\", description: \"Sign in with GitHub Copilot\" },\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcommand: \"codework auth login --openai-codex --device\",\n\t\t\t\t\t\t\tdescription: \"Sign in with a device code, no local port\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcommand: \"codework auth login --openai-codex --server ws://127.0.0.1:7433/rpc/v1\",\n\t\t\t\t\t\t\tdescription: \"Sign in the running server\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}),\n\t\t\t\tSpec.make(\"status\", {\n\t\t\t\t\tdescription: \"Show a stored login without refreshing it\",\n\t\t\t\t\tparams: { ...AuthParams, json: JsonFlag },\n\t\t\t\t\texamples: [{ command: \"codework auth status --openai-codex\", description: \"Show the stored login\" }],\n\t\t\t\t}),\n\t\t\t\tSpec.make(\"refresh\", {\n\t\t\t\t\tdescription: \"Refresh a stored login if it has expired\",\n\t\t\t\t\tparams: { ...AuthParams, json: JsonFlag },\n\t\t\t\t\texamples: [{ command: \"codework auth refresh --openai-codex\", description: \"Renew an expired login\" }],\n\t\t\t\t}),\n\t\t\t\tSpec.make(\"logout\", {\n\t\t\t\t\tdescription: \"Clear a stored login\",\n\t\t\t\t\tparams: AuthParams,\n\t\t\t\t\texamples: [{ command: \"codework auth logout --github-copilot\", description: \"Clear the stored login\" }],\n\t\t\t\t}),\n\t\t\t],\n\t\t}),\n\t\tSpec.make(\"mcp\", {\n\t\t\tdescription: \"Manage MCP servers\",\n\t\t\tcommands: [\n\t\t\t\tSpec.make(\"add\", {\n\t\t\t\t\tdescription: \"Add or replace a server in mcp.json\",\n\t\t\t\t\tparams: {\n\t\t\t\t\t\tname: Argument.String(\"name\").pipe(Argument.withDescription(\"Server name\")),\n\t\t\t\t\t\tcommand: Argument.String(\"command\").pipe(\n\t\t\t\t\t\t\tArgument.withDescription(\"Command and arguments of a stdio server, after --\"),\n\t\t\t\t\t\t\tArgument.variadic({ min: 0 }),\n\t\t\t\t\t\t),\n\t\t\t\t\t\turl: Flag.String(\"url\").pipe(\n\t\t\t\t\t\t\tFlag.withDescription(\"Streamable HTTP server URL (instead of a command)\"),\n\t\t\t\t\t\t\tFlag.optional,\n\t\t\t\t\t\t),\n\t\t\t\t\t\tenv: Flag.KeyValuePair(\"env\").pipe(\n\t\t\t\t\t\t\tFlag.withDescription(\"Environment variable of a stdio server, as KEY=VALUE\"),\n\t\t\t\t\t\t\tFlag.optional,\n\t\t\t\t\t\t),\n\t\t\t\t\t\tcwd: Flag.String(\"cwd\").pipe(\n\t\t\t\t\t\t\tFlag.withDescription(\"Working directory of a stdio server\"),\n\t\t\t\t\t\t\tFlag.optional,\n\t\t\t\t\t\t),\n\t\t\t\t\t\theader: Flag.KeyValuePair(\"header\").pipe(\n\t\t\t\t\t\t\tFlag.withDescription(\"HTTP header, as KEY=VALUE\"),\n\t\t\t\t\t\t\tFlag.optional,\n\t\t\t\t\t\t),\n\t\t\t\t\t\tbearerTokenEnvVar: Flag.String(\"bearer-token-env-var\").pipe(\n\t\t\t\t\t\t\tFlag.withDescription('Send \"Authorization: Bearer ${NAME}\"'),\n\t\t\t\t\t\t\tFlag.optional,\n\t\t\t\t\t\t),\n\t\t\t\t\t\toauthClientId: Flag.String(\"oauth-client-id\").pipe(\n\t\t\t\t\t\t\tFlag.withDescription(\"Pre-registered OAuth client id\"),\n\t\t\t\t\t\t\tFlag.optional,\n\t\t\t\t\t\t),\n\t\t\t\t\t\toauthClientSecret: Flag.String(\"oauth-client-secret\").pipe(\n\t\t\t\t\t\t\tFlag.withDescription(\"OAuth client secret (may be ${NAME} or !command)\"),\n\t\t\t\t\t\t\tFlag.optional,\n\t\t\t\t\t\t),\n\t\t\t\t\t\toauthCallbackPort: Flag.Int(\"oauth-callback-port\").pipe(\n\t\t\t\t\t\t\tFlag.withSchema(Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 65535 }))),\n\t\t\t\t\t\t\tFlag.withDescription(\"Fixed OAuth callback port\"),\n\t\t\t\t\t\t\tFlag.optional,\n\t\t\t\t\t\t),\n\t\t\t\t\t\toauthClientName: Flag.String(\"oauth-client-name\").pipe(\n\t\t\t\t\t\t\tFlag.withDescription(\"Client name sent when registering with the OAuth server\"),\n\t\t\t\t\t\t\tFlag.optional,\n\t\t\t\t\t\t),\n\t\t\t\t\t\texposure: Flag.Literals(\"exposure\", [\"direct\", \"hidden\", \"codemode\", \"deferred\"]).pipe(\n\t\t\t\t\t\t\tFlag.withDescription(\"How the model reaches the server's tools (default: direct)\"),\n\t\t\t\t\t\t\tFlag.optional,\n\t\t\t\t\t\t),\n\t\t\t\t\t\tdescription: Flag.String(\"description\").pipe(\n\t\t\t\t\t\t\tFlag.withDescription(\"What the server offers\"),\n\t\t\t\t\t\t\tFlag.optional,\n\t\t\t\t\t\t),\n\t\t\t\t\t\tlocal: Flag.Boolean(\"local\").pipe(\n\t\t\t\t\t\t\tFlag.withAlias(\"l\"),\n\t\t\t\t\t\t\tFlag.withDescription(\"Write the project's .codework/mcp.json instead of the user one\"),\n\t\t\t\t\t\t\tFlag.withDefault(false),\n\t\t\t\t\t\t),\n\t\t\t\t\t},\n\t\t\t\t\texamples: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcommand: \"codework mcp add fs -- npx -y @modelcontextprotocol/server-filesystem .\",\n\t\t\t\t\t\t\tdescription: \"Add a stdio server\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcommand: \"codework mcp add linear --url https://mcp.linear.app/mcp\",\n\t\t\t\t\t\t\tdescription: \"Add an HTTP server; sign in with codework mcp login linear\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcommand: \"codework mcp add tools -l --url http://127.0.0.1:8080/mcp\",\n\t\t\t\t\t\t\tdescription: \"Add a server to this project only\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}),\n\t\t\t\tSpec.make(\"remove\", {\n\t\t\t\t\tdescription: \"Remove a server from mcp.json\",\n\t\t\t\t\tparams: {\n\t\t\t\t\t\tname: Argument.String(\"name\").pipe(Argument.withDescription(\"Server name in mcp.json\")),\n\t\t\t\t\t\tlocal: Flag.Boolean(\"local\").pipe(\n\t\t\t\t\t\t\tFlag.withAlias(\"l\"),\n\t\t\t\t\t\t\tFlag.withDescription(\"Remove it from the project's .codework/mcp.json instead of the user one\"),\n\t\t\t\t\t\t\tFlag.withDefault(false),\n\t\t\t\t\t\t),\n\t\t\t\t\t},\n\t\t\t\t\texamples: [{ command: \"codework mcp remove linear\", description: \"Remove the linear server\" }],\n\t\t\t\t}),\n\t\t\t\tSpec.make(\"list\", {\n\t\t\t\t\tdescription: \"Connect to every enabled server and show its state, tools and errors\",\n\t\t\t\t\tparams: { json: JsonFlag },\n\t\t\t\t\texamples: [\n\t\t\t\t\t\t{ command: \"codework mcp list\", description: \"Check every configured server; exits 1 on a failure\" },\n\t\t\t\t\t],\n\t\t\t\t}),\n\t\t\t\tSpec.make(\"login\", {\n\t\t\t\t\tdescription: \"Sign in to an MCP server with OAuth\",\n\t\t\t\t\tparams: {\n\t\t\t\t\t\tname: Argument.String(\"name\").pipe(Argument.withDescription(\"Server name in mcp.json\")),\n\t\t\t\t\t\tbrowser: Flag.Boolean(\"browser\").pipe(\n\t\t\t\t\t\t\tFlag.withDescription(\"Open the authorization URL in the default browser\"),\n\t\t\t\t\t\t\tFlag.withDefault(true),\n\t\t\t\t\t\t),\n\t\t\t\t\t\ttimeout: Flag.Int(\"timeout\").pipe(\n\t\t\t\t\t\t\tFlag.withSchema(Schema.Int.check(Schema.isGreaterThan(0))),\n\t\t\t\t\t\t\tFlag.withDescription(\"Seconds the whole sign-in may take\"),\n\t\t\t\t\t\t\tFlag.withDefault(300),\n\t\t\t\t\t\t),\n\t\t\t\t\t},\n\t\t\t\t\texamples: [\n\t\t\t\t\t\t{ command: \"codework mcp login linear\", description: \"Sign in to the linear server\" },\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcommand: \"codework mcp login linear --browser=false\",\n\t\t\t\t\t\t\tdescription: \"Print the URL; paste the redirected URL back if the browser is elsewhere\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}),\n\t\t\t\tSpec.make(\"logout\", {\n\t\t\t\t\tdescription: \"Remove the stored OAuth credentials of an MCP server\",\n\t\t\t\t\tparams: {\n\t\t\t\t\t\tname: Argument.String(\"name\").pipe(Argument.withDescription(\"Server name in mcp.json\")),\n\t\t\t\t\t},\n\t\t\t\t\texamples: [{ command: \"codework mcp logout linear\", description: \"Sign out of the linear server\" }],\n\t\t\t\t}),\n\t\t\t\tSpec.make(\"reconnect\", {\n\t\t\t\t\tdescription: \"Connect a thread's MCP server afresh in a running server\",\n\t\t\t\t\tparams: McpControlParams,\n\t\t\t\t\texamples: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcommand: \"codework mcp reconnect linear --session ses_01h9\",\n\t\t\t\t\t\t\tdescription: \"Restart the linear server the main thread uses; its tools return from the next turn\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcommand: \"codework mcp reconnect linear --session ses_01h9 --thread thr_01ja\",\n\t\t\t\t\t\t\tdescription: \"Restart the one a thread of the session uses\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}),\n\t\t\t\tSpec.make(\"disconnect\", {\n\t\t\t\t\tdescription: \"Close a thread's MCP server in a running server until it is reconnected\",\n\t\t\t\t\tparams: McpControlParams,\n\t\t\t\t\texamples: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcommand: \"codework mcp disconnect linear --session ses_01h9\",\n\t\t\t\t\t\t\tdescription: \"Close the linear server the main thread uses\",\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\tSpec.make(\"run\", {\n\t\t\tdescription: \"Start or continue an agent session\",\n\t\t\tparams: {\n\t\t\t\tserver: Flag.String(\"server\").pipe(\n\t\t\t\t\tFlag.withDescription(\"RPC server URL (ws://host:port/rpc/v1)\"),\n\t\t\t\t\tFlag.optional,\n\t\t\t\t),\n\t\t\t\tprompt: Argument.String(\"prompt\").pipe(Argument.withDescription(\"Prompt for the agent\")),\n\t\t\t\tsession: Flag.String(\"session\").pipe(\n\t\t\t\t\tFlag.withAlias(\"s\"),\n\t\t\t\t\tFlag.withDescription(\"Continue an existing session\"),\n\t\t\t\t\tFlag.optional,\n\t\t\t\t),\n\t\t\t\tthread: Flag.String(\"thread\").pipe(\n\t\t\t\t\tFlag.withDescription(\"Thread of --session to continue: a thread ID, or main (default)\"),\n\t\t\t\t\tFlag.optional,\n\t\t\t\t),\n\t\t\t\tcwd: Flag.String(\"cwd\").pipe(\n\t\t\t\t\tFlag.withAlias(\"C\"),\n\t\t\t\t\tFlag.withDescription(\"Working directory for a new session\"),\n\t\t\t\t\tFlag.optional,\n\t\t\t\t),\n\t\t\t\tsandboxDriver: Flag.String(\"sandbox-driver\").pipe(\n\t\t\t\t\tFlag.withDescription(\"Sandbox driver for a new session (default: local)\"),\n\t\t\t\t\tFlag.optional,\n\t\t\t\t),\n\t\t\t\tsandboxId: Flag.String(\"sandbox-id\").pipe(\n\t\t\t\t\tFlag.withDescription(\"Reuse an existing sandbox instance\"),\n\t\t\t\t\tFlag.optional,\n\t\t\t\t),\n\t\t\t\tsandboxProviderId: Flag.String(\"sandbox-provider-id\").pipe(\n\t\t\t\t\tFlag.withDescription(\"Provider ID of an existing remote sandbox\"),\n\t\t\t\t\tFlag.optional,\n\t\t\t\t),\n\t\t\t\tprovider: Flag.String(\"provider\").pipe(Flag.withDescription(\"Model catalog provider ID\"), Flag.optional),\n\t\t\t\tmodel: Flag.String(\"model\").pipe(Flag.withDescription(\"Model ID\"), Flag.optional),\n\t\t\t\tthinking: Flag.Literals(\"thinking\", thinkingLevels).pipe(\n\t\t\t\t\tFlag.withDescription(\"Reasoning effort the model uses before answering\"),\n\t\t\t\t\tFlag.optional,\n\t\t\t\t),\n\t\t\t},\n\t\t\texamples: [\n\t\t\t\t{ command: 'codework run \"Inspect the failing tests\"', description: \"Create a session\" },\n\t\t\t\t{\n\t\t\t\t\tcommand: 'codework run --provider openai --model gpt-5.5 --thinking high \"Inspect the failing tests\"',\n\t\t\t\t\tdescription: \"Create a session with an explicit model\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tcommand: 'codework run --sandbox-driver daytona \"Inspect the repository\"',\n\t\t\t\t\tdescription: \"Create a Daytona sandbox and session\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tcommand: 'codework run --sandbox-driver daytona --sandbox-provider-id <id> \"Inspect the repository\"',\n\t\t\t\t\tdescription: \"Use an existing remote sandbox\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tcommand: 'codework run --session <id> --provider openai --model gpt-5.6-luna \"Now fix them\"',\n\t\t\t\t\tdescription: \"Continue a session with explicit model bindings\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tcommand: 'codework run --session <id> --thread <thread-id> \"Try OAuth instead\"',\n\t\t\t\t\tdescription: \"Continue one of the session's threads\",\n\t\t\t\t},\n\t\t\t],\n\t\t}),\n\t\tSpec.make(\"connect\", {\n\t\t\tdescription: \"Connect this machine to a workspace\",\n\t\t\tparams: {\n\t\t\t\tworkspace: Flag.String(\"workspace\").pipe(\n\t\t\t\t\tFlag.withDescription(\"Workspace to connect to; otherwise the approver picks it\"),\n\t\t\t\t\tFlag.optional,\n\t\t\t\t),\n\t\t\t\tmachineId: Flag.String(\"machine-id\").pipe(\n\t\t\t\t\tFlag.withDescription(\"Set this home's machine id instead of generating one, e.g. build-box-1\"),\n\t\t\t\t\tFlag.optional,\n\t\t\t\t),\n\t\t\t},\n\t\t\texamples: [\n\t\t\t\t{ command: \"codework connect\", description: \"Show a code to approve in the CodeWork app\" },\n\t\t\t\t{\n\t\t\t\t\tcommand: \"codework connect --machine-id build-box-1\",\n\t\t\t\t\tdescription: \"Connect with a fixed id, replacing a rebuilt machine's old link\",\n\t\t\t\t},\n\t\t\t],\n\t\t}),\n\t\tSpec.make(\"disconnect\", {\n\t\t\tdescription: \"Disconnect this machine from a workspace\",\n\t\t\tparams: {\n\t\t\t\tworkspace: Flag.String(\"workspace\").pipe(\n\t\t\t\t\tFlag.withDescription(\"Workspace to leave; optional when only one is connected\"),\n\t\t\t\t\tFlag.optional,\n\t\t\t\t),\n\t\t\t},\n\t\t\texamples: [{ command: \"codework disconnect\", description: \"Leave the only connected workspace\" }],\n\t\t}),\n\t\tSpec.make(\"serve\", {\n\t\t\tdescription: \"Start the CodeWork RPC server\",\n\t\t\tparams: {\n\t\t\t\thost: Flag.String(\"host\").pipe(\n\t\t\t\t\tFlag.withDescription(\"Host interface to bind\"),\n\t\t\t\t\tFlag.withDefault(\"127.0.0.1\"),\n\t\t\t\t),\n\t\t\t\tport: Flag.Int(\"port\").pipe(\n\t\t\t\t\tFlag.withSchema(Schema.Int.check(Schema.isBetween({ minimum: 0, maximum: 65535 }))),\n\t\t\t\t\tFlag.withDescription(\"Port to listen on (0 for an ephemeral port)\"),\n\t\t\t\t\tFlag.withDefault(7433),\n\t\t\t\t),\n\t\t\t\tservice: Flag.Boolean(\"service\").pipe(\n\t\t\t\t\tFlag.withDescription(\n\t\t\t\t\t\t\"Run as the background server `codework service` manages, logging to <home>/log/server.log\",\n\t\t\t\t\t),\n\t\t\t\t\tFlag.withDefault(false),\n\t\t\t\t),\n\t\t\t\ttrustedProxy: Flag.String(\"trusted-proxy\").pipe(\n\t\t\t\t\tFlag.withDescription(\n\t\t\t\t\t\t\"Address or CIDR range of a TLS proxy in front of the server, repeatable or comma-separated (default: CODEWORK_TRUSTED_PROXY, then server.trustedProxy in user settings)\",\n\t\t\t\t\t),\n\t\t\t\t\tFlag.atLeast(0),\n\t\t\t\t),\n\t\t\t},\n\t\t\texamples: [\n\t\t\t\t{ command: \"codework serve\", description: \"Start the RPC server on 127.0.0.1:7433\" },\n\t\t\t\t{ command: \"codework serve --port 0\", description: \"Choose an available local port\" },\n\t\t\t\t{\n\t\t\t\t\tcommand: \"codework serve --host 0.0.0.0 --trusted-proxy 10.0.0.0/8\",\n\t\t\t\t\tdescription: \"Believe X-Forwarded-Proto from a proxy in 10.0.0.0/8\",\n\t\t\t\t},\n\t\t\t],\n\t\t}),\n\t\tSpec.make(\"service\", {\n\t\t\tdescription: \"Manage the background server\",\n\t\t\tcommands: [\n\t\t\t\tSpec.make(\"start\", { description: \"Start the background server\", params: ServerAddress }),\n\t\t\t\tSpec.make(\"restart\", { description: \"Restart the background server\", params: ServerAddress }),\n\t\t\t\tSpec.make(\"status\", { description: \"Show background server status\" }),\n\t\t\t\tSpec.make(\"stop\", { description: \"Stop the background server\" }),\n\t\t\t\tSpec.make(\"pair\", {\n\t\t\t\t\tdescription: \"Print a one-time code another computer pairs with, valid 10 minutes\",\n\t\t\t\t}),\n\t\t\t\tSpec.make(\"devices\", { description: \"List paired devices\" }),\n\t\t\t\tSpec.make(\"revoke\", {\n\t\t\t\t\tdescription: \"Unpair a device and end its connections\",\n\t\t\t\t\tparams: { id: Argument.String(\"device-id\").pipe(Argument.withDescription(\"The device to unpair\")) },\n\t\t\t\t}),\n\t\t\t],\n\t\t}),\n\t\tSpec.make(\"session\", {\n\t\t\tdescription: \"Manage sessions\",\n\t\t\tcommands: [\n\t\t\t\tSpec.make(\"link\", {\n\t\t\t\t\tdescription: \"Anchor a session to a host directory\",\n\t\t\t\t\tparams: {\n\t\t\t\t\t\tsession: Argument.String(\"session-id\").pipe(Argument.withDescription(\"The session to link\")),\n\t\t\t\t\t\tpath: Argument.String(\"path\").pipe(\n\t\t\t\t\t\t\t// The anchor is not a configuration mechanism, but `.codework` is the landmark\n\t\t\t\t\t\t\t// a person recognises, so the help names it to make the directory concrete.\n\t\t\t\t\t\t\tArgument.withDescription(\n\t\t\t\t\t\t\t\t\"Host directory to anchor to — typically the directory holding your .codework configuration; defaults to the shell's\",\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tArgument.optional,\n\t\t\t\t\t\t),\n\t\t\t\t\t\tunlink: Flag.Boolean(\"unlink\").pipe(\n\t\t\t\t\t\t\tFlag.withDescription(\"Clear the anchor, leaving the session with no host directory\"),\n\t\t\t\t\t\t\tFlag.withDefault(false),\n\t\t\t\t\t\t),\n\t\t\t\t\t\tserver: RunningServer,\n\t\t\t\t\t},\n\t\t\t\t\texamples: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcommand: \"codework session link ses_01h9\",\n\t\t\t\t\t\t\tdescription: \"Link it to the directory you are standing in\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcommand: \"codework session link ses_01h9 ~/work/api\",\n\t\t\t\t\t\t\tdescription: \"Link it to a project elsewhere on this machine\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcommand: \"codework session link ses_01h9 --unlink\",\n\t\t\t\t\t\t\tdescription: \"Clear the anchor\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}),\n\t\t\t\tSpec.make(\"relink\", {\n\t\t\t\t\tdescription: \"Move where a session's work, or one thread's, happens\",\n\t\t\t\t\tparams: {\n\t\t\t\t\t\tsession: Argument.String(\"session-id\").pipe(Argument.withDescription(\"The session to move\")),\n\t\t\t\t\t\tthread: Flag.String(\"thread\").pipe(\n\t\t\t\t\t\t\tFlag.withDescription(\n\t\t\t\t\t\t\t\t\"Move only this thread: a thread ID, or main; omitted moves the session's default\",\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tFlag.optional,\n\t\t\t\t\t\t),\n\t\t\t\t\t\tdirectory: Flag.String(\"directory\").pipe(\n\t\t\t\t\t\t\tFlag.withAlias(\"C\"),\n\t\t\t\t\t\t\tFlag.withDescription(\n\t\t\t\t\t\t\t\t\"Checkout to move into; the work keeps its position under it when that path exists there\",\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tFlag.optional,\n\t\t\t\t\t\t),\n\t\t\t\t\t\tsandboxId: Flag.String(\"sandbox-id\").pipe(\n\t\t\t\t\t\t\tFlag.withDescription(\"Sandbox instance to move to (default: local)\"),\n\t\t\t\t\t\t\tFlag.optional,\n\t\t\t\t\t\t),\n\t\t\t\t\t\tjson: JsonFlag,\n\t\t\t\t\t\tserver: RunningServer,\n\t\t\t\t\t},\n\t\t\t\t\texamples: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcommand: \"codework session relink ses_01h9 -C ~/work/api\",\n\t\t\t\t\t\t\tdescription: \"Move the session to a local checkout\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcommand: \"codework session relink ses_01h9 --thread thr_01ja --sandbox-id sbx_01k2\",\n\t\t\t\t\t\t\tdescription: \"Run one thread in a sandbox, leaving the others where they are\",\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\tSpec.make(\"thread\", {\n\t\t\tdescription: \"Manage a session's threads\",\n\t\t\tcommands: [\n\t\t\t\tSpec.make(\"list\", {\n\t\t\t\t\tdescription: \"List a session's threads, newest first\",\n\t\t\t\t\tparams: {\n\t\t\t\t\t\tsession: Argument.String(\"session-id\").pipe(Argument.withDescription(\"The session\")),\n\t\t\t\t\t\tjson: JsonFlag,\n\t\t\t\t\t\tserver: RunningServer,\n\t\t\t\t\t},\n\t\t\t\t\texamples: [{ command: \"codework thread list ses_01h9\", description: \"List the session's threads\" }],\n\t\t\t\t}),\n\t\t\t\tSpec.make(\"fork\", {\n\t\t\t\t\tdescription: \"Start a new thread from a committed entry of a thread's history\",\n\t\t\t\t\tparams: {\n\t\t\t\t\t\tsession: Argument.String(\"session-id\").pipe(Argument.withDescription(\"The session\")),\n\t\t\t\t\t\tthread: Flag.String(\"thread\").pipe(\n\t\t\t\t\t\t\tFlag.withDescription(\"Thread to fork: a thread ID, or main (default)\"),\n\t\t\t\t\t\t\tFlag.optional,\n\t\t\t\t\t\t),\n\t\t\t\t\t\tat: Flag.String(\"at\").pipe(Flag.withDescription(\"Keep history through this entry\"), Flag.optional),\n\t\t\t\t\t\tbefore: Flag.String(\"before\").pipe(\n\t\t\t\t\t\t\tFlag.withDescription(\"Keep history up to this user entry, and print its text to edit\"),\n\t\t\t\t\t\t\tFlag.optional,\n\t\t\t\t\t\t),\n\t\t\t\t\t\tjson: JsonFlag,\n\t\t\t\t\t\tserver: RunningServer,\n\t\t\t\t\t},\n\t\t\t\t\texamples: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcommand: \"codework thread fork ses_01h9 --at 01jb\",\n\t\t\t\t\t\t\tdescription: \"Continue the main thread's history through an entry in a new thread\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcommand: \"codework thread fork ses_01h9 --thread thr_01ja --before 01jc\",\n\t\t\t\t\t\t\tdescription: \"Branch just before a prompt, to send it again differently\",\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\tSpec.make(\"plugin\", {\n\t\t\tdescription: \"Manage plugins\",\n\t\t\tcommands: [\n\t\t\t\tSpec.make(\"add\", {\n\t\t\t\t\tdescription: \"Install a plugin and add it to a settings file\",\n\t\t\t\t\tparams: {\n\t\t\t\t\t\tpackage: Argument.String(\"package\").pipe(\n\t\t\t\t\t\t\tArgument.withDescription(\"Package spec, path, or file: URL\"),\n\t\t\t\t\t\t),\n\t\t\t\t\t\tglobal: Flag.Boolean(\"global\").pipe(\n\t\t\t\t\t\t\tFlag.withAlias(\"g\"),\n\t\t\t\t\t\t\tFlag.withDescription(\"Write the user-wide settings file instead of this project's\"),\n\t\t\t\t\t\t\tFlag.withDefault(false),\n\t\t\t\t\t\t),\n\t\t\t\t\t\tsession: Flag.String(\"session\").pipe(\n\t\t\t\t\t\t\tFlag.withDescription(\"Write the project a session is linked to, rather than this directory's\"),\n\t\t\t\t\t\t\tFlag.optional,\n\t\t\t\t\t\t),\n\t\t\t\t\t},\n\t\t\t\t\texamples: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcommand: \"codework plugin add @acme/codework-tool-proc@1.2.0\",\n\t\t\t\t\t\t\tdescription: \"Install a published plugin into this project's settings\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcommand: \"codework plugin add @acme/codework-tool-proc --session ses_01h9\",\n\t\t\t\t\t\t\tdescription: \"Write the project that session is linked to, from anywhere\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcommand: \"codework plugin add @acme/codework-tool-proc -g\",\n\t\t\t\t\t\t\tdescription: \"Install it for every project this user runs\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}),\n\t\t\t\tSpec.make(\"install\", {\n\t\t\t\t\tdescription: \"Install every plugin the settings files name\",\n\t\t\t\t\tparams: {},\n\t\t\t\t\texamples: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcommand: \"codework plugin install\",\n\t\t\t\t\t\t\tdescription: \"Materialise what a fresh checkout already declares\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}),\n\t\t\t\tSpec.make(\"list\", {\n\t\t\t\t\tdescription: \"List configured plugins and what each one resolved to\",\n\t\t\t\t\tparams: {\n\t\t\t\t\t\tverbose: Flag.Boolean(\"verbose\").pipe(\n\t\t\t\t\t\t\tFlag.withDescription(\"Show the message behind a failure, not only its reason\"),\n\t\t\t\t\t\t\tFlag.withDefault(false),\n\t\t\t\t\t\t),\n\t\t\t\t\t},\n\t\t\t\t\texamples: [{ command: \"codework plugin list\", description: \"Show every configured plugin\" }],\n\t\t\t\t}),\n\t\t\t\tSpec.make(\"check\", {\n\t\t\t\t\tdescription: \"Report which configured plugins have a newer revision available\",\n\t\t\t\t\tparams: {\n\t\t\t\t\t\tspec: Argument.String(\"spec\").pipe(\n\t\t\t\t\t\t\tArgument.withDescription(\"Only this configured plugin: a package name or spec, git spec, or path\"),\n\t\t\t\t\t\t\tArgument.optional,\n\t\t\t\t\t\t),\n\t\t\t\t\t\t// An answer is reused for an hour, which is right for a command someone may\n\t\t\t\t\t\t// run repeatedly and wrong for the minute after they pushed a plugin. Without\n\t\t\t\t\t\t// this there is no way to say \"ask again\", and `check` reports a moving branch\n\t\t\t\t\t\t// as current while `update` — which always refreshes — moves it.\n\t\t\t\t\t\trefresh: Flag.Boolean(\"refresh\").pipe(\n\t\t\t\t\t\t\tFlag.withDescription(\"Ask the remote again instead of reusing a recent answer\"),\n\t\t\t\t\t\t\tFlag.withDefault(false),\n\t\t\t\t\t\t),\n\t\t\t\t\t},\n\t\t\t\t\texamples: [\n\t\t\t\t\t\t{ command: \"codework plugin check\", description: \"Ask the registry what has moved\" },\n\t\t\t\t\t\t{ command: \"codework plugin check @acme/codework-tool-proc\", description: \"Ask about one plugin\" },\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcommand: \"codework plugin check --refresh\",\n\t\t\t\t\t\t\tdescription: \"Ignore the cached answer, after pushing a plugin\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}),\n\t\t\t\tSpec.make(\"update\", {\n\t\t\t\t\tdescription: \"Fetch a newer revision of every plugin that has one\",\n\t\t\t\t\tparams: {\n\t\t\t\t\t\tspec: Argument.String(\"spec\").pipe(\n\t\t\t\t\t\t\tArgument.withDescription(\"Only this configured plugin: a package name or spec, git spec, or path\"),\n\t\t\t\t\t\t\tArgument.optional,\n\t\t\t\t\t\t),\n\t\t\t\t\t},\n\t\t\t\t\texamples: [\n\t\t\t\t\t\t{ command: \"codework plugin update\", description: \"Take whatever `check` found\" },\n\t\t\t\t\t\t{ command: \"codework plugin update @acme/codework-tool-proc\", description: \"Update one plugin\" },\n\t\t\t\t\t],\n\t\t\t\t}),\n\t\t\t\tSpec.make(\"reload\", {\n\t\t\t\t\tdescription: \"Re-import configured plugins in a running server\",\n\t\t\t\t\tparams: {\n\t\t\t\t\t\tserver: RunningServer,\n\t\t\t\t\t},\n\t\t\t\t\texamples: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcommand: \"codework plugin reload\",\n\t\t\t\t\t\t\tdescription: \"Pick up edits to a local plugin without restarting\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}),\n\t\t\t\tSpec.make(\"remove\", {\n\t\t\t\t\tdescription: \"Remove a plugin from a settings file\",\n\t\t\t\t\tparams: {\n\t\t\t\t\t\tpackage: Argument.String(\"package\").pipe(\n\t\t\t\t\t\t\tArgument.withDescription(\"Configured package spec, path, or plugin ID\"),\n\t\t\t\t\t\t),\n\t\t\t\t\t\tglobal: Flag.Boolean(\"global\").pipe(\n\t\t\t\t\t\t\tFlag.withAlias(\"g\"),\n\t\t\t\t\t\t\tFlag.withDescription(\"Edit the user-wide settings file instead of this project's\"),\n\t\t\t\t\t\t\tFlag.withDefault(false),\n\t\t\t\t\t\t),\n\t\t\t\t\t},\n\t\t\t\t\texamples: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcommand: \"codework plugin remove @acme/codework-tool-proc\",\n\t\t\t\t\t\t\tdescription: \"Drop a plugin and any configuration written against it\",\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\tSpec.make(\"models\", {\n\t\t\tdescription: \"List or refresh the model catalog\",\n\t\t\tparams: {\n\t\t\t\tprovider: Flag.String(\"provider\").pipe(Flag.withDescription(\"Model catalog provider ID\"), Flag.optional),\n\t\t\t},\n\t\t\texamples: [\n\t\t\t\t{ command: \"codework models\", description: \"List all models from all providers\" },\n\t\t\t\t{\n\t\t\t\t\tcommand: \"codework models --provider openai\",\n\t\t\t\t\tdescription: \"List models for a specific provider\",\n\t\t\t\t},\n\t\t\t\t{ command: \"codework models providers\", description: \"List all available provider IDs\" },\n\t\t\t],\n\t\t\tcommands: [\n\t\t\t\tSpec.make(\"providers\", {\n\t\t\t\t\tdescription: \"List available model providers in the catalog\",\n\t\t\t\t}),\n\t\t\t\tSpec.make(\"refresh\", {\n\t\t\t\t\tdescription: \"Download the model catalog into the home if it is stale\",\n\t\t\t\t\tparams: {\n\t\t\t\t\t\tforce: Flag.Boolean(\"force\").pipe(\n\t\t\t\t\t\t\tFlag.withDescription(\"Download it even if it is still fresh\"),\n\t\t\t\t\t\t\tFlag.withDefault(false),\n\t\t\t\t\t\t),\n\t\t\t\t\t},\n\t\t\t\t\texamples: [\n\t\t\t\t\t\t{ command: \"codework models refresh\", description: \"Refresh a catalog older than 15 minutes\" },\n\t\t\t\t\t\t{ command: \"codework models refresh --force\", description: \"Download the catalog now\" },\n\t\t\t\t\t],\n\t\t\t\t}),\n\t\t\t],\n\t\t}),\n\t\tSpec.make(\"acp\", {\n\t\t\tdescription: \"Start the CodeWork Agent Client Protocol (ACP) server over stdio\",\n\t\t\texamples: [{ command: \"codework acp\", description: \"Start the ACP server on stdio\" }],\n\t\t}),\n\t],\n});\n","import { Config, ConfigProvider, Effect, Layer, Metric, Option, References, Schema } from \"effect\";\nimport { FetchHttpClient } from \"effect/http\";\nimport { OtlpMetrics, OtlpSerialization, OtlpTracer } from \"effect/observability\";\nimport { uuidv7 } from \"uuidv7\";\n\n// Configured by the standard `OTEL_*` variables alone. A configuration that fails\n// to build runs the command without export rather than failing it.\n\n// The OTel spec defaults `OTEL_{TRACES,METRICS}_EXPORTER` to `otlp`; Effect reads an\n// unset list as none, so an endpoint alone would export nothing.\nconst exporterDefaults = ConfigProvider.layerAdd(\n\tConfigProvider.fromUnknown({ OTEL_TRACES_EXPORTER: [\"otlp\"], OTEL_METRICS_EXPORTER: [\"otlp\"] }),\n);\n\n// Effect's fiber metrics hook every fiber start and end, so they follow metrics export.\nconst metricsEnabled = Config.all({\n\tdisabled: Config.Boolean(\"OTEL_SDK_DISABLED\").pipe(Config.withDefault(false)),\n\tendpoint: Config.String(\"OTEL_EXPORTER_OTLP_METRICS_ENDPOINT\").pipe(\n\t\tConfig.orElse(() => Config.String(\"OTEL_EXPORTER_OTLP_ENDPOINT\")),\n\t\tConfig.option,\n\t),\n\texporters: Config.Array(Schema.String, \"OTEL_METRICS_EXPORTER\"),\n}).pipe(\n\tConfig.map(\n\t\t({ disabled, endpoint, exporters }) =>\n\t\t\t!disabled && Option.isSome(endpoint) && exporters.some((exporter) => exporter.trim().toLowerCase() === \"otlp\"),\n\t),\n);\n\nconst fiberMetrics = Layer.unwrap(\n\tEffect.gen(function* () {\n\t\treturn (yield* metricsEnabled) ? Metric.enableRuntimeMetricsLayer : Layer.empty;\n\t}),\n);\n\n// Only spans marked `level: \"Info\"` are exported; the rest, Effect's own `sql.*`\n// among them, default to `Debug`. Effect drops a span's children with it, so every\n// span on the path from a command to a model or tool call must be `Info`.\nconst levels = { all: \"All\", trace: \"Trace\", debug: \"Debug\", info: \"Info\", warn: \"Warn\", error: \"Error\" } as const;\n\nconst traceLevels = Layer.unwrap(\n\tEffect.gen(function* () {\n\t\tconst name = yield* Config.String(\"CODEWORK_TRACE_LEVEL\").pipe(Config.withDefault(\"info\"));\n\t\tconst minimum = levels[name.trim().toLowerCase() as keyof typeof levels] ?? \"Info\";\n\t\treturn Layer.mergeAll(\n\t\t\tLayer.succeed(References.CurrentTraceLevel, \"Debug\"),\n\t\t\tLayer.succeed(References.MinimumTraceLevel, minimum),\n\t\t);\n\t}),\n);\n\ninterface OtlpResource {\n\treadonly serviceName: string;\n\treadonly serviceVersion: string;\n\treadonly attributes: Record<string, string>;\n}\n\n// Effect has no gRPC exporter: `grpc` exports nothing rather than sending HTTP to a gRPC port.\nconst exporters = (resource: OtlpResource) =>\n\tLayer.unwrap(\n\t\tEffect.gen(function* () {\n\t\t\tconst protocol = yield* Config.String(\"OTEL_EXPORTER_OTLP_PROTOCOL\").pipe(Config.withDefault(\"http/protobuf\"));\n\t\t\tconst format = {\n\t\t\t\t\"http/json\": OtlpSerialization.layerJson,\n\t\t\t\t\"http/protobuf\": OtlpSerialization.layerProtobuf,\n\t\t\t}[protocol.trim().toLowerCase()];\n\t\t\tif (format === undefined) return Layer.empty;\n\t\t\treturn Layer.mergeAll(\n\t\t\t\tOtlpTracer.layerFromConfig({ resource }),\n\t\t\t\tOtlpMetrics.layerFromConfig({ resource }),\n\t\t\t).pipe(Layer.provide(format));\n\t\t}),\n\t);\n\nconst channel = (version: string) =>\n\tversion.includes(\"-canary.\") ? \"canary\" : version.includes(\"-dev.\") ? \"dev\" : \"latest\";\n\nconst instanceId = uuidv7();\n\nexport const layer = (options: { readonly version: string; readonly command: string }) => {\n\tconst resource: OtlpResource = {\n\t\tserviceName: \"codework\",\n\t\tserviceVersion: options.version,\n\t\tattributes: {\n\t\t\t\"service.instance.id\": instanceId,\n\t\t\t\"deployment.environment.name\": channel(options.version),\n\t\t\t\"codework.command\": options.command,\n\t\t},\n\t};\n\treturn Layer.mergeAll(exporters(resource), fiberMetrics, traceLevels).pipe(\n\t\tLayer.provide(FetchHttpClient.layer),\n\t\tLayer.provide(exporterDefaults),\n\t\tLayer.catchCause(() => Layer.empty),\n\t);\n};\n","import { Effect } from \"effect\";\nimport { Command } from \"effect/cli\";\nimport type { CommandError } from \"../cli/error.ts\";\nimport * as Otel from \"./otel.ts\";\nimport * as Spec from \"./spec.ts\";\n\n/**\n * Binds handlers to a {@link Spec} tree. Handlers are loaded through dynamic\n * imports so that starting the process -- or printing `--help` -- never pulls in\n * the harness, its sandbox drivers, or the model catalog.\n */\n\n/** Recovers the parsed input type of a spec node, for typing its handler. */\nexport type Input<Value> =\n\tValue extends Spec.Node<infer _Name, infer Spec, infer _Commands>\n\t\t? Input<Spec>\n\t\t: Value extends Command.Command<infer _Name, infer Parsed, infer _Context, infer _Error, infer _Requirements>\n\t\t\t? Parsed\n\t\t\t: never;\n\n/**\n * A handler may yield an ancestor's spec to read its shared flags, which shows up\n * as a `CommandContext` requirement; `withSubcommands` discharges it when the tree\n * is assembled.\n */\ntype Requirements = Command.Environment | Command.CommandContext<string>;\ntype Run<Parsed> = (input: Parsed) => Effect.Effect<void, CommandError, Requirements>;\ntype Loader<Node extends Spec.Any> = () => Promise<{ readonly default: Run<Input<Node>> }>;\n\n/**\n * The handler registry for a spec tree: a loader per leaf, mirroring the shape of\n * the tree. A parent with children takes its own handler under `$`.\n */\nexport type Handlers<Node extends Spec.Any> = keyof Node[\"commands\"] extends never\n\t? Loader<Node>\n\t: { readonly $?: Loader<Node> } & { readonly [Key in keyof Node[\"commands\"]]: Handlers<Node[\"commands\"][Key]> };\n\ninterface LazyHandler {\n\treadonly spec: Command.Command.Any;\n\t// biome-ignore lint/suspicious/noExplicitAny: input is recovered per-command by `Input`\n\treadonly load: () => Promise<{ readonly default: Run<any> }>;\n}\n\ntype LazyHandlers = LazyHandler[\"load\"] | { readonly [key: string]: LazyHandlers | undefined };\n\ntype ProvidedCommand = Command.Command<string, unknown, unknown, never, Command.Environment>;\n\n/** Type-checks a handler against the spec node it implements. */\nexport function handler<const Node extends Spec.Any>(_node: Node, run: Run<Input<Node>>) {\n\treturn run;\n}\n\nexport function handlers<const Root extends Spec.Any>(\n\troot: Root,\n\thandlers: Handlers<Root>,\n): ReadonlyArray<LazyHandler> {\n\tconst result: LazyHandler[] = [];\n\n\tfunction add(node: Spec.Any, value: LazyHandlers) {\n\t\tif (typeof value === \"function\") {\n\t\t\tresult.push({ spec: node.spec, load: value });\n\t\t\treturn;\n\t\t}\n\t\tif (value.$ !== undefined) result.push({ spec: node.spec, load: value.$ as LazyHandler[\"load\"] });\n\t\tfor (const [name, child] of Object.entries(node.commands)) {\n\t\t\tconst nested = value[name];\n\t\t\tif (nested !== undefined) add(child, nested);\n\t\t}\n\t}\n\n\tadd(root, handlers as LazyHandlers);\n\treturn result;\n}\n\nexport function run(root: Spec.Any, handlers: ReadonlyArray<LazyHandler>, options: { readonly version: string }) {\n\treturn Command.run(provide(root, handlers, { version: options.version, path: [] }), options);\n}\n\nfunction provide(\n\tnode: Spec.Any,\n\thandlers: ReadonlyArray<LazyHandler>,\n\tcontext: { readonly version: string; readonly path: ReadonlyArray<string> },\n): ProvidedCommand {\n\tconst found = handlers.find((entry) => entry.spec === node.spec);\n\tconst command = context.path.length === 0 ? node.name : context.path.join(\" \");\n\tconst spec = found\n\t\t? node.spec.pipe(\n\t\t\t\tCommand.withHandler((input) =>\n\t\t\t\t\tEffect.promise(found.load).pipe(\n\t\t\t\t\t\tEffect.flatMap((module) => module.default(input)),\n\t\t\t\t\t\t// Rendered here, so a handler's own failure prints as `error:` instead of reaching the\n\t\t\t\t\t\t// runtime's logger with a stack. Imported on failure: the renderer pulls in the harness.\n\t\t\t\t\t\tEffect.catch((error) =>\n\t\t\t\t\t\t\tEffect.promise(() => import(\"../cli/error.ts\")).pipe(\n\t\t\t\t\t\t\t\tEffect.flatMap((module) => module.reportFailure(error)),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t),\n\t\t\t\t\t\tEffect.provide(Otel.layer({ version: context.version, command })),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t)\n\t\t: node.spec;\n\tconst children = Object.values(node.commands);\n\tif (children.length === 0) return spec as ProvidedCommand;\n\treturn spec.pipe(\n\t\tCommand.withSubcommands(\n\t\t\tchildren.map((child) => provide(child, handlers, { ...context, path: [...context.path, child.name] })),\n\t\t),\n\t) as ProvidedCommand;\n}\n"],"mappings":";;;;;;;AAkDA,S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