@usine/server 0.3.0 → 0.4.0

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 (226) hide show
  1. package/LICENSE +661 -21
  2. package/README.md +22 -4
  3. package/dist/backend.d.ts +3 -1
  4. package/dist/backend.d.ts.map +1 -1
  5. package/dist/backend.js +5 -1
  6. package/dist/backend.js.map +1 -1
  7. package/dist/backup.d.ts +3 -3
  8. package/dist/backup.d.ts.map +1 -1
  9. package/dist/backup.js +3 -5
  10. package/dist/backup.js.map +1 -1
  11. package/dist/cli.d.ts +58 -5
  12. package/dist/cli.d.ts.map +1 -1
  13. package/dist/cli.js +216 -17
  14. package/dist/cli.js.map +1 -1
  15. package/dist/command.d.ts +22 -0
  16. package/dist/command.d.ts.map +1 -0
  17. package/dist/command.js +51 -0
  18. package/dist/command.js.map +1 -0
  19. package/dist/detach.d.ts +83 -0
  20. package/dist/detach.d.ts.map +1 -0
  21. package/dist/detach.js +320 -0
  22. package/dist/detach.js.map +1 -0
  23. package/dist/failure-message.d.ts +7 -1
  24. package/dist/failure-message.d.ts.map +1 -1
  25. package/dist/failure-message.js +71 -2
  26. package/dist/failure-message.js.map +1 -1
  27. package/dist/http.d.ts +14 -5
  28. package/dist/http.d.ts.map +1 -1
  29. package/dist/http.js +25 -13
  30. package/dist/http.js.map +1 -1
  31. package/dist/instance/environment.d.ts +17 -0
  32. package/dist/instance/environment.d.ts.map +1 -0
  33. package/dist/instance/environment.js +51 -0
  34. package/dist/instance/environment.js.map +1 -0
  35. package/dist/instance/id.d.ts +17 -0
  36. package/dist/instance/id.d.ts.map +1 -0
  37. package/dist/instance/id.js +35 -0
  38. package/dist/instance/id.js.map +1 -0
  39. package/dist/{instance-lock.d.ts → instance/lock.d.ts} +9 -5
  40. package/dist/instance/lock.d.ts.map +1 -0
  41. package/dist/instance/lock.js +127 -0
  42. package/dist/instance/lock.js.map +1 -0
  43. package/dist/instance/manifest.d.ts +52 -0
  44. package/dist/instance/manifest.d.ts.map +1 -0
  45. package/dist/instance/manifest.js +131 -0
  46. package/dist/instance/manifest.js.map +1 -0
  47. package/dist/instance/operator-api.d.ts +30 -0
  48. package/dist/instance/operator-api.d.ts.map +1 -0
  49. package/dist/instance/operator-api.js +47 -0
  50. package/dist/instance/operator-api.js.map +1 -0
  51. package/dist/instance/ports.d.ts +23 -0
  52. package/dist/instance/ports.d.ts.map +1 -0
  53. package/dist/instance/ports.js +81 -0
  54. package/dist/instance/ports.js.map +1 -0
  55. package/dist/instance/record.d.ts +82 -0
  56. package/dist/instance/record.d.ts.map +1 -0
  57. package/dist/instance/record.js +116 -0
  58. package/dist/instance/record.js.map +1 -0
  59. package/dist/instance/state.d.ts +45 -0
  60. package/dist/instance/state.d.ts.map +1 -0
  61. package/dist/instance/state.js +79 -0
  62. package/dist/instance/state.js.map +1 -0
  63. package/dist/instance/systemd.d.ts +36 -0
  64. package/dist/instance/systemd.d.ts.map +1 -0
  65. package/dist/instance/systemd.js +61 -0
  66. package/dist/instance/systemd.js.map +1 -0
  67. package/dist/logger.d.ts +3 -0
  68. package/dist/logger.d.ts.map +1 -0
  69. package/dist/logger.js +27 -0
  70. package/dist/logger.js.map +1 -0
  71. package/dist/main.js +35 -9
  72. package/dist/main.js.map +1 -1
  73. package/dist/registry.d.ts +20 -0
  74. package/dist/registry.d.ts.map +1 -0
  75. package/dist/registry.js +37 -0
  76. package/dist/registry.js.map +1 -0
  77. package/dist/restart.d.ts +19 -0
  78. package/dist/restart.d.ts.map +1 -0
  79. package/dist/restart.js +105 -0
  80. package/dist/restart.js.map +1 -0
  81. package/dist/status.d.ts +12 -0
  82. package/dist/status.d.ts.map +1 -0
  83. package/dist/status.js +99 -0
  84. package/dist/status.js.map +1 -0
  85. package/dist/stop.d.ts +81 -0
  86. package/dist/stop.d.ts.map +1 -0
  87. package/dist/stop.js +195 -0
  88. package/dist/stop.js.map +1 -0
  89. package/dist/system-sleep.d.ts +9 -0
  90. package/dist/system-sleep.d.ts.map +1 -0
  91. package/dist/system-sleep.js +42 -0
  92. package/dist/system-sleep.js.map +1 -0
  93. package/dist/tracing.d.ts +22 -0
  94. package/dist/tracing.d.ts.map +1 -0
  95. package/dist/tracing.js +61 -0
  96. package/dist/tracing.js.map +1 -0
  97. package/dist/up.d.ts +2 -2
  98. package/dist/up.d.ts.map +1 -1
  99. package/dist/up.js +41 -16
  100. package/dist/up.js.map +1 -1
  101. package/dist/upgrade.d.ts +58 -0
  102. package/dist/upgrade.d.ts.map +1 -0
  103. package/dist/upgrade.js +237 -0
  104. package/dist/upgrade.js.map +1 -0
  105. package/dist/web/assets/CompositeItem-DU6IyNMY.js +1 -0
  106. package/dist/web/assets/ToolbarRootContext-Cytu6o2e.js +1 -0
  107. package/dist/web/assets/X.es-B7iqdxa_.js +1 -0
  108. package/dist/web/assets/_agent-BVKD5odk.js +1 -0
  109. package/dist/web/assets/_loop-BFLzamuo.js +1 -0
  110. package/dist/web/assets/_name-Bh4AQ9sR.js +6 -0
  111. package/dist/web/assets/_name-CMVsmWzq.js +1 -0
  112. package/dist/web/assets/_name-DCkgEma_.js +1 -0
  113. package/dist/web/assets/_name-Ds_pWi15.js +1 -0
  114. package/dist/web/assets/_number-B9aYwvcQ.js +1 -0
  115. package/dist/web/assets/_run-BZWt47QS.js +8 -0
  116. package/dist/web/assets/_worker-Dgfufm5p.js +1 -0
  117. package/dist/web/assets/action-rCd1FeAz.js +1 -0
  118. package/dist/web/assets/agents-Drbg6qpH.js +1 -0
  119. package/dist/web/assets/agents-_6-dEjrY.js +1 -0
  120. package/dist/web/assets/button-DVWXde__.js +1 -0
  121. package/dist/web/assets/collapsible-IOhZV1qg.js +1 -0
  122. package/dist/web/assets/{core-BUmsKffF.js → core-wi-Hu_JV.js} +1 -1
  123. package/dist/web/assets/drawer-BiqnR_8i.js +1 -0
  124. package/dist/web/assets/dropdown-menu-C9D1kRkO.js +1 -0
  125. package/dist/web/assets/edit-and-retry-BgOR6mvP.js +1 -0
  126. package/dist/web/assets/error-alert-9tKpTE3v.js +1 -0
  127. package/dist/web/assets/file-error-SjG2jLJ9.js +1 -0
  128. package/dist/web/assets/fill-cell-ClM88KFD.js +1 -0
  129. package/dist/web/assets/heading-lX1a1LNN.js +1 -0
  130. package/dist/web/assets/index-BymNZU1Q.js +10 -0
  131. package/dist/web/assets/index-Dyjfp3ET.css +2 -0
  132. package/dist/web/assets/label-badge-aIGT1Bry.js +1 -0
  133. package/dist/web/assets/list-v8WJp2Eq.js +1 -0
  134. package/dist/web/assets/loops-BFoFf_og.js +1 -0
  135. package/dist/web/assets/mark-CC3RwMy_.js +1 -0
  136. package/dist/web/assets/{markdown-D07-JkYB.js → markdown-BnyfnuCL.js} +4 -4
  137. package/dist/web/assets/matchContext-BquevSJS.js +2 -0
  138. package/dist/web/assets/model-BerBT6R0.js +1 -0
  139. package/dist/web/assets/moves-Dg9sshX5.js +1 -0
  140. package/dist/web/assets/overview-C_tFKGZ8.js +1 -0
  141. package/dist/web/assets/page-DWnGi6wA.js +301 -0
  142. package/dist/web/assets/project-not-found-CodaBVdu.js +1 -0
  143. package/dist/web/assets/pull-request-marks-DE00nqGW.js +1 -0
  144. package/dist/web/assets/queries-B1SHA_r4.js +1 -0
  145. package/dist/web/assets/reload-Dsl0zjJ7.js +1 -0
  146. package/dist/web/assets/repositories-BdxmD192.js +1 -0
  147. package/dist/web/assets/repositories-D4wYJfa_.js +1 -0
  148. package/dist/web/assets/route-B_gphTYG.js +1 -0
  149. package/dist/web/assets/route-Cc7dKnn5.js +1 -0
  150. package/dist/web/assets/routes-BLy5TGH_.js +65 -0
  151. package/dist/web/assets/run-again-BTKagSXR.js +1 -0
  152. package/dist/web/assets/section-B3pWIIBa.js +1 -0
  153. package/dist/web/assets/section-CD-MB5r3.js +1 -0
  154. package/dist/web/assets/section-Id99HktI.js +1 -0
  155. package/dist/web/assets/settings-YrDysQXW.js +1 -0
  156. package/dist/web/assets/slots-BraHmbNr.js +1 -0
  157. package/dist/web/assets/status-badge-DnvNo1tG.js +1 -0
  158. package/dist/web/assets/strings-CW2XaR5f.js +1 -0
  159. package/dist/web/assets/table-BjyI4fVI.js +1 -0
  160. package/dist/web/assets/tasks-DCL8kLmD.js +1 -0
  161. package/dist/web/assets/transcript-sxRJzx6t.js +5 -0
  162. package/dist/web/assets/usage-CLQJdX9-.js +1 -0
  163. package/dist/web/assets/use-now-0P8TUXeg.js +1 -0
  164. package/dist/web/assets/useAnchoredPopupScrollLock-CQ83Wy-r.js +1 -0
  165. package/dist/web/assets/useNavigate-BW1WdocJ.js +1 -0
  166. package/dist/web/assets/usePositioner-rNCxnHO-.js +1 -0
  167. package/dist/web/assets/useTimeout-_TcdZXP6.js +1 -0
  168. package/dist/web/assets/with-selector-DoElmmtd.js +1 -0
  169. package/dist/web/assets/workers-BH5CBOR3.js +1 -0
  170. package/dist/web/index.html +15 -12
  171. package/package.json +16 -15
  172. package/dist/instance-lock.d.ts.map +0 -1
  173. package/dist/instance-lock.js +0 -58
  174. package/dist/instance-lock.js.map +0 -1
  175. package/dist/web/assets/DialogTitle-DrHlwOSg.js +0 -1
  176. package/dist/web/assets/_agent-cBqm12lE.js +0 -1
  177. package/dist/web/assets/_loop-kf1h3qkS.js +0 -1
  178. package/dist/web/assets/_name-CKWcxUh0.js +0 -2
  179. package/dist/web/assets/_name-DCEDRHnF.js +0 -1
  180. package/dist/web/assets/_name-sJkGyn7O.js +0 -1
  181. package/dist/web/assets/_number-DbgcVg1N.js +0 -1
  182. package/dist/web/assets/_run-DqslP0y6.js +0 -8
  183. package/dist/web/assets/_worker-CH4UoJT_.js +0 -1
  184. package/dist/web/assets/action-DYT048Jm.js +0 -1
  185. package/dist/web/assets/agents-DIZolb0U.js +0 -1
  186. package/dist/web/assets/agents-DMhSMb9O.js +0 -1
  187. package/dist/web/assets/button-C4yvcSko.js +0 -2
  188. package/dist/web/assets/copy-BM1l6IGB.js +0 -1
  189. package/dist/web/assets/error-alert-BrI00JbQ.js +0 -1
  190. package/dist/web/assets/file-error-C--_cWuj.js +0 -1
  191. package/dist/web/assets/index-BljdfRBm.js +0 -10
  192. package/dist/web/assets/index-YKcAk3No.css +0 -2
  193. package/dist/web/assets/item-rBBCTV8x.js +0 -1
  194. package/dist/web/assets/label-badge-ohqvZnY7.js +0 -1
  195. package/dist/web/assets/loops-CXM3f90o.js +0 -1
  196. package/dist/web/assets/loops-DWLXyUPN.js +0 -1
  197. package/dist/web/assets/moves-RiWgdCxQ.js +0 -5
  198. package/dist/web/assets/operator-copy-DsM7LJx6.js +0 -301
  199. package/dist/web/assets/outcome-YiIf6xbJ.js +0 -5
  200. package/dist/web/assets/project-not-found-CQVclgb0.js +0 -1
  201. package/dist/web/assets/query-DWN8IHdt.js +0 -1
  202. package/dist/web/assets/repositories-CoTEmYmS.js +0 -1
  203. package/dist/web/assets/repositories-Cq7zGzNb.js +0 -1
  204. package/dist/web/assets/rolldown-runtime-XKyaHtl9.js +0 -1
  205. package/dist/web/assets/route-CE9U74a9.js +0 -1
  206. package/dist/web/assets/route-DNH2EwHP.js +0 -1
  207. package/dist/web/assets/routes-XAUJJqfj.js +0 -1
  208. package/dist/web/assets/run-again-DxjFCuNu.js +0 -1
  209. package/dist/web/assets/run-drawer-CyjxH5mf.js +0 -1
  210. package/dist/web/assets/section-BBnBOk-U.js +0 -1
  211. package/dist/web/assets/section-Cm-j3zHs.js +0 -1
  212. package/dist/web/assets/section-DkBCDv4D.js +0 -1
  213. package/dist/web/assets/settings-iZf872O5.js +0 -1
  214. package/dist/web/assets/status-badge-CNlyvwWL.js +0 -1
  215. package/dist/web/assets/table-B6NH8hTW.js +0 -1
  216. package/dist/web/assets/tasks-DhLW-1gg.js +0 -1
  217. package/dist/web/assets/usage-DPUTTLGs.js +0 -1
  218. package/dist/web/assets/use-now-CcFZyFvf.js +0 -1
  219. package/dist/web/assets/useNavigate-lXd3v3E0.js +0 -1
  220. package/dist/web/assets/usePositioner-WErrA3Ah.js +0 -1
  221. package/dist/web/assets/useScrollLock-BOb01sL8.js +0 -1
  222. package/dist/web/assets/useTriggerFocusGuards-B0FItfLc.js +0 -1
  223. package/dist/web/assets/utils-BEQKLGgi.js +0 -1
  224. package/dist/web/assets/with-selector-NsM_5qXG.js +0 -1
  225. package/dist/web/assets/workers-BgocBXT9.js +0 -1
  226. package/dist/web/assets/workers-Dw2uHY0Y.js +0 -1
package/README.md CHANGED
@@ -8,15 +8,31 @@ Run it from an instance folder:
8
8
  usine up
9
9
  ```
10
10
 
11
- It prints `http://127.0.0.1:7331` and stays attached to the terminal. `--port <port>` or `USINE_PORT` changes the port; if the port is taken, the CLI names the conflict and suggests the override. `usine --version` prints the `@usine/server` version that the instance pins.
11
+ It prints `http://127.0.0.1:7331` and stays attached to the terminal. Every command reads `.env` in the instance folder for the variables that the environment doesn't set, as dotenv does, so keep tokens there to run the commands from any shell. `--port <port>` or `USINE_PORT` changes the port; if the port is taken, the CLI names the conflict and suggests the override. `--origin <url>` or `USINE_ORIGIN` names the URL at which a proxy, such as `tailscale serve`, publishes the UI; the operator API then accepts browser requests from pages there too. `--log-level <level>` or `USINE_LOG_LEVEL` sets the lowest level it logs, `info` by default; `debug` adds the lines that say why something was skipped. Each log line starts with its date and time in UTC. `usine --version` prints the `@usine/server` version that the instance pins. On macOS, `usine up` warns if the Mac can sleep, which drops the SSH connections to workers: run `caffeinate -s` while runs are open, or turn off sleep on AC power with `sudo pmset -c sleep 0`.
12
12
 
13
- One `usine up` runs per instance folder. It holds `.usine/instance.lock` from startup until every store closes, and writes its pid to `.usine/instance.pid`. A second `usine up` there names the running process and exits nonzero before opening a store. A draining process keeps the folder until it exits.
13
+ One `usine up` runs per instance folder. It holds `.usine/instance.lock` from startup until every store closes, writes its pid to `.usine/instance.pid`, and writes its pid, port, version, start time, and command line to `.usine/instance.json`. It removes both files when it exits. It reads the instance ID from `.usine/instance-id`, and writes a new UUID there at its first start; the ID labels its attempt containers on SSH workers, so that another instance with the same GitHub App doesn't remove them. A second `usine up` there names the running process and exits nonzero before opening a store. A draining process keeps the folder until it exits.
14
+
15
+ ## Manage the instance
16
+
17
+ ```sh
18
+ usine up --detach # start in the background, with the output in .usine/usine.log
19
+ usine status # running or not, pid, address, version, uptime, open runs; exit 3 if stopped
20
+ usine stop # send SIGTERM and wait for the drain; --force ends the drain
21
+ usine restart # stop, then start the recorded command line in the background
22
+ usine upgrade # back up, move the @usine/server pin, install, commit, and restart
23
+ ```
24
+
25
+ `stop`, `restart`, and `upgrade` wait `--timeout` seconds (120 by default) for each stop. With `--force`, they send `SIGKILL` to a process that still runs after the timeout. Each start, including `usine up --detach`, waits until the new process listens, which it does after startup recovery, and gives up only when the process writes no line to `.usine/usine.log` for that long. Without a readable `.usine/instance.json`, `restart` checks the pid in `.usine/instance.pid` on the port where it answers, stops it, and starts `usine up` as `usine up --detach` without flags would. `restart` and `upgrade` refuse while a run has a running attempt, unless `--force`, and when neither the shell nor `.env` sets a gateway's admin token variable, because the new process inherits the shell's environment and reads `.env`. `upgrade` applies to an instance that installs `@usine/server` from its own `package.json` pin; for a checkout, pull and build it, then run `usine restart`.
26
+
27
+ `usine up` records the systemd service whose cgroup it runs in, such as `usine.service`. If systemd reports the process as that service's main process, `stop`, `restart`, and `upgrade` stop it with `systemctl stop --no-block` and start it with `systemctl start`, so that systemd keeps managing it, and `status` names the service. A start whose service fails or waits to restart is stopped, so that it doesn't repeat.
14
28
 
15
29
  Without GitHub App credentials, it logs the typed error, leaves both trigger streams idle, and opens the setup screen in the default browser. The browser command times out after two seconds; a failed opener only logs a warning. Runs, transcripts, and loop pause state stay readable, and the instance folder can be reloaded, but interventions are unavailable. Supply `USINE_GITHUB_APP_ID` and `USINE_GITHUB_PRIVATE_KEY`, or `app_id` and `private_key` in a mode-0600 `.usine/github-app.json`. Credentials are read only at startup, so restart `usine up` after adding them, as the setup screen says.
16
30
 
17
31
  ## Web UI
18
32
 
19
- Each project opens as a board of authored or proposed lanes; proposed lanes are read-only. To enable moves, define `repos[].lanes` in `usine.yaml` and reload (see the [lane example](../../packages/config/README.md)). Moving an item to an authored label-backed lane swaps only the labels in that map and keeps other labels; polling then evaluates label-driven loops. Cards show the latest run and open its drawer. The UI can approve, retry, or cancel a run, pause or unpause a loop, page back through older transcript rows, and tail parent and first-level child activity.
33
+ Each project opens as a board of authored or proposed lanes; proposed lanes are read-only. To enable moves, define `repos[].lanes` in `usine.yaml` and reload (see the [lane example](../../packages/config/README.md)). Moving an item to an authored label-backed lane swaps only the labels in that map and keeps other labels; polling then evaluates label-driven loops. Cards show the latest run and open its drawer. Retry controls describe the saved harness and model. The drawer flags a changed agent definition, and **Edit and retry** uses the current loaded definition even with the same task and agent name. `POST /api/runs/:id/cancel` returns 409 for failed and succeeded runs and preserves their outcomes; repeating it on a canceled run succeeds.
34
+
35
+ The UI can approve, retry, or cancel a run, pause or unpause a loop, page back through older transcript rows, and tail parent and first-level child activity.
20
36
 
21
37
  Run conversations remember the reader's filter, opened disclosures, and reading position across drawer reopens and page refreshes. Bookmarks are per run and browser origin, and unread activity stays pending while a saved position is restored. See [Returning to a conversation](../web/README.md#returning-to-a-conversation) for retention and history-recovery limits. Adjacent completed tools are summarized by their recorded actions, such as files read or changed and recognized test or build commands; expand a group to see each tool and result.
22
38
 
@@ -67,6 +83,8 @@ The versioned JSON has `exportedAt`, the full run `snapshot` (event, effective t
67
83
 
68
84
  ## Stop the server
69
85
 
70
- Press Ctrl+C or send `SIGTERM` once to stop polling and drain admitted attempts. The server waits up to `max_attempt_minutes` from the request, or indefinitely if unset; a second signal stops the wait. Queued runs and automatic retries stay saved, and an attempt cut off by the deadline uses normal restart recovery. Start the next `usine up` after the process exits.
86
+ Run `usine stop`, press Ctrl+C, or send `SIGTERM` once to stop polling and drain admitted attempts. The server waits up to `max_attempt_minutes` from the request, or indefinitely if unset; a second signal, or `usine stop --force`, stops the wait, and `usine stop --force` sends `SIGKILL` if the process still runs after `--timeout`. Queued runs and automatic retries stay saved, and an attempt cut off by the deadline uses normal restart recovery. Start the next `usine up` after the process exits; `usine stop` returns when it has.
71
87
 
72
88
  To clear a handled failure, select **Mark resolved** in the run drawer, opened from Needs attention or run history. Resolution survives restarts and keeps the failed outcome, transcript, and retry. A later failed attempt asks for attention again. After a question the button reads **Mark answered**; after a question or blocker, the loop then acts on the item's newest state.
89
+
90
+ Failure resolution through `POST /api/runs/:runId/resolve-failure` records the current instance's operator login and resolution time. The next `GET /api/statistics/runs` reflects the resolution, including when the previous response was cached.
package/dist/backend.d.ts CHANGED
@@ -6,7 +6,7 @@ import { AgentName } from "@usine/core/agent";
6
6
  import type { RunAgainResult } from "@usine/engine/engine";
7
7
  import type { CurrentInstance, InstanceReload, InstanceReloadError } from "@usine/orchestrator/current-instance";
8
8
  import type { WorkerName } from "@usine/core/worker";
9
- import { type BoardMove, type ConfigurationView, type DeskView, type FactoryOverview, type RunDetailView, type RunGitHubChangesView, type TranscriptRequest, type Operator, type OperatorConfiguration, type OperatorError, type OperatorObservation, type EditAndRetry, type SessionIntervention, type TaskView } from "@usine/orchestrator/operator";
9
+ import { type BoardMove, type ConfigurationView, type DeskView, type FactoryOverview, type RunDetailView, type RunGitHubChangesView, type TranscriptRequest, type Operator, type OperatorConfiguration, type OperatorError, type OperatorObservation, type EditAndRetry, type SessionIntervention, type RunStatisticsView, type StatisticsView, type StatisticsWindow, type TaskView } from "@usine/orchestrator/operator";
10
10
  import type { ItemNumber } from "@usine/core/item";
11
11
  import type { RepositoryName } from "@usine/core/repository";
12
12
  import { Context, Effect, Layer, Schema } from "effect";
@@ -37,6 +37,8 @@ declare const FactoryBackend_base: Context.ServiceClass<FactoryBackend, "@usine/
37
37
  readonly task: (repository: RepositoryName, item: ItemNumber) => Effect.Effect<TaskView, BackendError>;
38
38
  readonly configuration: Effect.Effect<ConfigurationView, BackendError>;
39
39
  readonly desk: Effect.Effect<DeskView, BackendError>;
40
+ readonly statistics: (window: StatisticsWindow) => Effect.Effect<StatisticsView, BackendError>;
41
+ readonly runStatistics: (window: StatisticsWindow) => Effect.Effect<RunStatisticsView, BackendError>;
40
42
  }>;
41
43
  export declare class FactoryBackend extends FactoryBackend_base {
42
44
  }
@@ -1 +1 @@
1
- {"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../src/backend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,mBAAmB,EACpB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EACL,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,QAAQ,EACb,KAAK,eAAe,EAEpB,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,QAAQ,EACb,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,QAAQ,EACd,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;;;;AAExD,qBAAa,uBAAwB,SAAQ,4BAI3C;CAAG;AAEL,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,uBAAuB,GAAG,mBAAmB,CAAC;;uBAKlE,MAAM,CAAC,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EAAE,YAAY,CAAC;mBAE7C,CACb,UAAU,EAAE,cAAc,EAC1B,IAAI,EAAE,UAAU,KACb,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,YAAY,CAAC;4BAClB,MAAM,CAAC,MAAM,CAAC,iBAAiB,EAAE,YAAY,CAAC;mBACvD,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,YAAY,CAAC;yBAC/B,CAAC,MAAM,EAAE,gBAAgB,KAAK,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,YAAY,CAAC;4BACtE,CACtB,MAAM,EAAE,gBAAgB,KACrB,MAAM,CAAC,MAAM,CAAC,iBAAiB,EAAE,YAAY,CAAC;;AA1CvD,qBAAa,cAAe,SAAQ,mBA4CD;CAAG;AAEtC,KAAK,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC,CAAC;AAK1E,mGAAmG;AACnG,eAAO,MAAM,gBAAgB,cAChB,eAAe,YAChB,QAAQ,CAAC,SAAS,CAAC,iBACd,qBAAqB,CAAC,SAAS,CAAC,KAC9C,KAAK,CAAC,KAAK,CAAC,cAAc,CAqCzB,CAAC;AAEL;;;GAGG;AACH,eAAO,MAAM,sBAAsB,cACtB,eAAe,YAChB,MAAM,eACH,mBAAmB,CAAC,SAAS,CAAC,iBAC5B,qBAAqB,CAAC,SAAS,CAAC,KAC9C,KAAK,CAAC,KAAK,CAAC,cAAc,CAwC5B,CAAC"}
package/dist/backend.js CHANGED
@@ -20,7 +20,7 @@ export const liveBackendLayer = (instances, operator, configuration) => Layer.su
20
20
  approve: (runId) => Effect.flatMap(instances.get, (instance) => operator.approve(instance, runId)),
21
21
  resetCycleBudget: operator.resetCycleBudget,
22
22
  retry: (runId) => Effect.flatMap(instances.get, (instance) => operator.retry(instance, runId)),
23
- resolveFailure: operator.resolveFailure,
23
+ resolveFailure: (runId, attemptId) => Effect.flatMap(instances.get, (instance) => operator.resolveFailure(instance, runId, attemptId)),
24
24
  agents: rosterOf(instances),
25
25
  editAndRetry: (runId, edit) => Effect.flatMap(instances.get, (instance) => operator.editAndRetry(instance, runId, edit)),
26
26
  runAgain: (runId, edit) => Effect.flatMap(instances.get, (instance) => operator.runAgain(instance, runId, edit)),
@@ -34,6 +34,8 @@ export const liveBackendLayer = (instances, operator, configuration) => Layer.su
34
34
  task: (repository, item) => Effect.flatMap(instances.get, (instance) => operator.task(instance, repository, item)),
35
35
  configuration: Effect.flatMap(instances.get, configuration.view),
36
36
  desk: Effect.flatMap(instances.get, operator.desk),
37
+ statistics: (window) => Effect.flatMap(instances.get, (instance) => operator.statistics(instance, window)),
38
+ runStatistics: (window) => Effect.flatMap(instances.get, (instance) => operator.runStatistics(instance, window)),
37
39
  });
38
40
  /**
39
41
  * Provides the setup-mode backend, where only the overview, configuration, and reload work. Other
@@ -66,6 +68,8 @@ export const needsSetupBackendLayer = (instances, errorTag, observation, configu
66
68
  task: (repository, item) => Effect.flatMap(instances.get, (instance) => observation.task(instance, repository, item)),
67
69
  configuration: Effect.flatMap(instances.get, configuration.view),
68
70
  desk: Effect.flatMap(instances.get, observation.desk),
71
+ statistics: (window) => Effect.flatMap(instances.get, (instance) => observation.statistics(instance, window)),
72
+ runStatistics: (window) => Effect.flatMap(instances.get, (instance) => observation.runStatistics(instance, window)),
69
73
  });
70
74
  };
71
75
  //# sourceMappingURL=backend.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"backend.js","sourceRoot":"","sources":["../src/backend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAQ9C,OAAO,EAKL,kBAAkB,GAWn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time database to `output` and the durable storage next to it, durable storage
4
- * first. If the runtime copy fails, removes the durable copy.
3
+ * Copies the instance's runtime database to `output` and its durable storage next to it, durable
4
+ * storage first. If the runtime copy fails, removes the durable copy.
5
5
  */
6
- export declare const backup: (output: string) => Effect.Effect<void, import("@usine/durable/backup").DurableStorageBackupError | import("@usine/engine/local-sqlite").RuntimeStoreBackupError, FileSystem.FileSystem | Path.Path>;
6
+ export declare const backup: (directory: string & import("effect/Brand").Brand<"InstanceDirectory">, output: string) => Effect.Effect<void, import("@usine/durable/backup").DurableStorageBackupError | import("@usine/engine/local-sqlite").RuntimeStoreBackupError, FileSystem.FileSystem | Path.Path>;
7
7
  //# sourceMappingURL=backup.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"backup.d.ts","sourceRoot":"","sources":["../src/backup.ts"],"names":[],"mappings":"AAGA,OAAO,EAAW,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAQ3D;;;GAGG;AACH,eAAO,MAAM,MAAM,sMA6BjB,CAAC"}
1
+ {"version":3,"file":"backup.d.ts","sourceRoot":"","sources":["../src/backup.ts"],"names":[],"mappings":"AAGA,OAAO,EAAW,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAQ3D;;;GAGG;AACH,eAAO,MAAM,MAAM,6QA+BjB,CAAC"}
package/dist/backup.js CHANGED
@@ -1,4 +1,3 @@
1
- import { InstanceDirectory } from "@usine/core/instance";
2
1
  import { backup as backupDurableStorage } from "@usine/durable/backup";
3
2
  import { backup as backupDatabase } from "@usine/engine/local-sqlite";
4
3
  import { Console, Effect, FileSystem, Path } from "effect";
@@ -8,11 +7,10 @@ const durableDestination = (path, destination) => {
8
7
  return path.join(dir, `${name}.durable${ext === "" ? ".sqlite" : ext}`);
9
8
  };
10
9
  /**
11
- * Copies the runtime database to `output` and the durable storage next to it, durable storage
12
- * first. If the runtime copy fails, removes the durable copy.
10
+ * Copies the instance's runtime database to `output` and its durable storage next to it, durable
11
+ * storage first. If the runtime copy fails, removes the durable copy.
13
12
  */
14
- export const backup = Effect.fn("Cli.backup")(function* (output) {
15
- const directory = InstanceDirectory.make(process.cwd());
13
+ export const backup = Effect.fn("Cli.backup")(function* (directory, output) {
16
14
  const fileSystem = yield* FileSystem.FileSystem;
17
15
  const path = yield* Path.Path;
18
16
  const destination = path.resolve(output);
@@ -1 +1 @@
1
- {"version":3,"file":"backup.js","sourceRoot":"","sources":["../src/backup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,MAAM,IAAI,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE3D,8FAA8F;AAC9F,MAAM,kBAAkB,GAAG,CAAC,IAAe,EAAE,WAAmB,EAAU,EAAE;IAC1E,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IACnD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,WAAW,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;AAC1E,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC,EAAE,MAAc;IACrE,MAAM,SAAS,GAAG,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACxD,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC;IAChD,MAAM,IAAI,GAAG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,CAAC,OAAO,CAAC,CAAC,IAAI,CAC7B,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CACxB,MAAM,CAAC,UAAU,CAAC,sDAAsD,EAAE;YACxE,OAAO;YACP,OAAO,EAAE,KAAK,CAAC,OAAO;SACvB,CAAC,CACH,EACD,MAAM,CAAC,MAAM,CACd;QACH,CAAC,CAAC,MAAM,CAAC,IAAI,CAChB,CACF,CAAC;IACF,KAAK,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,kCAAkC,WAAW,EAAE,CAAC,CAAC;IACpE,KAAK,CAAC,CAAC,OAAO,CAAC,GAAG,CAChB,MAAM;QACJ,CAAC,CAAC,oCAAoC,OAAO,EAAE;QAC/C,CAAC,CAAC,qEAAqE,CAC1E,CAAC;AACJ,CAAC,CAAC,CAAC"}
package/dist/cli.d.ts CHANGED
@@ -1,13 +1,25 @@
1
1
  import { Duration, Effect, FileSystem, Option, Schema } from "effect";
2
- import { ChildProcessSpawner } from "effect/unstable/process";
3
- import type { ServeError } from "effect/unstable/http/HttpServerError";
2
+ import { ChildProcessSpawner } from "effect/process";
3
+ import type { ServeError } from "effect/http/HttpServerError";
4
4
  export declare const DEFAULT_PORT = 7331;
5
5
  /** The address that the HTTP server listens on and the port check probes. */
6
6
  export declare const SERVER_HOST = "127.0.0.1";
7
7
  export declare const BROWSER_OPEN_TIMEOUT = "2 seconds";
8
8
  export declare const Port: Schema.brand<Schema.Int, "ServerPort">;
9
9
  export type Port = typeof Port.Type;
10
- export declare const CLI_USAGE = "Usage:\n usine up [--port <port>] [--allow-volatile-instance]\n usine backup <path>\n usine export-run <runId> [--output <path>]\n usine --help\n usine --version\n\nOptions:\n -p, --port <port> Listen on this port (default: 7331)\n --allow-volatile-instance Start even when the instance folder is in a temporary directory\n -o, --output <path> Write the run evidence to this file (default: run-<encoded-runId>.json)\n -h, --help Print this help\n -v, --version Print the installed @usine/server version\n\nEnvironment:\n USINE_PORT Listen on this port if --port is not set\n USINE_ALLOW_VOLATILE_INSTANCE Set to 1 for the same effect as --allow-volatile-instance";
10
+ /**
11
+ * The origin of the UI's pages behind a proxy, such as the HTTPS URL at which `tailscale serve`
12
+ * publishes the UI: an `http` or `https` scheme, a host, and a port other than the scheme's
13
+ * default, as a browser writes it in the `Origin` header.
14
+ */
15
+ export declare const UiOrigin: Schema.brand<Schema.String, "UiOrigin">;
16
+ export type UiOrigin = typeof UiOrigin.Type;
17
+ /** The minimum level of the lines `usine up` logs. */
18
+ export declare const UpLogLevel: Schema.Literals<readonly ["Trace", "Debug", "Info", "Warn", "Error"]>;
19
+ export type UpLogLevel = typeof UpLogLevel.Type;
20
+ export declare const DEFAULT_LOG_LEVEL: UpLogLevel;
21
+ export declare const DEFAULT_LIFECYCLE_TIMEOUT_SECONDS = 120;
22
+ export declare const CLI_USAGE = "Usage:\n usine up [--port <port>] [--origin <url>] [--log-level <level>] [--allow-volatile-instance] [--detach]\n usine status\n usine stop [--timeout <seconds>] [--force]\n usine restart [--timeout <seconds>] [--force]\n usine upgrade [<version>] [--check] [--timeout <seconds>] [--force]\n usine backup <path>\n usine export-run <runId> [--output <path>]\n usine --help\n usine --version\n\nOptions:\n -p, --port <port> Listen on this port (default: 7331)\n --origin <url> Also accept the UI's pages at this origin, such as the URL of tailscale serve\n --log-level <level> Log at this level and above: trace, debug, info, warn, or error (default: info)\n --allow-volatile-instance Start even when the instance folder is in a temporary directory\n --detach Start in the background, with the output in .usine/usine.log\n --timeout <seconds> Wait this long for the instance to stop, and for the new one to listen or log a line (default: 120)\n --force Stop without waiting for running attempts; the next start reattaches them\n --check Print the running and the latest @usine/server version, and change nothing\n -o, --output <path> Write the run evidence to this file (default: run-<encoded-runId>.json)\n -h, --help Print this help\n -v, --version Print the installed @usine/server version\n\nEnvironment:\n USINE_PORT Listen on this port if --port is not set\n USINE_ORIGIN Also accept the UI's pages at this origin if --origin is not set\n USINE_LOG_LEVEL Log at this level if --log-level is not set\n USINE_ALLOW_VOLATILE_INSTANCE Set to 1 for the same effect as --allow-volatile-instance\n\nEvery command reads .env in the instance folder for the variables that the environment doesn't set.";
11
23
  declare const CliUsageError_base: Schema.Class<CliUsageError, Schema.TaggedStruct<"CliUsageError", {
12
24
  readonly message: Schema.String;
13
25
  }>, import("effect/Cause").YieldableError>;
@@ -53,10 +65,47 @@ export declare class VersionCommand extends VersionCommand_base {
53
65
  }
54
66
  declare const UpCommand_base: Schema.Class<UpCommand, Schema.TaggedStruct<"UpCommand", {
55
67
  readonly port: Schema.brand<Schema.Int, "ServerPort">;
68
+ /** The origin of the UI's pages besides the loopback ones, which the operator API accepts. */
69
+ readonly origin: Schema.Option<Schema.brand<Schema.String, "UiOrigin">>;
70
+ readonly logLevel: Schema.Literals<readonly ["Trace", "Debug", "Info", "Warn", "Error"]>;
56
71
  readonly allowVolatileInstance: Schema.Boolean;
72
+ readonly detach: Schema.Boolean;
57
73
  }>, {}>;
58
74
  export declare class UpCommand extends UpCommand_base {
59
75
  }
76
+ declare const StatusCommand_base: Schema.Class<StatusCommand, Schema.TaggedStruct<"StatusCommand", {}>, {}>;
77
+ /** Reports whether `usine up` runs in the current instance folder. */
78
+ export declare class StatusCommand extends StatusCommand_base {
79
+ }
80
+ declare const LifecycleOptions_base: Schema.Class<LifecycleOptions, Schema.Struct<{
81
+ readonly timeout: Schema.Duration;
82
+ /** Sends a second `SIGTERM`, which stops the instance without waiting for running Attempts. */
83
+ readonly force: Schema.Boolean;
84
+ }>, {}>;
85
+ /** How long a lifecycle command waits for each stop and start, and whether it ends the drain. */
86
+ export declare class LifecycleOptions extends LifecycleOptions_base {
87
+ }
88
+ declare const StopCommand_base: Schema.Class<StopCommand, Schema.TaggedStruct<"StopCommand", {
89
+ readonly options: typeof LifecycleOptions;
90
+ }>, {}>;
91
+ /** Stops the `usine up` of the current instance folder and waits for it to exit. */
92
+ export declare class StopCommand extends StopCommand_base {
93
+ }
94
+ declare const RestartCommand_base: Schema.Class<RestartCommand, Schema.TaggedStruct<"RestartCommand", {
95
+ readonly options: typeof LifecycleOptions;
96
+ }>, {}>;
97
+ /** Stops the `usine up` of the current instance folder and starts it again in the background. */
98
+ export declare class RestartCommand extends RestartCommand_base {
99
+ }
100
+ declare const UpgradeCommand_base: Schema.Class<UpgradeCommand, Schema.TaggedStruct<"UpgradeCommand", {
101
+ /** A version or dist-tag; `latest` if absent. */
102
+ readonly version: Schema.Option<Schema.NonEmptyString>;
103
+ readonly check: Schema.Boolean;
104
+ readonly options: typeof LifecycleOptions;
105
+ }>, {}>;
106
+ /** Moves the instance's `@usine/server` pin to another published version and restarts it. */
107
+ export declare class UpgradeCommand extends UpgradeCommand_base {
108
+ }
60
109
  declare const ExportRunCommand_base: Schema.Class<ExportRunCommand, Schema.TaggedStruct<"ExportRunCommand", {
61
110
  readonly runId: Schema.brand<Schema.NonEmptyString, "RunId">;
62
111
  readonly output: Schema.Option<Schema.NonEmptyString>;
@@ -72,12 +121,16 @@ export declare class BackupCommand extends BackupCommand_base {
72
121
  }
73
122
  export interface CliEnvironment {
74
123
  readonly port: Option.Option<string>;
124
+ readonly origin: Option.Option<string>;
125
+ readonly logLevel: Option.Option<string>;
75
126
  readonly allowVolatileInstance: Option.Option<string>;
76
127
  }
77
- export declare const CliCommand: Schema.Union<readonly [typeof HelpCommand, typeof VersionCommand, typeof UpCommand, typeof ExportRunCommand, typeof BackupCommand]>;
128
+ export declare const CliCommand: Schema.Union<readonly [typeof HelpCommand, typeof VersionCommand, typeof UpCommand, typeof StatusCommand, typeof StopCommand, typeof RestartCommand, typeof UpgradeCommand, typeof ExportRunCommand, typeof BackupCommand]>;
78
129
  export type CliCommand = typeof CliCommand.Type;
130
+ /** Returns the settings of a `usine up` without flags: those of the environment, or the defaults. */
131
+ export declare const environmentUp: (environment: CliEnvironment) => Effect.Effect<UpCommand, CliUsageError, never>;
79
132
  /** Parses process arguments and the environment into one validated CLI command. */
80
- export declare const parseCli: (args: readonly string[], environment: CliEnvironment) => Effect.Effect<BackupCommand | ExportRunCommand | HelpCommand | UpCommand | VersionCommand, CliUsageError, never>;
133
+ export declare const parseCli: (args: readonly string[], environment: CliEnvironment) => Effect.Effect<BackupCommand | ExportRunCommand | HelpCommand | RestartCommand | StatusCommand | StopCommand | UpCommand | UpgradeCommand | VersionCommand, CliUsageError, never>;
81
134
  /**
82
135
  * Returns the directories the OS may clear: `os.tmpdir()`, `$TMPDIR`, and common temp locations.
83
136
  */
package/dist/cli.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAKA,OAAO,EAAyB,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC7F,OAAO,EAAgB,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AAEvE,eAAO,MAAM,YAAY,OAAQ,CAAC;AAClC,6EAA6E;AAC7E,eAAO,MAAM,WAAW,cAAc,CAAC;AACvC,eAAO,MAAM,oBAAoB,cAAc,CAAC;AAGhD,eAAO,MAAM,IAAI,wCAEiB,CAAC;AACnC,MAAM,MAAM,IAAI,GAAG,OAAO,IAAI,CAAC,IAAI,CAAC;AAIpC,eAAO,MAAM,SAAS,ovBAgBqE,CAAC;;;;AAE5F,qBAAa,aAAc,SAAQ,kBAGlC;CAAG;;;;AAEJ,qBAAa,eAAgB,SAAQ,oBAEW;CAAG;;;IAOjD,yEAAyE;;;AAL3E,qDAAqD;AACrD,qBAAa,cAAe,SAAQ,mBAMlC;CAAG;;;;;AAEL,qBAAa,gBAAiB,SAAQ,qBAEuB;CAAG;;;;;AAEhE,kGAAkG;AAClG,qBAAa,8BAA+B,SAAQ,mCAKlD;CAAG;;;;;AAEL,qBAAa,gBAAiB,SAAQ,qBAKpC;CAAG;;AAEL,qBAAa,WAAY,SAAQ,gBAGhC;CAAG;;AAEJ,qBAAa,cAAe,SAA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;AAIH,+EAA+E;AAC/E,eAAO,MAAM,gBAAgB,SAAU,IAAI,SAAS,UAAU,sCAGN,CAAC;AA6BzD,oEAAoE;AACpE,eAAO,MAAM,SAAS,8IAOpB,CAAC;AAkBH;;;GAGG;AACH,eAAO,MAAM,eAAe,qKAE1B,CAAC;AAUH,uFAAuF;AACvF,eAAO,MAAM,WAAW,4IAyBtB,CAAC"}
package/dist/cli.js CHANGED
@@ -4,7 +4,7 @@ import { resolve, sep } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import { RunId } from "@usine/core/run";
6
6
  import { Array as Arr, Console, Duration, Effect, FileSystem, Option, Schema } from "effect";
7
- import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process";
7
+ import { ChildProcess, ChildProcessSpawner } from "effect/process";
8
8
  export const DEFAULT_PORT = 7_331;
9
9
  /** The address that the HTTP server listens on and the port check probes. */
10
10
  export const SERVER_HOST = "127.0.0.1";
@@ -12,8 +12,32 @@ export const BROWSER_OPEN_TIMEOUT = "2 seconds";
12
12
  const PORT_HOLDER_TIMEOUT = "2 seconds";
13
13
  export const Port = Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 65_535 }, { message: "Expected a TCP port" })).pipe(Schema.brand("ServerPort"));
14
14
  const PortFromString = Schema.NumberFromString.pipe(Schema.decodeTo(Port));
15
+ /**
16
+ * The origin of the UI's pages behind a proxy, such as the HTTPS URL at which `tailscale serve`
17
+ * publishes the UI: an `http` or `https` scheme, a host, and a port other than the scheme's
18
+ * default, as a browser writes it in the `Origin` header.
19
+ */
20
+ export const UiOrigin = Schema.String.check(Schema.makeFilter((origin) => URL.canParse(origin) &&
21
+ ["http:", "https:"].includes(new URL(origin).protocol) &&
22
+ new URL(origin).origin === origin, { message: "Expected an http or https origin, such as https://orchestrator.example.ts.net" })).pipe(Schema.brand("UiOrigin"));
23
+ /** The minimum level of the lines `usine up` logs. */
24
+ export const UpLogLevel = Schema.Literals(["Trace", "Debug", "Info", "Warn", "Error"]);
25
+ export const DEFAULT_LOG_LEVEL = "Info";
26
+ const LogLevelName = Schema.Literals(["trace", "debug", "info", "warn", "error"]);
27
+ const LOG_LEVEL_NAMES = {
28
+ trace: "Trace",
29
+ debug: "Debug",
30
+ info: "Info",
31
+ warn: "Warn",
32
+ error: "Error",
33
+ };
34
+ export const DEFAULT_LIFECYCLE_TIMEOUT_SECONDS = 120;
15
35
  export const CLI_USAGE = `Usage:
16
- usine up [--port <port>] [--allow-volatile-instance]
36
+ usine up [--port <port>] [--origin <url>] [--log-level <level>] [--allow-volatile-instance] [--detach]
37
+ usine status
38
+ usine stop [--timeout <seconds>] [--force]
39
+ usine restart [--timeout <seconds>] [--force]
40
+ usine upgrade [<version>] [--check] [--timeout <seconds>] [--force]
17
41
  usine backup <path>
18
42
  usine export-run <runId> [--output <path>]
19
43
  usine --help
@@ -21,14 +45,24 @@ export const CLI_USAGE = `Usage:
21
45
 
22
46
  Options:
23
47
  -p, --port <port> Listen on this port (default: 7331)
48
+ --origin <url> Also accept the UI's pages at this origin, such as the URL of tailscale serve
49
+ --log-level <level> Log at this level and above: trace, debug, info, warn, or error (default: info)
24
50
  --allow-volatile-instance Start even when the instance folder is in a temporary directory
51
+ --detach Start in the background, with the output in .usine/usine.log
52
+ --timeout <seconds> Wait this long for the instance to stop, and for the new one to listen or log a line (default: ${DEFAULT_LIFECYCLE_TIMEOUT_SECONDS})
53
+ --force Stop without waiting for running attempts; the next start reattaches them
54
+ --check Print the running and the latest @usine/server version, and change nothing
25
55
  -o, --output <path> Write the run evidence to this file (default: run-<encoded-runId>.json)
26
56
  -h, --help Print this help
27
57
  -v, --version Print the installed @usine/server version
28
58
 
29
59
  Environment:
30
60
  USINE_PORT Listen on this port if --port is not set
31
- USINE_ALLOW_VOLATILE_INSTANCE Set to 1 for the same effect as --allow-volatile-instance`;
61
+ USINE_ORIGIN Also accept the UI's pages at this origin if --origin is not set
62
+ USINE_LOG_LEVEL Log at this level if --log-level is not set
63
+ USINE_ALLOW_VOLATILE_INSTANCE Set to 1 for the same effect as --allow-volatile-instance
64
+
65
+ Every command reads .env in the instance folder for the variables that the environment doesn't set.`;
32
66
  export class CliUsageError extends Schema.TaggedError("@usine/server/CliUsageError")("CliUsageError", { message: Schema.String }) {
33
67
  }
34
68
  export class CliVersionError extends Schema.TaggedError("@usine/server/CliVersionError")("CliVersionError", { cause: Schema.Defect() }) {
@@ -57,7 +91,38 @@ export class HelpCommand extends Schema.TaggedClass("@usine/server/HelpCommand")
57
91
  }
58
92
  export class VersionCommand extends Schema.TaggedClass("@usine/server/VersionCommand")("VersionCommand", {}) {
59
93
  }
60
- export class UpCommand extends Schema.TaggedClass("@usine/server/UpCommand")("UpCommand", { port: Port, allowVolatileInstance: Schema.Boolean }) {
94
+ export class UpCommand extends Schema.TaggedClass("@usine/server/UpCommand")("UpCommand", {
95
+ port: Port,
96
+ /** The origin of the UI's pages besides the loopback ones, which the operator API accepts. */
97
+ origin: Schema.Option(UiOrigin),
98
+ logLevel: UpLogLevel,
99
+ allowVolatileInstance: Schema.Boolean,
100
+ detach: Schema.Boolean,
101
+ }) {
102
+ }
103
+ /** Reports whether `usine up` runs in the current instance folder. */
104
+ export class StatusCommand extends Schema.TaggedClass("@usine/server/StatusCommand")("StatusCommand", {}) {
105
+ }
106
+ /** How long a lifecycle command waits for each stop and start, and whether it ends the drain. */
107
+ export class LifecycleOptions extends Schema.Class("@usine/server/LifecycleOptions")({
108
+ timeout: Schema.Duration,
109
+ /** Sends a second `SIGTERM`, which stops the instance without waiting for running Attempts. */
110
+ force: Schema.Boolean,
111
+ }) {
112
+ }
113
+ /** Stops the `usine up` of the current instance folder and waits for it to exit. */
114
+ export class StopCommand extends Schema.TaggedClass("@usine/server/StopCommand")("StopCommand", { options: LifecycleOptions }) {
115
+ }
116
+ /** Stops the `usine up` of the current instance folder and starts it again in the background. */
117
+ export class RestartCommand extends Schema.TaggedClass("@usine/server/RestartCommand")("RestartCommand", { options: LifecycleOptions }) {
118
+ }
119
+ /** Moves the instance's `@usine/server` pin to another published version and restarts it. */
120
+ export class UpgradeCommand extends Schema.TaggedClass("@usine/server/UpgradeCommand")("UpgradeCommand", {
121
+ /** A version or dist-tag; `latest` if absent. */
122
+ version: Schema.Option(Schema.NonEmptyString),
123
+ check: Schema.Boolean,
124
+ options: LifecycleOptions,
125
+ }) {
61
126
  }
62
127
  /** Exports one Run from the current instance into a new local JSON file. */
63
128
  export class ExportRunCommand extends Schema.TaggedClass("@usine/server/ExportRunCommand")("ExportRunCommand", {
@@ -72,11 +137,26 @@ export const CliCommand = Schema.Union([
72
137
  HelpCommand,
73
138
  VersionCommand,
74
139
  UpCommand,
140
+ StatusCommand,
141
+ StopCommand,
142
+ RestartCommand,
143
+ UpgradeCommand,
75
144
  ExportRunCommand,
76
145
  BackupCommand,
77
146
  ]);
78
147
  const usageError = (message = CLI_USAGE) => new CliUsageError({ message });
79
148
  const decodePort = (source, value) => Schema.decodeUnknownEffect(PortFromString)(value).pipe(Effect.mapError(() => usageError(`${source} must be a whole number between 1 and 65535.\n\n${CLI_USAGE}`)));
149
+ /** Returns the origin of a URL without a path, query, or fragment, else `value` itself. */
150
+ const originOf = (value) => {
151
+ if (!URL.canParse(value))
152
+ return value;
153
+ const url = new URL(value);
154
+ return url.href === `${url.origin}/` ? url.origin : value;
155
+ };
156
+ /** Decodes the URL of the UI's pages, such as `https://orchestrator.example.ts.net/`. */
157
+ const decodeUiOrigin = (source, value) => Schema.decodeUnknownEffect(UiOrigin)(originOf(value)).pipe(Effect.mapError(() => usageError(`${source} must be the http or https URL of the UI without a path, such as https://orchestrator.example.ts.net.\n\n${CLI_USAGE}`)));
158
+ /** Decodes a log level name, ignoring case. */
159
+ const decodeLogLevel = (source, value) => Schema.decodeUnknownEffect(LogLevelName)(value.toLowerCase()).pipe(Effect.map((name) => LOG_LEVEL_NAMES[name]), Effect.mapError(() => usageError(`${source} must be trace, debug, info, warn, or error.\n\n${CLI_USAGE}`)));
80
160
  const ALLOW_VOLATILE_FLAG = "--allow-volatile-instance";
81
161
  const exportRunCommand = (args) => {
82
162
  const [runId, flag, output] = args;
@@ -98,7 +178,10 @@ const backupCommand = (args) => {
98
178
  };
99
179
  const upCommand = (args, environment) => Effect.gen(function* () {
100
180
  let port = Option.none();
181
+ let origin = Option.none();
182
+ let logLevel = Option.none();
101
183
  let allowVolatileInstance = Option.exists(environment.allowVolatileInstance, (v) => v === "1");
184
+ let detach = false;
102
185
  for (let index = 0; index < args.length; index += 1) {
103
186
  const arg = args[index];
104
187
  if (arg === "--port" || arg === "-p") {
@@ -111,9 +194,32 @@ const upCommand = (args, environment) => Effect.gen(function* () {
111
194
  else if (arg?.startsWith("--port=")) {
112
195
  port = Option.some(arg.slice("--port=".length));
113
196
  }
197
+ else if (arg === "--origin") {
198
+ const value = args[index + 1];
199
+ if (value === undefined)
200
+ return yield* usageError();
201
+ origin = Option.some(value);
202
+ index += 1;
203
+ }
204
+ else if (arg?.startsWith("--origin=")) {
205
+ origin = Option.some(arg.slice("--origin=".length));
206
+ }
207
+ else if (arg === "--log-level") {
208
+ const value = args[index + 1];
209
+ if (value === undefined)
210
+ return yield* usageError();
211
+ logLevel = Option.some(value);
212
+ index += 1;
213
+ }
214
+ else if (arg?.startsWith("--log-level=")) {
215
+ logLevel = Option.some(arg.slice("--log-level=".length));
216
+ }
114
217
  else if (arg === ALLOW_VOLATILE_FLAG) {
115
218
  allowVolatileInstance = true;
116
219
  }
220
+ else if (arg === "--detach") {
221
+ detach = true;
222
+ }
117
223
  else {
118
224
  return yield* usageError();
119
225
  }
@@ -125,26 +231,119 @@ const upCommand = (args, environment) => Effect.gen(function* () {
125
231
  }),
126
232
  onSome: (value) => decodePort("--port", value),
127
233
  });
128
- return new UpCommand({ port: resolvedPort, allowVolatileInstance });
234
+ const resolvedOrigin = yield* Option.match(origin, {
235
+ onNone: () => Option.match(environment.origin, {
236
+ onNone: () => Effect.succeedNone,
237
+ onSome: (value) => Effect.asSome(decodeUiOrigin("USINE_ORIGIN", value)),
238
+ }),
239
+ onSome: (value) => Effect.asSome(decodeUiOrigin("--origin", value)),
240
+ });
241
+ const resolvedLogLevel = yield* Option.match(logLevel, {
242
+ onNone: () => Option.match(environment.logLevel, {
243
+ onNone: () => Effect.succeed(DEFAULT_LOG_LEVEL),
244
+ onSome: (value) => decodeLogLevel("USINE_LOG_LEVEL", value),
245
+ }),
246
+ onSome: (value) => decodeLogLevel("--log-level", value),
247
+ });
248
+ return new UpCommand({
249
+ port: resolvedPort,
250
+ origin: resolvedOrigin,
251
+ logLevel: resolvedLogLevel,
252
+ allowVolatileInstance,
253
+ detach,
254
+ });
129
255
  });
256
+ /** Returns the settings of a `usine up` without flags: those of the environment, or the defaults. */
257
+ export const environmentUp = (environment) => upCommand([], environment);
258
+ const SecondsFromString = Schema.NumberFromString.pipe(Schema.decodeTo(Schema.Int.check(Schema.isGreaterThan(0))));
259
+ /** Parses `--timeout`, `--force`, and, if `allowCheck`, `--check`, and collects the operands. */
260
+ const lifecycleArguments = (args, allowCheck) => Effect.gen(function* () {
261
+ let timeout = Option.none();
262
+ let force = false;
263
+ let check = false;
264
+ const operands = [];
265
+ for (let index = 0; index < args.length; index += 1) {
266
+ const arg = args[index] ?? "";
267
+ if (arg === "--timeout") {
268
+ const value = args[index + 1];
269
+ if (value === undefined)
270
+ return yield* usageError();
271
+ timeout = Option.some(value);
272
+ index += 1;
273
+ }
274
+ else if (arg.startsWith("--timeout=")) {
275
+ timeout = Option.some(arg.slice("--timeout=".length));
276
+ }
277
+ else if (arg === "--force") {
278
+ force = true;
279
+ }
280
+ else if (arg === "--check" && allowCheck) {
281
+ check = true;
282
+ }
283
+ else if (arg !== "" && !arg.startsWith("-")) {
284
+ operands.push(arg);
285
+ }
286
+ else {
287
+ return yield* usageError();
288
+ }
289
+ }
290
+ const seconds = yield* Option.match(timeout, {
291
+ onNone: () => Effect.succeed(DEFAULT_LIFECYCLE_TIMEOUT_SECONDS),
292
+ onSome: (value) => Schema.decodeUnknownEffect(SecondsFromString)(value).pipe(Effect.mapError(() => usageError(`--timeout must be a whole number of seconds above 0.\n\n${CLI_USAGE}`))),
293
+ });
294
+ return {
295
+ options: new LifecycleOptions({ timeout: Duration.seconds(seconds), force }),
296
+ check,
297
+ operands,
298
+ };
299
+ });
300
+ const stopOrRestartCommand = (command, args) => Effect.flatMap(lifecycleArguments(args, false), ({ options, operands }) => {
301
+ if (operands.length > 0)
302
+ return Effect.fail(usageError());
303
+ return Effect.succeed(command === "stop" ? new StopCommand({ options }) : new RestartCommand({ options }));
304
+ });
305
+ const upgradeCommand = (args) => Effect.flatMap(lifecycleArguments(args, true), ({ options, check, operands }) => {
306
+ const [version, ...rest] = operands;
307
+ if (rest.length > 0)
308
+ return Effect.fail(usageError());
309
+ return Effect.succeed(new UpgradeCommand({ version: Option.fromUndefinedOr(version), check, options }));
310
+ });
311
+ const SUBCOMMANDS = new Set([
312
+ "up",
313
+ "status",
314
+ "stop",
315
+ "restart",
316
+ "upgrade",
317
+ "backup",
318
+ "export-run",
319
+ ]);
130
320
  /** Parses process arguments and the environment into one validated CLI command. */
131
321
  export const parseCli = Effect.fn("Cli.parse")((args, environment) => {
132
- if ((args.length === 1 && (args[0] === "--help" || args[0] === "-h")) ||
133
- (args.length === 2 &&
134
- (args[0] === "up" || args[0] === "export-run" || args[0] === "backup") &&
135
- (args[1] === "--help" || args[1] === "-h"))) {
322
+ const [command = "", ...rest] = args;
323
+ if ((args.length === 1 && (command === "--help" || command === "-h")) ||
324
+ (args.length === 2 && SUBCOMMANDS.has(command) && (rest[0] === "--help" || rest[0] === "-h"))) {
136
325
  return Effect.succeed(new HelpCommand());
137
326
  }
138
- if (args.length === 1 && (args[0] === "--version" || args[0] === "-v")) {
327
+ if (args.length === 1 && (command === "--version" || command === "-v")) {
139
328
  return Effect.succeed(new VersionCommand());
140
329
  }
141
- if (args[0] === "backup")
142
- return backupCommand(args.slice(1));
143
- if (args[0] === "export-run")
144
- return exportRunCommand(args.slice(1));
145
- if (args[0] !== "up")
146
- return Effect.fail(usageError());
147
- return upCommand(args.slice(1), environment);
330
+ switch (command) {
331
+ case "backup":
332
+ return backupCommand(rest);
333
+ case "export-run":
334
+ return exportRunCommand(rest);
335
+ case "up":
336
+ return upCommand(rest, environment);
337
+ case "status":
338
+ return rest.length === 0 ? Effect.succeed(new StatusCommand()) : Effect.fail(usageError());
339
+ case "stop":
340
+ case "restart":
341
+ return stopOrRestartCommand(command, rest);
342
+ case "upgrade":
343
+ return upgradeCommand(rest);
344
+ default:
345
+ return Effect.fail(usageError());
346
+ }
148
347
  });
149
348
  /**
150
349
  * Returns the directories the OS may clear: `os.tmpdir()`, `$TMPDIR`, and common temp locations.