@mndrk/agx 1.4.48 → 1.4.50

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.
Files changed (102) hide show
  1. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/BUILD_ID +1 -1
  2. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/app-build-manifest.json +33 -33
  3. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/app-path-routes-manifest.json +15 -15
  4. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/build-manifest.json +2 -2
  5. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/prerender-manifest.json +18 -18
  6. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  7. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/_not-found.html +2 -2
  8. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/_not-found.rsc +1 -1
  9. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/audit/route_client-reference-manifest.js +1 -1
  10. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/auth/[...nextauth]/route_client-reference-manifest.js +1 -1
  11. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/auth/daemon-secret/route_client-reference-manifest.js +1 -1
  12. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/auth/device/code/route_client-reference-manifest.js +1 -1
  13. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/auth/device/token/route_client-reference-manifest.js +1 -1
  14. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/auth/refresh/route_client-reference-manifest.js +1 -1
  15. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/auth/status/route_client-reference-manifest.js +1 -1
  16. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/domains/[id]/route_client-reference-manifest.js +1 -1
  17. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/domains/route_client-reference-manifest.js +1 -1
  18. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/health/route_client-reference-manifest.js +1 -1
  19. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/learnings/route_client-reference-manifest.js +1 -1
  20. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/logs/stream/route_client-reference-manifest.js +1 -1
  21. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/orchestrator/tasks/[taskId]/cancel/route_client-reference-manifest.js +1 -1
  22. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/orchestrator/tasks/[taskId]/signal/route_client-reference-manifest.js +1 -1
  23. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/orchestrator/tasks/[taskId]/start/route_client-reference-manifest.js +1 -1
  24. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/orchestrator/tasks/[taskId]/status/route_client-reference-manifest.js +1 -1
  25. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/projects/[id]/route_client-reference-manifest.js +1 -1
  26. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/projects/route_client-reference-manifest.js +1 -1
  27. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/providers/route_client-reference-manifest.js +1 -1
  28. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/queue/complete/route_client-reference-manifest.js +1 -1
  29. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/queue/route_client-reference-manifest.js +1 -1
  30. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/stage-prompts/route_client-reference-manifest.js +1 -1
  31. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/comments/[commentId]/route_client-reference-manifest.js +1 -1
  32. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/comments/route_client-reference-manifest.js +1 -1
  33. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/heartbeat/route_client-reference-manifest.js +1 -1
  34. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/history/route_client-reference-manifest.js +1 -1
  35. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/logs/route_client-reference-manifest.js +1 -1
  36. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/route_client-reference-manifest.js +1 -1
  37. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/route_client-reference-manifest.js +1 -1
  38. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/stream/route_client-reference-manifest.js +1 -1
  39. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/user-settings/route_client-reference-manifest.js +1 -1
  40. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/workflows/[id]/nodes/route_client-reference-manifest.js +1 -1
  41. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/workflows/[id]/route_client-reference-manifest.js +1 -1
  42. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/workflows/route_client-reference-manifest.js +1 -1
  43. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/auth/callback/route_client-reference-manifest.js +1 -1
  44. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/auth/device/page.js +5 -5
  45. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/auth/device/page_client-reference-manifest.js +1 -1
  46. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/auth/device.html +1 -1
  47. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/auth/device.rsc +2 -2
  48. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/dashboard/page_client-reference-manifest.js +1 -1
  49. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/dashboard.html +2 -2
  50. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/dashboard.rsc +2 -2
  51. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/index.html +2 -2
  52. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/index.rsc +1 -1
  53. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/login/page_client-reference-manifest.js +1 -1
  54. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/login.html +2 -2
  55. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/login.rsc +1 -1
  56. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/page_client-reference-manifest.js +1 -1
  57. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects/[slug]/page_client-reference-manifest.js +1 -1
  58. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects/[slug]/tasks/page_client-reference-manifest.js +1 -1
  59. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects/[slug]/workflow/page_client-reference-manifest.js +1 -1
  60. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects/page_client-reference-manifest.js +1 -1
  61. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects.html +2 -2
  62. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects.rsc +1 -1
  63. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  64. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/settings.html +2 -2
  65. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/settings.rsc +1 -1
  66. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app-paths-manifest.json +15 -15
  67. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/chunks/2298.js +1 -1
  68. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/middleware-manifest.json +5 -5
  69. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/pages/404.html +1 -1
  70. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/pages/500.html +1 -1
  71. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/server-reference-manifest.js +1 -1
  72. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/server-reference-manifest.json +1 -1
  73. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/{2456-55b0941a94896404.js → 2456-972d3e5278eb4a3a.js} +1 -1
  74. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/app/auth/device/{page-43328dfa9290b99a.js → page-11f3c6743511da7f.js} +1 -1
  75. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/package.json +7 -7
  76. package/lib/cli/cloud/executeVerifySingle.js +1 -0
  77. package/lib/cli/cloud/executeVerifySwarm.js +1 -0
  78. package/lib/cli/cloud/prompts.js +9 -1
  79. package/lib/cli/daemon.js +10 -2
  80. package/lib/executor.js +1 -1
  81. package/lib/storage/locks.js +23 -27
  82. package/package.json +1 -1
  83. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/_error.js +0 -28
  84. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/fallback/amp.js +0 -1015
  85. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/fallback/main-app.js +0 -1893
  86. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/fallback/main.js +0 -1616
  87. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/fallback/pages/_app.js +0 -28
  88. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/fallback/pages/_error.js +0 -28
  89. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/fallback/react-refresh.js +0 -62
  90. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/fallback/webpack.js +0 -1368
  91. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/main.js +0 -1616
  92. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/pages/_app.js +0 -28
  93. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/pages/_error.js +0 -28
  94. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/polyfills.js +0 -1
  95. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/react-refresh.js +0 -62
  96. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/webpack.js +0 -1405
  97. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/development/_buildManifest.js +0 -1
  98. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/development/_ssgManifest.js +0 -1
  99. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/webpack/86bcbfe8b4db248a.webpack.hot-update.json +0 -1
  100. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/webpack/webpack.86bcbfe8b4db248a.hot-update.js +0 -12
  101. /package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/{T941_jYQg-MmdlDwFUCbq → k3DQ286eexSP6rmMlvt13}/_buildManifest.js +0 -0
  102. /package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/{T941_jYQg-MmdlDwFUCbq → k3DQ286eexSP6rmMlvt13}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2456],{2325:(e,t,r)=>{r.d(t,{Tw:()=>o,ls:()=>i,mP:()=>m,ou:()=>u});var a=r(2115);let s={ideation:"\uD83D\uDCA1",planning:"\uD83D\uDCCB",execution:"\uD83D\uDCBB",verification:"\uD83E\uDDEA",done:"✅",coding:"\uD83D\uDCBB",qa:"\uD83E\uDDEA",acceptance:"✓",pr:"\uD83D\uDD00",pr_review:"\uD83D\uDC40",merge:"\uD83D\uDE80"},n={ideation:"var(--warning)",planning:"var(--info)",execution:"var(--primary)",verification:"var(--accent)",done:"var(--success)",coding:"var(--primary)",qa:"var(--accent)",acceptance:"#8b5cf6",pr:"#f97316",pr_review:"#ef4444",merge:"#22c55e"},o=["ideation","planning","execution","verification","done"],i={ideation:{icon:"\uD83D\uDCA1",label:"Ideation",color:"var(--warning)"},planning:{icon:"\uD83D\uDCCB",label:"Planning",color:"var(--info)"},execution:{icon:"\uD83D\uDCBB",label:"Execution",color:"var(--primary)"},verification:{icon:"\uD83E\uDDEA",label:"Verification",color:"var(--accent)"},done:{icon:"✅",label:"Done",color:"var(--success)"}},l="00000000-0000-0000-0000-000000000001",d=[{id:"00000000-0000-0000-0001-000000000001",workflow_id:l,name:"ideation",label:"Ideation",prompt:"Research and scope this. Define approach, estimate effort, list unknowns.",provider:null,model:null,position:0,node_type:"step",created_at:new Date(0).toISOString(),updated_at:new Date(0).toISOString()},{id:"00000000-0000-0000-0001-000000000002",workflow_id:l,name:"planning",label:"Planning",prompt:"Create detailed plan with tasks, milestones, and dependencies.",provider:null,model:null,position:1,node_type:"step",created_at:new Date(0).toISOString(),updated_at:new Date(0).toISOString()},{id:"00000000-0000-0000-0001-000000000003",workflow_id:l,name:"execution",label:"Execution",prompt:"Implement based on the plan. Write clean, tested code.",provider:null,model:null,position:2,node_type:"step",created_at:new Date(0).toISOString(),updated_at:new Date(0).toISOString()},{id:"00000000-0000-0000-0001-000000000004",workflow_id:l,name:"verification",label:"Verification",prompt:"Test thoroughly. Find edge cases. Fix bugs. Verify it works.",provider:null,model:null,position:3,node_type:"gate",created_at:new Date(0).toISOString(),updated_at:new Date(0).toISOString()},{id:"00000000-0000-0000-0001-000000000009",workflow_id:l,name:"done",label:"Done",prompt:"Task completed and shipped.",provider:null,model:null,position:4,node_type:"terminal",created_at:new Date(0).toISOString(),updated_at:new Date(0).toISOString()}],c=[{id:"fallback-ideation-planning",workflow_id:l,from_node:"ideation",to_node:"planning",condition:"done",priority:0,created_at:new Date(0).toISOString()},{id:"fallback-planning-execution",workflow_id:l,from_node:"planning",to_node:"execution",condition:"done",priority:0,created_at:new Date(0).toISOString()},{id:"fallback-execution-verification",workflow_id:l,from_node:"execution",to_node:"verification",condition:"done",priority:0,created_at:new Date(0).toISOString()},{id:"fallback-verification-done",workflow_id:l,from_node:"verification",to_node:"done",condition:"done",priority:0,created_at:new Date(0).toISOString()},{id:"fallback-verification-execution",workflow_id:l,from_node:"verification",to_node:"execution",condition:"failed",priority:1,created_at:new Date(0).toISOString()}],u="00000000-0000-0000-0000-000000000001";function m(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.workflowId||u,[r,m]=(0,a.useState)(null),[x,p]=(0,a.useState)(!0),[h,v]=(0,a.useState)(null),f=(0,a.useCallback)(async()=>{p(!0),v(null);try{var e;let r=await fetch("/api/workflows/".concat(t));if(!r.ok)throw Error("Failed to fetch workflow: ".concat(r.statusText));let a=await r.json(),s=null!=(e=a.workflow)?e:a,n=Array.isArray(s.nodes)?s.nodes:[];Array.isArray(s.transitions)&&s.transitions,n&&0!==n.length||t!==l?m(s):m({...s,nodes:d,transitions:c})}catch(e){console.error("Error fetching workflow:",e),v(e instanceof Error?e:Error(String(e)))}finally{p(!1)}},[t]);(0,a.useEffect)(()=>{f()},[f]);let g=(0,a.useMemo)(()=>{var e;return(null==r||null==(e=r.nodes)?void 0:e.length)?r.nodes.slice().sort((e,t)=>e.position-t.position).map(e=>e.name):[...o]},[r]),b=(0,a.useMemo)(()=>{var e;if(!(null==r||null==(e=r.nodes)?void 0:e.length))return i;let t={};for(let e of r.nodes)t[e.name]={icon:s[e.name]||"\uD83D\uDCCC",label:e.label||e.name.charAt(0).toUpperCase()+e.name.slice(1),color:n[e.name]||"var(--primary)"};return t},[r]),j=(0,a.useMemo)(()=>(null==r?void 0:r.transitions)||[],[r]),N=(0,a.useCallback)((e,t)=>{var a;if(e===t)return!0;if(!(null==r||null==(a=r.nodes)?void 0:a.length)){let r=o.indexOf(e),a=o.indexOf(t);return a<r||a===r+1}let s=g.indexOf(e),n=g.indexOf(t);return!!(n<s||j.some(r=>r.from_node===e&&r.to_node===t))||n===s+1},[r,g,j]);return{workflow:r,stages:g,stageConfig:b,transitions:j,isLoading:x,error:h,refetch:f,isValidTransition:N}}},5826:(e,t,r)=>{r.d(t,{A:()=>O});var a=r(5155),s=r(2115),n=r(4357);function o(e){let{comments:t,onAddComment:r,onDeleteComment:n}=e,[o,i]=(0,s.useState)(""),[l,d]=(0,s.useState)(!1),[c,u]=(0,s.useState)(!1),[m,x]=(0,s.useState)(null),p=async e=>{if(e.preventDefault(),o.trim()&&!c){u(!0);try{await r(o),i(""),d(!1)}finally{u(!1)}}},h=async e=>{if(n&&!m&&confirm("Are you sure you want to delete this comment?")){x(e);try{await n(e)}catch(e){console.error("Failed to delete comment:",e)}finally{x(null)}}};return(0,a.jsxs)("div",{className:"space-y-4",children:[l?(0,a.jsxs)("form",{onSubmit:p,className:"space-y-3 animate-fade-in-up",children:[(0,a.jsx)("textarea",{value:o,onChange:e=>i(e.target.value),placeholder:"Add context, decisions, or guidance...",className:"input resize-none h-24 focus:ring-2 focus:ring-[var(--primary)]/20",autoFocus:!0,disabled:c}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("button",{type:"submit",disabled:!o.trim()||c,className:"btn-primary px-4 py-2 flex items-center gap-2",children:c?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"spinner w-4 h-4 border-2 border-white/20 border-t-white"}),"Adding..."]}):"Add Comment"}),(0,a.jsx)("button",{type:"button",onClick:()=>{d(!1),i("")},disabled:c,className:"btn-ghost px-4 py-2",children:"Cancel"})]})]}):(0,a.jsx)("button",{onClick:()=>d(!0),className:"w-full py-3 border-2 border-dashed border-[var(--card-border)] rounded-xl text-[var(--muted-foreground)] hover:text-[var(--foreground)] hover:border-[var(--primary)] hover:bg-[var(--primary-muted)] transition-all duration-200 text-sm font-medium focus-visible:outline-2 focus-visible:outline-[var(--ring)] focus-visible:outline-offset-2",children:(0,a.jsxs)("span",{className:"flex items-center justify-center gap-2",children:[(0,a.jsx)("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),"Add comment"]})}),0===t.length?(0,a.jsxs)("div",{className:"text-center py-12 animate-fade-in",children:[(0,a.jsx)("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-[var(--background)] border border-[var(--card-border)] mb-3",children:(0,a.jsx)("span",{className:"text-xl opacity-50",children:"\uD83D\uDCDD"})}),(0,a.jsx)("p",{className:"text-[var(--muted-foreground)] text-sm",children:"No comments yet"}),(0,a.jsx)("p",{className:"text-[var(--muted-foreground)] text-xs mt-1",children:"Add context and guidance for this task"})]}):(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("div",{className:"timeline-line"}),(0,a.jsx)("div",{className:"space-y-4",children:t.map((e,t)=>(0,a.jsxs)("div",{className:"timeline-item relative pl-7 animate-fade-in-up",style:{animationDelay:"".concat(50*t,"ms")},children:[(0,a.jsx)("div",{className:"timeline-dot"}),(0,a.jsxs)("div",{className:"card p-4 hover:border-[var(--primary)]/30 group",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs text-[var(--muted-foreground)] tabular-nums",children:new Date(e.created_at).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}),e.author_type&&(0,a.jsx)("span",{className:"text-[10px] uppercase tracking-wide text-[var(--muted-foreground)]",children:e.author_type})]}),n&&"user"===e.author_type&&(0,a.jsx)("button",{onClick:()=>h(e.id),disabled:m===e.id,className:"opacity-0 group-hover:opacity-100 transition-opacity text-[var(--muted-foreground)] hover:text-[var(--destructive)] p-1 rounded",title:"Delete comment",children:m===e.id?(0,a.jsx)("span",{className:"spinner w-3 h-3 border-2 border-current border-t-transparent"}):(0,a.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]}),(0,a.jsx)("p",{className:"text-sm whitespace-pre-wrap leading-relaxed",children:e.content})]})]},e.id))})]})]})}var i=r(577);let l={30:"#94a3b8",31:"#f87171",32:"#4ade80",33:"#facc15",34:"#60a5fa",35:"#c084fc",36:"#22d3ee",37:"#e2e8f0",90:"#64748b",91:"#ef4444",92:"#22c55e",93:"#eab308",94:"#3b82f6",95:"#a855f7",96:"#06b6d4",97:"#f8fafc"},d=/\u001b\[([0-9;]*)m/g,c=/(^|\s)\[((?:\d{1,3};)*\d{1,3})m(\s|$)/g;function u(e){return Math.max(0,Math.min(255,e))}function m(e){let{taskId:t,status:r}=e,[n,o]=(0,s.useState)(!1),[m,x]=(0,s.useState)(!1),{output:p,isLoading:h,isStreaming:v}=(0,i.zH)(t,{enabled:n,tail:500,maxChars:2e5}),f=(0,s.useRef)(null);(0,s.useEffect)(()=>{n&&f.current&&(f.current.scrollTop=f.current.scrollHeight)},[p,n]);let g=p||(h?"Loading logs...":"in_progress"===r?"Waiting for live output...":"No output yet."),b=(0,s.useMemo)(()=>n?function(e){if(!e)return[];let t=e.replace(c,(e,t,r,a)=>t&&a?" ":t||a||""),r=[],a={},s=0;for(let e of t.matchAll(d)){var n;let o=null!=(n=e.index)?n:0;if(o>s){let e=t.slice(s,o);r.push({text:e,style:Object.keys(a).length?{...a}:void 0})}a=function(e,t){let r={...e},a=(t||"0").split(";").map(e=>Number.parseInt(e,10)).filter(e=>Number.isFinite(e));for(let e=0;e<a.length;e+=1){let t=a[e];if(0===t){delete r.color,delete r.fontStyle,delete r.fontWeight,delete r.textDecoration;continue}if(1===t){r.fontWeight=700;continue}if(3===t){r.fontStyle="italic";continue}if(4===t){r.textDecoration="underline";continue}if(22===t){delete r.fontWeight;continue}if(23===t){delete r.fontStyle;continue}if(24===t){delete r.textDecoration;continue}if(39===t){delete r.color;continue}if(38===t){let t=a[e+1];if(5===t&&Number.isFinite(a[e+2]))r.color=function(e){let t=Math.max(0,Math.min(255,e));if(t<16)return l[[30,31,32,33,34,35,36,37,90,91,92,93,94,95,96,97][t]]||"#e2e8f0";if(t>=232){let e=Math.round((t-232)/23*255);return"rgb(".concat(e,", ").concat(e,", ").concat(e,")")}let r=t-16,a=Math.floor(r/36),s=Math.floor(r%36/6),n=e=>0===e?0:40*e+55;return"rgb(".concat(n(a),", ").concat(n(s),", ").concat(n(r%6),")")}(a[e+2]),e+=2;else if(2===t&&Number.isFinite(a[e+2])&&Number.isFinite(a[e+3])&&Number.isFinite(a[e+4])){let t=u(a[e+2]),s=u(a[e+3]),n=u(a[e+4]);r.color="rgb(".concat(t,", ").concat(s,", ").concat(n,")"),e+=4}continue}l[t]&&(r.color=l[t])}return r}(a,e[1]||"0"),s=o+e[0].length}return s<t.length&&r.push({text:t.slice(s),style:Object.keys(a).length?{...a}:void 0}),function(e){if(!e.length)return e;let t=[];for(let r of e){if(!r.text)continue;let e=t[t.length-1],a=!!e&&JSON.stringify(e.style||null)===JSON.stringify(r.style||null);e&&a?e.text+=r.text:t.push({text:r.text,style:r.style?{...r.style}:void 0})}return t}(r)}(g):[],[g,n]);return(0,a.jsxs)("div",{className:"border-t border-[var(--card-border)] pt-8",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>o(e=>!e),className:"w-full flex items-center justify-between text-xs font-semibold uppercase tracking-wider text-[var(--muted-foreground)]","aria-expanded":n,children:[(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{children:"Terminal Stream"}),v&&(0,a.jsx)("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-emerald-500/15 text-emerald-400 border border-emerald-500/30",children:"Live"})]}),(0,a.jsx)("span",{className:"text-[10px] text-[var(--muted-foreground)]",children:n?"Collapse":"Expand"})]}),n&&(0,a.jsxs)("div",{className:"mt-4 rounded-xl border border-[var(--card-border)] bg-[#0b0f14] shadow-inner transition-all duration-300 ease-in-out",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-white/10 text-[10px] uppercase tracking-widest text-white/60",children:[(0,a.jsx)("span",{children:"Run Log"}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("span",{className:"font-mono text-[10px]",children:v?"Streaming":"Idle"}),(0,a.jsx)("button",{onClick:()=>x(!m),className:"hover:text-white transition-colors p-1",title:m?"Collapse View":"Expand View",children:m?(0,a.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,a.jsx)("path",{d:"M8 3v3a2 2 0 0 1-2 2H3"}),(0,a.jsx)("path",{d:"M21 8h-3a2 2 0 0 1-2-2V3"}),(0,a.jsx)("path",{d:"M3 16h3a2 2 0 0 1 2 2v3"}),(0,a.jsx)("path",{d:"M16 21v-3a2 2 0 0 1 2-2h3"})]}):(0,a.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,a.jsx)("path",{d:"M15 3h6v6"}),(0,a.jsx)("path",{d:"M9 21H3v-6"}),(0,a.jsx)("path",{d:"M21 3l-7 7"}),(0,a.jsx)("path",{d:"M3 21l7-7"})]})})]})]}),(0,a.jsx)("div",{ref:f,className:"".concat(m?"max-h-[70vh]":"max-h-64"," overflow-y-auto px-3 py-3 font-mono text-xs text-slate-200 whitespace-pre-wrap leading-relaxed transition-all duration-300 ease-in-out"),children:b.map((e,t)=>(0,a.jsx)("span",{style:e.style,children:e.text},"".concat(t,"-").concat(e.text.length)))})]})]})}let x={task:{label:"This Task",icon:"\uD83D\uDCCC",color:"var(--primary)",bgColor:"var(--primary-muted)",description:"Specific to this task only"},project:{label:"Project",icon:"\uD83D\uDCC1",color:"var(--accent)",bgColor:"var(--accent-muted)",description:"Applies to the whole project"},global:{label:"Playbook",icon:"\uD83D\uDCD6",color:"var(--warning)",bgColor:"var(--warning-muted)",description:"Universal best practices"}};function p(e){var t,r;let{learnings:n,taskId:o,projectContext:i,onAddLearning:l,compact:d=!1}=e,[c,u]=(0,s.useState)(!1),[m,p]=(0,s.useState)(""),[h,v]=(0,s.useState)("task"),[f,g]=(0,s.useState)(!1),b=(null==i?void 0:i.project)?[i.project.id,i.project.slug].filter(Boolean):[],j=(null==i||null==(t=i.project)?void 0:t.name)||(null==i||null==(r=i.project)?void 0:r.slug)||"Project",N=async e=>{if(e.preventDefault(),m.trim()&&!f){g(!0);try{let e="project"===h?b[0]:void 0;await l(m,h,e),p(""),u(!1)}finally{g(!1)}}},y=n.filter(e=>"task"===e.scope&&e.scope_id===o),w=b.length?n.filter(e=>"project"===e.scope&&e.scope_id&&b.includes(e.scope_id)):[],k=n.filter(e=>"global"===e.scope),_=(e,t,r)=>{let s=x[e];return(0,a.jsxs)("div",{className:d?"mb-4":"mb-6",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 ".concat(d?"mb-2":"mb-3"),children:[(0,a.jsx)("span",{className:"w-5 h-5 rounded-lg flex items-center justify-center text-xs",style:{backgroundColor:s.bgColor},children:s.icon}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h4",{className:"text-xs font-semibold",style:{color:s.color},children:r||s.label}),!d&&(0,a.jsx)("p",{className:"text-[10px] text-[var(--muted-foreground)]",children:s.description})]})]}),0===t.length?(0,a.jsx)("p",{className:"text-[10px] text-[var(--muted-foreground)] py-2 text-center bg-[var(--background)] rounded-lg border border-dashed border-[var(--card-border)]",children:"No learnings yet"}):(0,a.jsx)("ul",{className:"space-y-1.5",children:t.map((e,t)=>(0,a.jsx)("li",{className:"text-xs bg-[var(--background)] rounded-lg ".concat(d?"p-2":"p-3"," border border-[var(--card-border)]\n hover:border-[color-mix(in_srgb,var(--primary)_30%,var(--card-border))] \n transition-colors animate-fade-in-up"),style:{animationDelay:"".concat(30*t,"ms")},children:e.content},e.id))})]})};return(0,a.jsxs)("div",{children:[!d&&(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,a.jsx)("span",{className:"text-lg",children:"\uD83D\uDCA1"}),(0,a.jsx)("h3",{className:"text-lg font-semibold",children:"Learnings"}),(0,a.jsx)("span",{className:"text-xs text-[var(--muted-foreground)] bg-[var(--muted)] px-2 py-0.5 rounded-full",children:n.length})]}),c?(0,a.jsxs)("form",{onSubmit:N,className:"".concat(d?"mb-3":"mb-5"," space-y-2 animate-fade-in-up"),children:[(0,a.jsx)("textarea",{value:m,onChange:e=>p(e.target.value),placeholder:"What did you learn?",className:"input resize-none ".concat(d?"h-16 text-xs":"h-20 text-sm"),autoFocus:!0,disabled:f}),(0,a.jsx)("div",{className:"flex gap-1",children:["task","project","global"].map(e=>{let t=x[e],r=h===e,s="project"===e&&0===b.length;return(0,a.jsxs)("button",{type:"button",onClick:()=>v(e),disabled:s,className:"\n flex-1 flex items-center justify-center gap-1 px-1.5 py-1 text-[10px] font-medium rounded-lg\n transition-all duration-200\n ".concat(r?"text-white shadow-md":"bg-[var(--background)] text-[var(--muted-foreground)] hover:text-[var(--foreground)]","\n ").concat(s?"opacity-40 cursor-not-allowed":"","\n "),style:r?{backgroundColor:t.color,boxShadow:"0 2px 8px -2px ".concat(t.color,"60")}:void 0,children:[(0,a.jsx)("span",{children:t.icon}),!d&&(0,a.jsx)("span",{children:t.label})]},e)})}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("button",{type:"submit",disabled:!m.trim()||f,className:"btn-primary px-2 py-1 text-xs flex items-center gap-1.5",children:f?"...":"Add"}),(0,a.jsx)("button",{type:"button",onClick:()=>{u(!1),p("")},disabled:f,className:"btn-ghost px-2 py-1 text-xs",children:"Cancel"})]})]}):(0,a.jsx)("button",{onClick:()=>u(!0),className:"w-full ".concat(d?"py-2 mb-3":"py-3 mb-5"," border-2 border-dashed border-[var(--card-border)] rounded-xl \n text-[var(--muted-foreground)] hover:text-[var(--foreground)] \n hover:border-[var(--primary)] hover:bg-[var(--primary-muted)]\n transition-all duration-200 text-xs font-medium"),children:(0,a.jsxs)("span",{className:"flex items-center justify-center gap-2",children:[(0,a.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),"Add learning"]})}),_("task",y),b.length>0&&_("project",w,"Project: ".concat(j)),_("global",k,"Global Playbook")]})}let h=[{id:"ideation",icon:"\uD83D\uDCA1",label:"Ideation",prompt:"Research and scope. Define approach, estimate effort.",color:"var(--warning)"},{id:"planning",icon:"\uD83D\uDCCB",label:"Planning",prompt:"Create detailed plan with tasks, milestones, and dependencies.",color:"var(--info)"},{id:"execution",icon:"\uD83D\uDCBB",label:"Execution",prompt:"Implement based on plan. Write clean, tested code.",color:"var(--primary)"},{id:"verification",icon:"\uD83E\uDDEA",label:"Verification",prompt:"Test thoroughly. Find edge cases. Fix bugs. Verify against requirements.",color:"var(--accent)"},{id:"done",icon:"✅",label:"Done",prompt:"Task finished and shipped.",color:"var(--success)"}];function v(e){let{currentStage:t,onStageChange:r,readonly:s,size:n="md",stageDecisions:o,stages:i}=e,l=i||h,d=t?l.findIndex(e=>e.id===t):-1;return(0,a.jsx)("div",{className:"flex items-center gap-1 flex-wrap",role:"tablist","aria-label":"Task stages",children:l.map((e,i)=>{let c=e.id===t,u=d>i,m=!s&&r,x=null==o?void 0:o[e.id],p=["".concat(e.label,": ").concat(e.prompt||"")];return(null==x?void 0:x.decision)&&p.push("Decision: ".concat(x.decision)),(null==x?void 0:x.rationale)&&p.push("Rationale: ".concat(x.rationale)),(0,a.jsxs)("button",{onClick:()=>m&&r(e.id),disabled:s,title:p.join(" | "),role:"tab","aria-selected":c,"aria-disabled":s,className:"\n group relative flex items-center gap-1.5 rounded-lg font-medium\n transition-all duration-200 select-none\n focus-visible:outline-2 focus-visible:outline-[var(--ring)] focus-visible:outline-offset-2\n ".concat("sm"===n?"px-2 py-1 text-[10px]":"px-3 py-1.5 text-xs","\n ").concat(c?"text-white shadow-md":u?"bg-[var(--success-muted)] text-[var(--success)]":d<i&&-1!==d?"bg-[var(--background)] text-[var(--muted-foreground)] opacity-50":"bg-[var(--background)] text-[var(--muted-foreground)]","\n ").concat(m&&!c?"hover:bg-[var(--card-border)] hover:text-[var(--foreground)] cursor-pointer":"","\n ").concat(s?"cursor-default":"","\n "),style:c?{backgroundColor:e.color,boxShadow:"0 4px 14px -3px ".concat(e.color,"40")}:void 0,children:[(0,a.jsx)("span",{className:"".concat("sm"===n?"text-xs":"text-sm"," ").concat(c?"":"opacity-80"),children:e.icon}),(0,a.jsx)("span",{className:"hidden lg:inline",children:e.label}),i<l.length-1&&(0,a.jsx)("span",{className:"\n absolute -right-1 top-1/2 -translate-y-1/2 w-2 h-0.5 \n ".concat(u||c?"bg-[var(--success)]":"bg-[var(--card-border)]","\n transition-colors duration-300 hidden lg:block\n ")}),(0,a.jsx)("span",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-2 py-1 text-[10px] font-normal whitespace-nowrap bg-[var(--card-bg)] text-[var(--foreground)] border border-[var(--card-border)] rounded-md shadow-lg opacity-0 group-hover:opacity-100 pointer-events-none transition-opacity duration-200 lg:hidden z-50",children:e.label})]},e.id)})})}var f=r(8661),g=r.n(f),b=r(154),j=r(758),N=r(7004),y=r(6135),w=r(5226);let k=e=>{let{editor:t}=e;return t?(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-1 p-2 border-b border-[var(--card-border)] mb-2 sticky top-0 bg-[var(--card-bg)] z-10 opacity-90 backdrop-blur-sm",children:[(0,a.jsx)("button",{onClick:()=>t.chain().focus().toggleBold().run(),disabled:!t.can().chain().focus().toggleBold().run(),className:"p-1.5 rounded hover:bg-[var(--muted)] ".concat(t.isActive("bold")?"bg-[var(--muted)] text-[var(--foreground)]":"text-[var(--muted-foreground)]"),title:"Bold",children:(0,a.jsx)("span",{className:"font-bold font-serif",children:"B"})}),(0,a.jsx)("button",{onClick:()=>t.chain().focus().toggleItalic().run(),disabled:!t.can().chain().focus().toggleItalic().run(),className:"p-1.5 rounded hover:bg-[var(--muted)] ".concat(t.isActive("italic")?"bg-[var(--muted)] text-[var(--foreground)]":"text-[var(--muted-foreground)]"),title:"Italic",children:(0,a.jsx)("span",{className:"italic font-serif",children:"I"})}),(0,a.jsx)("button",{onClick:()=>t.chain().focus().toggleStrike().run(),disabled:!t.can().chain().focus().toggleStrike().run(),className:"p-1.5 rounded hover:bg-[var(--muted)] ".concat(t.isActive("strike")?"bg-[var(--muted)] text-[var(--foreground)]":"text-[var(--muted-foreground)]"),title:"Strike",children:(0,a.jsx)("span",{className:"line-through font-serif",children:"S"})}),(0,a.jsx)("div",{className:"w-px h-4 bg-[var(--card-border)] mx-1"}),(0,a.jsx)("button",{onClick:()=>t.chain().focus().toggleCode().run(),disabled:!t.can().chain().focus().toggleCode().run(),className:"p-1.5 rounded hover:bg-[var(--muted)] ".concat(t.isActive("code")?"bg-[var(--muted)] text-[var(--foreground)]":"text-[var(--muted-foreground)]"),title:"Code",children:(0,a.jsx)("span",{className:"font-mono text-xs",children:"<>"})}),(0,a.jsx)("button",{onClick:()=>t.chain().focus().toggleCodeBlock().run(),className:"p-1.5 rounded hover:bg-[var(--muted)] ".concat(t.isActive("codeBlock")?"bg-[var(--muted)] text-[var(--foreground)]":"text-[var(--muted-foreground)]"),title:"Code Block",children:(0,a.jsx)("span",{className:"font-mono text-xs",children:"CB"})}),(0,a.jsx)("div",{className:"w-px h-4 bg-[var(--card-border)] mx-1"}),(0,a.jsx)("button",{onClick:()=>t.chain().focus().toggleHeading({level:1}).run(),className:"p-1.5 rounded hover:bg-[var(--muted)] ".concat(t.isActive("heading",{level:1})?"bg-[var(--muted)] text-[var(--foreground)]":"text-[var(--muted-foreground)]"),title:"H1",children:(0,a.jsx)("span",{className:"font-bold text-xs",children:"H1"})}),(0,a.jsx)("button",{onClick:()=>t.chain().focus().toggleHeading({level:2}).run(),className:"p-1.5 rounded hover:bg-[var(--muted)] ".concat(t.isActive("heading",{level:2})?"bg-[var(--muted)] text-[var(--foreground)]":"text-[var(--muted-foreground)]"),title:"H2",children:(0,a.jsx)("span",{className:"font-bold text-xs",children:"H2"})}),(0,a.jsx)("button",{onClick:()=>t.chain().focus().toggleHeading({level:3}).run(),className:"p-1.5 rounded hover:bg-[var(--muted)] ".concat(t.isActive("heading",{level:3})?"bg-[var(--muted)] text-[var(--foreground)]":"text-[var(--muted-foreground)]"),title:"H3",children:(0,a.jsx)("span",{className:"font-bold text-xs",children:"H3"})}),(0,a.jsx)("div",{className:"w-px h-4 bg-[var(--card-border)] mx-1"}),(0,a.jsx)("button",{onClick:()=>t.chain().focus().toggleBulletList().run(),className:"p-1.5 rounded hover:bg-[var(--muted)] ".concat(t.isActive("bulletList")?"bg-[var(--muted)] text-[var(--foreground)]":"text-[var(--muted-foreground)]"),title:"Bullet List",children:(0,a.jsx)("span",{className:"text-xs",children:"• List"})}),(0,a.jsx)("button",{onClick:()=>t.chain().focus().toggleOrderedList().run(),className:"p-1.5 rounded hover:bg-[var(--muted)] ".concat(t.isActive("orderedList")?"bg-[var(--muted)] text-[var(--foreground)]":"text-[var(--muted-foreground)]"),title:"Ordered List",children:(0,a.jsx)("span",{className:"text-xs",children:"1. List"})}),(0,a.jsx)("button",{onClick:()=>t.chain().focus().toggleBlockquote().run(),className:"p-1.5 rounded hover:bg-[var(--muted)] ".concat(t.isActive("blockquote")?"bg-[var(--muted)] text-[var(--foreground)]":"text-[var(--muted-foreground)]"),title:"Quote",children:(0,a.jsx)("span",{className:"text-xs serif italic",children:'""'})})]}):null};function _(e){let{content:t,editable:r=!0,onChange:n,onBlur:o,placeholder:i="Add a description..."}=e,l=(0,b.hG)({extensions:[j.A,y.Ay.configure({openOnClick:!1}),N.A.configure({placeholder:i,emptyEditorClass:"is-editor-empty before:content-[attr(data-placeholder)] before:text-[var(--muted-foreground)] before:float-left before:pointer-events-none before:h-0"}),w.o.configure({html:!1,transformPastedText:!0,transformCopiedText:!0})],immediatelyRender:!1,content:t,editable:r,editorProps:{attributes:{class:"prose prose-sm max-w-none focus:outline-none min-h-[100px] text-[var(--foreground)]"}},onUpdate:e=>{let{editor:t}=e;null==n||n(t.storage.markdown.getMarkdown())},onBlur:()=>{null==o||o()}});return(0,s.useEffect)(()=>{l&&t!==l.storage.markdown.getMarkdown()&&!l.isFocused&&l.commands.setContent(t)},[t,l]),(0,a.jsxs)("div",{className:"jsx-cdf669dd826a0677 relative group",children:[r&&(0,a.jsx)(k,{editor:l}),(0,a.jsx)(b.$Z,{editor:l,className:"rich-text-editor"}),(0,a.jsx)(g(),{id:"cdf669dd826a0677",children:".rich-text-editor .ProseMirror{min-height:100px;outline:none}.rich-text-editor .ProseMirror p{margin-bottom:.75em;line-height:1.6}.rich-text-editor .ProseMirror h1{font-size:1.5em;font-weight:700;margin-top:1em;margin-bottom:.5em}.rich-text-editor .ProseMirror h2{font-size:1.25em;font-weight:600;margin-top:1em;margin-bottom:.5em}.rich-text-editor .ProseMirror h3{font-size:1.1em;font-weight:600;margin-top:1em;margin-bottom:.5em}.rich-text-editor .ProseMirror ul{list-style-type:disc;padding-left:1.5em;margin-bottom:.75em}.rich-text-editor .ProseMirror ol{list-style-type:decimal;padding-left:1.5em;margin-bottom:.75em}.rich-text-editor .ProseMirror blockquote{border-left:3px solid var(--card-border);padding-left:1em;font-style:italic;color:var(--muted-foreground)}.rich-text-editor .ProseMirror pre{background:var(--muted);padding:.75em;border-radius:var(--radius-sm);font-family:monospace;overflow-x:auto;margin-bottom:.75em}.rich-text-editor .ProseMirror code{background:var(--muted);padding:.2em .4em;border-radius:var(--radius-sm);font-family:monospace;font-size:.85em}.rich-text-editor .ProseMirror a{color:var(--primary);text-decoration:underline}"})]})}var C=r(91),S=r(2619),D=r.n(S);function A(e){var t,r,s;let{projectContext:n,fallbackProjectSlug:o}=e,i=(null==n?void 0:n.project)||null,l=null!=(t=null==n?void 0:n.repos)?t:[],d=null!=(r=null==n?void 0:n.learnings)?r:[],c=(s=null==i?void 0:i.metadata)&&"object"==typeof s?Object.entries(s).filter(e=>{let[t]=e;return!!t}):[];if(!i)return(0,a.jsxs)("div",{className:"p-4 rounded-2xl border border-dashed border-[var(--card-border)] bg-[var(--card-bg)]/60 space-y-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs font-semibold uppercase tracking-wide text-[var(--muted-foreground)]",children:"Project Context"}),(0,a.jsx)("p",{className:"text-sm text-[var(--muted-foreground)]",children:o?'Task is tagged with "'.concat(o,'" but no structured project context is available yet.'):"This task is not connected to a project. Link it to unlock repo maps, CI/CD notes, and project learnings."})]}),(0,a.jsx)(D(),{href:"/projects",className:"inline-flex items-center justify-center text-xs font-semibold px-3 py-1.5 rounded-full border border-[var(--card-border)] hover:border-[var(--primary)] hover:text-[var(--primary)] transition-colors",children:"Manage Projects"})]});let u=d.slice(0,3),m=d.length-u.length;return(0,a.jsxs)("div",{className:"p-4 rounded-2xl border border-[var(--card-border)] bg-[var(--card-bg)] space-y-4",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs font-semibold uppercase tracking-wide text-[var(--muted-foreground)]",children:"Project Context"}),(0,a.jsx)("h3",{className:"text-base font-semibold leading-tight mt-1",children:i.name}),(0,a.jsx)("p",{className:"text-[11px] uppercase tracking-wide text-[var(--muted-foreground)]",children:i.slug})]}),(0,a.jsx)(D(),{href:"/projects",className:"text-[11px] font-semibold px-2 py-1 rounded-full border border-[var(--card-border)] hover:border-[var(--primary)] hover:text-[var(--primary)] transition-colors",children:"View"})]}),i.description&&(0,a.jsx)("p",{className:"text-sm text-[var(--foreground)] whitespace-pre-line",children:i.description}),i.ci_cd_info&&(0,a.jsxs)("div",{className:"text-xs space-y-1",children:[(0,a.jsx)("p",{className:"font-semibold text-[var(--muted-foreground)] uppercase tracking-wide",children:"CI / CD"}),(0,a.jsx)("p",{className:"text-[var(--foreground)] text-sm",children:i.ci_cd_info})]}),c.length>0&&(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-[var(--muted-foreground)] mb-2",children:"Metadata"}),(0,a.jsx)("dl",{className:"space-y-1.5",children:c.map(e=>{let[t,r]=e;return(0,a.jsxs)("div",{className:"flex items-start justify-between gap-2 text-xs",children:[(0,a.jsx)("dt",{className:"font-semibold text-[var(--foreground)]",children:t}),(0,a.jsx)("dd",{className:"text-[var(--muted-foreground)] text-right max-w-[160px]",children:"string"==typeof r?r:JSON.stringify(r)})]},t)})})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.jsx)("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-[var(--muted-foreground)]",children:"Repository Map"}),(0,a.jsx)("span",{className:"text-[11px] text-[var(--muted-foreground)]",children:l.length?"".concat(l.length," connected"):"None"})]}),0===l.length?(0,a.jsx)("p",{className:"text-xs text-[var(--muted-foreground)]",children:"Add repositories to help agents navigate local and remote paths."}):(0,a.jsx)("ul",{className:"space-y-2",children:l.map(e=>(0,a.jsxs)("li",{className:"p-2 rounded-xl border border-[var(--card-border)] bg-[var(--background)] space-y-1 text-xs",children:[(0,a.jsx)("p",{className:"font-semibold text-[var(--foreground)]",children:e.name}),e.path&&(0,a.jsxs)("p",{className:"text-[var(--muted-foreground)]",children:["Path: ",e.path]}),e.git_url&&(0,a.jsxs)("p",{className:"text-[var(--muted-foreground)] break-all",children:["Repo: ",(0,a.jsx)("span",{className:"text-[var(--primary)]",children:e.git_url})]}),e.notes&&(0,a.jsxs)("p",{className:"text-[var(--muted-foreground)]",children:["Notes: ",e.notes]})]},e.id||e.name))})]}),d.length>0&&(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-[var(--muted-foreground)] mb-2",children:"Project Learnings"}),(0,a.jsx)("ul",{className:"space-y-1 text-xs text-[var(--foreground)]",children:u.map((e,t)=>(0,a.jsxs)("li",{className:"leading-relaxed",children:["• ",e]},"".concat(e,"-").concat(t)))}),m>0&&(0,a.jsxs)("p",{className:"text-[11px] text-[var(--muted-foreground)] mt-1",children:["+",m," more learnings in the panel below"]})]})]})}var M=r(8545);let L={queued:{label:"Queued",color:"var(--status-queued)",bgColor:"var(--status-queued-bg)"},in_progress:{label:"In Progress",color:"var(--status-in-progress)",bgColor:"var(--status-in-progress-bg)"},blocked:{label:"Blocked",color:"var(--status-blocked)",bgColor:"var(--status-blocked-bg)"},completed:{label:"Completed",color:"var(--status-completed)",bgColor:"var(--status-completed-bg)"},failed:{label:"Failed",color:"var(--status-failed)",bgColor:"var(--status-failed-bg)"}},I=["queued","in_progress","blocked","completed","failed"];function P(e){if(!e)return"N/A";let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function T(e){let t=(e.log_type||"output").toLowerCase();return"output"===t?e.content||"":"[".concat(t,"] ").concat(e.content||"")}function O(e){var t,r,i,l,d,c,u,x,f,g,b,j;let{task:N,comments:y,learnings:w,projectContext:k,projects:S,stage_config:D,stages:O,isDraft:F=!1,isCreating:B=!1,onClose:H,onAddComment:W,onDeleteComment:q,onAddLearning:R,onUpdate:z,onDelete:V}=e,{providers:U}=(0,M.u)(),{projects:Q}=(0,C.Y)(),Y=S||Q,G=O||h,[J,$]=(0,s.useState)(!1),[Z,K]=(0,s.useState)(!1),[X,ee]=(0,s.useState)(!1),[et,er]=(0,s.useState)(""),[ea,es]=(0,s.useState)(null),[en,eo]=(0,s.useState)(!1),[ei,el]=(0,s.useState)(N.provider||""),[ed,ec]=(0,s.useState)(N.model||""),[eu,em]=(0,s.useState)(null!=(d=N.swarm)&&d),[ex,ep]=(0,s.useState)([]),[eh,ev]=(0,s.useState)("gemini"),[ef,eg]=(0,s.useState)(""),[eb,ej]=(0,s.useState)(!1),[eN,ey]=(0,s.useState)(null),ew=N.resolved_provider||(null==D?void 0:D.provider)||"gemini",ek=N.resolved_model||(null==D?void 0:D.model)||"",e_=null!=(u=null!=(c=N.swarm)?c:null==D?void 0:D.swarm)&&u;N.resolved_swarm_models||null==D||D.swarm_models;let eC=null!=(x=null!=k?k:N.project_context)?x:null,eS=null!=(g=null!=(f=null==eC||null==(t=eC.project)?void 0:t.slug)?f:N.project)?g:null,[eD,eA]=(0,s.useState)(N.title||""),[eM,eL]=(0,s.useState)(""),eI=e=>{let t=e.match(/^---\n[\s\S]*?\n---\n([\s\S]*)$/);return t?t[1]:e};(0,s.useEffect)(()=>{var e;el(N.provider||""),ec(N.model||""),em(null!=(e=N.swarm)&&e),ep(Array.isArray(N.swarm_models)?N.swarm_models.filter(e=>e&&"string"==typeof e.provider&&"string"==typeof e.model).map(e=>({provider:e.provider.trim(),model:e.model.trim()})).filter(e=>e.provider&&e.model):[])},[N.provider,N.model,N.swarm,N.swarm_models,N.id]),(0,s.useEffect)(()=>{eA(N.title||"")},[N.title,N.id]),(0,s.useEffect)(()=>{var e;eL(null!=(e=N.description)?e:eI(N.content||""))},[N.content,N.description,N.id]),(0,s.useEffect)(()=>{let e=!1;if("failed"!==N.status){er(""),es(null),eo(!1);return}return(async()=>{eo(!0),es(null);try{let t=await fetch("/api/tasks/".concat(N.id,"/logs?tail=200")),r=await t.json().catch(()=>({}));if(!t.ok)throw Error((null==r?void 0:r.error)||"Failed to load logs (".concat(t.status,")"));let a=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2e4,r=Array.isArray(e)?e:[];if(!r.length)return"";let a=r.slice().sort((e,t)=>e.created_at===t.created_at?e.id.localeCompare(t.id):e.created_at.localeCompare(t.created_at)),s=a.filter(e=>"error"===(e.log_type||"").toLowerCase()),n=a.filter(e=>{let t=String(e.content||"");return t.includes("[execution/")&&(t.includes("stderr_tail:")||t.includes("stdout_tail:")||t.includes(" phase error")||t.includes(" error=")||t.includes(" exit="))}),o=(s.length>0?s.slice(-8):n.length>0?n.slice(-4):a.slice(-12)).map(T).join("\n");return o?o.length>t?o.slice(-t):o:""}((null==r?void 0:r.logs)||[]);e||er(a)}catch(t){e||es(t instanceof Error?t.message:String(t))}finally{e||eo(!1)}})(),()=>{e=!0}},[N.id,N.status]);let eP=async()=>{ee(!0);try{await (null==V?void 0:V())}finally{ee(!1),K(!1)}},eT=(0,n.YQ)(async e=>{var t;F||e===(null!=(t=N.description)?t:eI(N.content||""))||await z({description:e})},1e3),eO=(0,n.YQ)(async e=>{if(!F&&e!==(N.title||"")){ej(!0);try{await z({title:e})}finally{ej(!1)}}},1e3),eE=(0,n.YQ)(async e=>{ej(!0),ey(null);try{await z(e)}catch(e){ey(e instanceof Error?e.message:"Failed to update settings")}finally{ej(!1)}},1e3),eF=async e=>{let t="done"===e?"completed":"ideation"===e?"queued":"in_progress";if(F)return void await z({stage:e,status:t});await z({stage:e,status:t})},eB=async e=>{if(!e)return void await z({project:null,project_id:null});let t=Y.find(t=>t.id===e);t&&await z({project:t.slug,project_id:t.id})},eH=async()=>{try{await eq("queued")}catch(e){console.error("Failed to retry task",e)}},eW=async()=>{try{await eq("queued")}catch(e){console.error("Failed to unblock task",e)}},eq=async e=>{let t={status:e};"queued"===e&&(t.started_at=null,t.completed_at=null,t.error=void 0),"completed"!==e&&"failed"!==e&&"blocked"!==e||N.completed_at||(t.completed_at=new Date().toISOString()),await z(t)};L[N.status||"queued"];let eR=N.stage_decisions||{},ez=N.stage?eR[N.stage]:void 0,eV=function(e,t){if(!e||"object"!=typeof e)return null;let r=Object.entries(e).filter(e=>{let[,r]=e;return!!(r&&t(r))}).sort((e,t)=>{var r,a;let s=Date.parse((null==(r=e[1])?void 0:r.decided_at)||""),n=Date.parse((null==(a=t[1])?void 0:a.decided_at)||"");return(Number.isNaN(n)?0:n)-(Number.isNaN(s)?0:s)});if(!r.length)return null;let[a,s]=r[0];return{stage:a,decision:s}}(eR,e=>"failed"===e.decision),eU=Object.entries(eR).filter(e=>{let[,t]=e;return(null==t?void 0:t.decision)==="blocked"}).sort((e,t)=>{var r,a;let s=Date.parse((null==(r=e[1])?void 0:r.decided_at)||""),n=Date.parse((null==(a=t[1])?void 0:a.decided_at)||"");return(Number.isNaN(n)?0:n)-(Number.isNaN(s)?0:s)})[0],eQ=(null==ez?void 0:ez.decision)==="blocked"?N.stage:null==eU?void 0:eU[0],eY=eQ&&eR[eQ]?eR[eQ]:void 0,eG=null==eY?void 0:eY.rationale,eJ="string"==typeof N.error&&N.error.trim()?N.error.trim():((null==eV||null==(r=eV.decision)?void 0:r.rationale)||(null==eV||null==(i=eV.decision)?void 0:i.final_result)||"").trim()||"Task marked failed.";return(0,a.jsx)("div",{className:"modal-backdrop",onClick:e=>e.target===e.currentTarget&&H(),children:(0,a.jsxs)("div",{className:"bg-[var(--card-bg)] w-full max-w-[1200px] h-[90vh] rounded-xl shadow-2xl overflow-hidden flex flex-col animate-scale-in border border-[var(--card-border)] m-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-6 py-4 border-b border-[var(--card-border)] bg-[var(--card-bg)]",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("span",{className:"text-[var(--muted-foreground)] font-mono text-sm",children:F?"New Task":N.slug||N.id.slice(0,6)}),!F&&(0,a.jsx)(v,{currentStage:N.stage,onStageChange:eF,stageDecisions:N.stage_decisions,stages:G})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[F&&(0,a.jsx)("button",{onClick:()=>{var e,t;if(!eM.trim())return;let r="done"===N.stage?"completed":"ideation"===N.stage?"queued":"in_progress";z({title:eD,description:eM,stage:N.stage,status:r,project:null!=(e=N.project)?e:null,project_id:null!=(t=N.project_id)?t:null,provider:ei||void 0,model:ed||void 0,swarm:eu,swarm_models:eu?ex:[]})},disabled:B||!eM.trim(),className:"btn-primary px-4 py-2 rounded-md text-sm font-medium disabled:opacity-50 disabled:cursor-not-allowed",children:B?"Creating...":"Create Task"}),!F&&eb&&(0,a.jsxs)("span",{className:"text-[10px] text-[var(--muted-foreground)] animate-pulse flex items-center gap-1 mr-2",children:[(0,a.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--primary)]"}),"Saving..."]}),!F&&V&&(0,a.jsx)("button",{onClick:()=>K(!0),className:"btn-ghost p-2 rounded hover:bg-[var(--destructive-muted)] hover:text-[var(--destructive)]",title:"Delete Task",children:(0,a.jsx)("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})}),(0,a.jsx)("button",{onClick:H,className:"btn-ghost p-2 rounded",title:"Close (Esc)",children:(0,a.jsx)("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),Z&&(0,a.jsx)("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 rounded-xl animate-fade-in",children:(0,a.jsxs)("div",{className:"modal-content p-6 max-w-sm mx-4 animate-scale-in bg-[var(--card-bg)]",children:[(0,a.jsx)("h3",{className:"text-lg font-bold mb-2",children:"Delete Task?"}),(0,a.jsxs)("p",{className:"text-[var(--muted-foreground)] text-sm mb-6",children:["Are you sure you want to delete ",(0,a.jsx)("strong",{className:"text-[var(--foreground)]",children:N.slug||N.id.slice(0,6)}),"? This cannot be undone."]}),(0,a.jsxs)("div",{className:"flex justify-end gap-3",children:[(0,a.jsx)("button",{onClick:()=>K(!1),disabled:X,className:"btn-ghost",children:"Cancel"}),(0,a.jsx)("button",{onClick:eP,disabled:X,className:"btn-destructive px-4 py-2 rounded-md",children:X?"Deleting...":"Delete"})]})]})}),(0,a.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,a.jsx)("div",{className:"flex-1 overflow-y-auto scrollbar-thin",children:(0,a.jsxs)("div",{className:"max-w-3xl mx-auto p-8",children:[!F&&"failed"===N.status&&(0,a.jsxs)("div",{className:"mb-8 p-4 rounded-lg bg-[var(--status-failed-bg)] border border-[var(--status-failed)] text-[var(--status-failed)]",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,a.jsx)("span",{className:"font-bold text-sm uppercase tracking-wider",children:"Task Execution Failed"})]}),(0,a.jsx)("button",{onClick:eH,className:"btn-ghost px-3 py-1 text-xs font-bold bg-white/20 rounded hover:bg-white/30 transition-colors uppercase",children:"Retry Task"})]}),(0,a.jsx)("p",{className:"text-sm font-medium",children:eJ}),(0,a.jsxs)("div",{className:"mt-3 text-xs rounded-md border border-[var(--status-failed)]/40 bg-white/50 p-3",children:[(0,a.jsx)("h4",{className:"font-semibold uppercase tracking-wider mb-2",children:"Failure Metadata"}),(0,a.jsxs)("div",{className:"grid grid-cols-[140px_1fr] gap-x-3 gap-y-1.5",children:[(0,a.jsx)("span",{className:"opacity-70",children:"Stage"}),(0,a.jsx)("span",{className:"font-medium",children:N.stage||(null==eV?void 0:eV.stage)||"N/A"}),(0,a.jsx)("span",{className:"opacity-70",children:"Exit Code"}),(0,a.jsx)("span",{className:"font-mono",children:null!=(b=N.exit_code)?b:"N/A"}),(0,a.jsx)("span",{className:"opacity-70",children:"PID"}),(0,a.jsx)("span",{className:"font-mono",children:null!=(j=N.pid)?j:"N/A"}),(0,a.jsx)("span",{className:"opacity-70",children:"Completed At"}),(0,a.jsx)("span",{className:"font-medium",children:P(N.completed_at)}),(null==eV?void 0:eV.decision)&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"opacity-70",children:"Decision"}),(0,a.jsx)("span",{className:"font-medium",children:eV.decision.decision}),(0,a.jsx)("span",{className:"opacity-70",children:"Rationale"}),(0,a.jsx)("span",{className:"font-medium break-words",children:eV.decision.rationale||"N/A"}),(0,a.jsx)("span",{className:"opacity-70",children:"Final Result"}),(0,a.jsx)("span",{className:"font-medium break-words",children:eV.decision.final_result||"N/A"}),(0,a.jsx)("span",{className:"opacity-70",children:"Decided At"}),(0,a.jsx)("span",{className:"font-medium",children:P(eV.decision.decided_at)})]})]})]}),(en||et||ea)&&(0,a.jsxs)("details",{className:"mt-3",open:!0,children:[(0,a.jsx)("summary",{className:"cursor-pointer select-none text-xs font-semibold uppercase tracking-wider opacity-90",children:"Error Details"}),(0,a.jsxs)("div",{className:"mt-2 rounded-md border border-[var(--status-failed)]/40 bg-[#0b0f14] text-slate-200",children:[(0,a.jsxs)("div",{className:"px-3 py-2 border-b border-white/10 text-[10px] uppercase tracking-widest text-white/60 flex items-center justify-between",children:[(0,a.jsx)("span",{children:"Log Excerpt"}),(0,a.jsx)("span",{className:"font-mono",children:en?"Loading...":ea?"Unavailable":"Ready"})]}),(0,a.jsx)("pre",{className:"px-3 py-3 text-xs font-mono whitespace-pre-wrap max-h-64 overflow-y-auto",children:ea?"Failed to load error details: ".concat(ea):et||"No error logs found."})]})]})]}),!F&&"blocked"===N.status&&(0,a.jsxs)("div",{className:"mb-8 p-4 rounded-lg bg-[var(--status-blocked-bg)] border border-[var(--status-blocked)] text-[var(--status-blocked)]",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"})}),(0,a.jsx)("span",{className:"font-bold text-sm uppercase tracking-wider",children:"Task Blocked"})]}),(0,a.jsx)("button",{onClick:eW,className:"btn-ghost px-3 py-1 text-xs font-bold bg-white/20 rounded hover:bg-white/30 transition-colors uppercase",children:"Unblock Task"})]}),(0,a.jsx)("p",{className:"text-sm opacity-90 pl-7 mb-4",children:eG||"Task is blocked and requires manual intervention."}),(0,a.jsxs)("div",{className:"ml-7 text-xs rounded-md border border-[var(--status-blocked)]/40 bg-white/50 p-3",children:[(0,a.jsx)("h4",{className:"font-semibold uppercase tracking-wider mb-2",children:"Blocked Metadata"}),(0,a.jsxs)("div",{className:"grid grid-cols-[140px_1fr] gap-x-3 gap-y-1.5",children:[(0,a.jsx)("span",{className:"opacity-70",children:"Decision Stage"}),(0,a.jsx)("span",{className:"font-medium",children:eQ||N.stage||"N/A"}),(0,a.jsx)("span",{className:"opacity-70",children:"Decision"}),(0,a.jsx)("span",{className:"font-medium",children:(null==eY?void 0:eY.decision)||"blocked"}),(0,a.jsx)("span",{className:"opacity-70",children:"Final Result"}),(0,a.jsx)("span",{className:"font-medium break-words",children:(null==eY?void 0:eY.final_result)||"N/A"}),(0,a.jsx)("span",{className:"opacity-70",children:"Rationale"}),(0,a.jsx)("span",{className:"font-medium break-words",children:(null==eY?void 0:eY.rationale)||"N/A"}),(0,a.jsx)("span",{className:"opacity-70",children:"Decided At"}),(0,a.jsx)("span",{className:"font-medium",children:P(null==eY?void 0:eY.decided_at)}),(0,a.jsx)("span",{className:"opacity-70",children:"Workflow ID"}),(0,a.jsx)("span",{className:"font-mono break-all",children:N.workflow_id||"N/A"}),(0,a.jsx)("span",{className:"opacity-70",children:"Workflow Run ID"}),(0,a.jsx)("span",{className:"font-mono break-all",children:N.workflow_run_id||"N/A"}),(0,a.jsx)("span",{className:"opacity-70",children:"Orchestration Status"}),(0,a.jsx)("span",{className:"font-medium",children:N.orchestration_status||"N/A"}),(0,a.jsx)("span",{className:"opacity-70",children:"Last Orchestration Update"}),(0,a.jsx)("span",{className:"font-medium",children:P(N.last_orchestration_update)}),(0,a.jsx)("span",{className:"opacity-70",children:"Started At"}),(0,a.jsx)("span",{className:"font-medium",children:P(N.started_at)}),(0,a.jsx)("span",{className:"opacity-70",children:"Completed At"}),(0,a.jsx)("span",{className:"font-medium",children:P(N.completed_at)})]})]})]}),(0,a.jsx)("input",{type:"text",value:eD,onChange:e=>{var t;eA(t=e.target.value),F||eO(t)},placeholder:"Task title...",className:"w-full text-2xl font-bold bg-transparent border-none outline-none text-[var(--foreground)] placeholder:text-[var(--muted-foreground)]/50 mb-4"}),(0,a.jsx)("div",{className:"mb-12 min-h-[150px]",children:(0,a.jsx)(_,{content:eM,onChange:e=>{eL(e),F||eT(e)},placeholder:F?"Describe the task...":"Add more detail to this task..."})}),!F&&(0,a.jsx)(m,{taskId:N.id,status:N.status}),!F&&N.history&&N.history.length>0&&(0,a.jsxs)("div",{className:"mt-12 border-t border-[var(--card-border)] pt-8",children:[(0,a.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-wider text-[var(--muted-foreground)] mb-4",children:"Execution History"}),(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)("table",{className:"w-full text-sm text-left",children:[(0,a.jsx)("thead",{className:"text-xs text-[var(--muted-foreground)] border-b border-[var(--card-border)]",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"py-2 pr-4 font-medium",children:"Started"}),(0,a.jsx)("th",{className:"py-2 pr-4 font-medium",children:"Duration"}),(0,a.jsx)("th",{className:"py-2 pr-4 font-medium",children:"PID"}),(0,a.jsx)("th",{className:"py-2 pr-4 font-medium",children:"Exit Code"})]})}),(0,a.jsx)("tbody",{className:"divide-y divide-[var(--card-border)]",children:N.history.map(e=>{var t,r;return(0,a.jsxs)("tr",{className:"hover:bg-[var(--muted)]/20 transition-colors",children:[(0,a.jsx)("td",{className:"py-2 pr-4 font-mono text-xs opacity-80",children:e.started_at?new Date(e.started_at).toLocaleString():"N/A"}),(0,a.jsx)("td",{className:"py-2 pr-4 font-mono text-xs opacity-80",children:e.started_at&&e.completed_at?function(e,t){let r=t.getTime()-e.getTime();if(r<1e3)return"".concat(r,"ms");let a=Math.floor(r/1e3);if(a<60)return"".concat(a,"s");let s=Math.floor(a/60);return"".concat(s,"m ").concat(a%60,"s")}(new Date(e.started_at),new Date(e.completed_at)):"-"}),(0,a.jsx)("td",{className:"py-2 pr-4 font-mono text-xs opacity-80",children:null!=(t=e.pid)?t:"-"}),(0,a.jsx)("td",{className:"py-2 pr-4",children:(0,a.jsx)("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium border ".concat(0===e.exit_code?"bg-[var(--status-completed-bg)] text-[var(--status-completed)] border-[var(--status-completed)]/20":"bg-[var(--status-failed-bg)] text-[var(--status-failed)] border-[var(--status-failed)]/20"),children:null!=(r=e.exit_code)?r:"-"})})]},e.id)})})]})})]}),!F&&(0,a.jsxs)("div",{className:"border-t border-[var(--card-border)] pt-8",children:[(0,a.jsxs)("h3",{className:"text-xs font-semibold uppercase tracking-wider text-[var(--muted-foreground)] mb-6 flex items-center justify-between",children:[(0,a.jsx)("span",{children:"Comments"}),(0,a.jsx)("span",{className:"text-[10px] bg-[var(--muted)] px-2 py-0.5 rounded-full",children:y.length})]}),(0,a.jsx)(o,{comments:y,onAddComment:W,onDeleteComment:q})]})]})}),(0,a.jsxs)("div",{className:"w-80 border-l border-[var(--card-border)] bg-[var(--muted)]/20 overflow-y-auto scrollbar-thin p-6 flex flex-col gap-8 flex-shrink-0",children:[(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{className:"text-sm text-[var(--muted-foreground)]",children:"Stage"}),(0,a.jsx)("select",{value:N.stage,onChange:e=>eF(e.target.value),className:"text-sm font-medium bg-[var(--card-bg)] border border-[var(--card-border)] rounded px-2 py-1 focus:border-[var(--primary)] outline-none transition-colors cursor-pointer",children:G.map(e=>(0,a.jsx)("option",{value:e.id,children:e.label},e.id))})]}),!F&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{className:"text-sm text-[var(--muted-foreground)]",children:"Status"}),(0,a.jsx)("select",{value:N.status||"queued",onChange:e=>eq(e.target.value),className:"text-sm font-medium bg-[var(--card-bg)] border border-[var(--card-border)] rounded px-2 py-1 focus:border-[var(--primary)] outline-none transition-colors cursor-pointer",children:I.map(e=>(0,a.jsx)("option",{value:e,children:L[e].label},e))})]}),(0,a.jsx)(E,{label:"ID",value:N.id}),N.slug&&(0,a.jsx)(E,{label:"Slug",value:N.slug,truncate:!0})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{className:"text-sm text-[var(--muted-foreground)]",children:"Project"}),(0,a.jsxs)("select",{value:N.project_id||(null==(l=Y.find(e=>e.slug===N.project))?void 0:l.id)||"",onChange:e=>eB(e.target.value),className:"text-sm font-medium bg-[var(--card-bg)] border border-[var(--card-border)] rounded px-2 py-1 focus:border-[var(--primary)] outline-none transition-colors cursor-pointer max-w-[150px] truncate",children:[(0,a.jsx)("option",{value:"",children:"None"}),Y.map(e=>(0,a.jsx)("option",{value:e.id,children:e.name},e.id))]})]}),!F&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{className:"text-sm text-[var(--muted-foreground)]",children:"Provider"}),(0,a.jsx)("span",{className:"text-sm font-medium",children:e_?"Swarm":ew||"Default"})]}),void 0!==N.pid&&null!==N.pid&&(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{className:"text-sm text-[var(--muted-foreground)]",children:"PID"}),(0,a.jsx)("span",{className:"text-sm font-mono font-medium",title:"Process ID",children:N.pid})]}),void 0!==N.exit_code&&null!==N.exit_code&&(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{className:"text-sm text-[var(--muted-foreground)]",children:"Exit Code"}),(0,a.jsx)("span",{className:"text-sm font-mono font-medium ".concat(0===N.exit_code?"text-[var(--status-completed)]":"text-[var(--status-failed)]"),children:N.exit_code})]})]})]}),(0,a.jsx)("div",{className:"w-full h-px bg-[var(--card-border)]"}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)("div",{className:"flex items-center justify-between",children:(0,a.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wider text-[var(--muted-foreground)]",children:"Execution"})}),(0,a.jsxs)("div",{className:"flex items-center justify-between bg-[var(--card-bg)] p-2 rounded border border-[var(--card-border)]",children:[(0,a.jsx)("span",{className:"text-sm font-medium",children:"Swarm Mode"}),(0,a.jsx)("button",{onClick:()=>(e=>{em(e);let t={swarm:e};e?t.swarm_models=ex:(t.provider=ei,t.model=ed),z(t)})(!eu),className:"w-10 h-5 rounded-full transition-colors relative ".concat(eu?"bg-[var(--primary)]":"bg-[var(--muted-foreground)]/30"),children:(0,a.jsx)("span",{className:"absolute top-0.5 left-0.5 w-4 h-4 bg-white rounded-full transition-transform ".concat(eu?"translate-x-5":"translate-x-0")})})]}),eu?(0,a.jsxs)("div",{className:"space-y-3 animate-fade-in",children:[(0,a.jsx)("label",{className:"block text-xs text-[var(--muted-foreground)]",children:"Swarm Models"}),(0,a.jsxs)("div",{className:"grid gap-2",children:[(0,a.jsxs)("div",{className:"grid grid-cols-[1fr_1.2fr_auto] gap-2",children:[(0,a.jsx)("select",{value:eh,onChange:e=>ev(e.target.value),className:"text-sm bg-[var(--card-bg)] border border-[var(--card-border)] rounded px-2 py-1.5 focus:border-[var(--primary)] outline-none transition-colors appearance-none",children:U.map(e=>(0,a.jsx)("option",{value:e.id,children:e.label},e.id))}),(0,a.jsx)("input",{value:ef,onChange:e=>eg(e.target.value),placeholder:"model name",className:"text-sm bg-[var(--card-bg)] border border-[var(--card-border)] rounded px-2 py-1.5 focus:border-[var(--primary)] outline-none transition-colors"}),(0,a.jsx)("button",{type:"button",onClick:()=>{let e=ef.trim();if(!e)return;let t={provider:eh,model:e};if(ex.some(e=>e.provider.toLowerCase()===t.provider.toLowerCase()&&e.model.toLowerCase()===t.model.toLowerCase()))return;let r=[...ex,t];if(ep(r),eg(""),F)return void z({swarm_models:r});eu&&eE({swarm_models:r})},className:"px-3 py-1.5 text-xs font-semibold rounded-md bg-[var(--card-bg)] border border-[var(--card-border)] hover:border-[var(--muted-foreground)]",children:"Add"})]}),ex.length>0&&(0,a.jsx)("div",{className:"space-y-1",children:ex.map((e,t)=>(0,a.jsxs)("div",{className:"flex items-center justify-between px-2 py-1.5 rounded text-sm border bg-[var(--card-bg)] border-[var(--card-border)]",children:[(0,a.jsxs)("span",{className:"truncate",children:[(0,a.jsx)("span",{className:"text-[var(--muted-foreground)]",children:e.provider}),(0,a.jsx)("span",{className:"mx-1",children:"\xb7"}),(0,a.jsx)("span",{children:e.model})]}),(0,a.jsx)("button",{type:"button",onClick:()=>(e=>{let t=ex.filter((t,r)=>r!==e);if(ep(t),F)return void z({swarm_models:t});eu&&eE({swarm_models:t})})(t),className:"text-xs text-[var(--destructive)] hover:underline",children:"Remove"})]},"".concat(e.provider,"-").concat(e.model,"-").concat(t)))})]})]}):(0,a.jsxs)("div",{className:"space-y-3 animate-fade-in",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-xs text-[var(--muted-foreground)] mb-1.5",children:"Provider"}),(0,a.jsxs)("select",{value:ei,onChange:e=>(e=>{if(el(e),F)return void z({provider:e});z({provider:e})})(e.target.value),className:"w-full text-sm bg-[var(--card-bg)] border border-[var(--card-border)] rounded px-2 py-1.5 focus:border-[var(--primary)] outline-none transition-colors appearance-none",children:[(0,a.jsxs)("option",{value:"",children:["Default (",ew,")"]}),U.map(e=>(0,a.jsx)("option",{value:e.id,children:e.label},e.id))]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-xs text-[var(--muted-foreground)] mb-1.5",children:"Model"}),(0,a.jsx)("input",{value:ed,onChange:e=>(e=>{if(ec(e),F)return void z({model:e});eE({model:e})})(e.target.value),placeholder:"Default (".concat(ek||"unspecified",")"),className:"w-full text-sm bg-[var(--card-bg)] border border-[var(--card-border)] rounded px-2 py-1.5 focus:border-[var(--primary)] outline-none transition-colors"})]})]}),eN&&(0,a.jsx)("p",{className:"text-xs text-[var(--destructive)]",children:eN})]}),!F&&(0,a.jsx)("div",{className:"w-full h-px bg-[var(--card-border)]"}),!F&&(0,a.jsx)(A,{projectContext:eC,fallbackProjectSlug:eS}),!F&&(0,a.jsx)("div",{className:"w-full h-px bg-[var(--card-border)]"}),!F&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("button",{onClick:()=>$(!J),className:"w-full flex items-center justify-between p-3 rounded-lg border transition-all duration-200 ".concat(J?"bg-[var(--primary-muted)] border-[var(--primary)] text-[var(--primary)]":"bg-[var(--card-bg)] border-[var(--card-border)] hover:border-[var(--muted-foreground)]"),children:[(0,a.jsx)("span",{className:"text-sm font-medium",children:"Learnings"}),(0,a.jsx)("span",{className:"text-xs bg-[var(--background)] px-2 py-0.5 rounded-full border border-[var(--card-border)]",children:w.length})]}),J&&(0,a.jsx)("div",{className:"mt-4 animate-fade-in-up",children:(0,a.jsx)(p,{learnings:w,taskId:N.id,projectContext:eC,onAddLearning:R,compact:!0})})]}),!F&&(0,a.jsx)("div",{className:"mt-auto text-xs text-[var(--muted-foreground)]",children:(0,a.jsxs)("p",{children:["Created ",new Date(N.created_at||Date.now()).toLocaleDateString()]})})]})]})]})})}function E(e){let{label:t,value:r,truncate:n,mono:o=!0}=e,[i,l]=(0,s.useState)(!1);return(0,a.jsxs)("div",{className:"flex items-center justify-between group h-7",children:[(0,a.jsx)("span",{className:"text-sm text-[var(--muted-foreground)]",children:t}),(0,a.jsxs)("button",{onClick:()=>{navigator.clipboard.writeText(r),l(!0),setTimeout(()=>l(!1),2e3)},className:"text-sm ".concat(o?"font-mono":""," flex items-center gap-1.5 hover:bg-[var(--primary-muted)] hover:text-[var(--primary)] px-1.5 py-0.5 -mr-1.5 rounded transition-all"),title:"Click to copy",children:[(0,a.jsx)("span",{className:"".concat(n?"max-w-[140px] truncate":""," ").concat(i?"opacity-50":""),children:n&&r.length>20?r.slice(0,8)+"..."+r.slice(-8):r}),i?(0,a.jsx)("span",{className:"text-[10px] uppercase font-bold tracking-wider text-[var(--primary)] animate-scale-in",children:"Copied"}):(0,a.jsx)("svg",{className:"w-3.5 h-3.5 opacity-0 group-hover:opacity-60 transition-opacity",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})]})]})}},8545:(e,t,r)=>{r.d(t,{u:()=>n});var a=r(2115);let s=[{id:"gemini",label:"Gemini"},{id:"claude",label:"Claude"},{id:"ollama",label:"Ollama"},{id:"codex",label:"Codex"}];function n(){let[e,t]=(0,a.useState)(s),[r,n]=(0,a.useState)(!0);(0,a.useEffect)(()=>{let e=!1;return(async()=>{try{let r=await fetch("/api/providers"),a=await r.json().catch(()=>({}));if(!r.ok)throw Error((null==a?void 0:a.error)||"HTTP ".concat(r.status));let s=(Array.isArray(null==a?void 0:a.providers)?a.providers:[]).filter(e=>e&&"string"==typeof e.id&&"string"==typeof e.label).map(e=>({id:e.id,label:e.label}));!e&&s.length>0&&t(s)}catch(e){}finally{e||n(!1)}})(),()=>{e=!0}},[]);let o=(0,a.useMemo)(()=>e.map(e=>e.id),[e]);return{providers:e,providerIds:o,loading:r}}}}]);
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2456],{2325:(e,t,r)=>{r.d(t,{Tw:()=>o,ls:()=>i,mP:()=>m,ou:()=>u});var a=r(2115);let s={ideation:"\uD83D\uDCA1",planning:"\uD83D\uDCCB",execution:"\uD83D\uDCBB",verification:"\uD83E\uDDEA",done:"✅",coding:"\uD83D\uDCBB",qa:"\uD83E\uDDEA",acceptance:"✓",pr:"\uD83D\uDD00",pr_review:"\uD83D\uDC40",merge:"\uD83D\uDE80"},n={ideation:"var(--warning)",planning:"var(--info)",execution:"var(--primary)",verification:"var(--accent)",done:"var(--success)",coding:"var(--primary)",qa:"var(--accent)",acceptance:"#8b5cf6",pr:"#f97316",pr_review:"#ef4444",merge:"#22c55e"},o=["ideation","planning","execution","verification","done"],i={ideation:{icon:"\uD83D\uDCA1",label:"Ideation",color:"var(--warning)"},planning:{icon:"\uD83D\uDCCB",label:"Planning",color:"var(--info)"},execution:{icon:"\uD83D\uDCBB",label:"Execution",color:"var(--primary)"},verification:{icon:"\uD83E\uDDEA",label:"Verification",color:"var(--accent)"},done:{icon:"✅",label:"Done",color:"var(--success)"}},l="00000000-0000-0000-0000-000000000001",d=[{id:"00000000-0000-0000-0001-000000000001",workflow_id:l,name:"ideation",label:"Ideation",prompt:"Research and scope this. Define approach, estimate effort, list unknowns.",provider:null,model:null,position:0,node_type:"step",created_at:new Date(0).toISOString(),updated_at:new Date(0).toISOString()},{id:"00000000-0000-0000-0001-000000000002",workflow_id:l,name:"planning",label:"Planning",prompt:"Create detailed plan with tasks, milestones, and dependencies.",provider:null,model:null,position:1,node_type:"step",created_at:new Date(0).toISOString(),updated_at:new Date(0).toISOString()},{id:"00000000-0000-0000-0001-000000000003",workflow_id:l,name:"execution",label:"Execution",prompt:"Implement based on the plan. Write clean, tested code.",provider:null,model:null,position:2,node_type:"step",created_at:new Date(0).toISOString(),updated_at:new Date(0).toISOString()},{id:"00000000-0000-0000-0001-000000000004",workflow_id:l,name:"verification",label:"Verification",prompt:"Test thoroughly. Find edge cases. Fix bugs. Verify it works.",provider:null,model:null,position:3,node_type:"gate",created_at:new Date(0).toISOString(),updated_at:new Date(0).toISOString()},{id:"00000000-0000-0000-0001-000000000009",workflow_id:l,name:"done",label:"Done",prompt:"Task completed and shipped.",provider:null,model:null,position:4,node_type:"terminal",created_at:new Date(0).toISOString(),updated_at:new Date(0).toISOString()}],c=[{id:"fallback-ideation-planning",workflow_id:l,from_node:"ideation",to_node:"planning",condition:"done",priority:0,created_at:new Date(0).toISOString()},{id:"fallback-planning-execution",workflow_id:l,from_node:"planning",to_node:"execution",condition:"done",priority:0,created_at:new Date(0).toISOString()},{id:"fallback-execution-verification",workflow_id:l,from_node:"execution",to_node:"verification",condition:"done",priority:0,created_at:new Date(0).toISOString()},{id:"fallback-verification-done",workflow_id:l,from_node:"verification",to_node:"done",condition:"done",priority:0,created_at:new Date(0).toISOString()},{id:"fallback-verification-execution",workflow_id:l,from_node:"verification",to_node:"execution",condition:"failed",priority:1,created_at:new Date(0).toISOString()}],u="00000000-0000-0000-0000-000000000001";function m(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.workflowId||u,[r,m]=(0,a.useState)(null),[x,p]=(0,a.useState)(!0),[h,v]=(0,a.useState)(null),f=(0,a.useCallback)(async()=>{p(!0),v(null);try{var e;let r=await fetch("/api/workflows/".concat(t));if(!r.ok)throw Error("Failed to fetch workflow: ".concat(r.statusText));let a=await r.json(),s=null!=(e=a.workflow)?e:a,n=Array.isArray(s.nodes)?s.nodes:[];Array.isArray(s.transitions)&&s.transitions,n&&0!==n.length||t!==l?m(s):m({...s,nodes:d,transitions:c})}catch(e){console.error("Error fetching workflow:",e),v(e instanceof Error?e:Error(String(e)))}finally{p(!1)}},[t]);(0,a.useEffect)(()=>{f()},[f]);let g=(0,a.useMemo)(()=>{var e;return(null==r||null==(e=r.nodes)?void 0:e.length)?r.nodes.slice().sort((e,t)=>e.position-t.position).map(e=>e.name):[...o]},[r]),b=(0,a.useMemo)(()=>{var e;if(!(null==r||null==(e=r.nodes)?void 0:e.length))return i;let t={};for(let e of r.nodes)t[e.name]={icon:s[e.name]||"\uD83D\uDCCC",label:e.label||e.name.charAt(0).toUpperCase()+e.name.slice(1),color:n[e.name]||"var(--primary)"};return t},[r]),j=(0,a.useMemo)(()=>(null==r?void 0:r.transitions)||[],[r]),N=(0,a.useCallback)((e,t)=>{var a;if(e===t)return!0;if(!(null==r||null==(a=r.nodes)?void 0:a.length)){let r=o.indexOf(e),a=o.indexOf(t);return a<r||a===r+1}let s=g.indexOf(e),n=g.indexOf(t);return!!(n<s||j.some(r=>r.from_node===e&&r.to_node===t))||n===s+1},[r,g,j]);return{workflow:r,stages:g,stageConfig:b,transitions:j,isLoading:x,error:h,refetch:f,isValidTransition:N}}},5826:(e,t,r)=>{r.d(t,{A:()=>O});var a=r(5155),s=r(2115),n=r(4357);function o(e){let{comments:t,onAddComment:r,onDeleteComment:n}=e,[o,i]=(0,s.useState)(""),[l,d]=(0,s.useState)(!1),[c,u]=(0,s.useState)(!1),[m,x]=(0,s.useState)(null),p=async e=>{if(e.preventDefault(),o.trim()&&!c){u(!0);try{await r(o),i(""),d(!1)}finally{u(!1)}}},h=async e=>{if(n&&!m&&confirm("Are you sure you want to delete this comment?")){x(e);try{await n(e)}catch(e){console.error("Failed to delete comment:",e)}finally{x(null)}}};return(0,a.jsxs)("div",{className:"space-y-4",children:[l?(0,a.jsxs)("form",{onSubmit:p,className:"space-y-3 animate-fade-in-up",children:[(0,a.jsx)("textarea",{value:o,onChange:e=>i(e.target.value),placeholder:"Add context, decisions, or guidance...",className:"input resize-none h-24 focus:ring-2 focus:ring-[var(--primary)]/20",autoFocus:!0,disabled:c}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("button",{type:"submit",disabled:!o.trim()||c,className:"btn-primary px-4 py-2 flex items-center gap-2",children:c?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"spinner w-4 h-4 border-2 border-white/20 border-t-white"}),"Adding..."]}):"Add Comment"}),(0,a.jsx)("button",{type:"button",onClick:()=>{d(!1),i("")},disabled:c,className:"btn-ghost px-4 py-2",children:"Cancel"})]})]}):(0,a.jsx)("button",{onClick:()=>d(!0),className:"w-full py-3 border-2 border-dashed border-[var(--card-border)] rounded-xl text-[var(--muted-foreground)] hover:text-[var(--foreground)] hover:border-[var(--primary)] hover:bg-[var(--primary-muted)] transition-all duration-200 text-sm font-medium focus-visible:outline-2 focus-visible:outline-[var(--ring)] focus-visible:outline-offset-2",children:(0,a.jsxs)("span",{className:"flex items-center justify-center gap-2",children:[(0,a.jsx)("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),"Add comment"]})}),0===t.length?(0,a.jsxs)("div",{className:"text-center py-12 animate-fade-in",children:[(0,a.jsx)("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-[var(--background)] border border-[var(--card-border)] mb-3",children:(0,a.jsx)("span",{className:"text-xl opacity-50",children:"\uD83D\uDCDD"})}),(0,a.jsx)("p",{className:"text-[var(--muted-foreground)] text-sm",children:"No comments yet"}),(0,a.jsx)("p",{className:"text-[var(--muted-foreground)] text-xs mt-1",children:"Add context and guidance for this task"})]}):(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("div",{className:"timeline-line"}),(0,a.jsx)("div",{className:"space-y-4",children:t.map((e,t)=>(0,a.jsxs)("div",{className:"timeline-item relative pl-7 animate-fade-in-up",style:{animationDelay:"".concat(50*t,"ms")},children:[(0,a.jsx)("div",{className:"timeline-dot"}),(0,a.jsxs)("div",{className:"card p-4 hover:border-[var(--primary)]/30 group",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs text-[var(--muted-foreground)] tabular-nums",children:new Date(e.created_at).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}),e.author_type&&(0,a.jsx)("span",{className:"text-[10px] uppercase tracking-wide text-[var(--muted-foreground)]",children:e.author_type})]}),n&&"user"===e.author_type&&(0,a.jsx)("button",{onClick:()=>h(e.id),disabled:m===e.id,className:"opacity-0 group-hover:opacity-100 transition-opacity text-[var(--muted-foreground)] hover:text-[var(--destructive)] p-1 rounded",title:"Delete comment",children:m===e.id?(0,a.jsx)("span",{className:"spinner w-3 h-3 border-2 border-current border-t-transparent"}):(0,a.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]}),(0,a.jsx)("p",{className:"text-sm whitespace-pre-wrap leading-relaxed",children:e.content})]})]},e.id))})]})]})}var i=r(577);let l={30:"#94a3b8",31:"#f87171",32:"#4ade80",33:"#facc15",34:"#60a5fa",35:"#c084fc",36:"#22d3ee",37:"#e2e8f0",90:"#64748b",91:"#ef4444",92:"#22c55e",93:"#eab308",94:"#3b82f6",95:"#a855f7",96:"#06b6d4",97:"#f8fafc"},d=/\u001b\[([0-9;]*)m/g,c=/(^|\s)\[((?:\d{1,3};)*\d{1,3})m(\s|$)/g;function u(e){return Math.max(0,Math.min(255,e))}function m(e){let{taskId:t,status:r}=e,[n,o]=(0,s.useState)(!1),[m,x]=(0,s.useState)(!1),{output:p,isLoading:h,isStreaming:v}=(0,i.zH)(t,{enabled:n,tail:500,maxChars:2e5}),f=(0,s.useRef)(null);(0,s.useEffect)(()=>{n&&f.current&&(f.current.scrollTop=f.current.scrollHeight)},[p,n]);let g=p||(h?"Loading logs...":"in_progress"===r?"Waiting for live output...":"No output yet."),b=(0,s.useMemo)(()=>n?function(e){if(!e)return[];let t=e.replace(c,(e,t,r,a)=>t&&a?" ":t||a||""),r=[],a={},s=0;for(let e of t.matchAll(d)){var n;let o=null!=(n=e.index)?n:0;if(o>s){let e=t.slice(s,o);r.push({text:e,style:Object.keys(a).length?{...a}:void 0})}a=function(e,t){let r={...e},a=(t||"0").split(";").map(e=>Number.parseInt(e,10)).filter(e=>Number.isFinite(e));for(let e=0;e<a.length;e+=1){let t=a[e];if(0===t){delete r.color,delete r.fontStyle,delete r.fontWeight,delete r.textDecoration;continue}if(1===t){r.fontWeight=700;continue}if(3===t){r.fontStyle="italic";continue}if(4===t){r.textDecoration="underline";continue}if(22===t){delete r.fontWeight;continue}if(23===t){delete r.fontStyle;continue}if(24===t){delete r.textDecoration;continue}if(39===t){delete r.color;continue}if(38===t){let t=a[e+1];if(5===t&&Number.isFinite(a[e+2]))r.color=function(e){let t=Math.max(0,Math.min(255,e));if(t<16)return l[[30,31,32,33,34,35,36,37,90,91,92,93,94,95,96,97][t]]||"#e2e8f0";if(t>=232){let e=Math.round((t-232)/23*255);return"rgb(".concat(e,", ").concat(e,", ").concat(e,")")}let r=t-16,a=Math.floor(r/36),s=Math.floor(r%36/6),n=e=>0===e?0:40*e+55;return"rgb(".concat(n(a),", ").concat(n(s),", ").concat(n(r%6),")")}(a[e+2]),e+=2;else if(2===t&&Number.isFinite(a[e+2])&&Number.isFinite(a[e+3])&&Number.isFinite(a[e+4])){let t=u(a[e+2]),s=u(a[e+3]),n=u(a[e+4]);r.color="rgb(".concat(t,", ").concat(s,", ").concat(n,")"),e+=4}continue}l[t]&&(r.color=l[t])}return r}(a,e[1]||"0"),s=o+e[0].length}return s<t.length&&r.push({text:t.slice(s),style:Object.keys(a).length?{...a}:void 0}),function(e){if(!e.length)return e;let t=[];for(let r of e){if(!r.text)continue;let e=t[t.length-1],a=!!e&&JSON.stringify(e.style||null)===JSON.stringify(r.style||null);e&&a?e.text+=r.text:t.push({text:r.text,style:r.style?{...r.style}:void 0})}return t}(r)}(g):[],[g,n]);return(0,a.jsxs)("div",{className:"border-t border-[var(--card-border)] pt-8",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>o(e=>!e),className:"w-full flex items-center justify-between text-xs font-semibold uppercase tracking-wider text-[var(--muted-foreground)]","aria-expanded":n,children:[(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{children:"Terminal Stream"}),v&&(0,a.jsx)("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-emerald-500/15 text-emerald-400 border border-emerald-500/30",children:"Live"})]}),(0,a.jsx)("span",{className:"text-[10px] text-[var(--muted-foreground)]",children:n?"Collapse":"Expand"})]}),n&&(0,a.jsxs)("div",{className:"mt-4 rounded-xl border border-[var(--card-border)] bg-[#0b0f14] shadow-inner transition-all duration-300 ease-in-out",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-white/10 text-[10px] uppercase tracking-widest text-white/60",children:[(0,a.jsx)("span",{children:"Run Log"}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("span",{className:"font-mono text-[10px]",children:v?"Streaming":"Idle"}),(0,a.jsx)("button",{onClick:()=>x(!m),className:"hover:text-white transition-colors p-1",title:m?"Collapse View":"Expand View",children:m?(0,a.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,a.jsx)("path",{d:"M8 3v3a2 2 0 0 1-2 2H3"}),(0,a.jsx)("path",{d:"M21 8h-3a2 2 0 0 1-2-2V3"}),(0,a.jsx)("path",{d:"M3 16h3a2 2 0 0 1 2 2v3"}),(0,a.jsx)("path",{d:"M16 21v-3a2 2 0 0 1 2-2h3"})]}):(0,a.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,a.jsx)("path",{d:"M15 3h6v6"}),(0,a.jsx)("path",{d:"M9 21H3v-6"}),(0,a.jsx)("path",{d:"M21 3l-7 7"}),(0,a.jsx)("path",{d:"M3 21l7-7"})]})})]})]}),(0,a.jsx)("div",{ref:f,className:"".concat(m?"max-h-[70vh]":"max-h-64"," overflow-y-auto px-3 py-3 font-mono text-xs text-slate-200 whitespace-pre-wrap leading-relaxed transition-all duration-300 ease-in-out"),children:b.map((e,t)=>(0,a.jsx)("span",{style:e.style,children:e.text},"".concat(t,"-").concat(e.text.length)))})]})]})}let x={task:{label:"This Task",icon:"\uD83D\uDCCC",color:"var(--primary)",bgColor:"var(--primary-muted)",description:"Specific to this task only"},project:{label:"Project",icon:"\uD83D\uDCC1",color:"var(--accent)",bgColor:"var(--accent-muted)",description:"Applies to the whole project"},global:{label:"Playbook",icon:"\uD83D\uDCD6",color:"var(--warning)",bgColor:"var(--warning-muted)",description:"Universal best practices"}};function p(e){var t,r;let{learnings:n,taskId:o,projectContext:i,onAddLearning:l,compact:d=!1}=e,[c,u]=(0,s.useState)(!1),[m,p]=(0,s.useState)(""),[h,v]=(0,s.useState)("task"),[f,g]=(0,s.useState)(!1),b=(null==i?void 0:i.project)?[i.project.id,i.project.slug].filter(Boolean):[],j=(null==i||null==(t=i.project)?void 0:t.name)||(null==i||null==(r=i.project)?void 0:r.slug)||"Project",N=async e=>{if(e.preventDefault(),m.trim()&&!f){g(!0);try{let e="project"===h?b[0]:void 0;await l(m,h,e),p(""),u(!1)}finally{g(!1)}}},y=n.filter(e=>"task"===e.scope&&e.scope_id===o),w=b.length?n.filter(e=>"project"===e.scope&&e.scope_id&&b.includes(e.scope_id)):[],k=n.filter(e=>"global"===e.scope),_=(e,t,r)=>{let s=x[e];return(0,a.jsxs)("div",{className:d?"mb-4":"mb-6",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 ".concat(d?"mb-2":"mb-3"),children:[(0,a.jsx)("span",{className:"w-5 h-5 rounded-lg flex items-center justify-center text-xs",style:{backgroundColor:s.bgColor},children:s.icon}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h4",{className:"text-xs font-semibold",style:{color:s.color},children:r||s.label}),!d&&(0,a.jsx)("p",{className:"text-[10px] text-[var(--muted-foreground)]",children:s.description})]})]}),0===t.length?(0,a.jsx)("p",{className:"text-[10px] text-[var(--muted-foreground)] py-2 text-center bg-[var(--background)] rounded-lg border border-dashed border-[var(--card-border)]",children:"No learnings yet"}):(0,a.jsx)("ul",{className:"space-y-1.5",children:t.map((e,t)=>(0,a.jsx)("li",{className:"text-xs bg-[var(--background)] rounded-lg ".concat(d?"p-2":"p-3"," border border-[var(--card-border)]\n hover:border-[color-mix(in_srgb,var(--primary)_30%,var(--card-border))] \n transition-colors animate-fade-in-up"),style:{animationDelay:"".concat(30*t,"ms")},children:e.content},e.id))})]})};return(0,a.jsxs)("div",{children:[!d&&(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,a.jsx)("span",{className:"text-lg",children:"\uD83D\uDCA1"}),(0,a.jsx)("h3",{className:"text-lg font-semibold",children:"Learnings"}),(0,a.jsx)("span",{className:"text-xs text-[var(--muted-foreground)] bg-[var(--muted)] px-2 py-0.5 rounded-full",children:n.length})]}),c?(0,a.jsxs)("form",{onSubmit:N,className:"".concat(d?"mb-3":"mb-5"," space-y-2 animate-fade-in-up"),children:[(0,a.jsx)("textarea",{value:m,onChange:e=>p(e.target.value),placeholder:"What did you learn?",className:"input resize-none ".concat(d?"h-16 text-xs":"h-20 text-sm"),autoFocus:!0,disabled:f}),(0,a.jsx)("div",{className:"flex gap-1",children:["task","project","global"].map(e=>{let t=x[e],r=h===e,s="project"===e&&0===b.length;return(0,a.jsxs)("button",{type:"button",onClick:()=>v(e),disabled:s,className:"\n flex-1 flex items-center justify-center gap-1 px-1.5 py-1 text-[10px] font-medium rounded-lg\n transition-all duration-200\n ".concat(r?"text-white shadow-md":"bg-[var(--background)] text-[var(--muted-foreground)] hover:text-[var(--foreground)]","\n ").concat(s?"opacity-40 cursor-not-allowed":"","\n "),style:r?{backgroundColor:t.color,boxShadow:"0 2px 8px -2px ".concat(t.color,"60")}:void 0,children:[(0,a.jsx)("span",{children:t.icon}),!d&&(0,a.jsx)("span",{children:t.label})]},e)})}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("button",{type:"submit",disabled:!m.trim()||f,className:"btn-primary px-2 py-1 text-xs flex items-center gap-1.5",children:f?"...":"Add"}),(0,a.jsx)("button",{type:"button",onClick:()=>{u(!1),p("")},disabled:f,className:"btn-ghost px-2 py-1 text-xs",children:"Cancel"})]})]}):(0,a.jsx)("button",{onClick:()=>u(!0),className:"w-full ".concat(d?"py-2 mb-3":"py-3 mb-5"," border-2 border-dashed border-[var(--card-border)] rounded-xl \n text-[var(--muted-foreground)] hover:text-[var(--foreground)] \n hover:border-[var(--primary)] hover:bg-[var(--primary-muted)]\n transition-all duration-200 text-xs font-medium"),children:(0,a.jsxs)("span",{className:"flex items-center justify-center gap-2",children:[(0,a.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),"Add learning"]})}),_("task",y),b.length>0&&_("project",w,"Project: ".concat(j)),_("global",k,"Global Playbook")]})}let h=[{id:"ideation",icon:"\uD83D\uDCA1",label:"Ideation",prompt:"Research and scope. Define approach, estimate effort.",color:"var(--warning)"},{id:"planning",icon:"\uD83D\uDCCB",label:"Planning",prompt:"Create detailed plan with tasks, milestones, and dependencies.",color:"var(--info)"},{id:"execution",icon:"\uD83D\uDCBB",label:"Execution",prompt:"Implement based on plan. Write clean, tested code.",color:"var(--primary)"},{id:"verification",icon:"\uD83E\uDDEA",label:"Verification",prompt:"Test thoroughly. Find edge cases. Fix bugs. Verify against requirements.",color:"var(--accent)"},{id:"done",icon:"✅",label:"Done",prompt:"Task finished and shipped.",color:"var(--success)"}];function v(e){let{currentStage:t,onStageChange:r,readonly:s,size:n="md",stageDecisions:o,stages:i}=e,l=i||h,d=t?l.findIndex(e=>e.id===t):-1;return(0,a.jsx)("div",{className:"flex items-center gap-1 flex-wrap",role:"tablist","aria-label":"Task stages",children:l.map((e,i)=>{let c=e.id===t,u=d>i,m=!s&&r,x=null==o?void 0:o[e.id],p=["".concat(e.label,": ").concat(e.prompt||"")];return(null==x?void 0:x.decision)&&p.push("Decision: ".concat(x.decision)),(null==x?void 0:x.rationale)&&p.push("Rationale: ".concat(x.rationale)),(0,a.jsxs)("button",{onClick:()=>m&&r(e.id),disabled:s,title:p.join(" | "),role:"tab","aria-selected":c,"aria-disabled":s,className:"\n group relative flex items-center gap-1.5 rounded-lg font-medium\n transition-all duration-200 select-none\n focus-visible:outline-2 focus-visible:outline-[var(--ring)] focus-visible:outline-offset-2\n ".concat("sm"===n?"px-2 py-1 text-[10px]":"px-3 py-1.5 text-xs","\n ").concat(c?"text-white shadow-md":u?"bg-[var(--success-muted)] text-[var(--success)]":d<i&&-1!==d?"bg-[var(--background)] text-[var(--muted-foreground)] opacity-50":"bg-[var(--background)] text-[var(--muted-foreground)]","\n ").concat(m&&!c?"hover:bg-[var(--card-border)] hover:text-[var(--foreground)] cursor-pointer":"","\n ").concat(s?"cursor-default":"","\n "),style:c?{backgroundColor:e.color,boxShadow:"0 4px 14px -3px ".concat(e.color,"40")}:void 0,children:[(0,a.jsx)("span",{className:"".concat("sm"===n?"text-xs":"text-sm"," ").concat(c?"":"opacity-80"),children:e.icon}),(0,a.jsx)("span",{className:"hidden lg:inline",children:e.label}),i<l.length-1&&(0,a.jsx)("span",{className:"\n absolute -right-1 top-1/2 -translate-y-1/2 w-2 h-0.5 \n ".concat(u||c?"bg-[var(--success)]":"bg-[var(--card-border)]","\n transition-colors duration-300 hidden lg:block\n ")}),(0,a.jsx)("span",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-2 py-1 text-[10px] font-normal whitespace-nowrap bg-[var(--card-bg)] text-[var(--foreground)] border border-[var(--card-border)] rounded-md shadow-lg opacity-0 group-hover:opacity-100 pointer-events-none transition-opacity duration-200 lg:hidden z-50",children:e.label})]},e.id)})})}var f=r(8661),g=r.n(f),b=r(154),j=r(758),N=r(7004),y=r(6135),w=r(5226);let k=e=>{let{editor:t}=e;return t?(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-1 p-2 border-b border-[var(--card-border)] mb-2 sticky top-0 bg-[var(--card-bg)] z-10 opacity-90 backdrop-blur-sm",children:[(0,a.jsx)("button",{onClick:()=>t.chain().focus().toggleBold().run(),disabled:!t.can().chain().focus().toggleBold().run(),className:"p-1.5 rounded hover:bg-[var(--muted)] ".concat(t.isActive("bold")?"bg-[var(--muted)] text-[var(--foreground)]":"text-[var(--muted-foreground)]"),title:"Bold",children:(0,a.jsx)("span",{className:"font-bold font-serif",children:"B"})}),(0,a.jsx)("button",{onClick:()=>t.chain().focus().toggleItalic().run(),disabled:!t.can().chain().focus().toggleItalic().run(),className:"p-1.5 rounded hover:bg-[var(--muted)] ".concat(t.isActive("italic")?"bg-[var(--muted)] text-[var(--foreground)]":"text-[var(--muted-foreground)]"),title:"Italic",children:(0,a.jsx)("span",{className:"italic font-serif",children:"I"})}),(0,a.jsx)("button",{onClick:()=>t.chain().focus().toggleStrike().run(),disabled:!t.can().chain().focus().toggleStrike().run(),className:"p-1.5 rounded hover:bg-[var(--muted)] ".concat(t.isActive("strike")?"bg-[var(--muted)] text-[var(--foreground)]":"text-[var(--muted-foreground)]"),title:"Strike",children:(0,a.jsx)("span",{className:"line-through font-serif",children:"S"})}),(0,a.jsx)("div",{className:"w-px h-4 bg-[var(--card-border)] mx-1"}),(0,a.jsx)("button",{onClick:()=>t.chain().focus().toggleCode().run(),disabled:!t.can().chain().focus().toggleCode().run(),className:"p-1.5 rounded hover:bg-[var(--muted)] ".concat(t.isActive("code")?"bg-[var(--muted)] text-[var(--foreground)]":"text-[var(--muted-foreground)]"),title:"Code",children:(0,a.jsx)("span",{className:"font-mono text-xs",children:"<>"})}),(0,a.jsx)("button",{onClick:()=>t.chain().focus().toggleCodeBlock().run(),className:"p-1.5 rounded hover:bg-[var(--muted)] ".concat(t.isActive("codeBlock")?"bg-[var(--muted)] text-[var(--foreground)]":"text-[var(--muted-foreground)]"),title:"Code Block",children:(0,a.jsx)("span",{className:"font-mono text-xs",children:"CB"})}),(0,a.jsx)("div",{className:"w-px h-4 bg-[var(--card-border)] mx-1"}),(0,a.jsx)("button",{onClick:()=>t.chain().focus().toggleHeading({level:1}).run(),className:"p-1.5 rounded hover:bg-[var(--muted)] ".concat(t.isActive("heading",{level:1})?"bg-[var(--muted)] text-[var(--foreground)]":"text-[var(--muted-foreground)]"),title:"H1",children:(0,a.jsx)("span",{className:"font-bold text-xs",children:"H1"})}),(0,a.jsx)("button",{onClick:()=>t.chain().focus().toggleHeading({level:2}).run(),className:"p-1.5 rounded hover:bg-[var(--muted)] ".concat(t.isActive("heading",{level:2})?"bg-[var(--muted)] text-[var(--foreground)]":"text-[var(--muted-foreground)]"),title:"H2",children:(0,a.jsx)("span",{className:"font-bold text-xs",children:"H2"})}),(0,a.jsx)("button",{onClick:()=>t.chain().focus().toggleHeading({level:3}).run(),className:"p-1.5 rounded hover:bg-[var(--muted)] ".concat(t.isActive("heading",{level:3})?"bg-[var(--muted)] text-[var(--foreground)]":"text-[var(--muted-foreground)]"),title:"H3",children:(0,a.jsx)("span",{className:"font-bold text-xs",children:"H3"})}),(0,a.jsx)("div",{className:"w-px h-4 bg-[var(--card-border)] mx-1"}),(0,a.jsx)("button",{onClick:()=>t.chain().focus().toggleBulletList().run(),className:"p-1.5 rounded hover:bg-[var(--muted)] ".concat(t.isActive("bulletList")?"bg-[var(--muted)] text-[var(--foreground)]":"text-[var(--muted-foreground)]"),title:"Bullet List",children:(0,a.jsx)("span",{className:"text-xs",children:"• List"})}),(0,a.jsx)("button",{onClick:()=>t.chain().focus().toggleOrderedList().run(),className:"p-1.5 rounded hover:bg-[var(--muted)] ".concat(t.isActive("orderedList")?"bg-[var(--muted)] text-[var(--foreground)]":"text-[var(--muted-foreground)]"),title:"Ordered List",children:(0,a.jsx)("span",{className:"text-xs",children:"1. List"})}),(0,a.jsx)("button",{onClick:()=>t.chain().focus().toggleBlockquote().run(),className:"p-1.5 rounded hover:bg-[var(--muted)] ".concat(t.isActive("blockquote")?"bg-[var(--muted)] text-[var(--foreground)]":"text-[var(--muted-foreground)]"),title:"Quote",children:(0,a.jsx)("span",{className:"text-xs serif italic",children:'""'})})]}):null};function _(e){let{content:t,editable:r=!0,onChange:n,onBlur:o,placeholder:i="Add a description..."}=e,l=(0,b.hG)({extensions:[j.A,y.Ay.configure({openOnClick:!1}),N.A.configure({placeholder:i,emptyEditorClass:"is-editor-empty before:content-[attr(data-placeholder)] before:text-[var(--muted-foreground)] before:float-left before:pointer-events-none before:h-0"}),w.o.configure({html:!1,transformPastedText:!0,transformCopiedText:!0})],immediatelyRender:!1,content:t,editable:r,editorProps:{attributes:{class:"prose prose-sm max-w-none focus:outline-none min-h-[100px] text-[var(--foreground)]"}},onUpdate:e=>{let{editor:t}=e;null==n||n(t.storage.markdown.getMarkdown())},onBlur:()=>{null==o||o()}});return(0,s.useEffect)(()=>{l&&t!==l.storage.markdown.getMarkdown()&&!l.isFocused&&l.commands.setContent(t)},[t,l]),(0,a.jsxs)("div",{className:"jsx-cdf669dd826a0677 relative group",children:[r&&(0,a.jsx)(k,{editor:l}),(0,a.jsx)(b.$Z,{editor:l,className:"rich-text-editor"}),(0,a.jsx)(g(),{id:"cdf669dd826a0677",children:".rich-text-editor .ProseMirror{min-height:100px;outline:none}.rich-text-editor .ProseMirror p{margin-bottom:.75em;line-height:1.6}.rich-text-editor .ProseMirror h1{font-size:1.5em;font-weight:700;margin-top:1em;margin-bottom:.5em}.rich-text-editor .ProseMirror h2{font-size:1.25em;font-weight:600;margin-top:1em;margin-bottom:.5em}.rich-text-editor .ProseMirror h3{font-size:1.1em;font-weight:600;margin-top:1em;margin-bottom:.5em}.rich-text-editor .ProseMirror ul{list-style-type:disc;padding-left:1.5em;margin-bottom:.75em}.rich-text-editor .ProseMirror ol{list-style-type:decimal;padding-left:1.5em;margin-bottom:.75em}.rich-text-editor .ProseMirror blockquote{border-left:3px solid var(--card-border);padding-left:1em;font-style:italic;color:var(--muted-foreground)}.rich-text-editor .ProseMirror pre{background:var(--muted);padding:.75em;border-radius:var(--radius-sm);font-family:monospace;overflow-x:auto;margin-bottom:.75em}.rich-text-editor .ProseMirror code{background:var(--muted);padding:.2em .4em;border-radius:var(--radius-sm);font-family:monospace;font-size:.85em}.rich-text-editor .ProseMirror a{color:var(--primary);text-decoration:underline}"})]})}var C=r(91),S=r(2619),D=r.n(S);function A(e){var t,r,s;let{projectContext:n,fallbackProjectSlug:o}=e,i=(null==n?void 0:n.project)||null,l=null!=(t=null==n?void 0:n.repos)?t:[],d=null!=(r=null==n?void 0:n.learnings)?r:[],c=(s=null==i?void 0:i.metadata)&&"object"==typeof s?Object.entries(s).filter(e=>{let[t]=e;return!!t}):[];if(!i)return(0,a.jsxs)("div",{className:"p-4 rounded-2xl border border-dashed border-[var(--card-border)] bg-[var(--card-bg)]/60 space-y-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs font-semibold uppercase tracking-wide text-[var(--muted-foreground)]",children:"Project Context"}),(0,a.jsx)("p",{className:"text-sm text-[var(--muted-foreground)]",children:o?'Task is tagged with "'.concat(o,'" but no structured project context is available yet.'):"This task is not connected to a project. Link it to unlock repo maps, CI/CD notes, and project learnings."})]}),(0,a.jsx)(D(),{href:"/projects",className:"inline-flex items-center justify-center text-xs font-semibold px-3 py-1.5 rounded-full border border-[var(--card-border)] hover:border-[var(--primary)] hover:text-[var(--primary)] transition-colors",children:"Manage Projects"})]});let u=d.slice(0,3),m=d.length-u.length;return(0,a.jsxs)("div",{className:"p-4 rounded-2xl border border-[var(--card-border)] bg-[var(--card-bg)] space-y-4",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs font-semibold uppercase tracking-wide text-[var(--muted-foreground)]",children:"Project Context"}),(0,a.jsx)("h3",{className:"text-base font-semibold leading-tight mt-1",children:i.name}),(0,a.jsx)("p",{className:"text-[11px] uppercase tracking-wide text-[var(--muted-foreground)]",children:i.slug})]}),(0,a.jsx)(D(),{href:"/projects",className:"text-[11px] font-semibold px-2 py-1 rounded-full border border-[var(--card-border)] hover:border-[var(--primary)] hover:text-[var(--primary)] transition-colors",children:"View"})]}),i.description&&(0,a.jsx)("p",{className:"text-sm text-[var(--foreground)] whitespace-pre-line",children:i.description}),i.ci_cd_info&&(0,a.jsxs)("div",{className:"text-xs space-y-1",children:[(0,a.jsx)("p",{className:"font-semibold text-[var(--muted-foreground)] uppercase tracking-wide",children:"CI / CD"}),(0,a.jsx)("p",{className:"text-[var(--foreground)] text-sm",children:i.ci_cd_info})]}),c.length>0&&(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-[var(--muted-foreground)] mb-2",children:"Metadata"}),(0,a.jsx)("dl",{className:"space-y-1.5",children:c.map(e=>{let[t,r]=e;return(0,a.jsxs)("div",{className:"flex items-start justify-between gap-2 text-xs",children:[(0,a.jsx)("dt",{className:"font-semibold text-[var(--foreground)]",children:t}),(0,a.jsx)("dd",{className:"text-[var(--muted-foreground)] text-right max-w-[160px]",children:"string"==typeof r?r:JSON.stringify(r)})]},t)})})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.jsx)("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-[var(--muted-foreground)]",children:"Repository Map"}),(0,a.jsx)("span",{className:"text-[11px] text-[var(--muted-foreground)]",children:l.length?"".concat(l.length," connected"):"None"})]}),0===l.length?(0,a.jsx)("p",{className:"text-xs text-[var(--muted-foreground)]",children:"Add repositories to help agents navigate local and remote paths."}):(0,a.jsx)("ul",{className:"space-y-2",children:l.map(e=>(0,a.jsxs)("li",{className:"p-2 rounded-xl border border-[var(--card-border)] bg-[var(--background)] space-y-1 text-xs",children:[(0,a.jsx)("p",{className:"font-semibold text-[var(--foreground)]",children:e.name}),e.path&&(0,a.jsxs)("p",{className:"text-[var(--muted-foreground)]",children:["Path: ",e.path]}),e.git_url&&(0,a.jsxs)("p",{className:"text-[var(--muted-foreground)] break-all",children:["Repo: ",(0,a.jsx)("span",{className:"text-[var(--primary)]",children:e.git_url})]}),e.notes&&(0,a.jsxs)("p",{className:"text-[var(--muted-foreground)]",children:["Notes: ",e.notes]})]},e.id||e.name))})]}),d.length>0&&(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-[var(--muted-foreground)] mb-2",children:"Project Learnings"}),(0,a.jsx)("ul",{className:"space-y-1 text-xs text-[var(--foreground)]",children:u.map((e,t)=>(0,a.jsxs)("li",{className:"leading-relaxed",children:["• ",e]},"".concat(e,"-").concat(t)))}),m>0&&(0,a.jsxs)("p",{className:"text-[11px] text-[var(--muted-foreground)] mt-1",children:["+",m," more learnings in the panel below"]})]})]})}var M=r(8545);let L={queued:{label:"Queued",color:"var(--status-queued)",bgColor:"var(--status-queued-bg)"},in_progress:{label:"In Progress",color:"var(--status-in-progress)",bgColor:"var(--status-in-progress-bg)"},blocked:{label:"Blocked",color:"var(--status-blocked)",bgColor:"var(--status-blocked-bg)"},completed:{label:"Completed",color:"var(--status-completed)",bgColor:"var(--status-completed-bg)"},failed:{label:"Failed",color:"var(--status-failed)",bgColor:"var(--status-failed-bg)"}},I=["queued","in_progress","blocked","completed","failed"];function P(e){if(!e)return"N/A";let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function T(e){let t=(e.log_type||"output").toLowerCase();return"output"===t?e.content||"":"[".concat(t,"] ").concat(e.content||"")}function O(e){var t,r,i,l,d,c,u,x,f,g,b,j;let{task:N,comments:y,learnings:w,projectContext:k,projects:S,stage_config:D,stages:O,isDraft:F=!1,isCreating:B=!1,onClose:H,onAddComment:W,onDeleteComment:q,onAddLearning:R,onUpdate:z,onDelete:V}=e,{providers:U}=(0,M.u)(),{projects:$}=(0,C.Y)(),Q=S||$,Y=O||h,[G,J]=(0,s.useState)(!1),[Z,K]=(0,s.useState)(!1),[X,ee]=(0,s.useState)(!1),[et,er]=(0,s.useState)(""),[ea,es]=(0,s.useState)(null),[en,eo]=(0,s.useState)(!1),[ei,el]=(0,s.useState)(N.provider||""),[ed,ec]=(0,s.useState)(N.model||""),[eu,em]=(0,s.useState)(null!=(d=N.swarm)&&d),[ex,ep]=(0,s.useState)([]),[eh,ev]=(0,s.useState)("gemini"),[ef,eg]=(0,s.useState)(""),[eb,ej]=(0,s.useState)(!1),[eN,ey]=(0,s.useState)(null),ew=N.resolved_provider||(null==D?void 0:D.provider)||"gemini",ek=N.resolved_model||(null==D?void 0:D.model)||"",e_=null!=(u=null!=(c=N.swarm)?c:null==D?void 0:D.swarm)&&u;N.resolved_swarm_models||null==D||D.swarm_models;let eC=null!=(x=null!=k?k:N.project_context)?x:null,eS=null!=(g=null!=(f=null==eC||null==(t=eC.project)?void 0:t.slug)?f:N.project)?g:null,[eD,eA]=(0,s.useState)(N.title||""),[eM,eL]=(0,s.useState)(""),eI=e=>{let t=e.match(/^---\n[\s\S]*?\n---\n([\s\S]*)$/);return(t?t[1]:e).replace(/^#\s+.+(\r?\n|$)/,"").trim()};(0,s.useEffect)(()=>{var e;el(N.provider||""),ec(N.model||""),em(null!=(e=N.swarm)&&e),ep(Array.isArray(N.swarm_models)?N.swarm_models.filter(e=>e&&"string"==typeof e.provider&&"string"==typeof e.model).map(e=>({provider:e.provider.trim(),model:e.model.trim()})).filter(e=>e.provider&&e.model):[])},[N.provider,N.model,N.swarm,N.swarm_models,N.id]),(0,s.useEffect)(()=>{eA(N.title||"")},[N.title,N.id]),(0,s.useEffect)(()=>{var e;eL((null!=(e=N.description)?e:eI(N.content||"")).replace(/^#\s+.+(\r?\n|$)/,"").trim())},[N.content,N.description,N.id]),(0,s.useEffect)(()=>{let e=!1;if("failed"!==N.status){er(""),es(null),eo(!1);return}return(async()=>{eo(!0),es(null);try{let t=await fetch("/api/tasks/".concat(N.id,"/logs?tail=200")),r=await t.json().catch(()=>({}));if(!t.ok)throw Error((null==r?void 0:r.error)||"Failed to load logs (".concat(t.status,")"));let a=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2e4,r=Array.isArray(e)?e:[];if(!r.length)return"";let a=r.slice().sort((e,t)=>e.created_at===t.created_at?e.id.localeCompare(t.id):e.created_at.localeCompare(t.created_at)),s=a.filter(e=>"error"===(e.log_type||"").toLowerCase()),n=a.filter(e=>{let t=String(e.content||"");return t.includes("[execution/")&&(t.includes("stderr_tail:")||t.includes("stdout_tail:")||t.includes(" phase error")||t.includes(" error=")||t.includes(" exit="))}),o=(s.length>0?s.slice(-8):n.length>0?n.slice(-4):a.slice(-12)).map(T).join("\n");return o?o.length>t?o.slice(-t):o:""}((null==r?void 0:r.logs)||[]);e||er(a)}catch(t){e||es(t instanceof Error?t.message:String(t))}finally{e||eo(!1)}})(),()=>{e=!0}},[N.id,N.status]);let eP=async()=>{ee(!0);try{await (null==V?void 0:V())}finally{ee(!1),K(!1)}},eT=(0,n.YQ)(async e=>{var t;let r=(null!=(t=N.description)?t:eI(N.content||"")).replace(/^#\s+.+(\r?\n|$)/,"").trim();F||e===r||await z({description:e})},1e3),eO=(0,n.YQ)(async e=>{if(!F&&e!==(N.title||"")){ej(!0);try{await z({title:e})}finally{ej(!1)}}},1e3),eE=(0,n.YQ)(async e=>{ej(!0),ey(null);try{await z(e)}catch(e){ey(e instanceof Error?e.message:"Failed to update settings")}finally{ej(!1)}},1e3),eF=async e=>{let t="done"===e?"completed":"ideation"===e?"queued":"in_progress";if(F)return void await z({stage:e,status:t});await z({stage:e,status:t})},eB=async e=>{if(!e)return void await z({project:null,project_id:null});let t=Q.find(t=>t.id===e);t&&await z({project:t.slug,project_id:t.id})},eH=async()=>{try{await eq("queued")}catch(e){console.error("Failed to retry task",e)}},eW=async()=>{try{await eq("queued")}catch(e){console.error("Failed to unblock task",e)}},eq=async e=>{let t={status:e};"queued"===e&&(t.started_at=null,t.completed_at=null,t.error=void 0),"completed"!==e&&"failed"!==e&&"blocked"!==e||N.completed_at||(t.completed_at=new Date().toISOString()),await z(t)};L[N.status||"queued"];let eR=N.stage_decisions||{},ez=N.stage?eR[N.stage]:void 0,eV=function(e,t){if(!e||"object"!=typeof e)return null;let r=Object.entries(e).filter(e=>{let[,r]=e;return!!(r&&t(r))}).sort((e,t)=>{var r,a;let s=Date.parse((null==(r=e[1])?void 0:r.decided_at)||""),n=Date.parse((null==(a=t[1])?void 0:a.decided_at)||"");return(Number.isNaN(n)?0:n)-(Number.isNaN(s)?0:s)});if(!r.length)return null;let[a,s]=r[0];return{stage:a,decision:s}}(eR,e=>"failed"===e.decision),eU=Object.entries(eR).filter(e=>{let[,t]=e;return(null==t?void 0:t.decision)==="blocked"}).sort((e,t)=>{var r,a;let s=Date.parse((null==(r=e[1])?void 0:r.decided_at)||""),n=Date.parse((null==(a=t[1])?void 0:a.decided_at)||"");return(Number.isNaN(n)?0:n)-(Number.isNaN(s)?0:s)})[0],e$=(null==ez?void 0:ez.decision)==="blocked"?N.stage:null==eU?void 0:eU[0],eQ=e$&&eR[e$]?eR[e$]:void 0,eY=null==eQ?void 0:eQ.rationale,eG="string"==typeof N.error&&N.error.trim()?N.error.trim():((null==eV||null==(r=eV.decision)?void 0:r.rationale)||(null==eV||null==(i=eV.decision)?void 0:i.final_result)||"").trim()||"Task marked failed.";return(0,a.jsx)("div",{className:"modal-backdrop",onClick:e=>e.target===e.currentTarget&&H(),children:(0,a.jsxs)("div",{className:"bg-[var(--card-bg)] w-full max-w-[1200px] h-[90vh] rounded-xl shadow-2xl overflow-hidden flex flex-col animate-scale-in border border-[var(--card-border)] m-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-6 py-4 border-b border-[var(--card-border)] bg-[var(--card-bg)]",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("span",{className:"text-[var(--muted-foreground)] font-mono text-sm",children:F?"New Task":N.slug||N.id.slice(0,6)}),!F&&(0,a.jsx)(v,{currentStage:N.stage,onStageChange:eF,stageDecisions:N.stage_decisions,stages:Y})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[F&&(0,a.jsx)("button",{onClick:()=>{var e,t;if(!eM.trim())return;let r="done"===N.stage?"completed":"ideation"===N.stage?"queued":"in_progress";z({title:eD,description:eM,stage:N.stage,status:r,project:null!=(e=N.project)?e:null,project_id:null!=(t=N.project_id)?t:null,provider:ei||void 0,model:ed||void 0,swarm:eu,swarm_models:eu?ex:[]})},disabled:B||!eM.trim(),className:"btn-primary px-4 py-2 rounded-md text-sm font-medium disabled:opacity-50 disabled:cursor-not-allowed",children:B?"Creating...":"Create Task"}),!F&&eb&&(0,a.jsxs)("span",{className:"text-[10px] text-[var(--muted-foreground)] animate-pulse flex items-center gap-1 mr-2",children:[(0,a.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--primary)]"}),"Saving..."]}),!F&&V&&(0,a.jsx)("button",{onClick:()=>K(!0),className:"btn-ghost p-2 rounded hover:bg-[var(--destructive-muted)] hover:text-[var(--destructive)]",title:"Delete Task",children:(0,a.jsx)("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})}),(0,a.jsx)("button",{onClick:H,className:"btn-ghost p-2 rounded",title:"Close (Esc)",children:(0,a.jsx)("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),Z&&(0,a.jsx)("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 rounded-xl animate-fade-in",children:(0,a.jsxs)("div",{className:"modal-content p-6 max-w-sm mx-4 animate-scale-in bg-[var(--card-bg)]",children:[(0,a.jsx)("h3",{className:"text-lg font-bold mb-2",children:"Delete Task?"}),(0,a.jsxs)("p",{className:"text-[var(--muted-foreground)] text-sm mb-6",children:["Are you sure you want to delete ",(0,a.jsx)("strong",{className:"text-[var(--foreground)]",children:N.slug||N.id.slice(0,6)}),"? This cannot be undone."]}),(0,a.jsxs)("div",{className:"flex justify-end gap-3",children:[(0,a.jsx)("button",{onClick:()=>K(!1),disabled:X,className:"btn-ghost",children:"Cancel"}),(0,a.jsx)("button",{onClick:eP,disabled:X,className:"btn-destructive px-4 py-2 rounded-md",children:X?"Deleting...":"Delete"})]})]})}),(0,a.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,a.jsx)("div",{className:"flex-1 overflow-y-auto scrollbar-thin",children:(0,a.jsxs)("div",{className:"max-w-3xl mx-auto p-8",children:[!F&&"failed"===N.status&&(0,a.jsxs)("div",{className:"mb-8 p-4 rounded-lg bg-[var(--status-failed-bg)] border border-[var(--status-failed)] text-[var(--status-failed)]",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,a.jsx)("span",{className:"font-bold text-sm uppercase tracking-wider",children:"Task Execution Failed"})]}),(0,a.jsx)("button",{onClick:eH,className:"btn-ghost px-3 py-1 text-xs font-bold bg-white/20 rounded hover:bg-white/30 transition-colors uppercase",children:"Retry Task"})]}),(0,a.jsx)("p",{className:"text-sm font-medium",children:eG}),(0,a.jsxs)("div",{className:"mt-3 text-xs rounded-md border border-[var(--status-failed)]/40 bg-white/50 p-3",children:[(0,a.jsx)("h4",{className:"font-semibold uppercase tracking-wider mb-2",children:"Failure Metadata"}),(0,a.jsxs)("div",{className:"grid grid-cols-[140px_1fr] gap-x-3 gap-y-1.5",children:[(0,a.jsx)("span",{className:"opacity-70",children:"Stage"}),(0,a.jsx)("span",{className:"font-medium",children:N.stage||(null==eV?void 0:eV.stage)||"N/A"}),(0,a.jsx)("span",{className:"opacity-70",children:"Exit Code"}),(0,a.jsx)("span",{className:"font-mono",children:null!=(b=N.exit_code)?b:"N/A"}),(0,a.jsx)("span",{className:"opacity-70",children:"PID"}),(0,a.jsx)("span",{className:"font-mono",children:null!=(j=N.pid)?j:"N/A"}),(0,a.jsx)("span",{className:"opacity-70",children:"Completed At"}),(0,a.jsx)("span",{className:"font-medium",children:P(N.completed_at)}),(null==eV?void 0:eV.decision)&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"opacity-70",children:"Decision"}),(0,a.jsx)("span",{className:"font-medium",children:eV.decision.decision}),(0,a.jsx)("span",{className:"opacity-70",children:"Rationale"}),(0,a.jsx)("span",{className:"font-medium break-words",children:eV.decision.rationale||"N/A"}),(0,a.jsx)("span",{className:"opacity-70",children:"Final Result"}),(0,a.jsx)("span",{className:"font-medium break-words",children:eV.decision.final_result||"N/A"}),(0,a.jsx)("span",{className:"opacity-70",children:"Decided At"}),(0,a.jsx)("span",{className:"font-medium",children:P(eV.decision.decided_at)})]})]})]}),(en||et||ea)&&(0,a.jsxs)("details",{className:"mt-3",open:!0,children:[(0,a.jsx)("summary",{className:"cursor-pointer select-none text-xs font-semibold uppercase tracking-wider opacity-90",children:"Error Details"}),(0,a.jsxs)("div",{className:"mt-2 rounded-md border border-[var(--status-failed)]/40 bg-[#0b0f14] text-slate-200",children:[(0,a.jsxs)("div",{className:"px-3 py-2 border-b border-white/10 text-[10px] uppercase tracking-widest text-white/60 flex items-center justify-between",children:[(0,a.jsx)("span",{children:"Log Excerpt"}),(0,a.jsx)("span",{className:"font-mono",children:en?"Loading...":ea?"Unavailable":"Ready"})]}),(0,a.jsx)("pre",{className:"px-3 py-3 text-xs font-mono whitespace-pre-wrap max-h-64 overflow-y-auto",children:ea?"Failed to load error details: ".concat(ea):et||"No error logs found."})]})]})]}),!F&&"blocked"===N.status&&(0,a.jsxs)("div",{className:"mb-8 p-4 rounded-lg bg-[var(--status-blocked-bg)] border border-[var(--status-blocked)] text-[var(--status-blocked)]",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"})}),(0,a.jsx)("span",{className:"font-bold text-sm uppercase tracking-wider",children:"Task Blocked"})]}),(0,a.jsx)("button",{onClick:eW,className:"btn-ghost px-3 py-1 text-xs font-bold bg-white/20 rounded hover:bg-white/30 transition-colors uppercase",children:"Unblock Task"})]}),(0,a.jsx)("p",{className:"text-sm opacity-90 pl-7 mb-4",children:eY||"Task is blocked and requires manual intervention."}),(0,a.jsxs)("div",{className:"ml-7 text-xs rounded-md border border-[var(--status-blocked)]/40 bg-white/50 p-3",children:[(0,a.jsx)("h4",{className:"font-semibold uppercase tracking-wider mb-2",children:"Blocked Metadata"}),(0,a.jsxs)("div",{className:"grid grid-cols-[140px_1fr] gap-x-3 gap-y-1.5",children:[(0,a.jsx)("span",{className:"opacity-70",children:"Decision Stage"}),(0,a.jsx)("span",{className:"font-medium",children:e$||N.stage||"N/A"}),(0,a.jsx)("span",{className:"opacity-70",children:"Decision"}),(0,a.jsx)("span",{className:"font-medium",children:(null==eQ?void 0:eQ.decision)||"blocked"}),(0,a.jsx)("span",{className:"opacity-70",children:"Final Result"}),(0,a.jsx)("span",{className:"font-medium break-words",children:(null==eQ?void 0:eQ.final_result)||"N/A"}),(0,a.jsx)("span",{className:"opacity-70",children:"Rationale"}),(0,a.jsx)("span",{className:"font-medium break-words",children:(null==eQ?void 0:eQ.rationale)||"N/A"}),(0,a.jsx)("span",{className:"opacity-70",children:"Decided At"}),(0,a.jsx)("span",{className:"font-medium",children:P(null==eQ?void 0:eQ.decided_at)}),(0,a.jsx)("span",{className:"opacity-70",children:"Workflow ID"}),(0,a.jsx)("span",{className:"font-mono break-all",children:N.workflow_id||"N/A"}),(0,a.jsx)("span",{className:"opacity-70",children:"Workflow Run ID"}),(0,a.jsx)("span",{className:"font-mono break-all",children:N.workflow_run_id||"N/A"}),(0,a.jsx)("span",{className:"opacity-70",children:"Orchestration Status"}),(0,a.jsx)("span",{className:"font-medium",children:N.orchestration_status||"N/A"}),(0,a.jsx)("span",{className:"opacity-70",children:"Last Orchestration Update"}),(0,a.jsx)("span",{className:"font-medium",children:P(N.last_orchestration_update)}),(0,a.jsx)("span",{className:"opacity-70",children:"Started At"}),(0,a.jsx)("span",{className:"font-medium",children:P(N.started_at)}),(0,a.jsx)("span",{className:"opacity-70",children:"Completed At"}),(0,a.jsx)("span",{className:"font-medium",children:P(N.completed_at)})]})]})]}),(0,a.jsx)("input",{type:"text",value:eD,onChange:e=>{var t;eA(t=e.target.value),F||eO(t)},placeholder:"Task title...",className:"w-full text-2xl font-bold bg-transparent border-none outline-none text-[var(--foreground)] placeholder:text-[var(--muted-foreground)]/50 mb-4"}),(0,a.jsx)("div",{className:"mb-12 min-h-[150px]",children:(0,a.jsx)(_,{content:eM,onChange:e=>{eL(e),F||eT(e)},placeholder:F?"Describe the task...":"Add more detail to this task..."})}),!F&&(0,a.jsx)(m,{taskId:N.id,status:N.status}),!F&&N.history&&N.history.length>0&&(0,a.jsxs)("div",{className:"mt-12 border-t border-[var(--card-border)] pt-8",children:[(0,a.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-wider text-[var(--muted-foreground)] mb-4",children:"Execution History"}),(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)("table",{className:"w-full text-sm text-left",children:[(0,a.jsx)("thead",{className:"text-xs text-[var(--muted-foreground)] border-b border-[var(--card-border)]",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"py-2 pr-4 font-medium",children:"Started"}),(0,a.jsx)("th",{className:"py-2 pr-4 font-medium",children:"Duration"}),(0,a.jsx)("th",{className:"py-2 pr-4 font-medium",children:"PID"}),(0,a.jsx)("th",{className:"py-2 pr-4 font-medium",children:"Exit Code"})]})}),(0,a.jsx)("tbody",{className:"divide-y divide-[var(--card-border)]",children:N.history.map(e=>{var t,r;return(0,a.jsxs)("tr",{className:"hover:bg-[var(--muted)]/20 transition-colors",children:[(0,a.jsx)("td",{className:"py-2 pr-4 font-mono text-xs opacity-80",children:e.started_at?new Date(e.started_at).toLocaleString():"N/A"}),(0,a.jsx)("td",{className:"py-2 pr-4 font-mono text-xs opacity-80",children:e.started_at&&e.completed_at?function(e,t){let r=t.getTime()-e.getTime();if(r<1e3)return"".concat(r,"ms");let a=Math.floor(r/1e3);if(a<60)return"".concat(a,"s");let s=Math.floor(a/60);return"".concat(s,"m ").concat(a%60,"s")}(new Date(e.started_at),new Date(e.completed_at)):"-"}),(0,a.jsx)("td",{className:"py-2 pr-4 font-mono text-xs opacity-80",children:null!=(t=e.pid)?t:"-"}),(0,a.jsx)("td",{className:"py-2 pr-4",children:(0,a.jsx)("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium border ".concat(0===e.exit_code?"bg-[var(--status-completed-bg)] text-[var(--status-completed)] border-[var(--status-completed)]/20":"bg-[var(--status-failed-bg)] text-[var(--status-failed)] border-[var(--status-failed)]/20"),children:null!=(r=e.exit_code)?r:"-"})})]},e.id)})})]})})]}),!F&&(0,a.jsxs)("div",{className:"border-t border-[var(--card-border)] pt-8",children:[(0,a.jsxs)("h3",{className:"text-xs font-semibold uppercase tracking-wider text-[var(--muted-foreground)] mb-6 flex items-center justify-between",children:[(0,a.jsx)("span",{children:"Comments"}),(0,a.jsx)("span",{className:"text-[10px] bg-[var(--muted)] px-2 py-0.5 rounded-full",children:y.length})]}),(0,a.jsx)(o,{comments:y,onAddComment:W,onDeleteComment:q})]})]})}),(0,a.jsxs)("div",{className:"w-80 border-l border-[var(--card-border)] bg-[var(--muted)]/20 overflow-y-auto scrollbar-thin p-6 flex flex-col gap-8 flex-shrink-0",children:[(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{className:"text-sm text-[var(--muted-foreground)]",children:"Stage"}),(0,a.jsx)("select",{value:N.stage,onChange:e=>eF(e.target.value),className:"text-sm font-medium bg-[var(--card-bg)] border border-[var(--card-border)] rounded px-2 py-1 focus:border-[var(--primary)] outline-none transition-colors cursor-pointer",children:Y.map(e=>(0,a.jsx)("option",{value:e.id,children:e.label},e.id))})]}),!F&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{className:"text-sm text-[var(--muted-foreground)]",children:"Status"}),(0,a.jsx)("select",{value:N.status||"queued",onChange:e=>eq(e.target.value),className:"text-sm font-medium bg-[var(--card-bg)] border border-[var(--card-border)] rounded px-2 py-1 focus:border-[var(--primary)] outline-none transition-colors cursor-pointer",children:I.map(e=>(0,a.jsx)("option",{value:e,children:L[e].label},e))})]}),(0,a.jsx)(E,{label:"ID",value:N.id}),N.slug&&(0,a.jsx)(E,{label:"Slug",value:N.slug,truncate:!0})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{className:"text-sm text-[var(--muted-foreground)]",children:"Project"}),(0,a.jsxs)("select",{value:N.project_id||(null==(l=Q.find(e=>e.slug===N.project))?void 0:l.id)||"",onChange:e=>eB(e.target.value),className:"text-sm font-medium bg-[var(--card-bg)] border border-[var(--card-border)] rounded px-2 py-1 focus:border-[var(--primary)] outline-none transition-colors cursor-pointer max-w-[150px] truncate",children:[(0,a.jsx)("option",{value:"",children:"None"}),Q.map(e=>(0,a.jsx)("option",{value:e.id,children:e.name},e.id))]})]}),!F&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{className:"text-sm text-[var(--muted-foreground)]",children:"Provider"}),(0,a.jsx)("span",{className:"text-sm font-medium",children:e_?"Swarm":ew||"Default"})]}),void 0!==N.pid&&null!==N.pid&&(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{className:"text-sm text-[var(--muted-foreground)]",children:"PID"}),(0,a.jsx)("span",{className:"text-sm font-mono font-medium",title:"Process ID",children:N.pid})]}),void 0!==N.exit_code&&null!==N.exit_code&&(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{className:"text-sm text-[var(--muted-foreground)]",children:"Exit Code"}),(0,a.jsx)("span",{className:"text-sm font-mono font-medium ".concat(0===N.exit_code?"text-[var(--status-completed)]":"text-[var(--status-failed)]"),children:N.exit_code})]})]})]}),(0,a.jsx)("div",{className:"w-full h-px bg-[var(--card-border)]"}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)("div",{className:"flex items-center justify-between",children:(0,a.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wider text-[var(--muted-foreground)]",children:"Execution"})}),(0,a.jsxs)("div",{className:"flex items-center justify-between bg-[var(--card-bg)] p-2 rounded border border-[var(--card-border)]",children:[(0,a.jsx)("span",{className:"text-sm font-medium",children:"Swarm Mode"}),(0,a.jsx)("button",{onClick:()=>(e=>{em(e);let t={swarm:e};e?t.swarm_models=ex:(t.provider=ei,t.model=ed),z(t)})(!eu),className:"w-10 h-5 rounded-full transition-colors relative ".concat(eu?"bg-[var(--primary)]":"bg-[var(--muted-foreground)]/30"),children:(0,a.jsx)("span",{className:"absolute top-0.5 left-0.5 w-4 h-4 bg-white rounded-full transition-transform ".concat(eu?"translate-x-5":"translate-x-0")})})]}),eu?(0,a.jsxs)("div",{className:"space-y-3 animate-fade-in",children:[(0,a.jsx)("label",{className:"block text-xs text-[var(--muted-foreground)]",children:"Swarm Models"}),(0,a.jsxs)("div",{className:"grid gap-2",children:[(0,a.jsxs)("div",{className:"grid grid-cols-[1fr_1.2fr_auto] gap-2",children:[(0,a.jsx)("select",{value:eh,onChange:e=>ev(e.target.value),className:"text-sm bg-[var(--card-bg)] border border-[var(--card-border)] rounded px-2 py-1.5 focus:border-[var(--primary)] outline-none transition-colors appearance-none",children:U.map(e=>(0,a.jsx)("option",{value:e.id,children:e.label},e.id))}),(0,a.jsx)("input",{value:ef,onChange:e=>eg(e.target.value),placeholder:"model name",className:"text-sm bg-[var(--card-bg)] border border-[var(--card-border)] rounded px-2 py-1.5 focus:border-[var(--primary)] outline-none transition-colors"}),(0,a.jsx)("button",{type:"button",onClick:()=>{let e=ef.trim();if(!e)return;let t={provider:eh,model:e};if(ex.some(e=>e.provider.toLowerCase()===t.provider.toLowerCase()&&e.model.toLowerCase()===t.model.toLowerCase()))return;let r=[...ex,t];if(ep(r),eg(""),F)return void z({swarm_models:r});eu&&eE({swarm_models:r})},className:"px-3 py-1.5 text-xs font-semibold rounded-md bg-[var(--card-bg)] border border-[var(--card-border)] hover:border-[var(--muted-foreground)]",children:"Add"})]}),ex.length>0&&(0,a.jsx)("div",{className:"space-y-1",children:ex.map((e,t)=>(0,a.jsxs)("div",{className:"flex items-center justify-between px-2 py-1.5 rounded text-sm border bg-[var(--card-bg)] border-[var(--card-border)]",children:[(0,a.jsxs)("span",{className:"truncate",children:[(0,a.jsx)("span",{className:"text-[var(--muted-foreground)]",children:e.provider}),(0,a.jsx)("span",{className:"mx-1",children:"\xb7"}),(0,a.jsx)("span",{children:e.model})]}),(0,a.jsx)("button",{type:"button",onClick:()=>(e=>{let t=ex.filter((t,r)=>r!==e);if(ep(t),F)return void z({swarm_models:t});eu&&eE({swarm_models:t})})(t),className:"text-xs text-[var(--destructive)] hover:underline",children:"Remove"})]},"".concat(e.provider,"-").concat(e.model,"-").concat(t)))})]})]}):(0,a.jsxs)("div",{className:"space-y-3 animate-fade-in",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-xs text-[var(--muted-foreground)] mb-1.5",children:"Provider"}),(0,a.jsxs)("select",{value:ei,onChange:e=>(e=>{if(el(e),F)return void z({provider:e});z({provider:e})})(e.target.value),className:"w-full text-sm bg-[var(--card-bg)] border border-[var(--card-border)] rounded px-2 py-1.5 focus:border-[var(--primary)] outline-none transition-colors appearance-none",children:[(0,a.jsxs)("option",{value:"",children:["Default (",ew,")"]}),U.map(e=>(0,a.jsx)("option",{value:e.id,children:e.label},e.id))]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-xs text-[var(--muted-foreground)] mb-1.5",children:"Model"}),(0,a.jsx)("input",{value:ed,onChange:e=>(e=>{if(ec(e),F)return void z({model:e});eE({model:e})})(e.target.value),placeholder:"Default (".concat(ek||"unspecified",")"),className:"w-full text-sm bg-[var(--card-bg)] border border-[var(--card-border)] rounded px-2 py-1.5 focus:border-[var(--primary)] outline-none transition-colors"})]})]}),eN&&(0,a.jsx)("p",{className:"text-xs text-[var(--destructive)]",children:eN})]}),!F&&(0,a.jsx)("div",{className:"w-full h-px bg-[var(--card-border)]"}),!F&&(0,a.jsx)(A,{projectContext:eC,fallbackProjectSlug:eS}),!F&&(0,a.jsx)("div",{className:"w-full h-px bg-[var(--card-border)]"}),!F&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("button",{onClick:()=>J(!G),className:"w-full flex items-center justify-between p-3 rounded-lg border transition-all duration-200 ".concat(G?"bg-[var(--primary-muted)] border-[var(--primary)] text-[var(--primary)]":"bg-[var(--card-bg)] border-[var(--card-border)] hover:border-[var(--muted-foreground)]"),children:[(0,a.jsx)("span",{className:"text-sm font-medium",children:"Learnings"}),(0,a.jsx)("span",{className:"text-xs bg-[var(--background)] px-2 py-0.5 rounded-full border border-[var(--card-border)]",children:w.length})]}),G&&(0,a.jsx)("div",{className:"mt-4 animate-fade-in-up",children:(0,a.jsx)(p,{learnings:w,taskId:N.id,projectContext:eC,onAddLearning:R,compact:!0})})]}),!F&&(0,a.jsx)("div",{className:"mt-auto text-xs text-[var(--muted-foreground)]",children:(0,a.jsxs)("p",{children:["Created ",new Date(N.created_at||Date.now()).toLocaleDateString()]})})]})]})]})})}function E(e){let{label:t,value:r,truncate:n,mono:o=!0}=e,[i,l]=(0,s.useState)(!1);return(0,a.jsxs)("div",{className:"flex items-center justify-between group h-7",children:[(0,a.jsx)("span",{className:"text-sm text-[var(--muted-foreground)]",children:t}),(0,a.jsxs)("button",{onClick:()=>{navigator.clipboard.writeText(r),l(!0),setTimeout(()=>l(!1),2e3)},className:"text-sm ".concat(o?"font-mono":""," flex items-center gap-1.5 hover:bg-[var(--primary-muted)] hover:text-[var(--primary)] px-1.5 py-0.5 -mr-1.5 rounded transition-all"),title:"Click to copy",children:[(0,a.jsx)("span",{className:"".concat(n?"max-w-[140px] truncate":""," ").concat(i?"opacity-50":""),children:n&&r.length>20?r.slice(0,8)+"..."+r.slice(-8):r}),i?(0,a.jsx)("span",{className:"text-[10px] uppercase font-bold tracking-wider text-[var(--primary)] animate-scale-in",children:"Copied"}):(0,a.jsx)("svg",{className:"w-3.5 h-3.5 opacity-0 group-hover:opacity-60 transition-opacity",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})]})]})}},8545:(e,t,r)=>{r.d(t,{u:()=>n});var a=r(2115);let s=[{id:"gemini",label:"Gemini"},{id:"claude",label:"Claude"},{id:"ollama",label:"Ollama"},{id:"codex",label:"Codex"}];function n(){let[e,t]=(0,a.useState)(s),[r,n]=(0,a.useState)(!0);(0,a.useEffect)(()=>{let e=!1;return(async()=>{try{let r=await fetch("/api/providers"),a=await r.json().catch(()=>({}));if(!r.ok)throw Error((null==a?void 0:a.error)||"HTTP ".concat(r.status));let s=(Array.isArray(null==a?void 0:a.providers)?a.providers:[]).filter(e=>e&&"string"==typeof e.id&&"string"==typeof e.label).map(e=>({id:e.id,label:e.label}));!e&&s.length>0&&t(s)}catch(e){}finally{e||n(!1)}})(),()=>{e=!0}},[]);let o=(0,a.useMemo)(()=>e.map(e=>e.id),[e]);return{providers:e,providerIds:o,loading:r}}}}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8008],{63:(e,t,r)=>{"use strict";var s=r(7260);r.o(s,"usePathname")&&r.d(t,{usePathname:function(){return s.usePathname}}),r.o(s,"useRouter")&&r.d(t,{useRouter:function(){return s.useRouter}}),r.o(s,"useSearchParams")&&r.d(t,{useSearchParams:function(){return s.useSearchParams}})},926:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),!function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{callServer:function(){return s.callServer},createServerReference:function(){return c.createServerReference},findSourceMapURL:function(){return n.findSourceMapURL}});let s=r(1209),n=r(5153),c=r(7197)},2699:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>u});var s=r(5155),n=r(2115),c=r(63),a=r(926);let l=(0,a.createServerReference)("40e5e5f057a2988facde6f088311032d6e512c6c17",a.callServer,void 0,a.findSourceMapURL,"approveDeviceCode");function o(){let e=(0,c.useSearchParams)(),t=(0,c.useRouter)(),r=e.get("user_code")||"",[a,o]=(0,n.useState)(r),[u,i]=(0,n.useState)(!1),[d,f]=(0,n.useState)(null),[x,h]=(0,n.useState)(!1);(0,n.useEffect)(()=>{if(x){let e=setTimeout(()=>{t.push("/projects")},3e3);return()=>clearTimeout(e)}},[x,t]);let m=async e=>{e.preventDefault(),i(!0),f(null);try{let e=await l(a);if(!e.success)throw Error(e.error);h(!0)}catch(e){f(e.message)}finally{i(!1)}};return x?(0,s.jsx)("div",{className:"flex flex-col items-center justify-center min-h-screen bg-neutral-900 text-white p-4",children:(0,s.jsxs)("div",{className:"max-w-md w-full bg-neutral-800 p-8 rounded-xl shadow-2xl text-center",children:[(0,s.jsx)("h1",{className:"text-3xl font-bold mb-4 text-green-400",children:"Success!"}),(0,s.jsx)("p",{className:"text-gray-300 mb-2",children:"You have successfully authenticated your device."}),(0,s.jsx)("p",{className:"text-gray-400 text-sm mb-6 italic",children:"Redirecting to projects in a few seconds..."}),(0,s.jsx)("button",{onClick:()=>t.push("/projects"),className:"w-full py-3 px-4 bg-white text-black font-semibold rounded-lg hover:bg-gray-200 transition-colors",children:"Go to Projects"})]})}):(0,s.jsx)("div",{className:"flex flex-col items-center justify-center min-h-screen bg-neutral-900 text-white p-4",children:(0,s.jsxs)("div",{className:"max-w-md w-full bg-neutral-800 p-8 rounded-xl shadow-2xl",children:[(0,s.jsx)("h1",{className:"text-2xl font-bold mb-6 text-center",children:"Connect Device"}),(0,s.jsx)("p",{className:"text-gray-400 mb-8 text-center text-sm",children:"Enter the code displayed on your device to authorize it."}),(0,s.jsxs)("form",{onSubmit:m,className:"space-y-6",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"code",className:"block text-sm font-medium text-gray-400 mb-2",children:"Device Code"}),(0,s.jsx)("input",{type:"text",id:"code",value:a,onChange:e=>o(e.target.value.toUpperCase()),placeholder:"BCDF-XXXX",className:"w-full px-4 py-3 bg-neutral-900 border border-neutral-700 rounded-lg text-white placeholder-neutral-600 focus:outline-none focus:ring-2 focus:ring-blue-500 font-mono text-center tracking-widest text-lg uppercase",required:!0})]}),d&&(0,s.jsx)("div",{className:"p-3 bg-red-900/50 border border-red-800 rounded-lg text-red-200 text-center text-sm",children:d}),(0,s.jsx)("button",{type:"submit",disabled:u,className:"w-full py-3 px-4 bg-white text-black font-semibold rounded-lg hover:bg-gray-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:u?"Verifying...":"Authorize Device"})]})]})})}function u(){return(0,s.jsx)(n.Suspense,{fallback:(0,s.jsx)("div",{children:"Loading..."}),children:(0,s.jsx)(o,{})})}},5109:(e,t,r)=>{Promise.resolve().then(r.bind(r,2699))}},e=>{e.O(0,[8441,1255,7358],()=>e(e.s=5109)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8008],{63:(e,t,r)=>{"use strict";var s=r(7260);r.o(s,"usePathname")&&r.d(t,{usePathname:function(){return s.usePathname}}),r.o(s,"useRouter")&&r.d(t,{useRouter:function(){return s.useRouter}}),r.o(s,"useSearchParams")&&r.d(t,{useSearchParams:function(){return s.useSearchParams}})},926:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),!function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{callServer:function(){return s.callServer},createServerReference:function(){return c.createServerReference},findSourceMapURL:function(){return n.findSourceMapURL}});let s=r(1209),n=r(5153),c=r(7197)},5078:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>u});var s=r(5155),n=r(2115),c=r(63),a=r(926);let l=(0,a.createServerReference)("40f84c4ad9e6e621da7928b4dbfdecf7d999b30c78",a.callServer,void 0,a.findSourceMapURL,"approveDeviceCode");function o(){let e=(0,c.useSearchParams)(),t=(0,c.useRouter)(),r=e.get("user_code")||"",[a,o]=(0,n.useState)(r),[u,i]=(0,n.useState)(!1),[d,f]=(0,n.useState)(null),[x,h]=(0,n.useState)(!1);(0,n.useEffect)(()=>{if(x){let e=setTimeout(()=>{t.push("/projects")},3e3);return()=>clearTimeout(e)}},[x,t]);let m=async e=>{e.preventDefault(),i(!0),f(null);try{let e=await l(a);if(!e.success)throw Error(e.error);h(!0)}catch(e){f(e.message)}finally{i(!1)}};return x?(0,s.jsx)("div",{className:"flex flex-col items-center justify-center min-h-screen bg-neutral-900 text-white p-4",children:(0,s.jsxs)("div",{className:"max-w-md w-full bg-neutral-800 p-8 rounded-xl shadow-2xl text-center",children:[(0,s.jsx)("h1",{className:"text-3xl font-bold mb-4 text-green-400",children:"Success!"}),(0,s.jsx)("p",{className:"text-gray-300 mb-2",children:"You have successfully authenticated your device."}),(0,s.jsx)("p",{className:"text-gray-400 text-sm mb-6 italic",children:"Redirecting to projects in a few seconds..."}),(0,s.jsx)("button",{onClick:()=>t.push("/projects"),className:"w-full py-3 px-4 bg-white text-black font-semibold rounded-lg hover:bg-gray-200 transition-colors",children:"Go to Projects"})]})}):(0,s.jsx)("div",{className:"flex flex-col items-center justify-center min-h-screen bg-neutral-900 text-white p-4",children:(0,s.jsxs)("div",{className:"max-w-md w-full bg-neutral-800 p-8 rounded-xl shadow-2xl",children:[(0,s.jsx)("h1",{className:"text-2xl font-bold mb-6 text-center",children:"Connect Device"}),(0,s.jsx)("p",{className:"text-gray-400 mb-8 text-center text-sm",children:"Enter the code displayed on your device to authorize it."}),(0,s.jsxs)("form",{onSubmit:m,className:"space-y-6",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"code",className:"block text-sm font-medium text-gray-400 mb-2",children:"Device Code"}),(0,s.jsx)("input",{type:"text",id:"code",value:a,onChange:e=>o(e.target.value.toUpperCase()),placeholder:"BCDF-XXXX",className:"w-full px-4 py-3 bg-neutral-900 border border-neutral-700 rounded-lg text-white placeholder-neutral-600 focus:outline-none focus:ring-2 focus:ring-blue-500 font-mono text-center tracking-widest text-lg uppercase",required:!0})]}),d&&(0,s.jsx)("div",{className:"p-3 bg-red-900/50 border border-red-800 rounded-lg text-red-200 text-center text-sm",children:d}),(0,s.jsx)("button",{type:"submit",disabled:u,className:"w-full py-3 px-4 bg-white text-black font-semibold rounded-lg hover:bg-gray-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:u?"Verifying...":"Authorize Device"})]})]})})}function u(){return(0,s.jsx)(n.Suspense,{fallback:(0,s.jsx)("div",{children:"Loading..."}),children:(0,s.jsx)(o,{})})}},5109:(e,t,r)=>{Promise.resolve().then(r.bind(r,5078))}},e=>{e.O(0,[8441,1255,7358],()=>e(e.s=5109)),_N_E=e.O()}]);
@@ -3,9 +3,9 @@
3
3
  "version": "0.1.0",
4
4
  "private": true,
5
5
  "scripts": {
6
- "dev": "next dev --port 41741",
7
- "build": "next build",
8
- "start": "next start",
6
+ "dev": "node server.js",
7
+ "build": "echo 'standalone build - nothing to build'",
8
+ "start": "node server.js",
9
9
  "lint": "next lint",
10
10
  "test": "node --localstorage-file=/tmp/agx-cloud-jest-localstorage ./node_modules/jest/bin/jest.js",
11
11
  "test:watch": "node --localstorage-file=/tmp/agx-cloud-jest-localstorage ./node_modules/jest/bin/jest.js --watch",
@@ -16,9 +16,9 @@
16
16
  "test:e2e:report": "playwright show-report",
17
17
  "test:all": "npm run test && npm run test:e2e",
18
18
  "ci:test": "node --localstorage-file=/tmp/agx-cloud-jest-localstorage ./node_modules/jest/bin/jest.js --coverage && playwright test --reporter=github",
19
- "worker": "tsx worker/index.ts",
20
- "daemon:worker": "npm run worker",
21
- "daemon:temporal": "npm run worker"
19
+ "worker": "node worker/index.js",
20
+ "daemon:worker": "node worker/index.js",
21
+ "daemon:temporal": "node worker/index.js"
22
22
  },
23
23
  "dependencies": {
24
24
  "@chatscope/chat-ui-kit-react": "^2.1.1",
@@ -61,4 +61,4 @@
61
61
  "tsx": "^4.20.6",
62
62
  "typescript": "^5.7.0"
63
63
  }
64
- }
64
+ }
@@ -156,6 +156,7 @@ function createCloudExecuteVerifySingle(env) {
156
156
  verifyResults,
157
157
  iteration,
158
158
  lastRunPath: runContainerPath || verifyRun?.paths?.root || null,
159
+ agentOutput: output,
159
160
  });
160
161
  const verifyArtifacts = createDaemonArtifactsRecorder({ storage, run: verifyRun, taskId });
161
162
  verifyArtifacts.recordPrompt(`Verification Prompt (${provider}${model ? `/${model}` : ''}, iter ${iteration})`, verifyPrompt);
@@ -162,6 +162,7 @@ function createCloudExecuteVerifySwarm(env) {
162
162
  verifyResults,
163
163
  iteration,
164
164
  lastRunPath: runContainerPath || verifyRun?.paths?.root || null,
165
+ agentOutput: combinedOutput,
165
166
  });
166
167
  const verifyArtifacts = createDaemonArtifactsRecorder({ storage, run: verifyRun, taskId });
167
168
  verifyArtifacts.recordPrompt(`Verification Prompt (${verifierProvider}${verifierModel ? `/${verifierModel}` : ''}, iter ${iteration})`, verifyPrompt);
@@ -136,11 +136,14 @@ If uncertain, still return valid JSON with decision "failed" and explain why in
136
136
  ].join('\n');
137
137
  }
138
138
 
139
- function buildVerifyPrompt({ taskId, task, stagePrompt, stageRequirement, gitSummary, verifyResults, iteration, lastRunPath }) {
139
+ function buildVerifyPrompt({ taskId, task, stagePrompt, stageRequirement, gitSummary, verifyResults, iteration, lastRunPath, agentOutput }) {
140
140
  const title = String(task?.title || taskId || '').trim();
141
141
  const contentRaw = String(task?.content || '').trim();
142
142
  const content = contentRaw.length > 2500 ? `${contentRaw.slice(0, 2500)}\n[truncated]` : contentRaw;
143
143
 
144
+ const agentOutputRaw = agentOutput ? String(agentOutput).trim() : '';
145
+ const agentOutputShort = agentOutputRaw.length > 3000 ? `${agentOutputRaw.slice(-3000)}\n[truncated to last 3000 chars]` : agentOutputRaw;
146
+
144
147
  const diffStat = gitSummary?.diff_stat ? String(gitSummary.diff_stat).trim() : '';
145
148
  const statusPorcelain = gitSummary?.status_porcelain ? String(gitSummary.status_porcelain).trim() : '';
146
149
  const statusShort = statusPorcelain ? statusPorcelain.split('\n').slice(0, 80).join('\n') : '';
@@ -186,11 +189,16 @@ ${diffShort || '(none)'}
186
189
  Verification commands:
187
190
  ${cmdLines}
188
191
 
192
+ Agent output (last iteration):
193
+ ${agentOutputShort || '(not available)'}
194
+
189
195
  Decide if the stage is complete. Use verification commands as evidence.
190
196
  Ignore unrelated working tree changes; focus on whether the user request is satisfied.
191
197
  If not complete, provide the next smallest instruction for another iteration.
192
198
  Set "done": true when the user request is satisfied and the evidence supports it. Treat the stage objective/requirement as guidance, not a keyword checklist.
193
199
 
200
+ IMPORTANT: Empty git status/diff does NOT mean work was not done. The target state may already exist from a previous run (files already created, code already written). Judge completion by whether the desired outcome exists, not by whether new changes were made in this iteration. If the agent output indicates the work is already complete and verification commands pass, mark as done.
201
+
194
202
  Output contract (strict): your response MUST be exactly one raw JSON object with this shape:
195
203
  {
196
204
  "done": false,
package/lib/cli/daemon.js CHANGED
@@ -643,7 +643,6 @@ function startTemporalWorker() {
643
643
  return null;
644
644
  }
645
645
 
646
- const script = pickEmbeddedWorkerNpmScript(projectDir);
647
646
  let worker;
648
647
  try {
649
648
  const boardEnv = loadBoardEnv();
@@ -653,7 +652,16 @@ function startTemporalWorker() {
653
652
  fs.closeSync(logFd);
654
653
  return null;
655
654
  }
656
- worker = execa('npm', ['run', script], {
655
+
656
+ // For bundled runtimes, run worker/index.js directly (no npm/tsx needed).
657
+ // For dev mode, use the npm script which may use tsx for .ts files.
658
+ const workerJs = path.join(projectDir, 'worker', 'index.js');
659
+ const isBundled = fs.existsSync(path.join(projectDir, 'server.js')) && fs.existsSync(workerJs);
660
+
661
+ const cmd = isBundled ? 'node' : 'npm';
662
+ const cmdArgs = isBundled ? [workerJs] : ['run', pickEmbeddedWorkerNpmScript(projectDir)];
663
+
664
+ worker = execa(cmd, cmdArgs, {
657
665
  cwd: projectDir,
658
666
  detached: true,
659
667
  stdio: ['ignore', logFd, logFd],
package/lib/executor.js CHANGED
@@ -31,7 +31,7 @@ const PROJECT_CONTEXT = [
31
31
  const ENGINES = {
32
32
  claude: {
33
33
  cmd: 'claude',
34
- args: ['-p'],
34
+ args: ['--dangerously-skip-permissions', '-p'],
35
35
  available: () => commandExists('claude'),
36
36
  },
37
37
  gemini: {
@@ -129,37 +129,32 @@ async function acquireTaskLock(taskRootPath, options = {}) {
129
129
  const lockPath = path.join(taskRootPath, '.lock');
130
130
  const force = options.force || false;
131
131
 
132
- // Proactively clean stale locks before attempting acquisition
133
- // This handles the common case where a previous process died without cleanup
132
+ // Proactively clean stale/invalid locks before attempting acquisition
134
133
  const existingLock = await readJsonSafe(lockPath);
135
134
 
136
- if (existingLock && !force) {
135
+ if (existingLock) {
137
136
  const { valid, reason } = isLockValid(existingLock);
138
- if (!valid) {
139
- // Lock is stale/dead — clean it up silently
137
+ if (!valid || force) {
138
+ // Lock is stale/dead/forced — clean it up
139
+ if (!valid) {
140
+ console.error(`Auto-releasing stale lock (pid ${existingLock.pid}, reason: ${reason})`);
141
+ }
140
142
  try { await fs.promises.unlink(lockPath); } catch (e) {
141
143
  if (e.code !== 'ENOENT') throw e;
142
144
  }
143
- // Fall through to acquire below
144
- }
145
- }
146
-
147
- // Re-read after potential cleanup
148
- const currentLock = existingLock ? await readJsonSafe(lockPath) : null;
149
-
150
- if (currentLock && !force) {
151
- // If we get here, the lock survived the stale cleanup above — it's genuinely held.
152
- if (currentLock.pid === process.pid && isCurrentProcessLock(currentLock)) {
145
+ } else {
146
+ // Lock is genuinely held by a live process
147
+ if (existingLock.pid === process.pid && isCurrentProcessLock(existingLock)) {
148
+ throw new Error(
149
+ `Lock already held by this process instance. ` +
150
+ `This indicates a logic error - lock should be released before re-acquiring.`
151
+ );
152
+ }
153
153
  throw new Error(
154
- `Lock already held by this process instance. ` +
155
- `This indicates a logic error - lock should be released before re-acquiring.`
154
+ `Task is locked by process ${existingLock.pid} since ${existingLock.at}. ` +
155
+ `Use --force to override if you're sure the lock is stale.`
156
156
  );
157
157
  }
158
- // Lock is held by a live process — reject
159
- throw new Error(
160
- `Task is locked by process ${currentLock.pid} since ${currentLock.at}. ` +
161
- `Use --force to override if you're sure the lock is stale.`
162
- );
163
158
  }
164
159
 
165
160
  const now = new Date().toISOString();
@@ -391,17 +386,18 @@ function isLockValid(lock) {
391
386
  return { valid: false, reason: 'no lock' };
392
387
  }
393
388
 
389
+ // Check staleness FIRST — a stale lock is always invalid, even if the
390
+ // PID happens to be alive (PID reuse is common on macOS/Linux).
391
+ if (isLockStale(lock)) {
392
+ return { valid: false, reason: 'lock stale' };
393
+ }
394
+
394
395
  // Check if process is alive
395
396
  const alive = isProcessAlive(lock.pid);
396
397
  if (!alive) {
397
398
  return { valid: false, reason: 'process dead' };
398
399
  }
399
400
 
400
- // Check if lock is stale
401
- if (isLockStale(lock)) {
402
- return { valid: false, reason: 'lock stale' };
403
- }
404
-
405
401
  // Check process start time if available
406
402
  if (lock.startedAt && !isProcessStartTimeValid(lock.pid, lock.startedAt)) {
407
403
  return { valid: false, reason: 'pid reused' };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mndrk/agx",
3
- "version": "1.4.48",
3
+ "version": "1.4.50",
4
4
  "description": "Autonomous AI Agent Orchestrator for Claude, Gemini, and Ollama",
5
5
  "main": "lib/index.js",
6
6
  "exports": {