@hearsay-tools/squawk 0.19.0-dev.9210 → 0.19.0-dev.9220
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/dist/ci-wait/controller.d.ts +7 -7
- package/dist/features/hosts/routes.d.ts +64 -64
- package/dist/features/webhooks/routes.d.ts +38 -38
- package/dist/server/activity-routes.d.ts +23 -23
- package/dist/server/projects-routes.d.ts +41 -41
- package/dist/server/runs-routes.d.ts +311 -311
- package/package.json +4 -4
- package/web/dist/assets/accounts-section-s6sAdUT8.js +1 -0
- package/web/dist/assets/activity-motion-CXlbNrMI.js +1 -0
- package/web/dist/assets/{activity-route-BNDRi4k-.js → activity-route-BL-QWLNp.js} +1 -1
- package/web/dist/assets/agent-accounts-Du8CHfFX.js +1 -0
- package/web/dist/assets/agent-config-section-BzMSlPK0.js +7 -0
- package/web/dist/assets/agent-defaults-section-CqEVmRK0.js +1 -0
- package/web/dist/assets/appearance-vI6ae_So.js +1 -0
- package/web/dist/assets/archive-on-merge-field-C4hrO55O.js +1 -0
- package/web/dist/assets/ask-card-hEb8IHjL.js +9 -0
- package/web/dist/assets/automations-route-Bd6crv15.js +2 -0
- package/web/dist/assets/commit-list-Jr1_04RS.js +1 -0
- package/web/dist/assets/diff-BOF9OXhn.js +3 -0
- package/web/dist/assets/{diff-controls-C_ysCTVK.js → diff-controls-CkxtRrbB.js} +1 -1
- package/web/dist/assets/{diff-view-f2Zb3Tuc.js → diff-view-Chu6rn_i.js} +1 -1
- package/web/dist/assets/{discard-changes-dialog-Db5fnRbe.js → discard-changes-dialog-BB47RqdX.js} +1 -1
- package/web/dist/assets/file-preview-DNM-krBZ.js +2 -0
- package/web/dist/assets/folder-browser-TNWat5kt.js +1 -0
- package/web/dist/assets/{git-toolbar-DasGkLg-.js → git-toolbar-CoKBTzNV.js} +1 -1
- package/web/dist/assets/github-t611QkCi.js +1 -0
- package/web/dist/assets/{global-activity-route-DZtIc9Y6.js → global-activity-route-B9DMoviv.js} +1 -1
- package/web/dist/assets/{host-context-DDbYAKpm.js → host-context-iTMFRMT5.js} +1 -1
- package/web/dist/assets/host-storage-Cr_NKfWy.js +1 -0
- package/web/dist/assets/hosts-rdWe_OBc.js +1 -0
- package/web/dist/assets/{image-preview-CdL9a1Zj.js → image-preview-C_xACQXI.js} +1 -1
- package/web/dist/assets/index-C3kap2_j.js +21 -0
- package/web/dist/assets/index-CWmMYQdT.css +1 -0
- package/web/dist/assets/label-B_s8eiYA.js +1 -0
- package/web/dist/assets/{markdown-B4JilOS6.js → markdown-Bmdr6MIa.js} +1 -1
- package/web/dist/assets/{open-in-menu-Bf8JA2DJ.js → open-in-menu-DkFneOWr.js} +1 -1
- package/web/dist/assets/{option-select-C7kknSij.js → option-select-BxTmKg8G.js} +1 -1
- package/web/dist/assets/preferences-section-B_yl_o-g.js +1 -0
- package/web/dist/assets/preview-D3zYSmIA.js +1 -0
- package/web/dist/assets/{preview-pane-connected-BdBFebn0.js → preview-pane-connected-s9LvCVbp.js} +2 -2
- package/web/dist/assets/project-location-BczZtNyO.js +1 -0
- package/web/dist/assets/project-router-CfEuKuz1.js +1 -0
- package/web/dist/assets/project-scope-context-DNrHbqd2.js +4 -0
- package/web/dist/assets/projects-section-C6DnyUa2.js +1 -0
- package/web/dist/assets/{prompt-templates-section-Br5uL5GK.js → prompt-templates-section-BQvKWcaX.js} +2 -2
- package/web/dist/assets/queries-DD_9iITj.js +1 -0
- package/web/dist/assets/reference-chip-e-fG4-yW.js +1 -0
- package/web/dist/assets/remote-settings-notice-CUqI2DdF.js +1 -0
- package/web/dist/assets/repo-git-NG_TxE7N.js +1 -0
- package/web/dist/assets/report-reader-LYNHrAe-.js +1 -0
- package/web/dist/assets/{report-selection-Y2F9NTAs.js → report-selection-nUbQVjJu.js} +1 -1
- package/web/dist/assets/reports-DuT4m7i5.js +1 -0
- package/web/dist/assets/{resources-section-DEvZicO3.js → resources-section-CT48TCXY.js} +1 -1
- package/web/dist/assets/{review-notes-drafts-dS7OB8et.js → review-notes-drafts-C7HCRebB.js} +1 -1
- package/web/dist/assets/{review-panel-BRdqkYjE.js → review-panel-BffLSkRo.js} +1 -1
- package/web/dist/assets/review-strip-COa0ir6V.js +1 -0
- package/web/dist/assets/{run-detail-refresh-SYZM94ch.js → run-detail-refresh-Db5HOGMX.js} +1 -1
- package/web/dist/assets/{run-diff-D26PXp6r.js → run-diff-DldSY8BJ.js} +1 -1
- package/web/dist/assets/run-header-DxpN6yVQ.js +2 -0
- package/web/dist/assets/{select-DGNeDPgB.js → select-Cd8wvwvm.js} +1 -1
- package/web/dist/assets/{session-context-section-5kleIwBF.js → session-context-section-CW8DS0dW.js} +1 -1
- package/web/dist/assets/settings-agent-picker-an3ysM1B.js +1 -0
- package/web/dist/assets/{settings-save-bar-BBRySnQz.js → settings-save-bar-BiHFQ4c0.js} +1 -1
- package/web/dist/assets/settings-shell-KZ801oLH.js +1 -0
- package/web/dist/assets/sidebar-section-BRMO7aY4.js +1 -0
- package/web/dist/assets/skills-DHkLoxXb.js +1 -0
- package/web/dist/assets/status-dot-Da1M54kK.js +1 -0
- package/web/dist/assets/{tab-link-BJDe5cT4.js → tab-link-DL1UtKVR.js} +1 -1
- package/web/dist/assets/task-changes-CQhwyj0L.js +5 -0
- package/web/dist/assets/task-commits-CTP8izpc.js +1 -0
- package/web/dist/assets/{task-file-scope-DIKRE_b-.js → task-file-scope-CDIfOvl-.js} +1 -1
- package/web/dist/assets/task-files-CGlRH86B.js +1 -0
- package/web/dist/assets/task-github-item-ChgjULzj.js +1 -0
- package/web/dist/assets/task-thread-Cj9B2ISO.js +2 -0
- package/web/dist/assets/thread-state-D2KJrZ1o.js +4 -0
- package/web/dist/assets/use-finish-run-DifixlCM.js +1 -0
- package/web/dist/assets/use-hand-to-agent-state-Bjh1EnB3.js +1 -0
- package/web/dist/assets/use-path-bases-AV9YYh2B.js +1 -0
- package/web/dist/assets/use-workspace-config-save-02qlUK8v.js +1 -0
- package/web/dist/assets/{workflows-tS2KFiN5.js → workflows-BDc-MpiC.js} +2 -2
- package/web/dist/assets/workspace-tools-D7kUSb-0.js +1 -0
- package/web/dist/assets/{worktrees-section-Be49G15q.js → worktrees-section-Cv65NBgq.js} +5 -5
- package/web/dist/assets/{zoomable-image-CULOtYYp.js → zoomable-image-DJ1lJEMc.js} +1 -1
- package/web/dist/index.html +17 -20
- package/web/dist/live-worker.js +1 -1
- package/web/dist/assets/accounts-section-rl1VZO3h.js +0 -1
- package/web/dist/assets/activity-motion-z61Fgew-.js +0 -1
- package/web/dist/assets/agent-accounts-C2ILQhZy.js +0 -1
- package/web/dist/assets/agent-config-section-n-pEsz22.js +0 -7
- package/web/dist/assets/agent-defaults-section-D-HJwVes.js +0 -1
- package/web/dist/assets/appearance-BtRmAcNb.js +0 -1
- package/web/dist/assets/archive-on-merge-field-CvMwaqSO.js +0 -1
- package/web/dist/assets/ask-card-BwUCf0aZ.js +0 -9
- package/web/dist/assets/attention-C7BUdd2s.js +0 -1
- package/web/dist/assets/automations-route-DTiAXiUI.js +0 -2
- package/web/dist/assets/commit-list-C9Hv9ml6.js +0 -1
- package/web/dist/assets/diff-Cj-x8nqJ.js +0 -3
- package/web/dist/assets/file-preview-Cyj25xiD.js +0 -2
- package/web/dist/assets/folder-browser-3cBLlnE9.js +0 -1
- package/web/dist/assets/github-DCg3ksYv.js +0 -1
- package/web/dist/assets/host-storage-B72yoDU1.js +0 -1
- package/web/dist/assets/hosts-iUyg8S3j.js +0 -1
- package/web/dist/assets/index-DDSPQb52.css +0 -1
- package/web/dist/assets/index-DKnr4QWH.js +0 -21
- package/web/dist/assets/label-CWlxyeC-.js +0 -1
- package/web/dist/assets/preferences-section-fRAjnH9V.js +0 -1
- package/web/dist/assets/preview-BSFJfN4s.js +0 -1
- package/web/dist/assets/project-location-J285aq6e.js +0 -1
- package/web/dist/assets/project-router-CwD1firw.js +0 -1
- package/web/dist/assets/projects-section-CTJAcTFT.js +0 -1
- package/web/dist/assets/queries-D9mg7sFY.js +0 -1
- package/web/dist/assets/read-state-BsTfJki5.js +0 -1
- package/web/dist/assets/reference-chip-CZKBU_Ud.js +0 -1
- package/web/dist/assets/remote-settings-notice-oiFixJ1Q.js +0 -1
- package/web/dist/assets/repo-git-BnF9zc0t.js +0 -1
- package/web/dist/assets/report-reader-CAKZUxHi.js +0 -1
- package/web/dist/assets/reports-DLzhtnVJ.js +0 -1
- package/web/dist/assets/review-strip-BCrYmUm6.js +0 -1
- package/web/dist/assets/run-header-sCyLqpuL.js +0 -2
- package/web/dist/assets/settings-agent-picker-BHaCHv3L.js +0 -1
- package/web/dist/assets/settings-shell-NnVky05a.js +0 -1
- package/web/dist/assets/sidebar-section-CJttxkBb.js +0 -1
- package/web/dist/assets/skills-BWhCi78k.js +0 -1
- package/web/dist/assets/status-dot-DTU7afRv.js +0 -1
- package/web/dist/assets/task-changes-DxraCwDD.js +0 -5
- package/web/dist/assets/task-commits-BT54zRvY.js +0 -1
- package/web/dist/assets/task-files-BzhShCDY.js +0 -1
- package/web/dist/assets/task-github-item-NuNVjHSM.js +0 -1
- package/web/dist/assets/task-groups-BvVfsQKd.js +0 -1
- package/web/dist/assets/task-thread-Kb7rfaii.js +0 -2
- package/web/dist/assets/thread-state-BLwCv9hp.js +0 -4
- package/web/dist/assets/toaster-2ud_VdfV.js +0 -4
- package/web/dist/assets/use-finish-run-CfvaMV-b.js +0 -1
- package/web/dist/assets/use-hand-to-agent-state-DykS8SPU.js +0 -1
- package/web/dist/assets/use-path-bases-B7D8PPso.js +0 -1
- package/web/dist/assets/use-workspace-config-save-DDI7_WtK.js +0 -1
- package/web/dist/assets/workspace-tools-B5wyKj6g.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{K as r,Lt as i,Vt as a,en as o,ln as s,on as c,qt as l,st as u,un as d}from"./queries-D9mg7sFY.js";import{$n as f,Cn as p,Fi as m,Nr as h,On as g,Qn as _,Tn as ee,Xr as te,_i as ne,ai as v,ci as y,er as b,jt as x,n as re,ni as ie,rt as ae,sr as S,wi as oe,wn as se,xi as ce}from"./toaster-2ud_VdfV.js";import{B as C,C as le,F as w,G as ue,I as T,J as de,N as E,P as fe,T as pe,W as D,Y as me,j as O,z as k}from"./live-protocol-CNUmr-VT.js";import{n as A}from"./chunk-KS7C4IRE-BdLLx37K.js";import{o as j}from"./dist-CCX8mhHc.js";import{r as he}from"./run-detail-refresh-SYZM94ch.js";import{mt as ge,t as _e}from"./design-icons-QbNMZniQ.js";import{t as ve}from"./createLucideIcon-BHp8sXmF.js";import{t as ye}from"./ask-card-BwUCf0aZ.js";import{t as be}from"./arrow-right-Dh_Lx3um.js";import{t as xe}from"./arrow-up-right-DKGzsMqY.js";import{t as Se}from"./bot-TkDIw4y-.js";import{t as Ce}from"./external-link-BE6y205O.js";import{t as we}from"./info-DA1x_4bz.js";import{t as Te}from"./message-square-B-MD-8rD.js";import{a as Ee,o as De,r as Oe}from"./tool-display-CTbToGmi.js";import{t as M}from"./button-BV_AiLj2.js";import{i as ke,r as Ae,t as je}from"./popover-BQolmvDR.js";import{t as N}from"./project-router-CwD1firw.js";import"./attention-C7BUdd2s.js";import{t as P}from"./status-dot-DTU7afRv.js";import{c as Me,i as Ne,l as Pe,o as Fe,r as Ie,s as Le}from"./report-selection-Y2F9NTAs.js";import"./page-shell-BdjH5hyc.js";import{An as Re,un as ze}from"./index-DKnr4QWH.js";import{t as Be}from"./textarea-BGp28xFr.js";import{t as Ve}from"./use-finish-run-CfvaMV-b.js";import{t as He}from"./review-panel-BRdqkYjE.js";var Ue=ve(`folder-kanban`,[[`path`,{d:`M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z`,key:`1fr9dc`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M12 10v2`,key:`hh53o1`}],[`path`,{d:`M16 10v6`,key:`1d6xys`}]]),F=e(t(),1),I=n(),L=me(),R=k().int().nonnegative(),z=D().min(1),We=C({title:D().max(160),toolKind:O([`read`,`edit`,`delete`,`move`,`search`,`execute`,`think`,`fetch`,`task`,`plan`,`other`]),status:O([`pending`,`running`,`completed`,`failed`,`declined`]),startedAt:L,endedAt:L.optional()}).strict(),Ge=O([`pass`,`fail`,`pending`,`skipping`,`cancel`]),Ke=C({checks:E(C({name:D().max(100),bucket:Ge}).strict()).max(100),counts:C({pass:R,fail:R,pending:R,skipping:R,cancel:R}).strict(),truncated:T(!0).optional()}).strict(),qe=w(`kind`,[C({kind:T(`human`),since:L,detail:C({question:D().max(500).optional(),reason:O([`question`,`turn-end`,`budget`,`completion`]),queuedMessages:k().int().positive().optional()}).strict()}).strict(),C({kind:T(`usage-limit`),detail:C({resumeAt:D()}).strict()}).strict(),C({kind:T(`workers`),since:L,deadline:L.optional(),detail:C({owed:R,total:R,settled:R,replies:T(!0).optional(),mode:le.optional(),recipientRunIds:E(z)}).strict()}).strict(),C({kind:T(`peers`),since:L,deadline:L,detail:C({peerRunIds:E(z)}).strict()}).strict(),C({kind:T(`subagents`),since:L,deadline:L,detail:C({running:R}).strict()}).strict(),C({kind:T(`pr`),since:L,deadline:L,detail:C({number:k().int().positive(),target:h,checks:Ke.shape.checks.optional(),counts:Ke.shape.counts.optional(),truncated:T(!0).optional()}).strict()}).strict(),C({kind:T(`process`),since:L,deadline:L,detail:C({pid:k().int(),note:D().optional()}).strict()}).strict(),C({kind:T(`plugin`),since:L,deadline:L.optional(),detail:C({pluginKind:D().min(1).max(64),summary:D().max(256)}).strict()}).strict(),C({kind:T(`timer`),since:L,deadline:L,detail:C({wakeAt:L,note:D().optional()}).strict()}).strict()]),Je={runId:z,title:D(),status:ne,rung:O(ie),runner:ce.optional(),model:D().optional(),currentStepId:D().optional(),createdAt:D().optional(),startedAt:D().optional(),finishedAt:D().optional(),wait:qe.optional(),tool:We.optional(),rate:E(R).length(30),error:D().max(200).optional()},Ye=C({...Je,revision:R,collected:fe()}).strict(),Xe=C({...Je,workers:E(Ye)}).strict(),Ze=C({requestId:de(),relationship:O([`family`,`peer`]),senderRunId:z,recipientRunId:z,text:D().max(500),senderTitle:D().optional(),recipientTitle:D().optional(),createdAt:L,deadline:L.optional()}).strict(),Qe=C({requestId:de(),senderRunId:z,recipientRunId:z,status:pe.shape.status,observedAt:L}).strict(),$e=C({generatedAt:L,projects:E(C({projectId:D(),name:D(),loaded:fe(),unavailable:C({status:ue([T(404),T(409),T(503)]),error:D()}).strict().optional(),inReview:R,tasks:E(Xe),requests:E(Ze),closed:E(Qe)}).strict())}).strict();C({project:ue([T(`default`),D().regex(te)]).optional()});var et=5e3,tt=e=>[`workspace`,`activity`,e.kind===`project`?e.projectId:null],nt=e=>e.kind===`project`?`activity:project:${e.projectId}`:`activity:workspace`,rt=e=>e.kind===`project`?`/api/v1/workspace/activity?project=${encodeURIComponent(e.projectId)}`:`/api/v1/workspace/activity`,it=`the Squawk server answered /workspace/activity with an unexpected body`;function at(e){let t=$e.safeParse(e);if(!t.success)throw new p(200,it);return t.data}async function ot(e,t){let n=e.kind===`project`?{project:e.projectId}:{};return at(await g(await se.api.v1.workspace.activity.$get({query:n},ee(t)),`/workspace/activity`))}function st(e,t){return e!==void 0&&Date.parse(t.generatedAt)<Date.parse(e.generatedAt)?e:t}var ct=new Date(0).toISOString();function lt(e){return e!==void 0&&e!==ct&&!Number.isNaN(Date.parse(e))}var ut=new Set([404,409,503]);function dt(e,t,n,r){let i=e?.projects.find(e=>e.projectId===t)?.name??t;return{generatedAt:e?.generatedAt??ct,projects:[{projectId:t,name:i,loaded:!0,unavailable:{status:n,error:r},inReview:0,tasks:[],requests:[],closed:[]}]}}function ft(e,t){return new p(Number(/^HTTP (\d+)$/.exec(t)?.[1]??0),e&&typeof e==`object`&&typeof e.error==`string`?e.error:t)}var pt=(e,t)=>e.kind===`project`&&ut.has(t.status)?t.status:void 0;function mt(e){let t=e.kind===`project`?e.projectId:void 0,n=(0,F.useMemo)(()=>t===void 0?{kind:`workspace`}:{kind:`project`,projectId:t},[t]),r=(0,F.useMemo)(()=>tt(n),[n]),a=m(),o=oe({queryKey:r,queryFn:async({signal:e})=>{let t=a.getQueryData(r);try{return st(t,await ot(n,{signal:e}))}catch(e){let r=e instanceof p?pt(n,e):void 0;if(r===void 0||n.kind!==`project`)throw e;return dt(t,n.projectId,r,e.message)}},staleTime:1/0});return(0,F.useEffect)(()=>{let e=!0,t=t=>{a.cancelQueries({queryKey:r,exact:!0}).then(()=>{if(!e)return;let i=pt(n,t);if(i!==void 0&&n.kind===`project`){a.setQueryData(r,e=>dt(e,n.projectId,i,t.message));return}let o=a.getQueryCache().find({queryKey:r,exact:!0});o?.setState({status:`error`,error:t,errorUpdatedAt:Date.now(),errorUpdateCount:o.state.errorUpdateCount+1,fetchStatus:`idle`})})},o=n=>{let i;try{i=at(n)}catch(e){t(e);return}a.cancelQueries({queryKey:r,exact:!0}).then(()=>{e&&a.setQueryData(r,e=>st(e,i))})},s=i(nt(n),o),l=c(et),d,f=()=>{let e=_()===`finite`&&l!==!1;e&&!d?d=u({path:rt(n),intervalMs:l},(e,n)=>{n===void 0?o(e):t(ft(e,n))}):!e&&d&&(d(),d=void 0)};f();let p=b(f);return()=>{e=!1,p(),d?.(),s()}},[a,r,n]),o}var ht=e=>String(e).padStart(2,`0`);function B(e){let t=Math.max(0,Math.floor(e/1e3)),n=Math.floor(t/3600),r=Math.floor(t/60)%60,i=t%60;return n>0?`${n}:${ht(r)}:${ht(i)}`:`${r}:${ht(i)}`}function V(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60);if(r>=24)return`${Math.floor(r/24)}d`;let i=n%60;return r<6&&i>0?`${r}h ${i}m`:`${r}h`}function H(e,t){let n=e===void 0?NaN:Date.parse(e);return Number.isNaN(n)?0:t-n}var gt=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`});function U(e){let t=Date.parse(e);return Number.isNaN(t)?e:gt.format(t)}var _t=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`}),vt=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`});function W(e){let t=typeof e==`number`?e:Date.parse(e);return Number.isNaN(t)?String(e):`${_t.format(t)}, ${vt.format(t)} ${bt()}`}function yt(e){let t=Math.max(0,Math.floor(e/1e3));return t<60?`just now`:t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function bt(){return Intl.DateTimeFormat().resolvedOptions().timeZone}var xt=new Set([`queued`,`running`,`waiting`]),St={review:`Needs review`,failed:`Failed`,done:`Done`,cancelled:`Cancelled`},Ct={review:`review`,failed:`failed`,done:`done`,cancelled:`cancelled`},G=e=>xt.has(e),wt=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`,K=e=>v(e.rung).tone,Tt=(e,t=`Deadline`)=>e?`${t} ${U(e)}`:void 0;function Et(e,t,n){return t.length===1&&t[0]!==void 0?`${e} ${n.titleOf(t[0])}`:`${e} ${wt(t.length,`task`)}`}function Dt(e,t){let n=e.tool,r={verb:`Running`,tone:K(e),icon:`tool`},i=n?.endedAt!==void 0&&H(n.endedAt,t.now)>1e4;if(n===void 0)return{...r,main:`Thinking`,...e.startedAt?{since:e.startedAt}:{}};let a=`Last tool ${V(H(n.endedAt??n.startedAt,t.now))} ago`;return i?{...r,main:`Thinking`,detail:a,since:n.endedAt??n.startedAt}:{...r,main:n.title,mono:!0,detail:a,since:n.startedAt}}function Ot(e,t){let n={verb:`Needs you`,tone:K(e),icon:`user`,...t?{since:t.since}:{}};if(t?.detail.reason===`question`)return t.detail.question?{...n,main:t.detail.question,action:`answer`}:{...n,main:`Your turn`,action:`answer`};if(t?.detail.reason===`budget`){let e=t.detail.queuedMessages;return{...n,main:e?`Automatic wakes used up · ${wt(e,`message`)} queued`:`Automatic wakes used up`,action:`open`}}return{...n,main:`Your turn`,action:`open`}}function kt(e){return{verb:`Needs permission`,tone:K(e),icon:`user`,main:`Approval required`,action:`open`}}function At(e,t,n){let{owed:r,total:i,settled:a,replies:o,mode:s,recipientRunIds:c}=t.detail,l=i>0?a/i:0,u={tone:K(e),since:t.since};if(o){let e=c.length>0?Et(`From`,c,n):`Waiting for replies`;return{...u,verb:`Waiting for reply`,icon:`reply`,main:e,...q(`detail`,Tt(t.deadline,`Reply due`))}}let d=c.length>0?`${r} owed · ${a} settled`:s?`${jt[s]} of ${i} · ${a} settled`:`${r} owed`;return{...u,verb:`Waiting for workers`,icon:`workers`,main:d,bar:l,...q(`detail`,Tt(t.deadline))}}var jt={one:`One`,any:`Any`,all:`All`};function Mt(e){let t=e.detail.counts;if(t===void 0)return`PR ${e.detail.number} checks`;let n=t.pass+t.fail+t.pending;return`PR ${e.detail.number} checks · ${t.pass} of ${n} passed`}var Nt=[`fail`,`pending`,`pass`,`skipping`,`cancel`];function Pt(e){let{counts:t,checks:n=[],truncated:r}=e.detail;if(!r||t===void 0)return;let i=e=>Math.max(0,t[e]-n.filter(t=>t.bucket===e).length),a=Nt.reduce((e,t)=>e+i(t),0),o=Nt.find(e=>i(e)>0);return a>0&&o?{count:a,bucket:o}:void 0}var Ft=[[`pass`,`passed`],[`fail`,`failed`],[`pending`,`pending`],[`skipping`,`skipped`],[`cancel`,`cancelled`]];function It(e){let{counts:t,checks:n}=e.detail,r=e=>t?t[e]:(n??[]).filter(t=>t.bucket===e).length,i=Ft.filter(([e])=>r(e)>0).map(([e,t])=>`${r(e)} ${t}`),a=Pt(e);return a&&i.push(`+${a.count} more not listed`),i.length>0?i.join(`, `):void 0}function Lt(e,t){let n={tone:K(e),since:t.since,...q(`detail`,Tt(t.deadline))};if(t.detail.target!==`checks`)return{...n,verb:`Waiting for merge`,icon:`merge`,main:`PR ${t.detail.number}`};let r=t.detail.checks?[...t.detail.checks].sort((e,t)=>e.name.localeCompare(t.name)):void 0;return{...n,verb:`Waiting for CI`,icon:`ci`,main:Mt(t),...q(`checks`,r),...q(`overflow`,Pt(t)),...q(`checkSummary`,It(t))}}function q(e,t){return t===void 0?{}:{[e]:t}}function Rt(e,t,n){let r=K(e);switch(t.kind){case`workers`:return At(e,t,n);case`peers`:return{verb:`Waiting for a peer`,tone:r,icon:`peer`,since:t.since,main:Et(`For`,t.detail.peerRunIds,n),detail:`Deadline ${U(t.deadline)}`};case`subagents`:return{verb:`Waiting for subagents`,tone:r,icon:`subagents`,since:t.since,main:wt(t.detail.running,`native subagent`),detail:`Deadline ${U(t.deadline)}`};case`pr`:return Lt(e,t);case`process`:return{verb:`Waiting for command`,tone:r,icon:`command`,since:t.since,main:t.detail.note??`Process ${t.detail.pid}`,detail:`Running ${B(H(t.since,n.now))} · deadline ${U(t.deadline)}`};case`plugin`:return{verb:`Waiting`,tone:r,icon:`timer`,since:t.since,main:t.detail.summary,...q(`detail`,Tt(t.deadline))};case`timer`:return{verb:`Monitoring`,tone:r,icon:`timer`,since:t.since,main:t.detail.note??`Timer`,detail:`Wakes ${U(t.detail.wakeAt)} · in ${B(-H(t.detail.wakeAt,n.now))}`};case`usage-limit`:return zt(e,t.detail.resumeAt,n);case`human`:return}}function zt(e,t,n){let r=Date.parse(t),i=Number.isNaN(r)?`Resumes ${t}`:`Resumes ${U(t)} · in ${B(r-n.now)}`;return{verb:`Usage limit`,tone:K(e),icon:`pause`,main:`Paused until reset`,detail:i}}function Bt(e,t){let n=e.wait&&`since`in e.wait?e.wait.since:e.startedAt;return{verb:`Queued`,tone:K(e),icon:`queued`,main:`Waiting for a free slot`,...n?{since:n,detail:`Waiting ${V(H(n,t.now))}`}:{}}}function Vt(e,t){return{verb:St[e.status]??e.status,tone:K(e),icon:Ct[e.status]??`done`,main:t}}function Ht(e,t){return G(e.status)?Ut(e,t):Vt(e,wt(e.workers.filter(e=>G(e.status)).length,`live worker`))}function Ut(e,t){let n=e.wait;switch(e.rung){case`running`:return Dt(e,t);case`needs-permission`:return kt(e);case`needs-you`:return Ot(e,n?.kind===`human`?n:void 0);case`usage-limit`:return n?.kind===`usage-limit`?zt(e,n.detail.resumeAt,t):{verb:`Usage limit`,tone:K(e),icon:`pause`,main:`Paused until reset`};case`queued`:case`waiting-for-capacity`:return Bt(e,t);default:return(n&&Rt(e,n,t))??Bt(e,t)}}function Wt(e,t,n){if(n!==void 0&&G(e.status))return{verb:`Asks parent`,tone:K(e),main:`“${n}”`,asks:!0};let r=Gt(e,t);return{verb:r.verb,tone:r.tone,main:r.main,...r.mono?{mono:!0}:{}}}function Gt(e,t){switch(e.status){case`done`:return Vt(e,e.collected?`Collected`:`Ready to collect`);case`review`:return Vt(e,`Waiting for the parent’s review`);case`failed`:case`cancelled`:return Vt(e,e.error??St[e.status]??e.status);default:return Ut({...e,workers:[]},t)}}var Kt={success:`text-semantic-green`,pending:`text-semantic-amber`,danger:`text-semantic-red`,accent:`text-accent-text`,info:`text-semantic-info`,running:`text-semantic-violet`,neutral:`text-muted-foreground`};function qt({tone:e,className:t,children:n,...r}){return(0,I.jsx)(`span`,{...r,className:j(`bg-card-2`,{"text-semantic-green":e===`success`,"text-semantic-amber":e===`pending`,"text-semantic-red":e===`danger`,"text-accent-text":e===`accent`,"text-semantic-info":e===`info`,"text-semantic-violet":e===`running`,"text-muted-foreground":e===`neutral`},t),children:n})}var Jt={success:`border-success`,pending:`border-pending-strong`,danger:`border-danger`,accent:`border-accent-strong`,info:`border-info`,running:`border-status-running`,neutral:`border-soft-foreground`},Yt={success:`bg-success`,pending:`bg-pending-strong`,danger:`bg-danger`,accent:`bg-accent-strong`,info:`bg-info`,running:`bg-status-running`,neutral:`bg-soft-foreground`};function Xt(e,t){let n=v(e.rung),r=e.rung===`waiting-on-workers`&&(t===`worker`||e.wait?.kind===`peers`);return{tone:n.tone,shape:r?`ring`:n.shape,label:$t(e,t)??Re(e.rung,n.label)}}var Zt=(e,t,n)=>`${e} ${t} ${n}${t===1?``:`s`}`;function Qt(e){return e?.kind===`workers`&&!e.detail.replies&&e.detail.owed>0}function $t(e,t){let n=e.wait;if(e.rung===`waiting-on-workers`){if(t===`worker`&&!Qt(n))return`Waiting for parent reply`;if(n?.kind===`peers`&&n.detail.peerRunIds.length>0)return Zt(`Waiting for`,n.detail.peerRunIds.length,`task`);if(n?.kind===`workers`&&n.detail.replies)return`Waiting for replies`;if(n?.kind===`workers`&&n.detail.owed>0)return Zt(`Waiting for`,n.detail.owed,`worker`)}if(e.rung===`waiting-on-subagents`&&n?.kind===`subagents`&&n.detail.running>0)return Zt(`Waiting for`,n.detail.running,`subagent`)}function en(e,t){if(G(e.status))return e.rung===`running`&&t===`filled`?`activity-pulse`:t===`filled`?void 0:`activity-breathe`}function J({run:e,role:t}){let{tone:n,shape:r,label:i}=Xt(e,t);return(0,I.jsx)(`span`,{"data-activity-anchor":e.runId,className:j(`inline-flex size-[12px] shrink-0 items-center justify-center`,en(e,r)),children:(0,I.jsx)(P,{tone:n,shape:r,role:`img`,"aria-label":i})})}var tn={pass:`bg-success`,fail:`bg-danger`,pending:`bg-pending`,skipping:`border border-soft-foreground`,cancel:`border border-soft-foreground`},nn=(e,t)=>t?`activity-check-pass`:e===`pending`?`activity-breathe-fast`:void 0;function rn({checks:e,overflow:t,passed:n,className:r}){return(0,I.jsxs)(`span`,{"data-slot":`activity-checks`,"aria-hidden":`true`,className:r??j(`col-start-2 mt-[5px] flex items-center`,e.length>40?`gap-px`:`gap-[3px]`),children:[e.map(e=>(0,I.jsx)(`i`,{"data-bucket":e.bucket,"data-passed":n.has(e.name)?`true`:void 0,title:e.name,className:j(`h-[5px] min-w-px flex-1 rounded-[2px]`,tn[e.bucket],nn(e.bucket,n.has(e.name)))},e.name)),t?(0,I.jsxs)(`span`,{"data-slot":`activity-checks-overflow`,"data-bucket":t.bucket,className:`ml-1 flex shrink-0 items-center gap-1 text-xs leading-none text-muted-foreground tabular-nums`,children:[(0,I.jsx)(`i`,{className:j(`h-[5px] w-2 rounded-[2px]`,tn[t.bucket])}),`+`,t.count]}):null]})}function an({rate:e,className:t}){let n=e.reduce((e,t)=>e+t,0),r=Math.max(4,...e);return(0,I.jsxs)(`svg`,{"data-slot":`activity-heartbeat`,role:`img`,"aria-label":`${n} tool call${n===1?``:`s`} in the last ${e.length} s`,viewBox:`0 0 62 16`,className:j(`block h-4 w-[62px] shrink-0`,t),children:[n>0?(0,I.jsx)(`path`,{d:`M0 15.5h62`,className:`stroke-border`}):null,e.map((e,t)=>{if(e<=0)return null;let n=Math.max(1.5,e/r*14);return(0,I.jsx)(`rect`,{x:t*2.07,y:15-n,width:1.4,height:n,className:`fill-status-running`},t)})]})}var on=`inline-flex min-w-0 items-center rounded-md border px-3 py-1 text-[12px] font-medium focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring max-md:min-h-11 pointer-coarse:min-h-11`;function sn({scope:e,projectId:t,projectName:n,projects:r}){let i=e=>j(on,e?`border-border bg-card text-foreground shadow-xs`:`border-transparent text-muted-foreground hover:text-foreground`);return(0,I.jsxs)(`nav`,{"aria-label":`Activity scope`,"data-slot":`activity-scope`,className:`inline-flex max-w-full flex-wrap rounded-lg border border-border bg-muted/60 p-1`,children:[(r??(t===null?[]:[{id:t,name:n??t}])).map(n=>(0,I.jsx)(A,{to:`/p/${encodeURIComponent(n.id)}/activity`,"aria-current":e===`project`&&n.id===t?`page`:void 0,className:i(e===`project`&&n.id===t),children:(0,I.jsx)(`span`,{className:`max-w-40 truncate`,title:n.name,children:n.name})},n.id)),(0,I.jsx)(A,{to:`/activity`,state:{activityProjectId:t},"aria-current":e===`all`?`page`:void 0,className:i(e===`all`),children:`All projects`})]})}function cn({grouped:e,onToggle:t}){return(0,I.jsxs)(`button`,{type:`button`,"data-slot":`activity-group-toggle`,"aria-pressed":e,onClick:t,className:j(`inline-flex h-9 items-center gap-1.5 rounded-lg border px-2.5 text-[12px] font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring max-md:min-h-11 pointer-coarse:min-h-11`,e?`border-accent-text/60 bg-accent-strong/10 text-foreground`:`border-border bg-card text-muted-foreground hover:text-foreground`),children:[(0,I.jsx)(Ue,{"aria-hidden":`true`,className:`size-3.5`}),(0,I.jsx)(`span`,{children:`Group by project`})]})}function ln(){let e=`flex items-center gap-2`;return(0,I.jsxs)(je,{children:[(0,I.jsx)(ke,{asChild:!0,children:(0,I.jsxs)(`button`,{type:`button`,"data-slot":`activity-legend`,"aria-label":`Activity legend`,className:`inline-flex h-9 items-center gap-1.5 rounded-lg border border-border bg-card px-2.5 text-[12px] font-medium text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:min-h-11 pointer-coarse:min-h-11`,children:[(0,I.jsx)(we,{"aria-hidden":`true`,className:`size-3.5`}),(0,I.jsx)(`span`,{children:`Legend`})]})}),(0,I.jsx)(Ae,{align:`end`,className:`w-80 text-[12px] text-muted-foreground`,children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,I.jsx)(`p`,{className:`text-xs font-semibold tracking-[0.05em] text-foreground uppercase`,children:`Activity legend`}),(0,I.jsxs)(`div`,{className:e,children:[(0,I.jsx)(P,{tone:`pending`,"aria-hidden":`true`}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`strong`,{className:`text-foreground`,children:`Needs answer`}),` — waiting for your reply`]})]}),(0,I.jsxs)(`div`,{className:e,children:[(0,I.jsx)(P,{tone:`info`,"aria-hidden":`true`}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`strong`,{className:`text-foreground`,children:`Needs review`}),` — ready for diff review or PR`]})]}),(0,I.jsxs)(`div`,{className:e,children:[(0,I.jsx)(P,{tone:`danger`,"aria-hidden":`true`}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`strong`,{className:`text-foreground`,children:`Failed`}),` — stopped with an error`]})]}),(0,I.jsxs)(`div`,{className:e,children:[(0,I.jsx)(P,{tone:`running`,"aria-hidden":`true`}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`strong`,{className:`text-foreground`,children:`Working`}),` — running tools right now`]})]}),(0,I.jsxs)(`div`,{className:e,children:[(0,I.jsx)(P,{tone:`info`,shape:`ring`,"aria-hidden":`true`}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`strong`,{className:`text-foreground`,children:`Ring`}),` — waiting on CI, peer, or timer`]})]}),(0,I.jsxs)(`div`,{className:e,children:[(0,I.jsx)(P,{tone:`running`,shape:`workers`,"aria-hidden":`true`}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`strong`,{className:`text-foreground`,children:`Robot`}),` — waiting on its own workers`]})]}),(0,I.jsxs)(`div`,{className:e,children:[(0,I.jsx)(an,{rate:[0,2,5,1,3,0,4,2],className:`w-[34px]`}),(0,I.jsx)(`span`,{children:`Heartbeat: tool calls, last 30 s`})]}),(0,I.jsxs)(`div`,{className:e,children:[(0,I.jsx)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 34 10`,className:`h-2.5 w-[34px] shrink-0`,children:(0,I.jsx)(`path`,{d:`M2 5h30`,strokeWidth:2,strokeDasharray:`6 4`,className:`stroke-message-peer-accent`})}),(0,I.jsx)(`span`,{children:`Open peer request (task → task)`})]}),(0,I.jsxs)(`div`,{className:e,children:[(0,I.jsxs)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 34 10`,className:`h-2.5 w-[34px] shrink-0`,children:[(0,I.jsx)(`path`,{d:`M2 5h24`,strokeWidth:2.2,strokeLinecap:`round`,strokeDasharray:`0 6`,className:`stroke-message-peer-accent opacity-80`}),(0,I.jsx)(`circle`,{cx:`29.5`,cy:`5`,r:`3`,strokeWidth:1.6,className:`fill-card stroke-message-peer-accent`})]}),(0,I.jsx)(`span`,{children:`Waiting for a peer to write`})]})]})})]})}function un({scope:e,projectId:t,projectName:n,projects:r,grouped:i,onToggleGroup:a}){return(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(ln,{}),a?(0,I.jsx)(cn,{grouped:!!i,onToggle:a}):null,(0,I.jsx)(sn,{scope:e,projectId:t,projectName:n,projects:r})]})}function dn({now:e,updatedAt:t,stale:n}){let r=t!==void 0&&!Number.isNaN(Date.parse(t));return(0,I.jsxs)(`span`,{"data-slot":`activity-clock`,"data-stale":n?`true`:void 0,title:W(e),className:`inline-flex items-center gap-1.5 text-[13px] text-muted-foreground tabular-nums`,children:[(0,I.jsx)(`span`,{"data-tone":`success`,className:j(`inline-flex size-[12px] items-center justify-center`,!n&&`activity-pulse`),children:(0,I.jsx)(P,{tone:n?`neutral`:`success`,"aria-hidden":`true`})}),(0,I.jsx)(`b`,{className:j(`font-semibold`,n?`text-muted-foreground`:`text-success`),children:n?`Not updating`:`Live`}),r?(0,I.jsxs)(`span`,{children:[`· updated `,yt(H(t,e))]}):null]})}function fn({name:e,now:t,updatedAt:n,stale:r=!1,scopeSwitch:i}){return{title:`Activity`,scope:e,subtitle:t===void 0?void 0:(0,I.jsx)(dn,{now:t,updatedAt:n,stale:r}),secondaryActions:i}}function pn({primary:e=!1}){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(M,{variant:e?`primary`:`outline`,size:`sm`,asChild:!0,className:`py-1.5`,children:(0,I.jsx)(N,{to:`/new`,children:`New task`})}),(0,I.jsx)(M,{variant:`outline`,size:`sm`,asChild:!0,className:`py-1.5`,children:(0,I.jsx)(N,{to:`/`,children:`View tasks`})})]})}function mn({value:e,bump:t}){return(0,I.jsx)(`strong`,{"data-bump":t===void 0?void 0:`true`,className:j(`font-semibold text-foreground tabular-nums`,t!==void 0&&`activity-bump`),children:e},t??`still`)}function Y({icon:e,count:t,label:n,bump:r}){return(0,I.jsxs)(`li`,{"data-slot":`activity-chip`,"data-chip":n,className:`inline-flex items-center gap-[7px] px-2 py-1 text-xs text-muted-foreground`,children:[e,(0,I.jsx)(mn,{value:t,bump:r}),` `,n]})}function hn({summary:e,tasksTo:t,bumps:n={}}){let r=e=>n[e]?.key;return(0,I.jsxs)(`ul`,{"data-slot":`activity-summary`,"aria-live":`polite`,"aria-label":`Summary`,className:`flex flex-wrap gap-2`,children:[(0,I.jsx)(Y,{icon:(0,I.jsx)(P,{tone:`pending`,"aria-hidden":`true`}),count:e.needsYou,label:`Needs you`,bump:r(`needsYou`)}),(0,I.jsx)(Y,{icon:(0,I.jsx)(P,{tone:`running`,"aria-hidden":`true`}),count:e.working,label:`Working`,bump:r(`working`)}),(0,I.jsx)(Y,{icon:(0,I.jsx)(P,{tone:`running`,shape:`ring`,"aria-hidden":`true`}),count:e.waiting,label:`Waiting`,bump:r(`waiting`)}),(0,I.jsx)(Y,{icon:(0,I.jsx)(P,{tone:`neutral`,shape:`ring`,"aria-hidden":`true`}),count:e.queued,label:`Queued`,bump:r(`queued`)}),(0,I.jsx)(Y,{icon:(0,I.jsx)(Se,{"aria-hidden":`true`,className:`size-3.5`}),count:e.activeWorkers,label:`Active workers`,bump:r(`activeWorkers`)}),(0,I.jsx)(Y,{icon:(0,I.jsx)(Te,{"aria-hidden":`true`,className:`size-3.5 text-message-peer-accent`}),count:e.openRequests,label:`Open requests`,bump:r(`openRequests`)}),(0,I.jsx)(`li`,{"data-slot":`activity-chip`,"data-chip":`Needs review`,children:(0,I.jsxs)(N,{to:t,className:`inline-flex items-center gap-[7px] rounded-full border border-card-edge bg-card px-[11px] py-[5px] text-xs text-muted-foreground shadow-card transition-colors hover:border-accent-text/40 hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:min-h-11`,children:[(0,I.jsx)(P,{tone:`info`,"aria-hidden":`true`}),(0,I.jsx)(mn,{value:e.inReview,bump:r(`inReview`)}),` Needs review`,(0,I.jsx)(xe,{"aria-hidden":`true`,className:`size-3 text-soft-foreground`})]})})]})}function gn(e){if(e.unavailable)return e.unavailable.error;if(!e.loaded)return`Not loaded in this cockpit`}function _n(e){let t=new Map;for(let n of e.tasks){t.set(n.runId,{title:n.title,cardId:n.runId,role:`root`});for(let e of n.workers)t.set(e.runId,{title:e.title,cardId:n.runId,role:`worker`})}return t}function X(e,t,n){return e.get(t)?.title??n??`Unreadable task`}var vn=(e,t)=>X(e,t.senderRunId,t.senderTitle),yn=(e,t)=>X(e,t.recipientRunId,t.recipientTitle),bn=(e,t)=>`wait:${e}:${t}`;function Z(e){let t=[];for(let n of e){let e=n.wait;if(!(!G(n.status)||e?.kind!==`peers`))for(let r of new Set(e.detail.peerRunIds))r!==n.runId&&t.push({id:bn(n.runId,r),waiterRunId:n.runId,peerRunId:r,since:e.since,deadline:e.deadline})}return t}function xn(e,t){let n=new Set;for(let r of t)r.waiterRunId===e&&n.add(r.peerRunId),r.peerRunId===e&&n.add(r.waiterRunId);return n}function Sn(e,t){return t.filter(t=>t.waiterRunId===e)}function Cn(e,t,n,r=[]){let i=[];for(let r of t)r.senderRunId===e&&i.push(`Waiting for a reply from ${yn(n,r)}`),r.recipientRunId===e&&i.push(`${vn(n,r)} waits for your reply`);for(let t of r)t.waiterRunId===e&&i.push(`Waiting for a message from ${X(n,t.peerRunId)}`),t.peerRunId===e&&i.push(`${X(n,t.waiterRunId)} waits for you to write`);return i}function wn(e,t,n){return n.find(n=>n.relationship===`family`&&n.senderRunId===e&&n.recipientRunId===t)}function Tn(e,t){let n=-H(e,t);return n>=1e3?`reply due in ${B(n)}`:`reply overdue`}function En(e,t){return t.filter(t=>t.relationship===`peer`&&t.senderRunId===e)}function Dn(e,t){return e.relationship===`peer`?{kind:`Request`,relation:`Peer`}:{kind:`Question`,relation:On[kn(e,t)]}}var On={worker:`Worker → parent`,parent:`Parent → worker`,unknown:`Family`};function kn(e,t){let n=t.get(e.senderRunId)?.role;if(n)return n===`worker`?`worker`:`parent`;let r=t.get(e.recipientRunId)?.role;return r?r===`root`?`worker`:`parent`:`unknown`}var An=new Set([`queued`,`waiting-for-capacity`]);function jn(e){if(G(e.status))return y(e.rung)?`needsYou`:e.rung===`running`?`working`:An.has(e.rung)?`queued`:`waiting`}function Mn(e){let t={needsYou:0,working:0,waiting:0,queued:0,activeWorkers:0,openRequests:0,inReview:0};for(let n of e){t.inReview+=n.inReview,t.openRequests+=n.requests.length;for(let e of n.tasks){let n=jn(e);n&&(t[n]+=1),t.activeWorkers+=e.workers.filter(e=>G(e.status)).length}}return t}function Nn(e,t=()=>!1){let n=0,r=0;for(let i of e.workers)t(i.runId)||((i.status===`done`||i.status===`cancelled`)&&(n+=1),i.status===`failed`&&(n+=1,r+=1));return{finished:n,failed:r}}function Pn({finished:e,failed:t}){if(e!==0)return t>0?`✓ ${e} finished · ${t} failed`:`✓ ${e} worker${e===1?``:`s`} finished`}var Q={flash:1300,cardEnter:700,cardLeave:500,workerEnter:700,workerHold:3e3,workerFold:500,comet:1100,replied:900,fade:800,bump:500,slide:450,check:800},$={flash:{},entering:{},leaving:{},workerEnter:{},workerHold:{},opening:{},closing:{},waitsClosing:{},comets:{},bumps:{},slides:{},checks:{}},Fn=(e,t)=>`${e}\n${t}`;function In(e,t){let n=Fn(t,``);return new Set(Object.keys(e.checks).filter(e=>e.startsWith(n)).map(e=>e.slice(n.length)))}var Ln=class{key;changes=[];timers=[];constructor(e){this.key=e}timed(e,t,n,r){this.changes.push({field:e,id:t,value:{...n,key:this.key}}),this.timers.push({after:r,change:{field:e,id:t,ifKey:this.key}})}later(e,t,n,r){this.timers.push({after:r,change:{field:e,id:t,value:{...n,key:this.key},ifKey:this.key}})}drop(e,t){this.changes.push({field:e,id:t})}},Rn={done:`success`,review:`success`,failed:`danger`,cancelled:`neutral`};function zn(e,t){let n=Rn[t.status]??`success`;if(t.status===`review`){e.timed(`workerHold`,t.runId,{tone:n,phase:`flash`},Q.flash);return}e.timed(`workerHold`,t.runId,{tone:n,phase:`flash`},Q.workerHold+Q.workerFold),e.later(`workerHold`,t.runId,{tone:n,phase:`fold`},Q.workerHold)}function Bn(e,t){e.drop(`closing`,t.requestId),e.timed(`opening`,t.requestId,{},Q.fade),e.timed(`comets`,`${t.requestId}:open:${e.key}`,{requestId:t.requestId,reverse:!1,tone:t.relationship},Q.comet)}function Vn(e,t,n,r){let i=n.requestId;if(e.drop(`opening`,i),!r){e.timed(`closing`,i,{projectId:t,request:n,replied:!1,phase:`fade`},Q.fade);return}let a=Q.comet+Q.replied+Q.fade;e.timed(`closing`,i,{projectId:t,request:n,replied:!0,phase:`reply`},a),e.later(`closing`,i,{projectId:t,request:n,replied:!0,phase:`replied`},Q.comet),e.later(`closing`,i,{projectId:t,request:n,replied:!0,phase:`fade`},Q.comet+Q.replied),e.timed(`comets`,`${i}:reply:${e.key}`,{requestId:i,reverse:!0,tone:`success`},Q.comet)}function Hn(e,t){switch(t.kind){case`rung-changed`:return e.timed(`flash`,t.task.runId,{tone:v(t.task.rung).tone},Q.flash);case`tool-started`:return e.timed(`slides`,t.runId,{},Q.slide);case`worker-started`:return e.timed(`workerEnter`,t.worker.runId,{},Q.workerEnter);case`worker-settled`:return zn(e,t.worker);case`card-entered`:return e.drop(`leaving`,t.task.runId),e.timed(`entering`,t.task.runId,{},Q.cardEnter);case`card-left`:return e.timed(`leaving`,t.task.runId,{projectId:t.projectId,task:t.task},Q.cardLeave);case`check-passed`:return e.timed(`checks`,Fn(t.runId,t.name),{},Q.check);case`request-opened`:return Bn(e,t.request);case`request-closed`:return Vn(e,t.projectId,t.request,t.status===`replied`);case`chip-changed`:return e.timed(`bumps`,t.chip,{},Q.bump);case`wait-opened`:return e.drop(`waitsClosing`,t.wait.id),e.timed(`opening`,t.wait.id,{},Q.fade);case`wait-closed`:return e.drop(`opening`,t.wait.id),e.timed(`waitsClosing`,t.wait.id,{projectId:t.projectId,wait:t.wait},Q.fade)}}function Un(e,t,n){let r=new Ln(t);if(!n)for(let t of e)Hn(r,t);return{changes:r.changes,timers:r.timers}}function Wn(e,t){let n=e[t.field];if(t.ifKey!==void 0&&n[t.id]?.key!==t.ifKey||t.value===void 0&&!(t.id in n))return e;let r={...n};return t.value===void 0?delete r[t.id]:r[t.id]=t.value,{...e,[t.field]:r}}function Gn(e,t){return t.reduce(Wn,e)}function Kn(e,t,n){let r=new Set(t.map(e=>e.id));return Object.values(n.waitsClosing).filter(t=>t.projectId===e&&!r.has(t.wait.id)).map(e=>e.wait)}function qn({runId:e,requests:t,waits:n,index:r,link:i,pathOf:a,className:o,linkClassName:s}){let c=En(e,t),l=Sn(e,n);return c.length===0&&l.length===0?null:(0,I.jsxs)(`ul`,{"data-slot":`activity-peer-links`,className:o,children:[c.map(e=>(0,I.jsx)(`li`,{children:(0,I.jsxs)(i,{to:a(e.recipientRunId),className:s,children:[`→ `,yn(r,e)]})},e.requestId)),l.map(e=>(0,I.jsx)(`li`,{children:(0,I.jsxs)(i,{to:a(e.peerRunId),className:s,children:[`⋯ waits on `,X(r,e.peerRunId)]})},e.id))]})}var Jn=e=>`/tasks/${encodeURIComponent(e)}`;function Yn({texts:e}){return e.length===0?null:(0,I.jsx)(`ul`,{"data-slot":`activity-line-text`,className:`sr-only`,children:e.map((e,t)=>(0,I.jsx)(`li`,{children:e},t))})}var Xn={compact:{base:`relative flex flex-wrap items-center gap-x-2 gap-y-0.5 rounded-md px-2 py-1 text-[12px] text-muted-foreground`,asks:`border-l-2 border-dashed border-message-inbound-accent bg-message-inbound-bg`,shape:void 0,title:`min-w-0 truncate text-[12px] font-medium text-foreground`,line:`truncate text-xs text-muted-foreground tabular-nums`,main:`text-foreground`},card:{base:`relative grid grid-cols-[14px_minmax(0,1fr)] items-start gap-x-2 rounded-lg py-[5px] before:absolute before:top-[13px] before:-left-3.5 before:w-2.5 before:border-t before:border-border`,asks:`-mx-1.5 bg-message-inbound-bg px-1.5`,shape:`mt-[3px]`,title:`min-w-0 truncate text-[12.5px] font-medium text-foreground`,line:`col-start-2 truncate text-xs text-muted-foreground tabular-nums`,main:void 0}};function Zn({to:e,title:t,global:n}){let r=`relative z-[1] hover:underline focus-visible:outline-2 focus-visible:outline-ring max-md:inline-flex max-md:min-h-11 max-md:items-center`;return n?(0,I.jsx)(A,{to:e,className:r,children:t}):(0,I.jsx)(N,{to:e,className:r,children:t})}function Qn({worker:e,parentId:t,requests:n,index:r,ctx:i,motion:a,href:s,global:c=!1,compact:u=!1}){let d=Wt(e,i,wn(e.runId,t,n)?.text),f=a.workerHold[e.runId],p=o().data,m=u?Xn.compact:Xn.card,h=[e.runner?l(p,e.runner):void 0,e.model].filter(Boolean).join(` · `);return(0,I.jsxs)(`li`,{"data-slot":`activity-worker`,"data-run":e.runId,"data-asks":d.asks?`true`:void 0,"data-hold":f?.phase,className:j(m.base,d.asks&&m.asks,e.runId in a.workerEnter&&`activity-row-enter`,f?.phase===`fold`&&`activity-row-fold`),children:[f?(0,I.jsx)(`span`,{"aria-hidden":`true`,className:j(`activity-row-flash`,Yt[f.tone])},f.key):null,(0,I.jsx)(`span`,{className:m.shape,children:(0,I.jsx)(J,{run:e,role:`worker`})}),(0,I.jsxs)(`span`,{className:m.title,children:[(0,I.jsx)(Zn,{to:s??Jn(e.runId),title:e.title,global:c}),h?(0,I.jsx)(`span`,{className:`ml-1.5 text-xs font-normal text-muted-foreground`,children:h}):null]}),(0,I.jsxs)(`span`,{"data-slot":`activity-worker-line`,className:m.line,children:[(0,I.jsx)(`b`,{className:j(`font-semibold`,Kt[d.tone]),children:d.verb}),` · `,(0,I.jsx)(`span`,{className:j(m.main,d.mono&&`font-mono`),children:d.main})]}),(0,I.jsx)(Yn,{texts:Cn(e.runId,n,r)})]})}function $n({workers:e}){return(0,I.jsxs)(`div`,{"data-slot":`activity-worker-dots`,className:`mt-2 ml-[18px] flex flex-wrap items-center gap-1 text-xs text-muted-foreground`,children:[e.map(e=>(0,I.jsx)(J,{run:e,role:`worker`},e.runId)),(0,I.jsxs)(`span`,{className:`ml-1`,children:[e.length,` worker`,e.length===1?``:`s`]})]})}function er({task:e,requests:t,index:n,ctx:r,dense:i=!1,motion:a,projectId:o,global:s=!1,compact:c=!1}){let l=e=>e in a.workerHold,u=e.workers.filter(e=>G(e.status)||e.status===`review`||l(e.runId)),d=Pn(Nn(e,l));if(u.length===0&&!d)return null;let f=e=>s&&o?`/p/${encodeURIComponent(o)}/tasks/${encodeURIComponent(e)}`:Jn(e);return c?(0,I.jsxs)(`div`,{className:`ml-4 border-l border-border pl-3`,children:[u.length>0?(0,I.jsx)(`ul`,{"data-slot":`activity-workers`,className:`flex flex-col gap-0.5`,children:u.map(i=>(0,I.jsx)(Qn,{worker:i,parentId:e.runId,requests:t,index:n,ctx:r,motion:a,href:f(i.runId),global:s,compact:!0},i.runId))}):null,d?(0,I.jsx)(`p`,{"data-slot":`activity-finished`,className:`mt-1 px-2 text-xs text-muted-foreground`,children:d}):null]}):(0,I.jsxs)(I.Fragment,{children:[u.length>0&&i?(0,I.jsx)($n,{workers:u}):null,u.length>0&&!i?(0,I.jsx)(`ul`,{"data-slot":`activity-workers`,className:`mt-2 ml-1 border-l border-border pl-3.5`,children:u.map(i=>(0,I.jsx)(Qn,{worker:i,parentId:e.runId,requests:t,index:n,ctx:r,motion:a},i.runId))}):null,d?(0,I.jsx)(`p`,{"data-slot":`activity-finished`,className:`mt-1.5 ml-[18px] text-xs text-muted-foreground`,children:d}):null]})}function tr(e,t){return t?{onPointerEnter:()=>t(`pointer`,e),onPointerLeave:()=>t(`pointer`,void 0),onFocus:()=>t(`focus`,e),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||t(`focus`,void 0)}}:{}}function nr({task:e,motion:t,glow:n}){let r=t.flash[e.runId];return(0,I.jsxs)(I.Fragment,{children:[n?(0,I.jsx)(`span`,{"aria-hidden":`true`,className:`activity-glow`}):null,r?(0,I.jsx)(`span`,{"data-slot":`activity-flash`,"data-tone":r.tone,"aria-hidden":`true`,className:j(`activity-flash`,Jt[r.tone])},r.key):null]})}var rr=e=>/(auto|scroll|hidden|clip)/.test(getComputedStyle(e).overflowY);function ir(e){let t=[];for(let n=e.parentElement;n&&n!==document.body&&n!==document.documentElement;n=n.parentElement)rr(n)&&t.push(n);return t}var ar=e=>({requestId:e.id,senderRunId:e.peerRunId,recipientRunId:e.waiterRunId});function or({frame:e,cancel:t,draw:n}){let r=[],i,a=t=>{i=void 0,r=r.map(e=>({...e,start:e.start??t})).filter(e=>t<e.start+e.duration),n(r,t),r.length>0&&(i=e(a))};return{launch(t){r.some(e=>e.id===t.id)||(r.push(t),i===void 0&&(i=e(a)))},stop(){i!==void 0&&t(i),i=void 0,r=[],n([],0)},running:()=>i!==void 0}}var sr=e=>e<.5?2*e*e:1-(-2*e+2)**2/2;function cr(e,t,n=0){let r=Math.min(1,Math.max(0,(t-e.start)/e.duration)),i=Math.max(0,sr(r)-n);return e.reverse?1-i:i}var lr=`http://www.w3.org/2000/svg`,ur=[0,.03,.06,.09,.12],dr=[4.5,3.5,3,2.5,2],fr={peer:`fill-message-peer-accent`,family:`fill-message-inbound-accent`,success:`fill-success`};function pr(e,t){let n=e.querySelector(`g[data-comet="${CSS.escape(t.id)}"]`);if(n)return n;let r=document.createElementNS(lr,`g`);r.setAttribute(`data-comet`,t.id);let i=document.createElementNS(lr,`circle`);return i.setAttribute(`r`,`9`),i.setAttribute(`class`,`${fr[t.tone]} opacity-35`),r.append(i),ur.forEach((e,n)=>{let i=document.createElementNS(lr,`circle`);i.setAttribute(`r`,String(dr[n])),i.setAttribute(`class`,n===0?`fill-foreground`:fr[t.tone]),i.setAttribute(`opacity`,String(1-n*.15)),r.append(i)}),e.append(r),r}function mr(e,t,n){let r=new Set(t.map(e=>e.id));for(let t of e.querySelectorAll(`g[data-comet]`))r.has(t.getAttribute(`data-comet`)??``)||t.remove();let i=e.ownerSVGElement;for(let r of t){let t=i?.querySelector(`path[data-request="${CSS.escape(r.requestId)}"]`);if(!t||typeof t.getTotalLength!=`function`)continue;let a=t.getTotalLength();pr(e,r).querySelectorAll(`circle`).forEach((e,i)=>{let o=t.getPointAtLength(cr(r,n,ur[Math.max(0,i-1)])*a);e.setAttribute(`transform`,`translate(${o.x} ${o.y})`)})}}var hr=e=>typeof requestAnimationFrame==`function`?requestAnimationFrame(e):setTimeout(()=>e(performance.now()),16),gr=e=>typeof cancelAnimationFrame==`function`?cancelAnimationFrame(e):clearTimeout(e);function _r(e,t,n){let r=F.useRef(null),i=F.useRef(void 0),a=F.useRef(new Set);return F.useEffect(()=>{let e=r.current;if(!e)return;let t=or({frame:hr,cancel:gr,draw:(t,n)=>mr(e,t,n)});return i.current=t,()=>{t.stop(),i.current=void 0}},[]),F.useEffect(()=>{if(n){i.current?.stop();return}for(let t of a.current)t in e||a.current.delete(t);for(let[n,r]of Object.entries(e))a.current.has(n)||!t.has(r.requestId)||(a.current.add(n),i.current?.launch({id:n,requestId:r.requestId,reverse:r.reverse,tone:r.tone,duration:Q.comet}))},[e,t,n]),r}var vr=`activity-layout-settled`;function yr(e,t,n,r,i,a=!1){let[o,s]=F.useState([]);return F.useLayoutEffect(()=>{let i=e.current?.parentElement;if(!i)return;let o=()=>{let e=t(i);s(t=>n(t,e)?t:e)};o();let c=a?br(i,o):void 0;i.addEventListener(vr,o);let l=typeof ResizeObserver>`u`?void 0:new ResizeObserver(o);l?.observe(i);for(let e of i.querySelectorAll(r))l?.observe(e);return()=>{l?.disconnect(),i.removeEventListener(vr,o),c?.()}},[e,t,n,r,i,a]),o}function br(e,t){let n,r=()=>{n===void 0&&(n=requestAnimationFrame(()=>{n=void 0,t()}))},i=[...ir(e),window];for(let e of i)e.addEventListener(`scroll`,r,{passive:!0});return window.addEventListener(`resize`,r),()=>{for(let e of i)e.removeEventListener(`scroll`,r);window.removeEventListener(`resize`,r),n!==void 0&&cancelAnimationFrame(n)}}function xr(e,t){if(e.deadline!==void 0)return Sr(e.createdAt,e.deadline,t)}function Sr(e,t,n){let r=Date.parse(e),i=Date.parse(t);return Number.isNaN(r)||Number.isNaN(i)||i<=r?1:Math.min(1,Math.max(0,(n-r)/(i-r)))}function Cr(e,t){if(e===`fade`)return`activity-line-out`;if(e!==`replied`)return j(`activity-march`,t&&`activity-line-in`)}function wr(e,t){return t in e.waitsClosing?`activity-line-out`:j(`activity-drift`,t in e.opening&&`activity-line-in`)}var Tr=(e,t)=>e.closing[t]?.phase??`open`;function Er(e,t){let n=e.closing[t];return n!==void 0&&n.replied&&n.phase!==`reply`}function Dr({id:e}){return(0,I.jsx)(`marker`,{id:e,viewBox:`0 0 12 12`,refX:`10`,refY:`6`,markerWidth:`5`,markerHeight:`5`,markerUnits:`strokeWidth`,orient:`auto`,children:(0,I.jsx)(`circle`,{cx:`6`,cy:`6`,r:`4`,strokeWidth:`2.4`,className:`fill-background stroke-message-peer-accent`})})}function Or(e,t){let n=new Map;for(let r of[...e?.projects??[],...t.projects])for(let[e,t]of _n(r))n.set(e,t);return n}var kr={"timed-out":`timed out`,cancelled:`was cancelled`,destroyed:`closed: the recipient was destroyed`,failed:`closed: the recipient failed`,"completed-without-reply":`closed without a reply`,"sender-closed":`was closed by its sender`,"human-fallback":`went to a human`,deleted:`closed: the recipient was deleted`};function Ar(e,t,n){let r=n(e.senderRunId,e.senderTitle),i=n(e.recipientRunId,e.recipientTitle);return t===`replied`?`${i} replied to ${r}`:`${r}’s request to ${i} ${kr[t??``]??`closed`}`}var jr={done:{tone:`success`,word:`finished`},failed:{tone:`danger`,word:`failed`},cancelled:{tone:`neutral`,word:`was cancelled`},review:{tone:`info`,word:`waits for review`}},Mr=e=>e.relationship===`peer`?`peer`:`family`;function Nr(e,t,n){let r=(e,n)=>X(t,e,n);switch(e.kind){case`request-opened`:return{tone:Mr(e.request),text:`${r(e.request.senderRunId,e.request.senderTitle)} asked ${r(e.request.recipientRunId,e.request.recipientTitle)}`};case`request-closed`:return{tone:e.status===`replied`?`success`:`neutral`,text:Ar(e.request,e.status,r)};case`rung-changed`:return{tone:v(e.task.rung).tone,text:`${e.task.title}: ${Ht(e.task,{now:n,titleOf:e=>r(e)}).verb}`};case`worker-started`:return{tone:`running`,text:`${e.worker.title} started`};case`worker-settled`:{let t=jr[e.worker.status]??{tone:`neutral`,word:`settled`};return{tone:t.tone,text:`${e.worker.title} ${t.word}`}}case`card-entered`:return{tone:v(e.task.rung).tone,text:`${e.task.title} started`};case`card-left`:return{tone:`neutral`,text:`${e.task.title} left active work`};case`check-passed`:return{tone:`success`,text:`PR ${e.pr}: check “${e.name}” passed`};default:return}}function Pr(e,t,n,r){return[...t.map((e,t)=>({...e,id:r+t,at:n})),...e].slice(0,6)}function Fr(e){return Math.max(0,Math.floor(e/1e3))<5?`now`:V(e)}var Ir=`rounded-xl border border-card-edge bg-card px-3.5 py-3 shadow-card`,Lr=`mb-2 flex gap-2 text-xs font-semibold tracking-[0.06em] text-muted-foreground uppercase`;function Rr({request:e,index:t,now:n,motion:r}){let{kind:i,relation:a}=Dn(e,t),o=xr(e,n),s=e.relationship===`peer`?`text-message-peer-accent`:`text-message-inbound-accent`;return(0,I.jsxs)(`li`,{"data-slot":r===`fold`?`activity-request-closing`:`activity-request`,"data-request":e.requestId,"aria-hidden":r===`fold`||void 0,className:j(`border-t border-border py-2.5 first:border-t-0 first:pt-0`,r===`enter`&&`activity-row-enter`,r===`fold`&&`activity-row-fold`),children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[12px] font-medium`,children:[(0,I.jsx)(`span`,{className:`min-w-0 truncate`,children:vn(t,e)}),(0,I.jsx)(be,{"aria-label":`to`,className:`size-3 shrink-0 text-muted-foreground`}),(0,I.jsx)(`span`,{className:`min-w-0 truncate`,children:yn(t,e)}),(0,I.jsx)(`span`,{className:j(`ml-auto shrink-0 text-xs font-semibold tracking-[0.05em] uppercase`,s),children:i})]}),(0,I.jsxs)(`p`,{className:`my-1 line-clamp-3 text-[12px] text-muted-foreground`,children:[`“`,e.text,`”`]}),(0,I.jsxs)(`div`,{className:`flex gap-1.5 text-xs text-muted-foreground tabular-nums`,children:[(0,I.jsxs)(`span`,{children:[a,` · open `,B(H(e.createdAt,n))]}),e.deadline?(0,I.jsx)(`span`,{className:`ml-auto`,children:Tn(e.deadline,n)}):null]}),o===void 0?null:(0,I.jsx)(`div`,{"aria-hidden":`true`,className:`mt-1.5 h-[3px] overflow-hidden rounded-sm bg-border`,children:(0,I.jsx)(`span`,{className:j(`block h-full bg-current`,s),style:{width:`${Math.round(o*100)}%`}})})]})}var zr={...Yt,peer:`bg-message-peer-accent`,family:`bg-message-inbound-accent`};function Br({feed:e,now:t}){return(0,I.jsxs)(`section`,{"data-slot":`activity-just-now`,className:Ir,children:[(0,I.jsx)(`h2`,{className:Lr,children:`Just now`}),(0,I.jsx)(`ul`,{"data-slot":`activity-feed`,children:e.map((e,n)=>(0,I.jsxs)(`li`,{"data-slot":`activity-feed-entry`,className:j(`grid grid-cols-[10px_minmax(0,1fr)_auto] items-baseline gap-2 py-1 text-[12px] text-muted-foreground`,n===0&&`activity-feed-enter`),children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,className:j(`size-[7px] -translate-y-px rounded-full`,zr[e.tone])}),(0,I.jsx)(`span`,{className:`min-w-0`,children:e.text}),(0,I.jsx)(`span`,{"data-slot":`activity-feed-age`,className:`text-xs tabular-nums`,children:Fr(t-e.at)})]},e.id))})]})}function Vr({requests:e,closing:t=[],index:n,now:r,feed:i=[],motion:a=$,columnGap:o}){let s=e.length>0||t.length>0,c=i.length>0;return!s&&!c?null:(0,I.jsxs)(`aside`,{"data-slot":`activity-rail`,"aria-label":`Activity details`,style:o===void 0?void 0:{columnGap:o},className:j(`grid min-w-0 grid-cols-[minmax(0,1fr)] content-start items-start gap-4`,s&&c&&`md:grid-cols-2`),children:[s?(0,I.jsxs)(`section`,{"data-slot":`activity-open-requests`,className:Ir,children:[(0,I.jsxs)(`h2`,{className:Lr,children:[`Open requests `,(0,I.jsx)(`b`,{className:`text-foreground`,children:e.length})]}),(0,I.jsxs)(`ul`,{children:[e.map(e=>(0,I.jsx)(Rr,{request:e,index:n,now:r,motion:e.requestId in a.opening?`enter`:void 0},e.requestId)),t.map(e=>(0,I.jsx)(Rr,{request:e,index:n,now:r,motion:`fold`},e.requestId))]})]}):null,c?(0,I.jsx)(Br,{feed:i,now:r}):null]})}var Hr=new Set;function Ur(e){let[t,n]=F.useState({}),r=t.pointer??t.focus,i=F.useCallback((e,t)=>n(n=>n[e]===t?n:{...n,[e]:t}),[]);return{linked:F.useMemo(()=>r===void 0?Hr:xn(r,e),[r,e]),active:F.useMemo(()=>r===void 0?Hr:new Set(e.filter(e=>e.waiterRunId===r||e.peerRunId===r).map(e=>e.id)),[r,e]),onHover:i}}function Wr(e,t,n=Z(e.tasks)){let r=new Set(e.tasks.map(e=>e.runId)),i=new Set(e.requests.map(e=>e.requestId)),a=Object.values(t.closing).filter(t=>t.projectId===e.projectId&&!i.has(t.request.requestId));return{cards:Object.values(t.leaving).filter(t=>t.projectId===e.projectId&&!r.has(t.task.runId)).map(e=>e.task),requests:a.map(e=>e.request),waits:Kn(e.projectId,n,t),folding:a.filter(e=>e.phase===`reply`||!e.replied).map(e=>e.request)}}var Gr=36,Kr=22,qr=4,Jr=10;function Yr(e,t,n,r=$){let i=[],a=(e,t)=>{let r=n.get(e);return r!==void 0&&r===n.get(t)};for(let t of e){if(t.relationship!==`peer`||!a(t.senderRunId,t.recipientRunId))continue;let e=r.closing[t.requestId];i.push({kind:`request`,id:t.requestId,from:t.senderRunId,to:t.recipientRunId,createdAt:t.createdAt,...e?{closing:!0,replied:e.replied}:{}})}for(let e of t)a(e.peerRunId,e.waiterRunId)&&i.push({kind:`wait`,id:e.id,from:e.peerRunId,to:e.waiterRunId,since:e.since,...e.id in r.waitsClosing?{closing:!0}:{}});if(i.length===0)return{edges:i,gutterWidth:0};let o=Math.min(qr,i.length);return{edges:i,gutterWidth:Math.min(132,64+(o-1)*Kr)}}function Xr(e,t,n){let r=new Set;if(!e)return r;for(let n of t)n.relationship===`peer`&&(n.senderRunId===e||n.recipientRunId===e)&&(r.add(n.senderRunId),r.add(n.recipientRunId));for(let t of n)(t.peerRunId===e||t.waiterRunId===e)&&(r.add(t.peerRunId),r.add(t.waiterRunId));return r}function Zr(e,t){return e.map(e=>{let n=t.get(e.from),r=t.get(e.to);if(!(!n||!r))return{edge:e,start:n,end:r,span:Math.abs(r.y-n.y)}}).filter(e=>e!==void 0).sort((e,t)=>e.span-t.span).map(({edge:e,start:t,end:n},r)=>{let i=r%qr,a=Math.max(10,Math.min(t.x,n.x)-Gr-i*Kr),o=n.y-t.y,s=o>=0?1:-1,c=Math.min(Jr,Math.abs(o)/2,Math.max(2,t.x-a-2)),l=e.kind===`request`?n.x-2:n.x-6;return{edge:e,path:[`M ${t.x} ${t.y}`,`L ${a+c} ${t.y}`,`Q ${a} ${t.y} ${a} ${t.y+s*c}`,`L ${a} ${n.y-s*c}`,`Q ${a} ${n.y} ${a+c} ${n.y}`,`L ${l} ${n.y}`].join(` `),laneX:a,labelY:t.y+o*(.5+(r%2==0?-.06:.08)),endX:n.x-4,endY:n.y}})}function Qr(e){let t=new Map,n=e.getBoundingClientRect();for(let r of e.querySelectorAll(`[data-activity-row]`)){let e=r.getAttribute(`data-activity-row`);if(!e)continue;let i=r.getBoundingClientRect();t.set(e,{x:i.left-n.left,y:i.top-n.top+Math.min(i.height/2,24)})}return t}function $r({stage:e,edges:t,active:n,now:r,layoutKey:i,motion:a=$,paused:o=!1}){let s=F.useId(),[c,l]=F.useState([]);F.useLayoutEffect(()=>{if(!e||t.length===0){l([]);return}let n=()=>l(Zr(t,Qr(e)));if(n(),typeof ResizeObserver>`u`)return;let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[e,t,i]);let u=F.useMemo(()=>new Set(c.filter(e=>e.edge.kind===`request`).map(e=>e.edge.id)),[c]),d=_r(a.comets,u,o);return(0,I.jsxs)(`div`,{"data-slot":`activity-margin-arcs`,"aria-hidden":`true`,className:j(`pointer-events-none absolute inset-0 z-[5] hidden overflow-visible`,t.length>0&&`md:block`),children:[(0,I.jsxs)(`svg`,{className:`size-full overflow-visible`,children:[(0,I.jsx)(`defs`,{children:(0,I.jsx)(`marker`,{id:s,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,I.jsx)(`path`,{d:`M0 1 L7 4 L0 7 z`,className:`fill-message-peer-accent`})})}),c.map(e=>{let{edge:t}=e,r=n!==void 0&&(t.from===n||t.to===n),i=n!==void 0&&!r,a=t.kind===`request`?j(`fill-none stroke-message-peer-accent transition-opacity`,!t.closing&&`activity-march`,t.closing&&`activity-line-out`):j(`fill-none stroke-message-peer-accent transition-opacity`,!t.closing&&`activity-drift`,t.closing&&`activity-line-out`);return(0,I.jsxs)(`g`,{opacity:i?.22:r?1:.82,children:[(0,I.jsx)(`path`,{d:e.path,"data-request":t.kind===`request`?t.id:void 0,"data-wait":t.kind===`wait`?t.id:void 0,strokeWidth:r?2.4:1.8,strokeDasharray:t.kind===`request`?t.replied?void 0:`6 4`:`0 7`,strokeLinecap:t.kind===`wait`?`round`:void 0,markerEnd:t.kind===`request`?`url(#${s})`:void 0,className:a}),t.kind===`wait`?(0,I.jsx)(`circle`,{cx:e.endX,cy:e.endY,r:`3.2`,strokeWidth:`1.7`,className:`fill-card stroke-message-peer-accent`}):null]},`${t.kind}:${t.id}`)}),(0,I.jsx)(`g`,{ref:d})]}),c.map(e=>{let{edge:t}=e,i=n!==void 0&&(t.from===n||t.to===n),a=n!==void 0&&!i,o=B(H(t.kind===`request`?t.createdAt:t.since,r));return(0,I.jsx)(`span`,{style:{left:e.laneX,top:e.labelY},className:j(`absolute -translate-x-1/2 -translate-y-1/2 rounded-full border border-message-peer-accent/60 bg-card px-1.5 py-0.5 text-xs font-semibold whitespace-nowrap text-message-peer-accent tabular-nums shadow-xs transition-opacity`,t.kind===`wait`&&`border-dashed`,a&&`opacity-25`),children:t.kind===`request`?`Req · ${o}`:`Wait · ${o}`},`label:${t.kind}:${t.id}`)})]})}var ei={permission:0,answer:1,respond:2,review:3,failed:4},ti={running:0,waiting:1,queued:2,retained:3},ni=new Set([`queued`,`waiting-for-capacity`]);function ri(e){return e.status===`review`||e.status===`failed`||e.rung===`failed`||G(e.status)&&y(e.rung)}function ii(e){let{task:t}=e,n=t.wait?.kind===`human`?t.wait:void 0;if(n?.detail.reason===`question`)return{...e,kind:`answer`,stateLabel:`Needs answer`,tone:`pending`,blockingReason:n.detail.question??`The agent asked a question and is waiting for your answer.`,ageSince:n.since,actionLabel:`Answer`};if(n?.detail.reason===`budget`){let t=n.detail.queuedMessages;return{...e,kind:`respond`,stateLabel:`Needs you`,tone:`pending`,blockingReason:t?`Automatic wakes used up · ${t} queued ${t===1?`message`:`messages`} waiting.`:`Automatic wakes used up.`,ageSince:n.since,actionLabel:`Respond`}}return{...e,kind:`respond`,stateLabel:`Needs you`,tone:`pending`,blockingReason:`Your turn to reply or finish the task.`,ageSince:n?.since??t.startedAt??t.createdAt,actionLabel:`Respond`}}function ai(e,t){let n={runId:t.runId,projectId:e.projectId,projectName:e.name,task:t},r=t.finishedAt??t.startedAt??t.createdAt;if(t.rung===`needs-permission`){let e=t.wait&&`since`in t.wait?t.wait.since:void 0;return{...n,kind:`permission`,stateLabel:`Needs permission`,tone:`pending`,blockingReason:`Waiting for permission approval before continuing.`,ageSince:e??t.startedAt??t.createdAt,actionLabel:`Open task`}}return t.status===`review`||t.rung===`needs-review`?{...n,kind:`review`,stateLabel:`Needs review`,tone:`info`,blockingReason:`Changes are ready for review before anything lands.`,ageSince:r,actionLabel:`Review`}:t.status===`failed`||t.rung===`failed`?{...n,kind:`failed`,stateLabel:`Failed`,tone:`danger`,blockingReason:t.error??`Task stopped with an error.`,ageSince:r,actionLabel:`Inspect`}:ii(n)}function oi(e){return G(e.status)?e.rung===`running`?`running`:ni.has(e.rung)?`queued`:`waiting`:`retained`}var si=e=>{if(!e)return 1/0;let t=Date.parse(e);return Number.isNaN(t)?1/0:t};function ci(e){let t=[],n=[];for(let r of e)for(let e of r.tasks)ri(e)?t.push(ai(r,e)):n.push({runId:e.runId,projectId:r.projectId,projectName:r.name,task:e,tier:oi(e)});return t.sort((e,t)=>ei[e.kind]-ei[t.kind]||si(e.ageSince)-si(t.ageSince)||e.runId.localeCompare(t.runId)),n.sort((e,t)=>ti[e.tier]-ti[t.tier]),{attention:t,working:n}}function li(e,t){let n=new Map;for(let t of e){let e=n.get(t.projectId);e?e.items.push(t):n.set(t.projectId,{projectId:t.projectId,projectName:t.projectName,items:[t]})}let r=new Map(t.map((e,t)=>[e,t]));return[...n.values()].sort((e,t)=>(r.get(e.projectId)??2**53-1)-(r.get(t.projectId)??2**53-1)||e.projectName.localeCompare(t.projectName))}function ui(e,t,n,r){let i=new Map;for(let n of t)n.relationship===`peer`&&n.recipientRunId===e&&i.set(n.senderRunId,X(r,n.senderRunId,n.senderTitle));for(let t of n)t.peerRunId===e&&i.set(t.waiterRunId,X(r,t.waiterRunId));let a=[...i.values()];if(a.length!==0)return a.length===1?`Unblocks ${a[0]}`:a.length===2?`Unblocks ${a[0]} + ${a[1]}`:`Unblocks ${a[0]} + ${a.length-1} more`}function di(e,t){if(e===void 0)return;let n=t.filter(t=>!e.has(t.runId));if(n.length!==0)return n.length===1?`New item needs your decision: ${n[0].task.title}`:`${n.length} new items need your decision`}var fi={permission:`border-l-pending`,answer:`border-l-pending`,respond:`border-l-pending`,review:`border-l-info`,failed:`border-l-danger`},pi=`relative z-[1] text-[12px] text-message-peer-accent hover:underline focus-visible:outline-2 focus-visible:outline-ring max-md:inline-flex max-md:min-h-11 max-md:items-center`,mi=[],hi=[],gi=new Map;function _i(e,t,n){return n?`/p/${encodeURIComponent(e)}/tasks/${encodeURIComponent(t)}`:`/tasks/${encodeURIComponent(t)}`}function vi({items:e,grouped:t,projectOrder:n,countSuffix:r,renderItems:i}){return t?(0,I.jsx)(`div`,{className:`flex flex-col gap-3`,children:li(e,n).map(e=>(0,I.jsxs)(`div`,{"data-slot":`activity-project-group`,"data-project":e.projectId,className:`flex flex-col gap-2`,children:[(0,I.jsxs)(`h3`,{className:`flex items-center gap-2 text-[12.5px] font-semibold text-foreground`,children:[(0,I.jsx)(`span`,{children:e.projectName}),(0,I.jsxs)(`span`,{className:`text-xs font-normal text-muted-foreground tabular-nums`,children:[e.items.length,` `,r]})]}),i(e.items)]},e.projectId))}):(0,I.jsx)(I.Fragment,{children:i(e)})}var yi={permission:`text-foreground`,answer:`text-foreground`,respond:`text-foreground`,review:`text-muted-foreground`,failed:`font-mono text-[12px] text-signal-word-red`};function bi({href:e,title:t,global:n}){let r=`hover:underline focus-visible:outline-2 focus-visible:outline-ring max-md:inline-flex max-md:min-h-11 max-md:min-w-11 max-md:items-center pointer-coarse:inline-flex pointer-coarse:min-h-11 pointer-coarse:min-w-11 pointer-coarse:items-center`;return n?(0,I.jsx)(A,{to:e,className:r,children:t}):(0,I.jsx)(N,{to:e,className:r,children:t})}function xi({record:e,href:t,global:n,selected:r,onTriage:i}){return e.kind===`permission`?(0,I.jsx)(M,{asChild:!0,size:`sm`,variant:`primary`,className:`max-md:flex-1`,children:n?(0,I.jsx)(A,{to:t,children:e.actionLabel}):(0,I.jsx)(N,{to:t,children:e.actionLabel})}):(0,I.jsx)(M,{type:`button`,size:`sm`,variant:e.kind===`answer`||e.kind===`respond`?`primary`:`outline`,"data-slot":`activity-triage-trigger`,"aria-expanded":r,className:`max-md:flex-1`,onClick:t=>i(e,t.currentTarget),children:e.actionLabel})}function Si({record:e,requests:t,waits:n,index:r,now:i,global:a,selected:s,linked:c,motion:u,onHover:d,onTriage:f}){let p=o().data,{task:m}=e,h=[m.runner?l(p,m.runner):void 0,m.model,m.currentStepId?`step ${m.currentStepId}`:void 0].filter(Boolean).join(` · `),g=ui(e.runId,t,n,r),_=_i(e.projectId,e.runId,a),ee={now:i,titleOf:e=>r.get(e)?.title??`Unreadable task`},te=m.workers.length>0;return(0,I.jsxs)(`article`,{"data-activity-row":e.runId,"data-activity-card":e.runId,"data-slot":`activity-decision`,"data-decision-kind":e.kind,"data-rung":m.rung,"data-selected":s?`true`:void 0,"data-linked":c?`true`:void 0,...tr(e.runId,d),className:j(`relative grid min-w-0 grid-cols-1 items-center gap-3 rounded-xl border border-card-edge border-l-[3px] bg-card px-4 py-3 shadow-card transition-colors md:grid-cols-[minmax(0,1fr)_auto] md:gap-x-4`,fi[e.kind],s&&`border-accent-text bg-accent-strong/[0.06]`,c&&`outline-2 outline-offset-1 outline-message-peer-accent`,e.runId in u.entering&&`activity-card-enter`),children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,I.jsxs)(`span`,{className:j(`inline-flex items-center gap-1.5 text-[12px] font-semibold`,Kt[e.tone]),children:[(0,I.jsx)(J,{run:m,role:`root`}),(0,I.jsx)(`span`,{"data-slot":`activity-verb`,children:e.stateLabel})]}),(0,I.jsx)(`h3`,{className:`min-w-0 truncate text-[14px] font-semibold text-foreground`,children:(0,I.jsx)(bi,{href:_,title:m.title,global:a})}),(0,I.jsx)(`span`,{"data-slot":`activity-project-badge`,className:`inline-flex shrink-0 items-center rounded-md border border-border bg-muted px-1.5 py-0.5 text-xs font-medium text-muted-foreground`,children:e.projectName}),e.ageSince?(0,I.jsx)(`span`,{"data-slot":`activity-age`,title:W(e.ageSince),className:`text-[12px] text-muted-foreground tabular-nums`,children:V(H(e.ageSince,i))}):null]}),(0,I.jsx)(`p`,{"data-slot":`activity-main`,className:j(`break-words text-[13px] leading-relaxed`,yi[e.kind]),children:e.blockingReason}),h||g?(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-muted-foreground`,children:[h?(0,I.jsx)(`span`,{children:h}):null,g?(0,I.jsxs)(`span`,{"data-slot":`activity-unblocks`,className:`font-medium text-message-peer-accent`,children:[`· `,g]}):null]}):null,(0,I.jsx)(qn,{runId:e.runId,requests:t,waits:n,index:r,link:a?A:N,pathOf:t=>a?`/p/${encodeURIComponent(e.projectId)}/tasks/${encodeURIComponent(t)}`:`/tasks/${encodeURIComponent(t)}`,className:`mt-1 flex flex-col gap-0.5 md:hidden`,linkClassName:pi})]}),(0,I.jsx)(`div`,{className:`flex items-center gap-2 max-md:w-full`,children:(0,I.jsx)(xi,{record:e,href:_,global:a,selected:s,onTriage:f})}),te?(0,I.jsx)(`div`,{className:`min-w-0 md:col-span-2`,children:(0,I.jsx)(er,{task:m,requests:t,index:r,ctx:ee,motion:u,projectId:e.projectId,global:a,compact:!0})}):null,(0,I.jsx)(Yn,{texts:Cn(e.runId,t,r,n)})]})}function Ci({items:e,requestsByProject:t,waitsByProject:n,indexByProject:r,now:i,global:a,grouped:o,projectOrder:s,selectedRunId:c,linkedIds:l,motion:u=$,onHover:d,onTriage:f}){return e.length===0?null:(0,I.jsxs)(`section`,{"data-slot":`activity-attention`,"aria-label":`Needs your decision`,className:`flex min-w-0 flex-col gap-2.5`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(`h2`,{className:`text-[12px] font-semibold tracking-[0.06em] text-muted-foreground uppercase`,children:`Needs your decision`}),(0,I.jsx)(`span`,{"data-slot":`activity-attention-count`,className:`inline-flex items-center rounded-full bg-inbox-count px-2 py-0.5 text-xs font-semibold text-inbox-count-foreground tabular-nums`,children:e.length}),(0,I.jsx)(`span`,{className:`ml-auto hidden text-[12px] text-muted-foreground sm:inline`,children:`Resolve inline without leaving the queue`})]}),(0,I.jsx)(vi,{items:e,grouped:o,projectOrder:s,countSuffix:`waiting`,renderItems:e=>(0,I.jsx)(`div`,{className:`flex flex-col gap-2.5`,children:e.map(e=>(0,I.jsx)(Si,{record:e,requests:t.get(e.projectId)??mi,waits:n.get(e.projectId)??hi,index:r.get(e.projectId)??gi,now:i,global:a,selected:c===e.runId,linked:l.has(e.runId),motion:u,onHover:d,onTriage:f},e.runId))})})]})}function wi(e){return`/p/${encodeURIComponent(e.projectId)}/tasks/${encodeURIComponent(e.runId)}`}function Ti(e){return{...e.id===void 0?{}:{id:e.id},header:e.header,question:e.question,...e.options===void 0?{}:{options:e.options.map(e=>({label:e.label,...e.description===void 0?{}:{description:e.description}}))},...e.multiSelect===void 0?{}:{multiSelect:e.multiSelect},...e.allowFreeText===void 0?{}:{allowFreeText:e.allowFreeText}}}function Ei(e,t){let n=Ee(t);if(!n)return;let r=Oe(n);if(r)return{kind:`ask`,id:r.id,questions:r.questions.map(Ti),...r.context===void 0?{}:{context:r.context},resolved:!1,...e.delegation?.role===`worker`?{parentRunId:e.delegation.parentRunId}:{}}}function Di({run:e,projectId:t,prompt:n,onResolved:r}){let i=ze(e,t),a=Ve(e.id,{projectId:t,onSuccess:r}),[o,s]=(0,F.useState)(``),c=async()=>{let e=o.trim();e&&await i.send(e)===void 0&&(s(``),r())};return(0,I.jsxs)(`div`,{"data-slot":`activity-quick-reply`,className:`flex flex-col gap-3 rounded-lg border border-border bg-card p-3.5`,children:[(0,I.jsx)(`p`,{className:`text-[13px] text-foreground`,children:n}),(0,I.jsx)(Be,{"aria-label":`Reply to task`,placeholder:`Write your reply…`,rows:3,value:o,disabled:i.isPending||i.blockedBy!==void 0,onChange:e=>s(e.target.value),className:`bg-background text-base md:text-[13px]`}),i.reason?(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i.reason}):null,i.error?(0,I.jsx)(`p`,{role:`alert`,className:`text-xs text-semantic-red`,children:i.error}):null,(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(M,{type:`button`,size:`sm`,variant:`primary`,disabled:i.isPending||i.blockedBy!==void 0||o.trim().length===0,onClick:()=>void c(),children:`Send reply`}),e.finishBlocked===null?(0,I.jsx)(M,{type:`button`,size:`sm`,variant:`outline`,disabled:a.isPending,onClick:()=>a.mutate(),children:`Finish task`}):null]})]})}function Oi({record:e,run:t,onResolved:n}){let r=oe({queryKey:[`activity-triage`,`history-context`,e.projectId,e.runId,e.ageSince??``,e.blockingReason],queryFn:({signal:t})=>x(e.runId,{projectId:e.projectId,signal:t}),staleTime:0,gcTime:0,refetchOnMount:`always`});if(r.isPending)return(0,I.jsx)(`p`,{"data-slot":`triage-loading`,className:`text-xs text-muted-foreground`,children:`Loading question…`});let i=r.data?Ei(t,r.data.contextEvents):void 0;return i?(0,I.jsx)(ye,{ask:i,run:t,projectId:e.projectId,onAnswered:n}):(0,I.jsx)(Di,{run:t,projectId:e.projectId,prompt:e.blockingReason,onResolved:n})}function ki({record:e,run:t,onResolved:n}){let r=m(),i=ze(t,e.projectId),[o,c]=(0,F.useState)(``),l=d({mutationFn:()=>ae(s(e.runId,{projectId:e.projectId}),!0),onSuccess:()=>{re(`Failed task archived.`),r.invalidateQueries({queryKey:a.runs.all}),n()},onError:e=>re(e.message,{tone:`danger`})}),u=async()=>{let e=o.trim()||`Continue and resolve the failure.`;await i.send(e)===void 0&&(re(`Task resumed.`),n())},f=t.error??e.blockingReason;return(0,I.jsxs)(`div`,{"data-slot":`activity-failed-triage`,className:`flex flex-col gap-3`,children:[(0,I.jsxs)(`div`,{className:`rounded-lg border border-danger/40 bg-card-2 p-3.5`,children:[(0,I.jsx)(`p`,{className:`text-xs font-semibold text-signal-word-red`,children:`Failure details`}),(0,I.jsx)(`pre`,{className:`mt-2 overflow-x-auto font-mono text-xs whitespace-pre-wrap text-foreground`,children:f})]}),i.mode===`unavailable`?null:(0,I.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,I.jsx)(`label`,{htmlFor:`activity-retry-note`,className:`text-xs font-medium text-foreground`,children:`Retry instruction (optional)`}),(0,I.jsx)(Be,{id:`activity-retry-note`,rows:2,placeholder:`Leave blank to continue and resolve the failure…`,value:o,disabled:i.isPending||i.blockedBy!==void 0,onChange:e=>c(e.target.value),className:`bg-card text-base md:text-[13px]`}),i.reason?(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i.reason}):null,i.error?(0,I.jsx)(`p`,{role:`alert`,className:`text-xs text-semantic-red`,children:i.error}):null]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i.mode===`unavailable`?null:(0,I.jsxs)(M,{type:`button`,size:`sm`,variant:`primary`,disabled:i.isPending||i.blockedBy!==void 0,onClick:()=>void u(),children:[(0,I.jsx)(De,{"aria-hidden":`true`,className:`size-3.5`}),`Retry task`]}),(0,I.jsxs)(M,{type:`button`,size:`sm`,variant:`outline`,disabled:l.isPending,onClick:()=>l.mutate(),children:[(0,I.jsx)(_e,{"aria-hidden":`true`,className:`size-3.5`}),`Archive`]})]})]})}function Ai(e){let{task:t}=e,n=t.workers.map(e=>`${e.runId}:${e.status}`).join(`,`);return`${t.status}|${t.rung}|${t.finishedAt??``}|${t.error??``}|${e.ageSince??``}|${n}`}function ji({record:e,onResolved:t}){let n=m(),i=r(e.projectId,e.runId,!0,{staleTime:0,refetchOnMount:`always`}),a=Ai(e),o=(0,F.useRef)(a);if((0,F.useEffect)(()=>{if(o.current===a)return;o.current=a;let t=!1,r=[e.projectId,`runs`,`detail`,e.runId];return he(n,r),n.cancelQueries({queryKey:r,exact:!0}).then(()=>{t||n.refetchQueries({queryKey:r,exact:!0,type:`active`})}),e.kind===`review`&&n.invalidateQueries({queryKey:[e.projectId,`runs`,`diff`,e.runId],exact:!0}),()=>{t=!0}},[a,n,e.kind,e.projectId,e.runId]),(0,F.useEffect)(()=>{let t=[e.projectId,`runs`,`detail`,e.runId];return f(()=>(he(n,t),n.cancelQueries({queryKey:t,exact:!0}).then(()=>n.refetchQueries({queryKey:t,exact:!0,type:`active`}))))},[n,e.projectId,e.runId]),i.isPending)return(0,I.jsx)(`p`,{"data-slot":`triage-loading`,className:`text-xs text-muted-foreground`,children:`Loading task details…`});if(i.isError||!i.data)return(0,I.jsxs)(`div`,{role:`alert`,className:`flex flex-col gap-2 text-xs text-semantic-red`,children:[(0,I.jsxs)(`p`,{children:[`Could not load task details: `,i.error?.message??`task unavailable`,`.`]}),(0,I.jsx)(M,{type:`button`,size:`sm`,variant:`outline`,className:`self-start`,onClick:()=>void i.refetch(),children:`Retry`})]});let s=i.isFetching&&i.data.finishBlocked!==void 0?{...i.data,finishBlocked:void 0}:i.data;return e.kind===`answer`?(0,I.jsx)(Oi,{record:e,run:s,onResolved:t}):e.kind===`review`?(0,I.jsx)(He,{run:s,projectId:e.projectId,onResolved:t}):e.kind===`failed`?(0,I.jsx)(ki,{record:e,run:s,onResolved:t}):(0,I.jsx)(Di,{run:s,projectId:e.projectId,prompt:e.blockingReason,onResolved:t})}function Mi({record:e,selectionToken:t,resolved:n=!1,now:r,onClose:i,onResolved:a,onRestoreFocus:o}){let s=m();return(0,I.jsx)(Ne,{open:e!==null,onOpenChange:e=>{e||i()},children:(0,I.jsx)(Fe,{side:`right`,showCloseButton:!1,"data-slot":`activity-triage-drawer`,onCloseAutoFocus:e=>{o&&(e.preventDefault(),o())},className:`flex h-full w-full flex-col gap-0 p-0 data-[state=closed]:duration-150 data-[state=open]:duration-200 sm:max-w-lg`,children:e?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(Me,{className:`flex-row items-start justify-between gap-3 border-b border-border bg-card px-4 py-3.5`,children:[(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(`span`,{className:j(`text-xs font-semibold`,Kt[e.tone]),children:e.stateLabel}),(0,I.jsx)(`span`,{className:`inline-flex items-center rounded-md border border-border bg-muted px-1.5 py-0.5 text-xs font-medium text-muted-foreground`,children:e.projectName}),e.ageSince?(0,I.jsx)(`span`,{title:W(e.ageSince),className:`text-xs text-muted-foreground tabular-nums`,children:V(H(e.ageSince,r))}):null]}),(0,I.jsx)(Pe,{className:`mt-1 truncate text-[16px] leading-snug`,children:e.task.title}),(0,I.jsxs)(Le,{className:`sr-only`,children:[`Resolve `,e.stateLabel.toLowerCase(),` for `,e.task.title,` without leaving Live Activity.`]})]}),(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,I.jsx)(M,{asChild:!0,size:`sm`,variant:`ghost`,className:`px-2.5 text-xs`,children:(0,I.jsxs)(A,{to:wi(e),children:[`Open task`,(0,I.jsx)(Ce,{"aria-hidden":`true`,className:`size-3.5`})]})}),(0,I.jsx)(M,{type:`button`,size:`icon`,variant:`ghost`,"aria-label":`Close triage drawer`,onClick:i,children:(0,I.jsx)(ge,{"aria-hidden":`true`,className:`size-4`})})]})]}),(0,I.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-4`,children:n?(0,I.jsxs)(`div`,{"data-slot":`activity-triage-resolved`,role:`status`,className:`flex flex-col gap-3 rounded-lg border border-border bg-card p-4 text-[13px] text-muted-foreground`,children:[(0,I.jsx)(`p`,{className:`text-foreground`,children:`This task no longer needs your decision.`}),(0,I.jsx)(M,{type:`button`,size:`sm`,variant:`outline`,className:`self-start`,onClick:i,children:`Close`})]}):(0,I.jsx)(ji,{record:e,onResolved:((e,t)=>()=>{s.invalidateQueries({queryKey:[`workspace`,`activity`]}),s.invalidateQueries({queryKey:[`activity-triage`,`history-context`,e.projectId,e.runId]}),s.invalidateQueries({queryKey:[e.projectId,`runs`,`detail`,e.runId],exact:!0}),a(e.runId,t)})(e,t)},`${e.projectId}:${e.runId}:${e.kind}:${t??0}`)})]}):null})})}var Ni=12,Pi=`col-start-3 row-start-1 min-w-[3.25rem] justify-self-end text-right md:col-start-5`,Fi={fail:4,pending:3,pass:2,skipping:1,cancel:0};function Ii(e,t){let n=e.slice(Ni);if(n.length===0)return t;let r=n.length+(t?.count??0),i=t?.bucket??n[0].bucket;for(let e of n)Fi[e.bucket]>Fi[i]&&(i=e.bucket);return{count:r,bucket:i}}function Li({record:e,requests:t,waits:n,index:r,ctx:i,global:a,linked:o,motion:s,onHover:c}){let{task:l}=e,u=Ht(l,i),d=_i(e.projectId,e.runId,a),f=l.startedAt??u.since??l.createdAt,p=s.slides[l.runId]?.key,m=In(s,l.runId);return(0,I.jsxs)(`article`,{"data-activity-row":e.runId,"data-activity-card":e.runId,"data-slot":`activity-working-row`,"data-rung":l.rung,"data-linked":o?`true`:void 0,...tr(e.runId,c),className:j(`relative flex min-w-0 flex-col gap-1.5 px-3.5 py-2.5 transition-colors first:rounded-t-xl last:rounded-b-xl`,o&&`bg-message-peer-bg outline-2 outline-offset-1 outline-message-peer-accent`,e.runId in s.entering&&`activity-card-enter`),children:[(0,I.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[14px_minmax(0,1fr)_auto] items-center gap-x-2.5 gap-y-1 md:grid-cols-[14px_minmax(0,1.25fr)_minmax(0,1.45fr)_auto_auto]`,children:[(0,I.jsx)(J,{run:l,role:`root`}),(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(`h3`,{className:`min-w-0 truncate text-[13px] font-semibold text-foreground`,children:a?(0,I.jsx)(A,{to:d,className:`hover:underline focus-visible:outline-2 focus-visible:outline-ring max-md:inline-flex max-md:min-h-11 max-md:items-center`,children:l.title}):(0,I.jsx)(N,{to:d,className:`hover:underline focus-visible:outline-2 focus-visible:outline-ring max-md:inline-flex max-md:min-h-11 max-md:items-center`,children:l.title})}),(0,I.jsx)(`span`,{"data-slot":`activity-project-badge`,className:`inline-flex shrink-0 items-center rounded-md border border-border bg-muted px-1.5 py-0.5 text-xs font-medium text-muted-foreground`,children:e.projectName}),l.currentStepId?(0,I.jsxs)(`span`,{"data-slot":`activity-step`,className:`hidden shrink-0 text-xs text-muted-foreground sm:inline`,children:[`step `,l.currentStepId]}):null]}),(0,I.jsxs)(`div`,{className:`col-span-2 col-start-2 flex min-w-0 items-center gap-2 text-[12px] text-muted-foreground md:col-span-1 md:col-start-3`,children:[(0,I.jsx)(`span`,{"data-slot":`activity-verb`,className:j(`shrink-0 font-semibold`,Kt[u.tone]),children:u.verb}),(0,I.jsx)(`span`,{"data-slot":`activity-main`,className:j(`min-w-0 truncate text-foreground`,u.mono&&`font-mono text-xs`,p!==void 0&&`activity-slide`),children:u.main},p??`still`),u.checks&&u.checks.length>0?(0,I.jsx)(rn,{checks:u.checks.slice(0,Ni),overflow:Ii(u.checks,u.overflow),passed:m,className:`hidden w-20 shrink-0 items-center gap-[2px] sm:inline-flex`}):null,u.checkSummary?(0,I.jsx)(`span`,{"data-slot":`activity-checks-summary`,className:`sr-only`,children:u.checkSummary}):null]}),(0,I.jsx)(an,{rate:l.rate,className:`hidden h-3.5 w-[52px] md:block`}),f?(0,I.jsx)(`span`,{"data-slot":`activity-elapsed`,title:W(f),className:j(Pi,`text-[12px] text-muted-foreground tabular-nums`),children:V(H(f,i.now))}):(0,I.jsx)(`span`,{className:Pi})]}),(0,I.jsx)(Yn,{texts:Cn(e.runId,t,r,n)}),(0,I.jsx)(qn,{runId:e.runId,requests:t,waits:n,index:r,link:a?A:N,pathOf:t=>_i(e.projectId,t,a),className:`ml-6 flex flex-col gap-0.5 md:hidden`,linkClassName:pi}),(0,I.jsx)(er,{task:e.task,requests:t,index:r,ctx:i,motion:s,projectId:e.projectId,global:a,compact:!0})]})}function Ri({items:e,requestsByProject:t,waitsByProject:n,indexByProject:r,now:i,global:a,grouped:o,projectOrder:s,linkedIds:c,motion:l=$,onHover:u}){return e.length===0?null:(0,I.jsxs)(`section`,{"data-slot":`activity-working`,"aria-label":`Working and active tasks`,className:`flex min-w-0 flex-col gap-2.5`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(`h2`,{className:`text-[12px] font-semibold tracking-[0.06em] text-muted-foreground uppercase`,children:`Working & active`}),(0,I.jsx)(`span`,{"data-slot":`activity-working-count`,className:`inline-flex items-center rounded-full bg-muted px-2 py-0.5 text-xs font-semibold text-foreground tabular-nums`,children:e.length}),(0,I.jsx)(`span`,{className:`ml-auto hidden text-[12px] text-muted-foreground sm:inline`,children:`Live tool activity, waits, and worker trees`})]}),(0,I.jsx)(vi,{items:e,grouped:o,projectOrder:s,countSuffix:`active`,renderItems:e=>(0,I.jsx)(`div`,{className:`divide-y divide-border rounded-xl border border-card-edge bg-card shadow-card`,children:e.map(e=>{let o=r.get(e.projectId)??gi,s={now:i,titleOf:e=>o.get(e)?.title??`Unreadable task`};return(0,I.jsx)(Li,{record:e,requests:t.get(e.projectId)??mi,waits:n.get(e.projectId)??hi,index:o,ctx:s,global:a,linked:c.has(e.runId),motion:l,onHover:u},e.runId)})})})]})}function zi(e){let t=new Map;for(let n of e)for(let[e,r]of _n(n))t.set(e,r);return t}function Bi(e,t){let n=[],r=[],i=[];for(let a of e){let e=Wr(a,t);n.push(...e.requests),r.push(...e.folding),i.push(...Kn(a.projectId,Z(a.tasks),t))}return{requests:n,folding:r,waits:i}}function Vi(e,t){if(!e)return{activeDecision:null,resolvedExternally:!1};let n=t.find(t=>t.runId===e.runId&&t.projectId===e.projectId)??null;return{activeDecision:n??e.snapshot,resolvedExternally:n===null}}function Hi(e){return e<=0?{"data-has-arcs":void 0,style:void 0,className:`relative flex min-w-0 flex-col gap-6`}:{"data-has-arcs":`true`,style:{"--activity-arc-gutter":`${e}px`},className:`relative flex min-w-0 flex-col gap-6 md:pl-(--activity-arc-gutter)`}}function Ui(e){let[t,n]=F.useState(void 0),r=F.useRef(void 0),i=F.useRef(void 0),a=F.useRef(void 0);return F.useEffect(()=>{let t=di(r.current,e);if(r.current=new Set(e.map(e=>e.runId)),t){if(a.current!==void 0&&(window.clearTimeout(a.current),a.current=void 0),i.current!==t){i.current=t,n(t);return}n(``),a.current=window.setTimeout(()=>{a.current=void 0,i.current=t,n(t)},0)}},[e]),F.useEffect(()=>()=>{a.current!==void 0&&window.clearTimeout(a.current)},[]),t}function Wi(e,t,n){if(e&&e.isConnected){e.focus({preventScroll:!0});return}(t?.querySelector(`[data-slot="activity-triage-trigger"]`)??n)?.focus({preventScroll:!0})}function Gi({projects:e,now:t,global:n,grouped:r,projectOrder:i,motion:a=$,feed:o=[],still:s=!1,paused:c=!1,emptyMessage:l}){let u=F.useRef(null),[d,f]=F.useState(null),p=F.useRef(0),[m,h]=F.useState(null),g=F.useRef(null),[_,ee]=F.useState({}),te=F.useMemo(()=>zi(e),[e]),ne=F.useMemo(()=>new Map(e.map(e=>[e.projectId,_n(e)])),[e]),v=F.useMemo(()=>new Map(e.map(e=>[e.projectId,e.requests])),[e]),y=F.useMemo(()=>new Map(e.map(e=>[e.projectId,Z(e.tasks)])),[e]),{attention:b,working:x}=F.useMemo(()=>ci(e),[e]),re=Ui(b),ie=F.useMemo(()=>e.flatMap(e=>e.requests),[e]),ae=F.useMemo(()=>e.flatMap(e=>Z(e.tasks)),[e]),S=F.useMemo(()=>Bi(e,a),[e,a]),oe=F.useMemo(()=>[...ie,...S.requests],[ie,S.requests]),se=F.useMemo(()=>[...ae,...S.waits],[ae,S.waits]),ce=F.useMemo(()=>new Map([...b.map(e=>[e.runId,e.projectId]),...x.map(e=>[e.runId,e.projectId])]),[b,x]),{edges:C,gutterWidth:le}=F.useMemo(()=>Yr(oe,se,ce,a),[oe,se,ce,a]),w=_.pointer??_.focus,ue=F.useMemo(()=>{let e=w?ce.get(w):void 0;return e&&w?Xr(w,v.get(e)??[],y.get(e)??[]):new Set},[w,v,ce,y]),T=F.useCallback((e,t)=>{ee(n=>{if(n[e]===t)return n;let r={...n};return t===void 0?delete r[e]:r[e]=t,r})},[]),{activeDecision:de,resolvedExternally:E}=F.useMemo(()=>Vi(m,b),[b,m]),fe=F.useCallback((e,t)=>{g.current=t,h({token:++p.current,projectId:e.projectId,runId:e.runId,snapshot:e})},[]),pe=F.useCallback(()=>Wi(g.current,d,u.current),[d]),D=F.useCallback(()=>h(null),[]),me=F.useCallback((e,t)=>{h(e=>e&&(t===void 0||e.token===t)?null:e)},[]),O=`${r}:${b.map(e=>e.runId).join(`,`)}:${x.map(e=>e.runId).join(`,`)}:${C.map(e=>e.id).join(`,`)}`,k=b.length===0&&x.length===0;return(0,I.jsxs)(`div`,{ref:u,tabIndex:-1,className:`flex min-w-0 flex-col gap-5 outline-none`,children:[(0,I.jsx)(`p`,{"data-slot":`activity-announcement`,role:`status`,"aria-live":`polite`,className:`sr-only`,children:re??``}),k&&l?(0,I.jsx)(`p`,{"data-slot":`activity-empty`,className:`py-6 text-[13px] text-muted-foreground`,children:l}):null,k?null:(0,I.jsxs)(`div`,{ref:f,"data-slot":`activity-stage`,...Hi(le),children:[(0,I.jsx)($r,{stage:d,edges:C,active:w,now:t,layoutKey:O,motion:a,paused:c||s}),(0,I.jsx)(Ci,{items:b,requestsByProject:v,waitsByProject:y,indexByProject:ne,now:t,global:n,grouped:r,projectOrder:i,selectedRunId:de?.runId,linkedIds:ue,motion:a,onHover:T,onTriage:fe}),(0,I.jsx)(Ri,{items:x,requestsByProject:v,waitsByProject:y,indexByProject:ne,now:t,global:n,grouped:r,projectOrder:i,linkedIds:ue,motion:a,onHover:T})]}),(0,I.jsx)(Vr,{requests:ie,closing:S.folding,index:te,now:t,feed:o,motion:a}),(0,I.jsx)(Mi,{record:de,selectionToken:m?.token,resolved:E,now:t,onClose:D,onResolved:me,onRestoreFocus:pe})]})}var Ki=e=>new Map(e.map(e=>[e.runId,e])),qi=e=>e!==void 0&&gn(e)===void 0;function Ji(e,t,n,r){let i=Ki(t.workers);for(let t of n.workers){let a=i.get(t.runId);!a&&G(t.status)&&r({kind:`worker-started`,projectId:e,parentId:n.runId,worker:t}),a&&G(a.status)&&!G(t.status)&&r({kind:`worker-settled`,projectId:e,parentId:n.runId,worker:t})}}function Yi(e,t,n,r){if(t.wait?.kind!==`pr`||n.wait?.kind!==`pr`||t.wait.detail.number!==n.wait.detail.number)return;let i=new Set((t.wait.detail.checks??[]).filter(e=>e.bucket===`pending`).map(e=>e.name));for(let t of n.wait.detail.checks??[])t.bucket===`pass`&&i.has(t.name)&&r({kind:`check-passed`,projectId:e,runId:n.runId,pr:n.wait.detail.number,name:t.name})}var Xi=(e,t)=>t.tool!==void 0&&(t.tool.startedAt!==e.tool?.startedAt||t.tool.title!==e.tool?.title);function Zi(e,t,n,r){t.rung!==n.rung&&r({kind:`rung-changed`,projectId:e,task:n,from:t.rung}),Xi(t,n)&&r({kind:`tool-started`,projectId:e,runId:n.runId}),Ji(e,t,n,r),Yi(e,t,n,r)}function Qi(e,t,n){let r=Ki(e.tasks),i=Ki(t.tasks);for(let e of t.tasks){let i=r.get(e.runId);i?Zi(t.projectId,i,e,n):n({kind:`card-entered`,projectId:t.projectId,task:e})}for(let r of e.tasks)i.has(r.runId)||n({kind:`card-left`,projectId:t.projectId,task:r})}function $i(e,t,n){let r=new Set(e.requests.map(e=>e.requestId)),i=new Set(t.requests.map(e=>e.requestId)),a=new Map(t.closed.map(e=>[e.requestId,e.status]));for(let e of t.requests)r.has(e.requestId)||n({kind:`request-opened`,projectId:t.projectId,request:e});for(let r of e.requests){if(i.has(r.requestId))continue;let e=a.get(r.requestId);n({kind:`request-closed`,projectId:t.projectId,request:r,...e?{status:e}:{}})}}function ea(e,t,n){let r=Z(e.tasks),i=Z(t.tasks),a=new Set(r.map(e=>e.id)),o=new Set(i.map(e=>e.id));for(let e of i)a.has(e.id)||n({kind:`wait-opened`,projectId:t.projectId,wait:e});for(let e of r)o.has(e.id)||n({kind:`wait-closed`,projectId:t.projectId,wait:e})}var ta=[`needsYou`,`working`,`waiting`,`queued`,`activeWorkers`,`openRequests`,`inReview`];function na(e,t,n){let r=Mn(e),i=Mn(t);for(let e of ta)r[e]!==i[e]&&n({kind:`chip-changed`,chip:e,from:r[e],to:i[e]})}function ra(e,t){if(e===void 0)return[];let n=[],r=e=>n.push(e),i=new Map(e.projects.map(e=>[e.projectId,e]));for(let e of t.projects){let t=i.get(e.projectId);!qi(t)||!qi(e)||(Qi(t,e,r),$i(t,e,r),ea(t,e,r))}return na(e.projects,t.projects,r),n}function ia(e){return{input:e,reconcile:!1,seq:0,motion:$,feed:[],epoch:0,...e.snapshot?{seen:e.snapshot}:{}}}function aa(e){let{plan:t,...n}=e;return{...n,motion:$,epoch:e.epoch+1}}function oa(e,t,n){let r=ra(t,n);if(r.length===0)return e;let i=Date.parse(n.generatedAt),a=Or(t,n),o=r.flatMap(e=>Nr(e,a,i)??[]),s=e.seq+o.length+1,c=Un(r,s,e.input.reduced);return{...e,seq:s,feed:o.length>0?Pr(e.feed,o,i,e.seq+1):e.feed,motion:Gn(e.motion,c.changes),...c.timers.length>0?{plan:{key:s,timers:c.timers}}:{}}}function sa(e,t){let n=e.seen;if(!t||t===n)return e;let r={...e,seen:t};return!n||!e.input.active?r:e.reconcile?{...r,reconcile:!1}:oa(r,n,t)}function ca(e,t){let n=e.input;if(t.scope!==n.scope)return{...ia(t),seq:e.seq,epoch:e.epoch+1};if(t.snapshot===n.snapshot&&t.active===n.active&&t.reduced===n.reduced)return e;let r={...e,input:t};return n.active&&!t.active&&(r={...aa(r),reconcile:!0}),!n.reduced&&t.reduced&&(r=aa(r)),sa(r,t.snapshot)}var la=`(prefers-reduced-motion: reduce)`,ua=()=>typeof window<`u`&&typeof window.matchMedia==`function`?window.matchMedia(la):void 0;function da(e){let t=ua();return t?.addEventListener?.(`change`,e),()=>t?.removeEventListener?.(`change`,e)}function fa(){return ua()?.matches??!1}function pa(){return(0,F.useSyncExternalStore)(da,fa,()=>!1)}function ma(e,t){let n=F.useRef(new Set);F.useEffect(()=>{let e=n.current;return()=>{for(let t of e)clearTimeout(t);e.clear()}},[e.epoch]),F.useEffect(()=>{for(let{after:r,change:i}of e.plan?.timers??[]){let e=setTimeout(()=>{n.current.delete(e),t(e=>({...e,motion:Gn(e.motion,[i])}))},r);n.current.add(e)}},[e.plan?.key])}function ha(e,t){let n=pa(),r=S(),i={snapshot:e,scope:t,active:r,reduced:n},[a,o]=F.useState(()=>ia(i)),s=ca(a,i);return s!==a&&o(s),ma(s,o),{motion:s.motion,feed:s.feed,reduced:n,paused:!r}}function ga(e,t){let n=Ie(1e3),[r,i]=F.useState({offset:0}),a=r.offset;return lt(e)&&e!==r.generatedAt&&t!==0&&(a=Date.parse(e)-t,i({generatedAt:e,offset:a})),n+a}export{J as A,_n as C,hn as D,pn as E,W as F,H as I,V as L,G as M,Ht as N,fn as O,B as P,mt as R,gn as S,un as T,$ as _,Dr as a,X as b,Er as c,_r as d,ar as f,qn as g,tr as h,Ur as i,qt as j,an as k,wr as l,Yn as m,ha as n,Cr as o,nr as p,Gi as r,Tr as s,ga as t,yr as u,Kn as v,Mn as w,Z as x,Cn as y};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Ht as e,S as t,St as n,dn as r,en as i,ut as a}from"./queries-D9mg7sFY.js";import{Bn as o,Hn as s,In as c,Ln as l,Rn as u,Un as d,Vn as f,a as p,tn as m}from"./toaster-2ud_VdfV.js";function h(t){let n=t.filter(e=>!e.isDefault&&e.status===void 0),i=r({queries:n.map(t=>({queryKey:e.agentAccountStatus(t.id),queryFn:({signal:e})=>m(t.id,{signal:e}),staleTime:6e4,retry:!1}))}),a=new Map;return n.forEach((e,t)=>{let n=i[t]?.data?.status?.status;n!==void 0&&a.set(e.id,n)}),a}function g(e,t,n){let r=e?.projectSelections?.[t??`default`];return r===void 0?n?e?.selections?.[n]:void 0:r}function _(){let e=a().data?.profiles??[],t=h(e);return e.map(e=>{let n=e.status?.status??t.get(e.id);return{provider:e.provider,id:e.id,label:e.label,...e.configDir===void 0?{}:{configDir:e.configDir},isDefault:e.isDefault,...n===void 0?{}:{status:n}}})}function v(e){let n=a(),r=p(),i=t(e),o=_(),s=i.data?.info?.root;return{accounts:o,repoAccount:g(n.data,e??r.projectId,s)}}function y(e,t){return e.filter(e=>e.provider===t).length>1}function b(e){let t=n(),r=i(),{accounts:a,repoAccount:p}=v(e);return{runners:d(t.data,r.data,a),uninstalled:s(t.data,r.data),signedOut:f(t.data,r.data,a),accounts:l(t.data,a),repoAccount:p,accountFor:(e,n)=>c(t.data,a,e,n,p),runnersOn:e=>o(t.data,r.data,a,e),readyOn:(e,n)=>u(t.data,a,e,n)}}export{b as a,v as i,g as n,_ as r,y as t};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Jt as r,Vt as i,Xt as a,b as o,en as s,h as c,m as l,vt as u}from"./queries-D9mg7sFY.js";import{Cn as d,Fi as f,n as p}from"./toaster-2ud_VdfV.js";import{o as m}from"./dist-CCX8mhHc.js";import{t as h}from"./button-BV_AiLj2.js";import{t as g}from"./badge-DAnkqD7i.js";import{t as _}from"./centered-state-N8vWM_Hw.js";import{F as v,Hn as y,Rn as b,br as x}from"./index-DKnr4QWH.js";import{n as S,r as C,t as w}from"./remote-settings-notice-oiFixJ1Q.js";import{t as T}from"./use-path-bases-B7D8PPso.js";import{t as E}from"./code-editor-DZMD1guX.js";import{t as D}from"./discard-changes-dialog-Db5fnRbe.js";import{r as O}from"./settings-save-bar-BBRySnQz.js";var k=e(t(),1);function A(e){return t=>t.runners.includes(e)}function j(e,t){let n=A(e);return e=>n(e)&&e.kind===t}function M(e){let{label:t,note:n,groups:r}=e.agentConfig;return{id:e.id,label:t,note:n,groups:r.map(({id:t,label:n,note:r,empty:i,showsUserMcp:a})=>({id:t,label:n,note:r,...i?{empty:i}:{},...a?{showsUserMcp:a}:{},files:j(e.id,t)}))}}function N(e){return r(e).map(M)}var P=n();function F(e){return e.seeded?`Copied into each run’s worktree — takes effect on your next run.`:e.tracked===`tracked`?`Runs read the committed copy — this edit applies after you commit it.`:e.tracked===`outside-repo`?`Applies to every session on this machine.`:`Personal, git-ignored.`}function I(){let e=l(),t=C(),n=u(),r=s(),i=r.data,o=(0,k.useMemo)(()=>N(i),[i]),c=(0,k.useMemo)(()=>n.data?v(n.data.checks,i):a(i),[n.data,i]);return r.isError?(0,P.jsx)(_,{icon:(0,P.jsx)(x,{}),tone:`danger`,title:`Runners did not load`,subtitle:r.error.message,heading:`h2`}):e.isError?(0,P.jsx)(_,{icon:(0,P.jsx)(x,{}),tone:`danger`,title:`Agent config did not load`,subtitle:e.error.message,heading:`h2`}):e.isPending||i===void 0?(0,P.jsx)(`p`,{"data-slot":`agent-config-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading agent config…`}):(0,P.jsx)(L,{listing:e.data,descriptors:o,installed:c,onOpenFile:t})}function L({listing:e,descriptors:t,installed:n,onOpenFile:r}){let[i,a]=(0,k.useState)(`claude`),[o,s]=(0,k.useState)(null),[c,l]=(0,k.useState)(!1),[u,d]=(0,k.useState)(null),f=t.find(e=>e.id===i)??t[0];if(f===void 0)return null;let p=R(f,e),h=p.find(e=>e.id===o)??z(p),_=e=>{c?d(()=>e):e()},v=e=>{e!==f.id&&_(()=>{a(e),s(null)})};return(0,P.jsxs)(`div`,{"data-slot":`agent-config`,className:`flex flex-col gap-5 p-4 md:p-6`,children:[(0,P.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Edit project, local, and user-wide config files for each coding agent.`}),!e.editable&&(0,P.jsxs)(`div`,{"data-slot":`agent-config-readonly`,className:`rounded-md border border-border bg-muted/40 px-3 py-2 text-[13px] text-muted-foreground`,children:[`Read-only: this remote cockpit cannot edit agent config. You can still see every file and which one wins. To edit here, the host operator runs `,(0,P.jsx)(`code`,{children:w}),`.`]}),(0,P.jsx)(S,{risk:`Agent config can define hooks and MCP servers that run commands on the machine running Squawk`}),(0,P.jsx)(`div`,{"data-slot":`agent-config-agents`,role:`tablist`,className:`flex flex-wrap gap-1`,children:t.map(e=>(0,P.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":e.id===f.id,"data-slot":`agent-config-agent`,"data-agent":e.id,"data-selected":e.id===f.id,onClick:()=>v(e.id),className:m(`flex min-w-11 items-center justify-center gap-2 rounded-md px-3 py-1.5 text-[13px] transition-colors`,e.id===f.id?`bg-background font-semibold shadow-sm`:`hover:bg-muted/60`),children:[e.label,!n.includes(e.id)&&(0,P.jsx)(g,{variant:`outline`,className:`text-xs text-soft-foreground`,children:`Not installed`})]},e.id))}),f.note&&(0,P.jsx)(`p`,{"data-slot":`agent-config-agent-note`,className:`text-xs text-muted-foreground`,children:f.note}),(0,P.jsxs)(`div`,{className:`grid min-w-0 gap-6 lg:grid-cols-[minmax(17rem,24rem)_minmax(0,1fr)]`,children:[(0,P.jsx)(`nav`,{"data-slot":`agent-config-nav`,className:`flex min-w-0 flex-col gap-5`,children:(0,P.jsx)(V,{agent:f,listing:e,selectedId:h?.id??null,onSelect:e=>{if(e===h?.id){r();return}_(()=>{s(e),r()})}})}),(0,P.jsx)(`div`,{"data-slot":`agent-config-editor-pane`,className:`min-w-0`,children:h?(0,P.jsx)(U,{file:h,onDirtyChange:l},h.id):(0,P.jsx)(`p`,{"data-slot":`agent-config-editor-empty`,className:`rounded-md border border-border bg-muted/40 px-4 py-3 text-[13px] text-soft-foreground`,children:`This agent has no config files to show.`})})]}),(0,P.jsx)(D,{open:u!==null,subject:h?.label??`this file`,onKeep:()=>d(null),onDiscard:()=>{let e=u;d(null),l(!1),e?.()}})]})}function R(e,t){return e.groups.flatMap(e=>t.files.filter(e.files))}function z(e){return e.find(e=>e.scope===`project`)??e[0]??null}var B={project:`Project scope`,local:`Local scope`,user:`User scope`};function V({agent:e,listing:t,selectedId:n,onSelect:r}){let i=T();return(0,P.jsx)(P.Fragment,{children:e.groups.map(a=>{let o=t.files.filter(a.files),s=a.showsUserMcp?t.userMcp:void 0;return o.length===0&&!s&&!a.empty?null:(0,P.jsxs)(`section`,{"data-slot":`agent-config-group`,"data-group":a.id,"data-agent":e.id,children:[(0,P.jsx)(`p`,{className:`mb-1 text-xs font-medium uppercase tracking-wide text-soft-foreground`,children:a.label}),a.note&&(0,P.jsx)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:a.note}),o.length===0&&a.empty&&(0,P.jsx)(`p`,{"data-slot":`agent-config-group-empty`,className:`rounded-md border border-dashed border-border px-3 py-2 text-xs text-muted-foreground`,children:a.empty}),(0,P.jsx)(`ul`,{className:`flex flex-col gap-1`,children:o.map(e=>(0,P.jsx)(`li`,{children:(0,P.jsxs)(`button`,{type:`button`,"data-slot":`agent-config-file`,"data-selected":e.id===n,onClick:()=>r(e.id),title:e.label,className:m(`flex w-full flex-col items-start gap-1 rounded-md px-2 py-1.5 text-left text-[13px] transition-colors`,e.id===n?`bg-accent-strong/15 text-foreground`:`hover:bg-muted/60`),children:[(0,P.jsx)(`span`,{"data-slot":`agent-config-file-name`,className:`min-w-0 max-w-full break-all font-mono text-[12px]`,children:e.label}),e.seeded||!e.exists?(0,P.jsxs)(`span`,{"data-slot":`agent-config-file-meta`,className:`flex flex-wrap items-center gap-1.5`,children:[e.seeded&&(0,P.jsx)(g,{variant:`outline`,className:`text-xs`,children:`Default template`}),!e.exists&&(0,P.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Not created`})]}):null]})},e.id))}),s&&(0,P.jsx)(H,{userMcp:s,path:y(s.path,i)})]},a.id)})})}function H({userMcp:e,path:t}){return(0,P.jsxs)(`div`,{"data-slot":`agent-config-user-mcp`,className:`mt-3`,children:[(0,P.jsx)(`h4`,{className:`mb-1 text-[12px] font-semibold`,children:`User & local scopes`}),(0,P.jsxs)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:[`Managed by `,(0,P.jsx)(`code`,{"data-slot":`agent-config-user-mcp-command`,className:`whitespace-nowrap font-mono`,children:`claude mcp add`}),` in`,` `,(0,P.jsx)(`code`,{"data-slot":`agent-config-user-mcp-path`,title:e.path,className:`break-all font-mono text-foreground`,children:t}),` — Squawk does not edit Claude’s state file.`]}),e.readable?e.servers.length>0?(0,P.jsx)(`ul`,{className:`flex flex-wrap gap-1`,children:e.servers.map(e=>(0,P.jsx)(`li`,{children:(0,P.jsx)(g,{variant:`outline`,className:`font-mono text-xs`,children:e})},e))}):(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No user-scoped MCP servers.`}):(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Could not read the file.`})]})}function U({file:e,onDirtyChange:t}){let n=c(e.id),r=T(),[i,a]=(0,k.useState)(null),[o,s]=(0,k.useState)(!1),[l,u]=(0,k.useState)(null),d=n.data?.version??null,f=i??n.data?.content??``,p=n.data?f!==n.data.content:!1,m=e.writable,h=e.kind===`mcp`||e.holdsMcp,_=m&&p;(0,k.useEffect)(()=>{t?.(_)},[_,t]),(0,k.useEffect)(()=>()=>t?.(!1),[t]);let{save:v}=J({file:e,content:f,loadedVersion:d,setDraft:a,setConflict:s,setFormatError:u});return O({dirty:m&&p,save:v,discard:()=>a(null)}),(0,k.useEffect)(()=>{n.data&&(a(n.data.content),s(!1),u(null))},[n.data?.version,n.data]),(0,P.jsxs)(`div`,{"data-slot":`settings-config-editor`,"data-reports-dirty":``,className:`flex flex-col gap-3`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(`h3`,{className:`text-sm`,children:`Configuration file`}),(0,P.jsx)(g,{variant:`outline`,"data-slot":`agent-config-scope`,"data-scope":e.scope,className:`text-[12px]`,children:B[e.scope]})]}),(0,P.jsx)(b,{"data-slot":`agent-config-path`,value:e.path,bases:r,className:`text-xs text-foreground`}),(0,P.jsxs)(`div`,{className:`settings-readout flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`font-mono text-[13px]`,children:e.label}),(0,P.jsx)(g,{variant:`outline`,className:`text-[12px] uppercase`,children:e.format}),(0,P.jsx)(`a`,{href:e.docsUrl,target:`_blank`,rel:`noreferrer`,className:`text-[12px] text-soft-foreground underline hover:text-foreground`,children:`docs`})]}),(0,P.jsxs)(`div`,{className:`settings-config-content-heading`,children:[(0,P.jsx)(`h3`,{children:h?`MCP configuration`:`File contents`}),h&&(0,P.jsx)(`p`,{children:`Review server commands before saving. MCP servers execute locally.`})]}),n.isPending?(0,P.jsx)(`p`,{className:`text-[13px] text-soft-foreground`,children:`Loading file…`}):n.isError?(0,P.jsx)(`p`,{className:`text-[13px] text-destructive`,children:n.error.message}):(0,P.jsx)(W,{file:e,content:f,isMcp:h,onChange:a}),(0,P.jsx)(K,{formatError:l,conflict:o,onReload:()=>void n.refetch()}),m&&!e.exists&&!p?(0,P.jsx)(`p`,{"data-slot":`agent-config-save-cue`,className:`text-xs text-muted-foreground`,children:`Enter content above to create this file.`}):null,(0,P.jsxs)(`div`,{className:`settings-config-save-help`,children:[(0,P.jsx)(`p`,{"data-slot":`agent-config-precedence`,className:`text-xs text-muted-foreground`,children:e.precedence}),(0,P.jsxs)(`p`,{"data-slot":`agent-config-effect`,className:`text-xs text-foreground`,children:[F(e),e.hotReload?` ${e.hotReload}`:``]}),(0,P.jsx)(q,{reason:e.readOnlyReason})]})]})}function W({file:e,content:t,isMcp:n,onChange:r}){return(0,P.jsxs)(`div`,{"data-slot":`agent-config-editor-frame`,className:`relative`,children:[(0,P.jsx)(E,{value:t,language:e.format,readOnly:!e.writable,onChange:r,"aria-label":`${e.label} contents`,className:`h-[210px]`}),!e.exists&&t===``&&(0,P.jsx)(`pre`,{"data-slot":`agent-config-placeholder`,"aria-hidden":`true`,className:`pointer-events-none absolute inset-px m-0 overflow-hidden whitespace-pre px-3 py-2 font-mono text-xs leading-[1.7] text-soft-foreground`,children:G(e,n)})]})}function G(e,t){switch(e.format){case`json`:case`jsonc`:return`// File not created yet — example:\n${t?`{
|
|
2
|
-
"mcpServers": {}
|
|
3
|
-
}`:`{
|
|
4
|
-
"permissions": {}
|
|
5
|
-
}`}`;case`markdown`:return`<!-- File not created yet — write instructions here -->`;case`toml`:return`# File not created yet — example:
|
|
6
|
-
# key = "value"`;case`yaml`:return`# File not created yet — example:
|
|
7
|
-
# key: value`}}function K({formatError:e,conflict:t,onReload:n}){return(0,P.jsxs)(P.Fragment,{children:[e&&(0,P.jsx)(`p`,{"data-slot":`agent-config-format-error`,className:`text-[12px] text-destructive`,children:e}),t&&(0,P.jsxs)(`div`,{"data-slot":`agent-config-conflict`,className:`flex items-center justify-between gap-2 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[12px]`,children:[(0,P.jsx)(`span`,{children:`The file changed on disk since you opened it.`}),(0,P.jsx)(h,{size:`sm`,variant:`outline`,onClick:n,children:`Reload from disk`})]})]})}function q({reason:e}){return e&&(0,P.jsx)(`p`,{children:e})}function J({file:e,content:t,loadedVersion:n,setDraft:r,setConflict:a,setFormatError:s}){let c=o(e.id),l=f(),u=C();return{save:()=>(s(null),a(!1),c.mutateAsync({content:t,version:n},{onSuccess:()=>{r(null)},onError:e=>{e instanceof d&&e.status===409?u().then(()=>{l.getQueryData(i.health)?.capabilities.settingsAdmin===!1?p(e.message,{tone:`danger`}):a(!0)}):e instanceof d&&e.status===400?s(e.message):p(e.message,{tone:`danger`})}}))}}export{I as AgentConfigSection};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{At as r,Ht as i,Jt as a,S as o,St as s,Vt as c,Xt as l,en as u,g as d,kt as f,nn as p,qt as m,rn as h,un as g,ut as _,wt as v,xt as y}from"./queries-D9mg7sFY.js";import{Cn as b,Fi as x,Fn as S,I as C,Zt as ee,a as w,n as T,vn as E}from"./toaster-2ud_VdfV.js";import{c as D}from"./design-icons-QbNMZniQ.js";import{t as O}from"./button-BV_AiLj2.js";import{t as k}from"./switch-B9OfOEzC.js";import{t as A}from"./status-dot-DTU7afRv.js";import{n as j}from"./agent-accounts-C2ILQhZy.js";import{t as M}from"./centered-state-N8vWM_Hw.js";import{I as N,Mn as P,P as F,R as I}from"./index-DKnr4QWH.js";import{t as te}from"./textarea-BGp28xFr.js";import{t as L}from"./option-select-C7kknSij.js";import{a as ne,i as R,n as z,r as B,t as V}from"./settings-agent-picker-BHaCHv3L.js";import{n as H,t as U}from"./save-cue-CpHgT93o.js";import{n as W}from"./settings-field-AyinSFR_.js";import{r as G}from"./settings-save-bar-BBRySnQz.js";import{n as K}from"./saved-draft-BwzBc-_Y.js";var q=e(t(),1),J=n(),Y={connected:P(`connected`),disconnected:P(`disconnected`),"not-installed":P(`not-installed`),unknown:P(`unknown`)};function X(e,t,n){return{providers:e.providers.map(e=>e.provider===t?{...e,enabled:n}:e)}}function re(e,t){return e?Y[e]:t?{label:`Checking…`,tone:`neutral`}:Y.unknown}function ie(e,t){return e===`unknown`||t&&!e}function ae({provider:e,state:t,current:n,statusIsError:r}){return t===`not-installed`?(0,J.jsxs)(`p`,{className:`mt-1.5 text-xs text-soft-foreground`,children:[`Install `,e.displayName,`, then run `,(0,J.jsx)(`code`,{children:e.loginCommand}),`.`]}):ie(t,r)?(0,J.jsx)(`p`,{className:`mt-1.5 text-xs text-soft-foreground`,children:`Verification failed. Check again when the provider is available.`}):n?.hint?(0,J.jsx)(`p`,{className:`mt-1.5 text-xs text-soft-foreground`,children:n.hint}):null}function oe({provider:e,state:t,current:n,isConnecting:r,incidentId:i,refresh:a,connect:o,retry:s,queueToggle:c}){let l=t===`disconnected`||t===`unknown`,u=H();return(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t===`not-installed`?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(U,{saved:u.saved}),(0,J.jsx)(k,{checked:n?.enabled??!0,"aria-label":`Use ${e.displayName}`,onCheckedChange:t=>c(e.id,t,u.flash)})]}),l?(0,J.jsx)(O,{type:`button`,variant:`ghost`,size:`sm`,disabled:a.isPending,onClick:()=>a.mutate(void 0,{onError:e=>T(e.message,{tone:`danger`})}),children:`Check again`}):null,t===`disconnected`&&e.browserLogin?(0,J.jsx)(z,{provider:e.id,label:e.displayName}):null,t===`disconnected`&&e.terminalLogin!==!1?(0,J.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,disabled:o.isPending,onClick:()=>o.mutate(e.id),children:r?`Opening…`:`Connect`}):null,i===void 0?null:(0,J.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,disabled:s.isPending,onClick:()=>s.mutate({provider:e.id,authFailureId:i},{onSuccess:()=>T(`${e.displayName} can be tried again.`),onError:e=>T(e.message,{tone:`danger`})}),children:`Try again`})]})}function se({manual:e,provider:t,connected:n,onCopy:r}){return e===null||e.provider!==t||n?null:(0,J.jsxs)(`div`,{role:`region`,"aria-label":`${e.label} manual sign-in`,className:`rounded-md border border-pending/40 bg-pending/5 px-3.5 py-3`,children:[(0,J.jsx)(`p`,{className:`text-[13px] text-foreground`,children:e.message}),(0,J.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(`code`,{className:`min-w-0 flex-1 overflow-x-auto rounded-sm bg-muted px-2 py-1.5 text-xs`,children:e.command}),(0,J.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void r(e.command),children:`Copy command`})]})]})}function ce(){let e=u(),t=s(),n=v(),r=f(),o=x(),[c,l]=(0,q.useState)(null),d=(0,q.useRef)(Promise.resolve()),h=(0,q.useRef)({}),_=(0,q.useRef)({}),y=(0,q.useRef)(t.data);(0,q.useEffect)(()=>{c&&S(t.data,c.provider)?.status===`connected`&&l(null)},[c,t.data]),(0,q.useEffect)(()=>{if(t.data){if(Object.values(_.current).every(e=>e===0)||!y.current){y.current=t.data;return}y.current={providers:t.data.providers.map(e=>({...e,enabled:(_.current[e.provider]??0)>0?S(y.current,e.provider)?.enabled??e.enabled:e.enabled}))}}},[t.data]);let C=(0,q.useCallback)((e,t,n)=>{let r=i.providerStatus,a=o.getQueryData(r);if(!a)return;y.current||=a;let s=X(a,e,t);_.current[e]=(_.current[e]??0)+1,o.setQueryData(r,s);let c=(h.current[e]??0)+1;h.current[e]=c,d.current=d.current.then(async()=>{try{let i=await E(e,t),a=S(i,e)?.enabled;if(a===void 0)return;if(y.current=X(y.current??i,e,a),c===h.current[e]){let t=o.getQueryData(r);o.setQueryData(r,t?X(t,e,a):i),n()}}catch(t){if(c===h.current[e]){let n=S(y.current,e)?.enabled,i=o.getQueryData(r);i&&n!==void 0?o.setQueryData(r,X(i,e,n)):y.current?o.setQueryData(r,y.current):o.removeQueries({queryKey:r,exact:!0}),T(t instanceof Error?t.message:String(t),{tone:`danger`})}}finally{_.current[e]=(_.current[e]??0)-1}})},[o]),w=g({mutationFn:e=>ee(e),onSuccess:async(e,t)=>{l(null),T(e.opened?`Finish signing in in the terminal, then check again.`:`Provider is already connected.`),await o.invalidateQueries({queryKey:i.providerStatus}),await p(o,t,`none`)},onError:(t,n)=>{if(t instanceof b&&t.command){let r=m(e.data,n);l({provider:n,label:r,message:t.message,command:t.command});return}T(t.message,{tone:`danger`})}}),D=async e=>{try{await navigator.clipboard.writeText(e),T(`Command copied`)}catch{T(`Could not copy the command`,{tone:`danger`})}};return(0,J.jsxs)(`section`,{id:`providers`,"data-slot":`provider-settings`,className:`scroll-mt-20`,children:[(0,J.jsxs)(`div`,{className:`mb-2`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Providers`}),(0,J.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Connect the coding agents available on this computer.`})]}),t.isError?(0,J.jsxs)(`div`,{role:`alert`,className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border border-danger/30 bg-danger/5 px-3 py-2.5`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`p`,{className:`text-[13px] font-medium text-foreground`,children:`Provider status could not be loaded`}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.error.message})]}),(0,J.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,disabled:t.isFetching,onClick:()=>void t.refetch(),children:`Retry`})]}):null,(0,J.jsx)(`div`,{className:`flex flex-col gap-2`,children:a(e.data).map(e=>{let i=S(t.data,e.id),a=i?.status,o=re(a,t.isPending),s=w.isPending&&w.variables===e.id,l=i?.authFailureId;return(0,J.jsxs)(q.Fragment,{children:[(0,J.jsxs)(`div`,{"data-slot":`provider-card`,"data-provider":e.id,className:`rounded-md border border-border bg-card px-3.5 py-3`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`h3`,{className:`text-[13px] font-semibold text-foreground`,children:e.displayName}),(0,J.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,J.jsx)(A,{tone:o.tone,pulse:t.isPending}),(0,J.jsx)(`span`,{children:o.label}),i?.enabled===!1?(0,J.jsx)(`span`,{children:`Disabled`}):null]}),(0,J.jsx)(ae,{provider:e,state:a,current:i,statusIsError:t.isError})]}),(0,J.jsx)(oe,{provider:e,state:a,current:i,isConnecting:s,incidentId:l,refresh:n,connect:w,retry:r,queueToggle:C})]}),l===void 0?null:(0,J.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`Use this after completing the provider sign-in flow. Squawk cannot validate the credential without a task/model request; it will verify it on the next task.`})]}),(0,J.jsx)(se,{manual:c,provider:e.id,connected:a===`connected`,onCopy:D})]},e.id)})})]})}var Z=2e4;function le(){let e=d(),t=u(),n=h(l(t.data)),r=s();return e.isPending?(0,J.jsx)(`p`,{"data-slot":`agents-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading agent settings…`}):e.isError?(0,J.jsx)(M,{icon:(0,J.jsx)(D,{}),tone:`danger`,title:`Agent settings did not load`,subtitle:e.error.message,heading:`h2`}):(0,J.jsx)(ue,{config:e.data,catalogs:n,providerStatus:r,runners:t.data})}function ue({config:e,catalogs:t,providerStatus:n,runners:r}){let i=o(),s=x(),l=g({mutationFn:e=>C(e),onSuccess:e=>{s.setQueryData(c.config,e),s.invalidateQueries({queryKey:c.health}),s.invalidateQueries({queryKey:c.repo})},onError:e=>T(e.message,{tone:`danger`})}),[u,d]=K(e.systemPrompt??``),f=u.trim(),p=f===(e.systemPrompt??``),m=f.length>Z;G({dirty:!p,invalid:m,busy:l.isPending,save:()=>l.mutateAsync({systemPrompt:f===``?null:f}),discard:()=>d(e.systemPrompt??``)});let h=H(),_=H(),v=H(),y=H(),b=H(),S=(e,t)=>l.mutate(e,{onSuccess:t});return(0,J.jsxs)(`div`,{"data-slot":`agent-defaults-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:[(0,J.jsx)(Q,{defaultRunner:e.defaultRunner,providerStatus:n,saving:l.isPending,saved:h.saved,onSaved:h.flash,onPick:e=>S({defaultRunner:e},h.flash)}),(0,J.jsx)(W,{wide:!0,title:`Default model`,hint:e.modelsLocked?`Models are locked to the defaults configured in the native coding-agent settings.`:`The model preselected in the composer for each runner. Runner default lets the runner decide per task.`,saved:e.modelsLocked?void 0:_.saved,children:(0,J.jsx)(`div`,{"data-slot":`agents-model-rows`,className:`flex flex-col gap-2.5`,children:a(r).map(i=>{let{providerConnected:a,providerReason:o}=ne(n,i.id),s=t[i.id],c=N(i.id,r,s),u=I(i.id,r,s?.data,[e.defaultModels[i.id]]),d=e.defaultModels[i.id]??``,f=u.find(e=>e.id===d)?.label??d??`Runner default`;return(0,J.jsxs)(`label`,{className:`settings-option-row`,children:[(0,J.jsx)(`div`,{children:(0,J.jsx)(`h3`,{children:i.displayName})}),e.modelsLocked?(0,J.jsx)(`output`,{"aria-label":`Default model for ${i.pickerLabel}`,"data-slot":`agents-model`,"data-runner":i.id,title:`Model selection is locked to native coding-agent settings.`,className:`block rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs`,children:f}):(0,J.jsx)(L,{"aria-label":`Default model for ${i.pickerLabel}`,"data-slot":`agents-model`,"data-runner":i.id,value:d,title:o??i.pickerDescription,disabled:l.isPending||!a,onValueChange:e=>S({defaultModels:{[i.id]:e||null}},_.flash),className:`settings-select max-w-full bg-card`,options:[...u.map(e=>({value:e.id,label:e.label})),...c?[{value:F,label:c,disabled:!0}]:[]]})]},i.id)})})}),(0,J.jsxs)(W,{wide:!0,title:`System prompt`,hint:`Extra instructions for every run in this project.`,reportsDirty:!0,children:[(0,J.jsx)(te,{"aria-label":`System prompt`,"data-slot":`agents-system-prompt`,value:u,onChange:e=>d(e.target.value),placeholder:`Extra rules for every agent run — conventions, tone, review requirements…`,className:`min-h-48 w-full`}),(0,J.jsx)(de,{length:f.length,overLimit:m})]}),(0,J.jsxs)(`section`,{"data-slot":`agents-task-runs`,className:`settings-field flex flex-col gap-5`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Task runs`}),(0,J.jsx)($,{title:`Live title updates`,hint:`Refresh a task's short title through the namer model as the run progresses. A manual rename always wins and stops updates for that task.`,saved:v.saved,children:(0,J.jsxs)(`label`,{className:`flex w-fit items-center gap-3`,children:[(0,J.jsx)(k,{"aria-label":`Live title updates`,"data-slot":`agents-live-title-updates`,checked:e.liveTitleUpdates??!0,disabled:l.isPending,onCheckedChange:e=>S({liveTitleUpdates:e},v.flash)}),(0,J.jsxs)(`span`,{className:`text-[13px] text-muted-foreground`,children:[e.liveTitleUpdates??!0?`On`:`Off`,e.liveTitleUpdates===null&&` (default)`]})]})}),(0,J.jsx)($,{title:`Review changes before finishing`,hint:`When on, a task with changes pauses so you can Accept, Send back, or open a Draft PR. Autonomous tasks always skip this and finish on their own. Default: off — tasks finish without asking.`,saved:y.saved,children:(0,J.jsxs)(`label`,{className:`flex w-fit items-center gap-3`,children:[(0,J.jsx)(k,{"aria-label":`Review changes before finishing`,"data-slot":`agents-review-gate`,checked:e.reviewGate??!1,disabled:l.isPending,onCheckedChange:e=>S({reviewGate:e},y.flash)}),(0,J.jsxs)(`span`,{className:`text-[13px] text-muted-foreground`,children:[e.reviewGate??!1?`On`:`Off`,e.reviewGate===null&&` (default)`]})]})}),(0,J.jsx)($,{title:`Base branch`,hint:`New task worktrees branch from this and draft PRs target it. Also settable from the Git view.`,saved:b.saved,children:i.data?.info?(0,J.jsx)(L,{"aria-label":`Base branch`,"data-slot":`agents-base-branch`,value:e.baseBranch??``,disabled:l.isPending,onValueChange:e=>S({baseBranch:e||null},b.flash),className:`settings-select max-w-full bg-card`,options:[{value:``,label:`follow checked-out branch (default)`},...i.data.branches.map(e=>({value:e,label:e}))]}):(0,J.jsx)(`p`,{"data-slot":`agents-base-branch-unavailable`,className:`text-[13px] text-soft-foreground`,children:i.isPending?`Loading branches…`:`Not a git repository — tasks run in place, no branching.`})})]}),(0,J.jsxs)(`details`,{className:`settings-disclosure`,children:[(0,J.jsx)(`summary`,{children:`Provider connections`}),(0,J.jsx)(ce,{})]})]})}function Q({defaultRunner:e,providerStatus:t,saving:n,saved:i,onSaved:a,onPick:s}){let c=_(),l=y(),d=w(),f=o(),p=r(),m=d.projectId??`default`,h=f.data?.info?.root,g=j(c.data,d.projectId,h),v=u().data,b=B(c.data?.profiles??[],v),x=R(b,v);return(0,J.jsxs)(W,{title:`Default runner`,hint:`Project defaults. A task can override these choices.`,saved:i,children:[(0,J.jsx)(V,{rows:b,runner:e,accountFor:e=>g?.[e]??null,providerStatus:t,disabled:n,accountDisabled:p.isPending||l.data===void 0,onPick:(t,n,r)=>{t!==e&&s(t),r&&p.mutate({projectId:m,provider:t,profileId:n},{onSuccess:a,onError:e=>T(e.message,{tone:`danger`})})}}),!t.isPending&&!t.isError&&S(t.data,e)?.enabled===!1?(0,J.jsx)(`p`,{"data-slot":`agents-runner-disabled`,className:`text-[13px] text-muted-foreground`,children:`This provider is disabled. Enable it above or choose another provider.`}):null,x?(0,J.jsx)(`p`,{className:`max-w-md text-[13px] text-muted-foreground`,children:`The account is personal and never committed. Tasks already started under another account can’t be resumed here — their sessions live in that account’s folder.`}):null]})}function $({title:e,hint:t,saved:n,children:r}){return(0,J.jsxs)(`section`,{className:`settings-option-row`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h3`,{children:e}),(0,J.jsxs)(`p`,{children:[t,` `,(0,J.jsx)(U,{saved:n})]})]}),r]})}function de({length:e,overLimit:t}){return(0,J.jsx)(J.Fragment,{children:t?(0,J.jsxs)(`p`,{"data-slot":`agents-prompt-limit`,className:`text-xs text-danger`,children:[e.toLocaleString(),` characters — the limit is `,Z.toLocaleString(),`.`]}):(0,J.jsx)(`p`,{"data-slot":`agents-prompt-help`,className:`text-xs text-muted-foreground`,children:`Leave empty and save to clear. Applied to new runs only.`})})}export{le as AgentDefaultsSection};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./react-runtime-CCIEwYL0.js";import{xt as t}from"./queries-D9mg7sFY.js";import{o as n}from"./dist-CCX8mhHc.js";import{t as r}from"./createLucideIcon-BHp8sXmF.js";import{n as i,t as a}from"./moon-CRE9nU5R.js";import{t as o}from"./button-BV_AiLj2.js";import{En as s,_t as c,rr as l}from"./index-DKnr4QWH.js";import{n as u}from"./save-cue-CpHgT93o.js";import{n as d}from"./settings-field-AyinSFR_.js";var f=r(`sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),p=e(),m=[{value:`system`,label:`System`,icon:i},{value:`light`,label:`Light`,icon:f},{value:`dark`,label:`Dark`,icon:a}],h=[{value:`cezarion`,label:`Squawk`,swatch:`var(--accent-strong)`}],g=[{value:`comfortable`,label:`Comfortable`},{value:`compact`,label:`Compact`},{value:`ultra`,label:`Ultra-compact`}],_=[{value:`narrow`,label:`Narrow`},{value:`wide`,label:`Wide`}];function v({slot:e,label:t,value:r,options:i,onChange:a}){return(0,p.jsx)(`div`,{role:`radiogroup`,"aria-label":t,"data-slot":e,className:`inline-flex w-fit gap-0.5 rounded-lg border border-border bg-muted/60 p-1 max-md:max-w-full max-md:flex-wrap`,children:i.map(e=>{let t=e.value===r;return(0,p.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,"data-value":e.value,onClick:()=>a(e.value),className:n(`flex min-h-11 items-center gap-2 whitespace-nowrap rounded-md border border-transparent px-3 py-1.5 text-[13px] font-medium transition-colors`,t?`border border-border bg-card text-foreground shadow-xs`:`text-muted-foreground hover:text-foreground`),children:[e.icon?(0,p.jsx)(e.icon,{"aria-hidden":`true`,className:`size-3.5`}):null,e.swatch?(0,p.jsx)(`span`,{"aria-hidden":`true`,className:`size-3 rounded-full border border-border`,style:{background:e.swatch}}):null,e.label]},e.value)})})}function y(){let e=t(),{order:n,canReorder:r,reset:i}=s();return!((e.data?.projects.length??0)>1)||n.length===0?null:(0,p.jsx)(d,{title:`Project order`,hint:`The project rail is in the order you dragged it into. Reset puts it back in the order the projects were added. Saved with your workspace, so every browser sees it.`,children:(0,p.jsx)(o,{type:`button`,variant:`outline`,size:`sm`,"data-slot":`appearance-project-order-reset`,disabled:!r,onClick:i,className:`w-fit`,children:`Reset order`})})}function b(){let{theme:e,setTheme:t}=l(),{accent:n,density:r,width:i,setAccent:a,setDensity:o,setWidth:s}=c(),f=u(),b=u(),x=u(),S=u(),C=e=>t=>{t&&e()};return(0,p.jsxs)(`div`,{"data-slot":`appearance-section`,className:`flex w-full flex-col gap-7 rounded-lg border border-border bg-card p-5`,children:[(0,p.jsx)(d,{title:`Theme`,hint:`System follows your OS preference. Applies to this browser.`,saved:f.saved,children:(0,p.jsx)(v,{slot:`appearance-theme`,label:`Theme`,value:e,options:m,onChange:e=>{t(e)&&f.flash()}})}),h.length>1?(0,p.jsx)(d,{title:`Accent`,hint:`The cockpit brand accent. Saved with your workspace appearance.`,saved:b.saved,children:(0,p.jsx)(v,{slot:`appearance-accent`,label:`Accent`,value:n,options:h,onChange:e=>void a(e).then(C(b.flash))})}):null,(0,p.jsx)(d,{title:`Density`,hint:`Compact tightens spacing across the cockpit — text stays the same size.`,saved:x.saved,children:(0,p.jsx)(v,{slot:`appearance-density`,label:`Density`,value:r,options:g,onChange:e=>void o(e).then(C(x.flash))})}),(0,p.jsx)(d,{title:`Reading width`,hint:`Wide lets a task's session and commits use more of the screen. Narrow keeps a comfortable reading column. The Changes tab is always full-width.`,saved:S.saved,children:(0,p.jsx)(v,{slot:`appearance-width`,label:`Reading width`,value:i,options:_,onChange:e=>void s(e).then(C(S.flash))})}),(0,p.jsx)(y,{}),(0,p.jsxs)(`div`,{className:`settings-appearance-preview settings-readout`,children:[(0,p.jsx)(`span`,{className:`text-[12px] text-soft-foreground`,children:`PREVIEW`}),(0,p.jsx)(`p`,{className:`mt-3 text-base`,children:`Review finalization retries`}),(0,p.jsxs)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:[`Needs you · Squawk · Task `,`#`,`227`]}),(0,p.jsx)(`span`,{className:`mt-3 inline-flex rounded-md border border-border bg-card px-4 py-3 text-xs text-foreground shadow-xs`,children:`Open task`})]}),(0,p.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:`Changes apply immediately. Theme is browser-local; density and reading width are saved with your workspace.`})]})}export{b as AppearanceSection};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Ft as r,Ht as i,Vt as a,g as o,un as s}from"./queries-D9mg7sFY.js";import{Fi as c,I as l,un as u}from"./toaster-2ud_VdfV.js";import{t as d}from"./option-select-C7kknSij.js";import{n as f,t as p}from"./save-cue-CpHgT93o.js";var m=e(t(),1),h=n();function g(){let e=o();return e.isPending?(0,h.jsx)(`p`,{role:`status`,children:`Loading task settings…`}):e.isError?(0,h.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[`Task settings did not load: `,e.error.message]}):(0,h.jsx)(v,{config:e.data,scope:`project`})}function _(){let e=r();return e.isPending?(0,h.jsx)(`p`,{role:`status`,className:`text-sm`,children:`Loading task settings…`}):e.isError?(0,h.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[`Task settings did not load: `,e.error.message]}):(0,h.jsx)(v,{config:e.data,scope:`global`})}function v({config:e,scope:t}){let n=(0,m.useId)(),r=c(),o=f(),g=s({mutationFn:async({archiveOnMerge:e,projectKey:n})=>t===`project`?l({archiveOnMerge:e},n[0]):u({archiveOnMerge:e}),onSuccess:(e,{projectKey:n})=>{t===`project`?r.setQueryData(n,e):(r.setQueryData(i.config,e),r.invalidateQueries({predicate:e=>e.queryKey.at(-1)===`config`&&e.queryKey!==i.config})),o.flash()}});return(0,h.jsxs)(`section`,{"data-slot":`archive-on-merge-field`,className:`settings-field flex min-w-0 flex-col gap-3`,children:[(0,h.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,h.jsx)(`label`,{htmlFor:n,className:`text-sm font-semibold text-foreground`,children:`Archive tasks after PRs merge`}),(0,h.jsxs)(`p`,{id:`${n}-hint`,className:`text-[13px] text-muted-foreground`,children:[`Automatically archive a settled task and its workers once all their associated pull requests merge. History stays available in Archived. `,(0,h.jsx)(p,{saved:o.saved})]})]}),(0,h.jsx)(d,{id:n,"aria-describedby":`${n}-hint ${n}-effective`,className:`settings-select w-64 max-w-full bg-background`,value:e.archiveOnMerge===null?`inherit`:e.archiveOnMerge?`enabled`:`disabled`,disabled:g.isPending,onValueChange:e=>g.mutate({archiveOnMerge:e===`inherit`?null:e===`enabled`,projectKey:a.config}),options:[{value:`inherit`,label:t===`project`?`Inherit global setting`:`Use default`},{value:`enabled`,label:`Enabled`},{value:`disabled`,label:`Disabled`}]}),(0,h.jsxs)(`p`,{id:`${n}-effective`,className:`text-[13px] text-muted-foreground`,children:[`Currently `,e.effectiveArchiveOnMerge?`enabled`:`disabled`,` · `,e.archiveOnMergeSource,` setting.`]}),(0,h.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Unarchive restores the task. It stays visible until a later associated PR merges.`}),g.isPending?(0,h.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Saving…`}):null,g.isError?(0,h.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[`Could not save: `,g.error.message]}):null]})}export{_ as n,g as t};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{N as r,en as i,qt as a}from"./queries-D9mg7sFY.js";import{m as o}from"./host-context-DDbYAKpm.js";import{Ur as s}from"./toaster-2ud_VdfV.js";import{m as c,n as l,p as u}from"./chunk-KS7C4IRE-BdLLx37K.js";import{o as d}from"./dist-CCX8mhHc.js";import{J as f,Q as p,V as m,c as h,d as g,f as _,mt as v,pt as y,st as b,u as x,y as S}from"./design-icons-QbNMZniQ.js";import{t as C}from"./createLucideIcon-BHp8sXmF.js";import{t as w}from"./check-OP-CVgZG.js";import{t as T}from"./chevron-right-BENZ-1ZN.js";import{n as ee}from"./smartphone-Lr8Ug2z_.js";import{t as E}from"./loader-circle-CPBhhDbB.js";import{t as te}from"./message-square-B-MD-8rD.js";import{n as D,t as ne}from"./tool-display-CTbToGmi.js";import{t as O}from"./square-terminal-B6RYYieR.js";import{t as k}from"./button-BV_AiLj2.js";import{n as A,r as j,t as M}from"./collapsible-D5i3hm2L.js";import{t as N}from"./project-router-CwD1firw.js";import{a as re,c as ie,i as ae,l as oe,o as se,s as ce,t as le}from"./report-selection-Y2F9NTAs.js";import{r as ue}from"./html-report-BX3msvci.js";import{S as de,pr as fe,un as pe,vr as P,wn as me,wr as he,x as ge}from"./index-DKnr4QWH.js";import{t as _e}from"./zoomable-image-CULOtYYp.js";import{t as F}from"./textarea-BGp28xFr.js";import{t as I}from"./markdown-B4JilOS6.js";import{t as ve}from"./task-file-scope-DIKRE_b-.js";import{t as ye}from"./report-title-D4Mbu2Er.js";var be=C(`anchor`,[[`path`,{d:`M12 6v16`,key:`nqf5sj`}],[`path`,{d:`m19 13 2-1a9 9 0 0 1-18 0l2 1`,key:`y7qv08`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}],[`circle`,{cx:`12`,cy:`4`,r:`2`,key:`muu5ef`}]]),xe=C(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),Se=C(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),Ce=C(`locate-fixed`,[[`line`,{x1:`2`,x2:`5`,y1:`12`,y2:`12`,key:`bvdh0s`}],[`line`,{x1:`19`,x2:`22`,y1:`12`,y2:`12`,key:`1tbv5k`}],[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`5`,key:`11lu5j`}],[`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`,key:`x3vr5v`}],[`circle`,{cx:`12`,cy:`12`,r:`7`,key:`fim9np`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),L=C(`message-square-text`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),we=C(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),R=e(t(),1),z=n();function Te(e,t){if(e.length===1)return[t.replace(RegExp(`^${Ee(e[0].header)}: ?`),``)];let n=t,r=[];for(let[t,i]of e.entries()){let a=`${i.header}: `;if(!n.startsWith(a))return;n=n.slice(a.length);let o=e[t+1],s=o?n.indexOf(`\n${o.header}: `):n.length;if(s<0)return;r.push(n.slice(0,s)),n=n.slice(s+1)}return r}function Ee(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function De(e,t){if(t===void 0)return[];let n=e.options??[];if(!e.multiSelect)return n.filter(e=>e.label===t).map(e=>e.label);let r=[];function i(e,t){for(let{label:a}of n)t.includes(a)||(e===a?r.push([...t,a]):e.startsWith(`${a}, `)&&i(e.slice(a.length+2),[...t,a]))}return i(t,[]),r.length===1?r[0]:[]}var Oe=`
|
|
2
|
-
|
|
3
|
-
Additional comments:
|
|
4
|
-
`;function ke(e){let t=e.indexOf(Oe);if(t<0)return{body:e,comment:void 0};let n=e.slice(t+23).trim();return{body:e.slice(0,t),comment:n||void 0}}function Ae({ask:e}){let t=e.answer===void 0?void 0:ke(e.answer),n=t===void 0?void 0:Te(e.questions,t.body);return(0,z.jsxs)(`div`,{"data-slot":`ask-answers`,className:`flex flex-col gap-4 text-sm`,children:[e.questions.map((t,r)=>{let i=n?.[r],a=De(t,i),o=i!==void 0&&a.length===0;return(0,z.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":t.question,children:[(0,z.jsxs)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:[t.header,` · Question `,r+1,` of `,e.questions.length]}),(0,z.jsx)(`p`,{className:`break-words font-semibold`,children:t.question}),t.options?(0,z.jsxs)(`ul`,{className:`flex list-none flex-col gap-1.5`,children:[t.options.map(e=>(0,z.jsxs)(`li`,{"data-selected":a.includes(e.label),className:`flex items-start gap-2 rounded-md border border-border px-3 py-2 data-[selected=true]:border-message-user-border data-[selected=true]:bg-message-user-accent/5`,children:[(0,z.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-message-user-accent`,children:a.includes(e.label)?`✓`:`○`}),(0,z.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[(0,z.jsx)(`span`,{className:`font-medium`,children:e.label}),e.description?(0,z.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:e.description}):null]}),a.includes(e.label)?(0,z.jsx)(`span`,{className:`shrink-0 text-xs text-message-user-accent`,children:`Selected`}):null]},e.label)),(0,z.jsxs)(`li`,{"data-selected":o,className:`rounded-md border border-border px-3 py-2 data-[selected=true]:border-message-user-border`,children:[(0,z.jsxs)(`p`,{className:`flex items-start gap-2 font-medium`,children:[(0,z.jsx)(`span`,{"aria-hidden":!0,className:`text-message-user-accent`,children:o?`✓`:`○`}),(0,z.jsx)(`span`,{className:`flex-1`,children:`Other`}),o?(0,z.jsx)(`span`,{className:`text-xs text-message-user-accent`,children:`Selected`}):null]}),o?(0,z.jsx)(B,{text:i}):null]})]}):i===void 0?null:(0,z.jsx)(B,{text:i})]},t.id??r)}),n&&t?.comment?(0,z.jsxs)(`section`,{className:`flex flex-col gap-1`,"aria-label":`Additional comments`,children:[(0,z.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:`Additional comments`}),(0,z.jsx)(B,{text:t.comment})]}):null,!n&&e.answer!==void 0?(0,z.jsx)(B,{text:e.answer}):null]})}function B({text:e}){return(0,z.jsx)(`blockquote`,{className:`[margin-block-start:0.5rem] border-s-2 border-message-user-accent ps-3 break-words whitespace-pre-wrap`,children:e})}function V(e,t,n){let r=n[e];return r===void 0?(t[e]?.length??0)>0:r.trim().length>0}function je(e,t,n){let r=n[e]?.trim();if(r)return r;let i=t[e]??[];return i.length>0?i.join(`, `):`Not answered yet`}function Me({stepped:e,mode:t,onModeChange:n,showModeSwitch:r,stepLabel:i,hasSheetContext:a,showContextButtonRef:o,onOpenContext:s,onShowOrigin:c,onFold:l}){let u=l!==void 0,f=a?(0,z.jsxs)(k,{ref:o,type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-show-context`,"aria-label":u?`Show context`:void 0,className:d(`px-2 text-xs font-medium text-link-foreground underline underline-offset-4`,u&&`ms-auto`),onClick:s,children:[(0,z.jsx)(P,{"aria-hidden":`true`,className:`size-3.5`}),u?`Context`:`Show context`]}):c&&u?(0,z.jsx)(k,{type:`button`,variant:`ghost`,size:`icon-sm`,"data-slot":`ask-show-origin`,"aria-label":`Show where it was asked`,title:`Show where it was asked`,className:`ms-auto shrink-0 text-link-foreground`,onClick:c,children:(0,z.jsx)(Ce,{"aria-hidden":`true`,className:`size-4`})}):c?(0,z.jsx)(Ve,{onShowOrigin:c}):null,p=r?(0,z.jsx)(Ne,{mode:t,onModeChange:n}):null;return u?(0,z.jsxs)(`div`,{"data-slot":`ask-header`,"data-compact":`true`,className:`flex shrink-0 items-center gap-1.5 border-b border-border/70 py-1 ps-1.5 pe-1`,children:[(0,z.jsx)(`span`,{className:`sr-only`,children:`Needs your answer`}),e&&t===`options`?(0,z.jsx)(`span`,{"data-slot":`ask-step-indicator`,className:`sr-only`,children:i}):null,p,f,(0,z.jsx)(k,{type:`button`,variant:`ghost`,size:`icon-sm`,"data-slot":`ask-fold`,"aria-label":`Fold the question`,"aria-expanded":`true`,className:d(`shrink-0 text-muted-foreground`,!f&&`ms-auto`),onClick:l,children:(0,z.jsx)(x,{"aria-hidden":`true`,className:`size-4`})})]}):(0,z.jsxs)(`div`,{"data-slot":`ask-header`,className:`flex shrink-0 flex-wrap items-center gap-x-2 gap-y-1 border-b border-border/70 px-2.5 py-1.5 md:px-3 md:py-2`,children:[(0,z.jsx)(`span`,{className:`text-xs font-semibold text-link-foreground`,children:`Needs your answer`}),e&&t===`options`?(0,z.jsx)(`span`,{"data-slot":`ask-step-indicator`,className:`rounded-full bg-accent-strong/15 px-2 py-0.5 text-xs font-semibold text-foreground tabular-nums`,children:i}):null,(0,z.jsxs)(`div`,{className:`ms-auto flex flex-wrap items-center gap-1.5`,children:[f,p]})]})}function Ne({mode:e,onModeChange:t}){return(0,z.jsxs)(`div`,{"data-slot":`ask-mode-switch`,role:`group`,"aria-label":`Reply mode`,className:`inline-flex shrink-0 items-center rounded-lg border border-border bg-card p-0.5`,children:[(0,z.jsx)(`button`,{type:`button`,"data-slot":`ask-mode-options`,"aria-pressed":e===`options`,onClick:()=>t(`options`),className:d(`min-h-11 rounded-md px-2.5 text-xs font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring md:min-h-7`,e===`options`?`bg-accent-strong text-accent-strong-foreground`:`text-foreground hover:bg-muted/60`),children:`Options`}),(0,z.jsx)(`button`,{type:`button`,"data-slot":`ask-mode-reply`,"aria-pressed":e===`reply`,onClick:()=>t(`reply`),className:d(`min-h-11 rounded-md px-2.5 text-xs font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring md:min-h-7`,e===`reply`?`bg-accent-strong text-accent-strong-foreground`:`text-foreground hover:bg-muted/60`),children:`Write a reply`})]})}function Pe({tag:e,text:t,position:n,onOpen:r}){return(0,z.jsxs)(`button`,{type:`button`,"data-slot":`ask-folded-row`,"aria-expanded":`false`,onClick:r,className:`flex min-h-11 w-full min-w-0 items-center gap-2 rounded-xl px-2.5 py-1.5 text-start focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,z.jsx)(`span`,{className:`shrink-0 rounded-md bg-accent-strong px-1.5 py-0.5 text-xs font-semibold uppercase tracking-wide text-accent-strong-foreground`,children:e}),(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-foreground`,children:t}),n===void 0?null:(0,z.jsx)(`span`,{"data-slot":`ask-folded-position`,className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:n}),(0,z.jsx)(`span`,{className:`sr-only`,children:`Open the question`}),(0,z.jsx)(_,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`})]})}function Fe({questions:e,stepIndex:t,selections:n,otherAnswers:r,hasComment:i,onSelectStep:a}){let o=e.length;return(0,z.jsxs)(`div`,{"data-slot":`ask-step-pills`,role:`group`,"aria-label":`Question steps`,className:`hidden shrink-0 flex-wrap items-center gap-1.5 border-b border-border/60 px-3 py-1.5 md:flex`,children:[e.map((e,i)=>{let o=t===i,s=V(i,n,r);return(0,z.jsxs)(`button`,{type:`button`,"aria-current":o?`step`:void 0,onClick:()=>a(i),className:d(`inline-flex min-h-8 items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring`,o?`border-accent-strong bg-accent-strong/15 text-foreground`:s?`border-border bg-card text-foreground hover:border-accent-strong/50`:`border-border bg-transparent text-muted-foreground hover:text-foreground`),children:[(0,z.jsx)(`span`,{className:`tabular-nums text-xs font-semibold`,children:s?(0,z.jsx)(w,{"aria-hidden":`true`,className:`size-3 text-semantic-green`}):`${i+1}.`}),(0,z.jsx)(`span`,{className:`max-w-[140px] truncate`,children:e.header})]},e.id??i)}),(0,z.jsxs)(`button`,{type:`button`,"aria-current":t===o?`step`:void 0,onClick:()=>a(o),className:d(`inline-flex min-h-8 items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring`,t===o?`border-accent-strong bg-accent-strong/15 text-foreground`:i?`border-border bg-card text-foreground hover:border-accent-strong/50`:`border-dashed border-border bg-transparent text-muted-foreground hover:text-foreground`),children:[(0,z.jsx)(L,{"aria-hidden":`true`,className:`size-3`}),(0,z.jsx)(`span`,{children:`Comment`})]})]})}function Ie({questions:e,selections:t,otherAnswers:n,comment:r,disabled:i,onCommentChange:a,onJumpToQuestion:o}){let s=(0,R.useId)();return(0,z.jsxs)(`div`,{"data-slot":`ask-comment-step`,className:`flex flex-col gap-2.5`,children:[(0,z.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-2.5`,children:[(0,z.jsx)(`p`,{className:`mb-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:`Selected answers`}),(0,z.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.map((e,r)=>{let i=V(r,t,n);return(0,z.jsxs)(`li`,{className:`flex items-baseline justify-between gap-2 text-xs`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:()=>o(r),className:`min-h-11 text-start font-medium text-link-foreground underline-offset-4 hover:underline md:min-h-6`,children:e.header}),(0,z.jsx)(`span`,{className:d(`min-w-0 truncate text-end`,i?`text-foreground`:`text-semantic-red`),children:je(r,t,n)})]},e.id??r)})})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{htmlFor:s,className:`mb-1 block text-xs font-medium text-foreground`,children:`Additional comments (optional)`}),(0,z.jsx)(F,{id:s,"data-slot":`ask-additional-comment`,rows:2,value:r,disabled:i,placeholder:`Optional extra notes to send with your selections…`,onChange:e=>a(e.target.value),className:`bg-card text-base md:text-[13px]`})]})]})}function Le({value:e,onValueChange:t,disabled:n,renderFreeTextReply:r}){let i=(0,R.useId)();return r?(0,z.jsx)(`div`,{"data-slot":`ask-free-text`,children:r({value:e,onValueChange:t,disabled:n})}):(0,z.jsxs)(`div`,{"data-slot":`ask-free-text`,className:`flex flex-col gap-2`,children:[(0,z.jsx)(`label`,{htmlFor:i,className:`text-xs font-medium text-foreground`,children:`Reply to the agent`}),(0,z.jsx)(F,{id:i,rows:2,value:e,disabled:n,placeholder:`Write a free-text reply…`,onChange:e=>t(e.target.value),className:`bg-card text-base md:text-[13px]`})]})}function Re({stepIndex:e,questionCount:t,answeredCount:n,allAnswered:r,hasComment:i,resuming:a,disabled:o,onBack:s,onNext:c,onOpenComment:l,onSend:u,questions:f,selections:p,otherAnswers:m,stopControl:h,compact:g=!1}){let _=e===t-1,v=e===t,y=a?`Send answer & reopen`:`Send answer`,b=a?(0,z.jsx)(`span`,{"data-slot":`ask-resume-hint`,className:`text-xs text-soft-foreground`,children:`Reopens the closed session.`}):null,x=!_&&!v?(0,z.jsxs)(k,{type:`button`,variant:`outline`,size:`sm`,className:`px-3`,onClick:c,children:[`Next`,(0,z.jsx)(T,{"aria-hidden":`true`,className:`size-4`})]}):null,S=_?(0,z.jsx)(k,{type:`button`,variant:`outline`,size:`sm`,className:`px-3`,onClick:l,children:i?`Edit comment`:`+ Comment`}):null,C=_||v||r?(0,z.jsx)(k,{type:`button`,size:`sm`,className:`px-3.5`,disabled:o||!r,onClick:u,children:y}):null;return(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e>0?(0,z.jsxs)(k,{type:`button`,variant:`outline`,size:`sm`,className:`px-3`,onClick:s,children:[(0,z.jsx)(he,{"aria-hidden":`true`,className:`size-4`}),`Back`]}):null,(0,z.jsxs)(`span`,{"data-slot":`ask-progress-dots`,"aria-hidden":`true`,className:`flex items-center gap-1.5 px-1 md:hidden`,children:[f.map((t,n)=>{let r=n===e,i=V(n,p,m);return(0,z.jsx)(`span`,{className:d(`size-2 rounded-full motion-safe:transition-colors`,r?`bg-accent-strong`:i?`bg-success`:`bg-border`)},t.id??n)}),(0,z.jsx)(`span`,{className:d(`size-2 rounded-full motion-safe:transition-colors`,v?`bg-accent-strong`:i?`bg-success`:`bg-border/60`)})]}),(0,z.jsxs)(`span`,{"data-slot":`ask-progress-summary`,className:`hidden text-xs text-soft-foreground tabular-nums sm:inline`,children:[n,` of `,t,` answered`]}),g?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{"data-slot":`ask-step-actions`,className:`ms-auto flex items-center gap-2`,children:[x,C]}),S||h?(0,z.jsxs)(`div`,{"data-slot":`ask-secondary-actions`,className:`ms-auto flex items-center gap-2`,children:[S,h]}):null,b]}):(0,z.jsxs)(z.Fragment,{children:[b,(0,z.jsxs)(`div`,{className:`ms-auto flex flex-wrap items-center gap-2`,children:[h,x,S,C]})]})]})}function ze({oneTap:e,hasOtherAnswer:t,allowComment:n,commentOpen:r,hasComment:i,resuming:a,disabled:o,onToggleComment:s,onSend:c,stopControl:l,compact:u=!1}){return(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n?(0,z.jsxs)(k,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-add-comment`,className:`px-2 text-xs text-muted-foreground hover:text-foreground`,onClick:s,children:[(0,z.jsx)(L,{"aria-hidden":`true`,className:`size-3.5`}),r?`Hide comment`:i?`Edit comment`:`+ Add comment`]}):null,u&&!a?null:(0,z.jsx)(`span`,{"data-slot":a?`ask-resume-hint`:`ask-hint`,className:`text-xs text-soft-foreground`,children:a?`Reopens the closed session.`:e?`Tap an option to send.`:`Choose an answer, then send.`}),(0,z.jsxs)(`div`,{className:`ms-auto flex items-center gap-2`,children:[l,!e||t||r||i?(0,z.jsx)(k,{type:`button`,size:`sm`,className:`px-3.5`,disabled:o,onClick:c,children:a?`Send answer & reopen`:`Send answer`}):null]})]})}function Be({blockedBy:e,reason:t,error:n}){return(0,z.jsxs)(z.Fragment,{children:[t?(0,z.jsxs)(`p`,{"data-slot":`ask-blocked-reason`,className:`text-xs text-muted-foreground`,children:[t,` `,e===`provider`?(0,z.jsx)(N,{to:`/settings/agent-defaults#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`}):null]}):null,n?(0,z.jsx)(`p`,{role:`alert`,className:`text-xs text-semantic-red`,children:n}):null]})}function Ve({onShowOrigin:e,className:t}){return(0,z.jsx)(k,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-show-origin`,onClick:e,className:d(`px-2 text-xs font-medium text-link-foreground underline underline-offset-4`,t),children:`Show where it was asked`})}function He({open:e,onOpenChange:t,runId:n,context:r,onShowOrigin:i,returnFocusRef:a}){let o=(0,R.useRef)(!1);return(0,z.jsx)(ae,{open:e,onOpenChange:t,children:(0,z.jsxs)(se,{side:`right`,showCloseButton:!1,"data-slot":`ask-context-sheet`,className:`flex w-full max-w-[540px] flex-col gap-0 p-0 sm:max-w-[540px]`,onCloseAutoFocus:e=>{if(e.preventDefault(),o.current){o.current=!1,i?.();return}a?.current?.focus()},children:[(0,z.jsxs)(ie,{className:`relative shrink-0 border-b border-border px-5 py-4 pr-14`,children:[(0,z.jsx)(oe,{children:`Question context`}),(0,z.jsx)(ce,{children:`Your selections and drafts stay intact while you read.`}),(0,z.jsx)(re,{asChild:!0,children:(0,z.jsx)(k,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Close`,className:`absolute inset-bs-2 end-2`,children:(0,z.jsx)(v,{"aria-hidden":`true`,className:`size-4`})})})]}),(0,z.jsx)(`div`,{"data-slot":`ask-context`,role:`region`,"aria-label":`Context`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain break-words px-5 py-4 text-sm text-foreground`,children:(0,z.jsx)(ve,{runId:n,children:(0,z.jsx)(I,{breaks:!0,children:r})})}),i?(0,z.jsx)(`div`,{className:`flex shrink-0 items-center justify-end border-t border-border px-5 py-3`,children:(0,z.jsx)(k,{type:`button`,variant:`outline`,size:`sm`,"data-slot":`ask-show-origin`,onClick:()=>{o.current=!0,t(!1),i()},children:`Show where it was asked`})}):null]})})}function Ue(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var We=/^[A-Za-z0-9_./:=+,@%-]+$/;function Ge(e){return e.replaceAll(`'`,`'\\''`)}function Ke(e){return e===``?`''`:We.test(e)?e:`\u0027${Ge(e)}\u0027`}function qe(e){if(!Ue(e))return;let t=e.command;if(typeof t==`string`&&t!==``)return t;if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`);if(e.length>0)return e.map(Ke).join(` `)}}function Je(e){let t="`".repeat(3),n=`~`.repeat(3);return e.split(t).filter((e,t)=>t%2==0).join(` `).split(n).filter((e,t)=>t%2==0).join(` `).split("`").filter((e,t)=>t%2==0).join(` `)}function Ye(e){return e.replace(/!\[(?:\\.|[^\]\\])*\]\([^)\s]*(?:\s+"[^"]*")?\)/g,` `)}function Xe(e){return e.replace(/(?<!\\)(?:\*\*|\*|__|~~|`)/g,``).replace(/\\([!"#$%&'()*+,\-./:;<=>?@[\]\\^_`{|}~])/g,`$1`)}function H(e){let t=e.trim();return t===``||t.startsWith(`#`)||/^(https?:|mailto:)/i.test(t)?!0:!/^[a-z][a-z0-9+.-]*:/i.test(t)}function Ze(e){let t=Je(Ye(e)),n=new Map;for(let e of t.matchAll(/^\s*\[([^\]]+)\]:\s*(\S+)/gm))H(e[2])&&n.set(e[1].toLowerCase(),e[2]);let r=t.replace(/^\s*\[[^\]]+\]:\s*\S+.*$/gm,` `),i=[];for(let e of r.matchAll(/(?<!!)\[((?:\\.|[^\]\\])+)\](?:\(((?:[^()\s]|\([^)]*\))+)(?:\s+"[^"]*")?\)|\[([^\]]*)\])|<(https?:\/\/[^>\s]+)>|(https?:\/\/[^\s<]+)/g)){if(e[2]){H(e[2])&&i.push({label:Xe(e[1]),href:e[2]});continue}if(e[1]!==void 0&&e[3]!==void 0){let t=(e[3].length>0?e[3]:e[1]).toLowerCase(),r=n.get(t);r&&i.push({label:Xe(e[1]),href:r});continue}let t=(e[4]??e[5])?.replace(/[.,;:!?]+$/,``);t&&H(t)&&i.push({label:t,href:t})}return i}var Qe=(0,R.createContext)(void 0),U=(0,R.createContext)(void 0);function $e(e,t){let n=new Map;for(let r of Ze(e)){let e=de(r.href,t);if(!e)continue;let i=new URL(e,`https://cockpit.invalid`),a=/^\/p\/([^/]+)\/tasks\/([^/]+)\/report$/.exec(i.pathname),o=/^\/tasks\/([^/]+)\/report$/.exec(i.pathname),s=i.searchParams.get(`artifact`);if(!s||(a?decodeURIComponent(a[1])!==t.projectId:!o))continue;let c=decodeURIComponent(a?a[2]:o[1]),l=`${c}:${s}`;n.has(l)||n.set(l,{runId:c,artifactId:s,label:r.label,href:e})}return[...n.values()]}function W(e,t){return`report-card-${encodeURIComponent(e)}-${t}`}function et({text:e,messageKey:t}){let n=(0,R.useContext)(ge),r=(0,R.useContext)(U),i=t??r;if(!n||i===void 0)return null;let a=$e(e,n);return a.length===0?null:(0,z.jsx)(`div`,{"data-slot":`report-cards`,className:`flex flex-col gap-3 [margin-block-start:1rem]`,children:a.map(e=>(0,z.jsx)(tt,{reference:e,messageKey:i},`${e.runId}:${e.artifactId}`))})}function tt({reference:e,messageKey:t}){let{artifactId:n,runId:i,label:a,href:o}=e,s=(0,R.useContext)(Qe),d=(0,R.useContext)(le);(0,R.useLayoutEffect)(()=>d?.register(n,i),[d,n,i]);let f=r(i,n),p=u(),m=c();if(f.isError)return(0,z.jsx)(l,{id:W(t,n),"data-slot":`report-card-fallback`,to:o,state:{readerFrom:p.pathname+p.search},children:a});let h=f.data?.artifact;if(h&&!ue(h.name))return null;let g=new URLSearchParams(p.search);g.set(`report`,n),g.set(`card`,t);let _=new URLSearchParams(p.search).has(`report`)?p.state:null,v=new URLSearchParams(p.search);v.delete(`report`),v.delete(`card`);let y=`${p.pathname}${v.size?`?${v}`:``}`,b=window.navigation,x={reportCardEntry:!0,reportReturnTo:_?.reportReturnTo??y,reportReturnKey:_?.reportReturnKey??b?.currentEntry?.key,reportScrollTop:_?.reportScrollTop},S={pathname:p.pathname,search:`?${g}`,hash:new URL(o,`https://cockpit.invalid`).hash};return(0,z.jsxs)(`section`,{"data-slot":`report-card`,"data-artifact-id":n,"data-report-run-id":i,"aria-busy":f.isPending,className:`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-card p-3 text-foreground`,children:[(0,z.jsx)(`h3`,{className:`break-words text-sm font-medium`,children:h?ye(h):a}),(0,z.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`HTML report`}),(0,z.jsx)(l,{id:W(t,n),to:S,state:x,onClick:e=>{if(e.button!==0||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault(),s?.(t);let n=x.reportScrollTop??(document.querySelector(`[data-slot="thread-transcript"]`)??document.querySelector(`[data-slot="main"]`))?.scrollTop;m(S,{state:{...x,reportScrollTop:n}})},className:`inline-flex min-h-11 min-w-11 items-center self-start rounded-md border border-border px-3 text-sm active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring ${f.isPending?`text-soft-foreground`:`text-accent-text`}`,children:`Read report`})]})}var nt={message:!0,reasoning:!0,tool:!0,hook:!0};function rt(e){return Object.hasOwn(nt,e)&&nt[e]}var G=e=>e.kind===`tool`,it=e=>e.kind===`conversation`,at=e=>(e.toolKind===`read`||e.toolKind===`search`)&&e.status===`completed`,ot=(e,t,n)=>`${e} ${e===1?t:n}`;function st(e,t){let n=[];return e>0&&n.push(ot(e,`file`,`files`)),t>0&&n.push(ot(t,`search`,`searches`)),`Explored ${n.join(` · `)}`}function ct(e){return`${e} earlier tool call${e===1?``:`s`}`}var lt=[`Web search`,`Ran`,`Edit`,`Write`,`Read`,`Search`,`Fetch`,`Task:`];function ut(e){for(let t of lt)if(e.startsWith(`${t} `)&&e.length>t.length+1)return{verb:t===`Task:`?`Task`:t,detail:e.slice(t.length+1)};return{verb:e}}var dt=new WeakMap;function ft(e){let t=dt.get(e);if(t)return t;let n=pt(e);return dt.set(e,n),n}function pt(e){let t=e.filter(e=>!(e.kind===`tool`&&e.toolKind===`plan`)&&!((e.kind===`reasoning`||e.kind===`message`)&&e.text.trim()===``)),n=new Set(t.filter(G).map(e=>e.id)),r=new Map,i=[];for(let e of t){let t=rt(e.kind)&&`parentItemId`in e&&e.parentItemId!==void 0&&e.parentItemId!==e.id&&n.has(e.parentItemId)?e.parentItemId:void 0;if(t===void 0)i.push(e);else{let n=r.get(t);n?n.push(e):r.set(t,[e])}}let a=[],o=[],s=()=>{if(o.length>=2){let e=o.filter(e=>e.toolKind===`read`).length;a.push({kind:`context-group`,id:`group:${o[0].id}`,tools:o,files:e,searches:o.length-e,label:st(e,o.length-e)})}else for(let e of o)a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]});o=[]},c=[],l=()=>{if(c.length!==0){for(let e of mt(c).batches)a.push({kind:`worker-conversation`,id:`worker:${e.messages[0].id}`,batches:[e]});c=[]}};for(let e of i){if(it(e)){s(),c.push(e);continue}l(),G(e)&&at(e)&&!r.has(e.id)?o.push(e):(s(),G(e)?a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]}):a.push({kind:`entry`,id:e.id,entry:e}))}s(),l();let u=e=>e.kind===`context-group`||e.kind===`tool-card`&&e.item.status===`completed`,d=e=>e.kind===`context-group`?e.tools.length:1,f=[],p=[],m=()=>{if(p.length>3){let e=p.slice(0,p.length-3);f.push({kind:`streak`,id:`streak:${e[0].id}`,count:e.reduce((e,t)=>e+d(t),0),blocks:e}),f.push(...p.slice(p.length-3))}else f.push(...p);p=[]};for(let e of a)u(e)?p.push(e):(m(),f.push(e));return m(),f}function mt(e){let t=[];for(let n of e){let e=t.at(-1);n.messageKind===`request`&&e?.kind===`request`&&e.senderRunId===n.senderRunId&&e.text===n.text&&e.messages[0].relationship===`peer`==(n.relationship===`peer`)&&!e.messages.some(e=>e.recipientRunId===n.recipientRunId)?e.messages.push(n):t.push({id:`worker-batch:${n.messageId}`,kind:n.messageKind,text:n.text,senderRunId:n.senderRunId,messages:[n]})}return{kind:`worker-conversation`,id:`worker:${e[0].id}`,batches:t}}var K=new Map,ht=(0,R.createContext)(null);function q(){return(0,R.useContext)(ht)}function gt({runId:e,children:t}){let n=(0,R.useMemo)(()=>({get:t=>K.get(e)?.get(t),set:(t,n)=>{let r=K.get(e)??new Map;r.set(t,n),K.set(e,r)}}),[e]);return(0,z.jsx)(ht.Provider,{value:n,children:t})}function _t(e){return e.scrollTop<Math.max(600,e.clientHeight)}function vt(e,t){let n=t.find(({bottom:t})=>t>e);return n===void 0?void 0:{key:n.key,offset:n.top-e}}function yt(e,t,n,r,i){if(n===void 0)return i;let a=r.find(({key:e})=>e===n.key);return a===void 0?i:e+(a.top-t-n.offset)}function bt(e,t=24){return e.scrollHeight-e.scrollTop-e.clientHeight<t}function xt(e,t){let n=new URLSearchParams(e).get(`thread`);return n===`flat`||n===`virtual`?n:t>300?`virtual`:`flat`}var St=new Map;function Ct(e,t){St.set(e,t)}function wt(e){return St.get(e)}var J=new Map;function Tt(e,t){J.set(e,{...t,...t.rowKeys?{rowKeys:[...t.rowKeys]}:{}})}function Et(e){return J.get(e)}function Dt(e,t,n){let r=J.get(e);if(!r||r.rows!==t)return;let i=r.rowKeys;if(!(n&&i&&(n.length!==t||i.length!==t||!n.every((e,t)=>e===i[t]))))return r.cache}var Ot=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}),kt=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`medium`}),At=new Intl.DateTimeFormat(void 0,{weekday:`short`,month:`short`,day:`numeric`}),jt=new Intl.DateTimeFormat(void 0,{weekday:`short`,year:`numeric`,month:`short`,day:`numeric`}),Mt=new Intl.DateTimeFormat(void 0,{dateStyle:`full`});function Y(e){if(typeof e!=`string`||e===``)return;let t=new Date(e);return Number.isFinite(t.getTime())?t:void 0}function X(e){let t=Y(e);return t===void 0?void 0:Ot.format(t)}function Nt(e){let t=Y(e);return t===void 0?void 0:kt.format(t)}var Z=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`;function Pt(e){let t=Y(e);return t===void 0?void 0:Z(t)}function Ft(e,t=new Date){let n=Y(e);if(n===void 0)return;let r=Z(n);return r===Z(t)?`Today`:r===Z(new Date(t.getFullYear(),t.getMonth(),t.getDate()-1))?`Yesterday`:(n.getFullYear()===t.getFullYear()?At:jt).format(n)}function It(e,t){let n=Y(e),r=Y(t);if(n===void 0||r===void 0)return;let i=Math.round((r.getTime()-n.getTime())/1e3);if(i<0)return;if(i<60)return`${i}s`;let a=Math.floor(i/60);return a<60?`${a}m ${String(i%60).padStart(2,`0`)}s`:`${Math.floor(a/60)}h ${String(a%60).padStart(2,`0`)}m`}function Lt({ts:e}){let t=X(e);return t===void 0?null:(0,z.jsx)(`time`,{"data-slot":`message-time`,dateTime:e,title:Nt(e),className:`text-xs leading-none text-soft-foreground`,children:t})}function Rt({startedAt:e,completedAt:t}){let n=X(t);if(n===void 0)return null;let r=It(e,t);return(0,z.jsxs)(`div`,{"data-slot":`turn-time`,className:`flex items-center gap-1.5 px-0.5 text-xs leading-none text-soft-foreground`,children:[(0,z.jsx)(`time`,{dateTime:t,title:Nt(t),children:n}),r===void 0?null:(0,z.jsxs)(`span`,{title:`Replied in ${r}`,children:[`· `,r]})]})}function zt({ts:e}){let t=Ft(e),n=Y(e);if(t===void 0||n===void 0)return null;let r=Mt.format(n);return(0,z.jsxs)(`div`,{"data-slot":`day-separator`,role:`separator`,"aria-label":t===`Today`||t===`Yesterday`?`${t}, ${r}`:r,className:`flex items-center gap-3 py-1 text-xs font-medium text-soft-foreground`,children:[(0,z.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`}),(0,z.jsx)(`time`,{dateTime:Pt(e),title:r,children:t}),(0,z.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`})]})}var Bt={assistant:`Agent message`,error:`Runner error`,"session.error":`Session error`,"step-end":`Step status`,lifecycle:`Run status`};function Vt({note:e}){return e.icon===`handoff`?(0,z.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,"data-icon":`handoff`,className:`flex items-start gap-2 px-0.5 text-xs text-muted-foreground`,children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,className:`mt-[-1px] flex size-5 shrink-0 items-center justify-center rounded-full border border-border text-success`,children:(0,z.jsx)(fe,{className:`size-3`})}),(0,z.jsx)(`span`,{className:`min-w-0 break-words`,children:e.text})]}):e.details&&e.details.length>0?(0,z.jsxs)(M,{"data-slot":`note-line`,"data-tone":e.tone,className:`group/failure min-w-0 px-0.5 text-xs`,children:[(0,z.jsxs)(`div`,{className:d(`flex items-start gap-2`,e.tone===`danger`?`text-semantic-red`:`text-soft-foreground`),children:[(0,z.jsxs)(`span`,{className:`min-w-0 flex-1 whitespace-pre-wrap wrap-anywhere`,children:[e.tone===`danger`?`✗ `:null,e.text]}),(0,z.jsxs)(j,{"data-slot":`note-details-toggle`,className:`inline-flex shrink-0 items-center gap-1 rounded-sm px-1.5 py-0.5 text-xs font-medium text-muted-foreground hover:bg-muted/50 hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:min-h-11 max-md:min-w-11 max-md:justify-center pointer-coarse:min-h-11 pointer-coarse:min-w-11 pointer-coarse:justify-center`,children:[(0,z.jsx)(g,{"aria-hidden":`true`,className:`size-3 shrink-0 motion-safe:transition-transform group-data-[state=open]/failure:rotate-90`}),`Details`]})]}),(0,z.jsx)(A,{children:(0,z.jsx)(`ul`,{"data-slot":`note-details`,className:`mbs-1.5 flex flex-col gap-1 border-s border-border ps-3 font-mono text-xs text-muted-foreground`,children:e.details.map((e,t)=>(0,z.jsxs)(`li`,{className:`min-w-0 whitespace-pre-wrap wrap-anywhere`,children:[(0,z.jsxs)(`span`,{className:`font-sans font-medium text-foreground`,children:[Bt[e.source],`:`,` `]}),e.text]},`${e.source}:${t}`))})})]}):(0,z.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,className:d(`px-0.5 text-xs`,e.tone===`danger`?`text-semantic-red`:`text-soft-foreground`),children:[e.tone===`danger`?`✗ `:null,e.text]})}var Ht={user:{label:`YOUR MESSAGE`,speaker:`Your message`,classes:`border-message-user-border bg-message-user-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-user-accent`,accent:`text-message-user-accent`,body:`max-md:text-[12px]`},agent:{label:`AGENT RESPONSE`,speaker:`Agent response`,classes:`border-message-agent-border bg-message-agent-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-agent-accent`,accent:`text-message-agent-accent`,body:`text-[15px] md:text-[14px]`}};function Q({role:e,children:t,className:n,ts:r,headerActions:i,...a}){let o=Ht[e],s=r===void 0?void 0:X(r);return(0,z.jsxs)(`article`,{...a,"data-role":e,"aria-label":o.speaker,className:d(`flex w-full min-w-0 flex-col gap-2 self-stretch rounded-[8px] border p-3 md:px-4 md:py-[14px]`,o.classes,n),children:[(0,z.jsxs)(`p`,{className:d(`m-0 flex w-full min-w-0 items-start gap-2 text-xs leading-[1.2] font-semibold tracking-[0.6px] uppercase`,o.accent),children:[(0,z.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1 normal-case tracking-normal`,children:[(0,z.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2 uppercase tracking-[0.6px]`,children:[(0,z.jsx)(te,{"aria-hidden":`true`,className:`size-4 shrink-0`}),o.label]}),i]}),s===void 0?null:(0,z.jsx)(`span`,{className:`shrink-0 font-normal tracking-normal normal-case`,children:(0,z.jsx)(Lt,{ts:r})})]}),(0,z.jsx)(`div`,{className:d(`min-w-0 break-words text-[14px] text-foreground select-text [overflow-wrap:anywhere]`,o.body,`leading-[1.6]`),children:t})]})}var Ut=[],Wt=(0,R.memo)(function({text:e,imageCount:t=0,images:n=Ut,ts:r,onEdit:i,onRemove:a,editLabel:c=`Edit message`,removeLabel:l=`Remove message`,children:u}){let d=t-n.length,[p,m]=(0,R.useState)(!1),[h,g]=(0,R.useState)(e),[_,v]=(0,R.useState)(!1),[y,x]=(0,R.useState)(),S=()=>{g(e),x(void 0),m(!0)},C=async()=>{let t=h.trim();if(!t||t===e){m(!1);return}v(!0),x(void 0);try{await i?.(t),m(!1)}catch(e){x(e instanceof Error?e.message:`Could not save the message`)}finally{v(!1)}},w=async()=>{v(!0),x(void 0);try{await a?.()}catch(e){x(e instanceof Error?e.message:`Could not remove the message`)}finally{v(!1)}};return p?(0,z.jsxs)(Q,{role:`user`,ts:r,"data-slot":`user-bubble`,"data-editing":`true`,children:[(0,z.jsx)(`textarea`,{autoFocus:!0,"aria-label":`Edit the message`,value:h,onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Escape`?(e.stopPropagation(),m(!1)):e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),C())},className:`block max-h-[220px] min-h-[60px] w-full resize-none rounded-md bg-background px-2 py-1.5 text-[14px] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`}),(0,z.jsxs)(`span`,{className:`mt-1.5 flex justify-end gap-1.5`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:()=>m(!1),disabled:_,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm px-2 text-xs font-medium text-muted-foreground hover:bg-background hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:`Cancel`}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void C(),disabled:_,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm bg-action px-2 text-xs font-semibold text-action-foreground hover:brightness-[0.96] focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:_?(0,z.jsx)(E,{className:`size-3.5 animate-spin`}):`Save`})]}),y?(0,z.jsx)(`p`,{role:`alert`,className:`mt-1.5 text-xs text-danger`,children:y}):null]}):(0,z.jsxs)(Q,{role:`user`,ts:r,"data-slot":`user-bubble`,className:`group`,children:[i||a?(0,z.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`mb-1 flex justify-end gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100`,children:[i?(0,z.jsx)(`button`,{type:`button`,"aria-label":c,onClick:S,disabled:_,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,z.jsx)(we,{className:`size-3.5`})}):null,a?(0,z.jsx)(`button`,{type:`button`,"aria-label":l,onClick:()=>void w(),disabled:_,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-danger focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,z.jsx)(b,{className:`size-3.5`})}):null]}):null,y?(0,z.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:y}):null,u??(0,z.jsx)(I,{breaks:!0,children:e}),n.length>0?(0,z.jsx)(`span`,{"data-slot":`user-images`,className:`mt-2 flex flex-wrap items-center justify-end gap-1.5`,children:n.map(e=>s(e.split(`/`).pop()??``)?(0,z.jsx)(_e,{src:e,alt:`attached`,className:`max-h-40 max-w-[220px] rounded-md border border-border object-contain`},e):(0,z.jsxs)(`a`,{href:o(e),download:!0,"data-slot":`user-file`,className:`inline-flex min-h-11 min-w-11 max-w-[220px] items-center gap-1.5 rounded-md border border-border bg-background/60 px-2 py-1 text-xs text-muted-foreground hover:text-foreground`,children:[(0,z.jsx)(f,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,z.jsx)(`span`,{className:`truncate`,children:e.split(`/`).pop()})]},e))}):null,d>0?(0,z.jsxs)(`span`,{className:`mt-1 block text-xs text-soft-foreground`,children:[d,` image`,d>1?`s`:``,` attached`]}):null]})}),Gt=`inline-flex h-11 min-w-11 items-center justify-center gap-1 rounded-sm px-2 text-xs font-medium text-soft-foreground hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,Kt=[`[data-streamdown="code-block-actions"]`,`[data-streamdown="code-copy-button"]`,`[data-streamdown="code-block-copy-button"]`,`[data-streamdown="code-block-header"]`].join(`,`);function qt(e,t){let n=e.cloneNode(!0);n.querySelectorAll(Kt).forEach(e=>e.remove());let r=Ze(t);return[...n.querySelectorAll(`button[data-streamdown="link"]`)].forEach(e=>{let t=e.textContent??``,i=r.findIndex(e=>e.label===t);if(i<0)return;let a=r.splice(i,1)[0];if(!a||!H(a.href))return;let o=n.ownerDocument.createElement(`a`);o.setAttribute(`href`,a.href),o.setAttribute(`data-streamdown`,`link`),o.textContent=e.textContent,e.replaceWith(o)}),n.innerHTML}async function Jt(e,t,n){if(e===`markdown`){if(!navigator.clipboard?.writeText)throw Error(`Clipboard unavailable`);await navigator.clipboard.writeText(t);return}if(!navigator.clipboard?.write||typeof ClipboardItem>`u`||!n)throw Error(`Clipboard unavailable`);let r=qt(n,t);await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([r],{type:`text/html`}),"text/plain":new Blob([t],{type:`text/plain`})})])}var Yt=(0,R.memo)(function({text:e,ts:t,messageKey:n}){let r=(0,R.useRef)(null),[i,a]=(0,R.useState)(null),[o,s]=(0,R.useState)(null),c=(0,R.useRef)(null);(0,R.useEffect)(()=>()=>{c.current!==null&&clearTimeout(c.current)},[]);let l=async t=>{c.current!==null&&clearTimeout(c.current),a(null),s(null);try{await Jt(t,e,r.current),a(t),c.current=setTimeout(()=>a(null),2e3)}catch{s(`Couldn't copy to the clipboard`)}};return(0,z.jsxs)(Q,{role:`agent`,ts:t,"data-slot":`assistant-message`,headerActions:(0,z.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`flex items-center gap-0.5`,children:[(0,z.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply`,onClick:()=>void l(`html`),className:Gt,children:[(0,z.jsx)(S,{className:`size-3.5`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{"aria-live":`polite`,children:i===`html`?`Copied`:`Copy`})]}),(0,z.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply as markdown`,onClick:()=>void l(`markdown`),className:Gt,children:[(0,z.jsx)(P,{className:`size-3.5`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{"aria-live":`polite`,children:i===`markdown`?`Copied`:`Copy markdown`})]})]}),children:[o?(0,z.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:o}):null,(0,z.jsx)(`div`,{ref:r,children:(0,z.jsx)(I,{breaks:!0,children:e})}),(0,z.jsx)(et,{text:e,messageKey:n})]})});function Xt({incident:e}){let t=i().data;if(!t)return null;let n=a(t,e.provider);return(0,z.jsxs)(`div`,{role:`alert`,"data-slot":`provider-auth-required`,className:`rounded-md border border-danger/30 bg-danger/5 px-3.5 py-3`,children:[(0,z.jsxs)(`p`,{className:`text-[13px] font-semibold text-foreground`,children:[`This run needed `,n,` authorization`]}),(0,z.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Review `,n,` settings before retrying.`]}),(0,z.jsx)(N,{to:`/settings/agent-defaults#providers`,className:`mt-2 inline-flex text-xs font-medium text-foreground underline-offset-2 hover:underline`,children:`Open provider settings`})]})}var Zt=(0,R.memo)(function({text:e}){let t=(0,R.useId)();if(e.trim()===``)return null;let n=e.split(`
|
|
5
|
-
`,1)[0]??``,r=n.length<e.length;return(0,z.jsxs)(M,{"data-slot":`reasoning`,className:`group/reasoning min-w-0`,children:[(0,z.jsxs)(`div`,{id:t,className:`relative flex w-full items-center gap-1.5 rounded-md p-0.5 text-left text-[13px] text-soft-foreground hover:text-muted-foreground`,children:[(0,z.jsx)(g,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]/reasoning:rotate-90`}),(0,z.jsx)(`span`,{className:`shrink-0`,children:`Thinking — `}),(0,z.jsx)(`div`,{className:`min-w-0 truncate text-muted-foreground max-md:[&_*]:inline max-md:[&_*]:whitespace-nowrap`,children:(0,z.jsx)(I,{inline:!0,children:n})}),r?(0,z.jsx)(`span`,{"aria-hidden":!0,children:`…`}):null,(0,z.jsx)(j,{"aria-labelledby":t,className:`absolute inset-0 rounded-md focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`})]}),(0,z.jsx)(A,{children:(0,z.jsx)(`div`,{className:`px-6 py-1.5 text-[13px] leading-[1.6] text-soft-foreground`,children:(0,z.jsx)(I,{children:e})})})]})});function Qt(){return(0,z.jsxs)(`div`,{"data-slot":`working-indicator`,className:`flex items-center gap-2 py-1 text-[13px] text-soft-foreground`,children:[(0,z.jsx)(E,{role:`status`,"aria-label":`Working`,className:`size-3.5 shrink-0 animate-spin`}),(0,z.jsx)(`span`,{className:`shimmer font-medium`,children:`Working…`})]})}var $t={read:P,edit:we,delete:b,move:Se,search:p,execute:O,think:xe,fetch:ee,task:h,plan:m,other:y},en=e=>e.split(`
|
|
6
|
-
`).length;function tn({text:e,streaming:t}){let[n,r]=(0,R.useState)(!1),i=(0,R.useRef)(null),a=(0,R.useRef)(!0);(0,R.useEffect)(()=>{let e=i.current;t&&e&&a.current&&(e.scrollTop=e.scrollHeight)},[e,t]);let o=en(e),s=!t&&!n&&o>12;return(0,z.jsxs)(`div`,{"data-slot":`tool-output`,"data-clamped":s?`true`:void 0,children:[(0,z.jsxs)(`div`,{className:`relative`,children:[(0,z.jsx)(`div`,{ref:i,onScroll:t?e=>{a.current=bt(e.currentTarget)}:void 0,className:d(`overflow-x-auto`,t&&`max-h-[216px] overflow-y-auto`,s&&`max-h-[216px] overflow-y-hidden`),children:(0,z.jsx)(`pre`,{className:`px-4 py-3 font-mono text-xs leading-[1.7] whitespace-pre text-muted-foreground`,children:e})}),s?(0,z.jsx)(`div`,{"data-slot":`tool-output-fade`,"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 bottom-0 h-14 bg-gradient-to-b from-transparent to-card-2`}):null]}),!t&&o>12?(0,z.jsx)(`button`,{type:`button`,"data-slot":`tool-output-toggle`,onClick:()=>r(e=>!e),className:`block w-full border-t border-border/50 px-4 py-1.5 text-left text-xs font-medium text-soft-foreground hover:text-foreground`,children:n?`Show less`:`Show all ${o} lines`}):null]})}function nn({diffs:e}){return(0,z.jsx)(z.Fragment,{children:e.map((e,t)=>(0,z.jsxs)(`div`,{"data-slot":`diff-preview`,className:`min-w-0`,children:[(0,z.jsx)(`div`,{className:`border-b border-border/50 px-4 py-1.5 font-mono text-xs wrap-anywhere text-muted-foreground`,children:e.path}),(0,z.jsx)(`pre`,{className:`overflow-x-auto py-2 font-mono text-xs leading-[1.7] whitespace-pre`,children:e.unified===void 0?[...rn(e.oldText).map((e,t)=>(0,z.jsxs)(`span`,{className:`block bg-diff-del px-4 text-muted-foreground`,children:[`- `,e]},`old-${t}`)),...rn(e.newText).map((e,t)=>(0,z.jsxs)(`span`,{className:`block bg-diff-add px-4`,children:[`+ `,e]},`new-${t}`))]:e.unified.split(`
|
|
7
|
-
`).map((e,t)=>(0,z.jsx)(an,{text:e},t))})]},`${e.path}:${t}`))})}function rn(e){return e==null||e===``?[]:e.replace(/\n$/,``).split(`
|
|
8
|
-
`)}function an({text:e}){return(0,z.jsx)(`span`,{className:d(`block px-4`,e.startsWith(`+`)&&`bg-diff-add`,e.startsWith(`-`)&&`bg-diff-del text-muted-foreground`,e.startsWith(`@@`)&&`text-soft-foreground`),children:e})}function on(e){return e.toolKind===`execute`&&e.status===`running`&&e.output!==void 0}function sn(e){let t=e.status===`running`||e.status===`pending`,n=ut(e.title),{verb:r,detail:i}=e.toolKind===`execute`&&n.detail===void 0?{verb:`Ran`,detail:e.title}:n;return{busy:t,verb:r,detail:i,expandedCommand:(e.toolKind===`execute`?qe(e.input):D(e.name).toolKind===e.toolKind?ne(e.name,e.input):void 0)??i,Icon:$t[e.toolKind]??y}}function cn(e,t){return e.output!==void 0&&e.output!==``||e.error!==void 0&&e.error!==``||e.diffs!==void 0&&e.diffs.length>0||t>0}function ln({item:e,busy:t}){return(0,z.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[t?(0,z.jsx)(E,{role:`status`,"aria-label":`Running`,className:`size-3.5 animate-spin text-soft-foreground`}):null,e.status===`failed`?(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`failed`}):null,e.status===`declined`?(0,z.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`declined`}):null,e.toolKind===`execute`&&typeof e.exitCode==`number`?(0,z.jsx)(`span`,{"data-slot":`tool-exit`,className:d(`rounded-full px-2 py-px font-mono text-xs font-semibold`,e.exitCode===0?`bg-success/10 text-success`:`bg-danger/10 text-danger`),children:e.exitCode}):null]})}function un({item:e,command:t,busy:n,nested:r,cacheKey:i,renderNested:a}){return(0,z.jsxs)(`div`,{className:`border-t border-border bg-card-2`,children:[t===void 0?null:(0,z.jsx)(`pre`,{"data-slot":`tool-command`,className:`px-3 py-2 font-mono text-xs whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:t}),e.error!==void 0&&e.error!==``?(0,z.jsx)(`div`,{"data-slot":`tool-error`,className:`px-4 py-3 font-mono text-xs leading-[1.7] whitespace-pre-wrap wrap-anywhere text-signal-word-red`,children:e.error}):null,e.diffs!==void 0&&e.diffs.length>0?(0,z.jsx)(nn,{diffs:e.diffs}):null,e.output!==void 0&&e.output!==``?(0,z.jsx)(tn,{text:e.output,streaming:n}):null,r.length>0?(0,z.jsx)(`div`,{"data-slot":`tool-nested`,className:`flex flex-col gap-2 border-l-2 border-border py-2.5 pr-3 pl-3 ml-4 my-2`,children:a?.(r,i??e.id)}):null]})}function dn({item:e,nested:t=[],cacheKey:n,renderNested:r}){let i=q(),[a,o]=(0,R.useState)(()=>n===void 0?null:i?.get(n)??null),s=e=>{n!==void 0&&i?.set(n,e),o(e)},{busy:c,verb:l,detail:u,expandedCommand:f,Icon:p}=sn(e),m=cn(e,t.length),h=f!==void 0||m,_=h&&(a??(m&&on(e)));return(0,z.jsxs)(M,{"data-slot":`tool-card`,"data-status":e.status,"data-kind":e.toolKind,open:_,onOpenChange:s,className:d(`min-w-0 overflow-hidden rounded-md border bg-card`,e.status===`failed`?`border-danger/25`:`border-border`),children:[(0,z.jsxs)(j,{disabled:!h,className:`group flex min-h-[28px] w-full items-center gap-1.5 px-2.5 py-0.5 text-left text-[13px] enabled:hover:bg-muted`,children:[(0,z.jsx)(g,{"aria-hidden":!0,className:d(`size-3 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`,!h&&`invisible`)}),(0,z.jsx)(p,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,z.jsx)(`span`,{className:d(`shrink-0 font-semibold`,c&&`shimmer`,e.status===`declined`&&`text-muted-foreground`),children:l}),u===void 0?null:(0,z.jsx)(`code`,{title:u,className:`block min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground`,children:u}),(0,z.jsx)(ln,{item:e,busy:c})]}),(0,z.jsx)(A,{children:(0,z.jsx)(un,{item:e,command:f,busy:c,nested:t,cacheKey:n,renderNested:r})})]})}function fn(e){let t=e.name??e.event,n=t.indexOf(`:`);return n>0?`${t.slice(0,n)} · ${t.slice(n+1)}`:t}function pn({item:e,cacheKey:t}){let n=q(),[r,i]=(0,R.useState)(()=>t===void 0?!1:n?.get(t)??!1),a=e=>{t!==void 0&&n?.set(t,e),i(e)},o=e.status!==`completed`,s=e.entries.some(e=>e.kind===`context`),c=(e.stdout??``)!==``||(e.stderr??``)!==``,l=fn(e);return(0,z.jsxs)(M,{"data-slot":`hook-card`,"data-status":e.status,open:r,onOpenChange:a,className:d(`min-w-0 overflow-hidden rounded-md border bg-card`,o?`border-danger/25`:`border-border`),children:[(0,z.jsxs)(j,{className:`group flex min-h-[28px] w-full items-center gap-1.5 px-2.5 py-0.5 text-left text-[13px] hover:bg-muted`,children:[(0,z.jsx)(g,{"aria-hidden":!0,className:`size-3 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`}),(0,z.jsx)(be,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,z.jsx)(`span`,{className:`shrink-0 font-semibold`,children:`Hook`}),(0,z.jsx)(`code`,{title:l,className:`block min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground`,children:l}),(0,z.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[o?(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.status}):s?(0,z.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`context`}):null,o&&typeof e.exitCode==`number`&&e.exitCode!==0?(0,z.jsx)(`span`,{"data-slot":`hook-exit`,className:`rounded-full bg-danger/10 px-2 py-px font-mono text-xs font-semibold text-danger`,children:e.exitCode}):null]})]}),(0,z.jsx)(A,{children:(0,z.jsxs)(`div`,{className:`border-t border-border bg-card-2`,children:[e.entries.map((e,t)=>(0,z.jsx)(`pre`,{"data-slot":`hook-entry`,"data-kind":e.kind,className:d(`px-3 py-2 font-mono text-xs leading-[1.7] whitespace-pre-wrap [overflow-wrap:anywhere]`,(e.kind===`error`||e.kind===`stop`)&&`text-signal-word-red`),children:e.text},t)),e.source===void 0?null:(0,z.jsx)(`p`,{"data-slot":`hook-source`,className:`px-3 pb-2 font-mono text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:e.source}),c?(0,z.jsxs)(M,{className:`border-t border-border`,children:[(0,z.jsxs)(j,{"data-slot":`hook-raw-toggle`,className:`group flex w-full items-center gap-1 px-3 py-1 text-left text-xs text-muted-foreground hover:text-foreground`,children:[(0,z.jsx)(g,{"aria-hidden":!0,className:`size-3 shrink-0 transition-transform group-data-[state=open]:rotate-90`}),`Raw output${typeof e.exitCode==`number`?` · exit ${e.exitCode}`:``}`]}),(0,z.jsxs)(A,{children:[e.stdout?(0,z.jsx)(`pre`,{"data-slot":`hook-stdout`,className:`px-3 py-2 font-mono text-xs whitespace-pre-wrap [overflow-wrap:anywhere]`,children:e.stdout}):null,e.stderr?(0,z.jsx)(`pre`,{"data-slot":`hook-stderr`,className:`px-3 py-2 font-mono text-xs whitespace-pre-wrap text-signal-word-red [overflow-wrap:anywhere]`,children:e.stderr}):null]})]}):null]})})]})}function mn({group:e,scope:t}){return(0,z.jsxs)(M,{"data-slot":`ctx-group`,className:`min-w-0`,children:[(0,z.jsxs)(j,{className:`group flex h-[34px] tabular-nums w-full items-center gap-2 rounded-md px-2 -mx-2 text-left text-[13px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground`,children:[(0,z.jsx)(g,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`}),e.label]}),(0,z.jsx)(A,{children:(0,z.jsx)(`div`,{className:`flex flex-col gap-1.5 pt-1.5 pl-4`,children:e.tools.map(e=>(0,z.jsx)(dn,{item:e,cacheKey:t===void 0?void 0:`${t}:${e.id}`},e.id))})})]})}function hn({count:e,children:t}){return(0,z.jsxs)(M,{"data-slot":`tool-streak`,className:`min-w-0`,children:[(0,z.jsxs)(j,{className:`group flex items-center gap-1.5 rounded-md p-0.5 tabular-nums text-left text-xs text-soft-foreground hover:text-muted-foreground`,children:[(0,z.jsx)(g,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]:rotate-90`}),ct(e)]}),(0,z.jsx)(A,{children:(0,z.jsx)(`div`,{className:`flex flex-col gap-2 pt-2`,children:t})})]})}function gn({image:e}){return(0,z.jsx)(_e,{"data-slot":`thread-image`,src:e.url,alt:e.name??`image from the agent session`,className:`max-h-72 max-w-full self-start rounded-lg border border-border`})}var _n={finish:`Closed when the task finished`,superseded:`Closed when the worker went on`,"parent-stopped":`Closed when the parent stopped`,"worker-stopped":`Closed when the worker stopped`,undeliverable:`Closed: not delivered`};function vn(e,t,n){return`${e.header}: ${n?.trim()||t.join(`, `)}`}function yn(e,t,n,r=``){let i=e.map((e,r)=>vn(e,t[r]??[],n[r])).join(`
|
|
9
|
-
`),a=r.trim();return a?`${i}\n\nAdditional comments:\n${a}`:i}function bn({ask:e,run:t,projectId:n,onShowOrigin:r,onAnswered:i,renderFreeTextReply:a,onStop:o,stopping:s=!1,onFinish:c,finishing:l=!1,mode:u,onModeChange:d,hideReplyBody:f=!1,delivery:p,surface:m=`transcript`,fold:h}){let g=m===`transcript`&&e.context?(0,z.jsx)($,{text:e.context}):null;if(e.resolved)return(0,z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[e.context?(0,z.jsx)($,{text:e.context}):null,(0,z.jsxs)(Q,{role:`user`,"data-slot":`ask-card`,"data-resolved":`true`,children:[(0,z.jsx)(`span`,{className:`text-soft-foreground`,children:e.closed?_n[e.closed]:e.answeredBy===`parent`?`Answered by parent`:`Answered`}),(0,z.jsx)(Ae,{ask:e})]})]});let _=e.placement===`pinned`&&r?r:void 0;return e.routedToParent?(0,z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[g,(0,z.jsx)(xn,{ask:e,runId:t.id,surface:m,onShowOrigin:_})]}):(0,z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[g,(0,z.jsx)(Tn,{ask:e,run:t,projectId:n,surface:m,onShowOrigin:_,onAnswered:i,renderFreeTextReply:a,onStop:o,stopping:s,onFinish:c,finishing:l,controlledMode:u,onModeChange:d,hideReplyBody:f,delivery:p,fold:h})]})}function $({text:e}){return(0,z.jsx)(Q,{role:`agent`,children:(0,z.jsx)(`div`,{"data-slot":`ask-context`,role:`region`,"aria-label":`Context`,className:`break-words text-sm text-foreground`,children:(0,z.jsx)(I,{breaks:!0,children:e})})})}function xn({ask:e,runId:t,surface:n,onShowOrigin:r}){let[i,a]=(0,R.useState)(!1),o=(0,R.useRef)(null),s=n===`decision-zone`&&!!e.context;return(0,z.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`false`,"data-ask-id":e.id,"data-pinned":e.placement===`pinned`?`true`:void 0,"data-routed":`parent`,className:`rounded-xl border border-card-edge bg-card shadow-card px-3 py-2.5`,children:[(0,z.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`text-xs font-medium text-link-foreground`,children:`The agent is asking its parent`}),s?(0,z.jsx)(k,{ref:o,type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-show-context`,className:`ms-auto px-2 text-xs font-medium text-link-foreground underline underline-offset-4`,onClick:()=>a(!0),children:`Show context`}):null]}),(0,z.jsx)(`div`,{"data-slot":`ask-body`,className:`flex flex-col gap-3`,children:e.questions.map((e,t)=>(0,z.jsxs)(`div`,{role:`group`,"aria-label":e.question,children:[(0,z.jsx)(`div`,{className:`mb-0.5 flex items-center gap-2`,children:(0,z.jsx)(`span`,{className:`rounded-md bg-muted px-1.5 py-0.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:e.header})}),(0,z.jsx)(`p`,{className:`mb-1.5 break-words text-sm font-semibold text-foreground`,children:e.question}),e.options?(0,z.jsx)(`ul`,{className:`flex list-disc flex-col gap-0.5 pl-5 text-[13px] text-muted-foreground`,children:e.options.map(e=>(0,z.jsxs)(`li`,{className:`break-words`,children:[(0,z.jsx)(`span`,{className:`text-foreground`,children:e.label}),e.description?(0,z.jsxs)(`span`,{children:[`: `,e.description]}):null]},e.label))}):(0,z.jsx)(`p`,{"data-slot":`ask-open-routed`,className:`text-[13px] text-muted-foreground`,children:`Open question: answered in words, with no options.`})]},e.id??t))}),(0,z.jsxs)(`div`,{"data-slot":`ask-footer`,className:`mt-2.5 flex flex-wrap items-center gap-2`,children:[(0,z.jsxs)(`p`,{"data-slot":`ask-routed-hint`,className:`text-xs text-muted-foreground`,children:[`Routed to parent: answer it in the`,` `,e.parentRunId?(0,z.jsx)(N,{to:`/tasks/${e.parentRunId}`,className:`font-medium text-foreground underline underline-offset-4`,children:`parent task`}):`parent task`,`.`]}),!s&&r?(0,z.jsx)(Ve,{onShowOrigin:r,className:`ms-auto`}):null]}),s&&e.context?(0,z.jsx)(He,{open:i,onOpenChange:a,runId:t,context:e.context,onShowOrigin:r,returnFocusRef:o}):null]})}function Sn(e,t,n,r,i){let a=t.blockedBy!==void 0,o=e.questions,s=o.length>1,c=o.length,[l,u]=(0,R.useState)(`options`),d=n??l,f=e=>{u(e),r?.(e)},[p,m]=(0,R.useState)(0),[h,g]=(0,R.useState)({}),[_,v]=(0,R.useState)({}),[y,b]=(0,R.useState)(``),[x,S]=(0,R.useState)(!1),[C,w]=(0,R.useState)(``),[T,ee]=(0,R.useState)(!1),E=s&&p===c,te=o.length===1&&o[0]?.options!==void 0&&o[0]?.multiSelect!==!0&&!x&&y.trim()===``;me(Object.values(h).some(e=>e.length>0)||Object.values(_).some(e=>e.trim()!==``)||y.trim()!==``||C.trim()!==``);let D=(e,t)=>g(n=>({...n,[e]:t})),ne=e=>v(t=>{if(t[e]===void 0)return t;let n={...t};return delete n[e],n}),O=e=>{D(e,[]),v(t=>({...t,[e]:t[e]??``}))},k=o.some((e,t)=>!e.options||_[t]!==void 0),A=o.filter((e,t)=>V(t,h,_)).length,j=A===o.length,M=async e=>{let n=await t.send(e);return n===void 0&&i?.(),n};return{delivery:t,blocked:a,questions:o,stepped:s,commentStepIndex:c,mode:d,setMode:f,stepIndex:p,setStepIndex:m,selections:h,otherAnswers:_,setOtherAnswers:v,additionalComment:y,setAdditionalComment:b,singleCommentOpen:x,setSingleCommentOpen:S,freeTextDraft:C,setFreeTextDraft:w,contextOpen:T,setContextOpen:ee,onCommentStep:E,oneTap:te,setQuestion:D,clearOtherAnswer:ne,selectOther:O,hasOtherAnswer:k,answeredCount:A,allAnswered:j,deliver:M,sendAll:()=>void M(yn(o,h,_,y)),sendFreeText:()=>{let e=C.trim();e&&M(e).then(e=>{e===void 0&&w(``)})}}}function Cn({state:e,renderFreeTextReply:t}){let n=(0,R.useId)(),r=e.delivery.isPending||e.blocked;if(e.mode===`reply`)return(0,z.jsx)(Le,{value:e.freeTextDraft,onValueChange:e.setFreeTextDraft,disabled:r,renderFreeTextReply:t});if(e.onCommentStep)return(0,z.jsx)(Ie,{questions:e.questions,selections:e.selections,otherAnswers:e.otherAnswers,comment:e.additionalComment,disabled:r,onCommentChange:e.setAdditionalComment,onJumpToQuestion:e.setStepIndex});let i=e.stepped?Math.min(e.stepIndex,e.questions.length-1):0,a=e.questions[i];return a?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(jn,{question:a,disabled:r,selected:e.selections[i]??[],isOther:e.otherAnswers[i]!==void 0,otherAnswer:e.otherAnswers[i]??``,onSelect:t=>{e.blocked||(e.clearOtherAnswer(i),e.oneTap?e.deliver(vn(a,t)):e.setQuestion(i,t))},onOtherToggle:()=>{e.blocked||(e.otherAnswers[i]===void 0?e.selectOther(i):e.clearOtherAnswer(i))},onOtherChange:t=>e.setOtherAnswers(e=>({...e,[i]:t}))},a.id??i),!e.stepped&&e.singleCommentOpen?(0,z.jsxs)(`div`,{className:`pt-1`,children:[(0,z.jsx)(`label`,{htmlFor:n,className:`mb-1 block text-xs font-medium text-foreground`,children:`Additional comments (optional)`}),(0,z.jsx)(F,{id:n,"data-slot":`ask-additional-comment`,rows:2,value:e.additionalComment,disabled:r,placeholder:`Optional extra notes for the agent…`,onChange:t=>e.setAdditionalComment(t.target.value),className:`bg-card text-base md:text-[13px]`})]}):null]}):null}function wn({onFinish:e,finishing:t,onStop:n,stopping:r,onActionError:i}){if(!e&&!n)return null;let a=e=>{i(void 0),Promise.resolve(e()).catch(e=>{i(e instanceof Error?e.message:String(e))})};return(0,z.jsxs)(z.Fragment,{children:[e?(0,z.jsx)(k,{type:`button`,variant:`outline`,size:`sm`,"data-slot":`ask-finish`,disabled:t||r,title:`Close the session and mark this task done`,className:`px-3`,onClick:()=>a(e),children:t?`Finishing…`:`Finish`}):null,n?(0,z.jsx)(k,{type:`button`,variant:`outline`,size:`sm`,disabled:r||t,className:`px-3`,onClick:()=>a(n),children:r?`Stopping…`:`Stop`}):null]})}function Tn(e){return e.delivery===void 0?(0,z.jsx)(En,{...e}):(0,z.jsx)(Dn,{...e,delivery:e.delivery})}function En(e){let t=pe(e.run,e.projectId);return(0,z.jsx)(Dn,{...e,delivery:t})}function Dn({ask:e,run:t,surface:n,onShowOrigin:r,onAnswered:i,renderFreeTextReply:a,onStop:o,stopping:s,onFinish:c,finishing:l,controlledMode:u,onModeChange:f,hideReplyBody:p,delivery:m,fold:h}){let g=Sn(e,m,u,f,i),[_,v]=(0,R.useState)(void 0),y=(0,R.useRef)(null),b=n===`decision-zone`||a!==void 0,x=n===`decision-zone`&&!!e.context,S=g.mode===`reply`&&p,C=g.onCommentStep?`Comment (optional)`:`${g.stepIndex+1} of ${g.questions.length}`,w=h?.folded===!0,T=(0,z.jsx)(wn,{onFinish:c,finishing:l,onStop:o,stopping:s,onActionError:v});return(0,z.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`false`,"data-ask-id":e.id,"data-ask-mode":g.mode,"data-pinned":e.placement===`pinned`?`true`:void 0,"data-delivery":g.delivery.mode,"data-folded":h?String(w):void 0,className:d(`rounded-xl border border-accent-strong/30 bg-accent-strong/[0.04] [html:not(.light)_&]:bg-card`,S&&!w&&`rounded-b-none border-b-0`),children:[w?(0,z.jsx)(kn,{state:g,stepLabel:C,onOpen:()=>h.onFoldChange(!1)}):(0,z.jsx)(On,{state:g,stepLabel:C,showModeSwitch:b,hasSheetContext:x,contextButtonRef:y,onShowOrigin:r,onFold:h?()=>h.onFoldChange(!0):void 0,replyDockedOutside:S,renderFreeTextReply:a,stopControl:T,actionError:_}),x&&e.context?(0,z.jsx)(He,{open:g.contextOpen,onOpenChange:g.setContextOpen,runId:t.id,context:e.context,onShowOrigin:r,returnFocusRef:y}):null]})}function On({state:e,stepLabel:t,showModeSwitch:n,hasSheetContext:r,contextButtonRef:i,onShowOrigin:a,onFold:o,replyDockedOutside:s,renderFreeTextReply:c,stopControl:l,actionError:u}){let d=e.additionalComment.trim()!==``;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Me,{stepped:e.stepped,mode:e.mode,onModeChange:e.setMode,showModeSwitch:n,stepLabel:t,hasSheetContext:r,showContextButtonRef:i,onOpenContext:()=>e.setContextOpen(!0),onShowOrigin:r?void 0:a,onFold:o}),e.stepped&&e.mode===`options`?(0,z.jsx)(Fe,{questions:e.questions,stepIndex:e.stepIndex,selections:e.selections,otherAnswers:e.otherAnswers,hasComment:d,onSelectStep:e.setStepIndex}):null,s?null:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{"data-slot":`ask-body`,className:`flex flex-col gap-2.5 px-3 py-2.5`,children:(0,z.jsx)(Cn,{state:e,renderFreeTextReply:c})}),(0,z.jsxs)(`div`,{"data-slot":`ask-footer`,className:`flex shrink-0 flex-col gap-2 border-t border-border/70 px-3 py-2`,children:[(0,z.jsx)(An,{state:e,hasComment:d,resuming:e.delivery.mode===`resume`,hasCustomReply:c!==void 0,stopControl:l,compact:o!==void 0}),(0,z.jsx)(Be,{blockedBy:e.delivery.blockedBy,reason:e.delivery.reason,error:e.delivery.error??u})]})]})]})}function kn({state:e,stepLabel:t,onOpen:n}){let r=e.questions[Math.min(e.stepIndex,e.questions.length-1)];return e.onCommentStep?(0,z.jsx)(Pe,{tag:`Comment`,text:`Add a comment, then send.`,position:void 0,onOpen:n}):(0,z.jsx)(Pe,{tag:r?.header??``,text:r?.question??``,position:e.stepped?t:void 0,onOpen:n})}function An({state:e,hasComment:t,resuming:n,hasCustomReply:r,stopControl:i,compact:a}){return e.mode===`reply`?r?null:(0,z.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[i,(0,z.jsx)(k,{type:`button`,size:`sm`,className:`px-3.5`,disabled:e.delivery.isPending||e.blocked||e.freeTextDraft.trim()===``,onClick:e.sendFreeText,children:`Send reply`})]}):e.stepped?(0,z.jsx)(Re,{stepIndex:e.stepIndex,questionCount:e.questions.length,answeredCount:e.answeredCount,allAnswered:e.allAnswered,hasComment:t,resuming:n,disabled:e.delivery.isPending||e.blocked,onBack:()=>e.setStepIndex(e=>Math.max(0,e-1)),onNext:()=>e.setStepIndex(t=>Math.min(e.commentStepIndex,t+1)),onOpenComment:()=>e.setStepIndex(e.commentStepIndex),onSend:e.sendAll,questions:e.questions,selections:e.selections,otherAnswers:e.otherAnswers,stopControl:i,compact:a}):(0,z.jsx)(ze,{oneTap:e.oneTap,hasOtherAnswer:e.hasOtherAnswer,allowComment:e.questions[0]?.allowFreeText!==!1,commentOpen:e.singleCommentOpen,hasComment:t,resuming:n,disabled:e.delivery.isPending||e.blocked||!e.allAnswered,onToggleComment:()=>e.setSingleCommentOpen(e=>!e),onSend:e.sendAll,stopControl:i,compact:a})}function jn({question:e,disabled:t,selected:n,isOther:r,otherAnswer:i,onSelect:a,onOtherToggle:o,onOtherChange:s}){let c=(0,R.useId)(),l=(0,R.useRef)(null),u=(0,R.useRef)(r),f=e.options,p=f!==void 0,m=p&&e.multiSelect===!0;(0,R.useEffect)(()=>{let e=r&&!u.current;u.current=r,e&&p&&l.current?.focus()},[r,p]);let h=e=>{if(!m){a([e]);return}a(n.includes(e)?n.filter(t=>t!==e):[...n,e])};return(0,z.jsxs)(`div`,{"data-slot":`ask-question`,role:`group`,"aria-label":e.question,children:[(0,z.jsxs)(`div`,{className:`mb-1.5 flex flex-wrap items-baseline gap-x-2 gap-y-0.5`,children:[(0,z.jsx)(`span`,{className:`shrink-0 rounded-md bg-accent-strong px-1.5 py-0.5 text-xs font-semibold uppercase tracking-wide text-accent-strong-foreground`,children:e.header}),(0,z.jsx)(`p`,{className:`min-w-0 flex-1 break-words text-sm font-semibold text-foreground`,children:e.question}),m?(0,z.jsx)(`span`,{className:`ms-auto text-xs text-soft-foreground`,children:`select all that apply`}):null]}),f?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{"data-slot":`ask-options`,className:`grid grid-cols-1 gap-1.5 sm:grid-cols-2 sm:gap-2`,children:[f.map(e=>{let r=n.includes(e.label);return(0,z.jsxs)(`button`,{type:`button`,disabled:t,"aria-pressed":r,onClick:()=>h(e.label),className:d(`flex min-h-11 w-full flex-col items-start justify-start content-start gap-0.5 rounded-md border px-2.5 py-1.5 text-left transition-colors focus-visible:outline-2 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50`,r?`border-accent-strong bg-accent-strong/15 ring-1 ring-accent-strong/30 pointer-hover:border-accent-strong pointer-hover:bg-accent-strong/15`:`border-border bg-card pointer-hover:border-accent-strong/50 pointer-hover:bg-accent-strong/[0.08]`),children:[(0,z.jsxs)(`span`,{className:`flex min-w-0 items-start gap-2 text-[13px] font-semibold text-foreground`,children:[m?(0,z.jsx)(`span`,{"aria-hidden":`true`,className:d(`flex size-4 shrink-0 items-center justify-center rounded border text-[12px]`,r?`border-accent-strong bg-accent-strong text-accent-strong-foreground`:`border-soft-foreground`),children:r?`✓`:``}):null,(0,z.jsx)(`span`,{className:`min-w-0 break-words`,children:e.label})]}),e.description?(0,z.jsx)(`span`,{className:`min-w-0 break-words text-xs text-muted-foreground`,children:e.description}):null]},e.label)}),e.allowFreeText===!1?null:(0,z.jsx)(k,{type:`button`,variant:`outline`,"aria-pressed":r,"aria-expanded":r,"aria-controls":r?c:void 0,disabled:t,onClick:o,size:`block`,className:d(`px-2.5`,f.length%2==0&&`sm:col-span-2`,r&&`border-accent-strong bg-accent-strong/15 ring-1 ring-accent-strong/30 pointer-hover:border-accent-strong pointer-hover:bg-accent-strong/15`),children:`Other`})]}),e.allowFreeText!==!1&&r?(0,z.jsxs)(`div`,{className:`mt-2`,children:[(0,z.jsx)(`label`,{htmlFor:c,className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Your answer`}),(0,z.jsx)(F,{ref:l,id:c,rows:2,value:i,disabled:t,placeholder:`Type your custom answer…`,onChange:e=>s(e.target.value),className:`bg-card text-base md:text-[13px]`})]}):null]}):(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{htmlFor:c,className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Your answer`}),(0,z.jsx)(F,{id:c,rows:2,value:i,disabled:t,placeholder:`Type your answer…`,onChange:e=>s(e.target.value),className:`bg-card text-base md:text-[13px]`})]})]})}export{q as A,Dt as C,yt as D,Ct as E,Qe as F,W as I,$e as L,ut as M,rt as N,xt as O,U as P,Ae as R,Et as S,Tt as T,X as _,pn as a,bt as b,Zt as c,Wt as d,Qt as f,Rt as g,Lt as h,mn as i,ft as j,gt as k,dn as l,zt as m,$ as n,gn as o,Vt as p,Yt as r,Xt as s,bn as t,hn as u,Pt as v,wt as w,_t as x,vt as y,L as z};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{oi as e,ti as t}from"./toaster-2ud_VdfV.js";function n(n){return t[e(n).bucket]<=t.waiting}export{n as t};
|