@codeworksh/cli 0.9.0-canary.160.1.g8b6596ff → 0.9.0-canary.161.1.gdb3b1409

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.
Files changed (110) hide show
  1. package/{acp-DuWjGq3q.mjs → acp-NKndM0y4.mjs} +4 -4
  2. package/{acp-DuWjGq3q.mjs.map → acp-NKndM0y4.mjs.map} +1 -1
  3. package/{add-Bf7S3xyS.mjs → add-Dnl6Cvyn.mjs} +5 -5
  4. package/{add-Bf7S3xyS.mjs.map → add-Dnl6Cvyn.mjs.map} +1 -1
  5. package/{add-CdqkkEgo.mjs → add-_fJrOsjf.mjs} +5 -5
  6. package/{add-CdqkkEgo.mjs.map → add-_fJrOsjf.mjs.map} +1 -1
  7. package/{catalog-BhnZFkoq.mjs → catalog-CqY2eM62.mjs} +2 -2
  8. package/{catalog-BhnZFkoq.mjs.map → catalog-CqY2eM62.mjs.map} +1 -1
  9. package/{check-qniur0f-.mjs → check-CvJjC0rF.mjs} +4 -4
  10. package/{check-qniur0f-.mjs.map → check-CvJjC0rF.mjs.map} +1 -1
  11. package/{connect-C9Qlstmk.mjs → connect-Cwz4fwcc.mjs} +6 -6
  12. package/{connect-C9Qlstmk.mjs.map → connect-Cwz4fwcc.mjs.map} +1 -1
  13. package/{control-BN5pPW6Z.mjs → control-IZ0QF_Ye.mjs} +6 -6
  14. package/{control-BN5pPW6Z.mjs.map → control-IZ0QF_Ye.mjs.map} +1 -1
  15. package/{devices-aPlpoGGA.mjs → devices-CgsNM40i.mjs} +4 -4
  16. package/{devices-aPlpoGGA.mjs.map → devices-CgsNM40i.mjs.map} +1 -1
  17. package/disconnect-CjiHyadm.mjs +2 -0
  18. package/{disconnect-D98vTza4.mjs → disconnect-D4g8ISX9.mjs} +5 -5
  19. package/{disconnect-D98vTza4.mjs.map → disconnect-D4g8ISX9.mjs.map} +1 -1
  20. package/{discovery-RAocoXhu.mjs → discovery-CULIX-ah.mjs} +3 -3
  21. package/{discovery-RAocoXhu.mjs.map → discovery-CULIX-ah.mjs.map} +1 -1
  22. package/{entries-B6pHaiVs.mjs → entries-E2jIitR8.mjs} +3 -3
  23. package/{entries-B6pHaiVs.mjs.map → entries-E2jIitR8.mjs.map} +1 -1
  24. package/{error-ippxl2z7.mjs → error-qctchbYS.mjs} +13 -5
  25. package/error-qctchbYS.mjs.map +1 -0
  26. package/{fork-lbhh_6QP.mjs → fork-DyTp6gur.mjs} +5 -5
  27. package/{fork-lbhh_6QP.mjs.map → fork-DyTp6gur.mjs.map} +1 -1
  28. package/{identity-Dps5qkHz.mjs → identity--j8hMb07.mjs} +2 -2
  29. package/{identity-Dps5qkHz.mjs.map → identity--j8hMb07.mjs.map} +1 -1
  30. package/{ids-cNIRx0-c.mjs → ids-B4WUlv3c.mjs} +2 -2
  31. package/{ids-cNIRx0-c.mjs.map → ids-B4WUlv3c.mjs.map} +1 -1
  32. package/index.mjs +39 -39
  33. package/{install-Dzk6gQ3R.mjs → install-ButFcIwG.mjs} +4 -4
  34. package/{install-Dzk6gQ3R.mjs.map → install-ButFcIwG.mjs.map} +1 -1
  35. package/{jsonc-CXTpkzZe.mjs → jsonc-mZQUgSGM.mjs} +2 -2
  36. package/{jsonc-CXTpkzZe.mjs.map → jsonc-mZQUgSGM.mjs.map} +1 -1
  37. package/{link-D1cicwAl.mjs → link-BPgFVZti.mjs} +5 -5
  38. package/{link-D1cicwAl.mjs.map → link-BPgFVZti.mjs.map} +1 -1
  39. package/{list-DZK016LF.mjs → list-3a-BNhbN.mjs} +4 -4
  40. package/{list-DZK016LF.mjs.map → list-3a-BNhbN.mjs.map} +1 -1
  41. package/{list-BKJgNMJm.mjs → list-Bf7dMOGL.mjs} +5 -5
  42. package/{list-BKJgNMJm.mjs.map → list-Bf7dMOGL.mjs.map} +1 -1
  43. package/{list-BvMEYZss.mjs → list-CsqVdx1d.mjs} +4 -4
  44. package/{list-BvMEYZss.mjs.map → list-CsqVdx1d.mjs.map} +1 -1
  45. package/{list-e5NT4i9D.mjs → list-j-_v5-3C.mjs} +4 -4
  46. package/{list-e5NT4i9D.mjs.map → list-j-_v5-3C.mjs.map} +1 -1
  47. package/{login-CXRvj9pQ.mjs → login-DEPYLDKu.mjs} +4 -4
  48. package/{login-CXRvj9pQ.mjs.map → login-DEPYLDKu.mjs.map} +1 -1
  49. package/{login-DuFDeGH-.mjs → login-DRLw9AuP.mjs} +4 -4
  50. package/{login-DuFDeGH-.mjs.map → login-DRLw9AuP.mjs.map} +1 -1
  51. package/{logout-CA1No9_2.mjs → logout-Ci-Or_6v.mjs} +4 -4
  52. package/{logout-CA1No9_2.mjs.map → logout-Ci-Or_6v.mjs.map} +1 -1
  53. package/{logout-Dp3FLxH-.mjs → logout-UNTEpkgU.mjs} +4 -4
  54. package/{logout-Dp3FLxH-.mjs.map → logout-UNTEpkgU.mjs.map} +1 -1
  55. package/package-B5dVwZ1g.mjs +6 -0
  56. package/package-B5dVwZ1g.mjs.map +1 -0
  57. package/package.json +3 -3
  58. package/{pair-BC8a_KYX.mjs → pair-BDsnQtS0.mjs} +4 -4
  59. package/{pair-BC8a_KYX.mjs.map → pair-BDsnQtS0.mjs.map} +1 -1
  60. package/{providers--giKGohM.mjs → providers-COmYmk9Z.mjs} +4 -4
  61. package/{providers--giKGohM.mjs.map → providers-COmYmk9Z.mjs.map} +1 -1
  62. package/reconnect-BFaxT1DU.mjs +2 -0
  63. package/{refresh-BIH3qn5A.mjs → refresh-BAvSvO8q.mjs} +4 -4
  64. package/{refresh-BIH3qn5A.mjs.map → refresh-BAvSvO8q.mjs.map} +1 -1
  65. package/{refresh-Dg8WvRcq.mjs → refresh-CQv7naBW.mjs} +4 -4
  66. package/{refresh-Dg8WvRcq.mjs.map → refresh-CQv7naBW.mjs.map} +1 -1
  67. package/{relay-UTS7NtSR.mjs → relay-Ccwzl2lc.mjs} +4 -4
  68. package/{relay-UTS7NtSR.mjs.map → relay-Ccwzl2lc.mjs.map} +1 -1
  69. package/{relink-D8Koos_q.mjs → relink-BoQdyC5R.mjs} +5 -5
  70. package/{relink-D8Koos_q.mjs.map → relink-BoQdyC5R.mjs.map} +1 -1
  71. package/{reload-C5-B0s9x.mjs → reload-7PaufKR2.mjs} +4 -4
  72. package/{reload-C5-B0s9x.mjs.map → reload-7PaufKR2.mjs.map} +1 -1
  73. package/{remove-CReTs9O7.mjs → remove-BMEqPSq7.mjs} +4 -4
  74. package/{remove-CReTs9O7.mjs.map → remove-BMEqPSq7.mjs.map} +1 -1
  75. package/{remove-W7QswkaH.mjs → remove-CkVHlj69.mjs} +5 -5
  76. package/{remove-W7QswkaH.mjs.map → remove-CkVHlj69.mjs.map} +1 -1
  77. package/{restart-B1CsEzlL.mjs → restart-9yoKrlmo.mjs} +5 -5
  78. package/{restart-B1CsEzlL.mjs.map → restart-9yoKrlmo.mjs.map} +1 -1
  79. package/{revoke-Gu5N3Vzy.mjs → revoke-BCWK0foJ.mjs} +4 -4
  80. package/{revoke-Gu5N3Vzy.mjs.map → revoke-BCWK0foJ.mjs.map} +1 -1
  81. package/{run-RHrJN2Pv.mjs → run-DEE9e1dU.mjs} +5 -5
  82. package/{run-RHrJN2Pv.mjs.map → run-DEE9e1dU.mjs.map} +1 -1
  83. package/{runtime-CtLWuLd-.mjs → runtime-BC3hAvn_.mjs} +2 -2
  84. package/{runtime-CtLWuLd-.mjs.map → runtime-BC3hAvn_.mjs.map} +1 -1
  85. package/{serve-DGQOucNu.mjs → serve-CkGkCgTL.mjs} +22 -11
  86. package/serve-CkGkCgTL.mjs.map +1 -0
  87. package/{service-CRnqz89w.mjs → service-bQHXHYll.mjs} +3 -3
  88. package/{service-CRnqz89w.mjs.map → service-bQHXHYll.mjs.map} +1 -1
  89. package/{settings-CyvcSIcs.mjs → settings-DgH9gU-f.mjs} +3 -3
  90. package/{settings-CyvcSIcs.mjs.map → settings-DgH9gU-f.mjs.map} +1 -1
  91. package/{shared-Dzwbs5Lk.mjs → shared-CbPD6Xel.mjs} +4 -4
  92. package/{shared-Dzwbs5Lk.mjs.map → shared-CbPD6Xel.mjs.map} +1 -1
  93. package/{shared-BzfKCE2E.mjs → shared-D68fsVKM.mjs} +4 -4
  94. package/{shared-BzfKCE2E.mjs.map → shared-D68fsVKM.mjs.map} +1 -1
  95. package/{start-DVU9_HiQ.mjs → start-t0FCZvYw.mjs} +5 -5
  96. package/{start-DVU9_HiQ.mjs.map → start-t0FCZvYw.mjs.map} +1 -1
  97. package/{status-B2s6iBck.mjs → status-2NsYhn1K.mjs} +5 -5
  98. package/{status-B2s6iBck.mjs.map → status-2NsYhn1K.mjs.map} +1 -1
  99. package/{status-DJJOuCzL.mjs → status-DGGYd1NC.mjs} +4 -4
  100. package/{status-DJJOuCzL.mjs.map → status-DGGYd1NC.mjs.map} +1 -1
  101. package/{stop-C9hSMdVa.mjs → stop-CDk0lO6x.mjs} +5 -5
  102. package/{stop-C9hSMdVa.mjs.map → stop-CDk0lO6x.mjs.map} +1 -1
  103. package/{update-XBsVxrRL.mjs → update-EcSQRcWk.mjs} +4 -4
  104. package/{update-XBsVxrRL.mjs.map → update-EcSQRcWk.mjs.map} +1 -1
  105. package/disconnect-BTG_FVoG.mjs +0 -2
  106. package/error-ippxl2z7.mjs.map +0 -1
  107. package/package-D8VAWqDw.mjs +0 -6
  108. package/package-D8VAWqDw.mjs.map +0 -1
  109. package/reconnect-b5LQebj0.mjs +0 -2
  110. package/serve-DGQOucNu.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"disconnect-D98vTza4.mjs","names":["Runtime.handler","Service.home","File.read","Relay.disconnect"],"sources":["../../src/cli/cmd/handlers/disconnect.ts"],"sourcesContent":["import { Effect, Option } from \"effect\";\nimport * as Runtime from \"../../../framework/runtime.ts\";\nimport * as File from \"../../../machine/file.ts\";\nimport * as Relay from \"../../../machine/relay.ts\";\nimport { InvalidInputError, reportFailure } from \"../../error.ts\";\nimport { writeOut } from \"../../output.ts\";\nimport * as Service from \"../../service.ts\";\nimport { Cmd } from \"../cmd.ts\";\n\nexport default Runtime.handler(\n\tCmd.commands.disconnect,\n\tEffect.fn(\"CLI.disconnect\")(function* ({ workspace }) {\n\t\tconst paths = yield* Service.home(yield* Cmd.spec);\n\t\tconst connected = Option.match(yield* File.read(paths.home), {\n\t\t\tonNone: () => [],\n\t\t\tonSome: (machine) => Object.keys(machine.workspaces),\n\t\t});\n\t\tconst workspaceId = Option.getOrUndefined(workspace) ?? (connected.length === 1 ? connected[0] : undefined);\n\t\tif (workspaceId === undefined) {\n\t\t\treturn yield* new InvalidInputError({\n\t\t\t\tmessage:\n\t\t\t\t\tconnected.length === 0\n\t\t\t\t\t\t? \"This machine is not connected to any workspace\"\n\t\t\t\t\t\t: `Connected to ${connected.length} workspaces; name one with --workspace (${connected.join(\", \")})`,\n\t\t\t});\n\t\t}\n\t\tconst result = yield* Relay.disconnect(paths.home, workspaceId);\n\t\tyield* writeOut(\n\t\t\tresult.revoked\n\t\t\t\t? `Disconnected from ${result.workspace}\\n`\n\t\t\t\t: `Leaving ${result.workspace}: Relay didn’t confirm, so this machine keeps the link until it does. The server retries while it runs.\\n`,\n\t\t);\n\t}, Effect.catch(reportFailure)),\n);\n"],"mappings":";;;;;;AASA,IAAA,qBAAeA,QACd,IAAI,SAAS,YACb,OAAO,GAAG,gBAAgB,CAAC,CAAC,WAAW,EAAE,aAAa;CACrD,MAAM,QAAQ,OAAOC,KAAa,OAAO,IAAI,IAAI;CACjD,MAAM,YAAY,OAAO,MAAM,OAAOC,KAAU,MAAM,IAAI,GAAG;EAC5D,cAAc,CAAC;EACf,SAAS,YAAY,OAAO,KAAK,QAAQ,UAAU;CACpD,CAAC;CACD,MAAM,cAAc,OAAO,eAAe,SAAS,MAAM,UAAU,WAAW,IAAI,UAAU,KAAK,KAAA;CACjG,IAAI,gBAAgB,KAAA,GACnB,OAAO,OAAO,IAAI,kBAAkB,EACnC,SACC,UAAU,WAAW,IAClB,mDACA,gBAAgB,UAAU,OAAO,0CAA0C,UAAU,KAAK,IAAI,EAAE,GACrG,CAAC;CAEF,MAAM,SAAS,OAAOC,WAAiB,MAAM,MAAM,WAAW;CAC9D,OAAO,SACN,OAAO,UACJ,qBAAqB,OAAO,UAAU,MACtC,WAAW,OAAO,UAAU,0GAChC;AACD,GAAG,OAAO,MAAM,aAAa,CAAC,CAC/B"}
1
+ {"version":3,"file":"disconnect-D4g8ISX9.mjs","names":["Runtime.handler","Service.home","File.read","Relay.disconnect"],"sources":["../../src/cli/cmd/handlers/disconnect.ts"],"sourcesContent":["import { Effect, Option } from \"effect\";\nimport * as Runtime from \"../../../framework/runtime.ts\";\nimport * as File from \"../../../machine/file.ts\";\nimport * as Relay from \"../../../machine/relay.ts\";\nimport { InvalidInputError, reportFailure } from \"../../error.ts\";\nimport { writeOut } from \"../../output.ts\";\nimport * as Service from \"../../service.ts\";\nimport { Cmd } from \"../cmd.ts\";\n\nexport default Runtime.handler(\n\tCmd.commands.disconnect,\n\tEffect.fn(\"CLI.disconnect\")(function* ({ workspace }) {\n\t\tconst paths = yield* Service.home(yield* Cmd.spec);\n\t\tconst connected = Option.match(yield* File.read(paths.home), {\n\t\t\tonNone: () => [],\n\t\t\tonSome: (machine) => Object.keys(machine.workspaces),\n\t\t});\n\t\tconst workspaceId = Option.getOrUndefined(workspace) ?? (connected.length === 1 ? connected[0] : undefined);\n\t\tif (workspaceId === undefined) {\n\t\t\treturn yield* new InvalidInputError({\n\t\t\t\tmessage:\n\t\t\t\t\tconnected.length === 0\n\t\t\t\t\t\t? \"This machine is not connected to any workspace\"\n\t\t\t\t\t\t: `Connected to ${connected.length} workspaces; name one with --workspace (${connected.join(\", \")})`,\n\t\t\t});\n\t\t}\n\t\tconst result = yield* Relay.disconnect(paths.home, workspaceId);\n\t\tyield* writeOut(\n\t\t\tresult.revoked\n\t\t\t\t? `Disconnected from ${result.workspace}\\n`\n\t\t\t\t: `Leaving ${result.workspace}: Relay didn’t confirm, so this machine keeps the link until it does. The server retries while it runs.\\n`,\n\t\t);\n\t}, Effect.catch(reportFailure)),\n);\n"],"mappings":";;;;;;AASA,IAAA,qBAAeA,QACd,IAAI,SAAS,YACb,OAAO,GAAG,gBAAgB,CAAC,CAAC,WAAW,EAAE,aAAa;CACrD,MAAM,QAAQ,OAAOC,KAAa,OAAO,IAAI,IAAI;CACjD,MAAM,YAAY,OAAO,MAAM,OAAOC,KAAU,MAAM,IAAI,GAAG;EAC5D,cAAc,CAAC;EACf,SAAS,YAAY,OAAO,KAAK,QAAQ,UAAU;CACpD,CAAC;CACD,MAAM,cAAc,OAAO,eAAe,SAAS,MAAM,UAAU,WAAW,IAAI,UAAU,KAAK,KAAA;CACjG,IAAI,gBAAgB,KAAA,GACnB,OAAO,OAAO,IAAI,kBAAkB,EACnC,SACC,UAAU,WAAW,IAClB,mDACA,gBAAgB,UAAU,OAAO,0CAA0C,UAAU,KAAK,IAAI,EAAE,GACrG,CAAC;CAEF,MAAM,SAAS,OAAOC,WAAiB,MAAM,MAAM,WAAW;CAC9D,OAAO,SACN,OAAO,UACJ,qBAAqB,OAAO,UAAU,MACtC,WAAW,OAAO,UAAU,0GAChC;AACD,GAAG,OAAO,MAAM,aAAa,CAAC,CAC/B"}
@@ -1,6 +1,6 @@
1
- import { g as make, h as layer } from "./error-ippxl2z7.mjs";
1
+ import { g as make, h as layer } from "./error-qctchbYS.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-Dps5qkHz.mjs";
3
+ import { n as current } from "./identity--j8hMb07.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-RAocoXhu.mjs.map
174
+ //# sourceMappingURL=discovery-CULIX-ah.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"discovery-RAocoXhu.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;AAEr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AK,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
+ {"version":3,"file":"discovery-CULIX-ah.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,oBAA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,MAAM,UAAU,SAAyB,OAAO,UAAU,QAAQ,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM;CACrG,OAAO,OAAO,SAAS;CACvB,IAAI,EAAE,OAAO,MAAM,KAAK,YAAY,IAAI;EACvC,OAAO,OAAO,SAAS;EACvB,OAAO,MAAM,KAAK,YAAY;CAC/B;CAGA,KAAI,OADgBH,KAAkB,IAAI,EAAA,EAChC,QAAQ,KAAK,OAAO,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,5 +1,5 @@
1
- import { m as writeOut } from "./error-ippxl2z7.mjs";
2
- import { s as userLayer } from "./settings-CyvcSIcs.mjs";
1
+ import { m as writeOut } from "./error-qctchbYS.mjs";
2
+ import { s as userLayer } from "./settings-DgH9gU-f.mjs";
3
3
  import { Effect, Option, Path } from "effect";
4
4
  import { Global, Plugin, Settings } from "@codeworksh/harness/effect";
5
5
  //#region src/cli/cmd/handlers/plugin/entries.ts
@@ -87,4 +87,4 @@ const fetchable = (target) => target === void 0 || target.kind === "local" ? voi
87
87
  //#endregion
88
88
  export { targeted as a, read as i, local as n, probe as r, fetchable as t };
89
89
 
90
- //# sourceMappingURL=entries-B6pHaiVs.mjs.map
90
+ //# sourceMappingURL=entries-E2jIitR8.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"entries-B6pHaiVs.mjs","names":[],"sources":["../../src/cli/cmd/handlers/plugin/entries.ts"],"sourcesContent":["import { Global, Plugin, Settings } from \"@codeworksh/harness/effect\";\nimport { Effect, Option, Path } from \"effect\";\nimport { writeOut } from \"../../../output.ts\";\nimport { userLayer, type Shared } from \"./settings.ts\";\n\n/**\n * Every plugin entry the settings files name, across every layer, in the order they accumulate.\n *\n * This is what `install`, `list`, `check` and `update` all operate on: unlike `add` and `remove`,\n * none of them writes an entry. They read what is already there and act on the store -- each one\n * under the `.npmrc` context of the file that declared it, which is what keys the artifact.\n */\nexport interface Entry {\n\t/** The reference as the settings file spells it: the string a person will search for. */\n\treadonly written: string;\n\t/** The same reference, anchored to the file that declared it. This is what resolves. */\n\treadonly reference: string;\n\t/** Which settings file owns it: the last to declare it in the view that needs it. */\n\treadonly file: string;\n\t/**\n\t * The `.npmrc` anchor for the entry's store identity: the project that declared it, so the\n\t * registry context is the same wherever this command happens to run.\n\t */\n\treadonly from: string;\n\t/** Absent for an unparseable entry and for a local path. */\n\treadonly target: Plugin.Target | undefined;\n}\n\n/** Only a string entry loads a module; `{ package }` is configuration for one already selected. */\nconst moduleOf = (entry: unknown): string | undefined => (typeof entry === \"string\" ? entry : undefined);\n\nexport const read = Effect.fn(\"CLI.plugin.entries\")(function* (shared: Shared) {\n\tconst nodePath = yield* Path.Path;\n\t// The directory the command runs in resolves its app-level flags. No session links it to\n\t// another host directory, so it is the command's anchor too: project settings are discovered\n\t// from here, and a relative spec typed here resolves here.\n\tconst hostCwd = nodePath.resolve(\".\");\n\tconst hostDir = hostCwd;\n\tconst paths = yield* Global.resolve(Option.isNone(shared.home) ? {} : { home: shared.home.value });\n\tconst root = yield* Settings.projectRoot(hostDir, paths.home);\n\tconst layers = { home: paths.home, ...userLayer(shared, hostCwd) };\n\t/*\n\t * The runtime resolves plugins in two views, and each needs its own artifact on disk: boot\n\t * reads the user layers alone, and a session reads every layer. Within a view the last file to\n\t * declare a reference owns it, so a spec both layers name is owned by the user file at boot and\n\t * by the project file in the project's sessions -- two `.npmrc` anchors, and possibly two\n\t * registries. Collapsing it to one owner leaves one of those views without its artifact.\n\t */\n\tconst boot = yield* Settings.load(layers);\n\tconst views = root === undefined ? [boot] : [boot, yield* Settings.load({ ...layers, hostDir: root })];\n\n\t// One entry per store artifact, so two anchors on one registry stay a single line. A later\n\t// view names the file, which is the one a person in this project would edit.\n\tconst entries = new Map<string, Entry>();\n\tfor (const view of views) {\n\t\t// views is [boot] outside a project, or [boot, session] inside one.\n\t\t// Boot comes first, and the order matters (see below).\n\t\tfor (const [reference, one] of Settings.modules(view.declared)) {\n\t\t\t// Already anchored to the file that declared it, so `hostDir` here only affects a\n\t\t\t// reference no settings file produced.\n\t\t\tconst target = Option.getOrUndefined(yield* Plugin.parse(reference, hostDir).pipe(Effect.option));\n\t\t\tconst from = Plugin.anchor(one.file, hostDir);\n\t\t\tconst key = yield* identity(target, reference, from, paths.cache);\n\t\t\tentries.set(key, { written: moduleOf(one.written) ?? reference, reference, file: one.file, from, target });\n\t\t}\n\t}\n\treturn { entries: [...entries.values()] as ReadonlyArray<Entry>, cache: paths.cache, hostDir };\n});\n\n/**\n * What makes two entries one artifact: the store's own key for a fetched target, the file for a\n * local one. A registry that cannot be read keeps the entry apart, so its install reports why.\n */\nconst identity = (target: Plugin.Target | undefined, reference: string, from: string, cache: string) => {\n\tconst fetched = fetchable(target);\n\tif (fetched === undefined) return Effect.succeed(target?.kind === \"local\" ? target.path : reference);\n\treturn Plugin.identity(fetched, cache, from).pipe(Effect.orElseSucceed(() => `${reference}\\0${from}`));\n};\n\n/** What a reference names, whatever version it was written with: a package, a git spec, a file. */\nconst source = (reference: string, hostDir: string) =>\n\tPlugin.canonical(reference, hostDir).pipe(Effect.orElseSucceed(() => reference));\n\n/**\n * The entries a command acts on: all of them, or every one `spec` names.\n *\n * Matched by source identity, the way the `plugins` array reads -- `@acme/x` selects\n * `@acme/x@^1`, a relative path selects the file it resolves to from `hostDir`, and a local package\n * also answers to the name its `package.json` declares. A plugin ID is not a spelling of anything\n * in that array, so it matches nothing. Every match is kept: a spec both layers declare under\n * different registries is two artifacts, and both answer to it.\n */\nexport const targeted = Effect.fn(\"CLI.plugin.targeted\")(function* (\n\tentries: ReadonlyArray<Entry>,\n\tspec: Option.Option<string>,\n\t/** The host directory the command resolves from, which a relative spec is typed against. */\n\thostDir: string,\n) {\n\tif (Option.isNone(spec)) return entries;\n\tconst wanted = yield* source(spec.value, hostDir);\n\tconst selected: Entry[] = [];\n\tfor (const entry of entries) {\n\t\tconst named =\n\t\t\t(yield* source(entry.reference, hostDir)) === wanted ||\n\t\t\t(entry.target?.kind === \"local\" && (yield* Plugin.localName(entry.target.path)) === wanted);\n\t\tif (named) selected.push(entry);\n\t}\n\tif (selected.length === 0) {\n\t\tyield* writeOut(`Plugin \"${spec.value}\" is not configured. Run \\`codework plugin list\\` to see what is.\\n`);\n\t\tprocess.exitCode = 1;\n\t}\n\treturn selected as ReadonlyArray<Entry>;\n});\n\n/**\n * A local plugin has no revision to compare and is never copied into the store. Skipped quietly\n * when a command walks everything; named, it says why nothing happened.\n */\nexport const local = (entry: Entry, spec: Option.Option<string>) =>\n\tOption.isSome(spec) ? writeOut(`${entry.reference} local: no remote revision to compare\\n`) : Effect.void;\n\n/**\n * The network half, handed to the store so the store itself never opens a socket.\n *\n * `probe` bypasses pacote's own metadata cache, because a staleness check that reads a cache is\n * not a staleness check. `from` is the host directory: a probe that read a different `.npmrc`\n * chain than the install would answer about a registry nothing is ever fetched from.\n */\nexport const probe =\n\t(cache: string, from: string): Plugin.Probe =>\n\t(target) =>\n\t\tPlugin.probe(target, cache, from);\n\n/** Only a fetched target has a store entry; a local one is loaded where it lies. */\nexport const fetchable = (target: Plugin.Target | undefined): Plugin.Fetchable | undefined =>\n\ttarget === undefined || target.kind === \"local\" ? undefined : target;\n"],"mappings":";;;;;;AA6BA,MAAM,YAAY,UAAwC,OAAO,UAAU,WAAW,QAAQ,KAAA;AAE9F,MAAa,OAAO,OAAO,GAAG,oBAAoB,CAAC,CAAC,WAAW,QAAgB;CAK9E,MAAM,WAAU,OAJQ,KAAK,KAAA,CAIJ,QAAQ,GAAG;CACpC,MAAM,UAAU;CAChB,MAAM,QAAQ,OAAO,OAAO,QAAQ,OAAO,OAAO,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,MAAM,OAAO,KAAK,MAAM,CAAC;CACjG,MAAM,OAAO,OAAO,SAAS,YAAY,SAAS,MAAM,IAAI;CAC5D,MAAM,SAAS;EAAE,MAAM,MAAM;EAAM,GAAG,UAAU,QAAQ,OAAO;CAAE;CAQjE,MAAM,OAAO,OAAO,SAAS,KAAK,MAAM;CACxC,MAAM,QAAQ,SAAS,KAAA,IAAY,CAAC,IAAI,IAAI,CAAC,MAAM,OAAO,SAAS,KAAK;EAAE,GAAG;EAAQ,SAAS;CAAK,CAAC,CAAC;CAIrG,MAAM,0BAAU,IAAI,IAAmB;CACvC,KAAK,MAAM,QAAQ,OAGlB,KAAK,MAAM,CAAC,WAAW,QAAQ,SAAS,QAAQ,KAAK,QAAQ,GAAG;EAG/D,MAAM,SAAS,OAAO,eAAe,OAAO,OAAO,MAAM,WAAW,OAAO,CAAC,CAAC,KAAK,OAAO,MAAM,CAAC;EAChG,MAAM,OAAO,OAAO,OAAO,IAAI,MAAM,OAAO;EAC5C,MAAM,MAAM,OAAO,SAAS,QAAQ,WAAW,MAAM,MAAM,KAAK;EAChE,QAAQ,IAAI,KAAK;GAAE,SAAS,SAAS,IAAI,OAAO,KAAK;GAAW;GAAW,MA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AAa,OAAO,SAAS,UAAU,KAAA,IAAY"}
1
+ {"version":3,"file":"entries-E2jIitR8.mjs","names":[],"sources":["../../src/cli/cmd/handlers/plugin/entries.ts"],"sourcesContent":["import { Global, Plugin, Settings } from \"@codeworksh/harness/effect\";\nimport { Effect, Option, Path } from \"effect\";\nimport { writeOut } from \"../../../output.ts\";\nimport { userLayer, type Shared } from \"./settings.ts\";\n\n/**\n * Every plugin entry the settings files name, across every layer, in the order they accumulate.\n *\n * This is what `install`, `list`, `check` and `update` all operate on: unlike `add` and `remove`,\n * none of them writes an entry. They read what is already there and act on the store -- each one\n * under the `.npmrc` context of the file that declared it, which is what keys the artifact.\n */\nexport interface Entry {\n\t/** The reference as the settings file spells it: the string a person will search for. */\n\treadonly written: string;\n\t/** The same reference, anchored to the file that declared it. This is what resolves. */\n\treadonly reference: string;\n\t/** Which settings file owns it: the last to declare it in the view that needs it. */\n\treadonly file: string;\n\t/**\n\t * The `.npmrc` anchor for the entry's store identity: the project that declared it, so the\n\t * registry context is the same wherever this command happens to run.\n\t */\n\treadonly from: string;\n\t/** Absent for an unparseable entry and for a local path. */\n\treadonly target: Plugin.Target | undefined;\n}\n\n/** Only a string entry loads a module; `{ package }` is configuration for one already selected. */\nconst moduleOf = (entry: unknown): string | undefined => (typeof entry === \"string\" ? entry : undefined);\n\nexport const read = Effect.fn(\"CLI.plugin.entries\")(function* (shared: Shared) {\n\tconst nodePath = yield* Path.Path;\n\t// The directory the command runs in resolves its app-level flags. No session links it to\n\t// another host directory, so it is the command's anchor too: project settings are discovered\n\t// from here, and a relative spec typed here resolves here.\n\tconst hostCwd = nodePath.resolve(\".\");\n\tconst hostDir = hostCwd;\n\tconst paths = yield* Global.resolve(Option.isNone(shared.home) ? {} : { home: shared.home.value });\n\tconst root = yield* Settings.projectRoot(hostDir, paths.home);\n\tconst layers = { home: paths.home, ...userLayer(shared, hostCwd) };\n\t/*\n\t * The runtime resolves plugins in two views, and each needs its own artifact on disk: boot\n\t * reads the user layers alone, and a session reads every layer. Within a view the last file to\n\t * declare a reference owns it, so a spec both layers name is owned by the user file at boot and\n\t * by the project file in the project's sessions -- two `.npmrc` anchors, and possibly two\n\t * registries. Collapsing it to one owner leaves one of those views without its artifact.\n\t */\n\tconst boot = yield* Settings.load(layers);\n\tconst views = root === undefined ? [boot] : [boot, yield* Settings.load({ ...layers, hostDir: root })];\n\n\t// One entry per store artifact, so two anchors on one registry stay a single line. A later\n\t// view names the file, which is the one a person in this project would edit.\n\tconst entries = new Map<string, Entry>();\n\tfor (const view of views) {\n\t\t// views is [boot] outside a project, or [boot, session] inside one.\n\t\t// Boot comes first, and the order matters (see below).\n\t\tfor (const [reference, one] of Settings.modules(view.declared)) {\n\t\t\t// Already anchored to the file that declared it, so `hostDir` here only affects a\n\t\t\t// reference no settings file produced.\n\t\t\tconst target = Option.getOrUndefined(yield* Plugin.parse(reference, hostDir).pipe(Effect.option));\n\t\t\tconst from = Plugin.anchor(one.file, hostDir);\n\t\t\tconst key = yield* identity(target, reference, from, paths.cache);\n\t\t\tentries.set(key, { written: moduleOf(one.written) ?? reference, reference, file: one.file, from, target });\n\t\t}\n\t}\n\treturn { entries: [...entries.values()] as ReadonlyArray<Entry>, cache: paths.cache, hostDir };\n});\n\n/**\n * What makes two entries one artifact: the store's own key for a fetched target, the file for a\n * local one. A registry that cannot be read keeps the entry apart, so its install reports why.\n */\nconst identity = (target: Plugin.Target | undefined, reference: string, from: string, cache: string) => {\n\tconst fetched = fetchable(target);\n\tif (fetched === undefined) return Effect.succeed(target?.kind === \"local\" ? target.path : reference);\n\treturn Plugin.identity(fetched, cache, from).pipe(Effect.orElseSucceed(() => `${reference}\\0${from}`));\n};\n\n/** What a reference names, whatever version it was written with: a package, a git spec, a file. */\nconst source = (reference: string, hostDir: string) =>\n\tPlugin.canonical(reference, hostDir).pipe(Effect.orElseSucceed(() => reference));\n\n/**\n * The entries a command acts on: all of them, or every one `spec` names.\n *\n * Matched by source identity, the way the `plugins` array reads -- `@acme/x` selects\n * `@acme/x@^1`, a relative path selects the file it resolves to from `hostDir`, and a local package\n * also answers to the name its `package.json` declares. A plugin ID is not a spelling of anything\n * in that array, so it matches nothing. Every match is kept: a spec both layers declare under\n * different registries is two artifacts, and both answer to it.\n */\nexport const targeted = Effect.fn(\"CLI.plugin.targeted\")(function* (\n\tentries: ReadonlyArray<Entry>,\n\tspec: Option.Option<string>,\n\t/** The host directory the command resolves from, which a relative spec is typed against. */\n\thostDir: string,\n) {\n\tif (Option.isNone(spec)) return entries;\n\tconst wanted = yield* source(spec.value, hostDir);\n\tconst selected: Entry[] = [];\n\tfor (const entry of entries) {\n\t\tconst named =\n\t\t\t(yield* source(entry.reference, hostDir)) === wanted ||\n\t\t\t(entry.target?.kind === \"local\" && (yield* Plugin.localName(entry.target.path)) === wanted);\n\t\tif (named) selected.push(entry);\n\t}\n\tif (selected.length === 0) {\n\t\tyield* writeOut(`Plugin \"${spec.value}\" is not configured. Run \\`codework plugin list\\` to see what is.\\n`);\n\t\tprocess.exitCode = 1;\n\t}\n\treturn selected as ReadonlyArray<Entry>;\n});\n\n/**\n * A local plugin has no revision to compare and is never copied into the store. Skipped quietly\n * when a command walks everything; named, it says why nothing happened.\n */\nexport const local = (entry: Entry, spec: Option.Option<string>) =>\n\tOption.isSome(spec) ? writeOut(`${entry.reference} local: no remote revision to compare\\n`) : Effect.void;\n\n/**\n * The network half, handed to the store so the store itself never opens a socket.\n *\n * `probe` bypasses pacote's own metadata cache, because a staleness check that reads a cache is\n * not a staleness check. `from` is the host directory: a probe that read a different `.npmrc`\n * chain than the install would answer about a registry nothing is ever fetched from.\n */\nexport const probe =\n\t(cache: string, from: string): Plugin.Probe =>\n\t(target) =>\n\t\tPlugin.probe(target, cache, from);\n\n/** Only a fetched target has a store entry; a local one is loaded where it lies. */\nexport const fetchable = (target: Plugin.Target | undefined): Plugin.Fetchable | undefined =>\n\ttarget === undefined || target.kind === \"local\" ? undefined : target;\n"],"mappings":";;;;;;AA6BA,MAAM,YAAY,U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CAChC,IAAI,YAAY,KAAA,GAAW,OAAO,OAAO,QAAQ,QAAQ,SAAS,UAAU,OAAO,OAAO,SAAS;CACnG,OAAO,OAAO,SAAS,SAAS,OAAO,IAAI,CAAC,CAAC,KAAK,OAAO,oBAAoB,GAAG,UAAU,IAAI,MAAM,CAAC;AACtG;;AAGA,MAAM,UAAU,WAAmB,YAClC,OAAO,UAAU,WAAW,OAAO,CAAC,CAAC,KAAK,OAAO,oBAAoB,SAAS,CAAC;;;;;;;;;;AAWhF,MAAa,WAAW,OAAO,GAAG,qBAAqB,CAAC,CAAC,WACxD,SACA,MAEA,SACC;CACD,IAAI,OAAO,OAAO,IAAI,GAAG,OAAO;CAChC,MAAM,SAAS,OAAO,OAAO,KAAK,OAAO,OAAO;CAChD,MAAM,WAAoB,CAAC;CAC3B,KAAK,MAAM,SAAS,SAInB,KAFE,OAAO,OAAO,MAAM,WAAW,OAAO,OAAO,UAC7C,MAAM,QAAQ,SAAS,YAAY,OAAO,OAAO,UAAU,MAAM,OAAO,IAAI,OAAO,QAC1E,SAAS,KAAK,KAAK;CAE/B,IAAI,SAAS,WAAW,GAAG;EAC1B,OAAO,SAAS,WAAW,KAAK,MAAM,oEAAoE;EAC1G,QAAQ,WAAW;CACpB;CACA,OAAO;AACR,CAAC;;;;;AAMD,MAAa,SAAS,OAAc,SACnC,OAAO,OAAO,IAAI,IAAI,SAAS,GAAG,MAAM,UAAU,yCAAyC,IAAI,OAAO;;;;;;;;AASvG,MAAa,SACX,OAAe,UACf,WACA,OAAO,MAAM,QAAQ,OAAO,IAAI;;AAGlC,MAAa,aAAa,WACzB,WAAW,KAAA,KAAa,OAAO,SAAS,UAAU,KAAA,IAAY"}
@@ -964,8 +964,14 @@ const OAuthInfo = Schema.Struct({
964
964
  enterpriseUrl: optional(Schema.String),
965
965
  availableModels: optional(Schema.Int)
966
966
  });
967
- /** A host folder operation that failed: unreadable, not a directory, taken, or git/gh refused. */
968
- var HostError = class extends Schema.TaggedError()("Server.HostError", { message: Schema.String }) {};
967
+ /**
968
+ * A host folder operation that failed: unreadable, not a directory, taken, or git/gh refused. `reason`
969
+ * names a path that is not there, or is a file, so a client can offer to create it only when it is missing.
970
+ */
971
+ var HostError = class extends Schema.TaggedError()("Server.HostError", {
972
+ message: Schema.String,
973
+ reason: optional(Schema.Literals(["missing", "file"]))
974
+ }) {};
969
975
  /** A directory on the host, by its name and absolute path. */
970
976
  const Folder = Schema.Struct({
971
977
  name: Schema.String,
@@ -1588,13 +1594,15 @@ const Api = RpcGroup.make(
1588
1594
  }),
1589
1595
  /**
1590
1596
  * The directories in `path` (a leading `~` is the OS home), hidden ones included, symlinks and
1591
- * files left out. One the server may not read lists as empty.
1597
+ * files left out. One the server may not read lists as empty with `readable` false: it can still
1598
+ * be added, as a folder macOS keeps from the server can.
1592
1599
  */
1593
1600
  Rpc.make("host.browse", {
1594
1601
  payload: { path: Schema.String },
1595
1602
  success: Schema.Struct({
1596
1603
  path: Schema.String,
1597
- entries: Schema.Array(Folder)
1604
+ entries: Schema.Array(Folder),
1605
+ readable: optional(Schema.Boolean)
1598
1606
  }),
1599
1607
  error: HostError
1600
1608
  }),
@@ -2060,4 +2068,4 @@ const reportFailure = (error) => writeError(renderError(error)).pipe(Effect.andT
2060
2068
  //#endregion
2061
2069
  export { sign as $, decode as A, ticketsPath as B, Current as C, Unauthorized as D, Token as E, Exchange as F, WorkspaceId as G, Api$1 as H, Proof as I, fingerprint as J, PrivateKey as K, Signed as L, Core as M, encode as N, layerToken as O, ofThread as P, publicOf as Q, devicesPath as R, path as S, Forbidden as T, IdSource as U, ConnectError as V, MachineId as W, peek as X, generate as Y, peekClaims as Z, run as _, reportFailure as a, make$1 as at, OAuthError$1 as b, header as c, usage as d, thumbprint as et, writeError as f, make as g, layer as h, renderError as i, layer$1 as it, Connected as j, local as k, table as l, writeOut as m, OAuthError as n, encrypted as nt, addUsage as o, matches as ot, writeJson as p, PublicKey as q, error_exports as r, peer as rt, emptyUsage as s, protocols as st, InvalidInputError as t, verify as tt, terminalColumns as u, Api as v, Door as w, ThreadInfo as x, HostError as y, proofWindow as z };
2062
2070
 
2063
- //# sourceMappingURL=error-ippxl2z7.mjs.map
2071
+ //# sourceMappingURL=error-qctchbYS.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-qctchbYS.mjs","names":["make","layer","crypto","Connected","Unauthorized","Forbidden","Api","Connected","decode","Knock.make","OAuthError","Machine.Status","Machine.Disconnect","Machine.Disconnected","Machine.ConnectError","Machine.ConnectEvent","Principal.Forbidden","Principal.Door","Contract.Api","Door.protocols","Envelope.decode","Client.ExecutionError"],"sources":["../../../schema/src/door.ts","../../../schema/src/forwarded.ts","../../../schema/src/jws.ts","../../../schema/src/relay.ts","../../../schema/src/machine.ts","../../../schema/src/pairing.ts","../../src/server/envelope.ts","../../src/server/part.ts","../../src/server/principal.ts","../../src/server/contract.ts","../../src/server/client.ts","../../src/cli/output.ts","../../src/cli/error.ts"],"sourcesContent":["import { Effect } from \"effect\";\nimport { Base64Url } from \"effect/encoding\";\nimport { HttpRouter, HttpServerRequest, HttpServerResponse } from \"effect/http\";\n\n// Who may open a CodeWork listener's WebSocket. A browser WebSocket cannot set headers, so the token\n// travels as the second offered subprotocol, after the fixed name the listener selects: `ws` answers\n// with the first one offered, so the token is never echoed back.\n\n/** The subprotocol every client offers first, and the one a listener selects. */\nconst protocol = \"codework\";\n\n/** The subprotocols a client offers: the fixed name, then its token; without one it is refused. */\nexport const protocols = (token: string | undefined): Array<string> =>\n\ttoken === undefined ? [protocol] : [protocol, token];\n\n/** A token as a subprotocol can carry it: base64url, which is what {@link make} gives. */\nexport const isToken = (value: string) => /^[A-Za-z0-9_-]+$/.test(value);\n\n/** A fresh token: 32 random bytes. */\nexport const make = Effect.sync(() => Base64Url.encode(crypto.getRandomValues(new Uint8Array(32))));\n\n/** The token a `Sec-WebSocket-Protocol` header offers after the fixed name, and nothing else; none otherwise. */\nexport const offered = (header: string | undefined): string | undefined => {\n\tconst [name, token, ...rest] = (header ?? \"\").split(\",\").map((part) => part.trim());\n\treturn name === protocol && token !== undefined && isToken(token) && rest.length === 0 ? token : undefined;\n};\n\n/** Whether `given` is `expected`, in a time that depends on `expected`'s length alone. */\nexport const matches = (given: string, expected: string) => {\n\tlet difference = given.length ^ expected.length;\n\t// Past its end `given` reads NaN, which `| 0` turns into 0.\n\tfor (let index = 0; index < expected.length; index++)\n\t\tdifference |= expected.charCodeAt(index) ^ (given.charCodeAt(index) | 0);\n\treturn difference === 0;\n};\n\n/**\n * How a listener judges the credential a request offers, if any: it lets the request in as it came\n * or changed for the routes behind (a header they read), or turns it away with 401 by answering none.\n */\nexport type Admit = (\n\toffered: string | undefined,\n\trequest: HttpServerRequest.HttpServerRequest,\n) => Effect.Effect<HttpServerRequest.HttpServerRequest | undefined>;\n\n/** Admits a request that offers `expected`, and nothing else. */\nexport const token =\n\t(expected: string): Admit =>\n\t(given, request) =>\n\t\tEffect.succeed(given !== undefined && matches(given, expected) ? request : undefined);\n\n/**\n * The door on every request the listener serves, before a WebSocket upgrade: a refused one gets a\n * plain HTTP status instead of 101, 403 for where it comes from and 401 for its credential.\n */\nexport const layer = (options: { readonly admit: Admit; readonly origins: ReadonlyArray<string> }) =>\n\tHttpRouter.middleware(\n\t\t(app) =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst request = yield* HttpServerRequest.HttpServerRequest;\n\t\t\t\tconst origin = request.headers.origin;\n\t\t\t\tif (origin !== undefined && !options.origins.includes(origin))\n\t\t\t\t\treturn HttpServerResponse.empty({ status: 403 });\n\t\t\t\tconst admitted = yield* options.admit(offered(request.headers[\"sec-websocket-protocol\"]), request);\n\t\t\t\tif (admitted === undefined) return HttpServerResponse.empty({ status: 401 });\n\t\t\t\treturn yield* Effect.provideService(app, HttpServerRequest.HttpServerRequest, admitted);\n\t\t\t}),\n\t\t{ global: true },\n\t);\n","import { Option, Result } from \"effect\";\nimport type { HttpServerRequest } from \"effect/http\";\nimport * as IpNetwork from \"effect/net/IpNetwork\";\nimport * as NetAddress from \"effect/net/NetAddress\";\n\n// A listener speaks plain HTTP; TLS ends at a proxy in front of it, which says so in\n// `X-Forwarded-Proto`. Any client can send that header, so only a proxy's is believed: a peer on\n// loopback, or in the trusted list.\n\n/** The address `request` came from, by its socket, canonical; none when it has none. */\nexport const peer = (request: HttpServerRequest.HttpServerRequest): NetAddress.IpAddress | undefined =>\n\tOption.match(request.remoteAddress, {\n\t\tonNone: () => undefined,\n\t\tonSome: (address) =>\n\t\t\tResult.getOrUndefined(Result.map(NetAddress.ipFromString(address), (ip) => NetAddress.toCanonical(ip))),\n\t});\n\n/** Whether `request` reached the proxy in front of this listener over TLS, by a proxy on loopback or in `trusted`. */\nexport const encrypted = (\n\trequest: HttpServerRequest.HttpServerRequest,\n\ttrusted: ReadonlyArray<IpNetwork.IpNetwork>,\n): boolean => {\n\tconst from = peer(request);\n\tif (\n\t\tfrom === undefined ||\n\t\t!(NetAddress.isLoopback(from) || trusted.some((network) => IpNetwork.contains(network, from)))\n\t)\n\t\treturn false;\n\t// A chain of proxies appends; the first is the one the client reached.\n\treturn request.headers[\"x-forwarded-proto\"]?.split(\",\")[0]?.trim().toLowerCase() === \"https\";\n};\n","import { Effect, Result, Schema } from \"effect\";\nimport { Base64Url } from \"effect/encoding\";\n\n// Compact JWS with Ed25519 (EdDSA) over WebCrypto, so the same code signs on a machine (Node) and\n// verifies in the relay (Node or a Worker).\n\nexport const PublicKey = Schema.Struct({\n\tkty: Schema.Literal(\"OKP\"),\n\tcrv: Schema.Literal(\"Ed25519\"),\n\tx: Schema.String,\n});\nexport type PublicKey = typeof PublicKey.Type;\n\nexport const PrivateKey = Schema.Struct({ ...PublicKey.fields, d: Schema.String });\nexport type PrivateKey = typeof PrivateKey.Type;\n\nexport const Header = Schema.Struct({\n\talg: Schema.Literal(\"EdDSA\"),\n\t/** The signing key's thumbprint, for a key the verifier already holds. */\n\tkid: Schema.optional(Schema.String),\n\t/** The signing key itself, for a request that registers it. */\n\tjwk: Schema.optional(PublicKey),\n});\nexport type Header = typeof Header.Type;\n\nexport class JwsError extends Schema.TaggedError<JwsError>()(\"Jws.JwsError\", {\n\treason: Schema.Literals([\"malformed\", \"signature\", \"crypto\"]),\n}) {}\n\nconst algorithm = { name: \"Ed25519\" } as const;\nconst decodeHeader = Schema.decodeUnknownEffect(Schema.fromJsonString(Header));\nconst decodeJson = Schema.decodeUnknownEffect(Schema.fromJsonString(Schema.Unknown));\nconst crypto = <A>(evaluate: () => Promise<A>) =>\n\tEffect.tryPromise({ try: evaluate, catch: () => new JwsError({ reason: \"crypto\" }) });\nconst bytes = (part: string) =>\n\tResult.match(Base64Url.decode(part), {\n\t\tonFailure: () => Effect.fail(new JwsError({ reason: \"malformed\" })),\n\t\tonSuccess: (decoded) => Effect.succeed(Uint8Array.from(decoded)),\n\t});\n\n/** The public half of a private key. */\nexport const publicOf = (key: PrivateKey): PublicKey => ({ kty: key.kty, crv: key.crv, x: key.x });\n\n/** A fresh Ed25519 keypair as a private JWK; its public half is {@link publicOf}. */\nexport const generate = Effect.fn(\"Jws.generate\")(function* () {\n\tconst pair = yield* crypto(() => globalThis.crypto.subtle.generateKey(\"Ed25519\", true, [\"sign\", \"verify\"]));\n\tif (!(\"privateKey\" in pair)) return yield* new JwsError({ reason: \"crypto\" });\n\tconst jwk = yield* crypto(() => globalThis.crypto.subtle.exportKey(\"jwk\", pair.privateKey));\n\treturn yield* Schema.decodeUnknownEffect(PrivateKey)(jwk).pipe(\n\t\tEffect.mapError(() => new JwsError({ reason: \"crypto\" })),\n\t);\n});\n\n/** The RFC 7638 thumbprint of a public key: base64url SHA-256 of its required members, in order. */\nexport const thumbprint = Effect.fn(\"Jws.thumbprint\")(function* (key: PublicKey) {\n\tconst canonical = `{\"crv\":\"${key.crv}\",\"kty\":\"${key.kty}\",\"x\":\"${key.x}\"}`;\n\tconst digest = yield* crypto(() => globalThis.crypto.subtle.digest(\"SHA-256\", new TextEncoder().encode(canonical)));\n\treturn Base64Url.encode(new Uint8Array(digest));\n});\n\n/** A key's thumbprint as people compare it, `SHA256:<thumbprint>`. */\nexport const fingerprintOf = (thumbprint: string) => `SHA256:${thumbprint}`;\n\n/** A public key as people compare it: {@link fingerprintOf} its thumbprint. */\nexport const fingerprint = (key: PublicKey) => Effect.map(thumbprint(key), fingerprintOf);\n\n/** Signs `claims` with `key`, naming it by `kid` or embedding its public half. */\nexport const sign = Effect.fn(\"Jws.sign\")(function* (\n\tclaims: unknown,\n\tkey: PrivateKey,\n\tname: { readonly kid: string } | { readonly embed: true },\n) {\n\tconst header: Header = \"kid\" in name ? { alg: \"EdDSA\", kid: name.kid } : { alg: \"EdDSA\", jwk: publicOf(key) };\n\tconst input = `${Base64Url.encode(JSON.stringify(header))}.${Base64Url.encode(JSON.stringify(claims))}`;\n\tconst signer = yield* crypto(() => globalThis.crypto.subtle.importKey(\"jwk\", key, algorithm, false, [\"sign\"]));\n\tconst signature = yield* crypto(() =>\n\t\tglobalThis.crypto.subtle.sign(algorithm, signer, new TextEncoder().encode(input)),\n\t);\n\treturn `${input}.${Base64Url.encode(new Uint8Array(signature))}`;\n});\n\nconst parts = (token: string) => {\n\tconst [header, claims, signature, extra] = token.split(\".\");\n\treturn header === undefined || claims === undefined || signature === undefined || extra !== undefined\n\t\t? Effect.fail(new JwsError({ reason: \"malformed\" }))\n\t\t: Effect.succeed({ header, claims, signature });\n};\n\nconst decodeClaims = (part: string) =>\n\tEffect.flatMap(bytes(part), (decoded) =>\n\t\tdecodeJson(new TextDecoder().decode(decoded)).pipe(Effect.mapError(() => new JwsError({ reason: \"malformed\" }))),\n\t);\n\n/** A token's header, read before its signature is checked, to find the key that checks it. */\nexport const peek = Effect.fn(\"Jws.peek\")(function* (token: string) {\n\tconst { header } = yield* parts(token);\n\treturn yield* decodeHeader(new TextDecoder().decode(yield* bytes(header))).pipe(\n\t\tEffect.mapError(() => new JwsError({ reason: \"malformed\" })),\n\t);\n});\n\n/** A token's claims, still undecoded, read without checking its signature: for echoing, never for trusting. */\nexport const peekClaims = Effect.fn(\"Jws.peekClaims\")(function* (token: string) {\n\treturn yield* decodeClaims((yield* parts(token)).claims);\n});\n\n/** Checks `token`'s signature against `key` and returns its claims, still undecoded. */\nexport const verify = Effect.fn(\"Jws.verify\")(function* (token: string, key: PublicKey) {\n\tconst { header, claims, signature } = yield* parts(token);\n\tconst signed = yield* bytes(signature);\n\tconst verifier = yield* crypto(() => globalThis.crypto.subtle.importKey(\"jwk\", key, algorithm, false, [\"verify\"]));\n\tconst valid = yield* crypto(() =>\n\t\tglobalThis.crypto.subtle.verify(algorithm, verifier, signed, new TextEncoder().encode(`${header}.${claims}`)),\n\t);\n\tif (!valid) return yield* new JwsError({ reason: \"signature\" });\n\treturn yield* decodeClaims(claims);\n});\n","import { Context, Schema } from \"effect\";\nimport { HttpApi, HttpApiEndpoint, HttpApiGroup, HttpApiMiddleware, HttpApiSecurity } from \"effect/http-api\";\n\n// The relay's HTTP API (relay.codework.sh): people call it with an auth-vendor session token, machines\n// with requests signed by their own key (see ./jws.ts). The relay implements it; codework is a client.\n\nexport const Role = Schema.Literals([\"owner\", \"admin\", \"member\"]);\n\n/** A workspace's id, which the relay assigns; anything else is refused at the wire. */\nexport const WorkspaceId = Schema.String.check(Schema.isUUID());\n\n/** A machine's id: generated (a UUID) or set with `--machine-id`, lowercase letters, digits and dashes. */\nexport const MachineId = Schema.String.check(Schema.isPattern(/^[a-z0-9][a-z0-9-]{0,63}$/));\n\nexport class Account extends Schema.Class<Account>(\"Relay.Account\")({\n\tid: Schema.String,\n\temail: Schema.String,\n\tname: Schema.NullOr(Schema.String),\n}) {}\n\nexport class Workspace extends Schema.Class<Workspace>(\"Relay.Workspace\")({\n\tid: WorkspaceId,\n\tname: Schema.String,\n\trole: Role,\n}) {}\n\nexport class Me extends Schema.Class<Me>(\"Relay.Me\")({\n\taccount: Account,\n\tworkspaces: Schema.Array(Workspace),\n}) {}\n\n/** How a machine got its id: generated on first run, or set with `--machine-id`. */\nexport const IdSource = Schema.Literals([\"generated\", \"flag\"]);\n\n/** What a machine says about itself when it pairs and on every heartbeat. */\nexport const MachineInfo = Schema.Struct({\n\tid: MachineId,\n\tsource: IdSource,\n\tlocalHostName: Schema.String,\n\tgivenName: Schema.NullOr(Schema.String),\n\tos: Schema.String,\n\tarch: Schema.String,\n\tversion: Schema.String,\n});\nexport type MachineInfo = typeof MachineInfo.Type;\n\nexport class Machine extends Schema.Class<Machine>(\"Relay.Machine\")({\n\t...MachineInfo.fields,\n\tworkspaceId: WorkspaceId,\n\t/** The thumbprint of the key the link is live under; a home holds that key for this workspace. */\n\tkeyId: Schema.String,\n\t/** The thumbprint of the home's identity key: links with the same one, in any workspace, are one machine. */\n\tidentityKeyId: Schema.String,\n\townerId: Schema.String,\n\tonline: Schema.Boolean,\n\tlastSeenAt: Schema.NullOr(Schema.String),\n}) {}\n\n// Signed machine requests: the body carries one compact JWS whose claims name the operation, so a\n// signature made for one endpoint is refused by every other.\n\nexport const SignedRequest = Schema.Struct({ jws: Schema.String });\n\nexport const PairingClaims = Schema.Struct({\n\top: Schema.Literal(\"pairing.create\"),\n\tiat: Schema.Number,\n\tmachine: MachineInfo,\n\t/** The workspace the connect started from; the approver may pick another when it is null. */\n\tworkspaceId: Schema.NullOr(WorkspaceId),\n\t/** An {@link IdentityClaims} JWS by the home's identity key, naming this request's key. */\n\tidentity: Schema.String,\n});\nexport type PairingClaims = typeof PairingClaims.Type;\n\n/**\n * A home's identity key vouching for one of its link keys. It embeds the identity key and names the link\n * key's thumbprint, so the binding can't be replayed for another link.\n */\nexport const IdentityClaims = Schema.Struct({\n\top: Schema.Literal(\"identity.bind\"),\n\tiat: Schema.Number,\n\tkeyId: Schema.String,\n});\nexport type IdentityClaims = typeof IdentityClaims.Type;\n\n/** A pairing's poll, signed with the key it registered: only that process learns the outcome. */\nexport const PollClaims = Schema.Struct({\n\top: Schema.Literal(\"pairing.poll\"),\n\tiat: Schema.Number,\n});\nexport type PollClaims = typeof PollClaims.Type;\n\nexport const HeartbeatClaims = Schema.Struct({\n\top: Schema.Literal(\"machine.heartbeat\"),\n\tiat: Schema.Number,\n\tworkspaceId: WorkspaceId,\n\tmachine: MachineInfo,\n});\nexport type HeartbeatClaims = typeof HeartbeatClaims.Type;\n\nexport const RevokeClaims = Schema.Struct({\n\top: Schema.Literal(\"machine.revoke\"),\n\tiat: Schema.Number,\n\t/** Used once: a replayed revoke is refused. */\n\tjti: Schema.String,\n\tworkspaceId: WorkspaceId,\n\tmachineId: MachineId,\n});\nexport type RevokeClaims = typeof RevokeClaims.Type;\n\nexport const PairingCreated = Schema.Struct({\n\tuserCode: Schema.String,\n\texpiresIn: Schema.Int,\n\tinterval: Schema.Int,\n});\n\nexport const Connected = Schema.Struct({\n\tmachineId: MachineId,\n\tworkspace: Schema.Struct({ id: WorkspaceId, name: Schema.String }),\n\towner: Schema.Struct({ id: Schema.String, name: Schema.NullOr(Schema.String) }),\n});\nexport type Connected = typeof Connected.Type;\n\nexport const PairingStatus = Schema.Union([\n\t/** `superseded`: another connect for this machine and workspace was activated first. */\n\tSchema.Struct({ status: Schema.Literals([\"pending\", \"expired\", \"declined\", \"superseded\"]) }),\n\tSchema.Struct({ status: Schema.Literal(\"approved\"), connected: Connected }),\n]);\nexport type PairingStatus = typeof PairingStatus.Type;\n\nexport class Unauthorized extends Schema.TaggedError<Unauthorized>()(\n\t\"Relay.Unauthorized\",\n\t{ message: Schema.String },\n\t{ httpApiStatus: 401 },\n) {}\n\n/** The relay couldn't check the request just now (its auth vendor is unreachable): try again shortly. */\nexport class Unavailable extends Schema.TaggedError<Unavailable>()(\n\t\"Relay.Unavailable\",\n\t{ message: Schema.String },\n\t{ httpApiStatus: 503 },\n) {}\n\n/** The machine's link to the workspace is gone: revoked, replaced, or its owner left. Reconnect to restore it. */\nexport class MachineRevoked extends Schema.TaggedError<MachineRevoked>()(\n\t\"Relay.MachineRevoked\",\n\t{ message: Schema.String },\n\t{ httpApiStatus: 401 },\n) {}\n\nexport class Forbidden extends Schema.TaggedError<Forbidden>()(\n\t\"Relay.Forbidden\",\n\t{ message: Schema.String },\n\t{ httpApiStatus: 403 },\n) {}\n\nexport class NotFound extends Schema.TaggedError<NotFound>()(\n\t\"Relay.NotFound\",\n\t{ message: Schema.String },\n\t{ httpApiStatus: 404 },\n) {}\n\n/** A person whose session token the auth vendor verified: only the vendor's subject id. */\nexport class Person extends Context.Service<Person, { readonly authId: string }>()(\"relay/Person\") {}\n\n/** Verifies a person's bearer session token and provides {@link Person}. */\nexport class PersonAuth extends HttpApiMiddleware.Service<PersonAuth, { provides: Person; requires: never }>()(\n\t\"relay/PersonAuth\",\n\t{\n\t\tsecurity: { bearer: HttpApiSecurity.bearer },\n\t\terror: [Unauthorized, Unavailable],\n\t},\n) {}\n\nexport class MeGroup extends HttpApiGroup.make(\"me\")\n\t.add(HttpApiEndpoint.get(\"get\", \"/v1/me\", { success: Me }))\n\t.middleware(PersonAuth) {}\n\n/** A machine that ran `codework connect` for a workspace and waits for a member to approve its code. */\nexport class PendingPairing extends Schema.Class<PendingPairing>(\"Relay.PendingPairing\")({\n\tuserCode: Schema.String,\n\tmachine: MachineInfo,\n\t/** `approved`: a member approved it and the machine's next poll links it. */\n\tstatus: Schema.Literals([\"pending\", \"approved\"]),\n\t/** A machine with this id is already in the workspace; approving replaces its link. */\n\treplaces: Schema.Boolean,\n\tcreatedAt: Schema.String,\n\texpiresAt: Schema.String,\n}) {}\n\nexport const WorkspaceName = Schema.Trimmed.check(Schema.isNonEmpty(), Schema.isMaxLength(64));\n\n/** People create workspaces, and manage pairings and machines in a workspace they belong to. */\nexport class WorkspaceGroup extends HttpApiGroup.make(\"workspace\")\n\t.add(\n\t\tHttpApiEndpoint.post(\"create\", \"/v1/workspaces\", {\n\t\t\tpayload: Schema.Struct({ name: WorkspaceName }),\n\t\t\tsuccess: Workspace,\n\t\t}),\n\t\t/** Approves a code; the machine's next poll links it, so it answers with what the machine said. */\n\t\tHttpApiEndpoint.post(\"approve\", \"/v1/workspaces/:workspaceId/pairings/approve\", {\n\t\t\tparams: { workspaceId: WorkspaceId },\n\t\t\tpayload: Schema.Struct({ userCode: Schema.String }),\n\t\t\tsuccess: Schema.Struct({ machine: MachineInfo }),\n\t\t\terror: [NotFound, Forbidden],\n\t\t}),\n\t\tHttpApiEndpoint.get(\"machines\", \"/v1/workspaces/:workspaceId/machines\", {\n\t\t\tparams: { workspaceId: WorkspaceId },\n\t\t\tsuccess: Schema.Array(Machine),\n\t\t\terror: Forbidden,\n\t\t}),\n\t\t/** The workspace's pending connects, each with the code its machine shows. */\n\t\tHttpApiEndpoint.get(\"pairings\", \"/v1/workspaces/:workspaceId/pairings\", {\n\t\t\tparams: { workspaceId: WorkspaceId },\n\t\t\tsuccess: Schema.Array(PendingPairing),\n\t\t\terror: Forbidden,\n\t\t}),\n\t\t/** Turns a pending connect away; the waiting machine hears it was declined. */\n\t\tHttpApiEndpoint.post(\"decline\", \"/v1/workspaces/:workspaceId/pairings/decline\", {\n\t\t\tparams: { workspaceId: WorkspaceId },\n\t\t\tpayload: Schema.Struct({ userCode: Schema.String }),\n\t\t\terror: [NotFound, Forbidden],\n\t\t}),\n\t\t/** Disconnects a machine from the workspace: its owner, or a workspace owner or admin, may. */\n\t\tHttpApiEndpoint.post(\"remove\", \"/v1/workspaces/:workspaceId/machines/:machineId/remove\", {\n\t\t\tparams: { workspaceId: WorkspaceId, machineId: MachineId },\n\t\t\tpayload: Schema.Struct({ keyId: Schema.String }),\n\t\t\terror: [NotFound, Forbidden],\n\t\t}),\n\t)\n\t.middleware(PersonAuth) {}\n\n/** Machines authenticate each request with a signature, not a session. */\nexport class MachineGroup extends HttpApiGroup.make(\"machine\").add(\n\tHttpApiEndpoint.post(\"pair\", \"/v1/pairings\", {\n\t\tpayload: SignedRequest,\n\t\tsuccess: PairingCreated,\n\t\terror: [Unauthorized, NotFound],\n\t}),\n\tHttpApiEndpoint.post(\"poll\", \"/v1/pairings/poll\", {\n\t\tpayload: SignedRequest,\n\t\tsuccess: PairingStatus,\n\t\terror: [Unauthorized, NotFound],\n\t}),\n\tHttpApiEndpoint.post(\"heartbeat\", \"/v1/machines/heartbeat\", {\n\t\tpayload: SignedRequest,\n\t\terror: [Unauthorized, MachineRevoked],\n\t}),\n\tHttpApiEndpoint.post(\"revoke\", \"/v1/machines/revoke\", {\n\t\tpayload: SignedRequest,\n\t\terror: [Unauthorized, MachineRevoked],\n\t}),\n) {}\n\nexport class Api extends HttpApi.make(\"relay\").add(MeGroup).add(WorkspaceGroup).add(MachineGroup) {}\n","import { Schema } from \"effect\";\nimport { Connected } from \"./relay.ts\";\n\n// A CodeWork server as a machine: what its clients (the desktop app) see over the CodeWork RPC.\n\n/** This machine and the workspaces it is connected to, from its `machine.json`. */\nexport const Status = Schema.Struct({\n\t/** None before the machine's first connect gives it an identity. */\n\tid: Schema.NullOr(Schema.String),\n\t/** The OS's name for the host, read fresh. */\n\tlocalHostName: Schema.String,\n\t/** The user's own name for it, shown in place of `localHostName` when set. */\n\tgivenName: Schema.NullOr(Schema.String),\n\t/**\n\t * Each link with the thumbprint of its key: a relay row under another key is not this machine's. A\n\t * leaving link was ended here while the relay couldn't be reached; it is revoked once it can. Older\n\t * machines don't report it.\n\t */\n\tworkspaces: Schema.Array(\n\t\tSchema.Struct({\n\t\t\tid: Schema.String,\n\t\t\tname: Schema.String,\n\t\t\tkeyId: Schema.String,\n\t\t\tleaving: Schema.optionalKey(Schema.Boolean),\n\t\t}),\n\t),\n});\nexport type Status = typeof Status.Type;\n\nexport const Disconnect = Schema.Struct({ workspaceId: Schema.String, keyId: Schema.String });\n\n/** A disconnect: this machine afterwards, and whether the relay confirmed; if not, the link is left leaving. */\nexport const Disconnected = Schema.Struct({ status: Status, revoked: Schema.Boolean });\nexport type Disconnected = typeof Disconnected.Type;\n\n/** A connect's progress: the code to approve, then the link once a member approved it. */\nexport const ConnectEvent = Schema.Union([\n\tSchema.TaggedStruct(\"Code\", { userCode: Schema.String }),\n\tSchema.TaggedStruct(\"Connected\", { connected: Connected }),\n]);\nexport type ConnectEvent = typeof ConnectEvent.Type;\n\nexport class ConnectError extends Schema.TaggedError<ConnectError>()(\"Machine.ConnectError\", {\n\tmessage: Schema.String,\n}) {}\n","import { Schema } from \"effect\";\nimport { PublicKey } from \"./jws.ts\";\n\n// How another computer pairs with a CodeWork server over plain HTTP, beside its socket. As with SSH,\n// each side holds a key and keeps the other's public half; only signatures cross the wire. A refused\n// credential gets 401, never why.\n\n/** `POST` with {@link Exchange} creates a device: answers 201 with {@link Device}. */\nexport const devicesPath = \"/api/v1/devices\";\n/**\n * `POST` with a {@link Signed} {@link Proof} creates a ticket: answers 201 with a {@link Signed} {@link Grant},\n * or 401 with a {@link Signed} {@link Refusal} (empty when the body names no nonce).\n */\nexport const ticketsPath = \"/api/v1/tickets\";\n\n/** What `POST /api/v1/devices` takes: the code a person read, a name for the computer offering it, and its key. */\nexport const Exchange = Schema.Struct({\n\tcode: Schema.String,\n\tlabel: Schema.String.check(Schema.isNonEmpty(), Schema.isMaxLength(100), Schema.isPattern(/^[^\\p{Cc}]*$/u)),\n\tkey: PublicKey,\n});\n\n/** A new device: its id, and the machine's identity key, which signs every {@link Grant}. */\nexport const Device = Schema.Struct({ id: Schema.String, machine: PublicKey });\n\n/** A compact JWS, as both ticket routes carry one. */\nexport const Signed = Schema.Struct({ jws: Schema.String });\n\n/** How long a {@link Proof} is good for, either side of the machine's clock; its nonce is held as long. */\nexport const proofWindow = 5 * 60 * 1000;\n\n/** A device asking for a ticket, signed with its key and named by the key's thumbprint; each nonce is taken once. */\nexport const Proof = Schema.Struct({\n\top: Schema.Literal(\"ticket.create\"),\n\t/** The thumbprint of the machine key it is for: one device key is paired with every machine. */\n\taud: Schema.String,\n\tdevice: Schema.String,\n\t/** Epoch milliseconds. */\n\tiat: Schema.Finite,\n\tnonce: Schema.String,\n});\nexport type Proof = typeof Proof.Type;\n\n/** A ticket for one socket, signed with the machine's identity key, echoing the {@link Proof}'s nonce. */\nexport const Grant = Schema.Struct({\n\top: Schema.Literal(\"ticket.grant\"),\n\tticket: Schema.String,\n\tnonce: Schema.String,\n});\nexport type Grant = typeof Grant.Type;\n\n/**\n * A refused {@link Proof}, signed with the machine's identity key, echoing the nonce it named, so a refusal\n * is told from another machine's. `at` is the machine's clock, epoch milliseconds. It never says why.\n */\nexport const Refusal = Schema.Struct({\n\top: Schema.Literal(\"ticket.refuse\"),\n\tnonce: Schema.String,\n\tat: Schema.Finite,\n});\nexport type Refusal = typeof Refusal.Type;\n","import { EventList, EventSchema, optional } from \"@codeworksh/harness/effect\";\nimport { Effect, Predicate, Schema } from \"effect\";\n\n/**\n * The wire form of an `EventSchema.Payload`. `data` is carried in its encoded\n * form — decoded payloads are not wire-safe (`Schema.Duration`, aikit class\n * transforms) — so clients decode it lazily through their own copy of the\n * registry and can skip types they do not know.\n */\nexport const EventEnvelope = Schema.Struct({\n\tid: EventSchema.ID,\n\ttype: Schema.String,\n\tdurable: optional(Schema.Struct({ aggregateId: Schema.String, seq: Schema.Int, version: Schema.Int })),\n\tmetadata: optional(Schema.Record(Schema.String, Schema.String)),\n\tdata: Schema.Unknown,\n});\nexport type EventEnvelope = typeof EventEnvelope.Type;\n\n/** Whether an event belongs to a thread: every thread-scoped event names its `threadId`. */\nexport const ofThread =\n\t(threadId: string) =>\n\t(event: { readonly data: unknown }): boolean =>\n\t\tPredicate.hasProperty(event.data, \"threadId\") && event.data.threadId === threadId;\n\nclass UnknownEventTypeError extends Schema.TaggedError<UnknownEventTypeError>()(\"UnknownEventTypeError\", {\n\ttype: Schema.String,\n}) {}\n\n/** The transport's own readiness frame; it has no meaning inside the harness. */\nexport const Connected = EventSchema.define({ type: \"server.connected\", schema: {} });\n\n/** Resolves a published type to the definition that encodes it. */\nexport type Registry = (type: string) => EventSchema.Definition | undefined;\n\n/**\n * What a stock client can decode: the harness's public events plus the frames\n * the transport adds itself. A server may know more than this -- plugins\n * register their own types -- which is exactly why `data` crosses the wire\n * encoded and is decoded lazily, so an unknown type is skipped, not fatal.\n */\nconst core = EventSchema.latest([...EventList.PublicDefinitions, Connected]);\nexport const Core: Registry = (type) => core.get(type);\n\nexport class EncodingError extends Schema.TaggedError<EncodingError>()(\"EventEncodingError\", {\n\ttype: Schema.String,\n\tcause: Schema.Defect(),\n}) {}\n\nexport const encode = Effect.fn(\"Envelope.encode\")(function* (payload: EventSchema.Payload, registry: Registry = Core) {\n\tconst definition = registry(payload.type);\n\tif (definition === undefined) return yield* new UnknownEventTypeError({ type: payload.type });\n\tconst data = yield* Schema.encodeEffect(definition.data)(payload.data).pipe(\n\t\tEffect.mapError((cause) => new EncodingError({ type: payload.type, cause })),\n\t);\n\treturn {\n\t\tid: payload.id,\n\t\ttype: payload.type,\n\t\t...(payload.durable === undefined ? {} : { durable: payload.durable }),\n\t\t...(payload.metadata === undefined ? {} : { metadata: payload.metadata }),\n\t\tdata,\n\t};\n});\n\nexport const decode = Effect.fn(\"Envelope.decode\")(function* (envelope: EventEnvelope, registry: Registry = Core) {\n\tconst definition = registry(envelope.type);\n\tif (definition === undefined) {\n\t\treturn yield* new UnknownEventTypeError({ type: envelope.type });\n\t}\n\tconst data = yield* Schema.decodeEffect(definition.data)(envelope.data);\n\treturn {\n\t\tid: envelope.id,\n\t\ttype: envelope.type,\n\t\t...(envelope.durable === undefined ? {} : { durable: envelope.durable }),\n\t\t...(envelope.metadata === undefined ? {} : { metadata: envelope.metadata }),\n\t\tdata,\n\t} as EventSchema.Payload;\n});\n","import { Schema } from \"effect\";\n\n/*\n * A stored message part as clients see it: aikit's part JSON (persisted verbatim by the harness),\n * narrowed to what a client renders. Provider replay data (signatures, namespaces) and tool\n * `details` are left out, so decoding a stored part drops them.\n */\n\nconst TextContent = Schema.Struct({ type: Schema.Literal(\"text\"), text: Schema.String });\nconst ImageContent = Schema.Struct({\n\ttype: Schema.Literal(\"image\"),\n\tdata: Schema.String,\n\tmimeType: Schema.String,\n});\nconst ThinkingContent = Schema.Struct({\n\ttype: Schema.Literal(\"thinking\"),\n\tthinking: Schema.String,\n\t/** The provider withheld the reasoning; `thinking` is then empty. */\n\tredacted: Schema.optionalKey(Schema.Boolean),\n});\n\n/** aikit's ToolStatusEnum. */\nconst ToolStatus = Schema.Literals([\"pending\", \"running\", \"completed\", \"error\", \"skipped\", \"aborted\"]);\n\nconst ToolResult = Schema.Struct({\n\tcontent: Schema.Array(Schema.Union([TextContent, ImageContent])),\n\tisError: Schema.Boolean,\n});\n\nconst ToolCall = Schema.Struct({\n\ttype: Schema.Literal(\"toolCall\"),\n\tcallID: Schema.String,\n\tname: Schema.String,\n\targuments: Schema.Record(Schema.String, Schema.Json),\n\tstatus: ToolStatus,\n\t/** Present once the call settled (completed, error, skipped, aborted). */\n\tresult: Schema.optionalKey(ToolResult),\n\t/** Epoch milliseconds: started, and last lifecycle update. */\n\ttime: Schema.optionalKey(Schema.Struct({ start: Schema.Finite, end: Schema.Finite })),\n});\nexport type ToolCall = typeof ToolCall.Type;\n\nexport const Part = Schema.Union([TextContent, ImageContent, ThinkingContent, ToolCall]);\nexport type Part = typeof Part.Type;\n\n/** A stored part row's JSON, or none when it is not a part a client renders. */\nexport const decode = Schema.decodeUnknownOption(Schema.fromJsonString(Part));\n","import { Global } from \"@codeworksh/harness/effect\";\nimport { Door as Knock } from \"@codeworksh/schema\";\nimport { NodeServices } from \"@effect/platform-node\";\nimport { Context, Effect, FileSystem, Layer, Schema } from \"effect\";\nimport { RpcMiddleware } from \"effect/rpc\";\n\n/** Who is calling, decided once per connection by the listener's door. */\nexport type Principal =\n\t/** Holds the home's token, from this computer: nothing stored about who. */\n\t| { readonly kind: \"local\" }\n\t/** A paired device, by the id `codework service devices` lists. */\n\t| { readonly kind: \"device\"; readonly id: string };\n\nexport class Current extends Context.Service<Current, Principal>()(\"@codeworksh/cli/server/principal/Current\") {}\n\nexport class Unauthorized extends Schema.TaggedError<Unauthorized>()(\"Server.Unauthorized\", {\n\tmessage: Schema.String,\n}) {}\n\n/** A call this caller may not make: only this computer manages who is paired, and only a device leaves. */\nexport class Forbidden extends Schema.TaggedError<Forbidden>()(\"Server.Forbidden\", {\n\tmessage: Schema.String,\n}) {}\n\n/**\n * Decides the caller of every RPC from the connection it comes on. The contract carries the tag; each\n * listener provides its own implementation where it is built.\n */\nexport class Door extends RpcMiddleware.Service<Door, { provides: Current }>()(\n\t\"@codeworksh/cli/server/principal/Door\",\n\t{ error: Unauthorized },\n) {}\n\n/** `effect`, for a local caller only; a device is refused. */\nexport const local = <A, E, R>(effect: Effect.Effect<A, E, R>) =>\n\tEffect.gen(function* () {\n\t\tif ((yield* Current).kind !== \"local\")\n\t\t\treturn yield* new Forbidden({ message: \"Only this computer manages its paired devices\" });\n\t\treturn yield* effect;\n\t});\n\n/** The home's token for the life of the server, which every local client sends. */\nexport class Token extends Context.Service<Token, string>()(\"@codeworksh/cli/server/principal/Token\") {}\n\n/**\n * A fresh token per start, published in `service.json` alone. A `<home>/token` an earlier build kept\n * is deleted, so no stale copy of a credential stays behind.\n */\nexport const layerToken = Layer.effect(\n\tToken,\n\tEffect.gen(function* () {\n\t\tconst global = yield* Global.Service;\n\t\tconst fs = yield* FileSystem.FileSystem;\n\t\tyield* fs.remove(`${global.home}/token`).pipe(Effect.ignore);\n\t\treturn yield* Knock.make;\n\t}).pipe(Effect.provide(NodeServices.layer)),\n);\n","import { Model } from \"@codeworksh/aikit\";\nimport {\n\tControl,\n\tDaemonHost,\n\tEvent,\n\tEventList,\n\tLocation,\n\tMcpError,\n\toptional,\n\tProject,\n\tPromptSchema,\n\tRunner,\n\tSandbox,\n\tSandboxError,\n\tSession,\n\tSessionStore,\n\tSettings,\n\tSettingsFile,\n\tThreadSchema,\n\tThreadStore,\n\tUsageSchema,\n} from \"@codeworksh/harness/effect\";\nimport { Machine } from \"@codeworksh/schema\";\nimport { Schema } from \"effect\";\nimport { Rpc, RpcGroup } from \"effect/rpc\";\nimport { EncodingError, EventEnvelope } from \"./envelope.ts\";\nimport { Part } from \"./part.ts\";\nimport * as Principal from \"./principal.ts\";\n\n/** The HTTP path the RPC endpoint is served on; the version moves with breaking wire changes. */\nexport const path = \"/rpc/v1\";\n\n/** A computer paired with this machine. */\nexport const DeviceInfo = Schema.Struct({\n\tid: Schema.String,\n\tlabel: Schema.String,\n\t/** Its key's fingerprint, `SHA256:<thumbprint>`. */\n\tfingerprint: Schema.String,\n\t/** Epoch milliseconds. */\n\tcreatedAt: Schema.Finite,\n\t/** When it last took a ticket, epoch milliseconds; a device unseen for 30 days is refused. */\n\tseenAt: Schema.Finite,\n\t/** Whether it last paired or took a ticket over TLS, which ends at a proxy in front of this server. */\n\tencrypted: Schema.optional(Schema.Boolean),\n});\nexport type DeviceInfo = typeof DeviceInfo.Type;\n\nexport const SandboxInfo = Schema.Struct({\n\tid: Sandbox.SandboxInstance.ID,\n\tdriver: Schema.String,\n\tkind: Sandbox.SandboxInstance.Kind,\n\tproviderResourceId: Schema.OptionFromNullOr(Schema.String),\n\townership: Sandbox.SandboxInstance.Ownership,\n\tstatus: Sandbox.SandboxInstance.Status,\n\tusage: Sandbox.SandboxInstance.Usage,\n\trefCount: Schema.Int,\n\tcreatedAt: Schema.DateFromString,\n\tupdatedAt: Schema.DateFromString,\n});\nexport type SandboxInfo = typeof SandboxInfo.Type;\n\n/** One logical codebase, whatever env it is checked out in. */\nconst ProjectInfo = Schema.Struct({\n\tid: Schema.String,\n\tname: Schema.String,\n\tstatus: Schema.Literals([\"active\", \"archived\"]),\n\t/** Epoch milliseconds. */\n\tcreatedAt: Schema.Finite,\n\tupdatedAt: Schema.Finite,\n});\nexport type ProjectInfo = typeof ProjectInfo.Type;\n\n/** One directory of a project in one env; sessions attach to it. */\nconst SpaceInfo = Schema.Struct({\n\tid: Schema.String,\n\tprojectId: Schema.String,\n\tlocation: Session.AbsolutePath,\n\tkind: Schema.Literals([\"primary\", \"linked\", \"copy\", \"plain\"]),\n\t/** The sandbox it is in; absent for the host. */\n\tenv: optional(Schema.String),\n\tstatus: Schema.Literals([\"active\", \"archived\"]),\n\t/** Epoch milliseconds. */\n\tcreatedAt: Schema.Finite,\n\tupdatedAt: Schema.Finite,\n});\nexport type SpaceInfo = typeof SpaceInfo.Type;\n\n/** The container: where its threads run by default, and which host project it reads. */\nexport const SessionInfo = Schema.Struct({\n\tid: Session.SessionSchema.ID,\n\tspaceId: Schema.String,\n\tslug: Schema.String,\n\tdirectory: Session.AbsolutePath,\n\t/** The host directory this session is anchored to. Absent when it has none. */\n\thostDir: optional(Session.AbsolutePath),\n\tsandbox: optional(SandboxInfo),\n\t/** The project the session's space belongs to. */\n\tproject: optional(Schema.Struct({ id: Schema.String, name: Schema.String })),\n\ttag: optional(Schema.String),\n\tmetadata: optional(Schema.Record(Schema.String, Schema.String)),\n\t/** Epoch milliseconds. */\n\tcreatedAt: Schema.Finite,\n\t/** Last activity in any of its threads, epoch milliseconds. */\n\tupdatedAt: Schema.Finite,\n\t/** Where unaddressed prompts go. */\n\tmainThreadId: ThreadSchema.ID,\n});\nexport type SessionInfo = typeof SessionInfo.Type;\n\n/** `cut` is the committed seq of `entryId`: the inherited line ends there. */\nconst ThreadOrigin = Schema.Union([\n\tSchema.Struct({ kind: Schema.Literal(\"main\") }),\n\tSchema.Struct({ kind: Schema.Literal(\"fork\"), threadId: Schema.String, entryId: Schema.String, cut: Schema.Int }),\n\tSchema.Struct({\n\t\tkind: Schema.Literal(\"subagent\"),\n\t\tthreadId: Schema.String,\n\t\tcallId: Schema.String,\n\t\tentryId: optional(Schema.String),\n\t\t/** Present once `entryId` is committed. */\n\t\tcut: optional(Schema.Int),\n\t}),\n]);\n\n/** Billed usage of a thread's own entries; what it inherits through a fork point counts for its source. */\nconst ThreadUsage = Schema.Struct({\n\t/** Total cost in US dollars, from the catalog's prices. */\n\tcost: Schema.Finite,\n\tinput: Schema.Int,\n\toutput: Schema.Int,\n\tcacheRead: Schema.Int,\n\tcacheWrite: Schema.Int,\n});\nexport type ThreadUsage = typeof ThreadUsage.Type;\n\n/** The last run of a thread; `error` is set unless it succeeded or is still going. */\nconst ThreadRun = Schema.Struct({\n\t/** Epoch milliseconds. */\n\tstartedAt: Schema.Finite,\n\tendedAt: optional(Schema.Finite),\n\toutcome: optional(ThreadSchema.RunOutcome),\n\terror: optional(ThreadSchema.RunError),\n});\n\nconst ThreadFields = {\n\tid: ThreadSchema.ID,\n\torigin: ThreadOrigin,\n\t/** Absent until its first own prompt; clients show a fork's source title until then. */\n\ttitle: optional(Schema.String),\n\t/** Last activity, epoch milliseconds. */\n\tupdatedAt: Schema.Finite,\n\t/** The model chosen for this thread; absent when settings decide. */\n\tmodel: optional(Schema.Struct({ provider: Schema.String, id: Schema.String })),\n\t/** The thinking level chosen for this thread; absent when settings decide. */\n\tthinkingLevel: optional(Schema.Enum(Model.ThinkingLevelEnum)),\n\t/** The prompt foundation chosen for this thread; absent when prompt plugins render it. */\n\tfoundation: optional(Schema.String),\n\t/** Where it runs instead of the session's space and directory. */\n\tplacement: optional(Schema.Struct({ spaceId: Schema.String, directory: Session.AbsolutePath })),\n\tusage: ThreadUsage,\n\t/** Where its run is, as the harness stores it: live whenever the server is up. */\n\trunState: ThreadSchema.RunState,\n\t/** When `runState` last changed, epoch milliseconds; absent before the first run. */\n\trunStateAt: optional(Schema.Finite),\n\t/** Absent before the first run. */\n\tlastRun: optional(ThreadRun),\n\t/** Whether it holds queued prompts that wait for its next prompt instead of running by themselves. */\n\tparked: Schema.Boolean,\n\t/** Automatic restarts of the current run. */\n\trestarts: Schema.Int,\n\t/** The 1-based provider request in flight; absent when none is. */\n\tattempt: optional(Schema.Int),\n\t/** The seq of the session event that created it. */\n\tcreatedSeq: Schema.Int,\n\t/** Epoch milliseconds. */\n\tcreatedAt: Schema.Finite,\n};\n\n/** One linear transcript of a session, with the session embedded. */\nexport const ThreadInfo = Schema.Struct({ ...ThreadFields, session: SessionInfo });\nexport type ThreadInfo = typeof ThreadInfo.Type;\n\n/** A thread as `index.sync` sends it: its session is a row of its own. */\nexport const ThreadSummary = Schema.Struct({ ...ThreadFields, sessionId: Session.SessionSchema.ID });\nexport type ThreadSummary = typeof ThreadSummary.Type;\n\n/** An `index.sync` item: a row with the revision that last wrote it, a deletion, or progress. */\nexport const IndexItem = Schema.Union([\n\tSchema.TaggedStruct(\"Project\", { project: ProjectInfo, rev: Schema.Int }),\n\tSchema.TaggedStruct(\"Space\", { space: SpaceInfo, rev: Schema.Int }),\n\tSchema.TaggedStruct(\"Session\", { session: SessionInfo, rev: Schema.Int }),\n\tSchema.TaggedStruct(\"Thread\", { thread: ThreadSummary, rev: Schema.Int }),\n\tSchema.TaggedStruct(\"Removed\", { kind: Schema.Literal(\"session\"), id: Schema.String, rev: Schema.Int }),\n\t/**\n\t * Every row with a revision up to `rev` has been sent. `boot` is the store's latest open, for the\n\t * next call; `reset` marks the first one after a `boot` off the store's line: the whole index was\n\t * sent again from zero, and a client drops what it held of this store that was not sent.\n\t */\n\tSchema.TaggedStruct(\"Synced\", {\n\t\tstoreId: Schema.String,\n\t\trev: Schema.Int,\n\t\tboot: Schema.String,\n\t\treset: optional(Schema.Literal(true)),\n\t}),\n]);\nexport type IndexItem = typeof IndexItem.Type;\n\n/**\n * Upper bounds in ms of the request duration histogram: bucket `i` of `durations` counts durations\n * below `edges[i]` and at or above `edges[i - 1]`; one more bucket past the last edge is open-ended.\n */\nexport const edges = UsageSchema.edges;\n\n/** Where a `usage.sync` row belongs: a thread's UTC hour. */\nconst UsageOwner = {\n\t/** Start of the UTC hour, epoch milliseconds. */\n\thour: Schema.Int,\n\tthreadId: ThreadSchema.ID,\n\t/** The thread's session and project when the row was first written. */\n\tsessionId: Session.SessionSchema.ID,\n\tprojectId: Schema.String,\n};\n\n/** A `usage.sync` item: a rollup row with the revision that last wrote it, or progress. */\nexport const UsageItem = Schema.Union([\n\t/** Requests of one thread in one hour to one provider, model and thinking level, aborted ones included. */\n\tSchema.TaggedStruct(\"Usage\", {\n\t\t...UsageOwner,\n\t\tprovider: Schema.String,\n\t\tmodel: Schema.String,\n\t\tthinking: Schema.String,\n\t\trequests: Schema.Int,\n\t\t/** `reasoning` is part of `output`. */\n\t\ttokens: Schema.Struct({\n\t\t\tinput: Schema.Int,\n\t\t\toutput: Schema.Int,\n\t\t\tcacheRead: Schema.Int,\n\t\t\tcacheWrite: Schema.Int,\n\t\t\treasoning: Schema.Int,\n\t\t}),\n\t\t/** US dollars, from the catalog's prices. */\n\t\tcost: Schema.Struct({\n\t\t\ttotal: Schema.Finite,\n\t\t\tinput: Schema.Finite,\n\t\t\toutput: Schema.Finite,\n\t\t\tcacheRead: Schema.Finite,\n\t\t\tcacheWrite: Schema.Finite,\n\t\t}),\n\t\t/** Total ms of the `timed` requests: the committed ones; aborted requests are never timed. */\n\t\tduration: Schema.Finite,\n\t\ttimed: Schema.Int,\n\t\t/** The `timed` requests per bucket of `edges`, one more than there are edges. */\n\t\tdurations: Schema.Array(Schema.Int),\n\t\trev: Schema.Int,\n\t}),\n\t/** Committed prompts (`name` is empty), or tool calls that ran by tool name, of one thread in one hour. */\n\tSchema.TaggedStruct(\"Tally\", {\n\t\t...UsageOwner,\n\t\tkind: Schema.Literals(UsageSchema.tallyKinds),\n\t\tname: Schema.String,\n\t\tcount: Schema.Int,\n\t\trev: Schema.Int,\n\t}),\n\t/**\n\t * Every row with a revision up to `rev` has been sent. `boot` is the store's latest open, for the\n\t * next call; `reset` marks the first one after a `boot` off the store's line: every row was sent\n\t * again from zero, and a client drops what it held of this store.\n\t */\n\tSchema.TaggedStruct(\"Synced\", {\n\t\tstoreId: Schema.String,\n\t\trev: Schema.Int,\n\t\tboot: Schema.String,\n\t\treset: optional(Schema.Literal(true)),\n\t}),\n]);\nexport type UsageItem = typeof UsageItem.Type;\n\n/** A thread of a session: `threadId`, or the session's `main` thread when absent. */\nconst ThreadRef = {\n\tsessionId: Session.SessionSchema.ID,\n\tthreadId: optional(ThreadSchema.ID),\n};\n\n/** A thread's MCP server, by the name its `mcp.json` gives it. */\nconst McpServerRef = { ...ThreadRef, server: Schema.String };\n\n/** One message in a thread's line (inherited ones first), oldest first. */\nexport const HistoryEntry = Schema.Struct({\n\t/** The entry id: what live events and `thread.message` refer to. */\n\tid: Schema.String,\n\t/** The thread that wrote it: this one, or a source it was forked from. */\n\tthreadId: Schema.String,\n\t/** Its place in the session's durable log; live events continue from it. */\n\tseq: Schema.Int,\n\trole: Schema.Literals([\"user\", \"assistant\"]),\n\t/** `draft` is a reply still streaming; `aborted` one that was interrupted. */\n\tstate: Schema.Literals([\"committed\", \"draft\", \"aborted\"]),\n\t/** Epoch milliseconds. */\n\tcreatedAt: Schema.Finite,\n\t/** Epoch milliseconds of the last change; for a reply, when it ended once it is no longer a draft. */\n\tupdatedAt: Schema.Finite,\n\tparts: Schema.Array(Part),\n\t/** Bytes of its parts as the harness stores them; `thread.sync`'s budget counts it. */\n\tsize: Schema.Int,\n\t/** Why a reply failed, as `provider/model: reason`; absent for one that ended normally or was stopped. */\n\terror: optional(Schema.String),\n});\nexport type HistoryEntry = typeof HistoryEntry.Type;\n\n/** A prompt admitted but not yet in the conversation: a steer waiting for the next model request, or a follow-up for the next turn. */\nexport const QueuedPrompt = Schema.Struct({\n\t/** The id of the user message it becomes once promoted. */\n\tid: Schema.String,\n\tdelivery: PromptSchema.Delivery,\n\ttext: Schema.String,\n\t/** The thread's sequence number at admission; orders the queue. */\n\tadmittedSeq: Schema.Int,\n\t/** Epoch milliseconds. */\n\tcreatedAt: Schema.Finite,\n});\nexport type QueuedPrompt = typeof QueuedPrompt.Type;\n\n/** Text streamed into a reply's part since its last checkpoint; never stored. */\nexport const LiveDelta = Schema.Struct({\n\t/** The reply's entry id. */\n\tentryId: Schema.String,\n\tpartIndex: Schema.Int,\n\tkind: Schema.Literals([\"text\", \"thinking\"]),\n\t/** The part's text length before this delta: apply it only where the held text ends there. */\n\toffset: Schema.Int,\n\tdelta: Schema.String,\n});\nexport type LiveDelta = typeof LiveDelta.Type;\n\n/** A `thread.sync` item: a row with the revision that last wrote it, progress, or a live delta. */\nexport const ThreadItem = Schema.Union([\n\t/** Upsert by entry id. */\n\tSchema.TaggedStruct(\"Entry\", { entry: HistoryEntry, rev: Schema.Int }),\n\tSchema.TaggedStruct(\"Inbox\", {\n\t\tprompt: QueuedPrompt,\n\t\tstate: Schema.Literals([\"pending\", \"promoted\", \"cancelled\"]),\n\t\trev: Schema.Int,\n\t}),\n\t/** Every row with a revision up to `rev` has been sent; `floor`, on the first, is the oldest entry's seq. */\n\tSchema.TaggedStruct(\"Synced\", { storeId: Schema.String, rev: Schema.Int, floor: optional(Schema.Int) }),\n\tSchema.TaggedStruct(\"Delta\", { delta: LiveDelta }),\n]);\nexport type ThreadItem = typeof ThreadItem.Type;\n\n/** Ends `session.log`'s replay; `seq` is absent when the session has no durable events yet. */\nexport const LogSynced = Schema.Struct({\n\ttype: Schema.Literal(\"log.synced\"),\n\t/** The session the log was read for. */\n\taggregateId: Schema.String,\n\tseq: optional(Schema.Int),\n});\nexport type LogSynced = typeof LogSynced.Type;\n\n/** A thread's model, thinking and foundation choices: a given field replaces the stored one, `null` clears it. */\nexport const RuntimeConfig = Schema.Struct({\n\tmodel: optional(Schema.NullOr(Schema.Struct({ provider: Schema.String, id: Schema.String }))),\n\tthinkingLevel: optional(Schema.NullOr(Schema.Enum(Model.ThinkingLevelEnum))),\n\tfoundation: optional(Schema.NullOr(Schema.NonEmptyString)),\n});\nexport type RuntimeConfig = typeof RuntimeConfig.Type;\n\nconst SandboxRef = Sandbox.Selection;\n\n/** A model to choose, by the catalog's id and display name, with the thinking levels it supports. */\nconst ModelOption = Schema.Struct({\n\tid: Schema.String,\n\tname: Schema.String,\n\t/** In ascending order; `[\"off\"]` for a model that does not reason. */\n\tthinkingLevels: Schema.Array(Schema.Enum(Model.ThinkingLevelEnum)),\n});\n\n/** A provider this server can call, with the models a session may use from it. */\nconst ModelProvider = Schema.Struct({\n\tid: Schema.String,\n\tname: Schema.String,\n\tmodels: Schema.Array(ModelOption),\n});\nexport type ModelProvider = typeof ModelProvider.Type;\n\n/** A project's name as a client sets it: trimmed, never empty. */\nconst ProjectName = Schema.Trimmed.check(Schema.isNonEmpty());\n\nexport class OAuthError extends Schema.TaggedError<OAuthError>()(\"Server.OAuthError\", {\n\tmessage: Schema.String,\n}) {}\n\n/** OAuth providers whose credentials this server stores. */\nexport const OAuthProvider = Schema.Literals([\"openai-codex\", \"github-copilot\"]);\nexport type OAuthProvider = typeof OAuthProvider.Type;\n\n/**\n * Credentials as the provider's aikit module persists them. The union is\n * discriminated by `provider` so one set of RPCs serves every login.\n */\nexport const OAuthCredentials = Schema.Union([\n\tSchema.Struct({\n\t\tprovider: Schema.Literal(\"openai-codex\"),\n\t\taccess: Schema.String,\n\t\trefresh: Schema.String,\n\t\texpires: Schema.Finite,\n\t\taccountId: Schema.String,\n\t}),\n\tSchema.Struct({\n\t\tprovider: Schema.Literal(\"github-copilot\"),\n\t\taccess: Schema.String,\n\t\trefresh: Schema.String,\n\t\texpires: Schema.Finite,\n\t\tenterpriseUrl: optional(Schema.String),\n\t\tapiEndpoint: optional(Schema.String),\n\t\tavailableModelIds: optional(Schema.Array(Schema.String)),\n\t}),\n]);\nexport type OAuthCredentials = typeof OAuthCredentials.Type;\n\n/** What a login looks like from the outside: never the tokens themselves. */\nexport const OAuthInfo = Schema.Struct({\n\tprovider: OAuthProvider,\n\t/** Epoch millis, or 0 for a credential that does not expire. */\n\texpires: Schema.Finite,\n\taccountId: optional(Schema.String),\n\tapiEndpoint: optional(Schema.String),\n\tenterpriseUrl: optional(Schema.String),\n\tavailableModels: optional(Schema.Int),\n});\nexport type OAuthInfo = typeof OAuthInfo.Type;\n\n/**\n * A host folder operation that failed: unreadable, not a directory, taken, or git/gh refused. `reason`\n * names a path that is not there, or is a file, so a client can offer to create it only when it is missing.\n */\nexport class HostError extends Schema.TaggedError<HostError>()(\"Server.HostError\", {\n\tmessage: Schema.String,\n\treason: optional(Schema.Literals([\"missing\", \"file\"])),\n}) {}\n\n/** A directory on the host, by its name and absolute path. */\nexport const Folder = Schema.Struct({ name: Schema.String, path: Schema.String });\nexport type Folder = typeof Folder.Type;\n\n/** A GitHub repository as `gh` names it, with its web and SSH clone URLs. */\nexport const Repository = Schema.Struct({ nameWithOwner: Schema.String, url: Schema.String, sshUrl: Schema.String });\nexport type Repository = typeof Repository.Type;\n\nexport const CloneStage = Schema.Literals([\"connecting\", \"counting\", \"receiving\", \"resolving\", \"checkout\"]);\nexport type CloneStage = typeof CloneStage.Type;\n\nconst ClonePhase = Schema.Literals([\"running\", \"done\", \"failed\", \"cancelled\"]);\nexport type ClonePhase = typeof ClonePhase.Type;\n\n/** A tracked clone; `path` (the absolute destination) is its id. */\nexport const Clone = Schema.Struct({\n\tpath: Schema.String,\n\t/** Credentials and query stripped. */\n\tremote: Schema.String,\n\tphase: ClonePhase,\n\tstage: CloneStage,\n\t/** 0 to 100 within `stage`, when git prints one. */\n\tpercent: Schema.NullOr(Schema.Int),\n\t/** Git's transfer note, such as its speed; at most 200 characters. */\n\tdetail: Schema.NullOr(Schema.String),\n\t/** Git has printed no progress for 20 seconds. */\n\tstalled: Schema.Boolean,\n\t/** Why it failed; at most 1000 characters. */\n\terror: Schema.NullOr(Schema.String),\n\t/** Epoch milliseconds. */\n\tstartedAt: Schema.Finite,\n\tendedAt: Schema.NullOr(Schema.Finite),\n\t/** Bumped on every change across all clones; a higher one is newer. */\n\tsequence: Schema.Int,\n});\nexport type Clone = typeof Clone.Type;\n\nconst SessionErrors = Schema.Union([\n\tSessionStore.SessionNotFoundError,\n\tThreadStore.ThreadNotFoundError,\n\tSessionStore.SessionLinkedSpaceNotFoundError,\n\tSessionStore.RelinkError,\n]);\n\nconst ThreadErrors = Schema.Union([SessionStore.SessionNotFoundError, ThreadStore.ThreadNotFoundError]);\n\n// Every lifecycle error the sandbox control plane can raise; narrowing per\n// endpoint would misreport what `withMount` and `stop` actually fail with.\nconst SandboxErrors = Schema.Union([\n\tSandboxError.SandboxNotFoundError,\n\tSandboxError.SandboxDriverNotRegisteredError,\n\tSandboxError.SandboxDriverRegistrationError,\n\tSandboxError.SandboxUnsupportedError,\n\tSandboxError.SandboxProviderError,\n\tSandboxError.SandboxUnavailError,\n\tSandboxError.SandboxRemovedError,\n\tSandboxError.SandboxTransitionConflictError,\n\tSandboxError.SandboxBusyError,\n]);\n\nconst LocationErrors = Schema.Union([Location.DirectoryNotFoundError, Location.NotDirectoryError]);\n\n/** One of a thread's MCP servers as that thread sees it. */\nconst McpStatus = Schema.Struct({\n\tserver: Schema.String,\n\tstate: EventList.McpState,\n\terror: optional(Schema.String),\n\t/** Tools the server offered when last listed, each with its exposure in the thread. */\n\ttools: Schema.Array(\n\t\tSchema.Struct({ name: Schema.String, exposure: Schema.Literals([\"direct\", \"codemode\", \"deferred\", \"hidden\"]) }),\n\t),\n\tresources: Schema.Boolean,\n\t/** Tools it listed last that were left out because the MCP SDK rejects them; absent when none were. */\n\tskipped: optional(EventList.McpSkipped),\n});\nexport type McpStatus = typeof McpStatus.Type;\n\nconst McpErrors = Schema.Union([ThreadErrors, McpError.UnknownServerError]);\n\nconst SettingsFileRef = { projectId: optional(Schema.String), file: Schema.Literals([\"settings\", \"mcp\"]) };\n/** The settings a project's `settings.jsonc` falls back to, as the page shows them. */\nconst Inherited = Schema.Struct({\n\tretry: Schema.Struct({ maxRetries: Schema.Int, baseDelayMs: Schema.Int, maxDelayMs: Schema.Int }),\n});\nconst SettingsFileErrors = Schema.Union([\n\tSettings.SettingsError,\n\tProject.ProjectNotFoundError,\n\tProject.ProjectCheckoutError,\n]);\n\nexport const Api = RpcGroup.make(\n\t/**\n\t * The server's own identity: the process and build a client is talking to.\n\t *\n\t * The health probe: a discovery registration names a pid and version, and a\n\t * caller confirms the process answering is the one that registered before it\n\t * trusts the endpoint. Like every other capability it rides the RPC channel,\n\t * so there is no separate HTTP surface to keep in step.\n\t */\n\tRpc.make(\"server.info\", {\n\t\tpayload: {},\n\t\tsuccess: Schema.Struct({\n\t\t\tpid: Schema.Int,\n\t\t\tversion: Schema.String,\n\t\t\t/** The harness store this server serves; a sync cursor is only valid against it. */\n\t\t\tstoreId: Schema.String,\n\t\t\t/** The store's head: the last revision taken. */\n\t\t\trev: Schema.Int,\n\t\t\t/** The machine it runs on, by the name its user knows it; absent when the OS names it nothing. */\n\t\t\thost: optional(Schema.Struct({ name: Schema.String })),\n\t\t\t/** The id in the home's `machine.json`; absent until the home has one. */\n\t\t\tmachineId: optional(Schema.String),\n\t\t}),\n\t}),\n\t/**\n\t * The index of this machine: every project, space, session and thread whose revision is past\n\t * `after`, in revision order, then `Synced` at the head read when the call began; then the same\n\t * live after each commit. `after: 0` reads the whole index. A row written again moves to a later\n\t * revision and is sent again; the latest wins. A deleted session arrives as `Removed`. `boot` is\n\t * the one the last `Synced` carried: when the store left that line (a restored backup), it reads\n\t * from zero instead.\n\t */\n\tRpc.make(\"index.sync\", {\n\t\tpayload: { after: Schema.Int, boot: optional(Schema.String) },\n\t\tsuccess: IndexItem,\n\t\tstream: true,\n\t}),\n\t/**\n\t * The usage rollup of this machine: every `usage` and `tally` row whose revision is past `after`,\n\t * in revision order, then `Synced` at the head read when the call began; then the same live after\n\t * each commit. `after: 0` reads every row. A row written again moves to a later revision and is\n\t * sent again in full; the latest wins. Rows carry running totals, not deltas: a client replaces a\n\t * row by its key, never adds to it. A deleted session's rows stay. `boot` is the one the last\n\t * `Synced` carried: when the store left that line (a restored backup), it reads from zero instead.\n\t */\n\tRpc.make(\"usage.sync\", {\n\t\tpayload: { after: Schema.Int, boot: optional(Schema.String) },\n\t\tsuccess: UsageItem,\n\t\tstream: true,\n\t}),\n\tRpc.make(\"auth.save\", {\n\t\tpayload: { credentials: OAuthCredentials },\n\t\tsuccess: OAuthInfo,\n\t\terror: OAuthError,\n\t}),\n\tRpc.make(\"auth.status\", {\n\t\tpayload: { provider: OAuthProvider },\n\t\tsuccess: Schema.NullOr(OAuthInfo),\n\t\terror: OAuthError,\n\t}),\n\tRpc.make(\"auth.refresh\", {\n\t\tpayload: { provider: OAuthProvider },\n\t\tsuccess: Schema.NullOr(OAuthInfo),\n\t\terror: OAuthError,\n\t}),\n\tRpc.make(\"auth.logout\", {\n\t\tpayload: { provider: OAuthProvider },\n\t\tsuccess: Schema.Void,\n\t\terror: OAuthError,\n\t}),\n\t/** A session and its `main` thread; the main thread's info, with the session embedded. */\n\tRpc.make(\"session.create\", {\n\t\tpayload: {\n\t\t\t/** The main thread's title; absent = its first prompt names it. */\n\t\t\ttitle: optional(Schema.String),\n\t\t\tdirectory: optional(Schema.String),\n\t\t\t/**\n\t\t\t * The host directory this session is anchored to, usually the caller's project root.\n\t\t\t * Unrelated to `directory`, which names a place inside the session's space.\n\t\t\t *\n\t\t\t * It is an anchor and nothing more: whatever needs a host-side directory resolves from\n\t\t\t * here rather than from wherever the server happens to be running. What reads it is the\n\t\t\t * reader's business, not this field's.\n\t\t\t *\n\t\t\t * Optional and honoured as given. Omitting it is normal, not a failure.\n\t\t\t */\n\t\t\thostDir: optional(Session.AbsolutePath),\n\t\t\tsandbox: optional(SandboxRef),\n\t\t\truntime: optional(RuntimeConfig),\n\t\t\t/**\n\t\t\t * Names the project when this session creates it, ahead of the repository's and the\n\t\t\t * folder's name. A project that already exists keeps its name; `project.rename` changes it.\n\t\t\t */\n\t\t\tproject: optional(Schema.Struct({ name: ProjectName })),\n\t\t},\n\t\tsuccess: ThreadInfo,\n\t\t/** `HostError` when `hostDir` is a clone still running, failed or cancelled. */\n\t\terror: Schema.Union([SessionErrors, SandboxErrors, LocationErrors, HostError]),\n\t}),\n\t/** The `origin` URL of a project's main checkout on the host, credentials taken out; null when there is none. */\n\tRpc.make(\"project.remote\", {\n\t\tpayload: { projectId: Schema.String },\n\t\tsuccess: Schema.Struct({ url: Schema.NullOr(Schema.String) }),\n\t\terror: Project.ProjectNotFoundError,\n\t}),\n\tRpc.make(\"project.rename\", {\n\t\tpayload: { projectId: Schema.String, name: ProjectName },\n\t\tsuccess: Schema.Struct({ id: Schema.String, name: Schema.String }),\n\t\terror: Project.ProjectNotFoundError,\n\t}),\n\t/**\n\t * A settings file as written: the project's when `projectId` is given -- the one sessions in its\n\t * main checkout read -- otherwise the user's. `version` is what `settings.write` is held to;\n\t * `error` is what the runtime would reject in the file as it stands.\n\t */\n\tRpc.make(\"settings.read\", {\n\t\tpayload: SettingsFileRef,\n\t\tsuccess: Schema.Struct({\n\t\t\tpath: Schema.String,\n\t\t\tsource: Schema.String,\n\t\t\texists: Schema.Boolean,\n\t\t\tversion: Schema.String,\n\t\t\t/** The file's JSONC as a value; absent when it does not parse. */\n\t\t\tvalue: optional(Schema.Unknown),\n\t\t\terror: optional(Schema.String),\n\t\t\t/**\n\t\t\t * For `settings.jsonc`: what applies where this file sets nothing -- the user's settings over the\n\t\t\t * defaults for a project's file, the defaults for the user's. Absent when a lower file is broken.\n\t\t\t */\n\t\t\tinherited: optional(Inherited),\n\t\t\t/**\n\t\t\t * For `mcp.json`: the servers as sessions use them, user and project merged; entries the runtime\n\t\t\t * skips are left out. `from` is the file that defines the server, not one that only overrides it.\n\t\t\t */\n\t\t\tservers: optional(\n\t\t\t\tSchema.Array(\n\t\t\t\t\tSchema.Struct({\n\t\t\t\t\t\tname: Schema.String,\n\t\t\t\t\t\tfrom: Schema.Literals([\"user\", \"project\"]),\n\t\t\t\t\t\tenabled: Schema.Boolean,\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t),\n\t\t}),\n\t\terror: SettingsFileErrors,\n\t}),\n\t/** The whole file, written only when it is still at `version` and the runtime would accept it. */\n\tRpc.make(\"settings.write\", {\n\t\tpayload: { ...SettingsFileRef, source: Schema.String, version: Schema.String },\n\t\tsuccess: Schema.Struct({ version: Schema.String }),\n\t\terror: Schema.Union([SettingsFileErrors, SettingsFile.SettingsConflictError]),\n\t}),\n\t/**\n\t * One value at `at` set in place, keeping the rest of the file as written; no `value` removes it.\n\t * Refused when the result would not be accepted.\n\t */\n\tRpc.make(\"settings.set\", {\n\t\tpayload: {\n\t\t\t...SettingsFileRef,\n\t\t\tat: Schema.NonEmptyArray(Schema.Union([Schema.String, Schema.Int])),\n\t\t\tvalue: optional(Schema.Unknown),\n\t\t},\n\t\tsuccess: Schema.Struct({ version: Schema.String }),\n\t\terror: SettingsFileErrors,\n\t}),\n\t/**\n\t * The models a session anchored at `hostDir` can use: providers this server holds credentials\n\t * for, in the catalog plus that project's settings, and the model a session runs when it names\n\t * none: the one settings name, else one picked from those providers. `default` is absent when\n\t * neither gives one. Without `hostDir`, only the user's settings apply. Credentials are checked\n\t * for presence, not validity.\n\t */\n\tRpc.make(\"model.list\", {\n\t\tpayload: { hostDir: optional(Session.AbsolutePath) },\n\t\tsuccess: Schema.Struct({\n\t\t\tproviders: Schema.Array(ModelProvider),\n\t\t\tdefault: optional(\n\t\t\t\tSchema.Struct({\n\t\t\t\t\tprovider: Schema.String,\n\t\t\t\t\tid: Schema.String,\n\t\t\t\t\t/** As settings name it; a run clamps it to what the model supports. */\n\t\t\t\t\tthinkingLevel: Schema.Enum(Model.ThinkingLevelEnum),\n\t\t\t\t\t/** Display names from the catalog, present even when its provider is not listed. */\n\t\t\t\t\tname: optional(Schema.String),\n\t\t\t\t\tproviderName: optional(Schema.String),\n\t\t\t\t}),\n\t\t\t),\n\t\t}),\n\t\terror: Schema.Union([Settings.SettingsError, Runner.ModelCatalogError]),\n\t}),\n\t/**\n\t * Point an existing session at a host directory, or clear it with `null`.\n\t *\n\t * Not `session.relink`: that moves where the *work* happens, this changes which host directory\n\t * the session is *anchored to*. Conflating them would recreate exactly the `cwd`/`hostDir`\n\t * confusion the split exists to remove, which is why they sound alike and stay apart.\n\t */\n\tRpc.make(\"session.link\", {\n\t\tpayload: {\n\t\t\tsessionId: Session.SessionSchema.ID,\n\t\t\t/** Absent clears the anchor, leaving the session with no host directory. */\n\t\t\thostDir: optional(Session.AbsolutePath),\n\t\t},\n\t\tsuccess: SessionInfo,\n\t\terror: SessionStore.SessionNotFoundError,\n\t}),\n\t/**\n\t * Moves where the work happens. Without `threadId`, the session's default space and directory,\n\t * which every thread without its own placement follows; with it, that thread's placement only.\n\t * Answers with the addressed thread (`main` when absent): its `placement` and embedded session\n\t * show where it now runs.\n\t */\n\tRpc.make(\"session.relink\", {\n\t\tpayload: {\n\t\t\tsessionId: Session.SessionSchema.ID,\n\t\t\tthreadId: optional(ThreadSchema.ID),\n\t\t\tsandbox: optional(SandboxRef),\n\t\t\tdirectory: optional(Schema.String),\n\t\t},\n\t\tsuccess: ThreadInfo,\n\t\terror: Schema.Union([SessionErrors, SandboxErrors, LocationErrors]),\n\t}),\n\t/** Stops every thread, then removes the session with its log. `deleted` is false when it did not exist. */\n\tRpc.make(\"session.delete\", {\n\t\tpayload: { sessionId: Session.SessionSchema.ID },\n\t\tsuccess: Schema.Struct({ deleted: Schema.Boolean }),\n\t}),\n\t/** Interrupts every running thread of the session. */\n\tRpc.make(\"session.interrupt\", {\n\t\tpayload: { sessionId: Session.SessionSchema.ID },\n\t\tsuccess: Schema.Struct({ interrupted: Schema.Boolean }),\n\t}),\n\t/**\n\t * A session's durable events after `after` (exclusive; omitted reads from the start), then a\n\t * `log.synced` marker at the head read when the call began. With `follow`, each event then\n\t * streams as it commits; without it the stream ends at the marker. Every thread of the session\n\t * writes this one log; events name their `threadId`.\n\t * Ephemeral events (text and tool progress deltas) are never stored, so they are not here;\n\t * `event.subscribe` carries them live. To resume, pass the higher of the last event's\n\t * `durable.seq` and the last marker's `seq`: the marker can sit past the last event sent.\n\t * With `threadId`, only that thread's events; the marker still names the session's head. A fork's\n\t * own log starts at its `session.thread.forked`: what it inherits is in `thread.history`.\n\t */\n\tRpc.make(\"session.log\", {\n\t\tpayload: {\n\t\t\tsessionId: Session.SessionSchema.ID,\n\t\t\tthreadId: optional(ThreadSchema.ID),\n\t\t\tafter: optional(Schema.Int),\n\t\t\tfollow: optional(Schema.Boolean),\n\t\t},\n\t\tsuccess: Schema.Union([EventEnvelope, LogSynced]),\n\t\terror: Schema.Union([SessionStore.SessionNotFoundError, EncodingError]),\n\t\tstream: true,\n\t}),\n\t/** Threads newest first, each with its session embedded: of one session, or all. */\n\tRpc.make(\"thread.list\", {\n\t\tpayload: { sessionId: optional(Session.SessionSchema.ID) },\n\t\tsuccess: Schema.Array(ThreadInfo),\n\t}),\n\tRpc.make(\"thread.info\", {\n\t\tpayload: ThreadRef,\n\t\tsuccess: ThreadInfo,\n\t\terror: ThreadErrors,\n\t}),\n\t/**\n\t * The conversation in a thread's line: user and assistant messages, inherited ones first, oldest\n\t * first. The harness's own entries (compactions, resets, notices) are left out.\n\t */\n\tRpc.make(\"thread.history\", {\n\t\tpayload: ThreadRef,\n\t\tsuccess: Schema.Struct({ entries: Schema.Array(HistoryEntry) }),\n\t\terror: ThreadErrors,\n\t}),\n\t/**\n\t * Prompts admitted to the thread but not yet promoted, in admission order. Admission and\n\t * promotion are durable events, so a client following `session.log` rereads this whenever the\n\t * log moves.\n\t */\n\tRpc.make(\"thread.queue\", {\n\t\tpayload: ThreadRef,\n\t\tsuccess: Schema.Struct({ entries: Schema.Array(QueuedPrompt) }),\n\t\terror: ThreadErrors,\n\t}),\n\t/**\n\t * One thread's detail. Without `after`, the newest entries of its line (inherited ones\n\t * included) within `budget` bytes (default 1 MiB) and its pending inbox, then `Synced` with\n\t * `floor`. With `after`, its own entries and inbox rows whose revision is past it, then\n\t * `Synced`. Then the same live after each commit, with the thread's text and thinking deltas\n\t * as `Delta` between.\n\t */\n\tRpc.make(\"thread.sync\", {\n\t\tpayload: {\n\t\t\tsessionId: Session.SessionSchema.ID,\n\t\t\tthreadId: ThreadSchema.ID,\n\t\t\tafter: optional(Schema.Int),\n\t\t\tbudget: optional(Schema.Int),\n\t\t},\n\t\tsuccess: ThreadItem,\n\t\terror: Schema.Union([ThreadErrors, Event.SubscriptionOverflowError, EncodingError]),\n\t\tstream: true,\n\t}),\n\t/**\n\t * Older entries of a thread's line (inherited ones included), oldest first: the newest `limit`\n\t * whose `seq` is below `before`, cut to `budget` bytes (default 1 MiB). The newest is always sent.\n\t */\n\tRpc.make(\"thread.page\", {\n\t\tpayload: {\n\t\t\tsessionId: Session.SessionSchema.ID,\n\t\t\tthreadId: ThreadSchema.ID,\n\t\t\tbefore: Schema.Int,\n\t\t\tlimit: Schema.Int,\n\t\t\tbudget: optional(Schema.Int),\n\t\t},\n\t\tsuccess: Schema.Struct({ entries: Schema.Array(HistoryEntry) }),\n\t\terror: ThreadErrors,\n\t}),\n\tRpc.make(\"thread.configure\", {\n\t\tpayload: { ...ThreadRef, runtime: RuntimeConfig },\n\t\tsuccess: ThreadInfo,\n\t\terror: ThreadErrors,\n\t}),\n\t/**\n\t * A new thread whose history continues from this one's line through `entryId`, which must be\n\t * committed. `before` stops at the entry's predecessor and returns its text to edit again.\n\t */\n\tRpc.make(\"thread.fork\", {\n\t\tpayload: { ...ThreadRef, entryId: Schema.String, mode: optional(Schema.Literals([\"at\", \"before\"])) },\n\t\tsuccess: Schema.Struct({ thread: ThreadInfo, text: optional(Schema.String) }),\n\t\terror: Schema.Union([ThreadErrors, ThreadStore.ForkError]),\n\t}),\n\tRpc.make(\"thread.prompt\", {\n\t\tpayload: {\n\t\t\t...ThreadRef,\n\t\t\ttext: Schema.String,\n\t\t\tdelivery: optional(PromptSchema.Delivery),\n\t\t\tid: optional(Session.SessionMessageSchema.ID),\n\t\t},\n\t\tsuccess: Schema.Struct({ threadId: ThreadSchema.ID }),\n\t\terror: Schema.Union([ThreadErrors, Control.PromptConflictError]),\n\t}),\n\t/**\n\t * Withdraws a queued prompt before it joins the conversation. `cancelled` is false when it had\n\t * already been promoted (it then stays in the conversation) or no pending prompt has that id.\n\t */\n\tRpc.make(\"thread.cancel\", {\n\t\tpayload: { ...ThreadRef, messageId: Session.SessionMessageSchema.ID },\n\t\tsuccess: Schema.Struct({ cancelled: Schema.Boolean }),\n\t\terror: ThreadErrors,\n\t}),\n\t/**\n\t * Moves a queued prompt to the other lane or rewrites it, keeping its place in the queue.\n\t * `delivery: \"steer\"` also wakes the thread, so a prompt left waiting after a stop runs now.\n\t * `updated` is false when it had already been promoted or cancelled, or no pending prompt has that id.\n\t */\n\tRpc.make(\"thread.update\", {\n\t\tpayload: {\n\t\t\t...ThreadRef,\n\t\t\tmessageId: Session.SessionMessageSchema.ID,\n\t\t\tdelivery: optional(PromptSchema.Delivery),\n\t\t\ttext: optional(Schema.String),\n\t\t},\n\t\tsuccess: Schema.Struct({ updated: Schema.Boolean }),\n\t\terror: ThreadErrors,\n\t}),\n\tRpc.make(\"thread.interrupt\", {\n\t\tpayload: ThreadRef,\n\t\tsuccess: Schema.Struct({ interrupted: Schema.Boolean }),\n\t\terror: ThreadErrors,\n\t}),\n\t/**\n\t * Whether a prompt materialized into the thread's conversation. An admitted prompt that is still\n\t * queued has no entry yet, so this is the projection a client reconciles against when the\n\t * volatile stream left it unsure.\n\t */\n\tRpc.make(\"thread.message\", {\n\t\tpayload: { ...ThreadRef, messageId: Session.SessionMessageSchema.ID },\n\t\tsuccess: Schema.Struct({ found: Schema.Boolean }),\n\t\terror: ThreadErrors,\n\t}),\n\tRpc.make(\"thread.wait\", {\n\t\tpayload: ThreadRef,\n\t\tsuccess: Schema.Void,\n\t\terror: ThreadErrors,\n\t}),\n\t/**\n\t * Re-import every configured plugin, for the whole server.\n\t *\n\t * The one thing an exchange cannot notice on its own: a local plugin whose contents changed\n\t * while its path did not. A failure keeps the previous set and is reported here rather than\n\t * emptying a running server's tool registry.\n\t */\n\tRpc.make(\"plugin.reload\", {\n\t\tpayload: {},\n\t\t// No error channel: a reload that fails keeps the previous set and reports why, because a\n\t\t// server that empties its tool registry over a typo is worse than one that says so.\n\t\tsuccess: Schema.Struct({ plugins: Schema.Int, failure: optional(Schema.String) }),\n\t}),\n\t/**\n\t * Close the instance behind a thread's MCP server, or its attempt, and connect it afresh, for\n\t * every thread sharing it. Answers once that attempt finished, with the server's state then.\n\t */\n\tRpc.make(\"mcp.connect\", {\n\t\tpayload: McpServerRef,\n\t\tsuccess: McpStatus,\n\t\terror: McpErrors,\n\t}),\n\t/** Close it, for every thread sharing it, and keep it closed until `mcp.connect` or a config change. */\n\tRpc.make(\"mcp.disconnect\", {\n\t\tpayload: McpServerRef,\n\t\tsuccess: McpStatus,\n\t\terror: McpErrors,\n\t}),\n\t/** This machine and the workspaces it is connected to. */\n\tRpc.make(\"machine.info\", {\n\t\tpayload: {},\n\t\tsuccess: Machine.Status,\n\t}),\n\t/** Names this machine for people; an empty name goes back to the OS's. */\n\tRpc.make(\"machine.rename\", {\n\t\tpayload: { givenName: Schema.String },\n\t\tsuccess: Machine.Status,\n\t}),\n\t/** Leaves a workspace: the relay revokes this machine's link, and the machine forgets it. */\n\tRpc.make(\"machine.disconnect\", {\n\t\tpayload: Machine.Disconnect,\n\t\tsuccess: Machine.Disconnected,\n\t\terror: Machine.ConnectError,\n\t}),\n\t/**\n\t * Connects this machine to a workspace: the code a member approves, then the link once they have.\n\t * `workspaceId` is the workspace it is meant for; without one the approver picks it.\n\t */\n\tRpc.make(\"machine.connect\", {\n\t\tpayload: { workspaceId: Schema.optional(Schema.String) },\n\t\tsuccess: Machine.ConnectEvent,\n\t\terror: Machine.ConnectError,\n\t\tstream: true,\n\t}),\n\t/**\n\t * A one-time code another computer exchanges at `POST /api/v1/devices` to pair its key, and the\n\t * fingerprint of this machine's key, which that computer keeps. Valid 10 minutes, once; held in\n\t * memory, so a restart forgets it. Local callers only.\n\t */\n\tRpc.make(\"device.pair\", {\n\t\tpayload: {},\n\t\tsuccess: Schema.Struct({ code: Schema.String, expiresAt: Schema.Finite, fingerprint: Schema.String }),\n\t\terror: Principal.Forbidden,\n\t}),\n\t/** Every paired device, oldest first. Local callers only. */\n\tRpc.make(\"device.list\", {\n\t\tpayload: {},\n\t\tsuccess: Schema.Array(DeviceInfo),\n\t\terror: Principal.Forbidden,\n\t}),\n\t/** Forgets a device and ends its open connections; `applied` is false when none has `id`. Local callers only. */\n\tRpc.make(\"device.revoke\", {\n\t\tpayload: { id: Schema.String },\n\t\tsuccess: Schema.Struct({ applied: Schema.Boolean }),\n\t\terror: Principal.Forbidden,\n\t}),\n\t/**\n\t * Ends the calling device's own pairing, as `device.revoke` would. Its sockets end with it, this one\n\t * too, so the reply may never arrive: the connection dropping after the call is sent means it left.\n\t * Devices only; a local caller has no pairing to leave.\n\t */\n\tRpc.make(\"device.leave\", {\n\t\tpayload: {},\n\t\terror: Principal.Forbidden,\n\t}),\n\t/** The OS home directory, and the folder `host.create` makes projects in. */\n\tRpc.make(\"host.info\", {\n\t\tpayload: {},\n\t\tsuccess: Schema.Struct({ home: Schema.String, projects: Schema.String }),\n\t}),\n\t/**\n\t * The directories in `path` (a leading `~` is the OS home), hidden ones included, symlinks and\n\t * files left out. One the server may not read lists as empty with `readable` false: it can still\n\t * be added, as a folder macOS keeps from the server can.\n\t */\n\tRpc.make(\"host.browse\", {\n\t\tpayload: { path: Schema.String },\n\t\t// Optional: a client of this contract may reach a server from before it, which lists every folder as readable.\n\t\tsuccess: Schema.Struct({\n\t\t\tpath: Schema.String,\n\t\t\tentries: Schema.Array(Folder),\n\t\t\treadable: optional(Schema.Boolean),\n\t\t}),\n\t\terror: HostError,\n\t}),\n\t/**\n\t * A new folder under `host.info`'s `projects`, named after `name`, with a git repository and a\n\t * README. A first commit git refused is not fatal: `commitError` says why it was skipped.\n\t */\n\tRpc.make(\"host.create\", {\n\t\tpayload: { name: Schema.String },\n\t\tsuccess: Schema.Struct({ path: Schema.String, commitError: optional(Schema.String) }),\n\t\terror: HostError,\n\t}),\n\t/** An existing folder as an absolute path; a missing one is created. */\n\tRpc.make(\"host.add\", {\n\t\tpayload: { path: Schema.String },\n\t\tsuccess: Schema.Struct({ path: Schema.String }),\n\t\terror: HostError,\n\t}),\n\t/**\n\t * Starts a background clone of `remote` into `path`, which must be missing or empty, and answers\n\t * at once with the destination and the redacted remote; `host.clones` follows it. Git never prompts.\n\t */\n\tRpc.make(\"host.clone\", {\n\t\tpayload: { remote: Schema.String, path: Schema.String },\n\t\tsuccess: Schema.Struct({ path: Schema.String, remote: Schema.String }),\n\t\terror: HostError,\n\t}),\n\t/** Every tracked clone now, then the whole list again on each change. A finished one leaves 30 seconds after. */\n\tRpc.make(\"host.clones\", {\n\t\tpayload: {},\n\t\tsuccess: Schema.Array(Clone),\n\t\tstream: true,\n\t}),\n\t/** Stops a running clone and empties its folder; `applied` is false when it was not running. */\n\tRpc.make(\"host.cancel\", {\n\t\tpayload: { path: Schema.String },\n\t\tsuccess: Schema.Struct({ applied: Schema.Boolean }),\n\t}),\n\t/** Clones a failed or cancelled one again into its emptied folder; `applied` is false otherwise. */\n\tRpc.make(\"host.retry\", {\n\t\tpayload: { path: Schema.String },\n\t\tsuccess: Schema.Struct({ applied: Schema.Boolean }),\n\t\terror: HostError,\n\t}),\n\t/** Stops tracking a clone, stopping it and emptying its folder unless it finished. */\n\tRpc.make(\"host.discard\", {\n\t\tpayload: { path: Schema.String },\n\t\tsuccess: Schema.Void,\n\t}),\n\t/** Whether `gh` is installed and signed in; `hint` says what to do when it is not. */\n\tRpc.make(\"github.status\", {\n\t\tpayload: {},\n\t\tsuccess: Schema.Struct({ ready: Schema.Boolean, hint: optional(Schema.String) }),\n\t}),\n\t/** A repository by `owner/name`, `host/owner/name`, its URL, or a bare name of the signed-in user's. */\n\tRpc.make(\"github.lookup\", {\n\t\tpayload: { repository: Schema.String },\n\t\tsuccess: Repository,\n\t\terror: HostError,\n\t}),\n\tRpc.make(\"sandbox.drivers\", {\n\t\tpayload: {},\n\t\tsuccess: Schema.Array(Schema.Struct({ name: Schema.String, kind: Schema.String })),\n\t}),\n\tRpc.make(\"sandbox.list\", {\n\t\tpayload: {},\n\t\tsuccess: Schema.Array(SandboxInfo),\n\t}),\n\tRpc.make(\"sandbox.create\", {\n\t\tpayload: { driver: Schema.String },\n\t\tsuccess: SandboxInfo,\n\t\terror: SandboxErrors,\n\t}),\n\tRpc.make(\"sandbox.register\", {\n\t\tpayload: { driver: Schema.String, providerResourceId: Schema.String },\n\t\tsuccess: SandboxInfo,\n\t\terror: SandboxErrors,\n\t}),\n\tRpc.make(\"sandbox.stop\", {\n\t\tpayload: { sandboxId: Sandbox.SandboxInstance.ID },\n\t\tsuccess: Schema.Void,\n\t\terror: SandboxErrors,\n\t}),\n\t/**\n\t * Calls a method of a space daemon running in `spaceId`, such as `git.diff`. Never starts a daemon\n\t * and never wakes a sandbox: `unavailable` when none runs there, `detached` when the space is not\n\t * mounted.\n\t */\n\tRpc.make(\"daemon.call\", {\n\t\tpayload: {\n\t\t\tplugin: Schema.String,\n\t\t\tspaceId: Schema.String,\n\t\t\tmethod: Schema.String,\n\t\t\tinput: optional(Schema.Unknown),\n\t\t},\n\t\tsuccess: Schema.Unknown,\n\t\terror: DaemonHost.DaemonCallError,\n\t}),\n\t/**\n\t * Every event the server publishes, live, after a `server.connected` frame. With `threadId`,\n\t * only the events naming that thread; the frame still comes first.\n\t */\n\tRpc.make(\"event.subscribe\", {\n\t\tpayload: {\n\t\t\tthreadId: optional(ThreadSchema.ID),\n\t\t\t/**\n\t\t\t * Only these event types. The last event of each type that a space daemon published is sent\n\t\t\t * first, after `server.connected`: a client that was away catches up without a change.\n\t\t\t */\n\t\t\ttypes: optional(Schema.Array(Schema.String)),\n\t\t\t// With `threadId` too, only events naming that thread pass: daemon events name none.\n\t\t},\n\t\tsuccess: EventEnvelope,\n\t\terror: Schema.Union([Event.SubscriptionOverflowError, EncodingError]),\n\t\tstream: true,\n\t}),\n).middleware(Principal.Door);\n","import { EventList, type EventSchema, optional, Session } from \"@codeworksh/harness/effect\";\nimport { Door } from \"@codeworksh/schema\";\nimport { NodeSocket } from \"@effect/platform-node\";\nimport { Deferred, Effect, Layer, Schema, Stream } from \"effect\";\nimport { RpcClient, RpcSerialization } from \"effect/rpc\";\nimport * as Contract from \"./contract.ts\";\nimport * as Envelope from \"./envelope.ts\";\n\nexport const make = RpcClient.make(Contract.Api);\nexport type Client = Effect.Success<typeof make>;\n\n/** A server to call: its URL, and its home's token, offered as the socket opens. */\nexport interface Target {\n\treadonly url: string;\n\treadonly token: string;\n}\n\nexport const layer = (server: Target) =>\n\tRpcClient.layerProtocolSocket().pipe(\n\t\tLayer.provide(NodeSocket.layerWebSocket(server.url, { protocols: Door.protocols(server.token) })),\n\t\tLayer.provide(RpcSerialization.layerNdjson),\n\t);\n\n/** A server-side failure as the client sees it: the category, not the cause. */\nexport class ExecutionError extends Schema.TaggedError<ExecutionError>()(\"Client.ExecutionError\", {\n\ttype: Schema.String,\n\tmessage: Schema.String,\n\tstatus: optional(Schema.Int),\n}) {}\n\n/**\n * Runs one prompt against a server and renders its output.\n *\n * Threads are shared, so the stream carries other clients' work too and every\n * terminal event has to be attributed before it is believed. A terminal that\n * arrives before our own prompt is promoted belongs to somebody else's drain:\n * it is remembered rather than raised, and forgotten the moment our prompt is\n * promoted. It only becomes our outcome if the session reaches idle having\n * never promoted us -- at which point it is the best explanation available for\n * why our prompt never ran.\n */\nexport const run = Effect.fn(\"Client.run\")(function* <E, R>(\n\trpc: Client,\n\tinput: { sessionId: Session.SessionSchema.ID; threadId: Session.ThreadSchema.ID; text: string },\n\trender: (event: EventSchema.Payload) => Effect.Effect<void, E, R>,\n) {\n\tconst id = Session.SessionMessageSchema.ID.create();\n\tlet admitted = false;\n\tlet promoted = false;\n\tlet settled = false;\n\t// By log position, since notifications may arrive out of order: a run that started after our\n\t// admission is one our prompt woke, so its failure before promoting us is ours. A run already going\n\t// fails on its own, and parks our prompt behind it.\n\tlet admittedAt: number | undefined;\n\tconst starts: Array<number> = [];\n\t// Runs that ended before promoting us, failed ones with their error.\n\tconst ends: Array<{ readonly at: number; readonly error: ExecutionError | undefined }> = [];\n\tconst ours = () =>\n\t\tends.findLast(({ at, error }) => {\n\t\t\tconst start = Math.max(...starts.filter((seq) => seq < at));\n\t\t\treturn error !== undefined && admittedAt !== undefined && start > admittedAt;\n\t\t})?.error;\n\t// Raised once a run ends after our admission without our prompt in it: the session may be about to\n\t// go idle, and only idleness proves our prompt is never running.\n\tconst stalled = yield* Deferred.make<void>();\n\n\t/** How a run ended, as this client reports it; `undefined` for a success. */\n\tconst failure = (event: EventList.RunEnded): ExecutionError | undefined => {\n\t\tif (Schema.is(EventList.ExecutionInterrupted)(event))\n\t\t\treturn new ExecutionError({\n\t\t\t\ttype: \"aborted\",\n\t\t\t\tmessage: event.data.reason === \"shutdown\" ? \"Server stopped the session\" : \"Session interrupted\",\n\t\t\t});\n\t\tif (Schema.is(EventList.RunFailed)(event))\n\t\t\treturn new ExecutionError({ type: `run.${event.data.reason}`, message: event.data.message });\n\t\tif (Schema.is(EventList.ExecutionFailed)(event))\n\t\t\treturn new ExecutionError({\n\t\t\t\ttype: event.data.error.type,\n\t\t\t\tmessage: event.data.error.message,\n\t\t\t\t...(event.data.error.status === undefined ? {} : { status: event.data.error.status }),\n\t\t\t});\n\t\treturn undefined;\n\t};\n\n\tconst consume = rpc[\"event.subscribe\"]({ threadId: input.threadId }).pipe(\n\t\tStream.mapEffect(\n\t\t\tEffect.fnUntraced(function* (envelope) {\n\t\t\t\tif (envelope.type === Envelope.Connected.type) {\n\t\t\t\t\tyield* rpc[\"thread.prompt\"]({ ...input, id, delivery: \"followUp\" });\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst event = yield* Envelope.decode(envelope).pipe(\n\t\t\t\t\tEffect.catchTag(\"UnknownEventTypeError\", () => Effect.void),\n\t\t\t\t);\n\t\t\t\tif (event === undefined) return;\n\t\t\t\tconst seq = event.durable?.seq;\n\t\t\t\tif (Schema.is(EventList.ExecutionStarted)(event) && seq !== undefined) starts.push(seq);\n\t\t\t\tif (Schema.is(EventList.PromptAdmitted)(event) && event.data.messageId === id) {\n\t\t\t\t\tadmitted = true;\n\t\t\t\t\tadmittedAt = seq;\n\t\t\t\t}\n\t\t\t\tif (Schema.is(EventList.Prompted)(event) && event.data.messageId === id) promoted = true;\n\n\t\t\t\tconst ended = EventList.isRunEnded(event);\n\t\t\t\tconst error = ended ? failure(event) : undefined;\n\t\t\t\tif (!promoted) {\n\t\t\t\t\t// Kept whatever arrives first: our admission comes from another fiber than the runs, so a\n\t\t\t\t\t// run's end may be notified before it.\n\t\t\t\t\tif (ended && seq !== undefined) ends.push({ at: seq, error });\n\t\t\t\t\tif (admitted && ends.some(({ at }) => admittedAt === undefined || at > admittedAt))\n\t\t\t\t\t\tyield* Deferred.succeed(stalled, undefined);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (error !== undefined) return yield* error;\n\t\t\t\tif (ended) {\n\t\t\t\t\tsettled = true;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tyield* render(event);\n\t\t\t}),\n\t\t),\n\t\tStream.takeUntil(() => settled),\n\t\tStream.runDrain,\n\t);\n\n\t// Idle is the cue to reconcile, not the verdict. `wait` follows successors, so\n\t// it resolves only once the session is quiet -- then the projection says\n\t// whether our prompt was ever part of it. A prompt that did run leaves its\n\t// terminal in flight on the same socket, so the consumer is left alone to\n\t// finish; only a prompt that never materialized ends the run early.\n\tlet abandoned = false;\n\tconst reconcile = Deferred.await(stalled).pipe(\n\t\tEffect.andThen(rpc[\"thread.wait\"]({ sessionId: input.sessionId, threadId: input.threadId })),\n\t\tEffect.andThen(rpc[\"thread.message\"]({ sessionId: input.sessionId, threadId: input.threadId, messageId: id })),\n\t\tEffect.andThen(({ found }) =>\n\t\t\tfound\n\t\t\t\t? Effect.never\n\t\t\t\t: Effect.sync(() => {\n\t\t\t\t\t\tabandoned = true;\n\t\t\t\t\t}),\n\t\t),\n\t);\n\n\tyield* Effect.raceFirst(consume, reconcile);\n\tif (settled) return;\n\tif (abandoned) return yield* ours() ?? new ExecutionError({ type: \"unknown\", message: \"Prompt was not promoted\" });\n\treturn yield* new ExecutionError({\n\t\ttype: \"transport.disconnected\",\n\t\tmessage: \"Event stream ended before the prompt finished; its output was not rendered\",\n\t});\n});\n","import type { Message } from \"@codeworksh/aikit\";\nimport { Effect, Schema } from \"effect\";\n\nexport interface UsageSummary {\n\treadonly turns: number;\n\treadonly provider?: string;\n\treadonly model?: string;\n\treadonly input: number;\n\treadonly output: number;\n\treadonly reasoning: number;\n\treadonly cacheRead: number;\n\treadonly cacheWrite: number;\n\treadonly totalTokens: number;\n\treadonly cost: number;\n}\n\nexport const emptyUsage: UsageSummary = {\n\tturns: 0,\n\tinput: 0,\n\toutput: 0,\n\treasoning: 0,\n\tcacheRead: 0,\n\tcacheWrite: 0,\n\ttotalTokens: 0,\n\tcost: 0,\n};\n\nexport const addUsage = (summary: UsageSummary, message: Message.AssistantMessage): UsageSummary => ({\n\tturns: summary.turns + 1,\n\tprovider: message.provider.id,\n\tmodel: message.responseModel ?? message.model,\n\tinput: summary.input + message.usage.input,\n\toutput: summary.output + message.usage.output,\n\treasoning: summary.reasoning + (message.usage.reasoning ?? 0),\n\tcacheRead: summary.cacheRead + message.usage.cacheRead,\n\tcacheWrite: summary.cacheWrite + message.usage.cacheWrite,\n\ttotalTokens: summary.totalTokens + message.usage.totalTokens,\n\tcost: summary.cost + message.usage.cost.total,\n});\n\nconst number = new Intl.NumberFormat(\"en-US\");\nconst row = (label: string, value: string) => `${label.padEnd(9)}${value}\\n`;\n\nconst formatCost = (cost: number): string => `$${cost.toFixed(cost > 0 && cost < 0.01 ? 6 : 4)}`;\n\nconst divider = (label: string, columns = 72): string => {\n\tconst width = Math.min(100, Math.max(32, columns));\n\tconst start = `── ${label} `;\n\treturn `${start}${\"─\".repeat(Math.max(2, width - start.length))}\\n`;\n};\n\nexport const header = (input: {\n\treadonly sessionId: string;\n\treadonly sandbox: string;\n\treadonly directory: string;\n\treadonly columns?: number;\n}): string =>\n\t`${row(\"session\", input.sessionId)}${row(\"sandbox\", `${input.sandbox} · ${input.directory}`)}\\n${divider(\n\t\t\"response\",\n\t\tinput.columns,\n\t)}`;\n\nexport const usage = (summary: UsageSummary, columns?: number): string => {\n\tconst turns = `${summary.turns} ${summary.turns === 1 ? \"turn\" : \"turns\"}`;\n\tconst model =\n\t\tsummary.provider === undefined || summary.model === undefined\n\t\t\t? \"unknown\"\n\t\t\t: `${summary.provider}/${summary.model}`;\n\tconst reasoning = summary.reasoning === 0 ? \"\" : ` · ${number.format(summary.reasoning)} reasoning`;\n\treturn `${divider(\"usage\", columns)}${row(\"model\", model)}${row(\n\t\t\"tokens\",\n\t\t`${number.format(summary.input)} input · ${number.format(summary.output)} output${reasoning} · ${number.format(\n\t\t\tsummary.totalTokens,\n\t\t)} total`,\n\t)}${row(\"cache\", `${number.format(summary.cacheRead)} read · ${number.format(summary.cacheWrite)} write`)}${row(\n\t\t\"cost\",\n\t\t`${formatCost(summary.cost)} · ${turns}`,\n\t)}`;\n};\n\nexport const writeOut = (value: string) => Effect.sync(() => void process.stdout.write(value));\n/** A value in its wire form, as indented JSON. */\nexport const writeJson = <A, I>(schema: Schema.Codec<A, I>, value: A) =>\n\tSchema.encodeEffect(schema)(value).pipe(\n\t\tEffect.orDie,\n\t\tEffect.flatMap((encoded) => writeOut(`${JSON.stringify(encoded, null, \"\\t\")}\\n`)),\n\t);\n\n/** Rows as plain columns, two spaces apart; the last column is not padded. */\nexport const table = (rows: ReadonlyArray<ReadonlyArray<string>>) => {\n\tconst widths = rows[0]?.map((_, column) => Math.max(...rows.map((row) => row[column]?.length ?? 0))) ?? [];\n\treturn rows\n\t\t.map((row) => {\n\t\t\tconst last = row.length - 1;\n\t\t\treturn `${row.map((cell, column) => (column === last ? cell : cell.padEnd(widths[column] ?? 0))).join(\" \")}\\n`;\n\t\t})\n\t\t.join(\"\");\n};\n\nexport const writeError = (value: string) => Effect.sync(() => void process.stderr.write(value));\nexport const terminalColumns = () => (process.stderr.isTTY ? (process.stderr.columns ?? 72) : 72);\n","import {\n\tDatabase,\n\tModelCatalog,\n\tPlugin,\n\tRunner,\n\tSandboxError,\n\tSessionStore,\n\tSettings,\n} from \"@codeworksh/harness/effect\";\nimport { SandboxProvider } from \"@codeworksh/harness/sandbox\";\nimport { Duration, Effect, Schema } from \"effect\";\nimport * as Client from \"../server/client.ts\";\nimport { writeError } from \"./output.ts\";\n\n/** Bad flag or argument combinations the parser cannot express on its own. */\nexport class InvalidInputError extends Schema.TaggedError<InvalidInputError>()(\"CLI.InvalidInputError\", {\n\tmessage: Schema.String,\n}) {}\n\nexport class OAuthError extends Schema.TaggedError<OAuthError>()(\"CLI.OAuthError\", {\n\tmessage: Schema.String,\n\tcause: Schema.optional(Schema.Defect()),\n}) {}\n\n/**\n * Every failure a command handler may surface to the runtime. Harness failures are\n * rendered inside the handler that owns them, so only the CLI's own errors reach\n * the top-level renderer.\n */\nexport type CommandError = InvalidInputError | OAuthError;\n\nconst isInvalidInputError = Schema.is(InvalidInputError);\nconst isOAuthError = Schema.is(OAuthError);\nconst isProviderError = Schema.is(Runner.ProviderError);\nconst isModelCatalogError = Schema.is(Runner.ModelCatalogError);\nconst isModelCatalogRefreshError = Schema.is(ModelCatalog.RefreshError);\nconst isModelNotFoundError = Schema.is(Runner.ModelNotFoundError);\nconst isNoModelError = Schema.is(Runner.NoModelError);\nconst isLLMStreamError = Schema.is(Runner.LLMStreamError);\nconst isSandboxProviderError = Schema.is(SandboxProvider.SandboxProviderError);\nconst isPluginInstallError = Schema.is(Plugin.InstallError);\nconst isPluginSourceError = Schema.is(Plugin.SourceError);\nconst isPluginStoreError = Schema.is(Plugin.StoreError);\nconst isPluginLoadError = Schema.is(Plugin.LoadError);\nconst isSessionNotLinkedError = Schema.is(SessionStore.SessionNotLinkedError);\nconst isSettingsError = Schema.is(Settings.SettingsError);\nconst isSandboxDriverNotRegisteredError = Schema.is(SandboxError.SandboxDriverNotRegisteredError);\nconst isSandboxDriverRegistrationError = Schema.is(SandboxError.SandboxDriverRegistrationError);\nconst isExecutionError = Schema.is(Client.ExecutionError);\nconst isDatabaseOutdatedError = Schema.is(Database.OutdatedError);\n\nconst credentialHint = (provider: string): string => {\n\tswitch (provider) {\n\t\tcase \"openrouter\":\n\t\t\treturn \"set OPENROUTER_API_KEY and retry\";\n\t\tcase \"openai\":\n\t\t\treturn \"set OPENAI_API_KEY and retry\";\n\t\tcase \"openai-codex\":\n\t\t\treturn \"run `codework auth login --openai-codex` and retry\";\n\t\tcase \"github-copilot\":\n\t\t\treturn \"run `codework auth login --github-copilot` and retry\";\n\t\tcase \"anthropic\":\n\t\t\treturn \"set ANTHROPIC_API_KEY and retry\";\n\t\tcase \"google\":\n\t\t\treturn \"set GOOGLE_GENERATIVE_AI_API_KEY and retry\";\n\t\tcase \"xai\":\n\t\t\treturn \"set XAI_API_KEY and retry\";\n\t\tdefault:\n\t\t\treturn `configure credentials for provider \"${provider}\" and retry`;\n\t}\n};\n\nconst providerHint = (error: Runner.ProviderError): string | undefined => {\n\tswitch (error.reason._tag) {\n\t\tcase \"Runner.ProviderAuthenticationError\":\n\t\t\treturn error.reason.authentication === \"missing\"\n\t\t\t\t? credentialHint(error.provider)\n\t\t\t\t: `check the credentials configured for provider \"${error.provider}\"`;\n\t\tcase \"Runner.ProviderAuthorizationError\":\n\t\t\treturn \"check that the credential can access this model and endpoint\";\n\t\tcase \"Runner.ProviderModelUnavailableError\":\n\t\t\treturn \"check the provider model ID and whether your account can access it\";\n\t\tcase \"Runner.ProviderRateLimitError\":\n\t\t\treturn error.reason.retryAfter === undefined\n\t\t\t\t? \"retry after the provider rate-limit window resets\"\n\t\t\t\t: `retry in about ${Math.ceil(Duration.toMillis(error.reason.retryAfter) / 1_000)} seconds`;\n\t\tcase \"Runner.ProviderQuotaError\":\n\t\t\treturn \"check the provider account quota or billing balance\";\n\t\tcase \"Runner.ProviderTimeoutError\":\n\t\tcase \"Runner.ProviderTransportError\":\n\t\tcase \"Runner.ProviderUnavailableError\":\n\t\t\treturn error.isRetryable ? \"this failure is retryable\" : undefined;\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n};\n\nconst unknownMessage = (error: unknown): string => {\n\tif (error instanceof Error && error.message.trim().length > 0) return error.message;\n\tif (typeof error === \"string\" && error.trim().length > 0) return error;\n\tif (typeof error === \"object\" && error !== null && \"_tag\" in error) {\n\t\t// A bare tag such as `ServeError` hides the reason; its cause carries it (`EADDRINUSE`).\n\t\tconst cause = \"cause\" in error ? error.cause : undefined;\n\t\treturn cause instanceof Error ? `${String(error._tag)}: ${cause.message}` : String(error._tag);\n\t}\n\treturn \"the command failed for an unknown reason\";\n};\n\n/**\n * What the reader can do about a reference that failed to prepare. A plugin list is\n * usually hand-written in a settings file, so the phase is worth translating.\n */\n/** One hint per reason. Lowercase, like everything else a plugin failure prints. */\nconst providerCategory = (reason: Runner.ProviderFailureReason): string => {\n\tswitch (reason._tag) {\n\t\tcase \"Runner.ProviderAuthenticationError\":\n\t\t\treturn \"provider-authentication-error\";\n\t\tcase \"Runner.ProviderConfigurationError\":\n\t\t\treturn \"provider-configuration-error\";\n\t\tcase \"Runner.ProviderAuthorizationError\":\n\t\t\treturn \"provider-authorization-error\";\n\t\tcase \"Runner.ProviderModelUnavailableError\":\n\t\t\treturn \"provider-model-unavailable-error\";\n\t\tcase \"Runner.ProviderRateLimitError\":\n\t\t\treturn \"provider-rate-limit-error\";\n\t\tcase \"Runner.ProviderQuotaError\":\n\t\t\treturn \"provider-quota-error\";\n\t\tcase \"Runner.ProviderInvalidRequestError\":\n\t\t\treturn \"provider-invalid-request-error\";\n\t\tcase \"Runner.ProviderContentPolicyError\":\n\t\t\treturn \"provider-content-filter-error\";\n\t\tcase \"Runner.ProviderTimeoutError\":\n\t\t\treturn \"provider-timeout-error\";\n\t\tcase \"Runner.ProviderTransportError\":\n\t\t\treturn \"provider-transport-error\";\n\t\tcase \"Runner.ProviderUnavailableError\":\n\t\t\treturn \"provider-unavailable-error\";\n\t\tcase \"Runner.ProviderInvalidResponseError\":\n\t\t\treturn \"provider-invalid-response-error\";\n\t\tcase \"Runner.ProviderUnknownError\":\n\t\t\treturn \"provider-unknown-error\";\n\t}\n};\n\nconst pluginReasonHint = (\n\treason:\n\t\t| Plugin.SourceError[\"reason\"]\n\t\t| Plugin.InstallError[\"reason\"]\n\t\t| Plugin.StoreError[\"reason\"]\n\t\t| Plugin.LoadError[\"reason\"],\n): string => {\n\tswitch (reason) {\n\t\tcase \"plugin-unsupported-source\":\n\t\t\treturn \"a path entry starts with `./`, `../`, `~/` or `/`; anything else is a package or a git spec, and a remote tarball is not supported\";\n\t\tcase \"plugin-not-found\":\n\t\t\treturn \"the path does not exist; check the spelling, remembering it anchors to the settings file that declares it\";\n\t\tcase \"plugin-escapes-root\":\n\t\t\treturn \"a plugin path must stay inside the project it is declared in\";\n\t\tcase \"plugin-resolve-failed\":\n\t\t\treturn \"check that the registry or git remote is reachable, and that your credentials are current\";\n\t\tcase \"plugin-fetch-failed\":\n\t\t\treturn \"check the package name and version, and that the registry is reachable\";\n\t\tcase \"plugin-no-commit\":\n\t\t\treturn \"the git source installed but no commit could be recovered; name a branch, tag or commit explicitly\";\n\t\tcase \"plugin-no-entrypoint\":\n\t\t\treturn \"the package installed but exports no module to import; check its `exports` and `main`\";\n\t\tcase \"plugin-not-installed\":\n\t\t\treturn \"run `codework plugin install` to fetch what the settings files name\";\n\t\tcase \"plugin-lock-timeout\":\n\t\t\treturn \"another install is holding this entry; wait for it to finish, or remove the stale `.lock` directory\";\n\t\tcase \"plugin-marker-invalid\":\n\t\tcase \"plugin-index-invalid\":\n\t\t\treturn \"the store entry is damaged; remove it and install again\";\n\t\tcase \"plugin-collect-failed\":\n\t\t\treturn \"the store could not be tidied; check the permissions on the plugin cache\";\n\t\tcase \"plugin-import-failed\":\n\t\t\treturn \"the module failed to load; import it directly to see its own error\";\n\t\tcase \"plugin-missing-dependency\":\n\t\t\treturn \"the plugin's own dependencies are missing; install them where the plugin lives\";\n\t\tcase \"plugin-not-compiled\":\n\t\t\treturn \"a plugin installed from git or npm must ship compiled javascript; build it and commit or publish the output\";\n\t\tcase \"plugin-invalid-definition\":\n\t\t\treturn \"a plugin module must default-export one object with a `setup` and a `vendor.domain.name` id\";\n\t}\n};\n\nconst settingsHint = (reason: Settings.SettingsError[\"reason\"]): string => {\n\tswitch (reason) {\n\t\tcase \"read\":\n\t\t\treturn \"the file exists but could not be read; check that it is a file and readable\";\n\t\tcase \"write\":\n\t\t\treturn \"the file could not be written; check that its directory is writable\";\n\t\tcase \"parse\":\n\t\t\treturn \"the file is not valid JSON; the location above is where parsing stopped\";\n\t\tcase \"decode\":\n\t\t\treturn \"the key above holds a value this setting does not accept\";\n\t}\n};\n\n/** Render typed SDK errors for humans without exposing Effect causes or provider payloads. */\nexport const renderError = (error: unknown): string => {\n\tif (isSandboxDriverNotRegisteredError(error)) {\n\t\treturn `error: sandbox driver \"${error.driver}\" is not registered (available: ${error.registered?.join(\", \") ?? \"none\"})\\n`;\n\t}\n\tif (isSandboxDriverRegistrationError(error)) {\n\t\treturn `error: ${error.reason}\\n`;\n\t}\n\tif (isInvalidInputError(error)) {\n\t\treturn `error: ${error.message}\\n`;\n\t}\n\tif (isDatabaseOutdatedError(error)) {\n\t\treturn `error[database-outdated]: ${error.message}\\n`;\n\t}\n\tif (isOAuthError(error)) {\n\t\treturn (\n\t\t\t[\n\t\t\t\t`error[oauth-credential-error]: ${error.message}`,\n\t\t\t\t...(error.cause === undefined ? [] : [`detail: ${unknownMessage(error.cause)}`]),\n\t\t\t].join(\"\\n\") + \"\\n\"\n\t\t);\n\t}\n\tif (isSandboxProviderError(error)) {\n\t\treturn (\n\t\t\t[\n\t\t\t\t`error: SandboxProviderError - ${error.sanitized.message}`,\n\t\t\t\t`driver: ${error.driver}`,\n\t\t\t\t`operation: ${error.operation}`,\n\t\t\t\t...(error.sanitized.code === undefined ? [] : [`code: ${error.sanitized.code}`]),\n\t\t\t\t...(error.stack === undefined ? [] : [\"traceback:\", error.stack]),\n\t\t\t].join(\"\\n\") + \"\\n\"\n\t\t);\n\t}\n\tif (isSessionNotLinkedError(error)) {\n\t\treturn (\n\t\t\t[\n\t\t\t\t`error[${error.reason}]: ${error.message}`,\n\t\t\t\t`session: ${error.sessionId}`,\n\t\t\t\t\"hint: run `codework session link <session-id>` from the directory to anchor it to\",\n\t\t\t].join(\"\\n\") + \"\\n\"\n\t\t);\n\t}\n\tif (isSettingsError(error)) {\n\t\treturn (\n\t\t\t[\n\t\t\t\t`error[settings-${error.reason}-failed]: ${error.path}`,\n\t\t\t\t`detail: ${error.detail}`,\n\t\t\t\t`hint: ${settingsHint(error.reason)}`,\n\t\t\t].join(\"\\n\") + \"\\n\"\n\t\t);\n\t}\n\t// One shape for all three plugin domains: the reason is the slug, the message is the sentence,\n\t// and the reference is the string the person recognises from their settings file.\n\tif (\n\t\tisPluginSourceError(error) ||\n\t\tisPluginInstallError(error) ||\n\t\tisPluginStoreError(error) ||\n\t\tisPluginLoadError(error)\n\t) {\n\t\treturn (\n\t\t\t[\n\t\t\t\t`error[${error.reason}]: ${error.message}`,\n\t\t\t\t...(error.reference === \"\" ? [] : [`reference: ${error.reference}`]),\n\t\t\t\t...(error.file === undefined ? [] : [`declared in: ${error.file}`]),\n\t\t\t\t...(isPluginLoadError(error) && error.id !== undefined ? [`id: ${error.id}`] : []),\n\t\t\t\t`hint: ${pluginReasonHint(error.reason)}`,\n\t\t\t].join(\"\\n\") + \"\\n\"\n\t\t);\n\t}\n\tif (isProviderError(error)) {\n\t\tconst hint = providerHint(error);\n\t\treturn (\n\t\t\t[\n\t\t\t\t`error[${providerCategory(error.reason)}]: ${error.message}`,\n\t\t\t\t`provider: ${error.provider}`,\n\t\t\t\t`model: ${error.model}`,\n\t\t\t\t...(error.reason.requestId === undefined ? [] : [`request: ${error.reason.requestId}`]),\n\t\t\t\t...(hint === undefined ? [] : [`hint: ${hint}`]),\n\t\t\t].join(\"\\n\") + \"\\n\"\n\t\t);\n\t}\n\tif (isModelCatalogError(error)) {\n\t\treturn (\n\t\t\t[`error[model-catalog-${error.reason}]: ${error.message}`, \"hint: run `codework models refresh`\"].join(\"\\n\") +\n\t\t\t\"\\n\"\n\t\t);\n\t}\n\tif (isModelCatalogRefreshError(error)) {\n\t\treturn (\n\t\t\t[`error[catalog-refresh-failed]: ${error.message}`, \"hint: check the network connection and retry\"].join(\n\t\t\t\t\"\\n\",\n\t\t\t) + \"\\n\"\n\t\t);\n\t}\n\tif (isModelNotFoundError(error)) {\n\t\treturn (\n\t\t\t[\n\t\t\t\t`error[model-not-found-error]: ${error.message}`,\n\t\t\t\t\"hint: check the provider/model IDs in models.gen.json or regenerate the catalog\",\n\t\t\t].join(\"\\n\") + \"\\n\"\n\t\t);\n\t}\n\tif (isNoModelError(error)) {\n\t\treturn (\n\t\t\t[\n\t\t\t\t`error[no-model-error]: ${error.message}`,\n\t\t\t\t\"hint: set a provider API key, run `codework auth login`, or set model.provider and model.id in settings\",\n\t\t\t].join(\"\\n\") + \"\\n\"\n\t\t);\n\t}\n\tif (isLLMStreamError(error)) {\n\t\treturn `error[llm-stream-error]: ${error.message}\\n`;\n\t}\n\t// A remote run has only the category the server published; render it the same\n\t// way a local typed error is rendered, minus the detail that stayed server-side.\n\tif (isExecutionError(error)) {\n\t\treturn (\n\t\t\t[\n\t\t\t\terror.type === \"aborted\" ? `error: ${error.message}` : `error[${error.type}]: ${error.message}`,\n\t\t\t\t...(error.status === undefined ? [] : [`status: ${error.status}`]),\n\t\t\t].join(\"\\n\") + \"\\n\"\n\t\t);\n\t}\n\treturn `error: ${unknownMessage(error)}\\n`;\n};\n\nexport const reportFailure = (error: unknown) =>\n\twriteError(renderError(error)).pipe(\n\t\tEffect.andThen(\n\t\t\tEffect.sync(() => {\n\t\t\t\tprocess.exitCode = 1;\n\t\t\t}),\n\t\t),\n\t);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAM,WAAW;;AAGjB,MAAa,aAAa,UACzB,UAAU,KAAA,IAAY,CAAC,QAAQ,IAAI,CAAC,UAAU,KAAK;;AAGpD,MAAa,WAAW,UAAkB,mBAAmB,KAAK,KAAK;;AAGvE,MAAaA,SAAO,OAAO,WAAW,UAAU,OAAO,OAAO,gCAAgB,IAAI,WAAW,EAAE,CAAC,CAAC,CAAC;;AAGlG,MAAa,WAAW,WAAmD;CAC1E,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,UAAU,GAAA,CAAI,MAAM,GAAG,CAAC,CAAC,KAAK,SAAS,KAAK,KAAK,CAAC;CAClF,OAAO,SAAS,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,SAAS,MAAM,KAAK,KAAK,MAAM,WACtF,GAAI,MAAM,WAAW,KAAA,IAAY,CAAC,IAAI,CAAC,WAAW,MAAM,QAAQ,CACjE,CAAC,CAAC,KAAK,IAAI,IAAI;CAGjB,OAAO,UAAU,eAAe,KAAK,EAAE;AACxC;AAEA,MAAa,iBAAiB,UAC7B,WAAW,YAAY,KAAK,CAAC,CAAC,CAAC,KAC9B,OAAO,QACN,OAAO,WAAW;CACjB,QAAQ,WAAW;AACpB,CAAC,CACF,CACD"}
@@ -1,7 +1,7 @@
1
- import { a as reportFailure, g as make, m as writeOut, p as writeJson, t as InvalidInputError, x as ThreadInfo } from "./error-ippxl2z7.mjs";
2
- import { i as Cmd, t as handler } from "./runtime-CtLWuLd-.mjs";
3
- import { t as connect } from "./service-CRnqz89w.mjs";
4
- import { n as threadFlag, t as sessionId } from "./ids-cNIRx0-c.mjs";
1
+ import { a as reportFailure, g as make, m as writeOut, p as writeJson, t as InvalidInputError, x as ThreadInfo } from "./error-qctchbYS.mjs";
2
+ import { i as Cmd, t as handler } from "./runtime-BC3hAvn_.mjs";
3
+ import { t as connect } from "./service-bQHXHYll.mjs";
4
+ import { n as threadFlag, t as sessionId } from "./ids-B4WUlv3c.mjs";
5
5
  import { Effect, Option, Schema } from "effect";
6
6
  //#region src/cli/cmd/handlers/thread/fork.ts
7
7
  const Forked = Schema.Struct({
@@ -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-lbhh_6QP.mjs.map
33
+ //# sourceMappingURL=fork-DyTp6gur.mjs.map