1import{d as N,r as u,j as e,G as w,R as v,bC as p,am as h}from"./index-DUpygkxg.js";import{E as C}from"./EmptyState-D0-nX078.js";import{q as R,t as S,r as A,n as I,u as E}from"./firebase-eOymXQZD.js";import{A as b}from"./activity-BquJOpHu.js";import{C as M}from"./chevron-down-Bhl8YpBs.js";import{C as $}from"./chevron-right-DTgMSD5b.js";import{C as f}from"./circle-check-rffZ2Dr7.js";const D="agentExecutions",L=async(t=200)=>{const r=R(I(N,D),A("startedAt","desc"),S(t));return(await E(r)).docs.map(a=>T(a.id,a.data()))},F=t=>{const r=new Map;for(const a of t)r.has(a.agentId)||r.set(a.agentId,[]),r.get(a.agentId).push(a);const d=[];for(const[a,x]of r.entries()){const s=x.filter(l=>l.status==="success").length,o=x.filter(l=>l.status==="error").length,c=x.length,i=x[0];d.push({agentId:a,category:i?.category??null,totalRuns:c,successCount:s,errorCount:o,successRate:c>0?s/c:0,avgDurationMs:c>0?Math.round(x.reduce((l,g)=>l+(g.durationMs||0),0)/c):0,lastRunAt:i?.startedAt??null,lastStatus:i?.status??null,lastSummary:i?.outputSummary??null})}return d.sort((a,x)=>{const s=(a.category||"")+"",o=(x.category||"")+"";return s!==o?s.localeCompare(o):a.agentId.localeCompare(x.agentId)}),d};function T(t,r){return{id:t,agentId:String(r.agentId||"unknown"),category:r.category??null,trigger:r.trigger??null,startedAt:String(r.startedAt||""),completedAt:String(r.completedAt||""),durationMs:typeof r.durationMs=="number"?r.durationMs:0,status:r.status||"success",outputSummary:r.outputSummary??null,error:r.error??null}}const O={scout:"æ¢ç´¢",planner:"è¨ç»",executor:"å®è¡",auditor:"ç£è¦",unknown:"æªåé¡"},q={scout:"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300",planner:"bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300",executor:"bg-emerald-100 dark:bg-emerald-900/30 text-emerald-700 dark:text-emerald-300",auditor:"bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-300",unknown:"bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-300"};function j(t){return t<1e3?`${t}ms`:t<6e4?`${(t/1e3).toFixed(1)}s`:`${(t/6e4).toFixed(1)}min`}function B(t){if(!t)return"-";const r=new Date(t).getTime();if(isNaN(r))return"-";const d=Date.now()-r;return d<6e4?"ãã£ãä»":d<36e5?`${Math.floor(d/6e4)}åå`:d<864e5?`${Math.floor(d/36e5)}æéå`:`${Math.floor(d/864e5)}æ¥å`}function K(){const[t,r]=u.useState([]),[d,a]=u.useState(!0),[x,s]=u.useState(null),[o,c]=u.useState(null),i=async()=>{a(!0),s(null);try{const n=await L(300);r(n)}catch(n){s(n instanceof Error?n.message:String(n))}finally{a(!1)}};u.useEffect(()=>{i()},[]);const l=u.useMemo(()=>F(t),[t]),g=u.useMemo(()=>{const n=t.length,m=t.filter(y=>y.status==="success").length,k=t.filter(y=>y.status==="error").length;return{total:n,success:m,errors:k,successRate:n>0?m/n:0}},[t]);return d?e.jsx(w,{}):e.jsxs("div",{className:"p-4 sm:p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-xl font-bold dark:text-gray-100 flex items-center gap-2",children:[e.jsx(b,{className:"w-5 h-5 text-emerald-600"}),"èªå¾ã¨ã¼ã¸ã§ã³ã"]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"scheduled/* 㨠autonomous/* ã® Cloud Functions å®è¡ç¶æ³ãç´è¿ 300 ä»¶ããéè¨ã"})]}),e.jsxs("button",{onClick:i,className:"px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg text-gray-600 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 flex items-center gap-1.5",children:[e.jsx(v,{className:"w-3.5 h-3.5"})," åèªã¿è¾¼ã¿"]})]}),x&&e.jsx("div",{className:"bg-red-50 dark:bg-red-900/30 border border-red-200 dark:border-red-700 rounded-xl p-4 mb-4 text-sm text-red-700 dark:text-red-400",children:x}),e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4 mb-6",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-900 p-4 rounded-xl border border-gray-200 dark:border-gray-700",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"ç·å®è¡åæ°"}),e.jsx("p",{className:"text-2xl font-bold text-gray-800 dark:text-gray-100",children:g.total})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-900 p-4 rounded-xl border border-gray-200 dark:border-gray-700",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"æåç"}),e.jsxs("p",{className:`text-2xl font-bold ${g.successRate>=.95?"text-emerald-600":g.successRate>=.8?"text-amber-600":"text-red-600"}`,children:[(g.successRate*100).toFixed(1),"%"]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-900 p-4 rounded-xl border border-gray-200 dark:border-gray-700",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"ã¨ã©ã¼"}),e.jsx("p",{className:"text-2xl font-bold text-red-600 dark:text-red-400",children:g.errors})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-900 p-4 rounded-xl border border-gray-200 dark:border-gray-700",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"ã¨ã¼ã¸ã§ã³ãæ°"}),e.jsx("p",{className:"text-2xl font-bold text-gray-800 dark:text-gray-100",children:l.length})]})]}),l.length===0?e.jsx(C,{icon:b,title:"ã¾ã å®è¡ãã°ãããã¾ãã",description:"ã¨ã¼ã¸ã§ã³ãã 1 å以ä¸å®è¡ãããã¨ãããã«è¡¨ç¤ºããã¾ãã"}):e.jsx("div",{className:"bg-white dark:bg-gray-900 rounded-xl border border-gray-200 dark:border-gray-700 overflow-hidden overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm min-w-[760px]",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2.5 text-left text-xs font-medium text-gray-500 dark:text-gray-400 w-8"}),e.jsx("th",{className:"px-3 py-2.5 text-left text-xs font-medium text-gray-500 dark:text-gray-400",children:"ã¨ã¼ã¸ã§ã³ã"}),e.jsx("th",{className:"px-3 py-2.5 text-left text-xs font-medium text-gray-500 dark:text-gray-400",children:"åé¡"}),e.jsx("th",{className:"px-3 py-2.5 text-right text-xs font-medium text-gray-500 dark:text-gray-400",children:"å®è¡"}),e.jsx("th",{className:"px-3 py-2.5 text-right text-xs font-medium text-gray-500 dark:text-gray-400",children:"æåç"}),e.jsx("th",{className:"px-3 py-2.5 text-right text-xs font-medium text-gray-500 dark:text-gray-400",children:"å¹³åæè¦"}),e.jsx("th",{className:"px-3 py-2.5 text-left text-xs font-medium text-gray-500 dark:text-gray-400",children:"æçµå®è¡"}),e.jsx("th",{className:"px-3 py-2.5 text-left text-xs font-medium text-gray-500 dark:text-gray-400",children:"ç´è¿ã®åºå"})]})}),e.jsx("tbody",{children:l.map(n=>e.jsx(G,{summary:n,expanded:o===n.agentId,onToggle:()=>c(o===n.agentId?null:n.agentId),history:t.filter(m=>m.agentId===n.agentId).slice(0,30)},n.agentId))})]})})]})}function G({summary:t,expanded:r,onToggle:d,history:a}){const x=t.category||"unknown";return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{onClick:d,className:"border-b border-gray-100 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/30 cursor-pointer",children:[e.jsx("td",{className:"px-3 py-2.5 text-gray-400",children:r?e.jsx(M,{className:"w-4 h-4"}):e.jsx($,{className:"w-4 h-4"})}),e.jsx("td",{className:"px-3 py-2.5 font-mono text-xs font-medium dark:text-gray-100",children:t.agentId}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full font-medium ${q[x]}`,children:O[x]})}),e.jsx("td",{className:"px-3 py-2.5 text-right dark:text-gray-200",children:t.totalRuns}),e.jsxs("td",{className:`px-3 py-2.5 text-right font-medium ${t.successRate>=.95?"text-emerald-600":t.successRate>=.8?"text-amber-600":"text-red-600"}`,children:[(t.successRate*100).toFixed(0),"%",t.errorCount>0&&e.jsxs("span",{className:"text-xs text-red-500 ml-1",children:["(",t.errorCount,")"]})]}),e.jsx("td",{className:"px-3 py-2.5 text-right text-gray-600 dark:text-gray-400 text-xs",children:j(t.avgDurationMs)}),e.jsx("td",{className:"px-3 py-2.5 text-gray-600 dark:text-gray-400 text-xs",children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.lastStatus==="success"&&e.jsx(f,{className:"w-3.5 h-3.5 text-emerald-500"}),t.lastStatus==="error"&&e.jsx(p,{className:"w-3.5 h-3.5 text-red-500"}),t.lastStatus==="skipped"&&e.jsx(h,{className:"w-3.5 h-3.5 text-gray-400"}),t.lastRunAt?B(t.lastRunAt):"-"]})}),e.jsx("td",{className:"px-3 py-2.5 text-gray-500 dark:text-gray-400 text-xs truncate max-w-xs",children:t.lastSummary??"-"})]}),r&&e.jsx("tr",{className:"bg-gray-50 dark:bg-gray-800/50",children:e.jsxs("td",{colSpan:8,className:"px-6 py-3",children:[e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-2 font-medium",children:"å±¥æ´ (æ°ããé ãæå¤§ 30 ä»¶)"}),e.jsx("div",{className:"space-y-1 max-h-72 overflow-y-auto",children:a.map(s=>e.jsxs("div",{className:"flex items-start gap-2 py-1.5 px-2 text-xs border-b border-gray-100 dark:border-gray-700 last:border-0",children:[e.jsxs("span",{className:"flex-shrink-0 w-4",children:[s.status==="success"&&e.jsx(f,{className:"w-3.5 h-3.5 text-emerald-500"}),s.status==="error"&&e.jsx(p,{className:"w-3.5 h-3.5 text-red-500"}),s.status==="skipped"&&e.jsx(h,{className:"w-3.5 h-3.5 text-gray-400"})]}),e.jsx("span",{className:"font-mono text-gray-500 dark:text-gray-400 w-44 flex-shrink-0",children:s.startedAt.replace("T"," ").slice(0,19)}),e.jsx("span",{className:"text-gray-400 w-12 flex-shrink-0",children:j(s.durationMs)}),e.jsx("span",{className:"text-gray-400 w-16 flex-shrink-0",children:s.trigger||"schedule"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300 flex-1 break-words",children:s.error?e.jsx("span",{className:"text-red-600 dark:text-red-400",children:s.error}):s.outputSummary||"-"})]},s.id))})]})})]})}export{K as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.