@ahpd/web 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/dist/app/assets/ActionList-aOUHK9Z9.js +1 -0
- package/dist/app/assets/Composer-DpjCaX5G.js +2 -0
- package/dist/app/assets/{ContextMenu-D3PBPRRl.js → ContextMenu-qqlGWvJT.js} +1 -1
- package/dist/app/assets/{DataTable-DsRcsDHs.js → DataTable-Bv6EG42F.js} +1 -1
- package/dist/app/assets/Details-Cymq_tLr.js +1 -0
- package/dist/app/assets/DiffPage-CrT1Faon.js +1 -0
- package/dist/app/assets/{Edit-DuGIlEIV.js → Edit-KxWRJB1t.js} +1 -1
- package/dist/app/assets/Explorer-C4zxSdMF.js +1 -0
- package/dist/app/assets/{Explorer-DXZ2epSi.js → Explorer-Cxl5QGRN.js} +1 -1
- package/dist/app/assets/Explorer-D9lzbmtd.js +1 -0
- package/dist/app/assets/Explorer-h1FYBfP3.js +1 -0
- package/dist/app/assets/Explorer-kMkPIrYG.js +1 -0
- package/dist/app/assets/{ExplorerList-Cecr_ZQS.js → ExplorerList-Bdp0sfLW.js} +1 -1
- package/dist/app/assets/{FilePage-Bo_9WZiQ.js → FilePage-CWjlubpU.js} +1 -1
- package/dist/app/assets/{Filter-C9Z9GcBH.js → Filter-y-cAyV5s.js} +1 -1
- package/dist/app/assets/{Info-1oWO89--.js → Info-levnJ1pH.js} +1 -1
- package/dist/app/assets/{LocaleToggle-CBvJEvFm.js → LocaleToggle-DtU53oIZ.js} +1 -1
- package/dist/app/assets/{LogPage-DXOU5UzZ.js → LogPage-QIumryht.js} +1 -1
- package/dist/app/assets/{LoginForm-C7ZmFVLz.js → LoginForm-CoxoSwG-.js} +1 -1
- package/dist/app/assets/MarkdownPage-CNUmYD-d.js +1 -0
- package/dist/app/assets/Modal-BHPfQpzr.js +1 -0
- package/dist/app/assets/{MountTitle-DXPuKAFo.js → MountTitle-hWvATFel.js} +1 -1
- package/dist/app/assets/{New-DHihaOkV.js → New-CWi2ZODd.js} +2 -2
- package/dist/app/assets/Page-BXwzlAyC.js +2 -0
- package/dist/app/assets/{Page-BkOqYXfd.js → Page-BlQx3M_Q.js} +1 -1
- package/dist/app/assets/{Page-DOVek_br.js → Page-DXYj-sYk.js} +1 -1
- package/dist/app/assets/{Pagination-CmWBkMlC.js → Pagination-FSzhBpDU.js} +1 -1
- package/dist/app/assets/PortaLock-Dvr-6D1r.js +2 -0
- package/dist/app/assets/{Settings-wnbeCcl1.js → Settings--Ciusotp.js} +1 -1
- package/dist/app/assets/{SigillumGate-BVebugTV.js → SigillumGate-DoeGhrpT.js} +1 -1
- package/dist/app/assets/{SingleLayout-BNVy245Q.js → SingleLayout-CmIAtyIo.js} +1 -1
- package/dist/app/assets/{SpatialLayout-Bm8uhLD2.js → SpatialLayout-CacNe1y4.js} +1 -1
- package/dist/app/assets/{SplitLayout-BuZpjDyP.js → SplitLayout-BANKBMIh.js} +1 -1
- package/dist/app/assets/{StackLayout-CbP6W0Er.js → StackLayout-Cz4zMN4f.js} +1 -1
- package/dist/app/assets/{TabLayout-AUuJvVjp.js → TabLayout-BaH8UNpt.js} +1 -1
- package/dist/app/assets/{TabPanelLayout-BDz30u7O.js → TabPanelLayout-DkFUNHcz.js} +1 -1
- package/dist/app/assets/{TerminalPage-DbF4N79y.js → TerminalPage-C58xO7du.js} +3 -3
- package/dist/app/assets/{ThemeModeToggle-B0EIvYRF.js → ThemeModeToggle-CAippEfJ.js} +1 -1
- package/dist/app/assets/{ThemePicker-DHw8lqsi.js → ThemePicker-CvnWboZg.js} +1 -1
- package/dist/app/assets/Tree-BAAGdT3c.css +1 -0
- package/dist/app/assets/Tree-Bb5NwYJ1.js +1 -0
- package/dist/app/assets/actions-BQzD99j0.js +1 -0
- package/dist/app/assets/changeset-BY8dw-V-.js +1 -0
- package/dist/app/assets/{channel-BScxZDq2.js → channel-Cqz_LUS2.js} +1 -1
- package/dist/app/assets/clicks-IyfKhKFh.js +1 -0
- package/dist/app/assets/composer-commands-Bpp7NX4E.js +2 -0
- package/dist/app/assets/{data-BvTv-4oH.js → data-Fkj0LNnG.js} +1 -1
- package/dist/app/assets/drag-ruzgQUFW.js +1 -0
- package/dist/app/assets/emojis-BOylxma2.js +1 -0
- package/dist/app/assets/index-BkzdJo_Y.js +14 -0
- package/dist/app/assets/index-CPXMK2aI.css +1 -0
- package/dist/app/assets/notify-Bb548jAB.js +1 -0
- package/dist/app/assets/sessions-CEccRVtA.js +2 -0
- package/dist/app/assets/state-DRVsnGrf.js +1 -0
- package/dist/app/assets/state-KGSq646f.js +1 -0
- package/dist/app/assets/{terminal-BSweq0Uj.js → terminal-kD0C2LuZ.js} +1 -1
- package/dist/app/assets/{text-DJDdwKmv.js → text-CmjM0Nin.js} +1 -1
- package/dist/app/assets/useI18n-Bfix5MNN.js +1 -0
- package/dist/app/assets/useStoreLabel-m9cem_OG.js +1 -0
- package/dist/app/assets/words-BknpHIF3.js +1 -0
- package/dist/app/index.html +16 -12
- package/package.json +9 -10
- package/dist/app/assets/ActionList-DZ9lLGRe.js +0 -1
- package/dist/app/assets/Composer-C54KOyHb.js +0 -2
- package/dist/app/assets/Details-Bgo6JIBm.js +0 -1
- package/dist/app/assets/DiffPage-BFnOf1p9.js +0 -1
- package/dist/app/assets/Explorer-BkMOyBlc.js +0 -1
- package/dist/app/assets/Explorer-CjLkoKLM.js +0 -1
- package/dist/app/assets/Explorer-CwDdWpNn.js +0 -1
- package/dist/app/assets/MarkdownPage-8oL61A0c.js +0 -1
- package/dist/app/assets/Modal-BPnVnP2R.js +0 -1
- package/dist/app/assets/Page-D7hXrdQj.js +0 -2
- package/dist/app/assets/Palette-CEQLzNFd.js +0 -1
- package/dist/app/assets/PortaLock-CC2pIbs8.js +0 -2
- package/dist/app/assets/actions-DTKyI167.js +0 -1
- package/dist/app/assets/emojis-XibTG-gy.js +0 -1
- package/dist/app/assets/index-Cu7ySznN.js +0 -15
- package/dist/app/assets/index-DgTMhxdP.css +0 -1
- package/dist/app/assets/link-DK7OzQXZ.js +0 -1
- package/dist/app/assets/useI18n-BTsfCYkN.js +0 -1
- package/dist/app/assets/useStoreLabel-CK2AU1rh.js +0 -1
- package/dist/app/assets/words-CrqnRMW4.js +0 -1
package/README.md
CHANGED
|
@@ -14,6 +14,7 @@ What you get:
|
|
|
14
14
|
|
|
15
15
|
- **Sessions**, the list, each chat, new sessions and what they changed.
|
|
16
16
|
- **Composer**, supports `@attachments`, `/skills` and `/commands`.
|
|
17
|
+
- **Explorer**, the host's folders as a tree: the default folder first, then each session's. Drag a file to the composer to attach it, or with Shift to write its path.
|
|
17
18
|
- **Automations** for running tasks and scripts automatically based on session events.
|
|
18
19
|
- **Terminals** and a log in a bottom panel.
|
|
19
20
|
- **Host Information**, shows details about the server and its environment.
|
|
@@ -142,6 +143,11 @@ pnpm dev
|
|
|
142
143
|
|
|
143
144
|
`pnpm dev` serves on `http://127.0.0.1:5180`. It proxies `/api` and the socket (at `/ahp`) to `AHPD_URL`, default `http://127.0.0.1:9187`. The daemon needs `"http": true`.
|
|
144
145
|
|
|
146
|
+
```sh
|
|
147
|
+
AHPD_URL=http://127.0.0.1:9187 pnpm dev # another daemon
|
|
148
|
+
AHPD_URL=http://127.0.0.1:9187 pnpm dev --port 5200 # extra args go to Vite
|
|
149
|
+
```
|
|
150
|
+
|
|
145
151
|
To try a local build in ahpd:
|
|
146
152
|
|
|
147
153
|
```sh
|
|
@@ -182,6 +188,7 @@ npm sets a trusted publisher on a package that exists, so the first version is p
|
|
|
182
188
|
| `cli/` | `ahpw serve`: the same route on its own server, and the socket proxy |
|
|
183
189
|
| `src/connection/` | The AHP connection, the socket address, the protocol versions offered |
|
|
184
190
|
| `src/sessions/` | The sessions list, a new session, a session's chat and details |
|
|
191
|
+
| `src/folders/` | The explorer: the host's folders, and a host file dragged to the composer |
|
|
185
192
|
| `src/agents/` | The agents the server offers |
|
|
186
193
|
| `src/changes/` | What a session changed |
|
|
187
194
|
| `src/files/` | File, Markdown and diff viewers |
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{r as n}from"./colors-BieSUSt7.js";import{n as r}from"./ScenaProvider-6A3TJumQ.js";var i=t(),a=e();function o(e,t){return typeof t!=`number`||Number.isNaN(t)?e.length:Math.max(0,Math.min(e.length,Math.floor(t)))}function s(e,t=[`/`,`@`],n){if(!e)return null;let r=o(e,n),i=-1;if(r<e.length&&!/\s/.test(e[r]??``))i=r;else if(r>0&&!/\s/.test(e[r-1]??``))i=r-1;else return null;let a=i;for(;a>0&&!/\s/.test(e[a-1]??``);)--a;let s=i+1;for(;s<e.length&&!/\s/.test(e[s]??``);)s+=1;let c=e.slice(a,s),l=t.find(e=>c.startsWith(e));return l?{token:c,prefix:l,query:c.slice(l.length),start:a,end:s}:null}function c(e,t,n,r=[`/`,`@`]){let i=s(e,r,t);if(!i)return{next:e,caret:o(e,t)};let a=e.slice(0,i.start),c=`${a}${n}${e.slice(i.end)}`;return n===``&&(c=c.replace(/[ \t]+$/g,``)),{next:c,caret:Math.min(a.length+n.length,c.length)}}function l(e,t,n,r=[`/`,`@`]){let i=s(e,r,t);if(i)return{next:`${e.slice(0,i.start)}${n}${e.slice(i.end)}`,caret:i.start+n.length};let a=`${e}${e.length>0&&!/\s$/.test(e)?` `:``}${n}`;return{next:a,caret:a.length}}function u(e,t){if(!t)return e;let n=Array.isArray(t)?t:[t],r=e.toLowerCase();for(let t of n){let n=t.replace(/^[/@]/,``);if(r.startsWith(n.toLowerCase()))return e.slice(n.length).replace(/^[=\s]+/,``)}return e}function d(e,t){if(!t)return!0;let n=Array.isArray(t)?t:[t],r=e.toLowerCase();return n.some(e=>r.startsWith(e.toLowerCase()))}function f(e){if(e)return Array.isArray(e)?e[0]:e}var p=180;function m({spec:e,hostCtx:t,onBack:o,dataContext:s,manageKeys:c=!0,ref:l}){let u=r(),[d,m]=(0,i.useState)(0),[h,g]=(0,i.useState)({kind:`loading`}),[_,v]=(0,i.useState)(!1),y=(0,i.useRef)(h);y.current=h;let b=(0,i.useRef)(null),x=(0,i.useMemo)(()=>({scena:u,store:u.store,surfaces:u.surfaces,commands:u.commands,events:u.events,source:`menu`,dataContext:s}),[u,s]),S=(0,i.useCallback)(e=>e.map(e=>{let t=typeof e.title==`function`?e.title(x):e.title,n=typeof e.description==`function`?e.description(x):e.description,r=e.active?!!e.active(x):void 0,i=e.disabled?!!e.disabled(x):void 0;return{key:`cmd:${e.id}`,title:t,description:n,icon:e.icon,color:e.color,shortcut:f(e.shortcut),keys:f(e.keys),category:e.category,active:r,disabled:i,invoke:t=>{let n=f(e.shortcut);n&&t.replaceActiveToken(n),u.commands.execute(e.id,void 0,{source:`menu`,dataContext:s,host:t})}}}),[u,x,s]),C=(0,i.useCallback)(e=>e.map((e,t)=>{if(`commandId`in e){let n=u.commands.get(e.commandId);if(!n)return{key:`cmd:${e.commandId}:${t}`,title:`[${e.commandId}]`,disabled:!0,invoke:()=>void 0};let r=S([n])[0],i=e.args;return{...r,key:`cmd:${e.commandId}:${t}`,invoke:e=>{u.commands.execute(n.id,i,{source:`menu`,dataContext:s,host:e})}}}return{key:`act:${t}:${e.title}`,title:e.title,description:e.description,tooltip:e.tooltip,icon:e.icon,color:e.color,shortcut:e.shortcut,keys:e.keys,group:e.group,active:e.active,disabled:e.disabled,invoke:e.onSelect}}),[u,S,s]);(0,i.useEffect)(()=>{let n=!1,r=e.extraItems?C(e.extraItems):[];if(e.items)return v(!1),g({kind:`ready`,rows:[...r,...C(e.items)]}),()=>{n=!0};if(e.query){v(!1);let t=e.query.slot,i=e.query.q,a=()=>{let e=u.commands.list({slot:t,q:i,enabled:!0});n||g({kind:`ready`,rows:[...r,...S(e)]})};a();let o=!1;function s(){o||n||(o=!0,requestAnimationFrame(()=>{o=!1,n||a()}))}let c=u.events.on(`scena:registry:changed`,e=>{let t=e.registry;(t===`commands`||t===`components`)&&s()}),l=u.events.on(`scena:store:changed`,()=>{s()});return()=>{n=!0,c.dispose(),l.dispose()}}if(e.provider){let i=e.provider,a=()=>{if(n)return;let e;try{e=i(t)}catch(e){g({kind:`error`,message:e instanceof Error?e.message:String(e)}),v(!1);return}e instanceof Promise?e.then(e=>{n||(g({kind:`ready`,rows:[...r,...C(e)]}),v(!1))}).catch(e=>{n||(g({kind:`error`,message:e instanceof Error?e.message:String(e)}),v(!1))}):(g({kind:`ready`,rows:[...r,...C(e)]}),v(!1))},o=null,s=()=>{n||(v(!0),o&&clearTimeout(o),o=setTimeout(a,p))};y.current.kind===`ready`?s():(g({kind:`loading`}),a());let c=u.events.on(`scena:store:changed`,()=>s());return()=>{n=!0,o&&clearTimeout(o),c.dispose()}}return v(!1),g({kind:`ready`,rows:r}),()=>{n=!0}},[e,t,C,S,u]);let w=(0,i.useMemo)(()=>h.kind===`ready`?h.rows.filter(e=>!e.disabled):[],[h]);(0,i.useEffect)(()=>{m(0)},[w.length]),(0,i.useEffect)(()=>{let e=b.current;if(!e)return;let t=e.querySelector(`[data-selected="true"]`);t&&t.scrollIntoView({block:`nearest`})},[d]);let T=w[d],E=(0,i.useMemo)(()=>{if(h.kind!==`ready`)return[];let t=e.groupOrder??[],n=new Map,r=[];for(let e of h.rows){let t=e.category??e.group??``;n.has(t)||(n.set(t,[]),r.includes(t)||r.push(t)),n.get(t).push(e)}return[...t.filter(e=>n.has(e)),...r.filter(e=>!t.includes(e))].map(e=>({label:e===``?null:e,rows:n.get(e)}))},[h,e.groupOrder]),D=(0,i.useCallback)(e=>{if(w.length===0&&e.key!==`Escape`&&e.key!==`ArrowLeft`)return!1;if(e.key===`ArrowDown`)return e.preventDefault(),m(e=>(e+1)%w.length),!0;if(e.key===`ArrowUp`)return e.preventDefault(),m(e=>(e-1+w.length)%w.length),!0;if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let n=w[d];return n&&n.invoke(t),!0}return e.key===`Escape`?(e.preventDefault(),t.closeMenu(),!0):e.key===`ArrowLeft`&&o?(e.preventDefault(),o(),!0):!1},[w,d,t,o]);(0,i.useEffect)(()=>{if(!c)return;function e(e){let t={key:e.key,preventDefault:()=>e.preventDefault()};D(t)}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[D,c]),(0,i.useImperativeHandle)(l,()=>({handleKey:e=>D(e)}),[D]);let O=-1,k=e.rich===!0;function A(e){let r=!e.disabled;r&&(O+=1);let i=r&&O===d,o=O,s=e.color?{"--oo-color":n(e.color)}:void 0;return(0,a.jsxs)(`button`,{className:`oo-action-list__row`,type:`button`,title:e.tooltip,disabled:e.disabled,"data-cmd-group":e.group,"data-cmd-category":e.category,"data-color":e.color,"data-active":e.active?`true`:void 0,"data-disabled":e.disabled?`true`:void 0,"data-selected":i?`true`:void 0,style:s,onMouseEnter:()=>{r&&m(o)},onClick:()=>{r&&e.invoke(t)},children:[(0,a.jsx)(`span`,{className:`oo-icon`,children:e.icon??`·`}),k?(0,a.jsxs)(`span`,{className:`oo-action-list__text`,children:[(0,a.jsx)(`span`,{className:`oo-action-list__title`,children:e.title}),e.description?(0,a.jsx)(`span`,{className:`oo-action-list__subtitle`,children:e.description}):null]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(`span`,{className:`oo-action-list__title`,children:e.title}),e.description?(0,a.jsx)(`span`,{className:`oo-action-list__description`,children:e.description}):null]}),e.active?(0,a.jsx)(`span`,{className:`oo-action-list__check`,children:`✓`}):null,e.shortcut?(0,a.jsx)(`kbd`,{className:`oo-action-list__shortcut`,children:e.shortcut}):null,e.keys?(0,a.jsx)(`kbd`,{className:`oo-action-list__shortcut`,children:e.keys}):null]},e.key)}function j(){return h.kind===`loading`?(0,a.jsx)(`div`,{className:`oo-action-list__loading`,children:`Loading…`}):h.kind===`error`?(0,a.jsx)(`div`,{className:`oo-action-list__error`,children:h.message}):E.length===0||h.rows.length===0?(0,a.jsx)(`div`,{className:`oo-action-list__empty`,children:`No matches`}):(0,a.jsx)(a.Fragment,{children:E.map((e,t)=>(0,a.jsxs)(`div`,{children:[t>0?(0,a.jsx)(`div`,{className:`oo-action-list__divider`}):null,e.label?(0,a.jsx)(`div`,{className:`oo-action-list__group-label`,children:e.label}):null,e.rows.map(A)]},e.label??`__g${t}`))})}let M=e.layout??`list`,N=M===`header-list`&&e.header,P=M===`info-list`&&e.detail;return(0,a.jsxs)(`div`,{className:`oo-action-list`,"data-layout":M,children:[_?(0,a.jsx)(`div`,{className:`oo-action-list__pending`,"aria-hidden":!0,children:`searching…`}):null,o?(0,a.jsxs)(`button`,{type:`button`,className:`oo-action-list__back`,onClick:o,children:[`← `,e.title??`Back`]}):null,e.customHeader?(0,a.jsx)(`div`,{className:`oo-action-list__custom-header`,children:e.customHeader(t)}):null,N?(0,a.jsx)(`div`,{className:`oo-action-list__header`,children:e.header(t)}):null,(0,a.jsxs)(`div`,{className:`oo-action-list__body`,children:[(0,a.jsx)(`div`,{className:`oo-action-list__items`,ref:b,children:j()}),P?(0,a.jsx)(`div`,{className:`oo-action-list__detail`,children:e.detail(t,T)}):null]}),e.footerHints?(0,a.jsxs)(`div`,{className:`oo-action-list__footer`,children:[`↑↓ navigate · ↵ select`,o?` · ← back`:``,` · ⎋ close`]}):null]})}export{l as a,s as i,f as n,u as o,c as r,d as s,m as t};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{i as n}from"./notify-Bb548jAB.js";import{t as r,u as i}from"./useStore-BQkzWMs-.js";import{n as a}from"./ScenaProvider-6A3TJumQ.js";import{t as o}from"./Button-_R1oktDz.js";import{g as s,w as c}from"./data-Fkj0LNnG.js";import{a as l,n as u}from"./words-BknpHIF3.js";import{t as d}from"./emojis-BOylxma2.js";import{a as ee,i as f,n as p,o as te,r as m,s as h,t as g}from"./ActionList-aOUHK9Z9.js";import{_,a as v,c as y,d as b,f as x,g as S,h as C,i as w,l as ne,m as T,n as E,o as re,p as D,r as ie,t as O,u as ae}from"./composer-commands-Bpp7NX4E.js";import{n as oe,t as se}from"./drag-ruzgQUFW.js";var k=e(),A=t(),j=[`/`,`@`];function ce(e){let{input:t,setInput:n,caretIndex:r,panelDataContext:i,slashSlot:o=`chat:input/`,mentionSlot:s=`chat:input@`,mentionProvider:c,prefixes:l=j,onCaretChange:u}=e,d=a(),[_,v]=(0,A.useState)([]),y=(0,A.useRef)(_);y.current=_;let b=(0,A.useRef)(null),x=(0,A.useMemo)(()=>f(t,l,r),[t,l,r]),S=x!==null,C=(0,A.useCallback)(e=>x?.prefix===`@`?c?{provider:c,footerHints:!0,rich:!0}:{query:{slot:s,q:e},footerHints:!0,rich:!0}:{query:{slot:o,q:e},footerHints:!0,rich:!0},[x?.prefix,c,s,o]);(0,A.useEffect)(()=>{if(!x){y.current.length>0&&v([]);return}let e=y.current[y.current.length-1];if(y.current.length<=1){v([{spec:C(x.query)}]);return}let t=e&&`spec`in e?e.spec:void 0;if(t?.sentinel&&!h(x.token,t.sentinel)){v([{spec:C(x.query)}]);return}t?.query&&v(e=>{let n=e.slice(0,-1);return n.push({spec:{...t,query:{...t.query,q:x.query}}}),n})},[x,C]);let w=(0,A.useMemo)(()=>{let e=_[_.length-1];return e&&`spec`in e?e.spec.sentinel:void 0},[_]),ne=(0,A.useMemo)(()=>te(x?.query??``,w),[x,w]),T=(0,A.useMemo)(()=>({pushList:e=>v(t=>[...t,{spec:e}]),replaceList:e=>v(t=>{let n=t.slice(0,-1);return n.push({spec:e}),n}),openInline:e=>v(t=>[...t,{component:(0,k.jsx)(M,{name:e})}]),openPopover:()=>void 0,back:()=>v(e=>e.length>1?e.slice(0,-1):e),closeMenu:()=>{v([]);let e=m(t,r,``,l);n(e.next),u?.(e.caret)},keepOpen:()=>void 0,insertAtCursor:e=>{let i=m(t,r,e,l);n(i.next),u?.(i.caret)},replaceActiveToken:e=>{let i=m(t,r,e,l);n(i.next),u?.(i.caret)},query:ne}),[t,r,l,n,ne,u]),E=_[_.length-1],re=(0,A.useCallback)(()=>v(e=>e.slice(0,-1)),[]),D=_.length>1?re:void 0,ie=(0,A.useCallback)(e=>{if(!S)return!1;if(e.key===`Escape`)return e.preventDefault(),T.closeMenu(),!0;if(e.key===`ArrowLeft`&&D){let t=e.target;if(t.selectionStart===t.selectionEnd&&x&&t.selectionStart===x.start+x.prefix.length)return e.preventDefault(),D(),!0}return e.key===`ArrowDown`||e.key===`ArrowUp`||e.key===`Enter`||e.key===`Tab`?b.current?.handleKey(e)??!1:!1},[S,T,D,x]),O=(0,A.useCallback)(e=>{let a=d.commands.get(e);if(!a)return null;let s=p(a.shortcut),c=null;if(s){let{next:e,caret:i}=ee(t,r,s,l);c=i,n(e),v([{spec:{query:{slot:o,q:s.replace(/^[/@]/,``)},footerHints:!0,rich:!0}}])}return d.commands.execute(e,void 0,{source:`menu`,dataContext:i,host:T}),c},[d,i,t,r,l,T,n,o]),ae=(0,A.useCallback)(()=>T.closeMenu(),[T]);return{menuVisible:S,activeSentinel:w,pickerNode:E?`component`in E?E.component:(0,k.jsx)(g,{ref:b,spec:E.spec,hostCtx:T,onBack:D,dataContext:i,manageKeys:!1}):null,handleMenuKeyDown:ie,openCommand:O,closeMenu:ae}}function M({name:e}){return(0,k.jsxs)(`div`,{style:{padding:12},children:[`[component: `,e,`]`]})}var N=d.caretDown;function P({label:e,title:t,onOpen:n,on:r}){return(0,k.jsxs)(`button`,{type:`button`,className:`web-chip`,"data-on":r===!0?`true`:`false`,title:t,disabled:n===void 0,onClick:n,...n===void 0?{}:{"aria-haspopup":`menu`},children:[e,n===void 0?null:(0,k.jsx)(`span`,{"aria-hidden":`true`,children:N})]})}function F({label:e,title:t,value:n,options:r,onChange:i}){let a=r.find(e=>e.value===n)?.label??n;return(0,k.jsxs)(`span`,{className:`web-chip web-chip--choice`,title:t??e,children:[`${e}: ${a===``?`default`:a}`,(0,k.jsx)(`span`,{"aria-hidden":`true`,children:N}),(0,k.jsx)(`select`,{"aria-label":e,value:n,onChange:e=>i(e.currentTarget.value),children:r.map(e=>(0,k.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})}function I({label:e,title:t,value:n,onChange:r}){return(0,k.jsx)(`button`,{type:`button`,className:`web-chip`,"data-on":n?`true`:`false`,"aria-pressed":n,title:t??e,onClick:()=>r(!n),children:e})}function L({label:e,title:t,value:n,placeholder:r,onChange:i,width:a}){return(0,k.jsxs)(`span`,{className:`web-chip web-chip--text`,title:t??e,children:[e,(0,k.jsx)(`input`,{"aria-label":e,value:n,placeholder:r??``,style:{width:a??110},onChange:e=>i(e.currentTarget.value)})]})}var le=`$/ahp/composerFocus`,R=e=>typeof e==`object`&&e?e:{},z=e=>typeof e==`string`&&e!==``?e:void 0;function ue(e){let t=R(e).items;return(Array.isArray(t)?t:[]).map(e=>{let t=R(e),n=R(R(t.attachment)._meta),r=z(t.insertText)??``;return{insert:r,label:z(n.command)??r,detail:z(n.description),hint:z(n.argumentHint)}}).filter(e=>e.insert!==``)}function de(e,t,n){return i(...n.map(n=>e.commands.register({id:`ahp.composer.host.${t}.${n.insert}`,title:n.hint===void 0?n.label:`${n.label} ${n.hint}`,...n.detail===void 0?{}:{description:n.detail},category:`Agent`,shortcut:n.label.startsWith(`/`)?n.label:`/${n.label}`,slots:[O],when:`${le} == "${t}"`,run:e=>e.host?.replaceActiveToken(`${n.insert} `)})))}var fe=0,B=260,pe=[`/`,`@`],me=800;function he(e){e!==null&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,B)}px`)}function ge(e,t,n){return{text:e,origin:{kind:`user`},...t===void 0?{}:{model:{id:t}},...n.length===0?{}:{attachments:S(e,n)}}}var _e=(0,A.memo)(function({chatUri:e,activeId:t,activeStart:i,queued:ee,steering:f,draft:p,lastModel:te,config:m,summary:h,send:g}){let S=a(),j=(r(`$/ahp/agents`)??[]).find(e=>e.provider===h.provider),M=(0,A.useMemo)(()=>ie(e),[e]),[N]=(0,A.useState)(()=>`composer-${++fe}`),F=h.workingDirectories?.[0],[I,L]=(0,A.useState)(()=>p?.text??``),[R,z]=(0,A.useState)(null),[B,_e]=(0,A.useState)(()=>p?.model?.id??te),[V,H]=(0,A.useState)(()=>p?.attachments??[]),U=(0,A.useRef)(null),W=t===void 0?void 0:{id:t,startedAt:i??``},ve=ee??[];(0,A.useEffect)(()=>he(U.current),[I]);let G=(0,A.useRef)(!1);(0,A.useEffect)(()=>{if(!G.current)return;let t=window.setTimeout(()=>{let t=I.trim()===``&&V.length===0?void 0:ge(I,B,V);s(e,{type:`chat/draftChanged`,draft:t})},me);return()=>window.clearTimeout(t)},[I,B,V,e]);let K=(0,A.useCallback)(e=>{z(e),requestAnimationFrame(()=>{let t=U.current;t!==null&&(t.focus(),t.setSelectionRange(e,e))})},[]),q=(0,A.useCallback)(e=>{G.current=!0,H(t=>t.some(t=>C(t,e))?t:[...t,e])},[]),ye=(0,A.useRef)(null),be=(0,A.useCallback)(async e=>{let t=await D(Array.from(e??[]));for(let e of t.attached)q(e);t.refused.length>0&&n(`Not attached`,{description:`Over 5 MB or unreadable: ${t.refused.join(`, `)}`})},[q]),[xe,Se]=(0,A.useState)(null),Ce=(0,A.useCallback)(e=>{let t=Y.current??J.current.length,n=J.current.slice(0,t),r=n===``||/\s$/.test(n)?``:` `;G.current=!0,L(`${n}${r}${e}${J.current.slice(t)}`),K(n.length+r.length+e.length)},[K]),we=e=>{let t=se(e.dataTransfer);(t||Array.from(e.dataTransfer.types).includes(`Files`))&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`,Se(t&&e.shiftKey?`mention`:`attach`))},Te=e=>{Se(null);let t=oe(e.dataTransfer);if(t!==null){e.preventDefault(),e.shiftKey?Ce(`@${u(t.uri)}${t.directory?`/`:``} `):q(T(t.uri,t.directory));return}e.dataTransfer.files.length!==0&&(e.preventDefault(),be(e.dataTransfer.files))},J=(0,A.useRef)(I);J.current=I;let Y=(0,A.useRef)(R);Y.current=R;let Ee=(0,A.useCallback)(async()=>{let t=J.current;try{return(await c(`completions`,{kind:`userMessage`,channel:e,text:t,offset:Y.current??t.length})).items.map(e=>{let t=x(e.attachment,F);return{title:e.insertText.replace(/^@/,``),...t===void 0?{}:{description:t},onSelect:t=>{t.replaceActiveToken(`${e.insertText} `),q(_(e.attachment,e.insertText))}}})}catch{return[]}},[e,F,q]),[De,Oe]=(0,A.useState)([]);(0,A.useEffect)(()=>{let t=!0;return c(`completions`,{kind:`userMessage`,channel:e,text:`/`,offset:1}).then(e=>{t&&Oe(ue(e))}).catch(()=>{t&&Oe([])}),()=>{t=!1}},[e]),(0,A.useEffect)(()=>{let e=de(S,N,De);return()=>e.dispose()},[S,N,De]);let X=ce({input:I,setInput:L,caretIndex:R,panelDataContext:M,slashSlot:O,prefixes:pe,mentionProvider:Ee,onCaretChange:K}),Z=(0,A.useMemo)(()=>Object.entries(m?.schema.properties??{}).filter(([,e])=>e.sessionMutable===!0&&e.readOnly!==!0).map(([e,t])=>({key:e,schema:t,value:m?.values[e]})),[m]),ke=(0,A.useCallback)(()=>{if(t===void 0)return;let e=Date.parse(i??``);g({type:`chat/turnCancelled`,turnId:t,duration:Number.isNaN(e)?0:Math.max(0,Date.now()-e)})},[t,i,g]),Ae=(0,A.useMemo)(()=>(j?.models??[]).map(e=>({id:e.id,name:e.name})),[j]),Q=(0,A.useRef)(null);Q.current={models:()=>Ae,model:()=>B,setModel:e=>{G.current=!0,_e(e)},options:()=>Z,setOption:(e,t)=>{s(h.resource,{type:`session/configChanged`,config:{[e]:t}})},running:()=>W!==void 0,stop:ke,session:()=>h.resource,attach:q,type:e=>{let t=Y.current??J.current.length,n=J.current.slice(0,t),r=e===`/`||n===``||/\s$/.test(n)?``:` `,i=e===`/`&&n.trim()===``?`/${J.current.slice(t)}`:`${n}${r}${e}${J.current.slice(t)}`,a=e===`/`&&n.trim()===``?1:n.length+r.length+1;G.current=!0,L(i),K(a)},upload:()=>ye.current?.click()},(0,A.useEffect)(()=>E(M,{models:()=>Q.current?.models()??[],model:()=>Q.current?.model(),setModel:e=>Q.current?.setModel(e),options:()=>Q.current?.options()??[],setOption:(e,t)=>Q.current?.setOption(e,t),running:()=>Q.current?.running()??!1,stop:()=>Q.current?.stop(),session:()=>Q.current?.session()??``,attach:e=>Q.current?.attach(e),type:e=>Q.current?.type(e),upload:()=>Q.current?.upload()}),[M]);let je=Z.map(e=>e.key).join(`
|
|
2
|
+
`);(0,A.useEffect)(()=>{let e=y(S,Z);return()=>e.dispose()},[S,je]);function Me(e){let t=X.openCommand(e);K(t??U.current?.value.length??I.length)}function Ne(){L(``),H([]),G.current=!1,s(e,{type:`chat/draftChanged`,draft:void 0})}function $(e){let t=I.trim();if(t===``)return;let n=ge(t,B,V);g(W===void 0?{type:`chat/turnStarted`,turnId:l(),startedAt:new Date().toISOString(),message:n}:e===`steer`?{type:`chat/pendingMessageSet`,kind:`steering`,id:l(),message:n}:{type:`chat/pendingMessageSet`,kind:`queued`,id:l(),message:n}),Ne()}let Pe=Ae.find(e=>e.id===B)?.name??B;return(0,k.jsxs)(`div`,{className:`web-composer`,children:[X.pickerNode===null?null:(0,k.jsx)(`div`,{className:`web-composer__picker`,children:X.pickerNode}),f===void 0&&ve.length===0?null:(0,k.jsxs)(`ul`,{className:`web-composer__queue`,children:[f===void 0?null:(0,k.jsxs)(`li`,{children:[(0,k.jsx)(`span`,{className:`web-chip`,"data-on":`true`,children:`Steering`}),(0,k.jsx)(`span`,{className:`web-composer__queued`,children:f.message.text}),(0,k.jsx)(o,{label:`Remove`,size:`sm`,onClick:()=>g({type:`chat/pendingMessageRemoved`,kind:`steering`,id:f.id})})]}),ve.map((e,t)=>(0,k.jsxs)(`li`,{children:[(0,k.jsxs)(`span`,{className:`web-chip`,children:[`Next `,t+1]}),(0,k.jsx)(`span`,{className:`web-composer__queued`,children:e.message.text}),(0,k.jsx)(o,{label:`Remove`,size:`sm`,onClick:()=>g({type:`chat/pendingMessageRemoved`,kind:`queued`,id:e.id})})]},e.id))]}),(0,k.jsxs)(`div`,{className:`web-composer__where`,children:[F===void 0?null:(0,k.jsx)(P,{label:`${d.folder} ${u(F)}`,title:`The folder this session works in`}),(0,k.jsx)(P,{label:`${d.agents} ${j?.displayName??h.provider}`,title:j?.description??`The agent running this session`})]}),(0,k.jsxs)(`div`,{className:`web-composer__box`,"data-drop":xe??void 0,onDragOver:we,onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||Se(null)},onDrop:Te,children:[V.length===0?null:(0,k.jsx)(`div`,{className:`web-composer__attached`,children:V.map((e,t)=>(0,k.jsxs)(`span`,{className:`web-attachment`,title:x(e,F)??b(e),children:[(0,k.jsx)(`span`,{className:`web-attachment__icon`,"aria-hidden":`true`,children:ae(e)}),(0,k.jsx)(`span`,{className:`web-attachment__label`,children:b(e)}),(0,k.jsx)(`button`,{type:`button`,className:`web-attachment__remove`,"aria-label":`Remove ${b(e)}`,onClick:()=>{G.current=!0,H(e=>e.filter((e,n)=>n!==t))},children:d.close})]},`${b(e)}-${t}`))}),(0,k.jsx)(`div`,{className:`web-composer__bar`,children:(0,k.jsx)(`textarea`,{ref:U,className:`web-composer__text`,rows:1,value:I,"aria-label":`Message`,placeholder:W===void 0?`Message the agent, / for commands, @ to refer to a file`:`Queue a message for after this turn, or steer it`,onChange:e=>{G.current=!0,L(e.currentTarget.value),z(e.currentTarget.selectionStart)},onFocus:()=>S.store.set(le,N),onKeyUp:e=>z(e.currentTarget.selectionStart),onClick:e=>z(e.currentTarget.selectionStart),onKeyDown:e=>{if(!X.handleMenuKeyDown(e)){if(e.key===`Escape`&&W!==void 0){e.preventDefault(),ke();return}e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),$(e.altKey?`steer`:`send`))}}})}),(0,k.jsxs)(`div`,{className:`web-composer__foot`,children:[(0,k.jsx)(`button`,{type:`button`,className:`web-composer__add`,"aria-label":`Add context`,title:`Add context`,onClick:()=>Me(`ahp.composer.attach`),children:`+`}),(0,k.jsx)(`input`,{ref:ye,type:`file`,multiple:!0,hidden:!0,onChange:e=>{be(e.currentTarget.files),e.currentTarget.value=``}}),(0,k.jsxs)(`div`,{className:`web-composer__chips`,children:[Ae.length===0?null:(0,k.jsx)(P,{label:`Model: ${Pe??`default`}`,title:`The model the next message goes to`,onOpen:()=>Me(`ahp.composer.model`)}),Z.filter(ne).map(e=>(0,k.jsx)(P,{label:`${e.schema.title||e.key}: ${v(e)}`,title:e.schema.description??e.schema.title,...e.schema.type===`boolean`?{on:(e.value??e.schema.default)===!0}:{},...re(e.schema)?{onOpen:()=>Me(w(e.key))}:{}},e.key))]}),W===void 0||I.trim()===``?null:(0,k.jsx)(o,{label:`Steer`,size:`sm`,title:`Alt+Enter steers`,onClick:()=>$(`steer`)}),W===void 0||I.trim()===``?null:(0,k.jsx)(o,{label:`Queue`,variant:`primary`,size:`sm`,title:`Enter queues`,onClick:()=>$(`send`)}),W===void 0?(0,k.jsx)(`button`,{type:`button`,className:`web-composer__round`,"aria-label":`Send`,title:`Enter sends, Shift+Enter breaks the line`,disabled:I.trim()===``,onClick:()=>$(`send`),children:d.send}):(0,k.jsx)(`button`,{type:`button`,className:`web-composer__round`,"aria-label":`Stop`,title:`Esc stops`,onClick:ke,children:d.stop})]})]})]})});export{L as a,P as i,he as n,I as o,F as r,_e as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{n}from"./ScenaProvider-6A3TJumQ.js";import{t as r}from"./ActionList-
|
|
1
|
+
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{n}from"./ScenaProvider-6A3TJumQ.js";import{t as r}from"./ActionList-aOUHK9Z9.js";var i=e(),a=t();function o({x:e,y:t,onClose:n,closeOnOutsideClick:r=!0,closeOnEscape:o=!0,className:s,style:c,children:l}){let u=(0,a.useRef)(null),[d,f]=(0,a.useState)({left:e,top:t});return(0,a.useLayoutEffect)(()=>{let n=u.current;if(!n)return;let r=()=>{let r=n.getBoundingClientRect(),i=Math.max(4,window.innerWidth-r.width-4),a=Math.max(4,window.innerHeight-r.height-4),o=Math.max(4,Math.min(e,i)),s=Math.max(4,Math.min(t,a));f(e=>e.left===o&&e.top===s?e:{left:o,top:s})};r(),window.addEventListener(`resize`,r);let i=typeof ResizeObserver>`u`?null:new ResizeObserver(r);return i?.observe(n),()=>{window.removeEventListener(`resize`,r),i?.disconnect()}},[e,t]),(0,a.useEffect)(()=>{if(!r||!n)return;let e=!0;function t(t){e&&u.current&&(u.current.contains(t.target)||n?.())}let i=setTimeout(()=>{e&&document.addEventListener(`mousedown`,t)},0);return()=>{e=!1,clearTimeout(i),document.removeEventListener(`mousedown`,t)}},[r,n]),(0,a.useEffect)(()=>{if(!o||!n)return;function e(e){e.key===`Escape`&&n?.()}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[o,n]),(0,i.jsx)(`div`,{ref:u,className:[`oo-popup`,s].filter(Boolean).join(` `),style:{position:`fixed`,left:d.left,top:d.top,zIndex:9999,maxHeight:`calc(100vh - 8px)`,overflowY:`auto`,...c},onMouseDown:e=>e.stopPropagation(),children:l})}function s({spec:e,x:t,y:s,onClose:u,context:d,dataContext:f,inline:p}){let m=n(),[h,g]=(0,a.useState)(()=>p?[{component:p.component}]:[{spec:e}]),_=(0,a.useRef)(h);_.current=h;let v=(0,a.useRef)(!1);if(d&&!v.current){for(let[e,t]of Object.entries(d)){let n=e.startsWith(`$/`)?e:c(f,e);m.store.set(n,t)}v.current=!0}let y=(0,a.useMemo)(()=>({pushList:e=>g(t=>[...t,{spec:e}]),replaceList:e=>g(t=>{let n=t.slice(0,-1);return n.push({spec:e}),n}),openInline:(e,t)=>{g(n=>[...n,{component:(0,i.jsx)(l,{name:e,props:t})}])},openPopover:()=>{},back:()=>g(e=>e.length>1?e.slice(0,-1):e),closeMenu:u,keepOpen:()=>void 0,insertAtCursor:()=>void 0,replaceActiveToken:()=>void 0,query:``}),[u]),b=h[h.length-1],x=h.length>1?y.back:void 0;return(0,i.jsx)(o,{x:t,y:s,onClose:u,children:`component`in b?b.component:(0,i.jsx)(r,{spec:b.spec,hostCtx:y,onBack:x,dataContext:f})})}function c(e,t){return t.startsWith(`$/`)?t:e?`${e.endsWith(`/`)?e.slice(0,-1):e}${t.startsWith(`/`)?t:`/${t}`}`:t.startsWith(`/`)?`$${t}`:`$/${t}`}function l({name:e,props:t}){return(0,i.jsxs)(`div`,{style:{padding:12},children:[`[component: `,e,`]`]})}export{s as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./ContextMenu-
|
|
1
|
+
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./ContextMenu-qqlGWvJT.js";var r=t(),i=e();function a(e,t){if(typeof e==`object`&&e)return e[t]}function o(e,t,n){let r=a(e,n),i=a(t,n);return r==null&&i==null?0:r==null?-1:i==null?1:typeof r==`number`&&typeof i==`number`?r-i:String(r).localeCompare(String(i))}function s(e,t,n){if(!n)return e;let r=t.find(e=>e.key===n.key);if(!r||!r.sortable)return e;let i=typeof r.sortable==`function`?r.sortable:(e,t)=>o(e,t,r.key),a=n.direction===`asc`?1:-1;return[...e].sort((e,t)=>a*i(e,t))}var c=480;function l({items:e,columns:t,getKey:a,title:o,toolbar:l,selectedKey:d,onSelect:f,onActivate:p,initialSort:m,sort:h,onSortChange:g,tableBreakpoint:_=c,renderListRow:v,getRowStyle:y,contextMenuSlot:b,contextFor:x,contextDataContext:S,onRowDragStart:C,emptyState:w,className:T,style:E,manageKeys:D=!1}){let O=(0,r.useRef)(null),[k,A]=(0,r.useState)(0),[j,M]=(0,r.useState)(m??null);(0,r.useEffect)(()=>{let e=O.current;if(!e)return;let t=new ResizeObserver(([e])=>{e&&A(e.contentRect.width)});return t.observe(e),()=>t.disconnect()},[]);let N=k>=_,P=h!==void 0,F=P?h:j,I=(0,r.useMemo)(()=>t.filter(e=>!e.hidden&&(N||e.mode!==`table`)&&(e.showAt==null||k>=e.showAt)),[t,N,k]),L=(0,r.useMemo)(()=>({tableMode:N,containerWidth:k}),[N,k]),R=(0,r.useMemo)(()=>I.map(e=>typeof e.width==`function`?e.width(L):e.width).map(e=>e??`minmax(0, 1fr)`).join(` `),[I,L]),z=(0,r.useMemo)(()=>s(e,t,F??null),[e,t,F]);function B(e){if(!e.sortable)return;let t=F,n=!t||t.key!==e.key?{key:e.key,direction:`asc`}:t.direction===`asc`?{key:e.key,direction:`desc`}:null;P?g?.(n):M(n)}(0,r.useEffect)(()=>{if(!d||!O.current)return;let e=O.current.querySelector(`[data-key="${u(d)}"]`);e&&e.scrollIntoView({block:`nearest`})},[d]);let V=d?z.findIndex(e=>a(e)===d):-1;function H(e){if(z.length===0)return;let t=V>=0?V:0;switch(e.key){case`ArrowDown`:{e.preventDefault();let n=z[Math.min(z.length-1,t+1)];n&&f?.(n);return}case`ArrowUp`:{e.preventDefault();let n=z[Math.max(0,t-1)];n&&f?.(n);return}case`Enter`:case` `:{e.preventDefault();let n=z[t];n&&p?.(n);return}}}let[U,W]=(0,r.useState)(null);function G(e,t){b&&(e.preventDefault(),e.stopPropagation(),W({x:e.clientX,y:e.clientY,item:t}))}function K(e,t){let n=e.cellProps?.(t,L),r=e.style===void 0&&n?.style===void 0?void 0:{...e.style,...n?.style};return(0,i.jsx)(`div`,{role:`cell`,className:n?.className===void 0?`oo-listable__cell`:`oo-listable__cell ${n.className}`,"data-align":e.align??`left`,title:e.titleProps?.(t,L).title,style:r,children:J(e,t)},e.key)}function q(e){let t=F?.key===e.key,n=e.titleProps?.(void 0,L);return(0,i.jsx)(`div`,{role:`columnheader`,className:n?.className===void 0?`oo-listable__head-cell`:`oo-listable__head-cell ${n.className}`,"data-align":e.align??`left`,"data-sortable":e.sortable?`true`:void 0,"data-sorted":t?F.direction:void 0,title:e.sortable&&typeof e.label==`string`?`Sort by ${e.label}`:void 0,onClick:e.sortable?()=>B(e):void 0,style:n?.style,children:n?.hidden===!0?null:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`span`,{className:`oo-listable__head-label`,children:e.label}),t?(0,i.jsx)(`span`,{className:`oo-listable__sort-arrow`,"aria-hidden":`true`,children:F.direction===`asc`?`▲`:`▼`}):null]})},e.key)}function J(e,t){return e.visible&&!e.visible(t)?null:e.render(t,L)}function Y(e){let t=a(e);return(0,i.jsx)(`div`,{role:`row`,"data-key":t,"data-selected":t===d?`true`:void 0,className:`oo-listable__item oo-listable__row`,draggable:C?!0:void 0,onDragStart:C?t=>C(t,e):void 0,onClick:()=>{f?.(e)},onDoubleClick:()=>p?.(e),onContextMenu:t=>G(t,e),style:{cursor:f?`pointer`:void 0},children:I.map(t=>K(t,e))},t)}function X(e){let t=a(e),n=t===d,r=y?y(e,L):void 0;return(0,i.jsx)(`div`,{role:`row`,"data-key":t,"data-selected":n?`true`:void 0,className:`oo-listable__item oo-listable__stack`,draggable:C?!0:void 0,onDragStart:C?t=>C(t,e):void 0,onClick:()=>f?.(e),onDoubleClick:()=>p?.(e),onContextMenu:t=>G(t,e),style:{cursor:f?`pointer`:void 0,...r},children:v?v(e):I.map(t=>{let n=J(t,e);if(n==null)return null;let r=t.cellProps?.(e,L);return(0,i.jsx)(`div`,{className:r?.className===void 0?`oo-listable__list-cell`:`oo-listable__list-cell ${r.className}`,title:t.titleProps?.(e,L).title,style:t.style===void 0&&r?.style===void 0?void 0:{...t.style,...r?.style},children:(0,i.jsx)(`span`,{className:`oo-listable__list-value`,children:n})},t.key)})},t)}return(0,i.jsxs)(`div`,{ref:O,role:`table`,tabIndex:0,className:[`oo-listable`,T].filter(Boolean).join(` `),"data-mode":N?`table`:`list`,style:E,onKeyDown:D?H:void 0,children:[o||l?(0,i.jsxs)(`header`,{className:`oo-listable__header`,children:[o?(0,i.jsx)(`h2`,{className:`oo-listable__title`,children:o}):null,l]}):null,z.length===0?(0,i.jsx)(`div`,{className:`oo-listable__empty`,children:w??`Empty`}):(0,i.jsxs)(`div`,{className:`oo-listable__rows`,role:`rowgroup`,style:N?{"--oo-listable-template":R}:void 0,children:[N?(0,i.jsx)(`div`,{role:`row`,className:`oo-listable__head-row`,children:I.map(e=>q(e))}):null,z.map(e=>N?Y(e):X(e))]}),U&&b?(0,i.jsx)(n,{x:U.x,y:U.y,onClose:()=>W(null),spec:{query:{slot:b},footerHints:!0},context:x?x(U.item):void 0,dataContext:S}):null]})}function u(e){return e.replace(/(["\\\]])/g,`\\$1`)}function d(e){return e==null?``:typeof e==`object`?JSON.stringify(e):String(e)}function f({columns:e,rows:t,rowKey:n=`id`,caption:r,selectedKey:a,onSelect:o,onActivate:s,emptyState:c}){let u=e.map(e=>({key:e.key,label:e.label??e.key,width:e.width,align:e.align,sortable:!0,render:t=>d(t[e.key])}));return(0,i.jsx)(l,{items:t,columns:u,getKey:e=>String(e[n]??``),title:r,selectedKey:a,onSelect:o,onActivate:s,emptyState:c})}export{f as DataTable};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./useStore-BQkzWMs-.js";import{n as r}from"./ScenaProvider-6A3TJumQ.js";import{V as i,c as a,o,q as s}from"./data-Fkj0LNnG.js";import{n as c,t as l}from"./words-BknpHIF3.js";import{i as u,s as d}from"./terminal-kD0C2LuZ.js";import{t as f}from"./state-KGSq646f.js";import{a as p,i as m,r as h}from"./turn-BoF7W1h6.js";import{t as g}from"./channel-Cqz_LUS2.js";var _=t(),v=e();function y({uri:e,folder:t}){let n=r(),{state:i}=g(e,u);return d(i?.cwd,t)?(0,v.jsx)(`button`,{type:`button`,className:`web-link`,title:`Open the terminal`,onClick:()=>void n.commands.execute(`ahp.openTerminal`,{uri:e}),children:i?.title===``||i?.title===void 0?`Terminal`:i.title}):null}function b(){let e=r(),t=n(o),u=n(f),d=n(a)?.find(e=>e.resource===u),b=g(d===void 0?void 0:u,s),x=g(b.state?.defaultChat??d?.defaultChat,i),S=x.state?.turns,C=(0,_.useMemo)(()=>m(S??[]),[S]);if(d===void 0)return(0,v.jsx)(`p`,{className:`web-note web-details__empty`,children:`Open a session to see its details.`});let w=d.workingDirectories?.[0],T=d.changes,E=d.origin,D=b.state?.activeClients.length??0,O=b.state?.defaultChat??d.defaultChat,k=[[`Session`,d.title===``?`Untitled`:d.title],[`Session id`,(0,v.jsx)(`code`,{children:d.resource},`s`)]];return O!==void 0&&k.push([`Chat id`,(0,v.jsx)(`code`,{children:O},`h`)]),k.push([`Agent`,d.provider]),C.models.length>0&&k.push([`Model`,C.models.join(`, `)]),w!==void 0&&k.push([`Folder`,(0,v.jsx)(`button`,{type:`button`,className:`web-link`,title:`Show the folder in the explorer`,onClick:()=>void e.commands.execute(`ahp.revealFolder`,{uri:w}),children:(0,v.jsx)(`code`,{children:c(w)})},`f`)]),k.push([`Terminal`,(0,v.jsxs)(`span`,{className:`web-details__list`,children:[w===void 0?null:(t?.terminals??[]).map(e=>(0,v.jsx)(y,{uri:e.resource,folder:w},e.resource)),(0,v.jsx)(`button`,{type:`button`,className:`web-link`,title:w===void 0?`A new terminal`:`A new terminal in the session's folder`,onClick:()=>void e.commands.execute(`ahp.newTerminal`,w===void 0?void 0:{cwd:w}),children:`+ New terminal`})]},`t`)]),d.project!==void 0&&k.push([`Project`,d.project.displayName]),k.push([`Started`,p(d.createdAt)],[`Changed`,p(d.modifiedAt)]),C.turns>0&&(k.push([`Turns`,`${C.turns}${x.state?.turnsNextCursor===void 0?``:`+`}`]),k.push([`Working`,l(C.working)]),k.push([`Tokens`,`\u{2191}${h(C.input)} \u{2193}${h(C.output)}`]),C.tools>0&&k.push([`Tool calls`,String(C.tools)])),T!==void 0&&(T.additions!==void 0||T.deletions!==void 0)&&k.push([`Changes`,(0,v.jsxs)(`span`,{children:[(0,v.jsxs)(`span`,{className:`web-diff--add`,children:[`+`,T.additions??0]}),` `,(0,v.jsxs)(`span`,{className:`web-diff--remove`,children:[`-`,T.deletions??0]}),T.files===void 0?``:` in ${T.files} files`]},`c`)]),E!==void 0&&String(E.kind)===`automation`&&k.push([`From`,`An automation run`]),D>0&&k.push([`Watching`,String(D)]),(0,v.jsx)(`dl`,{className:`web-details`,children:k.map(([e,t])=>(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`dt`,{children:e}),(0,v.jsx)(`dd`,{children:t})]},e))})}export{b as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{n}from"./ScenaProvider-6A3TJumQ.js";import{t as r}from"./Button-_R1oktDz.js";import{b as i}from"./data-Fkj0LNnG.js";import{n as a}from"./words-BknpHIF3.js";import{t as o}from"./Spinner-B-iOhBZq.js";import{t as s}from"./Alert-CHZkhmDE.js";import{a as c,r as l,t as u}from"./changeset-BY8dw-V-.js";import{n as d,r as f,t as p}from"./diff-eyYjrmkY.js";var m=t(),h=e(),g=async e=>e===void 0?``:(await i(e)).text;function _({file:e,before:t,after:i,changeset:_,change:v,review:y}){let b=n(),x=c(_),S=x.files.find(e=>e.id===v),C=S===void 0?[]:x.operations.filter(e=>l(e,`resource`)),[w,T]=(0,m.useState)(null);(0,m.useEffect)(()=>{let e=!0;return T(null),Promise.all([g(t),g(i)]).then(([t,n])=>{e&&T({before:t,after:n})}).catch(t=>{e&&T({error:t instanceof Error?t.message:String(t)})}),()=>{e=!1}},[t,i]);let E=(0,m.useMemo)(()=>w===null||`error`in w||w.before===null||w.after===null?[]:d(w.before,w.after),[w]),D=e===void 0?``:a(e),O=p(E),k=(0,h.jsxs)(`div`,{className:`web-file__head`,children:[(0,h.jsx)(`code`,{children:D}),w!==null&&!(`error`in w)?(0,h.jsxs)(`span`,{children:[(0,h.jsxs)(`span`,{className:`web-diff--add`,children:[`+`,O.added]}),` `,(0,h.jsxs)(`span`,{className:`web-diff--remove`,children:[`-`,O.removed]}),t===void 0?` · new file`:i===void 0?` · deleted`:``]}):null,(0,h.jsxs)(`span`,{className:`web-file__actions`,children:[y===!0&&S!==void 0?(0,h.jsxs)(`label`,{className:`web-file__viewed`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:S.reviewed,onChange:e=>x.review([S],e.target.checked)}),`Viewed`]}):null,S===void 0?null:C.map(e=>(0,h.jsx)(r,{label:`${u(e)} ${e.label}`,size:`sm`,disabled:String(e.status)===`running`,onClick:()=>void x.run(e,S)},e.id)),e===void 0||i===void 0?null:(0,h.jsx)(r,{label:`Open file`,size:`sm`,onClick:()=>void b.commands.execute(`ahp.openFile`,{uri:e})})]})]}),A=x.said===null?null:(0,h.jsx)(s,{tone:x.said.tone,message:x.said.text});return w===null?(0,h.jsxs)(`div`,{className:`web-file`,children:[k,A,(0,h.jsx)(o,{label:`Reading both sides`})]}):`error`in w?(0,h.jsxs)(`div`,{className:`web-file`,children:[k,A,(0,h.jsx)(s,{tone:`danger`,title:`Not readable`,message:w.error})]}):w.before===null||w.after===null?(0,h.jsxs)(`div`,{className:`web-file`,children:[k,A,(0,h.jsx)(`p`,{className:`web-note`,children:`This file is not text.`})]}):E.length===0?(0,h.jsxs)(`div`,{className:`web-file`,children:[k,A,(0,h.jsx)(`p`,{className:`web-note`,children:`No changes.`})]}):(0,h.jsxs)(`div`,{className:`web-file`,children:[k,A,(0,h.jsx)(`div`,{className:`web-file__body`,children:(0,h.jsx)(`table`,{className:`web-code web-diff`,children:(0,h.jsx)(`tbody`,{children:E.map((e,t)=>[(0,h.jsx)(`tr`,{className:`web-diff__hunk`,children:(0,h.jsx)(`td`,{colSpan:3,children:f(e)})},`h${t}`),...e.lines.map((e,n)=>(0,h.jsxs)(`tr`,{"data-kind":e.kind,children:[(0,h.jsx)(`td`,{className:`web-code__number`,children:e.before??``}),(0,h.jsx)(`td`,{className:`web-code__number`,children:e.after??``}),(0,h.jsxs)(`td`,{className:`web-code__text`,children:[e.kind===`add`?`+`:e.kind===`del`?`-`:` `,e.text]})]},`${t}:${n}`))])})})})]})}export{_ as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./useStore-BQkzWMs-.js";import{n as r}from"./ScenaProvider-6A3TJumQ.js";import{t as i}from"./Button-_R1oktDz.js";import{G as a,d as o,g as s,i as c,n as l}from"./data-
|
|
1
|
+
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./useStore-BQkzWMs-.js";import{n as r}from"./ScenaProvider-6A3TJumQ.js";import{t as i}from"./Button-_R1oktDz.js";import{G as a,d as o,g as s,i as c,n as l}from"./data-Fkj0LNnG.js";import{a as u,n as d}from"./words-BknpHIF3.js";import{t as f}from"./Spinner-B-iOhBZq.js";import{t as p}from"./Alert-CHZkhmDE.js";import{t as m}from"./Text-MPtQvYE-.js";import{a as h,i as g,o as _,s as v}from"./index-BkzdJo_Y.js";import{t as y}from"./channel-Cqz_LUS2.js";var b=t(),x=e(),S=[{label:`By hand only`,expression:``},{label:`Every 10 minutes`,expression:`*/10 * * * *`},{label:`Every hour`,expression:`0 * * * *`},{label:`Every 6 hours`,expression:`0 */6 * * *`},{label:`Every day at 09:00`,expression:`0 9 * * *`},{label:`Weekdays at 09:00`,expression:`0 9 * * 1-5`},{label:`Every Monday at 05:00`,expression:`0 5 * * 1`}];function C({label:e,hint:t,children:n}){return(0,x.jsxs)(`label`,{className:`web-form__field`,children:[(0,x.jsx)(`span`,{className:`web-input__label`,children:e}),n,t===void 0?null:(0,x.jsx)(`span`,{className:`web-input__hint`,children:t})]})}function w({resource:e}){let t=r(),{state:w,error:T}=y(o,a),E=n(`$/ahp/agents`)??[],D=n(l),O=n(c),k=e===void 0?void 0:w?.entries.find(t=>t.resource===e),[A,j]=(0,b.useState)(null);if(T!==null)return(0,x.jsx)(p,{tone:`danger`,title:`No automations`,message:T});if(w===void 0)return(0,x.jsx)(f,{label:`Reading the automations`});if(e!==void 0&&k===void 0)return(0,x.jsx)(p,{tone:`warning`,message:`This automation is gone.`});if(e===void 0&&D?.create===void 0)return(0,x.jsx)(p,{tone:`warning`,message:`This host does not let clients create automations.`});let M=A??_(k,{...E[0]===void 0?{}:{provider:E[0].provider},...O==null?{}:{folder:d(O)}}),N=e=>j({...M,...e}),P=E.find(e=>e.provider===M.provider),F=v(M),I=D?.schedules?.minIntervalMinutes,L=S.find(e=>e.expression===M.expression.trim());return(0,x.jsxs)(`div`,{className:`web-page web-form`,children:[(0,x.jsx)(m,{variant:`h2`,text:k===void 0?`New automation`:`Edit ${k.definition.title||`automation`}`}),(0,x.jsx)(C,{label:`Title`,children:(0,x.jsx)(`input`,{className:`web-field`,value:M.title,onChange:e=>N({title:e.target.value})})}),(0,x.jsx)(C,{label:`Message`,hint:`What the agent is told each time it runs.`,children:(0,x.jsx)(`textarea`,{className:`web-field web-form__message`,rows:5,value:M.message,onChange:e=>N({message:e.target.value})})}),(0,x.jsxs)(`div`,{className:`web-form__row`,children:[(0,x.jsx)(C,{label:`Agent`,children:(0,x.jsxs)(`select`,{className:`web-field`,value:M.provider,onChange:e=>N({provider:e.target.value,model:``}),children:[(0,x.jsx)(`option`,{value:``,children:`The host default`}),E.map(e=>(0,x.jsx)(`option`,{value:e.provider,children:e.displayName},e.provider))]})}),(0,x.jsx)(C,{label:`Model`,children:(0,x.jsxs)(`select`,{className:`web-field`,value:M.model,onChange:e=>N({model:e.target.value}),children:[(0,x.jsx)(`option`,{value:``,children:`The agent default`}),(P?.models??[]).map(e=>(0,x.jsx)(`option`,{value:e.id,children:e.name},e.id))]})})]}),(0,x.jsx)(C,{label:`Folder`,hint:`A folder on the daemon's machine.`,children:(0,x.jsx)(`input`,{className:`web-field`,value:M.folder,onChange:e=>N({folder:e.target.value})})}),(0,x.jsxs)(`div`,{className:`web-form__row`,children:[(0,x.jsx)(C,{label:`Schedule`,children:(0,x.jsxs)(`select`,{className:`web-field`,value:L?.expression??`custom`,onChange:e=>{e.target.value!==`custom`&&N({expression:e.target.value})},children:[S.map(e=>(0,x.jsx)(`option`,{value:e.expression,children:e.label},e.label)),(0,x.jsx)(`option`,{value:`custom`,children:`Custom`})]})}),(0,x.jsx)(C,{label:`Cron expression`,hint:`${M.expression.trim()===``?`Runs only when started by hand.`:g(M.expression)}${I===void 0?``:` At most every ${I} minutes.`}`,children:(0,x.jsx)(`input`,{className:`web-field`,value:M.expression,placeholder:`minute hour day month weekday`,onChange:e=>N({expression:e.target.value})})})]}),M.expression.trim()===``?null:(0,x.jsxs)(`div`,{className:`web-form__row`,children:[(0,x.jsx)(C,{label:`Time zone`,children:(0,x.jsx)(`input`,{className:`web-field`,value:M.timeZone,onChange:e=>N({timeZone:e.target.value})})}),(0,x.jsx)(C,{label:`Missed runs`,hint:`What happens to a run due while the daemon was down.`,children:(0,x.jsxs)(`select`,{className:`web-field`,value:M.misfire,onChange:e=>N({misfire:e.target.value===`runOnce`?`runOnce`:`skip`}),children:[(0,x.jsx)(`option`,{value:`skip`,children:`Skip them`}),(0,x.jsx)(`option`,{value:`runOnce`,children:`Run once when back`})]})})]}),(0,x.jsxs)(`div`,{className:`web-form__row`,children:[(0,x.jsx)(C,{label:`Turn off after runs`,hint:`Empty keeps it on.`,children:(0,x.jsx)(`input`,{className:`web-field`,inputMode:`numeric`,value:M.afterRuns,onChange:e=>N({afterRuns:e.target.value})})}),(0,x.jsx)(C,{label:`Turn off after`,hint:`Empty keeps it on.`,children:(0,x.jsx)(`input`,{className:`web-field`,type:`date`,value:M.afterDate,onChange:e=>N({afterDate:e.target.value})})})]}),(0,x.jsxs)(`label`,{className:`web-input__row`,children:[(0,x.jsx)(`input`,{type:`checkbox`,checked:M.enabled,onChange:e=>N({enabled:e.target.checked})}),(0,x.jsx)(`span`,{children:`On`})]}),F===void 0?null:(0,x.jsx)(`p`,{className:`web-note`,children:F}),(0,x.jsxs)(`div`,{className:`web-page__actions`,children:[(0,x.jsx)(i,{label:k===void 0?`Create`:`Save`,variant:`primary`,disabled:F!==void 0,onClick:()=>{if(F!==void 0)return;let e=h(M,k?.definition);if(k===void 0){let n=`ahp-automation:/${u()}`;s(o,{type:`automation/createRequested`,resource:n,definition:e}),t.surfaces.close(`automation:new`),t.commands.execute(`ahp.openAutomation`,{resource:n})}else s(o,{type:`automation/updateRequested`,resource:k.resource,changes:e}),t.surfaces.close(`automation:edit:${k.resource}`),t.commands.execute(`ahp.openAutomation`,{resource:k.resource})}}),(0,x.jsx)(i,{label:`Cancel`,onClick:()=>t.surfaces.close(k===void 0?`automation:new`:`automation:edit:${k.resource}`)})]})]})}export{w as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{l as n,r}from"./notify-Bb548jAB.js";import{t as i}from"./useStore-BQkzWMs-.js";import{n as a}from"./ScenaProvider-6A3TJumQ.js";import{C as o,F as s,L as c,R as l,c as u,g as d,r as f,w as p,z as m}from"./data-Fkj0LNnG.js";import{n as h}from"./words-BknpHIF3.js";import{t as g}from"./emojis-BOylxma2.js";import{t as _}from"./Spinner-B-iOhBZq.js";import{t as v}from"./Alert-CHZkhmDE.js";import{t as y}from"./state-KGSq646f.js";import{t as b}from"./ExplorerList-Bdp0sfLW.js";var x=t(),S=[{id:`none`,label:`No groups`},{id:`folder`,label:`Group by folder`},{id:`status`,label:`Group by status`},{id:`agent`,label:`Group by agent`}],C=[{key:`input`,label:`Needs you`},{key:`running`,label:`Running`},{key:`error`,label:`Failed`},{key:`unread`,label:`Unread`},{key:`idle`,label:`Idle`},{key:`archived`,label:`Archived`}];function w(e){if(l(e.status))return C[5];let t=c(e.status);return t===`idle`&&!m(e.status)?C[3]:C.find(e=>e.key===t)}function T(e,t,n){switch(t){case`none`:return;case`status`:return w(e);case`agent`:return{key:e.provider,label:n(e.provider)};case`folder`:{let t=e.workingDirectories?.[0];return t===void 0?{key:``,label:`No folder`}:{key:t,label:h(t)}}}}function E(e,t,n){if(n===`none`)return[...e];let r=new Map;n===`status`&&C.forEach((e,t)=>r.set(e.key,t));for(let n of e){let e=t(n)?.key??``;r.has(e)||r.set(e,r.size+C.length)}return e.map((e,n)=>({item:e,index:n,rank:r.get(t(e)?.key??``)})).sort((e,t)=>e.rank-t.rank||e.index-t.index).map(e=>e.item)}var D=e(),O=`ahpd-web.session-grouping`;function k(){try{let e=localStorage.getItem(O);return S.some(t=>t.id===e)?e:`none`}catch{return`none`}}function A(e){try{localStorage.setItem(O,e)}catch{}}var j=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`}),M=new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`});function N(e,t=new Date){let n=new Date(e);return Number.isNaN(n.getTime())?``:(n.toDateString()===t.toDateString()?j:M).format(n)}var P={input:`attention`,running:`working`,error:`failed`,idle:`quiet`},F=e=>h(e).replace(/\/+$/,``).split(`/`).pop()??e;function I(e,t){let i=m(e.status),a=l(e.status),o=t=>d(e.resource,t);return[{title:`Open`,onSelect:e=>{e.closeMenu(),t()}},{title:`Rename`,onSelect:t=>{t.closeMenu();let n=window.prompt(`Rename the session`,e.title)?.trim();n!==void 0&&n!==``&&n!==e.title&&o({type:`session/titleChanged`,title:n})}},{title:i?`Mark as unread`:`Mark as read`,onSelect:e=>{e.closeMenu(),o({type:`session/isReadChanged`,isRead:!i})}},{title:a?`Unarchive`:`Archive`,onSelect:e=>{e.closeMenu(),o({type:`session/isArchivedChanged`,isArchived:!a})}},{title:`Copy link`,group:`more`,onSelect:t=>{t.closeMenu(),navigator.clipboard?.writeText(e.resource).catch(()=>void 0)}},{title:`Delete`,group:`more`,color:`red`,onSelect:t=>{t.closeMenu(),n({title:`Delete "${e.title||`Untitled`}"?`,body:`Its history goes with it.`,confirmLabel:`Delete`,tone:`danger`}).then(t=>{t&&p(`disposeSession`,{channel:e.resource}).catch(e=>r(`The session could not be deleted`,e))})}}]}function L(){let e=a(),t=i(f),n=i(u),r=i(`$/ahp/agents`)??[],d=i(y),[p,h]=(0,x.useState)(!1),[C,w]=(0,x.useState)(k),O=e=>{w(e),A(e)},[j,M]=(0,x.useState)(!1),L=t=>void e.commands.execute(`ahp.openSession`,{resource:t}),R=(0,x.useMemo)(()=>{let e=e=>r.find(t=>t.provider===e)?.displayName??e;return E((n??[]).filter(e=>p||!l(e.status)),t=>T(t,C,e),C).map(t=>{let n=c(t.status),r=n===`idle`&&!m(t.status),i=e(t.provider),a=T(t,C,e),o=t.workingDirectories?.[0],u=[i,o===void 0?void 0:F(o)].filter(e=>e!==void 0).join(` · `),d=t.changes,f=n===`idle`?d!==void 0&&(d.additions??0)+(d.deletions??0)>0?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`span`,{className:`web-diff--add`,children:[`+`,d.additions??0]}),` `,(0,D.jsxs)(`span`,{className:`web-diff--remove`,children:[`-`,d.deletions??0]}),d.files===void 0?``:` \u{00B7} ${d.files} files`]}):void 0:`${s[n]}${t.activity===void 0||t.activity===``?``:` \u{00B7} ${t.activity}`}`;return{key:t.resource,dot:l(t.status)?`off`:r?`fresh`:P[n],dotLabel:l(t.status)?`Archived`:r?`Unread`:s[n],title:t.title===``?`Untitled`:t.title,time:N(t.modifiedAt),lines:f===void 0?[u]:[u,f],menu:I(t,()=>L(t.resource)),strong:r,...a===void 0?{}:{group:a}}})},[n,r,p,C]),z=()=>{M(!0),o().catch(()=>void 0).finally(()=>M(!1))},B=t?.status===`failed`?(0,D.jsx)(v,{tone:`danger`,title:`Not connected`,message:t.error??`The server refused the connection.`}):t?.status!==`connected`&&n===void 0?(0,D.jsx)(_,{label:`Connecting to the server`}):R.length===0?(0,D.jsx)(`p`,{className:`web-note`,children:p?`No sessions.`:`No sessions yet.`}):null;return(0,D.jsx)(b,{title:`Sessions`,actions:[{icon:`+`,label:`New session`,run:()=>void e.commands.execute(`ahp.newSession`)},{icon:g.reload,label:j?`Reloading`:`Reload`,run:z,busy:j},{icon:g.archived,label:p?`Hide archived`:`Show archived`,run:()=>h(!p),on:p},{icon:g.group,label:`Group sessions`,on:C!==`none`,menu:S.map(e=>({title:e.label,...e.id===C?{description:`Current`}:{},onSelect:t=>{t.closeMenu(),O(e.id)}}))}],rows:R,selected:d??null,onOpen:L,notice:B,filterLabel:`Filter sessions`})}export{L as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./useStore-BQkzWMs-.js";import{n as r}from"./ScenaProvider-6A3TJumQ.js";import"./data-
|
|
1
|
+
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./useStore-BQkzWMs-.js";import{n as r}from"./ScenaProvider-6A3TJumQ.js";import"./data-Fkj0LNnG.js";import{t as i}from"./state-DRVsnGrf.js";import{t as a}from"./ExplorerList-Bdp0sfLW.js";import{a as o,i as s}from"./words-BMjqrsOT.js";var c=t(),l=e();function u(){let e=r(),t=n(`$/ahp/agents`)??[],u=n(`$/ahp/sessions`)??[],d=n(i),f=t=>void e.commands.execute(`ahp.openAgent`,{provider:t}),p=t=>void e.commands.execute(`ahp.newSession`,{provider:t}),m=(0,c.useMemo)(()=>t.map(e=>{let t=u.filter(t=>t.provider===e.provider).length,n=o(e).some(e=>e.required);return{key:e.provider,dot:`ok`,dotLabel:`Offered`,title:e.displayName,lines:[[s(e),t===1?`1 session`:`${t} sessions`,n?`needs sign-in`:void 0].filter(e=>e!==void 0).join(` · `),...e.description===``?[]:[e.description]],menu:[{title:`Open`,onSelect:t=>{t.closeMenu(),f(e.provider)}},{title:`New session`,onSelect:t=>{t.closeMenu(),p(e.provider)}}]}}),[t,u]);return(0,l.jsx)(a,{title:`Agents`,actions:[],rows:m,selected:d??null,onOpen:f,notice:m.length===0?(0,l.jsx)(`p`,{className:`web-note web-explorer__empty`,children:`This server offers no agent.`}):null,filterLabel:`Filter agents`})}export{u as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./useStore-BQkzWMs-.js";import{n as r}from"./ScenaProvider-6A3TJumQ.js";import{n as i}from"./sessions-CEccRVtA.js";import{c as a,f as o,i as s,r as c,w as l}from"./data-Fkj0LNnG.js";import{n as u}from"./words-BknpHIF3.js";import{t as d}from"./emojis-BOylxma2.js";import{t as f}from"./Spinner-B-iOhBZq.js";import{t as p}from"./Alert-CHZkhmDE.js";import{t as m}from"./Tree-Bb5NwYJ1.js";import{r as h}from"./index-BkzdJo_Y.js";import{r as g}from"./drag-ruzgQUFW.js";var _=t(),v=e=>/^[a-z][a-z0-9+.-]*:\/\/\/?$/i.test(e)?e:e.replace(/\/+$/,``);function y(e,t,n=[]){let r=new Set,i=[],a=(e,t)=>{if(e===void 0||e===``)return;let n=v(e);r.has(n)||(r.add(n),i.push({uri:n,isDefault:t}))};a(e??void 0,!0);for(let e of t)a(e.workingDirectories?.[0],!1);for(let e of n)a(e,!1);return i}var b=(e,t)=>`${e}${e.endsWith(`/`)?``:`/`}${encodeURIComponent(t)}`;function x(e){return[...e.filter(e=>e.type===`directory`),...e.filter(e=>e.type!==`directory`)]}function S(e){try{return decodeURIComponent(v(e).replace(/^file:\/\//i,``))}catch{return v(e).replace(/^file:\/\//i,``)}}function C(e,t){let n=S(t),r=e.filter(e=>{let t=S(e);return n===t||n.startsWith(t.endsWith(`/`)?t:`${t}/`)}).sort((e,t)=>S(t).length-S(e).length)[0];if(r===void 0)return[`file://${n.split(`/`).map(encodeURIComponent).join(`/`)}`];let i=[r];for(let e of n.slice(S(r).length).split(`/`).filter(e=>e!==``))i.push(b(i[i.length-1]??r,e));return i}var w=e(),T=`$/modus/class`;function E(e){let t=u(e);return(0,w.jsx)(`span`,{title:t,children:t.replace(/\/+$/,``).split(`/`).pop()||t})}function D(){let e=r(),t=n(c),u=n(s),v=n(a),S=n(h),[D,O]=(0,_.useState)([]),k=(0,_.useMemo)(()=>y(u,v??[],D),[u,v,D]),[A,j]=(0,_.useState)(new Map),[M,N]=(0,_.useState)(new Set),[P,F]=(0,_.useState)(null),I=(0,_.useCallback)(e=>{j(t=>new Map(t).set(e,`loading`)),l(`resourceList`,{channel:o,uri:e}).then(t=>j(n=>new Map(n).set(e,x(t.entries)))).catch(()=>j(t=>new Map(t).set(e,`failed`)))},[]),L=(0,_.useCallback)(e=>{for(let t of e)!M.has(t)&&!A.has(t)&&I(t);N(e)},[M,A,I]),R=k[0]?.uri;(0,_.useEffect)(()=>{R!==void 0&&!A.has(R)&&L(new Set([...M,R]))},[R]);let z=(0,_.useRef)(null);(0,_.useEffect)(()=>{if(S==null)return;e.store.set(h,null);let t=C(k.map(e=>e.uri),S),[n]=t;n!==void 0&&!k.some(e=>e.uri===n)&&O(e=>[...e,n]),L(new Set([...M,...t]));let r=t[t.length-1]??null;F(r),z.current=r},[S]);let B=(0,_.useRef)(null);(0,_.useEffect)(()=>{let e=z.current;if(e===null)return;let t=Array.from(B.current?.querySelectorAll(`[data-key]`)??[]).find(t=>t.dataset.key===e);t!==void 0&&(t.scrollIntoView({block:`center`}),z.current=null)},[A,P]);let V=()=>{j(new Map);for(let e of M)I(e)},H=(0,_.useMemo)(()=>{let e=(t,n,r)=>{let i=A.get(t),a=i===void 0?[]:i===`loading`?[{key:`${t}#loading`,label:`Loading`}]:i===`failed`?[{key:`${t}#failed`,label:`Not readable`}]:i.map(n=>{let r=b(t,n.name);return n.type===`directory`?e(r,n.name):{key:r,label:n.name,icon:d.file,draggable:!0,data:{uri:r,directory:!1}}});return{key:t,label:n,icon:d.folder,draggable:!0,data:{uri:t,directory:!0},children:a,...r===void 0?{}:{trailing:(0,w.jsx)(`span`,{className:`web-folders__tag`,children:r})}}};return k.map(t=>e(t.uri,E(t.uri),t.isDefault?`default`:void 0))},[k,A]);return t?.status!==`connected`&&k.length===0?t?.status===`failed`?(0,w.jsx)(p,{tone:`danger`,title:`Not connected`,message:t.error??`The server refused the connection.`}):(0,w.jsx)(f,{label:`Connecting to the server`}):(0,w.jsxs)(`div`,{className:`web-explorer`,children:[(0,w.jsxs)(`div`,{className:`web-explorer__title`,children:[(0,w.jsx)(`span`,{children:`Explorer`}),(0,w.jsx)(`span`,{className:`web-explorer__actions`,children:(0,w.jsx)(`button`,{type:`button`,className:`web-explorer__action`,title:`Refresh`,"aria-label":`Refresh`,onClick:V,children:(0,w.jsx)(`span`,{className:`web-explorer__icon`,children:d.reload})})})]}),(0,w.jsxs)(`div`,{className:`web-explorer__scroll`,ref:B,children:[k.length===0?(0,w.jsx)(`p`,{className:`web-note web-explorer__empty`,children:`The server names no folder yet. Start a session in one.`}):null,(0,w.jsx)(m,{nodes:H,selectedKey:P,expanded:M,onExpandedChange:L,onSelect:t=>{if(t.data!==void 0){if(F(t.key),t.data.directory){let e=new Set(M);e.delete(t.key)||e.add(t.key),L(e)}else e.commands.execute(`ahp.openFile`,{uri:t.data.uri}),i(e,e.store.get(T)??`large`)}},onDragStart:(e,t)=>{t.data!==void 0&&g(e.dataTransfer,t.data)}})]})]})}export{D as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./useStore-BQkzWMs-.js";import{n as r}from"./ScenaProvider-6A3TJumQ.js";import{t as i}from"./Button-_R1oktDz.js";import{S as a,c as o,q as s}from"./data-Fkj0LNnG.js";import{o as c}from"./words-BknpHIF3.js";import{t as l}from"./emojis-BOylxma2.js";import{t as u}from"./ContextMenu-qqlGWvJT.js";import{t as d}from"./Spinner-B-iOhBZq.js";import{t as f}from"./Alert-CHZkhmDE.js";import{t as ee}from"./Tree-Bb5NwYJ1.js";import{t as p}from"./TextField-DnSHrmJM.js";import{t as m}from"./CheckBox-Dkn59EbO.js";import{t as h}from"./Modal-BHPfQpzr.js";import{t as te}from"./state-KGSq646f.js";import{n as ne,t as re}from"./index-BkzdJo_Y.js";import{t as ie}from"./channel-Cqz_LUS2.js";import{a as ae,c as oe,d as se,i as g,l as ce,n as _,o as le,r as v,s as ue,t as y,u as b}from"./changeset-BY8dw-V-.js";var x=t(),S=e();function C(e){let t=e.filter(e=>e.staged).length;return t>0?t===1?`The 1 staged file is committed. The rest stay as they are.`:`The ${t} staged files are committed. The rest stay as they are.`:e.length===1?`Nothing is staged, so the 1 changed file is committed.`:`Nothing is staged, so all ${e.length} changed files are committed.`}function w({form:e,files:t,onCommit:n,onClose:r}){let[a,o]=(0,x.useState)(``),s=c(e.operation.confirmation),l=a.trim()!==``;return(0,S.jsx)(h,{open:!0,title:e.operation.label,onClose:r,children:(0,S.jsxs)(`div`,{className:`web-changeset-form`,children:[(0,S.jsx)(p,{label:`Commit message`,multiline:!0,rows:4,value:a,placeholder:`What does this change do?`,onChange:o}),(0,S.jsx)(`p`,{className:`web-note`,children:C(t)}),s===``?null:(0,S.jsx)(`p`,{className:`web-note`,children:s}),(0,S.jsxs)(`div`,{className:`web-changeset-form__actions`,children:[(0,S.jsx)(i,{label:`Cancel`,variant:`ghost`,onClick:r}),(0,S.jsx)(i,{label:e.operation.label,variant:`primary`,disabled:!l,onClick:()=>n(a.trim())})]})]})})}function T({form:e,onCreate:t,onClose:n}){let[r,a]=(0,x.useState)(e.draft.title),[o,s]=(0,x.useState)(e.draft.description),[c,l]=(0,x.useState)(!1);(0,x.useEffect)(()=>{a(e.draft.title),s(e.draft.description)},[e.draft]);let u=e.draft.branchName===null&&e.draft.baseBranchName===null?null:`${e.draft.branchName??`?`} \u{2192} ${e.draft.baseBranchName??`?`}`,f=!e.preparing&&e.create!==null&&r.trim()!==``;return(0,S.jsx)(h,{open:!0,title:`Create a pull request`,onClose:n,children:(0,S.jsxs)(`div`,{className:`web-changeset-form`,children:[e.preparing?(0,S.jsx)(d,{label:`Asking the server for a title and description`}):null,e.draft.repository===null&&u===null?null:(0,S.jsx)(`p`,{className:`web-note`,children:[e.draft.repository,u].filter(e=>e!==null).join(` · `)}),(0,S.jsx)(p,{label:`Title`,value:r,placeholder:`What is this request?`,disabled:e.preparing,onChange:a}),(0,S.jsx)(p,{label:`Description`,multiline:!0,rows:8,value:o,placeholder:`What changed, and why?`,disabled:e.preparing,onChange:s}),(0,S.jsx)(m,{label:`Open as a draft`,value:c,onChange:l}),(0,S.jsx)(`p`,{className:`web-note`,children:e.create===null?`This server offers no way to create the request.`:`The server commits what is uncommitted, pushes the branch and opens the request only when you press the button.`}),(0,S.jsxs)(`div`,{className:`web-changeset-form__actions`,children:[(0,S.jsx)(i,{label:`Cancel`,variant:`ghost`,onClick:n}),e.create===null?null:(0,S.jsx)(i,{label:e.create.label,variant:`primary`,disabled:!f,onClick:()=>t({...e.draft,title:r.trim(),description:o},c)})]})]})})}function de({form:e,files:t,onCommit:n,onPullRequest:r,onClose:i}){return e===null?null:e.kind===`commit`?(0,S.jsx)(w,{form:e,files:t,onCommit:n,onClose:i}):(0,S.jsx)(T,{form:e,onCreate:r,onClose:i})}var E=`ahpd-web.changes-view`,D=`ahpd-web.changes-grouping`,fe={review:`By review`,staging:`Staged and not`,none:`Not grouped`};function O(e,t){try{let n=localStorage.getItem(e);return t.find(e=>e===n)??null}catch{return null}}function k(e,t){try{localStorage.setItem(e,t)}catch{}}var pe={A:`Added`,M:`Modified`,D:`Deleted`,U:`Untracked`};function A(){let e=r(),t=n(te),i=n(o)?.find(e=>e.resource===t),c=ie(t,s),p=(0,x.useMemo)(()=>se(c.state?.changesets),[c.state?.changesets]),[m,h]=(0,x.useState)(void 0),C=p.find(e=>e.uri===m)??le(p),w=ae(C?.uri),{files:T,operations:A}=w,j=i?.workingDirectories?.[0]??null,[M,me]=(0,x.useState)(()=>O(E,[`list`,`tree`])??`list`),[N,he]=(0,x.useState)(()=>O(D,[`review`,`staging`,`none`])),P=C?.review===!0,ge=T.some(e=>e.staged||e.unstaged),F=[...P?[`review`]:[],...ge?[`staging`]:[],`none`],I=N!==null&&F.includes(N)?N:F[0]??`none`,[L,_e]=(0,x.useState)(``),[ve,R]=(0,x.useState)(new Set),[ye,z]=(0,x.useState)(null),[B,V]=(0,x.useState)(null),H=A.filter(e=>v(e,`resource`)),be=A.some(e=>e.id===`create-pr`),U=A.filter(e=>v(e,`changeset`)&&!(be&&e.id===`prepare-pull-request`)),W=e=>String(e.status)===`running`,xe=t=>{let n=[{title:`Open change`,onSelect:n=>{n.closeMenu(),_(e,t,C?.uri,P)}}];t.status!==`deleted`&&(n.push({title:`Open file`,onSelect:n=>{n.closeMenu(),e.commands.execute(`ahp.openFile`,{uri:t.file})}}),n.push(...re(e,t.file,ne(e,t.file)[0]?.component??null))),P&&n.push({title:t.reviewed?`Mark as not reviewed`:`Mark as reviewed`,onSelect:e=>{e.closeMenu(),w.review([t],!t.reviewed)}});for(let e of H)n.push({title:e.label,...e.description===void 0?{}:{tooltip:e.description},group:`file`,...e.confirmation===void 0?{}:{color:`red`},onSelect:n=>{n.closeMenu(),w.run(e,t)}});return n},Se=t=>{let n=ce(t),r=(e,t)=>{e.stopPropagation(),t()};return(0,S.jsxs)(`span`,{className:`web-change__end`,children:[(0,S.jsxs)(`span`,{className:`web-change__actions`,children:[P?(0,S.jsx)(`button`,{type:`button`,className:`web-change__action`,title:t.reviewed?`Mark as not reviewed`:`Mark as reviewed`,"aria-label":t.reviewed?`Mark as not reviewed`:`Mark as reviewed`,"aria-pressed":t.reviewed,onClick:e=>r(e,()=>w.review([t],!t.reviewed)),children:l.check}):null,t.status===`deleted`?null:(0,S.jsx)(`button`,{type:`button`,className:`web-change__action`,title:`Open file`,"aria-label":`Open file`,onClick:n=>r(n,()=>void e.commands.execute(`ahp.openFile`,{uri:t.file})),children:l.file}),H.map(e=>(0,S.jsx)(`button`,{type:`button`,className:`web-change__action`,title:e.label,"aria-label":e.label,disabled:W(e),onClick:n=>r(n,()=>void w.run(e,t)),children:y(e)},e.id))]}),(0,S.jsx)(`span`,{className:`web-change__counts`,children:t.added===void 0&&t.removed===void 0?null:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`span`,{className:`web-diff--add`,children:[`+`,t.added??0]}),` `,(0,S.jsxs)(`span`,{className:`web-diff--remove`,children:[`-`,t.removed??0]})]})}),(0,S.jsx)(`span`,{className:`web-change__letter`,"data-letter":n,title:pe[n],children:n})]})},G=L.trim().toLowerCase(),K=G===``?T:T.filter(e=>`${b(e.dir,j)}/${e.name}`.toLowerCase().includes(G)),q=oe(K,I),J=new Map,Y=(()=>{let t=(t,n)=>{let r=`${n}|${t.id}`;J.set(r,t);let i=b(t.dir,j);return{key:r,label:(0,S.jsxs)(`span`,{className:`web-change`,"data-reviewed":t.reviewed?`true`:`false`,"data-deleted":t.status===`deleted`?`true`:`false`,title:`${i}/${t.name}`,children:[(0,S.jsx)(`span`,{className:`web-change__name`,children:t.name}),M===`list`&&i!==`.`?(0,S.jsx)(`span`,{className:`web-change__dir`,children:i}):null]}),icon:ne(e,t.file)[0]?.opens?.icon??l.file,trailing:Se(t),data:t}},n=(e,r)=>({key:`${r}|dir:${e.path}`,label:(0,S.jsx)(`span`,{className:`web-change__name`,title:e.path,children:e.name}),icon:l.folder,children:[...e.folders.map(e=>n(e,r)),...e.changes.map(e=>t(e,r))]}),r=(e,r)=>{if(M===`list`)return e.map(e=>t(e,r));let i=ue(e,j);return[...i.folders.map(e=>n(e,r)),...i.changes.map(e=>t(e,r))]};return I===`none`?r(q[0]?.changes??[],`all`):q.map(e=>({key:`group:${e.key}`,icon:``,label:(0,S.jsx)(`span`,{className:`web-change__group`,children:e.label}),trailing:(0,S.jsx)(`span`,{className:`web-explorer__count`,children:e.changes.length}),children:r(e.changes,e.key)}))})(),X=[],Z=e=>{for(let t of e)t.children!==void 0&&(X.push(t.key),Z(t.children))};Z(Y);let Ce=new Set(X.filter(e=>!ve.has(e))),we=e=>{let t=e.target.closest(`[data-key]`)?.dataset.key,n=t===void 0?void 0:J.get(t);n!==void 0&&(e.preventDefault(),z(t??null),V({x:e.clientX,y:e.clientY,items:xe(n)}))},Te=String(w.state?.status??``),Ee=(0,S.jsxs)(S.Fragment,{children:[t===void 0?(0,S.jsx)(`p`,{className:`web-note web-explorer__empty`,children:`Open a session to see what it changed.`}):null,t!==void 0&&c.state!==void 0&&p.length===0?(0,S.jsx)(`p`,{className:`web-note web-explorer__empty`,children:`This session tracks no changes.`}):null,w.said===null?null:(0,S.jsx)(f,{tone:w.said.tone,message:w.said.text}),w.error===null?null:(0,S.jsx)(f,{tone:`danger`,title:`Changes not readable`,message:w.error}),w.state?.error===void 0?null:(0,S.jsx)(f,{tone:`danger`,message:w.state.error.message}),C!==void 0&&(w.state===void 0||Te===`computing`)&&w.error===null?(0,S.jsx)(d,{label:`Working out the changes`}):null,w.state!==void 0&&Te!==`computing`&&T.length===0?(0,S.jsx)(`p`,{className:`web-note web-explorer__empty`,children:`No changes.`}):null]}),Q=(e,t,n,r)=>(0,S.jsx)(`button`,{type:`button`,className:`web-explorer__action`,title:t,"aria-label":t,"aria-pressed":r?.on,"data-on":r?.on===!0?`true`:`false`,"data-busy":r?.busy===!0?`true`:`false`,"data-tone":r?.tone??void 0,disabled:r?.disabled,onClick:n,children:(0,S.jsx)(`span`,{className:`web-explorer__icon`,children:e})},t),$=e=>{me(e),k(E,e)},De=e=>{let t=e.currentTarget.getBoundingClientRect(),n=p.map(e=>({title:e.label,icon:e.uri===C?.uri?l.check:``,onSelect:t=>{t.closeMenu(),h(e.uri)}}));V({x:t.left,y:t.bottom,items:n})},Oe=e=>{let t=e.currentTarget.getBoundingClientRect(),n=e=>({icon:e?l.check:``}),r=U.map(e=>{let t=g(e);return{title:e.label,...e.description===void 0?{}:{tooltip:e.description},group:`changes`,icon:y(e),...t===null?{}:{color:t},disabled:W(e),onSelect:t=>{t.closeMenu(),w.run(e)}}});if(r.push({title:`Show as a list`,group:`view`,...n(M===`list`),onSelect:e=>{e.closeMenu(),$(`list`)}},{title:`Show as a tree`,group:`view`,...n(M===`tree`),onSelect:e=>{e.closeMenu(),$(`tree`)}}),F.length>1)for(let e of F)r.push({title:fe[e],group:`group`,...n(e===I),onSelect:t=>{t.closeMenu(),he(e),k(D,e)}});X.length>0&&(r.push({title:`Expand all`,group:`folders`,icon:``,onSelect:e=>{e.closeMenu(),R(new Set)}}),r.push({title:`Collapse all`,group:`folders`,icon:``,onSelect:e=>{e.closeMenu(),R(new Set(X))}})),V({x:Math.max(0,t.right-200),y:t.bottom,items:r})},ke=T.reduce((e,t)=>e+(t.added??0),0),Ae=T.reduce((e,t)=>e+(t.removed??0),0);return(0,S.jsxs)(`div`,{className:`web-explorer web-changes`,children:[(0,S.jsxs)(`div`,{className:`web-explorer__title`,children:[(0,S.jsx)(`span`,{className:`web-explorer__name`,title:i?.title,children:i===void 0?`Changes`:`Changes \u{00B7} ${i.title||`Untitled`}`}),C===void 0?null:(0,S.jsxs)(`span`,{className:`web-explorer__actions`,children:[U.map(e=>Q(y(e),e.label,()=>void w.run(e),{busy:W(e),disabled:W(e),tone:g(e)})),U.length===0?null:(0,S.jsx)(`span`,{className:`web-explorer__sep`,"aria-hidden":`true`}),Q(l.reload,`Reload`,()=>void a(C.uri)),Q(l.more,`View options`,Oe)]})]}),C===void 0?null:(0,S.jsxs)(`div`,{className:`web-changes__bar`,children:[p.length>1?(0,S.jsxs)(`button`,{type:`button`,className:`web-changes__scope`,title:C.description??C.label,"aria-haspopup":`menu`,onClick:De,children:[C.label,` `,(0,S.jsx)(`span`,{"aria-hidden":`true`,children:l.caretDown})]}):(0,S.jsx)(`span`,{className:`web-changes__scope web-changes__scope--only`,title:C.description??C.label,children:C.label}),(0,S.jsx)(`span`,{className:`web-changes__totals`,children:T.length===0?null:(0,S.jsxs)(S.Fragment,{children:[T.length===1?`1 file`:`${T.length} files`,` `,(0,S.jsxs)(`span`,{className:`web-diff--add`,children:[`+`,ke]}),` `,(0,S.jsxs)(`span`,{className:`web-diff--remove`,children:[`−`,Ae]})]})}),(0,S.jsx)(`span`,{className:`web-segments`,role:`group`,"aria-label":`Show as`,children:[`list`,`tree`].map(e=>(0,S.jsx)(`button`,{type:`button`,className:`web-segments__item web-segments__item--icon`,"aria-pressed":M===e,title:e===`list`?`Show as a list`:`Show as a tree`,"aria-label":e===`list`?`Show as a list`:`Show as a tree`,onClick:()=>$(e),children:e===`list`?l.log:l.tree},e))})]}),T.length===0?null:(0,S.jsx)(`input`,{className:`web-explorer__filter`,type:`search`,value:L,placeholder:`Filter files`,"aria-label":`Filter files`,onChange:e=>_e(e.target.value)}),(0,S.jsxs)(`div`,{className:`web-explorer__scroll`,onContextMenu:we,children:[(0,S.jsx)(`div`,{className:`web-explorer__notice`,children:Ee}),(0,S.jsx)(ee,{nodes:Y,selectedKey:ye,expanded:Ce,onExpandedChange:e=>R(new Set(X.filter(t=>!e.has(t)))),onSelect:t=>{if(t.data===void 0){R(e=>{let n=new Set(e);return n.delete(t.key)||n.add(t.key),n});return}z(t.key),_(e,t.data,C?.uri,P)}}),G!==``&&K.length===0?(0,S.jsx)(`p`,{className:`web-note web-explorer__empty`,children:`Nothing matches.`}):null]}),(0,S.jsx)(de,{form:w.form,files:T,onCommit:w.commit,onPullRequest:w.pullRequest,onClose:w.closeForm}),B===null?null:(0,S.jsx)(u,{spec:{items:B.items},x:B.x,y:B.y,onClose:()=>V(null)})]})}export{A as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{r as n}from"./notify-Bb548jAB.js";import{t as r}from"./useStore-BQkzWMs-.js";import{n as i}from"./ScenaProvider-6A3TJumQ.js";import{G as a,S as o,d as s,n as c}from"./data-Fkj0LNnG.js";import{t as l}from"./emojis-BOylxma2.js";import{t as u}from"./Spinner-B-iOhBZq.js";import{t as d}from"./Alert-CHZkhmDE.js";import{c as f,f as p,l as m,m as h,p as g,u as _}from"./index-BkzdJo_Y.js";import{t as v}from"./ExplorerList-Bdp0sfLW.js";import{t as y}from"./channel-Cqz_LUS2.js";import{i as b,n as x}from"./actions-BQzD99j0.js";var S=t(),C=e(),w={running:`working`,failed:`failed`,on:`ok`,off:`off`},T={running:`Running`,failed:`Last run failed`,on:`On`,off:`Off`},E={pending:`waiting`,running:`running`,completed:`done`,failed:`failed`,cancelled:`stopped`},D=new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}),O=e=>{if(e===void 0)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:D.format(t)},k=e=>n(`The automation could not run`,e);function A(){let e=i(),{state:t,error:n}=y(s,a),D=r(c),A=r(h),j=t=>void e.commands.execute(`ahp.openAutomation`,{resource:t}),M=t=>void e.commands.execute(`ahp.editAutomation`,{resource:t}),N=(0,S.useMemo)(()=>[...t?.entries??[]].sort((e,t)=>p(e).localeCompare(p(t))).map(e=>{let t=_(e),n=m(e)[0],r=n===void 0?void 0:f(n),i=e.definition.session.provider,a=e.runCount??e.runs.length;return{key:e.resource,dot:w[t],dotLabel:T[t],title:p(e),...e.nextRunAt===void 0||!e.definition.enabled?{}:{time:O(e.nextRunAt)},lines:[[g(e),i].filter(e=>e!==void 0).join(` · `),r===void 0?`Never run`:`${a} ${a===1?`run`:`runs`} \u{00B7} last ${E[r.status]??r.status} ${O(r.at)}`],menu:x(e,()=>j(e.resource),()=>M(e.resource)),...e.operations.map(String).includes(`run`)?{action:{icon:l.run,label:`Run now`,run:()=>void b(e).catch(k)}}:{}}}),[t]),P=n===null?t===void 0?(0,C.jsx)(u,{label:`Reading the automations`}):N.length===0?(0,C.jsx)(`p`,{className:`web-note web-explorer__empty`,children:`No automations yet.`}):null:(0,C.jsx)(d,{tone:`danger`,title:`No automations`,message:n});return(0,C.jsx)(v,{title:`Automations`,actions:[...D?.create===void 0?[]:[{icon:`+`,label:`New automation`,run:()=>void e.commands.execute(`ahp.newAutomation`)}],{icon:l.reload,label:`Reload`,run:()=>void o(s)}],rows:N,selected:A??null,onOpen:j,notice:P,filterLabel:`Filter automations`})}export{A as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./emojis-
|
|
1
|
+
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./emojis-BOylxma2.js";import{t as r}from"./ContextMenu-qqlGWvJT.js";var i=t(),a=e();function o({title:e,actions:t,rows:o,selected:s,onOpen:c,notice:l,filterLabel:u}){let[d,f]=(0,i.useState)(null),[p,m]=(0,i.useState)(``),[h,g]=(0,i.useState)(new Set),_=e=>g(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),v=p.trim().toLowerCase(),y=v===``?o:o.filter(e=>[e.title,...e.lines.filter(e=>typeof e==`string`)].join(` `).toLowerCase().includes(v)),b=(e,t)=>{e.preventDefault(),f({x:e.clientX,y:e.clientY,items:t.menu})};return(0,a.jsxs)(`div`,{className:`web-explorer`,children:[(0,a.jsxs)(`div`,{className:`web-explorer__title`,children:[(0,a.jsx)(`span`,{children:e}),(0,a.jsx)(`span`,{className:`web-explorer__actions`,children:t.map(e=>(0,a.jsx)(`button`,{type:`button`,className:`web-explorer__action`,title:e.label,"aria-label":e.label,"aria-pressed":e.on,"data-on":e.on===!0?`true`:`false`,"data-busy":e.busy===!0?`true`:void 0,disabled:e.busy===!0,onClick:t=>{if(e.menu===void 0)return e.run?.();let n=t.currentTarget.getBoundingClientRect();f({x:n.left,y:n.bottom,items:e.menu})},children:(0,a.jsx)(`span`,{className:`web-explorer__icon`,children:e.icon})},e.label))})]}),u===void 0?null:(0,a.jsx)(`input`,{className:`web-explorer__filter`,type:`search`,value:p,placeholder:u,"aria-label":u,onChange:e=>m(e.target.value)}),(0,a.jsxs)(`div`,{className:`web-explorer__scroll`,children:[l==null?null:(0,a.jsx)(`div`,{className:`web-explorer__notice`,children:l}),(0,a.jsx)(`ul`,{className:`web-explorer__list`,role:`listbox`,"aria-label":e,children:y.map((e,t)=>{let r=e.group,o=r!==void 0&&y[t-1]?.group?.key!==r.key,l=o?y.filter(e=>e.group?.key===r.key).length:0,u=r!==void 0&&h.has(r.key);return(0,a.jsxs)(i.Fragment,{children:[o?(0,a.jsx)(`li`,{className:`web-explorer__group`,role:`presentation`,children:(0,a.jsxs)(`button`,{type:`button`,"aria-expanded":!u,onClick:()=>_(r.key),children:[(0,a.jsx)(`span`,{className:`web-explorer__fold`,"aria-hidden":`true`,children:u?n.caretRight:n.caretDown}),(0,a.jsx)(`span`,{className:`web-explorer__group-label`,children:r.label}),(0,a.jsx)(`span`,{className:`web-explorer__count`,children:l})]})}):null,u?null:(0,a.jsxs)(`li`,{role:`option`,"aria-selected":e.key===s,tabIndex:0,className:`web-row`,"data-selected":e.key===s?`true`:`false`,onClick:()=>c(e.key),onKeyDown:t=>{if((t.key===`Enter`||t.key===` `)&&(t.preventDefault(),c(e.key)),t.key===`ContextMenu`||t.shiftKey&&t.key===`F10`){t.preventDefault();let n=t.currentTarget.getBoundingClientRect();f({x:n.left+24,y:n.bottom,items:e.menu})}},onContextMenu:t=>b(t,e),children:[(0,a.jsx)(`span`,{className:`web-row__dot`,"data-dot":e.dot,title:e.dotLabel,"aria-label":e.dotLabel}),(0,a.jsxs)(`span`,{className:`web-row__body`,children:[(0,a.jsxs)(`span`,{className:`web-row__head`,children:[(0,a.jsx)(`span`,{className:`web-row__title`,"data-strong":e.strong===!0?`true`:`false`,children:e.title}),e.time===void 0?null:(0,a.jsx)(`span`,{className:`web-row__time`,children:e.time}),e.action===void 0?null:(0,a.jsx)(`button`,{type:`button`,className:`web-row__action`,title:e.action.label,"aria-label":e.action.label,onClick:t=>{t.stopPropagation(),e.action?.run()},onKeyDown:e=>e.stopPropagation(),children:e.action.icon})]}),e.lines.map((e,t)=>(0,a.jsx)(`span`,{className:`web-row__line`,children:e},t))]})]})]},e.key)})}),v!==``&&y.length===0?(0,a.jsx)(`p`,{className:`web-note web-explorer__empty`,children:`Nothing matches.`}):null]}),d===null?null:(0,a.jsx)(r,{spec:{items:d.items},x:d.x,y:d.y,onClose:()=>f(null)})]})}export{o as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./Spinner-B-iOhBZq.js";import{t as r}from"./Alert-CHZkhmDE.js";import{i}from"./diff-eyYjrmkY.js";import{n as a,t as o}from"./text-
|
|
1
|
+
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./Spinner-B-iOhBZq.js";import{t as r}from"./Alert-CHZkhmDE.js";import{i}from"./diff-eyYjrmkY.js";import{n as a,t as o}from"./text-CmjM0Nin.js";var s=t(),c=e(),l=5e3;function u({uri:e,line:t,end:u}){let d=a(e),f=(0,s.useRef)(null);if((0,s.useEffect)(()=>{f.current?.scrollIntoView({block:`center`})},[d,t]),e===void 0)return(0,c.jsx)(r,{tone:`warning`,message:`No file was named.`});let p=(0,c.jsx)(o,{uri:e});if(d===null)return(0,c.jsxs)(`div`,{className:`web-file`,children:[p,(0,c.jsx)(n,{label:`Reading the file`})]});if(`error`in d)return(0,c.jsxs)(`div`,{className:`web-file`,children:[p,(0,c.jsx)(r,{tone:`danger`,title:`Not readable`,message:d.error})]});if(d.text===null)return(0,c.jsxs)(`div`,{className:`web-file`,children:[p,(0,c.jsx)(`p`,{className:`web-note`,children:`This file is not text.`})]});let m=i(d.text),h=m.slice(0,l),g=t??-1,_=u??g;return(0,c.jsxs)(`div`,{className:`web-file`,children:[p,(0,c.jsxs)(`div`,{className:`web-file__body`,children:[(0,c.jsx)(`table`,{className:`web-code`,children:(0,c.jsx)(`tbody`,{children:h.map((e,t)=>{let n=t+1;return(0,c.jsxs)(`tr`,{"data-hit":n>=g&&n<=_?`true`:`false`,...n===g?{ref:f}:{},children:[(0,c.jsx)(`td`,{className:`web-code__number`,children:n}),(0,c.jsx)(`td`,{className:`web-code__text`,children:e})]},n)})})}),m.length>l?(0,c.jsxs)(`p`,{className:`web-note`,children:[`Showing the first `,l,` of `,m.length,` lines.`]}):null]})]})}export{u as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./useStore-BQkzWMs-.js";import{n}from"./ScenaProvider-6A3TJumQ.js";import{t as r}from"./useI18n-
|
|
1
|
+
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./useStore-BQkzWMs-.js";import{n}from"./ScenaProvider-6A3TJumQ.js";import{t as r}from"./useI18n-Bfix5MNN.js";var i=e();function a({namespace:e,fields:a}){let d=n(),{t:f}=r(`query`),p=t(`$/${e}/query`),m=p?.where??[],h=t=>d.store.set(`$/${e}/query`,{...p??{page:1,pageSize:50},...t,page:1}),g=e=>e.value??!0,_=e=>m.some(t=>t.field===e.field&&t.value===g(e)),v=e=>{let t=m.filter(t=>t.field!==e.field),n=_(e)?t:[...t,{field:e.field,op:e.op??`eq`,value:g(e)}];h({where:n})};return(0,i.jsxs)(`div`,{style:o,children:[(0,i.jsx)(`input`,{style:s,placeholder:f(`search`,`Search…`),value:p?.q??``,onChange:e=>h({q:e.currentTarget.value})}),a?.length?(0,i.jsx)(`div`,{style:c,children:a.map(e=>(0,i.jsx)(`button`,{type:`button`,style:{...l,..._(e)?u:{}},onClick:()=>v(e),children:e.label??e.field},e.field))}):null]})}var o={display:`flex`,flexDirection:`column`,gap:6,padding:8},s={boxSizing:`border-box`,width:`100%`,padding:`6px 8px`,background:`var(--oo-color-canvas, #16181d)`,border:`1px solid var(--oo-color-border, #2b2f37)`,borderRadius:4,outline:`none`,fontSize:13,color:`var(--oo-color-text, #e6e8eb)`},c={display:`flex`,flexWrap:`wrap`,gap:4},l={appearance:`none`,border:`1px solid var(--oo-color-border, #2b2f37)`,background:`none`,borderRadius:999,padding:`2px 8px`,fontSize:11,cursor:`pointer`,color:`var(--oo-color-muted, #8a8f98)`},u={color:`#fff`,background:`var(--oo-color-accent, #4c7fff)`,borderColor:`var(--oo-color-accent, #4c7fff)`};export{a as Filter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./useStore-BQkzWMs-.js";import{n as r}from"./ScenaProvider-6A3TJumQ.js";import{t as i}from"./Button-_R1oktDz.js";import{i as a,n as o,o as s,r as c,x as l}from"./data-
|
|
1
|
+
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./useStore-BQkzWMs-.js";import{n as r}from"./ScenaProvider-6A3TJumQ.js";import{t as i}from"./Button-_R1oktDz.js";import{i as a,n as o,o as s,r as c,x as l}from"./data-Fkj0LNnG.js";import{n as u,t as d}from"./words-BknpHIF3.js";import{t as f}from"./Badge-BDEW5PFb.js";import{t as p}from"./Alert-CHZkhmDE.js";import{t as m}from"./Text-MPtQvYE-.js";import{t as h}from"./DetailList-Yalgw0YM.js";import{h as g}from"./index-BkzdJo_Y.js";import{a as _}from"./turn-BoF7W1h6.js";var v=t(),y=e(),b={connected:{tone:`success`,text:`Connected`},connecting:{tone:`info`,text:`Connecting`},reconnecting:{tone:`warning`,text:`Reconnecting`},disconnected:{tone:`default`,text:`Disconnected`},failed:{tone:`danger`,text:`Failed`}};function x(e){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(null);return(0,v.useEffect)(()=>{n(null),i(null)},[e]),{status:t,error:r}}function S(){let[e,t]=(0,v.useState)(()=>Date.now());return(0,v.useEffect)(()=>{let e=window.setInterval(()=>t(Date.now()),1e3);return()=>window.clearInterval(e)},[]),e}function C(){let e=r(),t=n(c),v=n(s),C=n(`$/ahp/agents`)??[],w=n(a),T=n(o),{status:E,error:D}=x(t?.generation??0),O=S(),k=b[t?.status??`disconnected`]??b.disconnected,A=E?.startedAt===void 0?NaN:Date.parse(E.startedAt),j=[{label:`Status`,value:k.text}];v!=null&&(j.push({label:`Host`,value:v.label}),v.protocolVersion!==null&&j.push({label:`Protocol`,value:v.protocolVersion}),v.connectedAt!==null&&j.push({label:`Connected`,value:`${_(v.connectedAt)} \u{00B7} ${d(O-v.connectedAt)}`}),j.push({label:`Client`,value:(0,y.jsx)(`code`,{children:v.clientId})},{label:`Server sequence`,value:String(v.serverSeq)},{label:`Following`,value:`${v.subscriptions} channels`})),t?.error!==null&&t?.error!==void 0&&j.push({label:`Last error`,value:t.error});let M=[];E!==null&&(Number.isNaN(A)||M.push({label:`Started`,value:`${_(A)} \u{00B7} up ${d(O-A)}`}),E.pid!==void 0&&M.push({label:`Process`,value:String(E.pid)}),E.url!==void 0&&M.push({label:`Address`,value:(0,y.jsx)(`code`,{children:E.url})}),E.automations!==void 0&&M.push({label:`Automations kept in`,value:E.automations}),(E.paths??[]).length>0&&M.push({label:`Sessions kept in`,value:(0,y.jsx)(`span`,{className:`web-lines`,children:E.paths.map(e=>(0,y.jsx)(`code`,{children:e},e))})}));let N=[{label:`Agents`,value:(0,y.jsx)(`button`,{type:`button`,className:`web-link`,onClick:()=>void e.commands.execute(`sidebar.activate`,{section:g}),children:C.length===0?`None`:C.map(e=>e.displayName).join(`, `)})},{label:`Default folder`,value:w==null?`None`:(0,y.jsx)(`code`,{children:u(w)})}];v?.activeSessions!==null&&v?.activeSessions!==void 0&&N.push({label:`Active sessions`,value:String(v.activeSessions)}),N.push({label:`Automations`,value:T==null?`Not offered`:[T.create===void 0?`Read only`:`Clients can create them`,T.schedules?.minIntervalMinutes===void 0?void 0:`at most every ${T.schedules.minIntervalMinutes} minutes`,T.runCancellation===void 0?void 0:`runs can be stopped`].filter(e=>e!==void 0).join(`, `)});let P=v?.terminals??[];return(0,y.jsxs)(`div`,{className:`web-page`,children:[(0,y.jsxs)(`div`,{className:`web-page__head`,children:[(0,y.jsxs)(`div`,{className:`web-chat__title`,children:[(0,y.jsx)(m,{variant:`h2`,text:`Host`}),(0,y.jsx)(f,{tone:k.tone,text:k.text})]}),(0,y.jsxs)(`div`,{className:`web-page__actions`,children:[t?.status===`connected`?null:(0,y.jsx)(i,{label:`Reconnect now`,variant:`primary`,onClick:l}),(0,y.jsx)(i,{label:`Settings`,onClick:()=>void e.commands.execute(`ahp.openSettings`)})]})]}),(0,y.jsx)(m,{variant:`h3`,text:`Connection`}),(0,y.jsx)(h,{items:j,columns:2}),E===null&&D===null?null:(0,y.jsx)(m,{variant:`h3`,text:`Daemon`}),D===null?null:(0,y.jsx)(p,{tone:`warning`,message:`The daemon's status is not readable: ${D}`}),M.length===0?null:(0,y.jsx)(h,{items:M,columns:2}),(0,y.jsx)(m,{variant:`h3`,text:`Offers`}),(0,y.jsx)(h,{items:N,columns:2}),(0,y.jsx)(m,{variant:`h3`,text:`Terminals`}),P.length===0?(0,y.jsx)(`p`,{className:`web-note`,children:`No terminals open.`}):(0,y.jsxs)(`table`,{className:`web-runs web-table`,children:[(0,y.jsx)(`thead`,{children:(0,y.jsxs)(`tr`,{children:[(0,y.jsx)(`th`,{children:`Title`}),(0,y.jsx)(`th`,{children:`State`})]})}),(0,y.jsx)(`tbody`,{children:P.map(e=>{let t=e.lifecycle;return(0,y.jsxs)(`tr`,{children:[(0,y.jsx)(`td`,{children:e.title}),(0,y.jsx)(`td`,{children:t.status===`exited`?`Exited${t.exitCode===void 0?``:` (${t.exitCode})`}`:`Running`})]},e.resource)})})]})]})}export{C as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./useI18n-
|
|
1
|
+
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./useI18n-Bfix5MNN.js";var r=t(),i=e();function a({display:e=`text`,locales:t,separator:a=`|`,className:s,style:c}){let{locale:l,locales:u,setLocale:d}=n(),f=t?t.map(e=>u.find(t=>t.locale===e)).filter(Boolean):u;return(0,i.jsx)(`div`,{className:[`oo-locale-toggle`,s].filter(Boolean).join(` `),style:c,role:`group`,children:f.map((t,n)=>(0,i.jsxs)(r.Fragment,{children:[n>0&&a!=null?(0,i.jsx)(`span`,{className:`oo-locale-toggle__sep`,"aria-hidden":`true`,children:a}):null,(0,i.jsx)(`button`,{type:`button`,className:`oo-locale-toggle__item`+(t.locale===l?` oo-locale-toggle__item--active`:``),"aria-pressed":t.locale===l,title:t.name??t.locale,onClick:()=>d(t.locale),children:o(t,e)})]},t.locale))})}function o(e,t){let n=(e.language??e.locale).toUpperCase();return t===`emoji`?e.emoji??n:t===`both`&&e.emoji?`${e.emoji} ${n}`:n}export{a as LocaleToggle};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{n}from"./ScenaProvider-6A3TJumQ.js";import{A as r,D as i,E as a,M as o,N as s,P as c,j as l,k as u}from"./data-
|
|
1
|
+
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{n}from"./ScenaProvider-6A3TJumQ.js";import{A as r,D as i,E as a,M as o,N as s,P as c,j as l,k as u}from"./data-Fkj0LNnG.js";import{t as d}from"./emojis-BOylxma2.js";var f=t(),p=e(),m=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform)?`Cmd+click to open`:`Ctrl+click to open`,h={connection:`Connection`,session:`Session`,terminal:`Terminal`,traffic:`Traffic`};function g(e,t){return t.startsWith(`ahp-terminal:`)?{tip:`Open the terminal`,run:()=>void e.commands.execute(`ahp.openTerminal`,{uri:t})}:(e.store.get(`$/ahp/sessions`)??[]).some(e=>e.resource===t)?{tip:`Open the session`,run:()=>void e.commands.execute(`ahp.openSession`,{resource:t})}:t.startsWith(`file:`)?{tip:`Open the file`,run:()=>void e.commands.execute(`ahp.openFile`,{uri:t})}:/^https?:/i.test(t)?{tip:`Open the page`,run:()=>void window.open(t,`_blank`,`noopener`)}:null}function _(e){if(typeof e==`string`)try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}return JSON.stringify(e,null,2)??String(e)}var v=e=>void navigator.clipboard?.writeText(e).catch(()=>void 0),y=(0,f.memo)(function({entry:e,open:t,onToggle:r}){let i=n(),a=s(e.text).map((e,t)=>{if(e.kind===`text`)return(0,p.jsx)(`span`,{children:e.text},t);let n=g(i,e.text);return n===null?(0,p.jsx)(`span`,{children:e.text},t):(0,p.jsx)(`a`,{className:`web-log__link`,title:`${n.tip} (${m})`,onClick:e=>{(e.ctrlKey||e.metaKey)&&(e.stopPropagation(),n.run())},children:e.text},t)});return(0,p.jsxs)(`div`,{className:`web-log__row`,"data-open":t||void 0,"data-level":e.level,children:[(0,p.jsxs)(`div`,{className:`web-log__line`,role:`button`,tabIndex:0,"aria-expanded":t,onClick:()=>r(e.id),onKeyDown:t=>{t.key===`Enter`&&r(e.id)},children:[(0,p.jsx)(`span`,{className:`web-log__caret`,children:t?d.caretDown:d.caretRight}),(0,p.jsx)(`span`,{className:`web-log__time`,children:u(e.at)}),(0,p.jsx)(`span`,{className:`web-log__level`,children:e.level.toUpperCase()}),(0,p.jsx)(`span`,{className:`web-log__scope`,"data-scope":e.scope,children:(0,p.jsx)(`span`,{children:h[e.scope]})}),(0,p.jsx)(`span`,{className:`web-log__text`,children:a}),t?(0,p.jsx)(`button`,{type:`button`,className:`web-log__icon`,title:`Copy the line`,onClick:t=>{t.stopPropagation(),v(l(e))},children:d.copy}):null]}),t&&e.detail!==void 0?(0,p.jsx)(`pre`,{className:`web-log__detail`,children:_(e.detail)}):null]})});function b(){let e=c(),[t,n]=(0,f.useState)([]),[s,l]=(0,f.useState)(`info`),[u,m]=(0,f.useState)(``),[g,_]=(0,f.useState)(new Set),b=(0,f.useMemo)(()=>r(e,{scopes:t.length===0?i.filter(e=>e!==`traffic`):t,minLevel:t.includes(`traffic`)?`debug`:s,query:u}),[e,t,s,u]),x=(0,f.useCallback)(e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),S=e=>n(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),C=()=>l(a[(a.indexOf(s)+1)%a.length]??`info`),w=(0,f.useRef)(null),T=(0,f.useRef)(!0);return(0,f.useEffect)(()=>{let e=w.current;if(e===null)return;let t=()=>{T.current=e.scrollHeight-e.scrollTop-e.clientHeight<24};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[]),(0,f.useLayoutEffect)(()=>{let e=w.current;e!==null&&T.current&&(e.scrollTop=e.scrollHeight)},[b]),(0,p.jsxs)(`div`,{className:`web-log`,children:[(0,p.jsxs)(`div`,{className:`web-log__bar`,children:[(0,p.jsx)(`button`,{type:`button`,className:`web-log__chip`,"data-on":t.length===0||void 0,onClick:()=>n([]),children:`All`}),i.map(e=>(0,p.jsxs)(`button`,{type:`button`,className:`web-log__chip`,"data-on":t.includes(e)||void 0,onClick:()=>S(e),children:[(0,p.jsx)(`span`,{className:`web-log__dot`,"data-scope":e}),h[e]]},e)),(0,p.jsx)(`span`,{className:`web-log__rule`}),(0,p.jsxs)(`button`,{type:`button`,className:`web-log__chip`,title:`Least severe level shown`,disabled:t.includes(`traffic`),onClick:C,children:[t.includes(`traffic`)?`debug`:s,` and up`]}),(0,p.jsx)(`input`,{className:`web-log__search`,type:`search`,placeholder:`Filter (!word excludes)`,value:u,onChange:e=>m(e.target.value)}),(0,p.jsx)(`button`,{type:`button`,className:`web-log__icon`,title:`Copy the lines shown`,onClick:()=>v(o(b)),children:d.copy})]}),(0,p.jsxs)(`div`,{className:`web-log__list`,ref:w,children:[b.length===0?(0,p.jsxs)(`p`,{className:`web-note`,children:[`Nothing logged`,e.length===0?` yet`:` matches the filter`,`.`]}):null,b.map(e=>(0,p.jsx)(y,{entry:e,open:g.has(e.id),onToggle:x},e.id))]})]})}export{b as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./useStore-BQkzWMs-.js";import{n as r}from"./ScenaProvider-6A3TJumQ.js";import{t as i}from"./useI18n-
|
|
1
|
+
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./useStore-BQkzWMs-.js";import{n as r}from"./ScenaProvider-6A3TJumQ.js";import{t as i}from"./useI18n-Bfix5MNN.js";import{t as a}from"./sigillum-Bev0l9LS.js";import{t as o}from"./Button-_R1oktDz.js";/* empty css */import{_ as s}from"./index-BkzdJo_Y.js";var c=t(),l=e();function u(e){return e&&typeof e==`object`&&`path`in e?e.path:void 0}function d(e,t=``){let r=n(u(e));return u(e)?r??t:(typeof e==`string`?e:void 0)??t}function f({provider:e,pending:t,fire:n,t:r}){let i=d(e.label,e.id);return(0,l.jsx)(o,{label:`${e.icon?`${e.icon} `:``}${r(`auth/providerLabel`,{provider:i,fallback:`Continue with {provider}`})}`,disabled:t,onClick:()=>n(`sigillum.signin`,{providerId:e.id,credentials:{}})})}function p({field:e}){let t=e.label&&typeof e.label==`object`&&`path`in e.label?u(e.label):void 0,r=n(t);return t?(0,l.jsx)(l.Fragment,{children:r??``}):(0,l.jsx)(l.Fragment,{children:typeof e.label==`string`?e.label:``})}function m({providers:e,allowSignup:t=!1,allowForgotPassword:u=!1,onSignup:m,onForgotPassword:_}){let v=r(),y=s(),{t:b}=i(),x=!!n(a.pending),S=n(a.error)??null,C=n(a.challenge)??null,w=(0,c.useMemo)(()=>e?y.providers.filter(t=>e.includes(t.id)):y.providers,[y.providers,e]),T=w.filter(e=>e.kind===`oauth-button`),E=w.filter(e=>e.kind===`form-fields`),D=w.filter(e=>e.kind===`otp`),O=w.filter(e=>e.kind===`magic-link`),k=(0,c.useMemo)(()=>{let e=[],t=new Set;for(let n of E)for(let r of n.fields??[])t.has(r.name)||(t.add(r.name),e.push({field:r,ownerId:n.id}));return e},[E]),[A,j]=(0,c.useState)({});function M(e,t){j(n=>({...n,[e]:t}))}function N(e,t){v.commands.execute(e,t)}function P(e){if(e.preventDefault(),E.length===0)return;let t=E.find(e=>e.id===`password`)??E[0];t&&N(`sigillum.signin`,{providerId:t.id,credentials:A})}let F=k.length>0||D.length>0||O.length>0,I=d((E.find(e=>e.id===`password`)??E[0])?.label,b(`auth/signIn`,`Sign in`));return(0,l.jsxs)(`form`,{className:`porta-form`,onSubmit:P,children:[T.length>0?(0,l.jsx)(`div`,{className:`porta-form__oauth`,children:T.map(e=>(0,l.jsx)(f,{provider:e,pending:x,fire:N,t:b},e.id))}):null,T.length>0&&F?(0,l.jsx)(`div`,{className:`porta-form__divider`,children:`or`}):null,k.length>0?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`porta-form__fields`,children:k.map(({field:e})=>(0,l.jsxs)(`label`,{className:`oo-field`,children:[(0,l.jsx)(`span`,{className:`oo-field__label`,children:e.label&&typeof e.label==`object`&&`t`in e.label?b(e.label.t,{...e.label.args,fallback:`???`}):(0,l.jsx)(p,{field:e})}),(0,l.jsx)(`input`,{className:`oo-input`,type:e.type,name:e.name,autoComplete:e.autoComplete,required:e.required,placeholder:e.placeholder,value:A[e.name]??``,onChange:t=>M(e.name,t.currentTarget.value)})]},e.name))}),(0,l.jsx)(o,{type:`submit`,variant:`primary`,label:I,disabled:x})]}):null,D.map(e=>(0,l.jsx)(h,{provider:e,challenge:C,pending:x,fire:N},e.id)),O.map(e=>(0,l.jsx)(g,{provider:e,challenge:C,pending:x,fire:N},e.id)),(0,l.jsxs)(`div`,{className:`porta-form__footer`,children:[(0,l.jsxs)(`span`,{children:[x?(0,l.jsx)(`span`,{className:`porta-form__pending`,children:`Working…`}):null,S?(0,l.jsx)(`span`,{className:`porta-form__error`,children:S}):null]}),(0,l.jsxs)(`div`,{className:`porta-form__aux`,children:[u?(0,l.jsx)(`button`,{type:`button`,onClick:_,children:b(`auth/forgotPassword`,`Forgot password?`)}):null,t?(0,l.jsx)(`button`,{type:`button`,onClick:m,children:b(`auth/createAccount`,`Create account`)}):null]})]})]})}function h({provider:e,challenge:t,pending:n,fire:r}){let{t:a}=i(`auth`),s=d(e.label,e.id),u=t?.providerId===e.id,f=e.otp?.digits??6,[p,m]=(0,c.useState)(``),[h,g]=(0,c.useState)(``);return(0,l.jsxs)(`div`,{className:`porta-form__two-step`,children:[(0,l.jsxs)(`span`,{className:`porta-form__two-step-label`,children:[e.icon?`${e.icon} `:``,s]}),u?(0,l.jsxs)(`div`,{className:`porta-form__two-step-row`,children:[(0,l.jsx)(_,{digits:f,value:h,onChange:g}),(0,l.jsx)(o,{label:`Verify`,variant:`primary`,disabled:n||h.length!==f,onClick:()=>r(`sigillum.verifyOtp`,{providerId:e.id,code:h})})]}):(0,l.jsxs)(`div`,{className:`porta-form__two-step-row`,children:[(0,l.jsxs)(`label`,{className:`oo-field`,children:[(0,l.jsx)(`span`,{className:`oo-field__label`,children:e.otp?.channel===`sms`?a(`phoneLabel`,`Phone number`):a(`emailLabel`,`Email address`)}),(0,l.jsx)(`input`,{className:`oo-input`,type:e.otp?.channel===`sms`?`tel`:`email`,value:p,placeholder:e.otp?.channel===`sms`?`+1 555 …`:`you@example.com`,onChange:e=>m(e.currentTarget.value)})]}),(0,l.jsx)(o,{label:e.otp?.sendLabel??a(`sendCode`,`Send code`),disabled:n||!p,onClick:()=>r(`sigillum.requestOtp`,{providerId:e.id,value:p})})]})]})}function g({provider:e,challenge:t,pending:n,fire:r}){let{t:a}=i(`auth`),s=d(e.label,e.id),u=t?.providerId===e.id,[f,p]=(0,c.useState)(``);return(0,l.jsxs)(`div`,{className:`porta-form__two-step`,children:[(0,l.jsxs)(`span`,{className:`porta-form__two-step-label`,children:[e.icon?`${e.icon} `:``,s]}),u?(0,l.jsxs)(`span`,{className:`porta-form__pending`,children:[`Check your `,e.magicLink?.channel??`inbox`,` for the link.`]}):(0,l.jsxs)(`div`,{className:`porta-form__two-step-row`,children:[(0,l.jsxs)(`label`,{className:`oo-field`,children:[(0,l.jsx)(`span`,{className:`oo-field__label`,children:e.magicLink?.channel===`sms`?a(`phoneLabel`,`Phone number`):a(`emailLabel`,`Email address`)}),(0,l.jsx)(`input`,{className:`oo-input`,type:e.magicLink?.channel===`sms`?`tel`:`email`,value:f,placeholder:e.magicLink?.channel===`sms`?`+1 555 …`:`you@example.com`,onChange:e=>p(e.currentTarget.value)})]}),(0,l.jsx)(o,{label:e.magicLink?.sendLabel??a(`sendLink`,`Send link`),disabled:n||!f,onClick:()=>r(`sigillum.requestOtp`,{providerId:e.id,value:f})})]})]})}function _({digits:e,value:t,onChange:n}){let r=(0,c.useRef)([]);(0,c.useEffect)(()=>{r.current=r.current.slice(0,e)},[e]);let i=t.padEnd(e,` `).slice(0,e).split(``);function a(t,a){let o=i.slice();o[t]=a.slice(-1)||` `,n(o.join(``).trimEnd()),a&&t+1<e&&r.current[t+1]?.focus()}return(0,l.jsx)(`div`,{className:`porta-form__otp-digits`,children:Array.from({length:e}).map((e,t)=>(0,l.jsx)(`input`,{ref:e=>{r.current[t]=e},className:`porta-form__otp-digit`,inputMode:`numeric`,maxLength:1,value:i[t]?.trim()??``,onChange:e=>a(t,e.currentTarget.value),onKeyDown:e=>{e.key===`Backspace`&&!i[t]?.trim()&&t>0&&r.current[t-1]?.focus()}},t))})}export{m as LoginForm,m as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{n as t}from"./ScenaProvider-6A3TJumQ.js";import{t as n}from"./Spinner-B-iOhBZq.js";import{t as r}from"./Markdown-BaxWPZc1.js";import{t as i}from"./Alert-CHZkhmDE.js";import{n as a,t as o}from"./text-CmjM0Nin.js";import{t as s}from"./clicks-IyfKhKFh.js";var c=e(),l=e=>e.replace(/\/[^/]*$/,``);function u({uri:e}){let u=t(),d=a(e);if(e===void 0)return(0,c.jsx)(i,{tone:`warning`,message:`No file was named.`});let f=(0,c.jsx)(o,{uri:e});return d===null?(0,c.jsxs)(`div`,{className:`web-file`,children:[f,(0,c.jsx)(n,{label:`Reading the file`})]}):`error`in d?(0,c.jsxs)(`div`,{className:`web-file`,children:[f,(0,c.jsx)(i,{tone:`danger`,title:`Not readable`,message:d.error})]}):d.text===null?(0,c.jsxs)(`div`,{className:`web-file`,children:[f,(0,c.jsx)(`p`,{className:`web-note`,children:`This file is not text.`})]}):(0,c.jsxs)(`div`,{className:`web-file`,children:[f,(0,c.jsx)(`div`,{className:`web-file__body`,children:(0,c.jsx)(`div`,{className:`web-file__doc web-md`,onClick:s(u,l(e)),children:(0,c.jsx)(r,{text:d.text})})})]})}export{u as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e,t}from"./jsx-runtime-BguD1OXD.js";import{t as n}from"./react-CybPckBe.js";import{o as r}from"./mount-context-DZgEFVFG.js";import{r as i}from"./Icon-CIQ7doud.js";var a=e({Modal:()=>c}),o=t(),s=n();function c({open:e,defaultOpen:t,title:n,child:a,children:c,onClose:l,dismissable:u=!0}){let d=r(`open`),[f,p]=(0,s.useState)(e??t??!1);(0,s.useEffect)(()=>{e!==void 0&&p(t=>t===e?t:e)},[e]);function m(){u&&(p(!1),d(!1),l?.())}if(!f)return null;let h=a??c;return(0,o.jsx)(`div`,{onClick:m,style:{position:`fixed`,inset:0,background:`rgba(0,0,0,0.4)`,display:`flex`,alignItems:`center`,justifyContent:`center`,zIndex:2e3},children:(0,o.jsxs)(`div`,{onClick:e=>e.stopPropagation(),style:{background:`var(--oo-color-canvas, #fff)`,color:`inherit`,border:`1px solid var(--oo-color-border)`,borderRadius:`var(--oo-radius-sm, 4px)`,padding:16,minWidth:320,maxWidth:`80vw`,maxHeight:`80vh`,overflow:`auto`},children:[n?(0,o.jsxs)(`div`,{style:{fontWeight:600,marginBottom:8,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,o.jsx)(`span`,{children:n}),u?(0,o.jsx)(`button`,{type:`button`,onClick:m,style:{background:`transparent`,border:`none`,cursor:`pointer`,font:`inherit`,color:`inherit`},"aria-label":`Close`,children:i.closePanel}):null]}):null,h]})})}export{a as n,c as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{c as t}from"./useStore-BQkzWMs-.js";import{n}from"./ScenaProvider-6A3TJumQ.js";import{t as r}from"./useStoreLabel-
|
|
1
|
+
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{c as t}from"./useStore-BQkzWMs-.js";import{n}from"./ScenaProvider-6A3TJumQ.js";import{t as r}from"./useStoreLabel-m9cem_OG.js";import{C as i}from"./index-BkzdJo_Y.js";var a=e();function o(e,t=``){let i=n(),a=e?i.components.get(e.component.component)?.props:void 0;return r(e?.props?.title??a?.title,``,e?.dataContext)||t}function s({mount:e,fallback:t,iconClassName:i,titleClassName:o,style:s}){let c=n(),l=e?c.components.get(e.component.component)?.props:void 0,u=r(e?.props?.title??l?.title,``,e?.dataContext)||(t??``),d=e?.props?.icon??l?.icon;return(0,a.jsxs)(`span`,{title:u,style:{display:`inline-flex`,alignItems:`center`,gap:6,minWidth:0,...s},children:[d?(0,a.jsx)(`span`,{className:i,"aria-hidden":!0,children:d}):null,(0,a.jsx)(`span`,{className:o,style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:u})]})}function c(e,n){let r=e.components.get(n.component.component)?.props,a=n.props?.title??r?.title;if(a==null)return n.key;if(typeof a==`string`)return a;if(`t`in a)return i(a.t);let o=t(e.store,n.dataContext,a.path);return o==null?n.key:String(o)}export{c as n,o as r,s as t};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./useStore-BQkzWMs-.js";import{n as r}from"./ScenaProvider-6A3TJumQ.js";import{t as i}from"./Button-_R1oktDz.js";import{f as a,g as o,i as s,w as c,y as l}from"./data-
|
|
1
|
+
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./useStore-BQkzWMs-.js";import{n as r}from"./ScenaProvider-6A3TJumQ.js";import{t as i}from"./Button-_R1oktDz.js";import{f as a,g as o,i as s,w as c,y as l}from"./data-Fkj0LNnG.js";import{a as u,i as d,n as f}from"./words-BknpHIF3.js";import{t as p}from"./emojis-BOylxma2.js";import{t as m}from"./Alert-CHZkhmDE.js";import{a as h,i as g,n as _,o as v,r as y}from"./Composer-DpjCaX5G.js";import{t as b}from"./Text-MPtQvYE-.js";var x=t(),S=e(),C=300;function w({name:e,schema:t,value:n,choices:r,set:i}){let a=t.title||e,o=n??t.default;if(t.type===`boolean`)return(0,S.jsx)(v,{label:a,...t.description===void 0?{}:{title:t.description},value:o===!0,onChange:i});let s=r??(t.enum??[]).map((e,n)=>({value:String(e),label:t.enumLabels?.[n]??String(e)}));if(s.length>0){let e=s.some(e=>e.value===String(o??``))?s:[{value:String(o??``),label:o===void 0?`default`:String(o)},...s];return(0,S.jsx)(y,{label:a,...t.description===void 0?{}:{title:t.description},value:String(o??``),options:e,onChange:e=>i(t.type===`number`?Number(e):e)})}return(0,S.jsx)(h,{label:a,...t.description===void 0?{}:{title:t.description},value:o==null?``:String(o),onChange:e=>i(t.type===`number`?e===``?void 0:Number(e):e)})}function T({provider:e}){let t=r(),v=n(`$/ahp/agents`)??[],T=n(s),[E,D]=(0,x.useState)(e??``),[O,k]=(0,x.useState)(``),[A,j]=(0,x.useState)(``),[M,N]=(0,x.useState)(``),[P,F]=(0,x.useState)({}),[I,L]=(0,x.useState)(null),[R,z]=(0,x.useState)({}),[B,V]=(0,x.useState)(!1),[H,U]=(0,x.useState)(null),W=(0,x.useRef)(null);(0,x.useEffect)(()=>{E===``&&v[0]!==void 0&&D(v[0].provider)},[v,E]),(0,x.useEffect)(()=>{O===``&&T!=null&&k(f(T))},[T,O]),(0,x.useEffect)(()=>_(W.current),[M]);let G=O.trim()===``?void 0:d(O),K=JSON.stringify([E,G,P]);(0,x.useEffect)(()=>{if(E===``)return;let e=!0,t=window.setTimeout(()=>{c(`resolveSessionConfig`,{channel:a,provider:E,...G===void 0?{}:{workingDirectory:G},config:P}).then(t=>{if(!e)return;let n=t;L({schema:n.schema.properties,values:n.values})}).catch(()=>{e&&L(null)})},C);return()=>{e=!1,window.clearTimeout(t)}},[K]);let q=Object.entries(I?.schema??{}).filter(([,e])=>e.enumDynamic===!0).map(([e])=>e).join(`
|
|
2
2
|
`);(0,x.useEffect)(()=>{if(q===``)return;let e=!0;for(let t of q.split(`
|
|
3
|
-
`))c(`sessionConfigCompletions`,{channel:a,provider:E,...G===void 0?{}:{workingDirectory:G},config:P,property:t}).then(n=>{let r=n.items;e&&z(e=>({...e,[t]:r.map(e=>({value:e.value,label:e.label}))}))}).catch(()=>void 0);return()=>{e=!1}},[q,E,G]);let J=v.find(e=>e.provider===E),Y=(0,x.useMemo)(()=>Object.entries(I?.schema??{}).filter(([e,t])=>t.readOnly!==!0&&e!==`model`),[I]),X=I?.schema.model,Z=X===void 0?(J?.models??[]).map(e=>({value:e.id,label:e.name})):R.model??(X.enum??[]).map((e,t)=>({value:String(e),label:X.enumLabels?.[t]??String(e)})),Q=async()=>{if(E===``)return;V(!0),U(null);let e=`${E}:/${u()}`,n=M.trim(),{model:r,...i}=P;try{if(await c(`createSession`,{channel:e,provider:E,...G===void 0?{}:{workingDirectories:[G]},...Object.keys(i).length===0?{}:{config:i}}),await t.commands.execute(`ahp.openSession`,{resource:e}),t.surfaces.close(`session:new`),n!==``){let t=(await l(e))?.defaultChat;if(t!==void 0){let e={text:n,origin:{kind:`user`},...A===``?{}:{model:{id:A}}};o(t,{type:`chat/turnStarted`,turnId:u(),startedAt:new Date().toISOString(),message:e})}}}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}};return v.length===0?(0,S.jsx)(m,{tone:`warning`,message:`This
|
|
3
|
+
`))c(`sessionConfigCompletions`,{channel:a,provider:E,...G===void 0?{}:{workingDirectory:G},config:P,property:t}).then(n=>{let r=n.items;e&&z(e=>({...e,[t]:r.map(e=>({value:e.value,label:e.label}))}))}).catch(()=>void 0);return()=>{e=!1}},[q,E,G]);let J=v.find(e=>e.provider===E),Y=(0,x.useMemo)(()=>Object.entries(I?.schema??{}).filter(([e,t])=>t.readOnly!==!0&&e!==`model`),[I]),X=I?.schema.model,Z=X===void 0?(J?.models??[]).map(e=>({value:e.id,label:e.name})):R.model??(X.enum??[]).map((e,t)=>({value:String(e),label:X.enumLabels?.[t]??String(e)})),Q=async()=>{if(E===``)return;V(!0),U(null);let e=`${E}:/${u()}`,n=M.trim(),{model:r,...i}=P;try{if(await c(`createSession`,{channel:e,provider:E,...G===void 0?{}:{workingDirectories:[G]},...Object.keys(i).length===0?{}:{config:i}}),await t.commands.execute(`ahp.openSession`,{resource:e}),t.surfaces.close(`session:new`),n!==``){let t=(await l(e))?.defaultChat;if(t!==void 0){let e={text:n,origin:{kind:`user`},...A===``?{}:{model:{id:A}}};o(t,{type:`chat/turnStarted`,turnId:u(),startedAt:new Date().toISOString(),message:e})}}}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}};return v.length===0?(0,S.jsx)(m,{tone:`warning`,message:`This server offers no agent.`}):(0,S.jsxs)(`div`,{className:`web-new`,children:[(0,S.jsx)(b,{variant:`h2`,text:`New session`}),J?.description===void 0||J.description===``?null:(0,S.jsx)(`p`,{className:`web-note`,children:J.description}),(0,S.jsxs)(`div`,{className:`web-composer web-new__composer`,children:[(0,S.jsxs)(`div`,{className:`web-composer__chips`,children:[(0,S.jsx)(y,{label:`Agent`,value:E,options:v.map(e=>({value:e.provider,label:e.displayName})),onChange:e=>{D(e),j(``),F({}),z({})}}),Z.length===0?null:(0,S.jsx)(y,{label:`Model`,value:A,options:[{value:``,label:`default`},...Z],onChange:j}),(0,S.jsx)(h,{label:p.folder,title:`A folder on the server's machine`,value:O,placeholder:`/path/to/project`,width:220,onChange:k}),Y.map(([e,t])=>(0,S.jsx)(w,{name:e,schema:t,value:P[e]??I?.values[e],choices:R[e],set:t=>F(n=>({...n,[e]:t}))},e)),I===null&&E!==``?(0,S.jsx)(g,{label:`Reading settings`}):null]}),(0,S.jsx)(`div`,{className:`web-composer__bar`,children:(0,S.jsx)(`textarea`,{ref:W,className:`web-composer__text`,rows:3,value:M,"aria-label":`First message`,placeholder:`What should it do? Enter starts the session; leave it empty to start without a message.`,onChange:e=>N(e.currentTarget.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),Q())}})}),(0,S.jsxs)(`div`,{className:`web-composer__actions`,children:[(0,S.jsx)(`span`,{className:`web-composer__hint`,children:`Enter starts, Shift+Enter breaks the line`}),(0,S.jsx)(i,{label:B?`Starting`:M.trim()===``?`Create`:`Start`,variant:`primary`,size:`sm`,disabled:B||E===``,onClick:()=>void Q()})]})]}),H===null?null:(0,S.jsx)(m,{tone:`danger`,title:`Not created`,message:H})]})}export{T as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./useStore-BQkzWMs-.js";import{n as r}from"./ScenaProvider-6A3TJumQ.js";import{t as i}from"./Button-_R1oktDz.js";import{F as a,I as o,L as s,V as c,c as l,g as u,q as d,w as f,z as p}from"./data-Fkj0LNnG.js";import{n as m,o as h,t as g}from"./words-BknpHIF3.js";import{t as _}from"./emojis-BOylxma2.js";import{t as v}from"./Badge-BDEW5PFb.js";import{t as y}from"./Spinner-B-iOhBZq.js";import{t as b}from"./Markdown-BaxWPZc1.js";import{t as x}from"./Alert-CHZkhmDE.js";import{t as S}from"./Composer-DpjCaX5G.js";import{t as ee}from"./Text-MPtQvYE-.js";import{d as C,u as w}from"./composer-commands-Bpp7NX4E.js";import{t as te}from"./state-KGSq646f.js";import{a as T,n as E,r as D,t as O}from"./turn-BoF7W1h6.js";import{t as k}from"./channel-Cqz_LUS2.js";import{n as A,r as ne,t as re}from"./clicks-IyfKhKFh.js";var j=t(),M=(0,j.createContext)(null),N={picked:[],text:``,other:!1};function P(e){return String(e.kind)===`boolean`?[{id:`yes`,label:`Yes`},{id:`no`,label:`No`}]:`options`in e?e.options:[]}function ie(e){let t=String(e.kind);return t===`single-select`||t===`multi-select`||t===`boolean`}function ae(e){return`allowFreeformInput`in e&&e.allowFreeformInput===!0}function oe(e,t){let n=String(e.kind),r=t.other?t.text.trim():``,i=e=>({state:`submitted`,value:e});if(n===`text`)return t.text.trim()===``?void 0:i({kind:`text`,value:t.text});if(n===`number`||n===`integer`){let e=Number(t.text);return t.text.trim()===``||Number.isNaN(e)?void 0:i({kind:`number`,value:e})}if(n===`boolean`)return t.picked[0]===void 0?void 0:i({kind:`boolean`,value:t.picked[0]===`yes`});if(n===`multi-select`)return t.picked.length===0&&r===``?void 0:i({kind:`selected-many`,value:t.picked,...r===``?{}:{freeformValues:[r]}});let a=t.picked[0];return a===void 0?r===``?void 0:i({kind:`text`,value:r}):i({kind:`selected`,value:a,...r===``?{}:{freeformValues:[r]}})}function se(e){let t=e?.value;if(t===void 0)return N;let n=t.freeformValues?.[0],r=e=>n===void 0?e:{...e,text:n,other:!0};switch(t.kind){case`text`:return{picked:[],text:String(t.value??``),other:!0};case`number`:return{...N,text:String(t.value??``)};case`boolean`:return{...N,picked:[t.value===!0?`yes`:`no`]};case`selected`:return r({...N,picked:[String(t.value)]});case`selected-many`:return r({...N,picked:Array.isArray(t.value)?t.value.map(String):[]});default:return N}}function ce(e,t){let n=t?.value;if(n===void 0)return`Skipped`;let r=t=>P(e).find(e=>e.id===t)?.label??t,i=n.freeformValues??[];switch(n.kind){case`boolean`:return n.value===!0?`Yes`:`No`;case`selected`:return[r(String(n.value)),...i].join(`, `);case`selected-many`:return[...Array.isArray(n.value)?n.value.map(e=>r(String(e))):[],...i].join(`, `);default:return String(n.value??``)}}var F=e(),I=new Map,le=`The agent has a question`;function ue(e){let t=String(e.kind),n=[];return t===`single-select`&&n.push(`Pick one`),t===`multi-select`&&n.push(`Pick any`),t===`text`&&n.push(`Type an answer`),(t===`number`||t===`integer`)&&n.push(`Type a number`),ae(e)&&n.push(`or write your own`),`${n.join(`, `)}${e.required===!0?``:` (optional)`}`}function de({question:e,draft:t,set:n,next:r}){let i=String(e.kind),a=i===`multi-select`,o=e=>{n(a?{...t,picked:t.picked.includes(e)?t.picked.filter(t=>t!==e):[...t.picked,e]}:{...t,picked:[e],other:!1})},s=e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),r())};return ie(e)?(0,F.jsxs)(`div`,{className:`web-ask__options`,role:a?`group`:`radiogroup`,children:[P(e).map((e,n)=>{let r=t.picked.includes(e.id);return(0,F.jsxs)(`button`,{type:`button`,className:`web-ask__option`,role:a?`checkbox`:`radio`,"aria-checked":r,"data-on":r,onClick:()=>o(e.id),children:[(0,F.jsx)(`span`,{className:`web-ask__mark`,"data-many":a,"aria-hidden":`true`}),(0,F.jsxs)(`span`,{className:`web-ask__option-body`,children:[(0,F.jsxs)(`span`,{className:`web-ask__option-label`,children:[(0,F.jsx)(`span`,{className:`web-ask__key`,children:n+1}),e.label,e.recommended===!0?(0,F.jsx)(`span`,{className:`web-ask__tag`,children:`Recommended`}):null]}),e.description===void 0?null:(0,F.jsx)(`span`,{className:`web-ask__option-hint`,children:e.description})]})]},e.id)}),ae(e)?(0,F.jsxs)(`div`,{className:`web-ask__option web-ask__other`,"data-on":t.other,children:[(0,F.jsx)(`button`,{type:`button`,className:`web-ask__mark`,"data-many":a,role:a?`checkbox`:`radio`,"aria-checked":t.other,"aria-label":`Other`,onClick:()=>n({...t,other:!t.other||!a,...a?{}:{picked:[]}})}),(0,F.jsx)(`input`,{className:`web-field`,value:t.text,placeholder:`Other: write your own answer`,onFocus:()=>{t.other||n({...t,other:!0,...a?{}:{picked:[]}})},onChange:e=>n({...t,text:e.target.value,other:!0,...a?{}:{picked:[]}}),onKeyDown:s})]}):null]}):i===`number`||i===`integer`?(0,F.jsx)(`input`,{className:`web-field`,type:`number`,autoFocus:!0,value:t.text,onChange:e=>n({...t,text:e.target.value}),onKeyDown:s}):(0,F.jsx)(`textarea`,{className:`web-field web-ask__text`,rows:3,autoFocus:!0,value:t.text,placeholder:`Your answer`,onChange:e=>n({...t,text:e.target.value}),onKeyDown:s})}function L({request:e,send:t,live:n,response:r}){let a=e.questions??[],[o,s]=(0,j.useState)(()=>Object.fromEntries(a.map(t=>[t.id,se(e.answers?.[t.id])]))),[c,l]=(0,j.useState)(0),[u,d]=(0,j.useState)(()=>I.get(e.id)??null),f=Object.fromEntries(a.flatMap(e=>{let t=oe(e,o[e.id]??N);return t===void 0?[]:[[e.id,t]]})),p=a.filter(e=>e.required===!0&&f[e.id]===void 0),m=e.message!==void 0&&e.message!==le?e.message:void 0,h=n=>{let r={response:n,answers:n===`accept`?f:{}};I.set(e.id,r),d(r),t({type:`chat/inputCompleted`,requestId:e.id,response:n,...n===`accept`&&Object.keys(f).length>0?{answers:f}:{}})},g=r??u?.response;if(g!==void 0||!n){let t=u?.answers??e.answers??{};return(0,F.jsxs)(`div`,{className:`web-ask`,"data-done":`true`,children:[(0,F.jsxs)(`div`,{className:`web-ask__head`,children:[(0,F.jsx)(`span`,{className:`web-ask__title`,children:g===`decline`?`Question declined`:g===void 0?`Question not answered`:`Question answered`}),u!==null&&r===void 0&&n?(0,F.jsx)(`span`,{className:`web-note`,children:`Sending to the agent`}):null]}),g===`accept`?(0,F.jsx)(`dl`,{className:`web-ask__summary`,children:a.map(e=>(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`dt`,{children:e.title??e.message}),(0,F.jsx)(`dd`,{children:ce(e,t[e.id])})]},e.id))}):null]})}let _=a[c],v=c>=a.length-1,y=_===void 0?void 0:f[_.id],x=_!==void 0&&_.required===!0&&y===void 0,S=()=>{x||(v?p.length===0&&h(`accept`):l(c+1))};return(0,F.jsxs)(`div`,{className:`web-ask`,tabIndex:-1,onKeyDown:e=>{let t=e.target;if(_===void 0||t.closest(`input, textarea`)!==null||!/^[1-9]$/.test(e.key))return;let n=P(_)[Number(e.key)-1];if(n===void 0)return;let r=o[_.id]??N,i=String(_.kind)===`multi-select`,a=i?r.picked.includes(n.id)?r.picked.filter(e=>e!==n.id):[...r.picked,n.id]:[n.id];s({...o,[_.id]:{...r,picked:a,...i?{}:{other:!1}}})},children:[(0,F.jsxs)(`div`,{className:`web-ask__head`,children:[(0,F.jsxs)(`span`,{className:`web-ask__title`,children:[(0,F.jsx)(`span`,{className:`web-ask__icon`,"aria-hidden":`true`,children:`?`}),m===void 0?`The agent asks`:`The agent asks:`]}),a.length>1?(0,F.jsxs)(`span`,{className:`web-ask__steps`,"aria-label":`Question ${c+1} of ${a.length}`,children:[a.map((e,t)=>(0,F.jsx)(`button`,{type:`button`,className:`web-ask__step`,"data-here":t===c,"data-done":f[e.id]!==void 0,title:e.title??e.message,onClick:()=>l(t)},e.id)),(0,F.jsxs)(`span`,{className:`web-ask__count`,children:[c+1,` of `,a.length]})]}):null]}),m===void 0?null:(0,F.jsx)(`div`,{className:`web-ask__message`,children:(0,F.jsx)(b,{text:m})}),e.url===void 0?null:(0,F.jsx)(`a`,{className:`web-link`,href:e.url,target:`_blank`,rel:`noreferrer`,children:e.url}),_===void 0?null:(0,F.jsxs)(`section`,{className:`web-ask__question`,children:[_.title===void 0?null:(0,F.jsx)(`span`,{className:`web-ask__chip`,children:_.title}),(0,F.jsx)(`div`,{className:`web-ask__text-line`,children:_.message}),(0,F.jsx)(`div`,{className:`web-ask__hint`,children:ue(_)}),(0,F.jsx)(de,{question:_,draft:o[_.id]??N,set:e=>s({...o,[_.id]:e}),next:S})]},_.id),(0,F.jsxs)(`div`,{className:`web-ask__actions`,children:[(0,F.jsx)(i,{label:`Decline`,size:`sm`,onClick:()=>h(`decline`)}),(0,F.jsx)(`span`,{className:`web-ask__spacer`}),c>0?(0,F.jsx)(i,{label:`Back`,size:`sm`,onClick:()=>l(c-1)}):null,v?(0,F.jsx)(i,{label:`Answer`,variant:`primary`,size:`sm`,disabled:p.length>0,onClick:()=>h(`accept`)}):(0,F.jsx)(i,{label:`Next`,variant:`primary`,size:`sm`,disabled:x,onClick:S})]}),v&&p.length>0&&!x?(0,F.jsx)(`p`,{className:`web-note`,children:p.length===1?`One question still needs an answer.`:`${p.length} questions still need an answer.`}):null]})}var fe=[`command`,`file_path`,`path`,`pattern`,`query`,`url`,`description`],pe=`ahpd.startedAt`,me=`ahpd.durationMs`;function R(e){let t=`toolInput`in e?e.toolInput:void 0;if(typeof t==`string`&&t.trim()!==``)try{return JSON.parse(t)}catch{return t}}function he(e){let t=R(e);return t===void 0?``:typeof t==`string`?t:JSON.stringify(t,null,2)}function ge(e){let t=R(e);if(typeof t!=`object`||!t)return``;let n=t;for(let e of fe){let t=n[e];if(typeof t==`string`&&t.trim()!==``)return t.trim().split(`
|
|
2
|
+
`)[0]}return``}function _e(e){let t=R(e);if(typeof t!=`object`||!t)return;let n=t;for(let e of[`file_path`,`notebook_path`,`path`]){let t=n[e];if(typeof t==`string`&&t.startsWith(`/`))return`file://${t}`}}function ve(e){let t=(e.status===`completed`||e.status===`pending-result-confirmation`?h(e.pastTenseMessage):``)||h(`invocationMessage`in e?e.invocationMessage:void 0)||e.intention||``,n=e.displayName||e.toolName;if(t!==``&&t!==n&&t!==e.toolName)return t;let r=ge(e);return r===``?n:`${n} ${r}`}function z(e){let t=e._meta?.[me];return typeof t==`number`?t:void 0}function ye(e){let t=e._meta?.[pe];if(typeof t!=`string`)return;let n=Date.parse(t);return Number.isNaN(n)?void 0:n}var be={Bash:`terminal`,terminal:`terminal`,shell:`terminal`,Read:`read`,read_file:`read`,NotebookRead:`read`,Glob:`search`,Grep:`search`,WebSearch:`search`,search:`search`,Edit:`edit`,MultiEdit:`edit`,Write:`edit`,NotebookEdit:`edit`,write_file:`edit`,edit_file:`edit`,Task:`subagent`,Agent:`subagent`,WebFetch:`web`,fetch:`web`};function xe(e){let t=e._meta?.toolKind;if(t===`terminal`||t===`read`||t===`search`||t===`subagent`)return t;let n=be[e.toolName];if(n!==void 0)return n;let r=`content`in e&&Array.isArray(e.content)?e.content:[];return r.some(e=>e.type===`fileEdit`)?`edit`:r.some(e=>e.type===`terminal`)?`terminal`:`other`}function Se(e){switch(e.status){case`streaming`:return`preparing`;case`pending-confirmation`:return`approval`;case`running`:return`running`;case`auth-required`:return`sign-in`;case`pending-result-confirmation`:return`review`;case`completed`:return e.success?`done`:`failed`;case`cancelled`:return`cancelled`;default:return`running`}}var Ce=e=>e.replace(/\u001b\[[0-9;?]*[ -/]*[@-~]/g,``);function we(e){let t=`content`in e&&Array.isArray(e.content)?e.content:[],n=[];for(let e of t){let t=String(e.type??``);if(t===`text`&&typeof e.text==`string`&&e.text!==``)n.push({kind:`text`,text:e.text});else if(t===`terminal`){let t=e.result;n.push({kind:`terminal`,title:String(e.title??`Terminal`),text:Ce(t?.preview??``),...t?.exitCode===void 0?{}:{exitCode:t.exitCode},truncated:t?.truncated===!0})}else if(t===`fileEdit`){let t=e.before,r=e.after,i=r?.uri??t?.uri??``,a=e.diff;n.push({kind:`file`,path:m(i),file:i,...t?.content?.uri===void 0?{}:{before:t.content.uri},...r?.content?.uri===void 0?{}:{after:r.content.uri},...a?.added===void 0?{}:{added:a.added},...a?.removed===void 0?{}:{removed:a.removed}})}else t===`subagent`?n.push({kind:`note`,text:`Ran ${String(e.agentName??e.title??`a subagent`)}`}):t===`resource`&&n.push({kind:`note`,text:`Read ${m(String(e.uri??``))}`})}if(e.status===`completed`||e.status===`pending-result-confirmation`){let t=e.error?.message.trim(),r=n.some(e=>(e.kind===`text`||e.kind===`terminal`)&&t!==void 0&&e.text.includes(t));t!==void 0&&t!==``&&!r&&n.push({kind:`note`,text:t})}if(e.status===`cancelled`){let t=h(e.reasonMessage)||{denied:`Denied.`,skipped:`Skipped.`,"result-denied":`Result rejected.`}[String(e.reason)]||`Cancelled.`;n.push({kind:`note`,text:t})}return n}var Te=/\[([^\]]+)\]\(([^)\s]+)\)|`([^`]+)`/g;function Ee(e,t){let n=[],r=0;for(let t of e.matchAll(Te))t.index>r&&n.push({text:e.slice(r,t.index)}),t[1]===void 0?n.push({text:t[3],href:t[3],code:!0}):n.push({text:t[1],href:t[2]}),r=t.index+t[0].length;if(n.length>0)return r<e.length&&n.push({text:e.slice(r)}),n;let i=t?.replace(/^file:\/\//,``),a=i===void 0?-1:e.indexOf(i);return i===void 0||a<0?[{text:e}]:[...a>0?[{text:e.slice(0,a)}]:[],{text:i,href:t},...a+i.length<e.length?[{text:e.slice(a+i.length)}]:[]]}var B=`pending-confirmation`,De=`pending-result-confirmation`,V={preparing:{glyph:_.pending,label:`Preparing`},approval:{glyph:_.waiting,label:`Needs approval`},running:{glyph:_.running,label:`Running`},"sign-in":{glyph:_.waiting,label:`Needs sign-in`},review:{glyph:_.waiting,label:`Review result`},done:{glyph:_.check,label:`Done`},failed:{glyph:_.cross,label:`Failed`},cancelled:{glyph:_.cross,label:`Cancelled`}};function Oe(){return re(r(),(0,j.useContext)(M))}var ke={terminal:_.terminal,read:_.read,search:_.search,edit:_.edit,subagent:_.subagent,web:_.web,other:_.dot};function Ae({line:e,file:t}){let n=r(),i=(0,j.useContext)(M);return(0,F.jsx)(`span`,{className:`web-tool__line`,children:Ee(e,t).map((e,t)=>{let r=e.href===void 0?null:e.code===!0?A(e.href,i):ne(e.href,i);if(r===null)return e.code===!0?(0,F.jsx)(`code`,{children:e.text},t):(0,F.jsx)(`span`,{children:e.text},t);let a=e=>{e.stopPropagation(),e.preventDefault(),n.commands.execute(`ahp.openFile`,{uri:r.uri,line:r.line,end:r.end})};return(0,F.jsx)(`span`,{role:`link`,tabIndex:0,className:`web-tool__ref`,title:`Open ${m(r.uri)}`,onClick:a,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&a(e)},children:e.text},t)})})}function H({title:e,text:t}){let[n,r]=(0,j.useState)(!1);return(0,F.jsxs)(`section`,{className:`web-tool__block`,children:[(0,F.jsxs)(`div`,{className:`web-tool__block-head`,children:[(0,F.jsx)(`span`,{children:e}),(0,F.jsx)(`button`,{type:`button`,className:`web-tool__copy`,onClick:()=>{navigator.clipboard?.writeText(t).then(()=>{r(!0),window.setTimeout(()=>r(!1),1200)}).catch(()=>void 0)},children:n?`Copied`:`Copy`})]}),(0,F.jsx)(`pre`,{className:`web-tool__pre`,children:t})]})}function je({out:e}){let t=r();switch(e.kind){case`text`:return(0,F.jsx)(H,{title:`Output`,text:e.text});case`terminal`:return(0,F.jsx)(H,{title:`${e.title}${e.exitCode===void 0?``:` \u{00B7} exit ${e.exitCode}`}${e.truncated?` · cut short`:``}`,text:e.text===``?`No output.`:e.text});case`file`:return(0,F.jsxs)(`p`,{className:`web-tool__file`,children:[(0,F.jsx)(`button`,{type:`button`,className:`web-link`,title:e.before===void 0&&e.after===void 0?`Open the file`:`Open the change`,onClick:()=>void(e.before===void 0&&e.after===void 0?t.commands.execute(`ahp.openFile`,{uri:e.file}):t.commands.execute(`ahp.openDiff`,{file:e.file,...e.before===void 0?{}:{before:e.before},...e.after===void 0?{}:{after:e.after}})),children:e.path}),e.added===void 0?null:(0,F.jsxs)(`span`,{className:`web-diff--add`,children:[`+`,e.added]}),e.removed===void 0?null:(0,F.jsxs)(`span`,{className:`web-diff--remove`,children:[`-`,e.removed]})]});case`note`:return(0,F.jsx)(`p`,{className:`web-note`,children:e.text})}}function U({call:e,send:t,live:n,turnId:a}){let o=Se(e),s=n&&(o===`approval`||o===`review`||o===`sign-in`),[c,l]=(0,j.useState)(!1),u=c||s,d=z(e),f=he(e),p=we(e),h=e.displayName||e.toolName,_=e.status===B?e.riskAssessment:void 0,v=_e(e),y=r();return(0,F.jsxs)(`div`,{className:`web-tool`,"data-outcome":o,children:[(0,F.jsxs)(`button`,{type:`button`,className:`web-tool__row`,"aria-expanded":u,title:V[o].label,onClick:()=>l(!c),children:[(0,F.jsx)(`span`,{className:`web-tool__mark`,"aria-label":V[o].label,children:ke[xe(e)]}),(0,F.jsx)(Ae,{line:ve(e),file:v}),o===`failed`||o===`cancelled`?(0,F.jsx)(`span`,{className:`web-tool__state`,children:V[o].label}):null,d===void 0||d<1e3?null:(0,F.jsx)(`span`,{className:`web-tool__time`,children:g(d)})]}),u?(0,F.jsxs)(`div`,{className:`web-tool__body`,children:[(0,F.jsxs)(`dl`,{className:`web-tool__facts`,children:[(0,F.jsx)(`dt`,{children:`Tool`}),(0,F.jsxs)(`dd`,{children:[(0,F.jsx)(`code`,{children:e.toolName}),h===e.toolName?null:` (${h})`]}),(0,F.jsx)(`dt`,{children:`Status`}),(0,F.jsx)(`dd`,{children:V[o].label}),v===void 0?null:(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`dt`,{children:`File`}),(0,F.jsx)(`dd`,{children:(0,F.jsx)(`button`,{type:`button`,className:`web-link`,onClick:()=>void y.commands.execute(`ahp.openFile`,{uri:v}),children:m(v)})})]}),e.intention===void 0?null:(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`dt`,{children:`Why`}),(0,F.jsx)(`dd`,{children:e.intention})]}),_===void 0||_.status!==`complete`?null:(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`dt`,{children:`Risk`}),(0,F.jsx)(`dd`,{children:`${_.safety}/10 safe \u{00B7} ${_.reason}`})]})]}),f===``?null:(0,F.jsx)(H,{title:`Arguments`,text:f}),p.map((e,t)=>(0,F.jsx)(je,{out:e},t)),n&&e.status===B?(0,F.jsx)(Me,{call:e,send:t,turnId:a}):null,n&&e.status===De?(0,F.jsxs)(`div`,{className:`web-tool__actions`,children:[(0,F.jsx)(i,{label:`Accept result`,variant:`primary`,onClick:()=>t({type:`chat/toolCallResultConfirmed`,turnId:a,toolCallId:e.toolCallId,approved:!0})}),(0,F.jsx)(i,{label:`Reject`,onClick:()=>t({type:`chat/toolCallResultConfirmed`,turnId:a,toolCallId:e.toolCallId,approved:!1})})]}):null]}):null]})}function W({text:e,running:t}){let[n,r]=(0,j.useState)(!1),i=e.replace(/[*_`#>]/g,``).replace(/\s+/g,` `).trim();return(0,F.jsxs)(`div`,{className:`web-tool`,"data-outcome":t?`running`:`thought`,children:[(0,F.jsxs)(`button`,{type:`button`,className:`web-tool__row`,"aria-expanded":n,onClick:()=>r(!n),children:[(0,F.jsx)(`span`,{className:`web-tool__mark`,"aria-hidden":`true`,children:_.thinking}),(0,F.jsxs)(`span`,{className:`web-tool__line`,children:[`Thinking: `,i]})]}),n?(0,F.jsx)(`div`,{className:`web-tool__body web-md`,children:(0,F.jsx)(b,{text:e})}):null]})}function Me({call:e,send:t,turnId:n}){let r=r=>t({type:`chat/toolCallConfirmed`,turnId:n,toolCallId:e.toolCallId,approved:!0,confirmed:`user-action`,...r===void 0?{}:{selectedOptionId:r}}),a=r=>t({type:`chat/toolCallConfirmed`,turnId:n,toolCallId:e.toolCallId,approved:!1,reason:`denied`,...r===void 0?{}:{selectedOptionId:r}}),o=e.status===B?e.options??[]:[],s=e.status===B?h(e.confirmationTitle):``;return(0,F.jsxs)(`div`,{className:`web-tool__confirm`,children:[s===``?null:(0,F.jsx)(b,{text:s}),(0,F.jsx)(`div`,{className:`web-tool__actions`,children:o.length===0?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(i,{label:`Approve`,variant:`primary`,onClick:()=>r()}),(0,F.jsx)(i,{label:`Deny`,onClick:()=>a()})]}):o.map(e=>(0,F.jsx)(i,{label:e.label,...e.kind===`approve`?{variant:`primary`}:{},onClick:()=>e.kind===`approve`?r(e.id):a(e.id)},e.id))})]})}var Ne=(0,j.memo)(function({part:e,send:t,live:n,turnId:i}){let a=Oe(),o=r();switch(String(e.kind)){case`markdown`:return`content`in e?(0,F.jsx)(`div`,{className:`web-md`,onClick:a,children:(0,F.jsx)(b,{text:e.content})}):null;case`contentRef`:{let t=`uri`in e?String(e.uri):``;return(0,F.jsx)(`button`,{type:`button`,className:`web-chip`,onClick:()=>void o.commands.execute(`ahp.openFile`,{uri:t}),children:`${_.file} ${m(t).split(`/`).pop()??t}`})}case`reasoning`:return`content`in e&&e.content!==``?(0,F.jsx)(W,{text:e.content,running:!1}):null;case`toolCall`:return`toolCall`in e?(0,F.jsx)(U,{call:e.toolCall,send:t,live:n,turnId:i}):null;case`inputRequest`:return`request`in e?(0,F.jsx)(L,{request:e.request,send:t,live:n,response:`response`in e&&e.response!==void 0?String(e.response):void 0}):null;case`error`:return(0,F.jsx)(x,{tone:`danger`,message:`error`in e&&e.error.message!==``?e.error.message:`The agent reported an error.`});case`systemNotification`:return(0,F.jsx)(`p`,{className:`web-note`,children:`content`in e?h(e.content):``});default:return null}}),Pe=new Set([`completed`,`cancelled`]),Fe=new Set([`pending-confirmation`,`pending-result-confirmation`,`auth-required`]);function Ie(e){let t=String(e.kind);if(t===`toolCall`&&`toolCall`in e)return{kind:`tool`,key:e.toolCall.toolCallId,call:e.toolCall};if(t===`reasoning`&&`content`in e){let t=String(e.content);return t.trim()===``?void 0:{kind:`reasoning`,key:`id`in e?String(e.id):``,text:t}}if(!(t===`markdown`&&`content`in e&&String(e.content).trim()===``))return null}function Le(e,t,n){return e.kind===`tool`?n.ended||Pe.has(String(e.call.status)):!(t&&n.live)}function G(e){return e.kind===`tool`&&Fe.has(String(e.call.status))}function Re(e){return e.kind===`tool`&&`success`in e.call&&e.call.success===!1}function ze(e,t,n){let r=[],i=[],a=[],o=e=>{let n=a[0];if(n!==void 0){let o={kind:`activity`,id:`act:${n.key}`,steps:a,live:e&&t,ended:!t};r.push(o),i.push(o)}a=[]};e.forEach((e,t)=>{let n=Ie(e);if(n!==void 0){if(n!==null){a.push(n);return}o(!1),r.push({kind:`part`,part:e,index:t})}}),o(!0);let s=i.length===1?i[0]:void 0;return s!==void 0&&!t&&n!==void 0&&(s.turnMs=n),r}function Be(e){let t=1/0,n=-1/0;for(let r of e){if(r.kind!==`tool`)continue;let e=ye(r.call),i=z(r.call);if(e===void 0||i===void 0)return;t=Math.min(t,e),n=Math.max(n,e+i)}return n>=t?n-t:void 0}var K=(e,t)=>e===void 0||e<1e3?void 0:t(e);function Ve(e,t){let n=[];if(e.done>0){n.push({text:e.done===1?`Completed 1 step`:`Completed ${e.done} steps`}),e.failed>0&&n.push({text:` (${e.failed} failed)`,failed:!0});let r=K(e.took,t);r!==void 0&&n.push({text:` in ${r}`})}let r=e.doing;if(r!==void 0){let e;if(r.what===`thinking`)e=`Thinking`;else{let n=`${r.what===`waiting`?`Waiting on`:`Working on`} ${r.name}`,i=K(r.for,t);e=i===void 0?n:`${n} for ${i}`}n.push({text:n.length>0?` \u{00B7} ${e}`:e})}return n}var q=new Map,J=new Map;function Y(e,t){t?q.has(e)||q.set(e,Date.now()):q.has(e)&&!J.has(e)&&J.set(e,Date.now())}function X(e,t){let n=q.get(e);return n===void 0?void 0:(J.get(e)??t)-n}function He(e,t){if(e.kind===`reasoning`)return{what:`thinking`};let n=e.call.displayName||e.call.toolName,r=X(e.key,t);return{what:G(e)?`waiting`:`working`,name:n,...r===void 0?{}:{for:r}}}function Ue({group:e,send:t,turnId:n}){let[r,i]=(0,j.useState)(!1),[a,o]=(0,j.useState)(()=>Date.now()),s=e.steps.length-1,c=e.steps.map((t,n)=>Le(t,n===s,e)),l=c.lastIndexOf(!1),u=l<0?void 0:e.steps[l];Y(e.id,e.live),e.steps.forEach((e,t)=>Y(e.key,!c[t])),(0,j.useEffect)(()=>{if(u===void 0)return;let e=window.setInterval(()=>o(Date.now()),1e3);return()=>window.clearInterval(e)},[u?.key]);let d=e.live&&e.steps.some(G),f=r||d,p=c.filter(Boolean).length,m=u===void 0?a:q.get(u.key),h=q.get(e.id),v=e.live?h===void 0||m===void 0?void 0:m-h:Be(e.steps)??X(e.id,a)??e.turnMs,y=Ve({done:p,failed:e.steps.filter(Re).length,...v===void 0?{}:{took:v},...u===void 0?{}:{doing:He(u,a)}},g);return(0,F.jsxs)(`div`,{className:`web-activity`,"data-live":u!==void 0,children:[(0,F.jsxs)(`button`,{type:`button`,className:`web-activity__line`,"aria-expanded":f,onClick:()=>i(!r),children:[(0,F.jsx)(`span`,{children:y.map((e,t)=>e.failed?(0,F.jsx)(`span`,{className:`web-activity__failed`,children:e.text},t):e.text)}),(0,F.jsx)(`span`,{className:`web-activity__chev`,"aria-hidden":`true`,children:f?_.caretDown:_.caretRight})]}),f?(0,F.jsx)(`div`,{className:`web-activity__steps`,children:e.steps.map((r,i)=>r.kind===`tool`?(0,F.jsx)(U,{call:r.call,send:t,live:!e.ended,turnId:n},r.key):(0,F.jsx)(W,{text:r.text,running:!c[i]},r.key))}):null]})}var Z={cancelled:`Stopped`,error:`Ended with an error`};function We(e){let[t,n]=(0,j.useState)(()=>Date.now());return(0,j.useEffect)(()=>{if(!e)return;let t=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(t)},[e]),t}function Ge({text:e}){let[t,n]=(0,j.useState)(!1);return(0,F.jsx)(`button`,{type:`button`,className:`web-turn__copy`,title:t?`Copied`:`Copy`,"aria-label":t?`Copied`:`Copy the reply`,onClick:()=>{navigator.clipboard?.writeText(e).then(()=>{n(!0),window.setTimeout(()=>n(!1),1200)}).catch(()=>void 0)},children:t?_.check:_.copy})}function Ke({facts:e,state:t,live:n,text:r}){let i=We(n),a=n?e.startedAt===void 0?void 0:i-e.startedAt:e.duration,o=[];return e.startedAt!==void 0&&o.push(T(e.startedAt)),a!==void 0&&o.push(n?`${g(a)} so far`:g(a)),(e.input!==void 0||e.output!==void 0)&&o.push(`\u{2191}${D(e.input??0)} \u{2193}${D(e.output??0)}`),e.cacheRead!==void 0&&e.cacheRead>0&&o.push(`${D(e.cacheRead)} cached`),e.model!==void 0&&o.push(e.model),e.tools>0&&o.push(e.tools===1?`1 tool call`:`${e.tools} tool calls`),(0,F.jsxs)(`div`,{className:`web-turn__facts`,children:[n||r===``?null:(0,F.jsx)(Ge,{text:r}),o.join(` · `),t===void 0||Z[t]===void 0?null:(0,F.jsx)(`span`,{className:`web-turn__ended`,"data-state":t,children:Z[t]})]})}var Q=[];function qe({attachments:e}){let t=r();return(0,F.jsx)(`div`,{className:`web-turn__attached`,children:e.map((e,n)=>{let r=e,i=typeof r.uri==`string`&&r.displayKind!==`directory`?r.uri:void 0,a=C(e),o=(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`web-attachment__icon`,children:w(e)}),(0,F.jsx)(`span`,{className:`web-attachment__label`,children:a})]});return i===void 0?(0,F.jsx)(`span`,{className:`web-attachment`,title:a,children:o},n):(0,F.jsx)(`button`,{type:`button`,className:`web-attachment`,title:`Open ${a}`,onClick:()=>void t.commands.execute(`ahp.openFile`,{uri:i}),children:o},n)})})}var $=(0,j.memo)(function({turn:e,live:t,send:n,open:r=Q}){let i=`state`in e?String(e.state):void 0,a=e.responseParts;return(0,F.jsxs)(`article`,{className:`web-turn`,children:[(0,F.jsxs)(`div`,{className:`web-turn__ask`,children:[e.message.text,e.message.attachments===void 0||e.message.attachments.length===0?null:(0,F.jsx)(qe,{attachments:e.message.attachments})]}),(0,F.jsxs)(`div`,{className:`web-turn__answer`,children:[ze(a,t,O(e).duration).map(r=>r.kind===`activity`?(0,F.jsx)(Ue,{group:r,send:n,turnId:e.id},r.id):(0,F.jsx)(Ne,{part:r.part,send:n,live:t,turnId:e.id},r.index)),t?r.map(e=>(0,F.jsx)(L,{request:e,send:n,live:!0,response:void 0},e.id)):null,t&&a.length===0?(0,F.jsx)(y,{label:`Working`}):null]}),(0,F.jsx)(Ke,{facts:O(e),...i===void 0?{}:{state:i},live:t,text:E(e)})]})});function Je({chatUri:e,cursor:t}){let[n,r]=(0,j.useState)(!1),[a,o]=(0,j.useState)(null);return(0,F.jsxs)(`div`,{className:`web-chat__older`,children:[(0,F.jsx)(i,{label:n?`Loading`:`Load older turns`,disabled:n,onClick:()=>{r(!0),o(null),f(`fetchTurns`,{channel:e,cursor:t}).catch(e=>o(e instanceof Error?e.message:String(e))).finally(()=>r(!1))}}),a===null?null:(0,F.jsx)(`span`,{className:`web-note`,children:a})]})}function Ye(e,t,n){let r=(0,j.useRef)({turn:void 0,requests:new Map});if(r.current.turn!==n?.id&&(r.current={turn:n?.id,requests:new Map}),n===void 0)return Q;for(let n of e??[])String(n.kind)===`chatInput`&&n.chat===t&&`request`in n&&r.current.requests.set(n.id,n.request);let i=new Set(n.responseParts.flatMap(e=>`request`in e?[e.request.id]:[])),a=[...r.current.requests.values()].filter(e=>!i.has(e.id));return a.length===0?Q:a}function Xe({resource:e}){let t=r(),i=n(l)?.find(t=>t.resource===e),f=k(e,d),m=f.state?.defaultChat??i?.defaultChat,h=k(m,c),g=(0,j.useRef)(null),_=(0,j.useRef)(!0),b=(0,j.useCallback)(e=>{m!==void 0&&u(m,e)},[m]),C=h.state?.turns.length??0,w=Ye(f.state?.inputNeeded,m,h.state?.activeTurn),T=(h.state?.activeTurn?.responseParts??[]).reduce((e,t)=>e+1+(`content`in t&&typeof t.content==`string`?t.content.length:0),0);(0,j.useEffect)(()=>{_.current&&g.current?.scrollIntoView({block:`end`})},[C,T]),(0,j.useEffect)(()=>{e!==void 0&&t.store.get(`$/ahp/activeSession`)===void 0&&t.store.set(te,e)},[t,e]);let E=i!==void 0&&!p(i.status);if((0,j.useEffect)(()=>{E&&e!==void 0&&u(e,{type:`session/isReadChanged`,isRead:!0})},[E,e,C]),i===void 0)return(0,F.jsx)(x,{tone:`warning`,message:`This session is gone.`});let D=s(i.status),O=String(f.state?.lifecycle??`ready`),A=h.state?.activity??i.activity;return(0,F.jsxs)(`div`,{className:`web-chat`,children:[(0,F.jsx)(`header`,{className:`web-chat__head`,children:(0,F.jsxs)(`div`,{className:`web-chat__title`,children:[(0,F.jsx)(ee,{variant:`h2`,text:i.title===``?`Untitled`:i.title}),(0,F.jsx)(v,{tone:o[D],text:a[D]}),A===void 0||A===``?null:(0,F.jsx)(`span`,{className:`web-note`,children:A})]})}),(0,F.jsxs)(`div`,{className:`web-chat__turns`,onScroll:e=>{let t=e.currentTarget;_.current=t.scrollHeight-t.scrollTop-t.clientHeight<48},children:[O===`creating`?(0,F.jsx)(y,{label:`Starting the session`}):null,O===`failed`?(0,F.jsx)(x,{tone:`danger`,title:`The session did not start`,message:f.state?.creationError?.message??`No reason given.`}):null,f.error===null?null:(0,F.jsx)(x,{tone:`danger`,title:`Session not readable`,message:f.error}),h.error===null?null:(0,F.jsx)(x,{tone:`danger`,title:`Chat not readable`,message:h.error}),m!==void 0&&h.state===void 0&&h.error===null?(0,F.jsx)(y,{label:`Reading the chat`}):null,m===void 0||h.state?.turnsNextCursor===void 0?null:(0,F.jsx)(Je,{chatUri:m,cursor:h.state.turnsNextCursor}),(0,F.jsxs)(M.Provider,{value:i.workingDirectories?.[0]??null,children:[h.state?.turns.map(e=>(0,F.jsx)($,{turn:e,live:!1,send:b},e.id)),h.state?.activeTurn===void 0?null:(0,F.jsx)($,{turn:h.state.activeTurn,live:!0,send:b,open:w})]}),h.state!==void 0&&C===0&&h.state.activeTurn===void 0?(0,F.jsx)(`p`,{className:`web-note`,children:`No messages yet.`}):null,(0,F.jsx)(`div`,{ref:g})]}),h.state===void 0||m===void 0?null:(0,F.jsx)(S,{chatUri:m,activeId:h.state.activeTurn?.id,activeStart:h.state.activeTurn?.startedAt,queued:h.state.queuedMessages,steering:h.state.steeringMessage,draft:h.state.draft,lastModel:h.state.turns.at(-1)?.message.model?.id,config:f.state?.config,summary:i,send:b})]})}export{Xe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./useStore-BQkzWMs-.js";import{n as r}from"./ScenaProvider-6A3TJumQ.js";import{t as i}from"./Button-_R1oktDz.js";import{G as a,d as o,n as s,w as c}from"./data-
|
|
1
|
+
import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./useStore-BQkzWMs-.js";import{n as r}from"./ScenaProvider-6A3TJumQ.js";import{t as i}from"./Button-_R1oktDz.js";import{G as a,d as o,n as s,w as c}from"./data-Fkj0LNnG.js";import{n as l,t as u}from"./words-BknpHIF3.js";import{t as d}from"./Badge-BDEW5PFb.js";import{t as f}from"./Spinner-B-iOhBZq.js";import{t as p}from"./Markdown-BaxWPZc1.js";import{t as m}from"./Alert-CHZkhmDE.js";import{t as h}from"./Text-MPtQvYE-.js";import{t as g}from"./DetailList-Yalgw0YM.js";import{c as _,d as v,f as y,i as b,l as x,u as S}from"./index-BkzdJo_Y.js";import{r as C}from"./turn-BoF7W1h6.js";import{t as w}from"./channel-Cqz_LUS2.js";import{a as T,i as E,r as D,t as O}from"./actions-BQzD99j0.js";var k=t(),A=e(),j={running:{tone:`info`,text:`Running`},failed:{tone:`danger`,text:`Last run failed`},on:{tone:`success`,text:`On`},off:{tone:`default`,text:`Off`}},M={pending:{tone:`default`,text:`Waiting`},running:{tone:`info`,text:`Running`},completed:{tone:`success`,text:`Done`},failed:{tone:`danger`,text:`Failed`},cancelled:{tone:`default`,text:`Stopped`}};function N(e){let t=e;if(String(t.kind)!==`trigger`)return`By hand`;let n=t.scheduledFor===void 0?``:` for ${v(t.scheduledFor)}`;return`${t.catchUp===!0?`Catch-up`:`Scheduled`}${n}`}var P=e=>(0,A.jsx)(`span`,{className:`web-lines`,children:e.map((e,t)=>(0,A.jsx)(`span`,{children:e},t))});function F(e){let{definition:t}=e,n=t.session,r=n.workingDirectories??[],i=t.triggers.filter(e=>`schedule`in e),a=t.triggers.filter(e=>!(`schedule`in e)),o=(t.disableConditions??[]).map(e=>`max`in e?`After ${e.max} runs`:`After ${v(e.date)}`),s=[{label:`Agent`,value:n.provider??`The host default`},{label:`Model`,value:n.model?.id??`The agent default`}];r.length>0&&s.push({label:`Folder`,value:P(r.map(l))}),n.config!==void 0&&Object.keys(n.config).length>0&&s.push({label:`Settings`,value:P(Object.entries(n.config).map(([e,t])=>`${e}: ${String(t)}`))});for(let e of i)`schedule`in e&&(s.push({label:`Schedule`,value:P([b(e.schedule.expression),(0,A.jsx)(`span`,{className:`web-method`,children:`${e.schedule.expression} \u{00B7} ${e.schedule.timeZone}`},`raw`)])}),s.push({label:`Missed runs`,value:String(e.misfirePolicy)===`runOnce`?`Run once when back`:`Skipped`}));i.length===0&&a.length===0&&s.push({label:`Schedule`,value:`Run by hand only`});for(let e of a)`schedule`in e||s.push({label:`Event`,value:`${e.title}${e.events.length===0?``:`: ${e.events.map(e=>e.title).join(`, `)}`}`});return o.length>0&&s.push({label:`Turns off`,value:P(o)}),e.nextRunAt!==void 0&&t.enabled&&s.push({label:`Next run`,value:v(e.nextRunAt)}),s.push({label:`Runs`,value:String(e.runCount??e.runs.length)}),(e.customizations?.length??0)>0&&s.push({label:`Customizations`,value:String(e.customizations?.length)}),s.push({label:`Created`,value:v(e.createdAt)},{label:`Changed`,value:v(e.modifiedAt)}),s}function I({resource:e}){let t=r(),{state:l,error:b}=w(o,a),P=n(s),[I,L]=(0,k.useState)(null);if(b!==null)return(0,A.jsx)(m,{tone:`danger`,title:`No automations`,message:b});if(l===void 0)return(0,A.jsx)(f,{label:`Reading the automations`});let R=l.entries.find(t=>t.resource===e);if(R===void 0)return(0,A.jsx)(m,{tone:`warning`,message:`This automation is gone.`});let z=e=>R.operations.map(String).includes(e),B=j[S(R)],V=x(R),H=e=>L(e instanceof Error?e.message:String(e));return(0,A.jsxs)(`div`,{className:`web-page`,children:[(0,A.jsxs)(`div`,{className:`web-page__head`,children:[(0,A.jsxs)(`div`,{className:`web-chat__title`,children:[(0,A.jsx)(h,{variant:`h2`,text:y(R)}),(0,A.jsx)(d,{tone:B.tone,text:B.text})]}),(0,A.jsxs)(`div`,{className:`web-page__actions`,children:[z(`run`)?(0,A.jsx)(i,{label:`Run now`,variant:`primary`,onClick:()=>void E(R).catch(H)}):null,z(`update`)?(0,A.jsx)(i,{label:R.definition.enabled?`Turn off`:`Turn on`,onClick:()=>T(R,!R.definition.enabled)}):null,z(`update`)?(0,A.jsx)(i,{label:`Edit`,onClick:()=>void t.commands.execute(`ahp.editAutomation`,{resource:R.resource})}):null,z(`remove`)?(0,A.jsx)(i,{label:`Delete`,onClick:()=>void D(R)}):null]})]}),I===null?null:(0,A.jsx)(m,{tone:`danger`,message:I}),(0,A.jsx)(g,{items:F(R),columns:2}),(0,A.jsx)(h,{variant:`h3`,text:`Message`}),(0,A.jsx)(`div`,{className:`web-automation__message`,children:(0,A.jsx)(p,{text:R.definition.message.text})}),(0,A.jsx)(h,{variant:`h3`,text:`Runs`}),V.length===0?(0,A.jsx)(`p`,{className:`web-note`,children:`No runs yet.`}):(0,A.jsxs)(`table`,{className:`web-runs`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{children:[(0,A.jsx)(`th`,{children:`Status`}),(0,A.jsx)(`th`,{children:`How`}),(0,A.jsx)(`th`,{children:`Started`}),(0,A.jsx)(`th`,{children:`Took`}),(0,A.jsx)(`th`,{children:`Tokens`}),(0,A.jsx)(`th`,{})]})}),(0,A.jsx)(`tbody`,{children:V.map(e=>{let n=_(e),r=M[n.status]??{tone:`default`,text:n.status},a=n.status===`running`||n.status===`pending`;return(0,A.jsxs)(`tr`,{children:[(0,A.jsxs)(`td`,{children:[(0,A.jsx)(d,{tone:r.tone,text:r.text}),n.error===void 0?null:(0,A.jsx)(`div`,{className:`web-note`,children:n.error})]}),(0,A.jsx)(`td`,{children:N(e.origin)}),(0,A.jsx)(`td`,{children:v(n.at)}),(0,A.jsx)(`td`,{children:n.took===void 0?``:u(n.took)}),(0,A.jsx)(`td`,{children:n.input===void 0&&n.output===void 0?``:`\u{2191}${C(n.input??0)} \u{2193}${C(n.output??0)}`}),(0,A.jsxs)(`td`,{className:`web-runs__actions`,children:[e.primarySession===void 0?null:(0,A.jsx)(i,{label:`Open session`,size:`sm`,onClick:()=>void t.commands.execute(`ahp.openSession`,{resource:e.primarySession})}),a&&P?.runCancellation!==void 0?(0,A.jsx)(i,{label:`Stop`,size:`sm`,onClick:()=>O(e.resource)}):null]})]},e.resource)})})]}),R.runsNextCursor===void 0?null:(0,A.jsx)(i,{label:`Load older runs`,onClick:()=>void c(`fetchAutomationRuns`,{channel:o,automation:R.resource,cursor:R.runsNextCursor}).catch(H)})]})}export{I as default};
|