@mndrk/agx 2.0.22 → 2.0.23

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 (147) hide show
  1. package/cloud-runtime/standalone/.next/BUILD_ID +1 -1
  2. package/cloud-runtime/standalone/.next/build-manifest.json +2 -2
  3. package/cloud-runtime/standalone/.next/prerender-manifest.json +3 -3
  4. package/cloud-runtime/standalone/.next/server/app/_global-error.html +2 -2
  5. package/cloud-runtime/standalone/.next/server/app/_global-error.rsc +1 -1
  6. package/cloud-runtime/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  7. package/cloud-runtime/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  8. package/cloud-runtime/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  9. package/cloud-runtime/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  10. package/cloud-runtime/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  11. package/cloud-runtime/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  12. package/cloud-runtime/standalone/.next/server/app/_not-found.html +2 -2
  13. package/cloud-runtime/standalone/.next/server/app/_not-found.rsc +2 -2
  14. package/cloud-runtime/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  15. package/cloud-runtime/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  16. package/cloud-runtime/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
  17. package/cloud-runtime/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  18. package/cloud-runtime/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  19. package/cloud-runtime/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  20. package/cloud-runtime/standalone/.next/server/app/agents/[id]/page_client-reference-manifest.js +1 -1
  21. package/cloud-runtime/standalone/.next/server/app/agents/page.js.nft.json +1 -1
  22. package/cloud-runtime/standalone/.next/server/app/agents/page_client-reference-manifest.js +1 -1
  23. package/cloud-runtime/standalone/.next/server/app/agents.html +2 -2
  24. package/cloud-runtime/standalone/.next/server/app/agents.rsc +3 -3
  25. package/cloud-runtime/standalone/.next/server/app/agents.segments/_full.segment.rsc +3 -3
  26. package/cloud-runtime/standalone/.next/server/app/agents.segments/_head.segment.rsc +1 -1
  27. package/cloud-runtime/standalone/.next/server/app/agents.segments/_index.segment.rsc +2 -2
  28. package/cloud-runtime/standalone/.next/server/app/agents.segments/_tree.segment.rsc +2 -2
  29. package/cloud-runtime/standalone/.next/server/app/agents.segments/agents/__PAGE__.segment.rsc +2 -2
  30. package/cloud-runtime/standalone/.next/server/app/agents.segments/agents.segment.rsc +1 -1
  31. package/cloud-runtime/standalone/.next/server/app/automations/page.js.nft.json +1 -1
  32. package/cloud-runtime/standalone/.next/server/app/automations/page_client-reference-manifest.js +1 -1
  33. package/cloud-runtime/standalone/.next/server/app/automations.html +2 -2
  34. package/cloud-runtime/standalone/.next/server/app/automations.rsc +3 -3
  35. package/cloud-runtime/standalone/.next/server/app/automations.segments/_full.segment.rsc +3 -3
  36. package/cloud-runtime/standalone/.next/server/app/automations.segments/_head.segment.rsc +1 -1
  37. package/cloud-runtime/standalone/.next/server/app/automations.segments/_index.segment.rsc +2 -2
  38. package/cloud-runtime/standalone/.next/server/app/automations.segments/_tree.segment.rsc +2 -2
  39. package/cloud-runtime/standalone/.next/server/app/automations.segments/automations/__PAGE__.segment.rsc +2 -2
  40. package/cloud-runtime/standalone/.next/server/app/automations.segments/automations.segment.rsc +1 -1
  41. package/cloud-runtime/standalone/.next/server/app/board/page_client-reference-manifest.js +1 -1
  42. package/cloud-runtime/standalone/.next/server/app/board.html +2 -2
  43. package/cloud-runtime/standalone/.next/server/app/board.rsc +2 -2
  44. package/cloud-runtime/standalone/.next/server/app/board.segments/_full.segment.rsc +2 -2
  45. package/cloud-runtime/standalone/.next/server/app/board.segments/_head.segment.rsc +1 -1
  46. package/cloud-runtime/standalone/.next/server/app/board.segments/_index.segment.rsc +2 -2
  47. package/cloud-runtime/standalone/.next/server/app/board.segments/_tree.segment.rsc +2 -2
  48. package/cloud-runtime/standalone/.next/server/app/board.segments/board/__PAGE__.segment.rsc +1 -1
  49. package/cloud-runtime/standalone/.next/server/app/board.segments/board.segment.rsc +1 -1
  50. package/cloud-runtime/standalone/.next/server/app/execution-graph/page_client-reference-manifest.js +1 -1
  51. package/cloud-runtime/standalone/.next/server/app/execution-graph.html +2 -2
  52. package/cloud-runtime/standalone/.next/server/app/execution-graph.rsc +2 -2
  53. package/cloud-runtime/standalone/.next/server/app/execution-graph.segments/_full.segment.rsc +2 -2
  54. package/cloud-runtime/standalone/.next/server/app/execution-graph.segments/_head.segment.rsc +1 -1
  55. package/cloud-runtime/standalone/.next/server/app/execution-graph.segments/_index.segment.rsc +2 -2
  56. package/cloud-runtime/standalone/.next/server/app/execution-graph.segments/_tree.segment.rsc +2 -2
  57. package/cloud-runtime/standalone/.next/server/app/execution-graph.segments/execution-graph/__PAGE__.segment.rsc +1 -1
  58. package/cloud-runtime/standalone/.next/server/app/execution-graph.segments/execution-graph.segment.rsc +1 -1
  59. package/cloud-runtime/standalone/.next/server/app/index.html +2 -2
  60. package/cloud-runtime/standalone/.next/server/app/index.rsc +3 -3
  61. package/cloud-runtime/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  62. package/cloud-runtime/standalone/.next/server/app/index.segments/_full.segment.rsc +3 -3
  63. package/cloud-runtime/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  64. package/cloud-runtime/standalone/.next/server/app/index.segments/_index.segment.rsc +2 -2
  65. package/cloud-runtime/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  66. package/cloud-runtime/standalone/.next/server/app/page.js.nft.json +1 -1
  67. package/cloud-runtime/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  68. package/cloud-runtime/standalone/.next/server/app/projects/[slug]/graph/[taskId]/page.js.nft.json +1 -1
  69. package/cloud-runtime/standalone/.next/server/app/projects/[slug]/graph/[taskId]/page_client-reference-manifest.js +1 -1
  70. package/cloud-runtime/standalone/.next/server/app/projects/[slug]/page.js.nft.json +1 -1
  71. package/cloud-runtime/standalone/.next/server/app/projects/[slug]/page_client-reference-manifest.js +1 -1
  72. package/cloud-runtime/standalone/.next/server/app/projects/orphans/page_client-reference-manifest.js +1 -1
  73. package/cloud-runtime/standalone/.next/server/app/projects/orphans.html +1 -1
  74. package/cloud-runtime/standalone/.next/server/app/projects/orphans.rsc +2 -2
  75. package/cloud-runtime/standalone/.next/server/app/projects/orphans.segments/_full.segment.rsc +2 -2
  76. package/cloud-runtime/standalone/.next/server/app/projects/orphans.segments/_head.segment.rsc +1 -1
  77. package/cloud-runtime/standalone/.next/server/app/projects/orphans.segments/_index.segment.rsc +2 -2
  78. package/cloud-runtime/standalone/.next/server/app/projects/orphans.segments/_tree.segment.rsc +2 -2
  79. package/cloud-runtime/standalone/.next/server/app/projects/orphans.segments/projects/orphans/__PAGE__.segment.rsc +1 -1
  80. package/cloud-runtime/standalone/.next/server/app/projects/orphans.segments/projects/orphans.segment.rsc +1 -1
  81. package/cloud-runtime/standalone/.next/server/app/projects/orphans.segments/projects.segment.rsc +1 -1
  82. package/cloud-runtime/standalone/.next/server/app/projects/page_client-reference-manifest.js +1 -1
  83. package/cloud-runtime/standalone/.next/server/app/projects.html +2 -2
  84. package/cloud-runtime/standalone/.next/server/app/projects.rsc +2 -2
  85. package/cloud-runtime/standalone/.next/server/app/projects.segments/_full.segment.rsc +2 -2
  86. package/cloud-runtime/standalone/.next/server/app/projects.segments/_head.segment.rsc +1 -1
  87. package/cloud-runtime/standalone/.next/server/app/projects.segments/_index.segment.rsc +2 -2
  88. package/cloud-runtime/standalone/.next/server/app/projects.segments/_tree.segment.rsc +2 -2
  89. package/cloud-runtime/standalone/.next/server/app/projects.segments/projects/__PAGE__.segment.rsc +1 -1
  90. package/cloud-runtime/standalone/.next/server/app/projects.segments/projects.segment.rsc +1 -1
  91. package/cloud-runtime/standalone/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  92. package/cloud-runtime/standalone/.next/server/app/settings.html +2 -2
  93. package/cloud-runtime/standalone/.next/server/app/settings.rsc +2 -2
  94. package/cloud-runtime/standalone/.next/server/app/settings.segments/_full.segment.rsc +2 -2
  95. package/cloud-runtime/standalone/.next/server/app/settings.segments/_head.segment.rsc +1 -1
  96. package/cloud-runtime/standalone/.next/server/app/settings.segments/_index.segment.rsc +2 -2
  97. package/cloud-runtime/standalone/.next/server/app/settings.segments/_tree.segment.rsc +2 -2
  98. package/cloud-runtime/standalone/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +1 -1
  99. package/cloud-runtime/standalone/.next/server/app/settings.segments/settings.segment.rsc +1 -1
  100. package/cloud-runtime/standalone/.next/server/app/status/page_client-reference-manifest.js +1 -1
  101. package/cloud-runtime/standalone/.next/server/app/status.html +2 -2
  102. package/cloud-runtime/standalone/.next/server/app/status.rsc +2 -2
  103. package/cloud-runtime/standalone/.next/server/app/status.segments/_full.segment.rsc +2 -2
  104. package/cloud-runtime/standalone/.next/server/app/status.segments/_head.segment.rsc +1 -1
  105. package/cloud-runtime/standalone/.next/server/app/status.segments/_index.segment.rsc +2 -2
  106. package/cloud-runtime/standalone/.next/server/app/status.segments/_tree.segment.rsc +2 -2
  107. package/cloud-runtime/standalone/.next/server/app/status.segments/status/__PAGE__.segment.rsc +1 -1
  108. package/cloud-runtime/standalone/.next/server/app/status.segments/status.segment.rsc +1 -1
  109. package/cloud-runtime/standalone/.next/server/app/thread/[id]/page.js.nft.json +1 -1
  110. package/cloud-runtime/standalone/.next/server/app/thread/[id]/page_client-reference-manifest.js +1 -1
  111. package/cloud-runtime/standalone/.next/server/app/welcome/page_client-reference-manifest.js +1 -1
  112. package/cloud-runtime/standalone/.next/server/app/welcome.html +2 -2
  113. package/cloud-runtime/standalone/.next/server/app/welcome.rsc +2 -2
  114. package/cloud-runtime/standalone/.next/server/app/welcome.segments/_full.segment.rsc +2 -2
  115. package/cloud-runtime/standalone/.next/server/app/welcome.segments/_head.segment.rsc +1 -1
  116. package/cloud-runtime/standalone/.next/server/app/welcome.segments/_index.segment.rsc +2 -2
  117. package/cloud-runtime/standalone/.next/server/app/welcome.segments/_tree.segment.rsc +2 -2
  118. package/cloud-runtime/standalone/.next/server/app/welcome.segments/welcome/__PAGE__.segment.rsc +1 -1
  119. package/cloud-runtime/standalone/.next/server/app/welcome.segments/welcome.segment.rsc +1 -1
  120. package/cloud-runtime/standalone/.next/server/chunks/ssr/{[root-of-the-server]__3fe0b1a1._.js → [root-of-the-server]__d2c48923._.js} +2 -2
  121. package/cloud-runtime/standalone/.next/server/chunks/ssr/{_d743f11d._.js → _8bbe2ac1._.js} +2 -2
  122. package/cloud-runtime/standalone/.next/server/chunks/ssr/_cf5fdbfb._.js +3 -0
  123. package/cloud-runtime/standalone/.next/server/chunks/ssr/_d021529a._.js +3 -0
  124. package/cloud-runtime/standalone/.next/server/chunks/ssr/app_agents_page_tsx_f5f08ed8._.js +1 -1
  125. package/cloud-runtime/standalone/.next/server/chunks/ssr/components_thread_WorkspaceSidebar_tsx_e660301b._.js +1 -1
  126. package/cloud-runtime/standalone/.next/server/middleware-manifest.json +5 -5
  127. package/cloud-runtime/standalone/.next/server/pages/404.html +1 -1
  128. package/cloud-runtime/standalone/.next/server/pages/500.html +2 -2
  129. package/cloud-runtime/standalone/.next/server/server-reference-manifest.js +1 -1
  130. package/cloud-runtime/standalone/.next/server/server-reference-manifest.json +1 -1
  131. package/cloud-runtime/standalone/.next/static/chunks/2a3594d4cb2efe79.css +1 -0
  132. package/cloud-runtime/standalone/.next/static/chunks/78f6cef7d2129d30.js +1 -0
  133. package/cloud-runtime/standalone/.next/static/chunks/81704a1c525bf2ee.js +1 -0
  134. package/cloud-runtime/standalone/app/agents/page.tsx +19 -214
  135. package/cloud-runtime/standalone/components/thread/WorkspaceSidebar.tsx +99 -91
  136. package/package.json +1 -1
  137. package/cloud-runtime/standalone/.next/server/chunks/ssr/_2da02644._.js +0 -3
  138. package/cloud-runtime/standalone/.next/server/chunks/ssr/_60f7e403._.js +0 -3
  139. package/cloud-runtime/standalone/.next/server/chunks/ssr/node_modules_lucide-react_dist_esm_icons_001a8448._.js +0 -3
  140. package/cloud-runtime/standalone/.next/static/chunks/1f1b912fe2e3d5bd.js +0 -1
  141. package/cloud-runtime/standalone/.next/static/chunks/4b3358c52d01a3f9.css +0 -1
  142. package/cloud-runtime/standalone/.next/static/chunks/5488a71a8515e8b2.js +0 -1
  143. package/cloud-runtime/standalone/.next/static/chunks/5ce01dbd17ce3bb2.js +0 -1
  144. package/cloud-runtime/standalone/.next/static/chunks/b649593a57df218f.js +0 -1
  145. /package/cloud-runtime/standalone/.next/static/{H3MuYxcqCPfZoSC2uYW8f → R2CPNTvy5domQF90j_DYV}/_buildManifest.js +0 -0
  146. /package/cloud-runtime/standalone/.next/static/{H3MuYxcqCPfZoSC2uYW8f → R2CPNTvy5domQF90j_DYV}/_clientMiddlewareManifest.json +0 -0
  147. /package/cloud-runtime/standalone/.next/static/{H3MuYxcqCPfZoSC2uYW8f → R2CPNTvy5domQF90j_DYV}/_ssgManifest.js +0 -0
@@ -1,3 +1,3 @@
1
- module.exports=[73570,a=>{"use strict";let b=(0,a.i(60137).default)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);a.s(["AlertTriangle",()=>b],73570)},41710,a=>{"use strict";let b=(0,a.i(60137).default)("clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]);a.s(["Clock",()=>b],41710)},69520,a=>{"use strict";let b=(0,a.i(60137).default)("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);a.s(["RefreshCw",()=>b],69520)},9270,(a,b,c)=>{"use strict";b.exports=a.r(42602).vendored.contexts.AppRouterContext},38783,(a,b,c)=>{"use strict";b.exports=a.r(42602).vendored["react-ssr"].ReactServerDOMTurbopackClient},39118,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d={DEFAULT_SEGMENT_KEY:function(){return l},NOT_FOUND_SEGMENT_KEY:function(){return m},PAGE_SEGMENT_KEY:function(){return k},addSearchParamsIfPageSegment:function(){return i},computeSelectedLayoutSegment:function(){return j},getSegmentValue:function(){return f},getSelectedLayoutSegmentPath:function(){return function a(b,c,d=!0,e=[]){let g;if(d)g=b[1][c];else{let a=b[1];g=a.children??Object.values(a)[0]}if(!g)return e;let h=f(g[0]);return!h||h.startsWith(k)?e:(e.push(h),a(g,c,!1,e))}},isGroupSegment:function(){return g},isParallelRouteSegment:function(){return h}};for(var e in d)Object.defineProperty(c,e,{enumerable:!0,get:d[e]});function f(a){return Array.isArray(a)?a[1]:a}function g(a){return"("===a[0]&&a.endsWith(")")}function h(a){return a.startsWith("@")&&"@children"!==a}function i(a,b){if(a.includes(k)){let a=JSON.stringify(b);return"{}"!==a?k+"?"+a:k}return a}function j(a,b){if(!a||0===a.length)return null;let c="children"===b?a[0]:a[a.length-1];return c===l?null:c}let k="__PAGE__",l="__DEFAULT__",m="/_not-found"},60137,a=>{"use strict";var b=a.i(72131);let c=(...a)=>a.filter((a,b,c)=>!!a&&""!==a.trim()&&c.indexOf(a)===b).join(" ").trim(),d=a=>{let b=a.replace(/^([A-Z])|[\s-_]+(\w)/g,(a,b,c)=>c?c.toUpperCase():b.toLowerCase());return b.charAt(0).toUpperCase()+b.slice(1)};var e={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let f=(0,b.forwardRef)(({color:a="currentColor",size:d=24,strokeWidth:f=2,absoluteStrokeWidth:g,className:h="",children:i,iconNode:j,...k},l)=>(0,b.createElement)("svg",{ref:l,...e,width:d,height:d,stroke:a,strokeWidth:g?24*Number(f)/Number(d):f,className:c("lucide",h),...!i&&!(a=>{for(let b in a)if(b.startsWith("aria-")||"role"===b||"title"===b)return!0;return!1})(k)&&{"aria-hidden":"true"},...k},[...j.map(([a,c])=>(0,b.createElement)(a,c)),...Array.isArray(i)?i:[i]])),g=(a,e)=>{let g=(0,b.forwardRef)(({className:g,...h},i)=>(0,b.createElement)(f,{ref:i,iconNode:e,className:c(`lucide-${d(a).replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${a}`,g),...h}));return g.displayName=d(a),g};a.s(["default",()=>g],60137)},15618,a=>{"use strict";let b=(0,a.i(60137).default)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);a.s(["Plus",()=>b],15618)},53722,a=>{"use strict";let b=(0,a.i(60137).default)("book-open",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);a.s(["BookOpen",()=>b],53722)},47349,(a,b,c)=>{"use strict";var d=a.r(72131);d.useState,d.useEffect,d.useLayoutEffect,d.useDebugValue,c.useSyncExternalStore=void 0!==d.useSyncExternalStore?d.useSyncExternalStore:function(a,b){return b()}},87610,(a,b,c)=>{"use strict";b.exports=a.r(47349)},97514,(a,b,c)=>{"use strict";var d=a.r(72131),e=a.r(87610),f="function"==typeof Object.is?Object.is:function(a,b){return a===b&&(0!==a||1/a==1/b)||a!=a&&b!=b},g=e.useSyncExternalStore,h=d.useRef,i=d.useEffect,j=d.useMemo,k=d.useDebugValue;c.useSyncExternalStoreWithSelector=function(a,b,c,d,e){var l=h(null);if(null===l.current){var m={hasValue:!1,value:null};l.current=m}else m=l.current;var n=g(a,(l=j(function(){function a(a){if(!i){if(i=!0,g=a,a=d(a),void 0!==e&&m.hasValue){var b=m.value;if(e(b,a))return h=b}return h=a}if(b=h,f(g,a))return b;var c=d(a);return void 0!==e&&e(b,c)?(g=a,b):(g=a,h=c)}var g,h,i=!1,j=void 0===c?null:c;return[function(){return a(b())},null===j?void 0:function(){return a(j())}]},[b,c,d,e]))[0],l[1]);return i(function(){m.hasValue=!0,m.value=n},[n]),k(n),n}},64442,(a,b,c)=>{"use strict";b.exports=a.r(97514)},50522,a=>{"use strict";let b=(0,a.i(60137).default)("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);a.s(["ChevronRight",()=>b],50522)},2835,a=>{"use strict";let b=(0,a.i(60137).default)("hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);a.s(["Hash",()=>b],2835)},99464,a=>{"use strict";let b=(0,a.i(60137).default)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);a.s(["Pencil",()=>b],99464)},33441,a=>{"use strict";let b=(0,a.i(60137).default)("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);a.s(["Check",()=>b],33441)},81560,a=>{"use strict";let b=(0,a.i(60137).default)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);a.s(["Trash2",()=>b],81560)},87532,a=>{"use strict";let b=(0,a.i(60137).default)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);a.s(["Search",()=>b],87532)},44637,a=>{"use strict";var b=a.i(90944),c=a.i(72131);let d={name:"",description:""},e={name:"",path:"",notes:""};function f(){let[a,b]=(0,c.useState)(d),[f,g]=(0,c.useState)([e]),[h,i]=(0,c.useState)(!1),[j,k]=(0,c.useState)(null),l=(0,c.useCallback)((a,b,c)=>{g(d=>d.map((d,e)=>e===a?{...d,[b]:c}:d))},[]),m=(0,c.useCallback)(()=>{g(a=>[...a,{...e}])},[]),n=(0,c.useCallback)(a=>{g(b=>b.filter((b,c)=>c!==a))},[]),o=(0,c.useCallback)(()=>{b(d),g([e]),k(null)},[]),p=(0,c.useCallback)(a=>{b({name:a.name||"",description:a.description||""}),a.repos&&a.repos.length>0?g(a.repos.map(a=>({id:a.id,name:a.name||"",path:a.path||"",git_url:a.git_url||"",notes:a.notes||""}))):g([e]),k(null)},[]);return{form:a,setForm:b,repos:f,handleRepoChange:l,addRepo:m,removeRepo:n,resetForm:o,hydrateFromProject:p,isSubmitting:h,setIsSubmitting:i,formError:j,setFormError:k}}function g(a,b){let c=b.filter(a=>a.name.trim()&&a.path.trim()).map(a=>({...a.id?{id:a.id}:{},name:a.name.trim(),path:a.path.trim(),...a.git_url?.trim()?{git_url:a.git_url.trim()}:{},notes:a.notes.trim()||void 0}));return{name:a.name.trim(),description:a.description.trim()||void 0,repos:c.length?c:void 0}}function h({form:a,repos:d,isEditingProject:e,isSubmitting:f,onFieldChange:g,onRepoChange:h,onAddRepo:i,onRemoveRepo:j}){let[k,l]=(0,c.useState)([]),m=(0,c.useRef)(0);(0,c.useEffect)(()=>{e?l([]):l(d.map((a,b)=>b)),m.current=d.length},[e,d.length]),(0,c.useEffect)(()=>{if(!e){m.current=d.length;return}let a=m.current;l(b=>{let c=b.filter(a=>a<d.length);return d.length>a&&c.push(...Array.from({length:d.length-a},(b,c)=>a+c)),c}),m.current=d.length},[e,d.length]);let n=(0,c.useCallback)(a=>{l(b=>b.includes(a)?b.filter(b=>b!==a):[...b,a])},[]),o=(0,c.useCallback)(a=>!e||k.includes(a),[k,e]);return(0,b.jsxs)("div",{className:"space-y-6",children:[(0,b.jsx)("div",{className:"grid gap-4",children:(0,b.jsxs)("label",{className:"space-y-1.5 block",children:[(0,b.jsx)("span",{className:"text-xs font-bold uppercase tracking-wider text-[var(--muted-foreground)]",children:"Project Name"}),(0,b.jsx)("input",{value:a.name,onChange:a=>g("name",a.target.value),className:"input w-full",placeholder:"e.g. AGX Cloud",disabled:f})]})}),(0,b.jsxs)("label",{className:"space-y-1.5 block",children:[(0,b.jsx)("span",{className:"text-xs font-bold uppercase tracking-wider text-[var(--muted-foreground)]",children:"Description"}),(0,b.jsx)("textarea",{value:a.description,onChange:a=>g("description",a.target.value),className:"input w-full h-24 resize-none",placeholder:"What is this project about?",disabled:f})]}),(0,b.jsxs)("div",{className:"space-y-4",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between border-b border-[var(--card-border)] pb-2",children:[(0,b.jsx)("h3",{className:"text-sm font-bold uppercase tracking-widest text-[var(--muted-foreground)]",children:"Repositories"}),(0,b.jsx)("button",{type:"button",onClick:i,className:"text-xs font-semibold text-[var(--primary)] hover:underline",disabled:f,children:"+ Add Repository"})]}),(0,b.jsx)("div",{className:"space-y-4",children:d.map((a,c)=>(0,b.jsxs)("div",{className:"p-4 rounded-2xl border border-[var(--card-border)] bg-[var(--muted)]/20 space-y-3 relative group",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between",children:[(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"text-xs font-bold text-[var(--foreground)] uppercase",children:["Repo #",c+1]}),e&&!o(c)?(0,b.jsxs)("div",{className:"mt-1 text-sm text-[var(--muted-foreground)]",children:[(0,b.jsx)("div",{children:a.name||"Unnamed repository"}),(0,b.jsx)("div",{className:"truncate",children:a.path||"No local path set"})]}):null]}),(0,b.jsxs)("div",{className:"flex items-center gap-3",children:[e&&(0,b.jsx)("button",{type:"button",onClick:()=>n(c),className:"text-xs font-semibold text-[var(--primary)] hover:underline",disabled:f,children:o(c)?"Done":"Edit"}),d.length>1&&(0,b.jsx)("button",{type:"button",onClick:()=>j(c),className:"text-xs font-semibold text-[var(--destructive)] hover:underline",disabled:f,children:"Remove"})]})]}),o(c)?(0,b.jsxs)("div",{className:"grid gap-3 md:grid-cols-2",children:[(0,b.jsx)("input",{value:a.name,onChange:a=>h(c,"name",a.target.value),placeholder:"Name (e.g. Frontend)",className:"input text-sm",disabled:f}),(0,b.jsx)("input",{value:a.path,onChange:a=>h(c,"path",a.target.value),placeholder:"Local path (mandatory)",className:"input text-sm",disabled:f}),(0,b.jsx)("div",{className:"md:col-span-2",children:(0,b.jsx)("textarea",{value:a.notes,onChange:a=>h(c,"notes",a.target.value),placeholder:"Repo-specific rules and notes (placeholder for conventions, constraints, ownership, deploy notes...)",className:"input text-sm w-full min-h-24 resize-y",disabled:f})})]}):null]},c))})]})]})}function i({isOpen:a,onClose:d,onSubmit:e,editingProject:f,form:g,repos:i,isSubmitting:j,formError:k,onFieldChange:l,onRepoChange:m,onAddRepo:n,onRemoveRepo:o}){let[p,q]=(0,c.useState)([]);return((0,c.useEffect)(()=>{let a=!1;return async function(){if(!f)return q([]);try{let b=await fetch(`/api/projects/${f.id}/memory?producer=system`),c=b.ok?await b.json():{memory:[]};a||q(c.memory??[])}catch{a||q([])}}(),()=>{a=!0}},[f]),a)?(0,b.jsx)("div",{className:"modal-backdrop p-2 sm:p-4 z-50 overflow-y-auto flex items-center justify-center",onClick:a=>a.target===a.currentTarget&&d(),children:(0,b.jsxs)("div",{className:"modal-content w-full max-w-4xl mx-2 sm:mx-auto bg-[var(--card-bg)] rounded-3xl border border-[var(--card-border)] shadow-2xl animate-scale-in flex flex-col max-h-[90vh]",children:[(0,b.jsxs)("div",{className:"px-4 py-4 sm:px-8 sm:py-6 border-b border-[var(--card-border)] flex items-center justify-between flex-shrink-0",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("h2",{className:"text-xl font-bold",children:f?"Edit Project":"Create New Project"}),(0,b.jsx)("p",{className:"text-xs text-[var(--muted-foreground)] mt-0.5",children:f?"Update your project settings and repositories.":"Define a new project and connect repositories."})]}),(0,b.jsx)("button",{onClick:d,className:"p-2 rounded-xl hover:bg-[var(--muted)]/50 transition-colors",children:(0,b.jsx)("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,b.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,b.jsxs)("div",{className:"flex-1 overflow-y-auto p-4 sm:p-8",children:[f&&(0,b.jsx)("div",{className:"mb-6",children:(0,b.jsxs)("div",{className:"rounded-2xl border border-[var(--card-border)] bg-[var(--muted)]/20 p-4",children:[(0,b.jsx)("h3",{className:"text-sm font-bold uppercase tracking-widest text-[var(--muted-foreground)]",children:"System-Generated Project Knowledge"}),p.length>0?(0,b.jsx)("div",{className:"mt-3 space-y-2",children:p.slice(0,5).map(a=>(0,b.jsxs)("div",{className:"rounded-xl border border-[var(--card-border)] bg-white px-3 py-2 text-sm text-[var(--foreground)]",children:[(0,b.jsx)("div",{children:a.content}),a.created_at?(0,b.jsx)("div",{className:"mt-1 text-[11px] text-[var(--muted-foreground)]",children:new Date(a.created_at).toLocaleString()}):null]},a.id))}):(0,b.jsx)("p",{className:"mt-2 text-sm text-[var(--muted-foreground)]",children:"No system-generated project knowledge candidates yet."})]})}),(0,b.jsx)(h,{form:g,repos:i,isEditingProject:!!f,isSubmitting:j,onFieldChange:l,onRepoChange:m,onAddRepo:n,onRemoveRepo:o}),k&&(0,b.jsx)("div",{className:"mt-6 p-4 rounded-xl bg-[var(--destructive-muted)] border border-[var(--destructive)]/20 text-sm text-[var(--destructive)]",children:k})]}),(0,b.jsxs)("div",{className:"px-4 py-4 sm:px-8 sm:py-6 border-t border-[var(--card-border)] flex items-center justify-end gap-3 flex-shrink-0",children:[(0,b.jsx)("button",{onClick:d,className:"px-6 py-2 rounded-xl border border-[var(--card-border)] hover:bg-[var(--muted)]/50 transition-colors text-sm font-medium",children:"Cancel"}),(0,b.jsx)("button",{onClick:e,disabled:j,className:"btn-primary px-8 py-2 shadow-lg shadow-[var(--primary)]/20 min-w-[120px]",children:j?(0,b.jsxs)("span",{className:"flex items-center gap-2",children:[(0,b.jsx)("span",{className:"spinner w-3 h-3 border-2 border-white/20 border-t-white"}),"Saving..."]}):f?"Save Changes":"Create Project"})]})]})}):null}a.s(["createProjectPayload",()=>g,"default",()=>i,"useProjectFormState",()=>f])}];
1
+ module.exports=[73570,a=>{"use strict";let b=(0,a.i(60137).default)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);a.s(["AlertTriangle",()=>b],73570)},69520,a=>{"use strict";let b=(0,a.i(60137).default)("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);a.s(["RefreshCw",()=>b],69520)},41710,a=>{"use strict";let b=(0,a.i(60137).default)("clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]);a.s(["Clock",()=>b],41710)},9270,(a,b,c)=>{"use strict";b.exports=a.r(42602).vendored.contexts.AppRouterContext},38783,(a,b,c)=>{"use strict";b.exports=a.r(42602).vendored["react-ssr"].ReactServerDOMTurbopackClient},39118,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d={DEFAULT_SEGMENT_KEY:function(){return l},NOT_FOUND_SEGMENT_KEY:function(){return m},PAGE_SEGMENT_KEY:function(){return k},addSearchParamsIfPageSegment:function(){return i},computeSelectedLayoutSegment:function(){return j},getSegmentValue:function(){return f},getSelectedLayoutSegmentPath:function(){return function a(b,c,d=!0,e=[]){let g;if(d)g=b[1][c];else{let a=b[1];g=a.children??Object.values(a)[0]}if(!g)return e;let h=f(g[0]);return!h||h.startsWith(k)?e:(e.push(h),a(g,c,!1,e))}},isGroupSegment:function(){return g},isParallelRouteSegment:function(){return h}};for(var e in d)Object.defineProperty(c,e,{enumerable:!0,get:d[e]});function f(a){return Array.isArray(a)?a[1]:a}function g(a){return"("===a[0]&&a.endsWith(")")}function h(a){return a.startsWith("@")&&"@children"!==a}function i(a,b){if(a.includes(k)){let a=JSON.stringify(b);return"{}"!==a?k+"?"+a:k}return a}function j(a,b){if(!a||0===a.length)return null;let c="children"===b?a[0]:a[a.length-1];return c===l?null:c}let k="__PAGE__",l="__DEFAULT__",m="/_not-found"},60137,a=>{"use strict";var b=a.i(72131);let c=(...a)=>a.filter((a,b,c)=>!!a&&""!==a.trim()&&c.indexOf(a)===b).join(" ").trim(),d=a=>{let b=a.replace(/^([A-Z])|[\s-_]+(\w)/g,(a,b,c)=>c?c.toUpperCase():b.toLowerCase());return b.charAt(0).toUpperCase()+b.slice(1)};var e={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let f=(0,b.forwardRef)(({color:a="currentColor",size:d=24,strokeWidth:f=2,absoluteStrokeWidth:g,className:h="",children:i,iconNode:j,...k},l)=>(0,b.createElement)("svg",{ref:l,...e,width:d,height:d,stroke:a,strokeWidth:g?24*Number(f)/Number(d):f,className:c("lucide",h),...!i&&!(a=>{for(let b in a)if(b.startsWith("aria-")||"role"===b||"title"===b)return!0;return!1})(k)&&{"aria-hidden":"true"},...k},[...j.map(([a,c])=>(0,b.createElement)(a,c)),...Array.isArray(i)?i:[i]])),g=(a,e)=>{let g=(0,b.forwardRef)(({className:g,...h},i)=>(0,b.createElement)(f,{ref:i,iconNode:e,className:c(`lucide-${d(a).replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${a}`,g),...h}));return g.displayName=d(a),g};a.s(["default",()=>g],60137)},15618,a=>{"use strict";let b=(0,a.i(60137).default)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);a.s(["Plus",()=>b],15618)},53722,a=>{"use strict";let b=(0,a.i(60137).default)("book-open",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);a.s(["BookOpen",()=>b],53722)},47349,(a,b,c)=>{"use strict";var d=a.r(72131);d.useState,d.useEffect,d.useLayoutEffect,d.useDebugValue,c.useSyncExternalStore=void 0!==d.useSyncExternalStore?d.useSyncExternalStore:function(a,b){return b()}},87610,(a,b,c)=>{"use strict";b.exports=a.r(47349)},97514,(a,b,c)=>{"use strict";var d=a.r(72131),e=a.r(87610),f="function"==typeof Object.is?Object.is:function(a,b){return a===b&&(0!==a||1/a==1/b)||a!=a&&b!=b},g=e.useSyncExternalStore,h=d.useRef,i=d.useEffect,j=d.useMemo,k=d.useDebugValue;c.useSyncExternalStoreWithSelector=function(a,b,c,d,e){var l=h(null);if(null===l.current){var m={hasValue:!1,value:null};l.current=m}else m=l.current;var n=g(a,(l=j(function(){function a(a){if(!i){if(i=!0,g=a,a=d(a),void 0!==e&&m.hasValue){var b=m.value;if(e(b,a))return h=b}return h=a}if(b=h,f(g,a))return b;var c=d(a);return void 0!==e&&e(b,c)?(g=a,b):(g=a,h=c)}var g,h,i=!1,j=void 0===c?null:c;return[function(){return a(b())},null===j?void 0:function(){return a(j())}]},[b,c,d,e]))[0],l[1]);return i(function(){m.hasValue=!0,m.value=n},[n]),k(n),n}},64442,(a,b,c)=>{"use strict";b.exports=a.r(97514)},50522,a=>{"use strict";let b=(0,a.i(60137).default)("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);a.s(["ChevronRight",()=>b],50522)},2835,a=>{"use strict";let b=(0,a.i(60137).default)("hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);a.s(["Hash",()=>b],2835)},99464,a=>{"use strict";let b=(0,a.i(60137).default)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);a.s(["Pencil",()=>b],99464)},33441,a=>{"use strict";let b=(0,a.i(60137).default)("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);a.s(["Check",()=>b],33441)},87532,a=>{"use strict";let b=(0,a.i(60137).default)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);a.s(["Search",()=>b],87532)},81560,a=>{"use strict";let b=(0,a.i(60137).default)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);a.s(["Trash2",()=>b],81560)},44637,a=>{"use strict";var b=a.i(90944),c=a.i(72131);let d={name:"",description:""},e={name:"",path:"",notes:""};function f(){let[a,b]=(0,c.useState)(d),[f,g]=(0,c.useState)([e]),[h,i]=(0,c.useState)(!1),[j,k]=(0,c.useState)(null),l=(0,c.useCallback)((a,b,c)=>{g(d=>d.map((d,e)=>e===a?{...d,[b]:c}:d))},[]),m=(0,c.useCallback)(()=>{g(a=>[...a,{...e}])},[]),n=(0,c.useCallback)(a=>{g(b=>b.filter((b,c)=>c!==a))},[]),o=(0,c.useCallback)(()=>{b(d),g([e]),k(null)},[]),p=(0,c.useCallback)(a=>{b({name:a.name||"",description:a.description||""}),a.repos&&a.repos.length>0?g(a.repos.map(a=>({id:a.id,name:a.name||"",path:a.path||"",git_url:a.git_url||"",notes:a.notes||""}))):g([e]),k(null)},[]);return{form:a,setForm:b,repos:f,handleRepoChange:l,addRepo:m,removeRepo:n,resetForm:o,hydrateFromProject:p,isSubmitting:h,setIsSubmitting:i,formError:j,setFormError:k}}function g(a,b){let c=b.filter(a=>a.name.trim()&&a.path.trim()).map(a=>({...a.id?{id:a.id}:{},name:a.name.trim(),path:a.path.trim(),...a.git_url?.trim()?{git_url:a.git_url.trim()}:{},notes:a.notes.trim()||void 0}));return{name:a.name.trim(),description:a.description.trim()||void 0,repos:c.length?c:void 0}}function h({form:a,repos:d,isEditingProject:e,isSubmitting:f,onFieldChange:g,onRepoChange:h,onAddRepo:i,onRemoveRepo:j}){let[k,l]=(0,c.useState)([]),m=(0,c.useRef)(0);(0,c.useEffect)(()=>{e?l([]):l(d.map((a,b)=>b)),m.current=d.length},[e,d.length]),(0,c.useEffect)(()=>{if(!e){m.current=d.length;return}let a=m.current;l(b=>{let c=b.filter(a=>a<d.length);return d.length>a&&c.push(...Array.from({length:d.length-a},(b,c)=>a+c)),c}),m.current=d.length},[e,d.length]);let n=(0,c.useCallback)(a=>{l(b=>b.includes(a)?b.filter(b=>b!==a):[...b,a])},[]),o=(0,c.useCallback)(a=>!e||k.includes(a),[k,e]);return(0,b.jsxs)("div",{className:"space-y-6",children:[(0,b.jsx)("div",{className:"grid gap-4",children:(0,b.jsxs)("label",{className:"space-y-1.5 block",children:[(0,b.jsx)("span",{className:"text-xs font-bold uppercase tracking-wider text-[var(--muted-foreground)]",children:"Project Name"}),(0,b.jsx)("input",{value:a.name,onChange:a=>g("name",a.target.value),className:"input w-full",placeholder:"e.g. AGX Cloud",disabled:f})]})}),(0,b.jsxs)("label",{className:"space-y-1.5 block",children:[(0,b.jsx)("span",{className:"text-xs font-bold uppercase tracking-wider text-[var(--muted-foreground)]",children:"Description"}),(0,b.jsx)("textarea",{value:a.description,onChange:a=>g("description",a.target.value),className:"input w-full h-24 resize-none",placeholder:"What is this project about?",disabled:f})]}),(0,b.jsxs)("div",{className:"space-y-4",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between border-b border-[var(--card-border)] pb-2",children:[(0,b.jsx)("h3",{className:"text-sm font-bold uppercase tracking-widest text-[var(--muted-foreground)]",children:"Repositories"}),(0,b.jsx)("button",{type:"button",onClick:i,className:"text-xs font-semibold text-[var(--primary)] hover:underline",disabled:f,children:"+ Add Repository"})]}),(0,b.jsx)("div",{className:"space-y-4",children:d.map((a,c)=>(0,b.jsxs)("div",{className:"p-4 rounded-2xl border border-[var(--card-border)] bg-[var(--muted)]/20 space-y-3 relative group",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between",children:[(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"text-xs font-bold text-[var(--foreground)] uppercase",children:["Repo #",c+1]}),e&&!o(c)?(0,b.jsxs)("div",{className:"mt-1 text-sm text-[var(--muted-foreground)]",children:[(0,b.jsx)("div",{children:a.name||"Unnamed repository"}),(0,b.jsx)("div",{className:"truncate",children:a.path||"No local path set"})]}):null]}),(0,b.jsxs)("div",{className:"flex items-center gap-3",children:[e&&(0,b.jsx)("button",{type:"button",onClick:()=>n(c),className:"text-xs font-semibold text-[var(--primary)] hover:underline",disabled:f,children:o(c)?"Done":"Edit"}),d.length>1&&(0,b.jsx)("button",{type:"button",onClick:()=>j(c),className:"text-xs font-semibold text-[var(--destructive)] hover:underline",disabled:f,children:"Remove"})]})]}),o(c)?(0,b.jsxs)("div",{className:"grid gap-3 md:grid-cols-2",children:[(0,b.jsx)("input",{value:a.name,onChange:a=>h(c,"name",a.target.value),placeholder:"Name (e.g. Frontend)",className:"input text-sm",disabled:f}),(0,b.jsx)("input",{value:a.path,onChange:a=>h(c,"path",a.target.value),placeholder:"Local path (mandatory)",className:"input text-sm",disabled:f}),(0,b.jsx)("div",{className:"md:col-span-2",children:(0,b.jsx)("textarea",{value:a.notes,onChange:a=>h(c,"notes",a.target.value),placeholder:"Repo-specific rules and notes (placeholder for conventions, constraints, ownership, deploy notes...)",className:"input text-sm w-full min-h-24 resize-y",disabled:f})})]}):null]},c))})]})]})}function i({isOpen:a,onClose:d,onSubmit:e,editingProject:f,form:g,repos:i,isSubmitting:j,formError:k,onFieldChange:l,onRepoChange:m,onAddRepo:n,onRemoveRepo:o}){let[p,q]=(0,c.useState)([]);return((0,c.useEffect)(()=>{let a=!1;return async function(){if(!f)return q([]);try{let b=await fetch(`/api/projects/${f.id}/memory?producer=system`),c=b.ok?await b.json():{memory:[]};a||q(c.memory??[])}catch{a||q([])}}(),()=>{a=!0}},[f]),a)?(0,b.jsx)("div",{className:"modal-backdrop p-2 sm:p-4 z-50 overflow-y-auto flex items-center justify-center",onClick:a=>a.target===a.currentTarget&&d(),children:(0,b.jsxs)("div",{className:"modal-content w-full max-w-4xl mx-2 sm:mx-auto bg-[var(--card-bg)] rounded-3xl border border-[var(--card-border)] shadow-2xl animate-scale-in flex flex-col max-h-[90vh]",children:[(0,b.jsxs)("div",{className:"px-4 py-4 sm:px-8 sm:py-6 border-b border-[var(--card-border)] flex items-center justify-between flex-shrink-0",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("h2",{className:"text-xl font-bold",children:f?"Edit Project":"Create New Project"}),(0,b.jsx)("p",{className:"text-xs text-[var(--muted-foreground)] mt-0.5",children:f?"Update your project settings and repositories.":"Define a new project and connect repositories."})]}),(0,b.jsx)("button",{onClick:d,className:"p-2 rounded-xl hover:bg-[var(--muted)]/50 transition-colors",children:(0,b.jsx)("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,b.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,b.jsxs)("div",{className:"flex-1 overflow-y-auto p-4 sm:p-8",children:[f&&(0,b.jsx)("div",{className:"mb-6",children:(0,b.jsxs)("div",{className:"rounded-2xl border border-[var(--card-border)] bg-[var(--muted)]/20 p-4",children:[(0,b.jsx)("h3",{className:"text-sm font-bold uppercase tracking-widest text-[var(--muted-foreground)]",children:"System-Generated Project Knowledge"}),p.length>0?(0,b.jsx)("div",{className:"mt-3 space-y-2",children:p.slice(0,5).map(a=>(0,b.jsxs)("div",{className:"rounded-xl border border-[var(--card-border)] bg-white px-3 py-2 text-sm text-[var(--foreground)]",children:[(0,b.jsx)("div",{children:a.content}),a.created_at?(0,b.jsx)("div",{className:"mt-1 text-[11px] text-[var(--muted-foreground)]",children:new Date(a.created_at).toLocaleString()}):null]},a.id))}):(0,b.jsx)("p",{className:"mt-2 text-sm text-[var(--muted-foreground)]",children:"No system-generated project knowledge candidates yet."})]})}),(0,b.jsx)(h,{form:g,repos:i,isEditingProject:!!f,isSubmitting:j,onFieldChange:l,onRepoChange:m,onAddRepo:n,onRemoveRepo:o}),k&&(0,b.jsx)("div",{className:"mt-6 p-4 rounded-xl bg-[var(--destructive-muted)] border border-[var(--destructive)]/20 text-sm text-[var(--destructive)]",children:k})]}),(0,b.jsxs)("div",{className:"px-4 py-4 sm:px-8 sm:py-6 border-t border-[var(--card-border)] flex items-center justify-end gap-3 flex-shrink-0",children:[(0,b.jsx)("button",{onClick:d,className:"px-6 py-2 rounded-xl border border-[var(--card-border)] hover:bg-[var(--muted)]/50 transition-colors text-sm font-medium",children:"Cancel"}),(0,b.jsx)("button",{onClick:e,disabled:j,className:"btn-primary px-8 py-2 shadow-lg shadow-[var(--primary)]/20 min-w-[120px]",children:j?(0,b.jsxs)("span",{className:"flex items-center gap-2",children:[(0,b.jsx)("span",{className:"spinner w-3 h-3 border-2 border-white/20 border-t-white"}),"Saving..."]}):f?"Save Changes":"Create Project"})]})]})}):null}a.s(["createProjectPayload",()=>g,"default",()=>i,"useProjectFormState",()=>f])}];
2
2
 
3
- //# sourceMappingURL=_d743f11d._.js.map
3
+ //# sourceMappingURL=_8bbe2ac1._.js.map
@@ -0,0 +1,3 @@
1
+ module.exports=[210,a=>{"use strict";let b=(0,a.i(60137).default)("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);a.s(["ArrowLeft",()=>b],210)},33441,a=>{"use strict";let b=(0,a.i(60137).default)("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);a.s(["Check",()=>b],33441)},84505,a=>{"use strict";let b=(0,a.i(60137).default)("download",[["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"}]]);a.s(["Download",()=>b],84505)},60246,a=>{"use strict";let b=(0,a.i(60137).default)("users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]);a.s(["Users",()=>b],60246)},89116,a=>{"use strict";let b="agx-chat:threads";function c(){let a=globalThis.localStorage;if(!a)throw Error("LocalThreadAdapter requires a browser-like environment with `localStorage`.");return a}function d(){let a=c().getItem(b);if(!a)return{threads:{}};try{let b=JSON.parse(a);if(b&&"object"==typeof b&&b.threads&&"object"==typeof b.threads)return{threads:Object.fromEntries(Object.entries(b.threads).map(([a,b])=>{var c,d;return[a,(c=a,d=b,{id:c,title:d?.title,messages:Array.isArray(d?.messages)?[...d.messages]:[],createdAt:"number"==typeof d?.createdAt?d.createdAt:Date.now(),updatedAt:"number"==typeof d?.updatedAt?d.updatedAt:Date.now(),metadata:d?.metadata,status:d?.status,outcomeNote:d?.outcomeNote,projectId:"string"==typeof d?.projectId?d.projectId:"string"==typeof d?.teamId?d.teamId:d?.projectId===null||d?.teamId===null?null:void 0})]}))}}catch{}return{threads:{}}}function e(a){c().setItem(b,JSON.stringify(a))}function f(a){return{...a,messages:a.messages.map(a=>({...a})),metadata:a.metadata?{...a.metadata}:void 0}}let g=new class{async saveThread(a){let b=Date.now(),c=d(),g=c.threads[a.id],h=g?.createdAt??a.createdAt??b,i=a.updatedAt??b,j={id:a.id,title:a.title,messages:a.messages.map(a=>({...a})),metadata:a.metadata,createdAt:h,updatedAt:i,status:a.status,outcomeNote:a.outcomeNote,projectId:a.projectId??a.teamId};return c.threads[a.id]=j,e(c),f(j)}async loadThread(a){let b=d().threads[a];return b?f(b):null}async listThreads(a){let b=Object.values(d().threads),c=a?.order??"desc",e=[...b].sort((a,b)=>"asc"===c?a.updatedAt-b.updatedAt:b.updatedAt-a.updatedAt),g=Math.max(0,a?.offset??0),h=a?.limit,i="number"==typeof h&&h>=0?e.slice(g,g+h):e.slice(g);return{total:b.length,threads:i.map(f)}}async deleteThread(a){let b=d();b.threads[a]&&(delete b.threads[a],e(b))}};a.s(["threadService",0,{listThreads:async()=>[...(await g.listThreads({order:"desc"})).threads.filter(a=>!0!==a.metadata?.archived)].sort((a,b)=>b.updatedAt-a.updatedAt),async createThread(a){let b="string"==typeof a?.id?a.id.trim():"";if(b){let c=await g.loadThread(b);if(c){let b={...c.metadata??{},...a?.metadata??{},archived:!1,archivedAt:null};return g.saveThread({id:c.id,title:a?.title??c.title,messages:a?.messages?.length?a.messages:c.messages,metadata:b,createdAt:c.createdAt})}}let c={id:b||("u">typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():`thread-${Date.now()}-${Math.random().toString(16).slice(2)}`),messages:a?.messages?.length?a.messages:[],title:a?.title,metadata:a?.metadata};return g.saveThread(c)},async deleteThread(a){let b=a.trim();if(!b)return;let c=await g.loadThread(b);if(!c)return;let d={...c.metadata??{},archived:!0,archivedAt:Date.now()};await g.saveThread({id:c.id,title:c.title,messages:c.messages,metadata:d,createdAt:c.createdAt})},async renameThread(a,b){let c=a.trim(),d=b.trim();if(!c||!d)return null;let e=await g.loadThread(c);return e?(e.title?.trim()??"")===d?e:g.saveThread({id:e.id,title:d,messages:e.messages,metadata:e.metadata,createdAt:e.createdAt}):null},async updateThreadStatus(a,b){let c=await g.loadThread(a);return c?c.status===b?c:g.saveThread({id:c.id,title:c.title,messages:c.messages,metadata:c.metadata,createdAt:c.createdAt,status:b,outcomeNote:c.outcomeNote}):null},async updateThreadOutcomeNote(a,b){let c=await g.loadThread(a);return c?c.outcomeNote===b?c:g.saveThread({id:c.id,title:c.title,messages:c.messages,metadata:c.metadata,createdAt:c.createdAt,status:c.status,outcomeNote:b}):null},async updateMessageThreadStatus(a,b,c){let d=await g.loadThread(a);if(!d)return null;let e=d.messages.map(a=>a.id===b?{...a,threadStatus:c}:a);return g.saveThread({id:d.id,title:d.title,messages:e,metadata:d.metadata,createdAt:d.createdAt,status:d.status,outcomeNote:d.outcomeNote})},async updateMessageOutcomeNote(a,b,c){let d=await g.loadThread(a);if(!d)return null;let e=d.messages.map(a=>a.id===b?{...a,outcomeNote:c}:a);return g.saveThread({id:d.id,title:d.title,messages:e,metadata:d.metadata,createdAt:d.createdAt,status:d.status,outcomeNote:d.outcomeNote})},async saveThreadMessages(a,b){let c=await g.loadThread(a);if(!c)return null;let d=c.title?.trim()||function(a){let b=a.find(a=>"user"===a.role)?.content?.trim();if(!b)return;let c=b.replace(/\s+/g," ");return c.length>60?`${c.slice(0,60).trim()}…`:c}(b);return function(a,b){if(a.length!==b.length)return!1;for(let c=0;c<a.length;c+=1){let d=a[c],e=b[c];if(d.id!==e.id||d.role!==e.role||d.participantId!==e.participantId||d.content!==e.content||d.timestamp!==e.timestamp)return!1}return!0}(c.messages,b)&&(c.title?.trim()||void 0)===d?c:g.saveThread({id:c.id,title:d,messages:b,metadata:c.metadata,createdAt:c.createdAt})}}],89116)},5151,a=>{"use strict";let b=(0,a.i(60137).default)("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);a.s(["Copy",()=>b],5151)}];
2
+
3
+ //# sourceMappingURL=_cf5fdbfb._.js.map
@@ -0,0 +1,3 @@
1
+ module.exports=[56196,a=>{"use strict";var b=a.i(72131);function c(){let[a,c]=(0,b.useState)([]),[d,e]=(0,b.useState)(!1),[f,g]=(0,b.useState)(null),h=(0,b.useCallback)(async()=>{e(!0);try{let a=await fetch("/api/projects");if(!a.ok)throw Error("Failed to fetch projects");let b=await a.json();c(b.projects??[]),g(null)}catch(a){g(a instanceof Error?a:Error("Unknown error"))}finally{e(!1)}},[]);(0,b.useEffect)(()=>{h()},[h]);let i=(0,b.useCallback)(async a=>{let b=await fetch("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!b.ok)throw Error((await b.json().catch(()=>({}))).error||"Failed to create project");let d=(await b.json()).project;return c(a=>[d,...a]),d},[]);return{projects:a,isLoading:d,error:f,refetch:h,createProject:i,updateProject:(0,b.useCallback)(async(a,b)=>{let d=await fetch(`/api/projects/${a}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!d.ok)throw Error((await d.json().catch(()=>({}))).error||"Failed to update project");let e=(await d.json()).project;return c(b=>b.map(b=>b.id===a?e:b)),e},[]),deleteProject:(0,b.useCallback)(async a=>{let b=await fetch(`/api/projects/${a}`,{method:"DELETE"});if(!b.ok)throw Error((await b.json().catch(()=>({}))).error||"Failed to delete project");c(b=>b.filter(b=>b.id!==a))},[])}}function d(){let[a,c]=(0,b.useState)([]),[d,e]=(0,b.useState)(!0),f=(0,b.useCallback)(async()=>{try{let a=await fetch("/api/projects");if(!a.ok)return;let{projects:b}=await a.json(),d=await Promise.all((b??[]).map(async a=>{let b=[],c=[];try{let[d,e]=await Promise.all([fetch(`/api/projects/${a.id}/agents`),fetch(`/api/projects/${a.id}/threads`)]);d.ok&&(b=(await d.json()).agents??[]),e.ok&&(c=((await e.json()).threads??[]).map(a=>a.thread_id))}catch{}return{...a,repos:a.repos??[],agents:b.map(b=>({project_id:a.id,agent_id:b.agent_id,routing_order:b.routing_order,created_at:b.created_at})),thread_ids:c,workspace_ids:c}}));c(d)}catch{}finally{e(!1)}},[]);(0,b.useEffect)(()=>{f()},[f]);let g=(0,b.useCallback)(async(a,b)=>{try{let d="string"==typeof a?{name:a}:a,e=d.name.trim(),f=(d.slug||e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")).trim(),g=await fetch("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...d,name:e,slug:f})});if(!g.ok)return null;let{project:h}=await g.json(),i=Array.isArray(b)?b:b?[b]:[];for(let a of i)await fetch(`/api/projects/${h.id}/threads`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({threadId:a})}).catch(()=>{});let j={...h,repos:h.repos??[],agents:[],thread_ids:i,workspace_ids:i};return c(a=>[...a,j].sort((a,b)=>a.name.localeCompare(b.name))),j}catch{return null}},[]),h=(0,b.useCallback)(async(a,b)=>{try{if(!(await fetch(`/api/projects/${a}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b})})).ok)return;c(c=>c.map(c=>c.id===a?{...c,name:b}:c).sort((a,b)=>a.name.localeCompare(b.name)))}catch{}},[]),i=(0,b.useCallback)(async a=>{try{if(!(await fetch(`/api/projects/${a}`,{method:"DELETE"})).ok)return;c(b=>b.filter(b=>b.id!==a))}catch{}},[]),j=(0,b.useCallback)(async(a,b)=>{try{let d=await fetch(`/api/projects/${a}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!d.ok){let a=await d.json().catch(()=>({}));throw Error(a.error||"Failed to update project")}let e=(await d.json()).project;return c(b=>b.map(b=>b.id===a?{...b,...e,repos:e.repos??b.repos}:b)),e}catch{return null}},[]),k=(0,b.useCallback)(async(a,b)=>{try{let d=await fetch(`/api/projects/${a}/agents`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentId:b})});if(!d.ok)return;let e=((await d.json()).agents??[]).map(b=>({project_id:a,agent_id:b.agent_id,routing_order:b.routing_order,created_at:b.created_at}));c(b=>b.map(b=>b.id===a?{...b,agents:e}:b))}catch{}},[]),l=(0,b.useCallback)(async(a,b)=>{try{let d=await fetch(`/api/projects/${a}/agents?agentId=${b}`,{method:"DELETE"});if(!d.ok)return;let e=((await d.json()).agents??[]).map(b=>({project_id:a,agent_id:b.agent_id,routing_order:b.routing_order,created_at:b.created_at}));c(b=>b.map(b=>b.id===a?{...b,agents:e}:b))}catch{}},[]);return{projects:a,isLoading:d,createProject:g,updateProject:j,renameProject:h,deleteProject:i,addAgent:k,removeAgent:l,reorderAgents:(0,b.useCallback)(async(a,b)=>{try{let d=await fetch(`/api/projects/${a}/agents`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({orderedAgentIds:b})});if(!d.ok)return;let e=((await d.json()).agents??[]).map(b=>({project_id:a,agent_id:b.agent_id,routing_order:b.routing_order,created_at:b.created_at}));c(b=>b.map(b=>b.id===a?{...b,agents:e}:b))}catch{}},[]),moveAgent:(0,b.useCallback)(async(a,b,c)=>{try{await fetch(`/api/projects/${b}/agents?agentId=${a}`,{method:"DELETE"}),await fetch(`/api/projects/${c}/agents`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentId:a})}),await f()}catch{}},[f]),refresh:f}}a.s(["useProjects",()=>c,"useProjectsWithAgents",()=>d])},9270,(a,b,c)=>{"use strict";b.exports=a.r(42602).vendored.contexts.AppRouterContext},38783,(a,b,c)=>{"use strict";b.exports=a.r(42602).vendored["react-ssr"].ReactServerDOMTurbopackClient},39118,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d={DEFAULT_SEGMENT_KEY:function(){return l},NOT_FOUND_SEGMENT_KEY:function(){return m},PAGE_SEGMENT_KEY:function(){return k},addSearchParamsIfPageSegment:function(){return i},computeSelectedLayoutSegment:function(){return j},getSegmentValue:function(){return f},getSelectedLayoutSegmentPath:function(){return function a(b,c,d=!0,e=[]){let g;if(d)g=b[1][c];else{let a=b[1];g=a.children??Object.values(a)[0]}if(!g)return e;let h=f(g[0]);return!h||h.startsWith(k)?e:(e.push(h),a(g,c,!1,e))}},isGroupSegment:function(){return g},isParallelRouteSegment:function(){return h}};for(var e in d)Object.defineProperty(c,e,{enumerable:!0,get:d[e]});function f(a){return Array.isArray(a)?a[1]:a}function g(a){return"("===a[0]&&a.endsWith(")")}function h(a){return a.startsWith("@")&&"@children"!==a}function i(a,b){if(a.includes(k)){let a=JSON.stringify(b);return"{}"!==a?k+"?"+a:k}return a}function j(a,b){if(!a||0===a.length)return null;let c="children"===b?a[0]:a[a.length-1];return c===l?null:c}let k="__PAGE__",l="__DEFAULT__",m="/_not-found"},60137,a=>{"use strict";var b=a.i(72131);let c=(...a)=>a.filter((a,b,c)=>!!a&&""!==a.trim()&&c.indexOf(a)===b).join(" ").trim(),d=a=>{let b=a.replace(/^([A-Z])|[\s-_]+(\w)/g,(a,b,c)=>c?c.toUpperCase():b.toLowerCase());return b.charAt(0).toUpperCase()+b.slice(1)};var e={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let f=(0,b.forwardRef)(({color:a="currentColor",size:d=24,strokeWidth:f=2,absoluteStrokeWidth:g,className:h="",children:i,iconNode:j,...k},l)=>(0,b.createElement)("svg",{ref:l,...e,width:d,height:d,stroke:a,strokeWidth:g?24*Number(f)/Number(d):f,className:c("lucide",h),...!i&&!(a=>{for(let b in a)if(b.startsWith("aria-")||"role"===b||"title"===b)return!0;return!1})(k)&&{"aria-hidden":"true"},...k},[...j.map(([a,c])=>(0,b.createElement)(a,c)),...Array.isArray(i)?i:[i]])),g=(a,e)=>{let g=(0,b.forwardRef)(({className:g,...h},i)=>(0,b.createElement)(f,{ref:i,iconNode:e,className:c(`lucide-${d(a).replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${a}`,g),...h}));return g.displayName=d(a),g};a.s(["default",()=>g],60137)},15618,a=>{"use strict";let b=(0,a.i(60137).default)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);a.s(["Plus",()=>b],15618)},53722,a=>{"use strict";let b=(0,a.i(60137).default)("book-open",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);a.s(["BookOpen",()=>b],53722)},47349,(a,b,c)=>{"use strict";var d=a.r(72131);d.useState,d.useEffect,d.useLayoutEffect,d.useDebugValue,c.useSyncExternalStore=void 0!==d.useSyncExternalStore?d.useSyncExternalStore:function(a,b){return b()}},87610,(a,b,c)=>{"use strict";b.exports=a.r(47349)},97514,(a,b,c)=>{"use strict";var d=a.r(72131),e=a.r(87610),f="function"==typeof Object.is?Object.is:function(a,b){return a===b&&(0!==a||1/a==1/b)||a!=a&&b!=b},g=e.useSyncExternalStore,h=d.useRef,i=d.useEffect,j=d.useMemo,k=d.useDebugValue;c.useSyncExternalStoreWithSelector=function(a,b,c,d,e){var l=h(null);if(null===l.current){var m={hasValue:!1,value:null};l.current=m}else m=l.current;var n=g(a,(l=j(function(){function a(a){if(!i){if(i=!0,g=a,a=d(a),void 0!==e&&m.hasValue){var b=m.value;if(e(b,a))return h=b}return h=a}if(b=h,f(g,a))return b;var c=d(a);return void 0!==e&&e(b,c)?(g=a,b):(g=a,h=c)}var g,h,i=!1,j=void 0===c?null:c;return[function(){return a(b())},null===j?void 0:function(){return a(j())}]},[b,c,d,e]))[0],l[1]);return i(function(){m.hasValue=!0,m.value=n},[n]),k(n),n}},64442,(a,b,c)=>{"use strict";b.exports=a.r(97514)},50522,a=>{"use strict";let b=(0,a.i(60137).default)("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);a.s(["ChevronRight",()=>b],50522)},2835,a=>{"use strict";let b=(0,a.i(60137).default)("hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);a.s(["Hash",()=>b],2835)},99464,a=>{"use strict";let b=(0,a.i(60137).default)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);a.s(["Pencil",()=>b],99464)}];
2
+
3
+ //# sourceMappingURL=_d021529a._.js.map
@@ -1,3 +1,3 @@
1
- module.exports=[84712,a=>{"use strict";var b=a.i(90944),c=a.i(72131),d=a.i(38246),e=a.i(210),f=a.i(5784),g=a.i(50522),h=a.i(5151),i=a.i(33441),j=a.i(84505),k=a.i(60137);let l=(0,k.default)("eye",[["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"}]]);var m=a.i(2835),n=a.i(99464),o=a.i(15618);let p=(0,k.default)("share-2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);var q=a.i(81560);let r=(0,k.default)("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);var s=a.i(60246),t=a.i(33508),u=a.i(56196),v=a.i(20138),w=a.i(89116);function x(a){return a?a.projects??[]:[]}function y(){let[a,k]=(0,c.useState)([]),[y,z]=(0,c.useState)([]),{projects:A,createProject:B,deleteProject:C,renameProject:D,addAgent:E,removeAgent:F,refresh:G}=(0,u.useProjectsWithAgents)(),[H,I]=(0,c.useState)(new Set),[J,K]=(0,c.useState)(!1),[L,M]=(0,c.useState)(""),[N,O]=(0,c.useState)(new Set),[P,Q]=(0,c.useState)(new Set),[R,S]=(0,c.useState)(null),[T,U]=(0,c.useState)(new Set),[V,W]=(0,c.useState)(!1),[X,Y]=(0,c.useState)(null),[Z,$]=(0,c.useState)(""),[_,aa]=(0,c.useState)(null),[ab,ac]=(0,c.useState)(!1),[ad,ae]=(0,c.useState)(new Set),[af,ag]=(0,c.useState)(!0),[ah,ai]=(0,c.useState)(!1),[aj,ak]=(0,c.useState)(null),[al,am]=(0,c.useState)(null),[an,ao]=(0,c.useState)(!1),[ap,aq]=(0,c.useState)(!1),[ar,as]=(0,c.useState)("choice"),[at,au]=(0,c.useState)(""),[av,aw]=(0,c.useState)(!1),[ax,ay]=(0,c.useState)(null),[az,aA]=(0,c.useState)(new Set),[aB,aC]=(0,c.useState)(new Set),[aD,aE]=(0,c.useState)(!1),[aF,aG]=(0,c.useState)(null),aH=(0,c.useRef)(null),[aI,aJ]=(0,c.useState)(new Set),aK=()=>{fetch("/api/participants").then(a=>a.json()).then(a=>k(Array.isArray(a)?a:[]))},aL=(0,c.useCallback)(async()=>{try{let a=await fetch("/api/processes");if(!a.ok)return;let b=await a.json();aJ(new Set(b.filter(a=>"spawning"===a.state||"running"===a.state).map(a=>a.agentId)))}catch{}},[]);(0,c.useEffect)(()=>{aK(),w.threadService.listThreads().then(z),aL();let a=setInterval(aL,3e3);return()=>clearInterval(a)},[aL]);let aM=new Map(y.map(a=>[a.id,a])),aN=A.filter(a=>!a.is_default),aO=async()=>{if(!L.trim())return;let a=Array.from(P),b=await B(L.trim(),a.length>0?a:void 0);if(b)for(let a of N)await E(b.id,a);K(!1)},aP=async()=>{X&&Z.trim()&&(await D(X.projectId,Z.trim()),Y(null))},aQ=async()=>{if(0!==ad.size){ai(!0);try{let a=await fetch("/api/agent-specs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentIds:Array.from(ad),includeSelf:af})});if(!a.ok)throw Error("Share failed");let b=await a.json();ak(b.code),am(b.expires_at)}catch(a){console.error("Share error:",a)}finally{ai(!1)}}},aR=async()=>{if(0!==ad.size){ai(!0);try{let a=Array.from(ad),b=await fetch("/api/agents/export",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentIds:a})});if(!b.ok)throw Error("Export failed");let c=(await b.json()).agents.map(a=>({...a,self:af?a.self:null})),d={version:1,exportedAt:new Date().toISOString(),agents:c,projects:[]},e=new Blob([JSON.stringify(d,null,2)],{type:"application/json"}),f=URL.createObjectURL(e),g=document.createElement("a");g.href=f,g.download=1===c.length?`${c[0].name.toLowerCase().replace(/\s+/g,"-")}.agent.json`:"agents.bundle.json",g.click(),URL.revokeObjectURL(f),ac(!1)}catch(a){console.error("Export error:",a)}finally{ai(!1)}}},aS=async()=>{if(0!==at.trim().length){aw(!0),aG(null),ay(null);try{let a=await fetch(`/api/agent-specs/pull?code=${encodeURIComponent(at.trim())}`);if(!a.ok){let b=await a.json().catch(()=>({error:"Failed to pull"}));aG(b.error||"Code not found or expired");return}let b=(await a.json()).bundle;ay(b),aA(new Set(b.agents.map(a=>a.id))),aC(new Set(x(b).map(a=>a.name)))}catch{aG("Failed to connect. Is agx-api running?")}finally{aw(!1)}}},aT=async()=>{if(ax){aE(!0);try{let b=new Set(a.map(a=>a.id));for(let a of ax.agents){if(!az.has(a.id))continue;let c={name:a.name,provider:a.provider,model:a.model,color:a.color,identity:a.identity||void 0,identityFile:a.identityFile||void 0,skills:a.skills||[],variables:a.variables||{}};b.has(a.id)?(c.id=a.id,await fetch("/api/participants",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)})):await fetch("/api/participants",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)})}for(let a of x(ax)){if(!aB.has(a.name))continue;let b=await B(a.name);if(b)for(let c of a.agentIds)az.has(c)&&await E(b.id,c)}aK(),await G(),aq(!1),ay(null)}catch(a){console.error("Import error:",a),aG("Import failed. Check console for details.")}finally{aE(!1)}}},aU=R?A.find(a=>a.id===R.projectId):null,aV=new Set(aU?.agents.map(a=>a.agent_id)??[]),aW=R?a.filter(a=>!aV.has(a.id)):[],aX=({checked:a})=>(0,b.jsx)("div",{className:`w-4 h-4 rounded border flex-shrink-0 flex items-center justify-center ${a?"bg-slate-900 border-slate-900":"border-slate-300"}`,children:a&&(0,b.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:(0,b.jsx)("path",{d:"M2 5l2 2 4-4",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})});return(0,b.jsxs)("div",{className:"min-h-screen bg-slate-50 p-6",children:[(0,b.jsxs)("div",{className:"max-w-6xl mx-auto",children:[(0,b.jsxs)("div",{className:"flex items-center gap-3 mb-6",children:[(0,b.jsxs)(d.default,{href:"/",className:"inline-flex items-center gap-1 text-sm text-slate-500 hover:text-slate-700 transition-colors",children:[(0,b.jsx)(e.ArrowLeft,{size:16}),"Back"]}),(0,b.jsx)("h1",{className:"text-2xl font-semibold text-slate-900",children:"Manage Agents"}),(0,b.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,b.jsxs)("button",{type:"button",className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-white bg-slate-900 rounded-lg hover:bg-slate-800 transition-colors",onClick:()=>W(!0),children:[(0,b.jsx)(o.Plus,{size:13}),"New Agent"]}),(0,b.jsxs)("button",{type:"button",className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-white bg-violet-600 rounded-lg hover:bg-violet-700 transition-colors",onClick:()=>{ae(new Set(a.map(a=>a.id))),ag(!0),ak(null),am(null),ao(!1),ac(!0)},disabled:0===a.length,children:[(0,b.jsx)(p,{size:13}),"Share"]}),(0,b.jsxs)("button",{type:"button",className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-violet-600 bg-violet-50 border border-violet-200 rounded-lg hover:bg-violet-100 transition-colors",onClick:()=>{as("choice"),au(""),ay(null),aA(new Set),aC(new Set),aG(null),aq(!0)},children:[(0,b.jsx)(j.Download,{size:13}),"Import"]}),(0,b.jsx)("input",{ref:aH,type:"file",accept:".json",className:"hidden",onChange:a=>{let b=a.target.files?.[0];if(!b)return;aG(null);let c=new FileReader;c.onload=()=>{try{let a=JSON.parse(c.result);if(!a.version||!Array.isArray(a.agents))throw Error("Invalid bundle format");ay(a),aA(new Set(a.agents.map(a=>a.id))),aC(new Set(x(a).map(a=>a.name)))}catch{aG("Invalid file. Expected an .agent.json bundle.")}},c.readAsText(b),a.target.value=""}})]})]}),aF&&!ap&&(0,b.jsxs)("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-50 border border-red-200 text-sm text-red-700 flex items-center justify-between",children:[(0,b.jsx)("span",{children:aF}),(0,b.jsx)("button",{type:"button",onClick:()=>aG(null),className:"text-red-400 hover:text-red-600",children:(0,b.jsx)(t.X,{size:14})})]}),0===a.length?(0,b.jsx)("p",{className:"text-slate-500 text-sm",children:"No agents configured yet."}):(0,b.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:a.map(a=>(0,b.jsxs)("div",{className:"bg-white rounded-xl border border-slate-200 p-4 hover:shadow-md transition-shadow text-left group",children:[(0,b.jsxs)("div",{className:"flex items-start gap-3 mb-3",children:[(0,b.jsx)("img",{src:(0,v.agentAvatarUrl)(a.id,48,a.color),alt:a.name,className:"w-12 h-12 rounded-full bg-slate-100"}),(0,b.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,b.jsx)("h3",{className:"font-medium text-slate-900 truncate",children:a.name}),(0,b.jsx)("p",{className:"text-xs text-slate-400 truncate mt-0.5",children:a.model}),aI.has(a.id)&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 mt-1 text-[10px] font-medium text-emerald-600",children:[(0,b.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"}),"Working"]})]})]}),a.skills&&a.skills.length>0&&(0,b.jsxs)("div",{className:"flex flex-wrap gap-1 mb-3",children:[a.skills.slice(0,3).map((a,c)=>(0,b.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-blue-50 text-blue-600 truncate max-w-[120px]",children:a.file.split("/").pop()},c)),a.skills.length>3&&(0,b.jsxs)("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-50 text-slate-400",children:["+",a.skills.length-3]})]}),(0,b.jsxs)("div",{className:"flex items-center justify-between pt-2 border-t border-slate-100",children:[(0,b.jsx)("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded-full bg-slate-100 text-slate-600 uppercase tracking-wide",children:a.provider}),(0,b.jsxs)("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[(0,b.jsx)("button",{type:"button",title:"Edit",onClick:()=>aa(a),className:"p-1.5 text-slate-400 hover:text-slate-600 rounded hover:bg-slate-50 transition-colors",children:(0,b.jsx)(n.Pencil,{size:13})}),(0,b.jsx)(d.default,{href:`/agents/${a.id}`,title:"View profile",className:"p-1.5 text-slate-400 hover:text-slate-600 rounded hover:bg-slate-50 transition-colors",children:(0,b.jsx)(l,{size:13})})]})]})]},a.id))}),(0,b.jsxs)("div",{className:"mt-10",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,b.jsx)("h2",{className:"text-lg font-semibold text-slate-900",children:"Projects"}),(0,b.jsxs)("button",{type:"button",className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-white bg-slate-900 rounded-lg hover:bg-slate-800 transition-colors",onClick:()=>{M(""),O(new Set),Q(new Set),K(!0)},children:[(0,b.jsx)(o.Plus,{size:13}),"Add project"]})]}),0===aN.length?(0,b.jsx)("p",{className:"text-sm text-slate-400",children:"No projects yet. Create one to group agents for a thread."}):(0,b.jsx)("div",{className:"bg-white rounded-xl border border-slate-200 divide-y divide-slate-100",children:aN.map(c=>{let d=H.has(c.id),e=(c.thread_ids??[]).map(a=>aM.get(a)?.title?.trim()||"Untitled").filter(Boolean);return(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"flex items-center gap-3 px-5 py-3.5 group",children:[(0,b.jsxs)("button",{type:"button",className:"flex items-center gap-3 flex-1 min-w-0 text-left",onClick:()=>{var a;return a=c.id,void I(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},children:[d?(0,b.jsx)(f.ChevronDown,{size:16,className:"text-slate-400 flex-shrink-0"}):(0,b.jsx)(g.ChevronRight,{size:16,className:"text-slate-400 flex-shrink-0"}),(0,b.jsx)(s.Users,{size:16,className:"text-slate-400 flex-shrink-0"}),(0,b.jsx)("span",{className:"font-medium text-slate-800 text-sm",children:c.name}),(0,b.jsxs)("span",{className:"text-xs text-slate-400",children:[c.agents.length," ",1===c.agents.length?"agent":"agents",e.length>0&&` \xb7 ${e.length} ${1===e.length?"thread":"threads"}`]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[(0,b.jsx)("button",{type:"button",className:"p-1.5 text-slate-400 hover:text-slate-600 rounded hover:bg-slate-50 transition-colors",title:"Add agent",onClick:()=>{U(new Set),S({projectId:c.id})},children:(0,b.jsx)(o.Plus,{size:14})}),(0,b.jsx)("button",{type:"button",className:"p-1.5 text-slate-400 hover:text-slate-600 rounded hover:bg-slate-50 transition-colors",title:"Rename project",onClick:()=>{$(c.name),Y({projectId:c.id,currentName:c.name})},children:(0,b.jsx)(n.Pencil,{size:13})}),(0,b.jsx)("button",{type:"button",className:"p-1.5 text-slate-400 hover:text-red-500 rounded hover:bg-slate-50 transition-colors",title:"Delete project",onClick:()=>void C(c.id),children:(0,b.jsx)(q.Trash2,{size:13})})]})]}),d&&(0,b.jsxs)("div",{className:"px-5 pb-4 pt-1 ml-9 flex flex-col gap-1",children:[0===c.agents.length&&(0,b.jsx)("p",{className:"text-xs text-slate-400 py-1",children:"No agents in this project."}),c.agents.map(d=>{let e=a.find(a=>a.id===d.agent_id);return(0,b.jsxs)("div",{className:"flex items-center gap-2.5 py-1.5 group/agent",children:[(0,b.jsx)("img",{src:(0,v.agentAvatarUrl)(d.agent_id,24,e?.color),alt:"",className:"w-6 h-6 rounded-full flex-shrink-0"}),(0,b.jsx)("span",{className:"text-sm text-slate-700 truncate flex-1",children:e?.name??d.agent_id}),(0,b.jsx)("span",{className:"text-[10px] text-slate-400",children:e?.model}),(0,b.jsx)("button",{type:"button",className:"opacity-0 group-hover/agent:opacity-100 text-slate-400 hover:text-red-500 transition-opacity",onClick:()=>void F(c.id,d.agent_id),title:"Remove from project",children:(0,b.jsx)(t.X,{size:14})})]},d.agent_id)}),e.length>0&&(0,b.jsxs)("div",{className:"mt-2 pt-2 border-t border-slate-100",children:[(0,b.jsx)("p",{className:"text-[10px] font-medium text-slate-400 uppercase tracking-wide mb-1",children:"Threads"}),(0,b.jsx)("div",{className:"flex flex-wrap gap-1.5",children:e.map((a,c)=>(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 text-xs px-2 py-1 rounded-md bg-indigo-50 text-indigo-600",children:[(0,b.jsx)(m.Hash,{size:11}),a]},c))})]})]})]},c.id)})})]})]}),ab&&(0,b.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30",onClick:()=>ac(!1),children:(0,b.jsxs)("div",{className:"bg-white rounded-xl shadow-xl border border-slate-200 w-[440px] max-h-[80vh] flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-5 py-3.5 border-b border-slate-100",children:[(0,b.jsx)("h3",{className:"text-sm font-medium text-slate-900",children:"Share Agents"}),(0,b.jsx)("button",{type:"button",className:"text-slate-400 hover:text-slate-600",onClick:()=>ac(!1),children:(0,b.jsx)(t.X,{size:16})})]}),aj?(0,b.jsxs)("div",{className:"px-5 py-6 flex flex-col items-center gap-4",children:[(0,b.jsxs)("div",{className:"text-center",children:[(0,b.jsx)("p",{className:"text-sm text-slate-600 mb-3",children:"Share this code with the recipient:"}),(0,b.jsxs)("div",{className:"flex items-center justify-center gap-3",children:[(0,b.jsx)("span",{className:"text-3xl font-mono font-bold tracking-[0.3em] text-slate-900",children:aj}),(0,b.jsx)("button",{type:"button",className:"p-2 text-slate-400 hover:text-slate-600 transition-colors",onClick:()=>{aj&&(navigator.clipboard.writeText(aj),ao(!0),setTimeout(()=>ao(!1),2e3))},children:an?(0,b.jsx)(i.Check,{size:18,className:"text-green-500"}):(0,b.jsx)(h.Copy,{size:18})})]})]}),al&&(0,b.jsxs)("p",{className:"text-[11px] text-slate-400",children:["Expires ",new Date(al).toLocaleTimeString()]}),(0,b.jsx)("button",{type:"button",className:"px-4 py-2 text-xs font-medium text-slate-600 bg-slate-100 rounded-lg hover:bg-slate-200 transition-colors",onClick:()=>ac(!1),children:"Done"})]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"overflow-y-auto flex-1",children:[aN.length>0&&(0,b.jsxs)("div",{className:"border-b border-slate-100 px-5 py-3",children:[(0,b.jsx)("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wide mb-2",children:"Select by project"}),(0,b.jsx)("div",{className:"flex flex-wrap gap-1.5",children:aN.map(c=>{let d=c.agents.map(a=>a.agent_id),e=d.length>0&&d.every(a=>ad.has(a)),f=d.some(a=>ad.has(a));return(0,b.jsxs)("button",{type:"button",className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-[11px] font-medium transition-colors ${e?"bg-slate-900 text-white":f?"bg-slate-300 text-slate-700":"bg-slate-100 text-slate-600 hover:bg-slate-200"}`,onClick:()=>{ae(a=>{let b=new Set(a);return e?d.forEach(a=>b.delete(a)):d.forEach(a=>b.add(a)),b})},title:d.map(b=>a.find(a=>a.id===b)?.name??b).join(", "),children:[(0,b.jsx)(s.Users,{size:10}),c.name,(0,b.jsx)("span",{className:`text-[10px] ${e?"text-slate-300":"text-slate-400"}`,children:c.agents.length})]},c.id)})})]}),(0,b.jsxs)("div",{className:"border-b border-slate-100",children:[(0,b.jsxs)("div",{className:"px-5 pt-3 pb-1 flex items-center justify-between",children:[(0,b.jsx)("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wide",children:"Agents"}),(0,b.jsx)("button",{type:"button",className:"text-[11px] text-slate-400 hover:text-slate-600",onClick:()=>{ad.size===a.length?ae(new Set):ae(new Set(a.map(a=>a.id)))},children:ad.size===a.length?"Deselect all":"Select all"})]}),a.map(a=>{let c=ad.has(a.id);return(0,b.jsxs)("button",{type:"button",className:`w-full flex items-center gap-3 px-5 py-2 text-sm transition-colors ${c?"bg-slate-50 text-slate-900":"text-slate-600 hover:bg-slate-50"}`,onClick:()=>{ae(b=>{let c=new Set(b);return c.has(a.id)?c.delete(a.id):c.add(a.id),c})},children:[(0,b.jsx)(aX,{checked:c}),(0,b.jsx)("img",{src:(0,v.agentAvatarUrl)(a.id,24,a.color),alt:"",className:"w-6 h-6 rounded-full flex-shrink-0"}),(0,b.jsx)("span",{className:"truncate text-xs font-medium flex-1",children:a.name}),(0,b.jsx)("span",{className:"text-[10px] text-slate-400",children:a.provider})]},a.id)})]}),(0,b.jsx)("div",{className:"px-5 py-3",children:(0,b.jsxs)("button",{type:"button",className:`flex items-center gap-3 w-full px-3 py-2 rounded-lg text-sm transition-colors ${af?"bg-slate-50 text-slate-900":"text-slate-600 hover:bg-slate-50"}`,onClick:()=>ag(!af),children:[(0,b.jsx)(aX,{checked:af}),(0,b.jsx)("span",{className:"text-xs font-medium",children:"Include self.md (agent bio)"})]})})]}),(0,b.jsxs)("div",{className:"px-5 py-3 border-t border-slate-100 flex items-center justify-between",children:[(0,b.jsxs)("span",{className:"text-[11px] text-slate-400",children:[ad.size," ",1===ad.size?"agent":"agents"]}),(0,b.jsxs)("div",{className:"flex gap-2",children:[(0,b.jsxs)("button",{type:"button",disabled:0===ad.size||ah,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-slate-600 bg-white border border-slate-200 rounded-lg hover:bg-slate-50 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",onClick:()=>void aR(),children:[(0,b.jsx)(j.Download,{size:12}),ah?"Exporting...":"Export to File"]}),(0,b.jsxs)("button",{type:"button",disabled:0===ad.size||ah,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-white bg-violet-600 rounded-lg hover:bg-violet-700 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",onClick:()=>void aQ(),children:[(0,b.jsx)(p,{size:12}),ah?"Pushing...":"Push to Hub"]}),(0,b.jsx)("button",{type:"button",className:"px-3 py-1.5 text-xs text-slate-500 hover:text-slate-700 transition-colors",onClick:()=>ac(!1),children:"Cancel"})]})]})]})]})}),J&&(0,b.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30",onClick:()=>K(!1),children:(0,b.jsxs)("div",{className:"bg-white rounded-xl shadow-xl border border-slate-200 w-[420px] max-h-[80vh] flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-5 py-3.5 border-b border-slate-100",children:[(0,b.jsx)("h3",{className:"text-sm font-medium text-slate-900",children:"Create project"}),(0,b.jsx)("button",{type:"button",className:"text-slate-400 hover:text-slate-600",onClick:()=>K(!1),children:(0,b.jsx)(t.X,{size:16})})]}),(0,b.jsxs)("div",{className:"overflow-y-auto flex-1",children:[(0,b.jsxs)("div",{className:"px-5 py-3 border-b border-slate-100",children:[(0,b.jsx)("label",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wide block mb-1.5",children:"Name"}),(0,b.jsx)("input",{autoFocus:!0,type:"text",value:L,onChange:a=>M(a.target.value),placeholder:"e.g. Frontend Crew",className:"w-full px-3 py-2 text-sm border border-slate-200 rounded-lg outline-none focus:border-slate-400 focus:ring-1 focus:ring-slate-200 transition-all"})]}),(0,b.jsxs)("div",{className:"px-5 py-3 border-b border-slate-100",children:[(0,b.jsx)("label",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wide block mb-1.5",children:"Threads"}),0===y.length?(0,b.jsx)("p",{className:"text-xs text-slate-400",children:"No threads available."}):(0,b.jsx)("div",{className:"flex flex-col gap-0.5",children:y.map(a=>{let c=P.has(a.id),d=a.title?.trim()||"Untitled";return(0,b.jsxs)("button",{type:"button",className:`flex items-center gap-2.5 px-3 py-2 rounded-lg text-sm transition-colors ${c?"bg-indigo-50 text-indigo-700":"text-slate-600 hover:bg-slate-50"}`,onClick:()=>{Q(b=>{let c=new Set(b);return c.has(a.id)?c.delete(a.id):c.add(a.id),c})},children:[(0,b.jsx)("div",{className:`w-4 h-4 rounded border flex-shrink-0 flex items-center justify-center ${c?"bg-indigo-600 border-indigo-600":"border-slate-300"}`,children:c&&(0,b.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:(0,b.jsx)("path",{d:"M2 5l2 2 4-4",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),(0,b.jsx)(m.Hash,{size:13,className:"flex-shrink-0 text-slate-400"}),(0,b.jsx)("span",{className:"truncate text-xs font-medium",children:d})]},a.id)})})]}),(0,b.jsxs)("div",{className:"py-1",children:[(0,b.jsx)("p",{className:"px-5 py-1.5 text-[11px] font-medium text-slate-400 uppercase tracking-wide",children:"Agents"}),a.map(a=>{let c=N.has(a.id);return(0,b.jsxs)("button",{type:"button",className:`w-full flex items-center gap-3 px-5 py-2 text-sm transition-colors ${c?"bg-slate-100 text-slate-900":"text-slate-700 hover:bg-slate-50"}`,onClick:()=>{O(b=>{let c=new Set(b);return c.has(a.id)?c.delete(a.id):c.add(a.id),c})},children:[(0,b.jsx)(aX,{checked:c}),(0,b.jsx)("img",{src:(0,v.agentAvatarUrl)(a.id,24,a.color),alt:"",className:"w-6 h-6 rounded-full flex-shrink-0"}),(0,b.jsx)("span",{className:"truncate text-xs font-medium",children:a.name})]},a.id)})]})]}),(0,b.jsxs)("div",{className:"px-5 py-3 border-t border-slate-100 flex justify-end gap-2",children:[(0,b.jsx)("button",{type:"button",className:"px-3 py-1.5 text-xs text-slate-500 hover:text-slate-700 transition-colors",onClick:()=>K(!1),children:"Cancel"}),(0,b.jsx)("button",{type:"button",disabled:!L.trim(),className:"px-3 py-1.5 text-xs font-medium text-white bg-slate-900 rounded-lg hover:bg-slate-800 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",onClick:()=>void aO(),children:"Create"})]})]})}),R&&!V&&(0,b.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30",onClick:()=>S(null),children:(0,b.jsxs)("div",{className:"bg-white rounded-xl shadow-xl border border-slate-200 w-80 max-h-[70vh] flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-slate-100",children:[(0,b.jsxs)("h3",{className:"text-sm font-medium text-slate-900",children:["Add to ",aU?.name??"project"]}),(0,b.jsx)("button",{type:"button",className:"text-slate-400 hover:text-slate-600",onClick:()=>S(null),children:(0,b.jsx)(t.X,{size:16})})]}),(0,b.jsxs)("div",{className:"overflow-y-auto py-1 flex-1",children:[(0,b.jsxs)("button",{type:"button",className:"w-full flex items-center gap-3 px-4 py-2.5 text-sm text-slate-700 hover:bg-slate-50 transition-colors border-b border-slate-100",onClick:()=>W(!0),children:[(0,b.jsx)(o.Plus,{size:14,className:"text-slate-400"}),(0,b.jsx)("span",{className:"text-xs font-medium",children:"Create new agent"})]}),0===aW.length?(0,b.jsx)("p",{className:"px-4 py-6 text-xs text-slate-400 text-center",children:"All agents are already in this project"}):aW.map(a=>{let c=T.has(a.id);return(0,b.jsxs)("button",{type:"button",className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${c?"bg-slate-100 text-slate-900":"text-slate-700 hover:bg-slate-50"}`,onClick:()=>{U(b=>{let c=new Set(b);return c.has(a.id)?c.delete(a.id):c.add(a.id),c})},children:[(0,b.jsx)(aX,{checked:c}),(0,b.jsx)("img",{src:(0,v.agentAvatarUrl)(a.id,24,a.color),alt:"",className:"w-6 h-6 rounded-full flex-shrink-0"}),(0,b.jsx)("div",{className:"min-w-0 flex-1 text-left",children:(0,b.jsx)("div",{className:"truncate font-medium text-xs",children:a.name})})]},a.id)})]}),aW.length>0&&(0,b.jsxs)("div",{className:"px-4 py-3 border-t border-slate-100 flex justify-end gap-2",children:[(0,b.jsx)("button",{type:"button",className:"px-3 py-1.5 text-xs text-slate-500 hover:text-slate-700 transition-colors",onClick:()=>S(null),children:"Cancel"}),(0,b.jsxs)("button",{type:"button",disabled:0===T.size,className:"px-3 py-1.5 text-xs font-medium text-white bg-slate-900 rounded-lg hover:bg-slate-800 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",onClick:()=>{for(let a of T)E(R.projectId,a);S(null)},children:["Add ",T.size>0?`(${T.size})`:""]})]})]})}),V&&(0,b.jsx)(v.AgentForm,{title:"Create new agent",initial:{name:"",provider:"claude",model:"",identity:"",skills:[]},submitLabel:"Create",projects:aN.map(a=>{let b=(a.thread_ids??[]).map(a=>aM.get(a)?.title?.trim()).filter(Boolean).join(", ")||"No thread";return{id:a.id,name:a.name,label:`${b} › ${a.name}`}}),initialProjectIds:R?[R.projectId]:[],onSubmit:async(b,c)=>{let d=["#D97706","#2563EB","#059669","#DC2626","#7C3AED","#DB2777","#0891B2"],e=d[a.length%d.length],f=b.name.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""),g=c?.[0],h=await fetch("/api/participants",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:f,name:b.name,provider:b.provider,model:b.model,color:b.color??e,...b.identity?{identity:b.identity}:{},skills:b.skills??[],...g?{projectId:g}:{}})});if(h.ok){let a=await h.json().catch(()=>({})),b="string"==typeof a?.id&&a.id.trim()?a.id.trim():f;for(let a of(c??[]).slice(1))await E(a,b);W(!1),S(null),aK(),G()}},onCancel:()=>{W(!1)}}),_&&(0,b.jsx)(v.AgentForm,{title:"Edit agent",initial:{name:_.name,provider:_.provider,model:_.model||"",identity:_.identity||"",color:_.color,skills:_.skills||[]},agentId:_.id,submitLabel:"Save",projectMemberships:{current:A.filter(a=>a.agents.some(a=>a.agent_id===_.id)).map(a=>({id:a.id,name:a.name,is_default:!!a.is_default})),available:A.filter(a=>!a.agents.some(a=>a.agent_id===_.id)).map(a=>({id:a.id,name:a.name}))},onAddToProject:a=>E(a,_.id),onRemoveFromProject:a=>F(a,_.id),onSubmit:async a=>{await fetch("/api/participants",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:_.id,name:a.name,provider:a.provider,model:a.model,color:a.color,...a.identity?{identity:a.identity}:{},skills:a.skills??[]})}),aa(null),aK()},onCancel:()=>aa(null)}),X&&(0,b.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30",onClick:()=>Y(null),children:(0,b.jsxs)("div",{className:"bg-white rounded-xl shadow-xl border border-slate-200 w-80 flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-slate-100",children:[(0,b.jsx)("h3",{className:"text-sm font-medium text-slate-900",children:"Rename project"}),(0,b.jsx)("button",{type:"button",className:"text-slate-400 hover:text-slate-600",onClick:()=>Y(null),children:(0,b.jsx)(t.X,{size:16})})]}),(0,b.jsxs)("form",{className:"px-4 py-4 flex flex-col gap-3",onSubmit:a=>{a.preventDefault(),aP()},children:[(0,b.jsx)("input",{autoFocus:!0,type:"text",value:Z,onChange:a=>$(a.target.value),placeholder:"Project name",className:"w-full px-3 py-2 text-sm border border-slate-200 rounded-lg outline-none focus:border-slate-400 focus:ring-1 focus:ring-slate-200 transition-all"}),(0,b.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,b.jsx)("button",{type:"button",className:"px-3 py-1.5 text-xs text-slate-500 hover:text-slate-700 transition-colors",onClick:()=>Y(null),children:"Cancel"}),(0,b.jsx)("button",{type:"submit",disabled:!Z.trim()||Z.trim()===X.currentName,className:"px-3 py-1.5 text-xs font-medium text-white bg-slate-900 rounded-lg hover:bg-slate-800 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:"Save"})]})]})]})}),ap&&(0,b.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30",onClick:()=>aq(!1),children:(0,b.jsxs)("div",{className:"bg-white rounded-xl shadow-xl border border-slate-200 w-[440px] max-h-[80vh] flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-5 py-3.5 border-b border-slate-100",children:[(0,b.jsx)("h3",{className:"text-sm font-medium text-slate-900",children:"Import Agents"}),(0,b.jsx)("button",{type:"button",className:"text-slate-400 hover:text-slate-600",onClick:()=>aq(!1),children:(0,b.jsx)(t.X,{size:16})})]}),"choice"===ar&&!ax&&(0,b.jsxs)("div",{className:"px-5 py-6 flex flex-col gap-3",children:[(0,b.jsxs)("button",{type:"button",className:"flex items-center gap-3 px-4 py-3.5 rounded-lg border border-slate-200 hover:border-violet-300 hover:bg-violet-50 transition-colors text-left",onClick:()=>as("pull"),children:[(0,b.jsx)("div",{className:"w-9 h-9 rounded-lg bg-violet-100 flex items-center justify-center flex-shrink-0",children:(0,b.jsx)(j.Download,{size:16,className:"text-violet-600"})}),(0,b.jsxs)("div",{children:[(0,b.jsx)("p",{className:"text-sm font-medium text-slate-900",children:"Pull from Hub"}),(0,b.jsx)("p",{className:"text-[11px] text-slate-400",children:"Enter a share code to import agents"})]})]}),(0,b.jsxs)("button",{type:"button",className:"flex items-center gap-3 px-4 py-3.5 rounded-lg border border-slate-200 hover:border-slate-300 hover:bg-slate-50 transition-colors text-left",onClick:()=>{as("file"),setTimeout(()=>aH.current?.click(),100)},children:[(0,b.jsx)("div",{className:"w-9 h-9 rounded-lg bg-slate-100 flex items-center justify-center flex-shrink-0",children:(0,b.jsx)(r,{size:16,className:"text-slate-600"})}),(0,b.jsxs)("div",{children:[(0,b.jsx)("p",{className:"text-sm font-medium text-slate-900",children:"Upload File"}),(0,b.jsx)("p",{className:"text-[11px] text-slate-400",children:"Import from a .agent.json bundle"})]})]})]}),"pull"===ar&&!ax&&(0,b.jsxs)("div",{className:"px-5 py-5 flex flex-col gap-3",children:[(0,b.jsx)("label",{className:"text-sm text-slate-600",children:"Enter share code:"}),(0,b.jsx)("input",{autoFocus:!0,type:"text",value:at,onChange:a=>au(a.target.value.toUpperCase()),placeholder:"e.g. A3X9K2",maxLength:6,className:"w-full px-3 py-2.5 text-center text-2xl font-mono font-bold tracking-[0.3em] border border-slate-200 rounded-lg outline-none focus:border-violet-400 focus:ring-1 focus:ring-violet-200 transition-all",onKeyDown:a=>{"Enter"===a.key&&aS()}}),aF&&(0,b.jsx)("p",{className:"text-xs text-red-500",children:aF}),(0,b.jsxs)("div",{className:"flex justify-end gap-2 mt-1",children:[(0,b.jsx)("button",{type:"button",className:"px-3 py-1.5 text-xs text-slate-500 hover:text-slate-700 transition-colors",onClick:()=>{as("choice"),aG(null)},children:"Back"}),(0,b.jsx)("button",{type:"button",disabled:0===at.trim().length||av,className:"px-4 py-1.5 text-xs font-medium text-white bg-violet-600 rounded-lg hover:bg-violet-700 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",onClick:()=>void aS(),children:av?"Fetching...":"Fetch"})]})]}),"file"===ar&&!ax&&(0,b.jsxs)("div",{className:"px-5 py-6 flex flex-col items-center gap-3",children:[(0,b.jsx)("p",{className:"text-sm text-slate-500",children:"Select a .agent.json file to import"}),(0,b.jsxs)("button",{type:"button",className:"inline-flex items-center gap-1.5 px-4 py-2 text-xs font-medium text-slate-600 bg-slate-100 rounded-lg hover:bg-slate-200 transition-colors",onClick:()=>aH.current?.click(),children:[(0,b.jsx)(r,{size:13}),"Choose File"]}),aF&&(0,b.jsx)("p",{className:"text-xs text-red-500",children:aF}),(0,b.jsx)("button",{type:"button",className:"text-xs text-slate-400 hover:text-slate-600 mt-1",onClick:()=>{as("choice"),aG(null)},children:"Back"})]}),ax&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"overflow-y-auto flex-1",children:[ax.exportedAt&&(0,b.jsx)("div",{className:"px-5 py-3 border-b border-slate-100 bg-slate-50",children:(0,b.jsxs)("p",{className:"text-[11px] text-slate-400",children:["Exported ",new Date(ax.exportedAt).toLocaleDateString()," · ",ax.agents.length," agents",x(ax).length>0?`, ${x(ax).length} projects`:""]})}),(0,b.jsxs)("div",{className:"border-b border-slate-100",children:[(0,b.jsxs)("div",{className:"px-5 pt-3 pb-1 flex items-center justify-between",children:[(0,b.jsxs)("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wide",children:[ax.agents.length," agent",1===ax.agents.length?"":"s"," found"]}),(0,b.jsx)("button",{type:"button",className:"text-[11px] text-slate-400 hover:text-slate-600",onClick:()=>{az.size===ax.agents.length?aA(new Set):aA(new Set(ax.agents.map(a=>a.id)))},children:az.size===ax.agents.length?"Deselect all":"Select all"})]}),ax.agents.map(c=>{let d=az.has(c.id),e=a.find(a=>a.id===c.id);return(0,b.jsxs)("button",{type:"button",className:`w-full flex items-center gap-3 px-5 py-2.5 text-sm transition-colors ${d?"bg-slate-50 text-slate-900":"text-slate-600 hover:bg-slate-50"}`,onClick:()=>{aA(a=>{let b=new Set(a);return b.has(c.id)?b.delete(c.id):b.add(c.id),b})},children:[(0,b.jsx)(aX,{checked:d}),(0,b.jsx)("img",{src:(0,v.agentAvatarUrl)(c.id,24,c.color),alt:"",className:"w-6 h-6 rounded-full flex-shrink-0"}),(0,b.jsxs)("div",{className:"min-w-0 flex-1 text-left",children:[(0,b.jsx)("div",{className:"truncate text-xs font-medium",children:c.name}),(0,b.jsxs)("div",{className:"truncate text-[10px] text-slate-400",children:[c.provider,c.model?` \xb7 ${c.model}`:""]})]}),e&&(0,b.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-50 text-amber-600 flex-shrink-0",children:"update"}),!e&&(0,b.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-green-50 text-green-600 flex-shrink-0",children:"new"}),c.self&&(0,b.jsx)("span",{className:"text-[10px] text-slate-400 flex-shrink-0",children:"+ self.md"})]},c.id)})]}),x(ax).length>0&&(0,b.jsxs)("div",{children:[(0,b.jsx)("div",{className:"px-5 pt-3 pb-1",children:(0,b.jsx)("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wide",children:"Projects"})}),x(ax).map(a=>{let c=aB.has(a.name);return(0,b.jsxs)("button",{type:"button",className:`w-full flex items-center gap-3 px-5 py-2 text-sm transition-colors ${c?"bg-slate-50 text-slate-900":"text-slate-600 hover:bg-slate-50"}`,onClick:()=>{aC(b=>{let c=new Set(b);return c.has(a.name)?c.delete(a.name):c.add(a.name),c})},children:[(0,b.jsx)(aX,{checked:c}),(0,b.jsx)(s.Users,{size:14,className:"text-slate-400 flex-shrink-0"}),(0,b.jsx)("span",{className:"truncate text-xs font-medium flex-1",children:a.name}),(0,b.jsxs)("span",{className:"text-[10px] text-slate-400",children:[a.agentIds.length," agents"]})]},a.name)})]})]}),aF&&(0,b.jsx)("div",{className:"px-5 py-2",children:(0,b.jsx)("p",{className:"text-xs text-red-500",children:aF})}),(0,b.jsxs)("div",{className:"px-5 py-3 border-t border-slate-100 flex items-center justify-between",children:[(0,b.jsxs)("span",{className:"text-[11px] text-slate-400",children:[az.size," ",1===az.size?"agent":"agents",aB.size>0?`, ${aB.size} ${1===aB.size?"project":"projects"}`:""]}),(0,b.jsxs)("div",{className:"flex gap-2",children:[(0,b.jsx)("button",{type:"button",className:"px-3 py-1.5 text-xs text-slate-500 hover:text-slate-700 transition-colors",onClick:()=>{ay(null),aA(new Set),aC(new Set)},children:"Back"}),(0,b.jsxs)("button",{type:"button",disabled:0===az.size||aD,className:"inline-flex items-center gap-1.5 px-4 py-1.5 text-xs font-medium text-white bg-violet-600 rounded-lg hover:bg-violet-700 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",onClick:()=>void aT(),children:[(0,b.jsx)(r,{size:12}),aD?"Importing...":`Import ${az.size} agent${1===az.size?"":"s"}`]})]})]})]})]})})]})}a.s(["default",()=>y],84712)}];
1
+ module.exports=[84712,a=>{"use strict";var b=a.i(90944),c=a.i(72131),d=a.i(38246),e=a.i(210),f=a.i(5784),g=a.i(50522),h=a.i(5151),i=a.i(33441),j=a.i(84505),k=a.i(60137);let l=(0,k.default)("eye",[["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"}]]);var m=a.i(2835),n=a.i(99464),o=a.i(15618);let p=(0,k.default)("share-2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),q=(0,k.default)("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);var r=a.i(60246),s=a.i(33508),t=a.i(56196),u=a.i(20138),v=a.i(89116);function w(a){return a?a.projects??[]:[]}function x(){let[a,k]=(0,c.useState)([]),[x,y]=(0,c.useState)([]),{projects:z,createProject:A,addAgent:B,removeAgent:C,refresh:D}=(0,t.useProjectsWithAgents)(),[E,F]=(0,c.useState)(new Set),[G,H]=(0,c.useState)(null),[I,J]=(0,c.useState)(new Set),[K,L]=(0,c.useState)(!1),[M,N]=(0,c.useState)(null),[O,P]=(0,c.useState)(!1),[Q,R]=(0,c.useState)(new Set),[S,T]=(0,c.useState)(!0),[U,V]=(0,c.useState)(!1),[W,X]=(0,c.useState)(null),[Y,Z]=(0,c.useState)(null),[$,_]=(0,c.useState)(!1),[aa,ab]=(0,c.useState)(!1),[ac,ad]=(0,c.useState)("choice"),[ae,af]=(0,c.useState)(""),[ag,ah]=(0,c.useState)(!1),[ai,aj]=(0,c.useState)(null),[ak,al]=(0,c.useState)(new Set),[am,an]=(0,c.useState)(new Set),[ao,ap]=(0,c.useState)(!1),[aq,ar]=(0,c.useState)(null),as=(0,c.useRef)(null),[at,au]=(0,c.useState)(new Set),av=()=>{fetch("/api/participants").then(a=>a.json()).then(a=>k(Array.isArray(a)?a:[]))},aw=(0,c.useCallback)(async()=>{try{let a=await fetch("/api/processes");if(!a.ok)return;let b=await a.json();au(new Set(b.filter(a=>"spawning"===a.state||"running"===a.state).map(a=>a.agentId)))}catch{}},[]);(0,c.useEffect)(()=>{av(),v.threadService.listThreads().then(y),aw();let a=setInterval(aw,3e3);return()=>clearInterval(a)},[aw]);let ax=new Map(x.map(a=>[a.id,a])),ay=z.filter(a=>!a.is_default),az=async()=>{if(0!==Q.size){V(!0);try{let a=await fetch("/api/agent-specs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentIds:Array.from(Q),includeSelf:S})});if(!a.ok)throw Error("Share failed");let b=await a.json();X(b.code),Z(b.expires_at)}catch(a){console.error("Share error:",a)}finally{V(!1)}}},aA=async()=>{if(0!==Q.size){V(!0);try{let a=Array.from(Q),b=await fetch("/api/agents/export",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentIds:a})});if(!b.ok)throw Error("Export failed");let c=(await b.json()).agents.map(a=>({...a,self:S?a.self:null})),d={version:1,exportedAt:new Date().toISOString(),agents:c,projects:[]},e=new Blob([JSON.stringify(d,null,2)],{type:"application/json"}),f=URL.createObjectURL(e),g=document.createElement("a");g.href=f,g.download=1===c.length?`${c[0].name.toLowerCase().replace(/\s+/g,"-")}.agent.json`:"agents.bundle.json",g.click(),URL.revokeObjectURL(f),P(!1)}catch(a){console.error("Export error:",a)}finally{V(!1)}}},aB=async()=>{if(0!==ae.trim().length){ah(!0),ar(null),aj(null);try{let a=await fetch(`/api/agent-specs/pull?code=${encodeURIComponent(ae.trim())}`);if(!a.ok){let b=await a.json().catch(()=>({error:"Failed to pull"}));ar(b.error||"Code not found or expired");return}let b=(await a.json()).bundle;aj(b),al(new Set(b.agents.map(a=>a.id))),an(new Set(w(b).map(a=>a.name)))}catch{ar("Failed to connect. Is agx-api running?")}finally{ah(!1)}}},aC=async()=>{if(ai){ap(!0);try{let b=new Set(a.map(a=>a.id));for(let a of ai.agents){if(!ak.has(a.id))continue;let c={name:a.name,provider:a.provider,model:a.model,color:a.color,identity:a.identity||void 0,identityFile:a.identityFile||void 0,skills:a.skills||[],variables:a.variables||{}};b.has(a.id)?(c.id=a.id,await fetch("/api/participants",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)})):await fetch("/api/participants",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)})}for(let a of w(ai)){if(!am.has(a.name))continue;let b=await A(a.name);if(b)for(let c of a.agentIds)ak.has(c)&&await B(b.id,c)}av(),await D(),ab(!1),aj(null)}catch(a){console.error("Import error:",a),ar("Import failed. Check console for details.")}finally{ap(!1)}}},aD=G?z.find(a=>a.id===G.projectId):null,aE=new Set(aD?.agents.map(a=>a.agent_id)??[]),aF=G?a.filter(a=>!aE.has(a.id)):[],aG=({checked:a})=>(0,b.jsx)("div",{className:`w-4 h-4 rounded border flex-shrink-0 flex items-center justify-center ${a?"bg-slate-900 border-slate-900":"border-slate-300"}`,children:a&&(0,b.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:(0,b.jsx)("path",{d:"M2 5l2 2 4-4",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})});return(0,b.jsxs)("div",{className:"min-h-screen bg-slate-50 p-6",children:[(0,b.jsxs)("div",{className:"max-w-6xl mx-auto",children:[(0,b.jsxs)("div",{className:"flex items-center gap-3 mb-6",children:[(0,b.jsxs)(d.default,{href:"/",className:"inline-flex items-center gap-1 text-sm text-slate-500 hover:text-slate-700 transition-colors",children:[(0,b.jsx)(e.ArrowLeft,{size:16}),"Back"]}),(0,b.jsx)("h1",{className:"text-2xl font-semibold text-slate-900",children:"Manage Agents"}),(0,b.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,b.jsxs)("button",{type:"button",className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-white bg-slate-900 rounded-lg hover:bg-slate-800 transition-colors",onClick:()=>L(!0),children:[(0,b.jsx)(o.Plus,{size:13}),"New Agent"]}),(0,b.jsxs)("button",{type:"button",className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-white bg-violet-600 rounded-lg hover:bg-violet-700 transition-colors",onClick:()=>{R(new Set(a.map(a=>a.id))),T(!0),X(null),Z(null),_(!1),P(!0)},disabled:0===a.length,children:[(0,b.jsx)(p,{size:13}),"Share"]}),(0,b.jsxs)("button",{type:"button",className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-violet-600 bg-violet-50 border border-violet-200 rounded-lg hover:bg-violet-100 transition-colors",onClick:()=>{ad("choice"),af(""),aj(null),al(new Set),an(new Set),ar(null),ab(!0)},children:[(0,b.jsx)(j.Download,{size:13}),"Import"]}),(0,b.jsx)("input",{ref:as,type:"file",accept:".json",className:"hidden",onChange:a=>{let b=a.target.files?.[0];if(!b)return;ar(null);let c=new FileReader;c.onload=()=>{try{let a=JSON.parse(c.result);if(!a.version||!Array.isArray(a.agents))throw Error("Invalid bundle format");aj(a),al(new Set(a.agents.map(a=>a.id))),an(new Set(w(a).map(a=>a.name)))}catch{ar("Invalid file. Expected an .agent.json bundle.")}},c.readAsText(b),a.target.value=""}})]})]}),aq&&!aa&&(0,b.jsxs)("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-50 border border-red-200 text-sm text-red-700 flex items-center justify-between",children:[(0,b.jsx)("span",{children:aq}),(0,b.jsx)("button",{type:"button",onClick:()=>ar(null),className:"text-red-400 hover:text-red-600",children:(0,b.jsx)(s.X,{size:14})})]}),0===a.length?(0,b.jsx)("p",{className:"text-slate-500 text-sm",children:"No agents configured yet."}):(0,b.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:a.map(a=>(0,b.jsxs)("div",{className:"bg-white rounded-xl border border-slate-200 p-4 hover:shadow-md transition-shadow text-left group",children:[(0,b.jsxs)("div",{className:"flex items-start gap-3 mb-3",children:[(0,b.jsx)("img",{src:(0,u.agentAvatarUrl)(a.id,48,a.color),alt:a.name,className:"w-12 h-12 rounded-full bg-slate-100"}),(0,b.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,b.jsx)("h3",{className:"font-medium text-slate-900 truncate",children:a.name}),(0,b.jsx)("p",{className:"text-xs text-slate-400 truncate mt-0.5",children:a.model}),at.has(a.id)&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 mt-1 text-[10px] font-medium text-emerald-600",children:[(0,b.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"}),"Working"]})]})]}),a.skills&&a.skills.length>0&&(0,b.jsxs)("div",{className:"flex flex-wrap gap-1 mb-3",children:[a.skills.slice(0,3).map((a,c)=>(0,b.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-blue-50 text-blue-600 truncate max-w-[120px]",children:a.file.split("/").pop()},c)),a.skills.length>3&&(0,b.jsxs)("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-50 text-slate-400",children:["+",a.skills.length-3]})]}),(0,b.jsxs)("div",{className:"flex items-center justify-between pt-2 border-t border-slate-100",children:[(0,b.jsx)("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded-full bg-slate-100 text-slate-600 uppercase tracking-wide",children:a.provider}),(0,b.jsxs)("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[(0,b.jsx)("button",{type:"button",title:"Edit",onClick:()=>N(a),className:"p-1.5 text-slate-400 hover:text-slate-600 rounded hover:bg-slate-50 transition-colors",children:(0,b.jsx)(n.Pencil,{size:13})}),(0,b.jsx)(d.default,{href:`/agents/${a.id}`,title:"View profile",className:"p-1.5 text-slate-400 hover:text-slate-600 rounded hover:bg-slate-50 transition-colors",children:(0,b.jsx)(l,{size:13})})]})]})]},a.id))}),(0,b.jsxs)("div",{className:"mt-10",children:[(0,b.jsxs)("div",{className:"mb-4",children:[(0,b.jsx)("h2",{className:"text-lg font-semibold text-slate-900",children:"Project assignments"}),(0,b.jsx)("p",{className:"mt-1 text-sm text-slate-400",children:"Assign agents to existing projects."})]}),0===ay.length?(0,b.jsx)("p",{className:"text-sm text-slate-400",children:"No projects available for assignment."}):(0,b.jsx)("div",{className:"bg-white rounded-xl border border-slate-200 divide-y divide-slate-100",children:ay.map(c=>{let d=E.has(c.id),e=(c.thread_ids??[]).map(a=>ax.get(a)?.title?.trim()||"Untitled").filter(Boolean);return(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"flex items-center gap-3 px-5 py-3.5 group",children:[(0,b.jsxs)("button",{type:"button",className:"flex items-center gap-3 flex-1 min-w-0 text-left",onClick:()=>{var a;return a=c.id,void F(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},children:[d?(0,b.jsx)(f.ChevronDown,{size:16,className:"text-slate-400 flex-shrink-0"}):(0,b.jsx)(g.ChevronRight,{size:16,className:"text-slate-400 flex-shrink-0"}),(0,b.jsx)(r.Users,{size:16,className:"text-slate-400 flex-shrink-0"}),(0,b.jsx)("span",{className:"font-medium text-slate-800 text-sm",children:c.name}),(0,b.jsxs)("span",{className:"text-xs text-slate-400",children:[c.agents.length," ",1===c.agents.length?"agent":"agents",e.length>0&&` \xb7 ${e.length} ${1===e.length?"thread":"threads"}`]})]}),(0,b.jsx)("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:(0,b.jsxs)("button",{type:"button",className:"inline-flex items-center gap-1.5 rounded-lg border border-slate-200 px-2.5 py-1.5 text-xs font-medium text-slate-600 transition-colors hover:bg-slate-50 hover:text-slate-900",title:"Add agents",onClick:()=>{J(new Set),H({projectId:c.id})},children:[(0,b.jsx)(o.Plus,{size:14}),"Add agents"]})})]}),d&&(0,b.jsxs)("div",{className:"px-5 pb-4 pt-1 ml-9 flex flex-col gap-1",children:[0===c.agents.length&&(0,b.jsx)("p",{className:"text-xs text-slate-400 py-1",children:"No agents in this project."}),c.agents.map(d=>{let e=a.find(a=>a.id===d.agent_id);return(0,b.jsxs)("div",{className:"flex items-center gap-2.5 py-1.5 group/agent",children:[(0,b.jsx)("img",{src:(0,u.agentAvatarUrl)(d.agent_id,24,e?.color),alt:"",className:"w-6 h-6 rounded-full flex-shrink-0"}),(0,b.jsx)("span",{className:"text-sm text-slate-700 truncate flex-1",children:e?.name??d.agent_id}),(0,b.jsx)("span",{className:"text-[10px] text-slate-400",children:e?.model}),(0,b.jsx)("button",{type:"button",className:"opacity-0 group-hover/agent:opacity-100 text-slate-400 hover:text-red-500 transition-opacity",onClick:()=>void C(c.id,d.agent_id),title:"Remove from project",children:(0,b.jsx)(s.X,{size:14})})]},d.agent_id)}),(0,b.jsxs)("button",{type:"button",className:"mt-2 inline-flex items-center gap-1.5 self-start rounded-lg border border-slate-200 px-2.5 py-1.5 text-xs font-medium text-slate-600 transition-colors hover:bg-slate-50 hover:text-slate-900",onClick:()=>{J(new Set),H({projectId:c.id})},children:[(0,b.jsx)(o.Plus,{size:12}),"Add agents"]}),e.length>0&&(0,b.jsxs)("div",{className:"mt-2 pt-2 border-t border-slate-100",children:[(0,b.jsx)("p",{className:"text-[10px] font-medium text-slate-400 uppercase tracking-wide mb-1",children:"Threads"}),(0,b.jsx)("div",{className:"flex flex-wrap gap-1.5",children:e.map((a,c)=>(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 text-xs px-2 py-1 rounded-md bg-indigo-50 text-indigo-600",children:[(0,b.jsx)(m.Hash,{size:11}),a]},c))})]})]})]},c.id)})})]})]}),O&&(0,b.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30",onClick:()=>P(!1),children:(0,b.jsxs)("div",{className:"bg-white rounded-xl shadow-xl border border-slate-200 w-[440px] max-h-[80vh] flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-5 py-3.5 border-b border-slate-100",children:[(0,b.jsx)("h3",{className:"text-sm font-medium text-slate-900",children:"Share Agents"}),(0,b.jsx)("button",{type:"button",className:"text-slate-400 hover:text-slate-600",onClick:()=>P(!1),children:(0,b.jsx)(s.X,{size:16})})]}),W?(0,b.jsxs)("div",{className:"px-5 py-6 flex flex-col items-center gap-4",children:[(0,b.jsxs)("div",{className:"text-center",children:[(0,b.jsx)("p",{className:"text-sm text-slate-600 mb-3",children:"Share this code with the recipient:"}),(0,b.jsxs)("div",{className:"flex items-center justify-center gap-3",children:[(0,b.jsx)("span",{className:"text-3xl font-mono font-bold tracking-[0.3em] text-slate-900",children:W}),(0,b.jsx)("button",{type:"button",className:"p-2 text-slate-400 hover:text-slate-600 transition-colors",onClick:()=>{W&&(navigator.clipboard.writeText(W),_(!0),setTimeout(()=>_(!1),2e3))},children:$?(0,b.jsx)(i.Check,{size:18,className:"text-green-500"}):(0,b.jsx)(h.Copy,{size:18})})]})]}),Y&&(0,b.jsxs)("p",{className:"text-[11px] text-slate-400",children:["Expires ",new Date(Y).toLocaleTimeString()]}),(0,b.jsx)("button",{type:"button",className:"px-4 py-2 text-xs font-medium text-slate-600 bg-slate-100 rounded-lg hover:bg-slate-200 transition-colors",onClick:()=>P(!1),children:"Done"})]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"overflow-y-auto flex-1",children:[ay.length>0&&(0,b.jsxs)("div",{className:"border-b border-slate-100 px-5 py-3",children:[(0,b.jsx)("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wide mb-2",children:"Select by project"}),(0,b.jsx)("div",{className:"flex flex-wrap gap-1.5",children:ay.map(c=>{let d=c.agents.map(a=>a.agent_id),e=d.length>0&&d.every(a=>Q.has(a)),f=d.some(a=>Q.has(a));return(0,b.jsxs)("button",{type:"button",className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-[11px] font-medium transition-colors ${e?"bg-slate-900 text-white":f?"bg-slate-300 text-slate-700":"bg-slate-100 text-slate-600 hover:bg-slate-200"}`,onClick:()=>{R(a=>{let b=new Set(a);return e?d.forEach(a=>b.delete(a)):d.forEach(a=>b.add(a)),b})},title:d.map(b=>a.find(a=>a.id===b)?.name??b).join(", "),children:[(0,b.jsx)(r.Users,{size:10}),c.name,(0,b.jsx)("span",{className:`text-[10px] ${e?"text-slate-300":"text-slate-400"}`,children:c.agents.length})]},c.id)})})]}),(0,b.jsxs)("div",{className:"border-b border-slate-100",children:[(0,b.jsxs)("div",{className:"px-5 pt-3 pb-1 flex items-center justify-between",children:[(0,b.jsx)("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wide",children:"Agents"}),(0,b.jsx)("button",{type:"button",className:"text-[11px] text-slate-400 hover:text-slate-600",onClick:()=>{Q.size===a.length?R(new Set):R(new Set(a.map(a=>a.id)))},children:Q.size===a.length?"Deselect all":"Select all"})]}),a.map(a=>{let c=Q.has(a.id);return(0,b.jsxs)("button",{type:"button",className:`w-full flex items-center gap-3 px-5 py-2 text-sm transition-colors ${c?"bg-slate-50 text-slate-900":"text-slate-600 hover:bg-slate-50"}`,onClick:()=>{R(b=>{let c=new Set(b);return c.has(a.id)?c.delete(a.id):c.add(a.id),c})},children:[(0,b.jsx)(aG,{checked:c}),(0,b.jsx)("img",{src:(0,u.agentAvatarUrl)(a.id,24,a.color),alt:"",className:"w-6 h-6 rounded-full flex-shrink-0"}),(0,b.jsx)("span",{className:"truncate text-xs font-medium flex-1",children:a.name}),(0,b.jsx)("span",{className:"text-[10px] text-slate-400",children:a.provider})]},a.id)})]}),(0,b.jsx)("div",{className:"px-5 py-3",children:(0,b.jsxs)("button",{type:"button",className:`flex items-center gap-3 w-full px-3 py-2 rounded-lg text-sm transition-colors ${S?"bg-slate-50 text-slate-900":"text-slate-600 hover:bg-slate-50"}`,onClick:()=>T(!S),children:[(0,b.jsx)(aG,{checked:S}),(0,b.jsx)("span",{className:"text-xs font-medium",children:"Include self.md (agent bio)"})]})})]}),(0,b.jsxs)("div",{className:"px-5 py-3 border-t border-slate-100 flex items-center justify-between",children:[(0,b.jsxs)("span",{className:"text-[11px] text-slate-400",children:[Q.size," ",1===Q.size?"agent":"agents"]}),(0,b.jsxs)("div",{className:"flex gap-2",children:[(0,b.jsxs)("button",{type:"button",disabled:0===Q.size||U,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-slate-600 bg-white border border-slate-200 rounded-lg hover:bg-slate-50 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",onClick:()=>void aA(),children:[(0,b.jsx)(j.Download,{size:12}),U?"Exporting...":"Export to File"]}),(0,b.jsxs)("button",{type:"button",disabled:0===Q.size||U,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-white bg-violet-600 rounded-lg hover:bg-violet-700 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",onClick:()=>void az(),children:[(0,b.jsx)(p,{size:12}),U?"Pushing...":"Push to Hub"]}),(0,b.jsx)("button",{type:"button",className:"px-3 py-1.5 text-xs text-slate-500 hover:text-slate-700 transition-colors",onClick:()=>P(!1),children:"Cancel"})]})]})]})]})}),G&&!K&&(0,b.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30",onClick:()=>H(null),children:(0,b.jsxs)("div",{className:"bg-white rounded-xl shadow-xl border border-slate-200 w-80 max-h-[70vh] flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-slate-100",children:[(0,b.jsxs)("h3",{className:"text-sm font-medium text-slate-900",children:["Add to ",aD?.name??"project"]}),(0,b.jsx)("button",{type:"button",className:"text-slate-400 hover:text-slate-600",onClick:()=>H(null),children:(0,b.jsx)(s.X,{size:16})})]}),(0,b.jsxs)("div",{className:"overflow-y-auto py-1 flex-1",children:[(0,b.jsxs)("button",{type:"button",className:"w-full flex items-center gap-3 px-4 py-2.5 text-sm text-slate-700 hover:bg-slate-50 transition-colors border-b border-slate-100",onClick:()=>L(!0),children:[(0,b.jsx)(o.Plus,{size:14,className:"text-slate-400"}),(0,b.jsx)("span",{className:"text-xs font-medium",children:"Create new agent"})]}),0===aF.length?(0,b.jsx)("p",{className:"px-4 py-6 text-xs text-slate-400 text-center",children:"All agents are already in this project"}):aF.map(a=>{let c=I.has(a.id);return(0,b.jsxs)("button",{type:"button",className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${c?"bg-slate-100 text-slate-900":"text-slate-700 hover:bg-slate-50"}`,onClick:()=>{J(b=>{let c=new Set(b);return c.has(a.id)?c.delete(a.id):c.add(a.id),c})},children:[(0,b.jsx)(aG,{checked:c}),(0,b.jsx)("img",{src:(0,u.agentAvatarUrl)(a.id,24,a.color),alt:"",className:"w-6 h-6 rounded-full flex-shrink-0"}),(0,b.jsx)("div",{className:"min-w-0 flex-1 text-left",children:(0,b.jsx)("div",{className:"truncate font-medium text-xs",children:a.name})})]},a.id)})]}),aF.length>0&&(0,b.jsxs)("div",{className:"px-4 py-3 border-t border-slate-100 flex justify-end gap-2",children:[(0,b.jsx)("button",{type:"button",className:"px-3 py-1.5 text-xs text-slate-500 hover:text-slate-700 transition-colors",onClick:()=>H(null),children:"Cancel"}),(0,b.jsxs)("button",{type:"button",disabled:0===I.size,className:"px-3 py-1.5 text-xs font-medium text-white bg-slate-900 rounded-lg hover:bg-slate-800 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",onClick:()=>{for(let a of I)B(G.projectId,a);H(null)},children:["Add ",I.size>0?`(${I.size})`:""]})]})]})}),K&&(0,b.jsx)(u.AgentForm,{title:"Create new agent",initial:{name:"",provider:"claude",model:"",identity:"",skills:[]},submitLabel:"Create",projects:ay.map(a=>{let b=(a.thread_ids??[]).map(a=>ax.get(a)?.title?.trim()).filter(Boolean).join(", ")||"No thread";return{id:a.id,name:a.name,label:`${b} › ${a.name}`}}),initialProjectIds:G?[G.projectId]:[],onSubmit:async(b,c)=>{let d=["#D97706","#2563EB","#059669","#DC2626","#7C3AED","#DB2777","#0891B2"],e=d[a.length%d.length],f=b.name.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""),g=c?.[0],h=await fetch("/api/participants",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:f,name:b.name,provider:b.provider,model:b.model,color:b.color??e,...b.identity?{identity:b.identity}:{},skills:b.skills??[],...g?{projectId:g}:{}})});if(h.ok){let a=await h.json().catch(()=>({})),b="string"==typeof a?.id&&a.id.trim()?a.id.trim():f;for(let a of(c??[]).slice(1))await B(a,b);L(!1),H(null),av(),D()}},onCancel:()=>{L(!1)}}),M&&(0,b.jsx)(u.AgentForm,{title:"Edit agent",initial:{name:M.name,provider:M.provider,model:M.model||"",identity:M.identity||"",color:M.color,skills:M.skills||[]},agentId:M.id,submitLabel:"Save",projectMemberships:{current:z.filter(a=>a.agents.some(a=>a.agent_id===M.id)).map(a=>({id:a.id,name:a.name,is_default:!!a.is_default})),available:z.filter(a=>!a.agents.some(a=>a.agent_id===M.id)).map(a=>({id:a.id,name:a.name}))},onAddToProject:a=>B(a,M.id),onRemoveFromProject:a=>C(a,M.id),onSubmit:async a=>{await fetch("/api/participants",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:M.id,name:a.name,provider:a.provider,model:a.model,color:a.color,...a.identity?{identity:a.identity}:{},skills:a.skills??[]})}),N(null),av()},onCancel:()=>N(null)}),aa&&(0,b.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30",onClick:()=>ab(!1),children:(0,b.jsxs)("div",{className:"bg-white rounded-xl shadow-xl border border-slate-200 w-[440px] max-h-[80vh] flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-5 py-3.5 border-b border-slate-100",children:[(0,b.jsx)("h3",{className:"text-sm font-medium text-slate-900",children:"Import Agents"}),(0,b.jsx)("button",{type:"button",className:"text-slate-400 hover:text-slate-600",onClick:()=>ab(!1),children:(0,b.jsx)(s.X,{size:16})})]}),"choice"===ac&&!ai&&(0,b.jsxs)("div",{className:"px-5 py-6 flex flex-col gap-3",children:[(0,b.jsxs)("button",{type:"button",className:"flex items-center gap-3 px-4 py-3.5 rounded-lg border border-slate-200 hover:border-violet-300 hover:bg-violet-50 transition-colors text-left",onClick:()=>ad("pull"),children:[(0,b.jsx)("div",{className:"w-9 h-9 rounded-lg bg-violet-100 flex items-center justify-center flex-shrink-0",children:(0,b.jsx)(j.Download,{size:16,className:"text-violet-600"})}),(0,b.jsxs)("div",{children:[(0,b.jsx)("p",{className:"text-sm font-medium text-slate-900",children:"Pull from Hub"}),(0,b.jsx)("p",{className:"text-[11px] text-slate-400",children:"Enter a share code to import agents"})]})]}),(0,b.jsxs)("button",{type:"button",className:"flex items-center gap-3 px-4 py-3.5 rounded-lg border border-slate-200 hover:border-slate-300 hover:bg-slate-50 transition-colors text-left",onClick:()=>{ad("file"),setTimeout(()=>as.current?.click(),100)},children:[(0,b.jsx)("div",{className:"w-9 h-9 rounded-lg bg-slate-100 flex items-center justify-center flex-shrink-0",children:(0,b.jsx)(q,{size:16,className:"text-slate-600"})}),(0,b.jsxs)("div",{children:[(0,b.jsx)("p",{className:"text-sm font-medium text-slate-900",children:"Upload File"}),(0,b.jsx)("p",{className:"text-[11px] text-slate-400",children:"Import from a .agent.json bundle"})]})]})]}),"pull"===ac&&!ai&&(0,b.jsxs)("div",{className:"px-5 py-5 flex flex-col gap-3",children:[(0,b.jsx)("label",{className:"text-sm text-slate-600",children:"Enter share code:"}),(0,b.jsx)("input",{autoFocus:!0,type:"text",value:ae,onChange:a=>af(a.target.value.toUpperCase()),placeholder:"e.g. A3X9K2",maxLength:6,className:"w-full px-3 py-2.5 text-center text-2xl font-mono font-bold tracking-[0.3em] border border-slate-200 rounded-lg outline-none focus:border-violet-400 focus:ring-1 focus:ring-violet-200 transition-all",onKeyDown:a=>{"Enter"===a.key&&aB()}}),aq&&(0,b.jsx)("p",{className:"text-xs text-red-500",children:aq}),(0,b.jsxs)("div",{className:"flex justify-end gap-2 mt-1",children:[(0,b.jsx)("button",{type:"button",className:"px-3 py-1.5 text-xs text-slate-500 hover:text-slate-700 transition-colors",onClick:()=>{ad("choice"),ar(null)},children:"Back"}),(0,b.jsx)("button",{type:"button",disabled:0===ae.trim().length||ag,className:"px-4 py-1.5 text-xs font-medium text-white bg-violet-600 rounded-lg hover:bg-violet-700 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",onClick:()=>void aB(),children:ag?"Fetching...":"Fetch"})]})]}),"file"===ac&&!ai&&(0,b.jsxs)("div",{className:"px-5 py-6 flex flex-col items-center gap-3",children:[(0,b.jsx)("p",{className:"text-sm text-slate-500",children:"Select a .agent.json file to import"}),(0,b.jsxs)("button",{type:"button",className:"inline-flex items-center gap-1.5 px-4 py-2 text-xs font-medium text-slate-600 bg-slate-100 rounded-lg hover:bg-slate-200 transition-colors",onClick:()=>as.current?.click(),children:[(0,b.jsx)(q,{size:13}),"Choose File"]}),aq&&(0,b.jsx)("p",{className:"text-xs text-red-500",children:aq}),(0,b.jsx)("button",{type:"button",className:"text-xs text-slate-400 hover:text-slate-600 mt-1",onClick:()=>{ad("choice"),ar(null)},children:"Back"})]}),ai&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"overflow-y-auto flex-1",children:[ai.exportedAt&&(0,b.jsx)("div",{className:"px-5 py-3 border-b border-slate-100 bg-slate-50",children:(0,b.jsxs)("p",{className:"text-[11px] text-slate-400",children:["Exported ",new Date(ai.exportedAt).toLocaleDateString()," · ",ai.agents.length," agents",w(ai).length>0?`, ${w(ai).length} projects`:""]})}),(0,b.jsxs)("div",{className:"border-b border-slate-100",children:[(0,b.jsxs)("div",{className:"px-5 pt-3 pb-1 flex items-center justify-between",children:[(0,b.jsxs)("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wide",children:[ai.agents.length," agent",1===ai.agents.length?"":"s"," found"]}),(0,b.jsx)("button",{type:"button",className:"text-[11px] text-slate-400 hover:text-slate-600",onClick:()=>{ak.size===ai.agents.length?al(new Set):al(new Set(ai.agents.map(a=>a.id)))},children:ak.size===ai.agents.length?"Deselect all":"Select all"})]}),ai.agents.map(c=>{let d=ak.has(c.id),e=a.find(a=>a.id===c.id);return(0,b.jsxs)("button",{type:"button",className:`w-full flex items-center gap-3 px-5 py-2.5 text-sm transition-colors ${d?"bg-slate-50 text-slate-900":"text-slate-600 hover:bg-slate-50"}`,onClick:()=>{al(a=>{let b=new Set(a);return b.has(c.id)?b.delete(c.id):b.add(c.id),b})},children:[(0,b.jsx)(aG,{checked:d}),(0,b.jsx)("img",{src:(0,u.agentAvatarUrl)(c.id,24,c.color),alt:"",className:"w-6 h-6 rounded-full flex-shrink-0"}),(0,b.jsxs)("div",{className:"min-w-0 flex-1 text-left",children:[(0,b.jsx)("div",{className:"truncate text-xs font-medium",children:c.name}),(0,b.jsxs)("div",{className:"truncate text-[10px] text-slate-400",children:[c.provider,c.model?` \xb7 ${c.model}`:""]})]}),e&&(0,b.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-50 text-amber-600 flex-shrink-0",children:"update"}),!e&&(0,b.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-green-50 text-green-600 flex-shrink-0",children:"new"}),c.self&&(0,b.jsx)("span",{className:"text-[10px] text-slate-400 flex-shrink-0",children:"+ self.md"})]},c.id)})]}),w(ai).length>0&&(0,b.jsxs)("div",{children:[(0,b.jsx)("div",{className:"px-5 pt-3 pb-1",children:(0,b.jsx)("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wide",children:"Projects"})}),w(ai).map(a=>{let c=am.has(a.name);return(0,b.jsxs)("button",{type:"button",className:`w-full flex items-center gap-3 px-5 py-2 text-sm transition-colors ${c?"bg-slate-50 text-slate-900":"text-slate-600 hover:bg-slate-50"}`,onClick:()=>{an(b=>{let c=new Set(b);return c.has(a.name)?c.delete(a.name):c.add(a.name),c})},children:[(0,b.jsx)(aG,{checked:c}),(0,b.jsx)(r.Users,{size:14,className:"text-slate-400 flex-shrink-0"}),(0,b.jsx)("span",{className:"truncate text-xs font-medium flex-1",children:a.name}),(0,b.jsxs)("span",{className:"text-[10px] text-slate-400",children:[a.agentIds.length," agents"]})]},a.name)})]})]}),aq&&(0,b.jsx)("div",{className:"px-5 py-2",children:(0,b.jsx)("p",{className:"text-xs text-red-500",children:aq})}),(0,b.jsxs)("div",{className:"px-5 py-3 border-t border-slate-100 flex items-center justify-between",children:[(0,b.jsxs)("span",{className:"text-[11px] text-slate-400",children:[ak.size," ",1===ak.size?"agent":"agents",am.size>0?`, ${am.size} ${1===am.size?"project":"projects"}`:""]}),(0,b.jsxs)("div",{className:"flex gap-2",children:[(0,b.jsx)("button",{type:"button",className:"px-3 py-1.5 text-xs text-slate-500 hover:text-slate-700 transition-colors",onClick:()=>{aj(null),al(new Set),an(new Set)},children:"Back"}),(0,b.jsxs)("button",{type:"button",disabled:0===ak.size||ao,className:"inline-flex items-center gap-1.5 px-4 py-1.5 text-xs font-medium text-white bg-violet-600 rounded-lg hover:bg-violet-700 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",onClick:()=>void aC(),children:[(0,b.jsx)(q,{size:12}),ao?"Importing...":`Import ${ak.size} agent${1===ak.size?"":"s"}`]})]})]})]})]})})]})}a.s(["default",()=>x],84712)}];
2
2
 
3
3
  //# sourceMappingURL=app_agents_page_tsx_f5f08ed8._.js.map
@@ -1,3 +1,3 @@
1
- module.exports=[86976,82434,92596,55672,a=>{"use strict";var b=a.i(90944),c=a.i(72131),d=a.i(5784),e=a.i(50522),f=a.i(2835),g=a.i(60137);let h=(0,g.default)("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);a.s(["Bot",()=>h],82434);let i=(0,g.default)("folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);a.s(["Folder",()=>i],92596);let j=(0,g.default)("folder-git-2",[["path",{d:"M18 19a5 5 0 0 1-5-5v8",key:"sz5oeg"}],["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"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]]),k=(0,g.default)("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);var l=a.i(99464),m=a.i(15618),n=a.i(87532),o=a.i(81560);let p=(0,g.default)("layout-dashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);var q=a.i(33508),r=a.i(38246),s=a.i(20138),t=a.i(44637);function u({threads:a,participants:g=[],activeThreadId:u,isLoading:v,isCreating:w,onSelectThread:x,onCreateThread:y,onRenameThread:z,onDeleteThread:A,deletingThreadId:B=null,renamingThreadId:C=null,activeParticipantIds:D=[],onToggleParticipantActive:E,visible:F=!1,isRestoringActiveThread:G=!1,onToggle:H,onSearch:I,projects:J=[],onCreateProject:K,onUpdateProject:L,onDeleteProject:M,onAddAgentToProject:N,onRemoveAgentFromProject:O,onAddAgentViaForm:P,onReorderProjectAgents:Q,onUpdateParticipant:R,onSelectProject:S}){let T,U,V=(0,c.useRef)(null),[W,X]=(0,c.useState)(new Set),[Y,Z]=(0,c.useState)(null),[$,_]=(0,c.useState)(new Set),[aa,ab]=(0,c.useState)(!1),[ac,ad]=(0,c.useState)(null),[ae,af]=(0,c.useState)(null),ag=(0,t.useProjectFormState)(),[ah,ai]=(0,c.useState)(null),aj=(0,c.useCallback)(a=>{a&&(a.focus(),a.select())},[]),[ak,al]=(0,c.useState)(null),[am,an]=(0,c.useState)(null),ao=am?g.find(a=>a.id===am)??null:null,[ap,aq]=(0,c.useState)(null),[ar,as]=(0,c.useState)(null),at=a=>{X(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},au=async()=>{if(!ac&&!ae)return;if(!ag.form.name.trim())return void ag.setFormError("Project name is required");let a=ag.repos.find(a=>a.name.trim()&&!a.path.trim());if(a)return void ag.setFormError(`Local path is required for repository "${a.name}"`);ag.setFormError(null),ag.setIsSubmitting(!0);let b=(0,t.createProjectPayload)(ag.form,ag.repos);ae?await L?.(ae.id,b):await K?.(b,ac?.threadId),ag.setIsSubmitting(!1),ad(null),af(null)},av=async a=>{ag.resetForm();try{let b=await fetch(`/api/projects/${a}`);if(!b.ok)throw Error("Failed to load project");let c=(await b.json()).project;af(c),ag.hydrateFromProject(c)}catch(a){console.error("Failed to load project settings",a)}};(0,c.useEffect)(()=>{let a=!1;async function b(){if(ap?.repoId)try{let b=await fetch(`/api/repos/${ap.repoId}/knowledge?producer=system`),c=b.ok?await b.json():{knowledge:[]};a||aq(a=>a&&a.repoId===ap.repoId?{...a,generatedKnowledge:c.knowledge??[],isLoadingKnowledge:!1}:a)}catch{a||aq(a=>a&&a.repoId===ap.repoId?{...a,generatedKnowledge:[],isLoadingKnowledge:!1}:a)}}return ap?.repoId&&b(),()=>{a=!0}},[ap?.repoId]);let aw=Y?J.find(a=>a.id===Y.projectId):null,ax=new Set(aw?.agents.map(a=>a.agent_id)??[]),ay=Y?g.filter(a=>!ax.has(a.id)):[],az=a.length>0,aA=!!F,aB=[...a].sort((a,b)=>(a.title??"").localeCompare(b.title??"")),aC=J.filter(a=>!a.is_default),aD=aB.filter(a=>!aC.some(b=>b.thread_ids?.includes(a.id)));!function({focusTarget:a,shouldFocus:b}){(0,c.useEffect)(()=>{if(!b||"u"<typeof document)return;let c=a.current;if(!c||c instanceof HTMLButtonElement&&c.disabled)return;let d=document.activeElement;if(!(d&&(c===d||c.contains(d))))try{c.focus({preventScroll:!0})}catch{c.focus()}},[a,b])}({focusTarget:V,shouldFocus:aA&&!(v&&!az||G&&az)&&!az&&!w});let aE=()=>{ai({title:"Create thread",placeholder:"Thread title",defaultValue:"",onSubmit:a=>void y({title:a})})};return aA?(0,b.jsxs)("aside",{id:"workspace-sidebar",className:"workspace-sidebar","aria-label":"Workspace sidebar","aria-busy":v?"true":void 0,children:[(0,b.jsxs)("div",{className:"workspace-sidebar__brand",children:[(0,b.jsx)("div",{className:"flex items-center justify-center mr-2","aria-hidden":"true",children:(0,b.jsxs)("svg",{width:"52",height:"31",viewBox:"0 0 64 38",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,b.jsx)("rect",{width:"64",height:"38",rx:"8",fill:"black"}),(0,b.jsxs)("g",{stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,b.jsx)("path",{d:"M 14 27 C 17 16 19 10 20 8 C 21 12 23 20 25 27"}),(0,b.jsx)("path",{d:"M 16 20 C 19 19 21 21 23 20"}),(0,b.jsx)("path",{d:"M 40 13 C 35 10 30 13 30 19 C 30 25 34 28 38 27 C 40 26 40 22 40 20 L 36 20"}),(0,b.jsx)("path",{d:"M 46 11 C 48 16 51 22 54 27"}),(0,b.jsx)("path",{d:"M 54 11 C 52 16 49 22 46 27"})]})]})}),H&&(0,b.jsx)("button",{type:"button",onClick:H,"aria-label":"Hide threads",title:"Hide threads",className:"ml-auto inline-flex h-7 w-7 items-center justify-center rounded-md text-slate-400 transition-all hover:bg-slate-100 hover:text-slate-600",children:(0,b.jsx)(k,{className:"h-4 w-4",strokeWidth:1.75})})]}),(0,b.jsxs)("div",{className:"workspace-sidebar__content",children:[I&&(0,b.jsx)("div",{className:"px-3 pt-2 pb-1",children:(0,b.jsxs)("button",{type:"button",onClick:I,className:"flex items-center gap-2 w-full h-8 px-2.5 rounded-lg border border-slate-200 bg-white text-slate-400 text-xs hover:border-slate-300 hover:text-slate-500 transition-all",children:[(0,b.jsx)(n.Search,{className:"h-3.5 w-3.5 shrink-0",strokeWidth:1.75}),(0,b.jsx)("span",{children:"Search..."}),(0,b.jsx)("kbd",{className:"ml-auto text-[10px] font-sans font-medium text-slate-300 bg-slate-50 border border-slate-200 rounded px-1 py-0.5",children:"⌘K"})]})}),(0,b.jsx)("nav",{className:"workspace-sidebar__section",style:{gap:0,marginTop:"1.5rem"},children:(0,b.jsxs)(r.default,{href:"/agents",className:"workspace-sidebar__section-link",children:[(0,b.jsx)(h,{size:13,className:"flex-shrink-0"}),"Manage Agents"]})}),(0,b.jsxs)("nav",{className:"workspace-sidebar__section",children:[(0,b.jsxs)("div",{className:"workspace-sidebar__section-header",children:[(0,b.jsx)("p",{className:"workspace-sidebar__section-label",children:"Projects"}),(0,b.jsx)("div",{className:"workspace-sidebar__header-actions",children:(0,b.jsx)("button",{type:"button",className:"workspace-sidebar__action",onClick:()=>{ag.resetForm(),af(null),ad({})},"aria-label":"Create project",title:"Create project",children:(0,b.jsx)(m.Plus,{size:14})})})]}),aC.map(a=>{let c=W.has(a.id),h=aB.filter(b=>a.thread_ids?.includes(b.id));return(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"workspace-sidebar__workspace-item group",children:[(0,b.jsxs)("button",{type:"button",className:"workspace-sidebar__nav-item workspace-sidebar__workspace-nav-item",onClick:()=>{S?.(a.id),at(a.id)},children:[c?(0,b.jsx)(d.ChevronDown,{size:14,className:"flex-shrink-0 text-slate-400",onClick:b=>{b.stopPropagation(),at(a.id)}}):(0,b.jsx)(e.ChevronRight,{size:14,className:"flex-shrink-0 text-slate-400",onClick:b=>{b.stopPropagation(),at(a.id)}}),(0,b.jsx)(i,{size:12,className:"flex-shrink-0 text-slate-400"}),(0,b.jsx)("span",{className:"workspace-sidebar__workspace-title",children:a.name})]}),(0,b.jsxs)("div",{className:"workspace-sidebar__workspace-actions",children:[(0,b.jsx)("button",{type:"button",className:"workspace-sidebar__workspace-action",onClick:()=>void av(a.id),"aria-label":`Open project settings for ${a.name}`,title:"Project settings",children:(0,b.jsx)(l.Pencil,{size:12})}),(0,b.jsx)("button",{type:"button",className:"workspace-sidebar__workspace-action workspace-sidebar__workspace-action--delete",onClick:()=>{var b;let c;return b=a.id,c=J.find(a=>a.id===b),void al({title:"Delete project",message:`Delete "${c?.name??"project"}"? Its agents will move to the Default project.`,onConfirm:()=>void M?.(b)})},"aria-label":`Delete project ${a.name}`,title:`Delete project ${a.name}`,children:(0,b.jsx)(o.Trash2,{size:12})})]})]}),c&&(0,b.jsxs)("div",{className:"pl-4 py-0.5 flex flex-col gap-0.5",children:[(0,b.jsx)("div",{className:"workspace-sidebar__workspace-item",children:h[0]?(0,b.jsxs)("button",{type:"button",className:`workspace-sidebar__nav-item ${h[0].id===u?"workspace-sidebar__nav-item--active":""}`,onClick:()=>x(h[0].id),"aria-current":h[0].id===u?"page":void 0,children:[(0,b.jsx)(f.Hash,{size:12,className:"flex-shrink-0 text-slate-400"}),(0,b.jsx)("span",{className:"workspace-sidebar__workspace-title text-xs",children:"Thread"})]}):(0,b.jsxs)("button",{type:"button",className:"workspace-sidebar__nav-item",onClick:aE,children:[(0,b.jsx)(f.Hash,{size:12,className:"flex-shrink-0 text-slate-400"}),(0,b.jsx)("span",{className:"workspace-sidebar__workspace-title text-xs",children:"Thread"})]})}),(0,b.jsx)("div",{className:"workspace-sidebar__workspace-item",children:(0,b.jsxs)(r.default,{href:`/projects/${a.slug}`,className:"workspace-sidebar__nav-item",children:[(0,b.jsx)(p,{size:12,className:"flex-shrink-0 text-slate-400"}),(0,b.jsx)("span",{className:"workspace-sidebar__workspace-title text-xs",children:"Board"})]})}),(0,b.jsxs)("div",{className:"pt-1",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-2 py-1",children:[(0,b.jsx)("p",{className:"text-[10px] font-medium text-slate-400 uppercase tracking-wide",children:"Repos"}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("span",{className:"text-[10px] text-slate-300",children:a.repos.length}),(0,b.jsx)("button",{type:"button",className:"workspace-sidebar__action text-slate-300 hover:text-white",onClick:()=>aq({projectId:a.id,projectName:a.name,repoId:null,name:"",path:"",gitUrl:"",notes:"",generatedKnowledge:[],isLoadingKnowledge:!1,isSaving:!1,error:null}),"aria-label":"Add repo",title:"Add repo",children:(0,b.jsx)(m.Plus,{size:12})})]})]}),a.repos.length>0?a.repos.map(c=>(0,b.jsxs)("div",{className:"workspace-sidebar__workspace-item group/repo flex items-center",children:[(0,b.jsxs)("button",{type:"button",className:"workspace-sidebar__nav-item ml-2 min-w-0 flex-1 text-left",onClick:()=>aq({projectId:a.id,projectName:a.name,repoId:c.id,name:c.name,path:c.path||"",gitUrl:c.git_url||"",notes:c.notes||"",generatedKnowledge:[],isLoadingKnowledge:!0,isSaving:!1,error:null}),children:[(0,b.jsx)(j,{size:12,className:"flex-shrink-0 text-slate-400"}),(0,b.jsx)("span",{className:"workspace-sidebar__workspace-title text-xs truncate",children:c.name})]}),(0,b.jsx)("button",{type:"button",className:"workspace-sidebar__action opacity-0 group-hover/repo:opacity-100 transition-opacity flex-shrink-0 text-slate-400 hover:text-red-400",onClick:async b=>{b.stopPropagation();let d=a.repos.filter(a=>a.id!==c.id).map(a=>({id:a.id,name:a.name,path:a.path,git_url:a.git_url,notes:a.notes}));await L?.(a.id,{repos:d})},"aria-label":"Delete repo",title:"Delete repo",children:(0,b.jsx)(o.Trash2,{size:12})})]},`${a.id}:${c.name}:${c.path??""}`)):(0,b.jsx)("p",{className:"pl-4 py-1 text-[11px] text-slate-400",children:"No repos"})]}),(0,b.jsxs)("div",{className:"pt-1",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-2 py-1",children:[(0,b.jsx)("p",{className:"text-[10px] font-medium text-slate-400 uppercase tracking-wide",children:"Agents"}),(0,b.jsx)("button",{type:"button",className:"workspace-sidebar__action opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{var b;return b=a.id,void(P?P(b):(_(new Set),Z({projectId:b})))},"aria-label":"Add agent",title:"Add agent",children:(0,b.jsx)(m.Plus,{size:12})})]}),a.agents.length>0?a.agents.map((c,d)=>{let e=g.find(a=>a.id===c.agent_id),f=ar?.projectId===a.id&&ar?.agentId===c.agent_id,h=ar?.projectId===a.id&&ar?.overIndex===d&&!f;return(0,b.jsx)("div",{draggable:!0,onDragStart:b=>{b.dataTransfer.effectAllowed="move",as({projectId:a.id,agentId:c.agent_id,overIndex:d})},onDragOver:b=>{b.preventDefault(),ar&&ar.projectId===a.id&&as(a=>a?{...a,overIndex:d}:null)},onDragEnd:()=>{if(ar&&ar.projectId===a.id&&Q){let b=a.agents.map(a=>a.agent_id),c=b.indexOf(ar.agentId),d=ar.overIndex;if(-1!==c&&c!==d){let e=[...b],[f]=e.splice(c,1);e.splice(d,0,f),Q(a.id,e)}}as(null)},className:`flex items-center ${h?"border-t-2 border-slate-400":"border-t-2 border-transparent"} ${f?"opacity-40":""}`,children:(0,b.jsxs)("button",{type:"button",className:"workspace-sidebar__nav-item ml-2 flex-1 min-w-0",onClick:()=>an(c.agent_id),children:[(0,b.jsx)("span",{className:"cursor-grab text-slate-300 hover:text-slate-500 flex-shrink-0 mr-0.5",title:"Drag to reorder",children:"⠿"}),(0,b.jsx)("img",{src:(0,s.agentAvatarUrl)(c.agent_id,16,e?.color),alt:"",className:"w-4 h-4 rounded-full flex-shrink-0"}),(0,b.jsx)("span",{className:"workspace-sidebar__workspace-title text-xs truncate",children:e?.name??c.agent_id}),0===d&&(0,b.jsx)("span",{className:"ml-auto text-[9px] text-slate-400 font-medium flex-shrink-0",title:"Default responder (top agent responds first)",children:"DEFAULT"})]})},c.agent_id)}):(0,b.jsx)("p",{className:"pl-4 py-1 text-[11px] text-slate-400",children:"No agents"})]})]})]},a.id)}),aD.length>0&&(0,b.jsxs)("div",{className:"pt-3",children:[(0,b.jsx)("p",{className:"px-1 py-1 text-[10px] font-medium text-slate-400 uppercase tracking-wide",children:"Unassigned Threads"}),aD.map(a=>{let c=a.id===u,d=a.title?.trim()||"Untitled thread";return(0,b.jsx)("div",{className:"workspace-sidebar__workspace-item group",children:(0,b.jsxs)("button",{type:"button",className:`workspace-sidebar__nav-item workspace-sidebar__workspace-nav-item ${c?"workspace-sidebar__nav-item--active workspace-sidebar__workspace-nav-item--active":""}`,onClick:()=>x(a.id),"aria-current":c?"page":void 0,children:[(0,b.jsx)(f.Hash,{size:12,className:"flex-shrink-0 text-slate-400"}),(0,b.jsx)("span",{className:"workspace-sidebar__workspace-title",children:d})]})},a.id)})]})]})]}),(0,b.jsx)("div",{className:"mt-auto px-3 pb-3",children:(0,b.jsxs)("a",{href:"https://discord.gg/G9afUYKKY3",target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-center gap-2 w-full py-2 rounded-lg text-white text-sm font-medium transition-colors",style:{backgroundColor:"#5865F2"},onMouseEnter:a=>a.currentTarget.style.backgroundColor="#4752C4",onMouseLeave:a=>a.currentTarget.style.backgroundColor="#5865F2",children:[(0,b.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 71 55",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:(0,b.jsx)("path",{d:"M60.1 4.9A58.5 58.5 0 0045.4.2a.2.2 0 00-.2.1 40.8 40.8 0 00-1.8 3.7 54 54 0 00-16.2 0A37.4 37.4 0 0025.4.3a.2.2 0 00-.2-.1A58.4 58.4 0 0010.5 4.9a.2.2 0 00-.1.1C1.5 18.7-.9 32.2.3 45.5v.1a58.8 58.8 0 0017.7 9a.2.2 0 00.3-.1 42 42 0 003.6-5.9.2.2 0 00-.1-.3 38.8 38.8 0 01-5.5-2.6.2.2 0 01 0-.4l1.1-.9a.2.2 0 01.2 0 42 42 0 0035.6 0 .2.2 0 01.2 0l1.1.9a.2.2 0 010 .4 36.4 36.4 0 01-5.5 2.6.2.2 0 00-.1.3 47.2 47.2 0 003.6 5.9.2.2 0 00.3.1 58.6 58.6 0 0017.7-9v-.1c1.4-15.2-2.4-28.4-10-40.1a.2.2 0 00-.1-.1zM23.7 37.3c-3.5 0-6.3-3.2-6.3-7s2.8-7 6.3-7 6.4 3.2 6.3 7-2.8 7-6.3 7zm23.3 0c-3.5 0-6.3-3.2-6.3-7s2.8-7 6.3-7 6.4 3.2 6.3 7-2.8 7-6.3 7z"})}),"Join Discord"]})}),ap&&(0,b.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30 p-4",onClick:()=>{ap.isSaving||aq(null)},children:(0,b.jsxs)("div",{className:"w-full max-w-lg rounded-2xl border border-slate-200 bg-white shadow-2xl",onClick:a=>a.stopPropagation(),children:[(0,b.jsxs)("div",{className:"flex items-start justify-between gap-4 border-b border-slate-100 px-5 py-4",children:[(0,b.jsxs)("div",{className:"min-w-0",children:[(0,b.jsx)("p",{className:"text-[11px] font-semibold uppercase tracking-[0.18em] text-slate-400",children:ap.projectName}),(0,b.jsx)("h3",{className:"truncate text-base font-semibold text-slate-900",children:ap.repoId?ap.name||"Repository":"Add Repository"})]}),(0,b.jsx)("button",{type:"button",className:"rounded-md p-1 text-slate-400 transition-colors hover:bg-slate-100 hover:text-slate-600",onClick:()=>{ap.isSaving||aq(null)},"aria-label":"Close repo details",disabled:ap.isSaving,children:(0,b.jsx)(q.X,{size:16})})]}),(0,b.jsxs)("div",{className:"space-y-4 px-5 py-4",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("p",{className:"mb-1 text-[11px] font-semibold uppercase tracking-[0.18em] text-slate-400",children:"Name"}),(0,b.jsx)("input",{value:ap.name,onChange:a=>aq(b=>b?{...b,name:a.target.value,error:null}:b),className:"w-full rounded-lg border border-slate-200 bg-slate-50 px-3 py-2 text-sm text-slate-700",disabled:ap.isSaving})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("p",{className:"mb-1 text-[11px] font-semibold uppercase tracking-[0.18em] text-slate-400",children:"Path"}),(0,b.jsx)("input",{value:ap.path,onChange:a=>aq(b=>b?{...b,path:a.target.value,error:null}:b),className:"w-full rounded-lg border border-slate-200 bg-slate-50 px-3 py-2 font-mono text-xs text-slate-700",disabled:ap.isSaving})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("p",{className:"mb-1 text-[11px] font-semibold uppercase tracking-[0.18em] text-slate-400",children:"Repo Notes"}),(0,b.jsx)("textarea",{value:ap.notes,onChange:a=>aq(b=>b?{...b,notes:a.target.value,error:null}:b),className:"min-h-28 w-full rounded-lg border border-slate-200 bg-slate-50 px-3 py-3 text-sm text-slate-700 whitespace-pre-wrap",disabled:ap.isSaving,placeholder:"Repo-specific rules, notes, conventions, deployment constraints..."})]}),ap.repoId?(0,b.jsxs)("div",{children:[(0,b.jsx)("p",{className:"mb-1 text-[11px] font-semibold uppercase tracking-[0.18em] text-slate-400",children:"System-Generated Repo Knowledge"}),ap.isLoadingKnowledge?(0,b.jsx)("p",{className:"text-sm text-slate-400",children:"Loading generated knowledge…"}):ap.generatedKnowledge.length>0?(0,b.jsx)("div",{className:"space-y-2",children:ap.generatedKnowledge.slice(0,5).map(a=>(0,b.jsxs)("div",{className:"rounded-lg border border-slate-200 bg-slate-50 px-3 py-2 text-sm text-slate-700",children:[(0,b.jsx)("div",{children:a.content}),a.created_at?(0,b.jsx)("div",{className:"mt-1 text-[11px] text-slate-400",children:new Date(a.created_at).toLocaleString()}):null]},a.id))}):(0,b.jsx)("p",{className:"text-sm text-slate-400",children:"No generated repo knowledge yet."})]}):null,ap.error?(0,b.jsx)("p",{className:"text-xs text-red-600",children:ap.error}):null,(0,b.jsxs)("div",{className:"flex justify-end gap-2 border-t border-slate-100 pt-4",children:[(0,b.jsx)("button",{type:"button",className:"rounded-lg px-3 py-2 text-sm text-slate-600 transition-colors hover:bg-slate-100",onClick:()=>aq(null),disabled:ap.isSaving,children:"Cancel"}),(0,b.jsx)("button",{type:"button",className:"rounded-lg bg-slate-900 px-3 py-2 text-sm font-medium text-white transition-colors hover:bg-slate-800 disabled:cursor-not-allowed disabled:opacity-60",disabled:ap.isSaving||!L,onClick:async()=>{let a=J.find(a=>a.id===ap.projectId);if(!a)return void aq(a=>a?{...a,error:"Project not found."}:a);let b=ap.name.trim(),c=ap.path.trim();if(!b)return void aq(a=>a?{...a,error:"Repo name is required."}:a);if(!c)return void aq(a=>a?{...a,error:"Repo path is required."}:a);aq(a=>a?{...a,isSaving:!0,error:null}:a);try{let d=ap.repoId?a.repos.map(a=>a.id===ap.repoId?{id:a.id,name:b,path:c,git_url:ap.gitUrl.trim()||void 0,notes:ap.notes.trim()||void 0}:{id:a.id,name:a.name,path:a.path,git_url:a.git_url,notes:a.notes}):[...a.repos.map(a=>({id:a.id,name:a.name,path:a.path,git_url:a.git_url,notes:a.notes})),{name:b,path:c,git_url:ap.gitUrl.trim()||void 0,notes:ap.notes.trim()||void 0}];await L?.(a.id,{repos:d}),aq(null)}catch(a){aq(b=>b?{...b,isSaving:!1,error:a instanceof Error?a.message:"Failed to save repo details."}:b)}},children:ap.isSaving?"Saving...":ap.repoId?"Save":"Add Repo"})]})]})]})}),Y&&!aa&&(0,b.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30",onClick:()=>Z(null),children:(0,b.jsxs)("div",{className:"bg-white rounded-xl shadow-xl border border-slate-200 w-80 max-h-[70vh] flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-slate-100",children:[(0,b.jsxs)("h3",{className:"text-sm font-medium text-slate-900",children:["Add to ",aw?.name??"project"]}),(0,b.jsx)("button",{type:"button",className:"text-slate-400 hover:text-slate-600",onClick:()=>Z(null),children:(0,b.jsx)(q.X,{size:16})})]}),(0,b.jsxs)("div",{className:"overflow-y-auto py-1 flex-1",children:[(0,b.jsxs)("button",{type:"button",className:"w-full flex items-center gap-3 px-4 py-2.5 text-sm text-slate-700 hover:bg-slate-50 transition-colors border-b border-slate-100",onClick:()=>ab(!0),children:[(0,b.jsx)(m.Plus,{size:14,className:"text-slate-400"}),(0,b.jsx)("span",{className:"text-xs font-medium",children:"Create new agent"})]}),0===ay.length?(0,b.jsx)("p",{className:"px-4 py-6 text-xs text-slate-400 text-center",children:"All agents are already in this project"}):ay.map(a=>{let c=$.has(a.id);return(0,b.jsxs)("button",{type:"button",className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${c?"bg-slate-100 text-slate-900":"text-slate-700 hover:bg-slate-50"}`,onClick:()=>{_(b=>{let c=new Set(b);return c.has(a.id)?c.delete(a.id):c.add(a.id),c})},children:[(0,b.jsx)("div",{className:`w-4 h-4 rounded border flex-shrink-0 flex items-center justify-center ${c?"bg-slate-900 border-slate-900":"border-slate-300"}`,children:c&&(0,b.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:(0,b.jsx)("path",{d:"M2 5l2 2 4-4",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),(0,b.jsx)("img",{src:(0,s.agentAvatarUrl)(a.id,24,a.color),alt:"",className:"w-6 h-6 rounded-full flex-shrink-0"}),(0,b.jsxs)("div",{className:"min-w-0 flex-1 text-left",children:[(0,b.jsx)("div",{className:"truncate font-medium text-xs",children:a.name}),(0,b.jsx)("div",{className:"truncate text-[11px] text-slate-400",children:a.model})]})]},a.id)})]}),ay.length>0&&(0,b.jsxs)("div",{className:"px-4 py-3 border-t border-slate-100 flex justify-end gap-2",children:[(0,b.jsx)("button",{type:"button",className:"px-3 py-1.5 text-xs text-slate-500 hover:text-slate-700 transition-colors",onClick:()=>Z(null),children:"Cancel"}),(0,b.jsxs)("button",{type:"button",disabled:0===$.size,className:"px-3 py-1.5 text-xs font-medium text-white bg-slate-900 rounded-lg hover:bg-slate-800 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",onClick:()=>{for(let a of $)N?.(Y.projectId,a);Z(null)},children:["Add ",$.size>0?`(${$.size})`:""]})]})]})}),aa&&(0,b.jsx)(s.AgentForm,{title:"Create new agent",initial:{name:"",provider:"claude",model:"",identity:"",skills:[]},submitLabel:"Create & Add",projects:J?.filter(a=>!a.is_default).map(b=>{let c=(b.thread_ids??[]).map(b=>a.find(a=>a.id===b)?.title?.trim()).filter(Boolean).join(", ")||"No thread";return{id:b.id,name:b.name,label:`${c} › ${b.name}`}}),initialProjectIds:Y?[Y.projectId]:[],onSubmit:async(a,b)=>{let c=["#D97706","#2563EB","#059669","#DC2626","#7C3AED","#DB2777","#0891B2"],d=c[g.length%c.length],e=a.name.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""),f=b?.[0],h=await fetch("/api/participants",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,name:a.name,provider:a.provider,model:a.model,color:a.color??d,...a.identity?{identity:a.identity}:{},skills:a.skills??[],...f?{projectId:f}:{}})});if(h.ok){let a=await h.json().catch(()=>({})),c="string"==typeof a?.id&&a.id.trim()?a.id.trim():e;for(let a of(b??[]).slice(1))N?.(a,c);ab(!1),Z(null)}},onCancel:()=>{ab(!1)}}),ah&&(0,b.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30",onClick:()=>ai(null),children:(0,b.jsxs)("div",{className:"bg-white rounded-xl shadow-xl border border-slate-200 w-80 flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-slate-100",children:[(0,b.jsx)("h3",{className:"text-sm font-medium text-slate-900",children:ah.title}),(0,b.jsx)("button",{type:"button",className:"text-slate-400 hover:text-slate-600",onClick:()=>ai(null),children:(0,b.jsx)(q.X,{size:16})})]}),(0,b.jsxs)("form",{className:"px-4 py-4 flex flex-col gap-3",onSubmit:a=>{a.preventDefault();let b=new FormData(a.currentTarget),c=b.get("value")?.trim();c&&(ah.onSubmit(c),ai(null))},children:[(0,b.jsx)("input",{ref:aj,name:"value",type:"text",defaultValue:ah.defaultValue,placeholder:ah.placeholder,className:"w-full px-3 py-2 text-sm border border-slate-200 rounded-lg outline-none focus:border-slate-400 focus:ring-1 focus:ring-slate-200 transition-all"}),(0,b.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,b.jsx)("button",{type:"button",className:"px-3 py-1.5 text-xs text-slate-500 hover:text-slate-700 transition-colors",onClick:()=>ai(null),children:"Cancel"}),(0,b.jsx)("button",{type:"submit",className:"px-3 py-1.5 text-xs font-medium text-white bg-slate-900 rounded-lg hover:bg-slate-800 transition-colors",children:ah.defaultValue?"Save":"Create"})]})]})]})}),ak&&(0,b.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30",onClick:()=>al(null),children:(0,b.jsxs)("div",{className:"bg-white rounded-xl shadow-xl border border-slate-200 w-80 flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-slate-100",children:[(0,b.jsx)("h3",{className:"text-sm font-medium text-slate-900",children:ak.title}),(0,b.jsx)("button",{type:"button",className:"text-slate-400 hover:text-slate-600",onClick:()=>al(null),children:(0,b.jsx)(q.X,{size:16})})]}),(0,b.jsxs)("div",{className:"px-4 py-4 flex flex-col gap-4",children:[(0,b.jsx)("p",{className:"text-sm text-slate-600",children:ak.message}),(0,b.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,b.jsx)("button",{type:"button",className:"px-3 py-1.5 text-xs text-slate-500 hover:text-slate-700 transition-colors",onClick:()=>al(null),children:"Cancel"}),(0,b.jsx)("button",{type:"button",className:"px-3 py-1.5 text-xs font-medium text-white bg-red-600 rounded-lg hover:bg-red-700 transition-colors",onClick:()=>{ak.onConfirm(),al(null)},children:"Delete"})]})]})]})}),(ac||ae)&&(0,b.jsx)(t.default,{isOpen:!0,onClose:()=>{ag.resetForm(),ad(null),af(null)},onSubmit:()=>void au(),editingProject:ae,form:ag.form,repos:ag.repos,isSubmitting:ag.isSubmitting,formError:ag.formError,onFieldChange:(a,b)=>ag.setForm(c=>({...c,[a]:b})),onRepoChange:ag.handleRepoChange,onAddRepo:ag.addRepo,onRemoveRepo:ag.removeRepo}),ao&&(T=J.filter(a=>a.agents.some(a=>a.agent_id===ao.id)),U=J.filter(a=>!a.agents.some(a=>a.agent_id===ao.id)),(0,b.jsx)(s.AgentForm,{title:"Edit agent",initial:{name:ao.name,provider:ao.provider,model:ao.model||"",identity:ao.identity||"",color:ao.color,skills:ao.skills||[]},agentId:ao.id,submitLabel:"Save",projectMemberships:{current:T.map(a=>({id:a.id,name:a.name,is_default:!!a.is_default})),available:U.map(a=>({id:a.id,name:a.name}))},onAddToProject:N?a=>N(a,ao.id):void 0,onRemoveFromProject:O?a=>O(a,ao.id):void 0,onSubmit:async a=>{R&&await R({...ao,name:a.name,provider:a.provider,model:a.model,color:a.color??ao.color,...a.identity?{identity:a.identity}:{},skills:a.skills??[]}),an(null)},onCancel:()=>an(null)}))]}):(0,b.jsxs)("aside",{id:"workspace-sidebar",className:"workspace-sidebar workspace-sidebar--collapsed","aria-label":"Workspace sidebar",children:[(0,b.jsx)("div",{className:"workspace-sidebar__brand",children:(0,b.jsx)("button",{type:"button",onClick:H,className:"workspace-sidebar__brand-icon p-0 bg-transparent hover:bg-transparent border-none outline-none","aria-label":"Show threads",title:"Show threads",children:(0,b.jsxs)("svg",{width:"52",height:"31",viewBox:"0 0 64 38",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"transition-transform hover:scale-105",children:[(0,b.jsx)("rect",{width:"64",height:"38",rx:"8",fill:"black"}),(0,b.jsxs)("g",{stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,b.jsx)("path",{d:"M 14 27 C 17 16 19 10 20 8 C 21 12 23 20 25 27"}),(0,b.jsx)("path",{d:"M 16 20 C 19 19 21 21 23 20"}),(0,b.jsx)("path",{d:"M 40 13 C 35 10 30 13 30 19 C 30 25 34 28 38 27 C 40 26 40 22 40 20 L 36 20"}),(0,b.jsx)("path",{d:"M 46 11 C 48 16 51 22 54 27"}),(0,b.jsx)("path",{d:"M 54 11 C 52 16 49 22 46 27"})]})]})})}),(0,b.jsx)("div",{className:"mt-auto p-2",children:(0,b.jsx)("a",{href:"https://discord.gg/G9afUYKKY3",target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-center w-8 h-8 rounded-lg text-white transition-colors",style:{backgroundColor:"#5865F2"},onMouseEnter:a=>a.currentTarget.style.backgroundColor="#4752C4",onMouseLeave:a=>a.currentTarget.style.backgroundColor="#5865F2",title:"Join Discord",children:(0,b.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 71 55",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:(0,b.jsx)("path",{d:"M60.1 4.9A58.5 58.5 0 0045.4.2a.2.2 0 00-.2.1 40.8 40.8 0 00-1.8 3.7 54 54 0 00-16.2 0A37.4 37.4 0 0025.4.3a.2.2 0 00-.2-.1A58.4 58.4 0 0010.5 4.9a.2.2 0 00-.1.1C1.5 18.7-.9 32.2.3 45.5v.1a58.8 58.8 0 0017.7 9a.2.2 0 00.3-.1 42 42 0 003.6-5.9.2.2 0 00-.1-.3 38.8 38.8 0 01-5.5-2.6.2.2 0 01 0-.4l1.1-.9a.2.2 0 01.2 0 42 42 0 0035.6 0 .2.2 0 01.2 0l1.1.9a.2.2 0 010 .4 36.4 36.4 0 01-5.5 2.6.2.2 0 00-.1.3 47.2 47.2 0 003.6 5.9.2.2 0 00.3.1 58.6 58.6 0 0017.7-9v-.1c1.4-15.2-2.4-28.4-10-40.1a.2.2 0 00-.1-.1zM23.7 37.3c-3.5 0-6.3-3.2-6.3-7s2.8-7 6.3-7 6.4 3.2 6.3 7-2.8 7-6.3 7zm23.3 0c-3.5 0-6.3-3.2-6.3-7s2.8-7 6.3-7 6.4 3.2 6.3 7-2.8 7-6.3 7z"})})})})]})}a.s(["WorkspaceSidebar",()=>u],86976);let v={threadSidebarVisible:!1};function w(){return({...v}).threadSidebarVisible}function x(a){}a.s(["loadWorkspaceSidebarVisible",()=>w,"persistWorkspaceSidebarVisible",()=>x],55672)}];
1
+ module.exports=[86976,82434,92596,55672,a=>{"use strict";var b=a.i(90944),c=a.i(72131),d=a.i(5784),e=a.i(50522),f=a.i(2835),g=a.i(60137);let h=(0,g.default)("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);a.s(["Bot",()=>h],82434);let i=(0,g.default)("folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);a.s(["Folder",()=>i],92596);let j=(0,g.default)("folder-git-2",[["path",{d:"M18 19a5 5 0 0 1-5-5v8",key:"sz5oeg"}],["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"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]]),k=(0,g.default)("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);var l=a.i(99464),m=a.i(15618),n=a.i(87532),o=a.i(81560);let p=(0,g.default)("layout-dashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);var q=a.i(33508),r=a.i(38246),s=a.i(20138),t=a.i(44637);function u({threads:a,participants:g=[],activeThreadId:u,isLoading:v,isCreating:w,onSelectThread:x,onCreateThread:y,onRenameThread:z,onDeleteThread:A,deletingThreadId:B=null,renamingThreadId:C=null,activeParticipantIds:D=[],onToggleParticipantActive:E,visible:F=!1,isRestoringActiveThread:G=!1,onToggle:H,onSearch:I,projects:J=[],onCreateProject:K,onUpdateProject:L,onDeleteProject:M,onAddAgentToProject:N,onRemoveAgentFromProject:O,onAddAgentViaForm:P,onReorderProjectAgents:Q,onUpdateParticipant:R,onSelectProject:S}){let T,U,V=(0,c.useRef)(null),[W,X]=(0,c.useState)(new Set),[Y,Z]=(0,c.useState)(null),[$,_]=(0,c.useState)(new Set),[aa,ab]=(0,c.useState)(!1),[ac,ad]=(0,c.useState)(null),[ae,af]=(0,c.useState)(null),ag=(0,t.useProjectFormState)(),[ah,ai]=(0,c.useState)(null),aj=(0,c.useCallback)(a=>{a&&(a.focus(),a.select())},[]),[ak,al]=(0,c.useState)(null),[am,an]=(0,c.useState)(null),ao=am?g.find(a=>a.id===am)??null:null,[ap,aq]=(0,c.useState)(null),[ar,as]=(0,c.useState)(null),at=a=>{X(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},au=async()=>{if(!ac&&!ae)return;if(!ag.form.name.trim())return void ag.setFormError("Project name is required");let a=ag.repos.find(a=>a.name.trim()&&!a.path.trim());if(a)return void ag.setFormError(`Local path is required for repository "${a.name}"`);ag.setFormError(null),ag.setIsSubmitting(!0);let b=(0,t.createProjectPayload)(ag.form,ag.repos);ae?await L?.(ae.id,b):await K?.(b,ac?.threadId),ag.setIsSubmitting(!1),ad(null),af(null)},av=async a=>{ag.resetForm();try{let b=await fetch(`/api/projects/${a}`);if(!b.ok)throw Error("Failed to load project");let c=(await b.json()).project;af(c),ag.hydrateFromProject(c)}catch(a){console.error("Failed to load project settings",a)}};(0,c.useEffect)(()=>{let a=!1;async function b(){if(ap?.repoId)try{let b=await fetch(`/api/repos/${ap.repoId}/knowledge?producer=system`),c=b.ok?await b.json():{knowledge:[]};a||aq(a=>a&&a.repoId===ap.repoId?{...a,generatedKnowledge:c.knowledge??[],isLoadingKnowledge:!1}:a)}catch{a||aq(a=>a&&a.repoId===ap.repoId?{...a,generatedKnowledge:[],isLoadingKnowledge:!1}:a)}}return ap?.repoId&&b(),()=>{a=!0}},[ap?.repoId]);let aw=a=>{P?P(a):(_(new Set),Z({projectId:a}))},ax=Y?J.find(a=>a.id===Y.projectId):null,ay=new Set(ax?.agents.map(a=>a.agent_id)??[]),az=Y?g.filter(a=>!ay.has(a.id)):[],aA=a.length>0,aB=!!F,aC=[...a].sort((a,b)=>(a.title??"").localeCompare(b.title??"")),aD=J.filter(a=>!a.is_default),aE=aC.filter(a=>!aD.some(b=>b.thread_ids?.includes(a.id)));!function({focusTarget:a,shouldFocus:b}){(0,c.useEffect)(()=>{if(!b||"u"<typeof document)return;let c=a.current;if(!c||c instanceof HTMLButtonElement&&c.disabled)return;let d=document.activeElement;if(!(d&&(c===d||c.contains(d))))try{c.focus({preventScroll:!0})}catch{c.focus()}},[a,b])}({focusTarget:V,shouldFocus:aB&&!(v&&!aA||G&&aA)&&!aA&&!w});let aF=()=>{ai({title:"Create thread",placeholder:"Thread title",defaultValue:"",onSubmit:a=>void y({title:a})})};return aB?(0,b.jsxs)("aside",{id:"workspace-sidebar",className:"workspace-sidebar","aria-label":"Workspace sidebar","aria-busy":v?"true":void 0,children:[(0,b.jsxs)("div",{className:"workspace-sidebar__brand",children:[(0,b.jsx)("div",{className:"flex items-center justify-center mr-2","aria-hidden":"true",children:(0,b.jsxs)("svg",{width:"52",height:"31",viewBox:"0 0 64 38",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,b.jsx)("rect",{width:"64",height:"38",rx:"8",fill:"black"}),(0,b.jsxs)("g",{stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,b.jsx)("path",{d:"M 14 27 C 17 16 19 10 20 8 C 21 12 23 20 25 27"}),(0,b.jsx)("path",{d:"M 16 20 C 19 19 21 21 23 20"}),(0,b.jsx)("path",{d:"M 40 13 C 35 10 30 13 30 19 C 30 25 34 28 38 27 C 40 26 40 22 40 20 L 36 20"}),(0,b.jsx)("path",{d:"M 46 11 C 48 16 51 22 54 27"}),(0,b.jsx)("path",{d:"M 54 11 C 52 16 49 22 46 27"})]})]})}),H&&(0,b.jsx)("button",{type:"button",onClick:H,"aria-label":"Hide threads",title:"Hide threads",className:"ml-auto inline-flex h-7 w-7 items-center justify-center rounded-md text-slate-400 transition-all hover:bg-slate-100 hover:text-slate-600",children:(0,b.jsx)(k,{className:"h-4 w-4",strokeWidth:1.75})})]}),(0,b.jsxs)("div",{className:"workspace-sidebar__content",children:[I&&(0,b.jsx)("div",{className:"px-3 pt-2 pb-1",children:(0,b.jsxs)("button",{type:"button",onClick:I,className:"flex items-center gap-2 w-full h-8 px-2.5 rounded-lg border border-slate-200 bg-white text-slate-400 text-xs hover:border-slate-300 hover:text-slate-500 transition-all",children:[(0,b.jsx)(n.Search,{className:"h-3.5 w-3.5 shrink-0",strokeWidth:1.75}),(0,b.jsx)("span",{children:"Search..."}),(0,b.jsx)("kbd",{className:"ml-auto text-[10px] font-sans font-medium text-slate-300 bg-slate-50 border border-slate-200 rounded px-1 py-0.5",children:"⌘K"})]})}),(0,b.jsx)("nav",{className:"workspace-sidebar__section",style:{gap:0,marginTop:"1.5rem"},children:(0,b.jsxs)(r.default,{href:"/agents",className:"workspace-sidebar__section-link",children:[(0,b.jsx)(h,{size:13,className:"flex-shrink-0"}),"Manage Agents"]})}),(0,b.jsxs)("nav",{className:"workspace-sidebar__section",children:[(0,b.jsxs)("div",{className:"workspace-sidebar__section-header group/projects-header",children:[(0,b.jsx)("p",{className:"workspace-sidebar__section-label",children:"Projects"}),(0,b.jsx)("div",{className:"workspace-sidebar__header-actions",children:(0,b.jsx)("button",{type:"button",className:"workspace-sidebar__action opacity-0 transition-opacity group-hover/projects-header:opacity-100",onClick:()=>{ag.resetForm(),af(null),ad({})},"aria-label":"Create project",title:"Create project",children:(0,b.jsx)(m.Plus,{size:14})})})]}),aD.map(a=>{let c=W.has(a.id),h=aC.filter(b=>a.thread_ids?.includes(b.id));return(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"workspace-sidebar__workspace-item group",children:[(0,b.jsxs)("button",{type:"button",className:"workspace-sidebar__nav-item workspace-sidebar__workspace-nav-item",onClick:()=>{S?.(a.id),at(a.id)},children:[c?(0,b.jsx)(d.ChevronDown,{size:14,className:"flex-shrink-0 text-slate-400",onClick:b=>{b.stopPropagation(),at(a.id)}}):(0,b.jsx)(e.ChevronRight,{size:14,className:"flex-shrink-0 text-slate-400",onClick:b=>{b.stopPropagation(),at(a.id)}}),(0,b.jsx)(i,{size:12,className:"flex-shrink-0 text-slate-400"}),(0,b.jsx)("span",{className:"workspace-sidebar__workspace-title",children:a.name})]}),(0,b.jsxs)("div",{className:"workspace-sidebar__workspace-actions",children:[(0,b.jsx)("button",{type:"button",className:"workspace-sidebar__workspace-action",onClick:()=>void av(a.id),"aria-label":`Open project settings for ${a.name}`,title:"Project settings",children:(0,b.jsx)(l.Pencil,{size:12})}),(0,b.jsx)("button",{type:"button",className:"workspace-sidebar__workspace-action workspace-sidebar__workspace-action--delete",onClick:()=>{var b;let c;return b=a.id,c=J.find(a=>a.id===b),void al({title:"Delete project",message:`Delete "${c?.name??"project"}"? Its agents will move to the Default project.`,onConfirm:()=>void M?.(b)})},"aria-label":`Delete project ${a.name}`,title:`Delete project ${a.name}`,children:(0,b.jsx)(o.Trash2,{size:12})})]})]}),c&&(0,b.jsxs)("div",{className:"pl-4 py-0.5 flex flex-col gap-0.5",children:[(0,b.jsx)("div",{className:"workspace-sidebar__workspace-item",children:h[0]?(0,b.jsxs)("button",{type:"button",className:`workspace-sidebar__nav-item ${h[0].id===u?"workspace-sidebar__nav-item--active":""}`,onClick:()=>x(h[0].id),"aria-current":h[0].id===u?"page":void 0,children:[(0,b.jsx)(f.Hash,{size:12,className:"flex-shrink-0 text-slate-400"}),(0,b.jsx)("span",{className:"workspace-sidebar__workspace-title text-xs",children:"Thread"})]}):(0,b.jsxs)("button",{type:"button",className:"workspace-sidebar__nav-item",onClick:aF,children:[(0,b.jsx)(f.Hash,{size:12,className:"flex-shrink-0 text-slate-400"}),(0,b.jsx)("span",{className:"workspace-sidebar__workspace-title text-xs",children:"Thread"})]})}),(0,b.jsx)("div",{className:"workspace-sidebar__workspace-item",children:(0,b.jsxs)(r.default,{href:`/projects/${a.slug}`,className:"workspace-sidebar__nav-item",children:[(0,b.jsx)(p,{size:12,className:"flex-shrink-0 text-slate-400"}),(0,b.jsx)("span",{className:"workspace-sidebar__workspace-title text-xs",children:"Board"})]})}),(0,b.jsxs)("div",{className:"pt-1",children:[(0,b.jsxs)("div",{className:"group/repos-header flex items-center justify-between px-2 py-1",children:[(0,b.jsx)("p",{className:"text-[10px] font-medium text-slate-400 uppercase tracking-wide",children:"Repos"}),(0,b.jsx)("button",{type:"button",className:"workspace-sidebar__action opacity-0 transition-opacity group-hover/repos-header:opacity-100 text-slate-300 hover:text-white",onClick:()=>aq({projectId:a.id,projectName:a.name,repoId:null,name:"",path:"",gitUrl:"",notes:"",generatedKnowledge:[],isLoadingKnowledge:!1,isSaving:!1,error:null}),"aria-label":"Add repo",title:"Add repo",children:(0,b.jsx)(m.Plus,{size:12})})]}),a.repos.length>0?a.repos.map(c=>(0,b.jsxs)("div",{className:"workspace-sidebar__workspace-item group/repo flex items-center",children:[(0,b.jsxs)("button",{type:"button",className:"workspace-sidebar__nav-item ml-2 min-w-0 flex-1 text-left",onClick:()=>aq({projectId:a.id,projectName:a.name,repoId:c.id,name:c.name,path:c.path||"",gitUrl:c.git_url||"",notes:c.notes||"",generatedKnowledge:[],isLoadingKnowledge:!0,isSaving:!1,error:null}),children:[(0,b.jsx)(j,{size:12,className:"flex-shrink-0 text-slate-400"}),(0,b.jsx)("span",{className:"workspace-sidebar__workspace-title text-xs truncate",children:c.name})]}),(0,b.jsx)("button",{type:"button",className:"workspace-sidebar__action opacity-0 group-hover/repo:opacity-100 transition-opacity flex-shrink-0 text-slate-400 hover:text-red-400",onClick:async b=>{b.stopPropagation();let d=a.repos.filter(a=>a.id!==c.id).map(a=>({id:a.id,name:a.name,path:a.path,git_url:a.git_url,notes:a.notes}));await L?.(a.id,{repos:d})},"aria-label":"Delete repo",title:"Delete repo",children:(0,b.jsx)(o.Trash2,{size:12})})]},`${a.id}:${c.name}:${c.path??""}`)):(0,b.jsx)("p",{className:"pl-4 py-1 text-[11px] text-slate-400",children:"No repos"})]}),(0,b.jsxs)("div",{className:"pt-1",children:[(0,b.jsxs)("div",{className:"group/agents-header flex items-center justify-between px-2 py-1",children:[(0,b.jsx)("p",{className:"text-[10px] font-medium text-slate-400 uppercase tracking-wide",children:"Agents"}),a.agents.length>0&&(0,b.jsx)("button",{type:"button",className:"workspace-sidebar__action opacity-0 transition-opacity group-hover/agents-header:opacity-100 text-slate-300 hover:text-white",onClick:()=>aw(a.id),"aria-label":"Add agents",title:"Add agents",children:(0,b.jsx)(m.Plus,{size:12})})]}),a.agents.length>0?(0,b.jsx)(b.Fragment,{children:a.agents.map((c,d)=>{let e=g.find(a=>a.id===c.agent_id),f=ar?.projectId===a.id&&ar?.agentId===c.agent_id,h=ar?.projectId===a.id&&ar?.overIndex===d&&!f;return(0,b.jsx)("div",{draggable:!0,onDragStart:b=>{b.dataTransfer.effectAllowed="move",as({projectId:a.id,agentId:c.agent_id,overIndex:d})},onDragOver:b=>{b.preventDefault(),ar&&ar.projectId===a.id&&as(a=>a?{...a,overIndex:d}:null)},onDragEnd:()=>{if(ar&&ar.projectId===a.id&&Q){let b=a.agents.map(a=>a.agent_id),c=b.indexOf(ar.agentId),d=ar.overIndex;if(-1!==c&&c!==d){let e=[...b],[f]=e.splice(c,1);e.splice(d,0,f),Q(a.id,e)}}as(null)},className:`flex items-center ${h?"border-t-2 border-slate-400":"border-t-2 border-transparent"} ${f?"opacity-40":""}`,children:(0,b.jsxs)("button",{type:"button",className:"workspace-sidebar__nav-item ml-2 flex-1 min-w-0",onClick:()=>an(c.agent_id),children:[(0,b.jsx)("span",{className:"cursor-grab text-slate-300 hover:text-slate-500 flex-shrink-0 mr-0.5",title:"Drag to reorder",children:"⠿"}),(0,b.jsx)("img",{src:(0,s.agentAvatarUrl)(c.agent_id,16,e?.color),alt:"",className:"w-4 h-4 rounded-full flex-shrink-0"}),(0,b.jsx)("span",{className:"workspace-sidebar__workspace-title text-xs truncate",children:e?.name??c.agent_id}),0===d&&(0,b.jsx)("span",{className:"ml-auto text-[9px] text-slate-400 font-medium flex-shrink-0",title:"Default responder (top agent responds first)",children:"DEFAULT"})]})},c.agent_id)})}):(0,b.jsxs)("button",{type:"button",className:"ml-4 inline-flex items-center gap-1 py-1 text-[11px] font-medium text-slate-500 transition-colors hover:text-slate-700",onClick:()=>aw(a.id),children:[(0,b.jsx)(m.Plus,{size:10}),(0,b.jsx)("span",{children:"Add agents"})]})]})]})]},a.id)}),aE.length>0&&(0,b.jsxs)("div",{className:"pt-3",children:[(0,b.jsx)("p",{className:"px-1 py-1 text-[10px] font-medium text-slate-400 uppercase tracking-wide",children:"Unassigned Threads"}),aE.map(a=>{let c=a.id===u,d=a.title?.trim()||"Untitled thread";return(0,b.jsx)("div",{className:"workspace-sidebar__workspace-item group",children:(0,b.jsxs)("button",{type:"button",className:`workspace-sidebar__nav-item workspace-sidebar__workspace-nav-item ${c?"workspace-sidebar__nav-item--active workspace-sidebar__workspace-nav-item--active":""}`,onClick:()=>x(a.id),"aria-current":c?"page":void 0,children:[(0,b.jsx)(f.Hash,{size:12,className:"flex-shrink-0 text-slate-400"}),(0,b.jsx)("span",{className:"workspace-sidebar__workspace-title",children:d})]})},a.id)})]})]})]}),(0,b.jsx)("div",{className:"mt-auto px-3 pb-3",children:(0,b.jsxs)("a",{href:"https://discord.gg/G9afUYKKY3",target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-center gap-2 w-full py-2 rounded-lg text-white text-sm font-medium transition-colors",style:{backgroundColor:"#5865F2"},onMouseEnter:a=>a.currentTarget.style.backgroundColor="#4752C4",onMouseLeave:a=>a.currentTarget.style.backgroundColor="#5865F2",children:[(0,b.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 71 55",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:(0,b.jsx)("path",{d:"M60.1 4.9A58.5 58.5 0 0045.4.2a.2.2 0 00-.2.1 40.8 40.8 0 00-1.8 3.7 54 54 0 00-16.2 0A37.4 37.4 0 0025.4.3a.2.2 0 00-.2-.1A58.4 58.4 0 0010.5 4.9a.2.2 0 00-.1.1C1.5 18.7-.9 32.2.3 45.5v.1a58.8 58.8 0 0017.7 9a.2.2 0 00.3-.1 42 42 0 003.6-5.9.2.2 0 00-.1-.3 38.8 38.8 0 01-5.5-2.6.2.2 0 01 0-.4l1.1-.9a.2.2 0 01.2 0 42 42 0 0035.6 0 .2.2 0 01.2 0l1.1.9a.2.2 0 010 .4 36.4 36.4 0 01-5.5 2.6.2.2 0 00-.1.3 47.2 47.2 0 003.6 5.9.2.2 0 00.3.1 58.6 58.6 0 0017.7-9v-.1c1.4-15.2-2.4-28.4-10-40.1a.2.2 0 00-.1-.1zM23.7 37.3c-3.5 0-6.3-3.2-6.3-7s2.8-7 6.3-7 6.4 3.2 6.3 7-2.8 7-6.3 7zm23.3 0c-3.5 0-6.3-3.2-6.3-7s2.8-7 6.3-7 6.4 3.2 6.3 7-2.8 7-6.3 7z"})}),"Join Discord"]})}),ap&&(0,b.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30 p-4",onClick:()=>{ap.isSaving||aq(null)},children:(0,b.jsxs)("div",{className:"w-full max-w-lg rounded-2xl border border-slate-200 bg-white shadow-2xl",onClick:a=>a.stopPropagation(),children:[(0,b.jsxs)("div",{className:"flex items-start justify-between gap-4 border-b border-slate-100 px-5 py-4",children:[(0,b.jsxs)("div",{className:"min-w-0",children:[(0,b.jsx)("p",{className:"text-[11px] font-semibold uppercase tracking-[0.18em] text-slate-400",children:ap.projectName}),(0,b.jsx)("h3",{className:"truncate text-base font-semibold text-slate-900",children:ap.repoId?ap.name||"Repository":"Add Repository"})]}),(0,b.jsx)("button",{type:"button",className:"rounded-md p-1 text-slate-400 transition-colors hover:bg-slate-100 hover:text-slate-600",onClick:()=>{ap.isSaving||aq(null)},"aria-label":"Close repo details",disabled:ap.isSaving,children:(0,b.jsx)(q.X,{size:16})})]}),(0,b.jsxs)("div",{className:"space-y-4 px-5 py-4",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("p",{className:"mb-1 text-[11px] font-semibold uppercase tracking-[0.18em] text-slate-400",children:"Name"}),(0,b.jsx)("input",{value:ap.name,onChange:a=>aq(b=>b?{...b,name:a.target.value,error:null}:b),className:"w-full rounded-lg border border-slate-200 bg-slate-50 px-3 py-2 text-sm text-slate-700",disabled:ap.isSaving})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("p",{className:"mb-1 text-[11px] font-semibold uppercase tracking-[0.18em] text-slate-400",children:"Path"}),(0,b.jsx)("input",{value:ap.path,onChange:a=>aq(b=>b?{...b,path:a.target.value,error:null}:b),className:"w-full rounded-lg border border-slate-200 bg-slate-50 px-3 py-2 font-mono text-xs text-slate-700",disabled:ap.isSaving})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("p",{className:"mb-1 text-[11px] font-semibold uppercase tracking-[0.18em] text-slate-400",children:"Repo Notes"}),(0,b.jsx)("textarea",{value:ap.notes,onChange:a=>aq(b=>b?{...b,notes:a.target.value,error:null}:b),className:"min-h-28 w-full rounded-lg border border-slate-200 bg-slate-50 px-3 py-3 text-sm text-slate-700 whitespace-pre-wrap",disabled:ap.isSaving,placeholder:"Repo-specific rules, notes, conventions, deployment constraints..."})]}),ap.repoId?(0,b.jsxs)("div",{children:[(0,b.jsx)("p",{className:"mb-1 text-[11px] font-semibold uppercase tracking-[0.18em] text-slate-400",children:"System-Generated Repo Knowledge"}),ap.isLoadingKnowledge?(0,b.jsx)("p",{className:"text-sm text-slate-400",children:"Loading generated knowledge…"}):ap.generatedKnowledge.length>0?(0,b.jsx)("div",{className:"space-y-2",children:ap.generatedKnowledge.slice(0,5).map(a=>(0,b.jsxs)("div",{className:"rounded-lg border border-slate-200 bg-slate-50 px-3 py-2 text-sm text-slate-700",children:[(0,b.jsx)("div",{children:a.content}),a.created_at?(0,b.jsx)("div",{className:"mt-1 text-[11px] text-slate-400",children:new Date(a.created_at).toLocaleString()}):null]},a.id))}):(0,b.jsx)("p",{className:"text-sm text-slate-400",children:"No generated repo knowledge yet."})]}):null,ap.error?(0,b.jsx)("p",{className:"text-xs text-red-600",children:ap.error}):null,(0,b.jsxs)("div",{className:"flex justify-end gap-2 border-t border-slate-100 pt-4",children:[(0,b.jsx)("button",{type:"button",className:"rounded-lg px-3 py-2 text-sm text-slate-600 transition-colors hover:bg-slate-100",onClick:()=>aq(null),disabled:ap.isSaving,children:"Cancel"}),(0,b.jsx)("button",{type:"button",className:"rounded-lg bg-slate-900 px-3 py-2 text-sm font-medium text-white transition-colors hover:bg-slate-800 disabled:cursor-not-allowed disabled:opacity-60",disabled:ap.isSaving||!L,onClick:async()=>{let a=J.find(a=>a.id===ap.projectId);if(!a)return void aq(a=>a?{...a,error:"Project not found."}:a);let b=ap.name.trim(),c=ap.path.trim();if(!b)return void aq(a=>a?{...a,error:"Repo name is required."}:a);if(!c)return void aq(a=>a?{...a,error:"Repo path is required."}:a);aq(a=>a?{...a,isSaving:!0,error:null}:a);try{let d=ap.repoId?a.repos.map(a=>a.id===ap.repoId?{id:a.id,name:b,path:c,git_url:ap.gitUrl.trim()||void 0,notes:ap.notes.trim()||void 0}:{id:a.id,name:a.name,path:a.path,git_url:a.git_url,notes:a.notes}):[...a.repos.map(a=>({id:a.id,name:a.name,path:a.path,git_url:a.git_url,notes:a.notes})),{name:b,path:c,git_url:ap.gitUrl.trim()||void 0,notes:ap.notes.trim()||void 0}];await L?.(a.id,{repos:d}),aq(null)}catch(a){aq(b=>b?{...b,isSaving:!1,error:a instanceof Error?a.message:"Failed to save repo details."}:b)}},children:ap.isSaving?"Saving...":ap.repoId?"Save":"Add Repo"})]})]})]})}),Y&&!aa&&(0,b.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30",onClick:()=>Z(null),children:(0,b.jsxs)("div",{className:"bg-white rounded-xl shadow-xl border border-slate-200 w-80 max-h-[70vh] flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-slate-100",children:[(0,b.jsxs)("h3",{className:"text-sm font-medium text-slate-900",children:["Add to ",ax?.name??"project"]}),(0,b.jsx)("button",{type:"button",className:"text-slate-400 hover:text-slate-600",onClick:()=>Z(null),children:(0,b.jsx)(q.X,{size:16})})]}),(0,b.jsxs)("div",{className:"overflow-y-auto py-1 flex-1",children:[(0,b.jsxs)("button",{type:"button",className:"w-full flex items-center gap-3 px-4 py-2.5 text-sm text-slate-700 hover:bg-slate-50 transition-colors border-b border-slate-100",onClick:()=>ab(!0),children:[(0,b.jsx)(m.Plus,{size:14,className:"text-slate-400"}),(0,b.jsx)("span",{className:"text-xs font-medium",children:"Create new agent"})]}),0===az.length?(0,b.jsx)("p",{className:"px-4 py-6 text-xs text-slate-400 text-center",children:"All agents are already in this project"}):az.map(a=>{let c=$.has(a.id);return(0,b.jsxs)("button",{type:"button",className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${c?"bg-slate-100 text-slate-900":"text-slate-700 hover:bg-slate-50"}`,onClick:()=>{_(b=>{let c=new Set(b);return c.has(a.id)?c.delete(a.id):c.add(a.id),c})},children:[(0,b.jsx)("div",{className:`w-4 h-4 rounded border flex-shrink-0 flex items-center justify-center ${c?"bg-slate-900 border-slate-900":"border-slate-300"}`,children:c&&(0,b.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:(0,b.jsx)("path",{d:"M2 5l2 2 4-4",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),(0,b.jsx)("img",{src:(0,s.agentAvatarUrl)(a.id,24,a.color),alt:"",className:"w-6 h-6 rounded-full flex-shrink-0"}),(0,b.jsxs)("div",{className:"min-w-0 flex-1 text-left",children:[(0,b.jsx)("div",{className:"truncate font-medium text-xs",children:a.name}),(0,b.jsx)("div",{className:"truncate text-[11px] text-slate-400",children:a.model})]})]},a.id)})]}),az.length>0&&(0,b.jsxs)("div",{className:"px-4 py-3 border-t border-slate-100 flex justify-end gap-2",children:[(0,b.jsx)("button",{type:"button",className:"px-3 py-1.5 text-xs text-slate-500 hover:text-slate-700 transition-colors",onClick:()=>Z(null),children:"Cancel"}),(0,b.jsxs)("button",{type:"button",disabled:0===$.size,className:"px-3 py-1.5 text-xs font-medium text-white bg-slate-900 rounded-lg hover:bg-slate-800 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",onClick:()=>{for(let a of $)N?.(Y.projectId,a);Z(null)},children:["Add ",$.size>0?`(${$.size})`:""]})]})]})}),aa&&(0,b.jsx)(s.AgentForm,{title:"Create new agent",initial:{name:"",provider:"claude",model:"",identity:"",skills:[]},submitLabel:"Create & Add",projects:J?.filter(a=>!a.is_default).map(b=>{let c=(b.thread_ids??[]).map(b=>a.find(a=>a.id===b)?.title?.trim()).filter(Boolean).join(", ")||"No thread";return{id:b.id,name:b.name,label:`${c} › ${b.name}`}}),initialProjectIds:Y?[Y.projectId]:[],onSubmit:async(a,b)=>{let c=["#D97706","#2563EB","#059669","#DC2626","#7C3AED","#DB2777","#0891B2"],d=c[g.length%c.length],e=a.name.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""),f=b?.[0],h=await fetch("/api/participants",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,name:a.name,provider:a.provider,model:a.model,color:a.color??d,...a.identity?{identity:a.identity}:{},skills:a.skills??[],...f?{projectId:f}:{}})});if(h.ok){let a=await h.json().catch(()=>({})),c="string"==typeof a?.id&&a.id.trim()?a.id.trim():e;for(let a of(b??[]).slice(1))N?.(a,c);ab(!1),Z(null)}},onCancel:()=>{ab(!1)}}),ah&&(0,b.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30",onClick:()=>ai(null),children:(0,b.jsxs)("div",{className:"bg-white rounded-xl shadow-xl border border-slate-200 w-80 flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-slate-100",children:[(0,b.jsx)("h3",{className:"text-sm font-medium text-slate-900",children:ah.title}),(0,b.jsx)("button",{type:"button",className:"text-slate-400 hover:text-slate-600",onClick:()=>ai(null),children:(0,b.jsx)(q.X,{size:16})})]}),(0,b.jsxs)("form",{className:"px-4 py-4 flex flex-col gap-3",onSubmit:a=>{a.preventDefault();let b=new FormData(a.currentTarget),c=b.get("value")?.trim();c&&(ah.onSubmit(c),ai(null))},children:[(0,b.jsx)("input",{ref:aj,name:"value",type:"text",defaultValue:ah.defaultValue,placeholder:ah.placeholder,className:"w-full px-3 py-2 text-sm border border-slate-200 rounded-lg outline-none focus:border-slate-400 focus:ring-1 focus:ring-slate-200 transition-all"}),(0,b.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,b.jsx)("button",{type:"button",className:"px-3 py-1.5 text-xs text-slate-500 hover:text-slate-700 transition-colors",onClick:()=>ai(null),children:"Cancel"}),(0,b.jsx)("button",{type:"submit",className:"px-3 py-1.5 text-xs font-medium text-white bg-slate-900 rounded-lg hover:bg-slate-800 transition-colors",children:ah.defaultValue?"Save":"Create"})]})]})]})}),ak&&(0,b.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30",onClick:()=>al(null),children:(0,b.jsxs)("div",{className:"bg-white rounded-xl shadow-xl border border-slate-200 w-80 flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-slate-100",children:[(0,b.jsx)("h3",{className:"text-sm font-medium text-slate-900",children:ak.title}),(0,b.jsx)("button",{type:"button",className:"text-slate-400 hover:text-slate-600",onClick:()=>al(null),children:(0,b.jsx)(q.X,{size:16})})]}),(0,b.jsxs)("div",{className:"px-4 py-4 flex flex-col gap-4",children:[(0,b.jsx)("p",{className:"text-sm text-slate-600",children:ak.message}),(0,b.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,b.jsx)("button",{type:"button",className:"px-3 py-1.5 text-xs text-slate-500 hover:text-slate-700 transition-colors",onClick:()=>al(null),children:"Cancel"}),(0,b.jsx)("button",{type:"button",className:"px-3 py-1.5 text-xs font-medium text-white bg-red-600 rounded-lg hover:bg-red-700 transition-colors",onClick:()=>{ak.onConfirm(),al(null)},children:"Delete"})]})]})]})}),(ac||ae)&&(0,b.jsx)(t.default,{isOpen:!0,onClose:()=>{ag.resetForm(),ad(null),af(null)},onSubmit:()=>void au(),editingProject:ae,form:ag.form,repos:ag.repos,isSubmitting:ag.isSubmitting,formError:ag.formError,onFieldChange:(a,b)=>ag.setForm(c=>({...c,[a]:b})),onRepoChange:ag.handleRepoChange,onAddRepo:ag.addRepo,onRemoveRepo:ag.removeRepo}),ao&&(T=J.filter(a=>a.agents.some(a=>a.agent_id===ao.id)),U=J.filter(a=>!a.agents.some(a=>a.agent_id===ao.id)),(0,b.jsx)(s.AgentForm,{title:"Edit agent",initial:{name:ao.name,provider:ao.provider,model:ao.model||"",identity:ao.identity||"",color:ao.color,skills:ao.skills||[]},agentId:ao.id,submitLabel:"Save",projectMemberships:{current:T.map(a=>({id:a.id,name:a.name,is_default:!!a.is_default})),available:U.map(a=>({id:a.id,name:a.name}))},onAddToProject:N?a=>N(a,ao.id):void 0,onRemoveFromProject:O?a=>O(a,ao.id):void 0,onSubmit:async a=>{R&&await R({...ao,name:a.name,provider:a.provider,model:a.model,color:a.color??ao.color,...a.identity?{identity:a.identity}:{},skills:a.skills??[]}),an(null)},onCancel:()=>an(null)}))]}):(0,b.jsxs)("aside",{id:"workspace-sidebar",className:"workspace-sidebar workspace-sidebar--collapsed","aria-label":"Workspace sidebar",children:[(0,b.jsx)("div",{className:"workspace-sidebar__brand",children:(0,b.jsx)("button",{type:"button",onClick:H,className:"workspace-sidebar__brand-icon p-0 bg-transparent hover:bg-transparent border-none outline-none","aria-label":"Show threads",title:"Show threads",children:(0,b.jsxs)("svg",{width:"52",height:"31",viewBox:"0 0 64 38",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"transition-transform hover:scale-105",children:[(0,b.jsx)("rect",{width:"64",height:"38",rx:"8",fill:"black"}),(0,b.jsxs)("g",{stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,b.jsx)("path",{d:"M 14 27 C 17 16 19 10 20 8 C 21 12 23 20 25 27"}),(0,b.jsx)("path",{d:"M 16 20 C 19 19 21 21 23 20"}),(0,b.jsx)("path",{d:"M 40 13 C 35 10 30 13 30 19 C 30 25 34 28 38 27 C 40 26 40 22 40 20 L 36 20"}),(0,b.jsx)("path",{d:"M 46 11 C 48 16 51 22 54 27"}),(0,b.jsx)("path",{d:"M 54 11 C 52 16 49 22 46 27"})]})]})})}),(0,b.jsx)("div",{className:"mt-auto p-2",children:(0,b.jsx)("a",{href:"https://discord.gg/G9afUYKKY3",target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-center w-8 h-8 rounded-lg text-white transition-colors",style:{backgroundColor:"#5865F2"},onMouseEnter:a=>a.currentTarget.style.backgroundColor="#4752C4",onMouseLeave:a=>a.currentTarget.style.backgroundColor="#5865F2",title:"Join Discord",children:(0,b.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 71 55",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:(0,b.jsx)("path",{d:"M60.1 4.9A58.5 58.5 0 0045.4.2a.2.2 0 00-.2.1 40.8 40.8 0 00-1.8 3.7 54 54 0 00-16.2 0A37.4 37.4 0 0025.4.3a.2.2 0 00-.2-.1A58.4 58.4 0 0010.5 4.9a.2.2 0 00-.1.1C1.5 18.7-.9 32.2.3 45.5v.1a58.8 58.8 0 0017.7 9a.2.2 0 00.3-.1 42 42 0 003.6-5.9.2.2 0 00-.1-.3 38.8 38.8 0 01-5.5-2.6.2.2 0 01 0-.4l1.1-.9a.2.2 0 01.2 0 42 42 0 0035.6 0 .2.2 0 01.2 0l1.1.9a.2.2 0 010 .4 36.4 36.4 0 01-5.5 2.6.2.2 0 00-.1.3 47.2 47.2 0 003.6 5.9.2.2 0 00.3.1 58.6 58.6 0 0017.7-9v-.1c1.4-15.2-2.4-28.4-10-40.1a.2.2 0 00-.1-.1zM23.7 37.3c-3.5 0-6.3-3.2-6.3-7s2.8-7 6.3-7 6.4 3.2 6.3 7-2.8 7-6.3 7zm23.3 0c-3.5 0-6.3-3.2-6.3-7s2.8-7 6.3-7 6.4 3.2 6.3 7-2.8 7-6.3 7z"})})})})]})}a.s(["WorkspaceSidebar",()=>u],86976);let v={threadSidebarVisible:!1};function w(){return({...v}).threadSidebarVisible}function x(a){}a.s(["loadWorkspaceSidebarVisible",()=>w,"persistWorkspaceSidebarVisible",()=>x],55672)}];
2
2
 
3
3
  //# sourceMappingURL=components_thread_WorkspaceSidebar_tsx_e660301b._.js.map
@@ -20,11 +20,11 @@
20
20
  "wasm": [],
21
21
  "assets": [],
22
22
  "env": {
23
- "__NEXT_BUILD_ID": "H3MuYxcqCPfZoSC2uYW8f",
24
- "NEXT_SERVER_ACTIONS_ENCRYPTION_KEY": "aa3w8h7wB7M8/QViaO8Pokjct27IIVDX6eKv4vBJbqQ=",
25
- "__NEXT_PREVIEW_MODE_ID": "9d2463718b9f05f6691c08f84e17590a",
26
- "__NEXT_PREVIEW_MODE_ENCRYPTION_KEY": "9b8ecf0842fe5d29a1ba12a89241f852c69d171ff0823634af0f67d57a78eb30",
27
- "__NEXT_PREVIEW_MODE_SIGNING_KEY": "0453e6a95b26cc81ce6564590ffbbace068eade872ccd0f849e8cf3640d33f42"
23
+ "__NEXT_BUILD_ID": "R2CPNTvy5domQF90j_DYV",
24
+ "NEXT_SERVER_ACTIONS_ENCRYPTION_KEY": "pgx25EQn7eB/liWh0YHEFWoE85RBnN0yOjqUVVKBeTA=",
25
+ "__NEXT_PREVIEW_MODE_ID": "62125675c1400285d790cae113e3e2e0",
26
+ "__NEXT_PREVIEW_MODE_ENCRYPTION_KEY": "5f97ebfb23e5e31c1dd3c41dd30bdc7db8315b7e04c95677f9a5168aada836c3",
27
+ "__NEXT_PREVIEW_MODE_SIGNING_KEY": "640b2bd2111ac4c37cbd5c2aa3c00935bb989cb1640e15a54bdd335a8a8a5d3a"
28
28
  }
29
29
  }
30
30
  },