@event4u/agent-config 7.1.0 → 7.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/.claude-plugin/marketplace.json +2 -1
  2. package/CHANGELOG.md +39 -0
  3. package/README.md +1 -1
  4. package/dist/agent-src/rules/brand-source-of-truth.md +10 -0
  5. package/dist/agent-src/rules/delegation-policy.md +1 -0
  6. package/dist/agent-src/rules/legal-safety-floor.md +42 -4
  7. package/dist/agent-src/rules/output-discipline.md +85 -0
  8. package/dist/agent-src/rules/telegraph-speak.md +4 -1
  9. package/dist/agent-src/rules/token-budget-discipline.md +94 -0
  10. package/dist/agent-src/skills/accessibility-auditor/SKILL.md +20 -5
  11. package/dist/agent-src/skills/blade-ui/SKILL.md +9 -0
  12. package/dist/agent-src/skills/contract-review/SKILL.md +3 -2
  13. package/dist/agent-src/skills/dashboard-design/SKILL.md +21 -5
  14. package/dist/agent-src/skills/design-intelligence/SKILL.md +96 -0
  15. package/dist/agent-src/skills/design-review/SKILL.md +83 -0
  16. package/dist/agent-src/skills/design-system-capture/SKILL.md +234 -0
  17. package/dist/agent-src/skills/design-tokens/SKILL.md +1 -0
  18. package/dist/agent-src/skills/dpa-review/SKILL.md +3 -2
  19. package/dist/agent-src/skills/existing-ui-audit/SKILL.md +15 -4
  20. package/dist/agent-src/skills/fe-design/SKILL.md +98 -16
  21. package/dist/agent-src/skills/flux/SKILL.md +8 -0
  22. package/dist/agent-src/skills/iconography/SKILL.md +1 -0
  23. package/dist/agent-src/skills/legal-intake-triage/SKILL.md +3 -2
  24. package/dist/agent-src/skills/legal-practice-profile/SKILL.md +3 -2
  25. package/dist/agent-src/skills/livewire/SKILL.md +8 -0
  26. package/dist/agent-src/skills/nda-triage/SKILL.md +3 -2
  27. package/dist/agent-src/skills/react-shadcn-ui/SKILL.md +21 -9
  28. package/dist/agent-src/skills/skill-writing/SKILL.md +18 -0
  29. package/dist/agent-src/skills/subagent-orchestration/SKILL.md +7 -10
  30. package/dist/agent-src/skills/tailwind-engineer/SKILL.md +17 -7
  31. package/dist/agent-src/skills/typography-system/SKILL.md +14 -0
  32. package/dist/agent-src/skills/ui-component-architect/SKILL.md +9 -0
  33. package/dist/discovery/deprecation-report.md +1 -1
  34. package/dist/discovery/discovery-manifest.json +123 -59
  35. package/dist/discovery/discovery-manifest.json.sha256 +1 -1
  36. package/dist/discovery/discovery-manifest.summary.md +8 -8
  37. package/dist/discovery/orphan-report.md +1 -1
  38. package/dist/discovery/packs.json +18 -15
  39. package/dist/discovery/trust-report.md +5 -5
  40. package/dist/discovery/workspaces.json +15 -12
  41. package/dist/mcp/registry-manifest.json +2 -2
  42. package/dist/router.json +1 -1
  43. package/dist/server/routes/wizard.js +4 -3
  44. package/dist/server/routes/wizard.js.map +1 -1
  45. package/dist/server/schemas/settings.js +9 -0
  46. package/dist/server/schemas/settings.js.map +1 -1
  47. package/dist/ui/assets/{index-CoQo90sz.js → index-UjcTG_9O.js} +2 -2
  48. package/dist/ui/assets/index-UjcTG_9O.js.map +1 -0
  49. package/dist/ui/index.html +1 -1
  50. package/docs/RELEASE_STORY_TEMPLATE.md +37 -0
  51. package/docs/architecture.md +3 -3
  52. package/docs/contracts/capability-boundary.md +64 -0
  53. package/docs/contracts/discovery-manifest.schema.json +2 -2
  54. package/docs/contracts/package-self-orientation.md +3 -0
  55. package/docs/contracts/subagent-boundary.md +54 -0
  56. package/docs/decisions/ADR-013-discovery-frontmatter-contract.md +13 -0
  57. package/docs/decisions/ADR-107-legal-domain-pack-adoption.md +19 -0
  58. package/docs/getting-started.md +1 -1
  59. package/docs/guidelines/agent-infra/domain-pack-architecture.md +1 -0
  60. package/docs/guidelines/design-antipatterns-triggers.json +17 -0
  61. package/docs/guidelines/design-antipatterns.md +170 -0
  62. package/docs/guidelines/design-modes.md +97 -0
  63. package/package.json +1 -1
  64. package/src/config/agent-settings.template.yml +31 -0
  65. package/src/config/discovery/packs.yml +16 -5
  66. package/src/config/discovery/workspaces.yml +4 -4
  67. package/src/scripts/check_trunk_drift.ts +67 -0
  68. package/src/scripts/lint_design_quality.ts +321 -0
  69. package/src/scripts/lint_discovery_vocabulary.ts +4 -4
  70. package/src/scripts/lint_legal_pack.ts +62 -4
  71. package/src/scripts/lint_output_slop.ts +223 -0
  72. package/src/scripts/lint_pack_risk_class.ts +79 -0
  73. package/src/scripts/schemas/agent-settings.schema.json +12 -0
  74. package/src/scripts/schemas/skill.schema.json +5 -0
  75. package/dist/ui/assets/index-CoQo90sz.js.map +0 -1
@@ -36,5 +36,5 @@
36
36
  `+e.slice(t,l),t=l+1),o=c;return u+=`
37
37
  `,e.length-t>n&&o>t?u+=e.slice(t,o)+`
38
38
  `+e.slice(o+1):u+=e.slice(t),u.slice(1)}function vc(e){for(var n="",i=0,r,t=0;t<e.length;i>=65536?t+=2:t++)i=Ce(e,t),r=L[i],!r&&Ue(i)?(n+=e[t],i>=65536&&(n+=e[t+1])):n+=r||ac(i);return n}function _c(e,n,i){var r="",t=e.tag,l,o,c;for(l=0,o=i.length;l<o;l+=1)c=i[l],e.replacer&&(c=e.replacer.call(i,String(l),c)),(q(e,n,c,!1,!1)||typeof c>"u"&&q(e,n,null,!1,!1))&&(r!==""&&(r+=","+(e.condenseFlow?"":" ")),r+=e.dump);e.tag=t,e.dump="["+r+"]"}function xr(e,n,i,r){var t="",l=e.tag,o,c,u;for(o=0,c=i.length;o<c;o+=1)u=i[o],e.replacer&&(u=e.replacer.call(i,String(o),u)),(q(e,n+1,u,!0,!0,!1,!0)||typeof u>"u"&&q(e,n+1,null,!0,!0,!1,!0))&&((!r||t!=="")&&(t+=di(e,n)),e.dump&&He===e.dump.charCodeAt(0)?t+="-":t+="- ",t+=e.dump);e.tag=l,e.dump=t||"[]"}function mc(e,n,i){var r="",t=e.tag,l=Object.keys(i),o,c,u,d,f;for(o=0,c=l.length;o<c;o+=1)f="",r!==""&&(f+=", "),e.condenseFlow&&(f+='"'),u=l[o],d=i[u],e.replacer&&(d=e.replacer.call(i,u,d)),q(e,n,u,!1,!1)&&(e.dump.length>1024&&(f+="? "),f+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),q(e,n,d,!1,!1)&&(f+=e.dump,r+=f));e.tag=t,e.dump="{"+r+"}"}function gc(e,n,i,r){var t="",l=e.tag,o=Object.keys(i),c,u,d,f,s,h;if(e.sortKeys===!0)o.sort();else if(typeof e.sortKeys=="function")o.sort(e.sortKeys);else if(e.sortKeys)throw new F("sortKeys must be a boolean or a function");for(c=0,u=o.length;c<u;c+=1)h="",(!r||t!=="")&&(h+=di(e,n)),d=o[c],f=i[d],e.replacer&&(f=e.replacer.call(i,d,f)),q(e,n+1,d,!0,!0,!0)&&(s=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,s&&(e.dump&&He===e.dump.charCodeAt(0)?h+="?":h+="? "),h+=e.dump,s&&(h+=di(e,n)),q(e,n+1,f,!0,s)&&(e.dump&&He===e.dump.charCodeAt(0)?h+=":":h+=": ",h+=e.dump,t+=h));e.tag=l,e.dump=t||"{}"}function Sr(e,n,i){var r,t,l,o,c,u;for(t=i?e.explicitTypes:e.implicitTypes,l=0,o=t.length;l<o;l+=1)if(c=t[l],(c.instanceOf||c.predicate)&&(!c.instanceOf||typeof n=="object"&&n instanceof c.instanceOf)&&(!c.predicate||c.predicate(n))){if(i?c.multi&&c.representName?e.tag=c.representName(n):e.tag=c.tag:e.tag="?",c.represent){if(u=e.styleMap[c.tag]||c.defaultStyle,zt.call(c.represent)==="[object Function]")r=c.represent(n,u);else if(qt.call(c.represent,u))r=c.represent[u](n,u);else throw new F("!<"+c.tag+'> tag resolver accepts not "'+u+'" style');e.dump=r}return!0}return!1}function q(e,n,i,r,t,l,o){e.tag=null,e.dump=i,Sr(e,i,!1)||Sr(e,i,!0);var c=zt.call(e.dump),u=r,d;r&&(r=e.flowLevel<0||e.flowLevel>n);var f=c==="[object Object]"||c==="[object Array]",s,h;if(f&&(s=e.duplicates.indexOf(i),h=s!==-1),(e.tag!==null&&e.tag!=="?"||h||e.indent!==2&&n>0)&&(t=!1),h&&e.usedDuplicates[s])e.dump="*ref_"+s;else{if(f&&h&&!e.usedDuplicates[s]&&(e.usedDuplicates[s]=!0),c==="[object Object]")r&&Object.keys(e.dump).length!==0?(gc(e,n,e.dump,t),h&&(e.dump="&ref_"+s+e.dump)):(mc(e,n,e.dump),h&&(e.dump="&ref_"+s+" "+e.dump));else if(c==="[object Array]")r&&e.dump.length!==0?(e.noArrayIndent&&!o&&n>0?xr(e,n-1,e.dump,t):xr(e,n,e.dump,t),h&&(e.dump="&ref_"+s+e.dump)):(_c(e,n,e.dump),h&&(e.dump="&ref_"+s+" "+e.dump));else if(c==="[object String]")e.tag!=="?"&&pc(e,e.dump,n,l,u);else{if(c==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new F("unacceptable kind of an object to dump "+c)}e.tag!==null&&e.tag!=="?"&&(d=encodeURI(e.tag[0]==="!"?e.tag.slice(1):e.tag).replace(/!/g,"%21"),e.tag[0]==="!"?d="!"+d:d.slice(0,18)==="tag:yaml.org,2002:"?d="!!"+d.slice(18):d="!<"+d+">",e.dump=d+" "+e.dump)}return!0}function yc(e,n){var i=[],r=[],t,l;for(pi(e,i,r),t=0,l=r.length;t<l;t+=1)n.duplicates.push(i[r[t]]);n.usedDuplicates=new Array(l)}function pi(e,n,i){var r,t,l;if(e!==null&&typeof e=="object")if(t=n.indexOf(e),t!==-1)i.indexOf(t)===-1&&i.push(t);else if(n.push(e),Array.isArray(e))for(t=0,l=e.length;t<l;t+=1)pi(e[t],n,i);else for(r=Object.keys(e),t=0,l=r.length;t<l;t+=1)pi(e[r[t]],n,i)}function bc(e,n){n=n||{};var i=new cc(n);i.noRefs||yc(e,i);var r=e;return i.replacer&&(r=i.replacer.call({"":r},"",r)),q(i,0,r,!0,!0)?i.dump+`
39
- `:""}var kc=bc,wc={dump:kc};function $i(e,n){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+n+" instead, which is now safe by default.")}}var xc=N,Sc=_t,Ac=bt,Cc=At,Tc=Ct,Ec=Ii,Oc=Yt.load,Nc=Yt.loadAll,Ic=wc.dump,Lc=F,Fc={binary:It,float:St,map:yt,null:kt,pairs:Ft,set:Rt,timestamp:Ot,bool:wt,int:xt,merge:Nt,omap:Lt,seq:gt,str:mt},Rc=$i("safeLoad","load"),$c=$i("safeLoadAll","loadAll"),Pc=$i("safeDump","dump"),Mc={Type:xc,Schema:Sc,FAILSAFE_SCHEMA:Ac,JSON_SCHEMA:Cc,CORE_SCHEMA:Tc,DEFAULT_SCHEMA:Ec,load:Oc,loadAll:Nc,dump:Ic,YAMLException:Lc,types:Fc,safeLoad:Rc,safeLoadAll:$c,safeDump:Pc};function Dc(e){if(e.trim()==="")return{};const i=Mc.load(e);if(i==null)return{};if(typeof i!="object"||Array.isArray(i))throw new Error(".agent-user.yml must parse to an object");return i}const Ar={id:"welcome",title:"Welcome — who are you?",navLabel:"You",subtitle:"Your name and language. Stored in .agent-user.yml; we pre-fill what we can detect.",kind:"welcome"},Cr={id:"profile",title:"Which experience?",navLabel:"Experience",subtitle:"Pick the experience that fits you — developer · content · founder · agency · finance · ops. It selects your default command/skill surface and persona pre-selection. Cost tier is a secondary knob on a later step. You can switch later with `agent-config use --profile=<id>`.",kind:"form",paths:["profile.id"]},jc=[{id:"ai-tools",title:"Which AI tools do you use?",navLabel:"AI tools",subtitle:"Pick the editors and CLIs that should pick up this config. Auto-detect runs first; you can override.",kind:"aiTools"},{id:"roles",title:"What do you work on?",navLabel:"Roles",subtitle:"Pick the areas you work in. We use them to recommend capability packs on the next step, and they become your roles in .agent-user.yml.",kind:"roles"},{id:"packs",title:"Which capability packs do you want?",navLabel:"Packs",subtitle:"Founder-strategy, finance-basic, gtm-sales, ops-people, ai-video — pick zero or more. You can change this later.",kind:"packs"}],Tr=[{id:"identity",title:"Editor and tooling",navLabel:"Editor",subtitle:"IDE goes into .agent-settings.yml so the agent opens files in the right tool. rtk presence is auto-detected (see the rtk row). Your name lives in .agent-user.yml (later step).",kind:"form",paths:["personal.ide","personal.open_edited_files"]},{id:"personality",title:"How should the agent behave?",navLabel:"Personality",subtitle:"Autonomy, output verbosity, and PR-comment style.",kind:"form",paths:["personal.autonomy","personal.minimal_output","personal.play_by_play","personal.pr_comment_bot_icon"]},{id:"cost",title:"Rule loading, budgets & model tier",navLabel:"Cost & rules",subtitle:"Three distinct levers: rule_loading_tier (how many behavioural rules load — token footprint), cost.budgets (optional USD spending ceilings), and model.auto_switch (per-skill model tier). They are independent — the rule tier is not a spend lever and the model tier is not a rule lever.",kind:"form",paths:["rule_loading_tier","cost.budgets.daily","cost.budgets.weekly","cost.budgets.monthly","cost.enforcement","model.auto_switch"]},{id:"roadmap-quality",title:"Roadmap & quality cadence",navLabel:"Roadmap & quality",subtitle:"When the agent runs quality tools and refreshes roadmap dashboards.",kind:"form",paths:["roadmap.quality_cadence","roadmap.dashboard_regen_cadence","quality.local_auto_run","quality.wait_for_remote_ci"]},{id:"memory",title:"Memory & redaction",navLabel:"Memory",subtitle:"Inline-review threshold and transcript-redaction regexes.",kind:"form",paths:["memory.review_threshold","memory.redact_patterns"]},{id:"user-md",title:"Your .agent-user.yml",navLabel:"User profile",subtitle:"Identity, voice, preferences. Stored at agents/settings/.agent-user.yml. Skip to leave empty.",kind:"userMd"},{id:"review",title:"Review & finish",navLabel:"Review",subtitle:"These keys will change. Confirm to write .agent-settings.yml and .agent-user.yml atomically.",kind:"review"}];function il(e={}){return e.extended===!0?[Ar,Cr,...jc,...Tr]:[Ar,Cr,...Tr]}function Hn(e,n={}){const i=il(n),r=Math.max(0,Math.min(i.length-1,e));return i[r]}function Hc(e,n){const i={type:"object",properties:{},...e.description!==void 0?{description:e.description}:{}},r=i.properties,t=e.properties??{};for(const l of n){const o=l.split(".").filter(H=>H.length>0);if(o.length===0)continue;const[c,u,d]=o;if(c===void 0)continue;const f=t[c];if(f===void 0)continue;if(u===void 0){r[c]=f;continue}const s=f.properties?.[u];if(s===void 0)continue;const p=r[c]??{type:"object",properties:{},...f.description!==void 0?{description:f.description}:{}},_=p.properties??={};if(d===void 0){_[u]=s,r[c]=p;continue}const g=s.properties?.[d];if(g===void 0)continue;const k=_[u]??{type:"object",properties:{},...s.description!==void 0?{description:s.description}:{}},m=k.properties??={};m[d]=g,_[u]=k,r[c]=p}return i}function Bc({current:e,total:n}){const i=Math.max(1,n),r=Math.max(0,Math.min(i-1,e)),t=Array.from({length:i},(o,c)=>c<=r),l=Math.round((r+1)/i*100);return a("div",{class:"ac-wizard__progress",role:"progressbar","aria-valuenow":r+1,"aria-valuemin":1,"aria-valuemax":i,"aria-valuetext":`Step ${r+1} of ${i} (${l}%)`,children:t.map((o,c)=>a("span",{class:`ac-wizard__progress-segment${o?" ac-wizard__progress-segment--filled":""}`,"aria-hidden":"true"},c))})}function Uc({step:e,index:n,total:i}){return a("header",{class:"ac-page__header ac-wizard__header",children:[a("p",{class:"ac-wizard__step-count",children:["Step ",n+1," of ",i]}),a("div",{class:"ac-wizard__header-text",children:[a("h1",{children:e.title}),a("p",{class:"ac-wizard__subtitle",children:e.subtitle})]}),a(Bc,{current:n,total:i})]})}function Wc(e){const n=e.canFinish??!0,i=e.completed??!1;return a("div",{class:"ac-form__actions ac-wizard__nav",children:[a("button",{type:"button",class:"ac-button",disabled:!e.canGoPrev||e.busy,onClick:e.onPrev,children:"Back"}),e.canSkip&&e.onSkip!==void 0?a("button",{type:"button",class:"ac-button ac-wizard__skip",disabled:e.busy,onClick:e.onSkip,children:e.skipLabel??"Skip"}):null,e.isLast?i?null:a("button",{type:"button",class:"ac-button ac-button--primary",disabled:e.busy||!n,onClick:e.onFinish,children:e.busy?"Saving…":"Finish & save"}):a("button",{type:"button",class:"ac-button ac-button--primary",disabled:!e.canGoNext||e.busy,onClick:e.onNext,children:e.nextLabel??"Next"})]})}function rl(e,n){return e.kind!=="form"||e.paths===void 0?!1:!!(e.paths.includes(n)||e.id==="cost"&&(n.startsWith("telegraph.")||n.startsWith("verbosity.")))}function Yc(e,n){return e.kind==="userMd"?n==="body"||n.startsWith("body."):rl(e,n)}function zc(e,n){for(const i of Object.keys(n.errors))if(Yc(e,i))return!0;return!1}function qc(e,n){if(zc(e,n))return{label:"needs attention",tone:"error"};if(e.kind==="userMd")return n.userMdChanged?{label:n.userMdAction==="create"?"will create":"will replace",tone:"changed"}:{label:"",tone:"idle"};if(e.kind==="form"){const i=n.changes.filter(r=>rl(e,r.path)).length;return i===0?{label:"",tone:"idle"}:{label:`${i} change${i===1?"":"s"}`,tone:"changed"}}if(e.kind==="aiTools"){const i=n.selectedToolsCount??0;return i===0?{label:"",tone:"idle"}:{label:`${i} tool${i===1?"":"s"}`,tone:"changed"}}if(e.kind==="packs"){const i=n.selectedPacksCount??0;return i===0?{label:"",tone:"idle"}:{label:`${i} pack${i===1?"":"s"}`,tone:"changed"}}return{label:"",tone:"idle"}}function Kc(e){const n=e.steps.filter((i,r)=>r!==e.currentIndex);return a(Z,{children:a("nav",{class:"ac-wizard__review-nav","aria-label":"Jump back to a step",children:[a("p",{class:"ac-wizard__review-nav-label",children:"Jump back to a step:"}),a("ul",{class:"ac-wizard__review-nav-list",children:n.map(i=>{const r=e.steps.indexOf(i),t=qc(i,e),l=t.tone==="error"?"ac-wizard__review-nav-button ac-wizard__review-nav-button--error":"ac-wizard__review-nav-button";return a("li",{children:a("button",{type:"button",class:l,onClick:()=>{e.onJump(r)},children:[a("span",{class:"ac-wizard__review-nav-index",children:r+1}),a("span",{class:"ac-wizard__review-nav-text",children:i.navLabel}),t.label!==""?a("span",{class:`ac-wizard__review-nav-status ac-wizard__review-nav-status--${t.tone}`,children:t.label}):null]})},i.id)})})]})})}function Gc(e){const n=e.abortedAt??"unknown time",i=e.abortNote??"no further detail recorded",r=e.writesSinceRollback;return a("aside",{class:"ac-banner ac-banner--recovery",role:"alert",children:[a("strong",{children:"Previous install was interrupted."}),a("p",{children:["Aborted at ",a("code",{children:n})," — ",i,". ",r," write",r===1?"":"s"," landed before the abort marker."]}),a("p",{children:"Pick how to recover before continuing. Resume reopens the wizard fresh, Rollback discards the abort state, Ignore hides this banner without touching the log."}),a("div",{class:"ac-banner__actions",children:[a("button",{type:"button",disabled:e.busy,onClick:()=>e.onResume(),children:"Resume install"}),a("button",{type:"button",disabled:e.busy,onClick:()=>e.onRollback(),children:"Rollback"}),a("button",{type:"button",disabled:e.busy,onClick:()=>e.onIgnore(),children:"Ignore"})]})]})}function Vc(){return a("section",{class:"ac-continue-screen","aria-labelledby":"ac-continue-title",children:[a("h2",{id:"ac-continue-title",children:"Install complete — continue with setup?"}),a("p",{children:"Your install selections (AI tools, roles, capability packs) are captured. Use the footer to continue:"}),a("ul",{children:[a("li",{children:[a("strong",{children:"Next"})," — go through the remaining personalisation steps: editor + tooling, personality, cost profile, roadmap & quality, memory, your",a("code",{children:" .agent-user.yml"}),", and finally the project module roots."]}),a("li",{children:[a("strong",{children:"Finish install here"})," — skip the rest and write ",a("code",{children:".agent-settings.yml"})," with the install-only selections. You can re-run ",a("code",{children:"agent-config setup"}),"later to pick up the personalisation steps."]})]})]})}function Jc(e){const n=e.version??"unknown";return a("section",{class:"ac-backup-screen","aria-labelledby":"ac-backup-title",children:[a("h2",{id:"ac-backup-title",children:"Existing v3 install detected"}),a("p",{children:["Found a v3.x install at ",a("code",{children:e.sourcePath})," ","(VERSION: ",a("code",{children:n}),"). v4 is a hard-cut release with no auto-migration — settings, identity, and history layouts changed. The wizard can back up the v3 tree before writing the v4 layout so you can roll back manually if needed."]}),e.error!==null?a("p",{class:"ac-banner ac-banner--error",children:["Backup failed: ",e.error]}):null,a("ul",{children:[a("li",{children:[a("strong",{children:"Backup v3 and proceed"})," — copies the tree to ",a("code",{children:e.backupTarget}),", then runs the v4 install. Restore later with",a("code",{children:[" mv ",e.backupTarget," ",e.sourcePath]}),"."]}),a("li",{children:[a("strong",{children:"Abort, uninstall v3 first"})," — closes the wizard. You decide what to keep."]})]}),a("div",{class:"ac-backup-screen__actions",children:[a("button",{type:"button",class:"ac-button ac-button--primary",disabled:e.busy,onClick:()=>e.onBackupAndProceed(),children:e.busy?"Backing up…":"Backup v3 and proceed"}),a("button",{type:"button",class:"ac-button",disabled:e.busy,onClick:()=>e.onAbort(),children:"Abort, uninstall v3 first"})]})]})}const tl=v(!1),Le=v(null),P=v(null),xn=v(!1),Sn=v(!1),oe=v(0),Pi=v(null),j=v({}),ll=v({}),al=v(0),ye=v({}),E=v(null),ie=v(null),Mi=v(!1),hi=v(!1),Bn=v(!1),ol=v({}),Un=v([]);v("global");const Di=v(!1),D=v(!1),Qc=v(!1),An=v(!1),Cn=v(null),ji=v([]),Tn=v({}),En=v(!0),On=v(""),Nn=v("agents");v(!1);const cl=v(null),Zc=[{id:"claude-code",label:"Claude Code"},{id:"claude-desktop",label:"Claude Desktop"},{id:"cursor",label:"Cursor"},{id:"windsurf",label:"Windsurf"},{id:"cline",label:"Cline"},{id:"gemini-cli",label:"Gemini CLI"},{id:"copilot",label:"GitHub Copilot"},{id:"augment",label:"Augment"},{id:"aider",label:"Aider"},{id:"codex",label:"Codex"},{id:"roocode",label:"Roo Code"},{id:"continue",label:"Continue"},{id:"kilocode",label:"Kilo Code"},{id:"zed",label:"Zed"},{id:"jetbrains",label:"JetBrains"},{id:"kiro",label:"Kiro"},{id:"qoder",label:"Qoder"},{id:"opencode",label:"OpenCode"},{id:"trae",label:"Trae"},{id:"antigravity",label:"Antigravity"},{id:"codebuddy",label:"CodeBuddy"},{id:"droid",label:"Droid"},{id:"warp",label:"Warp"}],Er=v(!1),Fe=v(!1),re=v(null),Hi=v([]),Bi=v([]),Wn=v([]),te=v({}),Or=v(!1),Zn=v(!1),sl=v({}),Nr=v(!1),ul=v(null),dl=v(null),fl=v("https://github.com/event4u-app/rtk");v(!1);v(null);v([]);v({});v({});const ce=v({}),G=v({}),vi=v(!1),Ir=v(!1);v({});v(null);v(null);v(!1);v(null);const In=v(null),pl=v(!1),_i=v(null),mi=v(!1),gi=v(!1),yi=v(null),Re=v(null),an=v(!1);function hl(){return il({extended:D.value})}function We(){return hl().length}function Xc(e){return e??new Date().toISOString()}function Ui(e){return Math.max(0,Math.min(We()-1,e))}function es(e){if("$ref"in e&&e.$ref!==void 0&&"definitions"in e&&e.definitions!==void 0){const n=e.$ref.replace("#/definitions/",""),i=e.definitions[n];if(i!==void 0)return i}return e}async function ns(){try{return await w("/api/v1/settings")}catch(e){if(e instanceof R&&e.status===404&&e.body.error?.code==="NOT_FOUND"){const n=e.body;if(n.defaults!==void 0&&n.schema!==void 0)return{values:n.defaults,lastModified:n.lastModified??0,path:n.path??".agent-settings.yml",schema:n.schema};const i=await w("/api/v1/schema");return{values:{},lastModified:0,path:".agent-settings.yml",schema:i.settings}}throw e}}async function is(){try{const e=await w("/api/v1/install/recovery");In.value=e.incomplete?e:null}catch{In.value=null}}async function rs(){try{const e=await w("/api/v1/install/legacy-v3");_i.value=e.present?e:null}catch{_i.value=null}}async function ts(){gi.value=!0,yi.value=null;try{await w("/api/v1/install/backup-v3",{method:"POST"}),mi.value=!0}catch(e){yi.value=e instanceof R?J(e.body.error??{code:"UNKNOWN",message:e.message}):e instanceof Error?e.message:String(e)}finally{gi.value=!1}}async function Xn(e){try{await w("/api/v1/install/recovery/dismiss",{method:"POST",body:{reason:e}})}catch(n){P.value={message:n instanceof Error?n.message:String(n),tone:"error"};return}In.value=null,pl.value=!0}async function ls(){Le.value=null;try{is(),rs();const[e,n]=await Promise.all([w("/api/v1/wizard/state"),ns()]);Pi.value=es(n.schema),al.value=n.lastModified,ll.value=n.values,ol.value=n.legacyHints??{},D.value=e.extendedSteps===!0,Re.value=e.wizardMode??null;const i=Object.keys(e.partial??{});j.value=i.length>0?{...n.values,...e.partial}:n.values,oe.value=Ui(e.step),Di.value=!1,tl.value=!0;const r=Hn(oe.value,{extended:D.value});(r.kind==="welcome"||r.kind==="userMd"||r.kind==="review")&&vl(),(r.kind==="roles"||r.kind==="aiTools"||r.kind==="packs")&&_l(),r.kind==="aiTools"&&ml(),r.id==="identity"&&gl(),r.kind==="review"&&yl()}catch(e){e instanceof R?Le.value=J(e.body.error??{code:"UNKNOWN",message:e.message}):Le.value=e instanceof Error?e.message:String(e)}}function as(e,n){return e.identity.name.trim()!==""?e:{...e,identity:{...e.identity,name:n}}}async function vl(){if(!hi.value)try{const e=await w("/api/v1/user-md");if(Mi.value=e.exists,e.exists&&e.identity!==null){const n=sr(e.identity);ie.value=n,E.value=n}else{let n;try{const r=await w("/api/v1/user-md/template");n=sr(Dc(r.body))}catch{n=pt()}const i=ol.value.user_name;typeof i=="string"&&i.trim()!==""&&(n=as(n,i)),ie.value=n,E.value=n}}catch(e){P.value={message:e instanceof Error?e.message:String(e),tone:"error"}}finally{hi.value=!0}}const os=new Set(["python"]);async function _l(){if(!(Er.value||Fe.value)){Fe.value=!0,re.value=null;try{const[e,n]=await Promise.all([w("/api/v1/wizard/manifest"),w("/api/v1/wizard/auto-detect")]),i=(e.packs??[]).map(l=>({id:l.id,label:l.label??l.id,description:l.description??"",requires_hint:l.requires_hint,cluster:l.cluster??void 0,workspaces:l.workspaces}));Hi.value=i,Wn.value=(e.workspaces??[]).filter(l=>l.id!=="agent-config-maintainer").map(l=>({id:l.id,label:l.label??l.id,description:l.description??"",default_packs:l.default_packs??[],optional_packs:l.optional_packs??[],...l.example_roles!==void 0?{example_roles:l.example_roles}:{}}));const r=new Set(i.map(l=>l.id)),t=n.signals.map(l=>l.id.startsWith("pack-")?l.id.slice(5):l.id).filter(l=>r.has(l)).filter(l=>!os.has(l));Bi.value=t}catch(e){e instanceof R?re.value=J(e.body.error??{code:"UNKNOWN",message:e.message}):re.value=e instanceof Error?e.message:String(e)}finally{Fe.value=!1,Er.value=!0}}}async function ml(){if(!(Or.value||Zn.value)){Zn.value=!0;try{const e=await w("/api/v1/wizard/detect-tools"),n=e.tools??{},i=e.configured??[];if(sl.value=n,Object.keys(ce.value).length===0){const r={};if(i.length>0)for(const t of i)r[t]=!0;else for(const[t,l]of Object.entries(n))l&&(r[t]=!0);ce.value=r}}catch{}finally{Zn.value=!1,Or.value=!0}}}async function gl(){if(!Nr.value){Nr.value=!0;try{const e=await w("/api/v1/wizard/detect-rtk"),n=e.installed===!0;ul.value=n,dl.value=e.installCommand??null,typeof e.repo=="string"&&(fl.value=e.repo);const i=j.value.personal??{};j.value={...j.value,personal:{...i,rtk_installed:n}}}catch{}}}async function cs(e,n){try{await w("/api/v1/wizard/state",{method:"POST",body:{step:e,totalSteps:We(),partial:n,startedAt:Xc(null)}})}catch(i){P.value={message:i instanceof Error?i.message:String(i),tone:"error"}}}async function yl(){Sn.value=!0;try{const e=await w("/api/v1/settings/diff",{method:"POST",body:{values:j.value,ifUnmodifiedSince:al.value}});Un.value=e.changes,ye.value={}}catch(e){e instanceof R?(ye.value=ct(e.body.error??{message:e.message}),P.value={message:J(e.body.error??{code:"UNKNOWN",message:e.message}),tone:"error"}):P.value={message:e instanceof Error?e.message:String(e),tone:"error"}}finally{Sn.value=!1}}function Ln(){return Bn.value?!1:E.value===null||ie.value===null?E.value!==ie.value:JSON.stringify(E.value)!==JSON.stringify(ie.value)}async function Te(e){const n=Ui(e);await cs(n,j.value),oe.value=n,P.value=null;const i=Hn(n,{extended:D.value});(i.kind==="welcome"||i.kind==="userMd")&&vl(),(i.kind==="roles"||i.kind==="aiTools"||i.kind==="packs")&&_l(),i.kind==="packs"&&kl(),i.kind==="aiTools"&&ml(),i.id==="identity"&&gl(),i.kind==="review"&&yl()}function bl(){const e=G.value,n=new Map(Hi.value.map(l=>[l.id,l])),i=Object.entries(e).filter(([,l])=>l===!0).map(([l])=>l).filter(l=>{const o=n.get(l)?.cluster;return o===void 0||e[o]===!0}),r=new Set,t=l=>{if(!r.has(l)){r.add(l);for(const o of n.get(l)?.requires_hint??[])t(o)}};for(const l of i)t(l);return[...r].sort()}function kl(){if(vi.value)return;const e=Object.entries(te.value).filter(([,r])=>r===!0).map(([r])=>r),n=new Map(Wn.value.map(r=>[r.id,r])),i={};for(const r of e)for(const t of n.get(r)?.default_packs??[])i[t]=!0;for(const r of Bi.value)i[r]=!0;G.value=i}function ss(){const e=Object.entries(ce.value).filter(([,r])=>r===!0).map(([r])=>r);if(e.length===0)return null;const n=bl();return{schema_version:"wizard-v2",tools:e,packs:n,settings:j.value}}async function us(){xn.value=!0,P.value=null;try{const e={settings:j.value},n=Object.entries(te.value).filter(([,u])=>u===!0).map(([u])=>u),i=E.value!==null&&typeof E.value.identity?.name=="string"&&E.value.identity.name.trim().length>0;E.value!==null&&i&&(Ln()||n.length>0)&&(e.identity=n.length>0?{...E.value,role:n}:E.value);const r=await w("/api/v1/wizard/finish",{method:"POST",body:e}),t="You can close this browser window now.",l=r.dryRun===!0?"Dry-run complete — no files written. Settings would be saved.":Array.isArray(r.writtenPaths)?`Saved (${r.writtenPaths.join(", ")}). Wizard complete.`:"Wizard complete.",o=D.value?ss():null;let c="";if(o!==null)try{let u=null;await Ql("/api/v1/wizard/apply",o,s=>{s.type==="error"&&(u=typeof s.message=="string"?s.message:"install failed")});const d=o.tools.length,f=o.packs.length;c=u!==null?` Installer failed: ${u}. Settings were saved; re-run the wizard to retry.`:` Installer applied ${d} tool${d===1?"":"s"}`+(f>0?` and ${f} pack${f===1?"":"s"}.`:".")}catch(u){c=` Installer bridge failed: ${u instanceof R?J(u.body.error??{code:"UNKNOWN",message:u.message}):u instanceof Error?u.message:String(u)}. Settings were saved; re-run the wizard to retry the install plan.`}P.value={message:`${l}${c} ${t}`,tone:"success"},oe.value=Ui(We()-1),ll.value=j.value,ie.value=Ln()?E.value:ie.value,Un.value=[],Di.value=!0}catch(e){e instanceof R?(ye.value=ct(e.body.error??{message:e.message}),P.value={message:J(e.body.error??{code:"UNKNOWN",message:e.message}),tone:"error"}):P.value={message:e instanceof Error?e.message:String(e),tone:"error"}}finally{xn.value=!1}}const ds=["de","en","en-US","en-GB","fr","es","it","nl","pt","pt-BR"];function fs(){if(Ir.value)return;const e=E.value;if(e===null)return;Ir.value=!0;let n=e;if(e.identity.name.trim()===""){const i=_n.value?.systemUser;i!==void 0&&i.trim()!==""&&(n={...n,identity:{...n.identity,name:i}})}if(!Mi.value&&typeof navigator<"u"){const i=(navigator.language||"").split("-")[0];i.length>=2&&(n={...n,language:i})}n!==e&&(E.value=n)}function ps(){const e=E.value;if(Ge(()=>{fs()},[e]),e===null)return a("p",{children:"Loading…"});const n=i=>{E.value={...i,last_updated:new Date().toISOString().slice(0,10)},Bn.value=!1};return a("div",{class:"ac-wizard-step-stub ac-wizard__module-fields",children:[a("p",{children:["Tell the agent who you are. We pre-filled what we could detect — adjust freely. Stored in ",a("code",{children:".agent-user.yml"}),"."]}),a("div",{class:"ac-field",children:[a("label",{class:"ac-field__label",for:"welcome-name",children:"Name"}),a("input",{class:"ac-input",id:"welcome-name",type:"text",placeholder:"How should the agent address you?",value:e.identity.name,onInput:i=>n({...e,identity:{...e.identity,name:i.currentTarget.value}})})]}),a("div",{class:"ac-field",children:[a("label",{class:"ac-field__label",for:"welcome-lang",children:"Language"}),a("input",{class:"ac-input",id:"welcome-lang",type:"text",list:"welcome-lang-list",placeholder:"BCP-47 code, e.g. de, en, en-US",value:e.language,onInput:i=>n({...e,language:i.currentTarget.value})}),a("datalist",{id:"welcome-lang-list",children:ds.map(i=>a("option",{value:i},i))})]})]})}function hs(){const e=ce.value,n=sl.value;return a("div",{class:"ac-wizard-step-stub",children:[a("p",{children:"Pick the AI tools you use. Tools detected on this machine are pre-selected on first run. The installer wires each selected tool's surface (skills, rules, commands) on apply; you can change this list later by re-running the wizard."}),a("ul",{class:"ac-wizard__tool-list",children:Zc.map(i=>{const r=n[i.id]===!0;return a("li",{class:"ac-wizard__tool-row",children:[a("label",{class:"ac-wizard__tool-label",children:[a("input",{type:"checkbox",checked:e[i.id]??!1,onChange:t=>{const l=t.currentTarget.checked;ce.value={...e,[i.id]:l}}})," ",i.label]}),a("span",{class:`ac-badge ${r?"ac-badge--installed":"ac-badge--missing"}`,title:r?"Detected on this machine":"Not detected on this machine",children:r?"installed":"not installed"})]},i.id)})})]})}function vs(){if(Fe.value)return a("p",{children:"Loading roles…"});if(re.value!==null)return a("div",{class:"ac-wizard-step-stub",children:a("p",{class:"ac-banner ac-banner--error",children:["Discovery failed: ",re.value]})});const e=te.value,n=Wn.value,i=(r,t)=>{te.value={...te.value,[r]:t},kl()};return a("div",{class:"ac-wizard-step-stub",children:[a("p",{children:["Pick the areas you work in. We use them to recommend capability packs on the next step, and they become your roles in",a("code",{children:" .agent-user.yml"}),"."]}),n.length===0?a("p",{children:a("em",{children:"No roles available in the manifest."})}):a("div",{class:"ac-wizard__pack-grid",children:n.map(r=>a("section",{class:"ac-pack-tile",children:[a("label",{class:"ac-pack-tile__head",children:[a("input",{type:"checkbox",checked:e[r.id]??!1,onChange:t=>{i(r.id,t.currentTarget.checked)}}),a("span",{class:"ac-pack-tile__title",children:r.label})]}),(r.example_roles??[]).length>0?a("p",{class:"ac-pack-tile__role",children:["e.g. ",(r.example_roles??[]).join(", ")]}):null,r.description!==""?a("p",{class:"ac-pack-tile__desc",children:r.description}):null]},r.id))})]})}function _s(){if(Fe.value)return a("p",{children:"Loading discovery manifest…"});if(re.value!==null)return a("div",{class:"ac-wizard-step-stub",children:[a("p",{class:"ac-banner ac-banner--error",children:["Discovery failed: ",re.value]}),a("p",{children:"The manifest endpoint is gated on extended-mode. Re-run the server with extended steps enabled to populate this list."})]});const e=G.value,n=new Set(Bi.value),i=new Map(Wn.value.map(s=>[s.id,s.label])),r=te.value,t=s=>{const h=(s??[]).filter(p=>p!=="agent-config-maintainer");return h.length===0?null:a("span",{class:"ac-pack-tile__ws",children:h.map(p=>a("span",{class:`ac-badge ac-badge--ws${r[p]===!0?" ac-badge--ws-active":""}`,title:r[p]===!0?"Matches a role you picked":"Workspace / area",children:i.get(p)??p},p))})},l=Hi.value.filter(s=>s.id!=="engineering-base"),o=new Map;for(const s of l)if(s.cluster!==void 0){const h=o.get(s.cluster)??[];h.push(s),o.set(s.cluster,h)}const c=new Set(l.filter(s=>s.cluster!==void 0).map(s=>s.id)),u=l.filter(s=>!c.has(s.id)),d=(s,h)=>{vi.value=!0,G.value={...G.value,[s]:h}},f=(s,h)=>{vi.value=!0;const p={...G.value,[s]:h};if(h)for(const _ of o.get(s)??[])p[_.id]===void 0&&(p[_.id]=!0);G.value=p};return a("div",{class:"ac-wizard-step-stub",children:[a("p",{children:"Pick the capability packs to install. Auto-detected packs are pre-selected; engineering hygiene is included automatically when a pack needs it. A language tile expands to its frameworks — turn the language off to skip them all."}),u.length===0?a("p",{children:a("em",{children:"No packs available in the manifest."})}):a("div",{class:"ac-wizard__pack-grid",children:u.map(s=>{const h=o.get(s.id)??[],p=h.length>0,_=e[s.id]??!1;return a("section",{class:"ac-pack-tile",children:[a("label",{class:"ac-pack-tile__head",children:[a("input",{type:"checkbox",checked:_,onChange:g=>{const b=g.currentTarget.checked;p?f(s.id,b):d(s.id,b)}}),a("span",{class:"ac-pack-tile__title",children:s.label}),n.has(s.id)?a("span",{class:"ac-badge ac-badge--installed",children:"auto-detected"}):null]}),t(s.workspaces),s.description!==""?a("p",{class:"ac-pack-tile__desc",children:s.description}):null,p?a("fieldset",{class:"ac-pack-tile__children",disabled:!_,children:h.map(g=>a("label",{class:"ac-pack-tile__child",children:[a("input",{type:"checkbox",checked:e[g.id]??!1,disabled:!_,onChange:b=>{d(g.id,b.currentTarget.checked)}}),a("span",{children:g.label})]},g.id))}):null]},s.id)})})]})}function ms(){const e=ul.value,n=dl.value;return a("div",{class:"ac-rtk-row",children:[a("div",{class:"ac-rtk-row__head",children:[a("span",{class:"ac-rtk-row__label",children:["rtk ",a("small",{children:"(Rust Token Killer)"})]}),e===null?a("span",{class:"ac-badge ac-badge--missing",children:"detecting…"}):e?a("span",{class:"ac-badge ac-badge--installed",children:"installed"}):a("span",{class:"ac-badge ac-badge--missing",children:"not installed"})]}),e===!1?a("div",{class:"ac-rtk-row__install",children:[a("p",{class:"ac-field__description",children:"rtk wraps verbose CLI output for ~60–90% token savings. Install it, then re-open the wizard to pick up detection:"}),n!==null?a("code",{class:"ac-rtk-row__cmd",children:n}):null,a("a",{class:"ac-button",href:fl.value,target:"_blank",rel:"noreferrer noopener",children:"Open rtk repo"})]}):null]})}function gs(){const e=Hn(oe.value,{extended:D.value});if(D.value&&Re.value==="install"&&e.id==="identity"&&!an.value)return a(Vc,{});if(e.kind==="form"){const i=Hc(Pi.value,e.paths??[]);return a(Z,{children:[e.id==="identity"?a(ms,{}):null,a(sa,{schema:i,values:j.value,errors:ye.value,onChange:r=>{j.value=r}})]})}return e.kind==="userMd"?!hi.value||E.value===null?a("p",{children:"Loading .agent-user.yml…"}):a(pa,{value:E.value,errors:ye.value,hideRole:D.value&&Re.value==="install",hideIdentityBasics:D.value&&Re.value==="install",onChange:i=>{E.value=i,Bn.value=!1}}):e.kind==="welcome"?a(ps,{}):e.kind==="aiTools"?a(hs,{}):e.kind==="roles"?a(vs,{}):e.kind==="packs"?a(_s,{}):a(Kc,{steps:hl(),currentIndex:oe.value,changes:Un.value,errors:ye.value,userMdChanged:Ln(),userMdAction:Mi.value?"replace":"create",loading:Sn.value,onJump:i=>{Te(i)},selectedToolsCount:Object.values(ce.value).filter(Boolean).length,selectedPacksCount:Object.values(G.value).filter(Boolean).length})}function ei({path:e}){if(Ge(()=>{ls()},[]),!tl.value||Pi.value===null)return a("div",{class:"ac-page",children:[a("h1",{children:"Setup wizard"}),Le.value!==null?a("p",{class:"ac-banner ac-banner--error",children:Le.value}):a("p",{children:"Loading…"})]});const n=oe.value,i=We(),r=Hn(n,{extended:D.value}),t=n===i-1,l=r.kind==="aiTools"&&Object.values(ce.value).filter(Boolean).length===0||r.kind==="roles"&&Object.values(te.value).filter(Boolean).length===0||r.kind==="packs"&&bl().length===0,o=D.value&&Re.value==="install"&&r.id==="identity"&&!an.value,c=In.value,u=c!==null&&!pl.value,d=_i.value;return d!==null&&d.present&&!mi.value?a("div",{class:"ac-page",children:a(Jc,{sourcePath:d.path,backupTarget:d.backupTarget,version:d.version,busy:gi.value,error:yi.value,onBackupAndProceed:()=>{ts()},onAbort:()=>{P.value={tone:"info",message:"Aborted. Uninstall v3 manually, then re-run `agent-config install`."},mi.value=!0}})}):a("div",{class:"ac-page",children:[a(Uc,{step:r,index:n,total:i}),u?a(Gc,{abortedAt:c.abortedAt,abortNote:c.abortNote,writesSinceRollback:c.writesSinceRollback,busy:xn.value,onResume:()=>{Xn("resume")},onRollback:()=>{Xn("rollback")},onIgnore:()=>{Xn("ignore")}}):null,P.value!==null?a("p",{class:`ac-banner${P.value.tone==="error"?" ac-banner--error":""}`,children:P.value.message}):null,a("div",{class:"ac-wizard__step",children:a(gs,{})}),l?a("p",{class:"ac-wizard__hint",children:r.kind==="aiTools"?"Select at least one AI tool to continue.":r.kind==="roles"?"Select at least one role to continue.":"Select at least one capability pack to continue."}):null,a(Wc,{canGoPrev:n>0,canGoNext:!t&&!l,canSkip:o||r.kind==="userMd",skipLabel:o?"Finish install here":"Skip",isLast:t,busy:xn.value||Sn.value,canFinish:Un.value.length>0||Ln(),completed:Di.value,onPrev:()=>{Te(n-1)},onNext:()=>{if(o){an.value=!0;return}Te(n+1)},onSkip:()=>{if(o){an.value=!0,Te(We()-1);return}Bn.value=!0,Te(n+1)},onFinish:()=>{us()}})]})}const Fn=v(!1),be=v(null);async function ys(){An.value=!0,Cn.value=null;try{const e=await w("/api/v1/modules/detect");ji.value=e.candidates,cl.value=e.project_root;const n={};for(const i of e.candidates)n[i.path]=!0;Tn.value=n,En.value=e.proposed_block.enabled,On.value=e.proposed_block.namespace_template??"",Nn.value=e.proposed_block.agent_folder??"agents"}catch(e){Cn.value=e instanceof R?J(e.body.error??{code:"UNKNOWN",message:e.message}):e instanceof Error?e.message:String(e)}finally{An.value=!1,Qc.value=!0}}function bs(){const e=new Set(ji.value.map(r=>r.path)),n=Tn.value,i=Object.keys(n).filter(r=>n[r]===!0&&e.has(r));return{enabled:En.value,root_paths:i,namespace_template:On.value,agent_folder:Nn.value||"agents"}}async function ks(){Fn.value=!0,be.value=null;try{const e=await w("/api/v1/modules/apply",{method:"POST",body:bs()});be.value={message:e.appliedTo!==null?`Saved project settings to ${e.appliedTo}.`:`Saved project settings to ${e.projectRoot}.`,tone:"success"}}catch(e){const n=e instanceof R?J(e.body.error??{code:"UNKNOWN",message:e.message}):e instanceof Error?e.message:String(e);be.value={message:`Could not save project settings: ${n}`,tone:"error"}}finally{Fn.value=!1}}function ws(){if(An.value)return a("p",{children:"Detecting module roots…"});if(Cn.value!==null)return a("p",{class:"ac-banner ac-banner--error",children:["Module detection failed: ",Cn.value]});const e=ji.value,n=Tn.value,i=cl.value;return a("div",{class:"ac-section",children:[i!==null?a("p",{class:"ac-section__description",children:["Scanning ",a("code",{children:i}),". Pick which detected roots the agent should treat as modules. These write to",a("code",{children:" .agent-project-settings.yml"})," in this repo only."]}):null,a("label",{children:[a("input",{type:"checkbox",checked:En.value,onChange:r=>{En.value=r.currentTarget.checked}})," ","Enable module discovery (writes ",a("code",{children:"modules.enabled"}),")"]}),e.length===0?a("p",{children:[a("em",{children:"No module roots detected."})," The scan found no common module layouts (Laravel ",a("code",{children:"app/Modules/"}),", Symfony",a("code",{children:" src/Module/"}),", Node ",a("code",{children:"packages/"}),", Python",a("code",{children:" src/"}),", Go ",a("code",{children:"internal/"}),")."]}):a("ul",{style:"list-style: none; padding-left: 0;",children:e.map(r=>a("li",{children:a("label",{children:[a("input",{type:"checkbox",checked:n[r.path]??!1,onChange:t=>{const l=t.currentTarget.checked;Tn.value={...n,[r.path]:l}}})," ",a("code",{children:r.path})," — ",r.stack," ",a("small",{children:["(",r.confidence," confidence)"]})]})},r.path))}),a("div",{class:"ac-wizard__module-fields",children:[a("div",{class:"ac-field",children:[a("label",{class:"ac-field__label",for:"ac-modules-namespace",children:"Namespace template"}),a("input",{id:"ac-modules-namespace",class:"ac-input",type:"text",value:On.value,placeholder:"e.g. App\\\\Modules\\\\{ModuleName}\\\\App",onInput:r=>{On.value=r.currentTarget.value}}),a("span",{class:"ac-field__description",children:"How a module path maps to its namespace. Leave blank to skip namespacing."})]}),a("div",{class:"ac-field",children:[a("label",{class:"ac-field__label",for:"ac-modules-agent-folder",children:"Agent folder"}),a("input",{id:"ac-modules-agent-folder",class:"ac-input",type:"text",value:Nn.value,placeholder:"agents",onInput:r=>{Nn.value=r.currentTarget.value}}),a("span",{class:"ac-field__description",children:["Folder name that holds per-module agent docs (default ",a("code",{children:"agents"}),")."]})]})]})]})}function xs(){return Ge(()=>{ys()},[]),a("div",{class:"ac-page",children:[a("header",{class:"ac-page__header",children:[a("h1",{children:"Project settings"}),a("p",{class:"ac-section__description",children:["Configuration scoped to this repository — written to",a("code",{children:" .agent-project-settings.yml"}),", not the global tree."]})]}),be.value!==null?a("p",{class:`ac-banner ac-banner--${be.value.tone==="success"?"success":"error"}`,children:be.value.message}):null,a("section",{class:"ac-section",children:[a("h2",{class:"ac-section__title",children:"Modules"}),a(ws,{})]}),a("div",{class:"ac-form__actions ac-wizard__nav",children:a("button",{type:"button",class:"ac-button ac-button--primary",disabled:Fn.value||An.value,onClick:()=>{ks()},children:Fn.value?"Saving…":"Save project settings"})})]})}const on=v([]),Ye=v([]),bi=v([]),ki=v([]),Rn=v(null),wl=v(!1),$e=v(null),M=v(null),ni=v("plain"),$n=v({}),xl=v([]),Lr={"claude-code":"Claude Code",codex:"Codex",gemini:"Gemini"};function Ss(){try{return globalThis.sessionStorage?.getItem("ac-workspace-host")??"claude-code"}catch{return"claude-code"}}const Wi=v(Ss());function As(e){Wi.value=e;try{globalThis.sessionStorage?.setItem("ac-workspace-host",e)}catch{}}const ze=v([]),W=v(null),ge=v({}),le=v(!1),qe=v(null),ee=v(""),Pe=v(!1),Yn=v(!1),wi=v(null),ae=v(null),Ke=v([]),cn=v(new Set),Sl="claude-code",Fr=2e3;async function Cs(){$e.value=null;try{const[e,n,i,r,t,l]=await Promise.all([w("/api/v1/workspace/roles"),w("/api/v1/workspace/sessions?limit=20"),w("/api/v1/workspace/knowledge?limit=20"),w("/api/v1/workspace/documents?limit=20"),w("/api/v1/workspace/drive-health").catch(()=>({health:{}})),w("/api/v1/workspace/hosts").catch(()=>({hosts:[]}))]);on.value=e.roles,Ye.value=n.sessions,bi.value=i.chunks,ki.value=r.documents,$n.value=t.health??{},xl.value=l.hosts??[],wl.value=!0}catch(e){e instanceof R?$e.value=e.body?.error?.message??e.message:$e.value=e instanceof Error?e.message:String(e)}}async function Ts(e,n){try{const i=await w(`/api/v1/workspace/roles/${e}/tasks`);ze.value=i.tasks}catch{ze.value=n}}async function Yi(e){ae.value=e,cn.value=new Set;try{const n=await w(`/api/v1/workspace/sessions/${e}`);Ke.value=Array.isArray(n.log)?n.log:[]}catch{Ke.value=[]}}async function Es(e){M.value=null,Yn.value=!1,ee.value="",W.value=null,await Yi(e)}async function Al(e,n,i){M.value=null,le.value=!0,ee.value="",Yn.value=!1,wi.value={role:e,task:n,inputs:i};try{const r=await w("/api/v1/workspace/launch",{method:"POST",body:{role:e,task:n,inputs:i,host:Wi.value}});qe.value=r,M.value=Cl(r),W.value=null,await Yi(r.id);const t=await w("/api/v1/workspace/sessions?limit=20");Ye.value=t.sessions,await zi()}catch(r){qe.value=null,r instanceof R?M.value=r.body?.error?.message??r.message:M.value=r instanceof Error?r.message:String(r)}finally{le.value=!1}}async function Os(e,n){if(!(n.trim()===""||Pe.value)){Pe.value=!0,M.value=null;try{const i=await w(`/api/v1/workspace/sessions/${e}/continue`,{method:"POST",body:{prompt:n}});qe.value=i,M.value=Cl(i),i.driven&&(ee.value=""),await Yi(e);const r=await w("/api/v1/workspace/sessions?limit=20");Ye.value=r.sessions,await zi()}catch(i){i instanceof R&&i.status===410?(Yn.value=!0,M.value="Host session expired — start a new conversation."):i instanceof R?M.value=i.body?.error?.message??i.message:M.value=i instanceof Error?i.message:String(i)}finally{Pe.value=!1}}}async function zi(){try{const e=await w("/api/v1/workspace/drive-health");$n.value=e.health??{}}catch{}}async function Ns(e){try{await w(`/api/v1/workspace/drive-health/${e}/reset`,{method:"POST"}),await zi()}catch{}}function Cl(e){return e.driven?e.recovered===!0?`Host recovered — drove the turn for ${e.role} · ${e.task}.`:`Drove the turn for ${e.role} · ${e.task}.`:e.host_killed===!0?`Host ${Sl} is paused after repeated failures — handed off to the inbox.`:e.error_kind==="render-error"?`Couldn't fill the prompt: ${e.error??"missing input"}.`:e.reason==="no-prompt-for-task"?"Recorded the session — this task has no runnable prompt yet.":typeof e.handoff=="string"?`Prepared a hand-off — open ${e.handoff} and paste it into your host.`:`Recorded the session ${e.id} (${e.role} · ${e.task}).`}function Is({role:e}){const n=Rn.value===e.slug;return a("button",{type:"button",class:`ac-workspace__role${n?" ac-workspace__role--active":""}`,"aria-current":n?"true":void 0,"aria-label":`Pick role ${e.display_name}`,onClick:()=>{Rn.value=e.slug,M.value=null,qe.value=null,W.value=null,ge.value={},ze.value=e.first_tasks,Ts(e.slug,e.first_tasks)},children:[a("span",{class:"ac-workspace__role-name",children:e.display_name}),a("span",{class:"ac-workspace__role-status","data-status":e.status,children:e.status}),a("span",{class:"ac-workspace__role-tagline",children:e.tagline})]})}function Ls({role:e,task:n}){const i=n.inputs??[],r=ge.value,t=i.some(l=>l.required&&(r[l.name]??"").trim()==="");return a("form",{class:"ac-workspace__task-form",onSubmit:l=>{l.preventDefault(),!t&&!le.value&&Al(e,n.name,ge.value)},children:[i.length===0?a("p",{class:"ac-workspace__form-note",children:"No inputs — runs the prompt as-is."}):i.map(l=>a("label",{class:"ac-workspace__field",children:[a("span",{class:"ac-workspace__field-label",children:[l.name,l.required?a("span",{class:"ac-workspace__req","aria-hidden":"true",children:" *"}):null]}),a("textarea",{class:"ac-workspace__field-input",placeholder:l.shape,required:l.required,"aria-label":`${l.name}${l.required?" (required)":""}`,value:r[l.name]??"",onInput:o=>{ge.value={...ge.value,[l.name]:o.target.value}}})]},l.name)),a("div",{class:"ac-workspace__form-actions",children:[a("button",{type:"submit",class:"ac-button ac-button--primary",disabled:t||le.value,children:le.value?"Running…":"Run task"}),a("button",{type:"button",class:"ac-button",onClick:()=>{W.value=null},children:"Cancel"})]})]})}function Fs(e){const n=[];for(const i of e){const r=i.data??{};if(i.kind==="launcher.input")r.followup===!0?n.push({kind:"user",text:typeof r.prompt=="string"?r.prompt:""}):n.push({kind:"task",text:typeof r.task=="string"?r.task:""});else if(i.kind==="host.turn"){const t=r.usage,l=t!=null?`${typeof r.model=="string"?r.model:Sl} · in ${t.input_tokens??0} / out ${t.output_tokens??0} tokens`:void 0;n.push({kind:"assistant",text:typeof r.text=="string"?r.text:"",meta:l})}else if(i.kind==="host.error"){const t=typeof r.error_kind=="string"?r.error_kind:"error";n.push({kind:"error",text:`${t}: ${typeof r.error=="string"?r.error:""}`})}}return n}function Rs(){if(ae.value===null)return null;const e=Fs(Ke.value),n=Ke.value.some(i=>i.kind==="host.turn");return a("section",{class:"ac-workspace__thread","aria-label":"Conversation thread",children:[a("h2",{class:"ac-workspace__heading",children:"Conversation"}),e.length===0?a("p",{class:"ac-workspace__empty",children:"No turns yet."}):a("ol",{class:"ac-workspace__thread-list",children:e.map((i,r)=>{const t=i.kind==="assistant"&&i.text.length>Fr,l=cn.value.has(r),o=t&&!l?`${i.text.slice(0,Fr)}…`:i.text;return a("li",{class:`ac-workspace__thread-block ac-workspace__thread-block--${i.kind}`,children:[a("span",{class:"ac-workspace__thread-role",children:i.kind==="task"?"Task":i.kind==="user"?"You":i.kind==="assistant"?"Host":"Error"}),a("pre",{class:"ac-workspace__thread-text",children:o}),t?a("button",{type:"button",class:"ac-button",onClick:()=>{const c=new Set(cn.value);c.has(r)?c.delete(r):c.add(r),cn.value=c},children:l?"Show less":"Show full"}):null,i.meta!=null?a("p",{class:"ac-workspace__turn-meta",children:i.meta}):null]},r)})}),Yn.value?a("div",{class:"ac-workspace__followup-gone",role:"status",children:[a("p",{children:"Host session expired."}),wi.value!==null?a("button",{type:"button",class:"ac-button ac-button--primary",disabled:le.value,onClick:()=>{const i=wi.value;i!==null&&Al(i.role,i.task,i.inputs)},children:le.value?"Starting…":"Start a new conversation"}):a("p",{children:"Pick a task above to start a new conversation."})]}):n?a("form",{class:"ac-workspace__followup",onSubmit:i=>{i.preventDefault(),ae.value!==null&&Os(ae.value,ee.value)},children:[a("label",{class:"ac-workspace__field",children:[a("span",{class:"ac-workspace__field-label",children:"Follow up"}),a("textarea",{class:"ac-workspace__field-input",placeholder:"Continue this conversation — e.g. make it shorter","aria-label":"Follow-up prompt",value:ee.value,onInput:i=>{ee.value=i.target.value}})]}),a("button",{type:"submit",class:"ac-button ac-button--primary",disabled:ee.value.trim()===""||Pe.value,children:Pe.value?"Continuing…":"Send follow-up"})]}):null]})}function $s({role:e}){const n=ze.value.length>0?ze.value:e.first_tasks;return a("section",{class:"ac-workspace__tasks","aria-labelledby":"task-heading",children:[a("h2",{id:"task-heading",class:"ac-workspace__heading",children:["First tasks · ",e.display_name]}),n.length===0?a("p",{class:"ac-workspace__empty",children:"No tasks scaffolded yet for this role."}):a("ul",{class:"ac-workspace__task-list",children:n.map(i=>a("li",{class:"ac-workspace__task",children:[a("div",{class:"ac-workspace__task-head",children:[a("span",{class:"ac-workspace__task-name",children:i.name}),a("button",{type:"button",class:"ac-button ac-button--primary","aria-expanded":W.value===i.name,onClick:()=>{W.value=W.value===i.name?null:i.name,ge.value={},qe.value=null,ae.value=null,Ke.value=[]},children:W.value===i.name?"Close":"Start session"})]}),a("p",{class:"ac-workspace__task-intent",children:i.intent}),i.prompt!==""?a("code",{class:"ac-workspace__task-prompt",children:["prompts/",i.prompt]}):null,W.value===i.name?a(Ls,{role:e.slug,task:i}):null]},i.name))}),e.skills.length>0?a("details",{class:"ac-workspace__skills",children:[a("summary",{children:["Skill shortlist (",e.skills.length,")"]}),a("ul",{class:"ac-workspace__skill-list",children:[e.skills.slice(0,5).map(i=>a("li",{class:"ac-workspace__skill",children:[a("code",{children:i.id})," — ",i.why]},i.id)),e.skills.length>5?a("li",{class:"ac-workspace__skill-more",children:["+ ",e.skills.length-5," more"]}):null]})]}):null]})}function Ps(){return a("section",{class:"ac-workspace__sessions","aria-labelledby":"sessions-heading",children:[a("h2",{id:"sessions-heading",class:"ac-workspace__heading",children:"Recent sessions"}),Ye.value.length===0?a("p",{class:"ac-workspace__empty",children:"No sessions yet — pick a role and start one."}):a("ul",{class:"ac-workspace__session-list",children:Ye.value.map(e=>a("li",{class:"ac-workspace__session",children:a("button",{type:"button",class:`ac-workspace__session-open${ae.value===e.id?" ac-workspace__session-open--active":""}`,"aria-label":`Open session ${e.task}`,"aria-current":ae.value===e.id?"true":void 0,onClick:()=>{Es(e.id)},children:[a("span",{class:"ac-workspace__session-id",children:e.id.slice(0,16)}),a("span",{class:"ac-workspace__session-role",children:e.role}),a("span",{class:"ac-workspace__session-task",children:e.task})]})},e.id))})]})}function Ms(){return a("section",{class:"ac-workspace__knowledge","aria-labelledby":"knowledge-heading",children:[a("h2",{id:"knowledge-heading",class:"ac-workspace__heading",children:"Knowledge sources"}),bi.value.length===0?a("p",{class:"ac-workspace__empty",children:["No sources yet. Run ",a("code",{children:"/knowledge:ingest <path>"})," to add documents."]}):a("ol",{class:"ac-workspace__citation-list",children:bi.value.map((e,n)=>a("li",{class:"ac-workspace__citation",children:[a("span",{class:"ac-workspace__citation-marker","aria-label":`Citation ${n+1}`,children:["[",n+1,"]"]}),a("a",{href:`file://${e.source}`,class:"ac-workspace__citation-source",title:"Open source in OS default app",children:e.source.split("/").pop()??e.source}),e.pinned?a("span",{class:"ac-workspace__citation-pin","aria-label":"pinned",children:"★"}):null,a("p",{class:"ac-workspace__citation-excerpt",children:[e.excerpt.slice(0,200),e.excerpt.length>200?"…":""]})]},e.id))})]})}function Ds(){return a("section",{class:"ac-workspace__recent","aria-labelledby":"recent-heading",children:[a("h2",{id:"recent-heading",class:"ac-workspace__heading",children:"Recent documents"}),ki.value.length===0?a("p",{class:"ac-workspace__empty",children:"No documents yet. Saved drafts land here."}):a("ul",{class:"ac-workspace__doc-list",children:ki.value.map(e=>a("li",{class:"ac-workspace__doc",children:[a("span",{class:"ac-workspace__doc-type","data-type":e.type,children:e.type}),a("span",{class:"ac-workspace__doc-title",children:e.title}),a("time",{class:"ac-workspace__doc-time",dateTime:e.updated_at,children:e.updated_at.slice(0,10)})]},`${e.type}/${e.slug}`))})]})}function js(){const n=Object.values($n.value).filter(i=>i.killed||i.consecutive_failures>0);return a("section",{class:"ac-workspace__drive-health","aria-labelledby":"drive-health-heading",children:[a("h2",{id:"drive-health-heading",class:"ac-workspace__heading",children:"Host health"}),n.length===0?a("p",{class:"ac-workspace__empty",children:"All hosts healthy."}):a("ul",{class:"ac-workspace__health-list",children:Object.entries($n.value).filter(([,i])=>i.killed||i.consecutive_failures>0).map(([i,r])=>{const t=r.killed?r.kill_reason==="manual"?"paused (manual)":"paused — auto-recovering":"degraded";return a("li",{class:"ac-workspace__health","data-killed":r.killed?"true":"false",children:[a("span",{class:"ac-workspace__health-host",children:i}),a("span",{class:"ac-workspace__health-state",children:t}),a("span",{class:"ac-workspace__health-meta",children:[r.consecutive_failures," fail streak",r.last_error_kind!=null?` · ${r.last_error_kind}`:""]}),r.killed?a("button",{type:"button",class:"ac-button ac-workspace__health-reset","aria-label":`Reset ${i}`,onClick:()=>{Ns(i)},children:"Reset"}):null]},i)})})]})}function Hs(){const e=ni.value;return a("fieldset",{class:"ac-workspace__explain",children:[a("legend",{class:"ac-workspace__heading",children:"Explanation style"}),a("label",{class:"ac-workspace__explain-option",children:[a("input",{type:"radio",name:"explain-mode",value:"plain",checked:e==="plain",onChange:()=>{ni.value="plain"},"aria-label":"Plain language"}),a("span",{children:"Plain language"})]}),a("label",{class:"ac-workspace__explain-option",children:[a("input",{type:"radio",name:"explain-mode",value:"technical",checked:e==="technical",onChange:()=>{ni.value="technical"},"aria-label":"Technical detail"}),a("span",{children:"Technical detail"})]}),a("p",{class:"ac-workspace__explain-hint",children:e==="plain"?"Replies use everyday words. Toggle to see the technical view.":"Replies keep the technical vocabulary. Toggle for the plain view."})]})}function Bs(){const e=xl.value,n=e.length>0?e.map(r=>r.id):Object.keys(Lr),i=new Map(e.map(r=>[r.id,r.cli_present]));return a("label",{class:"ac-workspace__host-picker",children:[a("span",{class:"ac-workspace__host-label",children:"Host"}),a("select",{class:"ac-workspace__host-select","aria-label":"Host agent",value:Wi.value,onChange:r=>{As(r.target.value)},children:n.map(r=>{const t=i.get(r)!==!1,l=Lr[r]??r;return a("option",{value:r,disabled:!t,children:[l," (",r,")",t?"":" — not installed"]},r)})})]})}function Us(){if(Ge(()=>{Cs()},[]),$e.value!==null)return a("div",{class:"ac-page ac-page--error",children:[a("h1",{children:"Workspace"}),a("p",{class:"ac-banner ac-banner--error",children:$e.value})]});if(!wl.value)return a("div",{class:"ac-page",children:[a("h1",{children:"Workspace"}),a("p",{children:"Loading…"})]});const e=Rn.value!==null?on.value.find(n=>n.slug===Rn.value)??null:null;return a("div",{class:"ac-page ac-workspace",children:[a("header",{class:"ac-page__header",children:[a("h1",{children:"Workspace"}),a("p",{class:"ac-page__subtitle",children:"Pick a role, pick a first task, run it."}),a(Bs,{})]}),M.value!==null?a("p",{class:"ac-banner",role:"status",children:M.value}):null,a("div",{class:"ac-workspace__grid",children:[a("section",{class:"ac-workspace__roles","aria-labelledby":"roles-heading",children:[a("h2",{id:"roles-heading",class:"ac-workspace__heading",children:"Roles"}),on.value.length===0?a("p",{class:"ac-workspace__empty",children:"No roles installed."}):a("div",{class:"ac-workspace__role-grid",children:on.value.map(n=>a(Is,{role:n},n.slug))})]}),a("main",{class:"ac-workspace__main","aria-label":"Tasks and sessions",children:[e!==null?a($s,{role:e}):a("p",{class:"ac-workspace__empty",children:"Pick a role on the left to see its first tasks."}),a(Rs,{}),a(Ps,{})]}),a("aside",{class:"ac-workspace__rail","aria-label":"Knowledge and documents",children:[a(Ms,{}),a(Ds,{}),a(js,{}),a(Hs,{})]})]})]})}const Tl=[{id:"setup",label:"Setup",hashPath:"/setup",matches:["/setup","/wizard"]},{id:"project",label:"Projekt",hashPath:"/project",matches:["/project"]},{id:"tasks",label:"Tasks",hashPath:"/tasks",matches:["/tasks"]},{id:"council",label:"Council",hashPath:"/council",matches:["/council"]},{id:"memory",label:"Memory",hashPath:"/memory",matches:["/memory"]},{id:"explain",label:"Explain",hashPath:"/explain",matches:["/explain"]},{id:"workspace",label:"Workspace",hashPath:"/workspace",matches:["/workspace"]}];function Ws(e){for(const n of Tl)for(const i of n.matches)if(e===i||e.startsWith(`${i}/`))return n.id;return null}function Ys(){const e=ve.value,n=Ws(e);return a("header",{class:"ac-topnav",children:a("div",{class:"ac-topnav__inner",children:[a("div",{class:"ac-topnav__brand",children:[a("h1",{class:"ac-topnav__title",children:"@event4u/agent-config"}),a("p",{class:"ac-topnav__subtitle",children:"Browser Wizard"})]}),a("nav",{class:"ac-topnav__tabs","aria-label":"Surfaces",children:Tl.map(i=>a("button",{type:"button",class:`ac-topnav__tab${n===i.id?" ac-topnav__tab--active":""}`,"aria-current":n===i.id?"page":void 0,onClick:()=>ci(i.hashPath),children:i.label},i.id))})]})})}function en({name:e}){return a("div",{class:"ac-page",children:[a("header",{class:"ac-page__header",children:a("h1",{children:e})}),a("section",{class:"ac-section",children:[a("p",{class:"ac-section__description",children:["The ",a("strong",{children:e})," surface is currently served by the legacy installer GUI on port ",a("code",{children:"41100"}),". It is being ported to the modern shell in a follow-up phase (road-to-unified-setup § Phase 5)."]}),a("p",{class:"ac-section__description",children:["For now the legacy surface remains reachable via"," ",a("code",{children:"installer gui"}),"."]})]})]})}function zs({path:e}){return a("div",{class:"ac-page ac-page--error",children:[a("h1",{children:"Page not found"}),a("p",{children:["Nothing routed to ",a("code",{children:e}),". Try ",a("a",{href:"#/setup",children:"Setup"}),"."]})]})}function qs(){const e=_n.value;return e===null||e.dryRun!==!0?null:a("div",{class:"ac-dryrun-banner",role:"status","aria-live":"polite",children:[a("strong",{children:"DRY RUN"}),a("span",{children:" · no files will be written. Validation + rendering run normally; commits return a preview."})]})}function Ks(e){return e==="/"||e==="/setup"||e.startsWith("/setup/")?a(ei,{path:e}):e.startsWith("/wizard")?a(ei,{path:e}):e==="/settings"||e.startsWith("/settings/")?a(ei,{path:"/setup"}):e==="/project"||e.startsWith("/project/")?a(xs,{}):e==="/tasks"?a(en,{name:"Tasks"}):e==="/council"?a(en,{name:"Council"}):e==="/memory"?a(en,{name:"Memory"}):e==="/explain"?a(en,{name:"Explain"}):e==="/workspace"?a(Us,{}):a(zs,{path:e})}function Gs(){return Ge(()=>{Vl(),(ve.value==="/"||ve.value==="/settings"||ve.value.startsWith("/settings/"))&&ci("/setup"),Zl()},[]),a(Z,{children:[a(qs,{}),a(Ys,{}),Ks(ve.value)]})}const Vs=3e4,Js=30*6e4;let nn=null,Rr=!1;function $r(e){if(!Rr&&(Rr=!0,!(typeof navigator>"u"||typeof navigator.sendBeacon!="function")))try{navigator.sendBeacon(`/api/v1/shutdown?token=${encodeURIComponent(e)}`)}catch{}}function Qs(e){if(typeof window>"u")return()=>{};let n=Date.now();const i=()=>{n=Date.now()},r=["pointerdown","keydown","wheel","touchstart"];for(const c of r)window.addEventListener(c,i,{passive:!0});const t=()=>{document.hidden||i()};document.addEventListener("visibilitychange",t);const l=()=>{nn!==null&&clearInterval(nn),nn=null;for(const c of r)window.removeEventListener(c,i);document.removeEventListener("visibilitychange",t),window.removeEventListener("pagehide",o)};nn=setInterval(()=>{if(!document.hidden){if(Date.now()-n>Js){$r(e),l();return}w("/api/v1/ping").catch(()=>{})}},Vs);function o(){$r(e)}return window.addEventListener("pagehide",o),l}function Zs(){return new URLSearchParams(window.location.search).get("token")}function Xs(){const e=document.getElementById("app");if(e===null)return;const n=Zs();if(n===null){e.textContent="agent-config UI · missing token — re-open via `agent-config ui:serve`.";return}Jl(n),Qs(n),e.textContent="",$l(a(Gs,{}),e)}Xs();
40
- //# sourceMappingURL=index-CoQo90sz.js.map
39
+ `:""}var kc=bc,wc={dump:kc};function $i(e,n){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+n+" instead, which is now safe by default.")}}var xc=N,Sc=_t,Ac=bt,Cc=At,Tc=Ct,Ec=Ii,Oc=Yt.load,Nc=Yt.loadAll,Ic=wc.dump,Lc=F,Fc={binary:It,float:St,map:yt,null:kt,pairs:Ft,set:Rt,timestamp:Ot,bool:wt,int:xt,merge:Nt,omap:Lt,seq:gt,str:mt},Rc=$i("safeLoad","load"),$c=$i("safeLoadAll","loadAll"),Pc=$i("safeDump","dump"),Mc={Type:xc,Schema:Sc,FAILSAFE_SCHEMA:Ac,JSON_SCHEMA:Cc,CORE_SCHEMA:Tc,DEFAULT_SCHEMA:Ec,load:Oc,loadAll:Nc,dump:Ic,YAMLException:Lc,types:Fc,safeLoad:Rc,safeLoadAll:$c,safeDump:Pc};function Dc(e){if(e.trim()==="")return{};const i=Mc.load(e);if(i==null)return{};if(typeof i!="object"||Array.isArray(i))throw new Error(".agent-user.yml must parse to an object");return i}const Ar={id:"welcome",title:"Welcome — who are you?",navLabel:"You",subtitle:"Your name and language. Stored in .agent-user.yml; we pre-fill what we can detect.",kind:"welcome"},Cr={id:"profile",title:"Which experience?",navLabel:"Experience",subtitle:"Pick the experience that fits you — developer · content · founder · agency · finance · ops. It selects your default command/skill surface and persona pre-selection. Cost tier is a secondary knob on a later step. You can switch later with `agent-config use --profile=<id>`.",kind:"form",paths:["profile.id"]},jc=[{id:"ai-tools",title:"Which AI tools do you use?",navLabel:"AI tools",subtitle:"Pick the editors and CLIs that should pick up this config. Auto-detect runs first; you can override.",kind:"aiTools"},{id:"roles",title:"What do you work on?",navLabel:"Roles",subtitle:"Pick the areas you work in. We use them to recommend capability packs on the next step, and they become your roles in .agent-user.yml.",kind:"roles"},{id:"packs",title:"Which capability packs do you want?",navLabel:"Packs",subtitle:"Founder-strategy, finance-basic, gtm-sales, ops-people, ai-video — pick zero or more. You can change this later.",kind:"packs"},{id:"legal-consent",title:"Legal review-prep — not legal advice",navLabel:"Legal consent",subtitle:"Only relevant if you picked the legal-review-prep pack. It provides templates and general information, never legal advice — check the box to acknowledge before it activates. Leave unchecked otherwise; the pack stays inactive.",kind:"form",paths:["legal_review_prep.acknowledged"]}],Tr=[{id:"identity",title:"Editor and tooling",navLabel:"Editor",subtitle:"IDE goes into .agent-settings.yml so the agent opens files in the right tool. rtk presence is auto-detected (see the rtk row). Your name lives in .agent-user.yml (later step).",kind:"form",paths:["personal.ide","personal.open_edited_files"]},{id:"personality",title:"How should the agent behave?",navLabel:"Personality",subtitle:"Autonomy, output verbosity, and PR-comment style.",kind:"form",paths:["personal.autonomy","personal.minimal_output","personal.play_by_play","personal.pr_comment_bot_icon"]},{id:"cost",title:"Rule loading, budgets & model tier",navLabel:"Cost & rules",subtitle:"Three distinct levers: rule_loading_tier (how many behavioural rules load — token footprint), cost.budgets (optional USD spending ceilings), and model.auto_switch (per-skill model tier). They are independent — the rule tier is not a spend lever and the model tier is not a rule lever.",kind:"form",paths:["rule_loading_tier","cost.budgets.daily","cost.budgets.weekly","cost.budgets.monthly","cost.enforcement","model.auto_switch","tokens.rich_skills"]},{id:"roadmap-quality",title:"Roadmap & quality cadence",navLabel:"Roadmap & quality",subtitle:"When the agent runs quality tools and refreshes roadmap dashboards.",kind:"form",paths:["roadmap.quality_cadence","roadmap.dashboard_regen_cadence","quality.local_auto_run","quality.wait_for_remote_ci"]},{id:"memory",title:"Memory & redaction",navLabel:"Memory",subtitle:"Inline-review threshold and transcript-redaction regexes.",kind:"form",paths:["memory.review_threshold","memory.redact_patterns"]},{id:"user-md",title:"Your .agent-user.yml",navLabel:"User profile",subtitle:"Identity, voice, preferences. Stored at agents/settings/.agent-user.yml. Skip to leave empty.",kind:"userMd"},{id:"review",title:"Review & finish",navLabel:"Review",subtitle:"These keys will change. Confirm to write .agent-settings.yml and .agent-user.yml atomically.",kind:"review"}];function il(e={}){return e.extended===!0?[Ar,Cr,...jc,...Tr]:[Ar,Cr,...Tr]}function Hn(e,n={}){const i=il(n),r=Math.max(0,Math.min(i.length-1,e));return i[r]}function Hc(e,n){const i={type:"object",properties:{},...e.description!==void 0?{description:e.description}:{}},r=i.properties,t=e.properties??{};for(const l of n){const o=l.split(".").filter(H=>H.length>0);if(o.length===0)continue;const[c,u,d]=o;if(c===void 0)continue;const f=t[c];if(f===void 0)continue;if(u===void 0){r[c]=f;continue}const s=f.properties?.[u];if(s===void 0)continue;const p=r[c]??{type:"object",properties:{},...f.description!==void 0?{description:f.description}:{}},_=p.properties??={};if(d===void 0){_[u]=s,r[c]=p;continue}const g=s.properties?.[d];if(g===void 0)continue;const k=_[u]??{type:"object",properties:{},...s.description!==void 0?{description:s.description}:{}},m=k.properties??={};m[d]=g,_[u]=k,r[c]=p}return i}function Bc({current:e,total:n}){const i=Math.max(1,n),r=Math.max(0,Math.min(i-1,e)),t=Array.from({length:i},(o,c)=>c<=r),l=Math.round((r+1)/i*100);return a("div",{class:"ac-wizard__progress",role:"progressbar","aria-valuenow":r+1,"aria-valuemin":1,"aria-valuemax":i,"aria-valuetext":`Step ${r+1} of ${i} (${l}%)`,children:t.map((o,c)=>a("span",{class:`ac-wizard__progress-segment${o?" ac-wizard__progress-segment--filled":""}`,"aria-hidden":"true"},c))})}function Uc({step:e,index:n,total:i}){return a("header",{class:"ac-page__header ac-wizard__header",children:[a("p",{class:"ac-wizard__step-count",children:["Step ",n+1," of ",i]}),a("div",{class:"ac-wizard__header-text",children:[a("h1",{children:e.title}),a("p",{class:"ac-wizard__subtitle",children:e.subtitle})]}),a(Bc,{current:n,total:i})]})}function Wc(e){const n=e.canFinish??!0,i=e.completed??!1;return a("div",{class:"ac-form__actions ac-wizard__nav",children:[a("button",{type:"button",class:"ac-button",disabled:!e.canGoPrev||e.busy,onClick:e.onPrev,children:"Back"}),e.canSkip&&e.onSkip!==void 0?a("button",{type:"button",class:"ac-button ac-wizard__skip",disabled:e.busy,onClick:e.onSkip,children:e.skipLabel??"Skip"}):null,e.isLast?i?null:a("button",{type:"button",class:"ac-button ac-button--primary",disabled:e.busy||!n,onClick:e.onFinish,children:e.busy?"Saving…":"Finish & save"}):a("button",{type:"button",class:"ac-button ac-button--primary",disabled:!e.canGoNext||e.busy,onClick:e.onNext,children:e.nextLabel??"Next"})]})}function rl(e,n){return e.kind!=="form"||e.paths===void 0?!1:!!(e.paths.includes(n)||e.id==="cost"&&(n.startsWith("telegraph.")||n.startsWith("verbosity.")))}function Yc(e,n){return e.kind==="userMd"?n==="body"||n.startsWith("body."):rl(e,n)}function zc(e,n){for(const i of Object.keys(n.errors))if(Yc(e,i))return!0;return!1}function qc(e,n){if(zc(e,n))return{label:"needs attention",tone:"error"};if(e.kind==="userMd")return n.userMdChanged?{label:n.userMdAction==="create"?"will create":"will replace",tone:"changed"}:{label:"",tone:"idle"};if(e.kind==="form"){const i=n.changes.filter(r=>rl(e,r.path)).length;return i===0?{label:"",tone:"idle"}:{label:`${i} change${i===1?"":"s"}`,tone:"changed"}}if(e.kind==="aiTools"){const i=n.selectedToolsCount??0;return i===0?{label:"",tone:"idle"}:{label:`${i} tool${i===1?"":"s"}`,tone:"changed"}}if(e.kind==="packs"){const i=n.selectedPacksCount??0;return i===0?{label:"",tone:"idle"}:{label:`${i} pack${i===1?"":"s"}`,tone:"changed"}}return{label:"",tone:"idle"}}function Kc(e){const n=e.steps.filter((i,r)=>r!==e.currentIndex);return a(Z,{children:a("nav",{class:"ac-wizard__review-nav","aria-label":"Jump back to a step",children:[a("p",{class:"ac-wizard__review-nav-label",children:"Jump back to a step:"}),a("ul",{class:"ac-wizard__review-nav-list",children:n.map(i=>{const r=e.steps.indexOf(i),t=qc(i,e),l=t.tone==="error"?"ac-wizard__review-nav-button ac-wizard__review-nav-button--error":"ac-wizard__review-nav-button";return a("li",{children:a("button",{type:"button",class:l,onClick:()=>{e.onJump(r)},children:[a("span",{class:"ac-wizard__review-nav-index",children:r+1}),a("span",{class:"ac-wizard__review-nav-text",children:i.navLabel}),t.label!==""?a("span",{class:`ac-wizard__review-nav-status ac-wizard__review-nav-status--${t.tone}`,children:t.label}):null]})},i.id)})})]})})}function Gc(e){const n=e.abortedAt??"unknown time",i=e.abortNote??"no further detail recorded",r=e.writesSinceRollback;return a("aside",{class:"ac-banner ac-banner--recovery",role:"alert",children:[a("strong",{children:"Previous install was interrupted."}),a("p",{children:["Aborted at ",a("code",{children:n})," — ",i,". ",r," write",r===1?"":"s"," landed before the abort marker."]}),a("p",{children:"Pick how to recover before continuing. Resume reopens the wizard fresh, Rollback discards the abort state, Ignore hides this banner without touching the log."}),a("div",{class:"ac-banner__actions",children:[a("button",{type:"button",disabled:e.busy,onClick:()=>e.onResume(),children:"Resume install"}),a("button",{type:"button",disabled:e.busy,onClick:()=>e.onRollback(),children:"Rollback"}),a("button",{type:"button",disabled:e.busy,onClick:()=>e.onIgnore(),children:"Ignore"})]})]})}function Vc(){return a("section",{class:"ac-continue-screen","aria-labelledby":"ac-continue-title",children:[a("h2",{id:"ac-continue-title",children:"Install complete — continue with setup?"}),a("p",{children:"Your install selections (AI tools, roles, capability packs) are captured. Use the footer to continue:"}),a("ul",{children:[a("li",{children:[a("strong",{children:"Next"})," — go through the remaining personalisation steps: editor + tooling, personality, cost profile, roadmap & quality, memory, your",a("code",{children:" .agent-user.yml"}),", and finally the project module roots."]}),a("li",{children:[a("strong",{children:"Finish install here"})," — skip the rest and write ",a("code",{children:".agent-settings.yml"})," with the install-only selections. You can re-run ",a("code",{children:"agent-config setup"}),"later to pick up the personalisation steps."]})]})]})}function Jc(e){const n=e.version??"unknown";return a("section",{class:"ac-backup-screen","aria-labelledby":"ac-backup-title",children:[a("h2",{id:"ac-backup-title",children:"Existing v3 install detected"}),a("p",{children:["Found a v3.x install at ",a("code",{children:e.sourcePath})," ","(VERSION: ",a("code",{children:n}),"). v4 is a hard-cut release with no auto-migration — settings, identity, and history layouts changed. The wizard can back up the v3 tree before writing the v4 layout so you can roll back manually if needed."]}),e.error!==null?a("p",{class:"ac-banner ac-banner--error",children:["Backup failed: ",e.error]}):null,a("ul",{children:[a("li",{children:[a("strong",{children:"Backup v3 and proceed"})," — copies the tree to ",a("code",{children:e.backupTarget}),", then runs the v4 install. Restore later with",a("code",{children:[" mv ",e.backupTarget," ",e.sourcePath]}),"."]}),a("li",{children:[a("strong",{children:"Abort, uninstall v3 first"})," — closes the wizard. You decide what to keep."]})]}),a("div",{class:"ac-backup-screen__actions",children:[a("button",{type:"button",class:"ac-button ac-button--primary",disabled:e.busy,onClick:()=>e.onBackupAndProceed(),children:e.busy?"Backing up…":"Backup v3 and proceed"}),a("button",{type:"button",class:"ac-button",disabled:e.busy,onClick:()=>e.onAbort(),children:"Abort, uninstall v3 first"})]})]})}const tl=v(!1),Le=v(null),P=v(null),xn=v(!1),Sn=v(!1),oe=v(0),Pi=v(null),j=v({}),ll=v({}),al=v(0),ye=v({}),E=v(null),ie=v(null),Mi=v(!1),hi=v(!1),Bn=v(!1),ol=v({}),Un=v([]);v("global");const Di=v(!1),D=v(!1),Qc=v(!1),An=v(!1),Cn=v(null),ji=v([]),Tn=v({}),En=v(!0),On=v(""),Nn=v("agents");v(!1);const cl=v(null),Zc=[{id:"claude-code",label:"Claude Code"},{id:"claude-desktop",label:"Claude Desktop"},{id:"cursor",label:"Cursor"},{id:"windsurf",label:"Windsurf"},{id:"cline",label:"Cline"},{id:"gemini-cli",label:"Gemini CLI"},{id:"copilot",label:"GitHub Copilot"},{id:"augment",label:"Augment"},{id:"aider",label:"Aider"},{id:"codex",label:"Codex"},{id:"roocode",label:"Roo Code"},{id:"continue",label:"Continue"},{id:"kilocode",label:"Kilo Code"},{id:"zed",label:"Zed"},{id:"jetbrains",label:"JetBrains"},{id:"kiro",label:"Kiro"},{id:"qoder",label:"Qoder"},{id:"opencode",label:"OpenCode"},{id:"trae",label:"Trae"},{id:"antigravity",label:"Antigravity"},{id:"codebuddy",label:"CodeBuddy"},{id:"droid",label:"Droid"},{id:"warp",label:"Warp"}],Er=v(!1),Fe=v(!1),re=v(null),Hi=v([]),Bi=v([]),Wn=v([]),te=v({}),Or=v(!1),Zn=v(!1),sl=v({}),Nr=v(!1),ul=v(null),dl=v(null),fl=v("https://github.com/event4u-app/rtk");v(!1);v(null);v([]);v({});v({});const ce=v({}),G=v({}),vi=v(!1),Ir=v(!1);v({});v(null);v(null);v(!1);v(null);const In=v(null),pl=v(!1),_i=v(null),mi=v(!1),gi=v(!1),yi=v(null),Re=v(null),an=v(!1);function hl(){return il({extended:D.value})}function We(){return hl().length}function Xc(e){return e??new Date().toISOString()}function Ui(e){return Math.max(0,Math.min(We()-1,e))}function es(e){if("$ref"in e&&e.$ref!==void 0&&"definitions"in e&&e.definitions!==void 0){const n=e.$ref.replace("#/definitions/",""),i=e.definitions[n];if(i!==void 0)return i}return e}async function ns(){try{return await w("/api/v1/settings")}catch(e){if(e instanceof R&&e.status===404&&e.body.error?.code==="NOT_FOUND"){const n=e.body;if(n.defaults!==void 0&&n.schema!==void 0)return{values:n.defaults,lastModified:n.lastModified??0,path:n.path??".agent-settings.yml",schema:n.schema};const i=await w("/api/v1/schema");return{values:{},lastModified:0,path:".agent-settings.yml",schema:i.settings}}throw e}}async function is(){try{const e=await w("/api/v1/install/recovery");In.value=e.incomplete?e:null}catch{In.value=null}}async function rs(){try{const e=await w("/api/v1/install/legacy-v3");_i.value=e.present?e:null}catch{_i.value=null}}async function ts(){gi.value=!0,yi.value=null;try{await w("/api/v1/install/backup-v3",{method:"POST"}),mi.value=!0}catch(e){yi.value=e instanceof R?J(e.body.error??{code:"UNKNOWN",message:e.message}):e instanceof Error?e.message:String(e)}finally{gi.value=!1}}async function Xn(e){try{await w("/api/v1/install/recovery/dismiss",{method:"POST",body:{reason:e}})}catch(n){P.value={message:n instanceof Error?n.message:String(n),tone:"error"};return}In.value=null,pl.value=!0}async function ls(){Le.value=null;try{is(),rs();const[e,n]=await Promise.all([w("/api/v1/wizard/state"),ns()]);Pi.value=es(n.schema),al.value=n.lastModified,ll.value=n.values,ol.value=n.legacyHints??{},D.value=e.extendedSteps===!0,Re.value=e.wizardMode??null;const i=Object.keys(e.partial??{});j.value=i.length>0?{...n.values,...e.partial}:n.values,oe.value=Ui(e.step),Di.value=!1,tl.value=!0;const r=Hn(oe.value,{extended:D.value});(r.kind==="welcome"||r.kind==="userMd"||r.kind==="review")&&vl(),(r.kind==="roles"||r.kind==="aiTools"||r.kind==="packs")&&_l(),r.kind==="aiTools"&&ml(),r.id==="identity"&&gl(),r.kind==="review"&&yl()}catch(e){e instanceof R?Le.value=J(e.body.error??{code:"UNKNOWN",message:e.message}):Le.value=e instanceof Error?e.message:String(e)}}function as(e,n){return e.identity.name.trim()!==""?e:{...e,identity:{...e.identity,name:n}}}async function vl(){if(!hi.value)try{const e=await w("/api/v1/user-md");if(Mi.value=e.exists,e.exists&&e.identity!==null){const n=sr(e.identity);ie.value=n,E.value=n}else{let n;try{const r=await w("/api/v1/user-md/template");n=sr(Dc(r.body))}catch{n=pt()}const i=ol.value.user_name;typeof i=="string"&&i.trim()!==""&&(n=as(n,i)),ie.value=n,E.value=n}}catch(e){P.value={message:e instanceof Error?e.message:String(e),tone:"error"}}finally{hi.value=!0}}const os=new Set(["python"]);async function _l(){if(!(Er.value||Fe.value)){Fe.value=!0,re.value=null;try{const[e,n]=await Promise.all([w("/api/v1/wizard/manifest"),w("/api/v1/wizard/auto-detect")]),i=(e.packs??[]).map(l=>({id:l.id,label:l.label??l.id,description:l.description??"",requires_hint:l.requires_hint,cluster:l.cluster??void 0,workspaces:l.workspaces}));Hi.value=i,Wn.value=(e.workspaces??[]).filter(l=>l.id!=="agent-config-maintainer").map(l=>({id:l.id,label:l.label??l.id,description:l.description??"",default_packs:l.default_packs??[],optional_packs:l.optional_packs??[],...l.example_roles!==void 0?{example_roles:l.example_roles}:{}}));const r=new Set(i.map(l=>l.id)),t=n.signals.map(l=>l.id.startsWith("pack-")?l.id.slice(5):l.id).filter(l=>r.has(l)).filter(l=>!os.has(l));Bi.value=t}catch(e){e instanceof R?re.value=J(e.body.error??{code:"UNKNOWN",message:e.message}):re.value=e instanceof Error?e.message:String(e)}finally{Fe.value=!1,Er.value=!0}}}async function ml(){if(!(Or.value||Zn.value)){Zn.value=!0;try{const e=await w("/api/v1/wizard/detect-tools"),n=e.tools??{},i=e.configured??[];if(sl.value=n,Object.keys(ce.value).length===0){const r={};if(i.length>0)for(const t of i)r[t]=!0;else for(const[t,l]of Object.entries(n))l&&(r[t]=!0);ce.value=r}}catch{}finally{Zn.value=!1,Or.value=!0}}}async function gl(){if(!Nr.value){Nr.value=!0;try{const e=await w("/api/v1/wizard/detect-rtk"),n=e.installed===!0;ul.value=n,dl.value=e.installCommand??null,typeof e.repo=="string"&&(fl.value=e.repo);const i=j.value.personal??{};j.value={...j.value,personal:{...i,rtk_installed:n}}}catch{}}}async function cs(e,n){try{await w("/api/v1/wizard/state",{method:"POST",body:{step:e,totalSteps:We(),partial:n,startedAt:Xc(null)}})}catch(i){P.value={message:i instanceof Error?i.message:String(i),tone:"error"}}}async function yl(){Sn.value=!0;try{const e=await w("/api/v1/settings/diff",{method:"POST",body:{values:j.value,ifUnmodifiedSince:al.value}});Un.value=e.changes,ye.value={}}catch(e){e instanceof R?(ye.value=ct(e.body.error??{message:e.message}),P.value={message:J(e.body.error??{code:"UNKNOWN",message:e.message}),tone:"error"}):P.value={message:e instanceof Error?e.message:String(e),tone:"error"}}finally{Sn.value=!1}}function Ln(){return Bn.value?!1:E.value===null||ie.value===null?E.value!==ie.value:JSON.stringify(E.value)!==JSON.stringify(ie.value)}async function Te(e){const n=Ui(e);await cs(n,j.value),oe.value=n,P.value=null;const i=Hn(n,{extended:D.value});(i.kind==="welcome"||i.kind==="userMd")&&vl(),(i.kind==="roles"||i.kind==="aiTools"||i.kind==="packs")&&_l(),i.kind==="packs"&&kl(),i.kind==="aiTools"&&ml(),i.id==="identity"&&gl(),i.kind==="review"&&yl()}function bl(){const e=G.value,n=new Map(Hi.value.map(l=>[l.id,l])),i=Object.entries(e).filter(([,l])=>l===!0).map(([l])=>l).filter(l=>{const o=n.get(l)?.cluster;return o===void 0||e[o]===!0}),r=new Set,t=l=>{if(!r.has(l)){r.add(l);for(const o of n.get(l)?.requires_hint??[])t(o)}};for(const l of i)t(l);return[...r].sort()}function kl(){if(vi.value)return;const e=Object.entries(te.value).filter(([,r])=>r===!0).map(([r])=>r),n=new Map(Wn.value.map(r=>[r.id,r])),i={};for(const r of e)for(const t of n.get(r)?.default_packs??[])i[t]=!0;for(const r of Bi.value)i[r]=!0;G.value=i}function ss(){const e=Object.entries(ce.value).filter(([,r])=>r===!0).map(([r])=>r);if(e.length===0)return null;const n=bl();return{schema_version:"wizard-v2",tools:e,packs:n,settings:j.value}}async function us(){xn.value=!0,P.value=null;try{const e={settings:j.value},n=Object.entries(te.value).filter(([,u])=>u===!0).map(([u])=>u),i=E.value!==null&&typeof E.value.identity?.name=="string"&&E.value.identity.name.trim().length>0;E.value!==null&&i&&(Ln()||n.length>0)&&(e.identity=n.length>0?{...E.value,role:n}:E.value);const r=await w("/api/v1/wizard/finish",{method:"POST",body:e}),t="You can close this browser window now.",l=r.dryRun===!0?"Dry-run complete — no files written. Settings would be saved.":Array.isArray(r.writtenPaths)?`Saved (${r.writtenPaths.join(", ")}). Wizard complete.`:"Wizard complete.",o=D.value?ss():null;let c="";if(o!==null)try{let u=null;await Ql("/api/v1/wizard/apply",o,s=>{s.type==="error"&&(u=typeof s.message=="string"?s.message:"install failed")});const d=o.tools.length,f=o.packs.length;c=u!==null?` Installer failed: ${u}. Settings were saved; re-run the wizard to retry.`:` Installer applied ${d} tool${d===1?"":"s"}`+(f>0?` and ${f} pack${f===1?"":"s"}.`:".")}catch(u){c=` Installer bridge failed: ${u instanceof R?J(u.body.error??{code:"UNKNOWN",message:u.message}):u instanceof Error?u.message:String(u)}. Settings were saved; re-run the wizard to retry the install plan.`}P.value={message:`${l}${c} ${t}`,tone:"success"},oe.value=Ui(We()-1),ll.value=j.value,ie.value=Ln()?E.value:ie.value,Un.value=[],Di.value=!0}catch(e){e instanceof R?(ye.value=ct(e.body.error??{message:e.message}),P.value={message:J(e.body.error??{code:"UNKNOWN",message:e.message}),tone:"error"}):P.value={message:e instanceof Error?e.message:String(e),tone:"error"}}finally{xn.value=!1}}const ds=["de","en","en-US","en-GB","fr","es","it","nl","pt","pt-BR"];function fs(){if(Ir.value)return;const e=E.value;if(e===null)return;Ir.value=!0;let n=e;if(e.identity.name.trim()===""){const i=_n.value?.systemUser;i!==void 0&&i.trim()!==""&&(n={...n,identity:{...n.identity,name:i}})}if(!Mi.value&&typeof navigator<"u"){const i=(navigator.language||"").split("-")[0];i.length>=2&&(n={...n,language:i})}n!==e&&(E.value=n)}function ps(){const e=E.value;if(Ge(()=>{fs()},[e]),e===null)return a("p",{children:"Loading…"});const n=i=>{E.value={...i,last_updated:new Date().toISOString().slice(0,10)},Bn.value=!1};return a("div",{class:"ac-wizard-step-stub ac-wizard__module-fields",children:[a("p",{children:["Tell the agent who you are. We pre-filled what we could detect — adjust freely. Stored in ",a("code",{children:".agent-user.yml"}),"."]}),a("div",{class:"ac-field",children:[a("label",{class:"ac-field__label",for:"welcome-name",children:"Name"}),a("input",{class:"ac-input",id:"welcome-name",type:"text",placeholder:"How should the agent address you?",value:e.identity.name,onInput:i=>n({...e,identity:{...e.identity,name:i.currentTarget.value}})})]}),a("div",{class:"ac-field",children:[a("label",{class:"ac-field__label",for:"welcome-lang",children:"Language"}),a("input",{class:"ac-input",id:"welcome-lang",type:"text",list:"welcome-lang-list",placeholder:"BCP-47 code, e.g. de, en, en-US",value:e.language,onInput:i=>n({...e,language:i.currentTarget.value})}),a("datalist",{id:"welcome-lang-list",children:ds.map(i=>a("option",{value:i},i))})]})]})}function hs(){const e=ce.value,n=sl.value;return a("div",{class:"ac-wizard-step-stub",children:[a("p",{children:"Pick the AI tools you use. Tools detected on this machine are pre-selected on first run. The installer wires each selected tool's surface (skills, rules, commands) on apply; you can change this list later by re-running the wizard."}),a("ul",{class:"ac-wizard__tool-list",children:Zc.map(i=>{const r=n[i.id]===!0;return a("li",{class:"ac-wizard__tool-row",children:[a("label",{class:"ac-wizard__tool-label",children:[a("input",{type:"checkbox",checked:e[i.id]??!1,onChange:t=>{const l=t.currentTarget.checked;ce.value={...e,[i.id]:l}}})," ",i.label]}),a("span",{class:`ac-badge ${r?"ac-badge--installed":"ac-badge--missing"}`,title:r?"Detected on this machine":"Not detected on this machine",children:r?"installed":"not installed"})]},i.id)})})]})}function vs(){if(Fe.value)return a("p",{children:"Loading roles…"});if(re.value!==null)return a("div",{class:"ac-wizard-step-stub",children:a("p",{class:"ac-banner ac-banner--error",children:["Discovery failed: ",re.value]})});const e=te.value,n=Wn.value,i=(r,t)=>{te.value={...te.value,[r]:t},kl()};return a("div",{class:"ac-wizard-step-stub",children:[a("p",{children:["Pick the areas you work in. We use them to recommend capability packs on the next step, and they become your roles in",a("code",{children:" .agent-user.yml"}),"."]}),n.length===0?a("p",{children:a("em",{children:"No roles available in the manifest."})}):a("div",{class:"ac-wizard__pack-grid",children:n.map(r=>a("section",{class:"ac-pack-tile",children:[a("label",{class:"ac-pack-tile__head",children:[a("input",{type:"checkbox",checked:e[r.id]??!1,onChange:t=>{i(r.id,t.currentTarget.checked)}}),a("span",{class:"ac-pack-tile__title",children:r.label})]}),(r.example_roles??[]).length>0?a("p",{class:"ac-pack-tile__role",children:["e.g. ",(r.example_roles??[]).join(", ")]}):null,r.description!==""?a("p",{class:"ac-pack-tile__desc",children:r.description}):null]},r.id))})]})}function _s(){if(Fe.value)return a("p",{children:"Loading discovery manifest…"});if(re.value!==null)return a("div",{class:"ac-wizard-step-stub",children:[a("p",{class:"ac-banner ac-banner--error",children:["Discovery failed: ",re.value]}),a("p",{children:"The manifest endpoint is gated on extended-mode. Re-run the server with extended steps enabled to populate this list."})]});const e=G.value,n=new Set(Bi.value),i=new Map(Wn.value.map(s=>[s.id,s.label])),r=te.value,t=s=>{const h=(s??[]).filter(p=>p!=="agent-config-maintainer");return h.length===0?null:a("span",{class:"ac-pack-tile__ws",children:h.map(p=>a("span",{class:`ac-badge ac-badge--ws${r[p]===!0?" ac-badge--ws-active":""}`,title:r[p]===!0?"Matches a role you picked":"Workspace / area",children:i.get(p)??p},p))})},l=Hi.value.filter(s=>s.id!=="engineering-base"),o=new Map;for(const s of l)if(s.cluster!==void 0){const h=o.get(s.cluster)??[];h.push(s),o.set(s.cluster,h)}const c=new Set(l.filter(s=>s.cluster!==void 0).map(s=>s.id)),u=l.filter(s=>!c.has(s.id)),d=(s,h)=>{vi.value=!0,G.value={...G.value,[s]:h}},f=(s,h)=>{vi.value=!0;const p={...G.value,[s]:h};if(h)for(const _ of o.get(s)??[])p[_.id]===void 0&&(p[_.id]=!0);G.value=p};return a("div",{class:"ac-wizard-step-stub",children:[a("p",{children:"Pick the capability packs to install. Auto-detected packs are pre-selected; engineering hygiene is included automatically when a pack needs it. A language tile expands to its frameworks — turn the language off to skip them all."}),u.length===0?a("p",{children:a("em",{children:"No packs available in the manifest."})}):a("div",{class:"ac-wizard__pack-grid",children:u.map(s=>{const h=o.get(s.id)??[],p=h.length>0,_=e[s.id]??!1;return a("section",{class:"ac-pack-tile",children:[a("label",{class:"ac-pack-tile__head",children:[a("input",{type:"checkbox",checked:_,onChange:g=>{const b=g.currentTarget.checked;p?f(s.id,b):d(s.id,b)}}),a("span",{class:"ac-pack-tile__title",children:s.label}),n.has(s.id)?a("span",{class:"ac-badge ac-badge--installed",children:"auto-detected"}):null]}),t(s.workspaces),s.description!==""?a("p",{class:"ac-pack-tile__desc",children:s.description}):null,p?a("fieldset",{class:"ac-pack-tile__children",disabled:!_,children:h.map(g=>a("label",{class:"ac-pack-tile__child",children:[a("input",{type:"checkbox",checked:e[g.id]??!1,disabled:!_,onChange:b=>{d(g.id,b.currentTarget.checked)}}),a("span",{children:g.label})]},g.id))}):null]},s.id)})})]})}function ms(){const e=ul.value,n=dl.value;return a("div",{class:"ac-rtk-row",children:[a("div",{class:"ac-rtk-row__head",children:[a("span",{class:"ac-rtk-row__label",children:["rtk ",a("small",{children:"(Rust Token Killer)"})]}),e===null?a("span",{class:"ac-badge ac-badge--missing",children:"detecting…"}):e?a("span",{class:"ac-badge ac-badge--installed",children:"installed"}):a("span",{class:"ac-badge ac-badge--missing",children:"not installed"})]}),e===!1?a("div",{class:"ac-rtk-row__install",children:[a("p",{class:"ac-field__description",children:"rtk wraps verbose CLI output for ~60–90% token savings. Install it, then re-open the wizard to pick up detection:"}),n!==null?a("code",{class:"ac-rtk-row__cmd",children:n}):null,a("a",{class:"ac-button",href:fl.value,target:"_blank",rel:"noreferrer noopener",children:"Open rtk repo"})]}):null]})}function gs(){const e=Hn(oe.value,{extended:D.value});if(D.value&&Re.value==="install"&&e.id==="identity"&&!an.value)return a(Vc,{});if(e.kind==="form"){const i=Hc(Pi.value,e.paths??[]);return a(Z,{children:[e.id==="identity"?a(ms,{}):null,a(sa,{schema:i,values:j.value,errors:ye.value,onChange:r=>{j.value=r}})]})}return e.kind==="userMd"?!hi.value||E.value===null?a("p",{children:"Loading .agent-user.yml…"}):a(pa,{value:E.value,errors:ye.value,hideRole:D.value&&Re.value==="install",hideIdentityBasics:D.value&&Re.value==="install",onChange:i=>{E.value=i,Bn.value=!1}}):e.kind==="welcome"?a(ps,{}):e.kind==="aiTools"?a(hs,{}):e.kind==="roles"?a(vs,{}):e.kind==="packs"?a(_s,{}):a(Kc,{steps:hl(),currentIndex:oe.value,changes:Un.value,errors:ye.value,userMdChanged:Ln(),userMdAction:Mi.value?"replace":"create",loading:Sn.value,onJump:i=>{Te(i)},selectedToolsCount:Object.values(ce.value).filter(Boolean).length,selectedPacksCount:Object.values(G.value).filter(Boolean).length})}function ei({path:e}){if(Ge(()=>{ls()},[]),!tl.value||Pi.value===null)return a("div",{class:"ac-page",children:[a("h1",{children:"Setup wizard"}),Le.value!==null?a("p",{class:"ac-banner ac-banner--error",children:Le.value}):a("p",{children:"Loading…"})]});const n=oe.value,i=We(),r=Hn(n,{extended:D.value}),t=n===i-1,l=r.kind==="aiTools"&&Object.values(ce.value).filter(Boolean).length===0||r.kind==="roles"&&Object.values(te.value).filter(Boolean).length===0||r.kind==="packs"&&bl().length===0,o=D.value&&Re.value==="install"&&r.id==="identity"&&!an.value,c=In.value,u=c!==null&&!pl.value,d=_i.value;return d!==null&&d.present&&!mi.value?a("div",{class:"ac-page",children:a(Jc,{sourcePath:d.path,backupTarget:d.backupTarget,version:d.version,busy:gi.value,error:yi.value,onBackupAndProceed:()=>{ts()},onAbort:()=>{P.value={tone:"info",message:"Aborted. Uninstall v3 manually, then re-run `agent-config install`."},mi.value=!0}})}):a("div",{class:"ac-page",children:[a(Uc,{step:r,index:n,total:i}),u?a(Gc,{abortedAt:c.abortedAt,abortNote:c.abortNote,writesSinceRollback:c.writesSinceRollback,busy:xn.value,onResume:()=>{Xn("resume")},onRollback:()=>{Xn("rollback")},onIgnore:()=>{Xn("ignore")}}):null,P.value!==null?a("p",{class:`ac-banner${P.value.tone==="error"?" ac-banner--error":""}`,children:P.value.message}):null,a("div",{class:"ac-wizard__step",children:a(gs,{})}),l?a("p",{class:"ac-wizard__hint",children:r.kind==="aiTools"?"Select at least one AI tool to continue.":r.kind==="roles"?"Select at least one role to continue.":"Select at least one capability pack to continue."}):null,a(Wc,{canGoPrev:n>0,canGoNext:!t&&!l,canSkip:o||r.kind==="userMd",skipLabel:o?"Finish install here":"Skip",isLast:t,busy:xn.value||Sn.value,canFinish:Un.value.length>0||Ln(),completed:Di.value,onPrev:()=>{Te(n-1)},onNext:()=>{if(o){an.value=!0;return}Te(n+1)},onSkip:()=>{if(o){an.value=!0,Te(We()-1);return}Bn.value=!0,Te(n+1)},onFinish:()=>{us()}})]})}const Fn=v(!1),be=v(null);async function ys(){An.value=!0,Cn.value=null;try{const e=await w("/api/v1/modules/detect");ji.value=e.candidates,cl.value=e.project_root;const n={};for(const i of e.candidates)n[i.path]=!0;Tn.value=n,En.value=e.proposed_block.enabled,On.value=e.proposed_block.namespace_template??"",Nn.value=e.proposed_block.agent_folder??"agents"}catch(e){Cn.value=e instanceof R?J(e.body.error??{code:"UNKNOWN",message:e.message}):e instanceof Error?e.message:String(e)}finally{An.value=!1,Qc.value=!0}}function bs(){const e=new Set(ji.value.map(r=>r.path)),n=Tn.value,i=Object.keys(n).filter(r=>n[r]===!0&&e.has(r));return{enabled:En.value,root_paths:i,namespace_template:On.value,agent_folder:Nn.value||"agents"}}async function ks(){Fn.value=!0,be.value=null;try{const e=await w("/api/v1/modules/apply",{method:"POST",body:bs()});be.value={message:e.appliedTo!==null?`Saved project settings to ${e.appliedTo}.`:`Saved project settings to ${e.projectRoot}.`,tone:"success"}}catch(e){const n=e instanceof R?J(e.body.error??{code:"UNKNOWN",message:e.message}):e instanceof Error?e.message:String(e);be.value={message:`Could not save project settings: ${n}`,tone:"error"}}finally{Fn.value=!1}}function ws(){if(An.value)return a("p",{children:"Detecting module roots…"});if(Cn.value!==null)return a("p",{class:"ac-banner ac-banner--error",children:["Module detection failed: ",Cn.value]});const e=ji.value,n=Tn.value,i=cl.value;return a("div",{class:"ac-section",children:[i!==null?a("p",{class:"ac-section__description",children:["Scanning ",a("code",{children:i}),". Pick which detected roots the agent should treat as modules. These write to",a("code",{children:" .agent-project-settings.yml"})," in this repo only."]}):null,a("label",{children:[a("input",{type:"checkbox",checked:En.value,onChange:r=>{En.value=r.currentTarget.checked}})," ","Enable module discovery (writes ",a("code",{children:"modules.enabled"}),")"]}),e.length===0?a("p",{children:[a("em",{children:"No module roots detected."})," The scan found no common module layouts (Laravel ",a("code",{children:"app/Modules/"}),", Symfony",a("code",{children:" src/Module/"}),", Node ",a("code",{children:"packages/"}),", Python",a("code",{children:" src/"}),", Go ",a("code",{children:"internal/"}),")."]}):a("ul",{style:"list-style: none; padding-left: 0;",children:e.map(r=>a("li",{children:a("label",{children:[a("input",{type:"checkbox",checked:n[r.path]??!1,onChange:t=>{const l=t.currentTarget.checked;Tn.value={...n,[r.path]:l}}})," ",a("code",{children:r.path})," — ",r.stack," ",a("small",{children:["(",r.confidence," confidence)"]})]})},r.path))}),a("div",{class:"ac-wizard__module-fields",children:[a("div",{class:"ac-field",children:[a("label",{class:"ac-field__label",for:"ac-modules-namespace",children:"Namespace template"}),a("input",{id:"ac-modules-namespace",class:"ac-input",type:"text",value:On.value,placeholder:"e.g. App\\\\Modules\\\\{ModuleName}\\\\App",onInput:r=>{On.value=r.currentTarget.value}}),a("span",{class:"ac-field__description",children:"How a module path maps to its namespace. Leave blank to skip namespacing."})]}),a("div",{class:"ac-field",children:[a("label",{class:"ac-field__label",for:"ac-modules-agent-folder",children:"Agent folder"}),a("input",{id:"ac-modules-agent-folder",class:"ac-input",type:"text",value:Nn.value,placeholder:"agents",onInput:r=>{Nn.value=r.currentTarget.value}}),a("span",{class:"ac-field__description",children:["Folder name that holds per-module agent docs (default ",a("code",{children:"agents"}),")."]})]})]})]})}function xs(){return Ge(()=>{ys()},[]),a("div",{class:"ac-page",children:[a("header",{class:"ac-page__header",children:[a("h1",{children:"Project settings"}),a("p",{class:"ac-section__description",children:["Configuration scoped to this repository — written to",a("code",{children:" .agent-project-settings.yml"}),", not the global tree."]})]}),be.value!==null?a("p",{class:`ac-banner ac-banner--${be.value.tone==="success"?"success":"error"}`,children:be.value.message}):null,a("section",{class:"ac-section",children:[a("h2",{class:"ac-section__title",children:"Modules"}),a(ws,{})]}),a("div",{class:"ac-form__actions ac-wizard__nav",children:a("button",{type:"button",class:"ac-button ac-button--primary",disabled:Fn.value||An.value,onClick:()=>{ks()},children:Fn.value?"Saving…":"Save project settings"})})]})}const on=v([]),Ye=v([]),bi=v([]),ki=v([]),Rn=v(null),wl=v(!1),$e=v(null),M=v(null),ni=v("plain"),$n=v({}),xl=v([]),Lr={"claude-code":"Claude Code",codex:"Codex",gemini:"Gemini"};function Ss(){try{return globalThis.sessionStorage?.getItem("ac-workspace-host")??"claude-code"}catch{return"claude-code"}}const Wi=v(Ss());function As(e){Wi.value=e;try{globalThis.sessionStorage?.setItem("ac-workspace-host",e)}catch{}}const ze=v([]),W=v(null),ge=v({}),le=v(!1),qe=v(null),ee=v(""),Pe=v(!1),Yn=v(!1),wi=v(null),ae=v(null),Ke=v([]),cn=v(new Set),Sl="claude-code",Fr=2e3;async function Cs(){$e.value=null;try{const[e,n,i,r,t,l]=await Promise.all([w("/api/v1/workspace/roles"),w("/api/v1/workspace/sessions?limit=20"),w("/api/v1/workspace/knowledge?limit=20"),w("/api/v1/workspace/documents?limit=20"),w("/api/v1/workspace/drive-health").catch(()=>({health:{}})),w("/api/v1/workspace/hosts").catch(()=>({hosts:[]}))]);on.value=e.roles,Ye.value=n.sessions,bi.value=i.chunks,ki.value=r.documents,$n.value=t.health??{},xl.value=l.hosts??[],wl.value=!0}catch(e){e instanceof R?$e.value=e.body?.error?.message??e.message:$e.value=e instanceof Error?e.message:String(e)}}async function Ts(e,n){try{const i=await w(`/api/v1/workspace/roles/${e}/tasks`);ze.value=i.tasks}catch{ze.value=n}}async function Yi(e){ae.value=e,cn.value=new Set;try{const n=await w(`/api/v1/workspace/sessions/${e}`);Ke.value=Array.isArray(n.log)?n.log:[]}catch{Ke.value=[]}}async function Es(e){M.value=null,Yn.value=!1,ee.value="",W.value=null,await Yi(e)}async function Al(e,n,i){M.value=null,le.value=!0,ee.value="",Yn.value=!1,wi.value={role:e,task:n,inputs:i};try{const r=await w("/api/v1/workspace/launch",{method:"POST",body:{role:e,task:n,inputs:i,host:Wi.value}});qe.value=r,M.value=Cl(r),W.value=null,await Yi(r.id);const t=await w("/api/v1/workspace/sessions?limit=20");Ye.value=t.sessions,await zi()}catch(r){qe.value=null,r instanceof R?M.value=r.body?.error?.message??r.message:M.value=r instanceof Error?r.message:String(r)}finally{le.value=!1}}async function Os(e,n){if(!(n.trim()===""||Pe.value)){Pe.value=!0,M.value=null;try{const i=await w(`/api/v1/workspace/sessions/${e}/continue`,{method:"POST",body:{prompt:n}});qe.value=i,M.value=Cl(i),i.driven&&(ee.value=""),await Yi(e);const r=await w("/api/v1/workspace/sessions?limit=20");Ye.value=r.sessions,await zi()}catch(i){i instanceof R&&i.status===410?(Yn.value=!0,M.value="Host session expired — start a new conversation."):i instanceof R?M.value=i.body?.error?.message??i.message:M.value=i instanceof Error?i.message:String(i)}finally{Pe.value=!1}}}async function zi(){try{const e=await w("/api/v1/workspace/drive-health");$n.value=e.health??{}}catch{}}async function Ns(e){try{await w(`/api/v1/workspace/drive-health/${e}/reset`,{method:"POST"}),await zi()}catch{}}function Cl(e){return e.driven?e.recovered===!0?`Host recovered — drove the turn for ${e.role} · ${e.task}.`:`Drove the turn for ${e.role} · ${e.task}.`:e.host_killed===!0?`Host ${Sl} is paused after repeated failures — handed off to the inbox.`:e.error_kind==="render-error"?`Couldn't fill the prompt: ${e.error??"missing input"}.`:e.reason==="no-prompt-for-task"?"Recorded the session — this task has no runnable prompt yet.":typeof e.handoff=="string"?`Prepared a hand-off — open ${e.handoff} and paste it into your host.`:`Recorded the session ${e.id} (${e.role} · ${e.task}).`}function Is({role:e}){const n=Rn.value===e.slug;return a("button",{type:"button",class:`ac-workspace__role${n?" ac-workspace__role--active":""}`,"aria-current":n?"true":void 0,"aria-label":`Pick role ${e.display_name}`,onClick:()=>{Rn.value=e.slug,M.value=null,qe.value=null,W.value=null,ge.value={},ze.value=e.first_tasks,Ts(e.slug,e.first_tasks)},children:[a("span",{class:"ac-workspace__role-name",children:e.display_name}),a("span",{class:"ac-workspace__role-status","data-status":e.status,children:e.status}),a("span",{class:"ac-workspace__role-tagline",children:e.tagline})]})}function Ls({role:e,task:n}){const i=n.inputs??[],r=ge.value,t=i.some(l=>l.required&&(r[l.name]??"").trim()==="");return a("form",{class:"ac-workspace__task-form",onSubmit:l=>{l.preventDefault(),!t&&!le.value&&Al(e,n.name,ge.value)},children:[i.length===0?a("p",{class:"ac-workspace__form-note",children:"No inputs — runs the prompt as-is."}):i.map(l=>a("label",{class:"ac-workspace__field",children:[a("span",{class:"ac-workspace__field-label",children:[l.name,l.required?a("span",{class:"ac-workspace__req","aria-hidden":"true",children:" *"}):null]}),a("textarea",{class:"ac-workspace__field-input",placeholder:l.shape,required:l.required,"aria-label":`${l.name}${l.required?" (required)":""}`,value:r[l.name]??"",onInput:o=>{ge.value={...ge.value,[l.name]:o.target.value}}})]},l.name)),a("div",{class:"ac-workspace__form-actions",children:[a("button",{type:"submit",class:"ac-button ac-button--primary",disabled:t||le.value,children:le.value?"Running…":"Run task"}),a("button",{type:"button",class:"ac-button",onClick:()=>{W.value=null},children:"Cancel"})]})]})}function Fs(e){const n=[];for(const i of e){const r=i.data??{};if(i.kind==="launcher.input")r.followup===!0?n.push({kind:"user",text:typeof r.prompt=="string"?r.prompt:""}):n.push({kind:"task",text:typeof r.task=="string"?r.task:""});else if(i.kind==="host.turn"){const t=r.usage,l=t!=null?`${typeof r.model=="string"?r.model:Sl} · in ${t.input_tokens??0} / out ${t.output_tokens??0} tokens`:void 0;n.push({kind:"assistant",text:typeof r.text=="string"?r.text:"",meta:l})}else if(i.kind==="host.error"){const t=typeof r.error_kind=="string"?r.error_kind:"error";n.push({kind:"error",text:`${t}: ${typeof r.error=="string"?r.error:""}`})}}return n}function Rs(){if(ae.value===null)return null;const e=Fs(Ke.value),n=Ke.value.some(i=>i.kind==="host.turn");return a("section",{class:"ac-workspace__thread","aria-label":"Conversation thread",children:[a("h2",{class:"ac-workspace__heading",children:"Conversation"}),e.length===0?a("p",{class:"ac-workspace__empty",children:"No turns yet."}):a("ol",{class:"ac-workspace__thread-list",children:e.map((i,r)=>{const t=i.kind==="assistant"&&i.text.length>Fr,l=cn.value.has(r),o=t&&!l?`${i.text.slice(0,Fr)}…`:i.text;return a("li",{class:`ac-workspace__thread-block ac-workspace__thread-block--${i.kind}`,children:[a("span",{class:"ac-workspace__thread-role",children:i.kind==="task"?"Task":i.kind==="user"?"You":i.kind==="assistant"?"Host":"Error"}),a("pre",{class:"ac-workspace__thread-text",children:o}),t?a("button",{type:"button",class:"ac-button",onClick:()=>{const c=new Set(cn.value);c.has(r)?c.delete(r):c.add(r),cn.value=c},children:l?"Show less":"Show full"}):null,i.meta!=null?a("p",{class:"ac-workspace__turn-meta",children:i.meta}):null]},r)})}),Yn.value?a("div",{class:"ac-workspace__followup-gone",role:"status",children:[a("p",{children:"Host session expired."}),wi.value!==null?a("button",{type:"button",class:"ac-button ac-button--primary",disabled:le.value,onClick:()=>{const i=wi.value;i!==null&&Al(i.role,i.task,i.inputs)},children:le.value?"Starting…":"Start a new conversation"}):a("p",{children:"Pick a task above to start a new conversation."})]}):n?a("form",{class:"ac-workspace__followup",onSubmit:i=>{i.preventDefault(),ae.value!==null&&Os(ae.value,ee.value)},children:[a("label",{class:"ac-workspace__field",children:[a("span",{class:"ac-workspace__field-label",children:"Follow up"}),a("textarea",{class:"ac-workspace__field-input",placeholder:"Continue this conversation — e.g. make it shorter","aria-label":"Follow-up prompt",value:ee.value,onInput:i=>{ee.value=i.target.value}})]}),a("button",{type:"submit",class:"ac-button ac-button--primary",disabled:ee.value.trim()===""||Pe.value,children:Pe.value?"Continuing…":"Send follow-up"})]}):null]})}function $s({role:e}){const n=ze.value.length>0?ze.value:e.first_tasks;return a("section",{class:"ac-workspace__tasks","aria-labelledby":"task-heading",children:[a("h2",{id:"task-heading",class:"ac-workspace__heading",children:["First tasks · ",e.display_name]}),n.length===0?a("p",{class:"ac-workspace__empty",children:"No tasks scaffolded yet for this role."}):a("ul",{class:"ac-workspace__task-list",children:n.map(i=>a("li",{class:"ac-workspace__task",children:[a("div",{class:"ac-workspace__task-head",children:[a("span",{class:"ac-workspace__task-name",children:i.name}),a("button",{type:"button",class:"ac-button ac-button--primary","aria-expanded":W.value===i.name,onClick:()=>{W.value=W.value===i.name?null:i.name,ge.value={},qe.value=null,ae.value=null,Ke.value=[]},children:W.value===i.name?"Close":"Start session"})]}),a("p",{class:"ac-workspace__task-intent",children:i.intent}),i.prompt!==""?a("code",{class:"ac-workspace__task-prompt",children:["prompts/",i.prompt]}):null,W.value===i.name?a(Ls,{role:e.slug,task:i}):null]},i.name))}),e.skills.length>0?a("details",{class:"ac-workspace__skills",children:[a("summary",{children:["Skill shortlist (",e.skills.length,")"]}),a("ul",{class:"ac-workspace__skill-list",children:[e.skills.slice(0,5).map(i=>a("li",{class:"ac-workspace__skill",children:[a("code",{children:i.id})," — ",i.why]},i.id)),e.skills.length>5?a("li",{class:"ac-workspace__skill-more",children:["+ ",e.skills.length-5," more"]}):null]})]}):null]})}function Ps(){return a("section",{class:"ac-workspace__sessions","aria-labelledby":"sessions-heading",children:[a("h2",{id:"sessions-heading",class:"ac-workspace__heading",children:"Recent sessions"}),Ye.value.length===0?a("p",{class:"ac-workspace__empty",children:"No sessions yet — pick a role and start one."}):a("ul",{class:"ac-workspace__session-list",children:Ye.value.map(e=>a("li",{class:"ac-workspace__session",children:a("button",{type:"button",class:`ac-workspace__session-open${ae.value===e.id?" ac-workspace__session-open--active":""}`,"aria-label":`Open session ${e.task}`,"aria-current":ae.value===e.id?"true":void 0,onClick:()=>{Es(e.id)},children:[a("span",{class:"ac-workspace__session-id",children:e.id.slice(0,16)}),a("span",{class:"ac-workspace__session-role",children:e.role}),a("span",{class:"ac-workspace__session-task",children:e.task})]})},e.id))})]})}function Ms(){return a("section",{class:"ac-workspace__knowledge","aria-labelledby":"knowledge-heading",children:[a("h2",{id:"knowledge-heading",class:"ac-workspace__heading",children:"Knowledge sources"}),bi.value.length===0?a("p",{class:"ac-workspace__empty",children:["No sources yet. Run ",a("code",{children:"/knowledge:ingest <path>"})," to add documents."]}):a("ol",{class:"ac-workspace__citation-list",children:bi.value.map((e,n)=>a("li",{class:"ac-workspace__citation",children:[a("span",{class:"ac-workspace__citation-marker","aria-label":`Citation ${n+1}`,children:["[",n+1,"]"]}),a("a",{href:`file://${e.source}`,class:"ac-workspace__citation-source",title:"Open source in OS default app",children:e.source.split("/").pop()??e.source}),e.pinned?a("span",{class:"ac-workspace__citation-pin","aria-label":"pinned",children:"★"}):null,a("p",{class:"ac-workspace__citation-excerpt",children:[e.excerpt.slice(0,200),e.excerpt.length>200?"…":""]})]},e.id))})]})}function Ds(){return a("section",{class:"ac-workspace__recent","aria-labelledby":"recent-heading",children:[a("h2",{id:"recent-heading",class:"ac-workspace__heading",children:"Recent documents"}),ki.value.length===0?a("p",{class:"ac-workspace__empty",children:"No documents yet. Saved drafts land here."}):a("ul",{class:"ac-workspace__doc-list",children:ki.value.map(e=>a("li",{class:"ac-workspace__doc",children:[a("span",{class:"ac-workspace__doc-type","data-type":e.type,children:e.type}),a("span",{class:"ac-workspace__doc-title",children:e.title}),a("time",{class:"ac-workspace__doc-time",dateTime:e.updated_at,children:e.updated_at.slice(0,10)})]},`${e.type}/${e.slug}`))})]})}function js(){const n=Object.values($n.value).filter(i=>i.killed||i.consecutive_failures>0);return a("section",{class:"ac-workspace__drive-health","aria-labelledby":"drive-health-heading",children:[a("h2",{id:"drive-health-heading",class:"ac-workspace__heading",children:"Host health"}),n.length===0?a("p",{class:"ac-workspace__empty",children:"All hosts healthy."}):a("ul",{class:"ac-workspace__health-list",children:Object.entries($n.value).filter(([,i])=>i.killed||i.consecutive_failures>0).map(([i,r])=>{const t=r.killed?r.kill_reason==="manual"?"paused (manual)":"paused — auto-recovering":"degraded";return a("li",{class:"ac-workspace__health","data-killed":r.killed?"true":"false",children:[a("span",{class:"ac-workspace__health-host",children:i}),a("span",{class:"ac-workspace__health-state",children:t}),a("span",{class:"ac-workspace__health-meta",children:[r.consecutive_failures," fail streak",r.last_error_kind!=null?` · ${r.last_error_kind}`:""]}),r.killed?a("button",{type:"button",class:"ac-button ac-workspace__health-reset","aria-label":`Reset ${i}`,onClick:()=>{Ns(i)},children:"Reset"}):null]},i)})})]})}function Hs(){const e=ni.value;return a("fieldset",{class:"ac-workspace__explain",children:[a("legend",{class:"ac-workspace__heading",children:"Explanation style"}),a("label",{class:"ac-workspace__explain-option",children:[a("input",{type:"radio",name:"explain-mode",value:"plain",checked:e==="plain",onChange:()=>{ni.value="plain"},"aria-label":"Plain language"}),a("span",{children:"Plain language"})]}),a("label",{class:"ac-workspace__explain-option",children:[a("input",{type:"radio",name:"explain-mode",value:"technical",checked:e==="technical",onChange:()=>{ni.value="technical"},"aria-label":"Technical detail"}),a("span",{children:"Technical detail"})]}),a("p",{class:"ac-workspace__explain-hint",children:e==="plain"?"Replies use everyday words. Toggle to see the technical view.":"Replies keep the technical vocabulary. Toggle for the plain view."})]})}function Bs(){const e=xl.value,n=e.length>0?e.map(r=>r.id):Object.keys(Lr),i=new Map(e.map(r=>[r.id,r.cli_present]));return a("label",{class:"ac-workspace__host-picker",children:[a("span",{class:"ac-workspace__host-label",children:"Host"}),a("select",{class:"ac-workspace__host-select","aria-label":"Host agent",value:Wi.value,onChange:r=>{As(r.target.value)},children:n.map(r=>{const t=i.get(r)!==!1,l=Lr[r]??r;return a("option",{value:r,disabled:!t,children:[l," (",r,")",t?"":" — not installed"]},r)})})]})}function Us(){if(Ge(()=>{Cs()},[]),$e.value!==null)return a("div",{class:"ac-page ac-page--error",children:[a("h1",{children:"Workspace"}),a("p",{class:"ac-banner ac-banner--error",children:$e.value})]});if(!wl.value)return a("div",{class:"ac-page",children:[a("h1",{children:"Workspace"}),a("p",{children:"Loading…"})]});const e=Rn.value!==null?on.value.find(n=>n.slug===Rn.value)??null:null;return a("div",{class:"ac-page ac-workspace",children:[a("header",{class:"ac-page__header",children:[a("h1",{children:"Workspace"}),a("p",{class:"ac-page__subtitle",children:"Pick a role, pick a first task, run it."}),a(Bs,{})]}),M.value!==null?a("p",{class:"ac-banner",role:"status",children:M.value}):null,a("div",{class:"ac-workspace__grid",children:[a("section",{class:"ac-workspace__roles","aria-labelledby":"roles-heading",children:[a("h2",{id:"roles-heading",class:"ac-workspace__heading",children:"Roles"}),on.value.length===0?a("p",{class:"ac-workspace__empty",children:"No roles installed."}):a("div",{class:"ac-workspace__role-grid",children:on.value.map(n=>a(Is,{role:n},n.slug))})]}),a("main",{class:"ac-workspace__main","aria-label":"Tasks and sessions",children:[e!==null?a($s,{role:e}):a("p",{class:"ac-workspace__empty",children:"Pick a role on the left to see its first tasks."}),a(Rs,{}),a(Ps,{})]}),a("aside",{class:"ac-workspace__rail","aria-label":"Knowledge and documents",children:[a(Ms,{}),a(Ds,{}),a(js,{}),a(Hs,{})]})]})]})}const Tl=[{id:"setup",label:"Setup",hashPath:"/setup",matches:["/setup","/wizard"]},{id:"project",label:"Projekt",hashPath:"/project",matches:["/project"]},{id:"tasks",label:"Tasks",hashPath:"/tasks",matches:["/tasks"]},{id:"council",label:"Council",hashPath:"/council",matches:["/council"]},{id:"memory",label:"Memory",hashPath:"/memory",matches:["/memory"]},{id:"explain",label:"Explain",hashPath:"/explain",matches:["/explain"]},{id:"workspace",label:"Workspace",hashPath:"/workspace",matches:["/workspace"]}];function Ws(e){for(const n of Tl)for(const i of n.matches)if(e===i||e.startsWith(`${i}/`))return n.id;return null}function Ys(){const e=ve.value,n=Ws(e);return a("header",{class:"ac-topnav",children:a("div",{class:"ac-topnav__inner",children:[a("div",{class:"ac-topnav__brand",children:[a("h1",{class:"ac-topnav__title",children:"@event4u/agent-config"}),a("p",{class:"ac-topnav__subtitle",children:"Browser Wizard"})]}),a("nav",{class:"ac-topnav__tabs","aria-label":"Surfaces",children:Tl.map(i=>a("button",{type:"button",class:`ac-topnav__tab${n===i.id?" ac-topnav__tab--active":""}`,"aria-current":n===i.id?"page":void 0,onClick:()=>ci(i.hashPath),children:i.label},i.id))})]})})}function en({name:e}){return a("div",{class:"ac-page",children:[a("header",{class:"ac-page__header",children:a("h1",{children:e})}),a("section",{class:"ac-section",children:[a("p",{class:"ac-section__description",children:["The ",a("strong",{children:e})," surface is currently served by the legacy installer GUI on port ",a("code",{children:"41100"}),". It is being ported to the modern shell in a follow-up phase (road-to-unified-setup § Phase 5)."]}),a("p",{class:"ac-section__description",children:["For now the legacy surface remains reachable via"," ",a("code",{children:"installer gui"}),"."]})]})]})}function zs({path:e}){return a("div",{class:"ac-page ac-page--error",children:[a("h1",{children:"Page not found"}),a("p",{children:["Nothing routed to ",a("code",{children:e}),". Try ",a("a",{href:"#/setup",children:"Setup"}),"."]})]})}function qs(){const e=_n.value;return e===null||e.dryRun!==!0?null:a("div",{class:"ac-dryrun-banner",role:"status","aria-live":"polite",children:[a("strong",{children:"DRY RUN"}),a("span",{children:" · no files will be written. Validation + rendering run normally; commits return a preview."})]})}function Ks(e){return e==="/"||e==="/setup"||e.startsWith("/setup/")?a(ei,{path:e}):e.startsWith("/wizard")?a(ei,{path:e}):e==="/settings"||e.startsWith("/settings/")?a(ei,{path:"/setup"}):e==="/project"||e.startsWith("/project/")?a(xs,{}):e==="/tasks"?a(en,{name:"Tasks"}):e==="/council"?a(en,{name:"Council"}):e==="/memory"?a(en,{name:"Memory"}):e==="/explain"?a(en,{name:"Explain"}):e==="/workspace"?a(Us,{}):a(zs,{path:e})}function Gs(){return Ge(()=>{Vl(),(ve.value==="/"||ve.value==="/settings"||ve.value.startsWith("/settings/"))&&ci("/setup"),Zl()},[]),a(Z,{children:[a(qs,{}),a(Ys,{}),Ks(ve.value)]})}const Vs=3e4,Js=30*6e4;let nn=null,Rr=!1;function $r(e){if(!Rr&&(Rr=!0,!(typeof navigator>"u"||typeof navigator.sendBeacon!="function")))try{navigator.sendBeacon(`/api/v1/shutdown?token=${encodeURIComponent(e)}`)}catch{}}function Qs(e){if(typeof window>"u")return()=>{};let n=Date.now();const i=()=>{n=Date.now()},r=["pointerdown","keydown","wheel","touchstart"];for(const c of r)window.addEventListener(c,i,{passive:!0});const t=()=>{document.hidden||i()};document.addEventListener("visibilitychange",t);const l=()=>{nn!==null&&clearInterval(nn),nn=null;for(const c of r)window.removeEventListener(c,i);document.removeEventListener("visibilitychange",t),window.removeEventListener("pagehide",o)};nn=setInterval(()=>{if(!document.hidden){if(Date.now()-n>Js){$r(e),l();return}w("/api/v1/ping").catch(()=>{})}},Vs);function o(){$r(e)}return window.addEventListener("pagehide",o),l}function Zs(){return new URLSearchParams(window.location.search).get("token")}function Xs(){const e=document.getElementById("app");if(e===null)return;const n=Zs();if(n===null){e.textContent="agent-config UI · missing token — re-open via `agent-config ui:serve`.";return}Jl(n),Qs(n),e.textContent="",$l(a(Gs,{}),e)}Xs();
40
+ //# sourceMappingURL=index-UjcTG_9O.js.map