@codeworksh/cli 0.9.0-canary.167.1.g6ddcc8db → 0.9.0-canary.169.1.g71f19429
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-CmtcmhuX.mjs → acp-Cw5Ljayx.mjs} +6 -5
- package/acp-Cw5Ljayx.mjs.map +1 -0
- package/{add-Bmholf85.mjs → add-Be7-HfBj.mjs} +2 -2
- package/{add-Bmholf85.mjs.map → add-Be7-HfBj.mjs.map} +1 -1
- package/{add-Ct20ZUEC.mjs → add-D2ly9-x3.mjs} +3 -3
- package/{add-Ct20ZUEC.mjs.map → add-D2ly9-x3.mjs.map} +1 -1
- package/{catalog-BJScfJLW.mjs → catalog-Dzi9__Rq.mjs} +2 -2
- package/{catalog-BJScfJLW.mjs.map → catalog-Dzi9__Rq.mjs.map} +1 -1
- package/categories-DD30aGHU.mjs +19 -0
- package/categories-DD30aGHU.mjs.map +1 -0
- package/{check-ki1450h-.mjs → check-DzxfN43i.mjs} +2 -2
- package/{check-ki1450h-.mjs.map → check-DzxfN43i.mjs.map} +1 -1
- package/{connect-KX-A0EzQ.mjs → connect-AqacTFrV.mjs} +5 -5
- package/{connect-KX-A0EzQ.mjs.map → connect-AqacTFrV.mjs.map} +1 -1
- package/{control-Cotypk4e.mjs → control-CFQeKIKx.mjs} +4 -4
- package/{control-Cotypk4e.mjs.map → control-CFQeKIKx.mjs.map} +1 -1
- package/create-dxNGBbiQ.mjs +35 -0
- package/create-dxNGBbiQ.mjs.map +1 -0
- package/{devices-BcuQ11QF.mjs → devices-DNzXKhNy.mjs} +3 -3
- package/{devices-BcuQ11QF.mjs.map → devices-DNzXKhNy.mjs.map} +1 -1
- package/disconnect-BcwEk1sG.mjs +19 -0
- package/disconnect-BcwEk1sG.mjs.map +1 -0
- package/disconnect-CHEHx_ic.mjs +2 -0
- package/{disconnect-CCI1DLJ0.mjs → disconnect-V4MnDMkF.mjs} +4 -4
- package/{disconnect-CCI1DLJ0.mjs.map → disconnect-V4MnDMkF.mjs.map} +1 -1
- package/discover-DAP4t5Kb.mjs +35 -0
- package/discover-DAP4t5Kb.mjs.map +1 -0
- package/{discovery-D2ftXE5a.mjs → discovery-C6H7dCHz.mjs} +2 -2
- package/{discovery-D2ftXE5a.mjs.map → discovery-C6H7dCHz.mjs.map} +1 -1
- package/{fork-DkYRL_nQ.mjs → fork-TUz05qSe.mjs} +3 -3
- package/{fork-DkYRL_nQ.mjs.map → fork-TUz05qSe.mjs.map} +1 -1
- package/{identity-Llk4K_8w.mjs → identity-fLl347sJ.mjs} +2 -2
- package/{identity-Llk4K_8w.mjs.map → identity-fLl347sJ.mjs.map} +1 -1
- package/index.mjs +49 -39
- package/index.mjs.map +1 -1
- package/{install-hs3tvWLA.mjs → install-BtoWHZoI.mjs} +2 -2
- package/{install-hs3tvWLA.mjs.map → install-BtoWHZoI.mjs.map} +1 -1
- package/{link-BzFGtDKJ.mjs → link-Cd6T22_n.mjs} +3 -3
- package/{link-BzFGtDKJ.mjs.map → link-Cd6T22_n.mjs.map} +1 -1
- package/{list-sLzs2Y7w.mjs → list-Bn5CvS1y.mjs} +3 -3
- package/{list-sLzs2Y7w.mjs.map → list-Bn5CvS1y.mjs.map} +1 -1
- package/list-C29G-xrA.mjs +27 -0
- package/list-C29G-xrA.mjs.map +1 -0
- package/{list-D1c5uzCc.mjs → list-CdS1_gFF.mjs} +2 -2
- package/{list-D1c5uzCc.mjs.map → list-CdS1_gFF.mjs.map} +1 -1
- package/{list-DhL_z5v2.mjs → list-DAA92mUG.mjs} +3 -3
- package/{list-DhL_z5v2.mjs.map → list-DAA92mUG.mjs.map} +1 -1
- package/{list-Dt0_ol5P.mjs → list-MiZ6rD_w.mjs} +3 -3
- package/{list-Dt0_ol5P.mjs.map → list-MiZ6rD_w.mjs.map} +1 -1
- package/{login-BxiN8frI.mjs → login-C_tBeHg6.mjs} +3 -3
- package/{login-BxiN8frI.mjs.map → login-C_tBeHg6.mjs.map} +1 -1
- package/login-D0EMtnh2.mjs +26 -0
- package/login-D0EMtnh2.mjs.map +1 -0
- package/{login-S-2L5YYB.mjs → login-Q_ezdpon.mjs} +3 -3
- package/{login-S-2L5YYB.mjs.map → login-Q_ezdpon.mjs.map} +1 -1
- package/{logout-BeMvfZkG.mjs → logout-BjL1W-0I.mjs} +3 -3
- package/{logout-BeMvfZkG.mjs.map → logout-BjL1W-0I.mjs.map} +1 -1
- package/{logout-CKcRACIf.mjs → logout-E_dRjl1L.mjs} +3 -3
- package/{logout-CKcRACIf.mjs.map → logout-E_dRjl1L.mjs.map} +1 -1
- package/package-Y0eg0qm4.mjs +6 -0
- package/package-Y0eg0qm4.mjs.map +1 -0
- package/package.json +4 -4
- package/{pair-BhGzBBV8.mjs → pair-BBneOJZJ.mjs} +3 -3
- package/{pair-BhGzBBV8.mjs.map → pair-BBneOJZJ.mjs.map} +1 -1
- package/{providers-DdBYxi9t.mjs → providers-BYnMGDs7.mjs} +3 -3
- package/{providers-DdBYxi9t.mjs.map → providers-BYnMGDs7.mjs.map} +1 -1
- package/reconnect-BKpud0ma.mjs +2 -0
- package/{refresh-BgQfD2zv.mjs → refresh-CvE_f1Fa.mjs} +3 -3
- package/{refresh-BgQfD2zv.mjs.map → refresh-CvE_f1Fa.mjs.map} +1 -1
- package/{refresh-Cy6abMk_.mjs → refresh-Dy9kI2El.mjs} +3 -3
- package/{refresh-Cy6abMk_.mjs.map → refresh-Dy9kI2El.mjs.map} +1 -1
- package/{relay-BmHXs1yg.mjs → relay-DbZQ4i7J.mjs} +3 -3
- package/{relay-BmHXs1yg.mjs.map → relay-DbZQ4i7J.mjs.map} +1 -1
- package/{relink-Dxg1kstB.mjs → relink-DxftNq9n.mjs} +3 -3
- package/{relink-Dxg1kstB.mjs.map → relink-DxftNq9n.mjs.map} +1 -1
- package/{reload-CUyG343t.mjs → reload-DRp3UlHQ.mjs} +3 -3
- package/{reload-CUyG343t.mjs.map → reload-DRp3UlHQ.mjs.map} +1 -1
- package/{remove-BXmNNX2f.mjs → remove-C0e5sHqb.mjs} +3 -3
- package/{remove-BXmNNX2f.mjs.map → remove-C0e5sHqb.mjs.map} +1 -1
- package/{remove-CJ__oofS.mjs → remove-CdcoheOp.mjs} +2 -2
- package/{remove-CJ__oofS.mjs.map → remove-CdcoheOp.mjs.map} +1 -1
- package/remove-y_AI5IuH.mjs +22 -0
- package/remove-y_AI5IuH.mjs.map +1 -0
- package/{restart-CMDZZJ4N.mjs → restart-BcpKCYwQ.mjs} +4 -4
- package/{restart-CMDZZJ4N.mjs.map → restart-BcpKCYwQ.mjs.map} +1 -1
- package/{revoke-DigrkMoL.mjs → revoke-DoMHa1vL.mjs} +3 -3
- package/{revoke-DigrkMoL.mjs.map → revoke-DoMHa1vL.mjs.map} +1 -1
- package/{run-BN0xfxh_.mjs → run-DNbme1W_.mjs} +8 -5
- package/run-DNbme1W_.mjs.map +1 -0
- package/{runtime-Q4G4z83G.mjs → runtime-CyXV7HH_.mjs} +152 -9
- package/runtime-CyXV7HH_.mjs.map +1 -0
- package/{serve-CfjS09-r.mjs → serve-CGPp3kyd.mjs} +27 -11
- package/serve-CGPp3kyd.mjs.map +1 -0
- package/service-C1UBpOCn.mjs +1718 -0
- package/service-C1UBpOCn.mjs.map +1 -0
- package/{service-B0O4PjbL.mjs → service-YVNwFMNf.mjs} +2 -2
- package/{service-B0O4PjbL.mjs.map → service-YVNwFMNf.mjs.map} +1 -1
- package/{shared-C2sMimyK.mjs → shared-CDJQxUb9.mjs} +4 -4
- package/{shared-C2sMimyK.mjs.map → shared-CDJQxUb9.mjs.map} +1 -1
- package/shared-CXbDdgs4.mjs +223 -0
- package/shared-CXbDdgs4.mjs.map +1 -0
- package/{shared-C4j4rGe4.mjs → shared-D_MVXtOf.mjs} +3 -3
- package/{shared-C4j4rGe4.mjs.map → shared-D_MVXtOf.mjs.map} +1 -1
- package/{start-DbCTFswo.mjs → start-Dky5Iihf.mjs} +4 -4
- package/{start-DbCTFswo.mjs.map → start-Dky5Iihf.mjs.map} +1 -1
- package/status-B29jKo_s.mjs +23 -0
- package/status-B29jKo_s.mjs.map +1 -0
- package/{status-CR_E6RiI.mjs → status-BoTZqXwd.mjs} +3 -3
- package/{status-CR_E6RiI.mjs.map → status-BoTZqXwd.mjs.map} +1 -1
- package/{status-Dcbdl6Sv.mjs → status-CdAZIIEi.mjs} +4 -4
- package/{status-Dcbdl6Sv.mjs.map → status-CdAZIIEi.mjs.map} +1 -1
- package/{stop-ML5Yeo_s.mjs → stop-BCAMcHem.mjs} +4 -4
- package/{stop-ML5Yeo_s.mjs.map → stop-BCAMcHem.mjs.map} +1 -1
- package/{update-BK_LdUUv.mjs → update-mWc5cR7q.mjs} +2 -2
- package/{update-BK_LdUUv.mjs.map → update-mWc5cR7q.mjs.map} +1 -1
- package/acp-CmtcmhuX.mjs.map +0 -1
- package/disconnect-DKi3PmC2.mjs +0 -2
- package/package-D_TWKUKk.mjs +0 -6
- package/package-D_TWKUKk.mjs.map +0 -1
- package/reconnect-DgUK2fwU.mjs +0 -2
- package/run-BN0xfxh_.mjs.map +0 -1
- package/runtime-Q4G4z83G.mjs.map +0 -1
- package/serve-CfjS09-r.mjs.map +0 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { a as reportFailure, m as writeOut } from "./error-BsI8iNna.mjs";
|
|
2
|
+
import { i as Cmd, t as handler } from "./runtime-CyXV7HH_.mjs";
|
|
3
|
+
import { i as withConnectApi, r as printJson } from "./shared-CXbDdgs4.mjs";
|
|
4
|
+
import { Effect, Option } from "effect";
|
|
5
|
+
//#region src/cli/cmd/handlers/connect/discover.ts
|
|
6
|
+
var discover_default = handler(Cmd.commands.connect.commands.discover, Effect.fn("CLI.connect.discover")(function* ({ query, kind, category, refresh, server, json }) {
|
|
7
|
+
return yield* withConnectApi(server, (api) => Effect.gen(function* () {
|
|
8
|
+
const result = yield* api.catalog({
|
|
9
|
+
query: Option.getOrUndefined(query),
|
|
10
|
+
kind: Option.getOrUndefined(kind),
|
|
11
|
+
category: Option.getOrUndefined(category),
|
|
12
|
+
refresh
|
|
13
|
+
});
|
|
14
|
+
if (json) {
|
|
15
|
+
yield* printJson(result);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (result.connectors.length === 0) {
|
|
19
|
+
yield* writeOut("No matching connectors found.\n");
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
for (const c of result.connectors) {
|
|
23
|
+
const auths = [
|
|
24
|
+
...c.auth.oauth ? ["oauth"] : [],
|
|
25
|
+
...c.auth.apikey ? ["apikey"] : [],
|
|
26
|
+
...c.auth.env ? ["env"] : []
|
|
27
|
+
].join(", ");
|
|
28
|
+
yield* writeOut(`${c.id.padEnd(20)} ${c.name.padEnd(18)} [${c.kinds.join(",")}] (${auths}) ${c.description}\n`);
|
|
29
|
+
}
|
|
30
|
+
})).pipe(Effect.catch(reportFailure));
|
|
31
|
+
}));
|
|
32
|
+
//#endregion
|
|
33
|
+
export { discover_default as default };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=discover-DAP4t5Kb.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discover-DAP4t5Kb.mjs","names":["Runtime.handler"],"sources":["../../src/cli/cmd/handlers/connect/discover.ts"],"sourcesContent":["import { Effect, Option } from \"effect\";\nimport * as Runtime from \"../../../../framework/runtime.ts\";\nimport { reportFailure } from \"../../../error.ts\";\nimport { writeOut } from \"../../../output.ts\";\nimport { Cmd } from \"../../cmd.ts\";\nimport { printJson, withConnectApi } from \"./shared.ts\";\n\nexport default Runtime.handler(\n\tCmd.commands.connect.commands.discover,\n\tEffect.fn(\"CLI.connect.discover\")(function* ({ query, kind, category, refresh, server, json }) {\n\t\tconst program = withConnectApi(server, (api) =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst result = yield* api.catalog({\n\t\t\t\t\tquery: Option.getOrUndefined(query),\n\t\t\t\t\tkind: Option.getOrUndefined(kind),\n\t\t\t\t\tcategory: Option.getOrUndefined(category),\n\t\t\t\t\trefresh,\n\t\t\t\t});\n\t\t\t\tif (json) {\n\t\t\t\t\tyield* printJson(result);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (result.connectors.length === 0) {\n\t\t\t\t\tyield* writeOut(\"No matching connectors found.\\n\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tfor (const c of result.connectors) {\n\t\t\t\t\tconst auths = [\n\t\t\t\t\t\t...(c.auth.oauth ? [\"oauth\"] : []),\n\t\t\t\t\t\t...(c.auth.apikey ? [\"apikey\"] : []),\n\t\t\t\t\t\t...(c.auth.env ? [\"env\"] : []),\n\t\t\t\t\t].join(\", \");\n\t\t\t\t\tyield* writeOut(\n\t\t\t\t\t\t`${c.id.padEnd(20)} ${c.name.padEnd(18)} [${c.kinds.join(\",\")}] (${auths}) ${c.description}\\n`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\t\treturn yield* program.pipe(Effect.catch(reportFailure));\n\t}),\n);\n"],"mappings":";;;;;AAOA,IAAA,mBAAeA,QACd,IAAI,SAAS,QAAQ,SAAS,UAC9B,OAAO,GAAG,sBAAsB,CAAC,CAAC,WAAW,EAAE,OAAO,MAAM,UAAU,SAAS,QAAQ,QAAQ;CA6B9F,OAAO,OA5BS,eAAe,SAAS,QACvC,OAAO,IAAI,aAAa;EACvB,MAAM,SAAS,OAAO,IAAI,QAAQ;GACjC,OAAO,OAAO,eAAe,KAAK;GAClC,MAAM,OAAO,eAAe,IAAI;GAChC,UAAU,OAAO,eAAe,QAAQ;GACxC;EACD,CAAC;EACD,IAAI,MAAM;GACT,OAAO,UAAU,MAAM;GACvB;EACD;EACA,IAAI,OAAO,WAAW,WAAW,GAAG;GACnC,OAAO,SAAS,iCAAiC;GACjD;EACD;EACA,KAAK,MAAM,KAAK,OAAO,YAAY;GAClC,MAAM,QAAQ;IACb,GAAI,EAAE,KAAK,QAAQ,CAAC,OAAO,IAAI,CAAC;IAChC,GAAI,EAAE,KAAK,SAAS,CAAC,QAAQ,IAAI,CAAC;IAClC,GAAI,EAAE,KAAK,MAAM,CAAC,KAAK,IAAI,CAAC;GAC7B,CAAC,CAAC,KAAK,IAAI;GACX,OAAO,SACN,GAAG,EAAE,GAAG,OAAO,EAAE,EAAE,GAAG,EAAE,KAAK,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,KAAK,GAAG,EAAE,MAAM,MAAM,KAAK,EAAE,YAAY,GAC9F;EACD;CACD,CAAC,CAEkB,CAAC,CAAC,KAAK,OAAO,MAAM,aAAa,CAAC;AACvD,CAAC,CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { g as make, h as layer } from "./error-BsI8iNna.mjs";
|
|
2
2
|
import { i as read, n as file, r as log, t as command } from "./registration-C6yiv31r.mjs";
|
|
3
|
-
import { n as current } from "./identity-
|
|
3
|
+
import { n as current } from "./identity-fLl347sJ.mjs";
|
|
4
4
|
import { Effect, FileSystem, Layer, Option, Schedule, Schema } from "effect";
|
|
5
5
|
import { ChildProcess, ChildProcessSpawner } from "effect/process";
|
|
6
6
|
//#region src/server/health.ts
|
|
@@ -171,4 +171,4 @@ const spawn = (options) => Effect.gen(function* () {
|
|
|
171
171
|
//#endregion
|
|
172
172
|
export { ensure as n, stop as r, discover as t };
|
|
173
173
|
|
|
174
|
-
//# sourceMappingURL=discovery-
|
|
174
|
+
//# sourceMappingURL=discovery-C6H7dCHz.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery-D2ftXE5a.mjs","names":["Client.layer","Client.make","Registration.read","Health.probe","Registration.file","log","Registration.log","Registration.command"],"sources":["../../src/server/health.ts","../../src/server/discovery.ts"],"sourcesContent":["import { Effect, Layer } from \"effect\";\nimport * as Client from \"./client.ts\";\n\n/**\n * One `server.info` call, with the answer normalized to `undefined` for every\n * way a server can fail to answer: unreachable, slow, refusing the token, or\n * speaking a different protocol. A health check that throws where it should say\n * \"no\" would make every caller wrap it in a catch.\n */\nexport const probe = (server: Client.Target) =>\n\tEffect.gen(function* () {\n\t\tconst context = yield* Layer.build(Client.layer(server)).pipe(Effect.orElseSucceed(() => undefined));\n\t\tif (context === undefined) return undefined;\n\t\treturn yield* Effect.gen(function* () {\n\t\t\tconst rpc = yield* Client.make;\n\t\t\treturn yield* rpc[\"server.info\"]({}).pipe(Effect.timeout(\"1 second\"));\n\t\t}).pipe(\n\t\t\tEffect.provideContext(context),\n\t\t\tEffect.orElseSucceed(() => undefined),\n\t\t);\n\t}).pipe(Effect.scoped);\n","import { type Duration, Effect, FileSystem, Option, Schedule, Schema } from \"effect\";\nimport { ChildProcess, ChildProcessSpawner } from \"effect/process\";\nimport * as Health from \"./health.ts\";\nimport * as Identity from \"./identity.ts\";\nimport * as Registration from \"./registration.ts\";\n\n/** A server a client can connect to, the process and port behind it, and the token it takes. */\nexport interface Endpoint {\n\treadonly url: string;\n\treadonly pid: number;\n\treadonly port: number;\n\treadonly token: string;\n}\n\n/** A managed server could not be produced, in the words the CLI prints. */\nclass ServerStartError extends Schema.TaggedError<ServerStartError>()(\"Discovery.ServerStartError\", {\n\tmessage: Schema.String,\n}) {}\n\nexport interface Options {\n\t/** The CodeWork home whose `service.json` names the server. */\n\treadonly home: string;\n\t/** The home's log directory, where a background server writes `server.log`. */\n\treadonly log: string;\n\treadonly host: string;\n\treadonly port: number;\n\t/** Server-owned flags placed before `serve`. */\n\treadonly args: ReadonlyArray<string>;\n}\n\nconst START_TIMEOUT = \"20 seconds\";\nconst RACE_GRACE = \"2 seconds\";\nconst STOP_TIMEOUT = \"5 seconds\";\n\nconst remove = (path: string) =>\n\tEffect.gen(function* () {\n\t\tconst fs = yield* FileSystem.FileSystem;\n\t\tyield* fs.remove(path);\n\t}).pipe(Effect.ignore);\n\n/** Whether `pid` is a running process. EPERM means it exists but belongs to someone else. */\nconst alive = (pid: number) =>\n\tEffect.try({ try: () => process.kill(pid, 0), catch: (error) => (error as NodeJS.ErrnoException).code }).pipe(\n\t\tEffect.as(true),\n\t\tEffect.catch((code) => Effect.succeed(code === \"EPERM\")),\n\t);\n\n/** Whether `pid` exits within `timeout`. */\nconst exits = (pid: number, timeout: typeof STOP_TIMEOUT) =>\n\talive(pid).pipe(\n\t\tEffect.repeat({ while: (running) => running, schedule: Schedule.spaced(\"50 millis\") }),\n\t\tEffect.timeoutOption(timeout),\n\t\tEffect.map(Option.isSome),\n\t);\n\n/**\n * The registered server, with `live` set when the process answering its endpoint\n * is the one that registered. The file is a hint, never proof: a different server\n * on a reused port must not pass for it.\n */\nconst registered = (path: string) =>\n\tEffect.gen(function* () {\n\t\tconst info = yield* Registration.read(path);\n\t\tif (info === undefined) return undefined;\n\t\tconst live = yield* Health.probe(info);\n\t\treturn { info, live: live?.pid === info.pid ? live : undefined };\n\t});\n\nconst endpoint = (info: Registration.Info): Endpoint => ({\n\turl: info.url,\n\tpid: info.pid,\n\tport: info.port,\n\ttoken: info.token,\n});\n\n/** The running server registered for `home`, with the build it reports. */\nexport const discover = (home: string) =>\n\tregistered(Registration.file(home)).pipe(\n\t\tEffect.map((found) =>\n\t\t\tfound?.live === undefined ? undefined : { ...endpoint(found.info), version: found.live.version },\n\t\t),\n\t);\n\n/**\n * Stop the server registered for `home`, returning it, or undefined when none\n * answers. Only a server that confirms it is the registrant is signalled: a pid\n * on file may since have been reused by an unrelated process.\n */\nexport const stop = (home: string) =>\n\tEffect.gen(function* () {\n\t\tconst path = Registration.file(home);\n\t\tconst found = yield* registered(path);\n\t\tif (found === undefined) return undefined;\n\t\tif (found.live === undefined) {\n\t\t\tif (!(yield* alive(found.info.pid))) yield* remove(path);\n\t\t\treturn undefined;\n\t\t}\n\t\tyield* terminate(path, found.info.pid);\n\t\treturn endpoint(found.info);\n\t});\n\n/**\n * Ensure a healthy local server for `home`: reuse the registered one, replace it\n * when `replace` is set and it runs a different build, or start a background one.\n *\n * The background server is detached and outlives this caller, so the next\n * invocation reuses it. When two callers race, only the contender that binds the\n * port registers; the loser exits and both adopt the winner, because a caller\n * only ever believes a registration it can confirm over the wire.\n */\nexport const ensure = (options: Options & { readonly replace: boolean }) =>\n\tEffect.gen(function* () {\n\t\tconst path = Registration.file(options.home);\n\t\tconst found = yield* registered(path);\n\t\tif (found?.live !== undefined) {\n\t\t\tif (!options.replace || found.live.version === Identity.current.version) return endpoint(found.info);\n\t\t\tyield* terminate(path, found.info.pid);\n\t\t} else {\n\t\t\t// A file nothing answers for, left by a crash, must not mislead the next caller.\n\t\t\tif (found !== undefined && !(yield* alive(found.info.pid))) yield* remove(path);\n\t\t}\n\t\treturn yield* start(path, options);\n\t});\n\n/** The registered server once it answers, polled every 200ms for up to `timeout`. */\nconst ready = (path: string, timeout: Duration.Input, pending: Effect.Effect<boolean>) =>\n\tEffect.gen(function* () {\n\t\tconst next = yield* registered(path);\n\t\tif (next?.live !== undefined) return Option.some(endpoint(next.info));\n\t\t// A live registrant that does not answer yet is another caller's server starting up.\n\t\tconst waiting = (yield* pending) || (next !== undefined && (yield* alive(next.info.pid)));\n\t\treturn waiting ? Option.none() : yield* Effect.fail(\"exited\" as const);\n\t}).pipe(\n\t\tEffect.repeat({ until: Option.isSome, schedule: Schedule.spaced(\"200 millis\") }),\n\t\tEffect.timeoutOption(timeout),\n\t\tEffect.map(Option.flatten),\n\t\tEffect.orElseSucceed(() => Option.none<Endpoint>()),\n\t);\n\n/**\n * Start a background server and wait for it to register, quoting the reason\n * from its log when it cannot.\n *\n * The contender stays tied to this scope until it is the server adopted: a\n * timeout, an interrupt, or another caller winning the race stops it rather than\n * leaving an unmanaged server behind.\n */\nconst start = (path: string, options: Options) =>\n\tEffect.gen(function* () {\n\t\tconst contender = yield* spawn(options);\n\t\tconst won = yield* ready(path, START_TIMEOUT, contender.isRunning.pipe(Effect.orElseSucceed(() => false)));\n\t\t// A contender that lost the bind race exits before the winner may have filed its\n\t\t// registration; give the winner a moment before calling the start a failure.\n\t\tconst server = Option.isSome(won) ? won : yield* ready(path, RACE_GRACE, Effect.succeed(true));\n\t\tif (Option.isSome(server)) {\n\t\t\tif (server.value.pid === contender.pid) yield* contender.unref.pipe(Effect.asVoid);\n\t\t\treturn server.value;\n\t\t}\n\n\t\tconst log = Registration.log(options.log);\n\t\tconst reason = yield* lastLine(log);\n\t\treturn yield* new ServerStartError({\n\t\t\tmessage: [\n\t\t\t\t`could not start a CodeWork server on ${options.host}:${options.port}`,\n\t\t\t\t...(reason === undefined ? [] : [`reason: ${reason}`]),\n\t\t\t\t`log: ${log}`,\n\t\t\t\t\"hint: pass --port to use another port\",\n\t\t\t].join(\"\\n\"),\n\t\t});\n\t}).pipe(Effect.scoped);\n\n/** Ask `pid` to shut down, escalating to SIGKILL, and retire its registration. */\nconst terminate = (path: string, pid: number) =>\n\tEffect.gen(function* () {\n\t\tconst signal = (name: NodeJS.Signals) => Effect.try(() => process.kill(pid, name)).pipe(Effect.ignore);\n\t\tyield* signal(\"SIGTERM\");\n\t\tif (!(yield* exits(pid, STOP_TIMEOUT))) {\n\t\t\tyield* signal(\"SIGKILL\");\n\t\t\tyield* exits(pid, STOP_TIMEOUT);\n\t\t}\n\t\t// A server removes its own file on a clean exit; this covers the SIGKILL path.\n\t\tconst info = yield* Registration.read(path);\n\t\tif (info?.pid === pid) yield* remove(path);\n\t});\n\nconst lastLine = (path: string) =>\n\tEffect.gen(function* () {\n\t\tconst fs = yield* FileSystem.FileSystem;\n\t\tconst text = yield* fs.readFileString(path).pipe(Effect.orElseSucceed(() => \"\"));\n\t\treturn text\n\t\t\t.split(\"\\n\")\n\t\t\t.map((line) => line.trim())\n\t\t\t.findLast((line) => line.length > 0);\n\t});\n\n/**\n * Spawn `codework serve --service` detached, inheriting this environment so it\n * resolves the same home, catalog and credentials. It writes its own log, so no\n * stdio is tied to this short-lived caller. It stays referenced, and so stopped\n * with the scope, until `start` adopts it.\n */\nconst spawn = (options: Options) =>\n\tEffect.gen(function* () {\n\t\tconst [file, ...base] = Registration.command();\n\t\tif (file === undefined) return yield* Effect.die(new Error(\"could not resolve the codework entrypoint\"));\n\t\tconst spawner = yield* ChildProcessSpawner.ChildProcessSpawner;\n\t\tconst handle = yield* spawner.spawn(\n\t\t\tChildProcess.make(\n\t\t\t\tfile,\n\t\t\t\t[...base, ...options.args, \"serve\", \"--service\", \"--host\", options.host, \"--port\", String(options.port)],\n\t\t\t\t{ detached: true, stdin: \"ignore\", stdout: \"ignore\", stderr: \"ignore\" },\n\t\t\t),\n\t\t);\n\t\treturn handle;\n\t});\n"],"mappings":";;;;;;;;;;;;AASA,MAAa,SAAS,WACrB,OAAO,IAAI,aAAa;CACvB,MAAM,UAAU,OAAO,MAAM,MAAMA,MAAa,MAAM,CAAC,CAAC,CAAC,KAAK,OAAO,oBAAoB,KAAA,CAAS,CAAC;CACnG,IAAI,YAAY,KAAA,GAAW,OAAO,KAAA;CAClC,OAAO,OAAO,OAAO,IAAI,aAAa;EAErC,OAAO,QAAO,OADKC,KAAAA,CACD,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,OAAO,QAAQ,UAAU,CAAC;CACrE,CAAC,CAAC,CAAC,KACF,OAAO,eAAe,OAAO,GAC7B,OAAO,oBAAoB,KAAA,CAAS,CACrC;AACD,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM;;;;ACLtB,IAAM,mBAAN,cAA+B,OAAO,YAA8B,CAAC,CAAC,8BAA8B,EACnG,SAAS,OAAO,OACjB,CAAC,CAAC,CAAC,CAAC;AAaJ,MAAM,gBAAgB;AACtB,MAAM,aAAa;AACnB,MAAM,eAAe;AAErB,MAAM,UAAU,SACf,OAAO,IAAI,aAAa;CAEvB,QAAO,OADW,WAAW,WAAA,CACnB,OAAO,IAAI;AACtB,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM;;AAGtB,MAAM,SAAS,QACd,OAAO,IAAI;CAAE,WAAW,QAAQ,KAAK,KAAK,CAAC;CAAG,QAAQ,UAAW,MAAgC;AAAK,CAAC,CAAC,CAAC,KACxG,OAAO,GAAG,IAAI,GACd,OAAO,OAAO,S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B,aAAa,KACZ,MACA;EAAC,GAAG;EAAM,GAAG,QAAQ;EAAM;EAAS;EAAa;EAAU,QAAQ;EAAM;EAAU,OAAO,QAAQ,IAAI;CAAC,GACvG;EAAE,UAAU;EAAM,OAAO;EAAU,QAAQ;EAAU,QAAQ;CAAS,CACvE,CACD;AAED,CAAC"}
|
|
1
|
+
{"version":3,"file":"discovery-C6H7dCHz.mjs","names":["Client.layer","Client.make","Registration.read","Health.probe","Registration.file","log","Registration.log","Registration.command"],"sources":["../../src/server/health.ts","../../src/server/discovery.ts"],"sourcesContent":["import { Effect, Layer } from \"effect\";\nimport * as Client from \"./client.ts\";\n\n/**\n * One `server.info` call, with the answer normalized to `undefined` for every\n * way a server can fail to answer: unreachable, slow, refusing the token, or\n * speaking a different protocol. A health check that throws where it should say\n * \"no\" would make every caller wrap it in a catch.\n */\nexport const probe = (server: Client.Target) =>\n\tEffect.gen(function* () {\n\t\tconst context = yield* Layer.build(Client.layer(server)).pipe(Effect.orElseSucceed(() => undefined));\n\t\tif (context === undefined) return undefined;\n\t\treturn yield* Effect.gen(function* () {\n\t\t\tconst rpc = yield* Client.make;\n\t\t\treturn yield* rpc[\"server.info\"]({}).pipe(Effect.timeout(\"1 second\"));\n\t\t}).pipe(\n\t\t\tEffect.provideContext(context),\n\t\t\tEffect.orElseSucceed(() => undefined),\n\t\t);\n\t}).pipe(Effect.scoped);\n","import { type Duration, Effect, FileSystem, Option, Schedule, Schema } from \"effect\";\nimport { ChildProcess, ChildProcessSpawner } from \"effect/process\";\nimport * as Health from \"./health.ts\";\nimport * as Identity from \"./identity.ts\";\nimport * as Registration from \"./registration.ts\";\n\n/** A server a client can connect to, the process and port behind it, and the token it takes. */\nexport interface Endpoint {\n\treadonly url: string;\n\treadonly pid: number;\n\treadonly port: number;\n\treadonly token: string;\n}\n\n/** A managed server could not be produced, in the words the CLI prints. */\nclass ServerStartError extends Schema.TaggedError<ServerStartError>()(\"Discovery.ServerStartError\", {\n\tmessage: Schema.String,\n}) {}\n\nexport interface Options {\n\t/** The CodeWork home whose `service.json` names the server. */\n\treadonly home: string;\n\t/** The home's log directory, where a background server writes `server.log`. */\n\treadonly log: string;\n\treadonly host: string;\n\treadonly port: number;\n\t/** Server-owned flags placed before `serve`. */\n\treadonly args: ReadonlyArray<string>;\n}\n\nconst START_TIMEOUT = \"20 seconds\";\nconst RACE_GRACE = \"2 seconds\";\nconst STOP_TIMEOUT = \"5 seconds\";\n\nconst remove = (path: string) =>\n\tEffect.gen(function* () {\n\t\tconst fs = yield* FileSystem.FileSystem;\n\t\tyield* fs.remove(path);\n\t}).pipe(Effect.ignore);\n\n/** Whether `pid` is a running process. EPERM means it exists but belongs to someone else. */\nconst alive = (pid: number) =>\n\tEffect.try({ try: () => process.kill(pid, 0), catch: (error) => (error as NodeJS.ErrnoException).code }).pipe(\n\t\tEffect.as(true),\n\t\tEffect.catch((code) => Effect.succeed(code === \"EPERM\")),\n\t);\n\n/** Whether `pid` exits within `timeout`. */\nconst exits = (pid: number, timeout: typeof STOP_TIMEOUT) =>\n\talive(pid).pipe(\n\t\tEffect.repeat({ while: (running) => running, schedule: Schedule.spaced(\"50 millis\") }),\n\t\tEffect.timeoutOption(timeout),\n\t\tEffect.map(Option.isSome),\n\t);\n\n/**\n * The registered server, with `live` set when the process answering its endpoint\n * is the one that registered. The file is a hint, never proof: a different server\n * on a reused port must not pass for it.\n */\nconst registered = (path: string) =>\n\tEffect.gen(function* () {\n\t\tconst info = yield* Registration.read(path);\n\t\tif (info === undefined) return undefined;\n\t\tconst live = yield* Health.probe(info);\n\t\treturn { info, live: live?.pid === info.pid ? live : undefined };\n\t});\n\nconst endpoint = (info: Registration.Info): Endpoint => ({\n\turl: info.url,\n\tpid: info.pid,\n\tport: info.port,\n\ttoken: info.token,\n});\n\n/** The running server registered for `home`, with the build it reports. */\nexport const discover = (home: string) =>\n\tregistered(Registration.file(home)).pipe(\n\t\tEffect.map((found) =>\n\t\t\tfound?.live === undefined ? undefined : { ...endpoint(found.info), version: found.live.version },\n\t\t),\n\t);\n\n/**\n * Stop the server registered for `home`, returning it, or undefined when none\n * answers. Only a server that confirms it is the registrant is signalled: a pid\n * on file may since have been reused by an unrelated process.\n */\nexport const stop = (home: string) =>\n\tEffect.gen(function* () {\n\t\tconst path = Registration.file(home);\n\t\tconst found = yield* registered(path);\n\t\tif (found === undefined) return undefined;\n\t\tif (found.live === undefined) {\n\t\t\tif (!(yield* alive(found.info.pid))) yield* remove(path);\n\t\t\treturn undefined;\n\t\t}\n\t\tyield* terminate(path, found.info.pid);\n\t\treturn endpoint(found.info);\n\t});\n\n/**\n * Ensure a healthy local server for `home`: reuse the registered one, replace it\n * when `replace` is set and it runs a different build, or start a background one.\n *\n * The background server is detached and outlives this caller, so the next\n * invocation reuses it. When two callers race, only the contender that binds the\n * port registers; the loser exits and both adopt the winner, because a caller\n * only ever believes a registration it can confirm over the wire.\n */\nexport const ensure = (options: Options & { readonly replace: boolean }) =>\n\tEffect.gen(function* () {\n\t\tconst path = Registration.file(options.home);\n\t\tconst found = yield* registered(path);\n\t\tif (found?.live !== undefined) {\n\t\t\tif (!options.replace || found.live.version === Identity.current.version) return endpoint(found.info);\n\t\t\tyield* terminate(path, found.info.pid);\n\t\t} else {\n\t\t\t// A file nothing answers for, left by a crash, must not mislead the next caller.\n\t\t\tif (found !== undefined && !(yield* alive(found.info.pid))) yield* remove(path);\n\t\t}\n\t\treturn yield* start(path, options);\n\t});\n\n/** The registered server once it answers, polled every 200ms for up to `timeout`. */\nconst ready = (path: string, timeout: Duration.Input, pending: Effect.Effect<boolean>) =>\n\tEffect.gen(function* () {\n\t\tconst next = yield* registered(path);\n\t\tif (next?.live !== undefined) return Option.some(endpoint(next.info));\n\t\t// A live registrant that does not answer yet is another caller's server starting up.\n\t\tconst waiting = (yield* pending) || (next !== undefined && (yield* alive(next.info.pid)));\n\t\treturn waiting ? Option.none() : yield* Effect.fail(\"exited\" as const);\n\t}).pipe(\n\t\tEffect.repeat({ until: Option.isSome, schedule: Schedule.spaced(\"200 millis\") }),\n\t\tEffect.timeoutOption(timeout),\n\t\tEffect.map(Option.flatten),\n\t\tEffect.orElseSucceed(() => Option.none<Endpoint>()),\n\t);\n\n/**\n * Start a background server and wait for it to register, quoting the reason\n * from its log when it cannot.\n *\n * The contender stays tied to this scope until it is the server adopted: a\n * timeout, an interrupt, or another caller winning the race stops it rather than\n * leaving an unmanaged server behind.\n */\nconst start = (path: string, options: Options) =>\n\tEffect.gen(function* () {\n\t\tconst contender = yield* spawn(options);\n\t\tconst won = yield* ready(path, START_TIMEOUT, contender.isRunning.pipe(Effect.orElseSucceed(() => false)));\n\t\t// A contender that lost the bind race exits before the winner may have filed its\n\t\t// registration; give the winner a moment before calling the start a failure.\n\t\tconst server = Option.isSome(won) ? won : yield* ready(path, RACE_GRACE, Effect.succeed(true));\n\t\tif (Option.isSome(server)) {\n\t\t\tif (server.value.pid === contender.pid) yield* contender.unref.pipe(Effect.asVoid);\n\t\t\treturn server.value;\n\t\t}\n\n\t\tconst log = Registration.log(options.log);\n\t\tconst reason = yield* lastLine(log);\n\t\treturn yield* new ServerStartError({\n\t\t\tmessage: [\n\t\t\t\t`could not start a CodeWork server on ${options.host}:${options.port}`,\n\t\t\t\t...(reason === undefined ? [] : [`reason: ${reason}`]),\n\t\t\t\t`log: ${log}`,\n\t\t\t\t\"hint: pass --port to use another port\",\n\t\t\t].join(\"\\n\"),\n\t\t});\n\t}).pipe(Effect.scoped);\n\n/** Ask `pid` to shut down, escalating to SIGKILL, and retire its registration. */\nconst terminate = (path: string, pid: number) =>\n\tEffect.gen(function* () {\n\t\tconst signal = (name: NodeJS.Signals) => Effect.try(() => process.kill(pid, name)).pipe(Effect.ignore);\n\t\tyield* signal(\"SIGTERM\");\n\t\tif (!(yield* exits(pid, STOP_TIMEOUT))) {\n\t\t\tyield* signal(\"SIGKILL\");\n\t\t\tyield* exits(pid, STOP_TIMEOUT);\n\t\t}\n\t\t// A server removes its own file on a clean exit; this covers the SIGKILL path.\n\t\tconst info = yield* Registration.read(path);\n\t\tif (info?.pid === pid) yield* remove(path);\n\t});\n\nconst lastLine = (path: string) =>\n\tEffect.gen(function* () {\n\t\tconst fs = yield* FileSystem.FileSystem;\n\t\tconst text = yield* fs.readFileString(path).pipe(Effect.orElseSucceed(() => \"\"));\n\t\treturn text\n\t\t\t.split(\"\\n\")\n\t\t\t.map((line) => line.trim())\n\t\t\t.findLast((line) => line.length > 0);\n\t});\n\n/**\n * Spawn `codework serve --service` detached, inheriting this environment so it\n * resolves the same home, catalog and credentials. It writes its own log, so no\n * stdio is tied to this short-lived caller. It stays referenced, and so stopped\n * with the scope, until `start` adopts it.\n */\nconst spawn = (options: Options) =>\n\tEffect.gen(function* () {\n\t\tconst [file, ...base] = Registration.command();\n\t\tif (file === undefined) return yield* Effect.die(new Error(\"could not resolve the codework entrypoint\"));\n\t\tconst spawner = yield* ChildProcessSpawner.ChildProcessSpawner;\n\t\tconst handle = yield* spawner.spawn(\n\t\t\tChildProcess.make(\n\t\t\t\tfile,\n\t\t\t\t[...base, ...options.args, \"serve\", \"--service\", \"--host\", options.host, \"--port\", String(options.port)],\n\t\t\t\t{ detached: true, stdin: \"ignore\", stdout: \"ignore\", stderr: \"ignore\" },\n\t\t\t),\n\t\t);\n\t\treturn handle;\n\t});\n"],"mappings":";;;;;;;;;;;;AASA,MAAa,SAAS,WACrB,OAAO,IAAI,aAAa;CACvB,MAAM,UAAU,OAAO,MAAM,MAAMA,MAAa,MAAM,CAAC,CAAC,CAAC,KAAK,OAAO,oBAAoB,KAAA,CAAS,CAAC;CACnG,IAAI,YAAY,KAAA,GAAW,OAAO,KAAA;CAClC,OAAO,OAAO,OAAO,IAAI,aAAa;EAErC,OAAO,QAAO,OADKC,KAAAA,CACD,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,OAAO,QAAQ,UAAU,CAAC;CACrE,CAAC,CAAC,CAAC,KACF,OAAO,eAAe,OAAO,GAC7B,OAAO,oBAAoB,KAAA,CAAS,CAC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AAO,OAAO,IAAI;AAC1C,CAAC;AAEF,MAAM,YAAY,SACjB,OAAO,IAAI,aAAa;CAGvB,QAAO,QADa,OADF,WAAW,WAAA,CACN,eAAe,IAAI,CAAC,CAAC,KAAK,OAAO,oBAAoB,EAAE,CAAC,EAAA,CAE7E,MAAM,IAAI,CAAC,CACX,KAAK,SAAS,KAAK,KAAK,CAAC,CAAC,CAC1B,UAAU,SAAS,KAAK,SAAS,CAAC;AACrC,CAAC;;;;;;;AAQF,MAAM,SAAS,YACd,OAAO,IAAI,aAAa;CACvB,MAAM,CAAC,MAAM,GAAG,QAAQK,QAAqB;CAC7C,IAAI,SAAS,KAAA,GAAW,OAAO,OAAO,OAAO,oBAAI,IAAI,MAAM,2CAA2C,CAAC;CASvG,OAAO,QAPe,OADC,oBAAoB,oBAAA,CACb,MAC7B,aAAa,KACZ,MACA;EAAC,GAAG;EAAM,GAAG,QAAQ;EAAM;EAAS;EAAa;EAAU,QAAQ;EAAM;EAAU,OAAO,QAAQ,IAAI;CAAC,GACvG;EAAE,UAAU;EAAM,OAAO;EAAU,QAAQ;EAAU,QAAQ;CAAS,CACvE,CACD;AAED,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { S as contract_exports, a as reportFailure, g as make, m as writeOut, p as writeJson, t as InvalidInputError } from "./error-BsI8iNna.mjs";
|
|
2
|
-
import { i as Cmd, t as handler } from "./runtime-
|
|
3
|
-
import { t as connect } from "./service-
|
|
2
|
+
import { i as Cmd, t as handler } from "./runtime-CyXV7HH_.mjs";
|
|
3
|
+
import { t as connect } from "./service-YVNwFMNf.mjs";
|
|
4
4
|
import { n as threadFlag, t as sessionId } from "./ids-BW5msGUm.mjs";
|
|
5
5
|
import { Effect, Option, Schema } from "effect";
|
|
6
6
|
//#region src/cli/cmd/handlers/thread/fork.ts
|
|
@@ -30,4 +30,4 @@ var fork_default = handler(Cmd.commands.thread.commands.fork, Effect.fn("CLI.thr
|
|
|
30
30
|
//#endregion
|
|
31
31
|
export { fork_default as default };
|
|
32
32
|
|
|
33
|
-
//# sourceMappingURL=fork-
|
|
33
|
+
//# sourceMappingURL=fork-TUz05qSe.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fork-
|
|
1
|
+
{"version":3,"file":"fork-TUz05qSe.mjs","names":["ThreadInfo","Runtime.handler","Client.make","Service.connect"],"sources":["../../src/cli/cmd/handlers/thread/fork.ts"],"sourcesContent":["import { Effect, Option, Schema } from \"effect\";\nimport * as Runtime from \"../../../../framework/runtime.ts\";\nimport * as Client from \"../../../../server/client.ts\";\nimport * as Service from \"../../../service.ts\";\nimport { ThreadInfo } from \"../../../../server/contract.ts\";\nimport { InvalidInputError, reportFailure } from \"../../../error.ts\";\nimport { writeJson, writeOut } from \"../../../output.ts\";\nimport { sessionId, threadFlag } from \"../../../ids.ts\";\nimport { Cmd } from \"../../cmd.ts\";\n\nconst Forked = Schema.Struct({ thread: ThreadInfo, text: Schema.optional(Schema.String) });\n\nexport default Runtime.handler(\n\tCmd.commands.thread.commands.fork,\n\tEffect.fn(\"CLI.thread.fork\")(function* ({ session, thread, at, before, json, server }) {\n\t\tconst id = yield* sessionId(session);\n\t\tconst program = Effect.gen(function* () {\n\t\t\tconst point = Option.isSome(at)\n\t\t\t\t? Option.isNone(before)\n\t\t\t\t\t? { entryId: at.value }\n\t\t\t\t\t: undefined\n\t\t\t\t: Option.map(before, (entryId) => ({ entryId, mode: \"before\" as const })).pipe(Option.getOrUndefined);\n\t\t\tif (point === undefined) {\n\t\t\t\treturn yield* new InvalidInputError({ message: \"Pass exactly one of --at or --before\" });\n\t\t\t}\n\t\t\tconst threadId = yield* threadFlag(thread);\n\t\t\tconst rpc = yield* Client.make;\n\t\t\tconst forked = yield* rpc[\"thread.fork\"]({\n\t\t\t\tsessionId: id,\n\t\t\t\t...(threadId === undefined ? {} : { threadId }),\n\t\t\t\t...point,\n\t\t\t});\n\t\t\tif (json) return yield* writeJson(Forked, forked);\n\t\t\tyield* writeOut(`${forked.thread.id}\\n`);\n\t\t\tif (forked.text !== undefined) yield* writeOut(`\\n${forked.text}\\n`);\n\t\t});\n\n\t\treturn yield* program.pipe(Service.connect(Option.getOrUndefined(server)), Effect.catch(reportFailure));\n\t}),\n);\n"],"mappings":";;;;;;AAUA,MAAM,SAAS,OAAO,OAAO;CAAE,QAAQA,iBAAAA;CAAY,MAAM,OAAO,SAAS,OAAO,MAAM;AAAE,CAAC;AAEzF,IAAA,eAAeC,QACd,IAAI,SAAS,OAAO,SAAS,MAC7B,OAAO,GAAG,iBAAiB,CAAC,CAAC,WAAW,EAAE,SAAS,QAAQ,IAAI,QAAQ,MAAM,UAAU;CACtF,MAAM,KAAK,OAAO,UAAU,OAAO;CAsBnC,OAAO,OArBS,OAAO,IAAI,aAAa;EACvC,MAAM,QAAQ,OAAO,OAAO,EAAE,IAC3B,OAAO,OAAO,MAAM,IACnB,EAAE,SAAS,GAAG,MAAM,IACpB,KAAA,IACD,OAAO,IAAI,SAAS,aAAa;GAAE;GAAS,MAAM;EAAkB,EAAE,CAAC,CAAC,KAAK,OAAO,cAAc;EACrG,IAAI,UAAU,KAAA,GACb,OAAO,OAAO,IAAI,kBAAkB,EAAE,SAAS,uCAAuC,CAAC;EAExF,MAAM,WAAW,OAAO,WAAW,MAAM;EAEzC,MAAM,SAAS,QAAO,OADHC,KAAAA,CACO,cAAc,CAAC;GACxC,WAAW;GACX,GAAI,aAAa,KAAA,IAAY,CAAC,IAAI,EAAE,SAAS;GAC7C,GAAG;EACJ,CAAC;EACD,IAAI,MAAM,OAAO,OAAO,UAAU,QAAQ,MAAM;EAChD,OAAO,SAAS,GAAG,OAAO,OAAO,GAAG,GAAG;EACvC,IAAI,OAAO,SAAS,KAAA,GAAW,OAAO,SAAS,KAAK,OAAO,KAAK,GAAG;CACpE,CAEoB,CAAC,CAAC,KAAKC,QAAgB,OAAO,eAAe,MAAM,CAAC,GAAG,OAAO,MAAM,aAAa,CAAC;AACvG,CAAC,CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as version } from "./package-
|
|
1
|
+
import { t as version } from "./package-Y0eg0qm4.mjs";
|
|
2
2
|
import { Context, Effect, Layer } from "effect";
|
|
3
3
|
import { NodeServices } from "@effect/platform-node";
|
|
4
4
|
import os from "node:os";
|
|
@@ -23,4 +23,4 @@ const layer = Layer.effect(Service, hostName.pipe(Effect.map((name) => Service.o
|
|
|
23
23
|
//#endregion
|
|
24
24
|
export { layer as i, current as n, hostName as r, Service as t };
|
|
25
25
|
|
|
26
|
-
//# sourceMappingURL=identity-
|
|
26
|
+
//# sourceMappingURL=identity-fLl347sJ.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity-
|
|
1
|
+
{"version":3,"file":"identity-fLl347sJ.mjs","names":["pkg.version"],"sources":["../../src/server/identity.ts"],"sourcesContent":["/* @effect-diagnostics nodeBuiltinImport:off -- the host's name is the OS's hostname. */\nimport os from \"node:os\";\nimport { NodeServices } from \"@effect/platform-node\";\nimport { Context, Effect, Layer } from \"effect\";\nimport { ChildProcess, ChildProcessSpawner } from \"effect/process\";\nimport pkg from \"../../package.json\" with { type: \"json\" };\n\n/**\n * What a running server is, as its clients need to know it.\n *\n * A discovery registration names the pid and version it wrote; `server.info`\n * answers with the live ones so a caller can tell the process it reached is the\n * one that registered rather than a different server that took the same port.\n */\nexport interface Interface {\n\treadonly pid: number;\n\treadonly version: string;\n\t/** The machine it runs on, by the name its user knows it; none when the OS names it nothing. */\n\treadonly host?: { readonly name: string };\n}\n\nexport class Service extends Context.Service<Service, Interface>()(\"@codeworksh/cli/server/identity/Service\") {}\n\n/** This process: a server answers with it, a client compares a server's version against it. */\nexport const current: Interface = { pid: process.pid, version: pkg.version };\n\n// macOS's computer name is the one Finder and sharing show; its hostname is a mangled copy of it.\n/** The machine's name as its user knows it, read from the OS; empty when it names nothing. */\nexport const hostName = Effect.gen(function* () {\n\tif (process.platform !== \"darwin\") return os.hostname().trim();\n\tconst spawner = yield* ChildProcessSpawner.ChildProcessSpawner;\n\tconst computer = yield* spawner\n\t\t.string(ChildProcess.make(\"scutil\", [\"--get\", \"ComputerName\"]))\n\t\t.pipe(Effect.orElseSucceed(() => \"\"));\n\treturn (\n\t\tcomputer.trim() ||\n\t\tos\n\t\t\t.hostname()\n\t\t\t.replace(/\\.local$/, \"\")\n\t\t\t.trim()\n\t);\n});\n\n/** The host's name is read once, when the server starts. */\nexport const layer = Layer.effect(\n\tService,\n\thostName.pipe(Effect.map((name) => Service.of(name === \"\" ? current : { ...current, host: { name } }))),\n).pipe(Layer.provide(NodeServices.layer));\n"],"mappings":";;;;;;AAqBA,IAAa,UAAb,cAA6B,QAAQ,QAA4B,CAAC,CAAC,yCAAyC,CAAC,CAAC,CAAC;;AAG/G,MAAa,UAAqB;CAAE,KAAK,QAAQ;CAAcA;AAAY;;AAI3E,MAAa,WAAW,OAAO,IAAI,aAAa;CAC/C,IAAI,QAAQ,aAAa,UAAU,OAAO,GAAG,SAAS,CAAC,CAAC,KAAK;CAK7D,QACC,QAJuB,OADD,oBAAoB,oBAAA,CAEzC,OAAO,aAAa,KAAK,UAAU,CAAC,SAAS,cAAc,CAAC,CAAC,CAAC,CAC9D,KAAK,OAAO,oBAAoB,EAAE,CAAC,EAAA,CAE3B,KAAK,KACd,GACE,SAAS,CAAC,CACV,QAAQ,YAAY,EAAE,CAAC,CACvB,KAAK;AAET,CAAC;;AAGD,MAAa,QAAQ,MAAM,OAC1B,SACA,SAAS,KAAK,OAAO,KAAK,SAAS,QAAQ,GAAG,SAAS,KAAK,UAAU;CAAE,GAAG;CAAS,MAAM,EAAE,KAAK;AAAE,CAAC,CAAC,CAAC,CACvG,CAAC,CAAC,KAAK,MAAM,QAAQ,aAAa,KAAK,CAAC"}
|
package/index.mjs
CHANGED
|
@@ -1,61 +1,71 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { t as version } from "./package-
|
|
3
|
-
import { i as Cmd, n as handlers, r as run } from "./runtime-
|
|
2
|
+
import { t as version } from "./package-Y0eg0qm4.mjs";
|
|
3
|
+
import { i as Cmd, n as handlers, r as run } from "./runtime-CyXV7HH_.mjs";
|
|
4
4
|
import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
|
|
5
5
|
import * as NodeServices from "@effect/platform-node/NodeServices";
|
|
6
6
|
import { Effect } from "effect";
|
|
7
7
|
//#region src/index.ts
|
|
8
8
|
const Handlers = handlers(Cmd, {
|
|
9
9
|
auth: {
|
|
10
|
-
login: () => import("./login-
|
|
11
|
-
status: () => import("./status-
|
|
12
|
-
refresh: () => import("./refresh-
|
|
13
|
-
logout: () => import("./logout-
|
|
10
|
+
login: () => import("./login-C_tBeHg6.mjs"),
|
|
11
|
+
status: () => import("./status-BoTZqXwd.mjs"),
|
|
12
|
+
refresh: () => import("./refresh-CvE_f1Fa.mjs"),
|
|
13
|
+
logout: () => import("./logout-E_dRjl1L.mjs")
|
|
14
14
|
},
|
|
15
15
|
mcp: {
|
|
16
|
-
add: () => import("./add-
|
|
17
|
-
remove: () => import("./remove-
|
|
18
|
-
list: () => import("./list-
|
|
19
|
-
login: () => import("./login-
|
|
20
|
-
logout: () => import("./logout-
|
|
21
|
-
reconnect: () => import("./reconnect-
|
|
22
|
-
disconnect: () => import("./disconnect-
|
|
16
|
+
add: () => import("./add-D2ly9-x3.mjs"),
|
|
17
|
+
remove: () => import("./remove-C0e5sHqb.mjs"),
|
|
18
|
+
list: () => import("./list-MiZ6rD_w.mjs"),
|
|
19
|
+
login: () => import("./login-Q_ezdpon.mjs"),
|
|
20
|
+
logout: () => import("./logout-BjL1W-0I.mjs"),
|
|
21
|
+
reconnect: () => import("./reconnect-BKpud0ma.mjs"),
|
|
22
|
+
disconnect: () => import("./disconnect-CHEHx_ic.mjs")
|
|
23
23
|
},
|
|
24
|
-
connect:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
connect: {
|
|
25
|
+
$: () => import("./connect-AqacTFrV.mjs"),
|
|
26
|
+
discover: () => import("./discover-DAP4t5Kb.mjs"),
|
|
27
|
+
categories: () => import("./categories-DD30aGHU.mjs"),
|
|
28
|
+
create: () => import("./create-dxNGBbiQ.mjs"),
|
|
29
|
+
login: () => import("./login-D0EMtnh2.mjs"),
|
|
30
|
+
list: () => import("./list-C29G-xrA.mjs"),
|
|
31
|
+
status: () => import("./status-B29jKo_s.mjs"),
|
|
32
|
+
disconnect: () => import("./disconnect-BcwEk1sG.mjs"),
|
|
33
|
+
remove: () => import("./remove-y_AI5IuH.mjs")
|
|
34
|
+
},
|
|
35
|
+
disconnect: () => import("./disconnect-V4MnDMkF.mjs"),
|
|
36
|
+
run: () => import("./run-DNbme1W_.mjs"),
|
|
37
|
+
serve: () => import("./serve-CGPp3kyd.mjs"),
|
|
28
38
|
service: {
|
|
29
|
-
start: () => import("./start-
|
|
30
|
-
restart: () => import("./restart-
|
|
31
|
-
status: () => import("./status-
|
|
32
|
-
stop: () => import("./stop-
|
|
33
|
-
pair: () => import("./pair-
|
|
34
|
-
devices: () => import("./devices-
|
|
35
|
-
revoke: () => import("./revoke-
|
|
39
|
+
start: () => import("./start-Dky5Iihf.mjs"),
|
|
40
|
+
restart: () => import("./restart-BcpKCYwQ.mjs"),
|
|
41
|
+
status: () => import("./status-CdAZIIEi.mjs"),
|
|
42
|
+
stop: () => import("./stop-BCAMcHem.mjs"),
|
|
43
|
+
pair: () => import("./pair-BBneOJZJ.mjs"),
|
|
44
|
+
devices: () => import("./devices-DNzXKhNy.mjs"),
|
|
45
|
+
revoke: () => import("./revoke-DoMHa1vL.mjs")
|
|
36
46
|
},
|
|
37
47
|
session: {
|
|
38
|
-
link: () => import("./link-
|
|
39
|
-
relink: () => import("./relink-
|
|
48
|
+
link: () => import("./link-Cd6T22_n.mjs"),
|
|
49
|
+
relink: () => import("./relink-DxftNq9n.mjs")
|
|
40
50
|
},
|
|
41
51
|
thread: {
|
|
42
|
-
list: () => import("./list-
|
|
43
|
-
fork: () => import("./fork-
|
|
52
|
+
list: () => import("./list-Bn5CvS1y.mjs"),
|
|
53
|
+
fork: () => import("./fork-TUz05qSe.mjs")
|
|
44
54
|
},
|
|
45
|
-
acp: () => import("./acp-
|
|
55
|
+
acp: () => import("./acp-Cw5Ljayx.mjs"),
|
|
46
56
|
plugin: {
|
|
47
|
-
add: () => import("./add-
|
|
48
|
-
check: () => import("./check-
|
|
49
|
-
install: () => import("./install-
|
|
50
|
-
list: () => import("./list-
|
|
51
|
-
reload: () => import("./reload-
|
|
52
|
-
remove: () => import("./remove-
|
|
53
|
-
update: () => import("./update-
|
|
57
|
+
add: () => import("./add-Be7-HfBj.mjs"),
|
|
58
|
+
check: () => import("./check-DzxfN43i.mjs"),
|
|
59
|
+
install: () => import("./install-BtoWHZoI.mjs"),
|
|
60
|
+
list: () => import("./list-CdS1_gFF.mjs"),
|
|
61
|
+
reload: () => import("./reload-DRp3UlHQ.mjs"),
|
|
62
|
+
remove: () => import("./remove-CdcoheOp.mjs"),
|
|
63
|
+
update: () => import("./update-mWc5cR7q.mjs")
|
|
54
64
|
},
|
|
55
65
|
models: {
|
|
56
|
-
$: () => import("./list-
|
|
57
|
-
providers: () => import("./providers-
|
|
58
|
-
refresh: () => import("./refresh-
|
|
66
|
+
$: () => import("./list-DAA92mUG.mjs"),
|
|
67
|
+
providers: () => import("./providers-BYnMGDs7.mjs"),
|
|
68
|
+
refresh: () => import("./refresh-Dy9kI2El.mjs")
|
|
59
69
|
}
|
|
60
70
|
});
|
|
61
71
|
const main = run(Cmd, Handlers, { version }).pipe(Effect.provide(NodeServices.layer));
|
package/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["Runtime.handlers","Runtime.run","pkg.version"],"sources":["../../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport * as NodeRuntime from \"@effect/platform-node/NodeRuntime\";\nimport * as NodeServices from \"@effect/platform-node/NodeServices\";\nimport { Effect } from \"effect\";\nimport type { CliError } from \"effect/cli\";\nimport pkg from \"../package.json\" with { type: \"json\" };\nimport { Cmd } from \"./cli/cmd/cmd.ts\";\nimport * as Runtime from \"./framework/runtime.ts\";\n\nconst Handlers = Runtime.handlers(Cmd, {\n\tauth: {\n\t\tlogin: () => import(\"./cli/cmd/handlers/auth/login.ts\"),\n\t\tstatus: () => import(\"./cli/cmd/handlers/auth/status.ts\"),\n\t\trefresh: () => import(\"./cli/cmd/handlers/auth/refresh.ts\"),\n\t\tlogout: () => import(\"./cli/cmd/handlers/auth/logout.ts\"),\n\t},\n\tmcp: {\n\t\tadd: () => import(\"./cli/cmd/handlers/mcp/add.ts\"),\n\t\tremove: () => import(\"./cli/cmd/handlers/mcp/remove.ts\"),\n\t\tlist: () => import(\"./cli/cmd/handlers/mcp/list.ts\"),\n\t\tlogin: () => import(\"./cli/cmd/handlers/mcp/login.ts\"),\n\t\tlogout: () => import(\"./cli/cmd/handlers/mcp/logout.ts\"),\n\t\treconnect: () => import(\"./cli/cmd/handlers/mcp/reconnect.ts\"),\n\t\tdisconnect: () => import(\"./cli/cmd/handlers/mcp/disconnect.ts\"),\n\t},\n\tconnect: () => import(\"./cli/cmd/handlers/connect.ts\"),\n\tdisconnect: () => import(\"./cli/cmd/handlers/disconnect.ts\"),\n\trun: () => import(\"./cli/cmd/handlers/run.ts\"),\n\tserve: () => import(\"./cli/cmd/handlers/serve.ts\"),\n\tservice: {\n\t\tstart: () => import(\"./cli/cmd/handlers/service/start.ts\"),\n\t\trestart: () => import(\"./cli/cmd/handlers/service/restart.ts\"),\n\t\tstatus: () => import(\"./cli/cmd/handlers/service/status.ts\"),\n\t\tstop: () => import(\"./cli/cmd/handlers/service/stop.ts\"),\n\t\tpair: () => import(\"./cli/cmd/handlers/service/pair.ts\"),\n\t\tdevices: () => import(\"./cli/cmd/handlers/service/devices.ts\"),\n\t\trevoke: () => import(\"./cli/cmd/handlers/service/revoke.ts\"),\n\t},\n\tsession: {\n\t\tlink: () => import(\"./cli/cmd/handlers/session/link.ts\"),\n\t\trelink: () => import(\"./cli/cmd/handlers/session/relink.ts\"),\n\t},\n\tthread: {\n\t\tlist: () => import(\"./cli/cmd/handlers/thread/list.ts\"),\n\t\tfork: () => import(\"./cli/cmd/handlers/thread/fork.ts\"),\n\t},\n\tacp: () => import(\"./cli/cmd/handlers/acp.ts\"),\n\tplugin: {\n\t\tadd: () => import(\"./cli/cmd/handlers/plugin/add.ts\"),\n\t\tcheck: () => import(\"./cli/cmd/handlers/plugin/check.ts\"),\n\t\tinstall: () => import(\"./cli/cmd/handlers/plugin/install.ts\"),\n\t\tlist: () => import(\"./cli/cmd/handlers/plugin/list.ts\"),\n\t\treload: () => import(\"./cli/cmd/handlers/plugin/reload.ts\"),\n\t\tremove: () => import(\"./cli/cmd/handlers/plugin/remove.ts\"),\n\t\tupdate: () => import(\"./cli/cmd/handlers/plugin/update.ts\"),\n\t},\n\tmodels: {\n\t\t$: () => import(\"./cli/cmd/handlers/models/list.ts\"),\n\t\tproviders: () => import(\"./cli/cmd/handlers/models/providers.ts\"),\n\t\trefresh: () => import(\"./cli/cmd/handlers/models/refresh.ts\"),\n\t},\n});\n\nexport const main: Effect.Effect<void, CliError.CliError> = Runtime.run(Cmd, Handlers, {\n\tversion: pkg.version,\n}).pipe(Effect.provide(NodeServices.layer));\n\nNodeRuntime.runMain(main);\n"],"mappings":";;;;;;;AAUA,MAAM,WAAWA,SAAiB,KAAK;CACtC,MAAM;EACL,aAAa,OAAO;EACpB,cAAc,OAAO;EACrB,eAAe,OAAO;EACtB,cAAc,OAAO;CACtB;CACA,KAAK;EACJ,WAAW,OAAO;EAClB,cAAc,OAAO;EACrB,YAAY,OAAO;EACnB,aAAa,OAAO;EACpB,cAAc,OAAO;EACrB,iBAAiB,OAAO;EACxB,kBAAkB,OAAO;CAC1B;CACA,
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["Runtime.handlers","Runtime.run","pkg.version"],"sources":["../../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport * as NodeRuntime from \"@effect/platform-node/NodeRuntime\";\nimport * as NodeServices from \"@effect/platform-node/NodeServices\";\nimport { Effect } from \"effect\";\nimport type { CliError } from \"effect/cli\";\nimport pkg from \"../package.json\" with { type: \"json\" };\nimport { Cmd } from \"./cli/cmd/cmd.ts\";\nimport * as Runtime from \"./framework/runtime.ts\";\n\nconst Handlers = Runtime.handlers(Cmd, {\n\tauth: {\n\t\tlogin: () => import(\"./cli/cmd/handlers/auth/login.ts\"),\n\t\tstatus: () => import(\"./cli/cmd/handlers/auth/status.ts\"),\n\t\trefresh: () => import(\"./cli/cmd/handlers/auth/refresh.ts\"),\n\t\tlogout: () => import(\"./cli/cmd/handlers/auth/logout.ts\"),\n\t},\n\tmcp: {\n\t\tadd: () => import(\"./cli/cmd/handlers/mcp/add.ts\"),\n\t\tremove: () => import(\"./cli/cmd/handlers/mcp/remove.ts\"),\n\t\tlist: () => import(\"./cli/cmd/handlers/mcp/list.ts\"),\n\t\tlogin: () => import(\"./cli/cmd/handlers/mcp/login.ts\"),\n\t\tlogout: () => import(\"./cli/cmd/handlers/mcp/logout.ts\"),\n\t\treconnect: () => import(\"./cli/cmd/handlers/mcp/reconnect.ts\"),\n\t\tdisconnect: () => import(\"./cli/cmd/handlers/mcp/disconnect.ts\"),\n\t},\n\tconnect: {\n\t\t$: () => import(\"./cli/cmd/handlers/connect.ts\"),\n\t\tdiscover: () => import(\"./cli/cmd/handlers/connect/discover.ts\"),\n\t\tcategories: () => import(\"./cli/cmd/handlers/connect/categories.ts\"),\n\t\tcreate: () => import(\"./cli/cmd/handlers/connect/create.ts\"),\n\t\tlogin: () => import(\"./cli/cmd/handlers/connect/login.ts\"),\n\t\tlist: () => import(\"./cli/cmd/handlers/connect/list.ts\"),\n\t\tstatus: () => import(\"./cli/cmd/handlers/connect/status.ts\"),\n\t\tdisconnect: () => import(\"./cli/cmd/handlers/connect/disconnect.ts\"),\n\t\tremove: () => import(\"./cli/cmd/handlers/connect/remove.ts\"),\n\t},\n\tdisconnect: () => import(\"./cli/cmd/handlers/disconnect.ts\"),\n\trun: () => import(\"./cli/cmd/handlers/run.ts\"),\n\tserve: () => import(\"./cli/cmd/handlers/serve.ts\"),\n\tservice: {\n\t\tstart: () => import(\"./cli/cmd/handlers/service/start.ts\"),\n\t\trestart: () => import(\"./cli/cmd/handlers/service/restart.ts\"),\n\t\tstatus: () => import(\"./cli/cmd/handlers/service/status.ts\"),\n\t\tstop: () => import(\"./cli/cmd/handlers/service/stop.ts\"),\n\t\tpair: () => import(\"./cli/cmd/handlers/service/pair.ts\"),\n\t\tdevices: () => import(\"./cli/cmd/handlers/service/devices.ts\"),\n\t\trevoke: () => import(\"./cli/cmd/handlers/service/revoke.ts\"),\n\t},\n\tsession: {\n\t\tlink: () => import(\"./cli/cmd/handlers/session/link.ts\"),\n\t\trelink: () => import(\"./cli/cmd/handlers/session/relink.ts\"),\n\t},\n\tthread: {\n\t\tlist: () => import(\"./cli/cmd/handlers/thread/list.ts\"),\n\t\tfork: () => import(\"./cli/cmd/handlers/thread/fork.ts\"),\n\t},\n\tacp: () => import(\"./cli/cmd/handlers/acp.ts\"),\n\tplugin: {\n\t\tadd: () => import(\"./cli/cmd/handlers/plugin/add.ts\"),\n\t\tcheck: () => import(\"./cli/cmd/handlers/plugin/check.ts\"),\n\t\tinstall: () => import(\"./cli/cmd/handlers/plugin/install.ts\"),\n\t\tlist: () => import(\"./cli/cmd/handlers/plugin/list.ts\"),\n\t\treload: () => import(\"./cli/cmd/handlers/plugin/reload.ts\"),\n\t\tremove: () => import(\"./cli/cmd/handlers/plugin/remove.ts\"),\n\t\tupdate: () => import(\"./cli/cmd/handlers/plugin/update.ts\"),\n\t},\n\tmodels: {\n\t\t$: () => import(\"./cli/cmd/handlers/models/list.ts\"),\n\t\tproviders: () => import(\"./cli/cmd/handlers/models/providers.ts\"),\n\t\trefresh: () => import(\"./cli/cmd/handlers/models/refresh.ts\"),\n\t},\n});\n\nexport const main: Effect.Effect<void, CliError.CliError> = Runtime.run(Cmd, Handlers, {\n\tversion: pkg.version,\n}).pipe(Effect.provide(NodeServices.layer));\n\nNodeRuntime.runMain(main);\n"],"mappings":";;;;;;;AAUA,MAAM,WAAWA,SAAiB,KAAK;CACtC,MAAM;EACL,aAAa,OAAO;EACpB,cAAc,OAAO;EACrB,eAAe,OAAO;EACtB,cAAc,OAAO;CACtB;CACA,KAAK;EACJ,WAAW,OAAO;EAClB,cAAc,OAAO;EACrB,YAAY,OAAO;EACnB,aAAa,OAAO;EACpB,cAAc,OAAO;EACrB,iBAAiB,OAAO;EACxB,kBAAkB,OAAO;CAC1B;CACA,SAAS;EACR,SAAS,OAAO;EAChB,gBAAgB,OAAO;EACvB,kBAAkB,OAAO;EACzB,cAAc,OAAO;EACrB,aAAa,OAAO;EACpB,YAAY,OAAO;EACnB,cAAc,OAAO;EACrB,kBAAkB,OAAO;EACzB,cAAc,OAAO;CACtB;CACA,kBAAkB,OAAO;CACzB,WAAW,OAAO;CAClB,aAAa,OAAO;CACpB,SAAS;EACR,aAAa,OAAO;EACpB,eAAe,OAAO;EACtB,cAAc,OAAO;EACrB,YAAY,OAAO;EACnB,YAAY,OAAO;EACnB,eAAe,OAAO;EACtB,cAAc,OAAO;CACtB;CACA,SAAS;EACR,YAAY,OAAO;EACnB,cAAc,OAAO;CACtB;CACA,QAAQ;EACP,YAAY,OAAO;EACnB,YAAY,OAAO;CACpB;CACA,WAAW,OAAO;CAClB,QAAQ;EACP,WAAW,OAAO;EAClB,aAAa,OAAO;EACpB,eAAe,OAAO;EACtB,YAAY,OAAO;EACnB,cAAc,OAAO;EACrB,cAAc,OAAO;EACrB,cAAc,OAAO;CACtB;CACA,QAAQ;EACP,SAAS,OAAO;EAChB,iBAAiB,OAAO;EACxB,eAAe,OAAO;CACvB;AACD,CAAC;AAED,MAAa,OAA+CC,IAAY,KAAK,UAAU,EAC7EC,QACV,CAAC,CAAC,CAAC,KAAK,OAAO,QAAQ,aAAa,KAAK,CAAC;AAE1C,YAAY,QAAQ,IAAI"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as reportFailure, m as writeOut } from "./error-BsI8iNna.mjs";
|
|
2
|
-
import { i as Cmd, t as handler } from "./runtime-
|
|
2
|
+
import { i as Cmd, t as handler } from "./runtime-CyXV7HH_.mjs";
|
|
3
3
|
import { i as read, t as fetchable } from "./entries-8D1NzQXw.mjs";
|
|
4
4
|
import { Effect } from "effect";
|
|
5
5
|
import { Plugin } from "@codeworksh/harness/effect";
|
|
@@ -51,4 +51,4 @@ var install_default = handler(Cmd.commands.plugin.commands.install, Effect.fn("C
|
|
|
51
51
|
//#endregion
|
|
52
52
|
export { install_default as default };
|
|
53
53
|
|
|
54
|
-
//# sourceMappingURL=install-
|
|
54
|
+
//# sourceMappingURL=install-BtoWHZoI.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install-
|
|
1
|
+
{"version":3,"file":"install-BtoWHZoI.mjs","names":["Runtime.handler"],"sources":["../../src/cli/cmd/handlers/plugin/install.ts"],"sourcesContent":["import { Plugin } from \"@codeworksh/harness/effect\";\nimport { Effect } from \"effect\";\nimport * as Runtime from \"../../../../framework/runtime.ts\";\nimport { reportFailure } from \"../../../error.ts\";\nimport { writeOut } from \"../../../output.ts\";\nimport { Cmd } from \"../../cmd.ts\";\nimport { fetchable, read } from \"./entries.ts\";\n\n/**\n * `plugin install`, with no argument: the answer to a fresh checkout.\n *\n * A committed `.codework/settings.jsonc` names plugins, the store on a colleague's machine is\n * empty, and something has to materialise them. This is `npm install` with no arguments -- it\n * writes no settings entry, because the entries already exist.\n *\n * It is also what lets **boot stay offline**. Without it the only path from an entry to bytes is a\n * boot that installs, which makes every fresh start a possible network wait; with it, boot\n * resolves or reports, and the error names this command as the remedy.\n */\nexport default Runtime.handler(\n\tCmd.commands.plugin.commands.install,\n\tEffect.fn(\"CLI.plugin.install\")(function* () {\n\t\tconst program = Effect.gen(function* () {\n\t\t\tconst shared = yield* Cmd.spec;\n\t\t\tconst { entries, cache } = yield* read(shared);\n\n\t\t\tlet installed = 0;\n\t\t\tlet present = 0;\n\t\t\tlet local = 0;\n\t\t\tfor (const entry of entries) {\n\t\t\t\tconst target = fetchable(entry.target);\n\t\t\t\tif (target === undefined) {\n\t\t\t\t\t// A local plugin is loaded where it lies and never copied into the store, so\n\t\t\t\t\t// there is nothing to install. An unparseable entry is `list`'s to report.\n\t\t\t\t\tlocal += 1;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif ((yield* Plugin.resolve(target, cache, entry.from)) !== undefined) {\n\t\t\t\t\tpresent += 1;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t// `inspect` installs, imports and validates, so a spec that turns out not to be a\n\t\t\t\t// plugin fails here rather than at the next run. The reported ID comes from the\n\t\t\t\t// module, never from the spec.\n\t\t\t\tconst plugin = yield* Plugin.inspect(entry.reference, { cache, hostDir: entry.from, file: entry.file });\n\t\t\t\tinstalled += 1;\n\t\t\t\tyield* writeOut(`Installed ${entry.reference} (${plugin.id})\\n`);\n\t\t\t}\n\n\t\t\tconst parts = [\n\t\t\t\t`${installed} installed`,\n\t\t\t\t...(present === 0 ? [] : [`${present} already present`]),\n\t\t\t\t...(local === 0 ? [] : [`${local} local`]),\n\t\t\t];\n\t\t\tyield* writeOut(`${parts.join(\", \")}\\n`);\n\t\t});\n\n\t\treturn yield* program.pipe(Effect.catch(reportFailure));\n\t}),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;AAmBA,IAAA,kBAAeA,QACd,IAAI,SAAS,OAAO,SAAS,SAC7B,OAAO,GAAG,oBAAoB,CAAC,CAAC,aAAa;CAoC5C,OAAO,OAnCS,OAAO,IAAI,aAAa;EACvC,MAAM,SAAS,OAAO,IAAI;EAC1B,MAAM,EAAE,SAAS,UAAU,OAAO,KAAK,MAAM;EAE7C,IAAI,YAAY;EAChB,IAAI,UAAU;EACd,IAAI,QAAQ;EACZ,KAAK,MAAM,SAAS,SAAS;GAC5B,MAAM,SAAS,UAAU,MAAM,MAAM;GACrC,IAAI,WAAW,KAAA,GAAW;IAGzB,SAAS;IACT;GACD;GACA,KAAK,OAAO,OAAO,QAAQ,QAAQ,OAAO,MAAM,IAAI,OAAO,KAAA,GAAW;IACrE,WAAW;IACX;GACD;GAIA,MAAM,SAAS,OAAO,OAAO,QAAQ,MAAM,WAAW;IAAE;IAAO,SAAS,MAAM;IAAM,MAAM,MAAM;GAAK,CAAC;GACtG,aAAa;GACb,OAAO,SAAS,aAAa,MAAM,UAAU,IAAI,OAAO,GAAG,IAAI;EAChE;EAEA,MAAM,QAAQ;GACb,GAAG,UAAU;GACb,GAAI,YAAY,IAAI,CAAC,IAAI,CAAC,GAAG,QAAQ,iBAAiB;GACtD,GAAI,UAAU,IAAI,CAAC,IAAI,CAAC,GAAG,MAAM,OAAO;EACzC;EACA,OAAO,SAAS,GAAG,MAAM,KAAK,IAAI,EAAE,GAAG;CACxC,CAEoB,CAAC,CAAC,KAAK,OAAO,MAAM,aAAa,CAAC;AACvD,CAAC,CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as reportFailure, g as make, m as writeOut } from "./error-BsI8iNna.mjs";
|
|
2
|
-
import { i as Cmd, t as handler } from "./runtime-
|
|
3
|
-
import { t as connect } from "./service-
|
|
2
|
+
import { i as Cmd, t as handler } from "./runtime-CyXV7HH_.mjs";
|
|
3
|
+
import { t as connect } from "./service-YVNwFMNf.mjs";
|
|
4
4
|
import { t as sessionId } from "./ids-BW5msGUm.mjs";
|
|
5
5
|
import { Effect, Option, Path } from "effect";
|
|
6
6
|
import { Session } from "@codeworksh/harness/effect";
|
|
@@ -40,4 +40,4 @@ var link_default = handler(Cmd.commands.session.commands.link, Effect.fn("CLI.se
|
|
|
40
40
|
//#endregion
|
|
41
41
|
export { link_default as default };
|
|
42
42
|
|
|
43
|
-
//# sourceMappingURL=link-
|
|
43
|
+
//# sourceMappingURL=link-Cd6T22_n.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link-
|
|
1
|
+
{"version":3,"file":"link-Cd6T22_n.mjs","names":["Runtime.handler","Client.make","Service.connect"],"sources":["../../src/cli/cmd/handlers/session/link.ts"],"sourcesContent":["import { Session } from \"@codeworksh/harness/effect\";\nimport { Effect, Option, Path } from \"effect\";\nimport * as Runtime from \"../../../../framework/runtime.ts\";\nimport { reportFailure } from \"../../../error.ts\";\nimport { sessionId } from \"../../../ids.ts\";\nimport { writeOut } from \"../../../output.ts\";\nimport * as Client from \"../../../../server/client.ts\";\nimport * as Service from \"../../../service.ts\";\nimport { Cmd } from \"../../cmd.ts\";\n\n/**\n * Sets `hostDir` on an existing session.\n *\n * **The session ID identifies it; the path is the target.** A project cannot identify a session --\n * it may have many or none, and it is the session that carries the field.\n *\n * The path defaults to the shell's directory, which is both the common case (you are standing in\n * the project you want to link) and safe to default: the CLI runs on the host, so the trust\n * question about naming host paths is about remote clients, not about a local shell's own cwd.\n *\n * Not `session relink`, which moves a session to another checkout of the same project. Different\n * axes -- `relink` changes where the *work* happens, `link` changes which host directory the\n * session is *anchored to* -- and conflating them would recreate the confusion the two names\n * exist to avoid.\n *\n * The anchor is not a settings mechanism. Settings discovery reads it, so do plugin installs, and\n * so will whatever needs a host-side directory next; naming any one of them in the description is\n * what made this read like a settings flag.\n */\nexport default Runtime.handler(\n\tCmd.commands.session.commands.link,\n\tEffect.fn(\"CLI.session.link\")(function* ({ session, path, unlink, server }) {\n\t\tconst id = yield* sessionId(session);\n\t\tconst program = Effect.gen(function* () {\n\t\t\tconst nodePath = yield* Path.Path;\n\t\t\tconst rpc = yield* Client.make;\n\t\t\tconst hostDir = unlink\n\t\t\t\t? undefined\n\t\t\t\t: Session.AbsolutePath.make(nodePath.resolve(Option.getOrElse(path, () => \".\")));\n\n\t\t\tconst info = yield* rpc[\"session.link\"]({\n\t\t\t\tsessionId: id,\n\t\t\t\t...(hostDir === undefined ? {} : { hostDir }),\n\t\t\t});\n\t\t\t// Settings are re-read every exchange, so this applies at the next one: no reload, no\n\t\t\t// restart, the project layer simply starts or stops being read.\n\t\t\tyield* writeOut(\n\t\t\t\tinfo.hostDir === undefined\n\t\t\t\t\t? `Unlinked ${info.id}; it now reads the user settings alone.\\n`\n\t\t\t\t\t: `Linked ${info.id} to ${info.hostDir}\\n`,\n\t\t\t);\n\t\t});\n\n\t\treturn yield* program.pipe(Service.connect(Option.getOrUndefined(server)), Effect.catch(reportFailure));\n\t}),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,IAAA,eAAeA,QACd,IAAI,SAAS,QAAQ,SAAS,MAC9B,OAAO,GAAG,kBAAkB,CAAC,CAAC,WAAW,EAAE,SAAS,MAAM,QAAQ,UAAU;CAC3E,MAAM,KAAK,OAAO,UAAU,OAAO;CAqBnC,OAAO,OApBS,OAAO,IAAI,aAAa;EACvC,MAAM,WAAW,OAAO,KAAK;EAC7B,MAAM,MAAM,OAAOC;EACnB,MAAM,UAAU,SACb,KAAA,IACA,QAAQ,aAAa,KAAK,SAAS,QAAQ,OAAO,UAAU,YAAY,GAAG,CAAC,CAAC;EAEhF,MAAM,OAAO,OAAO,IAAI,eAAe,CAAC;GACvC,WAAW;GACX,GAAI,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ;EAC5C,CAAC;EAGD,OAAO,SACN,KAAK,YAAY,KAAA,IACd,YAAY,KAAK,GAAG,6CACpB,UAAU,KAAK,GAAG,MAAM,KAAK,QAAQ,GACzC;CACD,CAEoB,CAAC,CAAC,KAAKC,QAAgB,OAAO,eAAe,MAAM,CAAC,GAAG,OAAO,MAAM,aAAa,CAAC;AACvG,CAAC,CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { S as contract_exports, a as reportFailure, g as make, l as table, m as writeOut, p as writeJson } from "./error-BsI8iNna.mjs";
|
|
2
|
-
import { i as Cmd, t as handler } from "./runtime-
|
|
3
|
-
import { t as connect } from "./service-
|
|
2
|
+
import { i as Cmd, t as handler } from "./runtime-CyXV7HH_.mjs";
|
|
3
|
+
import { t as connect } from "./service-YVNwFMNf.mjs";
|
|
4
4
|
import { t as sessionId } from "./ids-BW5msGUm.mjs";
|
|
5
5
|
import { Effect, Option, Schema } from "effect";
|
|
6
6
|
//#region src/cli/cmd/handlers/thread/list.ts
|
|
@@ -31,4 +31,4 @@ var list_default = handler(Cmd.commands.thread.commands.list, Effect.fn("CLI.thr
|
|
|
31
31
|
//#endregion
|
|
32
32
|
export { list_default as default };
|
|
33
33
|
|
|
34
|
-
//# sourceMappingURL=list-
|
|
34
|
+
//# sourceMappingURL=list-Bn5CvS1y.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-
|
|
1
|
+
{"version":3,"file":"list-Bn5CvS1y.mjs","names":["Runtime.handler","Client.make","ThreadInfoSchema","Service.connect"],"sources":["../../src/cli/cmd/handlers/thread/list.ts"],"sourcesContent":["import { Effect, Option, Schema } from \"effect\";\nimport * as Runtime from \"../../../../framework/runtime.ts\";\nimport * as Client from \"../../../../server/client.ts\";\nimport * as Service from \"../../../service.ts\";\nimport { type ThreadInfo, ThreadInfo as ThreadInfoSchema } from \"../../../../server/contract.ts\";\nimport { reportFailure } from \"../../../error.ts\";\nimport { sessionId } from \"../../../ids.ts\";\nimport { table, writeJson, writeOut } from \"../../../output.ts\";\nimport { Cmd } from \"../../cmd.ts\";\n\nconst origin = (info: ThreadInfo): string => {\n\tswitch (info.origin.kind) {\n\t\tcase \"main\":\n\t\t\treturn \"main\";\n\t\tcase \"fork\":\n\t\t\treturn `fork of ${info.origin.threadId}`;\n\t\tcase \"subagent\":\n\t\t\treturn `subagent of ${info.origin.threadId}`;\n\t}\n};\n\nconst cost = (info: ThreadInfo) => `$${info.usage.cost.toFixed(4)}`;\n\nexport default Runtime.handler(\n\tCmd.commands.thread.commands.list,\n\tEffect.fn(\"CLI.thread.list\")(function* ({ session, json, server }) {\n\t\tconst id = yield* sessionId(session);\n\t\tconst program = Effect.gen(function* () {\n\t\t\tconst rpc = yield* Client.make;\n\t\t\tconst threads = yield* rpc[\"thread.list\"]({ sessionId: id });\n\t\t\tif (json) return yield* writeJson(Schema.Array(ThreadInfoSchema), threads);\n\t\t\tif (threads.length === 0) return yield* writeOut(`No threads in ${session}.\\n`);\n\t\t\tconst rows = threads.map((info) => [\n\t\t\t\tinfo.id,\n\t\t\t\torigin(info),\n\t\t\t\tinfo.model === undefined ? \"-\" : `${info.model.provider}/${info.model.id}`,\n\t\t\t\t`${info.usage.input + info.usage.output} tok ${cost(info)}`,\n\t\t\t\tinfo.title ?? \"(untitled)\",\n\t\t\t]);\n\t\t\tyield* writeOut(table(rows));\n\t\t});\n\n\t\treturn yield* program.pipe(Service.connect(Option.getOrUndefined(server)), Effect.catch(reportFailure));\n\t}),\n);\n"],"mappings":";;;;;;AAUA,MAAM,UAAU,SAA6B;CAC5C,QAAQ,KAAK,OAAO,MAApB;EACC,KAAK,QACJ,OAAO;EACR,KAAK,QACJ,OAAO,WAAW,KAAK,OAAO;EAC/B,KAAK,YACJ,OAAO,eAAe,KAAK,OAAO;CACpC;AACD;AAEA,MAAM,QAAQ,SAAqB,IAAI,KAAK,MAAM,KAAK,QAAQ,CAAC;AAEhE,IAAA,eAAeA,QACd,IAAI,SAAS,OAAO,SAAS,MAC7B,OAAO,GAAG,iBAAiB,CAAC,CAAC,WAAW,EAAE,SAAS,MAAM,UAAU;CAClE,MAAM,KAAK,OAAO,UAAU,OAAO;CAgBnC,OAAO,OAfS,OAAO,IAAI,aAAa;EAEvC,MAAM,UAAU,QAAO,OADJC,KAAAA,CACQ,cAAc,CAAC,EAAE,WAAW,GAAG,CAAC;EAC3D,IAAI,MAAM,OAAO,OAAO,UAAU,OAAO,MAAMC,iBAAAA,UAAgB,GAAG,OAAO;EACzE,IAAI,QAAQ,WAAW,GAAG,OAAO,OAAO,SAAS,iBAAiB,QAAQ,IAAI;EAC9E,MAAM,OAAO,QAAQ,KAAK,SAAS;GAClC,KAAK;GACL,OAAO,IAAI;GACX,KAAK,UAAU,KAAA,IAAY,MAAM,GAAG,KAAK,MAAM,SAAS,GAAG,KAAK,MAAM;GACtE,GAAG,KAAK,MAAM,QAAQ,KAAK,MAAM,OAAO,OAAO,KAAK,IAAI;GACxD,KAAK,SAAS;EACf,CAAC;EACD,OAAO,SAAS,MAAM,IAAI,CAAC;CAC5B,CAEoB,CAAC,CAAC,KAAKC,QAAgB,OAAO,eAAe,MAAM,CAAC,GAAG,OAAO,MAAM,aAAa,CAAC;AACvG,CAAC,CACF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { a as reportFailure, m as writeOut } from "./error-BsI8iNna.mjs";
|
|
2
|
+
import { i as Cmd, t as handler } from "./runtime-CyXV7HH_.mjs";
|
|
3
|
+
import { i as withConnectApi, n as formatConnectionLine, r as printJson } from "./shared-CXbDdgs4.mjs";
|
|
4
|
+
import { Effect, Option } from "effect";
|
|
5
|
+
//#region src/cli/cmd/handlers/connect/list.ts
|
|
6
|
+
var list_default = handler(Cmd.commands.connect.commands.list, Effect.fn("CLI.connect.list")(function* ({ kind, connector, includeEnv, server, json }) {
|
|
7
|
+
return yield* withConnectApi(server, (api) => Effect.gen(function* () {
|
|
8
|
+
const items = yield* api.list({
|
|
9
|
+
kind: Option.getOrUndefined(kind),
|
|
10
|
+
connectorId: Option.getOrUndefined(connector),
|
|
11
|
+
includeEnv
|
|
12
|
+
});
|
|
13
|
+
if (json) {
|
|
14
|
+
yield* printJson(items);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (items.length === 0) {
|
|
18
|
+
yield* writeOut("No connections configured. Run `codework connect discover` to browse connectors.\n");
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
for (const item of items) yield* writeOut(`${formatConnectionLine(item)}\n`);
|
|
22
|
+
})).pipe(Effect.catch(reportFailure));
|
|
23
|
+
}));
|
|
24
|
+
//#endregion
|
|
25
|
+
export { list_default as default };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=list-C29G-xrA.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-C29G-xrA.mjs","names":["Runtime.handler"],"sources":["../../src/cli/cmd/handlers/connect/list.ts"],"sourcesContent":["import { Effect, Option } from \"effect\";\nimport * as Runtime from \"../../../../framework/runtime.ts\";\nimport { reportFailure } from \"../../../error.ts\";\nimport { writeOut } from \"../../../output.ts\";\nimport { Cmd } from \"../../cmd.ts\";\nimport { formatConnectionLine, printJson, withConnectApi } from \"./shared.ts\";\n\nexport default Runtime.handler(\n\tCmd.commands.connect.commands.list,\n\tEffect.fn(\"CLI.connect.list\")(function* ({ kind, connector, includeEnv, server, json }) {\n\t\tconst program = withConnectApi(server, (api) =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst items = yield* api.list({\n\t\t\t\t\tkind: Option.getOrUndefined(kind),\n\t\t\t\t\tconnectorId: Option.getOrUndefined(connector),\n\t\t\t\t\tincludeEnv,\n\t\t\t\t});\n\t\t\t\tif (json) {\n\t\t\t\t\tyield* printJson(items);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (items.length === 0) {\n\t\t\t\t\tyield* writeOut(\"No connections configured. Run `codework connect discover` to browse connectors.\\n\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tfor (const item of items) {\n\t\t\t\t\tyield* writeOut(`${formatConnectionLine(item)}\\n`);\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\t\treturn yield* program.pipe(Effect.catch(reportFailure));\n\t}),\n);\n"],"mappings":";;;;;AAOA,IAAA,eAAeA,QACd,IAAI,SAAS,QAAQ,SAAS,MAC9B,OAAO,GAAG,kBAAkB,CAAC,CAAC,WAAW,EAAE,MAAM,WAAW,YAAY,QAAQ,QAAQ;CAqBvF,OAAO,OApBS,eAAe,SAAS,QACvC,OAAO,IAAI,aAAa;EACvB,MAAM,QAAQ,OAAO,IAAI,KAAK;GAC7B,MAAM,OAAO,eAAe,IAAI;GAChC,aAAa,OAAO,eAAe,SAAS;GAC5C;EACD,CAAC;EACD,IAAI,MAAM;GACT,OAAO,UAAU,KAAK;GACtB;EACD;EACA,IAAI,MAAM,WAAW,GAAG;GACvB,OAAO,SAAS,oFAAoF;GACpG;EACD;EACA,KAAK,MAAM,QAAQ,OAClB,OAAO,SAAS,GAAG,qBAAqB,IAAI,EAAE,GAAG;CAEnD,CAAC,CAEkB,CAAC,CAAC,KAAK,OAAO,MAAM,aAAa,CAAC;AACvD,CAAC,CACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as reportFailure, m as writeOut } from "./error-BsI8iNna.mjs";
|
|
2
|
-
import { i as Cmd, t as handler } from "./runtime-
|
|
2
|
+
import { i as Cmd, t as handler } from "./runtime-CyXV7HH_.mjs";
|
|
3
3
|
import { i as read } from "./entries-8D1NzQXw.mjs";
|
|
4
4
|
import { Effect, Schema } from "effect";
|
|
5
5
|
import { Plugin } from "@codeworksh/harness/effect";
|
|
@@ -74,4 +74,4 @@ var list_default = handler(Cmd.commands.plugin.commands.list, Effect.fn("CLI.plu
|
|
|
74
74
|
//#endregion
|
|
75
75
|
export { list_default as default };
|
|
76
76
|
|
|
77
|
-
//# sourceMappingURL=list-
|
|
77
|
+
//# sourceMappingURL=list-CdS1_gFF.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-
|
|
1
|
+
{"version":3,"file":"list-CdS1_gFF.mjs","names":["Runtime.handler"],"sources":["../../src/cli/cmd/handlers/plugin/list.ts"],"sourcesContent":["import { Plugin } from \"@codeworksh/harness/effect\";\nimport { Effect, Schema } from \"effect\";\nimport * as Runtime from \"../../../../framework/runtime.ts\";\nimport { reportFailure } from \"../../../error.ts\";\nimport { writeOut } from \"../../../output.ts\";\nimport { Cmd } from \"../../cmd.ts\";\nimport { read } from \"./entries.ts\";\n\n/**\n * Two columns: what was written, and what it turned out to be.\n *\n * **The second column doubles as the state, for free.** An ID cannot be known without importing\n * the module -- the store records nothing about the plugin inside a package -- so printing one is\n * proof that everything worked: the entry parsed, the store had it, the import succeeded, and the\n * definition validated. When any of that fails there is no ID to print, and the reason goes in its\n * place.\n *\n * **Nothing is stored to make that work.** The reason is the live error from this run, not a\n * record of an older one: a stored failure goes stale the moment someone fixes the cause, and a\n * list still printing `plugin-import-failed` after you installed the missing dependency is worse\n * than one that says nothing. The work is cheap and local -- a parse, a lookup and an import.\n *\n * (`checkedAt`/`outdated` are stored, for the opposite reason: those come from the network, so\n * re-obtaining them is expensive and a slightly stale answer is the right trade. Local facts are\n * recomputed; remote facts are cached.)\n */\nconst isSourceError = Schema.is(Plugin.SourceError);\nconst isInstallError = Schema.is(Plugin.InstallError);\nconst isStoreError = Schema.is(Plugin.StoreError);\nconst isLoadError = Schema.is(Plugin.LoadError);\n\n/** The §5.5 reason slug, which is the same string the CLI prints and a log line carries. */\nconst reasonOf = (error: unknown): { readonly reason: string; readonly message: string } =>\n\tisSourceError(error) || isInstallError(error) || isStoreError(error) || isLoadError(error)\n\t\t? { reason: error.reason, message: error.message }\n\t\t: { reason: \"plugin-load-failed\", message: String(error) };\n\nexport default Runtime.handler(\n\tCmd.commands.plugin.commands.list,\n\tEffect.fn(\"CLI.plugin.list\")(function* ({ verbose }) {\n\t\tconst program = Effect.gen(function* () {\n\t\t\tconst shared = yield* Cmd.spec;\n\t\t\tconst { entries, cache } = yield* read(shared);\n\t\t\tif (entries.length === 0) {\n\t\t\t\tyield* writeOut(\"No plugins are configured.\\n\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst rows: Array<{ written: string; file: string; state: string; detail?: string }> = [];\n\t\t\tfor (const entry of entries) {\n\t\t\t\t// Resolve-only: listing what is configured must never install anything.\n\t\t\t\tconst inspected = yield* Plugin.inspect(entry.reference, {\n\t\t\t\t\tcache,\n\t\t\t\t\thostDir: entry.from,\n\t\t\t\t\tfile: entry.file,\n\t\t\t\t\tinstall: Plugin.resolveCached,\n\t\t\t\t}).pipe(Effect.result);\n\t\t\t\trows.push(\n\t\t\t\t\tinspected._tag === \"Success\"\n\t\t\t\t\t\t? { written: entry.written, file: entry.file, state: inspected.success.id }\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\twritten: entry.written,\n\t\t\t\t\t\t\t\tfile: entry.file,\n\t\t\t\t\t\t\t\tstate: reasonOf(inspected.failure).reason,\n\t\t\t\t\t\t\t\tdetail: reasonOf(inspected.failure).message,\n\t\t\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// The left column is the reference exactly as the entry spells it, because that is the\n\t\t\t// string a person will search their settings for.\n\t\t\tconst width = Math.max(...rows.map((row) => row.written.length));\n\t\t\tfor (const row of rows) {\n\t\t\t\tyield* writeOut(`${row.written.padEnd(width)} ${row.state}\\n`);\n\t\t\t\tif (verbose) {\n\t\t\t\t\tif (row.detail !== undefined) yield* writeOut(`${\" \".repeat(width)} ${row.detail}\\n`);\n\t\t\t\t\tyield* writeOut(`${\" \".repeat(width)} declared in: ${row.file}\\n`);\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":";;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAM,gBAAgB,OAAO,GAAG,OAAO,WAAW;AAClD,MAAM,iBAAiB,OAAO,GAAG,OAAO,YAAY;AACpD,MAAM,eAAe,OAAO,GAAG,OAAO,UAAU;AAChD,MAAM,cAAc,OAAO,GAAG,OAAO,SAAS;;AAG9C,MAAM,YAAY,UACjB,cAAc,KAAK,KAAK,eAAe,KAAK,KAAK,aAAa,KAAK,KAAK,YAAY,KAAK,IACtF;CAAE,QAAQ,MAAM;CAAQ,SAAS,MAAM;AAAQ,IAC/C;CAAE,QAAQ;CAAsB,SAAS,OAAO,KAAK;AAAE;AAE3D,IAAA,eAAeA,QACd,IAAI,SAAS,OAAO,SAAS,MAC7B,OAAO,GAAG,iBAAiB,CAAC,CAAC,WAAW,EA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Cmd, t as handler } from "./runtime-
|
|
3
|
-
import { n as synced } from "./catalog-
|
|
2
|
+
import { i as Cmd, t as handler } from "./runtime-CyXV7HH_.mjs";
|
|
3
|
+
import { n as synced } from "./catalog-Dzi9__Rq.mjs";
|
|
4
4
|
import { Effect, Option } from "effect";
|
|
5
5
|
import { ModelCatalog } from "@codeworksh/harness/effect";
|
|
6
6
|
//#region src/cli/cmd/handlers/models/list.ts
|
|
@@ -27,4 +27,4 @@ var list_default = handler(Cmd.commands.models, Effect.fn("CLI.models.list")(fun
|
|
|
27
27
|
//#endregion
|
|
28
28
|
export { list_default as default };
|
|
29
29
|
|
|
30
|
-
//# sourceMappingURL=list-
|
|
30
|
+
//# sourceMappingURL=list-DAA92mUG.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-
|
|
1
|
+
{"version":3,"file":"list-DAA92mUG.mjs","names":["Runtime.handler"],"sources":["../../src/cli/cmd/handlers/models/list.ts"],"sourcesContent":["import { ModelCatalog } from \"@codeworksh/harness/effect\";\nimport { Effect, Option } from \"effect\";\nimport * as Runtime from \"../../../../framework/runtime.ts\";\nimport { InvalidInputError, 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,\n\tEffect.fn(\"CLI.models.list\")(function* ({ provider }) {\n\t\tconst program = Effect.gen(function* () {\n\t\t\tyield* synced;\n\t\t\tconst catalog = yield* ModelCatalog.models;\n\t\t\tif (Option.isSome(provider)) {\n\t\t\t\tconst providerId = provider.value;\n\t\t\t\tif (!Object.hasOwn(catalog, providerId)) {\n\t\t\t\t\treturn yield* new InvalidInputError({\n\t\t\t\t\t\tmessage: `provider \"${providerId}\" is not in the catalog\\nhint: run \\`codework models providers\\``,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tconst sorted = Object.keys(catalog[providerId] ?? {}).sort((a, b) => a.localeCompare(b));\n\t\t\t\tyield* writeOut(sorted.map((modelId) => `${providerId}/${modelId}\\n`).join(\"\"));\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst lines: string[] = [];\n\t\t\tconst providers = Object.keys(catalog).sort((a, b) => a.localeCompare(b));\n\t\t\tfor (const providerId of providers) {\n\t\t\t\tconst providerModels = Object.keys(catalog[providerId] ?? {}).sort((a, b) => a.localeCompare(b));\n\t\t\t\tfor (const modelId of providerModels) {\n\t\t\t\t\tlines.push(`${providerId}/${modelId}\\n`);\n\t\t\t\t}\n\t\t\t}\n\t\t\tyield* writeOut(lines.join(\"\"));\n\t\t});\n\n\t\treturn yield* program.pipe(Effect.catch(reportFailure));\n\t}),\n);\n"],"mappings":";;;;;;AAQA,IAAA,eAAeA,QACd,IAAI,SAAS,QACb,OAAO,GAAG,iBAAiB,CAAC,CAAC,WAAW,EAAE,YAAY;CA2BrD,OAAO,OA1BS,OAAO,IAAI,aAAa;EACvC,OAAO;EACP,MAAM,UAAU,OAAO,aAAa;EACpC,IAAI,OAAO,OAAO,QAAQ,GAAG;GAC5B,MAAM,aAAa,SAAS;GAC5B,IAAI,CAAC,OAAO,OAAO,SAAS,UAAU,GACrC,OAAO,OAAO,IAAI,kBAAkB,EACnC,SAAS,aAAa,WAAW,kEAClC,CAAC;GAEF,MAAM,SAAS,OAAO,KAAK,QAAQ,eAAe,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,MAAM,EAAE,cAAc,CAAC,CAAC;GACvF,OAAO,SAAS,OAAO,KAAK,YAAY,GAAG,WAAW,GAAG,QAAQ,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC;GAC9E;EACD;EAEA,MAAM,QAAkB,CAAC;EACzB,MAAM,YAAY,OAAO,KAAK,OAAO,CAAC,CAAC,MAAM,GAAG,MAAM,EAAE,cAAc,CAAC,CAAC;EACxE,KAAK,MAAM,cAAc,WAAW;GACnC,MAAM,iBAAiB,OAAO,KAAK,QAAQ,eAAe,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,MAAM,EAAE,cAAc,CAAC,CAAC;GAC/F,KAAK,MAAM,WAAW,gBACrB,MAAM,KAAK,GAAG,WAAW,GAAG,QAAQ,GAAG;EAEzC;EACA,OAAO,SAAS,MAAM,KAAK,EAAE,CAAC;CAC/B,CAEoB,CAAC,CAAC,KAAK,OAAO,MAAM,aAAa,CAAC;AACvD,CAAC,CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as reportFailure, m as writeOut } from "./error-BsI8iNna.mjs";
|
|
2
|
-
import { i as Cmd, t as handler } from "./runtime-
|
|
3
|
-
import { n as configured, r as describe, t as MARKS } from "./shared-
|
|
2
|
+
import { i as Cmd, t as handler } from "./runtime-CyXV7HH_.mjs";
|
|
3
|
+
import { n as configured, r as describe, t as MARKS } from "./shared-D_MVXtOf.mjs";
|
|
4
4
|
import { Effect, Layer, References } from "effect";
|
|
5
5
|
import { Database, Event, Mcp } from "@codeworksh/harness/effect";
|
|
6
6
|
//#region src/cli/cmd/handlers/mcp/list.ts
|
|
@@ -68,4 +68,4 @@ var list_default = handler(Cmd.commands.mcp.commands.list, Effect.fn("CLI.mcp.li
|
|
|
68
68
|
//#endregion
|
|
69
69
|
export { list_default as default };
|
|
70
70
|
|
|
71
|
-
//# sourceMappingURL=list-
|
|
71
|
+
//# sourceMappingURL=list-MiZ6rD_w.mjs.map
|