@rho-workspace/rho 0.5.5 → 0.5.6

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 (106) hide show
  1. package/dist/agent-connect.d.ts +8 -0
  2. package/dist/agent-connect.js +15 -0
  3. package/dist/browser-access.js +1 -1
  4. package/dist/cli.js +38 -8
  5. package/dist/contract.generated.d.ts +148 -5
  6. package/dist/contract.generated.js +1 -1
  7. package/dist/contracts/owners.generated.js +107 -12
  8. package/dist/conversations.d.ts +157 -4
  9. package/dist/conversations.js +69 -6
  10. package/dist/discovery.js +1 -1
  11. package/dist/protocol.d.ts +1 -0
  12. package/dist/protocol.js +12 -5
  13. package/dist/server.d.ts +2 -10
  14. package/dist/server.js +71 -8
  15. package/dist/web/.vite/manifest.json +61 -61
  16. package/dist/web/assets/{choices-b0XhrGQV.js → choices-D-YfnFP6.js} +1 -1
  17. package/dist/web/assets/{console-BSjLGe0T.js → console-Trqc0swD.js} +1 -1
  18. package/dist/web/assets/{dist-Buk0lwzI.js → dist-DZmszrjG.js} +1 -1
  19. package/dist/web/assets/{dist-Cw8hRIlT.js → dist-DpIHRk3B.js} +1 -1
  20. package/dist/web/assets/{dist-foH9IKc6.js → dist-eMx6b8N1.js} +1 -1
  21. package/dist/web/assets/{dist-Tzoe_zm-.js → dist-pF902jHA.js} +1 -1
  22. package/dist/web/assets/{explore-in-BVUy3ZW_.js → explore-in-BCHqjJ7B.js} +1 -1
  23. package/dist/web/assets/{graph-1OdIJ9l7.js → graph-lENgfQNH.js} +1 -1
  24. package/dist/web/assets/index-B3_OVy91.css +1 -0
  25. package/dist/web/assets/{index-CxmItXqa.js → index-BpL_Kl_s.js} +84 -83
  26. package/dist/web/assets/{notes-meaning-pVbbQUGP.js → notes-meaning-DcVGUBBY.js} +1 -1
  27. package/dist/web/assets/{overview-B9UtVJ32.js → overview-CDnVKlOt.js} +3 -3
  28. package/dist/web/assets/{preview-CksD_5KS.js → preview-BEC1E9MK.js} +1 -1
  29. package/dist/web/assets/{review-CMxQlQ-C.js → review-DYP0aCXb.js} +1 -1
  30. package/dist/web/assets/{skills-BFNSyrnD.js → skills-1ec0Z-jx.js} +1 -1
  31. package/dist/web/assets/{skills-work-BGPSnF_I.js → skills-work-DNexV4OJ.js} +1 -1
  32. package/dist/web/assets/{studio-process-CsRoTHOh.js → studio-process-EYQgikxq.js} +1 -1
  33. package/dist/web/assets/{timeline-events-BbuuFWHV.js → timeline-events-Chj2Gbx7.js} +1 -1
  34. package/dist/web/assets/{work-turns-BvJlIMmA.js → work-turns-CT9RVcWY.js} +1 -1
  35. package/dist/web/assets/{workspace-CWlkjLNx.js → workspace-COmCbGV3.js} +1 -1
  36. package/dist/web/composition.json +58 -58
  37. package/dist/web/index.html +2 -2
  38. package/dist/web/renderer.json +1 -1
  39. package/docs/FRONTEND.md +26 -18
  40. package/docs/HEADLESS.md +37 -27
  41. package/node_modules/@rho-workspace/plugin-agent/README.md +29 -0
  42. package/node_modules/@rho-workspace/plugin-agent/dist/acp-command.d.ts +1 -0
  43. package/node_modules/@rho-workspace/plugin-agent/dist/acp-command.js +9 -1
  44. package/node_modules/@rho-workspace/plugin-agent/dist/acp-conversation.d.ts +1 -0
  45. package/node_modules/@rho-workspace/plugin-agent/dist/acp-conversation.js +10 -0
  46. package/node_modules/@rho-workspace/plugin-agent/dist/external-session-contract.js +10 -5
  47. package/node_modules/@rho-workspace/plugin-agent/dist/external-session.d.ts +12 -1
  48. package/node_modules/@rho-workspace/plugin-agent/dist/native-sessions.d.ts +70 -0
  49. package/node_modules/@rho-workspace/plugin-agent/dist/native-sessions.js +538 -0
  50. package/node_modules/@rho-workspace/plugin-agent/package.json +2 -1
  51. package/node_modules/hono/dist/adapter/aws-lambda/handler.js +1 -1
  52. package/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +1 -1
  53. package/node_modules/hono/dist/cjs/adapter/bun/serve-static.js +1 -1
  54. package/node_modules/hono/dist/cjs/adapter/bun/websocket.js +1 -1
  55. package/node_modules/hono/dist/cjs/client/fetch-result-please.js +1 -1
  56. package/node_modules/hono/dist/cjs/helper/accepts/accepts.js +2 -1
  57. package/node_modules/hono/dist/cjs/helper/ssg/ssg.js +5 -3
  58. package/node_modules/hono/dist/cjs/jsx/base.js +49 -30
  59. package/node_modules/hono/dist/cjs/jsx/components.js +2 -2
  60. package/node_modules/hono/dist/cjs/jsx/constants.js +2 -0
  61. package/node_modules/hono/dist/cjs/jsx/jsx-runtime.js +13 -17
  62. package/node_modules/hono/dist/cjs/middleware/etag/index.js +3 -1
  63. package/node_modules/hono/dist/cjs/middleware/pretty-json/index.js +1 -0
  64. package/node_modules/hono/dist/cjs/middleware/timing/timing.js +4 -3
  65. package/node_modules/hono/dist/cjs/utils/cookie.js +2 -2
  66. package/node_modules/hono/dist/cjs/utils/mime.js +1 -1
  67. package/node_modules/hono/dist/cjs/utils/url.js +1 -1
  68. package/node_modules/hono/dist/client/fetch-result-please.js +1 -1
  69. package/node_modules/hono/dist/helper/accepts/accepts.js +2 -1
  70. package/node_modules/hono/dist/helper/ssg/ssg.js +5 -3
  71. package/node_modules/hono/dist/jsx/base.js +49 -32
  72. package/node_modules/hono/dist/jsx/components.js +2 -2
  73. package/node_modules/hono/dist/jsx/constants.js +2 -1
  74. package/node_modules/hono/dist/jsx/jsx-runtime.js +15 -19
  75. package/node_modules/hono/dist/middleware/etag/index.js +3 -1
  76. package/node_modules/hono/dist/middleware/language/language.js +1 -1
  77. package/node_modules/hono/dist/middleware/pretty-json/index.js +1 -0
  78. package/node_modules/hono/dist/middleware/timing/timing.js +4 -3
  79. package/node_modules/hono/dist/utils/cookie.js +2 -2
  80. package/node_modules/hono/dist/utils/mime.js +1 -1
  81. package/node_modules/hono/dist/utils/url.js +1 -1
  82. package/node_modules/hono/package.json +1 -1
  83. package/package.json +2 -2
  84. package/protocol/index.json +39 -33
  85. package/protocol/operations/agent.sessions.list.json +49 -3
  86. package/protocol/operations/agent.sessions.read.json +53 -4
  87. package/protocol/operations/conversation.configure.json +29 -0
  88. package/protocol/operations/conversation.decide.json +29 -0
  89. package/protocol/operations/conversation.list.json +29 -0
  90. package/protocol/operations/conversation.permission.json +29 -0
  91. package/protocol/operations/conversation.read.json +29 -0
  92. package/protocol/operations/conversation.restore.json +29 -0
  93. package/protocol/operations/conversation.send.json +29 -0
  94. package/protocol/operations/conversation.settings.check.json +92 -0
  95. package/protocol/operations/conversation.settings.read.json +92 -0
  96. package/protocol/operations/conversation.settings.update.json +92 -0
  97. package/protocol/operations/conversation.start.json +46 -1
  98. package/protocol/operations/conversation.stop.json +29 -0
  99. package/protocol/operations/conversation.trash.json +29 -0
  100. package/protocol/operations/observation.snapshot.json +29 -0
  101. package/protocol/operations/session.instructions.json +43 -0
  102. package/vendor/composition.json +74 -74
  103. package/vendor/rho-workspace-plugin-agent-0.4.30.tgz +0 -0
  104. package/web/theme.css +12 -0
  105. package/dist/web/assets/index-CsC3sTRq.css +0 -1
  106. package/vendor/rho-workspace-plugin-agent-0.4.29.tgz +0 -0
@@ -1,4 +1,4 @@
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{A as i,C as a,D as o,E as s,O as c,S as l,T as u,_ as d,b as f,d as p,g as m,h,k as g,m as _,v,w as y,x as b,y as x}from"./canvas-D8rDdfDz.js";import{$ as S,Jt as C,Q as ee,Z as w,a as te,c as ne,d as T,et as re,f as E,h as ie,i as ae,l as oe,m as se,n as ce,nt as le,o as ue,p as de,r as fe,rt as D,s as pe,t as me,u as he,ut as ge,v as _e}from"./index-CxmItXqa.js";import{a as ve,i as ye,t as be}from"./console-BSjLGe0T.js";import{a as xe,c as Se,i as Ce,l as we,n as Te,o as Ee,r as De,s as Oe,t as ke}from"./facts-BMO6V3-3.js";import{t as Ae}from"./snapshot-CAxBYPvV.js";import{t as je}from"./explore-in-BVUy3ZW_.js";var O=e(n(),1),Me=e(C(),1);function k(e){return e.at??e.after??null}var Ne=e=>e===null?null:Date.parse(e);function Pe(e=`following`){return{step:-1,time:null,attention:e,question:null,objects:{},order:[],views:[],active:null,agent:null,suggestions:[],escalations:[],digest:null,items:[],hidden:{catalog:0,rejected:0,retries:0},revealed:null,expanded:[],moves:[],lastMove:null,pending:null,away:null}}function Fe(e,t,n,r){e.presentationClock=r,We(e,t,{...n,seq:e.step+1})}function Ie(e,t,n){Xe(e,t,{...n,at:e.step})}function Le(e,t){let n=e.time;e.presentationClock=t,e.time=new Date(t).toISOString(),F(e),e.time=n}function Re(e){for(let t of e.views)t.newer=et(e,t);let{lastMove:t,pending:n,away:r,presentationClock:i,...a}=e;return structuredClone(a)}function ze(e,t){return e.objects[t.id]||(e.objects[t.id]=t,e.order.push(t.id)),e.objects[t.id]}var Be=(e,t,n)=>ze(e,{id:`source:`+t,kind:`source`,name:t,version:1,savedVersion:null,changedAt:n,touchedAt:n,hidden:0}),Ve=(e,t,n)=>ze(e,{id:`artifact:`+t,kind:`artifact`,name:t,versions:[],changedAt:n,touchedAt:n,hidden:0}),He=(e,t)=>e.views.find(e=>e.id===t),Ue=e=>e.openedBy===`person`||e.pinned,A=(e,t)=>He(e,t)??e.views.find(e=>e.object===t&&Ue(e))??e.views.find(e=>e.object===t),j=(e,t,n)=>{let r=He(e,e.active);return!!r&&r.object===t&&(n===null||r.run===n)};function M(e,t,n){let r=t;for(;He(e,r);)r+=`@`+n;return r}var N=(e,t,n,r,i)=>({id:M(e,t,n),object:t,run:n,openedBy:r,pinned:!1,preview:i,selection:[],newer:null});function We(e,t,n){e.step=n.seq,e.time=k(n)??e.time;let r=n.object?e.objects[n.object]:void 0;if(r&&(r.touchedAt=n.seq),n.outcome===`rejected`)return r?r.hidden++:e.hidden.rejected++,F(e);let i=n.effect;if(!i)return F(e);let a=t.principals[n.actor]?.kind===`agent`,o=(t,r)=>a?P(e,n,t,r):F(e);switch(i.kind){case`catalog`:return e.hidden.catalog++,F(e);case`open`:{if(i.source===null)return F(e);let t=!!e.objects[`source:`+i.source],r=Be(e,i.source,n.seq);return r.version=i.version,t||(r.savedVersion=i.version),o(r.id,null)}case`edit`:{let t=Be(e,i.source,n.seq);return t.version=i.version,t.changedAt=n.seq,o(t.id,null)}case`save`:{let t=Be(e,i.source,n.seq);return t.savedVersion=i.version,t.changedAt=n.seq,o(t.id,null)}case`source-state`:{let t=Be(e,i.source,n.seq);return t.version=i.version,t.savedVersion=i.savedVersion,t.changedAt=n.seq,F(e)}case`submit`:if(i.sourceVersion!==null&&!e.objects[`source:`+i.source]){let t=Be(e,i.source,n.seq);t.version=t.savedVersion=i.sourceVersion}return ze(e,{id:`run:`+i.run,kind:`run`,name:`Run `+i.run,run:i.run,source:i.source,sourceVersion:i.sourceVersion,state:i.state??`running`,exit:null,firstLine:null,verified:[],changedAt:n.seq,touchedAt:n.seq,hidden:0}),o(`run:`+i.run,null);case`retry`:{let t=e.objects[`run:`+i.run];return t&&t.hidden++,e.hidden.retries++,F(e)}case`run-state`:case`ended`:{let t=e.objects[`run:`+i.run];return t?(i.kind===`ended`?(t.exit=i.exit,t.state=i.state??(i.exit===0?`completed`:i.exit===null?`unknown`:`failed`)):t.state=i.state,t.changedAt=n.seq,(t.state===`failed`||t.state===`unknown`)&&Ye(e,t,n.seq),t.state===`completed`&&(e.escalations=e.escalations.filter(n=>{let r=e.objects[n.object];return!(r?.kind===`run`&&r.source===t.source&&r.run<t.run)})),o(t.id,null)):F(e)}case`observe`:return o(`run:`+i.run,null);case`output`:{let n=e.objects[`run:`+i.run],r=i.stream?t.runs[i.run]?.outputs[i.stream]??``:``;(i.stream===`stderr`||i.stream&&!n.firstLine)&&(n.firstLine=tt(r));let a=e.escalations.find(e=>e.object===n.id);return a&&n.firstLine&&(a.reason=n.firstLine),o(n.id,null)}case`verified`:{let r=e.objects[`run:`+i.run],a=t.runs[i.run]?.verified??[];if(!r)return F(e);r.verified=[...i.artifacts],r.changedAt=n.seq;for(let t of i.artifacts){let r=Ve(e,t,n.seq),o=a.find(e=>e.name===t)?.digest??`unknown`,s=r.versions.find(e=>e.digest===o);s?s.runs.includes(i.run)||s.runs.push(i.run):(r.versions.push({digest:o,runs:[i.run]}),r.changedAt=n.seq)}return o(r.id,null)}case`registered`:{let t=Ve(e,i.artifact,n.seq);t.name=i.name;let r=t.versions.find(e=>e.digest===i.version);return r?i.run!==null&&!r.runs.includes(i.run)&&r.runs.push(i.run):(t.versions.push({digest:i.version,runs:i.run===null?[]:[i.run]}),t.changedAt=n.seq),F(e)}case`read`:{if(i.artifact===null)return F(e);let t=Ve(e,i.artifact,n.seq);return t.touchedAt=n.seq,o(t.id,i.run)}case`layout`:return a?qe(e,n,i.views,i.replace):F(e);case`items`:return i.question!==null&&(e.question=i.question),i.items&&(e.items=i.items),F(e);case`ask`:return ze(e,{id:i.question,kind:`question`,name:i.text,author:n.actor,target:i.target,version:i.version,run:i.run,rows:[...i.rows],document:i.document,state:`prepared`,fetchedBy:null,fetchedAt:null,changedAt:n.seq,touchedAt:n.seq,hidden:0}),F(e);case`fetched`:{let t=e.objects[i.question];return t?.kind===`question`&&(t.state!==`responded`&&(t.state=`fetched`),t.fetchedBy=n.actor,t.fetchedAt=n.seq,t.changedAt=n.seq),F(e)}case`responded`:{let t=e.objects[i.question];return t?.kind===`question`&&(t.state=`responded`,t.changedAt=n.seq),F(e)}}}function P(e,t,n,r){e.attention===`following`?j(e,n,r)?(e.agent={object:n,run:r,seq:t.seq,placement:`main`},e.pending=null):I(e,t)?(e.pending={kind:`focus`,object:n,run:r},e.agent={object:n,run:r,seq:t.seq,placement:`pending`}):(e.pending=null,Ke(e,n,r,`agent`),e.agent={object:n,run:r,seq:t.seq,placement:`main`},Ge(e,t,`agent`,`agent-focus`)):e.agent={object:n,run:r,seq:t.seq,placement:`marker`}}function F(e){if(!e.pending||e.attention!==`following`)return;let t={seq:e.step,at:e.time};if(I(e,t))return;let n=e.pending;e.pending=null,n.kind===`focus`?(Ke(e,n.object,n.run,`agent`),e.agent&&(e.agent.placement=`main`),Ge(e,t,`agent`,`agent-focus`)):Je(e,t,n.views,n.replace)}function I(e,t){let n=e.presentationClock??Ne(k(t))??Ne(e.time);return e.lastMove!==null&&n!==null&&n-e.lastMove<8e3}function Ge(e,t,n,r){n===`agent`&&(e.lastMove=e.presentationClock??Ne(k(t))??Ne(e.time)??e.lastMove),e.moves.push({seq:t.seq,by:n,view:e.active,rule:r})}function Ke(e,t,n,r,i){let a=e.views.filter(e=>e.object===t),o=r===`person`?A(e,t):a.find(e=>(n===null||e.run===n)&&(!i||e.version===i))??a.find(e=>!Ue(e));if(o&&r===`agent`&&n!==null&&(o.run=n),!o){o=N(e,t,n,r,r===`agent`);let i=r===`agent`?e.views.findIndex(e=>e.preview):-1;i>=0?e.views[i]=o:e.views.push(o)}r===`person`&&(o.preview=!1,o.openedBy=`person`),i&&(o.version=i),e.active=o.id}function qe(e,t,n,r){let i=e.views.some(t=>t.pinned&&t.id===e.active);if(e.attention===`following`&&!i){if(I(e,t)){e.pending={kind:`layout`,views:n,replace:r};return}return Je(e,t,n,r)}let a=e.attention===`away`?`away`:i?`pinned`:`working`,o=e.suggestions.find(e=>e.id.startsWith(`layout`));o?(o.views=n,o.merged++,o.cause=a):e.suggestions.push({id:`layout:`+t.seq,views:n,cause:a,from:t.seq,merged:0})}function Je(e,t,n,r,i=`agent`){r&&(e.views=e.views.filter(Ue));let a=null;for(let t of n){let n=t.object??`artifact:`+t.artifact,r=e.views.filter(e=>e.object===n),o=r.find(e=>e.run===t.run&&(!t.version||e.version===t.version))??r.find(e=>!Ue(e));o?(o.run=t.run,o.preview=!1):e.views.push(o=N(e,n,t.run,i,!1)),t.version&&(o.version=t.version),a??=o.id}e.active=a??e.active,Ge(e,t,i===`agent`?`agent`:`person`,i===`agent`?`agent-layout`:`accept`)}function Ye(e,t,n){if(e.attention!==`working`||Object.values(e.objects).some(e=>e.kind===`run`&&e.source===t.source&&e.run>t.run&&e.state===`completed`))return;let r=e.objects[He(e,e.active)?.object??``];r&&(r.id===t.id||r.id===`source:`+t.source||r.kind===`run`&&r.source===t.source||r.kind===`artifact`&&r.versions.some(n=>n.runs.some(n=>e.objects[`run:`+n]?.source===t.source)))&&!e.escalations.some(e=>e.object===t.id)&&e.escalations.push({object:t.id,reason:t.state===`unknown`?`Outcome unknown`:t.exit===null?`Execution failed`:`Exit `+t.exit,from:n})}function Xe(e,t,n){let r={seq:Math.max(n.at,-1),at:e.time},i=()=>{e.attention===`following`&&(e.attention=`working`)};switch(n.kind){case`follow`:e.attention=`following`,e.agent&&!j(e,e.agent.object,e.agent.run)&&(Ke(e,e.agent.object,e.agent.run,`agent`),e.moves.push({seq:r.seq,by:`person`,view:e.active,rule:`catch-up`})),e.agent&&(e.agent.placement=`main`),e.pending=null;return;case`unfollow`:e.attention=`working`;return;case`open`:{if(i(),n.version!==void 0||n.run!==void 0){let t=e.views.find(e=>e.object===n.target&&e.run===(n.run??null)&&(!n.version||e.version===n.version));t||(t=N(e,n.target,n.run??null,`person`,!1),e.views.push(t)),n.version&&(t.version=n.version),t.openedBy=`person`,t.preview=!1,e.active=t.id,e.escalations=e.escalations.filter(e=>e.object!==n.target),e.moves.push({seq:r.seq,by:`person`,view:e.active,rule:`person`});return}let t=e.objects[n.target],a=e.items.find(e=>`item:`+e.id===n.target),o=t?.kind===`question`?{object:t.target,version:t.version,run:t.run}:a?.artifact;if(o){let t=e.views.find(t=>t.object===o.object&&(t.version??Qe(e,o.object,t.run))===o.version);if(t)t.preview=!1,t.openedBy=`person`,e.active=t.id;else{let t=N(e,o.object,o.run,`person`,!1);t.version=o.version,e.views.push(t),e.active=t.id}e.moves.push({seq:r.seq,by:`person`,view:e.active,rule:`person`});return}let s=A(e,n.target),c=s?.object??n.target;s?(s.preview=!1,s.openedBy=`person`,e.active=s.id):Ke(e,c,c.startsWith(`artifact:`)?$e(e,c):null,`person`),e.escalations=e.escalations.filter(e=>e.object!==c),e.moves.push({seq:r.seq,by:`person`,view:e.active,rule:`person`});return}case`select`:{i();let t=A(e,n.target);t&&(t.selection=[...n.rows],t.preview=!1,t.openedBy=`person`);return}case`type`:i();return;case`close`:{let t=A(e,n.target);e.views=e.views.filter(e=>e!==t),t&&e.active===t.id&&(e.active=e.views.at(-1)?.id??null);return}case`pin`:case`unpin`:{let t=A(e,n.target);t&&(t.pinned=n.kind===`pin`,t.preview=!1,t.openedBy=`person`);return}case`update`:{i();let t=A(e,n.target),a=t?et(e,t):null;if(!t||a===null)return;t.run=a,t.version&&=Qe(e,t.object,a)??void 0,e.views=e.views.filter(e=>e===t||e.pinned||e.object!==t.object||e.run!==a),e.active=t.id,e.moves.push({seq:r.seq,by:`person`,view:e.active,rule:`person`});return}case`leave`:if(e.attention===`away`)return;e.pending=null,e.away={from:e.step,prior:e.attention,baseline:structuredClone(e.objects),suggestions:e.suggestions.map(e=>e.id),items:JSON.stringify(e.items)},e.attention=`away`;return;case`return`:{if(!e.away)return;let t=Ze(e,e.away);e.digest=t.length?{from:e.away.from,to:e.step,lines:t}:null,e.attention=e.away.prior,e.away=null;return}case`accept`:{let t=e.suggestions.find(e=>e.id===n.suggestion);if(!t)return;e.suggestions=e.suggestions.filter(e=>e!==t),Je(e,r,t.views,!1,`person`);return}case`ask`:{i();let t=A(e,n.target),a=t?Qe(e,t.object,t.run):null;if(!t||a===null||t.run===null)return;ze(e,{id:`question:asked-`+(e.order.filter(e=>e.startsWith(`question:asked-`)).length+1),kind:`question`,name:n.text,author:null,target:t.object,version:a,run:t.run,rows:[...n.rows],document:null,state:`prepared`,fetchedBy:null,fetchedAt:null,changedAt:r.seq,touchedAt:r.seq,hidden:0});return}case`dismiss`:e.suggestions=e.suggestions.filter(e=>e.id!==n.suggestion);return;case`dismiss-digest`:e.digest=null;return;case`reveal`:e.revealed=n.target;return;case`expand`:e.expanded.includes(n.target)||e.expanded.push(n.target);return;case`collapse`:e.expanded=e.expanded.filter(e=>e!==n.target);return}}function Ze(e,t){let n=[],r={source:0,run:1,artifact:2,question:3};for(let i of[...e.order].sort((t,n)=>r[e.objects[t].kind]-r[e.objects[n].kind])){let r=e.objects[i],a=t.baseline[i];if(r.kind===`source`&&(!a||a.version!==r.version)&&n.push({kind:`source`,object:i,from:a?a.version:null,to:r.version}),r.kind===`run`&&(!a||a.state!==r.state||a.verified.length!==r.verified.length)){let t={kind:`run`,object:i,state:r.state,firstLine:r.state===`completed`?null:r.firstLine,verified:r.verified.length,earlier:[]},a=n.findIndex(t=>t.kind===`run`&&e.objects[t.object].source===r.source);if(a<0)n.push(t);else{let e=n[a];t.earlier=[...e.earlier,e.object],n[a]=t}}r.kind===`artifact`&&r.versions.length!==(a?.versions.length??0)&&n.push({kind:`artifact`,object:i,versions:r.versions.length-(a?.versions.length??0)}),r.kind===`question`&&(!a||a.state!==r.state)&&n.push({kind:`question`,object:i,state:r.state})}for(let r of e.suggestions)t.suggestions.includes(r.id)||n.push({kind:`suggestion`,id:r.id});return JSON.stringify(e.items)!==t.items&&n.push({kind:`items`,count:e.items.length}),n}var Qe=(e,t,n)=>{let r=e.objects[t];return r?.kind===`artifact`&&n!==null?r.versions.find(e=>e.runs.includes(n))?.digest??null:null},$e=(e,t)=>e.objects[t]?.versions.at(-1)?.runs.at(-1)??null;function et(e,t){let n=e.objects[t.object];if(n?.kind!==`artifact`||t.run===null||!Ue(t))return null;let r=n.versions.findIndex(e=>e.runs.includes(t.run));return r>=0&&r<n.versions.length-1?$e(e,t.object):null}function tt(e){return e.split(`
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{A as i,C as a,D as o,E as s,O as c,S as l,T as u,_ as d,b as f,d as p,g as m,h,k as g,m as _,v,w as y,x as b,y as x}from"./canvas-D8rDdfDz.js";import{$ as S,Jt as C,Q as ee,Z as w,a as te,c as ne,d as T,et as re,f as E,h as ie,i as ae,l as oe,m as se,n as ce,nt as le,o as ue,p as de,r as fe,rt as D,s as pe,t as me,u as he,ut as ge,v as _e}from"./index-BpL_Kl_s.js";import{a as ve,i as ye,t as be}from"./console-Trqc0swD.js";import{a as xe,c as Se,i as Ce,l as we,n as Te,o as Ee,r as De,s as Oe,t as ke}from"./facts-BMO6V3-3.js";import{t as Ae}from"./snapshot-CAxBYPvV.js";import{t as je}from"./explore-in-BCHqjJ7B.js";var O=e(n(),1),Me=e(C(),1);function k(e){return e.at??e.after??null}var Ne=e=>e===null?null:Date.parse(e);function Pe(e=`following`){return{step:-1,time:null,attention:e,question:null,objects:{},order:[],views:[],active:null,agent:null,suggestions:[],escalations:[],digest:null,items:[],hidden:{catalog:0,rejected:0,retries:0},revealed:null,expanded:[],moves:[],lastMove:null,pending:null,away:null}}function Fe(e,t,n,r){e.presentationClock=r,We(e,t,{...n,seq:e.step+1})}function Ie(e,t,n){Xe(e,t,{...n,at:e.step})}function Le(e,t){let n=e.time;e.presentationClock=t,e.time=new Date(t).toISOString(),F(e),e.time=n}function Re(e){for(let t of e.views)t.newer=et(e,t);let{lastMove:t,pending:n,away:r,presentationClock:i,...a}=e;return structuredClone(a)}function ze(e,t){return e.objects[t.id]||(e.objects[t.id]=t,e.order.push(t.id)),e.objects[t.id]}var Be=(e,t,n)=>ze(e,{id:`source:`+t,kind:`source`,name:t,version:1,savedVersion:null,changedAt:n,touchedAt:n,hidden:0}),Ve=(e,t,n)=>ze(e,{id:`artifact:`+t,kind:`artifact`,name:t,versions:[],changedAt:n,touchedAt:n,hidden:0}),He=(e,t)=>e.views.find(e=>e.id===t),Ue=e=>e.openedBy===`person`||e.pinned,A=(e,t)=>He(e,t)??e.views.find(e=>e.object===t&&Ue(e))??e.views.find(e=>e.object===t),j=(e,t,n)=>{let r=He(e,e.active);return!!r&&r.object===t&&(n===null||r.run===n)};function M(e,t,n){let r=t;for(;He(e,r);)r+=`@`+n;return r}var N=(e,t,n,r,i)=>({id:M(e,t,n),object:t,run:n,openedBy:r,pinned:!1,preview:i,selection:[],newer:null});function We(e,t,n){e.step=n.seq,e.time=k(n)??e.time;let r=n.object?e.objects[n.object]:void 0;if(r&&(r.touchedAt=n.seq),n.outcome===`rejected`)return r?r.hidden++:e.hidden.rejected++,F(e);let i=n.effect;if(!i)return F(e);let a=t.principals[n.actor]?.kind===`agent`,o=(t,r)=>a?P(e,n,t,r):F(e);switch(i.kind){case`catalog`:return e.hidden.catalog++,F(e);case`open`:{if(i.source===null)return F(e);let t=!!e.objects[`source:`+i.source],r=Be(e,i.source,n.seq);return r.version=i.version,t||(r.savedVersion=i.version),o(r.id,null)}case`edit`:{let t=Be(e,i.source,n.seq);return t.version=i.version,t.changedAt=n.seq,o(t.id,null)}case`save`:{let t=Be(e,i.source,n.seq);return t.savedVersion=i.version,t.changedAt=n.seq,o(t.id,null)}case`source-state`:{let t=Be(e,i.source,n.seq);return t.version=i.version,t.savedVersion=i.savedVersion,t.changedAt=n.seq,F(e)}case`submit`:if(i.sourceVersion!==null&&!e.objects[`source:`+i.source]){let t=Be(e,i.source,n.seq);t.version=t.savedVersion=i.sourceVersion}return ze(e,{id:`run:`+i.run,kind:`run`,name:`Run `+i.run,run:i.run,source:i.source,sourceVersion:i.sourceVersion,state:i.state??`running`,exit:null,firstLine:null,verified:[],changedAt:n.seq,touchedAt:n.seq,hidden:0}),o(`run:`+i.run,null);case`retry`:{let t=e.objects[`run:`+i.run];return t&&t.hidden++,e.hidden.retries++,F(e)}case`run-state`:case`ended`:{let t=e.objects[`run:`+i.run];return t?(i.kind===`ended`?(t.exit=i.exit,t.state=i.state??(i.exit===0?`completed`:i.exit===null?`unknown`:`failed`)):t.state=i.state,t.changedAt=n.seq,(t.state===`failed`||t.state===`unknown`)&&Ye(e,t,n.seq),t.state===`completed`&&(e.escalations=e.escalations.filter(n=>{let r=e.objects[n.object];return!(r?.kind===`run`&&r.source===t.source&&r.run<t.run)})),o(t.id,null)):F(e)}case`observe`:return o(`run:`+i.run,null);case`output`:{let n=e.objects[`run:`+i.run],r=i.stream?t.runs[i.run]?.outputs[i.stream]??``:``;(i.stream===`stderr`||i.stream&&!n.firstLine)&&(n.firstLine=tt(r));let a=e.escalations.find(e=>e.object===n.id);return a&&n.firstLine&&(a.reason=n.firstLine),o(n.id,null)}case`verified`:{let r=e.objects[`run:`+i.run],a=t.runs[i.run]?.verified??[];if(!r)return F(e);r.verified=[...i.artifacts],r.changedAt=n.seq;for(let t of i.artifacts){let r=Ve(e,t,n.seq),o=a.find(e=>e.name===t)?.digest??`unknown`,s=r.versions.find(e=>e.digest===o);s?s.runs.includes(i.run)||s.runs.push(i.run):(r.versions.push({digest:o,runs:[i.run]}),r.changedAt=n.seq)}return o(r.id,null)}case`registered`:{let t=Ve(e,i.artifact,n.seq);t.name=i.name;let r=t.versions.find(e=>e.digest===i.version);return r?i.run!==null&&!r.runs.includes(i.run)&&r.runs.push(i.run):(t.versions.push({digest:i.version,runs:i.run===null?[]:[i.run]}),t.changedAt=n.seq),F(e)}case`read`:{if(i.artifact===null)return F(e);let t=Ve(e,i.artifact,n.seq);return t.touchedAt=n.seq,o(t.id,i.run)}case`layout`:return a?qe(e,n,i.views,i.replace):F(e);case`items`:return i.question!==null&&(e.question=i.question),i.items&&(e.items=i.items),F(e);case`ask`:return ze(e,{id:i.question,kind:`question`,name:i.text,author:n.actor,target:i.target,version:i.version,run:i.run,rows:[...i.rows],document:i.document,state:`prepared`,fetchedBy:null,fetchedAt:null,changedAt:n.seq,touchedAt:n.seq,hidden:0}),F(e);case`fetched`:{let t=e.objects[i.question];return t?.kind===`question`&&(t.state!==`responded`&&(t.state=`fetched`),t.fetchedBy=n.actor,t.fetchedAt=n.seq,t.changedAt=n.seq),F(e)}case`responded`:{let t=e.objects[i.question];return t?.kind===`question`&&(t.state=`responded`,t.changedAt=n.seq),F(e)}}}function P(e,t,n,r){e.attention===`following`?j(e,n,r)?(e.agent={object:n,run:r,seq:t.seq,placement:`main`},e.pending=null):I(e,t)?(e.pending={kind:`focus`,object:n,run:r},e.agent={object:n,run:r,seq:t.seq,placement:`pending`}):(e.pending=null,Ke(e,n,r,`agent`),e.agent={object:n,run:r,seq:t.seq,placement:`main`},Ge(e,t,`agent`,`agent-focus`)):e.agent={object:n,run:r,seq:t.seq,placement:`marker`}}function F(e){if(!e.pending||e.attention!==`following`)return;let t={seq:e.step,at:e.time};if(I(e,t))return;let n=e.pending;e.pending=null,n.kind===`focus`?(Ke(e,n.object,n.run,`agent`),e.agent&&(e.agent.placement=`main`),Ge(e,t,`agent`,`agent-focus`)):Je(e,t,n.views,n.replace)}function I(e,t){let n=e.presentationClock??Ne(k(t))??Ne(e.time);return e.lastMove!==null&&n!==null&&n-e.lastMove<8e3}function Ge(e,t,n,r){n===`agent`&&(e.lastMove=e.presentationClock??Ne(k(t))??Ne(e.time)??e.lastMove),e.moves.push({seq:t.seq,by:n,view:e.active,rule:r})}function Ke(e,t,n,r,i){let a=e.views.filter(e=>e.object===t),o=r===`person`?A(e,t):a.find(e=>(n===null||e.run===n)&&(!i||e.version===i))??a.find(e=>!Ue(e));if(o&&r===`agent`&&n!==null&&(o.run=n),!o){o=N(e,t,n,r,r===`agent`);let i=r===`agent`?e.views.findIndex(e=>e.preview):-1;i>=0?e.views[i]=o:e.views.push(o)}r===`person`&&(o.preview=!1,o.openedBy=`person`),i&&(o.version=i),e.active=o.id}function qe(e,t,n,r){let i=e.views.some(t=>t.pinned&&t.id===e.active);if(e.attention===`following`&&!i){if(I(e,t)){e.pending={kind:`layout`,views:n,replace:r};return}return Je(e,t,n,r)}let a=e.attention===`away`?`away`:i?`pinned`:`working`,o=e.suggestions.find(e=>e.id.startsWith(`layout`));o?(o.views=n,o.merged++,o.cause=a):e.suggestions.push({id:`layout:`+t.seq,views:n,cause:a,from:t.seq,merged:0})}function Je(e,t,n,r,i=`agent`){r&&(e.views=e.views.filter(Ue));let a=null;for(let t of n){let n=t.object??`artifact:`+t.artifact,r=e.views.filter(e=>e.object===n),o=r.find(e=>e.run===t.run&&(!t.version||e.version===t.version))??r.find(e=>!Ue(e));o?(o.run=t.run,o.preview=!1):e.views.push(o=N(e,n,t.run,i,!1)),t.version&&(o.version=t.version),a??=o.id}e.active=a??e.active,Ge(e,t,i===`agent`?`agent`:`person`,i===`agent`?`agent-layout`:`accept`)}function Ye(e,t,n){if(e.attention!==`working`||Object.values(e.objects).some(e=>e.kind===`run`&&e.source===t.source&&e.run>t.run&&e.state===`completed`))return;let r=e.objects[He(e,e.active)?.object??``];r&&(r.id===t.id||r.id===`source:`+t.source||r.kind===`run`&&r.source===t.source||r.kind===`artifact`&&r.versions.some(n=>n.runs.some(n=>e.objects[`run:`+n]?.source===t.source)))&&!e.escalations.some(e=>e.object===t.id)&&e.escalations.push({object:t.id,reason:t.state===`unknown`?`Outcome unknown`:t.exit===null?`Execution failed`:`Exit `+t.exit,from:n})}function Xe(e,t,n){let r={seq:Math.max(n.at,-1),at:e.time},i=()=>{e.attention===`following`&&(e.attention=`working`)};switch(n.kind){case`follow`:e.attention=`following`,e.agent&&!j(e,e.agent.object,e.agent.run)&&(Ke(e,e.agent.object,e.agent.run,`agent`),e.moves.push({seq:r.seq,by:`person`,view:e.active,rule:`catch-up`})),e.agent&&(e.agent.placement=`main`),e.pending=null;return;case`unfollow`:e.attention=`working`;return;case`open`:{if(i(),n.version!==void 0||n.run!==void 0){let t=e.views.find(e=>e.object===n.target&&e.run===(n.run??null)&&(!n.version||e.version===n.version));t||(t=N(e,n.target,n.run??null,`person`,!1),e.views.push(t)),n.version&&(t.version=n.version),t.openedBy=`person`,t.preview=!1,e.active=t.id,e.escalations=e.escalations.filter(e=>e.object!==n.target),e.moves.push({seq:r.seq,by:`person`,view:e.active,rule:`person`});return}let t=e.objects[n.target],a=e.items.find(e=>`item:`+e.id===n.target),o=t?.kind===`question`?{object:t.target,version:t.version,run:t.run}:a?.artifact;if(o){let t=e.views.find(t=>t.object===o.object&&(t.version??Qe(e,o.object,t.run))===o.version);if(t)t.preview=!1,t.openedBy=`person`,e.active=t.id;else{let t=N(e,o.object,o.run,`person`,!1);t.version=o.version,e.views.push(t),e.active=t.id}e.moves.push({seq:r.seq,by:`person`,view:e.active,rule:`person`});return}let s=A(e,n.target),c=s?.object??n.target;s?(s.preview=!1,s.openedBy=`person`,e.active=s.id):Ke(e,c,c.startsWith(`artifact:`)?$e(e,c):null,`person`),e.escalations=e.escalations.filter(e=>e.object!==c),e.moves.push({seq:r.seq,by:`person`,view:e.active,rule:`person`});return}case`select`:{i();let t=A(e,n.target);t&&(t.selection=[...n.rows],t.preview=!1,t.openedBy=`person`);return}case`type`:i();return;case`close`:{let t=A(e,n.target);e.views=e.views.filter(e=>e!==t),t&&e.active===t.id&&(e.active=e.views.at(-1)?.id??null);return}case`pin`:case`unpin`:{let t=A(e,n.target);t&&(t.pinned=n.kind===`pin`,t.preview=!1,t.openedBy=`person`);return}case`update`:{i();let t=A(e,n.target),a=t?et(e,t):null;if(!t||a===null)return;t.run=a,t.version&&=Qe(e,t.object,a)??void 0,e.views=e.views.filter(e=>e===t||e.pinned||e.object!==t.object||e.run!==a),e.active=t.id,e.moves.push({seq:r.seq,by:`person`,view:e.active,rule:`person`});return}case`leave`:if(e.attention===`away`)return;e.pending=null,e.away={from:e.step,prior:e.attention,baseline:structuredClone(e.objects),suggestions:e.suggestions.map(e=>e.id),items:JSON.stringify(e.items)},e.attention=`away`;return;case`return`:{if(!e.away)return;let t=Ze(e,e.away);e.digest=t.length?{from:e.away.from,to:e.step,lines:t}:null,e.attention=e.away.prior,e.away=null;return}case`accept`:{let t=e.suggestions.find(e=>e.id===n.suggestion);if(!t)return;e.suggestions=e.suggestions.filter(e=>e!==t),Je(e,r,t.views,!1,`person`);return}case`ask`:{i();let t=A(e,n.target),a=t?Qe(e,t.object,t.run):null;if(!t||a===null||t.run===null)return;ze(e,{id:`question:asked-`+(e.order.filter(e=>e.startsWith(`question:asked-`)).length+1),kind:`question`,name:n.text,author:null,target:t.object,version:a,run:t.run,rows:[...n.rows],document:null,state:`prepared`,fetchedBy:null,fetchedAt:null,changedAt:r.seq,touchedAt:r.seq,hidden:0});return}case`dismiss`:e.suggestions=e.suggestions.filter(e=>e.id!==n.suggestion);return;case`dismiss-digest`:e.digest=null;return;case`reveal`:e.revealed=n.target;return;case`expand`:e.expanded.includes(n.target)||e.expanded.push(n.target);return;case`collapse`:e.expanded=e.expanded.filter(e=>e!==n.target);return}}function Ze(e,t){let n=[],r={source:0,run:1,artifact:2,question:3};for(let i of[...e.order].sort((t,n)=>r[e.objects[t].kind]-r[e.objects[n].kind])){let r=e.objects[i],a=t.baseline[i];if(r.kind===`source`&&(!a||a.version!==r.version)&&n.push({kind:`source`,object:i,from:a?a.version:null,to:r.version}),r.kind===`run`&&(!a||a.state!==r.state||a.verified.length!==r.verified.length)){let t={kind:`run`,object:i,state:r.state,firstLine:r.state===`completed`?null:r.firstLine,verified:r.verified.length,earlier:[]},a=n.findIndex(t=>t.kind===`run`&&e.objects[t.object].source===r.source);if(a<0)n.push(t);else{let e=n[a];t.earlier=[...e.earlier,e.object],n[a]=t}}r.kind===`artifact`&&r.versions.length!==(a?.versions.length??0)&&n.push({kind:`artifact`,object:i,versions:r.versions.length-(a?.versions.length??0)}),r.kind===`question`&&(!a||a.state!==r.state)&&n.push({kind:`question`,object:i,state:r.state})}for(let r of e.suggestions)t.suggestions.includes(r.id)||n.push({kind:`suggestion`,id:r.id});return JSON.stringify(e.items)!==t.items&&n.push({kind:`items`,count:e.items.length}),n}var Qe=(e,t,n)=>{let r=e.objects[t];return r?.kind===`artifact`&&n!==null?r.versions.find(e=>e.runs.includes(n))?.digest??null:null},$e=(e,t)=>e.objects[t]?.versions.at(-1)?.runs.at(-1)??null;function et(e,t){let n=e.objects[t.object];if(n?.kind!==`artifact`||t.run===null||!Ue(t))return null;let r=n.versions.findIndex(e=>e.runs.includes(t.run));return r>=0&&r<n.versions.length-1?$e(e,t.object):null}function tt(e){return e.split(`
2
2
  `).map(e=>e.trim()).find(Boolean)??null}var L=()=>({activity:0,runs:[],states:{},documents:{},resources:{},composition:0,questions:{}}),nt=e=>e.split(`/`).at(-1)??e;function rt(e,t,n,r,i){let a={format:`rho.replay-trace/1`,recorded:{experiment:`live`,project:e.project.id,from:``,to:``},facts:[],principals:{},sources:{},runs:{},artifacts:{}},o={},s={},c=(e,t,n,r,i,o)=>{a.principals[t]={kind:t.startsWith(`agent:`)?`agent`:t.startsWith(`browser:`)?`browser`:`operator`,name:null},a.facts.push({seq:a.facts.length,label:e,op:e,actor:t,at:n,effect:r,object:i,outcome:o?`rejected`:`returned`,...o?{reason:o}:{}})},l=e=>{let t=r.runs.indexOf(e);return t<0?null:t+1},u=new Set;for(let e of[...t].sort((e,t)=>e.acceptedAt.localeCompare(t.acceptedAt))){r.runs.includes(e.operationId)||r.runs.push(e.operationId);let t=l(e.operationId),n=e.sourceKey??e.operationId;o[`run:`+t]=e.operationId,a.runs[t]={operationId:e.operationId,source:n,sourceVersion:null,declared:e.declared.map(e=>e.path),acceptedAt:e.acceptedAt,exit:null,observedAt:null,outputs:{}};let i=JSON.stringify([e.execution,e.integrity]);r.states[e.operationId]!==i&&u.add(e.operationId),e.operationId in r.states||c(`action.accepted`,`operator`,e.acceptedAt,{kind:`submit`,run:t,source:n,sourceVersion:null,state:`unobserved`},`run:`+t),r.states[e.operationId]!==i&&c(`operation.observed`,`operator`,null,{kind:`run-state`,run:t,state:e.execution===`active`?`running`:[`completed`,`failed`,`unobserved`].includes(e.execution)?e.execution:`unknown`},`run:`+t),r.states[e.operationId]=i}for(let t of e.documents){let e=`source:`+t.path;o[e]=t.path,a.sources[t.path]={versions:{},edited:{},saved:{},authors:{}};let n=JSON.stringify([t.version,t.dirty]);r.documents[t.id]!==n&&(c(`document.observed`,`operator`,t.acknowledgedAt,{kind:`source-state`,source:t.path,version:t.version,savedVersion:t.dirty?null:t.version},e),r.documents[t.id]=n),s[`document:`+t.id]={object:e,artifact:``,run:null}}for(let n of e.resources){let e=n.provenance,i=t.find(t=>t.operationId===e.operationId),u=i?.declared.find(e=>n.path===e.path||n.path.endsWith(`/`+e.path)),d=r.resources[n.id],f=`@`+n.version,p=i?.sourceKey&&u?i.sourceKey+`/`+u.path:d?.endsWith(f)?d.slice(0,-f.length):n.id,m=`artifact:`+p,h=e.operationId?l(e.operationId):null,g={artifact:p,run:h,version:n.version};s[n.id+`@`+n.version]=g,o[m]=nt(n.path);let _=(a.artifacts[p]??={kind:n.kind,versions:{}}).versions,v=_[n.version]??={runs:[],bytes:n.bytes};h!==null&&v.runs.push(h),r.resources[n.id]!==p+`@`+n.version&&(c(`resource.registered`,`operator`,null,{kind:`registered`,artifact:p,name:nt(n.path),version:n.version,run:h},m),r.resources[n.id]=p+`@`+n.version)}for(let n of t)if(n.integrity===`verified`&&u.has(n.operationId)){let t=l(n.operationId),r=e.resources.filter(e=>e.provenance.operationId===n.operationId);a.runs[t].verified=r.map(e=>({name:s[e.id+`@`+e.version].artifact,digest:e.version,kind:e.kind})),c(`artifact.integrity.observed`,`operator`,null,{kind:`verified`,run:t,artifacts:a.runs[t].verified.map(e=>e.name)},`run:`+t)}for(let e of n.views){let t=at(e,s);t&&(s[`view:`+e.id]=t)}let d=e.activity.retainedFrom>r.activity+1;for(let t of e.activity.entries){let n=t;if(n.cursor<=r.activity)continue;let i=e.documents.find(e=>e.id===n.documentId),a=typeof n.operationId==`string`?l(n.operationId):null,o=n.resource,u=o?s[o.id+`@`+o.version]:void 0,d,f;i&&(f=`source:`+i.path),a!==null&&(f=`run:`+a),u&&(f=u.object??`artifact:`+u.artifact),n.outcome===`rejected`?c(n.method,n.principal,n.at,void 0,f,{kind:typeof n.errorKind==`string`?n.errorKind:`unrecorded`,message:null}):([`capability.index`,`capability.resolve`].includes(n.method)&&(d={kind:`catalog`}),i&&typeof n.returnedVersion==`number`&&[`document.open`,`document.read`,`document.edit`,`document.save`].includes(n.method)&&(d={kind:`open`,source:i.path,version:i.version}),a!==null&&[`action.submit`,`action.lookup`,`action.observe`,`artifact.check`,`action.output`].includes(n.method)&&(d={kind:`observe`,run:a}),n.method===`data.page`&&(d={kind:`read`,artifact:u?.artifact??null,run:u?.run??null}),c(n.method,n.principal,n.at,d,f))}if(r.activity=Math.max(r.activity,e.activity.cursor),n.version!==r.composition){let e=n.views.flatMap(e=>s[`view:`+e.id]?[s[`view:`+e.id]]:[]);c(`composition.observed`,n.author??`operator`,n.acknowledgedAt??null,{kind:`layout`,replace:!0,views:e},`layout`),r.composition=n.version}for(let t of e.annotations){let n=t,i=n.messages?.[0],a=n.anchor;if(a?.kind!==`table`||!i)continue;let o=s[a.resource.id+`@`+a.resource.version];if(!o)continue;let l=`question:`+n.annotationId,u=e.contexts.find(e=>e.responses?.some(e=>e.annotationId===n.annotationId)),d=n.messages.some(e=>e.replyTo===i.id&&e.author.startsWith(`agent:`)),f=u?.delivery===`tool-fetched`&&u.fetchedBy?.startsWith(`agent:`),p=d?`responded`:f?`fetched`:`prepared`;if(l in r.questions||c(`annotation.create`,i.author,i.at,{kind:`ask`,question:l,text:i.draft.text,target:`artifact:`+o.artifact,version:a.resource.version,run:o.run,rows:a.entities,document:null},l),r.questions[l]!==p){if(f&&c(`context.read`,u.fetchedBy,u.fetchedAt,{kind:`fetched`,question:l},l),d){let e=n.messages.find(e=>e.replyTo===i.id&&e.author.startsWith(`agent:`));c(`annotation.reply`,e.author,e.at,{kind:`responded`,question:l},l)}r.questions[l]=p}}if(i){let e=i.items.map(e=>it(e,i.vocabulary,s)),t=JSON.stringify([i.question,e]);if(r.items!==t){let n=i.items.reduce((e,t)=>!e||t.at>e.at?t:e,void 0);c(`task.map.observed`,n?.author??`operator`,n?.at??null,{kind:`items`,question:i.question,items:e},`map`),r.items=t}}return{trace:a,refs:s,names:o,gap:d}}function it(e,t,n){let r=e.artifact&&n[e.artifact.id+`@`+e.artifact.version];return{id:e.id,kind:t.kinds[e.kind]?.label??e.kind,state:t.states[e.state]?.label??e.state,title:e.title,author:e.author,...e.summary?{summary:e.summary}:{},...e.view?{view:e.view}:{},...e.from?{from:e.from}:{},...e.lines?{lines:e.lines}:{},...r&&r.run!==null?{artifact:{object:r.object??`artifact:`+r.artifact,version:e.artifact.version,run:r.run}}:{}}}function at(e,t){for(let n of Object.values(e.bindings??{})){let e=n.documentId?t[`document:`+n.documentId]:t[n.id+`@`+n.version];if(e)return e}}var R={maxViews:64,maxEvidence:256,maxCheckpointBytes:1048576},ot=e=>e.object??`artifact:`+e.artifact,st=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function ct(e){let t=e.catalog?.components.find(e=>e.id===`rho.editor`),n=t?e.documents.map(e=>({id:`source:`+e.id,component:t.id,version:t.version,props:{title:e.path},bindings:{document:{kind:`live-document`,documentId:e.id}}})):[];for(let t of e.resources){let r=e.catalog?.components.find(e=>e.id===(t.kind===`table`?`rho.table`:t.kind===`media`?`rho.media`:``));if(!r)continue;let i=Object.keys(r.bindings)[0];i&&n.push({id:`object:`+t.id.slice(0,32)+`:`+t.version.slice(0,32),component:r.id,version:r.version,props:{title:t.path.split(`/`).at(-1)},bindings:{[i]:{id:t.id,version:t.version}}})}return n}function z(e,t,n,r){let i=L(),a=rt(e,t,n,i,r),o=Pe(`working`);for(let e of a.trace.facts)Fe(o,a.trace,e);return o.attention=`following`,o.suggestions=[],o.moves=[],o.views=n.views.flatMap(e=>{let t=at(e,a.refs);return t?[{id:e.id,object:ot(t),run:t.run,...t.version?{version:t.version}:{},openedBy:`agent`,pinned:!!e.protected,preview:!1,selection:[],newer:null}]:[]}),o.active=o.views[0]?.id??null,{format:1,expression:o,index:i,layout:structuredClone(n),latest:structuredClone(n),held:{},refs:a.refs,available:ct(e),trace:a.trace,evidence:a.trace.facts.slice(-R.maxEvidence),gap:a.gap,limit:``,active:n.views[0]?.id??``,names:a.names}}function B(e){let t=structuredClone(e.latest),n=new Map;for(let r of t.views){let i=e.held[r.id];i&&!st(i.bindings,r.bindings)&&n.set(r.id,`new:`+r.id.slice(0,70)+`:`+t.version)}t.views=t.views.map(e=>({...e,id:n.get(e.id)??e.id})),t.nodes&&=t.nodes.map(e=>e.kind===`view`?{...e,id:n.get(e.id)??e.id}:{...e,children:e.children.map(e=>n.get(e)??e)});for(let n of Object.values(e.held))if(!t.views.some(e=>e.id===n.id)){t.views.push(n);let e=t.nodes?.find(e=>e.kind===`group`&&e.id===t.rootId);e?.kind===`group`&&(e.children.push(n.id),e.presentation?.weights&&e.presentation.weights.push(1),t.nodes.push({...n,kind:`view`}))}t.views.length>R.maxViews?e.limit=`The 64-view presentation limit was reached. Existing views are kept; close or unpin views before accepting another layout.`:(e.layout=t,e.preview=void 0)}function V(e,t){let n=e.expression.moves.slice(t);n.some(e=>e.rule===`agent-layout`||e.rule===`accept`)&&B(e);let r=e.expression.views.find(t=>t.id===e.expression.active);if(!r||!n.length)return;let i=[...e.layout.views,...e.latest.views,...e.available??[]].find(t=>{let n=at(t,e.refs);return n&&ot(n)===r.object&&(r.run===null||n.run===r.run)&&(!r.version||n.version===r.version)});if(i){let t=i.id,n=e.layout.views.find(e=>e.id===t);if(n&&!st(n.bindings,i.bindings)&&(t=`preview:`+t.slice(0,70)+`:`+e.latest.version),!e.layout.views.some(e=>e.id===t)){if(e.layout.views.length>=R.maxViews){e.limit=`The 64-view presentation limit was reached; the new object remains in recorded evidence.`;return}let n=e.layout.views.filter(t=>t.id!==e.preview||e.held[t.id]);e.layout={...e.layout,views:[...n,{...i,id:t}]},r.preview&&(e.preview=t)}e.active=t}else if(r.object.startsWith(`run:`)){let t=e.names[r.object];if(!t)return;let n=`execution:`+t;!e.layout.views.some(e=>e.id===n)&&e.layout.views.length<R.maxViews&&(e.layout={...e.layout,views:[...e.layout.views.filter(t=>t.component!==`rho.execution`&&t.id!==e.preview||e.held[t.id]),{id:n,component:`rho.execution`,version:`1`,props:{title:t,operationId:t},bindings:{}}]},e.preview=n),e.layout.views.some(e=>e.id===n)&&(e.active=n)}}function lt(e,t,n,r,i,a){let o=rt(t,n,r,e.index,a),s=e.expression.moves.length;e.latest=structuredClone(r),e.refs=o.refs,e.names=o.names,e.trace=o.trace,e.available=ct(t),e.gap||=o.gap;for(let t of o.trace.facts)Fe(e.expression,o.trace,t,i);e.evidence.push(...o.trace.facts),e.evidence=e.evidence.slice(-R.maxEvidence),V(e,s),!r.author?.startsWith(`agent:`)&&e.layout.version!==r.version&&B(e),e.expression.moves=e.expression.moves.slice(-32)}function H(e,t){let n=e.expression.moves.length;Ie(e.expression,e.trace,t),V(e,n)}function U(e,t){delete e.held[t]}function ut(e,t){let n=e.layout.views.find(e=>e.id===t);if(!n)return;e.held[t]=structuredClone(n),e.active=t;let r=at(n,e.refs);H(e,r?{kind:`open`,target:ot(r),run:r.run,version:r.version}:{kind:`unfollow`}),e.active=t}function dt(e,t){let n=e.expression.moves.length;Le(e.expression,t),V(e,n)}function ft(e){return Re(e.expression)}function pt(e,t,n,r,i=!1){let{runs:a,problem:o,readAgain:s}=Se(n,e.project.id,e.cursor),c=e.catalog.operations.some(e=>e.method===`task.map.read`&&e.authorized&&e.state===`available`),[l,u]=(0,O.useState)(null),[d,f]=(0,O.useState)(``);(0,O.useEffect)(()=>{if(!c)return;let t=!0;return n.call(`task.map.read`,{projectId:e.project.id}).then(e=>{t&&(u(e),f(``))},e=>{t&&f(`The Agent's declared items could not be read. `+(e?.message??``))}),()=>{t=!1}},[n,e.project.id,e.cursor,c]);let p=[`rho-expression/1`,e.project.id,t.compositionId,r].join(`:`),m=(0,O.useRef)(null),h=(0,O.useRef)(!1),g=(0,O.useRef)(null),_=(0,O.useRef)(`owners`),[,v]=(0,O.useState)(0),[y,b]=(0,O.useState)(``),x=()=>{if(m.current&&sessionStorage.getItem(`rho.browser.session.v1`))try{let e=JSON.stringify(m.current);if(new TextEncoder().encode(e).length>R.maxCheckpointBytes)throw Error(`The 1 MiB return checkpoint limit was reached. Current views are retained in this tab; reload cannot restore the latest attention state.`);sessionStorage.setItem(p,e)}catch(e){b(e.message??`The return checkpoint could not be stored.`)}};(0,O.useEffect)(()=>{if(a){if(m.current){let n=m.current.active;lt(m.current,e,a,t,Date.now(),l),m.current.active!==n&&(_.current=`owners`)}else{try{let e=sessionStorage.getItem(p);if(e&&e.length<=R.maxCheckpointBytes){let n=JSON.parse(e);n.format===1&&n.layout?.compositionId===t.compositionId&&(m.current=n)}}catch{}m.current?(lt(m.current,e,a,t,Date.now(),l),H(m.current,{kind:`return`})):m.current=z(e,a,t,l),h.current&&ut(m.current,g.current&&m.current.layout.views.some(e=>e.id===g.current)?g.current:m.current.active),document.hidden&&H(m.current,{kind:`leave`})}i&&(m.current.layout=structuredClone(t),m.current.held={}),x(),v(e=>e+1)}},[e,t,a,l]),(0,O.useEffect)(()=>{let e=()=>{m.current&&(H(m.current,{kind:document.hidden?`leave`:`return`}),x(),v(e=>e+1))},t=()=>{m.current&&(H(m.current,{kind:`leave`}),x())},n=setInterval(()=>{if(m.current?.expression.pending){let e=m.current.active;dt(m.current,Date.now()),m.current.active!==e&&(_.current=`owners`),x(),v(e=>e+1)}},1e3);return document.addEventListener(`visibilitychange`,e),window.addEventListener(`pagehide`,t),()=>{t(),clearInterval(n),document.removeEventListener(`visibilitychange`,e),window.removeEventListener(`pagehide`,t)}},[p]);let S=e=>{_.current=`person`,m.current&&(e.kind===`unfollow`&&ut(m.current,m.current.active),H(m.current,e),x(),v(e=>e+1))},C=e=>{h.current=!0,g.current=e,_.current=`person`,m.current&&(ut(m.current,e),x(),v(e=>e+1))};return{state:m.current,screen:m.current?ft(m.current):null,layout:m.current?.layout??t,active:m.current?.active,movedBy:_.current,runs:a,readRuns:s,map:l,act:S,release:e=>{m.current&&(U(m.current,e),x())},hold:C,openResource:t=>{if(!m.current)return;let n=e.resources.find(e=>e.id===t.id&&e.version===t.version),r=e.compositions.flatMap(e=>e.views).find(e=>Object.values(e.bindings).some(e=>`id`in e&&e.id===t.id&&e.version===t.version)),i=e.catalog.components.find(e=>e.id===(n?.kind===`table`?`rho.table`:`rho.media`)),a=i&&Object.keys(i.bindings)[0];if(!n||!r&&(!i||!a)){b(`The linked result has no available resource viewer. Its exact reference is retained in the reply.`);return}let o=`result:`+t.id.slice(0,32)+`:`+t.version.slice(0,32);if(!m.current.layout.views.some(e=>e.id===o)){if(m.current.layout.views.length>=R.maxViews){b(`The 64-view limit was reached. The reply and linked result are retained.`);return}let e=r?{...r,id:o}:{id:o,component:i.id,version:i.version,props:{title:n.path.split(`/`).at(-1)},bindings:{[a]:t}};m.current.layout={...m.current.layout,views:[...m.current.layout.views,e]}}C(o)},problem:[o,d,y,m.current?.limit].filter(Boolean).join(` · `)}}var W=t();function mt(e){let t=n=>{let r=e.screen?.objects[n];return r?.kind===`question`?`Question about `+t(r.target):e.state?.names[n]??r?.name??n};return t}var ht={running:`running`,completed:`completed`,failed:`failed`,unknown:`outcome unknown`,unobserved:`accepted, not seen running yet`},G={prepared:`prepared, not fetched`,fetched:`fetched by the Agent`,responded:`answered by the Agent`};function K(e){return e?e.kind===`run`?ht[e.state]??e.state:e.kind===`source`?e.savedVersion!==null&&e.savedVersion!==e.version?`version ${e.version}, unsaved`:`version ${e.version}`:e.kind===`artifact`?e.versions.length===1?`1 version`:`${e.versions.length} versions`:G[e.state]??e.state:``}var q=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}),gt=e=>new Date(e).toLocaleDateString([],{month:`short`,day:`numeric`}),J=(e,t)=>new Date(e).toDateString()===new Date(t).toDateString(),Y=e=>{let t=Math.max(0,Math.round(e/1e3));return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`},_t=e=>(J(e,new Date().toISOString())?``:gt(e)+` `)+q(e);function X({live:e,who:t=!0}){let n=e.screen,r=n.agent,i=mt(e);return r?(0,W.jsxs)(`button`,{className:`shell-agent`,"data-rho-agent":``,title:`The Agent's latest object: ${i(r.object)}`,onClick:()=>e.act({kind:`open`,target:r.object}),children:[(0,W.jsx)(`span`,{className:t?`shell-agent-who`:`visually-hidden`,children:`Agent`}),` `,(0,W.jsx)(`span`,{className:`shell-agent-object`,children:i(r.object)}),` `,(0,W.jsxs)(`span`,{className:`shell-agent-state`,children:[K(n.objects[r.object]),r.placement===`pending`?` · shows when you pause`:``]})]}):null}function vt({live:e,evidence:t,onEvidence:n,held:i,attention:a=!0}){let{screen:o,act:s}=e;if(!o||!e.state)return(0,W.jsx)(`div`,{className:`shell-bar`,role:`status`,children:`Reading workspace…`});let c=o.attention===`following`;return(0,W.jsxs)(`div`,{className:`shell-bar`,"data-attention":o.attention,children:[(0,W.jsx)(X,{live:e}),(0,W.jsx)(`span`,{className:`shell-break`}),i>0&&(0,W.jsxs)(`span`,{className:`shell-held`,role:`status`,children:[i,` updates`]}),a&&(0,W.jsxs)(`button`,{className:`shell-follow`,"aria-pressed":c,title:`Follow the Agent's current view. Your input stops following.`,onClick:()=>s({kind:c?`unfollow`:`follow`}),children:[(0,W.jsx)(r,{name:`eye`,size:14}),c?`Following Agent`:`Follow Agent`]}),a&&(0,W.jsx)(`button`,{className:`shell-quiet`,onClick:()=>s({kind:o.attention===`away`?`return`:`leave`}),children:o.attention===`away`?`Return`:`Step away`}),(0,W.jsxs)(`button`,{className:`shell-quiet shell-evidence-toggle`,"aria-expanded":t,title:`Activity: the calls recorded for this workspace`,onClick:n,children:[(0,W.jsx)(r,{name:`list`,size:15}),(0,W.jsx)(`span`,{children:`Activity`})]})]})}function Z(e,t){let n=e.map?.items.find(e=>e.id===t);return n?e.map.vocabulary.states[n.state]?.role??``:``}var Q={prepared:`Prepared · not fetched by the Agent`,fetched:`Fetched by the Agent · no linked response yet`,responded:`Answered by the Agent`};function yt({contextId:e,prepare:t}){let[n,r]=(0,O.useState)(!1),[i,a]=(0,O.useState)(``);async function o(){a(``);try{let n=e??await t();await navigator.clipboard.writeText(`Answer my question in Rho: read context ${n}. It holds the table version, the rows I asked about and my question. Reply to it with annotation.reply, and link any new result you make.`),r(!0)}catch{a(`Could not copy. Try again.`)}}return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`button`,{className:`agent-question-copy`,onClick:o,children:n?`Copied`:`Copy request for the Agent`}),i&&(0,W.jsx)(`span`,{role:`alert`,children:i})]})}function bt({live:e,agents:t,contexts:n=[],prepare:i,principalId:a,evidence:o,onEvidence:s,focusObject:c,onClose:l}){let u=(0,O.useRef)(null),d=(0,O.useRef)(null);(0,O.useEffect)(()=>{o&&u.current?.scrollIntoView({block:`start`})},[o]),(0,O.useEffect)(()=>{l&&d.current?.focus()},[!!l]);let f=e.screen,p=e.state,m=mt(e),h=Object.values(f?.objects??{}).find(e=>e.kind===`run`&&e.state===`running`),[g,_]=(0,O.useState)(Date.now()),[v,y]=(0,O.useState)(!1);if((0,O.useEffect)(()=>{if(!h)return;let e=setInterval(()=>_(Date.now()),1e3);return()=>clearInterval(e)},[!!h]),!f||!p)return null;let b=[...t??[]].sort((e,t)=>(e.last?.at??``).localeCompare(t.last?.at??``)).at(-1),x=b?.label||Object.values(p.trace.principals).find(e=>e.kind===`agent`&&e.name)?.name||`The Agent`,S=b?.last?.at,C=h&&e.runs?.find(e=>e.operationId===m(h.id)&&e.execution===`active`),ee=C?C.startedAt??C.acceptedAt:void 0,w=Object.values(f.objects).filter(e=>e.kind===`question`).reverse(),te=f.items.find(e=>c&&e.artifact?.object===c)??f.items.find(t=>Z(e,t.id)===`working`),ne=te?.artifact&&Object.values(f.objects).find(e=>e.kind===`run`&&e.run===te.artifact.run),T=ne?e.runs?.find(e=>e.operationId===m(ne.id)):void 0,re=e=>T?.sourceKey?Object.values(p.refs).find(t=>t.artifact===T.sourceKey+`/`+e&&t.run===ne?.run):void 0,E=v?w:w.slice(0,1);return!h&&!f.items.length&&!T?.declared.length&&!w.length&&!o?null:(0,W.jsxs)(`aside`,{ref:d,className:`agent-column`+(l?` drawer`:``),"aria-label":x,"data-scroll-region":``,tabIndex:0,onKeyDown:e=>{l&&e.key===`Escape`&&(e.stopPropagation(),l())},children:[(0,W.jsxs)(`section`,{className:`agent-card`,children:[(0,W.jsxs)(`header`,{className:`agent-card-head`,children:[(0,W.jsx)(`span`,{className:`agent-dot`+(h?` running`:``),"aria-hidden":`true`}),(0,W.jsx)(`strong`,{children:x}),(0,W.jsx)(`span`,{className:`agent-card-meta`,children:h?`running`+(ee?` `+Y(g-Date.parse(ee)):``):S?`last action `+_t(S):`no recorded action`}),l&&(0,W.jsx)(`button`,{className:`icon-button agent-close`,"aria-label":`Close `+x,onClick:l,children:(0,W.jsx)(r,{name:`close`,size:14,stroke:2})})]}),(0,W.jsx)(X,{live:e,who:!1}),f.items.length>0&&(0,W.jsx)(`section`,{className:`agent-items`,"aria-label":`The Agent's notes`,children:(0,W.jsx)(`ol`,{children:f.items.map(t=>{let n=Z(e,t.id),r=t===te,i=t.artifact?.object,a=i&&!t.title.includes(m(i))?m(i):``;return(0,W.jsxs)(`li`,{className:`agent-item `+(n||`declared`)+(r?` current`:``),"data-fact":`agent`,children:[(0,W.jsx)(`span`,{className:`agent-item-mark`,"aria-hidden":`true`}),i?(0,W.jsx)(`button`,{className:`agent-item-title`,onClick:()=>e.act({kind:`open`,target:i,run:t.artifact.run,version:t.artifact.version}),children:t.title}):(0,W.jsx)(`span`,{className:`agent-item-title`,children:t.title}),(0,W.jsxs)(`span`,{className:`agent-item-meta`,children:[a,n===`done`?(0,W.jsxs)(`span`,{className:`visually-hidden`,children:[a&&` · `,t.state]}):(a&&` · `)+t.state]}),r&&(t.summary||t.lines?.length)?(0,W.jsxs)(`div`,{className:`agent-item-body`,children:[t.summary&&(0,W.jsx)(`p`,{children:t.summary}),t.lines?.map((e,t)=>(0,W.jsxs)(`p`,{children:[e.label?e.label+`: `:``,e.text,e.judgment?` · the Agent's reading`:``]},t))]}):null]},t.id)})})})]}),T&&T.declared.length>0&&(0,W.jsxs)(`section`,{className:`agent-card agent-outputs`,"aria-label":`Outputs of `+T.operationId,children:[(0,W.jsxs)(`header`,{className:`agent-card-head`,children:[(0,W.jsx)(`strong`,{children:`Outputs`}),(0,W.jsx)(`span`,{className:`agent-card-sub`,children:T.operationId}),(0,W.jsx)(`span`,{className:`agent-card-count`,children:T.declared.length})]}),(0,W.jsx)(`ul`,{children:T.declared.map(t=>{let n=re(t.path),i=n?`artifact:`+n.artifact:null,a=!!n&&i===c&&f.views.find(t=>t.id===e.active)?.version===n.version;return(0,W.jsxs)(`li`,{className:a?`current`:void 0,children:[(0,W.jsx)(r,{name:De(t.path),size:15,stroke:1.8}),i&&n?(0,W.jsx)(`button`,{className:`agent-output-name`,"aria-current":a||void 0,onClick:()=>e.act({kind:`open`,target:i,run:n.run,version:n.version}),children:t.path}):(0,W.jsx)(`span`,{className:`agent-output-name`,children:t.path}),T.integrity===`verified`&&t.present?(0,W.jsx)(`span`,{className:`agent-output-check`,title:`Bytes verified`,children:(0,W.jsx)(r,{name:`check`,size:14,stroke:2})}):t.present?null:(0,W.jsx)(`span`,{className:`agent-output-state`,children:`not on disk`})]},t.path)})})]}),w.length>0&&(0,W.jsxs)(`section`,{className:`agent-card`,"aria-label":`Your questions`,children:[(0,W.jsxs)(`header`,{className:`agent-card-head`,children:[(0,W.jsx)(`strong`,{children:`Your questions`}),w.length>1&&(0,W.jsx)(`button`,{className:`shell-quiet agent-card-meta`,"aria-expanded":v,onClick:()=>y(e=>!e),children:v?`Newest only`:`${w.length-1} earlier`})]}),(0,W.jsx)(`ul`,{className:`agent-questions`,children:E.map(t=>(0,W.jsxs)(`li`,{className:`agent-question `+t.state,children:[(0,W.jsx)(`p`,{"data-user-text":``,children:t.name}),(0,W.jsx)(`button`,{className:`shell-link`,onClick:()=>e.act({kind:`open`,target:t.target}),children:m(t.target)}),(()=>{let e=n.find(e=>e.responses?.some(e=>`question:`+e.annotationId===t.id)),r=t.state===`prepared`&&!e?`Question retained · context not confirmed`:Q[t.state]??t.state,a=e?.contextId??(i?void 0:null);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`agent-question-state`,children:r}),t.state!==`responded`&&a!==null&&(0,W.jsx)(yt,{contextId:a,prepare:()=>i(t.id.slice(9))})]})})()]},t.id))})]}),(0,W.jsxs)(`section`,{ref:u,className:`agent-card agent-record`,children:[(0,W.jsxs)(`button`,{className:`shell-quiet agent-record-toggle`,"aria-expanded":o,onClick:s,children:[`Recorded calls`,(0,W.jsx)(`span`,{className:`agent-card-meta`,children:p.evidence.length})]}),o&&(0,W.jsx)(Tt,{live:e,principalId:a,notes:!1})]})]})}function xt(e){let t=e.screen,n=[];e.problem&&n.push({key:`problem`,kind:`problem`,text:e.problem});for(let e of t?.escalations??[])n.push({key:`e:`+e.object,kind:`escalation`,object:e.object,text:e.reason});for(let e of t?.suggestions??[])n.push({key:`s:`+e.id,kind:`suggestion`,suggestion:e.id,text:`The Agent arranged a new layout`+(e.merged?` · ${e.merged+1} changes combined`:``)});return n}function St({live:e,items:t,onHide:n}){let[r,i]=(0,O.useState)(0),a=mt(e),o=t[Math.min(r,t.length-1)];return o?(0,W.jsxs)(`div`,{className:`shell-interruption `+o.kind,"data-rho-layer":`transient`,"data-rho-interruption":``,role:o.kind===`problem`?`alert`:`status`,children:[o.object&&(0,W.jsx)(`button`,{className:`shell-link`,onClick:()=>e.act({kind:`open`,target:o.object}),children:a(o.object)}),(0,W.jsx)(`span`,{className:`shell-interruption-text`,children:o.text}),o.suggestion&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`button`,{onClick:()=>e.act({kind:`accept`,suggestion:o.suggestion}),children:`Open update`}),(0,W.jsx)(`button`,{onClick:()=>e.act({kind:`dismiss`,suggestion:o.suggestion}),children:`Dismiss`})]}),t.length>1&&(0,W.jsxs)(`button`,{className:`shell-quiet`,onClick:()=>i(e=>(e+1)%t.length),children:[`Next of `,t.length]}),!o.suggestion&&(0,W.jsx)(`button`,{className:`shell-quiet`,"aria-label":`Hide until it changes`,onClick:()=>n(o.key+`:`+o.text),children:`Hide`})]}):null}function Ct(e){switch(e.kind){case`source`:return e.from===null?`edited, now version ${e.to}`:`version ${e.from} → ${e.to}`;case`run`:return[ht[e.state]??e.state,e.verified?`${e.verified} file${e.verified===1?``:`s`} verified`:``,e.firstLine??``,e.earlier.length?`${e.earlier.length} earlier run${e.earlier.length===1?``:`s`}`:``].filter(Boolean).join(` · `);case`artifact`:return e.versions===1?`1 new version`:`${e.versions} new versions`;case`question`:return G[e.state]??e.state;case`suggestion`:return`The Agent arranged a new layout`;case`items`:return`the Agent's notes changed · ${e.count} now`}}function wt({live:e}){let t=e.screen,n=mt(e),[r,i]=(0,O.useState)(!1);if(!t?.digest)return null;let a=t.digest.lines.filter(e=>e.kind!==`suggestion`||!t.suggestions.length),o=r?a:a.slice(0,a.length>6?5:6);return a.length?(0,W.jsxs)(`section`,{className:`shell-digest`,"data-rho-layer":`transient`,"data-rho-digest":``,"aria-label":`Changes while away`,...r?{"data-scroll-region":``,tabIndex:0}:{},children:[(0,W.jsxs)(`header`,{children:[(0,W.jsx)(`strong`,{children:`While you were away`}),(0,W.jsx)(`button`,{className:`shell-quiet`,onClick:()=>e.act({kind:`dismiss-digest`}),children:`Dismiss`})]}),(0,W.jsx)(`ul`,{children:o.map((t,r)=>(0,W.jsxs)(`li`,{children:[`object`in t?(0,W.jsx)(`button`,{className:`shell-link`,onClick:()=>e.act({kind:`open`,target:t.object}),children:n(t.object)}):null,(0,W.jsx)(`span`,{children:Ct(t)})]},r))}),o.length<a.length&&(0,W.jsxs)(`button`,{className:`shell-quiet`,onClick:()=>i(!0),children:[a.length-o.length,` more`]})]}):null}function Tt({live:e,principalId:t,notes:n=!0}){let r=e.state,i=mt(e);if(!r)return null;let a=e=>{if(t&&e===t)return`You`;let n=r.trace.principals[e],i=n?.kind??(e.startsWith(`agent:`)?`agent`:e.startsWith(`browser:`)?`browser`:void 0);return i===`agent`?n?.name??`The Agent`:i===`browser`?`Another browser tab`:e===`operator`?`Rho`:n?.name??`Unrecorded principal`},o=new Date().toISOString(),s=r.evidence.map((e,t)=>({f:e,i:t})).sort((e,t)=>(t.f.at??``).localeCompare(e.f.at??``)||t.i-e.i);return(0,W.jsxs)(`section`,{className:`shell-evidence`,"data-rho-layer":`transient`,"data-rho-evidence":``,"data-scroll-region":``,tabIndex:0,"aria-label":`Recorded activity`,children:[n&&e.screen&&e.screen.items.length>0&&(0,W.jsxs)(`section`,{"aria-label":`The Agent's notes`,className:`shell-notes`,children:[(0,W.jsxs)(`h3`,{children:[`The Agent's notes`,e.screen.question?` · `+e.screen.question:``]}),(0,W.jsx)(`ul`,{children:e.screen.items.map(t=>(0,W.jsxs)(`li`,{"data-fact":`agent`,children:[(0,W.jsx)(`strong`,{children:t.title}),(0,W.jsxs)(`span`,{children:[` · `,t.kind,` · `,t.state]}),t.artifact&&(0,W.jsx)(`button`,{className:`shell-link`,onClick:()=>e.act({kind:`open`,target:t.artifact.object,run:t.artifact.run,version:t.artifact.version}),children:i(t.artifact.object)}),t.summary&&(0,W.jsx)(`p`,{children:t.summary}),t.lines?.map((e,t)=>(0,W.jsxs)(`p`,{children:[e.label?e.label+`: `:``,e.text,e.judgment?` · the Agent's reading`:``]},t))]},t.id))})]}),r.gap&&(0,W.jsx)(`p`,{role:`status`,children:`Earlier activity is outside the retained window. No missing calls were reconstructed.`}),(0,W.jsx)(`ol`,{children:(()=>{let e=``;return s.map(({f:t,i:n})=>{let r=t.at&&!J(t.at,o)?gt(t.at):``,s=r===e?``:e=r;return(0,W.jsxs)(O.Fragment,{children:[s&&(0,W.jsx)(`li`,{className:`shell-evidence-day`,children:s}),(0,W.jsxs)(`li`,{children:[(0,W.jsx)(`time`,{children:t.at?new Date(t.at).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`}):`Time not recorded`}),(0,W.jsx)(`strong`,{children:a(t.actor)}),(0,W.jsxs)(`span`,{className:`shell-evidence-what`,children:[(0,W.jsx)(`code`,{children:t.op}),` `,t.object?i(t.object):`Object not recorded`,t.outcome===`rejected`?` · refused (${t.reason?.kind??`reason not recorded`})`:``]})]})]},n)})})()}),(0,W.jsxs)(`p`,{children:[`The latest `,r.evidence.length,` facts are kept (limit `,R.maxEvidence,`). Calls an adapter refused on its own are not recorded here.`]})]})}var Et=e=>Array.isArray(e?.type)?void 0:e?.type,Dt=e=>!!e&&(Et(e)===`string`||!!e.oneOf?.some(Dt)||!!e.anyOf?.some(Dt)),Ot=e=>!!e&&(Et(e)===`null`||Array.isArray(e.type)&&e.type.includes(`null`)||!!e.oneOf?.some(Ot)||!!e.anyOf?.some(Ot)),kt=e=>typeof e==`string`?/^[a-f0-9]{64}$/.test(e):!!e&&typeof e==`object`&&Object.values(e).some(kt);function At(e,t){if(!e||typeof e!=`object`||Array.isArray(e))return null;let n=e;if(typeof n.path==`string`)return n.kind===`disk`?`${n.path} · the saved file the Agent proposed`:n.path;if(typeof n.documentId==`string`){let e=t.documents.find(e=>e.id===n.documentId);return e?`${e.path} · version ${n.version}`:`A document that is not open in this project`}let r=n.resource??n;if(typeof r.id==`string`){let e=t.resources.find(e=>e.id===r.id&&e.version===r.version);return e?`${e.path} · the version the Agent proposed`:`A file version that is not registered here`}return null}function jt(e,t){if(!e)return`json`;if(kt(t)&&(!Array.isArray(t)||t.every(e=>typeof e==`string`||kt(e))))return`reference`;if(e.enum?.every(e=>typeof e==`string`))return`choice`;let n=Et(e);return n===`string`&&(t===void 0||typeof t==`string`)?`text`:!n&&Dt(e)&&Ot(e)&&(t===null||typeof t==`string`)?`optional-text`:(n===`number`||n===`integer`)&&(t===void 0||typeof t==`number`)?`number`:n===`boolean`&&(t===void 0||typeof t==`boolean`)?`boolean`:n===`array`&&Array.isArray(t)&&t.every(e=>typeof e==`string`)&&Dt(e.items)?`lines`:n===`object`&&e.properties&&!e.oneOf&&!e.anyOf&&typeof t==`object`&&t&&!Array.isArray(t)?`object`:`json`}function Mt({view:e,snapshot:t,client:n,live:r}){let i=e.props,a=t.catalog.actions.find(e=>e.id===i.action&&e.version===i.actionVersion),o=a?.inputSchema??{},[s,c]=(0,O.useState)(()=>structuredClone(i.input??{})),[l,u]=(0,O.useState)({}),[d,f]=(0,O.useState)(null),[p,m]=(0,O.useState)(!1),[h,g]=(0,O.useState)(!1),[_,v]=(0,O.useState)(``),[y,b]=(0,O.useState)(!1),x=e=>t.catalog.operations.some(t=>t.method===e&&t.state===`available`&&t.authorized),S=r.runs?.find(e=>e.operationId===i.operationId),C=(0,O.useMemo)(()=>({projectId:t.project.id,operationId:i.operationId,action:i.action,actionVersion:i.actionVersion,input:s,...i.repairOf?{repairOf:i.repairOf}:{}}),[t.project.id,i.operationId,i.action,i.actionVersion,i.repairOf,s]);(0,O.useEffect)(()=>{if(S||!x(`protocol.validate`))return;let e=!0;m(!0);let t=setTimeout(()=>{n.call(`protocol.validate`,{method:`action.submit`,body:C},AbortSignal.timeout(15e3)).then(t=>{e&&f(t.problems.map(e=>({path:e.path,message:e.message,fix:e.fix})))},()=>{e&&f(null)}).finally(()=>{e&&m(!1)})},250);return()=>{e=!1,clearTimeout(t)}},[C,S,n]);let ee=Object.keys(l).length>0||p||!!d?.length;async function w(){g(!0),v(``),b(!1);try{await n.call(`action.submit`,C,AbortSignal.timeout(6e4))}catch(e){let t=e?.error;t?.kind?v(t.message??`The owner did not accept this run.`):b(!0)}finally{g(!1),r.readRuns()}}let te=e=>(d??[]).filter(t=>t.path===e||t.path.startsWith(e+`/`)||t.path.startsWith(e+`.`)),ne=e=>`/input/`+e;return a?(0,W.jsxs)(`section`,{className:`shell-action`,"data-owner-body":``,"data-rho-action-form":i.operationId,"aria-label":i.title??i.action,children:[(0,W.jsx)(`h2`,{children:i.title??a.presentation?.displayName??i.action}),(0,W.jsxs)(`p`,{className:`shell-action-identity`,children:[(0,W.jsx)(`code`,{children:i.operationId}),` · `,a.presentation?.displayName??i.action,` `,i.actionVersion,i.repairOf?(0,W.jsxs)(W.Fragment,{children:[` · repairs `,(0,W.jsx)(`code`,{children:i.repairOf})]}):null]}),S?(0,W.jsxs)(`p`,{role:`status`,"data-rho-submitted":i.operationId,children:[`Submitted · `,(0,W.jsx)(`span`,{className:`shell-state `+S.execution,children:we(S.execution)}),` `,(0,W.jsx)(`button`,{className:`shell-link`,onClick:()=>{let e=Ee(r,S.operationId);e&&r.act({kind:`open`,target:e})},children:`Open run`})]}):(0,W.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),!ee&&!h&&w()},children:[Object.entries(o.properties??{}).filter(([e])=>e in s||o.required?.includes(e)).map(([e,n])=>(0,W.jsx)(Nt,{name:e,path:ne(e),schema:n,value:s[e],snapshot:t,problems:te(ne(e)),onValue:t=>c(n=>({...n,[e]:t})),onUnparsed:(e,t)=>u(n=>{let r={...n};return t===null?delete r[e]:r[e]=t,r})},e)),d&&te(`/input`).filter(e=>!Object.keys(o.properties??{}).some(t=>e.path.startsWith(ne(t)))).map((e,t)=>(0,W.jsxs)(`p`,{role:`alert`,className:`shell-field-problem`,children:[e.message,e.fix?` · `+e.fix:``]},t)),_&&(0,W.jsx)(`p`,{role:`alert`,className:`shell-field-problem`,children:_}),y&&(0,W.jsxs)(`p`,{role:`status`,"data-rho-lost":i.operationId,children:[`The reply did not arrive, and the project's runs do not show `,i.operationId,` yet. Sending it again cannot start a second run.`]}),(0,W.jsxs)(`div`,{className:`shell-action-submit`,children:[(0,W.jsx)(`button`,{type:`submit`,disabled:ee||h||!x(`action.submit`),children:h?`Submitting…`:y?`Send again`:`Run`}),p?(0,W.jsx)(`span`,{role:`status`,children:`Checking…`}):d?.length?(0,W.jsxs)(`span`,{role:`status`,children:[d.length,` to fix`]}):null]})]})]}):(0,W.jsxs)(`section`,{className:`shell-action`,"data-owner-body":``,"aria-label":i.title??i.action,children:[(0,W.jsx)(`h2`,{children:i.title??i.action}),(0,W.jsxs)(`p`,{role:`status`,children:[i.action,` `,i.actionVersion,` is not registered in this project.`]})]})}function Nt({name:e,path:t,schema:n,value:r,snapshot:i,problems:a,onValue:o,onUnparsed:s}){let c=(0,O.useId)(),l=jt(n,r),u=a.filter(e=>l!==`object`||e.path===t),[d,f]=(0,O.useState)(()=>JSON.stringify(r??null,null,2)),[p,m]=(0,O.useState)(``),h=u.length||p?c+`-problem`:void 0,g={id:c,"aria-invalid":!!h||void 0,"aria-describedby":h},_;if(l===`object`){let c=r;return(0,W.jsxs)(`fieldset`,{className:`shell-field-group`,children:[(0,W.jsx)(`legend`,{children:e}),Object.entries(n.properties??{}).filter(([e])=>e in c||n.required?.includes(e)).map(([e,n])=>(0,W.jsx)(Nt,{name:e,path:t+`/`+e,schema:n,value:c[e],snapshot:i,problems:a.filter(n=>n.path===t+`/`+e||n.path.startsWith(t+`/`+e+`/`)),onValue:t=>o({...c,[e]:t}),onUnparsed:s},e)),u.map((e,t)=>(0,W.jsxs)(`p`,{role:`alert`,className:`shell-field-problem`,children:[e.message,e.fix?` · `+e.fix:``]},t))]})}if(l===`reference`){let t=(Array.isArray(r)?r:[r]).map(e=>typeof e==`string`?kt(e)?`A pinned version`:e:At(e,i)??`A pinned reference`);return(0,W.jsxs)(`div`,{className:`shell-field`,children:[(0,W.jsx)(`span`,{className:`shell-field-name`,id:c,children:e}),(0,W.jsx)(`ul`,{className:`shell-field-references`,"aria-labelledby":c,"data-rho-reference":e,children:t.map((e,t)=>(0,W.jsx)(`li`,{children:e},t))}),u.length>0&&(0,W.jsx)(`p`,{role:`alert`,className:`shell-field-problem`,children:u.map(e=>e.message+(e.fix?` · `+e.fix:``)).join(` · `)})]})}return _=l===`choice`?(0,W.jsx)(`select`,{...g,value:String(r??``),onChange:e=>o(e.target.value),children:n.enum.map(e=>(0,W.jsx)(`option`,{value:e,children:e},e))}):l===`text`?(0,W.jsx)(`input`,{...g,value:String(r??``),onChange:e=>o(e.target.value)}):l===`optional-text`?(0,W.jsx)(`input`,{...g,value:typeof r==`string`?r:``,onChange:e=>o(e.target.value===``?null:e.target.value)}):l===`number`?(0,W.jsx)(`input`,{...g,type:`number`,value:r===void 0?``:String(r),min:n.minimum,max:n.maximum,step:Et(n)===`integer`?1:`any`,onChange:e=>o(e.target.value===``?void 0:Number(e.target.value))}):l===`boolean`?(0,W.jsx)(`input`,{...g,type:`checkbox`,checked:r===!0,onChange:e=>o(e.target.checked)}):l===`lines`?(0,W.jsx)(`textarea`,{...g,rows:Math.min(8,Math.max(2,r.length+1)),value:r.join(`
3
3
  `),onChange:e=>o(e.target.value===``?[]:e.target.value.split(`
4
4
  `))}):(0,W.jsx)(`textarea`,{...g,className:`shell-field-json`,rows:Math.min(10,Math.max(2,d.split(`
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "format": "rho.web-build/1",
3
3
  "uiProtocol": "0.1-draft",
4
- "rendererBuild": "3b349e536ff70ed5bfcf74df245c2b6806cd8689ba0ca31c1d1f3a560cb55f29",
4
+ "rendererBuild": "094bee327d7964c2c6ea9fe3db6d35899545d090074c964d0cdb056f556471f1",
5
5
  "ownerEntries": [
6
6
  {
7
7
  "plugin": "documents",
@@ -60,7 +60,7 @@
60
60
  "component": "rho.agent-note",
61
61
  "version": "0.2.0",
62
62
  "source": "web/entries/agent.tsx",
63
- "packageVersion": "0.4.29",
63
+ "packageVersion": "0.4.30",
64
64
  "entrySha256": "0e18d175dfc25fd8e237ec0341422e0d1311d2d8882e487962e8c7c25794d69e"
65
65
  },
66
66
  {
@@ -255,7 +255,7 @@
255
255
  {
256
256
  "path": ".vite/manifest.json",
257
257
  "bytes": 23614,
258
- "sha256": "c005620ae7168c671f7a2b1bfcf1d41ac06d4f9a86d1424dd8e0262574327f3e"
258
+ "sha256": "2dc60f63158b05c257607125515a2cdd1c31059f96cf596a31c88bb20dbf6576"
259
259
  },
260
260
  {
261
261
  "path": "assets/answer-board-CBkGbSLD.js",
@@ -268,34 +268,24 @@
268
268
  "sha256": "cd9dfbef068bacb28e1327cd137b26fff32004288a0827152ec532abc24f7558"
269
269
  },
270
270
  {
271
- "path": "assets/choices-b0XhrGQV.js",
271
+ "path": "assets/choices-D-YfnFP6.js",
272
272
  "bytes": 11096,
273
- "sha256": "53dcc1371554e3bd7a498e014a14bdd1d8b88f38779b2ae99d0b3508c7bd334b"
273
+ "sha256": "29d0563c9bf57492a6aee0c373d1da152594435c35708b5d2b6a7c79f18f6a33"
274
274
  },
275
275
  {
276
276
  "path": "assets/choices-DLah50GC.css",
277
277
  "bytes": 1659,
278
278
  "sha256": "2285c02644e12f379880df802cd34ed6262d73a159aeb9a12e80de44f12db447"
279
279
  },
280
- {
281
- "path": "assets/console-BSjLGe0T.js",
282
- "bytes": 21020,
283
- "sha256": "a00778dfaf497479106979941bb938bc2bc12b2548229bad026db0444bad236f"
284
- },
285
280
  {
286
281
  "path": "assets/console-By4Mvn1y.css",
287
282
  "bytes": 3779,
288
283
  "sha256": "38fdefe20f181e6a050793f715a13bcbde2e9c167f80f554a775e3578dcd78bc"
289
284
  },
290
285
  {
291
- "path": "assets/dist-Buk0lwzI.js",
292
- "bytes": 183314,
293
- "sha256": "345aa1f35697b2ac10b7f7675c5945f684ffa7aa6f7d5e19c628691c2c062dd3"
294
- },
295
- {
296
- "path": "assets/dist-Cw8hRIlT.js",
297
- "bytes": 35411,
298
- "sha256": "6bc9507492e252c592d32bb496698906c50f8a7c24d68dfd91d47a740986eadc"
286
+ "path": "assets/console-Trqc0swD.js",
287
+ "bytes": 21020,
288
+ "sha256": "c0e7821902b6e19724d259aec4aa115ed7462402eec0a3f6452df10f3152a10c"
299
289
  },
300
290
  {
301
291
  "path": "assets/dist-DCtcCJPs.js",
@@ -303,19 +293,29 @@
303
293
  "sha256": "9deb65f8b227a08473b422b448735f045aa2251acf498f169640f7d38d96173e"
304
294
  },
305
295
  {
306
- "path": "assets/dist-foH9IKc6.js",
296
+ "path": "assets/dist-DpIHRk3B.js",
297
+ "bytes": 35411,
298
+ "sha256": "22bf26faa31efb7f46296f6fc4f3b831bcf9303056c1b9bf9bb1b0fc0c58cdd3"
299
+ },
300
+ {
301
+ "path": "assets/dist-DZmszrjG.js",
302
+ "bytes": 183314,
303
+ "sha256": "0879df241ab3ba4064054d6c5f44a70ee10ad2f32b7d249107c143578dd891de"
304
+ },
305
+ {
306
+ "path": "assets/dist-eMx6b8N1.js",
307
307
  "bytes": 44651,
308
- "sha256": "d6cde09d1e887a5e9ccd174b5424a4cd221fd8925fa798b78e72809603c54cfe"
308
+ "sha256": "f0e536da7c98837e3b7841fbaf1e6eef294bb1d6fb5a939e923ec6d605ef56cd"
309
309
  },
310
310
  {
311
- "path": "assets/dist-Tzoe_zm-.js",
311
+ "path": "assets/dist-pF902jHA.js",
312
312
  "bytes": 37492,
313
- "sha256": "3d46a1e1e8b62f03387b5bc58ed26e96f6dd7a7e69d3e60a4fb1aa274ef9a494"
313
+ "sha256": "d2af94b048491a451eb7225abd3c581843d8e4370708c7a5f2dd4d984b7fc2f5"
314
314
  },
315
315
  {
316
- "path": "assets/explore-in-BVUy3ZW_.js",
316
+ "path": "assets/explore-in-BCHqjJ7B.js",
317
317
  "bytes": 782,
318
- "sha256": "a1fefc75676c96992b581d3429e519ee54599bde934edbdb035937bec560e62c"
318
+ "sha256": "75cea34047fd256982cea015a63bc82a39e3819c6bd8bcabe684893852ec7127"
319
319
  },
320
320
  {
321
321
  "path": "assets/facts-BMO6V3-3.js",
@@ -327,30 +327,30 @@
327
327
  "bytes": 18546,
328
328
  "sha256": "413304efcb99472948f1c20b997d0a0f9a4a6c84f2255338fef001ddfe8408b4"
329
329
  },
330
- {
331
- "path": "assets/graph-1OdIJ9l7.js",
332
- "bytes": 48768,
333
- "sha256": "cdbeeeafd4c5a13544309bba4899963f30ced19ad1f17decc05f0be7689f5088"
334
- },
335
330
  {
336
331
  "path": "assets/graph-BYKN84J3.css",
337
332
  "bytes": 24857,
338
333
  "sha256": "e84aa51d7376fc0a6104c0b140821c54bc25a2b55be32be6005e08b85dd7e0df"
339
334
  },
335
+ {
336
+ "path": "assets/graph-lENgfQNH.js",
337
+ "bytes": 48768,
338
+ "sha256": "39361c04da7930383cb5b0fd9753b1cbdb28d186c514da92cc13a4524ef3ef97"
339
+ },
340
340
  {
341
341
  "path": "assets/home-CCbP6kS-.js",
342
342
  "bytes": 12617,
343
343
  "sha256": "6bbbe67af01bd03b2777abcc02e63dda1bad1fa7aaf9296b07cda04ac481e7cb"
344
344
  },
345
345
  {
346
- "path": "assets/index-CsC3sTRq.css",
347
- "bytes": 114371,
348
- "sha256": "f305fffa17b37918b85c86996a24140e19b9d33e1214b3def5fbad04ada940dc"
346
+ "path": "assets/index-B3_OVy91.css",
347
+ "bytes": 114009,
348
+ "sha256": "15692810923cc0bcc8e4eb08df8a9ec0ca8ebaf8a05c754b6589052603869201"
349
349
  },
350
350
  {
351
- "path": "assets/index-CxmItXqa.js",
352
- "bytes": 1779546,
353
- "sha256": "9372a2cd0c090b7e1077d24f8f206db1d93db79419865c2cf6e99f7cedc939f3"
351
+ "path": "assets/index-BpL_Kl_s.js",
352
+ "bytes": 1779367,
353
+ "sha256": "0944ee8e42207a963f7be95c817b58648651f8cd2ccae0f475c265a105234038"
354
354
  },
355
355
  {
356
356
  "path": "assets/KaTeX_AMS-Regular-BQhdFMY1.woff2",
@@ -663,14 +663,14 @@
663
663
  "sha256": "717274e2c02c05db67e7f1bf6fec4dfae799f3a2780ea7a95c4fdf0d160dfab8"
664
664
  },
665
665
  {
666
- "path": "assets/notes-meaning-pVbbQUGP.js",
666
+ "path": "assets/notes-meaning-DcVGUBBY.js",
667
667
  "bytes": 5850,
668
- "sha256": "ba4560479d571ec61395840496b0e2e05c2c126e595c65f5814103f1d68affaa"
668
+ "sha256": "4af65e597d04917ac151c30f91f0811139350b3758132686729f8d49f63f849b"
669
669
  },
670
670
  {
671
- "path": "assets/overview-B9UtVJ32.js",
671
+ "path": "assets/overview-CDnVKlOt.js",
672
672
  "bytes": 48647,
673
- "sha256": "12207a8d05b37a007d55505143c8fea36509c976573bd86885204e7103d58c91"
673
+ "sha256": "a4e4bf4b0bfbbd3a73fbb216dcee730e46e83bb260fab25f836406db93840b14"
674
674
  },
675
675
  {
676
676
  "path": "assets/overview-CmC7mah4.css",
@@ -678,9 +678,9 @@
678
678
  "sha256": "f6b19e1fbbb7cc884faff634b6f7b016f806313b946600b11bbf76dc59caf1a9"
679
679
  },
680
680
  {
681
- "path": "assets/preview-CksD_5KS.js",
681
+ "path": "assets/preview-BEC1E9MK.js",
682
682
  "bytes": 4703,
683
- "sha256": "1bad11efd47741dc1817f88234e38f5d0d478909a98c38b4397b44d4373b8ff7"
683
+ "sha256": "9888dc22cea50e3757542e144c09fc85bf53fc3abc212955a8af6ae059d155fa"
684
684
  },
685
685
  {
686
686
  "path": "assets/r-CxDmU1I4.js",
@@ -698,9 +698,9 @@
698
698
  "sha256": "364a909acd2231cafe737e8f9b19ad58ba16d3b6cbb90b0de78015dd437bd56b"
699
699
  },
700
700
  {
701
- "path": "assets/review-CMxQlQ-C.js",
701
+ "path": "assets/review-DYP0aCXb.js",
702
702
  "bytes": 4860,
703
- "sha256": "7cb8a5c22a14c0b163c25022ba05582484884e83151f838d0856ad635f8ce88a"
703
+ "sha256": "6059e4b493405b191cae348f63ce7ae32ae97e8165710adeee0d26672405576e"
704
704
  },
705
705
  {
706
706
  "path": "assets/rolldown-runtime-XKyaHtl9.js",
@@ -708,9 +708,9 @@
708
708
  "sha256": "548d1dbf321e7d2ae804fcc158b588706a7c52f8ca175de1490c6ccb4dbe55b7"
709
709
  },
710
710
  {
711
- "path": "assets/skills-BFNSyrnD.js",
711
+ "path": "assets/skills-1ec0Z-jx.js",
712
712
  "bytes": 12538,
713
- "sha256": "5207aa503328e407dee96aa07be5c6f707b21069f6684650566a3819ea47cd17"
713
+ "sha256": "aeaf67104b99a56d368f41e6f2ddceb82c179f5309281258a8cecf50c8cc264b"
714
714
  },
715
715
  {
716
716
  "path": "assets/skills-WkE0KCzn.css",
@@ -718,9 +718,9 @@
718
718
  "sha256": "162823ce43fd1e1f2bd92a330516c171280b59a0b5460752f0d7aba5f194f3eb"
719
719
  },
720
720
  {
721
- "path": "assets/skills-work-BGPSnF_I.js",
721
+ "path": "assets/skills-work-DNexV4OJ.js",
722
722
  "bytes": 2528,
723
- "sha256": "1e61e6767a7744a7a120e34092ec70a68b80f22b0c01e56d56556790d9b251a8"
723
+ "sha256": "3f30614690b9199ece7838ab8076bb902f6f2fb619ff03dd568806b562ac1fa9"
724
724
  },
725
725
  {
726
726
  "path": "assets/snapshot-CAxBYPvV.js",
@@ -733,29 +733,29 @@
733
733
  "sha256": "7acddf1303643a15a8df990808a42e218033edf56b8c03b0fcc8271683b0195f"
734
734
  },
735
735
  {
736
- "path": "assets/studio-process-CsRoTHOh.js",
736
+ "path": "assets/studio-process-EYQgikxq.js",
737
737
  "bytes": 22888,
738
- "sha256": "98e6c6bfcbd2ab43f657dc34772a14884723cfffe4e2af7e2ec1e37f04cd5709"
738
+ "sha256": "055ece65b0ba5c0b6787daaa834bdd4e09aeb66a0fb062735114a5fa40c0fa3e"
739
739
  },
740
740
  {
741
- "path": "assets/timeline-events-BbuuFWHV.js",
741
+ "path": "assets/timeline-events-Chj2Gbx7.js",
742
742
  "bytes": 2227,
743
- "sha256": "860f7d40a19244286dbb7771c45992000f282f7f7603db8c273f2fb6090525a4"
743
+ "sha256": "be716e87f5a47e4e602a0d326e84cfb8e5e701abe10ae484e3f23fdb3587c3ff"
744
744
  },
745
745
  {
746
- "path": "assets/work-turns-BvJlIMmA.js",
746
+ "path": "assets/work-turns-CT9RVcWY.js",
747
747
  "bytes": 1460,
748
- "sha256": "57995cc85aa24db8834e6047ff5227110042e8e13d3fce2ecd6c1e48c2336e7c"
748
+ "sha256": "2270b5c2510a3b04a642621a345ead825c44bc7896b7231a3fbfb24903f62e3f"
749
749
  },
750
750
  {
751
- "path": "assets/workspace-CWlkjLNx.js",
751
+ "path": "assets/workspace-COmCbGV3.js",
752
752
  "bytes": 81815,
753
- "sha256": "82a8a02610fd34227bd91ed60a4c918c8a25e857b44ce126c4c6053b46351366"
753
+ "sha256": "d55693dd507204b35dd28f7e8723e9e15a425d05f8b727c55d73e7866b1f7562"
754
754
  },
755
755
  {
756
756
  "path": "index.html",
757
757
  "bytes": 1142,
758
- "sha256": "145025b89b02370b28af3c5295572c9f6edc87d8cb767a171d9243a255a51671"
758
+ "sha256": "d304ba22383bd32eba1e0ab88319c127fe05a0d255fc178253a79a0b6ce22425"
759
759
  },
760
760
  {
761
761
  "path": "licenses.md",
@@ -765,10 +765,10 @@
765
765
  {
766
766
  "path": "renderer.json",
767
767
  "bytes": 85,
768
- "sha256": "068fe23a6be66244df9c7c9aaa25986182541bb896e55c974cdc6174114336c3"
768
+ "sha256": "05327600965d5e945f3f6b239255194b3a90324408889b7dc2508a98cf4c1440"
769
769
  }
770
770
  ],
771
- "assetsSha256": "8c4dfdbb9df9b547648487cb3dadf4c44b2d0f5760d01e563bcc4caccd66bca6",
771
+ "assetsSha256": "75bcc4b9c1aee998d3112cc11bae15e86356104151ecea4f81826d5c3d13ec5a",
772
772
  "licenses": "licenses.md",
773
773
  "node": "v22.23.4"
774
774
  }
@@ -6,13 +6,13 @@
6
6
  <meta name="color-scheme" content="light" />
7
7
  <title>Rho Workspace</title>
8
8
  <link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='8' fill='%231e6b52'/%3E%3Ctext x='16' y='23' font-family='Georgia,serif' font-size='22' text-anchor='middle' fill='white'%3E%CF%81%3C/text%3E%3C/svg%3E" />
9
- <script type="module" crossorigin src="/assets/index-CxmItXqa.js"></script>
9
+ <script type="module" crossorigin src="/assets/index-BpL_Kl_s.js"></script>
10
10
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-XKyaHtl9.js">
11
11
  <link rel="modulepreload" crossorigin href="/assets/react-Dss-ouuy.js">
12
12
  <link rel="modulepreload" crossorigin href="/assets/markdown-0ngRuTpW.js">
13
13
  <link rel="modulepreload" crossorigin href="/assets/home-CCbP6kS-.js">
14
14
  <link rel="modulepreload" crossorigin href="/assets/canvas-D8rDdfDz.js">
15
- <link rel="stylesheet" crossorigin href="/assets/index-CsC3sTRq.css">
15
+ <link rel="stylesheet" crossorigin href="/assets/index-B3_OVy91.css">
16
16
  </head>
17
17
  <body>
18
18
  <div id="root"></div>
@@ -1 +1 @@
1
- {"rendererBuild":"3b349e536ff70ed5bfcf74df245c2b6806cd8689ba0ca31c1d1f3a560cb55f29"}
1
+ {"rendererBuild":"094bee327d7964c2c6ea9fe3db6d35899545d090074c964d0cdb056f556471f1"}
package/docs/FRONTEND.md CHANGED
@@ -249,21 +249,25 @@ inspect what happened. The application gives those actions direct places:
249
249
  - **Files** opens documents, browses the project's folder and the source folders it
250
250
  works in, and filters the current folder. A source folder is named as the person
251
251
  named it and opens one level at a time, the same way any other folder does.
252
- - **Agent** (the sidebar row) has three tabs. Conversations lists those started in Rho
253
- by day, searchable and by Agent: each row its title, model, effort, messages, state,
254
- context use and cost, with Continue, export as Markdown and the trash; opened, its
255
- facts beside what its latest messages did (the files changed and looked at, each
256
- shown in place when chosen, the commands and the answer). The trash restores or
257
- deletes. Runs follow when there are any, with their execution records, output,
258
- repair context and exports. Agents shows Claude Code and Codex: version, whether
259
- asked, the default, model, settings, Claude Code's own model names and the providers
260
- with their models. Outside Rho adds Rho to the person's own Claude Code or Codex with
261
- one button (`session.connect`) and shows three steps in the state Rho observes:
262
- access to this project, Rho in that Agent, its first call; Other ACP clients gives
263
- the `rho --acp` commands. Core-backed Claude Code/dsh activity streams, native errors
264
- and observed output files sit below in a section read only while it is open
265
- ([activity episode](AGENT-ACTIVITY.md), [Agents and conversations](AGENT-PAGE-EPISODE.md),
266
- [Agents outside Rho](AGENT-PANEL-EPISODE.md#agents-outside-rho)).
252
+ - **Agent** (the sidebar row) has two tabs. Conversations lists every session in
253
+ the project folder by day, searchable and by Agent: Rho's conversations, Claude
254
+ Code and Codex sessions read from the Agents' own records, and observed Harness
255
+ conversations. Each row names where the session started (Terminal, VS Code, Codex
256
+ app, Script…) and whether another window has it open now, and offers Continue,
257
+ the terminal resume command, Markdown export and the trash
258
+ ([session continuity](SESSION-CONTINUITY-EPISODE.md)). Agents lists the Agents
259
+ this service can start, with the one new conversations use, its model and folded
260
+ settings; an Agent not found on this computer is greyed out. Below it, one setup
261
+ prompt is for the person's own local MCP client. The prompt names
262
+ the running installation and exact existing project; the Agent configures its
263
+ own client. Reading or copying grants no access. Connections are listed by their
264
+ actual session labels, with access waiting for a call, a verified last call,
265
+ refusal or ended access. Copy failure leaves selectable text; request failure
266
+ offers retry. ACP observations and Host activity remain under a disclosure
267
+ ([connection episode](AGENT-CONNECT-EPISODE.md)). Conversation rows retain title,
268
+ model, effort, messages, state, usage, cost and their files, commands and answers;
269
+ the trash restores or deletes. Runs follow when present
270
+ ([Agents and conversations](AGENT-PAGE-EPISODE.md)).
267
271
  - **Project settings** manages source folders and explicitly checks available tools.
268
272
  - **Studio** shows how a conversation's work was done. The sidebar lists under Studio
269
273
  each session started in Rho, newest first (eight, then All sessions), and then the
@@ -572,8 +576,9 @@ Shared notes opens `project-notes.md` in the existing Documents owner. A failed
572
576
  view and offers Refresh. The cursor invalidates the read model; individual sources
573
577
  and resources retain their own versions. See the [observed loop](ACP-EPISODE.md#shared-workspace-loop).
574
578
  External ACP sessions use the same work surface with their own source identity,
575
- plans, usage and read-only latest reply. Their input and permission choices stay
576
- in the original client. The visible Overview rereads external projections every
579
+ plans, usage and read-only latest reply there. Their permission choices stay in the
580
+ original client; the Agent panel continues such a session in the folder once no
581
+ other window holds it. The visible Overview rereads external projections every
577
582
  1.5 seconds; it does not start a collector, Agent or Host. Turn cancellation keeps
578
583
  unfinished tool outcomes unknown and does not claim all native processes exited.
579
584
 
@@ -607,7 +612,10 @@ A conversation's messages, steps and endings belong to the service's record, not
607
612
  the tab. The tab keeps only an unsent message per conversation and the identity of
608
613
  a message being sent. When the reply to a send is lost, Retry sends that same message
609
614
  once; when the service refuses it, the words go back into the box. A session started
610
- elsewhere has no message box in Rho: its input stays in its own window.
615
+ elsewhere opens in the same panel with its history, its turns marked with where they
616
+ were sent, and its next message continues that session. While another window holds
617
+ it, the box is disabled with where it is open and a link to continue a copy; Rho
618
+ reloads a session whose record changed after its own last message.
611
619
 
612
620
  The palette and responsive dialogs use native dialog focus containment and Escape.
613
621
  Typography, color and layout are implemented in the three CSS files under `web/`.
package/docs/HEADLESS.md CHANGED
@@ -132,38 +132,47 @@ Exact Host and supplied Origin are checked. The bearer credential is project
132
132
  scoped for external callers. CLI shutdown stops only Hosts started by this
133
133
  service and reports confirmation separately. Existing Hosts keep their owner.
134
134
 
135
- ### Connect Claude Code or Codex
135
+ ### Connect your own Agent
136
136
 
137
- The running service's operator connection adds Rho to the person's own Claude Code
138
- or Codex for one project, as the project page's "Add to …" button does:
137
+ The project's **Agent → Agents** tab offers one prompt for any Agent
138
+ that can configure and run a local stdio MCP server. `session.instructions` is a
139
+ read-only operation for the local browser or operator: it returns the current
140
+ Node/launcher paths and existing project ID, without credential contents. Reading
141
+ or copying starts no Agent, grants no access and edits no client configuration.
142
+ The Agent uses its own supported configuration mechanism; Rho needs no additional
143
+ brand-specific form. The [connection episode](AGENT-CONNECT-EPISODE.md) records the
144
+ actual clients checked and the limits.
139
145
 
140
- ```sh
141
- rho --grant /absolute/service-state/connection.json --project PROJECT_FOLDER --agent claude-code|codex
142
- ```
143
-
144
- It gives that Agent its own grant to the project (kept when it still reaches the
145
- service), runs that Agent's `mcp remove` and `mcp add` on this machine — Claude Code's
146
- with `-s local` in the project folder, Codex's for every folder — and records it, so the
147
- page shows it under that Agent. The JSON reply names the project, its root, the number
148
- of granted methods, whether a new grant was made, and what was added (`name`, `scope`,
149
- `at`). A session that was already open does not have the tools; a new one does.
150
-
151
- Without `--agent`, the same connection grants one project to one Agent session and
152
- prints how Claude Code starts that session's MCP server:
146
+ The running service's operator connection grants one project to a named Agent:
153
147
 
154
148
  ```sh
155
- rho --grant /absolute/service-state/connection.json --project PROJECT_FOLDER [--session NAME]
149
+ rho --grant /absolute/service-state/connection.json \
150
+ --project-id EXISTING_PROJECT_ID --session my-agent
156
151
  ```
157
152
 
158
- `--project` is the folder relative to `--root`; `--session` defaults to
159
- `claude-code`, the session `--agent claude-code` uses, and `--session codex` is the one
160
- `--agent codex` uses. When the service is not running, both forms say so and exit 1. The JSON reply names the project, the private session connection
161
- file, the number of granted methods (the server default), an `mcp` entry
162
- (`name`, `command`, `args`) for an MCP configuration file, and the equivalent
163
- `claude mcp add rho-<folder> -- … --mcp <file>` command. `rho --mcp FILE` serves
164
- that grant on stdio with the four tools `rho_index`, `rho_resolve`, `rho_call` and
165
- `rho_read`; nothing else writes to stdout in that mode. Every connection file is a
166
- credential. `rho --help` prints the usage; an unknown option exits 2 with it.
153
+ `--project-id` selects an already registered project, including one chosen outside
154
+ the service's projects folder. The older `--project PROJECT_FOLDER` form remains
155
+ available for a folder relative to `--root`; select exactly one form. Choose a
156
+ stable session name for each Agent and reuse it on retry. Without `--session`, the
157
+ legacy default is `claude-code`.
158
+
159
+ The JSON reply supplies `mcp.name`, `mcp.command` and `mcp.args` for the Agent to
160
+ register in its own client. `rho --mcp FILE` serves that project grant on stdio with
161
+ `rho_index`, `rho_resolve`, `rho_call` and `rho_read`. Connection files are credentials;
162
+ keep their contents out of prompts and projects. The reply also retains the older
163
+ `claude` command for compatibility.
164
+
165
+ Repeating the same grant keeps a valid credential with the same project, methods
166
+ and profile; changing scope, expired access or stale connection data requires a
167
+ fresh one. A client may need to reload its tools or open a new session. A saved
168
+ entry alone does not verify a connection: call `rho_index` in that client and check
169
+ its project scope. The page observes grants and actual calls separately and does
170
+ not claim that an old successful call means the Agent is online now.
171
+
172
+ The existing `--agent claude-code|codex` shortcut and `session.connect` remain
173
+ available. They use those clients' own `mcp add` commands (Claude Code in the project
174
+ folder, Codex in user configuration). They are no longer the page's setup workflow.
175
+ A stopped service is reported with exit 1; an unknown CLI option exits 2 with usage.
167
176
 
168
177
  Agent 0.4.11 provides persistent Claude and Codex ACP entries and retains each
169
178
  tool step's human title, ACP category and one identifying input (command, file path,
@@ -279,7 +288,8 @@ const check = await rho.call('requirements.check', {
279
288
  | `context.create/read` | Exact buffer/version/range, declared selected entities, a media rectangle with page and pixels/points, or one run (`run: {operationId}`): its state, exit, stop, the last 8 KiB of retained stderr with its byte offset and Core's truncation flag, the script reference, args and declared files. |
280
289
  | `session.grant`, `binding.open/close/list/activity` | Operator-selected method grant, external binding metadata and bounded tool receipts. Agent grants include the read-only `project.entries` and no other `project.*` method. |
281
290
  | `session.connect` | The person at this machine only: grants Claude Code or Codex access to one project and runs that Agent's own `mcp add` (`claude mcp add -s local` in the project folder, `codex mcp add`) with the project-scoped connection. A grant that still reaches this service is kept; a new one the Agent refuses is removed. Each CLI call: 20 s and 8 KiB of output, then stopped with what it printed. |
282
- | `conversation.start/send/stop/read/permission` | Only the browser on this machine. Original message identities, retained text/tool steps and one selected Agent session. New conversations use the selected Claude or Codex ACP connection. Cancel is confirmed by the original prompt response; lost transport keeps an unknown outcome. Reads and reconnect never replay a prompt. Native permission choices are scoped to the original pending request. Limits are in `conversationLimits` and `--limits`. |
291
+ | `conversation.start/send/stop/read/permission` | Only the browser on this machine. Original message identities, retained text/tool steps and one selected Agent session. New conversations use the selected Claude or Codex ACP connection; `continue: {session, copy}` instead loads a session listed by `agent.sessions.list` under its own native ID, or forks it, and is refused while another process holds that session. Cancel is confirmed by the original prompt response; lost transport keeps an unknown outcome. Reads and reconnect never replay a prompt. Native permission choices are scoped to the original pending request. Limits are in `conversationLimits` and `--limits`. |
292
+ | `agent.sessions.list/read` | Only the browser on this machine; excluded from Agent grants. Claude Code and Codex sessions in the project folder read from their own records, and observed Harness conversations, each with where it started, whether another window holds it now and its resume command. Reading starts no Agent and is bounded (`nativeSessionLimits` in the Agent plugin). |
283
293
  | `composition.put/read/apply/undo`, `view.close` | Registered entry/version, props and binding checks; `apply`/`undo` are conditional tree transactions with receipts ([Collaboration](COLLABORATION.md#composition-and-selection)). Uninstalled UI is explicitly unavailable. `rho.action` (version `1`, no bindings) is Rho's own form for one proposed action: props `{title, action, actionVersion, operationId, input, repairOf?}`, and the action must be registered at that version. |
284
294
  | `workspace.save/export/restore` | Drafts/undo, bytes/provenance, selections and composition intent; native execution is not replayed. |
285
295
  | `action.export` | One run as ordinary files in a new project folder (default `exports/<operationId>`): `script/` holds the code that ran, from the run's own record; `outputs/` holds each declared file as the run left it; `provenance.json` and `PROVENANCE.md` give the run, script digest, arguments, inputs, each file's SHA-256 and whether it matches the inventory the run wrote. A declared file that was not written, or no longer matches that inventory, is named and left out, and the export says `partial`. When the script has unsaved changes the call must say `unsaved: "include"` (written as `<name>.unsaved.<ext>`, marked as never run) or `"leave"`. Runs nothing; never writes into an existing folder. |