@wjarka/cezarion 0.10.0-pr30.54

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 (478) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +838 -0
  3. package/dist/agent-config/account-identity.d.ts +44 -0
  4. package/dist/agent-config/account-identity.js +128 -0
  5. package/dist/agent-config/account-identity.js.map +1 -0
  6. package/dist/agent-config/catalog.d.ts +72 -0
  7. package/dist/agent-config/catalog.js +223 -0
  8. package/dist/agent-config/catalog.js.map +1 -0
  9. package/dist/agent-config/files.d.ts +46 -0
  10. package/dist/agent-config/files.js +119 -0
  11. package/dist/agent-config/files.js.map +1 -0
  12. package/dist/agent-config/model-settings/claude.d.ts +2 -0
  13. package/dist/agent-config/model-settings/claude.js +11 -0
  14. package/dist/agent-config/model-settings/claude.js.map +1 -0
  15. package/dist/agent-config/model-settings/codex.d.ts +2 -0
  16. package/dist/agent-config/model-settings/codex.js +16 -0
  17. package/dist/agent-config/model-settings/codex.js.map +1 -0
  18. package/dist/agent-config/model-settings/opencode.d.ts +2 -0
  19. package/dist/agent-config/model-settings/opencode.js +8 -0
  20. package/dist/agent-config/model-settings/opencode.js.map +1 -0
  21. package/dist/agent-config/model-settings/pi.d.ts +12 -0
  22. package/dist/agent-config/model-settings/pi.js +18 -0
  23. package/dist/agent-config/model-settings/pi.js.map +1 -0
  24. package/dist/agent-config/model-settings/shared.d.ts +9 -0
  25. package/dist/agent-config/model-settings/shared.js +93 -0
  26. package/dist/agent-config/model-settings/shared.js.map +1 -0
  27. package/dist/agent-config/model-settings/types.d.ts +9 -0
  28. package/dist/agent-config/model-settings/types.js +2 -0
  29. package/dist/agent-config/model-settings/types.js.map +1 -0
  30. package/dist/agent-config/models.d.ts +9 -0
  31. package/dist/agent-config/models.js +32 -0
  32. package/dist/agent-config/models.js.map +1 -0
  33. package/dist/agent-config/seed.d.ts +7 -0
  34. package/dist/agent-config/seed.js +90 -0
  35. package/dist/agent-config/seed.js.map +1 -0
  36. package/dist/agent-config/service.d.ts +44 -0
  37. package/dist/agent-config/service.js +71 -0
  38. package/dist/agent-config/service.js.map +1 -0
  39. package/dist/agent-config/validate.d.ts +21 -0
  40. package/dist/agent-config/validate.js +76 -0
  41. package/dist/agent-config/validate.js.map +1 -0
  42. package/dist/automations/coordinator.d.ts +26 -0
  43. package/dist/automations/coordinator.js +66 -0
  44. package/dist/automations/coordinator.js.map +1 -0
  45. package/dist/automations/github-poller.d.ts +74 -0
  46. package/dist/automations/github-poller.js +234 -0
  47. package/dist/automations/github-poller.js.map +1 -0
  48. package/dist/automations/scheduler.d.ts +42 -0
  49. package/dist/automations/scheduler.js +192 -0
  50. package/dist/automations/scheduler.js.map +1 -0
  51. package/dist/automations/store.d.ts +65 -0
  52. package/dist/automations/store.js +298 -0
  53. package/dist/automations/store.js.map +1 -0
  54. package/dist/automations/task-template.d.ts +18 -0
  55. package/dist/automations/task-template.js +95 -0
  56. package/dist/automations/task-template.js.map +1 -0
  57. package/dist/automations/types.d.ts +255 -0
  58. package/dist/automations/types.js +159 -0
  59. package/dist/automations/types.js.map +1 -0
  60. package/dist/config.d.ts +77 -0
  61. package/dist/config.js +242 -0
  62. package/dist/config.js.map +1 -0
  63. package/dist/contract/agent-config.d.ts +153 -0
  64. package/dist/contract/agent-profiles.d.ts +347 -0
  65. package/dist/contract/automations.d.ts +935 -0
  66. package/dist/contract/events.d.ts +104 -0
  67. package/dist/contract/github.d.ts +556 -0
  68. package/dist/contract/health.d.ts +102 -0
  69. package/dist/contract/index.d.ts +16 -0
  70. package/dist/contract/index.js +1895 -0
  71. package/dist/contract/projects.d.ts +210 -0
  72. package/dist/contract/repo.d.ts +234 -0
  73. package/dist/contract/runs.d.ts +1473 -0
  74. package/dist/contract/skills.d.ts +232 -0
  75. package/dist/contract/workflows.d.ts +218 -0
  76. package/dist/contract/workspace.d.ts +579 -0
  77. package/dist/core/agent-env.d.ts +31 -0
  78. package/dist/core/agent-env.js +371 -0
  79. package/dist/core/agent-env.js.map +1 -0
  80. package/dist/core/agent-model-policy.d.ts +10 -0
  81. package/dist/core/agent-model-policy.js +36 -0
  82. package/dist/core/agent-model-policy.js.map +1 -0
  83. package/dist/core/agent-profiles.d.ts +62 -0
  84. package/dist/core/agent-profiles.js +90 -0
  85. package/dist/core/agent-profiles.js.map +1 -0
  86. package/dist/core/agent-runner.d.ts +211 -0
  87. package/dist/core/agent-runner.js +68 -0
  88. package/dist/core/agent-runner.js.map +1 -0
  89. package/dist/core/ask.d.ts +105 -0
  90. package/dist/core/ask.js +187 -0
  91. package/dist/core/ask.js.map +1 -0
  92. package/dist/core/backend-detect.d.ts +16 -0
  93. package/dist/core/backend-detect.js +155 -0
  94. package/dist/core/backend-detect.js.map +1 -0
  95. package/dist/core/claude-cli-runner.d.ts +59 -0
  96. package/dist/core/claude-cli-runner.js +483 -0
  97. package/dist/core/claude-cli-runner.js.map +1 -0
  98. package/dist/core/claude-ui-mapper.d.ts +80 -0
  99. package/dist/core/claude-ui-mapper.js +598 -0
  100. package/dist/core/claude-ui-mapper.js.map +1 -0
  101. package/dist/core/codex-app-server-runner.d.ts +41 -0
  102. package/dist/core/codex-app-server-runner.js +584 -0
  103. package/dist/core/codex-app-server-runner.js.map +1 -0
  104. package/dist/core/codex-app-server-transport.d.ts +35 -0
  105. package/dist/core/codex-app-server-transport.js +150 -0
  106. package/dist/core/codex-app-server-transport.js.map +1 -0
  107. package/dist/core/codex-model-catalog.d.ts +10 -0
  108. package/dist/core/codex-model-catalog.js +110 -0
  109. package/dist/core/codex-model-catalog.js.map +1 -0
  110. package/dist/core/codex-ui-mapper.d.ts +112 -0
  111. package/dist/core/codex-ui-mapper.js +766 -0
  112. package/dist/core/codex-ui-mapper.js.map +1 -0
  113. package/dist/core/model-identity.d.ts +125 -0
  114. package/dist/core/model-identity.js +132 -0
  115. package/dist/core/model-identity.js.map +1 -0
  116. package/dist/core/model-presets.d.ts +21 -0
  117. package/dist/core/model-presets.js +81 -0
  118. package/dist/core/model-presets.js.map +1 -0
  119. package/dist/core/ndjson.d.ts +6 -0
  120. package/dist/core/ndjson.js +23 -0
  121. package/dist/core/ndjson.js.map +1 -0
  122. package/dist/core/opencode-model-catalog.d.ts +32 -0
  123. package/dist/core/opencode-model-catalog.js +153 -0
  124. package/dist/core/opencode-model-catalog.js.map +1 -0
  125. package/dist/core/opencode-server-runner.d.ts +32 -0
  126. package/dist/core/opencode-server-runner.js +882 -0
  127. package/dist/core/opencode-server-runner.js.map +1 -0
  128. package/dist/core/opencode-ui-mapper.d.ts +137 -0
  129. package/dist/core/opencode-ui-mapper.js +800 -0
  130. package/dist/core/opencode-ui-mapper.js.map +1 -0
  131. package/dist/core/pi-model-catalog.d.ts +31 -0
  132. package/dist/core/pi-model-catalog.js +152 -0
  133. package/dist/core/pi-model-catalog.js.map +1 -0
  134. package/dist/core/pi-runner.d.ts +24 -0
  135. package/dist/core/pi-runner.js +403 -0
  136. package/dist/core/pi-runner.js.map +1 -0
  137. package/dist/core/pi-ui-mapper.d.ts +36 -0
  138. package/dist/core/pi-ui-mapper.js +304 -0
  139. package/dist/core/pi-ui-mapper.js.map +1 -0
  140. package/dist/core/process-usage.d.ts +66 -0
  141. package/dist/core/process-usage.js +193 -0
  142. package/dist/core/process-usage.js.map +1 -0
  143. package/dist/core/provider-auth.d.ts +154 -0
  144. package/dist/core/provider-auth.js +509 -0
  145. package/dist/core/provider-auth.js.map +1 -0
  146. package/dist/core/provider-availability.d.ts +3 -0
  147. package/dist/core/provider-availability.js +14 -0
  148. package/dist/core/provider-availability.js.map +1 -0
  149. package/dist/core/runner-factory.d.ts +8 -0
  150. package/dist/core/runner-factory.js +25 -0
  151. package/dist/core/runner-factory.js.map +1 -0
  152. package/dist/core/runner-model-catalog.d.ts +29 -0
  153. package/dist/core/runner-model-catalog.js +78 -0
  154. package/dist/core/runner-model-catalog.js.map +1 -0
  155. package/dist/core/secret-redaction.d.ts +37 -0
  156. package/dist/core/secret-redaction.js +115 -0
  157. package/dist/core/secret-redaction.js.map +1 -0
  158. package/dist/core/shell-env.d.ts +28 -0
  159. package/dist/core/shell-env.js +56 -0
  160. package/dist/core/shell-env.js.map +1 -0
  161. package/dist/core/tool-display.d.ts +31 -0
  162. package/dist/core/tool-display.js +179 -0
  163. package/dist/core/tool-display.js.map +1 -0
  164. package/dist/core/ui-events.d.ts +335 -0
  165. package/dist/core/ui-events.js +25 -0
  166. package/dist/core/ui-events.js.map +1 -0
  167. package/dist/core/usage-limit.d.ts +42 -0
  168. package/dist/core/usage-limit.js +209 -0
  169. package/dist/core/usage-limit.js.map +1 -0
  170. package/dist/core/usage.d.ts +11 -0
  171. package/dist/core/usage.js +15 -0
  172. package/dist/core/usage.js.map +1 -0
  173. package/dist/core/v1-text-coalescer.d.ts +36 -0
  174. package/dist/core/v1-text-coalescer.js +72 -0
  175. package/dist/core/v1-text-coalescer.js.map +1 -0
  176. package/dist/git-diff-base.d.ts +85 -0
  177. package/dist/git-diff-base.js +180 -0
  178. package/dist/git-diff-base.js.map +1 -0
  179. package/dist/git-refs.d.ts +11 -0
  180. package/dist/git-refs.js +14 -0
  181. package/dist/git-refs.js.map +1 -0
  182. package/dist/git-worktree.d.ts +161 -0
  183. package/dist/git-worktree.js +508 -0
  184. package/dist/git-worktree.js.map +1 -0
  185. package/dist/handoff.d.ts +62 -0
  186. package/dist/handoff.js +154 -0
  187. package/dist/handoff.js.map +1 -0
  188. package/dist/index.d.ts +2 -0
  189. package/dist/index.js +680 -0
  190. package/dist/index.js.map +1 -0
  191. package/dist/install-as-command.d.ts +40 -0
  192. package/dist/install-as-command.js +52 -0
  193. package/dist/install-as-command.js.map +1 -0
  194. package/dist/pack-check.d.ts +17 -0
  195. package/dist/pack-check.js +27 -0
  196. package/dist/pack-check.js.map +1 -0
  197. package/dist/paths.d.ts +140 -0
  198. package/dist/paths.js +192 -0
  199. package/dist/paths.js.map +1 -0
  200. package/dist/planner.d.ts +27 -0
  201. package/dist/planner.js +268 -0
  202. package/dist/planner.js.map +1 -0
  203. package/dist/release/manifests.d.ts +81 -0
  204. package/dist/release/manifests.js +74 -0
  205. package/dist/release/manifests.js.map +1 -0
  206. package/dist/release/snapshot.d.ts +67 -0
  207. package/dist/release/snapshot.js +97 -0
  208. package/dist/release/snapshot.js.map +1 -0
  209. package/dist/release/stable.d.ts +38 -0
  210. package/dist/release/stable.js +55 -0
  211. package/dist/release/stable.js.map +1 -0
  212. package/dist/runs/agent-tmpdir.d.ts +41 -0
  213. package/dist/runs/agent-tmpdir.js +183 -0
  214. package/dist/runs/agent-tmpdir.js.map +1 -0
  215. package/dist/runs/auto-name.d.ts +75 -0
  216. package/dist/runs/auto-name.js +179 -0
  217. package/dist/runs/auto-name.js.map +1 -0
  218. package/dist/runs/event-history.d.ts +50 -0
  219. package/dist/runs/event-history.js +613 -0
  220. package/dist/runs/event-history.js.map +1 -0
  221. package/dist/runs/retention.d.ts +60 -0
  222. package/dist/runs/retention.js +86 -0
  223. package/dist/runs/retention.js.map +1 -0
  224. package/dist/runs/review-gate.d.ts +18 -0
  225. package/dist/runs/review-gate.js +21 -0
  226. package/dist/runs/review-gate.js.map +1 -0
  227. package/dist/runs/run-index.d.ts +19 -0
  228. package/dist/runs/run-index.js +43 -0
  229. package/dist/runs/run-index.js.map +1 -0
  230. package/dist/runs/store.d.ts +446 -0
  231. package/dist/runs/store.js +1118 -0
  232. package/dist/runs/store.js.map +1 -0
  233. package/dist/runs/task-markers.d.ts +28 -0
  234. package/dist/runs/task-markers.js +74 -0
  235. package/dist/runs/task-markers.js.map +1 -0
  236. package/dist/runs/task-refs.d.ts +25 -0
  237. package/dist/runs/task-refs.js +74 -0
  238. package/dist/runs/task-refs.js.map +1 -0
  239. package/dist/runs/ui-event-sink.d.ts +81 -0
  240. package/dist/runs/ui-event-sink.js +210 -0
  241. package/dist/runs/ui-event-sink.js.map +1 -0
  242. package/dist/server/app-type.d.ts +21 -0
  243. package/dist/server/app-type.js +2 -0
  244. package/dist/server/app-type.js.map +1 -0
  245. package/dist/server/capabilities.d.ts +70 -0
  246. package/dist/server/capabilities.js +152 -0
  247. package/dist/server/capabilities.js.map +1 -0
  248. package/dist/server/checkout.d.ts +128 -0
  249. package/dist/server/checkout.js +296 -0
  250. package/dist/server/checkout.js.map +1 -0
  251. package/dist/server/forge/github.d.ts +513 -0
  252. package/dist/server/forge/github.js +2364 -0
  253. package/dist/server/forge/github.js.map +1 -0
  254. package/dist/server/forge/index.d.ts +40 -0
  255. package/dist/server/forge/index.js +72 -0
  256. package/dist/server/forge/index.js.map +1 -0
  257. package/dist/server/forge/types.d.ts +242 -0
  258. package/dist/server/forge/types.js +2 -0
  259. package/dist/server/forge/types.js.map +1 -0
  260. package/dist/server/fs-browse.d.ts +105 -0
  261. package/dist/server/fs-browse.js +182 -0
  262. package/dist/server/fs-browse.js.map +1 -0
  263. package/dist/server/git-changes.d.ts +213 -0
  264. package/dist/server/git-changes.js +555 -0
  265. package/dist/server/git-changes.js.map +1 -0
  266. package/dist/server/git.d.ts +28 -0
  267. package/dist/server/git.js +112 -0
  268. package/dist/server/git.js.map +1 -0
  269. package/dist/server/github.d.ts +9 -0
  270. package/dist/server/github.js +8 -0
  271. package/dist/server/github.js.map +1 -0
  272. package/dist/server/launch-key.d.ts +7 -0
  273. package/dist/server/launch-key.js +33 -0
  274. package/dist/server/launch-key.js.map +1 -0
  275. package/dist/server/open-in-app.d.ts +66 -0
  276. package/dist/server/open-in-app.js +211 -0
  277. package/dist/server/open-in-app.js.map +1 -0
  278. package/dist/server/open-in-terminal.d.ts +70 -0
  279. package/dist/server/open-in-terminal.js +179 -0
  280. package/dist/server/open-in-terminal.js.map +1 -0
  281. package/dist/server/pr.d.ts +7 -0
  282. package/dist/server/pr.js +7 -0
  283. package/dist/server/pr.js.map +1 -0
  284. package/dist/server/project-context.d.ts +120 -0
  285. package/dist/server/project-context.js +182 -0
  286. package/dist/server/project-context.js.map +1 -0
  287. package/dist/server/provider-action-gate.d.ts +8 -0
  288. package/dist/server/provider-action-gate.js +56 -0
  289. package/dist/server/provider-action-gate.js.map +1 -0
  290. package/dist/server/provider-auth-runtime.d.ts +21 -0
  291. package/dist/server/provider-auth-runtime.js +66 -0
  292. package/dist/server/provider-auth-runtime.js.map +1 -0
  293. package/dist/server/server.d.ts +13138 -0
  294. package/dist/server/server.js +5263 -0
  295. package/dist/server/server.js.map +1 -0
  296. package/dist/server/static-ui.d.ts +49 -0
  297. package/dist/server/static-ui.js +92 -0
  298. package/dist/server/static-ui.js.map +1 -0
  299. package/dist/server/validators.d.ts +97 -0
  300. package/dist/server/validators.js +86 -0
  301. package/dist/server/validators.js.map +1 -0
  302. package/dist/server/ws.d.ts +85 -0
  303. package/dist/server/ws.js +218 -0
  304. package/dist/server/ws.js.map +1 -0
  305. package/dist/server/wsl.d.ts +25 -0
  306. package/dist/server/wsl.js +92 -0
  307. package/dist/server/wsl.js.map +1 -0
  308. package/dist/server-install/engine.d.ts +50 -0
  309. package/dist/server-install/engine.js +324 -0
  310. package/dist/server-install/engine.js.map +1 -0
  311. package/dist/server-install/platforms/macosx-ngrok.d.ts +6 -0
  312. package/dist/server-install/platforms/macosx-ngrok.js +345 -0
  313. package/dist/server-install/platforms/macosx-ngrok.js.map +1 -0
  314. package/dist/server-install/platforms/ubuntu-vps.d.ts +78 -0
  315. package/dist/server-install/platforms/ubuntu-vps.js +1016 -0
  316. package/dist/server-install/platforms/ubuntu-vps.js.map +1 -0
  317. package/dist/server-install/state.d.ts +52 -0
  318. package/dist/server-install/state.js +182 -0
  319. package/dist/server-install/state.js.map +1 -0
  320. package/dist/server-install/steps.d.ts +109 -0
  321. package/dist/server-install/steps.js +334 -0
  322. package/dist/server-install/steps.js.map +1 -0
  323. package/dist/server-install/strategies.d.ts +4 -0
  324. package/dist/server-install/strategies.js +20 -0
  325. package/dist/server-install/strategies.js.map +1 -0
  326. package/dist/server-install/types.d.ts +287 -0
  327. package/dist/server-install/types.js +121 -0
  328. package/dist/server-install/types.js.map +1 -0
  329. package/dist/server-install/ui.d.ts +42 -0
  330. package/dist/server-install/ui.js +130 -0
  331. package/dist/server-install/ui.js.map +1 -0
  332. package/dist/skills-banner.d.ts +22 -0
  333. package/dist/skills-banner.js +41 -0
  334. package/dist/skills-banner.js.map +1 -0
  335. package/dist/skills-remote.d.ts +84 -0
  336. package/dist/skills-remote.js +468 -0
  337. package/dist/skills-remote.js.map +1 -0
  338. package/dist/skills-update.d.ts +88 -0
  339. package/dist/skills-update.js +392 -0
  340. package/dist/skills-update.js.map +1 -0
  341. package/dist/skills.d.ts +82 -0
  342. package/dist/skills.js +251 -0
  343. package/dist/skills.js.map +1 -0
  344. package/dist/todos.d.ts +48 -0
  345. package/dist/todos.js +201 -0
  346. package/dist/todos.js.map +1 -0
  347. package/dist/ui-state.d.ts +26 -0
  348. package/dist/ui-state.js +38 -0
  349. package/dist/ui-state.js.map +1 -0
  350. package/dist/update-check.d.ts +12 -0
  351. package/dist/update-check.js +41 -0
  352. package/dist/update-check.js.map +1 -0
  353. package/dist/workflows/load.d.ts +15 -0
  354. package/dist/workflows/load.js +56 -0
  355. package/dist/workflows/load.js.map +1 -0
  356. package/dist/workflows/run.d.ts +758 -0
  357. package/dist/workflows/run.js +3389 -0
  358. package/dist/workflows/run.js.map +1 -0
  359. package/dist/workflows/types.d.ts +153 -0
  360. package/dist/workflows/types.js +212 -0
  361. package/dist/workflows/types.js.map +1 -0
  362. package/dist/workspace/agent-accounts.d.ts +153 -0
  363. package/dist/workspace/agent-accounts.js +304 -0
  364. package/dist/workspace/agent-accounts.js.map +1 -0
  365. package/dist/workspace/agent-profiles.d.ts +78 -0
  366. package/dist/workspace/agent-profiles.js +115 -0
  367. package/dist/workspace/agent-profiles.js.map +1 -0
  368. package/dist/workspace/config.d.ts +169 -0
  369. package/dist/workspace/config.js +379 -0
  370. package/dist/workspace/config.js.map +1 -0
  371. package/dist/workspace/migrations.d.ts +45 -0
  372. package/dist/workspace/migrations.js +147 -0
  373. package/dist/workspace/migrations.js.map +1 -0
  374. package/dist/workspace/projects-cli.d.ts +25 -0
  375. package/dist/workspace/projects-cli.js +172 -0
  376. package/dist/workspace/projects-cli.js.map +1 -0
  377. package/dist/workspace/projects.d.ts +109 -0
  378. package/dist/workspace/projects.js +250 -0
  379. package/dist/workspace/projects.js.map +1 -0
  380. package/dist/workspace/semaphore.d.ts +179 -0
  381. package/dist/workspace/semaphore.js +195 -0
  382. package/dist/workspace/semaphore.js.map +1 -0
  383. package/dist/workspace/ui-state.d.ts +34 -0
  384. package/dist/workspace/ui-state.js +53 -0
  385. package/dist/workspace/ui-state.js.map +1 -0
  386. package/package.json +70 -0
  387. package/scripts/check-pack.mjs +46 -0
  388. package/scripts/inline-contract.mjs +112 -0
  389. package/scripts/install-as-command.mjs +120 -0
  390. package/scripts/mock-claude.mjs +520 -0
  391. package/scripts/mock-pi-rpc.mjs +83 -0
  392. package/scripts/sync-readme.mjs +20 -0
  393. package/scripts/test-process-usage.mjs +47 -0
  394. package/web/dist/assets/alert-dialog-B4Ofsgv7.js +1 -0
  395. package/web/dist/assets/arrow-down-Dy8dup7j.js +1 -0
  396. package/web/dist/assets/arrow-left-BJaucbhn.js +1 -0
  397. package/web/dist/assets/bundle-mjs-BT31bpU6.js +1 -0
  398. package/web/dist/assets/centered-state-duPW0phQ.js +43 -0
  399. package/web/dist/assets/chevron-right-Be4A5TCS.js +1 -0
  400. package/web/dist/assets/chunk-BO2N2NFS-DE6qKn3r.js +131 -0
  401. package/web/dist/assets/collapsible-DdcNBdSk.js +1 -0
  402. package/web/dist/assets/commit-list-CgvN9vec.js +1 -0
  403. package/web/dist/assets/compare-variants-CQA2nd65.js +1 -0
  404. package/web/dist/assets/core-BCsw8oQw.js +12 -0
  405. package/web/dist/assets/css-BsVw1vtW.js +1 -0
  406. package/web/dist/assets/diff-B6Agp5Hl.js +3 -0
  407. package/web/dist/assets/diff-stat-BoXuGkgq.js +1 -0
  408. package/web/dist/assets/diff-view-CD8XI-fj.js +6 -0
  409. package/web/dist/assets/diff-woXpYk--.js +1 -0
  410. package/web/dist/assets/dropdown-menu-B3SYw-k5.js +1 -0
  411. package/web/dist/assets/editable-title-B-hjp5wl.js +1 -0
  412. package/web/dist/assets/ellipsis-vertical-BYwzw0xl.js +1 -0
  413. package/web/dist/assets/engine-javascript-FQvzRocB.js +141 -0
  414. package/web/dist/assets/file-BRj5eISx.js +1 -0
  415. package/web/dist/assets/folder-z4oT5981.js +1 -0
  416. package/web/dist/assets/git-toolbar-owSEkYld.js +1 -0
  417. package/web/dist/assets/github-Bz2VgRX3.js +1 -0
  418. package/web/dist/assets/go-rLFTqkRN.js +1 -0
  419. package/web/dist/assets/highlighted-body-OFNGDK62-BL-MfFgl.js +1 -0
  420. package/web/dist/assets/highlighter-CdHqIwFr.js +3 -0
  421. package/web/dist/assets/html-BY76lXLH.js +1 -0
  422. package/web/dist/assets/image-preview-h3WFluuy.js +1 -0
  423. package/web/dist/assets/index-BbcQNT92.css +2 -0
  424. package/web/dist/assets/index-EtQQQ6Kj.js +7 -0
  425. package/web/dist/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
  426. package/web/dist/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
  427. package/web/dist/assets/javascript-BgS3c2Ky.js +1 -0
  428. package/web/dist/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
  429. package/web/dist/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
  430. package/web/dist/assets/json-qhed-kSA.js +1 -0
  431. package/web/dist/assets/jsonc-CYpm1nAK.js +1 -0
  432. package/web/dist/assets/jsx-Bz0zcwM4.js +1 -0
  433. package/web/dist/assets/lib-BQXq3kEf.js +1 -0
  434. package/web/dist/assets/lib-BxQXEXDF.js +1 -0
  435. package/web/dist/assets/markdown-BYOwaDjH.js +1 -0
  436. package/web/dist/assets/markdown-DqBKYPiB.js +2 -0
  437. package/web/dist/assets/mermaid-GHXKKRXX-C4jxqUUb.js +1 -0
  438. package/web/dist/assets/new-task-form-BdJKRBJX.js +1 -0
  439. package/web/dist/assets/pill-BQfmfpYp.js +1 -0
  440. package/web/dist/assets/project-router-DxgFZY1l.js +1 -0
  441. package/web/dist/assets/prompt-templates-B6m16gq-.js +15 -0
  442. package/web/dist/assets/python-gzcpVVnB.js +1 -0
  443. package/web/dist/assets/react-runtime-CCIEwYL0.js +9 -0
  444. package/web/dist/assets/refresh-cw-mhSpxf2a.js +1 -0
  445. package/web/dist/assets/repo-git-CUNRxR3_.js +1 -0
  446. package/web/dist/assets/rolldown-runtime-QTnfLwEv.js +1 -0
  447. package/web/dist/assets/run-diff-DsmmDVfx.js +3 -0
  448. package/web/dist/assets/run-header-BkhrseLJ.js +1 -0
  449. package/web/dist/assets/rust-Cfkwpbl8.js +1 -0
  450. package/web/dist/assets/search-x-BqDMB2g8.js +1 -0
  451. package/web/dist/assets/shellscript-CLZ0U2zV.js +1 -0
  452. package/web/dist/assets/skill-empty-hint-BWEvTggc.js +1 -0
  453. package/web/dist/assets/skills-9oR_oHse.js +1 -0
  454. package/web/dist/assets/skills-DwIxnnWO.js +1 -0
  455. package/web/dist/assets/sparkles-DIoTQpyx.js +1 -0
  456. package/web/dist/assets/sql-BsFa4tDR.js +1 -0
  457. package/web/dist/assets/square-terminal-Cc7CuQxc.js +1 -0
  458. package/web/dist/assets/tab-link-D1fQgpmO.js +1 -0
  459. package/web/dist/assets/task-changes-BKeLlDpK.js +1 -0
  460. package/web/dist/assets/task-commits-gcEFZIa5.js +1 -0
  461. package/web/dist/assets/task-files-BGAqoXTW.js +2 -0
  462. package/web/dist/assets/task-thread-DT8aUYTS.js +9 -0
  463. package/web/dist/assets/textarea-BOVbfy5C.js +1 -0
  464. package/web/dist/assets/thread-loading-CypW73KD.js +1 -0
  465. package/web/dist/assets/toml-CcmNWLt0.js +1 -0
  466. package/web/dist/assets/trash-2-CJq6LHWn.js +1 -0
  467. package/web/dist/assets/triangle-alert-CjDFvU27.js +1 -0
  468. package/web/dist/assets/tsx-udAQXfEw.js +1 -0
  469. package/web/dist/assets/typescript-bsJCZSQ-.js +1 -0
  470. package/web/dist/assets/upload-CPDZlJeK.js +1 -0
  471. package/web/dist/assets/use-desktop-5JsLmi0a.js +1 -0
  472. package/web/dist/assets/use-submit-shortcut-CHVFevty.js +1 -0
  473. package/web/dist/assets/utils-DiO6zyJd.js +64 -0
  474. package/web/dist/assets/workflows-rQDFzWRt.js +11 -0
  475. package/web/dist/assets/yaml-rwi0_p6S.js +1 -0
  476. package/web/dist/assets/zoomable-image-COWqb11v.js +1 -0
  477. package/web/dist/index.html +80 -0
  478. package/web/dist/open-mercato.svg +11 -0
package/dist/index.js ADDED
@@ -0,0 +1,680 @@
1
+ #!/usr/bin/env node
2
+ import { parseArgs } from 'node:util';
3
+ import { spawn, execFileSync } from 'node:child_process';
4
+ import { createServer } from 'node:net';
5
+ import { mkdirSync, writeFileSync, existsSync, readFileSync } from 'node:fs';
6
+ import { dirname, join, resolve } from 'node:path';
7
+ import { fileURLToPath } from 'node:url';
8
+ import { detectEnvironment } from './core/backend-detect.js';
9
+ import { ProviderAuthService, providerAuthChecksDisabled, } from './core/provider-auth.js';
10
+ import { applyProviderEnablement } from './core/provider-availability.js';
11
+ import { pruneOrphans } from './git-worktree.js';
12
+ import { getRepoInfo } from './server/git.js';
13
+ import { DEFAULT_WORKTREE_RETENTION, loadConfig, resolveWorktreeRetention } from './config.js';
14
+ import { reclaimWorktrees } from './runs/retention.js';
15
+ import { RunStore } from './runs/store.js';
16
+ import { RunManager } from './workflows/run.js';
17
+ import { loadWorkflows } from './workflows/load.js';
18
+ import { startServer, WorkspaceEventBus } from './server/server.js';
19
+ import { ProviderRuntimeAuthObserver, recoverWithProviderRuntimeAuthObservation, } from './server/provider-auth-runtime.js';
20
+ import { providersRequiredByWorkflow, unavailableProviderMessage, } from './server/provider-action-gate.js';
21
+ import { checkForUpdate } from './update-check.js';
22
+ import { printSkillsBanner } from './skills-banner.js';
23
+ import { loadWorkspaceConfig } from './workspace/config.js';
24
+ import { runMigrations } from './workspace/migrations.js';
25
+ import { registerProject, shouldRegisterProject } from './workspace/projects.js';
26
+ import { runProjectsCommand } from './workspace/projects-cli.js';
27
+ import { WorkspaceSemaphore } from './workspace/semaphore.js';
28
+ const HELP = `cezar — local cockpit for AI agent tasks in your repo
29
+
30
+ Usage:
31
+ cez start the cockpit (server + GUI) for the current repo
32
+ cez run "<task>" run a task headless in the terminal
33
+ cez init scaffold .ai/cezar/ (example workflow + skill)
34
+ cez projects list the projects this cockpit serves
35
+ (also: projects add [<dir>] · projects remove <id>)
36
+ cez server-install interactive wizard to host cezar on a server
37
+ cez server-deploy redeploy a new version (reload the service) + verify
38
+ cez server-uninstall reverse a server-install
39
+
40
+ Options:
41
+ -p, --port <n> cockpit port (default 4321; server-install: this
42
+ instance's loopback port — auto-picked per domain)
43
+ --repo <dir> repo to operate on (default: cwd)
44
+ --workflow <name> workflow for \`run\` (default: quick-task)
45
+ --model <model> model override for \`run\`
46
+ --no-open don't open the browser
47
+ --platform <id> server-install target (ubuntu-vps | macosx-ngrok)
48
+ --domain <host> server-install (ubuntu-vps): host a SECOND, independent
49
+ cockpit for this domain (own nginx site + service + port).
50
+ A new domain never resumes/clobbers the first install.
51
+ --external-proxy server-install (ubuntu-vps): the box ALREADY has a
52
+ reverse proxy owning :80/:443 (Dokploy/Traefik, Coolify,
53
+ Caddy, your own nginx). Installs the service only — no
54
+ nginx, no certbot. That proxy must provide TLS + auth.
55
+ --bind-host <host> host the cockpit binds (default 127.0.0.1). Use with
56
+ --external-proxy when the proxy runs in a container and
57
+ cannot reach loopback (e.g. docker bridge 172.17.0.1).
58
+ cezar has NO built-in auth — never expose this publicly.
59
+ --yes server-install: accept safe defaults (never auto-sudo)
60
+ --reconfigure <ids> server-install: force re-run of step id(s), comma-separated
61
+ --reinstall server-install: force re-run of every step (full reinstall)
62
+ -h, --help show this help
63
+
64
+ Zero config: uses your logged-in \`claude\` CLI (and \`gh\` for GitHub bits).
65
+ Skills live in .ai/skills/, .ai/cezar/skills/ and your team skills repo
66
+ (default open-mercato/skills; override via .ai/cezar/config.json);
67
+ workflows in .ai/cezar/workflows/.`;
68
+ async function main() {
69
+ const { values, positionals } = parseArgs({
70
+ options: {
71
+ port: { type: 'string', short: 'p', default: '4321' },
72
+ repo: { type: 'string' },
73
+ workflow: { type: 'string' },
74
+ model: { type: 'string' },
75
+ 'no-open': { type: 'boolean', default: false },
76
+ platform: { type: 'string' },
77
+ domain: { type: 'string' },
78
+ 'bind-host': { type: 'string' },
79
+ 'external-proxy': { type: 'boolean', default: false },
80
+ yes: { type: 'boolean', default: false },
81
+ reconfigure: { type: 'string' },
82
+ reinstall: { type: 'boolean', default: false },
83
+ help: { type: 'boolean', short: 'h', default: false },
84
+ },
85
+ allowPositionals: true,
86
+ });
87
+ // `port` carries a default, so its presence can't tell an explicit `--port`
88
+ // from the fallback. server-install needs that distinction (explicit port
89
+ // wins; otherwise a new named instance auto-picks a free one), so detect the
90
+ // flag straight from argv.
91
+ const portExplicit = process.argv
92
+ .slice(2)
93
+ .some((a) => a === '-p' || a === '--port' || a.startsWith('--port=') || a.startsWith('-p='));
94
+ if (values.help) {
95
+ console.log(HELP);
96
+ return;
97
+ }
98
+ const command = positionals[0] ?? 'serve';
99
+ const cwd = resolve(values.repo ?? process.cwd());
100
+ const repoInfo = await getRepoInfo(cwd);
101
+ const repoRoot = repoInfo?.root ?? cwd;
102
+ switch (command) {
103
+ case 'serve':
104
+ await serveCommand(repoRoot, Number(values.port), !values['no-open'], values['bind-host']);
105
+ return;
106
+ case 'run':
107
+ await runCommand(repoRoot, positionals.slice(1).join(' ').trim(), values.workflow, values.model);
108
+ return;
109
+ case 'init':
110
+ initCommand(repoRoot);
111
+ return;
112
+ case 'projects':
113
+ // Registry-only (no server, no HTTP) — see workspace/projects-cli.ts.
114
+ // In single-project mode a listing is a launch-context read: register
115
+ // the boot repo through the normal self-healing path and pin the output
116
+ // to that explicit identity. Mutations are left to their own guards.
117
+ const projectArgs = positionals.slice(1);
118
+ const isList = projectArgs.length === 0 || projectArgs[0] === 'list';
119
+ const bootProjectId = process.env.CEZ_SINGLE_PROJECT === '1' && isList
120
+ ? await initWorkspace(repoRoot)
121
+ : undefined;
122
+ process.exitCode = await runProjectsCommand(projectArgs, { defaultRoot: repoRoot, bootProjectId });
123
+ return;
124
+ case 'server-install':
125
+ await serverCommand('install', repoRoot, values.platform, {
126
+ yes: Boolean(values.yes),
127
+ reconfigure: values.reconfigure,
128
+ reinstall: Boolean(values.reinstall),
129
+ domain: values.domain,
130
+ port: portExplicit ? Number(values.port) : undefined,
131
+ externalProxy: Boolean(values['external-proxy']),
132
+ bindHost: values['bind-host'],
133
+ });
134
+ return;
135
+ case 'server-deploy':
136
+ await serverCommand('deploy', repoRoot, values.platform, {
137
+ yes: Boolean(values.yes),
138
+ domain: values.domain,
139
+ });
140
+ return;
141
+ case 'server-uninstall':
142
+ await serverCommand('uninstall', repoRoot, values.platform, {
143
+ yes: Boolean(values.yes),
144
+ domain: values.domain,
145
+ });
146
+ return;
147
+ default:
148
+ console.error(`unknown command: ${command}\n`);
149
+ console.log(HELP);
150
+ process.exitCode = 1;
151
+ }
152
+ }
153
+ // ---- workspace boot ----------------------------------------------------------
154
+ /**
155
+ * Boot-time workspace bookkeeping (spec 2026-07-20-multi-project-workspace,
156
+ * "Boot flow"): run pending `~/.cezar` migrations first, then register the
157
+ * boot repo in the per-user project registry. Registration is suppressed for
158
+ * task worktrees and `$HOME` itself (`shouldRegisterProject`) — the process
159
+ * still serves those folders normally. Strictly non-fatal: the zero-config
160
+ * law says a broken or read-only home degrades to a smaller cockpit, never a
161
+ * failed boot, so any workspace error logs one warning and boot continues.
162
+ *
163
+ * Returns the boot project's registry id when registration happened —
164
+ * `serveCommand` plumbs it into the server (`ServerDeps.bootProjectId`) so
165
+ * `/api/projects` and `/api/v1/health` can name the boot project without a
166
+ * lookup. Undefined when registration was suppressed or the workspace is
167
+ * unavailable; the server then derives a fallback on its own.
168
+ */
169
+ async function initWorkspace(repoRoot) {
170
+ try {
171
+ await runMigrations({ bootRepoRoot: repoRoot });
172
+ if (await shouldRegisterProject(repoRoot))
173
+ return (await registerProject(repoRoot)).id;
174
+ }
175
+ catch (err) {
176
+ const message = err instanceof Error ? err.message : String(err);
177
+ console.warn(`[cez] workspace registry unavailable (${message}) — continuing without it`);
178
+ }
179
+ return undefined;
180
+ }
181
+ // ---- serve -----------------------------------------------------------------
182
+ async function serveCommand(repoRoot, preferredPort, openBrowser, bindHost) {
183
+ const bootProjectId = await initWorkspace(repoRoot);
184
+ // ONE workspace semaphore for the whole process (spec 2026-07-20, step 2.5):
185
+ // the boot manager and every lazily-built project context count their runs
186
+ // against the same `resources.maxParallel`. The boot refresh() below is the
187
+ // cache hook's first call; PUT /api/workspace/config (step 2.7) re-fires it.
188
+ const semaphore = new WorkspaceSemaphore();
189
+ await semaphore.refresh();
190
+ // keepLive + recover() (#367): runs that were queued/running/waiting when
191
+ // the previous process exited are re-queued or resumed instead of failed.
192
+ const store = openStore(repoRoot, { keepLive: true });
193
+ const manager = new RunManager(store, repoRoot, { semaphore });
194
+ const providerAuth = new ProviderAuthService();
195
+ const workspaceEvents = new WorkspaceEventBus();
196
+ const providerRuntimeAuth = new ProviderRuntimeAuthObserver(providerAuth, (status) => {
197
+ workspaceEvents.emit('provider-status', status);
198
+ });
199
+ const version = readOwnVersion();
200
+ const checks = await detectEnvironment();
201
+ const repo = await getRepoInfo(repoRoot);
202
+ // Startup reconcile (spec 006): sweep worktrees whose run no longer exists.
203
+ if (repo) {
204
+ const orphans = await pruneOrphans(repoRoot, new Set(store.listRuns().map((r) => r.id))).catch(() => []);
205
+ if (orphans.length > 0) {
206
+ console.log(` cleaned ${orphans.length} orphaned worktree(s): ${orphans.map((id) => id.slice(0, 8)).join(', ')}`);
207
+ }
208
+ // Count-based worktree retention (#483): reclaim finished worktrees beyond
209
+ // the keep-limit (directory only — `cez/<id8>` branch kept, so recoverable).
210
+ // Best-effort; never blocks boot.
211
+ const keep = await resolveWorktreeRetention(repoRoot).catch(() => DEFAULT_WORKTREE_RETENTION);
212
+ const reclaimed = await reclaimWorktrees(repoRoot, store, keep).catch(() => []);
213
+ if (reclaimed.length > 0) {
214
+ console.log(` reclaimed ${reclaimed.length} old worktree(s), branch kept: ${reclaimed.map((id) => id.slice(0, 8)).join(', ')}`);
215
+ }
216
+ }
217
+ const recovered = store
218
+ .listRuns()
219
+ .filter((r) => ['queued', 'waiting', 'running'].includes(r.status)).length;
220
+ await recoverWithProviderRuntimeAuthObservation(store, () => manager.recover(), providerRuntimeAuth);
221
+ if (recovered > 0)
222
+ console.log(` recovered ${recovered} run(s) from the previous session`);
223
+ // Update discovery (#368) — fire-and-forget; the banner prints whenever the
224
+ // registry answers and /api/v1/health picks it up for the GUI chip.
225
+ const pkgName = readOwnName();
226
+ const update = {};
227
+ void checkForUpdate(pkgName, version).then((latest) => {
228
+ if (!latest)
229
+ return;
230
+ update.latest = latest;
231
+ console.log(`\n ⬆ cezar ${latest} is available (running ${version}) — restart with: npx ${pkgName}@latest\n`);
232
+ });
233
+ const port = await pickPort(preferredPort);
234
+ // SECURITY: cezar executes agents. A non-loopback bind exposes that box to
235
+ // whatever can reach the interface, and cezar itself has NO auth — it is only
236
+ // for a deliberate hosted setup where a reverse proxy in front provides TLS +
237
+ // auth (see `server-install --external-proxy`). Say so, loudly, every start.
238
+ if (bindHost && !['127.0.0.1', 'localhost', '::1'].includes(bindHost)) {
239
+ console.log(`\n ⚠ binding ${bindHost}:${port} — cezar has no built-in auth.\n` +
240
+ ` Only do this behind a reverse proxy that enforces authentication,\n` +
241
+ ` and make sure this interface is not reachable from the internet.\n`);
242
+ }
243
+ startServer({
244
+ repoRoot,
245
+ store,
246
+ manager,
247
+ version,
248
+ update,
249
+ bootProjectId,
250
+ semaphore,
251
+ bindHost,
252
+ providerAuth,
253
+ providerRuntimeAuth,
254
+ workspaceEvents,
255
+ }, port);
256
+ const url = `http://localhost:${port}`;
257
+ console.log(`\n cezar v${version} — ${repoRoot}`);
258
+ console.log(` ${repo ? `branch ${repo.branch}` : 'not a git repository (tasks run in place, one at a time; repo view is empty)'}`);
259
+ for (const check of checks) {
260
+ const mark = check.available ? '✓' : '✗';
261
+ const detail = check.available ? (check.version ?? 'ok') : (check.hint ?? 'missing');
262
+ console.log(` ${mark} ${check.name.padEnd(6)} ${detail}`);
263
+ }
264
+ if (port !== preferredPort)
265
+ console.log(` (port ${preferredPort} was busy — using ${port})`);
266
+ console.log(`\n cockpit → ${url}\n`);
267
+ // Silenced by CEZ_NO_BANNER=1 or by dismissing the cockpit's banner (#391).
268
+ await printSkillsBanner(repoRoot);
269
+ const shutdown = () => {
270
+ store.flush();
271
+ process.exit(0);
272
+ };
273
+ process.on('SIGINT', shutdown);
274
+ process.on('SIGTERM', shutdown);
275
+ // Open the browser only once the server actually answers, so the first
276
+ // paint is the cockpit and never a connection error.
277
+ if (openBrowser) {
278
+ const healthy = await waitForHealth(`${url}/api/v1/health`, 5_000);
279
+ if (healthy)
280
+ openUrl(url);
281
+ }
282
+ }
283
+ /** First free port starting at `start` (the launch.mjs pattern from janitor). */
284
+ async function pickPort(start) {
285
+ for (let port = start; port < start + 50; port++) {
286
+ if (await canListen(port))
287
+ return port;
288
+ }
289
+ return start; // let the server fail loudly if 50 ports are somehow busy
290
+ }
291
+ function canListen(port) {
292
+ return new Promise((resolvePort) => {
293
+ const probe = createServer();
294
+ probe.once('error', () => resolvePort(false));
295
+ probe.once('listening', () => probe.close(() => resolvePort(true)));
296
+ probe.listen(port, '127.0.0.1');
297
+ });
298
+ }
299
+ async function waitForHealth(healthUrl, timeoutMs) {
300
+ const deadline = Date.now() + timeoutMs;
301
+ while (Date.now() < deadline) {
302
+ try {
303
+ const res = await fetch(healthUrl);
304
+ if (res.ok)
305
+ return true;
306
+ }
307
+ catch {
308
+ // not up yet
309
+ }
310
+ await new Promise((r) => setTimeout(r, 150));
311
+ }
312
+ return false;
313
+ }
314
+ // ---- run (headless) ----------------------------------------------------------
315
+ async function runCommand(repoRoot, task, workflowName, model) {
316
+ if (!task) {
317
+ console.error('usage: cez run "<task>" [--workflow name] [--model model]');
318
+ process.exitCode = 1;
319
+ return;
320
+ }
321
+ await initWorkspace(repoRoot);
322
+ const { workflows, issues } = await loadWorkflows(repoRoot);
323
+ for (const issue of issues)
324
+ console.error(`! skipped ${issue.path}: ${issue.message}`);
325
+ const name = workflowName ?? 'quick-task';
326
+ const workflow = workflows.find((w) => w.name === name);
327
+ if (!workflow) {
328
+ console.error(`unknown workflow: ${name} (available: ${workflows.map((w) => w.name).join(', ')})`);
329
+ process.exitCode = 1;
330
+ return;
331
+ }
332
+ const providerAuth = new ProviderAuthService();
333
+ const requiredProviders = providersRequiredByWorkflow(workflow, (await loadConfig(repoRoot)).defaultRunner);
334
+ if (requiredProviders.length > 0 && !providerAuthChecksDisabled()) {
335
+ const [discovered, workspace] = await Promise.all([
336
+ providerAuth.status(),
337
+ loadWorkspaceConfig(),
338
+ ]);
339
+ const blocked = unavailableProviderMessage(requiredProviders, applyProviderEnablement(discovered, workspace.disabledProviders));
340
+ if (blocked) {
341
+ console.error(blocked);
342
+ process.exitCode = 1;
343
+ return;
344
+ }
345
+ }
346
+ const store = openStore(repoRoot);
347
+ // Headless tasks still appear in the cockpit later, so persist the same
348
+ // task-local recovery event when a credential expires after the preflight.
349
+ const providerRuntimeAuth = new ProviderRuntimeAuthObserver(providerAuth, () => { });
350
+ providerRuntimeAuth.watch(store);
351
+ // Headless runs enforce the same workspace-level cap/memory limit (step
352
+ // 2.5) — one refreshed semaphore, even with just one manager in play.
353
+ const semaphore = new WorkspaceSemaphore();
354
+ await semaphore.refresh();
355
+ const manager = new RunManager(store, repoRoot, { semaphore });
356
+ store.on('event', ({ event }) => {
357
+ switch (event.type) {
358
+ case 'text':
359
+ console.log(String(event.text ?? ''));
360
+ break;
361
+ case 'tool-call':
362
+ console.log(` → ${String(event.tool)} ${previewJson(event.input)}`);
363
+ break;
364
+ case 'tool-result':
365
+ console.log(` ← ${firstLine(String(event.result ?? ''))}`);
366
+ break;
367
+ case 'check-output':
368
+ console.log(String(event.text ?? ''));
369
+ break;
370
+ case 'step-start':
371
+ console.log(`\n── step: ${String(event.name)} ${Number(event.iteration) > 1 ? `(attempt ${event.iteration})` : ''}`);
372
+ break;
373
+ case 'note':
374
+ case 'lifecycle':
375
+ console.log(` · ${String(event.message ?? '')}`);
376
+ break;
377
+ case 'error':
378
+ console.error(` ✗ ${String(event.message ?? '')}`);
379
+ break;
380
+ }
381
+ });
382
+ const run = manager.startRun(workflow, { task, model });
383
+ // `review` is terminal here too (spec 009) — headless runs must not hang on
384
+ // the GUI's review gate; the diff waits on the task branch/cockpit instead.
385
+ const final = await new Promise((resolveStatus) => {
386
+ store.on('run', (r) => {
387
+ if (r.id === run.id && ['done', 'review', 'failed', 'cancelled'].includes(r.status))
388
+ resolveStatus(r.status);
389
+ });
390
+ });
391
+ store.flush();
392
+ const record = store.getRun(run.id);
393
+ if (final === 'review') {
394
+ console.log(`\n changes ready for review on branch ${record?.branch ?? '?'} — inspect them in the cockpit: npx cezarion`);
395
+ }
396
+ console.log(`\nrun ${final} — ${record?.tokensUsed ?? 0} tokens — details in the cockpit: npx cezarion`);
397
+ process.exitCode = final === 'done' || final === 'review' ? 0 : 1;
398
+ }
399
+ // ---- server-install / server-uninstall --------------------------------------
400
+ // The whole server-install module (and its @clack/prompts dependency) is loaded
401
+ // lazily here so it never enters the `serve`/`run`/`init` import graph — the
402
+ // runtime server stack stays tiny (AGENTS.md).
403
+ /**
404
+ * Prepend the operator's login-shell PATH to this process's PATH so tool
405
+ * detection and installs find things in ~/.local/bin, nvm, and other
406
+ * profile-added dirs even when the installer was launched non-interactively.
407
+ * Best-effort: a shell that errors or hangs leaves PATH untouched.
408
+ */
409
+ function augmentPathFromLoginShell() {
410
+ try {
411
+ const out = execFileSync('bash', ['-lc', 'printf %s "$PATH"'], { timeout: 5000, encoding: 'utf8' });
412
+ const loginPath = out.split('\n').map((s) => s.trim()).filter(Boolean).pop() ?? '';
413
+ if (!loginPath)
414
+ return;
415
+ const seen = new Set();
416
+ process.env.PATH = [...loginPath.split(':'), ...(process.env.PATH ?? '').split(':')]
417
+ .filter((d) => d && !seen.has(d) && seen.add(d))
418
+ .join(':');
419
+ }
420
+ catch {
421
+ // best effort — keep the existing PATH
422
+ }
423
+ }
424
+ async function serverCommand(mode, repoRoot, platform, flags) {
425
+ // Detection (claude/gh/codex) and tool installs resolve executables off the
426
+ // process PATH. When the installer is launched from a non-login shell (an
427
+ // `ssh host cmd`, a script, a fresh service context), ~/.local/bin and nvm's
428
+ // bin are absent, so tools the user actually has look "not installed". Merge
429
+ // the login shell's PATH first so we see exactly what the operator sees.
430
+ augmentPathFromLoginShell();
431
+ const { getStrategy, availablePlatformIds } = await import('./server-install/strategies.js');
432
+ const { runInstall, runUninstall, runDeploy } = await import('./server-install/engine.js');
433
+ const { loadServerState, listServerInstances, nextFreeInstancePort } = await import('./server-install/state.js');
434
+ const { instanceSlug, DEFAULT_SERVER_INSTANCE } = await import('./paths.js');
435
+ const ids = availablePlatformIds();
436
+ // Resolve the instance from --domain (domain-keyed multi-instance). An
437
+ // interactive install with an existing cockpit and no --domain also offers to
438
+ // stand up a second instance — the exact "it asks me to reinstall" case.
439
+ let domain = (flags.domain ?? '').trim() || undefined;
440
+ if (mode === 'install' && !domain && !flags.yes && process.stdin.isTTY && loadServerState(DEFAULT_SERVER_INSTANCE).installed) {
441
+ try {
442
+ const { createClackUi } = await import('./server-install/ui.js');
443
+ const answer = await createClackUi().text({
444
+ message: 'This host already runs a cezar cockpit. Enter a NEW domain to host a second, independent instance — ' +
445
+ 'or leave blank to manage/redeploy the existing one.',
446
+ placeholder: 'shop.example.com',
447
+ });
448
+ if (typeof answer === 'string' && answer.trim())
449
+ domain = answer.trim();
450
+ }
451
+ catch {
452
+ // any prompt failure → fall back to managing the default instance
453
+ }
454
+ }
455
+ const instance = domain ? instanceSlug(domain) : DEFAULT_SERVER_INSTANCE;
456
+ // Uninstall and deploy can read the platform from THIS instance's record when omitted.
457
+ let chosen = platform;
458
+ if ((mode === 'uninstall' || mode === 'deploy') && !chosen) {
459
+ chosen = loadServerState(instance).platform;
460
+ }
461
+ if (!chosen) {
462
+ console.error(`--platform is required. Valid platforms: ${ids.join(', ')}`);
463
+ process.exitCode = 1;
464
+ return;
465
+ }
466
+ const strategy = getStrategy(chosen);
467
+ if (!strategy) {
468
+ console.error(`unknown platform: ${chosen} (valid: ${ids.join(', ')})`);
469
+ process.exitCode = 1;
470
+ return;
471
+ }
472
+ // Domain-keyed multi-instance is an ubuntu-vps feature (shared nginx front).
473
+ if (instance !== DEFAULT_SERVER_INSTANCE && chosen !== 'ubuntu-vps') {
474
+ console.error(`--domain (multi-instance) is only supported on ubuntu-vps, not ${chosen}.`);
475
+ process.exitCode = 1;
476
+ return;
477
+ }
478
+ // Port: an explicit --port always wins; a brand-new named instance otherwise
479
+ // auto-picks the next free loopback port so it can't collide with the first.
480
+ let port = flags.port;
481
+ if (mode === 'install' && instance !== DEFAULT_SERVER_INSTANCE && port === undefined) {
482
+ const known = listServerInstances().some((i) => i.instance === instance);
483
+ if (!known) {
484
+ port = nextFreeInstancePort();
485
+ console.log(`\n New instance "${instance}" (${domain}) → loopback port ${port} (override with --port).`);
486
+ }
487
+ }
488
+ const runOpts = {
489
+ dryRun: process.env.CEZ_DRY_RUN === '1',
490
+ assumeYes: flags.yes,
491
+ reconfigure: new Set((flags.reconfigure ?? '').split(',').map((s) => s.trim()).filter(Boolean)),
492
+ reinstall: Boolean(flags.reinstall),
493
+ repoRoot,
494
+ now: new Date().toISOString(),
495
+ instance,
496
+ domain,
497
+ port,
498
+ // Only an install decides proxy mode; deploy/uninstall read it back from
499
+ // the recorded state. Preserve an omitted flag as `undefined`: a flag-less
500
+ // resume must keep an external-proxy install external instead of flipping
501
+ // it back to cezar-managed nginx/SSL.
502
+ ...(mode === 'install'
503
+ ? { externalProxy: flags.externalProxy || undefined, bindHost: flags.bindHost }
504
+ : {}),
505
+ };
506
+ // e.g. "ubuntu-vps" or "ubuntu-vps, shop.example.com" for a named instance.
507
+ const label = instance === DEFAULT_SERVER_INSTANCE ? chosen : `${chosen}, ${domain}`;
508
+ const domainFlag = instance === DEFAULT_SERVER_INSTANCE ? '' : ` --domain ${domain}`;
509
+ try {
510
+ const result = mode === 'install'
511
+ ? await runInstall(strategy, runOpts)
512
+ : mode === 'deploy'
513
+ ? await runDeploy(strategy, runOpts)
514
+ : await runUninstall(strategy, runOpts);
515
+ if (mode === 'install' && result.status === 'complete') {
516
+ console.log(`\n cez server-install (${label}) complete.`);
517
+ console.log(` Redeploy a new version any time with: cez server-deploy --platform ${chosen}${domainFlag}\n`);
518
+ }
519
+ else if (mode === 'deploy' && result.status === 'complete') {
520
+ console.log(`\n cez server-deploy (${label}) complete — the service was reloaded and verified.\n`);
521
+ }
522
+ else if (mode === 'uninstall' && result.status === 'complete') {
523
+ console.log(`\n cez server-uninstall (${label}) complete — the changes it made were reversed.\n`);
524
+ }
525
+ // complete + cancelled (resumable) exit 0; failed exits 1.
526
+ process.exitCode = result.status === 'failed' ? 1 : 0;
527
+ }
528
+ catch (err) {
529
+ console.error(err instanceof Error ? err.message : String(err));
530
+ process.exitCode = 1;
531
+ }
532
+ }
533
+ // ---- init --------------------------------------------------------------------
534
+ function initCommand(repoRoot) {
535
+ const workflowsDir = join(repoRoot, '.ai/cezar', 'workflows');
536
+ const skillsDir = join(repoRoot, '.ai/cezar', 'skills');
537
+ mkdirSync(workflowsDir, { recursive: true });
538
+ mkdirSync(skillsDir, { recursive: true });
539
+ const examples = [
540
+ {
541
+ path: join(workflowsDir, 'fix-and-verify.yaml'),
542
+ content: `name: fix-and-verify
543
+ description: Implement the task, then run your test command; on failure the agent retries with the failing output.
544
+ steps:
545
+ - id: implement
546
+ name: Implement
547
+ prompt: "{{task}}"
548
+ - id: verify
549
+ name: Verify
550
+ command: "echo 'replace me with: npm test / yarn test / pytest'"
551
+ onFail:
552
+ retry: implement
553
+ max: 2
554
+ `,
555
+ },
556
+ {
557
+ path: join(skillsDir, 'project-conventions.md'),
558
+ content: `---
559
+ name: project-conventions
560
+ description: House rules the agent should follow in this repo.
561
+ ---
562
+
563
+ # Project conventions
564
+
565
+ - Describe your stack, style and testing conventions here.
566
+ - Reference this skill from a workflow step via \`skill: project-conventions\`.
567
+ `,
568
+ },
569
+ ];
570
+ for (const example of examples) {
571
+ if (existsSync(example.path)) {
572
+ console.log(` = ${example.path} (exists, left untouched)`);
573
+ }
574
+ else {
575
+ writeFileSync(example.path, example.content, 'utf8');
576
+ console.log(` + ${example.path}`);
577
+ }
578
+ }
579
+ ensureDataGitignore(repoRoot);
580
+ console.log('\nDone. Start the cockpit with: npx cezarion');
581
+ }
582
+ // ---- helpers -----------------------------------------------------------------
583
+ function openStore(repoRoot, opts) {
584
+ const dataDir = join(repoRoot, '.ai/cezar');
585
+ const store = RunStore.open(dataDir, opts);
586
+ ensureDataGitignore(repoRoot);
587
+ return store;
588
+ }
589
+ /** Keep run data out of the user's repo history; workflows/skills stay committable. */
590
+ function ensureDataGitignore(repoRoot) {
591
+ const path = join(repoRoot, '.ai/cezar', '.gitignore');
592
+ const wanted = [
593
+ 'runs.json',
594
+ 'runs.json.tmp',
595
+ 'runs/',
596
+ 'worktrees/',
597
+ 'tmp/', // per-run agent temp directories (#785)
598
+ 'todos.json',
599
+ 'todos.json.tmp',
600
+ 'launch-key',
601
+ 'automations.json',
602
+ 'automations.json.tmp',
603
+ 'automation-state.json',
604
+ 'automation-state.json.tmp',
605
+ 'automation-receipts.ndjson',
606
+ 'automation-receipts.ndjson.tmp',
607
+ 'automation-log.ndjson',
608
+ 'automation-log.ndjson.tmp',
609
+ 'automation-poll.lock',
610
+ ];
611
+ try {
612
+ mkdirSync(join(repoRoot, '.ai/cezar'), { recursive: true });
613
+ const current = existsSync(path) ? readFileSync(path, 'utf8') : '';
614
+ const lines = current.split('\n');
615
+ const missing = wanted.filter((w) => !lines.includes(w));
616
+ if (missing.length > 0) {
617
+ const glue = current && !current.endsWith('\n') ? '\n' : '';
618
+ writeFileSync(path, `${current}${glue}${missing.join('\n')}\n`, 'utf8');
619
+ }
620
+ }
621
+ catch {
622
+ // non-fatal
623
+ }
624
+ }
625
+ /** Own package name — for the npm-registry update check (#368). */
626
+ function readOwnName() {
627
+ try {
628
+ const here = dirname(fileURLToPath(import.meta.url));
629
+ const pkg = JSON.parse(readFileSync(join(here, '..', 'package.json'), 'utf8'));
630
+ return pkg.name ?? '@wjarka/cezarion';
631
+ }
632
+ catch {
633
+ return '@wjarka/cezarion';
634
+ }
635
+ }
636
+ function readOwnVersion() {
637
+ try {
638
+ const here = dirname(fileURLToPath(import.meta.url));
639
+ const pkg = JSON.parse(readFileSync(join(here, '..', 'package.json'), 'utf8'));
640
+ return pkg.version ?? '0.0.0';
641
+ }
642
+ catch {
643
+ return '0.0.0';
644
+ }
645
+ }
646
+ function openUrl(url) {
647
+ const cmd = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'cmd' : 'xdg-open';
648
+ const args = process.platform === 'win32' ? ['/c', 'start', '', url] : [url];
649
+ try {
650
+ const child = spawn(cmd, args, { stdio: 'ignore', detached: true });
651
+ // A missing opener (e.g. no `xdg-open` on a headless Linux VPS) surfaces
652
+ // asynchronously as an 'error' event, NOT a synchronous throw — without a
653
+ // listener Node promotes it to an unhandled error and hard-crashes the whole
654
+ // process, even though the cockpit is already serving. Swallow it: the URL is
655
+ // printed above, so a browser-less host just doesn't auto-open.
656
+ child.on('error', () => { });
657
+ child.unref();
658
+ }
659
+ catch {
660
+ // the printed URL is enough
661
+ }
662
+ }
663
+ function previewJson(input) {
664
+ try {
665
+ const s = JSON.stringify(input);
666
+ return s.length > 120 ? `${s.slice(0, 117)}…` : s;
667
+ }
668
+ catch {
669
+ return '';
670
+ }
671
+ }
672
+ function firstLine(s) {
673
+ const line = s.split('\n')[0] ?? '';
674
+ return line.length > 120 ? `${line.slice(0, 117)}…` : line;
675
+ }
676
+ main().catch((err) => {
677
+ console.error(err instanceof Error ? err.message : String(err));
678
+ process.exit(1);
679
+ });
680
+ //# sourceMappingURL=index.js.map