@alwith/module-chat 0.6.21 → 0.6.24
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 +1 -1
- package/dist/agent/client.js +1 -1
- package/dist/{chunk-dtxc0x7y.js → chunk-0myf2ak0.js} +2 -2
- package/dist/{chunk-j64839nf.js → chunk-11vn501z.js} +1 -1
- package/dist/{chunk-5pyvgshe.js → chunk-1pb43y89.js} +1 -1
- package/dist/{chunk-81hxr15a.js → chunk-1rwkdezk.js} +1 -1
- package/dist/{chunk-mvd124vs.js → chunk-2cc8d35c.js} +1 -1
- package/dist/{chunk-njwb0rbw.js → chunk-3qwtda21.js} +1 -1
- package/dist/{chunk-cfx5s6fz.js → chunk-3zae491f.js} +1 -1
- package/dist/{chunk-nmtz0797.js → chunk-4fmn1kk4.js} +1 -1
- package/dist/{chunk-v9jqk03c.js → chunk-4r0ffb0s.js} +1 -1
- package/dist/{chunk-5dgmqyg1.js → chunk-5ryfm4ka.js} +1 -1
- package/dist/{chunk-cc6x7r61.js → chunk-6tvq472s.js} +2 -2
- package/dist/{chunk-mc5668pn.js → chunk-6vdayg6w.js} +1 -1
- package/dist/{chunk-xqpdvq05.js → chunk-6w8p1hwb.js} +1 -1
- package/dist/{chunk-hp0eqd8x.js → chunk-73541c5k.js} +2 -2
- package/dist/{chunk-cn07a5nh.js → chunk-79ayc6qy.js} +1 -1
- package/dist/{chunk-mwthxh95.js → chunk-84eye2j0.js} +1 -1
- package/dist/{chunk-f1awp8vf.js → chunk-8mzbkjhk.js} +1 -1
- package/dist/{chunk-6e9wwjgv.js → chunk-a6ysp1fp.js} +1 -1
- package/dist/{chunk-exkacmay.js → chunk-a9grdyep.js} +1 -1
- package/dist/{chunk-689vpcc9.js → chunk-b61qhh61.js} +2 -2
- package/dist/{chunk-f7bn0nd2.js → chunk-bane0xc8.js} +2 -2
- package/dist/{chunk-ztnq7bts.js → chunk-bcnh0z8e.js} +2 -2
- package/dist/chunk-bfb8bpwc.js +2 -0
- package/dist/chunk-bgav9cq2.js +2 -0
- package/dist/{chunk-e6ya95ee.js → chunk-bshgrwe9.js} +2 -2
- package/dist/{chunk-5cf6ny70.js → chunk-cer4dxas.js} +1 -1
- package/dist/{chunk-4dp24aja.js → chunk-csbv8m51.js} +1 -1
- package/dist/{chunk-v78f93yn.js → chunk-d5gt1x0n.js} +1 -1
- package/dist/{chunk-9zgkpv8m.js → chunk-d6ke5e80.js} +2 -2
- package/dist/{chunk-c092x92d.js → chunk-e5m9kg1w.js} +1 -1
- package/dist/{chunk-ztb6vjcg.js → chunk-eqbp85f3.js} +1 -1
- package/dist/{chunk-s0z838qq.js → chunk-et2pdaz7.js} +1 -1
- package/dist/{chunk-g4devj8d.js → chunk-f9z37ptq.js} +2 -2
- package/dist/{chunk-5ygqjna0.js → chunk-geh3wyxw.js} +1 -1
- package/dist/{chunk-8a0fd2f5.js → chunk-gkyvgjyx.js} +1 -1
- package/dist/{chunk-0n26qaxb.js → chunk-gpcsb4tg.js} +1 -1
- package/dist/{chunk-05zhvfrp.js → chunk-h0k80cxs.js} +1 -1
- package/dist/chunk-j2cdjycf.js +2 -0
- package/dist/{chunk-0faa9z99.js → chunk-mcrd86tx.js} +1 -1
- package/dist/{chunk-jj5y2js2.js → chunk-mdercwm8.js} +2 -2
- package/dist/{chunk-hgtbhvyh.js → chunk-mfn37eme.js} +1 -1
- package/dist/{chunk-qe4nwsn7.js → chunk-mtn6vdf8.js} +1 -1
- package/dist/{chunk-cfpm71vd.js → chunk-p1tcxky2.js} +1 -1
- package/dist/chunk-p811gdar.js +2 -0
- package/dist/{chunk-p781sb6h.js → chunk-p8cm3xw1.js} +2 -2
- package/dist/{chunk-y93q3v30.js → chunk-q7ka46hb.js} +3 -3
- package/dist/{chunk-e5mn6ern.js → chunk-qm2jq2bq.js} +1 -1
- package/dist/{chunk-ag8696fb.js → chunk-qvw0kyse.js} +1 -1
- package/dist/{chunk-npev9ffr.js → chunk-rg8kj085.js} +1 -1
- package/dist/chunk-s05ftq29.js +2 -0
- package/dist/{chunk-8rtjn0tg.js → chunk-s3j71dbh.js} +1 -1
- package/dist/{chunk-v0h0jqej.js → chunk-t686zwxk.js} +1 -1
- package/dist/{chunk-3ek4vddd.js → chunk-tctdn4kk.js} +1 -1
- package/dist/{chunk-wrfs7q9f.js → chunk-tknyjndw.js} +1 -1
- package/dist/{chunk-94gqvrk7.js → chunk-v3dq3hx2.js} +2 -2
- package/dist/{chunk-qkv8wzq1.js → chunk-vkj5fznh.js} +2 -2
- package/dist/{chunk-grxjvm9h.js → chunk-whb8ttdy.js} +2 -2
- package/dist/{chunk-xre7g1gy.js → chunk-whzs7yxf.js} +1 -1
- package/dist/{chunk-x6m7zsg1.js → chunk-ww3f6z4x.js} +1 -1
- package/dist/{chunk-rn5bqc82.js → chunk-wyxa2tfm.js} +1 -1
- package/dist/{chunk-xw6rsyvx.js → chunk-ym6jphs4.js} +3 -3
- package/dist/chunk-znagg8v9.js +2 -0
- package/dist/{chunk-wd82qz3x.js → chunk-zpqj0ka8.js} +2 -2
- package/dist/{chunk-ca4vetrh.js → chunk-zzqbe5r0.js} +1 -1
- package/dist/client.js +1 -1
- package/dist/codex/activity-group.js +1 -1
- package/dist/codex/artifact-links.js +1 -1
- package/dist/codex/assistant-message.js +1 -1
- package/dist/codex/image-view-activity.js +1 -1
- package/dist/codex/markdown-renderer.js +1 -1
- package/dist/composer/inline-document.js +1 -1
- package/dist/composer/inline-dom.js +1 -1
- package/dist/composer/prompt-input-inline.js +1 -1
- package/dist/conversation/action-card.js +1 -1
- package/dist/conversation/composer/app-mentions.js +1 -1
- package/dist/conversation/composer/apps-menu.js +1 -1
- package/dist/conversation/composer/composer-menu.js +1 -1
- package/dist/conversation/composer/composer.js +1 -1
- package/dist/conversation/composer/config-options.js +1 -1
- package/dist/conversation/composer/mention-chips.js +1 -1
- package/dist/conversation/composer/model-menu.js +1 -1
- package/dist/conversation/composer/pasted-text-attachment.js +1 -1
- package/dist/conversation/composer/permission-mode-menu.js +1 -1
- package/dist/conversation/composer/prompt-history.js +1 -1
- package/dist/conversation/composer/slash-command-button.js +1 -1
- package/dist/conversation/composer/submit-button.js +1 -1
- package/dist/conversation/composer/usage-meter.js +1 -1
- package/dist/conversation/connection-notice.js +1 -1
- package/dist/conversation/context.js +1 -1
- package/dist/conversation/conversation-body.js +1 -1
- package/dist/conversation/conversation-search.js +1 -1
- package/dist/conversation/conversation-view.d.ts +1 -0
- package/dist/conversation/conversation-view.js +1 -1
- package/dist/conversation/conversation.js +1 -1
- package/dist/conversation/diff-modal.js +1 -1
- package/dist/conversation/draft-project-picker.js +1 -1
- package/dist/conversation/session-actions.js +1 -1
- package/dist/conversation/subagent-sessions.js +1 -1
- package/dist/conversation/subagent-tasks.js +1 -1
- package/dist/desktop/desktop-composer.js +1 -1
- package/dist/desktop/desktop.js +1 -1
- package/dist/desktop/draft-model-select.js +1 -1
- package/dist/desktop/model-catalog.js +1 -1
- package/dist/desktop/model-recovery.js +1 -1
- package/dist/desktop/model-settings-action.js +1 -1
- package/dist/desktop/native-file-drop.js +1 -1
- package/dist/lib/app-reference.js +1 -1
- package/dist/mermaid/diagram.js +1 -1
- package/dist/mermaid/index.js +1 -1
- package/dist/plugins/catalog-skeleton.js +1 -1
- package/dist/plugins/host.d.ts +1 -1
- package/dist/plugins/host.js +1 -1
- package/dist/plugins/plugin-detail-page.js +1 -1
- package/dist/plugins/plugins-page.js +1 -1
- package/dist/plugins/plugins.js +1 -1
- package/dist/plugins/skill-document.js +1 -1
- package/dist/plugins/skills-tab.js +1 -1
- package/dist/plugins/store.d.ts +1 -1
- package/dist/plugins/store.js +1 -1
- package/dist/search/chat-search.js +1 -1
- package/dist/search/codex-source-matches.js +1 -1
- package/dist/search/find-bar.js +1 -1
- package/dist/session-timeline/activity-group.js +1 -1
- package/dist/session-timeline/assistant-content.js +1 -1
- package/dist/session-timeline/assistant-turn.js +1 -1
- package/dist/session-timeline/async-questions.js +1 -1
- package/dist/session-timeline/edited-files-card.js +1 -1
- package/dist/session-timeline/host.js +1 -1
- package/dist/session-timeline/image-generation-progress.js +1 -1
- package/dist/session-timeline/navigation-rail.js +1 -1
- package/dist/session-timeline/resource-content.js +1 -1
- package/dist/session-timeline/session-timeline.js +1 -1
- package/dist/session-timeline/turn-error.js +1 -1
- package/dist/session-timeline/user-message.js +1 -1
- package/dist/settings/codex-account-card.js +1 -1
- package/dist/settings/login-card.js +1 -1
- package/dist/settings/model-alias-settings.js +1 -1
- package/dist/settings/provider-section.js +1 -1
- package/dist/settings/settings.js +1 -1
- package/native/darwin-arm64/artifact.json +1 -1
- package/native/darwin-arm64/libalwith_native_chat.dylib +0 -0
- package/native/win32-x64/alwith_native_chat.dll +0 -0
- package/native/win32-x64/artifact.json +1 -1
- package/package.json +2 -7
- package/dist/chunk-200zk66j.js +0 -2
- package/dist/chunk-3vzbqfsh.js +0 -2
- package/dist/chunk-5wqbhb7a.js +0 -2
- package/dist/chunk-7e86wygk.js +0 -2
- package/dist/chunk-ft7k6n4g.js +0 -2
- package/dist/chunk-wdph90qk.js +0 -2
- package/dist/import.d.ts +0 -1
- package/dist/import.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{xs}from"./chunk-qxssxzws.js";import{Zo,$e,t,qe,o,le}from"./chunk-g4devj8d.js";import{Ni,ft,ao,Ri,Li}from"./chunk-stc4ctrx.js";import{gt}from"./chunk-rb4p3h5b.js";import{vi}from"./chunk-0n26qaxb.js";import{Oi}from"./chunk-js3nhatr.js";import{Ii,Ti}from"./chunk-cn07a5nh.js";import{ki,Si}from"./chunk-76c0cx40.js";import{hi}from"./chunk-5xe89qwh.js";import{Pi}from"./chunk-gec6q1jb.js";import{mi}from"./chunk-qkv8wzq1.js";import{codexExtensionCapabilities as ze,codexMessageError as Ve,codexRetryNotice as Be,codexTurnError as Oe,nativeTurnId as ge}from"@nyssance/codex-acp-v2/client";import{ArrowDownIcon as Fe}from"lucide-react";import{useCallback as M,useEffect as H,useLayoutEffect as Te,useMemo as K,useRef as b,useState as U}from"react";import{flushSync as ye}from"react-dom";import{Button as Y}from"@nyssance/shadcn/vega/components/ui/button";import{jsx as i,jsxs as E}from"react/jsx-runtime";var xe=24;function De(e){let f=Math.max(0,e.turnTopPx-xe),v=Math.max(0,e.scrollHeightPx-e.viewportHeightPx),c=f-v;return{scrollTopPx:f,spacerPx:c>0?e.spacerPx+c:e.spacerPx}}function Ke({viewportRef:e,viewportProps:f,children:v}){return i("div",{ref:e,...f,className:"min-h-0 min-w-0 flex-1 overflow-x-hidden overflow-y-auto overscroll-contain outline-none",children:v})}function Ue({sessionId:e,turnId:f,root:v,error:c,connected:S}){let z=b(null),V=qe(),{t:w}=t(),k=M(()=>{V.loadHistoryTurn(e,f).catch(()=>{})},[V,e,f]);return H(()=>{if(!v||!z.current||!S||c)return;let R=new IntersectionObserver((_)=>{if(_.some((g)=>g.isIntersecting))R.disconnect(),k()},{root:v,rootMargin:"800px 0px"});return R.observe(z.current),()=>R.disconnect()},[v,S,c,k]),i("div",{ref:z,className:"flex min-h-80 flex-col justify-center gap-3 py-8","data-history-turn":f,"data-markdown-pending":!0,children:c?E("div",{className:"flex flex-col items-center gap-2",children:[i("p",{role:"alert",className:"text-destructive text-xs",children:c}),i(Y,{variant:"outline",size:"sm",onClick:k,disabled:!S,children:w("timeline.navigationRetry")})]}):E("div",{role:"status","aria-label":w("timeline.navigationLoading"),className:"space-y-3",children:[i("div",{className:"bg-muted ml-auto h-5 w-1/3 rounded"}),i("div",{className:"bg-muted h-3 w-4/5 rounded"}),i("div",{className:"bg-muted h-3 w-3/5 rounded"})]})})}function _e(e,f){let v=b([]),c=b(null);if(c.current?.items!==e.items||c.current.state!==e.state||c.current.ended!==e.turnEndedAt||c.current.usage!==e.turnUsage||c.current.historyOrder!==f)c.current={state:e.state,items:e.items,ended:e.turnEndedAt,usage:e.turnUsage,historyOrder:f,turns:Ni(e,v.current,f)};let S=c.current.turns;return v.current=S,S}function mt(e){return i($e,{host:e.host,client:e.client,children:i(Zo,{value:e.session.cwd,children:i(We,{...e})})})}function We({session:e,leading:f,afterTurn:v,turnWork:c,answerActions:S,turnFooter:z,renderUserMessage:V,insert:w,navigation:k,anchorNewTurn:R=!1,Viewport:_=Ke}){let g=qe(),L=t(),T=o((n)=>n.historyNavigation[e.id]),he=K(()=>e.commands.map((n)=>n.name),[e.commands]),m=_e(e,T?.turns),A=m.at(-1)?.key,be=Ri(e,m),y=e.state==="running"||e.state==="requires_action",W=K(()=>Oi(m,T),[m,T]),Z=K(()=>W.flatMap((n)=>n.turn===void 0?[]:[{...n.turn,key:n.turnKey}]),[W]),we=K(()=>k===void 0?[]:Ii(m,e.turnUsage,T),[k,m,e.turnUsage,T]),ee=w&&w.afterItemId!==null?m.findIndex((n)=>n.items.some((u)=>u.id===w.afterItemId)):-1,j=b(m);j.current=m;let[l,Re]=U(null),x=o((n)=>n.historyPages[e.id]),P=o((n)=>n.connection==="ready"),Se=o((n)=>ze(n.agent).sessionRetry),te=x!==void 0;H(()=>{if(P&&te&&!e.restoring)g.loadHistoryNavigation(e.id).catch(()=>{})},[g,P,te,e.id,e.restoring]);let[ke,Pe]=U(!1),q=b(null),[Ie,ne]=U(!1),re=b(0),X=b({key:A,running:y});X.current={key:A,running:y};let[ie,F]=U(0),I=b(0),N=b(null);I.current=ie;let Ne=M(()=>{if(N.current!==null)N.current.keepTop=!1},[]),{isFollowing:C,scrollToBottom:G,stopFollowing:B,schedulePin:oe,contentResized:ae,beginLocate:ue,cancelLocation:se}=Pi(l,y,Ne),ce=M(()=>{if(l===null||!y)return;let n=m.at(-1)?.key;if(n===void 0)return;let u=ue(!0),d=()=>u.isCurrent()&&X.current.running&&X.current.key===n,r=()=>requestAnimationFrame(()=>requestAnimationFrame(()=>{if(!d())return;let a=l.querySelector(`[data-codex-turn="${CSS.escape(n)}"]`);if(a===null)return;let s=l.scrollTop+a.getBoundingClientRect().top-l.getBoundingClientRect().top,p=De({turnTopPx:s,scrollHeightPx:l.scrollHeight,viewportHeightPx:l.clientHeight,spacerPx:I.current});N.current=p.spacerPx>0?{element:a,heightPx:a.getBoundingClientRect().height+p.spacerPx,keepTop:!0}:null,ye(()=>F(p.spacerPx)),requestAnimationFrame(()=>{if(d())u.finish(p.scrollTopPx)})})),h=q.current;if(h===null)return;h.scrollToKey(n,void 0,{align:"top"}).then(()=>{if(d())r()})},[ue,y,l,m]);Te(()=>{if(!R||y)return;se(),N.current=null,I.current=0,F(0)},[R,se,y]);let J=M(()=>{B(),g.loadOlderHistory(e.id).catch(()=>{})},[g,e.id,B]);H(()=>{if(l===null)return;let n=()=>{let u=l.scrollTop<600;if(Pe(u),u&&!T?.complete&&P&&!e.restoring&&!C&&x?.cursor&&!x.loading&&!x.error)J()};return n(),l.addEventListener("scroll",n,{passive:!0}),()=>l.removeEventListener("scroll",n)},[P,x,C,J,l,e.restoring,T?.complete]),H(()=>{ki({sessionId:e.id,turns:Z,api:q.current,beforeReveal:B,terminals:e.terminals})},[e.id,e.terminals,Z,B]),H(()=>()=>Si(e.id),[e.id]);let He=M(async(n,u)=>{let d=++re.current;ne(!0);try{if(n.isLoaded===!1&&n.nativeTurnId!==void 0)await g.loadHistoryTurn(e.id,n.nativeTurnId),await new Promise((s)=>requestAnimationFrame(()=>s()));if(!u())return null;let r=j.current.find((s)=>s.user?.id===(n.messageId??n.id))??j.current.find((s)=>s.user!==null&&n.nativeTurnId!==void 0&&s.items.some((p)=>ge(p)===n.nativeTurnId));if(!r?.user)return null;let h=r.user.id,a=q.current;if(a===null)throw Error("Virtual timeline is not mounted");return await a.scrollToKey(r.key,(s)=>s.querySelector(`[data-content-search-unit-key="${CSS.escape(h)}"]`),{align:"top"}),document.querySelector(`[data-chat-scroll] [data-content-search-unit-key="${CSS.escape(h)}"]`)}finally{if(re.current===d)ne(!1)}},[g,e.id]),Ee=M(async(n)=>{if(n.nativeTurnId!==void 0)await g.previewHistoryTurn(e.id,n.nativeTurnId)},[g,e.id]);H(()=>{if(l===null)return;let n=l.querySelector("[data-codex-timeline]");if(n===null)throw Error("Timeline content element is missing");let u=new ResizeObserver(()=>{let a=N.current,s=null;if(a!==null){let p=Math.max(0,a.heightPx-a.element.getBoundingClientRect().height);if(p!==I.current&&(p<I.current||a.keepTop)){if(I.current=p,ye(()=>F(p)),p===0)N.current=null}if(p>0&&a.keepTop)s=l.scrollTop+a.element.getBoundingClientRect().top-l.getBoundingClientRect().top-xe}ae(s)});u.observe(n),u.observe(l);let d=null,r=()=>{let a=A===void 0?null:n.querySelector(`[data-codex-turn="${CSS.escape(A)}"]`);if(a===d)return;if(d!==null)u.unobserve(d);if(d=a,d!==null)u.observe(d)};r();let h=new MutationObserver(r);return h.observe(n,{childList:!0,subtree:!0}),()=>{h.disconnect(),u.disconnect()}},[ae,A,l]),H(()=>{if(e.items.length===0)return;oe()},[oe,e.items]);let de=b(null);Te(()=>{if(l===null)return;let n=m.at(-1),u=de.current;if(de.current=n===void 0?null:{key:n.key,running:y},n===void 0||u===null||n.user===null||n.replayed)return;if(R){if(y&&e.turnEndedAt[n.user.id]===void 0&&(n.key!==u.key||!u.running))N.current=null,I.current=0,F(0),ce()}else if(n.key!==u.key)G()},[ce,R,y,G,l,e.turnEndedAt,m]);let Le=(n,u)=>{let d=n,r=d.turn;if(r===void 0){if(d.nativeTurnId===void 0)throw Error(`Turn is missing at index ${u}`);return i(Ue,{sessionId:e.id,turnId:d.nativeTurnId,root:l,error:T?.turnErrors[d.nativeTurnId],connected:P&&!C&&!Ie})}let h=m.indexOf(r),a=r.key===be,s=Li(e,m,h),p=!a&&s.continued,D=r.key===A,O=r.errors.at(-1),me=O===void 0?null:Ve(O),Q=O===void 0?null:ge(O),Ae=!e.subagent&&D&&!a&&P&&Se&&e.attached&&!e.readOnly&&!e.restoring&&O===e.items.at(-1)&&me!==null&&Oe(me).kind==="overloaded"&&Q!==null&&e.lastStopReason!=="end_turn"&&e.lastStopReason!=="cancelled",fe=z?.(r)??null,pe=c?.(r)??null,Ce=pe!==null||r.work.length>0||r.final.length>0||r.errors.length>0||a||fe!==null||ft(r)||ao(r)||D&&(e.error!==null||e.lastStopReason==="cancelled"),ve=r.user===null?null:gt(r);return E("div",{"data-virtualized-turn-content":!0,"data-codex-turn":r.key,className:"flex flex-col gap-1.5",children:[r.user!==null&&(V===void 0?i(mi,{item:r.user,messageTime:ve,skillNames:he}):V(r.user,ve)),Ce&&i(vi,{sessionId:e.id,turn:r,terminals:e.terminals,active:a,blocked:e.state==="requires_action",continued:p,edits:s.edits,activityItems:s.items,workStartedAt:s.startedAt,isLast:D,error:e.error,retrying:a?Be(e._meta)??void 0:void 0,retry:Ae?{turnId:Q,delaySeconds:hi(m),run:(Me)=>g.retrySession(e.id,Q,Me)}:void 0,interrupted:ao(r)||!a&&D&&e.lastStopReason==="cancelled",extraWork:pe,answerActions:S?.(r),footer:fe}),u===ee&&w?.node,v?.(r)]})};return E("div",{className:"relative flex min-h-0 flex-1 flex-col","data-stream-style":"codexUI",children:[i(_,{viewportRef:Re,viewportProps:{"data-chat-scroll":"",style:{overflowAnchor:"none"},tabIndex:0,role:"log","aria-label":L.t("timeline.label")},children:i("div",{className:"codex-timeline-content flex min-h-full w-full flex-col",children:E("div",{"data-timeline-user-message-navigation-content":!0,className:"mx-auto flex w-full max-w-3xl shrink-0 flex-col",children:[w&&ee===-1&&w.node,i(xs,{ref:q,entries:W,renderTurn:Le,scrollElement:l,sessionKey:e.id,preserveViewport:!C,leadingInsetPx:12,leadingContent:f===void 0?void 0:i("div",{className:"pt-3",children:f})}),R&&i("div",{"aria-hidden":"true","data-turn-anchor-spacer":!0,className:"shrink-0",style:{height:ie}}),i("div",{"aria-hidden":"true",className:"h-6 shrink-0"})]})})}),i("div",{"aria-hidden":"true",className:"codex-timeline-bottom-fade"}),T?.error&&i("div",{className:"absolute inset-x-0 top-2 z-10 flex justify-center",children:i(Y,{variant:"outline",size:"sm",disabled:!P,title:T.error,onClick:()=>{g.loadHistoryNavigation(e.id).catch(()=>{})},children:L.t("timeline.navigationRetry")})}),ke&&x?.cursor&&!T?.complete&&E("div",{className:"absolute inset-x-0 top-2 z-10 flex flex-col items-center gap-1","data-history-loader":!0,children:[i(Y,{variant:"outline",size:"sm",disabled:!P||e.restoring||x.loading,onClick:J,children:x.loading?L.t("timeline.loadingEarlier"):L.t("timeline.loadEarlier")}),x.error&&i("p",{role:"alert",className:"bg-background text-destructive max-w-md rounded px-2 py-1 text-xs",children:x.error})]}),k!==void 0&&i(Ti,{items:we,audio:k.audio,scrollRoot:l,beforeReveal:B,ensureItemMounted:He,onPreviewItem:Ee,onRevealError:(n)=>le(L,n),targetTopMarginPx:16},e.id),i("button",{type:"button",className:C?"codex-scroll-to-bottom codex-scroll-to-bottom-hidden":"codex-scroll-to-bottom",tabIndex:C?-1:void 0,onClick:G,"aria-label":L.t("timeline.scrollToBottom"),children:y?E("span",{className:"codex-scroll-to-bottom-dots","aria-hidden":"true",children:[i("span",{className:"codex-wave-dot"}),i("span",{className:"codex-wave-dot"}),i("span",{className:"codex-wave-dot"})]}):i(Fe,{})})]})}
|
|
1
|
+
import{xs}from"./chunk-qxssxzws.js";import{Zo,$e,t,qe,o,le}from"./chunk-f9z37ptq.js";import{Ni,ft,ao,Ri,Li}from"./chunk-stc4ctrx.js";import{gt}from"./chunk-rb4p3h5b.js";import{vi}from"./chunk-gpcsb4tg.js";import{Oi}from"./chunk-js3nhatr.js";import{Ii,Ti}from"./chunk-79ayc6qy.js";import{ki,Si}from"./chunk-76c0cx40.js";import{hi}from"./chunk-5xe89qwh.js";import{Pi}from"./chunk-gec6q1jb.js";import{mi}from"./chunk-vkj5fznh.js";import{codexExtensionCapabilities as ze,codexMessageError as Ve,codexRetryNotice as Be,codexTurnError as Oe,nativeTurnId as ge}from"@nyssance/codex-acp-v2/client";import{ArrowDownIcon as Fe}from"lucide-react";import{useCallback as M,useEffect as H,useLayoutEffect as Te,useMemo as K,useRef as b,useState as U}from"react";import{flushSync as ye}from"react-dom";import{Button as Y}from"@nyssance/shadcn/vega/components/ui/button";import{jsx as i,jsxs as E}from"react/jsx-runtime";var xe=24;function De(e){let f=Math.max(0,e.turnTopPx-xe),v=Math.max(0,e.scrollHeightPx-e.viewportHeightPx),c=f-v;return{scrollTopPx:f,spacerPx:c>0?e.spacerPx+c:e.spacerPx}}function Ke({viewportRef:e,viewportProps:f,children:v}){return i("div",{ref:e,...f,className:"min-h-0 min-w-0 flex-1 overflow-x-hidden overflow-y-auto overscroll-contain outline-none",children:v})}function Ue({sessionId:e,turnId:f,root:v,error:c,connected:S}){let z=b(null),V=qe(),{t:w}=t(),k=M(()=>{V.loadHistoryTurn(e,f).catch(()=>{})},[V,e,f]);return H(()=>{if(!v||!z.current||!S||c)return;let R=new IntersectionObserver((_)=>{if(_.some((g)=>g.isIntersecting))R.disconnect(),k()},{root:v,rootMargin:"800px 0px"});return R.observe(z.current),()=>R.disconnect()},[v,S,c,k]),i("div",{ref:z,className:"flex min-h-80 flex-col justify-center gap-3 py-8","data-history-turn":f,"data-markdown-pending":!0,children:c?E("div",{className:"flex flex-col items-center gap-2",children:[i("p",{role:"alert",className:"text-destructive text-xs",children:c}),i(Y,{variant:"outline",size:"sm",onClick:k,disabled:!S,children:w("timeline.navigationRetry")})]}):E("div",{role:"status","aria-label":w("timeline.navigationLoading"),className:"space-y-3",children:[i("div",{className:"bg-muted ml-auto h-5 w-1/3 rounded"}),i("div",{className:"bg-muted h-3 w-4/5 rounded"}),i("div",{className:"bg-muted h-3 w-3/5 rounded"})]})})}function _e(e,f){let v=b([]),c=b(null);if(c.current?.items!==e.items||c.current.state!==e.state||c.current.ended!==e.turnEndedAt||c.current.usage!==e.turnUsage||c.current.historyOrder!==f)c.current={state:e.state,items:e.items,ended:e.turnEndedAt,usage:e.turnUsage,historyOrder:f,turns:Ni(e,v.current,f)};let S=c.current.turns;return v.current=S,S}function mt(e){return i($e,{host:e.host,client:e.client,children:i(Zo,{value:e.session.cwd,children:i(We,{...e})})})}function We({session:e,leading:f,afterTurn:v,turnWork:c,answerActions:S,turnFooter:z,renderUserMessage:V,insert:w,navigation:k,anchorNewTurn:R=!1,Viewport:_=Ke}){let g=qe(),L=t(),T=o((n)=>n.historyNavigation[e.id]),he=K(()=>e.commands.map((n)=>n.name),[e.commands]),m=_e(e,T?.turns),A=m.at(-1)?.key,be=Ri(e,m),y=e.state==="running"||e.state==="requires_action",W=K(()=>Oi(m,T),[m,T]),Z=K(()=>W.flatMap((n)=>n.turn===void 0?[]:[{...n.turn,key:n.turnKey}]),[W]),we=K(()=>k===void 0?[]:Ii(m,e.turnUsage,T),[k,m,e.turnUsage,T]),ee=w&&w.afterItemId!==null?m.findIndex((n)=>n.items.some((u)=>u.id===w.afterItemId)):-1,j=b(m);j.current=m;let[l,Re]=U(null),x=o((n)=>n.historyPages[e.id]),P=o((n)=>n.connection==="ready"),Se=o((n)=>ze(n.agent).sessionRetry),te=x!==void 0;H(()=>{if(P&&te&&!e.restoring)g.loadHistoryNavigation(e.id).catch(()=>{})},[g,P,te,e.id,e.restoring]);let[ke,Pe]=U(!1),q=b(null),[Ie,ne]=U(!1),re=b(0),X=b({key:A,running:y});X.current={key:A,running:y};let[ie,F]=U(0),I=b(0),N=b(null);I.current=ie;let Ne=M(()=>{if(N.current!==null)N.current.keepTop=!1},[]),{isFollowing:C,scrollToBottom:G,stopFollowing:B,schedulePin:oe,contentResized:ae,beginLocate:ue,cancelLocation:se}=Pi(l,y,Ne),ce=M(()=>{if(l===null||!y)return;let n=m.at(-1)?.key;if(n===void 0)return;let u=ue(!0),d=()=>u.isCurrent()&&X.current.running&&X.current.key===n,r=()=>requestAnimationFrame(()=>requestAnimationFrame(()=>{if(!d())return;let a=l.querySelector(`[data-codex-turn="${CSS.escape(n)}"]`);if(a===null)return;let s=l.scrollTop+a.getBoundingClientRect().top-l.getBoundingClientRect().top,p=De({turnTopPx:s,scrollHeightPx:l.scrollHeight,viewportHeightPx:l.clientHeight,spacerPx:I.current});N.current=p.spacerPx>0?{element:a,heightPx:a.getBoundingClientRect().height+p.spacerPx,keepTop:!0}:null,ye(()=>F(p.spacerPx)),requestAnimationFrame(()=>{if(d())u.finish(p.scrollTopPx)})})),h=q.current;if(h===null)return;h.scrollToKey(n,void 0,{align:"top"}).then(()=>{if(d())r()})},[ue,y,l,m]);Te(()=>{if(!R||y)return;se(),N.current=null,I.current=0,F(0)},[R,se,y]);let J=M(()=>{B(),g.loadOlderHistory(e.id).catch(()=>{})},[g,e.id,B]);H(()=>{if(l===null)return;let n=()=>{let u=l.scrollTop<600;if(Pe(u),u&&!T?.complete&&P&&!e.restoring&&!C&&x?.cursor&&!x.loading&&!x.error)J()};return n(),l.addEventListener("scroll",n,{passive:!0}),()=>l.removeEventListener("scroll",n)},[P,x,C,J,l,e.restoring,T?.complete]),H(()=>{ki({sessionId:e.id,turns:Z,api:q.current,beforeReveal:B,terminals:e.terminals})},[e.id,e.terminals,Z,B]),H(()=>()=>Si(e.id),[e.id]);let He=M(async(n,u)=>{let d=++re.current;ne(!0);try{if(n.isLoaded===!1&&n.nativeTurnId!==void 0)await g.loadHistoryTurn(e.id,n.nativeTurnId),await new Promise((s)=>requestAnimationFrame(()=>s()));if(!u())return null;let r=j.current.find((s)=>s.user?.id===(n.messageId??n.id))??j.current.find((s)=>s.user!==null&&n.nativeTurnId!==void 0&&s.items.some((p)=>ge(p)===n.nativeTurnId));if(!r?.user)return null;let h=r.user.id,a=q.current;if(a===null)throw Error("Virtual timeline is not mounted");return await a.scrollToKey(r.key,(s)=>s.querySelector(`[data-content-search-unit-key="${CSS.escape(h)}"]`),{align:"top"}),document.querySelector(`[data-chat-scroll] [data-content-search-unit-key="${CSS.escape(h)}"]`)}finally{if(re.current===d)ne(!1)}},[g,e.id]),Ee=M(async(n)=>{if(n.nativeTurnId!==void 0)await g.previewHistoryTurn(e.id,n.nativeTurnId)},[g,e.id]);H(()=>{if(l===null)return;let n=l.querySelector("[data-codex-timeline]");if(n===null)throw Error("Timeline content element is missing");let u=new ResizeObserver(()=>{let a=N.current,s=null;if(a!==null){let p=Math.max(0,a.heightPx-a.element.getBoundingClientRect().height);if(p!==I.current&&(p<I.current||a.keepTop)){if(I.current=p,ye(()=>F(p)),p===0)N.current=null}if(p>0&&a.keepTop)s=l.scrollTop+a.element.getBoundingClientRect().top-l.getBoundingClientRect().top-xe}ae(s)});u.observe(n),u.observe(l);let d=null,r=()=>{let a=A===void 0?null:n.querySelector(`[data-codex-turn="${CSS.escape(A)}"]`);if(a===d)return;if(d!==null)u.unobserve(d);if(d=a,d!==null)u.observe(d)};r();let h=new MutationObserver(r);return h.observe(n,{childList:!0,subtree:!0}),()=>{h.disconnect(),u.disconnect()}},[ae,A,l]),H(()=>{if(e.items.length===0)return;oe()},[oe,e.items]);let de=b(null);Te(()=>{if(l===null)return;let n=m.at(-1),u=de.current;if(de.current=n===void 0?null:{key:n.key,running:y},n===void 0||u===null||n.user===null||n.replayed)return;if(R){if(y&&e.turnEndedAt[n.user.id]===void 0&&(n.key!==u.key||!u.running))N.current=null,I.current=0,F(0),ce()}else if(n.key!==u.key)G()},[ce,R,y,G,l,e.turnEndedAt,m]);let Le=(n,u)=>{let d=n,r=d.turn;if(r===void 0){if(d.nativeTurnId===void 0)throw Error(`Turn is missing at index ${u}`);return i(Ue,{sessionId:e.id,turnId:d.nativeTurnId,root:l,error:T?.turnErrors[d.nativeTurnId],connected:P&&!C&&!Ie})}let h=m.indexOf(r),a=r.key===be,s=Li(e,m,h),p=!a&&s.continued,D=r.key===A,O=r.errors.at(-1),me=O===void 0?null:Ve(O),Q=O===void 0?null:ge(O),Ae=!e.subagent&&D&&!a&&P&&Se&&e.attached&&!e.readOnly&&!e.restoring&&O===e.items.at(-1)&&me!==null&&Oe(me).kind==="overloaded"&&Q!==null&&e.lastStopReason!=="end_turn"&&e.lastStopReason!=="cancelled",fe=z?.(r)??null,pe=c?.(r)??null,Ce=pe!==null||r.work.length>0||r.final.length>0||r.errors.length>0||a||fe!==null||ft(r)||ao(r)||D&&(e.error!==null||e.lastStopReason==="cancelled"),ve=r.user===null?null:gt(r);return E("div",{"data-virtualized-turn-content":!0,"data-codex-turn":r.key,className:"flex flex-col gap-1.5",children:[r.user!==null&&(V===void 0?i(mi,{item:r.user,messageTime:ve,skillNames:he}):V(r.user,ve)),Ce&&i(vi,{sessionId:e.id,turn:r,terminals:e.terminals,active:a,blocked:e.state==="requires_action",continued:p,edits:s.edits,activityItems:s.items,workStartedAt:s.startedAt,isLast:D,error:e.error,retrying:a?Be(e._meta)??void 0:void 0,retry:Ae?{turnId:Q,delaySeconds:hi(m),run:(Me)=>g.retrySession(e.id,Q,Me)}:void 0,interrupted:ao(r)||!a&&D&&e.lastStopReason==="cancelled",extraWork:pe,answerActions:S?.(r),footer:fe}),u===ee&&w?.node,v?.(r)]})};return E("div",{className:"relative flex min-h-0 flex-1 flex-col","data-stream-style":"codexUI",children:[i(_,{viewportRef:Re,viewportProps:{"data-chat-scroll":"",style:{overflowAnchor:"none"},tabIndex:0,role:"log","aria-label":L.t("timeline.label")},children:i("div",{className:"codex-timeline-content flex min-h-full w-full flex-col",children:E("div",{"data-timeline-user-message-navigation-content":!0,className:"mx-auto flex w-full max-w-3xl shrink-0 flex-col",children:[w&&ee===-1&&w.node,i(xs,{ref:q,entries:W,renderTurn:Le,scrollElement:l,sessionKey:e.id,preserveViewport:!C,leadingInsetPx:12,leadingContent:f===void 0?void 0:i("div",{className:"pt-3",children:f})}),R&&i("div",{"aria-hidden":"true","data-turn-anchor-spacer":!0,className:"shrink-0",style:{height:ie}}),i("div",{"aria-hidden":"true",className:"h-6 shrink-0"})]})})}),i("div",{"aria-hidden":"true",className:"codex-timeline-bottom-fade"}),T?.error&&i("div",{className:"absolute inset-x-0 top-2 z-10 flex justify-center",children:i(Y,{variant:"outline",size:"sm",disabled:!P,title:T.error,onClick:()=>{g.loadHistoryNavigation(e.id).catch(()=>{})},children:L.t("timeline.navigationRetry")})}),ke&&x?.cursor&&!T?.complete&&E("div",{className:"absolute inset-x-0 top-2 z-10 flex flex-col items-center gap-1","data-history-loader":!0,children:[i(Y,{variant:"outline",size:"sm",disabled:!P||e.restoring||x.loading,onClick:J,children:x.loading?L.t("timeline.loadingEarlier"):L.t("timeline.loadEarlier")}),x.error&&i("p",{role:"alert",className:"bg-background text-destructive max-w-md rounded px-2 py-1 text-xs",children:x.error})]}),k!==void 0&&i(Ti,{items:we,audio:k.audio,scrollRoot:l,beforeReveal:B,ensureItemMounted:He,onPreviewItem:Ee,onRevealError:(n)=>le(L,n),targetTopMarginPx:16},e.id),i("button",{type:"button",className:C?"codex-scroll-to-bottom codex-scroll-to-bottom-hidden":"codex-scroll-to-bottom",tabIndex:C?-1:void 0,onClick:G,"aria-label":L.t("timeline.scrollToBottom"),children:y?E("span",{className:"codex-scroll-to-bottom-dots","aria-hidden":"true",children:[i("span",{className:"codex-wave-dot"}),i("span",{className:"codex-wave-dot"}),i("span",{className:"codex-wave-dot"})]}):i(Fe,{})})]})}
|
|
2
2
|
export{mt};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{e}from"./chunk-e6ya95ee.js";import{Zt}from"./chunk-5pyvgshe.js";import{A,xt,ie,Pn}from"./chunk-h8r785ne.js";import{Cn,Ee}from"./chunk-7xvrsw7x.js";import{CardSendIcon as pe}from"@solar-icons/react/line-duotone/card-send";import{cn as j}from"cn";import{ChevronDownIcon as te,ExternalLinkIcon as ve,EyeIcon as se,EyeOffIcon as ne,PlusIcon as ge,ServerIcon as oe,Trash2Icon as fe}from"lucide-react";import{useEffect as V,useRef as ye,useState as y}from"react";import{Button as R}from"@nyssance/shadcn/vega/components/ui/button";import{Collapsible as re,CollapsibleContent as ae,CollapsibleTrigger as le}from"@nyssance/shadcn/vega/components/ui/collapsible";import{Field as O,FieldDescription as de,FieldLabel as _}from"@nyssance/shadcn/vega/components/ui/field";import{Input as Z}from"@nyssance/shadcn/vega/components/ui/input";import{InputGroup as H,InputGroupAddon as ce,InputGroupButton as ue,InputGroupInput as q}from"@nyssance/shadcn/vega/components/ui/input-group";import{Select as be,SelectContent as he,SelectGroup as xe,SelectItem as Ne,SelectTrigger as Pe,SelectValue as Ce}from"@nyssance/shadcn/vega/components/ui/select";import{Separator as Q}from"@nyssance/shadcn/vega/components/ui/separator";import{Spinner as X}from"@nyssance/shadcn/vega/components/ui/spinner";import{Textarea as we}from"@nyssance/shadcn/vega/components/ui/textarea";import{jsx as t,jsxs as i,Fragment as Se}from"react/jsx-runtime";function W(s){if(s instanceof Error)return s.message;if(typeof s==="object"&&s!==null&&"message"in s)return String(s.message);return String(s)}function Y(){let{host:s}=e();return(d)=>{let u=d instanceof Error?d:Error(W(d));if(s.reportError)s.reportError(u);else console.error(u)}}function ii({refreshAccountProviders:s,openTopUp:d,group:u}){let{t:v}=e().host,C=Y(),[S,N]=y(0),[l,n]=y(null),[h,c]=y(!0),w=ye(s);return w.current=s,V(()=>{let b=()=>N((p)=>p+1);return window.addEventListener("focus",b),()=>window.removeEventListener("focus",b)},[]),V(()=>{let b=!0;return c(!0),w.current().then(()=>{if(b)n(null),c(!1)},(p)=>{if(b)n(W(p)),c(!1)}),()=>{b=!1}},[S]),t(u,{children:i("div",{className:"space-y-3 rounded-xl border p-4",children:[i("div",{className:"flex items-center justify-between gap-3",children:[t("h3",{className:"text-sm font-medium",children:"ALwith"}),d&&t(R,{variant:"ghost",size:"icon-sm",className:"text-primary hover:text-primary/80","aria-label":v("provider.managed.topUp"),title:v("provider.managed.topUp"),onClick:()=>{d().catch(C)},children:t(pe,{className:"size-4","aria-hidden":"true"})})]}),t("p",{className:"text-muted-foreground text-xs",children:v("provider.managed.description")}),l!==null&&i("div",{className:"space-y-2",children:[t("p",{role:"alert",className:"text-destructive text-xs",children:l}),i(R,{variant:"outline",size:"sm",disabled:h,onClick:()=>N((b)=>b+1),children:[h&&t(X,{"aria-hidden":"true"}),v("provider.retry")]})]})]})})}function Ms({port:s,bridge:d,group:u,label:v,refreshAccountProviders:C,openTopUp:S}){let{host:N}=e(),{t:l}=N,n=Y(),h=(o)=>N.notify?.(o),c=Ee(s,n),w=c?.providers??{},[b,p]=y(null),[x,k]=y(A[0]?.id??""),[F,B]=y(0),[U,M]=y({}),J=async(o,r,f)=>{p(r.id);try{let a=await s.save(o,r.id,f);if(!a.error)M((L)=>{let G={...L};return delete G[r.id],G});if(a.error)n(a.error);if(!a.error)h(l(a.status==="pending"?"provider.pending":f===null?"provider.removed":"provider.saved",{name:r.name}));return a}catch(a){return n(a),null}finally{p(null)}},I=async(o)=>{p(o);try{let r=await s.test(o);if(M((f)=>({...f,[o]:r})),r.ok)h(l("provider.testSuccess",{latency:r.latencyMs??0}));else n(`${l(`provider.testErrors.${r.code}`)}${r.message?`: ${r.message}`:""}`)}catch(r){n(r)}finally{p(null)}},T=async(o,r)=>{p(r.id);try{let f=await s.saveCustom(o,r);if(f.error)n(f.error);else M((a)=>{let L={...a};return delete L[r.id],L}),h(l(f.status==="pending"?"provider.pending":"provider.saved",{name:r.name}));return!f.error}catch(f){return n(f),!1}finally{p(null)}},z=async(o)=>{if(!c)return;p(o.id);try{let r=await s.removeCustom(c.revision,o.id);if(r.error)n(r.error);else k(A[0]?.id??""),h(l(r.status==="pending"?"provider.pending":"provider.removed",{name:o.name}))}catch(r){n(r)}finally{p(null)}},K=async()=>{p("retry");try{let o=await Cn(s);if(o.error)n(o.error);else if(o.status==="pending")h(l("provider.pending"))}catch(o){n(o)}finally{p(null)}},P=A.find((o)=>o.id===x)??null,E=c?.customProviders.find((o)=>o.id===x)??null;return V(()=>{if(!c||x==="new"||P||E)return;k(A[0]?.id??"")},[c,x,P,E]),i("div",{className:"flex flex-col gap-6",children:[i(u,{children:[t(v,{children:"Codex"}),t(Zt,{bridge:d})]}),C&&t(ii,{refreshAccountProviders:C,openTopUp:S,group:u}),c?.status==="pending"&&t("p",{className:"text-muted-foreground text-sm",children:l("provider.pending")}),c?.error&&t("p",{className:"text-destructive text-sm",children:c.error}),c&&c.status!=="applied"&&t(R,{variant:"outline",className:"self-start",disabled:b!==null,onClick:()=>void K(),children:l("provider.retry")}),t(u,{children:c&&i(Se,{children:[t(ri,{activeId:x,keys:w,customProviders:c.customProviders,onSelect:k,onAdd:()=>k("new"),label:v}),A.map((o)=>t("div",{hidden:x!==o.id,children:t(ai,{provider:o,saved:w[o.id]??null,revision:c.revision,busy:b!==null,onSave:(r,f)=>J(r,o,f),testResult:U[o.id],onTest:()=>I(o.id)})},o.id)),c.customProviders.map((o)=>t("div",{hidden:x!==o.id,children:t(eo,{provider:o,revision:c.revision,busy:b!==null,testResult:U[o.id],onTest:()=>I(o.id),onRemove:()=>z(o),onSaved:k,onSave:T})},o.id)),t("div",{hidden:x!=="new",children:t(eo,{provider:null,revision:c.revision,busy:b!==null,onSaved:(o)=>{B((r)=>r+1),k(o)},onSave:T},F)})]})})]})}function ri({activeId:s,keys:d,customProviders:u,onSelect:v,onAdd:C,label:S}){let{t:N}=e().host;return i("div",{children:[t(S,{children:N("provider.label")}),i("div",{className:"grid grid-cols-2 gap-2 py-4 sm:grid-cols-3",children:[A.map((l)=>{let n=l.logo,h=d[l.id]!==void 0;return t(ee,{id:l.id,name:l.name,active:s===l.id,configured:h,icon:t(n,{className:"size-5 shrink-0"}),onClick:()=>v(l.id)},l.id)}),u.map((l)=>t(ee,{id:l.id,name:l.name,active:s===l.id,configured:!0,icon:t(oe,{className:"size-5 shrink-0"}),onClick:()=>v(l.id)},l.id)),i(R,{type:"button",variant:"outline","aria-pressed":s==="new",onClick:C,className:j("h-9 w-full justify-start gap-2 rounded-full px-4",s==="new"&&"bg-accent"),children:[t(ge,{className:"size-4 shrink-0"}),t("span",{className:"truncate",children:N("provider.customButton")})]})]})]})}function ee({id:s,name:d,active:u,configured:v,icon:C,onClick:S}){return i(R,{type:"button",variant:"outline","aria-label":d,"aria-pressed":u,onClick:S,className:j("h-9 w-full gap-2 rounded-full px-4",u&&"bg-accent"),children:[C,t("span",{className:"min-w-0 flex-1 truncate text-center",children:d}),t("span",{"data-testid":`${s}-status`,"data-configured":v,"aria-hidden":"true",className:j("size-2 shrink-0 rounded-full",v?"bg-green-500":"bg-muted-foreground/30")})]})}function si({result:s}){let{t:d}=e().host;return t("p",{role:"status",className:s.ok?"text-muted-foreground text-xs":"text-destructive text-xs",children:s.ok?d("provider.testSuccess",{latency:s.latencyMs??0}):`${d(`provider.testErrors.${s.code}`)}${s.status?` (HTTP ${s.status})`:""}`})}function me({busy:s,canTest:d,onTest:u,onRemove:v,result:C,children:S}){let{t:N}=e().host;return i("div",{className:"space-y-3 border-t pt-4",children:[C&&t(si,{result:C}),u&&t("p",{className:"text-muted-foreground text-xs leading-relaxed",children:N("provider.testDescription")}),i("div",{className:"flex flex-wrap items-center gap-2",children:[v&&i(R,{size:"sm",variant:"destructive",className:"font-normal",disabled:s,onClick:v,children:[t(fe,{className:"size-4"}),N("provider.remove")]}),i("div",{className:"ms-auto flex flex-wrap items-center gap-2",children:[u&&t(R,{size:"sm",variant:"outline",disabled:s||!d,onClick:u,children:N("provider.testButton")}),S]})]})]})}function ai({provider:s,saved:d,revision:u,busy:v,onSave:C,testResult:S,onTest:N}){let{host:l}=e(),{t:n}=l,h=Y(),[c,w]=y(""),[b,p]=y(!1),[x,k]=y({saved:d,revision:u}),[F,B]=y(ie(s,d?.region)?.id),[U,M]=y(d?.base_url??""),J=s.logo,I=d!==null,T=c.trim(),z=Pn(s,F),K=F!==ie(s,x.saved?.region)?.id,P=U.trim()!==(x.saved?.base_url??"");V(()=>{if(u>x.revision&&T===""&&!K&&!P)k({saved:d,revision:u}),B(ie(s,d?.region)?.id),M(d?.base_url??"")},[u,d,s,x.revision,T,K,P]);let E=!v&&(T!==""||K||P),o=`${s.id}-api-key`,r=async(a)=>{let L=c,G=F,m=await C(x.revision,a);if(!m)return;let D=m.providers[s.id]??null;k({saved:D,revision:m.revision}),w((g)=>g===L?"":g),B((g)=>g===G?ie(s,D?.region)?.id:g),M((g)=>g===U?D?.base_url??"":g)},f=()=>{if(T===""&&x.saved===null)return;r({...T===""?{}:{apiKey:T},...F===void 0?{}:{region:F},...P?{baseUrl:U.trim()}:{}})};return i("div",{className:"space-y-5 rounded-xl border p-4",children:[i("div",{className:"flex flex-wrap items-center gap-3",children:[t(J,{className:"size-6 shrink-0"}),i("div",{className:"min-w-0 flex-1",children:[t("h3",{className:"text-sm font-medium",children:s.name}),t("div",{className:"text-muted-foreground mt-0.5 text-xs",children:I?n("provider.active",{name:s.name,count:s.models.length}):n("provider.inactive")})]}),s.regions&&i(be,{value:F,onValueChange:(a)=>B(a??s.regions?.[0]?.id),children:[t(Pe,{className:"w-32","aria-label":n("provider.region"),children:t(Ce,{})}),t(he,{align:"start",alignItemWithTrigger:!1,sideOffset:6,className:"max-w-(--available-width) min-w-0 p-1",children:t(xe,{children:s.regions.map((a)=>t(Ne,{value:a.id,children:n(`provider.regions.${a.id}`)},a.id))})})]})]}),t(Q,{}),i("section",{className:"space-y-4","aria-labelledby":`${s.id}-connection`,children:[t("h4",{id:`${s.id}-connection`,className:"text-sm font-medium",children:n("provider.connectionSettings")}),i(O,{className:"gap-2",children:[i("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t(_,{htmlFor:o,children:n("provider.apiKey")}),z!==null&&i(R,{type:"button",variant:"link",size:"sm",className:"text-muted-foreground h-auto p-0 text-xs",onClick:()=>{try{l.openLink(z)}catch(a){h(a)}},children:[n("provider.getKey",{name:s.name}),t(ve,{className:"size-3","aria-hidden":"true"})]})]}),i(H,{children:[t(q,{id:o,type:b?"text":"password",autoComplete:"off",spellCheck:!1,placeholder:I?n("provider.apiKeyKept"):n("provider.apiKeyPlaceholder"),value:c,onChange:(a)=>w(a.target.value),onKeyDown:(a)=>{if(a.key==="Enter"&&E)f()}}),t(ce,{align:"inline-end",children:t(ue,{size:"icon-xs","aria-label":n(b?"provider.hideKey":"provider.showKey"),onClick:()=>p((a)=>!a),children:b?t(se,{}):t(ne,{})})})]})]}),i(re,{className:"space-y-2",children:[i(le,{render:t(R,{variant:"ghost",size:"sm",className:"group px-2.5"}),children:[n("provider.baseUrl"),t(te,{className:"size-4 transition-transform group-aria-expanded:rotate-180","aria-hidden":"true"})]}),t(ae,{children:i(O,{className:"gap-2",children:[t(_,{htmlFor:`${s.id}-base-url`,className:"sr-only",children:n("provider.baseUrl")}),t(H,{children:t(q,{id:`${s.id}-base-url`,type:"url",spellCheck:!1,placeholder:ie(s,F)?.baseUrl??s.baseUrl,value:U,onChange:(a)=>M(a.target.value)})}),t(de,{className:"text-xs",children:n("provider.baseUrlDescription")})]})})]})]}),t(me,{busy:v,canTest:!E,onTest:I?N:void 0,onRemove:I?()=>void r(null):void 0,result:!E?S:void 0,children:i(R,{size:"sm",disabled:!E,onClick:f,children:[v&&t(X,{"data-icon":"inline-start"}),n("provider.saveButton")]})})]})}function eo({provider:s,revision:d,busy:u,testResult:v,onTest:C,onRemove:S,onSaved:N,onSave:l}){let{t:n}=e().host,[h,c]=y(s?.name??""),[w,b]=y(s?.baseUrl??""),[p,x]=y(""),[k,F]=y(!1),[B,U]=y(s===null),[M,J]=y(s?.models??[]),[I,T]=y(s?JSON.stringify(s.models,null,2):`[
|
|
1
|
+
import{e}from"./chunk-bshgrwe9.js";import{Zt}from"./chunk-1pb43y89.js";import{A,xt,ie,Pn}from"./chunk-h8r785ne.js";import{Cn,Ee}from"./chunk-7xvrsw7x.js";import{CardSendIcon as pe}from"@solar-icons/react/line-duotone/card-send";import{cn as j}from"cn";import{ChevronDownIcon as te,ExternalLinkIcon as ve,EyeIcon as se,EyeOffIcon as ne,PlusIcon as ge,ServerIcon as oe,Trash2Icon as fe}from"lucide-react";import{useEffect as V,useRef as ye,useState as y}from"react";import{Button as R}from"@nyssance/shadcn/vega/components/ui/button";import{Collapsible as re,CollapsibleContent as ae,CollapsibleTrigger as le}from"@nyssance/shadcn/vega/components/ui/collapsible";import{Field as O,FieldDescription as de,FieldLabel as _}from"@nyssance/shadcn/vega/components/ui/field";import{Input as Z}from"@nyssance/shadcn/vega/components/ui/input";import{InputGroup as H,InputGroupAddon as ce,InputGroupButton as ue,InputGroupInput as q}from"@nyssance/shadcn/vega/components/ui/input-group";import{Select as be,SelectContent as he,SelectGroup as xe,SelectItem as Ne,SelectTrigger as Pe,SelectValue as Ce}from"@nyssance/shadcn/vega/components/ui/select";import{Separator as Q}from"@nyssance/shadcn/vega/components/ui/separator";import{Spinner as X}from"@nyssance/shadcn/vega/components/ui/spinner";import{Textarea as we}from"@nyssance/shadcn/vega/components/ui/textarea";import{jsx as t,jsxs as i,Fragment as Se}from"react/jsx-runtime";function W(s){if(s instanceof Error)return s.message;if(typeof s==="object"&&s!==null&&"message"in s)return String(s.message);return String(s)}function Y(){let{host:s}=e();return(d)=>{let u=d instanceof Error?d:Error(W(d));if(s.reportError)s.reportError(u);else console.error(u)}}function ii({refreshAccountProviders:s,openTopUp:d,group:u}){let{t:v}=e().host,C=Y(),[S,N]=y(0),[l,n]=y(null),[h,c]=y(!0),w=ye(s);return w.current=s,V(()=>{let b=()=>N((p)=>p+1);return window.addEventListener("focus",b),()=>window.removeEventListener("focus",b)},[]),V(()=>{let b=!0;return c(!0),w.current().then(()=>{if(b)n(null),c(!1)},(p)=>{if(b)n(W(p)),c(!1)}),()=>{b=!1}},[S]),t(u,{children:i("div",{className:"space-y-3 rounded-xl border p-4",children:[i("div",{className:"flex items-center justify-between gap-3",children:[t("h3",{className:"text-sm font-medium",children:"ALwith"}),d&&t(R,{variant:"ghost",size:"icon-sm",className:"text-primary hover:text-primary/80","aria-label":v("provider.managed.topUp"),title:v("provider.managed.topUp"),onClick:()=>{d().catch(C)},children:t(pe,{className:"size-4","aria-hidden":"true"})})]}),t("p",{className:"text-muted-foreground text-xs",children:v("provider.managed.description")}),l!==null&&i("div",{className:"space-y-2",children:[t("p",{role:"alert",className:"text-destructive text-xs",children:l}),i(R,{variant:"outline",size:"sm",disabled:h,onClick:()=>N((b)=>b+1),children:[h&&t(X,{"aria-hidden":"true"}),v("provider.retry")]})]})]})})}function Ms({port:s,bridge:d,group:u,label:v,refreshAccountProviders:C,openTopUp:S}){let{host:N}=e(),{t:l}=N,n=Y(),h=(o)=>N.notify?.(o),c=Ee(s,n),w=c?.providers??{},[b,p]=y(null),[x,k]=y(A[0]?.id??""),[F,B]=y(0),[U,M]=y({}),J=async(o,r,f)=>{p(r.id);try{let a=await s.save(o,r.id,f);if(!a.error)M((L)=>{let G={...L};return delete G[r.id],G});if(a.error)n(a.error);if(!a.error)h(l(a.status==="pending"?"provider.pending":f===null?"provider.removed":"provider.saved",{name:r.name}));return a}catch(a){return n(a),null}finally{p(null)}},I=async(o)=>{p(o);try{let r=await s.test(o);if(M((f)=>({...f,[o]:r})),r.ok)h(l("provider.testSuccess",{latency:r.latencyMs??0}));else n(`${l(`provider.testErrors.${r.code}`)}${r.message?`: ${r.message}`:""}`)}catch(r){n(r)}finally{p(null)}},T=async(o,r)=>{p(r.id);try{let f=await s.saveCustom(o,r);if(f.error)n(f.error);else M((a)=>{let L={...a};return delete L[r.id],L}),h(l(f.status==="pending"?"provider.pending":"provider.saved",{name:r.name}));return!f.error}catch(f){return n(f),!1}finally{p(null)}},z=async(o)=>{if(!c)return;p(o.id);try{let r=await s.removeCustom(c.revision,o.id);if(r.error)n(r.error);else k(A[0]?.id??""),h(l(r.status==="pending"?"provider.pending":"provider.removed",{name:o.name}))}catch(r){n(r)}finally{p(null)}},K=async()=>{p("retry");try{let o=await Cn(s);if(o.error)n(o.error);else if(o.status==="pending")h(l("provider.pending"))}catch(o){n(o)}finally{p(null)}},P=A.find((o)=>o.id===x)??null,E=c?.customProviders.find((o)=>o.id===x)??null;return V(()=>{if(!c||x==="new"||P||E)return;k(A[0]?.id??"")},[c,x,P,E]),i("div",{className:"flex flex-col gap-6",children:[i(u,{children:[t(v,{children:"Codex"}),t(Zt,{bridge:d})]}),C&&t(ii,{refreshAccountProviders:C,openTopUp:S,group:u}),c?.status==="pending"&&t("p",{className:"text-muted-foreground text-sm",children:l("provider.pending")}),c?.error&&t("p",{className:"text-destructive text-sm",children:c.error}),c&&c.status!=="applied"&&t(R,{variant:"outline",className:"self-start",disabled:b!==null,onClick:()=>void K(),children:l("provider.retry")}),t(u,{children:c&&i(Se,{children:[t(ri,{activeId:x,keys:w,customProviders:c.customProviders,onSelect:k,onAdd:()=>k("new"),label:v}),A.map((o)=>t("div",{hidden:x!==o.id,children:t(ai,{provider:o,saved:w[o.id]??null,revision:c.revision,busy:b!==null,onSave:(r,f)=>J(r,o,f),testResult:U[o.id],onTest:()=>I(o.id)})},o.id)),c.customProviders.map((o)=>t("div",{hidden:x!==o.id,children:t(eo,{provider:o,revision:c.revision,busy:b!==null,testResult:U[o.id],onTest:()=>I(o.id),onRemove:()=>z(o),onSaved:k,onSave:T})},o.id)),t("div",{hidden:x!=="new",children:t(eo,{provider:null,revision:c.revision,busy:b!==null,onSaved:(o)=>{B((r)=>r+1),k(o)},onSave:T},F)})]})})]})}function ri({activeId:s,keys:d,customProviders:u,onSelect:v,onAdd:C,label:S}){let{t:N}=e().host;return i("div",{children:[t(S,{children:N("provider.label")}),i("div",{className:"grid grid-cols-2 gap-2 py-4 sm:grid-cols-3",children:[A.map((l)=>{let n=l.logo,h=d[l.id]!==void 0;return t(ee,{id:l.id,name:l.name,active:s===l.id,configured:h,icon:t(n,{className:"size-5 shrink-0"}),onClick:()=>v(l.id)},l.id)}),u.map((l)=>t(ee,{id:l.id,name:l.name,active:s===l.id,configured:!0,icon:t(oe,{className:"size-5 shrink-0"}),onClick:()=>v(l.id)},l.id)),i(R,{type:"button",variant:"outline","aria-pressed":s==="new",onClick:C,className:j("h-9 w-full justify-start gap-2 rounded-full px-4",s==="new"&&"bg-accent"),children:[t(ge,{className:"size-4 shrink-0"}),t("span",{className:"truncate",children:N("provider.customButton")})]})]})]})}function ee({id:s,name:d,active:u,configured:v,icon:C,onClick:S}){return i(R,{type:"button",variant:"outline","aria-label":d,"aria-pressed":u,onClick:S,className:j("h-9 w-full gap-2 rounded-full px-4",u&&"bg-accent"),children:[C,t("span",{className:"min-w-0 flex-1 truncate text-center",children:d}),t("span",{"data-testid":`${s}-status`,"data-configured":v,"aria-hidden":"true",className:j("size-2 shrink-0 rounded-full",v?"bg-green-500":"bg-muted-foreground/30")})]})}function si({result:s}){let{t:d}=e().host;return t("p",{role:"status",className:s.ok?"text-muted-foreground text-xs":"text-destructive text-xs",children:s.ok?d("provider.testSuccess",{latency:s.latencyMs??0}):`${d(`provider.testErrors.${s.code}`)}${s.status?` (HTTP ${s.status})`:""}`})}function me({busy:s,canTest:d,onTest:u,onRemove:v,result:C,children:S}){let{t:N}=e().host;return i("div",{className:"space-y-3 border-t pt-4",children:[C&&t(si,{result:C}),u&&t("p",{className:"text-muted-foreground text-xs leading-relaxed",children:N("provider.testDescription")}),i("div",{className:"flex flex-wrap items-center gap-2",children:[v&&i(R,{size:"sm",variant:"destructive",className:"font-normal",disabled:s,onClick:v,children:[t(fe,{className:"size-4"}),N("provider.remove")]}),i("div",{className:"ms-auto flex flex-wrap items-center gap-2",children:[u&&t(R,{size:"sm",variant:"outline",disabled:s||!d,onClick:u,children:N("provider.testButton")}),S]})]})]})}function ai({provider:s,saved:d,revision:u,busy:v,onSave:C,testResult:S,onTest:N}){let{host:l}=e(),{t:n}=l,h=Y(),[c,w]=y(""),[b,p]=y(!1),[x,k]=y({saved:d,revision:u}),[F,B]=y(ie(s,d?.region)?.id),[U,M]=y(d?.base_url??""),J=s.logo,I=d!==null,T=c.trim(),z=Pn(s,F),K=F!==ie(s,x.saved?.region)?.id,P=U.trim()!==(x.saved?.base_url??"");V(()=>{if(u>x.revision&&T===""&&!K&&!P)k({saved:d,revision:u}),B(ie(s,d?.region)?.id),M(d?.base_url??"")},[u,d,s,x.revision,T,K,P]);let E=!v&&(T!==""||K||P),o=`${s.id}-api-key`,r=async(a)=>{let L=c,G=F,m=await C(x.revision,a);if(!m)return;let D=m.providers[s.id]??null;k({saved:D,revision:m.revision}),w((g)=>g===L?"":g),B((g)=>g===G?ie(s,D?.region)?.id:g),M((g)=>g===U?D?.base_url??"":g)},f=()=>{if(T===""&&x.saved===null)return;r({...T===""?{}:{apiKey:T},...F===void 0?{}:{region:F},...P?{baseUrl:U.trim()}:{}})};return i("div",{className:"space-y-5 rounded-xl border p-4",children:[i("div",{className:"flex flex-wrap items-center gap-3",children:[t(J,{className:"size-6 shrink-0"}),i("div",{className:"min-w-0 flex-1",children:[t("h3",{className:"text-sm font-medium",children:s.name}),t("div",{className:"text-muted-foreground mt-0.5 text-xs",children:I?n("provider.active",{name:s.name,count:s.models.length}):n("provider.inactive")})]}),s.regions&&i(be,{value:F,onValueChange:(a)=>B(a??s.regions?.[0]?.id),children:[t(Pe,{className:"w-32","aria-label":n("provider.region"),children:t(Ce,{})}),t(he,{align:"start",alignItemWithTrigger:!1,sideOffset:6,className:"max-w-(--available-width) min-w-0 p-1",children:t(xe,{children:s.regions.map((a)=>t(Ne,{value:a.id,children:n(`provider.regions.${a.id}`)},a.id))})})]})]}),t(Q,{}),i("section",{className:"space-y-4","aria-labelledby":`${s.id}-connection`,children:[t("h4",{id:`${s.id}-connection`,className:"text-sm font-medium",children:n("provider.connectionSettings")}),i(O,{className:"gap-2",children:[i("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t(_,{htmlFor:o,children:n("provider.apiKey")}),z!==null&&i(R,{type:"button",variant:"link",size:"sm",className:"text-muted-foreground h-auto p-0 text-xs",onClick:()=>{try{l.openLink(z)}catch(a){h(a)}},children:[n("provider.getKey",{name:s.name}),t(ve,{className:"size-3","aria-hidden":"true"})]})]}),i(H,{children:[t(q,{id:o,type:b?"text":"password",autoComplete:"off",spellCheck:!1,placeholder:I?n("provider.apiKeyKept"):n("provider.apiKeyPlaceholder"),value:c,onChange:(a)=>w(a.target.value),onKeyDown:(a)=>{if(a.key==="Enter"&&E)f()}}),t(ce,{align:"inline-end",children:t(ue,{size:"icon-xs","aria-label":n(b?"provider.hideKey":"provider.showKey"),onClick:()=>p((a)=>!a),children:b?t(se,{}):t(ne,{})})})]})]}),i(re,{className:"space-y-2",children:[i(le,{render:t(R,{variant:"ghost",size:"sm",className:"group px-2.5"}),children:[n("provider.baseUrl"),t(te,{className:"size-4 transition-transform group-aria-expanded:rotate-180","aria-hidden":"true"})]}),t(ae,{children:i(O,{className:"gap-2",children:[t(_,{htmlFor:`${s.id}-base-url`,className:"sr-only",children:n("provider.baseUrl")}),t(H,{children:t(q,{id:`${s.id}-base-url`,type:"url",spellCheck:!1,placeholder:ie(s,F)?.baseUrl??s.baseUrl,value:U,onChange:(a)=>M(a.target.value)})}),t(de,{className:"text-xs",children:n("provider.baseUrlDescription")})]})})]})]}),t(me,{busy:v,canTest:!E,onTest:I?N:void 0,onRemove:I?()=>void r(null):void 0,result:!E?S:void 0,children:i(R,{size:"sm",disabled:!E,onClick:f,children:[v&&t(X,{"data-icon":"inline-start"}),n("provider.saveButton")]})})]})}function eo({provider:s,revision:d,busy:u,testResult:v,onTest:C,onRemove:S,onSaved:N,onSave:l}){let{t:n}=e().host,[h,c]=y(s?.name??""),[w,b]=y(s?.baseUrl??""),[p,x]=y(""),[k,F]=y(!1),[B,U]=y(s===null),[M,J]=y(s?.models??[]),[I,T]=y(s?JSON.stringify(s.models,null,2):`[
|
|
2
2
|
{ "label": "My Model", "api_id": "model-id" }
|
|
3
3
|
]`),[z,K]=y(null),[P]=y(()=>s?.id??`custom_${crypto.randomUUID().replaceAll("-","")}`),E=`${P}-name`,o=`${P}-base-url`,r=`${P}-api-key`,f=`${P}-models`,a=h.trim()!==s?.name||w.trim()!==s.baseUrl||p.trim()!==""||I!==JSON.stringify(s.models,null,2),L=(m)=>{if(!m)try{J(xt(I)),K(null)}catch(D){K(W(D));return}U(m)},G=async()=>{let m;try{m=xt(I),K(null)}catch(g){K(W(g)),U(!0);return}if(await l(d,{id:P,name:h.trim(),baseUrl:w.trim(),models:m,...p.trim()===""?{}:{apiKey:p.trim()}}))c((g)=>g===h?h.trim():g),b((g)=>g===w?w.trim():g),x((g)=>g===p?"":g),T((g)=>g===I?JSON.stringify(m,null,2):g),N(P)};return i("div",{className:"space-y-5 rounded-xl border p-4",children:[i("div",{className:"flex items-center gap-3",children:[t(oe,{className:"size-6 shrink-0"}),i("div",{className:"min-w-0 flex-1",children:[t("h3",{className:"text-sm font-medium break-words",children:s?.name||n("provider.addCustom")}),t("div",{className:"text-muted-foreground mt-0.5 text-xs",children:n("provider.customDescription")})]}),s&&t("span",{className:"text-muted-foreground shrink-0 text-xs",children:n("provider.configured")})]}),t(Q,{}),i("section",{className:"space-y-4","aria-labelledby":`${P}-connection`,children:[t("h4",{id:`${P}-connection`,className:"text-sm font-medium",children:n("provider.connectionSettings")}),i(O,{className:"gap-2",children:[t(_,{htmlFor:E,children:n("provider.name")}),t(Z,{id:E,value:h,onChange:(m)=>c(m.target.value)})]}),i(O,{className:"gap-2",children:[t(_,{htmlFor:o,children:n("provider.baseUrl")}),t(Z,{id:o,type:"url",placeholder:"https://.../v1",value:w,onChange:(m)=>b(m.target.value)})]}),i(O,{className:"gap-2",children:[t(_,{htmlFor:r,children:n("provider.apiKey")}),i(H,{children:[t(q,{id:r,type:k?"text":"password",autoComplete:"off",placeholder:s?n("provider.apiKeyKept"):n("provider.apiKeyPlaceholder"),value:p,onChange:(m)=>x(m.target.value)}),t(ce,{align:"inline-end",children:t(ue,{size:"icon-xs","aria-label":n(k?"provider.hideKey":"provider.showKey"),onClick:()=>F((m)=>!m),children:k?t(se,{}):t(ne,{})})})]})]})]}),t(Q,{}),i(re,{open:B,onOpenChange:L,className:"space-y-3",children:[i("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t("h4",{className:"text-sm font-medium",children:n("provider.models")}),i(le,{render:t(R,{variant:"ghost",size:"sm"}),children:[n(B?"provider.previewModels":"provider.editModels"),t(te,{className:j("size-4",B&&"rotate-180")})]})]}),!B&&t("ul",{className:"bg-muted/40 divide-y rounded-lg px-3",children:M.map((m)=>i("li",{className:"flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1 py-2.5 text-sm",children:[t("span",{className:"break-all",children:m.label}),t("span",{className:"text-muted-foreground font-mono text-xs break-all",children:m.api_id})]},m.api_id))}),t(ae,{children:i(O,{className:"gap-2","data-invalid":z!==null,children:[t(_,{htmlFor:f,children:n("provider.modelsJson")}),t(we,{id:f,"aria-invalid":z!==null,"aria-describedby":`${f}-description`,spellCheck:!1,className:"min-h-44 font-mono text-xs",value:I,onChange:(m)=>{T(m.target.value),K(null)}}),t(de,{id:`${f}-description`,className:j("text-xs",z&&"text-destructive"),role:z?"alert":void 0,children:z??n("provider.modelsJsonDescription")})]})})]}),t(me,{busy:u,canTest:!a,onTest:s?C:void 0,onRemove:s?S:void 0,result:!a?v:void 0,children:i(R,{size:"sm",disabled:u||!a||h.trim()===""||w.trim()===""||!s&&p.trim()==="",onClick:()=>void G(),children:[u&&t(X,{"data-icon":"inline-start"}),n("provider.saveButton")]})})]})}
|
|
4
4
|
export{ii,Ms,ri,si,ai,eo};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ar}from"./chunk-ck2ax5f6.js";import{e,
|
|
1
|
+
import{ar}from"./chunk-ck2ax5f6.js";import{e,b}from"./chunk-bshgrwe9.js";import{X,x}from"./chunk-p8cm3xw1.js";import{createLucideIcon as v,HandIcon as k,ShieldAlertIcon as w,ShieldCheckIcon as a}from"lucide-react";import{memo as y}from"react";import{jsx as t}from"react/jsx-runtime";var S=v("ApprovalShield",[["path",{d:"M12 22s8-4 8-11V5l-8-3-8 3v6c0 7 8 11 8 11",key:"shield"}],["path",{d:"m8 8 3 3-3 3M13 15h3",key:"terminal"}]]),d={"read-only":k,"workspace-write":a,agent:S,"agent-full-access":w},O={"read-only":"readOnly","workspace-write":"workspaceAccess",agent:"agent","agent-full-access":"fullAccess"};function A({sessionId:u,options:m,disabled:g,onConfigChange:c}){let{host:l,client:f}=e(),{t:r}=l,s=x(m,"mode");if(!s)return null;let o=s.currentValue,p=X(s).map((n)=>{let i=O[n.value];return i?{...n,name:r(`permissionModes.${i}.name`),description:r(`permissionModes.${i}.description`)}:n}),h=p.find((n)=>n.value===o),M=d[o]??a,I=(n)=>{if(n===o)return;b(l,c?c(s.configId,n):f.setConfig(u,s.configId,n))};return t(ar,{value:o,warning:o==="agent-full-access",currentName:h?.name??o,icon:t(M,{className:"size-3.5 shrink-0"}),header:r("permissionModes.heading"),disabled:g,label:r("composer.switchPermissionMode"),onValueChange:I,options:p.map((n)=>{let i=d[n.value]??a,C=n.value==="agent-full-access";return{value:n.value,label:t("span",{"data-permission-warning":C?"":void 0,children:n.name}),description:n.description?t("span",{className:"whitespace-normal",children:n.description}):void 0,icon:t(i,{className:"size-3.5 shrink-0"})}})})}var un=y(A);
|
|
2
2
|
export{un};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{e}from"./chunk-
|
|
2
|
-
export{
|
|
1
|
+
import{e}from"./chunk-bshgrwe9.js";import{Alert as s,AlertDescription as a,AlertTitle as p}from"@nyssance/shadcn/vega/components/ui/alert";import{Button as m}from"@nyssance/shadcn/vega/components/ui/button";import{jsx as t,jsxs as c}from"react/jsx-runtime";function Ps({connection:n,error:i,onReconnect:r,className:l="mx-auto w-full max-w-3xl px-6 pt-12"}){let{t:o}=e().host;if(n!=="failed"&&n!=="disconnected")return null;return t("div",{className:l,children:c(s,{variant:"destructive",children:[t(p,{children:n==="failed"?o("connection.failed"):o("connection.disconnected")}),c(a,{className:"flex flex-wrap items-center gap-2",children:[i!==null&&t("span",{className:"font-mono",children:i}),t(m,{size:"sm",variant:"outline",onClick:r,children:o("connection.reconnect")})]})]})})}
|
|
2
|
+
export{Ps};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c}from"./chunk-wf7kfk3p.js";import{vs}from"./chunk-zsrjzx7g.js";import{ae}from"./chunk-
|
|
1
|
+
import{c}from"./chunk-wf7kfk3p.js";import{vs}from"./chunk-zsrjzx7g.js";import{ae}from"./chunk-f9z37ptq.js";import{M}from"./chunk-pxv38ttf.js";import{isContentEntry as b,isImage as N,isResourceLink as w}from"@nyssance/codex-acp-v2/client";import{ChevronRightIcon as C,ImageIcon as S,LoaderCircleIcon as A,RefreshCwIcon as R}from"lucide-react";import{useEffect as T,useState as v}from"react";import{jsx as r,jsxs as f}from"react/jsx-runtime";function st(e){return e.type==="tool_use"&&e.name==="view_image"&&e.status==="completed"}function B(e){let s=[];for(let[n,l]of e.content.entries()){if(!b(l))continue;let i=l.content;if(N(i))s.push({key:`${e.id}:${n}`,src:`data:${i.mimeType};base64,${i.data}`,alt:e.title??""});if(w(i))s.push({key:`${e.id}:${n}`,path:i.uri,alt:i.name})}if(s.length)return s;let a=e.rawInput;if(a!==null&&typeof a==="object"&&"path"in a&&typeof a.path==="string")return[{key:e.id,path:a.path,alt:a.path.split(/[\\/]/).at(-1)??a.path}];throw Error(`Image view ${e.id} has no image source`)}function E({images:e}){let{loadImage:s,openImageGallery:a,openImage:n,t:l}=c(),i=ae(),[g,y]=v({}),[x,I]=v(0),h=JSON.stringify(e);T(()=>{let t=!0,m=JSON.parse(h);y({});for(let o of m)(o.src!==void 0?Promise.resolve(o.src):o.path!==void 0&&s?s(vs(o.path,i)):Promise.reject(Error("Image loading is unavailable"))).then((u)=>{if(t)y((p)=>({...p,[o.key]:{src:u}}))},()=>{if(t)y((u)=>({...u,[o.key]:{error:!0}}))});return()=>{t=!1}},[h,s,i,x]);let k=e.flatMap((t)=>{let m=g[t.key];return m&&"src"in m?[{src:m.src,alt:t.alt}]:[]});return r("div",{className:"codex-image-thumbnails",children:e.map((t,m)=>{let o=g[t.key];if(!o)return r("div",{className:"codex-image-thumbnail",role:"status","aria-label":l("stream.codex.imageLoading"),children:r(A,{className:"motion-safe:animate-spin","aria-hidden":"true"})},t.key);if("error"in o)return r("button",{type:"button",className:"codex-image-thumbnail",title:t.alt,"aria-label":l("stream.codex.imageFailed"),onClick:()=>I((d)=>d+1),children:r(R,{"aria-hidden":"true"})},t.key);return r("button",{type:"button",className:"codex-image-thumbnail",title:t.alt,onClick:()=>{let d=e.slice(0,m).filter((u)=>{let p=g[u.key];return p&&"src"in p}).length;if(a)a(k,d);else n?.(o.src)},children:r("img",{src:o.src,alt:t.alt,draggable:!1})},t.key)})})}function fs({blocks:e}){let{t:s}=c(),a=e.flatMap(B),[n,l]=M(`image-view:${e[0].id}`,!1);return f("div",{className:"codex-activity-item",children:[f("button",{type:"button",className:"codex-activity-header","data-codex-disclosure":"","aria-expanded":n,onClick:()=>l((i)=>!i),children:[f("span",{className:"codex-activity-label",children:[r(S,{className:"codex-activity-icon","aria-hidden":"true"}),r("span",{className:"codex-activity-leading",children:s("stream.codex.viewedImages",{count:a.length})})]}),r(C,{className:n?"codex-image-chevron codex-image-chevron-open":"codex-image-chevron","aria-hidden":"true"})]}),n&&r(E,{images:a})]})}
|
|
2
2
|
export{st,fs};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{M}from"./chunk-pxv38ttf.js";import{o}from"./chunk-
|
|
1
|
+
import{M}from"./chunk-pxv38ttf.js";import{o}from"./chunk-f9z37ptq.js";import{mt}from"./chunk-cer4dxas.js";import{x,Y}from"./chunk-p8cm3xw1.js";import{e}from"./chunk-bshgrwe9.js";import{Jn}from"./chunk-bane0xc8.js";import{ChevronDownIcon as A,ChevronRightIcon as G,GitBranchIcon as X,Loader2Icon as F,SquareIcon as Z}from"lucide-react";import{useCallback as ss,useEffect as es,useId as J,useRef as L,useState as N}from"react";import{Button as C}from"@nyssance/shadcn/vega/components/ui/button";import{jsx as t,jsxs as p,Fragment as as}from"react/jsx-runtime";function Qn(s,l){let d=o((u)=>u.sessions),r=o((u)=>u.actions),[S,m]=N(()=>new Set);return(u)=>{let c=l?.(u)??null,a=Jn(s.id,u,d,r,s);if(a.length===0)return c;let h=`${s.id}:${u.key}`;return{active:c?.active===!0||a.some((i)=>i.status==="running"||i.status==="requires_action"),defaultExpanded:c?.defaultExpanded===!0||S.has(h),content:p(as,{children:[t(Xo,{sessionId:s.id,turn:u,parent:s,tasks:a,onExpand:()=>m((i)=>i.has(h)?i:new Set([...i,h]))}),c?.content]})}}}function Xo({sessionId:s,turn:l,parent:d,tasks:r,onExpand:S}){let{host:m}=e(),u=o((n)=>n.sessions),c=o((n)=>n.actions),a=r??Jn(s,l,u,c,d),h=a.some((n)=>n.status==="running"),i=a.some((n)=>n.status==="running"||n.status==="requires_action"),[f,k]=M(`subagents:${s}:${l.key}`,i,!0),w=J();if(a.length===0)return null;let g=new Map;for(let n of a)g.set(n.status,(g.get(n.status)??0)+1);let v=[...g].map(([n,E])=>`${m.t(`subagents.${n}`)} ${E}`).join(" · ");return p("section",{"data-subagent-sessions":!0,"data-subagent-turn":l.key,"aria-label":m.t("subagents.group"),className:"my-2 min-w-0",children:[p(C,{variant:"ghost",size:"sm",className:"text-muted-foreground h-auto min-h-8 max-w-full justify-start gap-2 text-xs","aria-expanded":f,"aria-controls":w,onClick:()=>{if(!f)S?.();k(!f)},children:[f?t(A,{className:"size-3.5 shrink-0"}):t(G,{className:"size-3.5 shrink-0"}),h?t(F,{className:"size-3.5 shrink-0 motion-safe:animate-spin","aria-hidden":"true"}):t(X,{className:"size-3.5 shrink-0"}),p("span",{className:"shrink-0",children:[m.t("subagents.group")," · ",a.length]}),t("span",{className:"truncate",role:"status",children:v})]}),t("div",{id:w,hidden:!f,className:"border-border ms-3 min-w-0 border-s ps-2",children:a.map((n)=>t(ts,{task:n,cwd:d?.cwd??u[s]?.cwd??"",visible:f,stateKey:`${s}:${l.key}:${n.key}`,onRead:()=>{S?.(),k(!0)}},n.key))})]})}function O(s,l){if(!l)return s;let d=new Map(s.items.map((r)=>[`${r.kind}:${r.id}`,r]));for(let r of l.items)d.set(`${r.kind}:${r.id}`,r);return{...s,...l,items:[...d.values()]}}function ts({task:s,cwd:l,stateKey:d,visible:r,onRead:S}){let{client:m,host:u}=e(),{t:c}=u,a=s.session,h=o((b)=>b.connection==="ready"),[i,f]=M(`subagent:${d}`,!1),[k,w]=N(!1),[g,v]=N(null),[n,E]=N(null),[I,Q]=N(null),[R,P]=N(!1),B=L(!1),_=L(!1),j=J(),q=a&&x(a.configOptions,"model"),z=s.title??c("subagents.untitled"),W=n?O(n,a):a,U=h&&a?.attached&&a.subagent?.capabilities?.cancel!=null&&(s.status==="running"||s.status==="requires_action"),H=s.threadId,D=a?.cwd??l,T=ss(async(b)=>{if(!m.readSubagentHistory||H===null||B.current)return;_.current=!0,B.current=!0,P(!0),v(null);try{let y=await m.readSubagentHistory(H,D,b);E((K)=>K===null?y.session:O(y.session,K)),Q(y.cursor)}catch(y){v(y instanceof Error?y.message:String(y))}finally{B.current=!1,P(!1)}},[m,H,D]);es(()=>{if(r&&i&&!_.current)T(null)},[r,i,T]);let V=async()=>{if(!a)throw Error("A live child session is required for cancellation");w(!0),v(null);try{await m.cancel(a.id)}catch(b){v(b instanceof Error?b.message:String(b))}finally{w(!1)}};return p("section",{"aria-label":z,className:"min-w-0",children:[p("div",{className:"flex min-w-0 items-center gap-1",children:[p(C,{variant:"ghost",size:"sm",className:"min-w-0 flex-1 justify-start gap-2","aria-label":`${z} · ${c(`subagents.${s.status}`)}`,"aria-expanded":i,"aria-controls":j,onClick:()=>{if(!i)S();f(!i)},children:[i?t(A,{className:"size-3.5 shrink-0"}):t(G,{className:"size-3.5 shrink-0"}),t("span",{className:"truncate",children:z}),t("span",{className:"text-muted-foreground ms-auto shrink-0 text-xs",role:"status",children:c(`subagents.${s.status}`)})]}),U&&t(C,{variant:"ghost",size:"icon-sm",disabled:k,"aria-label":c("subagents.cancel",{name:z}),onClick:()=>{V()},children:k?t(F,{className:"size-3.5 animate-spin"}):t(Z,{className:"size-3.5"})})]}),g&&!i&&t("p",{role:"alert",className:"text-destructive px-2 py-1 text-xs",children:g}),p("div",{id:j,hidden:!i,className:"min-w-0 ps-4",children:[(s.description||q)&&p("div",{className:"text-muted-foreground flex min-w-0 items-center gap-2 px-2 py-1 text-xs",children:[t("span",{className:"min-w-0 flex-1 truncate",title:s.description??void 0,children:s.description}),q&&t("span",{className:"shrink-0",children:Y(q)})]}),g&&p("div",{role:"alert",className:"text-destructive px-2 py-1 text-xs",children:[g," ",s.threadId&&t(C,{variant:"ghost",size:"sm",onClick:()=>{T(n===null?null:I)},children:c("timeline.retry")})]}),R&&t("p",{role:"status",className:"text-muted-foreground px-2 py-2 text-xs",children:c("timeline.loadingEarlier")}),I&&t(C,{variant:"ghost",size:"sm",disabled:R,onClick:()=>{T(I)},children:c("timeline.loadEarlier")}),r&&i&&(W&&W.items.length>0?t("div",{className:"flex max-h-72 min-h-0 flex-col",children:t(ns,{session:W})}):!R&&!g&&t("p",{className:"text-muted-foreground px-2 py-3 text-xs",children:c("subagents.noMessages")}))]})]})}function ns({session:s}){let{client:l,host:d}=e(),r=Qn(s);return t(mt,{session:s,client:l,host:d,turnWork:r})}
|
|
2
2
|
export{Qn,Xo};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{d,i}from"./chunk-
|
|
1
|
+
import{d,i}from"./chunk-mcrd86tx.js";import{q,K,ce,W,Z,_e}from"./chunk-5d138vq3.js";import{Se}from"./chunk-mtn6vdf8.js";import{k}from"./chunk-qk1yqepm.js";import{ke}from"./chunk-a6ysp1fp.js";import{Q,Pe}from"./chunk-e04g26qm.js";import{CheckIcon as O,SparklesIcon as A,XIcon as U}from"lucide-react";import{useDeferredValue as V,useState as y}from"react";import{Button as N}from"@nyssance/shadcn/vega/components/ui/button";import{Dialog as F,DialogClose as X,DialogContent as _,DialogDescription as J,DialogHeader as R,DialogTitle as Y}from"@nyssance/shadcn/vega/components/ui/dialog";import{ItemTitle as ee}from"@nyssance/shadcn/vega/components/ui/item";import{Spinner as te}from"@nyssance/shadcn/vega/components/ui/spinner";import{Switch as ae}from"@nyssance/shadcn/vega/components/ui/switch";import{Tabs as se,TabsContent as ne,TabsList as le,TabsTrigger as ie}from"@nyssance/shadcn/vega/components/ui/tabs";import{jsx as t,jsxs as n,Fragment as S}from"react/jsx-runtime";function T({skill:r}){let{assetUrl:p}=d(),[u,s]=y(!1),l=r.interface?.iconSmall,h=l&&p?p(l):r.interface?.iconSmallUrl;return t("div",{className:"bg-muted flex size-10 shrink-0 items-center justify-center rounded-xl",children:h&&!u?t("img",{src:h,alt:"",onError:()=>s(!0),className:"size-6 rounded object-contain"}):t(A,{className:"text-muted-foreground size-6"})})}function oe({skill:r}){let{t:p}=d(),u=i((l)=>l.setSkillEnabled),s=i((l)=>(r.path in l.busySkills));return n("div",{className:"flex items-center gap-2",children:[s&&t(te,{className:"text-muted-foreground size-3.5"}),t(ae,{checked:r.enabled,disabled:s,"aria-label":`${p(r.enabled?"plugins.skills.disable":"plugins.skills.enable")}: ${r.interface?.displayName??r.name}`,onCheckedChange:(l)=>void u(r,l)})]})}function en({query:r,ready:p,onOpenPlugin:u}){let{t:s}=d(),l=i((e)=>e.skills),h=i((e)=>e.skillErrors),P=i((e)=>e.loading)||!p,j=i((e)=>e.installed),z=i((e)=>e.skillProjects),[M,E]=y(null),[v,L]=y(!1),[B,C]=y(null),b=V(r.trim().toLowerCase()),o=l.find((e)=>e.path===B),x=j.find(({plugin:e})=>e.id===o?.pluginId),c=l.filter((e)=>[e.name,e.interface?.displayName,e.description,e.shortDescription,e.interface?.shortDescription,e.pluginId].filter(Boolean).join(" ").toLowerCase().includes(b)).toSorted((e,a)=>(e.interface?.displayName??e.name).localeCompare(a.interface?.displayName??a.name)),m=[...["user","system","admin"].flatMap((e)=>{let a=l.filter((f)=>f.scope===e);return a.length?[{id:e,label:s(e==="user"?"plugins.catalog.personal":`plugins.skills.scope.${e}`),paths:new Set(a.map((f)=>f.path)),path:null}]:[]}),...Object.entries(z).flatMap(([e,a])=>{if(!l.some((I)=>I.scope==="repo"&&a.includes(I.path)))return[];let f=e.replace(/[\\/]+$/,"").split(/[\\/]/).at(-1)||e;return[{id:`project:${e}`,label:f,paths:new Set(a),path:e}]})],H=m.map((e)=>e.label);for(let e of m)if(e.path&&H.filter((a)=>a===e.label).length>1)e.label=e.path;let g=m.find((e)=>e.id===M)??m[0],D=g?c.filter((e)=>g.paths.has(e.path)):[],G=v||b?c:c.slice(0,6),w=(e)=>t(Z,{className:"grid grid-cols-1 gap-x-8 gap-y-2 px-0 @min-[700px]:grid-cols-2",children:e.map((a)=>n(_e,{className:"toolbox-row relative [contain-intrinsic-size:auto_80px] [content-visibility:auto]",children:[t(N,{variant:"ghost",className:"absolute inset-0 z-0 size-full","aria-label":a.interface?.displayName??a.name,onClick:()=>C(a.path)}),t(W,{className:"pointer-events-none relative translate-none! self-center!",children:t(T,{skill:a})}),n(K,{className:"pointer-events-none relative min-w-0",children:[t(ee,{className:"block truncate",children:a.interface?.displayName??a.name}),t(ce,{className:"line-clamp-1",title:a.interface?.shortDescription??a.shortDescription??a.description,children:a.interface?.shortDescription??a.shortDescription??a.description})]}),t(q,{className:"text-muted-foreground pointer-events-none relative",children:a.enabled?t(O,{className:"size-4","aria-label":s("plugins.skills.enabledStatus")}):t("span",{className:"text-xs",children:s("plugins.skills.disabledBadge")})})]},a.path))});return n("div",{className:"flex min-h-0 flex-1 flex-col gap-4",children:[t(k,{className:"pe-0",viewportClassName:"pe-0",children:n("div",{className:`${Q} space-y-8 pt-6`,children:[h.map((e)=>n("p",{role:"alert",className:"text-destructive text-xs break-words",children:[e.path,": ",e.message]},e.path)),P?t(Se,{skills:!0}):n(S,{children:[n("section",{"aria-label":s("plugins.skills.installed"),children:[n("div",{className:"mb-4 flex items-center justify-between gap-3",children:[t("h2",{className:"text-base font-medium",children:s("plugins.skills.installed")}),t("span",{role:"status",className:"text-muted-foreground text-xs",children:s("plugins.catalog.skillCount",{count:c.length})})]}),c.length?w(G):t("p",{className:"text-muted-foreground px-2 py-8 text-sm",children:s(b?"plugins.skills.filteredEmpty":"plugins.skills.empty")}),!b&&c.length>6&&t(N,{variant:"ghost",className:"text-muted-foreground mt-3 max-w-full justify-start","aria-expanded":v,onClick:()=>L((e)=>!e),children:v?s("plugins.sections.showLess"):s("plugins.catalog.showMore",{count:c.length-6})})]}),g&&n(se,{value:g.id,onValueChange:(e)=>{if(typeof e==="string")E(e)},className:"gap-6",children:[t(le,{"aria-label":s("plugins.catalog.scope"),className:"h-auto max-w-full flex-wrap justify-start gap-2 bg-transparent",children:m.map((e)=>t(ie,{value:e.id,title:e.path??e.label,className:"data-active:bg-muted! h-8 flex-none rounded-lg px-3 text-[13px] font-medium shadow-none! after:hidden dark:data-active:border-transparent",children:e.label},e.id))}),m.map((e)=>t(ne,{value:e.id,children:e.id===g.id&&(D.length?w(D):t("p",{className:"text-muted-foreground px-2 py-8 text-sm",children:s("plugins.skills.filteredEmpty")}))},e.id))]})]})]})}),t(F,{open:!!o,onOpenChange:(e)=>{if(!e)C(null)},children:t(_,{showCloseButton:!1,className:Pe,children:o&&n(S,{children:[t(ke,{path:o.path,renderHeader:(e)=>n(S,{children:[n("div",{className:"flex items-center justify-between gap-4",children:[t(T,{skill:o}),n("div",{className:"flex shrink-0 items-center gap-2",children:[t(oe,{skill:o}),e,t(X,{render:t(N,{variant:"ghost",size:"icon-sm","aria-label":s("plugins.close")}),children:t(U,{})})]})]}),n(R,{className:"gap-3",children:[t(Y,{className:"text-2xl leading-8 font-semibold break-words",children:o.interface?.displayName??o.name}),t(J,{className:"text-sm leading-6 break-words whitespace-pre-wrap",children:o.description})]})]})},o.path),o.pluginId&&n("div",{className:"text-sm",children:[n("span",{className:"text-muted-foreground",children:[s("plugins.catalog.fromPlugin")," "]}),x?t(N,{variant:"link",className:"h-auto p-0",onClick:()=>{C(null),u(x)},children:x.plugin.interface?.displayName??x.plugin.name}):o.pluginId]})]})})})]})}
|
|
2
2
|
export{en};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ys}from"./chunk-wf7kfk3p.js";import{createContext as s,useContext as i,useSyncExternalStore as m}from"react";import{jsx as l}from"react/jsx-runtime";var u=s(null),c=s(null),Zo=s(null);function ae(){return i(Zo)}function $e({host:e,client:n,children:r}){return l(ys,{host:e,children:l(u,{value:e,children:l(c,{value:n,children:r})})})}function t(){let e=i(u);if(e===null)throw Error("Timeline host is missing");return e}function qe(){let e=i(c);if(e===null)throw Error("Timeline client is missing");return e}function
|
|
2
|
-
export{Zo,ae,$e,t,qe,
|
|
1
|
+
import{ys}from"./chunk-wf7kfk3p.js";import{createContext as s,useContext as i,useSyncExternalStore as m}from"react";import{jsx as l}from"react/jsx-runtime";var u=s(null),c=s(null),Zo=s(null);function ae(){return i(Zo)}function $e({host:e,client:n,children:r}){return l(ys,{host:e,children:l(u,{value:e,children:l(c,{value:n,children:r})})})}function t(){let e=i(u);if(e===null)throw Error("Timeline host is missing");return e}function qe(){let e=i(c);if(e===null)throw Error("Timeline client is missing");return e}function y(e,n){return m((r)=>e.subscribe(r),()=>n(e.getState()),()=>n(e.getState()))}function o(e){let n=qe();return y(n.store,e)}function Qo(){return i(u)!==null}function le(e,n){if(e.reportError)e.reportError(n);else console.error(n)}
|
|
2
|
+
export{Zo,ae,$e,t,qe,y,o,Qo,le};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{be}from"./chunk-x4enakra.js";import{
|
|
1
|
+
import{be}from"./chunk-x4enakra.js";import{w}from"./chunk-0myf2ak0.js";import{t,le}from"./chunk-f9z37ptq.js";import{isEmbeddedResource as T,isImage as y,isResourceLink as L}from"@nyssance/codex-acp-v2/client";import{DownloadIcon as U,FileIcon as I,ImageOffIcon as z,LoaderCircleIcon as j}from"lucide-react";import{useState as C}from"react";import{Button as c}from"@nyssance/shadcn/vega/components/ui/button";import{jsx as n,jsxs as s}from"react/jsx-runtime";function Wn(e){let r=e.split(/[\\/]/).at(-1)??e;if(e.startsWith("file:")||/^https?:/.test(e))r=new URL(e).pathname.split("/").at(-1)??"";try{return decodeURIComponent(r)||"attachment"}catch(a){if(a instanceof URIError)return r||"attachment";throw a}}function Bo(e,r){let a=document.createElement("a");a.href=r,a.download=e,a.click()}function F({block:e,generated:r=!1}){let a=t(),[d,f]=C(!1),[R,B]=C(null);if(L(e)){let p=w(e.uri);if(p!==null)return n(be,{app:{id:p,name:e.title??e.name}});if(e.uri==="codex-image:unavailable")return s("span",{className:"text-muted-foreground flex items-center gap-2 rounded-lg border p-3 text-sm",children:[n(z,{className:"size-4"}),a.t("timeline.imageUnavailable")]});let u=Wn(e.uri);return s(c,{variant:"outline",className:"h-auto max-w-full min-w-0 justify-start gap-3 overflow-hidden p-3","aria-label":e.title??e.name,title:e.uri,onClick:()=>a.openLink(e.uri),children:[n(I,{}),s("span",{className:"min-w-0 flex-1 text-start",children:[n("span",{className:"block truncate",children:e.title??e.name}),s("span",{className:"text-muted-foreground block truncate text-xs",children:[(e.title??e.name)!==u&&`${u} · `,e.mimeType??u.split(".").at(-1)?.toUpperCase()]})]})]})}if(!T(e)&&!y(e))return null;let i=y(e)?{uri:e.uri??`image.${e.mimeType.split("/")[1]??"png"}`,mimeType:e.mimeType,blob:e.data}:e.resource,o=Wn(i.uri);if("text"in i)return s("div",{className:"min-w-0",children:[n("pre",{className:"overflow-x-auto whitespace-pre-wrap",children:i.text}),s(c,{variant:"link",size:"sm",className:"max-w-full min-w-0",title:i.uri,onClick:()=>a.openLink(i.uri),children:[n(I,{}),n("span",{className:"truncate",children:o})]})]});let m=`data:${i.mimeType??"application/octet-stream"};base64,${i.blob}`,g=i.mimeType?.toLowerCase().startsWith("image/")&&R!==m,{openImage:x,openImageGallery:v}=a,h=v?()=>v([{src:m,alt:o,uri:i.uri}],0):x&&(()=>x(m)),l=r&&g,E=async()=>{f(!0);try{if(a.saveFile)await a.saveFile(o,i.blob);else Bo(o,m)}catch(p){le(a,p)}finally{f(!1)}},N=n("img",{src:m,alt:"",className:r?"max-h-[40rem] max-w-full object-contain":"max-h-96 max-w-full rounded object-contain",onError:()=>B(m)});return s("div",{className:l?"codex-generated-image":"flex max-w-full min-w-0 flex-col items-start gap-1",children:[g&&(h===void 0?N:n(c,{variant:"ghost",className:r?"codex-generated-image-preview h-auto max-w-full p-0":"h-auto max-w-full p-0","aria-label":a.t("timeline.viewImage"),onClick:h,children:N})),s(c,{variant:l?"secondary":"link",size:l?"icon":"sm",className:l?"codex-generated-image-download":"max-w-full min-w-0",disabled:d,title:a.t("timeline.download",{name:o}),"aria-label":a.t("timeline.download",{name:o}),onClick:()=>{E()},children:[d?n(j,{className:"motion-safe:animate-spin"}):n(U,{}),!l&&n("span",{className:"truncate",children:o})]})]})}
|
|
2
2
|
export{Wn,Bo,F};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{o}from"./chunk-
|
|
1
|
+
import{o}from"./chunk-f9z37ptq.js";import{mt}from"./chunk-cer4dxas.js";import{e,b}from"./chunk-bshgrwe9.js";import{Qn}from"./chunk-eqbp85f3.js";import{Loader2Icon as v}from"lucide-react";import{Button as x}from"@nyssance/shadcn/vega/components/ui/button";import{Empty as c,EmptyDescription as l,EmptyHeader as d,EmptyTitle as f}from"@nyssance/shadcn/vega/components/ui/empty";import{jsx as r,jsxs as i}from"react/jsx-runtime";function Gt({session:t,timeline:s}){let{host:m,client:a}=e(),{t:n}=m,u=o((h)=>h.historyPages[t.id]?.cursor!=null),y=Qn(t,s?.turnWork),E=()=>b(m,a.open(t.id,t.cwd)),p=r(mt,{...s,session:t,client:a,host:m,turnWork:y});if(t.restoring)return t.items.length===0?i("div",{className:"text-muted-foreground flex flex-1 items-center justify-center gap-2 text-sm",children:[r(v,{className:"size-4 animate-spin","aria-hidden":"true"}),n("conversation.restoring")]}):p;if(!t.attached&&t.items.length===0)return i(c,{className:"flex-1",children:[i(d,{children:[r(f,{children:n("conversation.reopen")}),r(l,{children:n("conversation.detached")})]}),r(x,{onClick:E,children:n("conversation.reopen")})]});if(t.items.length===0&&t.state==="idle"&&!u)return r(c,{className:"flex-1",children:i(d,{children:[r(f,{className:"text-[28px] font-normal",children:n("conversation.welcomeTitle")}),r(l,{className:"truncate font-mono",children:t.cwd})]})});return p}
|
|
2
2
|
export{Gt};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{t}from"./chunk-
|
|
1
|
+
import{t}from"./chunk-f9z37ptq.js";import{Vo,jo}from"./chunk-ww3f6z4x.js";import{D}from"./chunk-50eym2q3.js";import{Pt}from"./chunk-b42vv8f2.js";import{ro}from"./chunk-vx6shb4g.js";import{Mi,de,ft,Ai}from"./chunk-stc4ctrx.js";import{to}from"./chunk-84eye2j0.js";import{Me}from"./chunk-6w8p1hwb.js";import{no}from"./chunk-7v7wc7k5.js";import{lo}from"./chunk-bgav9cq2.js";import{wi}from"./chunk-wyxa2tfm.js";import{xi}from"./chunk-t686zwxk.js";import{yi}from"./chunk-d29xbf16.js";import{Ci}from"./chunk-wwj743gm.js";import{oo,io}from"./chunk-mfn37eme.js";import{gt}from"./chunk-rb4p3h5b.js";import{codexMessageError as q,codexTurnError as z,isContentEntry as me,isEmbeddedResource as Z,isImage as ee,isResourceLink as le,isText as ce,nativeTurnId as ge}from"@nyssance/codex-acp-v2/client";import{SparklesIcon as ue}from"lucide-react";import{Fragment as X,memo as pe,useEffect as fe,useState as ye}from"react";import{jsx as i,jsxs as m,Fragment as A}from"react/jsx-runtime";function Y(s){if(ee(s))return`${s.mimeType.toLowerCase()}:${s.data}`;if(Z(s)&&"blob"in s.resource&&s.resource.mimeType?.toLowerCase().startsWith("image/"))return`${s.resource.mimeType.toLowerCase()}:${s.resource.blob}`;return null}function he({item:s}){let{t:n}=t(),l=s.status==="in_progress",[o,g]=ye(()=>Date.now()-s.at>=1e4);return fe(()=>{if(!l)return;let a=Math.max(0,s.at+1e4-Date.now());if(g(a===0),a===0)return;let h=setTimeout(()=>g(!0),a);return()=>clearTimeout(h)},[s.id,s.at,l]),m("div",{className:"codex-context-compaction",children:[i(ue,{"aria-hidden":"true"}),i("span",{children:s.status==="completed"?n("stream.codex.contextCompacted"):s.status==="cancelled"?n("timeline.interrupted"):n(o?"timeline.compactingWithDelayNotice":"timeline.compacting")})]})}function N({sessionId:s,entry:n,terminals:l,streaming:o,streamingThoughtId:g}){let{t:a}=t();switch(n.kind){case"activity":return i(to,{sessionId:s,items:n.items,terminals:l,streamingThoughtId:g});case"text":return D(n.item._meta).length>0?i(lo,{sessionId:s,item:n.item}):i(Me,{content:n.item.content,messageId:n.item.id,streaming:o});case"plan":return i(yi,{plan:n.item.plan});case"compaction":if(n.item.status==="failed")return m(oo,{children:[i("div",{children:a("timeline.compactionFailed")}),n.item.error!==null&&i("div",{children:n.item.error})]});return i(he,{item:n.item})}}function ke({sessionId:s,turn:n,terminals:l,active:o,blocked:g=!1,continued:a=!1,edits:h=n.edits,activityItems:M=n.items,workStartedAt:te=n.startedAt,isLast:F,error:k,interrupted:L,retry:P,retrying:p,extraWork:d=null,answerActions:G,footer:ne}){let{t:c}=t(),b=n.errors.map((e)=>{let r=q(e);if(r===null)throw Error("Turn error item is missing its diagnostics");let E=P?.turnId===ge(e)?P:void 0;return i(io,{error:r,retry:E},`${e.id}:${E?.delaySeconds??"manual"}`)});if(F&&k!==null&&!n.errors.some((e)=>{let r=q(e);return r!==null&&r.stopReason===k.stopReason&&z(r).message===z(k).message}))b.push(i(io,{error:k},"current-run-error"));let x=b.length>0?i("div",{className:"codex-turn-errors",children:b}):null,C=n.items.filter(ro);if(d===null&&C.length>0&&C.length===n.items.length)return m(A,{children:[i(to,{sessionId:s,items:C,terminals:l,streamingThoughtId:null}),x]});let T=n.work,w=T.length>0&&T.every((e)=>e.kind==="compaction");if(d===null&&(Mi(n)||w&&n.final.length===0))return m(A,{children:[i("div",{role:"status",className:"text-muted-foreground flex min-w-0 flex-col gap-2 py-2 text-sm",children:n.work.map((e)=>i(N,{sessionId:s,entry:e,terminals:l,streaming:!1,streamingThoughtId:null},e.key))}),x]});let O=ft(n),W=n.final.filter((e)=>D(e._meta).length===0).map((e)=>de({...e,content:no(e.content,n.items)})).join(`
|
|
2
2
|
`),I=o?null:gt(n,"assistant"),B=n.items.filter((e)=>e.kind==="tool"&&(e.name==="image_generation"||e.name==="alwith_client_generate_image"||e.name==="generate_image"||e.name?.endsWith(".generate_image"))&&(e.status==="pending"||e.status==="in_progress")),H=new Set(n.final.flatMap((e)=>e.content.map(Y).filter((r)=>r!==null))),f=n.items.flatMap((e)=>{if(!Pt(e))return[];return e.content.filter(me).flatMap((r,E)=>{let u=r.content,oe=ee(u),ae=le(u)||Z(u)&&"blob"in u.resource;if(!oe&&!ae)return[];let S=Y(u);if(S!==null){if(H.has(S))return[];H.add(S)}return[{key:`${e.id}:${E}`,block:u}]})}),K=n.final.some((e)=>D(e._meta).length===0&&e.content.some((r)=>!ce(r)||r.text.trim().length>0)),ie=B.length>0||f.length>0||w||K||n.final.some((e)=>D(e._meta).length>0),v=n.items.findIndex((e)=>n.final.includes(e)),R=(e)=>n.items.indexOf(e.kind==="activity"?e.items[0]:e.item),Q=T.filter((e)=>v===-1||R(e)<v),se=T.filter((e)=>v!==-1&&R(e)>v),re=[...n.final.map((e)=>({kind:"answer",item:e,index:n.items.indexOf(e)})),...se.map((e)=>({kind:"work",entry:e,index:R(e)}))].toSorted((e,r)=>e.index-r.index),V=!o&&!a&&(W.trim().length>0?i(Vo,{text:W,isMostRecentTurn:F,time:I,afterCopy:G}):m("div",{className:"flex items-center gap-0.5",children:[G,I&&i("span",{className:"codex-user-time ms-1",title:I.full,children:I.short})]})),y=Ci({...n,items:M},{running:o,blocked:g,retrying:p!==void 0}),j=y.kind==="reasoning"?y.ownerKey??null:null,J=y.kind==="thinking",_=Ai({...n,items:M}),U=o&&!K||d?.active===!0;return m(A,{children:[i(jo,{stateKey:JSON.stringify([s,n.replayed?"history":"live",n.key]),active:U,defaultExpanded:U||d?.defaultExpanded===!0||!n.replayed&&(L||O),..._,durationMs:d?.active?void 0:_.durationMs,startedAt:_.startedAt??te,loading:(J||y.kind==="working")&&n.work.length===0&&d===null,loadingLabel:y.kind==="working"?c("stream.codex.working"):void 0,work:[...a||w?[]:Q.map((e)=>i(N,{sessionId:s,entry:e,terminals:l,streaming:o,streamingThoughtId:j},e.key)),...d===null?[]:[i(X,{children:d.content},"additional-work")]],answer:ie||a?m("div",{className:"flex min-w-0 flex-col gap-3",children:[(a||w)&&Q.map((e)=>i(N,{sessionId:s,entry:e,terminals:l,streaming:!1,streamingThoughtId:null},e.key)),re.map((e)=>{if(e.kind==="work")return i(N,{sessionId:s,entry:e.entry,terminals:l,streaming:o,streamingThoughtId:j},e.entry.key);let r=e.item;return m(X,{children:[D(r._meta).length>0?i(lo,{sessionId:s,item:r}):i(Me,{content:no(r.content,n.items),messageId:r.id,streaming:o}),r===n.final.at(-1)&&f.length===0&&V]},r.id)}),B.map((e)=>m("div",{className:"codex-image-generation",role:"status","aria-label":c(o?"timeline.imageGenerating":"timeline.imageStopped"),"aria-busy":o,children:[i("div",{className:"codex-image-generation-texture","aria-hidden":"true"}),m("span",{className:"codex-image-generation-status",children:[o&&i(xi,{startedAt:e.at}),!o&&c("timeline.imageStopped")]})]},e.id)),f.length>0&&i("div",{className:"codex-reply-artifacts flex min-w-0 flex-col gap-3",children:f.map((e)=>i(Me,{content:[e.block],messageId:e.key,streaming:!1},e.key))}),(n.final.length===0||f.length>0)&&V]}):null,footer:m(A,{children:[J&&n.work.length>0&&i("div",{className:"codex-pending-message py-2",role:"status",children:i("span",{className:"codex-activity-running",children:c("message.thinking")})}),ne,h.length>0&&!o&&!a&&i(wi,{items:h}),L&&!O&&i("div",{className:"codex-interrupted-turn",role:"status",children:c("timeline.interrupted")}),!o&&x]})}),o&&p!==void 0&&i("div",{className:"text-muted-foreground py-2 text-sm",role:"status",children:p.capacity?(()=>{let e=/Reconnecting(?:\.\.\.)?\s+(\d+\/\d+)/.exec(p.message)?.[1];return e===void 0?c("timeline.capacityReconnecting"):c("timeline.capacityReconnectingProgress",{progress:e})})():p.message}),o&&x]})}var vi=pe(ke);
|
|
3
3
|
export{vi};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t,le}from"./chunk-
|
|
1
|
+
import{t,le}from"./chunk-f9z37ptq.js";import{Bo}from"./chunk-geh3wyxw.js";import{Uo,Yr}from"./chunk-1e83qr49.js";import{es}from"./chunk-rff6c87z.js";import{Code as P,Copy as I,Download as k,Eye as B,Maximize2 as L,MoreHorizontal as H,X as O}from"lucide-react";import{useEffect as R,useId as V,useMemo as _,useRef as F,useState as u}from"react";import{Button as w}from"@nyssance/shadcn/vega/components/ui/button";import{Dialog as A,DialogClose as U,DialogContent as X}from"@nyssance/shadcn/vega/components/ui/dialog";import{DropdownMenu as j,DropdownMenuContent as q,DropdownMenuItem as y,DropdownMenuTrigger as G}from"@nyssance/shadcn/vega/components/ui/dropdown-menu";import{jsx as o,jsxs as l,Fragment as K}from"react/jsx-runtime";function J(m){let r=getComputedStyle(m),e=document.createElement("canvas").getContext("2d");if(!e)throw Error("Unable to resolve diagram colors");let i=(p)=>{e.clearRect(0,0,1,1),e.fillStyle=r.backgroundColor,e.fillRect(0,0,1,1),e.fillStyle=p,e.fillRect(0,0,1,1);let[n,s,d]=e.getImageData(0,0,1,1).data;return`#${[n,s,d].map((f)=>f.toString(16).padStart(2,"0")).join("")}`};return{background:i(r.backgroundColor),primaryColor:i(r.getPropertyValue("--muted").trim()),primaryTextColor:i(r.color),primaryBorderColor:i(r.getPropertyValue("--border").trim()),lineColor:i(r.getPropertyValue("--muted-foreground").trim())}}function Ho({source:m}){let r=t(),{t:e,theme:i}=r,p=`mermaid-${V().replaceAll(":","")}`,[n,s]=u(null),[d,f]=u(!1),[h,b]=u(!1),[v,C]=u(!1),[x,z]=u(!1),c=F(null),g=_(()=>n===null?null:Uo(n),[n]);R(()=>{let a=!1;return s(null),(async()=>{try{let M=await import("mermaid");if(a||c.current===null)return;let S=M.default;S.initialize({startOnLoad:!1,securityLevel:"strict",htmlLabels:!1,theme:"base",themeVariables:{...J(c.current),darkMode:i==="dark"}});let N=await S.render(p,m);if(!a)s(N.svg)}catch{if(!a)s(null)}})(),()=>{a=!0}},[p,i,m]);let T=async()=>{try{await(r.copyText?r.copyText(m):navigator.clipboard.writeText(m))}catch(a){if(r.onCopyError)r.onCopyError(a);else le(r,a)}},D=async()=>{if(n===null||c.current===null||v)return;C(!0);try{let a=await Yr(n,getComputedStyle(c.current).backgroundColor);if(r.saveFile)await r.saveFile("mermaid.png",a);else Bo("mermaid.png",`data:image/png;base64,${a}`)}catch(a){le(r,a)}finally{C(!1)}},E=o(w,{variant:"ghost",size:"icon-sm","aria-label":e("mermaid.downloadPng"),title:e("mermaid.downloadPng"),disabled:n===null||v,onClick:()=>void D(),children:o(k,{className:"size-4"})});return l("div",{ref:c,className:"group/mermaid bg-background relative my-3 min-w-0 rounded-lg",children:[l("div",{"data-open":x,className:"absolute top-2 right-2 z-10 flex gap-1 opacity-0 transition-opacity group-focus-within/mermaid:opacity-100 group-hover/mermaid:opacity-100 data-[open=true]:opacity-100 [@media(hover:none)]:opacity-100",children:[l(j,{open:x,onOpenChange:z,children:[o(G,{"aria-label":e("mermaid.options"),title:e("mermaid.options"),render:o(w,{variant:"ghost",size:"icon-sm"}),children:o(H,{className:"size-4"})}),l(q,{align:"end",className:"w-40",children:[l(y,{disabled:n===null,onClick:()=>f((a)=>!a),children:[d?o(B,{}):o(P,{}),d?e("mermaid.viewDiagram"):e("mermaid.viewSource")]}),l(y,{onClick:()=>void T(),children:[o(I,{}),e("mermaid.copySource")]}),l(y,{disabled:n===null||v,onClick:()=>void D(),children:[o(k,{}),e("mermaid.downloadPng")]})]})]}),o(w,{variant:"ghost",size:"icon-sm","aria-label":e("mermaid.expand"),title:e("mermaid.expand"),disabled:n===null,onClick:()=>b(!0),children:o(L,{className:"size-4"})})]}),d||n===null?o("pre",{className:"bg-muted/30 overflow-x-auto rounded-lg p-3 pt-11 text-xs",children:o("code",{children:m})}):o("div",{className:"overflow-x-auto rounded-lg px-3 pt-10 pb-3 [&_svg]:mx-auto [&_svg]:max-w-full",dangerouslySetInnerHTML:{__html:n}}),o(A,{open:h&&g!==null,onOpenChange:b,children:o(X,{showCloseButton:!1,className:"bg-background flex h-[calc(100dvh-clamp(1.5rem,10dvh,6rem))] w-[calc(100vw-clamp(1.5rem,10vw,8rem))] max-w-none flex-col gap-2 overflow-hidden p-2 sm:max-w-none sm:p-4",children:h&&g&&o(es,{image:g,t:e,actions:l(K,{children:[E,o(U,{"aria-label":e("mermaid.closePreview"),title:e("mermaid.closePreview"),render:o(w,{variant:"ghost",size:"icon-sm"}),children:o(O,{className:"size-4"})})]})},g.src)})})]})}
|
|
2
2
|
export{Ho};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{ge}from"./chunk-r7paw6ba.js";import{C}from"./chunk-zpqj0ka8.js";import{y}from"./chunk-f9z37ptq.js";import{cn}from"./chunk-jjgwfpmp.js";import{Ne}from"./chunk-5ryfm4ka.js";import{bn}from"./chunk-7xvrsw7x.js";import{Le}from"./chunk-s3j71dbh.js";import{Re}from"./chunk-whzs7yxf.js";import{xn}from"./chunk-bfb8bpwc.js";import{vn,yn}from"./chunk-1rwkdezk.js";import{jsx as t,jsxs as d,Fragment as u}from"react/jsx-runtime";var n;function P(){return n??=bn(),n}function f(){let o=cn();return t(yn,{sessionId:o.session.id,enabled:o.inputReady&&!o.sending&&!o.shellMode,onMention:o.addMention,onBusyChange:o.setAdding})}function zs({client:o,providers:m,catalog:i,shellCommands:p=!0,modelMenu:l,children:a,...s}){let{session:e}=s,c=y(o.store,(r)=>r.modelRecovery[e.id]??!1);return d(u,{children:[c&&!ge(e.error?.error)&&t(xn,{client:o,session:e,providers:m??P(),catalog:i},e.id),d(Ne,{modelMenu:l??{defaultGroup:C,catalog:(r)=>Le(r,i),headerAction:t(Re,{})},...s,attachmentPolicy:vn,onShellCommand:p?(r)=>o.executeShell(e.id,r):void 0,children:[t(f,{}),a]})]})}
|
|
2
|
+
export{zs};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{nn}from"./chunk-
|
|
1
|
+
import{nn}from"./chunk-s05ftq29.js";import{createContext as l,useContext as a,useEffect as p,useSyncExternalStore as u}from"react";import{jsx as o}from"react/jsx-runtime";var g=l(null),P=l(null),r=new WeakMap;function We(e){let t=r.get(e);if(!t)t=nn(e),r.set(e,t);return t}function Ds({host:e,client:t,children:n}){let s=We(t);return s.bindHost(e),p(()=>s.bindHost(e),[s,e]),o(g,{value:e,children:o(P,{value:t,children:n})})}function d(){let e=a(g);if(e===null)throw Error("Plugins host is missing");return e}function Ze(){let e=a(P);if(e===null)throw Error("Plugins client is missing");return e}function ut(e){let t=Ze();return u((n)=>t.store.subscribe(n),()=>e(t.store.getState()),()=>e(t.store.getState()))}function i(e){let t=We(Ze());return u((n)=>t.subscribe(n),()=>e(t.getState()),()=>e(t.getState()))}function Qe(e,t){return t.then(()=>{},(n)=>{if(e.reportError)e.reportError(n);else console.error(n)})}
|
|
2
2
|
export{We,Ds,d,Ze,ut,i,Qe};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{w,is}from"./chunk-0myf2ak0.js";import{isResourceLink as g,isText as v}from"@nyssance/codex-acp-v2/client";import{useRef as h}from"react";function Ui(o,m,x,y=!1){let i=h(null);return(t)=>{if(t.defaultPrevented||t.altKey||t.ctrlKey||t.metaKey||t.shiftKey||t.nativeEvent.isComposing||t.nativeEvent.keyCode===229||t.key!=="ArrowUp"&&t.key!=="ArrowDown")return;let n=t.currentTarget;if(n.selectionStart!==n.selectionEnd)return;let e=i.current;if(e&&(e.sessionId!==o.id||e.value!==n.value))i.current=null,e=null;let s=t.key==="ArrowUp";if(s?n.value.slice(0,n.selectionStart).includes(`
|
|
2
2
|
`):n.value.slice(n.selectionEnd).includes(`
|
|
3
3
|
`))return;if(!e){if(!s||n.value!==""||y)return;let u=o.items.flatMap((a)=>{if(a.kind!=="user")return[];let f=a.content.filter(v).map((l)=>l.text).join(`
|
|
4
|
-
`),p=a.content.filter(g).flatMap((l)=>{let d=
|
|
4
|
+
`),p=a.content.filter(g).flatMap((l)=>{let d=w(l.uri);return d===null?[]:[{id:d,name:l.name}]});return f.trim()||p.length?[{text:is(f,p),apps:p}]:[]});if(!u.length)return;e={sessionId:o.id,entries:u,index:u.length,value:""},i.current=e}t.preventDefault(),e.index=Math.max(0,Math.min(e.entries.length,e.index+(s?-1:1)));let c=e.entries[e.index],r=c?.text??"";if(x?.(c?.apps??[]),e.value=r,m(r),n.value=r,n.setSelectionRange(r.length,r.length),e.index===e.entries.length)i.current=null}}
|
|
5
5
|
export{Ui};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t}from"./chunk-
|
|
1
|
+
import{t}from"./chunk-f9z37ptq.js";import{codexTurnError as R}from"@nyssance/codex-acp-v2/client";import{AlertCircleIcon as C}from"lucide-react";import{useEffect as k,useRef as i,useState as s}from"react";import{Button as I}from"@nyssance/shadcn/vega/components/ui/button";import{jsx as n,jsxs as m}from"react/jsx-runtime";function oo({children:u}){return m("div",{className:"codex-error-message",role:"alert",children:[n(C,{"aria-hidden":"true"}),n("div",{className:"min-w-0 flex-1",children:u})]})}function io({error:u,retry:e}){let{t:f,turnErrorAction:T}=t(),c=R(u),[l]=s(()=>e?.delaySeconds==null?null:Date.now()+e.delaySeconds*1000),[p,v]=s(e?.delaySeconds??null),[h,y]=s(!1),[x,g]=s(null),o=i(!1),w=i(!1),E=i(e?.run);E.current=e?.run;let S=i((N)=>{let a=E.current;if(o.current||a===void 0)return;o.current=!0,y(!0),g(null),a(N).catch((r)=>{w.current=!0,o.current=!1,v(null),y(!1),g(r instanceof Error?r.message:String(r))})}),b=T?.(c),d=b===void 0&&e!==void 0&&c.retryable;return k(()=>{if(!d||l===null)return;let a=setInterval(()=>{if(w.current||o.current)return;let r=Math.max(0,Math.ceil((l-Date.now())/1000));if(v(r),r===0)S.current("automatic")},1000);return()=>clearInterval(a)},[l,d]),m(oo,{children:[m("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[n("div",{className:"min-w-0 flex-1 whitespace-pre-wrap",children:c.message}),b,d&&n(I,{variant:"outline",size:"sm",disabled:h,onClick:()=>S.current("manual"),children:p===null?f("timeline.retry"):f("timeline.retryCountdown",{seconds:p})})]}),x!==null&&n("div",{className:"text-muted-foreground mt-2 text-sm",children:x})]})}
|
|
2
2
|
export{oo,io};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{d}from"./chunk-
|
|
1
|
+
import{d}from"./chunk-mcrd86tx.js";import{q,K,W,Z}from"./chunk-5d138vq3.js";import{Item as i}from"@nyssance/shadcn/vega/components/ui/item";import{Skeleton as s}from"@nyssance/shadcn/vega/components/ui/skeleton";import{jsx as e,jsxs as a}from"react/jsx-runtime";function Se({skills:l=!1}){let{t:o}=d();return a("div",{role:"status","aria-label":o(l?"plugins.skills.loading":"plugins.loading"),className:"my-3 flex flex-col gap-4",children:[e(s,{className:"h-4 w-36"}),e(Z,{className:"grid grid-cols-1 gap-x-8 gap-y-2 px-0 @min-[700px]:grid-cols-2","aria-hidden":"true",children:[1,2,3,4,5,6,7,8].map((t)=>a(i,{size:"xs",className:"toolbox-row",children:[e(W,{children:e(s,{className:"size-10 rounded-xl"})}),a(K,{className:"min-w-0 group-data-[size=xs]/item:gap-2",children:[e(s,{className:"h-4 w-2/3"}),e(s,{className:"h-3 w-full"}),e(s,{className:"h-3 w-1/3"})]}),e(q,{children:e(s,{className:"size-8 rounded-full"})})]},t))})]})}
|
|
2
2
|
export{Se};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{C}from"./chunk-zpqj0ka8.js";import{wt}from"./chunk-tyka859b.js";import{e}from"./chunk-bshgrwe9.js";import{me,S}from"./chunk-h8r785ne.js";import{Sn,Le}from"./chunk-s3j71dbh.js";import{Re}from"./chunk-whzs7yxf.js";import{Zap as g}from"lucide-react";import{jsx as n}from"react/jsx-runtime";function wn({snapshot:s,model:l,onChange:r,nativeModels:t,catalog:c}){let{host:u}=e(),{t:a}=u,f=[{id:C.id,name:C.name,models:t===void 0?[{api_id:"",label:C.name}]:t.map((o)=>({api_id:o.id,label:o.label??o.id}))},...(s===null?[]:me(s)).map((o)=>({id:o.id,name:o.name,models:o.models.map((i)=>({api_id:S(o.id,i.id),label:i.label??i.id}))}))],p=Le(f,c),d=p.flatMap((o)=>o.models),m=l===null?t===void 0?d[0]:{api_id:"",label:a("composer.model")}:d.find((o)=>o.api_id===l)??{api_id:l,label:l};return n(wt,{value:{...m,label:Sn(m)},models:d,modelGroups:p,header:{name:a("composer.model"),action:n(Re,{})},compactCatalog:!0,booleanOptions:[{id:"fast_mode",name:a("composer.fastMode"),currentValue:!1,disabled:!0,title:a("composer.fastModeUnsupported"),icon:n(g,{className:"size-4","aria-hidden":"true"})}],showModelList:!0,onChange:(o)=>r(o.api_id),t:(o)=>a(o)})}
|
|
2
2
|
export{wn};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{o}from"./chunk-f9z37ptq.js";import{kn,e,b}from"./chunk-bshgrwe9.js";import{Ne}from"./chunk-5ryfm4ka.js";import{Gt}from"./chunk-gkyvgjyx.js";import{$t}from"./chunk-73541c5k.js";import{zt,Vt}from"./chunk-q7ka46hb.js";import{jt}from"./chunk-v3dq3hx2.js";import{LockIcon as k,UnplugIcon as O}from"lucide-react";import{useMemo as S,useRef as M}from"react";import{Alert as x,AlertDescription as C,AlertTitle as N}from"@nyssance/shadcn/vega/components/ui/alert";import{Button as h}from"@nyssance/shadcn/vega/components/ui/button";import{Empty as P,EmptyDescription as z,EmptyHeader as B,EmptyTitle as I}from"@nyssance/shadcn/vega/components/ui/empty";import{jsx as r,jsxs as i}from"react/jsx-runtime";function Ss({host:t,client:c,...s}){let m=S(()=>t.openDiff?t:{...t,openDiff:zt},[t]);return i(kn,{host:m,client:c,children:[r(L,{...s}),!t.openDiff&&r(Vt,{})]})}function L({session:t,header:c,overlay:s,timeline:m,composer:w,readOnlyActions:D,recovery:g,welcome:E,children:R,rootRef:l,search:T=!0}){let{host:d,client:A}=e(),p=M(null),H=(a)=>{if(p.current=a,typeof l==="function")l(a);else if(l)l.current=a},{t:n}=d,f=o((a)=>a.connection==="ready"),v=o((a)=>a.historyPages[t.id]?.error),y=()=>b(d,A.open(t.id,t.cwd)),u=t.items.length===0&&t.attached&&!t.restoring&&t.state==="idle";return i("div",{"data-chat-drop-zone":!0,ref:H,className:"flex h-full min-h-0 flex-col",children:[c,i("div",{className:"relative flex min-h-0 flex-1 flex-col","data-chat-content":!0,children:[T&&!u&&r($t,{sessionId:t.id,rootRef:p}),s,f&&!t.attached&&!t.restoring&&!t.readOnly&&r("div",{className:"mx-auto my-3 w-full max-w-4xl px-4",children:i(x,{children:[r(O,{}),r(N,{children:n("conversation.stopped")}),r(C,{children:r(h,{size:"sm",variant:"outline",onClick:y,children:n("conversation.reconnect")})})]})}),u?E??r(P,{className:"flex-1",children:i(B,{children:[r(I,{className:"text-[28px] font-normal",children:n("conversation.welcomeTitle")}),r(z,{children:n("conversation.welcomeDescription")})]})}):r(Gt,{session:t,timeline:m}),r(jt,{sessionId:t.id}),g??(t.readOnly?r("div",{className:"mx-auto w-full max-w-3xl shrink-0 px-6 pb-5","data-readonly-composer":!0,children:i(x,{className:"flex items-center justify-between gap-4 rounded-3xl px-5 py-4",children:[i("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[r(k,{"aria-hidden":"true",className:"size-4 shrink-0"}),i("div",{className:"min-w-0 space-y-1",children:[r(N,{children:n("conversation.readOnlyTitle")}),r(C,{children:n("conversation.readOnlyDescription")}),v&&r("p",{role:"alert",className:"text-destructive break-words",children:v})]})]}),i("div",{className:"border-border flex shrink-0 items-center gap-1 border-s ps-3","data-readonly-actions":!0,children:[r(h,{size:"sm",variant:"outline",className:"text-foreground cursor-pointer disabled:cursor-not-allowed",onClick:y,disabled:!f||t.restoring,children:n(t.restoring?"conversation.restoring":"conversation.readOnlyRetry")}),D]})]})}):w??r(Ne,{session:t}))]}),R]})}
|
|
2
|
+
export{Ss};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{isGroupedSelect as i,isSelectOption as o}from"@nyssance/codex-acp-v2/client";function X(e){return i(e.options)?e.options.flatMap((t)=>t.options):e.options}function
|
|
2
|
-
export{X,
|
|
1
|
+
import{isGroupedSelect as i,isSelectOption as o}from"@nyssance/codex-acp-v2/client";function X(e){return i(e.options)?e.options.flatMap((t)=>t.options):e.options}function x(e,t){return e.find((n)=>n.category===t&&o(n))}function Y(e){return X(e).find((t)=>t.value===e.currentValue)?.name??e.currentValue}
|
|
2
|
+
export{X,x,Y};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{Qr,Lt}from"./chunk-dypeezvv.js";import{t,
|
|
2
|
-
`,1)[0]??"";return r.endsWith(` b/${a}`)||r.endsWith(` ${a}`)||r.includes(`/${a} `)})??e}function
|
|
3
|
-
export{
|
|
1
|
+
import{Qr,Lt}from"./chunk-dypeezvv.js";import{t,y}from"./chunk-f9z37ptq.js";import{createStore as d}from"@alwith/api/client";import{Dialog as f,DialogContent as p,DialogDescription as m,DialogHeader as u,DialogTitle as h}from"@nyssance/shadcn/vega/components/ui/dialog";import{jsx as i,jsxs as l}from"react/jsx-runtime";var c=d({request:null});function zt(e){c.setState({request:{path:e.path,patch:Yo(e.patch,e.path)}})}function Yo(e,a){let n=e.split(/^(?=diff --git )/m).filter((o)=>o.length>0);if(n.length<=1)return e;return n.find((o)=>{let r=o.split(`
|
|
2
|
+
`,1)[0]??"";return r.endsWith(` b/${a}`)||r.endsWith(` ${a}`)||r.includes(`/${a} `)})??e}function Vt(){let{t:e,theme:a}=t(),n=y(c,(o)=>o.request),s=n===null?null:Qr(n.patch);return i(f,{open:n!==null,onOpenChange:(o)=>!o&&c.setState({request:null}),children:l(p,{className:"flex h-[calc(100vh-2.5rem)] max-h-[900px] flex-col gap-3 sm:max-w-[min(1400px,calc(100vw-2.5rem))]",children:[l(u,{children:[i(h,{className:"truncate pe-8 font-mono text-sm font-normal",children:n?.path}),s!==null&&l(m,{children:[l("span",{className:"codex-diff-additions",children:["+",s.additions]})," ",l("span",{className:"codex-diff-deletions",children:["-",s.deletions]})," ",i("span",{children:e("conversation.changedLines")})]})]}),i("div",{className:"min-h-0 min-w-0 flex-1 overflow-hidden rounded-lg border [&>.codex-patch-view]:h-full","data-stream-style":"codexUI",children:n!==null&&i(Lt,{patch:n.patch,theme:a})})]})})}
|
|
3
|
+
export{zt,Yo,Vt};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{wt}from"./chunk-tyka859b.js";import{o}from"./chunk-
|
|
1
|
+
import{wt}from"./chunk-tyka859b.js";import{o}from"./chunk-f9z37ptq.js";import{e,b}from"./chunk-bshgrwe9.js";import{X,x,Y}from"./chunk-p8cm3xw1.js";import{isBooleanOption as U,isGroupedSelect as q,isSelectOption as A}from"@nyssance/codex-acp-v2/client";import{Zap as Z}from"lucide-react";import{memo as D,useRef as F}from"react";import{jsx as w}from"react/jsx-runtime";function H({sessionId:l,options:u,disabled:B,onModelChange:h,onConfigChange:C,defaultGroup:G={id:"models",name:"Models"},catalog:I=(c)=>c,headerAction:L}){let{host:c,client:N}=e(),{t:i}=c,P=o((n)=>Boolean(n.configPending[l])),p=F({sessionId:l,model:!0}),O=P&&(p.current.sessionId!==l||p.current.model),k=o((n)=>{let r=n.sessions[l];return r?.state==="running"||r?.state==="requires_action"}),t=x(u,"model"),a=x(u,"thought_level"),v=u.filter((n)=>n.configId!=="collaboration_mode"&&(n.category==="model_config"||n.category!=="mode"&&n!==t&&n!==a)),_=v.filter(A),m=v.filter(U);if(!t&&!a&&_.length===0&&m.length===0)return null;let f=(n,r)=>{if(r===n.currentValue)return Promise.resolve();p.current={sessionId:l,model:n===t};let d=C?C(n.configId,r):N.setConfig(l,n.configId,r);return b(c,d),d},g=a?X(a):[],z=g.reduce((n,r)=>r.name.length>=n.length?r.name:n,""),R=t?Y(t):i("composer.model"),S=(n)=>({api_id:n.value,label:n.name}),V=I(t&&q(t.options)?t.options.map((n)=>({id:n.groupId,name:n.name,models:n.options.map(S)})):[{...G,models:t?X(t).map(S):[]}]),y=V.flatMap((n)=>n.models),M=y.find((n)=>n.api_id===t?.currentValue)??{api_id:t?.currentValue??"",label:R},s=m.find((n)=>n.configId==="fast_mode"||n.configId==="fast-mode");return w(wt,{disabled:B||O||k,switching:O,value:{...M,label:M.shortLabel??M.label},compactCatalog:!0,models:y,showModelList:Boolean(t),onChange:(n)=>{if(n.api_id===t?.currentValue)return;if(h)h(n.api_id);else if(t)f(t,n.api_id)},header:{name:t?.name??i("composer.model"),action:L},modelGroups:V,t:i,effortConfig:a&&g.length>0?{name:"Effort",value:a.currentValue,levels:g,sizer:z,onChange:(n)=>f(a,n)}:void 0,selectOptions:_.map((n)=>({id:n.configId,name:n.name,value:n.currentValue,options:X(n).map((r)=>({value:r.value,label:r.name})),onChange:(r)=>f(n,r)})),booleanOptions:[{id:"fast_mode",name:i("composer.fastMode"),currentValue:s?.currentValue??!1,disabled:!s,title:!s?i("composer.fastModeUnsupported"):void 0,icon:w(Z,{className:"size-4","aria-hidden":"true"})},...m.filter((n)=>n!==s).map((n)=>({id:n.configId,name:n.name,currentValue:n.currentValue}))],onBooleanChange:(n,r)=>{let d=n==="fast_mode"?s:m.find((E)=>E.configId===n);if(!d)throw Error(`Unknown boolean config: ${n}`);f(d,r)}})}var fn=D(H);
|
|
2
2
|
export{fn};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{e}from"./chunk-
|
|
1
|
+
import{e}from"./chunk-bshgrwe9.js";import{qt,Kt}from"./chunk-81hv0s07.js";import{S}from"./chunk-h8r785ne.js";import{ChevronDownIcon as h}from"lucide-react";import{useId as x,useState as v}from"react";import{Button as b}from"@nyssance/shadcn/vega/components/ui/button";import{Collapsible as A,CollapsibleContent as M,CollapsibleTrigger as I}from"@nyssance/shadcn/vega/components/ui/collapsible";import{Input as N}from"@nyssance/shadcn/vega/components/ui/input";import{jsx as t,jsxs as i}from"react/jsx-runtime";function Ns({providers:n,store:l}){let{t:m}=e().host,d=qt(l);if(!n.some((s)=>s.models.length))return null;return i(A,{children:[i(I,{render:t(b,{variant:"ghost",size:"sm"}),children:[m("provider.managed.aliases"),t(h,{className:"size-4"})]}),i(M,{className:"space-y-3 pt-3",children:[t("p",{className:"text-muted-foreground text-xs",children:m("provider.managed.aliasHint")}),n.flatMap((s)=>s.models.map((o)=>{let a=S(s.id,o.api_id);return t(w,{id:a,label:o.label,modelId:o.api_id,alias:d[a]??"",store:l},a)}))]})]})}function w({id:n,label:l,modelId:m,alias:d,store:s}){let{host:o}=e(),a=x(),[C,c]=v(null),[p,f]=v(!1),u=C??d;async function y(){f(!0);try{await Kt(s,n,u),c(null)}catch(r){let g=r instanceof Error?r:Error(String(r));if(o.reportError)o.reportError(g);else console.error(g)}finally{f(!1)}}return i("form",{className:"space-y-1.5",onSubmit:(r)=>{if(r.preventDefault(),!p)y()},children:[t("label",{htmlFor:a,className:"text-sm font-medium",children:l}),t("p",{className:"text-muted-foreground text-xs break-all",children:m}),i("div",{className:"flex items-center gap-2",children:[t(N,{id:a,value:u,placeholder:l,maxLength:100,disabled:p,onChange:(r)=>c(r.target.value)}),t(b,{type:"submit",variant:"outline",size:"sm",disabled:p||u.trim()===d,children:o.t("provider.managed.saveAlias")})]})]})}
|
|
2
2
|
export{Ns};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{o}from"./chunk-
|
|
1
|
+
import{o}from"./chunk-f9z37ptq.js";import{e}from"./chunk-bshgrwe9.js";import{x,Y}from"./chunk-p8cm3xw1.js";import{hasAccount as D,isGroupedSelect as L}from"@nyssance/codex-acp-v2/client";import{cn as H}from"cn";import{memo as W,useEffect as T,useState as F}from"react";import{HoverCard as z,HoverCardContent as O,HoverCardTrigger as U}from"@nyssance/shadcn/vega/components/ui/hover-card";import{jsx as r,jsxs as u}from"react/jsx-runtime";var d=new Intl.NumberFormat("en-US",{maximumFractionDigits:0}),A=new Intl.NumberFormat("en-US",{style:"percent",maximumFractionDigits:1}),I=new Intl.NumberFormat("en-US",{maximumFractionDigits:1});function f(a){return typeof a==="number"&&!Number.isNaN(a)?Math.max(0,a):0}function V(a,t){let n=Math.min(100,a/t*100),p=n>=90?"text-destructive":n>=70?"text-foreground":"text-muted-foreground";return{pct:n,className:p}}function G(a){let t=x(a.configOptions,"model");return t===void 0?void 0:Y(t)}function et(a,t){let n=a.windowDurationMins;if(n===null)return t("usage.usage");if(n%1440===0)return t("usage.windowDays",{count:n/1440});return t("usage.windowHours",{count:Math.round(n/60)})}function P(a){let{client:t}=e(),n=o((s)=>a&&s.connection==="ready"&&D(s.agent)),[p,c]=F(null);return T(()=>{if(!n){c(null);return}let s=!0;t.readRateLimits().then((m)=>{if(s)c(m)},()=>{return});let l=t.onRateLimits((m)=>{if(s)c(m)});return()=>{s=!1,l()}},[n,t]),n?p:null}function _({session:a}){let{t}=e().host,n=x(a.configOptions,"model"),p=n!==void 0&&(L(n.options)?n.options.some((i)=>i.groupId==="chatgpt"&&i.options.some((y)=>y.value===n.currentValue)):!n.currentValue.startsWith("gateway:")&&n.options.some((i)=>i.value===n.currentValue)),c=P(p),{usage:s,lastTurnUsage:l}=a;if(s===null&&l===null)return null;let m=s&&s.size>0?V(s.used,s.size):null,h=7,b=2*Math.PI*h,N=f(l?.inputTokens),k=f(l?.outputTokens),g=f(l?.cachedReadTokens),w=f(l?.cachedWriteTokens),S=f(l?.totalTokens)||N+k+g+w,R=N+g,C=R>0?A.format(g/R):t("tokens.notAvailable"),M=[[t("tokens.input"),d.format(N)],[t("tokens.output"),d.format(k)],[t("tokens.cachedRead"),d.format(g)],[t("tokens.cachedWrite"),d.format(w)],[t("tokens.cacheHitRate"),C],[t("tokens.total"),d.format(S)]],v=G(a);return u(z,{children:[r(U,{delay:100,closeDelay:100,render:u("button",{type:"button",className:H("hover:text-foreground flex h-7 items-center gap-1.5 rounded-md px-1.5 text-xs tabular-nums",m?.className??"text-muted-foreground"),"aria-label":t("tokens.openDetails"),children:[u("svg",{viewBox:"0 0 18 18",className:"size-4","aria-hidden":"true",children:[r("circle",{cx:"9",cy:"9",r:h,fill:"none",stroke:"currentColor",strokeOpacity:"0.2",strokeWidth:"2"}),m!==null&&r("circle",{cx:"9",cy:"9",r:h,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeDasharray:b,strokeDashoffset:b*(1-m.pct/100),transform:"rotate(-90 9 9)"})]}),m!==null&&u("span",{children:[Math.round(m.pct),"%"]})]})}),u(O,{align:"end",side:"top",sideOffset:8,className:"w-56 p-0",children:[v!==void 0&&r("div",{className:"border-b px-3 py-2",children:r("p",{className:"text-foreground truncate text-xs font-semibold",title:v,children:v})}),u("div",{className:"flex flex-col gap-3 p-3",children:[l!==null&&u("div",{className:"flex flex-col gap-1.5",children:[r("p",{className:"text-xs font-medium",children:t("tokens.openDetails")}),r("dl",{className:"grid grid-cols-[1fr_auto] gap-x-4 gap-y-1 text-xs",children:M.map(([i,y])=>u("div",{className:"contents",children:[r("dt",{className:"text-muted-foreground",children:i}),r("dd",{className:"text-end tabular-nums",children:y})]},i))})]}),s!==null&&s.size>0&&u("div",{className:"flex flex-col gap-1.5 border-t pt-2",children:[r("p",{className:"text-xs font-medium",children:t("tokens.context")}),r("p",{className:"text-muted-foreground text-xs tabular-nums",children:t("tokens.contextSummary",{used:d.format(s.used),limit:d.format(s.size),percent:I.format(s.used/s.size*100)})})]}),c!==null&&(c.primary!==null||c.secondary!==null)&&u("div",{className:"flex flex-col gap-1.5 border-t pt-2",children:[r("p",{className:"text-xs font-medium",children:t("usage.limits")}),r("dl",{className:"grid grid-cols-[1fr_auto] gap-x-4 gap-y-1 text-xs",children:[c.primary,c.secondary].filter((i)=>i!==null).map((i)=>u("div",{className:"contents",children:[r("dt",{className:"text-muted-foreground",children:et(i,t)}),r("dd",{className:"text-end tabular-nums",children:t("usage.used",{percent:Math.round(Math.min(100,Math.max(0,i.usedPercent)))})})]},`${i.windowDurationMins??"window"}`))})]})]})]})]})}var hn=W(_);
|
|
2
2
|
export{et,hn};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createStore as I}from"@alwith/api/client";function k(a){return a instanceof Error?a.message:String(a)}function w(a){return a.interface?.displayName??a.name}function v(a){let g={},i=new Map,r=new Map;for(let c of a.data){for(let o of c.skills)if(i.set(o.path,o),o.scope==="repo"){let p=g[c.cwd]??[];if(!p.includes(o.path))p.push(o.path);g[c.cwd]=p}for(let o of c.errors)r.set(o.path,o)}return{skills:[...i.values()],errors:[...r.values()],projects:g}}function A(a){let g=[];for(let i of a.marketplaces)for(let r of i.plugins)if(r.installed)g.push({plugin:r,marketplace:i});return g.toSorted((i,r)=>(r.plugin.installedAt??0)-(i.plugin.installedAt??0))}function ui(a){let{plugin:g,marketplace:i}=a;return{installAttemptId:crypto.randomUUID(),pluginName:i.path===null?g.remotePluginId??g.name:g.name,...i.path===null?{remoteMarketplaceName:i.name}:{marketplacePath:i.path}}}function N(a){let{plugin:g,marketplace:i}=a;return{pluginName:i.path===null?g.remotePluginId??g.name:g.name,...i.path===null?{remoteMarketplaceName:i.name}:{marketplacePath:i.path}}}function nn(a,g){let i=g??{t:(e)=>e},r=(e,l)=>i.t(e,l),c=(e)=>i.notify?.(e),o=(e)=>{if(i.reportError)i.reportError(Error(e));else console.error(e)},p=null,b=null,d=(e)=>S.setState(e),m=()=>S.getState(),y=async(e=!1)=>{if(await m().refresh(void 0,{forceRefetch:e,background:!0}),m().error)throw Error(r("plugins.toast.syncError",{message:m().error}))},f=(e,l)=>d((n)=>{let s={...n.busyIds};if(l===null)delete s[e];else s[e]=l;return{busyIds:s}}),h=(e,l)=>d((n)=>{let s={...n.busyMarketplaces};if(l)s[e]=!0;else delete s[e];return{busyMarketplaces:s}}),R=I({loading:!1,loadedScope:null,upgrading:!1,error:null,cwds:[],marketplaces:[],marketplaceLoadErrors:[],featuredPluginIds:[],installed:[],skills:[],skillProjects:{},skillErrors:[],busyIds:{},busySkills:{},busyMarketplaces:{},refresh:(e=m().cwds,l={})=>{let n=l.forceRefetch===!0||p?.forceRefetch===!0,s=l.catalog!==!1||n||p?.catalog===!0;if(p={cwds:e,forceRefetch:n,catalog:s},d({cwds:e,...!l.background?{loading:!0}:{}}),b)return b;return b=(async()=>{while(p){let t=p;p=null,d({error:null});try{let[u,P,M]=await Promise.all([a.listSkills(t.cwds,t.forceRefetch),t.catalog?a.listPlugins({...t.cwds.length>0?{cwds:t.cwds}:{},...t.forceRefetch?{forceRefetch:!0}:{}}):null,a.installedPlugins(t.cwds)]);if(p)continue;let E=v(u);d({loadedScope:JSON.stringify(t.cwds),skills:E.skills,skillProjects:E.projects,skillErrors:E.errors,...P?{marketplaces:P.marketplaces,marketplaceLoadErrors:P.marketplaceLoadErrors,featuredPluginIds:P.featuredPluginIds}:{},installed:A(M)})}catch(u){if(!p)d({error:k(u)})}}})().finally(()=>{b=null,d({loading:!1})}),b},install:async(e)=>{if(e.plugin.id in m().busyIds)throw Error("Plugin operation already in progress");let l=w(e.plugin);f(e.plugin.id,"installing");try{let n=await a.installPlugin(ui(e));return await y(),f(e.plugin.id,null),c(r("plugins.toast.installed",{pluginName:l})),n}catch(n){throw o(`${r("plugins.toast.installError")}: ${k(n)}`),n}finally{f(e.plugin.id,null)}},setPluginEnabled:async(e,l)=>{if(e.id in m().busyIds)return;f(e.id,"toggling");let n=(t)=>d((u)=>({installed:u.installed.map((P)=>P.plugin.id===e.id?{...P,plugin:{...P.plugin,enabled:t}}:P)}));n(l);let s=e.enabled;try{let t=await a.setPluginEnabled(e.id,l);s=t.enabled,n(t.enabled),await y();let u=m().installed.find((P)=>P.plugin.id===e.id);if(u)s=u.plugin.enabled;if(!u||s!==l)throw Error(r("plugins.toast.toggleNotApplied"));f(e.id,null),c(r(l?"plugins.toast.enabled":"plugins.toast.disabled",{pluginName:w(e)}))}catch(t){n(s),o(`${r("plugins.toast.toggleError")}: ${k(t)}`)}finally{f(e.id,null)}},uninstall:async(e)=>{if(e.id in m().busyIds)return;let l=w(e);f(e.id,"uninstalling");try{let n=e.source.type==="remote"?e.remotePluginId:e.id;if(!n)throw Error("Remote plugin ID is missing");if(await a.uninstallPlugin(n),await y(),m().installed.some((s)=>s.plugin.id===e.id))throw Error(r("plugins.toast.uninstallNotApplied"));f(e.id,null),c(r("plugins.toast.uninstalled",{pluginName:l}))}catch(n){o(`${r("plugins.toast.uninstallError")}: ${k(n)}`)}finally{f(e.id,null)}},readPlugin:async(e)=>(await a.readPlugin(N(e))).plugin,setSkillEnabled:async(e,l)=>{if(e.path in m().busySkills)return;d((s)=>({busySkills:{...s.busySkills,[e.path]:!0}})),d((s)=>({skills:s.skills.map((t)=>t.path===e.path?{...t,enabled:l}:t)}));let n=e.interface?.displayName??e.name;try{let s=await a.setSkillEnabled({path:e.path,enabled:l});if(d((t)=>({skills:t.skills.map((u)=>u.path===e.path?{...u,enabled:s.effectiveEnabled}:u)})),s.effectiveEnabled!==l){o(r("plugins.catalog.toggleNotApplied"));return}c(r(l?"plugins.skills.enabledToast":"plugins.skills.disabledToast",{skillName:n}))}catch(s){d((t)=>({skills:t.skills.map((u)=>u.path===e.path?{...u,enabled:e.enabled}:u)})),o(`${r("plugins.skills.toggleError")}: ${k(s)}`)}finally{d((s)=>{let t={...s.busySkills};return delete t[e.path],{busySkills:t}})}},addMarketplace:async(e)=>{let l=await a.addMarketplace(e);return await y(!0),c(l.alreadyAdded?r("plugins.marketplace.alreadyAdded",{marketplaceName:l.marketplaceName}):r("plugins.marketplace.added",{marketplaceName:l.marketplaceName})),l},removeMarketplace:async(e)=>{h(e,!0);try{await a.removeMarketplace(e),await y(),h(e,!1),c(r("plugins.marketplace.removed",{marketplaceName:e}))}catch(l){o(`${r("plugins.marketplace.removeError")}: ${k(l)}`)}finally{h(e,!1)}},upgradeMarketplace:async(e)=>{h(e,!0);try{let l=await a.upgradeMarketplaces(e);if(await y(!0),h(e,!1),l.errors.length>0)o(`${r("plugins.marketplace.upgradeError")}: ${l.errors.map((n)=>n.message).join("; ")}`);else c(r("plugins.marketplace.upgraded",{marketplaceName:e}))}catch(l){o(`${r("plugins.marketplace.upgradeError")}: ${k(l)}`)}finally{h(e,!1)}},upgradeAll:async()=>{if(m().upgrading)return;d({upgrading:!0});try{let e=await a.upgradeMarketplaces();if(await y(!0),d({upgrading:!1}),e.errors.length>0)o(r("plugins.marketplace.upgradeAllError"));else c(r("plugins.marketplace.upgradedAll"))}catch(e){o(`${r("plugins.marketplace.upgradeAllRequestError")}: ${k(e)}`)}finally{d({upgrading:!1})}}}),S=Object.assign(R,{bindHost:(e)=>{i=e}});return S}
|
|
2
|
+
export{ui,nn};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{C}from"./chunk-zpqj0ka8.js";import{tr,nr,or,ir}from"./chunk-5pmr5dby.js";import{_n,A,yt,S,bt}from"./chunk-h8r785ne.js";import{Bot as p}from"lucide-react";import{jsx as l}from"react/jsx-runtime";var r={"alwith-account":tr,chatgpt:nr,minimax:or,seedream:ir};function Yi({provider:o,className:i,...a}){let e=Object.hasOwn(r,o)?r[o]:A.find((n)=>n.id===o)?.logo??p;return l(e,{"aria-hidden":"true",...a,className:["size-4 shrink-0",i].filter(Boolean).join(" ")})}var s=new Map(_n.filter((o)=>o.source==="account").flatMap((o)=>o.models.map((i)=>[S(o.id,i.id),i.label]))),d=new Map([..._n.map((o)=>[o.id,o.source==="account"?1:2]),[C.id,0]]);function Sn(o){return o.shortLabel??o.label}function Le(o,i={}){return o.toSorted((e,n)=>(d.get(e.id)??3)-(d.get(n.id)??3)).map((e)=>{let n=e.id===C.id;return{...e,models:e.models.map((t)=>({...t,label:s.get(t.api_id)??t.label,shortLabel:t.shortLabel??bt[t.api_id]?.shortLabel,icon:i.providerIcon?.(e.id,t.api_id)??l(Yi,{provider:n?"chatgpt":e.id==="litellm"||e.id==="alwith-managed-litellm"||yt(t.api_id)?"alwith-account":e.id})}))}})}
|
|
2
2
|
export{Yi,Sn,Le};
|