hive-am 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -1
- package/README.md +1 -5
- package/bin/hive-am.mjs +242 -31
- package/bin/run.mjs +135 -0
- package/package.json +1 -1
- package/server/dist/connections/manager.js +15 -3
- package/server/dist/connections/router.js +2 -2
- package/server/dist/connections/secrets.js +8 -0
- package/server/dist/db/migrations.js +68 -0
- package/server/dist/db.js +11 -10
- package/server/dist/efforts.js +105 -0
- package/server/dist/http/routes/agents.js +4 -3
- package/server/dist/http/routes/meta.js +12 -0
- package/server/dist/http/routes/notebook.js +10 -2
- package/server/dist/http/routes/resources.js +3 -0
- package/server/dist/http/routes/types.js +18 -1
- package/server/dist/http/validate.js +5 -2
- package/server/dist/index.js +4 -1
- package/server/dist/instructions.js +10 -2
- package/server/dist/objects/agent-db.js +258 -0
- package/server/dist/objects/database.js +496 -34
- package/server/dist/objects/index.js +16 -8
- package/server/dist/providers/kiro.js +7 -1
- package/server/dist/providers/opencode-server.js +11 -1
- package/server/dist/providers/opencode.js +4 -3
- package/server/dist/providers/spawn.js +38 -4
- package/server/dist/retention.js +50 -0
- package/server/dist/runtime.js +52 -21
- package/server/dist/services/agents.js +53 -1
- package/server/dist/services/notebook.js +7 -3
- package/server/dist/skills/defaults.js +35 -1
- package/server/dist/skills/notebook.js +57 -13
- package/server/mcp/dispatch.mjs +68 -0
- package/web/.next/BUILD_ID +1 -1
- package/web/.next/app-build-manifest.json +60 -60
- package/web/.next/app-path-routes-manifest.json +7 -7
- package/web/.next/build-manifest.json +2 -2
- package/web/.next/prerender-manifest.json +58 -58
- package/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/_not-found.html +1 -1
- package/web/.next/server/app/_not-found.rsc +3 -3
- package/web/.next/server/app/agents/[id]/page.js +4 -4
- package/web/.next/server/app/agents/[id]/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/agents/page.js +2 -2
- package/web/.next/server/app/agents/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/agents.html +1 -1
- package/web/.next/server/app/agents.rsc +4 -4
- package/web/.next/server/app/chat/page.js +1 -1
- package/web/.next/server/app/chat/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/chat.html +1 -1
- package/web/.next/server/app/chat.rsc +4 -4
- package/web/.next/server/app/connections/page.js +1 -1
- package/web/.next/server/app/connections/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/connections.html +1 -1
- package/web/.next/server/app/connections.rsc +4 -4
- package/web/.next/server/app/index.html +1 -1
- package/web/.next/server/app/index.rsc +4 -4
- package/web/.next/server/app/page.js +1 -1
- package/web/.next/server/app/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/relations/page.js +1 -1
- package/web/.next/server/app/relations/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/relations.html +1 -1
- package/web/.next/server/app/relations.rsc +4 -4
- package/web/.next/server/app/resources/[id]/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/resources/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/resources.html +1 -1
- package/web/.next/server/app/resources.rsc +4 -4
- package/web/.next/server/app/schedules/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/schedules.html +1 -1
- package/web/.next/server/app/schedules.rsc +4 -4
- package/web/.next/server/app/sessions/page.js +1 -1
- package/web/.next/server/app/sessions/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/sessions.html +1 -1
- package/web/.next/server/app/sessions.rsc +4 -4
- package/web/.next/server/app/skills/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/skills.html +1 -1
- package/web/.next/server/app/skills.rsc +4 -4
- package/web/.next/server/app/types/page.js +1 -1
- package/web/.next/server/app/types/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/types.html +1 -1
- package/web/.next/server/app/types.rsc +4 -4
- package/web/.next/server/app-paths-manifest.json +7 -7
- package/web/.next/server/chunks/143.js +1 -1
- package/web/.next/server/chunks/213.js +1 -1
- package/web/.next/server/chunks/274.js +1 -1
- package/web/.next/server/chunks/368.js +1 -1
- package/web/.next/server/chunks/403.js +1 -1
- package/web/.next/server/chunks/612.js +1 -1
- package/web/.next/server/pages/404.html +1 -1
- package/web/.next/server/pages/500.html +1 -1
- package/web/.next/server/server-reference-manifest.json +1 -1
- package/web/.next/static/chunks/{316-26da9cc233ba7557.js → 107-77dd87cc2ca4f941.js} +1 -1
- package/web/.next/static/chunks/281-30e32d932b8b5a75.js +1 -0
- package/web/.next/static/chunks/517-b3b1c9044d2ef23c.js +1 -0
- package/web/.next/static/chunks/587-5b511f5f93910180.js +1 -0
- package/web/.next/static/chunks/606-14fb5aaa4d0ff22d.js +1 -0
- package/web/.next/static/chunks/656-f3cc78328603241a.js +1 -0
- package/web/.next/static/chunks/{705-f81face97b1bb1af.js → 705-ce86175dea00e6a9.js} +1 -1
- package/web/.next/static/chunks/757-03361e7a97a605a2.js +1 -0
- package/web/.next/static/chunks/app/agents/[id]/page-638e12ba3cb813c3.js +1 -0
- package/web/.next/static/chunks/app/agents/page-9da499db6d22731f.js +1 -0
- package/web/.next/static/chunks/app/chat/{page-5261b12b7d50f5d1.js → page-383bc24e72dab7fa.js} +1 -1
- package/web/.next/static/chunks/app/connections/{page-eb11cfb1ffeab3ca.js → page-06bd2d7d9495126a.js} +1 -1
- package/web/.next/static/chunks/app/page-0062ebc30322b1ae.js +1 -0
- package/web/.next/static/chunks/app/relations/page-02710fe1f8a670a9.js +1 -0
- package/web/.next/static/chunks/app/sessions/page-85638705fdc18174.js +1 -0
- package/web/.next/static/chunks/app/types/page-8e25f503bdcd72ad.js +1 -0
- package/web/.next/static/css/dfcaa19a8d46e60d.css +1 -0
- package/web/.next/trace +30 -30
- package/web/.next/static/chunks/281-113274e705940a55.js +0 -1
- package/web/.next/static/chunks/517-373a80c8ba432bdc.js +0 -1
- package/web/.next/static/chunks/562-7c2e33d838e869bf.js +0 -1
- package/web/.next/static/chunks/587-8e4d2be01ba7d48f.js +0 -1
- package/web/.next/static/chunks/606-c9a19918b02a98d0.js +0 -1
- package/web/.next/static/chunks/656-f537149fe28f79aa.js +0 -1
- package/web/.next/static/chunks/app/agents/[id]/page-6ed6edb3e74b0ebe.js +0 -1
- package/web/.next/static/chunks/app/agents/page-9bb8cba69776c719.js +0 -1
- package/web/.next/static/chunks/app/page-99e0351e6ccaa384.js +0 -1
- package/web/.next/static/chunks/app/relations/page-a44fd515a3b0525e.js +0 -1
- package/web/.next/static/chunks/app/sessions/page-a7534ebd90e982d6.js +0 -1
- package/web/.next/static/chunks/app/types/page-ebd37e220f77c1f3.js +0 -1
- package/web/.next/static/css/582723fcea1f9887.css +0 -1
- /package/web/.next/static/{YT6HM6qmegMJaBMX5QvuP → UDA414PFPu9ZROltNmjbX}/_buildManifest.js +0 -0
- /package/web/.next/static/{YT6HM6qmegMJaBMX5QvuP → UDA414PFPu9ZROltNmjbX}/_ssgManifest.js +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[969],{16054:(e,s,t)=>{Promise.resolve().then(t.bind(t,44209))},44209:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>sw});var a=t(94799),n=t(20422),l=t(89128),i=t(34023),c=t(41463),r=t.n(c),o=t(43624),d=t(75406),h=t(32098),u=t(68449),m=t(97541),g=t(48538),x=t(3749),p=t(47890),j=t(54609),b=t(77021),f=t(61748),v=t(51705),N=t(44738),y=t(14214),k=t(84611),w=t(29718),C=t(8089),S=t(50352),A=t(12349),z=t(56072),E=t(69654);function M(e){var s,t,n,l,c,r,o,d,h,u;let{agent:m,session:p}=e,{t:j}=(0,E.s9)(),{finished:b,live:f}=(0,g.o0)(),[v,M]=(0,i.useState)(null),[F,R]=(0,i.useState)(!1),P=null!=(s=b[m.id])?s:0,_=f[m.id];if((0,i.useEffect)(()=>{if(!m.session_id&&!p)return void M(null);x.FH.get("/agents/".concat(m.id,"/stats").concat(p?"?session=".concat(encodeURIComponent(p)):"")).then(M).catch(()=>void 0)},[m.id,m.session_id,p,P]),!v||0===v.turns&&!_)return null;let L=null==_?void 0:_.usage,I=(0,z.RP)(v.usage)+(L?(0,z.RP)({input:null!=(t=L.input)?t:0,output:null!=(n=L.output)?n:0,cacheRead:null!=(l=L.cacheRead)?l:0,cacheWrite:null!=(c=L.cacheWrite)?c:0}):0),T=(null!=(r=v.cost)?r:0)+(null!=(o=null==_?void 0:_.cost)?o:0),H=(null!=(d=v.usage.credits)?d:0)+(null!=(h=null==L?void 0:L.credits)?h:0),U=null!=(u=null==L?void 0:L.contextPct)?u:v.contextPct,D=null!==v.cost||(null==_?void 0:_.cost)!==void 0,K=v.usage,W=Math.max(1,K.input+K.output+K.cacheRead+K.cacheWrite),O=Math.max(1,...v.tools.map(e=>e.count)),q=Math.max(1,...v.timeline.map(e=>e.tokens));return(0,a.jsxs)("div",{className:"stats-wrap",children:[(0,a.jsxs)("button",{className:"statsbar",onClick:()=>R(e=>!e),"aria-expanded":F,children:[(0,a.jsxs)("span",{className:"sb",title:"".concat(j("stats.contextTitle")," \xb7 ").concat((0,z.yj)(v.lastContext)).concat(v.contextWindow?" / ".concat((0,z.yj)(v.contextWindow)):""),children:[(0,a.jsx)(N.A,{size:14}),(0,a.jsx)("b",{children:null!==U?"".concat(U.toFixed(+(U<10)),"%"):(0,z.yj)(v.lastContext)}),j("stats.context")]}),(0,a.jsxs)("span",{className:"sb",children:[(0,a.jsx)(y.A,{size:14}),(0,a.jsx)("b",{children:(0,z.yj)(I)}),j("stats.tokens")]}),H>0&&(0,a.jsxs)("span",{className:"sb",children:[(0,a.jsx)(k.A,{size:14}),(0,a.jsx)("b",{children:H.toFixed(2)}),j("stats.credits")]}),D&&(0,a.jsxs)("span",{className:"sb",title:v.costEstimated?j("stats.costEstimated"):j("stats.costReported"),children:[(0,a.jsx)(k.A,{size:14}),(0,a.jsxs)("b",{children:[v.costEstimated?"≈ ":"",(0,z.F0)(T)]})]}),(0,a.jsxs)("span",{className:"sb",children:[(0,a.jsx)(w.A,{size:14}),(0,a.jsx)("b",{children:v.turns}),j("stats.turns",{count:v.turns})]}),(0,a.jsxs)("span",{className:"sb",children:[(0,a.jsx)(C.A,{size:14}),(0,a.jsx)("b",{children:v.toolCalls}),j("stats.toolCalls",{count:v.toolCalls}),v.toolErrors>0&&(0,a.jsxs)("em",{className:"tbad",children:[" \xb7 ",j("stats.failed",{count:v.toolErrors})]})]}),v.durationMs>0&&(0,a.jsxs)("span",{className:"sb",children:[(0,a.jsx)(S.A,{size:14}),(0,a.jsx)("b",{children:(0,z.nc)(v.durationMs)}),j("stats.working")]}),(0,a.jsx)(A.A,{size:15,className:"chev2 ".concat(F?"open":"")})]}),F&&(0,a.jsxs)("div",{className:"statspanel",children:[(0,a.jsxs)("section",{children:[(0,a.jsx)("div",{className:"eyebrow",children:j("stats.mix")}),(0,a.jsxs)("div",{className:"mixbar",role:"img","aria-label":j("stats.mix"),children:[(0,a.jsx)("i",{className:"fa-c-cr",style:{width:"".concat(K.cacheRead/W*100,"%")}}),(0,a.jsx)("i",{className:"fa-c-cw",style:{width:"".concat(K.cacheWrite/W*100,"%")}}),(0,a.jsx)("i",{className:"fa-c-in",style:{width:"".concat(K.input/W*100,"%")}}),(0,a.jsx)("i",{className:"fa-c-out",style:{width:"".concat(K.output/W*100,"%")}})]}),(0,a.jsxs)("dl",{className:"legend",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("i",{className:"fa-c-cr"}),(0,a.jsx)("dt",{children:j("stats.cacheRead")}),(0,a.jsx)("dd",{children:(0,z.yj)(K.cacheRead)})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("i",{className:"fa-c-cw"}),(0,a.jsx)("dt",{children:j("stats.cacheWrite")}),(0,a.jsx)("dd",{children:(0,z.yj)(K.cacheWrite)})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("i",{className:"fa-c-in"}),(0,a.jsx)("dt",{children:j("stats.input")}),(0,a.jsx)("dd",{children:(0,z.yj)(K.input)})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("i",{className:"fa-c-out"}),(0,a.jsx)("dt",{children:j("stats.output")}),(0,a.jsxs)("dd",{children:[(0,z.yj)(K.output),K.reasoning>0&&(0,a.jsxs)("span",{className:"muted",children:[" (",j("stats.thinking",{tokens:(0,z.yj)(K.reasoning)}),")"]})]})]})]}),v.models.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"eyebrow mt-m",children:j("stats.models")}),v.models.map(e=>(0,a.jsxs)("div",{className:"row small between",children:[(0,a.jsx)("span",{className:"mono",children:e.model}),(0,a.jsx)("span",{className:"muted",children:j("stats.modelLine",{count:e.messages,out:(0,z.yj)(e.output)})})]},e.model))]})]}),(0,a.jsxs)("section",{children:[(0,a.jsxs)("div",{className:"eyebrow",children:[j("stats.toolsUsed")," ",v.toolTimeMs>0&&(0,a.jsxs)("span",{className:"muted",children:["\xb7 ",j("stats.totalTime",{time:(0,z.nc)(v.toolTimeMs)})]})]}),0===v.tools.length?(0,a.jsx)("p",{className:"muted small m0 mt-s",children:j("stats.noTools")}):v.tools.slice(0,9).map(e=>(0,a.jsxs)("div",{className:"toolrow",title:j("stats.toolTitle",{count:e.count,time:(0,z.nc)(e.totalMs)}),children:[(0,a.jsx)("span",{className:"mono tn",children:e.name.replace(/^mcp__/,"").replace("__"," \xb7 ")}),(0,a.jsx)("span",{className:"tbar",children:(0,a.jsx)("i",{style:{width:"".concat(e.count/O*100,"%")}})}),(0,a.jsxs)("span",{className:"tc",children:[e.count,e.errors>0&&(0,a.jsxs)("em",{className:"tbad",children:[" (",e.errors,"✗)"]})]}),(0,a.jsx)("span",{className:"td muted",children:e.totalMs?(0,z.nc)(e.totalMs/e.count):""})]},e.name))]}),(0,a.jsxs)("section",{className:"fa-span",children:[(0,a.jsx)("div",{className:"eyebrow",children:j("stats.perTurn")}),(0,a.jsx)("div",{className:"tbars",role:"list",children:v.timeline.slice(-40).map((e,s)=>(0,a.jsx)("div",{className:"sbar",role:"listitem",title:"".concat(e.prompt||j("stats.promptFallback"),"\n").concat(j("stats.turnLine",{tokens:(0,z.yj)(e.tokens),tools:e.tools,time:(0,z.nc)(e.durationMs)})).concat(null!==e.cost?" \xb7 ".concat((0,z.F0)(e.cost)):""),children:(0,a.jsx)("i",{style:{height:"".concat(Math.max(4,e.tokens/q*100),"%")}})},s))})]})]})]})}var F=t(29416),R=t(59959),P=t(83372),_=t(47405),L=t(6673),I=t(7991),T=t(31606),H=t(74988),U=t(52974),D=t(10804);let K=["error","starting","running","ready","stopped","unknown"];function W(e){let{agent:s}=e,{t}=(0,E.s9)(),{objects:n}=(0,g.o0)(),l=(0,D.dj)(),[c,o]=(0,b.ud)("hive-am.chat.resources",!1),[d,h]=(0,b.ud)("hive-am.chat.resources.scope","mine"),[u,m]=(0,i.useState)(null);if(0===n.length)return null;let p=n.filter(e=>{var t,a;return e.manager_id===s.id||(null!=(t=e.colony_id)?t:null)===(null!=(a=s.colony_id)?a:null)}),j="all"===d||0===p.length,f=j?n:p,v=e=>f.filter(s=>s.state.status===e).length,N=async(e,s)=>{m("".concat(e.id,":").concat(s));try{await x.FH.post("/objects/".concat(e.id,"/action"),{action:s})}catch(e){l("".concat(t("obj.act.failed",{action:t("obj.act.".concat(s))}),": ").concat(e instanceof Error?e.message:""),"err")}finally{m(null)}};return(0,a.jsxs)("div",{className:"cres",children:[(0,a.jsxs)("button",{type:"button",className:"cres-head","aria-expanded":c,onClick:()=>o(!c),children:[(0,a.jsx)(F.A,{size:15,"aria-hidden":!0}),(0,a.jsx)("b",{children:t("cres.title")}),(0,a.jsx)("span",{className:"cres-sum",children:K.filter(e=>v(e)>0).map(e=>(0,a.jsxs)("span",{className:"cres-n ".concat(H.Wy[e]),children:[(0,a.jsx)(T.md,{status:e}),v(e)," ",(0,a.jsx)("em",{children:t("cres.n.".concat(e))})]},e))}),(0,a.jsx)(A.A,{size:15,className:"chev2 ".concat(c?"open":""),"aria-hidden":!0})]}),c&&(0,a.jsxs)("div",{className:"cres-body",children:[p.length>0&&p.length<n.length&&(0,a.jsxs)("div",{className:"seg cres-scope",role:"group","aria-label":t("cres.scope"),children:[(0,a.jsx)("button",{type:"button","aria-pressed":!j,onClick:()=>h("mine"),children:t("cres.mine",{a1:String(p.length)})}),(0,a.jsx)("button",{type:"button","aria-pressed":j,onClick:()=>h("all"),children:t("cres.all",{a1:String(n.length)})})]}),0===p.length&&(0,a.jsx)("p",{className:"muted small cres-note",children:t("cres.none")}),(0,a.jsx)("ul",{className:"cres-grid",children:f.map(e=>{var s;let n=H.Nd[e.kind].icon,l=e.state.status,i="running"===l||"starting"===l,c=U.G.includes(e.kind),o=null!=(s=null==u?void 0:u.startsWith("".concat(e.id,":")))&&s,d=(0,H.HS)(t,e.state.detail);return(0,a.jsxs)("li",{className:"cres-card ".concat(H.Wy[l]),children:[(0,a.jsx)("span",{className:"cres-ico",style:{"--c":H.Nd[e.kind].color},children:(0,a.jsx)(n,{size:16,"aria-hidden":!0})}),(0,a.jsxs)("div",{className:"cres-info",children:[(0,a.jsx)(r(),{className:"cres-name",href:"/resources/".concat(e.id),title:t("obj.open"),children:e.name}),(0,a.jsxs)("span",{className:"cres-st ".concat(H.Wy[l]),title:d||void 0,children:[(0,a.jsx)(T.md,{status:l}),t("obj.status.".concat(l)),d&&"error"===l?(0,a.jsx)("em",{children:d}):null]})]}),(0,a.jsxs)("div",{className:"cres-act",children:[o&&(0,a.jsx)(R.A,{size:14,className:"spin muted","aria-hidden":!0}),c&&(i?(0,a.jsx)("button",{type:"button",className:"btn ghost icon sm",disabled:!!u,onClick:()=>void N(e,"stop"),"aria-label":t("obj.act.stop"),title:t("obj.act.stop"),children:(0,a.jsx)(P.A,{size:14})}):(0,a.jsx)("button",{type:"button",className:"btn ghost icon sm",disabled:!!u,onClick:()=>void N(e,"start"),"aria-label":t("obj.act.start"),title:t("obj.act.start"),children:(0,a.jsx)(_.A,{size:14})})),c&&(0,a.jsx)("button",{type:"button",className:"btn ghost icon sm",disabled:!!u,onClick:()=>void N(e,"restart"),"aria-label":t("obj.act.restart"),title:t("obj.act.restart"),children:(0,a.jsx)(L.A,{size:14})}),(0,a.jsx)(r(),{className:"btn ghost icon sm",href:"/resources/".concat(e.id),"aria-label":t("obj.open"),title:t("obj.open"),children:(0,a.jsx)(I.A,{size:14})})]})]},e.id)})})]})]})}var O=t(33974),q=t(78330),$=t(92947),B=t(58311),G=t(72942),J=t(5372),Q=t(1517);function X(e){let{activeId:s,collapsed:t=!1,onToggle:n}=e,{t:l}=(0,E.s9)(),{agents:c,colonies:o,live:d}=(0,g.o0)(),h=(0,J.z6)(),[u,m]=(0,i.useState)(""),[x,j]=(0,i.useState)(!1),b=(0,i.useMemo)(()=>{let e=e=>!u||"".concat(e.name," ").concat(e.description," ").concat(e.provider," ").concat(e.model).toLowerCase().includes(u.toLowerCase()),s=o.map(s=>({key:s.id,name:s.name,color:s.color||"var(--honey)",items:c.filter(t=>t.colony_id===s.id&&e(t))}));return s.push({key:"free",name:l("common.noColony"),color:null,items:c.filter(s=>(!s.colony_id||!o.some(e=>e.id===s.colony_id))&&e(s))}),s.filter(e=>e.items.length)},[c,o,u,l]),f=n&&(0,a.jsx)("button",{className:"btn ghost icon sm",onClick:n,"aria-label":t?l("switcher.expand"):l("switcher.collapse"),title:t?l("switcher.expand"):l("switcher.collapse"),"aria-expanded":!t,children:t?(0,a.jsx)(O.A,{size:17}):(0,a.jsx)(q.A,{size:17})});return t?(0,a.jsxs)("aside",{className:"switcher mini","aria-label":l("nav.agents"),children:[(0,a.jsxs)("div",{className:"switcher-head",children:[f,(0,a.jsx)("button",{className:"btn ghost icon sm",onClick:()=>j(!0),"aria-label":l("newAgent.title"),title:l("newAgent.title"),children:(0,a.jsx)($.A,{size:16})})]}),(0,a.jsx)("div",{className:"switcher-list",children:b.map(e=>(0,a.jsxs)("div",{className:"mini-group",children:[(0,a.jsx)("div",{className:"mini-sep",title:"".concat(e.name," \xb7 ").concat(e.items.length),style:e.color?{"--c":e.color}:void 0}),e.items.map(e=>(0,a.jsx)(r(),{href:"/agents/".concat(e.id),className:"sw-item mini","aria-current":e.id===s?"page":void 0,"aria-label":e.name,...h.bind(e.id),children:(0,a.jsxs)("span",{className:"sw-av",children:[(0,a.jsx)(D._h,{agent:e}),"idle"!==e.status&&(0,a.jsx)("i",{className:"pip ".concat("error"===e.status?"err":"")})]})},e.id))]},e.key))}),x&&(0,a.jsx)(Q.b,{onClose:()=>j(!1)}),h.node]}):(0,a.jsxs)("aside",{className:"switcher","aria-label":l("nav.agents"),children:[(0,a.jsxs)("div",{className:"switcher-head",children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("b",{style:{fontFamily:"var(--font-display)",fontSize:16},className:"grow",children:l("nav.agents")}),f,(0,a.jsx)("button",{className:"btn ghost icon sm",onClick:()=>j(!0),"aria-label":l("newAgent.title"),children:(0,a.jsx)($.A,{size:16})})]}),(0,a.jsxs)("div",{className:"search",children:[(0,a.jsx)(B.A,{size:15}),(0,a.jsx)("input",{className:"input",placeholder:l("switcher.find"),value:u,onChange:e=>m(e.target.value),"aria-label":l("switcher.find")})]})]}),(0,a.jsxs)("div",{className:"switcher-list",children:[0===b.length&&(0,a.jsx)("p",{className:"muted small",style:{padding:16},children:l("switcher.noMatch",{query:u})}),b.map(e=>(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"switcher-group",children:[e.color&&(0,a.jsx)("i",{className:"cdot",style:{background:e.color}}),e.name,(0,a.jsx)("span",{children:e.items.length})]}),e.items.map(e=>{let t=(0,G.E)(d[e.id]);return(0,a.jsxs)(r(),{href:"/agents/".concat(e.id),className:"sw-item","aria-current":e.id===s?"page":void 0,...h.bind(e.id),children:[(0,a.jsxs)("span",{className:"sw-av",children:[(0,a.jsx)(D._h,{agent:e}),"idle"!==e.status&&(0,a.jsx)("i",{className:"pip ".concat("error"===e.status?"err":"")})]}),(0,a.jsxs)("span",{className:"sw-body",children:[(0,a.jsxs)("span",{className:"sw-top",children:[(0,a.jsx)("b",{children:e.name}),"orchestrator"===e.role&&(0,a.jsx)("em",{children:l("role.orchestrator")})]}),(0,a.jsx)("span",{className:"sw-sub ".concat(t?"live":e.description?"":"blank"),children:null!=t?t:"error"===e.status?l("status.error"):e.description||l("switcher.noDescription")}),(0,a.jsxs)("span",{className:"sw-meta",children:[(0,a.jsx)("i",{style:{background:p.xq[e.provider].color}}),p.xq[e.provider].short,e.model?" \xb7 ".concat(e.model):"",(0,a.jsx)("span",{className:"sw-ago",children:e.queued&&e.queued>0?l("queue.count",{count:e.queued}):(0,p.KN)(e.updated_at)})]})]})]},e.id)})]},e.key))]}),x&&(0,a.jsx)(Q.b,{onClose:()=>j(!1)}),h.node]})}var Y=t(94227),Z=t(89075),V=t(10776),ee=t(79141),es=t(12582),et=t(25661),ea=t(68979),en=t(76844);function el(e,s){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},n=new Map(s.map(e=>[e.path,e])),l=new Set(e);for(let e of s)l.add(e.path);let i={name:"",path:"",type:"dir",children:[],changed:0,additions:0,deletions:0},c=new Map([["",i]]),r=e=>{let s=c.get(e);if(s)return s;let t=e.lastIndexOf("/"),a=r(t<0?"":e.slice(0,t)),n={name:e.slice(t+1),path:e,type:"dir",children:[],changed:0,additions:0,deletions:0};return a.children.push(n),c.set(e,n),n};for(let e of l){var o,d,h,u;let s=e.lastIndexOf("/");r(s<0?"":e.slice(0,s)).children.push({name:e.slice(s+1),path:e,type:"file",children:[],change:n.get(e),changed:+!!n.has(e),additions:null!=(h=null==(o=n.get(e))?void 0:o.additions)?h:0,deletions:null!=(u=null==(d=n.get(e))?void 0:d.deletions)?u:0})}let m=(e,s,t)=>{var n;if(e.children.some(e=>e.path===s))return;let l={name:s.slice(s.lastIndexOf("/")+1),path:s,type:t?"dir":"file",children:[],ignored:!0,lazy:t&&!(s in a),changed:0,additions:0,deletions:0};if(e.children.push(l),t&&c.set(s,l),t)for(let e of null!=(n=a[s])?n:[])m(l,"".concat(s,"/").concat(e.name),e.dir)};for(let e of t){let s=e.endsWith("/"),t=s?e.slice(0,-1):e,a=t.lastIndexOf("/");m(r(a<0?"":t.slice(0,a)),t,s)}let g=e=>{for(let s of(e.children.sort((e,s)=>e.type===s.type?e.name.localeCompare(s.name):"dir"===e.type?-1:1),e.children))"dir"===s.type&&g(s),e.changed+=(s.type,s.changed),e.additions+=s.additions,e.deletions+=s.deletions;e.children=e.children.map(e=>{let s=e;for(;"dir"===s.type&&1===s.children.length&&"dir"===s.children[0].type;){let e=s.children[0];s={...e,name:"".concat(s.name,"/").concat(e.name)}}return s})};return g(i),i}function ei(e,s,t){let a=t.query.trim().toLowerCase(),n=e=>(!t.onlyChanged||0!==e.changed)&&(!a||("file"===e.type?e.path.toLowerCase().includes(a):e.children.some(n))),l=[],i=(e,c)=>{for(let r of e.children)n(r)&&(l.push({node:r,depth:c}),"dir"===r.type&&(a||t.onlyChanged||s.has(r.path))&&i(r,c+1))};return i(e,0),l}var ec=t(10969),er=t(39696),eo=t(78060),ed=t(61),eh=t(80306),eu=t(6458),em=t(53983);let eg=/\.(png|jpe?g|gif|webp|svg|ico|bmp|avif)$/i,ex=/\.(md|markdown|mdx)$/i;var ep=t(32480),ej=t(70665);function eb(e){let s={meta:[],hunks:[],binary:!1},t=null,a=0,n=0;for(let i of e.split("\n")){let e=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@ ?(.*)$/.exec(i);if(e){var l;a=Number(e[1]),n=Number(e[2]),t={header:i,section:null!=(l=e[3])?l:"",lines:[]},s.hunks.push(t);continue}if(!t){/^Binary files .* differ$/.test(i)||i.startsWith("GIT binary patch")?s.binary=!0:(/^(rename|copy) (from|to) /.test(i)||/^(new|deleted) file mode/.test(i)||/^similarity index/.test(i))&&s.meta.push(i);continue}let c=i[0];if("+"===c)t.lines.push({kind:"add",newNo:n++,text:i.slice(1)});else if("-"===c)t.lines.push({kind:"del",oldNo:a++,text:i.slice(1)});else if(" "===c)t.lines.push({kind:"ctx",oldNo:a++,newNo:n++,text:i.slice(1)});else if("\\"===c){let e=t.lines[t.lines.length-1];e&&(e.noEol=!0)}}return s}let ef=e=>{var s,t;return null!=(t=null==(s=/^(@@ [^@]+@@)/.exec(e))?void 0:s[1])?t:e};var ev=t(3218),eN=t(97254),ey=t(55267),ek=t(69962),ew=t(58099);let eC=(0,i.memo)(function(e){var s,t,n,l,i,c,r,o;let{row:d,path:h,ws:u,actions:m,picking:g,onPick:x}=e,{t:p}=(0,E.s9)();if("hunk"===d.t)return(0,a.jsxs)("div",{className:"vl-row hunk",children:[(0,a.jsx)("div",{className:"vl-ln",style:{left:0},children:"⋯"}),(0,a.jsx)("div",{className:"vl-ln",style:{left:"calc(6ch + 16px)"},children:"⋯"}),(0,a.jsxs)("div",{className:"vl-hl",children:[(0,a.jsx)("span",{className:"rng mono",children:d.header}),d.section&&(0,a.jsx)("span",{className:"hs",title:d.section,children:d.section}),m&&(null==g?void 0:g.hunk)===d.idx?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{type:"button",className:"hk-btn on",onClick:()=>m.pickAll(d.idx,d.changed),children:p("git.discard.lines.all")}),(0,a.jsxs)("button",{type:"button",className:"hk-btn danger on",disabled:!g.picked.size,onClick:()=>m.discardPicked(d.idx,d.header),children:[(0,a.jsx)(es.A,{size:12}),p("git.discard.lines.go",{count:g.picked.size})]}),(0,a.jsx)("button",{type:"button",className:"hk-btn on",onClick:m.stopPicking,children:p("common.cancel")})]}):m&&(0,a.jsxs)(a.Fragment,{children:[d.changed>0&&m.canPick&&(0,a.jsxs)("button",{type:"button",className:"hk-btn",title:p("git.discard.lines.hint"),onClick:()=>m.startPicking(d.idx),children:[(0,a.jsx)(ey.A,{size:12}),p("git.discard.lines")]}),(0,a.jsxs)("button",{type:"button",className:"hk-btn",title:p("git.discard.hunk.hint"),onClick:()=>m.discardHunk(d.idx,d.header),children:[(0,a.jsx)(es.A,{size:12}),p("git.discard.hunk")]})]})]})]});if("line"===d.t){let e=d.l;return(0,a.jsxs)("div",{className:"vl-row ".concat(e.kind," ").concat(x&&void 0!==d.k&&(null==g?void 0:g.picked.has(d.k))?"picked":""),onClick:x&&void 0!==d.k?()=>x(d.k):void 0,children:[(0,a.jsx)("div",{className:"vl-ln",style:{left:0},children:null!=(s=e.oldNo)?s:""}),(0,a.jsx)("div",{className:"vl-ln",style:{left:"calc(6ch + 16px)"},children:null!=(t=e.newNo)?t:""}),(0,a.jsx)("div",{className:"vl-sg",children:x&&void 0!==d.k?(0,a.jsx)("input",{type:"checkbox",checked:!!(null==g?void 0:g.picked.has(d.k)),onChange:()=>void 0,"aria-label":p("git.discard.lines.pick")}):"add"===e.kind?"+":"del"===e.kind?"−":""}),(0,a.jsx)("div",{className:"vl-cd",children:(0,a.jsx)(eN.SH,{text:e.text,path:h,ws:u})})]})}let{left:j,right:b}=d.r;return(0,a.jsxs)("div",{className:"vl-row split",children:[(0,a.jsx)("div",{className:"vl-ln ".concat(null!=(n=null==j?void 0:j.kind)?n:"void"),style:{left:0},children:null!=(l=null==j?void 0:j.oldNo)?l:""}),(0,a.jsx)("div",{className:"vl-cd ".concat(null!=(i=null==j?void 0:j.kind)?i:"void"),title:j&&j.text.length>60?j.text:void 0,children:j?(0,a.jsx)(eN.SH,{text:j.text,path:h,ws:u}):null}),(0,a.jsx)("div",{className:"vl-ln ".concat(null!=(c=null==b?void 0:b.kind)?c:"void"),children:null!=(r=null==b?void 0:b.newNo)?r:""}),(0,a.jsx)("div",{className:"vl-cd ".concat(null!=(o=null==b?void 0:b.kind)?o:"void"),title:b&&b.text.length>60?b.text:void 0,children:b?(0,a.jsx)(eN.SH,{text:b.text,path:h,ws:u}):null})]})});function eS(e){let{parsed:s,layout:t,path:n,cutOff:l=!1,firstIndex:c=0,onDiscardHunk:r,onDiscardLines:o}=e,{whitespace:d}=(0,er.Wx)(),h=(0,i.useMemo)(()=>(function(e,s,t){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,n=[],l=(0,ek.KJ)(t);return e.hunks.forEach((e,t)=>{n.push({t:"hunk",idx:t+a,header:ef(e.header),section:l?e.section:"",changed:e.lines.filter(e=>"ctx"!==e.kind).length});let i=0;if("unified"===s)for(let s of e.lines)n.push({t:"line",l:s,hunk:t+a,k:"ctx"===s.kind?void 0:i++});else for(let s of function(e){let s=[];for(let t=0;t<e.length;){let a=e[t];if("ctx"===a.kind){s.push({left:a,right:a}),t++;continue}let n=[],l=[];for(;t<e.length&&"del"===e[t].kind;)n.push(e[t++]);for(;t<e.length&&"add"===e[t].kind;)l.push(e[t++]);for(let e=0;e<Math.max(n.length,l.length);e++)s.push({left:n[e],right:l[e]})}return s}(e.lines))n.push({t:"pair",r:s})}),n})(s,t,n,c),[s,t,n,c]),u=(0,i.useMemo)(()=>s.hunks.reduce((e,s)=>s.lines.reduce((e,s)=>Math.max(e,s.text.length),e),0),[s]),m="unified"===t?"calc(12ch + 32px + 18px + ".concat(u,"ch + 24px)"):void 0,g=(0,i.useRef)(null),x=(0,i.useRef)(null),[p,j]=(0,i.useState)({max:0,track:0});(0,i.useEffect)(()=>{let e=g.current;if(!e||"split"!==t)return void j({max:0,track:0});let s=()=>{let s=e.querySelector(".vl");if(!s)return;let t=document.createElement("canvas").getContext("2d");if(!t)return;t.font=getComputedStyle(s).font;let a=t.measureText("0").width,n=(e.clientWidth-2*(6*a+16))/2;j({max:Math.max(0,Math.ceil(u*a+24-n)),track:e.clientWidth})};s();let a=new ResizeObserver(s);return a.observe(e),()=>a.disconnect()},[t,u,h.length]),(0,i.useEffect)(()=>{var e;x.current&&(x.current.scrollLeft=0),null==(e=g.current)||e.style.setProperty("--hx","0px")},[s,t]),(0,i.useEffect)(()=>{let e=g.current;if(!e||"split"!==t)return;let s=e=>{let s=Math.abs(e.deltaX)>Math.abs(e.deltaY)?e.deltaX:e.shiftKey?e.deltaY:0;s&&x.current&&(e.preventDefault(),x.current.scrollLeft+=s)};return e.addEventListener("wheel",s,{passive:!1}),()=>e.removeEventListener("wheel",s)},[t]);let[b,f]=(0,i.useState)(null);(0,i.useEffect)(()=>{f(null)},[s,t]);let v=e=>f(s=>{if(!s)return s;let t=new Set(s.picked);return t.has(e)?t.delete(e):t.add(e),{...s,picked:t}}),N=r?{canPick:"unified"===t&&!!o,discardHunk:r,startPicking:e=>f({hunk:e,picked:new Set}),stopPicking:()=>f(null),pickAll:(e,s)=>f({hunk:e,picked:new Set(Array.from({length:s},(e,s)=>s))}),discardPicked:(e,s)=>{if(b&&o){let t=[...b.picked].sort((e,s)=>e-s);f(null),o(e,s,t)}}}:void 0;return(0,a.jsxs)("div",{className:"vf is-".concat(t),ref:g,style:{"--vl-left":"0px","--hx":"0px"},children:[s.meta.length>0&&(0,a.jsx)("div",{className:"gx-meta",children:s.meta.join(" \xb7 ")}),(0,a.jsx)("div",{className:"vf-main",children:(0,a.jsx)(ew.T,{count:h.length,width:m,render:e=>{let t=h[e],i="line"===t.t&&(null==b?void 0:b.hunk)===t.hunk;return(0,a.jsx)(eC,{row:t,path:n,ws:d,actions:"hunk"!==t.t||l&&t.idx===s.hunks.length-1?void 0:N,picking:"hunk"===t.t||i?b:void 0,onPick:i?v:void 0},e)}})}),"split"===t&&p.max>0&&(0,a.jsx)("div",{className:"hbar",ref:x,onScroll:e=>{var s;return null==(s=g.current)?void 0:s.style.setProperty("--hx","".concat(e.currentTarget.scrollLeft,"px"))},"aria-label":"Scroll sideways",children:(0,a.jsx)("div",{style:{width:p.track+p.max,height:1}})})]})}function eA(e){let{path:s,hunk:t,index:n,total:l,extent:c,onClose:r,onGo:o}=e,{t:d}=(0,E.s9)(),h=(0,i.useMemo)(()=>({meta:[],hunks:[t],binary:!1}),[t]),u=t.lines.length+1;return(0,a.jsxs)("div",{className:"vl-peek",role:"dialog","aria-label":d("git.peek.title"),onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("div",{className:"vl-peek-head",children:[(0,a.jsx)("b",{children:c?c.from===c.to?d("git.peek.line",{n:c.from}):d("git.peek.lines",{from:c.from,to:c.to}):d("git.peek.title")}),(0,a.jsx)("span",{className:"muted mono small grow",children:ef(t.header)}),(0,a.jsx)("span",{className:"small muted",children:d("git.peek.count",{n:n+1,total:l})}),(0,a.jsx)("button",{type:"button",className:"btn ghost icon sm",disabled:n<=0,onClick:()=>o(n-1),"aria-label":d("git.peek.prev"),title:"".concat(d("git.peek.prev")," (Alt+↑)"),children:(0,a.jsx)(ep.A,{size:15})}),(0,a.jsx)("button",{type:"button",className:"btn ghost icon sm",disabled:n>=l-1,onClick:()=>o(n+1),"aria-label":d("git.peek.next"),title:"".concat(d("git.peek.next")," (Alt+↓)"),children:(0,a.jsx)(A.A,{size:15})}),(0,a.jsx)("button",{type:"button",className:"btn ghost icon sm",onClick:r,"aria-label":d("common.close"),children:(0,a.jsx)(ej.A,{size:14})})]}),(0,a.jsx)("div",{className:"vl-peek-body",style:{height:Math.min(u*ew.U+4,260)},children:(0,a.jsx)(eS,{parsed:h,layout:"unified",path:s,firstIndex:n})})]})}function ez(e){var s,t;let{f:n,agent:l,blame:c,onOpenCommit:r,marks:o,allNew:d,focusLine:h}=e,u=null!=(s=null==o?void 0:o.groups)?s:[],[m,g]=(0,i.useState)(null),j=(0,i.useMemo)(()=>{let e=n.content.split("\n").length;return u.map(s=>({from:Math.min(s.from,e),to:Math.min(s.to,e)}))},[u,n.content]),b=m&&null!=(t=j[m.block])?t:null,[f,v]=(0,i.useState)(),N=(e,s)=>{let t={from:e.from,to:Math.min(e.to,n.content.split("\n").length)};return(t.to-(s+1)<=25?Math.max(t.to,s+1):s+1)*ew.U},y=e=>34+Math.min((e.view.lines.length+1)*ew.U+4,260)+14,k=e=>{let s=j[e];if(!s)return;let t=Math.max(0,s.from-1);g({row:t,block:e}),v({top:t*ew.U,bottom:N(u[e],t)+y(u[e]),key:Date.now()})};(0,i.useEffect)(()=>{g(null)},[n.path,o]),(0,i.useEffect)(()=>{if(!m)return;let e=e=>{if("Escape"===e.key)g(null);else if(e.altKey&&("ArrowDown"===e.key||"ArrowUp"===e.key)){e.preventDefault();let s=m.block+("ArrowDown"===e.key?1:-1);s>=0&&s<u.length&&k(s)}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[m]);let{t:w}=(0,E.s9)(),{whitespace:C}=(0,er.Wx)(),[S,A]=(0,i.useState)(null),[M,F]=(0,i.useState)(null),R=(0,ev.Z)(n.content,n.path),P=(0,i.useMemo)(()=>R.length&&""===R[R.length-1]?R.slice(0,-1):R,[R]),_=(0,i.useMemo)(()=>n.content.split("\n").reduce((e,s)=>Math.max(e,s.length),0),[n.content]);(0,i.useEffect)(()=>{if(!c||"worktree"!==n.source){A(null),F(null);return}let e=!1;return x.FH.get("/agents/".concat(l.id,"/git/blame?path=").concat(encodeURIComponent(n.path))).then(s=>{e||(A(s),F(null))}).catch(s=>!e&&F(s instanceof Error?s.message:w("git.loadError"))),()=>{e=!0}},[c,l.id,n.path,n.source]);let L=(0,i.useMemo)(()=>{if(!S)return null;let e=-1;return S.lines.map((s,t)=>{let a=s!==S.lines[t-1];return a&&e++,{first:a,g:e%2}})},[S]);if(n.binary)return(0,a.jsx)("p",{className:"gx-note",children:w("git.file.binary")});if(0===P.length)return(0,a.jsx)("p",{className:"gx-note",children:w("git.file.empty")});let I=210*!!S;return(0,a.jsxs)("div",{className:"vf",children:["head"===n.source&&(0,a.jsx)("div",{className:"gx-banner",children:w("git.file.deleted")}),n.truncated&&(0,a.jsx)("div",{className:"gx-banner",children:w("git.file.truncated")}),M&&(0,a.jsx)("div",{className:"gx-banner",children:M}),(null==S?void 0:S.truncated)&&(0,a.jsx)("div",{className:"gx-banner",children:w("git.blame.truncated",{count:S.lines.length})}),(0,a.jsx)("div",{className:"vf-main",style:{"--vl-left":"".concat(I,"px")},children:(0,a.jsx)(ew.T,{count:P.length,width:"calc(".concat(I,"px + ").concat(6,"ch + ").concat(_,"ch + 40px)"),overlay:m&&u[m.block]?{top:N(u[m.block],m.row),node:(0,a.jsx)(eA,{path:n.path,hunk:u[m.block].view,index:m.block,extent:b,onClose:()=>g(null),total:u.length,onGo:k})}:void 0,reveal:h?{top:Math.max(0,h.line-4)*ew.U,bottom:(h.line+2)*ew.U,key:h.key}:f,render:e=>{var s;let t=null==S?void 0:S.lines[e],l=t?S.commits[t]:void 0,i=null==L?void 0:L[e],c="worktree"===n.source?d?"add":null==o?void 0:o.lines.get(e+1):void 0,x=!!o&&o.removedBefore.has(e+1),j=!!o&&e===P.length-1&&o.removedBefore.has(P.length+1),f=o&&"worktree"===n.source?null!=(s=o.blockOfLine.get(e+1))?s:x?o.blockOfRemoval.get(e+1):j?o.blockOfRemoval.get(P.length+1):void 0:void 0;return(0,a.jsxs)("div",{className:"vl-row ".concat(h&&e+1===h.line?"m-hit":""," ").concat(i?"bl-g".concat(i.g):""," ").concat(c?"m-".concat(c):""," ").concat(x?"m-delb":j?"m-dela":""," ").concat(void 0!==f?"has-peek":""," ").concat(b&&e+1>=b.from&&e+1<=b.to?"in-peek":""),onClick:void 0!==f?s=>{var t;if(!s.target.closest(".bl-btn")&&(s.target.closest(".vl-ln")||(null==(t=window.getSelection())?void 0:t.isCollapsed))){if((null==m?void 0:m.row)===e)return void g(null);g({row:e,block:f}),v({top:e*ew.U,bottom:N(u[f],e)+y(u[f]),key:Date.now()})}}:void 0,title:void 0!==f?w("git.peek.hint"):void 0,children:[S&&(0,a.jsx)("div",{className:"vl-bl ".concat((null==i?void 0:i.first)?"first":""),children:(null==i?void 0:i.first)&&l&&(l.uncommitted?(0,a.jsx)("span",{className:"muted",children:w("git.blame.uncommitted")}):(0,a.jsxs)("button",{type:"button",className:"bl-btn",title:"".concat(l.summary,"\n").concat(l.author," \xb7 ").concat((0,z.v7)(l.time)),onClick:()=>r(t),children:[(0,a.jsx)("span",{className:"mono sha",children:l.short}),(0,a.jsx)("span",{className:"who",children:l.author}),(0,a.jsx)("span",{className:"when",children:(0,p.KN)(l.time)})]}))}),(0,a.jsx)("div",{className:"vl-ln",children:e+1}),(0,a.jsx)("div",{className:"vl-cd",children:(0,a.jsx)(eN.Yr,{html:P[e],ws:C})})]},e)}})})]})}function eE(e){let{agent:s,gitRef:t,path:n,toolbar:l=!0}=e,{t:c}=(0,E.s9)(),[r,o]=(0,i.useState)(null),[d,h]=(0,i.useState)(""),[u,m]=(0,i.useState)("preview"),g=eg.test(n),p=ex.test(n);return(0,i.useEffect)(()=>{let e=!1;if(o(null),h(""),m("preview"),!g)return x.FH.get("/agents/".concat(s.id,"/git/ref-file?ref=").concat(encodeURIComponent(t),"&path=").concat(encodeURIComponent(n))).then(s=>!e&&o(s)).catch(s=>!e&&h(s instanceof Error&&/not found/i.test(s.message)?c("git.file.missingAt",{ref:t}):s instanceof Error?s.message:c("git.loadError"))),()=>{e=!0}},[s.id,t,n]),(0,a.jsxs)(a.Fragment,{children:[l&&(0,a.jsxs)("div",{className:"gx-ptools",style:{padding:"6px 14px"},children:[(0,a.jsx)("span",{className:"mono small grow",title:n,style:{overflow:"hidden",textOverflow:"ellipsis"},children:n}),r&&(0,a.jsx)("span",{className:"muted small",children:(0,z.zi)(r.size)}),p&&r&&!r.binary&&(0,a.jsx)(D.$q,{value:u,onChange:m,options:[{id:"preview",label:c("git.view.preview")},{id:"source",label:c("git.view.source")}]}),(0,a.jsx)(ec.WQ,{text:n,label:c("git.copyPath")})]}),(0,a.jsx)("div",{className:"gx-body",children:d?(0,a.jsx)("p",{className:"gx-note",children:d}):g?(0,a.jsx)("div",{className:"gx-image",children:(0,a.jsx)("img",{src:"/api/agents/".concat(s.id,"/git/raw-at?ref=").concat(encodeURIComponent(t),"&path=").concat(encodeURIComponent(n)),alt:n,onError:()=>h(c("git.file.missingAt",{ref:t}))})}):r?r.binary?(0,a.jsx)("p",{className:"gx-note",children:c("git.file.binary")}):p&&"preview"===u?(0,a.jsxs)("div",{className:"gx-md md",children:[r.truncated&&(0,a.jsx)("div",{className:"gx-banner",children:c("git.diff.truncated")}),(0,a.jsx)(eu.oz,{remarkPlugins:[em.A],components:{a:e=>(0,a.jsx)("a",{...e,target:"_blank",rel:"noreferrer"})},children:r.content})]}):(0,a.jsx)(ez,{f:r,agent:s,blame:!1,onOpenCommit:()=>void 0,marks:null,allNew:!1}):(0,a.jsx)("p",{className:"gx-note",children:c("git.loading")})})]})}let eM={modified:"M",added:"A",deleted:"D",renamed:"R",untracked:"U",conflict:"!",typechange:"T"};function eF(e){let{status:s,titled:t=!1}=e,{t:n}=(0,E.s9)();return(0,a.jsx)("span",{className:"stl st-".concat(s),title:t?n("git.status.".concat(s)):void 0,children:eM[s]})}function eR(e){let{agent:s,gitRef:t,path:n,label:l}=e,[c,r]=(0,i.useState)(!0);return((0,i.useEffect)(()=>{r(!0)},[t,n]),c)?(0,a.jsxs)("figure",{className:"gx-pic",children:[(0,a.jsx)("figcaption",{className:"muted small",children:l}),(0,a.jsx)("div",{className:"gx-image",children:(0,a.jsx)("img",{src:"/api/agents/".concat(s.id,"/git/raw-at?ref=").concat(encodeURIComponent(t),"&path=").concat(encodeURIComponent(n)),alt:n,onError:()=>r(!1)})})]}):null}function eP(e){var s;let{agent:t,detailUrl:n,diffUrl:l,header:c,focus:r,embedded:o=!1,before:d,after:h,label:u}=e,{t:m}=(0,E.s9)(),[g,p]=(0,i.useState)(null),[j,b]=(0,i.useState)(null),[f,v]=(0,i.useState)(null),[N,y]=(0,i.useState)("unified"),[k,w]=(0,i.useState)(null);(0,i.useEffect)(()=>{let e=!1;return p(null),b(null),v(null),w(null),x.FH.get(n).then(s=>{var t,a;e||(p(s),b(null!=(a=r&&s.files.some(e=>e.path===r)?r:null==(t=s.files[0])?void 0:t.path)?a:null))}).catch(s=>!e&&w(s instanceof Error?s.message:m("git.loadError"))),()=>{e=!0}},[t.id,n,r]);let C=null==g?void 0:g.files.find(e=>e.path===j);(0,i.useEffect)(()=>{if(!C)return void v(null);let e=!1;return v(null),x.FH.get(l(C)).then(s=>!e&&v(s)).catch(s=>!e&&w(s instanceof Error?s.message:m("git.loadError"))),()=>{e=!0}},[t.id,n,null==C?void 0:C.path,null==C?void 0:C.oldPath]);let S=(0,i.useMemo)(()=>f&&C&&f.path===C.path?eb(f.diff):null,[f,C]);if(k)return(0,a.jsx)("section",{className:"gx-preview",children:(0,a.jsx)("p",{className:"gx-note err",children:k})});if(!g)return(0,a.jsx)("section",{className:"gx-preview",children:(0,a.jsx)("p",{className:"gx-note",children:m("git.loading")})});let A=!!C&&eg.test(C.path);return(0,a.jsxs)("section",{className:"gx-preview gx-commitview ".concat(o?"embedded":""),"aria-label":u,children:[(0,a.jsx)("header",{className:"gx-chead",children:c(g)}),0===g.files.length?(0,a.jsx)("p",{className:"gx-note",children:m("git.cmp.nofiles")}):(0,a.jsx)("div",{className:"gx-cfilelist",role:"listbox",children:g.files.map(e=>{var s,t;return(0,a.jsxs)("button",{role:"option","aria-selected":j===e.path,className:"gx-cfile ".concat(j===e.path?"sel":""),onClick:()=>b(e.path),title:e.oldPath?"".concat(e.oldPath," → ").concat(e.path):e.path,children:[(0,a.jsx)(eF,{status:e.status}),(0,a.jsx)("span",{className:"mono nm",children:e.path}),(null!==e.additions||null!==e.deletions)&&(0,a.jsxs)("span",{className:"gx-counts sm",children:[(0,a.jsxs)("i",{className:"add",children:["+",null!=(s=e.additions)?s:0]}),(0,a.jsxs)("i",{className:"del",children:["−",null!=(t=e.deletions)?t:0]})]})]},e.path)})}),C&&(0,a.jsxs)(a.Fragment,{children:[!A&&(0,a.jsx)("div",{className:"gx-ptools",style:{padding:"6px 14px"},children:(0,a.jsx)(D.$q,{value:N,onChange:y,options:[{id:"unified",label:m("git.layout.unified")},{id:"split",label:m("git.layout.split")}]})}),(0,a.jsx)("div",{className:"gx-body",children:A?(0,a.jsxs)("div",{className:"gx-picpair",children:["added"!==C.status&&(0,a.jsx)(eR,{agent:t,gitRef:d,path:null!=(s=C.oldPath)?s:C.path,label:m("git.img.before")}),"deleted"!==C.status&&(0,a.jsx)(eR,{agent:t,gitRef:h,path:C.path,label:m("git.img.after")})]}):S?S.binary?(0,a.jsx)("p",{className:"gx-note",children:m("git.diff.binary")}):0===S.hunks.length?(0,a.jsx)("p",{className:"gx-note",children:m("git.diff.empty")}):(0,a.jsxs)(a.Fragment,{children:[(null==f?void 0:f.truncated)&&(0,a.jsx)("div",{className:"gx-banner",children:m("git.diff.truncated")}),(0,a.jsx)(eS,{parsed:S,layout:N,path:C.path})]}):(0,a.jsx)("p",{className:"gx-note",children:m("git.loading")})})]})]})}function e_(e){let{agent:s,sha:t,embedded:n=!1,focus:l}=e,{t:i}=(0,E.s9)();return(0,a.jsx)(eP,{agent:s,detailUrl:"/agents/".concat(s.id,"/git/commit?sha=").concat(t),embedded:n,focus:l,before:"".concat(t,"^"),after:t,label:t,diffUrl:e=>"/agents/".concat(s.id,"/git/commit-diff?sha=").concat(t,"&path=").concat(encodeURIComponent(e.path)).concat(e.oldPath?"&old=".concat(encodeURIComponent(e.oldPath)):""),header:e=>{let[s,...t]=e.message.split("\n"),n=t.join("\n").trim();return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("h3",{children:s}),n&&(0,a.jsx)("pre",{className:"gx-cbody",children:n}),(0,a.jsxs)("div",{className:"muted small row gap-s wrap",children:[(0,a.jsx)("span",{className:"mono",children:e.sha.slice(0,10)}),(0,a.jsx)(ec.WQ,{text:e.sha,label:i("git.info.copySha"),compact:!0}),(0,a.jsxs)("span",{children:["\xb7 ",e.author," \xb7 ",(0,z.v7)(e.date)]}),(0,a.jsxs)("span",{children:["\xb7 ",i("git.hist.files",{count:e.files.length})]})]})]})}})}function eL(e){let{agent:s,sel:t,onSelect:n,onLoaded:l}=e,{t:c}=(0,E.s9)(),[r,o]=(0,i.useState)(null),[d,h]=(0,i.useState)(!1),[u,m]=(0,i.useState)(""),[g,j]=(0,i.useState)("");(0,i.useEffect)(()=>{let e=!1;return o(null),j(""),x.FH.get("/agents/".concat(s.id,"/git/tags")).then(s=>{e||(o(s.tags),h(s.truncated),null==l||l(s.tags))}).catch(s=>!e&&j(s instanceof Error?s.message:"error")),()=>{e=!0}},[s.id]);let b=(0,i.useMemo)(()=>(null!=r?r:[]).filter(e=>!u||"".concat(e.name," ").concat(e.subject).toLowerCase().includes(u.toLowerCase())),[r,u]);return g?(0,a.jsx)("p",{className:"gx-note err",children:g}):r?r.length?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"gx-filter",children:(0,a.jsxs)("div",{className:"search",children:[(0,a.jsx)(B.A,{size:14}),(0,a.jsx)("input",{className:"input",placeholder:c("git.tags.search"),value:u,onChange:e=>m(e.target.value),"aria-label":c("git.tags.search")})]})}),(0,a.jsxs)("div",{className:"gx-hist",role:"listbox","aria-label":c("git.tab.tags"),children:[b.map(e=>(0,a.jsxs)("button",{role:"option","aria-selected":t===e.name,className:"gx-commit ".concat(t===e.name?"sel":""),onClick:()=>n(e),children:[(0,a.jsxs)("span",{className:"subj",children:[(0,a.jsx)(ed.A,{size:13,style:{verticalAlign:"-2px",marginRight:5}}),e.name]}),(0,a.jsx)("span",{className:"meta",children:e.subject||"—"}),(0,a.jsxs)("span",{className:"meta",children:[(0,a.jsx)("span",{className:"mono sha",children:e.sha.slice(0,8)})," \xb7 ",(0,p.KN)(Date.parse(e.date))]})]},e.name)),!b.length&&(0,a.jsx)("p",{className:"gx-note",children:c("git.noMatch",{query:u})}),d&&(0,a.jsx)("p",{className:"gx-note",children:c("git.tags.truncated",{count:r.length})})]})]}):(0,a.jsx)("p",{className:"gx-note",children:c("git.tags.empty")}):(0,a.jsx)("p",{className:"gx-note",children:c("git.loading")})}function eI(e){var s;let{agent:t,tag:n,onChanged:l}=e,{t:c}=(0,E.s9)(),r=(0,D.dj)(),[o,d]=(0,i.useState)(null),[h,u]=(0,i.useState)(""),m=!!o&&/^[\w./-]+$/.test(o)&&!o.startsWith("-")&&!o.endsWith("/")&&!o.includes(".."),g=async()=>{if(o&&m)try{await x.FH.post("/agents/".concat(t.id,"/git/branch-create"),{branch:o,from:n.name}),r(c("git.tags.branchCreated",{branch:o})),d(null),u(""),null==l||l()}catch(e){u(e instanceof Error?e.message:"error")}},[p,j]=(0,i.useState)("files"),[b,f]=(0,i.useState)(null),[v,N]=(0,i.useState)(!1),[y,k]=(0,i.useState)(new Set),[w,C]=(0,i.useState)(""),[S,M]=(0,i.useState)(null),[F,R]=(0,i.useState)("");(0,i.useEffect)(()=>{j("files"),M(null),C(""),k(new Set)},[n.name]),(0,i.useEffect)(()=>{let e=!1;return f(null),R(""),x.FH.get("/agents/".concat(t.id,"/git/tag-tree?tag=").concat(encodeURIComponent(n.name))).then(s=>{e||(f(s.files),N(s.truncated),k(new Set(s.files.length<=40?s.files.flatMap(e=>e.split("/").slice(0,-1).map((e,s,t)=>t.slice(0,s+1).join("/"))):[])))}).catch(s=>!e&&R(s instanceof Error?s.message:c("git.loadError"))),()=>{e=!0}},[t.id,n.name]);let P=(0,i.useMemo)(()=>b?el(b,[]):null,[b]),_=(0,i.useMemo)(()=>P?ei(P,y,{query:w,onlyChanged:!1}).slice(0,3e3):[],[P,y,w]);return(0,a.jsxs)("section",{className:"gx-preview gx-tagview","aria-label":n.name,children:[(0,a.jsxs)("header",{className:"gx-chead",children:[(0,a.jsxs)("h3",{children:[(0,a.jsx)(ed.A,{size:16,style:{verticalAlign:"-2px",marginRight:6}}),n.name]}),n.subject&&(0,a.jsx)("div",{children:n.subject}),(0,a.jsxs)("div",{className:"muted small row gap-s wrap",children:[(0,a.jsx)("span",{className:"gx-chip soft",children:n.annotated?c("git.tags.annotated"):c("git.tags.lightweight")}),(0,a.jsx)("span",{className:"mono",children:n.sha.slice(0,10)}),(0,a.jsx)(ec.WQ,{text:n.sha,label:c("git.info.copySha"),compact:!0}),(0,a.jsxs)("span",{children:["\xb7 ",(0,z.v7)(n.date)]}),b&&(0,a.jsxs)("span",{children:["\xb7 ",c("git.tags.nfiles",{count:b.length})]})]}),(0,a.jsx)("div",{className:"row gap-s wrap",style:{marginTop:8},children:null===o?(0,a.jsxs)("button",{className:"btn sm",onClick:()=>d(""),children:[(0,a.jsx)(V.A,{size:14}),c("git.tags.newBranch")]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("input",{className:"input mono",style:{maxWidth:240},autoFocus:!0,placeholder:c("git.tags.branchName"),value:o,onChange:e=>{d(e.target.value.trim()),u("")},"aria-label":c("git.tags.branchName"),onKeyDown:e=>{"Enter"===e.key&&g(),"Escape"===e.key&&d(null)}}),(0,a.jsx)("button",{className:"btn primary sm",disabled:!m,onClick:()=>void g(),children:c("git.tags.createBranch")}),(0,a.jsx)("button",{className:"btn ghost sm",onClick:()=>{d(null),u("")},children:c("common.cancel")})]})}),h&&(0,a.jsx)("p",{className:"gx-note err",style:{margin:0},children:h}),(0,a.jsx)("div",{style:{marginTop:4},children:(0,a.jsx)(D.$q,{value:p,onChange:j,options:[{id:"files",label:c("git.tags.files")},{id:"changes",label:c("git.tags.changes")}]})})]}),"changes"===p?(0,a.jsx)(e_,{agent:t,sha:n.sha,embedded:!0},n.sha):F?(0,a.jsx)("p",{className:"gx-note err",children:F}):P?(0,a.jsxs)("div",{className:"gx-tagfiles",children:[(0,a.jsxs)("div",{className:"gx-tagtree",children:[(0,a.jsx)("div",{className:"gx-filter",children:(0,a.jsxs)("div",{className:"search",children:[(0,a.jsx)(B.A,{size:14}),(0,a.jsx)("input",{className:"input",placeholder:c("git.filterPlaceholder"),value:w,onChange:e=>C(e.target.value),"aria-label":c("git.filterPlaceholder")})]})}),(0,a.jsxs)("div",{className:"gx-list",role:"tree",children:[0===_.length?(0,a.jsx)("p",{className:"gx-note",children:w?c("git.noMatch",{query:w}):c("git.noFiles")}):_.map(e=>{let{node:s,depth:t}=e,n="dir"===s.type,l=n&&(!!w||y.has(s.path));return(0,a.jsxs)("button",{type:"button",role:"treeitem","aria-level":t+1,"aria-expanded":n?l:void 0,"aria-selected":!n&&S===s.path,className:"gx-row ".concat(n?"dir":"file"," ").concat(n||S!==s.path?"":"sel"),style:{paddingLeft:8+14*t},title:s.path,onClick:()=>{let e;return n?(e=s.path,k(s=>{let t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})):M(s.path)},children:[(0,a.jsx)("span",{className:"chev",children:n?l?(0,a.jsx)(A.A,{size:14}):(0,a.jsx)(ee.A,{size:14}):null}),(0,a.jsx)("span",{className:"ico",children:n?l?(0,a.jsx)(eh.A,{size:15}):(0,a.jsx)(Y.A,{size:15}):(0,a.jsx)(et.A,{size:15})}),(0,a.jsx)("span",{className:"nm",children:s.name})]},s.path)}),v&&(0,a.jsx)("p",{className:"gx-note",children:c("git.treeTruncated",{count:null!=(s=null==b?void 0:b.length)?s:0})})]})]}),(0,a.jsx)("div",{className:"gx-tagfile",children:S?(0,a.jsx)(eE,{agent:t,gitRef:n.name,path:S}):(0,a.jsx)("div",{className:"gx-empty",children:(0,a.jsx)("p",{children:c("git.tags.pick")})})})]}):(0,a.jsx)("p",{className:"gx-note",children:c("git.loading")})]})}var eT=t(71857),eH=t(72705),eU=t(21018);function eD(e){var s,t,n,l;let{refs:c,value:r,onChange:o,label:d,extra:h,icon:u=!0,compact:m=!1}=e,{t:g}=(0,E.s9)(),[x,j]=(0,i.useState)(!1),[b,f]=(0,i.useState)(""),v=(0,i.useRef)(null);(0,eU.s)(x,v,()=>j(!1)),(0,i.useEffect)(()=>{x&&f("")},[x]);let N=e=>!b||"".concat(e.name," ").concat(e.subject).toLowerCase().includes(b.toLowerCase()),y=(0,i.useMemo)(()=>{var e;return(null!=(e=null==c?void 0:c.branches)?e:[]).filter(N)},[c,b]),k=(0,i.useMemo)(()=>{var e;return(null!=(e=null==c?void 0:c.remotes)?e:[]).filter(N)},[c,b]),w=(0,i.useMemo)(()=>{var e;return(null!=(e=null==c?void 0:c.tags)?e:[]).filter(N)},[c,b]),C=b.trim(),S=/^([0-9a-f]{7,40}|HEAD([~^]\d*)*)$/i.test(C)&&![...null!=(t=null==c?void 0:c.branches)?t:[],...null!=(n=null==c?void 0:c.tags)?n:[]].some(e=>e.name===C),z=e=>{o(e),j(!1)},M=(e,s)=>(0,a.jsxs)("button",{type:"button",role:"option","aria-selected":r===e.name,className:"gx-refrow ".concat(r===e.name?"sel":""),onClick:()=>z(e.name),title:e.subject,children:[(0,a.jsxs)("span",{className:"nm",children:[r===e.name?(0,a.jsx)(eH.A,{size:13}):"tag"===s?(0,a.jsx)(ed.A,{size:13}):(0,a.jsx)(V.A,{size:13}),e.name]}),(0,a.jsxs)("span",{className:"sub",children:[e.subject||"—"," \xb7 ",(0,p.KN)(Date.parse(e.date))]})]},"".concat(s,":").concat(e.name));return(0,a.jsxs)("div",{className:"gx-brmenu gx-refpick",ref:v,children:[m?(0,a.jsxs)("button",{type:"button",className:"btn sm ".concat(r?"primary gx-refbtn":"ghost icon"),"aria-expanded":x,"aria-haspopup":"listbox","aria-label":d,title:d,onClick:()=>j(e=>!e),children:[(0,a.jsx)(V.A,{size:14}),r&&(0,a.jsx)("span",{className:"nm mono",children:r})]}):(0,a.jsxs)("button",{type:"button",className:"btn sm gx-refbtn","aria-expanded":x,"aria-haspopup":"listbox",title:d,onClick:()=>j(e=>!e),children:[u&&(0,a.jsx)(V.A,{size:14}),(0,a.jsx)("span",{className:"nm mono",children:null!=(l=null==h||null==(s=h.find(e=>e.value===r))?void 0:s.label)?l:r||g("git.ref.pick")}),(0,a.jsx)(A.A,{size:13})]}),x&&(0,a.jsxs)("div",{className:"gx-pop",role:"listbox",children:[(0,a.jsxs)("div",{className:"search",children:[(0,a.jsx)(B.A,{size:14}),(0,a.jsx)("input",{className:"input",autoFocus:!0,placeholder:g("git.ref.search"),value:b,onChange:e=>f(e.target.value),"aria-label":g("git.ref.search"),onKeyDown:e=>{"Enter"===e.key&&S&&z(C)}})]}),(0,a.jsxs)("div",{className:"gx-brlist",children:[!b&&(null==h?void 0:h.map(e=>(0,a.jsx)("button",{type:"button",role:"option","aria-selected":r===e.value,className:"gx-refrow ".concat(r===e.value?"sel":""),onClick:()=>z(e.value),children:(0,a.jsxs)("span",{className:"nm",children:[r===e.value&&(0,a.jsx)(eH.A,{size:13}),e.label]})},e.value))),S&&(0,a.jsx)("button",{type:"button",className:"gx-refrow",onClick:()=>z(C),children:(0,a.jsx)("span",{className:"nm mono",children:g("git.ref.useCommit",{ref:C.slice(0,12)})})}),y.length>0&&(0,a.jsx)("div",{className:"gx-brhead",children:g("git.ref.branches")}),y.map(e=>M(e,"branch")),w.length>0&&(0,a.jsx)("div",{className:"gx-brhead",children:g("git.ref.tags")}),w.slice(0,200).map(e=>M(e,"tag")),k.length>0&&(0,a.jsx)("div",{className:"gx-brhead",children:g("git.ref.remotes")}),k.slice(0,200).map(e=>M(e,"branch")),c&&!y.length&&!w.length&&!k.length&&!S&&(0,a.jsx)("p",{className:"gx-note",children:g("git.ref.none")})]})]})]})}function eK(e){let{refs:s,sel:t,onChange:n}=e,{t:l}=(0,E.s9)();return(0,a.jsxs)("div",{className:"gx-cmpside",children:[(0,a.jsx)("label",{className:"label",children:l("git.cmp.base")}),(0,a.jsx)(eD,{refs:s,value:t.base,onChange:e=>n({...t,base:e})}),(0,a.jsx)("div",{className:"row",style:{justifyContent:"center"},children:(0,a.jsx)("button",{className:"btn ghost icon sm",onClick:()=>n({base:t.head,head:t.base}),disabled:!t.base&&!t.head,"aria-label":l("git.cmp.swap"),title:l("git.cmp.swap"),children:(0,a.jsx)(eT.A,{size:15,style:{transform:"rotate(90deg)"}})})}),(0,a.jsx)("label",{className:"label",children:l("git.cmp.head")}),(0,a.jsx)(eD,{refs:s,value:t.head,onChange:e=>n({...t,head:e})}),(!t.base||!t.head)&&(0,a.jsx)("p",{className:"muted small",children:l("git.cmp.pick")})]})}function eW(e){let{agent:s,sel:t}=e,{t:n}=(0,E.s9)();if(!(t.base&&t.head))return(0,a.jsx)("div",{className:"gx-preview",children:(0,a.jsx)("div",{className:"gx-empty",children:(0,a.jsx)("p",{children:n("git.cmp.pick")})})});let l="base=".concat(encodeURIComponent(t.base),"&head=").concat(encodeURIComponent(t.head));return(0,a.jsx)(eP,{agent:s,detailUrl:"/agents/".concat(s.id,"/git/compare?").concat(l),before:t.base,after:t.head,label:"".concat(t.base," → ").concat(t.head),diffUrl:e=>"/agents/".concat(s.id,"/git/compare-diff?").concat(l,"&path=").concat(encodeURIComponent(e.path)).concat(e.oldPath?"&old=".concat(encodeURIComponent(e.oldPath)):""),header:e=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("h3",{children:[(0,a.jsx)("span",{className:"mono",children:t.base})," → ",(0,a.jsx)("span",{className:"mono",children:t.head})]}),e.base.sha===e.head.sha?(0,a.jsx)("p",{className:"muted small",style:{margin:0},children:n("git.cmp.same")}):(0,a.jsxs)("div",{className:"muted small row gap-s wrap",children:[(0,a.jsx)("span",{children:n("git.cmp.summary",{ahead:e.ahead,behind:e.behind})}),(0,a.jsxs)("span",{children:["\xb7 ",n("git.hist.files",{count:e.files.length})]})]}),e.commits.length>0&&(0,a.jsxs)("details",{className:"gx-cmpcommits",children:[(0,a.jsx)("summary",{children:n("git.cmp.commits",{count:e.ahead})}),(0,a.jsx)("ul",{children:e.commits.map(e=>(0,a.jsxs)("li",{children:[(0,a.jsx)("span",{className:"mono sha",children:e.short})," ",e.subject," ",(0,a.jsxs)("span",{className:"muted",children:["\xb7 ",e.author," \xb7 ",(0,p.KN)(Date.parse(e.date))]})]},e.sha))}),e.commitsTruncated&&(0,a.jsx)("p",{className:"muted small",children:n("git.cmp.more",{count:e.commits.length})})]})]})})}function eO(e){let s=e.split("\n"),t=[];for(let e=0;e<s.length;e++){if(!/^<{7}( |$)/.test(s[e]))continue;let a=-1,n=-1,l=-1;for(let t=e+1;t<s.length&&!/^<{7}( |$)/.test(s[t]);t++)if(/^\|{7}( |$)/.test(s[t])&&a<0)n=t;else if("======="===s[t]&&a<0)a=t;else if(/^>{7}( |$)/.test(s[t])&&a>=0){l=t;break}a<0||l<0||(t.push({start:e,end:l,ours:s.slice(e+1,n>=0?n:a),base:n>=0?s.slice(n+1,a):void 0,theirs:s.slice(a+1,l),oursLabel:s[e].slice(8).trim(),theirsLabel:s[l].slice(8).trim()}),e=l)}return t}function eq(e,s,t){let a=eO(e)[s];if(!a)return e;let n={ours:a.ours,theirs:a.theirs,"ours-theirs":[...a.ours,...a.theirs],"theirs-ours":[...a.theirs,...a.ours]}[t],l=e.split("\n");return l.splice(a.start,a.end-a.start+1,...n),l.join("\n")}var e$=t(96213);function eB(e){let{agent:s,path:t,state:n,a:l,onResolved:c}=e,{t:r}=(0,E.s9)(),[o,h]=(0,i.useState)(null),[u,m]=(0,i.useState)(""),[g,p]=(0,i.useState)(null),[j,b]=(0,i.useState)(0);(0,i.useEffect)(()=>{let e=!1;return h(null),p(null),x.FH.get("/agents/".concat(s.id,"/git/file?path=").concat(encodeURIComponent(t))).then(s=>{e||(h(s),m(s.content))}).catch(s=>!e&&p(s instanceof Error?s.message:r("git.loadError"))),()=>{e=!0}},[s.id,t,j]);let f=(0,i.useMemo)(()=>eO(u),[u]),v="rebase"!==n&&"stash"!==n,N=e=>"mine"===e===v?"ours":"theirs",y=e=>"both-mine"===e?v?"ours-theirs":"theirs-ours":"both-remote"===e?v?"theirs-ours":"ours-theirs":N(e),k=/^(<{7}|>{7})( |$)/m.test(u),w=!!o&&!o.binary&&!o.truncated,C=!!l.busy,S=async e=>{await l.run("resolve",r("git.res.done"),"resolve-side",{path:t,side:N(e)})&&c()},A=async()=>{await l.run("resolve",r("git.res.done"),"resolve",{path:t,content:u})&&c()},z=async()=>{await l.run("unresolve",r("git.res.restored"),"unresolve",{path:t})&&b(e=>e+1)},M=t.lastIndexOf("/"),F=M>=0?t.slice(0,M+1):"",R=t.slice(M+1);return(0,a.jsxs)("section",{className:"gx-preview gx-resolver","aria-label":t,children:[(0,a.jsxs)("header",{className:"gx-phead",children:[(0,a.jsxs)("div",{className:"gx-ptitle",children:[(0,a.jsxs)("span",{className:"gx-path mono",title:t,children:[(0,a.jsx)("span",{className:"dir",children:F}),(0,a.jsx)("b",{children:R})]}),(0,a.jsx)("span",{className:"gx-chip st-conflict",children:r("git.status.conflict")}),w&&(0,a.jsx)("span",{className:"muted small",children:f.length>0?r("git.res.left",{count:f.length}):r("git.res.none")})]}),(0,a.jsxs)("div",{className:"gx-ptools",children:[(0,a.jsx)("button",{className:"btn sm",disabled:C,title:r("git.res.allMine.hint"),onClick:()=>void S("mine"),children:r("git.res.allMine")}),(0,a.jsx)("button",{className:"btn sm",disabled:C,title:r("git.res.allRemote.hint"),onClick:()=>void S("remote"),children:r("git.res.allRemote")}),(0,a.jsx)(ec.WQ,{text:t,label:r("git.copyPath")})]})]}),g?(0,a.jsx)("p",{className:"gx-note err",children:g}):o?w?(0,a.jsxs)("div",{className:"gx-rbody",children:[f.length>0&&(0,a.jsx)("div",{className:"gx-rblocks",children:f.map((e,s)=>(0,a.jsxs)("div",{className:"gx-rcard",children:[(0,a.jsxs)("div",{className:"gx-rtitle",children:[(0,a.jsx)("b",{children:r("git.res.block",{n:s+1,total:f.length})}),(0,a.jsx)("span",{className:"muted small",children:r("git.res.line",{n:e.start+1})})]}),(0,a.jsx)("div",{className:"gx-rsides",children:["mine","remote"].map(l=>{let i,c="ours"===N(l)?e.ours:e.theirs,o=!(i="ours"===N(l)?e.oursLabel:e.theirsLabel)||["HEAD","ours","theirs","Updated upstream","Stashed changes"].includes(i)?"":i;return(0,a.jsxs)("div",{className:"gx-rside ".concat(l),children:[(0,a.jsxs)("div",{className:"gx-rhead",children:[(0,a.jsx)("span",{children:"mine"===l?"stash"===n?r("git.res.mine.stash"):r("git.res.mine"):"stash"===n?r("git.res.remote.stash"):r("git.res.remote")}),o&&(0,a.jsx)("i",{className:"ref",children:o})]}),(0,a.jsx)("pre",{children:c.length?(0,a.jsx)(eN.Cy,{text:c.join("\n"),path:t}):(0,a.jsx)("span",{className:"muted",children:r("git.res.empty")})}),(0,a.jsx)("button",{className:"btn sm",onClick:()=>m(e=>eq(e,s,y(l))),children:"mine"===l?r("git.res.keepMine"):r("git.res.keepRemote")})]},l)})}),(0,a.jsxs)("div",{className:"gx-rboth",children:[(0,a.jsxs)("span",{className:"small muted",children:[r("git.res.both"),":"]}),(0,a.jsx)("button",{className:"btn sm",onClick:()=>m(e=>eq(e,s,y("both-mine"))),children:r("git.res.bothMine")}),(0,a.jsx)("button",{className:"btn sm",onClick:()=>m(e=>eq(e,s,y("both-remote"))),children:r("git.res.bothRemote")})]})]},"".concat(s,"-").concat(e.start)))}),(0,a.jsxs)("div",{className:"gx-rresult",children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("label",{className:"label grow",htmlFor:"gx-result",children:r("git.res.result")}),(0,a.jsx)("span",{className:"small muted",children:r("git.res.editHint")})]}),(0,a.jsx)(e$.B,{id:"gx-result",label:r("git.res.result"),value:u,path:t,onChange:m})]}),(0,a.jsxs)("footer",{className:"gx-rfoot",children:[(0,a.jsxs)("button",{className:"btn ghost sm",disabled:C,onClick:()=>void z(),title:r("git.res.restore.hint"),children:[(0,a.jsx)(d.A,{size:14}),r("git.res.restore")]}),(0,a.jsx)("span",{className:"grow"}),(0,a.jsx)("button",{className:"btn primary",disabled:C||k,onClick:()=>void A(),children:r("git.res.markResolved")})]})]}):(0,a.jsx)("p",{className:"gx-note",children:r("git.res.noEdit")}):(0,a.jsx)("p",{className:"gx-note",children:r("git.loading")})]})}function eG(e){let{agent:s,plan:t,a:n,onClose:l,onGo:i}=e,{t:c}=(0,E.s9)();return(0,a.jsxs)(D.TM,{title:c("git.sw.title",{branch:t.to}),confirmLabel:c("git.sw.anyway"),onConfirm:()=>{n.busy||i()},onClose:l,children:[t.carried>0&&(0,a.jsx)("p",{className:"confirm-body",children:c("git.sw.carried",{count:t.carried,from:t.from})}),(0,a.jsxs)("div",{className:"gx-sw-warn",role:"alert",children:[t.selfRunning&&(0,a.jsx)("div",{children:c("git.warn.running",{name:s.name})}),t.others.length>0&&(0,a.jsx)("div",{children:c("git.sw.others",{count:t.others.length,names:t.others.map(e=>e.name).join(", ")})})]})]})}var eJ=t(43380),eQ=t(24328),eX=t(97356);function eY(e){let{stashes:s,sel:t,onSelect:n,onSave:l,canSave:i}=e,{t:c}=(0,E.s9)();return(0,a.jsxs)("div",{className:"gx-stashes",children:[(0,a.jsx)("div",{className:"gx-stash-head",children:(0,a.jsxs)("button",{className:"btn sm",disabled:!i,title:i?void 0:c("git.stash.nothing"),onClick:l,children:[(0,a.jsx)(eJ.A,{size:14}),c("git.stash.save")]})}),s?0===s.length?(0,a.jsx)("p",{className:"gx-note",children:c("git.stash.empty")}):(0,a.jsx)("div",{className:"gx-hist",role:"listbox","aria-label":c("git.tab.stashes"),children:s.map(e=>(0,a.jsxs)("button",{role:"option","aria-selected":t===e.sha,className:"gx-commit ".concat(t===e.sha?"sel":""),onClick:()=>n(e.sha),children:[(0,a.jsx)("span",{className:"subj",children:e.message||"—"}),(0,a.jsxs)("span",{className:"meta",children:[e.branch&&(0,a.jsxs)(a.Fragment,{children:[e.branch," \xb7 "]}),(0,p.KN)(Date.parse(e.date))]}),e.smart&&(0,a.jsx)("span",{className:"refs",children:(0,a.jsx)("i",{className:"ref",children:c("git.stash.smart")})})]},e.sha))}):(0,a.jsx)("p",{className:"gx-note",children:c("git.loading")})]})}function eZ(e){let{a:s,onClose:t}=e,{t:n}=(0,E.s9)(),[l,c]=(0,i.useState)(""),r=async()=>{t(),await s.run("stash",n("git.stash.saved"),"stash-save",{message:l})};return(0,a.jsxs)(D.aF,{title:n("git.stash.save"),onClose:t,children:[(0,a.jsx)("p",{className:"confirm-body",children:n("git.stash.save.body")}),(0,a.jsx)("input",{className:"input",autoFocus:!0,value:l,maxLength:200,placeholder:n("git.stash.save.placeholder"),onChange:e=>c(e.target.value),onKeyDown:e=>{"Enter"===e.key&&r()},"aria-label":n("git.stash.save.placeholder")}),(0,a.jsxs)("div",{className:"row confirm-actions",children:[(0,a.jsx)("button",{className:"btn ghost",onClick:t,children:n("common.cancel")}),(0,a.jsx)("button",{className:"btn primary",disabled:!!s.busy,onClick:()=>void r(),children:n("git.stash.save")})]})]})}function eV(e){var s,t;let{agent:n,stash:l,a:c}=e,{t:r}=(0,E.s9)(),[o,d]=(0,i.useState)(null),[h,u]=(0,i.useState)(null),[m,g]=(0,i.useState)(null),[j,b]=(0,i.useState)(null),[f,v]=(0,i.useState)(!1),[N,y]=(0,i.useState)(null);(0,i.useEffect)(()=>{let e=!1;return d(null),u(null),g(null),b(null),y(null),Promise.all([x.FH.get("/agents/".concat(n.id,"/git/stash?sha=").concat(l.sha)),x.FH.get("/agents/".concat(n.id,"/git/commit?sha=").concat(l.sha))]).then(s=>{let[t,a]=s;if(e)return;d(t),u(a);let n=a.files[0];g(n?{path:n.path,untracked:!1,oldPath:n.oldPath}:t.untracked[0]?{path:t.untracked[0],untracked:!0}:null)}).catch(s=>!e&&y(s instanceof Error?s.message:r("git.loadError"))),()=>{e=!0}},[n.id,l.sha]),(0,i.useEffect)(()=>{if(!m||!o)return void b(null);let e=m.untracked?o.untrackedSha:l.sha;if(!e)return;let s=!1;return b(null),x.FH.get("/agents/".concat(n.id,"/git/commit-diff?sha=").concat(e,"&path=").concat(encodeURIComponent(m.path)).concat(m.oldPath?"&old=".concat(encodeURIComponent(m.oldPath)):"")).then(e=>!s&&b(e)).catch(e=>!s&&y(e instanceof Error?e.message:r("git.loadError"))),()=>{s=!0}},[n.id,l.sha,o,null==m?void 0:m.path,null==m?void 0:m.untracked]);let k=(0,i.useMemo)(()=>j?eb(j.diff):null,[j]),w=!!c.busy,C=e=>void c.run("stash",e?r("git.stash.popped"):r("git.stash.applied"),"stash-apply",{sha:l.sha,pop:e}),S=(null!=(s=null==h?void 0:h.files.length)?s:0)+(null!=(t=null==o?void 0:o.untracked.length)?t:0);return(0,a.jsxs)("section",{className:"gx-preview gx-commitview","aria-label":l.message,children:[(0,a.jsxs)("header",{className:"gx-chead",children:[(0,a.jsx)("h3",{children:l.message||"—"}),(0,a.jsxs)("div",{className:"muted small row gap-s wrap",children:[(0,a.jsxs)("span",{children:[l.branch&&"".concat(l.branch," \xb7 "),(0,p.KN)(Date.parse(l.date))]}),o&&(0,a.jsxs)("span",{children:["\xb7 ",r("git.hist.files",{count:S})]})]}),(0,a.jsxs)("div",{className:"row gap-s wrap",children:[(0,a.jsxs)("button",{className:"btn sm",disabled:w,title:r("git.stash.apply.hint"),onClick:()=>C(!1),children:[(0,a.jsx)(eQ.A,{size:14}),r("git.stash.apply")]}),(0,a.jsx)("button",{className:"btn sm primary",disabled:w,title:r("git.stash.pop.hint"),onClick:()=>C(!0),children:r("git.stash.pop")}),(0,a.jsxs)("button",{className:"btn sm danger",disabled:w,onClick:()=>v(!0),children:[(0,a.jsx)(eX.A,{size:14}),r("git.stash.drop")]})]})]}),N?(0,a.jsx)("p",{className:"gx-note err",children:N}):h&&o?0===S?(0,a.jsx)("p",{className:"gx-note",children:r("git.hist.noFiles")}):(0,a.jsxs)("div",{className:"gx-cfilelist",role:"listbox",children:[h.files.map(e=>{var s,t;return(0,a.jsxs)("button",{role:"option","aria-selected":(null==m?void 0:m.path)===e.path&&!m.untracked,className:"gx-cfile ".concat((null==m?void 0:m.path)!==e.path||m.untracked?"":"sel"),onClick:()=>g({path:e.path,untracked:!1,oldPath:e.oldPath}),children:[(0,a.jsx)(eF,{status:e.status}),(0,a.jsx)("span",{className:"mono nm",children:e.path}),(null!==e.additions||null!==e.deletions)&&(0,a.jsxs)("span",{className:"gx-counts sm",children:[(0,a.jsxs)("i",{className:"add",children:["+",null!=(s=e.additions)?s:0]}),(0,a.jsxs)("i",{className:"del",children:["−",null!=(t=e.deletions)?t:0]})]})]},"t-".concat(e.path))}),o.untracked.map(e=>(0,a.jsxs)("button",{role:"option","aria-selected":(null==m?void 0:m.path)===e&&m.untracked,className:"gx-cfile ".concat((null==m?void 0:m.path)===e&&m.untracked?"sel":""),onClick:()=>g({path:e,untracked:!0}),children:[(0,a.jsx)(eF,{status:"untracked"}),(0,a.jsx)("span",{className:"mono nm",children:e})]},"u-".concat(e)))]}):(0,a.jsx)("p",{className:"gx-note",children:r("git.loading")}),m&&(0,a.jsx)("div",{className:"gx-body",children:k?k.binary?(0,a.jsx)("p",{className:"gx-note",children:r("git.diff.binary")}):0===k.hunks.length?(0,a.jsx)("p",{className:"gx-note",children:r("git.diff.empty")}):(0,a.jsx)(eS,{parsed:k,layout:"unified",path:m.path,cutOff:!!(null==j?void 0:j.truncated)}):(0,a.jsx)("p",{className:"gx-note",children:r("git.loading")})}),f&&(0,a.jsx)(D.TM,{danger:!0,title:r("git.stash.drop.title"),body:r("git.stash.drop.body",{name:l.message||"—"}),confirmLabel:r("git.stash.drop"),onClose:()=>v(!1),onConfirm:()=>{w||c.run("stash",r("git.stash.dropped"),"stash-drop",{sha:l.sha})},children:(0,a.jsx)("p",{className:"gx-lost",children:r("git.discard.all.warn")})})]})}var e0=t(6819),e1=t(50703),e4=t(75014),e9=t(10216);function e3(e){let{a:s}=e,{t}=(0,E.s9)(),n=s.notice;return n?(0,a.jsxs)("div",{className:"gx-notice err",role:"alert",children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("b",{className:"grow",children:n.title}),(0,a.jsx)("button",{className:"btn ghost icon sm",onClick:()=>s.setNotice(null),"aria-label":t("common.close"),children:(0,a.jsx)(ej.A,{size:14})})]}),(0,a.jsx)("pre",{children:n.text}),n.diverged&&(0,a.jsxs)("div",{className:"row gap-s wrap",children:[(0,a.jsx)("span",{className:"small muted",children:t("git.notice.diverged")}),(0,a.jsx)("button",{className:"btn sm",disabled:!!s.busy,onClick:()=>void s.run("pull",t("git.done.pull"),"pull",{mode:"merge"}),children:t("git.pull.merge")}),(0,a.jsx)("button",{className:"btn sm",disabled:!!s.busy,onClick:()=>void s.run("pull",t("git.done.pull"),"pull",{mode:"rebase"}),children:t("git.pull.rebase")})]})]}):null}function e6(e){let{a:s,ahead:t,behind:n,detached:l,changeCount:i,onCommit:c}=e,{t:r}=(0,E.s9)(),o=!!s.busy;return(0,a.jsxs)("div",{className:"gx-acts",role:"group","aria-label":r("git.act.group"),children:[(0,a.jsx)("button",{className:"btn sm",disabled:o,title:"".concat(r("git.act.fetch"),": ").concat(r("git.act.fetch.hint")),"aria-label":r("git.act.fetch"),onClick:()=>void s.run("fetch",r("git.done.fetch"),"fetch"),children:"fetch"===s.busy?(0,a.jsx)(R.A,{size:14,className:"spin"}):(0,a.jsx)(e0.A,{size:14})}),(0,a.jsxs)("button",{className:"btn sm",disabled:o,title:"".concat(r("git.act.pull"),": ").concat(r("git.act.pull.hint")),"aria-label":r("git.act.pull"),onClick:()=>void s.run("pull",r("git.done.pull"),"pull"),children:["pull"===s.busy?(0,a.jsx)(R.A,{size:14,className:"spin"}):(0,a.jsx)(e1.A,{size:14}),n>0&&(0,a.jsx)("span",{className:"ct",children:n})]}),(0,a.jsxs)("button",{className:"btn sm",disabled:o||l,title:"".concat(r("git.act.push"),": ").concat(r("git.act.push.hint")),"aria-label":r("git.act.push"),onClick:()=>void s.run("push",r("git.done.push"),"push"),children:["push"===s.busy?(0,a.jsx)(R.A,{size:14,className:"spin"}):(0,a.jsx)(e4.A,{size:14}),t>0&&(0,a.jsx)("span",{className:"ct",children:t})]}),(0,a.jsxs)("button",{className:"btn sm primary",disabled:o||0===i,title:0===i?r("git.commit.nothing"):void 0,onClick:c,children:["commit"===s.busy?(0,a.jsx)(R.A,{size:14,className:"spin"}):(0,a.jsx)(e9.A,{size:14}),r("git.act.commit"),i>0&&(0,a.jsx)("span",{className:"ct",children:i})]})]})}var e2=t(67384);function e5(e){let{agent:s,a:t,current:n,onSwitch:l}=e,{t:c}=(0,E.s9)(),[r,o]=(0,i.useState)(!1),[d,h]=(0,i.useState)(null),[u,m]=(0,i.useState)(""),[g,j]=(0,i.useState)(""),[b,f]=(0,i.useState)(null),[v,N]=(0,i.useState)(null),[y,k]=(0,i.useState)(""),w=(0,i.useRef)(null);(0,eU.s)(r,w,()=>o(!1)),(0,i.useEffect)(()=>{r&&(k(""),f(null),x.FH.get("/agents/".concat(s.id,"/git/branches")).then(h).catch(e=>k(e instanceof Error?e.message:"error")))},[r,s.id]);let C=(0,i.useMemo)(()=>{var e;return(null!=(e=null==d?void 0:d.local)?e:[]).filter(e=>e.name.toLowerCase().includes(u.toLowerCase()))},[d,u]),S=(0,i.useMemo)(()=>{var e,s;let t=new Set((null!=(e=null==d?void 0:d.local)?e:[]).map(e=>e.name));return(null!=(s=null==d?void 0:d.remote)?s:[]).filter(e=>!t.has(e.name.split("/").slice(1).join("/"))&&e.name.toLowerCase().includes(u.toLowerCase()))},[d,u]),z=async(e,s,a,n)=>{o(!1),await t.run(e,s,a,n)},M=/^[\w./-]+$/.test(g)&&!g.startsWith("-")&&!g.endsWith("/")&&!g.includes("..");return(0,a.jsxs)("div",{className:"gx-brmenu",ref:w,children:[(0,a.jsxs)("button",{type:"button",className:"btn sm","aria-expanded":r,"aria-haspopup":"dialog",onClick:()=>o(e=>!e),children:[(0,a.jsx)(V.A,{size:14}),c("git.act.branches"),(0,a.jsx)(A.A,{size:13})]}),r&&(0,a.jsxs)("div",{className:"gx-pop",role:"dialog","aria-label":c("git.act.branches"),children:[(0,a.jsxs)("div",{className:"search",children:[(0,a.jsx)(B.A,{size:14}),(0,a.jsx)("input",{className:"input",autoFocus:!0,placeholder:c("git.br.search"),value:u,onChange:e=>m(e.target.value),"aria-label":c("git.br.search")})]}),(0,a.jsxs)("div",{className:"gx-newbr",children:[(0,a.jsx)("input",{className:"input mono",placeholder:c("git.br.newPlaceholder"),value:g,onChange:e=>j(e.target.value.trim()),"aria-label":c("git.br.new",{branch:null!=n?n:""}),onKeyDown:e=>{"Enter"===e.key&&M&&z("switch",c("git.done.switch",{branch:g}),"switch",{branch:g,create:!0})}}),(0,a.jsxs)("button",{className:"btn sm",disabled:!M||!!t.busy,title:c("git.br.new",{branch:null!=n?n:"…"}),onClick:()=>void z("switch",c("git.done.switch",{branch:g}),"switch",{branch:g,create:!0}),children:[(0,a.jsx)($.A,{size:14}),c("git.br.create")]})]}),y&&(0,a.jsx)("p",{className:"gx-note err",children:y}),(0,a.jsxs)("div",{className:"gx-brlist",children:[C.length>0&&(0,a.jsx)("div",{className:"gx-brhead",children:c("git.br.local")}),C.map(e=>(0,a.jsxs)("div",{className:"gx-br ".concat(e.name===n?"cur":""),children:[(0,a.jsxs)("button",{className:"grow",disabled:e.name===n||!!t.busy,onClick:()=>{o(!1),l(e.name)},title:c("git.br.switchTo",{branch:e.name}),children:[(0,a.jsxs)("span",{className:"nm",children:[e.name===n&&(0,a.jsx)(eH.A,{size:13}),e.name]}),(0,a.jsxs)("span",{className:"sub",children:[e.subject," \xb7 ",(0,p.KN)(Date.parse(e.date))]})]}),e.name!==n&&(0,a.jsx)("button",{className:"btn ghost icon sm",disabled:!!t.busy,onClick:()=>f(e.name),"aria-label":c("git.br.merge",{branch:null!=n?n:""}),title:c("git.br.merge",{branch:null!=n?n:""}),children:(0,a.jsx)(e2.A,{size:14})}),e.name!==n&&(0,a.jsx)("button",{className:"btn ghost icon sm",disabled:!!t.busy,onClick:()=>{t.setNotice(null),N(e.name),o(!1)},"aria-label":c("git.br.delete",{branch:e.name}),title:c("git.br.delete",{branch:e.name}),children:(0,a.jsx)(eX.A,{size:14})})]},e.name)),S.length>0&&(0,a.jsx)("div",{className:"gx-brhead",children:c("git.br.remote")}),S.map(e=>(0,a.jsxs)("div",{className:"gx-br",children:[(0,a.jsxs)("button",{className:"grow",disabled:!!t.busy,onClick:()=>{let s=e.name.split("/").slice(1).join("/");o(!1),l(s)},title:c("git.br.switchTo",{branch:e.name}),children:[(0,a.jsx)("span",{className:"nm",children:e.name}),(0,a.jsxs)("span",{className:"sub",children:[e.subject," \xb7 ",(0,p.KN)(Date.parse(e.date))]})]}),(0,a.jsx)("button",{className:"btn ghost icon sm",disabled:!!t.busy,onClick:()=>f(e.name),"aria-label":c("git.br.merge",{branch:null!=n?n:""}),title:c("git.br.merge",{branch:null!=n?n:""}),children:(0,a.jsx)(e2.A,{size:14})})]},e.name)),d&&!C.length&&!S.length&&(0,a.jsx)("p",{className:"gx-note",children:c("git.br.none")})]}),b&&(0,a.jsxs)("div",{className:"gx-mergeask",children:[(0,a.jsx)("span",{children:c("git.br.mergeAsk",{from:b,into:null!=n?n:""})}),(0,a.jsxs)("div",{className:"row gap-s",children:[(0,a.jsx)("button",{className:"btn ghost sm",onClick:()=>f(null),children:c("common.cancel")}),(0,a.jsx)("button",{className:"btn primary sm",disabled:!!t.busy,onClick:()=>void z("merge",c("git.done.merge",{branch:b}),"merge",{branch:b}),children:c("git.br.mergeGo")})]})]})]}),v&&(0,a.jsxs)(D.aF,{title:c("git.br.delete",{branch:v}),onClose:()=>N(null),children:[(0,a.jsx)("p",{className:"confirm-body",children:c("git.br.deleteAsk",{branch:v})}),t.notice&&(0,a.jsx)("pre",{className:"gx-notice err gx-prewrap",children:t.notice.text}),(0,a.jsxs)("div",{className:"row confirm-actions",children:[(0,a.jsx)("button",{className:"btn ghost",onClick:()=>N(null),children:c("common.cancel")}),t.notice&&/not fully merged/i.test(t.notice.text)?(0,a.jsx)("button",{className:"btn danger",disabled:!!t.busy,onClick:async()=>{await t.run("branch-delete",c("git.done.branchDelete"),"branch-delete",{branch:v,force:!0})&&N(null)},children:c("git.br.deleteForce")}):(0,a.jsx)("button",{className:"btn danger",disabled:!!t.busy,onClick:async()=>{await t.run("branch-delete",c("git.done.branchDelete"),"branch-delete",{branch:v})&&N(null)},children:c("git.br.deleteGo")})]})]})]})}function e7(e){let{changes:s,a:t,onClose:n,initialMessage:l=""}=e,{t:c}=(0,E.s9)(),[r,o]=(0,i.useState)(()=>new Set(s.map(e=>e.path))),[d,h]=(0,i.useState)(l),u=s.filter(e=>r.has(e.path)),m=u.flatMap(e=>e.oldPath?[e.path,e.oldPath]:[e.path]),g=!!d.trim()&&u.length>0&&!t.busy,x=async e=>{if(!await t.run("commit",c("git.done.commit"),"commit",{message:d,paths:m}))return void n();n(),e&&await t.run("push",c("git.done.push"),"push")};return(0,a.jsxs)(D.aF,{title:c("git.commit.title"),onClose:n,children:[(0,a.jsxs)("div",{className:"gx-cfiles",children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("span",{className:"small muted grow",children:c("git.commit.selected",{n:u.length,total:s.length})}),(0,a.jsx)("button",{className:"btn ghost sm",onClick:()=>o(new Set(s.map(e=>e.path))),children:c("git.commit.all")}),(0,a.jsx)("button",{className:"btn ghost sm",onClick:()=>o(new Set),children:c("git.commit.none")})]}),(0,a.jsx)("div",{className:"gx-clist",children:s.map(e=>{var s,t;return(0,a.jsxs)("label",{className:"gx-crow",title:e.path,children:[(0,a.jsx)("input",{type:"checkbox",checked:r.has(e.path),onChange:()=>{let s;return s=e.path,o(e=>{let t=new Set(e);return t.has(s)?t.delete(s):t.add(s),t})}}),(0,a.jsx)(eF,{status:e.status}),(0,a.jsx)("span",{className:"mono nm",children:e.path}),(null!==e.additions||null!==e.deletions)&&(0,a.jsxs)("span",{className:"gx-counts sm",children:[(0,a.jsxs)("i",{className:"add",children:["+",null!=(s=e.additions)?s:0]}),(0,a.jsxs)("i",{className:"del",children:["−",null!=(t=e.deletions)?t:0]})]})]},e.path)})})]}),(0,a.jsxs)("div",{className:"field",children:[(0,a.jsx)("label",{children:c("git.commit.message")}),(0,a.jsx)("textarea",{className:"textarea",rows:4,autoFocus:!0,value:d,onChange:e=>h(e.target.value),placeholder:c("git.commit.placeholder"),onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&"Enter"===e.key&&g&&x(!1)}}),(0,a.jsx)("span",{className:"hint",children:c("git.commit.hint")})]}),(0,a.jsxs)("div",{className:"row confirm-actions",children:[(0,a.jsx)("button",{className:"btn ghost",onClick:n,children:c("common.cancel")}),(0,a.jsx)("button",{className:"btn",disabled:!g,onClick:()=>void x(!1),children:"commit"===t.busy?c("git.commit.committing"):c("git.commit.go")}),(0,a.jsx)("button",{className:"btn primary",disabled:!g,onClick:()=>void x(!0),children:c("git.commit.goPush")})]})]})}function e8(e){let{agent:s,head:t,sel:n,onSelect:l,refs:c,path:r,onClearPath:o}=e,{t:d}=(0,E.s9)(),[h,u]=(0,i.useState)(null),[m,g]=(0,i.useState)(!1),[j,b]=(0,i.useState)(!1),[f,v]=(0,i.useState)(""),[N,y]=(0,i.useState)(""),[k,w]=(0,i.useState)("message"),[C,S]=(0,i.useState)(""),[A,z]=(0,i.useState)("");(0,i.useEffect)(()=>{let e=setTimeout(()=>z(N.trim()),350);return()=>clearTimeout(e)},[N]);let M=!!(A||r||C),F=async e=>{b(!0);try{let t="skip=".concat(e).concat(A?"&q=".concat(encodeURIComponent(A),"&by=").concat(k):"").concat(r?"&path=".concat(encodeURIComponent(r)):"").concat(C?"&ref=".concat(encodeURIComponent(C)):""),a=await x.FH.get("/agents/".concat(s.id,"/git/log?").concat(t));return u(s=>0===e?a.commits:[...null!=s?s:[],...a.commits]),g(a.hasMore),v(""),a.commits}catch(e){return v(e instanceof Error?e.message:"error"),null}finally{b(!1)}},R=(0,i.useRef)("");return(0,i.useEffect)(()=>{let e="".concat(A,"|").concat(k,"|").concat(null!=r?r:"","|").concat(C),s=e!==R.current;R.current=e,F(0).then(e=>{e&&e.length&&(s||!n)&&l(e[0].sha)})},[s.id,t,A,k,r,C]),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"gx-hfilter",children:[(0,a.jsxs)("div",{className:"search",children:[(0,a.jsx)(B.A,{size:14}),(0,a.jsx)("input",{className:"input",placeholder:d("git.hist.search"),value:N,onChange:e=>y(e.target.value),"aria-label":d("git.hist.search"),title:"content"===k?d("git.hist.by.hint"):void 0})]}),(0,a.jsxs)("div",{className:"row gap-s",children:[(0,a.jsxs)("select",{className:"input",value:k,onChange:e=>w(e.target.value),"aria-label":d("git.hist.search"),title:d("git.hist.by.hint"),children:[(0,a.jsx)("option",{value:"message",children:d("git.hist.by.message")}),(0,a.jsx)("option",{value:"author",children:d("git.hist.by.author")}),(0,a.jsx)("option",{value:"content",children:d("git.hist.by.content")})]}),(0,a.jsx)(eD,{refs:c,value:C,onChange:S,extra:[{value:"",label:d("git.hist.branchCurrent")},{value:"all",label:d("git.hist.branchAll")}]})]}),r&&(0,a.jsxs)("div",{className:"gx-chip soft gx-pathchip",children:[(0,a.jsx)("span",{className:"mono nm",title:r,children:d("git.hist.file",{path:r})}),(0,a.jsx)("button",{className:"btn ghost icon sm",onClick:o,"aria-label":d("git.hist.clearFile"),title:d("git.hist.clearFile"),children:(0,a.jsx)(ej.A,{size:13})})]})]}),f?(0,a.jsx)("p",{className:"gx-note err",children:f}):h?h.length?(0,a.jsxs)("div",{className:"gx-hist",role:"listbox","aria-label":d("git.tab.history"),children:[h.map(e=>(0,a.jsxs)("button",{role:"option","aria-selected":n===e.sha,className:"gx-commit ".concat(n===e.sha?"sel":""),onClick:()=>l(e.sha),children:[(0,a.jsx)("span",{className:"subj",children:e.subject||"—"}),(0,a.jsxs)("span",{className:"meta",children:[(0,a.jsx)("span",{className:"mono sha",children:e.short})," \xb7 ",e.author," \xb7 ",(0,p.KN)(Date.parse(e.date))]}),(e.refs.length>0||e.merge)&&(0,a.jsxs)("span",{className:"refs",children:[e.merge&&(0,a.jsx)("i",{className:"ref",children:d("git.hist.merge")}),e.refs.slice(0,3).map(e=>(0,a.jsx)("i",{className:"ref",children:e},e))]})]},e.sha)),m&&(0,a.jsx)("button",{className:"btn sm gx-more",disabled:j,onClick:()=>void F(h.length),children:j?d("git.loading"):d("git.hist.more")})]}):(0,a.jsx)("p",{className:"gx-note",children:M?d("git.hist.noMatch"):d("git.hist.empty")}):(0,a.jsx)("p",{className:"gx-note",children:d("git.loading")})]})}function se(e){let{files:s,all:t,summary:n,file:l,onConfirm:i,onClose:c}=e,{t:r}=(0,E.s9)(),o=(0,a.jsxs)("ul",{className:"gx-dlist",children:[s.slice(0,8).map(e=>(0,a.jsx)("li",{className:"mono",children:e},e)),s.length>8&&(0,a.jsx)("li",{className:"muted",children:r("hover.more",{count:s.length-8})})]});if(!t&&l&&!s.length){var d;let e=l.add||l.del?" (+".concat(l.add," −").concat(l.del,")"):"";return(0,a.jsxs)(D.TM,{danger:!0,title:r("git.discard.file.title"),confirmLabel:r("git.discard.file.go"),onConfirm:i,onClose:c,children:[(0,a.jsx)("p",{className:"gx-file-eff mono",children:l.path}),(0,a.jsx)("p",{className:"confirm-body",children:"deleted"===l.status?r("git.discard.file.deleted"):"renamed"===l.status?r("git.discard.file.renamed",{from:null!=(d=l.oldPath)?d:""}):r("git.discard.file.modified",{lines:e})}),(0,a.jsx)("p",{className:"gx-lost",children:r("git.discard.all.warn")})]})}return t?(0,a.jsxs)(D.TM,{danger:!0,title:r("git.discard.all.title"),confirmLabel:r("git.discard.all.go"),onConfirm:i,onClose:c,children:[(0,a.jsxs)("ul",{className:"gx-effects",children:[n&&n.restore>0&&(0,a.jsx)("li",{children:r("git.discard.all.restore",{count:n.restore})}),s.length>0&&(0,a.jsxs)("li",{className:"bad",children:[(0,a.jsx)("b",{children:r("git.discard.all.delete",{count:s.length})}),o]})]}),n&&(0,a.jsx)("p",{className:"muted small confirm-body",children:r("git.discard.all.lines",{add:n.add,del:n.del})}),(0,a.jsx)("p",{className:"gx-lost",children:r("git.discard.all.warn")})]}):(0,a.jsx)(D.TM,{danger:!0,title:r("git.discard.confirm.title"),body:r("git.discard.confirm.body",{count:s.length}),confirmLabel:r("git.discard.confirm.go"),onConfirm:i,onClose:c,children:o})}var ss=t(8591);function st(e){var s,t;let{agent:n,path:l,ignored:c=!1,change:r,stamp:o,refs:d,focusLine:h,onHistory:m,onOpenCommit:g,onDiscard:p,onDiscardHunk:j,onDiscardLines:b}=e,{t:f}=(0,E.s9)(),[v,N]=(0,i.useState)(!1),y=!!r&&!eg.test(l),k=ex.test(l),w=h?"file":y?"diff":k?"preview":"file",[C,S]=(0,i.useState)(w),[A,M]=(0,i.useState)("unified"),[F,R]=(0,i.useState)(null),[P,_]=(0,i.useState)(null),[L,I]=(0,i.useState)(null),[T,H]=(0,i.useState)(!1),[U,K]=(0,i.useState)(!1),W=eg.test(l),[O,q]=(0,i.useState)(null);(0,i.useEffect)(()=>{q(null)},[l]),(0,i.useEffect)(()=>{S(w),K(!1)},[l,y]),(0,i.useEffect)(()=>{let e=!1;I(null);let s="path=".concat(encodeURIComponent(l));return H(!0),("diff"===C&&r?x.FH.get("/agents/".concat(n.id,"/git/diff?").concat(s).concat(r.oldPath?"&old=".concat(encodeURIComponent(r.oldPath)):"")).then(s=>!e&&R(s)):W?Promise.resolve():x.FH.get("/agents/".concat(n.id,"/git/file?").concat(s)).then(s=>!e&&_(s))).catch(s=>!e&&I(s instanceof Error?s.message:f("git.loadError"))).finally(()=>!e&&H(!1)),()=>{e=!0}},[n.id,l,C,null==r?void 0:r.status,null==r?void 0:r.oldPath,o]);let $=(0,i.useMemo)(()=>F&&F.path===l?eb(F.diff):null,[F,l]),[B,G]=(0,i.useState)(null),J=(null==r?void 0:r.status)==="untracked"||(null==r?void 0:r.status)==="added"&&!r.oldPath;(0,i.useEffect)(()=>{if(G(null),"file"!==C||!r||W||J||"deleted"===r.status||"conflict"===r.status)return;let e=!1;return x.FH.get("/agents/".concat(n.id,"/git/diff?path=").concat(encodeURIComponent(l)).concat(r.oldPath?"&old=".concat(encodeURIComponent(r.oldPath)):"")).then(s=>!e&&G(s)).catch(()=>void 0),()=>{e=!0}},[n.id,l,C,null==r?void 0:r.status,null==r?void 0:r.oldPath,o]);let Q=(0,i.useMemo)(()=>B&&B.path===l?eb(B.diff):null,[B,l]),X=(0,i.useMemo)(()=>Q?function(e){let s=new Map,t=new Set,a=new Map,n=new Map,l=[];for(let m of e.hunks){var i,c,r,o,d,h,u;let e=m.lines,g=[],x=Number(null!=(c=null==(i=/\+(\d+)/.exec(m.header))?void 0:i[1])?c:1);for(let s=0;s<e.length;s++)g[s]=x,"del"!==e[s].kind&&(x=(null!=(r=e[s].newNo)?r:x)+1);let p=[];for(let s=0;s<e.length;){if("ctx"===e[s].kind){s++;continue}let t=s;for(;s<e.length&&"ctx"!==e[s].kind;)s++;p.push([t,s-1])}for(let[i,c]of p){let r=l.length,m=1/0,p=-1/0;for(let l=i;l<=c;){if("ctx"===e[l].kind){l++;continue}let i=[],o=[];for(;l<=c&&"del"===e[l].kind;)i.push(e[l++]);for(;l<=c&&"add"===e[l].kind;)o.push(e[l++]);o.forEach((e,t)=>{let n=e.newNo;s.set(n,t<i.length?"mod":"add"),a.set(n,r),m=Math.min(m,n),p=Math.max(p,n)});let d=o.length?o[o.length-1].newNo+1:l<e.length?g[l]:x;i.length>o.length&&(t.add(d),n.set(d,r),m=Math.min(m,d),p=Math.max(p,d))}let j=i;for(let s=0;s<3&&j>0&&"ctx"===e[j-1].kind;s++)j--;let b=c;for(let s=0;s<3&&b<e.length-1&&"ctx"===e[b+1].kind;s++)b++;let f=e.slice(j,b+1),v=f.filter(e=>void 0!==e.oldNo),N=f.filter(e=>void 0!==e.newNo);l.push({from:m,to:p,view:{header:"@@ -".concat(null!=(h=null==(o=v[0])?void 0:o.oldNo)?h:0,",").concat(v.length," +").concat(null!=(u=null==(d=N[0])?void 0:d.newNo)?u:0,",").concat(N.length," @@"),section:"",lines:f}})}}return{lines:s,removedBefore:t,blockOfLine:a,blockOfRemoval:n,groups:l}}(Q):null,[Q]),Y=l.lastIndexOf("/"),Z=Y>=0?l.slice(0,Y+1):"",V=l.slice(Y+1);return(0,a.jsxs)("section",{className:"gx-preview","aria-label":l,children:[(0,a.jsxs)("header",{className:"gx-phead",children:[(0,a.jsxs)("div",{className:"gx-ptitle",children:[(0,a.jsxs)("span",{className:"gx-path mono",title:l,children:[(0,a.jsx)("span",{className:"dir",children:Z}),(0,a.jsx)("b",{children:V})]}),c&&(0,a.jsx)("span",{className:"gx-chip soft",title:f("git.ignored.hint"),children:f("git.ignored.chip")}),r&&(0,a.jsx)("span",{className:"gx-chip st-".concat(r.status),children:f("git.status.".concat(r.status))}),(null==r?void 0:r.staged)&&(0,a.jsx)("span",{className:"gx-chip soft",children:f("git.staged")}),(null==r?void 0:r.unstaged)&&"untracked"!==r.status&&(0,a.jsx)("span",{className:"gx-chip soft",children:f("git.unstaged")}),r&&(null!==r.additions||null!==r.deletions)&&(0,a.jsxs)("span",{className:"gx-counts",children:[(0,a.jsxs)("i",{className:"add",children:["+",null!=(s=r.additions)?s:0]}),(0,a.jsxs)("i",{className:"del",children:["−",null!=(t=r.deletions)?t:0]})]}),P&&!r&&(0,a.jsx)("span",{className:"muted small",children:(0,z.zi)(P.size)})]}),(0,a.jsxs)("div",{className:"gx-ptr",children:[(null==r?void 0:r.status)!=="untracked"&&!c&&(0,a.jsx)("button",{type:"button",className:"btn ghost icon sm",title:f("git.file.history"),"aria-label":f("git.file.history"),onClick:()=>m(l),children:(0,a.jsx)(u.A,{size:15})}),(null==r?void 0:r.status)!=="untracked"&&!c&&(0,a.jsx)(eD,{refs:d,value:null!=O?O:"",onChange:q,compact:!0,label:f("git.file.viewAt"),extra:[{value:"",label:f("git.file.viewAt")}]}),!W&&!c&&!O&&(null==r?void 0:r.status)!=="deleted"&&(null==r?void 0:r.status)!=="untracked"&&(null==r?void 0:r.status)!=="conflict"&&(()=>{let e=v&&"file"===C;return(0,a.jsx)("button",{type:"button",className:"btn ghost icon sm ".concat(e?"on":""),"aria-pressed":e,"aria-label":f("git.blame"),title:"".concat(f("git.blame"),": ").concat(f("git.blame.hint")),onClick:()=>{"file"!==C?(S("file"),N(!0)):N(e=>!e)},children:(0,a.jsx)(ss.A,{size:15})})})(),(0,a.jsx)(ec.WQ,{text:l,label:f("git.copyPath"),compact:!0}),r&&"conflict"!==r.status&&(0,a.jsxs)("button",{type:"button",className:"btn sm",title:f("git.discard.hint"),onClick:()=>p(r),children:[(0,a.jsx)(es.A,{size:14}),f("git.discard")]})]}),(0,a.jsx)("div",{className:"gx-ptools",children:(0,a.jsxs)("div",{className:"gx-ptl",children:[(r||k)&&(0,a.jsx)(D.$q,{value:C,onChange:S,options:[...r?[{id:"diff",label:f("git.view.diff")}]:[],...k?[{id:"preview",label:f("git.view.preview")}]:[],{id:"file",label:f(k?"git.view.source":"git.view.file")}]}),"diff"===C&&r&&(0,a.jsx)(D.$q,{value:A,onChange:M,options:[{id:"unified",label:f("git.layout.unified")},{id:"split",label:f("git.layout.split")}]})]})})]}),(null==r?void 0:r.oldPath)&&(0,a.jsx)("div",{className:"gx-banner",children:f("git.renamedFrom",{path:r.oldPath})}),O&&(0,a.jsxs)("div",{className:"gx-banner row gap-s",children:[(0,a.jsx)("span",{className:"grow",children:f("git.file.atRef",{ref:O})}),(0,a.jsx)("button",{className:"btn sm",onClick:()=>q(null),children:f("git.file.backToCurrent")})]}),O?(0,a.jsx)(eE,{agent:n,gitRef:O,path:(null==r?void 0:r.oldPath)&&O?r.oldPath:l,toolbar:!1}):(0,a.jsx)("div",{className:"gx-body",children:L?(0,a.jsx)("p",{className:"gx-note err",children:L}):!T||$||P?"diff"===C&&r?$?$.binary?(0,a.jsx)("p",{className:"gx-note",children:f("git.diff.binary")}):0===$.hunks.length?(0,a.jsx)("p",{className:"gx-note",children:f("git.diff.empty")}):(0,a.jsxs)(a.Fragment,{children:[(null==F?void 0:F.truncated)&&(0,a.jsx)("div",{className:"gx-banner",children:f("git.diff.truncated")}),(0,a.jsx)(eS,{parsed:$,layout:A,path:l,cutOff:!!(null==F?void 0:F.truncated),onDiscardHunk:(null==r?void 0:r.status)==="modified"?(e,s)=>j(l,e,s):void 0,onDiscardLines:(null==r?void 0:r.status)==="modified"?(e,s,t)=>b(l,e,s,t):void 0})]}):null:W&&!U&&(null==r?void 0:r.status)!=="deleted"?(0,a.jsx)("div",{className:"gx-image",children:(0,a.jsx)("img",{src:"/api/agents/".concat(n.id,"/git/raw?path=").concat(encodeURIComponent(l),"&v=").concat(o),alt:V,onError:()=>K(!0)})}):"preview"===C&&P&&P.path===l?(0,a.jsxs)("div",{className:"gx-md md",children:[P.truncated&&(0,a.jsx)("div",{className:"gx-banner",children:f("git.diff.truncated")}),(0,a.jsx)(eu.oz,{remarkPlugins:[em.A],components:{a:e=>(0,a.jsx)("a",{...e,target:"_blank",rel:"noreferrer"})},children:P.content})]}):P&&P.path===l?(0,a.jsx)(ez,{f:P,agent:n,blame:v,onOpenCommit:g,marks:X,allNew:J,focusLine:h}):W&&U?(0,a.jsx)("p",{className:"gx-note",children:f("git.file.binary")}):null:(0,a.jsx)("p",{className:"gx-note",children:f("git.loading")})})]})}var sa=t(43249),sn=t(19431),sl=t(63745);function si(e){let{name:s}=e;return eg.test(s)?(0,a.jsx)(sa.A,{size:15}):/\.(md|mdx|txt|rst)$/i.test(s)?(0,a.jsx)(sn.A,{size:15}):(0,ek.eX)(s)?(0,a.jsx)(sl.A,{size:15}):(0,a.jsx)(et.A,{size:15})}let sc=(0,i.memo)(function(e){var s,t;let{rows:n,expanded:l,forceOpen:c,sel:r,onToggle:o,onSelect:d,label:h}=e,{t:u}=(0,E.s9)(),m=(0,i.useRef)(null),[g,x]=(0,i.useState)(null),p=e=>"".concat(e.ignored?"i:":"").concat(e.path),j=n.some(e=>p(e.node)===g)?g:null!=(t=null==(s=n.find(e=>e.node.path===r&&!e.node.ignored))?void 0:s.node.path)?t:n[0]?p(n[0].node):null,b=(0,i.useCallback)(e=>{var s,t;let a=[...null!=(t=null==(s=m.current)?void 0:s.querySelectorAll("[data-row]"))?t:[]],n=a.indexOf(document.activeElement),l=s=>{var t;e.preventDefault(),null==(t=a[Math.max(0,Math.min(a.length-1,s))])||t.focus()};if("ArrowDown"===e.key)l(n+1);else if("ArrowUp"===e.key)l(n-1);else if("Home"===e.key)l(0);else if("End"===e.key)l(a.length-1);else if(n>=0&&("ArrowRight"===e.key||"ArrowLeft"===e.key)){let s=a[n],t="1"===s.dataset.dir,i="true"===s.getAttribute("aria-expanded");if("ArrowRight"===e.key)t&&!i?(e.preventDefault(),s.click()):t&&i&&l(n+1);else if(t&&i)e.preventDefault(),s.click();else{let e=Number(s.getAttribute("aria-level"));for(let s=n-1;s>=0;s--)if(Number(a[s].getAttribute("aria-level"))<e){l(s);break}}}},[]);return(0,a.jsx)("div",{className:"gx-tree-rows",ref:m,onKeyDown:b,role:"tree","aria-label":h,children:n.map(e=>{var s,t;let{node:n,depth:i}=e,h="dir"===n.type,m=h&&(c||l.has(n.path)),g=n.change,b=p(n);return(0,a.jsxs)("button",{"data-row":!0,"data-dir":h?"1":"0","data-path":n.path,type:"button",role:"treeitem","aria-level":i+1,"aria-expanded":h?!!m:void 0,"aria-selected":!h&&r===n.path,tabIndex:j===b?0:-1,onFocus:()=>x(b),className:"gx-row ".concat(h?"dir":"file"," ").concat(n.ignored?"ignored":""," ").concat(g?"changed st-".concat(g.status):""," ").concat(!h&&r===n.path?"sel":""," ").concat(h&&n.changed?"has-changes":""),style:{paddingLeft:8+14*i},title:n.ignored?"".concat(n.path,": ").concat(u("git.ignored.hint")):n.path,onClick:()=>h?o(n):d(n.path),children:[(0,a.jsx)("span",{className:"chev",children:h?m?(0,a.jsx)(A.A,{size:14}):(0,a.jsx)(ee.A,{size:14}):null}),(0,a.jsx)("span",{className:"ico",children:h?m?(0,a.jsx)(eh.A,{size:15}):(0,a.jsx)(Y.A,{size:15}):(0,a.jsx)(si,{name:n.name})}),(0,a.jsx)("span",{className:"nm",children:n.name}),h&&n.changed>0&&(0,a.jsx)("span",{className:"dirdot",title:u("git.dirChanged",{count:n.changed}),children:n.changed}),g&&(0,a.jsxs)("span",{className:"meta",children:[(null!==g.additions||null!==g.deletions)&&(0,a.jsxs)("span",{className:"gx-counts sm",children:[(0,a.jsxs)("i",{className:"add",children:["+",null!=(s=g.additions)?s:0]}),(0,a.jsxs)("i",{className:"del",children:["−",null!=(t=g.deletions)?t:0]})]}),(0,a.jsx)(eF,{status:g.status,titled:!0})]})]},b)})})});var sr=t(32898),so=t(61904),sd=t(2507);let sh=["files","history","tags","compare","stashes"],su={files:sr.A,history:u.A,tags:ed.A,compare:so.A,stashes:sd.A},sm=e=>"gx-tab-".concat(e),sg="gx-side-panel";function sx(e){let{mode:s,onChange:t,stashCount:n,label:l}=e,{t:i}=(0,E.s9)(),c=e=>"".concat(i("git.tab.".concat(e))).concat("stashes"===e&&n?" \xb7 ".concat(n):"");return(0,a.jsx)("div",{className:"gx-tabs",role:"tablist","aria-label":l,onKeyDown:e=>{let a=sh.indexOf(s),n=null;"ArrowRight"===e.key||"ArrowDown"===e.key?n=(a+1)%sh.length:"ArrowLeft"===e.key||"ArrowUp"===e.key?n=(a-1+sh.length)%sh.length:"Home"===e.key?n=0:"End"===e.key&&(n=sh.length-1),null!==n&&(e.preventDefault(),t(sh[n]),requestAnimationFrame(()=>{var e;return null==(e=document.getElementById(sm(sh[n])))?void 0:e.focus()}))},children:sh.map((e,n)=>{let l=su[e];return(0,a.jsxs)("button",{id:sm(e),type:"button",role:"tab","aria-selected":s===e,"aria-controls":sg,tabIndex:s===e?0:-1,"aria-label":c(e),title:"".concat(c(e)," (Alt+").concat(n+1,")"),className:"gx-tab ".concat(s===e?"on":""),onClick:()=>t(e),children:[(0,a.jsx)(l,{size:15}),s===e&&(0,a.jsx)("span",{children:c(e)})]},e)})})}function sp(e){var s,t,n,l,c,r,o,d,h,u;let{agent:m,git:g}=e,{t:j}=(0,E.s9)(),{status:b,tree:f,loading:v,error:N,refresh:y}=g,[k,w]=(0,i.useState)(null),[C,S]=(0,i.useState)(new Set),[M,F]=(0,i.useState)(""),[R,P]=(0,i.useState)(!1),[_,L]=(0,i.useState)(!1),[I,T]=(0,i.useState)("files"),[H,U]=(0,i.useState)(null),[K,W]=(0,i.useState)({base:"",head:""}),[O,q]=(0,i.useState)(!1),[$,G]=(0,i.useState)(null),[J,Q]=(0,i.useState)(),X=(0,i.useRef)(null),[ed,eh]=(0,i.useState)(null),[eu,em]=(0,i.useState)(null),[eg,ex]=(0,i.useState)(null),[ep,ej]=(0,i.useState)(!1),[eb,ef]=(0,i.useState)(null),[ev,eN]=(0,i.useState)(!1),[ey,ek]=(0,i.useState)(null),[ew,eC]=(0,i.useState)(!1),eS=function(e,s){let{t}=(0,E.s9)(),a=(0,D.dj)(),[n,l]=(0,i.useState)(null),[c,r]=(0,i.useState)(null),o=async function(n,i,c){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};l(n),r(null);try{var d,h,u;let n=await x.FH.post("/agents/".concat(e.id,"/git/").concat(c),o),l=null!=(u=(null!=(h=n.output)?h:"").split("\n").filter(Boolean).pop())?u:"",r=["conflicts"===n.pending?t("git.pending.conflicts"):"",(null==(d=n.kept)?void 0:d.length)?t("git.sw.kept",{count:n.kept.length,names:n.kept.slice(0,3).join(", ")}):""].filter(Boolean).join(", ");return a(r?"".concat(i,": ").concat(r):l&&l.length<90?"".concat(i,": ").concat(l):i),await s(),!0}catch(a){let e=a instanceof Error?a.message:"error";return r({title:t("git.notice.failed",{action:i}),text:e,diverged:/fast-forward|divergent/i.test(e)}),await s(),!1}finally{l(null)}};return{busy:n,notice:c,setNotice:r,run:o}}(m,()=>y()),[eA,ez]=(0,i.useState)(null),eE=(0,er.Wx)(),eM=(0,i.useRef)(new Set),eF=b&&b.isRepo?b:null,eR=function(e,s){let[t,a]=(0,i.useState)(null);return(0,i.useEffect)(()=>{let s=!1;return x.FH.get("/agents/".concat(e.id,"/git/refs")).then(e=>!s&&a(e)).catch(()=>!s&&a({current:null,branches:[],remotes:[],tags:[]})),()=>{s=!0}},[e.id,s]),t}(m,null==eF||null==(s=eF.head)?void 0:s.sha),eP=f&&f.isRepo?f.files:null,eT=f&&f.isRepo?f.ignored:null,[eH,eU]=(0,i.useState)({});(0,i.useEffect)(()=>{eU({})},[m.id,m.effective.cwd]);let eD=(0,i.useMemo)(()=>eF&&eP?el(eP,eF.changes,eE.showIgnored&&null!=eT?eT:[],eH):null,[eF,eP,eT,eH,eE.showIgnored]),eO=(0,i.useMemo)(()=>{let e=(null!=eT?eT:[]).map(e=>e.replace(/\/$/,""));return s=>e.some(e=>s===e||s.startsWith("".concat(e,"/")))},[eT]),eq=(0,i.useMemo)(()=>{var e;return new Map((null!=(e=null==eF?void 0:eF.changes)?e:[]).map(e=>[e.path,e]))},[eF]),e$=(0,i.useMemo)(()=>{var e;return(null!=(e=null==eF?void 0:eF.changes)?e:[]).reduce((e,s)=>{var t,a;return{add:e.add+(null!=(t=s.additions)?t:0),del:e.del+(null!=(a=s.deletions)?a:0)}},{add:0,del:0})},[eF]);(0,i.useEffect)(()=>{if(!eD)return;let e=new Set,s=t=>{for(let n of t.children)if("dir"===n.type){var a;!eM.current.has(n.path)&&(n.changed>0||0===eM.current.size&&(null!=(a=null==eP?void 0:eP.length)?a:0)<=40)&&e.add(n.path),s(n)}};s(eD);let t=e=>{for(let s of e.children)"dir"===s.type&&(eM.current.add(s.path),t(s))};t(eD),e.size&&S(s=>new Set([...s,...e]))},[eD]),(0,i.useEffect)(()=>{var e;eD&&null===k&&(null==eF?void 0:eF.changes.length)&&w((null!=(e=eF.changes.find(e=>"conflict"===e.status))?e:eF.changes[0]).path)},[eD]),(0,i.useEffect)(()=>{let e=!1;return x.FH.get("/agents/".concat(m.id,"/git/stashes")).then(s=>{e||(em(s),ex(e=>{var t,a;return e&&s.some(s=>s.sha===e)?e:null!=(a=null==(t=s[0])?void 0:t.sha)?a:null}))}).catch(()=>void 0),()=>{e=!0}},[m.id,null==eF?void 0:eF.generatedAt]);let eJ="hive-am.git.last.".concat(m.id);(0,i.useEffect)(()=>{if(k)try{localStorage.setItem(eJ,k)}catch(e){}},[k,eJ]),(0,i.useEffect)(()=>{if(eD&&null===k&&(null==eF||!eF.changes.length))try{let e=localStorage.getItem(eJ);e&&(null==eP?void 0:eP.includes(e))&&w(e)}catch(e){}},[eD]),(0,i.useEffect)(()=>{let e=M.trim();if(!O||e.length<2)return void G(null);let s=!1,t=setTimeout(()=>x.FH.get("/agents/".concat(m.id,"/git/grep?q=").concat(encodeURIComponent(e))).then(t=>!s&&G({q:e,...t})).catch(()=>!s&&G({q:e,hits:[],truncated:!1})),350);return()=>{s=!0,clearTimeout(t)}},[m.id,O,M,null==eF?void 0:eF.generatedAt]),(0,i.useEffect)(()=>{let e=e=>{let s=e.target,t=!!s&&("INPUT"===s.tagName||"TEXTAREA"===s.tagName||"SELECT"===s.tagName||s.isContentEditable);"/"!==e.key||t||e.ctrlKey||e.metaKey||e.altKey?e.altKey&&!e.ctrlKey&&!e.metaKey&&/^[1-5]$/.test(e.key)&&(e.preventDefault(),T(sh[Number(e.key)-1])):(e.preventDefault(),T("files"),setTimeout(()=>{var e;return null==(e=X.current)?void 0:e.focus()},0))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]);let eQ=(0,i.useMemo)(()=>eD?ei(eD,C,{query:M,onlyChanged:R}):[],[eD,C,M,R]),eX=(0,i.useMemo)(()=>eQ.slice(0,2e3),[eQ]),e0=(0,i.useRef)(eH);e0.current=eH;let e1=(0,i.useCallback)(e=>{let s;s=e.path,S(e=>{let t=new Set(e);return t.has(s)?t.delete(s):t.add(s),t}),!e.ignored||!e.lazy||e.path in e0.current||x.FH.get("/agents/".concat(m.id,"/git/ls?path=").concat(encodeURIComponent(e.path))).then(s=>eU(t=>({...t,[e.path]:s.entries}))).catch(()=>eU(s=>({...s,[e.path]:[]})))},[m.id]),e4=(0,i.useCallback)(e=>{Q(void 0),w(e)},[]);if(N&&!b)return(0,a.jsx)("div",{className:"gx",children:(0,a.jsxs)("div",{className:"gx-empty",children:[(0,a.jsx)("h3",{children:j("git.error.title")}),(0,a.jsx)("p",{children:N}),(0,a.jsx)("button",{className:"btn",onClick:()=>void y(),children:j("git.refresh")})]})});if(!b)return(0,a.jsx)("div",{className:"gx",children:(0,a.jsx)("div",{className:"gx-empty",children:(0,a.jsx)("p",{children:j("git.loading")})})});if(!b.isRepo)return(0,a.jsx)("div",{className:"gx",children:(0,a.jsxs)("div",{className:"gx-empty",children:[(0,a.jsx)(Y.A,{size:26,className:"muted"}),(0,a.jsx)("h3",{children:"not-repo"===b.reason?j("git.notRepo.title"):"no-git"===b.reason?j("git.noGit.title"):j("git.error.title")}),(0,a.jsx)("p",{children:"not-repo"===b.reason?j("git.notRepo.body",{path:b.cwd.replace(/^\/home\/[^/]+/,"~")}):"no-git"===b.reason?j("git.noGit.body"):b.message}),(0,a.jsxs)("button",{className:"btn",onClick:()=>void y(),children:[(0,a.jsx)(Z.A,{size:14}),j("git.refresh")]})]})});let e9=k?eq.get(k):void 0,e2=e=>eS.run("switch",e.carried?j("git.done.switchCarried",{branch:e.to,count:e.carried}):j("git.done.switch",{branch:e.to}),e.overlap.length||e.collisions.length?"switch-smart":"switch",{branch:e.to}),ss=async e=>{try{let s=await x.FH.get("/agents/".concat(m.id,"/git/switch-plan?branch=").concat(encodeURIComponent(e)));s.others.length||s.selfRunning?ef(s):await e2(s)}catch(s){eS.setNotice({title:j("git.notice.failed",{action:j("git.done.switch",{branch:e})}),text:s instanceof Error?s.message:"error",diverged:!1})}},sa=e=>e.filter(e=>"untracked"===e.status||"added"===e.status&&!e.oldPath).map(e=>e.path),sn=(0,z.Xd)(b.generatedAt);return(0,a.jsxs)("div",{className:"gx","data-gx-theme":eE.theme,style:{"--g-tab":eE.tabSize},children:[(0,a.jsxs)("div",{className:"gx-bar",children:[(0,a.jsxs)("button",{type:"button",className:"gx-branch","aria-expanded":_,"aria-controls":"gx-info",title:j("git.info.toggle"),onClick:()=>L(e=>!e),children:[(0,a.jsx)(V.A,{size:14}),(0,a.jsx)("span",{className:"bn",children:null!=(c=b.branch)?c:b.head?"".concat(j("git.detached")," ").concat(b.head.sha):j("git.noCommitsBranch")}),b.head&&(0,a.jsx)("span",{className:"sha",children:b.head.sha}),b.upstream&&(b.upstream.ahead>0||b.upstream.behind>0)&&(0,a.jsxs)("span",{className:"ab",title:j("git.upstream"),children:[b.upstream.ahead>0&&"↑".concat(b.upstream.ahead),b.upstream.ahead>0&&b.upstream.behind>0&&" ",b.upstream.behind>0&&"↓".concat(b.upstream.behind)]}),_?(0,a.jsx)(A.A,{size:14}):(0,a.jsx)(ee.A,{size:14})]}),(0,a.jsx)("span",{className:"grow"}),(0,a.jsx)("span",{className:"gx-sum",children:0===b.changes.length?(0,a.jsx)("span",{className:"muted",children:j("git.clean")}):(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)("span",{title:j("git.summary",{count:b.changes.length}),"aria-label":j("git.summary",{count:b.changes.length}),children:[(0,a.jsx)("b",{children:b.changes.length})," ",(0,a.jsx)("span",{className:"muted",children:j("git.files.short")})," ",(0,a.jsxs)("i",{className:"add",children:["+",(0,z._E)(e$.add)]})," ",(0,a.jsxs)("i",{className:"del",children:["−",(0,z._E)(e$.del)]})]})})}),(0,a.jsx)(e5,{agent:m,a:eS,current:b.branch,onSwitch:e=>void ss(e)}),(0,a.jsx)(e6,{a:eS,ahead:null!=(r=null==(t=b.upstream)?void 0:t.ahead)?r:0,behind:null!=(o=null==(n=b.upstream)?void 0:n.behind)?o:0,detached:!b.branch,changeCount:b.changes.length,onCommit:()=>eC(!0)}),(0,a.jsx)("button",{className:"btn ghost icon sm",disabled:!!eS.busy||0===b.changes.length||!!b.state,onClick:()=>{let e=sa(b.changes);ez({files:e,all:!0,summary:{restore:b.changes.length-e.length,add:e$.add,del:e$.del},go:async()=>{let e=await eS.run("discard-all",j("git.done.discard"),"discard-all");return e&&w(null),e}})},"aria-label":j("git.discard.all"),title:b.state?j("git.discard.all.blocked"):j("git.discard.all"),children:(0,a.jsx)(es.A,{size:15})}),(0,a.jsx)(eo.i,{}),(0,a.jsx)("button",{className:"btn ghost icon sm",onClick:()=>void y(),"aria-label":j("git.refresh"),title:"".concat(j("git.refresh")," \xb7 ").concat(j("git.updated",{time:sn})),children:(0,a.jsx)(Z.A,{size:15,className:v?"spin":""})})]}),_&&(0,a.jsxs)("dl",{id:"gx-info",className:"gx-info",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{children:j("git.info.branch")}),(0,a.jsxs)("dd",{className:"mono",children:[null!=(d=b.branch)?d:b.head?"".concat(j("git.detached")," ").concat(b.head.sha):j("git.noCommitsBranch"),b.branch&&(0,a.jsx)(ec.WQ,{text:b.branch,label:j("git.info.copyBranch")})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{children:j("git.info.upstreamLabel")}),(0,a.jsx)("dd",{children:b.upstream?0===b.upstream.ahead&&0===b.upstream.behind?j("git.info.inSync"):j("git.info.upstreamStatus",{ahead:b.upstream.ahead,behind:b.upstream.behind}):(0,a.jsx)("span",{className:"muted",children:j("git.info.noUpstream")})})]}),b.head?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{children:j("git.info.commit")}),(0,a.jsxs)("dd",{className:"mono",children:[b.head.sha,(0,a.jsx)(ec.WQ,{text:b.head.sha,label:j("git.info.copySha")})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{children:j("git.info.message")}),(0,a.jsx)("dd",{className:"msg",children:b.head.subject||(0,a.jsx)("span",{className:"muted",children:"—"})})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{children:j("git.info.author")}),(0,a.jsx)("dd",{children:b.head.author})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{children:j("git.info.when")}),(0,a.jsxs)("dd",{children:[(0,z.v7)(b.head.when)," ",(0,a.jsxs)("span",{className:"muted",children:["\xb7 ",(0,p.KN)(Date.parse(b.head.when))]})]})]})]}):(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{children:j("git.info.commit")}),(0,a.jsx)("dd",{className:"muted",children:j("git.noCommits")})]})]}),"running"===m.status&&(0,a.jsx)("div",{className:"gx-warn",children:j("git.warn.running",{name:m.name})}),b.state&&(()=>{let e=b.changes.filter(e=>"conflict"===e.status),s="merge"===b.state?j("git.state.merge"):"rebase"===b.state?j("git.state.rebase"):j("git.state.stash");return(0,a.jsxs)("div",{className:"gx-state",role:"status",children:[(0,a.jsx)("b",{children:s}),(0,a.jsxs)("span",{className:"grow",children:["stash"===b.state&&b.stash&&(0,a.jsxs)(a.Fragment,{children:[j("git.state.stash.hint",{from:b.stash.from,to:b.stash.to})," \xb7 "]}),e.length>0?j("git.state.conflicts",{count:e.length}):j("git.state.ready")]}),0===e.length&&("merge"===b.state?(0,a.jsx)("button",{className:"btn primary sm",disabled:!!eS.busy,onClick:()=>eC(!0),children:j("git.state.finishMerge")}):"rebase"===b.state?(0,a.jsx)("button",{className:"btn primary sm",disabled:!!eS.busy,onClick:()=>void eS.run("continue",j("git.done.rebaseContinue"),"rebase-continue"),children:j("git.state.continueRebase")}):(0,a.jsx)("button",{className:"btn primary sm",disabled:!!eS.busy,onClick:()=>void eS.run("smart",j("git.done.smartFinish"),"smart-finish"),children:j("git.state.finishStash")})),"stash"===b.state?(0,a.jsx)("button",{className:"btn sm danger",disabled:!!eS.busy,onClick:()=>eN(!0),children:j("git.state.cancelStash")}):(0,a.jsx)("button",{className:"btn sm danger",disabled:!!eS.busy,onClick:()=>void eS.run("abort",j("git.done.mergeAbort"),"merge-abort"),children:"merge"===b.state?j("git.state.abortMerge"):j("git.state.abortRebase")})]})})(),(0,a.jsx)(e3,{a:eS}),b.scope&&(0,a.jsx)("div",{className:"gx-scope",children:j("git.scope",{path:b.scope})}),(0,a.jsxs)("div",{className:"gx-main",children:[(0,a.jsxs)("aside",{className:"gx-tree","aria-label":j("git.filesLabel"),children:[(0,a.jsx)(sx,{mode:I,onChange:T,stashCount:null!=(h=null==eu?void 0:eu.length)?h:0,label:j("git.filesLabel")}),(0,a.jsx)("div",{className:"gx-sidepanel",id:sg,role:"tabpanel","aria-labelledby":sm(I),children:"stashes"===I?(0,a.jsx)(eY,{stashes:eu,sel:eg,onSelect:ex,onSave:()=>ej(!0),canSave:b.changes.length>0&&!b.state}):"tags"===I?(0,a.jsx)(eL,{agent:m,sel:null!=(u=null==ed?void 0:ed.name)?u:null,onSelect:eh}):"compare"===I?(0,a.jsx)(eK,{refs:eR,sel:K,onChange:W}):"history"===I?(0,a.jsx)(e8,{agent:m,head:null==(l=b.head)?void 0:l.sha,sel:ey,onSelect:ek,refs:eR,path:H,onClearPath:()=>U(null)}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"gx-filter",children:[(0,a.jsxs)("div",{className:"search",children:[(0,a.jsx)(B.A,{size:14}),(0,a.jsx)("input",{ref:X,className:"input",placeholder:O?j("git.search.placeholder"):j("git.filterPlaceholder"),value:M,onChange:e=>F(e.target.value),"aria-label":j("git.filterPlaceholder")})]}),(0,a.jsxs)("div",{className:"seg icons",role:"group","aria-label":j("git.search.name"),children:[(0,a.jsx)("button",{type:"button","aria-pressed":!O,title:j("git.search.name"),"aria-label":j("git.search.name"),onClick:()=>q(!1),children:(0,a.jsx)(et.A,{size:14})}),(0,a.jsx)("button",{type:"button","aria-pressed":O,title:j("git.search.content"),"aria-label":j("git.search.content"),onClick:()=>q(!0),children:(0,a.jsx)(ea.A,{size:14})})]}),!O&&(0,a.jsxs)("button",{type:"button",className:"btn sm gx-onlych ".concat(R?"primary":""),"aria-pressed":R,title:j("git.filter.changed"),onClick:()=>P(e=>!e),children:[(0,a.jsx)(en.A,{size:14}),b.changes.length>0&&(0,a.jsx)("span",{className:"ct",children:b.changes.length})]})]}),O?(0,a.jsx)("div",{className:"gx-list gx-hits",children:M.trim().length<2?(0,a.jsx)("p",{className:"gx-note",children:j("git.search.min")}):$&&$.q===M.trim()?0===$.hits.length?(0,a.jsx)("p",{className:"gx-note",children:j("git.search.none",{query:$.q})}):(0,a.jsxs)(a.Fragment,{children:[$.hits.map((e,s)=>(0,a.jsxs)("button",{type:"button",className:"gx-hit ".concat(k===e.path&&(null==J?void 0:J.line)===e.line?"sel":""),onClick:()=>{w(e.path),Q({line:e.line,key:Date.now()})},title:"".concat(e.path,":").concat(e.line),children:[(0,a.jsxs)("span",{className:"mono nm",children:[e.path,(0,a.jsxs)("i",{children:[":",e.line]})]}),(0,a.jsx)("span",{className:"mono tx",children:e.text.trim()})]},"".concat(e.path,":").concat(e.line,":").concat(s))),$.truncated&&(0,a.jsx)("p",{className:"gx-note",children:j("git.search.capped",{count:$.hits.length})})]}):(0,a.jsx)("p",{className:"gx-note",children:j("git.search.searching")})}):(0,a.jsxs)("div",{className:"gx-list",children:[eD?0===eX.length?(0,a.jsx)("p",{className:"gx-note",children:M?j("git.noMatch",{query:M}):R?j("git.clean"):j("git.noFiles")}):(0,a.jsx)(sc,{rows:eX,expanded:C,forceOpen:!!(M||R),sel:k,onToggle:e1,onSelect:e4,label:j("git.filesLabel")}):(0,a.jsx)("p",{className:"gx-note",children:j("git.loading")}),eQ.length>eX.length&&(0,a.jsx)("p",{className:"gx-note",children:j("git.rowsCapped",{count:eX.length})}),(null==f?void 0:f.isRepo)&&f.truncated&&(0,a.jsx)("p",{className:"gx-note",children:j("git.treeTruncated",{count:f.files.length})})]})]})})]}),"stashes"===I?(null==eu?void 0:eu.find(e=>e.sha===eg))?(0,a.jsx)(eV,{agent:m,stash:eu.find(e=>e.sha===eg),a:eS},eg):(0,a.jsx)("div",{className:"gx-preview",children:(0,a.jsx)("div",{className:"gx-empty",children:(0,a.jsx)("p",{children:j("git.stash.empty")})})}):"compare"===I?(0,a.jsx)(eW,{agent:m,sel:K}):"tags"===I?ed?(0,a.jsx)(eI,{agent:m,tag:ed,onChanged:()=>void y()},ed.name):(0,a.jsx)("div",{className:"gx-preview",children:(0,a.jsx)("div",{className:"gx-empty",children:(0,a.jsx)("p",{children:j("git.tags.select")})})}):"history"===I?ey?(0,a.jsx)(e_,{agent:m,sha:ey,focus:null!=H?H:void 0},"".concat(ey,"|").concat(null!=H?H:"")):(0,a.jsx)("div",{className:"gx-preview",children:(0,a.jsx)("div",{className:"gx-empty",children:(0,a.jsx)("p",{children:j("git.hist.select")})})}):k&&(null==e9?void 0:e9.status)==="conflict"?(0,a.jsx)(eB,{agent:m,path:k,state:b.state,a:eS,onResolved:()=>{y()}},k):k?(0,a.jsx)(st,{agent:m,path:k,ignored:eO(k),change:e9,stamp:b.generatedAt,refs:eR,focusLine:J,onHistory:e=>{U(e),ek(null),T("history")},onOpenCommit:e=>{ek(e),T("history")},onDiscard:e=>{var s,t;return ez({files:sa([e]),all:!1,file:{path:e.path,status:e.status,oldPath:e.oldPath,add:null!=(s=e.additions)?s:0,del:null!=(t=e.deletions)?t:0},go:async()=>{let s=await eS.run("discard",j("git.done.discard"),"discard",{path:e.path,oldPath:e.oldPath});return s&&sa([e]).length&&w(null),s}})},onDiscardHunk:(e,s,t)=>void eS.run("discard-hunk",j("git.done.discard"),"discard-hunk",{path:e,index:s,header:t}),onDiscardLines:(e,s,t,a)=>void eS.run("discard-lines",j("git.done.discard"),"discard-lines",{path:e,index:s,header:t,lines:a})},k):(0,a.jsx)("div",{className:"gx-preview",children:(0,a.jsx)("div",{className:"gx-empty",children:(0,a.jsx)("p",{children:j("git.select")})})})]}),eb&&(0,a.jsx)(eG,{agent:m,plan:eb,a:eS,onClose:()=>ef(null),onGo:()=>{ef(null),e2(eb)}}),ep&&(0,a.jsx)(eZ,{a:eS,onClose:()=>ej(!1)}),ev&&b.stash&&(0,a.jsx)(D.TM,{danger:!0,title:j("git.state.cancelStash.title"),body:j("git.state.cancelStash.body",{from:b.stash.from}),confirmLabel:j("git.state.cancelStash.go"),onClose:()=>eN(!1),onConfirm:()=>{eS.busy||eS.run("smart",j("git.done.smartCancel"),"smart-cancel")}}),eA&&(0,a.jsx)(se,{files:eA.files,all:eA.all,summary:eA.summary,file:eA.file,onClose:()=>ez(null),onConfirm:()=>{eA.go()}}),ew&&(0,a.jsx)(e7,{changes:b.changes,a:eS,initialMessage:b.mergeMsg,onClose:()=>eC(!1)})]})}var sj=t(37064),sb=t(5300),sf=t(48180),sv=t(66477),sN=t(12646);function sy(e){let{agent:s}=e,{t}=(0,E.s9)(),{refresh:n}=(0,g.o0)(),l=(0,D.dj)(),[c,r]=(0,i.useState)(null),[o,d]=(0,i.useState)(""),[h,u]=(0,i.useState)(""),[m,j]=(0,i.useState)(!1),[b,f]=(0,i.useState)(!1),v=(0,i.useRef)(""),N=!!c&&o!==v.current,y=(0,i.useRef)(!1);y.current=N;let k=(0,i.useCallback)(async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];try{let t=await x.FH.get("/agents/".concat(s.id,"/notebook"));r(e=>e&&e.version===t.version&&e.enabled===t.enabled?e:t),(e||!y.current)&&(v.current=t.content,d(t.content))}catch(e){u(e instanceof Error?e.message:String(e))}},[s.id]);(0,i.useEffect)(()=>{r(null),u(""),k(!0)},[s.id,k]),(0,i.useEffect)(()=>{let e=setInterval(()=>{"visible"===document.visibilityState&&k()},4e3);return()=>clearInterval(e)},[k]);let w=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:o;if(c){j(!0),u("");try{let a=await x.FH.put("/agents/".concat(s.id,"/notebook"),{content:e,version:c.version});r({...c,...a}),v.current=a.content,d(a.content),l(t("notebook.saved"))}catch(e){u(e instanceof Error?e.message:String(e))}j(!1)}},C=async()=>{try{await x.FH.patch("/agents/".concat(s.id),{skill_ids:[...new Set([...s.skill_ids,c.skill_id])]}),await n(["agents"]),await k(!0)}catch(e){u(e instanceof Error?e.message:String(e))}};if(!c)return(0,a.jsx)("div",{className:"pane",children:(0,a.jsx)("p",{className:"hint",children:h||t("git.loading")})});let S=o.length,A=S>c.max,z=S>.8*c.max;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"pane",children:[(0,a.jsx)("p",{className:"hint",style:{margin:0},children:t("notebook.intro")}),!c.enabled&&(0,a.jsxs)("div",{className:"banner honey",children:[(0,a.jsx)(sf.A,{size:16}),(0,a.jsx)("div",{className:"grow",children:t("notebook.off")}),(0,a.jsx)("button",{className:"btn sm",onClick:C,children:t("notebook.on")})]}),h&&(0,a.jsxs)("div",{className:"banner err",children:[(0,a.jsx)(sf.A,{size:16}),(0,a.jsx)("div",{className:"grow",children:h}),(0,a.jsxs)("button",{className:"btn sm",onClick:()=>{u(""),k(!0)},children:[(0,a.jsx)(Z.A,{size:13}),t("notebook.reload")]})]}),(0,a.jsxs)("div",{className:"row small muted",style:{justifyContent:"space-between"},children:[(0,a.jsxs)("span",{children:[(0,a.jsx)(sv.A,{size:12,style:{verticalAlign:"-1px"}})," ",c.updated_at?t("notebook.updated",{who:t("user"===c.updated_by?"notebook.by.you":"notebook.by.agent"),when:(0,p.KN)(c.updated_at)}):t("notebook.never")]}),(0,a.jsxs)("span",{style:{color:A?"var(--danger, #c0392b)":z?"var(--honey)":void 0},children:[S.toLocaleString()," / ",c.max.toLocaleString()]})]}),(0,a.jsx)(sN.n,{value:o,onChange:d,placeholder:t("notebook.placeholder"),defaultView:"write",minHeight:320})]}),(0,a.jsxs)("div",{className:"savebar col",children:[(0,a.jsx)("span",{className:"muted small",children:N?t("agent.unsavedChanges"):t("agent.allSaved")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsxs)("button",{className:"btn danger sm",style:{marginRight:"auto"},disabled:!o.trim()||m,onClick:()=>f(!0),children:[(0,a.jsx)(eX.A,{size:14}),t("notebook.clear")]}),N&&(0,a.jsx)("button",{className:"btn ghost sm",onClick:()=>d(v.current),children:t("common.discard")}),(0,a.jsx)("button",{className:"btn primary sm",disabled:!N||m||A,onClick:()=>void w(),children:t("notebook.save")})]})]}),b&&(0,a.jsxs)(D.aF,{title:t("notebook.clear.title"),onClose:()=>f(!1),children:[(0,a.jsx)("p",{style:{margin:0},className:"muted",children:t("notebook.clear.confirm")}),(0,a.jsxs)("div",{className:"row",style:{justifyContent:"flex-end"},children:[(0,a.jsx)("button",{className:"btn ghost",onClick:()=>f(!1),children:t("common.cancel")}),(0,a.jsx)("button",{className:"btn danger",onClick:()=>{f(!1),w("")},children:t("notebook.clear")})]})]})]})}let sk=["config","notebook","sessions"];function sw(e){let{params:s}=e,{id:t}=(0,i.use)(s);return(0,a.jsx)(sC,{id:t},t)}function sC(e){var s;let{id:t}=e,{t:c}=(0,E.s9)(),{ready:N,error:y,retry:k,refresh:w}=(0,g.q5)(),C=(0,g.fJ)(t),S=(0,o.useRouter)(),A=(0,D.dj)(),[z,F]=(0,f.Z)("tab",""),[R,P]=(0,i.useState)("config"),_=sk.includes(z)?z:R,L=""!==z,[I,T]=(0,i.useState)(!1),[H,U]=(0,i.useState)([]),[K,O]=(0,i.useState)(void 0),[q,$]=(0,i.useState)(null),[B,G]=(0,i.useState)("chat"),[J,Q]=(0,b.ud)("hive-switcher-collapsed",0),Y=1===J,[Z,V]=(0,i.useState)(!1),ee=()=>{V(!0),Q(+!Y)},es=function(e,s){var t,a,n;let{finished:l}=(0,g.o0)(),c=null!=(t=null==e?void 0:e.id)?t:"",r=null!=(a=l[c])?a:0,[o,d]=(0,i.useState)(null),[h,u]=(0,i.useState)(null),[m,p]=(0,i.useState)(!1),[j,b]=(0,i.useState)(null),f=(0,i.useRef)(0),v=null!=(n=null==e?void 0:e.effective.cwd)?n:"",N=(null==e?void 0:e.status)==="running",y=(0,i.useCallback)(async e=>{if(!c)return;let s=++f.current;p(!0);try{let[t,a]=await Promise.all([x.FH.get("/agents/".concat(c,"/git/status")),e?x.FH.get("/agents/".concat(c,"/git/tree")):Promise.resolve(null)]);if(s!==f.current)return;d(t),a&&u(a),b(null)}catch(e){s===f.current&&b(e instanceof Error?e.message:"error")}finally{s===f.current&&p(!1)}},[c]);return(0,i.useEffect)(()=>{u(null),d(null)},[v]),(0,i.useEffect)(()=>{y(s)},[y,s,r,v]),(0,sj.n)(()=>y(!0),5e3,{enabled:s&&N,immediate:!1}),{status:o,tree:h,loading:m,error:j,refresh:(0,i.useCallback)(()=>y(!0),[y])}}(C,"changes"===B),et=es.status&&es.status.isRepo?es.status.changes.length:0,ea=(e,s)=>{let t=null!=s?s:_;P(t),F(e?t:"")},en=(0,l.A)(C,{onDeleted:()=>S.push("/agents")}),{draft:el,setDraft:ei,errors:ec,dirty:er}=en,eo=()=>{er?T(!0):ea(!1)};if((0,i.useEffect)(()=>{L&&"sessions"===_&&x.FH.get("/agents/".concat(t,"/sessions")).then(U).catch(()=>void 0)},[L,_,t,null==C?void 0:C.session_id]),(0,i.useEffect)(()=>{C&&(0,b.zS)(j.O,C.id)},[C]),!C)return(0,a.jsxs)("div",{className:"ws ".concat(Y?"sw-collapsed":""," ").concat(Z?"sw-anim":""),children:[(0,a.jsx)(X,{activeId:t,collapsed:Y,onToggle:ee}),(0,a.jsx)("div",{className:"page",children:!N&&y?(0,a.jsxs)(D.lZ,{kind:"err",children:[(0,a.jsx)("span",{children:y})," ",(0,a.jsx)("button",{type:"button",className:"btn sm",onClick:()=>void k(),children:c("fa.retry")})]}):N?(0,a.jsx)(D.pp,{title:c("agent.missing.title"),body:c("agent.missing.body"),action:(0,a.jsx)(r(),{className:"btn",href:"/agents",children:c("agent.missing.back")})}):null})]});let ed=async e=>{await x.FH.post("/agents/".concat(t,"/resume-session"),{session_id:e}),O(void 0),A(c("agent.resumed"))},eh=H.filter(e=>"delegation"!==e.kind),eu=H.filter(e=>"delegation"===e.kind),em=(null==(s=H.find(e=>e.session_id===K))?void 0:s.kind)==="delegation",eg=[...K?[{id:"make-current",label:c("agent.makeCurrent"),onClick:()=>void ed(K).catch(e=>A(e instanceof Error?e.message:String(e),"err")),disabled:em},{id:"back-current",label:c("agent.backToCurrent"),onClick:()=>O(void 0)}]:[],{id:"new-conv",label:c("agent.newConversation"),icon:(0,a.jsx)(d.A,{size:14}),onClick:()=>$("new"),disabled:!C.session_id||"running"===C.status}];return(0,a.jsxs)("div",{className:"ws ".concat(Y?"sw-collapsed":""," ").concat(Z?"sw-anim":""),children:[(0,a.jsx)(X,{activeId:t,collapsed:Y,onToggle:ee}),(0,a.jsxs)("section",{className:"ws-chat",children:[(0,a.jsx)(D.DS,{back:{href:"/",label:c("agent.backToColony")},avatar:(0,a.jsx)(D._h,{agent:C}),title:C.name,meta:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(D.PW,{role:C.role}),(0,a.jsx)(D.dJ,{provider:C.provider}),(0,a.jsx)("span",{className:"small",children:C.model||c("model.cliDefault")}),(0,a.jsx)(D.P5,{status:C.status})]}),actions:eg,primary:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"seg",role:"group","aria-label":c("git.tab.label"),children:[(0,a.jsx)("button",{type:"button","aria-pressed":"chat"===B,onClick:()=>G("chat"),children:c("git.tab.chat")}),(0,a.jsxs)("button",{type:"button","aria-pressed":"changes"===B,onClick:()=>G("changes"),children:[c("git.tab.changes"),et>0&&(0,a.jsx)("span",{className:"tabcount",children:et})]})]}),(0,a.jsx)(n.N,{spec:{agentId:t},title:c("dock.agent")}),(0,a.jsxs)("button",{type:"button",className:"btn sm ".concat(L?"primary":""),onClick:()=>L?eo():ea(!0),"aria-expanded":L,"aria-label":c("colony.agentSettings"),children:[(0,a.jsx)(h.A,{size:14}),c("agent.settings"),er&&(0,a.jsx)("i",{className:"dot run",title:c("agent.unsaved")})]})]})}),(0,a.jsxs)("div",{className:"chat-pane",hidden:"chat"!==B,children:[(0,a.jsx)(W,{agent:C}),(0,a.jsx)(M,{agent:C,session:K}),(0,a.jsx)(v.ry,{agent:C,sessionOverride:K})]}),"changes"===B&&(0,a.jsx)(sp,{agent:C,git:es})]}),L&&(0,a.jsx)(D._s,{title:C.name,subtitle:"".concat(c("role.".concat(C.role))," \xb7 ").concat(p.xq[C.provider].label),onClose:eo,footer:"config"===_&&el?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("span",{className:"muted small grow",children:[er?c("agent.unsavedChanges"):c("agent.allSaved"),er&&"running"===C.status?" ".concat(c("agent.appliesNextTurn")):""]}),en.actions({size:"sm"})]}):void 0,children:(0,a.jsxs)("div",{className:"agent-config",children:[(0,a.jsx)(D.tU,{idPrefix:"cfg",label:c("fa.cfg.tabs"),value:_,onChange:e=>ea(!0,e),tabs:[{id:"config",label:c("agent.tab.config")},{id:"notebook",label:c("agent.tab.notebook")},{id:"sessions",label:c("nav.sessions")}]}),(0,a.jsx)(D.Kp,{id:"config",value:_,idPrefix:"cfg",children:el&&(0,a.jsx)(a.Fragment,{children:(0,a.jsx)("div",{className:"pane",children:(0,a.jsx)(sb.SU,{draft:el,onChange:ei,errors:ec,selfId:t})})})}),(0,a.jsx)(D.Kp,{id:"notebook",value:_,idPrefix:"cfg",children:(0,a.jsx)(sy,{agent:C})}),(0,a.jsx)(D.Kp,{id:"sessions",value:_,idPrefix:"cfg",children:(0,a.jsxs)("div",{className:"pane",children:[(0,a.jsx)("p",{className:"hint m0",children:c("agent.sessions.intro",{path:(0,p._1)(C.effective.cwd)})}),(0,a.jsx)("div",{className:"eyebrow",children:c("agent.sessions.conversations")}),0===eh.length?(0,a.jsx)(D.pp,{compact:!0,icon:(0,a.jsx)(u.A,{size:22}),title:c("agent.sessions.empty")}):eh.map(e=>{let s=e.session_id===C.session_id;return(0,a.jsxs)("div",{className:"card card-pad col fa-sess ".concat(K===e.session_id?"on":""),children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsxs)("span",{className:"mono grow",children:[e.session_id.slice(0,18),"…"]}),s&&(0,a.jsx)("span",{className:"chip honey",children:c("sessions.current")})]}),(0,a.jsx)("span",{className:"muted small",children:c("agent.sessions.started",{started:(0,p.KN)(e.first_seen),last:(0,p.KN)(e.last_seen)})}),(0,a.jsxs)("div",{className:"row gap-s",children:[(0,a.jsx)("button",{className:"btn sm",onClick:()=>{O(s?void 0:e.session_id),ea(!1)},children:K===e.session_id?c("agent.sessions.viewing"):c("agent.sessions.read")}),!s&&(0,a.jsx)("button",{className:"btn sm",onClick:()=>ed(e.session_id).then(()=>ea(!1)).catch(e=>A(e instanceof Error?e.message:String(e),"err")),children:c("agent.sessions.resume")})]})]},e.session_id)}),eu.length>0&&(0,a.jsx)("div",{className:"eyebrow mt-s",children:c("agent.sessions.delegated")}),eu.map(e=>{var s;return(0,a.jsxs)("div",{className:"card card-pad col fa-sess ".concat(K===e.session_id?"on":""),children:[(0,a.jsxs)("div",{className:"row gap-s",children:[(0,a.jsx)(m.A,{size:14,className:"muted"}),(0,a.jsx)("b",{className:"grow",children:c("agent.sessions.from",{name:null!=(s=e.from_name)?s:c("chat.anOrchestrator")})}),(0,a.jsx)("span",{className:"muted small",children:(0,p.KN)(e.last_seen)})]}),e.task&&(0,a.jsx)("span",{className:"small fa-clamp3",children:e.task}),(0,a.jsx)("div",{className:"row gap-s",children:(0,a.jsx)("button",{className:"btn sm",onClick:()=>{O(K===e.session_id?void 0:e.session_id),ea(!1)},children:K===e.session_id?c("agent.sessions.viewing"):c("agent.sessions.read")})})]},e.session_id)})]})})]})}),en.deleteModal,I&&(0,a.jsx)(D.TM,{danger:!0,title:c("fa.unsaved.title"),body:c("fa.unsaved.body"),confirmLabel:c("fa.unsaved.discard"),cancelLabel:c("fa.unsaved.keep"),onClose:()=>T(!1),onConfirm:()=>{en.discard(),ea(!1)}}),"new"===q&&(0,a.jsx)(D.TM,{title:c("agent.newConvTitle"),body:c("agent.newConvBody"),confirmLabel:c("agent.newConvStart"),onClose:()=>$(null),onConfirm:async()=>{await x.FH.post("/agents/".concat(t,"/new-session")),await w(["agents"]),A(c("agent.newConvStarted"))}})]})}},48776:(e,s,t)=>{"use strict";t.d(s,{G:()=>r});var a=t(94799),n=t(10804),l=t(48538),i=t(3749),c=t(69654);function r(e){let{agent:s,onClose:t,onDeleted:r}=e,{t:o}=(0,c.s9)(),{refresh:d}=(0,l.zd)(),h=(0,n.dj)();return(0,a.jsx)(n.TM,{title:o("agent.deleteTitle",{name:s.name}),body:o("agent.deleteBody"),danger:!0,confirmLabel:o("agent.delete"),cancelLabel:o("agent.keep"),onClose:t,onConfirm:async()=>{await i.FH.del("/agents/".concat(s.id)),await d(["agents","colonies"]),h(o("agent.deleted")),null==r||r()}})}},54609:(e,s,t)=>{"use strict";t.d(s,{O:()=>a});let a="hive-am.lastChat"},89128:(e,s,t)=>{"use strict";t.d(s,{A:()=>m});var a=t(94799),n=t(34023),l=t(97356),i=t(10804),c=t(5300),r=t(48776),o=t(48538),d=t(73506),h=t(3749),u=t(69654);function m(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{t}=(0,u.s9)(),{agents:m,colonies:g,objects:x,refresh:p}=(0,o.q5)(),j=(0,i.dj)(),b=(0,n.useMemo)(()=>e?x.filter(s=>s.manager_id===e.id).map(e=>e.id).sort():[],[x,null==e?void 0:e.id]),f=(0,n.useMemo)(()=>e?JSON.stringify((0,c.TN)(e,b)):"",[e,b]),[v,N]=(0,n.useState)(()=>e?(0,c.TN)(e,b):null),[y,k]=(0,n.useState)(!1),[w,C]=(0,n.useState)(!1);(0,n.useEffect)(()=>{N(e?(0,c.TN)(e,b):null)},[f]);let S=v&&e?(0,c.tf)(v,m,e.id,g):{},A=!!v&&JSON.stringify(v)!==f;(0,d.h)(A);let z=async()=>{if(v&&e){if(Object.keys(S).length)return void j(t("edit.fixFields"),"err");k(!0);try{var a;let{type_id:n,object_ids:l,...i}=v;await h.FH.patch("/agents/".concat(e.id),i),JSON.stringify([...l].sort())!==JSON.stringify(b)&&await h.FH.put("/agents/".concat(e.id,"/resources"),{object_ids:l}),await p(["agents","colonies","objects"]),j(t("edit.saved",{name:v.name.trim()})),null==(a=s.onSaved)||a.call(s)}catch(e){j(e instanceof Error?e.message:t("edit.saveFailed"),"err")}k(!1)}},E=()=>{e&&N((0,c.TN)(e,b))};return{draft:v,setDraft:N,errors:S,dirty:A,saving:y,save:z,discard:E,actions:function(){var e,s,n,i;let c=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("button",{className:"btn danger push-r ".concat(null!=(e=c.size)?e:""),onClick:()=>C(!0),children:[(0,a.jsx)(l.A,{size:c.size?14:15}),t("agent.delete")]}),c.onCancel?(0,a.jsx)("button",{className:"btn ghost ".concat(null!=(s=c.size)?s:""),onClick:c.onCancel,children:t("common.cancel")}):(0,a.jsx)("button",{className:"btn ghost ".concat(null!=(n=c.size)?n:""),disabled:!A,onClick:E,children:t("common.discard")}),(0,a.jsx)("button",{className:"btn primary ".concat(null!=(i=c.size)?i:""),disabled:!A||y,onClick:z,children:y?t("common.saving"):t("common.saveChanges")})]})},deleteModal:w&&e?(0,a.jsx)(r.G,{agent:e,onClose:()=>C(!1),onDeleted:s.onDeleted}):null}}}},e=>{e.O(0,[586,706,837,391,316,281,517,350,606,30,705,408,89,358],()=>e(e.s=16054)),_N_E=e.O()}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[165],{3492:(e,s,a)=>{"use strict";a.d(s,{A:()=>t});let t=(0,a(74955).A)("Heading2",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]])},10452:(e,s,a)=>{Promise.resolve().then(a.bind(a,47857))},20555:(e,s,a)=>{"use strict";a.d(s,{A:()=>t});let t=(0,a(74955).A)("ListOrdered",[["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 18h11",key:"11hvi2"}],["path",{d:"M10 6h11",key:"c7qv1k"}],["path",{d:"M4 10h2",key:"16xx2s"}],["path",{d:"M4 6h1v4",key:"cnovpq"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",key:"m9a95d"}]])},47857:(e,s,a)=>{"use strict";a.r(s),a.d(s,{default:()=>y});var t=a(94799),l=a(41463),d=a.n(l),n=a(43624),i=a(34023),r=a(92947),c=a(48538),h=a(77021),o=a(47890),x=a(10804),p=a(1517),m=a(69654);function y(){let{t:e}=(0,m.s9)(),{agents:s,colonies:a,ready:l,error:y,retry:j}=(0,c.q5)(),k=(0,n.useRouter)(),[u,g]=(0,h.ud)("hive-am.agents.q",""),[v,b]=(0,h.ud)("hive-am.agents.role","all"),[N,w]=(0,h.ud)("hive-am.agents.provider","all"),[M,A]=(0,i.useState)(!1),f=(0,i.useMemo)(()=>s.filter(e=>("all"===v||e.role===v)&&("all"===N||e.provider===N)&&(!u||"".concat(e.name," ").concat(e.description," ").concat(e.cwd).toLowerCase().includes(u.toLowerCase()))),[s,u,v,N]);return(0,t.jsxs)("div",{className:"page",children:[(0,t.jsxs)("div",{className:"page-head",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{children:e("nav.agents")}),(0,t.jsx)("p",{children:e("agents.subtitle")})]}),(0,t.jsxs)("button",{className:"btn primary",onClick:()=>A(!0),children:[(0,t.jsx)(r.A,{size:16}),e("newAgent.title")]})]}),!l&&y&&(0,t.jsx)(x.lZ,{kind:"err",children:(0,t.jsxs)("div",{className:"row gap-s wrap",children:[(0,t.jsxs)("span",{className:"grow",children:[e("cx.loadFailed")," ",y]}),(0,t.jsx)("button",{className:"btn sm",onClick:()=>void j(),children:e("cx.retry")})]})}),(0,t.jsxs)("div",{className:"row wrap agents-filters",children:[(0,t.jsx)(x.DO,{className:"grow",value:u,onChange:g,placeholder:e("agents.searchPlaceholder"),label:e("agents.searchLabel")}),(0,t.jsx)(x.$q,{value:v,onChange:b,options:[{id:"all",label:e("common.all")},{id:"orchestrator",label:e("agents.filter.orchestrators")},{id:"worker",label:e("agents.filter.workers")}]}),(0,t.jsx)(x.$q,{value:N,onChange:w,options:[{id:"all",label:e("agents.filter.anyProvider")},...Object.keys(o.xq).map(e=>({id:e,label:o.xq[e].short}))]})]}),l&&0===s.length?(0,t.jsx)(x.pp,{icon:(0,t.jsx)(x._h,{size:"lg",queen:!0,label:"+"}),title:e("agents.empty.title"),body:e("agents.empty.body"),action:(0,t.jsxs)("button",{className:"btn primary",onClick:()=>A(!0),children:[(0,t.jsx)(r.A,{size:16}),e("newAgent.create")]})}):l?0===f.length?(0,t.jsx)(x.pp,{title:e("agents.noMatch.title"),body:e("agents.noMatch.body"),action:(0,t.jsx)("button",{className:"btn",onClick:()=>{g(""),b("all"),w("all")},children:e("common.clearFilters")})}):(0,t.jsx)("div",{className:"card table-scroll",children:(0,t.jsxs)("table",{className:"table",children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{children:e("agents.col.agent")}),(0,t.jsx)("th",{children:e("agents.col.providerModel")}),(0,t.jsx)("th",{children:e("form.colony")}),(0,t.jsx)("th",{children:e("colony.folder")}),(0,t.jsx)("th",{children:e("agents.col.status")}),(0,t.jsx)("th",{children:e("agents.col.updated")})]})}),(0,t.jsx)("tbody",{children:f.map(s=>{let l=()=>k.push("/agents/".concat(s.id)),n=a.find(e=>e.id===s.colony_id);return(0,t.jsxs)("tr",{className:"row-link",tabIndex:0,"aria-label":e("cx.openAgent",{name:s.name}),onClick:l,onKeyDown:e=>{e.target===e.currentTarget&&("Enter"===e.key||" "===e.key)&&(e.preventDefault(),l())},children:[(0,t.jsx)("td",{children:(0,t.jsxs)("div",{className:"name-cell",children:[(0,t.jsx)(x._h,{agent:s}),(0,t.jsxs)("div",{children:[(0,t.jsx)("b",{children:(0,t.jsx)(d(),{href:"/agents/".concat(s.id),onClick:e=>e.stopPropagation(),children:s.name})}),(0,t.jsx)("span",{children:s.description||("orchestrator"===s.role?e("agents.orchestratorLine",{count:s.worker_ids.length}):e("role.worker"))})]})]})}),(0,t.jsxs)("td",{children:[(0,t.jsx)("div",{className:"fw-600",children:o.xq[s.provider].label}),(0,t.jsx)("span",{className:"muted small",children:s.model||e("model.cliDefault")})]}),(0,t.jsx)("td",{children:n?(0,t.jsxs)("span",{className:"chip",children:[(0,t.jsx)("i",{className:"cdot cx-chip-dot",style:{background:n.color||"var(--honey)"}}),n.name]}):(0,t.jsx)("span",{className:"muted small",children:"—"})}),(0,t.jsxs)("td",{className:"mono muted small",children:[(0,o._1)(s.effective.cwd),s.effective.inherited.includes("cwd")?" \xb7":"",s.effective.inherited.includes("cwd")&&(0,t.jsxs)("span",{className:"muted",children:[" ",e("agents.colonyWord")]})]}),(0,t.jsx)("td",{children:(0,t.jsxs)("div",{className:"row gap-s wrap",children:[(0,t.jsx)(x.PW,{role:s.role}),(0,t.jsx)(x.P5,{status:s.status})]})}),(0,t.jsx)("td",{className:"muted small",children:(0,o.KN)(s.updated_at)})]},s.id)})})]})}):(0,t.jsxs)("div",{className:"card comb-skel",role:"status","aria-label":e("cx.loading"),children:[(0,t.jsx)("div",{className:"skel",style:{width:"100%",height:48}}),(0,t.jsx)("div",{className:"skel",style:{width:"100%",height:48}}),(0,t.jsx)("div",{className:"skel",style:{width:"100%",height:48}})]}),M&&(0,t.jsx)(p.b,{onClose:()=>A(!1)})]})}},52263:(e,s,a)=>{"use strict";a.d(s,{A:()=>t});let t=(0,a(74955).A)("List",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]])},55712:(e,s,a)=>{"use strict";a.d(s,{A:()=>t});let t=(0,a(74955).A)("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]])},55838:(e,s,a)=>{"use strict";a.d(s,{A:()=>t});let t=(0,a(74955).A)("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]])},71529:(e,s,a)=>{"use strict";a.d(s,{A:()=>t});let t=(0,a(74955).A)("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]])},91833:(e,s,a)=>{"use strict";a.d(s,{A:()=>t});let t=(0,a(74955).A)("Quote",[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]])},92947:(e,s,a)=>{"use strict";a.d(s,{A:()=>t});let t=(0,a(74955).A)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},98148:(e,s,a)=>{"use strict";a.d(s,{A:()=>t});let t=(0,a(74955).A)("Bold",[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]])},98938:(e,s,a)=>{"use strict";a.d(s,{A:()=>t});let t=(0,a(74955).A)("CodeXml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]])},99579:(e,s,a)=>{"use strict";a.d(s,{A:()=>t});let t=(0,a(74955).A)("Italic",[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]])}},e=>{e.O(0,[586,706,281,517,408,89,358],()=>e(e.s=10452)),_N_E=e.O()}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[974],{6261:(e,n,t)=>{"use strict";t.d(n,{A:()=>l});let l=(0,t(74955).A)("Hexagon",[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}]])},32098:(e,n,t)=>{"use strict";t.d(n,{A:()=>l});let l=(0,t(74955).A)("SlidersHorizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]])},36098:(e,n,t)=>{"use strict";t.r(n),t.d(n,{default:()=>G});var l=t(94799),o=t(41463),s=t.n(o),a=t(34023),i=t(92947),c=t(6261),r=t(77841),d=t(73784),m=t(75406),h=t(71529),u=t(14910),y=t(32098),x=t(70665);let g=(0,t(74955).A)("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);var p=t(97356),j=t(48538),f=t(77021),b=t(3749),v=t(47890),k=t(10804),w=t(41435),N=t(1517),C=t(12646),_=t(73506),M=t(22214),A=t(69654);let z=v.hg,S=["cwd","permission","skills","prompt"];function L(e){let{colony:n,onClose:t}=e,{t:o}=(0,A.s9)(),{agents:s,skills:i,colonies:c,refresh:r}=(0,j.q5)(),d=(0,k.dj)(),[m,h]=(0,a.useState)(()=>n?{name:n.name,color:n.color,cwd:n.cwd,permission:n.permission,system_prompt:n.system_prompt,skill_ids:n.skill_ids,skill_loads:n.skill_loads,agent_ids:n.agent_ids,inherit:n.inherit}:{name:"",color:z[c.length%z.length],cwd:"",permission:"acceptEdits",system_prompt:"",skill_ids:[],skill_loads:{},agent_ids:[],inherit:{cwd:!0,permission:!0,skills:!0,prompt:!0}}),u=(0,a.useMemo)(()=>JSON.stringify(m),[]),y=JSON.stringify(m)!==u;(0,_.h)(y);let[x,g]=(0,a.useState)(!1),f=()=>{y?g(!0):t()},[v,w]=(0,a.useState)(""),[N,S]=(0,a.useState)(!1),[L,D]=(0,a.useState)(!1),[E,T]=(0,a.useState)(!1),q=(e,n)=>h(t=>({...t,[e]:n})),H=async e=>{T(!0);try{let l={...m,name:m.name.trim(),color:m.color.toLowerCase(),inherit:e};n?await b.FH.patch("/colonies/".concat(n.id),l):await b.FH.post("/colonies",l),await r(["agents","colonies"]),d(n?o("colony.saved"):o("colony.created")),t()}catch(e){S(!1),w(e instanceof Error?e.message:o("edit.saveFailed")),T(!1)}};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(k._s,{title:n?o("colony.editTitle",{name:n.name}):o("colony.newTitle"),subtitle:o("colony.subtitle"),onClose:f,footer:(0,l.jsxs)(l.Fragment,{children:[n&&(0,l.jsxs)("button",{className:"btn danger push-r",onClick:()=>D(!0),children:[(0,l.jsx)(p.A,{size:15}),o("common.delete")]}),(0,l.jsx)("button",{className:"btn ghost",onClick:f,children:o("common.cancel")}),(0,l.jsx)("button",{className:"btn primary",onClick:()=>m.name.trim()?c.some(e=>e.id!==(null==n?void 0:n.id)&&e.name.toLowerCase()===m.name.trim().toLowerCase())?void w(o("colony.err.nameTaken")):/^#[0-9a-f]{6}$/i.test(m.color)?void(w(""),S(!0)):void w(o("colony.err.color")):void w(o("colony.err.name")),children:n?o("colony.save"):o("colony.create")})]}),children:[(0,l.jsx)(k.D0,{label:o("form.name"),error:v,children:(0,l.jsx)("input",{className:"input",value:m.name,onChange:e=>q("name",e.target.value),placeholder:o("colony.name.placeholder"),"data-autofocus":!0})}),(0,l.jsx)(k.D0,{label:o("colony.color"),children:(0,l.jsxs)("div",{className:"swatches",children:[z.map(e=>(0,l.jsx)("button",{type:"button",className:"swatch",style:{"--c":e},"aria-pressed":m.color.toLowerCase()===e,"aria-label":o("colony.colorOption",{color:e}),onClick:()=>q("color",e)},e)),(0,l.jsx)("label",{className:"swatch custom ".concat(z.includes(m.color.toLowerCase())?"":"on"),style:{"--c":/^#[0-9a-f]{6}$/i.test(m.color)?m.color:"transparent"},title:o("colony.colorCustom"),children:(0,l.jsx)("input",{type:"color",value:/^#[0-9a-f]{6}$/i.test(m.color)?m.color:"#2f8f5b",onChange:e=>q("color",e.target.value),"aria-label":o("colony.colorCustom")})}),(0,l.jsx)("input",{className:"input hex-input mono",value:m.color,maxLength:7,spellCheck:!1,"aria-label":o("colony.colorHex"),placeholder:"#2f8f5b",onChange:e=>{let n=e.target.value.trim();q("color",n.startsWith("#")||!n?n:"#".concat(n))}})]})}),(0,l.jsx)(k.dR,{value:m.cwd,onChange:e=>q("cwd",e)}),(0,l.jsx)(k.en,{value:m.permission,onChange:e=>q("permission",e)}),(0,l.jsx)(k.D0,{label:o("inherit.context"),hint:o("colony.context.hint"),children:(0,l.jsx)(C.n,{value:m.system_prompt,onChange:e=>q("system_prompt",e),placeholder:o("colony.context.placeholder"),defaultView:"write",minHeight:160})}),(0,l.jsx)(k.D0,{label:o("form.skills"),children:(0,l.jsx)(k.kV,{skills:i,value:m.skill_ids,loads:m.skill_loads,onChange:(e,n)=>h({...m,skill_ids:e,skill_loads:n})})}),(0,l.jsx)(k.D0,{label:o("colony.members"),hint:o("colony.members.hint"),children:0===s.length?(0,l.jsx)("p",{className:"hint",children:o("colony.members.empty")}):(0,l.jsx)(M.C,{value:m.agent_ids,onChange:e=>q("agent_ids",e),items:s.map(e=>{let t=e.colony_id&&e.colony_id!==(null==n?void 0:n.id)?c.find(n=>n.id===e.colony_id):null;return{id:e.id,name:e.name,note:t?o("colony.currentlyIn",{name:t.name}):e.description||o("role.".concat(e.role))}})})})]}),N&&(0,l.jsx)(F,{draft:m,colony:n,members:s.filter(e=>m.agent_ids.includes(e.id)),busy:E,onBack:()=>S(!1),onConfirm:H}),x&&(0,l.jsx)(k.TM,{danger:!0,title:o("fa.unsaved.title"),body:o("fa.unsaved.body"),confirmLabel:o("fa.unsaved.discard"),cancelLabel:o("fa.unsaved.keep"),onClose:()=>g(!1),onConfirm:t}),L&&n&&(0,l.jsx)(k.TM,{title:o("colony.deleteTitle",{name:n.name}),body:o("colony.deleteBody",{count:n.agent_ids.length}),danger:!0,confirmLabel:o("colony.delete"),cancelLabel:o("colony.keep"),onClose:()=>D(!1),onConfirm:async()=>{await b.FH.del("/colonies/".concat(n.id)),await r(["agents","colonies"]),d(o("colony.deleted")),t()}})]})}function F(e){let{draft:n,colony:t,members:o,busy:s,onBack:i,onConfirm:c}=e,{t:r}=(0,A.s9)(),d={cwd:!!n.cwd,permission:!0,skills:n.skill_ids.length>0,prompt:!!n.system_prompt.trim()},[m,h]=(0,a.useState)(()=>({cwd:(!t||t.inherit.cwd)&&d.cwd,permission:!t||t.inherit.permission,skills:(!t||t.inherit.skills)&&d.skills,prompt:(!t||t.inherit.prompt)&&d.prompt})),u=(0,a.useMemo)(()=>m.cwd&&n.cwd&&o.filter(e=>!e.overrides.includes("cwd")&&e.effective.cwd!==n.cwd).length,[m.cwd,n.cwd,o]);return(0,l.jsxs)(k.aF,{title:r("inheritAsk.title"),onClose:i,children:[(0,l.jsx)("p",{className:"muted small m0",children:r("inheritAsk.intro")}),(0,l.jsx)("div",{className:"col gap-s",children:S.map(e=>(0,l.jsx)(k.Tl,{disabled:!d[e],checked:m[e],onChange:n=>h(t=>({...t,[e]:n})),label:(0,l.jsxs)(l.Fragment,{children:[r("inheritAsk.field.".concat(e)),"cwd"===e&&n.cwd?(0,l.jsxs)("span",{className:"muted mono fw-400",children:[" \xb7 ",(0,v._1)(n.cwd)]}):null,"permission"===e?(0,l.jsxs)("span",{className:"muted fw-400",children:[" \xb7 ",(0,v.Ck)(n.permission)]}):null]}),hint:d[e]?r("inheritAsk.hint.".concat(e)):r("inheritAsk.empty.".concat(e))},e))}),u?(0,l.jsx)(k.lZ,{kind:"honey",children:r("inheritAsk.folderMoves",{count:Number(u)})}):null,(0,l.jsxs)("div",{className:"row push-end",children:[(0,l.jsx)("button",{className:"btn ghost",onClick:i,children:r("common.back")}),(0,l.jsx)("button",{className:"btn primary",disabled:s,onClick:()=>c(m),children:s?r("common.saving"):t?r("colony.save"):r("colony.create")})]})]})}var D=t(5300),E=t(89128);function T(e){let{agent:n,onClose:t}=e,{t:o}=(0,A.s9)(),s=(0,E.A)(n,{onSaved:t,onDeleted:t});return s.draft?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(k._s,{title:o("edit.title",{name:n.name}),subtitle:o("running"===n.status?"edit.subtitleRunning":"edit.subtitleIdle"),onClose:t,footer:s.actions({onCancel:t}),children:(0,l.jsx)(D.SU,{draft:s.draft,onChange:s.setDraft,errors:s.errors,selfId:n.id})}),s.deleteModal]}):null}var q=t(48776),H=t(37165),O=t(5372),I=t(31606),W=t(95587),R=t(74988);let K=74*Math.sqrt(3),B=[[1,0],[1,-1],[0,-1],[-1,0],[-1,1],[0,1]],P=e=>{let[n,t]=e;return{x:K*(n+t/2),y:111*t}},J=(e,n,t)=>Array.from({length:6},(l,o)=>{let s=(60*o-30)*Math.PI/180;return"".concat((e+t*Math.cos(s)).toFixed(1),",").concat((n+t*Math.sin(s)).toFixed(1))}).join(" ");function G(){var e,n,t;let{t:o}=(0,A.s9)(),{agents:C,colonies:_,objects:M,dispatches:z,ready:S,error:F,retry:D,refresh:E}=(0,j.q5)(),G=(0,k.dj)(),[U,V]=(0,a.useState)(null),[X,Y]=(0,a.useState)(null),[$,Z]=(0,a.useState)(null),[Q,ee]=(0,a.useState)(null),[en,et]=(0,a.useState)(null),[el,eo]=(0,a.useState)(null),[es,ea]=(0,f.ud)("hive-colony-layout",{}),[ei,ec]=(0,a.useState)(null),[er,ed]=(0,f.ud)("hive-colony-zoom",1),em=er>=.4&&er<=2.5?er:1,eh=e=>ed(Math.min(2.5,Math.max(.4,Math.round(100*e)/100))),eu=(0,a.useMemo)(()=>ei?{...es,[ei.key]:{x:ei.x,y:ei.y}}:es,[es,ei]),{clusters:ey,width:ex,height:eg}=(0,a.useMemo)(()=>(function(e,n,t){let l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=e=>!!e&&n.some(n=>n.id===e),s=n.map(n=>({key:n.id,colony:n,members:e.filter(e=>e.colony_id===n.id),things:t.filter(e=>e.colony_id===n.id)}));s.push({key:"free",colony:null,members:e.filter(e=>!o(e.colony_id)),things:t.filter(e=>!o(e.colony_id))});let a=[],i=0,c=0,r=0;for(let n of s){if(!n.members.length&&!n.things.length&&!n.colony&&e.length+t.length>0)continue;let o=function(e){let n=e.filter(e=>"orchestrator"===e.role);for(let t of[...n])for(let l of t.worker_ids){let t=e.find(e=>e.id===l);t&&!n.includes(t)&&n.push(t)}for(let t of e)n.includes(t)||n.push(t);return n}(n.members),s=(function(e){let n=[[0,0]];for(let t=1;n.length<e;t++){let e=B[4][0]*t,l=B[4][1]*t;for(let o=0;o<6;o++)for(let s=0;s<t;s++)n.push([e,l]),e+=B[o][0],l+=B[o][1]}return n.slice(0,e)})(o.length+n.things.length+1).map(P),d=Math.min(...s.map(e=>e.x))-K/2,m=Math.max(...s.map(e=>e.x))+K/2,h=Math.min(...s.map(e=>e.y))-74,u=Math.max(...s.map(e=>e.y))+74,y=m-d+52,x=u-h+52+50,g=n.colony?l[n.key]:void 0;!g&&i>0&&i+y>880&&(i=0,c+=r+36,r=0);let p=g?g.x:i,j=g?g.y:c,f=s.map((e,t)=>{var s,a,i;let c=null!=(a=o[t])?a:null,r=n.things[t-o.length],m=n.colony?void 0:l[null!=(i=null==(s=null!=c?c:r)?void 0:s.id)?i:""];return{agent:c,object:r,x:m?m.x:p+(e.x-d)+26,y:m?m.y:j+(e.y-h)+26+50}});a.push({key:n.key,colony:n.colony,cells:f,x:p,y:j,w:y,h:x}),g||(i+=y+36,r=Math.max(r,x))}let d=0,m=0;for(let e of a)if(e.colony)d=Math.max(d,e.x+e.w),m=Math.max(m,e.y+e.h);else for(let n of e.cells)d=Math.max(d,n.x+K/2+26),m=Math.max(m,n.y+74+26);return{clusters:a,width:d,height:m}})(C,_,M,eu),[C,_,M,eu]),ep=(0,a.useRef)(null),[ej,ef]=(0,a.useState)(0);(0,a.useEffect)(()=>{let e=ep.current;if(!e)return;let n=new ResizeObserver(()=>ef(e.clientWidth));return n.observe(e),ef(e.clientWidth),()=>n.disconnect()},[S,0===C.length]);let eb=(0,a.useRef)(em);eb.current=em,(0,a.useEffect)(()=>{let e=ep.current;if(!e)return;let n=e=>{(e.ctrlKey||e.metaKey)&&(e.preventDefault(),eh(eb.current*(e.deltaY<0?1.1:1/1.1)))};return e.addEventListener("wheel",n,{passive:!1}),()=>e.removeEventListener("wheel",n)},[S]);let ev=ex+80,ek=eg+80,ew=(ej?Math.min(1,(ej-24)/ev):1)*em,eN=(0,a.useRef)(null),eC=(0,a.useRef)(!1),e_=function(e,n,t,l){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{x:0,y:0};if(0===e.button){eN.current={key:n,sx:e.clientX,sy:e.clientY,ox:t,oy:l,min:o,moved:!1};try{e.currentTarget.setPointerCapture(e.pointerId)}catch(e){}}},eM=e=>{let n=eN.current;if(!n)return;let t=(e.clientX-n.sx)/ew,l=(e.clientY-n.sy)/ew;!n.moved&&Math.hypot(t,l)*ew<6||(n.moved=!0,n.last={x:Math.max(n.min.x,n.ox+t),y:Math.max(n.min.y,n.oy+l)},ec({key:n.key,...n.last}))},eA=()=>{let e=eN.current;eN.current=null,(null==e?void 0:e.moved)&&e.last&&(eC.current=!0,setTimeout(()=>{eC.current=!1},0),ea({...es,[e.key]:e.last}),ec(null))},ez=function(e,n,t,l){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{x:0,y:0},s={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]}[e.key];if(!s||e.altKey||e.ctrlKey||e.metaKey)return;e.preventDefault();let a=e.shiftKey?64:16;ea({...es,[n]:{x:Math.max(o.x,t+s[0]*a),y:Math.max(o.y,l+s[1]*a)}})},eS=(e,n,t,l)=>({onPointerDown:o=>e_(o,e,n,t,l),onPointerMove:eM,onPointerUp:eA,onPointerCancel:eA}),eL=new Map;for(let e of ey)for(let n of e.cells)n.agent&&eL.set(n.agent.id,{x:n.x+40,y:n.y+40}),n.object&&eL.set(n.object.id,{x:n.x+40,y:n.y+40});let eF=M.filter(e=>"cluster"===e.kind).flatMap(e=>e.config.members.map(n=>({from:e.id,to:n}))),eD=M.filter(e=>e.manager_id&&eL.has(e.manager_id)&&eL.has(e.id)).map(e=>({from:e.manager_id,to:e.id})),eE=e=>M.filter(n=>n.manager_id===e),[eT,eq]=(0,a.useState)(null),eH=null!=(e=C.find(e=>e.id===U))?e:null,eO=null!=(n=M.find(e=>e.id===U))?n:null,[eI,eW]=(0,a.useState)(null);(0,a.useLayoutEffect)(()=>{eW(U?document.querySelector('[data-sid="'.concat(U,'"]')):null)},[U,C.length,M.length]),(0,a.useEffect)(()=>{if(!U)return;let e=e=>{"Escape"!==e.key||document.querySelector('[role="dialog"]')||V(null)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[U]);let eR=null!=X?X:U,eK=C.filter(e=>"orchestrator"===e.role).flatMap(e=>e.worker_ids.map(n=>({from:e.id,to:n}))),eB=new Set(eR?[eR,...[...eK,...eF,...eD].filter(e=>e.from===eR||e.to===eR).flatMap(e=>[e.from,e.to])]:[]),eP=e=>C.filter(n=>"orchestrator"===n.role&&n.worker_ids.includes(e)),eJ=C.filter(e=>"running"===e.status).length,eG=M.filter(e=>"running"===e.state.status).length,eU=C.filter(e=>"orchestrator"===e.role).length,eV=e=>{var n,t;return null!=(t=null==(n=C.find(n=>n.id===e))?void 0:n.name)?t:o("colony.removedAgent")},eX=z.filter(e=>"running"===e.status).length,eY=[{id:"agents",n:C.length,label:o("stat.agents",{count:C.length}),href:"/agents"},{id:"colonies",n:_.length,label:o("stat.colonies",{count:_.length})},{id:"objects",n:M.length,label:o("stat.objects",{count:M.length}),href:"/resources",title:M.length?o("obj.running",{count:eG}):void 0},{id:"queens",n:eU,label:o("stat.orchestrators",{count:eU}),href:"/agents"},{id:"working",n:eJ,label:o("stat.working"),href:"/agents"},{id:"tasks",n:eX,label:o("stat.tasks"),href:"#recent"}],e$=eH?_.find(e=>e.id===eH.colony_id):void 0,eZ=async(e,n)=>{try{var t,l;await b.FH.patch("/agents/".concat(e.id),{colony_id:n||null,overrides:[]}),await E(["agents","colonies"]),G(n?o("colony.joined",{name:e.name,colony:null!=(l=null==(t=_.find(e=>e.id===n))?void 0:t.name)?l:""}):o("colony.left",{name:e.name}))}catch(e){G(e instanceof Error?e.message:o("colony.moveFailed"),"err")}};return(0,l.jsxs)("div",{className:"page",children:[(0,l.jsxs)("div",{className:"page-head",children:[(0,l.jsxs)("div",{children:[(0,l.jsxs)("div",{className:"row gap-s",children:[(0,l.jsx)("h1",{children:o("nav.colony")}),(0,l.jsx)(H.B,{label:o("colony.helpLabel"),title:o("colony.howTitle"),children:o("colony.howBody")})]}),(0,l.jsx)("p",{children:o("colony.page.subtitle")})]}),(0,l.jsx)("div",{className:"cx-head-actions",children:(0,l.jsx)(w.W1,{label:o("cx.new"),icon:(0,l.jsx)(i.A,{size:14}),children:e=>(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(w.Dr,{icon:(0,l.jsx)(c.A,{size:15}),onClick:()=>{e(),Z({})},children:o("newAgent.title")}),(0,l.jsx)(w.Dr,{icon:(0,l.jsx)(r.A,{size:15}),onClick:()=>{e(),ee("new")},children:o("colony.newTitle")}),(0,l.jsx)(w.Dr,{icon:(0,l.jsx)(d.A,{size:15}),onClick:()=>{e(),eo({})},children:o("obj.new")})]})})})]}),(0,l.jsx)("div",{className:"stats",children:eY.map(e=>{let n=(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("b",{children:e.n}),(0,l.jsx)("span",{children:e.label})]});return e.href?(0,l.jsx)(s(),{href:e.href,className:"card stat",title:e.title,"aria-label":"".concat(e.n," ").concat(e.label,". ").concat(o("cx.stat.open",{label:e.label})),children:n},e.id):(0,l.jsx)("div",{className:"card stat",title:e.title,children:n},e.id)})}),(0,l.jsxs)("div",{className:"colony",children:[(0,l.jsxs)("div",{className:"comb-wrap",ref:ep,children:[S?0===C.length&&0===_.length&&0===M.length?(0,l.jsx)("div",{className:"comb-empty-wrap",children:(0,l.jsx)(k.pp,{icon:(0,l.jsx)(k._h,{size:"lg",queen:!0,label:"+"}),title:o("colony.empty.title"),body:o("colony.empty.body"),action:(0,l.jsxs)("div",{className:"row",children:[(0,l.jsxs)("button",{className:"btn",onClick:()=>ee("new"),children:[(0,l.jsx)(i.A,{size:16}),o("colony.empty.createColony")]}),(0,l.jsxs)("button",{className:"btn primary",onClick:()=>Z({}),children:[(0,l.jsx)(i.A,{size:16}),o("colony.empty.createAgent")]})]})})}):(0,l.jsx)("div",{className:"comb-box",style:{width:ev*ew,height:ek*ew},children:(0,l.jsxs)("div",{className:"comb",style:{width:ev,height:ek,transform:"scale(".concat(ew,")"),transformOrigin:"0 0","--w":"".concat(.9*K,"px"),"--h":"".concat(133.20000000000002,"px")},children:[(0,l.jsx)("svg",{className:"links",width:ev,height:ek,children:ey.filter(e=>e.colony).map(e=>{let n=e.colony.color||"var(--honey)";return(0,l.jsxs)("g",{children:[e.cells.map((e,t)=>(0,l.jsx)("polygon",{points:J(e.x+40,e.y+40,74),style:{fill:n,stroke:n},strokeWidth:44,strokeLinejoin:"round"},"o"+t)),e.cells.map((e,t)=>(0,l.jsx)("polygon",{points:J(e.x+40,e.y+40,74),style:{fill:"color-mix(in srgb, ".concat(n," 9%, var(--surface))"),stroke:"color-mix(in srgb, ".concat(n," 9%, var(--surface))")},strokeWidth:38,strokeLinejoin:"round"},"i"+t))]},e.key)})}),ey.map(e=>(0,l.jsxs)("div",{children:[e.colony?(0,l.jsxs)("button",{className:"colony-label draggable ".concat((null==ei?void 0:ei.key)===e.key?"dragging":""),style:{left:e.x+e.w/2+40,top:e.y+50-10+40,"--c":e.colony.color||"var(--honey)"},...eS(e.key,e.x,e.y),onKeyDown:n=>ez(n,e.key,e.x,e.y),onClick:()=>{eC.current||ee(e.colony)},title:"".concat(e.colony.cwd?o("colony.editHover",{path:(0,v._1)(e.colony.cwd)}):o("colony.editHoverShort")," \xb7 ").concat(o("colony.dragHint")," \xb7 ").concat(o("cx.moveHint")),children:[(0,l.jsx)("i",{className:"cdot"}),e.colony.name,(0,l.jsx)("small",{children:o("colony.agentCount",{count:e.cells.filter(e=>e.agent).length})}),(0,l.jsx)(r.A,{size:13,className:"muted"})]}):_.length>0&&e.cells.some(e=>e.agent)?(0,l.jsx)("span",{className:"colony-label cx-unplaced",style:{left:e.x+e.w/2+40,top:e.y+50-10+40},children:(0,l.jsx)("small",{children:o("common.noColony")})}):null,e.cells.map((n,t)=>{let s=n.agent,a={left:n.x+40,top:n.y+40},c=n.object;if(c){let{icon:t,color:s}=R.Nd[c.kind];return(0,l.jsxs)("button",{"data-sid":c.id,className:"cell fill obj st-".concat(c.state.status," ").concat("running"===c.state.status?"running":""," ").concat(eR&&!eB.has(c.id)?"dim":""," ").concat(eR&&eB.has(c.id)&&c.id!==eR?"linked":""," ").concat(e.colony?"":"draggable"),style:{...a,"--c":s},"aria-pressed":U===c.id,onMouseEnter:()=>Y(c.id),onMouseLeave:()=>Y(null),onFocus:()=>Y(c.id),onBlur:()=>Y(null),...e.colony?{}:{...eS(c.id,n.x,n.y,{x:K/2,y:74}),onKeyDown:e=>ez(e,c.id,n.x,n.y,{x:K/2,y:74})},onClick:()=>{eC.current||V(c.id===U?null:c.id)},"aria-label":"".concat(c.name,", ").concat(o("obj.kind.".concat(c.kind)),", ").concat(o("obj.status.".concat(c.state.status))),title:c.state.detail?"".concat(o("obj.status.".concat(c.state.status)),": ").concat(c.state.detail):o("obj.status.".concat(c.state.status)),children:[(0,l.jsx)("span",{className:"shape"}),(0,l.jsxs)("span",{className:"label",children:[(0,l.jsx)(t,{size:16}),(0,l.jsx)("b",{children:c.name}),(0,l.jsx)("small",{children:o("obj.status.".concat(c.state.status))})]}),(0,l.jsx)("span",{className:"pip o-".concat(c.state.status)}),c.manager_id&&(0,l.jsxs)("span",{className:"ltag top mgr",title:o("colony.managedBy",{name:eV(c.manager_id)}),children:["⚙ ",eV(c.manager_id)]})]},c.id)}return s?(0,l.jsxs)("button",{"data-sid":s.id,className:"cell fill ".concat("orchestrator"===s.role?"queen":""," ").concat("running"===s.status?"running":""," ").concat(eR&&!eB.has(s.id)?"dim":""," ").concat(eR&&eB.has(s.id)&&s.id!==eR?"linked":""," ").concat(e.colony?"":"draggable"),onMouseEnter:()=>Y(s.id),onMouseLeave:()=>Y(null),onFocus:()=>Y(s.id),onBlur:()=>Y(null),style:{...a,"--c":v.xq[s.provider].color},"aria-pressed":U===s.id,...e.colony?{}:{...eS(s.id,n.x,n.y,{x:K/2,y:74}),onKeyDown:e=>ez(e,s.id,n.x,n.y,{x:K/2,y:74}),title:o("cx.moveHint")},onClick:()=>{eC.current||V(s.id===U?null:s.id)},"aria-label":"".concat(s.name,", ").concat(o("role.".concat(s.role)),", ").concat(v.xq[s.provider].short,", ").concat(o("status.".concat(s.status))),children:[(0,l.jsx)("span",{className:"shape"}),(0,l.jsxs)("span",{className:"label",children:[(0,l.jsx)("b",{children:s.name}),(0,l.jsx)("small",{children:v.xq[s.provider].short})]}),"idle"!==s.status&&(0,l.jsx)("span",{className:"pip ".concat("error"===s.status?"err":"")}),eE(s.id).length>0&&(0,l.jsxs)("span",{className:"ltag top mgr",title:o("colony.manages",{names:eE(s.id).map(e=>e.name).join(", ")}),children:["⚙ ",1===eE(s.id).length?eE(s.id)[0].name:eE(s.id).length]}),("orchestrator"===s.role?s.worker_ids.length>0:eP(s.id).length>0)&&(0,l.jsx)("span",{className:"ltag",title:"orchestrator"===s.role?o("colony.delegatesTo",{count:s.worker_ids.length}):o("colony.connectedTo",{names:eP(s.id).map(e=>e.name).join(", ")}),children:"orchestrator"===s.role?"↓ ".concat(s.worker_ids.length):"↑ ".concat(1===eP(s.id).length?eP(s.id)[0].name:eP(s.id).length)})]},s.id):(0,l.jsxs)("button",{className:"cell ghost",style:a,onClick:()=>{var n;return Z({colonyId:null==(n=e.colony)?void 0:n.id})},"aria-label":e.colony?o("colony.addTo",{name:e.colony.name}):o("colony.addAgent"),children:[(0,l.jsx)("svg",{className:"ghost-hex",viewBox:"0 0 100 115",preserveAspectRatio:"none","aria-hidden":!0,children:(0,l.jsx)("polygon",{points:"50,2 98,29 98,86 50,113 2,86 2,29"})}),(0,l.jsxs)("span",{className:"label",children:[(0,l.jsx)(i.A,{size:18}),o("colony.addAgent")]})]},e.key+"g"+t)})]},e.key+"l")),(0,l.jsxs)("svg",{className:"links top",width:ev,height:ek,"aria-hidden":!0,children:[eK.filter(e=>!!eR&&(e.from===eR||e.to===eR)).map(e=>{var n;let t=eL.get(e.from),o=eL.get(e.to);if(!t||!o)return null;let s=o.x-t.x,a=o.y-t.y,i=Math.hypot(s,a)||1,c=s/i,r=a/i,d=t.x+45.88*c,m=t.y+45.88*r,h=o.x-45.88*c,u=o.y-45.88*r,y=(null==(n=C.find(n=>n.id===e.to))?void 0:n.status)==="running",x=!!eR&&(e.from===eR||e.to===eR),g=!!eR&&!x;return(0,l.jsxs)("g",{opacity:g?.18:1,children:[(0,l.jsx)("line",{x1:d,y1:m,x2:h,y2:u,stroke:"var(--surface)",strokeWidth:x?8:5,strokeLinecap:"round",opacity:.85}),(0,l.jsx)("line",{x1:d,y1:m,x2:h,y2:u,stroke:"var(--honey)",strokeWidth:x?3.5:2.2,strokeDasharray:y?"7 6":x?void 0:"1 6",strokeLinecap:"round",children:y&&(0,l.jsx)("animate",{attributeName:"stroke-dashoffset",from:"26",to:"0",dur:"0.8s",repeatCount:"indefinite"})}),(0,l.jsx)("circle",{cx:h,cy:u,r:x?5.5:4,fill:"var(--honey)",stroke:"var(--surface)",strokeWidth:2})]},e.from+e.to)}),[...eF.map(e=>({...e,kind:"cluster"})),...eD.map(e=>({...e,kind:"manager"}))].filter(e=>!!eR&&(e.from===eR||e.to===eR)).map(e=>{let n=eL.get(e.from),t=eL.get(e.to);if(!n||!t)return null;let o=t.x-n.x,s=t.y-n.y,a=Math.hypot(o,s)||1,i=o/a,c=s/a,r="cluster"===e.kind?v.Ng:"var(--link-manager)";return(0,l.jsxs)("g",{children:[(0,l.jsx)("line",{x1:n.x+45.88*i,y1:n.y+45.88*c,x2:t.x-45.88*i,y2:t.y-45.88*c,stroke:"var(--surface)",strokeWidth:8,strokeLinecap:"round",opacity:.9}),(0,l.jsx)("line",{x1:n.x+45.88*i,y1:n.y+45.88*c,x2:t.x-45.88*i,y2:t.y-45.88*c,stroke:r,strokeWidth:3,strokeDasharray:"cluster"===e.kind?"3 5":"8 5",strokeLinecap:"round"}),(0,l.jsx)("circle",{cx:t.x-45.88*i,cy:t.y-45.88*c,r:5,fill:r,stroke:"var(--surface)",strokeWidth:2})]},e.kind+e.from+e.to)})]})]})}):F?(0,l.jsx)("div",{className:"comb-skel",children:(0,l.jsx)(k.lZ,{kind:"err",children:(0,l.jsxs)("div",{className:"row gap-s wrap",children:[(0,l.jsxs)("span",{className:"grow",children:[o("cx.loadFailed")," ",F]}),(0,l.jsx)("button",{className:"btn sm",onClick:()=>void D(),children:o("cx.retry")})]})})}):(0,l.jsxs)("div",{className:"comb-skel",role:"status","aria-label":o("cx.loading"),children:[(0,l.jsx)("div",{className:"skel",style:{width:220,height:190}}),(0,l.jsxs)("div",{className:"row gap-l",children:[(0,l.jsx)("div",{className:"skel",style:{width:150,height:130}}),(0,l.jsx)("div",{className:"skel",style:{width:150,height:130}})]})]}),(0,l.jsxs)("div",{className:"comb-zoom",role:"group","aria-label":o("colony.zoom"),children:[Object.keys(es).length>0&&(0,l.jsx)("button",{className:"btn ghost icon sm",onClick:()=>ea({}),title:o("colony.layout.reset"),"aria-label":o("colony.layout.reset"),children:(0,l.jsx)(m.A,{size:14})}),(0,l.jsx)("button",{className:"btn ghost icon sm",onClick:()=>eh(em/1.2),disabled:em<=.4,title:o("colony.zoom.out"),"aria-label":o("colony.zoom.out"),children:(0,l.jsx)(h.A,{size:14})}),(0,l.jsxs)("button",{className:"btn ghost sm zoom-pct",onClick:()=>eh(1),title:o("colony.zoom.fit"),"aria-label":o("colony.zoom.fit"),children:[Math.round(100*em),"%"]}),(0,l.jsx)("button",{className:"btn ghost icon sm",onClick:()=>eh(1.2*em),disabled:em>=2.5,title:o("colony.zoom.in"),"aria-label":o("colony.zoom.in"),children:(0,l.jsx)(i.A,{size:14})}),(0,l.jsx)("button",{className:"btn ghost icon sm",onClick:()=>eh(1),title:o("colony.zoom.fit"),"aria-label":o("colony.zoom.fit"),children:(0,l.jsx)(u.A,{size:14})})]}),(0,l.jsxs)("div",{className:"comb-legend",children:[Object.keys(v.xq).map(e=>(0,l.jsxs)("span",{className:"pbadge",style:{"--c":v.xq[e].color},children:[(0,l.jsx)("i",{}),v.xq[e].short]},e)),(0,l.jsxs)("span",{className:"pbadge",style:{"--c":"var(--honey)"},children:[(0,l.jsx)("i",{}),o("role.orchestrator")]})]})]}),eO?(0,l.jsx)(I.wl,{object:eO,target:eI,onClose:()=>V(null),onCreateManager:()=>{var e;return Z({colonyId:null!=(e=eO.colony_id)?e:void 0,manager:!0,objectId:eO.id})}},eO.id):eH?(0,l.jsxs)(O.rs,{target:eI,pinned:!0,width:340,label:eH.name,onClose:()=>V(null),children:[(0,l.jsxs)("div",{className:"ap-corner row gap-s",children:[(0,l.jsx)("button",{className:"btn ghost icon sm",onClick:()=>et(eH.id),"aria-label":o("colony.settingsFor",{name:eH.name}),title:o("colony.agentSettings"),children:(0,l.jsx)(y.A,{size:16})}),(0,l.jsx)("button",{className:"btn ghost icon sm",onClick:()=>V(null),"aria-label":o("common.close"),title:"".concat(o("common.close")," (Esc)"),children:(0,l.jsx)(x.A,{size:16})})]}),(0,l.jsx)(O.kh,{agent:eH,hideColony:!0}),(0,l.jsxs)("div",{className:"field ap-pin-field",children:[(0,l.jsx)("label",{children:o("form.colony")}),(0,l.jsxs)("select",{className:"select",value:null!=(t=null==e$?void 0:e$.id)?t:"",onChange:e=>void eZ(eH,e.target.value),children:[(0,l.jsx)("option",{value:"",children:o("common.noColony")}),_.map(e=>(0,l.jsx)("option",{value:e.id,children:e.name},e.id))]})]}),(0,l.jsxs)("div",{className:"row ap-pin-actions",children:[(0,l.jsxs)(s(),{className:"btn primary grow",href:"/agents/".concat(eH.id),children:[o("colony.openChat")," ",(0,l.jsx)(g,{size:16})]}),(0,l.jsx)("button",{className:"btn danger icon",onClick:()=>eq(eH.id),"aria-label":o("agent.delete"),title:o("agent.delete"),children:(0,l.jsx)(p.A,{size:16})})]})]},eH.id):null]}),(0,l.jsxs)("div",{className:"card card-pad recent",id:"recent",children:[(0,l.jsx)("div",{className:"eyebrow recent-head",children:o("colony.recent")}),0===z.length?(0,l.jsx)("p",{className:"muted small m0",children:o("colony.recentEmpty")}):(0,l.jsx)("div",{className:"recent-grid",children:z.slice(0,6).map(e=>(0,l.jsxs)("div",{className:"feed-item",children:[(0,l.jsx)("i",{className:"dot ".concat("running"===e.status?"run":"done"===e.status?"ok":"err")}),(0,l.jsxs)("div",{children:[(0,l.jsxs)("div",{className:"feed-line",children:[C.some(n=>n.id===e.from_id)?(0,l.jsx)(s(),{href:"/agents/".concat(e.from_id),"aria-label":o("cx.openAgent",{name:eV(e.from_id)}),children:eV(e.from_id)}):(0,l.jsx)("b",{children:eV(e.from_id)})," → ",C.some(n=>n.id===e.to_id)?(0,l.jsx)(s(),{href:"/agents/".concat(e.to_id),"aria-label":o("cx.openAgent",{name:eV(e.to_id)}),children:eV(e.to_id)}):(0,l.jsx)("b",{children:eV(e.to_id)})]}),(0,l.jsx)("div",{className:"muted small ellipsis",children:e.task}),(0,l.jsx)("div",{className:"muted feed-when",children:(0,v.KN)(e.created_at)})]})]},e.id))})]}),eT&&C.find(e=>e.id===eT)&&(0,l.jsx)(q.G,{agent:C.find(e=>e.id===eT),onClose:()=>eq(null),onDeleted:()=>V(null)}),$&&(0,l.jsx)(N.b,{presetColonyId:$.colonyId,presetObjectId:$.objectId,manager:$.manager,onClose:()=>Z(null),onCreated:e=>V(e)}),en&&C.find(e=>e.id===en)&&(0,l.jsx)(T,{agent:C.find(e=>e.id===en),onClose:()=>et(null)},en),el&&(0,l.jsx)(W.X,{presetColonyId:el.colonyId,onClose:()=>eo(null),onSaved:e=>V(e)}),Q&&(0,l.jsx)(L,{colony:"new"===Q?void 0:Q,onClose:()=>ee(null)})]})}},48776:(e,n,t)=>{"use strict";t.d(n,{G:()=>c});var l=t(94799),o=t(10804),s=t(48538),a=t(3749),i=t(69654);function c(e){let{agent:n,onClose:t,onDeleted:c}=e,{t:r}=(0,i.s9)(),{refresh:d}=(0,s.zd)(),m=(0,o.dj)();return(0,l.jsx)(o.TM,{title:r("agent.deleteTitle",{name:n.name}),body:r("agent.deleteBody"),danger:!0,confirmLabel:r("agent.delete"),cancelLabel:r("agent.keep"),onClose:t,onConfirm:async()=>{await a.FH.del("/agents/".concat(n.id)),await d(["agents","colonies"]),m(r("agent.deleted")),null==c||c()}})}},75406:(e,n,t)=>{"use strict";t.d(n,{A:()=>l});let l=(0,t(74955).A)("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]])},77701:(e,n,t)=>{Promise.resolve().then(t.bind(t,36098))},89128:(e,n,t)=>{"use strict";t.d(n,{A:()=>u});var l=t(94799),o=t(34023),s=t(97356),a=t(10804),i=t(5300),c=t(48776),r=t(48538),d=t(73506),m=t(3749),h=t(69654);function u(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{t}=(0,h.s9)(),{agents:u,colonies:y,objects:x,refresh:g}=(0,r.q5)(),p=(0,a.dj)(),j=(0,o.useMemo)(()=>e?x.filter(n=>n.manager_id===e.id).map(e=>e.id).sort():[],[x,null==e?void 0:e.id]),f=(0,o.useMemo)(()=>e?JSON.stringify((0,i.TN)(e,j)):"",[e,j]),[b,v]=(0,o.useState)(()=>e?(0,i.TN)(e,j):null),[k,w]=(0,o.useState)(!1),[N,C]=(0,o.useState)(!1);(0,o.useEffect)(()=>{v(e?(0,i.TN)(e,j):null)},[f]);let _=b&&e?(0,i.tf)(b,u,e.id,y):{},M=!!b&&JSON.stringify(b)!==f;(0,d.h)(M);let A=async()=>{if(b&&e){if(Object.keys(_).length)return void p(t("edit.fixFields"),"err");w(!0);try{var l;let{type_id:o,object_ids:s,...a}=b;await m.FH.patch("/agents/".concat(e.id),a),JSON.stringify([...s].sort())!==JSON.stringify(j)&&await m.FH.put("/agents/".concat(e.id,"/resources"),{object_ids:s}),await g(["agents","colonies","objects"]),p(t("edit.saved",{name:b.name.trim()})),null==(l=n.onSaved)||l.call(n)}catch(e){p(e instanceof Error?e.message:t("edit.saveFailed"),"err")}w(!1)}},z=()=>{e&&v((0,i.TN)(e,j))};return{draft:b,setDraft:v,errors:_,dirty:M,saving:k,save:A,discard:z,actions:function(){var e,n,o,a;let i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("button",{className:"btn danger push-r ".concat(null!=(e=i.size)?e:""),onClick:()=>C(!0),children:[(0,l.jsx)(s.A,{size:i.size?14:15}),t("agent.delete")]}),i.onCancel?(0,l.jsx)("button",{className:"btn ghost ".concat(null!=(n=i.size)?n:""),onClick:i.onCancel,children:t("common.cancel")}):(0,l.jsx)("button",{className:"btn ghost ".concat(null!=(o=i.size)?o:""),disabled:!M,onClick:z,children:t("common.discard")}),(0,l.jsx)("button",{className:"btn primary ".concat(null!=(a=i.size)?a:""),disabled:!M||k,onClick:A,children:k?t("common.saving"):t("common.saveChanges")})]})},deleteModal:N&&e?(0,l.jsx)(c.G,{agent:e,onClose:()=>C(!1),onDeleted:n.onDeleted}):null}}}},e=>{e.O(0,[586,706,391,281,517,350,606,587,408,89,358],()=>e(e.s=77701)),_N_E=e.O()}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[964],{27949:(e,r,l)=>{Promise.resolve().then(l.bind(l,86300))},86300:(e,r,l)=>{"use strict";l.r(r),l.d(r,{default:()=>v});var s=l(94799),t=l(34023),a=l(20831),i=l(15334);l(40117);var n=l(70665),o=l(10964),d=l(48538),c=l(77021),h=l(3749),u=l(47890),m=l(10804),x=l(69654);let p=e=>{let r=u.hg[e%u.hg.length];return"color-mix(in srgb, ".concat(r," calc(100% - var(--series-mix, 0%)), white)")},g={agent:function(e){let{data:r}=e,{t:l}=(0,x.s9)(),t=r.agent;return(0,s.jsxs)("div",{className:"rnode ".concat(r.dim?"dim":""," ").concat(r.active?"active":""),children:["worker"===t.role&&(0,s.jsx)(a.h7,{type:"target",position:i.yX.Top}),(0,s.jsx)(m._h,{agent:t}),(0,s.jsx)("b",{children:t.name}),(0,s.jsx)("small",{children:"orchestrator"===t.role?l("role.orchestrator"):u.xq[t.provider].short}),"orchestrator"===t.role&&(0,s.jsx)(a.h7,{type:"source",position:i.yX.Bottom})]})}},j={link:function(e){let{id:r,sourceX:l,sourceY:t,targetX:o,targetY:d,sourcePosition:c,targetPosition:h,data:u}=e,[m,x,p]=(0,i.Fp)({sourceX:l,sourceY:t,targetX:o,targetY:d,sourcePosition:c,targetPosition:h,curvature:.35});return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(a.tE,{id:r,path:m,interactionWidth:26,style:{stroke:u.color,strokeWidth:u.active?4:2.5,opacity:u.dim?.15:1,transition:"opacity .15s, stroke-width .15s"}}),u.show&&(0,s.jsx)(a.rV,{children:(0,s.jsx)("button",{className:"edge-x nodrag nopan",style:{transform:"translate(-50%, -50%) translate(".concat(x,"px, ").concat(p,"px)")},onClick:u.onRemove,"aria-label":u.label,title:u.label,children:(0,s.jsx)(n.A,{size:13,strokeWidth:3})})})]})}};function v(){let{t:e,locale:r}=(0,x.s9)(),{agents:l,refresh:i,ready:u,error:v,retry:k}=(0,d.q5)(),w=(0,m.dj)(),[f,N]=(0,c.ud)("hive-rel-pos-v2",{}),[b,y]=(0,t.useState)([]),[_,C]=(0,t.useState)(null),[E,M]=(0,t.useState)(null),[F,O]=(0,t.useState)(null),[S,W]=(0,t.useState)(0),A=(0,t.useMemo)(()=>(function(e){let r=e.filter(e=>"orchestrator"===e.role),l=e.filter(e=>"worker"===e.role),s=e=>r.find(r=>r.worker_ids.includes(e.id)),t={},a=0;for(let e of r){let r=l.filter(r=>{var l;return(null==(l=s(r))?void 0:l.id)===e.id}),i=Math.max(1,r.length);r.forEach((e,r)=>t[e.id]={x:a+190*r,y:280}),t[e.id]={x:a+(i-1)*190/2,y:0},a+=190*i+114}return l.filter(e=>!s(e)).forEach((e,r)=>t[e.id]={x:a+190*r,y:280}),t})(l),[l]);(0,t.useEffect)(()=>{y(l.map(e=>{var r,l;return{id:e.id,type:"agent",position:null!=(l=null!=(r=f[e.id])?r:A[e.id])?l:{x:0,y:0},data:{agent:e,dim:!1,active:!1}}}))},[l,A,f]);let T=(0,t.useMemo)(()=>new Map(l.filter(e=>"orchestrator"===e.role).map((e,r)=>[e.id,r])),[l]),V=null!=_?_:F,z=e=>{var r,s;return null!=(s=null==(r=l.find(r=>r.id===e))?void 0:r.name)?s:"?"},L=(0,t.useCallback)(async(r,l,s)=>{try{await h.FH.put("/orchestrators/".concat(r,"/workers"),{worker_ids:l}),await i(["agents"]),w(s)}catch(r){w(r instanceof Error?r.message:e("rel.updateFailed"),"err")}},[i,w]),R=(0,t.useCallback)((r,s)=>{let t=l.find(e=>e.id===r);t&&L(r,t.worker_ids.filter(e=>e!==s),e("rel.disconnected",{worker:z(s),orchestrator:t.name}))},[l,L]),Z=(0,t.useCallback)((r,s)=>{let t=l.find(e=>e.id===r);!t||t.worker_ids.includes(s)||L(r,[...t.worker_ids,s],e("rel.connected",{worker:z(s),orchestrator:t.name}))},[l,L]),q=(0,t.useMemo)(()=>l.filter(e=>"orchestrator"===e.role).flatMap(r=>r.worker_ids.map(s=>{var t,a;let i="".concat(r.id,">").concat(s),n=!!V&&(r.id===V||s===V);return{id:i,source:r.id,target:s,type:"link",animated:(null==(t=l.find(e=>e.id===s))?void 0:t.status)==="running",data:{color:p(null!=(a=T.get(r.id))?a:0),dim:!!V&&!n,active:n||E===i,show:n||E===i,label:e("rel.disconnectLabel",{worker:z(s),orchestrator:r.name}),onRemove:()=>R(r.id,s)}}})),[l,V,E,T,R,r]),B=(0,t.useMemo)(()=>{let e=new Set(V?[V]:[]);if(V)for(let r of q)(r.source===V||r.target===V)&&(e.add(r.source),e.add(r.target));return b.map(r=>({...r,selected:r.id===F,data:{...r.data,dim:!!V&&!e.has(r.id),active:r.id===V}}))},[b,q,V,F]),H=(0,t.useCallback)(e=>{y(r=>(0,a._0)(e,r));let r=e.filter(e=>"position"===e.type&&!e.dragging&&e.position);r.length&&N(e=>{let l={...e};for(let e of r)"position"===e.type&&e.position&&(l[e.id]=e.position);return l})},[]),P=l.find(e=>e.id===F),X=l.filter(e=>"orchestrator"===e.role),G=l.filter(e=>"worker"===e.role);return(0,s.jsxs)("div",{className:"page full rel",children:[(0,s.jsxs)("div",{className:"rel-hud",children:[(0,s.jsx)("h1",{children:e("nav.relations")}),(0,s.jsx)("p",{children:e("rel.hud")})]}),(0,s.jsx)("div",{className:"rel-tools",children:(0,s.jsxs)("button",{className:"btn sm",onClick:()=>{N({}),W(e=>e+1),w(e("rel.layoutReset"))},children:[(0,s.jsx)(o.A,{size:14}),e("rel.autoArrange")]})}),u?0===l.length?(0,s.jsx)("div",{className:"rel-empty",children:(0,s.jsx)(m.pp,{title:e("rel.empty.title"),body:e("rel.empty.body")})}):(0,s.jsxs)(a.Gc,{nodes:B,edges:q,nodeTypes:g,edgeTypes:j,onNodesChange:H,onConnect:e=>{e.source&&e.target&&Z(e.source,e.target)},onNodeMouseEnter:(e,r)=>C(r.id),onNodeMouseLeave:()=>C(null),onNodeClick:(e,r)=>O(e=>e===r.id?null:r.id),onPaneClick:()=>O(null),onEdgeMouseEnter:(e,r)=>M(r.id),onEdgeMouseLeave:()=>M(null),fitView:!0,fitViewOptions:{padding:.35,maxZoom:1.1},minZoom:.3,proOptions:{hideAttribution:!0},deleteKeyCode:null,nodesConnectable:!0,children:[(0,s.jsx)(a.VS,{gap:28,color:"var(--line-strong)"}),(0,s.jsx)(a.H2,{showInteractive:!1})]},S):v?(0,s.jsx)("div",{className:"rel-empty",children:(0,s.jsx)(m.lZ,{kind:"err",children:(0,s.jsxs)("div",{className:"row gap-s wrap",children:[(0,s.jsxs)("span",{className:"grow",children:[e("cx.loadFailed")," ",v]}),(0,s.jsx)("button",{className:"btn sm",onClick:()=>void k(),children:e("cx.retry")})]})})}):(0,s.jsx)("div",{className:"rel-empty comb-skel",role:"status","aria-label":e("cx.loading"),children:(0,s.jsx)("div",{className:"skel",style:{width:200,height:120}})}),P&&(0,s.jsxs)("aside",{className:"rel-panel card",children:[(0,s.jsxs)("div",{className:"row gap-l",children:[(0,s.jsx)(m._h,{agent:P}),(0,s.jsxs)("div",{className:"grow",children:[(0,s.jsx)("b",{className:"rel-panel-name",children:P.name}),(0,s.jsx)("div",{className:"muted small",children:e("role.".concat(P.role))})]}),(0,s.jsx)("button",{className:"btn ghost icon sm",onClick:()=>O(null),"aria-label":e("common.close"),children:(0,s.jsx)(n.A,{size:16})})]}),"orchestrator"===P.role?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"eyebrow",children:e("rel.delegatesTo",{count:P.worker_ids.length})}),0===P.worker_ids.length&&(0,s.jsx)("p",{className:"muted small m0",children:e("rel.noWorkers")}),P.worker_ids.map(r=>(0,s.jsxs)("div",{className:"relrow",children:[(0,s.jsx)("span",{className:"grow",children:z(r)}),(0,s.jsx)("button",{className:"btn sm",onClick:()=>R(P.id,r),children:e("rel.disconnect")})]},r)),(0,s.jsxs)("select",{className:"select",value:"",onChange:e=>e.target.value&&Z(P.id,e.target.value),"aria-label":e("rel.connectWorker"),children:[(0,s.jsx)("option",{value:"",children:e("rel.connectWorker")}),G.filter(e=>!P.worker_ids.includes(e.id)).map(e=>(0,s.jsx)("option",{value:e.id,children:e.name},e.id))]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"eyebrow",children:e("rel.directedBy")}),0===X.filter(e=>e.worker_ids.includes(P.id)).length&&(0,s.jsx)("p",{className:"muted small m0",children:e("rel.noOrchestrators")}),X.filter(e=>e.worker_ids.includes(P.id)).map(r=>{var l;return(0,s.jsxs)("div",{className:"relrow",children:[(0,s.jsx)("i",{className:"cdot cx-chip-dot",style:{background:p(null!=(l=T.get(r.id))?l:0)}}),(0,s.jsx)("span",{className:"grow",children:r.name}),(0,s.jsx)("button",{className:"btn sm",onClick:()=>R(r.id,P.id),children:e("rel.disconnect")})]},r.id)}),(0,s.jsxs)("select",{className:"select",value:"",onChange:e=>e.target.value&&Z(e.target.value,P.id),"aria-label":e("rel.connectOrchestrator"),children:[(0,s.jsx)("option",{value:"",children:e("rel.connectOrchestrator")}),X.filter(e=>!e.worker_ids.includes(P.id)).map(e=>(0,s.jsx)("option",{value:e.id,children:e.name},e.id))]})]})]})]})}}},e=>{e.O(0,[48,986,586,562,281,408,89,358],()=>e(e.s=27949)),_N_E=e.O()}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[898],{15065:(e,s,n)=>{Promise.resolve().then(n.bind(n,25382))},25382:(e,s,n)=>{"use strict";n.r(s),n.d(s,{default:()=>p});var t=n(94799),a=n(41463),l=n.n(a),i=n(34023),r=n(3749),c=n(48538),o=n(37064),d=n(61748),u=n(51705),m=n(47890),h=n(56072),g=n(10804),v=n(69654);function p(){let{t:e,locale:s}=(0,v.s9)(),{agents:n}=(0,c.q5)(),[a,p]=(0,i.useState)(null),[x,j]=(0,i.useState)(""),[f,w]=(0,i.useState)("all"),[N,_]=(0,d.Z)("session",""),[y,b]=(0,i.useState)(!1),[k,E]=(0,i.useState)(null),[S,L]=(0,i.useState)(0),[C,R]=(0,i.useState)(100),M=(0,i.useRef)(null),P=null===a||a.some(e=>e.pending);(0,o.n)(async()=>{p(await r.FH.get("/sessions")),b(!1)},2500,{enabled:P,onError:()=>{b(!0),p(e=>null!=e?e:[])}});let q=(0,i.useMemo)(()=>N&&(null==a?void 0:a.find(e=>e.session_id===N))||null,[a,N]);(0,i.useEffect)(()=>{R(100)},[null==q?void 0:q.session_id]),(0,i.useEffect)(()=>{let e=!1;return q?(r.FH.get("/agents/".concat(q.agent_id,"/history?session=").concat(encodeURIComponent(q.session_id),"&limit=").concat(C)).then(s=>{var n;e||(E(s.messages),L(null!=(n=s.total)?n:s.messages.length))}).catch(()=>!e&&E([])),()=>{e=!0}):void E(null)},[null==q?void 0:q.agent_id,null==q?void 0:q.session_id,C]),(0,i.useEffect)(()=>{k&&100===C&&M.current&&(M.current.scrollTop=M.current.scrollHeight)},[k,C]);let F=(0,i.useMemo)(()=>(null!=a?a:[]).filter(e=>("all"===f||e.provider===f)&&(!x||"".concat(e.agent_name," ").concat(e.preview," ").concat(e.cwd).toLowerCase().includes(x.toLowerCase()))),[a,x,f]),O=(0,i.useMemo)(()=>{let e=new Map;for(let n of F){var s;let t=new Date(n.last_seen).toLocaleDateString((0,v.VR)(),{weekday:"long",day:"numeric",month:"short"});e.set(t,[...null!=(s=e.get(t))?s:[],n])}return[...e.entries()]},[F,s]),T=q&&n.find(e=>e.id===q.agent_id),Z=k?S-k.length:0;return(0,t.jsx)("div",{className:"page full",children:!y||(null==a?void 0:a.length)?a&&!a.length?(0,t.jsx)("div",{className:"m-xl",children:(0,t.jsx)(g.pp,{title:e("sessions.empty.title"),body:e("sessions.empty.body"),action:(0,t.jsx)(l(),{className:"btn primary",href:"/agents",children:e("sessions.empty.go")})})}):(0,t.jsxs)("div",{className:"sk-ws sx-ws",children:[(0,t.jsxs)("aside",{className:"switcher","aria-label":e("nav.sessions"),children:[(0,t.jsxs)("div",{className:"switcher-head",children:[(0,t.jsx)("b",{className:"fa-title",children:e("nav.sessions")}),(0,t.jsx)(g.DO,{value:x,onChange:j,placeholder:e("sessions.searchPlaceholder"),label:e("sessions.searchLabel")}),(0,t.jsx)(g.$q,{value:f,onChange:w,options:[{id:"all",label:e("common.all")},...Object.keys(m.xq).map(e=>({id:e,label:m.xq[e].short}))]})]}),(0,t.jsxs)("div",{className:"switcher-list",children:[null===a&&(0,t.jsx)("p",{className:"muted small pad-m",children:e("sessions.reading")}),O.map(s=>{let[n,a]=s;return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"switcher-group",children:[n,(0,t.jsx)("span",{children:a.length})]}),a.map(s=>{var n;return(0,t.jsxs)("button",{className:"sk-item","aria-current":(null==q?void 0:q.session_id)===s.session_id,onClick:()=>_(s.session_id),children:[(0,t.jsxs)("div",{className:"row gap-xs",children:[(0,t.jsx)("b",{className:"grow",children:s.agent_name}),(0,t.jsx)(g.dJ,{provider:s.provider}),s.current&&(0,t.jsx)("span",{className:"chip honey",children:e("sessions.current")})]}),(0,t.jsx)("span",{className:"sk-desc",children:s.preview||(s.pending?e("sessions.counting"):s.task||e("sessions.emptySession"))}),(0,t.jsxs)("span",{className:"sk-meta",children:[(0,m.KN)(s.last_seen),"delegation"===s.kind&&" \xb7 ".concat(e("sessions.delegatedBy",{name:null!=(n=s.from_name)?n:e("chat.anOrchestrator")})),s.pending&&!s.message_count?" \xb7 …":" \xb7 ".concat(e("sessions.messages",{count:s.message_count})),(0,h.RP)(s.usage)>0&&" \xb7 ".concat((0,h.yj)((0,h.RP)(s.usage))," ").concat(e("stats.tokens")),null!==s.cost&&" \xb7 ≈ ".concat((0,h.F0)(s.cost))]})]},s.agent_id+s.session_id)})]},n)}),a&&a.length>0&&!F.length&&(0,t.jsx)("p",{className:"muted small pad-m",children:e("sessions.noMatch")})]})]}),q?(0,t.jsxs)("section",{className:"sk-main",children:[(0,t.jsxs)("header",{className:"sx-head",children:[(0,t.jsxs)("div",{className:"grow",children:[(0,t.jsx)("b",{className:"fa-title lg",children:q.agent_name}),(0,t.jsxs)("div",{className:"muted small mono ellipsis",children:[(0,m._1)(q.cwd)," \xb7 ",q.session_id]})]}),T&&(0,t.jsx)(l(),{className:"btn sm primary",href:"/agents/".concat(T.id),children:e("sessions.openAgent")})]}),(0,t.jsx)("div",{className:"transcript col sx-transcript",ref:M,children:null===k?(0,t.jsx)("p",{className:"muted",children:e("sessions.loading")}):0===k.length?(0,t.jsx)("p",{className:"muted",children:e("sessions.noMessages")}):(0,t.jsxs)(t.Fragment,{children:[Z>0&&(0,t.jsx)("button",{className:"btn sm push-c",onClick:()=>R(C+200),children:e("sessions.older",{count:Z})}),(0,t.jsx)(u.BZ,{msgs:k,agent:{id:q.agent_id,name:q.agent_name,provider:q.provider,role:q.agent_role}})]})})]}):(0,t.jsx)("section",{className:"sk-main sk-none",children:(0,t.jsx)("p",{className:"muted",children:e("sessions.select")})})]}):(0,t.jsx)("div",{className:"m-xl",children:(0,t.jsx)(g.lZ,{kind:"err",children:e("fa.sessions.loadFailed")})})})}},37064:(e,s,n)=>{"use strict";n.d(s,{n:()=>a});var t=n(34023);function a(e,s){let{enabled:n=!0,pauseHidden:a=!0,immediate:l=!0,onError:i}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=(0,t.useRef)(e);r.current=e;let c=(0,t.useRef)(i);c.current=i,(0,t.useEffect)(()=>{let e;if(!n)return;let t=!1,i=0,o=!1,d=()=>{clearTimeout(e),t||(e=setTimeout(()=>void u(),s*Math.min(6,2**i)))},u=async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!t&&!o){if(!e&&a&&"undefined"!=typeof document&&"hidden"===document.visibilityState)return void d();o=!0;try{await r.current(),i=0}catch(e){var s;0==i++&&(null==(s=c.current)||s.call(c,e))}finally{o=!1,d()}}},m=()=>{"visible"!==document.visibilityState||o||(clearTimeout(e),u())};return l?u(!0):d(),a&&document.addEventListener("visibilitychange",m),()=>{t=!0,clearTimeout(e),document.removeEventListener("visibilitychange",m)}},[s,n,a,l])}},61748:(e,s,n)=>{"use strict";n.d(s,{Z:()=>l});var t=n(34023);let a="hive-am:query";function l(e,s){let[n,l]=(0,t.useState)(s);return(0,t.useEffect)(()=>{let n=()=>{var n;return l(null!=(n=new URLSearchParams(location.search).get(e))?n:s)};return n(),window.addEventListener("popstate",n),window.addEventListener(a,n),()=>{window.removeEventListener("popstate",n),window.removeEventListener(a,n)}},[e,s]),[n,(0,t.useCallback)(n=>{let t=new URL(location.href);n===s?t.searchParams.delete(e):t.searchParams.set(e,n),history.replaceState(history.state,"",t),l(n),window.dispatchEvent(new Event(a))},[e,s])]}}},e=>{e.O(0,[586,706,654,281,350,705,408,89,358],()=>e(e.s=15065)),_N_E=e.O()}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[192],{3492:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(74955).A)("Heading2",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]])},11108:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>k});var a=t(94799),l=t(34023),i=t(12646),n=t(92947),r=t(97356),d=t(48538),o=t(3749),c=t(47890),p=t(10804),h=t(1517),y=t(69654),m=t(56072),u=t(73506);let x={name:"",description:"",role:"worker",provider:"claude",model:"",system_prompt:"",permission:"acceptEdits",skill_ids:[],skill_loads:{}};function k(){let{t:e}=(0,y.s9)(),{types:s,agents:t,skills:k,providers:j,refresh:v,ready:b}=(0,d.o0)(),g=(0,p.dj)(),[f,M]=(0,l.useState)(null),[A,N]=(0,l.useState)(""),[C,w]=(0,l.useState)(null),[_,z]=(0,l.useState)(null),[q,H]=(0,l.useState)(!1),D=(0,l.useRef)(""),S=e=>{D.current=JSON.stringify(e),M(e),N("")},V=!!f&&JSON.stringify(f)!==D.current;(0,u.h)(V);let L=()=>{V?H(!0):M(null)},T=async()=>{if(f){if(!f.name.trim())return void N(e("types.err.name"));try{f.id?await o.FH.patch("/types/".concat(f.id),f):await o.FH.post("/types",f),await v(["types"]),g(f.id?e("types.updated"):e("types.created")),M(null),N("")}catch(s){N(s instanceof Error?s.message:e("edit.saveFailed"))}}},E=(e,s)=>M(t=>t&&{...t,[e]:s});return(0,a.jsxs)("div",{className:"page",children:[(0,a.jsxs)("div",{className:"page-head",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h1",{children:e("nav.types")}),(0,a.jsx)("p",{children:e("types.subtitle")})]}),(0,a.jsxs)("button",{className:"btn primary",onClick:()=>S(x),children:[(0,a.jsx)(n.A,{size:16}),e("types.new")]})]}),b&&!s.length?(0,a.jsx)(p.pp,{title:e("types.empty.title"),body:e("types.empty.body"),action:(0,a.jsxs)("button",{className:"btn primary",onClick:()=>S(x),children:[(0,a.jsx)(n.A,{size:16}),e("types.empty.create")]})}):(0,a.jsx)("div",{className:"typegrid",children:s.map(s=>{let l=t.filter(e=>e.type_id===s.id).length;return(0,a.jsxs)("div",{className:"card typecard",children:[(0,a.jsxs)("div",{className:"row gap-l",children:[(0,a.jsx)(p._h,{color:c.xq[s.provider].color,queen:"orchestrator"===s.role,label:s.name.slice(0,2).toUpperCase()}),(0,a.jsxs)("div",{className:"grow",children:[(0,a.jsx)("h3",{className:"fa-card-title",children:s.name}),(0,a.jsx)("div",{className:"row gap-s mt-xs",children:(0,a.jsx)(p.PW,{role:s.role})})]})]}),(0,a.jsx)("p",{className:"muted small m0 fa-desc",children:s.description||e("types.noDescription")}),(0,a.jsxs)("div",{className:"row gap-s wrap",children:[(0,a.jsx)("span",{className:"chip",children:c.xq[s.provider].label}),(0,a.jsx)("span",{className:"chip",children:s.model||e("types.defaultModel")}),(0,a.jsx)("span",{className:"chip",children:e("types.skillsCount",{count:s.skill_ids.length})})]}),(0,a.jsxs)("div",{className:"row mt-xs",children:[(0,a.jsx)("span",{className:"muted small grow",children:e("types.usedBy",{count:l})}),(0,a.jsx)("button",{className:"btn sm",onClick:()=>S({...s}),children:e("common.edit")}),(0,a.jsx)("button",{className:"btn sm primary",onClick:()=>z(s.id),children:e("newAgent.create")})]})]},s.id)})}),f&&(0,a.jsxs)(p._s,{title:f.id?e("types.editTitle",{name:f.name||e("types.typeWord")}):e("types.newTitle"),subtitle:e("types.drawerSubtitle"),onClose:L,footer:(0,a.jsxs)(a.Fragment,{children:[f.id&&(0,a.jsxs)("button",{className:"btn danger push-r",onClick:()=>{var e;return w(null!=(e=s.find(e=>e.id===f.id))?e:null)},children:[(0,a.jsx)(r.A,{size:15}),e("common.delete")]}),(0,a.jsx)("button",{className:"btn ghost",onClick:L,children:e("common.cancel")}),(0,a.jsx)("button",{className:"btn primary",onClick:T,children:f.id?e("types.save"):e("types.create")})]}),children:[(0,a.jsx)(p.D0,{label:e("form.name"),error:A,children:(0,a.jsx)("input",{className:"input",value:f.name,onChange:e=>E("name",e.target.value),placeholder:e("types.name.placeholder"),autoFocus:!0})}),(0,a.jsx)(p.D0,{label:e("types.description"),hint:e("types.description.hint"),children:(0,a.jsx)("input",{className:"input",value:f.description,onChange:e=>E("description",e.target.value)})}),(0,a.jsx)(p.D0,{label:e("form.role"),children:(0,a.jsx)(p.$q,{value:f.role,onChange:e=>E("role",e),options:[{id:"worker",label:e("role.worker")},{id:"orchestrator",label:e("role.orchestrator")}]})}),(0,a.jsx)(p.D0,{label:e("form.provider"),children:(0,a.jsx)(p.YO,{value:f.provider,onChange:e=>M({...f,provider:e,model:""}),providers:j})}),(0,a.jsx)(p.CD,{provider:f.provider,value:f.model,onChange:e=>E("model",e)}),(0,a.jsx)(p.en,{value:f.permission,onChange:e=>E("permission",e)}),(0,a.jsx)(p.D0,{label:e("form.systemPrompt"),hint:e("types.chars",{count:f.system_prompt.length,n:(0,m._E)(f.system_prompt.length)}),children:(0,a.jsx)(i.n,{value:f.system_prompt,onChange:e=>E("system_prompt",e),minHeight:260})}),(0,a.jsx)(p.D0,{label:e("form.skills"),children:(0,a.jsx)(p.kV,{skills:k,value:f.skill_ids,loads:f.skill_loads,onChange:(e,s)=>M({...f,skill_ids:e,skill_loads:s})})})]}),C&&(0,a.jsx)(p.TM,{danger:!0,title:e("types.deleteTitle",{name:C.name}),body:e("types.deleteBody"),cancelLabel:e("types.keep"),confirmLabel:e("types.delete"),onClose:()=>w(null),onConfirm:async()=>{await o.FH.del("/types/".concat(C.id)),await v(["types","agents"]),M(null),g(e("types.deleted"))}}),q&&(0,a.jsx)(p.TM,{danger:!0,title:e("fa.unsaved.title"),body:e("fa.unsaved.body"),confirmLabel:e("fa.unsaved.discard"),cancelLabel:e("fa.unsaved.keep"),onClose:()=>H(!1),onConfirm:()=>M(null)}),_&&(0,a.jsx)(h.b,{presetTypeId:_,onClose:()=>z(null)})]})}},20555:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(74955).A)("ListOrdered",[["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 18h11",key:"11hvi2"}],["path",{d:"M10 6h11",key:"c7qv1k"}],["path",{d:"M4 10h2",key:"16xx2s"}],["path",{d:"M4 6h1v4",key:"cnovpq"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",key:"m9a95d"}]])},32021:(e,s,t)=>{Promise.resolve().then(t.bind(t,11108))},52263:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(74955).A)("List",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]])},55712:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(74955).A)("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]])},55838:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(74955).A)("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]])},71529:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(74955).A)("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]])},91833:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(74955).A)("Quote",[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]])},92947:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(74955).A)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},97356:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(74955).A)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},98148:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(74955).A)("Bold",[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]])},98938:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(74955).A)("CodeXml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]])},99579:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(74955).A)("Italic",[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]])}},e=>{e.O(0,[586,706,281,517,408,89,358],()=>e(e.s=32021)),_N_E=e.O()}]);
|