@codeworksh/cli 0.0.1-dev.20260925125202 → 0.1.0-canary.1.1.gc0ff5572
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 +5 -5
- package/acp-BHv2HR2W.mjs +494 -0
- package/acp-BHv2HR2W.mjs.map +1 -0
- package/{add-CIQSfxan.mjs → add-DlwSE-gO.mjs} +13 -12
- package/add-DlwSE-gO.mjs.map +1 -0
- package/{catalog-C5fDCgtx.mjs → catalog-BDSnGfE_.mjs} +5 -5
- package/catalog-BDSnGfE_.mjs.map +1 -0
- package/{check-B7bP5lRI.mjs → check-CpZTFCDq.mjs} +6 -5
- package/check-CpZTFCDq.mjs.map +1 -0
- package/{entries-CSY5N6jH.mjs → entries-8LFGwy4n.mjs} +15 -14
- package/entries-8LFGwy4n.mjs.map +1 -0
- package/error-CzUxh0Q9.mjs +630 -0
- package/error-CzUxh0Q9.mjs.map +1 -0
- package/{harness-DXAwGk0B.mjs → harness-6d8TlAVk.mjs} +4 -3
- package/harness-6d8TlAVk.mjs.map +1 -0
- package/identity-B3FOHqbf.mjs +89 -0
- package/identity-B3FOHqbf.mjs.map +1 -0
- package/index.mjs +27 -21
- package/index.mjs.map +1 -1
- package/{install-B02SIXwF.mjs → install-CNWMNyaf.mjs} +7 -6
- package/install-CNWMNyaf.mjs.map +1 -0
- package/{link-CA9XdPwj.mjs → link-oTpS3aUc.mjs} +6 -5
- package/{link-CA9XdPwj.mjs.map → link-oTpS3aUc.mjs.map} +1 -1
- package/{list-Ce1Ry4JN.mjs → list-CmHTTB8Z.mjs} +6 -5
- package/list-CmHTTB8Z.mjs.map +1 -0
- package/{list-Bbo4XnG_.mjs → list-DhdnHHJ5.mjs} +11 -10
- package/list-DhdnHHJ5.mjs.map +1 -0
- package/{login-CagARGqW.mjs → login-DPJbdjAY.mjs} +4 -4
- package/{login-CagARGqW.mjs.map → login-DPJbdjAY.mjs.map} +1 -1
- package/{logout-CYYtjZL3.mjs → logout-CL5CN_af.mjs} +4 -4
- package/{logout-CYYtjZL3.mjs.map → logout-CL5CN_af.mjs.map} +1 -1
- package/package-7FOUqcPO.mjs +6 -0
- package/package-7FOUqcPO.mjs.map +1 -0
- package/package.json +11 -34
- package/{providers-CoYj1SYv.mjs → providers-Dg8UlU_O.mjs} +6 -5
- package/providers-Dg8UlU_O.mjs.map +1 -0
- package/{refresh-D2a1ikea.mjs → refresh-OsgI6DYK.mjs} +6 -5
- package/refresh-OsgI6DYK.mjs.map +1 -0
- package/{refresh-8_nfeYNZ.mjs → refresh-TK948P0j.mjs} +4 -4
- package/{refresh-8_nfeYNZ.mjs.map → refresh-TK948P0j.mjs.map} +1 -1
- package/{reload-C5ysPM58.mjs → reload-_hDmESKE.mjs} +3 -3
- package/{reload-C5ysPM58.mjs.map → reload-_hDmESKE.mjs.map} +1 -1
- package/{remove-BkbspSED.mjs → remove-DjBJe09T.mjs} +6 -5
- package/remove-DjBJe09T.mjs.map +1 -0
- package/restart-CqAQCig7.mjs +21 -0
- package/restart-CqAQCig7.mjs.map +1 -0
- package/{run-CnxjZIGy.mjs → run-BpiW8Wxp.mjs} +17 -18
- package/run-BpiW8Wxp.mjs.map +1 -0
- package/{runtime-B3dlWGfs.mjs → runtime-CIBm_3RX.mjs} +52 -6
- package/runtime-CIBm_3RX.mjs.map +1 -0
- package/{serve-DaD7Eijz.mjs → serve-RFw_BCHm.mjs} +90 -52
- package/serve-RFw_BCHm.mjs.map +1 -0
- package/service-7_FrDOGJ.mjs +222 -0
- package/service-7_FrDOGJ.mjs.map +1 -0
- package/{settings-BZXmb54m.mjs → settings-BM_gw7Fm.mjs} +12 -11
- package/settings-BM_gw7Fm.mjs.map +1 -0
- package/{shared-BaTfajJ2.mjs → shared-DjyUhNsi.mjs} +5 -4
- package/shared-DjyUhNsi.mjs.map +1 -0
- package/start-DcvqAhc4.mjs +20 -0
- package/start-DcvqAhc4.mjs.map +1 -0
- package/status-9o_2AAAv.mjs +14 -0
- package/status-9o_2AAAv.mjs.map +1 -0
- package/{status-qJImmv6V.mjs → status-BTCqpq7x.mjs} +4 -4
- package/{status-qJImmv6V.mjs.map → status-BTCqpq7x.mjs.map} +1 -1
- package/stop-De_XWxXw.mjs +13 -0
- package/stop-De_XWxXw.mjs.map +1 -0
- package/tui-B5RAnvTr.mjs +76 -0
- package/tui-B5RAnvTr.mjs.map +1 -0
- package/{update-CxcNv_t0.mjs → update-6Fn2_4fJ.mjs} +7 -6
- package/update-6Fn2_4fJ.mjs.map +1 -0
- package/add-CIQSfxan.mjs.map +0 -1
- package/catalog-C5fDCgtx.mjs.map +0 -1
- package/check-B7bP5lRI.mjs.map +0 -1
- package/entries-CSY5N6jH.mjs.map +0 -1
- package/error-D0C5K2Av.mjs +0 -10376
- package/error-D0C5K2Av.mjs.map +0 -1
- package/harness-DXAwGk0B.mjs.map +0 -1
- package/index.d.mts +0 -24
- package/install-B02SIXwF.mjs.map +0 -1
- package/list-Bbo4XnG_.mjs.map +0 -1
- package/list-Ce1Ry4JN.mjs.map +0 -1
- package/providers-CoYj1SYv.mjs.map +0 -1
- package/refresh-D2a1ikea.mjs.map +0 -1
- package/remove-BkbspSED.mjs.map +0 -1
- package/run-CnxjZIGy.mjs.map +0 -1
- package/runtime-B3dlWGfs.mjs.map +0 -1
- package/serve-DaD7Eijz.mjs.map +0 -1
- package/settings-BZXmb54m.mjs.map +0 -1
- package/shared-BaTfajJ2.mjs.map +0 -1
- package/update-CxcNv_t0.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout-
|
|
1
|
+
{"version":3,"file":"logout-CL5CN_af.mjs","names":["Runtime.handler","Client.make"],"sources":["../../src/cli/cmd/handlers/auth/logout.ts"],"sourcesContent":["import { oauthNotice } from \"@codeworksh/aikit/oauth/summary\";\nimport { Effect, Option } from \"effect\";\nimport { Runtime } from \"../../../../framework/runtime.ts\";\nimport { reportFailure } from \"../../../error.ts\";\nimport { writeError } from \"../../../output.ts\";\nimport { Cmd } from \"../../cmd.ts\";\nimport {\n\tassertServerScope,\n\tattempt,\n\tClient,\n\tlocalOps,\n\toauthProviderLabel,\n\tselectProvider,\n\twithServer,\n} from \"./shared.ts\";\n\nexport default Runtime.handler(\n\tCmd.commands.auth.commands.logout,\n\tEffect.fn(\"CLI.auth.logout\")(function* ({ server, openaiCodex, githubCopilot, authFile }) {\n\t\tconst program = Effect.gen(function* () {\n\t\t\tconst provider = yield* selectProvider({ openaiCodex, githubCopilot });\n\t\t\tconst name = oauthProviderLabel(provider);\n\n\t\t\tif (Option.isSome(server)) {\n\t\t\t\tyield* assertServerScope(authFile);\n\t\t\t\treturn yield* withServer(\n\t\t\t\t\tserver.value,\n\t\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\t\tconst rpc = yield* Client.make;\n\t\t\t\t\t\tyield* rpc[\"auth.logout\"]({ provider });\n\t\t\t\t\t\tyield* writeError(`${oauthNotice(\"cleared\", provider, \"the server\")}\\n`);\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst ops = yield* localOps(provider, authFile);\n\t\t\tyield* attempt(`failed to clear ${name} credentials`, () => ops.logout());\n\t\t\tyield* writeError(`${oauthNotice(\"cleared\", provider, ops.path)}\\n`);\n\t\t});\n\n\t\treturn yield* program.pipe(Effect.catch(reportFailure));\n\t}),\n);\n"],"mappings":";;;;;;AAgBA,IAAA,iBAAeA,QACd,IAAI,SAAS,KAAK,SAAS,QAC3B,OAAO,GAAG,iBAAiB,CAAC,CAAC,WAAW,EAAE,QAAQ,aAAa,eAAe,YAAY;CAsBzF,OAAO,OArBS,OAAO,IAAI,aAAa;EACvC,MAAM,WAAW,OAAO,eAAe;GAAE;GAAa;EAAc,CAAC;EACrE,MAAM,OAAO,mBAAmB,QAAQ;EAExC,IAAI,OAAO,OAAO,MAAM,GAAG;GAC1B,OAAO,kBAAkB,QAAQ;GACjC,OAAO,OAAO,WACb,OAAO,OACP,OAAO,IAAI,aAAa;IAEvB,QAAO,OADYC,KAAAA,CACR,cAAc,CAAC,EAAE,SAAS,CAAC;IACtC,OAAO,WAAW,GAAG,YAAY,WAAW,UAAU,YAAY,EAAE,GAAG;GACxE,CAAC,CACF;EACD;EAEA,MAAM,MAAM,OAAO,SAAS,UAAU,QAAQ;EAC9C,OAAO,QAAQ,mBAAmB,KAAK,qBAAqB,IAAI,OAAO,CAAC;EACxE,OAAO,WAAW,GAAG,YAAY,WAAW,UAAU,IAAI,IAAI,EAAE,GAAG;CACpE,CAEoB,CAAC,CAAC,KAAK,OAAO,MAAM,aAAa,CAAC;AACvD,CAAC,CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-7FOUqcPO.mjs","names":[],"sources":["../../package.json"],"sourcesContent":[""],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codeworksh/cli",
|
|
3
|
-
"version": "0.0.1
|
|
3
|
+
"version": "0.1.0-canary.1.1.gc0ff5572",
|
|
4
4
|
"description": "CLI for running CodeWork coding agent harness.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|
|
@@ -24,18 +24,9 @@
|
|
|
24
24
|
"directory": "packages/codework"
|
|
25
25
|
},
|
|
26
26
|
"type": "module",
|
|
27
|
-
"types": "./index.d.mts",
|
|
28
27
|
"bin": {
|
|
29
28
|
"codework": "index.mjs"
|
|
30
29
|
},
|
|
31
|
-
"exports": {
|
|
32
|
-
".": {
|
|
33
|
-
"types": "./index.d.mts",
|
|
34
|
-
"import": "./index.mjs",
|
|
35
|
-
"default": "./index.mjs"
|
|
36
|
-
},
|
|
37
|
-
"./package.json": "./package.json"
|
|
38
|
-
},
|
|
39
30
|
"files": [
|
|
40
31
|
"**/*",
|
|
41
32
|
"README.md",
|
|
@@ -48,31 +39,17 @@
|
|
|
48
39
|
"node": ">=24.14.1"
|
|
49
40
|
},
|
|
50
41
|
"dependencies": {
|
|
51
|
-
"@
|
|
52
|
-
"@codeworksh/
|
|
53
|
-
"@
|
|
54
|
-
"@
|
|
55
|
-
"@
|
|
56
|
-
"
|
|
57
|
-
"@platformatic/vfs": "^0.4.0",
|
|
58
|
-
"effect": "4.0.0-rc.115",
|
|
42
|
+
"@agentclientprotocol/sdk": "1.5.1",
|
|
43
|
+
"@codeworksh/aikit": "0.10.0-canary.1.1.gc0ff5572",
|
|
44
|
+
"@codeworksh/harness": "0.1.0-canary.1.1.gc0ff5572",
|
|
45
|
+
"@codeworksh/tui": "0.0.1-canary.1.1.gc0ff5572",
|
|
46
|
+
"@effect/platform-node": "4.0.1",
|
|
47
|
+
"effect": "4.0.1",
|
|
59
48
|
"jsonc-parser": "3.3.1",
|
|
60
|
-
"
|
|
61
|
-
"npm-package-arg": "^14.0.0",
|
|
62
|
-
"pacote": "^22.0.0",
|
|
63
|
-
"typebox": "^1.3.30",
|
|
64
|
-
"uuidv7": "^1.2.1"
|
|
65
|
-
},
|
|
66
|
-
"peerDependencies": {
|
|
67
|
-
"@daytona/sdk": "*",
|
|
68
|
-
"@vercel/sandbox": "*"
|
|
49
|
+
"zod": "4.6.5"
|
|
69
50
|
},
|
|
70
|
-
"
|
|
71
|
-
"@daytona/sdk":
|
|
72
|
-
|
|
73
|
-
},
|
|
74
|
-
"@vercel/sandbox": {
|
|
75
|
-
"optional": true
|
|
76
|
-
}
|
|
51
|
+
"optionalDependencies": {
|
|
52
|
+
"@daytona/sdk": "^0.211.2",
|
|
53
|
+
"@vercel/sandbox": "^3.3.0"
|
|
77
54
|
}
|
|
78
55
|
}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { n as synced } from "./catalog-
|
|
1
|
+
import { i as Cmd, t as handler } from "./runtime-CIBm_3RX.mjs";
|
|
2
|
+
import { d as writeOut, i as reportFailure } from "./error-CzUxh0Q9.mjs";
|
|
3
|
+
import { n as synced } from "./catalog-BDSnGfE_.mjs";
|
|
4
4
|
import { Effect } from "effect";
|
|
5
|
+
import { ModelCatalog } from "@codeworksh/harness/effect";
|
|
5
6
|
//#region src/cli/cmd/handlers/models/providers.ts
|
|
6
7
|
var providers_default = handler(Cmd.commands.models.commands.providers, Effect.fn("CLI.models.providers")(function* () {
|
|
7
8
|
return yield* Effect.gen(function* () {
|
|
8
9
|
yield* synced;
|
|
9
|
-
const sorted = [...yield* providers].sort((a, b) => a.localeCompare(b));
|
|
10
|
+
const sorted = [...yield* ModelCatalog.providers].sort((a, b) => a.localeCompare(b));
|
|
10
11
|
yield* writeOut(sorted.map((providerId) => `${providerId}\n`).join(""));
|
|
11
12
|
}).pipe(Effect.catch(reportFailure));
|
|
12
13
|
}));
|
|
13
14
|
//#endregion
|
|
14
15
|
export { providers_default as default };
|
|
15
16
|
|
|
16
|
-
//# sourceMappingURL=providers-
|
|
17
|
+
//# sourceMappingURL=providers-Dg8UlU_O.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providers-Dg8UlU_O.mjs","names":["Runtime.handler"],"sources":["../../src/cli/cmd/handlers/models/providers.ts"],"sourcesContent":["import { ModelCatalog } from \"@codeworksh/harness/effect\";\nimport { Effect } from \"effect\";\nimport { Runtime } from \"../../../../framework/runtime.ts\";\nimport { reportFailure } from \"../../../error.ts\";\nimport { writeOut } from \"../../../output.ts\";\nimport { Cmd } from \"../../cmd.ts\";\nimport { synced } from \"./catalog.ts\";\n\nexport default Runtime.handler(\n\tCmd.commands.models.commands.providers,\n\tEffect.fn(\"CLI.models.providers\")(function* () {\n\t\tconst program = Effect.gen(function* () {\n\t\t\tyield* synced;\n\t\t\tconst providers = yield* ModelCatalog.providers;\n\t\t\tconst sorted = [...providers].sort((a, b) => a.localeCompare(b));\n\t\t\tyield* writeOut(sorted.map((providerId) => `${providerId}\\n`).join(\"\"));\n\t\t});\n\n\t\treturn yield* program.pipe(Effect.catch(reportFailure));\n\t}),\n);\n"],"mappings":";;;;;;AAQA,IAAA,oBAAeA,QACd,IAAI,SAAS,OAAO,SAAS,WAC7B,OAAO,GAAG,sBAAsB,CAAC,CAAC,aAAa;CAQ9C,OAAO,OAPS,OAAO,IAAI,aAAa;EACvC,OAAO;EAEP,MAAM,SAAS,CAAC,GAAG,OADM,aAAa,SACV,CAAC,CAAC,MAAM,GAAG,MAAM,EAAE,cAAc,CAAC,CAAC;EAC/D,OAAO,SAAS,OAAO,KAAK,eAAe,GAAG,WAAW,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC;CACvE,CAEoB,CAAC,CAAC,KAAK,OAAO,MAAM,aAAa,CAAC;AACvD,CAAC,CACF"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as
|
|
3
|
-
import { t as home } from "./catalog-
|
|
1
|
+
import { i as Cmd, t as handler } from "./runtime-CIBm_3RX.mjs";
|
|
2
|
+
import { d as writeOut, i as reportFailure, u as writeError } from "./error-CzUxh0Q9.mjs";
|
|
3
|
+
import { t as home } from "./catalog-BDSnGfE_.mjs";
|
|
4
4
|
import { Effect } from "effect";
|
|
5
|
+
import { ModelCatalog } from "@codeworksh/harness/effect";
|
|
5
6
|
//#region src/cli/cmd/handlers/models/refresh.ts
|
|
6
7
|
var refresh_default = handler(Cmd.commands.models.commands.refresh, Effect.fn("CLI.models.refresh")(function* ({ force }) {
|
|
7
8
|
return yield* Effect.gen(function* () {
|
|
8
|
-
const status = yield* refresh(yield* home, { force });
|
|
9
|
+
const status = yield* ModelCatalog.refresh(yield* home, { force });
|
|
9
10
|
yield* writeError(status.refreshed ? `Refreshed model catalog at ${status.path}\n` : `Model catalog at ${status.path} is fresh; pass --force to download it anyway\n`);
|
|
10
11
|
yield* writeOut(`${status.path}\n`);
|
|
11
12
|
}).pipe(Effect.catch(reportFailure));
|
|
@@ -13,4 +14,4 @@ var refresh_default = handler(Cmd.commands.models.commands.refresh, Effect.fn("C
|
|
|
13
14
|
//#endregion
|
|
14
15
|
export { refresh_default as default };
|
|
15
16
|
|
|
16
|
-
//# sourceMappingURL=refresh-
|
|
17
|
+
//# sourceMappingURL=refresh-OsgI6DYK.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refresh-OsgI6DYK.mjs","names":["Runtime.handler"],"sources":["../../src/cli/cmd/handlers/models/refresh.ts"],"sourcesContent":["import { ModelCatalog } from \"@codeworksh/harness/effect\";\nimport { Effect } from \"effect\";\nimport { Runtime } from \"../../../../framework/runtime.ts\";\nimport { reportFailure } from \"../../../error.ts\";\nimport { writeError, writeOut } from \"../../../output.ts\";\nimport { Cmd } from \"../../cmd.ts\";\nimport { home } from \"./catalog.ts\";\n\nexport default Runtime.handler(\n\tCmd.commands.models.commands.refresh,\n\tEffect.fn(\"CLI.models.refresh\")(function* ({ force }) {\n\t\tconst program = Effect.gen(function* () {\n\t\t\tconst status = yield* ModelCatalog.refresh(yield* home, { force });\n\t\t\tyield* writeError(\n\t\t\t\tstatus.refreshed\n\t\t\t\t\t? `Refreshed model catalog at ${status.path}\\n`\n\t\t\t\t\t: `Model catalog at ${status.path} is fresh; pass --force to download it anyway\\n`,\n\t\t\t);\n\t\t\tyield* writeOut(`${status.path}\\n`);\n\t\t});\n\n\t\treturn yield* program.pipe(Effect.catch(reportFailure));\n\t}),\n);\n"],"mappings":";;;;;;AAQA,IAAA,kBAAeA,QACd,IAAI,SAAS,OAAO,SAAS,SAC7B,OAAO,GAAG,oBAAoB,CAAC,CAAC,WAAW,EAAE,SAAS;CAWrD,OAAO,OAVS,OAAO,IAAI,aAAa;EACvC,MAAM,SAAS,OAAO,aAAa,QAAQ,OAAO,MAAM,EAAE,MAAM,CAAC;EACjE,OAAO,WACN,OAAO,YACJ,8BAA8B,OAAO,KAAK,MAC1C,oBAAoB,OAAO,KAAK,gDACpC;EACA,OAAO,SAAS,GAAG,OAAO,KAAK,GAAG;CACnC,CAEoB,CAAC,CAAC,KAAK,OAAO,MAAM,aAAa,CAAC;AACvD,CAAC,CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as
|
|
3
|
-
import { a as oauthProviderLabel, n as attempt, o as selectProvider, r as localOps, s as withServer, t as assertServerScope } from "./shared-
|
|
1
|
+
import { i as Cmd, t as handler } from "./runtime-CIBm_3RX.mjs";
|
|
2
|
+
import { d as writeOut, i as reportFailure, n as OAuthError, p as make, t as InvalidInputError, u as writeError } from "./error-CzUxh0Q9.mjs";
|
|
3
|
+
import { a as oauthProviderLabel, n as attempt, o as selectProvider, r as localOps, s as withServer, t as assertServerScope } from "./shared-DjyUhNsi.mjs";
|
|
4
4
|
import { Effect, Option } from "effect";
|
|
5
5
|
import { formatOAuthSummary, oauthNotice, oauthRefreshIssue } from "@codeworksh/aikit/oauth/summary";
|
|
6
6
|
//#region src/cli/cmd/handlers/auth/refresh.ts
|
|
@@ -32,4 +32,4 @@ var refresh_default = handler(Cmd.commands.auth.commands.refresh, Effect.fn("CLI
|
|
|
32
32
|
//#endregion
|
|
33
33
|
export { refresh_default as default };
|
|
34
34
|
|
|
35
|
-
//# sourceMappingURL=refresh-
|
|
35
|
+
//# sourceMappingURL=refresh-TK948P0j.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refresh-
|
|
1
|
+
{"version":3,"file":"refresh-TK948P0j.mjs","names":["Runtime.handler","Client.make"],"sources":["../../src/cli/cmd/handlers/auth/refresh.ts"],"sourcesContent":["import { formatOAuthSummary, oauthNotice, oauthRefreshIssue } from \"@codeworksh/aikit/oauth/summary\";\nimport { Effect, Option } from \"effect\";\nimport { Runtime } from \"../../../../framework/runtime.ts\";\nimport { InvalidInputError, OAuthError, reportFailure } from \"../../../error.ts\";\nimport { writeError, writeOut } from \"../../../output.ts\";\nimport { Cmd } from \"../../cmd.ts\";\nimport {\n\tassertServerScope,\n\tattempt,\n\tClient,\n\tlocalOps,\n\toauthProviderLabel,\n\tselectProvider,\n\twithServer,\n} from \"./shared.ts\";\n\nexport default Runtime.handler(\n\tCmd.commands.auth.commands.refresh,\n\tEffect.fn(\"CLI.auth.refresh\")(function* ({ server, openaiCodex, githubCopilot, authFile, json }) {\n\t\tconst program = Effect.gen(function* () {\n\t\t\tconst provider = yield* selectProvider({ openaiCodex, githubCopilot });\n\t\t\tconst blocked = oauthRefreshIssue(provider);\n\t\t\tif (blocked !== undefined) return yield* new InvalidInputError({ message: blocked });\n\n\t\t\tconst name = oauthProviderLabel(provider);\n\n\t\t\tif (Option.isSome(server)) {\n\t\t\t\tyield* assertServerScope(authFile);\n\t\t\t\treturn yield* withServer(\n\t\t\t\t\tserver.value,\n\t\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\t\tconst rpc = yield* Client.make;\n\t\t\t\t\t\tconst info = yield* rpc[\"auth.refresh\"]({ provider });\n\t\t\t\t\t\tif (info === null) {\n\t\t\t\t\t\t\treturn yield* new OAuthError({ message: oauthNotice(\"missing\", provider, \"the server\") });\n\t\t\t\t\t\t}\n\t\t\t\t\t\tyield* writeError(`${oauthNotice(\"refreshed\", provider, \"the server\")}\\n`);\n\t\t\t\t\t\tyield* writeOut(formatOAuthSummary(info, { json }));\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst ops = yield* localOps(provider, authFile);\n\t\t\tconst summary = yield* attempt(`failed to read ${name} credentials`, () => ops.refreshed());\n\t\t\tif (summary === undefined) {\n\t\t\t\treturn yield* new OAuthError({ message: oauthNotice(\"missing\", provider, ops.path) });\n\t\t\t}\n\t\t\tyield* writeError(`${oauthNotice(\"refreshed\", provider, ops.path)}\\n`);\n\t\t\tyield* writeOut(formatOAuthSummary(summary, { json }));\n\t\t});\n\n\t\treturn yield* program.pipe(Effect.catch(reportFailure));\n\t}),\n);\n"],"mappings":";;;;;;AAgBA,IAAA,kBAAeA,QACd,IAAI,SAAS,KAAK,SAAS,SAC3B,OAAO,GAAG,kBAAkB,CAAC,CAAC,WAAW,EAAE,QAAQ,aAAa,eAAe,UAAU,QAAQ;CAiChG,OAAO,O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as make } from "./error-CzUxh0Q9.mjs";
|
|
3
3
|
import { Effect } from "effect";
|
|
4
4
|
//#region src/cli/cmd/handlers/plugin/reload.ts
|
|
5
5
|
/**
|
|
@@ -23,4 +23,4 @@ var reload_default = handler(Cmd.commands.plugin.commands.reload, Effect.fn("CLI
|
|
|
23
23
|
//#endregion
|
|
24
24
|
export { reload_default as default };
|
|
25
25
|
|
|
26
|
-
//# sourceMappingURL=reload-
|
|
26
|
+
//# sourceMappingURL=reload-_hDmESKE.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reload-
|
|
1
|
+
{"version":3,"file":"reload-_hDmESKE.mjs","names":["Runtime.handler","Client.make","Client.layer"],"sources":["../../src/cli/cmd/handlers/plugin/reload.ts"],"sourcesContent":["import { Effect } from \"effect\";\nimport { Runtime } from \"../../../../framework/runtime.ts\";\nimport { reportFailure } from \"../../../error.ts\";\nimport { writeOut } from \"../../../output.ts\";\nimport { Client } from \"../../../../server/client.ts\";\nimport { Cmd } from \"../../cmd.ts\";\n\n/**\n * Re-import every configured plugin in a running server.\n *\n * It exists for exactly one case: a **local** plugin edited in place. Nothing in settings changed\n * and no generation moved -- a local source is never copied into the store, so it has none -- and\n * the module registry holds the old module against an unchanged URL. Everything else the runtime\n * notices for itself at the next exchange.\n *\n * There is no local form, and that is not an omission. In a CLI every run is a fresh process, so\n * the load pass happens at startup and a reload would have nothing to do.\n */\nexport default Runtime.handler(\n\tCmd.commands.plugin.commands.reload,\n\tEffect.fn(\"CLI.plugin.reload\")(function* ({ server }) {\n\t\tconst program = Effect.gen(function* () {\n\t\t\tconst rpc = yield* Client.make;\n\t\t\tconst result = yield* rpc[\"plugin.reload\"]({});\n\t\t\t// A reload that failed still reports the set that stayed loaded: the server kept\n\t\t\t// working, which is the whole point of not failing it.\n\t\t\tyield* writeOut(\n\t\t\t\tresult.failure === undefined\n\t\t\t\t\t? `Reloaded ${result.plugins} plugin${result.plugins === 1 ? \"\" : \"s\"}.\\n`\n\t\t\t\t\t: `Reload failed, keeping ${result.plugins} loaded: ${result.failure}\\n`,\n\t\t\t);\n\t\t\tif (result.failure !== undefined) process.exitCode = 1;\n\t\t});\n\n\t\treturn yield* program.pipe(Effect.provide(Client.layer(server)), Effect.scoped, Effect.catch(reportFailure));\n\t}),\n);\n"],"mappings":";;;;;;;;;;;;;;;AAkBA,IAAA,iBAAeA,QACd,IAAI,SAAS,OAAO,SAAS,QAC7B,OAAO,GAAG,mBAAmB,CAAC,CAAC,WAAW,EAAE,UAAU;CAcrD,OAAO,OAbS,OAAO,IAAI,aAAa;EAEvC,MAAM,SAAS,QAAO,OADHC,KAAAA,CACO,gBAAgB,CAAC,CAAC,CAAC;EAG7C,OAAO,SACN,OAAO,YAAY,KAAA,IAChB,YAAY,OAAO,QAAQ,SAAS,OAAO,YAAY,IAAI,KAAK,IAAI,OACpE,0BAA0B,OAAO,QAAQ,WAAW,OAAO,QAAQ,GACvE;EACA,IAAI,OAAO,YAAY,KAAA,GAAW,QAAQ,WAAW;CACtD,CAEoB,CAAC,CAAC,KAAK,OAAO,QAAQC,MAAa,MAAM,CAAC,GAAG,OAAO,QAAQ,OAAO,MAAM,aAAa,CAAC;AAC5G,CAAC,CACF"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { a as resolveTarget, c as withPluginsLock, i as readPlugins, l as writePlugins, o as spellings, r as matching, t as identify } from "./settings-
|
|
1
|
+
import { i as Cmd, t as handler } from "./runtime-CIBm_3RX.mjs";
|
|
2
|
+
import { d as writeOut, i as reportFailure } from "./error-CzUxh0Q9.mjs";
|
|
3
|
+
import { a as resolveTarget, c as withPluginsLock, i as readPlugins, l as writePlugins, o as spellings, r as matching, t as identify } from "./settings-BM_gw7Fm.mjs";
|
|
4
4
|
import { Effect, FileSystem, Option, Path } from "effect";
|
|
5
|
+
import { Global } from "@codeworksh/harness/effect";
|
|
5
6
|
//#region src/cli/cmd/handlers/plugin/remove.ts
|
|
6
7
|
var remove_default = handler(Cmd.commands.plugin.commands.remove, Effect.fn("CLI.plugin.remove")(function* ({ package: reference, global: userWide }) {
|
|
7
8
|
return yield* Effect.gen(function* () {
|
|
8
9
|
const shared = yield* Cmd.spec;
|
|
9
10
|
const path = yield* Path.Path;
|
|
10
11
|
const fs = yield* FileSystem.FileSystem;
|
|
11
|
-
const paths = yield* resolve(Option.isNone(shared.home) ? {} : { home: shared.home.value });
|
|
12
|
+
const paths = yield* Global.resolve(Option.isNone(shared.home) ? {} : { home: shared.home.value });
|
|
12
13
|
const target = yield* resolveTarget(shared, userWide, void 0, false);
|
|
13
14
|
if (!(yield* fs.exists(path.dirname(target.path)))) {
|
|
14
15
|
yield* writeOut(`Plugin "${reference}" is not configured in ${target.path}\n`);
|
|
@@ -33,4 +34,4 @@ var remove_default = handler(Cmd.commands.plugin.commands.remove, Effect.fn("CLI
|
|
|
33
34
|
//#endregion
|
|
34
35
|
export { remove_default as default };
|
|
35
36
|
|
|
36
|
-
//# sourceMappingURL=remove-
|
|
37
|
+
//# sourceMappingURL=remove-DjBJe09T.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-DjBJe09T.mjs","names":["Runtime.handler"],"sources":["../../src/cli/cmd/handlers/plugin/remove.ts"],"sourcesContent":["import { Global } from \"@codeworksh/harness/effect\";\nimport { Effect, FileSystem, Option, Path } from \"effect\";\nimport { Runtime } from \"../../../../framework/runtime.ts\";\nimport { reportFailure } from \"../../../error.ts\";\nimport { writeOut } from \"../../../output.ts\";\nimport { Cmd } from \"../../cmd.ts\";\nimport {\n\tidentify,\n\tmatching,\n\treadPlugins,\n\tresolveTarget,\n\tspellings,\n\twithPluginsLock,\n\twritePlugins,\n} from \"./settings.ts\";\n\nexport default Runtime.handler(\n\tCmd.commands.plugin.commands.remove,\n\tEffect.fn(\"CLI.plugin.remove\")(function* ({ package: reference, global: userWide }) {\n\t\tconst program = Effect.gen(function* () {\n\t\t\tconst shared = yield* Cmd.spec;\n\t\t\tconst path = yield* Path.Path;\n\t\t\tconst fs = yield* FileSystem.FileSystem;\n\t\t\tconst paths = yield* Global.resolve(Option.isNone(shared.home) ? {} : { home: shared.home.value });\n\t\t\tconst target = yield* resolveTarget(shared, userWide, undefined, false);\n\t\t\t// Removing from a directory that is not a project is a read-only no-op. In particular, it\n\t\t\t// must not create the marker that would make this directory shadow a real project later.\n\t\t\tif (!(yield* fs.exists(path.dirname(target.path)))) {\n\t\t\t\tyield* writeOut(`Plugin \"${reference}\" is not configured in ${target.path}\\n`);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst spelled = yield* spellings(reference, path.resolve(\".\"));\n\t\t\tyield* withPluginsLock(\n\t\t\t\ttarget.path,\n\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\tconst { source, plugins } = yield* readPlugins(target.path);\n\t\t\t\t\t// Both the module entry and any configuration written against it: the package it was\n\t\t\t\t\t// added as, the path or version it was written with, and the ID it declares all name\n\t\t\t\t\t// the one plugin being removed.\n\t\t\t\t\tconst entries = yield* identify(plugins, target.path, paths.cache);\n\t\t\t\t\tconst selected = matching(entries, spelled);\n\t\t\t\t\tconst kept = entries.filter((entry) => !selected.has(entry)).map((entry) => entry.value);\n\t\t\t\t\tif (kept.length === plugins.length) {\n\t\t\t\t\t\tyield* writeOut(`Plugin \"${reference}\" is not configured in ${target.path}\\n`);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tyield* writePlugins(target.path, source, kept);\n\t\t\t\t\tconst dropped = plugins.length - kept.length;\n\t\t\t\t\tyield* writeOut(\n\t\t\t\t\t\t`Removed ${dropped} ${dropped === 1 ? \"entry\" : \"entries\"} for \"${reference}\" from ${target.path}\\n`,\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t\t);\n\t\t});\n\n\t\treturn yield* program.pipe(Effect.catch(reportFailure));\n\t}),\n);\n"],"mappings":";;;;;;AAgBA,IAAA,iBAAeA,QACd,IAAI,SAAS,OA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AAK,OAAO,MAAM,aAAa,CAAC;AACvD,CAAC,CACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { i as Cmd, t as handler } from "./runtime-CIBm_3RX.mjs";
|
|
2
|
+
import { d as writeOut, i as reportFailure } from "./error-CzUxh0Q9.mjs";
|
|
3
|
+
import { i as ensure, n as options, o as stop } from "./service-7_FrDOGJ.mjs";
|
|
4
|
+
import { Effect } from "effect";
|
|
5
|
+
//#region src/cli/cmd/handlers/service/restart.ts
|
|
6
|
+
var restart_default = handler(Cmd.commands.service.commands.restart, Effect.fn("CLI.service.restart")(function* ({ host, port }) {
|
|
7
|
+
const options$1 = yield* options(yield* Cmd.spec, {
|
|
8
|
+
host,
|
|
9
|
+
port
|
|
10
|
+
});
|
|
11
|
+
yield* stop(options$1.home);
|
|
12
|
+
const server = yield* ensure({
|
|
13
|
+
...options$1,
|
|
14
|
+
replace: true
|
|
15
|
+
});
|
|
16
|
+
yield* writeOut(`${server.url}\n`);
|
|
17
|
+
}, Effect.catch(reportFailure)));
|
|
18
|
+
//#endregion
|
|
19
|
+
export { restart_default as default };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=restart-CqAQCig7.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"restart-CqAQCig7.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 { Runtime } from \"../../../../framework/runtime.ts\";\nimport { Discovery } from \"../../../../server/discovery.ts\";\nimport { reportFailure } from \"../../../error.ts\";\nimport { writeOut } from \"../../../output.ts\";\nimport { 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"}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { t as harnessOptions } from "./harness-
|
|
1
|
+
import { i as Cmd, t as handler } from "./runtime-CIBm_3RX.mjs";
|
|
2
|
+
import { a as addUsage, c as terminalColumns, d as writeOut, f as layer, l as usage, m as run, o as emptyUsage, p as make, r as renderError, s as header, t as InvalidInputError, u as writeError } from "./error-CzUxh0Q9.mjs";
|
|
3
|
+
import { t as harnessOptions } from "./harness-6d8TlAVk.mjs";
|
|
4
4
|
import { Effect, Exit, Fiber, Option, Queue, Ref, Schema, Stream } from "effect";
|
|
5
|
+
import { EventList, Harness, Sandbox, Session } from "@codeworksh/harness/effect";
|
|
5
6
|
//#region src/cli/cmd/handlers/run.ts
|
|
6
7
|
const initialRenderState = {
|
|
7
8
|
usage: emptyUsage,
|
|
8
9
|
textSeen: false,
|
|
9
10
|
textEndsWithNewline: false
|
|
10
11
|
};
|
|
11
|
-
const isTextDelta = Schema.is(LLMTextDelta);
|
|
12
|
-
const isLLMEnded = Schema.is(LLMEnded);
|
|
13
|
-
const isTurnEnded = Schema.is(TurnEnded);
|
|
12
|
+
const isTextDelta = Schema.is(EventList.LLMTextDelta);
|
|
13
|
+
const isLLMEnded = Schema.is(EventList.LLMEnded);
|
|
14
|
+
const isTurnEnded = Schema.is(EventList.TurnEnded);
|
|
14
15
|
const render = (state, ended) => Effect.fn("CLI.render")(function* (event) {
|
|
15
16
|
if (isTextDelta(event)) {
|
|
16
17
|
yield* writeOut(event.data.delta);
|
|
@@ -39,10 +40,10 @@ const awaitMessage = Effect.fn("CLI.awaitMessage")(function* (ended, messageId)
|
|
|
39
40
|
while ((yield* Queue.take(ended)) !== messageId);
|
|
40
41
|
});
|
|
41
42
|
const selectSandbox = Effect.fn("CLI.selectSandbox")(function* (input) {
|
|
42
|
-
const selection = yield* resolve(input);
|
|
43
|
+
const selection = yield* Sandbox.resolve(input);
|
|
43
44
|
if (selection.created && selection.info !== void 0) {
|
|
44
45
|
const id = selection.info.id;
|
|
45
|
-
yield* Effect.addFinalizer(() => Effect.ignore(stop(id)));
|
|
46
|
+
yield* Effect.addFinalizer(() => Effect.ignore(Sandbox.stop(id)));
|
|
46
47
|
}
|
|
47
48
|
return selection.info;
|
|
48
49
|
});
|
|
@@ -57,11 +58,11 @@ var run_default = handler(Cmd.commands.run, Effect.fn("CLI.run")(function* ({ pr
|
|
|
57
58
|
shared.userConfigDir
|
|
58
59
|
].some(Option.isSome)) return yield* new InvalidInputError({ message: "--home, --database, and --user-config-dir belong on codework serve when using --server" });
|
|
59
60
|
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" });
|
|
60
|
-
const selection = Option.isSome(sandboxId) ? { id:
|
|
61
|
+
const selection = Option.isSome(sandboxId) ? { id: Sandbox.SandboxInstance.ID.make(sandboxId.value) } : {
|
|
61
62
|
driver: Option.getOrElse(sandboxDriver, () => "local"),
|
|
62
63
|
...Option.isNone(sandboxProviderId) ? {} : { providerResourceId: sandboxProviderId.value }
|
|
63
64
|
};
|
|
64
|
-
const hostDir =
|
|
65
|
+
const hostDir = Session.AbsolutePath.make(process.cwd());
|
|
65
66
|
const runtime = {
|
|
66
67
|
...Option.isNone(provider) || Option.isNone(model) ? {} : { model: {
|
|
67
68
|
provider: provider.value,
|
|
@@ -72,10 +73,9 @@ var run_default = handler(Cmd.commands.run, Effect.fn("CLI.run")(function* ({ pr
|
|
|
72
73
|
const remote = Effect.gen(function* () {
|
|
73
74
|
const rpc = yield* make;
|
|
74
75
|
const info = Option.isSome(session) ? yield* rpc["session.configure"]({
|
|
75
|
-
sessionId: ID.make(session.value),
|
|
76
|
+
sessionId: Session.SessionSchema.ID.make(session.value),
|
|
76
77
|
runtime
|
|
77
78
|
}) : yield* rpc["session.create"]({
|
|
78
|
-
title: "CLI",
|
|
79
79
|
runtime,
|
|
80
80
|
...Option.isNone(cwd) ? {} : { directory: cwd.value },
|
|
81
81
|
hostDir,
|
|
@@ -98,14 +98,13 @@ var run_default = handler(Cmd.commands.run, Effect.fn("CLI.run")(function* ({ pr
|
|
|
98
98
|
});
|
|
99
99
|
const program = Effect.gen(function* () {
|
|
100
100
|
let handle;
|
|
101
|
-
if (Option.isSome(session)) handle = yield* attach({
|
|
102
|
-
sessionId: ID.make(session.value),
|
|
101
|
+
if (Option.isSome(session)) handle = yield* Session.attach({
|
|
102
|
+
sessionId: Session.SessionSchema.ID.make(session.value),
|
|
103
103
|
...runtime
|
|
104
104
|
});
|
|
105
105
|
else {
|
|
106
106
|
const selected = yield* selectSandbox(selection);
|
|
107
|
-
handle = yield* create({
|
|
108
|
-
title: "CLI",
|
|
107
|
+
handle = yield* Session.create({
|
|
109
108
|
...runtime,
|
|
110
109
|
...selected === void 0 ? {} : { sandbox: selected },
|
|
111
110
|
...Option.isNone(cwd) ? {} : { directory: cwd.value },
|
|
@@ -136,7 +135,7 @@ var run_default = handler(Cmd.commands.run, Effect.fn("CLI.run")(function* ({ pr
|
|
|
136
135
|
});
|
|
137
136
|
return yield* Effect.gen(function* () {
|
|
138
137
|
if (Option.isSome(server)) return yield* remote.pipe(Effect.provide(layer(server.value)));
|
|
139
|
-
return yield* program.pipe(Effect.provide(layer
|
|
138
|
+
return yield* program.pipe(Effect.provide(Harness.layer(harnessOptions(shared))));
|
|
140
139
|
}).pipe(Effect.scoped, Effect.catch((error) => writeError(renderError(error)).pipe(Effect.andThen(Effect.sync(() => {
|
|
141
140
|
process.exitCode = 1;
|
|
142
141
|
})))));
|
|
@@ -144,4 +143,4 @@ var run_default = handler(Cmd.commands.run, Effect.fn("CLI.run")(function* ({ pr
|
|
|
144
143
|
//#endregion
|
|
145
144
|
export { run_default as default };
|
|
146
145
|
|
|
147
|
-
//# sourceMappingURL=run-
|
|
146
|
+
//# sourceMappingURL=run-BpiW8Wxp.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-BpiW8Wxp.mjs","names":["Runtime.handler","Client.make","Client.run","Client.layer"],"sources":["../../src/cli/cmd/handlers/run.ts"],"sourcesContent":["import { EventList, type EventSchema, Harness, Sandbox, Session } from \"@codeworksh/harness/effect\";\nimport { Effect, Exit, Fiber, Option, Queue, Ref, Schema, Stream } from \"effect\";\nimport { Runtime } from \"../../../framework/runtime.ts\";\nimport { Client } from \"../../../server/client.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 { Cmd } from \"../cmd.ts\";\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 = (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) => ({ ...current, usage: addUsage(current.usage, event.data.message) }));\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});\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* (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\")(function* ({\n\t\tprompt,\n\t\tsession,\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(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\tif (Option.isSome(server) && [shared.home, shared.database, shared.userConfigDir].some(Option.isSome)) {\n\t\t\treturn yield* new InvalidInputError({\n\t\t\t\tmessage: \"--home, --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 = Option.isSome(session)\n\t\t\t\t? yield* rpc[\"session.configure\"]({ sessionId: Session.SessionSchema.ID.make(session.value), runtime })\n\t\t\t\t: yield* rpc[\"session.create\"]({\n\t\t\t\t\t\truntime,\n\t\t\t\t\t\t...(Option.isNone(cwd) ? {} : { directory: cwd.value }),\n\t\t\t\t\t\thostDir,\n\t\t\t\t\t\tsandbox: selection,\n\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.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\tif (info.sandbox !== undefined) yield* writeError(`sandbox-id: ${info.sandbox.id}\\n`);\n\t\t\tyield* Client.run(rpc, { sessionId: info.id, text: prompt }, render(state)).pipe(\n\t\t\t\tEffect.onInterrupt(() =>\n\t\t\t\t\trpc[\"session.interrupt\"]({ sessionId: info.id }).pipe(Effect.timeout(\"5 seconds\"), Effect.ignore),\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.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 selected = yield* selectSandbox(selection);\n\t\t\t\thandle = 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}\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.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\t// The local command joins execution to retain typed error details.\n\t\t\tconst execution = yield* handle\n\t\t\t\t.prompt({ text: prompt, delivery: \"followUp\" })\n\t\t\t\t.pipe(Effect.andThen(handle.resume()), Effect.exit);\n\t\t\tyield* handle.wait();\n\t\t\tif (Exit.isFailure(execution)) return yield* Effect.failCause(execution.cause);\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* finish(renderState, columns);\n\t\t});\n\n\t\tconst execute = Effect.gen(function* () {\n\t\t\tif (Option.isSome(server)) return yield* remote.pipe(Effect.provide(Client.layer(server.value)));\n\t\t\treturn yield* program.pipe(Effect.provide(Harness.layer(harnessOptions(shared))));\n\t\t});\n\t\treturn yield* execute.pipe(\n\t\t\tEffect.scoped,\n\t\t\tEff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AAO,OAAO,OAAO,UAAU,UAAU,KAAK;EAE7E,MAAM,QAAO,OADO,OAAO,KAAK,EAAA,CACd,GAAG,EAAE;EACvB,IAAI,SAAS,KAAA,GAAW,OAAO,aAAa,OAAO,KAAK,MAAM,EAAE;EAChE,OAAO,MAAM,UAAU,OAAO;EAC9B,OAAO,OAAO,aAAa,OAAO;CACnC,CAAC;CAMD,OAAO,OAJS,OAAO,IAAI,aAAa;EACvC,IAAI,OAAO,OAAO,MAAM,GAAG,OAAO,OAAO,OAAO,KAAK,OAAO,QAAQC,MAAa,OAAO,KAAK,CAAC,CAAC;EAC/F,OAAO,OAAO,QAAQ,KAAK,OAAO,QAAQ,QAAQ,MAAM,eAAe,MAAM,CAAC,CAAC,CAAC;CACjF,CACoB,CAAC,CAAC,KACrB,OAAO,QACP,OAAO,OAAO,UACb,WAAW,YAAY,KAAK,CAAC,CAAC,CAAC,KAC9B,OAAO,QACN,OAAO,WAAW;EACjB,QAAQ,WAAW;CACpB,CAAC,CACF,CACD,CACD,CACD;AACD,CAAC,CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Effect, Schema } from "effect";
|
|
2
2
|
import { Model } from "@codeworksh/aikit";
|
|
3
|
-
import { Argument, Command, Flag } from "effect/
|
|
3
|
+
import { Argument, Command, Flag } from "effect/cli";
|
|
4
4
|
//#region src/framework/spec.ts
|
|
5
5
|
function make(name, options = {}) {
|
|
6
6
|
let spec = Command.make(name, options.params ?? {}).pipe(Command.withSharedFlags(options.shared ?? {}));
|
|
@@ -26,9 +26,17 @@ const thinkingLevels = Object.values(Model.ThinkingLevelEnum);
|
|
|
26
26
|
const AuthParams = {
|
|
27
27
|
openaiCodex: Flag.Boolean("openai-codex").pipe(Flag.withDescription("Use OpenAI Codex OAuth"), Flag.withDefault(false)),
|
|
28
28
|
githubCopilot: Flag.Boolean("github-copilot").pipe(Flag.withDescription("Use GitHub Copilot OAuth (device flow)"), Flag.withDefault(false)),
|
|
29
|
-
server: Flag.String("server").pipe(Flag.withDescription("RPC server URL (ws://host:port/rpc)"), Flag.optional),
|
|
29
|
+
server: Flag.String("server").pipe(Flag.withDescription("RPC server URL (ws://host:port/rpc/v1)"), Flag.optional),
|
|
30
30
|
authFile: Flag.String("auth-file").pipe(Flag.withDescription("Credential file (defaults to <home>/aikit/auth.json)"), Flag.optional)
|
|
31
31
|
};
|
|
32
|
+
/** Where the background server binds when `tui` or `service` has to start one. */
|
|
33
|
+
const ServerAddress = {
|
|
34
|
+
host: Flag.String("host").pipe(Flag.withDescription("Host interface the background server binds"), Flag.withDefault("127.0.0.1")),
|
|
35
|
+
port: Flag.Int("port").pipe(Flag.withSchema(Schema.Int.check(Schema.isBetween({
|
|
36
|
+
minimum: 0,
|
|
37
|
+
maximum: 65535
|
|
38
|
+
}))), Flag.withDescription("Port the background server listens on"), Flag.withDefault(7433))
|
|
39
|
+
};
|
|
32
40
|
const JsonFlag = Flag.Boolean("json").pipe(Flag.withDescription("Print machine-readable output"), Flag.withDefault(false));
|
|
33
41
|
const Cmd = make("codework", {
|
|
34
42
|
description: "CodeWork Command Line Interface",
|
|
@@ -65,7 +73,7 @@ const Cmd = make("codework", {
|
|
|
65
73
|
description: "Sign in with a device code, no local port"
|
|
66
74
|
},
|
|
67
75
|
{
|
|
68
|
-
command: "codework auth login --openai-codex --server ws://127.0.0.1:7433/rpc",
|
|
76
|
+
command: "codework auth login --openai-codex --server ws://127.0.0.1:7433/rpc/v1",
|
|
69
77
|
description: "Sign in the running server"
|
|
70
78
|
}
|
|
71
79
|
]
|
|
@@ -105,7 +113,7 @@ const Cmd = make("codework", {
|
|
|
105
113
|
make("run", {
|
|
106
114
|
description: "Start or continue an agent session",
|
|
107
115
|
params: {
|
|
108
|
-
server: Flag.String("server").pipe(Flag.withDescription("RPC server URL (ws://host:port/rpc)"), Flag.optional),
|
|
116
|
+
server: Flag.String("server").pipe(Flag.withDescription("RPC server URL (ws://host:port/rpc/v1)"), Flag.optional),
|
|
109
117
|
prompt: Argument.String("prompt").pipe(Argument.withDescription("Prompt for the agent")),
|
|
110
118
|
session: Flag.String("session").pipe(Flag.withAlias("s"), Flag.withDescription("Continue an existing session"), Flag.optional),
|
|
111
119
|
cwd: Flag.String("cwd").pipe(Flag.withAlias("C"), Flag.withDescription("Working directory for a new session"), Flag.optional),
|
|
@@ -139,6 +147,21 @@ const Cmd = make("codework", {
|
|
|
139
147
|
}
|
|
140
148
|
]
|
|
141
149
|
}),
|
|
150
|
+
make("tui", {
|
|
151
|
+
description: "Launch the CodeWork terminal UI against the background server",
|
|
152
|
+
params: {
|
|
153
|
+
server: Flag.String("server").pipe(Flag.withDescription("RPC server URL to use instead of the background server (ws://host:port/rpc/v1)"), Flag.optional),
|
|
154
|
+
...ServerAddress,
|
|
155
|
+
args: Argument.variadic(Argument.String("args").pipe(Argument.withDescription("Arguments forwarded to the terminal UI")))
|
|
156
|
+
},
|
|
157
|
+
examples: [{
|
|
158
|
+
command: "codework tui",
|
|
159
|
+
description: "Start or reuse the local server and open the terminal UI"
|
|
160
|
+
}, {
|
|
161
|
+
command: "codework tui --server ws://127.0.0.1:7433/rpc/v1",
|
|
162
|
+
description: "Attach the terminal UI to a server you started yourself"
|
|
163
|
+
}]
|
|
164
|
+
}),
|
|
142
165
|
make("serve", {
|
|
143
166
|
description: "Start the CodeWork RPC server",
|
|
144
167
|
params: {
|
|
@@ -146,7 +169,8 @@ const Cmd = make("codework", {
|
|
|
146
169
|
port: Flag.Int("port").pipe(Flag.withSchema(Schema.Int.check(Schema.isBetween({
|
|
147
170
|
minimum: 0,
|
|
148
171
|
maximum: 65535
|
|
149
|
-
}))), Flag.withDescription("Port to listen on (0 for an ephemeral port)"), Flag.withDefault(7433))
|
|
172
|
+
}))), Flag.withDescription("Port to listen on (0 for an ephemeral port)"), Flag.withDefault(7433)),
|
|
173
|
+
service: Flag.Boolean("service").pipe(Flag.withDescription("Run as the background server `codework tui` manages, logging to <home>/log/server.log"), Flag.withDefault(false))
|
|
150
174
|
},
|
|
151
175
|
examples: [{
|
|
152
176
|
command: "codework serve",
|
|
@@ -156,6 +180,21 @@ const Cmd = make("codework", {
|
|
|
156
180
|
description: "Choose an available local port"
|
|
157
181
|
}]
|
|
158
182
|
}),
|
|
183
|
+
make("service", {
|
|
184
|
+
description: "Manage the background server",
|
|
185
|
+
commands: [
|
|
186
|
+
make("start", {
|
|
187
|
+
description: "Start the background server",
|
|
188
|
+
params: ServerAddress
|
|
189
|
+
}),
|
|
190
|
+
make("restart", {
|
|
191
|
+
description: "Restart the background server",
|
|
192
|
+
params: ServerAddress
|
|
193
|
+
}),
|
|
194
|
+
make("status", { description: "Show background server status" }),
|
|
195
|
+
make("stop", { description: "Stop the background server" })
|
|
196
|
+
]
|
|
197
|
+
}),
|
|
159
198
|
make("session", {
|
|
160
199
|
description: "Manage sessions",
|
|
161
200
|
commands: [make("link", {
|
|
@@ -304,6 +343,13 @@ const Cmd = make("codework", {
|
|
|
304
343
|
description: "Download the catalog now"
|
|
305
344
|
}]
|
|
306
345
|
})]
|
|
346
|
+
}),
|
|
347
|
+
make("acp", {
|
|
348
|
+
description: "Start the CodeWork Agent Client Protocol (ACP) server over stdio",
|
|
349
|
+
examples: [{
|
|
350
|
+
command: "codework acp",
|
|
351
|
+
description: "Start the ACP server on stdio"
|
|
352
|
+
}]
|
|
307
353
|
})
|
|
308
354
|
]
|
|
309
355
|
});
|
|
@@ -348,4 +394,4 @@ function provide(node, handlers) {
|
|
|
348
394
|
//#endregion
|
|
349
395
|
export { Cmd as i, handlers as n, run as r, handler as t };
|
|
350
396
|
|
|
351
|
-
//# sourceMappingURL=runtime-
|
|
397
|
+
//# sourceMappingURL=runtime-CIBm_3RX.mjs.map
|