@rho-workspace/rho 0.5.6 → 0.5.7

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 (211) hide show
  1. package/dist/agent-connect.d.ts +36 -2
  2. package/dist/agent-connect.js +64 -11
  3. package/dist/answer-board.js +3 -3
  4. package/dist/bridge.js +6 -1
  5. package/dist/browser-access.d.ts +1 -0
  6. package/dist/browser-access.js +5 -3
  7. package/dist/capabilities.d.ts +21 -5
  8. package/dist/capabilities.js +6 -4
  9. package/dist/cli.js +76 -11
  10. package/dist/composition.d.ts +1 -1
  11. package/dist/composition.js +13 -3
  12. package/dist/connect-cli.d.ts +50 -0
  13. package/dist/connect-cli.js +128 -0
  14. package/dist/contract.generated.d.ts +1191 -278
  15. package/dist/contract.generated.js +1 -1
  16. package/dist/contracts/owners.generated.js +845 -47
  17. package/dist/conversation-presentation.d.ts +9 -2
  18. package/dist/conversation-presentation.js +3 -1
  19. package/dist/conversations.d.ts +154 -8
  20. package/dist/conversations.js +147 -24
  21. package/dist/discovery.js +2 -2
  22. package/dist/extension-contract.d.ts +19 -0
  23. package/dist/extension-contract.js +15 -6
  24. package/dist/extension-markets.d.ts +74 -0
  25. package/dist/extension-markets.js +166 -0
  26. package/dist/extensions.d.ts +29 -1
  27. package/dist/extensions.js +13 -4
  28. package/dist/external-work.d.ts +22 -0
  29. package/dist/external-work.js +91 -0
  30. package/dist/plugin-cli.js +75 -3
  31. package/dist/plugin-inventory.d.ts +56 -0
  32. package/dist/plugin-inventory.js +41 -0
  33. package/dist/plugin-inventory.json +1581 -102
  34. package/dist/plugin-presentation.d.ts +105 -2
  35. package/dist/plugin-presentation.js +59 -5
  36. package/dist/plugins.d.ts +14 -3
  37. package/dist/plugins.js +12 -6
  38. package/dist/project-notes.js +1 -1
  39. package/dist/protocol.d.ts +6 -0
  40. package/dist/protocol.js +30 -12
  41. package/dist/replay.js +4 -0
  42. package/dist/response-contracts.js +26 -11
  43. package/dist/running.d.ts +10 -0
  44. package/dist/running.js +45 -0
  45. package/dist/server.d.ts +2 -0
  46. package/dist/server.js +71 -8
  47. package/dist/state.d.ts +8 -0
  48. package/dist/state.js +8 -0
  49. package/dist/studio-layout.js +3 -3
  50. package/dist/task-frame.d.ts +1 -1
  51. package/dist/timeline-events.d.ts +1 -0
  52. package/dist/timeline-events.js +8 -1
  53. package/dist/ui-context.d.ts +73 -0
  54. package/dist/ui-context.js +98 -0
  55. package/dist/ui-contract.d.ts +23 -0
  56. package/dist/web/.vite/manifest.json +133 -74
  57. package/dist/web/assets/answer-board-CeYS8k8y.js +1 -0
  58. package/dist/web/assets/choices-D8vGwsl2.js +1 -0
  59. package/dist/web/assets/{console-Trqc0swD.js → console-Dyuo1q4N.js} +4 -4
  60. package/dist/web/assets/{dist-pF902jHA.js → dist-CSiCyBml.js} +1 -1
  61. package/dist/web/assets/{dist-DpIHRk3B.js → dist-D9FLb9Hm.js} +1 -1
  62. package/dist/web/assets/{dist-eMx6b8N1.js → dist-FXbTBwML.js} +1 -1
  63. package/dist/web/assets/{dist-DZmszrjG.js → dist-l3DUhbw5.js} +1 -1
  64. package/dist/web/assets/{explore-in-BCHqjJ7B.js → explore-in-BfSFGRh2.js} +1 -1
  65. package/dist/web/assets/graph-BU2_o5uA.js +2 -0
  66. package/dist/web/assets/index-C16mXVvk.css +1 -0
  67. package/dist/web/assets/index-CWg9XYXx.js +952 -0
  68. package/dist/web/assets/markdown.reader-Ct2-e2Zt.png +0 -0
  69. package/dist/web/assets/{notes-meaning-DcVGUBBY.js → notes-meaning-T2m5zQfv.js} +1 -1
  70. package/dist/web/assets/overview-PzfLJCo-.js +6 -0
  71. package/dist/web/assets/preview-BguEdsza.js +1 -0
  72. package/dist/web/assets/previews-pWNik-2g.js +3 -0
  73. package/dist/web/assets/{review-DYP0aCXb.js → review-Dy_85lcH.js} +1 -1
  74. package/dist/web/assets/rho.editor-CCJeyHma.png +0 -0
  75. package/dist/web/assets/rho.flow-WkMj6fRS.png +0 -0
  76. package/dist/web/assets/rho.media-Cc6amodO.png +0 -0
  77. package/dist/web/assets/rho.notebook-6vsZKGDq.png +0 -0
  78. package/dist/web/assets/rho.object-BGoeXjte.png +0 -0
  79. package/dist/web/assets/rho.plots-yIiISCkb.png +0 -0
  80. package/dist/web/assets/rho.scatter-DwHxesCs.png +0 -0
  81. package/dist/web/assets/rho.servers-DKf_mnNq.png +0 -0
  82. package/dist/web/assets/rho.table-DWOGaWDa.png +0 -0
  83. package/dist/web/assets/rho.variables-CKcWczhQ.png +0 -0
  84. package/dist/web/assets/{skills-1ec0Z-jx.js → skills-Dyz7mBlc.js} +1 -1
  85. package/dist/web/assets/{skills-work-DNexV4OJ.js → skills-work-BEGqlCkx.js} +1 -1
  86. package/dist/web/assets/studio-process-D-ykbC4D.js +2 -0
  87. package/dist/web/assets/timeline-events-DKTho9fU.js +1 -0
  88. package/dist/web/assets/work-turns-DSabCogR.js +1 -0
  89. package/dist/web/assets/{workspace-COmCbGV3.js → workspace-DfjBL--r.js} +2 -2
  90. package/dist/web/composition.json +138 -83
  91. package/dist/web/index.html +3 -3
  92. package/dist/web/renderer.json +1 -1
  93. package/dist/web-assets.js +2 -2
  94. package/dist/work-graph.d.ts +11 -1
  95. package/dist/work-graph.js +16 -5
  96. package/dist/workspace.d.ts +2 -2
  97. package/dist/workspace.js +8 -7
  98. package/docs/FRONTEND.md +53 -11
  99. package/docs/HEADLESS.md +104 -11
  100. package/docs/THIRD-PARTY-PLUGINS.md +75 -3
  101. package/node_modules/@rho-workspace/plugin-agent/README.md +5 -0
  102. package/node_modules/@rho-workspace/plugin-agent/dist/acp-command.d.ts +31 -0
  103. package/node_modules/@rho-workspace/plugin-agent/dist/acp-command.js +45 -10
  104. package/node_modules/@rho-workspace/plugin-agent/dist/acp-conversation.js +19 -3
  105. package/node_modules/@rho-workspace/plugin-agent/dist/external-session-contract.js +3 -2
  106. package/node_modules/@rho-workspace/plugin-agent/dist/external-session.d.ts +1 -1
  107. package/node_modules/@rho-workspace/plugin-agent/dist/index.d.ts +8 -0
  108. package/node_modules/@rho-workspace/plugin-agent/dist/index.js +3 -2
  109. package/node_modules/@rho-workspace/plugin-agent/dist/mcp-entry.d.ts +13 -0
  110. package/node_modules/@rho-workspace/plugin-agent/dist/mcp-entry.js +13 -0
  111. package/node_modules/@rho-workspace/plugin-agent/dist/mcp.js +16 -8
  112. package/node_modules/@rho-workspace/plugin-agent/dist/native-sessions.d.ts +1 -1
  113. package/node_modules/@rho-workspace/plugin-agent/package.json +1 -1
  114. package/node_modules/@rho-workspace/plugin-figures/LICENSE +661 -0
  115. package/node_modules/@rho-workspace/plugin-figures/README.md +191 -0
  116. package/node_modules/@rho-workspace/plugin-figures/dist/index.d.ts +236 -0
  117. package/node_modules/@rho-workspace/plugin-figures/dist/index.js +165 -0
  118. package/node_modules/@rho-workspace/plugin-figures/dist/operations.d.ts +44 -0
  119. package/node_modules/@rho-workspace/plugin-figures/dist/operations.js +39 -0
  120. package/node_modules/@rho-workspace/plugin-figures/dist/presentation.d.ts +19 -0
  121. package/node_modules/@rho-workspace/plugin-figures/dist/presentation.js +26 -0
  122. package/node_modules/@rho-workspace/plugin-figures/dist/record.d.ts +188 -0
  123. package/node_modules/@rho-workspace/plugin-figures/dist/record.js +143 -0
  124. package/node_modules/@rho-workspace/plugin-figures/dist/ui-styles.d.ts +1 -0
  125. package/node_modules/@rho-workspace/plugin-figures/dist/ui-styles.js +68 -0
  126. package/node_modules/@rho-workspace/plugin-figures/dist/ui.d.ts +56 -0
  127. package/node_modules/@rho-workspace/plugin-figures/dist/ui.js +363 -0
  128. package/node_modules/@rho-workspace/plugin-figures/package.json +41 -0
  129. package/node_modules/@rho-workspace/plugin-figures/py/figures.py +856 -0
  130. package/node_modules/@rho-workspace/plugin-figures/r/figures.R +775 -0
  131. package/node_modules/@rho-workspace/plugin-kernel/README.md +27 -3
  132. package/node_modules/@rho-workspace/plugin-kernel/dist/contract.d.ts +12 -0
  133. package/node_modules/@rho-workspace/plugin-kernel/dist/contract.js +8 -1
  134. package/node_modules/@rho-workspace/plugin-kernel/dist/index.d.ts +61 -0
  135. package/node_modules/@rho-workspace/plugin-kernel/dist/index.js +125 -9
  136. package/node_modules/@rho-workspace/plugin-kernel/dist/session-scope.d.ts +14 -0
  137. package/node_modules/@rho-workspace/plugin-kernel/dist/session-scope.js +9 -0
  138. package/node_modules/@rho-workspace/plugin-kernel/dist/ui-base.d.ts +23 -5
  139. package/node_modules/@rho-workspace/plugin-kernel/dist/ui-notebook-work.js +1 -1
  140. package/node_modules/@rho-workspace/plugin-kernel/dist/ui-notebook.d.ts +6 -4
  141. package/node_modules/@rho-workspace/plugin-kernel/dist/ui-notebook.js +44 -17
  142. package/node_modules/@rho-workspace/plugin-kernel/dist/ui-styles.js +6 -0
  143. package/node_modules/@rho-workspace/plugin-kernel/package.json +1 -1
  144. package/node_modules/@rho-workspace/plugin-kernel/runners/runner.R +144 -4
  145. package/node_modules/@rho-workspace/plugin-kernel/runners/runner.py +106 -1
  146. package/node_modules/@rho-workspace/plugin-tables/README.md +5 -0
  147. package/node_modules/@rho-workspace/plugin-tables/dist/index.d.ts +1 -0
  148. package/node_modules/@rho-workspace/plugin-tables/dist/index.js +19 -3
  149. package/node_modules/@rho-workspace/plugin-tables/dist/ui.js +1 -1
  150. package/node_modules/@rho-workspace/plugin-tables/package.json +1 -1
  151. package/node_modules/jose/dist/webapi/jwe/general/decrypt.js +3 -2
  152. package/node_modules/jose/dist/webapi/jwks/remote.js +1 -1
  153. package/node_modules/jose/dist/webapi/jws/general/verify.js +2 -8
  154. package/node_modules/jose/dist/webapi/lib/jwe_decrypt.js +11 -8
  155. package/node_modules/jose/dist/webapi/lib/key_management.js +0 -1
  156. package/node_modules/jose/package.json +1 -1
  157. package/package.json +6 -4
  158. package/protocol/index.json +91 -55
  159. package/protocol/operations/agent.sessions.list.json +13 -5
  160. package/protocol/operations/agent.sessions.read.json +13 -5
  161. package/protocol/operations/capability.list.json +382 -6
  162. package/protocol/operations/composition.apply.json +10 -2
  163. package/protocol/operations/composition.delete.json +845 -0
  164. package/protocol/operations/composition.read.json +10 -2
  165. package/protocol/operations/composition.undo.json +10 -2
  166. package/protocol/operations/conversation.agents.add.json +346 -0
  167. package/protocol/operations/conversation.agents.remove.json +340 -0
  168. package/protocol/operations/conversation.decide.json +196 -0
  169. package/protocol/operations/conversation.permission.json +196 -0
  170. package/protocol/operations/conversation.read.json +196 -0
  171. package/protocol/operations/conversation.send.json +265 -0
  172. package/protocol/operations/conversation.settings.check.json +213 -495
  173. package/protocol/operations/conversation.settings.read.json +211 -490
  174. package/protocol/operations/conversation.settings.update.json +235 -554
  175. package/protocol/operations/conversation.start.json +267 -5
  176. package/protocol/operations/conversation.stop.json +196 -0
  177. package/protocol/operations/extension.describe.json +39 -0
  178. package/protocol/operations/extension.install.json +62 -0
  179. package/protocol/operations/extension.list.json +164 -1
  180. package/protocol/operations/extension.market.change.json +210 -0
  181. package/protocol/operations/figure.read.json +265 -0
  182. package/protocol/operations/figure.select.json +157 -0
  183. package/protocol/operations/kernel.interrupt.json +119 -0
  184. package/protocol/operations/kernel.read.json +119 -0
  185. package/protocol/operations/kernel.run.json +119 -0
  186. package/protocol/operations/observation.snapshot.json +416 -8
  187. package/protocol/operations/project.openFile.json +10 -2
  188. package/protocol/operations/session.grant.json +4 -0
  189. package/protocol/operations/shared.json +1 -0
  190. package/protocol/operations/view.close.json +10 -2
  191. package/protocol/operations/view.protection.set.json +10 -2
  192. package/vendor/composition.json +177 -112
  193. package/vendor/rho-workspace-plugin-agent-0.4.33.tgz +0 -0
  194. package/vendor/rho-workspace-plugin-figures-0.5.1.tgz +0 -0
  195. package/vendor/rho-workspace-plugin-kernel-0.5.13.tgz +0 -0
  196. package/vendor/rho-workspace-plugin-tables-0.5.2.tgz +0 -0
  197. package/web/theme.css +5 -0
  198. package/dist/web/assets/answer-board-CBkGbSLD.js +0 -1
  199. package/dist/web/assets/canvas-D8rDdfDz.js +0 -1
  200. package/dist/web/assets/choices-D-YfnFP6.js +0 -1
  201. package/dist/web/assets/graph-lENgfQNH.js +0 -2
  202. package/dist/web/assets/index-B3_OVy91.css +0 -1
  203. package/dist/web/assets/index-BpL_Kl_s.js +0 -892
  204. package/dist/web/assets/overview-CDnVKlOt.js +0 -6
  205. package/dist/web/assets/preview-BEC1E9MK.js +0 -1
  206. package/dist/web/assets/studio-process-EYQgikxq.js +0 -2
  207. package/dist/web/assets/timeline-events-Chj2Gbx7.js +0 -1
  208. package/dist/web/assets/work-turns-CT9RVcWY.js +0 -1
  209. package/vendor/rho-workspace-plugin-agent-0.4.30.tgz +0 -0
  210. package/vendor/rho-workspace-plugin-kernel-0.5.5.tgz +0 -0
  211. package/vendor/rho-workspace-plugin-tables-0.5.0.tgz +0 -0
@@ -1,4 +1,4 @@
1
- import{q as e}from"./index-BpL_Kl_s.js";var t=[[`question`,/^(questions?|aims?|问题|研究问题)$/i],[`method`,/^(data\s*(&|and)\s*methods?|data|methods?|数据与方法|数据和方法|方法)$/i],[`finding`,/^(key\s+results?|results?|findings?|关键结果|主要结果|结果)$/i],[`choice`,/^((analysis\s+)?choices?|decisions?|选择|分析选择)$/i],[`file`,/^(files?|outputs?|文件|输出)$/i],[`todo`,/^(to\s*-?\s*dos?|next\s+steps?|待办(事项)?)$/i]],n=e=>t.find(([,t])=>t.test(e.replace(/[*_`::]/g,``).trim()))?.[0]??null;function r(e){let t=e.trim().replace(/^<|>$/g,``);if(!t||t.startsWith(`#`)||/^[a-z][a-z0-9+.-]*:/i.test(t)||(t=t.replace(/[?#].*$/,``),t.endsWith(`/`)))return null;try{t=decodeURIComponent(t)}catch{}return t=t.replace(/^\.?\//,``).replace(/\/+$/,``),!t||t.split(`/`).some(e=>e===`..`||e===`.git`||e===`.rho`)?null:t}var i=/(!?)\[([^\]]*)\]\(\s*(<[^>]+>|[^)\s]+)(?:\s+"[^"]*")?\s*\)/g,a=/`([\w@.\/-]+\.[A-Za-z0-9]{1,6})`/g,o=/\.(csv|tsv|txt|json|jsonl|ya?ml|toml|md|qmd|rmd|ipynb|html?|pdf|png|jpe?g|gif|svg|webp|tiff?|py|r|jl|sh|js|mjs|ts|sql|xlsx?|parquet|feather|rds|rdata|h5|h5ad|hdf5|npy|npz|pkl|log|gz|zip|bam|sam|vcf|bed|gtf|gff3?|fasta|fa|fastq|fq|mtx|nc)$/i;function s(e){let t=[],n=e=>{let n=r(e);n&&!t.includes(n)&&t.push(n)};for(let t of e.matchAll(i))n(t[3]);for(let t of e.replace(i,` `).matchAll(a))(t[1].includes(`/`)||o.test(t[1]))&&n(t[1]);return t}function c(e){let t=e.replace(i,(e,t,n)=>n).replace(/^\s*(?:[-*+]|\d+[.)])\s+(\[[ xX]\]\s+)?/gm,``),n=[];return t.replace(/`([^`]*)`/g,(e,t)=>`\0`+(n.push(t)-1)+`\0`).replace(/(\*{1,3})(?=\S)([^*]+?)(?<=\S)\1/g,`$2`).replace(/(^|[^\w])(_{1,3})(?=\S)([^_]+?)(?<=\S)\2(?![\w])/g,`$1$3`).replace(/\u0000(\d+)\u0000/g,(e,t)=>n[Number(t)]).replace(/\s+/g,` `).trim()}var l=e=>e.charAt(0).toUpperCase()+e.slice(1);function u(e){let t=/^(.{2,48}?)\s*(?:=|:)\s+(\S[\s\S]*)$/.exec(e);return!t||t[1].split(/\s+/).length>6||/[.!?]\s/.test(t[1])?{topic:null,rest:e}:{topic:t[1],rest:l(t[2])}}function d(e,t){let n=e.trim(),r=``,i=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);for(let e=!0;e;){e=!1;for(let a of t){let t=RegExp(`[\\s,;]*\\(?`+i(a)+`\\)?([.;]?)$`).exec(n);t&&(n=n.slice(0,t.index),r||=t[1],e=!0)}}return n=n.replace(/[\s,;]+$/,``),r&&!/[.!?;:]$/.test(n)?n+r:n}var f=/^(\s*)([-*+]|\d+[.)])\s+(.*)$/,p=/^\s*!\[([^\]]*)\]\(\s*(<[^>]+>|[^)\s]+)(?:\s+"[^"]*")?\s*\)\s*$/,m=/^(alternatives?|instead|other(wise)?|或者|备选|替代)\b\s*[::-]?\s*/i,h=/(?<=[.;!?)\]—])\s+(?=(?:\*\*|__)?(?:alternatives?|instead|otherwise|备选|替代)(?:\*\*|__)?\s*[::])/i;function g(t){let i=t.split(`
1
+ import{q as e}from"./index-CWg9XYXx.js";var t=[[`question`,/^(questions?|aims?|问题|研究问题)$/i],[`method`,/^(data\s*(&|and)\s*methods?|data|methods?|数据与方法|数据和方法|方法)$/i],[`finding`,/^(key\s+results?|results?|findings?|关键结果|主要结果|结果)$/i],[`choice`,/^((analysis\s+)?choices?|decisions?|选择|分析选择)$/i],[`file`,/^(files?|outputs?|文件|输出)$/i],[`todo`,/^(to\s*-?\s*dos?|next\s+steps?|待办(事项)?)$/i]],n=e=>t.find(([,t])=>t.test(e.replace(/[*_`::]/g,``).trim()))?.[0]??null;function r(e){let t=e.trim().replace(/^<|>$/g,``);if(!t||t.startsWith(`#`)||/^[a-z][a-z0-9+.-]*:/i.test(t)||(t=t.replace(/[?#].*$/,``),t.endsWith(`/`)))return null;try{t=decodeURIComponent(t)}catch{}return t=t.replace(/^\.?\//,``).replace(/\/+$/,``),!t||t.split(`/`).some(e=>e===`..`||e===`.git`||e===`.rho`)?null:t}var i=/(!?)\[([^\]]*)\]\(\s*(<[^>]+>|[^)\s]+)(?:\s+"[^"]*")?\s*\)/g,a=/`([\w@.\/-]+\.[A-Za-z0-9]{1,6})`/g,o=/\.(csv|tsv|txt|json|jsonl|ya?ml|toml|md|qmd|rmd|ipynb|html?|pdf|png|jpe?g|gif|svg|webp|tiff?|py|r|jl|sh|js|mjs|ts|sql|xlsx?|parquet|feather|rds|rdata|h5|h5ad|hdf5|npy|npz|pkl|log|gz|zip|bam|sam|vcf|bed|gtf|gff3?|fasta|fa|fastq|fq|mtx|nc)$/i;function s(e){let t=[],n=e=>{let n=r(e);n&&!t.includes(n)&&t.push(n)};for(let t of e.matchAll(i))n(t[3]);for(let t of e.replace(i,` `).matchAll(a))(t[1].includes(`/`)||o.test(t[1]))&&n(t[1]);return t}function c(e){let t=e.replace(i,(e,t,n)=>n).replace(/^\s*(?:[-*+]|\d+[.)])\s+(\[[ xX]\]\s+)?/gm,``),n=[];return t.replace(/`([^`]*)`/g,(e,t)=>`\0`+(n.push(t)-1)+`\0`).replace(/(\*{1,3})(?=\S)([^*]+?)(?<=\S)\1/g,`$2`).replace(/(^|[^\w])(_{1,3})(?=\S)([^_]+?)(?<=\S)\2(?![\w])/g,`$1$3`).replace(/\u0000(\d+)\u0000/g,(e,t)=>n[Number(t)]).replace(/\s+/g,` `).trim()}var l=e=>e.charAt(0).toUpperCase()+e.slice(1);function u(e){let t=/^(.{2,48}?)\s*(?:=|:)\s+(\S[\s\S]*)$/.exec(e);return!t||t[1].split(/\s+/).length>6||/[.!?]\s/.test(t[1])?{topic:null,rest:e}:{topic:t[1],rest:l(t[2])}}function d(e,t){let n=e.trim(),r=``,i=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);for(let e=!0;e;){e=!1;for(let a of t){let t=RegExp(`[\\s,;]*\\(?`+i(a)+`\\)?([.;]?)$`).exec(n);t&&(n=n.slice(0,t.index),r||=t[1],e=!0)}}return n=n.replace(/[\s,;]+$/,``),r&&!/[.!?;:]$/.test(n)?n+r:n}var f=/^(\s*)([-*+]|\d+[.)])\s+(.*)$/,p=/^\s*!\[([^\]]*)\]\(\s*(<[^>]+>|[^)\s]+)(?:\s+"[^"]*")?\s*\)\s*$/,m=/^(alternatives?|instead|other(wise)?|或者|备选|替代)\b\s*[::-]?\s*/i,h=/(?<=[.;!?)\]—])\s+(?=(?:\*\*|__)?(?:alternatives?|instead|otherwise|备选|替代)(?:\*\*|__)?\s*[::])/i;function g(t){let i=t.split(`
2
2
  `),a=e(t);return a.map((e,t)=>{let o=t+1<a.length?a[t+1].line:_(i,e.line),l=[],u=null,d=null,g=null,v=``,y=()=>{let e=d;if(d=null,!e)return;if(e.kind===`choice`&&!e.alternatives.length){let[t,...n]=v.split(h);n.length&&(v=t,e.alternatives=n.map(e=>({text:``,source:e,links:[]})))}let t=e.kind===`choice`?v:e.source;e.text=c(t),e.links=s(t);for(let t of e.alternatives??[])t.text=c(t.source.replace(/^\s*(?:[-*+]|\d+[.)])\s+/,``)).replace(m,``),t.links=s(t.source);if(e.text||e.links.length)return l.push(e),l.length-1};for(let t=e.line+1;t<o;t++){let e=i[t],a=/^\s*(`{3,}|~{3,})/.exec(e);if(a){y(),g=g===null?a[1][0]:g===a[1][0]?null:g;continue}if(g!==null)continue;let o=/^#{3,6}\s+(.+?)\s*#*\s*$/.exec(e);if(o){y(),u=n(o[1]);continue}if(!u||/^\s*<!--.*-->\s*$/.test(e))continue;if(!e.trim()){d&&!f.test(i[t+1]??``)&&!/^\s+\S/.test(i[t+1]??``)&&y();continue}let s=p.exec(e);if(s){let n=d?.kind===`finding`,i=y(),a=r(s[2]);a&&l.push({kind:`figure`,text:s[1].trim(),source:e.trim(),line:t,links:[a],...n&&i!==void 0?{of:i}:{}});continue}let c=f.exec(e);if(c&&c[1].length<=1){y();let n=/^\[([ xX])\]\s+/.exec(c[3]);d={kind:u===`todo`||n&&u!==`choice`?`todo`:u,text:``,source:e.trim(),line:t,links:[],...n?{done:n[1]!==` `}:{}},d.kind===`choice`&&(d.alternatives=[],v=e.trim())}else if(d&&d.kind===`choice`){let t=d.alternatives;c?t.push({text:``,source:e.trim(),links:[]}):t.length?t.at(-1).source+=`
3
3
  `+e.trim():v+=`
4
4
  `+e.trim(),d.source+=`
@@ -0,0 +1,6 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/graph-BU2_o5uA.js","assets/rolldown-runtime-XKyaHtl9.js","assets/react-Dss-ouuy.js","assets/markdown-0ngRuTpW.js","assets/previews-pWNik-2g.js","assets/home-CCbP6kS-.js","assets/index-CWg9XYXx.js","assets/index-C16mXVvk.css","assets/work-turns-DSabCogR.js","assets/snapshot-CAxBYPvV.js","assets/timeline-events-DKTho9fU.js","assets/choices-D8vGwsl2.js","assets/notes-meaning-T2m5zQfv.js","assets/choices-DLah50GC.css","assets/graph-BYKN84J3.css"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./react-Dss-ouuy.js";import{a as r,n as i,r as a,s as o}from"./home-CCbP6kS-.js";import{r as s}from"./markdown-0ngRuTpW.js";import{F as c,J as l,W as u,a as d,c as f,d as p,f as m,i as h,l as g,m as _,o as v,u as ee,y as te}from"./previews-pWNik-2g.js";import{Ct as ne,Dt as re,Ft as ie,Lt as y,Mt as ae,Ot as oe,Q as b,St as se,Vt as ce,X as x,Y as S,Z as C,bt as le,gt as ue,i as w,jt as de,m as T,ut as E,vt as D,xt as fe,y as O,yt as pe}from"./index-CWg9XYXx.js";import{c as me,d as he,f as ge,l as _e,t as ve,u as ye}from"./facts-BMO6V3-3.js";import{t as k}from"./work-turns-DSabCogR.js";import{n as be,t as A}from"./choices-D8vGwsl2.js";import{t as j,u as M}from"./skills-work-BEGqlCkx.js";import{t as N}from"./explore-in-BfSFGRh2.js";import{n as P,r as xe}from"./answer-board-CeYS8k8y.js";var F=e(n(),1),I=t(),L={running:`Answering`,completed:`Last message answered`,failed:`Last message failed`,stopped:`Stopped`,unknown:`Outcome unknown`,retained:`Retained native activity`,idle:`No messages`};function R(e,t,n,r){let[i,a]=(0,F.useState)(null),[o,s]=(0,F.useState)(``),[c,l]=(0,F.useState)(!1),u=(0,F.useRef)(null),d=(0,F.useRef)(null);return(0,F.useEffect)(()=>{if(!n)return;let i=!0,o=!1,c=!1,f=new AbortController,p=async()=>{if(o)c=!0;else{o=!0,l(!0);try{let n=await e.call(`project.work.read`,{projectId:t.project.id},f.signal);i&&(a(n),s(``),r(n.sessions.length>0))}catch(e){i&&s(e instanceof Error?e.message:`Could not read project work.`)}finally{o=!1,i&&(l(!1),c&&(c=!1,m()))}}},m=()=>{u.current||=setTimeout(()=>{u.current=null,p()},750)};d.current=m,p();let h=setInterval(()=>{document.hidden||m()},1500);return()=>{clearInterval(h),i=!1,f.abort(),u.current&&clearTimeout(u.current),u.current=null,d.current=null}},[e,t.project.id,n]),(0,F.useEffect)(()=>{d.current?.()},[t.cursor]),{work:i,problem:o,reading:c,refresh:()=>d.current?.()}}function Se({state:e,openConversation:t,openActivity:n,boarded:r=!1}){let{work:i,problem:a,reading:o,refresh:s}=e,c=i?.sessions.filter(e=>!e.conversationId||(e.pendingPermissions??0)>0||!r&&e.state===`running`)??[];return!c.length&&!a?null:(0,I.jsxs)(`section`,{className:`project-section project-work`,"aria-label":`Project work`,children:[(0,I.jsxs)(`div`,{className:`section-heading`,children:[(0,I.jsx)(`h2`,{children:`Work progress`}),(0,I.jsx)(`button`,{className:`text-button`,disabled:o,onClick:s,children:o?`Reading…`:`Refresh`})]}),a&&(0,I.jsxs)(`p`,{role:`alert`,children:[a,` Retained observations remain below.`]}),c.length>0&&(0,I.jsx)(`div`,{className:`work-sessions`,children:c.map(e=>(0,I.jsxs)(`article`,{className:`work-session`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{children:e.title}),(0,I.jsxs)(`p`,{children:[L[e.state]??e.state,` · `,e.source===`acp`?e.agent===`codex`?`Codex · ACP`:`Claude Code · ACP`:e.source===`external-acp`?`External ACP`:e.source===`native-transcript`?`Native transcript`:e.source===`external-session`?`DeepSeek Harness · Outside Rho`:`Claude CLI`]})]}),e.conversationId?(0,I.jsx)(`button`,{onClick:()=>t(e.conversationId),children:`Continue conversation`}):e.source===`external-acp`?(0,I.jsx)(`span`,{className:`muted`,children:`Input stays in the original client`}):(0,I.jsx)(`button`,{onClick:()=>e.source===`external-session`?t(e.id):n(),children:e.source===`external-session`?`View conversation`:`View activity`})]}),e.observation?(0,I.jsx)(pe,{observation:e.observation}):e.source===`native-transcript`?(0,I.jsxs)(`p`,{className:`muted`,children:[`Input stays in the original window. Retained through cursor `,e.cursor,`; `,e.droppedEvents??0,` events dropped.`]}):e.source===`external-session`?(0,I.jsx)(`p`,{className:`muted`,children:`Messages, tool calls and reported results come from the Agent’s own record.`}):(0,I.jsx)(`p`,{className:`muted`,children:`No session projection retained yet.`}),e.source===`external-acp`&&(0,I.jsxs)(I.Fragment,{children:[(e.pendingPermissions??0)>0&&(0,I.jsx)(`p`,{role:`status`,children:`Waiting for a permission choice in the original client.`}),e.lastMessage&&(0,I.jsxs)(`details`,{children:[(0,I.jsx)(`summary`,{children:`Latest reply · read only`}),(0,I.jsx)(`p`,{className:`external-reply`,children:e.lastMessage}),(e.omittedMessageChars??0)>0&&(0,I.jsx)(`small`,{children:`Later reply text was not retained.`})]})]})]},e.id))})]})}var z=e=>/\.(png|jpe?g|svg|gif|pdf|tiff?|webp)$/i.test(e)?`image`:/\.(csv|tsv|xlsx?|parquet|rds|rda|feather)$/i.test(e)?`table`:/\.(R|r|py|sh|sql|js|ts|jl|Rmd|qmd)$/.test(e)?`code`:/\.(md|txt)$/i.test(e)?`document`:`file`;function Ce({work:e,openFile:t,openActivity:n}){if(!e||!e.files.length&&!e.omitted.fileReferences)return null;let r=[...e.files].sort((e,t)=>t.references.length-e.references.length),i=Math.max(1,...r.map(e=>e.references.length)),a=e.omitted.fileReferences;return(0,I.jsxs)(`section`,{className:`project-section touched-files`,"aria-labelledby":`touched-title`,children:[(0,I.jsxs)(`div`,{className:`section-heading`,children:[(0,I.jsx)(`h2`,{id:`touched-title`,children:`Files the Agent used`}),(0,I.jsx)(`span`,{className:`touched-unit`,children:`Tool calls`})]}),(0,I.jsx)(`ul`,{className:`touched-list`,children:r.map((n,r)=>{let a=n.path.split(`/`),o=a.pop(),c=a.join(`/`),l=n.state===`observed`,u=[...new Set(n.references.map(t=>e.sessions.find(e=>e.id===t.session)?.title??t.session))];return(0,I.jsx)(`li`,{children:(0,I.jsxs)(`button`,{className:`touched-row`+(r===0?` top`:``),"aria-label":n.path,title:`${n.path}\nNamed in ${u.join(`, `)}`,disabled:!l,onClick:()=>t(n.path),children:[(0,I.jsx)(s,{name:z(o),size:16,stroke:1.6}),(0,I.jsxs)(`span`,{className:`touched-name`,children:[(0,I.jsx)(`strong`,{children:o}),(0,I.jsx)(`small`,{children:l?c||`Project folder`:n.state.replaceAll(`-`,` `)}),(0,I.jsx)(`i`,{"aria-hidden":`true`,style:{width:`${Math.max(4,n.references.length/i*100)}%`}})]}),(0,I.jsx)(`span`,{className:`touched-count`,children:n.references.length})]})},n.path)})}),a>0&&(0,I.jsxs)(`p`,{className:`touched-more`,children:[a,` more outside the project or past the limit`]}),e.native.state===`available`&&(0,I.jsxs)(`button`,{className:`text-button touched-native`,onClick:n,children:[`View native activity `,(0,I.jsx)(s,{name:`chevron`,size:12})]})]})}function we({work:e,openFile:t}){let n=e?.notes.path??`project-notes.md`;return(0,I.jsxs)(`button`,{className:`notes-card`,"aria-label":`Open shared notes`,onClick:()=>t(n),children:[(0,I.jsxs)(`span`,{className:`notes-sheet`,"aria-hidden":`true`,children:[(0,I.jsx)(`i`,{}),(0,I.jsx)(`i`,{}),(0,I.jsx)(`i`,{})]}),(0,I.jsxs)(`span`,{className:`notes-name`,children:[(0,I.jsx)(`strong`,{children:`Shared notes`}),(0,I.jsx)(`small`,{children:n})]}),(0,I.jsx)(s,{name:`chevron`,size:14})]})}var B=e=>({path:e.path,bytes:e.bytes,modifiedAt:e.modifiedAt,resource:e.resource?{...e.resource,kind:/\.(csv|tsv)$/i.test(e.path)?`table`:`file`}:void 0}),Te={completed:`Answered`,failed:`Failed`,stopped:`Stopped`,running:`Working`,unknown:`Outcome unknown`};function V(e){let t=typeof e==`number`?e:typeof e==`string`&&/^-?\d+\.\d+(?:e[-+]?\d+)?$/i.test(e.trim())?Number(e):NaN;return Number.isFinite(t)?String(Number.isInteger(t)?t:Math.abs(t)>=1e5?Math.round(t):Number(t.toPrecision(4))):e==null?``:String(e)}function H({client:e,snapshot:t,node:n}){let r=(0,F.useContext)(T),[i,a]=(0,F.useState)(null),o=n.path+`@`+(n.resource?.version??n.modifiedAt);if((0,F.useEffect)(()=>{let r=!0;return h(e,t,B(n)).then(e=>{r&&a(e)}),()=>{r=!1}},[o]),!i)return(0,I.jsx)(`span`,{className:`board-figure loading`,"aria-hidden":`true`});if(i.kind!==`image`)return(0,I.jsx)(`span`,{className:`board-figure none`,children:i.kind===`none`?i.note:``});let s=(0,I.jsx)(`img`,{className:`board-figure`,src:i.url,alt:n.title});return i.sha256&&r?.figure?(0,I.jsx)(I.Fragment,{children:r.figure({client:e,projectId:t.project.id,file:{path:n.path,sha256:i.sha256},label:n.title,name:n.title,cursor:t.cursor,fallback:s})}):s}function Ee({client:e,snapshot:t,node:n,rows:r}){let[i,a]=(0,F.useState)(void 0),o=n.path+`@`+(n.resource?.version??n.modifiedAt);if((0,F.useEffect)(()=>{let i=!0;return d(e,t,B(n),r).then(e=>{i&&a(e)}),()=>{i=!1}},[o,r]),i===void 0)return(0,I.jsx)(`span`,{className:`board-table loading`,"aria-hidden":`true`});if(!i)return(0,I.jsx)(`p`,{className:`board-note`,children:`This table could not be read.`});let s=i.rows.slice(0,r);return(0,I.jsxs)(`div`,{className:`board-table-wrap`,children:[(0,I.jsxs)(`table`,{className:`board-table`,children:[(0,I.jsx)(`thead`,{children:(0,I.jsx)(`tr`,{children:i.columns.map(e=>(0,I.jsx)(`th`,{title:e,children:e},e))})}),(0,I.jsx)(`tbody`,{children:s.map((e,t)=>(0,I.jsx)(`tr`,{children:i.columns.map(t=>(0,I.jsx)(`td`,{title:e[t]===null||e[t]===void 0?``:String(e[t]),children:V(e[t])},t))},t))})]}),(0,I.jsxs)(`small`,{children:[i.total>s.length?`First ${s.length} of ${i.total.toLocaleString()} rows`:`${i.total.toLocaleString()} ${i.total===1?`row`:`rows`}`,i.width>i.columns.length?` · ${i.columns.length} of ${i.width} columns`:``]})]})}function U(e,t){let n=e.split(`
3
+ `),r=[],i=/\.py$/i.test(t),a=/\.[rR]$/.test(t);return n.forEach((e,t)=>{let n=/^#{1,3}\s*[-=#*]*\s*([A-Za-z0-9].{2,80}?)\s*[-=#*]*\s*$/.exec(e);i&&/^(?:async\s+)?(?:def|class)\s+\w+/.test(e)?r.push({line:t+1,text:e.replace(/\s*:\s*$/,``).replace(/^async\s+/,``)}):a&&/^[\w.]+\s*(?:<-|=)\s*function\s*\(/.test(e)?r.push({line:t+1,text:e.replace(/\s*\{\s*$/,``)}):n&&!/^#!/.test(e)&&!/^#\s*(?:TODO|NOTE|FIXME)\b/i.test(e)&&r.push({line:t+1,text:n[1]})}),{lines:n.length-+(n.at(-1)===``),marks:r}}function De({client:e,snapshot:t,node:n}){let[r,i]=(0,F.useState)(void 0),a=n.path+`@`+(n.resource?.version??n.modifiedAt);if((0,F.useEffect)(()=>{let r=!0;return v(e,t,B(n)).then(e=>{r&&i(e)}),()=>{r=!1}},[a]),r===void 0)return(0,I.jsx)(`span`,{className:`board-outline loading`,"aria-hidden":`true`});if(!r)return null;let{lines:o,marks:s}=U(r.text,n.path);return(0,I.jsxs)(`div`,{className:`board-outline`,children:[s.length>0&&(0,I.jsx)(`ol`,{children:s.slice(0,12).map(e=>(0,I.jsxs)(`li`,{children:[(0,I.jsx)(`span`,{children:e.line}),(0,I.jsx)(`code`,{children:e.text})]},e.line))}),(0,I.jsxs)(`small`,{children:[o.toLocaleString(),` lines`,r.cut?` (more than Rho read)`:``,s.length>12?` · ${s.length-12} more sections`:``]})]})}function W({client:e,snapshot:t,node:n,lines:r}){let[i,a]=(0,F.useState)(void 0),o=n.path+`@`+(n.resource?.version??n.modifiedAt);if((0,F.useEffect)(()=>{let r=!0;return v(e,t,B(n)).then(e=>{r&&a(e)}),()=>{r=!1}},[o]),i===void 0)return(0,I.jsx)(`span`,{className:`board-text loading`,"aria-hidden":`true`});if(!i)return null;let s=i.text;if(/\.json$/i.test(n.path)&&!i.cut)try{s=JSON.stringify(JSON.parse(s),null,2)}catch{}let c=s.replace(/\n$/,``).split(`
4
+ `);return(0,I.jsxs)(`div`,{className:`board-text`,children:[(0,I.jsx)(`pre`,{children:c.slice(0,r).join(`
5
+ `)}),(c.length>r||i.cut)&&(0,I.jsxs)(`small`,{children:[`First `,Math.min(r,c.length),` of `,i.cut?`more than `+c.length:c.length.toLocaleString(),` lines`]})]})}function G({node:e}){let t=e.outcome===`returned`&&(!e.end||/^exit 0\b/i.test(e.end));return(0,I.jsxs)(`details`,{className:`board-run`,children:[(0,I.jsxs)(`summary`,{children:[(0,I.jsxs)(`code`,{title:e.ran??e.command,children:[`$ `,xe(e.ran??e.command??``)]}),(0,I.jsxs)(`span`,{className:`board-run-end`+(t?``:` problem`),children:[e.end??(e.outcome===`requested`?`Running`:`Returned`),e.durationMs?` · `+y(e.durationMs):``]})]}),(0,I.jsx)(`pre`,{className:`board-run-full`,children:e.ran??e.command}),e.output?.text?(0,I.jsx)(`pre`,{ref:e=>{e&&(e.scrollTop=e.scrollHeight)},children:e.output.text}):(0,I.jsx)(`p`,{className:`board-note`,children:`The Agent reported no output for this command.`})]})}var Oe=(e,t)=>e.length>t?e.slice(0,t-1).trimEnd()+`…`:e,K=e=>e instanceof Error?e.message:`The message could not be sent.`;function ke({about:e,onSend:t,onCancel:n}){let[r,i]=(0,F.useState)(``),[a,o]=(0,F.useState)(!1),[s,c]=(0,F.useState)(``),l=(0,F.useRef)(null);(0,F.useEffect)(()=>{l.current?.focus()},[]);async function u(){if(r.trim()&&!a){o(!0),c(``);try{await t(r)}catch(e){c(K(e))}finally{o(!1)}}}return(0,I.jsxs)(`form`,{className:`board-ask-box`,onSubmit:e=>{e.preventDefault(),u()},onKeyDown:e=>{e.key===`Escape`&&n()},children:[e.kind===`passage`?(0,I.jsx)(`blockquote`,{children:e.text}):e.kind===`file`?(0,I.jsxs)(`p`,{className:`board-ask-about`,children:[`About `,(0,I.jsx)(`strong`,{children:e.title}),e.resource?` as this message left it`:``]}):(0,I.jsxs)(`p`,{className:`board-ask-about`,children:[(0,I.jsx)(`strong`,{children:`What needs to change?`}),` The Agent receives your words.`]}),(0,I.jsx)(`textarea`,{ref:l,rows:2,value:r,"aria-label":e.kind===`changes`?`What needs to change`:`Your question`,placeholder:e.kind===`changes`?`Say what is wrong or missing`:`What do you want to know or change?`,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),u())}}),s&&(0,I.jsx)(`p`,{className:`inline-error`,role:`alert`,children:s}),(0,I.jsxs)(`div`,{className:`board-ask-actions`,children:[(0,I.jsx)(`button`,{type:`button`,onClick:n,children:`Cancel`}),(0,I.jsx)(`button`,{type:`submit`,className:`primary`,disabled:a||!r.trim(),children:a?`Sending…`:e.kind===`changes`?`Send to the Agent`:`Ask the Agent`})]})]})}function q({text:e}){return(0,I.jsx)(I.Fragment,{children:e.split("`").map((e,t)=>t%2?(0,I.jsx)(`code`,{children:e},t):e)})}function J({client:e,snapshot:t,item:n,onPath:r,onExplore:i,said:a,span:o,ask:c,holds:l}){let{node:u,role:d}=n,f=u.category===`figures`,p=/\.(csv|tsv)$/i.test(u.path??``),m=d===`run`?null:f?(0,I.jsx)(H,{client:e,snapshot:t,node:u}):p&&(d===`primary`||d===`supporting`)?(0,I.jsx)(Ee,{client:e,snapshot:t,node:u,rows:d===`primary`?12:5}):d===`method`?(0,I.jsx)(De,{client:e,snapshot:t,node:u}):(d===`primary`||d===`supporting`)&&/\.(json|txt|md|ya?ml|log)$/i.test(u.path??``)?(0,I.jsx)(W,{client:e,snapshot:t,node:u,lines:d===`primary`?16:8}):null;return d===`run`?(0,I.jsxs)(`div`,{className:`board-item role-run`,children:[(0,I.jsx)(G,{node:u}),(0,I.jsx)(`small`,{className:`board-why`,children:(0,I.jsx)(q,{text:n.why})})]}):(0,I.jsxs)(`article`,{className:`board-item role-`+d+(o?` span-`+o:``)+(c?.open?` asking`:``),children:[(0,I.jsxs)(`header`,{children:[(0,I.jsxs)(`div`,{className:`board-item-title`,children:[(0,I.jsxs)(`button`,{className:`board-name`,title:`Show `+u.path,onClick:()=>r(u.path),children:[(0,I.jsx)(s,{name:se(u.path),size:15,stroke:1.7}),(0,I.jsx)(`strong`,{children:u.title})]}),(0,I.jsxs)(`span`,{className:`board-item-actions`,children:[c&&(0,I.jsx)(`button`,{className:`text-button board-ask-button`,"aria-expanded":c.open,onClick:c.toggle,children:`Ask`}),i&&C(u.path)&&w(t)&&(0,I.jsx)(N,{languages:[`r`,`python`],title:e=>`Open ${u.title} in Studio with the Notebook beside it, loaded into the ${b[e]} session as a new value`,onExplore:e=>i(u.path,e)})]})]}),l&&(0,I.jsx)(E,{className:`board-holds`,holds:l}),n.why!==a&&(0,I.jsx)(`small`,{className:`board-why`,children:(0,I.jsx)(q,{text:n.why})})]}),c?.open&&c.box,m]})}function Ae({record:e,graph:t,shown:n,onDecide:r,onNeedsChanges:i}){let a=e.decisions?.at(-1),[o,c]=(0,F.useState)(!1),[l,u]=(0,F.useState)(!1),[d,f]=(0,F.useState)(!1),[p,m]=(0,F.useState)(``);if((0,F.useEffect)(()=>{c(!1),u(!1),m(``)},[e.id,a?.changeId]),e.state===`running`||ie(e)&&!a)return null;let h=a?a.results.filter(e=>{let n=t.nodes.find(t=>t.kind===`file`&&t.path===e.path);return!!n?.modifiedAt&&Date.parse(n.modifiedAt)>Date.parse(a.at)+1e3}):[],g=a?n.filter(e=>!a.results.some(t=>t.path===e)):[];async function _(){f(!0),m(``);try{await r()}catch(e){m(K(e))}finally{f(!1)}}return l?(0,I.jsx)(`div`,{className:`board-verdict`,children:(0,I.jsx)(ke,{about:{kind:`changes`},onSend:i,onCancel:()=>u(!1)})}):(0,I.jsxs)(`div`,{className:`board-verdict`+(a&&!o?` `+a.decision:``),children:[a&&!o?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`p`,{children:[(0,I.jsx)(s,{name:a.decision===`accepted`?`check`:`pencil`,size:14,stroke:2}),` `,(0,I.jsx)(`strong`,{children:a.decision===`accepted`?`You chose to use this answer`:`You said this needs changes`}),(0,I.jsxs)(`span`,{className:`board-meta`,children:[` · `,fe(a.at),` · for the `,a.results.length,` `,a.results.length===1?`file version`:`file versions`,` this message kept`]})]}),a.note&&(0,I.jsx)(`blockquote`,{children:a.note}),g.length>0&&(0,I.jsxs)(`p`,{className:`board-meta`,children:[`Not covered: no version was kept of `,g.map(e=>e.split(`/`).at(-1)).join(`, `),`.`]}),h.length>0&&(0,I.jsxs)(`p`,{className:`board-verdict-since`,children:[`Changed since: `,h.map(e=>e.path.split(`/`).at(-1)).join(`, `),`. The decision does not cover the new `,h.length===1?`version`:`versions`,`.`]}),(0,I.jsx)(`button`,{className:`text-button`,onClick:()=>c(!0),children:`Change`})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`board-meta`,children:`Will you use this answer?`}),(0,I.jsxs)(`div`,{className:`board-verdict-actions`,children:[(0,I.jsx)(`button`,{className:`primary`,disabled:d,onClick:()=>void _(),children:d?`Saving…`:`Use this answer`}),(0,I.jsx)(`button`,{disabled:d,onClick:()=>u(!0),children:`Needs changes`}),o&&(0,I.jsx)(`button`,{className:`text-button`,onClick:()=>c(!1),children:`Cancel`})]})]}),p&&(0,I.jsx)(`p`,{className:`inline-error`,role:`alert`,children:p})]})}function je({id:e,node:t,running:n,at:r,onOpen:i}){if(!t)return null;let{about:a,quote:o,question:c}=ae(t.text??``);return(0,I.jsxs)(`li`,{className:`board-follow-up`,id:`board-follow-`+e,children:[(0,I.jsxs)(`div`,{className:`board-follow-ask`,children:[(a||o)&&(0,I.jsx)(`span`,{className:`board-follow-about`,title:o??a??``,children:a?`About `+(a.split(`/`).at(-1)??a):`“`+Oe(o,60)+`”`}),(0,I.jsx)(`p`,{children:c}),(0,I.jsxs)(`button`,{className:`text-button`,onClick:i,children:[n?`Answering…`:new Date(r).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}),` `,(0,I.jsx)(s,{name:`chevron`,size:12})]})]}),t.answer?(0,I.jsx)(le,{text:t.answer,streaming:n}):n?(0,I.jsx)(`p`,{className:`board-note`,role:`status`,children:`The Agent is working on this.`}):null]})}function Me({client:e,snapshot:t,files:n,notesText:r=``,onConversation:i,onPath:a,onExplore:o,onConsole:c,onGraph:l,onAsked:d}){let{turns:f,loading:p}=k(e,t),m=(0,F.useMemo)(()=>n.files.map(e=>({path:e.path,bytes:e.bytes,modifiedAt:e.modifiedAt,category:e.category})),[n.files]),h=(0,F.useMemo)(()=>oe(re({turns:f,files:m,project:t.project,kindOf:u,now:Date.now()})),[f,m,t.project]),g=be(e,t,h,m,r,f),_=(0,F.useMemo)(()=>P(h),[h]),[v,ee]=(0,F.useState)(null),te=v&&_.find(e=>e.turn.id===v)||_[0],y=te?.turn,b=te?.board,ce=te?.followUps??[],[x,S]=(0,F.useState)(null),[C,ue]=(0,F.useState)(null),w=(0,F.useRef)(null),T=(0,F.useRef)(null),E=(0,F.useRef)(null);if((0,F.useEffect)(()=>{S(null),ue(null)},[y?.id]),p||!b||!y)return null;let D=y.conversationId,O=!!f.find(e=>e.conversationId+`/`+e.turn.id===y.id)?.external,pe=t.conversations?.find(e=>e.conversationId===D)?.state===`running`;async function me(n,r){let a=de(n,r);w.current?.text!==a&&(w.current={text:a,changeId:`ask-`+crypto.randomUUID()}),await e.call(`conversation.send`,{projectId:t.project.id,conversationId:D,changeId:w.current.changeId,text:a}),w.current=null,S(null),(d??i)(D)}async function he(n,r){let i=y.id+`:`+n+`:`+(r??``);T.current?.key!==i&&(T.current={key:i,changeId:`decide-`+crypto.randomUUID()}),await e.call(`conversation.decide`,{projectId:t.project.id,conversationId:D,turnId:M.id,changeId:T.current.changeId,decision:n,...r?{note:r}:{}}),T.current=null}async function ge(n){await he(`needs-changes`,n.trim());let r=`Needs changes: `+n.trim();w.current?.text!==r&&(w.current={text:r,changeId:`ask-`+crypto.randomUUID()}),await e.call(`conversation.send`,{projectId:t.project.id,conversationId:D,changeId:w.current.changeId,text:r}),w.current=null,(d??i)(D)}let _e=(e,t)=>x?.key===e?(0,I.jsx)(ke,{about:x.about,onSend:e=>me(x.about,e),onCancel:()=>S(null)}):null,ve=e=>{let t=`file:`+e.node.path;return{open:x?.key===t,toggle:()=>S(x?.key===t?null:{key:t,about:{kind:`file`,path:e.node.path,title:e.node.title,resource:e.node.resource??null}}),box:_e(t,{kind:`file`,path:e.node.path,title:e.node.title})}};function ye(){let e=getSelection(),t=e?.toString().trim()??``,n=E.current;if(!e||!t||!n||!e.rangeCount||!n.contains(e.anchorNode)||!n.contains(e.focusNode)){ue(null);return}let r=e.getRangeAt(0).getBoundingClientRect(),i=n.getBoundingClientRect();ue({text:t.slice(0,2e3),top:r.bottom-i.top+6,left:Math.max(0,Math.min(r.left-i.left,i.width-140))})}let{question:j}=b,M=f.find(e=>e.conversationId+`/`+e.turn.id===y.id)?.turn,N=e=>b.items.filter(t=>t.role===e),L=N(`primary`)[0],R=N(`supporting`),Se=N(`method`),z=N(`run`),Ce=N(`input`),we=N(`report`),B=e=>b.omitted[e]?(0,I.jsxs)(`small`,{className:`board-more`,children:[b.omitted[e],` more in Files`]}):null,V=y.running?h.live:null,H=V&&h.nodes.find(e=>e.id===V.node),Ee=V&&H&&H.kind!==`question`?V.label+` `+(H.kind===`run`&&H.ran?xe(H.ran):H.title):V?.waiting?V.label:null,U=ce.find(e=>e.running),De=U?{id:U.id,title:Oe(ae(h.nodes.find(e=>e.id===`q:`+U.id)?.text??``).question.split(`
6
+ `)[0],60)}:null,W=[L,...R].filter(Boolean),G=e=>e.node.path?g.holds(e.node.path):void 0,K=g.meanings.find(e=>e.conversationId===D)?.statements.filter(e=>e.kind===`choice`)??[],Me=W.length>1&&W.every(e=>e.why===W[0].why)?W[0].why:void 0,Ne=(L?Math.max(0,R.length-2):R.length)%3;return(0,I.jsxs)(`section`,{className:`project-section answer-board`,"aria-labelledby":`board-title`,children:[(0,I.jsxs)(`header`,{className:`board-head`,children:[(0,I.jsxs)(`div`,{className:`board-ask`,children:[(0,I.jsx)(`h2`,{id:`board-title`,title:j.text,children:j.title}),(0,I.jsxs)(`p`,{className:`board-meta`,children:[(0,I.jsx)(`span`,{className:`work-state `+(j.state??``),children:M&&ie(M)?`Turn limit reached`:Te[j.state??``]??j.state}),M&&(0,I.jsxs)(I.Fragment,{children:[` · `,fe(M.endedAt??M.sentAt),M.endedAt&&ne(M.startedAt??M.sentAt,M.endedAt)?` · took `+ne(M.startedAt??M.sentAt,M.endedAt):``]}),Ee&&(0,I.jsxs)(I.Fragment,{children:[` · `,(0,I.jsx)(`span`,{className:`board-live`+(V?.waiting?` waiting`:``),title:Ee,children:Ee})]}),De&&(0,I.jsxs)(I.Fragment,{children:[` · `,(0,I.jsxs)(`button`,{className:`text-button board-live`,onClick:()=>document.getElementById(`board-follow-`+De.id)?.scrollIntoView({block:`center`,behavior:`smooth`}),children:[`Answering “`,De.title,`”`]})]})]})]}),(0,I.jsxs)(`div`,{className:`board-actions`,children:[_.length>1&&(0,I.jsx)(`select`,{"aria-label":`Answer to show`,value:y.id,onChange:e=>ee(e.target.value),children:_.map(({turn:e})=>(0,I.jsxs)(`option`,{value:e.id,children:[new Date(e.start).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}),` · `,h.nodes.find(t=>t.id===`q:`+e.id)?.title??`A message`]},e.id))}),(0,I.jsxs)(`button`,{className:`text-button`,onClick:()=>i(y.conversationId),children:[`Conversation `,(0,I.jsx)(s,{name:`chevron`,size:12})]})]})]}),j.answer?(0,I.jsxs)(`div`,{className:`board-answer`,ref:E,onMouseUp:ye,onKeyUp:ye,children:[(0,I.jsx)(le,{text:j.answer,streaming:!!y.running}),C&&!y.running&&!O&&(0,I.jsx)(`button`,{className:`board-select-ask`,style:{top:C.top,left:C.left},onMouseDown:e=>e.preventDefault(),onClick:()=>{S({key:`passage`,about:{kind:`passage`,text:C.text}}),ue(null),getSelection()?.removeAllRanges()},children:`Ask about this`})]}):y.running?(0,I.jsx)(`p`,{className:`board-note`,role:`status`,children:`The Agent is working on this message.`}):null,x?.key===`passage`&&_e(`passage`,x.about),pe&&x&&(0,I.jsx)(`p`,{className:`board-note`,children:`The Agent is still answering. Your question can be sent when it has finished.`}),(L||R.length>0)&&(0,I.jsxs)(`div`,{className:`board-results-block`,children:[(0,I.jsxs)(`p`,{className:`board-results-why`,children:[(0,I.jsx)(`strong`,{children:`Results`}),Me&&(0,I.jsxs)(I.Fragment,{children:[` · `,(0,I.jsx)(q,{text:Me})]})]}),(0,I.jsxs)(`div`,{className:`board-results beside-`+Math.min(R.length,2),children:[L&&(0,I.jsx)(J,{client:e,snapshot:t,item:L,onPath:a,onExplore:o,said:Me,holds:G(L),ask:y.running||O?void 0:ve(L)}),R.map((n,r)=>(0,I.jsx)(J,{client:e,snapshot:t,item:n,onPath:a,onExplore:o,said:Me,holds:G(n),span:r>=R.length-Ne?6/Ne:void 0,ask:y.running||O?void 0:ve(n)},n.node.id))]}),B(`supporting`)]}),(Se.length>0||z.length>0||Ce.length>0||we.length>0||b.otherCommands>0)&&(0,I.jsxs)(`div`,{className:`board-how`,children:[Se.length>0&&(0,I.jsxs)(`div`,{className:`board-row`,children:[(0,I.jsx)(`span`,{className:`board-label`,children:`Method`}),(0,I.jsx)(`div`,{className:`board-cells`,children:Se.map(n=>(0,I.jsx)(J,{client:e,snapshot:t,item:n,onPath:a,holds:G(n),ask:y.running||O?void 0:ve(n)},n.node.id))})]}),(z.length>0||b.otherCommands>0)&&(0,I.jsxs)(`div`,{className:`board-row`,children:[(0,I.jsx)(`span`,{className:`board-label`,children:`Ran`}),(0,I.jsxs)(`div`,{className:`board-cells`,children:[z.map(n=>(0,I.jsx)(J,{client:e,snapshot:t,item:n,onPath:a},n.node.id)),b.otherCommands>0&&(0,I.jsxs)(`button`,{className:`text-button board-console`,onClick:()=>c(y.id),children:[z.length?b.otherCommands+` other `+(b.otherCommands===1?`command`:`commands`):b.otherCommands+(b.otherCommands===1?` command`:` commands`),` in the Console `,(0,I.jsx)(s,{name:`chevron`,size:12})]})]})]}),Ce.length>0&&(0,I.jsxs)(`div`,{className:`board-row`,children:[(0,I.jsx)(`span`,{className:`board-label`,children:`From`}),(0,I.jsxs)(`div`,{className:`board-chips`,children:[Ce.map(e=>(0,I.jsxs)(`button`,{className:`work-file`,title:e.why.replaceAll("`",``)+` · `+e.node.path,onClick:()=>a(e.node.path),children:[(0,I.jsx)(s,{name:se(e.node.path),size:14,stroke:1.7}),(0,I.jsx)(`span`,{children:e.node.title})]},e.node.id)),B(`input`)]})]}),we.length>0&&(0,I.jsxs)(`div`,{className:`board-row`,children:[(0,I.jsx)(`span`,{className:`board-label`,children:`Report`}),(0,I.jsx)(`div`,{className:`board-chips`,children:we.map(e=>(0,I.jsxs)(`button`,{className:`work-file`,title:e.why.replaceAll("`",``)+` · `+e.node.path,onClick:()=>a(e.node.path),children:[(0,I.jsx)(s,{name:`document`,size:14,stroke:1.7}),(0,I.jsx)(`span`,{children:e.node.title})]},e.node.id))})]})]}),K.length>0&&(0,I.jsxs)(`div`,{className:`board-choices`,children:[(0,I.jsxs)(`p`,{className:`board-results-why`,children:[(0,I.jsx)(`strong`,{children:`Choices`}),` · what the Agent went with`,K.some(e=>e.alternatives?.length)?`, and the other option where the notes name one`:``]}),K.map(n=>(0,I.jsx)(A,{statement:n,trace:g.traces.get(n),conversationId:D,client:e,projectId:t.project.id,onPath:a,onSent:e=>(d??i)(e)},n.line))]}),ce.length>0&&(0,I.jsxs)(`div`,{className:`board-follow`,children:[(0,I.jsx)(`p`,{className:`board-results-why`,children:(0,I.jsx)(`strong`,{children:`Asked since`})}),(0,I.jsx)(`ol`,{children:ce.map(e=>(0,I.jsx)(je,{id:e.id,node:h.nodes.find(t=>t.id===`q:`+e.id),running:!!e.running,at:e.start,onOpen:()=>i(e.conversationId)},e.id))})]}),M&&!O&&(0,I.jsx)(Ae,{record:M,graph:h,shown:[L,...R,...we].filter(e=>!!e).map(e=>e.node.path),onDecide:()=>he(`accepted`),onNeedsChanges:ge}),O&&(0,I.jsxs)(`p`,{className:`board-note`,children:[`From `,y.agent,`’s own record. `,(0,I.jsx)(`button`,{className:`text-button`,onClick:()=>i(D),children:`Continue this conversation`})]}),(0,I.jsx)(`footer`,{className:`board-foot`,children:(0,I.jsxs)(`button`,{className:`text-button`,onClick:l,children:[`How each file connects, in the Graph `,(0,I.jsx)(s,{name:`chevron`,size:12})]})})]})}var Ne=(0,F.lazy)(()=>O(()=>import(`./graph-BU2_o5uA.js`).then(e=>({default:e.WorkStrip})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]))),Pe=e=>e>=6?6:e>=3?3:e,Y=(e,t)=>/table/.test(e)?`table`:/media|image/.test(e)?`image`:/\.(R|r|py|sh|sql|js|ts)$/.test(t)?`code`:/document|editor|note/.test(e)?`document`:`file`;function Fe({client:e,snapshot:t,item:n,modifiedAt:r}){let i=/\.(png|jpe?g|svg|csv)$/i.test(n.path),[a,o]=(0,F.useState)(null);return(0,F.useEffect)(()=>{if(!i)return;let a=!0;return h(e,t,{path:n.path,bytes:n.bytes,modifiedAt:r,resource:n.resource}).then(e=>{a&&o(e)}),()=>{a=!1}},[n.path,n.bytes,r,n.resource?.version]),i&&!a?(0,I.jsx)(`span`,{className:`figure-thumb loading`,"aria-hidden":`true`}):a?.kind===`image`?(0,I.jsx)(`span`,{className:`figure-thumb image`,children:(0,I.jsx)(`img`,{src:a.url,alt:``})}):a?.kind===`table`?(0,I.jsx)(`span`,{className:`figure-thumb table`,"aria-hidden":`true`,children:(0,I.jsxs)(`span`,{style:{gridTemplateColumns:`repeat(${a.columns.length}, minmax(0, 1fr))`},children:[a.columns.map(e=>(0,I.jsx)(`b`,{children:e},`h`+e)),a.rows.map((e,t)=>a.columns.map(n=>(0,I.jsx)(`i`,{children:e[n]===null||e[n]===void 0?``:String(e[n])},t+n)))]})}):(0,I.jsx)(`span`,{className:`figure-thumb kind`,"aria-hidden":`true`,children:(0,I.jsx)(s,{name:g(n),size:26,stroke:1.4})})}function Ie({composition:e}){let t=c(e),n=new Map(e.views.map(e=>[e.id,e]));if(!t)return(0,I.jsx)(`span`,{className:`mini-layout empty`,children:`Empty workspace`});let r=e=>{if(e.kind===`split`)return(0,I.jsx)(`span`,{className:`mini-split `+e.axis,children:e.children.map((t,n)=>(0,I.jsx)(`span`,{style:{flexGrow:e.weights[n]??1},children:r(t)},t.id))});let t=e.views.flatMap(e=>n.get(e)??[]),i=t[0],a=i?String(i.props.title??i.id):``;return(0,I.jsxs)(`span`,{className:`mini-pane`,children:[(0,I.jsx)(`span`,{className:`mini-tabs`,children:t.slice(0,5).map((e,t)=>(0,I.jsx)(`i`,{className:t===0?`on`:void 0},e.id))}),i&&(0,I.jsxs)(`span`,{className:`mini-face`,children:[(0,I.jsx)(s,{name:Y(String(i.component),a),size:13}),(0,I.jsx)(`span`,{children:a})]}),t.length>1&&(0,I.jsxs)(`small`,{children:[`+`,t.length-1]})]})};return(0,I.jsx)(`span`,{className:`mini-layout`,"aria-hidden":`true`,children:r(t)})}function Le(e){return e.provenance?.originalPath??e.path}function Re(e,t){if(!e)return r(t);let[n,...i]=e.split(`/`),a=n.startsWith(`@`)?t.sources?.find(e=>`@`+e.id===n):void 0;return[a?a.name:n,...i].join(`/`)}function X({project:e,snapshot:t,client:n,section:c,notesText:l=``,workspace:u,onExplore:d,onSection:h,onAgent:g,onLayout:v,onProjectChanged:ne,onOpened:re,category:ie,files:y,sources:ae,onFile:oe,linked:b=!1,onPath:se,onNewConversation:C,onConsole:le}){let[w,de]=(0,F.useState)(!1),{runs:T,problem:E,readAgain:fe}=me(n,e.id,t.cursor),[O,pe]=(0,F.useState)(null),[k,be]=(0,F.useState)(null),[A,N]=(0,F.useState)(!1),[P,xe]=(0,F.useState)(``),[L,z]=(0,F.useState)(``),[B,Te]=(0,F.useState)(``),[V,H]=(0,F.useState)(!1),[Ee,U]=(0,F.useState)(``),[De,W]=(0,F.useState)(``),[G,Oe]=(0,F.useState)(null),[K,ke]=(0,F.useState)(!1),[q,J]=(0,F.useState)(null),[Ae,je]=(0,F.useState)(!1),Y=t.catalog.operations.some(e=>e.method===`project.work.read`&&e.authorized),X=R(n,t,c===`overview`&&Y,je),ze=t.catalog.operations.some(e=>e.method===`kernel.read`&&e.state===`available`&&e.authorized),Ve=x(n,e.id,t.cursor,c===`overview`&&ze),He=!ze||Ve.read!==null||!!Ve.problem,Ue=t.catalog.operations.some(e=>e.method===`skills.list`&&e.state===`available`&&e.authorized),We=M(n,e.id,t.cursor,c===`overview`&&Ue),Ge=!!We.problem||[...We.list?.skills??[],...We.list?.removed??[]].some(e=>e.last),Ke=(0,F.useRef)(0),qe=(0,F.useRef)(null),Z=c===`files`||c===`documents`,Je=new Map,Ye=new Map;for(let e of t.compositions)for(let t of e.views)for(let n of Object.values(t.bindings??{}))`id`in n&&`version`in n&&Je.set(n.id+`@`+n.version,{compositionId:e.compositionId,viewId:t.id}),`documentId`in n&&`kind`in n&&n.kind===`live-document`&&Ye.set(String(n.documentId),{compositionId:e.compositionId,viewId:t.id});let Xe=he(t.resources.filter(e=>e.provenance?.source!==`current-filesystem-observation`),T??[]),Ze=[...T??[]].sort((e,t)=>t.acceptedAt.localeCompare(e.acceptedAt)),Qe=new Map((y?.files??[]).map(e=>[e.path,e.modifiedAt])),Q=[...ae?.results??[]].sort((e,t)=>(Qe.get(t.path)??``).localeCompare(Qe.get(e.path)??``)),$e=a(e),et=!t.compositions.length&&!Xe.length&&!t.taskMap?.question&&!t.taskMap?.items.length&&!t.conversations?.length&&!Ae&&!Ve.cells&&!Ve.problem,tt=!et||(T!==null||!!E)&&q!==null&&He,nt=c===`overview`&&et&&T!==null&&T.length===0&&q!==null&&He,rt=!!E||(T?.length??0)>0,it=!!X.work&&(X.work.files.length>0||X.work.omitted.fileReferences>0),at=rt||it||Y||t.compositions.length>0||Ge,$=Pe(Q.length),ot=!!y&&(!!t.conversations?.length||!!X.work?.sessions.some(e=>e.source===`external-session`)),st=(q??0)>0,ct=[{key:`files`,label:`Browse files`,icon:`folder`,run:()=>h(`files`),primary:st},{key:`agent`,label:`Work with Agent`,icon:`prompt`,run:()=>g(),primary:!st}].sort((e,t)=>Number(t.primary)-Number(e.primary));async function lt(t=``){let r=++Ke.current;N(!0),z(``);try{let i=await n.call(`project.entries`,{projectId:e.id,...t?{path:t}:{}});r===Ke.current&&(be(i),Te(``))}catch(e){r===Ke.current&&z(e instanceof Error?e.message:`Could not read this folder. Try again.`)}finally{r===Ke.current&&N(!1)}}(0,F.useEffect)(()=>{Z&&!k&&!A&&lt()},[Z]),(0,F.useEffect)(()=>{if(c!==`overview`||!et)return;let t=!0;return n.call(`project.entries`,{projectId:e.id}).then(e=>{t&&J(e.entries.length)},()=>{t&&J(-1)}),()=>{t=!1}},[n,e.id,c,et]),(0,F.useEffect)(()=>()=>{Ke.current++},[]),(0,F.useEffect)(()=>{O&&!qe.current?.open&&qe.current?.showModal()},[O]);async function ut(r){if(!P){xe(r.path),z(``);try{let i=u(),a=t.compositions.find(e=>e.compositionId===i),o=await n.call(`project.openFile`,{projectId:e.id,path:r.path,compositionId:i,expectedVersion:a?.version??0,changeId:`open-`+crypto.randomUUID()});re(o.composition.compositionId,o.viewId)}catch(e){z(e instanceof Error?e.message:`Could not open this file. Try again.`)}finally{xe(``)}}}async function dt(){H(!0),U(``);try{let t=await n.call(`project.source.add`,{projectId:e.id},new AbortController().signal);t.project&&ne(t.project)}catch(e){U(e instanceof Error?e.message:`Could not add the folder. Try again.`)}finally{H(!1)}}async function ft(){ke(!0),W(``);try{Oe((await n.call(`project.doctor`,{projectId:e.id},new AbortController().signal)).checks)}catch(e){W(e instanceof Error?e.message:`Could not check this project. Try again.`)}finally{ke(!1)}}let pt=e=>(0,I.jsxs)(`button`,{className:`activity-row`,onClick:()=>pe(e.operationId),children:[(0,I.jsx)(`span`,{className:`activity-symbol `+e.execution,children:(0,I.jsx)(s,{name:`run`,size:16})}),(0,I.jsxs)(`span`,{className:`activity-name`,children:[(0,I.jsx)(`strong`,{children:e.operationId}),(0,I.jsxs)(`small`,{children:[e.author,` · `,o(e.acceptedAt).text]})]}),(0,I.jsx)(`span`,{className:`state `+e.execution,children:_e(e.execution)}),(0,I.jsx)(s,{name:`chevron`,size:13})]},e.operationId),mt=(e,t)=>e&&(0,I.jsxs)(`div`,{className:`inline-error`,role:`alert`,children:[(0,I.jsx)(`p`,{children:e}),(0,I.jsx)(`button`,{onClick:t,children:`Try again`})]}),ht=(0,I.jsx)(`ul`,{className:`result-list`,children:Xe.map(({resource:e,run:t,earlier:n})=>{let r=Je.get(e.id+`@`+e.version),i=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`file-symbol`,children:(0,I.jsx)(s,{name:ee(e.kind),size:19,stroke:1.6})}),(0,I.jsxs)(`span`,{className:`result-name`,children:[(0,I.jsx)(`strong`,{title:Le(e),children:ge(Le(e))}),(0,I.jsxs)(`small`,{children:[e.kind,n?` · ${n} earlier version${n===1?``:`s`}`:``,t?` · `+t.operationId:``]})]}),(0,I.jsx)(`span`,{className:`result-state`,children:t?ye(t.integrity):f(e)}),r&&(0,I.jsx)(s,{name:`chevron`,size:14})]});return(0,I.jsx)(`li`,{children:r?(0,I.jsx)(`button`,{className:`result-row`,onClick:()=>v(r.compositionId,r.viewId),children:i}):(0,I.jsxs)(`div`,{className:`result-row`,children:[i,(0,I.jsx)(`small`,{children:`No open view`})]})},e.id+e.version)})}),gt=k?.entries.filter(e=>!B||e.name.toLocaleLowerCase().includes(B.toLocaleLowerCase()))??[],_t=m[ie??`data`],vt=Z?`Files`:c===`agent`?`Agent`:c===`settings`?`Project settings`:c===`sources`?_t:r(e);return(0,I.jsxs)(`section`,{className:`project-page overview`+(Z?` files-page`:``),"aria-labelledby":`overview-title`,children:[(0,I.jsxs)(`header`,{className:`page-heading`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h1`,{id:`overview-title`,children:vt}),c===`overview`&&(0,I.jsx)(`p`,{title:$e.full,children:$e.text})]}),Z&&(0,I.jsxs)(`button`,{onClick:()=>void lt(k?.path),disabled:A,children:[(0,I.jsx)(s,{name:`refresh`,size:15}),`Refresh`]}),c===`sources`&&y&&(0,I.jsxs)(`button`,{onClick:y.refresh,disabled:y.reading,children:[(0,I.jsx)(s,{name:`refresh`,size:15}),`Refresh`]})]}),c===`sources`&&y&&oe&&(0,I.jsx)(Be,{category:ie??`data`,files:y,items:ae?.[ie??`data`]??null,artifacts:Xe,onFile:oe}),c===`overview`&&Y&&(0,I.jsx)(Se,{state:X,boarded:ot,openConversation:g,openActivity:()=>h(`agent`)}),c===`overview`&&L&&(0,I.jsx)(`p`,{role:`alert`,children:L}),nt&&(0,I.jsxs)(`div`,{className:`empty-project`,children:[(0,I.jsx)(`span`,{className:`empty-symbol`,children:(0,I.jsx)(s,{name:`grid`,size:26,stroke:1.5})}),(0,I.jsx)(`h2`,{children:`No work yet`}),(0,I.jsx)(`div`,{className:`empty-actions`,children:ct.map(e=>(0,I.jsxs)(`button`,{className:e.primary?`primary`:void 0,onClick:e.run,children:[(0,I.jsx)(s,{name:e.icon,size:17,stroke:1.6}),(0,I.jsx)(`span`,{children:e.label})]},e.key))})]}),c===`overview`&&!nt&&tt&&(0,I.jsxs)(I.Fragment,{children:[t.taskMap?.question&&(0,I.jsxs)(`div`,{className:`project-question`,children:[(0,I.jsx)(s,{name:`prompt`,size:18}),(0,I.jsx)(`h2`,{children:t.taskMap.question})]}),y&&ot&&(0,I.jsx)(Me,{client:n,snapshot:t,files:y,notesText:l,onConversation:e=>g(e),onPath:e=>se?.(e),onExplore:d,onConsole:e=>le?le(e):h(`console`),onGraph:()=>h(`graph`)}),(0,I.jsxs)(`div`,{className:`project-columns`+(at?``:` single`),children:[(0,I.jsxs)(`div`,{className:`project-primary`,children:[y&&(0,I.jsx)(F.Suspense,{fallback:null,children:(0,I.jsx)(Ne,{client:n,snapshot:t,files:y,onOpen:()=>h(`graph`),onConversations:()=>h(`agent`)})}),(!ot||!Q.length&&Xe.length>0)&&(0,I.jsxs)(`section`,{className:`project-section figures-section`,children:[(0,I.jsxs)(`div`,{className:`section-heading`,children:[(0,I.jsxs)(`h2`,{children:[`Results & figures`,Q.length>0&&(0,I.jsx)(`span`,{className:`section-count`,children:Q.length})]}),(0,I.jsxs)(`button`,{className:`text-button`,onClick:()=>h(`files`),children:[`All files `,(0,I.jsx)(s,{name:`chevron`,size:12})]})]}),Q.length?(0,I.jsx)(`ul`,{className:`figure-grid count-`+$+($>=3?` featured`:``),children:Q.slice(0,$).map(e=>(0,I.jsx)(`li`,{children:(0,I.jsxs)(`button`,{className:`figure-card`,onClick:()=>oe?.(`results`,e),title:e.path,children:[(0,I.jsx)(Fe,{client:n,snapshot:t,item:e,modifiedAt:Qe.get(e.path)}),(0,I.jsxs)(`span`,{className:`figure-name`,children:[(0,I.jsx)(`strong`,{children:e.name}),(0,I.jsxs)(`small`,{children:[e.resource&&e.path.startsWith(`.rho/`)?`Run output`:e.folder,Qe.get(e.path)?` · `+o(Qe.get(e.path)).text:``]})]})]})},e.key))}):Xe.length?ht:(0,I.jsx)(`p`,{className:`quiet-empty`,children:`No results or figures yet.`}),Q.length>$&&(0,I.jsxs)(`button`,{className:`text-button figures-more`,onClick:()=>h(`files`),children:[Q.length-$,` more in Files `,(0,I.jsx)(s,{name:`chevron`,size:12})]})]}),(0,I.jsx)(S,{work:Ve,snapshot:t,onOpen:()=>h(`notebook`)}),t.taskMap?.items.length?(0,I.jsxs)(`section`,{className:`project-section`,children:[(0,I.jsx)(`div`,{className:`section-heading`,children:(0,I.jsx)(`h2`,{children:`From your Agent`})}),(0,I.jsx)(`ul`,{className:`agent-notes`,children:t.taskMap.items.map(e=>(0,I.jsxs)(`li`,{"data-fact":`agent`,children:[(0,I.jsx)(`strong`,{children:e.title}),e.summary&&(0,I.jsx)(`p`,{children:e.summary}),(0,I.jsx)(`small`,{children:t.taskMap.vocabulary.states[e.state]?.label??e.state})]},e.id))})]}):null]}),at&&(0,I.jsxs)(`aside`,{className:`project-side`,children:[(t.compositions.length>0||Y)&&(0,I.jsxs)(`section`,{className:`project-section`,children:[(0,I.jsx)(`div`,{className:`section-heading`,children:(0,I.jsx)(`h2`,{children:`Continue working`})}),(0,I.jsxs)(`div`,{className:`workspace-grid`,children:[t.compositions.filter(e=>!te(e.compositionId)).map(e=>(0,I.jsxs)(`button`,{className:`workspace-card`,onClick:()=>v(e.compositionId),children:[(0,I.jsxs)(`span`,{className:`workspace-card-head`,children:[(0,I.jsx)(`strong`,{children:_(e.compositionId)}),(0,I.jsxs)(`small`,{children:[e.views.length,` `,e.views.length===1?`view`:`views`]}),(0,I.jsx)(s,{name:`chevron`,size:14})]}),(0,I.jsx)(Ie,{composition:e})]},e.compositionId)),Y&&(0,I.jsx)(we,{work:X.work,openFile:e=>void ut({path:e})})]})]}),(0,I.jsx)(j,{list:We.list,problem:We.problem,snapshot:t,onOpen:()=>h(`skills`)}),(0,I.jsx)(Ce,{work:X.work,openFile:e=>void ut({path:e}),openActivity:()=>h(`agent`)}),rt&&(0,I.jsxs)(`section`,{className:`project-section project-recent`,children:[(0,I.jsxs)(`div`,{className:`section-heading`,children:[(0,I.jsx)(`h2`,{children:`Recent activity`}),(0,I.jsx)(`button`,{className:`text-button`,onClick:()=>h(`agent`),children:`View all`})]}),mt(E,fe),Ze.length?(0,I.jsx)(`div`,{className:`activity-list`,children:Ze.slice(0,5).map(pt)}):(0,I.jsx)(`p`,{className:`quiet-empty`,children:`No runs yet.`})]})]})]})]}),Z&&(0,I.jsxs)(I.Fragment,{children:[t.documents.length>0&&(0,I.jsxs)(`section`,{className:`project-section`,children:[(0,I.jsx)(`div`,{className:`section-heading`,children:(0,I.jsx)(`h2`,{children:`Open documents`})}),(0,I.jsx)(`div`,{className:`document-list`,children:t.documents.map(e=>{let t=Ye.get(e.id);return(0,I.jsxs)(`button`,{className:`document-link`,disabled:!!P,onClick:()=>t?v(t.compositionId,t.viewId):void ut(e),children:[(0,I.jsx)(s,{name:`document`,size:18}),(0,I.jsx)(`span`,{children:ge(e.path)}),e.dirty&&(0,I.jsx)(`span`,{className:`unsaved-dot`,title:`Unsaved changes`,"aria-label":`Unsaved changes`})]},e.id)})})]}),(0,I.jsxs)(`section`,{className:`project-section`,"aria-label":`Project files`,children:[(0,I.jsxs)(`div`,{className:`file-toolbar`,children:[(0,I.jsxs)(`div`,{className:`folder-location`,children:[k?.path&&(0,I.jsx)(`button`,{className:`icon-button`,"aria-label":`Up one folder`,onClick:()=>void lt(k.path.split(`/`).slice(0,-1).join(`/`)),children:(0,I.jsx)(s,{name:`chevron`,size:16})}),(0,I.jsx)(`strong`,{children:Re(k?.path??``,e)})]}),(0,I.jsxs)(`div`,{className:`search-field`,children:[(0,I.jsx)(s,{name:`search`,size:17,stroke:1.7}),(0,I.jsx)(`input`,{"aria-label":`Filter files`,placeholder:`Filter files…`,value:B,onChange:e=>Te(e.target.value)})]})]}),mt(L,()=>void lt(k?.path)),A&&(0,I.jsx)(`p`,{className:`loading-inline`,role:`status`,children:`Reading folder…`}),k&&(gt.length?(0,I.jsxs)(`div`,{className:`file-table-wrap`,"aria-busy":A,children:[(0,I.jsxs)(`table`,{className:`file-table`,children:[(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{children:`Name`}),(0,I.jsx)(`th`,{children:`Type`}),(0,I.jsx)(`th`,{children:`Size`})]})}),(0,I.jsx)(`tbody`,{children:gt.map(e=>(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`td`,{children:(0,I.jsxs)(`button`,{className:`file-open`,disabled:!!P||A,onClick:()=>void(e.kind===`folder`?lt(e.path):ut(e)),children:[(0,I.jsx)(s,{name:e.kind===`folder`?`folder`:`file`,size:19,stroke:1.6}),e.name,P===e.path&&(0,I.jsx)(`span`,{role:`status`,children:`Opening…`})]})}),(0,I.jsx)(`td`,{children:e.kind===`folder`?`Folder`:e.name.split(`.`).at(-1)?.toUpperCase()||`File`}),(0,I.jsx)(`td`,{children:e.kind===`folder`?`—`:p(e.bytes)})]},e.path))})]}),k.truncated&&(0,I.jsxs)(`p`,{className:`muted`,children:[`Showing `,k.entries.length,` of `,k.total,` entries.`]})]}):(0,I.jsxs)(`div`,{className:`empty-state compact`,children:[(0,I.jsx)(`p`,{children:B?`No files match your search.`:`This folder is empty.`}),B&&(0,I.jsx)(`button`,{onClick:()=>Te(``),children:`Clear search`})]}))]}),t.resources.length>0&&(0,I.jsxs)(`section`,{className:`project-section`,children:[(0,I.jsx)(`div`,{className:`section-heading`,children:(0,I.jsx)(`h2`,{children:`Registered results`})}),ht]})]}),c===`agent`&&(()=>{let r=(0,I.jsxs)(I.Fragment,{children:[(Ze.length>0||E)&&(0,I.jsxs)(`section`,{className:`project-section agent-runs`,children:[(0,I.jsx)(`div`,{className:`section-heading`,children:(0,I.jsx)(`h2`,{children:`Runs`})}),mt(E,fe),(0,I.jsx)(`div`,{className:`activity-list`,children:Ze.map(pt)})]}),b&&(0,I.jsxs)(`details`,{className:`agent-outside`,open:w,onToggle:e=>de(e.currentTarget.open),children:[(0,I.jsx)(`summary`,{children:`Agent sessions with access`}),w&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(ce,{snapshot:t}),(0,I.jsx)(D,{client:n,projectId:e.id,root:e.root,onOpened:re})]})]})]});return b?r:(0,I.jsx)(ue,{client:n,snapshot:t,exists:e=>!!y?.files.some(t=>t.path===e),onContinue:e=>g(e),onPath:e=>se?.(e),onNew:()=>C?.(),onOpened:re,extra:r})})(),c===`settings`&&(0,I.jsxs)(`div`,{className:`settings-sections`,children:[(0,I.jsxs)(`section`,{className:`project-section`,children:[(0,I.jsx)(`h2`,{children:`Source folders`}),(0,I.jsx)(i,{folders:e.sources??[{id:e.id,root:e.root,name:r(e)}],busy:V,onAdd:()=>void dt()}),mt(Ee,()=>void dt())]}),(0,I.jsxs)(`section`,{className:`project-section`,children:[(0,I.jsxs)(`div`,{className:`section-heading`,children:[(0,I.jsx)(`h2`,{children:`Project health`}),(0,I.jsx)(`button`,{disabled:K,onClick:()=>void ft(),children:K?`Checking…`:`Check project`})]}),G?(0,I.jsx)(`ul`,{className:`health-list`,children:G.map(e=>(0,I.jsxs)(`li`,{children:[(0,I.jsx)(`span`,{className:`state `+e.state,children:e.state===`ok`?`Ready`:e.state===`fail`?`Blocked`:`Check`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{children:e.detail}),e.remedy&&(0,I.jsx)(`small`,{children:e.remedy})]})]},e.id))}):(0,I.jsx)(`p`,{className:`muted`,children:`Check the tools and capabilities available to this project.`}),mt(De,()=>void ft())]})]}),O&&(0,I.jsxs)(`dialog`,{ref:qe,className:`run-dialog`,"aria-label":O,onClose:()=>pe(null),onClick:e=>{e.target===e.currentTarget&&e.currentTarget.close()},children:[(0,I.jsx)(`button`,{className:`icon-button run-dialog-close`,"aria-label":`Close`,onClick:()=>qe.current?.close(),children:(0,I.jsx)(s,{name:`close`,size:18})}),(0,I.jsx)(ve,{snapshot:t,client:n,operationId:O,runs:T,readRuns:fe,onOpenRun:pe,opener:e=>{let t=Je.get(e.id+`@`+e.version);return t?()=>v(t.compositionId,t.viewId):null}},O)]})]})}var ze={data:`No data files in this project yet.`,code:`No scripts in this project yet.`,results:`No results or figures yet.`,notes:`No notes in this project yet.`,workflows:`No workflow files in this project now.`,reports:`No reports in this project now.`,references:`No references in this project now.`,environment:`No environment files in this project now.`};function Be({category:e,files:t,items:n,artifacts:r,onFile:i}){let[a,o]=(0,F.useState)(``),c=new Map(r.map(e=>[e.resource.id+`@`+e.resource.version,e])),u=n??[],d=u.length,f=u.filter(e=>!a||e.path.toLocaleLowerCase().includes(a.toLocaleLowerCase()));return(0,I.jsxs)(`section`,{className:`project-section source-list`,"aria-label":e,children:[(0,I.jsxs)(`div`,{className:`file-toolbar`,children:[(0,I.jsxs)(`p`,{className:`source-summary`,children:[t.readAt===0&&t.reading?`Reading the project folders…`:`${d}${t.truncated?`+`:``} ${d===1?`file`:`files`}`,t.truncated&&(0,I.jsx)(`span`,{title:`Rho reads at most ${l.maxFolders} folders, ${l.maxDepth} levels deep.`,children:` · deeper folders were not read`})]}),(0,I.jsxs)(`div`,{className:`search-field`,children:[(0,I.jsx)(s,{name:`search`,size:17,stroke:1.7}),(0,I.jsx)(`input`,{"aria-label":`Filter these files`,placeholder:`Filter…`,value:a,onChange:e=>o(e.target.value)})]})]}),t.problem&&(0,I.jsxs)(`div`,{className:`inline-error`,role:`alert`,children:[(0,I.jsx)(`p`,{children:t.problem}),(0,I.jsx)(`button`,{onClick:t.refresh,children:`Try again`})]}),d===0&&t.readAt>0?(0,I.jsx)(`div`,{className:`empty-state compact`,children:(0,I.jsx)(`p`,{children:ze[e]})}):f.length>0?(0,I.jsx)(`ul`,{className:`source-rows`,children:f.map(t=>{let n=t.resource?c.get(t.resource.id+`@`+t.resource.version):void 0;return(0,I.jsx)(`li`,{children:(0,I.jsxs)(`button`,{className:`source-row`,onClick:()=>i(e,t),children:[(0,I.jsx)(`span`,{className:`file-symbol`,children:(0,I.jsx)(s,{name:g(t),size:18,stroke:1.6})}),(0,I.jsxs)(`span`,{className:`source-name`,children:[(0,I.jsx)(`strong`,{children:t.name}),(0,I.jsxs)(`small`,{children:[t.folder,n?.run?` · from `+n.run.operationId:``]})]}),(0,I.jsx)(`span`,{className:`source-meta`,children:t.resource?n?.run?ye(n.run.integrity):`Result`:t.bytes===null?``:p(t.bytes)})]})},t.key)})}):d>0?(0,I.jsxs)(`div`,{className:`empty-state compact`,children:[(0,I.jsx)(`p`,{children:`No files match your filter.`}),(0,I.jsx)(`button`,{onClick:()=>o(``),children:`Clear filter`})]}):null]})}export{X as ProjectOverview};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./react-Dss-ouuy.js";import{r}from"./markdown-0ngRuTpW.js";import{_ as i,d as a,l as o,x as s}from"./previews-pWNik-2g.js";import{Q as c,Z as l,et as u,u as d}from"./index-CWg9XYXx.js";import{t as f}from"./explore-in-BfSFGRh2.js";var p=e(n(),1),m=t();async function h(e,t,n){let r=await s(e,t,n.resource??n.path);return r&&{id:r.node.id,component:String(r.node.component),version:String(r.node.version),props:r.node.props??{},bindings:r.node.bindings}}function g(e){return!!(e instanceof HTMLElement?e:null)?.closest(`input, textarea, select, [contenteditable=""], [contenteditable=true], [data-owner-body], [role=tablist], [role=menu], dialog[open]`)}function _({client:e,snapshot:t,item:n,items:s,kind:_,principalId:v,workspace:y,onExplore:b,onMove:x,onStudio:S,onList:C,onAbout:w}){let[T,E]=(0,p.useState)(null),[D,O]=(0,p.useState)(null),[k,A]=(0,p.useState)(!1),[j,M]=(0,p.useState)(``),N=s.findIndex(e=>e.key===n.key),P=N>0?s[N-1]:void 0,F=N>=0?s[N+1]:void 0,I=t.catalog.components.length>0;(0,p.useEffect)(()=>{if(!I)return;let r=!0;E(e=>e&&`view`in e?e:null);let i=n.key;return h(e,t,n).then(e=>{r&&E(e?{key:i,view:e}:{key:i,problem:`Rho has no viewer for this kind of file yet. It stays in the project folder.`})},e=>{r&&E({key:i,problem:e instanceof Error?e.message:`This file could not be opened.`})}),()=>{r=!1}},[e,t.project.id,I,n.key,n.bytes,n.resource?.version]),(0,p.useEffect)(()=>{M(``)},[n.key]),(0,p.useEffect)(()=>{function e(e){if(e.defaultPrevented||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey||g(e.target))return;let t=e.key===`ArrowLeft`?P:e.key===`ArrowRight`?F:void 0;t&&(e.preventDefault(),x(t))}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[P?.key,F?.key,x]);async function L(){A(!0),M(``);try{let r=await i(e,t,y(),n.resource??n.path);r?S(r.compositionId,r.viewId):M(`Rho has no viewer for this kind of file yet.`)}catch(e){M(e instanceof Error?e.message:`It could not be opened in Studio.`)}finally{A(!1)}}let R=T&&`view`in T?T.view:null,z=T?.key===n.key;return(0,m.jsxs)(`section`,{className:`file-preview`,"aria-labelledby":`preview-title`,children:[(0,m.jsxs)(`header`,{className:`preview-bar`,children:[(0,m.jsx)(`span`,{className:`file-symbol`,children:(0,m.jsx)(r,{name:o(n),size:18,stroke:1.6})}),(0,m.jsxs)(`div`,{className:`preview-name`,children:[(0,m.jsx)(`h1`,{id:`preview-title`,title:n.path,children:n.name}),(0,m.jsxs)(`small`,{children:[n.folder,n.bytes===null?``:` · `+a(n.bytes)]})]}),(0,m.jsx)(`div`,{ref:O,className:`preview-owner-header`}),(0,m.jsxs)(`div`,{className:`preview-nav`,role:`group`,"aria-label":`Browse `+_,children:[(0,m.jsx)(`button`,{className:`icon-button`,"aria-label":P?`Previous: `+P.name:`Previous file`,title:`Previous (←)`,"aria-keyshortcuts":`ArrowLeft`,disabled:!P,onClick:()=>P&&x(P),children:(0,m.jsx)(r,{name:`back`,size:16})}),(0,m.jsx)(`button`,{className:`preview-position`,title:`All `+_.toLowerCase(),onClick:C,children:N>=0?`${N+1} of ${s.length}`:s.length+` files`}),(0,m.jsx)(`button`,{className:`icon-button`,"aria-label":F?`Next: `+F.name:`Next file`,title:`Next (→)`,"aria-keyshortcuts":`ArrowRight`,disabled:!F,onClick:()=>F&&x(F),children:(0,m.jsx)(r,{name:`chevron`,size:16})})]}),b&&(l(n.path)||u(n.path))&&(0,m.jsx)(f,{languages:l(n.path)?[`r`,`python`]:[u(n.path)],title:e=>l(n.path)?`Open ${n.name} in Studio with the Notebook beside it, loaded into the ${c[e]} session as a new value`:`Open ${n.name} in Studio with the Notebook beside it, and a line that runs it waiting there for you`,onExplore:e=>b(n.path,e)}),(0,m.jsxs)(`button`,{className:`preview-studio`,"aria-label":k?`Opening in Studio`:`Open in Studio`,title:`Open in Studio`,disabled:k,onClick:()=>void L(),children:[(0,m.jsx)(r,{name:`layout`,size:15}),(0,m.jsx)(`span`,{children:k?`Opening…`:`Open in Studio`})]})]}),j&&(0,m.jsx)(`p`,{className:`canvas-note`,role:`alert`,children:j}),(0,m.jsx)(`div`,{className:`preview-body`+(R&&!z?` switching`:``),"aria-busy":!z,children:R?(0,m.jsx)(d,{active:!0,params:{view:R,snapshot:t,client:e,principalId:v,compositionId:`preview`,compositionVersion:0,contextTarget:null,headerTarget:z?D:null,renderAllowed:!0,onAbout:w}},R.id):T&&`problem`in T&&z?(0,m.jsxs)(`div`,{className:`studio-empty`,children:[(0,m.jsx)(`span`,{className:`empty-symbol`,children:(0,m.jsx)(r,{name:`file`,size:26,stroke:1.5})}),(0,m.jsx)(`h2`,{children:n.name}),(0,m.jsx)(`p`,{children:T.problem})]}):(0,m.jsxs)(`div`,{className:`loading-state`,role:`status`,children:[(0,m.jsx)(`span`,{className:`loading-dot`}),(0,m.jsxs)(`span`,{children:[`Opening `,n.name,`…`]})]})})]})}export{_ as FilePreview};
@@ -0,0 +1,3 @@
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./react-Dss-ouuy.js";import{c as r,s as i}from"./home-CCbP6kS-.js";import{r as a}from"./markdown-0ngRuTpW.js";var o=e(n(),1),s=new Map(Object.entries({data:`csv.tsv.tab.xlsx.xls.json.parquet.feather.arrow.rds.rda.rdata.h5.h5ad.hdf5.loom.mtx.sav.dta.sas7bdat.fasta.fa.fastq.fq.bam.sam.vcf.bed.gtf.gff.gff3.nwk.tre.newick`.split(`.`),code:`r.rmd.qmd.py.ipynb.sh.bash.zsh.jl.sql.js.mjs.ts.stan.smk.nf.wdl.cpp.c.h.rs.go.java.pl.awk.sas.do.m`.split(`.`),figures:[`png`,`jpg`,`jpeg`,`svg`,`pdf`,`gif`,`tif`,`tiff`,`webp`,`eps`],notes:[`md`,`markdown`,`txt`,`rst`,`org`,`tex`,`bib`,`docx`,`html`]}).flatMap(([e,t])=>t.map(t=>[t,e]))),c=new Set([`results`,`result`,`output`,`outputs`,`out`,`figures`,`figs`,`plots`,`reports`]);function l(e){let t=e.split(`/`),n=t.at(-1).toLowerCase().split(`.`);n.length>2&&[`gz`,`bz2`,`xz`,`zst`].includes(n.at(-1))&&n.pop();let r=n.length>1?s.get(n.at(-1))??null:null;return r===`data`&&t.slice(0,-1).some(e=>c.has(e.toLowerCase()))?`results`:r}var u=e=>/\.(csv|png|jpe?g|svg)$/i.test(e),d=new Set([`node_modules`,`renv`,`packrat`,`__pycache__`,`venv`,`.venv`,`site-library`,`.ipynb_checkpoints`,`.Rproj.user`,`.snakemake`,`.nextflow`]),f={maxFolders:48,maxDepth:5,maxFiles:4e3};async function p(e,t,n){let r=[],i=[{path:``,depth:0}],a=0,o=!1;for(;i.length;){if(n.aborted)throw new DOMException(`aborted`,`AbortError`);if(a>=f.maxFolders){o=!0;break}let s=i.shift();a++;let c=await e.call(`project.entries`,{projectId:t,...s.path?{path:s.path}:{}},n);c.truncated&&(o=!0);for(let e of c.entries)if(!e.hidden){if(e.kind===`folder`){if(d.has(e.name))continue;if(s.depth+1>f.maxDepth){o=!0;continue}i.push({path:e.path,depth:s.depth+1})}else{if(r.length>=f.maxFiles){o=!0;break}r.push({...e,category:l(e.path)})}}}return{files:r,truncated:o}}function m(e,t,n){let[r,i]=(0,o.useState)({files:[],truncated:!1,reading:!1,problem:``,readAt:0}),[a,s]=(0,o.useState)(0),c=(0,o.useRef)(0),l=(0,o.useRef)(void 0),[u,d]=(0,o.useState)(0);return(0,o.useEffect)(()=>{i({files:[],truncated:!1,reading:!1,problem:``,readAt:0}),c.current=0},[t]),(0,o.useEffect)(()=>{if(!t)return;let e=Math.max(0,c.current+5e3-Date.now());return clearTimeout(l.current),l.current=setTimeout(()=>d(e=>e+1),e),()=>clearTimeout(l.current)},[t,n,a]),(0,o.useEffect)(()=>{if(!t||!u)return;let n=new AbortController;return c.current=Date.now(),i(e=>({...e,reading:!0})),p(e,t,n.signal).then(e=>i({...e,reading:!1,problem:``,readAt:Date.now()}),e=>{n.signal.aborted||i(t=>({...t,reading:!1,problem:e instanceof Error?e.message:`The project folder could not be read.`}))}),()=>n.abort()},[e,t,u]),{...r,refresh:()=>{c.current=0,s(e=>e+1)}}}var ee=[`data`,`code`,`results`,`notes`],te=[`data`,`code`,`workflows`,`results`,`reports`,`notes`,`references`,`environment`],h=new Set([`renv.lock`,`description`,`environment.yml`,`environment.yaml`,`pyproject.toml`,`setup.py`,`setup.cfg`,`pipfile`,`pipfile.lock`,`poetry.lock`,`uv.lock`,`conda-lock.yml`,`dockerfile`,`containerfile`,`apptainer.def`,`singularity.def`,`install.r`,`project.toml`,`manifest.toml`]),ne=new Set([`snakefile`,`makefile`,`gnumakefile`,`justfile`,`_targets.r`,`nextflow.config`,`dvc.yaml`]),re=new Set([`refs`,`references`,`literature`,`papers`,`reading`,`bibliography`]),g=e=>e.toLowerCase().replace(/\.[^./]+$/,``),ie=e=>new Set(e.filter(e=>/\.(rmd|qmd|rnw)$/i.test(e.path)).map(e=>g(e.path))),ae=e=>new Set(e.filter(e=>/\.html?$/i.test(e.path)).map(e=>e.path.toLowerCase().split(`/`).slice(0,-1).join(`/`))),_=/^[a-z][\w.]*(-[a-z][\w.]*)*-\d+(\.\d+)+$/,v=/^(lib|libs|site_libs|.+_files)$/;function y(e,t,n=new Set){let r=e.path.toLowerCase().split(`/`),i=r.at(-1),a=i.includes(`.`)?i.split(`.`).at(-1):``;return r.slice(0,-1).some((e,n)=>e.endsWith(`_files`)&&t.has([...r.slice(0,n),e.slice(0,-6)].join(`/`)))||r.slice(0,-1).some((e,t)=>t>0&&_.test(e)&&v.test(r[t-1])&&n.has(r.slice(0,t-1).join(`/`)))?null:h.has(i)||/^requirements([-_.][^/]*)?\.txt$/.test(i)||a===`rproj`?`environment`:ne.has(i)||[`smk`,`nf`,`wdl`,`cwl`].includes(a)?`workflows`:[`rmd`,`qmd`,`rnw`].includes(a)||[`html`,`pdf`,`docx`].includes(a)&&t.has(g(e.path))?`reports`:[`bib`,`ris`,`nbib`,`enw`].includes(a)||a===`pdf`&&r.slice(0,-1).some(e=>re.has(e))?`references`:e.category===`figures`||e.category===`results`?`results`:e.category}var b=e=>e.split(`/`).filter(Boolean).at(-1)??e;function x(e,t){let n=e.split(`/`);if(n.pop(),!n.length)return t.name??b(t.root);let r=n[0].startsWith(`@`)?t.sources?.find(e=>`@`+e.id===n[0]):void 0;return[r?r.name:n[0],...n.slice(1)].join(`/`)}var S=e=>![`current-filesystem-observation`,`captured-observation`].includes(e.provenance?.source??``),C=new Intl.Collator(void 0,{numeric:!0,sensitivity:`base`});function w(e,t,n,r,i=[]){let a=new Map,o=new Map(i.map(e=>[e.operationId,e.acceptedAt])),s=e=>o.get(String(e.provenance?.operationId??``))??``,c=new Map;if(e===`results`)for(let e of n){let t=c.get(e.path);S(e)&&(!t||s(e).localeCompare(s(t))>0||s(e)===s(t)&&e.version.localeCompare(t.version)>0)&&c.set(e.path,e)}for(let e of c.values())a.set(e.path,{key:`result:`+e.path,path:e.path,name:b(e.path),folder:x(e.path,r),bytes:e.bytes??null,category:e.kind===`media`?`figures`:`results`,resource:{id:e.id,version:e.version,kind:e.kind,path:e.path}});let l=ie(t),u=ae(t);for(let n of t)y(n,l,u)===e&&!a.has(n.path)&&a.set(n.path,{key:`file:`+n.path,path:n.path,name:n.name,folder:x(n.path,r),bytes:n.bytes,category:n.category});let d=e=>Number(e.path.includes(`/`));return[...a.values()].sort((e,t)=>d(e)-d(t)||C.compare(e.folder,t.folder)||C.compare(e.name,t.name))}function T(e){let t=new Set(e.views.map(e=>e.id)),n=new Set,r=new Map((e.nodes??[]).map(e=>[e.id,e])),i=e=>{let n=r.get(e);return n?n.kind===`view`?t.has(n.id)?[n.id]:[]:n.children.flatMap(i):[]},a=e=>{let o=r.get(e);if(!o)return null;if(o.kind===`view`)return t.has(o.id)?(n.add(o.id),{kind:`tabs`,id:`tabs:`+o.id,views:[o.id]}):null;let s=o.presentation?.mode===`split`?o.presentation:null;if(s){let e=o.children.map((e,t)=>({region:a(e),weight:s.weights[t]??1})).filter(e=>e.region);return e.length?e.length===1?e[0].region:{kind:`split`,id:o.id,axis:s.axis,weights:e.map(e=>e.weight),children:e.map(e=>e.region)}:null}let c=i(o.id);return c.forEach(e=>n.add(e)),c.length?{kind:`tabs`,id:o.id,views:c}:null},o=e.rootId&&r.size?a(e.rootId):null,s=e.views.map(e=>e.id).filter(e=>!n.has(e));if(!s.length)return o;if(!o)return{kind:`tabs`,id:`tabs:root`,views:s};let c=E(o),l=c[c.length-1];return o=ce(o,l.id,{...l,views:[...l.views,...s]}),o}function E(e){return e.kind===`tabs`?[e]:e.children.flatMap(E)}function oe(e){return e?E(e).flatMap(e=>e.views):[]}function se(e,t){return e?E(e).find(e=>e.views.includes(t))??null:null}function ce(e,t,n){return e.id===t?n:e.kind===`split`?{...e,children:e.children.map(e=>ce(e,t,n))}:e}function le(e,t,n,r=.12){let i=e.reduce((e,t)=>e+t,0),a=[...e],o=i*r,s=a[t]+a[t+1],c=Math.min(s-o,Math.max(o,a[t]+n*i));return a[t]=c,a[t+1]=s-c,a}function ue(e){let t=e.bindings?.data,n=e=>e.replace(/[^A-Za-z0-9._-]/g,`_`).slice(0,40);return typeof t?.id==`string`&&typeof t.version==`string`?{kind:`shared`,id:`linked:${n(t.id)}@${n(t.version)}`}:{kind:`shared`,id:e.id}}var D=e=>e?.presentation?.mode===`split`,O=(e,t)=>e.find(e=>e.kind===`group`&&e.children?.includes(t));function k(e,t){let n=t;for(;;){let t=O(e,n);if(!t||D(t))return n;n=t.id}}function A(e,t){let n=e.find(e=>e.id===t);return n?n.kind===`view`?[t]:(n.children??[]).flatMap(t=>A(e,t)):[]}function j(e){let t=e.nodes,n=e.rootId;for(let e=!0;e;){e=!1;for(let r of t){if(r.kind!==`group`||r.id===n)continue;let i=O(t,r.id);if(!r.children?.length){let n=i.children.indexOf(r.id);i.children=i.children.filter(e=>e!==r.id),D(i)&&(i.presentation={...i.presentation,weights:(i.presentation.weights??[]).filter((e,t)=>t!==n)}),t=t.filter(e=>e.id!==r.id),e=!0;break}if(D(r)&&r.children.length===1){let n=r.children[0];i.children=i.children.map(e=>e===r.id?n:e),t=t.filter(e=>e.id!==r.id),e=!0;break}}let r=t.find(e=>e.id===n);if(r&&D(r)&&r.children?.length===1){let i=r.children[0];t.find(e=>e.id===i).kind===`group`&&(t=t.filter(e=>e.id!==n),n=i,e=!0)}}return{rootId:n,nodes:t}}var M=e=>({rootId:e.rootId,nodes:structuredClone(e.nodes)});function N(e,t){let n=O(e.nodes,t),r=n.children.indexOf(t);n.children=n.children.filter(e=>e!==t),D(n)&&(n.presentation={...n.presentation,weights:(n.presentation.weights??[]).filter((e,t)=>t!==r)})}function de(e,t,n,r){if(!e.nodes.some(e=>e.id===t&&e.kind===`view`)||!O(e.nodes,t))return null;let i=k(e.nodes,t);if(i===t||A(e.nodes,i).length<2)return null;let a=M(e);N(a,t);let o={id:r(`group`),kind:`group`,children:[t]};a.nodes.push(o);let s=O(a.nodes,i);if(s&&D(s)&&s.presentation.axis===n){let e=s.children.indexOf(i),t=[...s.presentation.weights??s.children.map(()=>1)],n=(t[e]??1)/2;s.children.splice(e+1,0,o.id),t.splice(e,1,n,n),s.presentation={...s.presentation,weights:t}}else{let e={id:r(`split`),kind:`group`,children:[i,o.id],presentation:{mode:`split`,axis:n,weights:[1,1]}};a.nodes.push(e),s?s.children=s.children.map(t=>t===i?e.id:t):a.rootId=e.id}return j(a)}function P(e){let t=[],n=(r,i)=>{let a=e.nodes.find(e=>e.id===r);if(a){if(D(a))for(let e of a.children??[])n(e,!0);else(i||r===e.rootId)&&t.push(r)}};return n(e.rootId,!1),t}function F(e,t,n){let r=e.nodes.find(e=>e.id===t.id);if(r)return r.kind===`view`&&r.component===t.component&&r.version===t.version&&JSON.stringify(r.bindings)===JSON.stringify(t.bindings)?e:null;let i=M(e),a=P(i).at(-1),o=i.nodes.find(e=>e.id===a);if(!o)return null;if(i.nodes.push({id:t.id,kind:`view`,component:t.component,version:t.version,props:structuredClone(t.props),bindings:structuredClone(t.bindings)}),o.kind===`group`)o.children=[...o.children??[],t.id];else{let e={id:n(`group`),kind:`group`,children:[o.id,t.id]};i.nodes.push(e);let r=O(i.nodes,o.id);r?r.children=r.children.map(t=>t===o.id?e.id:t):i.rootId=e.id}return i}function fe(e,t,n,r){if(!O(e.nodes,t))return null;let i=P(e),a=k(e.nodes,t),o=i[i.indexOf(a)+n];if(!o||o===a)return null;let s=M(e);N(s,t);let c=s.nodes.find(e=>e.id===o);if(c.kind===`group`)c.children=[...c.children??[],t];else{let e={id:r(`group`),kind:`group`,children:[o,t]};s.nodes.push(e);let n=O(s.nodes,o);n.children=n.children.map(t=>t===o?e.id:t)}return j(s)}function pe(e,t,n){if(!e.nodes.find(e=>e.id===t&&e.kind===`view`))return null;let r=M(e),i=r.nodes.find(e=>e.id===t);return i.props={...i.props,...n},r}function me(e,t){if(!O(e.nodes,t))return null;let n=M(e);return N(n,t),n.nodes=n.nodes.filter(e=>e.id!==t),j(n)}function he(e,t,n){let r=e.nodes.find(e=>e.id===t);if(!D(r)||r.children.length!==n.length)return null;let i=M(e),a=i.nodes.find(e=>e.id===t);return a.presentation={...a.presentation,weights:n.map(e=>Math.round(e*1e3)/1e3)},i}var ge=e=>e.startsWith(`tabs:`)?e.slice(5):e;function I(e,t,n,r,i){let a=e.nodes.find(e=>e.id===n);if(!a||D(a)||n===t||!O(e.nodes,t))return null;if(k(e.nodes,t)===n){let i=A(e.nodes,n),a=i.filter(e=>e!==t),o=r&&a.includes(r)?a.indexOf(r):a.length;if(i.indexOf(t)===o)return null}let o=M(e);N(o,t);let s=o.nodes.find(e=>e.id===n);if(s.kind===`group`){let e=s.children??[],n=r?e.find(e=>e===r||A(o.nodes,e).includes(r)):void 0;e.splice(n?e.indexOf(n):e.length,0,t),s.children=e}else{let e={id:i(`group`),kind:`group`,children:r===n?[t,n]:[n,t]};o.nodes.push(e);let a=O(o.nodes,n);a?a.children=a.children.map(t=>t===n?e.id:t):o.rootId=e.id}return j(o)}function L(e,t,n,r,i){if(e.nodes.some(e=>e.id===t.id))return null;let a=n&&O(e.nodes,n)?n:A(e.nodes,P(e).at(-1)??e.rootId)[0]??null,o=F(e,t,i);return!o||!a?o:R(o,t.id,k(o.nodes,a),r,i)??o}function _e(e,t,n,r,i=.4){if(e.nodes.some(e=>e.id===t.id))return null;let a=F(e,t,r);if(!a||A(a.nodes,a.rootId).length<2)return a;let o=M(a);N(o,t.id);let s={id:r(`group`),kind:`group`,children:[t.id]};return o.nodes.push(s),ve(o,s.id,n,i,r),j(o)}function ve(e,t,n,r,i){let a=n===`left`||n===`right`?`horizontal`:`vertical`,o=n===`right`||n===`bottom`,s=e.nodes.find(t=>t.id===e.rootId);if(D(s)&&s.presentation.axis===a){let e=[...s.presentation.weights??s.children.map(()=>1)],n=e.reduce((e,t)=>e+t,0)*r/(1-r);o?(s.children.push(t),e.push(n)):(s.children.unshift(t),e.unshift(n)),s.presentation={...s.presentation,weights:e}}else{let n={id:i(`split`),kind:`group`,children:o?[e.rootId,t]:[t,e.rootId],presentation:{mode:`split`,axis:a,weights:o?[1-r,r]:[r,1-r]}};e.nodes.push(n),e.rootId=n.id}}function ye(e,t){let n=1;for(let r=k(e.nodes,t),i=O(e.nodes,r);i;r=i.id,i=O(e.nodes,r)){if(!D(i)||i.presentation.axis!==`horizontal`)continue;let e=i.presentation.weights??i.children.map(()=>1),t=e.reduce((e,t)=>e+t,0);n*=(e[i.children.indexOf(r)]??1)/(t||1)}return n}function be(e,t,n,r,i,a){let o=k(e.nodes,n),s=O(e.nodes,o);if(r&&s&&ye(e,n)*r<2*i){let n=s.children.indexOf(o),r=s.children[n+1]??s.children[n-1];for(let t=e.nodes.find(e=>e.id===r);t&&D(t);t=e.nodes.find(e=>e.id===r))r=t.children?.[0];let i=r?F(e,t,a):null;if(i)return I(i,t.id,r,null,a)??i}return L(e,t,n,`right`,a)}function R(e,t,n,r,i){let a=e.nodes.find(e=>e.id===n);if(!a||D(a)||n===t||!O(e.nodes,t)||k(e.nodes,t)===n&&A(e.nodes,n).length<2)return null;let o=M(e);N(o,t);let s={id:i(`group`),kind:`group`,children:[t]};return o.nodes.push(s),xe(o,s.id,n,r,i),j(o)}function xe(e,t,n,r,i){let a=r===`left`||r===`right`?`horizontal`:`vertical`,o=r===`right`||r===`bottom`,s=O(e.nodes,n);if(s&&D(s)&&s.presentation.axis===a){let e=s.children.indexOf(n),r=[...s.presentation.weights??s.children.map(()=>1)],i=(r[e]??1)/2;s.children.splice(o?e+1:e,0,t),r.splice(e,1,i,i),s.presentation={...s.presentation,weights:r}}else{let r={id:i(`split`),kind:`group`,children:o?[n,t]:[t,n],presentation:{mode:`split`,axis:a,weights:[1,1]}};e.nodes.push(r),s?s.children=s.children.map(e=>e===n?r.id:e):e.rootId=r.id}}function Se(e,t){let n=(e,t)=>{let r=e.nodes.find(e=>e.id===t);return!r||r.kind===`view`?t:[t,r.presentation?.mode===`split`?r.presentation.axis:`tabs`,(r.children??[]).map(t=>n(e,t))]};return JSON.stringify(n(e,e.rootId))===JSON.stringify(n(t,t.rootId))}function Ce(e,t,n,r,i,a){let o=P(e),s=e.nodes.find(e=>e.id===t);if(!s||t===n||t===e.rootId||!o.includes(t)||!o.includes(n))return null;if(s.kind===`view`)return r===`center`?I(e,t,n,i,a):R(e,t,n,r,a);let c=M(e);if(N(c,t),r!==`center`){xe(c,t,n,r,a);let i=j(c);return Se(e,i)?null:i}let l=A(c.nodes,t),u=new Set,d=e=>{let t=c.nodes.find(t=>t.id===e);t?.kind===`group`&&(u.add(e),t.children?.forEach(d))};d(t),c.nodes=c.nodes.filter(e=>!u.has(e.id));let f=c.nodes.find(e=>e.id===n);if(f.kind===`group`){let e=f.children??[],t=i?e.find(e=>e===i||A(c.nodes,e).includes(i)):void 0;e.splice(t?e.indexOf(t):e.length,0,...l),f.children=e}else{let e={id:a(`group`),kind:`group`,children:i===n?[...l,n]:[n,...l]};c.nodes.push(e);let t=O(c.nodes,n);t?t.children=t.children.map(t=>t===n?e.id:t):c.rootId=e.id}return j(c)}function we(e,t,n,r,i=1/3){let a=e.nodes.find(e=>e.id===t);if(!a||!O(e.nodes,t)||a.kind!==`view`&&!P(e).includes(t))return null;let o=k(e.nodes,t);if(o!==t&&A(e.nodes,o).length===1)return we(e,o,n,r,i);let s=M(e);N(s,t);let c=t;if(!P(e).includes(t)){let e={id:r(`group`),kind:`group`,children:[t]};s.nodes.push(e),c=e.id}ve(s,c,n,i,r);let l=j(s);return Se(e,l)?null:l}function Te(e,t,n,r){if(e.nodes.some(e=>e.id===t.id))return null;let i=F(e,t,r);return i&&(I(i,t.id,n,null,r)??i)}var Ee=`workspace`,De={workspace:`Workspace`,"agent-canvas":`Agent canvas`,"observed-outputs":`Observed outputs`,"external-results":`External results`};function Oe(e){return De[e]??(/^workspace-(\d+)$/.exec(e)?`Workspace `+e.slice(10):e)}var ke=e=>`conversation-`+e,Ae=e=>e.startsWith(`conversation-`)?e.slice(13):null;function je(e){let t=2166136261,n=16777619;for(let r of e){let e=r.codePointAt(0);t=Math.imul(t^e,16777619)>>>0,n=Math.imul(n^e,2166136261)>>>0}return`file-`+(t.toString(16).padStart(8,`0`)+n.toString(16).padStart(8,`0`)).slice(0,12)+`-`}var Me={maxViewsPerSide:6},z=`canvas-`,Ne=`markdown.reader`,Pe=`html.reader`,Fe=e=>e.kind===`view`?e.component===`rho.editor`||e.component===Ne||e.component===Pe?`code`:e.component===`rho.table`||e.component===`rho.media`?`data`:null:null,Ie=/\.(png|jpe?g|svg|gif|pdf|tiff?|webp|xlsx?|rds|rda|rdata|parquet|feather|h5|h5ad|bam|zip|gz)$/i,Le=e=>u(e)||!Ie.test(e),Re=(e,t)=>e.catalog.operations.some(e=>e.method===t&&e.authorized&&e.state===`available`),B=(e,t)=>e.catalog.components.find(e=>e.id===t),V=e=>Re(e,`agent.activity.capture`)&&!!B(e,`rho.table`)&&!!B(e,`rho.media`);async function H(e,t,n){if(typeof n!=`string`){let e=B(t,n.kind===`table`?`rho.table`:`rho.media`);if(!e||![`table`,`media`].includes(n.kind))return null;let r=Object.keys(e.bindings)[0]??`data`;return{side:`data`,node:{id:`result-`+n.id.slice(0,12)+`-`+n.version.slice(0,12),kind:`view`,component:e.id,version:e.version,props:{title:n.path.split(`/`).at(-1)??n.path},bindings:{[r]:{id:n.id,version:n.version}}}}}let r=n,i=t.project.id,a=r.split(`/`).at(-1)??r;if(u(r)&&V(t)){let n=await e.call(`agent.activity.capture`,{projectId:i,path:r}),o=B(t,n.kind===`table`?`rho.table`:`rho.media`),s=Object.keys(o.bindings)[0]??`data`;return{side:`data`,node:{id:je(r)+n.version.slice(0,12),kind:`view`,component:o.id,version:o.version,props:{title:a},bindings:{[s]:{id:n.id,version:n.version}}}}}if(Ie.test(r))return null;let o=(/\.(md|markdown)$/i.test(r)?B(t,Ne):/\.html?$/i.test(r)?B(t,Pe):void 0)??B(t,`rho.editor`);if(!o)return null;let s=await e.call(`document.open`,{projectId:i,path:r});return{side:`code`,node:{id:`doc-`+s.id.slice(0,12),kind:`view`,component:o.id,version:o.version,props:{title:a},bindings:{document:{kind:`live-document`,documentId:s.id}}}}}function ze(e,t,n,r){let i=structuredClone(e?.nodes??[]),a=e?.rootId??`root`;if(i.some(e=>e.id===t.id))return null;let o=e=>i.find(t=>t.id===e),s=e=>i.find(t=>t.kind===`group`&&t.children?.includes(e)),c=e=>!!e&&e.kind===`group`&&e.presentation?.mode!==`split`,l=t.id.startsWith(`file-`)?t.id.slice(0,18):``,u=l?i.find(e=>e.kind===`view`&&e.id.startsWith(l)):void 0;if(u){let e=s(u.id);if(e)return e.children=e.children.map(e=>e===u.id?t.id:e),{rootId:a,nodes:[...i.filter(e=>e.id!==u.id),t]}}if(r&&e?.rootId&&i.length)return Te({rootId:a,nodes:i},t,r,e=>`${e}-${crypto.randomUUID().slice(0,8)}`);let d=o(a);d||(d={id:a,kind:`group`,children:[]},i.push(d));let f=new Map;for(let e of i)if(Fe(e)===n){let t=s(e.id);c(t)&&f.set(t,(f.get(t)??0)+1)}let p=i.find(e=>e.id===z+n&&e.kind===`group`)??[...f].sort((e,t)=>t[1]-e[1])[0]?.[0]??(d.children?.length?void 0:d);if(!p){p={id:z+n,kind:`group`,children:[]},i.push(p);let e=e=>n===`code`?0:e;if(d.presentation?.mode===`split`&&d.presentation.axis===`horizontal`){let t=d.presentation.weights?.length===d.children.length?[...d.presentation.weights]:d.children.map(()=>1),n=e(d.children.length);d.children.splice(n,0,p.id),t.splice(n,0,t.reduce((e,t)=>e+t,0)/t.length),d.presentation={...d.presentation,weights:t}}else{let t=`split`,n=1;for(;o(t);)t=`split-`+ ++n;let r=[a];r.splice(e(1),0,p.id),i.push({id:t,kind:`group`,children:r,presentation:{mode:`split`,axis:`horizontal`,weights:[1,1]}}),a=t}}if(p.children=[...p.children??[],t.id],i.push(t),p.id.startsWith(z))for(;p.children.length>Me.maxViewsPerSide;){let e=p.children.shift(),t=i.findIndex(t=>t.id===e);t>=0&&i.splice(t,1)}return{rootId:a,nodes:i}}var Be=new Map;function Ve(e,t,n,i,a){let o=t.project.id+`/`+n,s=(Be.get(o)??Promise.resolve()).catch(()=>void 0).then(async()=>{let o=await H(e,t,i);if(!o)return null;let s=t.project.id;for(let t=0;;t++){let i=await e.call(`composition.read`,{projectId:s,compositionId:n}).catch(e=>{if(e instanceof r&&e.error.kind===`not_found`)return null;throw e}),c=(i?.nodes)?.find(e=>e.id===o.node.id);if(c)return{compositionId:n,viewId:c.id};let l=ze(i,o.node,o.side,a);if(!l)return{compositionId:n,viewId:o.node.id};try{return await e.call(`composition.apply`,{projectId:s,compositionId:n,expectedVersion:i?.version??0,changeId:`open-`+crypto.randomUUID(),operations:[{op:`replace`,rootId:l.rootId,nodes:l.nodes}]}),{compositionId:n,viewId:o.node.id}}catch(e){if(t===0&&e instanceof r&&e.error.kind===`stale`)continue;throw e}}});return Be.set(o,s),s}var U=t();function He(e){if(e<1024)return e+` B`;let t=[`KB`,`MB`,`GB`,`TB`],n=e/1024,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r++;return(n<10?n.toFixed(1).replace(/\.0$/,``):Math.round(n))+` `+t[r]}function Ue(e){return e===`table`?`table`:[`image`,`media`].includes(e)?`image`:`file`}function We(e){return e.availability===`available`?`Available`:e.availability===`partial`?`Partly readable`:e.availability===`missing`?`Can't be read`:`Not checked`}function Ge(e){return e.views.length+(e.views.length===1?` view`:` views`)}function Ke({project:e,snapshot:t,current:n,sources:r,partial:s,agent:c,sessions:l,values:u,onOverview:d,onStudio:f,onLayout:p,onNewLayout:m,onSection:h,onSources:ne,onFile:re,onValue:g,onAddSource:ie,adding:ae}){let _=`rho.sources.open.v1:`+e.id,[v,y]=(0,o.useState)(()=>{try{return JSON.parse(sessionStorage.getItem(_)??`[]`)}catch{return[]}});(0,o.useEffect)(()=>{try{y(JSON.parse(sessionStorage.getItem(_)??`[]`))}catch{y([])}},[_]);let b=n.startsWith(`file:`)?n.split(`:`)[1]:null;function x(e){let t=v.includes(e)?v.filter(t=>t!==e):[...v,e];y(t);try{sessionStorage.setItem(_,JSON.stringify(t))}catch{}}let S=e=>e===`workspace`?1:/^workspace-(\d+)$/.test(e)?Number(e.slice(10)):1/0,C=(t?.compositions??[]).filter(e=>!Ae(e.compositionId)).sort((e,t)=>S(e.compositionId)-S(t.compositionId)||e.compositionId.localeCompare(t.compositionId)),w=l.filter((e,t)=>t<8||n===`studio:`+e.id),T=(e,t)=>e==null?void 0:{title:`${e}${s&&t!==`run`?` or more`:``} ${t}${e===1?``:`s`}`,node:(0,U.jsxs)(`span`,{className:`nav-row-count`,"aria-hidden":`true`,children:[e,s&&t!==`run`?`+`:``]})},E=(e,t,r,i,o)=>(0,U.jsxs)(`button`,{className:`nav-row`,title:o?.title,"aria-current":n===e?`page`:void 0,onClick:i,children:[(0,U.jsx)(a,{name:r,size:18}),(0,U.jsx)(`span`,{className:`nav-row-name`,children:t}),o?.node]}),oe=c.waiting?(0,U.jsx)(`span`,{className:`nav-badge waiting`,children:`Needs you`}):c.running?(0,U.jsxs)(`span`,{className:`nav-badge working`,children:[(0,U.jsx)(`span`,{className:`pulse-dot`,"aria-hidden":`true`}),`Working`]}):c.conversations?(0,U.jsx)(`span`,{className:`nav-row-count`,"aria-hidden":`true`,children:c.conversations}):null;return(0,U.jsxs)(`nav`,{"aria-label":`Project`,children:[(0,U.jsxs)(`div`,{className:`nav-group`,children:[E(`overview`,`Overview`,`overview`,d),(0,U.jsxs)(`button`,{className:`nav-row`+(n.startsWith(`studio:`)?` within`:``),"aria-current":n.startsWith(`studio:`)&&!C.some(e=>n===`studio:`+e.compositionId)&&!l.some(e=>n===`studio:`+e.id)?`page`:void 0,onClick:f,children:[(0,U.jsx)(a,{name:`layout`,size:18}),(0,U.jsx)(`span`,{className:`nav-row-name`,children:`Studio`})]}),l.length>0&&(0,U.jsxs)(`div`,{role:`group`,"aria-label":`Sessions`,className:`nav-sub`,children:[w.map(e=>{let t=i(e.when);return(0,U.jsxs)(`button`,{className:`nav-row nav-sub-row nav-session`,title:e.title+(t.full?`
2
+ `+t.full:``),"aria-current":n===`studio:`+e.id?`page`:void 0,onClick:()=>p(e.id),children:[e.running?(0,U.jsx)(`span`,{className:`pulse-dot`,"aria-label":`Working`}):null,(0,U.jsx)(`span`,{className:`nav-row-name`,children:e.title})]},e.id)}),l.length>w.length&&(0,U.jsx)(`button`,{className:`nav-row nav-sub-row nav-more`,onClick:()=>h(`agent`),children:(0,U.jsxs)(`span`,{className:`nav-row-name`,children:[`All `,l.length,` sessions`]})})]}),(C.length>0||m)&&(0,U.jsxs)(`div`,{role:`group`,"aria-label":`Workspaces`,className:`nav-sub`,children:[C.map(e=>(0,U.jsxs)(`button`,{className:`nav-row nav-sub-row`,"aria-current":n===`studio:`+e.compositionId?`page`:void 0,onClick:()=>p(e.compositionId),children:[(0,U.jsx)(`span`,{className:`nav-row-name`,children:Oe(e.compositionId)}),(0,U.jsx)(`span`,{className:`nav-row-count`,title:Ge(e),children:e.views.length})]},e.compositionId)),m&&(0,U.jsxs)(`button`,{className:`nav-row nav-sub-row nav-new`,onClick:m,children:[(0,U.jsx)(a,{name:`plus`,size:13,stroke:2}),(0,U.jsx)(`span`,{className:`nav-row-name`,children:`New workspace`})]})]}),E(`graph`,`Graph`,`graph`,()=>h(`graph`)),E(`console`,`Console`,`prompt`,()=>h(`console`)),t?.catalog.plugins.some(e=>e.id===`kernel`)&&E(`notebook`,`Notebook`,`code`,()=>h(`notebook`)),t?.catalog.plugins.some(e=>e.id===`skills`)&&E(`skills`,`Skills`,`book`,()=>h(`skills`)),((t?.annotations?.length??0)>0||n===`review`)&&E(`review`,`Review`,`question`,()=>h(`review`),T(t?.annotations?.length,`question`)),(0,U.jsxs)(`button`,{className:`nav-row`,"aria-label":`Agent`+(c.waiting?`, needs your choice`:c.running?`, working`:``),"aria-current":n===`agent`?`page`:void 0,onClick:()=>h(`agent`),children:[(0,U.jsx)(a,{name:`spark`,size:18}),(0,U.jsx)(`span`,{className:`nav-row-name`,children:`Agent`}),oe]})]}),(0,U.jsxs)(`div`,{className:`nav-sources`,children:[(0,U.jsxs)(`div`,{className:`nav-heading`,children:[(0,U.jsx)(`span`,{className:`section-label`,id:`nav-sources`,children:`Sources`}),(0,U.jsx)(`button`,{className:`icon-button nav-add`,"aria-label":`Add source folder`,disabled:ae,onClick:ie,children:(0,U.jsx)(a,{name:`plus`,size:15})})]}),(0,U.jsxs)(`div`,{role:`group`,"aria-labelledby":`nav-sources`,className:`nav-group`,children:[te.map(e=>{let[t,i,c]=qe[e],l=r?.[e]??null,d=v.includes(e)||b===e,f=T(l?.length,c);if(!ee.includes(e)&&!l?.length)return null;let p=e===`results`&&u&&(0,U.jsx)(Ze,{values:u,open:v.includes(`variables`),onFold:()=>x(`variables`),onValue:g,onNotebook:()=>h(`notebook`)},`variables`);return(0,U.jsxs)(o.Fragment,{children:[p,(0,U.jsxs)(`div`,{className:`nav-source`+(d?` open`:``),children:[(0,U.jsxs)(`button`,{className:`nav-row`,title:f?.title,"aria-expanded":d,"aria-controls":`nav-files-`+e,"aria-current":n===`sources:`+e?`page`:void 0,onClick:()=>x(e),children:[(0,U.jsx)(a,{name:i,size:18}),(0,U.jsx)(`span`,{className:`nav-row-name`,children:t}),f?.node,(0,U.jsx)(`span`,{className:`nav-twisty`,"aria-hidden":`true`,children:(0,U.jsx)(a,{name:`chevron`,size:12,stroke:2})})]}),d&&(0,U.jsx)(Ye,{id:`nav-files-`+e,kind:e,label:t,items:l,partial:s,current:n,onFile:t=>re(e,t),onAll:()=>ne(e)})]})]},e)}),E(`files`,`Files`,`folder`,()=>h(`files`))]})]})]})}var W={data:`Data`,code:`Code`,results:`Results & figures`,notes:`Notes`,workflows:`Workflows`,reports:`Reports`,references:`References`,environment:`Environment`},qe={data:[W.data,`table`,`data file`],code:[W.code,`code`,`script`],workflows:[W.workflows,`workflow`,`workflow file`],results:[W.results,`chart`,`result`],reports:[W.reports,`report`,`report file`],notes:[W.notes,`document`,`note`],references:[W.references,`book`,`reference file`],environment:[W.environment,`tool`,`environment file`]},Je=e=>e.category===`figures`?`image`:e.category===`code`?`code`:e.category===`notes`?`document`:e.category?`table`:`file`;function Ye({id:e,kind:t,label:n,items:r,partial:i,current:s,onFile:c,onAll:l}){let u=(0,o.useRef)(null);if((0,o.useEffect)(()=>{u.current?.querySelector(`[aria-current=page]`)?.scrollIntoView({block:`nearest`})},[s]),!r)return(0,U.jsx)(`p`,{id:e,className:`nav-files-note`,role:`status`,children:`Reading folders…`});if(!r.length)return(0,U.jsx)(`p`,{id:e,className:`nav-files-note`,children:i?`None in the folders read`:`None yet`});let d=r.slice(0,40),f=new Set(d.map(e=>e.folder)).size>1;function p(e){if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;let t=[...e.currentTarget.closest(`.nav-files`).querySelectorAll(`.nav-file`)],n=t[t.indexOf(e.currentTarget)+(e.key===`ArrowDown`?1:-1)];n&&(e.preventDefault(),n.focus(),n.click())}return(0,U.jsxs)(`ul`,{ref:u,id:e,className:`nav-files`,"aria-label":n,children:[d.map((e,n)=>(0,U.jsxs)(`li`,{children:[f&&e.folder!==d[n-1]?.folder&&(0,U.jsx)(`span`,{className:`nav-folder`,title:e.folder,children:e.folder}),(0,U.jsxs)(`button`,{className:`nav-file`,title:e.path,"aria-current":s===`file:`+t+`:`+e.key?`page`:void 0,onClick:()=>c(e),onKeyDown:p,children:[(0,U.jsx)(a,{name:Je(e),size:14,stroke:1.7}),(0,U.jsx)(`span`,{children:e.name})]})]},e.key)),r.length>d.length&&(0,U.jsx)(`li`,{children:(0,U.jsxs)(`button`,{className:`nav-more`,onClick:l,children:[`All `,r.length,` files`]})})]})}var Xe=e=>e.version?.replace(/^R version (\S+).*$/,`R $1`).replace(/^Python (\S+).*$/,`Python $1`)??(e.language===`r`?`R`:`Python`);function Ze({values:e,open:t,onFold:n,onValue:r,onNotebook:i}){let s=e.sessions.reduce((e,t)=>e+t.variables.length+(t.variablesOmitted??0),0),c=e.sessions.some(e=>e.state===`busy`),l=e.read?e.sessions.length?`${s} value${s===1?``:`s`} in the live ${e.sessions.map(e=>e.language===`r`?`R`:`Python`).join(` and `)} session${e.sessions.length===1?``:`s`}`:`No live session`:void 0;return(0,U.jsxs)(`div`,{className:`nav-source`+(t?` open`:``),children:[(0,U.jsxs)(`button`,{className:`nav-row`,title:l,"aria-expanded":t,"aria-controls":`nav-values`,onClick:n,children:[(0,U.jsx)(a,{name:`list`,size:18}),(0,U.jsx)(`span`,{className:`nav-row-name`,children:`Variables`}),c&&(0,U.jsx)(`span`,{className:`pulse-dot`,"aria-label":`Running`}),e.sessions.length>0&&(0,U.jsx)(`span`,{className:`nav-row-count`,"aria-hidden":`true`,children:s}),(0,U.jsx)(`span`,{className:`nav-twisty`,"aria-hidden":`true`,children:(0,U.jsx)(a,{name:`chevron`,size:12,stroke:2})})]}),t&&(e.read?e.problem&&!e.sessions.length?(0,U.jsx)(`p`,{id:`nav-values`,className:`nav-files-note`,role:`alert`,children:e.problem}):e.sessions.length?(0,U.jsx)(`ul`,{id:`nav-values`,className:`nav-files nav-values`,"aria-label":`Variables`,children:e.sessions.map(e=>(0,U.jsxs)(o.Fragment,{children:[(0,U.jsx)(`li`,{children:(0,U.jsxs)(`span`,{className:`nav-folder`,children:[Xe(e),e.state===`busy`?` · running`:``]})}),e.variables.length?e.variables.slice(0,40).map(t=>(0,U.jsx)(`li`,{children:(0,U.jsxs)(`button`,{className:`nav-file nav-value`,title:`${t.name} · ${t.type}${t.size?` · `+t.size:``}${t.summary?`
3
+ `+t.summary:``}`,onClick:()=>r(e.language,t.name),children:[(0,U.jsx)(`span`,{children:t.name}),(0,U.jsx)(`small`,{children:t.type})]})},e.language+`:`+t.name)):(0,U.jsx)(`li`,{children:(0,U.jsx)(`span`,{className:`nav-files-note nav-values-none`,children:`No values yet`})}),e.variables.length>40||e.variablesOmitted?(0,U.jsx)(`li`,{children:(0,U.jsxs)(`button`,{className:`nav-more`,onClick:i,children:[`All `,e.variables.length+(e.variablesOmitted??0),` in the Notebook`]})}):null]},e.language))}):(0,U.jsxs)(`div`,{id:`nav-values`,className:`nav-files-note`,children:[`No live session. Values show here once R or Python runs a cell.`,(0,U.jsx)(`button`,{className:`nav-more`,onClick:i,children:`Open the Notebook`})]}):(0,U.jsx)(`p`,{id:`nav-values`,className:`nav-files-note`,role:`status`,children:`Reading the live sessions…`}))]})}var G={files:16,concurrent:2,figureBytes:2097152,rows:3,columns:4},Qe=new Map,$e=0,K=0,et=[];async function q(e){K>=G.concurrent&&await new Promise(e=>et.push(e)),K++;try{return await e()}finally{K--,et.shift()?.()}}var tt=()=>({kind:`none`,note:`Preview could not be read`});function nt(e,t,n){let r=t.project.id+`:`+n.path+`:`+(n.resource?n.resource.id+`@`+n.resource.version:n.bytes+`:`+n.modifiedAt),i=Qe.get(r);if(i)return i;if(!n.resource&&!V(t))return Promise.resolve({kind:`none`,note:`No preview in this build`});if(!n.resource&&!u(n.path))return Promise.resolve(tt());if($e>=G.files)return Promise.resolve({kind:`none`,note:`Select it to see it`});$e++;let a=q(async()=>{let r=t.project.id,i=n.resource??await e.call(`agent.activity.capture`,{projectId:r,path:n.path}),a={id:i.id,version:i.version};if(i.kind===`table`){let t=await e.call(`data.page`,{projectId:r,resource:a,offset:0,limit:G.rows});return{kind:`table`,columns:t.columns.slice(0,G.columns).map(e=>e.name),rows:t.rows,total:t.total,width:t.columns.length}}if((n.bytes??0)>G.figureBytes)return{kind:`none`,note:He(n.bytes??0)+` · select it to see it`};let o=await X(e,r,a,G.figureBytes),s=/\.svg$/i.test(n.path)?`image/svg+xml`:/\.png$/i.test(n.path)?`image/png`:`image/jpeg`;return{kind:`image`,url:URL.createObjectURL(new Blob([o],{type:s})),.../^[a-f0-9]{64}$/.test(i.version)?{sha256:i.version}:{}}}).catch(()=>tt());return Qe.set(r,a),a}var J={rows:12,columns:8,textBytes:262144},Y=new Map;async function rt(e,t,n){return n.resource??await e.call(`agent.activity.capture`,{projectId:t.project.id,path:n.path})}var it=(e,t,n)=>n+`:`+e.project.id+`:`+t.path+`:`+(t.resource?t.resource.id+`@`+t.resource.version:t.bytes+`:`+t.modifiedAt);function at(e,t,n,r=J.rows){let i=it(t,n,`table`+r);return Y.has(i)||Y.set(i,q(async()=>{let i=await rt(e,t,n);if(i.kind!==`table`)return null;let a=await e.call(`data.page`,{projectId:t.project.id,resource:{id:i.id,version:i.version},offset:0,limit:Math.min(r,J.rows)});return{columns:a.columns.slice(0,J.columns).map(e=>e.name),rows:a.rows,total:a.total,width:a.columns.length}}).catch(()=>null)),Y.get(i)}function ot(e,t,n){let r=it(t,n,`text`);return Y.has(r)||Y.set(r,q(async()=>{let r=await rt(e,t,n),i=await X(e,t.project.id,{id:r.id,version:r.version},J.textBytes),a=i.length>J.textBytes;return{text:new TextDecoder().decode(a?i.slice(0,J.textBytes):i),cut:a}}).catch(()=>null)),Y.get(r)}async function X(e,t,n,r){let i=0,a=``;for(;;){let o=await e.call(`resource.read`,{projectId:t,resource:n,offset:i});if(a+=atob(o.data),!o.more||a.length>r)break;i=o.nextOffset}return Uint8Array.from(a,e=>e.charCodeAt(0))}var st={files:256},Z=new Map;function ct(e,t,n,r){let i=e=>t.catalog.operations.some(t=>t.method===e&&t.authorized&&t.state===`available`);if(!i(`resource.capture`)||!i(`resource.read`)||(n.bytes??0)>r)return Promise.resolve(null);let a=t.project.id,o=a+`:`+n.path+`:`+n.bytes+`:`+n.modifiedAt,s=Z.get(o);if(s)return s;if(Z.size>=st.files)return Promise.resolve(null);let c=q(async()=>{let t=await e.call(`resource.capture`,{projectId:a,path:n.path,declaration:{path:n.path,kind:`file`,format:{mimeType:`application/octet-stream`}}}),i=await X(e,a,{id:t.id,version:t.version},r);return i.length>r?null:i});return Z.set(o,c),c.catch(()=>Z.delete(o)),c}var Q={images:64,bytes:8388608},lt={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,svg:`image/svg+xml`},$=new Map;function ut(e,t,n){let r=lt[n.path.split(`.`).at(-1).toLowerCase()];if(!r||!V(t)||(n.bytes??0)>Q.bytes)return Promise.resolve(null);let i=t.project.id,a=i+`:`+n.path+`:`+n.bytes+`:`+n.modifiedAt,o=$.get(a);if(o)return o;if($.size>=Q.images)return Promise.resolve(null);let s=q(async()=>{let t=await e.call(`agent.activity.capture`,{projectId:i,path:n.path}),a=await X(e,i,{id:t.id,version:t.version},Q.bytes);return a.length>Q.bytes?null:URL.createObjectURL(new Blob([a],{type:r}))});return $.set(a,s),s.catch(()=>$.delete(a)),s}export{Ce as A,de as B,L as C,R as D,me as E,T as F,w as G,oe as H,le as I,f as J,te as K,he as L,we as M,fe as N,ge as O,F as P,ue as R,_e as S,be as T,u as U,E as V,l as W,Ve as _,at as a,Le as b,We as c,He as d,W as f,je as g,Ee as h,nt as i,I as j,se as k,Je as l,Oe as m,ct as n,ot as o,V as p,m as q,ut as r,Ke as s,X as t,Ue as u,ke as v,Te as w,H as x,Ae as y,pe as z};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./react-Dss-ouuy.js";import{t as r}from"./markdown-0ngRuTpW.js";import{_ as i,b as a,g as o}from"./index-BpL_Kl_s.js";import{t as s}from"./snapshot-CAxBYPvV.js";var c=e(n(),1),l=t();function u({client:e,snapshot:t,principalId:n,annotationId:a,initialAnchor:u,onSent:m,onGraph:h}){let[g,_]=(0,c.useState)(null),[v,y]=(0,c.useState)(``);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(o,{client:e,projectId:t.project.id,principalId:n,annotationId:a,initialAnchor:u,threads:t.annotations,resources:t.resources,conversations:t.conversations??[],contexts:t.contexts,onSent:m,onOpenResource:_,onGraphResource:h,renderText:e=>(0,l.jsx)(r,{text:e,streaming:!1}),renderCodeChanges:n=>(0,l.jsx)(f,{client:e,projectId:t.project.id,annotationId:n,cursor:t.cursor}),renderComparison:(n,r)=>(0,l.jsx)(i,{client:e,projectId:t.project.id,left:n,right:r},n.id+r.id),onExport:y}),g&&(0,l.jsxs)(p,{label:`Captured result`,onClose:()=>_(null),children:[(0,l.jsx)(`button`,{onClick:()=>_(null),children:`Close captured result`}),(0,l.jsx)(s,{client:e,projectId:t.project.id,resource:g})]}),v&&(0,l.jsx)(d,{client:e,projectId:t.project.id,annotationId:v,onClose:()=>y(``)})]})}function d({client:e,projectId:t,annotationId:n,onClose:i}){let[a,o]=(0,c.useState)(null),[u,d]=(0,c.useState)(null),[f,m]=(0,c.useState)(null),[h,g]=(0,c.useState)(``),[_,v]=(0,c.useState)(!1);async function y(){v(!0);try{d(await e.call(`evidence.preview`,{projectId:t,annotationId:n}))}catch(e){g(e.message)}finally{v(!1)}}async function b(){v(!0);try{let r,i=`rho.evidence.export:`+t+`:`+n;try{r=JSON.parse(sessionStorage.getItem(i)??`null`)}catch{}r||(r={projectId:t,annotationId:n,expectedDigest:u.digest,exportId:`evidence-`+crypto.randomUUID()},sessionStorage.setItem(i,JSON.stringify(r))),m(await e.call(`evidence.export`,r)),sessionStorage.removeItem(i)}catch(e){g(e.message)}finally{v(!1)}}return(0,l.jsxs)(p,{label:`Export evidence`,onClose:i,children:[(0,l.jsx)(`button`,{onClick:i,children:`Close export`}),(0,l.jsx)(`h2`,{children:`Export read-only evidence`}),(0,l.jsx)(`p`,{children:`Only this question, its replies, decisions and explicitly linked captured files are included. Completeness of the analysis evidence is not established.`}),h&&(0,l.jsx)(`p`,{role:`alert`,children:h}),(0,l.jsx)(`button`,{disabled:_,onClick:()=>void y(),children:`Preview included evidence`}),u&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`h3`,{children:`Question and replies`}),u.thread.messages.map(e=>(0,l.jsx)(`div`,{children:(0,l.jsx)(r,{text:e.draft.text,streaming:!1})},e.id)),(0,l.jsx)(`h3`,{children:`Human decisions`}),(u.thread.decisions??[]).map(e=>(0,l.jsxs)(`p`,{children:[e.status,` · `,e.reason]},e.id)),(0,l.jsx)(`h3`,{children:`Selected files`}),(0,l.jsxs)(`p`,{children:[u.files.length,` files · `,u.bytes,` bytes`]}),(0,l.jsx)(`ul`,{children:u.files.map(e=>(0,l.jsxs)(`li`,{children:[(0,l.jsx)(`button`,{onClick:()=>o(e.resource),children:e.provenance?.transform?.fields?`Table differences`:e.path}),` `,`· `,e.bytes,` bytes · `,e.resource.version.slice(0,12)]},e.resource.id))}),a&&(0,l.jsx)(s,{client:e,projectId:t,resource:a}),(0,l.jsx)(`h3`,{children:`Evidence gaps`}),(0,l.jsx)(`ul`,{children:u.gaps.map((e,t)=>(0,l.jsx)(`li`,{children:e},t))}),(0,l.jsx)(`button`,{disabled:_||!!f,onClick:()=>void b(),children:`Export this selection`})]}),f&&(0,l.jsxs)(`p`,{role:`status`,children:[`Saved to `,f.destination,`. Open index.html to read it offline.`]})]})}function f({client:e,projectId:t,annotationId:n,cursor:r}){let[i,o]=(0,c.useState)([]),[s,u]=(0,c.useState)(``);(0,c.useEffect)(()=>{let r=!0;return e.call(`evidence.preview`,{projectId:t,annotationId:n}).then(e=>{r&&o(e.files.map(e=>({...e,sourceKind:e.provenance?.observation?.kind??`disk`})).filter(e=>/\.(R|r|py|qmd|Rmd|sh|sql)$/.test(e.path)))},e=>r&&u(e.message)),()=>{r=!1}},[n,r]);let d=[...new Set(i.map(e=>e.path+` · `+e.sourceKind))];return(0,l.jsxs)(`section`,{children:[(0,l.jsx)(`h2`,{children:`Code observations`}),s&&(0,l.jsx)(`p`,{role:`alert`,children:s}),!d.length&&(0,l.jsx)(`p`,{children:`No code versions were explicitly retained for this review.`}),d.map(n=>{let r=i.filter(e=>e.path+` · `+e.sourceKind===n);return(0,l.jsxs)(`article`,{children:[(0,l.jsx)(`h3`,{children:n}),r.length>1?(0,l.jsx)(a,{client:e,projectId:t,before:r[0].resource,after:r.at(-1).resource}):(0,l.jsx)(`p`,{children:`Only one captured version is available. An earlier code version was not retained.`})]},n)})]})}function p({label:e,onClose:t,children:n}){let r=(0,c.useRef)(null);return(0,c.useEffect)(()=>{let e=document.activeElement;return r.current?.showModal(),()=>{r.current?.close(),e?.focus()}},[]),(0,l.jsx)(`dialog`,{className:`review-overlay`,ref:r,"aria-label":e,onCancel:e=>{e.preventDefault(),t()},children:n})}export{u as default};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./react-Dss-ouuy.js";import{t as r}from"./markdown-0ngRuTpW.js";import{_ as i,b as a,g as o}from"./index-CWg9XYXx.js";import{t as s}from"./snapshot-CAxBYPvV.js";var c=e(n(),1),l=t();function u({client:e,snapshot:t,principalId:n,annotationId:a,initialAnchor:u,onSent:m,onGraph:h}){let[g,_]=(0,c.useState)(null),[v,y]=(0,c.useState)(``);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(o,{client:e,projectId:t.project.id,principalId:n,annotationId:a,initialAnchor:u,threads:t.annotations,resources:t.resources,conversations:t.conversations??[],contexts:t.contexts,onSent:m,onOpenResource:_,onGraphResource:h,renderText:e=>(0,l.jsx)(r,{text:e,streaming:!1}),renderCodeChanges:n=>(0,l.jsx)(f,{client:e,projectId:t.project.id,annotationId:n,cursor:t.cursor}),renderComparison:(n,r)=>(0,l.jsx)(i,{client:e,projectId:t.project.id,left:n,right:r},n.id+r.id),onExport:y}),g&&(0,l.jsxs)(p,{label:`Captured result`,onClose:()=>_(null),children:[(0,l.jsx)(`button`,{onClick:()=>_(null),children:`Close captured result`}),(0,l.jsx)(s,{client:e,projectId:t.project.id,resource:g})]}),v&&(0,l.jsx)(d,{client:e,projectId:t.project.id,annotationId:v,onClose:()=>y(``)})]})}function d({client:e,projectId:t,annotationId:n,onClose:i}){let[a,o]=(0,c.useState)(null),[u,d]=(0,c.useState)(null),[f,m]=(0,c.useState)(null),[h,g]=(0,c.useState)(``),[_,v]=(0,c.useState)(!1);async function y(){v(!0);try{d(await e.call(`evidence.preview`,{projectId:t,annotationId:n}))}catch(e){g(e.message)}finally{v(!1)}}async function b(){v(!0);try{let r,i=`rho.evidence.export:`+t+`:`+n;try{r=JSON.parse(sessionStorage.getItem(i)??`null`)}catch{}r||(r={projectId:t,annotationId:n,expectedDigest:u.digest,exportId:`evidence-`+crypto.randomUUID()},sessionStorage.setItem(i,JSON.stringify(r))),m(await e.call(`evidence.export`,r)),sessionStorage.removeItem(i)}catch(e){g(e.message)}finally{v(!1)}}return(0,l.jsxs)(p,{label:`Export evidence`,onClose:i,children:[(0,l.jsx)(`button`,{onClick:i,children:`Close export`}),(0,l.jsx)(`h2`,{children:`Export read-only evidence`}),(0,l.jsx)(`p`,{children:`Only this question, its replies, decisions and explicitly linked captured files are included. Completeness of the analysis evidence is not established.`}),h&&(0,l.jsx)(`p`,{role:`alert`,children:h}),(0,l.jsx)(`button`,{disabled:_,onClick:()=>void y(),children:`Preview included evidence`}),u&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`h3`,{children:`Question and replies`}),u.thread.messages.map(e=>(0,l.jsx)(`div`,{children:(0,l.jsx)(r,{text:e.draft.text,streaming:!1})},e.id)),(0,l.jsx)(`h3`,{children:`Human decisions`}),(u.thread.decisions??[]).map(e=>(0,l.jsxs)(`p`,{children:[e.status,` · `,e.reason]},e.id)),(0,l.jsx)(`h3`,{children:`Selected files`}),(0,l.jsxs)(`p`,{children:[u.files.length,` files · `,u.bytes,` bytes`]}),(0,l.jsx)(`ul`,{children:u.files.map(e=>(0,l.jsxs)(`li`,{children:[(0,l.jsx)(`button`,{onClick:()=>o(e.resource),children:e.provenance?.transform?.fields?`Table differences`:e.path}),` `,`· `,e.bytes,` bytes · `,e.resource.version.slice(0,12)]},e.resource.id))}),a&&(0,l.jsx)(s,{client:e,projectId:t,resource:a}),(0,l.jsx)(`h3`,{children:`Evidence gaps`}),(0,l.jsx)(`ul`,{children:u.gaps.map((e,t)=>(0,l.jsx)(`li`,{children:e},t))}),(0,l.jsx)(`button`,{disabled:_||!!f,onClick:()=>void b(),children:`Export this selection`})]}),f&&(0,l.jsxs)(`p`,{role:`status`,children:[`Saved to `,f.destination,`. Open index.html to read it offline.`]})]})}function f({client:e,projectId:t,annotationId:n,cursor:r}){let[i,o]=(0,c.useState)([]),[s,u]=(0,c.useState)(``);(0,c.useEffect)(()=>{let r=!0;return e.call(`evidence.preview`,{projectId:t,annotationId:n}).then(e=>{r&&o(e.files.map(e=>({...e,sourceKind:e.provenance?.observation?.kind??`disk`})).filter(e=>/\.(R|r|py|qmd|Rmd|sh|sql)$/.test(e.path)))},e=>r&&u(e.message)),()=>{r=!1}},[n,r]);let d=[...new Set(i.map(e=>e.path+` · `+e.sourceKind))];return(0,l.jsxs)(`section`,{children:[(0,l.jsx)(`h2`,{children:`Code observations`}),s&&(0,l.jsx)(`p`,{role:`alert`,children:s}),!d.length&&(0,l.jsx)(`p`,{children:`No code versions were explicitly retained for this review.`}),d.map(n=>{let r=i.filter(e=>e.path+` · `+e.sourceKind===n);return(0,l.jsxs)(`article`,{children:[(0,l.jsx)(`h3`,{children:n}),r.length>1?(0,l.jsx)(a,{client:e,projectId:t,before:r[0].resource,after:r.at(-1).resource}):(0,l.jsx)(`p`,{children:`Only one captured version is available. An earlier code version was not retained.`})]},n)})]})}function p({label:e,onClose:t,children:n}){let r=(0,c.useRef)(null);return(0,c.useEffect)(()=>{let e=document.activeElement;return r.current?.showModal(),()=>{r.current?.close(),e?.focus()}},[]),(0,l.jsx)(`dialog`,{className:`review-overlay`,ref:r,"aria-label":e,onCancel:e=>{e.preventDefault(),t()},children:n})}export{u as default};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./react-Dss-ouuy.js";import{s as r}from"./home-CCbP6kS-.js";import{r as i,t as a}from"./markdown-0ngRuTpW.js";import{tt as o}from"./index-BpL_Kl_s.js";import{a as s,c,i as l,l as u,n as d,o as f,r as p,s as m,u as h}from"./skills-work-DNexV4OJ.js";var g=e(n(),1),_=t(),v={changes:20},y={recorded:`changed`,removed:`removed`,undone:`undid a change to`,outside:`changed`};function b({client:e,snapshot:t,onPath:n,onConversation:i,onNotebook:a}){let o=t.project.id,{list:s,problem:l,again:f}=h(e,o,t.cursor),m=u(t),[v,b]=(0,g.useState)(p),[w,T]=(0,g.useState)(v!==null);(0,g.useEffect)(d,[]);let E=s?.skills??[],D=s?.removed??[],O=[...E,...D].filter(e=>e.last).sort((e,t)=>t.last.at.localeCompare(e.last.at))[0]??E[0]??null,k=v&&[...E,...D].some(e=>e.name===v)?v:O?.name??null,j=e=>{b(e),T(!0)},M=O?.last;return(0,_.jsxs)(`section`,{className:`project-page skills-page`,"aria-labelledby":`skills-title`,children:[(0,_.jsx)(`header`,{className:`page-heading`,children:(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`h1`,{id:`skills-title`,children:`Skills`}),s&&E.length===0&&(0,_.jsx)(`p`,{children:`How work is done in this project, read by every Agent here`}),s&&E.length>0&&(0,_.jsxs)(`p`,{children:[E.length,` `,E.length===1?`skill`:`skills`,` every Agent here reads`,M?` · ${M.kind===`outside`?c(O.name)+` was changed outside Rho`:m(M.by).name+` `+y[M.kind]+` `+c(O.name)} ${r(M.at).text.toLowerCase()}`:``]})]})}),l&&(0,_.jsxs)(`div`,{className:`inline-error`,role:`alert`,children:[(0,_.jsxs)(`p`,{children:[`The skills could not be read. `,l]}),(0,_.jsx)(`button`,{onClick:()=>void f(),children:`Try again`})]}),!s&&!l?(0,_.jsx)(`p`,{className:`quiet-empty`,role:`status`,children:`Reading the skills…`}):s&&(0,_.jsxs)(`div`,{className:`skills-layout`+(w&&k?` showing`:``)+(k?``:` none-yet`),children:[(0,_.jsxs)(`nav`,{className:`skills-index`,"aria-label":`Skills`,children:[E.length>0?(0,_.jsx)(`ul`,{className:`skills-list`,children:E.map(e=>(0,_.jsx)(`li`,{children:(0,_.jsx)(x,{skill:e,current:e.name===k,author:m,onChoose:()=>j(e.name)})},e.name))}):(0,_.jsxs)(`div`,{className:`skills-empty`,children:[(0,_.jsx)(`h2`,{children:`No project skills yet`}),(0,_.jsx)(`p`,{children:`When you correct how your Agent works, or it finds why something failed, it records that here, and the next conversation starts from it. You can also tell it directly:`}),(0,_.jsx)(`ul`,{children:[`For this project we report proportions as percentages.`,`Remember how we filter the cells, so the next analysis does the same.`].map(e=>(0,_.jsxs)(`li`,{children:[`“`,e,`”`]},e))}),(0,_.jsx)(`small`,{children:`Skills are kept as SKILL.md files in .claude/skills in the project folder. Claude Code reads them by itself; other Agents read them through Rho.`})]}),D.length>0&&(0,_.jsxs)(`details`,{className:`skills-removed`,open:D.some(e=>e.name===k),children:[(0,_.jsxs)(`summary`,{children:[(0,_.jsx)(C,{}),`Removed `,(0,_.jsx)(`span`,{className:`section-count`,children:D.length})]}),(0,_.jsx)(`ul`,{className:`skills-list`,children:D.map(e=>(0,_.jsx)(`li`,{children:(0,_.jsx)(x,{skill:e,current:e.name===k,author:m,onChoose:()=>j(e.name)})},e.name))})]}),(0,_.jsx)(A,{client:e,snapshot:t})]}),k&&(0,_.jsx)(S,{client:e,snapshot:t,name:k,summary:[...E,...D].find(e=>e.name===k),author:m,onBack:()=>T(!1),onPath:n,onConversation:i,onNotebook:a,onChanged:()=>void f()},k)]})]})}function x({skill:e,current:t,author:n,onChoose:i}){let a=e.last;return(0,_.jsxs)(`button`,{className:`skills-row`,"aria-current":t?`true`:void 0,onClick:i,title:m(e.name),children:[(0,_.jsx)(`strong`,{children:c(e.name)}),e.description&&(0,_.jsx)(`span`,{className:`skills-row-desc`,children:e.description}),(0,_.jsx)(`small`,{children:e.problem?(0,_.jsx)(`span`,{className:`skills-row-problem`,children:e.problem}):a?e.outside?`Changed outside Rho`:`${a.kind===`outside`?`Changed outside Rho`:l(a,n(a.by).name)} · ${r(a.at).text}`:`Written outside Rho`})]})}function S({client:e,snapshot:t,name:n,summary:o,author:u,onBack:d,onPath:p,onConversation:h,onNotebook:y,onChanged:b}){let x=t.project.id,[S,w]=(0,g.useState)(null),[A,j]=(0,g.useState)(``),[M,N]=(0,g.useState)(!1),[P,F]=(0,g.useState)(``),I=()=>e.call(`skills.read`,{projectId:x,name:n,limit:v.changes}).then(e=>{w(e),j(``)},e=>j(s(e)));(0,g.useEffect)(()=>{I()},[e,x,n,t.cursor]);let[L,...R]=S?.changes??[],z=!!L&&L.kind!==`outside`&&!L.undoneBy&&!S?.outside;async function B(t){N(!0),F(``);try{await e.call(`skills.undo`,{projectId:x,name:n,change:t.id,changeId:`undo-`+t.id+`-`+Date.now().toString(36)}),b(),await I()}catch(e){F(s(e))}finally{N(!1)}}let V=e=>{let t=u(e.by),n=l(e,t.name);return t.conversationId?(0,_.jsx)(`button`,{className:`text-button skills-who`,onClick:()=>h(t.conversationId),title:`Open the conversation`,children:n}):n},H=new Set((t.conversations??[]).map(e=>e.conversationId)),U=e=>(0,_.jsx)(k,{evidence:e,known:H.has(e.ref),onPath:p,onConversation:h,onNotebook:y},e.kind+e.ref);return(0,_.jsxs)(`article`,{className:`skills-detail`,"aria-labelledby":`skill-title`,children:[(0,_.jsxs)(`button`,{className:`text-button skills-back`,onClick:d,children:[(0,_.jsx)(i,{name:`back`,size:14}),`All skills`]}),(0,_.jsxs)(`header`,{className:`skills-detail-head`,children:[(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`h2`,{id:`skill-title`,children:c(n)}),(S?.skill?.description??o.description)&&(0,_.jsx)(`p`,{children:S?.skill?.description??o.description})]}),S?.skill&&(0,_.jsxs)(`button`,{onClick:()=>p(m(n)),title:m(n),children:[(0,_.jsx)(i,{name:`document`,size:15}),`Edit the file`]})]}),A&&(0,_.jsxs)(`div`,{className:`inline-error`,role:`alert`,children:[(0,_.jsx)(`p`,{children:A}),(0,_.jsx)(`button`,{onClick:()=>void I(),children:`Try again`})]}),!S&&!A&&(0,_.jsxs)(`p`,{className:`quiet-empty`,role:`status`,children:[`Reading `,c(n),`…`]}),o.problem&&(0,_.jsx)(`p`,{className:`skills-note`,role:`status`,children:o.problem}),S?.outside&&(S.outside.since===null&&!L?(0,_.jsx)(`p`,{className:`skills-note`,role:`status`,children:`Written outside Rho. Agents read it as it is; Rho records its changes from the first one made here.`}):(0,_.jsxs)(`section`,{className:`skills-change outside`,"aria-label":`Changed outside Rho`,children:[(0,_.jsx)(`p`,{className:`skills-change-reason`,children:`Changed outside Rho since the last recorded change`}),(0,_.jsxs)(`p`,{className:`skills-change-meta`,children:[(0,_.jsx)(E,{added:S.outside.added,removed:S.outside.removed}),` · Agents read it as it is now; the next change recorded here starts from it`]}),(0,_.jsx)(O,{diff:S.outside.diff})]})),L&&(0,_.jsxs)(`section`,{className:`skills-change newest`+(L.undoneBy?` undone`:``),"aria-label":`Newest change`,children:[(0,_.jsx)(`p`,{className:`skills-change-reason`,children:f(L)}),(0,_.jsxs)(`p`,{className:`skills-change-meta`,children:[V(L),` · `,r(L.at).text,` · `,(0,_.jsx)(E,{added:L.added,removed:L.removed})]}),L.evidence.length>0&&(0,_.jsx)(`div`,{className:`skills-evidence`,children:L.evidence.map(U)}),(0,_.jsx)(D,{change:L}),(z||P)&&(0,_.jsxs)(`div`,{className:`skills-change-actions`,children:[z&&(0,_.jsx)(`button`,{onClick:()=>void B(L),disabled:M,children:M?`Undoing…`:L.kind===`removed`?`Bring it back`:L.kind===`undone`?`Put the change back`:`Undo this change`}),P&&(0,_.jsx)(`p`,{role:`alert`,children:P})]})]}),S?.skill?(0,_.jsxs)(`section`,{className:`skills-text`,"aria-labelledby":`skills-text-title`,children:[(0,_.jsx)(`h3`,{id:`skills-text-title`,children:`What Agents read`}),(0,_.jsx)(a,{text:T(S.skill.body,n),streaming:!1})]}):S&&(0,_.jsx)(`p`,{className:`skills-note`,children:`This skill was removed. Its changes are kept below.`}),R.length>0&&(0,_.jsxs)(`section`,{className:`skills-history`,"aria-labelledby":`skills-history-title`,children:[(0,_.jsx)(`h3`,{id:`skills-history-title`,children:`Earlier changes`}),(0,_.jsx)(`ol`,{children:R.map(e=>(0,_.jsx)(`li`,{className:e.undoneBy?`undone`:void 0,children:(0,_.jsxs)(`details`,{children:[(0,_.jsxs)(`summary`,{children:[(0,_.jsx)(C,{}),(0,_.jsx)(`span`,{className:`skills-history-reason`,children:f(e)}),(0,_.jsxs)(`small`,{children:[l(e,u(e.by).name),` · `,r(e.at).text,e.undoneBy?` · undone`:``]}),(0,_.jsx)(E,{added:e.added,removed:e.removed})]}),e.evidence.length>0&&(0,_.jsx)(`div`,{className:`skills-evidence`,children:e.evidence.map(U)}),(0,_.jsx)(D,{change:e})]})},e.id))}),(S?.omitted??0)>0&&(0,_.jsxs)(`p`,{className:`quiet-empty`,children:[S.omitted,` older `,S.omitted===1?`change`:`changes`,` kept`]})]})]})}var C=()=>(0,_.jsx)(`span`,{className:`skills-twisty`,"aria-hidden":`true`,children:(0,_.jsx)(i,{name:`chevron`,size:11,stroke:2})}),w=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,` `).trim(),T=(e,t)=>e.replace(/^\s*# (.+)\n+/,(e,n)=>w(n)===w(t)?``:e),E=({added:e,removed:t})=>(0,_.jsxs)(`span`,{className:`skills-counts`,"aria-label":`${e} lines added, ${t} removed`,children:[(0,_.jsxs)(`span`,{className:`added`,children:[`+`,e]}),` `,(0,_.jsxs)(`span`,{className:`removed`,children:[`−`,t]})]});function D({change:e}){return e.before!==null&&e.after!==null?(0,_.jsx)(O,{diff:e.diff}):(0,_.jsxs)(`details`,{className:`skills-removed-text`,children:[(0,_.jsxs)(`summary`,{children:[(0,_.jsx)(C,{}),e.after===null?`The text it removed`:`The text it wrote`]}),(0,_.jsx)(O,{diff:e.diff})]})}function O({diff:e}){return e.lines.length?(0,_.jsxs)(`div`,{className:`skills-diff`,role:`group`,"aria-label":`What changed`,children:[e.lines.map((e,t)=>e.op===`…`?(0,_.jsxs)(`div`,{className:`fold`,children:[e.text,` unchanged `,e.text===`1`?`line`:`lines`]},t):(0,_.jsxs)(`div`,{className:e.op===`+`?`add`:e.op===`-`?`del`:`keep`,children:[(0,_.jsx)(`span`,{"aria-hidden":`true`,children:e.op}),e.text||` `]},t)),e.cut&&(0,_.jsx)(`div`,{className:`fold`,children:`The rest is not shown`})]}):null}function k({evidence:e,known:t,onPath:n,onConversation:r,onNotebook:a}){let s=e.label||e.ref;return e.kind===`cell`?(0,_.jsxs)(`button`,{className:`skills-chip`,onClick:()=>{o(e.ref),a()},title:`Open the cell in the Notebook`,children:[(0,_.jsx)(i,{name:`code`,size:13}),s]}):e.kind===`file`?(0,_.jsxs)(`button`,{className:`skills-chip`,onClick:()=>n(e.ref),title:e.ref,children:[(0,_.jsx)(i,{name:`file`,size:13}),s]}):e.kind===`conversation`&&t?(0,_.jsxs)(`button`,{className:`skills-chip`,onClick:()=>r(e.ref),children:[(0,_.jsx)(i,{name:`prompt`,size:13}),e.label||`The conversation`]}):(0,_.jsx)(`span`,{className:`skills-chip quiet`,title:e.kind===`note`?void 0:e.ref,children:e.kind===`note`?`“`+s.trim().replace(/^["“'‘]+|["”'’]+$/g,``)+`”`:s})}function A({client:e,snapshot:t}){let n=t.project.id,r=t.catalog.operations.some(e=>e.method===`kernel.servers`&&e.state===`available`&&e.authorized),[o,c]=(0,g.useState)(null),[l,u]=(0,g.useState)({});(0,g.useEffect)(()=>{if(!r)return;let t=!0;return e.call(`kernel.places`,{projectId:n}).then(async r=>{if(!r.places.some(e=>e.via===`serverctl`)){t&&c({places:r,servers:null});return}let i=await e.call(`kernel.servers`,{projectId:n});t&&c({places:r,servers:i})},()=>{}),()=>{t=!1}},[e,n,r]);let d=(o?.places.places??[]).filter(e=>e.via===`serverctl`).flatMap(e=>(o.servers?.servers.find(t=>t.server===e.destination)?.skills??[]).map(t=>({place:e,skill:t}))),f=d.filter((e,t)=>d.findIndex(t=>t.place.destination===e.place.destination&&t.skill.name===e.skill.name)===t);if(!f.length)return null;let p=(t,r)=>{let i=t+`/`+r;l[i]===void 0&&(u(e=>({...e,[i]:``})),e.call(`kernel.server.skill`,{projectId:n,server:t,name:r}).then(e=>u(t=>({...t,[i]:e.text??``})),e=>u(t=>({...t,[i]:s(e)}))))};return(0,_.jsxs)(`section`,{className:`skills-servers`,"aria-labelledby":`skills-servers-title`,children:[(0,_.jsx)(`h2`,{id:`skills-servers-title`,children:`From your servers`}),(0,_.jsx)(`ul`,{children:f.map(({place:e,skill:t})=>{let n=e.destination+`/`+t.name;return(0,_.jsx)(`li`,{children:(0,_.jsxs)(`details`,{onToggle:n=>{n.currentTarget.open&&p(e.destination,t.name)},children:[(0,_.jsxs)(`summary`,{children:[(0,_.jsx)(i,{name:`server`,size:14}),(0,_.jsxs)(`span`,{children:[(0,_.jsx)(`strong`,{children:t.name}),(0,_.jsxs)(`small`,{children:[e.destination,` · through serverctl`]})]})]}),t.description&&(0,_.jsx)(`p`,{className:`skills-servers-desc`,children:t.description}),l[n]===``?(0,_.jsx)(`p`,{className:`quiet-empty`,role:`status`,children:`Reading…`}):l[n]?(0,_.jsx)(`div`,{className:`skills-servers-text`,children:(0,_.jsx)(a,{text:l[n].replace(/^---[\s\S]*?\n---\n/,``),streaming:!1})}):null]})},n)})})]})}export{b as SkillsPage};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./react-Dss-ouuy.js";import{s as r}from"./home-CCbP6kS-.js";import{r as i,t as a}from"./markdown-0ngRuTpW.js";import{tt as o}from"./index-CWg9XYXx.js";import{a as s,c,i as l,l as u,n as d,o as f,r as p,s as m,u as h}from"./skills-work-BEGqlCkx.js";var g=e(n(),1),_=t(),v={changes:20},y={recorded:`changed`,removed:`removed`,undone:`undid a change to`,outside:`changed`};function b({client:e,snapshot:t,onPath:n,onConversation:i,onNotebook:a}){let o=t.project.id,{list:s,problem:l,again:f}=h(e,o,t.cursor),m=u(t),[v,b]=(0,g.useState)(p),[w,T]=(0,g.useState)(v!==null);(0,g.useEffect)(d,[]);let E=s?.skills??[],D=s?.removed??[],O=[...E,...D].filter(e=>e.last).sort((e,t)=>t.last.at.localeCompare(e.last.at))[0]??E[0]??null,k=v&&[...E,...D].some(e=>e.name===v)?v:O?.name??null,j=e=>{b(e),T(!0)},M=O?.last;return(0,_.jsxs)(`section`,{className:`project-page skills-page`,"aria-labelledby":`skills-title`,children:[(0,_.jsx)(`header`,{className:`page-heading`,children:(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`h1`,{id:`skills-title`,children:`Skills`}),s&&E.length===0&&(0,_.jsx)(`p`,{children:`How work is done in this project, read by every Agent here`}),s&&E.length>0&&(0,_.jsxs)(`p`,{children:[E.length,` `,E.length===1?`skill`:`skills`,` every Agent here reads`,M?` · ${M.kind===`outside`?c(O.name)+` was changed outside Rho`:m(M.by).name+` `+y[M.kind]+` `+c(O.name)} ${r(M.at).text.toLowerCase()}`:``]})]})}),l&&(0,_.jsxs)(`div`,{className:`inline-error`,role:`alert`,children:[(0,_.jsxs)(`p`,{children:[`The skills could not be read. `,l]}),(0,_.jsx)(`button`,{onClick:()=>void f(),children:`Try again`})]}),!s&&!l?(0,_.jsx)(`p`,{className:`quiet-empty`,role:`status`,children:`Reading the skills…`}):s&&(0,_.jsxs)(`div`,{className:`skills-layout`+(w&&k?` showing`:``)+(k?``:` none-yet`),children:[(0,_.jsxs)(`nav`,{className:`skills-index`,"aria-label":`Skills`,children:[E.length>0?(0,_.jsx)(`ul`,{className:`skills-list`,children:E.map(e=>(0,_.jsx)(`li`,{children:(0,_.jsx)(x,{skill:e,current:e.name===k,author:m,onChoose:()=>j(e.name)})},e.name))}):(0,_.jsxs)(`div`,{className:`skills-empty`,children:[(0,_.jsx)(`h2`,{children:`No project skills yet`}),(0,_.jsx)(`p`,{children:`When you correct how your Agent works, or it finds why something failed, it records that here, and the next conversation starts from it. You can also tell it directly:`}),(0,_.jsx)(`ul`,{children:[`For this project we report proportions as percentages.`,`Remember how we filter the cells, so the next analysis does the same.`].map(e=>(0,_.jsxs)(`li`,{children:[`“`,e,`”`]},e))}),(0,_.jsx)(`small`,{children:`Skills are kept as SKILL.md files in .claude/skills in the project folder. Claude Code reads them by itself; other Agents read them through Rho.`})]}),D.length>0&&(0,_.jsxs)(`details`,{className:`skills-removed`,open:D.some(e=>e.name===k),children:[(0,_.jsxs)(`summary`,{children:[(0,_.jsx)(C,{}),`Removed `,(0,_.jsx)(`span`,{className:`section-count`,children:D.length})]}),(0,_.jsx)(`ul`,{className:`skills-list`,children:D.map(e=>(0,_.jsx)(`li`,{children:(0,_.jsx)(x,{skill:e,current:e.name===k,author:m,onChoose:()=>j(e.name)})},e.name))})]}),(0,_.jsx)(A,{client:e,snapshot:t})]}),k&&(0,_.jsx)(S,{client:e,snapshot:t,name:k,summary:[...E,...D].find(e=>e.name===k),author:m,onBack:()=>T(!1),onPath:n,onConversation:i,onNotebook:a,onChanged:()=>void f()},k)]})]})}function x({skill:e,current:t,author:n,onChoose:i}){let a=e.last;return(0,_.jsxs)(`button`,{className:`skills-row`,"aria-current":t?`true`:void 0,onClick:i,title:m(e.name),children:[(0,_.jsx)(`strong`,{children:c(e.name)}),e.description&&(0,_.jsx)(`span`,{className:`skills-row-desc`,children:e.description}),(0,_.jsx)(`small`,{children:e.problem?(0,_.jsx)(`span`,{className:`skills-row-problem`,children:e.problem}):a?e.outside?`Changed outside Rho`:`${a.kind===`outside`?`Changed outside Rho`:l(a,n(a.by).name)} · ${r(a.at).text}`:`Written outside Rho`})]})}function S({client:e,snapshot:t,name:n,summary:o,author:u,onBack:d,onPath:p,onConversation:h,onNotebook:y,onChanged:b}){let x=t.project.id,[S,w]=(0,g.useState)(null),[A,j]=(0,g.useState)(``),[M,N]=(0,g.useState)(!1),[P,F]=(0,g.useState)(``),I=()=>e.call(`skills.read`,{projectId:x,name:n,limit:v.changes}).then(e=>{w(e),j(``)},e=>j(s(e)));(0,g.useEffect)(()=>{I()},[e,x,n,t.cursor]);let[L,...R]=S?.changes??[],z=!!L&&L.kind!==`outside`&&!L.undoneBy&&!S?.outside;async function B(t){N(!0),F(``);try{await e.call(`skills.undo`,{projectId:x,name:n,change:t.id,changeId:`undo-`+t.id+`-`+Date.now().toString(36)}),b(),await I()}catch(e){F(s(e))}finally{N(!1)}}let V=e=>{let t=u(e.by),n=l(e,t.name);return t.conversationId?(0,_.jsx)(`button`,{className:`text-button skills-who`,onClick:()=>h(t.conversationId),title:`Open the conversation`,children:n}):n},H=new Set((t.conversations??[]).map(e=>e.conversationId)),U=e=>(0,_.jsx)(k,{evidence:e,known:H.has(e.ref),onPath:p,onConversation:h,onNotebook:y},e.kind+e.ref);return(0,_.jsxs)(`article`,{className:`skills-detail`,"aria-labelledby":`skill-title`,children:[(0,_.jsxs)(`button`,{className:`text-button skills-back`,onClick:d,children:[(0,_.jsx)(i,{name:`back`,size:14}),`All skills`]}),(0,_.jsxs)(`header`,{className:`skills-detail-head`,children:[(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`h2`,{id:`skill-title`,children:c(n)}),(S?.skill?.description??o.description)&&(0,_.jsx)(`p`,{children:S?.skill?.description??o.description})]}),S?.skill&&(0,_.jsxs)(`button`,{onClick:()=>p(m(n)),title:m(n),children:[(0,_.jsx)(i,{name:`document`,size:15}),`Edit the file`]})]}),A&&(0,_.jsxs)(`div`,{className:`inline-error`,role:`alert`,children:[(0,_.jsx)(`p`,{children:A}),(0,_.jsx)(`button`,{onClick:()=>void I(),children:`Try again`})]}),!S&&!A&&(0,_.jsxs)(`p`,{className:`quiet-empty`,role:`status`,children:[`Reading `,c(n),`…`]}),o.problem&&(0,_.jsx)(`p`,{className:`skills-note`,role:`status`,children:o.problem}),S?.outside&&(S.outside.since===null&&!L?(0,_.jsx)(`p`,{className:`skills-note`,role:`status`,children:`Written outside Rho. Agents read it as it is; Rho records its changes from the first one made here.`}):(0,_.jsxs)(`section`,{className:`skills-change outside`,"aria-label":`Changed outside Rho`,children:[(0,_.jsx)(`p`,{className:`skills-change-reason`,children:`Changed outside Rho since the last recorded change`}),(0,_.jsxs)(`p`,{className:`skills-change-meta`,children:[(0,_.jsx)(E,{added:S.outside.added,removed:S.outside.removed}),` · Agents read it as it is now; the next change recorded here starts from it`]}),(0,_.jsx)(O,{diff:S.outside.diff})]})),L&&(0,_.jsxs)(`section`,{className:`skills-change newest`+(L.undoneBy?` undone`:``),"aria-label":`Newest change`,children:[(0,_.jsx)(`p`,{className:`skills-change-reason`,children:f(L)}),(0,_.jsxs)(`p`,{className:`skills-change-meta`,children:[V(L),` · `,r(L.at).text,` · `,(0,_.jsx)(E,{added:L.added,removed:L.removed})]}),L.evidence.length>0&&(0,_.jsx)(`div`,{className:`skills-evidence`,children:L.evidence.map(U)}),(0,_.jsx)(D,{change:L}),(z||P)&&(0,_.jsxs)(`div`,{className:`skills-change-actions`,children:[z&&(0,_.jsx)(`button`,{onClick:()=>void B(L),disabled:M,children:M?`Undoing…`:L.kind===`removed`?`Bring it back`:L.kind===`undone`?`Put the change back`:`Undo this change`}),P&&(0,_.jsx)(`p`,{role:`alert`,children:P})]})]}),S?.skill?(0,_.jsxs)(`section`,{className:`skills-text`,"aria-labelledby":`skills-text-title`,children:[(0,_.jsx)(`h3`,{id:`skills-text-title`,children:`What Agents read`}),(0,_.jsx)(a,{text:T(S.skill.body,n),streaming:!1})]}):S&&(0,_.jsx)(`p`,{className:`skills-note`,children:`This skill was removed. Its changes are kept below.`}),R.length>0&&(0,_.jsxs)(`section`,{className:`skills-history`,"aria-labelledby":`skills-history-title`,children:[(0,_.jsx)(`h3`,{id:`skills-history-title`,children:`Earlier changes`}),(0,_.jsx)(`ol`,{children:R.map(e=>(0,_.jsx)(`li`,{className:e.undoneBy?`undone`:void 0,children:(0,_.jsxs)(`details`,{children:[(0,_.jsxs)(`summary`,{children:[(0,_.jsx)(C,{}),(0,_.jsx)(`span`,{className:`skills-history-reason`,children:f(e)}),(0,_.jsxs)(`small`,{children:[l(e,u(e.by).name),` · `,r(e.at).text,e.undoneBy?` · undone`:``]}),(0,_.jsx)(E,{added:e.added,removed:e.removed})]}),e.evidence.length>0&&(0,_.jsx)(`div`,{className:`skills-evidence`,children:e.evidence.map(U)}),(0,_.jsx)(D,{change:e})]})},e.id))}),(S?.omitted??0)>0&&(0,_.jsxs)(`p`,{className:`quiet-empty`,children:[S.omitted,` older `,S.omitted===1?`change`:`changes`,` kept`]})]})]})}var C=()=>(0,_.jsx)(`span`,{className:`skills-twisty`,"aria-hidden":`true`,children:(0,_.jsx)(i,{name:`chevron`,size:11,stroke:2})}),w=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,` `).trim(),T=(e,t)=>e.replace(/^\s*# (.+)\n+/,(e,n)=>w(n)===w(t)?``:e),E=({added:e,removed:t})=>(0,_.jsxs)(`span`,{className:`skills-counts`,"aria-label":`${e} lines added, ${t} removed`,children:[(0,_.jsxs)(`span`,{className:`added`,children:[`+`,e]}),` `,(0,_.jsxs)(`span`,{className:`removed`,children:[`−`,t]})]});function D({change:e}){return e.before!==null&&e.after!==null?(0,_.jsx)(O,{diff:e.diff}):(0,_.jsxs)(`details`,{className:`skills-removed-text`,children:[(0,_.jsxs)(`summary`,{children:[(0,_.jsx)(C,{}),e.after===null?`The text it removed`:`The text it wrote`]}),(0,_.jsx)(O,{diff:e.diff})]})}function O({diff:e}){return e.lines.length?(0,_.jsxs)(`div`,{className:`skills-diff`,role:`group`,"aria-label":`What changed`,children:[e.lines.map((e,t)=>e.op===`…`?(0,_.jsxs)(`div`,{className:`fold`,children:[e.text,` unchanged `,e.text===`1`?`line`:`lines`]},t):(0,_.jsxs)(`div`,{className:e.op===`+`?`add`:e.op===`-`?`del`:`keep`,children:[(0,_.jsx)(`span`,{"aria-hidden":`true`,children:e.op}),e.text||` `]},t)),e.cut&&(0,_.jsx)(`div`,{className:`fold`,children:`The rest is not shown`})]}):null}function k({evidence:e,known:t,onPath:n,onConversation:r,onNotebook:a}){let s=e.label||e.ref;return e.kind===`cell`?(0,_.jsxs)(`button`,{className:`skills-chip`,onClick:()=>{o(e.ref),a()},title:`Open the cell in the Notebook`,children:[(0,_.jsx)(i,{name:`code`,size:13}),s]}):e.kind===`file`?(0,_.jsxs)(`button`,{className:`skills-chip`,onClick:()=>n(e.ref),title:e.ref,children:[(0,_.jsx)(i,{name:`file`,size:13}),s]}):e.kind===`conversation`&&t?(0,_.jsxs)(`button`,{className:`skills-chip`,onClick:()=>r(e.ref),children:[(0,_.jsx)(i,{name:`prompt`,size:13}),e.label||`The conversation`]}):(0,_.jsx)(`span`,{className:`skills-chip quiet`,title:e.kind===`note`?void 0:e.ref,children:e.kind===`note`?`“`+s.trim().replace(/^["“'‘]+|["”'’]+$/g,``)+`”`:s})}function A({client:e,snapshot:t}){let n=t.project.id,r=t.catalog.operations.some(e=>e.method===`kernel.servers`&&e.state===`available`&&e.authorized),[o,c]=(0,g.useState)(null),[l,u]=(0,g.useState)({});(0,g.useEffect)(()=>{if(!r)return;let t=!0;return e.call(`kernel.places`,{projectId:n}).then(async r=>{if(!r.places.some(e=>e.via===`serverctl`)){t&&c({places:r,servers:null});return}let i=await e.call(`kernel.servers`,{projectId:n});t&&c({places:r,servers:i})},()=>{}),()=>{t=!1}},[e,n,r]);let d=(o?.places.places??[]).filter(e=>e.via===`serverctl`).flatMap(e=>(o.servers?.servers.find(t=>t.server===e.destination)?.skills??[]).map(t=>({place:e,skill:t}))),f=d.filter((e,t)=>d.findIndex(t=>t.place.destination===e.place.destination&&t.skill.name===e.skill.name)===t);if(!f.length)return null;let p=(t,r)=>{let i=t+`/`+r;l[i]===void 0&&(u(e=>({...e,[i]:``})),e.call(`kernel.server.skill`,{projectId:n,server:t,name:r}).then(e=>u(t=>({...t,[i]:e.text??``})),e=>u(t=>({...t,[i]:s(e)}))))};return(0,_.jsxs)(`section`,{className:`skills-servers`,"aria-labelledby":`skills-servers-title`,children:[(0,_.jsx)(`h2`,{id:`skills-servers-title`,children:`From your servers`}),(0,_.jsx)(`ul`,{children:f.map(({place:e,skill:t})=>{let n=e.destination+`/`+t.name;return(0,_.jsx)(`li`,{children:(0,_.jsxs)(`details`,{onToggle:n=>{n.currentTarget.open&&p(e.destination,t.name)},children:[(0,_.jsxs)(`summary`,{children:[(0,_.jsx)(i,{name:`server`,size:14}),(0,_.jsxs)(`span`,{children:[(0,_.jsx)(`strong`,{children:t.name}),(0,_.jsxs)(`small`,{children:[e.destination,` · through serverctl`]})]})]}),t.description&&(0,_.jsx)(`p`,{className:`skills-servers-desc`,children:t.description}),l[n]===``?(0,_.jsx)(`p`,{className:`quiet-empty`,role:`status`,children:`Reading…`}):l[n]?(0,_.jsx)(`div`,{className:`skills-servers-text`,children:(0,_.jsx)(a,{text:l[n].replace(/^---[\s\S]*?\n---\n/,``),streaming:!1})}):null]})},n)})})]})}export{b as SkillsPage};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./react-Dss-ouuy.js";import{s as r}from"./home-CCbP6kS-.js";import{r as i}from"./markdown-0ngRuTpW.js";import{Mt as a}from"./index-BpL_Kl_s.js";var o=e(n(),1),s=t(),c={changes:3},l=`browser:local`,u=e=>e instanceof Error?e.message:`It could not be read.`,d=e=>{let t=e.replace(/-/g,` `);return t.charAt(0).toUpperCase()+t.slice(1)},f=e=>`.claude/skills/${e}/SKILL.md`;function p(e){return(0,o.useMemo)(()=>{let t=new Map((e.conversations??[]).filter(e=>e.principal).map(e=>[e.principal,{name:a(e.client),conversationId:e.conversationId}]));return e=>e===l?{name:`You`}:e===`outside`?{name:`Outside Rho`}:t.get(e)??{name:`An Agent`}},[e.conversations])}var m=e=>e.kind===`undone`?`Undid: `+e.reason:e.reason,h=(e,t)=>e.kind===`removed`?`${t} removed the skill`:e.kind===`undone`?`${t} undid a change`:e.kind===`outside`?`Noticed by Rho`:t;function g(e,t,n,r=!0){let[i,a]=(0,o.useState)({list:null,problem:``}),s=()=>e.call(`skills.list`,{projectId:t}).then(e=>a({list:e,problem:``}),e=>a(t=>({...t,problem:u(e)})));return(0,o.useEffect)(()=>{r&&s()},[e,t,n,r]),{...i,again:s}}var _=null,v=e=>{_=e},y=()=>_,b=()=>{_=null};function x({list:e,problem:t,snapshot:n,onOpen:a}){let o=p(n),l=[...e?.skills??[],...e?.removed??[]].filter(e=>e.last).sort((e,t)=>t.last.at.localeCompare(e.last.at));if(!l.length&&!t)return null;let u=e?.skills.length??0;return(0,s.jsxs)(`section`,{className:`project-section skills-work`,"aria-labelledby":`skills-work-title`,children:[(0,s.jsxs)(`div`,{className:`section-heading`,children:[(0,s.jsxs)(`h2`,{id:`skills-work-title`,children:[`Skills`,u>0&&(0,s.jsx)(`span`,{className:`section-count`,children:u})]}),(0,s.jsx)(`button`,{className:`text-button`,onClick:a,children:`View all`})]}),t&&(0,s.jsxs)(`p`,{role:`alert`,children:[`The skills could not be read. `,t]}),(0,s.jsx)(`div`,{className:`activity-list`,children:l.slice(0,c.changes).map(e=>{let t=e.last;return(0,s.jsxs)(`button`,{className:`activity-row`,onClick:()=>{v(e.name),a()},children:[(0,s.jsx)(`span`,{className:`activity-symbol`,children:(0,s.jsx)(i,{name:`book`,size:16})}),(0,s.jsxs)(`span`,{className:`activity-name`,children:[(0,s.jsx)(`strong`,{children:t.kind===`outside`?`Changed outside Rho`:m(t)}),(0,s.jsxs)(`small`,{children:[d(e.name),` · `,t.kind===`outside`?``:h(t,o(t.by).name)+` · `,r(t.at).text]})]}),(0,s.jsx)(i,{name:`chevron`,size:13})]},e.name)})})]})}export{u as a,d as c,h as i,p as l,b as n,m as o,y as r,f as s,x as t,g as u};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./react-Dss-ouuy.js";import{s as r}from"./home-CCbP6kS-.js";import{r as i}from"./markdown-0ngRuTpW.js";import{wt as a}from"./index-CWg9XYXx.js";var o=e(n(),1),s=t(),c={changes:3},l=`browser:local`,u=e=>e instanceof Error?e.message:`It could not be read.`,d=e=>{let t=e.replace(/-/g,` `);return t.charAt(0).toUpperCase()+t.slice(1)},f=e=>`.claude/skills/${e}/SKILL.md`;function p(e){return(0,o.useMemo)(()=>{let t=new Map((e.conversations??[]).filter(e=>e.principal).map(e=>[e.principal,{name:a(e.client),conversationId:e.conversationId}]));return e=>e===l?{name:`You`}:e===`outside`?{name:`Outside Rho`}:t.get(e)??{name:`An Agent`}},[e.conversations])}var m=e=>e.kind===`undone`?`Undid: `+e.reason:e.reason,h=(e,t)=>e.kind===`removed`?`${t} removed the skill`:e.kind===`undone`?`${t} undid a change`:e.kind===`outside`?`Noticed by Rho`:t;function g(e,t,n,r=!0){let[i,a]=(0,o.useState)({list:null,problem:``}),s=()=>e.call(`skills.list`,{projectId:t}).then(e=>a({list:e,problem:``}),e=>a(t=>({...t,problem:u(e)})));return(0,o.useEffect)(()=>{r&&s()},[e,t,n,r]),{...i,again:s}}var _=null,v=e=>{_=e},y=()=>_,b=()=>{_=null};function x({list:e,problem:t,snapshot:n,onOpen:a}){let o=p(n),l=[...e?.skills??[],...e?.removed??[]].filter(e=>e.last).sort((e,t)=>t.last.at.localeCompare(e.last.at));if(!l.length&&!t)return null;let u=e?.skills.length??0;return(0,s.jsxs)(`section`,{className:`project-section skills-work`,"aria-labelledby":`skills-work-title`,children:[(0,s.jsxs)(`div`,{className:`section-heading`,children:[(0,s.jsxs)(`h2`,{id:`skills-work-title`,children:[`Skills`,u>0&&(0,s.jsx)(`span`,{className:`section-count`,children:u})]}),(0,s.jsx)(`button`,{className:`text-button`,onClick:a,children:`View all`})]}),t&&(0,s.jsxs)(`p`,{role:`alert`,children:[`The skills could not be read. `,t]}),(0,s.jsx)(`div`,{className:`activity-list`,children:l.slice(0,c.changes).map(e=>{let t=e.last;return(0,s.jsxs)(`button`,{className:`activity-row`,onClick:()=>{v(e.name),a()},children:[(0,s.jsx)(`span`,{className:`activity-symbol`,children:(0,s.jsx)(i,{name:`book`,size:16})}),(0,s.jsxs)(`span`,{className:`activity-name`,children:[(0,s.jsx)(`strong`,{children:t.kind===`outside`?`Changed outside Rho`:m(t)}),(0,s.jsxs)(`small`,{children:[d(e.name),` · `,t.kind===`outside`?``:h(t,o(t.by).name)+` · `,r(t.at).text]})]}),(0,s.jsx)(i,{name:`chevron`,size:13})]},e.name)})})]})}export{u as a,d as c,h as i,p as l,b as n,m as o,y as r,f as s,x as t,g as u};
@@ -0,0 +1,2 @@
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./react-Dss-ouuy.js";import{r}from"./markdown-0ngRuTpW.js";import{U as i,W as a,v as o,w as s}from"./previews-pWNik-2g.js";import{Bt as c,Dt as l,Ht as u,Mt as d,at as f,it as p,lt as m,mt as h,ot as g,pt as _,rt as v,st as ee}from"./index-CWg9XYXx.js";import{i as y,r as b}from"./console-Dyuo1q4N.js";import{t as x}from"./work-turns-DSabCogR.js";import{n as te,r as S,t as ne}from"./timeline-events-DKTho9fU.js";import{n as C,r as re}from"./notes-meaning-T2m5zQfv.js";import{t as w}from"./answer-board-CeYS8k8y.js";import{Workspace as T}from"./workspace-DfjBL--r.js";var E=e(n(),1),ie=e(u(),1),D={titleChars:90,files:6},O=e=>/^\s*(API Error|Error:|Request failed|Overloaded)/i.test(e),k=e=>e?Date.parse(e):NaN,A=e=>{let t=e.replace(/\s+/g,` `).trim(),n=(/^(.+?[.!?。!?])(\s|$)/.exec(t)?.[1]??t).replace(/[::]$/,``);return n.length>D.titleChars?n.slice(0,D.titleChars-1).trimEnd()+`…`:n},j=e=>{let t=[...new Set(e.map(e=>e.split(`/`).at(-1)))];return t.length>2?t.slice(0,2).join(`, `)+` and `+(t.length-2)+` more`:t.join(` and `)};function M(e){let t=[],n=null,r=!1;for(let i of e)i.kind===`edit`&&(!n||r)&&(n={start:i.at,end:i.at,edits:0,runs:0,looks:0},t.push(n),r=!1),n&&(n.end=i.at,i.kind===`edit`?n.edits++:i.kind===`run`?(n.runs++,r=!0):i.kind===`look`&&n.looks++);return t.length>1?t:[]}function N(e,t,n,r,i={}){let a=n.filter(e=>e.kind===`run`).length,o=n.filter(e=>e.kind===`edit`).length,s=n.filter(e=>e.kind===`look`),c=n.filter(e=>e.kind===`refused`).length,l=o?`build`:a?`explore`:s.length?`look`:`work`,u=r?A(r):l===`look`?s.some(e=>e.path)?`Read `+j(s.flatMap(e=>e.path?[e.path]:[])):`Looked at the project`:l===`explore`?`Explored with `+a+(a===1?` command`:` commands`):l===`build`?`Edited `+j(n.filter(e=>e.kind===`edit`).flatMap(e=>e.path?[e.path]:[])):`Worked`;return{id:e+`:`+t,turn:e,start:n[0]?.at??NaN,end:n.at(-1)?.at??NaN,title:u,said:!!r,kind:l,steps:n.length,runs:a,edits:o,rounds:M(n),files:[...new Set(n.flatMap(e=>e.path?[e.path]:[]))].slice(0,D.files),notes:c?[c+` refused`]:[],running:!1,...i}}function P(e,t,n){let r=[],i=e.steps.reduce((e,t,n)=>t.kind===`tool`?n:e,-1),a={said:null,at:k(e.startedAt??e.sentAt),steps:[],notices:0},o=()=>{if(!a.steps.length&&!a.said)return;let e=a.steps;if(!a.said){let n=e.findIndex((t,n)=>t.kind===`run`&&e[n+1]?.kind===`run`),i=n>0?e.slice(0,n):[];i.some(e=>e.kind===`look`)&&!i.some(e=>e.kind===`edit`)&&(r.push(N(t,r.length,i,null,{kind:`look`,title:`Read `+j(i.filter(e=>e.kind===`look`).flatMap(e=>e.path?[e.path]:[]))})),a.steps=e.slice(n))}if(a.steps.length||a.said){let e=N(t,r.length,a.steps,a.said,a.said?{start:a.at}:{});a.notices&&e.notes.push(a.notices+(a.notices===1?` provider error`:` provider errors`)),r.push(e)}};e.steps.forEach((e,t)=>{let r=k(e.at);if(e.kind===`text`){if(t>i)return;if(O(e.text??``)){a.notices++;return}o(),a={said:e.text??``,at:r,steps:[],notices:0};return}if(e.kind===`error`){a.notices++;return}let s=c(e,null,n),l=s.outcome===`rejected`?`refused`:s.action===`read`||s.action===`search`?`look`:s.action===`edit`||s.action===`write`?`edit`:s.action===`execute`?`run`:`other`,u=s.targetKind===`path`&&s.target?s.target:null;a.steps.push({at:k(e.startedAt??e.at),kind:l,path:u})}),o();let s=e.steps.slice(i+1).filter(e=>e.kind===`text`&&!O(e.text??``));return s.length&&e.state!==`running`&&r.push({...N(t,r.length,[],null),kind:`answer`,title:`Answered`,start:k(s[0].at),end:k(s.at(-1).at)}),e.state===`running`&&r.length&&(r.at(-1).running=!0),r}var F={input:3,code:3,result:6,report:2},I={root:`studio`,left:`studio-left`,input:`studio-input`,code:`studio-code`,commands:`studio-commands`,right:`studio-right`,figures:`studio-figures`,result:`studio-result`,console:`studio-console`,session:`studio-session`},L={supporting:64,method:64,run:64,input:64,report:64},R={code:0,result:1,report:2,input:3};function z(e,t){let n=new Map;for(let r of e.nodes){if(r.kind!==`file`||r.path!==t)continue;let e=r.versions?.length?r.versions:r.resource?[{resource:r.resource,capturedAt:r.capturedAt??r.at}]:[];for(let t of e){let e=t.resource.id+`@`+t.resource.version;n.has(e)||n.set(e,{resource:{id:t.resource.id,version:t.resource.version},at:t.capturedAt})}}return[...n.values()].sort((e,t)=>e.at-t.at)}function ae(e){let t=new Map,n=t=>Math.min(...e.nodes.filter(e=>e.path===t).flatMap(e=>[e.at,...e.events.map(e=>e.at)])),r=(r,i,a)=>{if(!r.path||r.path===`project-notes.md`)return;let o=t.get(r.path);o&&R[o.role]<R[i]||(o&&o.role===i?o.lead||=a:t.set(r.path,{path:r.path,title:r.title,role:i,category:r.category??null,lead:a,first:n(r.path),versions:z(e,r.path)}))};for(let t of[...e.turns].sort((e,t)=>e.start-t.start)){let n=w(e,t.id,L);for(let e of n?.items??[]){let t=e.role===`method`?`code`:e.role===`primary`||e.role===`supporting`?`result`:e.role===`report`?`report`:e.role===`input`?`input`:null;t&&r(e.node,t,e.role===`primary`)}}return[...t.values()].sort((e,t)=>R[e.role]-R[t.role]||(e.role===`input`&&t.role===`input`?Number(t.category===`data`)-Number(e.category===`data`):0)||Number(t.lead)-Number(e.lead)||e.first-t.first||e.path.localeCompare(t.path))}function oe(e,t){return t===null?e:e.filter(e=>e.first<=t).map(e=>({...e,versions:e.versions.filter(e=>e.at<=t)}))}var B=(e,t)=>({id:e,kind:`group`,children:t}),V=(e,t,n)=>({id:e,kind:`group`,children:n.map(e=>e.id),presentation:{mode:`split`,axis:t,weights:n.map(e=>e.weight)}});function se(e,t,n=null){let r=[],i=(e,t)=>t.length?(r.push(B(e,t.map(e=>e.id)),...t),e):null,a=t=>e.filter(e=>e.role===t).slice(0,F[t]),o=(e,t)=>{let n=t.filter(e=>!!e);return n.length<2?n[0]?.id??null:(r.push(V(e,`vertical`,n)),e)},s=i(I.input,a(`input`).map(e=>e.node)),c=i(I.code,a(`code`).map(e=>e.node)),l=i(I.commands,[n,t].filter(e=>!!e)),u=[...a(`result`),...a(`report`)],d=i(I.figures,u.filter(e=>e.figure).map(e=>e.node)),f=i(I.result,u.filter(e=>!e.figure).map(e=>e.node)),p=o(I.left,[s?{id:s,weight:1.4}:null,c?{id:c,weight:1.2}:null,l?{id:l,weight:1.4}:null]),m=o(I.right,[d?{id:d,weight:1.25}:null,f?{id:f,weight:1}:null]);if(p&&m)return r.push(V(I.root,`horizontal`,[{id:p,weight:1},{id:m,weight:1.3}])),{rootId:I.root,nodes:r};let h=p??m;return h?{rootId:h,nodes:r}:null}function ce(e,t,n){let r=structuredClone(e.nodes),i=e.rootId,a=e=>r.find(t=>t.id===e),o=new Map(t.nodes.filter(e=>e.kind===`view`).map(e=>[e.id,e]));for(let e of r){let t=e.kind===`view`?o.get(e.id):void 0;t&&(e.bindings=t.bindings,e.props=t.props)}for(let[e,s]of o){if(a(e)||n(e))continue;let o=t.nodes.find(t=>t.kind===`group`&&t.children?.includes(e)),c=a(o.id);if(!c||c.kind!==`group`||c.presentation?.mode===`split`){c=B(o.id,[]),r.push(c);let e=a(i);if(e.presentation?.mode===`split`&&e.presentation.axis===`horizontal`)e.children=[...e.children,c.id],e.presentation={...e.presentation,weights:[...e.presentation.weights??e.children.slice(1).map(()=>1),1]};else{let e=`studio-wrap`,t=1;for(;a(e);)e=`studio-wrap-`+ ++t;r.push(V(e,`horizontal`,[{id:i,weight:1},{id:c.id,weight:1}])),i=e}}c.children=[...c.children,e],r.push(s)}return{rootId:i,nodes:r}}var H=t(),le={turns:8,readMs:700,stepMs:600,minStepMs:120},ue=e=>/\.(R|r|Rmd|qmd|py|md|markdown|txt|json|sh|sql|js|mjs|ts|ya?ml|toml|tex|log)$/.test(e);function de(e,t,n){let r=x(e,t,n);return{...r,summary:r.sessions[0]}}function fe({turns:e,then:t,root:n,at:r,onAt:i}){let a=(0,E.useMemo)(()=>e.map(e=>({turn:e.turn,title:d(e.turn.text).question.split(`
2
+ `)[0]??``,chapters:P(e.turn,e.turn.id,n)})),[e,n]),o=(0,E.useMemo)(()=>r===null?null:t.flatMap(e=>P(e.turn,e.turn.id,n)).at(-1)??null,[t,n,r]),s=a.flatMap(e=>e.chapters),c=s.filter(e=>r===null||e.start<=r).at(-1),l=(0,E.useRef)(null);if(!c)return null;let u=o??c,f=c.rounds.filter(e=>r===null||e.start<=r).length,p=e=>[e.rounds.length?e.rounds.length+` rounds`:``,e.edits?e.edits+(e.edits===1?` edit`:` edits`):``,e.runs?e.runs+(e.runs===1?` command`:` commands`):``,...e.notes].filter(Boolean).join(` · `);return(0,H.jsxs)(`details`,{ref:l,className:`steps-chip`,onKeyDown:e=>{e.key===`Escape`&&l.current?.open&&(e.preventDefault(),l.current.open=!1)},children:[(0,H.jsxs)(`summary`,{title:u.title,children:[(0,H.jsx)(`span`,{className:`steps-dot`+(u.running&&r===null?` live`:``),"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`steps-title`,children:u.title}),c.rounds.length>0&&(0,H.jsxs)(`span`,{className:`steps-round`,children:[`Round `,Math.max(1,f),` of `,c.rounds.length]}),(0,H.jsxs)(`span`,{className:`steps-count`,children:[s.indexOf(c)+1,`/`,s.length]})]}),(0,H.jsx)(`div`,{className:`steps-pop`,role:`list`,"aria-label":`Parts of this conversation`,children:a.map(e=>(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`p`,{className:`steps-asked`,title:e.turn.text,children:e.title.length>80?e.title.slice(0,79).trimEnd()+`…`:e.title}),e.chapters.map(e=>(0,H.jsxs)(`button`,{role:`listitem`,className:`steps-part `+e.kind+(e===c?` current`:r!==null&&e.start>r?` later`:``),onClick:()=>{i(e===s.at(-1)&&r!==null&&e.kind===`answer`?null:e.start),l.current&&(l.current.open=!1)},children:[(0,H.jsx)(`span`,{className:`steps-time`,children:v(e.start)}),(0,H.jsxs)(`span`,{className:`steps-name`,children:[e.title,e.said&&(0,H.jsx)(`small`,{children:` · in its words`})]}),p(e)&&(0,H.jsx)(`small`,{className:`steps-meta`,children:p(e)})]},e.id))]},e.turn.id))})]})}function pe({steps:e,marks:t,spans:n,at:i,playing:a,speed:o,running:s,onAt:c,onPlay:l,onSpeed:u}){let d=(0,E.useRef)(null),[m,h]=(0,E.useState)(400),[_,y]=(0,E.useState)(null),b=(0,E.useMemo)(()=>[...e.map(e=>({key:e.key,at:e.at,kind:f(e.action),failed:p(e),label:e.label})),...t.map(e=>({key:e.key,at:e.at,kind:f(e.action),failed:e.failed,label:S(e)}))].sort((e,t)=>e.at-t.at),[e,t]);(0,E.useLayoutEffect)(()=>{let e=d.current;if(!e)return;let t=new ResizeObserver(()=>h(e.clientHeight));return t.observe(e),h(e.clientHeight),()=>t.disconnect()},[]);let x=(0,E.useMemo)(()=>{let e=[];for(let t of[...n].sort((e,t)=>e.start-t.start)){let n=e.at(-1);n&&t.start<=n.end+3e4?n.end=Math.max(n.end,t.end):e.push({start:t.start,end:Math.max(t.end,t.start+1e3)})}return e},[n]),te=Math.max(60,m-16-26*Math.max(0,x.length-1)),ne=ee(x,b,te,8,96),C=[],re=8;x.forEach((e,t)=>{C.push(re),re+=ne[t]+26});let w=e=>ne[e],T=e=>{let t=x.findIndex(t=>e<=t.end),n=t<0?x.length-1:t,r=x[n];return r?C[n]+Math.min(w(n),Math.max(0,(e-r.start)/(r.end-r.start)*w(n))):8},ie=e=>{for(let t=x.length-1;t>=0;t--)if(e>=C[t]){let n=x[t];return n.start+Math.min(1,Math.max(0,(e-C[t])/w(t)))*(n.end-n.start)}return x[0]?.start??0},D=e=>b.reduce((t,n)=>!t||Math.abs(T(n.at)-e)<Math.abs(T(t.at)-e)?n:t,null);function O(e){let t=e.currentTarget,n=t.getBoundingClientRect();t.setPointerCapture(e.pointerId),y(null);let r=e=>{let t=e-n.top,r=D(t);c(r&&Math.abs(T(r.at)-t)<8?r.at:ie(t))};r(e.clientY);let i=e=>r(e.clientY),a=()=>{t.removeEventListener(`pointermove`,i),t.removeEventListener(`pointerup`,a),t.removeEventListener(`pointercancel`,a)};t.addEventListener(`pointermove`,i),t.addEventListener(`pointerup`,a),t.addEventListener(`pointercancel`,a)}function k(e){if(e.buttons)return;let t=e.clientY-e.currentTarget.getBoundingClientRect().top,n=D(t);y(n&&Math.abs(T(n.at)-t)<7?{event:n,y:T(n.at)}:null)}let A=i??b.at(-1)?.at??0,j=Math.floor(A/1e3)*1e3,M=()=>[...b].reverse().find(e=>e.at<j)?.at??b[0]?.at,N=()=>b.find(e=>e.at>A)?.at??null;function P(e){let t=e.key===`ArrowDown`?N():e.key===`ArrowUp`?M():e.key===`Home`?b[0]?.at:e.key===`End`?null:void 0;t!==void 0&&(e.preventDefault(),c(t))}let F=i===null?null:T(i),I=x.slice(1).map((e,t)=>({y:C[t+1]-26,length:e.start-x[t].end}));return(0,H.jsxs)(`aside`,{className:`side-timeline`,"aria-label":`Timeline`,children:[(0,H.jsxs)(`div`,{className:`side-tl-controls`,children:[(0,H.jsx)(`button`,{className:`icon-button`,"aria-label":a?`Pause`:i===null?`Play from the start`:`Play from here`,onClick:l,children:(0,H.jsx)(r,{name:a?`pause`:`run`,size:15})}),(0,H.jsxs)(`button`,{className:`side-tl-speed`,"aria-label":`Speed `+o+`×`,onClick:u,children:[o,`×`]}),(0,H.jsxs)(`span`,{className:`side-tl-step`,children:[(0,H.jsx)(`button`,{className:`icon-button`,"aria-label":`Earlier step`,disabled:!b.length||i!==null&&i<(b[0]?.at??0)+1e3,onClick:()=>{let e=M();e!==void 0&&c(e)},children:(0,H.jsx)(`span`,{className:`flip`,children:(0,H.jsx)(r,{name:`chevron`,size:14})})}),(0,H.jsx)(`span`,{className:`side-tl-at`,"aria-live":`polite`,children:i===null?`Now`:v(i,!0)}),(0,H.jsx)(`button`,{className:`icon-button`,"aria-label":`Later step`,disabled:i===null,onClick:()=>c(N()),children:(0,H.jsx)(r,{name:`chevron`,size:14})})]})]}),(0,H.jsxs)(`div`,{ref:d,className:`side-tl-track`,role:`slider`,tabIndex:0,"aria-orientation":`vertical`,"aria-label":`Moment shown`,"aria-valuemin":b[0]?.at??0,"aria-valuemax":b.at(-1)?.at??0,"aria-valuenow":i??b.at(-1)?.at??0,"aria-valuetext":i===null?`Now`:v(i,!0),onPointerDown:O,onPointerMove:k,onPointerLeave:()=>y(null),onKeyDown:P,children:[x.map((e,t)=>(0,H.jsx)(`span`,{className:`side-tl-stretch`,style:{top:C[t],height:w(t)},"aria-hidden":`true`,children:(0,H.jsx)(`small`,{children:v(e.start)})},t)),I.map((e,t)=>(0,H.jsx)(`span`,{className:`side-tl-fold`,style:{top:e.y,height:26},title:`A pause of `+g(e.length),"aria-hidden":`true`,children:(0,H.jsx)(`small`,{children:g(e.length)})},t)),b.map(e=>(0,H.jsx)(`i`,{className:`side-tl-mark `+e.kind+(e.failed?` failed`:``)+(i!==null&&e.at>i?` later`:``),style:{top:T(e.at)},"aria-hidden":`true`},e.key)),F!==null&&(0,H.jsx)(`span`,{className:`side-tl-head`,style:{top:F},"aria-hidden":`true`,children:(0,H.jsx)(`small`,{children:v(i,!0)})}),_&&(0,H.jsxs)(`span`,{className:`side-tl-hover`,style:{top:_.y},children:[_.event.label,` · `,v(_.event.at,!0)]})]}),(0,H.jsx)(`button`,{className:`side-tl-now`+(i===null?` on`:``),disabled:i===null,onClick:()=>c(null),children:i===null&&s?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`pulse-dot`,"aria-hidden":`true`}),`Live`]}):`Now`})]})}function U({client:e,snapshot:t,files:n,conversationId:c,notesText:u=``,at:d,playing:f,speed:p,onAt:g,onPlaying:v,onSpeed:ee,stepsTarget:x,agentNow:S,following:w,workspace:D}){let O=t.project.id,k=o(c),{turns:A,problem:j,loading:M,summary:N}=de(e,t,c),P=(0,E.useMemo)(()=>n.files.map(e=>({path:e.path,bytes:e.bytes,modifiedAt:e.modifiedAt,category:e.category})),[n.files]),F=(0,E.useMemo)(()=>l({turns:A,files:P,project:t.project,kindOf:a,now:Date.now()}),[A,P,t.project]),L=(0,E.useMemo)(()=>m(A,d),[A,d]),R=(0,E.useMemo)(()=>d===null?F:l({turns:L,files:P,project:t.project,kindOf:a,now:d}),[F,L,d]),z=(0,E.useMemo)(()=>ae(F),[F]),B=(0,E.useMemo)(()=>oe(z,d),[z,d]),V=(0,E.useMemo)(()=>F.events.filter(e=>Number.isFinite(e.at)).sort((e,t)=>e.at-t.at),[F]),U=!!N&&N.state===`running`,{marks:me}=ne(e,t,A),he=F.turns.length?Math.min(...F.turns.map(e=>e.start)):null,W=(0,E.useMemo)(()=>he===null?[]:te(me,c,he),[me,c,he]),G=(0,E.useMemo)(()=>[...V.map(e=>e.at),...W.map(e=>e.at)].sort((e,t)=>e-t),[V,W]),[ge,_e]=(0,E.useState)({}),ve=(0,E.useRef)(new Set),[ye,be]=(0,E.useState)({});(0,E.useEffect)(()=>{for(let t of z)ve.current.has(t.path)||(ue(t.path)?(ve.current.add(t.path),e.call(`document.open`,{projectId:O,path:t.path}).then(e=>_e(n=>({...n,[t.path]:e.id})),()=>_e(e=>({...e,[t.path]:null})))):i(t.path)&&!t.versions.length&&d===null&&(ve.current.add(t.path),e.call(`agent.activity.capture`,{projectId:O,path:t.path}).then(e=>be(n=>({...n,[t.path]:{id:e.id,version:e.version}})),()=>be(e=>({...e,[t.path]:null})))))},[z,d,e,O]);let xe=e=>t.catalog.components.find(t=>t.id===e),Se=R.nodes.filter(e=>e.kind===`run`).reduce((e,t)=>Math.min(e,t.at),1/0),Ce=F.nodes.filter(e=>e.kind===`run`).reduce((e,t)=>Math.min(e,t.at),1/0),we=e=>e.flatMap(e=>e.turn.steps??[]).filter(e=>e.kind===`tool`&&e.operation?.startsWith(`kernel.run`)).reduce((e,t)=>Math.min(e,Date.parse(t.startedAt??t.at)),1/0),Te=(0,E.useMemo)(()=>we(L),[L]),Ee=(0,E.useMemo)(()=>we(A),[A]),K=(0,E.useMemo)(()=>{let e=e=>{let t={title:e.title};if(i(e.path)){let n=e.versions.at(-1)?.resource??(d===null?ye[e.path]:null),r=xe(/\.csv$/i.test(e.path)?`rho.table`:`rho.media`);return!n||!r?null:{id:y(e.path),kind:`view`,component:r.id,version:r.version,props:t,bindings:{[Object.keys(r.bindings)[0]??`data`]:{id:n.id,version:n.version}}}}let n=ge[e.path],r=(/\.(md|markdown)$/i.test(e.path)?xe(`markdown.reader`):void 0)??xe(`rho.editor`);return!n||!r?null:{id:y(e.path),kind:`view`,component:r.id,version:r.version,props:t,bindings:{document:{kind:`live-document`,documentId:n}}}};return se(B.flatMap(t=>{let n=e(t);return n?[{role:t.role,node:n,figure:n.component===`rho.media`}]:[]}),Number.isFinite(Se)?{id:I.console,kind:`view`,component:`rho.console`,version:`1`,props:{title:`Commands`},bindings:{}}:null,Number.isFinite(Te)?{id:I.session,kind:`view`,component:`rho.notebook`,version:`1`,props:{title:`Notebook`},bindings:{}}:null)},[B,ge,ye,d,Se,Te,t.catalog]),q=(0,E.useMemo)(()=>{let e=t.compositions.find(e=>e.compositionId===k);if(!e?.rootId||!e.nodes?.length)return K;let n={rootId:e.rootId,nodes:e.nodes};if(d!==null)return n.nodes.some(e=>e.kind===`view`)?ce(n,K??{rootId:``,nodes:[]},()=>!1):K;let r=Date.parse(e.acknowledgedAt??``),i=e=>e===I.console?Ce:e===I.session?Ee:z.find(t=>y(t.path)===e)?.first??1/0;return ce(n,K??{rootId:``,nodes:[]},e=>!Number.isFinite(r)||i(e)<=r)},[K,z,d,Ce,Ee,t.compositions]),J=t.compositions.find(e=>e.compositionId===k),De=JSON.stringify(q)+`:`+(J?.version??0),Oe=(0,E.useMemo)(()=>q?{...J??{},compositionId:k,version:J?.version??0,rootId:q.rootId,nodes:q.nodes,views:q.nodes.filter(e=>e.kind===`view`)}:null,[De]);(0,E.useEffect)(()=>{if(!f)return;let e=d===null?0:G.findIndex(e=>e>d);if(e<0||e>=G.length){v(!1),g(null);return}let t=Math.min(le.stepMs,Math.max(le.minStepMs,12e3/Math.max(1,G.length)))/p,n=setTimeout(()=>g(G[e]),d===null?0:t);return()=>clearTimeout(n)},[f,d,G,p]);let[ke,Y]=(0,E.useState)(null),X=new Set(Oe?.views.map(e=>e.id)??[]),Ae=e=>e&&X.has(y(e))?y(e):void 0,Z=S?.running&&S.conversationId===c&&d===null?S:null,Q=d===null?null:[...V].reverse().find(e=>e.at<=d&&e.action!==`capture`),je=Q&&([...V].reverse().find(e=>e.at<=d&&e.at>=Math.floor(Q.at/1e3)*1e3&&(e.action===`write`||e.action===`edit`))??Q),Me=je?R.nodes.find(e=>e.id===je.node):null,Ne=d===null?null:[...W].reverse().find(e=>e.at<=d)??null,Pe=Ne&&(!Q||Ne.at>=Q.at)?Ne.source.startsWith(`kernel.`)?I.session:I.console:void 0,$=Z?Z.latest?.step.operation?.startsWith(`kernel.`)&&X.has(I.session)?I.session:Z.latest?.action===`execute`?I.console:Ae(Z.files.at(-1)?.path):Pe&&X.has(Pe)?Pe:Me?Me.kind===`run`?I.console:Ae(Me.path):void 0,Fe=(ke&&X.has(ke)?ke:void 0)??(w||d!==null?$:void 0);(0,E.useEffect)(()=>{Y(null)},[d===null,c]);let Ie=Z&&$&&X.has($)?{viewId:$,label:Z.title,verb:$===I.console?`Running`:Z.files.at(-1)?.verb??`Working`,live:Z.latest?.outcome===`requested`}:null,[Le,Re]=(0,E.useState)(``),[ze,Be]=(0,E.useState)(``),Ve=d===null&&t.catalog.operations.some(e=>e.method===`composition.apply`&&e.authorized&&e.state===`available`),He=d===null&&K?K.nodes.filter(e=>e.kind===`view`&&!X.has(e.id)):[];async function Ue(t,n){Re(n),Be(``);try{await e.call(`composition.apply`,{projectId:O,compositionId:k,expectedVersion:J?.version??0,changeId:`studio-`+n+`-`+crypto.randomUUID(),operations:[{op:`replace`,rootId:t.rootId,nodes:t.nodes}]})}catch(e){Be(e instanceof Error?e.message:`The layout could not be written.`)}finally{Re(``)}}let We=(e,t)=>{let n=q&&s(q,e,t,e=>`${e}-${crypto.randomUUID().slice(0,8)}`);n&&(Y(e.id),Ue(n,`reopen`))},Ge=Ve&&K?(0,H.jsxs)(`div`,{className:`studio-empty`,children:[(0,H.jsx)(`span`,{className:`empty-symbol`,children:(0,H.jsx)(r,{name:`layout`,size:26,stroke:1.5})}),(0,H.jsx)(`h2`,{children:`Every view of this work is closed`}),(0,H.jsx)(`p`,{children:`Its files, commands and versions are all kept. Lay them out again by what each is to the work, or choose a moment on the timeline to see the work as it was then.`}),(0,H.jsx)(`button`,{className:`primary`,disabled:!!Le,onClick:()=>void Ue(K,`relayout`),children:Le?`Laying out…`:`Lay out the work again`})]}):void 0,Ke=Ve&&He.length?e=>(0,H.jsx)(`div`,{className:`page-add`,children:(0,H.jsxs)(`section`,{className:`page-add-kind`,"aria-label":`Closed views of this work`,children:[(0,H.jsx)(`h3`,{children:`Closed views of this work`}),He.map(t=>(0,H.jsxs)(`button`,{onClick:()=>We(t,e),children:[(0,H.jsx)(r,{name:t.component===`rho.console`?`prompt`:t.component===`rho.notebook`?`code`:t.component===`rho.media`?`image`:t.component===`rho.table`?`table`:`file`,size:15,stroke:1.7}),(0,H.jsx)(`span`,{children:String(t.props?.title??t.id)})]},t.id))]})}):void 0,qe=(0,E.useMemo)(()=>C(re(u)),[u]),Je=(0,E.useMemo)(()=>_(A),[A]),Ye=(0,E.useMemo)(()=>A.some(e=>e.external)?[...new Set(A.flatMap(e=>e.kernelCells??[]))]:void 0,[A]),Xe=(0,E.useMemo)(()=>({conversationId:c,kernelCells:Ye,graph:R,whole:F,at:d,files:B,every:z,setAt:g,showPath:e=>Y(y(e)),holds:e=>h(e,qe,Je,d)}),[Je,c,Ye,R,F,d,B,z,qe]);return(0,H.jsxs)(b.Provider,{value:Xe,children:[(0,H.jsxs)(`div`,{className:`process-studio`,children:[(0,H.jsxs)(`div`,{className:`process-stage`,children:[j&&(0,H.jsx)(`p`,{className:`inline-error`,role:`alert`,children:j}),ze&&(0,H.jsx)(`p`,{className:`inline-error`,role:`alert`,children:ze}),Oe?(0,H.jsx)(T,{...D,bar:!1,composition:Oe,snapshot:t,client:e,openView:Fe,presence:Ie,arrange:d===null,following:w||d!==null,empty:Ge,addView:Ke},O+k):(0,H.jsxs)(`div`,{className:`studio-empty`,children:[(0,H.jsx)(`span`,{className:`empty-symbol`,children:U?(0,H.jsx)(`span`,{className:`pulse-dot large`,"aria-hidden":`true`}):(0,H.jsx)(r,{name:`layout`,size:26,stroke:1.5})}),(0,H.jsx)(`h2`,{children:j?`Work could not be read`:M?`Reading the conversation…`:U?(N?.agent??`The Agent`)+` is starting`:`Nothing to show yet`}),(0,H.jsx)(`p`,{children:j?`Earlier records are kept. This page will retry.`:U?`The data it reads, the code it writes, the commands it runs and the results they make appear here as it works.`:`This conversation has not read or made any project files.`})]})]}),G.length>0&&(0,H.jsx)(pe,{steps:V,marks:W,spans:[...F.turns,...W.map(e=>({start:e.at,end:e.end}))],at:d,playing:f,speed:p,running:U,onAt:e=>{v(!1),g(e)},onPlay:()=>v(!f),onSpeed:()=>ee(p===4?1:p*2)})]}),x&&(0,ie.createPortal)((0,H.jsx)(fe,{turns:A,then:L,root:t.project.root,at:d,onAt:e=>{v(!1),g(e)}}),x)]})}export{U as ProcessStudio};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{t}from"./react-Dss-ouuy.js";import{wt as n}from"./index-CWg9XYXx.js";var r=e(t(),1),i=`person`,a=`other`;function o(e,t,n){let r=new Map(t.flatMap(e=>e.principal?[[e.principal,e]]:[])),o=new Map;for(let e of t)for(let t of e.eventKeys??[]){let n=o.get(t);o.set(t,n===void 0||n?.conversationId===e.conversationId?e:null)}return e.flatMap(e=>{let t=Date.parse(e.startedAt);if(!Number.isFinite(t))return[];let s=e.endedAt?Date.parse(e.endedAt):NaN,c=Math.max(t,Number.isFinite(s)?s:e.outcome===`running`?n:t),l=e.source+`:`+e.id,u=e.by===`browser:local`?null:o.has(l)?o.get(l):r.get(e.by),d=e.by===`browser:local`?`person`:u?`conversation`:`other`;return[{key:e.source+`:`+e.id,at:t,end:c,lane:d===`person`?i:u?u.conversationId:a,laneTitle:d===`person`?`You`:u?u.title:`Outside Rho`,who:d,...u?{agent:u.agent}:{},source:e.source,action:e.action,label:e.label,where:e.where,outcome:e.outcome,failed:e.outcome===`failed`||e.outcome===`unknown`}]}).sort((e,t)=>e.at-t.at)}var s=(e,t,n)=>e.filter(e=>e.lane===t||e.who===`person`&&e.at>=n);function c(e){return`${e.who===`person`?`You`:e.who===`conversation`?e.agent??`The Agent`:`Someone outside Rho`} ${e.outcome===`running`?e.who===`person`?`are running`:`is running`:`ran`} ${e.label}${e.where?` · `+e.where:``}`}var l={events:200,readMs:1e3};function u(e){return e.catalog.plugins.flatMap(t=>t.timeline&&e.catalog.operations.some(e=>e.method===t.timeline&&e.state===`available`&&e.authorized)?[t.timeline]:[])}function d(e,t,i=[]){let a=u(t),s=a.join(`,`),[c,d]=(0,r.useState)([]),[f,p]=(0,r.useState)(``),m=(0,r.useRef)(0),h=(0,r.useRef)(0),g=(0,r.useRef)(0);(0,r.useEffect)(()=>{if(!a.length){d([]);return}let n=setTimeout(()=>{m.current=Date.now();let n=++h.current;Promise.all(a.map(n=>e.call(n,{projectId:t.project.id,limit:l.events}).then(e=>e.events.map(e=>({...e,source:n}))))).then(e=>{n>g.current&&(g.current=n,d(e.flat()),p(``))},e=>{n>g.current&&p(e instanceof Error?e.message:`What was run could not be read.`)})},Math.max(0,m.current+l.readMs-Date.now()));return()=>clearTimeout(n)},[e,t.project.id,t.cursor,s]);let _=(0,r.useMemo)(()=>[...(t.conversations??[]).map(e=>({conversationId:e.conversationId,principal:e.principal,title:e.agentTitle||e.title,agent:n(e.client)})),...i.filter(e=>e.external).map(e=>({conversationId:e.conversationId,principal:null,title:e.conversationTitle,agent:e.agent,eventKeys:(e.kernelCells??[]).map(e=>`kernel.events:`+e)}))],[t.conversations,i]);return{marks:(0,r.useMemo)(()=>o(c,_,Date.now()),[c,_]),problem:f}}export{s as n,c as r,d as t};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{t}from"./react-Dss-ouuy.js";import{Et as n,Tt as r,_t as i}from"./index-CWg9XYXx.js";var a=e(t(),1),o={conversations:6,turns:8};function s(e,t,s){let c=i(e,t.catalog.operations.some(e=>e.method===`agent.sessions.list`&&e.authorized)?t.project.id:null),l=(0,a.useMemo)(()=>n(t.conversations??[],c.sessions),[t.conversations,c.sessions]),u=(0,a.useMemo)(()=>s?l.filter(e=>e.id===s):l.slice(0,o.conversations),[l,s]),[d,f]=(0,a.useState)({}),[p,m]=(0,a.useState)(``),h=t.project,g=(0,a.useRef)(d),_=(0,a.useRef)({list:u,project:h});_.current={list:u,project:h};let v=e=>d[e.id]?.project===h.id?d[e.id]:void 0;(0,a.useEffect)(()=>{let t=!0,n=!1;m(``);let i=async()=>{if(!t||n)return;let{list:i,project:a}=_.current,s=i.filter(e=>g.current[e.id]?.project!==a.id||g.current[e.id]?.version!==e.version);if(!s.length)return;n=!0;let c=await Promise.allSettled(s.map(async t=>{if(t.external){let n=await e.call(`agent.sessions.read`,{projectId:a.id,session:t.id,limit:o.turns});return{s:t,turns:r(n,a),omitted:n.first+n.session.omittedTurns}}let n=await e.call(`conversation.read`,{projectId:a.id,conversationId:t.id,limit:o.turns});return{s:t,turns:n.turns.map(e=>({conversationId:t.id,conversationTitle:t.title,agent:t.agent,turn:e,observation:n.observation})),omitted:n.first}}));if(n=!1,!t)return;m(c.some(e=>e.status===`rejected`)?`Some session records could not be read. Earlier observations are kept; retrying.`:``);let l={...g.current};for(let e of c)if(e.status===`fulfilled`){let{s:t,turns:n,omitted:r}=e.value;l[t.id]={project:a.id,version:t.version,turns:n,omitted:r}}g.current=l,f(l)};i();let a=setInterval(()=>{document.hidden||i()},700);return()=>{t=!1,clearInterval(a)}},[e,h.id,s]);let y=(0,a.useMemo)(()=>u.flatMap(e=>v(e)?.turns??[]),[u,d,h.id]),b=u.reduce((e,t)=>e+(v(t)?.omitted??0),0)+(s?0:Math.max(0,l.length-u.length)+c.omitted);return{turns:y,sessions:u,problem:p||c.problem,loading:u.length>0&&!u.some(v),omitted:b}}export{s as t};