bazilion 0.16.0 → 0.18.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 (128) hide show
  1. package/dist/cli.js +672 -87
  2. package/dist/cli.js.map +1 -1
  3. package/dist/daemon.js +3759 -432
  4. package/dist/daemon.js.map +1 -1
  5. package/dist/migrations/0001_init.sql +169 -0
  6. package/dist/web/client/assets/ChatPane-CAYS_fIQ.js +76 -0
  7. package/dist/web/client/assets/ConfirmDialog-BzIiABOP.js +1 -0
  8. package/dist/web/client/assets/{FieldRow-DJ2Gx4Du.js → FieldRow-W_54rw5c.js} +1 -1
  9. package/dist/web/client/assets/ProductionTeamPolicyEditor-DNXVX8Lz.js +7 -0
  10. package/dist/web/client/assets/ProfileCommunicationEditor-DN0fOzqn.js +1 -0
  11. package/dist/web/client/assets/{ResultSourceConversation-CtzJ8QA-.js → ResultSourceConversation-DoU4tOWc.js} +1 -1
  12. package/dist/web/client/assets/TeamTabs-BmTZRI4T.js +1 -0
  13. package/dist/web/client/assets/TemplatesTabs-Bs_OXKwx.js +1 -0
  14. package/dist/web/client/assets/{UnsavedChangesGuard-BCsLw-mU.js → UnsavedChangesGuard-CPRtFReU.js} +1 -1
  15. package/dist/web/client/assets/{_id-DxopIW-y.js → _id-CxAB4TDr.js} +1 -1
  16. package/dist/web/client/assets/_id-DL4tJFQB.js +1 -0
  17. package/dist/web/client/assets/{_id-BEDmIXVf.js → _id-DR9eFC17.js} +1 -1
  18. package/dist/web/client/assets/{_id-BFM_tn_s.js → _id-Dbmei5tg.js} +1 -1
  19. package/dist/web/client/assets/{_id-B5Ov7cdO.js → _id-ybF-pqmr.js} +1 -1
  20. package/dist/web/client/assets/activity-oUyy77jD.js +1 -0
  21. package/dist/web/client/assets/{agents-CMPOFcs-.js → agents-D_TrEqAg.js} +1 -1
  22. package/dist/web/client/assets/{agents-O4soKZND.js → agents-DkjJp7JP.js} +1 -1
  23. package/dist/web/client/assets/{approvals-CwDu_lrA.js → approvals-DhOerWdt.js} +1 -1
  24. package/dist/web/client/assets/{attention-BY8MMuM_.js → attention-DGwiF-Jy.js} +1 -1
  25. package/dist/web/client/assets/chevron-right-DSa4xPTs.js +1 -0
  26. package/dist/web/client/assets/config-BJ2ZzHPR.js +3 -0
  27. package/dist/web/client/assets/createServerFn-Dzfjt7mA.js +3 -0
  28. package/dist/web/client/assets/git-review-presentation-CzHQulDk.js +1 -0
  29. package/dist/web/client/assets/{inbox-CWXql0K3.js → inbox-BUElnGep.js} +1 -1
  30. package/dist/web/client/assets/index-Bi-HxcPG.js +50 -0
  31. package/dist/web/client/assets/{learning-DAm4dyyc.js → learning-BiTHNwB3.js} +1 -1
  32. package/dist/web/client/assets/login-BmcZvAH2.js +1 -0
  33. package/dist/web/client/assets/{mcp-loLB0wuh.js → mcp-Cwk9V82W.js} +1 -1
  34. package/dist/web/client/assets/{members-BJ0ikkTl.js → members-CHDNabFh.js} +1 -1
  35. package/dist/web/client/assets/{memory-Drn9Gv53.js → memory-Cx_Fpd4e.js} +1 -1
  36. package/dist/web/client/assets/policy-C0nMdwcG.js +1 -0
  37. package/dist/web/client/assets/{results-9exU6f7m.js → results-Bz3jASs-.js} +1 -1
  38. package/dist/web/client/assets/review-AK9WGmpv.js +1 -0
  39. package/dist/web/client/assets/routes-DsMY_6oy.js +1 -0
  40. package/dist/web/client/assets/{services-BLso1BhA.js → services-DItA6fJ7.js} +1 -1
  41. package/dist/web/client/assets/{skills-BodqX3OI.js → skills-DbNV2vgL.js} +1 -1
  42. package/dist/web/client/assets/{styles-d1yjBpud.css → styles-C6br2xxl.css} +1 -1
  43. package/dist/web/client/assets/{teams-ByQedXZi.js → teams-D83scDxw.js} +1 -1
  44. package/dist/web/client/assets/{teams-SYsF1bOR.js → teams-DAny1ypN.js} +1 -1
  45. package/dist/web/client/assets/{telegram-DC9PLFbB.js → telegram-BOmf9vUh.js} +1 -1
  46. package/dist/web/client/assets/{tokens-DGy8Ijpo.js → tokens-DBGH6Bw5.js} +1 -1
  47. package/dist/web/client/assets/{triggers-BXpVmHDG.js → triggers-D1_pseI3.js} +1 -1
  48. package/dist/web/client/assets/verifications-CBTo-FyV.js +2 -0
  49. package/dist/web/client/assets/welcome-DAfPOm15.js +1 -0
  50. package/dist/web/client/assets/x-CWY-gUaM.js +1 -0
  51. package/dist/web/server/assets/{ChatPane-CS5oI7ef.js → ChatPane-DybH39WK.js} +301 -14
  52. package/dist/web/server/assets/{ResultSourceConversation-BpVWBRYq.js → ResultSourceConversation-BmXTcEOA.js} +1 -1
  53. package/dist/web/server/assets/{TeamTabs-TCKjCvMA.js → TeamTabs-Dg4v6x0-.js} +8 -0
  54. package/dist/web/server/assets/{_id-DtIYuJJX.js → _id--onriuvj.js} +1 -1
  55. package/dist/web/server/assets/{_id-DOnInzLb.js → _id--zoh1vv7.js} +1 -1
  56. package/dist/web/server/assets/{_id-CeyHEsCZ.js → _id-6p-mDmI8.js} +1 -1
  57. package/dist/web/server/assets/{_id-5pgKoid8.js → _id-BN1BPEDI.js} +1 -1
  58. package/dist/web/server/assets/{_id-DFHB9JFQ.js → _id-BYKpT2Tu.js} +1 -1
  59. package/dist/web/server/assets/{_id-B_-CDHOi2.js → _id-BqWTB8Wl.js} +1 -1
  60. package/dist/web/server/assets/{_id-BnqodC1c2.js → _id-C_2er0_G.js} +3 -3
  61. package/dist/web/server/assets/{_id-BG2nkGxa.js → _id-DptBl3X8.js} +1 -1
  62. package/dist/web/server/assets/{_id-DwZXhLlL.js → _id-EAjRXNbD.js} +2 -2
  63. package/dist/web/server/assets/{_id-DrB9uR1b.js → _id-dUnXL-My2.js} +1 -1
  64. package/dist/web/server/assets/{_tanstack-start-manifest_v-D7gKv6m6.js → _tanstack-start-manifest_v-B3M-dfRO.js} +108 -84
  65. package/dist/web/server/assets/{activity-0VUkStOu.js → activity-C5jpoEQI.js} +1 -1
  66. package/dist/web/server/assets/{activity-C88qrNqv.js → activity-Cu7zKPGD.js} +1 -1
  67. package/dist/web/server/assets/{activity-5fWKPDxj.js → activity-Dn50vkQP.js} +2 -2
  68. package/dist/web/server/assets/{agents-CSXLaM2W.js → agents-RE6aYOb-.js} +1 -1
  69. package/dist/web/server/assets/{agents-C86K6HvS.js → agents-nAOx_H7s.js} +1 -1
  70. package/dist/web/server/assets/{approvals-C3MysI6l.js → approvals-DhHxIDrL.js} +1 -1
  71. package/dist/web/server/assets/{attention-DLeLCKah.js → attention-CBWzWRni.js} +1 -1
  72. package/dist/web/server/assets/{auth-CDZp9aEk.js → auth-tB3i6cFd.js} +1 -1
  73. package/dist/web/server/assets/{config-BVTHvljR.js → config-D1k_tTAw.js} +1 -1
  74. package/dist/web/server/assets/{daemon-client-xWyYKAcx.js → daemon-client-C7qjQ2iO.js} +45 -0
  75. package/dist/web/server/assets/git-review-BB3M9nYg.js +26 -0
  76. package/dist/web/server/assets/git-review-Bf5ABFJg.js +179 -0
  77. package/dist/web/server/assets/git-review-presentation-TJiHJhen.js +81 -0
  78. package/dist/web/server/assets/{inbox-PQTrjtOw.js → inbox-Dw4pTevh.js} +1 -1
  79. package/dist/web/server/assets/{learning-K0cmDsZR.js → learning-CF8ZzFVD.js} +1 -1
  80. package/dist/web/server/assets/{mcp-Rtraochg.js → mcp-D5dmBT82.js} +1 -1
  81. package/dist/web/server/assets/{members-CD3GiTfF.js → members-Bd0OtiTr.js} +1 -1
  82. package/dist/web/server/assets/{members-grAKFWgv.js → members-CvwEN9pm.js} +1 -1
  83. package/dist/web/server/assets/{members-cc5SeEaW.js → members-xSXoYUOd.js} +2 -2
  84. package/dist/web/server/assets/{memory-egFpBD1g.js → memory-CcPK7um7.js} +1 -1
  85. package/dist/web/server/assets/{memory-C5i_GxlY.js → memory-UP6AsRkO.js} +2 -2
  86. package/dist/web/server/assets/{memory-CVqnyUaM.js → memory-lo2vHRNw.js} +1 -1
  87. package/dist/web/server/assets/{policy-bLKwvnja.js → policy-B62WXIFo.js} +1 -1
  88. package/dist/web/server/assets/{policy-Dgjb0_gK.js → policy-Bze9Krhg.js} +2 -2
  89. package/dist/web/server/assets/{policy-ooSBgiDS.js → policy-Dh6wd2wN.js} +1 -1
  90. package/dist/web/server/assets/{results-N-kP4iFT.js → results-BFqs2iOu.js} +1 -1
  91. package/dist/web/server/assets/{results-DXdYtHaq.js → results-BWnu3gXP.js} +1 -1
  92. package/dist/web/server/assets/{results-CfNsFncJ.js → results-CzZk50Fu.js} +3 -3
  93. package/dist/web/server/assets/review-DUe3vHPU.js +393 -0
  94. package/dist/web/server/assets/review-c_-cFi7H.js +14 -0
  95. package/dist/web/server/assets/{router-B6g_s7W3.js → router-Deq94UJQ.js} +41 -27
  96. package/dist/web/server/assets/{routes-pcRy_Sf8.js → routes-B6x3pEW8.js} +1 -1
  97. package/dist/web/server/assets/{routes-BqSaZvlu.js → routes-CVKkvFVv.js} +1 -1
  98. package/dist/web/server/assets/{routes-Dsh8F_7i.js → routes-DsUzzxk4.js} +2 -2
  99. package/dist/web/server/assets/{services-DlZA8fRL.js → services-CEr61xb5.js} +1 -1
  100. package/dist/web/server/assets/{skills-i2duvgW-.js → skills-BImC3LTO.js} +1 -1
  101. package/dist/web/server/assets/{teams-6RYIj1Xm.js → teams-8zEIo08E.js} +1 -1
  102. package/dist/web/server/assets/{teams-B1AI3NfN.js → teams-D-yaAWLV.js} +1 -1
  103. package/dist/web/server/assets/{telegram-C4q0YTVn.js → telegram-CGl_LFtJ.js} +1 -1
  104. package/dist/web/server/assets/{tokens-RFquA2Bx.js → tokens-cB-uf7qm.js} +1 -1
  105. package/dist/web/server/assets/{triggers-DVD-iE-N.js → triggers-CtSj79L0.js} +1 -1
  106. package/dist/web/server/assets/verification-B5QjcpIo.js +97 -0
  107. package/dist/web/server/assets/verifications-BfQsfwSE.js +268 -0
  108. package/dist/web/server/assets/verifications-CUq_6ZqL.js +26 -0
  109. package/dist/web/server/server.js +72 -28
  110. package/dist/worker.js +470 -79
  111. package/dist/worker.js.map +1 -1
  112. package/package.json +3 -3
  113. package/dist/web/client/assets/ChatPane-CQZzxOir.js +0 -76
  114. package/dist/web/client/assets/ConfirmDialog-MicTTwdy.js +0 -1
  115. package/dist/web/client/assets/ProductionTeamPolicyEditor-DqUnN_ce.js +0 -7
  116. package/dist/web/client/assets/ProfileCommunicationEditor-DArXub0b.js +0 -1
  117. package/dist/web/client/assets/TeamTabs-DbIk5vvT.js +0 -1
  118. package/dist/web/client/assets/TemplatesTabs-CatJIjGi.js +0 -1
  119. package/dist/web/client/assets/_id-CrnEVcw8.js +0 -1
  120. package/dist/web/client/assets/activity-CrG8Bg60.js +0 -1
  121. package/dist/web/client/assets/chevron-right-Cf6vKeLq.js +0 -1
  122. package/dist/web/client/assets/config-Cn4iBJFz.js +0 -3
  123. package/dist/web/client/assets/index-Bq2zrG2_.js +0 -52
  124. package/dist/web/client/assets/login-BsABI8Ux.js +0 -1
  125. package/dist/web/client/assets/policy-pQadZyk0.js +0 -1
  126. package/dist/web/client/assets/routes-jw1PuqiR.js +0 -1
  127. package/dist/web/client/assets/welcome-BKsnsCxJ.js +0 -1
  128. package/dist/web/client/assets/x-BK4xNCzS.js +0 -1
@@ -0,0 +1 @@
1
+ import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{d as r}from"./preload-helper-bztXdkDj.js";import{t as i}from"./ConfirmDialog-BzIiABOP.js";import{T as a,ct as o}from"./index-Bi-HxcPG.js";import{i as s,r as c}from"./Page-NV96O47A.js";import{t as l}from"./AgentTabs-BcmmwYJc.js";import{t as u}from"./AgentAvatar-JYijLvZ2.js";import{t as d}from"./Button-ByiV6fpd.js";import{t as f}from"./ChatPane-CAYS_fIQ.js";import{t as p}from"./ResultSourceConversation-DoU4tOWc.js";import{r as m}from"./wire-constants-CBD-lTaa.js";var h=o(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),g=e(n(),1),_=t();function v({value:e,className:t,ariaLabel:n=`Copy to clipboard`,title:r=`Copy to clipboard`}){let[i,a]=(0,g.useState)(!1);async function o(){if(!e)return;let t=!1;try{navigator.clipboard?.writeText&&(await navigator.clipboard.writeText(e),t=!0)}catch{}if(!t){let n=document.createElement(`textarea`);n.value=e,n.setAttribute(`readonly`,``),n.style.position=`fixed`,n.style.opacity=`0`,document.body.appendChild(n),n.select();try{t=document.execCommand(`copy`)}catch{}n.remove()}t&&(a(!0),setTimeout(()=>a(!1),1e3))}return(0,_.jsx)(`button`,{type:`button`,onClick:o,title:r,"aria-label":n,className:`inline-flex h-[1.3rem] w-[1.6rem] items-center justify-center rounded-sm border border-transparent text-mocha-light transition-colors hover:border-frost hover:bg-snow hover:text-mocha ${i?`border-[#bcd9bc] bg-[#eef7ee] text-[#3b7a3b] hover:border-[#bcd9bc] hover:bg-[#eef7ee] hover:text-[#3b7a3b]`:``} ${t??``}`,children:i?`✓`:`⧉`})}function y(){let{resolved:e,initialMessages:t,sessionHead:n,teams:o,skills:m,modelGroups:y,telegramConfigured:T}=a.useLoaderData(),D=a.useSearch(),O=r(),[k,A]=(0,g.useState)(null),[j,M]=(0,g.useState)(null),N=D.mode===`settings`;async function P(){let t=await fetch(`/api/agents/${encodeURIComponent(e.agent.id)}/archive`,{method:`POST`});if(!t.ok&&t.status!==204){let e=await t.json().catch(()=>null);throw Error(e?.error??`Could not archive Agent (${t.status})`)}await O.invalidate()}async function F(){M(null);try{let t=await fetch(`/api/agents/${encodeURIComponent(e.agent.id)}/unarchive`,{method:`POST`});if(!t.ok&&t.status!==204){let e=await t.json().catch(()=>null);throw Error(e?.error??`Could not restore Agent (${t.status})`)}await O.invalidate()}catch(e){M(e instanceof Error?e.message:String(e))}}async function I(){let t=await fetch(`/api/teams/${encodeURIComponent(e.team.id)}/policy`);if(!t.ok)throw Error(`The current Team policy is unavailable. Nothing was deleted.`);let n=await t.json(),r=await fetch(`/api/agents/${e.agent.id}?expectedTeamRevision=${n.teamPolicy.revision}`,{method:`DELETE`});if(r.ok||r.status===204)window.location.assign(`/agents`);else{let e=await r.json().catch(()=>null);throw Error(e?.error??`Could not delete Agent (${r.status})`)}}return(0,_.jsxs)(c,{children:[(0,_.jsxs)(`header`,{className:`mb-8`,children:[D.teamPolicy&&(0,_.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:[(0,_.jsxs)(`a`,{href:`/teams/${encodeURIComponent(D.teamPolicy)}/policy?view=${D.view??`flow`}&selected=${encodeURIComponent(D.selected??``)}&vx=${D.vx??0}&vy=${D.vy??0}&vz=${D.vz??.9}`,className:`ghost-btn`,children:[(0,_.jsx)(h,{className:`h-4 w-4`}),` back to Team policy`]}),(0,_.jsx)(`span`,{className:`text-xs text-mocha-light`,children:`Returns to the same projection, viewport, and selection.`})]}),(0,_.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,_.jsx)(u,{identity:e.agent.identity,size:44}),(0,_.jsxs)(`div`,{className:`min-w-0`,children:[(0,_.jsx)(`h1`,{className:`mb-0 break-words`,children:e.agent.name}),(e.agent.identity?.creature||e.agent.identity?.vibe)&&(0,_.jsx)(`p`,{className:`muted mt-0.5 text-sm`,children:[e.agent.identity?.creature,e.agent.identity?.vibe].filter(Boolean).join(` · `)})]})]}),(0,_.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-5 gap-y-2`,children:[(0,_.jsxs)(x,{children:[(0,_.jsx)(`span`,{className:`min-w-0 break-all px-1.5 font-mono text-[0.95em] text-mocha select-all`,children:e.agent.id}),(0,_.jsx)(v,{value:e.agent.id,ariaLabel:`Copy agent UUID`,title:`Copy UUID to clipboard`})]}),(0,_.jsxs)(x,{children:[`status: `,(0,_.jsx)(`span`,{className:`ml-1`,children:e.agent.status})]}),(0,_.jsxs)(x,{children:[`profile:`,` `,(0,_.jsx)(`code`,{className:`ml-1 min-w-0 break-all bg-transparent px-0`,children:e.profile.id})]}),(0,_.jsxs)(x,{children:[`team:`,` `,(0,_.jsx)(`a`,{href:`/teams/${encodeURIComponent(e.team.id)}`,className:`ml-1 min-w-0 break-all bg-transparent px-0 font-mono underline`,children:e.team.id}),` `,`·`,` `,(0,_.jsx)(`a`,{href:`/teams/${encodeURIComponent(e.team.id)}/memory`,className:`ml-0.5 underline`,children:`shared memory →`})]}),(0,_.jsxs)(x,{children:[`model:`,` `,(0,_.jsx)(`code`,{className:`ml-1 min-w-0 break-all bg-transparent px-0`,children:e.model})]}),(0,_.jsxs)(x,{children:[`reasoning:`,` `,(0,_.jsx)(`code`,{className:`ml-1 bg-transparent px-0`,children:e.reasoningLevel})]})]}),(0,_.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[e.agent.status===`archived`?(0,_.jsx)(d,{variant:`ghost`,onClick:()=>void F(),children:`Restore`}):(0,_.jsx)(d,{variant:`ghost`,onClick:()=>A(`archive`),children:`Archive`}),(0,_.jsx)(d,{variant:`danger`,onClick:()=>A(`delete`),children:`Delete permanently`})]})]}),j&&(0,_.jsx)(`p`,{role:`alert`,className:`err`,children:j}),e.agent.status===`archived`&&(0,_.jsxs)(`div`,{className:`mb-4 rounded-md border border-frost bg-fawn/35 px-4 py-2 text-[0.9em] text-chocolate`,children:[(0,_.jsx)(`strong`,{className:`text-warning`,children:`This agent is archived.`}),` It's hidden from the default agent list; use `,(0,_.jsx)(`em`,{children:`unarchive`}),` above to bring it back, or`,` `,(0,_.jsx)(`em`,{children:`delete permanently`}),` to remove its data entirely.`]}),(0,_.jsx)(l,{agentId:e.agent.id,active:N?`settings`:`chat`,archived:e.agent.status===`archived`}),D.resultSource?(0,_.jsx)(p,{resultId:D.resultSource,agentId:e.agent.id}):N?(0,_.jsxs)(`div`,{className:`space-y-6`,children:[(0,_.jsx)(S,{agentId:e.agent.id,currentModelOverride:e.agent.modelOverride??null,profileDefaultModel:e.profile.defaultModel,currentReasoning:e.reasoningLevel,modelGroups:y}),(0,_.jsxs)(s,{title:`Team`,description:`Move this permanent Agent between Team workspaces with an exact policy preview.`,children:[(0,_.jsx)(b,{children:`Team`}),(0,_.jsxs)(`p`,{className:`text-[0.9em] text-mocha-light`,children:[`Current team: `,(0,_.jsx)(`code`,{children:e.team.id}),` (`,e.team.name,`) —`,` `,(0,_.jsx)(`code`,{children:e.team.path}),`.`,` `,(0,_.jsx)(`a`,{href:`/teams/${e.team.id}`,children:`view / edit USER.md`})]}),(0,_.jsx)(C,{agentId:e.agent.id,currentTeamId:e.team.id,teams:o})]}),(0,_.jsx)(s,{title:`Skills`,description:`Attach or detach prompt skills for this Agent.`,children:(0,_.jsx)(w,{agentId:e.agent.id,attached:new Set(e.skills),all:m})}),T&&(0,_.jsx)(s,{title:`Telegram`,description:`Bind this Agent to its Telegram topic and control mirroring.`,children:(0,_.jsx)(E,{agent:e.agent})})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(b,{children:`Chat`}),(0,_.jsx)(`div`,{className:`h-[70vh]`,children:(0,_.jsx)(f,{agentId:e.agent.id,agentName:e.agent.name,initialMessages:t,initialSessionHead:n})}),(0,_.jsx)(`p`,{className:`mt-2 text-[0.82em] text-mocha-light`,children:`chat history persists in bazilion across navigation and restarts.`})]}),(0,_.jsx)(i,{open:k!==null,onOpenChange:e=>{e||A(null)},title:k===`delete`?`Delete ${e.agent.name} permanently?`:`Archive ${e.agent.name}?`,description:k===`delete`?(0,_.jsx)(`p`,{children:`This permanently removes messages, triggers, skill attachments, sessions, and the Agent's private on-disk directory. This cannot be undone.`}):(0,_.jsx)(`p`,{children:`The Agent will stop receiving normal work and disappear from current lists. You can restore it later from “Show archived”.`}),confirmLabel:k===`delete`?`Delete permanently`:`Archive Agent`,confirmVariant:k===`delete`?`danger`:`primary`,onConfirm:async()=>{M(null);try{k===`delete`?await I():await P()}catch(e){throw M(e instanceof Error?e.message:String(e)),e}}})]})}function b({children:e}){return(0,_.jsx)(`h3`,{className:`mb-3 font-body text-[0.85em] font-semibold uppercase tracking-wider text-mocha-light`,children:e})}function x({children:e}){return(0,_.jsx)(`span`,{className:`inline-flex max-w-full min-w-0 flex-wrap items-center gap-1 break-all rounded-full border border-frost bg-ivory px-3 py-0.5 text-[0.84em] text-mocha-light`,children:e})}function S({agentId:e,currentModelOverride:t,profileDefaultModel:n,currentReasoning:i,modelGroups:a}){let o=r(),[c,l]=(0,g.useState)(t??``),[u,f]=(0,g.useState)(i),[p,h]=(0,g.useState)(!1),[v,y]=(0,g.useState)(!1),[b,x]=(0,g.useState)(null),S=t!==null&&a.some(e=>e.models.some(n=>`${e.provider}:${n}`===t));async function C(t){t.preventDefault(),h(!0),x(null);try{let t=await fetch(`/api/agents/${encodeURIComponent(e)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify({modelOverride:c===``?null:c,reasoningLevel:u})});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error??t.statusText)}y(!0),setTimeout(()=>y(!1),1500),await o.invalidate()}catch(e){x(e.message)}finally{h(!1)}}return(0,_.jsx)(s,{title:`Model and reasoning`,description:`Override the Agent template defaults for this Agent only.`,children:(0,_.jsxs)(`form`,{onSubmit:C,className:`grid gap-4 sm:grid-cols-2`,children:[(0,_.jsxs)(`label`,{className:`m-0 flex min-w-0 flex-col gap-1 text-sm text-foreground`,children:[`Model override`,(0,_.jsxs)(`select`,{name:`modelOverride`,value:c,onChange:e=>l(e.target.value),className:`min-w-0`,children:[(0,_.jsxs)(`option`,{value:``,children:[`inherit from profile (`,n,`)`]}),t!==null&&!S&&(0,_.jsxs)(`option`,{value:t,children:[t,` (not in curated list)`]}),a.map(e=>(0,_.jsx)(`optgroup`,{label:e.provider,children:e.models.map(t=>{let n=`${e.provider}:${t}`;return(0,_.jsx)(`option`,{value:n,children:n},n)})},e.provider))]})]}),(0,_.jsxs)(`label`,{className:`m-0 flex min-w-0 flex-col gap-1 text-sm text-foreground`,children:[`Reasoning level`,(0,_.jsx)(`select`,{name:`reasoningLevel`,value:u,onChange:e=>f(e.target.value),className:`min-w-0`,children:m.map(e=>(0,_.jsx)(`option`,{value:e,children:e},e))})]}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 sm:col-span-2`,children:[(0,_.jsx)(d,{variant:`primary`,type:`submit`,disabled:p,children:p?`Saving…`:`Save model settings`}),v&&(0,_.jsx)(`span`,{role:`status`,className:`text-sm text-success`,children:`Saved`}),b&&(0,_.jsx)(`span`,{role:`alert`,className:`text-sm text-danger`,children:b})]})]})})}function C({agentId:e,currentTeamId:t,teams:n}){let i=r(),[a,o]=(0,g.useState)(t),[s,c]=(0,g.useState)(!1),[l,u]=(0,g.useState)(`profile_defaults`),[f,p]=(0,g.useState)(null),[m,h]=(0,g.useState)(null);async function v(n){if(n.preventDefault(),a!==t){c(!0),p(null);try{let[n,r]=await Promise.all([fetch(`/api/teams/${encodeURIComponent(t)}/policy`),fetch(`/api/teams/${encodeURIComponent(a)}/policy`)]);if(!n.ok||!r.ok)throw Error(`A Team policy is unavailable. Nothing was moved.`);let o=await n.json(),s=await r.json(),c={teamId:a,sourceExpectedRevision:o.teamPolicy.revision,destinationExpectedRevision:s.teamPolicy.revision,placement:l};if(!m){let t=await fetch(`/api/agents/${encodeURIComponent(e)}/team/preview`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(c)});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error??t.statusText)}h(await t.json());return}let u=await fetch(`/api/agents/${encodeURIComponent(e)}/team`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify({...c,sourceExpectedRevision:m.source.currentRevision,destinationExpectedRevision:m.destination.currentRevision})});if(!u.ok){let e=await u.json().catch(()=>null);throw Error(e?.error??u.statusText)}await i.invalidate()}catch(e){p(e.message)}finally{c(!1)}}}return(0,_.jsxs)(`form`,{onSubmit:v,className:`mt-2 flex flex-wrap items-end gap-2`,children:[(0,_.jsxs)(`label`,{className:`flex min-w-0 flex-1 flex-col gap-1 text-[0.85em] text-mocha-light`,children:[`move to:`,(0,_.jsx)(`select`,{value:a,onChange:e=>{o(e.target.value),h(null)},className:`w-full min-w-0 rounded-sm border border-frost bg-snow px-2 py-1.5 sm:min-w-[18rem]`,children:n.map(e=>(0,_.jsxs)(`option`,{value:e.id,children:[e.id,` — `,e.path]},e.id))})]}),(0,_.jsxs)(`label`,{className:`flex flex-col gap-1 text-[0.85em] text-mocha-light`,children:[`destination placement:`,(0,_.jsxs)(`select`,{value:l,onChange:e=>{u(e.target.value),h(null)},className:`rounded-sm border border-frost bg-snow px-2 py-1.5`,children:[(0,_.jsx)(`option`,{value:`profile_defaults`,children:`Agent-template defaults`}),(0,_.jsx)(`option`,{value:`isolated`,children:`isolated`})]})]}),(0,_.jsx)(d,{variant:`primary`,type:`submit`,disabled:s||a===t,children:s?`working…`:m?`commit reviewed move`:`review move`}),f&&(0,_.jsx)(`span`,{role:`alert`,className:`basis-full text-[0.85em] text-danger`,children:f}),m&&(0,_.jsxs)(`div`,{className:`basis-full rounded-md border border-sapphire-light bg-sapphire-glow p-3 text-sm`,children:[(0,_.jsxs)(`p`,{children:[`Source revision `,m.source.currentRevision,` → `,(0,_.jsx)(`strong`,{children:m.source.resultingRevision}),`, removing `,m.source.removedEdges.length,` incident edges. Destination revision `,m.destination.currentRevision,` → `,(0,_.jsx)(`strong`,{children:m.destination.resultingRevision}),`, adding `,m.destination.addedEdges.length,` edges to `,m.destination.existingEdges.length,` existing edges.`]}),(0,_.jsx)(`p`,{className:`mt-1 muted`,children:m.lineage})]})]})}function w({agentId:e,attached:t,all:n}){let a=r(),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(null),[u,f]=(0,g.useState)(null),[p,m]=(0,g.useState)(null);async function h(t,n=!1){let r=t.scanFindings??[];if(r.length>0&&!n){f(t);return}s(t.name),l(null);try{let n=await fetch(`/api/agents/${encodeURIComponent(e)}/skills`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({skill:t.name,allowFindings:r.length>0})});if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error??n.statusText)}await a.invalidate()}catch(e){throw l(e instanceof Error?e.message:String(e)),e}finally{s(null)}}async function v(t){s(t),l(null);try{let n=await fetch(`/api/agents/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}`,{method:`DELETE`});if(!n.ok&&n.status!==204){let e=await n.json().catch(()=>null);throw Error(e?.error??n.statusText)}await a.invalidate()}catch(e){throw l(e.message),e}finally{s(null)}}return n.length===0?(0,_.jsx)(`p`,{className:`text-[0.9em] text-mocha-light`,children:`no skills installed`}):(0,_.jsxs)(_.Fragment,{children:[c&&(0,_.jsx)(`p`,{role:`alert`,className:`mb-2 text-[0.85em] text-danger`,children:c}),(0,_.jsxs)(`table`,{className:`hidden md:table`,children:[(0,_.jsx)(`thead`,{children:(0,_.jsxs)(`tr`,{children:[(0,_.jsx)(`th`,{children:`name`}),(0,_.jsx)(`th`,{children:`description`}),(0,_.jsx)(`th`,{children:`scan`}),(0,_.jsx)(`th`,{})]})}),(0,_.jsx)(`tbody`,{children:n.map(e=>{let n=t.has(e.name),r=o===e.name;return(0,_.jsxs)(`tr`,{children:[(0,_.jsx)(`td`,{children:(0,_.jsx)(`code`,{children:e.name})}),(0,_.jsx)(`td`,{children:e.description||(0,_.jsx)(`span`,{className:`text-mocha-light`,children:`—`})}),(0,_.jsx)(`td`,{children:(0,_.jsx)(T,{findings:e.scanFindings??[]})}),(0,_.jsx)(`td`,{children:n?(0,_.jsx)(d,{variant:`ghost`,disabled:r,onClick:()=>m(e.name),children:r?`…`:`detach`}):(0,_.jsx)(d,{variant:`ghost`,disabled:r,onClick:()=>void h(e).catch(()=>{}),children:r?`…`:`attach`})})]},e.name)})})]}),(0,_.jsx)(`div`,{className:`grid gap-3 md:hidden`,children:n.map(e=>{let n=t.has(e.name),r=o===e.name;return(0,_.jsxs)(`article`,{className:`min-w-0 rounded-xl border border-border bg-muted/20 p-4`,children:[(0,_.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[(0,_.jsx)(`code`,{className:`min-w-0 break-all font-mono text-sm`,children:e.name}),(0,_.jsx)(`span`,{className:`shrink-0 text-xs font-semibold ${n?`text-success`:`text-muted-foreground`}`,children:n?`Attached`:`Available`})]}),(0,_.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:e.description||`No description provided.`}),(0,_.jsx)(`div`,{className:`mt-2`,children:(0,_.jsx)(T,{findings:e.scanFindings??[]})}),(0,_.jsx)(`div`,{className:`mt-3`,children:n?(0,_.jsx)(d,{variant:`ghost`,disabled:r,onClick:()=>m(e.name),children:r?`Detaching…`:`Detach`}):(0,_.jsx)(d,{variant:`ghost`,disabled:r,onClick:()=>void h(e).catch(()=>{}),children:r?`Attaching…`:`Attach`})})]},e.name)})}),(0,_.jsx)(i,{open:u!==null,onOpenChange:e=>{e||f(null)},title:`Attach ${u?.name??`skill`} despite scan findings?`,description:(0,_.jsxs)(`div`,{className:`space-y-2`,children:[(0,_.jsxs)(`p`,{children:[`Static scanning found `,u?.scanFindings?.length??0,` potentially unsafe instruction`,u?.scanFindings?.length===1?``:`s`,`. Review the findings before allowing this skill into the Agent's prompt.`]}),(0,_.jsx)(T,{findings:u?.scanFindings??[]})]}),confirmLabel:`Attach despite findings`,onConfirm:async()=>{u&&await h(u,!0)}}),(0,_.jsx)(i,{open:p!==null,onOpenChange:e=>{e||m(null)},title:`Detach ${p??`skill`}?`,description:(0,_.jsx)(`p`,{children:`This removes the skill's instructions from this Agent's future turns. It does not uninstall the skill, and you can attach it again later.`}),confirmLabel:`Detach skill`,onConfirm:async()=>{p&&await v(p)}})]})}function T({findings:e}){return e.length===0?(0,_.jsx)(`span`,{className:`text-mocha-light`,children:`clean`}):(0,_.jsxs)(`details`,{className:`text-[0.82em]`,children:[(0,_.jsxs)(`summary`,{className:e.some(e=>e.severity===`danger`)?`cursor-pointer text-danger`:`cursor-pointer text-mocha`,children:[e.length,` finding`,e.length===1?``:`s`]}),(0,_.jsx)(`ul`,{className:`m-0 list-disc pl-4`,children:e.map((e,t)=>(0,_.jsxs)(`li`,{children:[(0,_.jsx)(`span`,{className:`font-mono`,children:e.severity}),`: `,e.code,e.line?` line ${e.line}`:``,` - `,e.message]},`${e.code}-${e.line??0}-${t}`))})]})}function E({agent:e}){let t=r(),[n,a]=(0,g.useState)(!1),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(e.telegramMirrorMode),[u,f]=(0,g.useState)(e.telegramIconEmoji??``),[p,m]=(0,g.useState)(!1),h=e.telegramTopicId!==null;async function v(){a(!0),s(null);try{let n=await fetch(`/api/agents/${encodeURIComponent(e.id)}/telegram/bind`,{method:`POST`});if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error??n.statusText)}let r=await n.json();window.open(r.deepLink,`_blank`,`noopener`),await t.invalidate()}catch(e){s(e.message)}finally{a(!1)}}async function y(){a(!0),s(null);try{let n=await fetch(`/api/agents/${encodeURIComponent(e.id)}/telegram/binding`,{method:`DELETE`});if(!n.ok&&n.status!==204){let e=await n.json().catch(()=>null);throw Error(e?.error??`Could not unbind Telegram topic (${n.status})`)}await t.invalidate()}catch(e){throw s(e instanceof Error?e.message:String(e)),e}finally{a(!1)}}async function b(n){l(n);try{let r=await fetch(`/api/agents/${encodeURIComponent(e.id)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify({telegramMirrorMode:n})});if(!r.ok)throw Error(r.statusText);await t.invalidate()}catch(t){l(e.telegramMirrorMode),s(t.message)}}async function x(){s(null);try{let n=await fetch(`/api/agents/${encodeURIComponent(e.id)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify({telegramIconEmoji:u.trim()||null})});if(!n.ok)throw Error(n.statusText);await t.invalidate()}catch(e){s(e.message)}}return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`text-[0.9em]`,children:[(0,_.jsx)(`div`,{className:`mb-3 flex flex-wrap items-center gap-3`,children:h?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`span`,{className:`rounded-full bg-success/10 px-2 py-0.5 text-xs font-semibold text-success`,children:`bound`}),(0,_.jsxs)(`span`,{className:`font-mono text-mocha`,children:[`topic #`,e.telegramTopicId]}),(0,_.jsx)(`button`,{type:`button`,onClick:v,disabled:n,className:`ghost-btn`,title:`Open the topic in Telegram (works on desktop/Android; iOS shows the topic list)`,children:`open in Telegram`}),(0,_.jsx)(d,{variant:`danger`,onClick:()=>m(!0),disabled:n,children:`Unbind`})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`span`,{className:`rounded-full bg-warning/10 px-2 py-0.5 text-xs font-semibold text-warning`,children:`unbound`}),(0,_.jsx)(`button`,{type:`button`,onClick:v,disabled:n,className:`ghost-btn`,title:`Create a Telegram topic for this agent`,children:n?`binding…`:`bind a topic`})]})}),(0,_.jsxs)(`div`,{className:`flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-2`,children:[(0,_.jsx)(`label`,{htmlFor:`mirror-mode`,className:`m-0 text-mocha-light`,children:`Mirror mode`}),(0,_.jsxs)(`select`,{id:`mirror-mode`,value:c,onChange:e=>void b(e.target.value),className:`rounded-md border bg-background px-2 py-1 font-mono text-sm`,disabled:n,children:[(0,_.jsx)(`option`,{value:`minimal`,children:`minimal — assistant messages only`}),(0,_.jsx)(`option`,{value:`verbose`,children:`verbose — also tool calls`})]})]}),(0,_.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-end gap-2`,children:[(0,_.jsx)(`label`,{htmlFor:`topic-icon`,className:`m-0 text-mocha-light`,children:`Topic icon`}),(0,_.jsx)(`input`,{id:`topic-icon`,value:u,onChange:e=>f(e.target.value),placeholder:`(profile default)`,maxLength:8,className:`w-32 rounded-md border bg-background px-2 py-1 font-mono text-sm`,disabled:n}),(0,_.jsx)(`button`,{type:`button`,onClick:()=>void x(),disabled:n||u===(e.telegramIconEmoji??``),className:`ghost-btn`,children:`save icon`})]}),o&&(0,_.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-danger`,children:o}),(0,_.jsx)(`p`,{className:`mt-3 text-[0.85em] text-mocha-light`,children:`When bound, every assistant turn for this agent gets mirrored to the topic. Typing in the topic triggers a new turn. iOS Telegram clients have a known limitation that prevents inline link deep-links from opening directly into a topic — bound state is still functional; navigate via the topic list manually.`})]}),(0,_.jsx)(i,{open:p,onOpenChange:m,title:`Unbind ${e.name} from Telegram?`,description:(0,_.jsx)(`p`,{children:`Telegram ingress and mirroring stop for this Agent. The existing forum topic remains in Telegram as an orphan until you remove it there.`}),confirmLabel:`Unbind Telegram topic`,onConfirm:y})]})}export{y as component};
@@ -1 +1 @@
1
- import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{d as r}from"./preload-helper-bztXdkDj.js";import{t as i}from"./UnsavedChangesGuard-BCsLw-mU.js";import{t as a}from"./ProfileCommunicationEditor-DArXub0b.js";import{t as o}from"./index-Bq2zrG2_.js";import{r as s}from"./Page-NV96O47A.js";import{t as c}from"./team-policy-D0jpnn2b.js";import{t as l}from"./TemplatesTabs-CatJIjGi.js";var u=e(n()),d=t();function f(){let{loaded:e,modelGroups:t,skills:n}=o.useLoaderData(),[r,a]=(0,u.useState)(`basics`),[f,p]=(0,u.useState)({}),g=(0,u.useCallback)((e,t)=>{p(n=>n[e]===t?n:{...n,[e]:t})},[]),_=Object.values(f).filter(Boolean).length;return(0,d.jsxs)(s,{children:[(0,d.jsx)(i,{when:_>0,subject:`Agent template changes`}),(0,d.jsx)(l,{}),(0,d.jsxs)(`header`,{className:`mb-1`,children:[(0,d.jsx)(`a`,{href:`/templates/agents`,className:`mb-1 inline-block text-[0.85em] text-mocha-light hover:text-sapphire`,children:`← agent templates`}),(0,d.jsx)(`h1`,{children:e.profile.name}),(0,d.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-2 text-[0.9em] text-mocha-light`,children:[(0,d.jsx)(`code`,{children:e.profile.id}),(0,d.jsx)(`span`,{children:`·`}),(0,d.jsxs)(`span`,{children:[`model: `,(0,d.jsx)(`code`,{children:e.profile.defaultModel})]})]})]}),(0,d.jsxs)(`p`,{className:`muted my-6`,children:[`These settings and files seed every agent spawned from this Agent template going forward.`,` `,(0,d.jsx)(`strong`,{children:`Existing agents keep their own copies`}),` — edits here don't propagate to already-spawned agents.`]}),(0,d.jsx)(h,{items:[{id:`basics`,label:`1. basics`},{id:`skills`,label:`2. skills`},{id:`communication`,label:`3. communication`}],active:r,onChange:e=>a(e)}),_>0&&(0,d.jsxs)(`p`,{role:`status`,className:`mb-4 text-sm text-warning`,children:[_,` unsaved `,_===1?`section`:`sections`,` — switching tabs keeps the draft, but leaving this page will ask for confirmation.`]}),(0,d.jsxs)(`div`,{hidden:r!==`basics`,children:[(0,d.jsx)(x,{profileId:e.profile.id,initialName:e.profile.name,currentModel:e.profile.defaultModel,modelGroups:t,onDirtyChange:g}),(0,d.jsx)(y,{profileId:e.profile.id,file:`SOUL.md`,initialContent:e.files.soul,rows:14,onDirtyChange:g}),(0,d.jsx)(y,{profileId:e.profile.id,file:`IDENTITY.md`,initialContent:e.files.identity,rows:10,onDirtyChange:g}),e.files.bootstrap===null?(0,d.jsxs)(`section`,{className:`file-card`,children:[(0,d.jsx)(`div`,{className:`file-head`,children:(0,d.jsx)(`h3`,{children:`BOOTSTRAP.md`})}),(0,d.jsx)(`p`,{className:`muted`,children:`This profile was created without a bootstrap prompt. Spawned agents won't see a first-run intro message.`})]}):(0,d.jsx)(y,{profileId:e.profile.id,file:`BOOTSTRAP.md`,initialContent:e.files.bootstrap,rows:10,onDirtyChange:g}),(0,d.jsx)(b,{profileId:e.profile.id,file:`AGENTS.md`,initialContent:e.files.agents,hint:`Peers and routing notes — who this agent can hand off to.`,onDirtyChange:g}),(0,d.jsx)(b,{profileId:e.profile.id,file:`TOOLS.md`,initialContent:e.files.tools,hint:`Tool playbook. Agent-specific usage notes that go beyond the generic tool descriptions.`,onDirtyChange:g})]}),(0,d.jsx)(`div`,{hidden:r!==`skills`,children:(0,d.jsx)(S,{profileId:e.profile.id,initialMode:e.profile.skillsMode,initialPicked:new Set(e.defaultSkills),skills:n,onDirtyChange:g})}),(0,d.jsx)(`div`,{hidden:r!==`communication`,children:(0,d.jsx)(m,{profileId:e.profile.id,initial:e.profile.communicationDefaults??c,onDirtyChange:g})})]})}function p(e,t,n){(0,u.useEffect)(()=>{n(e,t)},[t,n,e])}function m({profileId:e,initial:t,onDirtyChange:n}){let[r,i]=(0,u.useState)(t),[o,s]=(0,u.useState)(t),[c,l]=(0,u.useState)({kind:`idle`,message:``}),f=JSON.stringify(r)!==JSON.stringify(o),m=_(f,c);return p(`communication`,f,n),(0,d.jsxs)(`section`,{className:`rounded-md border border-frost bg-snow p-5 shadow-baziu-sm`,children:[(0,d.jsx)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:(0,d.jsx)(`h3`,{className:`m-0 font-body text-[0.95rem] font-semibold normal-case text-chocolate`,children:`Communication defaults`})}),(0,d.jsx)(`p`,{className:`muted mb-4`,children:`Materialized into new Team and Team policy snapshots after preset resolution. Existing snapshots never inherit later changes. Stored by the daemon.`}),(0,d.jsx)(a,{value:r,onChange:i}),(0,d.jsxs)(`div`,{className:`mt-4 flex items-center gap-3`,children:[(0,d.jsx)(`button`,{type:`button`,className:`btn-primary`,disabled:!f||c.kind===`saving`,onClick:async()=>{l({kind:`saving`,message:`saving…`});try{let t=await fetch(`/api/profiles/${encodeURIComponent(e)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify({communicationDefaults:r})});if(!t.ok)throw Error((await t.json().catch(()=>null))?.error??t.statusText);s(r),l({kind:`saved`,message:`saved to daemon`})}catch(e){l({kind:`error`,message:`error: ${e instanceof Error?e.message:String(e)}`})}},children:`save communication defaults`}),m.message&&(0,d.jsx)(`span`,{role:m.kind===`error`?`alert`:`status`,className:`text-xs ${g(m.kind)}`,children:m.message})]})]})}function h({items:e,active:t,onChange:n}){return(0,d.jsx)(`nav`,{role:`tablist`,className:`-mb-px mb-5 flex gap-1 border-b border-frost`,children:e.map(e=>(0,d.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t===e.id,onClick:()=>n(e.id),className:`unstyled cursor-pointer border-b-2 bg-transparent px-4 py-2 text-[0.9em] font-medium transition-colors ${t===e.id?`border-sapphire text-sapphire`:`border-transparent text-mocha hover:text-sapphire`}`,children:e.label},e.id))})}function g(e){return e===`saved`?`text-sapphire`:e===`error`?`text-danger`:e===`dirty`?`text-mocha`:`text-mocha-light`}function _(e,t){return e&&t.kind!==`saving`&&t.kind!==`error`?{kind:`dirty`,message:`unsaved changes`}:t}function v({title:e,status:t,children:n}){return(0,d.jsxs)(`section`,{className:`file-card mb-5 rounded-[16px] border border-frost bg-snow p-5 shadow-baziu-sm`,children:[(0,d.jsxs)(`div`,{className:`mb-2 flex items-baseline justify-between`,children:[(0,d.jsx)(`h3`,{className:`m-0 font-mono text-[0.95em] font-semibold normal-case tracking-normal text-chocolate`,children:e}),t&&(0,d.jsx)(`span`,{role:t.kind===`error`?`alert`:t.message?`status`:void 0,className:`text-[0.82em] ${g(t.kind)}`,children:t.message})]}),n]})}function y({profileId:e,file:t,initialContent:n,rows:r=10,onDirtyChange:i}){let[a,o]=(0,u.useState)(n),[s,c]=(0,u.useState)(n),[l,f]=(0,u.useState)({kind:`idle`,message:``}),m=s!==a;p(`file:${t}`,m,i);let h=_(m,l);async function g(){f({kind:`saving`,message:`saving…`});try{let n=await fetch(`/api/profiles/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({content:s})});if(!n.ok&&n.status!==204){let e=await n.json().catch(()=>null);throw Error(e?.error??n.statusText)}o(s),f({kind:`saved`,message:`saved`})}catch(e){f({kind:`error`,message:`error: ${e.message}`})}}function y(){c(a),f({kind:`idle`,message:``})}return(0,d.jsxs)(v,{title:t,status:h,children:[(0,d.jsx)(`textarea`,{"aria-label":`${t} contents`,rows:r,value:s,onChange:e=>c(e.target.value),className:`font-mono text-[0.88em] leading-[1.55]`}),(0,d.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,d.jsx)(`button`,{type:`button`,className:`btn-primary`,onClick:g,disabled:l.kind===`saving`,children:`save`}),(0,d.jsx)(`button`,{type:`button`,className:`ghost-btn`,onClick:y,children:`revert`})]})]})}function b({profileId:e,file:t,initialContent:n,hint:i,onDirtyChange:a}){let o=r(),[s,c]=(0,u.useState)(!1),[l,f]=(0,u.useState)({kind:`idle`,message:``});async function p(){c(!0),f({kind:`saving`,message:`creating…`});try{let n=await fetch(`/api/profiles/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({content:``})});if(!n.ok&&n.status!==204){let e=await n.json().catch(()=>null);throw Error(e?.error??n.statusText)}await o.invalidate()}catch(e){f({kind:`error`,message:`error: ${e.message}`}),c(!1)}}return n===null?(0,d.jsxs)(v,{title:t,status:l,children:[(0,d.jsx)(`p`,{className:`muted my-1`,children:i}),(0,d.jsx)(`div`,{className:`mt-3 flex gap-2`,children:(0,d.jsx)(`button`,{type:`button`,className:`btn-primary`,onClick:p,disabled:s,children:s?`creating…`:`create empty`})})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`p`,{className:`muted -mb-3 ml-1 mt-2 text-[0.85em]`,children:i}),(0,d.jsx)(y,{profileId:e,file:t,initialContent:n,rows:10,onDirtyChange:a})]})}function x({profileId:e,initialName:t,currentModel:n,modelGroups:i,onDirtyChange:a}){let o=r(),[s,c]=(0,u.useState)(t),[l,f]=(0,u.useState)(n),[m,h]=(0,u.useState)(t),[g,y]=(0,u.useState)(n),[b,x]=(0,u.useState)({kind:`idle`,message:``}),S=s!==m||l!==g,C=_(S,b);p(`settings`,S,a);let w=!i.flatMap(e=>e.models.map(t=>`${e.provider}:${t}`)).includes(n);async function T(t){t.preventDefault();let n=s.trim(),r=l.trim();x({kind:`saving`,message:`saving…`});try{let t=await fetch(`/api/profiles/${encodeURIComponent(e)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify({name:n,defaultModel:r})});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error??t.statusText)}await o.invalidate(),c(n),f(r),h(n),y(r),x({kind:`saved`,message:`saved`})}catch(e){x({kind:`error`,message:`error: ${e.message}`})}}return(0,d.jsx)(v,{title:`settings`,status:C,children:(0,d.jsxs)(`form`,{onSubmit:T,children:[(0,d.jsxs)(`div`,{className:`flex gap-4`,children:[(0,d.jsxs)(`label`,{className:`flex-1`,children:[`name`,(0,d.jsx)(`input`,{value:s,onChange:e=>c(e.target.value)})]}),(0,d.jsxs)(`label`,{className:`flex-1`,children:[`default model`,i.length===0?(0,d.jsx)(`select`,{disabled:!0,children:(0,d.jsx)(`option`,{children:`(no models available — enable on /config)`})}):(0,d.jsxs)(`select`,{value:l,onChange:e=>f(e.target.value),children:[w&&(0,d.jsxs)(`option`,{value:n,children:[n,` (not in enabled list)`]}),i.map(e=>(0,d.jsx)(`optgroup`,{label:e.provider,children:e.models.map(t=>(0,d.jsx)(`option`,{value:`${e.provider}:${t}`,children:`${e.provider}:${t}`},t))},e.provider))]})]})]}),(0,d.jsx)(`div`,{className:`mt-3 flex gap-2`,children:(0,d.jsx)(`button`,{type:`submit`,disabled:!S||b.kind===`saving`,children:`save settings`})})]})})}function S({profileId:e,initialMode:t,initialPicked:n,skills:i,onDirtyChange:a}){let o=r(),[s,c]=(0,u.useState)(t),[l,f]=(0,u.useState)(n),[m,h]=(0,u.useState)(t),[g,y]=(0,u.useState)(n),[b,x]=(0,u.useState)({kind:`idle`,message:``}),S=s!==m||!C(l,g),w=_(S,b);p(`skills`,S,a);function T(e){f(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}async function E(t){t.preventDefault();let n=s===`selected`?new Set(l):new Set;x({kind:`saving`,message:`saving…`});try{let t=await fetch(`/api/profiles/${encodeURIComponent(e)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify({skillsMode:s,defaultSkills:Array.from(n)})});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error??t.statusText)}await o.invalidate(),h(s),f(n),y(n),x({kind:`saved`,message:`saved`})}catch(e){x({kind:`error`,message:`error: ${e.message}`})}}return(0,d.jsxs)(v,{title:`skills`,status:w,children:[(0,d.jsx)(`p`,{className:`muted my-2`,children:`Choose what agents spawned from this profile inherit. Existing agents aren't affected — they keep whatever skills they were spawned with.`}),(0,d.jsxs)(`form`,{onSubmit:E,children:[(0,d.jsxs)(`label`,{className:`my-2 flex cursor-pointer items-start gap-2`,children:[(0,d.jsx)(`input`,{type:`radio`,checked:s===`all`,onChange:()=>c(`all`)}),(0,d.jsxs)(`span`,{children:[(0,d.jsx)(`strong`,{children:`allow all skills`}),` — every skill on disk is attached at spawn.`]})]}),(0,d.jsxs)(`label`,{className:`my-2 flex cursor-pointer items-start gap-2`,children:[(0,d.jsx)(`input`,{type:`radio`,checked:s===`selected`,onChange:()=>c(`selected`)}),(0,d.jsxs)(`span`,{children:[(0,d.jsx)(`strong`,{children:`select skills`}),` — attach only the ones ticked below.`]})]}),(0,d.jsx)(`div`,{className:`mt-3 max-h-[22rem] overflow-y-auto rounded-md border border-frost p-3 ${s===`all`?`pointer-events-none opacity-50`:``}`,children:i.length===0?(0,d.jsxs)(`p`,{className:`muted`,children:[`No skills installed yet. Import some on `,(0,d.jsx)(`a`,{href:`/skills`,children:`/skills`}),`.`]}):i.map(e=>(0,d.jsxs)(`label`,{className:`my-1.5 flex cursor-pointer items-start gap-2`,children:[(0,d.jsx)(`input`,{type:`checkbox`,checked:l.has(e.name),onChange:()=>T(e.name)}),(0,d.jsxs)(`span`,{children:[(0,d.jsx)(`code`,{children:e.name}),e.description&&(0,d.jsxs)(`span`,{className:`text-[0.9em] text-mocha-light`,children:[` — `,e.description]})]})]},e.name))}),(0,d.jsx)(`div`,{className:`mt-3 flex gap-2`,children:(0,d.jsx)(`button`,{type:`submit`,disabled:!S||b.kind===`saving`,children:`save skills`})})]})]})}function C(e,t){return e.size===t.size&&Array.from(e).every(e=>t.has(e))}export{f as component};
1
+ import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{d as r}from"./preload-helper-bztXdkDj.js";import{t as i}from"./UnsavedChangesGuard-CPRtFReU.js";import{t as a}from"./ProfileCommunicationEditor-DN0fOzqn.js";import{t as o}from"./index-Bi-HxcPG.js";import{r as s}from"./Page-NV96O47A.js";import{t as c}from"./team-policy-D0jpnn2b.js";import{t as l}from"./TemplatesTabs-Bs_OXKwx.js";var u=e(n()),d=t();function f(){let{loaded:e,modelGroups:t,skills:n}=o.useLoaderData(),[r,a]=(0,u.useState)(`basics`),[f,p]=(0,u.useState)({}),g=(0,u.useCallback)((e,t)=>{p(n=>n[e]===t?n:{...n,[e]:t})},[]),_=Object.values(f).filter(Boolean).length;return(0,d.jsxs)(s,{children:[(0,d.jsx)(i,{when:_>0,subject:`Agent template changes`}),(0,d.jsx)(l,{}),(0,d.jsxs)(`header`,{className:`mb-1`,children:[(0,d.jsx)(`a`,{href:`/templates/agents`,className:`mb-1 inline-block text-[0.85em] text-mocha-light hover:text-sapphire`,children:`← agent templates`}),(0,d.jsx)(`h1`,{children:e.profile.name}),(0,d.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-2 text-[0.9em] text-mocha-light`,children:[(0,d.jsx)(`code`,{children:e.profile.id}),(0,d.jsx)(`span`,{children:`·`}),(0,d.jsxs)(`span`,{children:[`model: `,(0,d.jsx)(`code`,{children:e.profile.defaultModel})]})]})]}),(0,d.jsxs)(`p`,{className:`muted my-6`,children:[`These settings and files seed every agent spawned from this Agent template going forward.`,` `,(0,d.jsx)(`strong`,{children:`Existing agents keep their own copies`}),` — edits here don't propagate to already-spawned agents.`]}),(0,d.jsx)(h,{items:[{id:`basics`,label:`1. basics`},{id:`skills`,label:`2. skills`},{id:`communication`,label:`3. communication`}],active:r,onChange:e=>a(e)}),_>0&&(0,d.jsxs)(`p`,{role:`status`,className:`mb-4 text-sm text-warning`,children:[_,` unsaved `,_===1?`section`:`sections`,` — switching tabs keeps the draft, but leaving this page will ask for confirmation.`]}),(0,d.jsxs)(`div`,{hidden:r!==`basics`,children:[(0,d.jsx)(x,{profileId:e.profile.id,initialName:e.profile.name,currentModel:e.profile.defaultModel,modelGroups:t,onDirtyChange:g}),(0,d.jsx)(y,{profileId:e.profile.id,file:`SOUL.md`,initialContent:e.files.soul,rows:14,onDirtyChange:g}),(0,d.jsx)(y,{profileId:e.profile.id,file:`IDENTITY.md`,initialContent:e.files.identity,rows:10,onDirtyChange:g}),e.files.bootstrap===null?(0,d.jsxs)(`section`,{className:`file-card`,children:[(0,d.jsx)(`div`,{className:`file-head`,children:(0,d.jsx)(`h3`,{children:`BOOTSTRAP.md`})}),(0,d.jsx)(`p`,{className:`muted`,children:`This profile was created without a bootstrap prompt. Spawned agents won't see a first-run intro message.`})]}):(0,d.jsx)(y,{profileId:e.profile.id,file:`BOOTSTRAP.md`,initialContent:e.files.bootstrap,rows:10,onDirtyChange:g}),(0,d.jsx)(b,{profileId:e.profile.id,file:`AGENTS.md`,initialContent:e.files.agents,hint:`Peers and routing notes — who this agent can hand off to.`,onDirtyChange:g}),(0,d.jsx)(b,{profileId:e.profile.id,file:`TOOLS.md`,initialContent:e.files.tools,hint:`Tool playbook. Agent-specific usage notes that go beyond the generic tool descriptions.`,onDirtyChange:g})]}),(0,d.jsx)(`div`,{hidden:r!==`skills`,children:(0,d.jsx)(S,{profileId:e.profile.id,initialMode:e.profile.skillsMode,initialPicked:new Set(e.defaultSkills),skills:n,onDirtyChange:g})}),(0,d.jsx)(`div`,{hidden:r!==`communication`,children:(0,d.jsx)(m,{profileId:e.profile.id,initial:e.profile.communicationDefaults??c,onDirtyChange:g})})]})}function p(e,t,n){(0,u.useEffect)(()=>{n(e,t)},[t,n,e])}function m({profileId:e,initial:t,onDirtyChange:n}){let[r,i]=(0,u.useState)(t),[o,s]=(0,u.useState)(t),[c,l]=(0,u.useState)({kind:`idle`,message:``}),f=JSON.stringify(r)!==JSON.stringify(o),m=_(f,c);return p(`communication`,f,n),(0,d.jsxs)(`section`,{className:`rounded-md border border-frost bg-snow p-5 shadow-baziu-sm`,children:[(0,d.jsx)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:(0,d.jsx)(`h3`,{className:`m-0 font-body text-[0.95rem] font-semibold normal-case text-chocolate`,children:`Communication defaults`})}),(0,d.jsx)(`p`,{className:`muted mb-4`,children:`Materialized into new Team and Team policy snapshots after preset resolution. Existing snapshots never inherit later changes. Stored by the daemon.`}),(0,d.jsx)(a,{value:r,onChange:i}),(0,d.jsxs)(`div`,{className:`mt-4 flex items-center gap-3`,children:[(0,d.jsx)(`button`,{type:`button`,className:`btn-primary`,disabled:!f||c.kind===`saving`,onClick:async()=>{l({kind:`saving`,message:`saving…`});try{let t=await fetch(`/api/profiles/${encodeURIComponent(e)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify({communicationDefaults:r})});if(!t.ok)throw Error((await t.json().catch(()=>null))?.error??t.statusText);s(r),l({kind:`saved`,message:`saved to daemon`})}catch(e){l({kind:`error`,message:`error: ${e instanceof Error?e.message:String(e)}`})}},children:`save communication defaults`}),m.message&&(0,d.jsx)(`span`,{role:m.kind===`error`?`alert`:`status`,className:`text-xs ${g(m.kind)}`,children:m.message})]})]})}function h({items:e,active:t,onChange:n}){return(0,d.jsx)(`nav`,{role:`tablist`,className:`-mb-px mb-5 flex gap-1 border-b border-frost`,children:e.map(e=>(0,d.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t===e.id,onClick:()=>n(e.id),className:`unstyled cursor-pointer border-b-2 bg-transparent px-4 py-2 text-[0.9em] font-medium transition-colors ${t===e.id?`border-sapphire text-sapphire`:`border-transparent text-mocha hover:text-sapphire`}`,children:e.label},e.id))})}function g(e){return e===`saved`?`text-sapphire`:e===`error`?`text-danger`:e===`dirty`?`text-mocha`:`text-mocha-light`}function _(e,t){return e&&t.kind!==`saving`&&t.kind!==`error`?{kind:`dirty`,message:`unsaved changes`}:t}function v({title:e,status:t,children:n}){return(0,d.jsxs)(`section`,{className:`file-card mb-5 rounded-[16px] border border-frost bg-snow p-5 shadow-baziu-sm`,children:[(0,d.jsxs)(`div`,{className:`mb-2 flex items-baseline justify-between`,children:[(0,d.jsx)(`h3`,{className:`m-0 font-mono text-[0.95em] font-semibold normal-case tracking-normal text-chocolate`,children:e}),t&&(0,d.jsx)(`span`,{role:t.kind===`error`?`alert`:t.message?`status`:void 0,className:`text-[0.82em] ${g(t.kind)}`,children:t.message})]}),n]})}function y({profileId:e,file:t,initialContent:n,rows:r=10,onDirtyChange:i}){let[a,o]=(0,u.useState)(n),[s,c]=(0,u.useState)(n),[l,f]=(0,u.useState)({kind:`idle`,message:``}),m=s!==a;p(`file:${t}`,m,i);let h=_(m,l);async function g(){f({kind:`saving`,message:`saving…`});try{let n=await fetch(`/api/profiles/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({content:s})});if(!n.ok&&n.status!==204){let e=await n.json().catch(()=>null);throw Error(e?.error??n.statusText)}o(s),f({kind:`saved`,message:`saved`})}catch(e){f({kind:`error`,message:`error: ${e.message}`})}}function y(){c(a),f({kind:`idle`,message:``})}return(0,d.jsxs)(v,{title:t,status:h,children:[(0,d.jsx)(`textarea`,{"aria-label":`${t} contents`,rows:r,value:s,onChange:e=>c(e.target.value),className:`font-mono text-[0.88em] leading-[1.55]`}),(0,d.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,d.jsx)(`button`,{type:`button`,className:`btn-primary`,onClick:g,disabled:l.kind===`saving`,children:`save`}),(0,d.jsx)(`button`,{type:`button`,className:`ghost-btn`,onClick:y,children:`revert`})]})]})}function b({profileId:e,file:t,initialContent:n,hint:i,onDirtyChange:a}){let o=r(),[s,c]=(0,u.useState)(!1),[l,f]=(0,u.useState)({kind:`idle`,message:``});async function p(){c(!0),f({kind:`saving`,message:`creating…`});try{let n=await fetch(`/api/profiles/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({content:``})});if(!n.ok&&n.status!==204){let e=await n.json().catch(()=>null);throw Error(e?.error??n.statusText)}await o.invalidate()}catch(e){f({kind:`error`,message:`error: ${e.message}`}),c(!1)}}return n===null?(0,d.jsxs)(v,{title:t,status:l,children:[(0,d.jsx)(`p`,{className:`muted my-1`,children:i}),(0,d.jsx)(`div`,{className:`mt-3 flex gap-2`,children:(0,d.jsx)(`button`,{type:`button`,className:`btn-primary`,onClick:p,disabled:s,children:s?`creating…`:`create empty`})})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`p`,{className:`muted -mb-3 ml-1 mt-2 text-[0.85em]`,children:i}),(0,d.jsx)(y,{profileId:e,file:t,initialContent:n,rows:10,onDirtyChange:a})]})}function x({profileId:e,initialName:t,currentModel:n,modelGroups:i,onDirtyChange:a}){let o=r(),[s,c]=(0,u.useState)(t),[l,f]=(0,u.useState)(n),[m,h]=(0,u.useState)(t),[g,y]=(0,u.useState)(n),[b,x]=(0,u.useState)({kind:`idle`,message:``}),S=s!==m||l!==g,C=_(S,b);p(`settings`,S,a);let w=!i.flatMap(e=>e.models.map(t=>`${e.provider}:${t}`)).includes(n);async function T(t){t.preventDefault();let n=s.trim(),r=l.trim();x({kind:`saving`,message:`saving…`});try{let t=await fetch(`/api/profiles/${encodeURIComponent(e)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify({name:n,defaultModel:r})});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error??t.statusText)}await o.invalidate(),c(n),f(r),h(n),y(r),x({kind:`saved`,message:`saved`})}catch(e){x({kind:`error`,message:`error: ${e.message}`})}}return(0,d.jsx)(v,{title:`settings`,status:C,children:(0,d.jsxs)(`form`,{onSubmit:T,children:[(0,d.jsxs)(`div`,{className:`flex gap-4`,children:[(0,d.jsxs)(`label`,{className:`flex-1`,children:[`name`,(0,d.jsx)(`input`,{value:s,onChange:e=>c(e.target.value)})]}),(0,d.jsxs)(`label`,{className:`flex-1`,children:[`default model`,i.length===0?(0,d.jsx)(`select`,{disabled:!0,children:(0,d.jsx)(`option`,{children:`(no models available — enable on /config)`})}):(0,d.jsxs)(`select`,{value:l,onChange:e=>f(e.target.value),children:[w&&(0,d.jsxs)(`option`,{value:n,children:[n,` (not in enabled list)`]}),i.map(e=>(0,d.jsx)(`optgroup`,{label:e.provider,children:e.models.map(t=>(0,d.jsx)(`option`,{value:`${e.provider}:${t}`,children:`${e.provider}:${t}`},t))},e.provider))]})]})]}),(0,d.jsx)(`div`,{className:`mt-3 flex gap-2`,children:(0,d.jsx)(`button`,{type:`submit`,disabled:!S||b.kind===`saving`,children:`save settings`})})]})})}function S({profileId:e,initialMode:t,initialPicked:n,skills:i,onDirtyChange:a}){let o=r(),[s,c]=(0,u.useState)(t),[l,f]=(0,u.useState)(n),[m,h]=(0,u.useState)(t),[g,y]=(0,u.useState)(n),[b,x]=(0,u.useState)({kind:`idle`,message:``}),S=s!==m||!C(l,g),w=_(S,b);p(`skills`,S,a);function T(e){f(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}async function E(t){t.preventDefault();let n=s===`selected`?new Set(l):new Set;x({kind:`saving`,message:`saving…`});try{let t=await fetch(`/api/profiles/${encodeURIComponent(e)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify({skillsMode:s,defaultSkills:Array.from(n)})});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error??t.statusText)}await o.invalidate(),h(s),f(n),y(n),x({kind:`saved`,message:`saved`})}catch(e){x({kind:`error`,message:`error: ${e.message}`})}}return(0,d.jsxs)(v,{title:`skills`,status:w,children:[(0,d.jsx)(`p`,{className:`muted my-2`,children:`Choose what agents spawned from this profile inherit. Existing agents aren't affected — they keep whatever skills they were spawned with.`}),(0,d.jsxs)(`form`,{onSubmit:E,children:[(0,d.jsxs)(`label`,{className:`my-2 flex cursor-pointer items-start gap-2`,children:[(0,d.jsx)(`input`,{type:`radio`,checked:s===`all`,onChange:()=>c(`all`)}),(0,d.jsxs)(`span`,{children:[(0,d.jsx)(`strong`,{children:`allow all skills`}),` — every skill on disk is attached at spawn.`]})]}),(0,d.jsxs)(`label`,{className:`my-2 flex cursor-pointer items-start gap-2`,children:[(0,d.jsx)(`input`,{type:`radio`,checked:s===`selected`,onChange:()=>c(`selected`)}),(0,d.jsxs)(`span`,{children:[(0,d.jsx)(`strong`,{children:`select skills`}),` — attach only the ones ticked below.`]})]}),(0,d.jsx)(`div`,{className:`mt-3 max-h-[22rem] overflow-y-auto rounded-md border border-frost p-3 ${s===`all`?`pointer-events-none opacity-50`:``}`,children:i.length===0?(0,d.jsxs)(`p`,{className:`muted`,children:[`No skills installed yet. Import some on `,(0,d.jsx)(`a`,{href:`/skills`,children:`/skills`}),`.`]}):i.map(e=>(0,d.jsxs)(`label`,{className:`my-1.5 flex cursor-pointer items-start gap-2`,children:[(0,d.jsx)(`input`,{type:`checkbox`,checked:l.has(e.name),onChange:()=>T(e.name)}),(0,d.jsxs)(`span`,{children:[(0,d.jsx)(`code`,{children:e.name}),e.description&&(0,d.jsxs)(`span`,{className:`text-[0.9em] text-mocha-light`,children:[` — `,e.description]})]})]},e.name))}),(0,d.jsx)(`div`,{className:`mt-3 flex gap-2`,children:(0,d.jsx)(`button`,{type:`submit`,disabled:!S||b.kind===`saving`,children:`save skills`})})]})]})}function C(e,t){return e.size===t.size&&Array.from(e).every(e=>t.has(e))}export{f as component};
@@ -1 +1 @@
1
- import{t as e}from"./jsx-runtime-DGeXAQPT.js";import{y as t}from"./index-Bq2zrG2_.js";import{r as n}from"./Page-NV96O47A.js";import{t as r}from"./ResultCard-Cps_lXVN.js";var i=e();function a(){let{id:e}=t.useParams();return(0,i.jsxs)(n,{size:`narrow`,children:[(0,i.jsx)(`h1`,{children:`Saved file`}),(0,i.jsx)(r,{resultId:e,showPreview:!0})]})}export{a as component};
1
+ import{t as e}from"./jsx-runtime-DGeXAQPT.js";import{M as t}from"./index-Bi-HxcPG.js";import{r as n}from"./Page-NV96O47A.js";import{t as r}from"./ResultCard-Cps_lXVN.js";var i=e();function a(){let{id:e}=t.useParams();return(0,i.jsxs)(n,{size:`narrow`,children:[(0,i.jsx)(`h1`,{children:`Saved file`}),(0,i.jsx)(r,{resultId:e,showPreview:!0})]})}export{a as component};
@@ -1 +1 @@
1
- import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{d as r}from"./preload-helper-bztXdkDj.js";import{t as i}from"./UnsavedChangesGuard-BCsLw-mU.js";import{p as a}from"./index-Bq2zrG2_.js";import{a as o,i as s,r as c}from"./Page-NV96O47A.js";import{t as l}from"./Button-ByiV6fpd.js";import{t as u}from"./TeamTabs-DbIk5vvT.js";var d=e(n(),1),f=t();function p({teamId:e}){let[t,n]=(0,d.useState)(null),[r,i]=(0,d.useState)(``),[a,o]=(0,d.useState)(`.`),[s,c]=(0,d.useState)(``),[u,p]=(0,d.useState)(!1),m=`/api/teams/${encodeURIComponent(e)}/coding-environment`;return(0,d.useEffect)(()=>{let e=!0;return fetch(m).then(async e=>{if(!e.ok)throw Error(`Defaults unavailable`);return e.json()}).then(t=>{e&&(n(t),i(t.environment?.config.image??t.image),o(t.environment?.config.cwd??`.`))}).catch(t=>{e&&c(t.message)}),()=>{e=!1}},[m]),(0,f.jsxs)(`details`,{className:`border-t mt-4 pt-4`,children:[(0,f.jsx)(`summary`,{className:`cursor-pointer text-sm`,children:`Optional protected runtime defaults`}),(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground my-3`,children:`Agents discover commands during the task. Override the installation image only if this repository needs a different prepared toolchain. Host turns do not use these Docker defaults.`}),s&&(0,f.jsx)(`p`,{role:`alert`,children:s}),t&&(0,f.jsxs)(`form`,{className:`space-y-3`,onSubmit:async e=>{e.preventDefault(),p(!0),c(``);try{let e=await fetch(m,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({expectedRevision:t.environment?.revision??0,config:{image:r,cwd:a,env:t.environment?.config.env??{}}})}),i=await e.json();if(!e.ok)throw Error(i.error);n({...t,environment:i,image:r})}catch(e){c(e instanceof Error?e.message:`Save failed`)}finally{p(!1)}},children:[(0,f.jsxs)(`label`,{className:`block text-sm`,children:[`Local Docker image`,(0,f.jsx)(`input`,{required:!0,value:r,onChange:e=>i(e.target.value),className:`block w-full rounded border p-2 mt-1`})]}),(0,f.jsxs)(`label`,{className:`block text-sm`,children:[`Default directory`,(0,f.jsx)(`input`,{required:!0,value:a,onChange:e=>o(e.target.value),className:`block w-full rounded border p-2 mt-1`})]}),(0,f.jsx)(l,{type:`submit`,variant:`primary`,disabled:u,children:u?`Saving…`:`Save defaults`})]})]})}function m({teamId:e}){let[t,n]=(0,d.useState)(``),[r,i]=(0,d.useState)(null),[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(null),u=(0,d.useRef)(0),p=r?.report,m=p?[...new Map([...p.instructions.issues,...p.commands.issues,...p.git.issues].map(e=>[JSON.stringify([e.path,e.message]),e])).values()]:[];async function h(){let n=++u.current,r=t||`.`;o(!0),c(null);try{let t=await fetch(`/api/teams/${encodeURIComponent(e)}/repository-context?target=${encodeURIComponent(r)}`,{cache:`no-store`});if(!t.ok)throw Error(`Repository context could not be loaded. Refresh to try again.`);let a=await t.json();u.current===n&&i({report:a,target:r})}catch(e){u.current===n&&c(e instanceof Error?e.message:`Inspection failed`)}finally{u.current===n&&o(!1)}}return(0,d.useEffect)(()=>(h(),()=>{u.current++}),[e]),(0,f.jsxs)(`section`,{className:`min-w-0`,"aria-labelledby":`repository-context-heading`,children:[(0,f.jsx)(`h2`,{id:`repository-context-heading`,className:`font-serif text-xl mb-1`,children:`Explore the repository`}),(0,f.jsx)(`p`,{className:`text-muted-foreground text-sm mb-3`,children:`See the instructions and commands for the part of the project you’re working on.`}),(0,f.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),h()},className:`flex flex-wrap gap-2 items-end mb-3`,children:[(0,f.jsxs)(`label`,{className:`flex-1 min-w-[12rem] m-0 text-sm`,children:[`Project path`,(0,f.jsx)(`input`,{value:t,onChange:e=>n(e.target.value),placeholder:`. (Team root)`,maxLength:4096,className:`mt-1 block w-full rounded-md border bg-background px-3 py-2 font-mono text-sm`})]}),(0,f.jsx)(l,{type:`submit`,variant:`primary`,disabled:a,children:a?`Inspecting…`:p?`Refresh context`:`Inspect repository`})]}),s&&(0,f.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger mb-3`,children:[s,` `,p?`The report below is the previous capture.`:``]}),p&&r&&(0,f.jsxs)(`div`,{className:`space-y-3 text-sm min-w-0`,"aria-live":`polite`,children:[(0,f.jsxs)(`p`,{className:`text-xs text-muted-foreground break-words`,children:[(0,f.jsx)(`code`,{children:r.target===`.`?`Team root`:r.target}),` · Inspected`,` `,(0,f.jsx)(`time`,{dateTime:new Date(p.capturedAt).toISOString(),children:new Date(p.capturedAt).toLocaleString()}),`. Read-only inspection.`]}),m.length>0&&(0,f.jsxs)(`div`,{role:`status`,className:`border-l-2 border-primary bg-muted/40 px-3 py-2`,children:[(0,f.jsx)(`h3`,{className:`font-sans text-sm font-semibold`,children:`Some context is unavailable`}),(0,f.jsx)(`ul`,{className:`mt-1 space-y-1`,children:m.map((e,t)=>(0,f.jsxs)(`li`,{className:`break-words`,children:[e.path?`${e.path}: `:``,e.message]},t))})]}),(0,f.jsxs)(`div`,{className:`rounded-md bg-muted/40 px-3 py-2`,children:[(0,f.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3 gap-y-1`,children:[(0,f.jsx)(`h3`,{className:`font-sans text-sm font-semibold`,children:p.git.state===`available`?`Working tree`:p.git.state===`not_repository`?`No Git repository`:`Git unavailable`}),p.git.state===`available`&&(0,f.jsxs)(`p`,{className:`min-w-0 break-all`,children:[(0,f.jsx)(`span`,{className:`font-mono`,children:p.git.branch??`Detached HEAD`}),(0,f.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,`· `,p.git.head?.slice(0,8)??`No commits yet`]})]})]}),p.git.state===`available`&&(0,f.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:[p.git.staged,` staged · `,p.git.unstaged,` unstaged · `,p.git.untracked,` `,`untracked · `,p.git.conflicted,` conflicted`]})]}),(0,f.jsxs)(`div`,{children:[(0,f.jsxs)(`h3`,{className:`font-sans text-sm font-semibold`,children:[`Instructions`,` `,(0,f.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`· `,p.instructions.files.length,` files`,p.instructions.state===`complete`?``:` · incomplete`]})]}),(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Listed from broadest to most specific. Operator instructions and runtime policy take priority.`}),p.instructions.files.length===0&&(0,f.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:p.instructions.state===`complete`?`No applicable AGENTS.md files found.`:`Instructions for this scope could not be prepared.`}),(0,f.jsx)(`div`,{className:`mt-2 divide-y`,children:p.instructions.files.map(e=>(0,f.jsxs)(`details`,{className:`py-2 min-w-0`,children:[(0,f.jsx)(`summary`,{className:`cursor-pointer break-words font-mono text-sm`,children:e.path}),(0,f.jsx)(`pre`,{className:`mt-2 rounded-md bg-muted/40 p-3 whitespace-pre-wrap break-words text-xs max-h-80 overflow-auto`,children:e.content})]},e.path))})]}),(0,f.jsxs)(`div`,{className:`border-t pt-3`,children:[(0,f.jsx)(`h3`,{className:`font-sans text-sm font-semibold`,children:`Suggested commands`}),(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Source suggestions for Agent investigation; inspection never executes commands.`}),p.commands.candidates.length===0&&(0,f.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:`No command suggestions available for this scope.`}),(0,f.jsx)(`ul`,{className:`mt-1 divide-y`,children:p.commands.candidates.map((e,t)=>(0,f.jsxs)(`li`,{className:`py-2 min-w-0`,children:[(0,f.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:(0,f.jsx)(`code`,{className:`block bg-transparent p-0 whitespace-pre-wrap break-words min-w-0`,children:e.command})}),(0,f.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-1 break-words`,children:[e.source,` · `,e.location,` · cwd `,e.cwd,e.kind===`script`?` · ${e.packageManager??`package manager unknown`}`:` · documentation excerpt`]})]},`${e.source}:${t}`))})]}),(0,f.jsxs)(`details`,{className:`border-t pt-3 text-xs text-muted-foreground`,children:[(0,f.jsx)(`summary`,{className:`cursor-pointer`,children:`Source details and fingerprints`}),(0,f.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,f.jsx)(`p`,{children:`Deeper repository instructions apply within their own subtree. Private Agent instructions are managed on each Agent.`}),(0,f.jsxs)(`p`,{className:`break-all`,children:[`Snapshot SHA-256: `,p.fingerprint]}),p.git.head&&(0,f.jsxs)(`p`,{className:`break-all`,children:[`Git commit: `,p.git.head]}),p.instructions.files.map(e=>(0,f.jsxs)(`p`,{className:`break-all`,children:[(0,f.jsx)(`span`,{className:`font-mono`,children:e.path}),` · Scope: `,e.scope,` · Precedence:`,` `,e.precedence,(0,f.jsx)(`br`,{}),`SHA-256: `,e.sha256]},e.path)),p.commands.sources.map(e=>(0,f.jsxs)(`p`,{className:`break-all`,children:[(0,f.jsx)(`span`,{className:`font-mono`,children:e.path}),(0,f.jsx)(`br`,{}),`SHA-256: `,e.sha256]},e.path))]})]})]})]})}function h(){let{team:e,members:t,profileGroups:n}=a.useLoaderData(),h=r(),[v,y]=(0,d.useState)(e.userMd),[b,x]=(0,d.useState)(!1),[S,C]=(0,d.useState)(null),[w,T]=(0,d.useState)(null),[E,D]=(0,d.useState)(!1),O=v!==e.userMd||E;async function k(){x(!0),C(null);try{let t=await fetch(`/api/teams/${encodeURIComponent(e.id)}/user-md`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({userMd:v})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`${t.status} ${t.statusText}`)}T(Date.now()),await h.invalidate()}catch(e){C(e.message)}finally{x(!1)}}return(0,f.jsxs)(c,{children:[(0,f.jsx)(i,{when:O,subject:`Team context`}),(0,f.jsxs)(`h1`,{className:`font-serif text-3xl text-foreground`,children:[e.name,` `,(0,f.jsxs)(`span`,{className:`text-muted-foreground text-base`,children:[`(`,e.id,`)`]})]}),(0,f.jsxs)(`p`,{className:`text-muted-foreground text-sm mb-6 mt-1`,children:[(0,f.jsx)(`code`,{className:`font-mono`,children:e.path}),` · `,t.length,` `,`member`,t.length===1?``:`s`,` ·`,` `,(0,f.jsx)(`a`,{href:`/teams/${encodeURIComponent(e.id)}/memory`,className:`text-primary underline`,children:`shared memory →`})]}),(0,f.jsx)(u,{teamId:e.id}),(0,f.jsxs)(`section`,{className:`rounded-lg border bg-card p-5 mb-6`,children:[(0,f.jsx)(`h3`,{className:`font-serif text-xl mb-1`,children:`USER.md`}),(0,f.jsx)(`p`,{className:`text-muted-foreground text-sm mb-3`,children:`Read-only context about the human, injected into every member agent's system prompt. 12 KB cap. Agents cannot edit this file — only you can.`}),(0,f.jsx)(`label`,{htmlFor:`team-user-context`,className:`sr-only`,children:`USER.md Team context`}),(0,f.jsx)(`textarea`,{id:`team-user-context`,value:v,onChange:e=>y(e.target.value),rows:16,className:`w-full rounded-md border bg-background px-3 py-2 font-mono text-sm outline-none focus:ring-2 focus:ring-ring/30`,placeholder:`What the agent should know about you in this team context…`}),(0,f.jsxs)(`div`,{className:`flex items-center gap-3 mt-3`,children:[(0,f.jsx)(l,{variant:`primary`,onClick:k,disabled:b||v===e.userMd,children:b?`saving…`:`save`}),(0,f.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[v.length,` / 12000 chars`]}),w&&(0,f.jsx)(`span`,{role:`status`,className:`text-xs text-success`,children:`Saved`}),S&&(0,f.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:S})]})]}),(0,f.jsxs)(`details`,{className:`mb-6 rounded-lg border bg-card p-4`,children:[(0,f.jsx)(`summary`,{className:`cursor-pointer text-sm`,children:`Advanced repository diagnostics`}),(0,f.jsx)(m,{teamId:e.id},e.id),(0,f.jsx)(p,{teamId:e.id})]}),(0,f.jsx)(g,{team:e,sampleAgent:t[0]?.name??`researcher`,onSaved:()=>h.invalidate(),onDirtyChange:D}),t.length===0&&(0,f.jsx)(_,{teamId:e.id,profileGroups:n,onSpawned:()=>h.invalidate()}),(0,f.jsx)(s,{title:`Roster`,description:`Live Team membership has one canonical management view.`,actions:(0,f.jsxs)(o,{variant:t.length>0?`success`:`neutral`,children:[t.length,` member`,t.length===1?``:`s`]}),children:(0,f.jsx)(`a`,{href:`/teams/${encodeURIComponent(e.id)}/members`,className:`ghost-btn`,children:`Manage Team members`})})]})}function g({team:e,sampleAgent:t,onSaved:n,onDirtyChange:r}){let[i,a]=(0,d.useState)(e.telegramTopicNameFormat??``),[o,s]=(0,d.useState)(!1),[c,u]=(0,d.useState)(null),[p,m]=(0,d.useState)(null),h=i.trim(),g=h?h.replaceAll(`{agent.name}`,t).replaceAll(`{team.name}`,e.name).replaceAll(`{team.slug}`,e.id):e.id==="default"?t:`${e.id} › ${t}`,_=(e.telegramTopicNameFormat??``)!==i;(0,d.useEffect)(()=>(r(_),()=>r(!1)),[_,r]);async function v(t){s(!0),u(null);try{let r=await fetch(`/api/teams/${encodeURIComponent(e.id)}/topic-format`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({format:t?null:i})});if(!r.ok){let e=await r.json().catch(()=>({}));throw Error(e.error??`${r.status} ${r.statusText}`)}t&&a(``),m(Date.now()),n()}catch(e){u(e.message)}finally{s(!1)}}return(0,f.jsxs)(`section`,{className:`rounded-lg border bg-card p-5 mb-6`,children:[(0,f.jsx)(`h3`,{className:`font-serif text-xl mb-1`,children:`Telegram topic names`}),(0,f.jsxs)(`p`,{className:`text-muted-foreground text-sm mb-3`,children:[`Template for this team's Telegram forum-topic titles. Leave empty for built-in naming. Tokens: `,(0,f.jsx)(`code`,{className:`font-mono`,children:`{agent.name}`}),` `,(0,f.jsx)(`code`,{className:`font-mono`,children:`{team.name}`}),` `,(0,f.jsx)(`code`,{className:`font-mono`,children:`{team.slug}`}),` — must include`,` `,(0,f.jsx)(`code`,{className:`font-mono`,children:`{agent.name}`}),`. Saving renames existing topics that you haven't manually renamed in Telegram.`]}),(0,f.jsx)(`label`,{htmlFor:`team-telegram-topic-format`,className:`sr-only`,children:`Telegram topic name format`}),(0,f.jsx)(`input`,{id:`team-telegram-topic-format`,value:i,onChange:e=>a(e.target.value),placeholder:`{team.name} / {agent.name}`,className:`w-full rounded-md border bg-background px-3 py-2 font-mono text-sm outline-none focus:ring-2 focus:ring-ring/30`}),(0,f.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-2`,children:[`preview: `,(0,f.jsx)(`span`,{className:`font-mono text-foreground`,children:g})]}),(0,f.jsxs)(`div`,{className:`flex items-center gap-3 mt-3`,children:[(0,f.jsx)(l,{variant:`primary`,onClick:()=>v(!1),disabled:o||!_||h.length===0,children:o?`saving…`:`save`}),e.telegramTopicNameFormat&&(0,f.jsx)(l,{variant:`ghost`,onClick:()=>v(!0),disabled:o,children:`clear`}),p&&(0,f.jsx)(`span`,{role:`status`,className:`text-xs text-success`,children:`Saved`}),c&&(0,f.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:c})]})]})}function _({teamId:e,profileGroups:t,onSpawned:n}){let r=t.filter(e=>e.slotCount>0&&!e.deletedAt),[i,a]=(0,d.useState)(r[0]?.id??``),[o,s]=(0,d.useState)(!1),[c,u]=(0,d.useState)(null);async function p(){if(i){s(!0),u(null);try{let t=r.find(e=>e.id===i);if(!t)throw Error(`Team template is unavailable.`);let a=await fetch(`/api/teams/${encodeURIComponent(e)}/policy`);if(!a.ok)throw Error(`The current Team policy is unavailable.`);let o=await a.json(),s=await fetch(`/api/team-templates/${encodeURIComponent(i)}/spawn`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({templateExpectedRevision:t.currentRevision,teamId:e,teamExpectedRevision:o.teamPolicy.revision,mode:`initialize`})});if(!s.ok){let e=await s.json().catch(()=>({}));throw Error(e.error??`${s.status} ${s.statusText}`)}n()}catch(e){u(e.message)}finally{s(!1)}}}return(0,f.jsxs)(`section`,{className:`rounded-lg border bg-card p-5 mb-6`,children:[(0,f.jsx)(`h3`,{className:`font-serif text-xl mb-1`,children:`spawn a team into this team`}),(0,f.jsx)(`p`,{className:`text-muted-foreground text-sm mb-3`,children:`This Team is empty. Pick a canonical Team template to initialize its roster and policy at the current reviewed Team and Team revisions.`}),r.length===0?(0,f.jsxs)(`p`,{className:`text-muted-foreground text-sm`,children:[`No Team templates with slots yet. Build one on`,` `,(0,f.jsx)(`a`,{href:`/templates/teams`,className:`text-primary underline`,children:`Team templates`}),` `,`first.`]}):(0,f.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,f.jsxs)(`label`,{className:`m-0 flex min-w-0 flex-1 flex-col gap-1 text-sm text-foreground`,children:[`Team template`,(0,f.jsx)(`select`,{value:i,onChange:e=>a(e.target.value),className:`min-w-0 rounded-md border bg-background px-3 py-2 text-sm outline-none focus:ring-2 focus:ring-ring/30`,children:r.map(e=>(0,f.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.slotCount,` slot`,e.slotCount===1?``:`s`,`, r`,e.currentRevision,`)`]},e.id))})]}),(0,f.jsx)(l,{variant:`primary`,onClick:p,disabled:o||!i,children:o?`spawning…`:`spawn team`}),c&&(0,f.jsx)(`span`,{role:`alert`,className:`basis-full text-xs text-danger`,children:c})]})]})}export{h as component};
1
+ import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{d as r}from"./preload-helper-bztXdkDj.js";import{t as i}from"./UnsavedChangesGuard-CPRtFReU.js";import{E as a}from"./index-Bi-HxcPG.js";import{a as o,i as s,r as c}from"./Page-NV96O47A.js";import{t as l}from"./Button-ByiV6fpd.js";import{t as u}from"./TeamTabs-BmTZRI4T.js";var d=e(n(),1),f=t();function p({teamId:e}){let[t,n]=(0,d.useState)(null),[r,i]=(0,d.useState)(``),[a,o]=(0,d.useState)(`.`),[s,c]=(0,d.useState)(``),[u,p]=(0,d.useState)(!1),m=`/api/teams/${encodeURIComponent(e)}/coding-environment`;return(0,d.useEffect)(()=>{let e=!0;return fetch(m).then(async e=>{if(!e.ok)throw Error(`Defaults unavailable`);return e.json()}).then(t=>{e&&(n(t),i(t.environment?.config.image??t.image),o(t.environment?.config.cwd??`.`))}).catch(t=>{e&&c(t.message)}),()=>{e=!1}},[m]),(0,f.jsxs)(`details`,{className:`border-t mt-4 pt-4`,children:[(0,f.jsx)(`summary`,{className:`cursor-pointer text-sm`,children:`Optional protected runtime defaults`}),(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground my-3`,children:`Agents discover commands during the task. Override the installation image only if this repository needs a different prepared toolchain. Host turns do not use these Docker defaults.`}),s&&(0,f.jsx)(`p`,{role:`alert`,children:s}),t&&(0,f.jsxs)(`form`,{className:`space-y-3`,onSubmit:async e=>{e.preventDefault(),p(!0),c(``);try{let e=await fetch(m,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({expectedRevision:t.environment?.revision??0,config:{image:r,cwd:a,env:t.environment?.config.env??{}}})}),i=await e.json();if(!e.ok)throw Error(i.error);n({...t,environment:i,image:r})}catch(e){c(e instanceof Error?e.message:`Save failed`)}finally{p(!1)}},children:[(0,f.jsxs)(`label`,{className:`block text-sm`,children:[`Local Docker image`,(0,f.jsx)(`input`,{required:!0,value:r,onChange:e=>i(e.target.value),className:`block w-full rounded border p-2 mt-1`})]}),(0,f.jsxs)(`label`,{className:`block text-sm`,children:[`Default directory`,(0,f.jsx)(`input`,{required:!0,value:a,onChange:e=>o(e.target.value),className:`block w-full rounded border p-2 mt-1`})]}),(0,f.jsx)(l,{type:`submit`,variant:`primary`,disabled:u,children:u?`Saving…`:`Save defaults`})]})]})}function m({teamId:e}){let[t,n]=(0,d.useState)(``),[r,i]=(0,d.useState)(null),[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(null),u=(0,d.useRef)(0),p=r?.report,m=p?[...new Map([...p.instructions.issues,...p.commands.issues,...p.git.issues].map(e=>[JSON.stringify([e.path,e.message]),e])).values()]:[];async function h(){let n=++u.current,r=t||`.`;o(!0),c(null);try{let t=await fetch(`/api/teams/${encodeURIComponent(e)}/repository-context?target=${encodeURIComponent(r)}`,{cache:`no-store`});if(!t.ok)throw Error(`Repository context could not be loaded. Refresh to try again.`);let a=await t.json();u.current===n&&i({report:a,target:r})}catch(e){u.current===n&&c(e instanceof Error?e.message:`Inspection failed`)}finally{u.current===n&&o(!1)}}return(0,d.useEffect)(()=>(h(),()=>{u.current++}),[e]),(0,f.jsxs)(`section`,{className:`min-w-0`,"aria-labelledby":`repository-context-heading`,children:[(0,f.jsx)(`h2`,{id:`repository-context-heading`,className:`font-serif text-xl mb-1`,children:`Explore the repository`}),(0,f.jsx)(`p`,{className:`text-muted-foreground text-sm mb-3`,children:`See the instructions and commands for the part of the project you’re working on.`}),(0,f.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),h()},className:`flex flex-wrap gap-2 items-end mb-3`,children:[(0,f.jsxs)(`label`,{className:`flex-1 min-w-[12rem] m-0 text-sm`,children:[`Project path`,(0,f.jsx)(`input`,{value:t,onChange:e=>n(e.target.value),placeholder:`. (Team root)`,maxLength:4096,className:`mt-1 block w-full rounded-md border bg-background px-3 py-2 font-mono text-sm`})]}),(0,f.jsx)(l,{type:`submit`,variant:`primary`,disabled:a,children:a?`Inspecting…`:p?`Refresh context`:`Inspect repository`})]}),s&&(0,f.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger mb-3`,children:[s,` `,p?`The report below is the previous capture.`:``]}),p&&r&&(0,f.jsxs)(`div`,{className:`space-y-3 text-sm min-w-0`,"aria-live":`polite`,children:[(0,f.jsxs)(`p`,{className:`text-xs text-muted-foreground break-words`,children:[(0,f.jsx)(`code`,{children:r.target===`.`?`Team root`:r.target}),` · Inspected`,` `,(0,f.jsx)(`time`,{dateTime:new Date(p.capturedAt).toISOString(),children:new Date(p.capturedAt).toLocaleString()}),`. Read-only inspection.`]}),m.length>0&&(0,f.jsxs)(`div`,{role:`status`,className:`border-l-2 border-primary bg-muted/40 px-3 py-2`,children:[(0,f.jsx)(`h3`,{className:`font-sans text-sm font-semibold`,children:`Some context is unavailable`}),(0,f.jsx)(`ul`,{className:`mt-1 space-y-1`,children:m.map((e,t)=>(0,f.jsxs)(`li`,{className:`break-words`,children:[e.path?`${e.path}: `:``,e.message]},t))})]}),(0,f.jsxs)(`div`,{className:`rounded-md bg-muted/40 px-3 py-2`,children:[(0,f.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3 gap-y-1`,children:[(0,f.jsx)(`h3`,{className:`font-sans text-sm font-semibold`,children:p.git.state===`available`?`Working tree`:p.git.state===`not_repository`?`No Git repository`:`Git unavailable`}),p.git.state===`available`&&(0,f.jsxs)(`p`,{className:`min-w-0 break-all`,children:[(0,f.jsx)(`span`,{className:`font-mono`,children:p.git.branch??`Detached HEAD`}),(0,f.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,`· `,p.git.head?.slice(0,8)??`No commits yet`]})]})]}),p.git.state===`available`&&(0,f.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:[p.git.staged,` staged · `,p.git.unstaged,` unstaged · `,p.git.untracked,` `,`untracked · `,p.git.conflicted,` conflicted`]})]}),(0,f.jsxs)(`div`,{children:[(0,f.jsxs)(`h3`,{className:`font-sans text-sm font-semibold`,children:[`Instructions`,` `,(0,f.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`· `,p.instructions.files.length,` files`,p.instructions.state===`complete`?``:` · incomplete`]})]}),(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Listed from broadest to most specific. Operator instructions and runtime policy take priority.`}),p.instructions.files.length===0&&(0,f.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:p.instructions.state===`complete`?`No applicable AGENTS.md files found.`:`Instructions for this scope could not be prepared.`}),(0,f.jsx)(`div`,{className:`mt-2 divide-y`,children:p.instructions.files.map(e=>(0,f.jsxs)(`details`,{className:`py-2 min-w-0`,children:[(0,f.jsx)(`summary`,{className:`cursor-pointer break-words font-mono text-sm`,children:e.path}),(0,f.jsx)(`pre`,{className:`mt-2 rounded-md bg-muted/40 p-3 whitespace-pre-wrap break-words text-xs max-h-80 overflow-auto`,children:e.content})]},e.path))})]}),(0,f.jsxs)(`div`,{className:`border-t pt-3`,children:[(0,f.jsx)(`h3`,{className:`font-sans text-sm font-semibold`,children:`Suggested commands`}),(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Source suggestions for Agent investigation; inspection never executes commands.`}),p.commands.candidates.length===0&&(0,f.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:`No command suggestions available for this scope.`}),(0,f.jsx)(`ul`,{className:`mt-1 divide-y`,children:p.commands.candidates.map((e,t)=>(0,f.jsxs)(`li`,{className:`py-2 min-w-0`,children:[(0,f.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:(0,f.jsx)(`code`,{className:`block bg-transparent p-0 whitespace-pre-wrap break-words min-w-0`,children:e.command})}),(0,f.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-1 break-words`,children:[e.source,` · `,e.location,` · cwd `,e.cwd,e.kind===`script`?` · ${e.packageManager??`package manager unknown`}`:` · documentation excerpt`]})]},`${e.source}:${t}`))})]}),(0,f.jsxs)(`details`,{className:`border-t pt-3 text-xs text-muted-foreground`,children:[(0,f.jsx)(`summary`,{className:`cursor-pointer`,children:`Source details and fingerprints`}),(0,f.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,f.jsx)(`p`,{children:`Deeper repository instructions apply within their own subtree. Private Agent instructions are managed on each Agent.`}),(0,f.jsxs)(`p`,{className:`break-all`,children:[`Snapshot SHA-256: `,p.fingerprint]}),p.git.head&&(0,f.jsxs)(`p`,{className:`break-all`,children:[`Git commit: `,p.git.head]}),p.instructions.files.map(e=>(0,f.jsxs)(`p`,{className:`break-all`,children:[(0,f.jsx)(`span`,{className:`font-mono`,children:e.path}),` · Scope: `,e.scope,` · Precedence:`,` `,e.precedence,(0,f.jsx)(`br`,{}),`SHA-256: `,e.sha256]},e.path)),p.commands.sources.map(e=>(0,f.jsxs)(`p`,{className:`break-all`,children:[(0,f.jsx)(`span`,{className:`font-mono`,children:e.path}),(0,f.jsx)(`br`,{}),`SHA-256: `,e.sha256]},e.path))]})]})]})]})}function h(){let{team:e,members:t,profileGroups:n}=a.useLoaderData(),h=r(),[v,y]=(0,d.useState)(e.userMd),[b,x]=(0,d.useState)(!1),[S,C]=(0,d.useState)(null),[w,T]=(0,d.useState)(null),[E,D]=(0,d.useState)(!1),O=v!==e.userMd||E;async function k(){x(!0),C(null);try{let t=await fetch(`/api/teams/${encodeURIComponent(e.id)}/user-md`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({userMd:v})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`${t.status} ${t.statusText}`)}T(Date.now()),await h.invalidate()}catch(e){C(e.message)}finally{x(!1)}}return(0,f.jsxs)(c,{children:[(0,f.jsx)(i,{when:O,subject:`Team context`}),(0,f.jsxs)(`h1`,{className:`font-serif text-3xl text-foreground`,children:[e.name,` `,(0,f.jsxs)(`span`,{className:`text-muted-foreground text-base`,children:[`(`,e.id,`)`]})]}),(0,f.jsxs)(`p`,{className:`text-muted-foreground text-sm mb-6 mt-1`,children:[(0,f.jsx)(`code`,{className:`font-mono`,children:e.path}),` · `,t.length,` `,`member`,t.length===1?``:`s`,` ·`,` `,(0,f.jsx)(`a`,{href:`/teams/${encodeURIComponent(e.id)}/memory`,className:`text-primary underline`,children:`shared memory →`})]}),(0,f.jsx)(u,{teamId:e.id}),(0,f.jsxs)(`section`,{className:`rounded-lg border bg-card p-5 mb-6`,children:[(0,f.jsx)(`h3`,{className:`font-serif text-xl mb-1`,children:`USER.md`}),(0,f.jsx)(`p`,{className:`text-muted-foreground text-sm mb-3`,children:`Read-only context about the human, injected into every member agent's system prompt. 12 KB cap. Agents cannot edit this file — only you can.`}),(0,f.jsx)(`label`,{htmlFor:`team-user-context`,className:`sr-only`,children:`USER.md Team context`}),(0,f.jsx)(`textarea`,{id:`team-user-context`,value:v,onChange:e=>y(e.target.value),rows:16,className:`w-full rounded-md border bg-background px-3 py-2 font-mono text-sm outline-none focus:ring-2 focus:ring-ring/30`,placeholder:`What the agent should know about you in this team context…`}),(0,f.jsxs)(`div`,{className:`flex items-center gap-3 mt-3`,children:[(0,f.jsx)(l,{variant:`primary`,onClick:k,disabled:b||v===e.userMd,children:b?`saving…`:`save`}),(0,f.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[v.length,` / 12000 chars`]}),w&&(0,f.jsx)(`span`,{role:`status`,className:`text-xs text-success`,children:`Saved`}),S&&(0,f.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:S})]})]}),(0,f.jsxs)(`details`,{className:`mb-6 rounded-lg border bg-card p-4`,children:[(0,f.jsx)(`summary`,{className:`cursor-pointer text-sm`,children:`Advanced repository diagnostics`}),(0,f.jsx)(m,{teamId:e.id},e.id),(0,f.jsx)(p,{teamId:e.id})]}),(0,f.jsx)(g,{team:e,sampleAgent:t[0]?.name??`researcher`,onSaved:()=>h.invalidate(),onDirtyChange:D}),t.length===0&&(0,f.jsx)(_,{teamId:e.id,profileGroups:n,onSpawned:()=>h.invalidate()}),(0,f.jsx)(s,{title:`Roster`,description:`Live Team membership has one canonical management view.`,actions:(0,f.jsxs)(o,{variant:t.length>0?`success`:`neutral`,children:[t.length,` member`,t.length===1?``:`s`]}),children:(0,f.jsx)(`a`,{href:`/teams/${encodeURIComponent(e.id)}/members`,className:`ghost-btn`,children:`Manage Team members`})})]})}function g({team:e,sampleAgent:t,onSaved:n,onDirtyChange:r}){let[i,a]=(0,d.useState)(e.telegramTopicNameFormat??``),[o,s]=(0,d.useState)(!1),[c,u]=(0,d.useState)(null),[p,m]=(0,d.useState)(null),h=i.trim(),g=h?h.replaceAll(`{agent.name}`,t).replaceAll(`{team.name}`,e.name).replaceAll(`{team.slug}`,e.id):e.id==="default"?t:`${e.id} › ${t}`,_=(e.telegramTopicNameFormat??``)!==i;(0,d.useEffect)(()=>(r(_),()=>r(!1)),[_,r]);async function v(t){s(!0),u(null);try{let r=await fetch(`/api/teams/${encodeURIComponent(e.id)}/topic-format`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({format:t?null:i})});if(!r.ok){let e=await r.json().catch(()=>({}));throw Error(e.error??`${r.status} ${r.statusText}`)}t&&a(``),m(Date.now()),n()}catch(e){u(e.message)}finally{s(!1)}}return(0,f.jsxs)(`section`,{className:`rounded-lg border bg-card p-5 mb-6`,children:[(0,f.jsx)(`h3`,{className:`font-serif text-xl mb-1`,children:`Telegram topic names`}),(0,f.jsxs)(`p`,{className:`text-muted-foreground text-sm mb-3`,children:[`Template for this team's Telegram forum-topic titles. Leave empty for built-in naming. Tokens: `,(0,f.jsx)(`code`,{className:`font-mono`,children:`{agent.name}`}),` `,(0,f.jsx)(`code`,{className:`font-mono`,children:`{team.name}`}),` `,(0,f.jsx)(`code`,{className:`font-mono`,children:`{team.slug}`}),` — must include`,` `,(0,f.jsx)(`code`,{className:`font-mono`,children:`{agent.name}`}),`. Saving renames existing topics that you haven't manually renamed in Telegram.`]}),(0,f.jsx)(`label`,{htmlFor:`team-telegram-topic-format`,className:`sr-only`,children:`Telegram topic name format`}),(0,f.jsx)(`input`,{id:`team-telegram-topic-format`,value:i,onChange:e=>a(e.target.value),placeholder:`{team.name} / {agent.name}`,className:`w-full rounded-md border bg-background px-3 py-2 font-mono text-sm outline-none focus:ring-2 focus:ring-ring/30`}),(0,f.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-2`,children:[`preview: `,(0,f.jsx)(`span`,{className:`font-mono text-foreground`,children:g})]}),(0,f.jsxs)(`div`,{className:`flex items-center gap-3 mt-3`,children:[(0,f.jsx)(l,{variant:`primary`,onClick:()=>v(!1),disabled:o||!_||h.length===0,children:o?`saving…`:`save`}),e.telegramTopicNameFormat&&(0,f.jsx)(l,{variant:`ghost`,onClick:()=>v(!0),disabled:o,children:`clear`}),p&&(0,f.jsx)(`span`,{role:`status`,className:`text-xs text-success`,children:`Saved`}),c&&(0,f.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:c})]})]})}function _({teamId:e,profileGroups:t,onSpawned:n}){let r=t.filter(e=>e.slotCount>0&&!e.deletedAt),[i,a]=(0,d.useState)(r[0]?.id??``),[o,s]=(0,d.useState)(!1),[c,u]=(0,d.useState)(null);async function p(){if(i){s(!0),u(null);try{let t=r.find(e=>e.id===i);if(!t)throw Error(`Team template is unavailable.`);let a=await fetch(`/api/teams/${encodeURIComponent(e)}/policy`);if(!a.ok)throw Error(`The current Team policy is unavailable.`);let o=await a.json(),s=await fetch(`/api/team-templates/${encodeURIComponent(i)}/spawn`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({templateExpectedRevision:t.currentRevision,teamId:e,teamExpectedRevision:o.teamPolicy.revision,mode:`initialize`})});if(!s.ok){let e=await s.json().catch(()=>({}));throw Error(e.error??`${s.status} ${s.statusText}`)}n()}catch(e){u(e.message)}finally{s(!1)}}}return(0,f.jsxs)(`section`,{className:`rounded-lg border bg-card p-5 mb-6`,children:[(0,f.jsx)(`h3`,{className:`font-serif text-xl mb-1`,children:`spawn a team into this team`}),(0,f.jsx)(`p`,{className:`text-muted-foreground text-sm mb-3`,children:`This Team is empty. Pick a canonical Team template to initialize its roster and policy at the current reviewed Team and Team revisions.`}),r.length===0?(0,f.jsxs)(`p`,{className:`text-muted-foreground text-sm`,children:[`No Team templates with slots yet. Build one on`,` `,(0,f.jsx)(`a`,{href:`/templates/teams`,className:`text-primary underline`,children:`Team templates`}),` `,`first.`]}):(0,f.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,f.jsxs)(`label`,{className:`m-0 flex min-w-0 flex-1 flex-col gap-1 text-sm text-foreground`,children:[`Team template`,(0,f.jsx)(`select`,{value:i,onChange:e=>a(e.target.value),className:`min-w-0 rounded-md border bg-background px-3 py-2 text-sm outline-none focus:ring-2 focus:ring-ring/30`,children:r.map(e=>(0,f.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.slotCount,` slot`,e.slotCount===1?``:`s`,`, r`,e.currentRevision,`)`]},e.id))})]}),(0,f.jsx)(l,{variant:`primary`,onClick:p,disabled:o||!i,children:o?`spawning…`:`spawn team`}),c&&(0,f.jsx)(`span`,{role:`alert`,className:`basis-full text-xs text-danger`,children:c})]})]})}export{h as component};
@@ -0,0 +1 @@
1
+ import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{ot as r,s as i}from"./index-Bi-HxcPG.js";import{r as a}from"./Page-NV96O47A.js";import{t as o}from"./Button-ByiV6fpd.js";import{t as s}from"./TeamTabs-BmTZRI4T.js";var c=e(n()),l=t();function u(){let e=i.useLoaderData(),{id:t}=i.useParams(),[n,r]=(0,c.useState)(e),[u,f]=(0,c.useState)(!1),[p,m]=(0,c.useState)(null);return(0,l.jsxs)(a,{children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h1`,{children:`Blocked communication`}),(0,l.jsx)(`p`,{className:`muted`,children:`Durable denial evidence. Diagnostic simulations never create these records.`})]}),(0,l.jsx)(s,{teamId:t}),(0,l.jsxs)(`div`,{className:`space-y-3`,children:[n.blocks.map(e=>(0,l.jsx)(d,{block:e},e.id)),n.blocks.length===0&&(0,l.jsx)(`p`,{className:`card muted`,children:`No blocked communication has been recorded for this team.`})]}),p&&(0,l.jsx)(`p`,{role:`alert`,className:`err`,children:p}),n.nextCursor&&(0,l.jsx)(o,{variant:`ghost`,disabled:u,onClick:async()=>{if(n.nextCursor){f(!0),m(null);try{let e=await fetch(`/api/teams/${encodeURIComponent(t)}/policy/blocks?limit=25&cursor=${encodeURIComponent(n.nextCursor)}`);if(!e.ok)throw Error(`Could not load activity (${e.status})`);let i=await e.json();r({blocks:[...n.blocks,...i.blocks],nextCursor:i.nextCursor})}catch(e){m(e instanceof Error?e.message:String(e))}finally{f(!1)}}},children:u?`Loading…`:`Load older evidence`})]})}function d({block:e}){return(0,l.jsxs)(`details`,{className:`card team`,children:[(0,l.jsxs)(`summary`,{className:`flex cursor-pointer list-none flex-wrap items-center gap-2`,children:[(0,l.jsx)(`strong`,{className:`mr-auto break-all`,children:e.reason_code}),(0,l.jsx)(`time`,{className:`text-xs text-mocha-light`,children:new Date(e.created_at).toLocaleString()}),(0,l.jsx)(r,{className:`h-4 w-4 transition-transform team-open:rotate-180`})]}),(0,l.jsxs)(`dl`,{className:`mt-4 grid gap-3 text-sm sm:grid-cols-2`,children:[(0,l.jsx)(f,{label:`Path`,value:`${p(e.source_kind,e.source_id)} → ${p(e.target_kind,e.target_id)}`}),(0,l.jsx)(f,{label:`Channel / origin`,value:`${e.channel} · ${e.origin}`}),(0,l.jsx)(f,{label:`Operation`,value:e.operation}),(0,l.jsx)(f,{label:`Attempt identity`,value:`${e.attempt_kind}:${e.attempt_id}`,code:!0}),(0,l.jsx)(f,{label:`Reason`,value:e.reason,wide:!0})]}),(0,l.jsx)(`h3`,{className:`mt-5 text-sm`,children:`Policy revisions`}),(0,l.jsx)(`ul`,{className:`mt-2 text-sm`,children:e.policyRefs.map(e=>(0,l.jsxs)(`li`,{children:[(0,l.jsx)(`code`,{children:e.teamId}),` revision `,e.revision]},`${e.teamId}:${e.revision}`))}),e.componentOutcomes.length>1&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`h3`,{className:`mt-5 text-sm`,children:`Cross-Team consent components`}),(0,l.jsx)(`div`,{className:`mt-2 overflow-x-auto`,children:(0,l.jsxs)(`table`,{children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{children:`Team`}),(0,l.jsx)(`th`,{children:`Required edge`}),(0,l.jsx)(`th`,{children:`Matched`})]})}),(0,l.jsx)(`tbody`,{children:e.componentOutcomes.map(e=>(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{children:(0,l.jsx)(`code`,{children:e.teamId})}),(0,l.jsx)(`td`,{className:`break-all`,children:(0,l.jsx)(`code`,{children:e.edge})}),(0,l.jsx)(`td`,{children:e.matched?`yes`:`no`})]},`${e.teamId}:${e.edge}`))})]})})]}),(0,l.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[(0,l.jsx)(f,{label:`Required edges`,value:e.requiredEdgeIds.join(`, `)||`none`,code:!0}),(0,l.jsx)(f,{label:`Matched edges`,value:e.matchedEdgeIds.join(`, `)||`none`,code:!0})]})]})}function f({label:e,value:t,code:n=!1,wide:r=!1}){return(0,l.jsxs)(`div`,{className:r?`sm:col-span-2`:``,children:[(0,l.jsx)(`dt`,{className:`text-xs font-semibold uppercase text-mocha-light`,children:e}),(0,l.jsx)(`dd`,{className:`mt-1 break-words`,children:n?(0,l.jsx)(`code`,{className:`break-all`,children:t}):t})]})}function p(e,t){return t?`${e}:${t}`:e}export{u as component};
@@ -1 +1 @@
1
- import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{d as r}from"./preload-helper-bztXdkDj.js";import{t as i}from"./UnsavedChangesGuard-BCsLw-mU.js";import{t as a}from"./ProfileCommunicationEditor-DArXub0b.js";import{t as o}from"./ConfirmDialog-MicTTwdy.js";import{m as s}from"./index-Bq2zrG2_.js";import{n as c,r as l}from"./Page-NV96O47A.js";import{t as u}from"./Button-ByiV6fpd.js";import{t as d}from"./team-policy-D0jpnn2b.js";import{t as f}from"./TemplatesTabs-CatJIjGi.js";var p=e(n()),m=t();function h(){let{profiles:e,modelGroups:t,skills:n,templates:i}=s.useLoaderData(),a=r(),[d,h]=(0,p.useState)(null),[_,v]=(0,p.useState)(null);async function y(e){let t=await fetch(`/api/profiles/${encodeURIComponent(e)}`,{method:`DELETE`});if(!t.ok&&t.status!==204){let e=await t.json().catch(()=>null);throw Error(e?.error??t.statusText)}await a.invalidate()}return(0,m.jsxs)(l,{size:`wide`,children:[(0,m.jsx)(c,{eyebrow:`Templates`,title:`Agent templates`,description:`Define reusable identity, model, skills, and communication defaults for newly spawned agents.`}),_&&(0,m.jsx)(`p`,{role:`alert`,className:`err`,children:_}),(0,m.jsx)(f,{}),(0,m.jsx)(g,{modelGroups:t,skills:n,templates:i,onCreated:()=>a.invalidate()}),(0,m.jsx)(`div`,{className:`overflow-x-auto`,children:(0,m.jsxs)(`table`,{children:[(0,m.jsx)(`thead`,{children:(0,m.jsxs)(`tr`,{children:[(0,m.jsx)(`th`,{children:`id`}),(0,m.jsx)(`th`,{children:`name`}),(0,m.jsx)(`th`,{children:`model`}),(0,m.jsx)(`th`,{children:`agents`}),(0,m.jsx)(`th`,{children:`skills`}),(0,m.jsx)(`th`,{})]})}),(0,m.jsxs)(`tbody`,{children:[e.length===0&&(0,m.jsx)(`tr`,{children:(0,m.jsx)(`td`,{colSpan:6,className:`muted`,children:`no agent templates yet`})}),e.map(e=>{let t=e.skillsMode===`all`?`all`:e.defaultSkills.length===0?`—`:e.defaultSkills.join(`, `);return(0,m.jsxs)(`tr`,{children:[(0,m.jsx)(`td`,{children:(0,m.jsx)(`a`,{href:`/templates/agents/${e.id}`,children:(0,m.jsx)(`code`,{children:e.id})})}),(0,m.jsx)(`td`,{children:e.name}),(0,m.jsx)(`td`,{children:(0,m.jsx)(`code`,{children:e.defaultModel})}),(0,m.jsx)(`td`,{children:e.agentCount}),(0,m.jsx)(`td`,{className:`text-xs text-mocha-light`,children:t}),(0,m.jsx)(`td`,{children:e.agentCount===0?(0,m.jsx)(u,{variant:`danger`,onClick:()=>{v(null),h(e)},children:`delete`}):(0,m.jsx)(`span`,{className:`muted`,title:`${e.agentCount} agent(s) use this profile`,children:`in use`})})]},e.id)})]})]})}),(0,m.jsx)(o,{open:d!==null,title:`Delete Agent template ${d?.name??``}?`,description:(0,m.jsxs)(`p`,{children:[`This permanently deletes `,(0,m.jsx)(`code`,{className:`font-mono`,children:d?.id}),` and all of its template files. It cannot be restored. Existing Agents keep their own copies.`]}),confirmLabel:`delete Agent template`,onConfirm:async()=>{if(d)try{await y(d.id)}catch(e){throw v(e instanceof Error?e.message:String(e)),e}},onOpenChange:e=>{e||h(null)}})]})}function g({modelGroups:e,skills:t,templates:n,onCreated:r}){let[o,s]=(0,p.useState)(`basics`),[c,l]=(0,p.useState)(``),[f,h]=(0,p.useState)(``),[g,y]=(0,p.useState)(``),[b,x]=(0,p.useState)(n.soul),[S,C]=(0,p.useState)(n.identity),[w,T]=(0,p.useState)(n.bootstrap),[E,D]=(0,p.useState)(!0),[O,k]=(0,p.useState)(n.agents),[A,j]=(0,p.useState)(!0),[M,N]=(0,p.useState)(n.tools),[P,F]=(0,p.useState)(!0);function I(e,t,n){t(n),!n&&o===e&&s(`basics`)}let[L,R]=(0,p.useState)(`all`),[z,B]=(0,p.useState)(d),[V,H]=(0,p.useState)(new Set),[U,W]=(0,p.useState)(null),[G,K]=(0,p.useState)(!1),q=c.length>0||f.length>0||g.length>0||b!==n.soul||S!==n.identity||w!==n.bootstrap||!E||O!==n.agents||!A||M!==n.tools||!P||L!==`all`||V.size>0||JSON.stringify(z)!==JSON.stringify(d);function J(e){H(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}async function Y(e){if(e.preventDefault(),W(null),!c.trim()){W(`id is required`);return}if(!g.trim()){W(`default model is required`);return}K(!0);try{let e={id:c.trim(),name:f.trim()||void 0,model:g.trim(),skillsMode:L,defaultSkills:L===`selected`?Array.from(V):[],soul:b,identity:S,bootstrap:E?w:null,agents:A?O:null,tools:P?M:null,communicationDefaults:z},t=await fetch(`/api/profiles`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error??t.statusText)}l(``),h(``),y(``),x(n.soul),C(n.identity),T(n.bootstrap),D(!0),k(n.agents),j(!0),N(n.tools),F(!0),H(new Set),R(`all`),B(d),s(`basics`),r()}catch(e){W(e.message)}finally{K(!1)}}return(0,m.jsxs)(`form`,{className:`card`,onSubmit:Y,children:[(0,m.jsx)(i,{when:q&&!G,subject:`Agent template draft`}),(0,m.jsx)(`h3`,{children:`create agent template`}),U&&(0,m.jsx)(`div`,{role:`alert`,className:`err`,children:U}),(0,m.jsx)(_,{items:[{id:`basics`,label:`basics`},{id:`soul`,label:`SOUL`},{id:`identity`,label:`IDENTITY`},{id:`bootstrap`,label:`BOOTSTRAP`,disabled:!E},{id:`agents`,label:`AGENTS`,disabled:!A},{id:`tools`,label:`TOOLS`,disabled:!P},{id:`skills`,label:`skills`},{id:`communication`,label:`communication`}],active:o,onChange:e=>s(e)}),(0,m.jsxs)(`fieldset`,{className:`mb-5 rounded-md border border-frost p-3`,children:[(0,m.jsx)(`legend`,{className:`px-1 text-[0.85em] font-medium text-mocha`,children:`templates to include`}),(0,m.jsxs)(`div`,{className:`flex flex-wrap gap-x-5 gap-y-2 text-[0.9em]`,children:[(0,m.jsxs)(`label`,{className:`inline-flex items-center gap-1.5 opacity-60`,title:`always included`,children:[(0,m.jsx)(`input`,{type:`checkbox`,defaultChecked:!0,disabled:!0}),` SOUL.md`]}),(0,m.jsxs)(`label`,{className:`inline-flex items-center gap-1.5 opacity-60`,title:`always included`,children:[(0,m.jsx)(`input`,{type:`checkbox`,defaultChecked:!0,disabled:!0}),` IDENTITY.md`]}),(0,m.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1.5`,children:[(0,m.jsx)(`input`,{type:`checkbox`,checked:E,onChange:e=>I(`bootstrap`,D,e.target.checked)}),`BOOTSTRAP.md`]}),(0,m.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1.5`,children:[(0,m.jsx)(`input`,{type:`checkbox`,checked:A,onChange:e=>I(`agents`,j,e.target.checked)}),`AGENTS.md`]}),(0,m.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1.5`,children:[(0,m.jsx)(`input`,{type:`checkbox`,checked:P,onChange:e=>I(`tools`,F,e.target.checked)}),`TOOLS.md`]})]}),(0,m.jsx)(`p`,{className:`muted mt-2 text-[0.8em]`,children:`Disabled files aren't created for this Agent template. Each spawned agent gets its own copy of the enabled files at spawn time.`})]}),o===`basics`&&(0,m.jsxs)(`div`,{children:[(0,m.jsxs)(`div`,{className:`flex gap-4`,children:[(0,m.jsxs)(`label`,{className:`flex-1`,children:[`id (slug)`,(0,m.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),required:!0})]}),(0,m.jsxs)(`label`,{className:`flex-1`,children:[`name`,(0,m.jsx)(`input`,{value:f,onChange:e=>h(e.target.value)})]})]}),(0,m.jsxs)(`label`,{children:[`default model`,e.length===0?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`select`,{disabled:!0,children:(0,m.jsx)(`option`,{children:`(no models available)`})}),(0,m.jsxs)(`span`,{className:`muted text-[0.85em]`,children:[`Enable a provider and curate models on `,(0,m.jsx)(`a`,{href:`/config`,children:`/config`}),` first.`]})]}):(0,m.jsxs)(`select`,{value:g,onChange:e=>y(e.target.value),required:!0,children:[(0,m.jsx)(`option`,{value:``,children:`-- pick a model --`}),e.map(e=>(0,m.jsx)(`optgroup`,{label:e.provider,children:e.models.map(t=>(0,m.jsx)(`option`,{value:`${e.provider}:${t}`,children:`${e.provider}:${t}`},t))},e.provider))]})]})]}),o===`soul`&&(0,m.jsx)(v,{label:`SOUL.md`,hint:`Persona, values, and operating principles. Injected into every session.`,value:b,onChange:x,rows:16}),o===`identity`&&(0,m.jsx)(v,{label:`IDENTITY.md`,hint:`Name, creature, vibe, emoji, avatar — filled in during the bootstrap ritual.`,value:S,onChange:C,rows:12}),o===`bootstrap`&&(0,m.jsx)(v,{label:`BOOTSTRAP.md`,hint:`One-time first-run ritual. The agent retires it once introductions are done.`,value:w,onChange:T,rows:16}),o===`agents`&&(0,m.jsx)(v,{label:`AGENTS.md`,hint:`The workspace operating manual — memory discipline, red lines, channel etiquette.`,value:O,onChange:k,rows:16}),o===`tools`&&(0,m.jsx)(v,{label:`TOOLS.md`,hint:`Agent-specific tool notes and environment facts beyond the generic tool descriptions.`,value:M,onChange:N,rows:14}),o===`skills`&&(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`p`,{className:`muted my-2`,children:`Choose which skills agents inherit at spawn time. In both modes each agent can still attach or detach skills individually after it's spawned.`}),(0,m.jsxs)(`label`,{className:`flex items-start gap-2 my-2 cursor-pointer`,children:[(0,m.jsx)(`input`,{type:`radio`,name:`skillsMode`,value:`all`,checked:L===`all`,onChange:()=>R(`all`)}),(0,m.jsxs)(`span`,{children:[(0,m.jsx)(`strong`,{children:`allow all skills`}),` — every skill on disk is attached when an agent is spawned.`]})]}),(0,m.jsxs)(`label`,{className:`flex items-start gap-2 my-2 cursor-pointer`,children:[(0,m.jsx)(`input`,{type:`radio`,name:`skillsMode`,value:`selected`,checked:L===`selected`,onChange:()=>R(`selected`)}),(0,m.jsxs)(`span`,{children:[(0,m.jsx)(`strong`,{children:`select skills`}),` — attach only the ones you pick below.`]})]}),(0,m.jsx)(`div`,{className:`mt-3 max-h-[22rem] overflow-y-auto rounded-md border border-frost p-3 ${L===`all`?`opacity-50 pointer-events-none`:``}`,children:t.length===0?(0,m.jsxs)(`p`,{className:`muted`,children:[`No skills installed yet. Import some on `,(0,m.jsx)(`a`,{href:`/skills`,children:`/skills`}),`.`]}):t.map(e=>(0,m.jsxs)(`label`,{className:`my-1.5 flex cursor-pointer items-start gap-2`,children:[(0,m.jsx)(`input`,{type:`checkbox`,checked:V.has(e.name),onChange:()=>J(e.name)}),(0,m.jsxs)(`span`,{children:[(0,m.jsx)(`code`,{children:e.name}),e.description&&(0,m.jsxs)(`span`,{className:`text-[0.9em] text-mocha-light`,children:[` — `,e.description]})]})]},e.name))})]}),o===`communication`&&(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`div`,{className:`mb-3 flex items-center gap-2`,children:(0,m.jsx)(`h4`,{className:`text-sm font-semibold text-chocolate`,children:`Communication defaults`})}),(0,m.jsx)(`p`,{className:`muted mb-4`,children:`Materialized when a Team or live policy snapshot is created. Existing snapshots never inherit later changes.`}),(0,m.jsx)(a,{value:z,onChange:B})]}),(0,m.jsx)(`div`,{className:`mt-5 flex gap-2`,children:(0,m.jsx)(u,{variant:`primary`,type:`submit`,disabled:G,children:G?`creating…`:`create`})})]})}function _({items:e,active:t,onChange:n}){return(0,m.jsx)(`nav`,{role:`tablist`,className:`-mb-px mb-5 flex flex-wrap gap-1 border-b border-frost`,children:e.map(e=>(0,m.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t===e.id,disabled:e.disabled,title:e.disabled?`disabled — enable it in “templates to include”`:void 0,onClick:()=>n(e.id),className:`unstyled border-b-2 bg-transparent px-4 py-2 text-[0.9em] font-medium transition-colors ${e.disabled?`cursor-not-allowed border-transparent text-mocha-light/40`:t===e.id?`cursor-pointer border-sapphire text-sapphire`:`cursor-pointer border-transparent text-mocha hover:text-sapphire`}`,children:e.label},e.id))})}function v({label:e,hint:t,value:n,onChange:r,rows:i}){return(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`p`,{className:`muted my-2 text-[0.85em]`,children:t}),(0,m.jsxs)(`label`,{children:[e,(0,m.jsx)(`textarea`,{rows:i,value:n,onChange:e=>r(e.target.value),className:`font-mono text-[0.88em] leading-[1.55]`})]})]})}export{h as component};
1
+ import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{d as r}from"./preload-helper-bztXdkDj.js";import{t as i}from"./UnsavedChangesGuard-CPRtFReU.js";import{t as a}from"./ProfileCommunicationEditor-DN0fOzqn.js";import{t as o}from"./ConfirmDialog-BzIiABOP.js";import{D as s}from"./index-Bi-HxcPG.js";import{n as c,r as l}from"./Page-NV96O47A.js";import{t as u}from"./Button-ByiV6fpd.js";import{t as d}from"./team-policy-D0jpnn2b.js";import{t as f}from"./TemplatesTabs-Bs_OXKwx.js";var p=e(n()),m=t();function h(){let{profiles:e,modelGroups:t,skills:n,templates:i}=s.useLoaderData(),a=r(),[d,h]=(0,p.useState)(null),[_,v]=(0,p.useState)(null);async function y(e){let t=await fetch(`/api/profiles/${encodeURIComponent(e)}`,{method:`DELETE`});if(!t.ok&&t.status!==204){let e=await t.json().catch(()=>null);throw Error(e?.error??t.statusText)}await a.invalidate()}return(0,m.jsxs)(l,{size:`wide`,children:[(0,m.jsx)(c,{eyebrow:`Templates`,title:`Agent templates`,description:`Define reusable identity, model, skills, and communication defaults for newly spawned agents.`}),_&&(0,m.jsx)(`p`,{role:`alert`,className:`err`,children:_}),(0,m.jsx)(f,{}),(0,m.jsx)(g,{modelGroups:t,skills:n,templates:i,onCreated:()=>a.invalidate()}),(0,m.jsx)(`div`,{className:`overflow-x-auto`,children:(0,m.jsxs)(`table`,{children:[(0,m.jsx)(`thead`,{children:(0,m.jsxs)(`tr`,{children:[(0,m.jsx)(`th`,{children:`id`}),(0,m.jsx)(`th`,{children:`name`}),(0,m.jsx)(`th`,{children:`model`}),(0,m.jsx)(`th`,{children:`agents`}),(0,m.jsx)(`th`,{children:`skills`}),(0,m.jsx)(`th`,{})]})}),(0,m.jsxs)(`tbody`,{children:[e.length===0&&(0,m.jsx)(`tr`,{children:(0,m.jsx)(`td`,{colSpan:6,className:`muted`,children:`no agent templates yet`})}),e.map(e=>{let t=e.skillsMode===`all`?`all`:e.defaultSkills.length===0?`—`:e.defaultSkills.join(`, `);return(0,m.jsxs)(`tr`,{children:[(0,m.jsx)(`td`,{children:(0,m.jsx)(`a`,{href:`/templates/agents/${e.id}`,children:(0,m.jsx)(`code`,{children:e.id})})}),(0,m.jsx)(`td`,{children:e.name}),(0,m.jsx)(`td`,{children:(0,m.jsx)(`code`,{children:e.defaultModel})}),(0,m.jsx)(`td`,{children:e.agentCount}),(0,m.jsx)(`td`,{className:`text-xs text-mocha-light`,children:t}),(0,m.jsx)(`td`,{children:e.agentCount===0?(0,m.jsx)(u,{variant:`danger`,onClick:()=>{v(null),h(e)},children:`delete`}):(0,m.jsx)(`span`,{className:`muted`,title:`${e.agentCount} agent(s) use this profile`,children:`in use`})})]},e.id)})]})]})}),(0,m.jsx)(o,{open:d!==null,title:`Delete Agent template ${d?.name??``}?`,description:(0,m.jsxs)(`p`,{children:[`This permanently deletes `,(0,m.jsx)(`code`,{className:`font-mono`,children:d?.id}),` and all of its template files. It cannot be restored. Existing Agents keep their own copies.`]}),confirmLabel:`delete Agent template`,onConfirm:async()=>{if(d)try{await y(d.id)}catch(e){throw v(e instanceof Error?e.message:String(e)),e}},onOpenChange:e=>{e||h(null)}})]})}function g({modelGroups:e,skills:t,templates:n,onCreated:r}){let[o,s]=(0,p.useState)(`basics`),[c,l]=(0,p.useState)(``),[f,h]=(0,p.useState)(``),[g,y]=(0,p.useState)(``),[b,x]=(0,p.useState)(n.soul),[S,C]=(0,p.useState)(n.identity),[w,T]=(0,p.useState)(n.bootstrap),[E,D]=(0,p.useState)(!0),[O,k]=(0,p.useState)(n.agents),[A,j]=(0,p.useState)(!0),[M,N]=(0,p.useState)(n.tools),[P,F]=(0,p.useState)(!0);function I(e,t,n){t(n),!n&&o===e&&s(`basics`)}let[L,R]=(0,p.useState)(`all`),[z,B]=(0,p.useState)(d),[V,H]=(0,p.useState)(new Set),[U,W]=(0,p.useState)(null),[G,K]=(0,p.useState)(!1),q=c.length>0||f.length>0||g.length>0||b!==n.soul||S!==n.identity||w!==n.bootstrap||!E||O!==n.agents||!A||M!==n.tools||!P||L!==`all`||V.size>0||JSON.stringify(z)!==JSON.stringify(d);function J(e){H(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}async function Y(e){if(e.preventDefault(),W(null),!c.trim()){W(`id is required`);return}if(!g.trim()){W(`default model is required`);return}K(!0);try{let e={id:c.trim(),name:f.trim()||void 0,model:g.trim(),skillsMode:L,defaultSkills:L===`selected`?Array.from(V):[],soul:b,identity:S,bootstrap:E?w:null,agents:A?O:null,tools:P?M:null,communicationDefaults:z},t=await fetch(`/api/profiles`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error??t.statusText)}l(``),h(``),y(``),x(n.soul),C(n.identity),T(n.bootstrap),D(!0),k(n.agents),j(!0),N(n.tools),F(!0),H(new Set),R(`all`),B(d),s(`basics`),r()}catch(e){W(e.message)}finally{K(!1)}}return(0,m.jsxs)(`form`,{className:`card`,onSubmit:Y,children:[(0,m.jsx)(i,{when:q&&!G,subject:`Agent template draft`}),(0,m.jsx)(`h3`,{children:`create agent template`}),U&&(0,m.jsx)(`div`,{role:`alert`,className:`err`,children:U}),(0,m.jsx)(_,{items:[{id:`basics`,label:`basics`},{id:`soul`,label:`SOUL`},{id:`identity`,label:`IDENTITY`},{id:`bootstrap`,label:`BOOTSTRAP`,disabled:!E},{id:`agents`,label:`AGENTS`,disabled:!A},{id:`tools`,label:`TOOLS`,disabled:!P},{id:`skills`,label:`skills`},{id:`communication`,label:`communication`}],active:o,onChange:e=>s(e)}),(0,m.jsxs)(`fieldset`,{className:`mb-5 rounded-md border border-frost p-3`,children:[(0,m.jsx)(`legend`,{className:`px-1 text-[0.85em] font-medium text-mocha`,children:`templates to include`}),(0,m.jsxs)(`div`,{className:`flex flex-wrap gap-x-5 gap-y-2 text-[0.9em]`,children:[(0,m.jsxs)(`label`,{className:`inline-flex items-center gap-1.5 opacity-60`,title:`always included`,children:[(0,m.jsx)(`input`,{type:`checkbox`,defaultChecked:!0,disabled:!0}),` SOUL.md`]}),(0,m.jsxs)(`label`,{className:`inline-flex items-center gap-1.5 opacity-60`,title:`always included`,children:[(0,m.jsx)(`input`,{type:`checkbox`,defaultChecked:!0,disabled:!0}),` IDENTITY.md`]}),(0,m.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1.5`,children:[(0,m.jsx)(`input`,{type:`checkbox`,checked:E,onChange:e=>I(`bootstrap`,D,e.target.checked)}),`BOOTSTRAP.md`]}),(0,m.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1.5`,children:[(0,m.jsx)(`input`,{type:`checkbox`,checked:A,onChange:e=>I(`agents`,j,e.target.checked)}),`AGENTS.md`]}),(0,m.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1.5`,children:[(0,m.jsx)(`input`,{type:`checkbox`,checked:P,onChange:e=>I(`tools`,F,e.target.checked)}),`TOOLS.md`]})]}),(0,m.jsx)(`p`,{className:`muted mt-2 text-[0.8em]`,children:`Disabled files aren't created for this Agent template. Each spawned agent gets its own copy of the enabled files at spawn time.`})]}),o===`basics`&&(0,m.jsxs)(`div`,{children:[(0,m.jsxs)(`div`,{className:`flex gap-4`,children:[(0,m.jsxs)(`label`,{className:`flex-1`,children:[`id (slug)`,(0,m.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),required:!0})]}),(0,m.jsxs)(`label`,{className:`flex-1`,children:[`name`,(0,m.jsx)(`input`,{value:f,onChange:e=>h(e.target.value)})]})]}),(0,m.jsxs)(`label`,{children:[`default model`,e.length===0?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`select`,{disabled:!0,children:(0,m.jsx)(`option`,{children:`(no models available)`})}),(0,m.jsxs)(`span`,{className:`muted text-[0.85em]`,children:[`Enable a provider and curate models on `,(0,m.jsx)(`a`,{href:`/config`,children:`/config`}),` first.`]})]}):(0,m.jsxs)(`select`,{value:g,onChange:e=>y(e.target.value),required:!0,children:[(0,m.jsx)(`option`,{value:``,children:`-- pick a model --`}),e.map(e=>(0,m.jsx)(`optgroup`,{label:e.provider,children:e.models.map(t=>(0,m.jsx)(`option`,{value:`${e.provider}:${t}`,children:`${e.provider}:${t}`},t))},e.provider))]})]})]}),o===`soul`&&(0,m.jsx)(v,{label:`SOUL.md`,hint:`Persona, values, and operating principles. Injected into every session.`,value:b,onChange:x,rows:16}),o===`identity`&&(0,m.jsx)(v,{label:`IDENTITY.md`,hint:`Name, creature, vibe, emoji, avatar — filled in during the bootstrap ritual.`,value:S,onChange:C,rows:12}),o===`bootstrap`&&(0,m.jsx)(v,{label:`BOOTSTRAP.md`,hint:`One-time first-run ritual. The agent retires it once introductions are done.`,value:w,onChange:T,rows:16}),o===`agents`&&(0,m.jsx)(v,{label:`AGENTS.md`,hint:`The workspace operating manual — memory discipline, red lines, channel etiquette.`,value:O,onChange:k,rows:16}),o===`tools`&&(0,m.jsx)(v,{label:`TOOLS.md`,hint:`Agent-specific tool notes and environment facts beyond the generic tool descriptions.`,value:M,onChange:N,rows:14}),o===`skills`&&(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`p`,{className:`muted my-2`,children:`Choose which skills agents inherit at spawn time. In both modes each agent can still attach or detach skills individually after it's spawned.`}),(0,m.jsxs)(`label`,{className:`flex items-start gap-2 my-2 cursor-pointer`,children:[(0,m.jsx)(`input`,{type:`radio`,name:`skillsMode`,value:`all`,checked:L===`all`,onChange:()=>R(`all`)}),(0,m.jsxs)(`span`,{children:[(0,m.jsx)(`strong`,{children:`allow all skills`}),` — every skill on disk is attached when an agent is spawned.`]})]}),(0,m.jsxs)(`label`,{className:`flex items-start gap-2 my-2 cursor-pointer`,children:[(0,m.jsx)(`input`,{type:`radio`,name:`skillsMode`,value:`selected`,checked:L===`selected`,onChange:()=>R(`selected`)}),(0,m.jsxs)(`span`,{children:[(0,m.jsx)(`strong`,{children:`select skills`}),` — attach only the ones you pick below.`]})]}),(0,m.jsx)(`div`,{className:`mt-3 max-h-[22rem] overflow-y-auto rounded-md border border-frost p-3 ${L===`all`?`opacity-50 pointer-events-none`:``}`,children:t.length===0?(0,m.jsxs)(`p`,{className:`muted`,children:[`No skills installed yet. Import some on `,(0,m.jsx)(`a`,{href:`/skills`,children:`/skills`}),`.`]}):t.map(e=>(0,m.jsxs)(`label`,{className:`my-1.5 flex cursor-pointer items-start gap-2`,children:[(0,m.jsx)(`input`,{type:`checkbox`,checked:V.has(e.name),onChange:()=>J(e.name)}),(0,m.jsxs)(`span`,{children:[(0,m.jsx)(`code`,{children:e.name}),e.description&&(0,m.jsxs)(`span`,{className:`text-[0.9em] text-mocha-light`,children:[` — `,e.description]})]})]},e.name))})]}),o===`communication`&&(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`div`,{className:`mb-3 flex items-center gap-2`,children:(0,m.jsx)(`h4`,{className:`text-sm font-semibold text-chocolate`,children:`Communication defaults`})}),(0,m.jsx)(`p`,{className:`muted mb-4`,children:`Materialized when a Team or live policy snapshot is created. Existing snapshots never inherit later changes.`}),(0,m.jsx)(a,{value:z,onChange:B})]}),(0,m.jsx)(`div`,{className:`mt-5 flex gap-2`,children:(0,m.jsx)(u,{variant:`primary`,type:`submit`,disabled:G,children:G?`creating…`:`create`})})]})}function _({items:e,active:t,onChange:n}){return(0,m.jsx)(`nav`,{role:`tablist`,className:`-mb-px mb-5 flex flex-wrap gap-1 border-b border-frost`,children:e.map(e=>(0,m.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t===e.id,disabled:e.disabled,title:e.disabled?`disabled — enable it in “templates to include”`:void 0,onClick:()=>n(e.id),className:`unstyled border-b-2 bg-transparent px-4 py-2 text-[0.9em] font-medium transition-colors ${e.disabled?`cursor-not-allowed border-transparent text-mocha-light/40`:t===e.id?`cursor-pointer border-sapphire text-sapphire`:`cursor-pointer border-transparent text-mocha hover:text-sapphire`}`,children:e.label},e.id))})}function v({label:e,hint:t,value:n,onChange:r,rows:i}){return(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`p`,{className:`muted my-2 text-[0.85em]`,children:t}),(0,m.jsxs)(`label`,{children:[e,(0,m.jsx)(`textarea`,{rows:i,value:n,onChange:e=>r(e.target.value),className:`font-mono text-[0.88em] leading-[1.55]`})]})]})}export{h as component};
@@ -1 +1 @@
1
- import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{d as r}from"./preload-helper-bztXdkDj.js";import{t as i}from"./ConfirmDialog-MicTTwdy.js";import{b as a}from"./index-Bq2zrG2_.js";import{a as o,i as s,n as c,r as l,t as u}from"./Page-NV96O47A.js";import{t as d}from"./AgentAvatar-JYijLvZ2.js";import{t as f}from"./Button-ByiV6fpd.js";var p=e(n()),m=t();function h(){let{agents:e,profiles:t,teams:n,modelGroups:h}=a.useLoaderData(),{all:_}=a.useSearch(),v=_===`1`,y=r(),[b,x]=(0,p.useState)(null),[S,C]=(0,p.useState)(null);async function w(e){let t=await fetch(`/api/agents/${encodeURIComponent(e)}/archive`,{method:`POST`});if(!t.ok&&t.status!==204){let e=await t.json().catch(()=>null);throw Error(e?.error??`Could not archive agent (${t.status})`)}await y.invalidate()}async function T(e){C(null);try{let t=await fetch(`/api/agents/${encodeURIComponent(e)}/unarchive`,{method:`POST`});if(!t.ok&&t.status!==204){let e=await t.json().catch(()=>null);throw Error(e?.error??`Could not restore agent (${t.status})`)}await y.invalidate()}catch(e){C(e instanceof Error?e.message:String(e))}}async function E(t){let n=e.find(e=>e.id===t);if(!n)throw Error(`The selected agent no longer exists.`);let r=await fetch(`/api/teams/${encodeURIComponent(n.teamId)}/policy`);if(!r.ok)throw Error(`The current Team policy is unavailable. Nothing was deleted.`);let i=await r.json(),a=await fetch(`/api/agents/${encodeURIComponent(t)}?expectedTeamRevision=${i.teamPolicy.revision}`,{method:`DELETE`});if(!a.ok&&a.status!==204){let e=await a.json().catch(()=>null);throw Error(e?.error??`Could not delete agent (${a.status})`)}await y.invalidate()}return(0,m.jsxs)(l,{size:`wide`,children:[(0,m.jsx)(c,{eyebrow:`Workspace`,title:`Agents`,description:`Spawn, inspect, archive, and restore the agents that work across your teams.`,actions:(0,m.jsx)(f,{variant:`ghost`,onClick:()=>window.location.assign(v?`/agents`:`/agents?all=1`),children:v?`Hide archived`:`Show archived`})}),(0,m.jsx)(g,{profiles:t,teams:n,modelGroups:h,onSpawned:y.invalidate}),S&&(0,m.jsx)(`p`,{role:`alert`,className:`err`,children:S}),(0,m.jsx)(s,{title:v?`All agents`:`Current agents`,description:v?`Active and archived agents are shown together.`:`Archived agents stay hidden until you choose to show them.`,children:e.length===0?(0,m.jsx)(u,{title:v?`No agents yet`:`No current agents`,description:`Spawn an agent above to give a team its first working member.`}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`div`,{className:`hidden overflow-x-auto md:block`,children:(0,m.jsxs)(`table`,{className:`min-w-[760px]`,children:[(0,m.jsx)(`thead`,{children:(0,m.jsxs)(`tr`,{children:[(0,m.jsx)(`th`,{children:`ID`}),(0,m.jsx)(`th`,{children:`Name`}),(0,m.jsx)(`th`,{children:`Agent template`}),(0,m.jsx)(`th`,{children:`Status`}),(0,m.jsx)(`th`,{children:(0,m.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]})}),(0,m.jsx)(`tbody`,{children:e.map(e=>(0,m.jsxs)(`tr`,{children:[(0,m.jsx)(`td`,{children:(0,m.jsx)(`a`,{href:`/agents/${e.id}`,title:e.id,children:(0,m.jsxs)(`code`,{children:[e.id.slice(0,8),`…`]})})}),(0,m.jsx)(`td`,{children:(0,m.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,m.jsx)(d,{identity:e.identity,size:26}),(0,m.jsxs)(`div`,{className:`leading-tight`,children:[(0,m.jsx)(`div`,{children:e.name}),(e.identity?.creature||e.identity?.vibe)&&(0,m.jsx)(`div`,{className:`muted text-[0.8em]`,children:[e.identity?.creature,e.identity?.vibe].filter(Boolean).join(` · `)})]})]})}),(0,m.jsx)(`td`,{children:(0,m.jsx)(`code`,{children:e.profileId})}),(0,m.jsx)(`td`,{children:(0,m.jsx)(o,{variant:e.status===`archived`?`warning`:`success`,children:e.status})}),(0,m.jsx)(`td`,{children:(0,m.jsxs)(`div`,{className:`flex justify-end gap-1.5`,children:[e.status===`archived`?(0,m.jsx)(f,{variant:`ghost`,onClick:()=>T(e.id),children:`Restore`}):(0,m.jsx)(f,{variant:`ghost`,onClick:()=>x({kind:`archive`,agent:e}),children:`Archive`}),(0,m.jsx)(f,{variant:`danger`,onClick:()=>x({kind:`delete`,agent:e}),children:`Delete`})]})})]},e.id))})]})}),(0,m.jsx)(`div`,{className:`grid gap-3 md:hidden`,children:e.map(e=>(0,m.jsxs)(`article`,{className:`min-w-0 rounded-xl border border-border bg-muted/20 p-4`,children:[(0,m.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,m.jsx)(d,{identity:e.identity,size:36}),(0,m.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,m.jsx)(`a`,{href:`/agents/${e.id}`,className:`block truncate font-semibold text-foreground`,children:e.name}),(0,m.jsx)(`p`,{className:`mt-0.5 truncate text-xs text-muted-foreground`,children:e.identity?.creature||e.identity?.vibe?[e.identity?.creature,e.identity?.vibe].filter(Boolean).join(` · `):`Agent template: ${e.profileId}`})]}),(0,m.jsx)(o,{variant:e.status===`archived`?`warning`:`success`,children:e.status})]}),(0,m.jsxs)(`dl`,{className:`mt-3 grid grid-cols-2 gap-2 text-xs`,children:[(0,m.jsxs)(`div`,{className:`min-w-0 rounded-lg bg-muted p-2`,children:[(0,m.jsx)(`dt`,{className:`font-semibold text-muted-foreground`,children:`ID`}),(0,m.jsxs)(`dd`,{className:`mt-0.5 truncate font-mono`,title:e.id,children:[e.id.slice(0,12),`…`]})]}),(0,m.jsxs)(`div`,{className:`min-w-0 rounded-lg bg-muted p-2`,children:[(0,m.jsx)(`dt`,{className:`font-semibold text-muted-foreground`,children:`Agent template`}),(0,m.jsx)(`dd`,{className:`mt-0.5 truncate font-mono`,title:e.profileId,children:e.profileId})]})]}),(0,m.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[e.status===`archived`?(0,m.jsx)(f,{variant:`ghost`,onClick:()=>void T(e.id),children:`Restore`}):(0,m.jsx)(f,{variant:`ghost`,onClick:()=>x({kind:`archive`,agent:e}),children:`Archive`}),(0,m.jsx)(f,{variant:`danger`,onClick:()=>x({kind:`delete`,agent:e}),children:`Delete`})]})]},e.id))})]})}),(0,m.jsx)(i,{open:b!==null,onOpenChange:e=>{e||x(null)},title:b?.kind===`delete`?`Delete ${b.agent.name} permanently?`:`Archive ${b?.agent.name??`agent`}?`,description:b?.kind===`delete`?(0,m.jsx)(`p`,{children:`This permanently removes the Agent, its messages, triggers, skill attachments, sessions, and private on-disk directory. This cannot be undone.`}):(0,m.jsx)(`p`,{children:`The Agent will stop appearing in current lists and cannot receive normal work. You can restore it later from “Show archived”.`}),confirmLabel:b?.kind===`delete`?`Delete permanently`:`Archive agent`,confirmVariant:b?.kind===`delete`?`danger`:`primary`,onConfirm:async()=>{b&&(b.kind===`delete`?await E(b.agent.id):await w(b.agent.id))}})]})}function g({profiles:e,teams:t,modelGroups:n,onSpawned:r}){let[i,a]=(0,p.useState)(``),[o,c]=(0,p.useState)(``),[l,u]=(0,p.useState)(``),[d,h]=(0,p.useState)(t.find(e=>e.id==="default")?.id??``),[g,_]=(0,p.useState)(`profile_defaults`),[v,y]=(0,p.useState)(!1),[b,x]=(0,p.useState)(null);async function S(e){if(e.preventDefault(),!i){x(`profile is required`);return}y(!0),x(null);try{let e={profile:i};if(o&&(e.name=o),l&&(e.model=l),d){let t=await fetch(`/api/teams/${encodeURIComponent(d)}/policy`);if(!t.ok)throw Error(`The selected Team policy is unavailable.`);let n=await t.json();e.teamId=d,e.teamExpectedRevision=n.teamPolicy.revision,e.placement=g}let t=await fetch(`/api/agents`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error??t.statusText)}await t.json(),c(``),u(``),r()}catch(e){x(e.message)}finally{y(!1)}}return(0,m.jsx)(s,{title:`Spawn an agent`,description:`Skills come from the Agent template at spawn time. You can adjust an agent's skills later from its detail page.`,children:(0,m.jsxs)(`form`,{onSubmit:S,children:[b&&(0,m.jsx)(`div`,{role:`alert`,className:`err`,children:b}),(0,m.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,m.jsxs)(`label`,{children:[`Agent template`,(0,m.jsxs)(`select`,{value:i,onChange:e=>a(e.target.value),required:!0,children:[(0,m.jsx)(`option`,{value:``,children:`Select a template`}),e.map(e=>(0,m.jsx)(`option`,{value:e.id,children:e.id},e.id))]})]}),(0,m.jsxs)(`label`,{children:[`Name`,(0,m.jsx)(`input`,{value:o,onChange:e=>c(e.target.value)})]}),(0,m.jsxs)(`label`,{children:[`Model override`,n.length===0?(0,m.jsx)(`input`,{value:``,disabled:!0,placeholder:`Uses the template default — enable models in Config`}):(0,m.jsxs)(`select`,{value:l,onChange:e=>u(e.target.value),children:[(0,m.jsx)(`option`,{value:``,children:`Use the template default`}),n.map(e=>(0,m.jsx)(`optgroup`,{label:e.provider,children:e.models.map(t=>(0,m.jsx)(`option`,{value:`${e.provider}:${t}`,children:`${e.provider}:${t}`},t))},e.provider))]})]}),(0,m.jsxs)(`label`,{children:[`Team`,t.length===0?(0,m.jsx)(`select`,{disabled:!0,children:(0,m.jsx)(`option`,{children:`No teams — register one in Teams`})}):(0,m.jsx)(`select`,{value:d,onChange:e=>h(e.target.value),children:t.map(e=>(0,m.jsxs)(`option`,{value:e.id,children:[e.id,` (`,e.name,`)`]},e.id))})]}),(0,m.jsxs)(`label`,{className:`sm:col-span-2`,children:[`Initial policy placement`,(0,m.jsxs)(`select`,{value:g,onChange:e=>_(e.target.value),children:[(0,m.jsx)(`option`,{value:`profile_defaults`,children:`Agent-template defaults`}),(0,m.jsx)(`option`,{value:`isolated`,children:`Isolated`})]}),(0,m.jsx)(`span`,{className:`muted mt-1 block text-xs`,children:`Submission uses the latest displayed Team revision. A concurrent policy change is shown as a conflict and is never overwritten.`})]})]}),(0,m.jsx)(`div`,{className:`mt-4`,children:(0,m.jsx)(f,{variant:`primary`,type:`submit`,disabled:v,children:v?`Spawning…`:`Spawn agent`})})]})})}export{h as component};
1
+ import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{d as r}from"./preload-helper-bztXdkDj.js";import{t as i}from"./ConfirmDialog-BzIiABOP.js";import{N as a}from"./index-Bi-HxcPG.js";import{a as o,i as s,n as c,r as l,t as u}from"./Page-NV96O47A.js";import{t as d}from"./AgentAvatar-JYijLvZ2.js";import{t as f}from"./Button-ByiV6fpd.js";var p=e(n()),m=t();function h(){let{agents:e,profiles:t,teams:n,modelGroups:h}=a.useLoaderData(),{all:_}=a.useSearch(),v=_===`1`,y=r(),[b,x]=(0,p.useState)(null),[S,C]=(0,p.useState)(null);async function w(e){let t=await fetch(`/api/agents/${encodeURIComponent(e)}/archive`,{method:`POST`});if(!t.ok&&t.status!==204){let e=await t.json().catch(()=>null);throw Error(e?.error??`Could not archive agent (${t.status})`)}await y.invalidate()}async function T(e){C(null);try{let t=await fetch(`/api/agents/${encodeURIComponent(e)}/unarchive`,{method:`POST`});if(!t.ok&&t.status!==204){let e=await t.json().catch(()=>null);throw Error(e?.error??`Could not restore agent (${t.status})`)}await y.invalidate()}catch(e){C(e instanceof Error?e.message:String(e))}}async function E(t){let n=e.find(e=>e.id===t);if(!n)throw Error(`The selected agent no longer exists.`);let r=await fetch(`/api/teams/${encodeURIComponent(n.teamId)}/policy`);if(!r.ok)throw Error(`The current Team policy is unavailable. Nothing was deleted.`);let i=await r.json(),a=await fetch(`/api/agents/${encodeURIComponent(t)}?expectedTeamRevision=${i.teamPolicy.revision}`,{method:`DELETE`});if(!a.ok&&a.status!==204){let e=await a.json().catch(()=>null);throw Error(e?.error??`Could not delete agent (${a.status})`)}await y.invalidate()}return(0,m.jsxs)(l,{size:`wide`,children:[(0,m.jsx)(c,{eyebrow:`Workspace`,title:`Agents`,description:`Spawn, inspect, archive, and restore the agents that work across your teams.`,actions:(0,m.jsx)(f,{variant:`ghost`,onClick:()=>window.location.assign(v?`/agents`:`/agents?all=1`),children:v?`Hide archived`:`Show archived`})}),(0,m.jsx)(g,{profiles:t,teams:n,modelGroups:h,onSpawned:y.invalidate}),S&&(0,m.jsx)(`p`,{role:`alert`,className:`err`,children:S}),(0,m.jsx)(s,{title:v?`All agents`:`Current agents`,description:v?`Active and archived agents are shown together.`:`Archived agents stay hidden until you choose to show them.`,children:e.length===0?(0,m.jsx)(u,{title:v?`No agents yet`:`No current agents`,description:`Spawn an agent above to give a team its first working member.`}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`div`,{className:`hidden overflow-x-auto md:block`,children:(0,m.jsxs)(`table`,{className:`min-w-[760px]`,children:[(0,m.jsx)(`thead`,{children:(0,m.jsxs)(`tr`,{children:[(0,m.jsx)(`th`,{children:`ID`}),(0,m.jsx)(`th`,{children:`Name`}),(0,m.jsx)(`th`,{children:`Agent template`}),(0,m.jsx)(`th`,{children:`Status`}),(0,m.jsx)(`th`,{children:(0,m.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]})}),(0,m.jsx)(`tbody`,{children:e.map(e=>(0,m.jsxs)(`tr`,{children:[(0,m.jsx)(`td`,{children:(0,m.jsx)(`a`,{href:`/agents/${e.id}`,title:e.id,children:(0,m.jsxs)(`code`,{children:[e.id.slice(0,8),`…`]})})}),(0,m.jsx)(`td`,{children:(0,m.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,m.jsx)(d,{identity:e.identity,size:26}),(0,m.jsxs)(`div`,{className:`leading-tight`,children:[(0,m.jsx)(`div`,{children:e.name}),(e.identity?.creature||e.identity?.vibe)&&(0,m.jsx)(`div`,{className:`muted text-[0.8em]`,children:[e.identity?.creature,e.identity?.vibe].filter(Boolean).join(` · `)})]})]})}),(0,m.jsx)(`td`,{children:(0,m.jsx)(`code`,{children:e.profileId})}),(0,m.jsx)(`td`,{children:(0,m.jsx)(o,{variant:e.status===`archived`?`warning`:`success`,children:e.status})}),(0,m.jsx)(`td`,{children:(0,m.jsxs)(`div`,{className:`flex justify-end gap-1.5`,children:[e.status===`archived`?(0,m.jsx)(f,{variant:`ghost`,onClick:()=>T(e.id),children:`Restore`}):(0,m.jsx)(f,{variant:`ghost`,onClick:()=>x({kind:`archive`,agent:e}),children:`Archive`}),(0,m.jsx)(f,{variant:`danger`,onClick:()=>x({kind:`delete`,agent:e}),children:`Delete`})]})})]},e.id))})]})}),(0,m.jsx)(`div`,{className:`grid gap-3 md:hidden`,children:e.map(e=>(0,m.jsxs)(`article`,{className:`min-w-0 rounded-xl border border-border bg-muted/20 p-4`,children:[(0,m.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,m.jsx)(d,{identity:e.identity,size:36}),(0,m.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,m.jsx)(`a`,{href:`/agents/${e.id}`,className:`block truncate font-semibold text-foreground`,children:e.name}),(0,m.jsx)(`p`,{className:`mt-0.5 truncate text-xs text-muted-foreground`,children:e.identity?.creature||e.identity?.vibe?[e.identity?.creature,e.identity?.vibe].filter(Boolean).join(` · `):`Agent template: ${e.profileId}`})]}),(0,m.jsx)(o,{variant:e.status===`archived`?`warning`:`success`,children:e.status})]}),(0,m.jsxs)(`dl`,{className:`mt-3 grid grid-cols-2 gap-2 text-xs`,children:[(0,m.jsxs)(`div`,{className:`min-w-0 rounded-lg bg-muted p-2`,children:[(0,m.jsx)(`dt`,{className:`font-semibold text-muted-foreground`,children:`ID`}),(0,m.jsxs)(`dd`,{className:`mt-0.5 truncate font-mono`,title:e.id,children:[e.id.slice(0,12),`…`]})]}),(0,m.jsxs)(`div`,{className:`min-w-0 rounded-lg bg-muted p-2`,children:[(0,m.jsx)(`dt`,{className:`font-semibold text-muted-foreground`,children:`Agent template`}),(0,m.jsx)(`dd`,{className:`mt-0.5 truncate font-mono`,title:e.profileId,children:e.profileId})]})]}),(0,m.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[e.status===`archived`?(0,m.jsx)(f,{variant:`ghost`,onClick:()=>void T(e.id),children:`Restore`}):(0,m.jsx)(f,{variant:`ghost`,onClick:()=>x({kind:`archive`,agent:e}),children:`Archive`}),(0,m.jsx)(f,{variant:`danger`,onClick:()=>x({kind:`delete`,agent:e}),children:`Delete`})]})]},e.id))})]})}),(0,m.jsx)(i,{open:b!==null,onOpenChange:e=>{e||x(null)},title:b?.kind===`delete`?`Delete ${b.agent.name} permanently?`:`Archive ${b?.agent.name??`agent`}?`,description:b?.kind===`delete`?(0,m.jsx)(`p`,{children:`This permanently removes the Agent, its messages, triggers, skill attachments, sessions, and private on-disk directory. This cannot be undone.`}):(0,m.jsx)(`p`,{children:`The Agent will stop appearing in current lists and cannot receive normal work. You can restore it later from “Show archived”.`}),confirmLabel:b?.kind===`delete`?`Delete permanently`:`Archive agent`,confirmVariant:b?.kind===`delete`?`danger`:`primary`,onConfirm:async()=>{b&&(b.kind===`delete`?await E(b.agent.id):await w(b.agent.id))}})]})}function g({profiles:e,teams:t,modelGroups:n,onSpawned:r}){let[i,a]=(0,p.useState)(``),[o,c]=(0,p.useState)(``),[l,u]=(0,p.useState)(``),[d,h]=(0,p.useState)(t.find(e=>e.id==="default")?.id??``),[g,_]=(0,p.useState)(`profile_defaults`),[v,y]=(0,p.useState)(!1),[b,x]=(0,p.useState)(null);async function S(e){if(e.preventDefault(),!i){x(`profile is required`);return}y(!0),x(null);try{let e={profile:i};if(o&&(e.name=o),l&&(e.model=l),d){let t=await fetch(`/api/teams/${encodeURIComponent(d)}/policy`);if(!t.ok)throw Error(`The selected Team policy is unavailable.`);let n=await t.json();e.teamId=d,e.teamExpectedRevision=n.teamPolicy.revision,e.placement=g}let t=await fetch(`/api/agents`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error??t.statusText)}await t.json(),c(``),u(``),r()}catch(e){x(e.message)}finally{y(!1)}}return(0,m.jsx)(s,{title:`Spawn an agent`,description:`Skills come from the Agent template at spawn time. You can adjust an agent's skills later from its detail page.`,children:(0,m.jsxs)(`form`,{onSubmit:S,children:[b&&(0,m.jsx)(`div`,{role:`alert`,className:`err`,children:b}),(0,m.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,m.jsxs)(`label`,{children:[`Agent template`,(0,m.jsxs)(`select`,{value:i,onChange:e=>a(e.target.value),required:!0,children:[(0,m.jsx)(`option`,{value:``,children:`Select a template`}),e.map(e=>(0,m.jsx)(`option`,{value:e.id,children:e.id},e.id))]})]}),(0,m.jsxs)(`label`,{children:[`Name`,(0,m.jsx)(`input`,{value:o,onChange:e=>c(e.target.value)})]}),(0,m.jsxs)(`label`,{children:[`Model override`,n.length===0?(0,m.jsx)(`input`,{value:``,disabled:!0,placeholder:`Uses the template default — enable models in Config`}):(0,m.jsxs)(`select`,{value:l,onChange:e=>u(e.target.value),children:[(0,m.jsx)(`option`,{value:``,children:`Use the template default`}),n.map(e=>(0,m.jsx)(`optgroup`,{label:e.provider,children:e.models.map(t=>(0,m.jsx)(`option`,{value:`${e.provider}:${t}`,children:`${e.provider}:${t}`},t))},e.provider))]})]}),(0,m.jsxs)(`label`,{children:[`Team`,t.length===0?(0,m.jsx)(`select`,{disabled:!0,children:(0,m.jsx)(`option`,{children:`No teams — register one in Teams`})}):(0,m.jsx)(`select`,{value:d,onChange:e=>h(e.target.value),children:t.map(e=>(0,m.jsxs)(`option`,{value:e.id,children:[e.id,` (`,e.name,`)`]},e.id))})]}),(0,m.jsxs)(`label`,{className:`sm:col-span-2`,children:[`Initial policy placement`,(0,m.jsxs)(`select`,{value:g,onChange:e=>_(e.target.value),children:[(0,m.jsx)(`option`,{value:`profile_defaults`,children:`Agent-template defaults`}),(0,m.jsx)(`option`,{value:`isolated`,children:`Isolated`})]}),(0,m.jsx)(`span`,{className:`muted mt-1 block text-xs`,children:`Submission uses the latest displayed Team revision. A concurrent policy change is shown as a conflict and is never overwritten.`})]})]}),(0,m.jsx)(`div`,{className:`mt-4`,children:(0,m.jsx)(f,{variant:`primary`,type:`submit`,disabled:v,children:v?`Spawning…`:`Spawn agent`})})]})})}export{h as component};
@@ -1 +1 @@
1
- import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{x as r}from"./index-Bq2zrG2_.js";import{a as i,i as a,n as o,r as s,t as c}from"./Page-NV96O47A.js";import{t as l}from"./Button-ByiV6fpd.js";var u=e(n()),d=t();function f(){let[e,t]=(0,u.useState)(r.useLoaderData().approvals),[n,i]=(0,u.useState)(`pending`),[f,m]=(0,u.useState)(null),[h,v]=(0,u.useState)(!1),[b,x]=(0,u.useState)(null),S=e.filter(e=>n===`all`||e.status===n),C=async()=>{let e=await fetch(`/api/approvals?limit=100`);if(!e.ok)throw Error(`Could not refresh approvals (${e.status})`);t((await e.json()).approvals)},w=async e=>{try{let t=await fetch(`/api/approvals/${encodeURIComponent(e)}`);if(!t.ok)throw Error(`Could not load approval (${t.status})`);m(await t.json())}catch(e){x(e instanceof Error?e.message:String(e))}},T=async e=>{if(f){v(!0),x(null);try{let t=await fetch(`/api/approvals/${encodeURIComponent(f.id)}/${e}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({reason:e===`deny`?`Denied by operator`:void 0})}),n=await t.json();if(!t.ok)throw Error(n.error??`Decision failed (${t.status})`);await C(),await w(f.id),x(e===`approve`?`Approved and delivered once.`:`Denied.`)}catch(e){x(e instanceof Error?e.message:String(e)),await C(),await w(f.id)}finally{v(!1)}}};return(0,d.jsxs)(s,{size:`wide`,children:[(0,d.jsx)(o,{eyebrow:`Policy operations`,title:`Communication approvals`,description:`One durable queue for policy-protected attempts. Approval authorizes only the captured attempt.`,actions:(0,d.jsxs)(`label`,{className:`m-0 block w-full text-sm sm:w-52`,children:[`Status`,(0,d.jsxs)(`select`,{value:n,onChange:e=>i(e.target.value),className:`mt-1`,children:[(0,d.jsx)(`option`,{value:`pending`,children:`Pending`}),(0,d.jsx)(`option`,{value:`all`,children:`All history`}),(0,d.jsx)(`option`,{value:`delivered`,children:`Delivered`}),(0,d.jsx)(`option`,{value:`denied`,children:`Denied`}),(0,d.jsx)(`option`,{value:`expired`,children:`Expired`}),(0,d.jsx)(`option`,{value:`cancelled`,children:`Cancelled`}),(0,d.jsx)(`option`,{value:`delivery_failed`,children:`Delivery failed`})]})]})}),(0,d.jsxs)(`div`,{className:`grid min-w-0 gap-5 lg:grid-cols-[minmax(0,1.15fr)_minmax(320px,0.85fr)]`,children:[(0,d.jsx)(a,{title:`Approval queue`,description:`${S.length} matching attempt${S.length===1?``:`s`}`,className:`min-w-0`,children:S.length===0?(0,d.jsx)(c,{title:`No matching approvals`,description:`Try another status filter or return when a protected attempt needs review.`}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`div`,{className:`hidden overflow-x-auto md:block`,children:(0,d.jsxs)(`table`,{className:`m-0 min-w-[680px]`,children:[(0,d.jsx)(`thead`,{children:(0,d.jsxs)(`tr`,{children:[(0,d.jsx)(`th`,{children:`Status`}),(0,d.jsx)(`th`,{children:`Path`}),(0,d.jsx)(`th`,{children:`Origin`}),(0,d.jsx)(`th`,{children:`Expires`}),(0,d.jsx)(`th`,{children:(0,d.jsx)(`span`,{className:`sr-only`,children:`Action`})})]})}),(0,d.jsx)(`tbody`,{children:S.map(e=>(0,d.jsxs)(`tr`,{onClick:()=>void w(e.id),className:`cursor-pointer ${f?.id===e.id?`bg-accent/60`:``}`,children:[(0,d.jsx)(`td`,{children:(0,d.jsx)(p,{value:e.status})}),(0,d.jsxs)(`td`,{className:`min-w-56`,children:[g(e.source),` → `,g(e.target)]}),(0,d.jsx)(`td`,{children:e.origin}),(0,d.jsx)(`td`,{className:`whitespace-nowrap`,children:(0,d.jsx)(`time`,{dateTime:new Date(e.expiresAt).toISOString(),children:y(e.expiresAt)})}),(0,d.jsx)(`td`,{children:(0,d.jsx)(l,{variant:`ghost`,"aria-pressed":f?.id===e.id,onClick:t=>{t.stopPropagation(),w(e.id)},children:`Inspect`})})]},e.id))})]})}),(0,d.jsx)(`div`,{className:`grid gap-3 md:hidden`,children:S.map(e=>(0,d.jsxs)(`button`,{type:`button`,"aria-label":`Inspect ${e.attemptKind} approval`,"aria-pressed":f?.id===e.id,onClick:()=>void w(e.id),className:`unstyled min-w-0 rounded-xl border p-4 text-left ${f?.id===e.id?`border-primary/40 bg-accent/60`:`border-border bg-muted/20`}`,children:[(0,d.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,d.jsx)(p,{value:e.status}),(0,d.jsx)(`time`,{dateTime:new Date(e.expiresAt).toISOString(),className:`text-xs text-muted-foreground`,children:y(e.expiresAt)})]}),(0,d.jsxs)(`div`,{className:`mt-3 break-words text-sm font-semibold text-foreground`,children:[g(e.source),` → `,g(e.target)]}),(0,d.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Origin: `,e.origin]})]},e.id))})]})}),(0,d.jsx)(`aside`,{className:`min-w-0`,"aria-label":`Approval details`,children:(0,d.jsx)(a,{title:`Attempt details`,actions:f?(0,d.jsx)(p,{value:f.status}):void 0,children:f?(0,d.jsxs)(`div`,{className:`space-y-5`,children:[(0,d.jsxs)(`dl`,{className:`grid gap-3 text-sm sm:grid-cols-2 lg:grid-cols-1 xl:grid-cols-2`,children:[f.file&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(_,{label:`File`,value:f.file.name}),(0,d.jsx)(_,{label:`File type`,value:f.file.mimeType}),(0,d.jsx)(_,{label:`Size`,value:`${f.file.byteLength.toLocaleString()} bytes`})]}),(0,d.jsx)(_,{label:`Attempt`,value:`${f.attemptKind}:${f.attemptId}`}),(0,d.jsx)(_,{label:`Operation`,value:f.operation}),(0,d.jsx)(_,{label:`Path`,value:`${g(f.source)} → ${g(f.target)}`}),(0,d.jsx)(_,{label:`Policy`,value:f.policyRefs.map(e=>`${e.teamId}@${e.revision}`).join(`, `)}),(0,d.jsx)(_,{label:`Expires`,value:y(f.expiresAt)})]}),(0,d.jsxs)(`details`,{className:`rounded-lg border border-border bg-muted/30 p-3`,children:[(0,d.jsx)(`summary`,{className:`cursor-pointer text-sm font-semibold`,children:`Sensitive payload`}),(0,d.jsx)(`pre`,{className:`mt-3 max-h-48 overflow-auto rounded-lg bg-background p-3 text-xs`,children:JSON.stringify(f.payload,null,2)})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`h3`,{className:`m-0 font-body text-sm font-semibold text-foreground`,children:`Audit history`}),(0,d.jsx)(`ol`,{className:`mt-2 divide-y divide-border rounded-lg border border-border text-xs`,children:f.events.map(e=>(0,d.jsxs)(`li`,{className:`px-3 py-2 leading-5`,children:[y(e.createdAt),` · `,e.event,` · `,e.actor]},e.id))})]}),b&&(0,d.jsx)(`p`,{role:`status`,className:`rounded-lg bg-muted px-3 py-2 text-sm`,children:b}),f.status===`pending`&&(0,d.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,d.jsx)(l,{variant:`primary`,disabled:h,onClick:()=>void T(`approve`),children:`Approve once`}),(0,d.jsx)(l,{variant:`danger`,disabled:h,onClick:()=>void T(`deny`),children:`Deny`})]})]}):(0,d.jsx)(c,{title:`No attempt selected`,description:`Select an attempt from the queue to inspect its policy and audit history.`,className:`min-h-56`})})})]})]})}function p({value:e}){return(0,d.jsx)(i,{variant:m(e),children:h(e)})}function m(e){switch(e){case`pending`:return`warning`;case`approved`:case`delivering`:return`info`;case`delivered`:return`success`;case`denied`:case`delivery_failed`:return`danger`;case`expired`:case`cancelled`:return`neutral`}}function h(e){let t=e.replaceAll(`_`,` `);return`${t.charAt(0).toUpperCase()}${t.slice(1)}`}function g(e){return e.kind===`agent`?`Agent ${e.id}`:e.kind===`user`?`User`:`Outside ${e.teamId}`}function _({label:e,value:t}){return(0,d.jsxs)(`div`,{className:`rounded-lg bg-muted/40 p-3`,children:[(0,d.jsx)(`dt`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:e}),(0,d.jsx)(`dd`,{className:`mt-1 break-all text-foreground`,children:t})]})}var v=new Intl.DateTimeFormat(`en-GB`,{dateStyle:`medium`,timeStyle:`medium`,timeZone:`UTC`});function y(e){return`${v.format(new Date(e))} UTC`}export{f as component};
1
+ import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{P as r}from"./index-Bi-HxcPG.js";import{a as i,i as a,n as o,r as s,t as c}from"./Page-NV96O47A.js";import{t as l}from"./Button-ByiV6fpd.js";var u=e(n()),d=t();function f(){let[e,t]=(0,u.useState)(r.useLoaderData().approvals),[n,i]=(0,u.useState)(`pending`),[f,m]=(0,u.useState)(null),[h,v]=(0,u.useState)(!1),[b,x]=(0,u.useState)(null),S=e.filter(e=>n===`all`||e.status===n),C=async()=>{let e=await fetch(`/api/approvals?limit=100`);if(!e.ok)throw Error(`Could not refresh approvals (${e.status})`);t((await e.json()).approvals)},w=async e=>{try{let t=await fetch(`/api/approvals/${encodeURIComponent(e)}`);if(!t.ok)throw Error(`Could not load approval (${t.status})`);m(await t.json())}catch(e){x(e instanceof Error?e.message:String(e))}},T=async e=>{if(f){v(!0),x(null);try{let t=await fetch(`/api/approvals/${encodeURIComponent(f.id)}/${e}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({reason:e===`deny`?`Denied by operator`:void 0})}),n=await t.json();if(!t.ok)throw Error(n.error??`Decision failed (${t.status})`);await C(),await w(f.id),x(e===`approve`?`Approved and delivered once.`:`Denied.`)}catch(e){x(e instanceof Error?e.message:String(e)),await C(),await w(f.id)}finally{v(!1)}}};return(0,d.jsxs)(s,{size:`wide`,children:[(0,d.jsx)(o,{eyebrow:`Policy operations`,title:`Communication approvals`,description:`One durable queue for policy-protected attempts. Approval authorizes only the captured attempt.`,actions:(0,d.jsxs)(`label`,{className:`m-0 block w-full text-sm sm:w-52`,children:[`Status`,(0,d.jsxs)(`select`,{value:n,onChange:e=>i(e.target.value),className:`mt-1`,children:[(0,d.jsx)(`option`,{value:`pending`,children:`Pending`}),(0,d.jsx)(`option`,{value:`all`,children:`All history`}),(0,d.jsx)(`option`,{value:`delivered`,children:`Delivered`}),(0,d.jsx)(`option`,{value:`denied`,children:`Denied`}),(0,d.jsx)(`option`,{value:`expired`,children:`Expired`}),(0,d.jsx)(`option`,{value:`cancelled`,children:`Cancelled`}),(0,d.jsx)(`option`,{value:`delivery_failed`,children:`Delivery failed`})]})]})}),(0,d.jsxs)(`div`,{className:`grid min-w-0 gap-5 lg:grid-cols-[minmax(0,1.15fr)_minmax(320px,0.85fr)]`,children:[(0,d.jsx)(a,{title:`Approval queue`,description:`${S.length} matching attempt${S.length===1?``:`s`}`,className:`min-w-0`,children:S.length===0?(0,d.jsx)(c,{title:`No matching approvals`,description:`Try another status filter or return when a protected attempt needs review.`}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`div`,{className:`hidden overflow-x-auto md:block`,children:(0,d.jsxs)(`table`,{className:`m-0 min-w-[680px]`,children:[(0,d.jsx)(`thead`,{children:(0,d.jsxs)(`tr`,{children:[(0,d.jsx)(`th`,{children:`Status`}),(0,d.jsx)(`th`,{children:`Path`}),(0,d.jsx)(`th`,{children:`Origin`}),(0,d.jsx)(`th`,{children:`Expires`}),(0,d.jsx)(`th`,{children:(0,d.jsx)(`span`,{className:`sr-only`,children:`Action`})})]})}),(0,d.jsx)(`tbody`,{children:S.map(e=>(0,d.jsxs)(`tr`,{onClick:()=>void w(e.id),className:`cursor-pointer ${f?.id===e.id?`bg-accent/60`:``}`,children:[(0,d.jsx)(`td`,{children:(0,d.jsx)(p,{value:e.status})}),(0,d.jsxs)(`td`,{className:`min-w-56`,children:[g(e.source),` → `,g(e.target)]}),(0,d.jsx)(`td`,{children:e.origin}),(0,d.jsx)(`td`,{className:`whitespace-nowrap`,children:(0,d.jsx)(`time`,{dateTime:new Date(e.expiresAt).toISOString(),children:y(e.expiresAt)})}),(0,d.jsx)(`td`,{children:(0,d.jsx)(l,{variant:`ghost`,"aria-pressed":f?.id===e.id,onClick:t=>{t.stopPropagation(),w(e.id)},children:`Inspect`})})]},e.id))})]})}),(0,d.jsx)(`div`,{className:`grid gap-3 md:hidden`,children:S.map(e=>(0,d.jsxs)(`button`,{type:`button`,"aria-label":`Inspect ${e.attemptKind} approval`,"aria-pressed":f?.id===e.id,onClick:()=>void w(e.id),className:`unstyled min-w-0 rounded-xl border p-4 text-left ${f?.id===e.id?`border-primary/40 bg-accent/60`:`border-border bg-muted/20`}`,children:[(0,d.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,d.jsx)(p,{value:e.status}),(0,d.jsx)(`time`,{dateTime:new Date(e.expiresAt).toISOString(),className:`text-xs text-muted-foreground`,children:y(e.expiresAt)})]}),(0,d.jsxs)(`div`,{className:`mt-3 break-words text-sm font-semibold text-foreground`,children:[g(e.source),` → `,g(e.target)]}),(0,d.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Origin: `,e.origin]})]},e.id))})]})}),(0,d.jsx)(`aside`,{className:`min-w-0`,"aria-label":`Approval details`,children:(0,d.jsx)(a,{title:`Attempt details`,actions:f?(0,d.jsx)(p,{value:f.status}):void 0,children:f?(0,d.jsxs)(`div`,{className:`space-y-5`,children:[(0,d.jsxs)(`dl`,{className:`grid gap-3 text-sm sm:grid-cols-2 lg:grid-cols-1 xl:grid-cols-2`,children:[f.file&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(_,{label:`File`,value:f.file.name}),(0,d.jsx)(_,{label:`File type`,value:f.file.mimeType}),(0,d.jsx)(_,{label:`Size`,value:`${f.file.byteLength.toLocaleString()} bytes`})]}),(0,d.jsx)(_,{label:`Attempt`,value:`${f.attemptKind}:${f.attemptId}`}),(0,d.jsx)(_,{label:`Operation`,value:f.operation}),(0,d.jsx)(_,{label:`Path`,value:`${g(f.source)} → ${g(f.target)}`}),(0,d.jsx)(_,{label:`Policy`,value:f.policyRefs.map(e=>`${e.teamId}@${e.revision}`).join(`, `)}),(0,d.jsx)(_,{label:`Expires`,value:y(f.expiresAt)})]}),(0,d.jsxs)(`details`,{className:`rounded-lg border border-border bg-muted/30 p-3`,children:[(0,d.jsx)(`summary`,{className:`cursor-pointer text-sm font-semibold`,children:`Sensitive payload`}),(0,d.jsx)(`pre`,{className:`mt-3 max-h-48 overflow-auto rounded-lg bg-background p-3 text-xs`,children:JSON.stringify(f.payload,null,2)})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`h3`,{className:`m-0 font-body text-sm font-semibold text-foreground`,children:`Audit history`}),(0,d.jsx)(`ol`,{className:`mt-2 divide-y divide-border rounded-lg border border-border text-xs`,children:f.events.map(e=>(0,d.jsxs)(`li`,{className:`px-3 py-2 leading-5`,children:[y(e.createdAt),` · `,e.event,` · `,e.actor]},e.id))})]}),b&&(0,d.jsx)(`p`,{role:`status`,className:`rounded-lg bg-muted px-3 py-2 text-sm`,children:b}),f.status===`pending`&&(0,d.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,d.jsx)(l,{variant:`primary`,disabled:h,onClick:()=>void T(`approve`),children:`Approve once`}),(0,d.jsx)(l,{variant:`danger`,disabled:h,onClick:()=>void T(`deny`),children:`Deny`})]})]}):(0,d.jsx)(c,{title:`No attempt selected`,description:`Select an attempt from the queue to inspect its policy and audit history.`,className:`min-h-56`})})})]})]})}function p({value:e}){return(0,d.jsx)(i,{variant:m(e),children:h(e)})}function m(e){switch(e){case`pending`:return`warning`;case`approved`:case`delivering`:return`info`;case`delivered`:return`success`;case`denied`:case`delivery_failed`:return`danger`;case`expired`:case`cancelled`:return`neutral`}}function h(e){let t=e.replaceAll(`_`,` `);return`${t.charAt(0).toUpperCase()}${t.slice(1)}`}function g(e){return e.kind===`agent`?`Agent ${e.id}`:e.kind===`user`?`User`:`Outside ${e.teamId}`}function _({label:e,value:t}){return(0,d.jsxs)(`div`,{className:`rounded-lg bg-muted/40 p-3`,children:[(0,d.jsx)(`dt`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:e}),(0,d.jsx)(`dd`,{className:`mt-1 break-all text-foreground`,children:t})]})}var v=new Intl.DateTimeFormat(`en-GB`,{dateStyle:`medium`,timeStyle:`medium`,timeZone:`UTC`});function y(e){return`${v.format(new Date(e))} UTC`}export{f as component};
@@ -1 +1 @@
1
- import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{a as r}from"./preload-helper-bztXdkDj.js";import{S as i}from"./index-Bq2zrG2_.js";import{a,i as o,n as s,r as c,t as l}from"./Page-NV96O47A.js";import{t as u}from"./Button-ByiV6fpd.js";var d=e(n()),f=t();function p(){let e=i.useLoaderData(),[t,n]=(0,d.useState)(e.list.items),[p,h]=(0,d.useState)(e.list.degraded),[g,_]=(0,d.useState)(e.summary),[v,y]=(0,d.useState)(`open`),[b,x]=(0,d.useState)(`all`),[S,C]=(0,d.useState)(`all`),[w,T]=(0,d.useState)(null),[E,D]=(0,d.useState)(null),O=(0,d.useMemo)(()=>t.filter(e=>(v===`all`||(v===`open`?e.acknowledgedAt===null:e.acknowledgedAt!==null))&&(b===`all`||e.kind===b)&&(S===`all`||e.severity===S)),[t,b,S,v]);async function k(){let[e,t]=await Promise.all([fetch(`/api/attention?state=all&limit=200`),fetch(`/api/attention/summary`)]);if(!e.ok||!t.ok)throw Error(`Could not refresh the Attention Center`);let r=await e.json();n(r.items),h(r.degraded),_(await t.json())}async function A(e,t){T(e.key),D(null);try{let n=await fetch(`/api/attention/${encodeURIComponent(e.key)}/${t?`acknowledge`:`acknowledgement`}`,{method:t?`POST`:`DELETE`}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error(r.error??`Update failed (${n.status})`);await k()}catch(e){D(e instanceof Error?e.message:String(e)),await k().catch(()=>{})}finally{T(null)}}async function j(){T(`all`),D(null);try{let e=await fetch(`/api/attention/acknowledge-all`,{method:`POST`}),t=await e.json();if(!e.ok)throw Error(t.error??`Acknowledgement failed`);D(`Acknowledged ${t.acknowledged} informational item(s). Approvals and lessons were left open.`),await k()}catch(e){D(e instanceof Error?e.message:String(e))}finally{T(null)}}return(0,f.jsxs)(c,{size:`wide`,children:[(0,f.jsx)(s,{eyebrow:`Operations`,title:`Attention Center`,description:`One queue for decisions and terminal signals. Resolve action-required work at its canonical source; acknowledge informational failures here.`,actions:(0,f.jsx)(u,{variant:`ghost`,disabled:w!==null,onClick:()=>void j(),children:`Acknowledge all informational items`})}),(0,f.jsxs)(`div`,{className:`mb-5 grid gap-3 sm:grid-cols-3`,children:[(0,f.jsx)(m,{label:`Open`,value:g.openTotal}),(0,f.jsx)(m,{label:`Action required`,value:g.bySeverity.action_required}),(0,f.jsx)(m,{label:`Errors and warnings`,value:g.bySeverity.error+g.bySeverity.warning})]}),(p.length>0||g.degraded.length>0)&&(0,f.jsxs)(`div`,{role:`alert`,className:`mb-5 rounded-lg border border-danger/40 bg-danger/10 p-4 text-sm`,children:[(0,f.jsx)(`strong`,{children:`Partial results.`}),` `,[...new Set([...p,...g.degraded].map(e=>e.kind))].join(`, `),` could not be loaded.`]}),E&&(0,f.jsx)(`p`,{role:`status`,className:`mb-5 rounded-lg bg-muted px-4 py-3 text-sm`,children:E}),(0,f.jsx)(o,{title:`Queue`,description:`${O.length} matching item${O.length===1?``:`s`}`,actions:(0,f.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,f.jsxs)(`select`,{"aria-label":`Queue state`,value:v,onChange:e=>y(e.target.value),children:[(0,f.jsx)(`option`,{value:`open`,children:`Open`}),(0,f.jsx)(`option`,{value:`acknowledged`,children:`History`}),(0,f.jsx)(`option`,{value:`all`,children:`All`})]}),(0,f.jsxs)(`select`,{"aria-label":`Severity`,value:S,onChange:e=>C(e.target.value),children:[(0,f.jsx)(`option`,{value:`all`,children:`All severities`}),(0,f.jsx)(`option`,{value:`action_required`,children:`Action required`}),(0,f.jsx)(`option`,{value:`error`,children:`Errors`}),(0,f.jsx)(`option`,{value:`warning`,children:`Warnings`})]}),(0,f.jsxs)(`select`,{"aria-label":`Kind`,value:b,onChange:e=>x(e.target.value),children:[(0,f.jsx)(`option`,{value:`all`,children:`All kinds`}),(0,f.jsx)(`option`,{value:`communication_approval`,children:`Approvals`}),(0,f.jsx)(`option`,{value:`lesson_proposal`,children:`Lessons`}),(0,f.jsx)(`option`,{value:`review_failure`,children:`Review failures`}),(0,f.jsx)(`option`,{value:`trigger_failure`,children:`Trigger failures`}),(0,f.jsx)(`option`,{value:`agent_loop_break`,children:`Loop breaks`})]})]}),children:O.length===0?(0,f.jsx)(l,{title:v===`open`?`Nothing needs attention`:`No matching history`,description:`The queue updates from Bazilion's canonical approvals, learning, triggers, and loop diagnostics.`}):(0,f.jsx)(`div`,{className:`grid gap-3`,children:O.map(e=>(0,f.jsx)(`article`,{className:`rounded-lg border border-border p-4`,children:(0,f.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,f.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,f.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,f.jsx)(a,{variant:e.severity===`action_required`?`warning`:e.severity===`error`?`danger`:`info`,children:e.severity.replace(`_`,` `)}),(0,f.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.kind.replaceAll(`_`,` `)})]}),(0,f.jsx)(`h3`,{className:`mt-2 text-base`,children:e.title}),(0,f.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:e.diagnostic}),(0,f.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[[e.agentName,e.teamName].filter(Boolean).join(` · `)||`System`,` · `,(0,f.jsx)(`time`,{dateTime:new Date(e.occurredAt).toISOString(),children:new Date(e.occurredAt).toLocaleString()})]})]}),(0,f.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[(0,f.jsx)(r,{to:e.href,className:`btn-primary`,children:e.kind===`communication_approval`?`Review approval`:e.kind===`lesson_proposal`?`Review lesson`:`Inspect source`}),e.acknowledgeable&&(0,f.jsx)(u,{variant:`ghost`,disabled:w===e.key,onClick:()=>void A(e,e.acknowledgedAt===null),children:e.acknowledgedAt===null?`Acknowledge`:`Restore to open`})]})]})},e.key))})})]})}function m({label:e,value:t}){return(0,f.jsxs)(`div`,{className:`card p-4`,children:[(0,f.jsx)(`div`,{className:`text-xs font-semibold uppercase text-muted-foreground`,children:e}),(0,f.jsx)(`div`,{className:`mt-1 text-2xl font-semibold`,children:t})]})}export{p as component};
1
+ import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{a as r}from"./preload-helper-bztXdkDj.js";import{F as i}from"./index-Bi-HxcPG.js";import{a,i as o,n as s,r as c,t as l}from"./Page-NV96O47A.js";import{t as u}from"./Button-ByiV6fpd.js";var d=e(n()),f=t();function p(){let e=i.useLoaderData(),[t,n]=(0,d.useState)(e.list.items),[p,h]=(0,d.useState)(e.list.degraded),[g,_]=(0,d.useState)(e.summary),[v,y]=(0,d.useState)(`open`),[b,x]=(0,d.useState)(`all`),[S,C]=(0,d.useState)(`all`),[w,T]=(0,d.useState)(null),[E,D]=(0,d.useState)(null),O=(0,d.useMemo)(()=>t.filter(e=>(v===`all`||(v===`open`?e.acknowledgedAt===null:e.acknowledgedAt!==null))&&(b===`all`||e.kind===b)&&(S===`all`||e.severity===S)),[t,b,S,v]);async function k(){let[e,t]=await Promise.all([fetch(`/api/attention?state=all&limit=200`),fetch(`/api/attention/summary`)]);if(!e.ok||!t.ok)throw Error(`Could not refresh the Attention Center`);let r=await e.json();n(r.items),h(r.degraded),_(await t.json())}async function A(e,t){T(e.key),D(null);try{let n=await fetch(`/api/attention/${encodeURIComponent(e.key)}/${t?`acknowledge`:`acknowledgement`}`,{method:t?`POST`:`DELETE`}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error(r.error??`Update failed (${n.status})`);await k()}catch(e){D(e instanceof Error?e.message:String(e)),await k().catch(()=>{})}finally{T(null)}}async function j(){T(`all`),D(null);try{let e=await fetch(`/api/attention/acknowledge-all`,{method:`POST`}),t=await e.json();if(!e.ok)throw Error(t.error??`Acknowledgement failed`);D(`Acknowledged ${t.acknowledged} informational item(s). Approvals and lessons were left open.`),await k()}catch(e){D(e instanceof Error?e.message:String(e))}finally{T(null)}}return(0,f.jsxs)(c,{size:`wide`,children:[(0,f.jsx)(s,{eyebrow:`Operations`,title:`Attention Center`,description:`One queue for decisions and terminal signals. Resolve action-required work at its canonical source; acknowledge informational failures here.`,actions:(0,f.jsx)(u,{variant:`ghost`,disabled:w!==null,onClick:()=>void j(),children:`Acknowledge all informational items`})}),(0,f.jsxs)(`div`,{className:`mb-5 grid gap-3 sm:grid-cols-3`,children:[(0,f.jsx)(m,{label:`Open`,value:g.openTotal}),(0,f.jsx)(m,{label:`Action required`,value:g.bySeverity.action_required}),(0,f.jsx)(m,{label:`Errors and warnings`,value:g.bySeverity.error+g.bySeverity.warning})]}),(p.length>0||g.degraded.length>0)&&(0,f.jsxs)(`div`,{role:`alert`,className:`mb-5 rounded-lg border border-danger/40 bg-danger/10 p-4 text-sm`,children:[(0,f.jsx)(`strong`,{children:`Partial results.`}),` `,[...new Set([...p,...g.degraded].map(e=>e.kind))].join(`, `),` could not be loaded.`]}),E&&(0,f.jsx)(`p`,{role:`status`,className:`mb-5 rounded-lg bg-muted px-4 py-3 text-sm`,children:E}),(0,f.jsx)(o,{title:`Queue`,description:`${O.length} matching item${O.length===1?``:`s`}`,actions:(0,f.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,f.jsxs)(`select`,{"aria-label":`Queue state`,value:v,onChange:e=>y(e.target.value),children:[(0,f.jsx)(`option`,{value:`open`,children:`Open`}),(0,f.jsx)(`option`,{value:`acknowledged`,children:`History`}),(0,f.jsx)(`option`,{value:`all`,children:`All`})]}),(0,f.jsxs)(`select`,{"aria-label":`Severity`,value:S,onChange:e=>C(e.target.value),children:[(0,f.jsx)(`option`,{value:`all`,children:`All severities`}),(0,f.jsx)(`option`,{value:`action_required`,children:`Action required`}),(0,f.jsx)(`option`,{value:`error`,children:`Errors`}),(0,f.jsx)(`option`,{value:`warning`,children:`Warnings`})]}),(0,f.jsxs)(`select`,{"aria-label":`Kind`,value:b,onChange:e=>x(e.target.value),children:[(0,f.jsx)(`option`,{value:`all`,children:`All kinds`}),(0,f.jsx)(`option`,{value:`communication_approval`,children:`Approvals`}),(0,f.jsx)(`option`,{value:`lesson_proposal`,children:`Lessons`}),(0,f.jsx)(`option`,{value:`review_failure`,children:`Review failures`}),(0,f.jsx)(`option`,{value:`trigger_failure`,children:`Trigger failures`}),(0,f.jsx)(`option`,{value:`agent_loop_break`,children:`Loop breaks`})]})]}),children:O.length===0?(0,f.jsx)(l,{title:v===`open`?`Nothing needs attention`:`No matching history`,description:`The queue updates from Bazilion's canonical approvals, learning, triggers, and loop diagnostics.`}):(0,f.jsx)(`div`,{className:`grid gap-3`,children:O.map(e=>(0,f.jsx)(`article`,{className:`rounded-lg border border-border p-4`,children:(0,f.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,f.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,f.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,f.jsx)(a,{variant:e.severity===`action_required`?`warning`:e.severity===`error`?`danger`:`info`,children:e.severity.replace(`_`,` `)}),(0,f.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.kind.replaceAll(`_`,` `)})]}),(0,f.jsx)(`h3`,{className:`mt-2 text-base`,children:e.title}),(0,f.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:e.diagnostic}),(0,f.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[[e.agentName,e.teamName].filter(Boolean).join(` · `)||`System`,` · `,(0,f.jsx)(`time`,{dateTime:new Date(e.occurredAt).toISOString(),children:new Date(e.occurredAt).toLocaleString()})]})]}),(0,f.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[(0,f.jsx)(r,{to:e.href,className:`btn-primary`,children:e.kind===`communication_approval`?`Review approval`:e.kind===`lesson_proposal`?`Review lesson`:`Inspect source`}),e.acknowledgeable&&(0,f.jsx)(u,{variant:`ghost`,disabled:w===e.key,onClick:()=>void A(e,e.acknowledgedAt===null),children:e.acknowledgedAt===null?`Acknowledge`:`Restore to open`})]})]})},e.key))})})]})}function m({label:e,value:t}){return(0,f.jsxs)(`div`,{className:`card p-4`,children:[(0,f.jsx)(`div`,{className:`text-xs font-semibold uppercase text-muted-foreground`,children:e}),(0,f.jsx)(`div`,{className:`mt-1 text-2xl font-semibold`,children:t})]})}export{p as component};
@@ -0,0 +1 @@
1
+ import{ct as e}from"./index-Bi-HxcPG.js";var t=e(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]);export{t};
@@ -0,0 +1,3 @@
1
+ import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{d as r}from"./preload-helper-bztXdkDj.js";import{t as i}from"./chevron-right-DSa4xPTs.js";import{t as a}from"./ConfirmDialog-BzIiABOP.js";import{I as o,at as s,ct as c,ot as l}from"./index-Bi-HxcPG.js";import{a as u,t as d}from"./Page-NV96O47A.js";import{t as f}from"./Button-ByiV6fpd.js";import{t as p}from"./ConfigPage-BCLp-FUC.js";import{t as m}from"./FieldRow-W_54rw5c.js";var h=c(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),g=c(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),_=c(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),v=e(n()),y=t();function b({status:e}){let t=e.configuredOperatorHttp,n=e.protectedUnattendedTurns;return(0,y.jsxs)(`section`,{className:`overflow-hidden rounded-lg border bg-card`,children:[(0,y.jsxs)(`header`,{className:`border-b px-4 py-3`,children:[(0,y.jsx)(`h2`,{className:`font-semibold`,children:`Execution security`}),(0,y.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Operator HTTP requests keep their configured compatibility behavior. Unattended sources use a separate mandatory protected baseline.`})]}),(0,y.jsxs)(`div`,{className:`grid gap-4 p-4 lg:grid-cols-2`,children:[(0,y.jsxs)(`section`,{className:`rounded-md border bg-muted/20 p-3`,children:[(0,y.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,y.jsx)(`h3`,{className:`font-semibold`,children:`Configured operator HTTP`}),(0,y.jsx)(x,{ok:!1,children:`legacy · unprotected`})]}),(0,y.jsxs)(`dl`,{className:`space-y-2 text-sm`,children:[(0,y.jsx)(S,{label:`Coding surface`,value:C(t.codingSurface)}),(0,y.jsx)(S,{label:`Docker image`,value:t.dockerImage,mono:!0}),(0,y.jsx)(S,{label:`Browser`,value:t.browser}),(0,y.jsx)(S,{label:`MCP`,value:t.mcp})]}),(0,y.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:`This compatibility branch is for operator requests; Telegram and unattended delivery never select it.`})]}),(0,y.jsxs)(`section`,{className:`rounded-md border p-3 ${n.baseRuntimeReady?`border-success/25 bg-success/5`:`border-warning/25 bg-warning/10`}`,children:[(0,y.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,y.jsx)(`h3`,{className:`font-semibold`,children:`Protected unattended turns`}),(0,y.jsx)(x,{ok:n.baseRuntimeReady,children:n.baseRuntimeReady?`base runtime ready`:`base runtime unavailable`})]}),(0,y.jsx)(`p`,{className:`mb-3 text-xs text-muted-foreground`,children:`Telegram, schedules, inbox wake-ups, and approval delivery cannot select the legacy surface.`}),(0,y.jsxs)(`dl`,{className:`space-y-2 text-sm`,children:[(0,y.jsx)(S,{label:`Coding surface`,value:`Docker only`}),(0,y.jsx)(S,{label:`Docker`,value:n.docker.ready?`ready`:`unavailable`,ok:n.docker.ready}),(0,y.jsx)(S,{label:`Docker image`,value:n.docker.image,mono:!0}),n.docker.reason&&(0,y.jsx)(S,{label:`Docker reason`,value:n.docker.reason}),(0,y.jsx)(S,{label:`OpenAI Codex enabled`,value:w(n.openaiCodex.enabled),ok:n.openaiCodex.enabled}),(0,y.jsx)(S,{label:`ChatGPT connected`,value:w(n.openaiCodex.connected),ok:n.openaiCodex.connected}),(0,y.jsx)(S,{label:`OpenAI access`,value:T(n.openaiCodex),ok:n.openaiCodex.accessCurrent||n.openaiCodex.refreshOnNextTurn}),(0,y.jsx)(S,{label:`OpenAI Codex baseline eligible`,value:w(n.openaiCodex.baselineEligible),ok:n.openaiCodex.baselineEligible}),(0,y.jsx)(S,{label:`Browser`,value:n.browser,ok:!0}),(0,y.jsx)(S,{label:`MCP`,value:n.mcp,ok:!0})]}),n.remediation&&(0,y.jsxs)(`p`,{className:`mt-3 rounded-md border border-warning/25 bg-background/60 px-3 py-2 text-xs text-warning`,children:[(0,y.jsx)(`strong`,{children:`Remediation:`}),` `,n.remediation]}),(0,y.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:`Every turn separately validates its selected normal/review model, bound OAuth refresh, and Team/input/memory/skill mounts and paths before execution.`})]})]})]})}function x({ok:e,children:t}){return(0,y.jsx)(`span`,{className:`rounded-full px-2 py-0.5 text-xs font-semibold uppercase ${e?`bg-success/10 text-success`:`bg-warning/10 text-warning`}`,children:t})}function S({label:e,value:t,ok:n,mono:r=!1}){return(0,y.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,y.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,y.jsx)(`dd`,{className:`${r?`font-mono`:`font-medium`} text-right ${n===void 0?``:n?`text-success`:`text-warning`}`,children:t})]})}function C(e){return e===`host`?`Host tools`:e===`docker`?`Docker only`:`Unavailable`}function w(e){return e?`yes`:`no`}function T(e){return e.accessCurrent?`current`:e.refreshOnNextTurn?`refresh on next turn`:`unavailable`}var E=new Set([`openai-codex`,`openai`,`anthropic`,`google`]),D=new Set([`ollama`,`lmstudio`,`llamacpp`]);function O(e){return e.enabled||e.curated.length>0||e.fields.some(e=>e.set)}function k(e,t){let n=t.trim().toLocaleLowerCase();return n?[e.id,e.displayName,e.hint??``,e.envHint,...e.fields.flatMap(e=>[e.label,e.envVar]),...e.curated,...e.catalog].some(e=>e.toLocaleLowerCase().includes(n)):!0}function A(e,t=``){let n=e.filter(e=>k(e,t)),r=n.filter(O),i=new Set(r.map(e=>e.id)),a=n.filter(e=>!i.has(e.id));return[{key:`configured`,title:`Configured`,description:`Providers you enabled, added models to, or saved credentials for.`,providers:r},{key:`recommended`,title:`Recommended starting points`,description:`The simplest hosted options for a first Bazilion conversation.`,providers:a.filter(e=>E.has(e.id))},{key:`local`,title:`Local models`,description:`Use a model server on the same machine without exposing the daemon.`,providers:a.filter(e=>D.has(e.id))},{key:`more`,title:`More providers`,description:`Specialist, regional, enterprise, and subscription endpoints.`,providers:a.filter(e=>!E.has(e.id)&&!D.has(e.id))}].filter(e=>e.providers.length>0)}function j(e){return e.enabled?e.curated.length===0?{label:`Needs a model`,tone:`warning`}:{label:`Configured, unverified`,tone:`warning`}:O(e)?{label:`Saved, disabled`,tone:`neutral`}:{label:`Not configured`,tone:`neutral`}}function M(){let{providers:e,openaiCodex:t,executionSecurity:n}=o.useLoaderData(),r=e.some(e=>e.enabled&&e.curated.length>0),a=(0,v.useRef)(r),[c,u]=(0,v.useState)(!1),[m,x]=(0,v.useState)(``),S=(0,v.useMemo)(()=>A(e,m),[e,m]),C=e.filter(O).length,w=e.filter(e=>e.enabled).length;return(0,v.useEffect)(()=>{!a.current&&r&&u(!0)},[r]),(0,y.jsxs)(p,{active:`providers`,title:`Providers`,description:(0,y.jsx)(y.Fragment,{children:`Connect the model services your agents may use. Credentials stay encrypted; advanced endpoint and environment names remain available inside each provider.`}),children:[(0,y.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,"aria-label":`Provider summary`,children:[(0,y.jsx)(N,{label:`Configured`,value:C,detail:`credentials, models, or toggle`}),(0,y.jsx)(N,{label:`Enabled`,value:w,detail:`available to agent runtime`}),(0,y.jsx)(N,{label:`Selected models`,value:e.reduce((e,t)=>e+(t.enabled?t.curated.length:0),0),detail:`configured; test connectivity separately`})]}),(0,y.jsxs)(`details`,{className:`rounded-2xl border border-border bg-card shadow-baziu-sm`,children:[(0,y.jsxs)(`summary`,{className:`flex min-h-12 cursor-pointer list-none items-center gap-3 px-4 py-3 text-sm font-semibold text-foreground marker:hidden sm:px-5`,children:[(0,y.jsx)(s,{className:`size-4 text-primary`,"aria-hidden":`true`}),`Execution security`,(0,y.jsx)(`span`,{className:`ml-auto text-xs font-normal text-muted-foreground`,children:`Inspect host and protected-turn posture`}),(0,y.jsx)(l,{className:`size-4 text-muted-foreground`,"aria-hidden":`true`})]}),(0,y.jsx)(`div`,{className:`border-t border-border p-3 sm:p-4`,children:(0,y.jsx)(b,{status:n})})]}),!r&&(0,y.jsx)(P,{providers:e,openaiCodex:t}),c&&(0,y.jsx)(`section`,{role:`status`,className:`rounded-2xl border border-success/30 bg-success/10 p-5 text-sm`,children:(0,y.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,y.jsx)(h,{className:`mt-0.5 size-5 shrink-0 text-success`,"aria-hidden":`true`}),(0,y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,y.jsx)(`h2`,{className:`m-0 font-body text-base font-semibold text-foreground`,children:`Your default workspace is ready`}),(0,y.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:`Bazilion created the default Agent template and Team. Test the selected model below before relying on it, or continue to spawn your first agent.`}),(0,y.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,y.jsxs)(`a`,{href:`/agents`,className:`btn-primary no-underline`,children:[`Spawn your first agent`,(0,y.jsx)(i,{className:`size-4`,"aria-hidden":`true`})]}),(0,y.jsx)(f,{variant:`ghost`,onClick:()=>u(!1),children:`Keep configuring`})]})]})]})}),(0,y.jsxs)(`div`,{className:`rounded-2xl border border-border bg-card p-4 shadow-baziu-sm sm:p-5`,children:[(0,y.jsx)(`label`,{htmlFor:`provider-search`,className:`m-0 text-sm font-semibold text-foreground`,children:`Find a provider`}),(0,y.jsxs)(`div`,{className:`relative mt-2`,children:[(0,y.jsx)(g,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`,"aria-hidden":`true`}),(0,y.jsx)(`input`,{id:`provider-search`,type:`search`,value:m,onChange:e=>x(e.target.value),placeholder:`Search by service, model, or advanced key`,className:`pl-9`})]}),(0,y.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-muted-foreground`,children:`Start with one provider. Everything else stays collapsed until you need it.`})]}),S.length===0?(0,y.jsx)(d,{icon:(0,y.jsx)(g,{className:`size-4`,"aria-hidden":`true`}),title:`No providers match`,description:`Try another search instead of “${m}”.`,actions:(0,y.jsx)(f,{variant:`ghost`,onClick:()=>x(``),children:`Clear search`})}):(0,y.jsx)(`div`,{className:`space-y-4`,children:S.map(e=>(0,y.jsxs)(`details`,{open:!!m||e.key===`configured`||!r&&e.key===`recommended`,className:`group/providers overflow-hidden rounded-2xl border border-border bg-card shadow-baziu-sm`,children:[(0,y.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-3 px-4 py-4 marker:hidden sm:px-5`,children:[(0,y.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-xl bg-accent text-accent-foreground`,children:(0,y.jsx)(_,{className:`size-4`,"aria-hidden":`true`})}),(0,y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,y.jsx)(`span`,{className:`block text-sm font-semibold text-foreground`,children:e.title}),(0,y.jsx)(`span`,{className:`mt-0.5 block text-xs leading-5 text-muted-foreground`,children:e.description})]}),(0,y.jsx)(`span`,{className:`rounded-full border border-border bg-muted px-2 py-0.5 text-xs font-semibold text-muted-foreground`,children:e.providers.length}),(0,y.jsx)(l,{className:`size-4 shrink-0 text-muted-foreground transition-transform group-open/providers:rotate-180`,"aria-hidden":`true`})]}),(0,y.jsx)(`div`,{className:`space-y-2 border-t border-border bg-muted/20 p-2 sm:p-3`,children:e.providers.map(e=>(0,y.jsx)(F,{p:e,initiallyOpen:e.enabled||!!m||!r&&e.id===`openai-codex`,openaiCodexStatus:e.id===`openai-codex`?t:void 0},e.id))})]},`${e.key}:${m}`))})]})}function N({label:e,value:t,detail:n}){return(0,y.jsxs)(`div`,{className:`min-w-0 rounded-2xl border border-border bg-card p-4 shadow-baziu-sm`,children:[(0,y.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:e}),(0,y.jsx)(`div`,{className:`mt-1 text-2xl font-semibold text-foreground`,children:t}),(0,y.jsx)(`div`,{className:`mt-0.5 text-xs leading-5 text-muted-foreground`,children:n})]})}function P({providers:e,openaiCodex:t}){let n=[];for(let r of e)r.enabled&&(r.id===`openai-codex`&&!t.connected&&n.push(`${r.id}: enabled but ChatGPT is not connected — click "Connect ChatGPT" below`),r.curated.length===0&&n.push(`${r.id}: enabled but no curated models — add at least one name in the "curated models" box below and save`));let r=e.filter(e=>e.enabled).length;return(0,y.jsxs)(`div`,{role:`status`,className:`rounded-2xl border border-warning/30 bg-warning/10 p-5 text-sm`,children:[(0,y.jsx)(`div`,{className:`font-semibold text-foreground mb-1`,children:`Finish your first provider`}),(0,y.jsx)(`p`,{className:`text-muted-foreground mb-2`,children:`Enable one provider, save at least one exact model id, then send the small test request. Saving the model creates your default resources; a successful test confirms that the credential and model actually work.`}),n.length>0?(0,y.jsx)(`ul`,{className:`list-disc space-y-1 pl-5 text-warning`,children:n.map(e=>(0,y.jsx)(`li`,{children:e},e))}):r===0?(0,y.jsx)(`p`,{className:`text-warning`,children:`No provider is enabled. Open a recommended option below and follow its steps.`}):null]})}function F({p:e,openaiCodexStatus:t,initiallyOpen:n}){let a=r(),[o,s]=(0,v.useState)(e.enabled),[c,l]=(0,v.useState)(n),[d,p]=(0,v.useState)(e.curated.join(`
2
+ `)),[h,g]=(0,v.useState)(!1),[_,b]=(0,v.useState)(null),[x,S]=(0,v.useState)(null),[C,w]=(0,v.useState)(e.curated[0]??``),[T,E]=(0,v.useState)(!1),[D,O]=(0,v.useState)(null),k=j({...e,enabled:o});async function A(t){s(t),S(null);try{let n=await fetch(`/api/config/providers/${encodeURIComponent(e.id)}/enabled`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({enabled:t})});if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error??`Could not update provider (${n.status})`)}t&&l(!0),await a.invalidate()}catch(e){s(!t),S(e instanceof Error?e.message:String(e))}}async function M(t){t.preventDefault(),g(!0),b(null);try{let t=d.split(/\r?\n/).map(e=>e.trim()).filter(Boolean),n=await fetch(`/api/config/providers/${encodeURIComponent(e.id)}/models`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({models:t})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??`${n.status} ${n.statusText}`)}b({kind:`success`,message:`Models saved. Run the connection test before relying on them.`}),w(t[0]??``),O(null),await a.invalidate()}catch(e){b({kind:`error`,message:e.message})}finally{g(!1)}}async function N(){if(C){E(!0),O(null);try{let t=await fetch(`/api/providers/test`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({model:`${e.id}:${C}`,message:`Reply with exactly: Bazilion connection verified.`})}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error??`Connection test failed (${t.status})`);O({kind:`success`,message:`Verified ${e.displayName} with ${C}.`}),await a.invalidate()}catch(e){O({kind:`error`,message:e instanceof Error?e.message:String(e)})}finally{E(!1)}}}return(0,y.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-border bg-card`,children:[(0,y.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-center gap-2 px-3 py-3 sm:px-4`,children:[(0,y.jsxs)(`button`,{type:`button`,className:`unstyled flex min-w-0 flex-1 items-center gap-2 rounded-lg text-left`,"aria-expanded":c,"aria-controls":`provider-${e.id}`,onClick:()=>l(e=>!e),children:[(0,y.jsx)(i,{className:`size-4 shrink-0 text-muted-foreground transition-transform ${c?`rotate-90`:``}`,"aria-hidden":`true`}),(0,y.jsxs)(`span`,{className:`min-w-0`,children:[(0,y.jsx)(`span`,{className:`block truncate text-sm font-semibold text-foreground`,children:e.displayName}),(0,y.jsx)(`span`,{className:`block truncate font-mono text-xs text-muted-foreground`,children:e.id})]})]}),(0,y.jsx)(u,{variant:k.tone===`success`?`success`:k.tone===`warning`?`warning`:`neutral`,children:k.label}),(0,y.jsxs)(`label`,{className:`m-0 flex cursor-pointer items-center gap-1.5 rounded-lg px-1 text-xs font-semibold`,children:[(0,y.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>A(e.target.checked),className:`size-4`,"aria-label":`${o?`Disable`:`Enable`} ${e.displayName}`}),(0,y.jsx)(`span`,{className:o?`text-success`:`text-muted-foreground`,children:o?`enabled`:`disabled`})]}),(0,y.jsxs)(`span`,{className:`w-full pl-6 text-xs text-muted-foreground sm:w-auto sm:pl-0`,children:[e.curated.length>0&&(0,y.jsxs)(`span`,{children:[e.curated.length,` curated`]}),e.catalog.length>0&&(0,y.jsxs)(`span`,{children:[` · `,e.catalog.length,` catalog`]}),e.live&&!e.live.error&&(0,y.jsxs)(`span`,{children:[` · `,e.live.models.length,` live`]})]})]}),x&&(0,y.jsx)(`p`,{role:`alert`,className:`mx-4 mb-3 text-sm text-danger`,children:x}),c&&(0,y.jsxs)(`div`,{id:`provider-${e.id}`,className:`border-t border-dashed px-3 py-4 sm:px-4`,children:[e.hint&&(0,y.jsx)(`p`,{className:`text-xs text-muted-foreground mb-2`,children:e.hint}),e.id===`openai-codex`&&t&&(0,y.jsx)(R,{status:t}),e.fields.length===0&&e.envHint&&e.id!==`openai-codex`&&(0,y.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Credentials come from the process env: `,(0,y.jsx)(`code`,{className:`font-mono`,children:e.envHint})]}),e.fields.map(e=>(0,y.jsx)(m,{field:e},e.envVar)),(0,y.jsx)(`h4`,{id:`provider-${e.id}-models-label`,className:`mt-4 mb-1 font-body text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:`Models available to agents`}),e.curated.length===0&&(0,y.jsxs)(`p`,{className:`mb-2 text-xs font-medium text-warning`,children:[`First-run setup needs at least one model name here — type one (e.g.`,` `,(0,y.jsx)(`code`,{className:`font-mono`,children:I(e.id)}),`) and click`,` `,(0,y.jsx)(`em`,{children:`save models`}),`. Catalog chips below are the safest source when available.`]}),(0,y.jsxs)(`form`,{onSubmit:M,children:[(0,y.jsx)(`textarea`,{id:`provider-${e.id}-models`,"aria-labelledby":`provider-${e.id}-models-label`,value:d,onChange:e=>p(e.target.value),rows:Math.max(3,Math.min(8,d.split(`
3
+ `).length)),className:`w-full rounded-md border bg-background px-2 py-1.5 font-mono text-sm outline-none focus:ring-2 focus:ring-ring/30`,placeholder:e.catalog.length===0&&!e.live?`Type model names one per line, e.g. qwen3-coder-30b`:`Click catalog chips below, or type names one per line`}),(0,y.jsxs)(`div`,{className:`flex items-center gap-3 mt-2`,children:[(0,y.jsx)(`button`,{type:`submit`,disabled:h,className:`rounded-md bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground disabled:opacity-50`,children:h?`Saving…`:`Save models`}),_&&(0,y.jsx)(`span`,{role:_.kind===`error`?`alert`:`status`,className:`text-xs ${_.kind===`error`?`text-danger`:`text-success`}`,children:_.message})]})]}),e.catalog.length>0&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`h4`,{className:`mt-4 mb-1 text-xs uppercase tracking-wide text-muted-foreground`,children:`catalog`}),(0,y.jsx)(L,{items:e.catalog,onPick:e=>p(t=>t.includes(e)?t:`${t}\n${e}`.trim())})]}),e.live&&!e.live.error&&e.live.models.length>0&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`h4`,{className:`mt-4 mb-1 text-xs uppercase tracking-wide text-muted-foreground`,children:`live`}),(0,y.jsx)(L,{items:e.live.models,onPick:e=>p(t=>t.includes(e)?t:`${t}\n${e}`.trim())})]}),e.live?.error&&(0,y.jsxs)(`p`,{role:`alert`,className:`text-xs text-danger mt-2`,children:[`Could not fetch live models: `,e.live.error]}),o&&e.curated.length>0&&(0,y.jsxs)(`div`,{className:`mt-4 rounded-xl border border-border bg-muted/30 p-3`,children:[(0,y.jsx)(`h4`,{className:`m-0 font-body text-sm font-semibold text-foreground`,children:`Test the connection`}),(0,y.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-muted-foreground`,children:`Sends one short real request. Your provider may charge its normal token cost.`}),(0,y.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2 sm:flex-row sm:items-end`,children:[(0,y.jsxs)(`label`,{className:`m-0 min-w-0 flex-1 text-xs font-semibold text-foreground`,children:[`Model`,(0,y.jsx)(`select`,{className:`mt-1`,value:C,onChange:e=>w(e.target.value),children:e.curated.map(e=>(0,y.jsx)(`option`,{value:e,children:e},e))})]}),(0,y.jsx)(f,{variant:`ghost`,disabled:T||!C,onClick:()=>void N(),children:T?`Testing…`:`Send test request`})]}),D&&(0,y.jsx)(`p`,{role:D.kind===`error`?`alert`:`status`,className:`mt-3 rounded-lg px-3 py-2 text-sm ${D.kind===`error`?`bg-danger/10 text-danger`:`bg-success/10 text-success`}`,children:D.message})]})]})]})}function I(e){switch(e){case`openai-codex`:return`gpt-6-astra`;case`openai`:return`gpt-6-astra`;case`anthropic`:return`claude-opus-5`;case`google`:return`gemini-3.6-flash`;case`google-vertex`:return`gemini-3.6-flash`;case`xai`:return`grok-4.5`;case`groq`:return`llama-3.3-70b-versatile`;case`cerebras`:return`gpt-oss-120b`;case`mistral`:return`mistral-large-latest`;case`zai`:return`glm-5.2`;case`huggingface`:return`Qwen/Qwen3.5-397B-A17B`;case`openrouter`:return`anthropic/claude-opus-5`;case`vercel-ai-gateway`:return`anthropic/claude-opus-5`;case`deepseek`:return`deepseek-v4-pro`;case`fireworks`:return`accounts/fireworks/models/kimi-k3`;case`together`:return`moonshotai/Kimi-K3`;case`baseten`:return`moonshotai/Kimi-K3`;case`moonshotai`:return`kimi-k3`;case`moonshotai-cn`:return`kimi-k3`;case`kimi-coding`:return`kimi-for-coding`;case`minimax`:return`MiniMax-M2.7`;case`minimax-cn`:return`MiniMax-M3`;case`qwen-token-plan`:return`qwen3.8-max`;case`qwen-token-plan-cn`:case`qwen-token-plan-individual`:return`qwen3.8-max`;case`ant-ling`:return`Ling-2.6-1T`;case`nvidia`:return`nvidia/nemotron-3-super-120b-a12b`;case`cloudflare-workers-ai`:return`@cf/moonshotai/kimi-k2.6`;case`cloudflare-ai-gateway`:return`claude-opus-5`;case`github-copilot`:return`claude-opus-5`;case`xiaomi`:return`mimo-v2.5`;case`xiaomi-token-plan-ams`:case`xiaomi-token-plan-cn`:case`xiaomi-token-plan-sgp`:return`mimo-v2.5-pro`;case`opencode`:return`claude-opus-5`;case`opencode-go`:return`kimi-k2.7-code`;case`zai-coding-cn`:return`glm-5.2`;case`azure-openai`:return`gpt-5.6-luna`;case`bedrock`:return`global.anthropic.claude-opus-5`;case`ollama`:return`llama3.3`;case`lmstudio`:return`qwen3-coder-30b`;case`llamacpp`:return`unsloth/Qwen3.6-35B-A3B-MTP-GGUF:MXFP4_MOE`;default:return`model-name`}}function L({items:e,onPick:t}){return(0,y.jsx)(`div`,{className:`flex flex-wrap gap-1.5 max-h-40 overflow-y-auto rounded-md border bg-background p-1.5`,children:e.map(e=>(0,y.jsx)(`button`,{type:`button`,onClick:()=>t(e),"aria-label":`Add ${e} to selected models`,className:`rounded border bg-card px-2 py-0.5 font-mono text-xs hover:border-primary hover:bg-accent`,children:e},e))})}function R({status:e}){let t=r(),[n,i]=(0,v.useState)(!1),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!1),u=(0,v.useRef)(null);(0,v.useEffect)(()=>()=>{u.current?.abort()},[]);async function d(){u.current?.abort();let e=new AbortController;u.current=e,i(!0),s(null);try{let n=await fetch(`/api/auth/openai/login`,{method:`POST`,signal:e.signal});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??`${n.status} ${n.statusText}`)}if(e.signal.aborted)return;await t.invalidate()}catch(t){if(e.signal.aborted)return;s(t.message)}finally{u.current===e&&(u.current=null,e.signal.aborted||i(!1))}}async function p(){i(!0),s(null);try{let e=await fetch(`/api/auth/openai`,{method:`DELETE`});if(!e.ok&&e.status!==204){let t=await e.json().catch(()=>null);throw Error(t?.error??`Could not disconnect ChatGPT (${e.status})`)}await t.invalidate()}catch(e){throw s(e instanceof Error?e.message:String(e)),e}finally{i(!1)}}return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{className:`rounded-md border bg-muted/30 p-3 mb-3`,children:[e.connected?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{className:`flex flex-wrap gap-2 items-center mb-2`,children:[(0,y.jsx)(`span`,{className:`rounded-full bg-success/10 text-success px-2 py-0.5 text-xs font-semibold uppercase`,children:`connected`}),e.accountId&&(0,y.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`account `,(0,y.jsx)(`code`,{className:`font-mono`,children:e.accountId})]}),e.expiresAt&&(0,y.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`token expires`,` `,new Date(e.expiresAt).toISOString().replace(/\.\d+Z$/,`Z`)]})]}),(0,y.jsx)(f,{variant:`danger`,onClick:()=>l(!0),disabled:n,children:`Disconnect ChatGPT`})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`p`,{className:`text-xs text-muted-foreground mb-2`,children:[`Sign in with your ChatGPT account — the OAuth flow opens a new browser tab. The loopback callback at `,(0,y.jsx)(`code`,{className:`font-mono`,children:`localhost:1455`}),` only works when you're using the web UI on the same machine as the daemon. For remote setups or callback trouble, run`,` `,(0,y.jsx)(`code`,{className:`font-mono`,children:`bazilion auth openai login --device-code`}),` on the client. From a source checkout, run`,` `,(0,y.jsx)(`code`,{className:`font-mono`,children:`pnpm tsx apps/cli/src/index.ts auth openai login --device-code`}),` `,`from the repository root.`]}),(0,y.jsx)(f,{variant:`primary`,onClick:d,disabled:n,children:n?`opening browser…`:`Connect ChatGPT →`})]}),o&&(0,y.jsx)(`p`,{role:`alert`,className:`text-sm text-danger mt-2`,children:o})]}),(0,y.jsx)(a,{open:c,onOpenChange:l,title:`Disconnect ChatGPT?`,description:(0,y.jsxs)(`p`,{children:[`This removes the saved OpenAI Codex OAuth credentials. Agents using an`,` `,(0,y.jsx)(`code`,{children:`openai-codex`}),` model will stop working until you connect again.`]}),confirmLabel:`Disconnect ChatGPT`,onConfirm:p})]})}export{M as component};
@@ -0,0 +1,3 @@
1
+ import{L as e,S as t,v as n,y as r}from"./preload-helper-bztXdkDj.js";var i=`__TSS_CONTEXT`,a=Symbol.for(`TSS_SERVER_FUNCTION`),o=Symbol.for(`TSS_SERVER_FUNCTION_FACTORY`),s=`application/x-tss-framed`,c={JSON:0,CHUNK:1,END:2,ERROR:3};`${s}`;var l=/;\s*v=(\d+)/;function u(e){let t=e.match(l);return t?parseInt(t[1],10):void 0}function d(e){let t=u(e);if(t!==void 0&&t!==1)throw Error(`Incompatible framed protocol version: server=${t}, client=1. Please ensure client and server are using compatible versions.`)}var f=()=>window.__TSS_START_OPTIONS__;function p(e,t=String){let n=new URLSearchParams;for(let r in e){let i=e[r];i!==void 0&&n.set(r,t(i))}return n.toString()}function m(e){return e?e===`false`?!1:e===`true`?!0:e*0==0&&+e+``===e?+e:e:``}function ee(e){let t=new URLSearchParams(e),n=Object.create(null);for(let[e,r]of t.entries()){let t=n[e];t==null?n[e]=m(r):Array.isArray(t)?t.push(m(r)):n[e]=[t,m(r)]}return n}var te=(e=>(e[e.AggregateError=1]=`AggregateError`,e[e.ArrowFunction=2]=`ArrowFunction`,e[e.ErrorPrototypeStack=4]=`ErrorPrototypeStack`,e[e.ObjectAssign=8]=`ObjectAssign`,e[e.BigIntTypedArray=16]=`BigIntTypedArray`,e[e.RegExp=32]=`RegExp`,e))(te||{}),h=Symbol.asyncIterator,ne=Symbol.hasInstance,g=Symbol.isConcatSpreadable,_=Symbol.iterator,re=Symbol.match,ie=Symbol.matchAll,ae=Symbol.replace,oe=Symbol.search,se=Symbol.species,ce=Symbol.split,le=Symbol.toPrimitive,v=Symbol.toStringTag,ue=Symbol.unscopables,de={[h]:0,[ne]:1,[g]:2,[_]:3,[re]:4,[ie]:5,[ae]:6,[oe]:7,[se]:8,[ce]:9,[le]:10,[v]:11,[ue]:12},fe={0:h,1:ne,2:g,3:_,4:re,5:ie,6:ae,7:oe,8:se,9:ce,10:le,11:v,12:ue},y=void 0,pe={2:!0,3:!1,1:y,0:null,4:-0,5:1/0,6:-1/0,7:NaN},me={0:`Error`,1:`EvalError`,2:`RangeError`,3:`ReferenceError`,4:`SyntaxError`,5:`TypeError`,6:`URIError`},he={0:Error,1:EvalError,2:RangeError,3:ReferenceError,4:SyntaxError,5:TypeError,6:URIError};function b(e,t,n,r,i,a,o,s,c,l,u,d){return{t:e,i:t,s:n,c:r,m:i,p:a,e:o,a:s,f:c,b:l,o:u,l:d}}function x(e){return b(2,y,e,y,y,y,y,y,y,y,y,y)}var ge=x(2),_e=x(3),ve=x(1),ye=x(0),be=x(4),xe=x(5),Se=x(6),Ce=x(7);function we(e){switch(e){case`"`:return`\\"`;case`\\`:return`\\\\`;case`
2
+ `:return`\\n`;case`\r`:return`\\r`;case`\b`:return`\\b`;case` `:return`\\t`;case`\f`:return`\\f`;case`<`:return`\\x3C`;case`\u2028`:return`\\u2028`;case`\u2029`:return`\\u2029`;default:return y}}function S(e){let t=``,n=0,r;for(let i=0,a=e.length;i<a;i++)r=we(e[i]),r&&(t+=e.slice(n,i)+r,n=i+1);return n===0?t=e:t+=e.slice(n),t}function Te(e){switch(e){case`\\\\`:return`\\`;case`\\"`:return`"`;case`\\n`:return`
3
+ `;case`\\r`:return`\r`;case`\\b`:return`\b`;case`\\t`:return` `;case`\\f`:return`\f`;case`\\x3C`:return`<`;case`\\u2028`:return`\u2028`;case`\\u2029`:return`\u2029`;default:return e}}function C(e){return e.replace(/(\\\\|\\"|\\n|\\r|\\b|\\t|\\f|\\u2028|\\u2029|\\x3C)/g,Te)}var w=`__SEROVAL_REFS__`,Ee=new Map,E=new Map;function De(e){return Ee.has(e)}function Oe(e){return E.has(e)}function ke(e){if(De(e))return Ee.get(e);throw new pt(e)}function Ae(e){if(Oe(e))return E.get(e);throw new mt(e)}typeof globalThis<`u`?Object.defineProperty(globalThis,w,{value:E,configurable:!0,writable:!1,enumerable:!1}):typeof window<`u`?Object.defineProperty(window,w,{value:E,configurable:!0,writable:!1,enumerable:!1}):typeof self<`u`?Object.defineProperty(self,w,{value:E,configurable:!0,writable:!1,enumerable:!1}):typeof global<`u`&&Object.defineProperty(global,w,{value:E,configurable:!0,writable:!1,enumerable:!1});function D(e){return e instanceof EvalError?1:e instanceof RangeError?2:e instanceof ReferenceError?3:e instanceof SyntaxError?4:e instanceof TypeError?5:e instanceof URIError?6:0}function je(e){let t=me[D(e)];return e.name===t?e.constructor.name===t?{}:{name:e.constructor.name}:{name:e.name}}function Me(e,t){let n=je(e),r=Object.getOwnPropertyNames(e);for(let i=0,a=r.length,o;i<a;i++)o=r[i],o!==`name`&&o!==`message`&&(o===`stack`?t&4&&(n||={},n[o]=e[o]):(n||={},n[o]=e[o]));return n}function Ne(e){return Object.isFrozen(e)?3:Object.isSealed(e)?2:+!Object.isExtensible(e)}function Pe(e){switch(e){case 1/0:return xe;case-1/0:return Se}return e===e?Object.is(e,-0)?be:b(0,y,e,y,y,y,y,y,y,y,y,y):Ce}function Fe(e){return b(1,y,S(e),y,y,y,y,y,y,y,y,y)}function Ie(e){return b(3,y,``+e,y,y,y,y,y,y,y,y,y)}function Le(e){return b(4,e,y,y,y,y,y,y,y,y,y,y)}function Re(e,t){let n=t.valueOf();return b(5,e,n===n?t.toISOString():``,y,y,y,y,y,y,y,y,y)}function ze(e,t){return b(6,e,y,S(t.source),t.flags,y,y,y,y,y,y,y)}function Be(e,t){return b(17,e,de[t],y,y,y,y,y,y,y,y,y)}function Ve(e,t){return b(18,e,S(ke(t)),y,y,y,y,y,y,y,y,y)}function He(e,t,n){return b(25,e,n,S(t),y,y,y,y,y,y,y,y)}function Ue(e,t,n){return b(9,e,y,y,y,y,y,n,y,y,Ne(t),y)}function We(e,t){return b(21,e,y,y,y,y,y,y,t,y,y,y)}function Ge(e,t,n){return b(15,e,y,t.constructor.name,y,y,y,y,n,t.byteOffset,y,t.length)}function Ke(e,t,n){return b(16,e,y,t.constructor.name,y,y,y,y,n,t.byteOffset,y,t.byteLength)}function qe(e,t,n){return b(20,e,y,y,y,y,y,y,n,t.byteOffset,y,t.byteLength)}function Je(e,t,n){return b(13,e,D(t),y,S(t.message),n,y,y,y,y,y,y)}function Ye(e,t,n){return b(14,e,D(t),y,S(t.message),n,y,y,y,y,y,y)}function Xe(e,t){return b(7,e,y,y,y,y,y,t,y,y,y,y)}function Ze(e,t){return b(28,y,y,y,y,y,y,[e,t],y,y,y,y)}function Qe(e,t){return b(30,y,y,y,y,y,y,[e,t],y,y,y,y)}function $e(e,t,n){return b(31,e,y,y,y,y,y,n,t,y,y,y)}function et(e,t){return b(32,e,y,y,y,y,y,y,t,y,y,y)}function tt(e,t){return b(33,e,y,y,y,y,y,y,t,y,y,y)}function nt(e,t){return b(34,e,y,y,y,y,y,y,t,y,y,y)}function rt(e,t,n,r){return b(35,e,n,y,y,y,y,t,y,y,y,r)}var{toString:it}=Object.prototype,at={parsing:1,serialization:2,deserialization:3};function ot(e){return`Seroval Error (step: ${at[e]})`}var st=(e,t)=>ot(e),ct=class extends Error{constructor(e,t){super(st(e,t)),this.cause=t}},lt=class extends ct{constructor(e){super(`parsing`,e)}},ut=class extends ct{constructor(e){super(`deserialization`,e)}};function O(e){return`Seroval Error (specific: ${e})`}var k=class extends Error{constructor(e){super(O(1)),this.value=e}},dt=class extends Error{constructor(e){super(O(2))}},ft=class extends Error{constructor(e){super(O(3))}},A=class extends Error{constructor(e){super(O(4))}},pt=class extends Error{constructor(e){super(O(5)),this.value=e}},mt=class extends Error{constructor(e){super(O(6))}},ht=class extends Error{constructor(e){super(O(7))}},j=class extends Error{constructor(e){super(O(8))}},gt=class extends Error{constructor(e){super(O(9))}},_t=class{constructor(e,t){this.value=e,this.replacement=t}},M=()=>{let e={p:0,s:0,f:0};return e.p=new Promise((t,n)=>{e.s=t,e.f=n}),e};M.toString(),((e,t)=>{e.s(t),e.p.s=1,e.p.v=t}).toString(),((e,t)=>{e.f(t),e.p.s=2,e.p.v=t}).toString();var vt=()=>{let e=[],t=[],n=!0,r=!1,i=0,a=(e,n,r)=>{for(r=0;r<i;r++)t[r]&&t[r][n](e)},o=(t,i,a,o)=>{for(i=0,a=e.length;i<a;i++)o=e[i],!n&&i===a-1?t[r?`return`:`throw`](o):t.next(o)},s=(e,r)=>(n&&(r=i++,t[r]=e),o(e),()=>{n&&(t[r]=t[i],t[i--]=void 0)});return{__SEROVAL_STREAM__:!0,on:e=>s(e),next:t=>{n&&(e.push(t),a(t,`next`))},throw:i=>{n&&(e.push(i),a(i,`throw`),n=!1,r=!1,t.length=0)},return:i=>{n&&(e.push(i),a(i,`return`),n=!1,r=!0,t.length=0)}}};vt.toString();var yt=e=>t=>()=>{let n=0,r={[e]:()=>r,next:()=>{if(n>t.d)return{done:!0,value:void 0};let e=n++,r=t.v[e];if(e===t.t)throw r;return{done:e===t.d,value:r}}};return r};yt.toString();var bt=(e,t)=>n=>()=>{let r=0,i=-1,a=!1,o=[],s=[],c=(e=0,t=s.length)=>{for(;e<t;e++)s[e].s({done:!0,value:void 0})};n.on({next:e=>{let t=s.shift();t&&t.s({done:!1,value:e}),o.push(e)},throw:e=>{let t=s.shift();t&&t.f(e),c(),i=o.length,a=!0,o.push(e)},return:e=>{let t=s.shift();t&&t.s({done:!0,value:e}),c(),i=o.length,o.push(e)}});let l={[e]:()=>l,next:()=>{if(i===-1){let e=r++;if(e>=o.length){let e=t();return s.push(e),e.p}return{done:!1,value:o[e]}}if(r>i)return{done:!0,value:void 0};let e=r++,n=o[e];if(e!==i)return{done:!1,value:n};if(a)throw n;return{done:!0,value:n}}};return l};bt.toString();var xt=e=>{let t=atob(e),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.charCodeAt(e);return r.buffer};xt.toString();function St(e){return`__SEROVAL_SEQUENCE__`in e}function Ct(e,t,n){return{__SEROVAL_SEQUENCE__:!0,v:e,t,d:n}}function wt(e){let t=[],n=-1,r=-1,i=e[_]();for(;;)try{let e=i.next();if(t.push(e.value),e.done){r=t.length-1;break}}catch(e){n=t.length,t.push(e)}return Ct(t,n,r)}var Tt=yt(_);function Et(e){return Tt(e)}var Dt={},Ot={},kt={0:{},1:{},2:{},3:{},4:{},5:{}};function At(e){return`__SEROVAL_STREAM__`in e}function N(){return vt()}function jt(e){let t=N(),n=e[h]();async function r(){try{let e=await n.next();e.done?t.return(e.value):(t.next(e.value),await r())}catch(e){t.throw(e)}}return r().catch(()=>{}),t}var Mt=bt(h,M);function Nt(e){return Mt(e)}async function Pt(e){try{return[1,await e]}catch(e){return[0,e]}}function Ft(e,t){return{plugins:t.plugins,mode:e,marked:new Set,features:63^(t.disabledFeatures||0),refs:t.refs||new Map,depthLimit:t.depthLimit||1e3}}function P(e,t){e.marked.add(t)}function It(e,t){let n=e.refs.size;return e.refs.set(t,n),n}function F(e,t){let n=e.refs.get(t);return n==null?{type:0,value:It(e,t)}:(P(e,n),{type:1,value:Le(n)})}function I(e,t){let n=F(e,t);return n.type===1?n:De(t)?{type:2,value:Ve(n.value,t)}:n}function L(e,t){let n=I(e,t);if(n.type!==0)return n.value;if(t in de)return Be(n.value,t);throw new k(t)}function R(e,t){let n=F(e,kt[t]);return n.type===1?n.value:b(26,n.value,t,y,y,y,y,y,y,y,y,y)}function Lt(e){let t=F(e,Dt);return t.type===1?t.value:b(27,t.value,y,y,y,y,y,y,L(e,_),y,y,y)}function Rt(e){let t=F(e,Ot);return t.type===1?t.value:b(29,t.value,y,y,y,y,y,[R(e,1),L(e,h)],y,y,y,y)}function zt(e,t,n,r){return b(n?11:10,e,y,y,y,r,y,y,y,y,Ne(t),y)}function Bt(e,t,n,r){return b(8,t,y,y,y,y,{k:n,v:r},y,R(e,0),y,y,y)}function Vt(e,t,n){let r=new Uint8Array(n),i=``;for(let e=0,t=r.length;e<t;e++)i+=String.fromCharCode(r[e]);return b(19,t,S(btoa(i)),y,y,y,y,y,R(e,5),y,y,y)}function Ht(e,t){return{base:Ft(e,t),child:void 0}}var Ut=class{constructor(e,t){this._p=e,this.depth=t}parse(e){return V(this._p,this.depth,e)}};async function Wt(e,t,n){let r=[];for(let i=0,a=n.length;i<a;i++)i in n?r[i]=await V(e,t,n[i]):r[i]=0;return r}async function Gt(e,t,n,r){return Ue(n,r,await Wt(e,t,r))}async function z(e,t,n){let r=Object.entries(n),i=[],a=[];for(let n=0,o=r.length;n<o;n++)i.push(S(r[n][0])),a.push(await V(e,t,r[n][1]));return _ in n&&(i.push(L(e.base,_)),a.push(Ze(Lt(e.base),await V(e,t,wt(n))))),h in n&&(i.push(L(e.base,h)),a.push(Qe(Rt(e.base),await V(e,t,jt(n))))),v in n&&(i.push(L(e.base,v)),a.push(Fe(n[v]))),g in n&&(i.push(L(e.base,g)),a.push(n[g]?ge:_e)),{k:i,v:a}}async function B(e,t,n,r,i){return zt(n,r,i,await z(e,t,r))}async function Kt(e,t,n,r){return We(n,await V(e,t,r.valueOf()))}async function qt(e,t,n,r){return Ge(n,r,await V(e,t,r.buffer))}async function Jt(e,t,n,r){return Ke(n,r,await V(e,t,r.buffer))}async function Yt(e,t,n,r){return qe(n,r,await V(e,t,r.buffer))}async function Xt(e,t,n,r){let i=Me(r,e.base.features);return Je(n,r,i?await z(e,t,i):y)}async function Zt(e,t,n,r){let i=Me(r,e.base.features);return Ye(n,r,i?await z(e,t,i):y)}async function Qt(e,t,n,r){let i=[],a=[];for(let[n,o]of r.entries())i.push(await V(e,t,n)),a.push(await V(e,t,o));return Bt(e.base,n,i,a)}async function $t(e,t,n,r){let i=[];for(let n of r.keys())i.push(await V(e,t,n));return Xe(n,i)}async function en(e,t,n,r){let i=e.base.plugins;if(i)for(let a=0,o=i.length;a<o;a++){let o=i[a];if(o.parse.async&&o.test(r))return He(n,o.tag,await o.parse.async(r,new Ut(e,t),{id:n}))}return y}async function tn(e,t,n,r){let[i,a]=await Pt(r);return b(12,n,i,y,y,y,y,y,await V(e,t,a),y,y,y)}function nn(e,t,n,r,i){let a=[],o=n.on({next:n=>{P(this.base,t),V(this,e,n).then(e=>{a.push(et(t,e))},e=>{i(e),o()})},throw:n=>{P(this.base,t),V(this,e,n).then(e=>{a.push(tt(t,e)),r(a),o()},e=>{i(e),o()})},return:n=>{P(this.base,t),V(this,e,n).then(e=>{a.push(nt(t,e)),r(a),o()},e=>{i(e),o()})}})}async function rn(e,t,n,r){return $e(n,R(e.base,4),await new Promise(nn.bind(e,t,n,r)))}async function an(e,t,n,r){let i=[];for(let n=0,a=r.v.length;n<a;n++)i[n]=await V(e,t,r.v[n]);return rt(n,i,r.t,r.d)}async function on(e,t,n,r){if(Array.isArray(r))return Gt(e,t,n,r);if(At(r))return rn(e,t,n,r);if(St(r))return an(e,t,n,r);let i=r.constructor;if(i===_t)return V(e,t,r.replacement);let a=await en(e,t,n,r);if(a)return a;switch(i){case Object:return B(e,t,n,r,!1);case y:return B(e,t,n,r,!0);case Date:return Re(n,r);case Error:case EvalError:case RangeError:case ReferenceError:case SyntaxError:case TypeError:case URIError:return Xt(e,t,n,r);case Number:case Boolean:case String:case BigInt:return Kt(e,t,n,r);case ArrayBuffer:return Vt(e.base,n,r);case Int8Array:case Int16Array:case Int32Array:case Uint8Array:case Uint16Array:case Uint32Array:case Uint8ClampedArray:case Float32Array:case Float64Array:return qt(e,t,n,r);case DataView:return Yt(e,t,n,r);case Map:return Qt(e,t,n,r);case Set:return $t(e,t,n,r);default:break}if(i===Promise||r instanceof Promise)return tn(e,t,n,r);let o=e.base.features;if(o&32&&i===RegExp)return ze(n,r);if(o&16)switch(i){case BigInt64Array:case BigUint64Array:return Jt(e,t,n,r);default:break}if(o&1&&typeof AggregateError<`u`&&(i===AggregateError||r instanceof AggregateError))return Zt(e,t,n,r);if(r instanceof Error)return Xt(e,t,n,r);if(_ in r||h in r)return B(e,t,n,r,!!i);throw new k(r)}async function sn(e,t,n){let r=I(e.base,n);if(r.type!==0)return r.value;let i=await en(e,t,r.value,n);if(i)return i;throw new k(n)}async function V(e,t,n){switch(typeof n){case`boolean`:return n?ge:_e;case`undefined`:return ve;case`string`:return Fe(n);case`number`:return Pe(n);case`bigint`:return Ie(n);case`object`:if(n){let r=I(e.base,n);return r.type===0?await on(e,t+1,r.value,n):r.value}return ye;case`symbol`:return L(e.base,n);case`function`:return sn(e,t,n);default:throw new k(n)}}async function cn(e,t){try{return await V(e,0,t)}catch(e){throw e instanceof lt?e:new lt(e)}}var ln=(e=>(e[e.Vanilla=1]=`Vanilla`,e[e.Cross=2]=`Cross`,e))(ln||{});function H(e){return e}function un(e,t){for(let n=0,r=t.length;n<r;n++){let r=t[n];e.has(r)||(e.add(r),r.extends&&un(e,r.extends))}}function dn(e){if(e){let t=new Set;return un(t,e),[...t]}}function fn(e){switch(e){case`Int8Array`:return Int8Array;case`Int16Array`:return Int16Array;case`Int32Array`:return Int32Array;case`Uint8Array`:return Uint8Array;case`Uint16Array`:return Uint16Array;case`Uint32Array`:return Uint32Array;case`Uint8ClampedArray`:return Uint8ClampedArray;case`Float32Array`:return Float32Array;case`Float64Array`:return Float64Array;case`BigInt64Array`:return BigInt64Array;case`BigUint64Array`:return BigUint64Array;default:throw new ht(e)}}var pn=1e6,mn=1e4,hn=2e4;function gn(e,t){switch(t){case 3:return Object.freeze(e);case 1:return Object.preventExtensions(e);case 2:return Object.seal(e);default:return e}}var _n=1e3;function vn(e,t){let n=t.refs||new Map;return`types`in n||Object.assign(n,{types:new Map}),{mode:e,plugins:t.plugins,refs:n,features:t.features??63^(t.disabledFeatures||0),depthLimit:t.depthLimit||_n}}function yn(e){return{mode:2,base:vn(2,e),child:y}}var bn=class{constructor(e,t){this._p=e,this.depth=t}deserialize(e){return K(this._p,this.depth,e)}};function xn(e,t){if(t<0||!Number.isFinite(t)||!Number.isInteger(t))throw new j({t:4,i:t});if(e.refs.has(t))throw Error(`Conflicted ref id: `+t)}function Sn(e,t,n){return xn(e.base,t),e.state.marked.has(t)&&e.base.refs.set(t,n),n}function Cn(e,t,n){return xn(e.base,t),e.base.refs.set(t,n),n}function U(e,t,n){return e.mode===1?Sn(e,t,n):Cn(e,t,n)}function W(e,t,n){if(Object.hasOwn(t,n))return t[n];throw new j(e)}function wn(e,t){return U(e,t.i,Ae(C(t.s)))}function Tn(e,t,n){let r=n.a,i=r.length,a=U(e,n.i,Array(i));for(let n=0,o;n<i;n++)o=r[n],o&&(a[n]=K(e,t,o));return gn(a,n.o),a}function En(e){switch(e){case`constructor`:case`__proto__`:case`prototype`:case`__defineGetter__`:case`__defineSetter__`:case`__lookupGetter__`:case`__lookupSetter__`:return!1;default:return!0}}function Dn(e){switch(e){case h:case g:case v:case _:return!0;default:return!1}}function On(e,t,n){En(t)?e[t]=n:Object.defineProperty(e,t,{value:n,configurable:!0,enumerable:!0,writable:!0})}function kn(e,t,n,r,i){if(typeof r==`string`)On(n,C(r),K(e,t,i));else{let a=K(e,t,r);switch(typeof a){case`string`:On(n,a,K(e,t,i));break;case`symbol`:Dn(a)&&(n[a]=K(e,t,i));break;default:throw new j(r)}}}function An(e,t,n){e.base.refs.types.set(t,n)}function G(e,t,n,r){if(e.base.refs.types.get(n)!==r)throw new j(t)}function jn(e,t,n,r){let i=n.k;if(i.length>0)for(let a=0,o=n.v,s=i.length;a<s;a++)kn(e,t,r,i[a],o[a]);return r}function Mn(e,t,n){let r=U(e,n.i,n.t===10?{}:Object.create(null));return jn(e,t,n.p,r),gn(r,n.o),r}function Nn(e,t){return U(e,t.i,new Date(t.s))}function Pn(e,t){if(e.base.features&32){let n=C(t.c);if(n.length>hn)throw new j(t);return U(e,t.i,new RegExp(n,t.m))}throw new dt(t)}function Fn(e,t,n){let r=U(e,n.i,new Set);for(let i=0,a=n.a,o=a.length;i<o;i++)r.add(K(e,t,a[i]));return r}function In(e,t,n){let r=U(e,n.i,new Map);for(let i=0,a=n.e.k,o=n.e.v,s=a.length;i<s;i++)r.set(K(e,t,a[i]),K(e,t,o[i]));return r}function Ln(e,t){if(t.s.length>pn)throw new j(t);return U(e,t.i,xt(C(t.s)))}function Rn(e,t,n){let r=fn(n.c),i=K(e,t,n.f),a=n.b??0;if(a<0||a>i.byteLength)throw new j(n);return U(e,n.i,new r(i,a,n.l))}function zn(e,t,n){let r=K(e,t,n.f),i=n.b??0;if(i<0||i>r.byteLength)throw new j(n);return U(e,n.i,new DataView(r,i,n.l))}function Bn(e,t,n,r){if(n.p){let i=jn(e,t,n.p,{});Object.defineProperties(r,Object.getOwnPropertyDescriptors(i))}return r}function Vn(e,t,n){return Bn(e,t,n,U(e,n.i,AggregateError([],C(n.m))))}function Hn(e,t,n){let r=W(n,he,n.s);return Bn(e,t,n,U(e,n.i,new r(C(n.m))))}function Un(e,t,n){let r=M(),i=U(e,n.i,r.p),a=K(e,t,n.f);return n.s?r.s(a):r.f(a),i}function Wn(e,t,n){return U(e,n.i,Object(K(e,t,n.f)))}function Gn(e,t,n){let r=e.base.plugins;if(r){let i=C(n.c);for(let a=0,o=r.length;a<o;a++){let o=r[a];if(o.tag===i)return U(e,n.i,o.deserialize(n.s,new bn(e,t),{id:n.i}))}}throw new ft(n.c)}function Kn(e,t){let n=U(e,t.i,U(e,t.s,M()).p);return An(e,t.s,22),n}function qn(e,t,n){let r=e.base.refs.get(n.i);if(r)return G(e,n,n.i,22),r.s(K(e,t,n.a[1])),y;throw new A(`Promise`)}function Jn(e,t,n){let r=e.base.refs.get(n.i);if(r)return G(e,n,n.i,22),r.f(K(e,t,n.a[1])),y;throw new A(`Promise`)}function Yn(e,t,n){return K(e,t,n.a[0]),Et(K(e,t,n.a[1]))}function Xn(e,t,n){return K(e,t,n.a[0]),Nt(K(e,t,n.a[1]))}function Zn(e,t,n){let r=U(e,n.i,N());An(e,n.i,31);let i=n.a,a=i.length;if(a)for(let n=0;n<a;n++)K(e,t,i[n]);return r}function Qn(e,t,n){let r=e.base.refs.get(n.i);if(r)return G(e,n,n.i,31),r.next(K(e,t,n.f)),y;throw new A(`Stream`)}function $n(e,t,n){let r=e.base.refs.get(n.i);if(r)return G(e,n,n.i,31),r.throw(K(e,t,n.f)),y;throw new A(`Stream`)}function er(e,t,n){let r=e.base.refs.get(n.i);if(r)return G(e,n,n.i,31),r.return(K(e,t,n.f)),y;throw new A(`Stream`)}function tr(e,t,n){return K(e,t,n.f),y}function nr(e,t,n){return K(e,t,n.a[1]),y}function rr(e,t,n){let r=U(e,n.i,Ct([],n.s,n.l));for(let i=0,a=n.a.length;i<a;i++)r.v[i]=K(e,t,n.a[i]);return r}function K(e,t,n){if(t>e.base.depthLimit)throw new gt(e.base.depthLimit);switch(t+=1,n.t){case 2:return W(n,pe,n.s);case 0:return Number(n.s);case 1:return C(String(n.s));case 3:if(String(n.s).length>mn)throw new j(n);return BigInt(n.s);case 4:return e.base.refs.get(n.i);case 18:return wn(e,n);case 9:return Tn(e,t,n);case 10:case 11:return Mn(e,t,n);case 5:return Nn(e,n);case 6:return Pn(e,n);case 7:return Fn(e,t,n);case 8:return In(e,t,n);case 19:return Ln(e,n);case 16:case 15:return Rn(e,t,n);case 20:return zn(e,t,n);case 14:return Vn(e,t,n);case 13:return Hn(e,t,n);case 12:return Un(e,t,n);case 17:return W(n,fe,n.s);case 21:return Wn(e,t,n);case 25:return Gn(e,t,n);case 22:return Kn(e,n);case 23:return qn(e,t,n);case 24:return Jn(e,t,n);case 28:return Yn(e,t,n);case 30:return Xn(e,t,n);case 31:return Zn(e,t,n);case 32:return Qn(e,t,n);case 33:return $n(e,t,n);case 34:return er(e,t,n);case 27:return tr(e,t,n);case 29:return nr(e,t,n);case 35:return rr(e,t,n);default:throw new dt(n)}}function ir(e,t){try{return K(e,0,t)}catch(e){throw new ut(e)}}var ar=(()=>T).toString();/=>/.test(ar);function or(e,t){return ir(yn({plugins:dn(t.plugins),refs:t.refs,features:t.features,disabledFeatures:t.disabledFeatures,depthLimit:t.depthLimit}),e)}async function sr(e,t={}){let n=Ht(1,{plugins:dn(t.plugins),disabledFeatures:t.disabledFeatures});return{t:await cn(n,e),f:n.base.features,m:Array.from(n.base.marked)}}function cr(e){return e}function lr(e){return H({tag:`$TSR/t/`+e.key,test:e.test,parse:{sync(t,n,r){return{v:n.parse(e.toSerializable(t))}},async async(t,n,r){return{v:await n.parse(e.toSerializable(t))}},stream(t,n,r){return{v:n.parse(e.toSerializable(t))}}},serialize:void 0,deserialize(t,n,r){return e.fromSerializable(n.deserialize(t.v))}})}var ur=class{constructor(e,t){this.stream=e,this.hint=t?.hint??`binary`}},q=globalThis.Buffer,dr=!!q&&typeof q.from==`function`;function fr(e){if(e.length===0)return``;if(dr)return q.from(e).toString(`base64`);let t=32768,n=[];for(let r=0;r<e.length;r+=t){let i=e.subarray(r,r+t);n.push(String.fromCharCode.apply(null,i))}return btoa(n.join(``))}function pr(e){if(e.length===0)return new Uint8Array;if(dr){let t=q.from(e,`base64`);return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}var J=Object.create(null),Y=Object.create(null),mr=e=>new ReadableStream({start(t){e.on({next(e){try{t.enqueue(pr(e))}catch{}},throw(e){t.error(e)},return(){try{t.close()}catch{}}})}}),hr=new TextEncoder,gr=e=>new ReadableStream({start(t){e.on({next(e){try{typeof e==`string`?t.enqueue(hr.encode(e)):t.enqueue(pr(e.$b64))}catch{}},throw(e){t.error(e)},return(){try{t.close()}catch{}}})}}),_r=`(s=>new ReadableStream({start(c){s.on({next(b){try{const d=atob(b),a=new Uint8Array(d.length);for(let i=0;i<d.length;i++)a[i]=d.charCodeAt(i);c.enqueue(a)}catch(_){}},throw(e){c.error(e)},return(){try{c.close()}catch(_){}}})}}))`,vr=`(s=>{const e=new TextEncoder();return new ReadableStream({start(c){s.on({next(v){try{if(typeof v==='string'){c.enqueue(e.encode(v))}else{const d=atob(v.$b64),a=new Uint8Array(d.length);for(let i=0;i<d.length;i++)a[i]=d.charCodeAt(i);c.enqueue(a)}}catch(_){}},throw(x){c.error(x)},return(){try{c.close()}catch(_){}}})}})})`;function yr(e){let t=N(),n=e.getReader();return(async()=>{try{for(;;){let{done:e,value:r}=await n.read();if(e){t.return(void 0);break}t.next(fr(r))}}catch(e){t.throw(e)}finally{n.releaseLock()}})(),t}function br(e){let t=N(),n=e.getReader(),r=new TextDecoder(`utf-8`,{fatal:!0});return(async()=>{try{for(;;){let{done:e,value:i}=await n.read();if(e){try{let e=r.decode();e.length>0&&t.next(e)}catch{}t.return(void 0);break}try{let e=r.decode(i,{stream:!0});e.length>0&&t.next(e)}catch{t.next({$b64:fr(i)})}}}catch(e){t.throw(e)}finally{n.releaseLock()}})(),t}var xr=H({tag:`tss/RawStream`,extends:[H({tag:`tss/RawStreamFactory`,test(e){return e===J},parse:{sync(e,t,n){return{}},async async(e,t,n){return{}},stream(e,t,n){return{}}},serialize(e,t,n){return _r},deserialize(e,t,n){return J}}),H({tag:`tss/RawStreamFactoryText`,test(e){return e===Y},parse:{sync(e,t,n){return{}},async async(e,t,n){return{}},stream(e,t,n){return{}}},serialize(e,t,n){return vr},deserialize(e,t,n){return Y}})],test(e){return e instanceof ur},parse:{sync(e,t,n){let r=e.hint===`text`?Y:J;return{hint:t.parse(e.hint),factory:t.parse(r),stream:t.parse(N())}},async async(e,t,n){let r=e.hint===`text`?Y:J,i=e.hint===`text`?br(e.stream):yr(e.stream);return{hint:await t.parse(e.hint),factory:await t.parse(r),stream:await t.parse(i)}},stream(e,t,n){let r=e.hint===`text`?Y:J,i=e.hint===`text`?br(e.stream):yr(e.stream);return{hint:t.parse(e.hint),factory:t.parse(r),stream:t.parse(i)}}},serialize(e,t,n){return`(`+t.serialize(e.factory)+`)(`+t.serialize(e.stream)+`)`},deserialize(e,t,n){let r=t.deserialize(e.stream);return t.deserialize(e.hint)===`text`?gr(r):mr(r)}});function Sr(e){return H({tag:`tss/RawStream`,test:()=>!1,parse:{},serialize(){throw Error(`RawStreamDeserializePlugin.serialize should not be called. Client only deserializes.`)},deserialize(t,n,r){return e(typeof n?.deserialize==`function`?n.deserialize(t.streamId):t.streamId)}})}var Cr=H({tag:`$TSR/Error`,test(e){return e instanceof Error},parse:{sync(e,t){return{message:t.parse(e.message)}},async async(e,t){return{message:await t.parse(e.message)}},stream(e,t){return{message:t.parse(e.message)}}},serialize(e,t){return`new Error(`+t.serialize(e.message)+`)`},deserialize(e,t){return Error(t.deserialize(e.message))}}),X={},wr=e=>new ReadableStream({start:t=>{e.on({next:e=>{try{t.enqueue(e)}catch{}},throw:e=>{t.error(e)},return:()=>{try{t.close()}catch{}}})}}),Tr=H({tag:`seroval-plugins/web/ReadableStreamFactory`,test(e){return e===X},parse:{sync(){return X},async async(){return await Promise.resolve(X)},stream(){return X}},serialize(){return wr.toString()},deserialize(){return X}});function Er(e){let t=N(),n=e.getReader();async function r(){try{let e=await n.read();e.done?t.return(e.value):(t.next(e.value),await r())}catch(e){t.throw(e)}}return r().catch(()=>{}),t}var Dr=[Cr,xr,H({tag:`seroval/plugins/web/ReadableStream`,extends:[Tr],test(e){return typeof ReadableStream>`u`?!1:e instanceof ReadableStream},parse:{sync(e,t){return{factory:t.parse(X),stream:t.parse(N())}},async async(e,t){return{factory:await t.parse(X),stream:await t.parse(Er(e))}},stream(e,t){return{factory:t.parse(X),stream:t.parse(Er(e))}}},serialize(e,t){return`(`+t.serialize(e.factory)+`)(`+t.serialize(e.stream)+`)`},deserialize(e,t){return wr(t.deserialize(e.stream))}})];function Or(){return[...(f()?.serializationAdapters)?.map(lr)??[],...Dr]}var kr=new TextDecoder,Ar=new Uint8Array,jr=16*1024*1024,Mr=32*1024*1024,Nr=1024,Pr=1e5;function Fr(e){let t=new Map,n=new Map,r=new Set,i=!1,a=null,o=0,s,l=new ReadableStream({start(e){s=e},cancel(){i=!0;try{a?.cancel()}catch{}t.forEach(e=>{try{e.error(Error(`Framed response cancelled`))}catch{}}),t.clear(),n.clear(),r.clear()}});function u(e){let i=n.get(e);if(i)return i;if(r.has(e))return new ReadableStream({start(e){e.close()}});if(n.size>=Nr)throw Error(`Too many raw streams in framed response (max ${Nr})`);let a=new ReadableStream({start(n){t.set(e,n)},cancel(){r.add(e),t.delete(e),n.delete(e)}});return n.set(e,a),a}function d(e){return u(e),t.get(e)}return(async()=>{let n=e.getReader();a=n;let l=[],u=0;function f(){if(u<9)return null;let e=l[0];if(e.length>=9)return{type:e[0],streamId:(e[1]<<24|e[2]<<16|e[3]<<8|e[4])>>>0,length:(e[5]<<24|e[6]<<16|e[7]<<8|e[8])>>>0};let t=new Uint8Array(9),n=0,r=9;for(let e=0;e<l.length&&r>0;e++){let i=l[e],a=Math.min(i.length,r);t.set(i.subarray(0,a),n),n+=a,r-=a}return{type:t[0],streamId:(t[1]<<24|t[2]<<16|t[3]<<8|t[4])>>>0,length:(t[5]<<24|t[6]<<16|t[7]<<8|t[8])>>>0}}function p(e){if(e===0)return Ar;let t=l[0];if(t&&t.length>=e){let n=t.subarray(0,e);return t.length===e?l.shift():l[0]=t.subarray(e),u-=e,n}let n=new Uint8Array(e),r=0,i=e;for(;i>0&&l.length>0;){let e=l[0];if(!e)break;let t=Math.min(e.length,i);n.set(e.subarray(0,t),r),r+=t,i-=t,t===e.length?l.shift():l[0]=e.subarray(t)}return u-=e,n}try{for(;;){let{done:e,value:a}=await n.read();if(i||e)break;if(a){if(u+a.length>Mr)throw Error(`Framed response buffer exceeded ${Mr} bytes`);for(l.push(a),u+=a.length;;){let e=f();if(!e)break;let{type:n,streamId:i,length:a}=e;if(n!==c.JSON&&n!==c.CHUNK&&n!==c.END&&n!==c.ERROR)throw Error(`Unknown frame type: ${n}`);if(n===c.JSON){if(i!==0)throw Error(`Invalid JSON frame streamId (expected 0)`)}else if(i===0)throw Error(`Invalid raw frame streamId (expected non-zero)`);if(a>jr)throw Error(`Frame payload too large: ${a} bytes (max ${jr})`);let l=9+a;if(u<l)break;if(++o>Pr)throw Error(`Too many frames in framed response (max ${Pr})`);p(9);let m=p(a);switch(n){case c.JSON:try{s.enqueue(kr.decode(m))}catch{}break;case c.CHUNK:{let e=d(i);e&&e.enqueue(m);break}case c.END:{let e=d(i);if(r.add(i),e){try{e.close()}catch{}t.delete(i)}break}case c.ERROR:{let e=d(i);if(r.add(i),e){let n=kr.decode(m);e.error(Error(n)),t.delete(i)}break}}}}}if(u!==0)throw Error(`Incomplete frame at end of framed response`);try{s.close()}catch{}t.forEach(e=>{try{e.close()}catch{}}),t.clear()}catch(e){try{s.error(e)}catch{}t.forEach(t=>{try{t.error(e)}catch{}}),t.clear()}finally{try{n.releaseLock()}catch{}a=null}})(),{getOrCreateStream:u,jsonChunks:l}}var Z=null;async function Q(e){e.length>0&&await Promise.allSettled(e)}var Ir=Object.prototype.hasOwnProperty;function Lr(e){for(let t in e)if(Ir.call(e,t))return!0;return!1}async function Rr(e,t,n){Z||=Or();let r=t[0],i=r.fetch??n,a=r.data instanceof FormData?`formData`:`payload`,o=r.headers?new Headers(r.headers):new Headers;if(o.set(`x-tsr-serverFn`,`true`),a===`payload`&&o.set(`accept`,`${s}, application/x-ndjson, application/json`),r.method===`GET`){if(a===`formData`)throw Error(`FormData is not supported with GET requests`);let t=await zr(r);if(t!==void 0){let n=p({payload:t});e.includes(`?`)?e+=`&${n}`:e+=`?${n}`}}let c;if(r.method===`POST`){let e=await Vr(r);e?.contentType&&o.set(`content-type`,e.contentType),c=e?.body}return await Hr(async()=>i(e,{method:r.method,headers:o,signal:r.signal,body:c}))}async function zr(e){let t=!1,n={};if(e.data!==void 0&&(t=!0,n.data=e.data),e.context&&Lr(e.context)&&(t=!0,n.context=e.context),t)return Br(n)}async function Br(e){return JSON.stringify(await Promise.resolve(sr(e,{plugins:Z})))}async function Vr(e){if(e.data instanceof FormData){let t;return e.context&&Lr(e.context)&&(t=await Br(e.context)),t!==void 0&&e.data.set(i,t),{body:e.data}}let t=await zr(e);if(t)return{body:t,contentType:`application/json`}}async function Hr(n){let i;try{i=await n()}catch(e){if(e instanceof Response)i=e;else throw console.log(e),e}if(i.headers.get(`x-tss-raw`)===`true`)return i;let a=i.headers.get(`content-type`);if(a||e(),i.headers.get(`x-tss-serialized`)){let t;if(a.includes(`application/x-tss-framed`)){if(d(a),!i.body)throw Error(`No response body for framed response`);let{getOrCreateStream:e,jsonChunks:n}=Fr(i.body),r=[Sr(e),...Z||[]],o=new Map;t=await Ur({jsonStream:n,onMessage:e=>or(e,{refs:o,plugins:r}),onError(e,t){console.error(e,t)}})}else if(a.includes(`application/json`)){let e=await i.json(),n=[];try{t=or(e,{plugins:Z})}finally{}await Q(n)}if(t||e(),t instanceof Error)throw t;return t}if(a.includes(`application/json`)){let e=await i.json(),n=r(e);if(n)throw n;if(t(e))throw e;return e}if(!i.ok)throw Error(await i.text());return i}async function Ur({jsonStream:e,onMessage:t,onError:n}){let r=e.getReader(),{value:i,done:a}=await r.read();if(a||!i)throw Error(`Stream ended before first object`);let o=JSON.parse(i),s=!1,c=(async()=>{try{for(;;){let{value:e,done:i}=await r.read();if(i)break;if(e)try{let n=[];try{t(JSON.parse(e))}finally{}await Q(n)}catch(t){n?.(`Invalid JSON: ${e}`,t)}}}catch(e){s||n?.(`Stream processing error:`,e)}})(),l,u=[];try{l=t(o)}catch(e){throw s=!0,r.cancel().catch(()=>{}),e}return await Q(u),Promise.resolve(l).catch(()=>{s=!0,r.cancel().catch(()=>{})}),c.finally(()=>{try{r.releaseLock()}catch{}}),l}function Wr(e){let t=`/_serverFn/`+e;return Object.assign((...e)=>{let n=f()?.serverFns?.fetch;return Rr(t,e,n??fetch)},{url:t,serverFnMeta:{id:e},[a]:!0})}function Gr(e){if(Array.isArray(e))return e.flatMap(e=>Gr(e));if(typeof e!=`string`)return[];let t=[],n=0,r,i,a,o,s,c=()=>{for(;n<e.length&&/\s/.test(e.charAt(n));)n+=1;return n<e.length},l=()=>(i=e.charAt(n),i!==`=`&&i!==`;`&&i!==`,`);for(;n<e.length;){for(r=n,s=!1;c();)if(i=e.charAt(n),i===`,`){for(a=n,n+=1,c(),o=n;n<e.length&&l();)n+=1;n<e.length&&e.charAt(n)===`=`?(s=!0,n=o,t.push(e.slice(r,a)),r=n):n=a+1}else n+=1;(!s||n>=e.length)&&t.push(e.slice(r))}return t}function Kr(e){return e instanceof Headers?e:Array.isArray(e)||typeof e==`object`?new Headers(e):null}function qr(...e){return e.reduce((e,t)=>{let n=Kr(t);if(!n)return e;for(let[t,r]of n.entries())t===`set-cookie`?Gr(r).forEach(t=>e.append(`set-cookie`,t)):e.set(t,r);return e},new Headers)}function Jr(e){return e!==`__proto__`&&e!==`constructor`&&e!==`prototype`}function Yr(e,t){let n=Object.create(null);if(e)for(let t of Object.keys(e))Jr(t)&&(n[t]=e[t]);if(t&&typeof t==`object`)for(let e of Object.keys(t))Jr(e)&&(n[e]=t[e]);return n}function Xr(e){if(!e)return Object.create(null);let t=Object.create(null);for(let n of Object.keys(e))Jr(n)&&(t[n]=e[n]);return t}var Zr=()=>{throw Error(`createServerOnlyFn() functions can only be called on the server!`)},$=(e,t)=>{let n=t||e||{};n.method===void 0&&(n.method=`GET`);let i=e=>$(void 0,{...n,validator:e,inputValidator:e});return Object.assign(e=>$(void 0,{...n,...e}),{options:n,middleware:e=>{let t=[...n.middleware||[]];e.map(e=>{o in e?e.options.middleware&&t.push(...e.options.middleware):t.push(e)});let r=$(void 0,{...n,middleware:t});return r[o]=!0,r},validator:i,inputValidator:i,handler:(...e)=>{let[t,i]=e,a={...n,extractedFn:t,serverFn:i},o=[...a.middleware||[],ti(a)];return t.method=n.method,Object.assign(async e=>{let n=await Qr(o,`client`,{...t,...a,data:e?.data,headers:e?.headers,signal:e?.signal,fetch:e?.fetch,context:Xr()}),i=r(n.error);if(i)throw i;if(n.error)throw n.error;return n.result},{...t,method:n.method,__executeServer:async e=>{let n=Zr(),r=n.contextAfterGlobalMiddlewares;return await Qr(o,`server`,{...t,...e,serverFnMeta:t.serverFnMeta,context:Yr(e.context,r),request:n.request}).then(e=>({result:e.result,error:e.error,context:e.sendContext}))}})}})};async function Qr(e,t,r){let i=$r([...f()?.functionMiddleware||[],...e]);if(t===`server`){let e=Zr({throwIfNotFound:!1});e?.executedRequestMiddlewares&&(i=i.filter(t=>!e.executedRequestMiddlewares.has(t)))}let a=async e=>{let r=i.shift();if(!r)return e;try{let i=`validator`in r.options?r.options.validator:void 0;!i&&`inputValidator`in r.options&&(i=r.options.inputValidator),i&&t===`server`&&(e.data=await ei(i,e.data));let o;if(t===`client`?`client`in r.options&&(o=r.options.client):`server`in r.options&&(o=r.options.server),o){let t=async(t={})=>{let n=await a({...e,...t,context:Yr(e.context,t.context),sendContext:Yr(e.sendContext,t.sendContext),headers:qr(e.headers,t.headers),_callSiteFetch:e._callSiteFetch,fetch:e._callSiteFetch??t.fetch??e.fetch,result:t.result===void 0?t instanceof Response?t:e.result:t.result,error:t.error??e.error});if(n.error)throw n.error;return n},r=await o({...e,next:t});if(n(r))return{...e,error:r};if(r instanceof Response)return{...e,result:r};if(!r)throw Error(`User middleware returned undefined. You must call next() or return a result in your middlewares.`);return r}return a(e)}catch(t){return{...e,error:t}}};return a({...r,headers:r.headers||{},sendContext:r.sendContext||{},context:r.context||Xr(),_callSiteFetch:r.fetch})}function $r(e,t=100){let n=new Set,r=[],i=(e,a)=>{if(a>t)throw Error(`Middleware nesting depth exceeded maximum of ${t}. Check for circular references.`);e.forEach(e=>{e.options.middleware&&i(e.options.middleware,a+1),n.has(e)||(n.add(e),r.push(e))})};return i(e,0),r}async function ei(e,t){if(e==null)return{};if(`~standard`in e){let n=await e[`~standard`].validate(t);if(n.issues)throw Error(JSON.stringify(n.issues,void 0,2));return n.value}if(`parse`in e)return e.parse(t);if(typeof e==`function`)return e(t);throw Error(`Invalid validator type!`)}function ti(e){return{"~types":void 0,options:{inputValidator:e.validator??e.inputValidator,client:async({next:t,sendContext:n,fetch:r,...i})=>{let a={...i,context:n,fetch:r};return t(await e.extractedFn?.(a))},server:async({next:t,...n})=>{let r=await e.serverFn?.(n);return t({...n,result:r})}}}}export{p as a,ee as i,Wr as n,a as o,cr as r,$ as t};
@@ -0,0 +1 @@
1
+ function e(e){switch(e){case`added`:return`added`;case`modified`:return`modified`;case`deleted`:return`deleted`;case`renamed`:return`renamed`;case`copied`:return`copied`;case`type_changed`:return`type changed`;case`unmerged`:return`unmerged`;case`untracked`:return`untracked`;default:return`changed`}}function t(t){let n=e(t.status);return t.excludedReason===`credential_shaped`?`${n} · content withheld (credential-shaped)`:t.excludedReason===`bazilion_state`?`${n} · content withheld (Bazilion state)`:t.contentOmitted===`untracked_not_selected`?`${n} · content not selected`:t.binary?`${n} · binary`:t.addedLines===null||t.deletedLines===null?n:`${n} · +${t.addedLines} −${t.deletedLines}`}function n(e,t){return`${e.headState===`detached`?`detached at ${r(e.head)}`:e.headState===`unborn`?`unborn on ${e.branch??`(unknown branch)`}`:e.branch??`(unknown branch)`} · base ${t.base.requestedRef} (${r(t.base.resolvedOid)})`}function r(e){return e===null?`—`:e.slice(0,12)}function i(e,t){switch(e){case`not_repository`:return`This Team workspace is not a Git repository, so there are no changes to review.`;case`unsupported_layout`:return`${t} Bazilion does not widen mounts or run repository helpers to make inspection work; use a repository whose work tree and metadata are reachable from the Team root.`;case`invalid_base`:return`That comparison base is not a plain branch, tag or commit id.`;case`unknown_base`:return`That comparison base does not name a commit in this repository.`;default:return t}}function a(e){let t=new Date(e.createdAt).toISOString().replace(`T`,` `).slice(0,16),n=e.complete?`complete`:`incomplete (applicability unknown)`;return`${e.snapshotId.slice(0,12)} · ${n} · ${e.capturedBy} · ${t} · ${e.entryCount} entries`}function o(e){if(e===null)return`Source: Not checked`;switch(e.comparison){case`identical`:return`Source: unchanged since this result was produced`;case`changed`:return`Source: changed since this result was produced — relevance unknown`;default:return`Source: unknown (${e.reason.replaceAll(`_`,` `)})`}}function s(e){return e!==null&&e.comparison!==`identical`}function c(e){return`${e.id.slice(0,12)} · ${e.complete?`complete`:`incomplete`}`}export{c as a,t as i,s as n,a as o,n as r,i as s,o as t};