chorus-codes 0.8.43 → 0.8.45

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 (144) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +2 -2
  3. package/.next/build-manifest.json +2 -2
  4. package/.next/prerender-manifest.json +3 -3
  5. package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  6. package/.next/server/app/_global-error.html +1 -1
  7. package/.next/server/app/_global-error.rsc +1 -1
  8. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  9. package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  10. package/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  11. package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  12. package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  13. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  14. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  15. package/.next/server/app/_not-found.html +1 -1
  16. package/.next/server/app/_not-found.rsc +2 -2
  17. package/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  18. package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  19. package/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
  20. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  21. package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  22. package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  23. package/.next/server/app/connect/page.js +1 -1
  24. package/.next/server/app/connect/page_client-reference-manifest.js +1 -1
  25. package/.next/server/app/demo/[scenario]/page_client-reference-manifest.js +1 -1
  26. package/.next/server/app/new/page.js +1 -1
  27. package/.next/server/app/new/page_client-reference-manifest.js +1 -1
  28. package/.next/server/app/new.html +1 -1
  29. package/.next/server/app/new.rsc +3 -3
  30. package/.next/server/app/new.segments/_full.segment.rsc +3 -3
  31. package/.next/server/app/new.segments/_head.segment.rsc +1 -1
  32. package/.next/server/app/new.segments/_index.segment.rsc +2 -2
  33. package/.next/server/app/new.segments/_tree.segment.rsc +2 -2
  34. package/.next/server/app/new.segments/new/__PAGE__.segment.rsc +2 -2
  35. package/.next/server/app/new.segments/new.segment.rsc +1 -1
  36. package/.next/server/app/onboarding/page.js +2 -2
  37. package/.next/server/app/onboarding/page_client-reference-manifest.js +1 -1
  38. package/.next/server/app/onboarding.html +1 -1
  39. package/.next/server/app/onboarding.rsc +3 -3
  40. package/.next/server/app/onboarding.segments/_full.segment.rsc +3 -3
  41. package/.next/server/app/onboarding.segments/_head.segment.rsc +1 -1
  42. package/.next/server/app/onboarding.segments/_index.segment.rsc +2 -2
  43. package/.next/server/app/onboarding.segments/_tree.segment.rsc +2 -2
  44. package/.next/server/app/onboarding.segments/onboarding/__PAGE__.segment.rsc +2 -2
  45. package/.next/server/app/onboarding.segments/onboarding.segment.rsc +1 -1
  46. package/.next/server/app/page.js +1 -1
  47. package/.next/server/app/page_client-reference-manifest.js +1 -1
  48. package/.next/server/app/personas/page_client-reference-manifest.js +1 -1
  49. package/.next/server/app/personas.html +1 -1
  50. package/.next/server/app/personas.rsc +3 -3
  51. package/.next/server/app/personas.segments/_full.segment.rsc +3 -3
  52. package/.next/server/app/personas.segments/_head.segment.rsc +1 -1
  53. package/.next/server/app/personas.segments/_index.segment.rsc +2 -2
  54. package/.next/server/app/personas.segments/_tree.segment.rsc +2 -2
  55. package/.next/server/app/personas.segments/personas/__PAGE__.segment.rsc +2 -2
  56. package/.next/server/app/personas.segments/personas.segment.rsc +1 -1
  57. package/.next/server/app/runs/[runId]/page_client-reference-manifest.js +1 -1
  58. package/.next/server/app/runs/page_client-reference-manifest.js +1 -1
  59. package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  60. package/.next/server/app/settings/permissions/page_client-reference-manifest.js +1 -1
  61. package/.next/server/app/settings.html +1 -1
  62. package/.next/server/app/settings.rsc +3 -3
  63. package/.next/server/app/settings.segments/_full.segment.rsc +3 -3
  64. package/.next/server/app/settings.segments/_head.segment.rsc +1 -1
  65. package/.next/server/app/settings.segments/_index.segment.rsc +2 -2
  66. package/.next/server/app/settings.segments/_tree.segment.rsc +2 -2
  67. package/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +2 -2
  68. package/.next/server/app/settings.segments/settings.segment.rsc +1 -1
  69. package/.next/server/app/templates/page.js +1 -1
  70. package/.next/server/app/templates/page_client-reference-manifest.js +1 -1
  71. package/.next/server/app/templates.html +1 -1
  72. package/.next/server/app/templates.rsc +3 -3
  73. package/.next/server/app/templates.segments/_full.segment.rsc +3 -3
  74. package/.next/server/app/templates.segments/_head.segment.rsc +1 -1
  75. package/.next/server/app/templates.segments/_index.segment.rsc +2 -2
  76. package/.next/server/app/templates.segments/_tree.segment.rsc +2 -2
  77. package/.next/server/app/templates.segments/templates/__PAGE__.segment.rsc +2 -2
  78. package/.next/server/app/templates.segments/templates.segment.rsc +1 -1
  79. package/.next/server/app-paths-manifest.json +2 -2
  80. package/.next/server/chunks/189.js +1 -1
  81. package/.next/server/chunks/325.js +1 -1
  82. package/.next/server/chunks/642.js +1 -1
  83. package/.next/server/chunks/681.js +1 -1
  84. package/.next/server/middleware-build-manifest.js +1 -1
  85. package/.next/server/pages/404.html +1 -1
  86. package/.next/server/pages/500.html +1 -1
  87. package/.next/server/server-reference-manifest.json +1 -1
  88. package/.next/static/chunks/245-f3d2948b0049e981.js +1 -0
  89. package/.next/static/chunks/{641-66f3ba81d2479b02.js → 641-8c9e921c7be99a9d.js} +1 -1
  90. package/.next/static/chunks/744-c2e8529e7a5b0221.js +1 -0
  91. package/.next/static/chunks/app/connect/page-14d8e3fa9505959f.js +1 -0
  92. package/.next/static/chunks/app/new/page-4452a15141b14ef3.js +1 -0
  93. package/.next/static/chunks/app/onboarding/page-cc53c4eeeb372cda.js +1 -0
  94. package/.next/static/chunks/app/page-de91de3476faae94.js +1 -0
  95. package/.next/static/chunks/app/templates/page-4984d1f588c30038.js +1 -0
  96. package/.next/static/css/{a2b7a8d35dba10d3.css → e17f6c0e70cdd1f3.css} +1 -1
  97. package/.next/trace +20 -20
  98. package/.next/trace-build +1 -1
  99. package/dist/cli/commands/doctor.js +1 -0
  100. package/dist/cli/commands/doctor.js.map +1 -1
  101. package/dist/cli/commands/init.js +1 -0
  102. package/dist/cli/commands/init.js.map +1 -1
  103. package/dist/cli/commands/quickstart.js +1 -0
  104. package/dist/cli/commands/quickstart.js.map +1 -1
  105. package/dist/cli/commands/start.js +87 -1
  106. package/dist/cli/commands/start.js.map +1 -1
  107. package/dist/cli/commands/update.js +123 -1
  108. package/dist/cli/commands/update.js.map +1 -1
  109. package/dist/daemon/agents/antigravity.js +87 -0
  110. package/dist/daemon/agents/antigravity.js.map +1 -0
  111. package/dist/daemon/agents/index.js +4 -1
  112. package/dist/daemon/agents/index.js.map +1 -1
  113. package/dist/daemon/agents/parsers/antigravity.js +119 -0
  114. package/dist/daemon/agents/parsers/antigravity.js.map +1 -0
  115. package/dist/daemon/agents/parsers/index.js +4 -1
  116. package/dist/daemon/agents/parsers/index.js.map +1 -1
  117. package/dist/daemon/error-detector.js +20 -2
  118. package/dist/daemon/error-detector.js.map +1 -1
  119. package/dist/lib/cli-detect.js +9 -0
  120. package/dist/lib/cli-detect.js.map +1 -1
  121. package/dist/lib/cli-health.js +1 -0
  122. package/dist/lib/cli-health.js.map +1 -1
  123. package/dist/lib/cli-paths.js +1 -0
  124. package/dist/lib/cli-paths.js.map +1 -1
  125. package/dist/lib/cli-precheck.js +9 -0
  126. package/dist/lib/cli-precheck.js.map +1 -1
  127. package/dist/lib/db/voices.js +1 -1
  128. package/dist/lib/db/voices.js.map +1 -1
  129. package/dist/lib/lineage-maps.js +31 -0
  130. package/dist/lib/lineage-maps.js.map +1 -1
  131. package/dist/lib/template-schema.js +2 -2
  132. package/dist/lib/template-schema.js.map +1 -1
  133. package/dist/lib/voices.js +6 -0
  134. package/dist/lib/voices.js.map +1 -1
  135. package/package.json +1 -1
  136. package/.next/static/chunks/245-686f2a9a3d4d5554.js +0 -1
  137. package/.next/static/chunks/744-a5a2f718e91700bd.js +0 -1
  138. package/.next/static/chunks/app/connect/page-e216744a2daa061b.js +0 -1
  139. package/.next/static/chunks/app/new/page-d65ea7687a1b37ad.js +0 -1
  140. package/.next/static/chunks/app/onboarding/page-9f2b388be3008bdc.js +0 -1
  141. package/.next/static/chunks/app/page-75f1f750029680bd.js +0 -1
  142. package/.next/static/chunks/app/templates/page-0cfb5ce79f29fcd5.js +0 -1
  143. /package/.next/static/{4hHxZHWTDLJU0ZZPkLRz- → K3ZP-A6lDlsvS8qZe3cKK}/_buildManifest.js +0 -0
  144. /package/.next/static/{4hHxZHWTDLJU0ZZPkLRz- → K3ZP-A6lDlsvS8qZe3cKK}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[641],{1993:(e,t,n)=>{n.d(t,{K7:()=>d,UT:()=>r,dW:()=>o,qI:()=>s});var i=n(4411);function a(e){return{id:e.id,label:e.label,one_liner:e.one_liner,system_prompt:e.system_prompt,recommended_lineage:e.recommended_lineage,builtin:!!e.builtin,forked_from:e.forked_from??null,created_at:e.created_at,updated_at:e.updated_at}}async function r(){return(await (0,i.T)("/personas")).items.map(a)}async function o(e){return a(await (0,i.T)(`/personas/${encodeURIComponent(e)}`))}async function s(e){return a(await (0,i.T)("/personas",{method:"POST",body:JSON.stringify(e)}))}async function d(e){await (0,i.T)(`/personas/${encodeURIComponent(e)}`,{method:"DELETE"})}},4284:(e,t,n)=>{n.d(t,{U:()=>a});var i=n(9442);function a({className:e}){return(0,i.jsxs)("svg",{viewBox:"0 0 32 32","aria-hidden":"true",className:e,fill:"currentColor",children:[(0,i.jsx)("circle",{cx:"11",cy:"20",r:"3.2",fillOpacity:"0.55"}),(0,i.jsx)("circle",{cx:"21",cy:"20",r:"3.2",fillOpacity:"0.55"}),(0,i.jsx)("circle",{cx:"16",cy:"11",r:"3.2"})]})}},4411:(e,t,n)=>{n.d(t,{$:()=>r,T:()=>o}),n(9298);let i="/api/v1";async function a(){return new URL("/api/daemon",window.location.origin).toString()}class r extends Error{constructor(e,t,n,i){super(n),this.code=e,this.statusCode=t,this.details=i,this.name="DaemonError"}}async function o(e,t={}){let n=await a(),s=e.startsWith("/")?e:`/${e}`,d=s===i||s.startsWith(`${i}/`)?s:`${i}${s}`,c=`${n.replace(/\/$/,"")}${d}`;try{let e=await fetch(c,{...t,headers:{"Content-Type":"application/json",...t.headers}}),n=await e.json().catch(()=>({ok:!1,error:{code:"parse_error",message:"Failed to parse response"}}));if(!n.ok){if("string"==typeof n.error&&"string"==typeof n.message)throw new r(n.error,e.status,n.message);throw new r(n.error?.code||"unknown",e.status,n.error?.message||`Daemon returned ${e.status}`,n.error?.details)}return n.data}catch(e){if(e instanceof r)throw e;if(e instanceof TypeError&&e.message.includes("fetch"))throw new r("connection_failed",0,"Failed to connect to Chorus daemon. Is it running?");throw new r("unknown",0,e instanceof Error?e.message:"Unknown error")}}},6185:(e,t,n)=>{n.d(t,{$v:()=>i.$,jb:()=>w.jb,RL:()=>s,K7:()=>v.K7,I7:()=>y,dW:()=>v.dW,Ih:()=>o,UT:()=>v.UT,eG:()=>f,qI:()=>v.qI,AI:()=>h,Xx:()=>g.Xx,WH:()=>g.WH});var i=n(4411),a=n(9345);function r(e){let t,n;if(e.attached_files)try{let n=JSON.parse(e.attached_files);Array.isArray(n)&&(t=n)}catch{}if(e.template_snapshot)try{let t=JSON.parse(e.template_snapshot),i=a._i.safeParse(t);i.success&&(n={...i.data,phases:i.data.phases.map(e=>({...e,reviewer:e.reviewer?{...e.reviewer,candidatesWithModels:e.reviewer.candidatesWithModels??(e.reviewer.candidates??[]).map(e=>({lineage:e.lineage,models:e.models??[],...void 0!==e.persona?{persona:e.persona}:{}}))}:e.reviewer}))})}catch{}return{id:e.id,slug:e.slug??void 0,work:e.work,templateId:e.template_id,status:e.status,currentPhaseIdx:e.current_phase_idx??0,yolo:!!e.yolo,attachedFiles:t,repoPath:e.repo_path??void 0,prUrl:e.pr_url??void 0,shipError:e.ship_error??void 0,artifact:e.artifact??void 0,verdict:e.verdict??void 0,templateSnapshot:n,createdAt:e.created_at,updatedAt:e.updated_at,finishedAt:e.finished_at??void 0}}async function o(e){let t=new URLSearchParams;e?.limit&&t.append("limit",e.limit.toString()),e?.offset&&t.append("offset",e.offset.toString()),e?.status&&t.append("status",e.status);let n=t.toString();return(await (0,i.T)(`/chats${n?`?${n}`:""}`)).items.map(r)}async function s(e){return r(await (0,i.T)("/chats",{method:"POST",body:JSON.stringify(e)}))}var d=n(599);let c=new Set(["anthropic","openai","google","opencode","moonshot","any","xai"]),l={anthropic:"claude",openai:"codex",google:"gemini",opencode:"opencode",moonshot:"kimi",any:"claude",xai:"opencode"};function u(e){return e?l[e]??"claude":"claude"}function p(e){let t=e.kind??"review";return{id:e.id??"phase",name:e.title??e.name??e.id??"Phase",description:e.description??"",kind:t,gate:"auto",doer:{lineage:u(e.doer?.lineage),models:e.doer?.models??[],...e.doer?.persona?{persona:e.doer.persona}:{}},reviewer:{require:e.reviewer?.require??1,crossLineage:e.reviewer?.crossLineage??!0,candidates:(e.reviewer?.candidates??[]).map(e=>u(e.lineage)).filter(e=>c.has(Object.keys(l).find(t=>l[t]===e)??"")),candidatesWithModels:(e.reviewer?.candidates??[]).map(e=>({lineage:u(e.lineage),models:e.models??[],...e.persona?{persona:e.persona}:{}}))},inputs:{include:e.inputs?.include??[],exclude:e.inputs?.exclude??[]},iterate:{max:e.iterate?.maxRounds??2,onMax:"ask-user"},blindSpots:[],execution:"parallel",builtin:!0,..."review_only"===t?{artifact:{label:e.artifact?.label??"Artifact to review",hint:e.artifact?.hint??"Paste a unified diff, a markdown draft, code, or any text blob.",maxBytes:e.artifact?.maxBytes??1048576}}:{}}}function m(e){let t={};try{t=d.Ay.parse(e.yaml)??{}}catch{}let n="majority";"number"==typeof t.agreementThreshold?n=t.agreementThreshold>=.99?"unanimous":t.agreementThreshold>=.5?"majority":"any":"string"==typeof t.agreementThreshold&&(n=t.agreementThreshold);let i=(t.phases??[]).map(p);return{id:e.id,name:t.name??e.id,description:t.description??"",category:function(e,t){if(e.category)return e.category;let n=t.toLowerCase();return n.includes("bug")||n.includes("debug")||n.includes("diagnose")?"debug":n.includes("plan")||n.includes("architect")?"plan":n.includes("decide")||n.includes("decision")?"decide":"review"}(t,e.id),phases:i,agreementThreshold:n,onThresholdMet:"auto-finalize"===t.onThresholdMet?"auto-finalize":"ask-user",maxRounds:t.maxRounds??3,driver:"external",driverHandoff:!1,verificationGate:"auto",costCapUsd:0,yoloDefault:t.yoloDefault??!1,estimatedBaselineTokens:t.estimatedBaselineTokens,onError:"ask-user",notify:"dashboard-only",yaml:e.yaml,authorHandle:t.author??"chorus",forks:0,popularity:0,source:e.source,isComplete:"number"==typeof e.is_complete?0!==e.is_complete:!1!==e.is_complete}}async function f(){return(await (0,i.T)("/templates")).items.map(m)}async function h(e){return m(await (0,i.T)("/templates",{method:"POST",body:JSON.stringify(e)}))}async function y(e){await (0,i.T)(`/templates/${encodeURIComponent(e)}`,{method:"DELETE"})}var g=n(6441),w=n(8141),v=n(1993);n(7847)},6441:(e,t,n)=>{n.d(t,{A1:()=>f,Ci:()=>h,Df:()=>o,Dl:()=>m,Ep:()=>s,WH:()=>g,WK:()=>y,Wt:()=>p,Xx:()=>d,fk:()=>a,iW:()=>r,lT:()=>u,nr:()=>l,oD:()=>c});var i=n(4411);async function a(){return(await (0,i.T)("/onboard/detect-clis")).items}async function r(e,t){return(0,i.T)("/onboard/validate-cli-path",{method:"POST",body:JSON.stringify({id:e,path:t})})}async function o(e,t){return(0,i.T)("/onboard/save-cli-path",{method:"POST",body:JSON.stringify({id:e,path:t})})}async function s(e){return(0,i.T)("/settings/permissions",{method:"PUT",body:JSON.stringify(e)})}async function d(e){return(0,i.T)("/settings",{method:"PUT",body:JSON.stringify(e)})}async function c(){return(0,i.T)("/settings/transport")}async function l(e){return(0,i.T)("/settings/transport",{method:"PUT",body:JSON.stringify(e)})}async function u(){return(0,i.T)("/settings/concurrency")}async function p(e){return(0,i.T)("/settings/concurrency",{method:"PUT",body:JSON.stringify(e)})}async function m(){return(0,i.T)("/settings/billing")}async function f(e){return(0,i.T)("/settings/billing",{method:"PUT",body:JSON.stringify(e)})}async function h(){return(0,i.T)("/settings/telemetry")}async function y(e){return(0,i.T)("/settings/telemetry",{method:"PUT",body:JSON.stringify({enabled:e})})}async function g(e,t){return(0,i.T)(`/secrets/${e}`,{method:"PUT",body:JSON.stringify(t)})}},7362:(e,t,n)=>{n.d(t,{cn:()=>r});var i=n(142),a=n(9317);function r(...e){return(0,a.QP)((0,i.$)(e))}},7847:(e,t,n)=>{n.d(t,{createVoice:()=>o,listVoices:()=>a,updateVoice:()=>r});var i=n(4411);async function a(e){return(await (0,i.T)(`/voices${function(e){if(!e)return"";let t=[];return e.lineage&&t.push(`lineage=${encodeURIComponent(e.lineage)}`),e.source&&t.push(`source=${encodeURIComponent(e.source)}`),e.provider&&t.push(`provider=${encodeURIComponent(e.provider)}`),void 0!==e.enabled&&t.push(`enabled=${e.enabled?"true":"false"}`),0===t.length?"":`?${t.join("&")}`}(e)}`)).items}async function r(e,t){return(0,i.T)(`/voices/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(t)})}async function o(e){return(0,i.T)("/voices",{method:"POST",body:JSON.stringify(e)})}},8141:(e,t,n)=>{n.d(t,{Ay:()=>r,jb:()=>a});var i=n(4411);async function a(e){return(0,i.T)(`/orchestrators/${e}/connect`,{method:"POST"})}async function r(){return(0,i.T)("/orchestrators/opencode/models")}},9345:(e,t,n)=>{n.d(t,{_i:()=>f});var i=n(5097),a=n(4747);let r=i.ai().int().min(3e4).max(36e5).optional(),o=i.k5(["anthropic","openai","google","opencode","moonshot","openrouter","local","grok","any"]),s=i.k5(["anthropic","openai","google","opencode","moonshot","openrouter","local","grok"]),d=i.Ik({require:i.ai().int().min(0).default(1),crossLineage:i.zM().default(!0),candidates:i.YO(i.Ik({lineage:s,models:i.YO(i.Yj()).optional(),persona:i.Yj().optional()}))}).superRefine((e,t)=>{if(e.require>e.candidates.length&&t.addIssue({code:a.eq.custom,path:["require"],message:`reviewer.require (${e.require}) cannot exceed reviewer.candidates.length (${e.candidates.length}). Either lower require or add more candidates.`}),e.crossLineage&&e.require>0){let n=new Set(e.candidates.map(e=>e.lineage)).size;e.require>n&&t.addIssue({code:a.eq.custom,path:["require"],message:`reviewer.require (${e.require}) exceeds distinct lineages (${n}) in candidates with crossLineage=true. Either lower require, disable crossLineage, or add candidates from more lineages.`})}}),c=i.Ik({include:i.YO(i.Yj()).default([]),exclude:i.YO(i.Yj()).default([])}).default({include:[],exclude:[]}),l=i.Ik({maxRounds:i.ai().int().min(1).default(2),onDisagreement:i.k5(["continue","escalate","accept-doer"]).default("continue"),shareSessionAcrossRounds:i.zM().default(!0),shareSessionAcrossPhases:i.zM().default(!1)}).default({maxRounds:2,onDisagreement:"continue",shareSessionAcrossRounds:!0,shareSessionAcrossPhases:!1}),u=i.Ik({id:i.Yj().min(1),kind:i.k5(["plan","spec","tests","implement","review","verify","divergence"]),title:i.Yj().min(1),description:i.Yj().optional(),doer:i.Ik({lineage:o,models:i.YO(i.Yj()).optional(),persona:i.Yj().optional()}),reviewer:d.optional(),inputs:c,iterate:l,timeoutMs:r}),p=i.Ik({id:i.Yj().min(1),kind:i.eu("review_only"),title:i.Yj().min(1),description:i.Yj().optional(),reviewer:d,artifact:i.Ik({label:i.Yj().min(1).default("Artifact to review"),hint:i.Yj().default("Paste a unified diff, a markdown draft, code, or any text blob."),maxBytes:i.ai().int().min(1).default(1048576)}).default({label:"Artifact to review",hint:"Paste a unified diff, a markdown draft, code, or any text blob.",maxBytes:1048576}),inputs:c,timeoutMs:r}),m=i.gM("kind",[u.extend({kind:i.eu("plan")}),u.extend({kind:i.eu("spec")}),u.extend({kind:i.eu("tests")}),u.extend({kind:i.eu("implement")}),u.extend({kind:i.eu("review")}),u.extend({kind:i.eu("verify")}),u.extend({kind:i.eu("divergence")}),p]),f=i.Ik({id:i.Yj().min(1),name:i.Yj().min(1),description:i.Yj().min(1),author:i.Yj().default("chorus"),agreementThreshold:i.ai().min(0).max(1).default(.66),onThresholdMet:i.k5(["merge","ask","review"]).default("ask"),maxRounds:i.ai().int().min(1).default(3),yoloDefault:i.zM().default(!1),estimatedBaselineTokens:i.ai().int().min(0).optional(),phases:i.YO(m).min(1).refine(e=>{let t=e.filter(e=>"review_only"===e.kind).length;return 0===t||1===t&&1===e.length},{message:"review_only phases cannot be mixed with other phase kinds and only one is allowed (hybrid templates are out of scope)"}).refine(e=>{let t=e.map(e=>e.id);return new Set(t).size===t.length},{message:"phase ids must be unique"}),ship:i.Ik({enabled:i.zM().default(!1),baseBranch:i.Yj().optional(),branchPattern:i.Yj().default("chorus/{chatId}"),titleTemplate:i.Yj().default("chorus: {template} via #{chatId}")}).optional(),fallback:i.Ik({doer:i.YO(i.Ik({lineage:o,models:i.YO(i.Yj()).min(1),persona:i.Yj().optional()})).optional(),reviewer:i.YO(i.Ik({lineage:s,models:i.YO(i.Yj()).min(1),persona:i.Yj().optional()})).optional()}).optional()})}}]);
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[641],{1993:(e,t,n)=>{n.d(t,{K7:()=>d,UT:()=>r,dW:()=>o,qI:()=>s});var i=n(4411);function a(e){return{id:e.id,label:e.label,one_liner:e.one_liner,system_prompt:e.system_prompt,recommended_lineage:e.recommended_lineage,builtin:!!e.builtin,forked_from:e.forked_from??null,created_at:e.created_at,updated_at:e.updated_at}}async function r(){return(await (0,i.T)("/personas")).items.map(a)}async function o(e){return a(await (0,i.T)(`/personas/${encodeURIComponent(e)}`))}async function s(e){return a(await (0,i.T)("/personas",{method:"POST",body:JSON.stringify(e)}))}async function d(e){await (0,i.T)(`/personas/${encodeURIComponent(e)}`,{method:"DELETE"})}},4284:(e,t,n)=>{n.d(t,{U:()=>a});var i=n(9442);function a({className:e}){return(0,i.jsxs)("svg",{viewBox:"0 0 32 32","aria-hidden":"true",className:e,fill:"currentColor",children:[(0,i.jsx)("circle",{cx:"11",cy:"20",r:"3.2",fillOpacity:"0.55"}),(0,i.jsx)("circle",{cx:"21",cy:"20",r:"3.2",fillOpacity:"0.55"}),(0,i.jsx)("circle",{cx:"16",cy:"11",r:"3.2"})]})}},4411:(e,t,n)=>{n.d(t,{$:()=>r,T:()=>o}),n(9298);let i="/api/v1";async function a(){return new URL("/api/daemon",window.location.origin).toString()}class r extends Error{constructor(e,t,n,i){super(n),this.code=e,this.statusCode=t,this.details=i,this.name="DaemonError"}}async function o(e,t={}){let n=await a(),s=e.startsWith("/")?e:`/${e}`,d=s===i||s.startsWith(`${i}/`)?s:`${i}${s}`,c=`${n.replace(/\/$/,"")}${d}`;try{let e=await fetch(c,{...t,headers:{"Content-Type":"application/json",...t.headers}}),n=await e.json().catch(()=>({ok:!1,error:{code:"parse_error",message:"Failed to parse response"}}));if(!n.ok){if("string"==typeof n.error&&"string"==typeof n.message)throw new r(n.error,e.status,n.message);throw new r(n.error?.code||"unknown",e.status,n.error?.message||`Daemon returned ${e.status}`,n.error?.details)}return n.data}catch(e){if(e instanceof r)throw e;if(e instanceof TypeError&&e.message.includes("fetch"))throw new r("connection_failed",0,"Failed to connect to Chorus daemon. Is it running?");throw new r("unknown",0,e instanceof Error?e.message:"Unknown error")}}},6185:(e,t,n)=>{n.d(t,{$v:()=>i.$,jb:()=>w.jb,RL:()=>s,K7:()=>v.K7,I7:()=>y,dW:()=>v.dW,Ih:()=>o,UT:()=>v.UT,eG:()=>f,qI:()=>v.qI,AI:()=>h,Xx:()=>g.Xx,WH:()=>g.WH});var i=n(4411),a=n(9345);function r(e){let t,n;if(e.attached_files)try{let n=JSON.parse(e.attached_files);Array.isArray(n)&&(t=n)}catch{}if(e.template_snapshot)try{let t=JSON.parse(e.template_snapshot),i=a._i.safeParse(t);i.success&&(n={...i.data,phases:i.data.phases.map(e=>({...e,reviewer:e.reviewer?{...e.reviewer,candidatesWithModels:e.reviewer.candidatesWithModels??(e.reviewer.candidates??[]).map(e=>({lineage:e.lineage,models:e.models??[],...void 0!==e.persona?{persona:e.persona}:{}}))}:e.reviewer}))})}catch{}return{id:e.id,slug:e.slug??void 0,work:e.work,templateId:e.template_id,status:e.status,currentPhaseIdx:e.current_phase_idx??0,yolo:!!e.yolo,attachedFiles:t,repoPath:e.repo_path??void 0,prUrl:e.pr_url??void 0,shipError:e.ship_error??void 0,artifact:e.artifact??void 0,verdict:e.verdict??void 0,templateSnapshot:n,createdAt:e.created_at,updatedAt:e.updated_at,finishedAt:e.finished_at??void 0}}async function o(e){let t=new URLSearchParams;e?.limit&&t.append("limit",e.limit.toString()),e?.offset&&t.append("offset",e.offset.toString()),e?.status&&t.append("status",e.status);let n=t.toString();return(await (0,i.T)(`/chats${n?`?${n}`:""}`)).items.map(r)}async function s(e){return r(await (0,i.T)("/chats",{method:"POST",body:JSON.stringify(e)}))}var d=n(599);let c=new Set(["anthropic","openai","google","opencode","moonshot","any","xai"]),l={anthropic:"claude",openai:"codex",google:"gemini",opencode:"opencode",moonshot:"kimi",any:"claude",xai:"opencode"};function u(e){return e?l[e]??"claude":"claude"}function p(e){let t=e.kind??"review";return{id:e.id??"phase",name:e.title??e.name??e.id??"Phase",description:e.description??"",kind:t,gate:"auto",doer:{lineage:u(e.doer?.lineage),models:e.doer?.models??[],...e.doer?.persona?{persona:e.doer.persona}:{}},reviewer:{require:e.reviewer?.require??1,crossLineage:e.reviewer?.crossLineage??!0,candidates:(e.reviewer?.candidates??[]).map(e=>u(e.lineage)).filter(e=>c.has(Object.keys(l).find(t=>l[t]===e)??"")),candidatesWithModels:(e.reviewer?.candidates??[]).map(e=>({lineage:u(e.lineage),models:e.models??[],...e.persona?{persona:e.persona}:{}}))},inputs:{include:e.inputs?.include??[],exclude:e.inputs?.exclude??[]},iterate:{max:e.iterate?.maxRounds??2,onMax:"ask-user"},blindSpots:[],execution:"parallel",builtin:!0,..."review_only"===t?{artifact:{label:e.artifact?.label??"Artifact to review",hint:e.artifact?.hint??"Paste a unified diff, a markdown draft, code, or any text blob.",maxBytes:e.artifact?.maxBytes??1048576}}:{}}}function m(e){let t={};try{t=d.Ay.parse(e.yaml)??{}}catch{}let n="majority";"number"==typeof t.agreementThreshold?n=t.agreementThreshold>=.99?"unanimous":t.agreementThreshold>=.5?"majority":"any":"string"==typeof t.agreementThreshold&&(n=t.agreementThreshold);let i=(t.phases??[]).map(p);return{id:e.id,name:t.name??e.id,description:t.description??"",category:function(e,t){if(e.category)return e.category;let n=t.toLowerCase();return n.includes("bug")||n.includes("debug")||n.includes("diagnose")?"debug":n.includes("plan")||n.includes("architect")?"plan":n.includes("decide")||n.includes("decision")?"decide":"review"}(t,e.id),phases:i,agreementThreshold:n,onThresholdMet:"auto-finalize"===t.onThresholdMet?"auto-finalize":"ask-user",maxRounds:t.maxRounds??3,driver:"external",driverHandoff:!1,verificationGate:"auto",costCapUsd:0,yoloDefault:t.yoloDefault??!1,estimatedBaselineTokens:t.estimatedBaselineTokens,onError:"ask-user",notify:"dashboard-only",yaml:e.yaml,authorHandle:t.author??"chorus",forks:0,popularity:0,source:e.source,isComplete:"number"==typeof e.is_complete?0!==e.is_complete:!1!==e.is_complete}}async function f(){return(await (0,i.T)("/templates")).items.map(m)}async function h(e){return m(await (0,i.T)("/templates",{method:"POST",body:JSON.stringify(e)}))}async function y(e){await (0,i.T)(`/templates/${encodeURIComponent(e)}`,{method:"DELETE"})}var g=n(6441),w=n(8141),v=n(1993);n(7847)},6441:(e,t,n)=>{n.d(t,{A1:()=>f,Ci:()=>h,Df:()=>o,Dl:()=>m,Ep:()=>s,WH:()=>g,WK:()=>y,Wt:()=>p,Xx:()=>d,fk:()=>a,iW:()=>r,lT:()=>u,nr:()=>l,oD:()=>c});var i=n(4411);async function a(){return(await (0,i.T)("/onboard/detect-clis")).items}async function r(e,t){return(0,i.T)("/onboard/validate-cli-path",{method:"POST",body:JSON.stringify({id:e,path:t})})}async function o(e,t){return(0,i.T)("/onboard/save-cli-path",{method:"POST",body:JSON.stringify({id:e,path:t})})}async function s(e){return(0,i.T)("/settings/permissions",{method:"PUT",body:JSON.stringify(e)})}async function d(e){return(0,i.T)("/settings",{method:"PUT",body:JSON.stringify(e)})}async function c(){return(0,i.T)("/settings/transport")}async function l(e){return(0,i.T)("/settings/transport",{method:"PUT",body:JSON.stringify(e)})}async function u(){return(0,i.T)("/settings/concurrency")}async function p(e){return(0,i.T)("/settings/concurrency",{method:"PUT",body:JSON.stringify(e)})}async function m(){return(0,i.T)("/settings/billing")}async function f(e){return(0,i.T)("/settings/billing",{method:"PUT",body:JSON.stringify(e)})}async function h(){return(0,i.T)("/settings/telemetry")}async function y(e){return(0,i.T)("/settings/telemetry",{method:"PUT",body:JSON.stringify({enabled:e})})}async function g(e,t){return(0,i.T)(`/secrets/${e}`,{method:"PUT",body:JSON.stringify(t)})}},7362:(e,t,n)=>{n.d(t,{cn:()=>r});var i=n(142),a=n(9317);function r(...e){return(0,a.QP)((0,i.$)(e))}},7847:(e,t,n)=>{n.d(t,{createVoice:()=>o,listVoices:()=>a,updateVoice:()=>r});var i=n(4411);async function a(e){return(await (0,i.T)(`/voices${function(e){if(!e)return"";let t=[];return e.lineage&&t.push(`lineage=${encodeURIComponent(e.lineage)}`),e.source&&t.push(`source=${encodeURIComponent(e.source)}`),e.provider&&t.push(`provider=${encodeURIComponent(e.provider)}`),void 0!==e.enabled&&t.push(`enabled=${e.enabled?"true":"false"}`),0===t.length?"":`?${t.join("&")}`}(e)}`)).items}async function r(e,t){return(0,i.T)(`/voices/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(t)})}async function o(e){return(0,i.T)("/voices",{method:"POST",body:JSON.stringify(e)})}},8141:(e,t,n)=>{n.d(t,{Ay:()=>r,jb:()=>a});var i=n(4411);async function a(e){return(0,i.T)(`/orchestrators/${e}/connect`,{method:"POST"})}async function r(){return(0,i.T)("/orchestrators/opencode/models")}},9345:(e,t,n)=>{n.d(t,{_i:()=>f});var i=n(5097),a=n(4747);let r=i.ai().int().min(3e4).max(36e5).optional(),o=i.k5(["anthropic","openai","google","opencode","moonshot","openrouter","local","grok","antigravity","any"]),s=i.k5(["anthropic","openai","google","opencode","moonshot","openrouter","local","grok","antigravity"]),d=i.Ik({require:i.ai().int().min(0).default(1),crossLineage:i.zM().default(!0),candidates:i.YO(i.Ik({lineage:s,models:i.YO(i.Yj()).optional(),persona:i.Yj().optional()}))}).superRefine((e,t)=>{if(e.require>e.candidates.length&&t.addIssue({code:a.eq.custom,path:["require"],message:`reviewer.require (${e.require}) cannot exceed reviewer.candidates.length (${e.candidates.length}). Either lower require or add more candidates.`}),e.crossLineage&&e.require>0){let n=new Set(e.candidates.map(e=>e.lineage)).size;e.require>n&&t.addIssue({code:a.eq.custom,path:["require"],message:`reviewer.require (${e.require}) exceeds distinct lineages (${n}) in candidates with crossLineage=true. Either lower require, disable crossLineage, or add candidates from more lineages.`})}}),c=i.Ik({include:i.YO(i.Yj()).default([]),exclude:i.YO(i.Yj()).default([])}).default({include:[],exclude:[]}),l=i.Ik({maxRounds:i.ai().int().min(1).default(2),onDisagreement:i.k5(["continue","escalate","accept-doer"]).default("continue"),shareSessionAcrossRounds:i.zM().default(!0),shareSessionAcrossPhases:i.zM().default(!1)}).default({maxRounds:2,onDisagreement:"continue",shareSessionAcrossRounds:!0,shareSessionAcrossPhases:!1}),u=i.Ik({id:i.Yj().min(1),kind:i.k5(["plan","spec","tests","implement","review","verify","divergence"]),title:i.Yj().min(1),description:i.Yj().optional(),doer:i.Ik({lineage:o,models:i.YO(i.Yj()).optional(),persona:i.Yj().optional()}),reviewer:d.optional(),inputs:c,iterate:l,timeoutMs:r}),p=i.Ik({id:i.Yj().min(1),kind:i.eu("review_only"),title:i.Yj().min(1),description:i.Yj().optional(),reviewer:d,artifact:i.Ik({label:i.Yj().min(1).default("Artifact to review"),hint:i.Yj().default("Paste a unified diff, a markdown draft, code, or any text blob."),maxBytes:i.ai().int().min(1).default(1048576)}).default({label:"Artifact to review",hint:"Paste a unified diff, a markdown draft, code, or any text blob.",maxBytes:1048576}),inputs:c,timeoutMs:r}),m=i.gM("kind",[u.extend({kind:i.eu("plan")}),u.extend({kind:i.eu("spec")}),u.extend({kind:i.eu("tests")}),u.extend({kind:i.eu("implement")}),u.extend({kind:i.eu("review")}),u.extend({kind:i.eu("verify")}),u.extend({kind:i.eu("divergence")}),p]),f=i.Ik({id:i.Yj().min(1),name:i.Yj().min(1),description:i.Yj().min(1),author:i.Yj().default("chorus"),agreementThreshold:i.ai().min(0).max(1).default(.66),onThresholdMet:i.k5(["merge","ask","review"]).default("ask"),maxRounds:i.ai().int().min(1).default(3),yoloDefault:i.zM().default(!1),estimatedBaselineTokens:i.ai().int().min(0).optional(),phases:i.YO(m).min(1).refine(e=>{let t=e.filter(e=>"review_only"===e.kind).length;return 0===t||1===t&&1===e.length},{message:"review_only phases cannot be mixed with other phase kinds and only one is allowed (hybrid templates are out of scope)"}).refine(e=>{let t=e.map(e=>e.id);return new Set(t).size===t.length},{message:"phase ids must be unique"}),ship:i.Ik({enabled:i.zM().default(!1),baseBranch:i.Yj().optional(),branchPattern:i.Yj().default("chorus/{chatId}"),titleTemplate:i.Yj().default("chorus: {template} via #{chatId}")}).optional(),fallback:i.Ik({doer:i.YO(i.Ik({lineage:o,models:i.YO(i.Yj()).min(1),persona:i.Yj().optional()})).optional(),reviewer:i.YO(i.Ik({lineage:s,models:i.YO(i.Yj()).min(1),persona:i.Yj().optional()})).optional()}).optional()})}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[744],{63:(e,t,r)=>{r.d(t,{Zp:()=>o});var a=r(9442);r(6074);var n=r(7362);function o({className:e,...t}){return(0,a.jsx)("div",{"data-slot":"card",className:(0,n.cn)("flex flex-col gap-6 rounded-xl border bg-card py-6 text-card-foreground shadow-sm",e),...t})}},1749:(e,t,r)=>{r.d(t,{$:()=>s});var a=r(9442);r(6074);var n=r(9056),o=r(8113),i=r(7362);let d=(0,n.F)("inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",xs:"h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-xs":"size-6 rounded-md [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function s({className:e,variant:t="default",size:r="default",asChild:n=!1,...l}){let g=n?o.bL:"button";return(0,a.jsx)(g,{"data-slot":"button","data-variant":t,"data-size":r,className:(0,i.cn)(d({variant:t,size:r,className:e})),...l})}},1853:(e,t,r)=>{r.d(t,{Cf:()=>c,L3:()=>b,c7:()=>u,lG:()=>d,rr:()=>f,zM:()=>s});var a=r(9442);r(6074);var n=r(6891),o=r(3703),i=r(7362);function d({...e}){return(0,a.jsx)(o.bL,{"data-slot":"dialog",...e})}function s({...e}){return(0,a.jsx)(o.l9,{"data-slot":"dialog-trigger",...e})}function l({...e}){return(0,a.jsx)(o.ZL,{"data-slot":"dialog-portal",...e})}function g({className:e,...t}){return(0,a.jsx)(o.hJ,{"data-slot":"dialog-overlay",className:(0,i.cn)("fixed inset-0 z-50 bg-black/75 backdrop-blur-sm data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",e),...t})}function c({className:e,children:t,showCloseButton:r=!0,...d}){return(0,a.jsxs)(l,{"data-slot":"dialog-portal",children:[(0,a.jsx)(g,{}),(0,a.jsxs)(o.UC,{"data-slot":"dialog-content",className:(0,i.cn)("fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg",e),...d,children:[t,r&&(0,a.jsxs)(o.bm,{"data-slot":"dialog-close",className:"absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[(0,a.jsx)(n.A,{}),(0,a.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function u({className:e,...t}){return(0,a.jsx)("div",{"data-slot":"dialog-header",className:(0,i.cn)("flex flex-col gap-2 text-center sm:text-left",e),...t})}function b({className:e,...t}){return(0,a.jsx)(o.hE,{"data-slot":"dialog-title",className:(0,i.cn)("text-lg leading-none font-semibold",e),...t})}function f({className:e,...t}){return(0,a.jsx)(o.VY,{"data-slot":"dialog-description",className:(0,i.cn)("text-sm text-muted-foreground",e),...t})}r(1749)},3734:(e,t,r)=>{r.d(t,{JR:()=>g,QJ:()=>o,VW:()=>i,YM:()=>u,m_:()=>d,r2:()=>b,u5:()=>l,x0:()=>c,ze:()=>a});let a={anthropic:"Claude",openai:"Codex",google:"Gemini",opencode:"OpenCode",moonshot:"Kimi",local:"Local LLM",grok:"Grok",antigravity:"Antigravity"},n={anthropic:"bg-violet-400",openai:"bg-orange-400",google:"bg-blue-400",opencode:"bg-emerald-400",moonshot:"bg-pink-400",local:"bg-teal-400",grok:"bg-slate-400",antigravity:"bg-sky-400"};function o(e){return e?a[e]??e:""}function i(e){return e?n[e]??"bg-muted":"bg-muted"}let d={claude:"Claude",codex:"Codex",gemini:"Gemini",opencode:"OpenCode",kimi:"Kimi",openrouter:"OpenRouter",local:"Local LLM",grok:"Grok",antigravity:"Antigravity"},s={claude:"bg-violet-400",codex:"bg-orange-400",gemini:"bg-blue-400",opencode:"bg-emerald-400",kimi:"bg-pink-400",openrouter:"bg-cyan-400",local:"bg-teal-400",grok:"bg-slate-400",antigravity:"bg-sky-400"};function l(e){return e?d[e]??e:""}function g(e){return e?s[e]??"bg-muted":"bg-muted"}let c={claude:"claude-opus-4-7",codex:"gpt-5.5",gemini:"gemini-2.5-pro",opencode:"kimi-k2.6",kimi:"kimi-k2.6",openrouter:"",local:"",grok:"grok-build",antigravity:"gemini-3.5-flash"};function u(e){if(e)return c[e]}let b={claude:{dot:"bg-violet-400",ring:"ring-violet-400/40",gradient:"bg-gradient-to-b from-violet-500/15 to-card"},codex:{dot:"bg-orange-400",ring:"ring-orange-400/40",gradient:"bg-gradient-to-b from-orange-500/15 to-card"},gemini:{dot:"bg-blue-400",ring:"ring-blue-400/40",gradient:"bg-gradient-to-b from-blue-500/15 to-card"},opencode:{dot:"bg-emerald-400",ring:"ring-emerald-400/40",gradient:"bg-gradient-to-b from-emerald-500/15 to-card"},kimi:{dot:"bg-pink-400",ring:"ring-pink-400/40",gradient:"bg-gradient-to-b from-pink-500/15 to-card"},openrouter:{dot:"bg-cyan-400",ring:"ring-cyan-400/40",gradient:"bg-gradient-to-b from-cyan-500/15 to-card"},local:{dot:"bg-teal-400",ring:"ring-teal-400/40",gradient:"bg-gradient-to-b from-teal-500/15 to-card"},grok:{dot:"bg-slate-400",ring:"ring-slate-400/40",gradient:"bg-gradient-to-b from-slate-500/15 to-card"},antigravity:{dot:"bg-sky-400",ring:"ring-sky-400/40",gradient:"bg-gradient-to-b from-sky-500/15 to-card"}}},4372:(e,t,r)=>{r.d(t,{G:()=>i});var a=r(9442),n=r(821),o=r(8344);function i({children:e}){return(0,a.jsxs)("div",{className:"flex h-screen w-screen overflow-hidden bg-background text-foreground",children:[(0,a.jsx)(n.AppSidebar,{}),(0,a.jsxs)("div",{className:"flex flex-1 flex-col overflow-hidden",children:[(0,a.jsx)(o.MobileTopBar,{}),(0,a.jsx)("main",{className:"flex-1 overflow-y-auto",children:e})]})]})}},5702:(e,t,r)=>{r.d(t,{E:()=>s});var a=r(9442);r(6074);var n=r(9056),o=r(8113),i=r(7362);let d=(0,n.F)("inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3",{variants:{variant:{default:"bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"bg-destructive text-white focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40 [a&]:hover:bg-destructive/90",outline:"border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",ghost:"[a&]:hover:bg-accent [a&]:hover:text-accent-foreground",link:"text-primary underline-offset-4 [a&]:hover:underline"}},defaultVariants:{variant:"default"}});function s({className:e,variant:t="default",asChild:r=!1,...n}){let l=r?o.bL:"span";return(0,a.jsx)(l,{"data-slot":"badge","data-variant":t,className:(0,i.cn)(d({variant:t}),e),...n})}},6457:(e,t,r)=>{r.d(t,{z:()=>n});var a=r(9442);function n({eyebrow:e,title:t,subtitle:r,action:o}){return(0,a.jsxs)("header",{className:"mb-6 flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"text-xs uppercase tracking-wider text-muted-foreground",children:e}),(0,a.jsx)("h1",{className:"mt-1 text-2xl font-semibold tracking-tight",children:t}),r&&(0,a.jsx)("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed text-muted-foreground",children:r})]}),o&&(0,a.jsx)("div",{className:"shrink-0 self-start sm:self-auto",children:o})]})}},8191:(e,t,r)=>{r.d(t,{N:()=>o});var a=r(9442),n=r(9208);function o({filename:e,charCount:t,footer:r,maxHeightClassName:i="max-h-[70vh]",children:d}){return(0,a.jsxs)("div",{className:"flex h-full min-w-0 flex-col overflow-hidden rounded-lg border border-border bg-card",children:[(0,a.jsxs)("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b border-border bg-card/60 px-4 py-2.5",children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-2 font-mono text-[11px] text-muted-foreground",children:[(0,a.jsx)(n.A,{className:"h-3 w-3 shrink-0"}),(0,a.jsx)("span",{className:"truncate",children:e})]}),"number"==typeof t&&(0,a.jsxs)("span",{className:"font-mono text-[10px] text-muted-foreground/70",children:[t.toLocaleString()," chars"]})]}),(0,a.jsx)("pre",{className:`${i} min-h-0 flex-1 overflow-auto whitespace-pre-wrap break-words bg-background px-5 py-4 font-mono text-[12px] leading-relaxed text-foreground/90`,children:d}),r&&(0,a.jsx)("div",{className:"flex shrink-0 items-center justify-between gap-2 border-t border-border bg-card/60 px-4 py-2.5 text-[11px] text-muted-foreground",children:r})]})}}}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[951],{1727:(e,t,r)=>{"use strict";r.d(t,{OrchestratorCard:()=>g});var a=r(9442),n=r(6074),d=r(9707),s=r(3149),i=r(6823),o=r(4030),l=r(6185),c=r(7847),m=r(3734),u=r(7362);let p={claude:"claude-code",codex:"codex-cli",gemini:"gemini-cli",opencode:"opencode-cli",kimi:"kimi-cli"},x={dot:"bg-muted-foreground/40",gradient:"bg-gradient-to-br from-muted/30 via-card to-card"};function g({initial:e,voices:t}){var r;let[h,f]=(0,n.useState)(e),[y,j]=(0,n.useState)(!1),[v,N]=(0,n.useState)(null),[k,w]=(0,n.useState)(!1),A=p[e.name],[C,S]=(0,n.useState)(t),[M,_]=(0,n.useState)(null),[P,O]=(0,n.useState)(null),L=!!A&&C.length>0,$=C.filter(e=>e.enabled).length,E="opencode-cli"===A,R=h.connected,T=h.approvedTools>0&&!R,z=(r=e.name)in m.r2?m.r2[r]:x,V=async()=>{j(!0),N(null);try{let e=await (0,l.jb)(h.name);f(e.status),w(e.added.length>0)}catch(e){N(e instanceof l.$v?e.message:"Failed to connect — is the daemon running?")}finally{j(!1)}},F=async e=>{_(e.id),O(null);try{let t=await (0,c.updateVoice)(e.id,{enabled:!e.enabled});S(e=>e.map(e=>e.id===t.id?t:e))}catch(e){O(e instanceof l.$v?e.message:"Couldn't save. Is the daemon running?")}finally{_(null)}},I=new Map;if(E)for(let e of C){let t=e.model_id.indexOf("/"),r=t>0?e.model_id.slice(0,t):"other",a=I.get(r)??[];a.push(e),I.set(r,a)}let G=Array.from(I.keys()).sort();return(0,a.jsxs)("div",{className:(0,u.cn)("flex h-72 flex-col rounded-lg border border-border",z.gradient),children:[(0,a.jsx)("div",{className:"flex shrink-0 items-center gap-3 px-4 py-3",children:(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[(0,a.jsx)("span",{className:(0,u.cn)("h-2 w-2 shrink-0 rounded-full",z.dot)}),(0,a.jsx)("h3",{className:"whitespace-nowrap text-sm font-semibold",children:h.label}),R?(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-emerald-500/10 px-2 py-0.5 text-[10px] font-medium text-emerald-300",children:[(0,a.jsx)(d.A,{className:"h-3 w-3"})," Connected"]}):T?(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-amber-500/10 px-2 py-0.5 text-[10px] font-medium text-amber-300",children:[h.approvedTools,"/",h.totalTools," tools"]}):h.supported?(0,a.jsx)("span",{className:"inline-flex items-center rounded-full border border-border bg-card px-2 py-0.5 text-[10px] font-medium text-muted-foreground",children:"Not connected"}):(0,a.jsx)("span",{className:"inline-flex items-center rounded-full border border-border bg-card px-2 py-0.5 text-[10px] font-medium text-muted-foreground",children:"Coming soon"}),L&&(0,a.jsxs)("span",{className:"whitespace-nowrap text-[10px] text-muted-foreground",children:["\xb7 ",$," model",1===$?"":"s"]})]})}),(0,a.jsxs)("div",{className:"flex flex-1 flex-col gap-3 overflow-y-auto border-t border-border bg-card/30 p-4",children:[(0,a.jsx)("p",{className:"text-[11px] leading-relaxed text-muted-foreground",children:h.note}),!h.supported&&(0,a.jsx)("p",{className:"text-[11px] italic text-muted-foreground/70",children:"Wiring will land in a future release."}),h.supported&&(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsxs)("button",{type:"button",onClick:V,disabled:y||R&&!T,className:"inline-flex h-8 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground transition hover:bg-primary/90 disabled:cursor-not-allowed disabled:bg-muted disabled:text-muted-foreground",children:[y?(0,a.jsx)(s.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,a.jsx)(i.A,{className:"h-3.5 w-3.5"}),R?"Already connected":T?"Approve remaining tools":`Connect ${h.label}`]}),k&&!v&&(0,a.jsxs)("p",{className:"text-[11px] text-emerald-400",children:["✓ Done. Restart ",h.label," for the change to take effect."]}),v&&(0,a.jsxs)("p",{className:"flex items-start gap-1 text-[11px] text-destructive",children:[(0,a.jsx)(o.A,{className:"mt-0.5 h-3 w-3 shrink-0"})," ",v]})]}),R&&"prompts_once"===h.firstCallBehavior&&(0,a.jsx)("p",{className:"text-[11px] text-amber-300/90",children:'⚠ First chorus.* call will show a one-time prompt — click "Always allow".'}),L&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("p",{className:"text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:"Models"}),P&&(0,a.jsx)("p",{className:"text-[11px] text-destructive",children:P}),E?(0,a.jsx)("div",{className:"space-y-2",children:G.map(e=>{let t=I.get(e)??[];return(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsxs)("p",{className:"text-[10px] font-mono text-muted-foreground/80",children:[e,"/"]}),(0,a.jsx)("div",{className:"grid grid-cols-1 gap-1 sm:grid-cols-2",children:t.map(t=>(0,a.jsx)(b,{label:t.model_id.slice(e.length+1),value:t.model_id,selected:t.enabled,disabled:M===t.id,onClick:()=>F(t)},t.id))})]},e)})}):(0,a.jsx)("div",{className:"grid grid-cols-1 gap-1 sm:grid-cols-2",children:C.map(e=>(0,a.jsx)(b,{label:e.model_id,value:e.model_id,selected:e.enabled,disabled:M===e.id,onClick:()=>F(e)},e.id))})]})]})]})}function b({label:e,value:t,selected:r,disabled:n,onClick:s}){return(0,a.jsxs)("button",{type:"button",disabled:n,onClick:s,title:t,className:(0,u.cn)("flex items-center gap-2 rounded border px-2 py-1.5 text-left text-[11px] transition disabled:opacity-60",r?"border-primary/50 bg-primary/10 text-foreground":"border-border bg-card hover:border-muted-foreground/30 text-muted-foreground"),children:[(0,a.jsx)("div",{className:(0,u.cn)("grid h-3 w-3 shrink-0 place-items-center rounded-sm border transition",r?"border-primary bg-primary text-primary-foreground":"border-border"),children:r&&(0,a.jsx)(d.A,{className:"h-2 w-2"})}),(0,a.jsx)("span",{className:"truncate font-mono",children:e})]})}},2545:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let a=(0,r(3884).A)("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]])},2881:(e,t,r)=>{"use strict";r.d(t,{Eu:()=>s,M5:()=>n,Y8:()=>d});var a=r(4411);async function n(e){return(0,a.T)("/openrouter/save-key",{method:"POST",body:JSON.stringify({apiKey:e})})}async function d(){return(0,a.T)("/openrouter/models")}async function s(e,t){return(0,a.T)("/openrouter/voices",{method:"POST",body:JSON.stringify(t?{modelIds:e,apiKey:t}:{modelIds:e})})}},3149:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let a=(0,r(3884).A)("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]])},3734:(e,t,r)=>{"use strict";r.d(t,{JR:()=>c,QJ:()=>d,VW:()=>s,YM:()=>u,m_:()=>i,r2:()=>p,u5:()=>l,x0:()=>m,ze:()=>a});let a={anthropic:"Claude",openai:"Codex",google:"Gemini",opencode:"OpenCode",moonshot:"Kimi",local:"Local LLM",grok:"Grok",antigravity:"Antigravity"},n={anthropic:"bg-violet-400",openai:"bg-orange-400",google:"bg-blue-400",opencode:"bg-emerald-400",moonshot:"bg-pink-400",local:"bg-teal-400",grok:"bg-slate-400",antigravity:"bg-sky-400"};function d(e){return e?a[e]??e:""}function s(e){return e?n[e]??"bg-muted":"bg-muted"}let i={claude:"Claude",codex:"Codex",gemini:"Gemini",opencode:"OpenCode",kimi:"Kimi",openrouter:"OpenRouter",local:"Local LLM",grok:"Grok",antigravity:"Antigravity"},o={claude:"bg-violet-400",codex:"bg-orange-400",gemini:"bg-blue-400",opencode:"bg-emerald-400",kimi:"bg-pink-400",openrouter:"bg-cyan-400",local:"bg-teal-400",grok:"bg-slate-400",antigravity:"bg-sky-400"};function l(e){return e?i[e]??e:""}function c(e){return e?o[e]??"bg-muted":"bg-muted"}let m={claude:"claude-opus-4-7",codex:"gpt-5.5",gemini:"gemini-2.5-pro",opencode:"kimi-k2.6",kimi:"kimi-k2.6",openrouter:"",local:"",grok:"grok-build",antigravity:"gemini-3.5-flash"};function u(e){if(e)return m[e]}let p={claude:{dot:"bg-violet-400",ring:"ring-violet-400/40",gradient:"bg-gradient-to-b from-violet-500/15 to-card"},codex:{dot:"bg-orange-400",ring:"ring-orange-400/40",gradient:"bg-gradient-to-b from-orange-500/15 to-card"},gemini:{dot:"bg-blue-400",ring:"ring-blue-400/40",gradient:"bg-gradient-to-b from-blue-500/15 to-card"},opencode:{dot:"bg-emerald-400",ring:"ring-emerald-400/40",gradient:"bg-gradient-to-b from-emerald-500/15 to-card"},kimi:{dot:"bg-pink-400",ring:"ring-pink-400/40",gradient:"bg-gradient-to-b from-pink-500/15 to-card"},openrouter:{dot:"bg-cyan-400",ring:"ring-cyan-400/40",gradient:"bg-gradient-to-b from-cyan-500/15 to-card"},local:{dot:"bg-teal-400",ring:"ring-teal-400/40",gradient:"bg-gradient-to-b from-teal-500/15 to-card"},grok:{dot:"bg-slate-400",ring:"ring-slate-400/40",gradient:"bg-gradient-to-b from-slate-500/15 to-card"},antigravity:{dot:"bg-sky-400",ring:"ring-sky-400/40",gradient:"bg-gradient-to-b from-sky-500/15 to-card"}}},4030:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let a=(0,r(3884).A)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},7130:(e,t,r)=>{"use strict";r.d(t,{OpenRouterCard:()=>x});var a=r(9442),n=r(6074),d=r(9707),s=r(2545),i=r(3149),o=r(4030),l=r(9812),c=r(7362),m=r(2881),u=r(7847),p=r(3734);function x({voices:e}){let[t,r]=(0,n.useState)(e),[b,h]=(0,n.useState)(null),[f,y]=(0,n.useState)(!1),[j,v]=(0,n.useState)(!1),[N,k]=(0,n.useState)(""),[w,A]=(0,n.useState)(!1),[C,S]=(0,n.useState)(null),[M,_]=(0,n.useState)(!1),[P,O]=(0,n.useState)(""),[L,$]=(0,n.useState)(new Set),[E,R]=(0,n.useState)(!1),[T,z]=(0,n.useState)(null),[V,F]=(0,n.useState)(null),[I,G]=(0,n.useState)(null),[q,J]=(0,n.useState)(null),Y=t.filter(e=>e.enabled).length,K=t.length>0;async function W(){if(!f){y(!0),S(null),v(!0);try{let{models:e}=await (0,m.Y8)();e.sort((e,t)=>e.id.localeCompare(t.id)),h(e),_(!1)}catch(t){let e=t instanceof Error?t.message:String(t);_(!0),/no openrouter api key/i.test(e)||S(e)}finally{y(!1)}}}async function B(){if(0!==N.trim().length){A(!0),S(null);try{let e=await (0,m.M5)(N.trim());if(!e.valid)return void S(e.error??"Validation failed");k(""),_(!1);let{models:t}=await (0,m.Y8)();t.sort((e,t)=>e.id.localeCompare(t.id)),h(t),v(!0)}catch(e){S(e instanceof Error?e.message:String(e))}finally{A(!1)}}}async function D(){if(0!==L.size){R(!0),z(null),F(null);try{let e=await (0,m.Eu)(Array.from(L)),t=e.added.length,a=e.skipped.length;F(`Added ${t} voice${1===t?"":"s"}`+(a>0?` \xb7 skipped ${a} (unknown id)`:"")),$(new Set);try{let e=await (0,u.listVoices)({source:"api",provider:"openrouter"});r(e)}catch{}}catch(e){z(e instanceof Error?e.message:String(e))}finally{R(!1)}}}async function H(e){G(e.id),J(null);try{let t=await (0,u.updateVoice)(e.id,{enabled:!e.enabled});r(e=>e.map(e=>e.id===t.id?t:e))}catch(e){J(e instanceof Error?e.message:String(e))}finally{G(null)}}let Q=P.trim()?(b??[]).filter(e=>e.id.toLowerCase().includes(P.toLowerCase().trim())||e.name.toLowerCase().includes(P.toLowerCase().trim())):b??[];return(0,a.jsxs)("div",{className:(0,c.cn)("flex h-72 flex-col rounded-lg border border-border",p.r2.openrouter.gradient),children:[(0,a.jsx)("div",{className:"flex shrink-0 items-center gap-3 px-4 py-3",children:(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[(0,a.jsx)("span",{className:(0,c.cn)("h-2 w-2 shrink-0 rounded-full",p.r2.openrouter.dot)}),(0,a.jsx)("h3",{className:"whitespace-nowrap text-sm font-semibold",children:"OpenRouter"}),K?(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-emerald-500/10 px-2 py-0.5 text-[10px] font-medium text-emerald-300",children:[(0,a.jsx)(d.A,{className:"h-3 w-3"})," ",Y," enabled"]}):(0,a.jsx)("span",{className:"inline-flex items-center rounded-full border border-border bg-card px-2 py-0.5 text-[10px] font-medium text-muted-foreground",children:"Not configured"})]})}),(0,a.jsxs)("div",{className:"flex flex-1 flex-col gap-3 overflow-y-auto border-t border-border bg-card/30 p-4",children:[!K&&(0,a.jsx)("p",{className:"text-[11px] leading-relaxed text-muted-foreground",children:"Voices added here run via OpenRouter's chat-completions API. Costs come back per-call from the API and surface on the run page."}),K&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("p",{className:"text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:"Models"}),(0,a.jsx)("div",{className:"grid grid-cols-1 gap-1 sm:grid-cols-2",children:t.map(e=>(0,a.jsxs)("button",{type:"button",disabled:I===e.id,onClick:()=>H(e),title:e.model_id,className:(0,c.cn)("flex items-center gap-2 rounded border px-2 py-1.5 text-left text-[11px] transition disabled:opacity-60",e.enabled?"border-primary/50 bg-primary/10 text-foreground":"border-border bg-card text-muted-foreground hover:border-muted-foreground/30"),children:[(0,a.jsx)("div",{className:(0,c.cn)("grid h-3 w-3 shrink-0 place-items-center rounded-sm border transition",e.enabled?"border-primary bg-primary text-primary-foreground":"border-border"),children:e.enabled&&(0,a.jsx)(d.A,{className:"h-2 w-2"})}),(0,a.jsx)("span",{className:"truncate font-mono",children:e.model_id})]},e.id))}),q&&(0,a.jsx)("p",{className:"text-[11px] text-destructive",children:q})]}),(M||!K)&&(0,a.jsxs)("div",{className:"space-y-2 rounded-md border border-border bg-background/40 p-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("label",{className:"text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:K?"Replace API key":"OpenRouter API key"}),(0,a.jsxs)("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground",children:["Get a key ",(0,a.jsx)(s.A,{className:"h-2.5 w-2.5"})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("input",{type:"password",value:N,onChange:e=>k(e.target.value),placeholder:"sk-or-v1-…",disabled:w,className:"h-8 flex-1 rounded-md border border-border bg-background px-2 font-mono text-xs focus:border-primary/60 focus:outline-none"}),(0,a.jsxs)("button",{type:"button",onClick:B,disabled:w||0===N.trim().length,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-primary/40 bg-primary/10 px-3 text-[11px] font-medium text-primary transition hover:bg-primary/20 disabled:cursor-not-allowed disabled:opacity-50",children:[w?(0,a.jsx)(i.A,{className:"h-3 w-3 animate-spin"}):(0,a.jsx)(d.A,{className:"h-3 w-3"}),w?"Saving…":"Save"]})]}),C&&(0,a.jsxs)("p",{className:"flex items-center gap-1 text-[11px] text-destructive",children:[(0,a.jsx)(o.A,{className:"h-3 w-3"}),C]})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[K&&!j&&(0,a.jsxs)("button",{type:"button",onClick:W,disabled:f,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-border bg-card px-3 text-[11px] font-medium text-foreground transition hover:border-muted-foreground/30 disabled:opacity-50",children:[f?(0,a.jsx)(i.A,{className:"h-3 w-3 animate-spin"}):null,"Add more models"]}),K&&!M&&(0,a.jsx)("button",{type:"button",onClick:()=>_(!0),className:"text-[11px] text-muted-foreground underline-offset-2 hover:underline",children:"Replace API key"})]}),j&&(0,a.jsxs)(a.Fragment,{children:[f&&(0,a.jsxs)("p",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:[(0,a.jsx)(i.A,{className:"h-3 w-3 animate-spin"})," Loading catalog…"]}),b&&b.length>0&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsx)("p",{className:"text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:K?"Add more models":"Pick models"}),(0,a.jsxs)("button",{type:"button",onClick:D,disabled:0===L.size||E,className:"inline-flex h-7 items-center gap-1.5 rounded-md border border-primary/40 bg-primary/10 px-2.5 text-[11px] font-medium text-primary transition hover:bg-primary/20 disabled:cursor-not-allowed disabled:opacity-50",children:[E?(0,a.jsx)(i.A,{className:"h-3 w-3 animate-spin"}):null,"Add ",L.size>0?L.size:""]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-border bg-background/40 px-2",children:[(0,a.jsx)(l.A,{className:"h-3 w-3 text-muted-foreground"}),(0,a.jsx)("input",{type:"text",value:P,onChange:e=>O(e.target.value),placeholder:"filter by id or name…",className:"h-7 flex-1 bg-transparent text-[11px] focus:outline-none"}),(0,a.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[Q.length,"/",b.length]})]}),V&&(0,a.jsx)("p",{className:"text-[11px] text-emerald-300",children:V}),T&&(0,a.jsxs)("p",{className:"flex items-center gap-1 text-[11px] text-destructive",children:[(0,a.jsx)(o.A,{className:"h-3 w-3"}),T]}),(0,a.jsx)("div",{className:"max-h-72 overflow-y-auto rounded-md border border-border",children:Q.map(e=>{let r=L.has(e.id),n=t.some(t=>t.model_id===e.id);return(0,a.jsxs)("label",{className:(0,c.cn)("flex cursor-pointer items-center gap-2 border-b border-border px-2 py-1.5 text-[11px] last:border-b-0 hover:bg-card/40",n&&"opacity-50"),children:[(0,a.jsx)("input",{type:"checkbox",checked:r,disabled:n,onChange:t=>{$(r=>{let a=new Set(r);return t.target.checked?a.add(e.id):a.delete(e.id),a})},className:"h-3 w-3 shrink-0"}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"truncate font-mono text-[11px]",children:[e.id,n&&(0,a.jsx)("span",{className:"ml-1 text-[10px] text-muted-foreground",children:"\xb7 added"})]}),(0,a.jsxs)("div",{className:"truncate text-[10px] text-muted-foreground",children:[e.name,e.contextLength?` \xb7 ${(e.contextLength/1e3).toFixed(0)}k ctx`:"",void 0!==e.inputCostPerMtok||void 0!==e.outputCostPerMtok?` \xb7 ${g(e.inputCostPerMtok)}/${g(e.outputCostPerMtok)} per Mtok`:""]})]})]},e.id)})})]})]})]})]})}function g(e){return void 0===e?"?":e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}},8799:(e,t,r)=>{Promise.resolve().then(r.bind(r,821)),Promise.resolve().then(r.bind(r,8344)),Promise.resolve().then(r.bind(r,7130)),Promise.resolve().then(r.bind(r,1727))},9707:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let a=(0,r(3884).A)("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]])},9812:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let a=(0,r(3884).A)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]])}},e=>{e.O(0,[742,832,641,344,506,128,358],()=>e(e.s=8799)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[359],{63:(e,t,r)=>{"use strict";r.d(t,{Zp:()=>n});var s=r(9442);r(6074);var a=r(7362);function n({className:e,...t}){return(0,s.jsx)("div",{"data-slot":"card",className:(0,a.cn)("flex flex-col gap-6 rounded-xl border bg-card py-6 text-card-foreground shadow-sm",e),...t})}},862:(e,t,r)=>{"use strict";function s(e){return!!e&&e.phases[0]?.kind==="review_only"}r.d(t,{$:()=>s})},2471:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(3884).A)("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]])},2919:(e,t,r)=>{Promise.resolve().then(r.bind(r,6141))},3734:(e,t,r)=>{"use strict";r.d(t,{JR:()=>c,QJ:()=>n,VW:()=>o,YM:()=>m,m_:()=>i,r2:()=>x,u5:()=>d,x0:()=>u,ze:()=>s});let s={anthropic:"Claude",openai:"Codex",google:"Gemini",opencode:"OpenCode",moonshot:"Kimi",local:"Local LLM",grok:"Grok",antigravity:"Antigravity"},a={anthropic:"bg-violet-400",openai:"bg-orange-400",google:"bg-blue-400",opencode:"bg-emerald-400",moonshot:"bg-pink-400",local:"bg-teal-400",grok:"bg-slate-400",antigravity:"bg-sky-400"};function n(e){return e?s[e]??e:""}function o(e){return e?a[e]??"bg-muted":"bg-muted"}let i={claude:"Claude",codex:"Codex",gemini:"Gemini",opencode:"OpenCode",kimi:"Kimi",openrouter:"OpenRouter",local:"Local LLM",grok:"Grok",antigravity:"Antigravity"},l={claude:"bg-violet-400",codex:"bg-orange-400",gemini:"bg-blue-400",opencode:"bg-emerald-400",kimi:"bg-pink-400",openrouter:"bg-cyan-400",local:"bg-teal-400",grok:"bg-slate-400",antigravity:"bg-sky-400"};function d(e){return e?i[e]??e:""}function c(e){return e?l[e]??"bg-muted":"bg-muted"}let u={claude:"claude-opus-4-7",codex:"gpt-5.5",gemini:"gemini-2.5-pro",opencode:"kimi-k2.6",kimi:"kimi-k2.6",openrouter:"",local:"",grok:"grok-build",antigravity:"gemini-3.5-flash"};function m(e){if(e)return u[e]}let x={claude:{dot:"bg-violet-400",ring:"ring-violet-400/40",gradient:"bg-gradient-to-b from-violet-500/15 to-card"},codex:{dot:"bg-orange-400",ring:"ring-orange-400/40",gradient:"bg-gradient-to-b from-orange-500/15 to-card"},gemini:{dot:"bg-blue-400",ring:"ring-blue-400/40",gradient:"bg-gradient-to-b from-blue-500/15 to-card"},opencode:{dot:"bg-emerald-400",ring:"ring-emerald-400/40",gradient:"bg-gradient-to-b from-emerald-500/15 to-card"},kimi:{dot:"bg-pink-400",ring:"ring-pink-400/40",gradient:"bg-gradient-to-b from-pink-500/15 to-card"},openrouter:{dot:"bg-cyan-400",ring:"ring-cyan-400/40",gradient:"bg-gradient-to-b from-cyan-500/15 to-card"},local:{dot:"bg-teal-400",ring:"ring-teal-400/40",gradient:"bg-gradient-to-b from-teal-500/15 to-card"},grok:{dot:"bg-slate-400",ring:"ring-slate-400/40",gradient:"bg-gradient-to-b from-slate-500/15 to-card"},antigravity:{dot:"bg-sky-400",ring:"ring-sky-400/40",gradient:"bg-gradient-to-b from-sky-500/15 to-card"}}},4372:(e,t,r)=>{"use strict";r.d(t,{G:()=>o});var s=r(9442),a=r(821),n=r(8344);function o({children:e}){return(0,s.jsxs)("div",{className:"flex h-screen w-screen overflow-hidden bg-background text-foreground",children:[(0,s.jsx)(a.AppSidebar,{}),(0,s.jsxs)("div",{className:"flex flex-1 flex-col overflow-hidden",children:[(0,s.jsx)(n.MobileTopBar,{}),(0,s.jsx)("main",{className:"flex-1 overflow-y-auto",children:e})]})]})}},5702:(e,t,r)=>{"use strict";r.d(t,{E:()=>l});var s=r(9442);r(6074);var a=r(9056),n=r(8113),o=r(7362);let i=(0,a.F)("inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3",{variants:{variant:{default:"bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"bg-destructive text-white focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40 [a&]:hover:bg-destructive/90",outline:"border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",ghost:"[a&]:hover:bg-accent [a&]:hover:text-accent-foreground",link:"text-primary underline-offset-4 [a&]:hover:underline"}},defaultVariants:{variant:"default"}});function l({className:e,variant:t="default",asChild:r=!1,...a}){let d=r?n.bL:"span";return(0,s.jsx)(d,{"data-slot":"badge","data-variant":t,className:(0,o.cn)(i({variant:t}),e),...a})}},6141:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>N});var s=r(9442),a=r(8821),n=r(2471),o=r(5902),i=r(6074),l=r(4372),d=r(6457),c=r(5702),u=r(6185),m=r(6441),x=r(862);function g({icon:e,label:t,value:r,wide:a,children:n}){let[o,l]=(0,i.useState)(!1);return(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>l(e=>!e),className:"flex items-center gap-2 rounded-md border border-border bg-card px-3 py-1.5 text-sm transition hover:border-muted-foreground/40",children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:e}),(0,s.jsx)("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:t}),(0,s.jsx)("span",{className:"font-medium",children:r})]}),o&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"fixed inset-0 z-10",onClick:()=>l(!1)}),(0,s.jsx)("div",{className:`absolute left-0 top-full z-20 mt-1 rounded-md border border-border bg-popover p-1.5 shadow-xl ${a?"w-80":"w-56"}`,onClick:()=>l(!1),children:n})]})]})}var p=r(6289);let h=(0,r(3884).A)("dollar-sign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]);var f=r(63),b=r(3734);function v({template:e,prompt:t,setPrompt:r,reviewOnly:a,artifactSpec:n,billingMode:o,costEstimate:i,overCap:l,isPending:d,onStart:c}){return(0,s.jsxs)(s.Fragment,{children:[a&&n&&(0,s.jsxs)("div",{className:"mb-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[(0,s.jsx)("span",{className:"font-medium text-foreground",children:n.label}),(0,s.jsx)("span",{className:"text-muted-foreground/60",children:"\xb7"}),(0,s.jsxs)("span",{children:["cap ",(n.maxBytes/1024).toLocaleString()," KB"]})]}),(0,s.jsxs)(f.Zp,{className:"overflow-hidden p-0 mb-4",children:[(0,s.jsx)("textarea",{value:t,onChange:e=>r(e.target.value),placeholder:a&&n?n.hint:"Describe what you want chorus to weigh in on. Paste code, errors, design docs — anything the reviewers should see.",className:`block w-full resize-none border-0 bg-transparent px-5 py-4 text-sm text-foreground placeholder:text-muted-foreground/70 focus:outline-none ${a?"font-mono text-[12px] leading-relaxed":""}`,rows:a?16:10,spellCheck:!a}),(0,s.jsxs)("div",{className:"flex flex-col gap-3 border-t border-border bg-card/40 px-5 py-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsx)(j,{template:e,reviewOnly:a}),(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3 sm:justify-end",children:[(0,s.jsx)(w,{billingMode:o,costEstimate:i,overCap:l,template:e}),(0,s.jsxs)("button",{type:"button",onClick:c,disabled:!t||l||d,className:`inline-flex shrink-0 items-center gap-2 whitespace-nowrap rounded-md px-4 py-2 text-sm font-medium transition ${!t||l||d?"cursor-not-allowed bg-muted text-muted-foreground":"bg-primary text-primary-foreground hover:bg-primary/90"}`,children:[d?"Starting...":a?"Send for review":"Start the run",(0,s.jsx)(p.A,{className:"h-4 w-4"})]})]})]})]})]})}function j({template:e,reviewOnly:t}){return(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[!t&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:`h-1.5 w-1.5 rounded-full ${(0,b.JR)(e.phases[0]?.doer.lineage)}`}),"Doer: ",e.phases[0]?.doer.lineage]}),(0,s.jsx)("span",{className:"text-muted-foreground/50",children:"\xb7"})]}),(0,s.jsx)(y,{template:e}),e.phases.length>1&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-muted-foreground/50",children:"\xb7"}),(0,s.jsxs)("span",{className:"font-mono text-[10px]",children:[e.phases.length," phases"]})]})]})}function y({template:e}){let t=e.phases[0]?.reviewer.candidatesWithModels??[],r=new Map;for(let e of t)r.set(e.lineage,(r.get(e.lineage)??0)+1);return(0,s.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:"text-muted-foreground/80",children:"Reviewers:"}),t.map((e,t)=>{let a=(r.get(e.lineage)??0)>1,n=e.models?.[0]?.split("/").pop()??e.models?.[0],o=a&&n?`${e.lineage} \xb7 ${n}`:e.lineage;return(0,s.jsxs)("span",{className:"flex items-center gap-1",title:e.models?.[0]?`${e.lineage} \xb7 ${e.models[0]}`:e.lineage,children:[(0,s.jsx)("span",{className:`h-1.5 w-1.5 rounded-full ${(0,b.JR)(e.lineage)}`}),o]},`${e.lineage}-${e.models?.[0]??"default"}-${t}`)}),e.phases[0]?.reviewer.crossLineage&&(0,s.jsx)(c.E,{variant:"outline",className:"ml-1 border-border font-mono text-[9px] uppercase",title:"Reviewer must be a different lineage than the doer",children:"cross-lineage"})]})}function w({billingMode:e,costEstimate:t,overCap:r,template:a}){return"subscription"===e?(0,s.jsxs)("div",{className:"flex items-center gap-1.5 font-mono text-[10px] text-muted-foreground",title:`~${t.inputTokens.toLocaleString()} input tokens \xd7 ${t.reviewerCount} reviewers — counts against your CLI subscription quota, not billed per call`,children:["Subscription quota \xb7 ~",t.inputTokens.toLocaleString()," tok"]}):(0,s.jsxs)("div",{className:`flex items-center gap-1.5 font-mono text-[10px] ${r?"text-rose-300":"text-muted-foreground"}`,title:`~${t.inputTokens.toLocaleString()} input tokens \xd7 ${t.reviewerCount} reviewers; up to ${t.maxRounds} round${t.maxRounds>1?"s":""} on disagreement`,children:[(0,s.jsx)(h,{className:"h-3 w-3"}),t.maxRounds>1?`~$${t.usd.toFixed(3)} – $${t.usdRangeMax.toFixed(3)} est`:`~$${t.usd.toFixed(3)} est`,a.costCapUsd>0&&(0,s.jsxs)("span",{className:"text-muted-foreground/60",children:["/ cap $",a.costCapUsd.toFixed(2)]})]})}function N(){return(0,s.jsx)(i.Suspense,{fallback:(0,s.jsx)(l.G,{children:(0,s.jsx)("div",{className:"p-8 text-sm text-muted-foreground",children:"Loading…"})}),children:(0,s.jsx)(k,{})})}function k(){let e=(0,o.useSearchParams)(),t=(0,o.useRouter)(),[r,p]=(0,i.useTransition)(),[h,f]=(0,i.useState)([]),[b,j]=(0,i.useState)(null),[y,w]=(0,i.useState)(null);(0,i.useEffect)(()=>{(0,u.eG)().then(f).catch(e=>j(e instanceof u.$v?e.message:"Failed to load templates"))},[]);let[N,k]=(0,i.useState)("api");(0,i.useEffect)(()=>{(0,m.Dl)().then(e=>k(e.mode)).catch(()=>{})},[]);let $=e.get("template")??h[0]?.id??"",[C,S]=(0,i.useState)(""),R=[],L=h.find(e=>e.id===$)??h[0],M=(0,i.useMemo)(()=>(function(e){let{template:t,prompt:r,attachments:s}=e,a=t?.phases?.[0]?.reviewer?.candidates?.length??3,n=Math.max(1,t?.maxRounds??1),o=Math.ceil(r.length/4)+1500*s.length+(t?.estimatedBaselineTokens??800),i=(3e-6*o+.018000000000000002)*a;return{usd:i,usdRangeMax:i*n,inputTokens:o,reviewerCount:a,maxRounds:n}})({template:L,prompt:C,attachments:R}),[C,R,L]),E=!!("subscription"!==N&&L?.costCapUsd&&L.costCapUsd>0&&M.usdRangeMax>L.costCapUsd),[A,F]=(0,i.useState)(!1),[P,T]=(0,i.useState)(""),G=(0,x.$)(L),O=G?L?.phases?.[0]?.artifact:void 0;async function z(){if(L&&C){if(G&&O){let e=new TextEncoder().encode(C).length;if(e>O.maxBytes)return void w(`Artifact is ${e.toLocaleString()} bytes; this template caps at ${O.maxBytes.toLocaleString()}. Trim it down.`)}w(null),p(async()=>{try{let e=P.trim(),r=await (0,u.RL)({work:G?function(e){let t="Review the supplied artifact independently.";if(!e)return t;for(let t of e.split("\n")){let e=t.trim();if(0===e.length||e.startsWith("```")||e.startsWith("~~~"))continue;if(e.length<=80)return e;let r=e.slice(0,80),s=r.lastIndexOf(" ");return(s>40?r.slice(0,s):r)+"…"}return t}(C):C,templateId:L.id,files:R.length>0?R.map(e=>e.name):void 0,...G?{artifact:C}:{},...!G&&e.length>0?{repoPath:e}:{},yolo:A});t.push(`/runs/${r.slug||r.id}`)}catch(e){w(e instanceof u.$v?e.message:"Failed to create chat")}})}}return b?(0,s.jsx)(l.G,{children:(0,s.jsx)("div",{className:"mx-auto w-full max-w-6xl px-4 py-6 sm:px-6 sm:py-8 md:px-8 md:py-10",children:(0,s.jsxs)("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4",children:[(0,s.jsx)("p",{className:"text-sm text-destructive",children:"Error loading templates"}),(0,s.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:b})]})})}):L?(0,s.jsx)(l.G,{children:(0,s.jsxs)("div",{className:"mx-auto w-full max-w-6xl px-4 py-6 sm:px-6 sm:py-8 md:px-8 md:py-10",children:[(0,s.jsx)(d.z,{eyebrow:"New chat",title:G?"Paste an artifact. Get reviews.":"Paste a task. Pick a template.",subtitle:G?"Chorus skips the doer and runs your text past three reviewers. Single pass — revise yourself and resubmit for another round.":"Chorus runs it past your reviewers and reports consensus."}),y&&(0,s.jsx)("div",{className:"mb-4 rounded-lg border border-destructive/50 bg-destructive/10 p-4",children:(0,s.jsx)("p",{className:"text-sm text-destructive",children:y})}),(0,s.jsx)("div",{className:"mb-4 flex flex-wrap items-center gap-2",children:(0,s.jsx)(g,{icon:(0,s.jsx)(a.A,{className:"h-3.5 w-3.5"}),label:"Template",value:L?.name||"Select a template",wide:!0,children:(0,s.jsx)("ul",{className:"space-y-1",children:h.map(r=>{let a=!1===r.isComplete;return(0,s.jsx)("li",{children:(0,s.jsxs)("button",{type:"button",disabled:a,onClick:()=>{if(a)return;let s=new URLSearchParams(e);s.set("template",r.id),t.push(`/new?${s.toString()}`)},className:`block w-full rounded-md p-2 text-left transition ${a?"cursor-not-allowed opacity-50":r.id===$?"bg-accent":"hover:bg-accent/50"}`,children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"text-sm font-medium",children:r.name}),(0,x.$)(r)&&(0,s.jsx)(c.E,{variant:"outline",className:"border-blue-500/30 bg-blue-500/10 font-mono text-[9px] uppercase text-blue-300",children:"review only"}),a&&(0,s.jsx)(c.E,{variant:"outline",className:"border-amber-500/40 bg-amber-500/10 font-mono text-[9px] uppercase text-amber-300",children:"needs setup"})]}),(0,s.jsx)("div",{className:"text-xs text-muted-foreground line-clamp-1",children:a?"Edit this template's YAML to fill in models for your fleet.":r.description})]})},r.id)})})})}),(0,s.jsx)(v,{template:L,prompt:C,setPrompt:S,reviewOnly:G,artifactSpec:O,billingMode:N,costEstimate:M,overCap:E,isPending:r,onStart:z}),E&&(0,s.jsxs)("div",{className:"mb-4 flex items-start gap-2 rounded-md border border-rose-500/30 bg-rose-500/5 px-3 py-2 text-[11px] text-rose-200",children:[(0,s.jsx)(n.A,{className:"mt-0.5 h-3 w-3 shrink-0 text-rose-400"}),(0,s.jsxs)("span",{children:["Estimated cost"," ",(0,s.jsxs)("span",{className:"font-mono",children:["$",M.usd.toFixed(3)]})," ","exceeds template cap"," ",(0,s.jsxs)("span",{className:"font-mono",children:["$",L.costCapUsd.toFixed(2)]}),". Trim attachments, shorten the prompt, or raise the cap in template settings."]})]}),(0,s.jsxs)("div",{className:`mb-4 rounded-lg border border-dashed border-border bg-card/30 p-4 ${G?"opacity-50":""}`,children:[(0,s.jsxs)("div",{className:"mb-2 flex items-center gap-2",children:[(0,s.jsxs)("span",{className:"text-sm font-medium text-foreground",children:["Target repo"," ",(0,s.jsx)("span",{className:"text-muted-foreground",children:"(optional)"})]}),(0,s.jsx)(c.E,{variant:"outline",className:"border-emerald-500/30 bg-emerald-500/10 font-mono text-[10px] uppercase text-emerald-300",children:"opens PR"})]}),(0,s.jsx)("input",{type:"text",value:G?"":P,onChange:e=>T(e.target.value),disabled:G,placeholder:"/absolute/path/to/repo",className:"w-full rounded-md border border-border bg-background px-3 py-2 font-mono text-xs text-foreground placeholder:text-muted-foreground/50 focus:outline-none focus:ring-1 focus:ring-primary disabled:cursor-not-allowed disabled:opacity-60",spellCheck:!1}),(0,s.jsx)("p",{className:"mt-2 text-[11px] text-muted-foreground",children:G?"Review-only templates have no doer and no Ship phase, so there's nothing to commit. Pick a template with a doer (e.g. Tri-Review) to open a PR.":(0,s.jsxs)(s.Fragment,{children:["When set: doer makes real edits in this repo. After reviewers agree, chorus opens a PR via"," ",(0,s.jsx)("code",{className:"rounded bg-muted px-1",children:"gh pr create"})," (no auto-merge — you review + click Merge in GitHub). Leave blank to skip the Ship phase."]})})]}),(0,s.jsxs)("button",{type:"button",onClick:()=>F(e=>!e),className:`mb-4 flex w-full items-start justify-between gap-3 rounded-lg border px-4 py-3 text-left transition ${A?"border-rose-500/40 bg-rose-500/5":"border-dashed border-border bg-card/30 hover:border-foreground/30"}`,children:[(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("span",{className:`mt-0.5 grid h-7 w-7 place-items-center rounded-md text-sm ${A?"bg-rose-500/20 text-rose-300":"bg-card text-muted-foreground"}`,children:"\uD83D\uDE80"}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"text-sm font-medium text-foreground",children:"Yolo mode"}),(0,s.jsx)(c.E,{variant:"outline",className:"border-rose-500/30 bg-rose-500/10 font-mono text-[10px] uppercase text-rose-300",children:"unsafe"})]}),(0,s.jsx)("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:A?"Reviewer gates auto-approve. Permission prompts auto-allow. The driver merges without asking. Cost cap still enforced.":"Skip every ask-user gate for this single run. Useful for trusted templates or trivial fixes."})]})]}),(0,s.jsx)("span",{className:`flex h-5 w-9 shrink-0 items-center rounded-full border p-0.5 transition ${A?"border-rose-500/40 bg-rose-500/20":"border-border bg-card"}`,children:(0,s.jsx)("span",{className:`h-3.5 w-3.5 rounded-full transition-transform ${A?"translate-x-4 bg-rose-400":"bg-muted-foreground/50"}`})})]})]})}):(0,s.jsx)(l.G,{children:(0,s.jsx)("div",{className:"mx-auto w-full max-w-6xl px-4 py-12 text-sm text-muted-foreground sm:px-6 md:px-8",children:"Loading templates…"})})}},6289:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(3884).A)("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]])},6457:(e,t,r)=>{"use strict";r.d(t,{z:()=>a});var s=r(9442);function a({eyebrow:e,title:t,subtitle:r,action:n}){return(0,s.jsxs)("header",{className:"mb-6 flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"text-xs uppercase tracking-wider text-muted-foreground",children:e}),(0,s.jsx)("h1",{className:"mt-1 text-2xl font-semibold tracking-tight",children:t}),r&&(0,s.jsx)("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed text-muted-foreground",children:r})]}),n&&(0,s.jsx)("div",{className:"shrink-0 self-start sm:self-auto",children:n})]})}},9056:(e,t,r)=>{"use strict";r.d(t,{F:()=>o});var s=r(142);let a=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,n=s.$,o=(e,t)=>r=>{var s;if((null==t?void 0:t.variants)==null)return n(e,null==r?void 0:r.class,null==r?void 0:r.className);let{variants:o,defaultVariants:i}=t,l=Object.keys(o).map(e=>{let t=null==r?void 0:r[e],s=null==i?void 0:i[e];if(null===t)return null;let n=a(t)||a(s);return o[e][n]}),d=r&&Object.entries(r).reduce((e,t)=>{let[r,s]=t;return void 0===s||(e[r]=s),e},{});return n(e,l,null==t||null==(s=t.compoundVariants)?void 0:s.reduce((e,t)=>{let{class:r,className:s,...a}=t;return Object.entries(a).every(e=>{let[t,r]=e;return Array.isArray(r)?r.includes({...i,...d}[t]):({...i,...d})[t]===r})?[...e,r,s]:e},[]),null==r?void 0:r.class,null==r?void 0:r.className)}}},e=>{e.O(0,[742,832,641,344,506,128,358],()=>e(e.s=2919)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[566],{63:(e,t,r)=>{"use strict";r.d(t,{Zp:()=>n});var a=r(9442);r(6074);var i=r(7362);function n({className:e,...t}){return(0,a.jsx)("div",{"data-slot":"card",className:(0,i.cn)("flex flex-col gap-6 rounded-xl border bg-card py-6 text-card-foreground shadow-sm",e),...t})}},1749:(e,t,r)=>{"use strict";r.d(t,{$:()=>o});var a=r(9442);r(6074);var i=r(9056),n=r(8113),s=r(7362);let d=(0,i.F)("inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",xs:"h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-xs":"size-6 rounded-md [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function o({className:e,variant:t="default",size:r="default",asChild:i=!1,...l}){let c=i?n.bL:"button";return(0,a.jsx)(c,{"data-slot":"button","data-variant":t,"data-size":r,className:(0,s.cn)(d({variant:t,size:r,className:e})),...l})}},1996:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>G});var a=r(9442),i=r(3149),n=r(6289),s=r(5902),d=r(6074),o=r(4284),l=r(1749),c=r(6441),u=r(8141),m=r(7847),p=r(63),g=r(7362);function x({className:e,type:t,...r}){return(0,a.jsx)("input",{type:t,"data-slot":"input",className:(0,g.cn)("h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none selection:bg-primary selection:text-primary-foreground file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm dark:bg-input/30","focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50","aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40",e),...r})}var h=r(2545),b=r(9707),f=r(4030),v=r(2881);let y=["anthropic/claude-sonnet-4.5","openai/gpt-5","google/gemini-2.5-pro","deepseek/deepseek-chat-v3.1","moonshotai/kimi-k2"];function k({apiKeys:e,updateApiKey:t}){let r=e.openrouter??"",[n,s]=(0,d.useState)({kind:"idle"}),[o,l]=(0,d.useState)(null),[c,u]=(0,d.useState)(new Set(y)),[m,j]=(0,d.useState)(!1),[w,N]=(0,d.useState)(null);async function C(){if(0!==r.trim().length&&"saving"!==n.kind){s({kind:"saving"});try{let e=await (0,v.M5)(r.trim());if(!e.valid)return void s({kind:"invalid",message:e.error??"OpenRouter rejected this key."});await S()}catch(e){s({kind:"invalid",message:e instanceof Error?e.message:String(e)})}}}async function S(){s({kind:"loading_catalog"});try{let{models:e}=await (0,v.Y8)();e.sort((e,t)=>e.id.localeCompare(t.id)),l(e),s({kind:"valid",modelCount:e.length})}catch(e){s({kind:"catalog_failed",message:e instanceof Error?e.message:String(e)})}}async function A(){if(0!==c.size&&!m){j(!0),N(null);try{let e=await (0,v.Eu)(Array.from(c)),t=e.added.length,r=e.skipped.length;N(`Added ${t} voice${1===t?"":"s"}`+(r>0?` \xb7 skipped ${r} (unknown id)`:""))}catch(e){N(`Couldn't add voices: ${e instanceof Error?e.message:String(e)}`)}finally{j(!1)}}}return(0,a.jsxs)("section",{className:"mb-8",children:[(0,a.jsxs)("h2",{className:"mb-3 flex flex-wrap items-baseline gap-x-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:[(0,a.jsx)("span",{children:"API access"}),(0,a.jsx)("span",{className:"font-normal normal-case text-muted-foreground/70",children:"optional — gives you any model on OpenRouter as a chorus voice"})]}),(0,a.jsxs)(p.Zp,{className:"space-y-3 bg-card p-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("label",{htmlFor:"apikey-openrouter",className:"text-sm font-medium",children:"OpenRouter API key"}),(0,a.jsxs)("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground",children:["Get a key ",(0,a.jsx)(h.A,{className:"h-2.5 w-2.5"})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(x,{id:"apikey-openrouter",type:"password",autoComplete:"off",spellCheck:!1,placeholder:"sk-or-v1-…",value:r,onChange:e=>{t("openrouter",e.target.value),"idle"!==n.kind&&s({kind:"idle"}),l(null)},className:"flex-1 font-mono text-xs",disabled:"saving"===n.kind||"loading_catalog"===n.kind}),(0,a.jsxs)("button",{type:"button",onClick:C,disabled:0===r.trim().length||"saving"===n.kind||"loading_catalog"===n.kind||"valid"===n.kind,className:(0,g.cn)("inline-flex h-9 items-center gap-1.5 rounded-md border px-3 text-[11px] font-medium transition disabled:cursor-not-allowed disabled:opacity-50","valid"===n.kind?"border-emerald-500/40 bg-emerald-500/10 text-emerald-300":"border-primary/40 bg-primary/10 text-primary hover:bg-primary/20"),children:[("saving"===n.kind||"loading_catalog"===n.kind)&&(0,a.jsx)(i.A,{className:"h-3 w-3 animate-spin"}),"valid"===n.kind&&(0,a.jsx)(b.A,{className:"h-3 w-3"}),"saving"===n.kind?"Validating…":"loading_catalog"===n.kind?"Loading models…":"valid"===n.kind?"Validated":"Validate & save"]})]}),"invalid"===n.kind&&(0,a.jsxs)("p",{className:"flex items-center gap-1.5 text-xs text-destructive",children:[(0,a.jsx)(f.A,{className:"h-3 w-3"}),n.message]}),"catalog_failed"===n.kind&&(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3 rounded-md border border-amber-500/40 bg-amber-500/5 px-3 py-2",children:[(0,a.jsxs)("p",{className:"flex items-start gap-1.5 text-xs text-amber-100",children:[(0,a.jsx)(f.A,{className:"mt-0.5 h-3 w-3 shrink-0"}),(0,a.jsxs)("span",{children:["Key saved, but couldn't load the model catalog:"," ",n.message]})]}),(0,a.jsx)("button",{type:"button",onClick:S,className:"shrink-0 rounded-md border border-amber-500/40 bg-amber-500/10 px-2.5 py-1 text-[11px] font-medium text-amber-100 hover:bg-amber-500/20",children:"Reload models"})]}),"valid"===n.kind&&o&&(0,a.jsxs)("div",{className:"space-y-2 rounded-md border border-emerald-500/20 bg-emerald-500/5 p-3",children:[(0,a.jsxs)("p",{className:"text-[11px] text-emerald-300",children:["✓ Key valid \xb7 ",n.modelCount," models available. Pick a starter set now or browse the full catalog on the Connect page later."]}),(0,a.jsx)("div",{className:"grid grid-cols-1 gap-1 sm:grid-cols-2",children:y.filter(e=>o.some(t=>t.id===e)).map(e=>{let t=c.has(e),r=o.find(t=>t.id===e);return(0,a.jsxs)("label",{className:(0,g.cn)("flex cursor-pointer items-center gap-2 rounded border px-2 py-1.5 text-[11px] transition",t?"border-primary/50 bg-primary/10 text-foreground":"border-border bg-card text-muted-foreground hover:border-muted-foreground/30"),children:[(0,a.jsx)("input",{type:"checkbox",checked:t,onChange:t=>{u(r=>{let a=new Set(r);return t.target.checked?a.add(e):a.delete(e),a})},className:"h-3 w-3 shrink-0"}),(0,a.jsx)("span",{className:"truncate font-mono",children:r?.id??e})]},e)})}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsxs)("button",{type:"button",onClick:A,disabled:0===c.size||m,className:"inline-flex h-7 items-center gap-1.5 rounded-md border border-primary/40 bg-primary/10 px-2.5 text-[11px] font-medium text-primary transition hover:bg-primary/20 disabled:cursor-not-allowed disabled:opacity-50",children:[m?(0,a.jsx)(i.A,{className:"h-3 w-3 animate-spin"}):null,"Add ",c.size>0?c.size:""," voice",1===c.size?"":"s"]}),w&&(0,a.jsx)("p",{className:"text-[11px] text-emerald-300",children:w})]})]}),(0,a.jsxs)("p",{className:"text-[11px] leading-relaxed text-muted-foreground/80",children:["Stored locally in ",(0,a.jsx)("code",{children:"~/.chorus/chorus.db"}),". Used only to call OpenRouter on your behalf. Direct API support for other providers (Anthropic, OpenAI, Google, xAI) is on the roadmap — today, route those models via OpenRouter."]})]})]})}var j=r(3734);let w=[{id:"claude-code",provider:"anthropic",label:"Claude Code",hint:"Anthropic — uses your existing Claude login"},{id:"codex-cli",provider:"openai",label:"Codex CLI",hint:"OpenAI — ChatGPT Plus/Pro subscription"},{id:"gemini-cli",provider:"google",label:"Gemini CLI",hint:"Google — uses your gcloud auth"},{id:"opencode-cli",provider:"opencode",label:"OpenCode",hint:"OpenCode Go — routes Kimi, DeepSeek, Grok"},{id:"kimi-cli",provider:"moonshot",label:"Kimi CLI",hint:"MoonshotAI — kimi-k2 plan"},{id:"grok-cli",provider:"grok",label:"Grok Build",hint:"xAI — grok-build model (SuperGrok Heavy plan required for dispatch)"},{id:"antigravity-cli",provider:"antigravity",label:"Antigravity CLI",hint:"Google — Gemini 3.5 Flash via Google AI Pro (`agy` binary)"},{id:"cursor",provider:"cursor",label:"Cursor",hint:"Cursor IDE — invoke chorus from inside it"},{id:"windsurf",provider:"windsurf",label:"Windsurf",hint:"Windsurf IDE — invoke chorus from inside it"}],N={"claude-code":"claude","codex-cli":"codex","gemini-cli":"gemini","opencode-cli":"opencode","kimi-cli":"kimi"},C={"claude-code":"claude-code","codex-cli":"codex-cli","gemini-cli":"gemini-cli","opencode-cli":"opencode-cli","kimi-cli":"kimi-cli"},S={dot:"bg-muted-foreground/40",gradient:"bg-gradient-to-br from-muted/30 via-card to-card"},A=w.filter(e=>"cursor"!==e.id&&"windsurf"!==e.id);function P(e){return(0,a.jsxs)("section",{className:"mb-8",children:[(0,a.jsx)("h2",{className:"mb-3 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"CLI subscriptions"}),(0,a.jsx)("div",{className:"grid grid-cols-1 items-start gap-2 lg:grid-cols-2",children:A.map(t=>{let r=e.selectedClis.has(t.id),n=e.detection[t.id],s=n?.found===!0,d=e.detecting&&!n,o=!s&&!d&&e.manualOpen.has(t.id),l=e.manualBusy.has(t.id),c=s?j.r2[N[t.id]]??S:S;return(0,a.jsxs)("div",{className:(0,g.cn)("flex h-72 flex-col rounded-lg border transition",s?"border-border":"border-border/60 opacity-70",c.gradient),children:[(0,a.jsxs)("button",{type:"button",onClick:()=>s&&e.toggleCli(t.id),disabled:!s,className:(0,g.cn)("flex shrink-0 items-center gap-3 px-4 py-3 text-left transition",s?"hover:bg-card/30":"cursor-not-allowed"),children:[(0,a.jsx)("div",{className:(0,g.cn)("grid h-5 w-5 shrink-0 place-items-center rounded border transition",!s&&"opacity-50",r?"border-primary bg-primary text-primary-foreground":"border-border"),children:r&&(0,a.jsx)(b.A,{className:"h-3 w-3"})}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[(0,a.jsx)("span",{className:(0,g.cn)("h-2 w-2 shrink-0 rounded-full",c.dot)}),(0,a.jsx)("h3",{className:"whitespace-nowrap text-sm font-semibold",children:t.label}),s?(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-emerald-500/10 px-2 py-0.5 text-[10px] font-medium uppercase tracking-wider text-emerald-300",children:[(0,a.jsx)(b.A,{className:"h-3 w-3"})," Installed"]}):d?(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full border border-border bg-card px-2 py-0.5 text-[10px] font-medium text-muted-foreground",children:[(0,a.jsx)(i.A,{className:"h-3 w-3 animate-spin"})," Searching…"]}):(0,a.jsx)("span",{className:"inline-flex items-center rounded-full border border-border bg-card px-2 py-0.5 text-[10px] font-medium text-muted-foreground",children:"Not found"})]})]}),(0,a.jsxs)("div",{className:"flex flex-1 flex-col gap-2 overflow-y-auto border-t border-border bg-card/30 p-4",children:[(0,a.jsx)("p",{className:"text-[11px] leading-relaxed text-muted-foreground",children:s&&n.path?(0,a.jsx)("code",{className:"rounded bg-muted/60 px-1.5 py-0.5 font-mono",children:n.path}):d?(0,a.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[(0,a.jsx)(i.A,{className:"h-3 w-3 animate-spin"}),"Probing PATH and known install dirs…"]}):t.hint}),!s&&!d&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("button",{type:"button",onClick:()=>e.toggleManual(t.id),className:"text-[11px] text-muted-foreground transition hover:text-foreground",children:o?"Cancel":"Don't see it? Set path manually →"}),o&&(0,a.jsx)(_,{cliId:t.id,value:e.manualPath[t.id]??"",onChange:r=>e.setManualPath(e=>({...e,[t.id]:r})),error:e.manualError[t.id],busy:l,onSubmit:()=>e.submitManualPath(t.id)})]}),s&&"opencode-cli"===t.id&&r&&(0,a.jsx)(O,{loading:e.opencodeModelsLoading,error:e.opencodeModelsError,models:e.opencodeModels,selected:e.selectedOpencodeModels,onToggle:e.toggleOpencodeModel}),s&&"opencode-cli"!==t.id&&r&&(0,a.jsx)(M,{cliId:t.id,voices:e.cliVoices,savingVoiceIds:e.savingVoiceIds,saveError:e.voiceSaveError,onToggle:e.toggleVoice})]})]},t.id)})}),(0,a.jsx)("p",{className:"mt-3 text-[11px] text-muted-foreground",children:"Cursor and Windsurf are IDEs that invoke chorus, not voices — wire them up on the Connect page after onboarding."})]})}function M({cliId:e,voices:t,savingVoiceIds:r,saveError:i,onToggle:n}){let s=C[e],d=t.filter(e=>e.provider===s).slice().sort((e,t)=>e.id===s?-1:t.id===s?1:e.model_id.localeCompare(t.model_id));if(0===d.length)return(0,a.jsx)("p",{className:"text-[11px] italic text-muted-foreground/70",children:"Models will populate after the daemon finishes seeding (refresh in a few seconds)."});let o=d.filter(e=>e.enabled).length;return(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-baseline justify-between gap-2",children:[(0,a.jsx)("p",{className:"text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:"Models"}),(0,a.jsxs)("p",{className:"text-[11px] text-muted-foreground/70",children:[o,"/",d.length," enabled"]})]}),i&&(0,a.jsx)("p",{className:"text-[11px] text-destructive",children:i}),(0,a.jsx)("div",{className:"grid grid-cols-1 gap-1",children:d.map(e=>{let t=e.enabled,i=e.id===s;return(0,a.jsxs)("button",{type:"button",disabled:r.has(e.id),onClick:()=>n(e),title:e.model_id,className:(0,g.cn)("flex items-center gap-2 rounded border px-2 py-1.5 text-left text-[11px] transition disabled:opacity-60",t?"border-primary/50 bg-primary/10 text-foreground":"border-border bg-card text-muted-foreground hover:border-muted-foreground/30"),children:[(0,a.jsx)("div",{className:(0,g.cn)("grid h-3 w-3 shrink-0 place-items-center rounded-sm border transition",t?"border-primary bg-primary text-primary-foreground":"border-border"),children:t&&(0,a.jsx)(b.A,{className:"h-2 w-2"})}),(0,a.jsx)("span",{className:"truncate font-mono",children:e.model_id}),i&&(0,a.jsx)("span",{className:"shrink-0 rounded-full bg-emerald-500/10 px-1.5 py-0.5 text-[9px] font-medium uppercase tracking-wider text-emerald-300",children:"current"})]},e.id)})})]})}function O({loading:e,error:t,models:r,selected:n,onToggle:s}){return(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-baseline justify-between gap-2",children:[(0,a.jsx)("p",{className:"text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:"Pick models to enable"}),(0,a.jsxs)("p",{className:"text-[11px] text-muted-foreground/70",children:[n.size," selected"]})]}),e&&(0,a.jsxs)("p",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:[(0,a.jsx)(i.A,{className:"h-3 w-3 animate-spin"}),"Listing models from"," ",(0,a.jsx)("code",{className:"rounded bg-muted px-1",children:"opencode models"}),"…"]}),t&&(0,a.jsx)("p",{className:"text-[11px] text-destructive",children:t}),r&&(0,a.jsxs)("div",{className:"space-y-2",children:[Object.entries(r.gateways).filter(([e])=>e.startsWith("opencode")).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsxs)("p",{className:"text-[10px] font-mono text-muted-foreground/80",children:[e,"/"]}),(0,a.jsx)("div",{className:"grid grid-cols-1 gap-1",children:t.map(t=>{let r=n.has(t);return(0,a.jsxs)("button",{type:"button",onClick:()=>s(t),title:t,className:(0,g.cn)("flex items-center gap-2 rounded border px-2 py-1.5 text-left text-[11px] transition",r?"border-primary/50 bg-primary/10 text-foreground":"border-border bg-card text-muted-foreground hover:border-muted-foreground/30"),children:[(0,a.jsx)("div",{className:(0,g.cn)("grid h-3 w-3 shrink-0 place-items-center rounded-sm border transition",r?"border-primary bg-primary text-primary-foreground":"border-border"),children:r&&(0,a.jsx)(b.A,{className:"h-2 w-2"})}),(0,a.jsx)("span",{className:"truncate font-mono",children:t.slice(e.length+1)})]},t)})})]},e)),(0,a.jsxs)("p",{className:"text-[11px] leading-relaxed text-muted-foreground/70",children:["Pre-selected: ",r.defaultPicks.join(", ")||"none",". Change anytime in ",(0,a.jsx)("code",{className:"rounded bg-muted px-1",children:"Settings"}),"."]})]})]})}function _({cliId:e,value:t,onChange:r,error:n,busy:s,onSubmit:d}){let o=function(e){switch(e){case"claude-code":return"claude";case"codex-cli":return"codex";case"gemini-cli":return"gemini";case"opencode-cli":return"opencode";case"kimi-cli":return"kimi";case"grok-cli":return"grok";case"antigravity-cli":return"agy";default:return e}}(e);return(0,a.jsxs)("div",{className:"space-y-2 rounded-md border border-border bg-card/50 p-3",children:[(0,a.jsxs)("p",{className:"text-[11px] leading-relaxed text-muted-foreground",children:["Paste the full path to the"," ",(0,a.jsx)("code",{className:"rounded bg-muted px-1",children:o})," binary. Run"," ",(0,a.jsxs)("code",{className:"rounded bg-muted px-1",children:["which ",o]})," (macOS / Linux) or ",(0,a.jsxs)("code",{className:"rounded bg-muted px-1",children:["where ",o]})," ","(Windows) to find it. The daemon will run"," ",(0,a.jsxs)("code",{className:"rounded bg-muted px-1",children:[o," --version"]})," with a 2s timeout to confirm the binary works and identifies as the"," ",o," CLI."]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(x,{value:t,onChange:e=>r(e.target.value),placeholder:`/full/path/to/${o}`,className:"flex-1 font-mono text-xs",spellCheck:!1,autoComplete:"off"}),(0,a.jsx)(l.$,{type:"button",variant:"secondary",disabled:s,onClick:d,children:s?(0,a.jsx)(i.A,{className:"h-4 w-4 animate-spin"}):"Verify"})]}),n&&(0,a.jsx)("p",{className:"text-[11px] text-destructive",children:n})]})}let I=[{id:"strict",label:"Strict",hint:"Read-only. Reviewers can inspect code but can't write files, exec shell, or hit the network."},{id:"workspace",label:"Workspace (recommended)",hint:"Read+write inside the chat dir, scoped shell, no network. Default for most teams."},{id:"full",label:"Full access",hint:"No sandbox at all. Only on a personal machine you fully trust."}];function z({sandboxProfile:e,setSandboxProfile:t,autoApprovePrompts:r,setAutoApprovePrompts:i,networkAccess:n,setNetworkAccess:s}){return(0,a.jsxs)("section",{className:"mb-8",children:[(0,a.jsx)("h2",{className:"mb-3 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Permissions & sandbox"}),(0,a.jsx)("p",{className:"mb-4 text-xs leading-relaxed text-muted-foreground",children:"Controls what reviewers can do on your machine. You can change this anytime in Settings → Permissions."}),(0,a.jsx)("div",{className:"space-y-2",children:I.map(r=>{let i=e===r.id;return(0,a.jsxs)("button",{type:"button",onClick:()=>t(r.id),className:(0,g.cn)("flex w-full items-start gap-3 rounded-lg border p-4 text-left transition",i?"border-primary/50 bg-primary/10":"border-border bg-card hover:border-muted-foreground/30"),children:[(0,a.jsx)("div",{className:(0,g.cn)("mt-0.5 grid h-5 w-5 shrink-0 place-items-center rounded-full border transition",i?"border-primary bg-primary text-primary-foreground":"border-border"),children:i&&(0,a.jsx)(b.A,{className:"h-3 w-3"})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("div",{className:"text-sm font-medium",children:r.label}),(0,a.jsx)("div",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:r.hint})]})]},r.id)})}),(0,a.jsxs)("div",{className:"mt-3 space-y-2",children:[(0,a.jsxs)("label",{className:"flex cursor-pointer items-start gap-3 rounded-lg border border-border bg-card p-3",children:[(0,a.jsx)("input",{type:"checkbox",checked:r,onChange:e=>i(e.target.checked),className:"mt-1 h-4 w-4 cursor-pointer accent-primary"}),(0,a.jsxs)("div",{className:"min-w-0 flex-1 text-xs leading-relaxed",children:[(0,a.jsx)("div",{className:"text-sm font-medium",children:"Skip in-CLI permission prompts"}),(0,a.jsxs)("div",{className:"mt-0.5 text-muted-foreground",children:["Passes ",(0,a.jsx)("code",{className:"rounded bg-muted px-1",children:"--afk"})," /"," ",(0,a.jsx)("code",{className:"rounded bg-muted px-1",children:"auto_edit"}),"to spawned reviewers so they don't hang on per-tool prompts. Off = every action requires explicit consent in the CLI's TUI."]})]})]}),(0,a.jsxs)("label",{className:"flex cursor-pointer items-start gap-3 rounded-lg border border-border bg-card p-3",children:[(0,a.jsx)("input",{type:"checkbox",checked:n,onChange:e=>s(e.target.checked),className:"mt-1 h-4 w-4 cursor-pointer accent-primary"}),(0,a.jsxs)("div",{className:"min-w-0 flex-1 text-xs leading-relaxed",children:[(0,a.jsx)("div",{className:"text-sm font-medium",children:"Allow outbound network from reviewers"}),(0,a.jsx)("div",{className:"mt-0.5 text-muted-foreground",children:"Off by default. Templates that explicitly need network override per phase."})]})]})]})]})}var L=r(6185);async function E(e){for(let t of e.selectedClis){let e=w.find(e=>e.id===t);e&&await (0,L.WH)(e.provider,{kind:"cli_subscription",value:e.id,updatedAt:Date.now()})}for(let[t,r]of Object.entries(e.apiKeys)){let e=r.trim();e&&await (0,L.WH)(t,{kind:"api_key",value:e,updatedAt:Date.now()})}await (0,c.Ep)({sandboxProfile:e.sandboxProfile,autoApprovePrompts:e.autoApprovePrompts,networkAccess:e.networkAccess}),e.selectedClis.has("opencode-cli")&&e.opencodeModels&&await V(e),await (0,L.Xx)({onboarded:!0})}async function V(e){let{listVoices:t,updateVoice:a,createVoice:i}=await Promise.resolve().then(r.bind(r,7847)),n=new Map((await t({provider:"opencode-cli"}).catch(()=>[])).map(e=>[e.id,e])),s=e.opencodeModels;s&&await Promise.all(s.flat.map(async t=>{let r=`opencode-cli:${t}`,s=e.selectedOpencodeModels.has(t),d=n.get(r);try{if(d)d.enabled!==s&&await a(r,{enabled:s});else{let e,r,{lineage:a,vendor_family:n}=(r=((e=t.indexOf("/"))>=0?t.slice(e+1):t).toLowerCase()).includes("kimi")?{lineage:"moonshot",vendor_family:null}:r.includes("claude")?{lineage:"anthropic",vendor_family:null}:r.includes("gpt")||/(?:^|[^a-z])o[1-9](?:$|[^a-z0-9])/.test(r)?{lineage:"openai",vendor_family:null}:r.includes("gemini")?{lineage:"google",vendor_family:null}:r.includes("deepseek")?{lineage:"opencode",vendor_family:"deepseek"}:r.includes("llama")||r.includes("meta")?{lineage:"opencode",vendor_family:"meta"}:r.includes("mistral")||r.includes("mixtral")?{lineage:"opencode",vendor_family:"mistral"}:r.includes("grok")||r.includes("xai")?{lineage:"opencode",vendor_family:"xai"}:{lineage:"opencode",vendor_family:null};await i({provider:"opencode-cli",model_id:t,label:t,source:"cli",lineage:a,vendor_family:n,enabled:s})}}catch{}}))}function G(){let e=(0,s.useRouter)(),[t,r]=(0,d.useTransition)(),[p,g]=(0,d.useState)(null),[x,h]=(0,d.useState)(new Set),[b,f]=(0,d.useState)([]),[v,y]=(0,d.useState)(new Set),[j,w]=(0,d.useState)(null),[N,C]=(0,d.useState)({}),[S,A]=(0,d.useState)("workspace"),[M,O]=(0,d.useState)(!0),[_,I]=(0,d.useState)(!1),[V,G]=(0,d.useState)({}),[$,T]=(0,d.useState)(!0),[R,W]=(0,d.useState)(new Set),[D,K]=(0,d.useState)({}),[q,F]=(0,d.useState)({}),[H,Y]=(0,d.useState)(new Set),[J,B]=(0,d.useState)(null),[U,Z]=(0,d.useState)(null),[Q,X]=(0,d.useState)(!1),[ee,et]=(0,d.useState)(new Set);(0,d.useEffect)(()=>{let e=!1;return(0,c.fk)().then(t=>{if(e)return;let r={},a=new Set;for(let e of t)r[e.id]=e,e.found&&a.add(e.id);G(r),a.size>0&&h(a)}).catch(()=>{}).finally(()=>{e||T(!1)}),(0,m.listVoices)({source:"cli"}).then(t=>{e||f(t)}).catch(()=>{}),()=>{e=!0}},[]);let er=async e=>{y(t=>new Set(t).add(e.id)),w(null);try{let t=await (0,m.updateVoice)(e.id,{enabled:!e.enabled});f(e=>e.map(e=>e.id===t.id?t:e))}catch(e){w(e instanceof Error?e.message:"Couldn't save voice toggle.")}finally{y(t=>{let r=new Set(t);return r.delete(e.id),r})}};(0,d.useEffect)(()=>{!x.has("opencode-cli")||!V["opencode-cli"]?.found||J||Q||U||(X(!0),Z(null),(0,u.Ay)().then(e=>{B(e),et(t=>t.size>0?t:new Set(e.defaultPicks))}).catch(e=>{Z(e instanceof Error?e.message:"Couldn't list OpenCode models. Is the CLI authed (run `opencode auth login`)?")}).finally(()=>X(!1)))},[x,V,J,Q,U]);let ea=async e=>{let t=(D[e]||"").trim();if(!t)return void F(t=>({...t,[e]:"Enter the full path to the CLI program (e.g. /usr/local/bin/claude)."}));Y(t=>new Set(t).add(e)),F(t=>({...t,[e]:""}));try{let r=await (0,c.iW)(e,t);if(r.found){try{await (0,c.Df)(e,r.path??t)}catch(t){F(r=>({...r,[e]:`Validation passed but save failed: ${t instanceof Error?t.message:"unknown error"}. Try again, or paste the path again.`}));return}G(t=>({...t,[e]:r})),h(t=>new Set(t).add(e)),(0,m.listVoices)({source:"cli"}).then(f).catch(()=>{}),W(t=>{let r=new Set(t);return r.delete(e),r})}else{let t=r.reason??"couldn't run that path";F(r=>({...r,[e]:`Validation failed: ${t}.`}))}}catch{F(t=>({...t,[e]:"Validation failed. Is the daemon running?"}))}finally{Y(t=>{let r=new Set(t);return r.delete(e),r})}},ei=x.size+Object.values(N).filter(e=>e.trim().length>0).length;return(0,a.jsx)("main",{className:"min-h-screen bg-background text-foreground",children:(0,a.jsxs)("div",{className:"mx-auto w-full max-w-5xl px-4 py-10 sm:px-6 sm:py-14",children:[(0,a.jsxs)("div",{className:"mb-8 flex items-center gap-3",children:[(0,a.jsx)("div",{className:"grid h-10 w-10 place-items-center rounded-md bg-primary/15 text-primary",children:(0,a.jsx)(o.U,{className:"h-6 w-6"})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs uppercase tracking-wider text-muted-foreground",children:"Welcome to Chorus"}),(0,a.jsx)("h1",{className:"text-2xl font-semibold tracking-tight",children:"Connect at least one model to begin"})]})]}),(0,a.jsx)("p",{className:"mb-8 text-sm leading-relaxed text-muted-foreground",children:"Chorus runs your prompt past 2–4 LLMs of different lineages and synthesises consensus. Pick the CLI subscriptions you already have, or paste API keys. You can change these later in Settings."}),(0,a.jsx)(P,{selectedClis:x,toggleCli:e=>{h(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},detection:V,detecting:$,cliVoices:b,savingVoiceIds:v,voiceSaveError:j,toggleVoice:er,manualOpen:R,toggleManual:e=>{W(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r}),F(t=>({...t,[e]:""}))},manualPath:D,setManualPath:K,manualError:q,manualBusy:H,submitManualPath:ea,opencodeModels:J,opencodeModelsError:U,opencodeModelsLoading:Q,selectedOpencodeModels:ee,toggleOpencodeModel:e=>{et(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})}}),(0,a.jsx)(k,{apiKeys:N,updateApiKey:(e,t)=>{C(r=>({...r,[e]:t}))}}),(0,a.jsx)(z,{sandboxProfile:S,setSandboxProfile:A,autoApprovePrompts:M,setAutoApprovePrompts:O,networkAccess:_,setNetworkAccess:I}),p&&(0,a.jsx)("div",{className:"mb-6 rounded-md border border-destructive/50 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:p}),(0,a.jsxs)("div",{className:"flex flex-col-reverse gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:0===ei?"Pick at least one to continue.":`${ei} ${1===ei?"credential":"credentials"} ready to save.`}),(0,a.jsx)(l.$,{onClick:()=>{(g(null),0===ei)?g("Pick at least one CLI or paste at least one API key to continue."):r(async()=>{try{await E({selectedClis:x,apiKeys:N,sandboxProfile:S,autoApprovePrompts:M,networkAccess:_,opencodeModels:J,selectedOpencodeModels:ee}),e.push("/"),e.refresh()}catch(e){g(e instanceof L.$v?e.message:"Could not save. Is the Chorus daemon running?")}})},disabled:t||0===ei,className:"w-full sm:w-auto",children:t?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i.A,{className:"mr-1 h-4 w-4 animate-spin"}),"Saving…"]}):(0,a.jsxs)(a.Fragment,{children:["Get started",(0,a.jsx)(n.A,{className:"ml-1 h-4 w-4"})]})})]})]})})}},2545:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let a=(0,r(3884).A)("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]])},2881:(e,t,r)=>{"use strict";r.d(t,{Eu:()=>s,M5:()=>i,Y8:()=>n});var a=r(4411);async function i(e){return(0,a.T)("/openrouter/save-key",{method:"POST",body:JSON.stringify({apiKey:e})})}async function n(){return(0,a.T)("/openrouter/models")}async function s(e,t){return(0,a.T)("/openrouter/voices",{method:"POST",body:JSON.stringify(t?{modelIds:e,apiKey:t}:{modelIds:e})})}},3149:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let a=(0,r(3884).A)("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]])},3734:(e,t,r)=>{"use strict";r.d(t,{JR:()=>c,QJ:()=>n,VW:()=>s,YM:()=>m,m_:()=>d,r2:()=>p,u5:()=>l,x0:()=>u,ze:()=>a});let a={anthropic:"Claude",openai:"Codex",google:"Gemini",opencode:"OpenCode",moonshot:"Kimi",local:"Local LLM",grok:"Grok",antigravity:"Antigravity"},i={anthropic:"bg-violet-400",openai:"bg-orange-400",google:"bg-blue-400",opencode:"bg-emerald-400",moonshot:"bg-pink-400",local:"bg-teal-400",grok:"bg-slate-400",antigravity:"bg-sky-400"};function n(e){return e?a[e]??e:""}function s(e){return e?i[e]??"bg-muted":"bg-muted"}let d={claude:"Claude",codex:"Codex",gemini:"Gemini",opencode:"OpenCode",kimi:"Kimi",openrouter:"OpenRouter",local:"Local LLM",grok:"Grok",antigravity:"Antigravity"},o={claude:"bg-violet-400",codex:"bg-orange-400",gemini:"bg-blue-400",opencode:"bg-emerald-400",kimi:"bg-pink-400",openrouter:"bg-cyan-400",local:"bg-teal-400",grok:"bg-slate-400",antigravity:"bg-sky-400"};function l(e){return e?d[e]??e:""}function c(e){return e?o[e]??"bg-muted":"bg-muted"}let u={claude:"claude-opus-4-7",codex:"gpt-5.5",gemini:"gemini-2.5-pro",opencode:"kimi-k2.6",kimi:"kimi-k2.6",openrouter:"",local:"",grok:"grok-build",antigravity:"gemini-3.5-flash"};function m(e){if(e)return u[e]}let p={claude:{dot:"bg-violet-400",ring:"ring-violet-400/40",gradient:"bg-gradient-to-b from-violet-500/15 to-card"},codex:{dot:"bg-orange-400",ring:"ring-orange-400/40",gradient:"bg-gradient-to-b from-orange-500/15 to-card"},gemini:{dot:"bg-blue-400",ring:"ring-blue-400/40",gradient:"bg-gradient-to-b from-blue-500/15 to-card"},opencode:{dot:"bg-emerald-400",ring:"ring-emerald-400/40",gradient:"bg-gradient-to-b from-emerald-500/15 to-card"},kimi:{dot:"bg-pink-400",ring:"ring-pink-400/40",gradient:"bg-gradient-to-b from-pink-500/15 to-card"},openrouter:{dot:"bg-cyan-400",ring:"ring-cyan-400/40",gradient:"bg-gradient-to-b from-cyan-500/15 to-card"},local:{dot:"bg-teal-400",ring:"ring-teal-400/40",gradient:"bg-gradient-to-b from-teal-500/15 to-card"},grok:{dot:"bg-slate-400",ring:"ring-slate-400/40",gradient:"bg-gradient-to-b from-slate-500/15 to-card"},antigravity:{dot:"bg-sky-400",ring:"ring-sky-400/40",gradient:"bg-gradient-to-b from-sky-500/15 to-card"}}},4030:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let a=(0,r(3884).A)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},6289:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let a=(0,r(3884).A)("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]])},8600:(e,t,r)=>{Promise.resolve().then(r.bind(r,1996))},9056:(e,t,r)=>{"use strict";r.d(t,{F:()=>s});var a=r(142);let i=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,n=a.$,s=(e,t)=>r=>{var a;if((null==t?void 0:t.variants)==null)return n(e,null==r?void 0:r.class,null==r?void 0:r.className);let{variants:s,defaultVariants:d}=t,o=Object.keys(s).map(e=>{let t=null==r?void 0:r[e],a=null==d?void 0:d[e];if(null===t)return null;let n=i(t)||i(a);return s[e][n]}),l=r&&Object.entries(r).reduce((e,t)=>{let[r,a]=t;return void 0===a||(e[r]=a),e},{});return n(e,o,null==t||null==(a=t.compoundVariants)?void 0:a.reduce((e,t)=>{let{class:r,className:a,...i}=t;return Object.entries(i).every(e=>{let[t,r]=e;return Array.isArray(r)?r.includes({...d,...l}[t]):({...d,...l})[t]===r})?[...e,r,a]:e},[]),null==r?void 0:r.class,null==r?void 0:r.className)}},9707:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let a=(0,r(3884).A)("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]])}},e=>{e.O(0,[742,641,506,128,358],()=>e(e.s=8600)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[974],{1195:(e,t,r)=>{"use strict";r.d(t,{OpencodeFleetCard:()=>x});var n=r(9442),s=r(6074),a=r(5445),d=r(9707),i=r(4030),o=r(2956),l=r(3734),c=r(7847),m=r(4411),u=r(7362);function x({health:e,voices:t}){let[r,i]=(0,s.useState)(!1),[o,p]=(0,s.useState)(t),[b,h]=(0,s.useState)(null),[f,y]=(0,s.useState)(null);async function v(e){y(e.id),h(null);try{let t=await (0,c.updateVoice)(e.id,{enabled:!e.enabled});p(e=>e.map(e=>e.id===t.id?t:e))}catch(e){h(e instanceof m.$?e.message:"Couldn't save. Is the daemon running?")}finally{y(null)}}let N=new Map;for(let e of o){let t=e.model_id.indexOf("/"),r=t>0?e.model_id.slice(0,t):"other",n=N.get(r)??[];n.push(e),N.set(r,n)}let j=Array.from(N.keys()).sort(),k=o.filter(e=>e.enabled).length;return(0,n.jsxs)("div",{className:(0,u.cn)("rounded-lg border border-border transition-colors hover:border-foreground/20",l.r2.opencode.gradient),children:[(0,n.jsxs)("button",{type:"button",onClick:()=>i(e=>!e),className:"flex w-full items-center gap-3 p-3 text-left",children:[(0,n.jsx)("span",{className:(0,u.cn)("h-2 w-2 shrink-0 rounded-full",l.r2.opencode.dot)}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("div",{className:"text-sm font-medium",children:"OpenCode"}),(0,n.jsxs)("div",{className:"mt-0.5 flex items-center gap-2",children:[(0,n.jsx)(g,{status:e.status}),(0,n.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[k," model",1===k?"":"s"," enabled"]})]})]}),(0,n.jsx)(a.A,{className:(0,u.cn)("h-4 w-4 shrink-0 text-muted-foreground transition-transform",r&&"rotate-180")})]}),r&&(0,n.jsxs)("div",{className:"space-y-3 border-t border-border bg-card/50 p-3",children:[b&&(0,n.jsx)("p",{className:"text-[11px] text-destructive",children:b}),0===o.length?(0,n.jsxs)("p",{className:"text-[11px] text-muted-foreground",children:["No OpenCode voices detected yet. Run ",(0,n.jsx)("code",{className:"rounded bg-muted px-1",children:"opencode models"})," ","and restart the daemon."]}):(0,n.jsxs)("div",{className:"space-y-3",children:[j.map(e=>{let t=N.get(e)??[];return(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsxs)("p",{className:"text-[11px] font-mono text-muted-foreground/80",children:[e,"/"]}),(0,n.jsx)("div",{className:"grid grid-cols-1 gap-1 sm:grid-cols-2",children:t.map(t=>{let r=t.enabled,s=t.model_id.slice(e.length+1);return(0,n.jsxs)("button",{type:"button",disabled:f===t.id,onClick:()=>v(t),title:t.model_id,className:(0,u.cn)("flex items-center gap-2 rounded border px-2 py-1.5 text-left text-[11px] transition disabled:opacity-60",r?"border-primary/50 bg-primary/10 text-foreground":"border-border bg-card hover:border-muted-foreground/30 text-muted-foreground"),children:[(0,n.jsx)("div",{className:(0,u.cn)("grid h-3 w-3 shrink-0 place-items-center rounded-sm border transition",r?"border-primary bg-primary text-primary-foreground":"border-border"),children:r&&(0,n.jsx)(d.A,{className:"h-2 w-2"})}),(0,n.jsx)("span",{className:"truncate font-mono",children:s})]},t.id)})})]},e)}),(0,n.jsx)("p",{className:"text-[11px] leading-relaxed text-muted-foreground/70",children:"Toggles save automatically. Templates and the New Chat dialog will only offer models you've enabled here."})]})]})]})}function g({status:e}){switch(e){case"auth_invalid":case"quota_exhausted":case"rate_limited":return(0,n.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-destructive/10 px-2 py-0.5 text-[10px] font-medium text-destructive",children:[(0,n.jsx)(i.A,{className:"h-3 w-3"}),"auth_invalid"===e?"Auth broken":"quota_exhausted"===e?"Quota out":"Rate-limited"]});default:return(0,n.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-emerald-500/10 px-2 py-0.5 text-[10px] font-medium text-emerald-300",children:[(0,n.jsx)(o.A,{className:"h-3 w-3"}),"Connected"]})}}},2956:(e,t,r)=>{"use strict";r.d(t,{A:()=>n});let n=(0,r(3884).A)("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]])},3734:(e,t,r)=>{"use strict";r.d(t,{JR:()=>c,QJ:()=>a,VW:()=>d,YM:()=>u,m_:()=>i,r2:()=>x,u5:()=>l,x0:()=>m,ze:()=>n});let n={anthropic:"Claude",openai:"Codex",google:"Gemini",opencode:"OpenCode",moonshot:"Kimi",local:"Local LLM",grok:"Grok",antigravity:"Antigravity"},s={anthropic:"bg-violet-400",openai:"bg-orange-400",google:"bg-blue-400",opencode:"bg-emerald-400",moonshot:"bg-pink-400",local:"bg-teal-400",grok:"bg-slate-400",antigravity:"bg-sky-400"};function a(e){return e?n[e]??e:""}function d(e){return e?s[e]??"bg-muted":"bg-muted"}let i={claude:"Claude",codex:"Codex",gemini:"Gemini",opencode:"OpenCode",kimi:"Kimi",openrouter:"OpenRouter",local:"Local LLM",grok:"Grok",antigravity:"Antigravity"},o={claude:"bg-violet-400",codex:"bg-orange-400",gemini:"bg-blue-400",opencode:"bg-emerald-400",kimi:"bg-pink-400",openrouter:"bg-cyan-400",local:"bg-teal-400",grok:"bg-slate-400",antigravity:"bg-sky-400"};function l(e){return e?i[e]??e:""}function c(e){return e?o[e]??"bg-muted":"bg-muted"}let m={claude:"claude-opus-4-7",codex:"gpt-5.5",gemini:"gemini-2.5-pro",opencode:"kimi-k2.6",kimi:"kimi-k2.6",openrouter:"",local:"",grok:"grok-build",antigravity:"gemini-3.5-flash"};function u(e){if(e)return m[e]}let x={claude:{dot:"bg-violet-400",ring:"ring-violet-400/40",gradient:"bg-gradient-to-b from-violet-500/15 to-card"},codex:{dot:"bg-orange-400",ring:"ring-orange-400/40",gradient:"bg-gradient-to-b from-orange-500/15 to-card"},gemini:{dot:"bg-blue-400",ring:"ring-blue-400/40",gradient:"bg-gradient-to-b from-blue-500/15 to-card"},opencode:{dot:"bg-emerald-400",ring:"ring-emerald-400/40",gradient:"bg-gradient-to-b from-emerald-500/15 to-card"},kimi:{dot:"bg-pink-400",ring:"ring-pink-400/40",gradient:"bg-gradient-to-b from-pink-500/15 to-card"},openrouter:{dot:"bg-cyan-400",ring:"ring-cyan-400/40",gradient:"bg-gradient-to-b from-cyan-500/15 to-card"},local:{dot:"bg-teal-400",ring:"ring-teal-400/40",gradient:"bg-gradient-to-b from-teal-500/15 to-card"},grok:{dot:"bg-slate-400",ring:"ring-slate-400/40",gradient:"bg-gradient-to-b from-slate-500/15 to-card"},antigravity:{dot:"bg-sky-400",ring:"ring-sky-400/40",gradient:"bg-gradient-to-b from-sky-500/15 to-card"}}},3761:(e,t,r)=>{"use strict";r.d(t,{A:()=>n});let n=(0,r(3884).A)("clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]])},4030:(e,t,r)=>{"use strict";r.d(t,{A:()=>n});let n=(0,r(3884).A)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},5445:(e,t,r)=>{"use strict";r.d(t,{A:()=>n});let n=(0,r(3884).A)("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]])},5626:(e,t,r)=>{Promise.resolve().then(r.bind(r,6501)),Promise.resolve().then(r.t.bind(r,2573,23)),Promise.resolve().then(r.bind(r,821)),Promise.resolve().then(r.bind(r,9823)),Promise.resolve().then(r.bind(r,8344)),Promise.resolve().then(r.bind(r,1195)),Promise.resolve().then(r.bind(r,8359))},6289:(e,t,r)=>{"use strict";r.d(t,{A:()=>n});let n=(0,r(3884).A)("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]])},8359:(e,t,r)=>{"use strict";r.d(t,{OpenRouterFleetCard:()=>h});var n=r(9442),s=r(6074),a=r(2573),d=r.n(a),i=r(5445),o=r(4030),l=r(6289),c=r(9707),m=r(3761),u=r(2956),x=r(3734),g=r(7847),p=r(4411),b=r(7362);function h({voices:e,health:t}){let r=t?.status==="auth_invalid",[a,f]=(0,s.useState)(r),[y,v]=(0,s.useState)(e),[N,j]=(0,s.useState)(null),[k,w]=(0,s.useState)(null);async function A(e){w(e.id),j(null);try{let t=await (0,g.updateVoice)(e.id,{enabled:!e.enabled});v(e=>e.map(e=>e.id===t.id?t:e))}catch(e){j(e instanceof p.$?e.message:"Couldn't save. Is the daemon running?")}finally{w(null)}}let C=y.filter(e=>e.enabled).length;return(0,n.jsxs)("div",{className:(0,b.cn)("rounded-lg border border-border transition-colors hover:border-foreground/20",x.r2.openrouter.gradient),children:[(0,n.jsxs)("button",{type:"button",onClick:()=>f(e=>!e),className:"flex w-full items-center gap-3 p-3 text-left",children:[(0,n.jsx)("span",{className:(0,b.cn)("h-2 w-2 shrink-0 rounded-full",x.r2.openrouter.dot)}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("div",{className:"text-sm font-medium",children:"OpenRouter"}),(0,n.jsxs)("div",{className:"mt-0.5 flex items-center gap-2",children:[function(e){switch(e){case"quota_exhausted":return(0,n.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-destructive/10 px-2 py-0.5 text-[10px] font-medium text-destructive",children:[(0,n.jsx)(o.A,{className:"h-3 w-3"}),"Credits out"]});case"auth_invalid":return(0,n.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-destructive/10 px-2 py-0.5 text-[10px] font-medium text-destructive",children:[(0,n.jsx)(o.A,{className:"h-3 w-3"}),"Auth broken"]});case"rate_limited":return(0,n.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-amber-500/10 px-2 py-0.5 text-[10px] font-medium text-amber-300",children:[(0,n.jsx)(m.A,{className:"h-3 w-3"}),"Rate-limited"]});default:return(0,n.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-emerald-500/10 px-2 py-0.5 text-[10px] font-medium text-emerald-300",children:[(0,n.jsx)(u.A,{className:"h-3 w-3"}),"Configured"]})}}(t?.status??"healthy"),(0,n.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[C," model",1===C?"":"s"," enabled"]})]})]}),(0,n.jsx)(i.A,{className:(0,b.cn)("h-4 w-4 shrink-0 text-muted-foreground transition-transform",a&&"rotate-180")})]}),a&&(0,n.jsxs)("div",{className:"space-y-2 border-t border-border bg-card/50 p-3",children:[r&&(0,n.jsxs)("div",{className:"flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/10 p-2.5",children:[(0,n.jsx)(o.A,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-destructive"}),(0,n.jsxs)("div",{className:"min-w-0 flex-1 space-y-1.5",children:[(0,n.jsxs)("p",{className:"text-[11px] leading-relaxed text-destructive",children:["OpenRouter rejected the saved API key",t?.message?`: ${t.message}`:"."]}),(0,n.jsxs)(d(),{href:"/connect",className:"inline-flex items-center gap-1 rounded border border-destructive/50 bg-destructive/10 px-2 py-1 text-[11px] font-medium text-destructive transition hover:bg-destructive/20",children:["Fix on Connect",(0,n.jsx)(l.A,{className:"h-3 w-3"})]})]})]}),N&&(0,n.jsx)("p",{className:"text-[11px] text-destructive",children:N}),0===y.length?(0,n.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"No OpenRouter voices yet. Add some on the Connect page."}):(0,n.jsx)("div",{className:"grid grid-cols-1 gap-1",children:y.map(e=>(0,n.jsxs)("button",{type:"button",disabled:k===e.id,onClick:()=>A(e),title:e.model_id,className:(0,b.cn)("flex items-center gap-2 rounded border px-2 py-1.5 text-left text-[11px] transition disabled:opacity-60",e.enabled?"border-primary/50 bg-primary/10 text-foreground":"border-border bg-card text-muted-foreground hover:border-muted-foreground/30"),children:[(0,n.jsx)("div",{className:(0,b.cn)("grid h-3 w-3 shrink-0 place-items-center rounded-sm border transition",e.enabled?"border-primary bg-primary text-primary-foreground":"border-border"),children:e.enabled&&(0,n.jsx)(c.A,{className:"h-2 w-2"})}),(0,n.jsx)("span",{className:"truncate font-mono",children:e.model_id})]},e.id))}),!r&&(0,n.jsx)("p",{className:"text-[11px] leading-relaxed text-muted-foreground/70",children:"Add or replace your API key on Connect. Toggles save automatically."})]})]})}},9707:(e,t,r)=>{"use strict";r.d(t,{A:()=>n});let n=(0,r(3884).A)("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]])},9823:(e,t,r)=>{"use strict";r.d(t,{LineageFleetCard:()=>b});var n=r(9442),s=r(6074),a=r(5445),d=r(9707),i=r(4030),o=r(3761),l=r(2956),c=r(3734),m=r(7847),u=r(4411),x=r(7362);let g={anthropic:"claude",openai:"codex",google:"gemini",opencode:"opencode",moonshot:"kimi"},p={dot:"bg-muted-foreground/40",gradient:"bg-gradient-to-br from-muted/30 via-card to-card"};function b({lineage:e,label:t,voices:r,health:i}){let o,[l,f]=(0,s.useState)(!1),[y,v]=(0,s.useState)(r),[N,j]=(0,s.useState)(null),[k,w]=(0,s.useState)(null);async function A(e){w(e.id),j(null);try{let t=await (0,m.updateVoice)(e.id,{enabled:!e.enabled});v(e=>e.map(e=>e.id===t.id?t:e))}catch(e){j(e instanceof u.$?e.message:"Couldn't save. Is the daemon running?")}finally{w(null)}}let C=y.filter(e=>e.enabled).length,_=(o=g[e])?c.r2[o]:p;return(0,n.jsxs)("div",{className:(0,x.cn)("rounded-lg border border-border transition-colors hover:border-foreground/20",_.gradient),children:[(0,n.jsxs)("button",{type:"button",onClick:()=>f(e=>!e),className:"flex w-full items-center gap-3 p-3 text-left",children:[(0,n.jsx)("span",{className:(0,x.cn)("h-2 w-2 shrink-0 rounded-full",_.dot)}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("div",{className:"text-sm font-medium",children:t}),(0,n.jsxs)("div",{className:"mt-0.5 flex items-center gap-2",children:[(0,n.jsx)(h,{status:i.status}),(0,n.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[C," model",1===C?"":"s"," enabled"]})]})]}),(0,n.jsx)(a.A,{className:(0,x.cn)("h-4 w-4 shrink-0 text-muted-foreground transition-transform",l&&"rotate-180")})]}),l&&(0,n.jsxs)("div",{className:"space-y-2 border-t border-border bg-card/50 p-3",children:[N&&(0,n.jsx)("p",{className:"text-[11px] text-destructive",children:N}),0===y.length?(0,n.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"No voices detected for this provider yet."}):(0,n.jsx)("div",{className:"grid grid-cols-1 gap-1",children:y.map(e=>{let t=e.enabled;return(0,n.jsxs)("button",{type:"button",disabled:k===e.id,onClick:()=>A(e),title:e.model_id,className:(0,x.cn)("flex items-center gap-2 rounded border px-2 py-1.5 text-left text-[11px] transition disabled:opacity-60",t?"border-primary/50 bg-primary/10 text-foreground":"border-border bg-card hover:border-muted-foreground/30 text-muted-foreground"),children:[(0,n.jsx)("div",{className:(0,x.cn)("grid h-3 w-3 shrink-0 place-items-center rounded-sm border transition",t?"border-primary bg-primary text-primary-foreground":"border-border"),children:t&&(0,n.jsx)(d.A,{className:"h-2 w-2"})}),(0,n.jsx)("span",{className:"truncate font-mono",children:e.model_id})]},e.id)})}),(0,n.jsx)("p",{className:"text-[11px] leading-relaxed text-muted-foreground/70",children:"Toggles save automatically. Voice list is curated per chorus release — new models appear after upgrades."})]})]})}function h({status:e}){switch(e){case"auth_invalid":return(0,n.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-destructive/10 px-2 py-0.5 text-[10px] font-medium text-destructive",children:[(0,n.jsx)(i.A,{className:"h-3 w-3"}),"Auth broken"]});case"quota_exhausted":return(0,n.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-destructive/10 px-2 py-0.5 text-[10px] font-medium text-destructive",children:[(0,n.jsx)(i.A,{className:"h-3 w-3"}),"Quota out"]});case"rate_limited":return(0,n.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-amber-500/10 px-2 py-0.5 text-[10px] font-medium text-amber-300",children:[(0,n.jsx)(o.A,{className:"h-3 w-3"}),"Rate-limited"]});default:return(0,n.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-emerald-500/10 px-2 py-0.5 text-[10px] font-medium text-emerald-300",children:[(0,n.jsx)(l.A,{className:"h-3 w-3"}),"Connected"]})}}}},e=>{e.O(0,[742,832,641,344,506,128,358],()=>e(e.s=5626)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[814],{3016:(e,r,t)=>{"use strict";t.r(r),t.d(r,{default:()=>eG});var s=t(9442),a=t(6074),n=t(4052),o=t(3149),i=t(8420),l=t(4372),d=t(63),c=t(5702),u=t(6457),m=t(8191),x=t(9315),p=t(2865),h=t(6891),g=t(6458),f=t(4030),b=t(2956),v=t(1853),j=t(6185),y=t(599),w=t(9345);let N=Object.freeze({valid:!0,issues:[]});var k=t(7362),C=t(8979),A=t(8821),S=t(4608),M=t(7978);let L={claude:"anthropic",codex:"openai",gemini:"google",opencode:"opencode",kimi:"moonshot",openrouter:"openrouter",local:"local",grok:"grok",antigravity:"antigravity"},D={anthropic:"claude",openai:"codex",google:"gemini",opencode:"opencode",moonshot:"kimi",openrouter:"openrouter",xai:"opencode",local:"local",grok:"grok",antigravity:"antigravity"},R={claude:"claude-opus-4-7",codex:"gpt-5.5",gemini:"gemini-2.5-pro",opencode:"kimi-k2.6",kimi:"kimi-k2.6",openrouter:"",local:"",grok:"grok-build",antigravity:"gemini-3.5-flash"},P={id:"",name:"",description:"",author:"you",category:"review",phases:[{id:"review",name:"Review",description:"Three independent critiques.",kind:"review",gate:"ask-user",doer:{lineage:"claude",models:["claude-opus-4-7"]},reviewer:{require:3,crossLineage:!0,candidates:["codex","gemini","opencode"]},inputs:{include:[],exclude:[]},iterate:{max:3,onMax:"ask-user"},blindSpots:[],execution:"parallel",builtin:!1}],threshold:"unanimous",onThresholdMet:"ask-user",maxRounds:3,yoloDefault:!1,fallbackDoer:[],fallbackReviewer:[]},$=[{id:"review",label:"Review"},{id:"plan",label:"Plan"},{id:"debug",label:"Debug"},{id:"decide",label:"Decide"}],T=[{id:"unanimous",label:"Unanimous",hint:"All lineages must agree. Strictest — best for high-stakes reviews."},{id:"majority",label:"Majority",hint:"≥ ⅔ of lineages agree. Good default for code review."},{id:"any",label:"Any",hint:"≥1 lineage agrees. Useful for brainstorming where divergence is fine."}],_=[{id:"auto-finalize",label:"Auto-finalize"},{id:"ask-user",label:"Ask me"}],E=[{id:1,label:"Basics",icon:C.A},{id:2,label:"Phases",icon:A.A},{id:3,label:"Fallback",icon:S.A},{id:4,label:"Policy",icon:M.A}],q=["claude","codex","gemini","opencode","kimi","openrouter","local","grok","antigravity"];function F(e){return e.trim().toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-")||"untitled"}function U(e){var r;return y.Ay.stringify({id:(r=e).id||F(r.name),name:r.name||"Untitled template",description:r.description||"Describe what this template is for.",author:r.author||"chorus",agreementThreshold:void 0!==r.customThreshold?r.customThreshold:function(e){switch(e){case"unanimous":return 1;case"majority":return .66;case"any":return .34}}(r.threshold),onThresholdMet:r.onThresholdMetRaw??("auto-finalize"===r.onThresholdMet?"merge":"ask"),maxRounds:r.maxRounds,yoloDefault:r.yoloDefault,phases:r.phases.map(e=>{let r="review_only"===e.kind,t=e.reviewer.candidates.length>0?{require:e.reviewer.require,crossLineage:e.reviewer.crossLineage,candidates:e.reviewer.candidates.flatMap(r=>{let t=(e.reviewer.candidateModels?.[r]??[]).map(e=>e.trim()).filter(e=>e.length>0),s=e.reviewer.candidatePersonas?.[r],a=L[r]??"anthropic";if(0===t.length){let e=R[r]??"claude-opus-4-7",t=s?.[""];return[{lineage:a,models:[e],...t?{persona:t}:{}}]}return t.map(e=>{let r=s?.[e];return{lineage:a,models:[e],...r?{persona:r}:{}}})})}:void 0;return r?{id:e.id,kind:e.kind,title:e.name,description:e.description,reviewer:t,inputs:{include:e.inputs.include,exclude:e.inputs.exclude},artifact:{label:e.artifact?.label??"Artifact to review",hint:e.artifact?.hint??"Paste a unified diff, a markdown draft, code, or any text blob.",maxBytes:e.artifact?.maxBytes??1048576}}:{id:e.id,kind:e.kind,title:e.name,description:e.description,doer:{lineage:L[e.doer.lineage]??"anthropic",models:e.doer.models.length>0?e.doer.models:[R[e.doer.lineage]??"claude-opus-4-7"],...e.doer.persona?{persona:e.doer.persona}:{}},reviewer:t,inputs:{include:e.inputs.include,exclude:e.inputs.exclude},iterate:{maxRounds:e.iterate.max,onDisagreement:"loopback"===e.iterate.onMax?"continue":"fail"===e.iterate.onMax?"accept-doer":"escalate",shareSessionAcrossRounds:!0,shareSessionAcrossPhases:!1}}}),...r.fallbackDoer.length>0||r.fallbackReviewer.length>0?{fallback:{...r.fallbackDoer.length>0?{doer:r.fallbackDoer.map(e=>({lineage:L[e.lineage]??"anthropic",models:[e.model],...e.persona?{persona:e.persona}:{}}))}:{},...r.fallbackReviewer.length>0?{reviewer:r.fallbackReviewer.map(e=>({lineage:L[e.lineage]??"anthropic",models:[e.model],...e.persona?{persona:e.persona}:{}}))}:{}}}:{}},{lineWidth:0})}var Y=t(6758),z=t(5483),I=t(7847),O=t(1993),B=t(52),V=t(2116),G=t(9410),W=t(9208),K=t(7618),H=t(4579),Z=t(9812),J=t(3734);let Q={review:B.A,review_only:B.A,plan:V.A,spec:p.A,tests:G.A,implement:W.A,verify:K.A,pr:H.A,divergence:S.A,recon:Z.A},X=[{id:"plan",label:"Plan"},{id:"spec",label:"Spec / API"},{id:"tests",label:"Tests"},{id:"implement",label:"Implement"},{id:"verify",label:"Verify"},{id:"pr",label:"Open PR"},{id:"review",label:"Review"},{id:"review_only",label:"Review only (artifact)"},{id:"divergence",label:"Divergence"},{id:"recon",label:"Recon"}],ee=["claude","codex","gemini","opencode","kimi","openrouter","local","grok","antigravity"].map(e=>({id:e,label:J.m_[e],dot:J.r2[e].dot})),er=J.x0,et={anthropic:"claude",openai:"codex",google:"gemini",opencode:"opencode",moonshot:"kimi",xai:"opencode",local:"local",grok:"grok",antigravity:"antigravity"};function es(){let[e,r]=(0,a.useState)({byLineage:{},connectedLineages:new Set,loaded:!1});return(0,a.useEffect)(()=>{(0,I.listVoices)({enabled:!0}).then(e=>{let t={},s=new Set;for(let r of e){if("openrouter"===r.provider){s.add("openrouter"),(t.openrouter??=[]).push(r.id);continue}let e=et[r.lineage];e&&(s.add(e),(t[e]??=[]).push(r.model_id)),r.provider.startsWith("opencode")&&"opencode"!==e&&(s.add("opencode"),(t.opencode??=[]).push(r.model_id))}for(let e of Object.keys(t))t[e]=Array.from(new Set(t[e]));r({byLineage:t,connectedLineages:s,loaded:!0})}).catch(()=>r({byLineage:{},connectedLineages:new Set,loaded:!0}))},[]),e}var ea=t(1304),en=t(2379),eo=t(5445),ei=t(9707),el=t(2471);function ed({children:e,onClick:r,disabled:t,title:a,className:n}){return(0,s.jsx)("button",{type:"button",disabled:t,onClick:e=>{e.stopPropagation(),r()},title:a,className:(0,k.cn)("grid h-6 w-6 place-items-center rounded text-muted-foreground transition hover:bg-accent hover:text-foreground disabled:cursor-not-allowed disabled:opacity-30",n),children:e})}function ec({label:e,children:r}){return(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"mb-1.5 block text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:e}),r]})}function eu({on:e,tone:r,onClick:t,children:a}){return(0,s.jsx)("button",{type:"button",onClick:t,className:(0,k.cn)("rounded-md border px-2 py-0.5 font-mono text-[10px] uppercase tracking-wider transition",{emerald:e?"border-emerald-500/40 bg-emerald-500/15 text-emerald-200":"border-border bg-card/40 text-muted-foreground hover:border-emerald-500/30",rose:e?"border-rose-500/40 bg-rose-500/15 text-rose-200":"border-border bg-card/40 text-muted-foreground hover:border-rose-500/30"}[r]),children:a})}function em({value:e,personas:r,onChange:t,inline:a,ariaLabel:n}){let o="__none__",i=r.some(r=>r.id===e);return(0,s.jsxs)("select",{value:e??o,onChange:e=>{let r=e.target.value;t(r===o?void 0:r)},className:(0,k.cn)("h-7 rounded-md border border-border bg-background px-2 text-[11px] focus:border-primary/60 focus:outline-none",a?"w-32 shrink-0":"w-full"),"aria-label":n??"Persona",children:[(0,s.jsx)("option",{value:o,children:"(no persona)"}),r.map(e=>(0,s.jsx)("option",{value:e.id,children:e.label},e.id)),e&&!i&&(0,s.jsxs)("option",{value:e,children:[e," (missing)"]})]})}function ex({lineage:e,value:r,options:t,onChange:n,defaultModel:o}){let i="__custom__",l=!r||t.includes(r),[d,c]=(0,a.useState)(!1);if(d)return(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsx)("input",{type:"text",value:r,onChange:e=>n(e.target.value),placeholder:o?`default: ${o}`:`${e} model id`,className:"h-7 flex-1 rounded-md border border-border bg-background px-2 font-mono text-[11px] text-foreground placeholder:text-muted-foreground/50 focus:border-primary/60 focus:outline-none",autoFocus:!0}),(0,s.jsx)("button",{type:"button",onClick:()=>c(!1),className:"h-7 rounded-md border border-border bg-card/40 px-2 text-[10px] text-muted-foreground hover:text-foreground",children:"done"})]});if(0===t.length)return(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("input",{type:"text",value:r,onChange:e=>n(e.target.value),placeholder:o?`default: ${o}`:`${e} model id`,className:"h-7 w-full rounded-md border border-border bg-background px-2 font-mono text-[11px] text-foreground placeholder:text-muted-foreground/50 focus:border-primary/60 focus:outline-none"}),(0,s.jsxs)("p",{className:"text-[10px] text-amber-400/80",children:["No ",e," voices enabled. Configure in Connect to populate this dropdown."]})]});let u=l?t:[r,...t];return(0,s.jsxs)("select",{value:r,onChange:e=>{e.target.value===i?c(!0):n(e.target.value)},className:"h-7 w-full rounded-md border border-border bg-background px-2 font-mono text-[11px] text-foreground focus:border-primary/60 focus:outline-none",children:[!r&&(0,s.jsx)("option",{value:"",children:o?`default: ${o}`:"— pick a model —"}),u.map(e=>(0,s.jsxs)("option",{value:e,children:[e,t.includes(e)||r!==e?"":" (not enabled)"]},e)),(0,s.jsx)("option",{value:i,children:"+ custom (type a model id)…"})]})}function ep(e){let r=[];for(let t of e.candidates){let s=e.candidateModels?.[t],a=e.candidatePersonas?.[t];if(s&&0!==s.length)for(let e of s)r.push({lineage:t,model:e,...a?.[e]?{persona:a[e]}:{}});else r.push({lineage:t,model:"",...a?.[""]?{persona:a[""]}:{}})}return r}function eh({phase:e,connectedVoices:r,personas:t,onUpdate:a}){let n=ep(e.reviewer),o=ee.filter(e=>0===r.connectedLineages.size||r.connectedLineages.has(e.id));function i(r){a({reviewer:function(e,r){let t=[],s={},a={};for(let r of e)t.includes(r.lineage)||t.push(r.lineage),r.model&&(s[r.lineage]??=[]).push(r.model),r.persona&&((a[r.lineage]??={})[r.model]=r.persona);return{...r,candidates:t,candidateModels:s,...Object.keys(a).length>0?{candidatePersonas:a}:{candidatePersonas:void 0}}}(r,e.reviewer)})}function l(e,t){let s=n.map((r,s)=>s===e?{...r,...t}:r);if(t.lineage&&t.lineage!==n[e].lineage){let a=r.byLineage[t.lineage]??[];s[e].model=a[0]??er[t.lineage]??""}i(s)}return(0,s.jsxs)("div",{className:"space-y-1.5",children:[0===n.length&&(0,s.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"No reviewers yet. Click + add reviewer below."}),n.map((e,a)=>{let d=ee.find(r=>r.id===e.lineage);return(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,s.jsxs)("select",{value:e.lineage,onChange:e=>l(a,{lineage:e.target.value}),className:"h-7 w-32 shrink-0 rounded-md border border-border bg-background px-2 text-[11px] focus:border-primary/60 focus:outline-none","aria-label":"Reviewer lineage",children:[o.map(e=>(0,s.jsx)("option",{value:e.id,children:e.label},e.id)),!o.find(r=>r.id===e.lineage)&&(0,s.jsxs)("option",{value:e.lineage,children:[d?.label??e.lineage," (not connected)"]})]}),(0,s.jsx)("div",{className:"flex-1",children:(0,s.jsx)(ex,{lineage:e.lineage,value:e.model,options:r.byLineage[e.lineage]??[],defaultModel:er[e.lineage],onChange:e=>l(a,{model:e})})}),(0,s.jsx)(em,{value:e.persona,personas:t,onChange:e=>l(a,{persona:e}),inline:!0,ariaLabel:"Reviewer persona"}),(0,s.jsx)("button",{type:"button",onClick:()=>{i(n.filter((e,r)=>r!==a))},"aria-label":"Remove reviewer",className:"grid h-7 w-7 shrink-0 place-items-center rounded-md border border-border bg-card/40 text-muted-foreground hover:border-destructive/40 hover:text-destructive",children:(0,s.jsx)(h.A,{className:"h-3 w-3"})})]},a)}),(0,s.jsxs)("button",{type:"button",onClick:function(){let e=o[0]?.id??"claude",t=r.byLineage[e]??[],s=new Set(n.filter(r=>r.lineage===e).map(e=>e.model)),a=t.find(e=>!s.has(e))??er[e]??"";i([...n,{lineage:e,model:a}])},className:"flex w-full items-center justify-center gap-1.5 rounded-md border border-dashed border-border bg-card/30 px-3 py-2 text-[11px] font-medium text-muted-foreground transition hover:border-primary/40 hover:bg-card/50 hover:text-foreground",children:[(0,s.jsx)(x.A,{className:"h-3 w-3"}),"Add another reviewer"]})]})}function eg({phase:e,onUpdate:r,connectedVoices:t,personas:a}){return(0,s.jsxs)(ec,{label:"Doer \xb7 the agent that writes this phase's output",children:[(0,s.jsx)("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-5",children:ee.filter(e=>0===t.connectedLineages.size||t.connectedLineages.has(e.id)).map(a=>(0,s.jsxs)("button",{type:"button",onClick:()=>{let e=(t.byLineage[a.id]??[])[0]??er[a.id];r({doer:{lineage:a.id,models:e?[e]:[]}})},className:(0,k.cn)("flex items-center gap-1.5 rounded-md border px-2 py-1.5 text-left transition",e.doer.lineage===a.id?"border-primary/40 bg-primary/10":"border-border bg-card/40 hover:border-foreground/30"),children:[(0,s.jsx)("span",{className:(0,k.cn)("h-1.5 w-1.5 rounded-full",a.dot)}),(0,s.jsx)("span",{className:"text-xs",children:a.label}),e.doer.lineage===a.id&&(0,s.jsx)(ei.A,{className:"ml-auto h-3 w-3 text-primary"})]},a.id))}),(0,s.jsx)("div",{className:"mt-2",children:(0,s.jsx)(ex,{lineage:e.doer.lineage,value:e.doer.models[0]??"",options:t.byLineage[e.doer.lineage]??[],defaultModel:er[e.doer.lineage],onChange:t=>r({doer:{...e.doer,models:t?[t]:[]}})})}),(0,s.jsxs)("div",{className:"mt-2",children:[(0,s.jsx)("label",{className:"mb-1 block text-[10px] text-muted-foreground",children:"Persona (optional \xb7 prepends a worldview to the doer's prompt)"}),(0,s.jsx)(em,{value:e.doer.persona,personas:a,onChange:t=>r({doer:t?{...e.doer,persona:t}:(()=>{let{persona:r,...t}=e.doer;return t})()}),ariaLabel:"Doer persona"})]})]})}function ef({phase:e,onUpdate:r}){let t={label:e.artifact?.label??"Artifact to review",hint:e.artifact?.hint??"Paste a unified diff, a markdown draft, code, or any text blob.",maxBytes:e.artifact?.maxBytes??1048576};return(0,s.jsx)(ec,{label:"Artifact \xb7 what the user pastes when starting a chat",children:(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-[10px] text-muted-foreground",children:"Label"}),(0,s.jsx)("input",{type:"text",value:t.label,onChange:e=>r({artifact:{...t,label:e.target.value}}),placeholder:"Artifact to review",className:"mt-1 h-7 w-full rounded-md border border-border bg-background px-2.5 text-[11px] placeholder:text-muted-foreground/60 focus:border-primary/60 focus:outline-none"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-[10px] text-muted-foreground",children:"Placeholder hint"}),(0,s.jsx)("textarea",{value:e.artifact?.hint??"",onChange:e=>r({artifact:{...t,hint:e.target.value}}),placeholder:"Paste a unified diff, a markdown draft, code, or any text blob.",rows:2,className:"mt-1 w-full resize-none rounded-md border border-border bg-background px-2.5 py-1.5 text-[11px] placeholder:text-muted-foreground/60 focus:border-primary/60 focus:outline-none"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-[10px] text-muted-foreground",children:"Max bytes (server-side cap)"}),(0,s.jsx)("input",{type:"number",min:1024,step:1024,value:t.maxBytes,onChange:e=>r({artifact:{...t,maxBytes:Math.max(1024,parseInt(e.target.value,10)||1048576)}}),className:"mt-1 h-7 w-full rounded-md border border-border bg-background px-2.5 font-mono text-[11px] focus:border-primary/60 focus:outline-none"}),(0,s.jsx)("p",{className:"mt-1 text-[10px] text-muted-foreground/80",children:"1 MiB = 1048576. Default if unset."})]})]})})}function eb({phase:e,onUpdate:r,connectedVoices:t,personas:a}){return(0,s.jsx)(ec,{label:"Reviewers \xb7 who gates this phase",children:(0,s.jsx)(eh,{phase:e,connectedVoices:t,personas:a,onUpdate:r})})}function ev({phase:e,onUpdate:r}){return(0,s.jsx)(ec,{label:"Approvals",children:(0,s.jsxs)("div",{className:"flex items-center gap-4 flex-wrap",children:[(0,s.jsxs)("label",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:["Require:",(0,s.jsx)("input",{type:"number",min:0,max:Math.max(1,ep(e.reviewer).length),value:e.reviewer.require,onChange:t=>r({reviewer:{...e.reviewer,require:Math.max(0,parseInt(t.target.value,10)||0)}}),className:"h-6 w-12 rounded border border-border bg-background px-1.5 text-center font-mono text-[11px]"}),"approval",1===e.reviewer.require?"":"s"]}),"review_only"!==e.kind&&(0,s.jsxs)("label",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:[(0,s.jsx)("input",{type:"checkbox",checked:e.reviewer.crossLineage,onChange:t=>r({reviewer:{...e.reviewer,crossLineage:t.target.checked}}),className:"accent-primary"}),"Cross-lineage required"]})]})})}function ej({phase:e,onUpdate:r}){return(0,s.jsx)(ec,{label:"Reviewer execution \xb7 how multiple reviewers interact",children:(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>r({execution:"parallel"}),className:(0,k.cn)("rounded-md border px-3 py-2.5 text-left transition","parallel"===e.execution?"border-emerald-500/40 bg-emerald-500/5":"border-border bg-card/40 hover:border-foreground/30"),children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-xs font-medium",children:["Parallel independent",(0,s.jsx)("span",{className:"font-mono text-[9px] uppercase text-emerald-300/80",children:"fast"})]}),(0,s.jsx)("p",{className:"mt-0.5 text-[10px] leading-snug text-muted-foreground",children:"All reviewers see the same pack, work in isolation, vote. Catches single-reviewer mistakes via consensus. Risk: shared blind spots pass anyway."})]}),(0,s.jsxs)("button",{type:"button",onClick:()=>r({execution:"sequential"}),className:(0,k.cn)("rounded-md border px-3 py-2.5 text-left transition","sequential"===e.execution?"border-amber-500/40 bg-amber-500/5":"border-border bg-card/40 hover:border-foreground/30"),children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-xs font-medium",children:["Sequential hostile",(0,s.jsx)("span",{className:"font-mono text-[9px] uppercase text-amber-300/80",children:"thorough"})]}),(0,s.jsx)("p",{className:"mt-0.5 text-[10px] leading-snug text-muted-foreground",children:"Reviewers run in order. Each receives the already-hardened output and hunts what the prior reviewer missed. Slower; only works if the first reviewer's solution is sound."})]})]})})}function ey({phase:e,onUpdate:r,priorPhases:t}){return(0,s.jsxs)(ec,{label:"Inputs \xb7 which prior phases this doer can read",children:[(0,s.jsx)("div",{className:"space-y-1.5",children:t.map(t=>{let a=e.inputs.include.includes(t),n=e.inputs.exclude.includes(t),o=n?"exclude":a?"include":"none";return(0,s.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-border bg-card/30 px-2.5 py-1.5",children:[(0,s.jsx)("code",{className:"font-mono text-[11px] text-foreground",children:t}),(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsx)(eu,{on:"include"===o,tone:"emerald",onClick:()=>r({inputs:{include:a?e.inputs.include.filter(e=>e!==t):[...e.inputs.include,t],exclude:e.inputs.exclude.filter(e=>e!==t)}}),children:"include"}),(0,s.jsx)(eu,{on:"exclude"===o,tone:"rose",onClick:()=>r({inputs:{include:e.inputs.include.filter(e=>e!==t),exclude:n?e.inputs.exclude.filter(e=>e!==t):[...e.inputs.exclude,t]}}),children:"exclude (blind)"})]})]},t)})}),(0,s.jsxs)("p",{className:"mt-2 flex items-start gap-1.5 text-[10px] text-muted-foreground",children:[(0,s.jsx)(el.A,{className:"mt-0.5 h-2.5 w-2.5 shrink-0 text-muted-foreground/60"}),(0,s.jsxs)("span",{children:[(0,s.jsx)("span",{className:"font-mono text-rose-300",children:"exclude"}),"prevents this doer from seeing that phase's output. Used for info asymmetry — e.g. the implementer shouldn't see the tests."]})]})]})}function ew({phase:e,onUpdate:r,priorPhases:t}){return(0,s.jsx)(ec,{label:"Iterate \xb7 what happens when reviewer rejects",children:(0,s.jsxs)("div",{className:"grid grid-cols-3 gap-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-[10px] text-muted-foreground",children:"Max revise"}),(0,s.jsx)("input",{type:"number",min:1,max:10,value:e.iterate.max,onChange:t=>r({iterate:{...e.iterate,max:Math.max(1,parseInt(t.target.value,10)||1)}}),className:"mt-1 h-7 w-full rounded-md border border-border bg-background px-2 font-mono text-[11px]"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-[10px] text-muted-foreground",children:"On max"}),(0,s.jsxs)("select",{value:e.iterate.onMax,onChange:t=>r({iterate:{...e.iterate,onMax:t.target.value}}),className:"mt-1 h-7 w-full rounded-md border border-border bg-background px-1.5 text-[11px]",children:[(0,s.jsx)("option",{value:"ask-user",children:"ask me"}),(0,s.jsx)("option",{value:"loopback",children:"loop back"}),(0,s.jsx)("option",{value:"fail",children:"fail"})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-[10px] text-muted-foreground",children:"Loop back to"}),(0,s.jsxs)("select",{disabled:"loopback"!==e.iterate.onMax,value:e.iterate.loopbackTo??"",onChange:t=>r({iterate:{...e.iterate,loopbackTo:t.target.value||void 0}}),className:"mt-1 h-7 w-full rounded-md border border-border bg-background px-1.5 text-[11px] disabled:opacity-40",children:[(0,s.jsx)("option",{value:"",children:"—"}),t.map(e=>(0,s.jsx)("option",{value:e,children:e},e))]})]})]})})}function eN({phase:e,onUpdate:r}){return(0,s.jsx)(ec,{label:"Gate \xb7 what happens when this phase finishes",children:(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>r({gate:"auto"}),className:(0,k.cn)("rounded-md border px-2.5 py-1.5 text-left transition","auto"===e.gate?"border-emerald-500/40 bg-emerald-500/10":"border-border bg-card/40 hover:border-foreground/30"),children:[(0,s.jsx)("div",{className:"text-xs font-medium",children:"Auto-proceed"}),(0,s.jsx)("div",{className:"text-[10px] text-muted-foreground",children:"Continue to next phase without asking."})]}),(0,s.jsxs)("button",{type:"button",onClick:()=>r({gate:"ask-user"}),className:(0,k.cn)("rounded-md border px-2.5 py-1.5 text-left transition","ask-user"===e.gate?"border-amber-500/40 bg-amber-500/10":"border-border bg-card/40 hover:border-foreground/30"),children:[(0,s.jsx)("div",{className:"text-xs font-medium",children:"Checkpoint (ask me)"}),(0,s.jsx)("div",{className:"text-[10px] text-muted-foreground",children:"Stop here, surface verdict, wait for click."})]})]})})}function ek({phase:e,index:r,total:t,allPhaseIds:n,connectedVoices:o,personas:l,onUpdate:d,onMoveUp:c,onMoveDown:u,onDelete:m}){let[x,p]=(0,a.useState)(0===r),h=Q[e.kind],g=n.slice(0,r);return(0,s.jsxs)("div",{className:"rounded-lg border border-border bg-card/40",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>p(e=>!e),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left",children:[(0,s.jsx)("span",{className:"font-mono text-[10px] text-muted-foreground/60",children:String(r+1).padStart(2,"0")}),(0,s.jsx)("span",{className:"grid h-7 w-7 shrink-0 place-items-center rounded-md bg-primary/15 text-primary",children:(0,s.jsx)(h,{className:"h-3.5 w-3.5"})}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"text-sm font-medium text-foreground truncate",children:e.name||"Untitled phase"}),(0,s.jsx)("span",{className:"font-mono text-[10px] uppercase text-muted-foreground/70",children:e.kind})]}),(0,s.jsx)(eC,{phase:e})]}),(0,s.jsxs)("div",{className:"flex shrink-0 items-center gap-0.5",children:[(0,s.jsx)(ed,{disabled:0===r,onClick:c,title:"Move up",children:(0,s.jsx)(ea.A,{className:"h-3 w-3"})}),(0,s.jsx)(ed,{disabled:r===t-1,onClick:u,title:"Move down",children:(0,s.jsx)(en.A,{className:"h-3 w-3"})}),(0,s.jsx)(ed,{onClick:m,title:"Delete phase",className:"hover:text-rose-400",children:(0,s.jsx)(i.A,{className:"h-3 w-3"})}),(0,s.jsx)("span",{className:"ml-1 text-muted-foreground/60",children:x?(0,s.jsx)(eo.A,{className:"h-3.5 w-3.5"}):(0,s.jsx)(z.A,{className:"h-3.5 w-3.5"})})]})]}),x&&(0,s.jsxs)("div",{className:"space-y-4 border-t border-border bg-background/40 px-3 py-3",children:[(0,s.jsxs)("div",{className:"grid grid-cols-[1fr_140px] gap-2",children:[(0,s.jsx)(ec,{label:"Name",children:(0,s.jsx)("input",{type:"text",value:e.name,onChange:e=>d({name:e.target.value}),className:"h-8 w-full rounded-md border border-border bg-background px-2.5 text-xs text-foreground focus:border-primary/60 focus:outline-none"})}),(0,s.jsx)(ec,{label:"Kind",children:(0,s.jsx)("select",{value:e.kind,onChange:e=>d({kind:e.target.value}),className:"h-8 w-full rounded-md border border-border bg-background px-2 text-xs text-foreground focus:border-primary/60 focus:outline-none",children:X.map(e=>(0,s.jsx)("option",{value:e.id,children:e.label},e.id))})})]}),(0,s.jsx)(ec,{label:"Description",children:(0,s.jsx)("input",{type:"text",value:e.description,onChange:e=>d({description:e.target.value}),placeholder:"What this phase produces and why it exists.",className:"h-8 w-full rounded-md border border-border bg-background px-2.5 text-xs text-foreground placeholder:text-muted-foreground/60 focus:border-primary/60 focus:outline-none"})}),"review_only"!==e.kind&&(0,s.jsx)(eg,{phase:e,onUpdate:d,connectedVoices:o,personas:l}),"review_only"===e.kind&&(0,s.jsx)(ef,{phase:e,onUpdate:d}),(0,s.jsx)(eb,{phase:e,onUpdate:d,connectedVoices:o,personas:l}),(0,s.jsx)(ev,{phase:e,onUpdate:d}),(0,s.jsx)(ej,{phase:e,onUpdate:d}),g.length>0&&(0,s.jsx)(ey,{phase:e,onUpdate:d,priorPhases:g}),"review_only"!==e.kind&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ew,{phase:e,onUpdate:d,priorPhases:g}),(0,s.jsx)(eN,{phase:e,onUpdate:d})]})]})]})}function eC({phase:e}){return(0,s.jsxs)("div",{className:"mt-0.5 flex flex-wrap items-center gap-1.5 text-[10px] text-muted-foreground",children:["review_only"!==e.kind&&(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{className:(0,k.cn)("h-1.5 w-1.5 rounded-full",ee.find(r=>r.id===e.doer.lineage)?.dot)}),"doer: ",e.doer.lineage]}),e.reviewer.candidates.length>0&&(0,s.jsxs)(s.Fragment,{children:["review_only"!==e.kind&&(0,s.jsx)("span",{className:"text-muted-foreground/40",children:"\xb7"}),(0,s.jsxs)("span",{className:"flex items-center gap-1",children:["reviewers:",e.reviewer.candidates.map(e=>(0,s.jsx)("span",{className:(0,k.cn)("h-1.5 w-1.5 rounded-full",ee.find(r=>r.id===e)?.dot),title:e},e))]})]}),e.reviewer.crossLineage&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-muted-foreground/40",children:"\xb7"}),(0,s.jsx)("span",{className:"text-amber-300/90 font-mono text-[9px] uppercase",children:"cross-lineage"})]}),(0,s.jsx)("span",{className:"text-muted-foreground/40",children:"\xb7"}),(0,s.jsx)("span",{className:(0,k.cn)("font-mono text-[9px] uppercase","sequential"===e.execution?"text-amber-300/90":"text-emerald-300/80"),title:"sequential"===e.execution?"Sequential hostile — reviewers chain":"Parallel independent — reviewers vote",children:"sequential"===e.execution?"sequential":"parallel"}),e.inputs.exclude.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-muted-foreground/40",children:"\xb7"}),(0,s.jsxs)("span",{className:"text-rose-300/90 font-mono text-[9px]",children:["blind-to: ",e.inputs.exclude.join(",")]})]})]})}function eA({phases:e,onChange:r}){let t=es(),{personas:n}=function(){let[e,r]=(0,a.useState)({personas:[],loaded:!1});return(0,a.useEffect)(()=>{(0,O.UT)().then(e=>r({personas:e,loaded:!0})).catch(()=>r({personas:[],loaded:!0}))},[]),e}();function o(t,s){let a=t+s;if(a<0||a>=e.length)return;let n=[...e];[n[t],n[a]]=[n[a],n[t]],r(n)}let i=e.map(e=>e.id);return(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,s.jsxs)("span",{className:"text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:["Phases (",e.length,")"]}),(0,s.jsx)("span",{className:"text-[11px] text-muted-foreground/70",children:"Each phase has a doer + reviewer. Adversarial by default."})]}),(0,s.jsx)("div",{className:"space-y-2",children:e.map((a,l)=>(0,s.jsx)(ek,{phase:a,index:l,total:e.length,allPhaseIds:i,connectedVoices:t,personas:n,onUpdate:t=>{r(e.map((e,r)=>r===l?{...e,...t}:e))},onMoveUp:()=>o(l,-1),onMoveDown:()=>o(l,1),onDelete:()=>{r(e.filter((e,r)=>r!==l))}},a.id))}),(0,s.jsxs)("button",{type:"button",onClick:function(){var t;r([...e,(t=e.length,{id:`phase-${t+1}`,name:`Phase ${t+1}`,description:"",kind:"review",gate:"auto",doer:{lineage:"claude",models:["claude-opus-4-7"]},reviewer:{require:1,crossLineage:!0,candidates:["codex"]},inputs:{include:[],exclude:[]},iterate:{max:3,onMax:"ask-user"},blindSpots:[],execution:"sequential",builtin:!1})])},className:"mt-3 flex w-full items-center justify-center gap-1.5 rounded-md border border-dashed border-border bg-card/30 px-3 py-2.5 text-xs font-medium text-muted-foreground transition hover:border-primary/40 hover:bg-card/50 hover:text-foreground",children:[(0,s.jsx)(x.A,{className:"h-3.5 w-3.5"}),"Add phase"]})]})}function eS({active:e,onClick:r,disabled:t,children:a}){return(0,s.jsxs)("button",{type:"button",onClick:r,disabled:t,className:(0,k.cn)("relative flex items-center gap-1.5 rounded-t-md px-3 py-2.5 text-sm font-medium transition-colors",t?"cursor-not-allowed text-muted-foreground/50":e?"text-foreground":"text-muted-foreground hover:text-foreground"),children:[a,e&&!t&&(0,s.jsx)("span",{className:"absolute inset-x-0 -bottom-px h-0.5 bg-primary"})]})}function eM({label:e,htmlFor:r,hint:t,children:a}){return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("label",{htmlFor:r,className:"block text-[13px] font-medium text-foreground",children:e}),a,t&&(0,s.jsx)("p",{className:"text-[11px] leading-snug text-muted-foreground/80",children:t})]})}function eL({active:e,onClick:r,children:t}){return(0,s.jsx)("button",{type:"button",onClick:r,className:(0,k.cn)("h-8 rounded-md border px-3 text-xs font-medium transition",e?"border-primary/60 bg-primary/15 text-primary":"border-border bg-card text-muted-foreground hover:border-muted-foreground/30 hover:bg-accent/40 hover:text-foreground"),children:t})}function eD({form:e,setField:r,showErrors:t}){let a=t&&0===e.name.trim().length,n=t&&0===e.description.trim().length;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(eM,{label:"Name *",htmlFor:"tpl-name",children:[(0,s.jsx)("input",{id:"tpl-name",value:e.name,onChange:e=>r("name",e.target.value),placeholder:"security-audit","aria-invalid":a,className:(0,k.cn)("h-10 w-full rounded-md border bg-background px-3 text-sm placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2",a?"border-destructive/60 focus:border-destructive focus:ring-destructive/30":"border-border focus:border-primary/60 focus:ring-primary/20")}),a&&(0,s.jsx)("p",{className:"text-[11px] text-destructive",children:"Name is required."})]}),(0,s.jsxs)(eM,{label:"Description *",htmlFor:"tpl-desc",hint:"One sentence on when someone should reach for this template.",children:[(0,s.jsx)("textarea",{id:"tpl-desc",value:e.description,onChange:e=>r("description",e.target.value),placeholder:"Independent security audit from 3 model families…",rows:2,"aria-invalid":n,className:(0,k.cn)("w-full resize-none rounded-md border bg-background px-3 py-2 text-sm leading-relaxed placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2",n?"border-destructive/60 focus:border-destructive focus:ring-destructive/30":"border-border focus:border-primary/60 focus:ring-primary/20")}),n&&(0,s.jsx)("p",{className:"text-[11px] text-destructive",children:"Description is required."})]}),(0,s.jsx)(eM,{label:"Category",children:(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:$.map(t=>(0,s.jsx)(eL,{active:t.id===e.category,onClick:()=>r("category",t.id),children:t.label},t.id))})})]})}function eR({form:e,setField:r}){let t=es();return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"rounded-md border border-border bg-card/40 px-3 py-2 text-[11px] leading-relaxed text-muted-foreground",children:[(0,s.jsxs)("div",{className:"mb-1 flex items-center gap-1.5 text-foreground",children:[(0,s.jsx)(S.A,{className:"h-3 w-3"}),(0,s.jsx)("span",{className:"text-[12px] font-medium",children:"Template-level fallback chains"})]}),"Tried in order whenever a slot exhausts its own per-slot model chain. Cross-lineage swap supported — a codex slot can fall through to a claude or kimi entry. Strict",(0,s.jsx)("span",{className:"font-mono",children:" (lineage, model)"})," dedup keeps diversity: a fallback whose model already runs as another reviewer in this phase is skipped, so you never review the same code twice with the same voice. Order matters — list your most-preferred fallback first."]}),(0,s.jsx)(eP,{title:"Doer fallback",hint:"Engaged when the doer's primary + per-slot models all fail.",rows:e.fallbackDoer,onChange:e=>r("fallbackDoer",e),connectedVoices:t}),(0,s.jsx)(eP,{title:"Reviewer fallback",hint:"Engaged when any reviewer's primary + per-slot models all fail.",rows:e.fallbackReviewer,onChange:e=>r("fallbackReviewer",e),connectedVoices:t})]})}function eP({title:e,hint:r,rows:t,onChange:a,connectedVoices:n}){let o=(e,r)=>{a(t.map((t,s)=>s===e?{...t,...r}:t))};return(0,s.jsxs)("div",{className:"rounded-lg border border-border bg-card/40 p-4",children:[(0,s.jsxs)("div",{className:"mb-1 flex items-center justify-between",children:[(0,s.jsx)("h4",{className:"text-[13px] font-semibold tracking-tight",children:e}),(0,s.jsxs)("button",{type:"button",onClick:()=>{let e=q.find(e=>(n.byLineage[e]??[]).length>0)??"claude",r=n.byLineage[e]?.[0]??"";a([...t,{lineage:e,model:r}])},className:"inline-flex h-7 items-center gap-1 rounded-md border border-border bg-card px-2.5 text-[11px] font-medium text-muted-foreground transition hover:border-primary/40 hover:text-primary",children:[(0,s.jsx)(x.A,{className:"h-3 w-3"}),"Add fallback"]})]}),(0,s.jsx)("p",{className:"mb-3 text-[11px] leading-snug text-muted-foreground/80",children:r}),0===t.length?(0,s.jsx)("p",{className:"rounded-md border border-dashed border-border/60 bg-background/30 px-3 py-4 text-center text-[11px] text-muted-foreground",children:"None set — slot will fail its phase if the per-slot chain exhausts."}):(0,s.jsx)("ul",{className:"space-y-2",children:t.map((e,r)=>{let i=n.byLineage[e.lineage]??[],l=0===e.model.length||i.includes(e.model);return(0,s.jsxs)("li",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-border bg-card font-mono text-[10px] text-muted-foreground",children:r+1}),(0,s.jsx)("select",{value:e.lineage,onChange:e=>{var s;let a,i;return s=e.target.value,a=n.byLineage[s]??[],i=t[r].model,void o(r,{lineage:s,model:a.includes(i)?i:a[0]??""})},className:"h-8 rounded-md border border-border bg-background px-2 text-xs text-foreground focus:border-primary/60 focus:outline-none focus:ring-1 focus:ring-primary/20",children:q.map(e=>(0,s.jsx)("option",{value:e,children:e},e))}),(0,s.jsxs)("select",{value:e.model,onChange:e=>o(r,{model:e.target.value}),className:"h-8 flex-1 rounded-md border border-border bg-background px-2 font-mono text-[11px] text-foreground focus:border-primary/60 focus:outline-none focus:ring-1 focus:ring-primary/20",children:[0===i.length&&(0,s.jsx)("option",{value:"",disabled:!0,children:n.loaded?`No ${e.lineage} models enabled — open Connect → ${e.lineage}`:"loading…"}),i.map(e=>(0,s.jsx)("option",{value:e,children:e},e)),!l&&e.model.length>0&&(0,s.jsxs)("option",{value:e.model,children:[e.model," (stored)"]})]}),(0,s.jsx)("button",{type:"button",onClick:()=>{a(t.filter((e,t)=>t!==r))},"aria-label":`Remove fallback ${r+1}`,className:"grid h-7 w-7 place-items-center rounded-md border border-border bg-card text-muted-foreground transition hover:border-destructive/40 hover:text-destructive",children:(0,s.jsx)(h.A,{className:"h-3 w-3"})})]},r)})})]})}function e$({form:e,setField:r}){return(0,s.jsxs)("div",{className:"rounded-lg border border-border bg-card/40 p-4",children:[(0,s.jsx)("h3",{className:"mb-3 text-[13px] font-semibold tracking-tight",children:"Across all phases"}),(0,s.jsxs)("div",{className:"mb-4",children:[(0,s.jsx)("div",{className:"mb-1.5 text-[11px] font-medium text-muted-foreground",children:"Agreement threshold (per review-style phase)"}),(0,s.jsx)("div",{className:"grid grid-cols-3 gap-2",children:T.map(t=>(0,s.jsx)("button",{type:"button",onClick:()=>r("threshold",t.id),className:(0,k.cn)("rounded-md border px-3 py-2 text-left transition",e.threshold===t.id?"border-primary/60 bg-primary/10 ring-1 ring-primary/40":"border-border bg-card hover:border-muted-foreground/30 hover:bg-accent/40"),children:(0,s.jsx)("div",{className:"text-xs font-medium",children:t.label})},t.id))}),(0,s.jsx)("p",{className:"mt-1.5 text-[11px] leading-snug text-muted-foreground/80",children:T.find(r=>r.id===e.threshold)?.hint})]}),(0,s.jsxs)("div",{className:"mb-4",children:[(0,s.jsx)("div",{className:"mb-1.5 text-[11px] font-medium text-muted-foreground",children:"When threshold is met"}),(0,s.jsx)("div",{className:"grid grid-cols-2 gap-2",children:_.map(t=>(0,s.jsx)("button",{type:"button",onClick:()=>r("onThresholdMet",t.id),className:(0,k.cn)("rounded-md border px-3 py-2 text-left transition",e.onThresholdMet===t.id?"border-primary/60 bg-primary/10 ring-1 ring-primary/40":"border-border bg-card hover:border-muted-foreground/30 hover:bg-accent/40"),children:(0,s.jsx)("div",{className:"text-xs font-medium",children:t.label})},t.id))})]}),(0,s.jsxs)("div",{className:"mb-4",children:[(0,s.jsxs)("div",{className:"mb-1.5 flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"Max revise rounds (per phase)"}),(0,s.jsx)("span",{className:"font-mono text-xs text-foreground",children:e.maxRounds})]}),(0,s.jsx)("input",{type:"range",min:1,max:5,step:1,value:e.maxRounds,onChange:e=>r("maxRounds",parseInt(e.target.value,10)),className:"h-1 w-full cursor-pointer appearance-none rounded-full bg-muted accent-primary"})]}),(0,s.jsxs)("button",{type:"button",onClick:()=>r("yoloDefault",!e.yoloDefault),className:(0,k.cn)("flex w-full items-center justify-between rounded-md border px-3 py-2 text-left transition",e.yoloDefault?"border-rose-500/40 bg-rose-500/5":"border-border bg-card hover:border-foreground/30"),children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-xs font-medium text-foreground",children:"\uD83D\uDE80 Yolo by default"}),(0,s.jsx)("div",{className:"text-[10px] text-muted-foreground",children:"Auto-approve every gate. Only flip on for trusted templates or trivial fixes. Cost cap still enforced."})]}),(0,s.jsx)("span",{className:(0,k.cn)("flex h-5 w-9 shrink-0 items-center rounded-full border p-0.5 transition",e.yoloDefault?"border-rose-500/40 bg-rose-500/20":"border-border bg-card"),children:(0,s.jsx)("span",{className:(0,k.cn)("h-3.5 w-3.5 rounded-full transition-transform",e.yoloDefault?"translate-x-4 bg-rose-400":"bg-muted-foreground/50")})})]})]})}function eT(e,r){let t=[];if(1===e)r.name&&0!==r.name.trim().length?r.name.length>80&&t.push("Name is too long (max 80 chars)."):t.push("Name is required."),r.description&&0!==r.description.trim().length||t.push("Description is required — one line on when to use this template.");else if(2===e)for(let e of(0===r.phases.length&&t.push("At least one phase is required."),r.phases))e.id&&0!==e.id.trim().length||t.push(`Phase "${e.name||"(unnamed)"}" needs an id.`),"review_only"===e.kind||e.doer.lineage&&0!==e.doer.models.length||t.push(`Phase "${e.name||e.id}" needs a doer lineage + model.`),0===e.reviewer.candidates.length&&t.push(`Phase "${e.name||e.id}" needs at least one reviewer.`);return t}function e_({form:e,setField:r}){let[t,n]=(0,a.useState)(1),[o,i]=(0,a.useState)(!1),l=eT(t,e),d=0===l.length;return(0,s.jsxs)("div",{className:"flex h-full flex-col px-6 py-6",children:[(0,s.jsx)(eE,{currentStep:t,onJump:r=>{if(r<=t){i(!1),n(r);return}for(let s=t;s<r;s++)if(eT(s,e).length>0)return void i(!0);i(!1),n(r)},form:e}),(0,s.jsxs)("div",{className:"mt-6 flex-1 space-y-6",children:[1===t&&(0,s.jsx)(eD,{form:e,setField:r,showErrors:o}),2===t&&(0,s.jsx)(eq,{form:e,setField:r,showErrors:o}),3===t&&(0,s.jsx)(eR,{form:e,setField:r}),4===t&&(0,s.jsx)(e$,{form:e,setField:r})]}),o&&l.length>0&&(0,s.jsxs)("div",{className:"mt-6 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:[(0,s.jsx)("div",{className:"mb-1 font-medium",children:"Resolve these to continue:"}),(0,s.jsx)("ul",{className:"space-y-0.5 pl-4",children:l.map(e=>(0,s.jsx)("li",{className:"list-disc",children:e},e))})]}),(0,s.jsxs)("div",{className:"mt-6 flex items-center justify-between border-t border-border pt-4",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>{i(!1),t>1&&n(t-1)},disabled:1===t,className:"inline-flex h-9 items-center gap-1.5 rounded-md border border-border bg-card px-3 text-sm font-medium text-muted-foreground transition hover:border-muted-foreground/30 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40",children:[(0,s.jsx)(Y.A,{className:"h-3.5 w-3.5"}),"Back"]}),(0,s.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:["Step ",t," of 4 \xb7 ",E[t-1].label]}),t<4?(0,s.jsxs)("button",{type:"button",onClick:()=>{d?(i(!1),t<4&&n(t+1)):i(!0)},className:(0,k.cn)("inline-flex h-9 items-center gap-1.5 rounded-md px-3 text-sm font-medium shadow-sm transition",d?"bg-primary text-primary-foreground hover:bg-primary/90":"bg-muted text-muted-foreground/60"),children:["Next",(0,s.jsx)(z.A,{className:"h-3.5 w-3.5"})]}):(0,s.jsxs)("span",{className:"text-[11px] text-emerald-300",children:[(0,s.jsx)(b.A,{className:"mr-1 inline-block h-3 w-3"}),"Save in the footer below"]})]})]})}function eE({currentStep:e,onJump:r,form:t}){return(0,s.jsx)("div",{className:"flex items-stretch gap-2",children:E.map(a=>{let n=a.icon,o=a.id===e,i=0===eT(a.id,t).length,l=a.id<e;return(0,s.jsxs)("button",{type:"button",onClick:()=>r(a.id),className:(0,k.cn)("flex flex-1 items-center gap-2 rounded-md border px-3 py-2 text-left transition",o?"border-primary/60 bg-primary/10":l&&!i?"border-destructive/40 bg-destructive/5":"border-border bg-card hover:border-muted-foreground/30"),children:[(0,s.jsx)("span",{className:(0,k.cn)("flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-[10px] font-mono",o?"bg-primary text-primary-foreground":l&&i?"bg-emerald-500/20 text-emerald-300":l&&!i?"bg-destructive/20 text-destructive":"bg-muted text-muted-foreground"),children:l&&i?"✓":a.id}),(0,s.jsx)(n,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,s.jsx)("span",{className:"hidden text-xs font-medium sm:inline",children:a.label})]},a.id)})})}function eq({form:e,setField:r,showErrors:t}){let a=eT(2,e);return(0,s.jsxs)(s.Fragment,{children:[t&&a.length>0&&(0,s.jsx)("div",{className:"rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:a[0]}),(0,s.jsx)(eA,{phases:e.phases,onChange:e=>r("phases",e)})]})}function eF(e){return Array.isArray(e)?e.flatMap(e=>{let r=D[e.lineage??""]??"claude",t=(e.models??[]).filter(e=>"string"==typeof e&&e.trim().length>0);return 0===t.length?[]:t.map(t=>({lineage:r,model:t,...e.persona?{persona:e.persona}:{}}))}):[]}let eU=["plan","spec","tests","implement","review","verify","divergence","review_only"];function eY(e,r){let t,s,a,n,o=[];try{t=y.Ay.parse(e)??{}}catch{return{form:{...P,id:r},formLossy:!0,lossyReasons:["YAML failed to parse — only YAML mode is available."]}}t.ship?.enabled&&o.push("Template has `ship.enabled: true` — form mode can't edit ship config.");let i=[];for(let e of t.phases??[]){let{phase:r,reasons:t}=function(e){let r=[];void 0!==e.timeoutMs&&r.push(`Phase ${e.id??"?"} has \`timeoutMs\` — not exposed in form mode.`);let t="review_only"===e.kind,s=t?"claude":D[e.doer?.lineage??""]??"claude",a={},n={},o=new Set,i=[],l=[];for(let r of e.reviewer?.candidates??[]){let e=D[r.lineage??""];if(!e)continue;o.has(e)||(o.add(e),i.push(e));let t=(r.models??[]).map(e=>(e??"").trim()).filter(e=>e.length>0),s=r.persona&&r.persona.trim().length>0?r.persona:void 0,d=r=>{if(!s)return;let t=n[e]??={},a=t[r];void 0!==a&&a!==s&&l.push(`${e}/${r||"(no model)"}: "${a}" vs "${s}"`),t[r]=s};if(0===t.length)d("");else for(let r of t)(a[e]??=[]).push(r),d(r)}l.length>0&&r.push(`Phase ${e.id??"?"} has overlapping reviewer candidates with conflicting personas (${l.join("; ")}) — form mode would silently last-write-wins; edit in YAML to disambiguate.`);let d=eU.includes(e.kind)?e.kind:"review";return e.kind&&!eU.includes(e.kind)&&r.push(`Phase ${e.id??"?"} has unknown kind \`${e.kind}\` — form mode would coerce it to \`review\`.`),{phase:{id:e.id??"phase",name:e.title??e.name??e.id??"Phase",description:e.description??"",kind:d,gate:"auto",doer:{lineage:s,models:e.doer?.models&&e.doer.models.length>0?e.doer.models:[R[s]??"claude-opus-4-7"],...e.doer?.persona&&e.doer.persona.trim().length>0?{persona:e.doer.persona.trim()}:{}},reviewer:{require:e.reviewer?.require??1,crossLineage:e.reviewer?.crossLineage??!0,candidates:i,candidateModels:a,...Object.keys(n).length>0?{candidatePersonas:n}:{}},inputs:{include:e.inputs?.include??[],exclude:e.inputs?.exclude??[]},iterate:{max:e.iterate?.maxRounds??2,onMax:(e.iterate?.onDisagreement??"continue")==="continue"?"loopback":e.iterate?.onDisagreement==="accept-doer"?"fail":"ask-user"},blindSpots:[],execution:"parallel",builtin:!1,...t&&e.artifact?{artifact:{label:e.artifact.label??"Artifact to review",hint:e.artifact.hint??"Paste a unified diff, a markdown draft, code, or any text blob.",maxBytes:e.artifact.maxBytes??1048576}}:t?{artifact:{label:"Artifact to review",hint:"Paste a unified diff, a markdown draft, code, or any text blob.",maxBytes:1048576}}:{}},reasons:r}}(e);i.push(r),o.push(...t)}if("number"==typeof t.agreementThreshold){var l;s=(l=t.agreementThreshold)>=.99?"unanimous":l>=.5?"majority":"any",new Set([1,.66,.34]).has(t.agreementThreshold)||(a=t.agreementThreshold,o.push(`Custom \`agreementThreshold: ${t.agreementThreshold}\` — form mode only offers 1.0 / 0.66 / 0.34 presets.`))}else s=t.agreementThreshold??"majority";let d="review"===t.onThresholdMet?"review":void 0;return"review"===d&&o.push("`onThresholdMet: review` — form mode only offers auto-finalize / ask-user."),{form:{id:t.id??r,name:t.name??"",description:t.description??"",author:t.author??"chorus",category:(n=(t.id??r).toLowerCase()).includes("bug")||n.includes("debug")||n.includes("diagnose")?"debug":n.includes("plan")||n.includes("architect")?"plan":n.includes("decide")||n.includes("decision")?"decide":"review",phases:i.length>0?i:P.phases,threshold:s,...void 0!==a?{customThreshold:a}:{},onThresholdMet:"merge"===t.onThresholdMet?"auto-finalize":"ask-user",...d?{onThresholdMetRaw:d}:{},maxRounds:t.maxRounds??3,yoloDefault:t.yoloDefault??!1,fallbackDoer:eF(t.fallback?.doer),fallbackReviewer:eF(t.fallback?.reviewer)},formLossy:o.length>0,lossyReasons:o}}function ez({yaml:e,filename:r,issues:t,onChange:a}){return(0,s.jsxs)("div",{className:"flex h-full min-h-[400px] flex-col",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between border-b border-border bg-card/40 px-6 py-2.5",children:[(0,s.jsx)("span",{className:"font-mono text-[11px] text-muted-foreground",children:r}),(0,s.jsx)(eI,{issues:t})]}),(0,s.jsx)("textarea",{value:e,onChange:e=>a(e.target.value),spellCheck:!1,className:"flex-1 resize-none border-0 bg-background px-6 py-4 font-mono text-[12px] leading-relaxed text-foreground focus:outline-none"}),t.length>0&&(0,s.jsx)("ul",{className:"border-t border-border bg-destructive/5 px-6 py-2.5 text-[11px] text-destructive",children:t.map((e,r)=>(0,s.jsxs)("li",{className:"flex items-start gap-1.5 leading-snug",children:[(0,s.jsx)(f.A,{className:"mt-[1px] h-3 w-3 shrink-0"}),(0,s.jsxs)("span",{children:[(0,s.jsx)("span",{className:"font-mono",children:e.path}),"number"==typeof e.line&&` (line ${e.line})`,": ",e.message]})]},r))})]})}function eI({issues:e}){return 0===e.length?(0,s.jsxs)("span",{className:"flex items-center gap-1 rounded-md bg-emerald-500/10 px-1.5 py-0.5 text-[10px] font-medium text-emerald-400",children:[(0,s.jsx)(b.A,{className:"h-3 w-3"}),"Valid"]}):(0,s.jsxs)("span",{className:"flex items-center gap-1 rounded-md bg-destructive/10 px-1.5 py-0.5 text-[10px] font-medium text-destructive",children:[(0,s.jsx)(f.A,{className:"h-3 w-3"}),e.length," ",1===e.length?"issue":"issues"]})}function eO({editing:e,trigger:r,onSaved:t}){var i;let[l,d]=(0,a.useState)(!1),c=!!e,u=(0,a.useMemo)(()=>{if(!e)return{form:P,yaml:U(P),lossy:!1,reasons:[]};let r=eY(e.yaml,e.id);return{form:r.form,yaml:e.yaml,lossy:r.formLossy,reasons:r.lossyReasons}},[e?.id,e?.yaml]),[m,C]=(0,a.useState)(u.form),[A,S]=(0,a.useState)(u.yaml),[M,L]=(0,a.useState)(!1),[D,R]=(0,a.useState)(!1),[$,T]=(0,a.useState)(u.lossy?"yaml":"form"),[_,E]=(0,a.useState)(!1),[q,Y]=(0,a.useState)(null),[z,I]=(0,a.useState)([]);(0,a.useEffect)(()=>{C(u.form),S(u.yaml),L(!1),R(!1),T(u.lossy?"yaml":"form"),Y(null),I([])},[u]);let O=(0,a.useRef)(u);(0,a.useEffect)(()=>{O.current=u});let B=(i={yamlDirty:M,tab:$,formDirty:D,yamlText:A,formYaml:U(m),initialYaml:u.yaml}).yamlDirty||"yaml"===i.tab?i.yamlText:i.formDirty?i.formYaml:i.initialYaml,V=(0,a.useMemo)(()=>(function(e){let r;if(0===e.trim().length)return{valid:!1,issues:[{path:"<yaml>",message:"Template YAML is empty."}]};try{r=y.Ay.parse(e)}catch(t){let e=t instanceof Error?t.message:String(t),r=t.linePos?.[0];return{valid:!1,issues:[{path:"<yaml>",message:e,...r?{line:r.line,col:r.col}:{}}]}}if(null==r)return{valid:!1,issues:[{path:"<yaml>",message:"Template YAML parsed to null — at minimum it must define id, name, and phases."}]};let t=w._i.safeParse(r);return t.success?N:{valid:!1,issues:t.error.issues.map(e=>({path:e.path.length>0?e.path.join("."):"<root>",message:e.message}))}})(B),[B]);function G(e){if("form"===e&&M){let e=eY(A,m.id);if(e.formLossy)return;C(e.form),L(!1),R(!0)}T(e)}function W(){let e=O.current;C(e.form),S(e.yaml),L(!1),R(!1),T(e.lossy?"yaml":"form"),E(!1),Y(null),I([])}function K(e){d(e),e||setTimeout(W,200)}async function H(){if(!V.valid||_)return;let r=c?e.id:m.id||F(m.name)||"untitled";E(!0),Y(null),I([]);try{let e=await (0,j.AI)({id:r,yaml:B});t?.(e.id),K(!1)}catch(e){e instanceof j.$v?(Y(e.message),I(e.details?.issues??[])):Y(e instanceof Error?e.message:"Save failed (unknown error)")}finally{E(!1)}}let Z=V.valid&&!_,J=r??(0,s.jsxs)("button",{type:"button","aria-label":c?"Edit template":"New template",className:"inline-flex shrink-0 items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground shadow-sm transition hover:bg-primary/90",children:[c?(0,s.jsx)(n.A,{className:"h-4 w-4"}):(0,s.jsx)(x.A,{className:"h-4 w-4"}),(0,s.jsx)("span",{className:"hidden sm:inline",children:c?"Edit":"New template"})]});return(0,s.jsxs)(v.lG,{open:l,onOpenChange:K,children:[(0,s.jsx)(v.zM,{asChild:!0,children:J}),(0,s.jsxs)(v.Cf,{showCloseButton:!1,className:"flex max-h-[85vh] w-[min(96vw,720px)] flex-col gap-0 overflow-hidden border-border bg-card p-0 shadow-2xl sm:max-w-none",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 border-b border-border px-6 py-4",children:[(0,s.jsx)("div",{className:"grid h-9 w-9 shrink-0 place-items-center rounded-md bg-primary/15 text-primary ring-1 ring-primary/20",children:(0,s.jsx)(p.A,{className:"h-4 w-4"})}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)(v.L3,{className:"text-[15px] font-semibold leading-tight tracking-tight",children:c?`Edit template — ${e.name}`:"New template"}),(0,s.jsx)(v.rr,{className:"mt-0.5 text-xs text-muted-foreground",children:c?"Edit the YAML directly or use the form. Validation runs live.":"A reusable review workflow. Edit visually below or paste raw YAML."})]}),(0,s.jsx)("button",{type:"button",onClick:()=>K(!1),className:"grid h-7 w-7 place-items-center rounded-md text-muted-foreground transition hover:bg-accent hover:text-foreground","aria-label":"Close",children:(0,s.jsx)(h.A,{className:"h-4 w-4"})})]}),(0,s.jsx)("div",{className:"border-b border-border bg-card/40 px-6",children:(0,s.jsxs)("div",{className:"-mb-px flex items-center gap-1",children:[(0,s.jsxs)(eS,{active:"form"===$,onClick:()=>!u.lossy&&G("form"),disabled:u.lossy,children:[(0,s.jsx)(g.A,{className:"h-3.5 w-3.5"}),"Form",u.lossy&&(0,s.jsx)("span",{className:"ml-1 rounded bg-muted px-1 text-[9px] font-medium text-muted-foreground",children:"YAML only"})]}),(0,s.jsxs)(eS,{active:"yaml"===$,onClick:()=>G("yaml"),children:[(0,s.jsx)(p.A,{className:"h-3.5 w-3.5"}),"YAML",!V.valid&&"form"===$&&(0,s.jsx)("span",{className:"ml-1 h-1.5 w-1.5 rounded-full bg-destructive"})]})]})}),(0,s.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[u.lossy&&"yaml"===$&&(0,s.jsx)("div",{className:"border-b border-amber-500/30 bg-amber-500/5 px-6 py-2.5 text-[11px] text-amber-200",children:(0,s.jsxs)("div",{className:"flex items-start gap-2",children:[(0,s.jsx)(f.A,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("div",{className:"font-medium",children:"Form editing disabled for this template"}),(0,s.jsx)("ul",{className:"mt-1 space-y-0.5 leading-snug",children:u.reasons.map((e,r)=>(0,s.jsxs)("li",{children:["\xb7 ",e]},r))})]})]})}),"form"===$?(0,s.jsx)(e_,{form:m,setField:function(e,r){let t={...m,[e]:r};C(t),R(!0),M||S(U(t))}}):(0,s.jsx)(ez,{yaml:A,filename:`${m.id||F(m.name)||"untitled"}.yaml`,issues:V.issues,onChange:e=>{S(e),L(!0)}})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-2 border-t border-border bg-card/40 px-6 py-3",children:[q&&(0,s.jsx)("div",{className:"rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:(0,s.jsxs)("div",{className:"flex items-start gap-1.5",children:[(0,s.jsx)(f.A,{className:"mt-0.5 h-3 w-3 shrink-0"}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("div",{className:"font-medium",children:"Save failed"}),(0,s.jsx)("div",{className:"mt-0.5 leading-snug",children:q}),z.length>0&&(0,s.jsx)("ul",{className:"mt-1 space-y-0.5",children:z.slice(0,5).map((e,r)=>(0,s.jsxs)("li",{children:[(0,s.jsx)("span",{className:"font-mono",children:e.path}),":"," ",e.message]},r))})]})]})}),(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsx)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:V.valid?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(b.A,{className:"h-3 w-3 text-emerald-400"}),(0,s.jsx)("span",{children:"Ready to save"})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(f.A,{className:"h-3 w-3 text-destructive/80"}),(0,s.jsxs)("span",{children:[V.issues.length," ",1===V.issues.length?"issue":"issues"," to resolve"]})]})}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("button",{type:"button",onClick:()=>K(!1),className:"h-9 rounded-md border border-border bg-card px-4 text-sm font-medium text-muted-foreground transition hover:border-muted-foreground/30 hover:text-foreground",children:"Cancel"}),(0,s.jsxs)("button",{type:"button",disabled:!Z,onClick:H,className:(0,k.cn)("inline-flex h-9 items-center gap-1.5 rounded-md px-4 text-sm font-medium shadow-sm transition",Z?"bg-primary text-primary-foreground hover:bg-primary/90":"cursor-not-allowed bg-muted text-muted-foreground/60 shadow-none"),children:[_&&(0,s.jsx)(o.A,{className:"h-3.5 w-3.5 animate-spin"}),_?"Saving…":c?"Save changes":"Save template"]})]})]})]})]})]})}let eB=Object.fromEntries(Object.entries(J.r2).map(([e,r])=>[e,r.dot])),eV=[{id:"all",label:"All"},{id:"review",label:"Review"},{id:"plan",label:"Plan"},{id:"debug",label:"Debug"},{id:"decide",label:"Decide"}];function eG(){let[e,r]=(0,a.useState)([]),[t,x]=(0,a.useState)(null),[p,h]=(0,a.useState)("all"),[g,f]=(0,a.useState)(""),[b,v]=(0,a.useState)(null),[y,w]=(0,a.useState)(null),[N,k]=(0,a.useState)(null),C=(0,a.useCallback)(async e=>{try{let t=await (0,j.eG)();r(t),e&&t.find(r=>r.id===e)?f(e):t.length>0&&!g&&f(t[0].id)}catch(e){x(e instanceof j.$v?e.message:"Failed to load templates")}},[g]);async function A(e){if(!y&&"builtin"!==e.source){if(b!==e.id){v(e.id),k(null),setTimeout(()=>{v(r=>r===e.id?null:r)},8e3);return}w(e.id),k(null);try{await (0,j.I7)(e.id),v(null),g===e.id&&f(""),await C()}catch(e){k(e instanceof j.$v||e instanceof Error?e.message:"Delete failed (unknown error)"),v(null)}finally{w(null)}}}(0,a.useEffect)(()=>{C()},[]);let S="all"===p?e:e.filter(e=>e.category===p),M=e.find(e=>e.id===g)??e[0]??null;return t?(0,s.jsx)(l.G,{children:(0,s.jsx)("div",{className:"mx-auto w-full max-w-6xl px-4 py-6 sm:px-6 sm:py-8 md:px-8 md:py-10",children:(0,s.jsxs)("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4",children:[(0,s.jsx)("p",{className:"text-sm text-destructive",children:"Error loading templates"}),(0,s.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:t})]})})}):(0,s.jsx)(l.G,{children:(0,s.jsxs)("div",{className:"mx-auto w-full max-w-6xl px-4 py-6 sm:px-6 sm:py-8 md:px-8 md:py-10",children:[(0,s.jsx)(u.z,{eyebrow:"Templates",title:"Reusable review workflows",subtitle:"Each template defines the driver, reviewers, prompts, and quorum rule for a kind of task. Fork, edit, share.",action:(0,s.jsx)(eO,{onSaved:e=>C(e)})}),N&&(0,s.jsx)("div",{className:"mb-4 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:N}),(0,s.jsx)("div",{className:"mb-4 flex items-center gap-1 border-b border-border",children:eV.map(e=>(0,s.jsxs)("button",{type:"button",onClick:()=>h(e.id),className:`relative px-3 py-2 text-sm transition ${e.id===p?"text-foreground":"text-muted-foreground hover:text-foreground"}`,children:[e.label,e.id===p&&(0,s.jsx)("span",{className:"absolute inset-x-3 bottom-0 h-0.5 bg-primary"})]},e.id))}),(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-[1fr_1fr]",children:[(0,s.jsx)("div",{className:"flex min-w-0 flex-col gap-2",children:S.map(e=>(0,s.jsxs)("div",{role:"button",tabIndex:0,onClick:()=>f(e.id),onKeyDown:r=>{("Enter"===r.key||" "===r.key)&&(r.preventDefault(),f(e.id))},className:`group relative cursor-pointer rounded-xl text-left transition focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/60 ${e.id===g?"ring-2 ring-primary/60 ring-offset-2 ring-offset-background":""}`,children:[(0,s.jsxs)(d.Zp,{className:"bg-card p-4 transition group-hover:border-muted-foreground/30",children:[(0,s.jsx)("div",{className:"flex items-start justify-between gap-3",children:(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("span",{className:"text-sm font-semibold",children:e.name}),(0,s.jsx)(c.E,{variant:"outline",className:"border-border text-[10px] capitalize",children:e.category}),!1===e.isComplete&&(0,s.jsx)(c.E,{variant:"outline",className:"border-amber-500/40 bg-amber-500/10 font-mono text-[9px] uppercase text-amber-300",children:"needs setup"})]}),(0,s.jsx)("p",{className:"mt-1 text-xs text-muted-foreground line-clamp-2",children:!1===e.isComplete?"Some slots couldn't be filled from your installed CLIs. Edit the YAML to pick models for each slot.":e.description})]})}),e.phases[0]?.reviewer?.candidates.length?(0,s.jsxs)("div",{className:"mt-3 flex items-center gap-2 text-[11px] text-muted-foreground",children:[e.phases[0]?.kind!=="review_only"&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-amber-400"}),"doer"]}),(0,s.jsx)("span",{className:"text-muted-foreground/40",children:"→"})]}),(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[e.phases[0]?.reviewer?.candidates.map(e=>(0,s.jsx)("span",{className:`h-1.5 w-1.5 rounded-full ${eB[e]}`,title:e},e)),(0,s.jsxs)("span",{children:[e.phases[0]?.reviewer?.candidates.length," ",e.phases[0]?.reviewer?.candidates.length===1?"reviewer":"reviewers"]})]}),e.phases.length>1&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-muted-foreground/40",children:"\xb7"}),(0,s.jsxs)("span",{className:"font-mono text-[10px]",children:[e.phases.length," phases"]})]})]}):null]}),(0,s.jsxs)("div",{className:`absolute bottom-3 right-3 flex items-center gap-1.5 transition ${e.id===g?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"}`,onClick:r=>{r.stopPropagation(),f(e.id)},onKeyDown:e=>e.stopPropagation(),children:[(0,s.jsx)(eO,{editing:e,onSaved:e=>C(e),trigger:(0,s.jsx)("button",{type:"button","aria-label":`Edit ${e.name}`,className:"grid h-7 w-7 place-items-center rounded-md border border-border bg-card text-muted-foreground transition hover:border-muted-foreground/40 hover:bg-accent/60 hover:text-foreground",children:(0,s.jsx)(n.A,{className:"h-3.5 w-3.5"})})}),"builtin"!==e.source&&(0,s.jsx)("button",{type:"button","aria-label":b===e.id?`Confirm delete ${e.name}`:`Delete ${e.name}`,title:b===e.id?"Click again to confirm":"Delete",disabled:y===e.id,onClick:()=>A(e),className:`grid h-7 w-7 place-items-center rounded-md border transition disabled:cursor-not-allowed disabled:opacity-50 ${b===e.id?"border-destructive bg-destructive/15 text-destructive":"border-border bg-card text-muted-foreground hover:border-destructive/50 hover:text-destructive"}`,children:y===e.id?(0,s.jsx)(o.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,s.jsx)(i.A,{className:"h-3.5 w-3.5"})})]})]},e.id))}),M?(0,s.jsx)("div",{className:"lg:sticky lg:top-6 lg:max-h-[calc(100vh-10rem)] lg:h-[calc(100vh-10rem)]",children:(0,s.jsx)(m.N,{filename:`${M.id}.yaml`,charCount:M.yaml.length,maxHeightClassName:"h-full",footer:(0,s.jsxs)("span",{children:["by ",M.authorHandle]}),children:M.yaml})}):(0,s.jsx)(d.Zp,{className:"bg-card p-4 text-center text-muted-foreground",children:(0,s.jsx)("p",{children:"Select a template to view details"})})]})]})})}},9936:(e,r,t)=>{Promise.resolve().then(t.bind(t,3016))}},e=>{e.O(0,[742,832,690,641,344,744,506,128,358],()=>e(e.s=9936)),_N_E=e.O()}]);