@uniqbit/mate-core 0.20.0 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (286) hide show
  1. package/claude-capability-plugins/companion-mentions/.claude-plugin/plugin.json +1 -1
  2. package/claude-capability-plugins/companion-mentions/hooks/register.ts +1 -1
  3. package/claude-plugin/hooks/hooks.json +10 -1
  4. package/claude-plugin/hooks/rtk-worktree-git.mjs +58 -0
  5. package/opencode-plugin/src/server.ts +9 -2
  6. package/package.json +2 -1
  7. package/src/cli/commands/artifact/delivery/environment.ts +28 -8
  8. package/src/cli/commands/artifact/delivery/link.ts +28 -9
  9. package/src/cli/commands/artifact/delivery/output.ts +7 -0
  10. package/src/cli/commands/companion/update.ts +2 -19
  11. package/src/cli/commands/factory/factory.ts +11 -1
  12. package/src/cli/commands/install.ts +47 -36
  13. package/src/cli/commands/launch/claude.ts +2 -0
  14. package/src/cli/commands/launch/shared.ts +33 -6
  15. package/src/cli/commands/plugin/install.ts +27 -11
  16. package/src/cli/commands/report/index.ts +180 -184
  17. package/src/cli/commands/report/markdown.ts +67 -72
  18. package/src/cli/commands/shared/companion-selection.ts +3 -1
  19. package/src/cli/commands/studio/access.ts +6 -14
  20. package/src/cli/commands/studio/areas.ts +112 -33
  21. package/src/cli/commands/studio/companion-add.ts +87 -0
  22. package/src/cli/commands/studio/companion-removal.ts +15 -8
  23. package/src/cli/commands/studio/factory-credential.ts +1 -15
  24. package/src/cli/commands/studio/factory-git-tokens.ts +40 -0
  25. package/src/cli/commands/studio/factory-relay.ts +18 -0
  26. package/src/cli/commands/studio/graph-model.ts +61 -0
  27. package/src/cli/commands/studio/graph.ts +336 -0
  28. package/src/cli/commands/studio/index.ts +4 -4
  29. package/src/cli/commands/studio/payload.ts +42 -15
  30. package/src/cli/commands/studio/repository-add.ts +116 -0
  31. package/src/cli/commands/studio/routes.ts +6 -0
  32. package/src/cli/commands/studio/selection.ts +12 -3
  33. package/src/cli/commands/studio/server.ts +127 -5
  34. package/src/cli/commands/studio/services.ts +40 -0
  35. package/src/cli/commands/studio/terminal.ts +45 -3
  36. package/src/cli/commands/studio/views/vault/markdown-tree.ts +84 -3
  37. package/src/cli/commands/studio/workset-session.ts +47 -14
  38. package/src/cli/commands/unwrap.ts +3 -0
  39. package/src/cli/commands/update.ts +2 -0
  40. package/src/cli/commands/vscode/release-vsix.json +4 -0
  41. package/src/cli/commands/vscode/setup.ts +71 -13
  42. package/src/cli/commands/vscode/vsix.ts +48 -7
  43. package/src/cli/commands/working/cleanup.ts +40 -8
  44. package/src/cli/commands/working/worktree.ts +176 -35
  45. package/src/cli/main.ts +17 -2
  46. package/src/cli/usage.ts +1 -1
  47. package/src/hooks/rtk-worktree-git.ts +48 -0
  48. package/src/hooks/validate-artifact-path.ts +38 -7
  49. package/src/lib/delivery/branch-template.ts +122 -0
  50. package/src/lib/delivery/branches.ts +21 -16
  51. package/src/lib/delivery/checkout.ts +102 -0
  52. package/src/lib/delivery/environment.ts +2 -0
  53. package/src/lib/delivery/merge-git.ts +13 -1
  54. package/src/lib/delivery/record-delivery.ts +83 -29
  55. package/src/lib/delivery/record.ts +15 -3
  56. package/src/lib/delivery/resolve-branch.ts +157 -110
  57. package/src/lib/factory/attach-client.ts +11 -1
  58. package/src/lib/factory/broker.ts +37 -40
  59. package/src/lib/factory/client.ts +22 -1
  60. package/src/lib/factory/clone-url.ts +39 -0
  61. package/src/lib/factory/command.ts +21 -5
  62. package/src/lib/factory/git-auth.ts +61 -0
  63. package/src/lib/factory/git-credential-store.ts +181 -0
  64. package/src/lib/factory/ids.ts +12 -2
  65. package/src/lib/factory/outcomes/actions.ts +20 -4
  66. package/src/lib/factory/outcomes/index.ts +77 -11
  67. package/src/lib/factory/outcomes/lifecycle.ts +9 -2
  68. package/src/lib/factory/outcomes/sessions.ts +23 -1
  69. package/src/lib/factory/prepare.ts +9 -3
  70. package/src/lib/factory/runner/scheduler.ts +96 -14
  71. package/src/lib/factory/runner/workflow.ts +5 -1
  72. package/src/lib/factory/runtime.ts +143 -43
  73. package/src/lib/orchestrator/companion-hub.ts +6 -1
  74. package/src/lib/orchestrator/engine-floor.ts +48 -0
  75. package/src/lib/orchestrator/launcher.ts +34 -1
  76. package/src/lib/orchestrator/projection-claude-commands.ts +2 -2
  77. package/src/lib/orchestrator/projection-claude-entry.ts +42 -21
  78. package/src/lib/orchestrator/projection-claude-links.ts +32 -8
  79. package/src/lib/orchestrator/projection-claude-skills.ts +2 -2
  80. package/src/lib/orchestrator/projection-entries.ts +22 -18
  81. package/src/lib/orchestrator/projection-opencode-copies.ts +65 -21
  82. package/src/lib/orchestrator/projection-runtime-documents.ts +66 -43
  83. package/src/lib/orchestrator/projection-types.ts +28 -1
  84. package/src/lib/orchestrator/refresh-working-claude-links.ts +3 -1
  85. package/src/lib/orchestrator/session-prepare.ts +6 -1
  86. package/src/lib/orchestrator/setup-compatibilities.ts +1 -1
  87. package/src/lib/orchestrator/types.ts +4 -0
  88. package/src/lib/orchestrator/umbrella-checkouts.ts +102 -0
  89. package/src/lib/orchestrator/working-repo-projection.ts +24 -4
  90. package/src/lib/orchestrator/wrap-pass.ts +1 -0
  91. package/src/lib/public-npm.ts +95 -50
  92. package/src/lib/session-state.ts +72 -2
  93. package/src/lib/update-checker.ts +7 -1
  94. package/src/lib/usage/aggregate.ts +202 -0
  95. package/src/lib/usage/cache.ts +87 -0
  96. package/src/lib/usage/claude-pricing.ts +71 -0
  97. package/src/lib/usage/claude.ts +189 -0
  98. package/src/lib/usage/collect.ts +56 -0
  99. package/src/lib/usage/opencode.ts +188 -0
  100. package/src/lib/usage/records.ts +80 -0
  101. package/src/lib/usage/rtk-database.ts +72 -0
  102. package/src/lib/usage/savings.ts +209 -0
  103. package/src/lib/usage/scope.ts +182 -0
  104. package/src/lib/usage/source.ts +102 -0
  105. package/src/lib/usage/types.ts +143 -0
  106. package/src/lib/usage/window.ts +37 -0
  107. package/src/lib/workset/factory-local.ts +157 -0
  108. package/src/lib/workset/record.ts +25 -11
  109. package/src/lib/workset/repositories.ts +118 -25
  110. package/src/lib/workset/worktree-include.ts +161 -0
  111. package/src/lib/workset/worktree-index.ts +6 -2
  112. package/src/lib/workset/worktree.ts +591 -101
  113. package/src/opencode/companion-hooks.ts +46 -8
  114. package/src/opencode/companion-policy.ts +18 -5
  115. package/src/opencode/enter-worktree.ts +254 -6
  116. package/src/opencode/session-register.ts +2 -2
  117. package/src/runtime/claude-bg-isolation.ts +138 -0
  118. package/src/runtime/companion-git.ts +10 -2
  119. package/src/runtime/companion-guidance.ts +17 -4
  120. package/src/runtime/current-branch.ts +16 -2
  121. package/src/runtime/entered-worktree.ts +24 -0
  122. package/src/runtime/git-tracked.ts +60 -0
  123. package/src/runtime/repo-destination.ts +72 -0
  124. package/src/runtime/repo-local.ts +25 -3
  125. package/src/runtime/rtk-git-guard.ts +66 -0
  126. package/src/runtime/runtime-document-manifest.ts +229 -19
  127. package/src/runtime/runtime-document-manifest.typecheck.ts +10 -0
  128. package/src/runtime/secret-guard.ts +9 -2
  129. package/src/runtime/secret-policy-weakening.ts +122 -0
  130. package/src/runtime/serving-claude-wrap.ts +15 -2
  131. package/src/runtime/umbrella-folder.ts +56 -0
  132. package/src/runtime/wrap-state.ts +5 -13
  133. package/src/studio.ts +37 -0
  134. package/src/templates/mate-skills/agents/mate-apply-change/SKILL.md +61 -6
  135. package/src/templates/mate-skills/agents/mate-explore-change/SKILL.md +8 -4
  136. package/src/templates/mate-skills/agents/mate-propose-change/SKILL.md +9 -5
  137. package/src/templates/mate-skills/agents/mate-publish-artifact/SKILL.md +5 -4
  138. package/src/templates/mate-skills/agents/mate-show-me/SKILL.md +10 -4
  139. package/src/templates/mate-skills/agents/mate-simplify-code/SKILL.md +5 -1
  140. package/src/templates/mate-skills/claude/mate-apply-change/SKILL.md +61 -6
  141. package/src/templates/mate-skills/claude/mate-explore-change/SKILL.md +8 -4
  142. package/src/templates/mate-skills/claude/mate-propose-change/SKILL.md +9 -5
  143. package/src/templates/mate-skills/claude/mate-publish-artifact/SKILL.md +5 -4
  144. package/src/templates/mate-skills/claude/mate-show-me/SKILL.md +10 -4
  145. package/src/templates/mate-skills/claude/mate-simplify-code/SKILL.md +5 -1
  146. package/src/tools/setup/__snapshots__/runtime-surface-golden.test.ts.snap +305 -42
  147. package/src/tools/setup/capabilities/rtk.ts +93 -1
  148. package/src/tools/setup/dynamic-plugins/audiences.ts +65 -21
  149. package/src/tools/setup/dynamic-plugins/frozen.ts +32 -13
  150. package/src/tools/setup/dynamic-plugins/hydrate.ts +4 -4
  151. package/src/tools/setup/dynamic-plugins/install.ts +24 -22
  152. package/src/tools/setup/dynamic-plugins/loader.ts +11 -7
  153. package/src/tools/setup/dynamic-plugins/paths.ts +30 -10
  154. package/src/tools/setup/dynamic-plugins/verify.ts +10 -7
  155. package/src/tools/setup/dynamic-plugins/workspaces.ts +153 -0
  156. package/src/tools/setup/mate.ts +3 -3
  157. package/src/tools/setup/plugins/gitignore.ts +15 -9
  158. package/src/tools/setup/providers/claude-plugin-hooks.ts +12 -0
  159. package/src/tools/setup/providers/claude.ts +25 -3
  160. package/src/tools/setup/utils.ts +4 -2
  161. package/src/tools/setup/working-repo-cleanup.ts +2 -2
  162. package/src/tools/setup.ts +25 -14
  163. package/studio-dist/client/assets/app-D9cw6szy.css +2 -0
  164. package/studio-dist/client/assets/artifacts-WD2ZXYrx.js +1 -0
  165. package/studio-dist/client/assets/button-Br0O1sXw.js +1 -0
  166. package/studio-dist/client/assets/combobox-DA7RAUUZ.js +1 -0
  167. package/studio-dist/client/assets/companion-view-CrabvxS8.js +1 -0
  168. package/studio-dist/client/assets/factory-DGS0E16C.js +6 -0
  169. package/studio-dist/client/assets/fields-6aXBpFhJ.js +1 -0
  170. package/studio-dist/client/assets/getting-started-Clde4w6P.js +1 -0
  171. package/studio-dist/client/assets/getting-started-D6kgWwWZ.js +1 -0
  172. package/studio-dist/client/assets/getting-started._topic-BiunccbT.js +1 -0
  173. package/studio-dist/client/assets/getting-started.index-DpiNoGw8.js +1 -0
  174. package/studio-dist/client/assets/graph-B_TCBVbu.js +2 -0
  175. package/studio-dist/client/assets/graph-canvas-Ba37Y5AE.js +3242 -0
  176. package/studio-dist/client/assets/guides-Du_RtJxP.js +1 -0
  177. package/studio-dist/client/assets/index-Df8L1LQa.js +40 -0
  178. package/studio-dist/client/assets/jsx-runtime-MZURdZre.js +1 -0
  179. package/studio-dist/client/assets/markdown-view-BOX6x0rL.js +1 -0
  180. package/studio-dist/client/assets/panel-dbmCx7Mx.js +1 -0
  181. package/studio-dist/client/assets/queries-RvHeXY12.js +1 -0
  182. package/studio-dist/client/assets/react-3QStrcDO.js +27 -0
  183. package/studio-dist/client/assets/report-url-XRL0x1SY.js +1 -0
  184. package/studio-dist/client/assets/reports-r3IK7Doz.js +1 -0
  185. package/studio-dist/client/assets/routes-C0A5LTFc.js +1 -0
  186. package/studio-dist/client/assets/select-CnaMd617.js +1 -0
  187. package/studio-dist/client/assets/skills-CzjzHpBT.js +1 -0
  188. package/studio-dist/client/assets/specs-B0ldF_6J.js +1 -0
  189. package/studio-dist/client/assets/specs-view-BnCLA0gW.js +1 -0
  190. package/studio-dist/client/assets/spinner-Dcm3fqK1.js +1 -0
  191. package/studio-dist/client/assets/steps-C0p2N1Pb.js +1 -0
  192. package/studio-dist/client/assets/store-Dw34catY.js +1 -0
  193. package/studio-dist/client/assets/studio-Cpz_HRHp.js +100 -0
  194. package/studio-dist/client/assets/studio-queries-ibmpFo6R.js +2 -0
  195. package/studio-dist/client/assets/usage-C2QJ_0IZ.js +55 -0
  196. package/studio-dist/client/assets/useAnchoredPopupScrollLock-Bj-FWb8z.js +1 -0
  197. package/studio-dist/client/assets/useMutation-aAr2uiay.js +1 -0
  198. package/studio-dist/client/assets/useSelector-AYcH7lB0.js +2 -0
  199. package/studio-dist/client/assets/vault-BGcxkSIY.js +1 -0
  200. package/studio-dist/client/assets/warnings-R1cE1rLf.js +1 -0
  201. package/studio-dist/client/assets/workflow-C2qTrMDH.js +1 -0
  202. package/studio-dist/server/assets/__23tanstack-start-server-fn-resolver-Bn896ZYj.js +122 -0
  203. package/studio-dist/server/assets/_tanstack-start-manifest_v.js +102 -35
  204. package/studio-dist/server/assets/{actions-Bvgj9eb8.js → actions-DYSv-9VV.js} +10 -4
  205. package/studio-dist/server/assets/artifacts-DnF9L3dZ.js +216 -0
  206. package/studio-dist/server/assets/{button-CIJqAhni.js → button-CgOIVdmD.js} +13 -1702
  207. package/studio-dist/server/assets/combobox-DV_s9W0s.js +483 -0
  208. package/studio-dist/server/assets/{companion-view-DISASvdJ.js → companion-view-BKVXD3TO.js} +3 -3
  209. package/studio-dist/server/assets/companions-C7fctnU9.js +31 -0
  210. package/studio-dist/server/assets/{createServerRpc-tK2lE9R2.js → createServerRpc-bFKFpGFG.js} +1 -1
  211. package/studio-dist/server/assets/{factory-DUTa0eDs.js → factory-C7Ybg0xG.js} +1256 -353
  212. package/studio-dist/server/assets/{factory-DGPmNGbo.js → factory-Df5uAHjb.js} +53 -6
  213. package/studio-dist/server/assets/fields-BbieQTD0.js +1190 -0
  214. package/studio-dist/server/assets/getting-started-B136TP57.js +4 -0
  215. package/studio-dist/server/assets/getting-started-CRxMWorQ.js +67 -0
  216. package/studio-dist/server/assets/getting-started._topic-DJKQAzYl.js +13 -0
  217. package/studio-dist/server/assets/getting-started.index-D84gec1t.js +13 -0
  218. package/studio-dist/server/assets/graph-CSje3029.js +801 -0
  219. package/studio-dist/server/assets/graph-DDZzXM1L.js +16 -0
  220. package/studio-dist/server/assets/graph-canvas-22bWB5-2.js +21066 -0
  221. package/studio-dist/server/assets/graph-wire-BdSUx0G5.js +58 -0
  222. package/studio-dist/server/assets/guides-D9dk1Frq.js +13 -0
  223. package/studio-dist/server/assets/guides-IE-19POz.js +5 -0
  224. package/studio-dist/server/assets/guides.server-vcYRY5wx.js +66 -0
  225. package/studio-dist/server/assets/jsx-runtime-Bt0s0YKS.js +451 -0
  226. package/studio-dist/server/assets/{markdown-view-Bn7xPdks.js → markdown-view-BR8dJ7aR.js} +28 -9
  227. package/studio-dist/server/assets/{panel-3Jmn4awF.js → panel-BR_t9iMM.js} +4 -4
  228. package/studio-dist/server/assets/queries-DWoTin-q.js +32 -0
  229. package/studio-dist/server/assets/react-CdqSUhaL.js +89 -0
  230. package/studio-dist/server/assets/redirect-BaZ_QyqF.js +39 -0
  231. package/studio-dist/server/assets/report-url-BUXPcE_8.js +9 -0
  232. package/studio-dist/server/assets/{reports-D6YMqhnO.js → reports-CQ9qQ1-n.js} +9 -10
  233. package/studio-dist/server/assets/{reports-C06RXVE2.js → reports-dYDEoBeq.js} +3 -3
  234. package/studio-dist/server/assets/{router-C8MGqlAY.js → router-DkRHNTpE.js} +787 -2862
  235. package/studio-dist/server/assets/{routes-BcFgvqf7.js → routes-B6GfOew4.js} +22 -171
  236. package/studio-dist/server/assets/{search-JAKurDNh.js → search-BJnWLfkG.js} +21 -2
  237. package/studio-dist/server/assets/select-Af7Wibii.js +1609 -0
  238. package/studio-dist/server/assets/{shell-DS3wUexh.js → shell-Hq-hXgnT.js} +6 -5
  239. package/studio-dist/server/assets/{skills-BEnOxiDl.js → skills-B7nEuVbx.js} +9 -8
  240. package/studio-dist/server/assets/{skills-CtrBAtX3.js → skills-B_YYL7q8.js} +3 -3
  241. package/studio-dist/server/assets/specs-BpLUFntA.js +51 -0
  242. package/studio-dist/server/assets/specs-view-0peMVd22.js +426 -0
  243. package/studio-dist/server/assets/spinner-CdwJW4VB.js +20 -0
  244. package/studio-dist/server/assets/{steps-Dq_CwY_s.js → steps-D56DApvK.js} +1 -1
  245. package/studio-dist/server/assets/store-Cs17okNG.js +280 -0
  246. package/studio-dist/server/assets/studio-CAcKp3bM.js +10340 -0
  247. package/studio-dist/server/assets/studio-queries-BtRGzDdh.js +1451 -0
  248. package/studio-dist/server/assets/usage-COdjd1gD.js +25570 -0
  249. package/studio-dist/server/assets/usage-f6pqE1tm.js +24 -0
  250. package/studio-dist/server/assets/useAnchoredPopupScrollLock-DlBKHRw7.js +756 -0
  251. package/studio-dist/server/assets/useMutation-DzTZGenE.js +690 -0
  252. package/studio-dist/server/assets/{__23tanstack-start-server-fn-resolver-M2GBs8s3.js → useSelector-DUmCUXAs.js} +4 -668
  253. package/studio-dist/server/assets/{vault-Fvxt2Tzl.js → vault-BDuIUq0F.js} +8 -5
  254. package/studio-dist/server/assets/{vault-BmWnryh3.js → vault-BVLp6zu3.js} +3 -3
  255. package/studio-dist/server/assets/{views-BgYa-za2.js → views-flRUr21z.js} +4 -4
  256. package/studio-dist/server/assets/{warnings-DzR6fyZh.js → warnings-CDy9pdgL.js} +3 -2
  257. package/studio-dist/server/assets/{delivery-path-C29fBynY.js → workflow-D9GKI2EV.js} +132 -106
  258. package/studio-dist/server/server.js +582 -8
  259. package/src/cli/commands/report/collector.ts +0 -288
  260. package/studio-dist/client/assets/app-CdPiFv59.css +0 -2
  261. package/studio-dist/client/assets/button-BIIHE0EQ.js +0 -3
  262. package/studio-dist/client/assets/companion-view-DM6YyXaR.js +0 -1
  263. package/studio-dist/client/assets/delivery-path-DELxj0Av.js +0 -1
  264. package/studio-dist/client/assets/factory-BZy0E8ty.js +0 -4
  265. package/studio-dist/client/assets/index-B3wkMzjA.js +0 -40
  266. package/studio-dist/client/assets/markdown-view-pQ2Qp_i5.js +0 -1
  267. package/studio-dist/client/assets/panel-CbajlC3p.js +0 -1
  268. package/studio-dist/client/assets/prepaint-CwSrpdFA.js +0 -27
  269. package/studio-dist/client/assets/react-CN2GSx7x.js +0 -1
  270. package/studio-dist/client/assets/reports-DllhYQ5_.js +0 -1
  271. package/studio-dist/client/assets/rolldown-runtime-WkwZ5CU-.js +0 -1
  272. package/studio-dist/client/assets/routes-COm-G3mK.js +0 -1
  273. package/studio-dist/client/assets/skills-DmWAy-jZ.js +0 -1
  274. package/studio-dist/client/assets/specs-BG3Wi3ln.js +0 -1
  275. package/studio-dist/client/assets/steps-DFsH3Neu.js +0 -1
  276. package/studio-dist/client/assets/vault-B2q1nBY5.js +0 -1
  277. package/studio-dist/client/assets/warnings-BSXIyuSQ.js +0 -1
  278. package/studio-dist/client/assets/workflow-DlsQD6Hc.js +0 -1
  279. package/studio-dist/server/assets/companions-BYbHWKOZ.js +0 -15
  280. package/studio-dist/server/assets/createServerFn-F5sAOF8V.js +0 -459
  281. package/studio-dist/server/assets/prepaint-DJfTQ_VH.js +0 -45
  282. package/studio-dist/server/assets/react-Ce6dj15C.js +0 -46
  283. package/studio-dist/server/assets/rolldown-runtime-DYf_mQCB.js +0 -34
  284. package/studio-dist/server/assets/specs-C8rv34-5.js +0 -211
  285. package/studio-dist/server/assets/studio-BeltxxKt.js +0 -216
  286. package/studio-dist/server/assets/workflow-liRYecHk.js +0 -73
@@ -0,0 +1,1451 @@
1
+ import { n as require_react, o as __toESM, t as require_jsx_runtime } from "./jsx-runtime-Bt0s0YKS.js";
2
+ import { C as rootRouteId, S as trimPathRight, _ as invariant, a as useRouter, b as removeTrailingSlash, x as trimPathLeft, y as cleanPath } from "./useSelector-DUmCUXAs.js";
3
+ import { r as redirect } from "./redirect-BaZ_QyqF.js";
4
+ import { a as deepEqual, c as functionalUpdate$1, f as isDangerousProtocol, l as getUrlScheme, p as isModuleNotFoundError } from "./utils-C9CX1kcy.js";
5
+ import { i as reactUse, n as useMatch, t as getServerFnById } from "./__23tanstack-start-server-fn-resolver-Bn896ZYj.js";
6
+ import { n as createServerFn, r as TSS_SERVER_FUNCTION } from "../server.js";
7
+ import { u as COMPANION_DIGEST_PATTERN } from "./studio-CAcKp3bM.js";
8
+ import { t as OUTCOME_ACTIONS } from "./actions-DYSv-9VV.js";
9
+ import { n as unpackGraph } from "./graph-wire-BdSUx0G5.js";
10
+ import { r as validateStudioSearch } from "./search-BJnWLfkG.js";
11
+ // ../../node_modules/.bun/@tanstack+router-core@1.171.39/node_modules/@tanstack/router-core/dist/esm/route.js
12
+ var BaseRoute = class {
13
+ get to() {
14
+ return this._to;
15
+ }
16
+ get id() {
17
+ return this._id;
18
+ }
19
+ get path() {
20
+ return this._path;
21
+ }
22
+ get fullPath() {
23
+ return this._fullPath;
24
+ }
25
+ constructor(options) {
26
+ this.init = (originalIndex) => {
27
+ this.originalIndex = originalIndex;
28
+ this._branch = void 0;
29
+ const options = this.options;
30
+ const isRoot = !options?.path && !options?.id;
31
+ this.parentRoute = this.options.getParentRoute?.();
32
+ if (isRoot) this._path = rootRouteId;
33
+ else if (!this.parentRoute) invariant();
34
+ let path = isRoot ? rootRouteId : options?.path;
35
+ if (path && path !== "/") path = trimPathLeft(path);
36
+ const customId = options?.id || path;
37
+ const id = isRoot ? rootRouteId : cleanPath((this.parentRoute.id === "__root__" ? "" : this.parentRoute.id) + "/" + (customId ?? ""));
38
+ if (path === "__root__") path = "/";
39
+ const fullPath = id === "__root__" ? "/" : path === void 0 ? this.parentRoute.fullPath : cleanPath(this.parentRoute.fullPath + "/" + path);
40
+ this._path = path;
41
+ this._id = id;
42
+ this._fullPath = fullPath;
43
+ this._to = trimPathRight(fullPath);
44
+ };
45
+ this.addChildren = (children) => {
46
+ return this._addFileChildren(children);
47
+ };
48
+ this._addFileChildren = (children) => {
49
+ if (Array.isArray(children)) this.children = children;
50
+ if (typeof children === "object" && children !== null) this.children = Object.values(children);
51
+ return this;
52
+ };
53
+ this._addFileTypes = () => {
54
+ return this;
55
+ };
56
+ this.updateLoader = (options) => {
57
+ Object.assign(this.options, options);
58
+ return this;
59
+ };
60
+ this.update = (options) => {
61
+ Object.assign(this.options, options);
62
+ return this;
63
+ };
64
+ this.lazy = (lazyFn) => {
65
+ this.lazyFn = lazyFn;
66
+ return this;
67
+ };
68
+ this.redirect = (opts) => redirect({
69
+ from: this.fullPath,
70
+ ...opts
71
+ });
72
+ this.options = options || {};
73
+ this.isRoot = !options?.getParentRoute;
74
+ if (options?.id && options?.path) throw new Error(`Route cannot have both an 'id' and a 'path' option.`);
75
+ }
76
+ };
77
+ var BaseRootRoute = class extends BaseRoute {
78
+ constructor(options) {
79
+ super(options);
80
+ }
81
+ };
82
+ // ../../node_modules/.bun/@tanstack+react-router@1.170.46+7492c01c6988791b/node_modules/@tanstack/react-router/dist/esm/useLoaderData.js
83
+ /**
84
+ * Read and select the current route's loader data with type‑safety.
85
+ *
86
+ * Options:
87
+ * - `from`/`strict`: Choose which route's data to read and strictness
88
+ * - `select`: Map the loader data to a derived value
89
+ * - `structuralSharing`: Enable structural sharing for stable references
90
+ *
91
+ * @returns The loader data (or selected value) for the matched route.
92
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useLoaderDataHook
93
+ */
94
+ function useLoaderData(opts) {
95
+ return useMatch({
96
+ from: opts.from,
97
+ strict: opts.strict,
98
+ structuralSharing: opts.structuralSharing,
99
+ select: (match) => {
100
+ return opts.select ? opts.select(match.loaderData) : match.loaderData;
101
+ }
102
+ });
103
+ }
104
+ // ../../node_modules/.bun/@tanstack+react-router@1.170.46+7492c01c6988791b/node_modules/@tanstack/react-router/dist/esm/useLoaderDeps.js
105
+ /**
106
+ * Read and select the current route's loader dependencies object.
107
+ *
108
+ * Options:
109
+ * - `from`: Choose which route's loader deps to read
110
+ * - `select`: Map the deps to a derived value
111
+ * - `structuralSharing`: Enable structural sharing for stable references
112
+ *
113
+ * @returns The loader deps (or selected value) for the matched route.
114
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useLoaderDepsHook
115
+ */
116
+ function useLoaderDeps(opts) {
117
+ const { select, ...rest } = opts;
118
+ return useMatch({
119
+ ...rest,
120
+ select: (match) => {
121
+ return select ? select(match.loaderDeps) : match.loaderDeps;
122
+ }
123
+ });
124
+ }
125
+ // ../../node_modules/.bun/@tanstack+react-router@1.170.46+7492c01c6988791b/node_modules/@tanstack/react-router/dist/esm/useParams.js
126
+ /**
127
+ * Access the current route's path parameters with type-safety.
128
+ *
129
+ * Options:
130
+ * - `from`/`strict`: Specify the matched route and whether to enforce strict typing
131
+ * - `select`: Project the params object to a derived value for memoized renders
132
+ * - `structuralSharing`: Enable structural sharing for stable references
133
+ * - `shouldThrow`: Throw if the route is not found in strict contexts
134
+ *
135
+ * @returns The params object (or selected value) for the matched route.
136
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useParamsHook
137
+ */
138
+ function useParams(opts) {
139
+ return useMatch({
140
+ from: opts.from,
141
+ shouldThrow: opts.shouldThrow,
142
+ structuralSharing: opts.structuralSharing,
143
+ strict: opts.strict,
144
+ select: (match) => {
145
+ const params = opts.strict === false ? match.params : match._strictParams;
146
+ return opts.select ? opts.select(params) : params;
147
+ }
148
+ });
149
+ }
150
+ // ../../node_modules/.bun/@tanstack+react-router@1.170.46+7492c01c6988791b/node_modules/@tanstack/react-router/dist/esm/useSearch.js
151
+ /**
152
+ * Read and select the current route's search parameters with type-safety.
153
+ *
154
+ * Options:
155
+ * - `from`/`strict`: Control which route's search is read and how strictly it's typed
156
+ * - `select`: Map the search object to a derived value for render optimization
157
+ * - `structuralSharing`: Enable structural sharing for stable references
158
+ * - `shouldThrow`: Throw when the route is not found (strict contexts)
159
+ *
160
+ * @returns The search object (or selected value) for the matched route.
161
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useSearchHook
162
+ */
163
+ function useSearch(opts) {
164
+ return useMatch({
165
+ from: opts.from,
166
+ strict: opts.strict,
167
+ shouldThrow: opts.shouldThrow,
168
+ structuralSharing: opts.structuralSharing,
169
+ select: (match) => {
170
+ return opts.select ? opts.select(match.search) : match.search;
171
+ }
172
+ });
173
+ }
174
+ // ../../node_modules/.bun/@tanstack+react-router@1.170.46+7492c01c6988791b/node_modules/@tanstack/react-router/dist/esm/useNavigate.js
175
+ var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
176
+ /**
177
+ * Imperative navigation hook.
178
+ *
179
+ * Returns a stable `navigate(options)` function to change the current location
180
+ * programmatically. Prefer the `Link` component for user-initiated navigation,
181
+ * and use this hook from effects, callbacks, or handlers where imperative
182
+ * navigation is required.
183
+ *
184
+ * Options:
185
+ * - `from`: Optional route base used to resolve relative `to` paths.
186
+ *
187
+ * @returns A function that accepts `NavigateOptions`.
188
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useNavigateHook
189
+ */
190
+ function useNavigate(_defaultOpts) {
191
+ const router = useRouter();
192
+ return import_react.useCallback((options) => {
193
+ return router.navigate({
194
+ ...options,
195
+ from: options.from ?? _defaultOpts?.from
196
+ });
197
+ }, [_defaultOpts?.from, router]);
198
+ }
199
+ // ../../node_modules/.bun/@tanstack+react-router@1.170.46+7492c01c6988791b/node_modules/@tanstack/react-router/dist/esm/useRouteContext.js
200
+ function useRouteContext(opts) {
201
+ return useMatch({
202
+ ...opts,
203
+ select: (match) => opts.select ? opts.select(match.context) : match.context
204
+ });
205
+ }
206
+ // ../../node_modules/.bun/@tanstack+react-router@1.170.46+7492c01c6988791b/node_modules/@tanstack/react-router/dist/esm/link.js
207
+ var import_jsx_runtime = require_jsx_runtime();
208
+ function resolveExternalLink(to, protocolAllowlist) {
209
+ const scheme = typeof to === "string" && getUrlScheme(to);
210
+ if (!scheme) return;
211
+ if (!protocolAllowlist.has(scheme)) return null;
212
+ return to;
213
+ }
214
+ function resolveIsActive(location, next, activeOptions, basepath) {
215
+ const currentPath = removeTrailingSlash(location.pathname, basepath);
216
+ const nextPath = removeTrailingSlash(next.pathname, basepath);
217
+ if (activeOptions?.exact ? currentPath !== nextPath : !(currentPath.startsWith(nextPath) && (currentPath.length === nextPath.length || currentPath[nextPath.length] === "/"))) return false;
218
+ if (activeOptions?.includeSearch ?? true) {
219
+ if (!deepEqual(location.search, next.search, !activeOptions?.exact, activeOptions?.explicitUndefined)) return false;
220
+ }
221
+ return !activeOptions?.includeHash || location.hash === next.hash;
222
+ }
223
+ function useLinkProps(options, forwardedRef, host) {
224
+ return getServerLinkProps(useRouter(), options, forwardedRef, host);
225
+ }
226
+ var STATIC_EMPTY_OBJECT = {};
227
+ var STATIC_ACTIVE_OBJECT = { className: "active" };
228
+ var ROUTER_OPTION_KEYS = /* @__PURE__ */ new Set([
229
+ "to",
230
+ "params",
231
+ "search",
232
+ "hash",
233
+ "state",
234
+ "mask",
235
+ "from",
236
+ "unsafeRelative",
237
+ "reloadDocument",
238
+ "preload",
239
+ "preloadDelay",
240
+ "preloadIntentProximity",
241
+ "hashScrollIntoView",
242
+ "replace",
243
+ "startTransition",
244
+ "resetScroll",
245
+ "viewTransition",
246
+ "ignoreBlocker",
247
+ "activeProps",
248
+ "inactiveProps",
249
+ "activeOptions",
250
+ "_asChild"
251
+ ]);
252
+ function collectElementProps(options, host) {
253
+ const props = {};
254
+ for (const key in options) {
255
+ if (ROUTER_OPTION_KEYS.has(key) || key === "type" && host !== void 0 || key === "disabled" && host === "a") continue;
256
+ props[key] = options[key];
257
+ }
258
+ return props;
259
+ }
260
+ function applyLinkState(props, options, isActive, href, linkDisabled, host) {
261
+ const { activeProps, inactiveProps, className, style, target } = options;
262
+ const stateProps = functionalUpdate$1(isActive ? activeProps : inactiveProps, {}) ?? (isActive ? STATIC_ACTIVE_OBJECT : STATIC_EMPTY_OBJECT);
263
+ Object.assign(props, stateProps);
264
+ props.href = href;
265
+ if (host !== "a") props.disabled = linkDisabled;
266
+ props.target = target;
267
+ const stateStyle = stateProps.style;
268
+ if (style || stateStyle) props.style = style && stateStyle ? {
269
+ ...style,
270
+ ...stateStyle
271
+ } : style || stateStyle;
272
+ const stateClassName = stateProps.className;
273
+ if (className || stateClassName) props.className = className ? stateClassName ? `${className} ${stateClassName}` : className : stateClassName;
274
+ if (linkDisabled) {
275
+ props.role = "link";
276
+ props["aria-disabled"] = true;
277
+ }
278
+ if (isActive) {
279
+ props["data-status"] = "active";
280
+ props["aria-current"] = "page";
281
+ }
282
+ return props;
283
+ }
284
+ function getServerLinkProps(router, options, forwardedRef, host) {
285
+ const { to, disabled, activeOptions } = options;
286
+ const directExternalLink = resolveExternalLink(to, router.protocolAllowlist);
287
+ const next = directExternalLink === void 0 ? router.buildLocation(options) : void 0;
288
+ const hrefOption = next ? getHrefOption(next, router, disabled) : directExternalLink ?? void 0;
289
+ const linkDisabled = disabled || !hrefOption;
290
+ const externalLink = directExternalLink ?? (hrefOption && getUrlScheme(hrefOption) ? hrefOption : void 0);
291
+ const props = collectElementProps(options, host);
292
+ props.ref = forwardedRef;
293
+ if (externalLink) {
294
+ props.href = externalLink;
295
+ return props;
296
+ }
297
+ return applyLinkState(props, options, !!next && !(!disabled && !hrefOption) && !activeOptions?.includeHash && resolveIsActive(router.stores.location.get(), next, activeOptions, router.basepath), hrefOption, linkDisabled, host);
298
+ }
299
+ function getHrefOption(next, router, disabled) {
300
+ if (disabled) return;
301
+ const location = next.maskedLocation ?? next;
302
+ const href = location.external ? location.publicHref : router.history.createHref(location.publicHref) || "/";
303
+ if ((location.external || href !== location.publicHref) && isDangerousProtocol(href, router.protocolAllowlist)) return;
304
+ return href;
305
+ }
306
+ /**
307
+ * A strongly-typed anchor component for declarative navigation.
308
+ * Handles path, search, hash and state updates with optional route preloading
309
+ * and active-state styling.
310
+ *
311
+ * Props:
312
+ * - `preload`: Controls route preloading (eg. 'intent', 'render', 'viewport', true/false)
313
+ * - `preloadDelay`: Delay in ms before preloading on focus, hover, or viewport entry
314
+ * - `activeProps`/`inactiveProps`: Additional props merged when link is active/inactive
315
+ * - `resetScroll`/`hashScrollIntoView`: Control scroll behavior on navigation
316
+ * - `viewTransition`/`startTransition`: Use View Transitions/React transitions for navigation
317
+ * - `ignoreBlocker`: Bypass registered blockers
318
+ *
319
+ * @returns An anchor-like element that navigates without full page reloads.
320
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/linkComponent
321
+ */
322
+ var Link = import_react.memo(import_react.forwardRef((props, ref) => {
323
+ const host = props._asChild || "a";
324
+ const linkProps = useLinkProps(props, ref, host);
325
+ const children = typeof props.children === "function" ? props.children({ isActive: linkProps["data-status"] === "active" }) : props.children;
326
+ return import_react.createElement(host, linkProps, children);
327
+ }), areLinkPropsEqual);
328
+ function areLinkPropsEqual(prev, next) {
329
+ let extraKeys = 0;
330
+ for (const key in next) {
331
+ extraKeys++;
332
+ if (prev[key] === next[key]) continue;
333
+ if (!ROUTER_OPTION_KEYS.has(key) || !deepEqual(prev[key], next[key], false, true)) return false;
334
+ }
335
+ for (const _key in prev) extraKeys--;
336
+ return extraKeys === 0;
337
+ }
338
+ // ../../node_modules/.bun/@tanstack+react-router@1.170.46+7492c01c6988791b/node_modules/@tanstack/react-router/dist/esm/route.js
339
+ var Route = class extends BaseRoute {
340
+ /**
341
+ * @deprecated Use the `createRoute` function instead.
342
+ */
343
+ constructor(options) {
344
+ super(options);
345
+ this.useMatch = (opts) => {
346
+ return useMatch({
347
+ ...opts,
348
+ from: this.id
349
+ });
350
+ };
351
+ this.useRouteContext = (opts) => {
352
+ return useRouteContext({
353
+ ...opts,
354
+ from: this.id
355
+ });
356
+ };
357
+ this.useSearch = (opts) => {
358
+ return useSearch({
359
+ ...opts,
360
+ from: this.id
361
+ });
362
+ };
363
+ this.useParams = (opts) => {
364
+ return useParams({
365
+ ...opts,
366
+ from: this.id
367
+ });
368
+ };
369
+ this.useLoaderDeps = (opts) => {
370
+ return useLoaderDeps({
371
+ ...opts,
372
+ from: this.id
373
+ });
374
+ };
375
+ this.useLoaderData = (opts) => {
376
+ return useLoaderData({
377
+ ...opts,
378
+ from: this.id
379
+ });
380
+ };
381
+ this.useNavigate = () => {
382
+ return useNavigate({ from: this.fullPath });
383
+ };
384
+ this.Link = import_react.forwardRef((props, ref) => {
385
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Link, {
386
+ ref,
387
+ from: this.fullPath,
388
+ ...props
389
+ });
390
+ });
391
+ }
392
+ };
393
+ /**
394
+ * Creates a non-root Route instance for code-based routing.
395
+ *
396
+ * Use this to define a route that will be composed into a route tree
397
+ * (typically via a parent route's `addChildren`). If you're using file-based
398
+ * routing, prefer `createFileRoute`.
399
+ *
400
+ * @param options Route options (path, component, loader, context, etc.).
401
+ * @returns A Route instance to be attached to the route tree.
402
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRouteFunction
403
+ */
404
+ function createRoute(options) {
405
+ return new Route(options);
406
+ }
407
+ /**
408
+ * Creates a root route factory that requires a router context type.
409
+ *
410
+ * Use when your root route expects `context` to be provided to `createRouter`.
411
+ * The returned function behaves like `createRootRoute` but enforces a context type.
412
+ *
413
+ * @returns A factory function to configure and return a root route.
414
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRootRouteWithContextFunction
415
+ */
416
+ function createRootRouteWithContext() {
417
+ return (options) => {
418
+ return createRootRoute(options);
419
+ };
420
+ }
421
+ var RootRoute = class extends BaseRootRoute {
422
+ /**
423
+ * @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.
424
+ */
425
+ constructor(options) {
426
+ super(options);
427
+ this.useMatch = (opts) => {
428
+ return useMatch({
429
+ ...opts,
430
+ from: this.id
431
+ });
432
+ };
433
+ this.useRouteContext = (opts) => {
434
+ return useRouteContext({
435
+ ...opts,
436
+ from: this.id
437
+ });
438
+ };
439
+ this.useSearch = (opts) => {
440
+ return useSearch({
441
+ ...opts,
442
+ from: this.id
443
+ });
444
+ };
445
+ this.useParams = (opts) => {
446
+ return useParams({
447
+ ...opts,
448
+ from: this.id
449
+ });
450
+ };
451
+ this.useLoaderDeps = (opts) => {
452
+ return useLoaderDeps({
453
+ ...opts,
454
+ from: this.id
455
+ });
456
+ };
457
+ this.useLoaderData = (opts) => {
458
+ return useLoaderData({
459
+ ...opts,
460
+ from: this.id
461
+ });
462
+ };
463
+ this.useNavigate = () => {
464
+ return useNavigate({ from: this.fullPath });
465
+ };
466
+ this.Link = import_react.forwardRef((props, ref) => {
467
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Link, {
468
+ ref,
469
+ from: this.fullPath,
470
+ ...props
471
+ });
472
+ });
473
+ }
474
+ };
475
+ /**
476
+ * Creates a root Route instance used to build your route tree.
477
+ *
478
+ * Typically paired with `createRouter({ routeTree })`. If you need to require
479
+ * a typed router context, use `createRootRouteWithContext` instead.
480
+ *
481
+ * @param options Root route options (component, error, pending, etc.).
482
+ * @returns A root route instance.
483
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRootRouteFunction
484
+ */
485
+ function createRootRoute(options) {
486
+ return new RootRoute(options);
487
+ }
488
+ // ../../node_modules/.bun/@tanstack+react-router@1.170.46+7492c01c6988791b/node_modules/@tanstack/react-router/dist/esm/fileRoute.js
489
+ /**
490
+ * Creates a file-based Route factory for a given path.
491
+ *
492
+ * Used by TanStack Router's file-based routing to associate a file with a
493
+ * route. The returned function accepts standard route options. In normal usage
494
+ * the `path` string is inserted and maintained by the `tsr` generator.
495
+ *
496
+ * @param path File path literal for the route (usually auto-generated).
497
+ * @returns A function that accepts Route options and returns a Route instance.
498
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createFileRouteFunction
499
+ */
500
+ function createFileRoute(path) {
501
+ return (options) => {
502
+ const route = createRoute(options);
503
+ route.isRoot = false;
504
+ return route;
505
+ };
506
+ }
507
+ // ../../node_modules/.bun/@tanstack+react-router@1.170.46+7492c01c6988791b/node_modules/@tanstack/react-router/dist/esm/lazyRouteComponent.js
508
+ /**
509
+ * Wrap a dynamic import to create a route component that supports
510
+ * `.preload()` and friendly reload-on-module-missing behavior.
511
+ *
512
+ * @param importer Function returning a module promise
513
+ * @param exportName Named export to use (default: `default`)
514
+ * @returns A lazy route component compatible with TanStack Router
515
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/lazyRouteComponentFunction
516
+ */
517
+ function lazyRouteComponent(importer, exportName) {
518
+ let loadPromise;
519
+ let comp;
520
+ let error;
521
+ const load = () => {
522
+ if (!loadPromise) {
523
+ error = void 0;
524
+ loadPromise = importer().then((res) => {
525
+ comp = res[exportName ?? "default"];
526
+ }).catch((err) => {
527
+ loadPromise = void 0;
528
+ error = err;
529
+ });
530
+ }
531
+ return loadPromise;
532
+ };
533
+ const lazyComp = function Lazy(props) {
534
+ if (error) {
535
+ if (isModuleNotFoundError(error) && false);
536
+ throw error;
537
+ }
538
+ if (!comp) {
539
+ if (reactUse) reactUse(load());
540
+ else throw load();
541
+ }
542
+ return import_react.createElement(comp, props);
543
+ };
544
+ lazyComp.preload = load;
545
+ return lazyComp;
546
+ }
547
+ // ../../node_modules/.bun/@tanstack+query-core@5.105.3/node_modules/@tanstack/query-core/build/modern/timeoutManager.js
548
+ var defaultTimeoutProvider = {
549
+ setTimeout: (callback, delay) => setTimeout(callback, delay),
550
+ clearTimeout: (timeoutId) => clearTimeout(timeoutId),
551
+ setInterval: (callback, delay) => setInterval(callback, delay),
552
+ clearInterval: (intervalId) => clearInterval(intervalId)
553
+ };
554
+ /**
555
+ * Allows customization of how timeouts are created.
556
+ *
557
+ * `@tanstack/query-core` makes liberal use of timeouts to implement `staleTime`
558
+ * and `gcTime`. The default TimeoutManager provider uses the platform's global
559
+ * `setTimeout` implementation, which is known to have scalability issues with
560
+ * thousands of timeouts on the event loop.
561
+ *
562
+ * If you hit this limitation, consider providing a custom TimeoutProvider that
563
+ * coalesces timeouts.
564
+ */
565
+ var TimeoutManager = class {
566
+ #provider = defaultTimeoutProvider;
567
+ #providerCalled = false;
568
+ /**
569
+ * `setTimeoutProvider` can be used to set a custom implementation of the
570
+ * `setTimeout`, `clearTimeout`, `setInterval`, `clearInterval` functions,
571
+ * called a `TimeoutProvider`.
572
+ *
573
+ * This may be useful if you notice event loop performance issues with
574
+ * thousands of queries. A custom TimeoutProvider could also support timer
575
+ * delays longer than the global `setTimeout` maximum delay value of about
576
+ * 24 days.
577
+ *
578
+ * It is important to call `setTimeoutProvider` before creating a
579
+ * QueryClient or queries, so that the same provider is used consistently
580
+ * for all timers in the application, since different TimeoutProviders
581
+ * cannot cancel each others' timers.
582
+ * @param provider - The `TimeoutProvider` to use for all timers from now on.
583
+ * @example
584
+ * ```ts
585
+ * import { timeoutManager, QueryClient } from '@tanstack/query-core'
586
+ * import { CustomTimeoutProvider } from './CustomTimeoutProvider'
587
+ *
588
+ * timeoutManager.setTimeoutProvider(new CustomTimeoutProvider())
589
+ *
590
+ * export const queryClient = new QueryClient()
591
+ * ```
592
+ */
593
+ setTimeoutProvider(provider) {
594
+ this.#provider = provider;
595
+ }
596
+ /**
597
+ * `setTimeout` schedules a callback to run after approximately `delay`
598
+ * milliseconds, like the global `setTimeout` function. The callback can be
599
+ * canceled with `clearTimeout`.
600
+ *
601
+ * It returns a timer ID, which may be a number or an object that can be
602
+ * coerced to a number via `Symbol.toPrimitive`.
603
+ * @param callback - The function to call when the timeout elapses.
604
+ * @param delay - The time to wait before calling `callback`, in milliseconds.
605
+ * @returns The timer ID, to pass to {@link TimeoutManager#clearTimeout}.
606
+ * @example
607
+ * ```ts
608
+ * import { timeoutManager } from '@tanstack/query-core'
609
+ *
610
+ * const timeoutId = timeoutManager.setTimeout(
611
+ * () => console.log('ran at:', new Date()),
612
+ * 1000,
613
+ * )
614
+ *
615
+ * const timeoutIdNumber: number = Number(timeoutId)
616
+ * ```
617
+ */
618
+ setTimeout(callback, delay) {
619
+ return this.#provider.setTimeout(callback, delay);
620
+ }
621
+ /**
622
+ * `clearTimeout` cancels a timeout callback scheduled with `setTimeout`,
623
+ * like the global `clearTimeout` function. It should be called with a
624
+ * timer ID returned by `setTimeout`.
625
+ * @param timeoutId - The timer ID returned by `setTimeout`, or `undefined`.
626
+ * @example
627
+ * ```ts
628
+ * import { timeoutManager } from '@tanstack/query-core'
629
+ *
630
+ * const timeoutId = timeoutManager.setTimeout(
631
+ * () => console.log('ran at:', new Date()),
632
+ * 1000,
633
+ * )
634
+ *
635
+ * timeoutManager.clearTimeout(timeoutId)
636
+ * ```
637
+ */
638
+ clearTimeout(timeoutId) {
639
+ this.#provider.clearTimeout(timeoutId);
640
+ }
641
+ /**
642
+ * `setInterval` schedules a callback to be called approximately every
643
+ * `delay` milliseconds, like the global `setInterval` function.
644
+ *
645
+ * Like `setTimeout`, it returns a timer ID, which may be a number or an
646
+ * object that can be coerced to a number via `Symbol.toPrimitive`.
647
+ * @param callback - The function to call on every interval.
648
+ * @param delay - The time between calls, in milliseconds.
649
+ * @returns The timer ID, to pass to {@link TimeoutManager#clearInterval}.
650
+ * @example
651
+ * ```ts
652
+ * import { timeoutManager } from '@tanstack/query-core'
653
+ *
654
+ * const intervalId = timeoutManager.setInterval(
655
+ * () => console.log('ran at:', new Date()),
656
+ * 1000,
657
+ * )
658
+ * ```
659
+ */
660
+ setInterval(callback, delay) {
661
+ return this.#provider.setInterval(callback, delay);
662
+ }
663
+ /**
664
+ * `clearInterval` can be used to cancel an interval, like the global
665
+ * `clearInterval` function. It should be called with an interval ID
666
+ * returned by `setInterval`.
667
+ * @param intervalId - The timer ID returned by `setInterval`, or `undefined`.
668
+ * @example
669
+ * ```ts
670
+ * import { timeoutManager } from '@tanstack/query-core'
671
+ *
672
+ * const intervalId = timeoutManager.setInterval(
673
+ * () => console.log('ran at:', new Date()),
674
+ * 1000,
675
+ * )
676
+ *
677
+ * timeoutManager.clearInterval(intervalId)
678
+ * ```
679
+ */
680
+ clearInterval(intervalId) {
681
+ this.#provider.clearInterval(intervalId);
682
+ }
683
+ };
684
+ /**
685
+ * Singleton instance of {@link TimeoutManager}, used throughout TanStack Query to schedule and cancel timers.
686
+ */
687
+ var timeoutManager = new TimeoutManager();
688
+ /**
689
+ * In many cases code wants to delay to the next event loop tick; this is not
690
+ * mediated by {@link timeoutManager}.
691
+ *
692
+ * This function is provided to make auditing the `tanstack/query-core` for
693
+ * incorrect use of system `setTimeout` easier.
694
+ * @param callback - The function to call on the next event loop tick.
695
+ */
696
+ function systemSetTimeoutZero(callback) {
697
+ setTimeout(callback, 0);
698
+ }
699
+ // ../../node_modules/.bun/@tanstack+query-core@5.105.3/node_modules/@tanstack/query-core/build/modern/utils.js
700
+ /**
701
+ * @deprecated use `environmentManager.isServer()` instead.
702
+ */
703
+ var isServer = typeof window === "undefined" || "Deno" in globalThis;
704
+ function noop() {}
705
+ /**
706
+ * Resolves an {@link Updater}: calls it with `input` if it is a function, otherwise returns it as
707
+ * is.
708
+ * @param updater - The new value, or a function that receives `input` and returns the new value.
709
+ * @param input - The current value, passed to `updater` if it is a function.
710
+ * @returns The new value.
711
+ */
712
+ function functionalUpdate(updater, input) {
713
+ return typeof updater === "function" ? updater(input) : updater;
714
+ }
715
+ /**
716
+ * Checks whether a value can be used as a timeout: a non-negative, finite number.
717
+ * @param value - The value to check.
718
+ * @returns `true` if `value` is a number that is `>= 0` and not `Infinity`.
719
+ */
720
+ function isValidTimeout(value) {
721
+ return typeof value === "number" && value >= 0 && value !== Infinity;
722
+ }
723
+ /**
724
+ * Calculates how long until data updated at `updatedAt` becomes stale.
725
+ * @param updatedAt - The timestamp, in milliseconds, at which the data was last updated.
726
+ * @param staleTime - The time, in milliseconds, after which data is considered stale. Defaults to
727
+ * `0`.
728
+ * @returns The remaining time in milliseconds, or `0` if the data is already stale.
729
+ */
730
+ function timeUntilStale(updatedAt, staleTime) {
731
+ return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0);
732
+ }
733
+ /**
734
+ * Resolves an option that can be given either as a value or as a function of the query, such as
735
+ * `staleTime`.
736
+ * @param value - The option value, or a function that receives `query` and returns the value.
737
+ * @param query - The query passed to `value` if it is a function.
738
+ * @returns The resolved value, or `undefined` if `value` is `undefined`.
739
+ */
740
+ function resolveQueryValue(value, query) {
741
+ return typeof value === "function" ? value(query) : value;
742
+ }
743
+ /**
744
+ * Checks whether a query matches the given {@link QueryFilters}.
745
+ * Every filter that is specified must match; filters that are left unspecified are ignored.
746
+ * @param filters - The filters to check the query against.
747
+ * @param query - The query to check.
748
+ * @returns `true` if the query matches every specified filter.
749
+ * @example
750
+ * ```ts
751
+ * const queryCache = queryClient.getQueryCache()
752
+ *
753
+ * const matchingQueries = queryCache
754
+ * .getAll()
755
+ * .filter((query) => matchQuery({ queryKey: ['posts'] }, query))
756
+ * ```
757
+ */
758
+ function matchQuery(filters, query) {
759
+ const { type = "all", exact, fetchStatus, predicate, queryKey, stale } = filters;
760
+ if (queryKey) {
761
+ if (exact) {
762
+ if (query.queryHash !== hashQueryKeyByOptions(queryKey, query.options)) return false;
763
+ } else if (!partialMatchKey(query.queryKey, queryKey)) return false;
764
+ }
765
+ if (type !== "all") {
766
+ const isActive = query.isActive();
767
+ if (type === "active" && !isActive) return false;
768
+ if (type === "inactive" && isActive) return false;
769
+ }
770
+ if (typeof stale === "boolean" && query.isStale() !== stale) return false;
771
+ if (fetchStatus && fetchStatus !== query.state.fetchStatus) return false;
772
+ if (predicate && !predicate(query)) return false;
773
+ return true;
774
+ }
775
+ /**
776
+ * Checks whether a mutation matches the given {@link MutationFilters}.
777
+ * Every filter that is specified must match; filters that are left unspecified are ignored.
778
+ * If a `mutationKey` filter is provided but the mutation has no `mutationKey` of its own, it does not match.
779
+ * @param filters - The filters to check the mutation against.
780
+ * @param mutation - The mutation to check.
781
+ * @returns `true` if the mutation matches every specified filter.
782
+ * @example
783
+ * ```ts
784
+ * const mutationCache = queryClient.getMutationCache()
785
+ *
786
+ * const matchingMutations = mutationCache
787
+ * .getAll()
788
+ * .filter((mutation) => matchMutation({ mutationKey: ['addPost'] }, mutation))
789
+ * ```
790
+ */
791
+ function matchMutation(filters, mutation) {
792
+ const { exact, status, predicate, mutationKey } = filters;
793
+ if (mutationKey) {
794
+ if (!mutation.options.mutationKey) return false;
795
+ if (exact) {
796
+ if (hashKey(mutation.options.mutationKey) !== hashKey(mutationKey)) return false;
797
+ } else if (!partialMatchKey(mutation.options.mutationKey, mutationKey)) return false;
798
+ }
799
+ if (status && mutation.state.status !== status) return false;
800
+ if (predicate && !predicate(mutation)) return false;
801
+ return true;
802
+ }
803
+ /**
804
+ * Hashes a query key with the query's `queryKeyHashFn` option, falling back to {@link hashKey}.
805
+ * @param queryKey - The query key to hash.
806
+ * @param options - The query options that may provide a custom `queryKeyHashFn`.
807
+ * @returns The query hash, a string that identifies the query in the cache.
808
+ */
809
+ function hashQueryKeyByOptions(queryKey, options) {
810
+ return (options?.queryKeyHashFn || hashKey)(queryKey);
811
+ }
812
+ /**
813
+ * Default query & mutation keys hash function.
814
+ * Hashes the value into a stable hash.
815
+ * @param queryKey - The query or mutation key to hash.
816
+ * @returns The stable hash of the key, as a JSON string.
817
+ * @example
818
+ * ```ts
819
+ * // Object keys are sorted, so key order doesn't affect the hash:
820
+ * hashKey(['todos', { page: 1, filter: 'done' }]) // === '["todos",{"filter":"done","page":1}]'
821
+ * ```
822
+ */
823
+ function hashKey(queryKey) {
824
+ return JSON.stringify(queryKey, (_, val) => isPlainObject(val) ? Object.keys(val).sort().reduce((result, key) => {
825
+ result[key] = val[key];
826
+ return result;
827
+ }, {}) : val);
828
+ }
829
+ function partialMatchKey(a, b) {
830
+ if (a === b) return true;
831
+ if (typeof a !== typeof b) return false;
832
+ if (a && b && typeof a === "object" && typeof b === "object") {
833
+ if (Array.isArray(a) && Array.isArray(b)) {
834
+ if (b.length > a.length) return false;
835
+ for (let i = 0; i < b.length; i++) if (!partialMatchKey(a[i], b[i])) return false;
836
+ return true;
837
+ }
838
+ const bKeys = Object.keys(b);
839
+ for (const key of bKeys) if (!partialMatchKey(a[key], b[key])) return false;
840
+ return true;
841
+ }
842
+ return false;
843
+ }
844
+ var hasOwn = Object.prototype.hasOwnProperty;
845
+ function replaceEqualDeep(a, b, depth = 0) {
846
+ if (a === b) return a;
847
+ if (depth > 500) return b;
848
+ const array = isPlainArray(a) && isPlainArray(b);
849
+ if (!array && !(isPlainObject(a) && isPlainObject(b))) return b;
850
+ const aSize = (array ? a : Object.keys(a)).length;
851
+ const bItems = array ? b : Object.keys(b);
852
+ const bSize = bItems.length;
853
+ const copy = array ? new Array(bSize) : {};
854
+ let equalItems = 0;
855
+ for (let i = 0; i < bSize; i++) {
856
+ const key = array ? i : bItems[i];
857
+ const aItem = a[key];
858
+ const bItem = b[key];
859
+ if (aItem === bItem) {
860
+ copy[key] = aItem;
861
+ if (array ? i < aSize : hasOwn.call(a, key)) equalItems++;
862
+ continue;
863
+ }
864
+ if (aItem === null || bItem === null || typeof aItem !== "object" || typeof bItem !== "object") {
865
+ copy[key] = bItem;
866
+ continue;
867
+ }
868
+ const v = replaceEqualDeep(aItem, bItem, depth + 1);
869
+ copy[key] = v;
870
+ if (v === aItem) equalItems++;
871
+ }
872
+ return aSize === bSize && equalItems === aSize ? a : copy;
873
+ }
874
+ /**
875
+ * Shallow compare objects.
876
+ * @param a - The first object.
877
+ * @param b - The second object, or `undefined`.
878
+ * @returns `true` if both objects have the same keys, with strictly equal values for each key.
879
+ */
880
+ function shallowEqualObjects(a, b) {
881
+ if (!b || Object.keys(a).length !== Object.keys(b).length) return false;
882
+ for (const key of Object.keys(a)) if (!hasOwn.call(b, key) || a[key] !== b[key]) return false;
883
+ return true;
884
+ }
885
+ /**
886
+ * Checks whether a value is an array with no holes and no extra properties.
887
+ * @param value - The value to check.
888
+ * @returns `true` if `value` is an array whose number of own keys equals its `length`.
889
+ */
890
+ function isPlainArray(value) {
891
+ return Array.isArray(value) && value.length === Object.keys(value).length;
892
+ }
893
+ /**
894
+ * Checks whether a value is a plain object, e.g. created with an object literal or
895
+ * `Object.create(null)`.
896
+ * @param o - The value to check.
897
+ * @returns `true` if `o` is a plain object.
898
+ */
899
+ function isPlainObject(o) {
900
+ if (!hasObjectPrototype(o)) return false;
901
+ const objectPrototype = Object.getPrototypeOf(o);
902
+ const ctor = objectPrototype?.constructor;
903
+ if (ctor === void 0) return true;
904
+ if (typeof ctor !== "function") return false;
905
+ const prot = ctor.prototype;
906
+ if (!hasObjectPrototype(prot)) return false;
907
+ if (!prot.hasOwnProperty("isPrototypeOf")) return false;
908
+ if (objectPrototype !== Object.prototype) return false;
909
+ return true;
910
+ }
911
+ /**
912
+ * Checks whether a value's `Object.prototype.toString` tag is `[object Object]`.
913
+ * @param o - The value to check.
914
+ * @returns `true` if the tag is `[object Object]`.
915
+ */
916
+ function hasObjectPrototype(o) {
917
+ return Object.prototype.toString.call(o) === "[object Object]";
918
+ }
919
+ /**
920
+ * Waits for the given time, using the configured {@link timeoutManager}.
921
+ * @param timeout - The time to wait, in milliseconds.
922
+ * @returns A promise that resolves after `timeout` milliseconds.
923
+ */
924
+ function sleep(timeout) {
925
+ return new Promise((resolve) => {
926
+ timeoutManager.setTimeout(resolve, timeout);
927
+ });
928
+ }
929
+ /**
930
+ * Applies a query's `structuralSharing` option when writing new data.
931
+ * @param prevData - The previously cached data.
932
+ * @param data - The new data.
933
+ * @param options - The query options, whose `structuralSharing` decides how the data is merged.
934
+ * @returns The result of a custom `structuralSharing` function, `data` with its unchanged parts
935
+ * replaced by those of `prevData` by default, or `data` as is if `structuralSharing` is `false`.
936
+ * @throws {Error} The error from the default structural sharing, e.g. when the data is not JSON serializable.
937
+ * Outside production, it is also logged to the console.
938
+ */
939
+ function replaceData(prevData, data, options) {
940
+ if (typeof options.structuralSharing === "function") return options.structuralSharing(prevData, data);
941
+ else if (options.structuralSharing !== false) return replaceEqualDeep(prevData, data);
942
+ return data;
943
+ }
944
+ /**
945
+ * Intended to be passed as a query's `placeholderData` option, for example
946
+ * `placeholderData: keepPreviousData`. Instead of resetting the query's data to `undefined` while a new
947
+ * query key is fetching, it keeps displaying the previously fetched data until the new data arrives.
948
+ * @param previousData - The data of the previous query key, passed by the observer.
949
+ * @returns The previous data, unchanged.
950
+ * @example
951
+ * ```ts
952
+ * new QueryObserver(queryClient, {
953
+ * queryKey: ['posts', page],
954
+ * queryFn: () => fetchPosts(page),
955
+ * placeholderData: keepPreviousData,
956
+ * })
957
+ * ```
958
+ */
959
+ function keepPreviousData(previousData) {
960
+ return previousData;
961
+ }
962
+ /**
963
+ * Returns a new array with `item` added at the end. If that makes the array longer than `max`,
964
+ * excess items are removed from the start.
965
+ * @param items - The current items.
966
+ * @param item - The value to append.
967
+ * @param max - The maximum number of items to keep. `0` (the default) means no limit.
968
+ * @returns A new array with `item` added.
969
+ */
970
+ function addToEnd(items, item, max = 0) {
971
+ const newItems = [...items, item];
972
+ return max && newItems.length > max ? newItems.slice(-max) : newItems;
973
+ }
974
+ /**
975
+ * Returns a new array with `item` added at the start. If that makes the array longer than `max`,
976
+ * excess items are removed from the end.
977
+ * @param items - The current items.
978
+ * @param item - The value to prepend.
979
+ * @param max - The maximum number of items to keep. `0` (the default) means no limit.
980
+ * @returns A new array with `item` added.
981
+ */
982
+ function addToStart(items, item, max = 0) {
983
+ const newItems = [item, ...items];
984
+ return max && newItems.length > max ? newItems.slice(0, max) : newItems;
985
+ }
986
+ /**
987
+ * Sentinel value that can be passed as a query's `queryFn` to conditionally disable the query (equivalent
988
+ * to `enabled: false`) while preserving full type inference for the query's data. Unlike `enabled: false`,
989
+ * a query disabled via `skipToken` cannot be triggered with `refetch`.
990
+ * @example
991
+ * ```ts
992
+ * new QueryObserver(queryClient, {
993
+ * queryKey: ['post', postId],
994
+ * queryFn: postId != null ? () => fetchPost(postId) : skipToken,
995
+ * })
996
+ * ```
997
+ */
998
+ var skipToken = Symbol();
999
+ /**
1000
+ * Returns the function to call for a fetch. If there is no `queryFn` but the fetch was started from
1001
+ * an `initialPromise`, that promise is returned instead. If there is no usable `queryFn` (missing or
1002
+ * {@link skipToken}), the returned function rejects with a `Missing queryFn` error.
1003
+ * @param options - The query options with the `queryFn`, and the `queryHash` used in error messages.
1004
+ * @param fetchOptions - The fetch options, which may carry an `initialPromise`.
1005
+ * @returns The function to call for the fetch.
1006
+ */
1007
+ function ensureQueryFn(options, fetchOptions) {
1008
+ if (!options.queryFn && fetchOptions?.initialPromise) return () => fetchOptions.initialPromise;
1009
+ if (!options.queryFn || options.queryFn === skipToken) return () => Promise.reject(/* @__PURE__ */ new Error(`Missing queryFn: '${options.queryHash}'`));
1010
+ return options.queryFn;
1011
+ }
1012
+ /**
1013
+ * Resolves a `throwOnError` option to a boolean.
1014
+ * If `throwOnError` is a function, it is called with `params` (e.g. the error and, depending on the caller,
1015
+ * additional context such as the query or mutation) and its result is returned, allowing the throwing
1016
+ * behavior to be decided per error. Otherwise, `throwOnError` itself is coerced to a boolean (`undefined`
1017
+ * resolves to `false`).
1018
+ * @param throwOnError - The `throwOnError` option: a boolean, a function that decides per error, or
1019
+ * `undefined`.
1020
+ * @param params - The arguments passed to `throwOnError` if it is a function.
1021
+ * @returns Whether the error should be thrown.
1022
+ * @example
1023
+ * ```ts
1024
+ * const throwOnError =
1025
+ * query.state.error && typeof options.throwOnError === 'function'
1026
+ * ? shouldThrowError(options.throwOnError, [query.state.error, query])
1027
+ * : options.throwOnError
1028
+ * ```
1029
+ */
1030
+ function shouldThrowError(throwOnError, params) {
1031
+ if (typeof throwOnError === "function") return throwOnError(...params);
1032
+ return !!throwOnError;
1033
+ }
1034
+ var fetchSignal = Symbol();
1035
+ /**
1036
+ * Adds a lazy `signal` getter to an object, such as a query function context. The first time
1037
+ * `signal` is read, `onCancelled` is registered for the signal's `abort` event (or called right
1038
+ * away if it is already aborted), so cancellation is only tracked when the signal is actually used.
1039
+ * @param object - The object to add the `signal` property to.
1040
+ * @param getSignal - Returns the `AbortSignal`. Called once, when `signal` is first read.
1041
+ * @param onCancelled - Called when the signal is aborted, if `signal` was read.
1042
+ * @param internalSignal - The fetch signal to forward without consuming the getter.
1043
+ * @returns The same object, with the `signal` property added.
1044
+ */
1045
+ function addConsumeAwareSignal(object, getSignal, onCancelled, internalSignal) {
1046
+ let consumed = false;
1047
+ let signal;
1048
+ Object.defineProperties(object, {
1049
+ [fetchSignal]: { value: internalSignal },
1050
+ signal: {
1051
+ enumerable: true,
1052
+ get: () => {
1053
+ signal ??= getSignal();
1054
+ if (consumed) return signal;
1055
+ consumed = true;
1056
+ if (signal.aborted) onCancelled();
1057
+ else signal.addEventListener("abort", onCancelled, { once: true });
1058
+ return signal;
1059
+ }
1060
+ }
1061
+ });
1062
+ return object;
1063
+ }
1064
+ // ../../node_modules/.bun/@tanstack+react-query@5.105.3+cef22a3c7e8b4cef/node_modules/@tanstack/react-query/build/modern/queryOptions.js
1065
+ function queryOptions(options) {
1066
+ return options;
1067
+ }
1068
+ // ../mate-core/src/cli/commands/studio/routes.ts
1069
+ /** A hosted report's HTML is served at this prefix plus its id. */
1070
+ var REPORT_VIEW_PREFIX = "/studio/reports/";
1071
+ /** Prefix of a Workset's run log routes. */
1072
+ var FACTORY_WORKSETS_ROUTE = "/api/factory/worksets";
1073
+ /**
1074
+ * The Agents panel: `GET` the Workset agent credential's status, `PUT` `{kind, value}`
1075
+ * to set it, `DELETE` to clear one set in Studio. Factory mode only.
1076
+ */
1077
+ var FACTORY_CREDENTIAL_ROUTE = "/api/factory/credential";
1078
+ /**
1079
+ * The Git access panel: `GET` the Git tokens' keys with their source and date, `PUT`
1080
+ * `{key, token}` to set one, `DELETE` `{key}` to clear one set in Studio. Factory mode only.
1081
+ */
1082
+ var FACTORY_GIT_TOKENS_ROUTE = "/api/factory/git-tokens";
1083
+ /** `GET` a Workset's bounded run log as text. */
1084
+ function factoryLogRoute(id) {
1085
+ return `${FACTORY_WORKSETS_ROUTE}/${encodeURIComponent(id)}/log`;
1086
+ }
1087
+ /** Server-sent events: a Workset's run log replayed, then followed live. */
1088
+ function factoryLogStreamRoute(id) {
1089
+ return `${factoryLogRoute(id)}/stream`;
1090
+ }
1091
+ /** One event stream per page: board, reports and markdown tree changes for a companion. */
1092
+ var STUDIO_EVENTS_ROUTE = "/api/events";
1093
+ /** The terminal's WASM core, loaded by Studio's bundled terminal from Studio itself. */
1094
+ var TERMINAL_WASM = `/studio/terminal/wterm.wasm`;
1095
+ /** The terminal's WebSocket, and its session list and end calls. */
1096
+ var TERMINAL_SOCKET_ROUTE = "/api/terminal";
1097
+ var TERMINAL_SESSIONS_ROUTE = "/api/terminal/sessions";
1098
+ var TERMINAL_SESSIONS_END_ROUTE = "/api/terminal/sessions/end";
1099
+ // src/lib/agent-credential.ts
1100
+ /**
1101
+ * The Agents panel's calls to the factory credential route. Only the status is cached;
1102
+ * an entered value goes in one request body and is never kept, keyed or put in an address.
1103
+ */
1104
+ var agentCredentialKey = ["agent-credential"];
1105
+ async function call(method, route, body) {
1106
+ const response = await fetch(route, {
1107
+ method,
1108
+ credentials: "same-origin",
1109
+ headers: {
1110
+ accept: "application/json",
1111
+ "content-type": "application/json"
1112
+ },
1113
+ ...body ? { body: JSON.stringify(body) } : {}
1114
+ });
1115
+ if (!response.ok) {
1116
+ const refusal = await response.json().catch(() => null);
1117
+ throw new Error(refusal?.reason ?? `status ${response.status}`);
1118
+ }
1119
+ return await response.json();
1120
+ }
1121
+ var agentCredentialQuery = () => ({
1122
+ queryKey: agentCredentialKey,
1123
+ queryFn: () => call("GET", FACTORY_CREDENTIAL_ROUTE)
1124
+ });
1125
+ var setAgentCredential = (kind, value) => call("PUT", FACTORY_CREDENTIAL_ROUTE, {
1126
+ kind,
1127
+ value
1128
+ });
1129
+ var clearAgentCredential = () => call("DELETE", FACTORY_CREDENTIAL_ROUTE);
1130
+ // ../../node_modules/.bun/@tanstack+start-server-core@1.169.45/node_modules/@tanstack/start-server-core/dist/esm/createSsrRpc.js
1131
+ var createSsrRpc = (functionId) => {
1132
+ const url = "/_serverFn/" + functionId;
1133
+ const serverFnMeta = { id: functionId };
1134
+ const fn = async (...args) => {
1135
+ return (await getServerFnById(functionId, { origin: "server" }))(...args);
1136
+ };
1137
+ return Object.assign(fn, {
1138
+ url,
1139
+ serverFnMeta,
1140
+ [TSS_SERVER_FUNCTION]: true
1141
+ });
1142
+ };
1143
+ // src/server/factory.ts
1144
+ /** What the Factory reads from the companion payload; nothing else crosses to the browser. */
1145
+ /** Board actions a person can take: core's Outcome actions, plus `create`, which needs no runner. */
1146
+ var FACTORY_ACTIONS = ["create", ...OUTCOME_ACTIONS];
1147
+ var MAX_FIELD = 65536;
1148
+ function validate(input) {
1149
+ if (typeof input?.companion !== "string" || !COMPANION_DIGEST_PATTERN.test(input.companion)) throw new Error("no registered companion was selected");
1150
+ if (!FACTORY_ACTIONS.includes(input.action)) throw new Error(`unknown factory action ${JSON.stringify(input.action)}`);
1151
+ if (input.action !== "create" && typeof input.id !== "string") throw new Error("the action names no Outcome");
1152
+ const fields = {};
1153
+ for (const [name, value] of Object.entries(input.fields ?? {})) if (typeof value === "string" && value.length <= MAX_FIELD) fields[name] = value;
1154
+ return {
1155
+ companion: input.companion,
1156
+ action: input.action,
1157
+ id: input.id,
1158
+ fields
1159
+ };
1160
+ }
1161
+ /** One Outcome action, checked by core's services exactly as the old form posts were. */
1162
+ var runFactoryAction = createServerFn({ method: "POST" }).validator(validate).handler(createSsrRpc("b0ff357be654d7d833a4f9550953dda5e215e97cdc5b21639aef40d8a2401c4f"));
1163
+ /** The Factory's view model: the companion payload, its runs and sessions, at one moment. */
1164
+ var getFactory = createServerFn({ method: "GET" }).validator((input) => {
1165
+ if (!COMPANION_DIGEST_PATTERN.test(input?.companion ?? "")) throw new Error("no registered companion was selected");
1166
+ return { companion: input.companion };
1167
+ }).handler(createSsrRpc("332ea72d0b70383661ce66a3228167cb05dc752e7269134a11855d1329c936aa"));
1168
+ function checkedCompanion(companion) {
1169
+ if (typeof companion !== "string" || !COMPANION_DIGEST_PATTERN.test(companion)) throw new Error("no registered companion was selected");
1170
+ return companion;
1171
+ }
1172
+ /** Adds a Working Repository to the companion's list; a refusal comes back as an answer with its reason. */
1173
+ var addRepository = createServerFn({ method: "POST" }).validator((input) => {
1174
+ const companion = checkedCompanion(input?.companion);
1175
+ const given = input.input;
1176
+ if (given?.kind === "url" && typeof given.url === "string") return {
1177
+ companion,
1178
+ input: {
1179
+ kind: "url",
1180
+ url: given.url
1181
+ }
1182
+ };
1183
+ if (given?.kind === "path" && typeof given.path === "string") return {
1184
+ companion,
1185
+ input: {
1186
+ kind: "path",
1187
+ path: given.path
1188
+ }
1189
+ };
1190
+ throw new Error("name a Git URL or a path");
1191
+ }).handler(createSsrRpc("8d04585e5fc8779cd8f1652917ecb307b274a1cfa4a075aa28a5e0c532101faa"));
1192
+ /** Removes an entry the companion's list holds. */
1193
+ var removeRepository = createServerFn({ method: "POST" }).validator((input) => {
1194
+ if (typeof input?.identity !== "string") throw new Error("name the repository to remove");
1195
+ return {
1196
+ companion: checkedCompanion(input.companion),
1197
+ identity: input.identity
1198
+ };
1199
+ }).handler(createSsrRpc("2c3daf16b0b19b9818a4fbbe0989f7517d2f070bb20f12dff293e217a82f4a05"));
1200
+ // src/server/graph.ts
1201
+ /** The companion's spec graph, packed; Core rebuilds it only when its specs or archives change. */
1202
+ var getGraph = createServerFn({ method: "GET" }).validator((input) => {
1203
+ if (typeof input?.companion !== "string" || !COMPANION_DIGEST_PATTERN.test(input.companion)) throw new Error("no registered companion was selected");
1204
+ return { companion: input.companion };
1205
+ }).handler(createSsrRpc("3fcb2bd7158d460f09117ddf736a3fc4d2e1cf934bfd85a7de1e60845d0163a6"));
1206
+ // src/server/reports.ts
1207
+ /** A registered companion's hosted reports, newest first; titles and times only. */
1208
+ var getReports = createServerFn({ method: "GET" }).validator((input) => {
1209
+ if (typeof input?.companion !== "string" || !COMPANION_DIGEST_PATTERN.test(input.companion)) throw new Error("no registered companion was selected");
1210
+ return { companion: input.companion };
1211
+ }).handler(createSsrRpc("990d830ca9afc020639551c43ec50904b734051c52b1ad91dbf739065b343bb3"));
1212
+ // src/server/shell.ts
1213
+ /** `refresh` collects the companion again; every other call reads the held snapshot. */
1214
+ var getShell = createServerFn({ method: "GET" }).validator((input) => ({
1215
+ ...validateStudioSearch(input),
1216
+ ...input.refresh === true ? { refresh: true } : {}
1217
+ })).handler(createSsrRpc("b4cd58adfccec803b6c97478c78656e3acf554351ec97ef0ce550a10e235ebce"));
1218
+ // src/server/skills.ts
1219
+ var AGENTS = /* @__PURE__ */ new Set([
1220
+ "claude",
1221
+ "opencode",
1222
+ "agents"
1223
+ ]);
1224
+ /** One installed skill's files and one of them rendered; core confines it to the skill's folder. */
1225
+ var getSkillPreview = createServerFn({ method: "GET" }).validator((input) => {
1226
+ if (typeof input?.companion !== "string" || !COMPANION_DIGEST_PATTERN.test(input.companion)) throw new Error("no registered companion was selected");
1227
+ if (!AGENTS.has(input.agent)) throw new Error("unknown agent");
1228
+ if (typeof input.name !== "string" || input.name === "" || input.name.length > 200) throw new Error("the request names no skill");
1229
+ const file = typeof input.file === "string" && input.file !== "" && input.file.length <= 4096 ? input.file : void 0;
1230
+ return {
1231
+ companion: input.companion,
1232
+ agent: input.agent,
1233
+ name: input.name,
1234
+ file
1235
+ };
1236
+ }).handler(createSsrRpc("8a3086c4bf87fd353e471c38fe6c5e531cb9aa6b29b234d7edb6de5d143cf689"));
1237
+ // src/server/vault.ts
1238
+ var MAX_CONTENT = 5242880;
1239
+ function companionOf(input) {
1240
+ if (typeof input?.companion !== "string" || !COMPANION_DIGEST_PATTERN.test(input.companion)) throw new Error("no registered companion was selected");
1241
+ return input.companion;
1242
+ }
1243
+ var text = (value) => typeof value === "string" && value.length > 0 && value.length <= 4096 ? value : void 0;
1244
+ /** The vault page; core resolves every path against the selected companion. */
1245
+ var getVault = createServerFn({ method: "GET" }).validator((input) => ({
1246
+ companion: companionOf(input),
1247
+ path: text(input.path),
1248
+ dir: text(input.dir),
1249
+ refresh: input.refresh === true,
1250
+ wait: input.wait === true
1251
+ })).handler(createSsrRpc("cc0685774bfb5205a762c25bdd4b959c1f541584df4b67aac816fe529fa37c87"));
1252
+ var getVaultChildren = createServerFn({ method: "GET" }).validator((input) => {
1253
+ const dir = text(input.dir);
1254
+ if (!dir) throw new Error("the request names no folder");
1255
+ return {
1256
+ companion: companionOf(input),
1257
+ dir
1258
+ };
1259
+ }).handler(createSsrRpc("7564d662d1e0ede6133407d7dde8d613b3b11718bc4f95160680342deeaf9cfd"));
1260
+ var getVaultMatches = createServerFn({ method: "GET" }).validator((input) => ({
1261
+ companion: companionOf(input),
1262
+ query: typeof input.query === "string" ? input.query.slice(0, 200) : ""
1263
+ })).handler(createSsrRpc("99f4d57911b5959a331ed18424ab13369de22f8b2b142a146ea967742dfbc997"));
1264
+ /** Unsaved editor text rendered as a saved file would be; nothing is read or written. */
1265
+ var previewVaultFile = createServerFn({ method: "POST" }).validator((input) => {
1266
+ const path = text(input.path);
1267
+ if (!path) throw new Error("the preview names no file");
1268
+ if (typeof input.content !== "string" || input.content.length > MAX_CONTENT) throw new Error("preview requires content within the size limit");
1269
+ return {
1270
+ companion: companionOf(input),
1271
+ path,
1272
+ content: input.content
1273
+ };
1274
+ }).handler(createSsrRpc("c9e07976b298f1d1353d3422b03638f260b66975d28a1c8b07919923be8c488d"));
1275
+ /** A save; a stale token comes back as a conflict carrying the current content and token. */
1276
+ var saveVaultFile = createServerFn({ method: "POST" }).validator((input) => {
1277
+ const path = text(input.path);
1278
+ if (!path) throw new Error("save requires a path");
1279
+ if (typeof input.content !== "string" || input.content.length > MAX_CONTENT) throw new Error("save requires content within the size limit");
1280
+ return {
1281
+ companion: companionOf(input),
1282
+ path,
1283
+ content: input.content,
1284
+ token: text(input.token)
1285
+ };
1286
+ }).handler(createSsrRpc("63d1e2171062e2d082e16522c162963c4da2a71c447f69f0937bd6e5e10b73ba"));
1287
+ // src/server/views.ts
1288
+ var VIEWS = /* @__PURE__ */ new Set([
1289
+ "dashboard",
1290
+ "workflow",
1291
+ "skills",
1292
+ "specs"
1293
+ ]);
1294
+ var getCompanionView = createServerFn({ method: "GET" }).validator((input) => {
1295
+ if (!VIEWS.has(input?.view)) throw new Error("unknown view");
1296
+ const search = validateStudioSearch(input);
1297
+ if (!search.companion || !COMPANION_DIGEST_PATTERN.test(search.companion)) throw new Error("no registered companion was selected");
1298
+ return {
1299
+ ...search,
1300
+ view: input.view
1301
+ };
1302
+ }).handler(createSsrRpc("a09876e9d912d4f3edfe004081679f011fcebe77cfe1b2b25cf6f3e6f1eafc6a"));
1303
+ // src/lib/studio-queries.ts
1304
+ /**
1305
+ * Every companion-scoped Studio query, and which of them each trigger makes stale. Keys start
1306
+ * with the companion digest (`null` when none is selected), so one prefix is one companion.
1307
+ */
1308
+ var keys = {
1309
+ companion: (companion) => [companion],
1310
+ shell: (companion) => [companion, "shell"],
1311
+ views: (companion) => [companion, "view"],
1312
+ skills: (companion) => [companion, "skills"],
1313
+ factory: (companion) => [companion, "factory"],
1314
+ vault: (companion) => [companion, "vault"],
1315
+ vaultViews: (companion) => [
1316
+ companion,
1317
+ "vault",
1318
+ "view"
1319
+ ],
1320
+ reports: (companion) => [companion, "reports"],
1321
+ graph: (companion) => [companion, "graph"]
1322
+ };
1323
+ /** Per file and per filter, so unbounded; dropped a while after their last use. */
1324
+ var VAULT_GC_MS = 3e5;
1325
+ var shellQuery = (search) => queryOptions({
1326
+ queryKey: [...keys.shell(search.companion ?? null), search.studioMode ?? null],
1327
+ queryFn: () => getShell({ data: search })
1328
+ });
1329
+ /**
1330
+ * Holds the shell another enabled mode would read, built from the one shown: only the mode
1331
+ * differs, so switching waits for no request. Held as stale, so the server's copy follows.
1332
+ */
1333
+ function holdShellForMode(queryClient, search, shell, studioMode) {
1334
+ const { queryKey } = shellQuery({
1335
+ ...search,
1336
+ studioMode
1337
+ });
1338
+ if (queryClient.getQueryData(queryKey) !== void 0) return;
1339
+ queryClient.setQueryData(queryKey, {
1340
+ ...shell,
1341
+ studioMode
1342
+ }, { updatedAt: 0 });
1343
+ }
1344
+ var companionViewQuery = (view, search) => queryOptions({
1345
+ queryKey: [
1346
+ ...keys.views(search.companion ?? null),
1347
+ view,
1348
+ search.studioMode ?? null
1349
+ ],
1350
+ queryFn: () => getCompanionView({ data: {
1351
+ ...search,
1352
+ view
1353
+ } })
1354
+ });
1355
+ var skillPreviewQuery = (companion, agent, name, file) => queryOptions({
1356
+ queryKey: [
1357
+ ...keys.skills(companion),
1358
+ agent,
1359
+ name,
1360
+ file ?? null
1361
+ ],
1362
+ queryFn: () => getSkillPreview({ data: {
1363
+ companion,
1364
+ agent,
1365
+ name,
1366
+ file
1367
+ } })
1368
+ });
1369
+ var factoryQuery = (companion) => queryOptions({
1370
+ queryKey: keys.factory(companion),
1371
+ queryFn: () => getFactory({ data: { companion } }),
1372
+ refetchInterval: 3e4
1373
+ });
1374
+ var vaultQuery = (companion, search, wait = false) => queryOptions({
1375
+ queryKey: [
1376
+ ...keys.vaultViews(companion),
1377
+ search.path ?? null,
1378
+ search.dir ?? null,
1379
+ wait
1380
+ ],
1381
+ queryFn: () => getVault({ data: {
1382
+ companion,
1383
+ path: search.path,
1384
+ dir: search.dir,
1385
+ wait
1386
+ } }),
1387
+ gcTime: VAULT_GC_MS
1388
+ });
1389
+ var vaultChildrenQuery = (companion, dir) => queryOptions({
1390
+ queryKey: [
1391
+ ...keys.vault(companion),
1392
+ "children",
1393
+ dir
1394
+ ],
1395
+ queryFn: () => getVaultChildren({ data: {
1396
+ companion,
1397
+ dir
1398
+ } })
1399
+ });
1400
+ var vaultMatchesQuery = (companion, query) => queryOptions({
1401
+ queryKey: [
1402
+ ...keys.vault(companion),
1403
+ "matches",
1404
+ query
1405
+ ],
1406
+ queryFn: () => getVaultMatches({ data: {
1407
+ companion,
1408
+ query
1409
+ } }),
1410
+ gcTime: VAULT_GC_MS
1411
+ });
1412
+ var reportsQuery = (companion) => queryOptions({
1413
+ queryKey: keys.reports(companion),
1414
+ queryFn: () => getReports({ data: { companion } })
1415
+ });
1416
+ /** Never loaded ahead: Core builds the graph only when the Graph view asks for it. */
1417
+ var graphQuery = (companion) => queryOptions({
1418
+ queryKey: keys.graph(companion),
1419
+ queryFn: async () => unpackGraph(await getGraph({ data: { companion } }))
1420
+ });
1421
+ async function stale(queryClient, ...queryKeys) {
1422
+ await Promise.all(queryKeys.map((queryKey) => queryClient.invalidateQueries({ queryKey })));
1423
+ }
1424
+ /** After a server event for `companion`; views refetch in place (design D7). */
1425
+ async function afterEvent(queryClient, companion, type) {
1426
+ if (type === "board") {
1427
+ if (queryClient.getQueryCache().find({ queryKey: keys.factory(companion) })?.isActive()) {
1428
+ await stale(queryClient, keys.factory(companion));
1429
+ await stale(queryClient, keys.shell(companion), keys.views(companion));
1430
+ } else await stale(queryClient, keys.factory(companion), keys.shell(companion), keys.views(companion));
1431
+ } else if (type === "reports") await stale(queryClient, keys.reports(companion));
1432
+ }
1433
+ var afterFactoryAction = (queryClient, companion) => stale(queryClient, keys.factory(companion));
1434
+ /** The refresh answer is shown at once; the companion's other vault reads follow. */
1435
+ function afterVaultRefresh(queryClient, companion, search, fresh) {
1436
+ const shown = vaultQuery(companion, search).queryKey;
1437
+ queryClient.setQueryData(shown, fresh);
1438
+ const answered = hashKey(shown);
1439
+ return queryClient.invalidateQueries({
1440
+ queryKey: keys.vault(companion),
1441
+ predicate: (query) => query.queryHash !== answered
1442
+ });
1443
+ }
1444
+ /** After the open file changed on disk or was saved. */
1445
+ var afterVaultFileChange = (queryClient, companion) => stale(queryClient, keys.vaultViews(companion));
1446
+ /**
1447
+ * After Refresh collected `companion` again; other companions keep what they hold. The agent
1448
+ * credential is not companion data but may change out of band; terminal sessions are polled.
1449
+ */
1450
+ var afterRefresh = (queryClient, companion) => stale(queryClient, keys.companion(companion ?? null), agentCredentialKey);
1451
+ export { partialMatchKey as $, REPORT_VIEW_PREFIX as A, addToEnd as B, createSsrRpc as C, clearAgentCredential as D, call as E, TERMINAL_WASM as F, hashKey as G, ensureQueryFn as H, factoryLogRoute as I, isValidTimeout as J, hashQueryKeyByOptions as K, factoryLogStreamRoute as L, TERMINAL_SESSIONS_END_ROUTE as M, TERMINAL_SESSIONS_ROUTE as N, setAgentCredential as O, TERMINAL_SOCKET_ROUTE as P, noop as Q, queryOptions as R, runFactoryAction as S, agentCredentialQuery as T, fetchSignal as U, addToStart as V, functionalUpdate as W, matchMutation as X, keepPreviousData as Y, matchQuery as Z, previewVaultFile as _, afterVaultRefresh as a, sleep as at, addRepository as b, graphQuery as c, timeoutManager as ct, shellQuery as d, createRootRouteWithContext as dt, replaceData as et, skillPreviewQuery as f, Link as ft, getVault as g, vaultQuery as h, afterVaultFileChange as i, skipToken as it, STUDIO_EVENTS_ROUTE as j, FACTORY_GIT_TOKENS_ROUTE as k, holdShellForMode as l, lazyRouteComponent as lt, vaultMatchesQuery as m, afterFactoryAction as n, shallowEqualObjects as nt, companionViewQuery as o, timeUntilStale as ot, vaultChildrenQuery as p, useNavigate as pt, isServer as q, afterRefresh as r, shouldThrowError as rt, factoryQuery as s, systemSetTimeoutZero as st, afterEvent as t, resolveQueryValue as tt, reportsQuery as u, createFileRoute as ut, saveVaultFile as v, agentCredentialKey as w, removeRepository as x, getShell as y, addConsumeAwareSignal as z };