@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.
- package/cloud-runtime/standalone/.next/BUILD_ID +1 -1
- package/cloud-runtime/standalone/.next/build-manifest.json +2 -2
- package/cloud-runtime/standalone/.next/prerender-manifest.json +3 -3
- package/cloud-runtime/standalone/.next/server/app/_global-error.html +2 -2
- package/cloud-runtime/standalone/.next/server/app/_global-error.rsc +1 -1
- package/cloud-runtime/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/cloud-runtime/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/cloud-runtime/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/cloud-runtime/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/cloud-runtime/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/cloud-runtime/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/.next/server/app/_not-found.html +2 -2
- package/cloud-runtime/standalone/.next/server/app/_not-found.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/cloud-runtime/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/cloud-runtime/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/cloud-runtime/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/agents/[id]/page_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/.next/server/app/agents/page.js.nft.json +1 -1
- package/cloud-runtime/standalone/.next/server/app/agents/page_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/.next/server/app/agents.html +2 -2
- package/cloud-runtime/standalone/.next/server/app/agents.rsc +3 -3
- package/cloud-runtime/standalone/.next/server/app/agents.segments/_full.segment.rsc +3 -3
- package/cloud-runtime/standalone/.next/server/app/agents.segments/_head.segment.rsc +1 -1
- package/cloud-runtime/standalone/.next/server/app/agents.segments/_index.segment.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/agents.segments/_tree.segment.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/agents.segments/agents/__PAGE__.segment.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/agents.segments/agents.segment.rsc +1 -1
- package/cloud-runtime/standalone/.next/server/app/automations/page.js.nft.json +1 -1
- package/cloud-runtime/standalone/.next/server/app/automations/page_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/.next/server/app/automations.html +2 -2
- package/cloud-runtime/standalone/.next/server/app/automations.rsc +3 -3
- package/cloud-runtime/standalone/.next/server/app/automations.segments/_full.segment.rsc +3 -3
- package/cloud-runtime/standalone/.next/server/app/automations.segments/_head.segment.rsc +1 -1
- package/cloud-runtime/standalone/.next/server/app/automations.segments/_index.segment.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/automations.segments/_tree.segment.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/automations.segments/automations/__PAGE__.segment.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/automations.segments/automations.segment.rsc +1 -1
- package/cloud-runtime/standalone/.next/server/app/board/page_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/.next/server/app/board.html +2 -2
- package/cloud-runtime/standalone/.next/server/app/board.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/board.segments/_full.segment.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/board.segments/_head.segment.rsc +1 -1
- package/cloud-runtime/standalone/.next/server/app/board.segments/_index.segment.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/board.segments/_tree.segment.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/board.segments/board/__PAGE__.segment.rsc +1 -1
- package/cloud-runtime/standalone/.next/server/app/board.segments/board.segment.rsc +1 -1
- package/cloud-runtime/standalone/.next/server/app/execution-graph/page_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/.next/server/app/execution-graph.html +2 -2
- package/cloud-runtime/standalone/.next/server/app/execution-graph.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/execution-graph.segments/_full.segment.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/execution-graph.segments/_head.segment.rsc +1 -1
- package/cloud-runtime/standalone/.next/server/app/execution-graph.segments/_index.segment.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/execution-graph.segments/_tree.segment.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/execution-graph.segments/execution-graph/__PAGE__.segment.rsc +1 -1
- package/cloud-runtime/standalone/.next/server/app/execution-graph.segments/execution-graph.segment.rsc +1 -1
- package/cloud-runtime/standalone/.next/server/app/index.html +2 -2
- package/cloud-runtime/standalone/.next/server/app/index.rsc +3 -3
- package/cloud-runtime/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/index.segments/_full.segment.rsc +3 -3
- package/cloud-runtime/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/cloud-runtime/standalone/.next/server/app/index.segments/_index.segment.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/page.js.nft.json +1 -1
- package/cloud-runtime/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/.next/server/app/projects/[slug]/graph/[taskId]/page.js.nft.json +1 -1
- package/cloud-runtime/standalone/.next/server/app/projects/[slug]/graph/[taskId]/page_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/.next/server/app/projects/[slug]/page.js.nft.json +1 -1
- package/cloud-runtime/standalone/.next/server/app/projects/[slug]/page_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/.next/server/app/projects/orphans/page_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/.next/server/app/projects/orphans.html +1 -1
- package/cloud-runtime/standalone/.next/server/app/projects/orphans.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/projects/orphans.segments/_full.segment.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/projects/orphans.segments/_head.segment.rsc +1 -1
- package/cloud-runtime/standalone/.next/server/app/projects/orphans.segments/_index.segment.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/projects/orphans.segments/_tree.segment.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/projects/orphans.segments/projects/orphans/__PAGE__.segment.rsc +1 -1
- package/cloud-runtime/standalone/.next/server/app/projects/orphans.segments/projects/orphans.segment.rsc +1 -1
- package/cloud-runtime/standalone/.next/server/app/projects/orphans.segments/projects.segment.rsc +1 -1
- package/cloud-runtime/standalone/.next/server/app/projects/page_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/.next/server/app/projects.html +2 -2
- package/cloud-runtime/standalone/.next/server/app/projects.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/projects.segments/_full.segment.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/projects.segments/_head.segment.rsc +1 -1
- package/cloud-runtime/standalone/.next/server/app/projects.segments/_index.segment.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/projects.segments/_tree.segment.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/projects.segments/projects/__PAGE__.segment.rsc +1 -1
- package/cloud-runtime/standalone/.next/server/app/projects.segments/projects.segment.rsc +1 -1
- package/cloud-runtime/standalone/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/.next/server/app/settings.html +2 -2
- package/cloud-runtime/standalone/.next/server/app/settings.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/settings.segments/_full.segment.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/settings.segments/_head.segment.rsc +1 -1
- package/cloud-runtime/standalone/.next/server/app/settings.segments/_index.segment.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/settings.segments/_tree.segment.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +1 -1
- package/cloud-runtime/standalone/.next/server/app/settings.segments/settings.segment.rsc +1 -1
- package/cloud-runtime/standalone/.next/server/app/status/page_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/.next/server/app/status.html +2 -2
- package/cloud-runtime/standalone/.next/server/app/status.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/status.segments/_full.segment.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/status.segments/_head.segment.rsc +1 -1
- package/cloud-runtime/standalone/.next/server/app/status.segments/_index.segment.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/status.segments/_tree.segment.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/status.segments/status/__PAGE__.segment.rsc +1 -1
- package/cloud-runtime/standalone/.next/server/app/status.segments/status.segment.rsc +1 -1
- package/cloud-runtime/standalone/.next/server/app/thread/[id]/page.js.nft.json +1 -1
- package/cloud-runtime/standalone/.next/server/app/thread/[id]/page_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/.next/server/app/welcome/page_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/.next/server/app/welcome.html +2 -2
- package/cloud-runtime/standalone/.next/server/app/welcome.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/welcome.segments/_full.segment.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/welcome.segments/_head.segment.rsc +1 -1
- package/cloud-runtime/standalone/.next/server/app/welcome.segments/_index.segment.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/welcome.segments/_tree.segment.rsc +2 -2
- package/cloud-runtime/standalone/.next/server/app/welcome.segments/welcome/__PAGE__.segment.rsc +1 -1
- package/cloud-runtime/standalone/.next/server/app/welcome.segments/welcome.segment.rsc +1 -1
- package/cloud-runtime/standalone/.next/server/chunks/ssr/{[root-of-the-server]__3fe0b1a1._.js → [root-of-the-server]__d2c48923._.js} +2 -2
- package/cloud-runtime/standalone/.next/server/chunks/ssr/{_d743f11d._.js → _8bbe2ac1._.js} +2 -2
- package/cloud-runtime/standalone/.next/server/chunks/ssr/_cf5fdbfb._.js +3 -0
- package/cloud-runtime/standalone/.next/server/chunks/ssr/_d021529a._.js +3 -0
- package/cloud-runtime/standalone/.next/server/chunks/ssr/app_agents_page_tsx_f5f08ed8._.js +1 -1
- package/cloud-runtime/standalone/.next/server/chunks/ssr/components_thread_WorkspaceSidebar_tsx_e660301b._.js +1 -1
- package/cloud-runtime/standalone/.next/server/middleware-manifest.json +5 -5
- package/cloud-runtime/standalone/.next/server/pages/404.html +1 -1
- package/cloud-runtime/standalone/.next/server/pages/500.html +2 -2
- package/cloud-runtime/standalone/.next/server/server-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/.next/server/server-reference-manifest.json +1 -1
- package/cloud-runtime/standalone/.next/static/chunks/2a3594d4cb2efe79.css +1 -0
- package/cloud-runtime/standalone/.next/static/chunks/78f6cef7d2129d30.js +1 -0
- package/cloud-runtime/standalone/.next/static/chunks/81704a1c525bf2ee.js +1 -0
- package/cloud-runtime/standalone/app/agents/page.tsx +19 -214
- package/cloud-runtime/standalone/components/thread/WorkspaceSidebar.tsx +99 -91
- package/package.json +1 -1
- package/cloud-runtime/standalone/.next/server/chunks/ssr/_2da02644._.js +0 -3
- package/cloud-runtime/standalone/.next/server/chunks/ssr/_60f7e403._.js +0 -3
- package/cloud-runtime/standalone/.next/server/chunks/ssr/node_modules_lucide-react_dist_esm_icons_001a8448._.js +0 -3
- package/cloud-runtime/standalone/.next/static/chunks/1f1b912fe2e3d5bd.js +0 -1
- package/cloud-runtime/standalone/.next/static/chunks/4b3358c52d01a3f9.css +0 -1
- package/cloud-runtime/standalone/.next/static/chunks/5488a71a8515e8b2.js +0 -1
- package/cloud-runtime/standalone/.next/static/chunks/5ce01dbd17ce3bb2.js +0 -1
- package/cloud-runtime/standalone/.next/static/chunks/b649593a57df218f.js +0 -1
- /package/cloud-runtime/standalone/.next/static/{H3MuYxcqCPfZoSC2uYW8f → R2CPNTvy5domQF90j_DYV}/_buildManifest.js +0 -0
- /package/cloud-runtime/standalone/.next/static/{H3MuYxcqCPfZoSC2uYW8f → R2CPNTvy5domQF90j_DYV}/_clientMiddlewareManifest.json +0 -0
- /package/cloud-runtime/standalone/.next/static/{H3MuYxcqCPfZoSC2uYW8f → R2CPNTvy5domQF90j_DYV}/_ssgManifest.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,71689,e=>{"use strict";let t=(0,e.i(75254).default)("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);e.s(["ArrowLeft",()=>t],71689)},43531,e=>{"use strict";let t=(0,e.i(75254).default)("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);e.s(["Check",()=>t],43531)},99438,e=>{"use strict";let t="agx-chat:threads";function a(){let e=globalThis.localStorage;if(!e)throw Error("LocalThreadAdapter requires a browser-like environment with `localStorage`.");return e}function s(){let e=a().getItem(t);if(!e)return{threads:{}};try{let t=JSON.parse(e);if(t&&"object"==typeof t&&t.threads&&"object"==typeof t.threads)return{threads:Object.fromEntries(Object.entries(t.threads).map(([e,t])=>{var a,s;return[e,(a=e,s=t,{id:a,title:s?.title,messages:Array.isArray(s?.messages)?[...s.messages]:[],createdAt:"number"==typeof s?.createdAt?s.createdAt:Date.now(),updatedAt:"number"==typeof s?.updatedAt?s.updatedAt:Date.now(),metadata:s?.metadata,status:s?.status,outcomeNote:s?.outcomeNote,projectId:"string"==typeof s?.projectId?s.projectId:"string"==typeof s?.teamId?s.teamId:s?.projectId===null||s?.teamId===null?null:void 0})]}))}}catch{}return{threads:{}}}function r(e){a().setItem(t,JSON.stringify(e))}function n(e){return{...e,messages:e.messages.map(e=>({...e})),metadata:e.metadata?{...e.metadata}:void 0}}let l=new class{async saveThread(e){let t=Date.now(),a=s(),l=a.threads[e.id],i=l?.createdAt??e.createdAt??t,o=e.updatedAt??t,c={id:e.id,title:e.title,messages:e.messages.map(e=>({...e})),metadata:e.metadata,createdAt:i,updatedAt:o,status:e.status,outcomeNote:e.outcomeNote,projectId:e.projectId??e.teamId};return a.threads[e.id]=c,r(a),n(c)}async loadThread(e){let t=s().threads[e];return t?n(t):null}async listThreads(e){let t=Object.values(s().threads),a=e?.order??"desc",r=[...t].sort((e,t)=>"asc"===a?e.updatedAt-t.updatedAt:t.updatedAt-e.updatedAt),l=Math.max(0,e?.offset??0),i=e?.limit,o="number"==typeof i&&i>=0?r.slice(l,l+i):r.slice(l);return{total:t.length,threads:o.map(n)}}async deleteThread(e){let t=s();t.threads[e]&&(delete t.threads[e],r(t))}};e.s(["threadService",0,{listThreads:async()=>[...(await l.listThreads({order:"desc"})).threads.filter(e=>!0!==e.metadata?.archived)].sort((e,t)=>t.updatedAt-e.updatedAt),async createThread(e){let t="string"==typeof e?.id?e.id.trim():"";if(t){let a=await l.loadThread(t);if(a){let t={...a.metadata??{},...e?.metadata??{},archived:!1,archivedAt:null};return l.saveThread({id:a.id,title:e?.title??a.title,messages:e?.messages?.length?e.messages:a.messages,metadata:t,createdAt:a.createdAt})}}let a={id:t||("u">typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():`thread-${Date.now()}-${Math.random().toString(16).slice(2)}`),messages:e?.messages?.length?e.messages:[],title:e?.title,metadata:e?.metadata};return l.saveThread(a)},async deleteThread(e){let t=e.trim();if(!t)return;let a=await l.loadThread(t);if(!a)return;let s={...a.metadata??{},archived:!0,archivedAt:Date.now()};await l.saveThread({id:a.id,title:a.title,messages:a.messages,metadata:s,createdAt:a.createdAt})},async renameThread(e,t){let a=e.trim(),s=t.trim();if(!a||!s)return null;let r=await l.loadThread(a);return r?(r.title?.trim()??"")===s?r:l.saveThread({id:r.id,title:s,messages:r.messages,metadata:r.metadata,createdAt:r.createdAt}):null},async updateThreadStatus(e,t){let a=await l.loadThread(e);return a?a.status===t?a:l.saveThread({id:a.id,title:a.title,messages:a.messages,metadata:a.metadata,createdAt:a.createdAt,status:t,outcomeNote:a.outcomeNote}):null},async updateThreadOutcomeNote(e,t){let a=await l.loadThread(e);return a?a.outcomeNote===t?a:l.saveThread({id:a.id,title:a.title,messages:a.messages,metadata:a.metadata,createdAt:a.createdAt,status:a.status,outcomeNote:t}):null},async updateMessageThreadStatus(e,t,a){let s=await l.loadThread(e);if(!s)return null;let r=s.messages.map(e=>e.id===t?{...e,threadStatus:a}:e);return l.saveThread({id:s.id,title:s.title,messages:r,metadata:s.metadata,createdAt:s.createdAt,status:s.status,outcomeNote:s.outcomeNote})},async updateMessageOutcomeNote(e,t,a){let s=await l.loadThread(e);if(!s)return null;let r=s.messages.map(e=>e.id===t?{...e,outcomeNote:a}:e);return l.saveThread({id:s.id,title:s.title,messages:r,metadata:s.metadata,createdAt:s.createdAt,status:s.status,outcomeNote:s.outcomeNote})},async saveThreadMessages(e,t){let a=await l.loadThread(e);if(!a)return null;let s=a.title?.trim()||function(e){let t=e.find(e=>"user"===e.role)?.content?.trim();if(!t)return;let a=t.replace(/\s+/g," ");return a.length>60?`${a.slice(0,60).trim()}…`:a}(t);return function(e,t){if(e.length!==t.length)return!1;for(let a=0;a<e.length;a+=1){let s=e[a],r=t[a];if(s.id!==r.id||s.role!==r.role||s.participantId!==r.participantId||s.content!==r.content||s.timestamp!==r.timestamp)return!1}return!0}(a.messages,t)&&(a.title?.trim()||void 0)===s?a:l.saveThread({id:a.id,title:s,messages:t,metadata:a.metadata,createdAt:a.createdAt})}}],99438)},74049,e=>{"use strict";var t=e.i(71645);function a(){let[e,a]=(0,t.useState)([]),[s,r]=(0,t.useState)(!1),[n,l]=(0,t.useState)(null),i=(0,t.useCallback)(async()=>{r(!0);try{let e=await fetch("/api/projects");if(!e.ok)throw Error("Failed to fetch projects");let t=await e.json();a(t.projects??[]),l(null)}catch(e){l(e instanceof Error?e:Error("Unknown error"))}finally{r(!1)}},[]);(0,t.useEffect)(()=>{i()},[i]);let o=(0,t.useCallback)(async e=>{let t=await fetch("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw Error((await t.json().catch(()=>({}))).error||"Failed to create project");let s=(await t.json()).project;return a(e=>[s,...e]),s},[]);return{projects:e,isLoading:s,error:n,refetch:i,createProject:o,updateProject:(0,t.useCallback)(async(e,t)=>{let s=await fetch(`/api/projects/${e}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!s.ok)throw Error((await s.json().catch(()=>({}))).error||"Failed to update project");let r=(await s.json()).project;return a(t=>t.map(t=>t.id===e?r:t)),r},[]),deleteProject:(0,t.useCallback)(async e=>{let t=await fetch(`/api/projects/${e}`,{method:"DELETE"});if(!t.ok)throw Error((await t.json().catch(()=>({}))).error||"Failed to delete project");a(t=>t.filter(t=>t.id!==e))},[])}}function s(){let[e,a]=(0,t.useState)([]),[s,r]=(0,t.useState)(!0),n=(0,t.useCallback)(async()=>{try{let e=await fetch("/api/projects");if(!e.ok)return;let{projects:t}=await e.json(),s=await Promise.all((t??[]).map(async e=>{let t=[],a=[];try{let[s,r]=await Promise.all([fetch(`/api/projects/${e.id}/agents`),fetch(`/api/projects/${e.id}/threads`)]);s.ok&&(t=(await s.json()).agents??[]),r.ok&&(a=((await r.json()).threads??[]).map(e=>e.thread_id))}catch{}return{...e,repos:e.repos??[],agents:t.map(t=>({project_id:e.id,agent_id:t.agent_id,routing_order:t.routing_order,created_at:t.created_at})),thread_ids:a,workspace_ids:a}}));a(s)}catch{}finally{r(!1)}},[]);(0,t.useEffect)(()=>{n()},[n]);let l=(0,t.useCallback)(async(e,t)=>{try{let s="string"==typeof e?{name:e}:e,r=s.name.trim(),n=(s.slug||r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")).trim(),l=await fetch("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,name:r,slug:n})});if(!l.ok)return null;let{project:i}=await l.json(),o=Array.isArray(t)?t:t?[t]:[];for(let e of o)await fetch(`/api/projects/${i.id}/threads`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({threadId:e})}).catch(()=>{});let c={...i,repos:i.repos??[],agents:[],thread_ids:o,workspace_ids:o};return a(e=>[...e,c].sort((e,t)=>e.name.localeCompare(t.name))),c}catch{return null}},[]),i=(0,t.useCallback)(async(e,t)=>{try{if(!(await fetch(`/api/projects/${e}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t})})).ok)return;a(a=>a.map(a=>a.id===e?{...a,name:t}:a).sort((e,t)=>e.name.localeCompare(t.name)))}catch{}},[]),o=(0,t.useCallback)(async e=>{try{if(!(await fetch(`/api/projects/${e}`,{method:"DELETE"})).ok)return;a(t=>t.filter(t=>t.id!==e))}catch{}},[]),c=(0,t.useCallback)(async(e,t)=>{try{let s=await fetch(`/api/projects/${e}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!s.ok){let e=await s.json().catch(()=>({}));throw Error(e.error||"Failed to update project")}let r=(await s.json()).project;return a(t=>t.map(t=>t.id===e?{...t,...r,repos:r.repos??t.repos}:t)),r}catch{return null}},[]),d=(0,t.useCallback)(async(e,t)=>{try{let s=await fetch(`/api/projects/${e}/agents`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentId:t})});if(!s.ok)return;let r=((await s.json()).agents??[]).map(t=>({project_id:e,agent_id:t.agent_id,routing_order:t.routing_order,created_at:t.created_at}));a(t=>t.map(t=>t.id===e?{...t,agents:r}:t))}catch{}},[]),u=(0,t.useCallback)(async(e,t)=>{try{let s=await fetch(`/api/projects/${e}/agents?agentId=${t}`,{method:"DELETE"});if(!s.ok)return;let r=((await s.json()).agents??[]).map(t=>({project_id:e,agent_id:t.agent_id,routing_order:t.routing_order,created_at:t.created_at}));a(t=>t.map(t=>t.id===e?{...t,agents:r}:t))}catch{}},[]);return{projects:e,isLoading:s,createProject:l,updateProject:c,renameProject:i,deleteProject:o,addAgent:d,removeAgent:u,reorderAgents:(0,t.useCallback)(async(e,t)=>{try{let s=await fetch(`/api/projects/${e}/agents`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({orderedAgentIds:t})});if(!s.ok)return;let r=((await s.json()).agents??[]).map(t=>({project_id:e,agent_id:t.agent_id,routing_order:t.routing_order,created_at:t.created_at}));a(t=>t.map(t=>t.id===e?{...t,agents:r}:t))}catch{}},[]),moveAgent:(0,t.useCallback)(async(e,t,a)=>{try{await fetch(`/api/projects/${t}/agents?agentId=${e}`,{method:"DELETE"}),await fetch(`/api/projects/${a}/agents`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentId:e})}),await n()}catch{}},[n]),refresh:n}}e.s(["useProjects",()=>a,"useProjectsWithAgents",()=>s])},33525,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0}),Object.defineProperty(a,"warnOnce",{enumerable:!0,get:function(){return s}});let s=e=>{}},98183,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0});var s={assign:function(){return o},searchParamsToUrlQuery:function(){return n},urlQueryToSearchParams:function(){return i}};for(var r in s)Object.defineProperty(a,r,{enumerable:!0,get:s[r]});function n(e){let t={};for(let[a,s]of e.entries()){let e=t[a];void 0===e?t[a]=s:Array.isArray(e)?e.push(s):t[a]=[e,s]}return t}function l(e){return"string"==typeof e?e:("number"!=typeof e||isNaN(e))&&"boolean"!=typeof e?"":String(e)}function i(e){let t=new URLSearchParams;for(let[a,s]of Object.entries(e))if(Array.isArray(s))for(let e of s)t.append(a,l(e));else t.set(a,l(s));return t}function o(e,...t){for(let a of t){for(let t of a.keys())e.delete(t);for(let[t,s]of a.entries())e.append(t,s)}return e}},61746,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0});var s={formatUrl:function(){return i},formatWithValidation:function(){return c},urlObjectKeys:function(){return o}};for(var r in s)Object.defineProperty(a,r,{enumerable:!0,get:s[r]});let n=e.r(90809)._(e.r(98183)),l=/https?|ftp|gopher|file/;function i(e){let{auth:t,hostname:a}=e,s=e.protocol||"",r=e.pathname||"",i=e.hash||"",o=e.query||"",c=!1;t=t?encodeURIComponent(t).replace(/%3A/i,":")+"@":"",e.host?c=t+e.host:a&&(c=t+(~a.indexOf(":")?`[${a}]`:a),e.port&&(c+=":"+e.port)),o&&"object"==typeof o&&(o=String(n.urlQueryToSearchParams(o)));let d=e.search||o&&`?${o}`||"";return s&&!s.endsWith(":")&&(s+=":"),e.slashes||(!s||l.test(s))&&!1!==c?(c="//"+(c||""),r&&"/"!==r[0]&&(r="/"+r)):c||(c=""),i&&"#"!==i[0]&&(i="#"+i),d&&"?"!==d[0]&&(d="?"+d),r=r.replace(/[?#]/g,encodeURIComponent),d=d.replace("#","%23"),`${s}${c}${r}${d}${i}`}let o=["auth","hash","host","hostname","href","path","pathname","port","protocol","query","search","slashes"];function c(e){return i(e)}},18581,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0}),Object.defineProperty(a,"useMergedRef",{enumerable:!0,get:function(){return r}});let s=e.r(71645);function r(e,t){let a=(0,s.useRef)(null),r=(0,s.useRef)(null);return(0,s.useCallback)(s=>{if(null===s){let e=a.current;e&&(a.current=null,e());let t=r.current;t&&(r.current=null,t())}else e&&(a.current=n(e,s)),t&&(r.current=n(t,s))},[e,t])}function n(e,t){if("function"!=typeof e)return e.current=t,()=>{e.current=null};{let a=e(t);return"function"==typeof a?a:()=>e(null)}}("function"==typeof a.default||"object"==typeof a.default&&null!==a.default)&&void 0===a.default.__esModule&&(Object.defineProperty(a.default,"__esModule",{value:!0}),Object.assign(a.default,a),t.exports=a.default)},18967,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0});var s={DecodeError:function(){return g},MiddlewareNotFoundError:function(){return v},MissingStaticPage:function(){return b},NormalizeError:function(){return y},PageNotFoundError:function(){return j},SP:function(){return h},ST:function(){return f},WEB_VITALS:function(){return n},execOnce:function(){return l},getDisplayName:function(){return u},getLocationOrigin:function(){return c},getURL:function(){return d},isAbsoluteUrl:function(){return o},isResSent:function(){return p},loadGetInitialProps:function(){return m},normalizeRepeatedSlashes:function(){return x},stringifyError:function(){return w}};for(var r in s)Object.defineProperty(a,r,{enumerable:!0,get:s[r]});let n=["CLS","FCP","FID","INP","LCP","TTFB"];function l(e){let t,a=!1;return(...s)=>(a||(a=!0,t=e(...s)),t)}let i=/^[a-zA-Z][a-zA-Z\d+\-.]*?:/,o=e=>i.test(e);function c(){let{protocol:e,hostname:t,port:a}=window.location;return`${e}//${t}${a?":"+a:""}`}function d(){let{href:e}=window.location,t=c();return e.substring(t.length)}function u(e){return"string"==typeof e?e:e.displayName||e.name||"Unknown"}function p(e){return e.finished||e.headersSent}function x(e){let t=e.split("?");return t[0].replace(/\\/g,"/").replace(/\/\/+/g,"/")+(t[1]?`?${t.slice(1).join("?")}`:"")}async function m(e,t){let a=t.res||t.ctx&&t.ctx.res;if(!e.getInitialProps)return t.ctx&&t.Component?{pageProps:await m(t.Component,t.ctx)}:{};let s=await e.getInitialProps(t);if(a&&p(a))return s;if(!s)throw Object.defineProperty(Error(`"${u(e)}.getInitialProps()" should resolve to an object. But found "${s}" instead.`),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0});return s}let h="u">typeof performance,f=h&&["mark","measure","getEntriesByName"].every(e=>"function"==typeof performance[e]);class g extends Error{}class y extends Error{}class j extends Error{constructor(e){super(),this.code="ENOENT",this.name="PageNotFoundError",this.message=`Cannot find module for page: ${e}`}}class b extends Error{constructor(e,t){super(),this.message=`Failed to load static file for page: ${e} ${t}`}}class v extends Error{constructor(){super(),this.code="ENOENT",this.message="Cannot find the middleware module"}}function w(e){return JSON.stringify({message:e.message,stack:e.stack})}},73668,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0}),Object.defineProperty(a,"isLocalURL",{enumerable:!0,get:function(){return n}});let s=e.r(18967),r=e.r(52817);function n(e){if(!(0,s.isAbsoluteUrl)(e))return!0;try{let t=(0,s.getLocationOrigin)(),a=new URL(e,t);return a.origin===t&&(0,r.hasBasePath)(a.pathname)}catch(e){return!1}}},84508,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0}),Object.defineProperty(a,"errorOnce",{enumerable:!0,get:function(){return s}});let s=e=>{}},22016,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0});var s={default:function(){return g},useLinkStatus:function(){return j}};for(var r in s)Object.defineProperty(a,r,{enumerable:!0,get:s[r]});let n=e.r(90809),l=e.r(18050),i=n._(e.r(71645)),o=e.r(61746),c=e.r(8372),d=e.r(18581),u=e.r(18967),p=e.r(5550);e.r(33525);let x=e.r(91949),m=e.r(73668),h=e.r(9396);function f(e){return"string"==typeof e?e:(0,o.formatUrl)(e)}function g(t){var a;let s,r,n,[o,g]=(0,i.useOptimistic)(x.IDLE_LINK_STATUS),j=(0,i.useRef)(null),{href:b,as:v,children:w,prefetch:N=null,passHref:k,replace:S,shallow:C,scroll:A,onClick:T,onMouseEnter:E,onTouchStart:_,legacyBehavior:P=!1,onNavigate:O,ref:z,unstable_dynamicOnHover:$,...I}=t;s=w,P&&("string"==typeof s||"number"==typeof s)&&(s=(0,l.jsx)("a",{children:s}));let L=i.default.useContext(c.AppRouterContext),M=!1!==N,U=!1!==N?null===(a=N)||"auto"===a?h.FetchStrategy.PPR:h.FetchStrategy.Full:h.FetchStrategy.PPR,{href:D,as:R}=i.default.useMemo(()=>{let e=f(b);return{href:e,as:v?f(v):e}},[b,v]);if(P){if(s?.$$typeof===Symbol.for("react.lazy"))throw Object.defineProperty(Error("`<Link legacyBehavior>` received a direct child that is either a Server Component, or JSX that was loaded with React.lazy(). This is not supported. Either remove legacyBehavior, or make the direct child a Client Component that renders the Link's `<a>` tag."),"__NEXT_ERROR_CODE",{value:"E863",enumerable:!1,configurable:!0});r=i.default.Children.only(s)}let F=P?r&&"object"==typeof r&&r.ref:z,B=i.default.useCallback(e=>(null!==L&&(j.current=(0,x.mountLinkInstance)(e,D,L,U,M,g)),()=>{j.current&&((0,x.unmountLinkForCurrentNavigation)(j.current),j.current=null),(0,x.unmountPrefetchableInstance)(e)}),[M,D,L,U,g]),J={ref:(0,d.useMergedRef)(B,F),onClick(t){P||"function"!=typeof T||T(t),P&&r.props&&"function"==typeof r.props.onClick&&r.props.onClick(t),!L||t.defaultPrevented||function(t,a,s,r,n,l,o){if("u">typeof window){let c,{nodeName:d}=t.currentTarget;if("A"===d.toUpperCase()&&((c=t.currentTarget.getAttribute("target"))&&"_self"!==c||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||t.nativeEvent&&2===t.nativeEvent.which)||t.currentTarget.hasAttribute("download"))return;if(!(0,m.isLocalURL)(a)){n&&(t.preventDefault(),location.replace(a));return}if(t.preventDefault(),o){let e=!1;if(o({preventDefault:()=>{e=!0}}),e)return}let{dispatchNavigateAction:u}=e.r(99781);i.default.startTransition(()=>{u(s||a,n?"replace":"push",l??!0,r.current)})}}(t,D,R,j,S,A,O)},onMouseEnter(e){P||"function"!=typeof E||E(e),P&&r.props&&"function"==typeof r.props.onMouseEnter&&r.props.onMouseEnter(e),L&&M&&(0,x.onNavigationIntent)(e.currentTarget,!0===$)},onTouchStart:function(e){P||"function"!=typeof _||_(e),P&&r.props&&"function"==typeof r.props.onTouchStart&&r.props.onTouchStart(e),L&&M&&(0,x.onNavigationIntent)(e.currentTarget,!0===$)}};return(0,u.isAbsoluteUrl)(R)?J.href=R:P&&!k&&("a"!==r.type||"href"in r.props)||(J.href=(0,p.addBasePath)(R)),n=P?i.default.cloneElement(r,J):(0,l.jsx)("a",{...I,...J,children:s}),(0,l.jsx)(y.Provider,{value:o,children:n})}e.r(84508);let y=(0,i.createContext)(x.IDLE_LINK_STATUS),j=()=>(0,i.useContext)(y);("function"==typeof a.default||"object"==typeof a.default&&null!==a.default)&&void 0===a.default.__esModule&&(Object.defineProperty(a.default,"__esModule",{value:!0}),Object.assign(a.default,a),t.exports=a.default)},75254,e=>{"use strict";var t=e.i(71645);let a=(...e)=>e.filter((e,t,a)=>!!e&&""!==e.trim()&&a.indexOf(e)===t).join(" ").trim(),s=e=>{let t=e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,a)=>a?a.toUpperCase():t.toLowerCase());return t.charAt(0).toUpperCase()+t.slice(1)};var r={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 n=(0,t.forwardRef)(({color:e="currentColor",size:s=24,strokeWidth:n=2,absoluteStrokeWidth:l,className:i="",children:o,iconNode:c,...d},u)=>(0,t.createElement)("svg",{ref:u,...r,width:s,height:s,stroke:e,strokeWidth:l?24*Number(n)/Number(s):n,className:a("lucide",i),...!o&&!(e=>{for(let t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0;return!1})(d)&&{"aria-hidden":"true"},...d},[...c.map(([e,a])=>(0,t.createElement)(e,a)),...Array.isArray(o)?o:[o]])),l=(e,r)=>{let l=(0,t.forwardRef)(({className:l,...i},o)=>(0,t.createElement)(n,{ref:o,iconNode:r,className:a(`lucide-${s(e).replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${e}`,l),...i}));return l.displayName=s(e),l};e.s(["default",()=>l],75254)},7233,e=>{"use strict";let t=(0,e.i(75254).default)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);e.s(["Plus",()=>t],7233)},10980,e=>{"use strict";let t=(0,e.i(75254).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"}]]);e.s(["BookOpen",()=>t],10980)},55838,(e,t,a)=>{"use strict";var s=e.r(71645),r="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},n=s.useState,l=s.useEffect,i=s.useLayoutEffect,o=s.useDebugValue;function c(e){var t=e.getSnapshot;e=e.value;try{var a=t();return!r(e,a)}catch(e){return!0}}var d="u"<typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var a=t(),s=n({inst:{value:a,getSnapshot:t}}),r=s[0].inst,d=s[1];return i(function(){r.value=a,r.getSnapshot=t,c(r)&&d({inst:r})},[e,a,t]),l(function(){return c(r)&&d({inst:r}),e(function(){c(r)&&d({inst:r})})},[e]),o(a),a};a.useSyncExternalStore=void 0!==s.useSyncExternalStore?s.useSyncExternalStore:d},2239,(e,t,a)=>{"use strict";t.exports=e.r(55838)},52822,(e,t,a)=>{"use strict";var s=e.r(71645),r=e.r(2239),n="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},l=r.useSyncExternalStore,i=s.useRef,o=s.useEffect,c=s.useMemo,d=s.useDebugValue;a.useSyncExternalStoreWithSelector=function(e,t,a,s,r){var u=i(null);if(null===u.current){var p={hasValue:!1,value:null};u.current=p}else p=u.current;var x=l(e,(u=c(function(){function e(e){if(!o){if(o=!0,l=e,e=s(e),void 0!==r&&p.hasValue){var t=p.value;if(r(t,e))return i=t}return i=e}if(t=i,n(l,e))return t;var a=s(e);return void 0!==r&&r(t,a)?(l=e,t):(l=e,i=a)}var l,i,o=!1,c=void 0===a?null:a;return[function(){return e(t())},null===c?void 0:function(){return e(c())}]},[t,a,s,r]))[0],u[1]);return o(function(){p.hasValue=!0,p.value=x},[x]),d(x),x}},30224,(e,t,a)=>{"use strict";t.exports=e.r(52822)},63059,e=>{"use strict";let t=(0,e.i(75254).default)("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);e.s(["ChevronRight",()=>t],63059)},88081,e=>{"use strict";let t=(0,e.i(75254).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"}]]);e.s(["Hash",()=>t],88081)},88699,e=>{"use strict";let t=(0,e.i(75254).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"}]]);e.s(["Pencil",()=>t],88699)},40160,e=>{"use strict";let t=(0,e.i(75254).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"}]]);e.s(["Download",()=>t],40160)},61911,e=>{"use strict";let t=(0,e.i(75254).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"}]]);e.s(["Users",()=>t],61911)},74886,e=>{"use strict";let t=(0,e.i(75254).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"}]]);e.s(["Copy",()=>t],74886)},61628,e=>{"use strict";var t=e.i(18050),a=e.i(71645),s=e.i(22016),r=e.i(71689),n=e.i(64659),l=e.i(63059),i=e.i(74886),o=e.i(43531),c=e.i(40160),d=e.i(75254);let u=(0,d.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 p=e.i(88081),x=e.i(88699),m=e.i(7233);let h=(0,d.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"}]]),f=(0,d.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 g=e.i(61911),y=e.i(37727),j=e.i(74049),b=e.i(25459),v=e.i(99438);function w(e){return e?e.projects??[]:[]}function N(){let[e,d]=(0,a.useState)([]),[N,k]=(0,a.useState)([]),{projects:S,createProject:C,addAgent:A,removeAgent:T,refresh:E}=(0,j.useProjectsWithAgents)(),[_,P]=(0,a.useState)(new Set),[O,z]=(0,a.useState)(null),[$,I]=(0,a.useState)(new Set),[L,M]=(0,a.useState)(!1),[U,D]=(0,a.useState)(null),[R,F]=(0,a.useState)(!1),[B,J]=(0,a.useState)(new Set),[H,K]=(0,a.useState)(!0),[V,W]=(0,a.useState)(!1),[X,q]=(0,a.useState)(null),[Z,Q]=(0,a.useState)(null),[G,Y]=(0,a.useState)(!1),[ee,et]=(0,a.useState)(!1),[ea,es]=(0,a.useState)("choice"),[er,en]=(0,a.useState)(""),[el,ei]=(0,a.useState)(!1),[eo,ec]=(0,a.useState)(null),[ed,eu]=(0,a.useState)(new Set),[ep,ex]=(0,a.useState)(new Set),[em,eh]=(0,a.useState)(!1),[ef,eg]=(0,a.useState)(null),ey=(0,a.useRef)(null),[ej,eb]=(0,a.useState)(new Set),ev=()=>{fetch("/api/participants").then(e=>e.json()).then(e=>d(Array.isArray(e)?e:[]))},ew=(0,a.useCallback)(async()=>{try{let e=await fetch("/api/processes");if(!e.ok)return;let t=await e.json();eb(new Set(t.filter(e=>"spawning"===e.state||"running"===e.state).map(e=>e.agentId)))}catch{}},[]);(0,a.useEffect)(()=>{ev(),v.threadService.listThreads().then(k),ew();let e=setInterval(ew,3e3);return()=>clearInterval(e)},[ew]);let eN=new Map(N.map(e=>[e.id,e])),ek=S.filter(e=>!e.is_default),eS=async()=>{if(0!==B.size){W(!0);try{let e=await fetch("/api/agent-specs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentIds:Array.from(B),includeSelf:H})});if(!e.ok)throw Error("Share failed");let t=await e.json();q(t.code),Q(t.expires_at)}catch(e){console.error("Share error:",e)}finally{W(!1)}}},eC=async()=>{if(0!==B.size){W(!0);try{let e=Array.from(B),t=await fetch("/api/agents/export",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentIds:e})});if(!t.ok)throw Error("Export failed");let a=(await t.json()).agents.map(e=>({...e,self:H?e.self:null})),s={version:1,exportedAt:new Date().toISOString(),agents:a,projects:[]},r=new Blob([JSON.stringify(s,null,2)],{type:"application/json"}),n=URL.createObjectURL(r),l=document.createElement("a");l.href=n,l.download=1===a.length?`${a[0].name.toLowerCase().replace(/\s+/g,"-")}.agent.json`:"agents.bundle.json",l.click(),URL.revokeObjectURL(n),F(!1)}catch(e){console.error("Export error:",e)}finally{W(!1)}}},eA=async()=>{if(0!==er.trim().length){ei(!0),eg(null),ec(null);try{let e=await fetch(`/api/agent-specs/pull?code=${encodeURIComponent(er.trim())}`);if(!e.ok){let t=await e.json().catch(()=>({error:"Failed to pull"}));eg(t.error||"Code not found or expired");return}let t=(await e.json()).bundle;ec(t),eu(new Set(t.agents.map(e=>e.id))),ex(new Set(w(t).map(e=>e.name)))}catch{eg("Failed to connect. Is agx-api running?")}finally{ei(!1)}}},eT=async()=>{if(eo){eh(!0);try{let t=new Set(e.map(e=>e.id));for(let e of eo.agents){if(!ed.has(e.id))continue;let a={name:e.name,provider:e.provider,model:e.model,color:e.color,identity:e.identity||void 0,identityFile:e.identityFile||void 0,skills:e.skills||[],variables:e.variables||{}};t.has(e.id)?(a.id=e.id,await fetch("/api/participants",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})):await fetch("/api/participants",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})}for(let e of w(eo)){if(!ep.has(e.name))continue;let t=await C(e.name);if(t)for(let a of e.agentIds)ed.has(a)&&await A(t.id,a)}ev(),await E(),et(!1),ec(null)}catch(e){console.error("Import error:",e),eg("Import failed. Check console for details.")}finally{eh(!1)}}},eE=O?S.find(e=>e.id===O.projectId):null,e_=new Set(eE?.agents.map(e=>e.agent_id)??[]),eP=O?e.filter(e=>!e_.has(e.id)):[],eO=({checked:e})=>(0,t.jsx)("div",{className:`w-4 h-4 rounded border flex-shrink-0 flex items-center justify-center ${e?"bg-slate-900 border-slate-900":"border-slate-300"}`,children:e&&(0,t.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:(0,t.jsx)("path",{d:"M2 5l2 2 4-4",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})});return(0,t.jsxs)("div",{className:"min-h-screen bg-slate-50 p-6",children:[(0,t.jsxs)("div",{className:"max-w-6xl mx-auto",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 mb-6",children:[(0,t.jsxs)(s.default,{href:"/",className:"inline-flex items-center gap-1 text-sm text-slate-500 hover:text-slate-700 transition-colors",children:[(0,t.jsx)(r.ArrowLeft,{size:16}),"Back"]}),(0,t.jsx)("h1",{className:"text-2xl font-semibold text-slate-900",children:"Manage Agents"}),(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,t.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(!0),children:[(0,t.jsx)(m.Plus,{size:13}),"New Agent"]}),(0,t.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:()=>{J(new Set(e.map(e=>e.id))),K(!0),q(null),Q(null),Y(!1),F(!0)},disabled:0===e.length,children:[(0,t.jsx)(h,{size:13}),"Share"]}),(0,t.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:()=>{es("choice"),en(""),ec(null),eu(new Set),ex(new Set),eg(null),et(!0)},children:[(0,t.jsx)(c.Download,{size:13}),"Import"]}),(0,t.jsx)("input",{ref:ey,type:"file",accept:".json",className:"hidden",onChange:e=>{let t=e.target.files?.[0];if(!t)return;eg(null);let a=new FileReader;a.onload=()=>{try{let e=JSON.parse(a.result);if(!e.version||!Array.isArray(e.agents))throw Error("Invalid bundle format");ec(e),eu(new Set(e.agents.map(e=>e.id))),ex(new Set(w(e).map(e=>e.name)))}catch{eg("Invalid file. Expected an .agent.json bundle.")}},a.readAsText(t),e.target.value=""}})]})]}),ef&&!ee&&(0,t.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,t.jsx)("span",{children:ef}),(0,t.jsx)("button",{type:"button",onClick:()=>eg(null),className:"text-red-400 hover:text-red-600",children:(0,t.jsx)(y.X,{size:14})})]}),0===e.length?(0,t.jsx)("p",{className:"text-slate-500 text-sm",children:"No agents configured yet."}):(0,t.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:e.map(e=>(0,t.jsxs)("div",{className:"bg-white rounded-xl border border-slate-200 p-4 hover:shadow-md transition-shadow text-left group",children:[(0,t.jsxs)("div",{className:"flex items-start gap-3 mb-3",children:[(0,t.jsx)("img",{src:(0,b.agentAvatarUrl)(e.id,48,e.color),alt:e.name,className:"w-12 h-12 rounded-full bg-slate-100"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("h3",{className:"font-medium text-slate-900 truncate",children:e.name}),(0,t.jsx)("p",{className:"text-xs text-slate-400 truncate mt-0.5",children:e.model}),ej.has(e.id)&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 mt-1 text-[10px] font-medium text-emerald-600",children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"}),"Working"]})]})]}),e.skills&&e.skills.length>0&&(0,t.jsxs)("div",{className:"flex flex-wrap gap-1 mb-3",children:[e.skills.slice(0,3).map((e,a)=>(0,t.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-blue-50 text-blue-600 truncate max-w-[120px]",children:e.file.split("/").pop()},a)),e.skills.length>3&&(0,t.jsxs)("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-50 text-slate-400",children:["+",e.skills.length-3]})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between pt-2 border-t border-slate-100",children:[(0,t.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:e.provider}),(0,t.jsxs)("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[(0,t.jsx)("button",{type:"button",title:"Edit",onClick:()=>D(e),className:"p-1.5 text-slate-400 hover:text-slate-600 rounded hover:bg-slate-50 transition-colors",children:(0,t.jsx)(x.Pencil,{size:13})}),(0,t.jsx)(s.default,{href:`/agents/${e.id}`,title:"View profile",className:"p-1.5 text-slate-400 hover:text-slate-600 rounded hover:bg-slate-50 transition-colors",children:(0,t.jsx)(u,{size:13})})]})]})]},e.id))}),(0,t.jsxs)("div",{className:"mt-10",children:[(0,t.jsxs)("div",{className:"mb-4",children:[(0,t.jsx)("h2",{className:"text-lg font-semibold text-slate-900",children:"Project assignments"}),(0,t.jsx)("p",{className:"mt-1 text-sm text-slate-400",children:"Assign agents to existing projects."})]}),0===ek.length?(0,t.jsx)("p",{className:"text-sm text-slate-400",children:"No projects available for assignment."}):(0,t.jsx)("div",{className:"bg-white rounded-xl border border-slate-200 divide-y divide-slate-100",children:ek.map(a=>{let s=_.has(a.id),r=(a.thread_ids??[]).map(e=>eN.get(e)?.title?.trim()||"Untitled").filter(Boolean);return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 px-5 py-3.5 group",children:[(0,t.jsxs)("button",{type:"button",className:"flex items-center gap-3 flex-1 min-w-0 text-left",onClick:()=>{var e;return e=a.id,void P(t=>{let a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a})},children:[s?(0,t.jsx)(n.ChevronDown,{size:16,className:"text-slate-400 flex-shrink-0"}):(0,t.jsx)(l.ChevronRight,{size:16,className:"text-slate-400 flex-shrink-0"}),(0,t.jsx)(g.Users,{size:16,className:"text-slate-400 flex-shrink-0"}),(0,t.jsx)("span",{className:"font-medium text-slate-800 text-sm",children:a.name}),(0,t.jsxs)("span",{className:"text-xs text-slate-400",children:[a.agents.length," ",1===a.agents.length?"agent":"agents",r.length>0&&` \xb7 ${r.length} ${1===r.length?"thread":"threads"}`]})]}),(0,t.jsx)("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:(0,t.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:()=>{I(new Set),z({projectId:a.id})},children:[(0,t.jsx)(m.Plus,{size:14}),"Add agents"]})})]}),s&&(0,t.jsxs)("div",{className:"px-5 pb-4 pt-1 ml-9 flex flex-col gap-1",children:[0===a.agents.length&&(0,t.jsx)("p",{className:"text-xs text-slate-400 py-1",children:"No agents in this project."}),a.agents.map(s=>{let r=e.find(e=>e.id===s.agent_id);return(0,t.jsxs)("div",{className:"flex items-center gap-2.5 py-1.5 group/agent",children:[(0,t.jsx)("img",{src:(0,b.agentAvatarUrl)(s.agent_id,24,r?.color),alt:"",className:"w-6 h-6 rounded-full flex-shrink-0"}),(0,t.jsx)("span",{className:"text-sm text-slate-700 truncate flex-1",children:r?.name??s.agent_id}),(0,t.jsx)("span",{className:"text-[10px] text-slate-400",children:r?.model}),(0,t.jsx)("button",{type:"button",className:"opacity-0 group-hover/agent:opacity-100 text-slate-400 hover:text-red-500 transition-opacity",onClick:()=>void T(a.id,s.agent_id),title:"Remove from project",children:(0,t.jsx)(y.X,{size:14})})]},s.agent_id)}),(0,t.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:()=>{I(new Set),z({projectId:a.id})},children:[(0,t.jsx)(m.Plus,{size:12}),"Add agents"]}),r.length>0&&(0,t.jsxs)("div",{className:"mt-2 pt-2 border-t border-slate-100",children:[(0,t.jsx)("p",{className:"text-[10px] font-medium text-slate-400 uppercase tracking-wide mb-1",children:"Threads"}),(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5",children:r.map((e,a)=>(0,t.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,t.jsx)(p.Hash,{size:11}),e]},a))})]})]})]},a.id)})})]})]}),R&&(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30",onClick:()=>F(!1),children:(0,t.jsxs)("div",{className:"bg-white rounded-xl shadow-xl border border-slate-200 w-[440px] max-h-[80vh] flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-5 py-3.5 border-b border-slate-100",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-slate-900",children:"Share Agents"}),(0,t.jsx)("button",{type:"button",className:"text-slate-400 hover:text-slate-600",onClick:()=>F(!1),children:(0,t.jsx)(y.X,{size:16})})]}),X?(0,t.jsxs)("div",{className:"px-5 py-6 flex flex-col items-center gap-4",children:[(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsx)("p",{className:"text-sm text-slate-600 mb-3",children:"Share this code with the recipient:"}),(0,t.jsxs)("div",{className:"flex items-center justify-center gap-3",children:[(0,t.jsx)("span",{className:"text-3xl font-mono font-bold tracking-[0.3em] text-slate-900",children:X}),(0,t.jsx)("button",{type:"button",className:"p-2 text-slate-400 hover:text-slate-600 transition-colors",onClick:()=>{X&&(navigator.clipboard.writeText(X),Y(!0),setTimeout(()=>Y(!1),2e3))},children:G?(0,t.jsx)(o.Check,{size:18,className:"text-green-500"}):(0,t.jsx)(i.Copy,{size:18})})]})]}),Z&&(0,t.jsxs)("p",{className:"text-[11px] text-slate-400",children:["Expires ",new Date(Z).toLocaleTimeString()]}),(0,t.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:()=>F(!1),children:"Done"})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"overflow-y-auto flex-1",children:[ek.length>0&&(0,t.jsxs)("div",{className:"border-b border-slate-100 px-5 py-3",children:[(0,t.jsx)("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wide mb-2",children:"Select by project"}),(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5",children:ek.map(a=>{let s=a.agents.map(e=>e.agent_id),r=s.length>0&&s.every(e=>B.has(e)),n=s.some(e=>B.has(e));return(0,t.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 ${r?"bg-slate-900 text-white":n?"bg-slate-300 text-slate-700":"bg-slate-100 text-slate-600 hover:bg-slate-200"}`,onClick:()=>{J(e=>{let t=new Set(e);return r?s.forEach(e=>t.delete(e)):s.forEach(e=>t.add(e)),t})},title:s.map(t=>e.find(e=>e.id===t)?.name??t).join(", "),children:[(0,t.jsx)(g.Users,{size:10}),a.name,(0,t.jsx)("span",{className:`text-[10px] ${r?"text-slate-300":"text-slate-400"}`,children:a.agents.length})]},a.id)})})]}),(0,t.jsxs)("div",{className:"border-b border-slate-100",children:[(0,t.jsxs)("div",{className:"px-5 pt-3 pb-1 flex items-center justify-between",children:[(0,t.jsx)("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wide",children:"Agents"}),(0,t.jsx)("button",{type:"button",className:"text-[11px] text-slate-400 hover:text-slate-600",onClick:()=>{B.size===e.length?J(new Set):J(new Set(e.map(e=>e.id)))},children:B.size===e.length?"Deselect all":"Select all"})]}),e.map(e=>{let a=B.has(e.id);return(0,t.jsxs)("button",{type:"button",className:`w-full flex items-center gap-3 px-5 py-2 text-sm transition-colors ${a?"bg-slate-50 text-slate-900":"text-slate-600 hover:bg-slate-50"}`,onClick:()=>{J(t=>{let a=new Set(t);return a.has(e.id)?a.delete(e.id):a.add(e.id),a})},children:[(0,t.jsx)(eO,{checked:a}),(0,t.jsx)("img",{src:(0,b.agentAvatarUrl)(e.id,24,e.color),alt:"",className:"w-6 h-6 rounded-full flex-shrink-0"}),(0,t.jsx)("span",{className:"truncate text-xs font-medium flex-1",children:e.name}),(0,t.jsx)("span",{className:"text-[10px] text-slate-400",children:e.provider})]},e.id)})]}),(0,t.jsx)("div",{className:"px-5 py-3",children:(0,t.jsxs)("button",{type:"button",className:`flex items-center gap-3 w-full px-3 py-2 rounded-lg text-sm transition-colors ${H?"bg-slate-50 text-slate-900":"text-slate-600 hover:bg-slate-50"}`,onClick:()=>K(!H),children:[(0,t.jsx)(eO,{checked:H}),(0,t.jsx)("span",{className:"text-xs font-medium",children:"Include self.md (agent bio)"})]})})]}),(0,t.jsxs)("div",{className:"px-5 py-3 border-t border-slate-100 flex items-center justify-between",children:[(0,t.jsxs)("span",{className:"text-[11px] text-slate-400",children:[B.size," ",1===B.size?"agent":"agents"]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsxs)("button",{type:"button",disabled:0===B.size||V,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 eC(),children:[(0,t.jsx)(c.Download,{size:12}),V?"Exporting...":"Export to File"]}),(0,t.jsxs)("button",{type:"button",disabled:0===B.size||V,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 eS(),children:[(0,t.jsx)(h,{size:12}),V?"Pushing...":"Push to Hub"]}),(0,t.jsx)("button",{type:"button",className:"px-3 py-1.5 text-xs text-slate-500 hover:text-slate-700 transition-colors",onClick:()=>F(!1),children:"Cancel"})]})]})]})]})}),O&&!L&&(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30",onClick:()=>z(null),children:(0,t.jsxs)("div",{className:"bg-white rounded-xl shadow-xl border border-slate-200 w-80 max-h-[70vh] flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-slate-100",children:[(0,t.jsxs)("h3",{className:"text-sm font-medium text-slate-900",children:["Add to ",eE?.name??"project"]}),(0,t.jsx)("button",{type:"button",className:"text-slate-400 hover:text-slate-600",onClick:()=>z(null),children:(0,t.jsx)(y.X,{size:16})})]}),(0,t.jsxs)("div",{className:"overflow-y-auto py-1 flex-1",children:[(0,t.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:()=>M(!0),children:[(0,t.jsx)(m.Plus,{size:14,className:"text-slate-400"}),(0,t.jsx)("span",{className:"text-xs font-medium",children:"Create new agent"})]}),0===eP.length?(0,t.jsx)("p",{className:"px-4 py-6 text-xs text-slate-400 text-center",children:"All agents are already in this project"}):eP.map(e=>{let a=$.has(e.id);return(0,t.jsxs)("button",{type:"button",className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${a?"bg-slate-100 text-slate-900":"text-slate-700 hover:bg-slate-50"}`,onClick:()=>{I(t=>{let a=new Set(t);return a.has(e.id)?a.delete(e.id):a.add(e.id),a})},children:[(0,t.jsx)(eO,{checked:a}),(0,t.jsx)("img",{src:(0,b.agentAvatarUrl)(e.id,24,e.color),alt:"",className:"w-6 h-6 rounded-full flex-shrink-0"}),(0,t.jsx)("div",{className:"min-w-0 flex-1 text-left",children:(0,t.jsx)("div",{className:"truncate font-medium text-xs",children:e.name})})]},e.id)})]}),eP.length>0&&(0,t.jsxs)("div",{className:"px-4 py-3 border-t border-slate-100 flex justify-end gap-2",children:[(0,t.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,t.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 e of $)A(O.projectId,e);z(null)},children:["Add ",$.size>0?`(${$.size})`:""]})]})]})}),L&&(0,t.jsx)(b.AgentForm,{title:"Create new agent",initial:{name:"",provider:"claude",model:"",identity:"",skills:[]},submitLabel:"Create",projects:ek.map(e=>{let t=(e.thread_ids??[]).map(e=>eN.get(e)?.title?.trim()).filter(Boolean).join(", ")||"No thread";return{id:e.id,name:e.name,label:`${t} › ${e.name}`}}),initialProjectIds:O?[O.projectId]:[],onSubmit:async(t,a)=>{let s=["#D97706","#2563EB","#059669","#DC2626","#7C3AED","#DB2777","#0891B2"],r=s[e.length%s.length],n=t.name.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""),l=a?.[0],i=await fetch("/api/participants",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:n,name:t.name,provider:t.provider,model:t.model,color:t.color??r,...t.identity?{identity:t.identity}:{},skills:t.skills??[],...l?{projectId:l}:{}})});if(i.ok){let e=await i.json().catch(()=>({})),t="string"==typeof e?.id&&e.id.trim()?e.id.trim():n;for(let e of(a??[]).slice(1))await A(e,t);M(!1),z(null),ev(),E()}},onCancel:()=>{M(!1)}}),U&&(0,t.jsx)(b.AgentForm,{title:"Edit agent",initial:{name:U.name,provider:U.provider,model:U.model||"",identity:U.identity||"",color:U.color,skills:U.skills||[]},agentId:U.id,submitLabel:"Save",projectMemberships:{current:S.filter(e=>e.agents.some(e=>e.agent_id===U.id)).map(e=>({id:e.id,name:e.name,is_default:!!e.is_default})),available:S.filter(e=>!e.agents.some(e=>e.agent_id===U.id)).map(e=>({id:e.id,name:e.name}))},onAddToProject:e=>A(e,U.id),onRemoveFromProject:e=>T(e,U.id),onSubmit:async e=>{await fetch("/api/participants",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:U.id,name:e.name,provider:e.provider,model:e.model,color:e.color,...e.identity?{identity:e.identity}:{},skills:e.skills??[]})}),D(null),ev()},onCancel:()=>D(null)}),ee&&(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30",onClick:()=>et(!1),children:(0,t.jsxs)("div",{className:"bg-white rounded-xl shadow-xl border border-slate-200 w-[440px] max-h-[80vh] flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-5 py-3.5 border-b border-slate-100",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-slate-900",children:"Import Agents"}),(0,t.jsx)("button",{type:"button",className:"text-slate-400 hover:text-slate-600",onClick:()=>et(!1),children:(0,t.jsx)(y.X,{size:16})})]}),"choice"===ea&&!eo&&(0,t.jsxs)("div",{className:"px-5 py-6 flex flex-col gap-3",children:[(0,t.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:()=>es("pull"),children:[(0,t.jsx)("div",{className:"w-9 h-9 rounded-lg bg-violet-100 flex items-center justify-center flex-shrink-0",children:(0,t.jsx)(c.Download,{size:16,className:"text-violet-600"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium text-slate-900",children:"Pull from Hub"}),(0,t.jsx)("p",{className:"text-[11px] text-slate-400",children:"Enter a share code to import agents"})]})]}),(0,t.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:()=>{es("file"),setTimeout(()=>ey.current?.click(),100)},children:[(0,t.jsx)("div",{className:"w-9 h-9 rounded-lg bg-slate-100 flex items-center justify-center flex-shrink-0",children:(0,t.jsx)(f,{size:16,className:"text-slate-600"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium text-slate-900",children:"Upload File"}),(0,t.jsx)("p",{className:"text-[11px] text-slate-400",children:"Import from a .agent.json bundle"})]})]})]}),"pull"===ea&&!eo&&(0,t.jsxs)("div",{className:"px-5 py-5 flex flex-col gap-3",children:[(0,t.jsx)("label",{className:"text-sm text-slate-600",children:"Enter share code:"}),(0,t.jsx)("input",{autoFocus:!0,type:"text",value:er,onChange:e=>en(e.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:e=>{"Enter"===e.key&&eA()}}),ef&&(0,t.jsx)("p",{className:"text-xs text-red-500",children:ef}),(0,t.jsxs)("div",{className:"flex justify-end gap-2 mt-1",children:[(0,t.jsx)("button",{type:"button",className:"px-3 py-1.5 text-xs text-slate-500 hover:text-slate-700 transition-colors",onClick:()=>{es("choice"),eg(null)},children:"Back"}),(0,t.jsx)("button",{type:"button",disabled:0===er.trim().length||el,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 eA(),children:el?"Fetching...":"Fetch"})]})]}),"file"===ea&&!eo&&(0,t.jsxs)("div",{className:"px-5 py-6 flex flex-col items-center gap-3",children:[(0,t.jsx)("p",{className:"text-sm text-slate-500",children:"Select a .agent.json file to import"}),(0,t.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:()=>ey.current?.click(),children:[(0,t.jsx)(f,{size:13}),"Choose File"]}),ef&&(0,t.jsx)("p",{className:"text-xs text-red-500",children:ef}),(0,t.jsx)("button",{type:"button",className:"text-xs text-slate-400 hover:text-slate-600 mt-1",onClick:()=>{es("choice"),eg(null)},children:"Back"})]}),eo&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"overflow-y-auto flex-1",children:[eo.exportedAt&&(0,t.jsx)("div",{className:"px-5 py-3 border-b border-slate-100 bg-slate-50",children:(0,t.jsxs)("p",{className:"text-[11px] text-slate-400",children:["Exported ",new Date(eo.exportedAt).toLocaleDateString()," · ",eo.agents.length," agents",w(eo).length>0?`, ${w(eo).length} projects`:""]})}),(0,t.jsxs)("div",{className:"border-b border-slate-100",children:[(0,t.jsxs)("div",{className:"px-5 pt-3 pb-1 flex items-center justify-between",children:[(0,t.jsxs)("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wide",children:[eo.agents.length," agent",1===eo.agents.length?"":"s"," found"]}),(0,t.jsx)("button",{type:"button",className:"text-[11px] text-slate-400 hover:text-slate-600",onClick:()=>{ed.size===eo.agents.length?eu(new Set):eu(new Set(eo.agents.map(e=>e.id)))},children:ed.size===eo.agents.length?"Deselect all":"Select all"})]}),eo.agents.map(a=>{let s=ed.has(a.id),r=e.find(e=>e.id===a.id);return(0,t.jsxs)("button",{type:"button",className:`w-full flex items-center gap-3 px-5 py-2.5 text-sm transition-colors ${s?"bg-slate-50 text-slate-900":"text-slate-600 hover:bg-slate-50"}`,onClick:()=>{eu(e=>{let t=new Set(e);return t.has(a.id)?t.delete(a.id):t.add(a.id),t})},children:[(0,t.jsx)(eO,{checked:s}),(0,t.jsx)("img",{src:(0,b.agentAvatarUrl)(a.id,24,a.color),alt:"",className:"w-6 h-6 rounded-full flex-shrink-0"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1 text-left",children:[(0,t.jsx)("div",{className:"truncate text-xs font-medium",children:a.name}),(0,t.jsxs)("div",{className:"truncate text-[10px] text-slate-400",children:[a.provider,a.model?` \xb7 ${a.model}`:""]})]}),r&&(0,t.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-50 text-amber-600 flex-shrink-0",children:"update"}),!r&&(0,t.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-green-50 text-green-600 flex-shrink-0",children:"new"}),a.self&&(0,t.jsx)("span",{className:"text-[10px] text-slate-400 flex-shrink-0",children:"+ self.md"})]},a.id)})]}),w(eo).length>0&&(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"px-5 pt-3 pb-1",children:(0,t.jsx)("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wide",children:"Projects"})}),w(eo).map(e=>{let a=ep.has(e.name);return(0,t.jsxs)("button",{type:"button",className:`w-full flex items-center gap-3 px-5 py-2 text-sm transition-colors ${a?"bg-slate-50 text-slate-900":"text-slate-600 hover:bg-slate-50"}`,onClick:()=>{ex(t=>{let a=new Set(t);return a.has(e.name)?a.delete(e.name):a.add(e.name),a})},children:[(0,t.jsx)(eO,{checked:a}),(0,t.jsx)(g.Users,{size:14,className:"text-slate-400 flex-shrink-0"}),(0,t.jsx)("span",{className:"truncate text-xs font-medium flex-1",children:e.name}),(0,t.jsxs)("span",{className:"text-[10px] text-slate-400",children:[e.agentIds.length," agents"]})]},e.name)})]})]}),ef&&(0,t.jsx)("div",{className:"px-5 py-2",children:(0,t.jsx)("p",{className:"text-xs text-red-500",children:ef})}),(0,t.jsxs)("div",{className:"px-5 py-3 border-t border-slate-100 flex items-center justify-between",children:[(0,t.jsxs)("span",{className:"text-[11px] text-slate-400",children:[ed.size," ",1===ed.size?"agent":"agents",ep.size>0?`, ${ep.size} ${1===ep.size?"project":"projects"}`:""]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("button",{type:"button",className:"px-3 py-1.5 text-xs text-slate-500 hover:text-slate-700 transition-colors",onClick:()=>{ec(null),eu(new Set),ex(new Set)},children:"Back"}),(0,t.jsxs)("button",{type:"button",disabled:0===ed.size||em,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 eT(),children:[(0,t.jsx)(f,{size:12}),em?"Importing...":`Import ${ed.size} agent${1===ed.size?"":"s"}`]})]})]})]})]})})]})}e.s(["default",()=>N],61628)}]);
|
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
Pencil,
|
|
15
15
|
Plus,
|
|
16
16
|
Share2,
|
|
17
|
-
Trash2,
|
|
18
17
|
Upload,
|
|
19
18
|
Users,
|
|
20
19
|
X,
|
|
@@ -65,23 +64,15 @@ export default function AgentLibraryPage() {
|
|
|
65
64
|
const {
|
|
66
65
|
projects,
|
|
67
66
|
createProject,
|
|
68
|
-
deleteProject,
|
|
69
|
-
renameProject,
|
|
70
67
|
addAgent: addAgentToProject,
|
|
71
68
|
removeAgent: removeAgentFromProject,
|
|
72
69
|
refresh: refreshProjects,
|
|
73
70
|
} = useProjectsWithAgents();
|
|
74
71
|
|
|
75
72
|
const [expandedProjects, setExpandedProjects] = useState<Set<string>>(new Set());
|
|
76
|
-
const [createModal, setCreateModal] = useState(false);
|
|
77
|
-
const [createName, setCreateName] = useState("");
|
|
78
|
-
const [createAgents, setCreateAgents] = useState<Set<string>>(new Set());
|
|
79
|
-
const [createWorkspaces, setCreateWorkspaces] = useState<Set<string>>(new Set());
|
|
80
73
|
const [addAgentModal, setAddAgentModal] = useState<{ projectId: string } | null>(null);
|
|
81
74
|
const [addAgentSelection, setAddAgentSelection] = useState<Set<string>>(new Set());
|
|
82
75
|
const [creatingNewAgent, setCreatingNewAgent] = useState(false);
|
|
83
|
-
const [renameModal, setRenameModal] = useState<{ projectId: string; currentName: string } | null>(null);
|
|
84
|
-
const [renameValue, setRenameValue] = useState("");
|
|
85
76
|
|
|
86
77
|
// Edit agent state
|
|
87
78
|
const [editAgent, setEditAgent] = useState<Participant | null>(null);
|
|
@@ -151,24 +142,6 @@ export default function AgentLibraryPage() {
|
|
|
151
142
|
});
|
|
152
143
|
};
|
|
153
144
|
|
|
154
|
-
const handleCreateSubmit = async () => {
|
|
155
|
-
if (!createName.trim()) return;
|
|
156
|
-
const wsIds = Array.from(createWorkspaces);
|
|
157
|
-
const project = await createProject(createName.trim(), wsIds.length > 0 ? wsIds : undefined);
|
|
158
|
-
if (project) {
|
|
159
|
-
for (const agentId of createAgents) {
|
|
160
|
-
await addAgentToProject(project.id, agentId);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
setCreateModal(false);
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
const handleRenameSubmit = async () => {
|
|
167
|
-
if (!renameModal || !renameValue.trim()) return;
|
|
168
|
-
await renameProject(renameModal.projectId, renameValue.trim());
|
|
169
|
-
setRenameModal(null);
|
|
170
|
-
};
|
|
171
|
-
|
|
172
145
|
// ── Outbound (Share / Export) ──────────────────────────────────────
|
|
173
146
|
|
|
174
147
|
const openOutboundModal = () => {
|
|
@@ -515,25 +488,13 @@ export default function AgentLibraryPage() {
|
|
|
515
488
|
|
|
516
489
|
{/* Projects Section */}
|
|
517
490
|
<div className="mt-10">
|
|
518
|
-
<div className="
|
|
519
|
-
<h2 className="text-lg font-semibold text-slate-900">
|
|
520
|
-
<
|
|
521
|
-
type="button"
|
|
522
|
-
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"
|
|
523
|
-
onClick={() => {
|
|
524
|
-
setCreateName("");
|
|
525
|
-
setCreateAgents(new Set());
|
|
526
|
-
setCreateWorkspaces(new Set());
|
|
527
|
-
setCreateModal(true);
|
|
528
|
-
}}
|
|
529
|
-
>
|
|
530
|
-
<Plus size={13} />
|
|
531
|
-
Add project
|
|
532
|
-
</button>
|
|
491
|
+
<div className="mb-4">
|
|
492
|
+
<h2 className="text-lg font-semibold text-slate-900">Project assignments</h2>
|
|
493
|
+
<p className="mt-1 text-sm text-slate-400">Assign agents to existing projects.</p>
|
|
533
494
|
</div>
|
|
534
495
|
|
|
535
496
|
{nonDefaultProjects.length === 0 ? (
|
|
536
|
-
<p className="text-sm text-slate-400">No projects
|
|
497
|
+
<p className="text-sm text-slate-400">No projects available for assignment.</p>
|
|
537
498
|
) : (
|
|
538
499
|
<div className="bg-white rounded-xl border border-slate-200 divide-y divide-slate-100">
|
|
539
500
|
{nonDefaultProjects.map((project) => {
|
|
@@ -565,33 +526,15 @@ export default function AgentLibraryPage() {
|
|
|
565
526
|
<div className="flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity">
|
|
566
527
|
<button
|
|
567
528
|
type="button"
|
|
568
|
-
className="
|
|
569
|
-
title="Add
|
|
529
|
+
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"
|
|
530
|
+
title="Add agents"
|
|
570
531
|
onClick={() => {
|
|
571
532
|
setAddAgentSelection(new Set());
|
|
572
533
|
setAddAgentModal({ projectId: project.id });
|
|
573
534
|
}}
|
|
574
535
|
>
|
|
575
536
|
<Plus size={14} />
|
|
576
|
-
|
|
577
|
-
<button
|
|
578
|
-
type="button"
|
|
579
|
-
className="p-1.5 text-slate-400 hover:text-slate-600 rounded hover:bg-slate-50 transition-colors"
|
|
580
|
-
title="Rename project"
|
|
581
|
-
onClick={() => {
|
|
582
|
-
setRenameValue(project.name);
|
|
583
|
-
setRenameModal({ projectId: project.id, currentName: project.name });
|
|
584
|
-
}}
|
|
585
|
-
>
|
|
586
|
-
<Pencil size={13} />
|
|
587
|
-
</button>
|
|
588
|
-
<button
|
|
589
|
-
type="button"
|
|
590
|
-
className="p-1.5 text-slate-400 hover:text-red-500 rounded hover:bg-slate-50 transition-colors"
|
|
591
|
-
title="Delete project"
|
|
592
|
-
onClick={() => void deleteProject(project.id)}
|
|
593
|
-
>
|
|
594
|
-
<Trash2 size={13} />
|
|
537
|
+
Add agents
|
|
595
538
|
</button>
|
|
596
539
|
</div>
|
|
597
540
|
</div>
|
|
@@ -629,6 +572,18 @@ export default function AgentLibraryPage() {
|
|
|
629
572
|
);
|
|
630
573
|
})}
|
|
631
574
|
|
|
575
|
+
<button
|
|
576
|
+
type="button"
|
|
577
|
+
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"
|
|
578
|
+
onClick={() => {
|
|
579
|
+
setAddAgentSelection(new Set());
|
|
580
|
+
setAddAgentModal({ projectId: project.id });
|
|
581
|
+
}}
|
|
582
|
+
>
|
|
583
|
+
<Plus size={12} />
|
|
584
|
+
Add agents
|
|
585
|
+
</button>
|
|
586
|
+
|
|
632
587
|
{threadNames.length > 0 && (
|
|
633
588
|
<div className="mt-2 pt-2 border-t border-slate-100">
|
|
634
589
|
<p className="text-[10px] font-medium text-slate-400 uppercase tracking-wide mb-1">Threads</p>
|
|
@@ -833,115 +788,6 @@ export default function AgentLibraryPage() {
|
|
|
833
788
|
</div>
|
|
834
789
|
)}
|
|
835
790
|
|
|
836
|
-
{/* ── Create Project Modal ──────────────────────────────────────────── */}
|
|
837
|
-
{createModal && (
|
|
838
|
-
<div
|
|
839
|
-
className="fixed inset-0 z-50 flex items-center justify-center bg-black/30"
|
|
840
|
-
onClick={() => setCreateModal(false)}
|
|
841
|
-
>
|
|
842
|
-
<div
|
|
843
|
-
className="bg-white rounded-xl shadow-xl border border-slate-200 w-[420px] max-h-[80vh] flex flex-col"
|
|
844
|
-
onClick={(e) => e.stopPropagation()}
|
|
845
|
-
>
|
|
846
|
-
<div className="flex items-center justify-between px-5 py-3.5 border-b border-slate-100">
|
|
847
|
-
<h3 className="text-sm font-medium text-slate-900">Create project</h3>
|
|
848
|
-
<button type="button" className="text-slate-400 hover:text-slate-600" onClick={() => setCreateModal(false)}>
|
|
849
|
-
<X size={16} />
|
|
850
|
-
</button>
|
|
851
|
-
</div>
|
|
852
|
-
|
|
853
|
-
<div className="overflow-y-auto flex-1">
|
|
854
|
-
<div className="px-5 py-3 border-b border-slate-100">
|
|
855
|
-
<label className="text-[11px] font-medium text-slate-400 uppercase tracking-wide block mb-1.5">Name</label>
|
|
856
|
-
<input
|
|
857
|
-
autoFocus
|
|
858
|
-
type="text"
|
|
859
|
-
value={createName}
|
|
860
|
-
onChange={(e) => setCreateName(e.target.value)}
|
|
861
|
-
placeholder="e.g. Frontend Crew"
|
|
862
|
-
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"
|
|
863
|
-
/>
|
|
864
|
-
</div>
|
|
865
|
-
|
|
866
|
-
<div className="px-5 py-3 border-b border-slate-100">
|
|
867
|
-
<label className="text-[11px] font-medium text-slate-400 uppercase tracking-wide block mb-1.5">Threads</label>
|
|
868
|
-
{threads.length === 0 ? (
|
|
869
|
-
<p className="text-xs text-slate-400">No threads available.</p>
|
|
870
|
-
) : (
|
|
871
|
-
<div className="flex flex-col gap-0.5">
|
|
872
|
-
{threads.map((ws) => {
|
|
873
|
-
const selected = createWorkspaces.has(ws.id);
|
|
874
|
-
const title = ws.title?.trim() || "Untitled";
|
|
875
|
-
return (
|
|
876
|
-
<button
|
|
877
|
-
key={ws.id}
|
|
878
|
-
type="button"
|
|
879
|
-
className={`flex items-center gap-2.5 px-3 py-2 rounded-lg text-sm transition-colors ${selected ? "bg-indigo-50 text-indigo-700" : "text-slate-600 hover:bg-slate-50"}`}
|
|
880
|
-
onClick={() => {
|
|
881
|
-
setCreateWorkspaces((prev) => {
|
|
882
|
-
const next = new Set(prev);
|
|
883
|
-
if (next.has(ws.id)) next.delete(ws.id);
|
|
884
|
-
else next.add(ws.id);
|
|
885
|
-
return next;
|
|
886
|
-
});
|
|
887
|
-
}}
|
|
888
|
-
>
|
|
889
|
-
<div className={`w-4 h-4 rounded border flex-shrink-0 flex items-center justify-center ${selected ? "bg-indigo-600 border-indigo-600" : "border-slate-300"}`}>
|
|
890
|
-
{selected && (
|
|
891
|
-
<svg width="10" height="10" viewBox="0 0 10 10" fill="none"><path d="M2 5l2 2 4-4" stroke="white" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round"/></svg>
|
|
892
|
-
)}
|
|
893
|
-
</div>
|
|
894
|
-
<Hash size={13} className="flex-shrink-0 text-slate-400" />
|
|
895
|
-
<span className="truncate text-xs font-medium">{title}</span>
|
|
896
|
-
</button>
|
|
897
|
-
);
|
|
898
|
-
})}
|
|
899
|
-
</div>
|
|
900
|
-
)}
|
|
901
|
-
</div>
|
|
902
|
-
|
|
903
|
-
<div className="py-1">
|
|
904
|
-
<p className="px-5 py-1.5 text-[11px] font-medium text-slate-400 uppercase tracking-wide">Agents</p>
|
|
905
|
-
{participants.map((p) => {
|
|
906
|
-
const selected = createAgents.has(p.id);
|
|
907
|
-
return (
|
|
908
|
-
<button
|
|
909
|
-
key={p.id}
|
|
910
|
-
type="button"
|
|
911
|
-
className={`w-full flex items-center gap-3 px-5 py-2 text-sm transition-colors ${selected ? "bg-slate-100 text-slate-900" : "text-slate-700 hover:bg-slate-50"}`}
|
|
912
|
-
onClick={() => {
|
|
913
|
-
setCreateAgents((prev) => {
|
|
914
|
-
const next = new Set(prev);
|
|
915
|
-
if (next.has(p.id)) next.delete(p.id);
|
|
916
|
-
else next.add(p.id);
|
|
917
|
-
return next;
|
|
918
|
-
});
|
|
919
|
-
}}
|
|
920
|
-
>
|
|
921
|
-
<Checkbox checked={selected} />
|
|
922
|
-
<img src={agentAvatarUrl(p.id, 24, p.color)} alt="" className="w-6 h-6 rounded-full flex-shrink-0" />
|
|
923
|
-
<span className="truncate text-xs font-medium">{p.name}</span>
|
|
924
|
-
</button>
|
|
925
|
-
);
|
|
926
|
-
})}
|
|
927
|
-
</div>
|
|
928
|
-
</div>
|
|
929
|
-
|
|
930
|
-
<div className="px-5 py-3 border-t border-slate-100 flex justify-end gap-2">
|
|
931
|
-
<button type="button" className="px-3 py-1.5 text-xs text-slate-500 hover:text-slate-700 transition-colors" onClick={() => setCreateModal(false)}>Cancel</button>
|
|
932
|
-
<button
|
|
933
|
-
type="button"
|
|
934
|
-
disabled={!createName.trim()}
|
|
935
|
-
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"
|
|
936
|
-
onClick={() => void handleCreateSubmit()}
|
|
937
|
-
>
|
|
938
|
-
Create
|
|
939
|
-
</button>
|
|
940
|
-
</div>
|
|
941
|
-
</div>
|
|
942
|
-
</div>
|
|
943
|
-
)}
|
|
944
|
-
|
|
945
791
|
{/* ── Add Agent to Project Modal ────────────────────────────────────── */}
|
|
946
792
|
{addAgentModal && !creatingNewAgent && (
|
|
947
793
|
<div
|
|
@@ -1105,47 +951,6 @@ export default function AgentLibraryPage() {
|
|
|
1105
951
|
/>
|
|
1106
952
|
)}
|
|
1107
953
|
|
|
1108
|
-
{/* ── Rename Project Modal ──────────────────────────────────────────── */}
|
|
1109
|
-
{renameModal && (
|
|
1110
|
-
<div
|
|
1111
|
-
className="fixed inset-0 z-50 flex items-center justify-center bg-black/30"
|
|
1112
|
-
onClick={() => setRenameModal(null)}
|
|
1113
|
-
>
|
|
1114
|
-
<div
|
|
1115
|
-
className="bg-white rounded-xl shadow-xl border border-slate-200 w-80 flex flex-col"
|
|
1116
|
-
onClick={(e) => e.stopPropagation()}
|
|
1117
|
-
>
|
|
1118
|
-
<div className="flex items-center justify-between px-4 py-3 border-b border-slate-100">
|
|
1119
|
-
<h3 className="text-sm font-medium text-slate-900">Rename project</h3>
|
|
1120
|
-
<button type="button" className="text-slate-400 hover:text-slate-600" onClick={() => setRenameModal(null)}><X size={16} /></button>
|
|
1121
|
-
</div>
|
|
1122
|
-
<form
|
|
1123
|
-
className="px-4 py-4 flex flex-col gap-3"
|
|
1124
|
-
onSubmit={(e) => { e.preventDefault(); void handleRenameSubmit(); }}
|
|
1125
|
-
>
|
|
1126
|
-
<input
|
|
1127
|
-
autoFocus
|
|
1128
|
-
type="text"
|
|
1129
|
-
value={renameValue}
|
|
1130
|
-
onChange={(e) => setRenameValue(e.target.value)}
|
|
1131
|
-
placeholder="Project name"
|
|
1132
|
-
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"
|
|
1133
|
-
/>
|
|
1134
|
-
<div className="flex justify-end gap-2">
|
|
1135
|
-
<button type="button" className="px-3 py-1.5 text-xs text-slate-500 hover:text-slate-700 transition-colors" onClick={() => setRenameModal(null)}>Cancel</button>
|
|
1136
|
-
<button
|
|
1137
|
-
type="submit"
|
|
1138
|
-
disabled={!renameValue.trim() || renameValue.trim() === renameModal.currentName}
|
|
1139
|
-
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"
|
|
1140
|
-
>
|
|
1141
|
-
Save
|
|
1142
|
-
</button>
|
|
1143
|
-
</div>
|
|
1144
|
-
</form>
|
|
1145
|
-
</div>
|
|
1146
|
-
</div>
|
|
1147
|
-
)}
|
|
1148
|
-
|
|
1149
954
|
{/* ── Inbound Modal (Import: Pull from Hub / Upload File) ────────── */}
|
|
1150
955
|
{inboundModal && (
|
|
1151
956
|
<div
|