agent-state-machine 2.5.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/llm.js +14 -3
- package/lib/runtime/prompt.js +1 -1
- package/lib/runtime/runtime.js +14 -2
- package/lib/runtime/track-changes.js +84 -0
- package/package.json +1 -1
- package/templates/project-builder/agents/{code-writer.md → code-write.md} +18 -12
- package/templates/project-builder/agents/{assumptions-clarifier.md → intake-assumptions.md} +1 -0
- package/templates/project-builder/agents/{requirements-clarifier.md → intake-requirements.md} +1 -0
- package/templates/project-builder/agents/{scope-clarifier.md → intake-scope.md} +1 -0
- package/templates/project-builder/agents/{security-clarifier.md → intake-security.md} +1 -0
- package/templates/project-builder/agents/{roadmap-generator.md → plan-roadmap.md} +1 -0
- package/templates/project-builder/agents/{task-planner.md → plan-tasks.md} +1 -0
- package/templates/project-builder/agents/post-code-fix.md +59 -0
- package/templates/project-builder/agents/{code-reviewer.md → post-code-review.md} +10 -0
- package/templates/project-builder/agents/post-code-security.md +55 -0
- package/templates/project-builder/agents/{security-reviewer.md → pre-code-security.md} +8 -11
- package/templates/project-builder/agents/{test-planner.md → pre-code-tests.md} +1 -0
- package/templates/project-builder/agents/response-interpreter.md +1 -0
- package/templates/project-builder/agents/verify-commit-msg.md +64 -0
- package/templates/project-builder/agents/{sanity-checker.md → verify-sanity.md} +1 -12
- package/templates/project-builder/config.js +15 -4
- package/templates/project-builder/scripts/safeguard-recovery.js +40 -0
- package/templates/project-builder/scripts/validate-changes.js +61 -0
- package/templates/project-builder/scripts/workflow-helpers.js +87 -35
- package/templates/project-builder/workflow.js +231 -93
- package/vercel-server/public/remote/assets/{index-BSL55rdk.js → index-BnuR91vD.js} +1 -1
- package/vercel-server/public/remote/index.html +1 -1
- package/vercel-server/ui/src/components/ContentCard.jsx +7 -7
- package/vercel-server/ui/src/components/SettingsModal.jsx +19 -4
- package/templates/project-builder/agents/code-fixer.md +0 -50
- /package/templates/project-builder/{agents → scripts}/sanity-runner.js +0 -0
|
@@ -185,4 +185,4 @@ ${Ne}`.replace(/\n{3,}/g,`
|
|
|
185
185
|
|
|
186
186
|
`).trim();if(!Q){z=null;return}U.push({title:z.title||"Prompt",content:Q}),z=null};return M.forEach(Q=>{const Ne=Q.trim();if(/^```/.test(Ne)&&(F=!F),!Ne){z&&z.content.push("");return}if(!F&&/^---+$/.test(Ne)){B();return}const ye=F?null:/^(#{1,6})\s+(.+)$/.exec(Ne);if(ye){B(),z={title:ye[2].trim(),content:[]};return}z||(z={title:"Prompt",content:[]}),z.content.push(Q)}),B(),U},ze=(w,M)=>w?w.includes("```")?c.jsx(mr,{as:"pre",className:"text-xs sm:text-sm font-mono leading-relaxed whitespace-pre-wrap break-words overflow-auto max-h-[60vh] text-black/90 dark:text-white/90",children:As(w,M)}):c.jsx(mr,{className:"text-base sm:text-lg leading-relaxed whitespace-pre-wrap break-words text-black/80 dark:text-white/80",children:As(w,M)}):c.jsx(mr,{className:"italic text-black/40 dark:text-white/40",children:"—"}),H=w=>{if(w==null)return c.jsx("span",{className:"italic",children:"—"});if(typeof w=="boolean"){const M="inline-flex items-center rounded-full px-3 py-1 text-[11px] font-semibold tracking-[0.16em] uppercase border";return w?c.jsx("span",{className:`${M} bg-black text-white border-black dark:bg-white dark:text-black dark:border-white`,children:"Yes"}):c.jsx("span",{className:`${M} bg-white text-black border-black dark:bg-black dark:text-white dark:border-white`,children:"No"})}if(typeof w=="string"){const M=V(w);return M!==null?E(M):w.length>140||w.includes(`
|
|
187
187
|
`)?c.jsx(Wl,{children:w}):c.jsx("span",{className:"text-lg sm:text-xl font-semibold whitespace-pre-wrap break-words",children:w})}return typeof w=="object"?c.jsx(Cd,{children:JSON.stringify(w,null,2)}):c.jsx("span",{className:"text-lg sm:text-xl font-semibold break-words",children:String(w)})},Se=6;function R(w,M){if(!w.length)return c.jsx("span",{className:"italic",children:"—"});const U=w.every(B=>B===null||["string","number","boolean"].includes(typeof B)),F=w.every(B=>B&&typeof B=="object"&&!Array.isArray(B))&&w.every(B=>Object.values(B).every(Q=>Q===null||["string","number","boolean"].includes(typeof Q)));return U?c.jsx("div",{className:"space-y-3",children:w.map((B,Q)=>c.jsx("div",{className:"text-base sm:text-lg",children:H(B)},`item-${Q}`))}):F?c.jsx("div",{className:"space-y-4",children:w.map((B,Q)=>c.jsx("div",{className:"rounded-[20px] border border-black/10 dark:border-white/10 bg-black/[0.02] dark:bg-white/[0.04] p-4",children:A(Object.entries(B),M)},`item-${Q}`))}):c.jsx("div",{className:"space-y-6",children:w.map((B,Q)=>c.jsxs("div",{className:"space-y-4 rounded-[24px] border border-black/10 dark:border-white/10 bg-black/[0.02] dark:bg-white/[0.04] p-5",children:[c.jsxs("div",{className:"text-[11px] font-semibold tracking-[0.24em] uppercase text-black/50 dark:text-white/50",children:["Item ",Q+1]}),E(B,M+1)]},`item-${Q}`))})}function _(w,M){const U=Object.entries(w);return U.length?M>=Se?H(w):A(U,M):c.jsx("span",{className:"italic",children:"—"})}function E(w,M=0){return w==null||typeof w=="string"||typeof w=="number"||typeof w=="boolean"?H(w):Array.isArray(w)?R(w,M):typeof w=="object"?_(w,M):H(w)}function A(w,M=0){return c.jsx("div",{className:"space-y-6",children:w.map(([U,z])=>c.jsxs("div",{className:"grid gap-2 sm:grid-cols-[160px_1fr] sm:items-start min-w-0",children:[c.jsx("div",{className:"text-xs font-semibold text-black/50 dark:text-white/50 break-words",children:j(U)}),c.jsx("div",{className:"text-base sm:text-lg leading-relaxed break-words min-w-0",children:E(z,M+1)})]},U))})}let O=null;if(e.event==="AGENT_STARTED"){const{cleanedPrompt:w,contextTitle:M,contextData:U,contextRaw:z}=te(e.prompt||""),F=ne(w),B=s.trim(),Q=B.toLowerCase(),Ne=B?F.filter(ve=>`${ve.title}
|
|
188
|
-
${ve.content}`.toLowerCase().includes(Q)):[],ye=F.length?`${F.length} sections`:null,lu=W(z||""),au=z?`~${G(lu)}`:"";O=c.jsxs("div",{className:"space-y-10 py-6",children:[c.jsxs("div",{className:"space-y-3 text-center",children:[c.jsx(jk,{}),c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-[11px] font-semibold tracking-[0.28em] uppercase text-black/50 dark:text-white/50",children:"Agent started"}),c.jsx("h2",{className:"text-3xl sm:text-4xl font-black tracking-tight",children:e.agent}),e.model&&c.jsxs("div",{className:"inline-flex items-center gap-1.5 px-3 py-1 rounded-full bg-black/5 dark:bg-white/10 text-xs font-mono text-black/60 dark:text-white/60",children:[e.modelAlias&&c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"font-semibold",children:e.modelAlias}),c.jsx("span",{className:"text-black/30 dark:text-white/30",children:"•"})]}),_o(e.model)]})]})]}),M&&U!==null&&c.jsxs("details",{className:"group rounded-[24px] border border-black/10 dark:border-white/10 bg-black/[0.02] dark:bg-white/[0.04]",children:[c.jsxs("summary",{className:"cursor-pointer select-none px-6 py-5 flex items-center justify-between gap-6 [&::-webkit-details-marker]:hidden",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(Ul,{className:"w-4 h-4 transition-transform group-open:rotate-90"}),M==="Current Context"?c.jsx(ck,{className:"w-4 h-4","aria-hidden":"true"}):null,c.jsx("div",{className:"text-[11px] font-semibold tracking-[0.24em] uppercase text-black/60 dark:text-white/60",children:M})]}),au?c.jsx("div",{className:"text-xs font-mono text-black/50 dark:text-white/50",children:au}):null]}),typeof U=="string"?c.jsx(mr,{className:"text-base sm:text-lg leading-relaxed whitespace-pre-wrap break-words text-black/80 dark:text-white/80",children:U}):c.jsx(mr,{children:E(U)})]}),c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"text-[11px] font-semibold tracking-[0.24em] uppercase text-black/50 dark:text-white/50",children:"Prompt"}),c.jsx("button",{type:"button",onClick:()=>u(!0),className:"p-1.5 rounded-full text-black/40 dark:text-white/40 hover:text-black dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/10 transition-colors","aria-label":"Search prompt",children:c.jsx(Sd,{className:"w-4 h-4"})})]}),ye?c.jsx("div",{className:"text-xs font-mono text-black/40 dark:text-white/40",children:ye}):null]}),c.jsx("div",{className:"space-y-4",children:F.length>0?F.map((ve,cs)=>{const ds=/(^| )instructions$/i.test(ve.title.trim()),mm=cs===0||ds,uu=ve.content?ve.content.split(/\r?\n/).length:0;return c.jsxs("details",{open:mm,className:"group rounded-[24px] border border-black/10 dark:border-white/10 bg-black/[0.02] dark:bg-white/[0.04]",children:[c.jsxs("summary",{className:"cursor-pointer select-none px-6 py-5 flex items-center justify-between gap-6 [&::-webkit-details-marker]:hidden",children:[c.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[c.jsx(Ul,{className:"w-4 h-4 transition-transform group-open:rotate-90"}),c.jsx("div",{className:"text-[11px] font-semibold tracking-[0.24em] uppercase text-black/60 dark:text-white/60 break-words",children:ve.title||"Prompt"})]}),uu?c.jsxs("div",{className:"text-xs font-mono text-black/40 dark:text-white/40",children:[uu," lines"]}):null]}),ze(ve.content,"")]},`${ve.title}-${cs}`)}):c.jsx(Wl,{children:w})})]}),a?c.jsx("div",{className:"fixed inset-0 z-40 bg-white text-black dark:bg-black dark:text-white",children:c.jsx("div",{className:"h-full w-full overflow-y-auto custom-scroll px-6 sm:px-10 py-10",children:c.jsxs("div",{className:"max-w-3xl mx-auto space-y-8",children:[c.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[c.jsx("div",{className:"text-[11px] font-semibold tracking-[0.32em] uppercase text-black/50 dark:text-white/50",children:"Prompt search"}),c.jsx("button",{type:"button",onClick:()=>u(!1),className:"text-[10px] font-bold tracking-[0.2em] uppercase text-black/60 hover:text-black dark:text-white/60 dark:hover:text-white",children:"Close"})]}),c.jsxs("div",{className:"relative",children:[c.jsx(Sd,{className:"w-4 h-4 text-black/50 dark:text-white/60 absolute left-4 top-1/2 -translate-y-1/2"}),c.jsx("input",{value:s,onChange:ve=>i(ve.target.value),placeholder:"Search the prompt...",className:"w-full rounded-full border border-black/20 dark:border-white/20 bg-transparent py-4 pl-11 pr-10 text-base text-black dark:text-white placeholder:text-black/40 dark:placeholder:text-white/40 focus:outline-none focus:ring-1 focus:ring-black/30 dark:focus:ring-white/40",autoFocus:!0}),B?c.jsx("button",{type:"button",onClick:()=>i(""),"aria-label":"Clear prompt search",className:"absolute right-3 top-1/2 -translate-y-1/2 rounded-full p-1 text-black/60 hover:text-black dark:text-white/60 dark:hover:text-white",children:c.jsx(fm,{className:"w-3.5 h-3.5"})}):null]}),B?Ne.length>0?c.jsx("div",{className:"space-y-4",children:Ne.map((ve,cs)=>{const ds=ve.content?ve.content.split(/\r?\n/).length:0;return c.jsxs("div",{className:"rounded-[22px] border border-black/10 dark:border-white/15 bg-black/[0.02] dark:bg-white/5 overflow-hidden",children:[c.jsxs("div",{className:"px-5 py-4 flex items-center justify-between gap-4",children:[c.jsx("div",{className:"text-[11px] font-semibold tracking-[0.24em] uppercase text-black/70 dark:text-white/70 break-words",children:As(ve.title||"Prompt",B)}),ds?c.jsxs("div",{className:"text-xs font-mono text-black/50 dark:text-white/50",children:[ds," lines"]}):null]}),c.jsx("div",{className:"border-t border-black/10 dark:border-white/10 p-5",children:c.jsx("pre",{className:"m-0 text-xs sm:text-sm font-mono leading-relaxed whitespace-pre-wrap break-words text-black/85 dark:text-white/85",children:As(ve.content||"",B)})})]},`${ve.title}-${cs}`)})}):c.jsxs("div",{className:"rounded-[20px] border border-black/10 dark:border-white/10 bg-black/[0.02] dark:bg-white/5 p-5 text-sm text-black/60 dark:text-white/60",children:['No prompt sections match "',B,'".']}):c.jsx("div",{className:"text-sm text-black/50 dark:text-white/50",children:"Start typing to filter prompt sections."})]})})}):null]})}else if(e.event&&e.event.startsWith("WORKFLOW_")){const w=e.event.replace("WORKFLOW_","");O=c.jsxs("div",{className:"min-h-[50vh] flex flex-col items-center justify-center text-center space-y-8 py-16",children:[c.jsx("div",{className:"text-[10px] font-semibold tracking-[0.4em] uppercase text-black/50 dark:text-white/50",children:"Lifecycle status"}),c.jsxs("div",{className:"w-full max-w-5xl rounded-[28px] border border-black/10 dark:border-white/10 bg-black/[0.02] dark:bg-white/[0.04] p-10",children:[c.jsx("h2",{className:"text-4xl sm:text-6xl md:text-7xl font-black tracking-tighter leading-none uppercase",children:w}),e.error&&c.jsx("div",{className:"mt-6",children:c.jsx(Cd,{children:e.error})})]})]})}else if(e.event==="PROMPT_REQUESTED"||e.event==="INTERACTION_REQUESTED"){const M=e.event==="INTERACTION_REQUESTED"?"Interaction needed":"Question asked",U=e.question||e.prompt||"Prompt",z=e.agent||e.slug||"Agent";O=c.jsxs("div",{className:"py-10 sm:py-14 space-y-8",children:[c.jsxs("div",{className:"text-center space-y-4",children:[c.jsx(Nd,{className:"w-12 h-12"}),c.jsx("div",{className:"text-[11px] font-semibold tracking-[0.32em] uppercase text-black/50 dark:text-white/50",children:M}),c.jsxs("div",{className:"text-lg sm:text-xl font-semibold text-black/70 dark:text-white/70",children:[z," needs your input"]})]}),c.jsx("div",{className:"text-3xl sm:text-4xl md:text-5xl font-black tracking-tight leading-tight text-center text-balance",children:U}),k&&P!==null&&c.jsx("div",{className:"text-center",children:c.jsxs("div",{className:`inline-flex items-center gap-2 px-4 py-2 rounded-full ${P>0?"bg-black/5 dark:bg-white/10":"bg-black text-white dark:bg-white dark:text-black"}`,children:[c.jsx("span",{className:"text-xl",children:"⚡"}),c.jsx("span",{className:`text-sm font-semibold ${P>0?"text-black/70 dark:text-white/70":""}`,children:P>0?`Agent deciding in ${P}s...`:"Auto-selected"})]})}),y==="choice"&&p.length>0&&c.jsxs("div",{className:"space-y-3 max-w-2xl mx-auto",children:[c.jsx("div",{className:"text-[11px] font-semibold tracking-[0.24em] uppercase text-black/50 dark:text-white/50 text-center",children:"Options"}),c.jsx("div",{className:"space-y-2",children:p.map((F,B)=>c.jsxs("div",{className:`p-4 rounded-2xl border transition-all ${B===0?"border-black bg-black text-white dark:border-white dark:bg-white dark:text-black":"border-black/10 dark:border-white/10 bg-black/[0.02] dark:bg-white/[0.03]"}`,children:[c.jsx("div",{className:"flex items-center gap-3",children:c.jsxs("div",{className:`font-bold ${B===0?"":"text-black dark:text-white"}`,children:[F.label||F.key,B===0&&c.jsx("span",{className:"ml-2 text-xs font-medium px-2 py-0.5 rounded-full bg-white/20 dark:bg-black/20",children:"Recommended"})]})}),F.description&&c.jsx("div",{className:`text-sm mt-1 ${B===0?"text-white/70 dark:text-black/70":"text-black/50 dark:text-white/50"}`,children:F.description})]},F.key||B))}),e.allowCustom&&c.jsx("div",{className:"text-xs text-center text-black/40 dark:text-white/40 mt-2",children:"Custom response allowed"})]})]})}else if(e.event==="INTERACTION_AUTO_RESOLVED"||e.event==="PROMPT_AUTO_ANSWERED"){const w=e.autoSelected||"Unknown",M=e.agent||e.slug||"Agent";O=c.jsxs("div",{className:"space-y-8 py-6",children:[c.jsxs("div",{className:"space-y-4 text-center",children:[c.jsx("div",{className:"mx-auto w-14 h-14 rounded-full border-2 border-black dark:border-white bg-black dark:bg-white flex items-center justify-center",children:c.jsx("span",{className:"text-2xl",children:"⚡"})}),c.jsx("div",{className:"text-[11px] font-semibold tracking-[0.24em] uppercase text-black/50 dark:text-white/50",children:"Auto-selected"}),c.jsxs("div",{className:"text-lg sm:text-xl font-semibold text-black/70 dark:text-white/70",children:[M," decided automatically"]})]}),c.jsx("div",{className:"rounded-[24px] border-2 border-black bg-black text-white dark:border-white dark:bg-white dark:text-black p-6 text-center max-w-md mx-auto",children:c.jsx("div",{className:"text-2xl sm:text-3xl font-black tracking-tight",children:w})})]})}else if(e.event==="INTERACTION_RESOLVED"){const w=e.source==="remote"?"Remote response received.":"Response captured.",M=e.source==="remote"?"Received from remote":e.source?`Received from ${e.source}`:"Received",U=e.agent||e.slug||"Agent";O=c.jsxs("div",{className:"space-y-8 py-6",children:[c.jsxs("div",{className:"space-y-4 text-center",children:[c.jsx(Nd,{className:"w-12 h-12"}),c.jsx("div",{className:"text-[11px] font-semibold tracking-[0.24em] uppercase text-black/50 dark:text-white/50",children:"Interaction resolved"}),c.jsxs("div",{className:"text-lg sm:text-xl font-semibold text-black/70 dark:text-white/70",children:[U," received your response"]})]}),c.jsxs("div",{className:"rounded-[24px] border border-black/10 dark:border-white/10 bg-black/[0.02] dark:bg-white/[0.04] p-6 text-center",children:[c.jsx("div",{className:"text-xl sm:text-2xl font-semibold leading-relaxed text-balance",children:w}),c.jsx("div",{className:"mt-3 text-sm text-black/60 dark:text-white/60",children:M})]})]})}else if(e.event==="PROMPT_ANSWERED"||e.event==="INTERACTION_SUBMITTED"){const w=e.answer!==void 0?e.answer:e.response;O=c.jsx("div",{className:"space-y-8 py-6",children:c.jsxs("div",{className:"space-y-3",children:[c.jsx("div",{className:"text-[11px] font-semibold tracking-[0.24em] uppercase text-black/50 dark:text-white/50",children:"Response sent"}),Ek(w)]})})}else if(e.event==="AGENT_COMPLETED"){const w=e.usage&&(e.usage.inputTokens>0||e.usage.outputTokens>0);O=c.jsxs("div",{className:"space-y-10 py-6",children:[c.jsxs("div",{className:"rounded-[28px] border border-black/10 dark:border-white/10 bg-black/[0.02] dark:bg-white/[0.04] p-6 sm:p-8 text-center space-y-4",children:[c.jsx(Pk,{className:"w-12 h-12"}),c.jsx("div",{className:"text-[11px] font-semibold tracking-[0.24em] uppercase text-black/50 dark:text-white/50",children:"Agent completed"}),c.jsx("div",{className:"text-2xl sm:text-3xl font-black tracking-tight",children:e.agent||"Agent"}),w&&c.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-4 text-sm",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-black/50 dark:text-white/50",children:"In:"}),c.jsx("span",{className:"font-mono font-semibold",children:G(e.usage.inputTokens)})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-black/50 dark:text-white/50",children:"Out:"}),c.jsx("span",{className:"font-mono font-semibold",children:G(e.usage.outputTokens)})]}),e.usage.cachedTokens>0&&c.jsxs("div",{className:"flex items-center gap-2 text-black/40 dark:text-white/40",children:[c.jsx("span",{children:"Cached:"}),c.jsx("span",{className:"font-mono",children:G(e.usage.cachedTokens)})]}),e.usage.cost>0&&c.jsx("div",{className:"flex items-center gap-2 text-black/60 dark:text-white/60",children:c.jsxs("span",{className:"font-mono font-semibold",children:["$",e.usage.cost.toFixed(4)]})})]}),e.model&&c.jsx("div",{className:"inline-flex items-center gap-1.5 px-3 py-1 rounded-full bg-black/5 dark:bg-white/10 text-xs font-mono text-black/60 dark:text-white/60",children:_o(e.model)}),typeof e.attempts=="number"&&c.jsxs("div",{className:"text-sm text-black/60 dark:text-white/60",children:[e.attempts," ",e.attempts===1?"attempt":"attempts"]})]}),e.output!==void 0?c.jsxs("div",{className:"space-y-4",children:[c.jsx("div",{className:"text-[11px] font-semibold tracking-[0.24em] uppercase text-black/50 dark:text-white/50",children:"Answer"}),c.jsx("div",{className:"rounded-[24px] border border-black/10 dark:border-white/10 bg-black/[0.02] dark:bg-white/[0.04] p-6",children:E(e.output)})]}):null]})}else{const w=Object.entries(e).filter(([M])=>M!=="event"&&M!=="timestamp");O=c.jsx("div",{className:"space-y-6 py-6",children:c.jsxs("div",{className:"rounded-[24px] border border-black/10 dark:border-white/10 bg-black/[0.02] dark:bg-white/[0.04] p-6",children:[c.jsx("div",{className:"text-lg sm:text-xl font-semibold leading-relaxed text-balance",children:e.event?e.event.replace(/_/g," "):"Event"}),c.jsx("div",{className:"mt-3 text-sm text-black/60 dark:text-white/60",children:w.length>0?"Open Raw for full details.":"Open Raw for more info."})]})})}return c.jsxs("div",{className:"w-full h-full flex flex-col overflow-y-auto custom-scroll px-6 sm:px-10 lg:px-12 bg-white text-black dark:bg-black dark:text-white",children:[c.jsxs("div",{className:"content-width flex-1",children:[c.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4 pt-8 sm:pt-10 pb-6 border-b border-black/10 dark:border-white/10",children:[c.jsx("div",{className:"flex items-center gap-3",children:v.hasTokens&&c.jsxs("div",{className:"relative",children:[c.jsxs("button",{type:"button",onClick:()=>f(w=>!w),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-xs font-mono bg-black/5 dark:bg-white/10 hover:bg-black/10 dark:hover:bg-white/15 transition-colors","aria-expanded":d,"aria-label":"Toggle token stats",children:[c.jsx("span",{className:"text-black/50 dark:text-white/50",children:"↑"}),c.jsx("span",{children:Td(v.pointInTime.inputTokens)}),c.jsx("span",{className:"text-black/50 dark:text-white/50",children:"↓"}),c.jsx("span",{children:Td(v.pointInTime.outputTokens)}),c.jsx(dk,{className:`w-3 h-3 text-black/40 dark:text-white/40 transition-transform ${d?"rotate-180":""}`})]}),d&&c.jsxs("div",{className:"absolute top-full left-0 mt-2 z-10 min-w-[200px] rounded-2xl border border-black/10 dark:border-white/10 bg-white dark:bg-black shadow-xl shadow-black/10 dark:shadow-white/5 p-4 space-y-3",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"text-[10px] font-semibold tracking-[0.2em] uppercase text-black/40 dark:text-white/40",children:["Up to page ",t+1]}),c.jsxs("div",{className:"flex items-center gap-3 text-sm font-mono",children:[c.jsx("span",{className:"text-black/50 dark:text-white/50",children:"↑"}),c.jsx("span",{className:"font-semibold",children:v.pointInTime.inputTokens.toLocaleString()}),c.jsx("span",{className:"text-black/50 dark:text-white/50",children:"↓"}),c.jsx("span",{className:"font-semibold",children:v.pointInTime.outputTokens.toLocaleString()})]})]}),c.jsxs("div",{className:"border-t border-black/10 dark:border-white/10 pt-3 space-y-1",children:[c.jsx("div",{className:"text-[10px] font-semibold tracking-[0.2em] uppercase text-black/40 dark:text-white/40",children:"Session total"}),c.jsxs("div",{className:"flex items-center gap-3 text-sm font-mono",children:[c.jsx("span",{className:"text-black/50 dark:text-white/50",children:"↑"}),c.jsx("span",{className:"font-semibold",children:v.total.inputTokens.toLocaleString()}),c.jsx("span",{className:"text-black/50 dark:text-white/50",children:"↓"}),c.jsx("span",{className:"font-semibold",children:v.total.outputTokens.toLocaleString()})]})]}),c.jsx("button",{type:"button",onClick:()=>{f(!1),g(!0)},className:"w-full mt-2 pt-3 border-t border-black/10 dark:border-white/10 text-[10px] font-semibold tracking-[0.16em] uppercase text-black/50 dark:text-white/50 hover:text-black dark:hover:text-white transition-colors text-center",children:"View details"})]})]})}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(bk,{open:o,onToggle:()=>l(w=>!w)}),c.jsx(hm,{text:e})]})]}),c.jsx("div",{className:"pt-6",children:c.jsx("div",{className:"text-xs font-mono text-black/50 dark:text-white/50",children:r})}),o?c.jsx("pre",{className:"raw-json-block",children:pm(e)}):O]}),h&&c.jsx("div",{className:"fixed inset-0 z-50 bg-white text-black dark:bg-black dark:text-white",children:c.jsx("div",{className:"h-full w-full overflow-y-auto custom-scroll px-6 sm:px-10 py-10",children:c.jsxs("div",{className:"max-w-4xl mx-auto space-y-8",children:[c.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-[11px] font-semibold tracking-[0.32em] uppercase text-black/50 dark:text-white/50",children:"Token Usage Details"}),c.jsxs("div",{className:"text-2xl font-bold",children:[v.agentBreakdown.length," agent ",v.agentBreakdown.length===1?"call":"calls"]})]}),c.jsx("button",{type:"button",onClick:()=>g(!1),className:"text-[10px] font-bold tracking-[0.2em] uppercase text-black/60 hover:text-black dark:text-white/60 dark:hover:text-white",children:"Close"})]}),c.jsxs("div",{className:"rounded-[24px] border border-black/10 dark:border-white/10 bg-black/[0.02] dark:bg-white/[0.04] p-6",children:[c.jsx("div",{className:"text-[10px] font-semibold tracking-[0.2em] uppercase text-black/40 dark:text-white/40 mb-4",children:"Session Totals"}),c.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-6",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-xs text-black/50 dark:text-white/50",children:"Input Tokens"}),c.jsx("div",{className:"text-xl font-mono font-bold",children:v.total.inputTokens.toLocaleString()})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-xs text-black/50 dark:text-white/50",children:"Output Tokens"}),c.jsx("div",{className:"text-xl font-mono font-bold",children:v.total.outputTokens.toLocaleString()})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-xs text-black/50 dark:text-white/50",children:"Total Tokens"}),c.jsx("div",{className:"text-xl font-mono font-bold",children:(v.total.inputTokens+v.total.outputTokens).toLocaleString()})]}),v.total.cost>0&&c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-xs text-black/50 dark:text-white/50",children:"Total Cost"}),c.jsxs("div",{className:"text-xl font-mono font-bold",children:["$",v.total.cost.toFixed(4)]})]})]})]}),c.jsxs("div",{className:"space-y-4",children:[c.jsx("div",{className:"text-[10px] font-semibold tracking-[0.2em] uppercase text-black/40 dark:text-white/40",children:"Per-Agent Breakdown"}),c.jsx("div",{className:"space-y-3",children:v.agentBreakdown.map((w,M)=>c.jsxs("div",{className:"rounded-[20px] border border-black/10 dark:border-white/10 bg-black/[0.02] dark:bg-white/[0.04] p-5",children:[c.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4 mb-4",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-lg font-bold",children:w.agent}),c.jsxs("div",{className:"flex items-center gap-2",children:[w.model&&c.jsx("span",{className:"inline-flex px-2 py-0.5 rounded-full bg-black/5 dark:bg-white/10 text-xs font-mono text-black/60 dark:text-white/60",children:_o(w.model)}),c.jsx("span",{className:"text-xs text-black/40 dark:text-white/40",children:new Date(w.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})})]})]}),w.cost>0&&c.jsx("div",{className:"text-right",children:c.jsxs("div",{className:"text-lg font-mono font-bold",children:["$",w.cost.toFixed(4)]})})]}),c.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4 text-sm",children:[c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"text-xs text-black/40 dark:text-white/40",children:"Input"}),c.jsx("div",{className:"font-mono font-semibold",children:w.inputTokens.toLocaleString()})]}),c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"text-xs text-black/40 dark:text-white/40",children:"Output"}),c.jsx("div",{className:"font-mono font-semibold",children:w.outputTokens.toLocaleString()})]}),w.cachedTokens>0&&c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"text-xs text-black/40 dark:text-white/40",children:"Cached"}),c.jsx("div",{className:"font-mono font-semibold text-black/60 dark:text-white/60",children:w.cachedTokens.toLocaleString()})]}),c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"text-xs text-black/40 dark:text-white/40",children:"Total"}),c.jsx("div",{className:"font-mono font-semibold",children:(w.inputTokens+w.outputTokens).toLocaleString()})]})]})]},`${w.agent}-${M}`))})]}),v.agentBreakdown.length===0&&c.jsx("div",{className:"rounded-[20px] border border-black/10 dark:border-white/10 bg-black/[0.02] dark:bg-white/[0.04] p-6 text-center text-black/50 dark:text-white/50",children:"No token usage data available yet."})]})})})]})}const Mk=e=>{const t="w-3.5 h-3.5 text-black/70 dark:text-white/70";if(!e)return c.jsx($l,{className:`${t} opacity-40`});const n=e.toUpperCase();return n.includes("STARTED")||n.includes("START")?c.jsx(dm,{className:`${t} opacity-70`}):n.includes("SUBMITTED")||n.includes("ANSWERED")||n.includes("SUCCESS")||n.includes("RESOLVED")?c.jsx(pk,{className:`${t} opacity-80`}):n.includes("REQUESTED")||n.includes("REQUEST")?c.jsx(wk,{className:`${t} opacity-60`}):n.includes("ERROR")||n.includes("FAILED")?c.jsx(hk,{className:`${t} opacity-90`}):c.jsx($l,{className:`${t} opacity-40`})},Rk=e=>{const t=e.question||e.answer||e.prompt||e.error||e.status||e.message,n=e.slug||(e.event&&e.event.startsWith("WORKFLOW_")?e.event.replace("WORKFLOW_",""):null);return!t&&!n?e.event||"Unknown Event":c.jsxs("div",{className:"flex flex-col gap-0.5",children:[n&&c.jsx("span",{className:"text-black/60 dark:text-white/60 font-medium text-[10px] tracking-[0.24em] uppercase",children:n}),t&&c.jsx("span",{className:"opacity-70 truncate max-w-md",children:typeof t=="string"?t:JSON.stringify(t)})]})};function Ak({history:e,onJump:t}){return c.jsx("div",{className:"w-full h-full flex flex-col overflow-hidden bg-bg",children:c.jsx("div",{className:"flex-1 overflow-y-auto custom-scroll px-6 sm:px-8 lg:px-10 py-20",children:c.jsx("div",{className:"max-w-4xl mx-auto space-y-1",children:e.length===0?c.jsxs("div",{className:"h-[40vh] flex flex-col items-center justify-center opacity-20 space-y-4",children:[c.jsx($l,{className:"w-12 h-12"}),c.jsx("div",{className:"text-xs font-bold tracking-[0.4em] uppercase",children:"No events yet"})]}):e.map((n,r)=>{var i;const s=new Date(n.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});return c.jsxs("button",{onClick:()=>t(r),className:"w-full text-left group flex items-start gap-6 p-5 rounded-2xl transition-all border border-black/10 dark:border-white/10 hover:bg-black/[0.03] dark:hover:bg-white/[0.04]",children:[c.jsx("div",{className:"flex-shrink-0 w-20 pt-1",children:c.jsx("span",{className:"text-[10px] font-mono font-medium opacity-30 group-hover:opacity-60 transition-opacity",children:s})}),c.jsx("div",{className:"flex-shrink-0 pt-0.5",children:Mk(n.event)}),c.jsxs("div",{className:"flex-1 min-w-0 flex flex-col gap-1",children:[c.jsx("div",{className:"text-[10px] font-semibold tracking-[0.28em] uppercase opacity-40 group-hover:opacity-70 transition-opacity",children:((i=n.event)==null?void 0:i.replace(/_/g," "))||"EVENT"}),c.jsx("div",{className:"text-sm leading-relaxed truncate group-hover:text-black dark:group-hover:text-white transition-colors",children:Rk(n)})]})]},r)})})})})}function Dk({page:e,total:t,onNext:n,onPrev:r,onJump:s,hasNew:i,onJumpToLatest:o,className:l=""}){const[a,u]=S.useState(e+1);S.useEffect(()=>u(e+1),[e]);const d=f=>{const{value:h}=f.target;u(h);const g=parseInt(h,10);!Number.isNaN(g)&&g>=1&&g<=t&&s(g-1)};return c.jsx("footer",{className:`nav-footer transition-opacity duration-300 ${l}`,children:c.jsxs("div",{className:"footer-control",children:[c.jsx("button",{onClick:r,disabled:e===0,className:"tooltip p-1 hover:text-black dark:hover:text-white disabled:opacity-0 transition-all pointer-events-auto","data-tooltip":"Previous","aria-label":"Previous event",children:c.jsx(fk,{className:"w-5 h-5"})}),c.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono font-bold tracking-widest opacity-60",children:[c.jsx("input",{type:"number",value:a,onChange:d,className:"jumper-input",min:"1",max:t}),c.jsx("span",{className:"opacity-20",children:"/"}),c.jsx("span",{children:t})]}),c.jsx("button",{onClick:n,disabled:e===t-1,className:"tooltip p-1 hover:text-black dark:hover:text-white disabled:opacity-0 transition-all pointer-events-auto","data-tooltip":"Next","aria-label":"Next event",children:c.jsx(Ul,{className:"w-5 h-5"})}),i?c.jsx("button",{onClick:o,className:"tooltip px-3 py-1 rounded-full text-[10px] font-bold tracking-[0.2em] uppercase bg-black text-white dark:bg-white dark:text-black shadow-[0_10px_30px_rgba(0,0,0,0.2)] dark:shadow-[0_10px_30px_rgba(255,255,255,0.1)] hover:scale-[1.02] transition-transform","data-tooltip":"Latest","aria-label":"Jump to latest event",children:"New"}):null]})})}function Vk({workflowName:e,status:t,theme:n,toggleTheme:r,viewMode:s,setViewMode:i,history:o,fullAuto:l,onToggleFullAuto:a,onOpenSettings:u,configDisabled:d}){const f=t==="connected";return c.jsxs("header",{className:"fixed top-0 inset-x-0 h-20 px-6 sm:px-10 lg:px-12 flex items-center justify-between z-50 bg-bg/80 backdrop-blur-3xl",children:[c.jsxs("div",{className:"flex items-center gap-4",children:[c.jsx("div",{className:`w-2.5 h-2.5 rounded-full border ${f?"bg-black border-black dark:bg-white dark:border-white":"bg-transparent border-black/30 dark:border-white/30"}`,"aria-hidden":"true"}),c.jsx("span",{className:"font-semibold text-[10px] tracking-[0.32em] uppercase text-black/50 dark:text-white/50 truncate max-w-[300px]",children:e||"Workflow"})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("button",{onClick:a,disabled:d,className:`tooltip w-10 h-10 flex items-center justify-center rounded-full transition-colors ${d?"opacity-30 cursor-not-allowed":"hover:bg-black/5 dark:hover:bg-white/10"}`,"data-tooltip":l?"Pause auto":"Enable auto","aria-label":l?"Disable full-auto mode":"Enable full-auto mode",children:l?c.jsx(xk,{className:"w-5 h-5 opacity-60"}):c.jsx(dm,{className:"w-5 h-5 opacity-40 hover:opacity-100"})}),c.jsx("button",{onClick:u,className:"tooltip w-10 h-10 flex items-center justify-center rounded-full hover:bg-black/5 dark:hover:bg-white/10 transition-colors","data-tooltip":"Settings","aria-label":"Open settings",children:c.jsx(Sk,{className:"w-5 h-5 opacity-40 hover:opacity-100"})}),c.jsx(hm,{text:o||[],label:"Copy full history",disabled:!o||o.length===0}),c.jsx("button",{onClick:()=>i(s==="present"?"log":"present"),className:"tooltip w-10 h-10 flex items-center justify-center rounded-full hover:bg-black/5 dark:hover:bg-white/10 transition-colors","data-tooltip":s==="present"?"Log view":"Present view","aria-label":s==="present"?"Switch to Log view":"Switch to Presentation view",children:s==="present"?c.jsx(gk,{className:"w-5 h-5 opacity-40 hover:opacity-100"}):c.jsx(kk,{className:"w-5 h-5 opacity-40 hover:opacity-100"})}),c.jsx("button",{onClick:r,className:"tooltip w-10 h-10 flex items-center justify-center rounded-full hover:bg-black/5 dark:hover:bg-white/10 transition-colors","data-tooltip":n==="dark"?"Light theme":"Dark theme","aria-label":n==="dark"?"Switch to Light theme":"Switch to Dark theme",children:n==="dark"?c.jsx(Ck,{className:"w-5 h-5 opacity-40 hover:opacity-100"}):c.jsx(vk,{className:"w-5 h-5 opacity-40 hover:opacity-100"})})]})]})}function _k({interaction:e,onSubmit:t,disabled:n}){const{prompt:r,question:s,options:i=[],multiSelect:o,allowCustom:l,fullAuto:a,autoSelectDelay:u=20,timestamp:d}=e,[f,h]=S.useState(o?[]:null),[g,v]=S.useState(""),[x,C]=S.useState(!1),[y,p]=S.useState(0),m=S.useMemo(()=>i||[],[i]),k=r||s||"Choose an option.",N=S.useMemo(()=>{if(!a||!d)return null;const L=new Date(d).getTime(),V=Math.floor((Date.now()-L)/1e3);return u-V},[a,d,u,y]);S.useEffect(()=>{if(!a)return;const L=setInterval(()=>p(V=>V+1),1e3);return()=>clearInterval(L)},[a]);const T=L=>{o?(h(V=>V.includes(L)?V.filter(W=>W!==L):[...V,L]),C(!1)):(h(L),C(!1))},P=()=>{if(x&&g.trim()){t({isCustom:!0,customText:g.trim(),raw:g.trim()});return}if(o&&f.length>0){t({selectedKeys:f,raw:f.join(", ")});return}f&&t({selectedKey:f,raw:String(f)})},j=x?!!g.trim():o?f.length>0:!!f;return c.jsxs("div",{className:"w-full h-full flex flex-col items-stretch overflow-hidden",children:[c.jsxs("div",{className:"flex-1 overflow-y-auto custom-scroll px-6 py-12 space-y-8 flex flex-col items-center",children:[c.jsxs("div",{className:"space-y-4 shrink-0",children:[c.jsx("div",{className:"w-16 h-16 rounded-3xl bg-black text-white dark:bg-white dark:text-black flex items-center justify-center mx-auto shadow-2xl shadow-black/20 dark:shadow-white/10",children:c.jsx(us,{className:"w-8 h-8"})}),c.jsx("h3",{className:"text-3xl sm:text-4xl font-extrabold tracking-tight text-fg pt-4 text-center",children:"Choose an option."})]}),c.jsx("div",{className:"text-lg sm:text-xl font-medium text-fg/70 text-center max-w-2xl whitespace-pre-wrap break-words",children:k}),a&&N!==null&&c.jsx("div",{className:"text-center",children:c.jsxs("div",{className:`inline-flex items-center gap-2 px-4 py-2 rounded-full ${N>0?"bg-yellow-500 text-black animate-pulse":"bg-black text-white dark:bg-white dark:text-black"}`,children:[c.jsx("span",{className:"text-xl",children:"⚡"}),c.jsx("span",{className:"text-sm font-bold",children:N>0?`Agent deciding in ${N}s...`:"Auto-selecting recommended option..."})]})}),c.jsxs("div",{className:"w-full max-w-2xl space-y-3",children:[m.map((L,V)=>{const W=o?f.includes(L.key):f===L.key,G=W?"text-white dark:text-black":"text-black dark:text-white",te=W?"text-white/70 dark:text-black/70":"text-black/50 dark:text-white/50";return c.jsx("button",{onClick:()=>T(L.key),disabled:n,type:"button",className:`w-full p-6 rounded-2xl border-2 transition-all text-left ${W?"border-black bg-black text-white dark:border-white dark:bg-white dark:text-black":"border-black/10 dark:border-white/10 hover:border-black/30 dark:hover:border-white/30 bg-black/[0.02] dark:bg-white/[0.03]"}`,children:c.jsxs("div",{className:"flex items-center gap-4",children:[c.jsx("div",{className:`w-6 h-6 rounded-full border-2 flex items-center justify-center ${W?"border-black bg-black text-white dark:border-white dark:bg-white dark:text-black":"border-black/30 dark:border-white/30"}`,children:W&&c.jsx(cm,{className:"w-4 h-4"})}),c.jsxs("div",{className:"flex-1",children:[c.jsxs("div",{className:`font-bold text-lg break-words flex flex-wrap items-center gap-2 ${G}`,children:[c.jsx("span",{className:"break-words",children:L.label||L.key}),V===0&&c.jsx("span",{className:`ml-2 text-xs font-medium px-2 py-0.5 rounded-full ${W?"bg-white/20 dark:bg-black/20":"bg-black/10 dark:bg-white/10"}`,children:"Recommended"})]}),L.description&&c.jsx("div",{className:`text-sm mt-1 break-words ${te}`,children:L.description})]})]})},L.key)}),l&&c.jsxs("button",{onClick:()=>{C(!0),h(o?[]:null)},disabled:n,type:"button",className:`w-full p-6 rounded-2xl border-2 transition-all text-left ${x?"border-black bg-black text-white dark:border-white dark:bg-white dark:text-black":"border-black/10 dark:border-white/10 hover:border-black/30 dark:hover:border-white/30 bg-black/[0.02] dark:bg-white/[0.03]"}`,children:[c.jsx("div",{className:`font-bold text-lg break-words ${x?"text-white dark:text-black":"text-black dark:text-white"}`,children:"Other"}),c.jsx("div",{className:`text-sm mt-1 break-words ${x?"text-white/70 dark:text-black/70":"text-black/50 dark:text-white/50"}`,children:"Provide a custom response"})]}),x&&c.jsx("textarea",{value:g,onChange:L=>v(L.target.value),placeholder:"Type your response...",className:"w-full h-32 p-6 rounded-2xl bg-black/[0.02] dark:bg-white/[0.03] border-2 border-black/20 dark:border-white/20 focus:border-black dark:focus:border-white focus:outline-none text-lg"})]})]}),c.jsx("div",{className:"p-4 flex justify-center bg-gradient-to-t from-bg via-bg to-transparent shrink-0 border-t border-black/10 dark:border-white/10",children:c.jsx("button",{onClick:P,disabled:n||!j,className:"px-12 py-6 bg-fg text-bg rounded-full font-bold text-xl hover:scale-105 active:scale-95 transition-all disabled:opacity-30 shadow-2xl",children:"Continue"})})]})}function Ok({interaction:e,onSubmit:t,disabled:n}){const{prompt:r,question:s,confirmLabel:i="Confirm",cancelLabel:o="Cancel",context:l}=e;return c.jsxs("div",{className:"w-full h-full flex flex-col items-stretch overflow-hidden",children:[c.jsxs("div",{className:"flex-1 overflow-y-auto custom-scroll px-6 py-12 space-y-8 flex flex-col items-center justify-center",children:[c.jsxs("div",{className:"space-y-4",children:[c.jsx("div",{className:"w-16 h-16 rounded-3xl bg-black text-white dark:bg-white dark:text-black flex items-center justify-center mx-auto shadow-2xl shadow-black/20 dark:shadow-white/10",children:c.jsx(us,{className:"w-8 h-8"})}),c.jsx("h3",{className:"text-3xl sm:text-4xl font-extrabold tracking-tight text-fg pt-4 text-center",children:"Confirm action."})]}),c.jsx("div",{className:"text-lg sm:text-xl font-medium text-fg/70 text-center max-w-2xl whitespace-pre-wrap break-words",children:r||s||"Please confirm."}),(l==null?void 0:l.documentPath)&&c.jsxs("div",{className:"text-sm text-fg/40 text-center",children:["Review: ",c.jsx("code",{className:"bg-black/10 dark:bg-white/10 px-2 py-1 rounded",children:l.documentPath})]})]}),c.jsxs("div",{className:"p-4 flex justify-center gap-4 bg-gradient-to-t from-bg via-bg to-transparent shrink-0 border-t border-black/10 dark:border-white/10",children:[c.jsx("button",{onClick:()=>t({confirmed:!1,raw:o}),disabled:n,className:"px-12 py-6 border border-black/20 dark:border-white/20 text-fg rounded-full font-bold text-xl hover:bg-black/5 dark:hover:bg-white/10 transition-all disabled:opacity-30",children:o}),c.jsx("button",{onClick:()=>t({confirmed:!0,raw:i}),disabled:n,className:"px-12 py-6 bg-fg text-bg rounded-full font-bold text-xl hover:scale-105 active:scale-95 transition-all disabled:opacity-30 shadow-2xl shadow-black/20 dark:shadow-white/10",children:i})]})]})}function Ik({interaction:e,onSubmit:t,disabled:n}){const{prompt:r,question:s,placeholder:i,validation:o}=e,[l,a]=S.useState(""),[u,d]=S.useState(null),f=S.useMemo(()=>o||{},[o]),h=v=>f.minLength&&v.length<f.minLength?`Minimum ${f.minLength} characters required`:f.maxLength&&v.length>f.maxLength?`Maximum ${f.maxLength} characters allowed`:f.pattern&&!new RegExp(f.pattern).test(v)?"Invalid format":null,g=()=>{const v=l.trim(),x=h(v);if(x){d(x);return}t({text:v,raw:v})};return c.jsxs("div",{className:"w-full h-full flex flex-col items-stretch overflow-hidden",children:[c.jsxs("div",{className:"flex-1 overflow-y-auto custom-scroll px-6 py-12 space-y-8 flex flex-col items-center",children:[c.jsxs("div",{className:"space-y-4 shrink-0",children:[c.jsx("div",{className:"w-16 h-16 rounded-3xl bg-black text-white dark:bg-white dark:text-black flex items-center justify-center mx-auto shadow-2xl shadow-black/20 dark:shadow-white/10",children:c.jsx(us,{className:"w-8 h-8"})}),c.jsx("h3",{className:"text-3xl sm:text-4xl font-extrabold tracking-tight text-fg pt-4 text-center",children:"Action required."})]}),c.jsxs("div",{className:"w-full max-w-2xl space-y-4",children:[c.jsx("div",{className:"text-lg sm:text-xl font-medium text-fg/70 text-center whitespace-pre-wrap break-words",children:r||s||"Provide your response."}),c.jsx("textarea",{value:l,onChange:v=>{a(v.target.value),d(null)},disabled:n,placeholder:i||"Your response...",className:`w-full h-64 p-8 rounded-[32px] bg-black/[0.02] dark:bg-white/[0.03] border-2 ${u?"border-black dark:border-white":"border-transparent"} focus:border-black dark:focus:border-white focus:outline-none text-xl sm:text-2xl font-medium transition-all text-center placeholder:opacity-20`}),u&&c.jsx("div",{className:"text-black dark:text-white text-center text-sm font-semibold",children:u})]})]}),c.jsx("div",{className:"p-4 flex justify-center bg-gradient-to-t from-bg via-bg to-transparent shrink-0 border-t border-black/10 dark:border-white/10",children:c.jsx("button",{onClick:g,disabled:n||!l.trim(),className:"px-12 py-6 bg-fg text-bg rounded-full font-bold text-xl hover:scale-105 active:scale-95 transition-all disabled:opacity-30 shadow-2xl",children:"Submit Response"})})]})}function Fk({interaction:e,onSubmit:t,disabled:n}){const r=(e==null?void 0:e.type)||"text",s=i=>{t(e.slug,e.targetKey,i)};switch(r){case"choice":return c.jsx(_k,{interaction:e,onSubmit:s,disabled:n},e.slug);case"confirm":return c.jsx(Ok,{interaction:e,onSubmit:s,disabled:n},e.slug);case"text":default:return c.jsx(Ik,{interaction:e,onSubmit:s,disabled:n},e.slug)}}function zk({submission:e}){const t=e!=null&&e.slug?`Waiting for the CLI to receive ${e.slug} and log the next event.`:"Waiting for the CLI to receive the response and log the next event.";return c.jsx("div",{className:"w-full h-full flex items-center justify-center px-6 py-12 bg-white text-black dark:bg-black dark:text-white",children:c.jsxs("div",{className:"content-width w-full flex flex-col items-center text-center gap-6",children:[c.jsxs("div",{className:"relative",children:[c.jsx("div",{className:"absolute -inset-4 rounded-[36px] bg-black/10 dark:bg-white/10 blur-2xl opacity-60","aria-hidden":"true"}),c.jsx("div",{className:"relative w-20 h-20 rounded-[28px] border border-black/10 dark:border-white/10 bg-black/[0.03] dark:bg-white/[0.03] flex items-center justify-center shadow-2xl shadow-black/20 dark:shadow-white/10",children:c.jsx(yk,{className:"w-9 h-9 text-black dark:text-white animate-spin"})})]}),c.jsxs("div",{className:"space-y-3",children:[c.jsx("div",{className:"text-4xl font-black tracking-tight",children:"Sending response"}),c.jsx("div",{className:"text-lg font-medium text-black/60 dark:text-white/60 max-w-xl break-words",children:t}),c.jsx("div",{className:"text-[10px] font-bold tracking-[0.35em] uppercase opacity-30",children:"Keep this tab open"})]})]})})}function Bk({isOpen:e,onClose:t,fullAuto:n,onToggleFullAuto:r,autoSelectDelay:s,onDelayChange:i,onStop:o,disabled:l}){const[a,u]=S.useState(!1);if(!e)return null;const d=()=>{a?(o(),u(!1),t()):u(!0)},f=h=>{h.target===h.currentTarget&&(u(!1),t())};return c.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",onClick:f,children:c.jsxs("div",{className:"bg-white dark:bg-black border border-black/10 dark:border-white/10 rounded-3xl p-8 w-[90vw] max-w-md shadow-2xl",children:[c.jsxs("div",{className:"flex justify-between items-center mb-6",children:[c.jsx("h2",{className:"text-xl font-bold",children:"Settings"}),c.jsx("button",{onClick:()=>{u(!1),t()},className:"p-2 hover:bg-black/5 dark:hover:bg-white/10 rounded-full transition-colors","aria-label":"Close settings",children:c.jsx(fm,{className:"w-5 h-5"})})]}),c.jsxs("div",{className:"flex items-center justify-between py-4 border-b border-black/10 dark:border-white/10",children:[c.jsxs("div",{children:[c.jsx("div",{className:"font-semibold",children:"Full-Auto Mode"}),c.jsx("div",{className:"text-sm text-black/50 dark:text-white/50",children:"Auto-select recommended options"})]}),c.jsx("button",{onClick:r,disabled:l,className:`w-12 h-7 rounded-full transition-colors relative ${n?"bg-black dark:bg-white":"bg-black/20 dark:bg-white/20"} ${l?"opacity-50 cursor-not-allowed":""}`,"aria-pressed":n,"aria-label":"Toggle full-auto mode",children:c.jsx("div",{className:`absolute top-1 w-5 h-5 rounded-full bg-white dark:bg-black transition-transform ${n?"left-6":"left-1"}`})})]}),c.jsxs("div",{className:"flex items-center justify-between py-4 border-b border-black/10 dark:border-white/10",children:[c.jsxs("div",{children:[c.jsx("div",{className:"font-semibold",children:"Countdown Delay"}),c.jsx("div",{className:"text-sm text-black/50 dark:text-white/50",children:"Seconds before auto-select"})]}),c.jsx("input",{type:"number",value:s,onChange:h=>{const g=parseInt(h.target.value,10);!isNaN(g)&&g>=1&&g<=120&&i(g)},min:1,max:120,disabled:l,className:"w-20 p-2 text-center rounded-xl border border-black/20 dark:border-white/20 bg-transparent disabled:opacity-50"})]}),c.jsxs("div",{className:"mt-6",children:[c.jsxs("button",{onClick:d,disabled:l,className:`w-full py-4 rounded-2xl font-bold flex items-center justify-center gap-2 transition-colors ${a?"bg-red-600 text-white hover:bg-red-700":"bg-red-500/10 text-red-500 hover:bg-red-500/20"} ${l?"opacity-50 cursor-not-allowed":""}`,children:[c.jsx(Nk,{className:"w-5 h-5"}),a?"Click again to confirm":"Stop Workflow"]}),a&&c.jsx("div",{className:"text-center text-sm text-black/50 dark:text-white/50 mt-2",children:"This will terminate the CLI process"})]})]})})}function Uk(){const[e,t]=S.useState([]),[n,r]=S.useState(0),[s,i]=S.useState("connecting"),[o,l]=S.useState("..."),[a,u]=S.useState("light"),[d,f]=S.useState("present"),[h,g]=S.useState(null),[v,x]=S.useState(!1),[C,y]=S.useState(null),[p,m]=S.useState({fullAuto:!1,autoSelectDelay:20}),[k,N]=S.useState(!1);S.useEffect(()=>{const E=localStorage.getItem("rf_theme")||(window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");u(E);const A=localStorage.getItem("rf_view")||"present";f(A)},[]),S.useEffect(()=>{document.documentElement.classList.toggle("dark",a==="dark"),localStorage.setItem("rf_theme",a)},[a]),S.useEffect(()=>{localStorage.setItem("rf_view",d)},[d]);const T=window.SESSION_TOKEN==="{{SESSION_TOKEN}}"?null:window.SESSION_TOKEN,P=T?`/api/history/${T}`:"/api/history",j=T?`/api/events/${T}`:"/api/events",L=T?`/api/submit/${T}`:"/api/submit",V=T?`/api/config/${T}`:"/api/config",W=async()=>{try{const A=await(await fetch(P)).json();if(A.entries){const O=[...A.entries].reverse();t(M=>(M.length===0&&O.length>0&&r(O.length-1),O));const w=O[O.length-1];w&&(w.event==="INTERACTION_REQUESTED"||w.event==="PROMPT_REQUESTED")?g(w):g(null)}A.workflowName&&l(A.workflowName),A.config&&m(A.config),i("connected")}catch{i("disconnected")}},G=async E=>{try{(await fetch(V,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(E)})).ok&&m(O=>({...O,...E}))}catch(A){console.error("Failed to update config:",A)}},te=S.useRef(0);S.useEffect(()=>{e.length>te.current&&(te.current===0&&e.length>0?(r(e.length-1),x(!1)):n<e.length-1&&x(!0)),te.current=e.length},[e.length,n]),S.useEffect(()=>{if(!C||e.length===0)return;const E=e[e.length-1];if(e.length!==C.historyLength||E!=null&&E.timestamp&&E.timestamp!==C.lastEventTimestamp){if((E==null?void 0:E.event)==="INTERACTION_SUBMITTED"){y(O=>O&&{...O,historyLength:e.length,lastEventTimestamp:(E==null?void 0:E.timestamp)||O.lastEventTimestamp});return}y(null),r(e.length-1)}},[e,C]),S.useEffect(()=>{n===e.length-1&&x(!1)},[n,e.length]),S.useEffect(()=>{W();const E=setInterval(W,3e3),A=new EventSource(j);return A.onmessage=O=>{O.data==="update"&&W()},()=>{clearInterval(E),A.close()}},[]);const ne=()=>r(E=>Math.min(e.length-1,E+1)),ze=()=>r(E=>Math.max(0,E-1));S.useEffect(()=>{const E=A=>{(A.target.tagName==="TEXTAREA"||A.target.tagName==="INPUT"&&A.target.type==="number")&&A.target.className!=="jumper-input"||(A.key==="ArrowRight"&&ne(),A.key==="ArrowLeft"&&ze())};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[e.length]);const H=e[n],Se=H&&(H.event==="INTERACTION_REQUESTED"||H.event==="PROMPT_REQUESTED"),R=h&&Se&&H.slug===h.slug,_=!!C;return c.jsxs("div",{className:"w-full h-[100dvh] flex flex-col relative overflow-hidden bg-bg",children:[c.jsx(Vk,{workflowName:o,status:s,theme:a,toggleTheme:()=>u(E=>E==="dark"?"light":"dark"),viewMode:d,setViewMode:f,history:e,fullAuto:p.fullAuto,onToggleFullAuto:()=>G({fullAuto:!p.fullAuto}),onOpenSettings:()=>N(!0),configDisabled:s!=="connected"}),c.jsx("main",{className:"main-stage overflow-hidden",children:d==="log"?c.jsx(Ak,{history:e,onJump:E=>{r(E),f("present")}}):c.jsx(ok,{mode:"wait",children:c.jsx(q1.div,{initial:{opacity:0,scale:.99,filter:"blur(4px)"},animate:{opacity:1,scale:1,filter:"blur(0px)"},exit:{opacity:0,scale:1.01,filter:"blur(4px)"},transition:{duration:.3,ease:[.16,1,.3,1]},className:"w-full h-full",children:_?c.jsx(zk,{submission:C}):R?c.jsx("div",{className:"content-width h-full",children:c.jsx(Fk,{interaction:h,onSubmit:async(E,A,O)=>{const w=e[e.length-1];y({slug:E,targetKey:A,historyLength:e.length,lastEventTimestamp:(w==null?void 0:w.timestamp)||null});try{const M=await fetch(L,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:E,targetKey:A,response:O})});if(!M.ok)throw new Error(`Submit failed with ${M.status}`)}catch{y(null)}finally{setTimeout(W,1e3)}},disabled:s==="disconnected"||_})}):c.jsx(Lk,{item:H,pageIndex:n,history:e})},n)})}),c.jsx(Dk,{page:n,total:e.length,onNext:ne,onPrev:ze,onJump:r,hasNew:v,onJumpToLatest:()=>r(e.length-1),className:d==="log"?"opacity-0 pointer-events-none":"opacity-100"}),c.jsx(Bk,{isOpen:k,onClose:()=>N(!1),fullAuto:p.fullAuto,onToggleFullAuto:()=>G({fullAuto:!p.fullAuto}),autoSelectDelay:p.autoSelectDelay,onDelayChange:E=>G({autoSelectDelay:E}),onStop:()=>G({stop:!0}),disabled:s!=="connected"})]})}const $k=zh(document.getElementById("root"));$k.render(c.jsx(Uk,{}));
|
|
188
|
+
${ve.content}`.toLowerCase().includes(Q)):[],ye=F.length?`${F.length} sections`:null,lu=W(e.prompt||""),au=e.prompt?`~${G(lu)}`:"";O=c.jsxs("div",{className:"space-y-10 py-6",children:[c.jsxs("div",{className:"space-y-3 text-center",children:[c.jsx(jk,{}),c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-[11px] font-semibold tracking-[0.28em] uppercase text-black/50 dark:text-white/50",children:"Agent started"}),c.jsx("h2",{className:"text-3xl sm:text-4xl font-black tracking-tight",children:e.agent}),e.model&&c.jsxs("div",{className:"inline-flex items-center gap-1.5 px-3 py-1 rounded-full bg-black/5 dark:bg-white/10 text-xs font-mono text-black/60 dark:text-white/60",children:[e.modelAlias&&c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"font-semibold",children:e.modelAlias}),c.jsx("span",{className:"text-black/30 dark:text-white/30",children:"•"})]}),_o(e.model)]})]})]}),M&&U!==null&&c.jsxs("details",{className:"group rounded-[24px] border border-black/10 dark:border-white/10 bg-black/[0.02] dark:bg-white/[0.04]",children:[c.jsxs("summary",{className:"cursor-pointer select-none px-6 py-5 flex items-center justify-between gap-6 [&::-webkit-details-marker]:hidden",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(Ul,{className:"w-4 h-4 transition-transform group-open:rotate-90"}),M==="Current Context"?c.jsx(ck,{className:"w-4 h-4","aria-hidden":"true"}):null,c.jsx("div",{className:"text-[11px] font-semibold tracking-[0.24em] uppercase text-black/60 dark:text-white/60",children:M})]}),au?c.jsx("div",{className:"text-xs font-mono text-black/50 dark:text-white/50",children:au}):null]}),typeof U=="string"?c.jsx(mr,{className:"text-base sm:text-lg leading-relaxed whitespace-pre-wrap break-words text-black/80 dark:text-white/80",children:U}):c.jsx(mr,{children:E(U)})]}),c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"text-[11px] font-semibold tracking-[0.24em] uppercase text-black/50 dark:text-white/50",children:"Prompt"}),c.jsx("button",{type:"button",onClick:()=>u(!0),className:"p-1.5 rounded-full text-black/40 dark:text-white/40 hover:text-black dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/10 transition-colors","aria-label":"Search prompt",children:c.jsx(Sd,{className:"w-4 h-4"})})]}),ye?c.jsx("div",{className:"text-xs font-mono text-black/40 dark:text-white/40",children:ye}):null]}),c.jsx("div",{className:"space-y-4",children:F.length>0?F.map((ve,cs)=>{const ds=/(^| )instructions$/i.test(ve.title.trim()),mm=cs===0||ds,uu=ve.content?ve.content.split(/\r?\n/).length:0;return c.jsxs("details",{open:mm,className:"group rounded-[24px] border border-black/10 dark:border-white/10 bg-black/[0.02] dark:bg-white/[0.04]",children:[c.jsxs("summary",{className:"cursor-pointer select-none px-6 py-5 flex items-center justify-between gap-6 [&::-webkit-details-marker]:hidden",children:[c.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[c.jsx(Ul,{className:"w-4 h-4 transition-transform group-open:rotate-90"}),c.jsx("div",{className:"text-[11px] font-semibold tracking-[0.24em] uppercase text-black/60 dark:text-white/60 break-words",children:ve.title||"Prompt"})]}),uu?c.jsxs("div",{className:"text-xs font-mono text-black/40 dark:text-white/40",children:[uu," lines"]}):null]}),ze(ve.content,"")]},`${ve.title}-${cs}`)}):c.jsx(Wl,{children:w})})]}),a?c.jsx("div",{className:"fixed inset-0 z-40 bg-white text-black dark:bg-black dark:text-white",children:c.jsx("div",{className:"h-full w-full overflow-y-auto custom-scroll px-6 sm:px-10 py-10",children:c.jsxs("div",{className:"max-w-3xl mx-auto space-y-8",children:[c.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[c.jsx("div",{className:"text-[11px] font-semibold tracking-[0.32em] uppercase text-black/50 dark:text-white/50",children:"Prompt search"}),c.jsx("button",{type:"button",onClick:()=>u(!1),className:"text-[10px] font-bold tracking-[0.2em] uppercase text-black/60 hover:text-black dark:text-white/60 dark:hover:text-white",children:"Close"})]}),c.jsxs("div",{className:"relative",children:[c.jsx(Sd,{className:"w-4 h-4 text-black/50 dark:text-white/60 absolute left-4 top-1/2 -translate-y-1/2"}),c.jsx("input",{value:s,onChange:ve=>i(ve.target.value),placeholder:"Search the prompt...",className:"w-full rounded-full border border-black/20 dark:border-white/20 bg-transparent py-4 pl-11 pr-10 text-base text-black dark:text-white placeholder:text-black/40 dark:placeholder:text-white/40 focus:outline-none focus:ring-1 focus:ring-black/30 dark:focus:ring-white/40",autoFocus:!0}),B?c.jsx("button",{type:"button",onClick:()=>i(""),"aria-label":"Clear prompt search",className:"absolute right-3 top-1/2 -translate-y-1/2 rounded-full p-1 text-black/60 hover:text-black dark:text-white/60 dark:hover:text-white",children:c.jsx(fm,{className:"w-3.5 h-3.5"})}):null]}),B?Ne.length>0?c.jsx("div",{className:"space-y-4",children:Ne.map((ve,cs)=>{const ds=ve.content?ve.content.split(/\r?\n/).length:0;return c.jsxs("div",{className:"rounded-[22px] border border-black/10 dark:border-white/15 bg-black/[0.02] dark:bg-white/5 overflow-hidden",children:[c.jsxs("div",{className:"px-5 py-4 flex items-center justify-between gap-4",children:[c.jsx("div",{className:"text-[11px] font-semibold tracking-[0.24em] uppercase text-black/70 dark:text-white/70 break-words",children:As(ve.title||"Prompt",B)}),ds?c.jsxs("div",{className:"text-xs font-mono text-black/50 dark:text-white/50",children:[ds," lines"]}):null]}),c.jsx("div",{className:"border-t border-black/10 dark:border-white/10 p-5",children:c.jsx("pre",{className:"m-0 text-xs sm:text-sm font-mono leading-relaxed whitespace-pre-wrap break-words text-black/85 dark:text-white/85",children:As(ve.content||"",B)})})]},`${ve.title}-${cs}`)})}):c.jsxs("div",{className:"rounded-[20px] border border-black/10 dark:border-white/10 bg-black/[0.02] dark:bg-white/5 p-5 text-sm text-black/60 dark:text-white/60",children:['No prompt sections match "',B,'".']}):c.jsx("div",{className:"text-sm text-black/50 dark:text-white/50",children:"Start typing to filter prompt sections."})]})})}):null]})}else if(e.event&&e.event.startsWith("WORKFLOW_")){const w=e.event.replace("WORKFLOW_","");O=c.jsxs("div",{className:"min-h-[50vh] flex flex-col items-center justify-center text-center space-y-8 py-16",children:[c.jsx("div",{className:"text-[10px] font-semibold tracking-[0.4em] uppercase text-black/50 dark:text-white/50",children:"Lifecycle status"}),c.jsxs("div",{className:"w-full max-w-5xl rounded-[28px] border border-black/10 dark:border-white/10 bg-black/[0.02] dark:bg-white/[0.04] p-10",children:[c.jsx("h2",{className:"text-4xl sm:text-6xl md:text-7xl font-black tracking-tighter leading-none uppercase",children:w}),e.error&&c.jsx("div",{className:"mt-6",children:c.jsx(Cd,{children:e.error})})]})]})}else if(e.event==="PROMPT_REQUESTED"||e.event==="INTERACTION_REQUESTED"){const M=e.event==="INTERACTION_REQUESTED"?"Interaction needed":"Question asked",U=e.question||e.prompt||"Prompt",z=e.agent||e.slug||"Agent";O=c.jsxs("div",{className:"py-10 sm:py-14 space-y-8",children:[c.jsxs("div",{className:"text-center space-y-4",children:[c.jsx(Nd,{className:"w-12 h-12"}),c.jsx("div",{className:"text-[11px] font-semibold tracking-[0.32em] uppercase text-black/50 dark:text-white/50",children:M}),c.jsxs("div",{className:"text-lg sm:text-xl font-semibold text-black/70 dark:text-white/70",children:[z," needs your input"]})]}),c.jsx("div",{className:"text-3xl sm:text-4xl md:text-5xl font-black tracking-tight leading-tight text-center text-balance",children:U}),k&&P!==null&&c.jsx("div",{className:"text-center",children:c.jsxs("div",{className:`inline-flex items-center gap-2 px-4 py-2 rounded-full ${P>0?"bg-black/5 dark:bg-white/10":"bg-black text-white dark:bg-white dark:text-black"}`,children:[c.jsx("span",{className:"text-xl",children:"⚡"}),c.jsx("span",{className:`text-sm font-semibold ${P>0?"text-black/70 dark:text-white/70":""}`,children:P>0?`Agent deciding in ${P}s...`:"Auto-selected"})]})}),y==="choice"&&p.length>0&&c.jsxs("div",{className:"space-y-3 max-w-2xl mx-auto",children:[c.jsx("div",{className:"text-[11px] font-semibold tracking-[0.24em] uppercase text-black/50 dark:text-white/50 text-center",children:"Options"}),c.jsx("div",{className:"space-y-2",children:p.map((F,B)=>c.jsxs("div",{className:`p-4 rounded-2xl border transition-all ${B===0?"border-black bg-black text-white dark:border-white dark:bg-white dark:text-black":"border-black/10 dark:border-white/10 bg-black/[0.02] dark:bg-white/[0.03]"}`,children:[c.jsx("div",{className:"flex items-center gap-3",children:c.jsxs("div",{className:`font-bold ${B===0?"":"text-black dark:text-white"}`,children:[F.label||F.key,B===0&&c.jsx("span",{className:"ml-2 text-xs font-medium px-2 py-0.5 rounded-full bg-white/20 dark:bg-black/20",children:"Recommended"})]})}),F.description&&c.jsx("div",{className:`text-sm mt-1 ${B===0?"text-white/70 dark:text-black/70":"text-black/50 dark:text-white/50"}`,children:F.description})]},F.key||B))}),e.allowCustom&&c.jsx("div",{className:"text-xs text-center text-black/40 dark:text-white/40 mt-2",children:"Custom response allowed"})]})]})}else if(e.event==="INTERACTION_AUTO_RESOLVED"||e.event==="PROMPT_AUTO_ANSWERED"){const w=e.autoSelected||"Unknown",M=e.agent||e.slug||"Agent";O=c.jsxs("div",{className:"space-y-8 py-6",children:[c.jsxs("div",{className:"space-y-4 text-center",children:[c.jsx("div",{className:"mx-auto w-14 h-14 rounded-full border-2 border-black dark:border-white bg-black dark:bg-white flex items-center justify-center",children:c.jsx("span",{className:"text-2xl",children:"⚡"})}),c.jsx("div",{className:"text-[11px] font-semibold tracking-[0.24em] uppercase text-black/50 dark:text-white/50",children:"Auto-selected"}),c.jsxs("div",{className:"text-lg sm:text-xl font-semibold text-black/70 dark:text-white/70",children:[M," decided automatically"]})]}),c.jsx("div",{className:"rounded-[24px] border-2 border-black bg-black text-white dark:border-white dark:bg-white dark:text-black p-6 text-center max-w-md mx-auto",children:c.jsx("div",{className:"text-2xl sm:text-3xl font-black tracking-tight",children:w})})]})}else if(e.event==="INTERACTION_RESOLVED"){const w=e.source==="remote"?"Remote response received.":"Response captured.",M=e.source==="remote"?"Received from remote":e.source?`Received from ${e.source}`:"Received",U=e.agent||e.slug||"Agent";O=c.jsxs("div",{className:"space-y-8 py-6",children:[c.jsxs("div",{className:"space-y-4 text-center",children:[c.jsx(Nd,{className:"w-12 h-12"}),c.jsx("div",{className:"text-[11px] font-semibold tracking-[0.24em] uppercase text-black/50 dark:text-white/50",children:"Interaction resolved"}),c.jsxs("div",{className:"text-lg sm:text-xl font-semibold text-black/70 dark:text-white/70",children:[U," received your response"]})]}),c.jsxs("div",{className:"rounded-[24px] border border-black/10 dark:border-white/10 bg-black/[0.02] dark:bg-white/[0.04] p-6 text-center",children:[c.jsx("div",{className:"text-xl sm:text-2xl font-semibold leading-relaxed text-balance",children:w}),c.jsx("div",{className:"mt-3 text-sm text-black/60 dark:text-white/60",children:M})]})]})}else if(e.event==="PROMPT_ANSWERED"||e.event==="INTERACTION_SUBMITTED"){const w=e.answer!==void 0?e.answer:e.response;O=c.jsx("div",{className:"space-y-8 py-6",children:c.jsxs("div",{className:"space-y-3",children:[c.jsx("div",{className:"text-[11px] font-semibold tracking-[0.24em] uppercase text-black/50 dark:text-white/50",children:"Response sent"}),Ek(w)]})})}else if(e.event==="AGENT_COMPLETED"){const w=e.usage&&(e.usage.inputTokens>0||e.usage.outputTokens>0);O=c.jsxs("div",{className:"space-y-10 py-6",children:[c.jsxs("div",{className:"rounded-[28px] border border-black/10 dark:border-white/10 bg-black/[0.02] dark:bg-white/[0.04] p-6 sm:p-8 text-center space-y-4",children:[c.jsx(Pk,{className:"w-12 h-12"}),c.jsx("div",{className:"text-[11px] font-semibold tracking-[0.24em] uppercase text-black/50 dark:text-white/50",children:"Agent completed"}),c.jsx("div",{className:"text-2xl sm:text-3xl font-black tracking-tight",children:e.agent||"Agent"}),w&&c.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-4 text-sm",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-black/50 dark:text-white/50",children:"In:"}),c.jsx("span",{className:"font-mono font-semibold",children:G(e.usage.inputTokens)})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-black/50 dark:text-white/50",children:"Out:"}),c.jsx("span",{className:"font-mono font-semibold",children:G(e.usage.outputTokens)})]}),e.usage.cachedTokens>0&&c.jsxs("div",{className:"flex items-center gap-2 text-black/40 dark:text-white/40",children:[c.jsx("span",{children:"Cached:"}),c.jsx("span",{className:"font-mono",children:G(e.usage.cachedTokens)})]}),e.usage.cost>0&&c.jsx("div",{className:"flex items-center gap-2 text-black/60 dark:text-white/60",children:c.jsxs("span",{className:"font-mono font-semibold",children:["$",e.usage.cost.toFixed(4)]})})]}),e.model&&c.jsx("div",{className:"inline-flex items-center gap-1.5 px-3 py-1 rounded-full bg-black/5 dark:bg-white/10 text-xs font-mono text-black/60 dark:text-white/60",children:_o(e.model)}),typeof e.attempts=="number"&&c.jsxs("div",{className:"text-sm text-black/60 dark:text-white/60",children:[e.attempts," ",e.attempts===1?"attempt":"attempts"]})]}),e.output!==void 0?c.jsxs("div",{className:"space-y-4",children:[c.jsx("div",{className:"text-[11px] font-semibold tracking-[0.24em] uppercase text-black/50 dark:text-white/50",children:"Answer"}),c.jsx("div",{className:"rounded-[24px] border border-black/10 dark:border-white/10 bg-black/[0.02] dark:bg-white/[0.04] p-6",children:E(e.output)})]}):null]})}else{const w=Object.entries(e).filter(([M])=>M!=="event"&&M!=="timestamp");O=c.jsx("div",{className:"space-y-6 py-6",children:c.jsxs("div",{className:"rounded-[24px] border border-black/10 dark:border-white/10 bg-black/[0.02] dark:bg-white/[0.04] p-6",children:[c.jsx("div",{className:"text-lg sm:text-xl font-semibold leading-relaxed text-balance",children:e.event?e.event.replace(/_/g," "):"Event"}),c.jsx("div",{className:"mt-3 text-sm text-black/60 dark:text-white/60",children:w.length>0?"Open Raw for full details.":"Open Raw for more info."})]})})}return c.jsxs("div",{className:"w-full h-full flex flex-col overflow-y-auto custom-scroll px-6 sm:px-10 lg:px-12 bg-white text-black dark:bg-black dark:text-white",children:[c.jsxs("div",{className:"content-width flex-1",children:[c.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4 pt-8 sm:pt-10 pb-6 border-b border-black/10 dark:border-white/10",children:[c.jsx("div",{className:"flex items-center gap-3",children:v.hasTokens&&c.jsxs("div",{className:"relative",children:[c.jsxs("button",{type:"button",onClick:()=>f(w=>!w),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-xs font-mono bg-black/5 dark:bg-white/10 hover:bg-black/10 dark:hover:bg-white/15 transition-colors","aria-expanded":d,"aria-label":"Toggle token stats",children:[c.jsx("span",{className:"text-black/50 dark:text-white/50",children:"↑"}),c.jsx("span",{children:Td(v.pointInTime.inputTokens)}),c.jsx("span",{className:"text-black/50 dark:text-white/50",children:"↓"}),c.jsx("span",{children:Td(v.pointInTime.outputTokens)}),c.jsx(dk,{className:`w-3 h-3 text-black/40 dark:text-white/40 transition-transform ${d?"rotate-180":""}`})]}),d&&c.jsxs("div",{className:"absolute top-full left-0 mt-2 z-10 min-w-[200px] rounded-2xl border border-black/10 dark:border-white/10 bg-white dark:bg-black shadow-xl shadow-black/10 dark:shadow-white/5 p-4 space-y-3",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"text-[10px] font-semibold tracking-[0.2em] uppercase text-black/40 dark:text-white/40",children:["Up to page ",t+1]}),c.jsxs("div",{className:"flex items-center gap-3 text-sm font-mono",children:[c.jsx("span",{className:"text-black/50 dark:text-white/50",children:"↑"}),c.jsx("span",{className:"font-semibold",children:v.pointInTime.inputTokens.toLocaleString()}),c.jsx("span",{className:"text-black/50 dark:text-white/50",children:"↓"}),c.jsx("span",{className:"font-semibold",children:v.pointInTime.outputTokens.toLocaleString()})]})]}),c.jsxs("div",{className:"border-t border-black/10 dark:border-white/10 pt-3 space-y-1",children:[c.jsx("div",{className:"text-[10px] font-semibold tracking-[0.2em] uppercase text-black/40 dark:text-white/40",children:"Session total"}),c.jsxs("div",{className:"flex items-center gap-3 text-sm font-mono",children:[c.jsx("span",{className:"text-black/50 dark:text-white/50",children:"↑"}),c.jsx("span",{className:"font-semibold",children:v.total.inputTokens.toLocaleString()}),c.jsx("span",{className:"text-black/50 dark:text-white/50",children:"↓"}),c.jsx("span",{className:"font-semibold",children:v.total.outputTokens.toLocaleString()})]})]}),c.jsx("button",{type:"button",onClick:()=>{f(!1),g(!0)},className:"w-full mt-2 pt-3 border-t border-black/10 dark:border-white/10 text-[10px] font-semibold tracking-[0.16em] uppercase text-black/50 dark:text-white/50 hover:text-black dark:hover:text-white transition-colors text-center",children:"View details"})]})]})}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(bk,{open:o,onToggle:()=>l(w=>!w)}),c.jsx(hm,{text:e})]})]}),c.jsx("div",{className:"pt-6",children:c.jsx("div",{className:"text-xs font-mono text-black/50 dark:text-white/50",children:r})}),o?c.jsx("pre",{className:"raw-json-block",children:pm(e)}):O]}),h&&c.jsx("div",{className:"fixed inset-0 z-50 bg-white text-black dark:bg-black dark:text-white",children:c.jsx("div",{className:"h-full w-full overflow-y-auto custom-scroll px-6 sm:px-10 py-10",children:c.jsxs("div",{className:"max-w-4xl mx-auto space-y-8",children:[c.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-[11px] font-semibold tracking-[0.32em] uppercase text-black/50 dark:text-white/50",children:"Token Usage Details"}),c.jsxs("div",{className:"text-2xl font-bold",children:[v.agentBreakdown.length," agent ",v.agentBreakdown.length===1?"call":"calls"]})]}),c.jsx("button",{type:"button",onClick:()=>g(!1),className:"text-[10px] font-bold tracking-[0.2em] uppercase text-black/60 hover:text-black dark:text-white/60 dark:hover:text-white",children:"Close"})]}),c.jsxs("div",{className:"rounded-[24px] border border-black/10 dark:border-white/10 bg-black/[0.02] dark:bg-white/[0.04] p-6",children:[c.jsx("div",{className:"text-[10px] font-semibold tracking-[0.2em] uppercase text-black/40 dark:text-white/40 mb-4",children:"Session Totals"}),c.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-6",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-xs text-black/50 dark:text-white/50",children:"Input Tokens"}),c.jsx("div",{className:"text-xl font-mono font-bold",children:v.total.inputTokens.toLocaleString()})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-xs text-black/50 dark:text-white/50",children:"Output Tokens"}),c.jsx("div",{className:"text-xl font-mono font-bold",children:v.total.outputTokens.toLocaleString()})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-xs text-black/50 dark:text-white/50",children:"Total Tokens"}),c.jsx("div",{className:"text-xl font-mono font-bold",children:(v.total.inputTokens+v.total.outputTokens).toLocaleString()})]}),v.total.cost>0&&c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-xs text-black/50 dark:text-white/50",children:"Total Cost"}),c.jsxs("div",{className:"text-xl font-mono font-bold",children:["$",v.total.cost.toFixed(4)]})]})]})]}),c.jsxs("div",{className:"space-y-4",children:[c.jsx("div",{className:"text-[10px] font-semibold tracking-[0.2em] uppercase text-black/40 dark:text-white/40",children:"Per-Agent Breakdown"}),c.jsx("div",{className:"space-y-3",children:v.agentBreakdown.map((w,M)=>c.jsxs("div",{className:"rounded-[20px] border border-black/10 dark:border-white/10 bg-black/[0.02] dark:bg-white/[0.04] p-5",children:[c.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4 mb-4",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-lg font-bold",children:w.agent}),c.jsxs("div",{className:"flex items-center gap-2",children:[w.model&&c.jsx("span",{className:"inline-flex px-2 py-0.5 rounded-full bg-black/5 dark:bg-white/10 text-xs font-mono text-black/60 dark:text-white/60",children:_o(w.model)}),c.jsx("span",{className:"text-xs text-black/40 dark:text-white/40",children:new Date(w.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})})]})]}),w.cost>0&&c.jsx("div",{className:"text-right",children:c.jsxs("div",{className:"text-lg font-mono font-bold",children:["$",w.cost.toFixed(4)]})})]}),c.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4 text-sm",children:[c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"text-xs text-black/40 dark:text-white/40",children:"Input"}),c.jsx("div",{className:"font-mono font-semibold",children:w.inputTokens.toLocaleString()})]}),c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"text-xs text-black/40 dark:text-white/40",children:"Output"}),c.jsx("div",{className:"font-mono font-semibold",children:w.outputTokens.toLocaleString()})]}),c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"text-xs text-black/40 dark:text-white/40",children:"Total"}),c.jsx("div",{className:"font-mono font-semibold",children:(w.inputTokens+w.outputTokens).toLocaleString()})]}),w.cachedTokens>0&&c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"text-xs text-black/40 dark:text-white/40",children:"Cached"}),c.jsx("div",{className:"font-mono font-semibold text-black/60 dark:text-white/60",children:w.cachedTokens.toLocaleString()})]})]})]},`${w.agent}-${M}`))})]}),v.agentBreakdown.length===0&&c.jsx("div",{className:"rounded-[20px] border border-black/10 dark:border-white/10 bg-black/[0.02] dark:bg-white/[0.04] p-6 text-center text-black/50 dark:text-white/50",children:"No token usage data available yet."})]})})})]})}const Mk=e=>{const t="w-3.5 h-3.5 text-black/70 dark:text-white/70";if(!e)return c.jsx($l,{className:`${t} opacity-40`});const n=e.toUpperCase();return n.includes("STARTED")||n.includes("START")?c.jsx(dm,{className:`${t} opacity-70`}):n.includes("SUBMITTED")||n.includes("ANSWERED")||n.includes("SUCCESS")||n.includes("RESOLVED")?c.jsx(pk,{className:`${t} opacity-80`}):n.includes("REQUESTED")||n.includes("REQUEST")?c.jsx(wk,{className:`${t} opacity-60`}):n.includes("ERROR")||n.includes("FAILED")?c.jsx(hk,{className:`${t} opacity-90`}):c.jsx($l,{className:`${t} opacity-40`})},Rk=e=>{const t=e.question||e.answer||e.prompt||e.error||e.status||e.message,n=e.slug||(e.event&&e.event.startsWith("WORKFLOW_")?e.event.replace("WORKFLOW_",""):null);return!t&&!n?e.event||"Unknown Event":c.jsxs("div",{className:"flex flex-col gap-0.5",children:[n&&c.jsx("span",{className:"text-black/60 dark:text-white/60 font-medium text-[10px] tracking-[0.24em] uppercase",children:n}),t&&c.jsx("span",{className:"opacity-70 truncate max-w-md",children:typeof t=="string"?t:JSON.stringify(t)})]})};function Ak({history:e,onJump:t}){return c.jsx("div",{className:"w-full h-full flex flex-col overflow-hidden bg-bg",children:c.jsx("div",{className:"flex-1 overflow-y-auto custom-scroll px-6 sm:px-8 lg:px-10 py-20",children:c.jsx("div",{className:"max-w-4xl mx-auto space-y-1",children:e.length===0?c.jsxs("div",{className:"h-[40vh] flex flex-col items-center justify-center opacity-20 space-y-4",children:[c.jsx($l,{className:"w-12 h-12"}),c.jsx("div",{className:"text-xs font-bold tracking-[0.4em] uppercase",children:"No events yet"})]}):e.map((n,r)=>{var i;const s=new Date(n.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});return c.jsxs("button",{onClick:()=>t(r),className:"w-full text-left group flex items-start gap-6 p-5 rounded-2xl transition-all border border-black/10 dark:border-white/10 hover:bg-black/[0.03] dark:hover:bg-white/[0.04]",children:[c.jsx("div",{className:"flex-shrink-0 w-20 pt-1",children:c.jsx("span",{className:"text-[10px] font-mono font-medium opacity-30 group-hover:opacity-60 transition-opacity",children:s})}),c.jsx("div",{className:"flex-shrink-0 pt-0.5",children:Mk(n.event)}),c.jsxs("div",{className:"flex-1 min-w-0 flex flex-col gap-1",children:[c.jsx("div",{className:"text-[10px] font-semibold tracking-[0.28em] uppercase opacity-40 group-hover:opacity-70 transition-opacity",children:((i=n.event)==null?void 0:i.replace(/_/g," "))||"EVENT"}),c.jsx("div",{className:"text-sm leading-relaxed truncate group-hover:text-black dark:group-hover:text-white transition-colors",children:Rk(n)})]})]},r)})})})})}function Dk({page:e,total:t,onNext:n,onPrev:r,onJump:s,hasNew:i,onJumpToLatest:o,className:l=""}){const[a,u]=S.useState(e+1);S.useEffect(()=>u(e+1),[e]);const d=f=>{const{value:h}=f.target;u(h);const g=parseInt(h,10);!Number.isNaN(g)&&g>=1&&g<=t&&s(g-1)};return c.jsx("footer",{className:`nav-footer transition-opacity duration-300 ${l}`,children:c.jsxs("div",{className:"footer-control",children:[c.jsx("button",{onClick:r,disabled:e===0,className:"tooltip p-1 hover:text-black dark:hover:text-white disabled:opacity-0 transition-all pointer-events-auto","data-tooltip":"Previous","aria-label":"Previous event",children:c.jsx(fk,{className:"w-5 h-5"})}),c.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono font-bold tracking-widest opacity-60",children:[c.jsx("input",{type:"number",value:a,onChange:d,className:"jumper-input",min:"1",max:t}),c.jsx("span",{className:"opacity-20",children:"/"}),c.jsx("span",{children:t})]}),c.jsx("button",{onClick:n,disabled:e===t-1,className:"tooltip p-1 hover:text-black dark:hover:text-white disabled:opacity-0 transition-all pointer-events-auto","data-tooltip":"Next","aria-label":"Next event",children:c.jsx(Ul,{className:"w-5 h-5"})}),i?c.jsx("button",{onClick:o,className:"tooltip px-3 py-1 rounded-full text-[10px] font-bold tracking-[0.2em] uppercase bg-black text-white dark:bg-white dark:text-black shadow-[0_10px_30px_rgba(0,0,0,0.2)] dark:shadow-[0_10px_30px_rgba(255,255,255,0.1)] hover:scale-[1.02] transition-transform","data-tooltip":"Latest","aria-label":"Jump to latest event",children:"New"}):null]})})}function Vk({workflowName:e,status:t,theme:n,toggleTheme:r,viewMode:s,setViewMode:i,history:o,fullAuto:l,onToggleFullAuto:a,onOpenSettings:u,configDisabled:d}){const f=t==="connected";return c.jsxs("header",{className:"fixed top-0 inset-x-0 h-20 px-6 sm:px-10 lg:px-12 flex items-center justify-between z-50 bg-bg/80 backdrop-blur-3xl",children:[c.jsxs("div",{className:"flex items-center gap-4",children:[c.jsx("div",{className:`w-2.5 h-2.5 rounded-full border ${f?"bg-black border-black dark:bg-white dark:border-white":"bg-transparent border-black/30 dark:border-white/30"}`,"aria-hidden":"true"}),c.jsx("span",{className:"font-semibold text-[10px] tracking-[0.32em] uppercase text-black/50 dark:text-white/50 truncate max-w-[300px]",children:e||"Workflow"})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("button",{onClick:a,disabled:d,className:`tooltip w-10 h-10 flex items-center justify-center rounded-full transition-colors ${d?"opacity-30 cursor-not-allowed":"hover:bg-black/5 dark:hover:bg-white/10"}`,"data-tooltip":l?"Pause auto":"Enable auto","aria-label":l?"Disable full-auto mode":"Enable full-auto mode",children:l?c.jsx(xk,{className:"w-5 h-5 opacity-60"}):c.jsx(dm,{className:"w-5 h-5 opacity-40 hover:opacity-100"})}),c.jsx("button",{onClick:u,className:"tooltip w-10 h-10 flex items-center justify-center rounded-full hover:bg-black/5 dark:hover:bg-white/10 transition-colors","data-tooltip":"Settings","aria-label":"Open settings",children:c.jsx(Sk,{className:"w-5 h-5 opacity-40 hover:opacity-100"})}),c.jsx(hm,{text:o||[],label:"Copy full history",disabled:!o||o.length===0}),c.jsx("button",{onClick:()=>i(s==="present"?"log":"present"),className:"tooltip w-10 h-10 flex items-center justify-center rounded-full hover:bg-black/5 dark:hover:bg-white/10 transition-colors","data-tooltip":s==="present"?"Log view":"Present view","aria-label":s==="present"?"Switch to Log view":"Switch to Presentation view",children:s==="present"?c.jsx(gk,{className:"w-5 h-5 opacity-40 hover:opacity-100"}):c.jsx(kk,{className:"w-5 h-5 opacity-40 hover:opacity-100"})}),c.jsx("button",{onClick:r,className:"tooltip w-10 h-10 flex items-center justify-center rounded-full hover:bg-black/5 dark:hover:bg-white/10 transition-colors","data-tooltip":n==="dark"?"Light theme":"Dark theme","aria-label":n==="dark"?"Switch to Light theme":"Switch to Dark theme",children:n==="dark"?c.jsx(Ck,{className:"w-5 h-5 opacity-40 hover:opacity-100"}):c.jsx(vk,{className:"w-5 h-5 opacity-40 hover:opacity-100"})})]})]})}function _k({interaction:e,onSubmit:t,disabled:n}){const{prompt:r,question:s,options:i=[],multiSelect:o,allowCustom:l,fullAuto:a,autoSelectDelay:u=20,timestamp:d}=e,[f,h]=S.useState(o?[]:null),[g,v]=S.useState(""),[x,C]=S.useState(!1),[y,p]=S.useState(0),m=S.useMemo(()=>i||[],[i]),k=r||s||"Choose an option.",N=S.useMemo(()=>{if(!a||!d)return null;const L=new Date(d).getTime(),V=Math.floor((Date.now()-L)/1e3);return u-V},[a,d,u,y]);S.useEffect(()=>{if(!a)return;const L=setInterval(()=>p(V=>V+1),1e3);return()=>clearInterval(L)},[a]);const T=L=>{o?(h(V=>V.includes(L)?V.filter(W=>W!==L):[...V,L]),C(!1)):(h(L),C(!1))},P=()=>{if(x&&g.trim()){t({isCustom:!0,customText:g.trim(),raw:g.trim()});return}if(o&&f.length>0){t({selectedKeys:f,raw:f.join(", ")});return}f&&t({selectedKey:f,raw:String(f)})},j=x?!!g.trim():o?f.length>0:!!f;return c.jsxs("div",{className:"w-full h-full flex flex-col items-stretch overflow-hidden",children:[c.jsxs("div",{className:"flex-1 overflow-y-auto custom-scroll px-6 py-12 space-y-8 flex flex-col items-center",children:[c.jsxs("div",{className:"space-y-4 shrink-0",children:[c.jsx("div",{className:"w-16 h-16 rounded-3xl bg-black text-white dark:bg-white dark:text-black flex items-center justify-center mx-auto shadow-2xl shadow-black/20 dark:shadow-white/10",children:c.jsx(us,{className:"w-8 h-8"})}),c.jsx("h3",{className:"text-3xl sm:text-4xl font-extrabold tracking-tight text-fg pt-4 text-center",children:"Choose an option."})]}),c.jsx("div",{className:"text-lg sm:text-xl font-medium text-fg/70 text-center max-w-2xl whitespace-pre-wrap break-words",children:k}),a&&N!==null&&c.jsx("div",{className:"text-center",children:c.jsxs("div",{className:`inline-flex items-center gap-2 px-4 py-2 rounded-full ${N>0?"bg-yellow-500 text-black animate-pulse":"bg-black text-white dark:bg-white dark:text-black"}`,children:[c.jsx("span",{className:"text-xl",children:"⚡"}),c.jsx("span",{className:"text-sm font-bold",children:N>0?`Agent deciding in ${N}s...`:"Auto-selecting recommended option..."})]})}),c.jsxs("div",{className:"w-full max-w-2xl space-y-3",children:[m.map((L,V)=>{const W=o?f.includes(L.key):f===L.key,G=W?"text-white dark:text-black":"text-black dark:text-white",te=W?"text-white/70 dark:text-black/70":"text-black/50 dark:text-white/50";return c.jsx("button",{onClick:()=>T(L.key),disabled:n,type:"button",className:`w-full p-6 rounded-2xl border-2 transition-all text-left ${W?"border-black bg-black text-white dark:border-white dark:bg-white dark:text-black":"border-black/10 dark:border-white/10 hover:border-black/30 dark:hover:border-white/30 bg-black/[0.02] dark:bg-white/[0.03]"}`,children:c.jsxs("div",{className:"flex items-center gap-4",children:[c.jsx("div",{className:`w-6 h-6 rounded-full border-2 flex items-center justify-center ${W?"border-black bg-black text-white dark:border-white dark:bg-white dark:text-black":"border-black/30 dark:border-white/30"}`,children:W&&c.jsx(cm,{className:"w-4 h-4"})}),c.jsxs("div",{className:"flex-1",children:[c.jsxs("div",{className:`font-bold text-lg break-words flex flex-wrap items-center gap-2 ${G}`,children:[c.jsx("span",{className:"break-words",children:L.label||L.key}),V===0&&c.jsx("span",{className:`ml-2 text-xs font-medium px-2 py-0.5 rounded-full ${W?"bg-white/20 dark:bg-black/20":"bg-black/10 dark:bg-white/10"}`,children:"Recommended"})]}),L.description&&c.jsx("div",{className:`text-sm mt-1 break-words ${te}`,children:L.description})]})]})},L.key)}),l&&c.jsxs("button",{onClick:()=>{C(!0),h(o?[]:null)},disabled:n,type:"button",className:`w-full p-6 rounded-2xl border-2 transition-all text-left ${x?"border-black bg-black text-white dark:border-white dark:bg-white dark:text-black":"border-black/10 dark:border-white/10 hover:border-black/30 dark:hover:border-white/30 bg-black/[0.02] dark:bg-white/[0.03]"}`,children:[c.jsx("div",{className:`font-bold text-lg break-words ${x?"text-white dark:text-black":"text-black dark:text-white"}`,children:"Other"}),c.jsx("div",{className:`text-sm mt-1 break-words ${x?"text-white/70 dark:text-black/70":"text-black/50 dark:text-white/50"}`,children:"Provide a custom response"})]}),x&&c.jsx("textarea",{value:g,onChange:L=>v(L.target.value),placeholder:"Type your response...",className:"w-full h-32 p-6 rounded-2xl bg-black/[0.02] dark:bg-white/[0.03] border-2 border-black/20 dark:border-white/20 focus:border-black dark:focus:border-white focus:outline-none text-lg"})]})]}),c.jsx("div",{className:"p-4 flex justify-center bg-gradient-to-t from-bg via-bg to-transparent shrink-0 border-t border-black/10 dark:border-white/10",children:c.jsx("button",{onClick:P,disabled:n||!j,className:"px-12 py-6 bg-fg text-bg rounded-full font-bold text-xl hover:scale-105 active:scale-95 transition-all disabled:opacity-30 shadow-2xl",children:"Continue"})})]})}function Ok({interaction:e,onSubmit:t,disabled:n}){const{prompt:r,question:s,confirmLabel:i="Confirm",cancelLabel:o="Cancel",context:l}=e;return c.jsxs("div",{className:"w-full h-full flex flex-col items-stretch overflow-hidden",children:[c.jsxs("div",{className:"flex-1 overflow-y-auto custom-scroll px-6 py-12 space-y-8 flex flex-col items-center justify-center",children:[c.jsxs("div",{className:"space-y-4",children:[c.jsx("div",{className:"w-16 h-16 rounded-3xl bg-black text-white dark:bg-white dark:text-black flex items-center justify-center mx-auto shadow-2xl shadow-black/20 dark:shadow-white/10",children:c.jsx(us,{className:"w-8 h-8"})}),c.jsx("h3",{className:"text-3xl sm:text-4xl font-extrabold tracking-tight text-fg pt-4 text-center",children:"Confirm action."})]}),c.jsx("div",{className:"text-lg sm:text-xl font-medium text-fg/70 text-center max-w-2xl whitespace-pre-wrap break-words",children:r||s||"Please confirm."}),(l==null?void 0:l.documentPath)&&c.jsxs("div",{className:"text-sm text-fg/40 text-center",children:["Review: ",c.jsx("code",{className:"bg-black/10 dark:bg-white/10 px-2 py-1 rounded",children:l.documentPath})]})]}),c.jsxs("div",{className:"p-4 flex justify-center gap-4 bg-gradient-to-t from-bg via-bg to-transparent shrink-0 border-t border-black/10 dark:border-white/10",children:[c.jsx("button",{onClick:()=>t({confirmed:!1,raw:o}),disabled:n,className:"px-12 py-6 border border-black/20 dark:border-white/20 text-fg rounded-full font-bold text-xl hover:bg-black/5 dark:hover:bg-white/10 transition-all disabled:opacity-30",children:o}),c.jsx("button",{onClick:()=>t({confirmed:!0,raw:i}),disabled:n,className:"px-12 py-6 bg-fg text-bg rounded-full font-bold text-xl hover:scale-105 active:scale-95 transition-all disabled:opacity-30 shadow-2xl shadow-black/20 dark:shadow-white/10",children:i})]})]})}function Ik({interaction:e,onSubmit:t,disabled:n}){const{prompt:r,question:s,placeholder:i,validation:o}=e,[l,a]=S.useState(""),[u,d]=S.useState(null),f=S.useMemo(()=>o||{},[o]),h=v=>f.minLength&&v.length<f.minLength?`Minimum ${f.minLength} characters required`:f.maxLength&&v.length>f.maxLength?`Maximum ${f.maxLength} characters allowed`:f.pattern&&!new RegExp(f.pattern).test(v)?"Invalid format":null,g=()=>{const v=l.trim(),x=h(v);if(x){d(x);return}t({text:v,raw:v})};return c.jsxs("div",{className:"w-full h-full flex flex-col items-stretch overflow-hidden",children:[c.jsxs("div",{className:"flex-1 overflow-y-auto custom-scroll px-6 py-12 space-y-8 flex flex-col items-center",children:[c.jsxs("div",{className:"space-y-4 shrink-0",children:[c.jsx("div",{className:"w-16 h-16 rounded-3xl bg-black text-white dark:bg-white dark:text-black flex items-center justify-center mx-auto shadow-2xl shadow-black/20 dark:shadow-white/10",children:c.jsx(us,{className:"w-8 h-8"})}),c.jsx("h3",{className:"text-3xl sm:text-4xl font-extrabold tracking-tight text-fg pt-4 text-center",children:"Action required."})]}),c.jsxs("div",{className:"w-full max-w-2xl space-y-4",children:[c.jsx("div",{className:"text-lg sm:text-xl font-medium text-fg/70 text-center whitespace-pre-wrap break-words",children:r||s||"Provide your response."}),c.jsx("textarea",{value:l,onChange:v=>{a(v.target.value),d(null)},disabled:n,placeholder:i||"Your response...",className:`w-full h-64 p-8 rounded-[32px] bg-black/[0.02] dark:bg-white/[0.03] border-2 ${u?"border-black dark:border-white":"border-transparent"} focus:border-black dark:focus:border-white focus:outline-none text-xl sm:text-2xl font-medium transition-all text-center placeholder:opacity-20`}),u&&c.jsx("div",{className:"text-black dark:text-white text-center text-sm font-semibold",children:u})]})]}),c.jsx("div",{className:"p-4 flex justify-center bg-gradient-to-t from-bg via-bg to-transparent shrink-0 border-t border-black/10 dark:border-white/10",children:c.jsx("button",{onClick:g,disabled:n||!l.trim(),className:"px-12 py-6 bg-fg text-bg rounded-full font-bold text-xl hover:scale-105 active:scale-95 transition-all disabled:opacity-30 shadow-2xl",children:"Submit Response"})})]})}function Fk({interaction:e,onSubmit:t,disabled:n}){const r=(e==null?void 0:e.type)||"text",s=i=>{t(e.slug,e.targetKey,i)};switch(r){case"choice":return c.jsx(_k,{interaction:e,onSubmit:s,disabled:n},e.slug);case"confirm":return c.jsx(Ok,{interaction:e,onSubmit:s,disabled:n},e.slug);case"text":default:return c.jsx(Ik,{interaction:e,onSubmit:s,disabled:n},e.slug)}}function zk({submission:e}){const t=e!=null&&e.slug?`Waiting for the CLI to receive ${e.slug} and log the next event.`:"Waiting for the CLI to receive the response and log the next event.";return c.jsx("div",{className:"w-full h-full flex items-center justify-center px-6 py-12 bg-white text-black dark:bg-black dark:text-white",children:c.jsxs("div",{className:"content-width w-full flex flex-col items-center text-center gap-6",children:[c.jsxs("div",{className:"relative",children:[c.jsx("div",{className:"absolute -inset-4 rounded-[36px] bg-black/10 dark:bg-white/10 blur-2xl opacity-60","aria-hidden":"true"}),c.jsx("div",{className:"relative w-20 h-20 rounded-[28px] border border-black/10 dark:border-white/10 bg-black/[0.03] dark:bg-white/[0.03] flex items-center justify-center shadow-2xl shadow-black/20 dark:shadow-white/10",children:c.jsx(yk,{className:"w-9 h-9 text-black dark:text-white animate-spin"})})]}),c.jsxs("div",{className:"space-y-3",children:[c.jsx("div",{className:"text-4xl font-black tracking-tight",children:"Sending response"}),c.jsx("div",{className:"text-lg font-medium text-black/60 dark:text-white/60 max-w-xl break-words",children:t}),c.jsx("div",{className:"text-[10px] font-bold tracking-[0.35em] uppercase opacity-30",children:"Keep this tab open"})]})]})})}function Bk({isOpen:e,onClose:t,fullAuto:n,onToggleFullAuto:r,autoSelectDelay:s,onDelayChange:i,onStop:o,disabled:l}){const[a,u]=S.useState(!1),[d,f]=S.useState(String(s));if(S.useEffect(()=>{f(String(s))},[s]),!e)return null;const h=()=>{a?(o(),u(!1),t()):u(!0)},g=v=>{v.target===v.currentTarget&&(u(!1),t())};return c.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",onClick:g,children:c.jsxs("div",{className:"bg-white dark:bg-black border border-black/10 dark:border-white/10 rounded-3xl p-8 w-[90vw] max-w-md shadow-2xl",children:[c.jsxs("div",{className:"flex justify-between items-center mb-6",children:[c.jsx("h2",{className:"text-xl font-bold",children:"Settings"}),c.jsx("button",{onClick:()=>{u(!1),t()},className:"p-2 hover:bg-black/5 dark:hover:bg-white/10 rounded-full transition-colors","aria-label":"Close settings",children:c.jsx(fm,{className:"w-5 h-5"})})]}),c.jsxs("div",{className:"flex items-center justify-between py-4 border-b border-black/10 dark:border-white/10",children:[c.jsxs("div",{children:[c.jsx("div",{className:"font-semibold",children:"Full-Auto Mode"}),c.jsx("div",{className:"text-sm text-black/50 dark:text-white/50",children:"Auto-select recommended options"})]}),c.jsx("button",{onClick:r,disabled:l,className:`w-12 h-7 rounded-full transition-colors relative ${n?"bg-black dark:bg-white":"bg-black/20 dark:bg-white/20"} ${l?"opacity-50 cursor-not-allowed":""}`,"aria-pressed":n,"aria-label":"Toggle full-auto mode",children:c.jsx("div",{className:`absolute top-1 w-5 h-5 rounded-full bg-white dark:bg-black transition-transform ${n?"left-6":"left-1"}`})})]}),c.jsxs("div",{className:"flex items-center justify-between py-4 border-b border-black/10 dark:border-white/10",children:[c.jsxs("div",{children:[c.jsx("div",{className:"font-semibold",children:"Countdown Delay"}),c.jsx("div",{className:"text-sm text-black/50 dark:text-white/50",children:"Seconds before auto-select"})]}),c.jsx("input",{type:"number",value:d,onChange:v=>f(v.target.value),onBlur:()=>{const v=parseInt(d,10);!isNaN(v)&&v>=1&&v<=120?i(v):f(String(s))},onKeyDown:v=>{v.key==="Enter"&&v.target.blur()},min:1,max:120,disabled:l,className:"w-20 p-2 text-center rounded-xl border border-black/20 dark:border-white/20 bg-transparent disabled:opacity-50"})]}),c.jsxs("div",{className:"mt-6",children:[c.jsxs("button",{onClick:h,disabled:l,className:`w-full py-4 rounded-2xl font-bold flex items-center justify-center gap-2 transition-colors ${a?"bg-red-600 text-white hover:bg-red-700":"bg-red-500/10 text-red-500 hover:bg-red-500/20"} ${l?"opacity-50 cursor-not-allowed":""}`,children:[c.jsx(Nk,{className:"w-5 h-5"}),a?"Click again to confirm":"Stop Workflow"]}),a&&c.jsx("div",{className:"text-center text-sm text-black/50 dark:text-white/50 mt-2",children:"This will terminate the CLI process"})]})]})})}function Uk(){const[e,t]=S.useState([]),[n,r]=S.useState(0),[s,i]=S.useState("connecting"),[o,l]=S.useState("..."),[a,u]=S.useState("light"),[d,f]=S.useState("present"),[h,g]=S.useState(null),[v,x]=S.useState(!1),[C,y]=S.useState(null),[p,m]=S.useState({fullAuto:!1,autoSelectDelay:20}),[k,N]=S.useState(!1);S.useEffect(()=>{const E=localStorage.getItem("rf_theme")||(window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");u(E);const A=localStorage.getItem("rf_view")||"present";f(A)},[]),S.useEffect(()=>{document.documentElement.classList.toggle("dark",a==="dark"),localStorage.setItem("rf_theme",a)},[a]),S.useEffect(()=>{localStorage.setItem("rf_view",d)},[d]);const T=window.SESSION_TOKEN==="{{SESSION_TOKEN}}"?null:window.SESSION_TOKEN,P=T?`/api/history/${T}`:"/api/history",j=T?`/api/events/${T}`:"/api/events",L=T?`/api/submit/${T}`:"/api/submit",V=T?`/api/config/${T}`:"/api/config",W=async()=>{try{const A=await(await fetch(P)).json();if(A.entries){const O=[...A.entries].reverse();t(M=>(M.length===0&&O.length>0&&r(O.length-1),O));const w=O[O.length-1];w&&(w.event==="INTERACTION_REQUESTED"||w.event==="PROMPT_REQUESTED")?g(w):g(null)}A.workflowName&&l(A.workflowName),A.config&&m(A.config),i("connected")}catch{i("disconnected")}},G=async E=>{try{(await fetch(V,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(E)})).ok&&m(O=>({...O,...E}))}catch(A){console.error("Failed to update config:",A)}},te=S.useRef(0);S.useEffect(()=>{e.length>te.current&&(te.current===0&&e.length>0?(r(e.length-1),x(!1)):n<e.length-1&&x(!0)),te.current=e.length},[e.length,n]),S.useEffect(()=>{if(!C||e.length===0)return;const E=e[e.length-1];if(e.length!==C.historyLength||E!=null&&E.timestamp&&E.timestamp!==C.lastEventTimestamp){if((E==null?void 0:E.event)==="INTERACTION_SUBMITTED"){y(O=>O&&{...O,historyLength:e.length,lastEventTimestamp:(E==null?void 0:E.timestamp)||O.lastEventTimestamp});return}y(null),r(e.length-1)}},[e,C]),S.useEffect(()=>{n===e.length-1&&x(!1)},[n,e.length]),S.useEffect(()=>{W();const E=setInterval(W,3e3),A=new EventSource(j);return A.onmessage=O=>{O.data==="update"&&W()},()=>{clearInterval(E),A.close()}},[]);const ne=()=>r(E=>Math.min(e.length-1,E+1)),ze=()=>r(E=>Math.max(0,E-1));S.useEffect(()=>{const E=A=>{(A.target.tagName==="TEXTAREA"||A.target.tagName==="INPUT"&&A.target.type==="number")&&A.target.className!=="jumper-input"||(A.key==="ArrowRight"&&ne(),A.key==="ArrowLeft"&&ze())};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[e.length]);const H=e[n],Se=H&&(H.event==="INTERACTION_REQUESTED"||H.event==="PROMPT_REQUESTED"),R=h&&Se&&H.slug===h.slug,_=!!C;return c.jsxs("div",{className:"w-full h-[100dvh] flex flex-col relative overflow-hidden bg-bg",children:[c.jsx(Vk,{workflowName:o,status:s,theme:a,toggleTheme:()=>u(E=>E==="dark"?"light":"dark"),viewMode:d,setViewMode:f,history:e,fullAuto:p.fullAuto,onToggleFullAuto:()=>G({fullAuto:!p.fullAuto}),onOpenSettings:()=>N(!0),configDisabled:s!=="connected"}),c.jsx("main",{className:"main-stage overflow-hidden",children:d==="log"?c.jsx(Ak,{history:e,onJump:E=>{r(E),f("present")}}):c.jsx(ok,{mode:"wait",children:c.jsx(q1.div,{initial:{opacity:0,scale:.99,filter:"blur(4px)"},animate:{opacity:1,scale:1,filter:"blur(0px)"},exit:{opacity:0,scale:1.01,filter:"blur(4px)"},transition:{duration:.3,ease:[.16,1,.3,1]},className:"w-full h-full",children:_?c.jsx(zk,{submission:C}):R?c.jsx("div",{className:"content-width h-full",children:c.jsx(Fk,{interaction:h,onSubmit:async(E,A,O)=>{const w=e[e.length-1];y({slug:E,targetKey:A,historyLength:e.length,lastEventTimestamp:(w==null?void 0:w.timestamp)||null});try{const M=await fetch(L,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:E,targetKey:A,response:O})});if(!M.ok)throw new Error(`Submit failed with ${M.status}`)}catch{y(null)}finally{setTimeout(W,1e3)}},disabled:s==="disconnected"||_})}):c.jsx(Lk,{item:H,pageIndex:n,history:e})},n)})}),c.jsx(Dk,{page:n,total:e.length,onNext:ne,onPrev:ze,onJump:r,hasNew:v,onJumpToLatest:()=>r(e.length-1),className:d==="log"?"opacity-0 pointer-events-none":"opacity-100"}),c.jsx(Bk,{isOpen:k,onClose:()=>N(!1),fullAuto:p.fullAuto,onToggleFullAuto:()=>G({fullAuto:!p.fullAuto}),autoSelectDelay:p.autoSelectDelay,onDelayChange:E=>G({autoSelectDelay:E}),onStop:()=>G({stop:!0}),disabled:s!=="connected"})]})}const $k=zh(document.getElementById("root"));$k.render(c.jsx(Uk,{}));
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
|
6
6
|
<title>{{WORKFLOW_NAME}}</title>
|
|
7
|
-
<script type="module" crossorigin src="/remote/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/remote/assets/index-BnuR91vD.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="/remote/assets/index-BHvHkNOe.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
|
@@ -613,8 +613,8 @@ export default function ContentCard({ item, pageIndex = 0, history = [] }) {
|
|
|
613
613
|
: [];
|
|
614
614
|
const promptCountLabel = promptSections.length ? `${promptSections.length} sections` : null;
|
|
615
615
|
|
|
616
|
-
const
|
|
617
|
-
const
|
|
616
|
+
const promptTokenCount = estimateTokensFromText(item.prompt || "");
|
|
617
|
+
const promptMeta = item.prompt ? `~${formatTokenCount(promptTokenCount)}` : "";
|
|
618
618
|
|
|
619
619
|
content = (
|
|
620
620
|
<div className="space-y-10 py-6">
|
|
@@ -651,7 +651,7 @@ export default function ContentCard({ item, pageIndex = 0, history = [] }) {
|
|
|
651
651
|
{contextTitle}
|
|
652
652
|
</div>
|
|
653
653
|
</div>
|
|
654
|
-
{
|
|
654
|
+
{promptMeta ? <div className="text-xs font-mono text-black/50 dark:text-white/50">{promptMeta}</div> : null}
|
|
655
655
|
</summary>
|
|
656
656
|
|
|
657
657
|
{typeof contextData === "string" ? (
|
|
@@ -1232,16 +1232,16 @@ export default function ContentCard({ item, pageIndex = 0, history = [] }) {
|
|
|
1232
1232
|
<div className="text-xs text-black/40 dark:text-white/40">Output</div>
|
|
1233
1233
|
<div className="font-mono font-semibold">{agent.outputTokens.toLocaleString()}</div>
|
|
1234
1234
|
</div>
|
|
1235
|
+
<div className="space-y-0.5">
|
|
1236
|
+
<div className="text-xs text-black/40 dark:text-white/40">Total</div>
|
|
1237
|
+
<div className="font-mono font-semibold">{(agent.inputTokens + agent.outputTokens).toLocaleString()}</div>
|
|
1238
|
+
</div>
|
|
1235
1239
|
{agent.cachedTokens > 0 && (
|
|
1236
1240
|
<div className="space-y-0.5">
|
|
1237
1241
|
<div className="text-xs text-black/40 dark:text-white/40">Cached</div>
|
|
1238
1242
|
<div className="font-mono font-semibold text-black/60 dark:text-white/60">{agent.cachedTokens.toLocaleString()}</div>
|
|
1239
1243
|
</div>
|
|
1240
1244
|
)}
|
|
1241
|
-
<div className="space-y-0.5">
|
|
1242
|
-
<div className="text-xs text-black/40 dark:text-white/40">Total</div>
|
|
1243
|
-
<div className="font-mono font-semibold">{(agent.inputTokens + agent.outputTokens).toLocaleString()}</div>
|
|
1244
|
-
</div>
|
|
1245
1245
|
</div>
|
|
1246
1246
|
</div>
|
|
1247
1247
|
))}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { X, Square } from "lucide-react";
|
|
2
|
-
import { useState } from "react";
|
|
2
|
+
import { useState, useEffect } from "react";
|
|
3
3
|
|
|
4
4
|
export default function SettingsModal({
|
|
5
5
|
isOpen,
|
|
@@ -12,6 +12,12 @@ export default function SettingsModal({
|
|
|
12
12
|
disabled,
|
|
13
13
|
}) {
|
|
14
14
|
const [showStopConfirm, setShowStopConfirm] = useState(false);
|
|
15
|
+
const [localDelay, setLocalDelay] = useState(String(autoSelectDelay));
|
|
16
|
+
|
|
17
|
+
// Sync local state when prop changes (e.g., from remote update)
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
setLocalDelay(String(autoSelectDelay));
|
|
20
|
+
}, [autoSelectDelay]);
|
|
15
21
|
|
|
16
22
|
if (!isOpen) return null;
|
|
17
23
|
|
|
@@ -90,11 +96,20 @@ export default function SettingsModal({
|
|
|
90
96
|
</div>
|
|
91
97
|
<input
|
|
92
98
|
type="number"
|
|
93
|
-
value={
|
|
94
|
-
onChange={(e) =>
|
|
95
|
-
|
|
99
|
+
value={localDelay}
|
|
100
|
+
onChange={(e) => setLocalDelay(e.target.value)}
|
|
101
|
+
onBlur={() => {
|
|
102
|
+
const val = parseInt(localDelay, 10);
|
|
96
103
|
if (!isNaN(val) && val >= 1 && val <= 120) {
|
|
97
104
|
onDelayChange(val);
|
|
105
|
+
} else {
|
|
106
|
+
// Reset to current valid value if invalid
|
|
107
|
+
setLocalDelay(String(autoSelectDelay));
|
|
108
|
+
}
|
|
109
|
+
}}
|
|
110
|
+
onKeyDown={(e) => {
|
|
111
|
+
if (e.key === "Enter") {
|
|
112
|
+
e.target.blur();
|
|
98
113
|
}
|
|
99
114
|
}}
|
|
100
115
|
min={1}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
model: high
|
|
3
|
-
format: json
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Code Fixer Agent
|
|
7
|
-
|
|
8
|
-
You fix specific issues in existing code based on sanity check failures.
|
|
9
|
-
|
|
10
|
-
## Critical Guidelines
|
|
11
|
-
|
|
12
|
-
**DO NOT** disable, skip, or remove failing tests to make them pass.
|
|
13
|
-
Your fixes must address the actual underlying code issues that cause tests to fail.
|
|
14
|
-
|
|
15
|
-
- ❌ Never add `.skip()`, `.todo()`, or comment out tests
|
|
16
|
-
- ❌ Never modify test expectations to match broken behavior
|
|
17
|
-
- ❌ Never delete test files or test cases
|
|
18
|
-
- ❌ Never wrap tests in `try/catch` to swallow errors
|
|
19
|
-
- ✅ Fix the implementation code to pass existing tests
|
|
20
|
-
- ✅ Fix test setup/teardown issues if the tests themselves are misconfigured
|
|
21
|
-
- ✅ Update tests ONLY if the original requirements were misunderstood
|
|
22
|
-
|
|
23
|
-
If the issue truly cannot be fixed within the current architecture, set `"confidence": "low"` and explain why in the analysis.
|
|
24
|
-
|
|
25
|
-
## Input
|
|
26
|
-
- task: Task definition
|
|
27
|
-
- originalImplementation: Current code-writer output
|
|
28
|
-
- sanityCheckResults: Failed checks with specific errors
|
|
29
|
-
- testPlan: Test plan for context
|
|
30
|
-
- previousAttempts: Number of quick-fix attempts so far
|
|
31
|
-
|
|
32
|
-
## Output Format
|
|
33
|
-
|
|
34
|
-
{
|
|
35
|
-
"analysis": {
|
|
36
|
-
"rootCauses": ["What caused each failure"],
|
|
37
|
-
"fixApproach": "Strategy for fixing"
|
|
38
|
-
},
|
|
39
|
-
"fixes": [
|
|
40
|
-
{
|
|
41
|
-
"path": "src/feature.js",
|
|
42
|
-
"operation": "replace",
|
|
43
|
-
"code": "// Full corrected file content"
|
|
44
|
-
}
|
|
45
|
-
],
|
|
46
|
-
"expectedResolutions": ["Which checks should now pass"],
|
|
47
|
-
"confidence": "high|medium|low"
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
Focus on minimal, targeted fixes. Don't rewrite entire files unless necessary.
|
|
File without changes
|