@dmrlzz/davecode 0.5.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/{ChatApp-Z6PQIZ5J.js → ChatApp-RQZ2IZFQ.js} +6 -6
- package/dist/{account-RTPS2V6O.js → account-FY6THFLW.js} +3 -3
- package/dist/{accounts-IYQ4ZRL7.js → accounts-ZV3KMLC5.js} +5 -5
- package/dist/{budget-N2ZB66FF.js → budget-OUOEMMOM.js} +4 -4
- package/dist/{chat-6TX6JX45.js → chat-OHVP4BS3.js} +8 -8
- package/dist/{chunk-UEV5K3DH.js → chunk-2MM5WT5J.js} +3 -3
- package/dist/{chunk-UNK3EQD6.js → chunk-2P5DJWIJ.js} +4 -4
- package/dist/{chunk-QKY3OKVG.js → chunk-2XGDILCW.js} +1677 -133
- package/dist/chunk-2XGDILCW.js.map +1 -0
- package/dist/{chunk-LEU46DGH.js → chunk-FFB2QA5I.js} +2 -2
- package/dist/{goal-STLEU7C7.js → chunk-HL4RIXPM.js} +8 -8
- package/dist/chunk-HL4RIXPM.js.map +1 -0
- package/dist/{chunk-WAARDGCZ.js → chunk-L7NEDOA3.js} +2 -2
- package/dist/{chunk-BJTXMET2.js → chunk-NKRI6SYR.js} +2 -2
- package/dist/{chunk-KUY3QHGS.js → chunk-TP3ORSHY.js} +134 -4
- package/dist/chunk-TP3ORSHY.js.map +1 -0
- package/dist/{chunk-YNAMNQLW.js → chunk-U5CI774J.js} +3 -3
- package/dist/{config-YQKY2AA4.js → config-ZLO3YOUX.js} +3 -3
- package/dist/dashboard/assets/Accounts-CIhOt9FH.js +1 -0
- package/dist/dashboard/assets/{Callout-1E8Wsl9W.js → Callout-CqdcH6dC.js} +1 -1
- package/dist/dashboard/assets/Goals-CITP2GqG.js +1 -0
- package/dist/dashboard/assets/{Library-DZxBVUo_.js → Library-DnCIb76j.js} +1 -1
- package/dist/dashboard/assets/{Panes-C-TJekjs.js → Panes-DBqKYuaE.js} +3 -3
- package/dist/dashboard/assets/RoutesPage-BNVmKhyU.js +4 -0
- package/dist/dashboard/assets/Runner-KR35ZWUE.js +1 -0
- package/dist/dashboard/assets/Settings-B5qE-a5O.js +1 -0
- package/dist/dashboard/assets/Tasks-bJLfNJmS.js +2 -0
- package/dist/dashboard/assets/Traffic-CGfilrRx.js +1 -0
- package/dist/dashboard/assets/Workspace-Dc3cvct_.js +1 -0
- package/dist/dashboard/assets/format-328qIBHX.js +111 -0
- package/dist/dashboard/assets/index-C-bwzlsl.js +50 -0
- package/dist/dashboard/assets/index-D9FCfPmM.css +2 -0
- package/dist/dashboard/assets/task-errors-DK4-900l.js +1 -0
- package/dist/dashboard/index.html +3 -3
- package/dist/{dist-PIC255RX.js → dist-56V3DLJ4.js} +16 -2
- package/dist/{doctor-PQC7JQPP.js → doctor-DUOKUSJL.js} +3 -3
- package/dist/goal-WG37XHUY.js +26 -0
- package/dist/index.js +64 -31
- package/dist/index.js.map +1 -1
- package/dist/{init-NHU5LJSS.js → init-WW4XPFMM.js} +3 -3
- package/dist/orchestrate-7YQDBS3E.js +382 -0
- package/dist/orchestrate-7YQDBS3E.js.map +1 -0
- package/dist/{run-7HWSHMRJ.js → run-QB4SGPEC.js} +3 -3
- package/dist/runtime.js +6 -2
- package/dist/{start-WVAEAQWL.js → start-U4RL377T.js} +3 -3
- package/dist/{status-ZRHPFLFT.js → status-GHVMGZI5.js} +4 -4
- package/dist/status-GHVMGZI5.js.map +1 -0
- package/dist/{tasks-JVWXUNXN.js → tasks-VTBJ4B2G.js} +4 -4
- package/package.json +4 -4
- package/dist/chunk-KUY3QHGS.js.map +0 -1
- package/dist/chunk-QKY3OKVG.js.map +0 -1
- package/dist/dashboard/assets/Accounts-DXiGsutB.js +0 -1
- package/dist/dashboard/assets/Badge-DUGKlx3Z.js +0 -55
- package/dist/dashboard/assets/Goals-kL4VAxw3.js +0 -1
- package/dist/dashboard/assets/RoutesPage-DWYm9tW8.js +0 -4
- package/dist/dashboard/assets/Runner-CmHBjECR.js +0 -1
- package/dist/dashboard/assets/Settings-BANphxva.js +0 -1
- package/dist/dashboard/assets/Tasks-cSx1PKyQ.js +0 -2
- package/dist/dashboard/assets/Traffic-DEAuM6jq.js +0 -1
- package/dist/dashboard/assets/Workspace-BQFjc1jH.js +0 -1
- package/dist/dashboard/assets/index-B8kld9xo.js +0 -104
- package/dist/dashboard/assets/index-BEmBgsbP.css +0 -2
- package/dist/dashboard/assets/task-errors-r-WYZ_S3.js +0 -1
- package/dist/goal-STLEU7C7.js.map +0 -1
- /package/dist/{ChatApp-Z6PQIZ5J.js.map → ChatApp-RQZ2IZFQ.js.map} +0 -0
- /package/dist/{account-RTPS2V6O.js.map → account-FY6THFLW.js.map} +0 -0
- /package/dist/{accounts-IYQ4ZRL7.js.map → accounts-ZV3KMLC5.js.map} +0 -0
- /package/dist/{budget-N2ZB66FF.js.map → budget-OUOEMMOM.js.map} +0 -0
- /package/dist/{chat-6TX6JX45.js.map → chat-OHVP4BS3.js.map} +0 -0
- /package/dist/{chunk-UEV5K3DH.js.map → chunk-2MM5WT5J.js.map} +0 -0
- /package/dist/{chunk-UNK3EQD6.js.map → chunk-2P5DJWIJ.js.map} +0 -0
- /package/dist/{chunk-LEU46DGH.js.map → chunk-FFB2QA5I.js.map} +0 -0
- /package/dist/{chunk-WAARDGCZ.js.map → chunk-L7NEDOA3.js.map} +0 -0
- /package/dist/{chunk-BJTXMET2.js.map → chunk-NKRI6SYR.js.map} +0 -0
- /package/dist/{chunk-YNAMNQLW.js.map → chunk-U5CI774J.js.map} +0 -0
- /package/dist/{config-YQKY2AA4.js.map → config-ZLO3YOUX.js.map} +0 -0
- /package/dist/{dist-PIC255RX.js.map → dist-56V3DLJ4.js.map} +0 -0
- /package/dist/{doctor-PQC7JQPP.js.map → doctor-DUOKUSJL.js.map} +0 -0
- /package/dist/{status-ZRHPFLFT.js.map → goal-WG37XHUY.js.map} +0 -0
- /package/dist/{init-NHU5LJSS.js.map → init-WW4XPFMM.js.map} +0 -0
- /package/dist/{run-7HWSHMRJ.js.map → run-QB4SGPEC.js.map} +0 -0
- /package/dist/{start-WVAEAQWL.js.map → start-U4RL377T.js.map} +0 -0
- /package/dist/{tasks-JVWXUNXN.js.map → tasks-VTBJ4B2G.js.map} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e,n as t,o as n,r,t as i}from"./cn-BwE4cei0.js";import{B as a,V as o,c as s,ct as c,f as l,i as u,l as d,lt as f,p,r as m,t as h,ut as g}from"./Badge-DUGKlx3Z.js";import{A as _,B as v,I as y,O as b,V as x,Z as S,_ as C,f as w,k as T,m as E,n as D,q as O,r as k,s as A,t as j,u as M,w as N}from"./index-B8kld9xo.js";import{n as P,r as F}from"./Field-Cmpgg_1z.js";var I={name:`loader`,size:24,node:[[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m16.2 7.8 2.9-2.9`,key:`r700ao`}],[`path`,{d:`M18 12h4`,key:`wj9ykh`}],[`path`,{d:`m16.2 16.2 2.9 2.9`,key:`1bxg5t`}],[`path`,{d:`M12 18v4`,key:`jadmvz`}],[`path`,{d:`m4.9 19.1 2.9-2.9`,key:`bwix9q`}],[`path`,{d:`M2 12h4`,key:`j09sii`}],[`path`,{d:`m4.9 4.9 2.9 2.9`,key:`giyufr`}]]};I.node;var L=t(I),R=n(e(),1),z=r();function B({chain:e,accounts:t,className:n}){let r=e.attempts.map(e=>{let n=t.get(e.accountId)?.label??e.accountId;return e.outcome===`failed`?`${n} failed (${g(e)})`:`${n} ${e.outcome}`}).join(`, then `);return(0,z.jsxs)(`div`,{className:i(`flex min-w-0 items-center gap-1`,n),title:r,children:[(0,z.jsx)(`span`,{className:`sr-only`,children:r}),e.attempts.map((n,r)=>(0,z.jsxs)(R.Fragment,{children:[r>0&&(0,z.jsx)(V,{attempt:e.attempts[r-1]}),(0,z.jsx)(H,{attempt:n,account:t.get(n.accountId),compact:e.attempts.length>2&&r<e.attempts.length-1})]},r))]})}function V({attempt:e}){return(0,z.jsxs)(`span`,{"aria-hidden":!0,className:`flex shrink-0 items-center gap-1 text-faint`,children:[(0,z.jsx)(`span`,{className:`h-px w-2 bg-line-strong`}),e?.outcome===`failed`&&(0,z.jsx)(`span`,{className:`rounded border border-err/30 bg-err-soft px-1 font-mono text-[10px] leading-4 text-err`,children:g(e)}),(0,z.jsx)(`span`,{className:`h-px w-2 bg-line-strong`}),(0,z.jsx)(`span`,{className:`-ml-1.5 text-[10px] leading-none`,children:`▸`})]})}function H({attempt:e,account:t,compact:n}){let r=t?.label??e.accountId;return(0,z.jsxs)(`span`,{"aria-hidden":!0,className:i(`inline-flex h-6 max-w-[180px] min-w-0 items-center gap-1.5 rounded border pr-1.5 pl-0.5 text-[12px]`,e.outcome===`failed`?`border-line text-muted`:`border-line-strong bg-raised text-fg`),children:[(0,z.jsx)(C,{provider:e.provider,size:`sm`,className:`size-[18px] border-0 bg-transparent`}),!n&&(0,z.jsx)(`span`,{className:i(`truncate`,e.outcome===`failed`&&`line-through decoration-faint`),children:r}),e.outcome===`success`&&(0,z.jsx)(O,{className:`size-3 shrink-0 text-ok`,strokeWidth:2.25}),e.outcome===`failed`&&(0,z.jsx)(_,{className:`size-3 shrink-0 text-err`,strokeWidth:2.25}),e.outcome===`pending`&&(0,z.jsx)(L,{className:`size-3 shrink-0 animate-spin text-info [animation-duration:1.6s]`,strokeWidth:2})]})}function U({chain:e}){return e.outcome===`pending`?(0,z.jsx)(h,{tone:`info`,dot:!0,pulse:!0,children:`in flight`}):e.outcome===`failed`?(0,z.jsx)(h,{tone:`err`,dot:!0,children:`failed`}):e.failovers>0?(0,z.jsxs)(h,{tone:`warn`,dot:!0,children:[`ok · `,e.failovers,` failover`,e.failovers>1?`s`:``]}):(0,z.jsx)(h,{tone:`ok`,dot:!0,children:`ok`})}function W({chain:e,accounts:t,onClose:n}){return(0,z.jsx)(w,{open:!!e,onClose:n,title:`Request`,description:e&&(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-mono`,children:[e.requestId,(0,z.jsx)(E,{value:e.requestId,label:`Copy request id`})]}),width:`w-[min(520px,100vw)]`,children:e&&(0,z.jsx)(G,{chain:e,accounts:t})})}function G({chain:e,accounts:t}){let n=f(e),r=c(e),a=[[`Outcome`,(0,z.jsx)(U,{chain:e},`o`)],[`Model`,(0,z.jsx)(`span`,{className:`font-mono`,children:e.model||`—`},`m`)],[`Started`,(0,z.jsx)(`span`,{className:`tnum font-mono`,children:m(e.startedTs,!0)},`s`)],[`End-to-end`,(0,z.jsx)(`span`,{className:`tnum font-mono`,children:r===void 0?`—`:d(r)},`l`)],[`Tokens`,(0,z.jsxs)(`span`,{className:`tnum font-mono`,children:[s(n.prompt),` in · `,s(n.completion),` out`]},`t`)],[`Failovers`,(0,z.jsx)(`span`,{className:`tnum font-mono`,children:e.failovers},`f`)]];return(0,z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,z.jsx)(`dl`,{className:`grid grid-cols-[110px_1fr] gap-x-4 gap-y-2 text-[13px]`,children:a.map(([e,t])=>(0,z.jsxs)(`div`,{className:`contents`,children:[(0,z.jsx)(`dt`,{className:`text-muted`,children:e}),(0,z.jsx)(`dd`,{className:`min-w-0 text-fg`,children:t})]},e))}),(0,z.jsxs)(`section`,{"aria-labelledby":`attempts-title`,children:[(0,z.jsx)(`h3`,{id:`attempts-title`,className:`mb-2 text-[12px] font-medium text-fg-2`,children:`Attempts`}),(0,z.jsx)(`ol`,{className:`relative flex flex-col gap-0`,children:e.attempts.map((n,r)=>{let a=t.get(n.accountId),o=n.startedTs-e.startedTs,c=r===e.attempts.length-1;return(0,z.jsxs)(`li`,{className:`relative flex gap-3 pb-4 last:pb-0`,children:[!c&&(0,z.jsx)(`span`,{"aria-hidden":!0,className:`absolute top-7 bottom-0 left-[11px] w-px bg-line-strong`}),(0,z.jsx)(`span`,{className:i(`z-10 mt-0.5 flex size-6 shrink-0 items-center justify-center rounded-full border text-[10px] font-semibold`,n.outcome===`success`?`border-ok/40 bg-ok-soft text-ok`:n.outcome===`failed`?`border-err/40 bg-err-soft text-err`:`border-info/40 bg-info-soft text-info`),children:r+1}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1 rounded-md border border-line bg-raised p-2.5`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(C,{provider:n.provider,size:`sm`}),(0,z.jsx)(`span`,{className:`truncate text-[13px] font-medium text-fg`,children:a?.label??n.accountId}),(0,z.jsx)(`span`,{className:`ml-auto`,children:n.outcome===`success`?(0,z.jsx)(h,{tone:`ok`,children:`served`}):n.outcome===`failed`?(0,z.jsxs)(h,{tone:`err`,mono:!0,children:[g(n),` `,n.errorKind]}):(0,z.jsx)(h,{tone:`info`,dot:!0,pulse:!0,children:`in flight`})})]}),(0,z.jsxs)(`p`,{className:`tnum mt-1.5 font-mono text-2xs text-muted`,children:[n.accountId,` · +`,d(o),n.latencyMs!==void 0&&` · took ${d(n.latencyMs)}`,n.outcome===`success`&&` · ${s(n.promptTokens??0)} → ${s(n.completionTokens??0)} tok`]}),n.errorMessage&&(0,z.jsx)(`p`,{className:`mt-1.5 text-[12px] text-fg-2`,children:n.errorMessage})]})]},r)})})]}),(0,z.jsxs)(`details`,{className:`rounded-md border border-line`,children:[(0,z.jsx)(`summary`,{className:`px-3 py-2 text-[12px] font-medium text-fg-2 select-none hover:text-fg`,children:`Raw chain`}),(0,z.jsx)(`pre`,{className:`max-h-80 overflow-auto border-t border-line p-3 font-mono text-2xs leading-5 text-fg-2`,children:JSON.stringify(e,null,2)})]})]})}function K(e,t){switch(t){case`ok`:return e.outcome===`success`&&e.failovers===0;case`failover`:return e.failovers>0;case`failed`:return e.outcome===`failed`;case`pending`:return e.outcome===`pending`;default:return!0}}var q=250;function J(){let e=o(),{connection:t}=a(),n=p(),{params:r}=T(),[s,g]=(0,R.useState)(``),[_,C]=(0,R.useState)(`all`),[w,E]=(0,R.useState)(``),[O,I]=(0,R.useState)(null),L=(0,R.useMemo)(()=>new Map((n.data??[]).map(e=>[e.id,e])),[n.data]),V=O??e.chains,H=O?Math.max(0,e.chains.length-O.length):0,G=(0,R.useMemo)(()=>{let e={all:0,ok:0,failover:0,failed:0,pending:0};for(let t of V)e.all+=1,K(t,`ok`)&&(e.ok+=1),K(t,`failover`)&&(e.failover+=1),K(t,`failed`)&&(e.failed+=1),K(t,`pending`)&&(e.pending+=1);return e},[V]),J=s.trim().toLowerCase(),Y=V.filter(e=>K(e,_)&&(!w||e.attempts.some(e=>e.accountId===w))&&(!J||e.requestId.toLowerCase().includes(J)||e.model.toLowerCase().includes(J)||e.attempts.some(e=>e.accountId.toLowerCase().includes(J)||(L.get(e.accountId)?.label.toLowerCase().includes(J)??!1)))).slice(0,q),X=r.get(`req`),Z=X?e.chains.find(e=>e.requestId===X):void 0,Q=e.chains.length===0&&t.mode!==`live`;return(0,z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,z.jsx)(D,{title:`Traffic`,description:`Every request through /v1, with failover hops shown inline.`,actions:(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[O?(0,z.jsxs)(h,{tone:`warn`,children:[`paused`,H>0&&` · ${H} new`]}):(0,z.jsx)(h,{tone:`ok`,dot:!0,pulse:!0,children:`streaming`}),(0,z.jsx)(N,{icon:O?v:x,onClick:()=>I(O?null:e.chains),"aria-pressed":!!O,children:O?`Resume`:`Pause`})]})}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsxs)(`div`,{className:`relative w-full sm:w-64`,children:[(0,z.jsx)(y,{"aria-hidden":!0,className:`pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2 text-muted`,strokeWidth:1.75}),(0,z.jsx)(P,{type:`search`,"aria-label":`Filter requests`,placeholder:`Model, request id or account`,value:s,onChange:e=>g(e.target.value),className:`pl-8`,"data-filter-input":!0})]}),(0,z.jsx)(j,{label:`Outcome`,value:_,onChange:C,options:[{value:`all`,label:`All`,count:G.all},{value:`ok`,label:`OK`,count:G.ok},{value:`failover`,label:`Failover`,count:G.failover},{value:`failed`,label:`Failed`,count:G.failed},{value:`pending`,label:`In flight`,count:G.pending}]}),(0,z.jsxs)(F,{"aria-label":`Filter by account`,value:w,onChange:e=>E(e.target.value),className:`w-auto min-w-44`,children:[(0,z.jsx)(`option`,{value:``,children:`All accounts`}),(n.data??[]).map(e=>(0,z.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]}),(0,z.jsx)(k,{children:Q?(0,z.jsx)(M,{rows:8}):Y.length===0?e.chains.length===0?(0,z.jsx)(A,{icon:S,title:`No requests yet`,description:`Point any OpenAI-compatible client at the gateway and use a davecode/<route> model.`,command:`curl http://127.0.0.1:4040/v1/chat/completions -H 'content-type: application/json' -d '{"model":"davecode/auto","messages":[{"role":"user","content":"hi"}]}'`}):(0,z.jsx)(A,{icon:y,title:`No matching requests`,description:`Try a different filter.`}):(0,z.jsx)(`div`,{className:`overflow-x-auto`,children:(0,z.jsxs)(`table`,{className:`w-full min-w-[920px] text-[12px]`,children:[(0,z.jsx)(`caption`,{className:`sr-only`,children:`Recent requests, newest first`}),(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{className:`border-b border-line text-left text-muted`,children:[(0,z.jsx)(`th`,{scope:`col`,className:`w-24 px-3.5 py-2 font-medium`,children:`Time`}),(0,z.jsx)(`th`,{scope:`col`,className:`w-24 px-2 py-2 font-medium`,children:`Request`}),(0,z.jsx)(`th`,{scope:`col`,className:`w-40 px-2 py-2 font-medium`,children:`Model`}),(0,z.jsx)(`th`,{scope:`col`,className:`px-2 py-2 font-medium`,children:`Accounts`}),(0,z.jsx)(`th`,{scope:`col`,className:`w-20 px-2 py-2 text-right font-medium`,children:`Latency`}),(0,z.jsx)(`th`,{scope:`col`,className:`w-28 px-2 py-2 text-right font-medium`,children:`Tokens in → out`}),(0,z.jsx)(`th`,{scope:`col`,className:`w-36 px-3.5 py-2 text-right font-medium`,children:`Status`})]})}),(0,z.jsx)(`tbody`,{children:Y.map(e=>{let t=f(e),n=c(e);return(0,z.jsxs)(`tr`,{onClick:()=>b(`req`,e.requestId),className:i(`animate-row-in cursor-pointer border-b border-line transition-colors duration-150 last:border-b-0 hover:bg-hover/60`,X===e.requestId&&`bg-hover/60`),children:[(0,z.jsx)(`td`,{className:`tnum px-3.5 py-2 font-mono text-muted`,children:m(e.startedTs)}),(0,z.jsx)(`td`,{className:`px-2 py-2`,children:(0,z.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),b(`req`,e.requestId)},className:`font-mono text-fg-2 hover:text-fg hover:underline focus-visible:underline`,"aria-label":`Open request ${e.requestId}`,children:l(e.requestId)})}),(0,z.jsx)(`td`,{className:`max-w-0 truncate px-2 py-2 font-mono text-fg`,children:e.model||`—`}),(0,z.jsx)(`td`,{className:`max-w-0 px-2 py-1.5`,children:(0,z.jsx)(B,{chain:e,accounts:L})}),(0,z.jsx)(`td`,{className:`tnum px-2 py-2 text-right font-mono text-fg-2`,children:n===void 0?`…`:d(n)}),(0,z.jsx)(`td`,{className:`tnum px-2 py-2 text-right font-mono text-fg-2`,children:t.prompt||t.completion?(0,z.jsxs)(z.Fragment,{children:[u(t.prompt),` `,(0,z.jsx)(`span`,{className:`text-faint`,children:`→`}),` `,u(t.completion)]}):(0,z.jsx)(`span`,{className:`text-faint`,children:`—`})}),(0,z.jsx)(`td`,{className:`px-3.5 py-2 text-right`,children:(0,z.jsx)(U,{chain:e})})]},e.requestId)})})]})})}),Y.length===q&&(0,z.jsxs)(`p`,{className:`text-center text-[12px] text-muted`,children:[`Showing the latest `,q,` requests.`]}),(0,z.jsx)(W,{chain:Z,accounts:L,onClose:()=>b(`req`,null)})]})}export{J as Traffic};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e,o as t,r as n}from"./cn-BwE4cei0.js";import{B as r,C as i,M as a,N as o,T as s,ft as c,g as l,p as u,pt as d}from"./Badge-DUGKlx3Z.js";import{t as f}from"./arrow-up-DjhzZprp.js";import{t as p}from"./Markdown-CGgIydUh.js";import{t as m}from"./Callout-1E8Wsl9W.js";import{B as h,D as g,E as _,F as v,k as y,q as b,w as x}from"./index-B8kld9xo.js";import{GoalDetail as S,isActiveGoal as C,t as w}from"./Goals-kL4VAxw3.js";var T=t(e(),1),E=n(),D={planning:`Putting a plan together`,running:`Working on it`,reviewing:`Checking the result`,planned:`Your plan is ready`,succeeded:`Done`,failed:`Something needs attention`,cancelled:`Stopped`,budget_exhausted:`Usage limit reached`},O=[{title:`Make something`,prompt:`Help me turn an idea into something useful. First help me define who it is for and what it should do.`},{title:`Understand a project`,prompt:`Explain this project in plain language and write a short getting-started guide for someone without a technical background.`},{title:`Improve a design`,prompt:`Review this project’s interface. Propose a distinctive visual direction, explain the most useful improvements and make a plan before changing code.`}];function k(){let{params:e}=y(),{connection:t}=r(),n=s(),k=u(),A=o(),j=a(),M=i(),N=l(),P=(0,T.useRef)(null),[F,I]=(0,T.useState)(()=>(e.get(`brief`)??``).slice(0,4e3)),[L,R]=(0,T.useState)(`plan`),[z,B]=(0,T.useState)(`50000`),[V,H]=(0,T.useState)(),U=n.data??[],W=U.find(C),G=e.has(`new`)||e.has(`brief`)?void 0:U.find(t=>t.id===e.get(`goal`))??W,K=t.mode===`mock`,q=d(n.error)&&n.error.status===501,J=(k.data??[]).some(e=>e.enabled),Y=n.isPending||n.isError||k.isPending||k.isError||!J||j.isPending||!!W&&L===`work`;function X(e){e.preventDefault(),!Y&&F.trim()&&(H(void 0),j.mutate({objective:F.trim(),dryRun:L===`plan`,maxTokens:Number(z)},{onSuccess:e=>{I(``),g(`/?goal=${encodeURIComponent(e.id)}`)},onError:e=>H(c(e))}))}return(0,E.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[780px] flex-1 flex-col`,children:[K&&(0,E.jsxs)(`p`,{className:`mb-4 text-center text-[12px] text-muted`,children:[`This is a demo.`,` `,(0,E.jsx)(_,{to:`/settings`,className:`underline`,children:`Connect your device`}),` `,`to work on your files.`]}),q&&(0,E.jsxs)(m,{tone:`warn`,title:`Open a project to start`,children:[`Start DaveCode in your project folder.`,` `,(0,E.jsx)(_,{to:`/goals`,className:`underline`,children:`Setup instructions`})]}),n.isError&&!q&&(0,E.jsx)(m,{tone:`err`,title:`Could not load your work`,children:c(n.error)}),k.isError&&(0,E.jsx)(m,{tone:`err`,title:`Could not load AI connections`,children:c(k.error)}),G?(0,E.jsxs)(`div`,{className:`flex flex-1 flex-col gap-7 pb-10 pt-6`,children:[(0,E.jsx)(`div`,{className:`ml-auto max-w-[90%] rounded-2xl bg-raised px-5 py-4 text-[15px] leading-7 text-fg`,children:G.objective}),(0,E.jsxs)(`section`,{"aria-labelledby":`work-status`,className:`px-1`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,E.jsx)(`h1`,{id:`work-status`,className:`text-[19px] font-medium tracking-tight text-fg`,children:D[G.status]}),C(G)&&(0,E.jsx)(x,{size:`sm`,variant:`ghost`,icon:v,loading:N.isPending,onClick:()=>N.mutate(G.id,{onError:e=>H(c(e))}),children:`Stop`})]}),G.tasks.length>0&&(0,E.jsx)(`ol`,{className:`mt-5 flex flex-col gap-4`,children:G.tasks.map(e=>(0,E.jsxs)(`li`,{className:`flex items-start gap-3 text-[14px] leading-6 text-fg-2`,children:[e.status===`SUCCESS`?(0,E.jsx)(b,{"aria-hidden":!0,className:`mt-1 size-4 shrink-0 text-fg-2`}):(0,E.jsx)(`span`,{className:`mt-0.5 w-4 shrink-0 text-center text-muted`,"aria-hidden":!0,children:e.id===G.activeTaskId?`→`:`−`}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`span`,{children:e.title}),e.status===`FAILED`&&(0,E.jsx)(`p`,{className:`mt-1 text-[12px] text-err`,children:`This step needs attention.`})]})]},e.id))}),G.summary&&(0,E.jsx)(p,{source:G.summary,className:`mt-6 text-[14px]`}),G.lastError&&(0,E.jsx)(`p`,{role:`alert`,className:`mt-4 text-[13px] text-err`,children:G.lastError}),G.status===`planned`&&(0,E.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-center gap-3`,children:[(0,E.jsx)(x,{size:`sm`,variant:`primary`,icon:h,loading:M.isPending,disabled:!!W,onClick:()=>{H(void 0),M.mutate(G.id,{onError:e=>H(c(e))})},children:`Execute this plan`}),(0,E.jsx)(`span`,{className:`text-[13px] leading-6 text-muted`,children:`Runs the planned steps above without re-planning.`})]})]}),(0,E.jsxs)(`details`,{className:`text-[12px] text-muted`,children:[(0,E.jsx)(`summary`,{className:`mb-3 cursor-pointer`,children:`Task details`}),(0,E.jsx)(S,{goal:G},G.id)]})]}):(0,E.jsxs)(`section`,{className:`flex flex-1 flex-col items-center justify-center pb-8 pt-16 text-center md:pt-20`,children:[(0,E.jsx)(`h1`,{className:`text-3xl font-medium tracking-tight text-fg md:text-[38px]`,children:`What are we making?`}),(0,E.jsx)(`p`,{className:`mt-3 text-[15px] text-muted`,children:`An idea is a good place to start.`}),(0,E.jsx)(`div`,{className:`mt-8 flex flex-wrap justify-center gap-2`,children:O.map(e=>(0,E.jsx)(`button`,{type:`button`,onClick:()=>{I(e.prompt),R(`plan`),P.current?.focus()},className:`rounded-xl border border-line px-4 py-3 text-[13px] text-fg-2 transition-colors hover:border-line-strong hover:bg-hover`,children:e.title},e.title))})]}),(0,E.jsxs)(`div`,{className:`sticky bottom-0 bg-bg pb-3 pt-3`,children:[(0,E.jsxs)(`form`,{onSubmit:X,className:`rounded-2xl border border-line-strong bg-panel p-4 focus-within:border-faint`,children:[(0,E.jsx)(`label`,{htmlFor:`workspace-composer`,className:`sr-only`,children:`What would you like to do?`}),(0,E.jsx)(`textarea`,{id:`workspace-composer`,ref:P,required:!0,rows:3,maxLength:4e3,value:F,onChange:e=>I(e.target.value),placeholder:`Describe what you have in mind…`,"aria-describedby":V?`workspace-error`:void 0,className:`block w-full resize-none border-0 bg-transparent px-1 py-2 text-[15px] leading-6 text-fg outline-none placeholder:text-muted`}),(0,E.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3`,children:[(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,E.jsx)(`label`,{className:`sr-only`,htmlFor:`workspace-mode`,children:`How to start`}),(0,E.jsxs)(`select`,{id:`workspace-mode`,value:L,onChange:e=>R(e.target.value),className:`max-w-44 rounded-lg border-0 bg-transparent py-2 pr-3 text-[12px] text-fg-2 outline-accent`,children:[(0,E.jsx)(`option`,{value:`plan`,children:`Plan first`}),(0,E.jsx)(`option`,{value:`work`,children:`Plan and work`})]}),(0,E.jsxs)(`details`,{className:`relative`,children:[(0,E.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-1 text-[12px] text-muted`,children:[`Options`,(0,E.jsx)(w,{"aria-hidden":!0,className:`size-3`})]}),(0,E.jsxs)(`div`,{className:`absolute bottom-9 left-0 z-10 w-56 rounded-xl border border-line-strong bg-panel p-4 shadow-overlay`,children:[(0,E.jsx)(`label`,{htmlFor:`workspace-limit`,className:`text-[12px] text-fg-2`,children:`AI usage limit`}),(0,E.jsxs)(`select`,{id:`workspace-limit`,value:z,onChange:e=>B(e.target.value),className:`mt-2 w-full rounded-md border border-line-strong bg-panel px-2 py-2 text-[12px] text-fg`,children:[(0,E.jsx)(`option`,{value:`50000`,children:`50k tokens`}),(0,E.jsx)(`option`,{value:`250000`,children:`250k tokens`}),(0,E.jsx)(`option`,{value:`1000000`,children:`1m tokens`})]}),(0,E.jsx)(`p`,{className:`mt-2 text-[11px] leading-5 text-muted`,children:`A usage limit, not a price cap.`})]})]})]}),(0,E.jsx)(x,{type:`submit`,icon:f,iconOnly:!0,"aria-label":K?`Try demo`:L===`plan`?`Make a plan`:`Start working`,variant:`primary`,disabled:Y||!F.trim(),loading:j.isPending,className:`size-9 rounded-xl`})]})]}),V&&(0,E.jsx)(`p`,{id:`workspace-error`,role:`alert`,className:`mt-2 text-[12px] text-err`,children:V}),!k.isPending&&!k.isError&&!J&&(0,E.jsxs)(`p`,{className:`mt-3 text-center text-[12px] text-muted`,children:[(0,E.jsx)(_,{to:`/accounts`,className:`underline`,children:`Connect an AI tool`}),` `,`to get started.`]}),W&&L===`work`&&(0,E.jsx)(`p`,{role:`status`,className:`mt-3 text-center text-[12px] text-muted`,children:`A task is running. You can still plan the next one.`}),(0,E.jsxs)(`p`,{className:`mt-3 text-center text-[11px] leading-5 text-muted`,children:[L===`plan`?`Planning does not execute tasks.`:`Execution can edit files and merge changes.`,A.data?.project?` Working in ${A.data.project.name}.`:``]})]})]})}export{k as Workspace};
|