@uniqbit/mate-core 0.21.1 → 1.0.0-canary.10

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 (467) hide show
  1. package/claude-capability-plugins/companion-mentions/.claude-plugin/plugin.json +1 -1
  2. package/claude-plugin/hooks/hooks.json +32 -1
  3. package/claude-plugin/hooks/workflow-turn.mjs +68 -0
  4. package/opencode-plugin/src/companion.ts +6 -0
  5. package/opencode-plugin/src/server.ts +24 -0
  6. package/package.json +9 -4
  7. package/src/cli/commands/artifact/apply-context.ts +1 -0
  8. package/src/cli/commands/artifact/artifact.ts +16 -0
  9. package/src/cli/commands/artifact/delivery/archive.ts +37 -112
  10. package/src/cli/commands/artifact/delivery/branch-flags.ts +19 -1
  11. package/src/cli/commands/artifact/delivery/environment.ts +30 -90
  12. package/src/cli/commands/artifact/delivery/link.ts +26 -26
  13. package/src/cli/commands/artifact/delivery/output.ts +27 -4
  14. package/src/cli/commands/artifact/delivery/resolve.ts +102 -0
  15. package/src/cli/commands/artifact/delivery/submit.ts +171 -0
  16. package/src/cli/commands/artifact/delivery/take.ts +46 -0
  17. package/src/cli/commands/artifact/extract-repo-name.ts +1 -1
  18. package/src/cli/commands/artifact/finish/command.ts +486 -55
  19. package/src/cli/commands/artifact/finish/engine.ts +87 -69
  20. package/src/cli/commands/artifact/finish/finisher.ts +5 -12
  21. package/src/cli/commands/artifact/finish/git.ts +9 -10
  22. package/src/cli/commands/artifact/finish/openspec.ts +21 -174
  23. package/src/cli/commands/artifact/finish/secret-scan.ts +5 -43
  24. package/src/cli/commands/artifact/finish/worktree-cleanup.ts +57 -7
  25. package/src/cli/commands/artifact/pending/command.ts +187 -10
  26. package/src/cli/commands/artifact/pending/discovery.ts +7 -11
  27. package/src/cli/commands/artifact/project/command.ts +59 -0
  28. package/src/cli/commands/cap/tokensave.ts +2 -2
  29. package/src/cli/commands/companion/hub.ts +11 -6
  30. package/src/cli/commands/companion/link.ts +173 -46
  31. package/src/cli/commands/companion/list.ts +70 -14
  32. package/src/cli/commands/companion/sync.ts +18 -0
  33. package/src/cli/commands/companion/update.ts +4 -3
  34. package/src/cli/commands/doctor.ts +84 -4
  35. package/src/cli/commands/friction.ts +558 -0
  36. package/src/cli/commands/install.ts +9 -4
  37. package/src/cli/commands/plugin/install.ts +82 -35
  38. package/src/cli/commands/studio/companion-add.ts +12 -27
  39. package/src/cli/commands/studio/connection.ts +53 -0
  40. package/src/{lib/factory/outcomes/sessions.ts → cli/commands/studio/live-sessions.ts} +7 -5
  41. package/src/cli/commands/studio/mcp-manager.ts +162 -0
  42. package/src/cli/commands/studio/payload.ts +172 -17
  43. package/src/cli/commands/studio/reports.ts +19 -18
  44. package/src/cli/commands/studio/routes.ts +8 -24
  45. package/src/cli/commands/studio/selection.ts +13 -4
  46. package/src/cli/commands/studio/server.ts +267 -243
  47. package/src/cli/commands/studio/service-host.ts +269 -0
  48. package/src/cli/commands/studio/services.ts +53 -34
  49. package/src/cli/commands/studio/studio-app.ts +1 -0
  50. package/src/cli/commands/studio/terminal.ts +1 -1
  51. package/src/cli/commands/studio/vault.ts +41 -40
  52. package/src/cli/commands/studio/views/model.ts +1 -9
  53. package/src/cli/commands/studio/views/vault/markdown-tree.ts +6 -5
  54. package/src/cli/commands/triage.ts +172 -0
  55. package/src/cli/commands/vscode/release-vsix.json +2 -2
  56. package/src/cli/commands/workflow/workflow.ts +516 -0
  57. package/src/cli/commands/working/cleanup.ts +1 -18
  58. package/src/cli/companion-link-wizard.tsx +158 -91
  59. package/src/cli/install-plan.tsx +3 -0
  60. package/src/cli/main.ts +106 -26
  61. package/src/cli/plugin-commands.ts +6 -1
  62. package/src/cli/repo-list-table.tsx +73 -37
  63. package/src/cli/usage.ts +30 -9
  64. package/src/create-mate.ts +15 -6
  65. package/src/distribution.ts +2 -0
  66. package/src/factory-host.ts +75 -0
  67. package/src/hooks/companion-instructions.ts +19 -8
  68. package/src/hooks/hook-io.ts +3 -1
  69. package/src/hooks/session-banner.ts +25 -0
  70. package/src/hooks/validate-artifact-path.ts +73 -22
  71. package/src/hooks/workflow-turn.ts +219 -0
  72. package/src/index.ts +1 -0
  73. package/src/lib/apply-context/fingerprint.ts +2 -1
  74. package/src/lib/apply-context/protocol.ts +2 -2
  75. package/src/lib/artifact-trailer.ts +27 -0
  76. package/src/lib/change-layout.ts +83 -38
  77. package/src/lib/delivery/branch-template.ts +4 -12
  78. package/src/lib/delivery/checkout.ts +3 -2
  79. package/src/lib/delivery/environment.ts +129 -7
  80. package/src/lib/delivery/merge-git.ts +312 -28
  81. package/src/lib/delivery/overlap.ts +81 -16
  82. package/src/lib/delivery/record-delivery.ts +102 -9
  83. package/src/lib/delivery/record.ts +186 -24
  84. package/src/lib/delivery/refresh.ts +241 -152
  85. package/src/lib/delivery/remote.ts +66 -0
  86. package/src/lib/delivery/repository-access.ts +30 -66
  87. package/src/lib/delivery/stages.ts +83 -50
  88. package/src/lib/delivery/staging/apply-chain.ts +182 -0
  89. package/src/lib/delivery/staging/artifact-type.ts +101 -0
  90. package/src/lib/delivery/staging/declared-type.ts +277 -0
  91. package/src/lib/delivery/staging/linked-merges.ts +175 -0
  92. package/src/lib/delivery/staging/naming.ts +67 -0
  93. package/src/lib/delivery/staging/openspec-type.ts +166 -0
  94. package/src/lib/delivery/staging/pending-edit.ts +291 -0
  95. package/src/lib/delivery/staging/pending.ts +922 -0
  96. package/src/lib/delivery/staging/preflight.ts +239 -0
  97. package/src/lib/delivery/staging/project.ts +512 -0
  98. package/src/lib/delivery/staging/publish.ts +1024 -0
  99. package/src/lib/delivery/staging/refs.ts +258 -0
  100. package/src/lib/delivery/staging/registry.ts +73 -0
  101. package/src/lib/delivery/staging/replay.ts +310 -0
  102. package/src/lib/delivery/staging/requirement-blocks.ts +10 -0
  103. package/src/lib/delivery/staging/resolve.ts +264 -0
  104. package/src/lib/delivery/staging/settle-linked.ts +176 -0
  105. package/src/lib/delivery/staging/submit.ts +1050 -0
  106. package/src/lib/delivery/staging/worktree.ts +130 -0
  107. package/src/lib/delivery/submit-change.ts +569 -0
  108. package/src/lib/friction/describe.ts +42 -0
  109. package/src/lib/friction/fields.ts +60 -0
  110. package/src/lib/friction/mark.ts +194 -0
  111. package/src/lib/friction/view/model.ts +67 -0
  112. package/src/lib/friction/view/read.ts +145 -0
  113. package/src/lib/friction/view/select.ts +54 -0
  114. package/src/lib/git-key.ts +15 -0
  115. package/src/lib/install.ts +2 -0
  116. package/src/lib/mcp-manager/resolve.ts +88 -0
  117. package/src/lib/mcp-manager/store.ts +133 -0
  118. package/src/lib/mcp-manager/types.ts +72 -0
  119. package/src/lib/mcp-manager/validate.ts +242 -0
  120. package/src/lib/openspec-canonical-frontmatter.ts +159 -0
  121. package/src/lib/openspec-cli.ts +10 -5
  122. package/src/lib/orchestrator/adapters/base.ts +31 -20
  123. package/src/lib/orchestrator/adapters/claude.ts +21 -7
  124. package/src/lib/orchestrator/adapters/opencode.ts +4 -0
  125. package/src/lib/orchestrator/companion-git-sync.ts +152 -16
  126. package/src/lib/orchestrator/config-store.ts +30 -7
  127. package/src/lib/orchestrator/engine-floor.ts +16 -4
  128. package/src/lib/orchestrator/engine-guard.ts +7 -1
  129. package/src/lib/orchestrator/framework-context.ts +15 -1
  130. package/src/lib/orchestrator/projection-claude-links.ts +1 -0
  131. package/src/lib/orchestrator/refresh-working-claude-links.ts +1 -0
  132. package/src/lib/orchestrator/repo-local-store.ts +14 -0
  133. package/src/lib/orchestrator/repository-link.ts +80 -52
  134. package/src/lib/orchestrator/root-context.ts +40 -7
  135. package/src/lib/orchestrator/session-prepare.ts +11 -1
  136. package/src/lib/orchestrator/types.ts +4 -0
  137. package/src/lib/orchestrator/umbrella-checkouts.ts +4 -4
  138. package/src/lib/package-paths.ts +23 -15
  139. package/src/lib/prebuilt-workspace-prepare.ts +2 -1
  140. package/src/lib/prebuilt-workspace.ts +1 -0
  141. package/src/lib/session-attribution.ts +3 -7
  142. package/src/lib/session-state.ts +3 -2
  143. package/src/lib/skills-cli.ts +38 -0
  144. package/src/lib/tool-manifest.ts +73 -0
  145. package/src/lib/triage/context.ts +312 -0
  146. package/src/lib/triage/launch.ts +52 -0
  147. package/src/lib/triage/prepare.ts +112 -0
  148. package/src/lib/triage/session.ts +126 -0
  149. package/src/lib/workflow/declaration.ts +6 -0
  150. package/src/lib/workflow/handoff.ts +90 -0
  151. package/src/lib/workflow/hook-trust.ts +108 -0
  152. package/src/lib/workflow/position.ts +524 -0
  153. package/src/lib/workflow/report.ts +79 -0
  154. package/src/lib/workflow/work.ts +106 -0
  155. package/src/lib/workset/factory-local.ts +2 -2
  156. package/src/lib/workset/repositories.ts +2 -2
  157. package/src/lib/workset/stage.ts +4 -2
  158. package/src/lib/workset/stages.ts +64 -4
  159. package/src/lib/workset/worktree.ts +32 -14
  160. package/src/opencode/companion-hooks.ts +63 -14
  161. package/src/opencode/projected-guidance.ts +7 -2
  162. package/src/opencode/turn-hook.ts +241 -0
  163. package/src/playbooks/companion-guidance.ts +7 -4
  164. package/src/plugin-api.ts +48 -0
  165. package/src/runtime/artifact-trailers.ts +63 -0
  166. package/src/runtime/claude-hook-group.ts +2 -0
  167. package/src/runtime/command-arg.ts +15 -0
  168. package/src/runtime/command-friction.ts +97 -0
  169. package/src/runtime/companion-git-state.ts +155 -10
  170. package/src/runtime/companion-git.ts +86 -11
  171. package/src/runtime/companion-guidance.ts +120 -17
  172. package/src/runtime/companion-instructions.ts +1 -1
  173. package/src/runtime/companion-sync.ts +109 -21
  174. package/src/runtime/env-names.ts +2 -2
  175. package/src/runtime/env.ts +7 -6
  176. package/src/runtime/forge-remote.ts +54 -0
  177. package/src/runtime/friction-fingerprint.ts +35 -0
  178. package/src/runtime/friction-log.ts +376 -0
  179. package/src/runtime/friction-recorder.ts +212 -0
  180. package/src/runtime/friction-retention.ts +1 -0
  181. package/src/runtime/friction-state.ts +110 -0
  182. package/src/runtime/friction-switch.ts +26 -0
  183. package/src/runtime/friction-vocabulary.ts +42 -0
  184. package/src/runtime/git-layout.ts +21 -7
  185. package/src/runtime/git-tracked.ts +13 -2
  186. package/src/runtime/json-fields.ts +8 -0
  187. package/src/runtime/pending-records.ts +533 -0
  188. package/src/runtime/projected-guidance.ts +8 -3
  189. package/src/runtime/publication-secret-scan.ts +45 -0
  190. package/src/runtime/secret-patterns.ts +7 -5
  191. package/src/runtime/secret-values.ts +16 -0
  192. package/src/runtime/session-id.ts +24 -0
  193. package/src/runtime/session-prepare-runner.ts +3 -0
  194. package/src/runtime/skill-prefix.ts +75 -0
  195. package/src/runtime/submitted-arrivals.ts +547 -0
  196. package/src/runtime/turn-state.d.mts +14 -0
  197. package/src/runtime/turn-state.mjs +93 -0
  198. package/src/runtime/umbrella-children.ts +52 -0
  199. package/src/runtime/umbrella-folder.ts +31 -3
  200. package/src/runtime/workflow/change-folders.ts +66 -0
  201. package/src/runtime/workflow/declaration.ts +720 -0
  202. package/src/runtime/workflow/globs.ts +85 -0
  203. package/src/runtime/workflow/next-handoff-process.ts +99 -0
  204. package/src/runtime/workflow/turn.ts +311 -0
  205. package/src/runtime/workflow/workflow.ts +262 -0
  206. package/src/studio.ts +113 -23
  207. package/src/templates/capabilities/openspec-cap/{mate-v1 → mate-full}/schema.yaml +3 -3
  208. package/src/templates/capabilities/openspec-cap/{mate-v1 → mate-full}/templates/design.md +1 -1
  209. package/src/templates/capabilities/openspec-cap/{mate-v1 → mate-full}/templates/proposal.md +1 -1
  210. package/src/templates/capabilities/openspec-cap/{mate-v1 → mate-full}/templates/tasks.md +1 -1
  211. package/src/templates/capabilities/openspec-cap/mate-minimal/schema.yaml +7 -3
  212. package/src/templates/capabilities/react-doctor/mate-react-doctor/SKILL.md +28 -0
  213. package/src/templates/mate-skills/agents/mate-apply-change/SKILL.md +84 -28
  214. package/src/templates/mate-skills/agents/mate-apply-change/references/openspec-apply-change.md +1 -1
  215. package/src/templates/mate-skills/agents/mate-archive-change/SKILL.md +30 -68
  216. package/src/templates/mate-skills/agents/mate-backfill-spec/SKILL.md +23 -1
  217. package/src/templates/mate-skills/agents/mate-clarify-intent/SKILL.md +39 -8
  218. package/src/templates/mate-skills/agents/mate-domain-modeling/SKILL.md +38 -0
  219. package/src/templates/mate-skills/agents/mate-explore-change/SKILL.md +65 -12
  220. package/src/templates/mate-skills/agents/mate-grill-me/SKILL.md +28 -0
  221. package/src/templates/mate-skills/agents/mate-grill-with-docs/SKILL.md +28 -0
  222. package/src/templates/mate-skills/agents/mate-grilling/SKILL.md +25 -0
  223. package/src/templates/mate-skills/agents/mate-interview-me/SKILL.md +28 -0
  224. package/src/templates/mate-skills/agents/mate-propose-change/SKILL.md +68 -28
  225. package/src/templates/mate-skills/agents/mate-propose-change/references/mate-revise.md +13 -7
  226. package/src/templates/mate-skills/agents/mate-propose-change/references/openspec-update-change.md +1 -1
  227. package/src/templates/mate-skills/agents/mate-publish-artifact/SKILL.md +136 -86
  228. package/src/templates/mate-skills/agents/mate-publish-artifact/references/openspec.md +111 -100
  229. package/src/templates/mate-skills/agents/mate-show-me/SKILL.md +28 -3
  230. package/src/templates/mate-skills/agents/mate-simplify-code/SKILL.md +39 -5
  231. package/src/templates/mate-skills/agents/mate-submit-change/SKILL.md +138 -0
  232. package/src/templates/mate-skills/claude/mate-apply-change/SKILL.md +84 -28
  233. package/src/templates/mate-skills/claude/mate-apply-change/references/openspec-apply-change.md +1 -1
  234. package/src/templates/mate-skills/claude/mate-archive-change/SKILL.md +30 -68
  235. package/src/templates/mate-skills/claude/mate-backfill-spec/SKILL.md +23 -1
  236. package/src/templates/mate-skills/claude/mate-clarify-intent/SKILL.md +39 -8
  237. package/src/templates/mate-skills/claude/mate-domain-modeling/SKILL.md +38 -0
  238. package/src/templates/mate-skills/claude/mate-explore-change/SKILL.md +65 -12
  239. package/src/templates/mate-skills/claude/mate-grill-me/SKILL.md +28 -0
  240. package/src/templates/mate-skills/claude/mate-grill-with-docs/SKILL.md +28 -0
  241. package/src/templates/mate-skills/claude/mate-grilling/SKILL.md +25 -0
  242. package/src/templates/mate-skills/claude/mate-interview-me/SKILL.md +28 -0
  243. package/src/templates/mate-skills/claude/mate-propose-change/SKILL.md +68 -28
  244. package/src/templates/mate-skills/claude/mate-propose-change/references/mate-revise.md +13 -7
  245. package/src/templates/mate-skills/claude/mate-propose-change/references/openspec-update-change.md +1 -1
  246. package/src/templates/mate-skills/claude/mate-publish-artifact/SKILL.md +136 -86
  247. package/src/templates/mate-skills/claude/mate-publish-artifact/references/openspec.md +111 -100
  248. package/src/templates/mate-skills/claude/mate-show-me/SKILL.md +28 -3
  249. package/src/templates/mate-skills/claude/mate-simplify-code/SKILL.md +39 -5
  250. package/src/templates/mate-skills/claude/mate-submit-change/SKILL.md +138 -0
  251. package/src/templates/mate-skills/openspec-references.ts +3 -2
  252. package/src/templates/triage/PLAYBOOK.md +120 -0
  253. package/src/tools/setup/__snapshots__/runtime-surface-golden.test.ts.snap +678 -170
  254. package/src/tools/setup/capabilities/graphify.ts +23 -1
  255. package/src/tools/setup/capabilities/mcp-manager.ts +73 -0
  256. package/src/tools/setup/capabilities/openspec.ts +54 -15
  257. package/src/tools/setup/capabilities/rtk.ts +47 -94
  258. package/src/tools/setup/capabilities/tokensave.ts +79 -56
  259. package/src/tools/setup/context-services.ts +35 -6
  260. package/src/tools/setup/dynamic-plugins/api.ts +38 -0
  261. package/src/tools/setup/dynamic-plugins/audiences.ts +31 -16
  262. package/src/tools/setup/dynamic-plugins/host.ts +2 -32
  263. package/src/tools/setup/dynamic-plugins/hydrate.ts +32 -14
  264. package/src/tools/setup/dynamic-plugins/install.ts +2 -0
  265. package/src/tools/setup/dynamic-plugins/installed.ts +73 -0
  266. package/src/tools/setup/dynamic-plugins/loader.ts +12 -10
  267. package/src/tools/setup/dynamic-plugins/local.ts +492 -0
  268. package/src/tools/setup/dynamic-plugins/paths.ts +34 -6
  269. package/src/tools/setup/dynamic-plugins/verify.ts +34 -14
  270. package/src/tools/setup/dynamic-plugins/workspaces.ts +21 -12
  271. package/src/tools/setup/engine.ts +75 -4
  272. package/src/tools/setup/mate.ts +28 -1
  273. package/src/tools/setup/package-managers/bun.ts +8 -8
  274. package/src/tools/setup/plugin.ts +28 -1
  275. package/src/tools/setup/plugins/gitignore.ts +45 -12
  276. package/src/tools/setup/plugins/guidance.ts +4 -2
  277. package/src/tools/setup/providers/claude-format.ts +39 -2
  278. package/src/tools/setup/providers/claude-plugin-hooks.ts +18 -0
  279. package/src/tools/setup/providers/claude.ts +56 -6
  280. package/src/tools/setup/providers/opencode-format.ts +13 -3
  281. package/src/tools/setup/providers/opencode.ts +7 -18
  282. package/src/tools/setup/providers/relative-path-warnings.ts +26 -0
  283. package/src/tools/setup/service-registry.ts +69 -0
  284. package/src/tools/setup/service.ts +245 -0
  285. package/src/tools/setup/utils.ts +34 -4
  286. package/src/tools/setup.ts +16 -2
  287. package/studio-dist/client/assets/DialogTitle-B_G47-lk.js +1 -0
  288. package/studio-dist/client/assets/app-0NoFqMou.css +2 -0
  289. package/studio-dist/client/assets/button-D_0295cs.js +1 -0
  290. package/studio-dist/client/assets/cn-Cx_D6I3u.js +1 -0
  291. package/studio-dist/client/assets/combobox-D0iPQP50.js +1 -0
  292. package/studio-dist/client/assets/{companion-view-CrabvxS8.js → companion-view-D3A76MLj.js} +1 -1
  293. package/studio-dist/client/assets/fields-Ctheim1h.js +1 -0
  294. package/studio-dist/client/assets/friction-Cn9n_zBA.js +1 -0
  295. package/studio-dist/client/assets/getting-started-DgoVWbWo.js +1 -0
  296. package/studio-dist/client/assets/{getting-started-D6kgWwWZ.js → getting-started-MmLqvy01.js} +1 -1
  297. package/studio-dist/client/assets/getting-started._topic-DBF0khhz.js +1 -0
  298. package/studio-dist/client/assets/getting-started.index-BRdAVqIh.js +1 -0
  299. package/studio-dist/client/assets/graph-BVRdq46V.js +2 -0
  300. package/studio-dist/client/assets/{graph-canvas-Ba37Y5AE.js → graph-canvas-BNzd-eVb.js} +1 -1
  301. package/studio-dist/client/assets/guides-DY1W9LRs.js +1 -0
  302. package/studio-dist/client/assets/index-CuTIc9yd.js +40 -0
  303. package/studio-dist/client/assets/{markdown-view-BOX6x0rL.js → markdown-view-BqZQkk_k.js} +1 -1
  304. package/studio-dist/client/assets/mcp-CIFxmDs0.js +4 -0
  305. package/studio-dist/client/assets/panel-DafanLQ4.js +1 -0
  306. package/studio-dist/client/assets/plugins._service._view-xSRLxHNM.js +1 -0
  307. package/studio-dist/client/assets/prepaint-C--F50QZ.js +27 -0
  308. package/studio-dist/client/assets/{queries-RvHeXY12.js → queries-ByCoiacy.js} +1 -1
  309. package/studio-dist/client/assets/react-BYUSgtBs.js +1 -0
  310. package/studio-dist/client/assets/reports-Diryyked.js +1 -0
  311. package/studio-dist/client/assets/routes-DbRwPd55.js +1 -0
  312. package/studio-dist/client/assets/search-BDKQRwa5.js +1 -0
  313. package/studio-dist/client/assets/select-_9JT3hpU.js +1 -0
  314. package/studio-dist/client/assets/skills-D5a6ybQM.js +1 -0
  315. package/studio-dist/client/assets/{specs-B0ldF_6J.js → specs-COAWUTog.js} +1 -1
  316. package/studio-dist/client/assets/specs-view-9eTn9TcN.js +1 -0
  317. package/studio-dist/client/assets/steps-BS588WAV.js +1 -0
  318. package/studio-dist/client/assets/store-3cffhIO6.js +1 -0
  319. package/studio-dist/client/assets/studio-CG9eioSx.js +100 -0
  320. package/studio-dist/client/assets/studio-queries-BS1yR7Wc.js +2 -0
  321. package/studio-dist/client/assets/{usage-C2QJ_0IZ.js → usage-Ccl4d7w0.js} +15 -15
  322. package/studio-dist/client/assets/useAnchoredPopupScrollLock-D_y83VP7.js +1 -0
  323. package/studio-dist/client/assets/useBlocker-BQOfcu_f.js +1 -0
  324. package/studio-dist/client/assets/useMutation-BDmS2V6y.js +1 -0
  325. package/studio-dist/client/assets/usePopupHandleStore-BcqpNR-F.js +1 -0
  326. package/studio-dist/client/assets/vault-C1tOhQMe.js +1 -0
  327. package/studio-dist/client/assets/warnings-BZ_X1nkO.js +1 -0
  328. package/studio-dist/client/assets/workflow-Cm2fsnly.js +1 -0
  329. package/studio-dist/server/assets/DialogTitle-KSVhF_7V.js +421 -0
  330. package/studio-dist/server/assets/{__23tanstack-start-server-fn-resolver-Bn896ZYj.js → __23tanstack-start-server-fn-resolver-QQnIXyKi.js} +40 -28
  331. package/studio-dist/server/assets/_tanstack-start-manifest_v.js +84 -74
  332. package/studio-dist/server/assets/{button-CgOIVdmD.js → button-C7EMLaX6.js} +229 -5527
  333. package/studio-dist/server/assets/cn-D7uJiH_O.js +5528 -0
  334. package/studio-dist/server/assets/{combobox-DV_s9W0s.js → combobox-Dc4_y20Y.js} +6 -5
  335. package/studio-dist/server/assets/{companion-view-BKVXD3TO.js → companion-view-CrSi37Mb.js} +2 -2
  336. package/studio-dist/server/assets/{companions-C7fctnU9.js → companions-CDSuLqA4.js} +1 -1
  337. package/studio-dist/server/assets/{fields-BbieQTD0.js → fields-BxBN6-Dz.js} +10 -2
  338. package/studio-dist/server/assets/friction-B1K8Kp8r.js +62 -0
  339. package/studio-dist/server/assets/friction-Vl3B6THL.js +943 -0
  340. package/studio-dist/server/assets/{getting-started-CRxMWorQ.js → getting-started-B3lu5W7M.js} +2 -2
  341. package/studio-dist/server/assets/{getting-started._topic-DJKQAzYl.js → getting-started._topic-EYtxZM-Y.js} +2 -2
  342. package/studio-dist/server/assets/{getting-started.index-D84gec1t.js → getting-started.index-CTaXYycH.js} +2 -2
  343. package/studio-dist/server/assets/{graph-DDZzXM1L.js → graph-Bhmk7H8V.js} +1 -1
  344. package/studio-dist/server/assets/{graph-CSje3029.js → graph-D3fXCaKt.js} +8 -8
  345. package/studio-dist/server/assets/{graph-canvas-22bWB5-2.js → graph-canvas-DIvTodML.js} +2 -2
  346. package/studio-dist/server/assets/{guides-IE-19POz.js → guides-BZWFpJl-.js} +1 -1
  347. package/studio-dist/server/assets/{guides-D9dk1Frq.js → guides-CHBkRO6R.js} +1 -1
  348. package/studio-dist/server/assets/{guides.server-vcYRY5wx.js → guides.server-DX9KRkcK.js} +1 -1
  349. package/studio-dist/server/assets/{markdown-view-BR8dJ7aR.js → markdown-view-qrCSkVta.js} +1 -1
  350. package/studio-dist/server/assets/mcp-Ljf4simO.js +1103 -0
  351. package/studio-dist/server/assets/mcp-manager-DohRwmJU.js +50 -0
  352. package/studio-dist/server/assets/{panel-BR_t9iMM.js → panel-CAwz4mKp.js} +6 -4
  353. package/studio-dist/server/assets/plugins._service._view-DUpAo5D_.js +97 -0
  354. package/studio-dist/server/assets/prepaint-BxZ-pU7t.js +45 -0
  355. package/studio-dist/server/assets/{queries-DWoTin-q.js → queries-W4LXzTnT.js} +1 -1
  356. package/studio-dist/server/assets/react-CiBZPDs8.js +45 -0
  357. package/studio-dist/server/assets/{reports-CQ9qQ1-n.js → reports-BVNSPHU3.js} +13 -7
  358. package/studio-dist/server/assets/{reports-dYDEoBeq.js → reports-CGG_wRN5.js} +1 -1
  359. package/studio-dist/server/assets/{router-DkRHNTpE.js → router-KH1x6ryF.js} +1039 -1096
  360. package/studio-dist/server/assets/{routes-B6GfOew4.js → routes-Bl90FC4R.js} +333 -38
  361. package/studio-dist/server/assets/search-BjG5f16n.js +110 -0
  362. package/studio-dist/server/assets/{select-Af7Wibii.js → select-B8q9tLbl.js} +5 -4
  363. package/studio-dist/server/assets/{shell-Hq-hXgnT.js → shell-C5emwofr.js} +12 -3
  364. package/studio-dist/server/assets/{skills-B7nEuVbx.js → skills-10l0eCfP.js} +8 -8
  365. package/studio-dist/server/assets/{skills-B_YYL7q8.js → skills-vG6TTvP1.js} +1 -1
  366. package/studio-dist/server/assets/{specs-BpLUFntA.js → specs-C1P2BEao.js} +4 -4
  367. package/studio-dist/server/assets/{specs-view-0peMVd22.js → specs-view-csUBtMWU.js} +10 -10
  368. package/studio-dist/server/assets/{steps-D56DApvK.js → steps-T4wXftgd.js} +88 -45
  369. package/studio-dist/server/assets/store-CWlRjv9s.js +93 -0
  370. package/studio-dist/server/assets/{studio-CAcKp3bM.js → studio-D-ZPWSMv.js} +1567 -59
  371. package/studio-dist/server/assets/{studio-queries-BtRGzDdh.js → studio-queries-DC273ifg.js} +66 -124
  372. package/studio-dist/server/assets/{usage-COdjd1gD.js → usage-CT3IWLJc.js} +13 -30
  373. package/studio-dist/server/assets/{usage-f6pqE1tm.js → usage-D4t_ibR8.js} +1 -1
  374. package/studio-dist/server/assets/{useAnchoredPopupScrollLock-DlBKHRw7.js → useAnchoredPopupScrollLock-BchJDJYg.js} +2 -2
  375. package/studio-dist/server/assets/useBlocker-CQtANHK8.js +111 -0
  376. package/studio-dist/server/assets/{useMutation-DzTZGenE.js → useMutation-0HbcKUsQ.js} +2 -2
  377. package/studio-dist/server/assets/usePopupHandleStore-B3SNGTic.js +26 -0
  378. package/studio-dist/server/assets/{vault-BDuIUq0F.js → vault-BIytrudF.js} +10 -117
  379. package/studio-dist/server/assets/{vault-BVLp6zu3.js → vault-MINXmyXA.js} +1 -1
  380. package/studio-dist/server/assets/{views-flRUr21z.js → views-DrmY_3J5.js} +7 -4
  381. package/studio-dist/server/assets/{warnings-CDy9pdgL.js → warnings-BVZCDbIz.js} +2 -2
  382. package/studio-dist/server/assets/{workflow-D9GKI2EV.js → workflow-DFdqnMtW.js} +57 -50
  383. package/studio-dist/server/server.js +2 -2
  384. package/tool-manifest.yaml +85 -0
  385. package/src/cli/commands/factory/factory.ts +0 -311
  386. package/src/cli/commands/studio/factory-credential.ts +0 -35
  387. package/src/cli/commands/studio/factory-git-tokens.ts +0 -40
  388. package/src/cli/commands/studio/factory-relay.ts +0 -18
  389. package/src/cli/commands/studio/repository-add.ts +0 -116
  390. package/src/cli/commands/studio/workset-session.ts +0 -164
  391. package/src/lib/delivery/archive-change.ts +0 -165
  392. package/src/lib/delivery/forge.ts +0 -279
  393. package/src/lib/delivery/token.ts +0 -24
  394. package/src/lib/factory/attach-client.ts +0 -123
  395. package/src/lib/factory/attach.ts +0 -178
  396. package/src/lib/factory/broker.ts +0 -187
  397. package/src/lib/factory/bun-commands.ts +0 -39
  398. package/src/lib/factory/client.ts +0 -113
  399. package/src/lib/factory/clone-url.ts +0 -39
  400. package/src/lib/factory/command.ts +0 -77
  401. package/src/lib/factory/credential-store.ts +0 -153
  402. package/src/lib/factory/frames.ts +0 -77
  403. package/src/lib/factory/git-auth.ts +0 -61
  404. package/src/lib/factory/git-credential-store.ts +0 -181
  405. package/src/lib/factory/ids.ts +0 -68
  406. package/src/lib/factory/outcomes/actions.ts +0 -130
  407. package/src/lib/factory/outcomes/index.ts +0 -457
  408. package/src/lib/factory/outcomes/lifecycle.ts +0 -212
  409. package/src/lib/factory/outcomes/runs.ts +0 -81
  410. package/src/lib/factory/prepare.ts +0 -55
  411. package/src/lib/factory/pty.ts +0 -103
  412. package/src/lib/factory/runner/companion-context.ts +0 -178
  413. package/src/lib/factory/runner/control.ts +0 -92
  414. package/src/lib/factory/runner/harness-agent.ts +0 -250
  415. package/src/lib/factory/runner/live.ts +0 -159
  416. package/src/lib/factory/runner/questions.ts +0 -22
  417. package/src/lib/factory/runner/rank.ts +0 -26
  418. package/src/lib/factory/runner/run-policy.ts +0 -12
  419. package/src/lib/factory/runner/run.ts +0 -199
  420. package/src/lib/factory/runner/scheduler.ts +0 -498
  421. package/src/lib/factory/runner/state.ts +0 -233
  422. package/src/lib/factory/runner/workflow.ts +0 -546
  423. package/src/lib/factory/runtime.ts +0 -1081
  424. package/src/lib/factory/sandbox.ts +0 -292
  425. package/src/lib/factory/worktree-branch.ts +0 -17
  426. package/src/templates/capabilities/openspec-cap/mate-v1/templates/explore-brief.md +0 -25
  427. package/studio-dist/client/assets/app-D9cw6szy.css +0 -2
  428. package/studio-dist/client/assets/artifacts-WD2ZXYrx.js +0 -1
  429. package/studio-dist/client/assets/button-Br0O1sXw.js +0 -1
  430. package/studio-dist/client/assets/combobox-DA7RAUUZ.js +0 -1
  431. package/studio-dist/client/assets/factory-DGS0E16C.js +0 -6
  432. package/studio-dist/client/assets/fields-6aXBpFhJ.js +0 -1
  433. package/studio-dist/client/assets/getting-started-Clde4w6P.js +0 -1
  434. package/studio-dist/client/assets/getting-started._topic-BiunccbT.js +0 -1
  435. package/studio-dist/client/assets/getting-started.index-DpiNoGw8.js +0 -1
  436. package/studio-dist/client/assets/graph-B_TCBVbu.js +0 -2
  437. package/studio-dist/client/assets/guides-Du_RtJxP.js +0 -1
  438. package/studio-dist/client/assets/index-Df8L1LQa.js +0 -40
  439. package/studio-dist/client/assets/panel-dbmCx7Mx.js +0 -1
  440. package/studio-dist/client/assets/react-3QStrcDO.js +0 -27
  441. package/studio-dist/client/assets/report-url-XRL0x1SY.js +0 -1
  442. package/studio-dist/client/assets/reports-r3IK7Doz.js +0 -1
  443. package/studio-dist/client/assets/routes-C0A5LTFc.js +0 -1
  444. package/studio-dist/client/assets/select-CnaMd617.js +0 -1
  445. package/studio-dist/client/assets/skills-CzjzHpBT.js +0 -1
  446. package/studio-dist/client/assets/specs-view-BnCLA0gW.js +0 -1
  447. package/studio-dist/client/assets/spinner-Dcm3fqK1.js +0 -1
  448. package/studio-dist/client/assets/steps-C0p2N1Pb.js +0 -1
  449. package/studio-dist/client/assets/store-Dw34catY.js +0 -1
  450. package/studio-dist/client/assets/studio-Cpz_HRHp.js +0 -100
  451. package/studio-dist/client/assets/studio-queries-ibmpFo6R.js +0 -2
  452. package/studio-dist/client/assets/useAnchoredPopupScrollLock-Bj-FWb8z.js +0 -1
  453. package/studio-dist/client/assets/useMutation-aAr2uiay.js +0 -1
  454. package/studio-dist/client/assets/vault-BGcxkSIY.js +0 -1
  455. package/studio-dist/client/assets/warnings-R1cE1rLf.js +0 -1
  456. package/studio-dist/client/assets/workflow-C2qTrMDH.js +0 -1
  457. package/studio-dist/server/assets/actions-DYSv-9VV.js +0 -60
  458. package/studio-dist/server/assets/artifacts-DnF9L3dZ.js +0 -216
  459. package/studio-dist/server/assets/factory-C7Ybg0xG.js +0 -3075
  460. package/studio-dist/server/assets/factory-Df5uAHjb.js +0 -116
  461. package/studio-dist/server/assets/react-CdqSUhaL.js +0 -89
  462. package/studio-dist/server/assets/report-url-BUXPcE_8.js +0 -9
  463. package/studio-dist/server/assets/search-BJnWLfkG.js +0 -55
  464. package/studio-dist/server/assets/spinner-CdwJW4VB.js +0 -20
  465. package/studio-dist/server/assets/store-Cs17okNG.js +0 -280
  466. /package/src/lib/{factory/keyed-serial.ts → keyed-serial.ts} +0 -0
  467. /package/src/templates/capabilities/openspec-cap/{mate-v1 → mate-full}/templates/spec.md +0 -0
@@ -1,3075 +0,0 @@
1
- import { A as gitTokensQuery, B as inField, C as pathPositionOf, D as GitTokenForm, G as DialogTitle, H as DialogClose, M as tokenCovers, O as clearGitToken, S as nextStepOf, St as useSuspenseQuery, U as DialogContent, V as Dialog, W as DialogDescription, _ as ACTIVITY_LABELS, b as factoryHome, d as Route, g as sendMessage, h as parseMessage, j as hostOf, k as gitTokensKey, m as openTerminalSocket, mt as useAppearance, p as loadWTerm, v as PATH_STEPS, w as situationOf, x as milestonesOf, y as activityOf } from "./router-DkRHNTpE.js";
2
- import { D as clearAgentCredential, F as TERMINAL_WASM, I as factoryLogRoute, L as factoryLogStreamRoute, O as setAgentCredential, S as runFactoryAction, T as agentCredentialQuery, b as addRepository, n as afterFactoryAction, p as vaultChildrenQuery, pt as useNavigate, s as factoryQuery, w as agentCredentialKey, x as removeRepository } from "./studio-queries-BtRGzDdh.js";
3
- import { n as require_react, o as __toESM, t as require_jsx_runtime } from "./jsx-runtime-Bt0s0YKS.js";
4
- import { Dr as useQuery, Tr as cn, r as Icon, t as Button, zr as useQueryClient } from "./button-CgOIVdmD.js";
5
- import { i as require_react_dom } from "../server.js";
6
- import { t as Warnings } from "./warnings-CDy9pdgL.js";
7
- import { n as outcomeActions } from "./actions-DYSv-9VV.js";
8
- import { i as PathSteps, t as ArtifactBody } from "./artifacts-DnF9L3dZ.js";
9
- import { c as PAGE_PAD, d as Progress, s as ListCard, u as Pills } from "./store-Cs17okNG.js";
10
- import { a as Select, c as SelectTrigger, l as SelectValue, o as SelectContent, s as SelectItem } from "./select-Af7Wibii.js";
11
- import { a as SheetClose, i as Sheet, o as SheetContent, r as SidePanel, s as SheetTitle } from "./panel-BR_t9iMM.js";
12
- import { t as useMutation } from "./useMutation-DzTZGenE.js";
13
- import { t as Input } from "./fields-BbieQTD0.js";
14
- import { t as create } from "./react-CdqSUhaL.js";
15
- import { t as reportSrc } from "./report-url-BUXPcE_8.js";
16
- import "./studio-CAcKp3bM.js";
17
- import { t as Spinner } from "./spinner-CdwJW4VB.js";
18
- // ../mate-core/src/lib/factory/runner/questions.ts
19
- /**
20
- * A waiting state's questions; a state written before questions were grouped holds one
21
- * question in its own fields.
22
- */
23
- function questionsOf(state) {
24
- if (Array.isArray(state.questions) && state.questions.length > 0) return state.questions;
25
- const single = state;
26
- return typeof single.question === "string" ? [single] : [];
27
- }
28
- // src/views/factory/change-doc.tsx
29
- var import_react_dom = /* @__PURE__ */ __toESM(require_react_dom(), 1);
30
- var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
31
- var import_jsx_runtime = require_jsx_runtime();
32
- var TITLES = {
33
- spec: "Spec",
34
- tasks: "Tasks"
35
- };
36
- /** The change's spec deltas, one section per capability folder. */
37
- function SpecDocs({ companion, dir }) {
38
- const folders = useQuery(vaultChildrenQuery(companion, `${dir}/specs`));
39
- if (folders.isPending) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
40
- className: "m-0 text-sm text-muted",
41
- children: "Loading…"
42
- });
43
- if (folders.isError) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
44
- className: "m-0 text-sm text-muted",
45
- children: "The spec could not be read."
46
- });
47
- const specs = (folders.data?.entries ?? []).filter((entry) => entry.kind === "directory");
48
- if (specs.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
49
- className: "m-0 text-sm text-muted",
50
- children: "The change has no spec yet."
51
- });
52
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: specs.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
53
- "aria-label": `Spec ${entry.name}`,
54
- children: [specs.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", {
55
- className: "mono",
56
- children: entry.name
57
- }) : null, /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ArtifactBody, {
58
- companion,
59
- path: `${entry.path}/spec.md`
60
- })]
61
- }, entry.path)) });
62
- }
63
- /** A change's spec or task list in place of the Outcome's content, like a report; Back returns. */
64
- function ChangeDoc({ companion, change, doc, onBack }) {
65
- const dir = `openspec/changes/${change}`;
66
- const back = (0, import_react.useRef)(null);
67
- (0, import_react.useEffect)(() => back.current?.focus(), []);
68
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", {
69
- className: "outcome-dialog-head outcome-report-head",
70
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
71
- ref: back,
72
- type: "button",
73
- className: "outcome-report-back",
74
- onClick: onBack,
75
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { name: "left" }), " Back"]
76
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("h2", { children: [
77
- TITLES[doc],
78
- " · ",
79
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
80
- className: "mono",
81
- children: change
82
- })
83
- ] })]
84
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
85
- className: "outcome-doc",
86
- "data-outcome-doc": doc,
87
- children: doc === "spec" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SpecDocs, {
88
- companion,
89
- dir
90
- }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ArtifactBody, {
91
- companion,
92
- path: `${dir}/tasks.md`
93
- })
94
- })] });
95
- }
96
- // src/views/factory/factory-companion.ts
97
- /** The companion the board acts on; set once by the Factory view. */
98
- var FactoryCompanion = (0, import_react.createContext)("");
99
- // src/views/factory/agents-dialog.tsx
100
- /** Each tab's form: what it asks for, and how to get it. */
101
- var TABS = [{
102
- kind: "subscription",
103
- tab: "Claude subscription",
104
- label: "Subscription token",
105
- hint: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("ol", {
106
- className: "note agents-steps",
107
- children: [
108
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { children: [
109
- "In a terminal on your own machine, run ",
110
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { children: "claude setup-token" }),
111
- "."
112
- ] }),
113
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: "Sign in with your Claude account in the browser it opens." }),
114
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { children: [
115
- "Paste the token it prints below. It starts with ",
116
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { children: "sk-ant-oat" }),
117
- " and is valid for a year."
118
- ] })
119
- ]
120
- })
121
- }, {
122
- kind: "api-key",
123
- tab: "API key",
124
- label: "Anthropic API key",
125
- hint: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
126
- className: "note",
127
- children: "Agents bill this key. It starts with sk-ant-api."
128
- })
129
- }];
130
- var KIND_LABELS = {
131
- subscription: "Claude subscription token",
132
- "api-key": "Anthropic API key"
133
- };
134
- function statusText(status) {
135
- if (!status) return "Checking…";
136
- if (!status.kind) return "No credential set. Worksets cannot start agents until one is.";
137
- const source = status.source === "studio" ? `set in Studio${status.setAt ? ` on ${new Date(status.setAt).toLocaleString()}` : ""}` : "supplied at startup";
138
- return `${KIND_LABELS[status.kind]}, ${source}.`;
139
- }
140
- /** Reads one field and empties the form, so the value lives only in this request. */
141
- function takeField(event, name) {
142
- event.preventDefault();
143
- const form = event.currentTarget;
144
- const value = new FormData(form).get(name);
145
- form.reset();
146
- return typeof value === "string" ? value : "";
147
- }
148
- function SecretForm({ kind, label, hint, onSaved }) {
149
- const save = useMutation({
150
- mutationFn: (value) => setAgentCredential(kind, value),
151
- onSuccess: onSaved
152
- });
153
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", {
154
- className: "factory-sheet",
155
- "data-agents-form": kind,
156
- onSubmit: (event) => save.mutate(takeField(event, "value")),
157
- children: [
158
- hint,
159
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
160
- className: "agents-field",
161
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: label }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
162
- type: "password",
163
- name: "value",
164
- autoComplete: "off",
165
- spellCheck: false,
166
- required: true
167
- })]
168
- }),
169
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
170
- className: "factory-sheet-actions",
171
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
172
- type: "submit",
173
- disabled: save.isPending,
174
- children: "Save"
175
- })
176
- }),
177
- save.error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
178
- className: "factory-problems",
179
- role: "alert",
180
- children: save.error.message
181
- }) : null
182
- ]
183
- });
184
- }
185
- /** The Agents panel, sliding over the page: sets the one Claude credential the factory's Workset agents use. */
186
- function AgentsDialog({ onClose }) {
187
- const queryClient = useQueryClient();
188
- const status = useQuery(agentCredentialQuery());
189
- const [tab, setTab] = (0, import_react.useState)("subscription");
190
- const [saved, setSaved] = (0, import_react.useState)(false);
191
- const form = TABS.find((entry) => entry.kind === tab);
192
- const onSaved = (next) => {
193
- queryClient.setQueryData(agentCredentialKey, next);
194
- setSaved(true);
195
- };
196
- const clear = useMutation({
197
- mutationFn: clearAgentCredential,
198
- onSuccess: (next) => {
199
- queryClient.setQueryData(agentCredentialKey, next);
200
- setSaved(false);
201
- }
202
- });
203
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Sheet, {
204
- open: true,
205
- onOpenChange: (open) => {
206
- if (!open) onClose();
207
- },
208
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(SheetContent, {
209
- className: "agents-dialog",
210
- "aria-labelledby": "agents-title",
211
- initialFocus: () => document.querySelector(".agents-dialog .outcome-dialog-close"),
212
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", {
213
- className: "outcome-dialog-head",
214
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
215
- className: "outcome-dialog-heading",
216
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SheetTitle, {
217
- id: "agents-title",
218
- children: "Workset agents"
219
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
220
- className: "outcome-dialog-state",
221
- "data-agents-status": "",
222
- children: status.error ? status.error.message : statusText(status.data)
223
- })]
224
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(SheetClose, {
225
- className: "outcome-dialog-close",
226
- "aria-keyshortcuts": "Escape",
227
- children: ["Close ", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("kbd", { children: "Esc" })]
228
- })]
229
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
230
- className: "agents-dialog-body",
231
- children: [
232
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
233
- role: "tablist",
234
- "aria-label": "How to sign in",
235
- className: "agents-tabs",
236
- children: TABS.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
237
- type: "button",
238
- role: "tab",
239
- id: `agents-tab-${entry.kind}`,
240
- "aria-controls": "agents-panel",
241
- "aria-selected": tab === entry.kind,
242
- onClick: () => {
243
- setTab(entry.kind);
244
- setSaved(false);
245
- },
246
- children: entry.tab
247
- }, entry.kind))
248
- }),
249
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
250
- role: "tabpanel",
251
- id: "agents-panel",
252
- "aria-labelledby": `agents-tab-${tab}`,
253
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SecretForm, {
254
- kind: form.kind,
255
- label: form.label,
256
- hint: form.hint,
257
- onSaved
258
- }, form.kind)
259
- }),
260
- saved ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
261
- className: "note",
262
- role: "status",
263
- children: "Saved. The next agent start uses it."
264
- }) : null,
265
- status.data?.source === "studio" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
266
- className: "factory-sheet-actions agents-clear",
267
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
268
- type: "button",
269
- onClick: () => clear.mutate(),
270
- disabled: clear.isPending,
271
- children: "Remove the credential set in Studio"
272
- }), clear.error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
273
- className: "factory-problems",
274
- role: "alert",
275
- children: clear.error.message
276
- }) : null]
277
- }) : null
278
- ]
279
- })]
280
- })
281
- });
282
- }
283
- // src/views/factory/git-access-dialog.tsx
284
- function sourceText(token) {
285
- return token.source === "studio" ? `set in Studio${token.setAt ? ` on ${token.setAt.slice(0, 10)}` : ""}` : "supplied at startup";
286
- }
287
- /** The Git access panel, sliding over the page: Git tokens per host or organization for cloning. */
288
- function GitAccessDialog({ onClose }) {
289
- const queryClient = useQueryClient();
290
- const status = useQuery(gitTokensQuery());
291
- const [saved, setSaved] = (0, import_react.useState)(false);
292
- const clear = useMutation({
293
- mutationFn: clearGitToken,
294
- onSuccess: (next) => {
295
- queryClient.setQueryData(gitTokensKey, next);
296
- setSaved(false);
297
- }
298
- });
299
- const tokens = status.data?.tokens ?? [];
300
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Sheet, {
301
- open: true,
302
- onOpenChange: (open) => {
303
- if (!open) onClose();
304
- },
305
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(SheetContent, {
306
- className: "agents-dialog",
307
- "aria-labelledby": "git-access-title",
308
- initialFocus: () => document.querySelector(".agents-dialog .outcome-dialog-close"),
309
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", {
310
- className: "outcome-dialog-head",
311
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
312
- className: "outcome-dialog-heading",
313
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SheetTitle, {
314
- id: "git-access-title",
315
- children: "Git access"
316
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
317
- className: "outcome-dialog-state",
318
- "data-git-access-status": "",
319
- children: status.error ? status.error.message : status.data ? `${tokens.length} ${tokens.length === 1 ? "key" : "keys"} set.` : "Checking…"
320
- })]
321
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(SheetClose, {
322
- className: "outcome-dialog-close",
323
- "aria-keyshortcuts": "Escape",
324
- children: ["Close ", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("kbd", { children: "Esc" })]
325
- })]
326
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
327
- className: "agents-dialog-body",
328
- children: [
329
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
330
- className: "note",
331
- children: "A token clones private repositories. Set it for a host, or for a host and organization; the organization's token wins. Tokens are kept by the factory and never shown again."
332
- }),
333
- tokens.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
334
- className: "git-access-keys",
335
- "data-git-access-keys": "",
336
- children: tokens.map((token) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
337
- "data-git-access-key": token.key,
338
- children: [
339
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
340
- className: "mono",
341
- children: token.key
342
- }),
343
- " ",
344
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
345
- className: "note",
346
- children: sourceText(token)
347
- }),
348
- token.source === "studio" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
349
- type: "button",
350
- onClick: () => clear.mutate(token.key),
351
- disabled: clear.isPending,
352
- children: "Remove"
353
- }) : null
354
- ]
355
- }, token.key))
356
- }) : null,
357
- clear.error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
358
- className: "factory-problems",
359
- role: "alert",
360
- children: clear.error.message
361
- }) : null,
362
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GitTokenForm, { onSaved: () => setSaved(true) }),
363
- saved ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
364
- className: "note",
365
- role: "status",
366
- children: "Saved. The next clone uses it."
367
- }) : null
368
- ]
369
- })]
370
- })
371
- });
372
- }
373
- // src/views/factory/repository-dialog.tsx
374
- var MODES = [{
375
- mode: "url",
376
- label: "Git URL",
377
- field: "Git URL of the repository",
378
- placeholder: "https://git.acme.test/acme/web.git",
379
- hint: "The factory checks the remote answers before it is listed. A private repository asks for a Git token."
380
- }, {
381
- mode: "path",
382
- label: "Local path",
383
- field: "Absolute path of a checkout",
384
- placeholder: "/home/dev/acme-web",
385
- hint: "Only the checkout's origin URL is listed. The factory clones from that URL, so commits not pushed there are not seen."
386
- }];
387
- /** Adds a Working Repository to the companion's list by Git URL or from a local checkout, and removes listed ones. */
388
- function RepositoryDialog({ open, companion, listed, onClose, onAdded }) {
389
- const queryClient = useQueryClient();
390
- const [mode, setMode] = (0, import_react.useState)("url");
391
- const [value, setValue] = (0, import_react.useState)("");
392
- const [refusal, setRefusal] = (0, import_react.useState)(null);
393
- const [note, setNote] = (0, import_react.useState)(null);
394
- const form = MODES.find((entry) => entry.mode === mode);
395
- const input = () => mode === "url" ? {
396
- kind: "url",
397
- url: value
398
- } : {
399
- kind: "path",
400
- path: value
401
- };
402
- const add = useMutation({
403
- mutationFn: () => addRepository({ data: {
404
- companion,
405
- input: input()
406
- } }),
407
- onSuccess: async (result) => {
408
- if (!result.ok) {
409
- setRefusal(result);
410
- return;
411
- }
412
- await afterFactoryAction(queryClient, companion);
413
- setValue("");
414
- setNote(result.warning ?? null);
415
- onAdded(result.identity);
416
- if (!result.warning) onClose();
417
- }
418
- });
419
- const remove = useMutation({
420
- mutationFn: (identity) => removeRepository({ data: {
421
- companion,
422
- identity
423
- } }),
424
- onSuccess: async (result) => {
425
- if (result.ok) await afterFactoryAction(queryClient, companion);
426
- else setRefusal(result);
427
- }
428
- });
429
- function reset() {
430
- setValue("");
431
- setRefusal(null);
432
- setNote(null);
433
- add.reset();
434
- }
435
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Dialog, {
436
- open,
437
- onOpenChange: (next) => {
438
- if (next) return;
439
- reset();
440
- onClose();
441
- },
442
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DialogContent, {
443
- className: "grid w-[min(520px,calc(100vw-32px))] gap-4 p-5",
444
- children: [
445
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
446
- className: "grid gap-1.5",
447
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogTitle, {
448
- className: "text-md",
449
- children: "Add a repository"
450
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogDescription, { children: form.hint })]
451
- }),
452
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
453
- role: "tablist",
454
- "aria-label": "How to add",
455
- className: "flex gap-1.5",
456
- children: MODES.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
457
- type: "button",
458
- role: "tab",
459
- "aria-selected": mode === entry.mode,
460
- className: cn("h-7 rounded-full border border-rule bg-transparent px-3 text-sm text-muted", mode === entry.mode && "border-accent bg-accent-soft text-text"),
461
- onClick: () => {
462
- setMode(entry.mode);
463
- reset();
464
- },
465
- children: entry.label
466
- }, entry.mode))
467
- }),
468
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", {
469
- className: "grid gap-3",
470
- "data-add-repository-form": "",
471
- onSubmit: (event) => {
472
- event.preventDefault();
473
- setRefusal(null);
474
- setNote(null);
475
- add.mutate();
476
- },
477
- children: [
478
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
479
- className: "grid gap-1.5 text-sm",
480
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: form.field }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
481
- value,
482
- placeholder: form.placeholder,
483
- autoComplete: "off",
484
- spellCheck: false,
485
- required: true,
486
- onChange: (event) => setValue(event.currentTarget.value),
487
- "aria-label": form.field
488
- })]
489
- }),
490
- refusal ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
491
- className: "m-0 text-sm text-bad",
492
- role: "alert",
493
- children: refusal.reason
494
- }) : null,
495
- add.isError ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
496
- className: "m-0 text-sm text-bad",
497
- role: "alert",
498
- children: add.error instanceof Error ? add.error.message : "The repository was not added."
499
- }) : null,
500
- note ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
501
- className: "m-0 text-sm text-muted",
502
- role: "status",
503
- children: ["Added. ", note]
504
- }) : null,
505
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
506
- className: "flex justify-end gap-2",
507
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogClose, {
508
- render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
509
- variant: "ghost",
510
- type: "button"
511
- }),
512
- children: "Close"
513
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
514
- type: "submit",
515
- disabled: add.isPending || value.trim() === "",
516
- children: add.isPending ? "Checking…" : "Add repository"
517
- })]
518
- })
519
- ]
520
- }),
521
- refusal && "tokenKey" in refusal && refusal.tokenKey ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
522
- className: "grid gap-2 border-t border-rule pt-3",
523
- "data-add-repository-token": "",
524
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
525
- className: "m-0 text-sm text-muted",
526
- children: "Set a Git token for this host, then add the repository again."
527
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GitTokenForm, {
528
- defaultKey: refusal.tokenKey,
529
- onSaved: () => {
530
- setRefusal(null);
531
- add.mutate();
532
- }
533
- })]
534
- }) : null,
535
- listed.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
536
- className: "m-0 grid list-none gap-1.5 border-t border-rule p-0 pt-3",
537
- "data-listed-repositories": "",
538
- children: listed.map((identity) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
539
- className: "flex items-center justify-between gap-2 text-sm",
540
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
541
- className: "font-mono",
542
- children: identity
543
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
544
- type: "button",
545
- variant: "ghost",
546
- disabled: remove.isPending,
547
- onClick: () => remove.mutate(identity),
548
- children: "Remove"
549
- })]
550
- }, identity))
551
- }) : null
552
- ]
553
- })
554
- });
555
- }
556
- // src/views/factory/repository-token.tsx
557
- /** Sets a Git token for the chosen repository's `host/org`, beside the Outcome form, never in it. */
558
- function RepositoryTokenDialog({ open, tokenKey, onClose }) {
559
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Dialog, {
560
- open,
561
- onOpenChange: (next) => {
562
- if (!next) onClose();
563
- },
564
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DialogContent, {
565
- className: "grid w-[min(520px,calc(100vw-32px))] gap-4 p-5",
566
- children: [
567
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
568
- className: "grid gap-1.5",
569
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogTitle, {
570
- className: "text-md",
571
- children: "Set a Git token"
572
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogDescription, { children: "A token clones private repositories from this host. It is kept by the factory and never shown again." })]
573
- }),
574
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GitTokenForm, {
575
- defaultKey: tokenKey,
576
- onSaved: onClose
577
- }, tokenKey),
578
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
579
- className: "flex justify-end",
580
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogClose, {
581
- render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
582
- variant: "ghost",
583
- type: "button"
584
- }),
585
- children: "Close"
586
- })
587
- })
588
- ]
589
- })
590
- });
591
- }
592
- // src/views/factory/factory-form.tsx
593
- /**
594
- * A board action as a form: its own fields (and the pressed button's name and value) are sent
595
- * through one validated server function, then the board refetches. The markup stays the form
596
- * the server-rendered board posted, so keyboard submission and field names are unchanged.
597
- */
598
- function FactoryForm({ action, id, className, children, onDone, ...rest }) {
599
- const companion = (0, import_react.useContext)(FactoryCompanion);
600
- const queryClient = useQueryClient();
601
- const mutation = useMutation({
602
- mutationFn: (fields) => runFactoryAction({ data: {
603
- companion,
604
- action,
605
- id,
606
- fields
607
- } }),
608
- onSuccess: () => afterFactoryAction(queryClient, companion)
609
- });
610
- const submit = (event) => {
611
- event.preventDefault();
612
- const form = event.currentTarget;
613
- const submitter = event.nativeEvent.submitter;
614
- const fields = {};
615
- for (const [name, value] of new FormData(form, submitter)) if (typeof value === "string") fields[name] = value;
616
- mutation.mutate(fields, { onSuccess: () => {
617
- form.reset();
618
- onDone?.();
619
- } });
620
- };
621
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", {
622
- className,
623
- "data-factory-action": id ? `/${id}/${action}` : `/${action}`,
624
- onSubmit: submit,
625
- "aria-busy": mutation.isPending || void 0,
626
- ...rest,
627
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("fieldset", {
628
- className: "factory-form-fields",
629
- disabled: mutation.isPending,
630
- children
631
- }), mutation.error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
632
- className: "factory-problems",
633
- role: "alert",
634
- children: mutation.error.message
635
- }) : null]
636
- });
637
- }
638
- // ../../node_modules/.bun/zustand@5.0.16+f73d66fb2ea5e116/node_modules/zustand/esm/middleware.mjs
639
- function createJSONStorage(getStorage, options) {
640
- let storage;
641
- try {
642
- storage = getStorage();
643
- } catch (e) {
644
- return;
645
- }
646
- return {
647
- getItem: (name) => {
648
- var _a;
649
- const parse = (str2) => {
650
- if (str2 === null) return null;
651
- return JSON.parse(str2, options == null ? void 0 : options.reviver);
652
- };
653
- const str = (_a = storage.getItem(name)) != null ? _a : null;
654
- if (str instanceof Promise) return str.then(parse);
655
- return parse(str);
656
- },
657
- setItem: (name, newValue) => storage.setItem(name, JSON.stringify(newValue, options == null ? void 0 : options.replacer)),
658
- removeItem: (name) => storage.removeItem(name)
659
- };
660
- }
661
- var toThenable = (fn) => (input) => {
662
- try {
663
- const result = fn(input);
664
- if (result instanceof Promise) return result;
665
- return {
666
- then(onFulfilled) {
667
- return toThenable(onFulfilled)(result);
668
- },
669
- catch(_onRejected) {
670
- return this;
671
- }
672
- };
673
- } catch (e) {
674
- return {
675
- then(_onFulfilled) {
676
- return this;
677
- },
678
- catch(onRejected) {
679
- return toThenable(onRejected)(e);
680
- }
681
- };
682
- }
683
- };
684
- var persistImpl = (config, baseOptions) => (set, get, api) => {
685
- let options = {
686
- storage: createJSONStorage(() => window.localStorage),
687
- partialize: (state) => state,
688
- version: 0,
689
- merge: (persistedState, currentState) => ({
690
- ...currentState,
691
- ...persistedState
692
- }),
693
- ...baseOptions
694
- };
695
- let hasHydrated = false;
696
- let hydrationVersion = 0;
697
- const hydrationListeners = /* @__PURE__ */ new Set();
698
- const finishHydrationListeners = /* @__PURE__ */ new Set();
699
- let storage = options.storage;
700
- if (!storage) return config((...args) => {
701
- console.warn(`[zustand persist middleware] Unable to update item '${options.name}', the given storage is currently unavailable.`);
702
- set(...args);
703
- }, get, api);
704
- const setItem = () => {
705
- const state = options.partialize({ ...get() });
706
- return storage.setItem(options.name, {
707
- state,
708
- version: options.version
709
- });
710
- };
711
- const savedSetState = api.setState;
712
- api.setState = (...args) => {
713
- savedSetState(...args);
714
- return setItem();
715
- };
716
- const configResult = config((...args) => {
717
- set(...args);
718
- return setItem();
719
- }, get, api);
720
- api.getInitialState = () => configResult;
721
- let stateFromStorage;
722
- const hydrate = () => {
723
- var _a, _b;
724
- if (!storage) return;
725
- const currentVersion = ++hydrationVersion;
726
- hasHydrated = false;
727
- hydrationListeners.forEach((cb) => {
728
- var _a2;
729
- return cb((_a2 = get()) != null ? _a2 : configResult);
730
- });
731
- const postRehydrationCallback = ((_b = options.onRehydrateStorage) == null ? void 0 : _b.call(options, (_a = get()) != null ? _a : configResult)) || void 0;
732
- return toThenable(storage.getItem.bind(storage))(options.name).then((deserializedStorageValue) => {
733
- if (deserializedStorageValue) {
734
- if (typeof deserializedStorageValue.version === "number" && deserializedStorageValue.version !== options.version) {
735
- if (options.migrate) {
736
- const migration = options.migrate(deserializedStorageValue.state, deserializedStorageValue.version);
737
- if (migration instanceof Promise) return migration.then((result) => [true, result]);
738
- return [true, migration];
739
- }
740
- console.error(`State loaded from storage couldn't be migrated since no migrate function was provided`);
741
- } else return [false, deserializedStorageValue.state];
742
- }
743
- return [false, void 0];
744
- }).then((migrationResult) => {
745
- var _a2;
746
- if (currentVersion !== hydrationVersion) return;
747
- const [migrated, migratedState] = migrationResult;
748
- stateFromStorage = options.merge(migratedState, (_a2 = get()) != null ? _a2 : configResult);
749
- set(stateFromStorage, true);
750
- if (migrated) return setItem();
751
- }).then(() => {
752
- if (currentVersion !== hydrationVersion) return;
753
- postRehydrationCallback?.(get(), void 0);
754
- stateFromStorage = get();
755
- hasHydrated = true;
756
- finishHydrationListeners.forEach((cb) => cb(stateFromStorage));
757
- }).catch((e) => {
758
- if (currentVersion !== hydrationVersion) return;
759
- postRehydrationCallback?.(void 0, e);
760
- });
761
- };
762
- api.persist = {
763
- setOptions: (newOptions) => {
764
- options = {
765
- ...options,
766
- ...newOptions
767
- };
768
- if (newOptions.storage) storage = newOptions.storage;
769
- },
770
- clearStorage: () => {
771
- ++hydrationVersion;
772
- storage?.removeItem(options.name);
773
- },
774
- getOptions: () => options,
775
- rehydrate: () => hydrate(),
776
- hasHydrated: () => hasHydrated,
777
- onHydrate: (cb) => {
778
- hydrationListeners.add(cb);
779
- return () => {
780
- hydrationListeners.delete(cb);
781
- };
782
- },
783
- onFinishHydration: (cb) => {
784
- finishHydrationListeners.add(cb);
785
- return () => {
786
- finishHydrationListeners.delete(cb);
787
- };
788
- }
789
- };
790
- if (!options.skipHydration) hydrate();
791
- return stateFromStorage || configResult;
792
- };
793
- var persist = persistImpl;
794
- // src/stores/factory-ui.ts
795
- var useFactoryUi = create()(persist((set) => ({
796
- filter: "",
797
- setFilter: (filter) => set({ filter }),
798
- stepped: false,
799
- setStepped: (stepped) => set({ stepped }),
800
- agentsOpen: false,
801
- setAgentsOpen: (agentsOpen) => set({ agentsOpen }),
802
- gitAccessOpen: false,
803
- setGitAccessOpen: (gitAccessOpen) => set({ gitAccessOpen })
804
- }), {
805
- name: "mate.factory.filter",
806
- storage: createJSONStorage(() => sessionStorage),
807
- partialize: ({ filter }) => ({ filter })
808
- }));
809
- // src/views/factory/factory-live.ts
810
- var SEEN_KEY = "mate.factory.needsYou";
811
- /** Whether every word of `query` occurs in `text`, ignoring case. */
812
- function matchesFilter(text, query) {
813
- const haystack = text.toLowerCase();
814
- return query.toLowerCase().split(/\s+/).every((word) => haystack.includes(word));
815
- }
816
- /** The page title with the decision count in front, without stacking counts. */
817
- function titled(title, count) {
818
- const bare = title.replace(/^\(\d+\) /, "");
819
- return count > 0 ? `(${count}) ${bare}` : bare;
820
- }
821
- /** The row `delta` steps from the focused one, held at the ends; the first row when none is. */
822
- function stepRow(rows, focused, delta) {
823
- const at = focused ? rows.indexOf(focused) : -1;
824
- if (at === -1) return rows[0];
825
- return rows[Math.min(rows.length - 1, Math.max(0, at + delta))];
826
- }
827
- /** Whether a key press belongs to a field or the terminal rather than to a shortcut. */
828
- function typing(target) {
829
- return inField(target) || Boolean(target?.closest?.(".outcome-terminal"));
830
- }
831
- /** In an open Outcome panel: 1–9 pick a one-click answer, J/K the next or previous Outcome. */
832
- function dialogButton(dialog, key) {
833
- if (/^[1-9]$/.test(key)) return dialog.querySelector(`[data-option-key="${key}"]`);
834
- const step = {
835
- j: "Next",
836
- k: "Previous"
837
- }[key];
838
- if (!step) return null;
839
- return (dialog.closest("[data-slot=sheet-content]") ?? dialog).querySelector(`button[aria-label="${step}"]`);
840
- }
841
- /** On the board: N focuses the new-outcome field, / the filter. */
842
- function boardField(doc, key) {
843
- if (key === "n") return doc.querySelector("form[data-outcome-input] textarea");
844
- if (key === "/") return doc.querySelector("[data-outcome-filter]");
845
- return null;
846
- }
847
- /**
848
- * Board shortcuts: N starts a new outcome, / filters, J/K (arrows on a row) move between
849
- * rows, Enter opens one. In an open Outcome panel J/K step to the next or previous Outcome, 1–9
850
- * pick a one-click answer and Ctrl/Cmd+Enter sends the form being typed in. Fields and the
851
- * terminal keep every other key.
852
- */
853
- function factoryKeyHandler(doc) {
854
- return (event) => {
855
- if (event.defaultPrevented || event.altKey) return;
856
- const target = event.target;
857
- if (event.key === "Enter" && (event.ctrlKey || event.metaKey)) {
858
- const form = target?.closest?.("form");
859
- if (target?.localName === "textarea" && form) {
860
- event.preventDefault();
861
- if (form.querySelector("button[type=\"submit\"].factory-primary:disabled")) return;
862
- const start = form.querySelector("button[value=\"start\"]");
863
- form.requestSubmit(start ?? void 0);
864
- }
865
- return;
866
- }
867
- if (event.ctrlKey || event.metaKey || typing(target)) return;
868
- const modal = target?.closest?.("[data-slot=\"sheet-content\"], [data-slot=\"dialog-content\"]");
869
- if (modal && !modal.querySelector("[data-outcome-panel]")) return;
870
- const dialog = doc.querySelector("[data-outcome-panel]");
871
- if (dialog) {
872
- const button = dialogButton(dialog, event.key);
873
- if (button) {
874
- event.preventDefault();
875
- button.click();
876
- }
877
- return;
878
- }
879
- const field = boardField(doc, event.key);
880
- if (field) {
881
- event.preventDefault();
882
- field.focus();
883
- return;
884
- }
885
- const onRow = Boolean(target?.matches?.("[data-outcome-row]"));
886
- const down = event.key === "j" || onRow && event.key === "ArrowDown";
887
- const up = event.key === "k" || onRow && event.key === "ArrowUp";
888
- if (!down && !up) return;
889
- const next = stepRow([...doc.querySelectorAll("[data-outcome-row]")].filter((row) => row.getClientRects().length > 0), doc.activeElement, down ? 1 : -1);
890
- if (!next) return;
891
- event.preventDefault();
892
- next.focus();
893
- next.scrollIntoView({ block: "nearest" });
894
- };
895
- }
896
- function useFactoryKeys() {
897
- (0, import_react.useEffect)(() => {
898
- const handler = factoryKeyHandler(document);
899
- window.addEventListener("keydown", handler, true);
900
- return () => window.removeEventListener("keydown", handler, true);
901
- }, []);
902
- }
903
- /** Puts the decision count in the title and notifies when it grows, once per count. */
904
- function useNeedsYou(count) {
905
- (0, import_react.useEffect)(() => {
906
- document.title = titled(document.title, count);
907
- if (typeof Notification === "undefined" || Notification.permission !== "granted") return;
908
- let seen = 0;
909
- try {
910
- seen = Number(sessionStorage.getItem(SEEN_KEY) || "0");
911
- sessionStorage.setItem(SEEN_KEY, String(count));
912
- } catch {}
913
- if (count > seen) new Notification("Mate factory", { body: count === 1 ? "1 decision needs you" : `${count} decisions need you` });
914
- }, [count]);
915
- (0, import_react.useEffect)(() => () => void (document.title = titled(document.title, 0)), []);
916
- }
917
- /** Whether to offer notifications: only while the browser has not been asked yet. */
918
- function useNotificationOffer() {
919
- const [offered, setOffered] = (0, import_react.useState)(() => typeof Notification !== "undefined" && Notification.permission === "default");
920
- return {
921
- offered,
922
- ask: () => void Notification.requestPermission().then(() => setOffered(false))
923
- };
924
- }
925
- // src/views/factory/age.ts
926
- /** Whole days, hours or minutes since `iso`, for an age; empty without a render time. */
927
- function ageText(iso, now) {
928
- if (now === void 0) return "";
929
- const minutes = Math.max(0, Math.floor((now - Date.parse(iso)) / 6e4));
930
- if (minutes >= 1440) return `${Math.floor(minutes / 1440)}d`;
931
- if (minutes >= 60) return `${Math.floor(minutes / 60)}h`;
932
- return `${minutes}m`;
933
- }
934
- // src/views/factory/use-outcome-log.ts
935
- var EMPTY_LOG = {
936
- pieces: [],
937
- open: {}
938
- };
939
- /** The runner's own notes in the stored log: stage prompts, links, commits, pushes and the like. */
940
- var FACTORY_LINE = /^(> |committed: |pushed |published |linked |Returned to automation|no review report |the review report for |\S+ is now at )/;
941
- /**
942
- * The stored log is plain text; its lines are told apart by the runner's prefixes. Tool calls
943
- * are not stored, so a replay holds agent text and factory notes only.
944
- */
945
- function classifyStored(log) {
946
- const pieces = [];
947
- for (const line of log.split(/(?<=\n)/)) {
948
- const kind = FACTORY_LINE.test(line) ? "factory" : "agent";
949
- const last = pieces.at(-1);
950
- if (last && (last.kind === kind || line.trim() === "")) last.text += line;
951
- else pieces.push({
952
- kind,
953
- text: line
954
- });
955
- }
956
- return pieces;
957
- }
958
- /** Streaming blocks by id, tool calls as lines, each piece kept with its kind. */
959
- function logReducer(state, event) {
960
- const append = (kind, text, id) => {
961
- const pieces = [...state.pieces, id === void 0 ? {
962
- kind,
963
- text
964
- } : {
965
- id,
966
- kind,
967
- text
968
- }];
969
- return {
970
- pieces,
971
- open: id === void 0 ? state.open : {
972
- ...state.open,
973
- [id]: pieces.length - 1
974
- }
975
- };
976
- };
977
- const grow = (id, text) => {
978
- const at = state.open[id];
979
- if (at === void 0) return append("agent", text, id);
980
- const pieces = [...state.pieces];
981
- pieces[at] = {
982
- ...pieces[at],
983
- text: pieces[at].text + text
984
- };
985
- return {
986
- ...state,
987
- pieces
988
- };
989
- };
990
- switch (event.type) {
991
- case "replay": {
992
- let next = {
993
- pieces: classifyStored(event.log),
994
- open: {}
995
- };
996
- for (const block of event.open) next = logReducer(next, {
997
- type: "text",
998
- ...block,
999
- delta: block.text
1000
- });
1001
- return next;
1002
- }
1003
- case "text": return event.id === void 0 ? append("agent", event.delta) : grow(event.id, event.delta);
1004
- case "text-end": {
1005
- const next = grow(event.id, "\n");
1006
- const { [event.id]: _ended, ...open } = next.open;
1007
- return {
1008
- ...next,
1009
- open
1010
- };
1011
- }
1012
- case "tool": return append("tool", `› ${event.name} ${event.summary}\n`);
1013
- case "tool-done": return event.failed ? append("failed", ` ${event.name} failed\n`) : state;
1014
- case "log": return append("factory", event.text);
1015
- case "lost": return append("factory", "\nThis view fell behind the run; close and reopen the Outcome.\n");
1016
- case "settled": return state;
1017
- }
1018
- }
1019
- /**
1020
- * Follows one Outcome's run log for as long as its dialog is open; `null` follows none. The stream keeps going
1021
- * across stages; when a stage ends the board's own update shows the new state in place.
1022
- */
1023
- function useOutcomeLog(url) {
1024
- const [state, dispatch] = (0, import_react.useReducer)((current, event) => event.type === "reset" ? {
1025
- ...EMPTY_LOG,
1026
- ended: false
1027
- } : {
1028
- ...logReducer(current, event),
1029
- ended: current.ended || event.type === "lost"
1030
- }, {
1031
- ...EMPTY_LOG,
1032
- ended: false
1033
- });
1034
- (0, import_react.useEffect)(() => {
1035
- dispatch({ type: "reset" });
1036
- if (!url || typeof EventSource === "undefined") return;
1037
- const source = new EventSource(url);
1038
- source.addEventListener("message", (message) => {
1039
- try {
1040
- dispatch(JSON.parse(message.data));
1041
- } catch {}
1042
- });
1043
- return () => source.close();
1044
- }, [url]);
1045
- return {
1046
- pieces: state.pieces,
1047
- ended: state.ended
1048
- };
1049
- }
1050
- // src/terminal/outcome-terminal.tsx
1051
- /** What the terminal says when its session ends: Claude's quit and the Outcome's return are told apart. */
1052
- function endNotice(message) {
1053
- if (message.reason === "returned") return "The Outcome is back with automation.";
1054
- if (message.reason === "deleted") return "The Outcome was deleted.";
1055
- if (message.type === "ended") return "The session ended. Return to automation when you are done, or close and reopen the Outcome to start it again.";
1056
- if (message.status === 0 || message.status === 130) return "Claude closed. The Outcome returns to automation; if it does not, return it with the button.";
1057
- return "Claude stopped unexpectedly. The Outcome stays with you; return it to automation when you are done.";
1058
- }
1059
- /**
1060
- * One Outcome's Workset session in a terminal view: starts it, or attaches to the live one,
1061
- * and restarts a session that went away. Closing only detaches; the session keeps running for
1062
- * its detach window.
1063
- */
1064
- var OutcomeSession = class {
1065
- mount;
1066
- outcome;
1067
- companion;
1068
- failed;
1069
- phase;
1070
- focus;
1071
- term = null;
1072
- ws = null;
1073
- sessionId = null;
1074
- observer = null;
1075
- closed = false;
1076
- /** Set at the first output, or when the session ended: from then on reasons are notices. */
1077
- live = false;
1078
- /** A `gone` answer restarts once; the next `ready` clears it. */
1079
- restarted = false;
1080
- /** Set while an `attach` awaits its `ready`. */
1081
- attaching = false;
1082
- constructor(mount, outcome, companion, failed, phase, focus) {
1083
- this.mount = mount;
1084
- this.outcome = outcome;
1085
- this.companion = companion;
1086
- this.failed = failed;
1087
- this.phase = phase;
1088
- this.focus = focus;
1089
- this.open();
1090
- }
1091
- async open() {
1092
- try {
1093
- const WTerm = await loadWTerm();
1094
- if (this.closed) return;
1095
- const term = new WTerm(this.mount, {
1096
- cursorBlink: true,
1097
- autoResize: false,
1098
- wasmUrl: TERMINAL_WASM
1099
- });
1100
- this.term = term;
1101
- term.onData = (data) => this.send({
1102
- type: "input",
1103
- data
1104
- });
1105
- term.onResize = () => this.send({
1106
- type: "resize",
1107
- cols: term.cols,
1108
- rows: term.rows
1109
- });
1110
- await term.init();
1111
- if (this.closed) return;
1112
- term.fit();
1113
- this.observer = new ResizeObserver(() => {
1114
- if (this.mount.clientWidth && this.mount.clientHeight) term.fit();
1115
- });
1116
- this.observer.observe(this.mount);
1117
- this.connect();
1118
- } catch {
1119
- this.term = null;
1120
- this.failed();
1121
- }
1122
- }
1123
- send(message) {
1124
- sendMessage(this.ws, message);
1125
- }
1126
- notice(text) {
1127
- this.term?.write(`\r\n\u001b[2m${text}\u001b[0m\r\n`);
1128
- }
1129
- start() {
1130
- if (!this.term) return;
1131
- const { cols, rows } = this.term;
1132
- this.send({
1133
- type: "start",
1134
- workset: this.outcome,
1135
- companion: this.companion,
1136
- cols,
1137
- rows
1138
- });
1139
- }
1140
- connect() {
1141
- const ws = openTerminalSocket();
1142
- this.ws = ws;
1143
- ws.onopen = () => {
1144
- if (!this.term) return;
1145
- const { cols, rows } = this.term;
1146
- if (this.sessionId) {
1147
- this.attaching = true;
1148
- this.send({
1149
- type: "attach",
1150
- sessionId: this.sessionId,
1151
- cols,
1152
- rows
1153
- });
1154
- } else this.start();
1155
- };
1156
- ws.onmessage = (event) => this.receive(event.data);
1157
- ws.onclose = () => {
1158
- if (this.ws !== ws) return;
1159
- this.ws = null;
1160
- if (!this.live && !this.closed) this.show({
1161
- kind: "refused",
1162
- reason: "The connection closed before the session started."
1163
- });
1164
- };
1165
- }
1166
- receive(data) {
1167
- const term = this.term;
1168
- if (!term) return;
1169
- if (typeof data !== "string") {
1170
- if (!this.live) this.show({ kind: "live" });
1171
- term.write(new Uint8Array(data));
1172
- return;
1173
- }
1174
- const message = parseMessage(data);
1175
- if (!message) return;
1176
- if (message.type === "ready") {
1177
- this.restarted = false;
1178
- this.sessionId = message.sessionId ?? null;
1179
- if (this.attaching) this.show({ kind: "live" });
1180
- this.attaching = false;
1181
- term.write("\x1Bc");
1182
- if (this.focus) term.focus();
1183
- } else if (message.type === "gone") {
1184
- this.sessionId = null;
1185
- this.attaching = false;
1186
- if (this.restarted) {
1187
- this.show({
1188
- kind: "refused",
1189
- reason: "The session could not be started."
1190
- });
1191
- return;
1192
- }
1193
- this.restarted = true;
1194
- this.show({ kind: "starting" });
1195
- this.start();
1196
- } else if (message.type === "exit" || message.type === "ended") {
1197
- this.sessionId = null;
1198
- this.show({ kind: "live" });
1199
- this.notice(endNotice(message));
1200
- } else if (message.type === "takenOver") this.notice("Another tab has this session now.");
1201
- else if (message.type === "error" && message.reason) {
1202
- if (this.live) this.notice(message.reason);
1203
- else this.show({
1204
- kind: "refused",
1205
- reason: message.reason
1206
- });
1207
- }
1208
- }
1209
- show(phase) {
1210
- this.live = phase.kind === "live";
1211
- this.phase(phase);
1212
- }
1213
- /** Starts again after a refusal. */
1214
- retry() {
1215
- this.restarted = false;
1216
- this.show({ kind: "starting" });
1217
- this.start();
1218
- }
1219
- close() {
1220
- this.closed = true;
1221
- this.observer?.disconnect();
1222
- this.ws?.close();
1223
- this.ws = null;
1224
- this.term?.destroy();
1225
- this.term = null;
1226
- }
1227
- };
1228
- /** The taken-over session inside an Outcome's dialog; mounting starts or attaches, unmounting detaches. */
1229
- function OutcomeTerminal({ outcome, companion, focus = true }) {
1230
- const mount = (0, import_react.useRef)(null);
1231
- const [failed, setFailed] = (0, import_react.useState)(false);
1232
- const [phase, setPhase] = (0, import_react.useState)({ kind: "starting" });
1233
- const key = `${companion}\n${outcome}`;
1234
- const [sessionKey, setSessionKey] = (0, import_react.useState)(key);
1235
- if (sessionKey !== key) {
1236
- setSessionKey(key);
1237
- setPhase({ kind: "starting" });
1238
- }
1239
- const focusOnReady = (0, import_react.useRef)(focus);
1240
- const current = (0, import_react.useRef)(null);
1241
- (0, import_react.useEffect)(() => {
1242
- const session = new OutcomeSession(mount.current, outcome, companion, () => setFailed(true), setPhase, focusOnReady.current);
1243
- current.current = session;
1244
- return () => session.close();
1245
- }, [outcome, companion]);
1246
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1247
- className: "outcome-terminal-frame",
1248
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
1249
- ref: mount,
1250
- className: "outcome-terminal",
1251
- "data-outcome-terminal": outcome,
1252
- "data-companion": companion,
1253
- "data-terminal-error": failed ? "" : void 0,
1254
- children: failed ? "The terminal could not start in this browser. Close and reopen the Outcome to retry." : null
1255
- }), phase.kind === "live" || failed ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
1256
- className: "outcome-terminal-cover",
1257
- role: phase.kind === "refused" ? "alert" : "status",
1258
- "data-terminal-phase": phase.kind,
1259
- children: phase.kind === "refused" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: phase.reason }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
1260
- type: "button",
1261
- onClick: () => current.current?.retry(),
1262
- children: "Try again"
1263
- })] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spinner, {
1264
- "aria-hidden": "true",
1265
- className: "size-7 text-accent"
1266
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Starting the session…" })] })
1267
- })]
1268
- });
1269
- }
1270
- // src/views/factory/factory-view.tsx
1271
- var ATTENTION_LABELS = {
1272
- control: "You have control",
1273
- decision: "Decision needed",
1274
- review: "Plan ready for review",
1275
- merge: "Ready to merge",
1276
- publish: "Ready to publish",
1277
- problem: "Something went wrong"
1278
- };
1279
- /** What being in control means, in the note card above the terminal. */
1280
- var CONTROL_HINT = "You work in the factory's own conversation. Exit Claude, then return the Outcome to automation; the factory checks what changed and continues.";
1281
- /** What Take control does, beside the button. */
1282
- var TAKE_CONTROL_HINT = "Pauses automation after the current stage; you continue the factory's own conversation here.";
1283
- var RECENT_COMPLETED = 5;
1284
- /** "Decisions needed (3)" when the agent asked several questions together. */
1285
- function attentionLabel(kind, run) {
1286
- const count = run?.state === "waiting" ? questionsOf(run).length : 0;
1287
- return kind === "decision" && count > 1 ? `Decisions needed (${count})` : ATTENTION_LABELS[kind];
1288
- }
1289
- /** Optional Jira key for a new Outcome; it names the Outcome's Delivery Branch. */
1290
- function TicketField({ context }) {
1291
- if (context.ticketFormat !== "jira") return null;
1292
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
1293
- name: "ticket",
1294
- className: "outcome-ticket",
1295
- placeholder: "ABC-123",
1296
- "aria-label": "Ticket (optional)",
1297
- autoComplete: "off",
1298
- spellCheck: false
1299
- });
1300
- }
1301
- /** The actions that move an Outcome forward; the rest stay quiet. */
1302
- var PRIMARY_ACTIONS = /* @__PURE__ */ new Set([
1303
- "answer",
1304
- "start-apply",
1305
- "publish",
1306
- "return",
1307
- "retry",
1308
- "start"
1309
- ]);
1310
- function ActionForm({ id, action, label, primary = PRIMARY_ACTIONS.has(action), children }) {
1311
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(FactoryForm, {
1312
- id,
1313
- action,
1314
- className: "factory-action",
1315
- children: [children, /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
1316
- type: "submit",
1317
- className: primary ? "factory-primary" : void 0,
1318
- children: label
1319
- })]
1320
- });
1321
- }
1322
- /** A control for one action; none when Studio is read-only or the Outcome does not accept it. */
1323
- function actionFor(item, context) {
1324
- const accepted = outcomeActions(item.workset, item.run, context);
1325
- return (action, label, children, primary) => context.writable && accepted.has(action) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActionForm, {
1326
- id: item.workset.id,
1327
- action,
1328
- label,
1329
- primary,
1330
- children
1331
- }) : null;
1332
- }
1333
- var canDelete = (item, context) => context.writable && outcomeActions(item.workset, item.run, context).has("delete");
1334
- /**
1335
- * Delete, offered only while the factory accepts it and behind a confirm step that names the
1336
- * Outcome. A refusal shows in the form; `onDeleted` runs once the Outcome is gone.
1337
- */
1338
- function DeleteOutcome({ item, context, onDeleted }) {
1339
- const [confirming, setConfirming] = (0, import_react.useState)(false);
1340
- const confirm = (0, import_react.useRef)(null);
1341
- (0, import_react.useEffect)(() => {
1342
- if (confirming) confirm.current?.focus();
1343
- }, [confirming]);
1344
- const { workset, run } = item;
1345
- if (!canDelete(item, context)) return null;
1346
- if (!confirming) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
1347
- type: "button",
1348
- className: "factory-delete",
1349
- onClick: () => setConfirming(true),
1350
- children: "Delete"
1351
- });
1352
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(FactoryForm, {
1353
- id: workset.id,
1354
- action: "delete",
1355
- className: "factory-action factory-confirm",
1356
- onDone: onDeleted,
1357
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
1358
- className: "note",
1359
- children: [
1360
- "Delete “",
1361
- workset.title,
1362
- "”?",
1363
- runActive(run) ? " Its run will be stopped first." : "",
1364
- " Its request is removed; branches stay."
1365
- ]
1366
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1367
- className: "factory-confirm-actions",
1368
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
1369
- ref: confirm,
1370
- type: "submit",
1371
- className: "factory-delete",
1372
- children: "Delete outcome"
1373
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
1374
- type: "button",
1375
- onClick: () => setConfirming(false),
1376
- children: "Cancel"
1377
- })]
1378
- })]
1379
- });
1380
- }
1381
- /** The Outcome's state as a coloured dot; the text beside it says the same in words. */
1382
- function ActivityDot({ activity }) {
1383
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1384
- className: "activity-dot",
1385
- "data-activity": activity,
1386
- title: ACTIVITY_LABELS[activity],
1387
- "aria-hidden": "true"
1388
- });
1389
- }
1390
- /** Opens the Add repository dialog and keeps the repository chosen for the next Outcome. */
1391
- function useRepositoryChoice(repositories, sources, companion) {
1392
- const [open, setOpen] = (0, import_react.useState)(false);
1393
- const [chosen, setChosen] = (0, import_react.useState)(null);
1394
- const listed = Object.entries(sources ?? {}).flatMap(([identity, kind]) => kind === "list" ? [identity] : []);
1395
- return {
1396
- ask: () => setOpen(true),
1397
- dialog: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RepositoryDialog, {
1398
- open,
1399
- companion,
1400
- listed,
1401
- onClose: () => setOpen(false),
1402
- onAdded: setChosen
1403
- }),
1404
- value: chosen !== null && repositories.includes(chosen) ? chosen : repositories[0] ?? "",
1405
- choose: setChosen
1406
- };
1407
- }
1408
- var SOURCE_LABELS = {
1409
- linked: "linked",
1410
- list: "listed",
1411
- environment: "configured"
1412
- };
1413
- /** `acme/web · git.acme.test · listed`: the repository, the Git host it clones from and its source. */
1414
- function repositoryText(repository, sources, keys) {
1415
- const key = keys?.[repository];
1416
- const host = key ? hostOf(key) : null;
1417
- const source = sources?.[repository];
1418
- return [
1419
- repository,
1420
- host,
1421
- source ? SOURCE_LABELS[source] : null
1422
- ].filter(Boolean).join(" · ");
1423
- }
1424
- /** Whether the factory holds a Git token for the chosen repository, and Set token when it can. */
1425
- function TokenState({ tokenKey, covered, onSet }) {
1426
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
1427
- className: "note",
1428
- "data-repository-token": covered ? "covered" : "none",
1429
- children: [
1430
- covered ? `A Git token is set for ${hostOf(tokenKey)}.` : `No Git token for ${tokenKey}: only public repositories clone.`,
1431
- " ",
1432
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
1433
- type: "button",
1434
- "data-open-set-token": "",
1435
- onClick: onSet,
1436
- children: "Set token…"
1437
- })
1438
- ]
1439
- });
1440
- }
1441
- /** Plain-language input; Start runs it at once, Save for later keeps it unstarted. */
1442
- function OutcomeInput({ repositories, sources, keys, factoryMode, context }) {
1443
- const choice = useRepositoryChoice(repositories, sources, context.companionDigest);
1444
- const [setting, setSetting] = (0, import_react.useState)(false);
1445
- const tokens = useQuery({
1446
- ...gitTokensQuery(),
1447
- enabled: factoryMode && context.writable
1448
- });
1449
- const options = repositories.map((repository) => ({
1450
- value: repository,
1451
- label: repositoryText(repository, sources, keys)
1452
- }));
1453
- const tokenKey = keys?.[choice.value];
1454
- const tokenState = factoryMode && tokens.data && tokenKey ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TokenState, {
1455
- tokenKey,
1456
- covered: tokenCovers(tokenKey, tokens.data.tokens),
1457
- onSet: () => setSetting(true)
1458
- }) : null;
1459
- const addButton = factoryMode ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
1460
- type: "button",
1461
- "data-open-add-repository": "",
1462
- onClick: choice.ask,
1463
- children: "Add repository…"
1464
- }) : null;
1465
- if (!context.writable) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
1466
- className: "note",
1467
- children: "Read-only mode. Start Studio with --writable to describe outcomes."
1468
- });
1469
- if (repositories.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
1470
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
1471
- className: "note",
1472
- children: "Link a Working Repository to this companion to describe outcomes."
1473
- }),
1474
- addButton,
1475
- factoryMode ? choice.dialog : null
1476
- ] });
1477
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
1478
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(FactoryForm, {
1479
- action: "create",
1480
- className: "outcome-input",
1481
- "data-outcome-input": "",
1482
- children: [
1483
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1484
- className: "outcome-input-label",
1485
- children: "What should we build or improve?"
1486
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", {
1487
- name: "text",
1488
- rows: 3,
1489
- required: true,
1490
- placeholder: "Make onboarding easier: fewer signup steps, and keep authentication working."
1491
- })] }),
1492
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1493
- className: "outcome-input-actions",
1494
- children: [
1495
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
1496
- type: "submit",
1497
- name: "start",
1498
- value: "start",
1499
- className: "factory-primary",
1500
- children: ["Start ", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("kbd", { children: "⌘↵" })]
1501
- }),
1502
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
1503
- type: "submit",
1504
- name: "start",
1505
- value: "later",
1506
- children: "Save for later"
1507
- }),
1508
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TicketField, { context }),
1509
- repositories.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Select, {
1510
- name: "repository",
1511
- required: true,
1512
- items: options,
1513
- value: choice.value,
1514
- onValueChange: (value) => {
1515
- if (value !== null) choice.choose(value);
1516
- },
1517
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectTrigger, {
1518
- "aria-label": "Working Repository",
1519
- className: "w-auto max-w-80",
1520
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectValue, {})
1521
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectContent, { children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectItem, {
1522
- value: option.value,
1523
- children: option.label
1524
- }, option.value)) })]
1525
- }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
1526
- "data-working-repository": "",
1527
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
1528
- type: "hidden",
1529
- name: "repository",
1530
- value: choice.value
1531
- }), repositoryText(choice.value, sources, keys)]
1532
- }),
1533
- addButton
1534
- ]
1535
- }),
1536
- tokenState
1537
- ]
1538
- }),
1539
- factoryMode ? choice.dialog : null,
1540
- tokenKey ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RepositoryTokenDialog, {
1541
- open: setting,
1542
- tokenKey,
1543
- onClose: () => setSetting(false)
1544
- }) : null
1545
- ] });
1546
- }
1547
- /** Milestones as a row of pips and a count; the title names the next one. */
1548
- function MilestoneTrack({ workset }) {
1549
- const milestones = milestonesOf(workset);
1550
- const reached = milestones.filter((milestone) => milestone.reached).length;
1551
- const next = milestones.find((milestone) => !milestone.reached);
1552
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
1553
- className: "outcome-row-track",
1554
- title: `${reached} of ${milestones.length} milestones${next ? `; next: ${next.label}` : ""}`,
1555
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1556
- className: "outcome-row-pips",
1557
- "aria-hidden": "true",
1558
- children: milestones.map((milestone) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", { "data-reached": milestone.reached ? "true" : "false" }, milestone.label))
1559
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
1560
- className: "mono",
1561
- children: [
1562
- reached,
1563
- "/",
1564
- milestones.length
1565
- ]
1566
- })]
1567
- });
1568
- }
1569
- function Checks({ checks }) {
1570
- if (!checks?.length) return null;
1571
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
1572
- className: "outcome-checks",
1573
- "aria-label": "Checks",
1574
- children: checks.map((check) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
1575
- "data-passed": check.passed ? "true" : "false",
1576
- children: [
1577
- check.passed ? "✓" : "✗",
1578
- " ",
1579
- check.name
1580
- ]
1581
- }, check.name))
1582
- });
1583
- }
1584
- /** Opens `change`'s report; names the change only when there are several. */
1585
- function ReportButton({ label, change, several, onOpenReport }) {
1586
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
1587
- type: "button",
1588
- className: "outcome-report-open",
1589
- "data-open-report": change,
1590
- onClick: (event) => onOpenReport(change, event.currentTarget),
1591
- children: [label, several ? ` · ${change}` : ""]
1592
- });
1593
- }
1594
- /** Report controls name their change once the Outcome has several changes or reports. */
1595
- function namesChanges(item) {
1596
- const reports = Object.keys(item.run?.reviewReports ?? {});
1597
- return item.workset.changes.length > 1 || reports.length > 1;
1598
- }
1599
- /** Review plan, opened in the panel, and View changes, when there is something to look at. */
1600
- function ResultLinks({ item, onOpenReport }) {
1601
- const reports = Object.keys(item.run?.reviewReports ?? {});
1602
- const compare = item.run?.compareUrl;
1603
- if (reports.length === 0 && !compare) return null;
1604
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1605
- className: "outcome-results",
1606
- children: [reports.map((change) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportButton, {
1607
- label: "Review plan",
1608
- change,
1609
- several: namesChanges(item),
1610
- onOpenReport
1611
- }, change)), compare ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", {
1612
- href: compare,
1613
- target: "_blank",
1614
- rel: "noreferrer",
1615
- children: "View changes"
1616
- }) : null]
1617
- });
1618
- }
1619
- /** One review report in place of the Outcome's content, in Studio's appearance; Back returns. */
1620
- function OutcomeReport({ change, report, onBack }) {
1621
- const theme = useAppearance((state) => state.theme);
1622
- const src = reportSrc(report, theme);
1623
- const back = (0, import_react.useRef)(null);
1624
- (0, import_react.useEffect)(() => back.current?.focus(), []);
1625
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", {
1626
- className: "outcome-dialog-head outcome-report-head",
1627
- children: [
1628
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
1629
- ref: back,
1630
- type: "button",
1631
- className: "outcome-report-back",
1632
- onClick: onBack,
1633
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { name: "left" }), " Back"]
1634
- }),
1635
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("h2", { children: ["Review report · ", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1636
- className: "mono",
1637
- children: change
1638
- })] }),
1639
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("a", {
1640
- href: src,
1641
- target: "_blank",
1642
- rel: "noopener noreferrer",
1643
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { name: "external" }), " Open in new tab"]
1644
- })
1645
- ]
1646
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("iframe", {
1647
- className: "outcome-report-frame",
1648
- src,
1649
- title: `Review report for ${change}`,
1650
- sandbox: "allow-scripts allow-modals",
1651
- referrerPolicy: "no-referrer"
1652
- })] });
1653
- }
1654
- /** Before archive feedback revises the plan; after it, it starts a new Outcome. */
1655
- function FeedbackField({ item, context }) {
1656
- if (!context.writable) return null;
1657
- const { stage } = item.workset;
1658
- if (stage === "publish" || stage === "done") return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(FactoryForm, {
1659
- action: "create",
1660
- className: "outcome-feedback",
1661
- children: [
1662
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", {
1663
- name: "text",
1664
- rows: 2,
1665
- required: true,
1666
- "aria-label": "A new outcome"
1667
- }),
1668
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TicketField, { context }),
1669
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
1670
- type: "submit",
1671
- name: "start",
1672
- value: "start",
1673
- children: "Start as a new outcome"
1674
- })
1675
- ]
1676
- });
1677
- return actionFor(item, context)("feedback", "Request a change", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", {
1678
- name: "feedback",
1679
- rows: 2,
1680
- required: true,
1681
- "aria-label": "Request a change",
1682
- placeholder: "What should change?"
1683
- }));
1684
- }
1685
- var runActive = (run) => run?.state === "running" || run?.state === "queued";
1686
- /** The last lines the run wrote, for the running focus block. */
1687
- function lastLines(pieces, count) {
1688
- const lines = [];
1689
- for (const piece of pieces.toReversed()) for (const line of piece.text.split("\n").toReversed()) {
1690
- if (line.trim() !== "") lines.unshift(line);
1691
- if (lines.length === count) return lines;
1692
- }
1693
- return lines;
1694
- }
1695
- /** The run's log in the Activity row; the client follows it live while the dialog is open. */
1696
- function OutcomeLog({ item, log }) {
1697
- const { workset, run } = item;
1698
- const active = runActive(run);
1699
- if (!run?.hasLog && !active) return null;
1700
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
1701
- className: "outcome-log-section",
1702
- "aria-label": "Log",
1703
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", {
1704
- className: "outcome-section-head",
1705
- children: [
1706
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: "Log" }),
1707
- active ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1708
- className: "outcome-log-live",
1709
- children: "live"
1710
- }) : null,
1711
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", {
1712
- href: factoryLogRoute(workset.id),
1713
- target: "_blank",
1714
- rel: "noreferrer",
1715
- children: "Full log"
1716
- })
1717
- ]
1718
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LiveLog, {
1719
- id: workset.id,
1720
- log
1721
- })]
1722
- });
1723
- }
1724
- /** The stored log, then the running stage's text and tool activity as it arrives, by who wrote it. */
1725
- function LiveLog({ id, log }) {
1726
- const { pieces, ended } = log;
1727
- const ref = (0, import_react.useRef)(null);
1728
- const following = (0, import_react.useRef)(true);
1729
- const [reading, setReading] = (0, import_react.useState)(false);
1730
- (0, import_react.useEffect)(() => {
1731
- const pre = ref.current;
1732
- if (pre && pieces.length > 0 && following.current) pre.scrollTop = pre.scrollHeight;
1733
- }, [pieces]);
1734
- const toEnd = () => {
1735
- const pre = ref.current;
1736
- if (!pre) return;
1737
- pre.scrollTop = pre.scrollHeight;
1738
- following.current = true;
1739
- setReading(false);
1740
- };
1741
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1742
- className: "outcome-log-frame",
1743
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", {
1744
- ref,
1745
- role: "log",
1746
- "aria-label": "Run log",
1747
- tabIndex: 0,
1748
- onScroll: (event) => {
1749
- const pre = event.currentTarget;
1750
- following.current = pre.scrollHeight - pre.scrollTop - pre.clientHeight < 48;
1751
- setReading(!following.current);
1752
- },
1753
- className: "outcome-log",
1754
- "data-outcome-log": factoryLogStreamRoute(id),
1755
- "data-ended": ended || void 0,
1756
- children: pieces.length > 0 ? pieces.map((piece, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1757
- "data-kind": piece.kind,
1758
- children: piece.text
1759
- }, index)) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1760
- className: "outcome-log-empty",
1761
- children: "Waiting for output."
1762
- })
1763
- }), reading ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
1764
- type: "button",
1765
- className: "outcome-log-jump",
1766
- onClick: toEnd,
1767
- children: "Jump to latest"
1768
- }) : null]
1769
- });
1770
- }
1771
- /** While a person has control: a note on what that means, then their session on the factory's conversation. */
1772
- function ControlSheet({ item, context }) {
1773
- const { workset, run } = item;
1774
- const stepped = useFactoryUi((state) => state.stepped);
1775
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1776
- className: "factory-sheet outcome-control",
1777
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1778
- className: "outcome-control-note",
1779
- children: [run?.control?.reason ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
1780
- className: "outcome-control-reason",
1781
- children: run.control.reason
1782
- }) : null, /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
1783
- className: "note",
1784
- children: CONTROL_HINT
1785
- })]
1786
- }), context.sessions && run?.control?.mode === "manual" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutcomeTerminal, {
1787
- outcome: workset.id,
1788
- companion: context.companionDigest,
1789
- focus: !stepped
1790
- }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
1791
- className: "note",
1792
- children: "The terminal is not available in this Studio."
1793
- })]
1794
- });
1795
- }
1796
- /** Between Take control and the handover: what the person waits for, above the live log. */
1797
- function TakeoverPending({ run, now }) {
1798
- if (run?.control?.mode !== "takeover-requested") return null;
1799
- const stage = run.state === "running" ? run.stage : null;
1800
- const since = run.control.updatedAt ? ageText(run.control.updatedAt, now) : "";
1801
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
1802
- className: "outcome-attention-hint",
1803
- "data-pending": "",
1804
- role: "status",
1805
- "aria-label": "Taking control",
1806
- children: [
1807
- "Control passes to you once",
1808
- " ",
1809
- stage ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
1810
- "the ",
1811
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1812
- className: "mono",
1813
- children: stage
1814
- }),
1815
- " stage"
1816
- ] }) : "the current stage",
1817
- " ",
1818
- "ends; the log below keeps following it. The terminal opens here then.",
1819
- since ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
1820
- className: "factory-age mono",
1821
- children: [
1822
- " · asked ",
1823
- since,
1824
- " ago"
1825
- ]
1826
- }) : null
1827
- ]
1828
- });
1829
- }
1830
- /** The run in a few words: what it does at which stage, and for how long. */
1831
- function runText(run, now) {
1832
- if (!run || run.state === "idle") return "idle";
1833
- const since = run.state === "running" ? run.startedAt : run.updatedAt;
1834
- return `${run.state} ${run.stage}${since ? ` · ${ageText(since, now)}` : ""}`;
1835
- }
1836
- /**
1837
- * What can be done to the run itself, always in reach and quiet: Return to automation is the
1838
- * primary action while the person has control. Nothing renders when nothing applies.
1839
- */
1840
- function OutcomeFooter({ item, context, onDeleted }) {
1841
- const { workset, run } = item;
1842
- const form = actionFor(item, context);
1843
- const open = workset.stage !== "done";
1844
- const back = form("return", "Return to automation");
1845
- const start = open && !workset.queuedAt ? form("start", "Start") : null;
1846
- const cancel = runActive(run) ? form("cancel", "Cancel run") : null;
1847
- const regenerate = workset.stage === "human-review" ? form("regenerate", "Regenerate reports") : null;
1848
- const later = open && workset.queuedAt ? form("later", "Move to later") : null;
1849
- const take = takeControlOf(item, context);
1850
- const remove = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DeleteOutcome, {
1851
- item,
1852
- context,
1853
- onDeleted
1854
- });
1855
- if (![
1856
- back,
1857
- start,
1858
- cancel,
1859
- regenerate,
1860
- later,
1861
- take
1862
- ].some(Boolean) && !canDelete(item, context)) return null;
1863
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("footer", {
1864
- className: "outcome-dialog-foot",
1865
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1866
- className: "outcome-actions",
1867
- role: "group",
1868
- "aria-label": "Run actions",
1869
- children: [
1870
- back,
1871
- start,
1872
- cancel,
1873
- regenerate,
1874
- later,
1875
- take,
1876
- remove
1877
- ]
1878
- }), take ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
1879
- className: "note",
1880
- children: TAKE_CONTROL_HINT
1881
- }) : null]
1882
- });
1883
- }
1884
- /** Take control, for an Outcome whose conversation the factory still drives. */
1885
- function takeControlOf(item, context) {
1886
- const { workset, run } = item;
1887
- if (!run?.conversation || run.control || workset.stage === "done") return null;
1888
- return actionFor(item, context)("take-control", "Take control");
1889
- }
1890
- /** The execution facts beside the map: stage, changes, run and branch. */
1891
- function Facts({ item, context }) {
1892
- const { workset, run } = item;
1893
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("dl", {
1894
- className: "outcome-facts",
1895
- children: [
1896
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", { children: "Stage" }),
1897
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", { children: workset.stageLabel }),
1898
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", { children: "Run" }),
1899
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", { children: runText(run, context.now) }),
1900
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", { children: "Changes" }),
1901
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", {
1902
- className: "mono",
1903
- children: workset.changes.join(", ") || "none yet"
1904
- }),
1905
- run?.pushedBranch ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", { children: "Branch" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", {
1906
- className: "mono",
1907
- children: run.pushedBranch
1908
- })] }) : null,
1909
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", { children: "Id" }),
1910
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", {
1911
- className: "mono",
1912
- children: workset.id
1913
- })
1914
- ]
1915
- });
1916
- }
1917
- /** The recommendation, marked in words beside the option it belongs to. */
1918
- function RecommendedTag() {
1919
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1920
- className: "factory-recommended",
1921
- children: "recommended"
1922
- });
1923
- }
1924
- /** A single question: one click on an option sends it; number keys pick options. */
1925
- function SingleDecision({ item, asked, round, context }) {
1926
- const act = context.writable && outcomeActions(item.workset, item.run, context).has("answer");
1927
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1928
- className: "factory-sheet",
1929
- children: [
1930
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
1931
- className: "factory-question",
1932
- children: asked.question
1933
- }),
1934
- asked.options?.length ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
1935
- className: "factory-options",
1936
- role: "group",
1937
- "aria-label": "Answers",
1938
- children: asked.options.map((option, index) => {
1939
- const recommended = option === asked.recommended;
1940
- const shortcut = index < 9 ? String(index + 1) : void 0;
1941
- return act ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(FactoryForm, {
1942
- id: item.workset.id,
1943
- action: "answer",
1944
- className: "factory-option",
1945
- children: [
1946
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
1947
- type: "hidden",
1948
- name: "round",
1949
- value: round
1950
- }),
1951
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
1952
- type: "hidden",
1953
- name: "answer",
1954
- value: option
1955
- }),
1956
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
1957
- type: "submit",
1958
- "data-recommended": recommended ? "true" : "false",
1959
- "data-option-key": shortcut,
1960
- "aria-keyshortcuts": shortcut,
1961
- children: [
1962
- shortcut ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("kbd", {
1963
- "aria-hidden": "true",
1964
- children: shortcut
1965
- }) : null,
1966
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: option }),
1967
- recommended ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RecommendedTag, {}) : null
1968
- ]
1969
- })
1970
- ]
1971
- }, option) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
1972
- className: "factory-choice",
1973
- "data-recommended": recommended ? "true" : "false",
1974
- children: [option, recommended ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RecommendedTag, {}) : null]
1975
- }, option);
1976
- })
1977
- }) : asked.recommended ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
1978
- className: "note",
1979
- children: ["Recommended: ", asked.recommended]
1980
- }) : null,
1981
- actionFor(item, context)("answer", asked.options?.length ? "Send my words" : "Answer", /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
1982
- type: "hidden",
1983
- name: "round",
1984
- value: round
1985
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", {
1986
- name: "answer",
1987
- rows: 2,
1988
- required: true,
1989
- "aria-label": "Answer in your words",
1990
- placeholder: asked.options?.length ? "Or answer in your words" : "Your answer"
1991
- })] }))
1992
- ]
1993
- });
1994
- }
1995
- /** One question of a round: its options as choices, none chosen, and own words that override. */
1996
- function QuestionBlock({ asked, index }) {
1997
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("fieldset", {
1998
- className: "factory-question-set",
1999
- children: [
2000
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("legend", {
2001
- className: "factory-question",
2002
- children: [
2003
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
2004
- className: "mono",
2005
- children: [index + 1, "."]
2006
- }),
2007
- " ",
2008
- asked.question
2009
- ]
2010
- }),
2011
- asked.options?.length ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
2012
- className: "factory-choices",
2013
- children: asked.options.map((option) => {
2014
- const recommended = option === asked.recommended;
2015
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
2016
- className: "factory-choice",
2017
- "data-recommended": recommended ? "true" : "false",
2018
- children: [
2019
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
2020
- type: "radio",
2021
- name: `choice-${index}`,
2022
- value: option
2023
- }),
2024
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: option }),
2025
- recommended ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RecommendedTag, {}) : null
2026
- ]
2027
- }, option);
2028
- })
2029
- }) : asked.recommended ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
2030
- className: "note",
2031
- children: ["Recommended: ", asked.recommended]
2032
- }) : null,
2033
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", {
2034
- name: `answer-${index}`,
2035
- rows: 1,
2036
- "aria-label": `Answer to question ${index + 1} in your words`,
2037
- placeholder: asked.options?.length ? "Or in your words (overrides the choice)" : "Your answer"
2038
- })
2039
- ]
2040
- });
2041
- }
2042
- /** How many questions of a round have a choice or words, read from the form. */
2043
- function answeredIn(form, count) {
2044
- const data = new FormData(form);
2045
- let answered = 0;
2046
- for (let index = 0; index < count; index += 1) {
2047
- const words = data.get(`answer-${index}`);
2048
- if (data.get(`choice-${index}`) || typeof words === "string" && words.trim()) answered += 1;
2049
- }
2050
- return answered;
2051
- }
2052
- /** The questions the agent asked together: answered together, nothing chosen for the person. */
2053
- function GroupedDecision({ item, questions, round, context }) {
2054
- const [answered, setAnswered] = (0, import_react.useState)(0);
2055
- if (!context.writable || !outcomeActions(item.workset, item.run, context).has("answer")) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ol", {
2056
- className: "outcome-history",
2057
- children: questions.map((asked) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: asked.question }, asked.question))
2058
- });
2059
- const count = (event) => {
2060
- const form = event.currentTarget.closest("form");
2061
- if (form) setAnswered(answeredIn(form, questions.length));
2062
- };
2063
- const recommended = questions.every((asked) => asked.recommended);
2064
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2065
- className: "factory-sheet",
2066
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(FactoryForm, {
2067
- id: item.workset.id,
2068
- action: "answer",
2069
- className: "factory-action factory-round",
2070
- children: [
2071
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
2072
- type: "hidden",
2073
- name: "round",
2074
- value: round
2075
- }),
2076
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
2077
- className: "factory-round-questions",
2078
- onChange: count,
2079
- onInput: count,
2080
- children: questions.map((asked, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(QuestionBlock, {
2081
- asked,
2082
- index
2083
- }, asked.question))
2084
- }),
2085
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2086
- className: "factory-sheet-actions",
2087
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
2088
- type: "submit",
2089
- className: "factory-primary",
2090
- disabled: answered < questions.length,
2091
- children: "Send answers"
2092
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
2093
- className: "factory-round-count mono",
2094
- "aria-live": "polite",
2095
- children: [
2096
- answered,
2097
- " of ",
2098
- questions.length,
2099
- " answered"
2100
- ]
2101
- })]
2102
- })
2103
- ]
2104
- }), recommended ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(FactoryForm, {
2105
- id: item.workset.id,
2106
- action: "answer",
2107
- className: "factory-action",
2108
- children: [
2109
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
2110
- type: "hidden",
2111
- name: "round",
2112
- value: round
2113
- }),
2114
- questions.map((asked, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
2115
- type: "hidden",
2116
- name: `choice-${index}`,
2117
- value: asked.recommended
2118
- }, asked.question)),
2119
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
2120
- type: "submit",
2121
- children: "Accept all recommendations"
2122
- })
2123
- ]
2124
- }) : null]
2125
- });
2126
- }
2127
- /** The questions the agent asked: one alone is answered in a click, several together. */
2128
- function DecisionSheet({ item, run, context }) {
2129
- const questions = questionsOf(run);
2130
- if (questions.length === 1) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SingleDecision, {
2131
- item,
2132
- asked: questions[0],
2133
- round: run.round ?? "",
2134
- context
2135
- });
2136
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GroupedDecision, {
2137
- item,
2138
- questions,
2139
- round: run.round ?? "",
2140
- context
2141
- });
2142
- }
2143
- /** The plan under review: what to read, then Approve plan or Request changes, in place. */
2144
- function PlanReview({ item, context, onOpenReport, onOpenDoc }) {
2145
- const { workset, run } = item;
2146
- const stored = run?.reviewReports ?? {};
2147
- const several = namesChanges(item);
2148
- const named = (label, change) => several ? `${label} · ${change}` : label;
2149
- const canRequest = context.writable && outcomeActions(workset, run, context).has("feedback");
2150
- const [open, setOpen] = (0, import_react.useState)(false);
2151
- const [draft, setDraft] = (0, import_react.useState)("");
2152
- const field = (0, import_react.useRef)(null);
2153
- const toggle = (0, import_react.useRef)(null);
2154
- (0, import_react.useEffect)(() => {
2155
- if (open) field.current?.focus();
2156
- }, [open]);
2157
- const close = () => {
2158
- (0, import_react_dom.flushSync)(() => setOpen(false));
2159
- toggle.current?.focus();
2160
- };
2161
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2162
- className: "outcome-plan",
2163
- children: [
2164
- workset.changes.map((change) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
2165
- className: "outcome-read",
2166
- children: [
2167
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
2168
- className: "muted",
2169
- children: "Read"
2170
- }),
2171
- stored[change] ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportButton, {
2172
- label: "Show me",
2173
- change,
2174
- several,
2175
- onOpenReport
2176
- }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
2177
- className: "note",
2178
- "data-report-missing": change,
2179
- children: [
2180
- "No review report for ",
2181
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
2182
- className: "mono",
2183
- children: change
2184
- }),
2185
- "."
2186
- ]
2187
- }),
2188
- ["spec", "tasks"].map((doc) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
2189
- type: "button",
2190
- className: "outcome-report-open",
2191
- "data-open-doc": `${doc}:${change}`,
2192
- onClick: (event) => onOpenDoc(change, doc, event.currentTarget),
2193
- children: named(`Show ${doc}`, change)
2194
- }, doc))
2195
- ]
2196
- }, change)),
2197
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2198
- className: "factory-sheet-actions",
2199
- children: [actionFor(item, context)("start-apply", "Approve plan", void 0, !open), canRequest ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
2200
- ref: toggle,
2201
- type: "button",
2202
- "aria-expanded": open,
2203
- onClick: () => open ? close() : setOpen(true),
2204
- children: "Request changes"
2205
- }) : null]
2206
- }),
2207
- canRequest && open ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(FactoryForm, {
2208
- id: workset.id,
2209
- action: "feedback",
2210
- className: "outcome-request",
2211
- onDone: () => {
2212
- setDraft("");
2213
- setOpen(false);
2214
- },
2215
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", {
2216
- ref: field,
2217
- name: "feedback",
2218
- rows: 3,
2219
- "aria-label": "What should change?",
2220
- placeholder: "What should change?",
2221
- value: draft,
2222
- onChange: (event) => setDraft(event.target.value),
2223
- onKeyDown: (event) => {
2224
- if (event.key !== "Escape") return;
2225
- event.stopPropagation();
2226
- close();
2227
- }
2228
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2229
- className: "factory-sheet-actions",
2230
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
2231
- type: "submit",
2232
- className: "factory-primary",
2233
- disabled: draft.trim() === "",
2234
- children: "Send changes"
2235
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
2236
- type: "button",
2237
- onClick: close,
2238
- children: "Cancel"
2239
- })]
2240
- })]
2241
- }) : null
2242
- ]
2243
- });
2244
- }
2245
- /** What a person does for one attention item, opened in place. */
2246
- function FocusBody({ item, kind, context, onOpenReport, onOpenDoc }) {
2247
- const { run } = item;
2248
- const form = actionFor(item, context);
2249
- if (kind === "control") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ControlSheet, {
2250
- item,
2251
- context
2252
- });
2253
- if (kind === "decision" && run?.state === "waiting") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DecisionSheet, {
2254
- item,
2255
- run,
2256
- context
2257
- });
2258
- if (kind === "problem") return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2259
- className: "factory-sheet",
2260
- children: [
2261
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
2262
- className: "factory-problems",
2263
- children: run?.state === "failed" ? run.reason : "Stopped when Studio restarted."
2264
- }),
2265
- run?.needsCredential ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OpenAgents, { label: "Set the agent credential" }) : null,
2266
- form("retry", "Retry")
2267
- ]
2268
- });
2269
- if (kind === "review") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PlanReview, {
2270
- item,
2271
- context,
2272
- onOpenReport,
2273
- onOpenDoc
2274
- });
2275
- if (kind === "merge") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
2276
- className: "factory-sheet",
2277
- children: run?.compareUrl ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("a", {
2278
- href: run.compareUrl,
2279
- target: "_blank",
2280
- rel: "noreferrer",
2281
- children: [
2282
- "Open ",
2283
- run.pushedBranch ?? "the branch",
2284
- " to merge"
2285
- ]
2286
- }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
2287
- className: "note",
2288
- children: [
2289
- "Merge ",
2290
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
2291
- className: "mono",
2292
- children: run?.pushedBranch ?? "the delivery branch"
2293
- }),
2294
- ", then refresh."
2295
- ]
2296
- })
2297
- });
2298
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
2299
- className: "factory-sheet",
2300
- children: form("publish", "Publish")
2301
- });
2302
- }
2303
- var dialogId = (id) => `outcome-${id}`;
2304
- /**
2305
- * Opens, steps to or closes an Outcome's dialog through the address, so it can be linked,
2306
- * a reload reopens it and Back closes it. Stepping replaces the entry; opening adds one.
2307
- */
2308
- function useOutcomeAddress() {
2309
- const navigate = useNavigate();
2310
- const go = (outcome, replace = false) => void navigate({
2311
- to: "/factory",
2312
- search: (previous) => ({
2313
- ...previous,
2314
- outcome
2315
- }),
2316
- replace,
2317
- resetScroll: false
2318
- });
2319
- return {
2320
- open: (id) => go(id),
2321
- step: (id) => go(id, true),
2322
- close: () => go(void 0)
2323
- };
2324
- }
2325
- /** One line per Outcome: what it is and where it is; the row opens the dialog. */
2326
- function OutcomeRow({ item, context, lead, progress = true, trailing }) {
2327
- const { workset, run } = item;
2328
- const situation = situationOf(workset, run);
2329
- const since = situation.at ?? (run?.updatedAt || workset.queuedAt);
2330
- const address = useOutcomeAddress();
2331
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
2332
- className: "outcome-row-item",
2333
- "data-workset": workset.id,
2334
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
2335
- type: "button",
2336
- className: "outcome-row",
2337
- "data-outcome-row": "",
2338
- onClick: () => {
2339
- useFactoryUi.getState().setStepped(false);
2340
- address.open(workset.id);
2341
- },
2342
- children: [
2343
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActivityDot, { activity: activityOf(workset, run) }),
2344
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
2345
- className: "outcome-row-title",
2346
- children: workset.title
2347
- }),
2348
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
2349
- className: "outcome-row-where",
2350
- children: lead ?? situation.text
2351
- }),
2352
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
2353
- className: "outcome-row-progress",
2354
- children: progress ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MilestoneTrack, { workset }) : null
2355
- }),
2356
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
2357
- className: "outcome-row-age mono",
2358
- children: since ? ageText(since, context.now) : ""
2359
- })
2360
- ]
2361
- }), trailing]
2362
- });
2363
- }
2364
- function OutcomeList({ label, section, count, children }) {
2365
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
2366
- className: "outcome-list-section",
2367
- "data-section": section,
2368
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ListCard, {
2369
- title: label,
2370
- count,
2371
- tone: section === "attention" ? "warn" : void 0,
2372
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
2373
- className: "outcome-list",
2374
- children
2375
- })
2376
- })
2377
- });
2378
- }
2379
- var sameText = (a, b) => a.replace(/\.$/, "").toLowerCase() === b.replace(/\.$/, "").toLowerCase();
2380
- /** Whether something failed or is wrong, so checks, problems and results belong in view. */
2381
- function hasTrouble(item, situation) {
2382
- return item.workset.problems.length > 0 || (situation.checks?.some((check) => !check.passed) ?? false);
2383
- }
2384
- /** Failed checks, problems and result links; in the focus block only while something is wrong. */
2385
- function Findings({ item, situation, onOpenReport }) {
2386
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
2387
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Checks, { checks: situation.checks }),
2388
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ResultLinks, {
2389
- item,
2390
- onOpenReport
2391
- }),
2392
- item.workset.problems.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
2393
- className: "factory-problems",
2394
- children: item.workset.problems.map((problem) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: problem }, problem))
2395
- }) : null
2396
- ] });
2397
- }
2398
- /** The step being worked on, its task progress when tracked, and the latest output. */
2399
- function WorkingOn({ text, tasks, tail }) {
2400
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2401
- className: "outcome-working",
2402
- role: "status",
2403
- "aria-label": "Working on",
2404
- children: [
2405
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
2406
- className: "outcome-working-step",
2407
- children: text
2408
- }),
2409
- tasks ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Progress, {
2410
- done: tasks.done,
2411
- total: tasks.total
2412
- }) : null,
2413
- tail.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ol", {
2414
- className: "outcome-tail",
2415
- "aria-label": "Latest log",
2416
- children: tail.map((line, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: line }, index))
2417
- }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
2418
- className: "note",
2419
- children: "Waiting for output."
2420
- })
2421
- ]
2422
- });
2423
- }
2424
- /**
2425
- * The one thing the panel is about: what is happening or what is asked of the person, as one
2426
- * sentence, with its action. A running Outcome shows the last lines of its log.
2427
- */
2428
- function FocusBlock({ item, kind, context, situation, log, onOpenReport, onOpenDoc }) {
2429
- const { workset, run } = item;
2430
- const next = nextStepOf(workset, run);
2431
- const tail = run?.state === "running" ? lastLines(log.pieces, 3) : null;
2432
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
2433
- className: "outcome-focus",
2434
- "data-kind": kind ?? void 0,
2435
- "aria-label": kind ? "Needs you" : "Where it is",
2436
- children: [
2437
- kind ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: attentionLabel(kind, run) }) : null,
2438
- tail ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(WorkingOn, {
2439
- text: situation.text,
2440
- tasks: context.tasksOf(workset),
2441
- tail
2442
- }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
2443
- className: "outcome-situation",
2444
- children: [situation.text, sameText(next, situation.text) ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
2445
- className: "outcome-next",
2446
- children: [
2447
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
2448
- className: "muted",
2449
- children: "Next:"
2450
- }),
2451
- " ",
2452
- next
2453
- ]
2454
- })]
2455
- }),
2456
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TakeoverPending, {
2457
- run,
2458
- now: context.now
2459
- }),
2460
- hasTrouble(item, situation) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Findings, {
2461
- item,
2462
- situation,
2463
- onOpenReport
2464
- }) : null,
2465
- kind ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FocusBody, {
2466
- item,
2467
- kind,
2468
- context,
2469
- onOpenReport,
2470
- onOpenDoc
2471
- }) : null
2472
- ]
2473
- });
2474
- }
2475
- /** The run's reported situations, newest first; nothing before the first report. */
2476
- function History({ run, now }) {
2477
- if (!run?.situations?.length) return null;
2478
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
2479
- className: "outcome-history-section",
2480
- "aria-label": "What happened",
2481
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: "What happened" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ol", {
2482
- className: "outcome-history",
2483
- children: run.situations.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
2484
- className: "factory-age mono",
2485
- children: ageText(entry.at, now)
2486
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: entry.text })] }, entry.at))
2487
- })]
2488
- });
2489
- }
2490
- /** One line until opened: its name and a short summary of what it holds. */
2491
- function Row({ label, summary, className, children }) {
2492
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("details", {
2493
- className: cn("outcome-row-fold", className),
2494
- "aria-label": label,
2495
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("summary", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
2496
- className: "outcome-row-fold-label",
2497
- children: label
2498
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
2499
- className: "outcome-row-fold-summary",
2500
- children: summary
2501
- })] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
2502
- className: "outcome-row-fold-body",
2503
- children
2504
- })]
2505
- });
2506
- }
2507
- /** Activity, Request and Details: everything the focus block leaves out, one line each. */
2508
- function OutcomeRows({ item, kind, context, situation, log, onOpenReport }) {
2509
- const { workset, run } = item;
2510
- const updates = run?.situations?.length ?? 0;
2511
- const hasLog = Boolean(run?.hasLog) || runActive(run);
2512
- const activity = [updates > 0 ? `${updates} ${updates === 1 ? "update" : "updates"}` : "", hasLog ? "log" : ""].filter(Boolean).join(" · ");
2513
- const feedback = kind !== "review" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FeedbackField, {
2514
- item,
2515
- context
2516
- }) : null;
2517
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
2518
- activity ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Row, {
2519
- label: "Activity",
2520
- summary: activity,
2521
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(History, {
2522
- run,
2523
- now: context.now
2524
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutcomeLog, {
2525
- item,
2526
- log
2527
- })]
2528
- }) : null,
2529
- workset.intent || feedback ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Row, {
2530
- label: "Request",
2531
- summary: workset.intent.split("\n")[0] ?? "",
2532
- children: [workset.intent ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
2533
- className: "outcome-intent",
2534
- children: workset.intent
2535
- }) : null, feedback]
2536
- }) : null,
2537
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Row, {
2538
- label: "Details",
2539
- summary: `${workset.stageLabel} · ${runText(run, context.now)}`,
2540
- className: "outcome-dialog-rail",
2541
- children: [hasTrouble(item, situation) ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Findings, {
2542
- item,
2543
- situation,
2544
- onOpenReport
2545
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Facts, {
2546
- item,
2547
- context
2548
- })]
2549
- })
2550
- ] });
2551
- }
2552
- /**
2553
- * Everything about one Outcome, in the slide-over panel: the state, the Delivery Path on one
2554
- * line, one focus block, the Activity, Request and Details rows, and the run's actions.
2555
- * In control the terminal takes the width. A review report opens in its place, with Back.
2556
- */
2557
- function OutcomePanel({ item, kind, context, onDeleted }) {
2558
- const { workset, run } = item;
2559
- const situation = situationOf(workset, run);
2560
- const activity = activityOf(workset, run);
2561
- const since = run?.state === "running" ? run.startedAt : run?.updatedAt || situation.at;
2562
- const id = dialogId(workset.id);
2563
- const log = useOutcomeLog(run?.hasLog || runActive(run) ? factoryLogStreamRoute(workset.id) : null);
2564
- const [openReport, setOpenReport] = (0, import_react.useState)(null);
2565
- const opener = (0, import_react.useRef)(null);
2566
- if (openReport && run?.reviewReports?.[openReport.change] !== openReport.report) setOpenReport(null);
2567
- const [openDoc, setOpenDoc] = (0, import_react.useState)(null);
2568
- if (openDoc && (workset.stage !== "human-review" || !workset.changes.includes(openDoc.change))) setOpenDoc(null);
2569
- const showReport = (change, from) => {
2570
- const stored = run?.reviewReports?.[change];
2571
- if (!stored) return;
2572
- opener.current = from;
2573
- setOpenDoc(null);
2574
- setOpenReport({
2575
- change,
2576
- report: stored
2577
- });
2578
- };
2579
- const showDoc = (change, doc, from) => {
2580
- opener.current = from;
2581
- setOpenReport(null);
2582
- setOpenDoc({
2583
- change,
2584
- doc
2585
- });
2586
- };
2587
- const back = () => {
2588
- (0, import_react_dom.flushSync)(() => {
2589
- setOpenReport(null);
2590
- setOpenDoc(null);
2591
- });
2592
- opener.current?.focus();
2593
- };
2594
- const reportOpen = openReport !== null || openDoc !== null;
2595
- let layout;
2596
- if (reportOpen) layout = "report";
2597
- else if (kind === "control") layout = "control";
2598
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2599
- id,
2600
- className: "outcome-dialog",
2601
- "data-outcome-panel": "",
2602
- "data-workset": workset.id,
2603
- "data-layout": layout,
2604
- children: [
2605
- openReport ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutcomeReport, {
2606
- change: openReport.change,
2607
- report: openReport.report,
2608
- onBack: back
2609
- }) : null,
2610
- openDoc ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChangeDoc, {
2611
- companion: context.companionDigest,
2612
- change: openDoc.change,
2613
- doc: openDoc.doc,
2614
- onBack: back
2615
- }) : null,
2616
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("header", {
2617
- className: "outcome-dialog-head",
2618
- hidden: reportOpen,
2619
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2620
- className: "outcome-dialog-heading",
2621
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", {
2622
- id: `${id}-title`,
2623
- children: workset.title
2624
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
2625
- className: "outcome-dialog-state",
2626
- "data-activity": activity,
2627
- children: [
2628
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActivityDot, { activity }),
2629
- ACTIVITY_LABELS[activity],
2630
- since ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
2631
- className: "factory-age mono",
2632
- children: ["· ", ageText(since, context.now)]
2633
- }) : null
2634
- ]
2635
- })]
2636
- })
2637
- }),
2638
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2639
- className: "outcome-dialog-main",
2640
- hidden: reportOpen,
2641
- children: [
2642
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
2643
- className: "outcome-path",
2644
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PathSteps, {
2645
- compact: true,
2646
- steps: PATH_STEPS,
2647
- ...pathPositionOf(workset, run)
2648
- })
2649
- }),
2650
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FocusBlock, {
2651
- item,
2652
- kind,
2653
- context,
2654
- situation,
2655
- log,
2656
- onOpenReport: showReport,
2657
- onOpenDoc: showDoc
2658
- }),
2659
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutcomeRows, {
2660
- item,
2661
- kind,
2662
- context,
2663
- situation,
2664
- log,
2665
- onOpenReport: showReport
2666
- }),
2667
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutcomeFooter, {
2668
- item,
2669
- context,
2670
- onDeleted
2671
- })
2672
- ]
2673
- })
2674
- ]
2675
- });
2676
- }
2677
- function Completed({ items, context, expanded }) {
2678
- if (items.length === 0) return null;
2679
- const rest = expanded ? [] : items.slice(RECENT_COMPLETED);
2680
- const row = (item) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutcomeRow, {
2681
- item,
2682
- context,
2683
- progress: false
2684
- }, item.workset.id);
2685
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(OutcomeList, {
2686
- label: "Done",
2687
- section: "completed",
2688
- count: items.length,
2689
- children: [(expanded ? items : items.slice(0, RECENT_COMPLETED)).map(row), rest.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("details", {
2690
- className: "outcome-list-more",
2691
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("summary", { children: ["Show all ", items.length] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
2692
- className: "outcome-list",
2693
- children: rest.map(row)
2694
- })]
2695
- }) }) : null]
2696
- });
2697
- }
2698
- /** The journey an Outcome takes, shown before the first one exists. */
2699
- function FirstRun() {
2700
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
2701
- className: "factory-first-run",
2702
- "aria-label": "How the factory works",
2703
- children: [
2704
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: "How an outcome gets delivered" }),
2705
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("ol", { children: [
2706
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: "Describe what you want built or improved, and start it." }),
2707
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: "The factory clarifies and explores; answer its questions as they come up." }),
2708
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: "It writes a plan. Review it, then approve or request a change." }),
2709
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: "It builds the plan on a delivery branch. Merge the branch, then publish." })
2710
- ] }),
2711
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
2712
- className: "note",
2713
- children: "Everything that needs you shows under Needs you. Open an outcome to follow its log or take control of its conversation."
2714
- })
2715
- ]
2716
- });
2717
- }
2718
- /**
2719
- * The board's lists in board order and as the filter leaves them. Each Outcome is listed once:
2720
- * what needs the person is not repeated under Running.
2721
- */
2722
- function useBoard(home) {
2723
- const query = useFactoryUi((state) => state.filter).trim();
2724
- const kinds = new Map(home.attention.map((item) => [item.workset.id, item.kind]));
2725
- const running = home.active.filter((item) => !kinds.has(item.workset.id));
2726
- const shows = (item) => {
2727
- if (!query) return true;
2728
- const kind = kinds.get(item.workset.id);
2729
- const label = kind ? attentionLabel(kind, item.run) : "";
2730
- return matchesFilter(`${item.workset.title} ${situationOf(item.workset, item.run).text} ${label}`, query);
2731
- };
2732
- const attention = home.attention.filter(shows);
2733
- const runningShown = running.filter(shows);
2734
- const later = home.later.filter(shows);
2735
- const completed = home.completed.filter(shows);
2736
- return {
2737
- kinds,
2738
- query,
2739
- ordered: [
2740
- ...home.attention,
2741
- ...running,
2742
- ...home.later,
2743
- ...home.completed
2744
- ],
2745
- attention,
2746
- running: {
2747
- all: running,
2748
- shown: runningShown
2749
- },
2750
- later,
2751
- completed,
2752
- shownCount: attention.length + runningShown.length + later.length + completed.length
2753
- };
2754
- }
2755
- /** Opens the Agents panel. */
2756
- function OpenAgents({ label }) {
2757
- const setAgentsOpen = useFactoryUi((state) => state.setAgentsOpen);
2758
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
2759
- type: "button",
2760
- "data-open-agents": "",
2761
- onClick: () => setAgentsOpen(true),
2762
- children: label
2763
- });
2764
- }
2765
- /** Opens the Git access panel. */
2766
- function OpenGitAccess() {
2767
- const setGitAccessOpen = useFactoryUi((state) => state.setGitAccessOpen);
2768
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
2769
- type: "button",
2770
- "data-open-git-access": "",
2771
- onClick: () => setGitAccessOpen(true),
2772
- children: "Git access"
2773
- });
2774
- }
2775
- /** The filter, the keys and the offer to notify, above the board. */
2776
- function BoardToolbar({ count, worksets, writable, factoryMode, onPass, children }) {
2777
- const filter = useFactoryUi((state) => state.filter);
2778
- const setFilter = useFactoryUi((state) => state.setFilter);
2779
- const notifications = useNotificationOffer();
2780
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2781
- className: "view-intro",
2782
- "data-factory-live": "",
2783
- "data-needs-you": count,
2784
- children: [
2785
- children,
2786
- worksets > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
2787
- type: "search",
2788
- className: "outcome-filter",
2789
- "data-outcome-filter": "",
2790
- placeholder: "Filter outcomes",
2791
- "aria-label": "Filter outcomes",
2792
- "aria-keyshortcuts": "/",
2793
- value: filter,
2794
- onChange: (event) => setFilter(event.target.value),
2795
- onKeyDown: (event) => {
2796
- if (event.key !== "Escape") return;
2797
- setFilter("");
2798
- event.currentTarget.blur();
2799
- }
2800
- }) : null,
2801
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
2802
- className: "factory-keys",
2803
- children: [
2804
- writable ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("kbd", { children: "N" }), " new"] }) : null,
2805
- worksets > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("kbd", { children: "/" }), " filter"] }) : null,
2806
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("kbd", { children: "J" }),
2807
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("kbd", { children: "K" }),
2808
- " move ",
2809
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("kbd", { children: "↵" }),
2810
- " open ",
2811
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("kbd", { children: "1" }),
2812
- "–",
2813
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("kbd", { children: "9" }),
2814
- " answer"
2815
- ]
2816
- }),
2817
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
2818
- type: "button",
2819
- "data-factory-notify": "",
2820
- hidden: !notifications.offered,
2821
- onClick: notifications.ask,
2822
- children: "Notify me about decisions"
2823
- }),
2824
- factoryMode && writable ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OpenAgents, { label: "Agents" }) : null,
2825
- factoryMode && writable ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OpenGitAccess, {}) : null,
2826
- onPass ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
2827
- type: "button",
2828
- className: "factory-primary factory-pass",
2829
- onClick: onPass,
2830
- children: ["Clear what needs you ", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
2831
- className: "mono",
2832
- children: count
2833
- })]
2834
- }) : null
2835
- ]
2836
- });
2837
- }
2838
- /** Task counts summed over a Workset's changes; null when none are tracked. */
2839
- function tasksIn(changes) {
2840
- const byName = new Map((changes ?? []).map((change) => [change.name, change]));
2841
- return (workset) => {
2842
- let done = 0;
2843
- let total = 0;
2844
- for (const name of workset.changes) {
2845
- const change = byName.get(name);
2846
- done += change?.completedTasks ?? 0;
2847
- total += change?.totalTasks ?? 0;
2848
- }
2849
- return total > 0 ? {
2850
- done,
2851
- total
2852
- } : null;
2853
- };
2854
- }
2855
- /** The board's Outcomes and the context every row and panel reads. */
2856
- function contextOf({ payload, companionDigest, writable, sessions = null, runs = null, now }) {
2857
- return {
2858
- home: factoryHome(payload.worksets, runs),
2859
- context: {
2860
- companionDigest,
2861
- writable,
2862
- sessions,
2863
- runner: runs !== null,
2864
- now,
2865
- ticketFormat: payload.ticketFormat,
2866
- tasksOf: tasksIn(payload.changes)
2867
- }
2868
- };
2869
- }
2870
- /** Outcomes as lists of one line each; everything else opens in the Outcome's panel. */
2871
- function Factory({ payload, companionDigest, writable, sessions = null, runs = null, now, openId, factoryMode = false }) {
2872
- const { home, context } = contextOf({
2873
- payload,
2874
- companionDigest,
2875
- writable,
2876
- sessions,
2877
- runs,
2878
- now
2879
- });
2880
- const { kinds, ordered, attention, running, later, completed, shownCount, query } = useBoard(home);
2881
- const idle = running.all.length === 0 && home.attention.length === 0;
2882
- useFactoryKeys();
2883
- useNeedsYou(home.attention.length);
2884
- const [list, setList] = (0, import_react.useState)("all");
2885
- const [pass, setPass] = (0, import_react.useState)(false);
2886
- const address = useOutcomeAddress();
2887
- const shows = (section) => list === "all" || list === section;
2888
- const walk = pass ? home.attention : ordered;
2889
- const open = openId ? ordered.find((item) => item.workset.id === openId) ?? null : null;
2890
- const agentsOpen = useFactoryUi((state) => state.agentsOpen);
2891
- const setAgentsOpen = useFactoryUi((state) => state.setAgentsOpen);
2892
- const gitAccessOpen = useFactoryUi((state) => state.gitAccessOpen);
2893
- const setGitAccessOpen = useFactoryUi((state) => state.setGitAccessOpen);
2894
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FactoryCompanion.Provider, {
2895
- value: companionDigest,
2896
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
2897
- className: cn(PAGE_PAD, "view-section factory-home grid content-start gap-4 pb-10"),
2898
- "aria-label": "Factory",
2899
- children: [
2900
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutcomeInput, {
2901
- repositories: payload.linkedRepositories,
2902
- sources: payload.repositorySources,
2903
- keys: payload.repositoryKeys,
2904
- factoryMode,
2905
- context
2906
- }),
2907
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BoardToolbar, {
2908
- count: home.attention.length,
2909
- worksets: payload.worksets.length,
2910
- writable,
2911
- factoryMode,
2912
- onPass: home.attention.length > 0 ? () => {
2913
- setPass(true);
2914
- useFactoryUi.getState().setStepped(false);
2915
- address.open(home.attention[0].workset.id);
2916
- } : void 0,
2917
- children: payload.worksets.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pills, {
2918
- label: "Show outcomes",
2919
- value: list,
2920
- onChange: setList,
2921
- options: [
2922
- {
2923
- value: "all",
2924
- label: "All",
2925
- count: payload.worksets.length
2926
- },
2927
- {
2928
- value: "attention",
2929
- label: "Needs you",
2930
- count: home.attention.length,
2931
- tone: "warn"
2932
- },
2933
- {
2934
- value: "active",
2935
- label: "Running",
2936
- count: running.all.length
2937
- },
2938
- {
2939
- value: "later",
2940
- label: "Later",
2941
- count: home.later.length
2942
- },
2943
- {
2944
- value: "completed",
2945
- label: "Done",
2946
- count: home.completed.length
2947
- }
2948
- ]
2949
- }) : null
2950
- }),
2951
- shows("attention") && attention.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutcomeList, {
2952
- label: "Needs you",
2953
- section: "attention",
2954
- count: attention.length,
2955
- children: attention.map((item) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutcomeRow, {
2956
- item,
2957
- context,
2958
- lead: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
2959
- className: "attention-kind",
2960
- "data-kind": item.kind,
2961
- children: attentionLabel(item.kind, item.run)
2962
- })
2963
- }, item.workset.id))
2964
- }) : null,
2965
- shows("active") && running.shown.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutcomeList, {
2966
- label: "Running",
2967
- section: "active",
2968
- count: running.shown.length,
2969
- children: running.shown.map((item) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutcomeRow, {
2970
- item,
2971
- context
2972
- }, item.workset.id))
2973
- }) : null,
2974
- payload.worksets.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FirstRun, {}) : idle ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
2975
- className: "note",
2976
- children: "The factory is idle. Describe an outcome to get it started."
2977
- }) : null,
2978
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
2979
- className: "note outcome-filter-empty",
2980
- "data-outcome-filter-empty": "",
2981
- hidden: !query || shownCount > 0,
2982
- children: "No outcomes match the filter."
2983
- }),
2984
- shows("later") && later.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutcomeList, {
2985
- label: "Later",
2986
- section: "later",
2987
- count: later.length,
2988
- children: later.map((item) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutcomeRow, {
2989
- item,
2990
- context,
2991
- progress: false,
2992
- trailing: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [actionFor(item, context)("start", "Start"), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DeleteOutcome, {
2993
- item,
2994
- context
2995
- })] })
2996
- }, item.workset.id))
2997
- }) : null,
2998
- shows("completed") ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Completed, {
2999
- items: completed,
3000
- context,
3001
- expanded: Boolean(query)
3002
- }) : null,
3003
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SidePanel, {
3004
- items: walk.map((item) => item.workset.id),
3005
- current: open?.workset.id ?? null,
3006
- onSelect: (id) => {
3007
- if (id === null) {
3008
- setPass(false);
3009
- address.close();
3010
- return;
3011
- }
3012
- useFactoryUi.getState().setStepped(true);
3013
- address.step(id);
3014
- },
3015
- pass: pass ? "Needs you" : void 0,
3016
- wide: true,
3017
- title: open ? open.workset.title : "Outcome",
3018
- children: open ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutcomePanel, {
3019
- item: open,
3020
- kind: kinds.get(open.workset.id) ?? null,
3021
- context,
3022
- onDeleted: address.close
3023
- }, open.workset.id) : null
3024
- }),
3025
- payload.worksetProblems.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Warnings, { warnings: payload.worksetProblems.map((problem) => `${problem.path} ${problem.reason}`) }) : null,
3026
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Warnings, { warnings: payload.warnings }),
3027
- factoryMode && writable && agentsOpen ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AgentsDialog, { onClose: () => setAgentsOpen(false) }) : null,
3028
- factoryMode && writable && gitAccessOpen ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GitAccessDialog, { onClose: () => setGitAccessOpen(false) }) : null
3029
- ]
3030
- })
3031
- });
3032
- }
3033
- // src/routes/factory.tsx?tsr-split=component
3034
- function FactoryRoute() {
3035
- const { companion, outcome } = Route.useSearch();
3036
- const navigate = useNavigate();
3037
- (0, import_react.useEffect)(() => {
3038
- const legacy = /^#outcome-([a-z0-9][a-z0-9-]*)$/.exec(window.location.hash)?.[1];
3039
- if (legacy && !outcome) navigate({
3040
- to: "/factory",
3041
- search: (previous) => ({
3042
- ...previous,
3043
- outcome: legacy
3044
- }),
3045
- hash: "",
3046
- replace: true
3047
- });
3048
- }, [navigate, outcome]);
3049
- if (!companion) return null;
3050
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FactoryBoard, {
3051
- companion,
3052
- outcome
3053
- });
3054
- }
3055
- function FactoryBoard({ companion, outcome }) {
3056
- const { data } = useSuspenseQuery(factoryQuery(companion));
3057
- if (!data.payload) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("section", {
3058
- className: "mx-8 max-sm:mx-4",
3059
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
3060
- className: "empty m-0 rounded-card border border-dashed border-rule px-6 py-7 text-muted",
3061
- children: data.error ?? "No state collected for this companion."
3062
- })
3063
- });
3064
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Factory, {
3065
- payload: data.payload,
3066
- companionDigest: companion,
3067
- writable: data.writable,
3068
- factoryMode: data.factoryMode,
3069
- sessions: data.sessions,
3070
- runs: data.runs,
3071
- now: data.renderedAt,
3072
- openId: outcome
3073
- });
3074
- }
3075
- export { FactoryRoute as component };