@lovelybunch/api 1.0.71-alpha.1 → 1.0.71-alpha.2

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 (235) hide show
  1. package/dist/lib/auth/auth-manager.d.ts.map +1 -0
  2. package/dist/lib/auth/auth-manager.js.map +1 -0
  3. package/dist/lib/gait-path.d.ts.map +1 -0
  4. package/dist/lib/gait-path.js.map +1 -0
  5. package/dist/lib/git-settings.d.ts.map +1 -0
  6. package/dist/lib/git-settings.js.map +1 -0
  7. package/dist/lib/git.d.ts.map +1 -0
  8. package/dist/lib/git.js.map +1 -0
  9. package/dist/lib/jobs/global-job-scheduler.d.ts.map +1 -0
  10. package/dist/lib/jobs/global-job-scheduler.js.map +1 -0
  11. package/dist/lib/jobs/job-runner.d.ts.map +1 -0
  12. package/dist/lib/jobs/job-runner.js.map +1 -0
  13. package/dist/lib/jobs/job-scheduler.d.ts.map +1 -0
  14. package/dist/lib/jobs/job-scheduler.js.map +1 -0
  15. package/dist/lib/jobs/job-store.d.ts.map +1 -0
  16. package/dist/lib/jobs/job-store.js.map +1 -0
  17. package/dist/lib/project-paths.d.ts.map +1 -0
  18. package/dist/lib/project-paths.js.map +1 -0
  19. package/dist/lib/storage/file-storage.d.ts.map +1 -0
  20. package/dist/lib/storage/file-storage.js.map +1 -0
  21. package/dist/lib/symlinks/symlink-manager.d.ts.map +1 -0
  22. package/dist/lib/symlinks/symlink-manager.js.map +1 -0
  23. package/dist/lib/symlinks/types.d.ts.map +1 -0
  24. package/dist/lib/symlinks/types.js.map +1 -0
  25. package/dist/lib/terminal/context-helper.d.ts.map +1 -0
  26. package/dist/lib/terminal/context-helper.js.map +1 -0
  27. package/dist/lib/terminal/global-manager.d.ts.map +1 -0
  28. package/dist/lib/terminal/global-manager.js.map +1 -0
  29. package/dist/lib/terminal/shell-utils.d.ts.map +1 -0
  30. package/dist/lib/terminal/shell-utils.js.map +1 -0
  31. package/dist/lib/terminal/terminal-manager.d.ts.map +1 -0
  32. package/dist/lib/terminal/terminal-manager.js.map +1 -0
  33. package/dist/lib/user-preferences.d.ts.map +1 -0
  34. package/dist/lib/user-preferences.js.map +1 -0
  35. package/dist/middleware/auth.d.ts.map +1 -0
  36. package/dist/middleware/auth.js.map +1 -0
  37. package/dist/routes/api/v1/agents/[id]/index.d.ts.map +1 -0
  38. package/dist/routes/api/v1/agents/[id]/index.js.map +1 -0
  39. package/dist/routes/api/v1/agents/[id]/route.d.ts.map +1 -0
  40. package/dist/routes/api/v1/agents/[id]/route.js.map +1 -0
  41. package/dist/routes/api/v1/agents/index.d.ts.map +1 -0
  42. package/dist/routes/api/v1/agents/index.js.map +1 -0
  43. package/dist/routes/api/v1/agents/route.d.ts.map +1 -0
  44. package/dist/routes/api/v1/agents/route.js.map +1 -0
  45. package/dist/routes/api/v1/ai/index.d.ts.map +1 -0
  46. package/dist/routes/api/v1/ai/index.js.map +1 -0
  47. package/dist/routes/api/v1/ai/route.d.ts.map +1 -0
  48. package/dist/routes/api/v1/ai/route.js.map +1 -0
  49. package/dist/routes/api/v1/api-keys/index.d.ts.map +1 -0
  50. package/dist/routes/api/v1/api-keys/index.js.map +1 -0
  51. package/dist/routes/api/v1/api-keys/route.d.ts.map +1 -0
  52. package/dist/routes/api/v1/api-keys/route.js.map +1 -0
  53. package/dist/routes/api/v1/auth/index.d.ts.map +1 -0
  54. package/dist/routes/api/v1/auth/index.js.map +1 -0
  55. package/dist/routes/api/v1/auth/route.d.ts.map +1 -0
  56. package/dist/routes/api/v1/auth/route.js.map +1 -0
  57. package/dist/routes/api/v1/auth-settings/index.d.ts.map +1 -0
  58. package/dist/routes/api/v1/auth-settings/index.js.map +1 -0
  59. package/dist/routes/api/v1/auth-settings/route.d.ts.map +1 -0
  60. package/dist/routes/api/v1/auth-settings/route.js.map +1 -0
  61. package/dist/routes/api/v1/chats/[id]/index.d.ts.map +1 -0
  62. package/dist/routes/api/v1/chats/[id]/index.js.map +1 -0
  63. package/dist/routes/api/v1/chats/[id]/route.d.ts.map +1 -0
  64. package/dist/routes/api/v1/chats/[id]/route.js.map +1 -0
  65. package/dist/routes/api/v1/chats/index.d.ts.map +1 -0
  66. package/dist/routes/api/v1/chats/index.js.map +1 -0
  67. package/dist/routes/api/v1/chats/route.d.ts.map +1 -0
  68. package/dist/routes/api/v1/chats/route.js.map +1 -0
  69. package/dist/routes/api/v1/config/index.d.ts.map +1 -0
  70. package/dist/routes/api/v1/config/index.js.map +1 -0
  71. package/dist/routes/api/v1/config/route.d.ts.map +1 -0
  72. package/dist/routes/api/v1/config/route.js.map +1 -0
  73. package/dist/routes/api/v1/context/architecture/route.d.ts.map +1 -0
  74. package/dist/routes/api/v1/context/architecture/route.js.map +1 -0
  75. package/dist/routes/api/v1/context/index.d.ts.map +1 -0
  76. package/dist/routes/api/v1/context/index.js.map +1 -0
  77. package/dist/routes/api/v1/context/knowledge/[filename]/index.d.ts.map +1 -0
  78. package/dist/routes/api/v1/context/knowledge/[filename]/index.js.map +1 -0
  79. package/dist/routes/api/v1/context/knowledge/[filename]/route.d.ts.map +1 -0
  80. package/dist/routes/api/v1/context/knowledge/[filename]/route.js.map +1 -0
  81. package/dist/routes/api/v1/context/knowledge/index.d.ts.map +1 -0
  82. package/dist/routes/api/v1/context/knowledge/index.js.map +1 -0
  83. package/dist/routes/api/v1/context/knowledge/route.d.ts.map +1 -0
  84. package/dist/routes/api/v1/context/knowledge/route.js.map +1 -0
  85. package/dist/routes/api/v1/context/project/route.d.ts.map +1 -0
  86. package/dist/routes/api/v1/context/project/route.js.map +1 -0
  87. package/dist/routes/api/v1/events/status/route.d.ts +1 -1
  88. package/dist/routes/api/v1/git/index.d.ts.map +1 -0
  89. package/dist/routes/api/v1/git/index.js.map +1 -0
  90. package/dist/routes/api/v1/jobs/[id]/route.d.ts.map +1 -0
  91. package/dist/routes/api/v1/jobs/[id]/route.js.map +1 -0
  92. package/dist/routes/api/v1/jobs/[id]/run/route.d.ts +2 -2
  93. package/dist/routes/api/v1/jobs/[id]/run/route.d.ts.map +1 -0
  94. package/dist/routes/api/v1/jobs/[id]/run/route.js.map +1 -0
  95. package/dist/routes/api/v1/jobs/index.d.ts.map +1 -0
  96. package/dist/routes/api/v1/jobs/index.js.map +1 -0
  97. package/dist/routes/api/v1/jobs/route.d.ts.map +1 -0
  98. package/dist/routes/api/v1/jobs/route.js.map +1 -0
  99. package/dist/routes/api/v1/jobs/status/route.d.ts +1 -1
  100. package/dist/routes/api/v1/jobs/status/route.d.ts.map +1 -0
  101. package/dist/routes/api/v1/jobs/status/route.js.map +1 -0
  102. package/dist/routes/api/v1/mcp/index.d.ts.map +1 -0
  103. package/dist/routes/api/v1/mcp/index.js.map +1 -0
  104. package/dist/routes/api/v1/mcp/route.d.ts.map +1 -0
  105. package/dist/routes/api/v1/mcp/route.js.map +1 -0
  106. package/dist/routes/api/v1/proposals/[id]/route.d.ts +8 -8
  107. package/dist/routes/api/v1/proposals/[id]/route.d.ts.map +1 -0
  108. package/dist/routes/api/v1/proposals/[id]/route.js.map +1 -0
  109. package/dist/routes/api/v1/proposals/index.d.ts.map +1 -0
  110. package/dist/routes/api/v1/proposals/index.js.map +1 -0
  111. package/dist/routes/api/v1/proposals/route.d.ts.map +1 -0
  112. package/dist/routes/api/v1/proposals/route.js.map +1 -0
  113. package/dist/routes/api/v1/resources/[id]/index.d.ts.map +1 -0
  114. package/dist/routes/api/v1/resources/[id]/index.js.map +1 -0
  115. package/dist/routes/api/v1/resources/[id]/route.js.map +1 -0
  116. package/dist/routes/api/v1/resources/[id]/thumbnail/index.d.ts.map +1 -0
  117. package/dist/routes/api/v1/resources/[id]/thumbnail/index.js.map +1 -0
  118. package/dist/routes/api/v1/resources/[id]/thumbnail/route.js.map +1 -0
  119. package/dist/routes/api/v1/resources/index.d.ts.map +1 -0
  120. package/dist/routes/api/v1/resources/index.js.map +1 -0
  121. package/dist/routes/api/v1/resources/route.d.ts.map +1 -0
  122. package/dist/routes/api/v1/resources/route.js.map +1 -0
  123. package/dist/routes/api/v1/symlinks/index.d.ts.map +1 -0
  124. package/dist/routes/api/v1/symlinks/index.js.map +1 -0
  125. package/dist/routes/api/v1/symlinks/route.d.ts.map +1 -0
  126. package/dist/routes/api/v1/symlinks/route.js.map +1 -0
  127. package/dist/routes/api/v1/terminal/[proposalId]/create/index.d.ts.map +1 -0
  128. package/dist/routes/api/v1/terminal/[proposalId]/create/index.js.map +1 -0
  129. package/dist/routes/api/v1/terminal/[proposalId]/create/route.d.ts.map +1 -0
  130. package/dist/routes/api/v1/terminal/[proposalId]/create/route.js.map +1 -0
  131. package/dist/routes/api/v1/terminal/[proposalId]/destroy/index.d.ts.map +1 -0
  132. package/dist/routes/api/v1/terminal/[proposalId]/destroy/index.js.map +1 -0
  133. package/dist/routes/api/v1/terminal/[proposalId]/destroy/route.d.ts.map +1 -0
  134. package/dist/routes/api/v1/terminal/[proposalId]/destroy/route.js.map +1 -0
  135. package/dist/routes/api/v1/terminal/[proposalId]/resize/index.d.ts.map +1 -0
  136. package/dist/routes/api/v1/terminal/[proposalId]/resize/index.js.map +1 -0
  137. package/dist/routes/api/v1/terminal/[proposalId]/resize/route.d.ts.map +1 -0
  138. package/dist/routes/api/v1/terminal/[proposalId]/resize/route.js.map +1 -0
  139. package/dist/routes/api/v1/terminal/sessions/index.d.ts.map +1 -0
  140. package/dist/routes/api/v1/terminal/sessions/index.js.map +1 -0
  141. package/dist/routes/api/v1/terminal/sessions/route.d.ts.map +1 -0
  142. package/dist/routes/api/v1/terminal/sessions/route.js.map +1 -0
  143. package/dist/routes/api/v1/user/index.d.ts.map +1 -0
  144. package/dist/routes/api/v1/user/index.js.map +1 -0
  145. package/dist/routes/api/v1/user/settings/index.d.ts.map +1 -0
  146. package/dist/routes/api/v1/user/settings/index.js.map +1 -0
  147. package/dist/routes/api/v1/user/settings/route.d.ts.map +1 -0
  148. package/dist/routes/api/v1/user/settings/route.js.map +1 -0
  149. package/dist/server-with-static.d.ts.map +1 -0
  150. package/dist/server-with-static.js.map +1 -0
  151. package/dist/server.d.ts.map +1 -0
  152. package/dist/server.js.map +1 -0
  153. package/package.json +4 -4
  154. package/static/assets/AgentDetailPage-DwWIjGx1.js +1 -0
  155. package/static/assets/AgentEditPage-BvVPfYR3.js +1 -0
  156. package/static/assets/AgentsPage-D-Uy87Gh.js +3 -0
  157. package/static/assets/AgentsSettingsPage-CDuAvFxu.js +6 -0
  158. package/static/assets/ApiKeysSettingsPage-Jug0kB7Z.js +7 -0
  159. package/static/assets/ArchitectureEditPage-BmAgJAMV.js +21 -0
  160. package/static/assets/ArchitecturePage-ZjbdnDA7.js +1 -0
  161. package/static/assets/AuthSettingsPage-_pXoewOB.js +11 -0
  162. package/static/assets/CallbackPage-CaAOpz4z.js +1 -0
  163. package/static/assets/CodePage-DEbgr8C1.js +2 -0
  164. package/static/assets/CollapsibleSection-msxUBh1L.js +1 -0
  165. package/static/assets/DashboardPage-BXu-fikP.js +11 -0
  166. package/static/assets/GitPage-B7qFcP-K.js +16 -0
  167. package/static/assets/GitSettingsPage-D7GjdOnE.js +6 -0
  168. package/static/assets/IdentityPage-BR48gNhN.js +11 -0
  169. package/static/assets/ImplementationStepsEditor-BdHMNVVd.js +6 -0
  170. package/static/assets/IntegrationsSettingsPage-B1OHGlDC.js +1 -0
  171. package/static/assets/KnowledgeDetailPage-DBOQQs3R.js +1 -0
  172. package/static/assets/KnowledgeEditPage-DHJxLPwi.js +1 -0
  173. package/static/assets/KnowledgePage-CuuDTMa_.js +8 -0
  174. package/static/assets/LoginPage-IIU6NAG9.js +1 -0
  175. package/static/assets/McpSettingsPage-iz5gLGWt.js +1 -0
  176. package/static/assets/NewAgentPage-DolltGy5.js +1 -0
  177. package/static/assets/NewKnowledgePage-_jbUZqBU.js +9 -0
  178. package/static/assets/NewProposalPage-bFnfuuoA.js +90 -0
  179. package/static/assets/ProjectEditPage-DTTjPnGj.js +11 -0
  180. package/static/assets/ProjectPage-DhwrnEq2.js +1 -0
  181. package/static/assets/PromptsSettingsPage-DLOVysbE.js +1 -0
  182. package/static/assets/ProposalDetailPage-KvjXUaaf.js +1 -0
  183. package/static/assets/ProposalEditPage-BmzkHL9a.js +1 -0
  184. package/static/assets/ProposalsPage-DwQr1ycd.js +17 -0
  185. package/static/assets/ResourcesPage-B8Hm_j47.js +66 -0
  186. package/static/assets/RulesSettingsPage-CsGXFTFY.js +16 -0
  187. package/static/assets/SchedulePage-CY8GdQlp.js +4 -0
  188. package/static/assets/TagInput-CbH9zq5n.js +1 -0
  189. package/static/assets/TerminalPage-DsjOLnyY.js +1 -0
  190. package/static/assets/TerminalSessionPage-DQ065WYU.js +13 -0
  191. package/static/assets/UserPreferencesPage-55VTrzfQ.js +1 -0
  192. package/static/assets/UserSettingsPage-BZwb93B4.js +1 -0
  193. package/static/assets/UtilitiesPage-BmEW7eJ_.js +1 -0
  194. package/static/assets/alert-CNSGDe1U.js +1 -0
  195. package/static/assets/arrow-down-D1dapxzl.js +6 -0
  196. package/static/assets/arrow-left-CEZFPQje.js +6 -0
  197. package/static/assets/arrow-up-D-lB4Ah6.js +6 -0
  198. package/static/assets/badge-DO6e5hC1.js +1 -0
  199. package/static/assets/browser-modal-BTxVvZIA.js +6 -0
  200. package/static/assets/calendar-DWaFMSXH.js +6 -0
  201. package/static/assets/card-Cnz8b7Ou.js +1 -0
  202. package/static/assets/chevron-left-CNgc28Tc.js +6 -0
  203. package/static/assets/circle-alert-Dick-jNf.js +6 -0
  204. package/static/assets/circle-check-DDk43rYV.js +6 -0
  205. package/static/assets/circle-check-big-B70gdce7.js +6 -0
  206. package/static/assets/circle-play-TJEfmKde.js +6 -0
  207. package/static/assets/circle-x-BfR2YcXx.js +6 -0
  208. package/static/assets/clipboard-B9ndUJKl.js +1 -0
  209. package/static/assets/clipboard-BTZru8wn.js +11 -0
  210. package/static/assets/clock-DQXbrDkQ.js +6 -0
  211. package/static/assets/download-CW_rWwud.js +6 -0
  212. package/static/assets/droid-CmYuCN_q.js +4 -0
  213. package/static/assets/eye-Bv6mO2ld.js +6 -0
  214. package/static/assets/folder-git-2-Cv5NbBZZ.js +6 -0
  215. package/static/assets/index-BSBM4i_g.js +458 -0
  216. package/static/assets/{index-Bo1l13x2.css → index-CKwmN6yL.css} +2 -33
  217. package/static/assets/label-vEgNxdb2.js +1 -0
  218. package/static/assets/markdown-editor-DUEthZ0y.css +1 -0
  219. package/static/assets/markdown-editor-O6tGYa1a.js +62 -0
  220. package/static/assets/pause-6aQLhmG9.js +6 -0
  221. package/static/assets/play-DsDsjO2V.js +6 -0
  222. package/static/assets/plus-BfBtnncn.js +6 -0
  223. package/static/assets/radio-group-D_RD_9vY.js +1 -0
  224. package/static/assets/refresh-cw-DvFNtws1.js +6 -0
  225. package/static/assets/search-kcgmZUqQ.js +6 -0
  226. package/static/assets/switch-Bjq8cgQn.js +1 -0
  227. package/static/assets/tabs-DDbBXbPg.js +1 -0
  228. package/static/assets/tag-Czz-3rNY.js +6 -0
  229. package/static/assets/terminal-preview-B7iP2vUT.js +11 -0
  230. package/static/assets/use-terminal-CN3pheMp.js +1 -0
  231. package/static/assets/xterm-DTxiCjtJ.js +9 -0
  232. package/static/assets/xterm-qxJ8_QYu.css +32 -0
  233. package/static/assets/zap-BMkP_c9R.js +6 -0
  234. package/static/index.html +2 -2
  235. package/static/assets/index-DgZp291y.js +0 -973
@@ -0,0 +1,4 @@
1
+ import{H as Qe,ag as Xe,r as m,j as e,B as u,n as O,be as pe,M as q,N as ge,T as fe,O as V,P as Y,Q as G,R as K,U as Q,V as X,W as Z,i as ee,h as ve,bf as Ze,C as es,q as ss,s as se,D as je,a as Ne,b as be,d as ye,e as we,I as te,v as ts,w as as,x as rs,y as ns,z as is,a5 as Se,a6 as Ce,a7 as ke,a8 as Ae,a9 as De,ae as Te,a0 as ls,ac as ds,$ as Ie,A as j}from"./index-BSBM4i_g.js";import{C as J,a as ae,c as re,b as Fe}from"./card-Cnz8b7Ou.js";import{B as F}from"./badge-DO6e5hC1.js";import{L as v}from"./label-vEgNxdb2.js";import{S as cs}from"./switch-Bjq8cgQn.js";import{T as os,a as ms,b as ne,c as ie}from"./tabs-DDbBXbPg.js";import{R as us}from"./refresh-cw-DvFNtws1.js";import{P as Pe}from"./plus-BfBtnncn.js";import{P as Me}from"./play-DsDsjO2V.js";import{P as hs}from"./pause-6aQLhmG9.js";import{C as xs}from"./clock-DQXbrDkQ.js";const ce=[{id:"claude",label:"Claude Code"},{id:"gemini",label:"Google Gemini"},{id:"codex",label:"OpenAI Codex"},{id:"droid",label:"Factory Droid"}],ps=[{label:"Monday",value:"monday"},{label:"Tuesday",value:"tuesday"},{label:"Wednesday",value:"wednesday"},{label:"Thursday",value:"thursday"},{label:"Friday",value:"friday"},{label:"Saturday",value:"saturday"},{label:"Sunday",value:"sunday"}],$e=["monday","tuesday","wednesday","thursday","friday"],Ee=a=>{if(!a)return"—";try{return new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(new Date(a))}catch{return a}},H=a=>{if(!a)return"—";const x=new Date(a).getTime()-Date.now(),f=Math.round(x/(1e3*60));if(Number.isNaN(f))return Ee(a);if(Math.abs(f)<1)return"now";if(f>0){if(f<60)return`in ${f}m`;const b=Math.round(f/60);return b<24?`in ${b}h`:`in ${Math.round(b/24)}d`}const N=Math.abs(f);if(N<60)return`${N}m ago`;const I=Math.round(N/60);return I<24?`${I}h ago`:`${Math.round(I/24)}d ago`},gs=a=>{if(a.type==="interval"){const o=a.daysOfWeek.map(x=>x.slice(0,3).toUpperCase()).join(", ");return`Every ${a.hours}h (${o||"All days"})`}return a.description||`Cron: ${a.expression}`},fs=a=>{const o=ce.find(x=>x.id===a);return o?o.label:a},le=a=>{switch(a){case"active":case"succeeded":return"default";case"paused":case"running":return"secondary";case"failed":return"destructive";default:return"outline"}},de=()=>({name:"",model:"claude",prompt:"",hours:6,daysOfWeek:new Set($e),status:!0,anchorHour:"",agentIds:[],mcpServers:[]}),Re=a=>{if(a.schedule.type!=="interval")return de();const o=a.agentIds||(a.agentId?[a.agentId]:[]);return{name:a.name,model:ce.some(x=>x.id===a.model)?a.model:"claude",prompt:a.prompt,hours:a.schedule.hours,daysOfWeek:new Set(a.schedule.daysOfWeek),status:a.status==="active",anchorHour:a.schedule.anchorHour===void 0?"":String(a.schedule.anchorHour),agentIds:o,mcpServers:a.mcpServers||[]}},vs=a=>a?Array.isArray(a)?a.filter(o=>typeof o=="string").map(o=>o.trim()).filter(Boolean):typeof a=="string"?a.split(",").map(o=>o.trim()).filter(Boolean):[]:[];function Is(){const{toast:a}=Qe(),{refresh:o}=Xe(),[x,f]=m.useState([]),[N,I]=m.useState(!0),[L,b]=m.useState(!1),[P,y]=m.useState(!1),[n,p]=m.useState(()=>de()),[z,oe]=m.useState(!1),[w,S]=m.useState(null),[c,C]=m.useState(null),[g,M]=m.useState(null),[Oe,R]=m.useState(!1),[$,Je]=m.useState([]),[W,He]=m.useState([]),[Le,ze]=m.useState(new Set),[B,U]=m.useState({open:!1,serverToRemove:null}),k=async(s=!1)=>{try{N||b(!0);const t=await fetch(`${j}/api/v1/jobs`);if(!t.ok)throw new Error(`Failed to fetch jobs (${t.status})`);const r=await t.json();if(!r?.success)throw new Error(r?.error?.message||"Unknown error loading jobs");const i=r.data??[];if(f(i),c){const l=i.find(d=>d.id===c.id);l&&(C(l),l.schedule.type!=="cron"&&p(Re(l)))}if(g){const l=i.find(d=>d.id===g.id);l&&M(l)}s&&a({title:"Schedule refreshed",description:"Latest job information loaded."})}catch(t){console.error("Failed to load jobs:",t),a({title:"Failed to load schedule",description:t?.message??"Unknown error",variant:"destructive"})}finally{I(!1),b(!1)}};m.useEffect(()=>{k()},[]),m.useEffect(()=>{P&&(async()=>{try{const t=await fetch(`${j}/api/v1/agents`);if(t.ok){const i=await t.json(),d=(Array.isArray(i?.documents)?i.documents:[]).map(h=>({id:h.filename,name:h?.metadata?.name||h.title||h.filename,tools:vs(h?.metadata?.tools)}));if(Je(d),c){const D=(c.agentIds||(c.agentId?[c.agentId]:[])).filter(T=>!d.find(_=>_.id===T));D.length>0&&(a({title:"Some agents no longer available",description:`The following agents have been removed: ${D.join(", ")}`,variant:"destructive"}),p(T=>({...T,agentIds:T.agentIds.filter(_=>d.find(Ke=>Ke.id===_))})))}}const r=await fetch(`${j}/api/v1/mcp`);if(r.ok){const i=await r.json();if(i?.success&&Array.isArray(i.servers)&&(He(i.servers),c?.mcpServers)){const l=c.mcpServers.filter(d=>!i.servers.includes(d));l.length>0&&(a({title:"Some MCP servers are no longer available",description:`The following servers have been removed: ${l.join(", ")}`,variant:"destructive"}),p(d=>({...d,mcpServers:d.mcpServers.filter(h=>i.servers.includes(h))})))}}}catch(t){console.error("Failed to load agents or MCP servers:",t)}})()},[P,c,a]);const A=s=>{p(t=>({...t,...s}))},We=(s,t)=>{p(r=>{let i;if(t){i=[...r.agentIds,s];const l=$.find(d=>d.id===s);if(l&&l.tools.length>0){const d=new Set([...r.mcpServers,...l.tools]);return{...r,agentIds:i,mcpServers:Array.from(d).filter(h=>W.includes(h))}}}else i=r.agentIds.filter(l=>l!==s);return{...r,agentIds:i}})},Be=(s,t)=>{if(!t&&$.filter(i=>n.agentIds.includes(i.id)&&i.tools.includes(s)).length>0){U({open:!0,serverToRemove:s});return}p(r=>({...r,mcpServers:t?[...r.mcpServers,s]:r.mcpServers.filter(i=>i!==s)}))},Ue=()=>{const s=B.serverToRemove;s&&p(t=>({...t,mcpServers:t.mcpServers.filter(r=>r!==s)})),U({open:!1,serverToRemove:null})},_e=(s,t)=>{p(r=>{const i=new Set(r.daysOfWeek);return t?i.add(s):i.delete(s),i.size===0&&$e.forEach(l=>i.add(l)),{...r,daysOfWeek:i}})},E=()=>{p(de())},me=s=>{ze(t=>{const r=new Set(t);return r.has(s)?r.delete(s):r.add(s),r})},ue=s=>{M(s),R(!0)},he=()=>{C(null),E(),y(!0)},qe=s=>{if(s._error){a({title:"Cannot edit corrupted job",description:"Please fix the job file manually at .nut/jobs/"+s.id+".md",variant:"destructive"});return}if(s.schedule.type==="cron"){a({title:"Manual edit required",description:"Cron-based jobs can be edited directly in .nut/jobs/<id>.md for now.",variant:"destructive"});return}C(s),p(Re(s)),y(!0)},Ve=async s=>{if(s.preventDefault(),!n.name.trim()){a({title:"Job name required",description:"Please provide a name for the scheduled job.",variant:"destructive"});return}if(!n.prompt.trim()){a({title:"Prompt required",description:"Please provide instructions for the scheduled job.",variant:"destructive"});return}oe(!0);const t=!!c;try{const r=Number(n.anchorHour.trim()),i=n.anchorHour.trim()===""||Number.isNaN(r)?void 0:Math.min(23,Math.max(0,r)),l={name:n.name.trim(),prompt:n.prompt.trim(),model:n.model,status:n.status?"active":"paused",schedule:{type:"interval",hours:Math.max(1,Number(n.hours)||6),daysOfWeek:Array.from(n.daysOfWeek),anchorHour:i},agentIds:n.agentIds.length>0?n.agentIds:void 0,mcpServers:n.mcpServers.length>0?n.mcpServers:void 0},d=t?`${j}/api/v1/jobs/${c?.id}`:`${j}/api/v1/jobs`,D=await fetch(d,{method:t?"PATCH":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!D.ok){const T=await D.json().catch(()=>({}));throw new Error(T?.error?.message||`Failed to ${t?"update":"create"} job (${D.status})`)}a({title:t?"Scheduled job updated":"Scheduled job created",description:l.name}),y(!1),C(null),E(),await k()}catch(r){console.error("Failed to submit job:",r),a({title:`Failed to ${c?"update":"create"} job`,description:r?.message??"Unknown error",variant:"destructive"})}finally{oe(!1)}},Ye=async s=>{if(s._error){a({title:"Cannot run corrupted job",description:"Please fix the job file manually at .nut/jobs/"+s.id+".md",variant:"destructive"});return}S(s.id);try{const t=await fetch(`${j}/api/v1/jobs/${s.id}/run`,{method:"POST"});if(!t.ok){const r=await t.json().catch(()=>({}));throw new Error(r?.error?.message||`Failed to run job (${t.status})`)}a({title:"Run started",description:`${s.name} is executing.`}),await k(),await o()}catch(t){console.error("Failed to run job:",t),a({title:"Run failed to start",description:t?.message??"Unknown error",variant:"destructive"})}finally{S(null)}},Ge=async s=>{if(s._error){a({title:"Cannot update corrupted job",description:"Please fix the job file manually at .nut/jobs/"+s.id+".md",variant:"destructive"});return}S(s.id);const t=s.status==="active"?"paused":"active";try{const r=await fetch(`${j}/api/v1/jobs/${s.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:t})});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i?.error?.message||`Failed to update job (${r.status})`)}a({title:t==="active"?"Job resumed":"Job paused",description:s.name}),await k(),await o()}catch(r){console.error("Failed to update job status:",r),a({title:"Failed to update job",description:r?.message??"Unknown error",variant:"destructive"})}finally{S(null)}},xe=async s=>{S(s.id);try{const t=await fetch(`${j}/api/v1/jobs/${s.id}`,{method:"DELETE"});if(!t.ok){const r=await t.json().catch(()=>({}));throw new Error(r?.error?.message||`Failed to delete job (${t.status})`)}a({title:"Scheduled job deleted",description:s.name}),c?.id===s.id&&(y(!1),C(null),E()),g?.id===s.id&&(R(!1),M(null)),await k()}catch(t){console.error("Failed to delete job:",t),a({title:"Failed to delete job",description:t?.message??"Unknown error",variant:"destructive"})}finally{S(null)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Schedule"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Automate recurring agent runs with prompts, preferred models, and guardrails."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(u,{variant:"outline",onClick:()=>k(!0),disabled:N||L,children:[L?e.jsx(O,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(us,{className:"mr-2 h-4 w-4"}),"Refresh"]}),e.jsxs(u,{onClick:he,children:[e.jsx(Pe,{className:"mr-2 h-4 w-4"}),"New Scheduled Job"]})]})]}),N?e.jsx(J,{children:e.jsxs(ae,{className:"flex items-center justify-center py-12 text-muted-foreground",children:[e.jsx(O,{className:"mr-2 h-5 w-5 animate-spin"}),"Loading scheduled jobs..."]})}):x.length===0?e.jsx(J,{className:"border-dashed",children:e.jsxs(ae,{className:"flex flex-col items-center justify-center py-16 px-6 text-center",children:[e.jsx("div",{className:"rounded-full bg-muted p-6 mb-6",children:e.jsx(pe,{className:"h-12 w-12 text-muted-foreground"})}),e.jsx(re,{className:"text-2xl mb-3",children:"No scheduled jobs yet"}),e.jsx("p",{className:"text-muted-foreground max-w-md mb-6",children:"Automate recurring tasks by scheduling an agent to run on your behalf. Set up your first job to get started."}),e.jsxs("div",{className:"bg-accent/50 rounded-lg p-6 max-w-lg space-y-3 text-sm text-left",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-6 w-6 rounded-full bg-primary/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("span",{className:"text-xs font-bold text-primary",children:"1"})}),e.jsx("p",{className:"text-muted-foreground",children:"Choose the days of the week and cadence that fit your workflow"})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-6 w-6 rounded-full bg-primary/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("span",{className:"text-xs font-bold text-primary",children:"2"})}),e.jsx("p",{className:"text-muted-foreground",children:"Provide detailed instructions so the agent can execute safely"})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-6 w-6 rounded-full bg-primary/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("span",{className:"text-xs font-bold text-primary",children:"3"})}),e.jsx("p",{className:"text-muted-foreground",children:"All runs are logged under for review"})]})]}),e.jsxs(u,{onClick:he,className:"mt-8",size:"lg",children:[e.jsx(Pe,{className:"mr-2 h-5 w-5"}),"Create Your First Job"]})]})}):e.jsx("div",{className:"grid gap-4",children:x.map(s=>s._error?e.jsx(J,{className:"border-destructive/50 bg-destructive/5",children:e.jsx(Fe,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsxs(re,{className:"text-lg truncate text-destructive",children:["Unable to load job: ",s.id]}),e.jsx(F,{variant:"destructive",className:"text-xs shrink-0",children:"Error"})]}),e.jsx("p",{className:"text-sm text-destructive/80 mt-1",children:s._error}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["Please review the job file at ",e.jsxs("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:[".nut/jobs/",s.id,".md"]})]})]}),e.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:e.jsxs(q,{children:[e.jsx(ge,{asChild:!0,children:e.jsx(u,{size:"sm",variant:"ghost",disabled:w===s.id,className:"h-8 px-2 text-destructive hover:text-destructive hover:bg-destructive/10",children:e.jsx(fe,{className:"h-3.5 w-3.5"})})}),e.jsxs(V,{children:[e.jsxs(Y,{children:[e.jsx(G,{children:"Delete corrupted job?"}),e.jsxs(K,{children:["This will remove the corrupted job file ",e.jsx("strong",{children:s.id}),". This action cannot be undone."]})]}),e.jsxs(Q,{children:[e.jsx(X,{children:"Cancel"}),e.jsx(Z,{onClick:()=>xe(s),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})})]})})},s.id):e.jsxs(J,{className:"group relative overflow-hidden border-border hover:border-primary/50 transition-all hover:shadow-lg",children:[e.jsx(Fe,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsx(re,{className:"text-lg truncate",children:s.name}),e.jsx(F,{variant:le(s.status),className:"capitalize text-xs shrink-0",children:s.status})]}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:s.description||s.prompt||"No description provided"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx(u,{size:"sm",variant:"default",onClick:()=>Ye(s),disabled:w===s.id,className:"h-8 px-3",children:w===s.id?e.jsx(O,{className:"h-3.5 w-3.5 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Me,{className:"mr-1.5 h-3.5 w-3.5"}),"Run"]})}),e.jsx(u,{size:"sm",variant:"outline",onClick:()=>qe(s),disabled:w===s.id,className:"h-8 px-3 text-xs",children:"Edit"}),e.jsx(u,{size:"sm",variant:"outline",onClick:()=>Ge(s),disabled:w===s.id,className:"h-8 px-2",children:s.status==="active"?e.jsx(hs,{className:"h-3.5 w-3.5"}):e.jsx(Me,{className:"h-3.5 w-3.5"})}),e.jsxs(q,{children:[e.jsx(ge,{asChild:!0,children:e.jsx(u,{size:"sm",variant:"ghost",disabled:w===s.id,className:"h-8 px-2 text-destructive hover:text-destructive hover:bg-destructive/10",children:e.jsx(fe,{className:"h-3.5 w-3.5"})})}),e.jsxs(V,{children:[e.jsxs(Y,{children:[e.jsx(G,{children:"Delete scheduled job?"}),e.jsxs(K,{children:["This will remove ",e.jsx("strong",{children:s.name}),". Existing run logs will remain in ",e.jsx("code",{children:".nut/jobs/logs"}),"."]})]}),e.jsxs(Q,{children:[e.jsx(X,{children:"Cancel"}),e.jsx(Z,{onClick:()=>xe(s),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})]})}),e.jsxs(ae,{className:"space-y-3 pt-0",children:[e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-accent/30",children:[e.jsx(xs,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"min-w-0",children:e.jsx("div",{className:"font-semibold truncate",children:gs(s.schedule)})})]}),e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-accent/30",children:[e.jsx(ee,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"font-semibold",children:fs(s.model)})]}),e.jsx("div",{className:"flex items-center gap-2 p-2 rounded-md bg-accent/30",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[10px] text-muted-foreground uppercase font-bold",children:"Next"}),e.jsx("div",{className:"font-semibold truncate",children:H(s.metadata.nextRunAt)})]})}),e.jsx("div",{className:"flex items-center gap-2 p-2 rounded-md bg-accent/30",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[10px] text-muted-foreground uppercase font-bold",children:"Last"}),e.jsx("div",{className:"font-semibold truncate",children:H(s.metadata.lastRunAt)})]})})]}),(s.agentIds&&s.agentIds.length>0||s.agentId||s.mcpServers&&s.mcpServers.length>0)&&e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs",children:[(s.agentIds||(s.agentId?[s.agentId]:[])).map(t=>e.jsxs("div",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md bg-blue-50 dark:bg-blue-950/20 border border-blue-200 dark:border-blue-800",children:[e.jsx(ee,{className:"h-3 w-3 text-blue-600 dark:text-blue-400"}),e.jsx("span",{className:"font-medium text-blue-900 dark:text-blue-100",children:t.replace(".md","")})]},t)),s.mcpServers&&s.mcpServers.length>0&&s.mcpServers.map(t=>e.jsxs("div",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md bg-purple-50 dark:bg-purple-950/20 border border-purple-200 dark:border-purple-800",children:[e.jsx(ve,{className:"h-3 w-3 text-purple-600 dark:text-purple-400"}),e.jsx("span",{className:"font-medium text-purple-900 dark:text-purple-100",children:t})]},t))]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground flex items-center gap-1.5",children:[e.jsx(Ze,{className:"h-3 w-3"}),"Recent Runs"]}),s.runs.length>1&&e.jsxs(u,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>ue(s),children:["View All (",s.runs.length,")",e.jsx(es,{className:"ml-1 h-3 w-3"})]})]}),s.runs.length===0?e.jsx("div",{className:"rounded-md border border-dashed bg-muted/20 p-4 text-center text-xs text-muted-foreground",children:'No runs yet • Click "Run" to execute'}):e.jsxs("div",{className:"space-y-1.5",children:[s.runs.slice(0,1).map(t=>{const r=Le.has(t.id);return e.jsxs("div",{className:"rounded-md border bg-card/50 overflow-hidden transition-all",children:[e.jsxs("div",{className:"p-2.5 text-xs hover:bg-accent/50 transition-colors cursor-pointer",onClick:()=>me(t.id),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsx(F,{variant:le(t.status),className:"capitalize text-[10px] h-5",children:t.status}),e.jsx("span",{className:"text-muted-foreground truncate",children:H(t.startedAt)})]}),t.trigger==="manual"&&e.jsx(F,{variant:"outline",className:"text-[10px] h-5",children:"manual"})]}),t.error&&e.jsx("p",{className:"text-destructive font-medium mt-1 line-clamp-1",children:t.error})]}),t.summary&&e.jsx("div",{className:"px-2.5 pb-2.5",children:e.jsxs("div",{className:"rounded bg-muted/50 p-2 font-mono text-[10px] leading-relaxed text-muted-foreground relative cursor-pointer hover:bg-muted/70 transition-colors",onClick:i=>{i.stopPropagation(),me(t.id)},children:[e.jsx("div",{className:r?"":"line-clamp-2",children:t.summary}),e.jsx("div",{className:"flex justify-center mt-1",children:e.jsx("div",{className:"text-muted-foreground p-0.5",children:r?e.jsx(ss,{className:"h-3 w-3"}):e.jsx(se,{className:"h-3 w-3"})})})]})})]},t.id)}),s.runs.length>1&&e.jsxs(u,{variant:"ghost",size:"sm",className:"w-full h-7 text-xs",onClick:()=>ue(s),children:["+",s.runs.length-1," more runs"]})]})]})]})]},s.id))}),e.jsx(je,{open:P,onOpenChange:s=>{y(s),s||(C(null),E())},children:e.jsxs(Ne,{className:"max-w-4xl h-[700px] overflow-hidden flex flex-col",children:[e.jsxs(be,{className:"space-y-2 pb-4 shrink-0",children:[e.jsxs(ye,{className:"text-xl flex items-center gap-2",children:[e.jsx(pe,{className:"h-5 w-5 text-primary"}),c?"Edit Scheduled Job":"Create New Scheduled Job"]}),e.jsx(we,{className:"text-sm",children:c?"Update the prompt, cadence, or agent preference":"Automate recurring tasks by scheduling an agent"})]}),e.jsxs("form",{onSubmit:Ve,className:"flex flex-col flex-1 min-h-0",children:[e.jsxs(os,{defaultValue:"basics",className:"flex-1 flex flex-col min-h-0",children:[e.jsxs(ms,{className:"grid w-full grid-cols-3 mb-4 shrink-0",children:[e.jsx(ne,{value:"basics",children:"Basics"}),e.jsx(ne,{value:"schedule",children:"Schedule"}),e.jsx(ne,{value:"advanced",children:"Advanced"})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto pr-2 -mr-2 min-h-0",children:[e.jsxs(ie,{value:"basics",className:"space-y-5 mt-0",children:[e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(v,{htmlFor:"job-name",className:"text-sm font-medium flex items-center gap-1.5",children:["Job Name",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(te,{id:"job-name",placeholder:"e.g., Publish docs nightly",value:n.name,onChange:s=>A({name:s.target.value}),className:"h-11",required:!0})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsx(v,{htmlFor:"job-model",className:"text-sm font-medium",children:"AI Model"}),e.jsxs(ts,{value:n.model,onValueChange:s=>A({model:s}),children:[e.jsx(as,{id:"job-model",className:"h-11",children:e.jsx(rs,{placeholder:"Select a model"})}),e.jsx(ns,{children:ce.map(s=>e.jsx(is,{value:s.id,children:s.label},s.id))})]})]})]}),e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(v,{className:"text-sm font-medium flex items-center gap-1.5",children:[e.jsx(ee,{className:"h-4 w-4"}),"Custom Agent",e.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"(optional)"})]}),e.jsxs(Se,{children:[e.jsx(Ce,{asChild:!0,children:e.jsxs(u,{variant:"outline",className:"w-full h-11 justify-between font-normal",children:[n.agentIds.length===0?"No agents selected":`${n.agentIds.length} agent${n.agentIds.length!==1?"s":""} selected`,e.jsx(se,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(ke,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsx(Ae,{children:"Available Agents"}),e.jsx(De,{}),$.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-muted-foreground",children:"No agents configured"}):$.map(s=>e.jsx(Te,{checked:n.agentIds.includes(s.id),onCheckedChange:t=>We(s.id,t),children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:s.name}),s.tools.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["MCP: ",s.tools.join(", ")]})]})},s.id))]})]})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(v,{className:"text-sm font-medium flex items-center gap-1.5",children:[e.jsx(ve,{className:"h-4 w-4"}),"MCP Servers",e.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"(optional)"})]}),e.jsxs(Se,{children:[e.jsx(Ce,{asChild:!0,children:e.jsxs(u,{variant:"outline",className:"w-full h-11 justify-between font-normal",children:[n.mcpServers.length===0?"No MCP servers selected":`${n.mcpServers.length} server${n.mcpServers.length!==1?"s":""} selected`,e.jsx(se,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(ke,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsx(Ae,{children:"Available MCP Servers"}),e.jsx(De,{}),W.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-muted-foreground",children:"No MCP servers configured"}):W.map(s=>e.jsx(Te,{checked:n.mcpServers.includes(s),onCheckedChange:t=>Be(s,t),children:s},s))]})]})]})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(v,{htmlFor:"job-prompt",className:"text-sm font-medium flex items-center gap-1.5",children:[n.agentIds.length>0?"Custom Instructions":"Instructions",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(ls,{id:"job-prompt",placeholder:n.agentIds.length>0?`Additional instructions to supplement the agent's predefined behavior...
2
+ Example: Focus on performance optimizations`:`Example:
3
+ Run the following command and append the output to .nut/context/knowledge/runs.md:
4
+ pnpm docs:publish`,rows:6,value:n.prompt,onChange:s=>A({prompt:s.target.value}),className:"resize-none font-mono text-sm"}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-start gap-1.5",children:[e.jsx("span",{className:"text-amber-600 dark:text-amber-500",children:"⚠"}),e.jsx("span",{children:n.agentIds.length>0?"These custom instructions will be combined with the selected agents' predefined instructions. Jobs run with autonomous permissions.":"Provide clear, actionable instructions. Jobs run with autonomous permissions - include safety checks where needed."})]})]})]}),e.jsx(ie,{value:"schedule",className:"space-y-5 mt-0",children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-[1.2fr_1fr]",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(v,{className:"text-sm font-medium",children:"Days of the Week"}),e.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:ps.map(s=>e.jsxs("label",{className:"flex items-center gap-2.5 text-sm rounded-md border border-input px-3.5 py-2.5 cursor-pointer hover:bg-accent/50 transition-colors",children:[e.jsx(ds,{checked:n.daysOfWeek.has(s.value),onCheckedChange:t=>_e(s.value,t)}),e.jsx("span",{className:"font-medium",children:s.label})]},s.value))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Select which days the job should run"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2.5",children:[e.jsx(v,{htmlFor:"job-hours",className:"text-sm font-medium",children:"Frequency (hours)"}),e.jsxs("div",{className:"relative",children:[e.jsx(te,{id:"job-hours",type:"number",min:1,value:n.hours,onChange:s=>A({hours:Number(s.target.value)||1}),className:"h-11 pr-16"}),e.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground",children:"hours"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"How often the job runs on selected days"})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(v,{htmlFor:"job-anchor",className:"text-sm font-medium flex items-center gap-1.5",children:["Start Hour",e.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"(optional)"})]}),e.jsxs("div",{className:"relative",children:[e.jsx(te,{id:"job-anchor",type:"number",min:0,max:23,placeholder:"Auto",value:n.anchorHour,onChange:s=>A({anchorHour:s.target.value}),className:"h-11"}),e.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground",children:"0-23"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Preferred starting hour in 24h format"})]})]})]})}),e.jsx(ie,{value:"advanced",className:"space-y-5 mt-0",children:e.jsxs("div",{className:"flex items-start gap-4 rounded-lg border border-border bg-accent/20 p-4",children:[e.jsx(cs,{id:"job-status",checked:n.status,onCheckedChange:s=>A({status:s}),className:"mt-1"}),e.jsxs("div",{className:"space-y-1 flex-1",children:[e.jsx(v,{htmlFor:"job-status",className:"text-base font-semibold cursor-pointer",children:n.status?"Start Active":"Start Paused"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n.status?"Job will begin running on the configured schedule immediately after creation.":"Job will be created in a paused state. You can activate it later from the schedule page."})]})]})})]})]}),e.jsxs(Ie,{className:"gap-2 sm:gap-2 pt-4 border-t mt-4",children:[e.jsx(u,{type:"button",variant:"outline",onClick:()=>y(!1),disabled:z,className:"min-w-24",children:"Cancel"}),e.jsx(u,{type:"submit",disabled:z||!n.name.trim()||!n.prompt.trim(),className:"min-w-32",children:z?e.jsxs(e.Fragment,{children:[e.jsx(O,{className:"mr-2 h-4 w-4 animate-spin"}),c?"Saving...":"Creating..."]}):e.jsx(e.Fragment,{children:c?"Save Changes":"Create Job"})})]})]})]})}),e.jsx(je,{open:Oe,onOpenChange:s=>{R(s),s||M(null)},children:e.jsxs(Ne,{className:"max-w-3xl",children:[e.jsxs(be,{children:[e.jsxs(ye,{children:["Run history — ",g?.name]}),e.jsxs(we,{children:[g?.runs?.length??0," recorded runs. Logs stored in ",e.jsxs("code",{children:[".nut/jobs/",g?.id,".md"]})," and ",e.jsxs("code",{children:[".nut/jobs/logs/",g?.id]}),"."]})]}),e.jsxs("div",{className:"max-h-[420px] space-y-3 overflow-y-auto pr-2",children:[g?.runs.map(s=>e.jsxs("div",{className:"rounded-md border border-border overflow-hidden",children:[e.jsxs("div",{className:"p-3 text-xs bg-card/50",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[e.jsx(F,{variant:le(s.status),className:"capitalize text-[10px] h-5",children:s.status}),e.jsxs("span",{className:"text-muted-foreground",children:[s.trigger," • ",Ee(s.startedAt)]}),s.finishedAt&&e.jsxs("span",{className:"text-muted-foreground",children:["• completed ",H(s.finishedAt)]})]}),s.error&&e.jsx("p",{className:"text-destructive font-medium mb-2",children:s.error}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-[10px] text-muted-foreground",children:[s.outputPath&&e.jsxs("span",{children:["log: ",e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded",children:s.outputPath})]}),s.cliCommand&&e.jsxs("span",{children:["cmd: ",e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded",children:s.cliCommand})]})]})]}),s.summary&&e.jsx("div",{className:"px-3 pb-3",children:e.jsx("div",{className:"rounded bg-muted/50 p-2 font-mono text-[10px] leading-relaxed text-muted-foreground whitespace-pre-wrap",children:s.summary})})]},s.id)),g&&g.runs.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"No recorded runs yet."})]}),e.jsx(Ie,{children:e.jsx(u,{variant:"outline",onClick:()=>R(!1),children:"Close"})})]})}),e.jsx(q,{open:B.open,onOpenChange:s=>{s||U({open:!1,serverToRemove:null})},children:e.jsxs(V,{children:[e.jsxs(Y,{children:[e.jsx(G,{children:"Remove MCP Server?"}),e.jsxs(K,{children:["One or more selected agents require the ",e.jsx("strong",{children:B.serverToRemove})," MCP server. Removing it may lead to unexpected consequences when the job runs."]})]}),e.jsxs(Q,{children:[e.jsx(X,{children:"Cancel"}),e.jsx(Z,{onClick:Ue,children:"OK"})]})]})})]})}export{Is as default};
@@ -0,0 +1 @@
1
+ import{r as p,j as t,I as d,B as m,X as x}from"./index-BSBM4i_g.js";import{B as f}from"./badge-DO6e5hC1.js";function j({tags:a,onChange:r,disabled:n,placeholder:o}){const[l,s]=p.useState(""),c=()=>{const e=l.trim();if(e){if(a.includes(e)){s("");return}r([...a,e]),s("")}},i=e=>{r(a.filter(u=>u!==e))};return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx(d,{placeholder:o||"Add a tag",value:l,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key==="Enter"&&(e.preventDefault(),c())},disabled:n}),t.jsx(m,{type:"button",variant:"outline",onClick:c,disabled:n,children:"Add"})]}),a.length>0&&t.jsx("div",{className:"flex flex-wrap gap-2",children:a.map(e=>t.jsxs(f,{variant:"secondary",className:"flex items-center gap-1",children:[e,t.jsx("button",{type:"button",onClick:()=>i(e),className:"ml-1 hover:text-destructive",disabled:n,"aria-label":`Remove tag ${e}`,children:t.jsx(x,{className:"h-3 w-3"})})]},e))})]})}export{j as T};
@@ -0,0 +1 @@
1
+ import{u as U,H as J,r as i,j as e,B as r,a3 as S,q as K,s as L,X as q,n as H,a4 as G}from"./index-BSBM4i_g.js";import{C as f,a as W}from"./card-Cnz8b7Ou.js";import{u as X}from"./use-terminal-CN3pheMp.js";import{C as _,a as Q,T as V}from"./terminal-preview-B7iP2vUT.js";import{R as Y}from"./refresh-cw-DvFNtws1.js";import{P as M}from"./play-DsDsjO2V.js";import{C as Z}from"./circle-play-TJEfmKde.js";import"./xterm-DTxiCjtJ.js";function oe(){const m=U(),{sessions:p,loading:o,error:k,refreshSessions:h,createSession:j,destroySession:B}=X(),{toast:l}=J(),[x,u]=i.useState(""),[g,I]=i.useState(!1),[v,T]=i.useState(!1),[N,$]=i.useState([]),[,w]=i.useState(null),O=s=>{const t=Date.now(),a=new Date(s).getTime(),n=Math.max(0,Math.floor((t-a)/1e3));if(n<60)return`${n}s ago`;const b=Math.floor(n/60);if(b<60)return`${b}m ago`;const C=Math.floor(b/60);return C<24?`${C}h ago`:`${Math.floor(C/24)}d ago`};i.useEffect(()=>{h()},[h]),i.useEffect(()=>{y(s=>{const t={...s};return p.forEach(a=>{a.id in t||(t[a.id]=!0)}),t})},[p]),i.useEffect(()=>{try{const s=localStorage.getItem("terminal.commandHistory");s&&$(JSON.parse(s))}catch{}},[]);const D=s=>{s&&($(t=>{const a=[s,...t.filter(n=>n!==s)].slice(0,5);try{localStorage.setItem("terminal.commandHistory",JSON.stringify(a))}catch{}return a}),w(null))},c=p.filter(s=>!s.proposalId?.startsWith("cp-")).sort((s,t)=>new Date(t.lastActivity).getTime()-new Date(s.lastActivity).getTime()),[d,y]=i.useState(()=>{const s={};return p.forEach(t=>{s[t.id]=!0}),s}),R=async()=>{const s=`session-${Date.now()}`;await j(s,!1)&&(l({title:"New terminal started",description:`${s}`}),m(`/terminal/${s}`))},E=async()=>{const s=x.trim();if(!s)return;const t=`session-${Date.now()}`;I(!0);try{await j(t,!1,s)?(D(s),l({title:"Session started",description:`${t}`}),m(`/terminal/${t}`)):l({title:"Failed to start",description:"See error above",variant:"destructive"})}finally{I(!1)}},A=async()=>{const s=x.trim();if(!s)return;const t=`session-${Date.now()}`;T(!0);try{await j(t,!1,s)?(D(s),setTimeout(()=>h(),150),u(""),l({title:"Started in background",description:`${t}`,action:e.jsx(G,{altText:"Open session",onClick:()=>m(`/terminal/${t}`),children:"Open"})})):l({title:"Failed to start",description:"See error above",variant:"destructive"})}finally{T(!1)}},P=async s=>{await B(s)?(l({title:"Session closed",description:s}),setTimeout(()=>h(),100)):l({title:"Failed to close session",description:s,variant:"destructive"})},F=()=>{const s=c.every(a=>d[a.id]),t={};c.forEach(a=>{t[a.id]=!s}),y(t)},z=c.length>0&&c.every(s=>d[s.id]);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Terminal"}),e.jsx("p",{className:"text-muted-foreground hidden sm:block",children:"Manage terminal sessions"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(r,{variant:"outline",onClick:()=>h(),disabled:o,children:[e.jsx(Y,{className:`h-4 w-4 sm:mr-2 ${o?"animate-spin":""}`}),e.jsx("span",{className:"hidden sm:inline",children:"Refresh"})]}),c.length>0&&e.jsx(r,{variant:"outline",onClick:F,children:z?e.jsxs(e.Fragment,{children:[e.jsx(_,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Hide All"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Q,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Show All"})]})}),e.jsxs(r,{onClick:R,disabled:o,children:[e.jsx(S,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"New Terminal"})]})]})]}),k&&e.jsx("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsx("div",{className:"text-red-600",children:k})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Sessions"}),o?e.jsx("div",{className:"space-y-2",children:[...Array(2)].map((s,t)=>e.jsx(f,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-4 w-4 rounded bg-muted animate-pulse"}),e.jsxs("div",{children:[e.jsx("div",{className:"h-4 w-40 bg-muted rounded animate-pulse mb-2"}),e.jsx("div",{className:"h-3 w-24 bg-muted rounded animate-pulse"})]})]}),e.jsx("div",{className:"h-6 w-20 bg-muted rounded animate-pulse"})]})},t))}):c.length===0?e.jsx(f,{className:"p-8",children:e.jsxs("div",{className:"flex flex-col items-center justify-center text-center space-y-3",children:[e.jsx(S,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"No active sessions"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Get started by launching a new terminal session with the"," ",e.jsx("button",{onClick:R,className:"text-primary hover:underline font-medium",children:"New Terminal"})," ","button above."]})]})]})}):e.jsx("div",{className:"space-y-2",children:c.slice(0,10).map(s=>e.jsxs(f,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(S,{className:"h-4 w-4"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:s.proposalId}),e.jsxs("div",{className:"text-xs text-gray-500",children:["Session ",s.id.split("-").slice(-1)[0].substring(0,8)," • Last activity ",O(s.lastActivity)]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 sm:gap-2",children:[e.jsx("div",{className:`flex items-center gap-1 ${s.connected?"text-green-600":"text-gray-400"}`,title:s.connected?"Connected":"Disconnected",children:e.jsx("div",{className:`w-2 h-2 rounded-full ${s.connected?"bg-green-500":"bg-gray-400"}`})}),e.jsx(r,{size:"sm",variant:"outline",onClick:()=>{y(t=>({...t,[s.id]:!t[s.id]}))},"aria-label":d[s.id]?"Hide preview":"Show preview",title:d[s.id]?"Hide preview":"Show preview",children:d[s.id]?e.jsx(K,{className:"h-4 w-4"}):e.jsx(L,{className:"h-4 w-4"})}),e.jsxs(r,{size:"sm",variant:"outline",onClick:()=>m(`/terminal/${s.proposalId}`),children:[e.jsx(M,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Open"})]}),e.jsx(r,{size:"icon",variant:"destructive",onClick:()=>P(s.id),title:"Close session","aria-label":"Close session",children:e.jsx(q,{className:"h-4 w-4"})})]})]}),d[s.id]&&e.jsx("div",{className:"mt-2 w-full p-2 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>m(`/terminal/${s.proposalId}`),title:"Click to open full terminal session",children:e.jsx(V,{sessionId:s.id,heightPx:160,maxScrollback:200})})]},s.id))})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Run Custom Command"}),e.jsx(f,{children:e.jsxs(W,{className:"py-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{value:x,onChange:s=>u(s.target.value),onKeyDown:s=>{s.key==="Enter"?(s.preventDefault(),s.shiftKey?A():E()):s.key==="ArrowUp"?(s.preventDefault(),w(t=>{const a=t===null?0:Math.min((t??0)+1,N.length-1),n=N[a];return n&&u(n),a})):s.key==="ArrowDown"&&(s.preventDefault(),w(t=>{if(t===null)return null;const a=t-1;if(a<0)return u(""),null;const n=N[a];return n&&u(n),a}))},placeholder:"npm run dev",className:"flex-1 h-9 rounded-md border px-3 text-sm bg-white dark:bg-gray-900 border-gray-300 dark:border-gray-700 text-gray-900 dark:text-gray-100 placeholder-gray-500 dark:placeholder-gray-400"}),e.jsxs(r,{onClick:A,variant:"secondary",disabled:o||!x.trim()||v||g,children:[v?e.jsx(H,{className:"h-4 w-4 animate-spin sm:mr-1"}):e.jsx(Z,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Background"})]}),e.jsxs(r,{onClick:E,disabled:o||!x.trim()||g||v,children:[g?e.jsx(H,{className:"h-4 w-4 animate-spin sm:mr-2"}):e.jsx(M,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Run"})]})]}),e.jsx("div",{className:"text-xs text-muted-foreground mt-2",children:"Enter to Run • Shift+Enter to Run in background"})]})})]})]})}export{oe as default};
@@ -0,0 +1,13 @@
1
+ import{c as Ge,j as e,B as C,a5 as Ee,a6 as Le,a7 as Pe,a8 as We,a9 as Me,aa as Ze,p as oe,r as n,ab as Ye,E as Ke,l as Xe,u as Qe,H as et,k as ue,a3 as je,ac as Be,v as ye,w as ve,x as we,y as Ne,z as H,X as Oe,ad as tt,i as _e,h as Ie,s as ke,D as rt,a as st,b as nt,d as at,ae as ze,A as ce}from"./index-BSBM4i_g.js";import{C as it,a as ot}from"./card-Cnz8b7Ou.js";import{B as De}from"./badge-DO6e5hC1.js";import{R as ct,a as Ce}from"./radio-group-D_RD_9vY.js";import{C as lt}from"./CollapsibleSection-msxUBh1L.js";import{L as he}from"./label-vEgNxdb2.js";import{u as dt}from"./use-terminal-CN3pheMp.js";import{x as mt,a as ut}from"./xterm-DTxiCjtJ.js";import{A as ht}from"./arrow-down-D1dapxzl.js";import{b as Fe,a as xt,c as gt,d as ft}from"./droid-CmYuCN_q.js";import{R as pt}from"./refresh-cw-DvFNtws1.js";import{P as Se}from"./play-DsDsjO2V.js";import{P as Ae}from"./plus-BfBtnncn.js";import{Z as bt}from"./zap-BMkP_c9R.js";/**
2
+ * @license lucide-react v0.542.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const jt=[["path",{d:"M10 2v8l3-3 3 3V2",key:"sqw3rj"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]],yt=Ge("book-marked",jt);/**
7
+ * @license lucide-react v0.542.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const vt=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],Ue=Ge("message-square",vt);var Te={exports:{}},Je;function wt(){return Je||(Je=1,(function(r,E){(function(R,j){r.exports=j()})(self,(()=>(()=>{var R={6:(d,w)=>{function x(c){try{const i=new URL(c),o=i.password&&i.username?`${i.protocol}//${i.username}:${i.password}@${i.host}`:i.username?`${i.protocol}//${i.username}@${i.host}`:`${i.protocol}//${i.host}`;return c.toLocaleLowerCase().startsWith(o.toLocaleLowerCase())}catch{return!1}}Object.defineProperty(w,"__esModule",{value:!0}),w.LinkComputer=w.WebLinkProvider=void 0,w.WebLinkProvider=class{constructor(c,i,o,u={}){this._terminal=c,this._regex=i,this._handler=o,this._options=u}provideLinks(c,i){const o=S.computeLink(c,this._regex,this._terminal,this._handler);i(this._addCallbacks(o))}_addCallbacks(c){return c.map((i=>(i.leave=this._options.leave,i.hover=(o,u)=>{if(this._options.hover){const{range:f}=i;this._options.hover(o,u,f)}},i)))}};class S{static computeLink(i,o,u,f){const J=new RegExp(o.source,(o.flags||"")+"g"),[h,m]=S._getWindowedLineStrings(i-1,u),A=h.join("");let N;const L=[];for(;N=J.exec(A);){const W=N[0];if(!x(W))continue;const[D,k]=S._mapStrIdx(u,m,0,N.index),[K,V]=S._mapStrIdx(u,D,k,W.length);if(D===-1||k===-1||K===-1||V===-1)continue;const B={start:{x:k+1,y:D+1},end:{x:V,y:K+1}};L.push({range:B,text:W,activate:f})}return L}static _getWindowedLineStrings(i,o){let u,f=i,J=i,h=0,m="";const A=[];if(u=o.buffer.active.getLine(i)){const N=u.translateToString(!0);if(u.isWrapped&&N[0]!==" "){for(h=0;(u=o.buffer.active.getLine(--f))&&h<2048&&(m=u.translateToString(!0),h+=m.length,A.push(m),u.isWrapped&&m.indexOf(" ")===-1););A.reverse()}for(A.push(N),h=0;(u=o.buffer.active.getLine(++J))&&u.isWrapped&&h<2048&&(m=u.translateToString(!0),h+=m.length,A.push(m),m.indexOf(" ")===-1););}return[A,f]}static _mapStrIdx(i,o,u,f){const J=i.buffer.active,h=J.getNullCell();let m=u;for(;f;){const A=J.getLine(o);if(!A)return[-1,-1];for(let N=m;N<A.length;++N){A.getCell(N,h);const L=h.getChars();if(h.getWidth()&&(f-=L.length||1,N===A.length-1&&L==="")){const W=J.getLine(o+1);W&&W.isWrapped&&(W.getCell(0,h),h.getWidth()===2&&(f+=1))}if(f<0)return[o,N]}o++,m=0}return[o,m]}}w.LinkComputer=S}},j={};function y(d){var w=j[d];if(w!==void 0)return w.exports;var x=j[d]={exports:{}};return R[d](x,x.exports,y),x.exports}var v={};return(()=>{var d=v;Object.defineProperty(d,"__esModule",{value:!0}),d.WebLinksAddon=void 0;const w=y(6),x=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function S(c,i){const o=window.open();if(o){try{o.opener=null}catch{}o.location.href=i}else console.warn("Opening link blocked as opener could not be cleared")}d.WebLinksAddon=class{constructor(c=S,i={}){this._handler=c,this._options=i}activate(c){this._terminal=c;const i=this._options,o=i.urlRegex||x;this._linkProvider=this._terminal.registerLinkProvider(new w.WebLinkProvider(this._terminal,o,this._handler,i))}dispose(){this._linkProvider?.dispose()}}})(),v})()))})(Te)),Te.exports}var Nt=wt();const kt=[{label:"Save to knowledge base",command:"Save this to the knowledge base (.nut/context/knowledge/) using the following schema as reference .nut/.schema/knowledge.schema.md",description:"Save content to knowledge base with schema reference"},{label:"Update project document",command:"Update the project document (.nut/context/project.md) using the following schema as reference .nut/.schema/project.schema.md",description:"Update project.md using schema reference"},{label:"Update architecture document",command:"Update the architecture document (.nut/context/architecture.md) using the following schema as reference .nut/.schema/architecture.schema.md",description:"Update architecture.md using schema reference"}];function Ct({onJumpToBottom:r,onSnippet:E,onSendKey:R}){return e.jsxs("div",{className:"w-full border-t border-gray-700/50 bg-[#252525] px-4 py-2.5 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[r&&e.jsxs(C,{variant:"outline",size:"sm",onClick:r,className:"h-8 text-xs bg-[#2d2d2d] border-gray-600 hover:bg-[#3d3d3d] text-gray-200 hover:text-white transition-colors",title:"Jump to bottom and set focus",children:[e.jsx(ht,{className:"h-3.5 w-3.5 sm:mr-1.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Jump to Bottom"})]}),E&&e.jsxs(Ee,{children:[e.jsx(Le,{asChild:!0,children:e.jsxs(C,{variant:"outline",size:"sm",className:"h-8 text-xs bg-[#2d2d2d] border-gray-600 hover:bg-[#3d3d3d] text-gray-200 hover:text-white transition-colors",children:[e.jsx(yt,{className:"h-3.5 w-3.5 sm:mr-1.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Snippets"})]})}),e.jsxs(Pe,{align:"start",className:"w-72",children:[e.jsx(We,{children:"Command Snippets"}),e.jsx(Me,{}),kt.map((j,y)=>e.jsxs(Ze,{onClick:()=>E(j.command),className:"cursor-pointer flex flex-col items-start py-2",children:[e.jsx("span",{className:"font-medium",children:j.label}),e.jsx("span",{className:"text-xs text-muted-foreground font-mono mt-0.5",children:j.command})]},y))]})]})]}),R&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{onClick:()=>R(""),className:"h-8 px-2 flex items-center gap-1 rounded-md bg-[#2d2d2d] border border-gray-600 hover:bg-red-900/40 hover:border-red-700 text-gray-200 hover:text-red-300 transition-colors",title:"Send Ctrl+C (interrupt)",children:[e.jsx(oe,{className:"bg-gray-700/50 border-gray-600 text-gray-300",children:"⌃"}),e.jsx(oe,{className:"bg-gray-700/50 border-gray-600 text-gray-300",children:"C"})]}),e.jsxs("button",{onClick:()=>R(""),className:"h-8 px-2 flex items-center gap-1 rounded-md bg-[#2d2d2d] border border-gray-600 hover:bg-[#3d3d3d] hover:border-gray-500 text-gray-200 hover:text-white transition-colors",title:"Send Ctrl+Z (suspend)",children:[e.jsx(oe,{className:"bg-gray-700/50 border-gray-600 text-gray-300",children:"⌃"}),e.jsx(oe,{className:"bg-gray-700/50 border-gray-600 text-gray-300",children:"Z"})]}),e.jsx("button",{onClick:()=>R("\x1B"),className:"h-8 px-2 flex items-center gap-1 rounded-md bg-[#2d2d2d] border border-gray-600 hover:bg-[#3d3d3d] hover:border-gray-500 text-gray-200 hover:text-white transition-colors",title:"Send Escape key",children:e.jsx(oe,{className:"bg-gray-700/50 border-gray-600 text-gray-300",children:"Esc"})})]})]})}function St({sessionId:r,onResize:E,onDestroy:R,pendingCommand:j,onCommandExecuted:y,showToolbar:v=!0,onSnippet:d}){const w=n.useRef(null),x=n.useRef(null),S=n.useRef(null),c=n.useRef(null),[i,o]=n.useState(!1),[u,f]=n.useState(null),[J,h]=n.useState(!0),m=n.useRef(0),A=5,N=n.useRef(null),L=n.useRef(null),W=n.useRef(j??null),D=n.useRef(!1),k=n.useRef(null),K=n.useRef(y),V=n.useRef(R),B=n.useRef(E);n.useEffect(()=>{K.current=y},[y]),n.useEffect(()=>{V.current=R},[R]),n.useEffect(()=>{B.current=E},[E]);const X=n.useCallback(P=>{!W.current||D.current||(k.current!==null&&window.clearTimeout(k.current),k.current=window.setTimeout(()=>{if(!W.current||D.current){k.current=null;return}c.current?.readyState===WebSocket.OPEN&&(c.current.send(JSON.stringify({type:"input",data:W.current+"\r"})),D.current=!0,K.current?.()),k.current=null},P))},[]);n.useEffect(()=>{if(W.current=j??null,D.current=!1,!W.current){k.current!==null&&(window.clearTimeout(k.current),k.current=null);return}const P=c.current?.readyState===WebSocket.OPEN;return X(P?200:800),()=>{k.current!==null&&(window.clearTimeout(k.current),k.current=null)}},[j,r,X]),n.useEffect(()=>{o(!1),h(!0),f(null)},[r]),n.useEffect(()=>{if(!w.current||!r)return;const P=g=>{const b=g.getBoundingClientRect();return b.width>0&&b.height>0},p=new mt.Terminal({cursorBlink:!0,fontSize:14,fontFamily:'Monaco, Menlo, "Ubuntu Mono", monospace',convertEol:!0,theme:{background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#ffffff",selectionBackground:"#264f78",black:"#000000",red:"#cd3131",green:"#0dbc79",yellow:"#e5e510",blue:"#2472c8",magenta:"#bc3fbc",cyan:"#11a8cd",white:"#e5e5e5",brightBlack:"#666666",brightRed:"#f14c4c",brightGreen:"#23d18b",brightYellow:"#f5f543",brightBlue:"#3b8eea",brightMagenta:"#d670d6",brightCyan:"#29b8db",brightWhite:"#e5e5e5"}}),re=new ut.FitAddon,M=new Nt.WebLinksAddon;p.loadAddon(re),p.loadAddon(M),p.open(w.current),x.current=p,S.current=re;let _=null,F=null;const le=()=>{if(!p||!p.element||!p.element.parentElement)return;const g=p.cols??0,b=p.rows??0;if(g>0&&b>0){c.current?.readyState===WebSocket.OPEN&&c.current.send(JSON.stringify({type:"resize",cols:g,rows:b}));const $=B.current;$&&$(g,b)}},I=()=>{const g=w.current;if(g&&P(g)&&!(!p||!p.element||!p.element.parentElement))try{const b=g.getBoundingClientRect();if(b.width<10||b.height<10)return;re.fit(),le()}catch(b){console.warn("xterm fit() failed, will retry if needed:",b)}},Z=()=>{_&&cancelAnimationFrame(_),_=requestAnimationFrame(()=>{I()})},ee=()=>{if(!r)return;N.current&&(window.clearTimeout(N.current),N.current=null);const g=`${Ye}/ws/terminal/${r}`,b=new WebSocket(g);return c.current=b,b.onopen=()=>{o(!0),f(null),m.current=0,console.log("Terminal WebSocket connected"),L.current&&window.clearInterval(L.current),L.current=window.setInterval(()=>{b.readyState===WebSocket.OPEN&&b.send(JSON.stringify({type:"keepalive"}))},120*1e3),Z(),setTimeout(()=>{h(!1),Z(),setTimeout(()=>Z(),50),setTimeout(()=>Z(),150)},400),X(1200)},b.onmessage=$=>{try{const z=JSON.parse($.data);switch(z.type){case"snapshot":if(typeof z.data=="string"&&z.data.length&&x.current){const T=x.current;T.write(z.data,()=>{T.scrollToBottom()})}break;case"data":if(x.current){const T=x.current,fe=T.buffer.active.viewportY+T.rows>=T.buffer.active.baseY+T.buffer.active.cursorY;T.write(z.data,()=>{fe&&T.scrollToBottom()})}break;case"exit":x.current&&x.current.write(`\r
12
+ \x1B[31mProcess exited with code ${z.exitCode}\x1B[0m\r
13
+ `),V.current?.();break}}catch(z){console.error("Error parsing WebSocket message:",z)}},b.onclose=$=>{if(o(!1),console.log("Terminal WebSocket disconnected",$.code,$.reason),L.current&&(window.clearInterval(L.current),L.current=null),$.code!==1e3&&m.current<A&&r){m.current++;const z=Math.min(1e3*Math.pow(2,m.current-1),1e4);console.log(`Attempting to reconnect (${m.current}/${A}) in ${z}ms`),N.current=window.setTimeout(()=>{ee()},z)}else m.current>=A&&f("Connection lost. Please refresh the page to reconnect.")},b.onerror=$=>{console.error("Terminal WebSocket error:",$),m.current===0&&f("WebSocket connection failed")},b};ee(),p.onData(g=>{c.current?.readyState===WebSocket.OPEN&&c.current.send(JSON.stringify({type:"input",data:g}))});const Q=()=>{Z()},ge=new ResizeObserver(Q);w.current&&ge.observe(w.current),window.addEventListener("resize",Q),window.addEventListener("orientationchange",Q);const de=()=>{document.visibilityState==="visible"&&(F&&clearTimeout(F),F=window.setTimeout(()=>{Z()},50))};document.addEventListener("visibilitychange",de);let se=0;const me=20,ne=()=>{const g=w.current;if(g){if(P(g)){I();return}se+=1,se<me?_=requestAnimationFrame(ne):F=window.setTimeout(()=>{I()},100)}};return _=requestAnimationFrame(ne),()=>{ge.disconnect(),window.removeEventListener("resize",Q),window.removeEventListener("orientationchange",Q),document.removeEventListener("visibilitychange",de),_&&cancelAnimationFrame(_),F&&clearTimeout(F),N.current&&(window.clearTimeout(N.current),N.current=null),L.current&&(window.clearInterval(L.current),L.current=null),c.current?.readyState===WebSocket.OPEN&&c.current.close(),k.current!==null&&(window.clearTimeout(k.current),k.current=null),p.dispose()}},[r,X]);const q=n.useCallback(()=>{x.current&&(x.current.scrollToBottom(),x.current.focus())},[]),xe=n.useCallback(P=>{c.current?.readyState===WebSocket.OPEN&&(c.current.send(JSON.stringify({type:"input",data:P})),x.current&&x.current.focus())},[]),O=n.useCallback(P=>{c.current?.readyState===WebSocket.OPEN&&(c.current.send(JSON.stringify({type:"input",data:P})),x.current&&x.current.focus())},[]);return u?e.jsx("div",{className:"flex items-center justify-center h-full bg-red-50 border border-red-200 rounded-lg",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-red-600 font-medium",children:"Terminal Connection Error"}),e.jsx("div",{className:"text-red-500 text-sm mt-1",children:u})]})}):e.jsxs("div",{className:"relative h-full flex flex-col bg-[#1e1e1e] overflow-hidden",children:[!i&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-[#1e1e1e] bg-opacity-95 z-10 backdrop-blur-sm",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500 mx-auto"}),e.jsx("div",{className:"text-gray-300 mt-2",children:"Connecting to terminal..."})]})}),i&&J&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-[#1e1e1e] bg-opacity-50 z-10 transition-opacity duration-300 backdrop-blur-sm",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-pulse rounded-full h-6 w-6 bg-blue-500 mx-auto"}),e.jsx("div",{className:"text-gray-300 text-sm mt-2",children:"Loading terminal..."})]})}),e.jsx("div",{ref:w,className:"flex-1 w-full overflow-hidden",style:{minHeight:"400px"}}),v&&e.jsx(Ct,{onJumpToBottom:q,onSnippet:d||xe,onSendKey:O})]})}const At=r=>r?Array.isArray(r)?r.filter(E=>typeof E=="string").map(E=>E.trim()).filter(Boolean):typeof r=="string"?r.split(",").map(E=>E.trim()).filter(Boolean):[]:[];function Ut(){const{proposalId:r}=Ke(),E=Xe(),R=Qe(),{toast:j}=et(),y=r?.startsWith("session-"),v=n.useMemo(()=>!!r&&r.startsWith("cp-"),[r]),d=n.useMemo(()=>!!r&&r.startsWith("ag-"),[r]),w=n.useMemo(()=>d&&r?r.replace("ag-","")+".md":null,[d,r]),{sessions:x,loading:S,error:c,createSession:i,destroySession:o,refreshSessions:u}=dt(),[f,J]=n.useState([]),[h,m]=n.useState(null),[A,N]=n.useState(!1),[L,W]=n.useState(null),[D,k]=n.useState("claude"),[K,V]=n.useState(!1),[B,X]=n.useState("claude"),[q,xe]=n.useState([]),[O,P]=n.useState([]),[p,re]=n.useState([]),[M,_]=n.useState([]),[F,le]=n.useState(!1),[I,Z]=n.useState(""),[ee,Q]=n.useState(!1),[ge,de]=n.useState({}),[se,me]=n.useState(null),ne=n.useRef([]),[g,b]=n.useState("current"),[$,z]=n.useState("main"),T=n.useMemo(()=>r?`terminal.cp.config.${r}`:null,[r]);n.useEffect(()=>{if(!(!v&&!d||!T))try{const t=localStorage.getItem(T);if(t){const s=JSON.parse(t);s.cliAgent&&X(s.cliAgent),Array.isArray(s.selectedMcpServers)&&P(s.selectedMcpServers),Array.isArray(s.selectedAgentIds)&&_(s.selectedAgentIds),typeof s.automationEnabled=="boolean"&&le(s.automationEnabled),typeof s.customInstruction=="string"&&Z(s.customInstruction),typeof s.createWorktree=="boolean"&&Q(s.createWorktree),s.branchMode&&b(s.branchMode)}}catch{console.error("Failed to load config",T)}},[v,d,T]);const fe=n.useCallback(()=>{if(!T)return;const t={cliAgent:B,selectedMcpServers:O,selectedAgentIds:M,automationEnabled:F,customInstruction:I,createWorktree:ee,branchMode:g};try{localStorage.setItem(T,JSON.stringify(t))}catch{console.error("Failed to persist config",T)}},[T,B,O,M,F,I,ee,g]),te=t=>`feat/cp-${t.startsWith("cp-")?t.slice(3):t}`,Ve=async t=>{try{const s=te(t),l=await(await fetch(`${ce}/api/v1/git/branches`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s,from:$})})).json();if(!l.success){const U=l.error?.message||"Unknown error";return j({title:"Branch creation failed",description:U,variant:"destructive"}),!1}return j({title:"Branch created",description:`Created branch: ${s}`}),!0}catch{return j({title:"Branch creation failed",description:"Network error or invalid response",variant:"destructive"}),!1}},Re=async t=>{try{const s=te(t),l=await(await fetch(`${ce}/api/v1/git/worktrees`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:s,from:$})})).json();if(!l.success){const U=l.error?.message||"Unknown error";return j({title:"Worktree creation failed",description:U,variant:"destructive"}),!1}return j({title:"Worktree created",description:`Created branch: ${s}`}),!0}catch{return j({title:"Worktree creation failed",description:"Network error or invalid response",variant:"destructive"}),!1}};n.useEffect(()=>{(v||d)&&r&&(async()=>{try{const s=await fetch(`${ce}/api/v1/git/status`);if(s.ok){const l=await s.json();l?.success&&l.data?.branch&&z(l.data.branch)}const a=await fetch(`${ce}/api/v1/mcp`);if(a.ok){const l=await a.json();l?.success&&Array.isArray(l.servers)&&(xe(l.servers),P(U=>U.filter(G=>l.servers.includes(G))),l.mcpServers&&typeof l.mcpServers=="object"&&de(l.mcpServers))}}catch(s){console.error("Failed to load MCP servers",s)}try{const s=await fetch(`${ce}/api/v1/agents`);if(s.ok){const a=await s.json(),U=(Array.isArray(a?.documents)?a.documents:[]).map(G=>({id:G.filename,name:G?.metadata?.name||G.title||G.filename,tools:At(G?.metadata?.tools)}));re(U),_(G=>{const ie=G.filter(Y=>U.some(be=>be.id===Y));if(d&&w&&ie.length===0){const Y=U.find(be=>be.id===w);if(Y)return[Y.id]}return ie})}}catch(s){console.error("Failed to load agents",s)}})()},[v,d,r,w]),n.useEffect(()=>{const t=ne.current,s=M.filter(a=>!t.includes(a));s.length>0&&P(a=>{const l=new Set(a),U=q.length>0?new Set(q):void 0;return s.forEach(G=>{const ie=p.find(Y=>Y.id===G);ie&&ie.tools.forEach(Y=>{(!U||U.has(Y))&&l.add(Y)})}),Array.from(l)}),ne.current=M},[M,p,q]),n.useEffect(()=>{r&&u(r)},[r,u]),n.useEffect(()=>{if(!r)return;const s=x.filter(a=>a.proposalId===r).map(a=>a.id);J(s),!h&&s.length>0&&m(s[0]),h&&!s.includes(h)&&m(s.length>0?s[0]:null)},[x,r,h]);const ae=async t=>{if(!r)return;const s=t||void 0,a=await i(r,A,s);a&&(m(a),!s&&t&&W(t),setTimeout(()=>u(r),100))},qe=t=>{const a={proposalId:r,contextType:v?"change-proposal":d?"agent":"general",selectedMcpServers:O,selectedAgentIds:M,automationEnabled:F,customInstruction:I};switch(t){case"claude":return Fe(a);case"gemini":return ft(a);case"codex":return gt(a);case"droid":return xt(a);default:return Fe(a)}},pe=async()=>{v&&r&&(g==="new-branch"?await Ve(r)||console.warn("Branch creation failed, continuing with terminal creation"):g==="new-worktree"&&(await Re(r)||console.warn("Worktree creation failed, continuing with terminal creation"))),v&&ee&&g==="current"&&r&&(await Re(r)||console.warn("Worktree creation failed, continuing with terminal creation"));const s=qe(v||d?B:D);await ae(s)},$e=async t=>{if(await o(t)&&h===t){const a=f.filter(l=>l!==t);m(a.length>0?a[0]:null)}},He=t=>{$e(t)};return r?e.jsxs("div",{className:"flex flex-col h-full",children:[y&&f.length===0&&r&&e.jsx(Tt,{proposalId:r,onStart:ae,locationSearch:E.search}),e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 bg-gray-100 dark:bg-gray-800 rounded-lg",children:v||d?e.jsx(ue,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"}):e.jsx(je,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold text-gray-900 dark:text-gray-100",children:y?"Terminal":"Coding Agent Session"}),!y&&e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 font-mono",children:r}),y&&e.jsxs("span",{className:"text-sm text-gray-500 font-mono",children:["(",r,")"]})]})]})}),e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[e.jsxs("div",{className:"hidden sm:flex items-center space-x-2 px-3 py-2 bg-gray-50 dark:bg-gray-800 rounded-lg border",children:[e.jsx(Be,{id:"enable-logging",checked:A,onCheckedChange:t=>N(t===!0)}),e.jsx("label",{htmlFor:"enable-logging",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Log sessions"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>r&&u(r),disabled:S,className:"bg-white dark:bg-gray-800",children:[e.jsx(pt,{className:`h-4 w-4 sm:mr-2 ${S?"animate-spin":""}`}),e.jsx("span",{className:"hidden sm:inline",children:"Refresh"})]}),!y&&!v&&!d&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(ye,{value:D,onValueChange:k,children:[e.jsx(ve,{className:"w-24",children:e.jsx(we,{})}),e.jsxs(Ne,{children:[e.jsx(H,{value:"claude",children:"Claude Code"}),e.jsx(H,{value:"gemini",children:"Google Gemini"}),e.jsx(H,{value:"codex",children:"OpenAI Codex"})]})]}),e.jsxs(C,{onClick:pe,disabled:S,size:"sm",variant:"default",className:"bg-green-600 hover:bg-green-700",children:[e.jsx(Se,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Start Coding"})]})]}),!v&&!d&&(!y||f.length===0)&&e.jsxs(C,{onClick:()=>ae(),disabled:S,size:"sm",children:[e.jsx(Ae,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"New Terminal"})]})]})]})]}),c&&e.jsx("div",{className:"mb-6 p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-xl",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-1.5 bg-red-100 dark:bg-red-900/40 rounded-lg flex-shrink-0",children:e.jsx(Oe,{className:"h-4 w-4 text-red-600 dark:text-red-400"})}),e.jsx("div",{className:"text-red-800 dark:text-red-200 text-sm font-medium",children:c})]})}),f.length>0&&e.jsx("div",{className:"flex items-center gap-1 border-b dark:border-gray-700",children:f.map(t=>{const s=x.find(l=>l.id===t),a=h===t;return e.jsxs("div",{className:`flex items-center gap-2 px-4 py-3 border-b-1 cursor-pointer rounded-t-lg transition-all duration-200 ${a?"border-gray-400 bg-white dark:bg-gray-800 dark:border-gray-500 shadow-sm":"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800 hover:border-gray-300"}`,onClick:()=>m(t),children:[e.jsx("div",{className:`p-1.5 rounded-md ${a?"bg-gray-200 dark:bg-gray-700":"bg-gray-100 dark:bg-gray-700"}`,children:e.jsx(je,{className:`h-3.5 w-3.5 ${a?"text-gray-700 dark:text-gray-300":"text-gray-600 dark:text-gray-400"}`})}),e.jsxs("span",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:["Terminal ",t.split("-").slice(-1)[0].substring(0,6)]}),e.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${s?.connected?"bg-green-500":"bg-gray-400"}`}),e.jsx(C,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-red-100 dark:hover:bg-red-900/30 rounded-md opacity-60 hover:opacity-100 transition-opacity",onClick:l=>{l.stopPropagation(),$e(t)},children:e.jsx(Oe,{className:"h-3 w-3"})})]},t)})}),e.jsx("div",{className:"flex-1 min-h-0",children:f.length===0?e.jsx(it,{className:"h-full border-0 shadow-lg",children:e.jsx(ot,{className:"flex items-center justify-center h-full p-8",children:e.jsxs("div",{className:"text-center w-full max-w-[33vw] min-w-[400px]",children:[e.jsx("div",{className:"p-2 bg-gray-100 dark:bg-gray-800 rounded-full w-fit mx-auto mb-2",children:v||d?e.jsx(ue,{className:"h-8 w-8 text-gray-600 dark:text-gray-400"}):e.jsx(je,{className:"h-8 w-8 text-gray-600 dark:text-gray-400"})}),e.jsx("h3",{className:"text-xl font-semibold text-gray-900 dark:text-gray-100 mb-3",children:"Prepare Coding Agent"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6 leading-relaxed",children:y?"Create a new terminal session":`Configure the agent to start working on ${r}.`}),e.jsxs("div",{className:"flex flex-col items-center gap-6",children:[!y&&!v&&!d&&e.jsxs("div",{className:"flex flex-col items-center gap-4 p-6 border border-gray-200 dark:border-gray-700 rounded-xl shadow-sm bg-gradient-to-br from-white to-gray-50 dark:from-gray-800 dark:to-gray-900 w-full",children:[e.jsxs("div",{className:"w-full space-y-3",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Choose your AI agent"}),e.jsxs(ye,{value:D,onValueChange:k,children:[e.jsx(ve,{className:"w-full h-11 bg-white dark:bg-gray-800",children:e.jsx(we,{})}),e.jsxs(Ne,{children:[e.jsx(H,{value:"claude",children:"Claude Code (default)"}),e.jsx(H,{value:"gemini",children:"Google Gemini"}),e.jsx(H,{value:"codex",children:"OpenAI Codex"})]})]})]}),e.jsxs(C,{onClick:pe,disabled:S,className:"bg-green-600 hover:bg-green-700 w-full h-11 text-base font-medium",size:"lg",children:[e.jsx(Se,{className:"h-5 w-5 mr-2"}),"Start Coding"]}),e.jsxs("div",{className:"flex items-center gap-3 w-full",children:[e.jsx("div",{className:"flex-1 h-px bg-gray-300 dark:bg-gray-600"}),e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400 font-medium",children:"or"}),e.jsx("div",{className:"flex-1 h-px bg-gray-300 dark:bg-gray-600"})]}),e.jsxs(C,{onClick:()=>ae(),disabled:S,variant:"outline",className:"w-full h-11 bg-white dark:bg-gray-800",size:"lg",children:[e.jsx(Ae,{className:"h-5 w-5 mr-2"}),"New Terminal"]})]}),!y&&(v||d)&&e.jsxs("div",{className:"flex flex-col items-center gap-4 p-6 border border-gray-200 dark:border-gray-700 rounded-xl shadow-sm bg-gradient-to-br from-white to-gray-50 dark:from-gray-800 dark:to-gray-900 w-full",children:[e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsxs(C,{variant:"outline",onClick:()=>V(!0),className:"flex-1 h-11 bg-white dark:bg-gray-800",size:"lg",children:[e.jsx(tt,{className:"h-5 w-5 mr-2"}),"Configure"]}),e.jsxs(C,{onClick:pe,disabled:S,className:"flex-1 bg-green-600 hover:bg-green-700 h-11 text-base font-medium",size:"lg",children:[e.jsx(Se,{className:"h-5 w-5 mr-2"}),"Start Coding"]})]}),e.jsxs("div",{className:"w-full space-y-3",children:[e.jsx("div",{className:"text-xs uppercase font-semibold text-gray-500 dark:text-gray-400",children:"Current Configuration"}),e.jsxs("div",{className:"text-left text-sm text-gray-700 dark:text-gray-300 bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ue,{className:"h-3.5 w-3.5 text-gray-500 dark:text-gray-400"}),e.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-400",children:"Coding Agent:"}),e.jsx("span",{className:"font-mono text-sm",children:B==="claude"?"Claude Code":B.charAt(0).toUpperCase()+B.slice(1)})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(_e,{className:"h-3.5 w-3.5 text-gray-500 dark:text-gray-400 mt-0.5"}),e.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-400",children:"Custom Agents:"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:M.length?M.map(t=>{const s=p.find(a=>a.id===t);return e.jsx(De,{variant:"secondary",className:"font-mono text-xs",children:s?.name||t},t)}):e.jsx("span",{className:"font-mono text-sm text-gray-500",children:"None"})})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ie,{className:"h-3.5 w-3.5 text-gray-500 dark:text-gray-400 mt-0.5"}),e.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-400",children:"MCP Servers:"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:O.length?O.map(t=>e.jsx(De,{variant:"secondary",className:"font-mono text-xs",children:t},t)):e.jsx("span",{className:"font-mono text-sm text-gray-500",children:"None"})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(bt,{className:"h-3.5 w-3.5 text-gray-500 dark:text-gray-400"}),e.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-400",children:"Automation:"}),e.jsx("span",{className:"font-mono text-sm",children:F?"Enabled":"Disabled"})]}),v&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ke,{className:"h-3.5 w-3.5 text-gray-500 dark:text-gray-400"}),e.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-400",children:"Branch:"}),e.jsx("span",{className:"font-mono text-sm",children:g==="current"?`Current (${$})`:g==="new-branch"?`New branch (${te(r||"")})`:`New worktree (${te(r||"")})`})]})]}),I&&e.jsxs("div",{className:"text-left text-sm bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:[e.jsxs("div",{className:"font-medium text-blue-700 dark:text-blue-300 mb-1 flex items-center gap-2",children:[e.jsx(Ue,{className:"h-3.5 w-3.5"}),"Custom Instructions"]}),e.jsx("div",{className:"text-gray-700 dark:text-gray-300 font-mono",children:I})]})]})]}),y&&f.length===0&&e.jsx("div",{className:"p-6 border border-gray-200 dark:border-gray-700 rounded-xl shadow-sm bg-gradient-to-br from-white to-gray-50 dark:from-gray-800 dark:to-gray-900 w-full",children:e.jsxs(C,{onClick:()=>ae(),disabled:S,className:"w-full h-11 text-base font-medium",size:"lg",children:[e.jsx(Ae,{className:"h-5 w-5 mr-2"}),"New Terminal"]})})]})]})})}):h?e.jsx("div",{className:"h-full overflow-hidden rounded-b-lg",children:e.jsx(St,{sessionId:h,onDestroy:()=>He(h),pendingCommand:L,onCommandExecuted:()=>W(null),showToolbar:!0})}):null}),e.jsx(rt,{open:K,onOpenChange:V,children:e.jsxs(st,{className:"max-w-3xl max-h-[85vh] overflow-y-auto",children:[e.jsxs(nt,{children:[e.jsx(at,{children:"Configure Coding Agent"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"Customize the coding agent's capabilities and configure it's environment."})]}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(ue,{className:"h-4 w-4"}),"Coding Agent"]}),e.jsxs(ye,{value:B,onValueChange:t=>X(t),children:[e.jsx(ve,{className:"w-full",children:e.jsx(we,{placeholder:"Select coding agent"})}),e.jsxs(Ne,{children:[e.jsx(H,{value:"claude",children:"Claude Code"}),e.jsx(H,{value:"gemini",children:"Google Gemini"}),e.jsx(H,{value:"codex",children:"OpenAI Codex"}),e.jsx(H,{value:"droid",children:"Factory Droid"})]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(_e,{className:"h-4 w-4"}),"Custom Agents"]}),e.jsxs("div",{className:"text-xs text-gray-500",children:[M.length," of ",p.length," selected"]})]}),e.jsxs(Ee,{children:[e.jsx(Le,{asChild:!0,children:e.jsxs(C,{variant:"outline",className:"w-full justify-between",children:[M.length===0?"Select agents...":M.length===p.length?"All agents selected":`${M.length} agent${M.length!==1?"s":""} selected`,e.jsx(ke,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(Pe,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsxs(We,{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Available Agents"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(C,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:t=>{t.preventDefault(),_(p.map(s=>s.id))},children:"All"}),e.jsx(C,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:t=>{t.preventDefault(),_([])},children:"None"})]})]}),e.jsx(Me,{}),p.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-gray-500",children:"No agents found"}):p.map(t=>e.jsx(ze,{checked:M.includes(t.id),onCheckedChange:s=>{_(a=>s?a.includes(t.id)?a:[...a,t.id]:a.filter(l=>l!==t.id))},children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:t.name}),t.tools.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["MCP servers: ",t.tools.join(", ")]}),t.tools.length===0&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Inherits available MCP servers"})]})},t.id))]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Ie,{className:"h-4 w-4"}),"MCP Servers"]}),e.jsxs("div",{className:"text-xs text-gray-500",children:[O.length," of ",q.length," selected"]})]}),e.jsxs(Ee,{children:[e.jsx(Le,{asChild:!0,children:e.jsxs(C,{variant:"outline",className:"w-full justify-between",children:[O.length===0?"Select MCP servers...":O.length===q.length?"All servers selected":`${O.length} server${O.length!==1?"s":""} selected`,e.jsx(ke,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(Pe,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsxs(We,{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Available Servers"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(C,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:t=>{t.preventDefault(),P(q)},children:"All"}),e.jsx(C,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:t=>{t.preventDefault(),P([])},children:"None"})]})]}),e.jsx(Me,{}),q.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-gray-500",children:"No MCP servers found"}):q.map(t=>e.jsx(ze,{checked:O.includes(t),onCheckedChange:s=>{P(a=>s?a.includes(t)?a:[...a,t]:a.filter(l=>l!==t))},children:t},t))]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Ue,{className:"h-4 w-4"}),"Additional instructions"]}),e.jsxs("div",{className:"text-xs text-gray-500",children:[I.length,"/500"]})]}),e.jsx("textarea",{className:"w-full min-h-[80px] rounded-md border p-3 text-sm bg-gray-50 dark:bg-gray-900/50 border-gray-300 dark:border-gray-700 text-gray-900 dark:text-gray-100 placeholder-gray-500 dark:placeholder-gray-400 resize-none",placeholder:"Add specific instructions to guide the coding agent...",value:I,onChange:t=>Z(t.target.value),rows:3}),I.length>500&&e.jsx("div",{className:"text-xs text-red-600 mt-1",children:"Custom instruction is too long (max 500 characters)"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-3 p-3 border rounded-md bg-amber-50/50 dark:bg-amber-900/20 border-amber-200 dark:border-amber-800",children:[e.jsx(Be,{id:"automation",checked:F,onCheckedChange:t=>le(t===!0),className:"data-[state=checked]:bg-red-600 data-[state=checked]:border-red-600 data-[state=checked]:text-white border-red-400",disabled:B==="droid"}),e.jsx("label",{htmlFor:"automation",className:"text-sm font-medium text-red-600 dark:text-red-400 cursor-pointer",children:"Full environment access (recommended in containers only)"})]}),B==="droid"&&e.jsxs("p",{className:"text-xs text-muted-foreground px-1",children:[e.jsx("span",{className:"font-medium",children:"Droid:"})," Automation level is set in the REPL. Press ",e.jsx("kbd",{className:"px-1.5 py-0.5 bg-muted rounded text-[10px] font-mono",children:"shift+tab"})," to cycle through Off → Low → Medium → High."]})]}),v&&e.jsx(lt,{title:"Advanced Settings",description:"Configure branch and worktree options",defaultOpen:!1,children:e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(he,{className:"text-sm font-medium mb-3 block",children:"Branch Management"}),e.jsxs(ct,{value:g,onValueChange:t=>b(t),children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ce,{value:"current",id:"branch-current"}),e.jsxs(he,{htmlFor:"branch-current",className:"cursor-pointer font-normal",children:["Stay on current branch (",e.jsx("code",{className:"text-xs font-mono bg-muted px-1 py-0.5 rounded",children:$}),")"]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ce,{value:"new-branch",id:"branch-new"}),e.jsxs(he,{htmlFor:"branch-new",className:"cursor-pointer font-normal",children:["Create new branch: ",e.jsx("code",{className:"text-xs font-mono bg-muted px-1 py-0.5 rounded",children:te(r||"")})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ce,{value:"new-worktree",id:"branch-worktree"}),e.jsxs(he,{htmlFor:"branch-worktree",className:"cursor-pointer font-normal",children:["Create new worktree: ",e.jsx("code",{className:"text-xs font-mono bg-muted px-1 py-0.5 rounded",children:te(r||"")})]})]})]})]})})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(C,{variant:"outline",onClick:()=>V(!1),children:"Close"}),e.jsx(C,{onClick:()=>{if(I.length>500){me("Please shorten the custom instruction to 500 characters.");return}me(null),fe(),V(!1)},children:"Save"})]}),se&&e.jsx("div",{className:"text-xs text-red-600 text-right",children:se})]})]})})]}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-red-600 font-medium",children:"Invalid Proposal ID"}),e.jsx(C,{onClick:()=>R("/proposals"),className:"mt-4",children:"Back to Proposals"})]})})}function Tt({proposalId:r,onStart:E,locationSearch:R}){return n.useEffect(()=>{if(!r)return;const j=new URLSearchParams(R);if(!j.has("autostart"))return;const y=`terminal.autostart.${r}`;if(sessionStorage.getItem(y)==="done")return;sessionStorage.setItem(y,"done");const d=j.get("run")||void 0;E(d||void 0)},[r]),null}export{Ut as default};
@@ -0,0 +1 @@
1
+ import{r as n,H as k,aU as N,A as g,j as e,a1 as P,v as h,w as u,x as m,y as f,z as a,I as b,B as y}from"./index-BSBM4i_g.js";import{C as w,b as F,c as T,d as L,a as D}from"./card-Cnz8b7Ou.js";import{L as o}from"./label-vEgNxdb2.js";const r={theme:"coconut",defaultEditor:"cursor",terminalShell:"bash",autoSaveInterval:60,notifications:{email:!1,desktop:!1,slack:!1}};function U(s){return{theme:s?.theme??r.theme,defaultEditor:s?.defaultEditor??r.defaultEditor,terminalShell:s?.terminalShell??r.terminalShell,autoSaveInterval:s?.autoSaveInterval??r.autoSaveInterval,notifications:{email:s?.notifications?.email??r.notifications.email,desktop:s?.notifications?.desktop??r.notifications.desktop,slack:s?.notifications?.slack??r.notifications.slack}}}function B(){const[s,v]=n.useState(r),[C,E]=n.useState(!0),[c,x]=n.useState(!1),{toast:d}=k(),{theme:j,setTheme:p}=N();n.useEffect(()=>{S()},[]),n.useEffect(()=>{s.theme!==j&&p(s.theme)},[s.theme,j,p]);const S=async()=>{try{const l=await(await fetch(`${g}/api/v1/user/settings`)).json();l.success&&v(U(l.data.preferences))}catch(t){console.error("Failed to load preferences:",t),d({title:"Error",description:"Failed to load user preferences",variant:"destructive"})}finally{E(!1)}},I=async()=>{x(!0);try{const l=await(await fetch(`${g}/api/v1/user/settings`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({preferences:s})})).json();if(l.success)d({title:"Preferences saved",description:"Your personal preferences have been updated."});else throw new Error(l.error)}catch(t){console.error("Failed to save preferences:",t),d({title:"Error",description:"Failed to save preferences",variant:"destructive"})}finally{x(!1)}},i=t=>{v(l=>({...l,...t,notifications:{...l.notifications,...t.notifications}}))};return C?e.jsx("div",{children:"Loading..."}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"User Preferences"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure defaults for editors, shells, themes, and notifications."})]}),e.jsx(P,{}),e.jsxs(w,{children:[e.jsxs(F,{children:[e.jsx(T,{children:"Workspace Defaults"}),e.jsx(L,{children:"Set the defaults Coconut uses when creating sessions and surfaces."})]}),e.jsxs(D,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"theme",children:"Theme"}),e.jsxs(h,{value:s.theme,onValueChange:t=>i({theme:t}),children:[e.jsx(u,{id:"theme",children:e.jsx(m,{placeholder:"Select theme"})}),e.jsxs(f,{children:[e.jsx(a,{value:"coconut",children:"Coconut"}),e.jsx(a,{value:"system",children:"System"}),e.jsx(a,{value:"light",children:"Light"}),e.jsx(a,{value:"dark",children:"Dark"})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"System follows your OS preference. Coconut is the default branded theme."})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"defaultEditor",children:"Default Editor"}),e.jsxs(h,{value:s.defaultEditor,onValueChange:t=>i({defaultEditor:t}),children:[e.jsx(u,{id:"defaultEditor",children:e.jsx(m,{placeholder:"Select editor"})}),e.jsxs(f,{children:[e.jsx(a,{value:"cursor",children:"Cursor"}),e.jsx(a,{value:"vscode",children:"VS Code"}),e.jsx(a,{value:"vim",children:"Vim"}),e.jsx(a,{value:"emacs",children:"Emacs"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"terminalShell",children:"Preferred Shell"}),e.jsxs(h,{value:s.terminalShell,onValueChange:t=>i({terminalShell:t}),children:[e.jsx(u,{id:"terminalShell",children:e.jsx(m,{placeholder:"Select shell"})}),e.jsxs(f,{children:[e.jsx(a,{value:"bash",children:"Bash"}),e.jsx(a,{value:"zsh",children:"Zsh"}),e.jsx(a,{value:"fish",children:"Fish"}),e.jsx(a,{value:"sh",children:"sh"}),e.jsx(a,{value:"system",children:"System Default"})]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"autoSaveInterval",children:"Auto-save Interval (seconds)"}),e.jsx(b,{id:"autoSaveInterval",type:"number",min:10,max:600,value:s.autoSaveInterval,onChange:t=>i({autoSaveInterval:Number.parseInt(t.target.value,10)||r.autoSaveInterval})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Controls how often Coconut persists draft work to disk."})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(y,{variant:"outline",onClick:S,disabled:c,children:"Reset"}),e.jsx(y,{onClick:I,disabled:c,children:c?"Saving...":"Save Preferences"})]})]})}export{B as default};
@@ -0,0 +1 @@
1
+ import{r as a,H as I,A as S,j as e,a1 as D,B as g,I as p,v as F,w as P,x as z,y as L,z as A,L as R}from"./index-BSBM4i_g.js";import{C as q,b as T,c as M,d as O,a as U}from"./card-Cnz8b7Ou.js";import{L as c}from"./label-vEgNxdb2.js";import{C as B,a as H}from"./clipboard-BTZru8wn.js";const m=[{id:"software-engineer",title:"Software Engineer",description:"Builds, refactors, and reviews high-quality code across stacks. Excellent at translating specs into implementation and optimizing system performance. Strong at debugging, architecture patterns, and accelerating development velocity."},{id:"product-strategist",title:"Product Strategist",description:"Defines product direction, clarifies requirements, and aligns work with user and business goals. Skilled in roadmap planning, prioritization, and transforming ambiguous ideas into actionable plans."},{id:"researcher",title:"Researcher",description:"Investigates topics deeply, synthesizes information, and produces evidence-based insights. Strong at literature review, competitive analysis, and generating clear summaries to inform decisions."},{id:"designer",title:"Designer",description:"Creates intuitive interfaces, user flows, and visual assets. Focused on usability, accessibility, and crafting polished experiences. Strong at wireframing and turning requirements into elegant solutions."},{id:"qa-engineer",title:"QA Engineer",description:"Identifies bugs, edge cases, and reliability gaps. Produces test plans, automated tests, and reproducible reports. Strong at ensuring product quality and preventing regressions."},{id:"devops-engineer",title:"DevOps Engineer",description:"Manages infrastructure, deployments, and operational reliability. Skilled with CI/CD, observability, automation, and environment provisioning. Ensures systems are scalable and fault-tolerant."},{id:"data-analyst",title:"Data Analyst",description:"Analyzes data, defines metrics, and generates actionable insights. Strong in SQL, visualization, experimentation, and turning raw data into strategic recommendations."},{id:"marketer",title:"Marketer",description:"Creates campaigns, messaging, and positioning to reach target audiences. Skilled in content, funnels, and brand strategy. Strong at synthesizing market needs and shaping demand."},{id:"sales-partnerships-agent",title:"Sales & Partnerships Agent",description:"Identifies prospects, crafts outreach, and develops strategic relationships. Strong at value articulation, objection handling, and mapping product capabilities to customer needs."},{id:"growth-operator",title:"Growth Operator",description:"Optimizes acquisition, activation, and retention through experimentation. Skilled in funnel analysis, rapid testing, and leveraging data for compounding growth."},{id:"customer-success-specialist",title:"Customer Success Specialist",description:"Ensures users succeed by providing onboarding, guidance, and proactive support. Strong at diagnosing user challenges and improving long-term satisfaction and retention."},{id:"orchestration-engineer",title:"Orchestration Engineer",description:"Coordinates multi-agent workflows, dependencies, and handoffs. Strong at breaking large tasks into sequenced steps and ensuring agents operate cohesively and efficiently."},{id:"context-curator",title:"Context Curator",description:"Maintains clean, accurate project context by organizing files, logs, and knowledge. Strong at eliminating ambiguity, ensuring agents have the right information at the right time."},{id:"documentation-writer",title:"Documentation Writer",description:"Produces clear technical docs, guides, READMEs, and CP summaries. Strong at structuring complex information and keeping knowledge bases up to date and accessible."}];function G(){const[n,h]=a.useState({}),[r,d]=a.useState(null),[f,x]=a.useState(!1),[b,N]=a.useState(!0),[u,v]=a.useState(!1),{toast:o}=I();a.useEffect(()=>{j()},[]);const j=async()=>{try{try{const t=await fetch(`${S}/api/v1/config`),s=await t.json();if(t.ok&&s?.success){const i=s.data?.coconut||{};d(i.id??null),(i.firstName||i.lastName||i.email||i.role||i.roleDescription)&&h({firstName:i.firstName,lastName:i.lastName,email:i.email,role:i.role,roleDescription:i.roleDescription})}else d(null)}catch(t){console.error("Failed to load coconut config:",t),d(null)}}catch(t){console.error("Failed to load settings:",t),o({title:"Error",description:"Failed to load user settings",variant:"destructive"})}finally{N(!1)}},w=async()=>{v(!0);try{const s=await(await fetch(`${S}/api/v1/config`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({coconut:{...n,id:r||void 0}})})).json();if(s.success)o({title:"Success",description:"Settings saved successfully"});else throw new Error(s.error||"Failed to save settings")}catch(t){console.error("Failed to save settings:",t),o({title:"Error",description:"Failed to save settings",variant:"destructive"})}finally{v(!1)}},l=t=>{h(s=>{const i={...s,...t};if(t.role!==void 0){const C=m.find(E=>E.id===t.role);C?.description&&(i.roleDescription=C.description)}return i})},y=a.useMemo(()=>n.role&&m.find(s=>s.id===n.role)?.description||null,[n.role]),k=async()=>{if(r)try{await navigator.clipboard.writeText(r),x(!0),o({title:"Copied",description:"Coconut ID copied to clipboard."}),setTimeout(()=>x(!1),1500)}catch(t){console.error("Failed to copy coconut ID:",t),o({title:"Copy failed",description:"Unable to copy the Coconut ID to the clipboard.",variant:"destructive"})}};return b?e.jsx("div",{children:"Loading..."}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"Coconut Settings"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage the Coconut's profile information."})]}),e.jsx(D,{}),e.jsx("div",{className:"rounded-lg border border-dashed bg-muted/40 p-4",children:r?e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("h4",{className:"text-sm font-medium text-muted-foreground",children:"Coconut ID"}),e.jsx("p",{className:"mt-1 font-mono text-sm",children:r})]}),e.jsxs(g,{variant:"outline",size:"sm",onClick:k,children:[f?e.jsx(B,{className:"h-4 w-4"}):e.jsx(H,{className:"h-4 w-4"}),e.jsx("span",{className:"ml-2",children:f?"Copied":"Copy"})]})]}):e.jsxs("div",{className:"space-y-1",children:[e.jsx("h4",{className:"text-sm font-medium text-muted-foreground",children:"Coconut ID not configured"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Add an `id` under the `coconut` section in `.nut/config.json` to register this Coconut instance."})]})}),e.jsxs(q,{children:[e.jsxs(T,{children:[e.jsx(M,{children:"Coconut Profile"}),e.jsx(O,{children:"Update the Coconut's identifying details and role."})]}),e.jsxs(U,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(c,{htmlFor:"firstName",children:"First Name"}),e.jsx(p,{id:"firstName",value:n.firstName||"",onChange:t=>l({firstName:t.target.value}),placeholder:"Enter first name"})]}),e.jsxs("div",{children:[e.jsx(c,{htmlFor:"lastName",children:"Last Name"}),e.jsx(p,{id:"lastName",value:n.lastName||"",onChange:t=>l({lastName:t.target.value}),placeholder:"Enter last name"})]})]}),e.jsxs("div",{children:[e.jsx(c,{htmlFor:"email",children:"Email"}),e.jsx(p,{id:"email",type:"email",value:n.email||"",onChange:t=>l({email:t.target.value}),placeholder:"Enter email address"})]}),e.jsxs("div",{children:[e.jsx(c,{htmlFor:"role",children:"Role"}),e.jsxs(F,{value:n.role,onValueChange:t=>l({role:t}),children:[e.jsx(P,{children:e.jsx(z,{placeholder:"Select role"})}),e.jsx(L,{children:m.map(t=>e.jsx(A,{value:t.id,children:t.title},t.id))})]}),y&&e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:y})]})]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["You can also manage the Coconut's identity to other agents on the"," ",e.jsx(R,{to:"/identity",className:"underline underline-offset-4 hover:text-primary",children:"Identity page"}),"."]}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(g,{variant:"outline",onClick:j,disabled:u,children:"Cancel"}),e.jsx(g,{onClick:w,disabled:u,children:u?"Saving...":"Save Changes"})]})]})}export{G as default};
@@ -0,0 +1 @@
1
+ import{u as k,H as w,r as n,j as e,B as g,af as b,L as C,A as S,a4 as I}from"./index-BSBM4i_g.js";import{C as R,a as B}from"./card-Cnz8b7Ou.js";import{u as Q}from"./use-terminal-CN3pheMp.js";import{C as $}from"./circle-play-TJEfmKde.js";import{P as O}from"./play-DsDsjO2V.js";function L(){const o=k(),{loading:l,createSession:d,refreshSessions:j}=Q(),{toast:i}=w(),[m,u]=n.useState(!1),[x,h]=n.useState(!1),[,f]=n.useState([]),[c,y]=n.useState({});n.useEffect(()=>{try{const t=localStorage.getItem("terminal.commandHistory");t&&f(JSON.parse(t))}catch{}},[]),n.useEffect(()=>{(async()=>{try{const s=await fetch(`${S}/api/v1/context/architecture`);if(!s.ok)return;const a=await s.json();a?.success&&a?.document?.metadata?.commands&&y(a.document.metadata.commands)}catch{}})()},[]);const p=t=>{t&&f(s=>{const a=[t,...s.filter(r=>r!==t)].slice(0,5);try{localStorage.setItem("terminal.commandHistory",JSON.stringify(a))}catch{}return a})},N=async t=>{const s=(t||"").trim();if(!s)return;const a=`session-${Date.now()}`;u(!0);try{await d(a,!1,s)?(p(s),i({title:"Session started",description:`${a}`}),o(`/terminal/${a}`)):i({title:"Failed to start",description:"See error above",variant:"destructive"})}finally{u(!1)}},v=async t=>{const s=(t||"").trim();if(!s)return;const a=`session-${Date.now()}`;h(!0);try{await d(a,!1,s)?(p(s),setTimeout(()=>j(),150),i({title:"Started in background",description:`${a}`,action:e.jsx(I,{altText:"Open session",onClick:()=>o(`/terminal/${a}`),children:"Open"})})):i({title:"Failed to start",description:"See error above",variant:"destructive"})}finally{h(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Utilities"}),e.jsx("p",{className:"text-muted-foreground",children:"Quick commands and shortcuts"})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Quick Commands"}),e.jsx(R,{children:e.jsx(B,{className:"pt-6",children:c&&Object.keys(c).length>0?e.jsx("div",{className:"space-y-2",children:e.jsx("div",{className:"rounded-md border divide-y",children:Object.entries(c).map(([t,s])=>e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 p-2",children:[e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col sm:flex-row sm:items-center gap-1 sm:gap-2",children:[e.jsx("span",{className:"text-sm font-medium truncate",children:t}),e.jsx("span",{className:"text-muted-foreground hidden sm:inline",children:":"}),e.jsx("span",{className:"truncate max-w-full",children:e.jsx("code",{className:"bg-muted px-2 py-0.5 rounded text-xs",children:s})})]}),e.jsxs("div",{className:"flex items-center gap-1 sm:gap-2 flex-shrink-0",children:[e.jsxs(g,{onClick:()=>v(s),variant:"secondary",size:"sm",disabled:l||x||m,title:"Run in background",children:[e.jsx($,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Background"})]}),e.jsxs(g,{onClick:()=>N(s),size:"sm",disabled:l||m||x,title:"Run",children:[e.jsx(O,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Run"})]})]})]},t))})}):e.jsxs("div",{className:"flex flex-col items-center justify-center text-center space-y-3 py-8",children:[e.jsx(b,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"No quick commands configured"}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-md leading-relaxed",children:"Quick commands let you run common tasks with one click, like starting your development server or running build scripts."}),e.jsxs("p",{className:"text-sm text-muted-foreground max-w-md mt-2",children:["Set them up in the"," ",e.jsx(C,{to:"/context/architecture/edit",className:"text-primary hover:underline font-medium",children:"Quick Commands section"}),"."]})]})]})})})]})]})}export{L as default};
@@ -0,0 +1 @@
1
+ import{r,j as a,f as o}from"./index-BSBM4i_g.js";const v=r.forwardRef(({className:e,variant:t="default",...s},d)=>{const l="relative w-full rounded-lg border px-4 py-3 text-sm [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",i=t==="destructive"?"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive":"bg-background text-foreground";return a.jsx("div",{ref:d,role:"alert",className:o(l,i,e),...s})});v.displayName="Alert";const c=r.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:o("text-sm [&_p]:leading-relaxed",e),...t}));c.displayName="AlertDescription";export{v as A,c as a};
@@ -0,0 +1,6 @@
1
+ import{c as o}from"./index-BSBM4i_g.js";/**
2
+ * @license lucide-react v0.542.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const e=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],c=o("arrow-down",e);export{c as A};
@@ -0,0 +1,6 @@
1
+ import{c as o}from"./index-BSBM4i_g.js";/**
2
+ * @license lucide-react v0.542.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const e=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],r=o("arrow-left",e);export{r as A};
@@ -0,0 +1,6 @@
1
+ import{c as o}from"./index-BSBM4i_g.js";/**
2
+ * @license lucide-react v0.542.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const r=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],c=o("arrow-up",r);export{c as A};
@@ -0,0 +1 @@
1
+ import{j as o,f as n,bb as a}from"./index-BSBM4i_g.js";const s=a("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function i({className:r,variant:e,...t}){return o.jsx("div",{className:n(s({variant:e}),r),...t})}export{i as B};
@@ -0,0 +1,6 @@
1
+ import{c as J,r,j as e,D as W,a as Y,b as z,d as K,I as Q,n as A,S as V,f as X,$ as Z,B as R}from"./index-BSBM4i_g.js";import{B as y}from"./badge-DO6e5hC1.js";import{S as O}from"./search-kcgmZUqQ.js";/**
2
+ * @license lucide-react v0.542.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const ee=[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]],oe=J("library",ee),te="https://registry.coconut.dev";async function B(a){const n=a.startsWith("http")?a:`${te}${a}`,i=await fetch(n,{headers:{Accept:"application/json","User-Agent":"coconut-frontend"}});if(!i.ok)throw new Error(`Failed to fetch registry resource: ${i.status}`);return i.json()}async function se(a){const n=`/registry/${a}/root.json`;return B(n)}async function ce(a){return B(a)}const re="Browse Registry",ae="Import";function de({open:a,categoryId:n,onOpenChange:i,title:F=re,confirmLabel:M=ae,filterTags:d,onConfirm:I,getDetail:_,renderPreview:$}){const[u,v]=r.useState([]),[U,N]=r.useState(!1),[w,S]=r.useState(null),[o,E]=r.useState(null),[x,b]=r.useState({}),[T,g]=r.useState(!1),[L,j]=r.useState(null),[f,C]=r.useState(""),[p,k]=r.useState(!1);r.useEffect(()=>{if(!a)return;N(!0),S(null),E(null),j(null),g(!1),b({}),C("");const t=Array.isArray(n)?n:[n];Promise.all(t.map(s=>se(s))).then(s=>{const l=s.flatMap(h=>h.elements??[]);v(l)}).catch(s=>{console.error("Failed to load registry category",s),v([]),S("Failed to load registry entries")}).finally(()=>N(!1))},[a,n]);const D=r.useMemo(()=>{let t=u;if(d&&d.length>0&&(t=t.filter(l=>{const h=l.tags??[];return d.some(G=>h.some(H=>H.toLowerCase()===G.toLowerCase()))})),!f.trim())return t;const s=f.trim().toLowerCase();return t.filter(l=>[l.name,l.description,l.preview,...l.tags??[]].filter(Boolean).join(" ").toLowerCase().includes(s))},[u,f,d]),c=r.useMemo(()=>o?u.find(t=>t.id===o)??null:null,[u,o]),m=r.useMemo(()=>o?x[o]?.detail??null:null,[o,x]),P=async t=>{if(E(t.id),j(null),!x?.[t.id]?.detail){g(!0);try{const s=await _(t);b(l=>({...l??{},[t.id]:{detail:s,fetchedAt:Date.now()}}))}catch(s){console.error("Failed to load registry element detail",s),j("Unable to load detail for this entry")}finally{g(!1)}}},q=async()=>{if(!(!c||!m)){k(!0);try{await I(c,m),i(!1)}catch(t){console.error("Failed to import registry element",t)}finally{k(!1)}}};return e.jsx(W,{open:a,onOpenChange:i,children:e.jsxs(Y,{className:"max-w-5xl h-[80vh] flex flex-col",children:[e.jsx(z,{children:e.jsx(K,{children:F})}),e.jsx("div",{className:"flex flex-col gap-4",children:e.jsxs("div",{className:"relative",children:[e.jsx(O,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Q,{value:f,onChange:t=>C(t.target.value),placeholder:"Search registry entries",className:"pl-9"})]})}),e.jsxs("div",{className:"flex-1 flex gap-4 min-h-0",children:[e.jsx("div",{className:"w-1/3 border-r pr-3",children:U?e.jsxs("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:[e.jsx(A,{className:"h-4 w-4 animate-spin mr-2"}),"Loading entries…"]}):w?e.jsx("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:w}):D.length===0?e.jsx("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:"No entries found"}):e.jsx(V,{className:"h-full",children:e.jsx("div",{className:"space-y-1 pb-4",children:D.map(t=>e.jsxs("button",{onClick:()=>P(t),className:X("w-full rounded-md border border-transparent p-3 text-left transition-colors hover:border-border hover:bg-muted/40",o===t.id&&"border-primary bg-muted"),children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:t.name}),e.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-muted-foreground",children:t.description||t.preview})]}),t.version&&e.jsxs(y,{variant:"outline",className:"text-[10px] font-medium uppercase",children:["v",t.version]})]}),t.tags&&t.tags.length>0&&e.jsxs("div",{className:"mt-2 flex flex-wrap gap-1",children:[t.tags.slice(0,4).map(s=>e.jsx(y,{variant:"secondary",className:"text-[10px] font-normal",children:s},s)),t.tags.length>4&&e.jsxs(y,{variant:"outline",className:"text-[10px] font-normal",children:["+",t.tags.length-4]})]})]},t.id))})})}),e.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:T?e.jsxs("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:[e.jsx(A,{className:"h-5 w-5 animate-spin mr-2"}),"Loading detail…"]}):L?e.jsx("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:L}):c?e.jsx("div",{className:"h-full overflow-hidden",children:$(c,m)}):e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"Select an entry to preview"})})]}),e.jsxs(Z,{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:c?`Selected: ${c.name}`:"No entry selected"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(R,{variant:"outline",onClick:()=>i(!1),disabled:p,children:"Cancel"}),e.jsx(R,{onClick:q,disabled:!c||!m||p,children:p?"Importing…":M})]})]})]})})}export{oe as L,te as R,de as a,ce as f};
@@ -0,0 +1,6 @@
1
+ import{c as e}from"./index-BSBM4i_g.js";/**
2
+ * @license lucide-react v0.542.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const t=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],a=e("calendar",t);export{a as C};
@@ -0,0 +1 @@
1
+ import{r,j as d,f as t}from"./index-BSBM4i_g.js";const o=r.forwardRef(({className:a,...e},s)=>d.jsx("div",{ref:s,className:t("rounded-xl border bg-card text-card-foreground shadow",a),...e}));o.displayName="Card";const c=r.forwardRef(({className:a,...e},s)=>d.jsx("div",{ref:s,className:t("flex flex-col space-y-1.5 p-6",a),...e}));c.displayName="CardHeader";const i=r.forwardRef(({className:a,...e},s)=>d.jsx("h3",{ref:s,className:t("font-semibold leading-none tracking-tight",a),...e}));i.displayName="CardTitle";const n=r.forwardRef(({className:a,...e},s)=>d.jsx("p",{ref:s,className:t("text-sm text-muted-foreground",a),...e}));n.displayName="CardDescription";const l=r.forwardRef(({className:a,...e},s)=>d.jsx("div",{ref:s,className:t("p-6 pt-0",a),...e}));l.displayName="CardContent";const f=r.forwardRef(({className:a,...e},s)=>d.jsx("div",{ref:s,className:t("flex items-center p-6 pt-0",a),...e}));f.displayName="CardFooter";export{o as C,l as a,c as b,i as c,n as d,f as e};
@@ -0,0 +1,6 @@
1
+ import{c as e}from"./index-BSBM4i_g.js";/**
2
+ * @license lucide-react v0.542.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const o=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],t=e("chevron-left",o);export{t as C};
@@ -0,0 +1,6 @@
1
+ import{c as e}from"./index-BSBM4i_g.js";/**
2
+ * @license lucide-react v0.542.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const c=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],y=e("circle-alert",c);export{y as C};
@@ -0,0 +1,6 @@
1
+ import{c}from"./index-BSBM4i_g.js";/**
2
+ * @license lucide-react v0.542.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const e=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],r=c("circle-check",e);export{r as C};
@@ -0,0 +1,6 @@
1
+ import{c}from"./index-BSBM4i_g.js";/**
2
+ * @license lucide-react v0.542.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const e=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],t=c("circle-check-big",e);export{t as C};
@@ -0,0 +1,6 @@
1
+ import{c}from"./index-BSBM4i_g.js";/**
2
+ * @license lucide-react v0.542.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const a=[["path",{d:"M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z",key:"kmsa83"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],l=c("circle-play",a);export{l as C};
@@ -0,0 +1,6 @@
1
+ import{c}from"./index-BSBM4i_g.js";/**
2
+ * @license lucide-react v0.542.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const e=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],o=c("circle-x",e);export{o as C};
@@ -0,0 +1 @@
1
+ async function r(o){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(o);return}if(document.execCommand){const e=document.createElement("textarea");e.value=o,e.style.position="fixed",e.style.left="-999999px",e.style.top="-999999px",document.body.appendChild(e),e.focus(),e.select();try{const t=document.execCommand("copy");if(document.body.removeChild(e),!t)throw new Error("execCommand failed")}catch{throw document.body.removeChild(e),new Error("Fallback copy failed")}return}throw new Error("Clipboard API not available")}export{r as c};
@@ -0,0 +1,11 @@
1
+ import{c as a}from"./index-BSBM4i_g.js";/**
2
+ * @license lucide-react v0.542.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const t=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]],o=a("clipboard-check",t);/**
7
+ * @license lucide-react v0.542.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const c=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]],r=a("clipboard",c);export{o as C,r as a};
@@ -0,0 +1,6 @@
1
+ import{c}from"./index-BSBM4i_g.js";/**
2
+ * @license lucide-react v0.542.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const o=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],r=c("clock",o);export{r as C};
@@ -0,0 +1,6 @@
1
+ import{c as o}from"./index-BSBM4i_g.js";/**
2
+ * @license lucide-react v0.542.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const a=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],e=o("download",a);export{e as D};
@@ -0,0 +1,4 @@
1
+ const l="Consult the schema references in .nut/.schema (proposal.schema.md, project.schema.md, architecture.schema.md, agent.schema.md, knowledge.schema.md) so any updates you make follow the documented structure and include complete arrays for plan steps, dependencies, tags, labels, and comments.",m="Use .nut/context/project.md and .nut/context/architecture.md for reference.";function p(e,t,s,o=!0){const n=[];return o&&n.push(`
2
+ ## Task
3
+
4
+ `,`Review .nut/proposals/${e}.md and begin implementing.`,"Update the assignment to yourself (Coconut AI), the implementation steps (updated as you progress), and set the status upon completion to Code Complete.","Use .nut/context/project.md and .nut/context/architecture.md for reference and make any logical updates to those files upon completion of the proposal too.",l,`Lastly, please add notable comments to the proposal (.nut/proposals/${e}.md) from your chain-of-thought upon completion, particularly for ideas for future suggestions and/or improvements related to the proposal or wider project.`),t.length>0&&n.push(`Please also use these agents: ${t.join(", ")}`),s&&s.trim()&&n.push(s.trim()),n}function d(e,t){const s=[];return s.push(m),e.length>0&&s.push(`Please use these agents: ${e.join(", ")}`),t&&t.trim()&&s.push(`Additional instruction: ${t.trim()}`),s}const h=e=>{const t=e.selectedAgentIds.map(u=>`.nut/agents/${u}`),o=(e.contextType==="change-proposal"?p(e.proposalId,t,e.customInstruction,e.includeDefaultInstructions??!0):d(t,e.customInstruction)).join(" "),n=[e.automationEnabled?"--dangerously-skip-permissions":""].filter(Boolean).join(" "),c=e.selectedMcpServers.map(u=>`'${u.replace(/'/g,"'\\''")}'`).join(","),a=[JSON.stringify(o)].concat(n?[JSON.stringify("--dangerously-skip-permissions")]:[]);return`node -e "${`const fs=require('fs'),{spawn}=require('child_process');const s=new Set([${c}]);const c=require('./.nut/mcp/config.json');const o={mcpServers:Object.fromEntries(Object.entries(c.mcpServers||{}).filter(([k])=>s.has(k)))};fs.writeFileSync('.mcp.json',JSON.stringify(o,null,2));const p=spawn('claude',[${a.join(",")}],{stdio:'inherit'});p.on('exit',code=>process.exit(code));`.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`},g=e=>{const t=e.selectedAgentIds.map(i=>`.nut/agents/${i}`),o=(e.contextType==="change-proposal"?p(e.proposalId,t,e.customInstruction,e.includeDefaultInstructions??!0):d(t,e.customInstruction)).join(" ");return`node -e "${`const fs=require('fs'),path=require('path'),{spawn}=require('child_process');const s=new Set([${e.selectedMcpServers.map(i=>`'${i.replace(/'/g,"'\\''")}'`).join(",")}]);const c=require('./.nut/mcp/config.json');const geminiPath=path.join(require('os').homedir(),'.gemini','settings.json');let settings={};try{settings=JSON.parse(fs.readFileSync(geminiPath,'utf8'))}catch(e){}settings.mcpServers=Object.fromEntries(Object.entries(c.mcpServers||{}).filter(([k])=>s.has(k)));fs.writeFileSync(geminiPath,JSON.stringify(settings,null,2));const p=spawn('gemini',['-i',${JSON.stringify(o)}],{stdio:'inherit'});p.on('exit',code=>process.exit(code));`.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`},f=e=>{const t=e.selectedAgentIds.map(r=>`.nut/agents/${r}`),o=(e.contextType==="change-proposal"?p(e.proposalId,t,e.customInstruction,e.includeDefaultInstructions??!0):d(t,e.customInstruction)).join(" "),n=e.selectedMcpServers.map(r=>`'${r.replace(/'/g,"'\\''")}'`).join(","),c=[JSON.stringify(o)].concat(e.automationEnabled?[JSON.stringify("--dangerously-bypass-approvals-and-sandbox")]:[]);return`node -e "${`const fs=require('fs'),{spawn}=require('child_process');const s=new Set([${n}]);const c=require('./.nut/mcp/config.json');const o={mcpServers:Object.fromEntries(Object.entries(c.mcpServers||{}).filter(([k])=>s.has(k)))};fs.writeFileSync('.mcp.json',JSON.stringify(o,null,2));const p=spawn('codex',[${c.join(",")}],{stdio:'inherit'});p.on('exit',code=>process.exit(code));`.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`},j=e=>{const t=e.selectedAgentIds.map(r=>`.nut/agents/${r}`),o=(e.contextType==="change-proposal"?p(e.proposalId,t,e.customInstruction,e.includeDefaultInstructions??!0):d(t,e.customInstruction)).join(" "),n=e.selectedMcpServers.map(r=>`'${r.replace(/'/g,"'\\''")}'`).join(","),c=[JSON.stringify(o)];return`node -e "${`const fs=require('fs'),{spawn}=require('child_process');const s=new Set([${n}]);const c=require('./.nut/mcp/config.json');const o={mcpServers:Object.fromEntries(Object.entries(c.mcpServers||{}).filter(([k])=>s.has(k)))};fs.writeFileSync('.mcp.json',JSON.stringify(o,null,2));const p=spawn('droid',[${c.join(",")}],{stdio:'inherit'});p.on('exit',code=>process.exit(code));`.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`};export{j as a,h as b,f as c,g as d};
@@ -0,0 +1,6 @@
1
+ import{c}from"./index-BSBM4i_g.js";/**
2
+ * @license lucide-react v0.542.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const e=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],r=c("eye",e);export{r as E};
@@ -0,0 +1,6 @@
1
+ import{c}from"./index-BSBM4i_g.js";/**
2
+ * @license lucide-react v0.542.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const e=[["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5",key:"1w6njk"}],["circle",{cx:"13",cy:"12",r:"2",key:"1j92g6"}],["path",{d:"M18 19c-2.8 0-5-2.2-5-5v8",key:"pkpw2h"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]],a=c("folder-git-2",e);export{a as F};