@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,21 +1,25 @@
1
- import { $ as partialMatchKey, C as createSsrRpc, E as call, F as TERMINAL_WASM, G as hashKey, K as hashQueryKeyByOptions, M as TERMINAL_SESSIONS_END_ROUTE, N as TERMINAL_SESSIONS_ROUTE, P as TERMINAL_SOCKET_ROUTE, Q as noop, W as functionalUpdate, X as matchMutation, Z as matchQuery, d as shellQuery, dt as createRootRouteWithContext, ft as Link, h as vaultQuery, it as skipToken, j as STUDIO_EVENTS_ROUTE, k as FACTORY_GIT_TOKENS_ROUTE, l as holdShellForMode, lt as lazyRouteComponent, o as companionViewQuery, pt as useNavigate, r as afterRefresh, s as factoryQuery, t as afterEvent, tt as resolveQueryValue, u as reportsQuery, ut as createFileRoute, y as getShell } from "./studio-queries-BtRGzDdh.js";
2
- import { $ as ToggleGroup, $n as getFrameElement, $t as triggerOpenStateMapping, A as useFloatingParentNodeId, An as inputClear, Ar as QueryObserver, At as getPaddingObject, B as FocusGuard, Bn as triggerPress, Bt as stopEvent, C as useAnimationsFinished, Ct as getAlignmentAxis, D as FloatingNode, Dn as focusOut, Dr as useQuery, Dt as getOppositeAxis, En as escapeKey, Et as getExpandedPlacements, F as CLICK_TRIGGER_IDENTIFIER, Fn as none, Fr as notifyManager, Ft as rectToClientRect, G as useValueAsRef, Gn as useButton, Gt as isTargetInsideEnabledTrigger, H as visuallyHiddenInput, Hn as createChangeEventDetails, Ht as getNodeChildren, I as DISABLED_TRANSITIONS_STYLE, Ir as focusManager, It as round, J as Timeout, Jn as useIsoLayoutEffect, Jt as matchesFocusVisible, K as mergeCleanups, Kn as ownerDocument, Ln as pointer, Lr as Subscribable, Lt as isMouseLikePointerType, M as FloatingPortal, Mn as itemPress, Mt as getSideAxis, N as useFloatingPortalNode, Nn as keyboard, Nt as max, O as FloatingTree, On as imperativeAction, Or as useBaseQuery, Ot as getOppositeAxisPlacements, Pr as onlineManager, Pt as min, Q as fastComponentRef, Qn as getDocumentElement, Qt as pressableTriggerOpenStateMapping, R as POPUP_COLLISION_AVOIDANCE, Rn as triggerFocus, Rr as QueryClientProvider, S as useOpenChangeComplete, Sn as CompositeList, Sr as useBaseUiId, St as getAlignment, T as useDismiss, Tn as disabled, Tr as cn, Tt as getAxisLength, Un as createGenericEventDetails, V as visuallyHidden, Wn as useCompositeListItem, Wt as isInteractiveElement, X as useOnMount, Xn as getComputedStyle$1, Xt as popupStateMapping, Y as useTimeout, Yn as useStableCallback, Yt as triggerDisabled, Z as fastComponent, Zn as getContainingBlock, Zt as popupTransitionStateMapping, _ as usePopupInteractionProps, _n as webkit, _r as EMPTY_OBJECT, a as ReactStore, ar as isContainingBlock, b as useTriggerDataForwarding, bn as mac, br as useMergedRefs, bt as evaluate, c as PopupTriggerMap, cr as isLastTraversableNode, ct as isOutsideEvent, d as applyPopupOpenChange, dn as activeElement, dr as isTableElement, dt as getGridNavigatedIndex, er as getNodeName, et as ToggleGroupItem, f as attachPreventUnmountOnClose, fn as closest, fr as isTopLayer, g as useOpenStateTransitions, gn as gecko, gr as EMPTY_ARRAY, gt as isIndexOutOfListBounds, h as useImplicitActiveTrigger, hr as mergeProps, ir as getWindow, j as useFloatingTree, jn as inputPress, jr as Query, jt as getSide, k as useFloatingNodeId, kn as inputChange, kr as defaultThrowOnError, kt as getOppositePlacement, l as FOCUSABLE_POPUP_PROPS, lr as isOverflowElement, m as createPopupOpenState, mn as getTarget, mr as useRenderElement, nr as getOverflowAncestors, nt as useDirection, on as transitionStatusMapping, or as isElement, p as createDefaultInitialFocus, pn as contains, pr as isWebKit, q as addEventListener, qn as formatErrorMessage, qt as isTypeableElement, r as Icon, rr as getParentNode, rt as COMPOSITE_KEYS, s as require_shim, sr as isHTMLElement, st as getTabbableNearElement, t as Button, tr as getNodeScroll, tt as useToolbarRootContext, u as PopupHandleAttachment, v as usePopupRootStore, vn as android, vr as NOOP, vt as clamp, wn as closePress, wr as useControlled, wt as getAlignmentSides, x as useUnmountAfterClose, xr as useRefWithInit, xt as floor, y as usePopupRootSync, yn as ios, yt as createCoords, z as createAttribute, zn as triggerHover, zr as useQueryClient } from "./button-CgOIVdmD.js";
3
- import { n as Mutation, t as useMutation } from "./useMutation-DzTZGenE.js";
4
1
  import { a as useRouter, c as _getAssetMatches, m as createNonReactiveReadonlyStore, p as createNonReactiveMutableStore, u as RouterCore } from "./useSelector-DUmCUXAs.js";
5
2
  import { i as __exportAll, n as require_react, o as __toESM, t as require_jsx_runtime } from "./jsx-runtime-Bt0s0YKS.js";
3
+ import { a as QueryObserver, d as focusManager, f as Subscribable, i as defaultThrowOnError, l as onlineManager, m as useQueryClient, o as Query, p as QueryClientProvider, r as useBaseQuery, t as cn, u as notifyManager } from "./cn-D7uJiH_O.js";
4
+ import { D as TERMINAL_SOCKET_ROUTE, E as TERMINAL_SESSIONS_ROUTE, F as functionalUpdate, H as matchQuery, I as hashKey, K as replaceEqualDeep, L as hashQueryKeyByOptions, O as TERMINAL_WASM, T as TERMINAL_SESSIONS_END_ROUTE, U as noop, V as matchMutation, W as partialMatchKey, X as skipToken, a as companionViewQuery, at as useNavigate, b as studioFetch, c as pluginAttentionQuery, it as Link, k as queryOptions, l as reportsQuery, m as vaultQuery, n as afterRefresh, nt as createFileRoute, ot as useParams, q as resolveQueryValue, rt as createRootRouteWithContext, s as holdShellForMode, t as afterEvent, tt as lazyRouteComponent, u as shellQuery, v as getShell, w as STUDIO_EVENTS_ROUTE, x as probeStudio, y as createSsrRpc } from "./studio-queries-DC273ifg.js";
6
5
  import { r as redirect } from "./redirect-BaZ_QyqF.js";
7
6
  import { a as useMatches, c as appendUniqueUserTags, d as resolveManifestCssLink, i as require_react_dom, l as getAssetCrossOrigin, n as createServerFn, o as Outlet, s as useHydrated, u as getScriptPreloadAttrs } from "../server.js";
8
7
  import { s as escapeHtml } from "./utils-C9CX1kcy.js";
9
- import { g as STUDIO_MODES, h as SHARED_VIEWS, m as MODE_VIEWS, n as LIGHT_PALETTE, r as WORKSET_STAGE_ORDER, t as DARK_PALETTE, u as COMPANION_DIGEST_PATTERN, x as viewsFor } from "./studio-CAcKp3bM.js";
8
+ import { A as SHARED_VIEWS, I as viewsFor, T as COMPANION_DIGEST_PATTERN, a as LIGHT_PALETTE, g as defaultWorkflow, i as DARK_PALETTE, j as STUDIO_MODES, k as MODE_VIEWS, o as stagesBeforeWork, s as stepStage, y as MARK_STATES } from "./studio-D-ZPWSMv.js";
9
+ import { a as VAULT_TREE_STORAGE_KEY, i as THEME_STORAGE_KEY, n as RAIL_STORAGE_KEY, r as STUDIO_PREPAINT_SCRIPT, t as COMPANION_STORAGE_KEY } from "./prepaint-BxZ-pU7t.js";
10
+ import { n as loadView, r as registeredCompanion, t as loadHeld } from "./queries-W4LXzTnT.js";
10
11
  import { t as formatCollectedAt } from "./model-PyPALjii.js";
11
- import { a as THEME_STORAGE_KEY, i as STUDIO_PREPAINT_SCRIPT, n as COMPANION_STORAGE_KEY, o as VAULT_TREE_STORAGE_KEY, r as RAIL_STORAGE_KEY, t as create } from "./react-CdqSUhaL.js";
12
- import { n as loadView, r as registeredCompanion, t as loadHeld } from "./queries-DWoTin-q.js";
13
- import { n as validateSpecsSearch, r as validateStudioSearch, t as canonicalHref } from "./search-BJnWLfkG.js";
14
- import { a as Count, l as PageHeader, n as popupStoreSelectors, t as createInitialPopupStoreState } from "./store-Cs17okNG.js";
15
- import { _ as inertValue, a as InternalBackdrop, c as useLabelableId, d as useRegisterFieldControl, f as DEFAULT_FIELD_ROOT_CONTEXT, g as fieldValidityMapping, h as DEFAULT_FIELD_STATE_ATTRIBUTES, i as useScrollLock, l as useLabelableContext, m as useFieldRootContext, n as Kbd, o as useSetFieldFocused, p as FieldRootContext, r as Separator, s as useValueChanged, t as Input, u as useFormContext, v as FloatingFocusManager } from "./fields-BbieQTD0.js";
16
- import "./__23tanstack-start-server-fn-resolver-Bn896ZYj.js";
17
- import { t as getGuide } from "./guides-IE-19POz.js";
18
- import { S as useClick, _ as resolveSelectedIndex, a as hasNullItemLabel, b as useListNavigation, d as compareItemEquality, f as defaultItemEquality, g as removeItem, h as isSelectedValueDirty, i as flattenLeafItems, l as stringifyAsLabel, m as findSelectionIndex, n as useOpenInteractionType, o as isGroupedItems, p as findItemIndex, r as useOpenMethodTriggerProps, t as useAnchoredPopupScrollLock, u as stringifyAsValue, v as selectedValueIncludes, x as useFloatingRootContext, y as useOnFirstRender } from "./useAnchoredPopupScrollLock-DlBKHRw7.js";
12
+ import { a as validateSpecsSearch, c as frictionViewDays, i as stringifyStudioSearch, n as oneOf, o as validateStudioSearch, r as parseStudioSearch, s as FRICTION_VIEW_DAYS, t as canonicalHref } from "./search-BjG5f16n.js";
13
+ import { t as create } from "./react-CiBZPDs8.js";
14
+ import { A as useFloatingParentNodeId, An as android, Ar as NOOP, At as clamp, B as FocusGuard, Bn as imperativeAction, Bt as getOppositeAxisPlacements, C as useAnimationsFinished, Cn as activeElement, Cr as isTableElement, Ct as getGridNavigatedIndex, D as FloatingNode, Dr as mergeProps, En as getTarget, Er as useRenderElement, F as CLICK_TRIGGER_IDENTIFIER, Ft as getAlignmentAxis, G as useValueAsRef, Gn as keyboard, Gt as max, H as visuallyHiddenInput, Hn as inputClear, Ht as getPaddingObject, I as DISABLED_TRANSITIONS_STYLE, In as closePress, Ir as useControlled, It as getAlignmentSides, J as Timeout, Jt as round, K as mergeCleanups, Kt as min, Ln as disabled, Lr as useQuery, Lt as getAxisLength, M as FloatingPortal, Mn as mac, Mr as useMergedRefs, Mt as evaluate, N as useFloatingPortalNode, Nr as useRefWithInit, Nt as floor, O as FloatingTree, On as gecko, Or as EMPTY_ARRAY, Ot as isIndexOutOfListBounds, Pn as CompositeList, Pr as useBaseUiId, Pt as getAlignment, Q as fastComponentRef, Qn as triggerPress, Qt as stopEvent, R as POPUP_COLLISION_AVOIDANCE, Rn as escapeKey, Rt as getExpandedPlacements, S as useOpenChangeComplete, T as useDismiss, Tn as contains, Tr as isWebKit, Un as inputPress, Ut as getSide, V as visuallyHidden, Vn as inputChange, Vt as getOppositePlacement, Wn as itemPress, Wt as getSideAxis, X as useOnMount, Xn as triggerFocus, Y as useTimeout, Yn as pointer, Yt as isMouseLikePointerType, Z as fastComponent, Zn as triggerHover, _ as usePopupInteractionProps, _r as isContainingBlock, a as ReactStore, an as isTypeableElement, ar as formatErrorMessage, at as PageHeader, b as useTriggerDataForwarding, br as isLastTraversableNode, bt as isOutsideEvent, c as PopupTriggerMap, cn as popupStateMapping, cr as getComputedStyle$1, d as applyPopupOpenChange, dn as triggerOpenStateMapping, dr as getFrameElement, dt as ToggleGroup, en as getNodeChildren, er as createChangeEventDetails, f as attachPreventUnmountOnClose, fr as getNodeName, ft as ToggleGroupItem, g as useOpenStateTransitions, gr as getWindow, h as useImplicitActiveTrigger, hr as getParentNode, ht as COMPOSITE_KEYS, ir as ownerDocument, j as useFloatingTree, jn as ios, jt as createCoords, k as useFloatingNodeId, kn as webkit, kr as EMPTY_OBJECT, l as FOCUSABLE_POPUP_PROPS, ln as popupTransitionStateMapping, lr as getContainingBlock, lt as StatusWord, m as createPopupOpenState, mr as getOverflowAncestors, mt as useDirection, nn as isInteractiveElement, nr as useCompositeListItem, on as matchesFocusVisible, or as useIsoLayoutEffect, p as createDefaultInitialFocus, pr as getNodeScroll, pt as useToolbarRootContext, q as addEventListener, qn as none, qt as rectToClientRect, r as Icon, rn as isTargetInsideEnabledTrigger, rr as useButton, rt as ListCard, sn as triggerDisabled, sr as useStableCallback, t as Button, tr as createGenericEventDetails, tt as Count, u as PopupHandleAttachment, un as pressableTriggerOpenStateMapping, ur as getDocumentElement, v as usePopupRootStore, vr as isElement, wn as closest, wr as isTopLayer, x as useUnmountAfterClose, xr as isOverflowElement, y as usePopupRootSync, yr as isHTMLElement, yt as getTabbableNearElement, z as createAttribute, zn as focusOut, zt as getOppositeAxis } from "./button-C7EMLaX6.js";
15
+ import { _ as fieldValidityMapping, c as useValueChanged, d as useFormContext, f as useRegisterFieldControl, g as DEFAULT_FIELD_STATE_ATTRIBUTES, h as useFieldRootContext, l as useLabelableId, m as FieldRootContext, n as Kbd, o as InternalBackdrop, p as DEFAULT_FIELD_ROOT_CONTEXT, r as Separator, s as useSetFieldFocused, t as Input, u as useLabelableContext, v as inertValue, y as FloatingFocusManager } from "./fields-BxBN6-Dz.js";
16
+ import { n as Mutation, t as useMutation } from "./useMutation-0HbcKUsQ.js";
17
+ import "./__23tanstack-start-server-fn-resolver-QQnIXyKi.js";
18
+ import { t as getGuide } from "./guides-BZWFpJl-.js";
19
+ import { n as popupStoreSelectors, t as createInitialPopupStoreState } from "./store-CWlRjv9s.js";
20
+ import { t as usePopupHandleStore } from "./usePopupHandleStore-B3SNGTic.js";
21
+ import { S as useClick, _ as resolveSelectedIndex, a as hasNullItemLabel, b as useListNavigation, d as compareItemEquality, f as defaultItemEquality, g as removeItem, h as isSelectedValueDirty, i as flattenLeafItems, l as stringifyAsLabel, m as findSelectionIndex, n as useOpenInteractionType, o as isGroupedItems, p as findItemIndex, r as useOpenMethodTriggerProps, t as useAnchoredPopupScrollLock, u as stringifyAsValue, v as selectedValueIncludes, x as useFloatingRootContext, y as useOnFirstRender } from "./useAnchoredPopupScrollLock-BchJDJYg.js";
22
+ import { a as DialogClose$1, i as DialogPopup, n as DialogRoot, o as DialogBackdrop, r as DialogPortal, s as useDialogRootContext, t as DialogTitle$1 } from "./DialogTitle-KSVhF_7V.js";
19
23
  // ../../node_modules/.bun/@tanstack+router-core@1.171.39/node_modules/@tanstack/router-core/dist/esm/ssr/bodyScripts.js
20
24
  function getSsrBodyScriptParts(matches, manifest, nonce, routeScriptAttrs) {
21
25
  const assetMatches = _getAssetMatches(matches);
@@ -1856,6 +1860,131 @@ function useSuspenseQuery(options, queryClient) {
1856
1860
  placeholderData: void 0
1857
1861
  }, QueryObserver, queryClient);
1858
1862
  }
1863
+ // ../../node_modules/.bun/@tanstack+react-query@5.105.3+cef22a3c7e8b4cef/node_modules/@tanstack/react-query/build/modern/useMutationState.js
1864
+ /**
1865
+ * The `useIsMutating` hook returns the `number` of mutations that your application currently has `pending`
1866
+ * (useful for app-wide loading indicators).
1867
+ * @param filters - The {@link MutationFilters} to narrow down the matched mutations.
1868
+ * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
1869
+ * be used.
1870
+ * @returns Will be the `number` of the mutations that your application currently has `pending`.
1871
+ * @example
1872
+ * ```tsx
1873
+ * import { useIsMutating } from '@tanstack/react-query'
1874
+ *
1875
+ * function PostsMutatingIndicator() {
1876
+ * // How many mutations matching the posts prefix are in progress?
1877
+ * const isMutatingPosts = useIsMutating({ mutationKey: ['posts'] })
1878
+ *
1879
+ * return isMutatingPosts ? <span>Saving posts...</span> : null
1880
+ * }
1881
+ * ```
1882
+ */
1883
+ function useIsMutating(filters, queryClient) {
1884
+ const client = useQueryClient(queryClient);
1885
+ return useMutationState({ filters: {
1886
+ ...filters,
1887
+ status: "pending"
1888
+ } }, client).length;
1889
+ }
1890
+ /**
1891
+ * Creates snapshot getters that share equal selected results across renders.
1892
+ * A new getter is created on each render. Each getter caches its snapshot until the matching mutations
1893
+ * or their states change.
1894
+ * @returns A factory for snapshot getters with a shared result cache.
1895
+ */
1896
+ function createSnapshotFactory() {
1897
+ let previousResult;
1898
+ return (mutationCache, options) => {
1899
+ let inputs = [];
1900
+ let snapshot;
1901
+ return () => {
1902
+ const mutations = mutationCache.findAll(options.filters);
1903
+ const nextInputs = mutations.flatMap((mutation) => [mutation, mutation.state]);
1904
+ if (!snapshot || nextInputs.length !== inputs.length || nextInputs.some((input, index) => !Object.is(input, inputs[index]))) {
1905
+ inputs = nextInputs;
1906
+ snapshot = replaceEqualDeep(previousResult, mutations.map((mutation) => options.select ? options.select(mutation) : mutation.state));
1907
+ previousResult = snapshot;
1908
+ }
1909
+ return snapshot;
1910
+ };
1911
+ };
1912
+ }
1913
+ /**
1914
+ * `useMutationState` is a hook that gives you access to all mutations in the `MutationCache`. You can pass
1915
+ * `filters` ({@link MutationFilters}) to narrow down your mutations, and `select` to transform the mutation
1916
+ * state.
1917
+ * @param options - The `filters` to narrow down matched mutations, and an optional `select` to transform the
1918
+ * mutation state.
1919
+ * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
1920
+ * be used.
1921
+ * @returns Will be an Array of whatever `select` returns for each matching mutation.
1922
+ * @example
1923
+ * Get all variables of all running mutations:
1924
+ * ```tsx
1925
+ * import { useMutationState } from '@tanstack/react-query'
1926
+ *
1927
+ * function PendingPosts() {
1928
+ * const pendingVariables = useMutationState({
1929
+ * filters: { status: 'pending' },
1930
+ * select: (mutation) => mutation.state.variables,
1931
+ * })
1932
+ *
1933
+ * return <>{pendingVariables.length} posts saving...</>
1934
+ * }
1935
+ * ```
1936
+ * @example
1937
+ * Get all data for specific mutations via the `mutationKey`:
1938
+ * ```tsx
1939
+ * import { useMutation, useMutationState } from '@tanstack/react-query'
1940
+ *
1941
+ * const mutationKey = ['posts']
1942
+ *
1943
+ * function Posts() {
1944
+ * // Some mutation that we want to get the state for
1945
+ * const mutation = useMutation({
1946
+ * mutationKey,
1947
+ * mutationFn: createPosts,
1948
+ * })
1949
+ *
1950
+ * const savedPosts = useMutationState({
1951
+ * // this mutation key needs to match the mutation key of the given mutation (see above)
1952
+ * filters: { mutationKey, status: 'success' },
1953
+ * select: (mutation) => mutation.state.data,
1954
+ * })
1955
+ *
1956
+ * return (
1957
+ * <button onClick={() => mutation.mutate(['New Post'])}>
1958
+ * Create post ({savedPosts.length} saved so far)
1959
+ * </button>
1960
+ * )
1961
+ * }
1962
+ * ```
1963
+ * @example
1964
+ * Access the latest successful mutation data via the `mutationKey`. Each invocation of `mutate` adds a new
1965
+ * entry to the mutation cache for `gcTime` milliseconds — with the `status: 'success'` filter below, check the
1966
+ * last item that `useMutationState` returns to get the latest successful invocation:
1967
+ * ```tsx
1968
+ * import { useMutationState } from '@tanstack/react-query'
1969
+ *
1970
+ * function LatestPost() {
1971
+ * const savedPosts = useMutationState({
1972
+ * filters: { mutationKey: ['posts'], status: 'success' },
1973
+ * select: (mutation) => mutation.state.data,
1974
+ * })
1975
+ *
1976
+ * const latestSavedPost = savedPosts[savedPosts.length - 1]
1977
+ *
1978
+ * return <>{latestSavedPost ? 'Saved' : 'Nothing saved yet'}</>
1979
+ * }
1980
+ * ```
1981
+ */
1982
+ function useMutationState(options = {}, queryClient) {
1983
+ const mutationCache = useQueryClient(queryClient).getMutationCache();
1984
+ const [createSnapshot] = import_react.useState(() => createSnapshotFactory());
1985
+ const getSnapshot = createSnapshot(mutationCache, options);
1986
+ return import_react.useSyncExternalStore(import_react.useCallback((onStoreChange) => mutationCache.subscribe(notifyManager.batchCalls(onStoreChange)), [mutationCache]), getSnapshot, getSnapshot);
1987
+ }
1859
1988
  // ../../node_modules/.bun/@tanstack+router-ssr-query-core@1.169.3+3554ab4a3d907bbf/node_modules/@tanstack/router-ssr-query-core/dist/esm/index.js
1860
1989
  var shouldDehydrateAllQueries = () => true;
1861
1990
  function setupCoreRouterSsrQueryIntegration({ router, queryClient, dehydrateOptions, hydrateOptions, handleRedirects = true }) {
@@ -1977,24 +2106,6 @@ var BRAND_SVGS = {
1977
2106
  symbolOnDark: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 256 256\" width=\"256\" height=\"256\" role=\"img\" aria-labelledby=\"title\"><title id=\"title\">mate logo</title><g id=\"symbol\"><path fill=\"#F4F0E8\" d=\"M36 16H144V240H36A20 20 0 0 1 16 220V36A20 20 0 0 1 36 16Z\"/><path fill=\"#7FD0A6\" d=\"M160 16H220A20 20 0 0 1 240 36V80H160Z M160 96H240V160H160Z M160 176H240V220A20 20 0 0 1 220 240H160Z\"/></g></svg>",
1978
2107
  favicon: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 256 256\" width=\"256\" height=\"256\" role=\"img\" aria-labelledby=\"title\"><title id=\"title\">mate logo</title><rect width=\"256\" height=\"256\" rx=\"48\" fill=\"#1F2421\"/><g id=\"symbol\" transform=\"translate(32 32) scale(0.75)\"><path fill=\"#F4F0E8\" d=\"M36 16H144V240H36A20 20 0 0 1 16 220V36A20 20 0 0 1 36 16Z\"/><path fill=\"#7FD0A6\" d=\"M160 16H220A20 20 0 0 1 240 36V80H160Z M160 96H240V160H160Z M160 176H240V220A20 20 0 0 1 220 240H160Z\"/></g></svg>"
1979
2108
  };
1980
- // ../mate-core/src/lib/factory/runner/rank.ts
1981
- /**
1982
- * The factory work queue's one ordering rule: started Outcomes run in the order they were
1983
- * started. A Later Outcome has no rank.
1984
- */
1985
- function rankOf(record) {
1986
- if (!record.queuedAt) return null;
1987
- const queued = Date.parse(record.queuedAt);
1988
- return Number.isNaN(queued) ? null : queued;
1989
- }
1990
- /** Lower rank first, then identifier; Later Outcomes keep their relative order at the end. */
1991
- function compareRanked(a, b) {
1992
- if (a.rank === null || b.rank === null) {
1993
- if (a.rank === b.rank) return 0;
1994
- return a.rank === null ? 1 : -1;
1995
- }
1996
- return a.rank - b.rank || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0);
1997
- }
1998
2109
  // src/styles/palette.ts
1999
2110
  /** Each of these also gets a `--<name>-soft` tint: this share of the colour over the card surface. */
2000
2111
  var TINTED_TOKENS = [
@@ -2074,27 +2185,29 @@ ${declarations(STUDIO_LIGHT_PALETTE, " ")}
2074
2185
  /** The path each view is served at. */
2075
2186
  var VIEW_PATHS = {
2076
2187
  dashboard: "/",
2077
- factory: "/factory",
2078
2188
  workflow: "/workflow",
2079
2189
  "getting-started": "/getting-started",
2080
2190
  skills: "/skills",
2191
+ mcp: "/mcp",
2081
2192
  vault: "/vault",
2082
2193
  specs: "/specs",
2083
2194
  reports: "/reports",
2084
2195
  usage: "/usage",
2196
+ friction: "/friction",
2085
2197
  graph: "/graph"
2086
2198
  };
2087
2199
  /** A view's page title is its navigation label. */
2088
2200
  var VIEW_TITLES = {
2089
2201
  dashboard: "Overview",
2090
- factory: "Factory",
2091
2202
  workflow: "Workflow",
2092
2203
  "getting-started": "Getting Started",
2093
2204
  skills: "Skills",
2205
+ mcp: "MCP",
2094
2206
  vault: "Vault",
2095
2207
  specs: "Specs",
2096
2208
  reports: "Reports",
2097
2209
  usage: "Usage",
2210
+ friction: "Friction",
2098
2211
  graph: "Graph"
2099
2212
  };
2100
2213
  var MODE_TITLES = {
@@ -2110,31 +2223,33 @@ function viewAt(pathname) {
2110
2223
  var VIEW_DESCRIPTIONS = {
2111
2224
  engineering: {
2112
2225
  dashboard: "Changes in flight, grouped by what they need next.",
2113
- factory: "Outcomes the factory works on, and the decisions they wait for.",
2114
2226
  workflow: "The Delivery Path: every stage, its skill and where your changes are.",
2115
2227
  "getting-started": "Take your first change from an idea to delivery in your existing checkout.",
2116
2228
  skills: "The skills each agent can run in this companion.",
2229
+ mcp: "The MCP servers this companion gives its agents, per audience.",
2117
2230
  vault: "Every file in the Companion Repository.",
2118
2231
  specs: "Capabilities by Area, with their requirements.",
2119
2232
  reports: "Reports agents published for this companion.",
2120
2233
  usage: "Token usage across this companion and every linked Working Repository.",
2234
+ friction: "Where Mate got in your agents' way, recorded on this machine.",
2121
2235
  graph: "Capabilities, Areas and repositories, and how they connect."
2122
2236
  },
2123
2237
  analysis: {
2124
2238
  dashboard: "What shipped lately, and the specs it changed.",
2125
- factory: "Outcomes the factory works on.",
2126
2239
  workflow: "The Delivery Path.",
2127
2240
  "getting-started": "Developer setup and isolated work.",
2128
2241
  skills: "Skills in this companion.",
2242
+ mcp: "MCP servers in this companion.",
2129
2243
  vault: "Every file in the Companion Repository.",
2130
2244
  specs: "Capabilities by Area, with their requirements.",
2131
2245
  reports: "Reports agents published for this companion.",
2132
2246
  usage: "Token usage across this companion and every linked Working Repository.",
2247
+ friction: "Where Mate got in the agents' way, recorded on this machine.",
2133
2248
  graph: "Capabilities, Areas and repositories, and how they connect."
2134
2249
  }
2135
2250
  };
2136
2251
  // src/styles/app.css?url
2137
- var app_default = "/assets/app-D9cw6szy.css";
2252
+ var app_default = "/assets/app-0NoFqMou.css";
2138
2253
  // src/terminal/keys.ts
2139
2254
  /** Browser storage keys and sizes of the agent terminal, shared by the page and its scripts. */
2140
2255
  var TERMINAL_TAB_KEY = "mate-studio-terminal-tab";
@@ -2143,6 +2258,10 @@ var TERMINAL_WIDTH_KEY = "mate-studio-terminal-width";
2143
2258
  var TERMINAL_COLLAPSED_KEY = "mate-studio-terminal-collapsed";
2144
2259
  var TERMINAL_MAX_WIDTH_RATIO = .7;
2145
2260
  // src/stores/terminal-ui.ts
2261
+ /** The workspace view holding the sidebar collapsed, if any. */
2262
+ function heldBy(workspace, released) {
2263
+ return workspace && !released.includes(workspace) ? workspace : null;
2264
+ }
2146
2265
  function clampWidth(px) {
2147
2266
  return Math.round(Math.max(360, Math.min(px, window.innerWidth * TERMINAL_MAX_WIDTH_RATIO)));
2148
2267
  }
@@ -2160,6 +2279,8 @@ var useTerminalUi = create((set, get) => ({
2160
2279
  drawerOpen: false,
2161
2280
  viewing: null,
2162
2281
  controller: null,
2282
+ workspace: null,
2283
+ released: [],
2163
2284
  setCollapsed: (collapsed) => {
2164
2285
  document.documentElement.toggleAttribute("data-terminal-collapsed", collapsed);
2165
2286
  save$1(TERMINAL_COLLAPSED_KEY, String(collapsed));
@@ -2177,7 +2298,14 @@ var useTerminalUi = create((set, get) => ({
2177
2298
  set({ viewing });
2178
2299
  },
2179
2300
  register: (controller) => set({ controller }),
2301
+ setWorkspace: (workspace) => set({ workspace }),
2302
+ release: (view) => {
2303
+ if (get().collapsed) get().setCollapsed(false);
2304
+ if (!get().released.includes(view)) set({ released: [...get().released, view] });
2305
+ },
2180
2306
  reveal: () => {
2307
+ const held = heldBy(get().workspace, get().released);
2308
+ if (held) get().release(held);
2181
2309
  if (get().collapsed) get().setCollapsed(false);
2182
2310
  if (window.matchMedia?.("(max-width: 1200px)").matches) set({ drawerOpen: true });
2183
2311
  }
@@ -2530,28 +2658,6 @@ function useClientPoint(store, props = {}) {
2530
2658
  trigger: reference
2531
2659
  } : {}, [enabled, reference]);
2532
2660
  }
2533
- // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/utils/popups/usePopupHandleStore.mjs
2534
- var import_shim = require_shim();
2535
- /**
2536
- * Reads the store currently exposed by a popup handle and subscribes to store-pointer changes.
2537
- * Detached triggers use this to follow a handle as a root attaches or detaches: while no root is
2538
- * attached, the handle exposes its fallback store; once a root attaches, subscribers re-render and
2539
- * read from the live root store.
2540
- *
2541
- * Returns `undefined` when no handle is provided so callers can fall back to their root context.
2542
- *
2543
- * @param handle The popup handle to read from, or `undefined` when the trigger is not handle-bound.
2544
- */
2545
- function usePopupHandleStore(handle) {
2546
- const subscribe = import_react.useCallback((listener) => {
2547
- if (handle === void 0) return NOOP;
2548
- return handle.subscribeStore(listener);
2549
- }, [handle]);
2550
- const getSnapshot = import_react.useCallback(() => {
2551
- return handle === void 0 ? void 0 : handle.store;
2552
- }, [handle]);
2553
- return (0, import_shim.useSyncExternalStore)(subscribe, getSnapshot, () => handle?.serverStore);
2554
- }
2555
2661
  // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/floating-ui-react/hooks/useFocus.mjs
2556
2662
  var isMacSafari = mac && webkit;
2557
2663
  /**
@@ -4500,7 +4606,7 @@ var size = (options, deps) => {
4500
4606
  };
4501
4607
  };
4502
4608
  // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/tooltip/store/TooltipStore.mjs
4503
- var selectors$3 = {
4609
+ var selectors$2 = {
4504
4610
  ...popupStoreSelectors,
4505
4611
  disabled: (state) => state.disabled,
4506
4612
  instantType: (state) => state.instantType,
@@ -4524,7 +4630,7 @@ var selectors$3 = {
4524
4630
  var TooltipStore = class extends ReactStore {
4525
4631
  constructor(initialState, floatingId, nested) {
4526
4632
  const triggerElements = new PopupTriggerMap();
4527
- super(createInitialState$2(initialState, triggerElements, floatingId, nested), createInitialContext$2(triggerElements), selectors$3);
4633
+ super(createInitialState$1(initialState, triggerElements, floatingId, nested), createInitialContext$1(triggerElements), selectors$2);
4528
4634
  }
4529
4635
  setOpen = (nextOpen, eventDetails) => {
4530
4636
  applyPopupOpenChange(this, nextOpen, eventDetails, { extraState: { openChangeReason: eventDetails.reason } });
@@ -4533,7 +4639,7 @@ var TooltipStore = class extends ReactStore {
4533
4639
  this.state.floatingRootContext.dispatchOpenChange(false, createChangeEventDetails(triggerPress, event));
4534
4640
  }
4535
4641
  };
4536
- function createInitialState$2(initialState, triggerElements, floatingId, nested = false) {
4642
+ function createInitialState$1(initialState, triggerElements, floatingId, nested = false) {
4537
4643
  return {
4538
4644
  ...createInitialPopupStoreState(triggerElements, floatingId, nested),
4539
4645
  disabled: false,
@@ -4548,7 +4654,7 @@ function createInitialState$2(initialState, triggerElements, floatingId, nested
4548
4654
  ...initialState
4549
4655
  };
4550
4656
  }
4551
- function createInitialContext$2(triggerElements) {
4657
+ function createInitialContext$1(triggerElements) {
4552
4658
  return {
4553
4659
  popupRef: /*#__PURE__*/ import_react.createRef(),
4554
4660
  onOpenChange: void 0,
@@ -5570,6 +5676,99 @@ function Tooltip({ label, children, side = "right", disabled = false, className
5570
5676
  }) })]
5571
5677
  });
5572
5678
  }
5679
+ // src/stores/connection.ts
5680
+ /** The page's connection state, for Studio's own components. */
5681
+ var useConnectionState = create(() => ({ state: "online" }));
5682
+ var FIRST_RETRY_MS = 1e3;
5683
+ var MAX_RETRY_MS = 3e4;
5684
+ var browserTimers = {
5685
+ set: (run, ms) => setTimeout(run, ms),
5686
+ clear: (handle) => clearTimeout(handle)
5687
+ };
5688
+ /**
5689
+ * Tracks the page's connection: a suspected failure starts a probe and only the probe's result
5690
+ * changes the state. While not online it probes again with backoff; on recovery it refetches
5691
+ * every query before telling subscribers.
5692
+ */
5693
+ function createConnectionMonitor({ queryClient, probe = () => probeStudio(), target = window, isVisible = () => document.visibilityState === "visible", timers = browserTimers }) {
5694
+ const listeners = /* @__PURE__ */ new Set();
5695
+ let probing = false;
5696
+ let retry = null;
5697
+ let delay = FIRST_RETRY_MS;
5698
+ let disposed = false;
5699
+ const settle = (next) => {
5700
+ if (disposed) return;
5701
+ const changed = next !== useConnectionState.getState().state;
5702
+ if (next === "online") delay = FIRST_RETRY_MS;
5703
+ else {
5704
+ retry = timers.set(() => {
5705
+ retry = null;
5706
+ run();
5707
+ }, delay);
5708
+ delay = Math.min(delay * 2, MAX_RETRY_MS);
5709
+ }
5710
+ if (!changed) return;
5711
+ useConnectionState.setState({ state: next });
5712
+ if (next === "online") queryClient.invalidateQueries();
5713
+ for (const listener of listeners) try {
5714
+ listener(next);
5715
+ } catch (error) {
5716
+ console.error(error);
5717
+ }
5718
+ };
5719
+ const run = async () => {
5720
+ if (probing || disposed) return;
5721
+ if (retry !== null) {
5722
+ timers.clear(retry);
5723
+ retry = null;
5724
+ }
5725
+ probing = true;
5726
+ let next;
5727
+ try {
5728
+ next = await probe();
5729
+ } catch {
5730
+ next = "offline";
5731
+ } finally {
5732
+ probing = false;
5733
+ }
5734
+ settle(next);
5735
+ };
5736
+ const now = () => void run();
5737
+ const onVisible = () => {
5738
+ if (isVisible()) now();
5739
+ };
5740
+ target.addEventListener("online", now);
5741
+ target.addEventListener("visibilitychange", onVisible);
5742
+ return {
5743
+ state: () => useConnectionState.getState().state,
5744
+ suspect() {
5745
+ if (retry !== null) return;
5746
+ now();
5747
+ },
5748
+ subscribe(listener) {
5749
+ listeners.add(listener);
5750
+ return () => void listeners.delete(listener);
5751
+ },
5752
+ dispose() {
5753
+ disposed = true;
5754
+ if (retry !== null) timers.clear(retry);
5755
+ target.removeEventListener("online", now);
5756
+ target.removeEventListener("visibilitychange", onVisible);
5757
+ listeners.clear();
5758
+ }
5759
+ };
5760
+ }
5761
+ var current = null;
5762
+ /** Starts the page's one monitor; browser only, so SSR never touches `window`. */
5763
+ function startConnectionMonitor(options) {
5764
+ current?.dispose();
5765
+ current = createConnectionMonitor(options);
5766
+ return current;
5767
+ }
5768
+ /** The page's monitor; `null` during SSR and before the router started it. */
5769
+ function studioConnection() {
5770
+ return current;
5771
+ }
5573
5772
  // src/stores/page-ui.ts
5574
5773
  var toastTimer;
5575
5774
  var reportTimer;
@@ -5628,8 +5827,10 @@ function useStudioEvents(digest) {
5628
5827
  const queryClient = useQueryClient();
5629
5828
  (0, import_react.useEffect)(() => {
5630
5829
  if (!digest || typeof EventSource === "undefined") return;
5631
- const source = new EventSource(`${STUDIO_EVENTS_ROUTE}?companion=${encodeURIComponent(digest)}`);
5632
- source.addEventListener("message", (message) => {
5830
+ const connection = studioConnection();
5831
+ let source;
5832
+ let waiting = null;
5833
+ const onMessage = (message) => {
5633
5834
  let event;
5634
5835
  try {
5635
5836
  event = JSON.parse(message.data);
@@ -5642,8 +5843,27 @@ function useStudioEvents(digest) {
5642
5843
  title: event.title
5643
5844
  });
5644
5845
  afterEvent(queryClient, digest, event.type);
5645
- });
5646
- return () => source.close();
5846
+ };
5847
+ const onError = () => {
5848
+ connection?.suspect();
5849
+ if (source.readyState !== EventSource.CLOSED || !connection || waiting) return;
5850
+ waiting = connection.subscribe((state) => {
5851
+ if (state !== "online") return;
5852
+ waiting?.();
5853
+ waiting = null;
5854
+ open();
5855
+ });
5856
+ };
5857
+ const open = () => {
5858
+ source = new EventSource(`${STUDIO_EVENTS_ROUTE}?companion=${encodeURIComponent(digest)}`);
5859
+ source.addEventListener("message", onMessage);
5860
+ source.addEventListener("error", onError);
5861
+ };
5862
+ open();
5863
+ return () => {
5864
+ waiting?.();
5865
+ source.close();
5866
+ };
5647
5867
  }, [digest, queryClient]);
5648
5868
  }
5649
5869
  // src/lib/page-actions.ts
@@ -5694,7 +5914,7 @@ function useStudioClicks() {
5694
5914
  }, []);
5695
5915
  }
5696
5916
  // src/lib/prefetch-views.ts
5697
- /** Views read from the held snapshot; Factory, Vault and Reports load their own way. */
5917
+ /** Views read from the held snapshot; Vault and Reports load their own way. */
5698
5918
  var AHEAD = [
5699
5919
  "dashboard",
5700
5920
  "workflow",
@@ -5740,8 +5960,7 @@ var whenIdle = (run) => {
5740
5960
  /**
5741
5961
  * While the page is idle, one item at a time: the code of every view the mode offers, the
5742
5962
  * mode's companion views, the Vault's root listing and the Reports list, then each other
5743
- * enabled mode's Overview, so no first visit waits. Factory data is never loaded ahead: it
5744
- * refreshes on its own events.
5963
+ * enabled mode's Overview, so no first visit waits.
5745
5964
  */
5746
5965
  function usePrefetchViews(search, studioMode, enabledModes = []) {
5747
5966
  const queryClient = useQueryClient();
@@ -5910,7 +6129,7 @@ function useComboboxHasItemsContext() {
5910
6129
  * Non-reactive values shared with the combobox parts. Nothing here is observable through
5911
6130
  * `selectors`, so writing to a ref never notifies subscribers.
5912
6131
  */
5913
- var selectors$2 = {
6132
+ var selectors$1 = {
5914
6133
  id: (state) => state.id,
5915
6134
  labelId: (state) => state.labelId,
5916
6135
  items: (state) => state.items,
@@ -6330,7 +6549,7 @@ function AriaCombobox(props) {
6330
6549
  valuesRef,
6331
6550
  pointerDownItemRef,
6332
6551
  selectionEventRef
6333
- }, selectors$2);
6552
+ }, selectors$1);
6334
6553
  }).current;
6335
6554
  const fieldRawValue = selectionMode === "none" ? inputValue : selectedValue;
6336
6555
  const fieldStringValue = import_react.useMemo(() => {
@@ -7768,74 +7987,6 @@ var ComboboxEmpty = /*#__PURE__*/ import_react.forwardRef(function ComboboxEmpty
7768
7987
  }, elementProps]
7769
7988
  });
7770
7989
  });
7771
- // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/dialog/root/DialogRootContext.mjs
7772
- var DialogRootContext = /*#__PURE__*/ import_react.createContext(void 0);
7773
- function useDialogRootContext(optional) {
7774
- const store = import_react.useContext(DialogRootContext);
7775
- if (!optional && store === void 0) throw new Error(formatErrorMessage(27));
7776
- return store;
7777
- }
7778
- // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/dialog/backdrop/DialogBackdrop.mjs
7779
- /**
7780
- * An overlay displayed beneath the popup.
7781
- * Renders a `<div>` element.
7782
- *
7783
- * Documentation: [Base UI Dialog](https://base-ui.com/react/components/dialog)
7784
- */
7785
- var DialogBackdrop = /*#__PURE__*/ import_react.forwardRef(function DialogBackdrop(componentProps, forwardedRef) {
7786
- const { render, className, style, forceRender = false, ...elementProps } = componentProps;
7787
- const store = useDialogRootContext();
7788
- const open = store.useState("open");
7789
- const nested = store.useState("nested");
7790
- const mounted = store.useState("mounted");
7791
- const state = {
7792
- open,
7793
- transitionStatus: store.useState("transitionStatus")
7794
- };
7795
- return useRenderElement("div", componentProps, {
7796
- state,
7797
- ref: [store.context.backdropRef, forwardedRef],
7798
- stateAttributesMapping: popupTransitionStateMapping,
7799
- props: [{
7800
- role: "presentation",
7801
- hidden: !mounted,
7802
- style: {
7803
- userSelect: "none",
7804
- WebkitUserSelect: "none"
7805
- }
7806
- }, elementProps],
7807
- enabled: forceRender || !nested
7808
- });
7809
- });
7810
- // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/dialog/close/DialogClose.mjs
7811
- /**
7812
- * A button that closes the dialog.
7813
- * Renders a `<button>` element.
7814
- *
7815
- * Documentation: [Base UI Dialog](https://base-ui.com/react/components/dialog)
7816
- */
7817
- var DialogClose$1 = /*#__PURE__*/ import_react.forwardRef(function DialogClose(componentProps, forwardedRef) {
7818
- const { render, className, style, disabled = false, nativeButton = true, ...elementProps } = componentProps;
7819
- const store = useDialogRootContext();
7820
- const open = store.useState("open");
7821
- const { getButtonProps, buttonRef } = useButton({
7822
- disabled,
7823
- native: nativeButton
7824
- });
7825
- const state = { disabled };
7826
- function handleClick(event) {
7827
- if (open) store.setOpen(false, createChangeEventDetails(closePress, event.nativeEvent));
7828
- }
7829
- return useRenderElement("button", componentProps, {
7830
- state,
7831
- ref: [forwardedRef, buttonRef],
7832
- props: [
7833
- { onClick: handleClick },
7834
- elementProps,
7835
- getButtonProps
7836
- ]
7837
- });
7838
- });
7839
7990
  // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/dialog/description/DialogDescription.mjs
7840
7991
  /**
7841
7992
  * A paragraph with additional information about the dialog.
@@ -7853,412 +8004,60 @@ var DialogDescription$1 = /*#__PURE__*/ import_react.forwardRef(function DialogD
7853
8004
  props: [{ id }, elementProps]
7854
8005
  });
7855
8006
  });
7856
- // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/dialog/portal/DialogPortalContext.mjs
7857
- var DialogPortalContext = /*#__PURE__*/ import_react.createContext(void 0);
7858
- function useDialogPortalContext() {
7859
- const value = import_react.useContext(DialogPortalContext);
7860
- if (value === void 0) throw new Error(formatErrorMessage(26));
7861
- return value;
7862
- }
7863
- // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/dialog/popup/DialogPopupCssVars.mjs
7864
- /**
7865
- * Indicates how many dialogs are nested within.
7866
- * @type {number}
7867
- */
7868
- var nestedDialogs = "--nested-dialogs";
7869
- /**
7870
- * Present when the dialog has other open dialogs nested within it.
7871
- */
7872
- var nestedDialogOpen = "data-nested-dialog-open";
7873
- // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/dialog/utils/stateAttributesMapping.mjs
7874
- /**
7875
- * Shared by `Dialog.Popup` and `Dialog.Viewport`, whose states have the same shape.
7876
- * `nested` is not mapped: unmapped `true` booleans already render as `data-nested`.
7877
- */
7878
- var dialogStateAttributesMapping = {
7879
- ...popupStateMapping,
7880
- ...transitionStatusMapping,
7881
- nestedDialogOpen(value) {
7882
- return value ? { [nestedDialogOpen]: "" } : null;
7883
- }
7884
- };
7885
- // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/dialog/popup/DialogPopup.mjs
7886
- /**
7887
- * A container for the dialog contents.
7888
- * Renders a `<div>` element.
7889
- *
7890
- * Documentation: [Base UI Dialog](https://base-ui.com/react/components/dialog)
7891
- */
7892
- var DialogPopup = /*#__PURE__*/ import_react.forwardRef(function DialogPopup(componentProps, forwardedRef) {
7893
- const { render, className, style, finalFocus, initialFocus, ...elementProps } = componentProps;
7894
- const store = useDialogRootContext();
7895
- const descriptionElementId = store.useState("descriptionElementId");
7896
- const disablePointerDismissal = store.useState("disablePointerDismissal");
7897
- const floatingRootContext = store.useState("floatingRootContext");
7898
- const rootPopupProps = store.useState("popupProps");
7899
- const modal = store.useState("modal");
7900
- const mounted = store.useState("mounted");
7901
- const nested = store.useState("nested");
7902
- const nestedOpenDialogCount = store.useState("nestedOpenDialogCount");
7903
- const open = store.useState("open");
7904
- const openMethod = store.useState("openMethod");
7905
- const titleElementId = store.useState("titleElementId");
7906
- const transitionStatus = store.useState("transitionStatus");
7907
- const role = store.useState("role");
7908
- const floatingId = floatingRootContext.useState("floatingId");
7909
- useDialogPortalContext();
7910
- useOpenChangeComplete({
7911
- open,
7912
- ref: store.context.popupRef,
7913
- onComplete() {
7914
- if (open) store.context.onOpenChangeComplete?.(true);
7915
- }
8007
+ fastComponentRef(function DialogTrigger(componentProps, forwardedRef) {
8008
+ const { render, className, style, disabled = false, nativeButton = true, id: idProp, payload, handle, ...elementProps } = componentProps;
8009
+ const dialogRootStore = useDialogRootContext(true);
8010
+ const store = usePopupHandleStore(handle) ?? dialogRootStore;
8011
+ if (!store) throw new Error(formatErrorMessage(79));
8012
+ const thisTriggerId = useBaseUiId(idProp);
8013
+ const floatingContext = store.useState("floatingRootContext");
8014
+ const isOpenedByThisTrigger = store.useState("isOpenedByTrigger", thisTriggerId);
8015
+ const popupId = store.useState("triggerPopupId", thisTriggerId);
8016
+ const triggerElementRef = import_react.useRef(null);
8017
+ const { registerTrigger, isMountedByThisTrigger } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, { payload });
8018
+ const { getButtonProps, buttonRef } = useButton({
8019
+ disabled,
8020
+ native: nativeButton
7916
8021
  });
7917
- const resolvedInitialFocus = initialFocus === void 0 ? createDefaultInitialFocus(store.context.popupRef) : initialFocus;
7918
- const nestedDialogOpen = nestedOpenDialogCount > 0;
7919
- const setPopupElement = store.useStateSetter("popupElement");
7920
- const element = useRenderElement("div", componentProps, {
7921
- state: {
7922
- open,
7923
- nested,
7924
- transitionStatus,
7925
- nestedDialogOpen
7926
- },
8022
+ const click = useClick(floatingContext);
8023
+ const interactionTypeProps = useOpenMethodTriggerProps(() => store.select("open"), (interactionType) => {
8024
+ store.set("openMethod", interactionType);
8025
+ });
8026
+ const state = {
8027
+ disabled,
8028
+ open: isOpenedByThisTrigger
8029
+ };
8030
+ const rootTriggerProps = store.useState("triggerProps", isMountedByThisTrigger);
8031
+ return useRenderElement("button", componentProps, {
8032
+ state,
8033
+ ref: [
8034
+ buttonRef,
8035
+ forwardedRef,
8036
+ registerTrigger,
8037
+ triggerElementRef
8038
+ ],
7927
8039
  props: [
7928
- rootPopupProps,
8040
+ click.reference,
8041
+ rootTriggerProps,
8042
+ interactionTypeProps,
7929
8043
  {
7930
- id: floatingId,
7931
- "aria-labelledby": titleElementId,
7932
- "aria-describedby": descriptionElementId,
7933
- role,
7934
- ...FOCUSABLE_POPUP_PROPS,
7935
- hidden: !mounted,
7936
- onKeyDown(event) {
7937
- if (COMPOSITE_KEYS.has(event.key)) event.stopPropagation();
7938
- },
7939
- style: { [nestedDialogs]: nestedOpenDialogCount }
8044
+ [CLICK_TRIGGER_IDENTIFIER]: "",
8045
+ id: thisTriggerId,
8046
+ "aria-haspopup": "dialog",
8047
+ "aria-expanded": isOpenedByThisTrigger,
8048
+ "aria-controls": popupId
7940
8049
  },
7941
- elementProps
7942
- ],
7943
- ref: [
7944
- forwardedRef,
7945
- store.context.popupRef,
7946
- setPopupElement
8050
+ elementProps,
8051
+ getButtonProps
7947
8052
  ],
7948
- stateAttributesMapping: dialogStateAttributesMapping
7949
- });
7950
- return /*#__PURE__*/ (0, import_jsx_runtime.jsx)(FloatingFocusManager, {
7951
- context: floatingRootContext,
7952
- openInteractionType: openMethod,
7953
- disabled: !mounted,
7954
- closeOnFocusOut: !disablePointerDismissal,
7955
- initialFocus: resolvedInitialFocus,
7956
- returnFocus: finalFocus,
7957
- modal: modal !== false,
7958
- restoreFocus: "popup",
7959
- children: element
8053
+ stateAttributesMapping: triggerOpenStateMapping
7960
8054
  });
7961
8055
  });
7962
- // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/dialog/portal/DialogPortal.mjs
7963
- /**
7964
- * A portal element that moves the popup to a different part of the DOM.
7965
- * By default, the portal element is appended to `<body>`.
7966
- * Renders a `<div>` element.
7967
- *
7968
- * Documentation: [Base UI Dialog](https://base-ui.com/react/components/dialog)
7969
- */
7970
- var DialogPortal = /*#__PURE__*/ import_react.forwardRef(function DialogPortal(props, forwardedRef) {
7971
- const { keepMounted = false, ...portalProps } = props;
7972
- const store = useDialogRootContext();
7973
- const mounted = store.useState("mounted");
7974
- const modal = store.useState("modal");
7975
- const open = store.useState("open");
7976
- if (!(mounted || keepMounted)) return null;
7977
- return /*#__PURE__*/ (0, import_jsx_runtime.jsx)(DialogPortalContext.Provider, {
7978
- value: keepMounted,
7979
- children: /*#__PURE__*/ (0, import_jsx_runtime.jsxs)(FloatingPortal, {
7980
- ref: forwardedRef,
7981
- ...portalProps,
7982
- children: [mounted && modal === true && /*#__PURE__*/ (0, import_jsx_runtime.jsx)(InternalBackdrop, {
7983
- ref: store.context.internalBackdropRef,
7984
- inert: inertValue(!open)
7985
- }), props.children]
7986
- })
7987
- });
7988
- });
7989
- // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/dialog/root/useDialogRoot.mjs
7990
- function DialogInteractions({ store, parentContext, isDrawer }) {
7991
- const open = store.useState("open");
7992
- const mounted = store.useState("mounted");
7993
- const disablePointerDismissal = store.useState("disablePointerDismissal");
7994
- const modal = store.useState("modal");
7995
- const popupElement = store.useState("popupElement");
7996
- const floatingRootContext = store.useState("floatingRootContext");
7997
- const [ownNestedOpenDialogs, setOwnNestedOpenDialogs] = import_react.useState(0);
7998
- const [ownNestedOpenDrawers, setOwnNestedOpenDrawers] = import_react.useState(0);
7999
- const isTopmost = ownNestedOpenDialogs === 0;
8000
- const dismiss = useDismiss(floatingRootContext, {
8001
- outsidePressEvent() {
8002
- if (store.context.internalBackdropRef.current || store.context.backdropRef.current) return "intentional";
8003
- return {
8004
- mouse: modal === "trap-focus" ? "sloppy" : "intentional",
8005
- touch: "sloppy"
8006
- };
8007
- },
8008
- outsidePress(event) {
8009
- if (!store.context.outsidePressEnabledRef.current) return false;
8010
- if ("button" in event && event.button !== 0) return false;
8011
- if ("touches" in event) {
8012
- if (event.type === "touchend") {
8013
- if (event.changedTouches.length !== 1 || event.touches.length !== 0) return false;
8014
- } else if (event.touches.length !== 1) return false;
8015
- }
8016
- const target = getTarget(event);
8017
- if (isTopmost && !disablePointerDismissal) {
8018
- if (modal) {
8019
- const internalBackdrop = store.context.internalBackdropRef.current;
8020
- const backdrop = store.context.backdropRef.current;
8021
- return internalBackdrop || backdrop ? internalBackdrop === target || backdrop === target || contains(target, popupElement) && !target?.hasAttribute("data-base-ui-portal") : true;
8022
- }
8023
- return true;
8024
- }
8025
- return false;
8026
- },
8027
- escapeKey: isTopmost
8028
- });
8029
- useScrollLock(open && modal === true, popupElement);
8030
- store.useContextCallback("onNestedDialogOpen", (dialogCount, drawerCount) => {
8031
- if (!store.select("open") && !store.select("mounted")) return;
8032
- setOwnNestedOpenDialogs(dialogCount);
8033
- setOwnNestedOpenDrawers(drawerCount);
8034
- });
8035
- useIsoLayoutEffect(() => {
8036
- if (!open && !mounted) {
8037
- setOwnNestedOpenDialogs(0);
8038
- setOwnNestedOpenDrawers(0);
8039
- }
8040
- }, [open, mounted]);
8041
- useIsoLayoutEffect(() => {
8042
- if (parentContext?.onNestedDialogOpen) {
8043
- if (open) parentContext.onNestedDialogOpen(ownNestedOpenDialogs + 1, ownNestedOpenDrawers + (isDrawer ? 1 : 0));
8044
- }
8045
- return () => {
8046
- if (parentContext?.onNestedDialogOpen && open) parentContext.onNestedDialogOpen(0, 0);
8047
- };
8048
- }, [
8049
- isDrawer,
8050
- open,
8051
- ownNestedOpenDialogs,
8052
- ownNestedOpenDrawers,
8053
- parentContext
8054
- ]);
8055
- usePopupInteractionProps(store, {
8056
- activeTriggerProps: dismiss.reference,
8057
- inactiveTriggerProps: dismiss.trigger,
8058
- popupProps: dismiss.floating,
8059
- nestedOpenDialogCount: ownNestedOpenDialogs,
8060
- nestedOpenDrawerCount: ownNestedOpenDrawers
8061
- });
8062
- return null;
8063
- }
8064
- // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/dialog/store/DialogStore.mjs
8065
- var selectors$1 = {
8066
- ...popupStoreSelectors,
8067
- modal: (state) => state.modal,
8068
- nested: (state) => state.nested,
8069
- nestedOpenDialogCount: (state) => state.nestedOpenDialogCount,
8070
- nestedOpenDrawerCount: (state) => state.nestedOpenDrawerCount,
8071
- disablePointerDismissal: (state) => state.disablePointerDismissal,
8072
- openMethod: (state) => state.openMethod,
8073
- descriptionElementId: (state) => state.descriptionElementId,
8074
- titleElementId: (state) => state.titleElementId,
8075
- viewportElement: (state) => state.viewportElement,
8076
- role: (state) => state.role
8077
- };
8078
- /**
8079
- * The subset of `DialogStore` that detached handle-backed triggers rely on. Both the real
8080
- * `DialogStore` and the inert fallback store satisfy it, so a trigger can read from whichever
8081
- * store the handle currently exposes.
8082
- */
8083
- var DialogStore = class extends ReactStore {
8084
- constructor(initialState, floatingId, nested) {
8085
- const triggerElements = new PopupTriggerMap();
8086
- const state = createInitialState$1(initialState, triggerElements, floatingId, nested);
8087
- super(state, createInitialContext$1(triggerElements), selectors$1);
8088
- }
8089
- setOpen = (nextOpen, eventDetails) => {
8090
- eventDetails.preventUnmountOnClose = () => {
8091
- this.set("preventUnmountingOnClose", true);
8092
- };
8093
- if (!nextOpen && eventDetails.trigger == null && this.state.activeTriggerId != null) eventDetails.trigger = this.state.activeTriggerElement ?? void 0;
8094
- this.context.onOpenChange?.(nextOpen, eventDetails);
8095
- if (eventDetails.isCanceled) return;
8096
- this.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
8097
- this.update(createPopupOpenState(this.state, nextOpen, eventDetails.trigger));
8098
- };
8099
- };
8100
- function createInitialState$1(initialState, triggerElements, floatingId, nested = false) {
8101
- return {
8102
- ...createInitialPopupStoreState(triggerElements, floatingId, nested),
8103
- modal: true,
8104
- disablePointerDismissal: false,
8105
- viewportElement: null,
8106
- descriptionElementId: void 0,
8107
- titleElementId: void 0,
8108
- openMethod: null,
8109
- nested: false,
8110
- nestedOpenDialogCount: 0,
8111
- nestedOpenDrawerCount: 0,
8112
- role: "dialog",
8113
- ...initialState
8114
- };
8115
- }
8116
- function createInitialContext$1(triggerElements) {
8117
- return {
8118
- popupRef: /*#__PURE__*/ import_react.createRef(),
8119
- backdropRef: /*#__PURE__*/ import_react.createRef(),
8120
- internalBackdropRef: /*#__PURE__*/ import_react.createRef(),
8121
- outsidePressEnabledRef: { current: true },
8122
- triggerElements,
8123
- onOpenChange: void 0,
8124
- onOpenChangeComplete: void 0
8125
- };
8126
- }
8127
- // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/dialog/root/useRenderDialogRoot.mjs
8128
- function useRenderDialogRoot(mode, props) {
8129
- const { children, open: openProp, defaultOpen = false, onOpenChange, onOpenChangeComplete, disablePointerDismissal: disablePointerDismissalProp = false, modal: modalProp = true, actionsRef, handle, triggerId: triggerIdProp, defaultTriggerId: defaultTriggerIdProp = null } = props;
8130
- const isDrawer = mode === "drawer";
8131
- const isAlertDialog = mode === "alert-dialog";
8132
- const modal = isAlertDialog ? true : modalProp;
8133
- const disablePointerDismissal = isAlertDialog || disablePointerDismissalProp;
8134
- const role = isAlertDialog ? "alertdialog" : "dialog";
8135
- const parentStore = useDialogRootContext(true);
8136
- const rootState = {
8137
- modal,
8138
- disablePointerDismissal,
8139
- nested: parentStore != null,
8140
- role
8141
- };
8142
- const store = usePopupRootStore((floatingId, floatingNested) => new DialogStore({
8143
- open: defaultOpen,
8144
- openProp,
8145
- activeTriggerId: defaultTriggerIdProp,
8146
- triggerIdProp,
8147
- ...rootState
8148
- }, floatingId, floatingNested), true);
8149
- store.useControlledProp("openProp", openProp);
8150
- store.useControlledProp("triggerIdProp", triggerIdProp);
8151
- store.useSyncedValues(rootState);
8152
- store.useContextCallback("onOpenChange", onOpenChange);
8153
- store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
8154
- const open = store.useState("open");
8155
- const mounted = store.useState("mounted");
8156
- const payload = store.useState("payload");
8157
- usePopupRootSync(store, open);
8158
- useImplicitActiveTrigger(store);
8159
- const { forceUnmount } = useOpenStateTransitions(open, store);
8160
- import_react.useImperativeHandle(actionsRef, () => ({
8161
- unmount: forceUnmount,
8162
- close: () => store.setOpen(false, createChangeEventDetails(imperativeAction))
8163
- }), [forceUnmount, store]);
8164
- const shouldRenderInteractions = open || mounted || handle != null;
8165
- return /*#__PURE__*/ (0, import_jsx_runtime.jsxs)(DialogRootContext.Provider, {
8166
- value: store,
8167
- children: [
8168
- handle && /*#__PURE__*/ (0, import_jsx_runtime.jsx)(PopupHandleAttachment, {
8169
- handle,
8170
- store
8171
- }),
8172
- shouldRenderInteractions && /*#__PURE__*/ (0, import_jsx_runtime.jsx)(DialogInteractions, {
8173
- store,
8174
- parentContext: parentStore?.context,
8175
- isDrawer
8176
- }),
8177
- typeof children === "function" ? children({ payload }) : children
8178
- ]
8179
- });
8180
- }
8181
- // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/dialog/root/DialogRoot.mjs
8182
- /**
8183
- * Groups all parts of the dialog.
8184
- * Doesn't render its own HTML element.
8185
- *
8186
- * Documentation: [Base UI Dialog](https://base-ui.com/react/components/dialog)
8187
- */
8188
- var DialogRoot = fastComponent(function DialogRoot(props) {
8189
- return useRenderDialogRoot("dialog", props);
8190
- });
8191
- // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/dialog/title/DialogTitle.mjs
8192
- /**
8193
- * A heading that labels the dialog.
8194
- * Renders an `<h2>` element.
8195
- *
8196
- * Documentation: [Base UI Dialog](https://base-ui.com/react/components/dialog)
8197
- */
8198
- var DialogTitle$1 = /*#__PURE__*/ import_react.forwardRef(function DialogTitle(componentProps, forwardedRef) {
8199
- const { render, className, style, id: idProp, ...elementProps } = componentProps;
8200
- const store = useDialogRootContext();
8201
- const id = useBaseUiId(idProp);
8202
- store.useSyncedValueWithCleanup("titleElementId", id);
8203
- return useRenderElement("h2", componentProps, {
8204
- ref: forwardedRef,
8205
- props: [{ id }, elementProps]
8206
- });
8207
- });
8208
- fastComponentRef(function DialogTrigger(componentProps, forwardedRef) {
8209
- const { render, className, style, disabled = false, nativeButton = true, id: idProp, payload, handle, ...elementProps } = componentProps;
8210
- const dialogRootStore = useDialogRootContext(true);
8211
- const store = usePopupHandleStore(handle) ?? dialogRootStore;
8212
- if (!store) throw new Error(formatErrorMessage(79));
8213
- const thisTriggerId = useBaseUiId(idProp);
8214
- const floatingContext = store.useState("floatingRootContext");
8215
- const isOpenedByThisTrigger = store.useState("isOpenedByTrigger", thisTriggerId);
8216
- const popupId = store.useState("triggerPopupId", thisTriggerId);
8217
- const triggerElementRef = import_react.useRef(null);
8218
- const { registerTrigger, isMountedByThisTrigger } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, { payload });
8219
- const { getButtonProps, buttonRef } = useButton({
8220
- disabled,
8221
- native: nativeButton
8222
- });
8223
- const click = useClick(floatingContext);
8224
- const interactionTypeProps = useOpenMethodTriggerProps(() => store.select("open"), (interactionType) => {
8225
- store.set("openMethod", interactionType);
8226
- });
8227
- const state = {
8228
- disabled,
8229
- open: isOpenedByThisTrigger
8230
- };
8231
- const rootTriggerProps = store.useState("triggerProps", isMountedByThisTrigger);
8232
- return useRenderElement("button", componentProps, {
8233
- state,
8234
- ref: [
8235
- buttonRef,
8236
- forwardedRef,
8237
- registerTrigger,
8238
- triggerElementRef
8239
- ],
8240
- props: [
8241
- click.reference,
8242
- rootTriggerProps,
8243
- interactionTypeProps,
8244
- {
8245
- [CLICK_TRIGGER_IDENTIFIER]: "",
8246
- id: thisTriggerId,
8247
- "aria-haspopup": "dialog",
8248
- "aria-expanded": isOpenedByThisTrigger,
8249
- "aria-controls": popupId
8250
- },
8251
- elementProps,
8252
- getButtonProps
8253
- ],
8254
- stateAttributesMapping: triggerOpenStateMapping
8255
- });
8256
- });
8257
- // src/components/ui/dialog.tsx
8258
- function Dialog(props) {
8259
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogRoot, {
8260
- "data-slot": "dialog",
8261
- ...props
8056
+ // src/components/ui/dialog.tsx
8057
+ function Dialog(props) {
8058
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogRoot, {
8059
+ "data-slot": "dialog",
8060
+ ...props
8262
8061
  });
8263
8062
  }
8264
8063
  var DialogClose = DialogClose$1;
@@ -8307,14 +8106,25 @@ var CHANGE_GROUPS = [
8307
8106
  var GROUP_TITLES = {
8308
8107
  "needs-you": "Needs you",
8309
8108
  building: "Implementation started",
8310
- ready: "Ready to archive"
8109
+ ready: "Ready to submit"
8311
8110
  };
8111
+ /** The stages a change is ready at: `submit`, and `publish` after it. */
8112
+ var READY_STAGES = /* @__PURE__ */ new Set(["submit", "publish"]);
8312
8113
  function changeGroup(change) {
8114
+ if (change.planned === false) return READY_STAGES.has(change.position?.stage?.id ?? "") ? "ready" : "needs-you";
8313
8115
  const total = change.totalTasks ?? 0;
8314
8116
  const done = change.completedTasks ?? 0;
8315
8117
  if (change.valid === false || total === 0 || done === 0) return "needs-you";
8316
8118
  return done < total ? "building" : "ready";
8317
8119
  }
8120
+ /**
8121
+ * The changes still in flight: a submitted change awaits publication even when its folder is
8122
+ * checked out, unless that folder holds work the submitted one lacks.
8123
+ */
8124
+ function activeChanges(changes, submitted) {
8125
+ const awaiting = new Set(submitted.map((change) => change.name));
8126
+ return changes.filter((change) => !awaiting.has(change.name) || change.unsubmitted === true);
8127
+ }
8318
8128
  function groupChanges(changes) {
8319
8129
  const groups = {
8320
8130
  "needs-you": [],
@@ -8324,41 +8134,63 @@ function groupChanges(changes) {
8324
8134
  for (const change of changes) groups[changeGroup(change)].push(change);
8325
8135
  return groups;
8326
8136
  }
8327
- function changeStep(change) {
8328
- const total = change.totalTasks ?? 0;
8329
- const done = change.completedTasks ?? 0;
8330
- if (change.valid === false) {
8331
- const issues = change.issueCount ?? 0;
8137
+ var DEFAULT_WORKFLOW = defaultWorkflow();
8138
+ /** The stages a change walks: the required ones up to submit, as its panel lists them. */
8139
+ function changePath(workflow = DEFAULT_WORKFLOW) {
8140
+ const passed = stagesBeforeWork(workflow);
8141
+ return workflow.stages.filter((stage) => !stage.optional && !(stage.kind === "skill" && stage.milestone === "published") && !passed.includes(stage));
8142
+ }
8143
+ /** The prompt of a skill action in the fallback `/name` syntax. */
8144
+ var promptOf = (action) => `/${action.skill}${action.change ? ` ${action.change}` : ""}`;
8145
+ /** The artifact id of a review action (`Review specs: <path>`); null for another text. */
8146
+ var reviewedId = (action) => action.kind === "text" ? /^Review ([^:]+):/.exec(action.text)?.[1] ?? null : null;
8147
+ var NOT_PLACED = {
8148
+ stage: "Not placed",
8149
+ stageId: null,
8150
+ review: false,
8151
+ situation: "Its position is not known",
8152
+ next: "Reload Studio",
8153
+ prompt: ""
8154
+ };
8155
+ /**
8156
+ * Where the change is on the companion's Delivery Path and what comes next, as its payload
8157
+ * position says: what `mate workflow next` computes for it.
8158
+ */
8159
+ function changeStep(change, workflow = DEFAULT_WORKFLOW) {
8160
+ const { position } = change;
8161
+ if (!position) return NOT_PLACED;
8162
+ const { stage } = position;
8163
+ if (!stage) return {
8164
+ stage: "Dropped",
8165
+ stageId: null,
8166
+ review: false,
8167
+ situation: "Withdrawn",
8168
+ next: "Nothing to do",
8169
+ prompt: ""
8170
+ };
8171
+ const { actions } = position.handoff;
8172
+ const action = actions.find((entry) => entry.kind === "skill");
8173
+ const at = {
8174
+ stage: stage.label,
8175
+ stageId: stage.id,
8176
+ prompt: action ? promptOf(action) : ""
8177
+ };
8178
+ if (stage.kind === "review") {
8179
+ const reviews = actions.map(reviewedId).filter((id) => id !== null);
8180
+ const follows = action ? stepStage(workflow, action.skill)?.label : void 0;
8332
8181
  return {
8333
- stage: "Propose change",
8334
- situation: `${issues} validation ${issues === 1 ? "issue" : "issues"}`,
8335
- next: "Fix the plan so it validates",
8336
- prompt: `/mate-propose-change ${change.name}`
8182
+ ...at,
8183
+ review: true,
8184
+ situation: "Plan ready for review",
8185
+ next: `Review ${reviews.length > 0 ? reviews.join(", ") : "the plan"}, then run ${follows ?? "the next stage"}`
8337
8186
  };
8338
8187
  }
8339
- if (total === 0) return {
8340
- stage: "Propose change",
8341
- situation: "No tasks yet",
8342
- next: "Finish the plan",
8343
- prompt: `/mate-propose-change ${change.name}`
8344
- };
8345
- if (done === 0) return {
8346
- stage: "Human review",
8347
- situation: "Plan ready for review",
8348
- next: "Review the plan, then apply it",
8349
- prompt: `/mate-apply-change ${change.name}`
8350
- };
8351
- if (done < total) return {
8352
- stage: "Apply change",
8353
- situation: `${total - done} ${total - done === 1 ? "task" : "tasks"} left`,
8354
- next: "Continue the build",
8355
- prompt: `/mate-apply-change ${change.name}`
8356
- };
8188
+ const runs = !action || action.skill === stage.entry ? stage.label : action.skill;
8357
8189
  return {
8358
- stage: "Archive change",
8359
- situation: "All tasks done",
8360
- next: "Archive the change",
8361
- prompt: `/mate-archive-change ${change.name}`
8190
+ ...at,
8191
+ review: false,
8192
+ situation: position.open ?? "Ready",
8193
+ next: `Run ${runs}`
8362
8194
  };
8363
8195
  }
8364
8196
  /**
@@ -8402,8 +8234,8 @@ function useMediaQuery(query) {
8402
8234
  var MODE_ORDER = [
8403
8235
  "dashboard",
8404
8236
  "workflow",
8405
- "factory",
8406
8237
  "skills",
8238
+ "mcp",
8407
8239
  "getting-started"
8408
8240
  ];
8409
8241
  var LIBRARY_ORDER = [
@@ -8411,17 +8243,22 @@ var LIBRARY_ORDER = [
8411
8243
  "vault",
8412
8244
  "graph"
8413
8245
  ];
8414
- var INSIGHTS_ORDER = ["usage", "reports"];
8246
+ var INSIGHTS_ORDER = [
8247
+ "usage",
8248
+ "friction",
8249
+ "reports"
8250
+ ];
8415
8251
  var VIEW_ICONS = {
8416
8252
  dashboard: "home",
8417
8253
  workflow: "flow",
8418
8254
  "getting-started": "doc",
8419
- factory: "factory",
8420
8255
  skills: "spark",
8256
+ mcp: "plug",
8421
8257
  specs: "doc",
8422
8258
  vault: "folder",
8423
8259
  reports: "chart",
8424
8260
  usage: "chart",
8261
+ friction: "alert",
8425
8262
  graph: "graph"
8426
8263
  };
8427
8264
  /** Core's views in Studio's order; a view the order does not name yet goes last, never missing. */
@@ -8429,9 +8266,9 @@ function inOrder(views, order) {
8429
8266
  const rank = (view) => order.includes(view) ? order.indexOf(view) : order.length;
8430
8267
  return views.toSorted((a, b) => rank(a) - rank(b));
8431
8268
  }
8432
- /** The views a mode lists, in navigation order; Factory only where the broker runs. */
8433
- function modeViews(mode, factoryMode) {
8434
- return inOrder(MODE_VIEWS[mode], MODE_ORDER).filter((view) => factoryMode || view !== "factory");
8269
+ /** The views a mode lists, in navigation order. */
8270
+ function modeViews(mode) {
8271
+ return inOrder(MODE_VIEWS[mode], MODE_ORDER);
8435
8272
  }
8436
8273
  function libraryViews() {
8437
8274
  return inOrder(SHARED_VIEWS.filter((view) => !INSIGHTS_ORDER.includes(view)), LIBRARY_ORDER);
@@ -8478,7 +8315,7 @@ function openTerminal() {
8478
8315
  if (narrowFrame()) focusDrawer();
8479
8316
  }
8480
8317
  // src/shell/command-palette.tsx
8481
- /** Cmd/Ctrl+K anywhere, Slash outside a text field unless the page took it (Factory filter). */
8318
+ /** Cmd/Ctrl+K anywhere, Slash outside a text field unless the page took it (a view's own filter). */
8482
8319
  function usePaletteKeys(enabled) {
8483
8320
  const setOpen = usePalette((state) => state.setOpen);
8484
8321
  (0, import_react.useEffect)(() => {
@@ -8514,7 +8351,7 @@ function useCommands(shell, search, open) {
8514
8351
  }
8515
8352
  });
8516
8353
  const views = [
8517
- ...modeViews(shell.studioMode, shell.factoryMode),
8354
+ ...modeViews(shell.studioMode),
8518
8355
  ...libraryViews(),
8519
8356
  ...insightViews()
8520
8357
  ].map((view) => ({
@@ -8524,17 +8361,35 @@ function useCommands(shell, search, open) {
8524
8361
  icon: VIEW_ICONS[view],
8525
8362
  run: () => go(view)
8526
8363
  }));
8364
+ const pluginViews = shell.pluginViews.map((entry) => ({
8365
+ id: `plugin-${entry.service}-${entry.view}`,
8366
+ label: entry.label,
8367
+ hint: "View",
8368
+ icon: "spark",
8369
+ run: () => void navigate({
8370
+ to: "/plugins/$service/$view",
8371
+ params: {
8372
+ service: entry.service,
8373
+ view: entry.view
8374
+ },
8375
+ search: {
8376
+ companion: search.companion,
8377
+ studioMode: search.studioMode
8378
+ }
8379
+ })
8380
+ }));
8527
8381
  const changes = engineering ? data?.changes ?? [] : [];
8382
+ const workflow = data?.workflow ?? void 0;
8528
8383
  const changeCommands = changes.map((change) => ({
8529
8384
  id: `change-${change.name}`,
8530
8385
  label: change.name,
8531
- hint: changeStep(change).situation,
8386
+ hint: changeStep(change, workflow).situation,
8532
8387
  icon: "doc",
8533
8388
  mono: true,
8534
8389
  run: () => go("dashboard", { change: change.name })
8535
8390
  }));
8536
8391
  const nextSteps = groupChanges(changes)["needs-you"].map((change) => {
8537
- const step = changeStep(change);
8392
+ const step = changeStep(change, workflow);
8538
8393
  return {
8539
8394
  id: `next-${change.name}`,
8540
8395
  label: `Copy next step: ${step.prompt}`,
@@ -8581,7 +8436,7 @@ function useCommands(shell, search, open) {
8581
8436
  return [
8582
8437
  {
8583
8438
  value: "Views",
8584
- items: views
8439
+ items: [...views, ...pluginViews]
8585
8440
  },
8586
8441
  {
8587
8442
  value: "Changes",
@@ -9328,102 +9183,13 @@ var addCompanion = createServerFn({ method: "POST" }).validator((input) => {
9328
9183
  };
9329
9184
  throw new Error("name a Git URL or a path");
9330
9185
  }).handler(createSsrRpc("ce3152edd0f9f5f9d010eb4e4217f988b6787024b3f6a48677370a325f4698aa"));
9331
- // src/lib/git-tokens.ts
9332
- /**
9333
- * The Git access panel's calls to the Git token route. Only each key's status is cached; an
9334
- * entered token goes in one request body and is never kept, keyed or put in an address.
9335
- */
9336
- var gitTokensKey = ["git-tokens"];
9337
- var gitTokensQuery = () => ({
9338
- queryKey: gitTokensKey,
9339
- queryFn: () => call("GET", FACTORY_GIT_TOKENS_ROUTE)
9340
- });
9341
- var setGitToken = (key, token) => call("PUT", FACTORY_GIT_TOKENS_ROUTE, {
9342
- key,
9343
- token
9344
- });
9345
- var clearGitToken = (key) => call("DELETE", FACTORY_GIT_TOKENS_ROUTE, { key });
9346
- /** The host of a `host` or `host/org` key. */
9347
- var hostOf = (key) => key.split("/")[0];
9348
- /** Whether a stored key covers `key` (`host/org`): its own, or its host's. */
9349
- var tokenCovers = (key, tokens) => tokens.some((token) => token.key === key || token.key === hostOf(key));
9350
- // src/views/factory/git-token-form.tsx
9351
- /** Reads the form's fields and empties the token, so it lives only in this request. */
9352
- function takeFields(event) {
9353
- event.preventDefault();
9354
- const form = event.currentTarget;
9355
- const data = new FormData(form);
9356
- const key = data.get("key");
9357
- const token = data.get("token");
9358
- form.querySelector("[name=\"token\"]").value = "";
9359
- return {
9360
- key: typeof key === "string" ? key : "",
9361
- token: typeof token === "string" ? token : ""
9362
- };
9363
- }
9364
- /**
9365
- * Sets a Git token for a `host` or `host/org`. Used by the Git access panel and by the dialogs
9366
- * that add a repository, which pass the key of the URL that was refused.
9367
- */
9368
- function GitTokenForm({ defaultKey = "", onSaved }) {
9369
- const queryClient = useQueryClient();
9370
- const save = useMutation({
9371
- mutationFn: ({ key, token }) => setGitToken(key, token),
9372
- onSuccess: (next) => {
9373
- queryClient.setQueryData(gitTokensKey, next);
9374
- onSaved?.(next);
9375
- }
9376
- });
9377
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", {
9378
- className: "factory-sheet",
9379
- "data-git-token-form": "",
9380
- onSubmit: (event) => save.mutate(takeFields(event)),
9381
- children: [
9382
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
9383
- className: "agents-field",
9384
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Host or host/organization" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
9385
- type: "text",
9386
- name: "key",
9387
- defaultValue: defaultKey,
9388
- placeholder: "git.acme.test/acme",
9389
- autoComplete: "off",
9390
- spellCheck: false,
9391
- required: true
9392
- })]
9393
- }),
9394
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
9395
- className: "agents-field",
9396
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Token" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
9397
- type: "password",
9398
- name: "token",
9399
- autoComplete: "off",
9400
- spellCheck: false,
9401
- required: true
9402
- })]
9403
- }),
9404
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
9405
- className: "factory-sheet-actions",
9406
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
9407
- type: "submit",
9408
- disabled: save.isPending,
9409
- children: "Save"
9410
- })
9411
- }),
9412
- save.error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
9413
- className: "factory-problems",
9414
- role: "alert",
9415
- children: save.error.message
9416
- }) : null
9417
- ]
9418
- });
9419
- }
9420
9186
  // src/shell/add-companion-dialog.tsx
9421
9187
  var MODES = [{
9422
9188
  mode: "url",
9423
9189
  label: "Git URL",
9424
9190
  field: "Git URL of the companion",
9425
9191
  placeholder: "https://git.acme.test/acme/companion.git",
9426
- hint: "The factory clones it into its companions directory. A private repository asks for a Git token."
9192
+ hint: "The service that adds companions clones it into its own folder. A private repository needs a Git token."
9427
9193
  }, {
9428
9194
  mode: "path",
9429
9195
  label: "Local path",
@@ -9431,7 +9197,7 @@ var MODES = [{
9431
9197
  placeholder: "/srv/acme-companion",
9432
9198
  hint: "Registered where it is, on the machine Studio runs on. Nothing is copied."
9433
9199
  }];
9434
- /** Adds a companion by Git URL or local path; opens the token form when a private clone is refused. */
9200
+ /** Adds a companion by Git URL or local path; names the Git token a refused private clone needs. */
9435
9201
  function AddCompanionDialog({ open, onClose, onAdded }) {
9436
9202
  const [mode, setMode] = (0, import_react.useState)("url");
9437
9203
  const [value, setValue] = (0, import_react.useState)("");
@@ -9539,24 +9305,229 @@ function AddCompanionDialog({ open, onClose, onAdded }) {
9539
9305
  })
9540
9306
  ]
9541
9307
  }),
9542
- refusal?.tokenKey ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
9543
- className: "grid gap-2 border-t border-rule pt-3",
9308
+ refusal?.tokenKey ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
9309
+ className: "m-0 border-t border-rule pt-3 text-sm text-muted",
9544
9310
  "data-add-companion-token": "",
9545
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
9546
- className: "m-0 text-sm text-muted",
9547
- children: "Set a Git token for this host, then add the companion again."
9548
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GitTokenForm, {
9549
- defaultKey: refusal.tokenKey,
9550
- onSaved: () => {
9551
- setRefusal(null);
9552
- add.mutate();
9553
- }
9554
- })]
9311
+ children: [
9312
+ "Set a Git token for ",
9313
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", {
9314
+ className: "font-mono",
9315
+ children: refusal.tokenKey
9316
+ }),
9317
+ " where the service keeps its Git tokens, then add the companion again."
9318
+ ]
9555
9319
  }) : null
9556
9320
  ]
9557
9321
  })
9558
9322
  });
9559
9323
  }
9324
+ // src/components/friction-recording.tsx
9325
+ var REACH = "friction-recording-reach";
9326
+ function RecordingState({ recording }) {
9327
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(StatusWord, {
9328
+ marker: recording ? "build" : "idle",
9329
+ children: ["Recording is ", recording ? "on" : "off"]
9330
+ });
9331
+ }
9332
+ function RecordingReach() {
9333
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
9334
+ id: REACH,
9335
+ className: "m-0 text-xs text-muted",
9336
+ children: "Applies to all companions on the machine that runs Studio."
9337
+ });
9338
+ }
9339
+ /** With `recording` unknown, the button is disabled and claims neither state. */
9340
+ function RecordingButton({ recording, toggle, ref }) {
9341
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
9342
+ ref,
9343
+ size: "sm",
9344
+ variant: recording === false ? "primary" : "default",
9345
+ disabled: recording === void 0 || toggle.pending,
9346
+ "aria-describedby": REACH,
9347
+ onClick: () => toggle.onChange(!recording),
9348
+ children: recording === void 0 ? "Turn recording on or off" : `Turn recording ${recording ? "off" : "on"}`
9349
+ });
9350
+ }
9351
+ // src/server/friction.ts
9352
+ function validateFrictionInput(input) {
9353
+ if (typeof input?.companion !== "string" || !COMPANION_DIGEST_PATTERN.test(input.companion)) throw new Error("No registered companion was selected");
9354
+ const days = frictionViewDays(input.days);
9355
+ if (!days) throw new Error(`The friction period is one of ${FRICTION_VIEW_DAYS.join(", ")} days`);
9356
+ return {
9357
+ companion: input.companion,
9358
+ days
9359
+ };
9360
+ }
9361
+ function validateRecordingInput(input) {
9362
+ if (typeof input?.recording !== "boolean") throw new Error("Recording is on or off");
9363
+ return { recording: input.recording };
9364
+ }
9365
+ var getFriction = createServerFn({ method: "GET" }).validator(validateFrictionInput).handler(createSsrRpc("3d0d77471aa778cecabd4e5db91ab864e236510fba212a7e364cf9ee35750729"));
9366
+ var getFrictionRecording = createServerFn({ method: "GET" }).handler(createSsrRpc("f1599335a08f9f65c30311d4e51c4cfad933345d616c61c8945d5183444c2503"));
9367
+ var setFrictionRecording = createServerFn({ method: "POST" }).validator(validateRecordingInput).handler(createSsrRpc("129eb7026f249381cdf25972dd63a821750853b2ea77ea3a1fdd22b56f1b24ec"));
9368
+ var optionalText = (value, name) => {
9369
+ if (value === void 0) return void 0;
9370
+ if (typeof value !== "string") throw new Error(`The ${name} is text`);
9371
+ return value;
9372
+ };
9373
+ function validateMarkInput(input) {
9374
+ if (typeof input?.target !== "string" || input.target === "") throw new Error("A mark names a fingerprint or a report");
9375
+ const state = oneOf(MARK_STATES, input.state);
9376
+ if (!state) throw new Error(`A mark sets one of ${MARK_STATES.join(", ")}`);
9377
+ return {
9378
+ target: input.target,
9379
+ state,
9380
+ note: optionalText(input.note, "note"),
9381
+ link: optionalText(input.link, "link")
9382
+ };
9383
+ }
9384
+ var markFriction = createServerFn({ method: "POST" }).validator(validateMarkInput).handler(createSsrRpc("e257827a07a72fbb27ff303a6d721f51ae699f21ddaaa8fb7b1f33203d573c56"));
9385
+ // src/lib/friction-query.ts
9386
+ var SCOPE$1 = "friction";
9387
+ var MACHINE_WIDE = "machine";
9388
+ var frictionKey = (owner, ...rest) => [
9389
+ owner,
9390
+ SCOPE$1,
9391
+ ...rest
9392
+ ];
9393
+ var isFrictionQuery = ({ queryKey: [, scope] }) => scope === SCOPE$1;
9394
+ var frictionQuery = (companion, days) => queryOptions({
9395
+ queryKey: frictionKey(companion, days),
9396
+ queryFn: () => getFriction({ data: {
9397
+ companion,
9398
+ days
9399
+ } }),
9400
+ retry: false,
9401
+ refetchOnWindowFocus: false
9402
+ });
9403
+ var frictionRecordingQuery = queryOptions({
9404
+ queryKey: frictionKey(MACHINE_WIDE, "recording"),
9405
+ queryFn: () => getFrictionRecording(),
9406
+ retry: false,
9407
+ refetchOnWindowFocus: false
9408
+ });
9409
+ var RECORDING_CHANGE = [SCOPE$1, "set-recording"];
9410
+ function useSetFrictionRecording() {
9411
+ const client = useQueryClient();
9412
+ const pending = useIsMutating({ mutationKey: RECORDING_CHANGE }) > 0;
9413
+ const change = useMutation({
9414
+ mutationKey: RECORDING_CHANGE,
9415
+ mutationFn: (recording) => setFrictionRecording({ data: { recording } }),
9416
+ onSuccess: async ({ recording }) => {
9417
+ await client.cancelQueries({ predicate: isFrictionQuery });
9418
+ client.setQueriesData({ predicate: isFrictionQuery }, (held) => held && {
9419
+ ...held,
9420
+ recording
9421
+ });
9422
+ return client.invalidateQueries({ predicate: isFrictionQuery });
9423
+ }
9424
+ });
9425
+ return {
9426
+ pending,
9427
+ error: change.isError ? `Recording could not be turned ${change.variables ? "on" : "off"}: ${change.error.message}` : void 0,
9428
+ onChange: (recording) => change.mutate(recording)
9429
+ };
9430
+ }
9431
+ function useMarkFriction() {
9432
+ const client = useQueryClient();
9433
+ return useMutation({
9434
+ mutationKey: [SCOPE$1, "mark"],
9435
+ mutationFn: (mark) => markFriction({ data: mark }),
9436
+ onSuccess: async (result) => {
9437
+ if (!result.ok) return;
9438
+ await client.cancelQueries({ predicate: isFrictionQuery });
9439
+ await client.invalidateQueries({ predicate: isFrictionQuery });
9440
+ }
9441
+ }).mutateAsync;
9442
+ }
9443
+ // src/lib/use-retry-focus.ts
9444
+ /**
9445
+ * A successful Retry removes itself; focus then goes to `target`, or without one to the control
9446
+ * `button` points at.
9447
+ */
9448
+ function useRetryFocus(isSuccess, target) {
9449
+ const button = (0, import_react.useRef)(null);
9450
+ const retried = (0, import_react.useRef)(false);
9451
+ (0, import_react.useEffect)(() => {
9452
+ if (!isSuccess || !retried.current) return;
9453
+ retried.current = false;
9454
+ (target ?? button).current?.focus();
9455
+ }, [isSuccess, target]);
9456
+ return {
9457
+ button,
9458
+ retried: () => {
9459
+ retried.current = true;
9460
+ }
9461
+ };
9462
+ }
9463
+ // src/lib/use-browser.ts
9464
+ var subscribe$1 = () => () => {};
9465
+ /**
9466
+ * `true` once the page runs in the browser. Queries the shell starts only for counts wait for
9467
+ * it, so the server-rendered document never holds its stream open for them.
9468
+ */
9469
+ function useBrowser() {
9470
+ return (0, import_react.useSyncExternalStore)(subscribe$1, () => true, () => false);
9471
+ }
9472
+ // src/shell/global-features.tsx
9473
+ function RecordingRow({ status, note, action }) {
9474
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
9475
+ className: "flex flex-wrap items-center justify-between gap-x-4 gap-y-2 px-4 py-3",
9476
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
9477
+ className: "grid min-w-0 flex-[1_1_16rem] gap-0.5",
9478
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
9479
+ className: "flex flex-wrap items-center gap-x-3 gap-y-0.5",
9480
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", {
9481
+ className: "text-sm font-semibold",
9482
+ children: "Friction recording"
9483
+ }), status]
9484
+ }), note]
9485
+ }), action]
9486
+ });
9487
+ }
9488
+ function GlobalFeatures() {
9489
+ const query = useQuery({
9490
+ ...frictionRecordingQuery,
9491
+ enabled: useBrowser()
9492
+ });
9493
+ const toggle = useSetFrictionRecording();
9494
+ const { button: recordingButton, retried } = useRetryFocus(query.isSuccess);
9495
+ const recording = query.data?.recording;
9496
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ListCard, {
9497
+ title: "Global features",
9498
+ children: [query.isError ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RecordingRow, {
9499
+ note: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
9500
+ className: "m-0 text-xs text-bad",
9501
+ role: "alert",
9502
+ children: "The recording state could not be read."
9503
+ }),
9504
+ action: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
9505
+ size: "sm",
9506
+ disabled: query.isFetching,
9507
+ onClick: () => {
9508
+ retried();
9509
+ query.refetch();
9510
+ },
9511
+ children: "Retry"
9512
+ })
9513
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RecordingRow, {
9514
+ status: recording === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
9515
+ className: "text-xs text-muted",
9516
+ children: "Checking…"
9517
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RecordingState, { recording }),
9518
+ note: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RecordingReach, {}),
9519
+ action: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RecordingButton, {
9520
+ ref: recordingButton,
9521
+ recording,
9522
+ toggle
9523
+ })
9524
+ }), toggle.error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
9525
+ className: "m-0 border-t border-rule-soft px-4 py-2 text-sm wrap-anywhere text-bad",
9526
+ role: "alert",
9527
+ children: toggle.error
9528
+ }) : null]
9529
+ });
9530
+ }
9560
9531
  // src/shell/companion-picker.tsx
9561
9532
  var svgUri = (svg) => `data:image/svg+xml;base64,${btoa(svg)}`;
9562
9533
  var SYMBOL_COLOR_URI = svgUri(BRAND_SVGS.symbolColor);
@@ -9837,7 +9808,7 @@ function CompanionRow({ companion, selected, onChoose, writable, onDelete, onInt
9837
9808
  });
9838
9809
  }
9839
9810
  /** The top bar's brand mark: names the selected companion and switches to another. */
9840
- function CompanionSwitcher({ companions, selected, writable = false, factoryMode = false }) {
9811
+ function CompanionSwitcher({ companions, selected, writable = false, addsCompanions = false }) {
9841
9812
  const [open, setOpen] = (0, import_react.useState)(false);
9842
9813
  const select = useSelectCompanion();
9843
9814
  const prefetch = usePrefetchCompanion();
@@ -9894,7 +9865,7 @@ function CompanionSwitcher({ companions, selected, writable = false, factoryMode
9894
9865
  children: "No Companion Repository is registered."
9895
9866
  }) : null,
9896
9867
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Separator, { className: "my-1" }),
9897
- factoryMode && writable ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
9868
+ addsCompanions && writable ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
9898
9869
  type: "button",
9899
9870
  className: "flex items-center gap-2.5 rounded-control border-0 bg-transparent px-2.5 py-2 text-left text-sm text-text hover:bg-surface-soft",
9900
9871
  "data-add-companion": "",
@@ -9923,63 +9894,95 @@ function CompanionSwitcher({ companions, selected, writable = false, factoryMode
9923
9894
  })]
9924
9895
  }),
9925
9896
  deletion.dialog,
9926
- factoryMode && writable ? adding.dialog : null
9897
+ addsCompanions && writable ? adding.dialog : null
9927
9898
  ] });
9928
9899
  }
9929
- /** The page while no companion is selected: every registered companion, and how to add one. */
9930
- function CompanionPicker({ companions, writable = false, factoryMode = false }) {
9900
+ function CompanionPicker({ companions, writable = false, addsCompanions = false }) {
9931
9901
  const select = useSelectCompanion();
9932
9902
  const prefetch = usePrefetchCompanion();
9933
9903
  const deletion = useCompanionDeletion(null);
9934
9904
  const adding = useCompanionAdd();
9935
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
9936
- className: "mx-auto grid w-full max-w-[760px] gap-5 px-8 py-16 max-sm:px-4",
9937
- "aria-label": "Companion Repositories",
9938
- children: [
9939
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
9940
- className: "grid gap-1.5",
9941
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", {
9942
- className: "m-0 text-[1.7rem] font-semibold tracking-[-0.02em]",
9943
- children: companions.length === 0 ? "No Companion Repository" : "Choose a Companion Repository"
9944
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
9945
- className: "m-0 text-muted",
9946
- children: companions.length === 0 ? "No Companion Repository is registered on this machine." : "Studio serves one companion at a time, and remembers the one you choose for your next visit."
9947
- })]
9948
- }),
9949
- companions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
9950
- className: "overflow-hidden rounded-card border border-rule",
9951
- children: companions.map((companion) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CompanionRow, {
9952
- companion,
9953
- selected: false,
9954
- roomy: true,
9955
- onChoose: () => select(companion.digest),
9956
- onIntent: () => prefetch(companion.digest),
9957
- writable,
9958
- onDelete: () => deletion.ask(companion)
9959
- }, companion.digest))
9960
- }) : null,
9961
- factoryMode && writable ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
9962
- type: "button",
9963
- "data-add-companion": "",
9964
- onClick: adding.ask,
9965
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { name: "plus" }), "Add companion…"]
9966
- }) }) : null,
9967
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
9968
- className: "m-0 text-sm text-muted",
9969
- children: [
9970
- "To add one, run",
9971
- " ",
9972
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", {
9973
- className: "rounded-[6px] border border-rule bg-surface px-1.5 font-mono text-xs",
9974
- children: "mate companion setup"
9975
- }),
9976
- " ",
9977
- "in a Working Repository."
9978
- ]
9979
- }),
9980
- deletion.dialog,
9981
- factoryMode && writable ? adding.dialog : null
9982
- ]
9905
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
9906
+ className: "mx-auto grid w-full max-w-[760px] gap-8 px-8 py-16 max-sm:px-4",
9907
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(GlobalFeatures, {}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
9908
+ className: "grid gap-5",
9909
+ "aria-label": "Companion Repositories",
9910
+ children: [
9911
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
9912
+ className: "grid gap-1.5",
9913
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", {
9914
+ className: "m-0 text-[1.7rem] font-semibold tracking-[-0.02em]",
9915
+ children: companions.length === 0 ? "No Companion Repository" : "Choose a Companion Repository"
9916
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
9917
+ className: "m-0 text-muted",
9918
+ children: companions.length === 0 ? "No Companion Repository is registered on this machine." : "Studio serves one companion at a time, and remembers the one you choose for your next visit."
9919
+ })]
9920
+ }),
9921
+ companions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
9922
+ className: "overflow-hidden rounded-card border border-rule",
9923
+ children: companions.map((companion) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CompanionRow, {
9924
+ companion,
9925
+ selected: false,
9926
+ roomy: true,
9927
+ onChoose: () => select(companion.digest),
9928
+ onIntent: () => prefetch(companion.digest),
9929
+ writable,
9930
+ onDelete: () => deletion.ask(companion)
9931
+ }, companion.digest))
9932
+ }) : null,
9933
+ addsCompanions && writable ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
9934
+ type: "button",
9935
+ "data-add-companion": "",
9936
+ onClick: adding.ask,
9937
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { name: "plus" }), "Add companion…"]
9938
+ }) }) : null,
9939
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
9940
+ className: "m-0 text-sm text-muted",
9941
+ children: [
9942
+ "To add one, run",
9943
+ " ",
9944
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", {
9945
+ className: "rounded-[6px] border border-rule bg-surface px-1.5 font-mono text-xs",
9946
+ children: "mate companion setup"
9947
+ }),
9948
+ " ",
9949
+ "in a Working Repository."
9950
+ ]
9951
+ }),
9952
+ deletion.dialog,
9953
+ addsCompanions && writable ? adding.dialog : null
9954
+ ]
9955
+ })]
9956
+ });
9957
+ }
9958
+ // src/shell/connection-banner.tsx
9959
+ var MESSAGES = {
9960
+ offline: "Connection to Studio lost",
9961
+ "signed-out": "Connection to Studio lost — reload to sign in again",
9962
+ expired: "Session expired — open the address Studio printed when it started",
9963
+ "host-refused": "Studio does not answer to this host"
9964
+ };
9965
+ var reloadPage = () => location.reload();
9966
+ /**
9967
+ * Above the view while the page has lost Studio; the view and its data stay. Reloading is the
9968
+ * person's choice, so an unsaved edit is never lost to it.
9969
+ */
9970
+ function ConnectionBanner({ reload = reloadPage }) {
9971
+ const state = useConnectionState((current) => current.state);
9972
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
9973
+ role: "status",
9974
+ "aria-live": "polite",
9975
+ children: state === "online" ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
9976
+ className: "mx-8 mt-3 flex items-center gap-3 rounded-card border border-warn bg-warn-soft px-4 py-2.5 text-sm max-sm:mx-4",
9977
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
9978
+ className: "flex-1",
9979
+ children: MESSAGES[state]
9980
+ }), state === "host-refused" ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
9981
+ size: "sm",
9982
+ onClick: reload,
9983
+ children: "Reload"
9984
+ })]
9985
+ })
9983
9986
  });
9984
9987
  }
9985
9988
  // src/shell/navigation-progress.tsx
@@ -10013,244 +10016,6 @@ function ViewPlaceholder() {
10013
10016
  ]
10014
10017
  });
10015
10018
  }
10016
- // src/lib/use-browser.ts
10017
- var subscribe$1 = () => () => {};
10018
- /**
10019
- * `true` once the page runs in the browser. Queries the shell starts only for counts wait for
10020
- * it, so the server-rendered document never holds its stream open for them.
10021
- */
10022
- function useBrowser() {
10023
- return (0, import_react.useSyncExternalStore)(subscribe$1, () => true, () => false);
10024
- }
10025
- // src/views/factory/outcome.ts
10026
- var ACTIVE = /* @__PURE__ */ new Set(["queued", "running"]);
10027
- /** Why an Outcome waits on a person, or `null` when it does not. */
10028
- function attentionKind(workset, run) {
10029
- if (workset.stage === "done") return null;
10030
- if (run?.control?.mode === "manual") return "control";
10031
- if (run?.state === "waiting") return "decision";
10032
- if (run?.state === "failed" || run?.state === "interrupted") return "problem";
10033
- if (run && ACTIVE.has(run.state)) return null;
10034
- if (workset.stage === "human-review") return "review";
10035
- if (workset.stage === "merge-wait") return "merge";
10036
- if (workset.stage === "publish") return "publish";
10037
- return null;
10038
- }
10039
- function byId(a, b) {
10040
- return a.workset.id < b.workset.id ? -1 : a.workset.id > b.workset.id ? 1 : 0;
10041
- }
10042
- /** When an Outcome started waiting, as far as Studio knows; unknown sorts last. */
10043
- function waitingSince(item) {
10044
- const parsed = Date.parse(item.run?.updatedAt || item.workset.queuedAt || "");
10045
- return Number.isNaN(parsed) ? Number.POSITIVE_INFINITY : parsed;
10046
- }
10047
- function itemsOf(worksets, runs) {
10048
- return worksets.map((workset) => ({
10049
- workset,
10050
- run: runs?.[workset.id]
10051
- }));
10052
- }
10053
- function rankCompare(a, b) {
10054
- return compareRanked({
10055
- id: a.workset.id,
10056
- rank: rankOf(a.workset)
10057
- }, {
10058
- id: b.workset.id,
10059
- rank: rankOf(b.workset)
10060
- });
10061
- }
10062
- /** When an Outcome last changed, newest-first ordering for the history. */
10063
- function lastChange(item) {
10064
- const stamps = [
10065
- item.run?.situations?.[0]?.at,
10066
- item.run?.updatedAt,
10067
- item.workset.queuedAt
10068
- ];
10069
- return Math.max(0, ...stamps.map((stamp) => Date.parse(stamp ?? "")).filter(Number.isFinite));
10070
- }
10071
- /** A Later Outcome that already has a plan, or a run, is under way all the same. */
10072
- function underWay(item) {
10073
- return item.workset.queuedAt !== void 0 || item.workset.changes.length > 0 || item.run !== void 0 && item.run.state !== "idle";
10074
- }
10075
- /** Every Outcome where the home shows it; the view lists one that needs the person only there. */
10076
- function factoryHome(worksets, runs) {
10077
- const items = itemsOf(worksets, runs);
10078
- const attention = items.flatMap((item) => {
10079
- const kind = attentionKind(item.workset, item.run);
10080
- return kind ? [{
10081
- ...item,
10082
- kind
10083
- }] : [];
10084
- }).toSorted((a, b) => waitingSince(a) - waitingSince(b) || byId(a, b));
10085
- const open = items.filter((item) => item.workset.stage !== "done");
10086
- return {
10087
- attention,
10088
- active: open.filter(underWay).toSorted(rankCompare),
10089
- later: open.filter((item) => !underWay(item)).toSorted(byId),
10090
- completed: items.filter((item) => item.workset.stage === "done").toSorted((a, b) => lastChange(b) - lastChange(a) || byId(a, b))
10091
- };
10092
- }
10093
- /** Each milestone is reached once the Outcome's stage is past the one named. */
10094
- var MILESTONES = [
10095
- {
10096
- label: "Understood",
10097
- after: "clarify-intent",
10098
- next: "The factory is working out what you want"
10099
- },
10100
- {
10101
- label: "Approach chosen",
10102
- after: "explore",
10103
- next: "The factory is choosing the approach"
10104
- },
10105
- {
10106
- label: "Plan ready",
10107
- after: "propose",
10108
- next: "The factory is writing the plan"
10109
- },
10110
- {
10111
- label: "Plan approved",
10112
- after: "human-review",
10113
- next: "Ready for your review"
10114
- },
10115
- {
10116
- label: "Built",
10117
- after: "apply",
10118
- next: "The factory is building it"
10119
- },
10120
- {
10121
- label: "Merged",
10122
- after: "merge-wait",
10123
- next: "Ready for you to merge"
10124
- },
10125
- {
10126
- label: "Delivered",
10127
- after: "publish",
10128
- next: "Ready to publish"
10129
- }
10130
- ];
10131
- function stageIndex(stage) {
10132
- return WORKSET_STAGE_ORDER.indexOf(stage);
10133
- }
10134
- function milestonesOf(workset) {
10135
- const at = stageIndex(workset.stage);
10136
- return MILESTONES.map((milestone) => ({
10137
- label: milestone.label,
10138
- reached: at > stageIndex(milestone.after)
10139
- }));
10140
- }
10141
- function savedForLater(workset, run) {
10142
- return !workset.queuedAt && workset.changes.length === 0 && (!run || run.state === "idle");
10143
- }
10144
- /** The next meaningful step, phrased by who acts next. */
10145
- function nextStepOf(workset, run) {
10146
- if (workset.stage === "done") return "Delivered";
10147
- if (run?.control?.mode === "manual") return "You have control";
10148
- if (run?.state === "waiting") return "Waiting for your answer";
10149
- if (run?.state === "failed" || run?.state === "interrupted") return "Stopped; needs you";
10150
- if (savedForLater(workset, run)) return "Saved for later";
10151
- const at = stageIndex(workset.stage);
10152
- return MILESTONES.find((milestone) => at <= stageIndex(milestone.after))?.next ?? "Delivered";
10153
- }
10154
- var DERIVED = {
10155
- "clarify-intent": "Understanding what you want.",
10156
- explore: "Working out the approach.",
10157
- propose: "Writing the plan.",
10158
- "human-review": "A plan is ready for your review.",
10159
- apply: "Building it.",
10160
- "merge-wait": "Built; waiting for the merge.",
10161
- publish: "Merged; ready to publish.",
10162
- done: "Delivered."
10163
- };
10164
- /** A sentence from the stage, for an Outcome the agent has not reported on. */
10165
- function derivedSituation(workset, run) {
10166
- if (run?.state === "queued") {
10167
- if (run.waiting === "workset-slot") return "Waiting for a Workset slot.";
10168
- if (run.waiting === "build-slot") return "Waiting for a build slot.";
10169
- return "Waiting for a free slot.";
10170
- }
10171
- if (run?.state === "failed") return `Stopped: ${run.reason}`;
10172
- if (run?.state === "interrupted") return "Stopped when Studio restarted.";
10173
- if (run?.state === "waiting") return "Waiting for your answer.";
10174
- if (savedForLater(workset, run)) return "Saved for later.";
10175
- return DERIVED[workset.stage] ?? workset.stageLabel;
10176
- }
10177
- /** Run states that say more than the last report; queued, waiting, failed and interrupted. */
10178
- var OVERRIDING = /* @__PURE__ */ new Set([
10179
- "queued",
10180
- "waiting",
10181
- "failed",
10182
- "interrupted"
10183
- ]);
10184
- /** The latest reported situation, or a derived one without a time. */
10185
- function situationOf(workset, run) {
10186
- const reported = run?.situations?.[0];
10187
- if (reported && !(run && OVERRIDING.has(run.state))) return reported;
10188
- return { text: derivedSituation(workset, run) };
10189
- }
10190
- /** The Delivery Path as the panel's strip shows it; clarify and explore are one step. */
10191
- var PATH_STEPS = [
10192
- "Understand",
10193
- "Propose change",
10194
- "Human review",
10195
- "Apply change",
10196
- "Merge",
10197
- "Publish"
10198
- ];
10199
- var STEP_OF_STAGE = {
10200
- "clarify-intent": 0,
10201
- explore: 0,
10202
- propose: 1,
10203
- "human-review": 2,
10204
- apply: 3,
10205
- "merge-wait": 4,
10206
- publish: 5,
10207
- done: PATH_STEPS.length
10208
- };
10209
- /** Where an Outcome is on the strip, and the colour its current step takes. */
10210
- function pathPositionOf(workset, run) {
10211
- const activity = activityOf(workset, run);
10212
- const current = activity === "later" ? -1 : STEP_OF_STAGE[workset.stage];
10213
- switch (activity) {
10214
- case "control": return {
10215
- current,
10216
- tone: "why"
10217
- };
10218
- case "stopped": return {
10219
- current,
10220
- tone: "bad"
10221
- };
10222
- case "needs-you": return {
10223
- current,
10224
- tone: attentionKind(workset, run) === "review" ? "why" : "warn"
10225
- };
10226
- default: return {
10227
- current,
10228
- tone: "accent"
10229
- };
10230
- }
10231
- }
10232
- var ACTIVITY_LABELS = {
10233
- running: "Running",
10234
- queued: "Queued",
10235
- "needs-you": "Needs you",
10236
- control: "You have control",
10237
- stopped: "Stopped",
10238
- idle: "Idle",
10239
- later: "Saved for later",
10240
- done: "Delivered"
10241
- };
10242
- function activityOf(workset, run) {
10243
- if (workset.stage === "done") return "done";
10244
- if (run?.control?.mode === "manual") return "control";
10245
- if (run?.state === "failed" || run?.state === "interrupted") return "stopped";
10246
- if (run?.state === "running") return "running";
10247
- if (run?.state === "queued") return "queued";
10248
- if (attentionKind(workset, run)) return "needs-you";
10249
- return underWay({
10250
- workset,
10251
- run
10252
- }) ? "idle" : "later";
10253
- }
10254
10019
  // src/shell/sidebar.tsx
10255
10020
  var MODE_ICONS = {
10256
10021
  engineering: "code",
@@ -10263,13 +10028,8 @@ function useNeedsYou(shell, search) {
10263
10028
  ...companionViewQuery("dashboard", search),
10264
10029
  enabled: engineering
10265
10030
  });
10266
- const factory = useQuery({
10267
- ...factoryQuery(shell.selected?.digest ?? ""),
10268
- enabled: engineering && shell.factoryMode
10269
- });
10270
10031
  const counts = {};
10271
10032
  if (overview.data?.changes) counts.dashboard = groupChanges(overview.data.changes)["needs-you"].length;
10272
- if (factory.data?.payload) counts.factory = factoryHome(factory.data.payload.worksets, factory.data.runs).attention.length;
10273
10033
  return counts;
10274
10034
  }
10275
10035
  function Sidebar({ shell, search, view }) {
@@ -10285,7 +10045,7 @@ function Sidebar({ shell, search, view }) {
10285
10045
  children: [shell.selected ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
10286
10046
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NavGroup, {
10287
10047
  label: MODE_TITLES[mode],
10288
- views: modeViews(mode, shell.factoryMode),
10048
+ views: modeViews(mode),
10289
10049
  search,
10290
10050
  current: view,
10291
10051
  counts,
@@ -10306,6 +10066,11 @@ function Sidebar({ shell, search, view }) {
10306
10066
  current: view,
10307
10067
  counts,
10308
10068
  collapsed
10069
+ }),
10070
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PluginNavGroup, {
10071
+ shell,
10072
+ search,
10073
+ collapsed
10309
10074
  })
10310
10075
  ] }) : null, /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
10311
10076
  className: "sidebar-footer mt-auto grid gap-1 border-t border-rule-soft pt-2 max-[900px]:mt-0 max-[900px]:ml-auto max-[900px]:flex max-[900px]:border-0 max-[900px]:pt-0",
@@ -10360,6 +10125,81 @@ function NavGroup(props) {
10360
10125
  }, view))]
10361
10126
  });
10362
10127
  }
10128
+ /** Views plugin services ship as their own modules. */
10129
+ function PluginNavGroup({ shell, search, collapsed }) {
10130
+ if (shell.pluginViews.length === 0) return null;
10131
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PluginNavLinks, {
10132
+ shell,
10133
+ search,
10134
+ collapsed
10135
+ });
10136
+ }
10137
+ function PluginNavLinks({ shell, search, collapsed }) {
10138
+ const params = useParams({ strict: false });
10139
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
10140
+ className: "grid gap-px max-[900px]:flex max-[900px]:min-w-0 max-[900px]:max-w-full max-[900px]:flex-wrap max-[900px]:items-center",
10141
+ role: "group",
10142
+ "aria-label": "Services",
10143
+ "data-studio-nav-section": "Services",
10144
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", {
10145
+ className: "m-0 px-2.5 pt-3.5 pb-1.5 text-[0.68rem] leading-none font-semibold text-muted first:pt-1.5 rail-min:mx-2 rail-min:my-2.5 rail-min:h-px rail-min:overflow-hidden rail-min:bg-rule-soft rail-min:p-0 rail-min:text-[0px] max-[900px]:sr-only",
10146
+ "aria-hidden": "true",
10147
+ children: "Services"
10148
+ }), shell.pluginViews.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PluginNavLink, {
10149
+ entry,
10150
+ companion: shell.selected?.digest ?? null,
10151
+ search,
10152
+ current: params.service === entry.service && params.view === entry.view,
10153
+ collapsed
10154
+ }, `${entry.service}/${entry.view}`))]
10155
+ });
10156
+ }
10157
+ /** How many things a plugin view says wait on the person; asked in the browser only. */
10158
+ function usePluginAttention(entry, companion) {
10159
+ const browser = useBrowser();
10160
+ return useQuery({
10161
+ ...pluginAttentionQuery(companion ?? "", entry.attentionUrl ?? ""),
10162
+ enabled: browser && companion !== null && entry.attentionUrl !== void 0
10163
+ }).data;
10164
+ }
10165
+ function PluginNavLink({ entry, companion, search, current, collapsed }) {
10166
+ const count = usePluginAttention(entry, companion);
10167
+ const needs = count !== void 0 && count > 0;
10168
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip, {
10169
+ label: entry.label,
10170
+ disabled: !collapsed,
10171
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Link, {
10172
+ to: "/plugins/$service/$view",
10173
+ params: {
10174
+ service: entry.service,
10175
+ view: entry.view
10176
+ },
10177
+ search,
10178
+ className: cn("sidebar-nav-link relative flex h-8 items-center gap-2.5 rounded-[6px] px-2.5 text-sm whitespace-nowrap text-[color-mix(in_srgb,var(--text)_82%,var(--muted))] no-underline hover:bg-surface hover:text-text rail-min:justify-center rail-min:px-0", current && "bg-surface font-semibold text-text ring-1 ring-rule ring-inset"),
10179
+ "aria-current": current ? "page" : void 0,
10180
+ "aria-label": collapsed ? needs ? `${entry.label}, ${count} need you` : entry.label : void 0,
10181
+ children: [
10182
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, {
10183
+ name: "spark",
10184
+ className: current ? "text-accent" : "text-muted"
10185
+ }),
10186
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
10187
+ className: "truncate rail-min:hidden",
10188
+ children: entry.label
10189
+ }),
10190
+ needs ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NeedsYouCount, { count }) : null
10191
+ ]
10192
+ })
10193
+ });
10194
+ }
10195
+ function NeedsYouCount({ count }) {
10196
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Count, {
10197
+ value: count,
10198
+ tone: "warn",
10199
+ className: "ml-auto rail-min:absolute rail-min:top-1 rail-min:right-1.5 rail-min:size-[7px] rail-min:min-w-0 rail-min:bg-warn rail-min:p-0 rail-min:text-[0px]",
10200
+ label: `${count} need you`
10201
+ });
10202
+ }
10363
10203
  function NavLink({ view, search, current, count, collapsed }) {
10364
10204
  const title = VIEW_TITLES[view];
10365
10205
  const needs = count !== void 0 && count > 0;
@@ -10383,12 +10223,7 @@ function NavLink({ view, search, current, count, collapsed }) {
10383
10223
  children: title
10384
10224
  }),
10385
10225
  view === "reports" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportsBadge, {}) : null,
10386
- needs ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Count, {
10387
- value: count,
10388
- tone: "warn",
10389
- className: "ml-auto rail-min:absolute rail-min:top-1 rail-min:right-1.5 rail-min:size-[7px] rail-min:min-w-0 rail-min:bg-warn rail-min:p-0 rail-min:text-[0px]",
10390
- label: `${count} need you`
10391
- }) : null
10226
+ needs ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NeedsYouCount, { count }) : null
10392
10227
  ]
10393
10228
  })
10394
10229
  });
@@ -10495,7 +10330,7 @@ function TopBar({ shell, search }) {
10495
10330
  companions: shell.companions,
10496
10331
  selected: shell.selected,
10497
10332
  writable: shell.writable,
10498
- factoryMode: shell.factoryMode
10333
+ addsCompanions: shell.addsCompanions
10499
10334
  }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
10500
10335
  className: "ml-auto flex min-w-0 flex-[0_1_auto] items-center justify-end gap-1.5",
10501
10336
  children: [
@@ -10733,7 +10568,7 @@ var TerminalClient = class {
10733
10568
  this.events.reconnectable(false);
10734
10569
  const ws = openTerminalSocket();
10735
10570
  this.ws = ws;
10736
- ws.onopen = () => {
10571
+ ws.addEventListener("open", () => {
10737
10572
  this.attempts = 0;
10738
10573
  this.events.state("connected");
10739
10574
  this.events.status("Connected.");
@@ -10744,9 +10579,9 @@ var TerminalClient = class {
10744
10579
  const session = storedSession();
10745
10580
  if (session) this.attach(session);
10746
10581
  }
10747
- };
10748
- ws.onmessage = (event) => this.receive(event.data);
10749
- ws.onclose = () => {
10582
+ });
10583
+ ws.addEventListener("message", (event) => this.receive(event.data));
10584
+ ws.addEventListener("close", () => {
10750
10585
  this.ws = null;
10751
10586
  if (this.takenOver || this.destroyed) return;
10752
10587
  if (this.attempts >= MAX_ATTEMPTS) {
@@ -10760,7 +10595,7 @@ var TerminalClient = class {
10760
10595
  this.events.state("reconnecting");
10761
10596
  this.events.status(`Reconnecting (attempt ${this.attempts} of ${MAX_ATTEMPTS})…`);
10762
10597
  this.retry = setTimeout(() => this.connect(), delay);
10763
- };
10598
+ });
10764
10599
  }
10765
10600
  receive(data) {
10766
10601
  if (typeof data !== "string") {
@@ -10816,7 +10651,7 @@ var TerminalClient = class {
10816
10651
  ...task
10817
10652
  });
10818
10653
  }
10819
- /** A Factory Outcome names only its Workset; the server resolves everything else. */
10654
+ /** A Workset session names only its Workset; the server resolves everything else. */
10820
10655
  startWorkset(workset) {
10821
10656
  this.sendOrQueue({
10822
10657
  type: "start",
@@ -10889,7 +10724,7 @@ function useTerminalSessions() {
10889
10724
  const sessions = useQuery({
10890
10725
  queryKey: sessionsKey,
10891
10726
  queryFn: async () => {
10892
- const response = await fetch(TERMINAL_SESSIONS_ROUTE, { credentials: "same-origin" });
10727
+ const response = await studioFetch(TERMINAL_SESSIONS_ROUTE);
10893
10728
  return response.ok ? (await response.json()).sessions : [];
10894
10729
  },
10895
10730
  refetchInterval: 5e3
@@ -10994,12 +10829,13 @@ function useTerminalClient(mount, companion) {
10994
10829
  * A direct grid child of `.shell`: sticky positioning breaks under an ancestor that sets
10995
10830
  * `overflow`. Lives in the root layout, so its session survives navigation between views.
10996
10831
  */
10997
- function TerminalSidebar({ terminal }) {
10832
+ function TerminalSidebar({ terminal, heldBy }) {
10998
10833
  const target = terminal.target;
10999
10834
  const mount = (0, import_react.useRef)(null);
11000
10835
  const { client, state, status, reconnectable, choice, setChoice } = useTerminalClient(mount, target?.digest ?? "");
11001
10836
  const { sessions, end } = useTerminalSessions();
11002
10837
  const ui = useTerminalUi();
10838
+ const collapsed = ui.collapsed || Boolean(heldBy);
11003
10839
  (0, import_react.useEffect)(() => {
11004
10840
  if (!ui.drawerOpen) return;
11005
10841
  const close = (event) => {
@@ -11024,9 +10860,9 @@ function TerminalSidebar({ terminal }) {
11024
10860
  className: ICON_BUTTON,
11025
10861
  id: "terminal-expand",
11026
10862
  "aria-controls": "terminal-body",
11027
- "aria-expanded": !ui.collapsed,
10863
+ "aria-expanded": !collapsed,
11028
10864
  "aria-label": "Expand the terminal",
11029
- onClick: () => ui.setCollapsed(false),
10865
+ onClick: () => heldBy ? ui.release(heldBy) : ui.setCollapsed(false),
11030
10866
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { name: "left" })
11031
10867
  }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
11032
10868
  className: "terminal-dot",
@@ -11056,7 +10892,7 @@ function TerminalSidebar({ terminal }) {
11056
10892
  className: ICON_BUTTON,
11057
10893
  id: "terminal-collapse",
11058
10894
  "aria-controls": "terminal-body",
11059
- "aria-expanded": !ui.collapsed,
10895
+ "aria-expanded": !collapsed,
11060
10896
  "aria-label": "Collapse the terminal",
11061
10897
  onClick: () => ui.setCollapsed(true),
11062
10898
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { name: "right" })
@@ -11246,11 +11082,20 @@ function useRailKey() {
11246
11082
  function StudioLayout({ search }) {
11247
11083
  const { data: shell } = useSuspenseQuery(shellQuery(search));
11248
11084
  const view = useMatches({ select: (matches) => matches.findLast((match) => match.staticData.view)?.staticData.view }) ?? "dashboard";
11085
+ const pluginParams = useMatches({ select: (matches) => matches.findLast((match) => match.staticData.pluginView)?.params });
11086
+ const pluginView = pluginParams ? shell.pluginViews.find((entry) => entry.service === pluginParams.service && entry.view === pluginParams.view) : void 0;
11087
+ const workspace = pluginView?.layout === "workspace";
11088
+ const workspaceKey = pluginView ? `${pluginView.service}/${pluginView.view}` : null;
11089
+ const released = useTerminalUi((state) => state.released);
11090
+ const held = heldBy(workspace ? workspaceKey : null, released);
11249
11091
  const digest = shell.selected?.digest;
11250
11092
  useStudioEvents(digest);
11251
11093
  useStudioClicks();
11252
11094
  useRailKey();
11253
11095
  usePrefetchViews(shell.selected ? search : {}, shell.studioMode, shell.enabledModes);
11096
+ (0, import_react.useEffect)(() => {
11097
+ useTerminalUi.getState().setWorkspace(workspace ? workspaceKey : null);
11098
+ }, [workspace, workspaceKey]);
11254
11099
  (0, import_react.useEffect)(() => {
11255
11100
  if (!digest) return;
11256
11101
  try {
@@ -11263,6 +11108,7 @@ function StudioLayout({ search }) {
11263
11108
  "data-companion": digest,
11264
11109
  "data-terminal": shell.terminal ? "" : void 0,
11265
11110
  "data-picker": shell.selected ? void 0 : "",
11111
+ "data-terminal-held": held ? "" : void 0,
11266
11112
  children: [
11267
11113
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NavigationProgress, {}),
11268
11114
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TopBar, {
@@ -11274,22 +11120,25 @@ function StudioLayout({ search }) {
11274
11120
  search,
11275
11121
  view
11276
11122
  }) : null,
11277
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("main", {
11123
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("main", {
11278
11124
  className: "studio-main flex min-h-0 min-w-0 flex-col overflow-auto",
11279
11125
  id: "studio-main",
11280
- children: shell.selected ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(PageHeader, {
11281
- title: VIEW_TITLES[view],
11282
- description: VIEW_DESCRIPTIONS[shell.studioMode][view]
11126
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ConnectionBanner, {}), shell.selected && workspace ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Outlet, {}) : shell.selected ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(PageHeader, {
11127
+ title: pluginView ? pluginView.label : VIEW_TITLES[view],
11128
+ description: pluginView ? pluginView.description ?? "" : VIEW_DESCRIPTIONS[shell.studioMode][view]
11283
11129
  }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
11284
11130
  className: "flex min-h-0 flex-1 flex-col pt-3",
11285
11131
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Outlet, {})
11286
11132
  })] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CompanionPicker, {
11287
11133
  companions: shell.companions,
11288
11134
  writable: shell.writable,
11289
- factoryMode: shell.factoryMode
11290
- })
11135
+ addsCompanions: shell.addsCompanions
11136
+ })]
11291
11137
  }),
11292
- shell.terminal ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TerminalSidebar, { terminal: shell.terminal }) : null
11138
+ shell.terminal ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TerminalSidebar, {
11139
+ terminal: shell.terminal,
11140
+ heldBy: held
11141
+ }) : null
11293
11142
  ]
11294
11143
  }),
11295
11144
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CommandPalette, {
@@ -11329,7 +11178,7 @@ function Toasts({ search }) {
11329
11178
  }
11330
11179
  // src/routes/__root.tsx
11331
11180
  var FAVICON_URI = `data:image/svg+xml;base64,${btoa(BRAND_SVGS.favicon)}`;
11332
- var Route$12 = createRootRouteWithContext()({
11181
+ var Route$14 = createRootRouteWithContext()({
11333
11182
  validateSearch: validateStudioSearch,
11334
11183
  loaderDeps: ({ search }) => search,
11335
11184
  ssr: true,
@@ -11370,7 +11219,7 @@ var Route$12 = createRootRouteWithContext()({
11370
11219
  component: RootLayout
11371
11220
  });
11372
11221
  function RootLayout() {
11373
- const { companion, studioMode } = Route$12.useSearch();
11222
+ const { companion, studioMode } = Route$14.useSearch();
11374
11223
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StudioLayout, { search: {
11375
11224
  companion,
11376
11225
  studioMode
@@ -11383,8 +11232,8 @@ function RootDocument({ children }) {
11383
11232
  });
11384
11233
  }
11385
11234
  // src/routes/index.tsx
11386
- var $$splitComponentImporter$11 = () => import("./routes-B6GfOew4.js");
11387
- var Route$11 = createFileRoute("/")({
11235
+ var $$splitComponentImporter$13 = () => import("./routes-Bl90FC4R.js");
11236
+ var Route$13 = createFileRoute("/")({
11388
11237
  staticData: { view: "dashboard" },
11389
11238
  validateSearch: (raw) => typeof raw.change === "string" && raw.change !== "" ? { change: raw.change } : {},
11390
11239
  loaderDeps: ({ search }) => ({
@@ -11393,53 +11242,109 @@ var Route$11 = createFileRoute("/")({
11393
11242
  }),
11394
11243
  ssr: true,
11395
11244
  loader: async ({ context, deps }) => await registeredCompanion(context.queryClient, deps) ? loadView(context.queryClient, companionViewQuery("dashboard", deps)) : null,
11396
- component: lazyRouteComponent($$splitComponentImporter$11, "component")
11245
+ component: lazyRouteComponent($$splitComponentImporter$13, "component")
11397
11246
  });
11398
11247
  /** Each mode reads its own Overview; the server's effective mode picks it, not the address. */
11399
- // src/routes/factory.tsx
11400
- var $$splitComponentImporter$10 = () => import("./factory-C7Ybg0xG.js");
11401
- var Route$10 = createFileRoute("/factory")({
11402
- staticData: { view: "factory" },
11403
- validateSearch: (raw) => typeof raw.outcome === "string" && /^[a-z0-9][a-z0-9-]*$/.test(raw.outcome) ? { outcome: raw.outcome } : {},
11404
- beforeLoad: async ({ context, search }) => {
11405
- const studioSearch = {
11406
- companion: search.companion,
11407
- studioMode: search.studioMode
11408
- };
11409
- if (!(await loadHeld(context.queryClient, shellQuery(studioSearch))).factoryMode) throw redirect({
11410
- to: "/",
11411
- search: studioSearch
11412
- });
11413
- },
11248
+ // src/routes/friction.tsx
11249
+ var $$splitComponentImporter$12 = () => import("./friction-Vl3B6THL.js");
11250
+ var Route$12 = createFileRoute("/friction")({
11251
+ staticData: { view: "friction" },
11414
11252
  loaderDeps: ({ search }) => ({
11415
11253
  companion: search.companion,
11416
11254
  studioMode: search.studioMode
11417
11255
  }),
11418
- loader: async ({ context, deps }) => {
11419
- const companion = await registeredCompanion(context.queryClient, deps);
11420
- return companion ? loadView(context.queryClient, factoryQuery(companion)) : null;
11421
- },
11422
- component: lazyRouteComponent($$splitComponentImporter$10, "component")
11256
+ loader: ({ context, deps }) => registeredCompanion(context.queryClient, deps),
11257
+ component: lazyRouteComponent($$splitComponentImporter$12, "component")
11423
11258
  });
11424
11259
  // src/routes/getting-started.tsx
11425
- var $$splitComponentImporter$9 = () => import("./getting-started-B136TP57.js");
11426
- var Route$9 = createFileRoute("/getting-started")({
11260
+ var $$splitComponentImporter$11 = () => import("./getting-started-B136TP57.js");
11261
+ var Route$11 = createFileRoute("/getting-started")({
11427
11262
  ssr: true,
11428
11263
  staticData: { view: "getting-started" },
11429
- component: lazyRouteComponent($$splitComponentImporter$9, "component")
11264
+ component: lazyRouteComponent($$splitComponentImporter$11, "component")
11430
11265
  });
11431
11266
  // src/routes/graph.tsx
11432
- var $$splitComponentImporter$8 = () => import("./graph-CSje3029.js").then((n) => n.t);
11267
+ var $$splitComponentImporter$10 = () => import("./graph-D3fXCaKt.js").then((n) => n.t);
11433
11268
  var text$1 = (value) => typeof value === "string" && value.length > 0 && value.length <= 1024 ? value : void 0;
11434
- var Route$8 = createFileRoute("/graph")({
11269
+ var Route$10 = createFileRoute("/graph")({
11435
11270
  validateSearch: (raw) => text$1(raw.node) ? { node: text$1(raw.node) } : {},
11436
11271
  staticData: { view: "graph" },
11437
11272
  ssr: false,
11438
- component: lazyRouteComponent($$splitComponentImporter$8, "component")
11273
+ component: lazyRouteComponent($$splitComponentImporter$10, "component")
11274
+ });
11275
+ // src/server/mcp-manager.ts
11276
+ /** Far above any real section; core validates what is inside. */
11277
+ var MAX_STATE = 262144;
11278
+ function companionOf(input) {
11279
+ if (typeof input?.companion !== "string" || !COMPANION_DIGEST_PATTERN.test(input.companion)) throw new Error("no registered companion was selected");
11280
+ return input.companion;
11281
+ }
11282
+ var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
11283
+ /** The outer shape and size only. */
11284
+ function stateOf(input) {
11285
+ const next = input?.next;
11286
+ if (!isRecord(next) || !(next.catalog === null || isRecord(next.catalog)) || !isRecord(next.audiences) || !Object.values(next.audiences).every(isRecord)) throw new Error("the request holds no mcpManager state");
11287
+ if (JSON.stringify(next).length > MAX_STATE) throw new Error("the mcpManager state exceeds the size limit");
11288
+ return {
11289
+ catalog: next.catalog,
11290
+ audiences: next.audiences
11291
+ };
11292
+ }
11293
+ var getMcpManager = createServerFn({ method: "GET" }).validator((input) => ({ companion: companionOf(input) })).handler(createSsrRpc("1d009b232dd1b78890b3c1f2be3a5df2d35a25793e0ad67870cb866677faad41"));
11294
+ /** Effective sets and variable states for unsaved state, or core's validation error. */
11295
+ var previewMcpManager = createServerFn({ method: "POST" }).validator((input) => ({
11296
+ companion: companionOf(input),
11297
+ next: stateOf(input)
11298
+ })).handler(createSsrRpc("e6f927edb301210a568a297901febc6dddf894875a991839f0582883c5599ba9"));
11299
+ /** A save; a stale token comes back as a conflict carrying the current view. */
11300
+ var saveMcpManager = createServerFn({ method: "POST" }).validator((input) => {
11301
+ if (typeof input?.token !== "string" || !/^[0-9a-f]{64}$/.test(input.token)) throw new Error("save requires the token of the last read");
11302
+ return {
11303
+ companion: companionOf(input),
11304
+ next: stateOf(input),
11305
+ token: input.token
11306
+ };
11307
+ }).handler(createSsrRpc("ba52b9a6beea7d337a5d2c387d967cfc6ba4ef7fe19a80a904306f29079f5d27"));
11308
+ // src/lib/mcp-query.ts
11309
+ var SCOPE = "mcp";
11310
+ var mcpManagerQuery = (companion) => queryOptions({
11311
+ queryKey: [companion, SCOPE],
11312
+ queryFn: () => getMcpManager({ data: { companion } }),
11313
+ retry: false
11314
+ });
11315
+ /** What core derives from unsaved state, or its validation error; held briefly per state. */
11316
+ var mcpPreviewQuery = (companion, next) => queryOptions({
11317
+ queryKey: [
11318
+ companion,
11319
+ SCOPE,
11320
+ "preview",
11321
+ next
11322
+ ],
11323
+ queryFn: () => previewMcpManager({ data: {
11324
+ companion,
11325
+ next
11326
+ } }),
11327
+ gcTime: 6e4
11328
+ });
11329
+ // src/routes/mcp.tsx
11330
+ var $$splitComponentImporter$9 = () => import("./mcp-Ljf4simO.js");
11331
+ var Route$9 = createFileRoute("/mcp")({
11332
+ staticData: { view: "mcp" },
11333
+ loaderDeps: ({ search }) => ({
11334
+ companion: search.companion,
11335
+ studioMode: search.studioMode
11336
+ }),
11337
+ ssr: true,
11338
+ loader: async ({ context, deps }) => {
11339
+ const companion = await registeredCompanion(context.queryClient, deps);
11340
+ if (!companion) return null;
11341
+ return loadView(context.queryClient, mcpManagerQuery(companion)).catch(() => null);
11342
+ },
11343
+ component: lazyRouteComponent($$splitComponentImporter$9, "component")
11439
11344
  });
11440
11345
  // src/routes/reports.tsx
11441
- var $$splitComponentImporter$7 = () => import("./reports-CQ9qQ1-n.js");
11442
- var Route$7 = createFileRoute("/reports")({
11346
+ var $$splitComponentImporter$8 = () => import("./reports-BVNSPHU3.js");
11347
+ var Route$8 = createFileRoute("/reports")({
11443
11348
  staticData: { view: "reports" },
11444
11349
  loaderDeps: ({ search }) => ({
11445
11350
  companion: search.companion,
@@ -11449,11 +11354,11 @@ var Route$7 = createFileRoute("/reports")({
11449
11354
  const companion = await registeredCompanion(context.queryClient, deps);
11450
11355
  return companion ? loadView(context.queryClient, reportsQuery(companion)) : null;
11451
11356
  },
11452
- component: lazyRouteComponent($$splitComponentImporter$7, "component")
11357
+ component: lazyRouteComponent($$splitComponentImporter$8, "component")
11453
11358
  });
11454
11359
  // src/routes/skills.tsx
11455
- var $$splitComponentImporter$6 = () => import("./skills-B7nEuVbx.js");
11456
- var Route$6 = createFileRoute("/skills")({
11360
+ var $$splitComponentImporter$7 = () => import("./skills-10l0eCfP.js");
11361
+ var Route$7 = createFileRoute("/skills")({
11457
11362
  staticData: { view: "skills" },
11458
11363
  loaderDeps: ({ search }) => ({
11459
11364
  companion: search.companion,
@@ -11461,11 +11366,11 @@ var Route$6 = createFileRoute("/skills")({
11461
11366
  }),
11462
11367
  ssr: true,
11463
11368
  loader: async ({ context, deps }) => await registeredCompanion(context.queryClient, deps) ? loadView(context.queryClient, companionViewQuery("skills", deps)) : null,
11464
- component: lazyRouteComponent($$splitComponentImporter$6, "component")
11369
+ component: lazyRouteComponent($$splitComponentImporter$7, "component")
11465
11370
  });
11466
11371
  // src/routes/specs.tsx
11467
- var $$splitComponentImporter$5 = () => import("./specs-BpLUFntA.js");
11468
- var Route$5 = createFileRoute("/specs")({
11372
+ var $$splitComponentImporter$6 = () => import("./specs-C1P2BEao.js");
11373
+ var Route$6 = createFileRoute("/specs")({
11469
11374
  staticData: { view: "specs" },
11470
11375
  validateSearch: validateSpecsSearch,
11471
11376
  loaderDeps: ({ search }) => ({
@@ -11474,23 +11379,23 @@ var Route$5 = createFileRoute("/specs")({
11474
11379
  }),
11475
11380
  ssr: true,
11476
11381
  loader: async ({ context, deps }) => await registeredCompanion(context.queryClient, deps) ? loadView(context.queryClient, companionViewQuery("specs", deps)) : null,
11477
- component: lazyRouteComponent($$splitComponentImporter$5, "component")
11382
+ component: lazyRouteComponent($$splitComponentImporter$6, "component")
11478
11383
  });
11479
11384
  // src/routes/usage.tsx
11480
- var $$splitComponentImporter$4 = () => import("./usage-COdjd1gD.js");
11481
- var Route$4 = createFileRoute("/usage")({
11385
+ var $$splitComponentImporter$5 = () => import("./usage-CT3IWLJc.js");
11386
+ var Route$5 = createFileRoute("/usage")({
11482
11387
  staticData: { view: "usage" },
11483
11388
  loaderDeps: ({ search }) => ({
11484
11389
  companion: search.companion,
11485
11390
  studioMode: search.studioMode
11486
11391
  }),
11487
11392
  loader: ({ context, deps }) => registeredCompanion(context.queryClient, deps),
11488
- component: lazyRouteComponent($$splitComponentImporter$4, "component")
11393
+ component: lazyRouteComponent($$splitComponentImporter$5, "component")
11489
11394
  });
11490
11395
  // src/routes/vault.tsx
11491
- var $$splitComponentImporter$3 = () => import("./vault-BDuIUq0F.js");
11396
+ var $$splitComponentImporter$4 = () => import("./vault-BIytrudF.js");
11492
11397
  var text = (value) => typeof value === "string" && value ? value : void 0;
11493
- var Route$3 = createFileRoute("/vault")({
11398
+ var Route$4 = createFileRoute("/vault")({
11494
11399
  staticData: { view: "vault" },
11495
11400
  validateSearch: (raw) => ({
11496
11401
  ...text(raw.path) ? { path: text(raw.path) } : {},
@@ -11507,11 +11412,11 @@ var Route$3 = createFileRoute("/vault")({
11507
11412
  const companion = await registeredCompanion(context.queryClient, deps);
11508
11413
  return companion ? loadView(context.queryClient, vaultQuery(companion, deps)) : null;
11509
11414
  },
11510
- component: lazyRouteComponent($$splitComponentImporter$3, "component")
11415
+ component: lazyRouteComponent($$splitComponentImporter$4, "component")
11511
11416
  });
11512
11417
  // src/routes/workflow.tsx
11513
- var $$splitComponentImporter$2 = () => import("./workflow-D9GKI2EV.js");
11514
- var Route$2 = createFileRoute("/workflow")({
11418
+ var $$splitComponentImporter$3 = () => import("./workflow-DFdqnMtW.js");
11419
+ var Route$3 = createFileRoute("/workflow")({
11515
11420
  staticData: { view: "workflow" },
11516
11421
  loaderDeps: ({ search }) => ({
11517
11422
  companion: search.companion,
@@ -11519,115 +11424,153 @@ var Route$2 = createFileRoute("/workflow")({
11519
11424
  }),
11520
11425
  ssr: true,
11521
11426
  loader: async ({ context, deps }) => await registeredCompanion(context.queryClient, deps) ? loadView(context.queryClient, companionViewQuery("workflow", deps)) : null,
11522
- component: lazyRouteComponent($$splitComponentImporter$2, "component")
11427
+ component: lazyRouteComponent($$splitComponentImporter$3, "component")
11523
11428
  });
11524
11429
  // src/routes/getting-started.index.tsx
11525
- var $$splitComponentImporter$1 = () => import("./getting-started.index-D84gec1t.js");
11526
- var Route$1 = createFileRoute("/getting-started/")({
11430
+ var $$splitComponentImporter$2 = () => import("./getting-started.index-CTaXYycH.js");
11431
+ var Route$2 = createFileRoute("/getting-started/")({
11527
11432
  loaderDeps: ({ search }) => search,
11528
11433
  ssr: true,
11529
11434
  loader: async ({ context, deps }) => await registeredCompanion(context.queryClient, deps) ? getGuide({ data: { topic: "start" } }) : null,
11530
- component: lazyRouteComponent($$splitComponentImporter$1, "component")
11435
+ component: lazyRouteComponent($$splitComponentImporter$2, "component")
11531
11436
  });
11532
11437
  // src/routes/getting-started.$topic.tsx
11533
- var $$splitComponentImporter = () => import("./getting-started._topic-DJKQAzYl.js");
11534
- var Route = createFileRoute("/getting-started/$topic")({
11438
+ var $$splitComponentImporter$1 = () => import("./getting-started._topic-EYtxZM-Y.js");
11439
+ var Route$1 = createFileRoute("/getting-started/$topic")({
11535
11440
  loaderDeps: ({ search }) => search,
11536
11441
  ssr: true,
11537
11442
  loader: async ({ context, deps, params }) => await registeredCompanion(context.queryClient, deps) ? getGuide({ data: { topic: params.topic } }) : null,
11443
+ component: lazyRouteComponent($$splitComponentImporter$1, "component")
11444
+ });
11445
+ // src/routes/plugins.$service.$view.tsx
11446
+ var $$splitComponentImporter = () => import("./plugins._service._view-DUpAo5D_.js");
11447
+ /** A view a plugin service ships as its own module; Studio mounts it in the layout. */
11448
+ var Route = createFileRoute("/plugins/$service/$view")({
11449
+ staticData: { pluginView: true },
11538
11450
  component: lazyRouteComponent($$splitComponentImporter, "component")
11539
11451
  });
11540
11452
  // src/route-tree.gen.ts
11541
- var IndexRoute = Route$11.update({
11453
+ var IndexRoute = Route$13.update({
11542
11454
  id: "/",
11543
11455
  path: "/",
11544
- getParentRoute: () => Route$12
11456
+ getParentRoute: () => Route$14
11545
11457
  });
11546
- var FactoryRoute = Route$10.update({
11547
- id: "/factory",
11548
- path: "/factory",
11549
- getParentRoute: () => Route$12
11458
+ var FrictionRoute = Route$12.update({
11459
+ id: "/friction",
11460
+ path: "/friction",
11461
+ getParentRoute: () => Route$14
11550
11462
  });
11551
- var GettingStartedRoute = Route$9.update({
11463
+ var GettingStartedRoute = Route$11.update({
11552
11464
  id: "/getting-started",
11553
11465
  path: "/getting-started",
11554
- getParentRoute: () => Route$12
11466
+ getParentRoute: () => Route$14
11555
11467
  });
11556
- var GraphRoute = Route$8.update({
11468
+ var GraphRoute = Route$10.update({
11557
11469
  id: "/graph",
11558
11470
  path: "/graph",
11559
- getParentRoute: () => Route$12
11471
+ getParentRoute: () => Route$14
11472
+ });
11473
+ var McpRoute = Route$9.update({
11474
+ id: "/mcp",
11475
+ path: "/mcp",
11476
+ getParentRoute: () => Route$14
11560
11477
  });
11561
- var ReportsRoute = Route$7.update({
11478
+ var ReportsRoute = Route$8.update({
11562
11479
  id: "/reports",
11563
11480
  path: "/reports",
11564
- getParentRoute: () => Route$12
11481
+ getParentRoute: () => Route$14
11565
11482
  });
11566
- var SkillsRoute = Route$6.update({
11483
+ var SkillsRoute = Route$7.update({
11567
11484
  id: "/skills",
11568
11485
  path: "/skills",
11569
- getParentRoute: () => Route$12
11486
+ getParentRoute: () => Route$14
11570
11487
  });
11571
- var SpecsRoute = Route$5.update({
11488
+ var SpecsRoute = Route$6.update({
11572
11489
  id: "/specs",
11573
11490
  path: "/specs",
11574
- getParentRoute: () => Route$12
11491
+ getParentRoute: () => Route$14
11575
11492
  });
11576
- var UsageRoute = Route$4.update({
11493
+ var UsageRoute = Route$5.update({
11577
11494
  id: "/usage",
11578
11495
  path: "/usage",
11579
- getParentRoute: () => Route$12
11496
+ getParentRoute: () => Route$14
11580
11497
  });
11581
- var VaultRoute = Route$3.update({
11498
+ var VaultRoute = Route$4.update({
11582
11499
  id: "/vault",
11583
11500
  path: "/vault",
11584
- getParentRoute: () => Route$12
11501
+ getParentRoute: () => Route$14
11585
11502
  });
11586
- var WorkflowRoute = Route$2.update({
11503
+ var WorkflowRoute = Route$3.update({
11587
11504
  id: "/workflow",
11588
11505
  path: "/workflow",
11589
- getParentRoute: () => Route$12
11506
+ getParentRoute: () => Route$14
11590
11507
  });
11591
- var GettingStartedIndexRoute = Route$1.update({
11508
+ var GettingStartedIndexRoute = Route$2.update({
11592
11509
  id: "/",
11593
11510
  path: "/",
11594
11511
  getParentRoute: () => GettingStartedRoute
11595
11512
  });
11513
+ var GettingStartedTopicRoute = Route$1.update({
11514
+ id: "/$topic",
11515
+ path: "/$topic",
11516
+ getParentRoute: () => GettingStartedRoute
11517
+ });
11518
+ var PluginsServiceViewRoute = Route.update({
11519
+ id: "/plugins/$service/$view",
11520
+ path: "/plugins/$service/$view",
11521
+ getParentRoute: () => Route$14
11522
+ });
11596
11523
  var GettingStartedRouteChildren = {
11597
- GettingStartedTopicRoute: Route.update({
11598
- id: "/$topic",
11599
- path: "/$topic",
11600
- getParentRoute: () => GettingStartedRoute
11601
- }),
11524
+ GettingStartedTopicRoute,
11602
11525
  GettingStartedIndexRoute
11603
11526
  };
11604
11527
  var rootRouteChildren = {
11605
11528
  IndexRoute,
11606
- FactoryRoute,
11529
+ FrictionRoute,
11607
11530
  GettingStartedRoute: GettingStartedRoute._addFileChildren(GettingStartedRouteChildren),
11608
11531
  GraphRoute,
11532
+ McpRoute,
11609
11533
  ReportsRoute,
11610
11534
  SkillsRoute,
11611
11535
  SpecsRoute,
11612
11536
  UsageRoute,
11613
11537
  VaultRoute,
11614
- WorkflowRoute
11538
+ WorkflowRoute,
11539
+ PluginsServiceViewRoute
11615
11540
  };
11616
- var routeTree = Route$12._addFileChildren(rootRouteChildren)._addFileTypes();
11541
+ var routeTree = Route$14._addFileChildren(rootRouteChildren)._addFileTypes();
11542
+ // src/lib/query-client.ts
11543
+ /**
11544
+ * The page's query client. In the browser every failed query or mutation makes the page's
11545
+ * connection monitor probe; during SSR there is no monitor, so `window` stays untouched.
11546
+ */
11547
+ function createStudioQueryClient() {
11548
+ let monitor = null;
11549
+ const suspect = () => monitor?.suspect();
11550
+ const queryClient = new QueryClient({
11551
+ queryCache: new QueryCache({ onError: suspect }),
11552
+ mutationCache: new MutationCache({ onError: suspect }),
11553
+ defaultOptions: { queries: {
11554
+ staleTime: 5e3,
11555
+ gcTime: Infinity
11556
+ } }
11557
+ });
11558
+ if (typeof window !== "undefined") monitor = startConnectionMonitor({ queryClient });
11559
+ return queryClient;
11560
+ }
11617
11561
  // src/router.tsx
11618
11562
  var router_exports = /* @__PURE__ */ __exportAll({ getRouter: () => getRouter });
11619
11563
  /** One router and query client per request on the server, one per page in the browser. */
11620
11564
  function getRouter() {
11621
- const queryClient = new QueryClient({ defaultOptions: { queries: {
11622
- staleTime: 5e3,
11623
- gcTime: Infinity
11624
- } } });
11565
+ const queryClient = createStudioQueryClient();
11625
11566
  const router = createRouter({
11626
11567
  routeTree,
11627
11568
  context: { queryClient },
11628
11569
  scrollRestoration: true,
11629
11570
  defaultPreload: "intent",
11630
- defaultPendingComponent: ViewPlaceholder
11571
+ defaultPendingComponent: ViewPlaceholder,
11572
+ parseSearch: parseStudioSearch,
11573
+ stringifySearch: stringifyStudioSearch
11631
11574
  });
11632
11575
  setupRouterSsrQueryIntegration({
11633
11576
  router,
@@ -11635,4 +11578,4 @@ function getRouter() {
11635
11578
  });
11636
11579
  return router;
11637
11580
  }
11638
- export { ComboboxItem as $, gitTokensQuery as A, inField as B, pathPositionOf as C, GitTokenForm as D, ViewPlaceholder as E, GROUP_TITLES as F, DialogTitle as G, DialogClose as H, changeGroup as I, DialogPortal as J, DialogTitle$1 as K, changeProgress as L, tokenCovers as M, useMediaQuery as N, clearGitToken as O, CHANGE_GROUPS as P, ComboboxEmpty as Q, changeStep as R, nextStepOf as S, useSuspenseQuery as St, useBrowser as T, DialogContent as U, Dialog as V, DialogDescription as W, DialogClose$1 as X, DialogPopup as Y, DialogBackdrop as Z, ACTIVITY_LABELS as _, Tooltip as _t, Route$3 as a, useComboboxPositionerContext as at, factoryHome as b, useAnchorPositioning as bt, Route$6 as c, triggerStateAttributesMapping as ct, Route$10 as d, useComboboxFloatingContext as dt, useComboboxItemContext as et, Route$11 as f, useComboboxInputValueContext as ft, sendMessage as g, getRouter, usePageUi as gt, parseMessage as h, useVaultUi as ht, Route$2 as i, ComboboxPositionerContext as it, hostOf as j, gitTokensKey as k, Route$7 as l, AriaCombobox as lt, openTerminalSocket as m, useAppearance as mt, Route as n, ComboboxInput as nt, Route$4 as o, useListEmpty as ot, loadWTerm as p, useComboboxRootContext as pt, DialogRoot as q, Route$1 as r, ComboboxInternalDismissButton as rt, Route$5 as s, usePopupSide as st, router_exports as t, ComboboxList as tt, Route$8 as u, getComboboxPopupId as ut, PATH_STEPS as v, usePositioner as vt, situationOf as w, milestonesOf as x, platform as xt, activityOf as y, getDisabledMountTransitionStyles as yt, groupChanges as z };
11581
+ export { AriaCombobox as $, activeChanges as A, DialogDescription as B, useSetFrictionRecording as C, useMediaQuery as D, RecordingState as E, groupChanges as F, ComboboxList as G, ComboboxEmpty as H, inField as I, ComboboxPositionerContext as J, ComboboxInput as K, Dialog as L, changePath as M, changeProgress as N, CHANGE_GROUPS as O, changeStep as P, triggerStateAttributesMapping as Q, DialogClose as R, useMarkFriction as S, RecordingReach as T, ComboboxItem as U, DialogTitle as V, useComboboxItemContext as W, useListEmpty as X, useComboboxPositionerContext as Y, usePopupSide as Z, Route$13 as _, Route$3 as a, useVaultUi as at, useRetryFocus as b, Route$6 as c, Tooltip as ct, Route$9 as d, useAnchorPositioning as dt, getComboboxPopupId as et, mcpManagerQuery as f, platform as ft, Route$12 as g, getRouter, Route$10 as h, Route$2 as i, useAppearance as it, changeGroup as j, GROUP_TITLES as k, Route$7 as l, usePositioner as lt, saveMcpManager as m, Route as n, useComboboxInputValueContext as nt, Route$4 as o, usePageUi as ot, mcpPreviewQuery as p, useSuspenseQuery as pt, ComboboxInternalDismissButton as q, Route$1 as r, useComboboxRootContext as rt, Route$5 as s, studioConnection as st, router_exports as t, useComboboxFloatingContext as tt, Route$8 as u, getDisabledMountTransitionStyles as ut, ViewPlaceholder as v, RecordingButton as w, frictionQuery as x, useBrowser as y, DialogContent as z };