@kubitnodes/stellaris 0.3.24 → 0.3.26

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 (70) hide show
  1. package/dist/cli/index.js +99 -553
  2. package/dist/server/index.js +318 -581
  3. package/package.json +4 -4
  4. package/web/dist/assets/BackLink-UTiLF1J4.js +1 -0
  5. package/web/dist/assets/Button-Cp4cNRUX.js +1 -0
  6. package/web/dist/assets/ChannelForms-DD2B0tey.js +1 -0
  7. package/web/dist/assets/{ChannelView-BIXouQMX.js → ChannelView-CY3oG9hZ.js} +2 -2
  8. package/web/dist/assets/CitizenView-BNK5ro-6.js +2 -0
  9. package/web/dist/assets/{CitizensView-CYFS3f9U.js → CitizensView-WPQ6Jhl3.js} +1 -1
  10. package/web/dist/assets/{CliIcon-DVX5iLhG.js → CliIcon-C7bwChMP.js} +1 -1
  11. package/web/dist/assets/CronsView-_pdgwX1I.js +1 -0
  12. package/web/dist/assets/FileTree-jyDUSu7g.js +1 -0
  13. package/web/dist/assets/FileView-DcQvlc8V.js +4 -0
  14. package/web/dist/assets/KnowledgeView-DDl0HQPG.js +1 -0
  15. package/web/dist/assets/{Markdown--whKJBYV.js → Markdown-DT3V-EVe.js} +7 -7
  16. package/web/dist/assets/{MessageItem-BvDOeJci.js → MessageItem-agtEugfG.js} +1 -1
  17. package/web/dist/assets/MetricsView-DiXyYeWP.js +1 -0
  18. package/web/dist/assets/NeedsYouView-CKmuYan_.js +1 -0
  19. package/web/dist/assets/Overview-CKcTqsMM.js +1 -0
  20. package/web/dist/assets/{Pane-DTmByqgA.js → Pane-BaM0TdE6.js} +1 -1
  21. package/web/dist/assets/{Picker-DsHm4f7s.js → Picker-C2ig-0dT.js} +1 -1
  22. package/web/dist/assets/ProjectView-T2OHTh5j.js +1 -0
  23. package/web/dist/assets/ProposalView-B5yjTAcn.js +1 -0
  24. package/web/dist/assets/ProposalsView-p4KjwV9p.js +1 -0
  25. package/web/dist/assets/{Quota-D8WDWp5H.js → Quota-CfFGIql9.js} +1 -1
  26. package/web/dist/assets/RunnersView-DdvwoOur.js +1 -0
  27. package/web/dist/assets/{SkillFileList-DhdEcFQA.js → SkillFileList-CgrCnuaC.js} +1 -1
  28. package/web/dist/assets/SkillView-Di5Z9h2L.js +1 -0
  29. package/web/dist/assets/SocietyView-BDiVxUC5.js +1 -0
  30. package/web/dist/assets/StickyList-BaV_KZ8x.js +1 -0
  31. package/web/dist/assets/{SubjectThread-BEXt-tub.js → SubjectThread-DD_ZCCnr.js} +1 -1
  32. package/web/dist/assets/TaskView-CKcs-MOC.js +3 -0
  33. package/web/dist/assets/TasksView-oZMjncOU.js +1 -0
  34. package/web/dist/assets/{ThreadForms-DzoRDeBh.js → ThreadForms-CG5Y926b.js} +1 -1
  35. package/web/dist/assets/{ThreadItem-CDVppcOZ.js → ThreadItem-D-n2arFA.js} +1 -1
  36. package/web/dist/assets/{ThreadView-B4F10_j1.js → ThreadView-CT9vd0P4.js} +1 -1
  37. package/web/dist/assets/{citizen-BPIJzKdn.js → citizen-BiHfph2A.js} +1 -1
  38. package/web/dist/assets/{compose-BUhbVoI-.js → compose-DY1WL8zB.js} +1 -1
  39. package/web/dist/assets/format-CENiwkJC.js +55 -0
  40. package/web/dist/assets/governance-C6ez5MLh.js +1 -0
  41. package/web/dist/assets/index-CPXALUV6.js +23 -0
  42. package/web/dist/assets/{index-Bj8MlyAn.css → index-DIa8Dlav.css} +1 -1
  43. package/web/dist/assets/mentions-BEL5U6ra.js +3 -0
  44. package/web/dist/assets/{tasks-CTaxXtGL.js → tasks-CAI8Eci7.js} +1 -1
  45. package/web/dist/assets/useMatch-CINzyDWa.js +1 -0
  46. package/web/dist/index.html +9 -9
  47. package/web/dist/assets/BackLink-DKMw_rHu.js +0 -1
  48. package/web/dist/assets/Button-BYJGqZ3Q.js +0 -1
  49. package/web/dist/assets/ChannelForms-CkYupEL2.js +0 -1
  50. package/web/dist/assets/CitizenView-C3AMFixP.js +0 -2
  51. package/web/dist/assets/CronsView-BGCcO7bH.js +0 -1
  52. package/web/dist/assets/KnowledgeView-DLLYjd1G.js +0 -1
  53. package/web/dist/assets/MetricsView-B-KUNOZm.js +0 -1
  54. package/web/dist/assets/NeedsYouView-Dee_bOKj.js +0 -1
  55. package/web/dist/assets/Overview-DFiHDFnA.js +0 -1
  56. package/web/dist/assets/ProjectView-DsRXW-qk.js +0 -1
  57. package/web/dist/assets/ProposalView-B-4P1S-s.js +0 -1
  58. package/web/dist/assets/ProposalsView-uEuj-ooV.js +0 -1
  59. package/web/dist/assets/RunnersView-BB3q65rG.js +0 -1
  60. package/web/dist/assets/SkillView-vAv7zvtJ.js +0 -1
  61. package/web/dist/assets/SocietyView-Dv4phSkz.js +0 -1
  62. package/web/dist/assets/StickyList-C4fC_KJv.js +0 -1
  63. package/web/dist/assets/TaskFileView-B9sex0tS.js +0 -4
  64. package/web/dist/assets/TaskView-BCT388kb.js +0 -3
  65. package/web/dist/assets/TasksView-CuPay34-.js +0 -1
  66. package/web/dist/assets/format-CvfmDNoY.js +0 -55
  67. package/web/dist/assets/governance-Bba0OHvJ.js +0 -1
  68. package/web/dist/assets/index-DD3J11PT.js +0 -23
  69. package/web/dist/assets/mentions-D838wlfQ.js +0 -3
  70. package/web/dist/assets/useMatch-B8j0hm1q.js +0 -1
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "codex",
9
9
  "multi-agent"
10
10
  ],
11
- "version": "0.3.24",
11
+ "version": "0.3.26",
12
12
  "license": "MIT",
13
13
  "homepage": "https://github.com/kr4t0n/stellaris",
14
14
  "repository": {
@@ -33,16 +33,16 @@
33
33
  ],
34
34
  "dependencies": {
35
35
  "@hono/node-server": "2.1.1",
36
- "@modelcontextprotocol/sdk": "1.30.1",
36
+ "@modelcontextprotocol/sdk": "1.32.2",
37
37
  "commander": "15.0.0",
38
38
  "croner": "10.0.1",
39
39
  "execa": "10.0.1",
40
40
  "gray-matter": "4.0.3",
41
- "hono": "4.13.10",
41
+ "hono": "4.13.13",
42
42
  "micromark": "4.0.3",
43
43
  "micromark-extension-gfm": "3.0.0",
44
44
  "pino": "10.3.1",
45
45
  "ulid": "3.0.2",
46
- "zod": "4.6.5"
46
+ "zod": "4.6.7"
47
47
  }
48
48
  }
@@ -0,0 +1 @@
1
+ import{S as e,Un as t,Xt as n}from"./format-CENiwkJC.js";import{O as r,n as i,r as a,t as o,v as s}from"./index-CPXALUV6.js";var c=t(),l=`grid size-7 shrink-0 place-items-center rounded-lg text-fg-tertiary hover:bg-surface-2/70 hover:text-fg-primary`;function u({fallback:t}){let u=n(),d=r({select:e=>e.location.state.__TSR_index}),f=a(),p=s(),m=e(),h=i(f,d);if(h===null)return t;let g=o(h,{entity:e=>p.get(e)?.title,project:e=>m.data?.find(t=>t.slug===e)?.name});return(0,c.jsx)(`button`,{type:`button`,onClick:()=>u.history.back(),"aria-label":`Back to ${g}`,title:`Back to ${g}`,className:l,children:`←`})}export{u as t};
@@ -0,0 +1 @@
1
+ import{Dn as e,Fn as t,Hn as n,Rn as r,Tn as i,Un as a,Wn as o,jn as s,kn as c,qn as l,wn as u,zn as d}from"./format-CENiwkJC.js";var f=class extends u{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||p(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??(this.state.status===`pending`?this.execute(this.state.variables):Promise.resolve())}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey},r=this.#r=i({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)}),a=this.state.status===`pending`,o=!r.canStart();try{if(a)t();else{this.#i({type:`pending`,variables:e,isPaused:o}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:o})}let i=await r.start();return await this.#n.config.onSuccess?.(i,e,this.state.context,this,n),await this.options.onSuccess?.(i,e,this.state.context,n),await this.#n.config.onSettled?.(i,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(i,null,e,this.state.context,n),this.#i({type:`success`,data:i}),i}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#r===r&&(this.#r=void 0),this.#n.runNext(this)}}#i(t){let n=e=>{switch(t.type){case`failed`:return{...e,failureCount:t.failureCount,failureReason:t.error};case`pause`:return{...e,isPaused:!0};case`continue`:return{...e,isPaused:!1};case`pending`:return{...e,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:`pending`,variables:t.variables,submittedAt:Date.now()};case`success`:return{...e,data:t.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...e,data:void 0,error:t.error,failureCount:e.failureCount+1,failureReason:t.error,isPaused:!1,status:`error`}}};this.state=n(this.state),e.batch(()=>{this.#t.forEach(e=>{e.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:`updated`,action:t})})}};function p(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var m=class extends c{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),r(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&s(t.mutationKey)!==s(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onSubscribe(){this.listeners.size===1&&this.#n&&(this.#n.addObserver(this),this.#i())}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??p();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(t){e.batch(()=>{if(this.#r&&this.hasListeners()){let e=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(t?.type===`success`){try{this.#r.onSuccess?.(t.data,e,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(t.data,null,e,n,r)}catch(e){Promise.reject(e)}}else if(t?.type===`error`){try{this.#r.onError?.(t.error,e,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,t.error,e,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},h=l(o(),1);function g(r,i){let a=n(i),[o]=h.useState(()=>new m(a,r));h.useEffect(()=>{o.setOptions(r)},[o,r]);let s=h.useSyncExternalStore(h.useCallback(t=>o.subscribe(e.batchCalls(t)),[o]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),c=h.useCallback((...e)=>{o.mutate(e[0],e[1]).catch(t)},[o]);if(s.error&&d(o.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:c,mutateAsync:s.mutate}}var _=a(),v={primary:`bg-fg-primary font-medium text-surface-0 hover:bg-white`,ghost:`text-fg-tertiary hover:bg-surface-2/70 hover:text-fg-primary`};function y({variant:e=`ghost`,className:t=``,...n}){return(0,_.jsx)(`button`,{type:`button`,...n,className:`inline-flex h-7 shrink-0 items-center rounded-md px-3 text-xs transition-colors focus-visible:ring-2 focus-visible:ring-fg-primary/30 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-40 ${v[e]} ${t}`})}export{g as n,f as r,y as t};
@@ -0,0 +1 @@
1
+ import{Hn as e,Jt as t,Un as n,Wn as r,j as i,qn as a,t as o}from"./format-CENiwkJC.js";import{n as s,t as c}from"./Button-Cp4cNRUX.js";import{i as l}from"./compose-DY1WL8zB.js";import{n as u,r as d}from"./ThreadForms-CG5Y926b.js";var f=a(r(),1),p=n();function m({project:t,onDone:n}){let{api:r}=i(),a=e(),o=l(),[m,h]=(0,f.useState)(``),[g,_]=(0,f.useState)(``),v=(0,f.useRef)(null);(0,f.useEffect)(()=>v.current?.focus(),[]);let y=s({mutationFn:()=>r.createChannel({project:t,name:m.trim(),purpose:g.trim()}),onSuccess:async e=>{await a.invalidateQueries({queryKey:[`channels`]}),n(),await o({to:`/c/$`,params:{_splat:e}})}});return(0,p.jsxs)(`form`,{"aria-label":`New channel`,className:`space-y-2 border-b border-line bg-surface-2/20 p-3`,onSubmit:e=>{e.preventDefault(),y.mutate()},children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(`div`,{className:`w-40 shrink-0`,children:(0,p.jsx)(`input`,{ref:v,value:m,maxLength:64,spellCheck:!1,"aria-label":`Channel name`,placeholder:`release-0-4`,onChange:e=>h(e.target.value),className:`${u} font-mono`})}),(0,p.jsx)(`input`,{value:g,"aria-label":`Purpose`,placeholder:`What the channel is for`,onChange:e=>_(e.target.value),className:`${u} min-w-0 flex-1`}),(0,p.jsx)(c,{onClick:n,children:`Cancel`}),(0,p.jsx)(c,{variant:`primary`,type:`submit`,disabled:y.isPending||m.trim()===``||g.trim()===``,children:y.isPending?`Opening…`:`Open`})]}),(0,p.jsx)(d,{error:y.error})]})}function h({channel:t,onDone:n}){let{api:r}=i(),a=e(),[o,l]=(0,f.useState)(``),m=s({mutationFn:()=>r.archiveChannel({channel:t,reason:o.trim()}),onSuccess:async()=>{await a.invalidateQueries({queryKey:[`channels`]}),n()}});return(0,p.jsxs)(`form`,{"aria-label":`Archive the channel`,className:`space-y-2 border-b border-line bg-surface-2/20 p-3`,onSubmit:e=>{e.preventDefault(),m.mutate()},children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(`input`,{value:o,"aria-label":`Reason`,placeholder:`Why its work is done`,onChange:e=>l(e.target.value),className:`${u} min-w-0 flex-1`}),(0,p.jsx)(c,{onClick:n,children:`Cancel`}),(0,p.jsx)(c,{variant:`primary`,type:`submit`,disabled:m.isPending||o.trim()===``,children:m.isPending?`Archiving…`:`Archive channel`})]}),(0,p.jsx)(d,{error:m.error})]})}function g({channels:e,now:n}){return e.length===0?(0,p.jsx)(`p`,{className:`text-meta`,children:`No channels.`}):(0,p.jsx)(`ul`,{className:`space-y-1`,children:e.map(e=>(0,p.jsxs)(`li`,{children:[(0,p.jsxs)(t,{to:`/c/$`,params:{_splat:e.ref},className:`text-sm hover:text-fg-primary ${e.archived===void 0?`text-fg-secondary`:`text-fg-tertiary`}`,children:[`# `,e.name]}),(0,p.jsxs)(`span`,{className:`text-meta`,children:[` `,`· `,e.messages,` messages`,e.archived===void 0?``:` · archived ${o(e.archived.at,n)}`]})]},e.ref))})}export{g as n,m as r,h as t};
@@ -1,2 +1,2 @@
1
- import{A as e,Cn as t,Gn as n,Jn as r,K as i,St as a,V as o,Wn as s,Yt as c,_ as l,b as u,c as d,t as f,x as p}from"./format-CvfmDNoY.js";import{t as m}from"./Button-BYJGqZ3Q.js";import{A as h,C as g,i as _,k as v,s as y}from"./index-DD3J11PT.js";import{t as b}from"./BackLink-DKMw_rHu.js";import{i as x}from"./ThreadForms-DzoRDeBh.js";import{t as S}from"./ChannelForms-CkYupEL2.js";import{t as C}from"./MessageItem-BvDOeJci.js";import{n as w,t as T}from"./Pane-DTmByqgA.js";import{t as E}from"./StickyList-C4fC_KJv.js";import{n as D}from"./ThreadItem-CDVppcOZ.js";var O=r(n(),1);function k(e,t){let n=e.notices.at(-1);return n!==void 0&&n.kind===`knowledge`&&t.kind===`knowledge`&&n.action!==`removed`&&t.action===`updated`&&n.topic===t.topic&&n.project===t.project}function A(e,t){let n=[],r=null;for(let i of e){let e=t(i),a=e?.notice;e===void 0||a===void 0?(n.push({kind:`item`,item:i}),r=null):r!==null&&k(r,a)?(r.messages.push(e),r.notices.push(a)):(r={messages:[e],notices:[a]},n.push({kind:`notices`,run:r}))}return n}function j(e){let[t]=e,n=e.length-1;return t===void 0||t.action===`removed`?{did:`removed`,times:null}:t.action===`written`?{did:`wrote`,times:n===0?null:`then updated it ${n===1?`once`:`${n} times`}`}:{did:`updated`,times:n===0?null:`${e.length} times`}}function M(e){let t=[...new Set(e)];return t.length<=2?t.join(` and `):`${t.slice(0,-1).join(`, `)}, and ${t.at(-1)??``}`}var N=s();function P(){return(0,N.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`size-3.5`,children:(0,N.jsx)(`path`,{d:`M8 4.2C6.4 3 4.4 2.8 2.2 3.4v9.2c2.2-.6 4.2-.4 5.8.8m0-9.2c1.6-1.2 3.6-1.4 5.8-.8v9.2c-2.2-.6-4.2-.4-5.8.8m0-9.2v9.2`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.2`,strokeLinejoin:`round`})})}function F({notices:e}){let[t]=e;if(t===void 0)return null;let{did:n,times:r}=j(e);return(0,N.jsxs)(N.Fragment,{children:[n,` knowledge`,` `,t.action===`removed`?(0,N.jsx)(`span`,{className:`text-fg-secondary`,children:t.topic}):(0,N.jsx)(c,{to:`/knowledge/$scope/$topic`,params:{scope:t.project??`society`,topic:t.topic},className:`text-fg-secondary hover:text-fg-primary`,children:t.topic}),r===null?null:` · ${r}`]})}function I(e){let t=e.notices.filter(e=>e.kind===`knowledge`);return{mark:(0,N.jsx)(P,{}),text:(0,N.jsx)(F,{notices:t})}}function L({run:e,now:t}){let n=y(),r=e.messages.at(-1);if(r===void 0)return null;let{mark:i,text:a}=I(e);return(0,N.jsxs)(`div`,{className:`flex gap-3 px-4 py-1`,children:[(0,N.jsx)(`span`,{className:`grid h-5 w-7 shrink-0 place-items-center text-fg-muted`,children:i}),(0,N.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-baseline gap-3`,children:[(0,N.jsxs)(`p`,{className:`min-w-0 flex-1 truncate text-sm text-fg-tertiary`,children:[M(e.messages.map(e=>n(e.author))),` `,a]}),(0,N.jsx)(`time`,{dateTime:r.ts,title:e.messages.map(e=>`${n(e.author)} ${e.ts}`).join(`
2
- `),className:`shrink-0 text-meta`,children:f(r.ts,t)})]})]})}var R=`grid size-7 shrink-0 place-items-center rounded-lg text-fg-tertiary hover:bg-surface-2/70 hover:text-fg-primary`;function z(){let{_splat:e=`general`}=h({from:`/c/$`}),{message:t}=v({from:`/c/$`});return(0,N.jsx)(B,{channel:e,target:t},e)}function B({channel:n,target:r}){let{api:s}=e(),h=t({queryKey:[`channel`,n],queryFn:()=>s.channel(n)}),v=o(),y=l(),k=p(),j=d(),M=u(3e4),[P,F]=(0,O.useState)(!1),[I,z]=(0,O.useState)(!1),B=(0,O.useMemo)(()=>{let e=(h.data??[]).map(e=>({kind:`message`,at:e.ts,id:e.id,message:e})),t=(v.data??[]).filter(e=>e.channel===n).map(e=>({kind:`thread`,at:e.openedAt,id:e.id,thread:e}));return[...e,...t].toSorted((e,t)=>e.at.localeCompare(t.at)||e.id.localeCompare(t.id))},[h.data,v.data,n]),V=(0,O.useMemo)(()=>A(B,e=>e.kind===`message`?e.message:void 0),[B]),H=h.data?.at(-1)?.id??null;(0,O.useEffect)(()=>g(n,H),[n,H]);let[U,W]=n.split(`/`),G=W??U??n,K=W===void 0?void 0:k.data?.find(e=>e.slug===U),q=W===void 0?`society`:K?.name??U,J=j.data?.find(e=>e.ref===n)?.archived,Y=K?.archived!==void 0||J!==void 0,X=!Y&&!a(W===void 0?null:U??null,G),Z=B.filter(e=>e.kind===`thread`&&e.thread.state===`open`),Q=W===void 0||U===void 0?(0,N.jsx)(c,{to:`/society`,"aria-label":`Back to the society`,className:R,children:`←`}):(0,N.jsx)(c,{to:`/p/$slug`,params:{slug:U},"aria-label":`Back to ${q}`,className:R,children:`←`});return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(T,{leading:(0,N.jsx)(b,{fallback:Q}),title:`# ${G}`,subtitle:`${q} · ${h.data?.length??0} messages${Z.length>0?` · ${Z.length} open threads`:``}`,trailing:P||I||Y?null:(0,N.jsxs)(N.Fragment,{children:[X?(0,N.jsx)(m,{onClick:()=>z(!0),children:`Archive…`}):null,(0,N.jsx)(m,{onClick:()=>F(!0),children:`New thread`})]})}),P?(0,N.jsx)(x,{channel:n,onDone:()=>F(!1)}):null,I?(0,N.jsx)(S,{channel:n,onDone:()=>z(!1)}):null,(0,N.jsx)(E,{stick:r===void 0,ids:h.data?.map(e=>e.id),className:`py-2`,children:h.error instanceof i&&h.error.status===404?(0,N.jsxs)(w,{children:[`There is no channel `,n,`.`]}):h.data===void 0?(0,N.jsx)(w,{children:`Reading the channel…`}):B.length===0?(0,N.jsx)(w,{children:`Nothing has been said here yet.`}):V.map(e=>{if(e.kind===`notices`){let t=e.run.messages[0]?.id??``;return(0,N.jsx)(L,{run:e.run,now:M},t)}let{item:t}=e;return t.kind===`message`?(0,N.jsx)(C,{message:t.message,members:y.data,now:M,target:t.id===r},t.id):(0,N.jsx)(D,{thread:t.thread,now:M},t.id)})}),h.data===void 0?null:J===void 0?Y?(0,N.jsxs)(`p`,{className:`border-t border-line px-4 py-3 text-meta`,children:[q,` is archived, so its channels are read-only.`]}):(0,N.jsx)(_,{target:{channel:n},placeholder:`Message #${G}`}):(0,N.jsxs)(`p`,{className:`border-t border-line px-4 py-3 text-meta`,children:[`Archived `,f(J.at,M),` by `,J.by,`: `,J.reason,`.`]})]})}export{z as ChannelView};
1
+ import{Jt as e,K as t,S as n,Sn as r,Un as i,V as a,Wn as o,j as s,l as c,qn as l,t as u,v as d,x as f,xt as p}from"./format-CENiwkJC.js";import{t as m}from"./Button-Cp4cNRUX.js";import{A as h,C as g,i as _,k as v,s as y}from"./index-CPXALUV6.js";import{t as b}from"./BackLink-UTiLF1J4.js";import{i as x}from"./ThreadForms-CG5Y926b.js";import{t as S}from"./ChannelForms-DD2B0tey.js";import{t as C}from"./MessageItem-agtEugfG.js";import{n as w,t as T}from"./Pane-BaM0TdE6.js";import{t as E}from"./StickyList-BaV_KZ8x.js";import{n as D}from"./ThreadItem-D-n2arFA.js";var O=l(o(),1);function k(e,t){let n=e.notices.at(-1);return n!==void 0&&n.kind===`knowledge`&&t.kind===`knowledge`&&n.action!==`removed`&&t.action===`updated`&&n.topic===t.topic&&n.project===t.project}function A(e,t){let n=[],r=null;for(let i of e){let e=t(i),a=e?.notice;e===void 0||a===void 0?(n.push({kind:`item`,item:i}),r=null):r!==null&&k(r,a)?(r.messages.push(e),r.notices.push(a)):(r={messages:[e],notices:[a]},n.push({kind:`notices`,run:r}))}return n}function j(e){let[t]=e,n=e.length-1;return t===void 0||t.action===`removed`?{did:`removed`,times:null}:t.action===`written`?{did:`wrote`,times:n===0?null:`then updated it ${n===1?`once`:`${n} times`}`}:{did:`updated`,times:n===0?null:`${e.length} times`}}function M(e){let t=[...new Set(e)];return t.length<=2?t.join(` and `):`${t.slice(0,-1).join(`, `)}, and ${t.at(-1)??``}`}var N=i();function P(){return(0,N.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`size-3.5`,children:(0,N.jsx)(`path`,{d:`M8 4.2C6.4 3 4.4 2.8 2.2 3.4v9.2c2.2-.6 4.2-.4 5.8.8m0-9.2c1.6-1.2 3.6-1.4 5.8-.8v9.2c-2.2-.6-4.2-.4-5.8.8m0-9.2v9.2`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.2`,strokeLinejoin:`round`})})}function F({notices:t}){let[n]=t;if(n===void 0)return null;let{did:r,times:i}=j(t);return(0,N.jsxs)(N.Fragment,{children:[r,` knowledge`,` `,n.action===`removed`?(0,N.jsx)(`span`,{className:`text-fg-secondary`,children:n.topic}):(0,N.jsx)(e,{to:`/knowledge/$scope/$topic`,params:{scope:n.project??`society`,topic:n.topic},className:`text-fg-secondary hover:text-fg-primary`,children:n.topic}),i===null?null:` · ${i}`]})}function I(e){let t=e.notices.filter(e=>e.kind===`knowledge`);return{mark:(0,N.jsx)(P,{}),text:(0,N.jsx)(F,{notices:t})}}function L({run:e,now:t}){let n=y(),r=e.messages.at(-1);if(r===void 0)return null;let{mark:i,text:a}=I(e);return(0,N.jsxs)(`div`,{className:`flex gap-3 px-4 py-1`,children:[(0,N.jsx)(`span`,{className:`grid h-5 w-7 shrink-0 place-items-center text-fg-muted`,children:i}),(0,N.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-baseline gap-3`,children:[(0,N.jsxs)(`p`,{className:`min-w-0 flex-1 truncate text-sm text-fg-tertiary`,children:[M(e.messages.map(e=>n(e.author))),` `,a]}),(0,N.jsx)(`time`,{dateTime:r.ts,title:e.messages.map(e=>`${n(e.author)} ${e.ts}`).join(`
2
+ `),className:`shrink-0 text-meta`,children:u(r.ts,t)})]})]})}var R=`grid size-7 shrink-0 place-items-center rounded-lg text-fg-tertiary hover:bg-surface-2/70 hover:text-fg-primary`;function z(){let{_splat:e=`general`}=h({from:`/c/$`}),{message:t}=v({from:`/c/$`});return(0,N.jsx)(B,{channel:e,target:t},e)}function B({channel:i,target:o}){let{api:l}=s(),h=r({queryKey:[`channel`,i],queryFn:()=>l.channel(i)}),v=a(),y=d(),k=n(),j=c(),M=f(3e4),[P,F]=(0,O.useState)(!1),[I,z]=(0,O.useState)(!1),B=(0,O.useMemo)(()=>{let e=(h.data??[]).map(e=>({kind:`message`,at:e.ts,id:e.id,message:e})),t=(v.data??[]).filter(e=>e.channel===i).map(e=>({kind:`thread`,at:e.openedAt,id:e.id,thread:e}));return[...e,...t].toSorted((e,t)=>e.at.localeCompare(t.at)||e.id.localeCompare(t.id))},[h.data,v.data,i]),V=(0,O.useMemo)(()=>A(B,e=>e.kind===`message`?e.message:void 0),[B]),H=h.data?.at(-1)?.id??null;(0,O.useEffect)(()=>g(i,H),[i,H]);let[U,W]=i.split(`/`),G=W??U??i,K=W===void 0?void 0:k.data?.find(e=>e.slug===U),q=W===void 0?`society`:K?.name??U,J=j.data?.find(e=>e.ref===i)?.archived,Y=K?.archived!==void 0||J!==void 0,X=!Y&&!p(W===void 0?null:U??null,G),Z=B.filter(e=>e.kind===`thread`&&e.thread.state===`open`),Q=W===void 0||U===void 0?(0,N.jsx)(e,{to:`/society`,"aria-label":`Back to the society`,className:R,children:`←`}):(0,N.jsx)(e,{to:`/p/$slug`,params:{slug:U},"aria-label":`Back to ${q}`,className:R,children:`←`});return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(T,{leading:(0,N.jsx)(b,{fallback:Q}),title:`# ${G}`,subtitle:`${q} · ${h.data?.length??0} messages${Z.length>0?` · ${Z.length} open threads`:``}`,trailing:P||I||Y?null:(0,N.jsxs)(N.Fragment,{children:[X?(0,N.jsx)(m,{onClick:()=>z(!0),children:`Archive…`}):null,(0,N.jsx)(m,{onClick:()=>F(!0),children:`New thread`})]})}),P?(0,N.jsx)(x,{channel:i,onDone:()=>F(!1)}):null,I?(0,N.jsx)(S,{channel:i,onDone:()=>z(!1)}):null,(0,N.jsx)(E,{stick:o===void 0,ids:h.data?.map(e=>e.id),className:`py-2`,children:h.error instanceof t&&h.error.status===404?(0,N.jsxs)(w,{children:[`There is no channel `,i,`.`]}):h.data===void 0?(0,N.jsx)(w,{children:`Reading the channel…`}):B.length===0?(0,N.jsx)(w,{children:`Nothing has been said here yet.`}):V.map(e=>{if(e.kind===`notices`){let t=e.run.messages[0]?.id??``;return(0,N.jsx)(L,{run:e.run,now:M},t)}let{item:t}=e;return t.kind===`message`?(0,N.jsx)(C,{message:t.message,members:y.data,now:M,target:t.id===o},t.id):(0,N.jsx)(D,{thread:t.thread,now:M},t.id)})}),h.data===void 0?null:J===void 0?Y?(0,N.jsxs)(`p`,{className:`border-t border-line px-4 py-3 text-meta`,children:[q,` is archived, so its channels are read-only.`]}):(0,N.jsx)(_,{target:{channel:i},placeholder:`Message #${G}`}):(0,N.jsxs)(`p`,{className:`border-t border-line px-4 py-3 text-meta`,children:[`Archived `,u(J.at,M),` by `,J.by,`: `,J.reason,`.`]})]})}export{z as ChannelView};
@@ -0,0 +1,2 @@
1
+ import{D as e,Hn as t,Ht as n,Jt as r,K as i,O as a,S as o,U as s,Un as c,Vt as l,W as u,Wn as d,X as f,a as p,h as m,j as h,k as g,m as _,o as v,p as y,qn as b,t as x,u as S,v as C,x as w,y as T,yt as ee,z as E}from"./format-CENiwkJC.js";import{n as D,t as O}from"./Button-Cp4cNRUX.js";import{t as te}from"./CliIcon-C7bwChMP.js";import{A as k,_ as A,c as j,d as M,f as N,h as P,i as F,k as I,l as L,m as R,p as ne,u as z,v as B}from"./index-CPXALUV6.js";import{t as V}from"./Markdown-DT3V-EVe.js";import{n as re,r as H}from"./ThreadForms-CG5Y926b.js";import{n as U,t as ie}from"./Pane-BaM0TdE6.js";import{t as ae}from"./StickyList-BaV_KZ8x.js";import{a as W,c as oe,d as se,f as ce,i as le,l as ue,n as de,s as fe,t as pe}from"./citizen-BiHfph2A.js";import{n as G}from"./Picker-C2ig-0dT.js";import{t as me}from"./Quota-CfFGIql9.js";var K=b(d(),1),q=c(),he={completed:`completed`,timeout:`timed out`,error:`failed`,interrupted:`was interrupted`,blocked:`was blocked`,stopped:`was stopped by you`};function J(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})}function ge({label:e,tone:t,children:n}){return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`px-0.5 pb-0.5 text-[10px] tracking-wider text-fg-muted uppercase`,children:e}),(0,q.jsx)(`pre`,{className:`max-h-72 overflow-auto rounded-md bg-surface-0/60 p-2 font-mono text-[11px] leading-relaxed whitespace-pre-wrap break-words ${t}`,children:n})]})}function _e({step:e,open:t}){if(e.kind===`say`)return(0,q.jsx)(`li`,{className:`py-1.5 text-sm`,title:J(e.at),children:(0,q.jsx)(V,{text:e.text})});if(e.kind===`error`)return(0,q.jsx)(`li`,{className:`py-1 font-mono text-xs break-words text-red-400`,title:J(e.at),children:e.message});if(e.kind===`steer`)return(0,q.jsx)(`li`,{children:(0,q.jsxs)(`details`,{open:t,className:`group rounded-md open:bg-surface-2/30`,children:[(0,q.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 rounded-md px-1.5 py-1 text-xs hover:bg-surface-2/40`,children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`grid w-3 shrink-0 place-items-center text-sky-300`,children:`↳`}),(0,q.jsxs)(`span`,{className:`shrink-0 text-fg-tertiary`,children:[`Took `,M(e.posts.length)]}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-fg-secondary`,children:e.from.length===0?``:`from ${e.from.join(`, `)}, delivered mid-turn`}),(0,q.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-fg-muted`,children:J(e.at)})]}),(0,q.jsx)(`ul`,{className:`space-y-1.5 px-1.5 pb-1.5`,children:e.posts.map(e=>(0,q.jsxs)(`li`,{className:`rounded-md bg-surface-0/40 px-2.5 py-2`,children:[(0,q.jsxs)(`p`,{className:`flex gap-1.5 text-meta`,children:[(0,q.jsx)(`span`,{className:`text-fg-secondary`,children:e.author}),(0,q.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`in `,e.where]}),e.at===``?null:(0,q.jsx)(`span`,{className:`ml-auto shrink-0 font-mono`,children:J(e.at)})]}),(0,q.jsx)(`div`,{className:`mt-1 text-sm`,children:(0,q.jsx)(V,{text:e.body})})]},`${e.at}-${e.author}`))})]})});let n=e.ok===null?(0,q.jsx)(`span`,{"aria-label":`running`,className:`size-1.5 animate-pulse rounded-full bg-amber-300`}):e.ok?(0,q.jsx)(`span`,{"aria-label":`succeeded`,className:`text-[11px] text-emerald-400`,children:`✓`}):(0,q.jsx)(`span`,{"aria-label":`failed`,className:`text-[11px] text-red-400`,children:`✕`});return(0,q.jsx)(`li`,{children:(0,q.jsxs)(`details`,{open:t,className:`group rounded-md open:bg-surface-2/30`,children:[(0,q.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 rounded-md px-1.5 py-1 text-xs hover:bg-surface-2/40`,children:[(0,q.jsx)(`span`,{className:`grid w-3 shrink-0 place-items-center`,children:n}),(0,q.jsx)(`span`,{className:`shrink-0 font-mono text-fg-tertiary`,children:N(e.name)}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-fg-secondary`,children:e.summary}),(0,q.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-fg-muted`,children:J(e.at)})]}),(0,q.jsxs)(`div`,{className:`space-y-1.5 px-1.5 pb-1.5`,children:[(0,q.jsx)(ge,{label:`Input`,tone:`text-fg-secondary`,children:e.detail}),e.output===null?null:(0,q.jsx)(ge,{label:e.ok===!1?`Returned an error`:`Returned`,tone:e.ok===!1?`text-red-300`:`text-fg-tertiary`,children:e.output})]})]})})}function ve({steps:e}){let[t,n]=(0,K.useState)(!1),r=e.filter(e=>e.kind===`tool`).length;return e.length===0?(0,q.jsx)(`p`,{className:`mt-2 text-meta`,children:`No steps yet.`}):(0,q.jsxs)(q.Fragment,{children:[r===0?null:(0,q.jsxs)(`p`,{className:`mt-2 flex items-center gap-2 text-meta`,children:[r===1?`1 tool call`:`${r} tool calls`,(0,q.jsx)(`button`,{type:`button`,onClick:()=>n(!t),className:`rounded-md px-1.5 py-0.5 text-fg-tertiary transition-colors hover:bg-surface-2/60 hover:text-fg-primary`,children:t?`Collapse all`:`Expand all`})]}),(0,q.jsx)(`ol`,{className:`mt-1 space-y-0.5`,children:e.map(e=>(0,q.jsx)(_e,{step:e,open:t},e.seq))})]})}function ye({turn:e,running:t,now:n}){return e.end===null?t?(0,q.jsxs)(`p`,{className:`mt-3 flex items-center gap-2 text-meta`,"aria-live":`polite`,children:[(0,q.jsx)(`span`,{className:`size-1.5 animate-pulse rounded-full bg-emerald-400`}),`Working · last step `,x(e.lastAt,n)]}):(0,q.jsx)(`p`,{className:`mt-3 text-meta`,children:`The turn ended without a report.`}):(0,q.jsxs)(`section`,{className:`mt-3 rounded-xl bg-surface-2/40 px-3.5 py-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)]`,children:[(0,q.jsxs)(`p`,{className:`text-caps`,children:[`The turn `,he[e.end.exitReason],` `,x(e.end.at,n),e.fromStart?` · ${L(e.startedAt,Date.parse(e.end.at))}`:``]}),e.end.summary===null?null:(0,q.jsx)(`p`,{className:`mt-1 text-sm text-fg-secondary`,children:e.end.summary})]})}var be=30,xe={turn:`turn`,board:`board`,merge:`both kept`},Se={turn:`Changed by a turn`,board:`Written by the board`,merge:`Both versions kept`};function Ce(e){return e.status===`added`?`new`:e.status===`deleted`?`deleted`:e.added===null||e.removed===null?`binary`:`+${e.added} −${e.removed}`}function we(e){return e.files.map(e=>`${e.path} ${Ce(e)}`).join(`, `)}function Te(e){return e.startsWith(`@@`)||e.startsWith(`\\`)?`text-fg-muted`:e.startsWith(`+`)?`text-emerald-300`:e.startsWith(`-`)?`text-red-300`:`text-fg-tertiary`}function Ee({file:e}){return(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`p`,{className:`text-xs text-fg-secondary`,children:[e.path,e.status===`modified`?``:(0,q.jsxs)(`span`,{className:`text-fg-muted`,children:[` · `,e.status]})]}),e.patch===null?(0,q.jsx)(`p`,{className:`mt-1 text-meta`,children:`A binary file; its contents are not shown.`}):e.patch===``?(0,q.jsx)(`p`,{className:`mt-1 text-meta`,children:`Empty.`}):(0,q.jsx)(`pre`,{className:`mt-1 max-h-96 overflow-auto rounded-md bg-surface-0/60 p-2 font-mono text-[11px] leading-relaxed`,children:e.patch.split(`
2
+ `).map((e,t)=>(0,q.jsx)(`span`,{className:`block whitespace-pre-wrap break-words ${Te(e)}`,children:e===``?` `:e},t))}),e.truncated?(0,q.jsx)(`p`,{className:`mt-1 text-meta`,children:`The rest of this file's change is cut.`}):null]})}function De({name:e,change:t}){let n=y(e,t.commit,!0);return(0,q.jsxs)(`div`,{className:`space-y-3 px-4 pt-1 pb-3`,children:[(0,q.jsxs)(`p`,{className:`text-xs text-fg-secondary`,children:[t.kind===`merge`?Se.merge:t.kind===`board`?`Written by the board: ${t.subject.replace(/^home: /,``)}.`:t.turnId===void 0?t.subject:(0,q.jsx)(r,{to:`/citizen/$name`,params:{name:e},search:{tab:`turns`,turn:t.turnId},className:`text-fg-secondary underline decoration-line underline-offset-2 hover:text-fg-primary`,children:`Open the turn that made it`}),(0,q.jsxs)(`span`,{className:`text-fg-muted`,children:[` · `,J(t.at)]})]}),n.data===void 0?(0,q.jsx)(`p`,{className:`text-meta`,children:n.isError?`Could not read the change.`:`Reading the change…`}):n.data.map(e=>(0,q.jsx)(Ee,{file:e},e.path))]})}function Oe({name:e,change:t,now:n}){let[r,i]=(0,K.useState)(!1),a=t.files.length===0?t.subject:we(t);return(0,q.jsx)(`li`,{className:`border-b border-line/60 last:border-b-0`,children:(0,q.jsxs)(`details`,{className:`group`,onToggle:e=>i(e.currentTarget.open),children:[(0,q.jsx)(`summary`,{"aria-label":`${Se[t.kind]} ${x(t.at,n)}: ${a}`,className:`block cursor-pointer list-none px-4 py-2.5 transition-colors hover:bg-surface-2/30 group-open:bg-surface-2/20`,children:(0,q.jsxs)(`span`,{className:`flex items-center gap-2 text-xs`,children:[(0,q.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:xe[t.kind]}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-fg-secondary`,children:a}),(0,q.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:x(t.at,n)}),(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 text-[10px] text-fg-muted transition-transform group-open:rotate-90`,children:`▸`})]})}),r?(0,q.jsx)(De,{name:e,change:t}):null]})})}function ke({name:e}){let[t,n]=(0,K.useState)(be),r=m(e,t),i=w(3e4);if(r.data===void 0)return(0,q.jsx)(U,{children:r.isError?`Could not read the home's history.`:`Reading the history…`});let{changes:a,more:o}=r.data;return a.length===0?(0,q.jsx)(U,{children:`No history yet.`}):(0,q.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[(0,q.jsx)(`ol`,{children:a.map(t=>(0,q.jsx)(Oe,{name:e,change:t,now:i},t.commit))}),o?(0,q.jsx)(`button`,{type:`button`,onClick:()=>n(t+be),className:`px-4 py-3 text-xs text-fg-tertiary hover:text-fg-primary`,children:`Show earlier changes`}):null]})}function Y({title:e,children:t}){return(0,q.jsxs)(`section`,{className:`border-t border-line pt-4 first:border-t-0 first:pt-0`,children:[(0,q.jsx)(`h3`,{className:`text-section`,children:e}),(0,q.jsx)(`div`,{className:`mt-2`,children:t})]})}function Ae({member:e,charter:t}){let n=T(e.name),r=v(e.name),i=_(e.name),a=w(3e4);return(0,q.jsxs)(`div`,{className:`flex-1 space-y-5 overflow-y-auto px-4 py-4`,children:[i.data===void 0||i.data.length===0?null:(0,q.jsx)(Y,{title:`Edits to reconcile`,children:(0,q.jsx)(`ul`,{className:`space-y-1.5`,children:i.data.map(e=>(0,q.jsxs)(`li`,{className:`text-sm`,children:[(0,q.jsx)(`span`,{className:`text-fg-primary`,children:e.file}),(0,q.jsxs)(`span`,{className:`text-meta`,children:[` `,`· `,e.path.slice(e.path.lastIndexOf(`/`)+1),` · left`,` `,x(e.since,a)]})]},e.path))})}),(0,q.jsx)(Y,{title:`Profile`,children:e.profile.trim()===``?(0,q.jsx)(`p`,{className:`text-meta`,children:`No profile yet.`}):(0,q.jsx)(V,{text:ce(e.profile,`Profile`)})}),(0,q.jsx)(Y,{title:`Core memory`,children:n.data===void 0?(0,q.jsx)(`p`,{className:`text-meta`,children:`Reading…`}):n.data.body.trim()===``?(0,q.jsx)(`p`,{className:`text-meta`,children:`Empty.`}):(0,q.jsx)(V,{text:ce(n.data.body,`Core memory`)})}),(0,q.jsx)(Y,{title:`Own skills`,children:r.data===void 0?(0,q.jsx)(`p`,{className:`text-meta`,children:`Reading…`}):r.data.length===0?(0,q.jsx)(`p`,{className:`text-meta`,children:`None yet.`}):(0,q.jsx)(`ul`,{className:`space-y-1.5`,children:r.data.map(e=>(0,q.jsxs)(`li`,{className:`text-sm`,children:[(0,q.jsx)(`span`,{className:`text-fg-primary`,children:e.name}),e.summary===``?null:(0,q.jsxs)(`span`,{className:`text-fg-secondary`,children:[` · `,e.summary]})]},e.name))})}),t===void 0?null:(0,q.jsxs)(Y,{title:`Charter of ${t.name}`,children:[(0,q.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:t.purpose}),(0,q.jsxs)(`p`,{className:`mt-2 text-meta`,children:[`Wakes on mentions, stages, and `,t.wakeTriggers.join(`, `)||`nothing else`,t.resident?` · keeps a warm session`:``,t.reflects?` · reflects`:``]}),(0,q.jsx)(`p`,{className:`mt-2 flex flex-wrap gap-1`,children:t.verbs.map(e=>(0,q.jsx)(`span`,{className:`rounded-md bg-surface-2/70 px-1.5 py-px font-mono text-[11px] text-fg-tertiary`,children:e},e))})]})]})}function je(e,t){let n=s(e,t?.turnId??null);return{turn:(0,K.useMemo)(()=>t===void 0||n.data===void 0?void 0:ne(n.data,e,t.project,t),[t,n.data,e]),loading:t?.turnId!==void 0&&n.isPending,missing:t!==void 0&&(t.turnId===void 0||n.isError)}}var X=50;function Me({name:e,entry:t,now:n,opened:r}){let[i,a]=(0,K.useState)(r),o=(0,K.useRef)(null);(0,K.useEffect)(()=>{r&&o.current?.scrollIntoView({block:`start`})},[r]);let s=B(),c=ue(t),l=t.thread===void 0?t.channel===void 0?t.place===void 0?null:`${t.place}'s channels`:`#${t.channel}`:s.get(t.thread)?.title??`a thread`,u=t.error??t.summary??``,d=t.error===null?`text-fg-secondary`:`text-red-300`;return(0,q.jsx)(`li`,{ref:o,className:`border-b border-line/60 last:border-b-0`,children:(0,q.jsxs)(`details`,{className:`group`,open:i,onToggle:e=>a(e.currentTarget.open),children:[(0,q.jsxs)(`summary`,{className:`block cursor-pointer list-none px-4 py-2.5 transition-colors hover:bg-surface-2/30 group-open:bg-surface-2/20`,children:[(0,q.jsxs)(`span`,{className:`flex items-center gap-2 text-xs`,children:[(0,q.jsxs)(`span`,{className:`min-w-0 truncate text-fg-secondary`,children:[W(t.project),l===null?``:` · ${l}`]}),(0,q.jsx)(`span`,{className:`text-fg-muted`,children:t.trigger}),(0,q.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-fg-muted`,children:[pe(t),` `,x(t.ts,n)]}),(0,q.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-fg-tertiary`,title:t.usage===void 0?void 0:fe(t.usage),children:[c,t.toolCalls===void 0?null:`${t.toolCalls} tools`,t.usage===void 0?null:oe(t.usage)].filter(e=>e!==null).join(` · `)}),(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 text-[10px] text-fg-muted transition-transform group-open:rotate-90`,children:`▸`})]}),u.trim()===``?null:(0,q.jsx)(`span`,{className:`mt-1 line-clamp-2 block text-xs leading-relaxed group-open:hidden ${d}`,children:(0,q.jsx)(A,{text:u,links:!1})})]}),i?(0,q.jsx)(Ne,{name:e,entry:t,text:u,tone:d}):null]})})}function Ne({name:e,entry:t,text:n,tone:r}){let i=je(e,t);return(0,q.jsxs)(`div`,{className:`px-4 pt-1 pb-3`,children:[n.trim()===``?null:(0,q.jsx)(`p`,{className:`text-xs leading-relaxed whitespace-pre-wrap ${r}`,children:(0,q.jsx)(A,{text:n})}),(0,q.jsx)(`div`,{className:`mt-2`,children:t.turnId===void 0?(0,q.jsx)(`p`,{className:`text-meta`,children:`This turn ran before turns kept their steps.`}):i.loading?(0,q.jsx)(`p`,{className:`text-meta`,children:`Reading the steps…`}):i.turn===void 0?(0,q.jsx)(`p`,{className:`text-meta`,children:`No steps were kept for this turn.`}):(0,q.jsxs)(q.Fragment,{children:[t.startedAt===void 0?null:(0,q.jsxs)(`p`,{className:`text-caps`,children:[`Started `,J(t.startedAt)]}),(0,q.jsx)(ve,{steps:i.turn.steps})]})})]})}function Pe({name:e,opened:t}){let[n,r]=(0,K.useState)(X),i=u(e,n),a=w(3e4);if(i.data===void 0)return(0,q.jsx)(U,{children:`Reading the turns…`});let o=i.data.toReversed();if(o.length===0)return(0,q.jsxs)(U,{children:[e,` has not finished a turn yet.`]});let s=de(o),c=s.usage===null?``:` · ${oe(s.usage)}${s.withUsage<s.turns?` over ${s.withUsage} of them`:``}`;return(0,q.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[(0,q.jsxs)(`p`,{className:`px-4 pt-3 pb-1 text-meta`,title:s.usage===null?void 0:fe(s.usage),children:[s.turns===1?`1 turn`:`${s.turns} turns`,s.failed===0?``:`, ${s.failed} not completed`,c]}),t!==null&&!o.some(e=>e.turnId===t)?(0,q.jsx)(`p`,{className:`px-4 pb-1 text-meta`,children:i.data.length===n?`The turn this address opens is further back.`:`The turn this address opens is not in this citizen's history.`}):null,(0,q.jsx)(`ol`,{children:o.map(n=>(0,q.jsx)(Me,{name:e,entry:n,now:a,opened:t!==null&&n.turnId===t},n.id))}),i.data.length===n?(0,q.jsxs)(`button`,{type:`button`,onClick:()=>r(n+X),className:`px-4 py-3 text-xs text-fg-tertiary hover:text-fg-primary`,children:[`Show `,X,` earlier turns`]}):null]})}var Z=``,Q=``;function Fe(e,t){return[{value:Z,name:`CLI default`,id:e.find(e=>e.isDefault)?.name??null,description:`Whatever the CLI runs when no model is set.`},...e.map(e=>({value:e.id,name:e.name,id:e.name===e.id?null:e.id,description:e.description})),...t===null?[]:[{value:t,name:t,id:null,description:`Not in the CLI's list.`}]]}function Ie(e,t){return[{value:Q,name:`Default`,id:e?.defaultEffort??null,description:`Whatever the model runs unset.`},...(e?.efforts??[]).map(e=>({value:e.id,name:e.id,id:null,description:e.description})),...t===null?[]:[{value:t,name:t,id:null,description:`Not in the model's list.`}]]}function Le({member:e,onDone:n}){let{api:r}=h(),a=t(),o=p(e.name),s=e.model??Z,c=e.effort??Q,[l,u]=(0,K.useState)(s),[d,f]=(0,K.useState)(c),m=D({mutationFn:async()=>{l!==s&&await r.setModel(e.name,l===Z?null:l),d!==c&&await r.setEffort(e.name,d===Q?null:d)},onSettled:()=>void a.invalidateQueries({queryKey:[`members`]}),onSuccess:n}),g=o.data?.models??[],_=e.model!==void 0&&!g.some(t=>t.id===e.model)?e.model:null,v=e=>g.find(t=>e===Z?t.isDefault:t.id===e),y=v(l)?.efforts??[],b=d!==Q&&!y.some(e=>e.id===d)?d:null,x=e=>{u(e);let t=v(e)?.efforts??[];d!==Q&&!t.some(e=>e.id===d)&&f(Q)},S=l!==s||d!==c;return(0,q.jsxs)(`form`,{"aria-label":`Model of ${e.name}`,className:`space-y-2 border-b border-line bg-surface-2/20 p-3`,onSubmit:e=>{e.preventDefault(),m.mutate()},children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[o.isPending?(0,q.jsxs)(`p`,{className:`min-w-0 flex-1 truncate text-meta`,children:[`Asking `,e.cli,` for its models…`]}):o.error===null?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(G,{label:`Model`,choices:Fe(g,_),value:l,onChange:x}),y.length===0&&b===null?null:(0,q.jsx)(`div`,{className:`flex w-32 shrink-0`,children:(0,q.jsx)(G,{label:`Effort`,choices:Ie(v(l),b),value:d,onChange:f,listClassName:`right-0 w-64`})})]}):(0,q.jsxs)(`p`,{role:`alert`,className:`min-w-0 flex-1 truncate text-xs text-red-400`,children:[e.cli,` did not list its models:`,` `,o.error instanceof i?o.error.message:`the board server did not answer`]}),(0,q.jsx)(O,{onClick:n,children:`Cancel`}),(0,q.jsx)(O,{variant:`primary`,type:`submit`,disabled:m.isPending||!S||o.error!==null,children:m.isPending?`Saving…`:`Save`})]}),o.data===void 0?null:(0,q.jsxs)(`p`,{className:`text-meta`,children:[`Listed by `,o.data.cli,` on `,o.data.runner]}),(0,q.jsx)(H,{error:m.error})]})}var $=``;function Re(e,t){let n=t.cli;return[e.status,e.clis.length===0?`offers no CLI yet`:e.clis.join(`, `),n!==null&&e.clis.length>0&&!e.clis.includes(n)?`has no ${n}`:``,e.capabilities.length===0?``:e.capabilities.join(`, `)].filter(e=>e!==``).join(` · `)}function ze(e,t){return[{value:$,name:`Any runner`,id:null,description:`Pinned to the least busy runner on its next turn outside a project.`},...e.map(e=>({value:e.name,name:e.name,id:e.os,description:Re(e,t)}))]}function Be({member:e,onDone:n}){let{api:r}=h(),i=t(),o=a(),s=e.homeRunner??$,[c,l]=(0,K.useState)(s),u=D({mutationFn:()=>r.setRunner(e.name,c===$?null:c),onSuccess:()=>{i.invalidateQueries({queryKey:[`members`]}),n()}});return(0,q.jsxs)(`form`,{"aria-label":`Runner of ${e.name}`,className:`space-y-2 border-b border-line bg-surface-2/20 p-3`,onSubmit:e=>{e.preventDefault(),u.mutate()},children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[o.data===void 0?(0,q.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-meta`,children:`Reading the runners…`}):(0,q.jsx)(G,{label:`Runner`,choices:ze(o.data,e),value:c,onChange:l}),(0,q.jsx)(O,{onClick:n,children:`Cancel`}),(0,q.jsx)(O,{variant:`primary`,type:`submit`,disabled:u.isPending||c===s,children:u.isPending?`Saving…`:`Run here`})]}),(0,q.jsx)(H,{error:u.error})]})}function Ve(e){if(e.thread!==void 0)return{threadId:e.thread};let t=e.scope===`society`?null:e.scope;return e.channel===void 0?e.place===void 0?{channel:e.askedIn??l(t,`general`)}:{channel:e.askedIn!==void 0&&n(e.askedIn).project===e.place?e.askedIn:l(e.place,`general`)}:{channel:l(t,e.channel)}}function He({name:e,turn:n}){let{api:r}=h(),i=t(),[a,o]=(0,K.useState)(!1),s=D({mutationFn:()=>r.stopTurn(n.turnId),onSuccess:()=>{o(!1),i.invalidateQueries({queryKey:[`scheduler`]})}});return(0,q.jsxs)(`div`,{className:`border-t border-line`,children:[(0,q.jsx)(F,{target:Ve(n),initialText:`@${e} `,placeholder:n.steerable?`Message ${e} while it works`:`Message ${e} for its next turn`,className:`px-3 pt-3 pb-2`},n.turnId),n.stoppable?(0,q.jsxs)(`div`,{className:`flex items-center gap-2 px-3 pb-3`,children:[(0,q.jsx)(`p`,{className:`min-w-0 flex-1 text-[11px] leading-snug text-fg-muted`,children:a?`Stop ${e}'s turn?`:n.steerable?`Posts reach the turn at its next step.`:`This runner delivers posts after the turn ends.`}),a?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(O,{onClick:()=>{o(!1),s.reset()},children:`Keep it running`}),(0,q.jsx)(O,{variant:`primary`,disabled:s.isPending,onClick:()=>{s.mutate()},children:s.isPending?`Stopping…`:`Stop the turn`})]}):(0,q.jsx)(O,{onClick:()=>o(!0),children:`Stop…`})]}):null,s.error===null?null:(0,q.jsx)(`div`,{className:`px-3 pb-3`,children:(0,q.jsx)(H,{error:s.error})})]})}function Ue({member:e,scopes:n,preferred:r,running:i,paused:a,onDone:o}){let{api:s}=h(),c=t(),[l,u]=(0,K.useState)(`manual`),[d,f]=(0,K.useState)(r!==null&&n.includes(r)?r:n[0]??``),[p,m]=(0,K.useState)(``),g=(0,K.useRef)(null);(0,K.useEffect)(()=>g.current?.focus(),[]);let _=D({mutationFn:()=>s.wake({agent:e.name,project:d,kind:l,...p.trim()===``?{}:{reason:p.trim()}}),onSuccess:()=>{c.invalidateQueries({queryKey:[`scheduler`]}),o()}}),v=a?`The society is paused.`:i.includes(d)?`${e.name} is in a turn there now.`:null;return(0,q.jsxs)(`form`,{"aria-label":`Wake ${e.name}`,className:`space-y-2 border-b border-line bg-surface-2/20 p-3`,onSubmit:e=>{e.preventDefault(),_.mutate()},children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsxs)(`fieldset`,{className:`flex gap-1`,children:[(0,q.jsx)(`legend`,{className:`sr-only`,children:`Kind of turn`}),[`manual`,`reflection`].map(e=>(0,q.jsxs)(`label`,{className:`cursor-pointer rounded-md px-2.5 py-1 text-xs transition-colors has-focus-visible:ring-2 has-focus-visible:ring-fg-primary/30 ${l===e?`bg-surface-2 text-fg-primary`:`text-fg-tertiary hover:bg-surface-2/60 hover:text-fg-primary`}`,children:[(0,q.jsx)(`input`,{type:`radio`,name:`kind`,value:e,checked:l===e,onChange:()=>u(e),className:`sr-only`}),e===`manual`?`A turn`:`A reflection`]},e))]}),(0,q.jsxs)(`div`,{className:`ml-auto flex w-52 items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`shrink-0 text-xs text-fg-tertiary`,children:`at`}),(0,q.jsx)(G,{label:`Where`,choices:le(n),value:d,onChange:f})]})]}),(0,q.jsx)(`textarea`,{ref:g,value:p,rows:2,placeholder:l===`reflection`?`What to reflect on, optional`:`What it should look at`,"aria-label":`Reason`,onChange:e=>m(e.target.value),className:`${re} resize-none`}),v===null?null:(0,q.jsx)(`p`,{className:`text-[11px] leading-relaxed text-fg-muted`,children:v}),(0,q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,q.jsx)(O,{onClick:o,children:`Cancel`}),(0,q.jsx)(O,{variant:`primary`,type:`submit`,disabled:_.isPending||d===``,children:_.isPending?`Waking…`:l===`reflection`?`Ask for a reflection`:`Wake ${e.name}`})]}),(0,q.jsx)(H,{error:_.error})]})}var We={working:`bg-emerald-500/15 text-emerald-300`,queued:`bg-amber-500/15 text-amber-300`,idle:`bg-surface-2 text-fg-tertiary`};function Ge({project:e,name:t}){let n=(E(e).data??[]).filter(e=>e.status===`claimed`&&e.claimedBy===t);return n.length===0?null:(0,q.jsx)(`ul`,{className:`mt-1.5 space-y-1`,children:n.map(e=>(0,q.jsx)(`li`,{children:(0,q.jsxs)(r,{to:`/task/$taskId`,params:{taskId:e.id},className:`flex items-center gap-2 rounded-md text-xs text-fg-secondary hover:text-fg-primary`,children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`text-fg-muted`,children:`◇`}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title}),(0,q.jsx)(`span`,{className:`max-w-[40%] shrink-0 truncate font-mono text-[11px] text-fg-muted`,children:ee(e)?.name??e.stage})]})},e.id))})}function Ke(){let{name:e}=k({from:`/citizen/$name`}),{scope:t,tab:n,turn:r}=I({from:`/citizen/$name`});return(0,q.jsx)(Je,{name:e,chosen:t??null,tab:n??`now`,turn:r??null},e)}var qe=[{tab:`now`,label:`Now`},{tab:`turns`,label:`Turns`},{tab:`memory`,label:`Memory`},{tab:`history`,label:`History`}];function Je({name:t,chosen:n,tab:i,turn:s}){let c=C(),l=e(),u=g(),d=P(),p=S(),m=a(),h=o(),_=w(3e4),[v,y]=(0,K.useState)(null),b=c.data?.find(e=>e.name===t);if(b===void 0)return(0,q.jsx)(U,{children:c.data===void 0?`Reading the roster…`:`There is no citizen ${t}.`});let x=f(u.data?.running??[]).filter(e=>e.agent===t),T=[...new Set(x.map(e=>e.scope))],ee=x.map(e=>z(e.agent,e.scope,e)),E=f(u.data?.pending??[]).find(e=>e.agent===t),D=T.length>0?`working`:E===void 0?`idle`:`queued`,k=R(d,t)[0],A=k?.model??b.lastModel,j=A??b.model??`CLI default`,M=b.model!==void 0&&b.model!==A?b.model:null,N=l.data?.find(e=>e.name===b.role),F=se(b),I=b.status===`active`&&b.cli!==null,L=(p.data??[]).filter(e=>e.agent===t&&e.ended===void 0).length;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(ie,{leading:b.cli===null?null:(0,q.jsx)(`span`,{className:`grid size-9 shrink-0 place-items-center rounded-lg bg-surface-2/70`,children:(0,q.jsx)(te,{cli:b.cli,size:20})}),title:t,subtitle:(0,q.jsxs)(q.Fragment,{children:[b.role,` · `,j,M===null?``:` · set to ${M}`,b.effort===void 0?``:` · ${b.effort} effort`,b.homeRunner===void 0?``:` · on ${b.homeRunner}`,b.status===`retired`?` · retired`:``]}),trailing:(0,q.jsxs)(q.Fragment,{children:[L===0?null:(0,q.jsx)(r,{to:`/crons`,search:{agent:t},className:`inline-flex h-7 shrink-0 items-center rounded-md px-3 text-xs text-fg-tertiary transition-colors hover:bg-surface-2/70 hover:text-fg-primary focus-visible:ring-2 focus-visible:ring-fg-primary/30 focus-visible:outline-none`,children:L===1?`1 cron`:`${L} crons`}),I&&v===null?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(O,{onClick:()=>y(`model`),children:`Model…`}),(0,q.jsx)(O,{onClick:()=>y(`runner`),children:`Runner…`}),(0,q.jsx)(O,{onClick:()=>y(`wake`),children:`Wake…`})]}):null,(0,q.jsx)(`span`,{className:`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium ${We[D]}`,children:D})]})}),(0,q.jsx)(me,{member:b,runners:m.data??[],placed:new Map((h.data??[]).flatMap(e=>e.runner===void 0?[]:[[e.slug,e.runner]])),now:_}),v===`wake`?(0,q.jsx)(Ue,{member:b,scopes:F,preferred:n?.split(`/`)[0]??k?.scope??null,running:T,paused:u.data?.paused??!1,onDone:()=>y(null)}):v===`model`?(0,q.jsx)(Le,{member:b,onDone:()=>y(null)}):v===`runner`?(0,q.jsx)(Be,{member:b,onDone:()=>y(null)}):null,(0,q.jsx)(`nav`,{"aria-label":`Citizen views`,className:`flex gap-1 border-b border-line px-3 py-2`,children:qe.map(e=>(0,q.jsx)(r,{to:`/citizen/$name`,params:{name:t},search:{...n===null?{}:{scope:n},...e.tab===`now`?{}:{tab:e.tab}},replace:!0,"aria-current":e.tab===i?`page`:void 0,className:`rounded-md px-2.5 py-1 text-xs transition-colors ${e.tab===i?`bg-surface-2 text-fg-primary`:`text-fg-tertiary hover:bg-surface-2/60 hover:text-fg-primary`}`,children:e.label},e.tab))}),i===`turns`?(0,q.jsx)(Pe,{name:t,opened:s},s):i===`memory`?(0,q.jsx)(Ae,{member:b,charter:N}):i===`history`?(0,q.jsx)(ke,{name:t}):(0,q.jsx)(Xe,{name:t,chosen:n,lastTurnAt:b.lastTurnAt,state:D,runningScopes:T,runningKeys:ee,runningTurns:(u.data?.turns??[]).filter(e=>e.agent===t),queuedScope:E?.scope??null})]})}function Ye(e){return e.toSorted((e,t)=>e.startedAt.localeCompare(t.startedAt))[0]}function Xe({name:e,chosen:t,lastTurnAt:n,state:i,runningScopes:a,runningKeys:o,runningTurns:s,queuedScope:c}){let l=P(),d=w(5e3),f=R(l,e),p=u(e,1),m=je(e,f.length===0?p.data?.at(-1):void 0),h=B(),g=e=>e.end===null&&o.includes(z(e.agent,e.scope,e)),_=t?.split(`/`)[0]??null,v=(t?.includes(`/`)===!0?f.find(e=>j(e)===t):void 0)??Ye(f.filter(e=>e.scope===_&&g(e)))??f.find(e=>j(e)===t)??Ye(f.filter(g))??f[0]??m.turn,y=e=>e.thread===void 0?e.channel===void 0?e.place===void 0?W(e.scope):`${W(e.scope)} · ${e.place}'s channels`:`${W(e.scope)} · #${e.channel}`:`${W(e.scope)} · ${h.get(e.thread)?.title??`a thread`}`,b=v!==void 0&&g(v),S=v?.scope??a[0]??c,C=(v===void 0?void 0:s.find(e=>e.scope===v.scope&&e.thread===v.thread&&e.channel===v.channel&&e.place===v.place))??(b?void 0:s[0]);return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`section`,{className:`border-b border-line px-4 py-3 text-xs text-fg-tertiary`,children:[(0,q.jsx)(`p`,{children:b?`In a turn at ${W(v.scope)} for ${v.fromStart?``:`at least `}${L(v.startedAt,d)}`:a.length>0?`In a turn at ${a.map(W).join(` and `)}`:c===null?n===void 0?`No turns yet`:`Last turn ${x(n,d)}`:`Queued for a turn at ${W(c)}`}),S===null||S===`society`?null:(0,q.jsx)(Ge,{project:S,name:e})]}),(0,q.jsx)(ae,{className:`px-4 py-3`,children:v===void 0?(0,q.jsx)(U,{children:i===`working`?`The turn has not reported a step yet.`:m.loading?`Reading the last turn…`:n===void 0?`${e} has not taken a turn yet.`:`${e}'s last turn kept no steps.`}):(0,q.jsxs)(q.Fragment,{children:[f.length>1?(0,q.jsx)(`div`,{className:`mb-3 flex flex-wrap gap-1.5`,"aria-label":`Turns by conversation`,children:f.toSorted((e,t)=>j(e).localeCompare(j(t))).map(t=>(0,q.jsxs)(r,{to:`/citizen/$name`,params:{name:e},search:{scope:j(t)},replace:!0,"aria-current":t===v?`true`:void 0,className:`inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-[11px] transition-colors ${t===v?`bg-surface-2 text-fg-primary`:`text-fg-tertiary hover:bg-surface-2/60 hover:text-fg-primary`}`,children:[g(t)?(0,q.jsx)(`span`,{className:`size-1.5 animate-pulse rounded-full bg-emerald-400`}):null,y(t)]},j(t)))}):null,(0,q.jsxs)(`p`,{className:`text-caps`,children:[b?`This turn`:`Last turn`,` · `,y(v),` · started`,` `,v.fromStart?J(v.startedAt):`before the earliest step shown`]}),(0,q.jsx)(ve,{steps:v.steps}),(0,q.jsx)(ye,{turn:v,running:b,now:d})]})}),C===void 0?null:(0,q.jsx)(He,{name:e,turn:C})]})}export{Ke as CitizenView};
@@ -1 +1 @@
1
- import{D as e,Gn as t,H as n,Jn as r,O as i,Wn as a,X as o,Yt as s,_ as c,b as l,t as u,x as d}from"./format-CvfmDNoY.js";import{t as f}from"./CliIcon-DVX5iLhG.js";import{k as p}from"./index-DD3J11PT.js";import{n as m,t as h}from"./Pane-DTmByqgA.js";import{a as g,o as _,r as v}from"./citizen-BPIJzKdn.js";import{r as y}from"./Quota-D8WDWp5H.js";var b=r(t(),1),x=a(),S=[{window:`24h`,label:`24h`,title:`the last 24 hours`},{window:`7d`,label:`7d`,title:`the last 7 days`},{window:`all`,label:`All`,title:`all time`}];function C(e){let t=e.lastModel??e.model??`CLI default`,n=e.model!==void 0&&e.model!==t?`${t} · set to ${e.model}`:t;return e.effort===void 0?n:`${n} · ${e.effort}`}function w(e,t){return e.name.localeCompare(t.name)}function T(e,t){return e.role.localeCompare(t.role)||w(e,t)}function E({member:e,state:t,tokens:n,outputs:r,runners:i,placed:a,now:o}){let c=C(e),l=e.memberships.length===0?`no projects`:e.memberships.join(`, `),u=v(e,a);return(0,x.jsx)(`li`,{className:`col-span-full grid grid-cols-subgrid`,children:(0,x.jsxs)(s,{to:`/citizen/$name`,params:{name:e.name},className:`col-span-full grid grid-cols-subgrid items-center rounded-lg px-2 py-1.5 text-sm transition-colors hover:bg-surface-2/50`,children:[(0,x.jsxs)(`span`,{className:`relative grid size-4 place-items-center`,children:[e.cli===null?null:(0,x.jsx)(f,{cli:e.cli,size:13}),e.status===`active`?(0,x.jsx)(y,{member:e,runners:i,placed:a,now:o}):null]}),(0,x.jsx)(`span`,{className:`text-fg-primary`,children:e.name}),(0,x.jsx)(`span`,{className:`text-fg-secondary`,children:e.role}),(0,x.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,title:c,children:c}),(0,x.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,title:u.detail,children:u.label}),(0,x.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,title:l,children:l}),(0,x.jsxs)(`span`,{className:`col-[2/-1] row-start-2 text-right text-xs whitespace-nowrap text-fg-muted tabular-nums @min-[560px]:col-auto @min-[560px]:row-auto`,title:n.detail,children:[n.counts===null?n.label:(0,x.jsxs)(x.Fragment,{children:[`${n.counts.input} · `,(0,x.jsxs)(`span`,{className:`inline-grid justify-items-end`,children:[(0,x.jsx)(`span`,{className:`[grid-area:1/1]`,children:n.counts.output}),r.map(e=>(0,x.jsx)(`span`,{"data-width":e,className:`invisible [grid-area:1/1] before:content-[attr(data-width)]`},e))]})]}),n.spoken===null?null:(0,x.jsxs)(`span`,{className:`sr-only`,children:[`, `,n.spoken]})]}),(0,x.jsxs)(`span`,{className:`text-right text-xs whitespace-nowrap @min-[560px]:-ml-2 @min-[560px]:text-left`,children:[(0,x.jsxs)(`span`,{"aria-hidden":`true`,className:`hidden text-fg-muted @min-[560px]:inline`,children:[`·`,` `]}),(0,x.jsx)(`span`,{className:t.tone,title:t.detail,children:t.label})]})]})})}function D(){let{window:t=`24h`}=p({from:`/citizens`}),r=c(),a=i(),f=d(),v=e(),y=n(t),C=l(3e4),D=(0,b.useId)(),O=(0,b.useId)();if(r.data===void 0)return(0,x.jsx)(m,{children:`Reading the roster…`});let k=r.data.filter(e=>e.cli!==null),A=k.filter(e=>e.status===`active`).toSorted(T),j=k.filter(e=>e.status!==`active`).toSorted(w),M=new Set(A.map(e=>e.role)).size,N=o(a.data?.running??[]),P=o(a.data?.pending??[]),F=new Map((f.data??[]).flatMap(e=>e.runner===void 0?[]:[[e.slug,e.runner]])),I=new Map((y.data?.citizens??[]).map(e=>[e.agent,e])),L=e=>{if(e.status!==`active`)return{label:`retired`,detail:e.retiredAt===void 0?`retired`:`retired ${u(e.retiredAt,C)}`,tone:`text-fg-muted`};let t=[...new Set(N.filter(t=>t.agent===e.name).map(e=>e.scope))];return t.length>0?{label:`working`,detail:`in a turn at ${t.map(g).join(` and `)}`,tone:`text-emerald-300`}:P.some(t=>t.agent===e.name)?{label:`queued`,detail:`queued for a turn`,tone:`text-amber-300`}:{label:`resting`,detail:`resting`,tone:`text-fg-muted`}},R=e=>y.data===void 0?y.error===null?{label:`counting…`,counts:null,detail:void 0,spoken:null}:{label:`tokens unknown`,counts:null,detail:y.error.message,spoken:null}:_(I.get(e.name),t),z=[...new Set([...A,...j].flatMap(e=>R(e).counts?.output??[]))],B=e=>(0,x.jsx)(E,{member:e,state:L(e),tokens:R(e),outputs:z,runners:v.data??[],placed:F,now:C},e.name),V=(0,x.jsxs)(`nav`,{"aria-labelledby":D,className:`flex shrink-0 items-center gap-1`,children:[(0,x.jsx)(`span`,{id:D,className:`mr-1 text-caps`,children:`Tokens`}),S.map(e=>(0,x.jsx)(s,{to:`/citizens`,search:{window:e.window},title:e.title,"aria-current":e.window===t?`page`:void 0,className:`rounded-md px-2 py-1 text-xs transition-colors ${e.window===t?`bg-surface-2 text-fg-primary`:`text-fg-tertiary hover:bg-surface-2/70 hover:text-fg-primary`}`,children:e.label},e.window))]});return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(h,{title:`Citizens`,subtitle:`${A.length} active in ${M===1?`1 role`:`${M} roles`}${j.length===0?``:` · ${j.length} retired`}`,trailing:V}),(0,x.jsxs)(`div`,{className:`@container flex-1 overflow-y-auto px-2 py-2`,children:[A.length===0?(0,x.jsx)(`p`,{className:`px-2 py-2 text-meta`,children:j.length===0?`No citizens yet.`:`No active citizens.`}):null,(0,x.jsxs)(`div`,{className:`grid grid-cols-[auto_auto_auto_minmax(0,max-content)_minmax(0,max-content)_minmax(3rem,1fr)_auto] gap-x-3 @min-[560px]:grid-cols-[auto_auto_auto_minmax(0,max-content)_minmax(0,max-content)_minmax(0,max-content)_minmax(max-content,1fr)_auto]`,children:[(0,x.jsx)(`ul`,{className:`col-span-full grid grid-cols-subgrid`,children:A.map(B)}),j.length===0?null:(0,x.jsxs)(`section`,{"aria-labelledby":O,className:`col-span-full mt-2 grid grid-cols-subgrid border-t border-line pt-2`,children:[(0,x.jsx)(`h3`,{id:O,className:`col-span-full px-2 py-1 text-section`,children:`Retired`}),(0,x.jsx)(`ul`,{className:`col-span-full grid grid-cols-subgrid`,children:j.map(B)})]})]})]})]})}export{D as CitizensView};
1
+ import{H as e,Jt as t,O as n,S as r,Un as i,Wn as a,X as o,k as s,qn as c,t as l,v as u,x as d}from"./format-CENiwkJC.js";import{t as f}from"./CliIcon-C7bwChMP.js";import{k as p}from"./index-CPXALUV6.js";import{n as m,t as h}from"./Pane-BaM0TdE6.js";import{a as g,o as _,r as v}from"./citizen-BiHfph2A.js";import{r as y}from"./Quota-CfFGIql9.js";var b=c(a(),1),x=i(),S=[{window:`24h`,label:`24h`,title:`the last 24 hours`},{window:`7d`,label:`7d`,title:`the last 7 days`},{window:`all`,label:`All`,title:`all time`}];function C(e){let t=e.lastModel??e.model??`CLI default`,n=e.model!==void 0&&e.model!==t?`${t} · set to ${e.model}`:t;return e.effort===void 0?n:`${n} · ${e.effort}`}function w(e,t){return e.name.localeCompare(t.name)}function T(e,t){return e.role.localeCompare(t.role)||w(e,t)}function E({member:e,state:n,tokens:r,outputs:i,runners:a,placed:o,now:s}){let c=C(e),l=e.memberships.length===0?`no projects`:e.memberships.join(`, `),u=v(e,o);return(0,x.jsx)(`li`,{className:`col-span-full grid grid-cols-subgrid`,children:(0,x.jsxs)(t,{to:`/citizen/$name`,params:{name:e.name},className:`col-span-full grid grid-cols-subgrid items-center rounded-lg px-2 py-1.5 text-sm transition-colors hover:bg-surface-2/50`,children:[(0,x.jsxs)(`span`,{className:`relative grid size-4 place-items-center`,children:[e.cli===null?null:(0,x.jsx)(f,{cli:e.cli,size:13}),e.status===`active`?(0,x.jsx)(y,{member:e,runners:a,placed:o,now:s}):null]}),(0,x.jsx)(`span`,{className:`text-fg-primary`,children:e.name}),(0,x.jsx)(`span`,{className:`text-fg-secondary`,children:e.role}),(0,x.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,title:c,children:c}),(0,x.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,title:u.detail,children:u.label}),(0,x.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,title:l,children:l}),(0,x.jsxs)(`span`,{className:`col-[2/-1] row-start-2 text-right text-xs whitespace-nowrap text-fg-muted tabular-nums @min-[560px]:col-auto @min-[560px]:row-auto`,title:r.detail,children:[r.counts===null?r.label:(0,x.jsxs)(x.Fragment,{children:[`${r.counts.input} · `,(0,x.jsxs)(`span`,{className:`inline-grid justify-items-end`,children:[(0,x.jsx)(`span`,{className:`[grid-area:1/1]`,children:r.counts.output}),i.map(e=>(0,x.jsx)(`span`,{"data-width":e,className:`invisible [grid-area:1/1] before:content-[attr(data-width)]`},e))]})]}),r.spoken===null?null:(0,x.jsxs)(`span`,{className:`sr-only`,children:[`, `,r.spoken]})]}),(0,x.jsxs)(`span`,{className:`text-right text-xs whitespace-nowrap @min-[560px]:-ml-2 @min-[560px]:text-left`,children:[(0,x.jsxs)(`span`,{"aria-hidden":`true`,className:`hidden text-fg-muted @min-[560px]:inline`,children:[`·`,` `]}),(0,x.jsx)(`span`,{className:n.tone,title:n.detail,children:n.label})]})]})})}function D(){let{window:i=`24h`}=p({from:`/citizens`}),a=u(),c=s(),f=r(),v=n(),y=e(i),C=d(3e4),D=(0,b.useId)(),O=(0,b.useId)();if(a.data===void 0)return(0,x.jsx)(m,{children:`Reading the roster…`});let k=a.data.filter(e=>e.cli!==null),A=k.filter(e=>e.status===`active`).toSorted(T),j=k.filter(e=>e.status!==`active`).toSorted(w),M=new Set(A.map(e=>e.role)).size,N=o(c.data?.running??[]),P=o(c.data?.pending??[]),F=new Map((f.data??[]).flatMap(e=>e.runner===void 0?[]:[[e.slug,e.runner]])),I=new Map((y.data?.citizens??[]).map(e=>[e.agent,e])),L=e=>{if(e.status!==`active`)return{label:`retired`,detail:e.retiredAt===void 0?`retired`:`retired ${l(e.retiredAt,C)}`,tone:`text-fg-muted`};let t=[...new Set(N.filter(t=>t.agent===e.name).map(e=>e.scope))];return t.length>0?{label:`working`,detail:`in a turn at ${t.map(g).join(` and `)}`,tone:`text-emerald-300`}:P.some(t=>t.agent===e.name)?{label:`queued`,detail:`queued for a turn`,tone:`text-amber-300`}:{label:`resting`,detail:`resting`,tone:`text-fg-muted`}},R=e=>y.data===void 0?y.error===null?{label:`counting…`,counts:null,detail:void 0,spoken:null}:{label:`tokens unknown`,counts:null,detail:y.error.message,spoken:null}:_(I.get(e.name),i),z=[...new Set([...A,...j].flatMap(e=>R(e).counts?.output??[]))],B=e=>(0,x.jsx)(E,{member:e,state:L(e),tokens:R(e),outputs:z,runners:v.data??[],placed:F,now:C},e.name),V=(0,x.jsxs)(`nav`,{"aria-labelledby":D,className:`flex shrink-0 items-center gap-1`,children:[(0,x.jsx)(`span`,{id:D,className:`mr-1 text-caps`,children:`Tokens`}),S.map(e=>(0,x.jsx)(t,{to:`/citizens`,search:{window:e.window},title:e.title,"aria-current":e.window===i?`page`:void 0,className:`rounded-md px-2 py-1 text-xs transition-colors ${e.window===i?`bg-surface-2 text-fg-primary`:`text-fg-tertiary hover:bg-surface-2/70 hover:text-fg-primary`}`,children:e.label},e.window))]});return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(h,{title:`Citizens`,subtitle:`${A.length} active in ${M===1?`1 role`:`${M} roles`}${j.length===0?``:` · ${j.length} retired`}`,trailing:V}),(0,x.jsxs)(`div`,{className:`@container flex-1 overflow-y-auto px-2 py-2`,children:[A.length===0?(0,x.jsx)(`p`,{className:`px-2 py-2 text-meta`,children:j.length===0?`No citizens yet.`:`No active citizens.`}):null,(0,x.jsxs)(`div`,{className:`grid grid-cols-[auto_auto_auto_minmax(0,max-content)_minmax(0,max-content)_minmax(3rem,1fr)_auto] gap-x-3 @min-[560px]:grid-cols-[auto_auto_auto_minmax(0,max-content)_minmax(0,max-content)_minmax(0,max-content)_minmax(max-content,1fr)_auto]`,children:[(0,x.jsx)(`ul`,{className:`col-span-full grid grid-cols-subgrid`,children:A.map(B)}),j.length===0?null:(0,x.jsxs)(`section`,{"aria-labelledby":O,className:`col-span-full mt-2 grid grid-cols-subgrid border-t border-line pt-2`,children:[(0,x.jsx)(`h3`,{id:O,className:`col-span-full px-2 py-1 text-section`,children:`Retired`}),(0,x.jsx)(`ul`,{className:`col-span-full grid grid-cols-subgrid`,children:j.map(B)})]})]})]})]})}export{D as CitizensView};
@@ -1 +1 @@
1
- import{Wn as e}from"./format-CvfmDNoY.js";var t=`M6.766 11.328c-2.063-.25-3.516-1.734-3.516-3.656 0-.781.281-1.625.75-2.188-.203-.515-.172-1.609.063-2.062.625-.078 1.468.25 1.968.703.594-.187 1.219-.281 1.985-.281.765 0 1.39.094 1.953.265.484-.437 1.344-.765 1.969-.687.218.422.25 1.515.046 2.047.5.593.766 1.39.766 2.203 0 1.922-1.453 3.375-3.547 3.64.531.344.89 1.094.89 1.954v1.625c0 .468.391.734.86.547C13.781 14.359 16 11.53 16 8.03 16 3.61 12.406 0 7.984 0 3.563 0 0 3.61 0 8.031a7.88 7.88 0 0 0 5.172 7.422c.422.156.828-.125.828-.547v-1.25c-.219.094-.5.156-.75.156-1.031 0-1.64-.562-2.078-1.609-.172-.422-.36-.672-.719-.719-.187-.015-.25-.093-.25-.187 0-.188.313-.328.625-.328.453 0 .844.281 1.25.86.313.452.64.655 1.031.655s.641-.14 1-.5c.266-.265.47-.5.657-.656`,n={claude:{label:`Claude Code`,path:`M20.998 10.949H24v3.102h-3v3.028h-1.487V20H18v-2.921h-1.487V20H15v-2.921H9V20H7.488v-2.921H6V20H4.487v-2.921H3V14.05H0V10.95h3V5h17.998v5.949zM6 10.949h1.488V8.102H6v2.847zm10.51 0H18V8.102h-1.49v2.847z`,fill:`#D97757`,accent:`#fb923c`},codex:{label:`Codex`,path:`M8.086.457a6.105 6.105 0 013.046-.415c1.333.153 2.521.72 3.564 1.7a.117.117 0 00.107.029c1.408-.346 2.762-.224 4.061.366l.063.03.154.076c1.357.703 2.33 1.77 2.918 3.198.278.679.418 1.388.421 2.126a5.655 5.655 0 01-.18 1.631.167.167 0 00.04.155 5.982 5.982 0 011.578 2.891c.385 1.901-.01 3.615-1.183 5.14l-.182.22a6.063 6.063 0 01-2.934 1.851.162.162 0 00-.108.102c-.255.736-.511 1.364-.987 1.992-1.199 1.582-2.962 2.462-4.948 2.451-1.583-.008-2.986-.587-4.21-1.736a.145.145 0 00-.14-.032c-.518.167-1.04.191-1.604.185a5.924 5.924 0 01-2.595-.622 6.058 6.058 0 01-2.146-1.781c-.203-.269-.404-.522-.551-.821a7.74 7.74 0 01-.495-1.283 6.11 6.11 0 01-.017-3.064.166.166 0 00.008-.074.115.115 0 00-.037-.064 5.958 5.958 0 01-1.38-2.202 5.196 5.196 0 01-.333-1.589 6.915 6.915 0 01.188-2.132c.45-1.484 1.309-2.648 2.577-3.493.282-.188.55-.334.802-.438.286-.12.573-.22.861-.304a.129.129 0 00.087-.087A6.016 6.016 0 015.635 2.31C6.315 1.464 7.132.846 8.086.457zm-.804 7.85a.848.848 0 00-1.473.842l1.694 2.965-1.688 2.848a.849.849 0 001.46.864l1.94-3.272a.849.849 0 00.007-.854l-1.94-3.393zm5.446 6.24a.849.849 0 000 1.695h4.848a.849.849 0 000-1.696h-4.848z`,fill:`#f5f5f5`,accent:`#10b981`}},r=e();function i({cli:e,size:t=16}){let i=n[e];return(0,r.jsx)(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,"aria-hidden":`true`,className:`shrink-0`,children:(0,r.jsx)(`path`,{d:i.path,fill:i.fill,fillRule:`evenodd`,clipRule:`evenodd`})})}export{n,t as r,i as t};
1
+ import{Un as e}from"./format-CENiwkJC.js";var t=`M6.766 11.328c-2.063-.25-3.516-1.734-3.516-3.656 0-.781.281-1.625.75-2.188-.203-.515-.172-1.609.063-2.062.625-.078 1.468.25 1.968.703.594-.187 1.219-.281 1.985-.281.765 0 1.39.094 1.953.265.484-.437 1.344-.765 1.969-.687.218.422.25 1.515.046 2.047.5.593.766 1.39.766 2.203 0 1.922-1.453 3.375-3.547 3.64.531.344.89 1.094.89 1.954v1.625c0 .468.391.734.86.547C13.781 14.359 16 11.53 16 8.03 16 3.61 12.406 0 7.984 0 3.563 0 0 3.61 0 8.031a7.88 7.88 0 0 0 5.172 7.422c.422.156.828-.125.828-.547v-1.25c-.219.094-.5.156-.75.156-1.031 0-1.64-.562-2.078-1.609-.172-.422-.36-.672-.719-.719-.187-.015-.25-.093-.25-.187 0-.188.313-.328.625-.328.453 0 .844.281 1.25.86.313.452.64.655 1.031.655s.641-.14 1-.5c.266-.265.47-.5.657-.656`,n={claude:{label:`Claude Code`,path:`M20.998 10.949H24v3.102h-3v3.028h-1.487V20H18v-2.921h-1.487V20H15v-2.921H9V20H7.488v-2.921H6V20H4.487v-2.921H3V14.05H0V10.95h3V5h17.998v5.949zM6 10.949h1.488V8.102H6v2.847zm10.51 0H18V8.102h-1.49v2.847z`,fill:`#D97757`,accent:`#fb923c`},codex:{label:`Codex`,path:`M8.086.457a6.105 6.105 0 013.046-.415c1.333.153 2.521.72 3.564 1.7a.117.117 0 00.107.029c1.408-.346 2.762-.224 4.061.366l.063.03.154.076c1.357.703 2.33 1.77 2.918 3.198.278.679.418 1.388.421 2.126a5.655 5.655 0 01-.18 1.631.167.167 0 00.04.155 5.982 5.982 0 011.578 2.891c.385 1.901-.01 3.615-1.183 5.14l-.182.22a6.063 6.063 0 01-2.934 1.851.162.162 0 00-.108.102c-.255.736-.511 1.364-.987 1.992-1.199 1.582-2.962 2.462-4.948 2.451-1.583-.008-2.986-.587-4.21-1.736a.145.145 0 00-.14-.032c-.518.167-1.04.191-1.604.185a5.924 5.924 0 01-2.595-.622 6.058 6.058 0 01-2.146-1.781c-.203-.269-.404-.522-.551-.821a7.74 7.74 0 01-.495-1.283 6.11 6.11 0 01-.017-3.064.166.166 0 00.008-.074.115.115 0 00-.037-.064 5.958 5.958 0 01-1.38-2.202 5.196 5.196 0 01-.333-1.589 6.915 6.915 0 01.188-2.132c.45-1.484 1.309-2.648 2.577-3.493.282-.188.55-.334.802-.438.286-.12.573-.22.861-.304a.129.129 0 00.087-.087A6.016 6.016 0 015.635 2.31C6.315 1.464 7.132.846 8.086.457zm-.804 7.85a.848.848 0 00-1.473.842l1.694 2.965-1.688 2.848a.849.849 0 001.46.864l1.94-3.272a.849.849 0 00.007-.854l-1.94-3.393zm5.446 6.24a.849.849 0 000 1.695h4.848a.849.849 0 000-1.696h-4.848z`,fill:`#f5f5f5`,accent:`#10b981`}},r=e();function i({cli:e,size:t=16}){let i=n[e];return(0,r.jsx)(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,"aria-hidden":`true`,className:`shrink-0`,children:(0,r.jsx)(`path`,{d:i.path,fill:i.fill,fillRule:`evenodd`,clipRule:`evenodd`})})}export{n,t as r,i as t};
@@ -0,0 +1 @@
1
+ import{F as e,Hn as t,Jt as n,Pt as r,S as i,Un as a,V as o,Wn as s,gt as c,j as l,qn as u,t as d,u as f,v as p,x as m}from"./format-CENiwkJC.js";import{n as h,t as g}from"./Button-Cp4cNRUX.js";import{t as _}from"./CliIcon-C7bwChMP.js";import{D as v,E as y,T as b,k as x,w as S}from"./index-CPXALUV6.js";import{t as C}from"./Markdown-DT3V-EVe.js";import{a as w,o as T,r as E}from"./ThreadForms-CG5Y926b.js";import{n as D,t as O}from"./Pane-BaM0TdE6.js";import{a as k,d as A,i as j}from"./citizen-BiHfph2A.js";import{n as M,r as N,t as P}from"./Picker-C2ig-0dT.js";var F=u(s(),1),I=a(),L=[`UTC`,...Intl.supportedValuesOf(`timeZone`).filter(e=>e!==`UTC`)],R=50;function z(e,t){let n=new Intl.DateTimeFormat(`en-US`,{timeZone:e,timeZoneName:`longOffset`}).formatToParts(t).find(e=>e.type===`timeZoneName`)?.value??``;return n===`GMT`?`UTC`:n.replace(`GMT`,`UTC`)}function B({value:e,onChange:t,label:n,placeholder:r}){let[i,a]=(0,F.useState)(!1),[o,s]=(0,F.useState)(0),c=(0,F.useRef)(null),l=(0,F.useRef)([]),u=e.trim().toLowerCase(),d=(0,F.useMemo)(()=>(u===``?L:L.filter(e=>e.toLowerCase().includes(u))).slice(0,R),[u]),f=(0,F.useMemo)(()=>new Date,[]);(0,F.useEffect)(()=>{i&&l.current[o]?.scrollIntoView({block:`nearest`})},[i,o]),(0,F.useEffect)(()=>{if(!i)return;let e=e=>{e.target instanceof Node&&c.current?.contains(e.target)===!0||a(!1)};return window.addEventListener(`click`,e),()=>window.removeEventListener(`click`,e)},[i]);let p=e=>{t(e),a(!1)};return(0,I.jsxs)(`div`,{ref:c,className:`relative min-w-0 flex-1`,children:[(0,I.jsx)(`input`,{"aria-label":n,value:e,spellCheck:!1,autoComplete:`off`,placeholder:r,onChange:e=>{t(e.target.value),s(0),a(!0)},onClick:()=>a(!0),onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(e.preventDefault(),!i){a(!0);return}let t=e.key===`ArrowDown`?1:-1;s(e=>(e+t+d.length)%Math.max(d.length,1))}else e.key===`Enter`&&i&&d[o]!==void 0?(e.preventDefault(),p(d[o])):e.key===`Tab`?a(!1):e.key===`Escape`&&i&&(e.preventDefault(),e.stopPropagation(),a(!1))},className:T}),i&&d.length>0&&(d.length!==1||d[0]!==e)?(0,I.jsx)(`div`,{className:`max-h-48 ${P}`,children:d.map((e,t)=>(0,I.jsxs)(`button`,{ref:e=>{l.current[t]=e},type:`button`,tabIndex:-1,"aria-current":t===o?`true`:void 0,onPointerDown:e=>e.preventDefault(),onPointerEnter:()=>s(t),onClick:()=>p(e),className:N(t===o),children:[(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-fg-secondary`,children:e}),(0,I.jsx)(`span`,{className:`shrink-0 text-[11px] text-fg-muted`,children:z(e,f)})]},e))}):null]})}function V({word:e,children:t}){return(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[(0,I.jsx)(`span`,{className:`shrink-0 text-xs text-fg-tertiary`,children:e}),t]})}function H(e,t){return r(typeof e==`string`?new Date(e):e,t)}function U({cron:e}){let t=o(),r=b(e);if(r.kind===`thread`){let e=t.data?.find(e=>e.id===r.id)?.title??r.id;return(0,I.jsxs)(n,{to:`/thread/$threadId`,params:{threadId:r.id},className:`truncate hover:text-fg-primary`,children:[`thread “`,e,`”`]})}return r.kind===`channel`?(0,I.jsxs)(n,{to:`/c/$`,params:{_splat:r.ref},className:`hover:text-fg-primary`,children:[`#`,r.ref]}):r.kind===`place`?(0,I.jsxs)(n,{to:`/p/$slug`,params:{slug:r.project},className:`hover:text-fg-primary`,children:[r.project,`'s channels`]}):(0,I.jsxs)(`span`,{children:[`home at `,k(r.scope)]})}function W({cron:e,next:r,member:i,zone:a,now:o,focused:s}){let c=(0,F.useRef)(null);(0,F.useEffect)(()=>{s&&c.current!==null&&(c.current.open=!0,c.current.scrollIntoView({block:`nearest`}))},[s]);let{api:u}=l(),f=t(),[p,m]=(0,F.useState)(!1),[v,b]=(0,F.useState)(``),x=()=>void f.invalidateQueries({queryKey:[`crons`]}),S=h({mutationFn:t=>u.pauseCron(e.id,t),onSuccess:x}),w=h({mutationFn:()=>u.removeCron(e.id,v.trim()),onSuccess:x}),D=`at`in e.schedule?`once, ${H(e.schedule.at,a)}`:`${e.schedule.cron} · ${e.schedule.timezone??a}`,O=e.ended===void 0?e.paused===void 0?r===null?`no time to come`:r.getTime()<=o?`due, waiting for its turn`:d(r.toISOString(),o):`paused`:`ended ${d(e.ended.at,o)}`,k=y(e);return(0,I.jsx)(`li`,{className:`rounded-lg ${s?`bg-surface-2/30`:``}`,children:(0,I.jsxs)(`details`,{ref:c,className:`group`,children:[(0,I.jsxs)(`summary`,{className:`cursor-pointer list-none rounded-lg px-2 py-2 hover:bg-surface-2/40 focus-visible:ring-2 focus-visible:ring-fg-primary/30 focus-visible:outline-none`,children:[(0,I.jsxs)(`div`,{className:`flex items-baseline gap-2 text-sm`,children:[i?.cli===void 0||i.cli===null?null:(0,I.jsx)(_,{cli:i.cli,size:13}),(0,I.jsx)(`span`,{className:`shrink-0 text-fg-secondary`,children:e.agent}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-fg-primary`,children:e.title}),(0,I.jsx)(`span`,{className:`shrink-0 text-xs ${e.paused===void 0?`text-fg-muted`:`text-amber-300`}`,title:r===null?void 0:`${H(r,a)}, ${a}`,children:O})]}),(0,I.jsxs)(`p`,{className:`mt-0.5 flex items-baseline gap-1.5 truncate text-meta`,children:[(0,I.jsx)(`span`,{children:D}),(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,I.jsx)(U,{cron:e}),e.lastRun===void 0?null:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,I.jsxs)(`span`,{children:[`last turn `,e.lastRun.outcome,` `,d(e.lastRun.at,o)]})]}),k?(0,I.jsxs)(`span`,{className:`text-amber-300`,children:[`· `,e.failures,` failed in a row`]}):null]})]}),(0,I.jsxs)(`div`,{className:`space-y-3 px-2 pt-1 pb-3`,children:[(0,I.jsx)(`div`,{className:`rounded-lg bg-surface-2/30 px-3 py-2`,children:(0,I.jsx)(C,{text:e.note})}),(0,I.jsxs)(`p`,{className:`text-meta`,children:[`Set by `,e.createdBy,` `,d(e.createdAt,o),e.lastFiredAt===void 0?``:` · fired last ${H(e.lastFiredAt,a)}`,e.ended===void 0?``:` · ended by ${e.ended.by}: ${e.ended.reason}`]}),r===null?null:(0,I.jsxs)(`p`,{className:`text-meta`,children:[`Next `,H(r,a),` (`,a,`)`]}),e.lastRun===void 0?null:(0,I.jsx)(n,{to:`/citizen/$name`,params:{name:e.agent},search:{tab:`turns`,turn:e.lastRun.turnId},className:`text-meta underline-offset-2 hover:text-fg-primary hover:underline`,children:`Open its last turn`}),e.ended===void 0?p?(0,I.jsxs)(`form`,{"aria-label":`Remove ${e.title}`,className:`space-y-2`,onSubmit:e=>{e.preventDefault(),w.mutate()},children:[(0,I.jsx)(`input`,{value:v,"aria-label":`Why it ends`,placeholder:`Why it ends`,onChange:e=>b(e.target.value),className:T}),(0,I.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,I.jsx)(g,{onClick:()=>m(!1),children:`Cancel`}),(0,I.jsx)(g,{variant:`primary`,type:`submit`,disabled:w.isPending||v.trim()===``,children:w.isPending?`Removing…`:`Remove cron`})]}),(0,I.jsx)(E,{error:w.error})]}):(0,I.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,I.jsx)(g,{onClick:()=>S.mutate(e.paused===void 0),disabled:S.isPending,children:e.paused===void 0?`Pause`:`Resume`}),(0,I.jsx)(g,{onClick:()=>m(!0),children:`Remove…`}),(0,I.jsx)(E,{error:S.error})]}):null]})]})})}function G({zone:e,onDone:n}){let{api:r}=l(),i=t(),[a,o]=(0,F.useState)(e),s=new Intl.DateTimeFormat().resolvedOptions().timeZone,c=h({mutationFn:()=>r.setTimezone(a.trim()),onSuccess:()=>{i.invalidateQueries({queryKey:[`society`]}),i.invalidateQueries({queryKey:[`crons`]}),n()}});return(0,I.jsxs)(`form`,{"aria-label":`Time zone`,className:`space-y-2 border-b border-line bg-surface-2/20 p-3`,onSubmit:e=>{e.preventDefault(),c.mutate()},children:[(0,I.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,I.jsx)(B,{value:a,onChange:o,label:`Society time zone`}),s===a?null:(0,I.jsxs)(g,{onClick:()=>o(s),children:[`Use `,s]})]}),(0,I.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,I.jsx)(g,{onClick:n,children:`Cancel`}),(0,I.jsx)(g,{variant:`primary`,type:`submit`,disabled:c.isPending||a.trim()===``||a.trim()===e,children:c.isPending?`Saving…`:`Save`})]}),(0,I.jsx)(E,{error:c.error})]})}function K({members:n,preferred:r,zone:a,onDone:o}){let{api:s}=l(),u=t(),d=i(),f=e(),[p,_]=(0,F.useState)(n.find(e=>e.name===r)?.name??n[0]?.name??``),y=n.find(e=>e.name===p),b=y===void 0?[]:A(y),[x,S]=(0,F.useState)(b[0]??`society`),[C,D]=(0,F.useState)(``),[O,k]=(0,F.useState)(`repeats`),[N,P]=(0,F.useState)(`0 9 * * 1-5`),[L,R]=(0,F.useState)(``),[z,U]=(0,F.useState)(``),[W,G]=(0,F.useState)(``),[K,q]=(0,F.useState)(``),J=(0,F.useRef)(null);(0,F.useEffect)(()=>J.current?.focus(),[]);let Y=m(3e4),ee=(x===`society`?f.data?.channels??[]:d.data?.find(e=>e.slug===x)?.channels??[]).filter(e=>e!==`general`),X=O===`repeats`?{cron:N,...L.trim()===``?{}:{timezone:L.trim()}}:{at:z===``?``:new Date(z).toISOString()},Z=v(O===`once`&&z===``?{at:`invalid`}:X,a,new Date(Y)),Q=O===`repeats`?L.trim()===``?a:L.trim():a,$=h({mutationFn:()=>s.createCron({agent:p,title:W.trim(),note:K.trim(),project:x,...C===``?{}:{channel:C},...X}),onSuccess:()=>{u.invalidateQueries({queryKey:[`crons`]}),o()}});return(0,I.jsxs)(`form`,{"aria-label":`New cron`,className:`space-y-2 border-b border-line bg-surface-2/20 p-3`,onSubmit:e=>{e.preventDefault(),$.mutate()},children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(V,{word:`wakes`,children:(0,I.jsx)(M,{label:`Citizen`,choices:n.map(e=>({value:e.name,name:e.name,id:e.role,description:e.memberships.length===0?`in no project`:`in ${e.memberships.join(`, `)}`})),value:p,onChange:e=>{let t=n.find(t=>t.name===e);_(e),S(t===void 0?c:A(t)[0]??`society`),D(``)}})}),(0,I.jsx)(V,{word:`at`,children:(0,I.jsx)(M,{label:`Where`,choices:j(b),value:x,onChange:e=>{S(e),D(``)}})}),(0,I.jsx)(V,{word:`in`,children:(0,I.jsx)(M,{label:`Conversation`,choices:[{value:``,name:`its home`,id:null,description:`general, and work tied to no other channel`},...ee.map(e=>({value:e,name:`#${e}`,id:null,description:`a workstream's own conversation`}))],value:C,onChange:D})})]}),(0,I.jsx)(`input`,{ref:J,value:W,maxLength:120,"aria-label":`Title`,placeholder:`Title, such as Morning report`,onChange:e=>G(e.target.value),className:T}),(0,I.jsx)(`textarea`,{value:K,rows:3,"aria-label":`Note`,placeholder:`What to do when it fires`,onChange:e=>q(e.target.value),className:w}),(0,I.jsxs)(`fieldset`,{className:`flex gap-1`,children:[(0,I.jsx)(`legend`,{className:`sr-only`,children:`How often`}),[`repeats`,`once`].map(e=>(0,I.jsxs)(`label`,{className:`cursor-pointer rounded-md px-2.5 py-1 text-xs transition-colors has-focus-visible:ring-2 has-focus-visible:ring-fg-primary/30 ${O===e?`bg-surface-2 text-fg-primary`:`text-fg-tertiary hover:bg-surface-2/60 hover:text-fg-primary`}`,children:[(0,I.jsx)(`input`,{type:`radio`,name:`kind`,value:e,checked:O===e,onChange:()=>k(e),className:`sr-only`}),e===`repeats`?`Repeats`:`Once`]},e))]}),O===`repeats`?(0,I.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,I.jsx)(`div`,{className:`w-44 shrink-0`,children:(0,I.jsx)(`input`,{value:N,spellCheck:!1,"aria-label":`Cron expression`,placeholder:`minute hour day month weekday`,onChange:e=>P(e.target.value),className:T})}),(0,I.jsx)(B,{value:L,onChange:R,label:`Its time zone`,placeholder:`${a}, the society's`})]}):(0,I.jsx)(`input`,{type:`datetime-local`,value:z,"aria-label":`When, in this browser's time`,onChange:e=>U(e.target.value),className:T}),(0,I.jsx)(`p`,{"aria-live":`polite`,className:`text-xs leading-relaxed text-fg-muted`,children:`error`in Z?(0,I.jsx)(`span`,{className:`text-amber-300`,children:Z.error}):(0,I.jsxs)(I.Fragment,{children:[Z.times.length===1?`Fires `:`Fires next `,Z.times.map(e=>H(e,Q)).join(`, `),` (`,Q,`).`]})}),(0,I.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,I.jsx)(g,{onClick:o,children:`Cancel`}),(0,I.jsx)(g,{variant:`primary`,type:`submit`,disabled:$.isPending||p===``||W.trim()===``||K.trim()===``||`error`in Z,children:$.isPending?`Setting…`:`Set cron`})]}),(0,I.jsx)(E,{error:$.error})]})}function q(){let{agent:t,cron:r}=x({from:`/crons`}),i=f(),a=p(),o=e(),s=m(3e4),[c,l]=(0,F.useState)(null),u=o.data?.timezone??`UTC`,d=(i.data??[]).filter(e=>t===void 0||e.agent===t),h=S(d,u),_=d.filter(y).length,v=(a.data??[]).filter(e=>e.status===`active`&&e.cli!==null),b=e=>a.data?.find(t=>t.name===e);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(O,{title:t===void 0?`Crons`:`Crons of ${t}`,subtitle:[`${h.active.length} running`,...h.paused.length===0?[]:[`${h.paused.length} paused`],..._===0?[]:[`${_} failing`],`times in ${u}`].join(` · `),trailing:c===null?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(g,{onClick:()=>l(`zone`),children:`Time zone…`}),(0,I.jsx)(g,{onClick:()=>l(`new`),disabled:v.length===0,children:`New cron…`})]}):null}),c===`new`?(0,I.jsx)(K,{members:v,preferred:t,zone:u,onDone:()=>l(null)}):c===`zone`?(0,I.jsx)(G,{zone:u,onDone:()=>l(null)}):null,(0,I.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-2 py-2`,children:[t===void 0?null:(0,I.jsx)(n,{to:`/crons`,className:`block px-2 pb-2 text-meta hover:text-fg-primary`,children:`Show every citizen's crons`}),i.error!==null&&i.data===void 0?(0,I.jsxs)(D,{children:[`Could not read the crons: `,i.error.message]}):i.data===void 0?(0,I.jsx)(D,{children:`Reading the crons…`}):h.active.length+h.paused.length+h.ended.length===0?(0,I.jsx)(`p`,{className:`px-2 py-2 text-meta`,children:`No crons yet.`}):null,h.active.length===0?null:(0,I.jsx)(`ul`,{"aria-label":`Running`,className:`space-y-0.5`,children:h.active.map(({cron:e,next:t})=>(0,I.jsx)(W,{cron:e,next:t,member:b(e.agent),zone:u,now:s,focused:e.id===r},e.id))}),h.paused.length===0?null:(0,I.jsxs)(`section`,{"aria-label":`Paused`,className:`mt-3`,children:[(0,I.jsx)(`h3`,{className:`px-2 pb-1 text-section`,children:`Paused`}),(0,I.jsx)(`ul`,{className:`space-y-0.5`,children:h.paused.map(e=>(0,I.jsx)(W,{cron:e,next:null,member:b(e.agent),zone:u,now:s,focused:e.id===r},e.id))})]}),h.ended.length===0?null:(0,I.jsxs)(`details`,{className:`mt-3`,open:h.ended.some(e=>e.id===r),children:[(0,I.jsxs)(`summary`,{className:`cursor-pointer px-2 pb-1 text-section`,children:[`Ended (`,h.ended.length,`)`]}),(0,I.jsx)(`ul`,{"aria-label":`Ended`,className:`space-y-0.5`,children:h.ended.map(e=>(0,I.jsx)(W,{cron:e,next:null,member:b(e.agent),zone:u,now:s,focused:e.id===r},e.id))})]})]})]})}export{q as CronsView};
@@ -0,0 +1 @@
1
+ import{Un as e}from"./format-CENiwkJC.js";var t=e(),n=`flex w-full items-baseline gap-2 rounded-md py-0.5 text-left text-sm hover:bg-surface-2/40`;function r({nested:e,children:n}){return(0,t.jsx)(`ul`,{className:e?`ml-[5px] border-l border-line-strong pl-2`:`mt-2`,children:n})}function i({name:e,open:r,onToggle:i,children:a}){return(0,t.jsxs)(`button`,{type:`button`,"aria-expanded":r,onClick:i,className:n,children:[(0,t.jsx)(`span`,{"aria-hidden":`true`,className:`inline-block w-2.5 shrink-0 text-[10px] text-fg-muted transition-transform ${r?`rotate-90`:``}`,children:`▸`}),(0,t.jsxs)(`span`,{className:`min-w-0 truncate text-fg-primary`,children:[e,`/`]}),a]})}function a(){return(0,t.jsx)(`span`,{"aria-hidden":`true`,className:`w-2.5 shrink-0`})}export{r as i,i as n,n as r,a as t};
@@ -0,0 +1,4 @@
1
+ import{I as e,Jt as t,K as n,S as r,Un as i,Wn as a,c as o,it as s,qn as c,t as l,x as u}from"./format-CENiwkJC.js";import{A as d,k as f}from"./index-CPXALUV6.js";import{t as p}from"./BackLink-UTiLF1J4.js";import{_ as m,a as h,d as g,g as _,h as v,i as y,n as b,p as x,r as S,s as C,t as w,u as T}from"./Markdown-DT3V-EVe.js";import{n as E,t as D}from"./Pane-BaM0TdE6.js";var O=c(a(),1),k=i(),A=`grid size-7 shrink-0 place-items-center rounded-lg text-fg-tertiary hover:bg-surface-2/70 hover:text-fg-primary`,j=`inline-flex h-7 shrink-0 items-center rounded-md px-3 text-xs text-fg-tertiary transition-colors hover:bg-surface-2/70 hover:text-fg-primary`,M=1e3,N=2e4;function P({source:e,path:t}){let n=t===``?[]:t.split(`/`),r=`text-fg-tertiary hover:text-fg-primary`;return(0,k.jsxs)(`nav`,{"aria-label":`Path`,className:`flex flex-wrap items-center gap-x-1 text-meta`,children:[n.length===0?(0,k.jsx)(`span`,{children:`Files`}):(0,k.jsx)(b,{source:e,path:``,className:r,children:`Files`}),n.map((t,i)=>(0,k.jsxs)(O.Fragment,{children:[(0,k.jsx)(`span`,{"aria-hidden":`true`,children:`/`}),i===n.length-1?(0,k.jsx)(`span`,{className:`text-fg-secondary`,children:t}):(0,k.jsx)(b,{source:e,path:n.slice(0,i+1).join(`/`),className:r,children:t})]},n.slice(0,i+1).join(`/`)))]})}function F({rows:e}){let[t,...n]=e;if(t===void 0)return(0,k.jsx)(`p`,{className:`mt-3 text-meta`,children:`The table is empty.`});let r=n.slice(0,M),i=`border border-line px-2 py-1 text-left align-top whitespace-pre-wrap`;return(0,k.jsxs)(`div`,{className:`mt-3 overflow-x-auto`,children:[(0,k.jsxs)(`table`,{className:`text-xs text-fg-secondary`,children:[(0,k.jsx)(`thead`,{children:(0,k.jsx)(`tr`,{children:t.map((e,t)=>(0,k.jsx)(`th`,{scope:`col`,className:`${i} font-medium text-fg-primary`,children:e},t))})}),(0,k.jsx)(`tbody`,{children:r.map((e,t)=>(0,k.jsx)(`tr`,{children:e.map((e,t)=>(0,k.jsx)(`td`,{className:i,children:e},t))},t))})]}),n.length>r.length?(0,k.jsxs)(`p`,{className:`mt-2 text-meta`,children:[`The first `,M,` of `,n.length,` rows`]}):null]})}function I({text:e,line:t}){let n=e.endsWith(`
2
+ `)?e.slice(0,-1).split(`
3
+ `):e.split(`
4
+ `),r=`mt-3 overflow-x-auto rounded-lg bg-surface-0/80 p-3 font-mono text-[12px] leading-relaxed text-fg-secondary shadow-[inset_0_0_0_1px_rgba(255,255,255,0.05)]`;return n.length>N?(0,k.jsx)(`pre`,{className:r,children:e}):(0,k.jsx)(`pre`,{className:r,children:n.map((e,n)=>(0,k.jsxs)(`span`,{className:`flex ${n+1===t?`line-target`:``}`,children:[(0,k.jsx)(`span`,{"aria-hidden":`true`,className:`w-10 shrink-0 pr-3 text-right text-fg-muted select-none`,children:n+1}),(0,k.jsx)(`span`,{className:`whitespace-pre`,children:e===``?` `:e})]},n))})}function L({source:e,file:t,url:n,line:r}){let i=(0,O.useMemo)(()=>t.content===null?null:m(t.path,h(t.content)),[t.path,t.content]),a=t.path.split(`/`).at(-1)??t.path;return i===null?(0,k.jsxs)(`p`,{className:`mt-3 text-sm text-fg-secondary`,children:[a,` is `,_(t.size),`, more than the `,_(s),` the board shows.`]}):i.kind===`markdown`?(0,k.jsx)(`div`,{className:`mt-3`,children:(0,k.jsx)(w,{text:i.text,base:{source:e,dir:x(t.path)},line:r})}):i.kind===`image`?n===null?null:(0,k.jsx)(`img`,{src:n,alt:a,className:`mt-3 max-w-full rounded-lg`}):i.kind===`table`?(0,k.jsx)(F,{rows:i.rows}):i.kind===`text`?(0,k.jsx)(I,{text:i.text,line:r}):(0,k.jsxs)(`p`,{className:`mt-3 text-sm text-fg-secondary`,children:[a,` is not text (`,_(t.size),`).`]})}function R(e,t){let n=C(g(e??``)??``);return{path:n.path,line:t.line??n.line}}function z({source:e,path:t,line:r,where:i,parent:a,missing:s,away:c,readFrom:d}){let f=o(e,t),m=u(3e4),h=f.data,g=h?.kind===`file`?h.content:null,_=y(g,T(t)??`application/octet-stream`),v=t===``?`Files`:t.split(`/`).at(-1)??t,b=(0,O.useRef)(null);(0,O.useEffect)(()=>{r!==void 0&&h!==void 0&&b.current?.querySelector(`.line-target`)?.scrollIntoView({block:`center`})},[r,h]);let x;return x=h===void 0?f.error instanceof n&&f.error.status===404?(0,k.jsx)(`p`,{className:`mt-3 text-sm text-fg-secondary`,children:s}):f.error instanceof n&&f.error.status===503?(0,k.jsx)(`p`,{className:`mt-3 text-sm text-fg-secondary`,children:c}):f.error===null?(0,k.jsxs)(E,{children:[`Reading `,v,` from `,d,`…`]}):(0,k.jsx)(`p`,{className:`mt-3 text-sm text-fg-secondary`,children:f.error.message}):h.kind===`dir`?(0,k.jsx)(S,{source:e,file:h,className:`mt-3 space-y-1`}):(0,k.jsx)(L,{source:e,file:h,url:_,line:r}),(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(D,{leading:(0,k.jsx)(p,{fallback:a}),title:v,subtitle:h===void 0?i:`${i}${r===void 0?``:` · line ${r}`} · committed by ${h.commit.author} ${l(h.commit.at,m)} · ${h.commit.id.slice(0,7)}`,trailing:_===null?null:(0,k.jsx)(`a`,{href:_,download:v,className:j,children:`Download`})}),(0,k.jsxs)(`div`,{ref:b,className:`flex-1 overflow-y-auto px-4 py-4`,children:[(0,k.jsx)(P,{source:e,path:t}),x]})]})}function B(){let{taskId:n,_splat:i}=d({from:`/task/$taskId/files/$`}),{path:a,line:o}=R(i,f({from:`/task/$taskId/files/$`})),s=e(n),c=r(),l=s.data?.title??n,u=c.data?.find(e=>e.slug===s.data?.project);return(0,k.jsx)(z,{source:{kind:`task`,taskId:n},path:a,line:o,where:l,parent:(0,k.jsx)(t,{to:`/task/$taskId`,params:{taskId:n},"aria-label":`Back to the task ${l}`,className:A,children:`←`}),missing:`${a===``?`Nothing`:a} is not on task/${n} yet.`,away:`${v(u)}, is not connected, so the task's files cannot be read now.`,readFrom:`the task's runner`})}function V(){let{slug:e,_splat:n}=d({from:`/p/$slug/files/$`}),{path:i,line:a}=R(n,f({from:`/p/$slug/files/$`})),o=r(),s=o.data?.find(t=>t.slug===e),c=s?.name??e,l=s?.defaultBranch;return o.data!==void 0&&s===void 0?(0,k.jsxs)(E,{children:[`There is no project `,e,`.`]}):(0,k.jsx)(z,{source:{kind:`project`,slug:e},path:i,line:a,where:l===void 0?c:`${c} · ${l}`,parent:(0,k.jsx)(t,{to:`/p/$slug`,params:{slug:e},"aria-label":`Back to the project ${c}`,className:A,children:`←`}),missing:i===``?`Nothing on ${l??`the default branch`} yet.`:`${i} is not on ${l??`the default branch`}.`,away:`${v(s)}, is not connected, so the project's files cannot be read now.`,readFrom:`the project's runner`})}export{V as ProjectFileView,B as TaskFileView};
@@ -0,0 +1 @@
1
+ import{Hn as e,Jt as t,S as n,Un as r,Wn as i,g as a,gt as o,j as s,qn as c,t as l,x as u}from"./format-CENiwkJC.js";import{n as d,t as f}from"./Button-Cp4cNRUX.js";import{i as p}from"./compose-DY1WL8zB.js";import{A as m}from"./index-CPXALUV6.js";import{t as h}from"./BackLink-UTiLF1J4.js";import{t as g}from"./Markdown-DT3V-EVe.js";import{r as _}from"./ThreadForms-CG5Y926b.js";import{n as v,t as y}from"./Pane-BaM0TdE6.js";var b=c(i(),1),x=r(),S=`grid size-7 shrink-0 place-items-center rounded-lg text-fg-tertiary hover:bg-surface-2/70 hover:text-fg-primary`;function C(){let{scope:r,topic:i}=m({from:`/knowledge/$scope/$topic`}),{api:c}=s(),C=e(),w=p(),T=a(r),E=n(),D=u(3e4),[O,k]=(0,b.useState)(!1),A=r===o,j=A?`the society`:E.data?.find(e=>e.slug===r)?.name??r,M=T.data?.find(e=>e.topic===i),N=d({mutationFn:()=>c.removeKnowledge({project:A?null:r,topic:i}),onSuccess:async()=>{await C.invalidateQueries({queryKey:[`knowledge`,r]}),await w(A?{to:`/society`}:{to:`/p/$slug`,params:{slug:r}})}}),P=A?(0,x.jsx)(t,{to:`/society`,"aria-label":`Back to the society`,className:S,children:`←`}):(0,x.jsx)(t,{to:`/p/$slug`,params:{slug:r},"aria-label":`Back to ${j}`,className:S,children:`←`});return M===void 0?(0,x.jsx)(v,{children:T.data===void 0?`Reading…`:`${j} has no topic ${i}.`}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(y,{leading:(0,x.jsx)(h,{fallback:P}),title:M.topic,subtitle:`Knowledge of ${j} · written by ${M.updatedBy} ${l(M.updatedAt,D)}`,trailing:O?null:(0,x.jsx)(f,{onClick:()=>k(!0),children:`Remove…`})}),O?(0,x.jsxs)(`form`,{"aria-label":`Remove the topic`,className:`space-y-2 border-b border-line bg-surface-2/20 p-3`,onSubmit:e=>{e.preventDefault(),N.mutate()},children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsxs)(`p`,{className:`min-w-0 flex-1 truncate text-meta`,children:[`Remove `,M.topic,`?`]}),(0,x.jsx)(f,{onClick:()=>k(!1),children:`Cancel`}),(0,x.jsx)(f,{variant:`primary`,type:`submit`,disabled:N.isPending,children:N.isPending?`Removing…`:`Remove topic`})]}),(0,x.jsx)(_,{error:N.error})]}):null,(0,x.jsx)(`div`,{className:`flex-1 overflow-y-auto px-4 py-4`,children:(0,x.jsx)(g,{text:M.body})})]})}export{C as KnowledgeView};